mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-31 23:08:22 -04:00
pwm: implement driver for boot sysmodule
This commit is contained in:
parent
35552bac2c
commit
3d31837ca1
41 changed files with 2107 additions and 59 deletions
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/pwm/pwm_types.hpp>
|
||||
|
||||
namespace ams::pwm::driver::board::nintendo_nx {
|
||||
|
||||
void Initialize();
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/pwm/pwm_types.hpp>
|
||||
|
||||
namespace ams::pwm::driver {
|
||||
|
||||
namespace impl {
|
||||
|
||||
constexpr inline size_t ChannelSessionSize = 0x60;
|
||||
constexpr inline size_t ChannelSessionAlign = 8;
|
||||
struct alignas(ChannelSessionAlign) ChannelSessionImplPadded;
|
||||
|
||||
}
|
||||
|
||||
struct ChannelSession {
|
||||
util::TypedStorage<impl::ChannelSessionImplPadded, impl::ChannelSessionSize, impl::ChannelSessionAlign> _impl;
|
||||
};
|
||||
|
||||
Result OpenSession(ChannelSession *out, DeviceCode device_code);
|
||||
void CloseSession(ChannelSession &session);
|
||||
|
||||
void SetPeriod(ChannelSession &session, TimeSpan period);
|
||||
TimeSpan GetPeriod(ChannelSession &session);
|
||||
|
||||
void SetDuty(ChannelSession &session, int duty);
|
||||
int GetDuty(ChannelSession &session);
|
||||
|
||||
void SetEnabled(ChannelSession &session, bool en);
|
||||
bool GetEnabled(ChannelSession &session);
|
||||
|
||||
void SetScale(ChannelSession &session, double scale);
|
||||
double GetScale(ChannelSession &session);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/pwm/pwm_types.hpp>
|
||||
|
||||
namespace ams::pwm::driver {
|
||||
|
||||
void Initialize();
|
||||
void Finalize();
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/pwm/pwm_types.hpp>
|
||||
#include <stratosphere/pwm/driver/pwm_i_pwm_device.hpp>
|
||||
#include <stratosphere/pwm/driver/pwm_i_pwm_driver.hpp>
|
||||
|
||||
namespace ams::pwm::driver {
|
||||
|
||||
void RegisterDriver(IPwmDriver *driver);
|
||||
void UnregisterDriver(IPwmDriver *driver);
|
||||
|
||||
Result RegisterDeviceCode(DeviceCode device_code, IPwmDevice *device);
|
||||
bool UnregisterDeviceCode(DeviceCode device_code);
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/pwm/pwm_types.hpp>
|
||||
#include <stratosphere/ddsf.hpp>
|
||||
|
||||
namespace ams::pwm::driver {
|
||||
|
||||
class IPwmDevice : public ::ams::ddsf::IDevice {
|
||||
NON_COPYABLE(IPwmDevice);
|
||||
NON_MOVEABLE(IPwmDevice);
|
||||
AMS_DDSF_CASTABLE_TRAITS(ams::pwm::IPwmDevice, ::ams::ddsf::IDriver);
|
||||
private:
|
||||
int channel_index;
|
||||
public:
|
||||
IPwmDevice(int id) : IDevice(false), channel_index(id) { /* ... */ }
|
||||
virtual ~IPwmDevice() { /* ... */ }
|
||||
|
||||
constexpr int GetChannelIndex() const { return this->channel_index; }
|
||||
};
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/pwm/pwm_types.hpp>
|
||||
#include <stratosphere/pwm/driver/pwm_i_pwm_device.hpp>
|
||||
#include <stratosphere/ddsf.hpp>
|
||||
|
||||
namespace ams::pwm::driver {
|
||||
|
||||
class IPwmDriver : public ::ams::ddsf::IDriver {
|
||||
NON_COPYABLE(IPwmDriver);
|
||||
NON_MOVEABLE(IPwmDriver);
|
||||
AMS_DDSF_CASTABLE_TRAITS(ams::pwm::IPwmDriver, ::ams::ddsf::IDriver);
|
||||
public:
|
||||
IPwmDriver() : IDriver() { /* ... */ }
|
||||
virtual ~IPwmDriver() { /* ... */ }
|
||||
|
||||
virtual void InitializeDriver() = 0;
|
||||
virtual void FinalizeDriver() = 0;
|
||||
|
||||
virtual Result InitializeDevice(IPwmDevice *device) = 0;
|
||||
virtual void FinalizeDevice(IPwmDevice *device) = 0;
|
||||
|
||||
virtual Result SetPeriod(IPwmDevice *device, TimeSpan period) = 0;
|
||||
virtual Result GetPeriod(TimeSpan *out, IPwmDevice *device) = 0;
|
||||
|
||||
virtual Result SetDuty(IPwmDevice *device, int duty) = 0;
|
||||
virtual Result GetDuty(int *out, IPwmDevice *device) = 0;
|
||||
|
||||
virtual Result SetScale(IPwmDevice *device, double scale) = 0;
|
||||
virtual Result GetScale(double *out, IPwmDevice *device) = 0;
|
||||
|
||||
virtual Result SetEnabled(IPwmDevice *device, bool en) = 0;
|
||||
virtual Result GetEnabled(bool *out, IPwmDevice *device) = 0;
|
||||
|
||||
virtual Result Suspend() = 0;
|
||||
virtual void Resume() = 0;
|
||||
};
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/pwm/pwm_types.hpp>
|
||||
#include <stratosphere/pwm/driver/pwm_i_pwm_driver.hpp>
|
||||
|
||||
#if defined(ATMOSPHERE_BOARD_NINTENDO_NX)
|
||||
|
||||
#include <stratosphere/pwm/driver/board/nintendo_nx/pwm_driver_api.hpp>
|
||||
|
||||
namespace ams::pwm::driver::board {
|
||||
|
||||
using namespace ams::pwm::driver::board::nintendo_nx;
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#error "Unknown board for ams::pwm::driver::"
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/pwm/pwm_types.hpp>
|
||||
#include <stratosphere/pwm/sf/pwm_sf_i_manager.hpp>
|
||||
|
||||
namespace ams::pwm {
|
||||
|
||||
void InitializeWith(std::shared_ptr<pwm::sf::IManager> &&sp);
|
||||
void Finalize();
|
||||
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/pwm/pwm_types.hpp>
|
||||
|
||||
namespace ams::pwm {
|
||||
|
||||
struct ChannelSession {
|
||||
void *_session;
|
||||
};
|
||||
|
||||
Result OpenSession(ChannelSession *out, DeviceCode device_code);
|
||||
void CloseSession(ChannelSession &session);
|
||||
|
||||
void SetPeriod(ChannelSession &session, TimeSpan period);
|
||||
TimeSpan GetPeriod(ChannelSession &session);
|
||||
|
||||
void SetDuty(ChannelSession &session, int duty);
|
||||
int GetDuty(ChannelSession &session);
|
||||
|
||||
void SetEnabled(ChannelSession &session, bool en);
|
||||
bool GetEnabled(ChannelSession &session);
|
||||
|
||||
void SetScale(ChannelSession &session, double scale);
|
||||
double GetScale(ChannelSession &session);
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/pwm/pwm_types.hpp>
|
||||
#include <stratosphere/pwm/sf/pwm_sf_i_manager.hpp>
|
||||
|
||||
namespace ams::pwm::server {
|
||||
|
||||
std::shared_ptr<pwm::sf::IManager> GetServiceObject();
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/pwm/pwm_types.hpp>
|
||||
|
||||
namespace ams::pwm::sf {
|
||||
|
||||
#define AMS_PWM_I_CHANNEL_SESSION_INTERFACE_INFO(C, H) \
|
||||
AMS_SF_METHOD_INFO(C, H, 0, Result, SetPeriod, (TimeSpanType period) ) \
|
||||
AMS_SF_METHOD_INFO(C, H, 1, Result, GetPeriod, (ams::sf::Out<TimeSpanType> out) ) \
|
||||
AMS_SF_METHOD_INFO(C, H, 2, Result, SetDuty, (int duty) ) \
|
||||
AMS_SF_METHOD_INFO(C, H, 3, Result, GetDuty, (ams::sf::Out<int> out) ) \
|
||||
AMS_SF_METHOD_INFO(C, H, 4, Result, SetEnabled, (bool enabled) ) \
|
||||
AMS_SF_METHOD_INFO(C, H, 5, Result, GetEnabled, (ams::sf::Out<bool> out) ) \
|
||||
AMS_SF_METHOD_INFO(C, H, 6, Result, SetScale, (double scale), hos::Version_6_0_0) \
|
||||
AMS_SF_METHOD_INFO(C, H, 7, Result, GetScale, (ams::sf::Out<double> out), hos::Version_6_0_0)
|
||||
|
||||
AMS_SF_DEFINE_INTERFACE(IChannelSession, AMS_PWM_I_CHANNEL_SESSION_INTERFACE_INFO)
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/ddsf/ddsf_types.hpp>
|
||||
#include <stratosphere/pwm/pwm_select_channel_name.hpp>
|
||||
#include <stratosphere/pwm/sf/pwm_sf_i_channel_session.hpp>
|
||||
|
||||
namespace ams::pwm::sf {
|
||||
|
||||
#define AMS_PWM_I_MANAGER_INTERFACE_INFO(C, H) \
|
||||
AMS_SF_METHOD_INFO(C, H, 0, Result, OpenSessionForDev, (ams::sf::Out<std::shared_ptr<pwm::sf::IChannelSession>> out, int channel) ) \
|
||||
AMS_SF_METHOD_INFO(C, H, 1, Result, OpenSession, (ams::sf::Out<std::shared_ptr<pwm::sf::IChannelSession>> out, pwm::ChannelName channel_name) ) \
|
||||
AMS_SF_METHOD_INFO(C, H, 2, Result, OpenSession2, (ams::sf::Out<std::shared_ptr<pwm::sf::IChannelSession>> out, DeviceCode device_code), hos::Version_6_0_0)
|
||||
|
||||
AMS_SF_DEFINE_INTERFACE(IManager, AMS_PWM_I_MANAGER_INTERFACE_INFO)
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue