public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: media: atomisp: csi2: Fix DPCM decompression for source pad format
@ 2026-04-20  3:27 Debjeet Banerjee
  2026-04-20  4:34 ` [PATCH v2] " Debjeet Banerjee
  0 siblings, 1 reply; 19+ messages in thread
From: Debjeet Banerjee @ 2026-04-20  3:27 UTC (permalink / raw)
  To: hansg, mchehab, gregkh
  Cc: andy, sakari.ailus, debjeetbanerjee48, linux-media, linux-kernel,
	inux-staging

The CSI2 source pad format was set by blindly copying the sink pad
format, regardless of whether the sink pad is receiving a DPCM-compressed
mbus code. This was marked with a FIXME comment.

When a sensor transmits DPCM-compressed data over MIPI CSI-2 (e.g.
MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8), the Atom ISP hardware decompresses it
before passing it to the ISP pipeline. Therefore the source pad must
expose the uncompressed format (e.g. MEDIA_BUS_FMT_SGRBG10_1X10), not
the compressed one.

atomisp_subdev_uncompressed_code() already implements this mapping via
the compressed_codes[] table in atomisp_subdev.c, which pairs each
DPCM mbus code with its uncompressed counterpart. For codes that are not
DPCM-compressed, the function returns the code unchanged, so this change
is a no-op for all non-DPCM formats.

Signed-off-by: Debjeet Banerjee <debjeetbanerjee48@gmail.com>
---
 drivers/staging/media/atomisp/pci/atomisp_csi2.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_csi2.c b/drivers/staging/media/atomisp/pci/atomisp_csi2.c
index 95b9113d75e9..484765b0d9e6 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_csi2.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_csi2.c
@@ -107,10 +107,17 @@ int atomisp_csi2_set_ffmt(struct v4l2_subdev *sd,
 					     &tmp_ffmt);
 	}
 
-     /* FIXME: DPCM decompression */
-     *actual_ffmt = *ffmt = *__csi2_get_format(csi2, sd_state, which,
-                 CSI2_PAD_SINK);
-    
+    /*
+     * The source pad must expose the uncompressed format even when the sink
+     * pad receives DPCM-compressed data. The hardware decompresses DPCM
+     * (e.g. SGRBG10_DPCM8_1X8 -> SGRBG10_1X10) between sink and source,
+     * so propagate the sink format but map the mbus code to its uncompressed
+     * equivalent. atomisp_subdev_uncompressed_code() returns the code
+     * unchanged for formats that are not DPCM-compressed.
+     */
+    *actual_ffmt = *__csi2_get_format(csi2, sd_state, which, CSI2_PAD_SINK);
+    actual_ffmt->code = atomisp_subdev_uncompressed_code(actual_ffmt->code);
+    *ffmt = *actual_ffmt;
      return 0;
   }
 
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2026-04-24 13:04 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-20  3:27 [PATCH] staging: media: atomisp: csi2: Fix DPCM decompression for source pad format Debjeet Banerjee
2026-04-20  4:34 ` [PATCH v2] " Debjeet Banerjee
2026-04-20  6:46   ` Andy Shevchenko
2026-04-20  7:42     ` Debjeet Banerjee
2026-04-21  8:22     ` [PATCH v3] " Debjeet Banerjee
2026-04-22 10:46       ` Sakari Ailus
2026-04-22 11:16         ` Debjeet Banerjee
2026-04-22 11:18           ` Sakari Ailus
2026-04-22 12:20             ` [PATCH v4 1/2] media: atomisp: csi2: Remove unimplemented DPCM decompression Debjeet Banerjee
2026-04-22 12:20               ` [PATCH v4 2/2] media: atomisp: Remove unused DPCM helper functions and declarations Debjeet Banerjee
2026-04-22 12:38               ` [PATCH v4 1/2] media: atomisp: csi2: Remove unimplemented DPCM decompression Sakari Ailus
2026-04-22 12:48                 ` [PATCH v3] media: atomisp: csi2: Fix DPCM decompression for source pad format Debjeet Banerjee
2026-04-22 12:51                 ` [PATCH v4 1/2] media: atomisp: csi2: Remove unimplemented DPCM decompression Debjeet Banerjee
2026-04-22 12:58                   ` Sakari Ailus
2026-04-22 13:38                     ` Debjeet Banerjee
2026-04-23 12:52                     ` [PATCH v5 " Debjeet Banerjee
2026-04-23 12:52                       ` [PATCH v5 2/2] media: atomisp: Remove unused DPCM helper functions and declarations Debjeet Banerjee
2026-04-23 21:05                       ` [PATCH v5 1/2] media: atomisp: csi2: Remove unimplemented DPCM decompression Sakari Ailus
2026-04-24 13:04                         ` [PATCH v6] media: atomisp: " Debjeet Banerjee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox