Message ID | 20250123-v4h-iif-v1-4-7b4e5299939f@ideasonboard.com (mailing list archive) |
---|---|
State | New |
Delegated to: | Kieran Bingham |
Headers | show |
Series | media: renesas: vsp1: Add support for IIF | expand |
Hi Jacopo, Thank you for the patch. On Thu, Jan 23, 2025 at 06:04:05PM +0100, Jacopo Mondi wrote: > The current implementation of the r/wpf format handling assumes > three formats to be supported in the RGB/YUV space. > > With the forthcoming support for VSPX the r/wpf units will be > used to fetch from exteranal memory images in RAW Bayer format s/exteranal/external/ > and buffers of ISP configuration parameters. > > Prepare for adding support for these new formats by breaking > out the list of supported media bus codes in the vsp1_rwpf.c > file. > > Signed-off-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> > --- > drivers/media/platform/renesas/vsp1/vsp1_rwpf.c | 25 ++++++++++++++----------- > 1 file changed, 14 insertions(+), 11 deletions(-) > > diff --git a/drivers/media/platform/renesas/vsp1/vsp1_rwpf.c b/drivers/media/platform/renesas/vsp1/vsp1_rwpf.c > index 9d38203e73d00b82a1a7db0353e2f0b5a94084f6..93b0ed5fd0da0c6a182dbbfe1e54eb8cfd66c493 100644 > --- a/drivers/media/platform/renesas/vsp1/vsp1_rwpf.c > +++ b/drivers/media/platform/renesas/vsp1/vsp1_rwpf.c > @@ -16,6 +16,12 @@ > #define RWPF_MIN_WIDTH 1 > #define RWPF_MIN_HEIGHT 1 > > +static const u32 rwpf_mbus_codes[] = { > + MEDIA_BUS_FMT_ARGB8888_1X32, > + MEDIA_BUS_FMT_AHSV8888_1X32, > + MEDIA_BUS_FMT_AYUV8_1X32, > +}; > + > /* ----------------------------------------------------------------------------- > * V4L2 Subdevice Operations > */ > @@ -24,16 +30,10 @@ static int vsp1_rwpf_enum_mbus_code(struct v4l2_subdev *subdev, > struct v4l2_subdev_state *sd_state, > struct v4l2_subdev_mbus_code_enum *code) > { > - static const unsigned int codes[] = { > - MEDIA_BUS_FMT_ARGB8888_1X32, > - MEDIA_BUS_FMT_AHSV8888_1X32, > - MEDIA_BUS_FMT_AYUV8_1X32, > - }; > - > - if (code->index >= ARRAY_SIZE(codes)) > + if (code->index >= ARRAY_SIZE(rwpf_mbus_codes)) > return -EINVAL; > > - code->code = codes[code->index]; > + code->code = rwpf_mbus_codes[code->index]; > > return 0; > } > @@ -57,6 +57,7 @@ static int vsp1_rwpf_set_format(struct v4l2_subdev *subdev, > struct vsp1_rwpf *rwpf = to_rwpf(subdev); > struct v4l2_subdev_state *state; > struct v4l2_mbus_framefmt *format; > + unsigned int i; > int ret = 0; > > mutex_lock(&rwpf->entity.lock); > @@ -68,9 +69,11 @@ static int vsp1_rwpf_set_format(struct v4l2_subdev *subdev, > } > > /* Default to YUV if the requested format is not supported. */ > - if (fmt->format.code != MEDIA_BUS_FMT_ARGB8888_1X32 && > - fmt->format.code != MEDIA_BUS_FMT_AHSV8888_1X32 && > - fmt->format.code != MEDIA_BUS_FMT_AYUV8_1X32) > + for (i = 0; i < ARRAY_SIZE(rwpf_mbus_codes); ++i) { > + if (fmt->format.code == rwpf_mbus_codes[i]) > + break; > + } > + if (i == ARRAY_SIZE(rwpf_mbus_codes)) > fmt->format.code = MEDIA_BUS_FMT_AYUV8_1X32; > > format = v4l2_subdev_state_get_format(state, fmt->pad); >
diff --git a/drivers/media/platform/renesas/vsp1/vsp1_rwpf.c b/drivers/media/platform/renesas/vsp1/vsp1_rwpf.c index 9d38203e73d00b82a1a7db0353e2f0b5a94084f6..93b0ed5fd0da0c6a182dbbfe1e54eb8cfd66c493 100644 --- a/drivers/media/platform/renesas/vsp1/vsp1_rwpf.c +++ b/drivers/media/platform/renesas/vsp1/vsp1_rwpf.c @@ -16,6 +16,12 @@ #define RWPF_MIN_WIDTH 1 #define RWPF_MIN_HEIGHT 1 +static const u32 rwpf_mbus_codes[] = { + MEDIA_BUS_FMT_ARGB8888_1X32, + MEDIA_BUS_FMT_AHSV8888_1X32, + MEDIA_BUS_FMT_AYUV8_1X32, +}; + /* ----------------------------------------------------------------------------- * V4L2 Subdevice Operations */ @@ -24,16 +30,10 @@ static int vsp1_rwpf_enum_mbus_code(struct v4l2_subdev *subdev, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_mbus_code_enum *code) { - static const unsigned int codes[] = { - MEDIA_BUS_FMT_ARGB8888_1X32, - MEDIA_BUS_FMT_AHSV8888_1X32, - MEDIA_BUS_FMT_AYUV8_1X32, - }; - - if (code->index >= ARRAY_SIZE(codes)) + if (code->index >= ARRAY_SIZE(rwpf_mbus_codes)) return -EINVAL; - code->code = codes[code->index]; + code->code = rwpf_mbus_codes[code->index]; return 0; } @@ -57,6 +57,7 @@ static int vsp1_rwpf_set_format(struct v4l2_subdev *subdev, struct vsp1_rwpf *rwpf = to_rwpf(subdev); struct v4l2_subdev_state *state; struct v4l2_mbus_framefmt *format; + unsigned int i; int ret = 0; mutex_lock(&rwpf->entity.lock); @@ -68,9 +69,11 @@ static int vsp1_rwpf_set_format(struct v4l2_subdev *subdev, } /* Default to YUV if the requested format is not supported. */ - if (fmt->format.code != MEDIA_BUS_FMT_ARGB8888_1X32 && - fmt->format.code != MEDIA_BUS_FMT_AHSV8888_1X32 && - fmt->format.code != MEDIA_BUS_FMT_AYUV8_1X32) + for (i = 0; i < ARRAY_SIZE(rwpf_mbus_codes); ++i) { + if (fmt->format.code == rwpf_mbus_codes[i]) + break; + } + if (i == ARRAY_SIZE(rwpf_mbus_codes)) fmt->format.code = MEDIA_BUS_FMT_AYUV8_1X32; format = v4l2_subdev_state_get_format(state, fmt->pad);
The current implementation of the r/wpf format handling assumes three formats to be supported in the RGB/YUV space. With the forthcoming support for VSPX the r/wpf units will be used to fetch from exteranal memory images in RAW Bayer format and buffers of ISP configuration parameters. Prepare for adding support for these new formats by breaking out the list of supported media bus codes in the vsp1_rwpf.c file. Signed-off-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com> --- drivers/media/platform/renesas/vsp1/vsp1_rwpf.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-)