Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e8c8ce5e authored by E V Ravi's avatar E V Ravi
Browse files

Add S2R and S2D support in KMD



S2R: Implement .suspend() and .resume()
S2D: Implement .thaw() and .restore().

Change-Id: Idef319f8f67895fcadb838fb72f03187799401c8
Signed-off-by: default avatarE V Ravi <evenka@codeaurora.org>
parent 2237d580
Loading
Loading
Loading
Loading
+59 −0
Original line number Diff line number Diff line
@@ -745,6 +745,64 @@ static const struct of_device_id cam_req_mgr_dt_match[] = {
};
MODULE_DEVICE_TABLE(of, cam_dt_match);

static int cam_pm_suspend(struct device *pdev)
{
	struct v4l2_event event;

	event.id = V4L_EVENT_CAM_REQ_MGR_S2R_SUSPEND;
	event.type = V4L_EVENT_CAM_REQ_MGR_EVENT;
	CAM_DBG(CAM_CRM, "Queue S2R suspend event");
	v4l2_event_queue(g_dev.video, &event);
	return 0;
}

static int cam_pm_resume(struct device *pdev)
{
	struct v4l2_event event;

	event.id = V4L_EVENT_CAM_REQ_MGR_S2R_RESUME;
	event.type = V4L_EVENT_CAM_REQ_MGR_EVENT;
	CAM_DBG(CAM_CRM, "Queue S2R resume event");
	v4l2_event_queue(g_dev.video, &event);
	return 0;
}

static int cam_pm_freeze(struct device *pdev)
{
	CAM_DBG(CAM_CRM, "Freeze done for cam_req_mgr driver");
	return 0;
}

static int cam_pm_restore(struct device *pdev)
{
	struct v4l2_event event;

	event.id = V4L_EVENT_CAM_REQ_MGR_HIBERNATION_RESUME;
	event.type = V4L_EVENT_CAM_REQ_MGR_EVENT;
	CAM_DBG(CAM_CRM, "Queue hibernation restore event");
	v4l2_event_queue(g_dev.video, &event);
	return 0;
}

static int cam_pm_thaw(struct device *pdev)
{
	struct v4l2_event event;

	event.id = V4L_EVENT_CAM_REQ_MGR_HIBERNATION_SUSPEND;
	event.type = V4L_EVENT_CAM_REQ_MGR_EVENT;
	CAM_DBG(CAM_CRM, "Queue hibernation thaw event");
	v4l2_event_queue(g_dev.video, &event);
	return 0;
}

static const struct dev_pm_ops cam_pm_ops = {
	.suspend = &cam_pm_suspend,
	.resume = &cam_pm_resume,
	.freeze = &cam_pm_freeze,
	.restore = &cam_pm_restore,
	.thaw = &cam_pm_thaw,
};

static struct platform_driver cam_req_mgr_driver = {
	.probe = cam_req_mgr_probe,
	.remove = cam_req_mgr_remove,
@@ -753,6 +811,7 @@ static struct platform_driver cam_req_mgr_driver = {
		.owner = THIS_MODULE,
		.of_match_table = cam_req_mgr_dt_match,
		.suppress_bind_attrs = true,
		.pm = &cam_pm_ops,
	},
};

+9 −3
Original line number Diff line number Diff line
@@ -47,6 +47,12 @@
#define V4L_EVENT_CAM_REQ_MGR_ERROR                  1
#define V4L_EVENT_CAM_REQ_MGR_SOF_BOOT_TS            2

/* Suspend to RAM and Hibernation events */
#define V4L_EVENT_CAM_REQ_MGR_S2R_SUSPEND           10
#define V4L_EVENT_CAM_REQ_MGR_S2R_RESUME            11
#define V4L_EVENT_CAM_REQ_MGR_HIBERNATION_SUSPEND   12
#define V4L_EVENT_CAM_REQ_MGR_HIBERNATION_RESUME    13

/* SOF Event status */
#define CAM_REQ_MGR_SOF_EVENT_SUCCESS           0
#define CAM_REQ_MGR_SOF_EVENT_ERROR             1