CAM service serialization

This commit is contained in:
Hamish Milne 2019-12-26 10:37:43 +00:00 committed by zhupengfei
parent 1185d62792
commit 17b9cbefef
11 changed files with 129 additions and 3 deletions

3
TODO
View File

@ -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

View File

@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include <algorithm>
#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 <class Archive>
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<Resolution, 8> PRESET_RESOLUTION{{
{640, 480, 0, 0, 639, 479}, // VGA

View File

@ -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 <class Archive>
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<Module> cam;
};
@ -738,6 +752,17 @@ private:
Effect effect{Effect::None};
OutputFormat format{OutputFormat::YUV422};
Resolution resolution = {0, 0, 0, 0, 0, 0};
private:
template <class Archive>
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<ContextConfig, 2> contexts;
int current_context{0};
FrameRate frame_rate{FrameRate::Rate_5};
private:
template <class Archive>
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 <class Archive>
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<CameraConfig, NumCameras> cameras;
std::array<PortConfig, 2> ports;
Core::TimingEventType* completion_event_callback;
// TODO: Make this *const
const Core::TimingEventType* completion_event_callback;
std::atomic<bool> is_camera_reload_pending{false};
template <class Archive>
void serialize(Archive& ar, const unsigned int);
friend class boost::serialization::access;
};
std::shared_ptr<Module> GetModule(Core::System& system);
@ -795,3 +862,11 @@ std::shared_ptr<Module> GetModule(Core::System& system);
void InstallInterfaces(Core::System& system);
} // namespace Service::CAM
namespace boost::serialization {
template <class Archive>
inline void load_construct_data(Archive& ar, Service::CAM::Module* t, const unsigned int)
{
::new(t)Service::CAM::Module(Core::Global<Core::System>());
}
}

View File

@ -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<Module> cam) : Module::Interface(std::move(cam), "c
}
} // namespace Service::CAM
SERIALIZE_EXPORT_IMPL(Service::CAM::CAM_C)

View File

@ -11,6 +11,12 @@ namespace Service::CAM {
class CAM_C final : public Module::Interface {
public:
explicit CAM_C(std::shared_ptr<Module> 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)

View File

@ -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)

View File

@ -11,6 +11,15 @@ namespace Service::CAM {
class CAM_Q : public ServiceFramework<CAM_Q> {
public:
CAM_Q();
private:
template <class Archive>
void serialize(Archive& ar, const unsigned int)
{
ar & boost::serialization::base_object<Kernel::SessionRequestHandler>(*this);
}
friend class boost::serialization::access;
};
} // namespace Service::CAM
BOOST_CLASS_EXPORT_KEY(Service::CAM::CAM_Q)

View File

@ -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<Module> cam) : Module::Interface(std::move(cam), "c
}
} // namespace Service::CAM
SERIALIZE_EXPORT_IMPL(Service::CAM::CAM_S)

View File

@ -11,6 +11,12 @@ namespace Service::CAM {
class CAM_S final : public Module::Interface {
public:
explicit CAM_S(std::shared_ptr<Module> 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)

View File

@ -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<Module> cam) : Module::Interface(std::move(cam), "c
}
} // namespace Service::CAM
SERIALIZE_EXPORT_IMPL(Service::CAM::CAM_U)

View File

@ -11,6 +11,12 @@ namespace Service::CAM {
class CAM_U final : public Module::Interface {
public:
explicit CAM_U(std::shared_ptr<Module> 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)