Skip to contentSkip to conversation

media: Fix warnings with llvm9

PATCH In review Ricardo Ribalda 6 participants 13 messages Dec 2, 2024 – May 1, 2025

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

cover media: Fix warnings with llvm9

When we tried to build media with llvm we got some new warnings, lets try to fix them before llvm is part of our CI.

---
Ricardo Ribalda (3):
media: cx231xx: Convert enum into a define
media: atomisp: Use the actual value of the enum instead of the enum
media: mediatek: vcodec: Workaround a compiler warning

 .../mediatek/vcodec/encoder/venc/venc_h264_if.c        |  6 ++++--
 drivers/media/usb/cx231xx/cx231xx-pcb-cfg.h            | 18 +++++++-----------
 .../media/atomisp/pci/hive_isp_css_common/irq_global.h |  2 +-
 3 files changed, 12 insertions(+), 14 deletions(-)

---
base-commit: 40384c840ea1944d7c5a392e8975ed088ecf0b37
change-id: 20241202-fix-llvm9-4c8d705c9e3e

Best regards,

Signature · 1 line
Ricardo Ribalda <[email protected]>
#1 lore raw

PATCH 1/3 media: cx231xx: Convert enum into a define

The code is running arithmentics with the enum, which when not done with care makes the compiler a bit nervous.

Because those enums are only used as defines (no argument or variable from that enumeration type), convert it into a define and move on.

It is required to build with llvm 9 without these warnings:
drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:673:17: warning: bitwise operation between different enumeration types ('enum TS_PORT' and 'enum POWE_TYPE') [-Wenum-enum-conversion] drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:680:21: warning: bitwise operation between different enumeration types ('enum AVDEC_STATUS' and 'enum POWE_TYPE') [-Wenum-enum-conversion] drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:687:21: warning: bitwise operation between different enumeration types ('enum AVDEC_STATUS' and 'enum POWE_TYPE') [-Wenum-enum-conversion] drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:702:17: warning: bitwise operation between different enumeration types ('enum TS_PORT' and 'enum POWE_TYPE') [-Wenum-enum-conversion] drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:709:21: warning: bitwise operation between different enumeration types ('enum TS_PORT' and 'enum POWE_TYPE') [-Wenum-enum-conversion] drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:718:21: warning: bitwise operation between different enumeration types ('enum AVDEC_STATUS' and 'enum POWE_TYPE') [-Wenum-enum-conversion] drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:727:21: warning: bitwise operation between different enumeration types ('enum AVDEC_STATUS' and 'enum TS_PORT') [-Wenum-enum-conversion] drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:737:21: warning: bitwise operation between different enumeration types ('enum AVDEC_STATUS' and 'enum TS_PORT') [-Wenum-enum-conversion] drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:749:21: warning: bitwise operation between different enumeration types ('enum AVDEC_STATUS' and 'enum TS_PORT') [-Wenum-enum-conversion]

---
 drivers/media/usb/cx231xx/cx231xx-pcb-cfg.h | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
drivers/media/usb/cx231xx/cx231xx-pcb-cfg.h +7 -11
index 5bc44f194d0a..62ffa16bb82c 100644
@@ -57,19 +57,17 @@ enum USB_SPEED{
 };
 
 #define TS_MASK         0x6
-enum TS_PORT{
-	NO_TS_PORT = 0x0,	/* 2'b00: Neither port used. PCB not a Hybrid,
+#define NO_TS_PORT	0x0	/* 2'b00: Neither port used. PCB not a Hybrid,
 				   only offers Analog TV or Video */
-	TS1_PORT = 0x4,		/* 2'b10: TS1 Input (Hybrid mode :
+#define TS1_PORT	0x4	/* 2'b10: TS1 Input (Hybrid mode :
 				Digital or External Analog/Compressed source) */
-	TS1_TS2_PORT = 0x6,	/* 2'b11: TS1 & TS2 Inputs
+#define TS1_TS2_PORT	0x6	/* 2'b11: TS1 & TS2 Inputs
 				(Dual inputs from Digital and/or
 				External Analog/Compressed sources) */
-	TS1_EXT_CLOCK = 0x6,	/* 2'b11: TS1 & TS2 as selector
+#define TS1_EXT_CLOCK	0x6	/* 2'b11: TS1 & TS2 as selector
 						to external clock */
-	TS1VIP_TS2_PORT = 0x2	/* 2'b01: TS1 used as 656/VIP Output,
+#define TS1VIP_TS2_PORT 0x2	/* 2'b01: TS1 used as 656/VIP Output,
 				   TS2 Input (from Compressor) */
-};
 
 #define EAVP_MASK       0x8
 enum EAV_PRESENT{
@@ -89,10 +87,8 @@ enum AT_MODE{
 };
 
 #define PWR_SEL_MASK    0x40
-enum POWE_TYPE{
-	SELF_POWER = 0x0,	/* 0: self power */
-	BUS_POWER = 0x40	/* 1: bus power */
-};
+#define SELF_POWER	0x0	/* 0: self power */
+#define BUS_POWER	0x40	/* 1: bus power */
 
 enum USB_POWE_TYPE{
 	USB_SELF_POWER = 0,
Signature · 1 line
2.47.0.338.g60cca15819-goog
#2 lore raw

Re: [PATCH 1/3] media: cx231xx: Convert enum into a define

Em Mon, 02 Dec 2024 15:47:15 +0000
Ricardo Ribalda <[email protected]> escreveu:

Quoted 55 lines

The code is running arithmentics with the enum, which when not done with care makes the compiler a bit nervous.

Because those enums are only used as defines (no argument or variable from that enumeration type), convert it into a define and move on.

It is required to build with llvm 9 without these warnings:
drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:673:17: warning: bitwise operation between different enumeration types ('enum TS_PORT' and 'enum POWE_TYPE') [-Wenum-enum-conversion] drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:680:21: warning: bitwise operation between different enumeration types ('enum AVDEC_STATUS' and 'enum POWE_TYPE') [-Wenum-enum-conversion] drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:687:21: warning: bitwise operation between different enumeration types ('enum AVDEC_STATUS' and 'enum POWE_TYPE') [-Wenum-enum-conversion] drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:702:17: warning: bitwise operation between different enumeration types ('enum TS_PORT' and 'enum POWE_TYPE') [-Wenum-enum-conversion] drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:709:21: warning: bitwise operation between different enumeration types ('enum TS_PORT' and 'enum POWE_TYPE') [-Wenum-enum-conversion] drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:718:21: warning: bitwise operation between different enumeration types ('enum AVDEC_STATUS' and 'enum POWE_TYPE') [-Wenum-enum-conversion] drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:727:21: warning: bitwise operation between different enumeration types ('enum AVDEC_STATUS' and 'enum TS_PORT') [-Wenum-enum-conversion] drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:737:21: warning: bitwise operation between different enumeration types ('enum AVDEC_STATUS' and 'enum TS_PORT') [-Wenum-enum-conversion] drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:749:21: warning: bitwise operation between different enumeration types ('enum AVDEC_STATUS' and 'enum TS_PORT') [-Wenum-enum-conversion]

---
 drivers/media/usb/cx231xx/cx231xx-pcb-cfg.h | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
drivers/media/usb/cx231xx/cx231xx-pcb-cfg.h +5 -7
index 5bc44f194d0a..62ffa16bb82c 100644
@@ -57,19 +57,17 @@ enum USB_SPEED{
 };
 
 #define TS_MASK         0x6
-enum TS_PORT{
-	NO_TS_PORT = 0x0,	/* 2'b00: Neither port used. PCB not a Hybrid,
+#define NO_TS_PORT	0x0	/* 2'b00: Neither port used. PCB not a Hybrid,
 				   only offers Analog TV or Video */
-	TS1_PORT = 0x4,		/* 2'b10: TS1 Input (Hybrid mode :
+#define TS1_PORT	0x4	/* 2'b10: TS1 Input (Hybrid mode :
 				Digital or External Analog/Compressed source) */
-	TS1_TS2_PORT = 0x6,	/* 2'b11: TS1 & TS2 Inputs
+#define TS1_TS2_PORT	0x6	/* 2'b11: TS1 & TS2 Inputs
 				(Dual inputs from Digital and/or
 				External Analog/Compressed sources) */
-	TS1_EXT_CLOCK = 0x6,	/* 2'b11: TS1 & TS2 as selector
+#define TS1_EXT_CLOCK	0x6	/* 2'b11: TS1 & TS2 as selector
 						to external clock */
-	TS1VIP_TS2_PORT = 0x2	/* 2'b01: TS1 used as 656/VIP Output,
+#define TS1VIP_TS2_PORT 0x2	/* 2'b01: TS1 used as 656/VIP Output,
 				   TS2 Input (from Compressor) */
-};
 
 #define EAVP_MASK       0x8
 enum EAV_PRESENT{
@@ -89,10 +87,8 @@ enum AT_MODE{
 };
 

drivers/media/usb/cx231xx/cx231xx-pcb-cfg.h enum AT_MODE{ · line 94

Quoted 10 lines
drivers/media/usb/cx231xx/cx231xx-pcb-cfg.h +2 -4
 #define PWR_SEL_MASK    0x40
-enum POWE_TYPE{
-	SELF_POWER = 0x0,	/* 0: self power */
-	BUS_POWER = 0x40	/* 1: bus power */
-};
+#define SELF_POWER	0x0	/* 0: self power */
+#define BUS_POWER	0x40	/* 1: bus power */
 
 enum USB_POWE_TYPE{
 	USB_SELF_POWER = 0,

IMO keeping them into enums are a lot better than defines.

Perhaps the right thing would be to join both enums here.

Thanks,
Mauro

#3 lore raw

Re: [PATCH 1/3] media: cx231xx: Convert enum into a define

Quoted 65 lines · Mauro Carvalho Chehab

Em Mon, 02 Dec 2024 15:47:15 +0000
Ricardo Ribalda <[email protected]> escreveu:

Quoted 62 lines

The code is running arithmentics with the enum, which when not done with care makes the compiler a bit nervous.

Because those enums are only used as defines (no argument or variable from that enumeration type), convert it into a define and move on.

It is required to build with llvm 9 without these warnings:
drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:673:17: warning: bitwise operation between different enumeration types ('enum TS_PORT' and 'enum POWE_TYPE') [-Wenum-enum-conversion] drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:680:21: warning: bitwise operation between different enumeration types ('enum AVDEC_STATUS' and 'enum POWE_TYPE') [-Wenum-enum-conversion] drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:687:21: warning: bitwise operation between different enumeration types ('enum AVDEC_STATUS' and 'enum POWE_TYPE') [-Wenum-enum-conversion] drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:702:17: warning: bitwise operation between different enumeration types ('enum TS_PORT' and 'enum POWE_TYPE') [-Wenum-enum-conversion] drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:709:21: warning: bitwise operation between different enumeration types ('enum TS_PORT' and 'enum POWE_TYPE') [-Wenum-enum-conversion] drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:718:21: warning: bitwise operation between different enumeration types ('enum AVDEC_STATUS' and 'enum POWE_TYPE') [-Wenum-enum-conversion] drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:727:21: warning: bitwise operation between different enumeration types ('enum AVDEC_STATUS' and 'enum TS_PORT') [-Wenum-enum-conversion] drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:737:21: warning: bitwise operation between different enumeration types ('enum AVDEC_STATUS' and 'enum TS_PORT') [-Wenum-enum-conversion] drivers/media/usb/cx231xx/cx231xx-pcb-cfg.c:749:21: warning: bitwise operation between different enumeration types ('enum AVDEC_STATUS' and 'enum TS_PORT') [-Wenum-enum-conversion]

---
 drivers/media/usb/cx231xx/cx231xx-pcb-cfg.h | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
drivers/media/usb/cx231xx/cx231xx-pcb-cfg.h +7 -11
index 5bc44f194d0a..62ffa16bb82c 100644
@@ -57,19 +57,17 @@ enum USB_SPEED{
 };
 
 #define TS_MASK         0x6
-enum TS_PORT{
-	NO_TS_PORT = 0x0,	/* 2'b00: Neither port used. PCB not a Hybrid,
+#define NO_TS_PORT	0x0	/* 2'b00: Neither port used. PCB not a Hybrid,
 				   only offers Analog TV or Video */
-	TS1_PORT = 0x4,		/* 2'b10: TS1 Input (Hybrid mode :
+#define TS1_PORT	0x4	/* 2'b10: TS1 Input (Hybrid mode :
 				Digital or External Analog/Compressed source) */
-	TS1_TS2_PORT = 0x6,	/* 2'b11: TS1 & TS2 Inputs
+#define TS1_TS2_PORT	0x6	/* 2'b11: TS1 & TS2 Inputs
 				(Dual inputs from Digital and/or
 				External Analog/Compressed sources) */
-	TS1_EXT_CLOCK = 0x6,	/* 2'b11: TS1 & TS2 as selector
+#define TS1_EXT_CLOCK	0x6	/* 2'b11: TS1 & TS2 as selector
 						to external clock */
-	TS1VIP_TS2_PORT = 0x2	/* 2'b01: TS1 used as 656/VIP Output,
+#define TS1VIP_TS2_PORT 0x2	/* 2'b01: TS1 used as 656/VIP Output,
 				   TS2 Input (from Compressor) */
-};
 
 #define EAVP_MASK       0x8
 enum EAV_PRESENT{
@@ -89,10 +87,8 @@ enum AT_MODE{
 };
 
 #define PWR_SEL_MASK    0x40
-enum POWE_TYPE{
-	SELF_POWER = 0x0,	/* 0: self power */
-	BUS_POWER = 0x40	/* 1: bus power */
-};
+#define SELF_POWER	0x0	/* 0: self power */
+#define BUS_POWER	0x40	/* 1: bus power */
 
Quoted 7 lines

drivers/media/usb/cx231xx/cx231xx-pcb-cfg.h enum AT_MODE{ · line 94

Quoted 3 lines
drivers/media/usb/cx231xx/cx231xx-pcb-cfg.h +0 -0
 enum USB_POWE_TYPE{
 	USB_SELF_POWER = 0,

IMO keeping them into enums are a lot better than defines.

Perhaps the right thing would be to join both enums here.

ORing enums is really not a good idea: you would normally never do that, and the compiler warning is IMHO appropriate.

I think this is a good change and I plan to take this.

Regards,

Hans

Quoted 5 lines

Thanks,
Mauro

maintainer
#4 lore raw

Re: [PATCH 1/3] media: cx231xx: Convert enum into a define

Quoted 1 line · Hans Verkuil

On 12/3/24 09:31, Mauro Carvalho Chehab wrote:

...

Quoted 1 line

ORing enums is really not a good idea: you would normally never do that, and

I think you missed a keyword "different", so "ORing different enums ..." which I totally agree on, but the same enum values are fine.

Quoted 1 line

the compiler warning is IMHO appropriate.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#5 lore raw

Re: [PATCH 1/3] media: cx231xx: Convert enum into a define

Quoted 9 lines · Andy Shevchenko
Quoted 1 line · Hans Verkuil

On 12/3/24 09:31, Mauro Carvalho Chehab wrote:

...

Quoted 1 line

ORing enums is really not a good idea: you would normally never do that, and

I think you missed a keyword "different", so "ORing different enums ..." which I totally agree on, but the same enum values are fine.

While the compiler might be happy with that, I think ORing enums regardless is weird. It's not what enums are for.

Regards,

Hans

Quoted 3 lines
Quoted 2 lines

the compiler warning is IMHO appropriate.

maintainer
#6 lore raw

Re: [PATCH 1/3] media: cx231xx: Convert enum into a define

Quoted 3 lines · Hans Verkuil
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · Hans Verkuil

On 12/3/24 09:31, Mauro Carvalho Chehab wrote:

...

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

ORing enums is really not a good idea: you would normally never do that, and

I think you missed a keyword "different", so "ORing different enums ..." which I totally agree on, but the same enum values are fine.

While the compiler might be happy with that, I think ORing enums regardless is weird. It's not what enums are for.

I disagree. It's totally normal to have "mixed" enums where we have ranges of sequential values mixed with bit flags. Cross-enum bit operations (and what this patch is about) should be prohibited, indeed.

Quoted 1 line
Quoted 1 line
Quoted 1 line

the compiler warning is IMHO appropriate.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#7 lore raw

PATCH 2/3 media: atomisp: Use the actual value of the enum instead of the enum

In reply to Ricardo Ribalda

hrt_isp_css_irq_sw_pin_0 has a different enum type than irq_sw_channel_id_t.

Replace it with the actual value of hrt_isp_css_irq_sw_pin_0 to avoid arithmetic operations between different enum types (and make the compiler happy).

It is required to build with llvm 9 without these warnings:
drivers/staging/media/atomisp/pci/sh_css_hrt.c:68:19: warning: arithmetic between different enumeration types ('irq_sw_channel_id_t' and 'enum hrt_isp_css_irq') [-Wenum-enum-conversion] drivers/staging/media/atomisp/pci/sh_css.c:1233:40: warning: arithmetic between different enumeration types ('irq_sw_channel_id_t' and 'enum hrt_isp_css_irq') [-Wenum-enum-conversion] drivers/staging/media/atomisp/pci/sh_css.c:1237:40: warning: arithmetic between different enumeration types ('irq_sw_channel_id_t' and 'enum hrt_isp_css_irq') [-Wenum-enum-conversion] ro

---
 drivers/staging/media/atomisp/pci/hive_isp_css_common/irq_global.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/atomisp/pci/hive_isp_css_common/irq_global.h +1 -1
index 2c47e7820bd7..69e68ecd6bc3 100644
@@ -18,7 +18,7 @@
 #endif
 
 /* The IRQ is not mapped uniformly on its related interfaces */
-#define	IRQ_SW_CHANNEL_OFFSET	hrt_isp_css_irq_sw_pin_0
+#define	IRQ_SW_CHANNEL_OFFSET	HIVE_GP_DEV_IRQ_SW_PIN_0_BIT_ID
 
 typedef enum {
 	IRQ_SW_CHANNEL0_ID = hrt_isp_css_irq_sw_pin_0 - IRQ_SW_CHANNEL_OFFSET,
Signature · 1 line
2.47.0.338.g60cca15819-goog
maintainer Reviewed-by on v1 2/3
#8 lore raw

Re: [PATCH 2/3] media: atomisp: Use the actual value of the enum instead of the enum

Quoted 8 lines · Ricardo Ribalda

hrt_isp_css_irq_sw_pin_0 has a different enum type than irq_sw_channel_id_t.

Replace it with the actual value of hrt_isp_css_irq_sw_pin_0 to avoid arithmetic operations between different enum types (and make the compiler happy).

It is required to build with llvm 9 without these warnings:

9?! Maybe 19?

Quoted 4 lines

drivers/staging/media/atomisp/pci/sh_css_hrt.c:68:19: warning: arithmetic between different enumeration types ('irq_sw_channel_id_t' and 'enum hrt_isp_css_irq') [-Wenum-enum-conversion] drivers/staging/media/atomisp/pci/sh_css.c:1233:40: warning: arithmetic between different enumeration types ('irq_sw_channel_id_t' and 'enum hrt_isp_css_irq') [-Wenum-enum-conversion] drivers/staging/media/atomisp/pci/sh_css.c:1237:40: warning: arithmetic between different enumeration types ('irq_sw_channel_id_t' and 'enum hrt_isp_css_irq') [-Wenum-enum-conversion] ro

You can make the above lines shorter by dropping the obvious an duplicated (in other places) part, i.e. drivers/staging/media/atomisp/. I usually replace this with "...".

.../pci/sh_css_hrt.c:68:19: warning: arithmetic between different enumeration types ('irq_sw_channel_id_t' and 'enum hrt_isp_css_irq') [-Wenum-enum-conversion] .../pci/sh_css.c:1233:40: warning: arithmetic between different enumeration types ('irq_sw_channel_id_t' and 'enum hrt_isp_css_irq') [-Wenum-enum-conversion] .../pci/sh_css.c:1237:40: warning: arithmetic between different enumeration types ('irq_sw_channel_id_t' and 'enum hrt_isp_css_irq') [-Wenum-enum-conversion]

Otherwise LGTM,

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#9 lore raw

Re: [PATCH 2/3] media: atomisp: Use the actual value of the enum instead of the enum

In reply to Ricardo Ribalda

Hi Ricardo,

Quoted 7 lines · Ricardo Ribalda

hrt_isp_css_irq_sw_pin_0 has a different enum type than irq_sw_channel_id_t.

Replace it with the actual value of hrt_isp_css_irq_sw_pin_0 to avoid arithmetic operations between different enum types (and make the compiler happy).

Quoted 7 lines

It is required to build with llvm 9 without these warnings:
drivers/staging/media/atomisp/pci/sh_css_hrt.c:68:19: warning: arithmetic between different enumeration types ('irq_sw_channel_id_t' and 'enum hrt_isp_css_irq') [-Wenum-enum-conversion] drivers/staging/media/atomisp/pci/sh_css.c:1233:40: warning: arithmetic between different enumeration types ('irq_sw_channel_id_t' and 'enum hrt_isp_css_irq') [-Wenum-enum-conversion] drivers/staging/media/atomisp/pci/sh_css.c:1237:40: warning: arithmetic between different enumeration types ('irq_sw_channel_id_t' and 'enum hrt_isp_css_irq') [-Wenum-enum-conversion] ro

Thank you for your patch.

I have merged this in my media-atomisp branch:
https://git.kernel.org/pub/scm/linux/kernel/git/hansg/linux.git/log/?h=media-atomisp

with Andy's suggested commit message improvements applied.

And this patch will be included in my next pull-request to Mauro (to media subsystem maintainer)

Regards,

Hans

Quoted 18 lines
---
 drivers/staging/media/atomisp/pci/hive_isp_css_common/irq_global.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/atomisp/pci/hive_isp_css_common/irq_global.h +1 -1
index 2c47e7820bd7..69e68ecd6bc3 100644
@@ -18,7 +18,7 @@
 #endif
 
 /* The IRQ is not mapped uniformly on its related interfaces */
-#define	IRQ_SW_CHANNEL_OFFSET	hrt_isp_css_irq_sw_pin_0
+#define	IRQ_SW_CHANNEL_OFFSET	HIVE_GP_DEV_IRQ_SW_PIN_0_BIT_ID
 
 typedef enum {
 	IRQ_SW_CHANNEL0_ID = hrt_isp_css_irq_sw_pin_0 - IRQ_SW_CHANNEL_OFFSET,
#10 lore raw

PATCH 3/3 media: mediatek: vcodec: Workaround a compiler warning

In reply to Ricardo Ribalda

llvm identifies that the SCP_IPI_VENC_H264 and IPI_VENC_H264 are from the same enum type, but their are part of the same ternary operator.

vpu_inst.id is of type int, so we can just rewrite a bit the code and
avoid the following llvm9 warning:
drivers/media/platform/mediatek/vcodec/encoder/venc/venc_h264_if.c:597:29: warning: conditional expression between different enumeration types ('enum scp_ipi_id' and 'enum ipi_id') [-Wenum-compare-conditional]

---
 drivers/media/platform/mediatek/vcodec/encoder/venc/venc_h264_if.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/media/platform/mediatek/vcodec/encoder/venc/venc_h264_if.c +4 -2
index f8145998fcaf..4786062e879a 100644
@@ -584,7 +584,6 @@ static void h264_encode_filler(struct venc_h264_inst *inst, void *buf,
 
 static int h264_enc_init(struct mtk_vcodec_enc_ctx *ctx)
 {
-	const bool is_ext = MTK_ENC_CTX_IS_EXT(ctx);
 	int ret = 0;
 	struct venc_h264_inst *inst;
 
@@ -594,7 +593,10 @@ static int h264_enc_init(struct mtk_vcodec_enc_ctx *ctx)
 
 	inst->ctx = ctx;
 	inst->vpu_inst.ctx = ctx;
-	inst->vpu_inst.id = is_ext ? SCP_IPI_VENC_H264 : IPI_VENC_H264;
+	if (MTK_ENC_CTX_IS_EXT(ctx))
+		inst->vpu_inst.id = SCP_IPI_VENC_H264;
+	else
+		inst->vpu_inst.id = IPI_VENC_H264;
 	inst->hw_base = mtk_vcodec_get_reg_addr(inst->ctx->dev->reg_base, VENC_SYS);
 
 	ret = vpu_enc_init(&inst->vpu_inst);
Signature · 1 line
2.47.0.338.g60cca15819-goog
Reviewed-by on v1 3/3
#11 lore raw

Re: [PATCH 3/3] media: mediatek: vcodec: Workaround a compiler warning

Quoted 5 lines · Ricardo Ribalda

llvm identifies that the SCP_IPI_VENC_H264 and IPI_VENC_H264 are from the same enum type, but their are part of the same ternary operator.

vpu_inst.id is of type int, so we can just rewrite a bit the code and avoid the following llvm9 warning:

LLVM 19, not LLVM 9, as the minimum version for building the kernel is LLVM 13.

Quoted 3 lines

drivers/media/platform/mediatek/vcodec/encoder/venc/venc_h264_if.c:597:29: warning: conditional expression between different enumeration types ('enum scp_ipi_id' and 'enum ipi_id') [-Wenum-compare-conditional]

FYI, Arnd basically sent the same patch October 18 but I guess it has not been picked up?

https://lore.kernel.org/[email protected]/

Hopefully the new media committers model will help patches like that get picked up in a more timely manner.

Quoted 32 lines
---
 drivers/media/platform/mediatek/vcodec/encoder/venc/venc_h264_if.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/media/platform/mediatek/vcodec/encoder/venc/venc_h264_if.c +4 -2
index f8145998fcaf..4786062e879a 100644
@@ -584,7 +584,6 @@ static void h264_encode_filler(struct venc_h264_inst *inst, void *buf,
 
 static int h264_enc_init(struct mtk_vcodec_enc_ctx *ctx)
 {
-	const bool is_ext = MTK_ENC_CTX_IS_EXT(ctx);
 	int ret = 0;
 	struct venc_h264_inst *inst;
 
@@ -594,7 +593,10 @@ static int h264_enc_init(struct mtk_vcodec_enc_ctx *ctx)
 
 	inst->ctx = ctx;
 	inst->vpu_inst.ctx = ctx;
-	inst->vpu_inst.id = is_ext ? SCP_IPI_VENC_H264 : IPI_VENC_H264;
+	if (MTK_ENC_CTX_IS_EXT(ctx))
+		inst->vpu_inst.id = SCP_IPI_VENC_H264;
+	else
+		inst->vpu_inst.id = IPI_VENC_H264;
 	inst->hw_base = mtk_vcodec_get_reg_addr(inst->ctx->dev->reg_base, VENC_SYS);
 
 	ret = vpu_enc_init(&inst->vpu_inst);
Signature · 2 lines
-- 
2.47.0.338.g60cca15819-goog
#12 lore raw

Re: [PATCH 3/3] media: mediatek: vcodec: Workaround a compiler warning

Hi

Quoted 17 lines · Nathan Chancellor
Quoted 5 lines · Ricardo Ribalda

llvm identifies that the SCP_IPI_VENC_H264 and IPI_VENC_H264 are from the same enum type, but their are part of the same ternary operator.

vpu_inst.id is of type int, so we can just rewrite a bit the code and avoid the following llvm9 warning:

LLVM 19, not LLVM 9, as the minimum version for building the kernel is LLVM 13.

Quoted 3 lines

drivers/media/platform/mediatek/vcodec/encoder/venc/venc_h264_if.c:597:29: warning: conditional expression between different enumeration types ('enum scp_ipi_id' and 'enum ipi_id') [-Wenum-compare-conditional]

Quoted 7 lines

FYI, Arnd basically sent the same patch October 18 but I guess it has not been picked up?

https://lore.kernel.org/[email protected]/

Hopefully the new media committers model will help patches like that get picked up in a more timely manner.

We can take Arnd's patch.

Yeah, this is the kind of patches that the multi committers can really help with :)

Quoted 28 lines
Quoted 28 lines
---
 drivers/media/platform/mediatek/vcodec/encoder/venc/venc_h264_if.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/media/platform/mediatek/vcodec/encoder/venc/venc_h264_if.c +4 -2
index f8145998fcaf..4786062e879a 100644
@@ -584,7 +584,6 @@ static void h264_encode_filler(struct venc_h264_inst *inst, void *buf,
 
 static int h264_enc_init(struct mtk_vcodec_enc_ctx *ctx)
 {
-     const bool is_ext = MTK_ENC_CTX_IS_EXT(ctx);
      int ret = 0;
      struct venc_h264_inst *inst;
 
@@ -594,7 +593,10 @@ static int h264_enc_init(struct mtk_vcodec_enc_ctx *ctx)
 
      inst->ctx = ctx;
      inst->vpu_inst.ctx = ctx;
-     inst->vpu_inst.id = is_ext ? SCP_IPI_VENC_H264 : IPI_VENC_H264;
+     if (MTK_ENC_CTX_IS_EXT(ctx))
+             inst->vpu_inst.id = SCP_IPI_VENC_H264;
+     else
+             inst->vpu_inst.id = IPI_VENC_H264;
      inst->hw_base = mtk_vcodec_get_reg_addr(inst->ctx->dev->reg_base, VENC_SYS);
 
Quoted 5 lines
Quoted 5 lines
drivers/media/platform/mediatek/vcodec/encoder/venc/venc_h264_if.c +0 -1
      ret = vpu_enc_init(&inst->vpu_inst);
 
--

2.47.0.338.g60cca15819-goog

--
Ricardo Ribalda