diff --git a/TODO b/TODO index c6e3366e3..354e61a2f 100644 --- a/TODO +++ b/TODO @@ -66,7 +66,8 @@ ✔ AM @started(19-12-24 23:17) @done(19-12-24 23:53) @lasted(36m8s) ✔ APT @done(19-12-25 21:41) ✔ BOSS @started(19-12-25 21:48) @done(19-12-25 23:18) @lasted(1h30m14s) - ☐ CAM + ☐ CAM @started(19-12-26 10:37) + Need to check capture_result ☐ CECD ☐ CGF ☐ CSND diff --git a/src/core/hle/service/cam/cam.cpp b/src/core/hle/service/cam/cam.cpp index bf1bab8c0..b7acd307c 100644 --- a/src/core/hle/service/cam/cam.cpp +++ b/src/core/hle/service/cam/cam.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include +#include "common/archives.h" #include "common/bit_set.h" #include "common/logging/log.h" #include "core/core.h" @@ -22,6 +23,16 @@ namespace Service::CAM { +template +void Module::serialize(Archive& ar, const unsigned int) +{ + ar & cameras; + ar & ports; + ar & is_camera_reload_pending; +} + +SERIALIZE_IMPL(Module) + // built-in resolution parameters constexpr std::array PRESET_RESOLUTION{{ {640, 480, 0, 0, 639, 479}, // VGA diff --git a/src/core/hle/service/cam/cam.h b/src/core/hle/service/cam/cam.h index 9f3d81990..229c882b5 100644 --- a/src/core/hle/service/cam/cam.h +++ b/src/core/hle/service/cam/cam.h @@ -12,6 +12,7 @@ #include "common/swap.h" #include "core/hle/result.h" #include "core/hle/service/service.h" +#include "core/global.h" namespace Core { class System; @@ -179,6 +180,19 @@ struct Resolution { u16 crop_y0; u16 crop_x1; u16 crop_y1; + +private: + template + void serialize(Archive& ar, const unsigned int) + { + ar & width; + ar & height; + ar & crop_x0; + ar & crop_y0; + ar & crop_x1; + ar & crop_y1; + } + friend class boost::serialization::access; }; struct PackageParameterWithoutContext { @@ -710,7 +724,7 @@ public: */ void DriverFinalize(Kernel::HLERequestContext& ctx); - private: + protected: std::shared_ptr cam; }; @@ -738,6 +752,17 @@ private: Effect effect{Effect::None}; OutputFormat format{OutputFormat::YUV422}; Resolution resolution = {0, 0, 0, 0, 0, 0}; + + private: + template + void serialize(Archive& ar, const unsigned int) + { + ar & flip; + ar & effect; + ar & format; + ar & resolution; + } + friend class boost::serialization::access; }; struct CameraConfig { @@ -745,6 +770,17 @@ private: std::array contexts; int current_context{0}; FrameRate frame_rate{FrameRate::Rate_5}; + + private: + template + void serialize(Archive& ar, const unsigned int) + { + ar & impl; + ar & contexts; + ar & current_context; + ar & frame_rate; + } + friend class boost::serialization::access; }; struct PortConfig { @@ -779,6 +815,32 @@ private: u32 dest_size{0}; // the destination size of the receiving process void Clear(); + + private: + template + void serialize(Archive& ar, const unsigned int) + { + ar & camera_id; + ar & is_active; + ar & is_pending_receiving; + ar & is_busy; + ar & is_receiving; + ar & is_trimming; + ar & x0; + ar & y0; + ar & x1; + ar & y1; + ar & transfer_bytes; + ar & completion_event; + ar & buffer_error_interrupt_event; + ar & vsync_interrupt_event; + // TODO: Check if this is ever needed: + //ar & capture_result; + ar & dest_process; + ar & dest; + ar & dest_size; + } + friend class boost::serialization::access; }; void LoadCameraImplementation(CameraConfig& camera, int camera_id); @@ -786,8 +848,13 @@ private: Core::System& system; std::array cameras; std::array ports; - Core::TimingEventType* completion_event_callback; + // TODO: Make this *const + const Core::TimingEventType* completion_event_callback; std::atomic is_camera_reload_pending{false}; + + template + void serialize(Archive& ar, const unsigned int); + friend class boost::serialization::access; }; std::shared_ptr GetModule(Core::System& system); @@ -795,3 +862,11 @@ std::shared_ptr GetModule(Core::System& system); void InstallInterfaces(Core::System& system); } // namespace Service::CAM + +namespace boost::serialization { + template + inline void load_construct_data(Archive& ar, Service::CAM::Module* t, const unsigned int) + { + ::new(t)Service::CAM::Module(Core::Global()); + } +} diff --git a/src/core/hle/service/cam/cam_c.cpp b/src/core/hle/service/cam/cam_c.cpp index 80816c923..a29e9db3e 100644 --- a/src/core/hle/service/cam/cam_c.cpp +++ b/src/core/hle/service/cam/cam_c.cpp @@ -4,6 +4,7 @@ #include "core/hle/service/cam/cam.h" #include "core/hle/service/cam/cam_c.h" +#include "common/archives.h" namespace Service::CAM { @@ -79,3 +80,5 @@ CAM_C::CAM_C(std::shared_ptr cam) : Module::Interface(std::move(cam), "c } } // namespace Service::CAM + +SERIALIZE_EXPORT_IMPL(Service::CAM::CAM_C) diff --git a/src/core/hle/service/cam/cam_c.h b/src/core/hle/service/cam/cam_c.h index d6dfcd6c5..c1ed355ac 100644 --- a/src/core/hle/service/cam/cam_c.h +++ b/src/core/hle/service/cam/cam_c.h @@ -11,6 +11,12 @@ namespace Service::CAM { class CAM_C final : public Module::Interface { public: explicit CAM_C(std::shared_ptr cam); + +private: + SERVICE_SERIALIZATION(CAM_C, cam, Module) }; } // namespace Service::CAM + +BOOST_CLASS_EXPORT_KEY(Service::CAM::CAM_C) +BOOST_SERIALIZATION_CONSTRUCT(Service::CAM::CAM_C) diff --git a/src/core/hle/service/cam/cam_q.cpp b/src/core/hle/service/cam/cam_q.cpp index 71fc127d2..ac477bf04 100644 --- a/src/core/hle/service/cam/cam_q.cpp +++ b/src/core/hle/service/cam/cam_q.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include "core/hle/service/cam/cam_q.h" +#include "common/archives.h" namespace Service::CAM { @@ -13,3 +14,5 @@ CAM_Q::CAM_Q() : ServiceFramework("cam:q", 1 /*TODO: find the true value*/) { } } // namespace Service::CAM + +SERIALIZE_EXPORT_IMPL(Service::CAM::CAM_Q) diff --git a/src/core/hle/service/cam/cam_q.h b/src/core/hle/service/cam/cam_q.h index d1124493b..33943ca21 100644 --- a/src/core/hle/service/cam/cam_q.h +++ b/src/core/hle/service/cam/cam_q.h @@ -11,6 +11,15 @@ namespace Service::CAM { class CAM_Q : public ServiceFramework { public: CAM_Q(); +private: + template + void serialize(Archive& ar, const unsigned int) + { + ar & boost::serialization::base_object(*this); + } + friend class boost::serialization::access; }; } // namespace Service::CAM + +BOOST_CLASS_EXPORT_KEY(Service::CAM::CAM_Q) diff --git a/src/core/hle/service/cam/cam_s.cpp b/src/core/hle/service/cam/cam_s.cpp index c4936f9b5..0797ed4e1 100644 --- a/src/core/hle/service/cam/cam_s.cpp +++ b/src/core/hle/service/cam/cam_s.cpp @@ -4,6 +4,7 @@ #include "core/hle/service/cam/cam.h" #include "core/hle/service/cam/cam_s.h" +#include "common/archives.h" namespace Service::CAM { @@ -79,3 +80,5 @@ CAM_S::CAM_S(std::shared_ptr cam) : Module::Interface(std::move(cam), "c } } // namespace Service::CAM + +SERIALIZE_EXPORT_IMPL(Service::CAM::CAM_S) diff --git a/src/core/hle/service/cam/cam_s.h b/src/core/hle/service/cam/cam_s.h index 0c9d26644..cceb99b87 100644 --- a/src/core/hle/service/cam/cam_s.h +++ b/src/core/hle/service/cam/cam_s.h @@ -11,6 +11,12 @@ namespace Service::CAM { class CAM_S final : public Module::Interface { public: explicit CAM_S(std::shared_ptr cam); + +private: + SERVICE_SERIALIZATION(CAM_S, cam, Module) }; } // namespace Service::CAM + +BOOST_CLASS_EXPORT_KEY(Service::CAM::CAM_S) +BOOST_SERIALIZATION_CONSTRUCT(Service::CAM::CAM_S) diff --git a/src/core/hle/service/cam/cam_u.cpp b/src/core/hle/service/cam/cam_u.cpp index 3c3c4b17d..16c652a26 100644 --- a/src/core/hle/service/cam/cam_u.cpp +++ b/src/core/hle/service/cam/cam_u.cpp @@ -4,6 +4,7 @@ #include "core/hle/service/cam/cam.h" #include "core/hle/service/cam/cam_u.h" +#include "common/archives.h" namespace Service::CAM { @@ -79,3 +80,5 @@ CAM_U::CAM_U(std::shared_ptr cam) : Module::Interface(std::move(cam), "c } } // namespace Service::CAM + +SERIALIZE_EXPORT_IMPL(Service::CAM::CAM_U) diff --git a/src/core/hle/service/cam/cam_u.h b/src/core/hle/service/cam/cam_u.h index 85b12559a..2b775a035 100644 --- a/src/core/hle/service/cam/cam_u.h +++ b/src/core/hle/service/cam/cam_u.h @@ -11,6 +11,12 @@ namespace Service::CAM { class CAM_U final : public Module::Interface { public: explicit CAM_U(std::shared_ptr cam); + +private: + SERVICE_SERIALIZATION(CAM_U, cam, Module) }; } // namespace Service::CAM + +BOOST_CLASS_EXPORT_KEY(Service::CAM::CAM_U) +BOOST_SERIALIZATION_CONSTRUCT(Service::CAM::CAM_U)