Add V4L2 controls (currently CAMERA_SENSOR_ROTATION and CAMERA_SENSOR_ORIENTATION) from properties. Signed-off-by: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx> --- drivers/media/i2c/ccs/ccs-core.c | 35 ++++++++++++-------------------- drivers/media/i2c/ccs/ccs.h | 13 ------------ 2 files changed, 13 insertions(+), 35 deletions(-) diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c index 431dd7d24cdc..b08938f42f61 100644 --- a/drivers/media/i2c/ccs/ccs-core.c +++ b/drivers/media/i2c/ccs/ccs-core.c @@ -796,16 +796,24 @@ static const struct v4l2_ctrl_ops ccs_ctrl_ops = { static int ccs_init_controls(struct ccs_sensor *sensor) { struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); - int default_flip sensor->hwcfg.module_board_orient == - CCS_MODULE_BOARD_ORIENT_180; + struct v4l2_fwnode_device_properties props; int rval; - rval = v4l2_ctrl_handler_init(&sensor->pixel_array->ctrl_handler, 17); + rval = v4l2_ctrl_handler_init(&sensor->pixel_array->ctrl_handler, 19); if (rval) return rval; sensor->pixel_array->ctrl_handler.lock = &sensor->mutex; + rval = v4l2_fwnode_device_parse(&client->dev, &props); + if (rval) + return rval; + + rval = v4l2_ctrl_new_fwnode_properties(&sensor->pixel_array->ctrl_handler, + &ccs_ctrl_ops, &props); + if (rval) + return rval; + switch (CCS_LIM(sensor, ANALOG_GAIN_CAPABILITY)) { case CCS_ANALOG_GAIN_CAPABILITY_GLOBAL: { struct { @@ -946,10 +954,10 @@ static int ccs_init_controls(struct ccs_sensor *sensor) sensor->hflip = v4l2_ctrl_new_std( &sensor->pixel_array->ctrl_handler, &ccs_ctrl_ops, - V4L2_CID_HFLIP, 0, 1, 1, default_flip); + V4L2_CID_HFLIP, 0, 1, 1, props.rotation == 180); sensor->vflip = v4l2_ctrl_new_std( &sensor->pixel_array->ctrl_handler, &ccs_ctrl_ops, - V4L2_CID_VFLIP, 0, 1, 1, default_flip); + V4L2_CID_VFLIP, 0, 1, 1, props.rotation == 180); sensor->vblank = v4l2_ctrl_new_std( &sensor->pixel_array->ctrl_handler, &ccs_ctrl_ops, @@ -3183,7 +3191,6 @@ static int ccs_get_hwconfig(struct ccs_sensor *sensor, struct device *dev) struct v4l2_fwnode_endpoint bus_cfg = { .bus_type = V4L2_MBUS_UNKNOWN }; struct fwnode_handle *ep; struct fwnode_handle *fwnode = dev_fwnode(dev); - u32 rotation; unsigned int i; int rval; @@ -3222,22 +3229,6 @@ static int ccs_get_hwconfig(struct ccs_sensor *sensor, struct device *dev) goto out_err; } - rval = fwnode_property_read_u32(fwnode, "rotation", &rotation); - if (!rval) { - switch (rotation) { - case 180: - hwcfg->module_board_orient = - CCS_MODULE_BOARD_ORIENT_180; - fallthrough; - case 0: - break; - default: - dev_err(dev, "invalid rotation %u\n", rotation); - rval = -EINVAL; - goto out_err; - } - } - rval = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency", &hwcfg->ext_clk); if (rval) diff --git a/drivers/media/i2c/ccs/ccs.h b/drivers/media/i2c/ccs/ccs.h index ea8909f011d9..a94c796cea48 100644 --- a/drivers/media/i2c/ccs/ccs.h +++ b/drivers/media/i2c/ccs/ccs.h @@ -57,17 +57,6 @@ #define CCS_LIM_AT(sensor, limit, offset) \ ccs_get_limit(sensor, CCS_L_##limit, CCS_L_##limit##_OFFSET(offset)) -/* - * Sometimes due to board layout considerations the camera module can be - * mounted rotated. The typical rotation used is 180 degrees which can be - * corrected by giving a default H-FLIP and V-FLIP in the sensor readout. - * FIXME: rotation also changes the bayer pattern. - */ -enum ccs_module_board_orient { - CCS_MODULE_BOARD_ORIENT_0 = 0, - CCS_MODULE_BOARD_ORIENT_180, -}; - struct ccs_flash_strobe_parms { u8 mode; u32 strobe_width_high_us; @@ -90,8 +79,6 @@ struct ccs_hwconfig { u32 csi_signalling_mode; /* CCS_CSI_SIGNALLING_MODE_* */ u64 *op_sys_clock; - enum ccs_module_board_orient module_board_orient; - struct ccs_flash_strobe_parms *strobe_setup; }; -- 2.30.2