linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] Support H264 4K on MT8192
@ 2021-02-03  8:37 Irui Wang
  2021-02-03  8:37 ` [PATCH 1/5] dt-bindings: media: mtk-vcodec: Add dma-ranges property Irui Wang
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Irui Wang @ 2021-02-03  8:37 UTC (permalink / raw)
  To: Alexandre Courbot, Hans Verkuil, Tiffany Lin, Andrew-CT Chen,
	Mauro Carvalho Chehab, Rob Herring, Matthias Brugger,
	Fritz Koenig, Tzung-Bi Shih
  Cc: Maoguang Meng, Longfei Wang, Yunfei Dong, Irui Wang, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, srv_heupstream,
	linux-mediatek

Add MT8192 H264 venc driver and support H264 4K encoding on MT8192.

Signed-off-by: Irui Wang <irui.wang@mediatek.com>
---
This patch dependents on
"dt-bindings: media: mtk-vcodec: Separating mtk vcodec encoder node" [1]

We need "name" and "core_id" variable in device private data to indicate
current encoder driver.
Please also accept this patch together with [1].

[1]http://lists.infradead.org/pipermail/linux-mediatek/2021-January/021165.html
---
Irui Wang (5):
  dt-bindings: media: mtk-vcodec: Add dma-ranges property
  media: mtk-vcodec: Support 4GB~8GB range iova space for venc
  dt-bindings: media: mtk-vcodec: Add binding for MT8192 VENC
  media: mtk-vcodec: Add MT8192 H264 venc driver
  media: mtk-vcodec: Support H264 4K encoding on MT8192

 .../bindings/media/mediatek-vcodec.txt        | 28 +++++++++
 .../platform/mtk-vcodec/mtk_vcodec_drv.h      |  1 +
 .../platform/mtk-vcodec/mtk_vcodec_enc.c      | 58 ++++++++++++++-----
 .../platform/mtk-vcodec/mtk_vcodec_enc_drv.c  | 19 ++++++
 .../platform/mtk-vcodec/venc/venc_h264_if.c   |  4 ++
 5 files changed, 95 insertions(+), 15 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/5] dt-bindings: media: mtk-vcodec: Add dma-ranges property
  2021-02-03  8:37 [PATCH 0/5] Support H264 4K on MT8192 Irui Wang
@ 2021-02-03  8:37 ` Irui Wang
  2021-02-10 22:53   ` Rob Herring
  2021-02-03  8:37 ` [PATCH 2/5] media: mtk-vcodec: Support 4GB~8GB range iova space for venc Irui Wang
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Irui Wang @ 2021-02-03  8:37 UTC (permalink / raw)
  To: Alexandre Courbot, Hans Verkuil, Tiffany Lin, Andrew-CT Chen,
	Mauro Carvalho Chehab, Rob Herring, Matthias Brugger,
	Fritz Koenig, Tzung-Bi Shih
  Cc: Maoguang Meng, Longfei Wang, Yunfei Dong, Irui Wang, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, srv_heupstream,
	linux-mediatek

Adds dma-ranges property for DMA addresses translation.

Signed-off-by: Irui Wang <irui.wang@mediatek.com>
---
 Documentation/devicetree/bindings/media/mediatek-vcodec.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/mediatek-vcodec.txt b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
index f85276e629bf..e4644f8caee9 100644
--- a/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
+++ b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
@@ -23,6 +23,8 @@ Required properties:
 - iommus : should point to the respective IOMMU block with master port as
   argument, see Documentation/devicetree/bindings/iommu/mediatek,iommu.txt
   for details.
+- dma-ranges : describes how the physical address space of the IOMMU maps
+  to memory.
 One of the two following nodes:
 - mediatek,vpu : the node of the video processor unit, if using VPU.
 - mediatek,scp : the node of the SCP unit, if using SCP.
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/5] media: mtk-vcodec: Support 4GB~8GB range iova space for venc
  2021-02-03  8:37 [PATCH 0/5] Support H264 4K on MT8192 Irui Wang
  2021-02-03  8:37 ` [PATCH 1/5] dt-bindings: media: mtk-vcodec: Add dma-ranges property Irui Wang
@ 2021-02-03  8:37 ` Irui Wang
  2021-02-03  8:37 ` [PATCH 3/5] dt-bindings: media: mtk-vcodec: Add binding for MT8192 VENC Irui Wang
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Irui Wang @ 2021-02-03  8:37 UTC (permalink / raw)
  To: Alexandre Courbot, Hans Verkuil, Tiffany Lin, Andrew-CT Chen,
	Mauro Carvalho Chehab, Rob Herring, Matthias Brugger,
	Fritz Koenig, Tzung-Bi Shih
  Cc: Maoguang Meng, Longfei Wang, Yunfei Dong, Irui Wang, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, srv_heupstream,
	linux-mediatek

Uses the dma_set_mask_and_coherent helper to set venc
DMA bit mask to support 4GB~8GB range iova space.

Signed-off-by: Irui Wang <irui.wang@mediatek.com>
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
index 4bee42454253..e8552673bbc7 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
@@ -361,6 +361,9 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
 		goto err_event_workq;
 	}
 
+	if (of_get_property(pdev->dev.of_node, "dma-ranges", NULL))
+		dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(34));
+
 	ret = video_register_device(vfd_enc, VFL_TYPE_VIDEO, 1);
 	if (ret) {
 		mtk_v4l2_err("Failed to register video device");
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/5] dt-bindings: media: mtk-vcodec: Add binding for MT8192 VENC
  2021-02-03  8:37 [PATCH 0/5] Support H264 4K on MT8192 Irui Wang
  2021-02-03  8:37 ` [PATCH 1/5] dt-bindings: media: mtk-vcodec: Add dma-ranges property Irui Wang
  2021-02-03  8:37 ` [PATCH 2/5] media: mtk-vcodec: Support 4GB~8GB range iova space for venc Irui Wang
@ 2021-02-03  8:37 ` Irui Wang
  2021-02-10 22:54   ` Rob Herring
  2021-02-03  8:37 ` [PATCH 4/5] media: mtk-vcodec: Add MT8192 H264 venc driver Irui Wang
  2021-02-03  8:37 ` [PATCH 5/5] media: mtk-vcodec: Support H264 4K encoding on MT8192 Irui Wang
  4 siblings, 1 reply; 11+ messages in thread
From: Irui Wang @ 2021-02-03  8:37 UTC (permalink / raw)
  To: Alexandre Courbot, Hans Verkuil, Tiffany Lin, Andrew-CT Chen,
	Mauro Carvalho Chehab, Rob Herring, Matthias Brugger,
	Fritz Koenig, Tzung-Bi Shih
  Cc: Maoguang Meng, Longfei Wang, Yunfei Dong, Irui Wang, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, srv_heupstream,
	linux-mediatek

Updates binding document for mt8192 encoder driver.

Signed-off-by: Irui Wang <irui.wang@mediatek.com>
---
 .../bindings/media/mediatek-vcodec.txt        | 26 +++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/mediatek-vcodec.txt b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
index e4644f8caee9..c7fac557006f 100644
--- a/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
+++ b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
@@ -9,6 +9,7 @@ Required properties:
   "mediatek,mt8173-vcodec-avc-enc" for mt8173 avc encoder.
   "mediatek,mt8183-vcodec-enc" for MT8183 encoder.
   "mediatek,mt8173-vcodec-dec" for MT8173 decoder.
+  "mediatek,mt8192-vcodec-enc" for MT8192 encoder.
 - reg : Physical base address of the video codec registers and length of
   memory mapped region.
 - interrupts : interrupt number to the cpu.
@@ -128,3 +129,28 @@ vcodec_enc_lt: vcodec@19002000 {
     assigned-clocks = <&topckgen CLK_TOP_VENC_LT_SEL>;
     assigned-clock-parents = <&topckgen CLK_TOP_VCODECPLL_370P5>;
   };
+
+vcodec_enc: vcodec@0x17020000 {
+    compatible = "mediatek,mt8192-vcodec-enc";
+    reg = <0 0x17020000 0 0x2000>;
+    iommus = <&iommu0 M4U_PORT_L7_VENC_RCPU>,
+             <&iommu0 M4U_PORT_L7_VENC_REC>,
+             <&iommu0 M4U_PORT_L7_VENC_BSDMA>,
+             <&iommu0 M4U_PORT_L7_VENC_SV_COMV>,
+             <&iommu0 M4U_PORT_L7_VENC_RD_COMV>,
+             <&iommu0 M4U_PORT_L7_VENC_CUR_LUMA>,
+             <&iommu0 M4U_PORT_L7_VENC_CUR_CHROMA>,
+             <&iommu0 M4U_PORT_L7_VENC_REF_LUMA>,
+             <&iommu0 M4U_PORT_L7_VENC_REF_CHROMA>,
+             <&iommu0 M4U_PORT_L7_VENC_SUB_R_LUMA>,
+             <&iommu0 M4U_PORT_L7_VENC_SUB_W_LUMA>;
+    interrupts = <GIC_SPI 309 IRQ_TYPE_LEVEL_HIGH 0>;
+    dma-ranges = <0x1 0x0 0x0 0x40000000 0x0 0xfff00000>;
+    mediatek,scp = <&scp>;
+    power-domains = <&scpsys MT8192_POWER_DOMAIN_VENC>;
+    clocks = <&vencsys CLK_VENC_SET1_VENC>;
+    clock-names = "venc-set1";
+    assigned-clocks = <&topckgen CLK_TOP_VENC_SEL>;
+    assigned-clock-parents = <&topckgen CLK_TOP_UNIVPLL_D4>;
+};
+
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 4/5] media: mtk-vcodec: Add MT8192 H264 venc driver
  2021-02-03  8:37 [PATCH 0/5] Support H264 4K on MT8192 Irui Wang
                   ` (2 preceding siblings ...)
  2021-02-03  8:37 ` [PATCH 3/5] dt-bindings: media: mtk-vcodec: Add binding for MT8192 VENC Irui Wang
@ 2021-02-03  8:37 ` Irui Wang
  2021-02-03  8:37 ` [PATCH 5/5] media: mtk-vcodec: Support H264 4K encoding on MT8192 Irui Wang
  4 siblings, 0 replies; 11+ messages in thread
From: Irui Wang @ 2021-02-03  8:37 UTC (permalink / raw)
  To: Alexandre Courbot, Hans Verkuil, Tiffany Lin, Andrew-CT Chen,
	Mauro Carvalho Chehab, Rob Herring, Matthias Brugger,
	Fritz Koenig, Tzung-Bi Shih
  Cc: Maoguang Meng, Longfei Wang, Yunfei Dong, Irui Wang, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, srv_heupstream,
	linux-mediatek

Add MT8192 venc driver's compatible and device private data.

Signed-off-by: Irui Wang <irui.wang@mediatek.com>
---
 .../media/platform/mtk-vcodec/mtk_vcodec_drv.h   |  1 +
 .../platform/mtk-vcodec/mtk_vcodec_enc_drv.c     | 16 ++++++++++++++++
 2 files changed, 17 insertions(+)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
index 1594edcc706d..75914d2fd54a 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
@@ -303,6 +303,7 @@ struct mtk_vcodec_ctx {
 enum mtk_chip {
 	MTK_MT8173,
 	MTK_MT8183,
+	MTK_MT8192,
 };
 
 /**
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
index e8552673bbc7..dedc68b2260d 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
@@ -428,12 +428,28 @@ static const struct mtk_vcodec_enc_pdata mt8183_pdata = {
 	.core_id = VENC_SYS,
 };
 
+static const struct mtk_vcodec_enc_pdata mt8192_pdata = {
+	.chip = MTK_MT8192,
+	.name = MTK_VCODEC_ENC_NAME,
+	.uses_ext = true,
+	/* MT8192 supports the same capture formats as MT8183*/
+	.capture_formats = mtk_video_formats_capture_mt8183,
+	.num_capture_formats = ARRAY_SIZE(mtk_video_formats_capture_mt8183),
+	/* MT8192 supports the same output formats as MT8173 */
+	.output_formats = mtk_video_formats_output_mt8173,
+	.num_output_formats = ARRAY_SIZE(mtk_video_formats_output_mt8173),
+	.min_bitrate = 64,
+	.max_bitrate = 100000000,
+	.core_id = VENC_SYS,
+};
+
 static const struct of_device_id mtk_vcodec_enc_match[] = {
 	{.compatible = "mediatek,mt8173-vcodec-avc-enc",
 			.data = &mt8173_avc_pdata},
 	{.compatible = "mediatek,mt8173-vcodec-vp8-enc",
 			.data = &mt8173_vp8_pdata},
 	{.compatible = "mediatek,mt8183-vcodec-enc", .data = &mt8183_pdata},
+	{.compatible = "mediatek,mt8192-vcodec-enc", .data = &mt8192_pdata},
 	{},
 };
 MODULE_DEVICE_TABLE(of, mtk_vcodec_enc_match);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 5/5] media: mtk-vcodec: Support H264 4K encoding on MT8192
  2021-02-03  8:37 [PATCH 0/5] Support H264 4K on MT8192 Irui Wang
                   ` (3 preceding siblings ...)
  2021-02-03  8:37 ` [PATCH 4/5] media: mtk-vcodec: Add MT8192 H264 venc driver Irui Wang
@ 2021-02-03  8:37 ` Irui Wang
  4 siblings, 0 replies; 11+ messages in thread
From: Irui Wang @ 2021-02-03  8:37 UTC (permalink / raw)
  To: Alexandre Courbot, Hans Verkuil, Tiffany Lin, Andrew-CT Chen,
	Mauro Carvalho Chehab, Rob Herring, Matthias Brugger,
	Fritz Koenig, Tzung-Bi Shih
  Cc: Maoguang Meng, Longfei Wang, Yunfei Dong, Irui Wang, linux-media,
	devicetree, linux-kernel, linux-arm-kernel, srv_heupstream,
	linux-mediatek

Supports H264 4K (3840x2176) and level 5.1 encoding on MT8192.

Signed-off-by: Irui Wang <irui.wang@mediatek.com>
---
 .../platform/mtk-vcodec/mtk_vcodec_enc.c      | 58 ++++++++++++++-----
 .../platform/mtk-vcodec/venc/venc_h264_if.c   |  4 ++
 2 files changed, 47 insertions(+), 15 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
index 0da6871b4b39..3d8c8fe24372 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
@@ -21,12 +21,16 @@
 #define MTK_VENC_MIN_H	128U
 #define MTK_VENC_MAX_W	1920U
 #define MTK_VENC_MAX_H	1088U
+#define MTK_VENC_4K_MAX_W	3840U
+#define MTK_VENC_4K_MAX_H	2176U
+
 #define DFT_CFG_WIDTH	MTK_VENC_MIN_W
 #define DFT_CFG_HEIGHT	MTK_VENC_MIN_H
 #define MTK_MAX_CTRLS_HINT	20
 
 #define MTK_DEFAULT_FRAMERATE_NUM 1001
 #define MTK_DEFAULT_FRAMERATE_DENOM 30000
+#define MTK_VENC_4K_CAPABILITY_ENABLE BIT(0)
 
 static void mtk_venc_worker(struct work_struct *work);
 
@@ -152,18 +156,23 @@ static int vidioc_enum_framesizes(struct file *file, void *fh,
 				  struct v4l2_frmsizeenum *fsize)
 {
 	const struct mtk_video_fmt *fmt;
+	struct mtk_vcodec_ctx *ctx = fh_to_ctx(fh);
 
 	if (fsize->index != 0)
 		return -EINVAL;
 
 	fmt = mtk_venc_find_format(fsize->pixel_format,
-				   fh_to_ctx(fh)->dev->venc_pdata);
+			ctx->dev->venc_pdata);
 	if (!fmt)
 		return -EINVAL;
 
 	fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE;
 	fsize->stepwise = mtk_venc_framesizes;
 
+	if (ctx->dev->enc_capability & MTK_VENC_4K_CAPABILITY_ENABLE) {
+		fsize->stepwise.max_width = MTK_VENC_4K_MAX_W;
+		fsize->stepwise.max_height = MTK_VENC_4K_MAX_H;
+	}
 	return 0;
 }
 
@@ -252,7 +261,7 @@ static struct mtk_q_data *mtk_venc_get_q_data(struct mtk_vcodec_ctx *ctx,
 /* V4L2 specification suggests the driver corrects the format struct if any of
  * the dimensions is unsupported
  */
-static int vidioc_try_fmt(struct v4l2_format *f,
+static int vidioc_try_fmt(struct mtk_vcodec_ctx *ctx, struct v4l2_format *f,
 			  const struct mtk_video_fmt *fmt)
 {
 	struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp;
@@ -265,13 +274,22 @@ static int vidioc_try_fmt(struct v4l2_format *f,
 		pix_fmt_mp->plane_fmt[0].bytesperline = 0;
 	} else if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
 		int tmp_w, tmp_h;
+		unsigned int max_width, max_height;
+
+		if (ctx->dev->enc_capability & MTK_VENC_4K_CAPABILITY_ENABLE) {
+			max_width = MTK_VENC_4K_MAX_W;
+			max_height = MTK_VENC_4K_MAX_H;
+		} else {
+			max_width = MTK_VENC_MAX_W;
+			max_height = MTK_VENC_MAX_H;
+		}
 
 		pix_fmt_mp->height = clamp(pix_fmt_mp->height,
 					MTK_VENC_MIN_H,
-					MTK_VENC_MAX_H);
+					max_height);
 		pix_fmt_mp->width = clamp(pix_fmt_mp->width,
 					MTK_VENC_MIN_W,
-					MTK_VENC_MAX_W);
+					max_width);
 
 		/* find next closer width align 16, heign align 32, size align
 		 * 64 rectangle
@@ -280,16 +298,16 @@ static int vidioc_try_fmt(struct v4l2_format *f,
 		tmp_h = pix_fmt_mp->height;
 		v4l_bound_align_image(&pix_fmt_mp->width,
 					MTK_VENC_MIN_W,
-					MTK_VENC_MAX_W, 4,
+					max_width, 4,
 					&pix_fmt_mp->height,
 					MTK_VENC_MIN_H,
-					MTK_VENC_MAX_H, 5, 6);
+					max_height, 5, 6);
 
 		if (pix_fmt_mp->width < tmp_w &&
-			(pix_fmt_mp->width + 16) <= MTK_VENC_MAX_W)
+			(pix_fmt_mp->width + 16) <= max_width)
 			pix_fmt_mp->width += 16;
 		if (pix_fmt_mp->height < tmp_h &&
-			(pix_fmt_mp->height + 32) <= MTK_VENC_MAX_H)
+			(pix_fmt_mp->height + 32) <= max_height)
 			pix_fmt_mp->height += 32;
 
 		mtk_v4l2_debug(0,
@@ -416,7 +434,7 @@ static int vidioc_venc_s_fmt_cap(struct file *file, void *priv,
 	}
 
 	q_data->fmt = fmt;
-	ret = vidioc_try_fmt(f, q_data->fmt);
+	ret = vidioc_try_fmt(ctx, f, q_data->fmt);
 	if (ret)
 		return ret;
 
@@ -489,7 +507,7 @@ static int vidioc_venc_s_fmt_out(struct file *file, void *priv,
 	q_data->visible_width = f->fmt.pix_mp.width;
 	q_data->visible_height = f->fmt.pix_mp.height;
 	q_data->fmt = fmt;
-	ret = vidioc_try_fmt(f, q_data->fmt);
+	ret = vidioc_try_fmt(ctx, f, q_data->fmt);
 	if (ret)
 		return ret;
 
@@ -566,7 +584,7 @@ static int vidioc_try_fmt_vid_cap_mplane(struct file *file, void *priv,
 	f->fmt.pix_mp.quantization = ctx->quantization;
 	f->fmt.pix_mp.xfer_func = ctx->xfer_func;
 
-	return vidioc_try_fmt(f, fmt);
+	return vidioc_try_fmt(ctx, f, fmt);
 }
 
 static int vidioc_try_fmt_vid_out_mplane(struct file *file, void *priv,
@@ -588,7 +606,7 @@ static int vidioc_try_fmt_vid_out_mplane(struct file *file, void *priv,
 		f->fmt.pix_mp.xfer_func = V4L2_XFER_FUNC_DEFAULT;
 	}
 
-	return vidioc_try_fmt(f, fmt);
+	return vidioc_try_fmt(ctx, f, fmt);
 }
 
 static int vidioc_venc_g_selection(struct file *file, void *priv,
@@ -1260,9 +1278,19 @@ int mtk_vcodec_enc_ctrls_setup(struct mtk_vcodec_ctx *ctx)
 	v4l2_ctrl_new_std_menu(handler, ops, V4L2_CID_MPEG_VIDEO_H264_PROFILE,
 			V4L2_MPEG_VIDEO_H264_PROFILE_HIGH,
 			0, V4L2_MPEG_VIDEO_H264_PROFILE_HIGH);
-	v4l2_ctrl_new_std_menu(handler, ops, V4L2_CID_MPEG_VIDEO_H264_LEVEL,
-			V4L2_MPEG_VIDEO_H264_LEVEL_4_2,
-			0, V4L2_MPEG_VIDEO_H264_LEVEL_4_0);
+
+	if (ctx->dev->enc_capability & MTK_VENC_4K_CAPABILITY_ENABLE) {
+		v4l2_ctrl_new_std_menu(handler, ops,
+				       V4L2_CID_MPEG_VIDEO_H264_LEVEL,
+				       V4L2_MPEG_VIDEO_H264_LEVEL_5_1,
+				       0, V4L2_MPEG_VIDEO_H264_LEVEL_4_0);
+	} else {
+		v4l2_ctrl_new_std_menu(handler, ops,
+				       V4L2_CID_MPEG_VIDEO_H264_LEVEL,
+				       V4L2_MPEG_VIDEO_H264_LEVEL_4_2,
+				       0, V4L2_MPEG_VIDEO_H264_LEVEL_4_0);
+	}
+
 	if (handler->error) {
 		mtk_v4l2_err("Init control handler fail %d",
 				handler->error);
diff --git a/drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c b/drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c
index d0123dfc5f93..b6a4f2074fa5 100644
--- a/drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c
+++ b/drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c
@@ -215,6 +215,10 @@ static unsigned int h264_get_level(struct venc_h264_inst *inst,
 		return 41;
 	case V4L2_MPEG_VIDEO_H264_LEVEL_4_2:
 		return 42;
+	case V4L2_MPEG_VIDEO_H264_LEVEL_5_0:
+		return 50;
+	case V4L2_MPEG_VIDEO_H264_LEVEL_5_1:
+		return 51;
 	default:
 		mtk_vcodec_debug(inst, "unsupported level %d", level);
 		return 31;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/5] dt-bindings: media: mtk-vcodec: Add dma-ranges property
  2021-02-03  8:37 ` [PATCH 1/5] dt-bindings: media: mtk-vcodec: Add dma-ranges property Irui Wang
@ 2021-02-10 22:53   ` Rob Herring
  2021-03-01  6:45     ` Irui Wang
  0 siblings, 1 reply; 11+ messages in thread
From: Rob Herring @ 2021-02-10 22:53 UTC (permalink / raw)
  To: Irui Wang
  Cc: Alexandre Courbot, Hans Verkuil, Tiffany Lin, Andrew-CT Chen,
	Mauro Carvalho Chehab, Matthias Brugger, Fritz Koenig,
	Tzung-Bi Shih, Maoguang Meng, Longfei Wang, Yunfei Dong,
	linux-media, devicetree, linux-kernel, linux-arm-kernel,
	srv_heupstream, linux-mediatek

On Wed, Feb 03, 2021 at 04:37:48PM +0800, Irui Wang wrote:
> Adds dma-ranges property for DMA addresses translation.
> 
> Signed-off-by: Irui Wang <irui.wang@mediatek.com>
> ---
>  Documentation/devicetree/bindings/media/mediatek-vcodec.txt | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/media/mediatek-vcodec.txt b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
> index f85276e629bf..e4644f8caee9 100644
> --- a/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
> +++ b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
> @@ -23,6 +23,8 @@ Required properties:
>  - iommus : should point to the respective IOMMU block with master port as
>    argument, see Documentation/devicetree/bindings/iommu/mediatek,iommu.txt
>    for details.
> +- dma-ranges : describes how the physical address space of the IOMMU maps
> +  to memory.

dma-ranges is supposed to be in a bus/parent node.

>  One of the two following nodes:
>  - mediatek,vpu : the node of the video processor unit, if using VPU.
>  - mediatek,scp : the node of the SCP unit, if using SCP.
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/5] dt-bindings: media: mtk-vcodec: Add binding for MT8192 VENC
  2021-02-03  8:37 ` [PATCH 3/5] dt-bindings: media: mtk-vcodec: Add binding for MT8192 VENC Irui Wang
@ 2021-02-10 22:54   ` Rob Herring
  0 siblings, 0 replies; 11+ messages in thread
From: Rob Herring @ 2021-02-10 22:54 UTC (permalink / raw)
  To: Irui Wang
  Cc: Alexandre Courbot, Hans Verkuil, Tiffany Lin, Andrew-CT Chen,
	Mauro Carvalho Chehab, Matthias Brugger, Fritz Koenig,
	Tzung-Bi Shih, Maoguang Meng, Longfei Wang, Yunfei Dong,
	linux-media, devicetree, linux-kernel, linux-arm-kernel,
	srv_heupstream, linux-mediatek

On Wed, Feb 03, 2021 at 04:37:50PM +0800, Irui Wang wrote:
> Updates binding document for mt8192 encoder driver.
> 
> Signed-off-by: Irui Wang <irui.wang@mediatek.com>
> ---
>  .../bindings/media/mediatek-vcodec.txt        | 26 +++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/media/mediatek-vcodec.txt b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
> index e4644f8caee9..c7fac557006f 100644
> --- a/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
> +++ b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
> @@ -9,6 +9,7 @@ Required properties:
>    "mediatek,mt8173-vcodec-avc-enc" for mt8173 avc encoder.
>    "mediatek,mt8183-vcodec-enc" for MT8183 encoder.
>    "mediatek,mt8173-vcodec-dec" for MT8173 decoder.
> +  "mediatek,mt8192-vcodec-enc" for MT8192 encoder.
>  - reg : Physical base address of the video codec registers and length of
>    memory mapped region.
>  - interrupts : interrupt number to the cpu.
> @@ -128,3 +129,28 @@ vcodec_enc_lt: vcodec@19002000 {
>      assigned-clocks = <&topckgen CLK_TOP_VENC_LT_SEL>;
>      assigned-clock-parents = <&topckgen CLK_TOP_VCODECPLL_370P5>;
>    };
> +
> +vcodec_enc: vcodec@0x17020000 {

Don't add an example just for a new compatible.

> +    compatible = "mediatek,mt8192-vcodec-enc";
> +    reg = <0 0x17020000 0 0x2000>;
> +    iommus = <&iommu0 M4U_PORT_L7_VENC_RCPU>,
> +             <&iommu0 M4U_PORT_L7_VENC_REC>,
> +             <&iommu0 M4U_PORT_L7_VENC_BSDMA>,
> +             <&iommu0 M4U_PORT_L7_VENC_SV_COMV>,
> +             <&iommu0 M4U_PORT_L7_VENC_RD_COMV>,
> +             <&iommu0 M4U_PORT_L7_VENC_CUR_LUMA>,
> +             <&iommu0 M4U_PORT_L7_VENC_CUR_CHROMA>,
> +             <&iommu0 M4U_PORT_L7_VENC_REF_LUMA>,
> +             <&iommu0 M4U_PORT_L7_VENC_REF_CHROMA>,
> +             <&iommu0 M4U_PORT_L7_VENC_SUB_R_LUMA>,
> +             <&iommu0 M4U_PORT_L7_VENC_SUB_W_LUMA>;
> +    interrupts = <GIC_SPI 309 IRQ_TYPE_LEVEL_HIGH 0>;
> +    dma-ranges = <0x1 0x0 0x0 0x40000000 0x0 0xfff00000>;
> +    mediatek,scp = <&scp>;
> +    power-domains = <&scpsys MT8192_POWER_DOMAIN_VENC>;
> +    clocks = <&vencsys CLK_VENC_SET1_VENC>;
> +    clock-names = "venc-set1";
> +    assigned-clocks = <&topckgen CLK_TOP_VENC_SEL>;
> +    assigned-clock-parents = <&topckgen CLK_TOP_UNIVPLL_D4>;
> +};
> +
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/5] dt-bindings: media: mtk-vcodec: Add dma-ranges property
  2021-02-10 22:53   ` Rob Herring
@ 2021-03-01  6:45     ` Irui Wang
  2021-04-29 11:15       ` Hans Verkuil
  0 siblings, 1 reply; 11+ messages in thread
From: Irui Wang @ 2021-03-01  6:45 UTC (permalink / raw)
  To: Rob Herring
  Cc: Alexandre Courbot, Hans Verkuil, Tiffany Lin, Andrew-CT Chen,
	Mauro Carvalho Chehab, Matthias Brugger, Fritz Koenig,
	Tzung-Bi Shih, Maoguang Meng, Longfei Wang, Yunfei Dong,
	linux-media, devicetree, linux-kernel, linux-arm-kernel,
	srv_heupstream, linux-mediatek

On Wed, 2021-02-10 at 16:53 -0600, Rob Herring wrote:
> On Wed, Feb 03, 2021 at 04:37:48PM +0800, Irui Wang wrote:
> > Adds dma-ranges property for DMA addresses translation.
> > 
> > Signed-off-by: Irui Wang <irui.wang@mediatek.com>
> > ---
> >  Documentation/devicetree/bindings/media/mediatek-vcodec.txt | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/media/mediatek-vcodec.txt b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
> > index f85276e629bf..e4644f8caee9 100644
> > --- a/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
> > +++ b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
> > @@ -23,6 +23,8 @@ Required properties:
> >  - iommus : should point to the respective IOMMU block with master port as
> >    argument, see Documentation/devicetree/bindings/iommu/mediatek,iommu.txt
> >    for details.
> > +- dma-ranges : describes how the physical address space of the IOMMU maps
> > +  to memory.
> 
> dma-ranges is supposed to be in a bus/parent node.
Dear Rob,

The mt8192 iommu support 0~16GB iova. We separate it to four banks:
0~4G; 4G~8G; 8G~12G; 12G~16G.

The "dma-ranges" could be used to adjust the bank we locate.
If we don't set this property. The default range always is 0~4G.

Here we don't have actual bus/parent concept here.  And the iova
requirement is for our HW. Thus put the property in our node.

Is this OK? If this is ok for you, I will put this message in the commit
message and binding in next version.

Regards
> 
> >  One of the two following nodes:
> >  - mediatek,vpu : the node of the video processor unit, if using VPU.
> >  - mediatek,scp : the node of the SCP unit, if using SCP.
> > -- 
> > 2.25.1
> > 


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/5] dt-bindings: media: mtk-vcodec: Add dma-ranges property
  2021-03-01  6:45     ` Irui Wang
@ 2021-04-29 11:15       ` Hans Verkuil
  2021-05-17  7:51         ` Irui Wang
  0 siblings, 1 reply; 11+ messages in thread
From: Hans Verkuil @ 2021-04-29 11:15 UTC (permalink / raw)
  To: Irui Wang, Rob Herring
  Cc: Alexandre Courbot, Tiffany Lin, Andrew-CT Chen,
	Mauro Carvalho Chehab, Matthias Brugger, Fritz Koenig,
	Tzung-Bi Shih, Maoguang Meng, Longfei Wang, Yunfei Dong,
	linux-media, devicetree, linux-kernel, linux-arm-kernel,
	srv_heupstream, linux-mediatek

Hi Rob,

On 01/03/2021 07:45, Irui Wang wrote:
> On Wed, 2021-02-10 at 16:53 -0600, Rob Herring wrote:
>> On Wed, Feb 03, 2021 at 04:37:48PM +0800, Irui Wang wrote:
>>> Adds dma-ranges property for DMA addresses translation.
>>>
>>> Signed-off-by: Irui Wang <irui.wang@mediatek.com>
>>> ---
>>>  Documentation/devicetree/bindings/media/mediatek-vcodec.txt | 2 ++
>>>  1 file changed, 2 insertions(+)
>>>
>>> diff --git a/Documentation/devicetree/bindings/media/mediatek-vcodec.txt b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
>>> index f85276e629bf..e4644f8caee9 100644
>>> --- a/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
>>> +++ b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
>>> @@ -23,6 +23,8 @@ Required properties:
>>>  - iommus : should point to the respective IOMMU block with master port as
>>>    argument, see Documentation/devicetree/bindings/iommu/mediatek,iommu.txt
>>>    for details.
>>> +- dma-ranges : describes how the physical address space of the IOMMU maps
>>> +  to memory.
>>
>> dma-ranges is supposed to be in a bus/parent node.
> Dear Rob,
> 
> The mt8192 iommu support 0~16GB iova. We separate it to four banks:
> 0~4G; 4G~8G; 8G~12G; 12G~16G.
> 
> The "dma-ranges" could be used to adjust the bank we locate.
> If we don't set this property. The default range always is 0~4G.
> 
> Here we don't have actual bus/parent concept here.  And the iova
> requirement is for our HW. Thus put the property in our node.
> 
> Is this OK? If this is ok for you, I will put this message in the commit
> message and binding in next version.

Can you answer Irui's question? Just a reminder...

Much appreciated!

Regards,

	Hans

> 
> Regards
>>
>>>  One of the two following nodes:
>>>  - mediatek,vpu : the node of the video processor unit, if using VPU.
>>>  - mediatek,scp : the node of the SCP unit, if using SCP.
>>> -- 
>>> 2.25.1
>>>
> 


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/5] dt-bindings: media: mtk-vcodec: Add dma-ranges property
  2021-04-29 11:15       ` Hans Verkuil
@ 2021-05-17  7:51         ` Irui Wang
  0 siblings, 0 replies; 11+ messages in thread
From: Irui Wang @ 2021-05-17  7:51 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: Rob Herring, Alexandre Courbot, Tiffany Lin, Andrew-CT Chen,
	Mauro Carvalho Chehab, Matthias Brugger, Fritz Koenig,
	Tzung-Bi Shih, Maoguang Meng, Longfei Wang, Yunfei Dong,
	linux-media, devicetree, linux-kernel, linux-arm-kernel,
	srv_heupstream, linux-mediatek

Dear Hans, Rob and Maintainers,

Much appreciated for reviewing this patchset, we have sent PATCH-V3 for
the patchset with Rob's comments:
https://patchwork.kernel.org/project/linux-mediatek/cover/20210412124555.26897-1-irui.wang@mediatek.com/

Just Gentle ping for this V3 patch.

Thanks,
Best Regards

On Thu, 2021-04-29 at 13:15 +0200, Hans Verkuil wrote:
> Hi Rob,
> 
> On 01/03/2021 07:45, Irui Wang wrote:
> > On Wed, 2021-02-10 at 16:53 -0600, Rob Herring wrote:
> >> On Wed, Feb 03, 2021 at 04:37:48PM +0800, Irui Wang wrote:
> >>> Adds dma-ranges property for DMA addresses translation.
> >>>
> >>> Signed-off-by: Irui Wang <irui.wang@mediatek.com>
> >>> ---
> >>>  Documentation/devicetree/bindings/media/mediatek-vcodec.txt | 2 ++
> >>>  1 file changed, 2 insertions(+)
> >>>
> >>> diff --git a/Documentation/devicetree/bindings/media/mediatek-vcodec.txt b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
> >>> index f85276e629bf..e4644f8caee9 100644
> >>> --- a/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
> >>> +++ b/Documentation/devicetree/bindings/media/mediatek-vcodec.txt
> >>> @@ -23,6 +23,8 @@ Required properties:
> >>>  - iommus : should point to the respective IOMMU block with master port as
> >>>    argument, see Documentation/devicetree/bindings/iommu/mediatek,iommu.txt
> >>>    for details.
> >>> +- dma-ranges : describes how the physical address space of the IOMMU maps
> >>> +  to memory.
> >>
> >> dma-ranges is supposed to be in a bus/parent node.
> > Dear Rob,
> > 
> > The mt8192 iommu support 0~16GB iova. We separate it to four banks:
> > 0~4G; 4G~8G; 8G~12G; 12G~16G.
> > 
> > The "dma-ranges" could be used to adjust the bank we locate.
> > If we don't set this property. The default range always is 0~4G.
> > 
> > Here we don't have actual bus/parent concept here.  And the iova
> > requirement is for our HW. Thus put the property in our node.
> > 
> > Is this OK? If this is ok for you, I will put this message in the commit
> > message and binding in next version.
> 
> Can you answer Irui's question? Just a reminder...
> 
> Much appreciated!
> 
> Regards,
> 
> 	Hans
> 
> > 
> > Regards
> >>
> >>>  One of the two following nodes:
> >>>  - mediatek,vpu : the node of the video processor unit, if using VPU.
> >>>  - mediatek,scp : the node of the SCP unit, if using SCP.
> >>> -- 
> >>> 2.25.1
> >>>
> > 
> 


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-05-17  7:52 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-03  8:37 [PATCH 0/5] Support H264 4K on MT8192 Irui Wang
2021-02-03  8:37 ` [PATCH 1/5] dt-bindings: media: mtk-vcodec: Add dma-ranges property Irui Wang
2021-02-10 22:53   ` Rob Herring
2021-03-01  6:45     ` Irui Wang
2021-04-29 11:15       ` Hans Verkuil
2021-05-17  7:51         ` Irui Wang
2021-02-03  8:37 ` [PATCH 2/5] media: mtk-vcodec: Support 4GB~8GB range iova space for venc Irui Wang
2021-02-03  8:37 ` [PATCH 3/5] dt-bindings: media: mtk-vcodec: Add binding for MT8192 VENC Irui Wang
2021-02-10 22:54   ` Rob Herring
2021-02-03  8:37 ` [PATCH 4/5] media: mtk-vcodec: Add MT8192 H264 venc driver Irui Wang
2021-02-03  8:37 ` [PATCH 5/5] media: mtk-vcodec: Support H264 4K encoding on MT8192 Irui Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).