[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220317082230.23622-6-irui.wang@mediatek.com>
Date: Thu, 17 Mar 2022 16:22:25 +0800
From: Irui Wang <irui.wang@...iatek.com>
To: Hans Verkuil <hverkuil-cisco@...all.nl>,
Tzung-Bi Shih <tzungbi@...omium.org>,
Rob Herring <robh+dt@...nel.org>,
Alexandre Courbot <acourbot@...omium.org>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
"Matthias Brugger" <matthias.bgg@...il.com>,
Tomasz Figa <tfiga@...gle.com>,
<angelogioacchino.delregno@...labora.com>,
Yong Wu <yong.wu@...iatek.com>,
Tiffany Lin <tiffany.lin@...iatek.com>,
Andrew-CT Chen <andrew-ct.chen@...iatek.com>
CC: Hsin-Yi Wang <hsinyi@...omium.org>,
Maoguang Meng <maoguang.meng@...iatek.com>,
Longfei Wang <longfei.wang@...iatek.com>,
Yunfei Dong <yunfei.dong@...iatek.com>,
Fritz Koenig <frkoenig@...omium.org>,
Irui Wang <irui.wang@...iatek.com>,
<linux-media@...r.kernel.org>, <devicetree@...r.kernel.org>,
<linux-kernel@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>,
<srv_heupstream@...iatek.com>,
<linux-mediatek@...ts.infradead.org>,
<Project_Global_Chrome_Upstream_Group@...iatek.com>
Subject: [PATCH v3, 05/10] media: mtk-vcodec: mtk-vcodec: Rewrite venc power manage interface
The args "struct mtk_vcodec_dev *" doesn't appropriate for init_clk
functions because of sub-devices. For main device, it has no "pm/clk"
properties in dtsi, sub-devices will init their own "pm/clk" instead.
So rewrite the pm interface with args "platform_device *" and
"mtk_vcodec_pm*".
Signed-off-by: Irui Wang <irui.wang@...iatek.com>
---
drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_core.c | 8 ++++++++
drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c | 2 +-
drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c | 8 ++------
drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.h | 4 ++--
4 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_core.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_core.c
index 9d3ea5a8afe4..7e376413beaa 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_core.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_core.c
@@ -13,6 +13,7 @@
#include "mtk_vcodec_drv.h"
#include "mtk_vcodec_enc.h"
#include "mtk_vcodec_enc_core.h"
+#include "mtk_vcodec_enc_pm.h"
#include "mtk_vcodec_intr.h"
static const struct of_device_id mtk_venc_core_ids[] = {
@@ -117,6 +118,13 @@ static int mtk_venc_core_probe(struct platform_device *pdev)
return dev_err_probe(dev, -EINVAL,
"Invalid core id %d\n", core->core_id);
+ ret = mtk_vcodec_init_enc_clk(core->plat_dev, &core->pm);
+ if (ret < 0)
+ return dev_err_probe(dev, ret,
+ "Failed to get venc core clock source!");
+
+ pm_runtime_enable(&pdev->dev);
+
main_dev->enc_core_dev[core->core_id] = core;
core->main_dev = main_dev;
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 d540d52191d9..1b1c17b03ef5 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
@@ -272,7 +272,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
}
if (!dev->venc_multi_core) {
- ret = mtk_vcodec_init_enc_clk(dev);
+ ret = mtk_vcodec_init_enc_clk(dev->plat_dev, &dev->pm);
if (ret < 0) {
dev_err(&pdev->dev,
"Failed to get mtk vcodec clock source!");
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c
index 74495edab558..1e814fc3172f 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c
@@ -12,17 +12,13 @@
#include "mtk_vcodec_enc_pm.h"
#include "mtk_vcodec_util.h"
-int mtk_vcodec_init_enc_clk(struct mtk_vcodec_dev *mtkdev)
+int mtk_vcodec_init_enc_clk(struct platform_device *pdev,
+ struct mtk_vcodec_pm *pm)
{
- struct platform_device *pdev;
- struct mtk_vcodec_pm *pm;
struct mtk_vcodec_clk *enc_clk;
struct mtk_vcodec_clk_info *clk_info;
int ret, i;
- pdev = mtkdev->plat_dev;
- pm = &mtkdev->pm;
- memset(pm, 0, sizeof(struct mtk_vcodec_pm));
pm->dev = &pdev->dev;
enc_clk = &pm->venc_clk;
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.h b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.h
index bc455cefc0cd..97a394c68f4e 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.h
@@ -9,8 +9,8 @@
#include "mtk_vcodec_drv.h"
-int mtk_vcodec_init_enc_clk(struct mtk_vcodec_dev *dev);
-
+int mtk_vcodec_init_enc_clk(struct platform_device *pdev,
+ struct mtk_vcodec_pm *pm);
void mtk_vcodec_enc_clock_on(struct mtk_vcodec_pm *pm);
void mtk_vcodec_enc_clock_off(struct mtk_vcodec_pm *pm);
--
2.18.0
Powered by blists - more mailing lists