Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: pisp_be: Use clamp() and define max sizes

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>

authored by

Jacopo Mondi and committed by
Hans Verkuil
aa89281b e9bb2eac

+12 -8
+7 -4
drivers/media/platform/raspberrypi/pisp_be/pisp_be.c
··· 9 9 #include <linux/io.h> 10 10 #include <linux/kernel.h> 11 11 #include <linux/lockdep.h> 12 + #include <linux/minmax.h> 12 13 #include <linux/module.h> 13 14 #include <linux/platform_device.h> 14 15 #include <linux/pm_runtime.h> ··· 1113 1112 f->fmt.pix_mp.pixelformat = fmt->fourcc; 1114 1113 f->fmt.pix_mp.num_planes = fmt->num_planes; 1115 1114 f->fmt.pix_mp.field = V4L2_FIELD_NONE; 1116 - f->fmt.pix_mp.width = max(min(f->fmt.pix_mp.width, 65536u), 1117 - PISP_BACK_END_MIN_TILE_WIDTH); 1118 - f->fmt.pix_mp.height = max(min(f->fmt.pix_mp.height, 65536u), 1119 - PISP_BACK_END_MIN_TILE_HEIGHT); 1115 + f->fmt.pix_mp.width = clamp(f->fmt.pix_mp.width, 1116 + PISP_BACK_END_MIN_TILE_WIDTH, 1117 + PISP_BACK_END_MAX_TILE_WIDTH); 1118 + f->fmt.pix_mp.height = clamp(f->fmt.pix_mp.height, 1119 + PISP_BACK_END_MIN_TILE_HEIGHT, 1120 + PISP_BACK_END_MAX_TILE_HEIGHT); 1120 1121 1121 1122 /* 1122 1123 * Fill in the actual colour space when the requested one was
+5 -4
include/uapi/linux/media/raspberrypi/pisp_be_config.h
··· 21 21 /* preferred byte alignment for outputs */ 22 22 #define PISP_BACK_END_OUTPUT_MAX_ALIGN 64u 23 23 24 - /* minimum allowed tile width anywhere in the pipeline */ 25 - #define PISP_BACK_END_MIN_TILE_WIDTH 16u 26 - /* minimum allowed tile width anywhere in the pipeline */ 27 - #define PISP_BACK_END_MIN_TILE_HEIGHT 16u 24 + /* minimum allowed tile sizes anywhere in the pipeline */ 25 + #define PISP_BACK_END_MIN_TILE_WIDTH 16u 26 + #define PISP_BACK_END_MIN_TILE_HEIGHT 16u 27 + #define PISP_BACK_END_MAX_TILE_WIDTH 65536u 28 + #define PISP_BACK_END_MAX_TILE_HEIGHT 65536u 28 29 29 30 #define PISP_BACK_END_NUM_OUTPUTS 2 30 31 #define PISP_BACK_END_HOG_OUTPUT 1