Align CCS driver behaviour regarding flipping and rotation
Subsystems (2)
Sakari Ailus
maintainercover Align CCS driver behaviour regarding flipping and rotation
Hi,
This set aligns the behaviour of flipping controls with other drivers and adds CAMERA_SENSOR_ROTATION and CAMERA_SENSOR_ORIENTATION controls to the CCS driver.
The changes to flipping are that the flipping controls are no longer inverted if the sensor is mounted upside down. The flipping control still default enabled if the sensor is so mounted.
Sakari Ailus (2):
media: ccs: Align flipping behaviour with other drivers
media: ccs: Add V4L2 controls from properties
drivers/media/i2c/ccs/ccs-core.c | 56 ++++++++------------------------ drivers/media/i2c/ccs/ccs.h | 14 -------- 2 files changed, 13 insertions(+), 57 deletions(-)
Signature · 1 line
2.30.2
Sakari Ailus
maintainerPATCH 1/2 media: ccs: Align flipping behaviour with other drivers
No longer mirror flipping controls if the sensor is mounted upside down. Instead, change the default flip control values.
This way the behaviour of the flipping controls and rotation of the sensor are aligned with the rest of the drivers.
--- drivers/media/i2c/ccs/ccs-core.c | 29 ++++------------------------- drivers/media/i2c/ccs/ccs.h | 1 - 2 files changed, 4 insertions(+), 26 deletions(-)
drivers/media/i2c/ccs/ccs-core.c +4 -25
@@ -569,8 +569,6 @@ static u32 ccs_pixel_order(struct ccs_sensor *sensor) flip |=CCS_IMAGE_ORIENTATION_VERTICAL_FLIP ; } - flip ^= sensor->hvflip_inv_mask; -dev_dbg (&client->dev,"flip %u\n" , flip);return sensor->default_pixel_order ^ flip; }
@@ -632,8 +630,6 @@ static int ccs_set_ctrl(struct v4l2_ctrl *ctrl)if (sensor->vflip->val) orient |=CCS_IMAGE_ORIENTATION_VERTICAL_FLIP ; - orient ^= sensor->hvflip_inv_mask; -ccs_update_mbus_formats (sensor);break ;
@@ -800,6 +796,8 @@ 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 ;int rval; rval =v4l2_ctrl_handler_init (&sensor->pixel_array->ctrl_handler,17 );
@@ -948,10 +946,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 ,0 ); +V4L2_CID_HFLIP ,0 ,1 ,1 , default_flip); sensor->vflip =v4l2_ctrl_new_std ( &sensor->pixel_array->ctrl_handler, &ccs_ctrl_ops, -V4L2_CID_VFLIP ,0 ,1 ,1 ,0 ); +V4L2_CID_VFLIP ,0 ,1 ,1 , default_flip); sensor->vblank = v4l2_ctrl_new_std( &sensor->pixel_array->ctrl_handler, &ccs_ctrl_ops,
@@ -3437,25 +3435,6 @@ static int ccs_probe(struct i2c_client *client)if (rval <0 ) goto out_free_ccs_limits; -/* -* Handle Sensor Module orientation on the board. -* -* The application of H-FLIP and V-FLIP on the sensor is modified by -* the sensor orientation on the board. -* -* For CCS_BOARD_SENSOR_ORIENT_180 the default behaviour is to set -* both H-FLIP and V-FLIP for normal operation which also implies -* that a set/unset operation for user space HFLIP and VFLIP v4l2 -* controls will need to be internally inverted. -* -* Rotation also changes the bayer pattern. -*/ -if (sensor->hwcfg.module_board_orient == -CCS_MODULE_BOARD_ORIENT_180 ) - sensor->hvflip_inv_mask = -CCS_IMAGE_ORIENTATION_HORIZONTAL_MIRROR | -CCS_IMAGE_ORIENTATION_VERTICAL_FLIP ; - rval =ccs_call_quirk (sensor, limits);if (rval) {dev_err (&client->dev,"limits quirks failed\n" );
drivers/media/i2c/ccs/ccs.h +0 -1
@@ -243,7 +243,6 @@ struct ccs_sensor {u8 scale_m;u8 scaling_mode; -u8 hvflip_inv_mask;/* H/VFLIP inversion due to sensor orientation */ u8 frame_skip;u16 embedded_start;/* embedded data start line */ u16 embedded_end;
Signature · 1 line
2.30.2
Re: [PATCH 1/2] media: ccs: Align flipping behaviour with other drivers
Hi Sakari
Quoted 35 lines · Sakari Ailus
No longer mirror flipping controls if the sensor is mounted upside down. Instead, change the default flip control values.
This way the behaviour of the flipping controls and rotation of the sensor are aligned with the rest of the drivers.
Signed-off-by Sakari Ailus <[email protected]>--- drivers/media/i2c/ccs/ccs-core.c | 29 ++++------------------------- drivers/media/i2c/ccs/ccs.h | 1 - 2 files changed, 4 insertions(+), 26 deletions(-)drivers/media/i2c/ccs/ccs-core.c +0
-4@@ -569,8 +569,6 @@ static u32 ccs_pixel_order(struct ccs_sensor *sensor) flip |=CCS_IMAGE_ORIENTATION_VERTICAL_FLIP ; } - flip ^= sensor->hvflip_inv_mask; -dev_dbg (&client->dev,"flip %u\n" , flip);return sensor->default_pixel_order ^ flip; }@@ -632,8 +630,6 @@ static int ccs_set_ctrl(struct v4l2_ctrl *ctrl)if (sensor->vflip->val) orient |=CCS_IMAGE_ORIENTATION_VERTICAL_FLIP ; - orient ^= sensor->hvflip_inv_mask; -ccs_update_mbus_formats (sensor);break ;
drivers/media/i2c/ccs/ccs-core.c static const struct v4l2_ctrl_ops ccs_ctrl_ops = { · line 799
Quoted 4 lines
drivers/media/i2c/ccs/ccs-core.c +1
-0@@ -800,6 +796,8 @@ 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 ==
I think there's something wrong here :)
drivers/media/i2c/ccs/ccs-core.c static const struct v4l2_ctrl_ops ccs_ctrl_ops = { · line 800
Quoted 1 line
drivers/media/i2c/ccs/ccs-core.c +1
-0+CCS_MODULE_BOARD_ORIENT_180 ;
I would also be tempted to suggest dropping module_board_orient completely and store the rotation value directly. But then you would have to compare it to "180", "0" etc etc. Maybe it's not a good idea.
Or maybe instead of removing hvflip_inv_mask you could keep it and remove module_board_orient instead, so that v and h flips can be considered in isolation.
The rest of the patch looks good to me
Thanks
j
Quoted 57 lines
drivers/media/i2c/ccs/ccs-core.c +2
-21int rval; rval =v4l2_ctrl_handler_init (&sensor->pixel_array->ctrl_handler,17 );@@ -948,10 +946,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 ,0 ); +V4L2_CID_HFLIP ,0 ,1 ,1 , default_flip); sensor->vflip =v4l2_ctrl_new_std ( &sensor->pixel_array->ctrl_handler, &ccs_ctrl_ops, -V4L2_CID_VFLIP ,0 ,1 ,1 ,0 ); +V4L2_CID_VFLIP ,0 ,1 ,1 , default_flip); sensor->vblank = v4l2_ctrl_new_std( &sensor->pixel_array->ctrl_handler, &ccs_ctrl_ops,@@ -3437,25 +3435,6 @@ static int ccs_probe(struct i2c_client *client)if (rval <0 ) goto out_free_ccs_limits; -/* -* Handle Sensor Module orientation on the board. -* -* The application of H-FLIP and V-FLIP on the sensor is modified by -* the sensor orientation on the board. -* -* For CCS_BOARD_SENSOR_ORIENT_180 the default behaviour is to set -* both H-FLIP and V-FLIP for normal operation which also implies -* that a set/unset operation for user space HFLIP and VFLIP v4l2 -* controls will need to be internally inverted. -* -* Rotation also changes the bayer pattern. -*/ -if (sensor->hwcfg.module_board_orient == -CCS_MODULE_BOARD_ORIENT_180 ) - sensor->hvflip_inv_mask = -CCS_IMAGE_ORIENTATION_HORIZONTAL_MIRROR | -CCS_IMAGE_ORIENTATION_VERTICAL_FLIP ; - rval =ccs_call_quirk (sensor, limits);if (rval) {dev_err (&client->dev,"limits quirks failed\n" );drivers/media/i2c/ccs/ccs.h +0
-2@@ -243,7 +243,6 @@ struct ccs_sensor {u8 scale_m;u8 scaling_mode; -u8 hvflip_inv_mask;/* H/VFLIP inversion due to sensor orientation */ u8 frame_skip;u16 embedded_start;/* embedded data start line */ u16 embedded_end; --2.30.2
Sakari Ailus
maintainerPATCH 2/2 media: ccs: Add V4L2 controls from properties
In reply to Sakari AilusAdd V4L2 controls (currently CAMERA_SENSOR_ROTATION and CAMERA_SENSOR_ORIENTATION) from properties.
--- drivers/media/i2c/ccs/ccs-core.c | 35 ++++++++++++-------------------- drivers/media/i2c/ccs/ccs.h | 13 ------------ 2 files changed, 13 insertions(+), 35 deletions(-)
drivers/media/i2c/ccs/ccs-core.c +13 -22
@@ -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)
drivers/media/i2c/ccs/ccs.h +0 -13
@@ -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; };
Signature · 1 line
2.30.2
Re: [PATCH 2/2] media: ccs: Add V4L2 controls from properties
Hi Sakari
Quoted 42 lines · Sakari Ailus
Add V4L2 controls (currently
CAMERA_SENSOR_ROTATIONandCAMERA_SENSOR_ORIENTATION) from properties.Signed-off-by Sakari Ailus <[email protected]>--- drivers/media/i2c/ccs/ccs-core.c | 35 ++++++++++++-------------------- drivers/media/i2c/ccs/ccs.h | 13 ------------ 2 files changed, 13 insertions(+), 35 deletions(-)drivers/media/i2c/ccs/ccs-core.c +11
-3@@ -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 {
drivers/media/i2c/ccs/ccs-core.c static int ccs_init_controls(struct ccs_sensor *sensor) · line 957
Quoted 5 lines
drivers/media/i2c/ccs/ccs-core.c +1
-1@@ -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 );
Ah! ignore my comments on 1/2 :)
Thanks
j
Quoted 72 lines
drivers/media/i2c/ccs/ccs-core.c +1
-18sensor->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)drivers/media/i2c/ccs/ccs.h +0
-14@@ -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
Sakari Ailus
maintainerRe: [PATCH 2/2] media: ccs: Add V4L2 controls from properties
Quoted 10 lines · Jacopo Mondi
drivers/media/i2c/ccs/ccs-core.c static int ccs_init_controls(struct ccs_sensor *sensor) · line 957
Quoted 6 lines
drivers/media/i2c/ccs/ccs-core.c +1
-1@@ -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 );Ah! ignore my comments on 1/2 :)
Reviewed-by Jacopo Mondi <[email protected]>
Thanks, Jacopo!
Could you also check the documentation patch?
I suppose we'll be good after this one? Or are there still drivers that have differing behaviour?
Signature · 1 line
Sakari Ailus