Browse Source

video: driver: add power suspend and resume

add power suspend and resume implementations.

Change-Id: I785b5b05f37ed5ed656d2cbc04f5d429ff543260
Signed-off-by: Darshana Patil <[email protected]>
Darshana Patil 3 years ago
parent
commit
784a4c9280

+ 0 - 1
driver/vidc/inc/msm_vidc.h

@@ -16,7 +16,6 @@ union msm_v4l2_cmd {
 
 void *msm_vidc_open(void *core, u32 session_type);
 int msm_vidc_close(void *instance);
-int msm_vidc_suspend(int core_id);
 int msm_vidc_querycap(void *instance, struct v4l2_capability *cap);
 int msm_vidc_enum_fmt(void *instance, struct v4l2_fmtdesc *f);
 int msm_vidc_try_fmt(void *instance, struct v4l2_format *f);

+ 1 - 0
driver/vidc/inc/msm_vidc_driver.h

@@ -322,6 +322,7 @@ int msm_vidc_trigger_ssr(struct msm_vidc_core *core,
 void msm_vidc_ssr_handler(struct work_struct *work);
 void msm_vidc_pm_work_handler(struct work_struct *work);
 void msm_vidc_fw_unload_handler(struct work_struct *work);
+int msm_vidc_suspend(struct msm_vidc_core *core);
 void msm_vidc_batch_handler(struct work_struct *work);
 int msm_vidc_event_queue_init(struct msm_vidc_inst *inst);
 int msm_vidc_event_queue_deinit(struct msm_vidc_inst *inst);

+ 16 - 0
driver/vidc/src/msm_vidc_driver.c

@@ -4612,6 +4612,22 @@ void msm_vidc_fw_unload_handler(struct work_struct *work)
 
 }
 
+int msm_vidc_suspend(struct msm_vidc_core *core)
+{
+	int rc = 0;
+
+	if (!core) {
+		d_vpr_e("%s: invalid params\n", __func__);
+		return -EINVAL;
+	}
+
+	rc = venus_hfi_suspend(core);
+	if (rc)
+		return rc;
+
+	return rc;
+}
+
 void msm_vidc_batch_handler(struct work_struct *work)
 {
 	struct msm_vidc_inst *inst;

+ 42 - 0
driver/vidc/src/msm_vidc_probe.c

@@ -470,12 +470,54 @@ static int msm_vidc_probe(struct platform_device *pdev)
 	return -EINVAL;
 }
 
+static int msm_vidc_pm_suspend(struct device *dev)
+{
+	int rc = 0;
+	struct msm_vidc_core *core;
+
+	d_vpr_h("%s\n", __func__);
+	/*
+	 * Bail out if
+	 * - driver possibly not probed yet
+	 * - not the main device. We don't support power management on
+	 *   subdevices (e.g. context banks)
+	 */
+	if (!dev || !dev->driver ||
+		!of_device_is_compatible(dev->of_node, "qcom,msm-vidc"))
+		return 0;
+
+	core = dev_get_drvdata(dev);
+	if (!core) {
+		d_vpr_e("%s: invalid core\n", __func__);
+		return -EINVAL;
+	}
+
+	rc = msm_vidc_suspend(core);
+	if (rc == -ENOTSUPP)
+		rc = 0;
+	else if (rc)
+		d_vpr_e("Failed to suspend: %d\n", rc);
+
+	return rc;
+}
+
+static int msm_vidc_pm_resume(struct device *dev)
+{
+	d_vpr_h("%s\n", __func__);
+	return 0;
+}
+
+static const struct dev_pm_ops msm_vidc_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(msm_vidc_pm_suspend, msm_vidc_pm_resume)
+};
+
 struct platform_driver msm_vidc_driver = {
 	.probe = msm_vidc_probe,
 	.remove = msm_vidc_remove,
 	.driver = {
 		.name = "msm_vidc_v4l2",
 		.of_match_table = msm_vidc_dt_match,
+		.pm = &msm_vidc_pm_ops,
 	},
 };