Skip to contentSkip to conversation

staging: media: imx7-mipi-csis: Two small fixes

PATCH In review Jacopo Mondi 3 participants 10 messages Jan 19, 2022 – Jan 26, 2022

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

cover staging: media: imx7-mipi-csis: Two small fixes

Two small fixes for the imx7-mipi-csis driver.

The second patch is required to correctly capture in packed YUV422 formats

Thanks
j

Jacopo Mondi (2):
staging: media: imx: imx7-mipi-csic: Resume on debug
staging: media: imx: imx7-mipi-csic: Set PIXEL_MODE for YUV422

 drivers/staging/media/imx/imx7-mipi-csis.c | 8 ++++++++
 1 file changed, 8 insertions(+)

--
2.34.1

#1 lore raw

PATCH 1/2 staging: media: imx: imx7-mipi-csic: Resume on debug

The mipi_csis_dump_regs() function reads and printout the interface registers for debugging purposes.

Trying to access the registers without proper powering up the interface causes the chip to hang.

Fix that by increasing the pm runtime usage count which, if necessary, resumes the interface.

---
 drivers/staging/media/imx/imx7-mipi-csis.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/staging/media/imx/imx7-mipi-csis.c +4 -0
index 2b73fa55c938..cb54bb7491d9 100644
@@ -780,11 +780,15 @@ static int mipi_csis_dump_regs(struct csi_state *state)
 
 	dev_info(state->dev, "--- REGISTERS ---\n");
 
+	pm_runtime_resume_and_get(state->dev);
+
 	for (i = 0; i < ARRAY_SIZE(registers); i++) {
 		cfg = mipi_csis_read(state, registers[i].offset);
 		dev_info(state->dev, "%14s: 0x%08x\n", registers[i].name, cfg);
 	}
 
+	pm_runtime_put(state->dev);
+
 	return 0;
 }
 
Signature · 1 line
2.34.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] staging: media: imx: imx7-mipi-csic: Resume on debug

Hi Jacopo,

Thank you for the patch.

Quoted 19 lines · Jacopo Mondi

The mipi_csis_dump_regs() function reads and printout the interface registers for debugging purposes.

Trying to access the registers without proper powering up the interface causes the chip to hang.

Fix that by increasing the pm runtime usage count which, if necessary, resumes the interface.

---
 drivers/staging/media/imx/imx7-mipi-csis.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/staging/media/imx/imx7-mipi-csis.c +0 -0
index 2b73fa55c938..cb54bb7491d9 100644

drivers/staging/media/imx/imx7-mipi-csis.c static int mipi_csis_dump_regs(struct csi_state *state) · line 783

Quoted 4 lines
drivers/staging/media/imx/imx7-mipi-csis.c +1 -0
@@ -780,11 +780,15 @@ static int mipi_csis_dump_regs(struct csi_state *state)
 
 	dev_info(state->dev, "--- REGISTERS ---\n");
 
+	pm_runtime_resume_and_get(state->dev);

Should this have an error check ? With that,

Quoted 11 lines
drivers/staging/media/imx/imx7-mipi-csis.c +3 -0
+
 	for (i = 0; i < ARRAY_SIZE(registers); i++) {
 		cfg = mipi_csis_read(state, registers[i].offset);
 		dev_info(state->dev, "%14s: 0x%08x\n", registers[i].name, cfg);
 	}
 
+	pm_runtime_put(state->dev);
+
 	return 0;
 }
 
Signature · 3 lines
Regards,

Laurent Pinchart
#3 lore raw

Re: [PATCH 1/2] staging: media: imx: imx7-mipi-csic: Resume on debug

Hi Jacopo,

Quoted 21 lines · Laurent Pinchart
Quoted 20 lines · Jacopo Mondi

The mipi_csis_dump_regs() function reads and printout the interface registers for debugging purposes.

Trying to access the registers without proper powering up the interface causes the chip to hang.

Fix that by increasing the pm runtime usage count which, if necessary, resumes the interface.

---
 drivers/staging/media/imx/imx7-mipi-csis.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/staging/media/imx/imx7-mipi-csis.c +0 -0
index 2b73fa55c938..cb54bb7491d9 100644
@@ -780,11 +780,15 @@ static int mipi_csis_dump_regs(struct csi_state *state)
 
Quoted 7 lines

drivers/staging/media/imx/imx7-mipi-csis.c static int mipi_csis_dump_regs(struct csi_state *state) · line 783

Quoted 3 lines
drivers/staging/media/imx/imx7-mipi-csis.c +1 -0
 	dev_info(state->dev, "--- REGISTERS ---\n");
 
+	pm_runtime_resume_and_get(state->dev);

Should this have an error check ? With that,

I just noticed that the call to mipi_csis_dump_regs() in mipi_csis_log_status() is conditioned by state->state & ST_POWERED. An alternative would thus be to add the same condition to mipi_csis_dump_regs_show() (or to move it to mipi_csis_dump_regs()), as dumping the register when then hardware is turned off is quite pointeless. Up to you.

Quoted 11 lines
Quoted 11 lines
drivers/staging/media/imx/imx7-mipi-csis.c +3 -0
+
 	for (i = 0; i < ARRAY_SIZE(registers); i++) {
 		cfg = mipi_csis_read(state, registers[i].offset);
 		dev_info(state->dev, "%14s: 0x%08x\n", registers[i].name, cfg);
 	}
 
+	pm_runtime_put(state->dev);
+
 	return 0;
 }
 
Signature · 3 lines
Regards,

Laurent Pinchart
#4 lore raw

Re: [PATCH 1/2] staging: media: imx: imx7-mipi-csic: Resume on debug

Hi Laurent,

Quoted 30 lines · Laurent Pinchart

Hi Jacopo,

Quoted 27 lines · Laurent Pinchart
Quoted 19 lines · Jacopo Mondi

The mipi_csis_dump_regs() function reads and printout the interface registers for debugging purposes.

Trying to access the registers without proper powering up the interface causes the chip to hang.

Fix that by increasing the pm runtime usage count which, if necessary, resumes the interface.

---
 drivers/staging/media/imx/imx7-mipi-csis.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/staging/media/imx/imx7-mipi-csis.c +0 -0
index 2b73fa55c938..cb54bb7491d9 100644

drivers/staging/media/imx/imx7-mipi-csis.c static int mipi_csis_dump_regs(struct csi_state *state) · line 783

Quoted 4 lines
drivers/staging/media/imx/imx7-mipi-csis.c +1 -0
@@ -780,11 +780,15 @@ static int mipi_csis_dump_regs(struct csi_state *state)
 
 	dev_info(state->dev, "--- REGISTERS ---\n");
 
+	pm_runtime_resume_and_get(state->dev);

Should this have an error check ? With that,

Quoted 9 lines
Quoted 1 line

I just noticed that the call to mipi_csis_dump_regs() in mipi_csis_log_status() is conditioned by state->state & ST_POWERED. An alternative would thus be to add the same condition to mipi_csis_dump_regs_show() (or to move it to mipi_csis_dump_regs()), as dumping the register when then hardware is turned off is quite pointeless. Up to you.

Tbh, I would drop this custom sysfs attribute completely. It should serve the purpose to easily dump the reg value, but it is either accessed at the right time (ie during the streaming session) otherwise all you get is POR default values (or a hang, without this patch)

Quoted 16 lines
Quoted 11 lines

drivers/staging/media/imx/imx7-mipi-csis.c static int mipi_csis_dump_regs(struct csi_state *state) · line 794

Quoted 11 lines
drivers/staging/media/imx/imx7-mipi-csis.c +3 -0
+
 	for (i = 0; i < ARRAY_SIZE(registers); i++) {
 		cfg = mipi_csis_read(state, registers[i].offset);
 		dev_info(state->dev, "%14s: 0x%08x\n", registers[i].name, cfg);
 	}
 
+	pm_runtime_put(state->dev);
+
 	return 0;
 }
 

--
Regards,

Laurent Pinchart

#5 lore raw

Re: [PATCH 1/2] staging: media: imx: imx7-mipi-csic: Resume on debug

Hi Jacopo,

Quoted 38 lines · Jacopo Mondi
Quoted 28 lines · Laurent Pinchart
Quoted 27 lines · Laurent Pinchart
Quoted 19 lines · Jacopo Mondi

The mipi_csis_dump_regs() function reads and printout the interface registers for debugging purposes.

Trying to access the registers without proper powering up the interface causes the chip to hang.

Fix that by increasing the pm runtime usage count which, if necessary, resumes the interface.

---
 drivers/staging/media/imx/imx7-mipi-csis.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/staging/media/imx/imx7-mipi-csis.c +0 -0
index 2b73fa55c938..cb54bb7491d9 100644

drivers/staging/media/imx/imx7-mipi-csis.c static int mipi_csis_dump_regs(struct csi_state *state) · line 783

Quoted 4 lines
drivers/staging/media/imx/imx7-mipi-csis.c +1 -0
@@ -780,11 +780,15 @@ static int mipi_csis_dump_regs(struct csi_state *state)
 
 	dev_info(state->dev, "--- REGISTERS ---\n");
 
+	pm_runtime_resume_and_get(state->dev);

Should this have an error check ? With that,

Quoted 8 lines
Quoted 1 line

I just noticed that the call to mipi_csis_dump_regs() in mipi_csis_log_status() is conditioned by state->state & ST_POWERED. An alternative would thus be to add the same condition to mipi_csis_dump_regs_show() (or to move it to mipi_csis_dump_regs()), as dumping the register when then hardware is turned off is quite pointeless. Up to you.

Quoted 5 lines

Tbh, I would drop this custom sysfs attribute completely. It should serve the purpose to easily dump the reg value, but it is either accessed at the right time (ie during the streaming session) otherwise all you get is POR default values (or a hang, without this patch)

The debugfs interface has served me before to diagnose problems, as it allows checking how the register values change during streaming, in particular the DPHY status. I'd like to keep it if possible.

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/staging/media/imx/imx7-mipi-csis.c +3 -0
+
 	for (i = 0; i < ARRAY_SIZE(registers); i++) {
 		cfg = mipi_csis_read(state, registers[i].offset);
 		dev_info(state->dev, "%14s: 0x%08x\n", registers[i].name, cfg);
 	}
 
+	pm_runtime_put(state->dev);
+
 	return 0;
 }
 
Signature · 3 lines
Regards,

Laurent Pinchart
#6 lore raw

PATCH 2/2 staging: media: imx: imx7-mipi-csic: Set PIXEL_MODE for YUV422

In reply to Jacopo Mondi

Bits 13 and 12 of the ISP_CONFIGn register configure the PIXEL_MODE which specifies the sampling size, in pixel component units, on the CSI-2 output data interface when data are transferred to memory.

The register description in the chip manual specifies that DUAL mode should be used for YUV422 data but does not clarify the reason.

Todo: verify if other YUV formats require the same setting and what is the appropriate setting for RAW and sRGB formats.

---
 drivers/staging/media/imx/imx7-mipi-csis.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/staging/media/imx/imx7-mipi-csis.c +4 -0
index cb54bb7491d9..e96989c46479 100644
@@ -499,6 +499,10 @@ static void __mipi_csis_set_format(struct csi_state *state)
 	/* Color format */
 	val = mipi_csis_read(state, MIPI_CSIS_ISP_CONFIG_CH(0));
 	val &= ~(MIPI_CSIS_ISPCFG_ALIGN_32BIT | MIPI_CSIS_ISPCFG_FMT_MASK);
+
+	if (state->csis_fmt->data_type == MIPI_CSI2_DATA_TYPE_YUV422_8)
+		val |= MIPI_CSIS_ISPCFG_PIXEL_MODE_DUAL;
+
 	val |= MIPI_CSIS_ISPCFG_FMT(state->csis_fmt->data_type);
 	mipi_csis_write(state, MIPI_CSIS_ISP_CONFIG_CH(0), val);
 
Signature · 1 line
2.34.1
#7 lore raw

Re: [PATCH 2/2] staging: media: imx: imx7-mipi-csic: Set PIXEL_MODE for YUV422

Hi Jacopo,

Thank you for the patch.

Quoted 9 lines · Jacopo Mondi

Bits 13 and 12 of the ISP_CONFIGn register configure the PIXEL_MODE which specifies the sampling size, in pixel component units, on the CSI-2 output data interface when data are transferred to memory.

The register description in the chip manual specifies that DUAL mode should be used for YUV422 data but does not clarify the reason.

Todo: verify if other YUV formats require the same setting and what is the appropriate setting for RAW and sRGB formats.

I'll also test it on i.MX8MM, I recall I had to *not* set PIXEL_MODE_DUAL on that platform for YUV to work.

Quoted 20 lines
---
 drivers/staging/media/imx/imx7-mipi-csis.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/staging/media/imx/imx7-mipi-csis.c +4 -0
index cb54bb7491d9..e96989c46479 100644
@@ -499,6 +499,10 @@ static void __mipi_csis_set_format(struct csi_state *state)
 	/* Color format */
 	val = mipi_csis_read(state, MIPI_CSIS_ISP_CONFIG_CH(0));
 	val &= ~(MIPI_CSIS_ISPCFG_ALIGN_32BIT | MIPI_CSIS_ISPCFG_FMT_MASK);
+
+	if (state->csis_fmt->data_type == MIPI_CSI2_DATA_TYPE_YUV422_8)
+		val |= MIPI_CSIS_ISPCFG_PIXEL_MODE_DUAL;
+
 	val |= MIPI_CSIS_ISPCFG_FMT(state->csis_fmt->data_type);
 	mipi_csis_write(state, MIPI_CSIS_ISP_CONFIG_CH(0), val);
 
Signature · 3 lines
Regards,

Laurent Pinchart
Acked-by on the v1 series
#8 lore raw
In reply to Jacopo Mondi

Hey Jacopo,
both patches LGTM.

I only have one nit with them...

Quoted 10 lines · Jacopo Mondi

Two small fixes for the imx7-mipi-csis driver.

The second patch is required to correctly capture in packed YUV422 formats

Thanks
j

Jacopo Mondi (2):
staging: media: imx: imx7-mipi-csic: Resume on debug
staging: media: imx: imx7-mipi-csic: Set PIXEL_MODE for YUV422

^
here should be s (imx7-mipi-csis) on both patches

Maybe Laurent could fix the typo on the pull, other than that:

Cheers,
Rui

Quoted 6 lines
 drivers/staging/media/imx/imx7-mipi-csis.c | 8 ++++++++
 1 file changed, 8 insertions(+)

--
2.34.1

#9 lore raw

Hi Rui

Quoted 11 lines · Rui Miguel Silva

Hey Jacopo,
both patches LGTM.

I only have one nit with them...

Quoted 4 lines · Jacopo Mondi

Two small fixes for the imx7-mipi-csis driver.

The second patch is required to correctly capture in packed YUV422 formats

Quoted 8 lines
Quoted 6 lines

Thanks
j

Jacopo Mondi (2):
staging: media: imx: imx7-mipi-csic: Resume on debug
staging: media: imx: imx7-mipi-csic: Set PIXEL_MODE for YUV422

^
here should be s (imx7-mipi-csis) on both patches

Oh ups, I honestly thought at the time the IP core was called csic...

Quoted 2 lines

Maybe Laurent could fix the typo on the pull, other than that:

I owe an update to add an error check to 1/2 once Laurent (or someone with an i.MX8MM) tests 2/2, so I can fix the subject in v2.

Quoted 2 lines

Thanks
j

Quoted 13 lines

Cheers,
Rui

Quoted 6 lines
 drivers/staging/media/imx/imx7-mipi-csis.c | 8 ++++++++
 1 file changed, 8 insertions(+)

--
2.34.1