Hi Jacopo, Thank you for the patch. On Mon, Jan 31, 2022 at 03:45:27PM +0100, Jacopo Mondi wrote: > Parse the device properties and register the rotation and orientation > V4L2 controls using v4l2_ctrl_new_fwnode_properties(). > > Remove the open-coded parsing of the rotation property and assume the > DTS is correct is providing either <0> or <180> as possible rotations. > > Signed-off-by: Jacopo Mondi <jacopo@xxxxxxxxxx> Reviewed-by: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx> > --- > drivers/media/i2c/ov5640.c | 29 ++++++++++++----------------- > 1 file changed, 12 insertions(+), 17 deletions(-) > > diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c > index 28da0ddd2a06..9d6eb3288b07 100644 > --- a/drivers/media/i2c/ov5640.c > +++ b/drivers/media/i2c/ov5640.c > @@ -3164,6 +3164,7 @@ static int ov5640_init_controls(struct ov5640_dev *sensor) > const struct v4l2_ctrl_ops *ops = &ov5640_ctrl_ops; > struct ov5640_ctrls *ctrls = &sensor->ctrls; > struct v4l2_ctrl_handler *hdl = &ctrls->handler; > + struct v4l2_fwnode_device_properties props; > unsigned int max_vblank; > unsigned int hblank; > int ret; > @@ -3240,6 +3241,17 @@ static int ov5640_init_controls(struct ov5640_dev *sensor) > goto free_ctrls; > } > > + ret = v4l2_fwnode_device_parse(&sensor->i2c_client->dev, &props); > + if (ret) > + goto free_ctrls; > + > + if (props.rotation == 180) > + sensor->upside_down = true; > + > + ret = v4l2_ctrl_new_fwnode_properties(hdl, ops, &props); > + if (ret) > + goto free_ctrls; > + > ctrls->pixel_rate->flags |= V4L2_CTRL_FLAG_READ_ONLY; > ctrls->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY; > ctrls->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY; > @@ -3512,7 +3524,6 @@ static int ov5640_probe(struct i2c_client *client) > struct device *dev = &client->dev; > struct fwnode_handle *endpoint; > struct ov5640_dev *sensor; > - u32 rotation; > int ret; > > sensor = devm_kzalloc(dev, sizeof(*sensor), GFP_KERNEL); > @@ -3535,22 +3546,6 @@ static int ov5640_probe(struct i2c_client *client) > > sensor->ae_target = 52; > > - /* optional indication of physical rotation of sensor */ > - ret = fwnode_property_read_u32(dev_fwnode(&client->dev), "rotation", > - &rotation); > - if (!ret) { > - switch (rotation) { > - case 180: > - sensor->upside_down = true; > - fallthrough; > - case 0: > - break; > - default: > - dev_warn(dev, "%u degrees rotation is not supported, ignoring...\n", > - rotation); > - } > - } > - > endpoint = fwnode_graph_get_next_endpoint(dev_fwnode(&client->dev), > NULL); > if (!endpoint) { -- Regards, Laurent Pinchart