2023-12-14 06:51:20

by Changhuang Liang

[permalink] [raw]
Subject: [PATCH v1 4/9] staging: media: starfive: camss: Replace format index with pad

Replace format index with pad.

Signed-off-by: Changhuang Liang <[email protected]>
---
drivers/staging/media/starfive/camss/stf-isp.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/media/starfive/camss/stf-isp.c b/drivers/staging/media/starfive/camss/stf-isp.c
index ac83f23842df..c3ae02cf6dd8 100644
--- a/drivers/staging/media/starfive/camss/stf-isp.c
+++ b/drivers/staging/media/starfive/camss/stf-isp.c
@@ -11,9 +11,6 @@

#include "stf-camss.h"

-#define SINK_FORMATS_INDEX 0
-#define SOURCE_FORMATS_INDEX 1
-
static int isp_set_selection(struct v4l2_subdev *sd,
struct v4l2_subdev_state *state,
struct v4l2_subdev_selection *sel);
@@ -95,11 +92,7 @@ static void isp_try_format(struct stf_isp_dev *isp_dev,
return;
}

- if (pad == STF_ISP_PAD_SINK)
- formats = &isp_dev->formats[SINK_FORMATS_INDEX];
- else if (pad == STF_ISP_PAD_SRC)
- formats = &isp_dev->formats[SOURCE_FORMATS_INDEX];
-
+ formats = &isp_dev->formats[pad];
fmt->width = clamp_t(u32, fmt->width, STFCAMSS_FRAME_MIN_WIDTH,
STFCAMSS_FRAME_MAX_WIDTH);
fmt->height = clamp_t(u32, fmt->height, STFCAMSS_FRAME_MIN_HEIGHT,
@@ -124,7 +117,7 @@ static int isp_enum_mbus_code(struct v4l2_subdev *sd,
if (code->index >= ARRAY_SIZE(isp_formats_sink))
return -EINVAL;

- formats = &isp_dev->formats[SINK_FORMATS_INDEX];
+ formats = &isp_dev->formats[code->pad];
code->code = formats->fmts[code->index].code;
} else {
struct v4l2_mbus_framefmt *sink_fmt;
--
2.25.1


2023-12-14 12:13:04

by Laurent Pinchart

[permalink] [raw]
Subject: Re: [PATCH v1 4/9] staging: media: starfive: camss: Replace format index with pad

Hi Changhuang,

Thank you for the patch.

On Wed, Dec 13, 2023 at 10:50:22PM -0800, Changhuang Liang wrote:
> Replace format index with pad.

The code change looks good I think, but the commit message needs to
explain *why* you're changing this.

> Signed-off-by: Changhuang Liang <[email protected]>
> ---
> drivers/staging/media/starfive/camss/stf-isp.c | 11 ++---------
> 1 file changed, 2 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/staging/media/starfive/camss/stf-isp.c b/drivers/staging/media/starfive/camss/stf-isp.c
> index ac83f23842df..c3ae02cf6dd8 100644
> --- a/drivers/staging/media/starfive/camss/stf-isp.c
> +++ b/drivers/staging/media/starfive/camss/stf-isp.c
> @@ -11,9 +11,6 @@
>
> #include "stf-camss.h"
>
> -#define SINK_FORMATS_INDEX 0
> -#define SOURCE_FORMATS_INDEX 1
> -
> static int isp_set_selection(struct v4l2_subdev *sd,
> struct v4l2_subdev_state *state,
> struct v4l2_subdev_selection *sel);
> @@ -95,11 +92,7 @@ static void isp_try_format(struct stf_isp_dev *isp_dev,
> return;
> }
>
> - if (pad == STF_ISP_PAD_SINK)
> - formats = &isp_dev->formats[SINK_FORMATS_INDEX];
> - else if (pad == STF_ISP_PAD_SRC)
> - formats = &isp_dev->formats[SOURCE_FORMATS_INDEX];
> -
> + formats = &isp_dev->formats[pad];
> fmt->width = clamp_t(u32, fmt->width, STFCAMSS_FRAME_MIN_WIDTH,
> STFCAMSS_FRAME_MAX_WIDTH);
> fmt->height = clamp_t(u32, fmt->height, STFCAMSS_FRAME_MIN_HEIGHT,
> @@ -124,7 +117,7 @@ static int isp_enum_mbus_code(struct v4l2_subdev *sd,
> if (code->index >= ARRAY_SIZE(isp_formats_sink))
> return -EINVAL;
>
> - formats = &isp_dev->formats[SINK_FORMATS_INDEX];
> + formats = &isp_dev->formats[code->pad];
> code->code = formats->fmts[code->index].code;
> } else {
> struct v4l2_mbus_framefmt *sink_fmt;

--
Regards,

Laurent Pinchart