mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-12-24 11:16:11 +00:00
166318ba77
* sdmmc: begin skeletoning sdmmc driver * sdmmc: add most of SdHostStandardController * sdmmc: implement most of SdmmcController * sdmmc: Sdmmc2Controller * sdmmc: skeleton implementation of Sdmmc1Controller * sdmmc: complete abstract logic for Sdmmc1 power controller * sdmmc: implement gpio handling for sdmmc1-register-control * sdmmc: implement pinmux handling for sdmmc1-register-control * sdmmc: fix building for arm32 and in stratosphere context * sdmmc: implement voltage enable/set for sdmmc1-register-control * util: move T(V)SNPrintf from kernel to util * sdmmc: implement BaseDeviceAccessor * sdmmc: implement MmcDeviceAccessor * sdmmc: implement clock reset controller for register api * sdmmc: fix bug in WaitWhileCommandInhibit, add mmc accessors * exo: add sdmmc test program * sdmmc: fix speed mode extension, add CheckMmcConnection for debug * sdmmc: add DeviceDetector, gpio: implement client api * gpio: modernize client api instead of doing it the lazy way * sdmmc: SdCardDeviceAccessor impl * sdmmc: update test program to read first two sectors of sd card * sdmmc: fix vref sel * sdmmc: finish outward-facing api (untested) * ams: changes for libvapours including tegra register defs * sdmmc: remove hwinit
99 lines
3.4 KiB
C++
99 lines
3.4 KiB
C++
/*
|
|
* Copyright (c) 2018-2020 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 <http://www.gnu.org/licenses/>.
|
|
*/
|
|
#include <stratosphere.hpp>
|
|
#include "fatal_task_sound.hpp"
|
|
|
|
namespace ams::fatal::srv {
|
|
|
|
namespace {
|
|
|
|
/* Task definition. */
|
|
class StopSoundTask : public ITaskWithDefaultStack {
|
|
private:
|
|
void StopSound();
|
|
public:
|
|
virtual Result Run() override;
|
|
virtual const char *GetName() const override {
|
|
return "SoundTask";
|
|
}
|
|
};
|
|
|
|
/* Task global. */
|
|
StopSoundTask g_stop_sound_task;
|
|
|
|
/* Task implementation. */
|
|
void StopSoundTask::StopSound() {
|
|
/* Talk to the ALC5639 over I2C, and disable audio output. */
|
|
{
|
|
I2cSession audio;
|
|
if (R_SUCCEEDED(i2cOpenSession(&audio, I2cDevice_Alc5639))) {
|
|
ON_SCOPE_EXIT { i2csessionClose(&audio); };
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* Talk to the ALC5639 over GPIO, and disable audio output */
|
|
{
|
|
gpio::GpioPadSession audio;
|
|
if (R_SUCCEEDED(gpio::OpenSession(std::addressof(audio), gpio::DeviceCode_CodecLdoEnTemp))) {
|
|
ON_SCOPE_EXIT { gpio::CloseSession(std::addressof(audio)); };
|
|
|
|
/* Set direction output, sleep 200 ms so it can take effect. */
|
|
gpio::SetDirection(std::addressof(audio), gpio::Direction_Output);
|
|
os::SleepThread(TimeSpan::FromMilliSeconds(200));
|
|
|
|
/* Pull audio codec low. */
|
|
gpio::SetValue(std::addressof(audio), gpio::GpioValue_Low);
|
|
}
|
|
}
|
|
}
|
|
|
|
Result StopSoundTask::Run() {
|
|
StopSound();
|
|
return ResultSuccess();
|
|
}
|
|
|
|
}
|
|
|
|
ITask *GetStopSoundTask(const ThrowContext *ctx) {
|
|
g_stop_sound_task.Initialize(ctx);
|
|
return &g_stop_sound_task;
|
|
}
|
|
|
|
}
|