strat: update for code changes found in boot (closes #1797)

This commit is contained in:
Michael Scire 2022-05-05 17:45:55 -07:00
parent e96972c939
commit 4db485083b
3 changed files with 20 additions and 11 deletions

View file

@ -38,6 +38,7 @@ namespace ams::pwm::driver {
virtual Result SetPeriod(IPwmDevice *device, TimeSpan period) = 0; virtual Result SetPeriod(IPwmDevice *device, TimeSpan period) = 0;
virtual Result GetPeriod(TimeSpan *out, IPwmDevice *device) = 0; virtual Result GetPeriod(TimeSpan *out, IPwmDevice *device) = 0;
/* TODO: Nintendo removed these in 14.0.0. Should we? */
virtual Result SetDuty(IPwmDevice *device, int duty) = 0; virtual Result SetDuty(IPwmDevice *device, int duty) = 0;
virtual Result GetDuty(int *out, IPwmDevice *device) = 0; virtual Result GetDuty(int *out, IPwmDevice *device) = 0;

View file

@ -18,14 +18,14 @@
#include <vapours.hpp> #include <vapours.hpp>
#include <stratosphere/pwm/pwm_types.hpp> #include <stratosphere/pwm/pwm_types.hpp>
#define AMS_PWM_I_CHANNEL_SESSION_INTERFACE_INFO(C, H) \ #define AMS_PWM_I_CHANNEL_SESSION_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, SetPeriod, (TimeSpanType period), (period) ) \ AMS_SF_METHOD_INFO(C, H, 0, Result, SetPeriod, (TimeSpanType period), (period)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, GetPeriod, (ams::sf::Out<TimeSpanType> out), (out) ) \ AMS_SF_METHOD_INFO(C, H, 1, Result, GetPeriod, (ams::sf::Out<TimeSpanType> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, SetDuty, (int duty), (duty) ) \ AMS_SF_METHOD_INFO(C, H, 2, Result, SetDuty, (int duty), (duty), hos::Version_Min, hos::Version_13_2_1) \
AMS_SF_METHOD_INFO(C, H, 3, Result, GetDuty, (ams::sf::Out<int> out), (out) ) \ AMS_SF_METHOD_INFO(C, H, 3, Result, GetDuty, (ams::sf::Out<int> out), (out), hos::Version_Min, hos::Version_13_2_1) \
AMS_SF_METHOD_INFO(C, H, 4, Result, SetEnabled, (bool enabled), (enabled) ) \ AMS_SF_METHOD_INFO(C, H, 4, Result, SetEnabled, (bool enabled), (enabled)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, GetEnabled, (ams::sf::Out<bool> out), (out) ) \ AMS_SF_METHOD_INFO(C, H, 5, Result, GetEnabled, (ams::sf::Out<bool> out), (out)) \
AMS_SF_METHOD_INFO(C, H, 6, Result, SetScale, (double scale), (scale), hos::Version_6_0_0) \ AMS_SF_METHOD_INFO(C, H, 6, Result, SetScale, (double scale), (scale), hos::Version_6_0_0) \
AMS_SF_METHOD_INFO(C, H, 7, Result, GetScale, (ams::sf::Out<double> out), (out), hos::Version_6_0_0) AMS_SF_METHOD_INFO(C, H, 7, Result, GetScale, (ams::sf::Out<double> out), (out), hos::Version_6_0_0)
AMS_SF_DEFINE_INTERFACE(ams::pwm::sf, IChannelSession, AMS_PWM_I_CHANNEL_SESSION_INTERFACE_INFO, 0xAC0A18F9) AMS_SF_DEFINE_INTERFACE(ams::pwm::sf, IChannelSession, AMS_PWM_I_CHANNEL_SESSION_INTERFACE_INFO, 0xAC0A18F9)

View file

@ -79,7 +79,7 @@ namespace ams::pwm::driver::board::nintendo::nx::impl {
/* Configure initial settings. */ /* Configure initial settings. */
/* NOTE: None of these results are checked. */ /* NOTE: None of these results are checked. */
this->SetEnabled(device, false); this->SetEnabled(device, false);
this->SetDuty(device, 0); this->SetScale(device, 0.0);
this->SetPeriod(device, DefaultChannelPeriod); this->SetPeriod(device, DefaultChannelPeriod);
R_SUCCEED(); R_SUCCEED();
} }
@ -169,8 +169,16 @@ namespace ams::pwm::driver::board::nintendo::nx::impl {
/* Convert the scale to a duty. */ /* Convert the scale to a duty. */
const int duty = static_cast<int>(((scale * 256.0) / 100.0) + 0.5); const int duty = static_cast<int>(((scale * 256.0) / 100.0) + 0.5);
/* Set the duty. */ /* Validate the duty. */
R_RETURN(this->SetDuty(device, duty)); R_UNLESS(0 <= duty && duty <= MaxDuty, pwm::ResultInvalidArgument());
/* Acquire exclusive access to the device registers. */
std::scoped_lock lk(device->SafeCastTo<PwmDeviceImpl>());
/* Update the duty. */
reg::ReadWrite(this->GetRegistersFor(device) + PWM_CONTROLLER_PWM_CSR, PWM_REG_BITS_VALUE(PWM_CSR_PWM, static_cast<u32>(duty)));
R_SUCCEED();
} }
Result PwmDriverImpl::GetScale(double *out, IPwmDevice *device) { Result PwmDriverImpl::GetScale(double *out, IPwmDevice *device) {