media: staging: media: imx: imx7-media-csi: Don't populate vdev lists

The imx_media_dev framework maintains a per-pad list of connected video
devices, created once all subdevs have been bound. This is used for two
purposes, updating V4L2 control inheritance when links change, and
relaying subdev events to video nodes. None of these are used by the
imx7-media-csi driver as it implements the MC-centric approach. Drop
them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
This commit is contained in:
Laurent Pinchart 2022-02-06 05:13:53 +00:00 committed by Mauro Carvalho Chehab
parent f9806bd2b4
commit 46332d14eb

View file

@ -717,151 +717,6 @@ static irqreturn_t imx7_csi_irq_handler(int irq, void *data)
return IRQ_HANDLED;
}
/* -----------------------------------------------------------------------------
* Temporary copy of imx_media_dev helpers
*/
/*
* adds given video device to given imx-media source pad vdev list.
* Continues upstream from the pad entity's sink pads.
*/
static int imx_media_add_vdev_to_pad(struct imx_media_dev *imxmd,
struct imx_media_video_dev *vdev,
struct media_pad *srcpad)
{
struct media_entity *entity = srcpad->entity;
struct imx_media_pad_vdev *pad_vdev;
struct list_head *pad_vdev_list;
struct media_link *link;
struct v4l2_subdev *sd;
int i, ret;
/* skip this entity if not a v4l2_subdev */
if (!is_media_entity_v4l2_subdev(entity))
return 0;
sd = media_entity_to_v4l2_subdev(entity);
pad_vdev_list = to_pad_vdev_list(sd, srcpad->index);
if (!pad_vdev_list) {
v4l2_warn(&imxmd->v4l2_dev, "%s:%u has no vdev list!\n",
entity->name, srcpad->index);
/*
* shouldn't happen, but no reason to fail driver load,
* just skip this entity.
*/
return 0;
}
/* just return if we've been here before */
list_for_each_entry(pad_vdev, pad_vdev_list, list) {
if (pad_vdev->vdev == vdev)
return 0;
}
dev_dbg(imxmd->md.dev, "adding %s to pad %s:%u\n",
vdev->vfd->entity.name, entity->name, srcpad->index);
pad_vdev = devm_kzalloc(imxmd->md.dev, sizeof(*pad_vdev), GFP_KERNEL);
if (!pad_vdev)
return -ENOMEM;
/* attach this vdev to this pad */
pad_vdev->vdev = vdev;
list_add_tail(&pad_vdev->list, pad_vdev_list);
/* move upstream from this entity's sink pads */
for (i = 0; i < entity->num_pads; i++) {
struct media_pad *pad = &entity->pads[i];
if (!(pad->flags & MEDIA_PAD_FL_SINK))
continue;
list_for_each_entry(link, &entity->links, list) {
if (link->sink != pad)
continue;
ret = imx_media_add_vdev_to_pad(imxmd, vdev,
link->source);
if (ret)
return ret;
}
}
return 0;
}
/*
* For every subdevice, allocate an array of list_head's, one list_head
* for each pad, to hold the list of video devices reachable from that
* pad.
*/
static int imx_media_alloc_pad_vdev_lists(struct imx_media_dev *imxmd)
{
struct list_head *vdev_lists;
struct media_entity *entity;
struct v4l2_subdev *sd;
int i;
list_for_each_entry(sd, &imxmd->v4l2_dev.subdevs, list) {
entity = &sd->entity;
vdev_lists = devm_kcalloc(imxmd->md.dev,
entity->num_pads, sizeof(*vdev_lists),
GFP_KERNEL);
if (!vdev_lists)
return -ENOMEM;
/* attach to the subdev's host private pointer */
sd->host_priv = vdev_lists;
for (i = 0; i < entity->num_pads; i++)
INIT_LIST_HEAD(to_pad_vdev_list(sd, i));
}
return 0;
}
/* form the vdev lists in all imx-media source pads */
static int imx_media_create_pad_vdev_lists(struct imx_media_dev *imxmd)
{
struct imx_media_video_dev *vdev;
struct media_link *link;
int ret;
ret = imx_media_alloc_pad_vdev_lists(imxmd);
if (ret)
return ret;
list_for_each_entry(vdev, &imxmd->vdev_list, list) {
link = list_first_entry(&vdev->vfd->entity.links,
struct media_link, list);
ret = imx_media_add_vdev_to_pad(imxmd, vdev, link->source);
if (ret)
return ret;
}
return 0;
}
/* async subdev complete notifier */
static int __imx_media_probe_complete(struct imx_media_dev *imxmd)
{
int ret;
mutex_lock(&imxmd->mutex);
ret = imx_media_create_pad_vdev_lists(imxmd);
if (ret)
goto unlock;
ret = v4l2_device_register_subdev_nodes(&imxmd->v4l2_dev);
unlock:
mutex_unlock(&imxmd->mutex);
if (ret)
return ret;
return media_device_register(&imxmd->md);
}
/* -----------------------------------------------------------------------------
* V4L2 Subdev Operations
*/
@ -1214,12 +1069,24 @@ static int imx7_csi_registered(struct v4l2_subdev *sd)
ret = imx_media_capture_device_register(csi->vdev,
MEDIA_LNK_FL_IMMUTABLE);
if (ret) {
imx_media_capture_device_remove(csi->vdev);
return ret;
}
if (ret)
goto err_remove;
return __imx_media_probe_complete(csi->imxmd);
ret = v4l2_device_register_subdev_nodes(&csi->imxmd->v4l2_dev);
if (ret)
goto err_unreg;
ret = media_device_register(&csi->imxmd->md);
if (ret)
goto err_unreg;
return 0;
err_unreg:
imx_media_capture_device_unregister(csi->vdev);
err_remove:
imx_media_capture_device_remove(csi->vdev);
return ret;
}
static void imx7_csi_unregistered(struct v4l2_subdev *sd)