Skip to content

Commit 776f1bd

Browse files
changhuangliangmchehab
authored andcommitted
media: staging: media: starfive: Clean pad selection in isp_try_format()
The code to select isp_dev->formats[] is overly complicated. We can just use the "pad" as the index. This will making adding new pads easier in future patches. No functional change. Link: https://lore.kernel.org/linux-media/20240312024520.11022-1-changhuang.liang@starfivetech.com Signed-off-by: Changhuang Liang <changhuang.liang@starfivetech.com> Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
1 parent 53dbe08 commit 776f1bd

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

  • drivers/staging/media/starfive/camss

drivers/staging/media/starfive/camss/stf-isp.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010

1111
#include "stf-camss.h"
1212

13-
#define SINK_FORMATS_INDEX 0
14-
#define SOURCE_FORMATS_INDEX 1
15-
1613
static int isp_set_selection(struct v4l2_subdev *sd,
1714
struct v4l2_subdev_state *state,
1815
struct v4l2_subdev_selection *sel);
@@ -94,10 +91,7 @@ static void isp_try_format(struct stf_isp_dev *isp_dev,
9491
return;
9592
}
9693

97-
if (pad == STF_ISP_PAD_SINK)
98-
formats = &isp_dev->formats[SINK_FORMATS_INDEX];
99-
else if (pad == STF_ISP_PAD_SRC)
100-
formats = &isp_dev->formats[SOURCE_FORMATS_INDEX];
94+
formats = &isp_dev->formats[pad];
10195

10296
fmt->width = clamp_t(u32, fmt->width, STFCAMSS_FRAME_MIN_WIDTH,
10397
STFCAMSS_FRAME_MAX_WIDTH);
@@ -123,7 +117,7 @@ static int isp_enum_mbus_code(struct v4l2_subdev *sd,
123117
if (code->index >= ARRAY_SIZE(isp_formats_sink))
124118
return -EINVAL;
125119

126-
formats = &isp_dev->formats[SINK_FORMATS_INDEX];
120+
formats = &isp_dev->formats[code->pad];
127121
code->code = formats->fmts[code->index].code;
128122
} else {
129123
struct v4l2_mbus_framefmt *sink_fmt;

0 commit comments

Comments
 (0)