Commit 49e1b5d6 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab

media: imx: capture: Add a mechanism to disable control inheritance

Add a parameter to the imx_media_capture_device_init() function to
select between the legacy and MC-centric API. When selecting the
MC-centric API, the video node doesn't inherit controls from subdevs
anymore. All callers are updated to use the legacy API for now,
preserving the existing behaviour.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: default avatarRui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 3a854824
......@@ -1265,7 +1265,7 @@ static int prp_registered(struct v4l2_subdev *sd)
priv->vdev = imx_media_capture_device_init(ic_priv->ipu_dev,
&ic_priv->sd,
PRPENCVF_SRC_PAD);
PRPENCVF_SRC_PAD, true);
if (IS_ERR(priv->vdev))
return PTR_ERR(priv->vdev);
......
......@@ -45,6 +45,8 @@ struct capture_priv {
spinlock_t q_lock; /* Protect ready_q */
struct v4l2_ctrl_handler ctrl_hdlr; /* Controls inherited from subdevs */
bool legacy_api; /* Use the legacy (pre-MC) API */
};
#define to_capture_priv(v) container_of(v, struct capture_priv, vdev)
......@@ -800,7 +802,7 @@ EXPORT_SYMBOL_GPL(imx_media_capture_device_unregister);
struct imx_media_video_dev *
imx_media_capture_device_init(struct device *dev, struct v4l2_subdev *src_sd,
int pad)
int pad, bool legacy_api)
{
struct capture_priv *priv;
struct video_device *vfd;
......@@ -814,6 +816,7 @@ imx_media_capture_device_init(struct device *dev, struct v4l2_subdev *src_sd,
priv->src_sd = src_sd;
priv->src_sd_pad = pad;
priv->dev = dev;
priv->legacy_api = legacy_api;
mutex_init(&priv->mutex);
INIT_LIST_HEAD(&priv->ready_q);
......@@ -868,9 +871,11 @@ imx_media_capture_device_init(struct device *dev, struct v4l2_subdev *src_sd,
return ERR_PTR(ret);
}
/* Initialize the control handler. */
v4l2_ctrl_handler_init(&priv->ctrl_hdlr, 0);
vfd->ctrl_handler = &priv->ctrl_hdlr;
if (legacy_api) {
/* Initialize the control handler. */
v4l2_ctrl_handler_init(&priv->ctrl_hdlr, 0);
vfd->ctrl_handler = &priv->ctrl_hdlr;
}
return &priv->vdev;
}
......
......@@ -1781,9 +1781,8 @@ static int csi_registered(struct v4l2_subdev *sd)
goto put_csi;
}
priv->vdev = imx_media_capture_device_init(priv->sd.dev,
&priv->sd,
CSI_SRC_PAD_IDMAC);
priv->vdev = imx_media_capture_device_init(priv->sd.dev, &priv->sd,
CSI_SRC_PAD_IDMAC, true);
if (IS_ERR(priv->vdev)) {
ret = PTR_ERR(priv->vdev);
goto free_fim;
......
......@@ -287,6 +287,8 @@ static int imx_media_link_notify(struct media_link *link, u32 flags,
!(flags & MEDIA_LNK_FL_ENABLED)) {
list_for_each_entry(pad_vdev, pad_vdev_list, list) {
vfd = pad_vdev->vdev->vfd;
if (!vfd->ctrl_handler)
continue;
dev_dbg(imxmd->md.dev,
"reset controls for %s\n",
vfd->entity.name);
......@@ -297,6 +299,8 @@ static int imx_media_link_notify(struct media_link *link, u32 flags,
(link->flags & MEDIA_LNK_FL_ENABLED)) {
list_for_each_entry(pad_vdev, pad_vdev_list, list) {
vfd = pad_vdev->vdev->vfd;
if (!vfd->ctrl_handler)
continue;
dev_dbg(imxmd->md.dev,
"refresh controls for %s\n",
vfd->entity.name);
......
......@@ -286,7 +286,7 @@ int imx_media_ic_unregister(struct v4l2_subdev *sd);
/* imx-media-capture.c */
struct imx_media_video_dev *
imx_media_capture_device_init(struct device *dev, struct v4l2_subdev *src_sd,
int pad);
int pad, bool legacy_api);
void imx_media_capture_device_remove(struct imx_media_video_dev *vdev);
int imx_media_capture_device_register(struct imx_media_video_dev *vdev);
void imx_media_capture_device_unregister(struct imx_media_video_dev *vdev);
......
......@@ -1100,7 +1100,7 @@ static int imx7_csi_registered(struct v4l2_subdev *sd)
}
csi->vdev = imx_media_capture_device_init(csi->sd.dev, &csi->sd,
IMX7_CSI_PAD_SRC);
IMX7_CSI_PAD_SRC, true);
if (IS_ERR(csi->vdev))
return PTR_ERR(csi->vdev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment