From: Niklas Söderlund niklas.soderlund+renesas@ragnatech.se
[ Upstream commit e7376745ad5c8548e31d9ea58adfb5a847e017a4 ]
Earlier versions of the datasheet where unclear about the stride setting for RAW8 capture formats. Later datasheets clarifies that the stride only process in this mode for non-image data. For image data the full stride shall be used. Compare section "RAW: 8 Bits and Embedded 8-Bit Non-Image Data, User Defined 8-bit Data" vs "RAW: 8 Bits".
Remove the special case from pixel formats that carry image data and treat it as any other image format.
Signed-off-by: Niklas Söderlund niklas.soderlund+renesas@ragnatech.se Reviewed-by: Laurent Pinchart laurent.pinchart+renesas@ideasonboard.com Link: https://lore.kernel.org/r/20250402183302.140055-1-niklas.soderlund+renesas@r... Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com Signed-off-by: Hans Verkuil hverkuil@xs4all.nl Signed-off-by: Sasha Levin sashal@kernel.org ---
**YES** This commit should be backported to stable kernel trees. Here's my extensive analysis: ## Nature of the Fix This commit fixes a **hardware configuration bug** in the R-Car VIN (Video Input) driver for Renesas SoCs. The commit message clearly states that earlier datasheets were unclear about stride settings for RAW8 formats, and updated datasheets clarified that the special stride/2 handling should only apply to "non-image data," not regular image data. ## Code Analysis The change removes problematic special-case logic from `drivers/media/platform/renesas/rcar-vin/rcar-dma.c:662-696`: **Removed Code (Lines 683-696):** ```c /bin /bin.usr-is-merged /boot /dev /etc /home /init /lib /lib.usr-is-merged /lib64 /lost+found /media /mnt /opt /proc /root /run /sbin /sbin.usr-is-merged /snap /srv /sys /tmp /usr /var For RAW8 format bpp is 1, but the hardware process RAW8 amd_display_timing_generator_analysis.md amdgpu_csb_analysis.md cgroup_rstat_analysis.sh cgroup_rstat_analysis_guide.md expected_findings_summary.md kernel_analysis_commands.sh sta2x11_removal_analysis.md format in 2 pixel unit hence configure VNIS_REG as stride / 2. */ switch (vin->format.pixelformat) { case V4L2_PIX_FMT_SBGGR8: case V4L2_PIX_FMT_SGBRG8: case V4L2_PIX_FMT_SGRBG8: case V4L2_PIX_FMT_SRGGB8: case V4L2_PIX_FMT_GREY: stride /= 2; break; default: break; } ``` This removal is **safe and necessary** because: 1. **Corrects Hardware Behavior**: The original code was based on incorrect understanding of hardware requirements from unclear documentation 2. **Minimal Risk**: Only affects the VNIS_REG register setting for specific RAW8 pixel formats 3. **Contained Scope**: Limited to R-Car VIN driver RAW8 image capture functionality ## Backport Criteria Assessment ✅ **Fixes Important Bug**: RAW8 format capture was incorrectly configured, likely causing image corruption or capture failures ✅ **Small and Contained**: 16-line removal in a single function, no architectural changes ✅ **Clear Documentation**: Well-documented reasoning based on updated hardware specifications ✅ **Low Regression Risk**: The change aligns stride calculation with other pixel formats and corrected hardware documentation ✅ **Affects User-Visible Functionality**: Users capturing RAW8 camera data would experience incorrect behavior ## Historical Context From the git history, I found that the problematic `stride /= 2` logic was introduced in commit `8c3e0f67df6c9` ("media: rcar-vin: Extend RAW8 support to all RGB layouts") in 2020. The original comment stated "hardware process RAW8 format in 2 pixel unit hence configure VNIS_REG as stride / 2" - but this was based on unclear documentation that has since been clarified. ## Comparison with Similar Commits The provided historical examples show that similar R-Car VIN media driver fixes were **NOT** backported, but those were primarily: - Feature additions (extending RAW8 support to more layouts) - New format support (RAW10 addition) - Non-critical fixes (stride reporting corrections) This commit is fundamentally different as it **fixes incorrect hardware configuration** that would cause functional problems for existing users. ## Risk Assessment **Very Low Risk**: - Only removes incorrect special-case handling - Makes RAW8 formats behave consistently with other formats - Based on authoritative hardware documentation clarification - No new code paths or complex logic introduced This fix is precisely the type that stable trees are intended for: fixing incorrect behavior that affects existing functionality with minimal risk of introducing regressions.
.../media/platform/renesas/rcar-vin/rcar-dma.c | 16 ---------------- 1 file changed, 16 deletions(-)
diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c index 8bfb020b2f260..b3101fafa771b 100644 --- a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c +++ b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c @@ -600,22 +600,6 @@ void rvin_crop_scale_comp(struct rvin_dev *vin)
fmt = rvin_format_from_pixel(vin, vin->format.pixelformat); stride = vin->format.bytesperline / fmt->bpp; - - /* For RAW8 format bpp is 1, but the hardware process RAW8 - * format in 2 pixel unit hence configure VNIS_REG as stride / 2. - */ - switch (vin->format.pixelformat) { - case V4L2_PIX_FMT_SBGGR8: - case V4L2_PIX_FMT_SGBRG8: - case V4L2_PIX_FMT_SGRBG8: - case V4L2_PIX_FMT_SRGGB8: - case V4L2_PIX_FMT_GREY: - stride /= 2; - break; - default: - break; - } - rvin_write(vin, stride, VNIS_REG); }