media: staging/imx: Implement init_cfg subdev pad op
Steve Longerbeam
maintainerPATCH v2 1/1 media: staging/imx: Implement init_cfg subdev pad op
Implement the init_cfg pad op in all imx-media subdevices. The try formats are initialized to the current active formats on all pads.
---
Changes since v1:
- It isn't necessary to acquire the subdev locks in the init_cfg pad op, the op only writes the try_fmt in cfg, and cfg is private to every open subdev fh. Without the need for the lock, init_cfg can be made generic. So this version moves the op to imx-media-utils.c for all subdevs to call. It initializes try_fmt's to the current active formats.
drivers/staging/media/imx/imx-ic-prp.c | 1 + drivers/staging/media/imx/imx-ic-prpencvf.c | 1 + drivers/staging/media/imx/imx-media-csi.c | 1 + drivers/staging/media/imx/imx-media-utils.c | 29 +++++++++++++++++++++++++++++ drivers/staging/media/imx/imx-media-vdic.c | 1 + drivers/staging/media/imx/imx-media.h | 2 ++ drivers/staging/media/imx/imx6-mipi-csi2.c | 1 + 7 files changed, 36 insertions(+)
drivers/staging/media/imx/imx-ic-prp.c +1 -0
@@ -462,6 +462,7 @@ static int prp_registered(struct v4l2_subdev *sd) }static const struct v4l2_subdev_pad_ops prp_pad_ops = { + .init_cfg = imx_media_init_cfg, .enum_mbus_code = prp_enum_mbus_code, .get_fmt = prp_get_fmt, .set_fmt = prp_set_fmt,
drivers/staging/media/imx/imx-ic-prpencvf.c +1 -0
@@ -1253,6 +1253,7 @@ static void prp_unregistered(struct v4l2_subdev *sd) }static const struct v4l2_subdev_pad_ops prp_pad_ops = { + .init_cfg = imx_media_init_cfg, .enum_mbus_code = prp_enum_mbus_code, .enum_frame_size = prp_enum_frame_size, .get_fmt = prp_get_fmt,
drivers/staging/media/imx/imx-media-csi.c +1 -0
@@ -1715,6 +1715,7 @@ static const struct v4l2_subdev_video_ops csi_video_ops = { };static const struct v4l2_subdev_pad_ops csi_pad_ops = { + .init_cfg = imx_media_init_cfg, .enum_mbus_code = csi_enum_mbus_code, .enum_frame_size = csi_enum_frame_size, .enum_frame_interval = csi_enum_frame_interval,
drivers/staging/media/imx/imx-media-utils.c +29 -0
@@ -465,6 +465,35 @@ int imx_media_init_mbus_fmt(struct v4l2_mbus_framefmt *mbus,EXPORT_SYMBOL_GPL (imx_media_init_mbus_fmt);/* +* Initializes the TRY format to the ACTIVE format on all pads +* of a subdev. Can be used as the .init_cfg pad operation. +*/ +int imx_media_init_cfg (struct v4l2_subdev *sd, +struct v4l2_subdev_pad_config *cfg) +{ +struct v4l2_mbus_framefmt *mf_try; +struct v4l2_subdev_format format; +unsigned int pad; +int ret; + +for (pad =0 ; pad < sd->entity.num_pads; pad++) { +memset (&format,0 ,sizeof (format)); + + format.pad = pad; + format.which =V4L2_SUBDEV_FORMAT_ACTIVE ; + ret =v4l2_subdev_call (sd, pad, get_fmt,NULL , &format); +if (ret) +continue ; + + mf_try =v4l2_subdev_get_try_format (sd, cfg, pad); + *mf_try = format.format; + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (imx_media_init_cfg); + +/* * Check whether the field and colorimetry parameters in tryfmt are * uninitialized, and if so fill them with the values from fmt, * or if tryfmt->colorspace has been initialized, all the default
drivers/staging/media/imx/imx-media-vdic.c +1 -0
@@ -909,6 +909,7 @@ static void vdic_unregistered(struct v4l2_subdev *sd) }static const struct v4l2_subdev_pad_ops vdic_pad_ops = { + .init_cfg = imx_media_init_cfg, .enum_mbus_code = vdic_enum_mbus_code, .get_fmt = vdic_get_fmt, .set_fmt = vdic_set_fmt,
drivers/staging/media/imx/imx-media.h +2 -0
@@ -172,6 +172,8 @@ int imx_media_enum_ipu_format(u32 *code, u32 index, enum codespace_sel cs_sel);int imx_media_init_mbus_fmt (struct v4l2_mbus_framefmt *mbus,u32 width,u32 height,u32 code,u32 field,const struct imx_media_pixfmt **cc); +int imx_media_init_cfg (struct v4l2_subdev *sd, +struct v4l2_subdev_pad_config *cfg);void imx_media_fill_default_mbus_fields (struct v4l2_mbus_framefmt *tryfmt,struct v4l2_mbus_framefmt *fmt,bool ic_route);
drivers/staging/media/imx/imx6-mipi-csi2.c +1 -0
@@ -531,6 +531,7 @@ static const struct v4l2_subdev_video_ops csi2_video_ops = { };static const struct v4l2_subdev_pad_ops csi2_pad_ops = { + .init_cfg = imx_media_init_cfg, .get_fmt = csi2_get_fmt, .set_fmt = csi2_set_fmt, };
Signature · 1 line
2.7.4
Quoted 127 lines · Steve Longerbeam
Implement the
init_cfgpad op in all imx-media subdevices. The try formats are initialized to the current active formats on all pads.Signed-off-by Steve Longerbeam <[email protected]>---
Changes since v1:
- It isn't necessary to acquire the subdev locks in theinit_cfgpad op, the op only writes thetry_fmtin cfg, and cfg is private to every open subdev fh. Without the need for the lock,init_cfgcan be made generic. So this version moves the op toimx-media-utils.cfor all subdevs to call. It initializes try_fmt's to the current active formats.drivers/staging/media/imx/imx-ic-prp.c | 1 + drivers/staging/media/imx/imx-ic-prpencvf.c | 1 + drivers/staging/media/imx/imx-media-csi.c | 1 + drivers/staging/media/imx/imx-media-utils.c | 29 +++++++++++++++++++++++++++++ drivers/staging/media/imx/imx-media-vdic.c | 1 + drivers/staging/media/imx/imx-media.h | 2 ++ drivers/staging/media/imx/imx6-mipi-csi2.c | 1 + 7 files changed, 36 insertions(+)drivers/staging/media/imx/imx-ic-prp.c +1
-0@@ -462,6 +462,7 @@ static int prp_registered(struct v4l2_subdev *sd) }static const struct v4l2_subdev_pad_ops prp_pad_ops = { + .init_cfg = imx_media_init_cfg, .enum_mbus_code = prp_enum_mbus_code, .get_fmt = prp_get_fmt, .set_fmt = prp_set_fmt,drivers/staging/media/imx/imx-ic-prpencvf.c +1
-0@@ -1253,6 +1253,7 @@ static void prp_unregistered(struct v4l2_subdev *sd) }static const struct v4l2_subdev_pad_ops prp_pad_ops = { + .init_cfg = imx_media_init_cfg, .enum_mbus_code = prp_enum_mbus_code, .enum_frame_size = prp_enum_frame_size, .get_fmt = prp_get_fmt,drivers/staging/media/imx/imx-media-csi.c +1
-0@@ -1715,6 +1715,7 @@ static const struct v4l2_subdev_video_ops csi_video_ops = { };static const struct v4l2_subdev_pad_ops csi_pad_ops = { + .init_cfg = imx_media_init_cfg, .enum_mbus_code = csi_enum_mbus_code, .enum_frame_size = csi_enum_frame_size, .enum_frame_interval = csi_enum_frame_interval,drivers/staging/media/imx/imx-media-utils.c +29
-0@@ -465,6 +465,35 @@ int imx_media_init_mbus_fmt(struct v4l2_mbus_framefmt *mbus,EXPORT_SYMBOL_GPL (imx_media_init_mbus_fmt);/* +* Initializes the TRY format to the ACTIVE format on all pads +* of a subdev. Can be used as the .init_cfg pad operation. +*/ +int imx_media_init_cfg (struct v4l2_subdev *sd, +struct v4l2_subdev_pad_config *cfg) +{ +struct v4l2_mbus_framefmt *mf_try; +struct v4l2_subdev_format format; +unsigned int pad; +int ret; + +for (pad =0 ; pad < sd->entity.num_pads; pad++) { +memset (&format,0 ,sizeof (format)); + + format.pad = pad; + format.which =V4L2_SUBDEV_FORMAT_ACTIVE ; + ret =v4l2_subdev_call (sd, pad, get_fmt,NULL , &format); +if (ret) +continue ; + + mf_try =v4l2_subdev_get_try_format (sd, cfg, pad); + *mf_try = format.format; + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (imx_media_init_cfg); + +/* * Check whether the field and colorimetry parameters in tryfmt are * uninitialized, and if so fill them with the values from fmt, * or if tryfmt->colorspace has been initialized, all the default drivers/staging/media/imx/imx-media-vdic.c +1
-0@@ -909,6 +909,7 @@ static void vdic_unregistered(struct v4l2_subdev *sd) }static const struct v4l2_subdev_pad_ops vdic_pad_ops = { + .init_cfg = imx_media_init_cfg, .enum_mbus_code = vdic_enum_mbus_code, .get_fmt = vdic_get_fmt, .set_fmt = vdic_set_fmt,drivers/staging/media/imx/imx-media.h +2
-0@@ -172,6 +172,8 @@ int imx_media_enum_ipu_format(u32 *code, u32 index, enum codespace_sel cs_sel);int imx_media_init_mbus_fmt (struct v4l2_mbus_framefmt *mbus,u32 width,u32 height,u32 code,u32 field,const struct imx_media_pixfmt **cc); +int imx_media_init_cfg (struct v4l2_subdev *sd, +struct v4l2_subdev_pad_config *cfg);void imx_media_fill_default_mbus_fields (struct v4l2_mbus_framefmt *tryfmt,struct v4l2_mbus_framefmt *fmt,bool ic_route);drivers/staging/media/imx/imx6-mipi-csi2.c +0
-0
drivers/staging/media/imx/imx6-mipi-csi2.c static const struct v4l2_subdev_video_ops csi2_video_ops = { · line 537
Quoted 7 lines
drivers/staging/media/imx/imx6-mipi-csi2.c +1
-0@@ -531,6 +531,7 @@ static const struct v4l2_subdev_video_ops csi2_video_ops = { };static const struct v4l2_subdev_pad_ops csi2_pad_ops = { + .init_cfg = imx_media_init_cfg, .get_fmt = csi2_get_fmt, .set_fmt = csi2_set_fmt, };
regards
Philipp