Skip to content

Commit 72dbeba

Browse files
Jacopo Mondipopcornmix
authored andcommitted
media: pisp_be: Use clamp() and define max sizes
Use the clamp() from minmax.h and provide a define for the max size as they will be used in sequent patches. Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
1 parent 5e06284 commit 72dbeba

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

drivers/media/platform/raspberrypi/pisp_be/pisp_be.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <linux/io.h>
1010
#include <linux/kernel.h>
1111
#include <linux/lockdep.h>
12+
#include <linux/minmax.h>
1213
#include <linux/module.h>
1314
#include <linux/platform_device.h>
1415
#include <linux/pm_runtime.h>
@@ -1144,10 +1145,12 @@ static void pispbe_try_format(struct v4l2_format *f, struct pispbe_node *node)
11441145
f->fmt.pix_mp.pixelformat = fmt->fourcc;
11451146
f->fmt.pix_mp.num_planes = fmt->num_planes;
11461147
f->fmt.pix_mp.field = V4L2_FIELD_NONE;
1147-
f->fmt.pix_mp.width = max(min(f->fmt.pix_mp.width, 65536u),
1148-
PISP_BACK_END_MIN_TILE_WIDTH);
1149-
f->fmt.pix_mp.height = max(min(f->fmt.pix_mp.height, 65536u),
1150-
PISP_BACK_END_MIN_TILE_HEIGHT);
1148+
f->fmt.pix_mp.width = clamp(f->fmt.pix_mp.width,
1149+
PISP_BACK_END_MIN_TILE_WIDTH,
1150+
PISP_BACK_END_MAX_TILE_WIDTH);
1151+
f->fmt.pix_mp.height = clamp(f->fmt.pix_mp.height,
1152+
PISP_BACK_END_MIN_TILE_HEIGHT,
1153+
PISP_BACK_END_MAX_TILE_HEIGHT);
11511154

11521155
/*
11531156
* Fill in the actual colour space when the requested one was

include/uapi/linux/media/raspberrypi/pisp_be_config.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121
/* preferred byte alignment for outputs */
2222
#define PISP_BACK_END_OUTPUT_MAX_ALIGN 64u
2323

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
2829

2930
#define PISP_BACK_END_NUM_OUTPUTS 2
3031
#define PISP_BACK_END_HOG_OUTPUT 1

0 commit comments

Comments
 (0)