From 0ca028cfbc5fe7d53fe985300dbc6efa817b1d42 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Tue, 10 Nov 2020 05:02:41 -0800 Subject: [PATCH] boot: various bugfixes (b/w logo displays now) --- .../source/i2c/driver/impl/i2c_i2c_session_impl.cpp | 12 ++++++------ libstratosphere/source/i2c/i2c_client_api.cpp | 12 ++++++++---- .../source/i2c/i2c_command_list_formatter.cpp | 6 +++--- .../nintendo_nx/impl/pwm_impl_pwm_driver_api.cpp | 4 ++-- .../board/nintendo_nx/impl/pwm_pwm_driver_impl.cpp | 2 +- libvapours/include/vapours/tegra/tegra_i2c.hpp | 2 +- libvapours/include/vapours/tegra/tegra_pinmux.hpp | 2 ++ 7 files changed, 23 insertions(+), 17 deletions(-) diff --git a/libstratosphere/source/i2c/driver/impl/i2c_i2c_session_impl.cpp b/libstratosphere/source/i2c/driver/impl/i2c_i2c_session_impl.cpp index 83c48991..413cc4ad 100644 --- a/libstratosphere/source/i2c/driver/impl/i2c_i2c_session_impl.cpp +++ b/libstratosphere/source/i2c/driver/impl/i2c_i2c_session_impl.cpp @@ -67,8 +67,8 @@ namespace ams::i2c::driver::impl { Result I2cSessionImpl::SendHandler(const u8 **cur_cmd, u8 **cur_dst) { /* Read the header bytes. */ - const util::BitPack8 hdr0{*(*cur_cmd++)}; - const util::BitPack8 hdr1{*(*cur_cmd++)}; + const util::BitPack8 hdr0{*((*cur_cmd)++)}; + const util::BitPack8 hdr1{*((*cur_cmd)++)}; /* Decode the header. */ const bool start = hdr0.Get(); @@ -86,8 +86,8 @@ namespace ams::i2c::driver::impl { Result I2cSessionImpl::ReceiveHandler(const u8 **cur_cmd, u8 **cur_dst) { /* Read the header bytes. */ - const util::BitPack8 hdr0{*(*cur_cmd++)}; - const util::BitPack8 hdr1{*(*cur_cmd++)}; + const util::BitPack8 hdr0{*((*cur_cmd)++)}; + const util::BitPack8 hdr1{*((*cur_cmd)++)}; /* Decode the header. */ const bool start = hdr0.Get(); @@ -105,13 +105,13 @@ namespace ams::i2c::driver::impl { Result I2cSessionImpl::ExtensionHandler(const u8 **cur_cmd, u8 **cur_dst) { /* Read the header bytes. */ - const util::BitPack8 hdr0{*(*cur_cmd++)}; + const util::BitPack8 hdr0{*((*cur_cmd)++)}; /* Execute the subcommand. */ switch (hdr0.Get()) { case i2c::impl::SubCommandId_Sleep: { - const util::BitPack8 param{*(*cur_cmd++)}; + const util::BitPack8 param{*((*cur_cmd)++)}; os::SleepThread(TimeSpan::FromMicroSeconds(param.Get())); } diff --git a/libstratosphere/source/i2c/i2c_client_api.cpp b/libstratosphere/source/i2c/i2c_client_api.cpp index f0acae7d..e8d3a74a 100644 --- a/libstratosphere/source/i2c/i2c_client_api.cpp +++ b/libstratosphere/source/i2c/i2c_client_api.cpp @@ -84,15 +84,19 @@ namespace ams::i2c { { std::scoped_lock lk(g_i2c_mutex); AMS_ASSERT(g_i2c_count > 0); - if ((--g_i2c_count) == 0) { - g_i2c_manager.reset(); + if (g_i2c_count > 0) { + if ((--g_i2c_count) == 0) { + g_i2c_manager.reset(); + } } } { std::scoped_lock lk(g_i2c_pcv_mutex); AMS_ASSERT(g_i2c_pcv_count > 0); - if ((--g_i2c_pcv_count) == 0) { - g_i2c_pcv_manager.reset(); + if (g_i2c_pcv_count > 0) { + if ((--g_i2c_pcv_count) == 0) { + g_i2c_pcv_manager.reset(); + } } } } diff --git a/libstratosphere/source/i2c/i2c_command_list_formatter.cpp b/libstratosphere/source/i2c/i2c_command_list_formatter.cpp index eaf6cbd3..37a6dc65 100644 --- a/libstratosphere/source/i2c/i2c_command_list_formatter.cpp +++ b/libstratosphere/source/i2c/i2c_command_list_formatter.cpp @@ -32,7 +32,7 @@ namespace ams::i2c { util::BitPack8 *cmd_list = static_cast(this->command_list); /* Get references to the header. */ - auto &header0 = cmd_list[this->current_index++]; + auto &header0 = cmd_list[this->current_index++]; auto &header1 = cmd_list[this->current_index++]; /* Set the header. */ @@ -54,7 +54,7 @@ namespace ams::i2c { util::BitPack8 *cmd_list = static_cast(this->command_list); /* Get references to the header. */ - auto &header0 = cmd_list[this->current_index++]; + auto &header0 = cmd_list[this->current_index++]; auto &header1 = cmd_list[this->current_index++]; /* Set the header. */ @@ -80,7 +80,7 @@ namespace ams::i2c { util::BitPack8 *cmd_list = static_cast(this->command_list); /* Get references to the header. */ - auto &header0 = cmd_list[this->current_index++]; + auto &header0 = cmd_list[this->current_index++]; auto &header1 = cmd_list[this->current_index++]; /* Set the header. */ diff --git a/libstratosphere/source/pwm/driver/board/nintendo_nx/impl/pwm_impl_pwm_driver_api.cpp b/libstratosphere/source/pwm/driver/board/nintendo_nx/impl/pwm_impl_pwm_driver_api.cpp index f292236c..1b1849d1 100644 --- a/libstratosphere/source/pwm/driver/board/nintendo_nx/impl/pwm_impl_pwm_driver_api.cpp +++ b/libstratosphere/source/pwm/driver/board/nintendo_nx/impl/pwm_impl_pwm_driver_api.cpp @@ -25,8 +25,8 @@ namespace ams::pwm::driver::board::nintendo_nx::impl { constexpr inline size_t PwmRegistersSize = 0x100; constexpr const ChannelDefinition SupportedChannels[] = { - { pwm::DeviceCode_CpuFan, 0 }, - { pwm::DeviceCode_LcdBacklight, 1 }, + { pwm::DeviceCode_LcdBacklight, 0 }, + { pwm::DeviceCode_CpuFan, 1 }, }; } diff --git a/libstratosphere/source/pwm/driver/board/nintendo_nx/impl/pwm_pwm_driver_impl.cpp b/libstratosphere/source/pwm/driver/board/nintendo_nx/impl/pwm_pwm_driver_impl.cpp index 0c2e2919..353148e5 100644 --- a/libstratosphere/source/pwm/driver/board/nintendo_nx/impl/pwm_pwm_driver_impl.cpp +++ b/libstratosphere/source/pwm/driver/board/nintendo_nx/impl/pwm_pwm_driver_impl.cpp @@ -141,7 +141,7 @@ namespace ams::pwm::driver::board::nintendo_nx::impl { AMS_ASSERT(device != nullptr); /* Validate the duty. */ - R_UNLESS(0 <= duty && duty < MaxDuty, pwm::ResultInvalidArgument()); + R_UNLESS(0 <= duty && duty <= MaxDuty, pwm::ResultInvalidArgument()); /* Acquire exclusive access to the device registers. */ std::scoped_lock lk(device->SafeCastTo()); diff --git a/libvapours/include/vapours/tegra/tegra_i2c.hpp b/libvapours/include/vapours/tegra/tegra_i2c.hpp index 5e09f792..3f7bd2a1 100644 --- a/libvapours/include/vapours/tegra/tegra_i2c.hpp +++ b/libvapours/include/vapours/tegra/tegra_i2c.hpp @@ -54,7 +54,7 @@ DEFINE_I2C_REG(I2C_CNFG_LENGTH, 1, 3); DEFINE_I2C_REG_BIT_ENUM(I2C_CNFG_CMD1, 6, WRITE, READ); DEFINE_I2C_REG_BIT_ENUM(I2C_CNFG_SEND, 9, NOP, GO); -DEFINE_I2C_REG_BIT_ENUM(I2C_CNFG_PACKET_MODE_EN, 9, NOP, GO); +DEFINE_I2C_REG_BIT_ENUM(I2C_CNFG_PACKET_MODE_EN, 10, NOP, GO); DEFINE_I2C_REG_BIT_ENUM(I2C_CNFG_NEW_MASTER_FSM, 11, DISABLE, ENABLE); DEFINE_I2C_REG_THREE_BIT_ENUM(I2C_CNFG_DEBOUNCE_CNT, 12, NO_DEBOUNCE, DEBOUNCE_2T, DEBOUNCE_4T, DEBOUNCE_6T, DEBOUNCE_8T, DEBOUNCE_10T, DEBOUNCE_12T, DEBOUNCE_14T); diff --git a/libvapours/include/vapours/tegra/tegra_pinmux.hpp b/libvapours/include/vapours/tegra/tegra_pinmux.hpp index 137a8eae..c79d2d17 100644 --- a/libvapours/include/vapours/tegra/tegra_pinmux.hpp +++ b/libvapours/include/vapours/tegra/tegra_pinmux.hpp @@ -94,4 +94,6 @@ DEFINE_PINMUX_REG_TWO_BIT_ENUM(AUX_UART3_PM, 0, UARTC, SPI4, RSVD2, RSVD3); DEFINE_PINMUX_REG_TWO_BIT_ENUM(AUX_DVFS_PWM_PM, 0, RSVD0, CLDVFS, SPI3, RSVD3); +DEFINE_PINMUX_REG_TWO_BIT_ENUM(AUX_LCD_BL_PWM_PM, 0, DISPLAYA, PWM0, SOR0, RSVD3); + DEFINE_PINMUX_REG_TWO_BIT_ENUM(AUX_GPIO_PA6_PM, 0, SATA, RSVD1, RSVD2, RSVD3);