]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: stm32: dcmipp: byteproc: only allow compose with 8/16bit fmts
authorAlain Volmat <alain.volmat@foss.st.com>
Fri, 19 Dec 2025 14:30:39 +0000 (15:30 +0100)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Fri, 16 Jan 2026 13:08:52 +0000 (14:08 +0100)
Since the byteproc is working at byte level, it is not possible to
perform decimation with formats other than 8 or 16 bit per pixel.
Ensure any other format won't be able to set a compose.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-byteproc.c

index f45a3027f8f3ca05a4174d9a6e30eb30e2e6f1dd..f9e4a3a9ef3fa2a369e3e57c53c27e6c3362c737 100644 (file)
@@ -131,6 +131,8 @@ static void dcmipp_byteproc_adjust_crop(struct v4l2_rect *r,
 static void dcmipp_byteproc_adjust_compose(struct v4l2_rect *r,
                                           const struct v4l2_mbus_framefmt *fmt)
 {
+       const struct dcmipp_byteproc_pix_map *vpix;
+
        r->top = 0;
        r->left = 0;
 
@@ -142,6 +144,14 @@ static void dcmipp_byteproc_adjust_compose(struct v4l2_rect *r,
                return;
        }
 
+       /* Prevent compose on formats which are not 1 or 2 bytes per pixel */
+       vpix = dcmipp_byteproc_pix_map_by_code(fmt->code);
+       if (vpix->bpp != 1 && vpix->bpp != 2) {
+               r->width = fmt->width;
+               r->height = fmt->height;
+               return;
+       }
+
        /* Adjust height - we can only perform 1/2 decimation */
        if (r->height <= (fmt->height / 2))
                r->height = fmt->height / 2;
@@ -149,7 +159,7 @@ static void dcmipp_byteproc_adjust_compose(struct v4l2_rect *r,
                r->height = fmt->height;
 
        /* Adjust width /2 or /4 for 8bits formats and /2 for 16bits formats */
-       if (fmt->code == MEDIA_BUS_FMT_Y8_1X8 && r->width <= (fmt->width / 4))
+       if (vpix->bpp == 1 && r->width <= (fmt->width / 4))
                r->width = fmt->width / 4;
        else if (r->width <= (fmt->width / 2))
                r->width = fmt->width / 2;