staging: media: starfive: Add the dynamic resolution support
authorChanghuang Liang <changhuang.liang@starfivetech.com>
Tue, 20 Aug 2024 11:20:02 +0000 (04:20 -0700)
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Sat, 24 Aug 2024 22:42:01 +0000 (01:42 +0300)
Add the dynamic resolution support for video "capture_raw" device.
Otherwise it will capture the wrong image data if the width is
not 1920.

Fixes: e080f339c80a ("media: staging: media: starfive: camss: Add capture driver")
Signed-off-by: Changhuang Liang <changhuang.liang@starfivetech.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://lore.kernel.org/r/20240820112002.560432-1-changhuang.liang@starfivetech.com
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
drivers/staging/media/starfive/camss/stf-capture.c

index ec5169e7b3918bf2ff1ade1c294027cf816cd0e5..e15d2e97eb0b6ceaf6412563a2243293dd656308 100644 (file)
@@ -180,6 +180,8 @@ static void stf_channel_set(struct stfcamss_video *video)
        u32 val;
 
        if (cap->type == STF_CAPTURE_RAW) {
+               const struct v4l2_pix_format *pix = &video->active_fmt.fmt.pix;
+
                val = stf_syscon_reg_read(stfcamss, VIN_CHANNEL_SEL_EN);
                val &= ~U0_VIN_CHANNEL_SEL_MASK;
                val |= CHANNEL(0);
@@ -193,7 +195,7 @@ static void stf_channel_set(struct stfcamss_video *video)
                val |= PIXEL_HEIGH_BIT_SEL(0);
 
                val &= ~U0_VIN_PIX_CNT_END_MASK;
-               val |= PIX_CNT_END(IMAGE_MAX_WIDTH / 4 - 1);
+               val |= PIX_CNT_END(pix->width / 4 - 1);
 
                stf_syscon_reg_write(stfcamss, VIN_INRT_PIX_CFG, val);
        } else if (cap->type == STF_CAPTURE_YUV) {