Add enum_mbus_code ioctl so that user space can know what
formats are supported to csi2rx.
Signed-off-by: Changhuang Liang <[email protected]>
---
drivers/media/platform/cadence/cdns-csi2rx.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c
index 889f4fbbafb3..7788ce0e3171 100644
--- a/drivers/media/platform/cadence/cdns-csi2rx.c
+++ b/drivers/media/platform/cadence/cdns-csi2rx.c
@@ -389,6 +389,18 @@ static int csi2rx_s_stream(struct v4l2_subdev *subdev, int enable)
return ret;
}
+static int csi2rx_enum_mbus_code(struct v4l2_subdev *subdev,
+ struct v4l2_subdev_state *state,
+ struct v4l2_subdev_mbus_code_enum *code_enum)
+{
+ if (code_enum->index >= ARRAY_SIZE(formats))
+ return -EINVAL;
+
+ code_enum->code = formats[code_enum->index].code;
+
+ return 0;
+}
+
static int csi2rx_set_fmt(struct v4l2_subdev *subdev,
struct v4l2_subdev_state *state,
struct v4l2_subdev_format *format)
@@ -439,6 +451,7 @@ static int csi2rx_init_cfg(struct v4l2_subdev *subdev,
}
static const struct v4l2_subdev_pad_ops csi2rx_pad_ops = {
+ .enum_mbus_code = csi2rx_enum_mbus_code,
.get_fmt = v4l2_subdev_get_fmt,
.set_fmt = csi2rx_set_fmt,
.init_cfg = csi2rx_init_cfg,
--
2.25.1
Hi,
On 12/11/23 10:43, Changhuang Liang wrote:
> Add enum_mbus_code ioctl so that user space can know what
> formats are supported to csi2rx.
>
> Signed-off-by: Changhuang Liang <[email protected]>
Reviewed-by: Julien Massot <[email protected]>
Tested-by: Julien Massot <[email protected]>
> ---
> drivers/media/platform/cadence/cdns-csi2rx.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c
> index 889f4fbbafb3..7788ce0e3171 100644
> --- a/drivers/media/platform/cadence/cdns-csi2rx.c
> +++ b/drivers/media/platform/cadence/cdns-csi2rx.c
> @@ -389,6 +389,18 @@ static int csi2rx_s_stream(struct v4l2_subdev *subdev, int enable)
> return ret;
> }
>
> +static int csi2rx_enum_mbus_code(struct v4l2_subdev *subdev,
> + struct v4l2_subdev_state *state,
> + struct v4l2_subdev_mbus_code_enum *code_enum)
> +{
> + if (code_enum->index >= ARRAY_SIZE(formats))
> + return -EINVAL;
> +
> + code_enum->code = formats[code_enum->index].code;
> +
> + return 0;
> +}
> +
> static int csi2rx_set_fmt(struct v4l2_subdev *subdev,
> struct v4l2_subdev_state *state,
> struct v4l2_subdev_format *format)
> @@ -439,6 +451,7 @@ static int csi2rx_init_cfg(struct v4l2_subdev *subdev,
> }
>
> static const struct v4l2_subdev_pad_ops csi2rx_pad_ops = {
> + .enum_mbus_code = csi2rx_enum_mbus_code,
> .get_fmt = v4l2_subdev_get_fmt,
> .set_fmt = csi2rx_set_fmt,
> .init_cfg = csi2rx_init_cfg,
Regards,
--
Julien Massot
Hi,
Thanks for the patch.
On Dec 11, 2023 at 01:43:29 -0800, Changhuang Liang wrote:
> Add enum_mbus_code ioctl so that user space can know what
> formats are supported to csi2rx.
>
> Signed-off-by: Changhuang Liang <[email protected]>
> ---
> drivers/media/platform/cadence/cdns-csi2rx.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c
> index 889f4fbbafb3..7788ce0e3171 100644
> --- a/drivers/media/platform/cadence/cdns-csi2rx.c
> +++ b/drivers/media/platform/cadence/cdns-csi2rx.c
> @@ -389,6 +389,18 @@ static int csi2rx_s_stream(struct v4l2_subdev *subdev, int enable)
> return ret;
> }
>
> +static int csi2rx_enum_mbus_code(struct v4l2_subdev *subdev,
> + struct v4l2_subdev_state *state,
> + struct v4l2_subdev_mbus_code_enum *code_enum)
> +{
> + if (code_enum->index >= ARRAY_SIZE(formats))
> + return -EINVAL;
> +
> + code_enum->code = formats[code_enum->index].code;
> +
> + return 0;
> +}
> +
Tested next-20240108 + this patch, output looks good to me:
root@am62axx-evm:~# v4l2-ctl -d/dev/v4l-subdev0 --list-subdev-mbus-codes
ioctl: VIDIOC_SUBDEV_ENUM_MBUS_CODE (pad=0,stream=0)
0x2011: MEDIA_BUS_FMT_YUYV8_1X16
0x200f: MEDIA_BUS_FMT_UYVY8_1X16
0x2012: MEDIA_BUS_FMT_YVYU8_1X16
0x2010: MEDIA_BUS_FMT_VYUY8_1X16
0x3001: MEDIA_BUS_FMT_SBGGR8_1X8
0x3013: MEDIA_BUS_FMT_SGBRG8_1X8
0x3002: MEDIA_BUS_FMT_SGRBG8_1X8
0x3014: MEDIA_BUS_FMT_SRGGB8_1X8
0x3007: MEDIA_BUS_FMT_SBGGR10_1X10
0x300e: MEDIA_BUS_FMT_SGBRG10_1X10
0x300a: MEDIA_BUS_FMT_SGRBG10_1X10
0x300f: MEDIA_BUS_FMT_SRGGB10_1X10
Reviewed-by: Jai Luthra <[email protected]>
Tested-by: Jai Luthra <[email protected]> # [Test on sk-am62a]
> static int csi2rx_set_fmt(struct v4l2_subdev *subdev,
> struct v4l2_subdev_state *state,
> struct v4l2_subdev_format *format)
> @@ -439,6 +451,7 @@ static int csi2rx_init_cfg(struct v4l2_subdev *subdev,
> }
>
> static const struct v4l2_subdev_pad_ops csi2rx_pad_ops = {
> + .enum_mbus_code = csi2rx_enum_mbus_code,
> .get_fmt = v4l2_subdev_get_fmt,
> .set_fmt = csi2rx_set_fmt,
> .init_cfg = csi2rx_init_cfg,
> --
> 2.25.1
>
>
--
Thanks,
Jai
GPG Fingerprint: 4DE0 D818 E5D5 75E8 D45A AFC5 43DE 91F9 249A 7145