From 0b3226fc8f3cab5efb8a47bd17f5d7bd3ed609d1 Mon Sep 17 00:00:00 2001 From: mcc45tr Date: Wed, 2 Sep 2026 14:29:36 +0300 Subject: [PATCH 73/73] media: qcom: expose CAMSS sensors as each one binds --- drivers/media/platform/qcom/camss/camss.c | 63 +++++++++++------------ 1 file changed, 29 insertions(+), 34 deletions(-) diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c index a83aa915daf7..73d4304aba14 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -5419,49 +5419,44 @@ static int camss_subdev_notifier_bound(struct v4l2_async_notifier *async, container_of(asd, struct camss_async_subdev, asd); u8 id = csd->interface.csiphy_id; struct csiphy_device *csiphy = &camss->csiphy[id]; + struct media_entity *sensor = &subdev->entity; + unsigned int i; + int ret; csiphy->cfg.csi2 = &csd->interface.csi2; subdev->host_priv = csiphy; - return 0; + /* + * Link each sensor as soon as it binds. Waiting for notifier completion + * makes every working camera disappear when another optional sensor is + * absent or fails its chip-ID probe. + */ + for (i = 0; i < sensor->num_pads; i++) { + if (sensor->pads[i].flags & MEDIA_PAD_FL_SOURCE) + break; + } + if (i == sensor->num_pads) { + dev_err(camss->dev, "No source pad in external entity\n"); + return -EINVAL; + } + + ret = media_create_pad_link(sensor, i, &csiphy->subdev.entity, + MSM_CSIPHY_PAD_SINK, + MEDIA_LNK_FL_IMMUTABLE | + MEDIA_LNK_FL_ENABLED); + if (ret < 0) { + camss_link_err(camss, sensor->name, + csiphy->subdev.entity.name, ret); + return ret; + } + + /* The helper is idempotent and skips subdevices with an existing node. */ + return v4l2_device_register_subdev_nodes(&camss->v4l2_dev); } static int camss_subdev_notifier_complete(struct v4l2_async_notifier *async) { struct camss *camss = container_of(async, struct camss, notifier); - struct v4l2_device *v4l2_dev = &camss->v4l2_dev; - struct v4l2_subdev *sd; - - list_for_each_entry(sd, &v4l2_dev->subdevs, list) { - struct csiphy_device *csiphy = sd->host_priv; - struct media_entity *input, *sensor; - unsigned int i; - int ret; - - if (!csiphy) - continue; - - input = &csiphy->subdev.entity; - sensor = &sd->entity; - - for (i = 0; i < sensor->num_pads; i++) { - if (sensor->pads[i].flags & MEDIA_PAD_FL_SOURCE) - break; - } - if (i == sensor->num_pads) { - dev_err(camss->dev, - "No source pad in external entity\n"); - return -EINVAL; - } - - ret = media_create_pad_link(sensor, i, input, - MSM_CSIPHY_PAD_SINK, - MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED); - if (ret < 0) { - camss_link_err(camss, sensor->name, input->name, ret); - return ret; - } - } return v4l2_device_register_subdev_nodes(&camss->v4l2_dev); } -- 2.55.0