media: mtk-vcodec: Add new interface to lock different hardware
authorYunfei Dong <yunfei.dong@mediatek.com>
Thu, 13 Jan 2022 04:10:49 +0000 (05:10 +0100)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Sun, 23 Jan 2022 20:18:45 +0000 (21:18 +0100)
For add new hardware, not only need to lock lat hardware, also
need to lock core hardware in case of different instance start
to decoder at the same time.

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.c
drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h

index 2b334a8a81c626766717a00e4b0b4b737aa0c94c..130ecef2e766462abea9181714b12d3346e89600 100644 (file)
@@ -105,12 +105,12 @@ static int vidioc_decoder_cmd(struct file *file, void *priv,
 
 void mtk_vdec_unlock(struct mtk_vcodec_ctx *ctx)
 {
-       mutex_unlock(&ctx->dev->dec_mutex);
+       mutex_unlock(&ctx->dev->dec_mutex[ctx->hw_id]);
 }
 
 void mtk_vdec_lock(struct mtk_vcodec_ctx *ctx)
 {
-       mutex_lock(&ctx->dev->dec_mutex);
+       mutex_lock(&ctx->dev->dec_mutex[ctx->hw_id]);
 }
 
 void mtk_vcodec_dec_release(struct mtk_vcodec_ctx *ctx)
index ffc4ba698876ed3013d3d59bf73bba827c777539..d592104023d9ca9a87c59f0da498f7a10effb985 100644 (file)
@@ -279,7 +279,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
        struct video_device *vfd_dec;
        phandle rproc_phandle;
        enum mtk_vcodec_fw_type fw_type;
-       int ret;
+       int i, ret;
 
        dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
        if (!dev)
@@ -311,7 +311,8 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
                goto err_dec_pm;
        }
 
-       mutex_init(&dev->dec_mutex);
+       for (i = 0; i < MTK_VDEC_HW_MAX; i++)
+               mutex_init(&dev->dec_mutex[i]);
        mutex_init(&dev->dev_mutex);
        spin_lock_init(&dev->irqlock);
 
index 4d3fd2a7a56eee94cbc08f6c4f4d525c582c087e..cefac02624263e7b4eeaf39f3330c88647d48ed5 100644 (file)
@@ -500,7 +500,8 @@ struct mtk_vcodec_dev {
        int dec_irq;
        int enc_irq;
 
-       struct mutex dec_mutex;
+       /* decoder hardware mutex lock */
+       struct mutex dec_mutex[MTK_VDEC_HW_MAX];
        struct mutex enc_mutex;
 
        struct mtk_vcodec_pm pm;