]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
media: pisp_be: Use clamp() and define max sizes
authorJacopo Mondi <jacopo.mondi@ideasonboard.com>
Thu, 12 Jun 2025 14:58:21 +0000 (16:58 +0200)
committerHans Verkuil <hverkuil@xs4all.nl>
Thu, 3 Jul 2025 07:25:01 +0000 (09:25 +0200)
Use the clamp() function from minmax.h and provide a define for the max
sizes as they will be used in subsequent patches.

Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
drivers/media/platform/raspberrypi/pisp_be/pisp_be.c
include/uapi/linux/media/raspberrypi/pisp_be_config.h

index be794a12362020f42b3cf5bd291b4a1625543b5f..b30891718d8df9c48ce1b83ad9fcafb201105625 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/lockdep.h>
+#include <linux/minmax.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
@@ -1112,10 +1113,12 @@ static void pispbe_try_format(struct v4l2_format *f, struct pispbe_node *node)
        f->fmt.pix_mp.pixelformat = fmt->fourcc;
        f->fmt.pix_mp.num_planes = fmt->num_planes;
        f->fmt.pix_mp.field = V4L2_FIELD_NONE;
-       f->fmt.pix_mp.width = max(min(f->fmt.pix_mp.width, 65536u),
-                                 PISP_BACK_END_MIN_TILE_WIDTH);
-       f->fmt.pix_mp.height = max(min(f->fmt.pix_mp.height, 65536u),
-                                  PISP_BACK_END_MIN_TILE_HEIGHT);
+       f->fmt.pix_mp.width = clamp(f->fmt.pix_mp.width,
+                                   PISP_BACK_END_MIN_TILE_WIDTH,
+                                   PISP_BACK_END_MAX_TILE_WIDTH);
+       f->fmt.pix_mp.height = clamp(f->fmt.pix_mp.height,
+                                    PISP_BACK_END_MIN_TILE_HEIGHT,
+                                    PISP_BACK_END_MAX_TILE_HEIGHT);
 
        /*
         * Fill in the actual colour space when the requested one was
index cbeb714f4d61ad53162c0450f2303431a5958040..2ad3b90684d7be80776af75b5c5009f7b677f466 100644 (file)
 /* preferred byte alignment for outputs */
 #define PISP_BACK_END_OUTPUT_MAX_ALIGN 64u
 
-/* minimum allowed tile width anywhere in the pipeline */
-#define PISP_BACK_END_MIN_TILE_WIDTH 16u
-/* minimum allowed tile width anywhere in the pipeline */
-#define PISP_BACK_END_MIN_TILE_HEIGHT 16u
+/* minimum allowed tile sizes anywhere in the pipeline */
+#define PISP_BACK_END_MIN_TILE_WIDTH   16u
+#define PISP_BACK_END_MIN_TILE_HEIGHT  16u
+#define PISP_BACK_END_MAX_TILE_WIDTH   65536u
+#define PISP_BACK_END_MAX_TILE_HEIGHT  65536u
 
 #define PISP_BACK_END_NUM_OUTPUTS 2
 #define PISP_BACK_END_HOG_OUTPUT 1