This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: ccs: Rework initialising sub-device state
Author:  Sakari Ailus <sakari.ai...@linux.intel.com>
Date:    Mon Oct 9 09:40:11 2023 +0300

Initialise sub-device state in init_cfg callback using ccs_propagate() to
the extent it covers of the initialisation. This fixes a bug where the
driver configuration was incorrectly initialised.

Fixes: d8bca3ed1d70 ("media: ccs: Use sub-device active state")
Signed-off-by: Sakari Ailus <sakari.ai...@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-ci...@xs4all.nl>

 drivers/media/i2c/ccs/ccs-core.c | 45 +++++++++++++++++++++++++---------------
 1 file changed, 28 insertions(+), 17 deletions(-)

---

diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c
index 2abfd5932e02..14e89ae98294 100644
--- a/drivers/media/i2c/ccs/ccs-core.c
+++ b/drivers/media/i2c/ccs/ccs-core.c
@@ -2075,6 +2075,7 @@ static void ccs_propagate(struct v4l2_subdev *subdev,
        struct ccs_sensor *sensor = to_ccs_sensor(subdev);
        struct ccs_subdev *ssd = to_ccs_subdev(subdev);
        struct v4l2_rect *comp, *crops[CCS_PADS];
+       struct v4l2_mbus_framefmt *fmt;
 
        ccs_get_crop_compose(subdev, sd_state, crops, &comp);
 
@@ -2096,6 +2097,9 @@ static void ccs_propagate(struct v4l2_subdev *subdev,
                fallthrough;
        case V4L2_SEL_TGT_COMPOSE:
                *crops[CCS_PAD_SRC] = *comp;
+               fmt = v4l2_subdev_get_pad_format(subdev, sd_state, CCS_PAD_SRC);
+               fmt->width = comp->width;
+               fmt->height = comp->height;
                if (which == V4L2_SUBDEV_FORMAT_ACTIVE && ssd == sensor->src)
                        sensor->src_src = *crops[CCS_PAD_SRC];
                break;
@@ -3003,31 +3007,38 @@ static int ccs_init_cfg(struct v4l2_subdev *sd,
 {
        struct ccs_subdev *ssd = to_ccs_subdev(sd);
        struct ccs_sensor *sensor = ssd->sensor;
-       unsigned int i;
+       unsigned int pad = ssd == sensor->pixel_array ?
+               CCS_PA_PAD_SRC : CCS_PAD_SINK;
+       struct v4l2_mbus_framefmt *fmt =
+               v4l2_subdev_get_pad_format(sd, sd_state, pad);
+       struct v4l2_rect *crop =
+               v4l2_subdev_get_pad_crop(sd, sd_state, pad);
+       bool is_active = !sd->active_state || sd->active_state == sd_state;
 
        mutex_lock(&sensor->mutex);
 
-       for (i = 0; i < ssd->npads; i++) {
-               struct v4l2_mbus_framefmt *fmt =
-                       v4l2_subdev_get_pad_format(sd, sd_state, i);
-               struct v4l2_rect *crop =
-                       v4l2_subdev_get_pad_crop(sd, sd_state, i);
-               struct v4l2_rect *comp;
-
-               ccs_get_native_size(ssd, crop);
+       ccs_get_native_size(ssd, crop);
 
-               fmt->width = crop->width;
-               fmt->height = crop->height;
-               fmt->code = sensor->internal_csi_format->code;
-               fmt->field = V4L2_FIELD_NONE;
+       fmt->width = crop->width;
+       fmt->height = crop->height;
+       fmt->code = sensor->internal_csi_format->code;
+       fmt->field = V4L2_FIELD_NONE;
 
-               if (ssd == sensor->pixel_array)
-                       continue;
+       if (ssd == sensor->pixel_array) {
+               if (is_active)
+                       sensor->pa_src = *crop;
 
-               comp = v4l2_subdev_get_pad_compose(sd, sd_state, i);
-               *comp = *crop;
+               mutex_unlock(&sensor->mutex);
+               return 0;
        }
 
+       fmt = v4l2_subdev_get_pad_format(sd, sd_state, CCS_PAD_SRC);
+       fmt->code = ssd == sensor->src ?
+               sensor->csi_format->code : sensor->internal_csi_format->code;
+       fmt->field = V4L2_FIELD_NONE;
+
+       ccs_propagate(sd, sd_state, is_active, V4L2_SEL_TGT_CROP);
+
        mutex_unlock(&sensor->mutex);
 
        return 0;

_______________________________________________
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to