Skip to content

Commit 256b776

Browse files
Sakari AilusHans Verkuil
authored andcommitted
media: ccs: Rework initialising sub-device state
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: d8bca3e ("media: ccs: Use sub-device active state") Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
1 parent ab75641 commit 256b776

1 file changed

Lines changed: 28 additions & 17 deletions

File tree

drivers/media/i2c/ccs/ccs-core.c

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2075,6 +2075,7 @@ static void ccs_propagate(struct v4l2_subdev *subdev,
20752075
struct ccs_sensor *sensor = to_ccs_sensor(subdev);
20762076
struct ccs_subdev *ssd = to_ccs_subdev(subdev);
20772077
struct v4l2_rect *comp, *crops[CCS_PADS];
2078+
struct v4l2_mbus_framefmt *fmt;
20782079

20792080
ccs_get_crop_compose(subdev, sd_state, crops, &comp);
20802081

@@ -2096,6 +2097,9 @@ static void ccs_propagate(struct v4l2_subdev *subdev,
20962097
fallthrough;
20972098
case V4L2_SEL_TGT_COMPOSE:
20982099
*crops[CCS_PAD_SRC] = *comp;
2100+
fmt = v4l2_subdev_get_pad_format(subdev, sd_state, CCS_PAD_SRC);
2101+
fmt->width = comp->width;
2102+
fmt->height = comp->height;
20992103
if (which == V4L2_SUBDEV_FORMAT_ACTIVE && ssd == sensor->src)
21002104
sensor->src_src = *crops[CCS_PAD_SRC];
21012105
break;
@@ -3003,31 +3007,38 @@ static int ccs_init_cfg(struct v4l2_subdev *sd,
30033007
{
30043008
struct ccs_subdev *ssd = to_ccs_subdev(sd);
30053009
struct ccs_sensor *sensor = ssd->sensor;
3006-
unsigned int i;
3010+
unsigned int pad = ssd == sensor->pixel_array ?
3011+
CCS_PA_PAD_SRC : CCS_PAD_SINK;
3012+
struct v4l2_mbus_framefmt *fmt =
3013+
v4l2_subdev_get_pad_format(sd, sd_state, pad);
3014+
struct v4l2_rect *crop =
3015+
v4l2_subdev_get_pad_crop(sd, sd_state, pad);
3016+
bool is_active = !sd->active_state || sd->active_state == sd_state;
30073017

30083018
mutex_lock(&sensor->mutex);
30093019

3010-
for (i = 0; i < ssd->npads; i++) {
3011-
struct v4l2_mbus_framefmt *fmt =
3012-
v4l2_subdev_get_pad_format(sd, sd_state, i);
3013-
struct v4l2_rect *crop =
3014-
v4l2_subdev_get_pad_crop(sd, sd_state, i);
3015-
struct v4l2_rect *comp;
3016-
3017-
ccs_get_native_size(ssd, crop);
3020+
ccs_get_native_size(ssd, crop);
30183021

3019-
fmt->width = crop->width;
3020-
fmt->height = crop->height;
3021-
fmt->code = sensor->internal_csi_format->code;
3022-
fmt->field = V4L2_FIELD_NONE;
3022+
fmt->width = crop->width;
3023+
fmt->height = crop->height;
3024+
fmt->code = sensor->internal_csi_format->code;
3025+
fmt->field = V4L2_FIELD_NONE;
30233026

3024-
if (ssd == sensor->pixel_array)
3025-
continue;
3027+
if (ssd == sensor->pixel_array) {
3028+
if (is_active)
3029+
sensor->pa_src = *crop;
30263030

3027-
comp = v4l2_subdev_get_pad_compose(sd, sd_state, i);
3028-
*comp = *crop;
3031+
mutex_unlock(&sensor->mutex);
3032+
return 0;
30293033
}
30303034

3035+
fmt = v4l2_subdev_get_pad_format(sd, sd_state, CCS_PAD_SRC);
3036+
fmt->code = ssd == sensor->src ?
3037+
sensor->csi_format->code : sensor->internal_csi_format->code;
3038+
fmt->field = V4L2_FIELD_NONE;
3039+
3040+
ccs_propagate(sd, sd_state, is_active, V4L2_SEL_TGT_CROP);
3041+
30313042
mutex_unlock(&sensor->mutex);
30323043

30333044
return 0;

0 commit comments

Comments
 (0)