[media] v4l: subdev: Add pad config allocator and init
Add a new subdev operation to initialize a subdev pad config array, and a helper function to allocate and initialize the array. This can be used by bridge drivers to implement try format based on subdev pad operations. Signed-off-by: Laurent Pinchart <laurent.pinchart@linaro.org> Acked-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
This commit is contained in:
parent
45b46879a7
commit
9b02cbb3ed
|
@ -35,9 +35,11 @@
|
||||||
static int subdev_fh_init(struct v4l2_subdev_fh *fh, struct v4l2_subdev *sd)
|
static int subdev_fh_init(struct v4l2_subdev_fh *fh, struct v4l2_subdev *sd)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
|
#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
|
||||||
fh->pad = kzalloc(sizeof(*fh->pad) * sd->entity.num_pads, GFP_KERNEL);
|
if (sd->entity.num_pads) {
|
||||||
|
fh->pad = v4l2_subdev_alloc_pad_config(sd);
|
||||||
if (fh->pad == NULL)
|
if (fh->pad == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +47,7 @@ static int subdev_fh_init(struct v4l2_subdev_fh *fh, struct v4l2_subdev *sd)
|
||||||
static void subdev_fh_free(struct v4l2_subdev_fh *fh)
|
static void subdev_fh_free(struct v4l2_subdev_fh *fh)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
|
#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
|
||||||
kfree(fh->pad);
|
v4l2_subdev_free_pad_config(fh->pad);
|
||||||
fh->pad = NULL;
|
fh->pad = NULL;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -569,6 +571,35 @@ int v4l2_subdev_link_validate(struct media_link *link)
|
||||||
sink, link, &source_fmt, &sink_fmt);
|
sink, link, &source_fmt, &sink_fmt);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(v4l2_subdev_link_validate);
|
EXPORT_SYMBOL_GPL(v4l2_subdev_link_validate);
|
||||||
|
|
||||||
|
struct v4l2_subdev_pad_config *
|
||||||
|
v4l2_subdev_alloc_pad_config(struct v4l2_subdev *sd)
|
||||||
|
{
|
||||||
|
struct v4l2_subdev_pad_config *cfg;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (!sd->entity.num_pads)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
cfg = kcalloc(sd->entity.num_pads, sizeof(*cfg), GFP_KERNEL);
|
||||||
|
if (!cfg)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
ret = v4l2_subdev_call(sd, pad, init_cfg, cfg);
|
||||||
|
if (ret < 0 && ret != -ENOIOCTLCMD) {
|
||||||
|
kfree(cfg);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return cfg;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(v4l2_subdev_alloc_pad_config);
|
||||||
|
|
||||||
|
void v4l2_subdev_free_pad_config(struct v4l2_subdev_pad_config *cfg)
|
||||||
|
{
|
||||||
|
kfree(cfg);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(v4l2_subdev_free_pad_config);
|
||||||
#endif /* CONFIG_MEDIA_CONTROLLER */
|
#endif /* CONFIG_MEDIA_CONTROLLER */
|
||||||
|
|
||||||
void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops)
|
void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops)
|
||||||
|
|
|
@ -572,6 +572,7 @@ struct v4l2_subdev_pad_config {
|
||||||
/**
|
/**
|
||||||
* struct v4l2_subdev_pad_ops - v4l2-subdev pad level operations
|
* struct v4l2_subdev_pad_ops - v4l2-subdev pad level operations
|
||||||
*
|
*
|
||||||
|
* @init_cfg: initialize the pad config to default values
|
||||||
* @enum_mbus_code: callback for VIDIOC_SUBDEV_ENUM_MBUS_CODE ioctl handler
|
* @enum_mbus_code: callback for VIDIOC_SUBDEV_ENUM_MBUS_CODE ioctl handler
|
||||||
* code.
|
* code.
|
||||||
* @enum_frame_size: callback for VIDIOC_SUBDEV_ENUM_FRAME_SIZE ioctl handler
|
* @enum_frame_size: callback for VIDIOC_SUBDEV_ENUM_FRAME_SIZE ioctl handler
|
||||||
|
@ -607,6 +608,8 @@ struct v4l2_subdev_pad_config {
|
||||||
* may be adjusted by the subdev driver to device capabilities.
|
* may be adjusted by the subdev driver to device capabilities.
|
||||||
*/
|
*/
|
||||||
struct v4l2_subdev_pad_ops {
|
struct v4l2_subdev_pad_ops {
|
||||||
|
int (*init_cfg)(struct v4l2_subdev *sd,
|
||||||
|
struct v4l2_subdev_pad_config *cfg);
|
||||||
int (*enum_mbus_code)(struct v4l2_subdev *sd,
|
int (*enum_mbus_code)(struct v4l2_subdev *sd,
|
||||||
struct v4l2_subdev_pad_config *cfg,
|
struct v4l2_subdev_pad_config *cfg,
|
||||||
struct v4l2_subdev_mbus_code_enum *code);
|
struct v4l2_subdev_mbus_code_enum *code);
|
||||||
|
@ -801,7 +804,12 @@ int v4l2_subdev_link_validate_default(struct v4l2_subdev *sd,
|
||||||
struct v4l2_subdev_format *source_fmt,
|
struct v4l2_subdev_format *source_fmt,
|
||||||
struct v4l2_subdev_format *sink_fmt);
|
struct v4l2_subdev_format *sink_fmt);
|
||||||
int v4l2_subdev_link_validate(struct media_link *link);
|
int v4l2_subdev_link_validate(struct media_link *link);
|
||||||
|
|
||||||
|
struct v4l2_subdev_pad_config *
|
||||||
|
v4l2_subdev_alloc_pad_config(struct v4l2_subdev *sd);
|
||||||
|
void v4l2_subdev_free_pad_config(struct v4l2_subdev_pad_config *cfg);
|
||||||
#endif /* CONFIG_MEDIA_CONTROLLER */
|
#endif /* CONFIG_MEDIA_CONTROLLER */
|
||||||
|
|
||||||
void v4l2_subdev_init(struct v4l2_subdev *sd,
|
void v4l2_subdev_init(struct v4l2_subdev *sd,
|
||||||
const struct v4l2_subdev_ops *ops);
|
const struct v4l2_subdev_ops *ops);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue