diff --git a/stratosphere/fatal/source/fatal_main.cpp b/stratosphere/fatal/source/fatal_main.cpp
index e5f1065ce..9ed72b2e6 100644
--- a/stratosphere/fatal/source/fatal_main.cpp
+++ b/stratosphere/fatal/source/fatal_main.cpp
@@ -72,6 +72,11 @@ void __appInit(void) {
std::abort();
}
+ rc = i2cInitialize();
+ if (R_FAILED(rc)) {
+ std::abort();
+ }
+
rc = bpcInitialize();
if (R_FAILED(rc)) {
std::abort();
@@ -107,6 +112,7 @@ void __appExit(void) {
lblExit();
pcvExit();
bpcExit();
+ i2cExit();
pminfoExit();
setsysExit();
smExit();
diff --git a/stratosphere/fatal/source/fatal_task.cpp b/stratosphere/fatal/source/fatal_task.cpp
index 51beefd7e..53c3c2853 100644
--- a/stratosphere/fatal/source/fatal_task.cpp
+++ b/stratosphere/fatal/source/fatal_task.cpp
@@ -20,6 +20,7 @@
#include "fatal_task_error_report.hpp"
#include "fatal_task_screen.hpp"
+#include "fatal_task_sound.hpp"
#include "fatal_task_clock.hpp"
#include "fatal_task_power.hpp"
@@ -56,7 +57,7 @@ void RunFatalTasks(FatalContext *ctx, u64 title_id, bool error_report, Event *er
RunTask(new ErrorReportTask(ctx, title_id, error_report, erpt_event));
RunTask(new PowerControlTask(ctx, title_id, erpt_event, battery_event));
/* TODO: RunTask(new ShowFatalTask(ctx, title_id, battery_event)); */
- /* TODO: RunTask(new StopSoundTask(ctx, title_id)); */
+ RunTask(new StopSoundTask(ctx, title_id));
RunTask(new BacklightControlTask(ctx, title_id));
RunTask(new AdjustClockTask(ctx, title_id));
RunTask(new PowerButtonObserveTask(ctx, title_id, erpt_event));
diff --git a/stratosphere/fatal/source/fatal_task_sound.cpp b/stratosphere/fatal/source/fatal_task_sound.cpp
new file mode 100644
index 000000000..9a08f331e
--- /dev/null
+++ b/stratosphere/fatal/source/fatal_task_sound.cpp
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2018 Atmosphère-NX
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include
+#include "fatal_task_sound.hpp"
+
+
+void StopSoundTask::StopSound() {
+ /* Talk to the ALC5639 over I2C, and disable audio output. */
+ I2cSession audio;
+ if (R_SUCCEEDED(i2cOpenSession(&audio, I2cDevice_AudioCodec))) {
+ struct {
+ u16 dev;
+ u8 val;
+ } __attribute__((packed)) cmd;
+ static_assert(sizeof(cmd) == 3, "I2C command definition!");
+
+ cmd.dev = 0xC801;
+ cmd.val = 200;
+ i2csessionSendAuto(&audio, &cmd, sizeof(cmd), I2cTransactionOption_All);
+
+ cmd.dev = 0xC802;
+ cmd.val = 200;
+ i2csessionSendAuto(&audio, &cmd, sizeof(cmd), I2cTransactionOption_All);
+
+ cmd.dev = 0xC802;
+ cmd.val = 200;
+ i2csessionSendAuto(&audio, &cmd, sizeof(cmd), I2cTransactionOption_All);
+
+ for (u16 dev = 97; dev <= 102; dev++) {
+ cmd.dev = dev;
+ cmd.val = 0;
+ i2csessionSendAuto(&audio, &cmd, sizeof(cmd), I2cTransactionOption_All);
+ }
+
+ i2csessionClose(&audio);
+ }
+
+ /* TODO: Talk to the ALC5639 over GPIO */
+}
+
+Result StopSoundTask::Run() {
+ StopSound();
+ return 0;
+}
\ No newline at end of file
diff --git a/stratosphere/fatal/source/fatal_task_sound.hpp b/stratosphere/fatal/source/fatal_task_sound.hpp
new file mode 100644
index 000000000..bbce20d4c
--- /dev/null
+++ b/stratosphere/fatal/source/fatal_task_sound.hpp
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2018 Atmosphère-NX
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#pragma once
+#include
+#include
+#include "fatal_task.hpp"
+
+class StopSoundTask : public IFatalTask {
+ private:
+ void StopSound();
+ public:
+ StopSoundTask(FatalContext *ctx, u64 title_id) : IFatalTask(ctx, title_id) { }
+ virtual Result Run() override;
+ virtual const char *GetName() const override {
+ return "SoundTask";
+ }
+};
\ No newline at end of file