Patches split off the metadata series
Subsystems (4)
Sakari Ailus
maintainerv2 cover Patches split off the metadata series
Hi all,
This small set of cleanups could be split off from the metadata series.
The comments to the patches earlier on in streams set version 9 and 11 have been taken into account.
since v1:
- Fix a false positive warning (all of GCC, sparse and smatch!).
- Add a patch to switch to guard()/scoped_guard().
Laurent Pinchart (1):
media: i2c: imx219: Inline imx219_update_pad_format() in its caller
Sakari Ailus (7):
media: ccs: Remove ccs_get_crop_compose helper
media: ccs: Rely on sub-device state locking
media: ccs: Switch to guard and scoped_guard
media: ccs: Compute binning configuration from sub-device state
media: ccs: Compute scaling configuration from sub-device state
media: ccs: Remove which parameter from ccs_propagate
media: ccs: Make supported mbus code bitmask a u64
drivers/media/i2c/ccs/ccs-core.c | 458 +++++++++++++++---------------- drivers/media/i2c/ccs/ccs.h | 11 +- drivers/media/i2c/imx219.c | 29 +- 3 files changed, 243 insertions(+), 255 deletions(-)
Signature · 1 line
2.47.3
Sakari Ailus
maintainerPATCH v2 1/8 media: ccs: Remove ccs_get_crop_compose helper
As it's now easier to obtain the necessary information on crop and compose rectangles after moving to sub-device state, remove the ccs_get_crop_compose helper.
Also remove the comp arguments of the compose goodness calculators and make related local variables and function arguments const where applicable.
--- drivers/media/i2c/ccs/ccs-core.c | 161 ++++++++++++++----------------- 1 file changed, 71 insertions(+), 90 deletions(-)
drivers/media/i2c/ccs/ccs-core.c +71 -90
@@ -2091,24 +2091,6 @@ static int ccs_get_format(struct v4l2_subdev *subdev,return rval; } -static void ccs_get_crop_compose (struct v4l2_subdev *subdev, -struct v4l2_subdev_state *sd_state, -struct v4l2_rect **crops, -struct v4l2_rect **comps) -{ -struct ccs_subdev *ssd =to_ccs_subdev (subdev); -unsigned int i; - -if (crops) -for (i =0 ; i < subdev->entity.num_pads; i++) - crops[i] = -v4l2_subdev_state_get_crop (sd_state, i, -CCS_STREAM_PIXEL ); -if (comps) - *comps =v4l2_subdev_state_get_compose (sd_state, ssd->sink_pad, -CCS_STREAM_PIXEL ); -} -/* Changes require propagation only on sink pad. */ static void ccs_propagate(struct v4l2_subdev *subdev, struct v4l2_subdev_state *sd_state, int which,
@@ -2116,15 +2098,17 @@ 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_rect *comp, *crop;struct v4l2_mbus_framefmt *fmt; -ccs_get_crop_compose (subdev, sd_state, crops, &comp); - + comp =v4l2_subdev_state_get_compose (sd_state, ssd->sink_pad, +CCS_STREAM_PIXEL );switch (target) {case V4L2_SEL_TGT_CROP : - comp->width = crops[CCS_PAD_SINK ]->width; - comp->height = crops[CCS_PAD_SINK ]->height; + crop =v4l2_subdev_state_get_crop (sd_state,CCS_PAD_SINK , +CCS_STREAM_PIXEL ); + comp->width = crop->width; + comp->height = crop->height;if (which ==V4L2_SUBDEV_FORMAT_ACTIVE ) {if (ssd == sensor->scaler) { sensor->scale_m =CCS_LIM (sensor,SCALER_N_MIN );
@@ -2138,13 +2122,15 @@ static void ccs_propagate(struct v4l2_subdev *subdev, } fallthrough;case V4L2_SEL_TGT_COMPOSE : - *crops[CCS_PAD_SRC ] = *comp; + crop =v4l2_subdev_state_get_crop (sd_state,CCS_PAD_SRC , +CCS_STREAM_PIXEL ); + *crop = *comp; fmt =v4l2_subdev_state_get_format (sd_state,CCS_PAD_SRC ,CCS_STREAM_PIXEL ); fmt->width = comp->width; fmt->height = comp->height;if (which ==V4L2_SUBDEV_FORMAT_ACTIVE && ssd == sensor->src) - sensor->src_src = *crops[CCS_PAD_SRC ]; + sensor->src_src = *crop;break ;default :WARN_ON_ONCE (1 );
@@ -2210,7 +2196,7 @@ static int ccs_set_format(struct v4l2_subdev *subdev, {struct ccs_sensor *sensor =to_ccs_sensor (subdev);struct ccs_subdev *ssd =to_ccs_subdev (subdev); -struct v4l2_rect *crops[CCS_PADS ]; +struct v4l2_rect *crop;mutex_lock (&sensor->mutex);
@@ -2239,12 +2225,13 @@ static int ccs_set_format(struct v4l2_subdev *subdev,CCS_LIM (sensor,MIN_Y_OUTPUT_SIZE ), CCS_LIM(sensor, MAX_Y_OUTPUT_SIZE)); -ccs_get_crop_compose (subdev, sd_state, crops,NULL ); + crop =v4l2_subdev_state_get_crop (sd_state, ssd->sink_pad, +CCS_STREAM_PIXEL ); - crops[ssd->sink_pad]->left =0 ; - crops[ssd->sink_pad]->top =0 ; - crops[ssd->sink_pad]->width = fmt->format.width; - crops[ssd->sink_pad]->height = fmt->format.height; + crop->left =0 ; + crop->top =0 ; + crop->width = fmt->format.width; + crop->height = fmt->format.height;ccs_propagate (subdev, sd_state, fmt->which,V4L2_SEL_TGT_CROP );mutex_unlock (&sensor->mutex);
@@ -2299,26 +2286,23 @@ static int scaling_goodness(struct v4l2_subdev *subdev, int w, int ask_w,static void ccs_set_compose_binner (struct v4l2_subdev *subdev,struct v4l2_subdev_state *sd_state,struct v4l2_subdev_selection *sel, -struct v4l2_rect **crops, -struct v4l2_rect *comp) +const struct v4l2_rect *sink_crop) {struct ccs_sensor *sensor =to_ccs_sensor (subdev);unsigned int i;unsigned int binh =1 , binv =1 ; -int best =scaling_goodness ( - subdev, - crops[CCS_PAD_SINK ]->width, sel->r.width, - crops[CCS_PAD_SINK ]->height, sel->r.height, sel->flags); +int best =scaling_goodness (subdev, sink_crop->width, sel->r.width, + sink_crop->height, sel->r.height, + sel->flags);for (i =0 ; i < sensor->nbinning_subtypes; i++) { -int this =scaling_goodness ( - subdev, - crops[CCS_PAD_SINK ]->width - / sensor->binning_subtypes[i].horizontal, - sel->r.width, - crops[CCS_PAD_SINK ]->height - / sensor->binning_subtypes[i].vertical, - sel->r.height, sel->flags); +int this =scaling_goodness (subdev, + sink_crop->width + / sensor->binning_subtypes[i].horizontal, + sel->r.width, + sink_crop->height + / sensor->binning_subtypes[i].vertical, + sel->r.height, sel->flags);if (this > best) { binh = sensor->binning_subtypes[i].horizontal;
@@ -2331,8 +2315,8 @@ static void ccs_set_compose_binner(struct v4l2_subdev *subdev, sensor->binning_horizontal = binh; } - sel->r.width = (crops[CCS_PAD_SINK ]->width / binh) & ~1 ; - sel->r.height = (crops[CCS_PAD_SINK ]->height / binv) & ~1 ; + sel->r.width = (sink_crop->width / binh) & ~1 ; + sel->r.height = (sink_crop->height / binv) & ~1 ; }/*
@@ -2347,8 +2331,7 @@ static void ccs_set_compose_binner(struct v4l2_subdev *subdev,static void ccs_set_compose_scaler (struct v4l2_subdev *subdev,struct v4l2_subdev_state *sd_state,struct v4l2_subdev_selection *sel, -struct v4l2_rect **crops, -struct v4l2_rect *comp) +const struct v4l2_rect *sink_crop) {struct i2c_client *client =v4l2_get_subdevdata (subdev);struct ccs_sensor *sensor =to_ccs_sensor (subdev);
@@ -2360,16 +2343,12 @@ static void ccs_set_compose_scaler(struct v4l2_subdev *subdev,unsigned int i;int best =INT_MIN ; - sel->r.width = min_t(unsigned int, sel->r.width, - crops[CCS_PAD_SINK ]->width); - sel->r.height = min_t(unsigned int, sel->r.height, - crops[CCS_PAD_SINK ]->height); + sel->r.width = min_t(unsigned int, sel->r.width, sink_crop->width); + sel->r.height = min_t(unsigned int, sel->r.height, sink_crop->height); - a = crops[CCS_PAD_SINK ]->width - *CCS_LIM (sensor,SCALER_N_MIN ) / sel->r.width; - b = crops[CCS_PAD_SINK ]->height - *CCS_LIM (sensor,SCALER_N_MIN ) / sel->r.height; - max_m = crops[CCS_PAD_SINK ]->width + a = sink_crop->width *CCS_LIM (sensor,SCALER_N_MIN ) / sel->r.width; + b = sink_crop->height *CCS_LIM (sensor,SCALER_N_MIN ) / sel->r.height; + max_m = sink_crop->width *CCS_LIM (sensor,SCALER_N_MIN ) / (CCS_LIM (sensor,MIN_X_OUTPUT_SIZE ) ?:1 );
@@ -2401,14 +2380,12 @@ static void ccs_set_compose_scaler(struct v4l2_subdev *subdev, }for (i =0 ; i < ntry; i++) { -int this =scaling_goodness ( - subdev, - crops[CCS_PAD_SINK ]->width - / try[i] *CCS_LIM (sensor,SCALER_N_MIN ), - sel->r.width, - crops[CCS_PAD_SINK ]->height, - sel->r.height, - sel->flags); +int this =scaling_goodness (subdev, + sink_crop->width + / try[i] + *CCS_LIM (sensor,SCALER_N_MIN ), + sel->r.width, sink_crop->height, + sel->r.height, sel->flags);dev_dbg (&client->dev,"trying factor %u (%u)\n" , try[i], i);
@@ -2423,12 +2400,10 @@ static void ccs_set_compose_scaler(struct v4l2_subdev *subdev,continue ; this =scaling_goodness ( - subdev, crops[CCS_PAD_SINK ]->width - / try[i] + subdev, sink_crop->width / try[i] *CCS_LIM (sensor,SCALER_N_MIN ), sel->r.width, - crops[CCS_PAD_SINK ]->height - / try[i] + sink_crop->height / try[i] *CCS_LIM (sensor,SCALER_N_MIN ), sel->r.height, sel->flags);
@@ -2440,18 +2415,13 @@ static void ccs_set_compose_scaler(struct v4l2_subdev *subdev, } } - sel->r.width = - (crops[CCS_PAD_SINK ]->width - / scale_m - *CCS_LIM (sensor,SCALER_N_MIN )) & ~1 ; + sel->r.width = (sink_crop->width / scale_m + *CCS_LIM (sensor,SCALER_N_MIN )) & ~1 ;if (mode ==SMIAPP_SCALING_MODE_BOTH ) - sel->r.height = - (crops[CCS_PAD_SINK ]->height - / scale_m - *CCS_LIM (sensor,SCALER_N_MIN )) - & ~1 ; + sel->r.height = (sink_crop->height / scale_m + *CCS_LIM (sensor,SCALER_N_MIN )) & ~1 ;else - sel->r.height = crops[CCS_PAD_SINK ]->height; + sel->r.height = sink_crop->height;if (sel->which ==V4L2_SUBDEV_FORMAT_ACTIVE ) { sensor->scale_m = scale_m;
@@ -2465,17 +2435,21 @@ static int ccs_set_compose(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 ]; +const struct v4l2_rect *sink_crop; +struct v4l2_rect *comp; -ccs_get_crop_compose (subdev, sd_state, crops, &comp); + sink_crop =v4l2_subdev_state_get_crop (sd_state,CCS_PAD_SINK , +CCS_STREAM_PIXEL ); + comp =v4l2_subdev_state_get_compose (sd_state, ssd->sink_pad, +CCS_STREAM_PIXEL ); sel->r.top =0 ; sel->r.left =0 ;if (ssd == sensor->binner) -ccs_set_compose_binner (subdev, sd_state, sel, crops, comp); +ccs_set_compose_binner (subdev, sd_state, sel, sink_crop);else -ccs_set_compose_scaler (subdev, sd_state, sel, crops, comp); +ccs_set_compose_scaler (subdev, sd_state, sel, sink_crop); *comp = sel->r;ccs_propagate (subdev, sd_state, sel->which,V4L2_SEL_TGT_COMPOSE );
@@ -2530,9 +2504,13 @@ static int ccs_set_crop(struct v4l2_subdev *subdev, {struct ccs_sensor *sensor =to_ccs_sensor (subdev);struct ccs_subdev *ssd =to_ccs_subdev (subdev); -struct v4l2_rect src_size = {0 }, *crops[CCS_PADS ], *comp; +struct v4l2_rect src_size = {0 }, *crop; +const struct v4l2_rect *comp; -ccs_get_crop_compose (subdev, sd_state, crops, &comp); + crop =v4l2_subdev_state_get_crop (sd_state, sel->pad, +CCS_STREAM_PIXEL ); + comp =v4l2_subdev_state_get_compose (sd_state, ssd->sink_pad, +CCS_STREAM_PIXEL );if (sel->pad == ssd->sink_pad) { struct v4l2_mbus_framefmt *mfmt =
@@ -2555,7 +2533,7 @@ static int ccs_set_crop(struct v4l2_subdev *subdev, sel->r.left =min_t (int, sel->r.left, src_size.width - sel->r.width); sel->r.top =min_t (int, sel->r.top, src_size.height - sel->r.height); - *crops[sel->pad] = sel->r; + *crop = sel->r;if (ssd != sensor->pixel_array && sel->pad ==CCS_PAD_SINK )ccs_propagate (subdev, sd_state, sel->which,V4L2_SEL_TGT_CROP );
@@ -2580,14 +2558,17 @@ static int ccs_get_selection(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 ]; +const struct v4l2_rect *crop, *comp;int ret; ret =ccs_sel_supported (subdev, sel);if (ret)return ret; -ccs_get_crop_compose (subdev, sd_state, crops, &comp); + crop =v4l2_subdev_state_get_crop (sd_state, sel->pad, +CCS_STREAM_PIXEL ); + comp =v4l2_subdev_state_get_compose (sd_state, ssd->sink_pad, +CCS_STREAM_PIXEL );switch (sel->target) {case V4L2_SEL_TGT_CROP_BOUNDS :
@@ -2607,7 +2588,7 @@ static int ccs_get_selection(struct v4l2_subdev *subdev,break ;case V4L2_SEL_TGT_CROP :case V4L2_SEL_TGT_COMPOSE_BOUNDS : - sel->r = *crops[sel->pad]; + sel->r = *crop;break ;case V4L2_SEL_TGT_COMPOSE : sel->r = *comp;
Signature · 1 line
2.47.3
Sakari Ailus
maintainerPATCH v2 2/8 media: ccs: Rely on sub-device state locking
In reply to Sakari AilusRely on sub-device state locking to serialise access to driver's data structures. The driver-provided mutex is used as the state lock for all driver sub-devices.
--- drivers/media/i2c/ccs/ccs-core.c | 146 +++++++++++++++---------------- drivers/media/i2c/ccs/ccs.h | 1 - 2 files changed, 70 insertions(+), 77 deletions(-)
drivers/media/i2c/ccs/ccs-core.c +70 -76
@@ -541,12 +541,13 @@ static int ccs_pll_update(struct ccs_sensor *sensor)* */ -static void __ccs_update_exposure_limits (struct ccs_sensor *sensor) +static void __ccs_update_exposure_limits (struct ccs_sensor *sensor, +const struct v4l2_rect *pa_src) {struct v4l2_ctrl *ctrl = sensor->exposure;int max; - max = sensor->pa_src.height + sensor->vblank->val - + max = pa_src->height + sensor->vblank->val -CCS_LIM (sensor,COARSE_INTEGRATION_TIME_MAX_MARGIN );__v4l2_ctrl_modify_range (ctrl, ctrl->minimum, max, ctrl->step, max);
@@ -649,12 +650,20 @@ static int ccs_set_ctrl(struct v4l2_ctrl *ctrl) container_of(ctrl->handler, struct ccs_subdev, ctrl_handler) ->sensor;struct i2c_client *client =v4l2_get_subdevdata (&sensor->src->sd); +struct v4l2_subdev_state *state; +const struct v4l2_rect *pa_src =NULL ;int pm_status;u32 orient =0 ;unsigned int i;int exposure;int rval; +if (ctrl->id ==V4L2_CID_VBLANK || ctrl->id ==V4L2_CID_HBLANK ) { + state =v4l2_subdev_get_locked_active_state (&sensor->pixel_array->sd); + pa_src =v4l2_subdev_state_get_crop (state,CCS_PA_PAD_SRC , +CCS_STREAM_PIXEL ); + } +switch (ctrl->id) {case V4L2_CID_HFLIP :case V4L2_CID_VFLIP :
@@ -673,7 +682,7 @@ static int ccs_set_ctrl(struct v4l2_ctrl *ctrl)case V4L2_CID_VBLANK : exposure = sensor->exposure->val; -__ccs_update_exposure_limits (sensor); +__ccs_update_exposure_limits (sensor, pa_src);if (exposure > sensor->exposure->maximum) { sensor->exposure->val = sensor->exposure->maximum;
@@ -765,12 +774,12 @@ static int ccs_set_ctrl(struct v4l2_ctrl *ctrl)break ;case V4L2_CID_VBLANK : rval =ccs_write (sensor,FRAME_LENGTH_LINES , - sensor->pa_src.height + ctrl->val); + pa_src->height + ctrl->val);break ;case V4L2_CID_HBLANK : rval =ccs_write (sensor,LINE_LENGTH_PCK , - sensor->pa_src.width + ctrl->val); + pa_src->width + ctrl->val);break ;case V4L2_CID_TEST_PATTERN :
@@ -1223,7 +1232,8 @@ static int ccs_get_mbus_formats(struct ccs_sensor *sensor)return 0 ; } -static void ccs_update_blanking (struct ccs_sensor *sensor) +static void ccs_update_blanking (struct ccs_sensor *sensor, +const struct v4l2_rect *pa_src) {struct v4l2_ctrl *vblank = sensor->vblank;struct v4l2_ctrl *hblank = sensor->hblank;
@@ -1246,21 +1256,26 @@ static void ccs_update_blanking(struct ccs_sensor *sensor) min =max_t (int,CCS_LIM (sensor,MIN_FRAME_BLANKING_LINES ), - min_fll - sensor->pa_src.height); - max = max_fll - sensor->pa_src.height; + min_fll - pa_src->height); + max = max_fll - pa_src->height;__v4l2_ctrl_modify_range (vblank, min, max, vblank->step, min); - min =max_t (int, min_llp - sensor->pa_src.width, min_lbp); - max = max_llp - sensor->pa_src.width; + min =max_t (int, min_llp - pa_src->width, min_lbp); + max = max_llp - pa_src->width;__v4l2_ctrl_modify_range (hblank, min, max, hblank->step, min); -__ccs_update_exposure_limits (sensor); +__ccs_update_exposure_limits (sensor, pa_src); }static int ccs_pll_blanking_update (struct ccs_sensor *sensor) { +struct v4l2_subdev_state *state = +v4l2_subdev_get_locked_active_state (&sensor->pixel_array->sd); +const struct v4l2_rect *pa_src = +v4l2_subdev_state_get_crop (state,CCS_PA_PAD_SRC , +CCS_STREAM_PIXEL );struct i2c_client *client =v4l2_get_subdevdata (&sensor->src->sd);int rval;
@@ -1269,15 +1284,15 @@ static int ccs_pll_blanking_update(struct ccs_sensor *sensor)return rval;/* Output from pixel array, including blanking */ -ccs_update_blanking (sensor); +ccs_update_blanking (sensor, pa_src);dev_dbg (&client->dev,"vblank\t\t%d\n" , sensor->vblank->val);dev_dbg (&client->dev,"hblank\t\t%d\n" , sensor->hblank->val);dev_dbg (&client->dev,"real timeperframe\t100/%d\n" , sensor->pll.pixel_rate_pixel_array / - ((sensor->pa_src.width + sensor->hblank->val) * - (sensor->pa_src.height + sensor->vblank->val) /100 )); + ((pa_src->width + sensor->hblank->val) * + (pa_src->height + sensor->vblank->val) /100 ));return 0 ; }
@@ -1782,6 +1797,16 @@ static int ccs_enable_streams(struct v4l2_subdev *subdev, u64 streams_mask) {struct ccs_sensor *sensor =to_ccs_sensor (subdev); +struct v4l2_subdev_state *pa_state = +v4l2_subdev_get_locked_active_state (&sensor->pixel_array->sd); +struct v4l2_subdev_state *src_state = +v4l2_subdev_get_locked_active_state (&sensor->src->sd); +const struct v4l2_rect *pa_src = +v4l2_subdev_state_get_crop (pa_state,CCS_PA_PAD_SRC , +CCS_STREAM_PIXEL ); +const struct v4l2_rect *src_src = +v4l2_subdev_state_get_crop (src_state,CCS_PAD_SRC , +CCS_STREAM_PIXEL );struct i2c_client *client =v4l2_get_subdevdata (&sensor->src->sd);unsigned int binning_mode;int rval;
@@ -1829,22 +1854,20 @@ static int ccs_enable_streams(struct v4l2_subdev *subdev, goto err_pm_put;/* Analog crop start coordinates */ - rval =ccs_write (sensor,X_ADDR_START , sensor->pa_src.left); + rval =ccs_write (sensor,X_ADDR_START , pa_src->left);if (rval <0 ) goto err_pm_put; - rval =ccs_write (sensor,Y_ADDR_START , sensor->pa_src.top); + rval =ccs_write (sensor,Y_ADDR_START , pa_src->top);if (rval <0 ) goto err_pm_put;/* Analog crop end coordinates */ - rval =ccs_write (sensor,X_ADDR_END , - sensor->pa_src.left + sensor->pa_src.width -1 ); + rval =ccs_write (sensor,X_ADDR_END , pa_src->left + pa_src->width -1 );if (rval <0 ) goto err_pm_put; - rval =ccs_write (sensor,Y_ADDR_END , - sensor->pa_src.top + sensor->pa_src.height -1 ); + rval =ccs_write (sensor,Y_ADDR_END , pa_src->top + pa_src->height -1 );if (rval <0 ) goto err_pm_put;
@@ -1856,23 +1879,30 @@ static int ccs_enable_streams(struct v4l2_subdev *subdev,/* Digital crop */ if (CCS_LIM (sensor,DIGITAL_CROP_CAPABILITY ) ==CCS_DIGITAL_CROP_CAPABILITY_INPUT_CROP ) { +struct v4l2_subdev_state *scaler_state = +v4l2_subdev_get_locked_active_state (&sensor->scaler->sd); +const struct v4l2_rect *scaler_sink = +v4l2_subdev_state_get_crop (scaler_state, + sensor->scaler->sink_pad, +CCS_STREAM_PIXEL ); + rval =ccs_write (sensor,DIGITAL_CROP_X_OFFSET , - sensor->scaler_sink.left); + scaler_sink->left);if (rval <0 ) goto err_pm_put; rval =ccs_write (sensor,DIGITAL_CROP_Y_OFFSET , - sensor->scaler_sink.top); + scaler_sink->top);if (rval <0 ) goto err_pm_put; rval =ccs_write (sensor,DIGITAL_CROP_IMAGE_WIDTH , - sensor->scaler_sink.width); + scaler_sink->width);if (rval <0 ) goto err_pm_put; rval =ccs_write (sensor,DIGITAL_CROP_IMAGE_HEIGHT , - sensor->scaler_sink.height); + scaler_sink->height);if (rval <0 ) goto err_pm_put; }
@@ -1890,10 +1920,10 @@ static int ccs_enable_streams(struct v4l2_subdev *subdev, }/* Output size from sensor */ - rval =ccs_write (sensor,X_OUTPUT_SIZE , sensor->src_src.width); + rval =ccs_write (sensor,X_OUTPUT_SIZE , src_src->width);if (rval <0 ) goto err_pm_put; - rval =ccs_write (sensor,Y_OUTPUT_SIZE , sensor->src_src.height); + rval =ccs_write (sensor,Y_OUTPUT_SIZE , src_src->height);if (rval <0 ) goto err_pm_put;
@@ -2022,20 +2052,17 @@ static int ccs_enum_mbus_code(struct v4l2_subdev *subdev,struct ccs_sensor *sensor =to_ccs_sensor (subdev);unsigned int i;int idx =-1 ; -int rval = -EINVAL ; - -mutex_lock (&sensor->mutex);dev_err (&client->dev,"subdev %s, pad %u, index %u\n" , subdev->name, code->pad, code->index);if (subdev != &sensor->src->sd || code->pad !=CCS_PAD_SRC ) {if (code->index) - goto out; +return -EINVAL ; code->code = sensor->internal_csi_format->code; - rval =0 ; - goto out; + +return 0 ; }for (i =0 ; i <ARRAY_SIZE (ccs_csi_data_formats); i++) {
@@ -2046,18 +2073,14 @@ static int ccs_enum_mbus_code(struct v4l2_subdev *subdev, code->code = ccs_csi_data_formats[i].code;dev_err (&client->dev,"found index %u, i %u, code %x\n" , code->index, i, code->code); - rval =0 ; -break ; +return 0 ; } } -out: -mutex_unlock (&sensor->mutex); - -return rval; +return -EINVAL ; } -static u32 __ccs_get_mbus_code (struct v4l2_subdev *subdev,unsigned int pad) +static u32 ccs_get_mbus_code (struct v4l2_subdev *subdev,unsigned int pad) {struct ccs_sensor *sensor =to_ccs_sensor (subdev);
@@ -2067,28 +2090,14 @@ static u32 __ccs_get_mbus_code(struct v4l2_subdev *subdev, unsigned int pad)return sensor->internal_csi_format->code; } -static int __ccs_get_format (struct v4l2_subdev *subdev, -struct v4l2_subdev_state *sd_state, -struct v4l2_subdev_format *fmt) -{ - fmt->format = *v4l2_subdev_state_get_format (sd_state, fmt->pad); - fmt->format.code =__ccs_get_mbus_code (subdev, fmt->pad); - -return 0 ; -} -static int ccs_get_format (struct v4l2_subdev *subdev,struct v4l2_subdev_state *sd_state,struct v4l2_subdev_format *fmt) { -struct ccs_sensor *sensor =to_ccs_sensor (subdev); -int rval; - -mutex_lock (&sensor->mutex); - rval =__ccs_get_format (subdev, sd_state, fmt); -mutex_unlock (&sensor->mutex); + fmt->format = *v4l2_subdev_state_get_format (sd_state, fmt->pad); + fmt->format.code =ccs_get_mbus_code (subdev, fmt->pad); -return rval; +return 0 ; }/* Changes require propagation only on sink pad. */
@@ -2114,7 +2123,6 @@ static void ccs_propagate(struct v4l2_subdev *subdev, sensor->scale_m =CCS_LIM (sensor,SCALER_N_MIN ); sensor->scaling_mode =CCS_SCALING_MODE_NO_SCALING ; - sensor->scaler_sink = *comp; }else if (ssd == sensor->binner) { sensor->binning_horizontal =1 ; sensor->binning_vertical =1 ;
@@ -2129,8 +2137,6 @@ static void ccs_propagate(struct v4l2_subdev *subdev, CCS_STREAM_PIXEL); fmt->width = comp->width; fmt->height = comp->height; -if (which ==V4L2_SUBDEV_FORMAT_ACTIVE && ssd == sensor->src) - sensor->src_src = *crop;break ;default :WARN_ON_ONCE (1 );
@@ -2149,7 +2155,7 @@ static int ccs_set_format_source(struct v4l2_subdev *subdev,unsigned int i;int rval; - rval =__ccs_get_format (subdev, sd_state, fmt); + rval =ccs_get_format (subdev, sd_state, fmt);if (rval)return rval;
@@ -2198,20 +2204,17 @@ static int ccs_set_format(struct v4l2_subdev *subdev,struct ccs_subdev *ssd =to_ccs_subdev (subdev);struct v4l2_rect *crop; -mutex_lock (&sensor->mutex); -if (fmt->pad == ssd->source_pad) {int rval; rval =ccs_set_format_source (subdev, sd_state, fmt); -mutex_unlock (&sensor->mutex); -return rval; }/* Sink pad. Width and height are changeable here. */ - fmt->format.code =__ccs_get_mbus_code (subdev, fmt->pad); + fmt->format.code =ccs_get_mbus_code (subdev, fmt->pad); + fmt->format.width &= ~1 ; fmt->format.height &= ~1 ; fmt->format.field =V4L2_FIELD_NONE ;
@@ -2234,8 +2237,6 @@ static int ccs_set_format(struct v4l2_subdev *subdev, crop->height = fmt->format.height;ccs_propagate (subdev, sd_state, fmt->which,V4L2_SEL_TGT_CROP ); -mutex_unlock (&sensor->mutex); -return 0 ; }
@@ -2537,9 +2538,6 @@ static int ccs_set_crop(struct v4l2_subdev *subdev,if (ssd != sensor->pixel_array && sel->pad ==CCS_PAD_SINK )ccs_propagate (subdev, sd_state, sel->which,V4L2_SEL_TGT_CROP ); -else if (sel->which ==V4L2_SUBDEV_FORMAT_ACTIVE && - ssd == sensor->pixel_array) - sensor->pa_src = sel->r;return 0 ; }
@@ -2609,8 +2607,6 @@ static int ccs_set_selection(struct v4l2_subdev *subdev,if (ret)return ret; -mutex_lock (&sensor->mutex); - sel->r.left =max (0 , sel->r.left & ~1 ); sel->r.top =max (0 , sel->r.top & ~1 ); sel->r.width =CCS_ALIGN_DIM (sel->r.width, sel->flags);
@@ -2632,7 +2628,6 @@ static int ccs_set_selection(struct v4l2_subdev *subdev, ret = -EINVAL ; } -mutex_unlock (&sensor->mutex);return ret; }
@@ -3002,6 +2997,7 @@ static int ccs_init_subdev(struct ccs_sensor *sensor, ssd->sd.flags |=V4L2_SUBDEV_FL_HAS_DEVNODE ; ssd->sd.entity.function = function; + ssd->sd.state_lock = &sensor->mutex; ssd->sensor = sensor; ssd->npads = num_pads;
@@ -3059,10 +3055,8 @@ static int ccs_init_state(struct v4l2_subdev *sd, fmt->field =V4L2_FIELD_NONE ;if (ssd == sensor->pixel_array) { -if (is_active) - sensor->pa_src = *crop; -mutex_unlock (&sensor->mutex); +return 0 ; }
drivers/media/i2c/ccs/ccs.h +0 -1
@@ -225,7 +225,6 @@ struct ccs_sensor {u32 mbus_frame_fmts;const struct ccs_csi_data_format *csi_format;const struct ccs_csi_data_format *internal_csi_format; -struct v4l2_rect pa_src, scaler_sink, src_src;u32 default_mbus_frame_fmts;int default_pixel_order;struct ccs_data_container sdata, mdata;
Signature · 1 line
2.47.3
Sakari Ailus
maintainerPATCH v2 3/8 media: ccs: Switch to guard and scoped_guard
In reply to Sakari AilusReplace the use of mutex_{,un}lock() by guard() and scoped_guard() where it makes sense (i.e. everywhere).
--- drivers/media/i2c/ccs/ccs-core.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-)
drivers/media/i2c/ccs/ccs-core.c +6 -13
@@ -2006,9 +2006,8 @@ static int ccs_pre_streamon(struct v4l2_subdev *subdev, u32 flags) } } -mutex_lock (&sensor->mutex); - rval =ccs_pm_get_init (sensor); -mutex_unlock (&sensor->mutex); +scoped_guard (mutex, &sensor->mutex) + rval = ccs_pm_get_init(sensor);if (rval)return rval;
@@ -3045,7 +3044,7 @@ static int ccs_init_state(struct v4l2_subdev *sd,v4l2_subdev_state_get_crop (sd_state, pad);bool is_active = !sd->active_state || sd->active_state == sd_state; -mutex_lock (&sensor->mutex); +guard (mutex)(&sensor->mutex);ccs_get_native_size (ssd, crop);
@@ -3054,11 +3053,8 @@ static int ccs_init_state(struct v4l2_subdev *sd, fmt->code = sensor->internal_csi_format->code; fmt->field =V4L2_FIELD_NONE ; -if (ssd == sensor->pixel_array) { -mutex_unlock (&sensor->mutex); - +if (ssd == sensor->pixel_array)return 0 ; - } fmt =v4l2_subdev_state_get_format (sd_state,CCS_PAD_SRC ); fmt->code = ssd == sensor->src ?
@@ -3067,8 +3063,6 @@ static int ccs_init_state(struct v4l2_subdev *sd,ccs_propagate (sd, sd_state, is_active,V4L2_SEL_TGT_CROP ); -mutex_unlock (&sensor->mutex); -return 0 ; }
@@ -3553,9 +3547,8 @@ static int ccs_probe(struct i2c_client *client) goto out_cleanup; } -mutex_lock (&sensor->mutex); - rval =ccs_pll_blanking_update (sensor); -mutex_unlock (&sensor->mutex); +scoped_guard (mutex, &sensor->mutex) + rval = ccs_pll_blanking_update(sensor);if (rval) {dev_err (&client->dev,"update mode failed\n" ); goto out_cleanup;
Signature · 1 line
2.47.3
Sakari Ailus
maintainerPATCH v2 4/8 media: ccs: Compute binning configuration from sub-device state
In reply to Sakari AilusCalculate binning configuration from sub-device state so the state related configuration can be removed from the driver's device context struct.
--- drivers/media/i2c/ccs/ccs-core.c | 56 +++++++++++++++++++------------- drivers/media/i2c/ccs/ccs.h | 3 -- 2 files changed, 33 insertions(+), 26 deletions(-)
drivers/media/i2c/ccs/ccs-core.c +33 -23
@@ -511,13 +511,36 @@ static int ccs_pll_try(struct ccs_sensor *sensor, struct ccs_pll *pll)return ccs_pll_calculate (&client->dev, &lim, pll); } +static void +ccs_get_binning (struct ccs_sensor *sensor,u8 *binning_mode,u8 *binh,u8 *binv) +{ +struct v4l2_subdev_state *state = +v4l2_subdev_get_locked_active_state (&sensor->binner->sd); +const struct v4l2_rect *sink_crop = +v4l2_subdev_state_get_crop (state,CCS_PAD_SINK , +CCS_STREAM_PIXEL ); +const struct v4l2_rect *sink_comp = +v4l2_subdev_state_get_compose (state,CCS_PAD_SINK , +CCS_STREAM_PIXEL ); + +if (binning_mode) + *binning_mode = sink_crop->width == sink_comp->width && + sink_crop->height == sink_comp->height ?0 :1 ; + + *binh = sink_crop->width / sink_comp->width; + *binv = sink_crop->height / sink_comp->height; +} +static int ccs_pll_update (struct ccs_sensor *sensor) {struct ccs_pll *pll = &sensor->pll; +u8 binh, binv;int rval; - pll->binning_horizontal = sensor->binning_horizontal; - pll->binning_vertical = sensor->binning_vertical; +ccs_get_binning (sensor,NULL , &binh, &binv); + + pll->binning_horizontal = binh; + pll->binning_vertical = binv; pll->link_freq = sensor->link_freq->qmenu_int[sensor->link_freq->val]; pll->scale_m = sensor->scale_m;
@@ -1239,8 +1262,11 @@ static void ccs_update_blanking(struct ccs_sensor *sensor,struct v4l2_ctrl *hblank = sensor->hblank;u16 min_fll, max_fll, min_llp, max_llp, min_lbp;int min, max; +u8 binh, binv; + +ccs_get_binning (sensor,NULL , &binh, &binv); -if (sensor->binning_vertical >1 || sensor->binning_horizontal >1 ) { +if (binv >1 || binh >1 ) { min_fll =CCS_LIM (sensor,MIN_FRAME_LENGTH_LINES_BIN ); max_fll =CCS_LIM (sensor,MAX_FRAME_LENGTH_LINES_BIN ); min_llp =CCS_LIM (sensor,MIN_LINE_LENGTH_PCK_BIN );
@@ -1808,7 +1834,7 @@ static int ccs_enable_streams(struct v4l2_subdev *subdev,v4l2_subdev_state_get_crop (src_state,CCS_PAD_SRC ,CCS_STREAM_PIXEL );struct i2c_client *client =v4l2_get_subdevdata (&sensor->src->sd); -unsigned int binning_mode; +u8 binning_mode, binh, binv;int rval;if (pad !=CCS_PAD_SRC )
@@ -1830,19 +1856,12 @@ static int ccs_enable_streams(struct v4l2_subdev *subdev, goto err_pm_put;/* Binning configuration */ -if (sensor->binning_horizontal ==1 && - sensor->binning_vertical ==1 ) { - binning_mode =0 ; - }else { -u8 binning_type = - (sensor->binning_horizontal <<4 ) - | sensor->binning_vertical; +ccs_get_binning (sensor, &binning_mode, &binh, &binv); - rval =ccs_write (sensor,BINNING_TYPE , binning_type); +if (binning_mode) { + rval =ccs_write (sensor,BINNING_TYPE , (binh <<4 ) | binv);if (rval <0 ) goto err_pm_put; - - binning_mode =1 ; } rval =ccs_write (sensor,BINNING_MODE , binning_mode);if (rval <0 )
@@ -2122,9 +2141,6 @@ static void ccs_propagate(struct v4l2_subdev *subdev, sensor->scale_m =CCS_LIM (sensor,SCALER_N_MIN ); sensor->scaling_mode =CCS_SCALING_MODE_NO_SCALING ; - }else if (ssd == sensor->binner) { - sensor->binning_horizontal =1 ; - sensor->binning_vertical =1 ; } } fallthrough;
@@ -2310,10 +2326,6 @@ static void ccs_set_compose_binner(struct v4l2_subdev *subdev, best = this; } } -if (sel->which ==V4L2_SUBDEV_FORMAT_ACTIVE ) { - sensor->binning_vertical = binv; - sensor->binning_horizontal = binh; - } sel->r.width = (sink_crop->width / binh) & ~1 ; sel->r.height = (sink_crop->height / binv) & ~1 ;
@@ -3400,8 +3412,6 @@ static int ccs_probe(struct i2c_client *client) sensor->binning_subtypes[i].vertical); } } - sensor->binning_horizontal =1 ; - sensor->binning_vertical =1 ;if (device_create_file (&client->dev, &dev_attr_ident) !=0 ) {dev_err (&client->dev,"sysfs ident entry creation failed\n" );
drivers/media/i2c/ccs/ccs.h +0 -3
@@ -229,9 +229,6 @@ struct ccs_sensor {int default_pixel_order;struct ccs_data_container sdata, mdata; -u8 binning_horizontal; -u8 binning_vertical; -u8 scale_m;u8 scaling_mode;
Signature · 1 line
2.47.3
Sakari Ailus
maintainerPATCH v2 5/8 media: ccs: Compute scaling configuration from sub-device state
In reply to Sakari AilusCompute scaling configuration from sub-device state instead of storing it to the driver's device context struct.
--- drivers/media/i2c/ccs/ccs-core.c | 59 ++++++++++++++++++++++---------- drivers/media/i2c/ccs/ccs.h | 3 -- 2 files changed, 40 insertions(+), 22 deletions(-)
drivers/media/i2c/ccs/ccs-core.c +40 -19
@@ -531,19 +531,51 @@ ccs_get_binning(struct ccs_sensor *sensor, u8 *binning_mode, u8 *binh, u8 *binv) *binv = sink_crop->height / sink_comp->height; } +static void ccs_get_scaling (struct ccs_sensor *sensor,u8 *scaling_mode, +u8 *scale_m) +{ +struct v4l2_subdev_state *state = +v4l2_subdev_get_locked_active_state (&sensor->scaler->sd); +const struct v4l2_rect *sink_crop = +v4l2_subdev_state_get_crop (state,CCS_PAD_SINK , +CCS_STREAM_PIXEL ); +const struct v4l2_rect *sink_comp = +v4l2_subdev_state_get_compose (state,CCS_PAD_SINK , +CCS_STREAM_PIXEL ); + + *scale_m = sink_crop->width *CCS_LIM (sensor,SCALER_N_MIN ) / + sink_comp->width; + +if (!scaling_mode) +return ; + +if (sink_crop->width == sink_comp->width) + *scaling_mode =CCS_SCALING_MODE_NO_SCALING ; +else if (sink_crop->height == sink_comp->height) + *scaling_mode =CCS_SCALING_MODE_HORIZONTAL ; +else + *scaling_mode =SMIAPP_SCALING_MODE_BOTH ; +} +static int ccs_pll_update (struct ccs_sensor *sensor) {struct ccs_pll *pll = &sensor->pll;u8 binh, binv; +u8 scale_m;int rval;ccs_get_binning (sensor,NULL , &binh, &binv); +if (sensor->scaler) +ccs_get_scaling (sensor,NULL , &scale_m); +else + scale_m =CCS_LIM (sensor,SCALER_N_MIN ); + pll->binning_horizontal = binh; pll->binning_vertical = binv; pll->link_freq = sensor->link_freq->qmenu_int[sensor->link_freq->val]; - pll->scale_m = sensor->scale_m; + pll->scale_m = scale_m; pll->bits_per_pixel = sensor->csi_format->compressed; rval =ccs_pll_try (sensor, pll);
@@ -1184,7 +1216,7 @@ static int ccs_get_mbus_formats(struct ccs_sensor *sensor)/* Figure out which BPP values can be used with which formats. */ pll->binning_horizontal =1 ; pll->binning_vertical =1 ; - pll->scale_m = sensor->scale_m; + pll->scale_m =CCS_LIM (sensor,SCALER_N_MIN );for (i =0 ; i <ARRAY_SIZE (ccs_csi_data_formats); i++) { sensor->compressed_min_bpp =
@@ -1929,11 +1961,15 @@ static int ccs_enable_streams(struct v4l2_subdev *subdev,/* Scaling */ if (CCS_LIM (sensor,SCALING_CAPABILITY ) !=CCS_SCALING_CAPABILITY_NONE ) { - rval =ccs_write (sensor,SCALING_MODE , sensor->scaling_mode); +u8 scaling_mode, scale_m; + +ccs_get_scaling (sensor, &scaling_mode, &scale_m); + + rval =ccs_write (sensor,SCALING_MODE , scaling_mode);if (rval <0 ) goto err_pm_put; - rval =ccs_write (sensor,SCALE_M , sensor->scale_m); + rval =ccs_write (sensor,SCALE_M , scale_m);if (rval <0 ) goto err_pm_put; }
@@ -2123,7 +2159,6 @@ static void ccs_propagate(struct v4l2_subdev *subdev, struct v4l2_subdev_state *sd_state, int which, int target) { - struct ccs_sensor *sensor = to_ccs_sensor(subdev); struct ccs_subdev *ssd = to_ccs_subdev(subdev);struct v4l2_rect *comp, *crop;struct v4l2_mbus_framefmt *fmt;
@@ -2136,13 +2171,6 @@ static void ccs_propagate(struct v4l2_subdev *subdev, CCS_STREAM_PIXEL); comp->width = crop->width; comp->height = crop->height; -if (which ==V4L2_SUBDEV_FORMAT_ACTIVE ) { -if (ssd == sensor->scaler) { - sensor->scale_m =CCS_LIM (sensor,SCALER_N_MIN ); - sensor->scaling_mode = -CCS_SCALING_MODE_NO_SCALING ; - } - } fallthrough;case V4L2_SEL_TGT_COMPOSE : crop = v4l2_subdev_state_get_crop(sd_state, CCS_PAD_SRC,
@@ -2434,11 +2462,6 @@ static void ccs_set_compose_scaler(struct v4l2_subdev *subdev, * CCS_LIM(sensor, SCALER_N_MIN)) & ~1; else sel->r.height = sink_crop->height; - -if (sel->which ==V4L2_SUBDEV_FORMAT_ACTIVE ) { - sensor->scale_m = scale_m; - sensor->scaling_mode = mode; - } }/* We're only called on source pads. This function sets scaling. */ static int ccs_set_compose(struct v4l2_subdev *subdev,
@@ -3448,8 +3471,6 @@ static int ccs_probe(struct i2c_client *client) sensor->pixel_array = &sensor->ssds[sensor->ssds_used]; sensor->ssds_used++; - sensor->scale_m =CCS_LIM (sensor,SCALER_N_MIN ); -/* prepare PLL configuration input values */ switch (sensor->hwcfg.csi_signalling_mode) {case CCS_CSI_SIGNALING_MODE_CSI_2_CPHY :
drivers/media/i2c/ccs/ccs.h +0 -3
@@ -229,9 +229,6 @@ struct ccs_sensor {int default_pixel_order;struct ccs_data_container sdata, mdata; -u8 scale_m; -u8 scaling_mode; -u8 frame_skip;u16 embedded_start;/* embedded data start line */ u16 embedded_end;
Signature · 1 line
2.47.3
Sakari Ailus
maintainerPATCH v2 6/8 media: ccs: Remove which parameter from ccs_propagate
In reply to Sakari Ailusccs_propagate() no longer stores information in the driver's context struct. The which parameter can thus be removed.
--- drivers/media/i2c/ccs/ccs-core.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/media/i2c/ccs/ccs-core.c +5 -7
@@ -2156,8 +2156,7 @@ static int ccs_get_format(struct v4l2_subdev *subdev,/* Changes require propagation only on sink pad. */ static void ccs_propagate (struct v4l2_subdev *subdev, -struct v4l2_subdev_state *sd_state,int which, -int target) +struct v4l2_subdev_state *sd_state,int target) {struct ccs_subdev *ssd =to_ccs_subdev (subdev);struct v4l2_rect *comp, *crop;
@@ -2278,7 +2277,7 @@ static int ccs_set_format(struct v4l2_subdev *subdev, crop->top =0 ; crop->width = fmt->format.width; crop->height = fmt->format.height; -ccs_propagate (subdev, sd_state, fmt->which,V4L2_SEL_TGT_CROP ); +ccs_propagate (subdev, sd_state,V4L2_SEL_TGT_CROP );return 0 ; }
@@ -2487,7 +2486,7 @@ static int ccs_set_compose(struct v4l2_subdev *subdev,ccs_set_compose_scaler (subdev, sd_state, sel, sink_crop); *comp = sel->r; -ccs_propagate (subdev, sd_state, sel->which,V4L2_SEL_TGT_COMPOSE ); +ccs_propagate (subdev, sd_state,V4L2_SEL_TGT_COMPOSE );if (sel->which ==V4L2_SUBDEV_FORMAT_ACTIVE )return ccs_pll_blanking_update (sensor);
@@ -2571,7 +2570,7 @@ static int ccs_set_crop(struct v4l2_subdev *subdev, *crop = sel->r;if (ssd != sensor->pixel_array && sel->pad ==CCS_PAD_SINK ) -ccs_propagate (subdev, sd_state, sel->which,V4L2_SEL_TGT_CROP ); +ccs_propagate (subdev, sd_state,V4L2_SEL_TGT_CROP );return 0 ; }
@@ -3077,7 +3076,6 @@ static int ccs_init_state(struct v4l2_subdev *sd,v4l2_subdev_state_get_format (sd_state, pad);struct v4l2_rect *crop =v4l2_subdev_state_get_crop (sd_state, pad); -bool is_active = !sd->active_state || sd->active_state == sd_state;guard (mutex)(&sensor->mutex);
@@ -3096,7 +3094,7 @@ static int ccs_init_state(struct v4l2_subdev *sd, 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 ); +ccs_propagate (sd, sd_state,V4L2_SEL_TGT_CROP );return 0 ; }
Signature · 1 line
2.47.3
Sakari Ailus
maintainerPATCH v2 7/8 media: ccs: Make supported mbus code bitmask a u64
In reply to Sakari AilusPrepare for adding more media bus codes.
--- drivers/media/i2c/ccs/ccs-core.c | 9 +++++---- drivers/media/i2c/ccs/ccs.h | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-)
drivers/media/i2c/ccs/ccs-core.c +5 -4
@@ -13,6 +13,7 @@* Based on smia-sensor.c by Tuukka Toivonen <[email protected]> */ +#include <linux/bits.h> #include <linux/clk.h> #include <linux/delay.h> #include <linux/device.h>
@@ -1209,7 +1210,7 @@ static int ccs_get_mbus_formats(struct ccs_sensor *sensor)dev_dbg (&client->dev,"jolly good! %u\n" , j); - sensor->default_mbus_frame_fmts |=1 << j; + sensor->default_mbus_frame_fmts |=BIT_U64 (j); } }
@@ -1242,7 +1243,7 @@ static int ccs_get_mbus_formats(struct ccs_sensor *sensor) f->compressed - sensor->compressed_min_bpp];unsigned int j; -if (!(sensor->default_mbus_frame_fmts &1 << i)) +if (!(sensor->default_mbus_frame_fmts &BIT_U64 (i)))continue ; pll->bits_per_pixel = f->compressed;
@@ -2090,7 +2091,7 @@ static const struct ccs_csi_data_formatunsigned int i;for (i =0 ; i <ARRAY_SIZE (ccs_csi_data_formats); i++) { -if (sensor->mbus_frame_fmts & (1 << i) && +if (sensor->mbus_frame_fmts &BIT_U64 (i) && ccs_csi_data_formats[i].code == code)return &ccs_csi_data_formats[i]; }
@@ -2120,7 +2121,7 @@ static int ccs_enum_mbus_code(struct v4l2_subdev *subdev, }for (i =0 ; i <ARRAY_SIZE (ccs_csi_data_formats); i++) { -if (sensor->mbus_frame_fmts & (1 << i)) +if (sensor->mbus_frame_fmts &BIT_U64 (i)) idx++;if (idx == code->index) {
drivers/media/i2c/ccs/ccs.h +2 -2
@@ -222,10 +222,10 @@ struct ccs_sensor {void *ccs_limits;u8 nbinning_subtypes;struct ccs_binning_subtype binning_subtypes[CCS_LIM_BINNING_SUB_TYPE_MAX_N +1 ]; -u32 mbus_frame_fmts; +u64 mbus_frame_fmts;const struct ccs_csi_data_format *csi_format;const struct ccs_csi_data_format *internal_csi_format; -u32 default_mbus_frame_fmts; +u64 default_mbus_frame_fmts;int default_pixel_order;struct ccs_data_container sdata, mdata;
Signature · 1 line
2.47.3
Sakari Ailus
maintainerPATCH v2 8/8 media: i2c: imx219: Inline imx219_update_pad_format() in its caller
In reply to Sakari AilusFrom: Laurent Pinchart <[email protected]>
The imx219_update_pad_format() is short and called from a single place, in imx219_set_pad_format(). Inline the code in the caller to keep all format adjustments grouped in a single place and improve readability.
--- drivers/media/i2c/imx219.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-)
drivers/media/i2c/imx219.c +13 -16
@@ -792,21 +792,6 @@ static int imx219_disable_streams(struct v4l2_subdev *sd,return ret; } -static void imx219_update_pad_format (struct imx219 *imx219, -const struct imx219_mode *mode, -struct v4l2_mbus_framefmt *fmt,u32 code) -{ -/* Bayer order varies with flips */ - fmt->code =imx219_get_format_code (imx219, code); - fmt->width = mode->width; - fmt->height = mode->height; - fmt->field =V4L2_FIELD_NONE ; - fmt->colorspace =V4L2_COLORSPACE_RAW ; - fmt->ycbcr_enc =V4L2_YCBCR_ENC_601 ; - fmt->quantization =V4L2_QUANTIZATION_FULL_RANGE ; - fmt->xfer_func =V4L2_XFER_FUNC_NONE ; -} -static int imx219_enum_mbus_code (struct v4l2_subdev *sd,struct v4l2_subdev_state *state,struct v4l2_subdev_mbus_code_enum *code)
@@ -858,12 +843,24 @@ static int imx219_set_pad_format(struct v4l2_subdev *sd, format =v4l2_subdev_state_get_format (state,0 ); prev_line_len = format->width + imx219->hblank->val; +/* +* Adjust the requested format to match the closest mode. The Bayer +* order varies with flips. +*/ mode =v4l2_find_nearest_size (supported_modes,ARRAY_SIZE (supported_modes), width, height, fmt->format.width, fmt->format.height); -imx219_update_pad_format (imx219, mode, &fmt->format, fmt->format.code); + fmt->format.code =imx219_get_format_code (imx219, fmt->format.code); + fmt->format.width = mode->width; + fmt->format.height = mode->height; + fmt->format.field =V4L2_FIELD_NONE ; + fmt->format.colorspace =V4L2_COLORSPACE_RAW ; + fmt->format.ycbcr_enc =V4L2_YCBCR_ENC_601 ; + fmt->format.quantization =V4L2_QUANTIZATION_FULL_RANGE ; + fmt->format.xfer_func =V4L2_XFER_FUNC_NONE ; + *format = fmt->format;/*
Signature · 1 line
2.47.3