mirror of
https://github.com/torvalds/linux.git
synced 2026-06-04 04:23:35 +02:00
media: ccs: Compute scaling configuration from sub-device state
Compute scaling configuration from sub-device state instead of storing it to the driver's device context struct. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
This commit is contained in:
parent
7858ac7a8a
commit
ce7b25c017
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user