media: ov5640: Register device properties
authorJacopo Mondi <jacopo@jmondi.org>
Fri, 13 May 2022 14:14:10 +0000 (15:14 +0100)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Fri, 8 Jul 2022 14:34:18 +0000 (15:34 +0100)
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@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/i2c/ov5640.c

index f7d1bf1..14e42bb 100644 (file)
@@ -3347,6 +3347,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;
        const struct ov5640_timings *timings;
        unsigned int max_vblank;
        unsigned int hblank;
@@ -3426,6 +3427,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;
@@ -3690,7 +3702,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);
@@ -3714,22 +3725,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) {