[PATCH v2,4/9] media: mtk-jpegenc: Refactor jpeg clock interface
kyrie.wu
kyrie.wu at mediatek.com
Wed Jun 30 00:27:54 PDT 2021
Using the needed param for lock on/off function.
Signed-off-by: kyrie.wu <kyrie.wu at mediatek.com>
---
drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c | 46 ++++++++++++++++++++++++-
drivers/media/platform/mtk-jpeg/mtk_jpeg_core.h | 28 +++++++++++++++
2 files changed, 73 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
index 24edd87..7c053e3 100644
--- a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
+++ b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c
@@ -1053,7 +1053,32 @@ static int mtk_jpeg_queue_init(void *priv, struct vb2_queue *src_vq,
static void mtk_jpeg_clk_on(struct mtk_jpeg_dev *jpeg)
{
- int ret;
+ struct mtk_jpeg_dev *comp_dev;
+ struct mtk_jpegenc_pm *pm;
+ struct mtk_jpegenc_clk *jpegclk;
+ struct mtk_jpegenc_clk_info *clk_info;
+ int ret, i;
+
+ if (jpeg->variant->is_encoder) {
+ for (i = 0; i < MTK_JPEGENC_HW_MAX; i++) {
+ comp_dev = jpeg->hw_dev[i];
+ if (!comp_dev) {
+ dev_err(jpeg->dev, "Failed to get hw dev\n");
+ return;
+ }
+
+ pm = &comp_dev->pm;
+ jpegclk = &pm->venc_clk;
+ clk_info = jpegclk->clk_info;
+ ret = clk_prepare_enable(clk_info->jpegenc_clk);
+ if (ret) {
+ dev_err(jpeg->dev, "jpegenc clk enable %d %s fail\n",
+ i, jpegclk->clk_info->clk_name);
+ return;
+ }
+ }
+ return;
+ }
ret = mtk_smi_larb_get(jpeg->larb);
if (ret)
@@ -1067,6 +1092,25 @@ static void mtk_jpeg_clk_on(struct mtk_jpeg_dev *jpeg)
static void mtk_jpeg_clk_off(struct mtk_jpeg_dev *jpeg)
{
+ struct mtk_jpeg_dev *comp_dev;
+ struct mtk_jpegenc_pm *pm;
+ struct mtk_jpegenc_clk *jpegclk;
+ int i;
+
+ if (jpeg->variant->is_encoder) {
+ for (i = 0; i < MTK_JPEGENC_HW_MAX; i++) {
+ comp_dev = jpeg->hw_dev[i];
+ if (!comp_dev) {
+ dev_err(jpeg->dev, "Failed to get hw dev\n");
+ return;
+ }
+
+ pm = &comp_dev->pm;
+ jpegclk = &pm->venc_clk;
+ clk_disable_unprepare(jpegclk->clk_info->jpegenc_clk);
+ }
+ return;
+ }
clk_bulk_disable_unprepare(jpeg->variant->num_clks,
jpeg->variant->clks);
mtk_smi_larb_put(jpeg->larb);
diff --git a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.h b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.h
index bdbd768..93ea71c 100644
--- a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.h
+++ b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.h
@@ -75,6 +75,31 @@ struct mtk_jpeg_variant {
u32 cap_q_default_fourcc;
};
+enum mtk_jpegenc_hw_id {
+ MTK_JPEGENC_HW0,
+ MTK_JPEGENC_HW1,
+ MTK_JPEGENC_HW_MAX,
+};
+
+/** * struct mtk_jpegenc_clk_info - Structure used to store clock name */
+struct mtk_jpegenc_clk_info {
+ const char *clk_name;
+ struct clk *jpegenc_clk;
+};
+
+/* struct mtk_vcodec_clk - Structure used to store vcodec clock information */
+struct mtk_jpegenc_clk {
+ struct mtk_jpegenc_clk_info *clk_info;
+ int clk_num;
+};
+
+/** * struct mtk_vcodec_pm - Power management data structure */
+struct mtk_jpegenc_pm {
+ struct mtk_jpegenc_clk venc_clk;
+ struct device *dev;
+ struct mtk_jpeg_dev *mtkdev;
+};
+
/**
* struct mtk_jpeg_dev - JPEG IP abstraction
* @lock: the mutex protecting this structure
@@ -103,6 +128,9 @@ struct mtk_jpeg_dev {
struct device *larb;
struct delayed_work job_timeout_work;
const struct mtk_jpeg_variant *variant;
+
+ struct mtk_jpeg_dev *hw_dev[MTK_JPEGENC_HW_MAX];
+ struct mtk_jpegenc_pm pm;
};
/**
--
2.6.4
More information about the Linux-mediatek
mailing list