Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: d8bca3ed1d70 ("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>

authored by

Sakari Ailus and committed by
Hans Verkuil
256b7767 ab75641f

+28 -17
+28 -17
drivers/media/i2c/ccs/ccs-core.c
··· 2075 2075 struct ccs_sensor *sensor = to_ccs_sensor(subdev); 2076 2076 struct ccs_subdev *ssd = to_ccs_subdev(subdev); 2077 2077 struct v4l2_rect *comp, *crops[CCS_PADS]; 2078 + struct v4l2_mbus_framefmt *fmt; 2078 2079 2079 2080 ccs_get_crop_compose(subdev, sd_state, crops, &comp); 2080 2081 ··· 2097 2096 fallthrough; 2098 2097 case V4L2_SEL_TGT_COMPOSE: 2099 2098 *crops[CCS_PAD_SRC] = *comp; 2099 + fmt = v4l2_subdev_get_pad_format(subdev, sd_state, CCS_PAD_SRC); 2100 + fmt->width = comp->width; 2101 + fmt->height = comp->height; 2100 2102 if (which == V4L2_SUBDEV_FORMAT_ACTIVE && ssd == sensor->src) 2101 2103 sensor->src_src = *crops[CCS_PAD_SRC]; 2102 2104 break; ··· 3007 3003 { 3008 3004 struct ccs_subdev *ssd = to_ccs_subdev(sd); 3009 3005 struct ccs_sensor *sensor = ssd->sensor; 3010 - unsigned int i; 3006 + unsigned int pad = ssd == sensor->pixel_array ? 3007 + CCS_PA_PAD_SRC : CCS_PAD_SINK; 3008 + struct v4l2_mbus_framefmt *fmt = 3009 + v4l2_subdev_get_pad_format(sd, sd_state, pad); 3010 + struct v4l2_rect *crop = 3011 + v4l2_subdev_get_pad_crop(sd, sd_state, pad); 3012 + bool is_active = !sd->active_state || sd->active_state == sd_state; 3011 3013 3012 3014 mutex_lock(&sensor->mutex); 3013 3015 3014 - for (i = 0; i < ssd->npads; i++) { 3015 - struct v4l2_mbus_framefmt *fmt = 3016 - v4l2_subdev_get_pad_format(sd, sd_state, i); 3017 - struct v4l2_rect *crop = 3018 - v4l2_subdev_get_pad_crop(sd, sd_state, i); 3019 - struct v4l2_rect *comp; 3016 + ccs_get_native_size(ssd, crop); 3020 3017 3021 - ccs_get_native_size(ssd, crop); 3018 + fmt->width = crop->width; 3019 + fmt->height = crop->height; 3020 + fmt->code = sensor->internal_csi_format->code; 3021 + fmt->field = V4L2_FIELD_NONE; 3022 3022 3023 - fmt->width = crop->width; 3024 - fmt->height = crop->height; 3025 - fmt->code = sensor->internal_csi_format->code; 3026 - fmt->field = V4L2_FIELD_NONE; 3023 + if (ssd == sensor->pixel_array) { 3024 + if (is_active) 3025 + sensor->pa_src = *crop; 3027 3026 3028 - if (ssd == sensor->pixel_array) 3029 - continue; 3030 - 3031 - comp = v4l2_subdev_get_pad_compose(sd, sd_state, i); 3032 - *comp = *crop; 3027 + mutex_unlock(&sensor->mutex); 3028 + return 0; 3033 3029 } 3030 + 3031 + fmt = v4l2_subdev_get_pad_format(sd, sd_state, CCS_PAD_SRC); 3032 + fmt->code = ssd == sensor->src ? 3033 + sensor->csi_format->code : sensor->internal_csi_format->code; 3034 + fmt->field = V4L2_FIELD_NONE; 3035 + 3036 + ccs_propagate(sd, sd_state, is_active, V4L2_SEL_TGT_CROP); 3034 3037 3035 3038 mutex_unlock(&sensor->mutex); 3036 3039