diff mbox series

[v2,30/34] media: iris: register video encoder device to platform driver

Message ID 1702899149-21321-31-git-send-email-quic_dikshita@quicinc.com
State New
Headers show
Series Qualcomm video encoder and decoder driver | expand

Commit Message

Dikshita Agarwal Dec. 18, 2023, 11:32 a.m. UTC
Register/unregister video Encoder device.

Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
---
 .../media/platform/qcom/vcodec/iris/iris_common.h  |  5 +++
 .../media/platform/qcom/vcodec/iris/iris_core.h    |  2 ++
 .../media/platform/qcom/vcodec/iris/iris_probe.c   | 42 ++++++++++++++++------
 3 files changed, 38 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/drivers/media/platform/qcom/vcodec/iris/iris_common.h b/drivers/media/platform/qcom/vcodec/iris/iris_common.h
index 3ab4767..b1273d0 100644
--- a/drivers/media/platform/qcom/vcodec/iris/iris_common.h
+++ b/drivers/media/platform/qcom/vcodec/iris/iris_common.h
@@ -30,6 +30,11 @@ 
 
 #define INPUT_TIMER_LIST_SIZE 30
 
+enum domain_type {
+	ENCODER	= BIT(0),
+	DECODER	= BIT(1),
+};
+
 enum codec_type {
 	H264	= BIT(0),
 	HEVC	= BIT(1),
diff --git a/drivers/media/platform/qcom/vcodec/iris/iris_core.h b/drivers/media/platform/qcom/vcodec/iris/iris_core.h
index 50553d2..c56eb24 100644
--- a/drivers/media/platform/qcom/vcodec/iris/iris_core.h
+++ b/drivers/media/platform/qcom/vcodec/iris/iris_core.h
@@ -23,6 +23,7 @@ 
  * @irq: iris irq
  * @v4l2_dev: a holder for v4l2 device structure
  * @vdev_dec: iris video device structure for decoder
+ * @vdev_enc: iris video device structure for encoder
  * @v4l2_file_ops: iris v4l2 file ops
  * @v4l2_ioctl_ops: iris v4l2 ioctl ops
  * @bus_tbl: table of iris buses
@@ -66,6 +67,7 @@  struct iris_core {
 	int					irq;
 	struct v4l2_device			v4l2_dev;
 	struct video_device			*vdev_dec;
+	struct video_device			*vdev_enc;
 	const struct v4l2_file_operations	*v4l2_file_ops;
 	const struct v4l2_ioctl_ops		*v4l2_ioctl_ops;
 	struct bus_info				*bus_tbl;
diff --git a/drivers/media/platform/qcom/vcodec/iris/iris_probe.c b/drivers/media/platform/qcom/vcodec/iris/iris_probe.c
index 2571e27..b487e83 100644
--- a/drivers/media/platform/qcom/vcodec/iris/iris_probe.c
+++ b/drivers/media/platform/qcom/vcodec/iris/iris_probe.c
@@ -31,16 +31,15 @@  static int init_iris_isr(struct iris_core *core)
 	return ret;
 }
 
-static int iris_register_video_device(struct iris_core *core)
+static int iris_register_video_device(struct iris_core *core, enum domain_type type)
 {
 	struct video_device *vdev;
-	int ret;
+	int ret = 0;
 
 	vdev = video_device_alloc();
 	if (!vdev)
 		return -ENOMEM;
 
-	strscpy(vdev->name, "qcom-iris-decoder", sizeof(vdev->name));
 	vdev->release = video_device_release;
 	vdev->fops = core->v4l2_file_ops;
 	vdev->ioctl_ops = core->v4l2_ioctl_ops;
@@ -48,11 +47,24 @@  static int iris_register_video_device(struct iris_core *core)
 	vdev->v4l2_dev = &core->v4l2_dev;
 	vdev->device_caps = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_STREAMING;
 
-	ret = video_register_device(vdev, VFL_TYPE_VIDEO, -1);
-	if (ret)
-		goto err_vdev_release;
+	if (type == DECODER) {
+		strscpy(vdev->name, "qcom-iris-decoder", sizeof(vdev->name));
+
+		ret = video_register_device(vdev, VFL_TYPE_VIDEO, -1);
+		if (ret)
+			goto err_vdev_release;
+
+		core->vdev_dec = vdev;
+	} else if (type == ENCODER) {
+		strscpy(vdev->name, "qcom-iris-encoder", sizeof(vdev->name));
+
+		ret = video_register_device(vdev, VFL_TYPE_VIDEO, -1);
+		if (ret)
+			goto err_vdev_release;
+
+		core->vdev_enc = vdev;
+	}
 
-	core->vdev_dec = vdev;
 	video_set_drvdata(vdev, core);
 
 	return ret;
@@ -80,6 +92,8 @@  static void iris_remove(struct platform_device *pdev)
 
 	video_unregister_device(core->vdev_dec);
 
+	video_unregister_device(core->vdev_enc);
+
 	v4l2_device_unregister(&core->v4l2_dev);
 
 	iris_pm_put(core, false);
@@ -185,17 +199,21 @@  static int iris_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_runtime_disable;
 
-	ret = iris_register_video_device(core);
+	ret = iris_register_video_device(core, DECODER);
 	if (ret)
 		goto err_v4l2_unreg;
 
+	ret = iris_register_video_device(core, ENCODER);
+	if (ret)
+		goto err_vdev_unreg_dec;
+
 	platform_set_drvdata(pdev, core);
 
 	dma_mask = core->cap[DMA_MASK].value;
 
 	ret = dma_set_mask_and_coherent(dev, dma_mask);
 	if (ret)
-		goto err_vdev_unreg;
+		goto err_vdev_unreg_enc;
 
 	dma_set_max_seg_size(&pdev->dev, (unsigned int)DMA_BIT_MASK(32));
 	dma_set_seg_boundary(&pdev->dev, (unsigned long)DMA_BIT_MASK(64));
@@ -206,7 +224,7 @@  static int iris_probe(struct platform_device *pdev)
 	if (ret) {
 		dev_err_probe(core->dev, ret,
 			      "%s: interface queues init failed\n", __func__);
-		goto err_vdev_unreg;
+		goto err_vdev_unreg_enc;
 	}
 
 	ret = iris_pm_get(core);
@@ -236,7 +254,9 @@  static int iris_probe(struct platform_device *pdev)
 	hfi_queue_deinit(core->dev, &core->iface_q_table, &core->sfr,
 			 &core->command_queue, &core->message_queue,
 			 &core->debug_queue);
-err_vdev_unreg:
+err_vdev_unreg_enc:
+	video_unregister_device(core->vdev_enc);
+err_vdev_unreg_dec:
 	video_unregister_device(core->vdev_dec);
 err_v4l2_unreg:
 	v4l2_device_unregister(&core->v4l2_dev);