Skip to contentSkip to conversation

media: mtk-jpeg: Fixes jpeghw multi-core judgement

PATCH Superseded Irui Wang 3 participants 3 messages Jan 3, 2023 – Jan 29, 2023

Subsystems (3)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Irui Wang

author
#0 lore raw

PATCH v4 1/1 media: mtk-jpeg: Fixes jpeghw multi-core judgement

From: kyrie wu <[email protected]>

some chips have multi-hw, but others have only one, modify the condition of multi-hw judgement

Fixes 934e8bccac95 ("mtk-jpegenc: support jpegenc multi-hardware")
---
 drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c |  4 +++-
 drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h | 12 ++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +3 -1
index 969516a940ba..56b27ecd61ec 100644
@@ -1692,7 +1692,7 @@ static int mtk_jpeg_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	if (list_empty(&pdev->dev.devres_head)) {
+	if (jpeg->variant->hw_arch) {
 		INIT_DELAYED_WORK(&jpeg->job_timeout_work,
 				  mtk_jpeg_job_timeout_work);
 
@@ -1885,6 +1885,7 @@ static struct mtk_jpeg_variant mtk8195_jpegenc_drvdata = {
 	.ioctl_ops = &mtk_jpeg_enc_ioctl_ops,
 	.out_q_default_fourcc = V4L2_PIX_FMT_YUYV,
 	.cap_q_default_fourcc = V4L2_PIX_FMT_JPEG,
+	.hw_arch = MTK_JPEG_HW_MULTI_CORE,
 };
 
 static const struct mtk_jpeg_variant mtk8195_jpegdec_drvdata = {
@@ -1896,6 +1897,7 @@ static const struct mtk_jpeg_variant mtk8195_jpegdec_drvdata = {
 	.ioctl_ops = &mtk_jpeg_dec_ioctl_ops,
 	.out_q_default_fourcc = V4L2_PIX_FMT_JPEG,
 	.cap_q_default_fourcc = V4L2_PIX_FMT_YUV420M,
+	.hw_arch = MTK_JPEG_HW_MULTI_CORE,
 };
 
 #if defined(CONFIG_OF)
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h +12 -0
index b9126476be8f..ead47e11dd48 100644
@@ -46,6 +46,16 @@ enum mtk_jpeg_ctx_state {
 	MTK_JPEG_SOURCE_CHANGE,
 };
 
+/**
+ * enum mtk_jpeg_hw_arch - arch of the jpeg hw
+ * @MTK_JPEG_HW_MULTI_CORE:	jpeg hw is mluti-core
+ * @MTK_JPEG_HW_SINGLE_CORE:	jpeg hw is single core
+ */
+enum mtk_jpeg_hw_arch {
+	MTK_JPEG_HW_MULTI_CORE = 0,
+	MTK_JPEG_HW_SINGLE_CORE = 1,
+};
+
 /**
  * struct mtk_jpeg_variant - mtk jpeg driver variant
  * @clks:			clock names
@@ -60,6 +70,7 @@ enum mtk_jpeg_ctx_state {
  * @ioctl_ops:			the callback of jpeg v4l2_ioctl_ops
  * @out_q_default_fourcc:	output queue default fourcc
  * @cap_q_default_fourcc:	capture queue default fourcc
+ * @hw_arch:            mark jpeg hw arch
  */
 struct mtk_jpeg_variant {
 	struct clk_bulk_data *clks;
@@ -74,6 +85,7 @@ struct mtk_jpeg_variant {
 	const struct v4l2_ioctl_ops *ioctl_ops;
 	u32 out_q_default_fourcc;
 	u32 cap_q_default_fourcc;
+	enum mtk_jpeg_hw_arch hw_arch;
 };
 
 struct mtk_jpeg_src_buf {
Signature · 1 line
2.18.0
#1 lore raw

Hi Irui, Kyrie,

Quoted 37 lines · Irui Wang

From: kyrie wu <[email protected]>

some chips have multi-hw, but others have only one, modify the condition of multi-hw judgement

Fixes 934e8bccac95 ("mtk-jpegenc: support jpegenc multi-hardware")
---
 drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c |  4 +++-
 drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h | 12 ++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +2 -1
index 969516a940ba..56b27ecd61ec 100644
@@ -1692,7 +1692,7 @@ static int mtk_jpeg_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	if (list_empty(&pdev->dev.devres_head)) {
+	if (jpeg->variant->hw_arch) {
 		INIT_DELAYED_WORK(&jpeg->job_timeout_work,
 				  mtk_jpeg_job_timeout_work);
 
@@ -1885,6 +1885,7 @@ static struct mtk_jpeg_variant mtk8195_jpegenc_drvdata = {
 	.ioctl_ops = &mtk_jpeg_enc_ioctl_ops,
 	.out_q_default_fourcc = V4L2_PIX_FMT_YUYV,
 	.cap_q_default_fourcc = V4L2_PIX_FMT_JPEG,
+	.hw_arch = MTK_JPEG_HW_MULTI_CORE,
 };
 
 static const struct mtk_jpeg_variant mtk8195_jpegdec_drvdata = {

drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c static const struct mtk_jpeg_variant mtk8195_jpegdec_drvdata = { · line 1901

Quoted 5 lines
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +1 -0
@@ -1896,6 +1897,7 @@ static const struct mtk_jpeg_variant mtk8195_jpegdec_drvdata = {
 	.ioctl_ops = &mtk_jpeg_dec_ioctl_ops,
 	.out_q_default_fourcc = V4L2_PIX_FMT_JPEG,
 	.cap_q_default_fourcc = V4L2_PIX_FMT_YUV420M,
+	.hw_arch = MTK_JPEG_HW_MULTI_CORE,
 };

So presumably the mtk8195 is multi core and the other variants are single core, but...

drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h enum mtk_jpeg_ctx_state { · line 51

Quoted 13 lines
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +0 -0
 #if defined(CONFIG_OF)
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h +3 -0
index b9126476be8f..ead47e11dd48 100644
@@ -46,6 +46,16 @@ enum mtk_jpeg_ctx_state {
 	MTK_JPEG_SOURCE_CHANGE,
 };
 
+/**
+ * enum mtk_jpeg_hw_arch - arch of the jpeg hw
+ * @MTK_JPEG_HW_MULTI_CORE:	jpeg hw is mluti-core

mluti -> multi

drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h enum mtk_jpeg_ctx_state { · line 55

Quoted 4 lines
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h +4 -0
+ * @MTK_JPEG_HW_SINGLE_CORE:	jpeg hw is single core
+ */
+enum mtk_jpeg_hw_arch {
+	MTK_JPEG_HW_MULTI_CORE = 0,

...this has value 0, so multi core is the default. This means that all variants are seen as multi core.

drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h enum mtk_jpeg_ctx_state { · line 73

Quoted 11 lines
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h +4 -0
+	MTK_JPEG_HW_SINGLE_CORE = 1,
+};
+
 /**
  * struct mtk_jpeg_variant - mtk jpeg driver variant
  * @clks:			clock names
@@ -60,6 +70,7 @@ enum mtk_jpeg_ctx_state {
  * @ioctl_ops:			the callback of jpeg v4l2_ioctl_ops
  * @out_q_default_fourcc:	output queue default fourcc
  * @cap_q_default_fourcc:	capture queue default fourcc
+ * @hw_arch:            mark jpeg hw arch

I think this is a poorly chosen name: wouldn't it be better to just make this a 'bool multi_core;'?

drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h struct mtk_jpeg_variant { · line 91

Quoted 11 lines
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h +1 -0
  */
 struct mtk_jpeg_variant {
 	struct clk_bulk_data *clks;
@@ -74,6 +85,7 @@ struct mtk_jpeg_variant {
 	const struct v4l2_ioctl_ops *ioctl_ops;
 	u32 out_q_default_fourcc;
 	u32 cap_q_default_fourcc;
+	enum mtk_jpeg_hw_arch hw_arch;
 };
 
 struct mtk_jpeg_src_buf {

In any case, this patch doesn't look right.

Regards,

Hans

#2 lore raw
Quoted 72 lines · Hans Verkuil

Hi Irui, Kyrie,

Quoted 42 lines · Irui Wang

From: kyrie wu <[email protected]>

some chips have multi-hw, but others have only one, modify the condition of multi-hw judgement

Fixes 934e8bccac95 ("mtk-jpegenc: support jpegenc multi-hardware")
Reviewed-by AngeloGioacchino Del Regno <

[email protected]>

---
 drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c |  4 +++-
 drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h | 12
++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +2 -1
index 969516a940ba..56b27ecd61ec 100644
@@ -1692,7 +1692,7 @@ static int mtk_jpeg_probe(struct
 platform_device *pdev)
 		return -EINVAL;
 	}
 
-	if (list_empty(&pdev->dev.devres_head)) {
+	if (jpeg->variant->hw_arch) {
 		INIT_DELAYED_WORK(&jpeg->job_timeout_work,
 				  mtk_jpeg_job_timeout_work);
@@ -1885,6 +1885,7 @@ static struct mtk_jpeg_variant
 mtk8195_jpegenc_drvdata = {
 	.ioctl_ops = &mtk_jpeg_enc_ioctl_ops,
 	.out_q_default_fourcc = V4L2_PIX_FMT_YUYV,
 	.cap_q_default_fourcc = V4L2_PIX_FMT_JPEG,
+	.hw_arch = MTK_JPEG_HW_MULTI_CORE,
 };
 

static const struct mtk_jpeg_variant mtk8195_jpegdec_drvdata = {

drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c static const struct mtk_jpeg_variant · line 1902

Quoted 6 lines
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +1 -0
@@ -1896,6 +1897,7 @@ static const struct mtk_jpeg_variant
 mtk8195_jpegdec_drvdata = {
 	.ioctl_ops = &mtk_jpeg_dec_ioctl_ops,
 	.out_q_default_fourcc = V4L2_PIX_FMT_JPEG,
 	.cap_q_default_fourcc = V4L2_PIX_FMT_YUV420M,
+	.hw_arch = MTK_JPEG_HW_MULTI_CORE,
 };

So presumably the mtk8195 is multi core and the other variants are single core, but...

Quoted 8 lines
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +0 -0
 #if defined(CONFIG_OF)
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h +0 -0
index b9126476be8f..ead47e11dd48 100644

drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h enum mtk_jpeg_ctx_state { · line 51

Quoted 6 lines
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h +3 -0
@@ -46,6 +46,16 @@ enum mtk_jpeg_ctx_state {
 	MTK_JPEG_SOURCE_CHANGE,
 };
 
+/**
+ * enum mtk_jpeg_hw_arch - arch of the jpeg hw
+ * @MTK_JPEG_HW_MULTI_CORE:	jpeg hw is mluti-core

mluti -> multi

Quoted 8 lines

drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h enum mtk_jpeg_ctx_state { · line 55

Quoted 4 lines
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h +4 -0
+ * @MTK_JPEG_HW_SINGLE_CORE:	jpeg hw is single core
+ */
+enum mtk_jpeg_hw_arch {
+	MTK_JPEG_HW_MULTI_CORE = 0,

...this has value 0, so multi core is the default. This means that all variants are
seen as multi core.

Dear Hans,

Thanks for your reminding, I will fix this problem.

Quoted 16 lines
Quoted 9 lines
drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h +3 -0
+	MTK_JPEG_HW_SINGLE_CORE = 1,
+};
+
 /**
  * struct mtk_jpeg_variant - mtk jpeg driver variant
  * @clks:			clock names
@@ -60,6 +70,7 @@ enum mtk_jpeg_ctx_state {
  * @ioctl_ops:			the callback of jpeg
Quoted 4 lines

v4l2_ioctl_ops
* @out_q_default_fourcc: output queue default fourcc
* @cap_q_default_fourcc: capture queue default fourcc
+ * @hw_arch: mark jpeg hw arch

I think this is a poorly chosen name: wouldn't it be better to just make this a 'bool multi_core;'?

Thanks, I would change the choosing.

Regards,
Kyrie.

Quoted 18 lines

drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h struct mtk_jpeg_variant { · line 91

Quoted 12 lines

*/
struct mtk_jpeg_variant {

drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h +1 -0
 	struct clk_bulk_data *clks;
@@ -74,6 +85,7 @@ struct mtk_jpeg_variant {
 	const struct v4l2_ioctl_ops *ioctl_ops;
 	u32 out_q_default_fourcc;
 	u32 cap_q_default_fourcc;
+	enum mtk_jpeg_hw_arch hw_arch;
 };
 
 struct mtk_jpeg_src_buf {

In any case, this patch doesn't look right.

Regards,

Hans