media: mtk-vcodec: Support 34bits dma address for vdec
authorYunfei Dong <yunfei.dong@mediatek.com>
Thu, 13 Jan 2022 04:10:51 +0000 (05:10 +0100)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Sun, 23 Jan 2022 20:18:45 +0000 (21:18 +0100)
Use the dma_set_mask_and_coherent helper to set vdec
DMA bit mask to support 34bits iova space(16GB) that
the mt8192 iommu HW support.

Whole the iova range separate to 0~4G/4G~8G/8G~12G/12G~16G,
regarding which iova range VDEC actually locate, it
depends on the dma-ranges property of vdec dtsi node.

Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c

index 1b67ed8f7f527cbed7d4cc4559f99a02b7a80edc..08d8e02559c6cd441e91256598b154a8c8b70827 100644 (file)
@@ -323,6 +323,14 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
                }
        }
 
+       if (of_get_property(pdev->dev.of_node, "dma-ranges", NULL)) {
+               ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(34));
+               if (ret) {
+                       mtk_v4l2_err("Failed to set mask");
+                       goto err_core_workq;
+               }
+       }
+
        for (i = 0; i < MTK_VDEC_HW_MAX; i++)
                mutex_init(&dev->dec_mutex[i]);
        mutex_init(&dev->dev_mutex);