Commit 1066fc1c authored by Jacopo Mondi's avatar Jacopo Mondi Committed by Mauro Carvalho Chehab

media: ov5640: Register device properties

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: default avatarJacopo Mondi <jacopo@jmondi.org>
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent 66ed85eb
...@@ -3347,6 +3347,7 @@ static int ov5640_init_controls(struct ov5640_dev *sensor) ...@@ -3347,6 +3347,7 @@ static int ov5640_init_controls(struct ov5640_dev *sensor)
const struct v4l2_ctrl_ops *ops = &ov5640_ctrl_ops; const struct v4l2_ctrl_ops *ops = &ov5640_ctrl_ops;
struct ov5640_ctrls *ctrls = &sensor->ctrls; struct ov5640_ctrls *ctrls = &sensor->ctrls;
struct v4l2_ctrl_handler *hdl = &ctrls->handler; struct v4l2_ctrl_handler *hdl = &ctrls->handler;
struct v4l2_fwnode_device_properties props;
const struct ov5640_timings *timings; const struct ov5640_timings *timings;
unsigned int max_vblank; unsigned int max_vblank;
unsigned int hblank; unsigned int hblank;
...@@ -3426,6 +3427,17 @@ static int ov5640_init_controls(struct ov5640_dev *sensor) ...@@ -3426,6 +3427,17 @@ static int ov5640_init_controls(struct ov5640_dev *sensor)
goto free_ctrls; 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->pixel_rate->flags |= V4L2_CTRL_FLAG_READ_ONLY;
ctrls->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY; ctrls->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
ctrls->hblank->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) ...@@ -3690,7 +3702,6 @@ static int ov5640_probe(struct i2c_client *client)
struct device *dev = &client->dev; struct device *dev = &client->dev;
struct fwnode_handle *endpoint; struct fwnode_handle *endpoint;
struct ov5640_dev *sensor; struct ov5640_dev *sensor;
u32 rotation;
int ret; int ret;
sensor = devm_kzalloc(dev, sizeof(*sensor), GFP_KERNEL); sensor = devm_kzalloc(dev, sizeof(*sensor), GFP_KERNEL);
...@@ -3714,22 +3725,6 @@ static int ov5640_probe(struct i2c_client *client) ...@@ -3714,22 +3725,6 @@ static int ov5640_probe(struct i2c_client *client)
sensor->ae_target = 52; 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), endpoint = fwnode_graph_get_next_endpoint(dev_fwnode(&client->dev),
NULL); NULL);
if (!endpoint) { if (!endpoint) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment