10f5512b6a4b37edaf0f3964750acf0294c8e151
[openwrt/staging/chunkeey.git] / target / linux / bcm27xx / patches-5.10 / 950-0296-media-i2c-ov5647-Parse-and-register-properties.patch
1 From 0f0998ed9620f676ee78eb6f606b0b2fa118bf68 Mon Sep 17 00:00:00 2001
2 From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
3 Date: Sat, 4 Jul 2020 01:45:08 +0300
4 Subject: [PATCH] media: i2c: ov5647: Parse and register properties
5
6 Parse device properties and register controls for them using the V4L2
7 fwnode properties helpers.
8
9 Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
10 ---
11 drivers/media/i2c/ov5647.c | 13 ++++++++++++-
12 1 file changed, 12 insertions(+), 1 deletion(-)
13
14 --- a/drivers/media/i2c/ov5647.c
15 +++ b/drivers/media/i2c/ov5647.c
16 @@ -1501,6 +1501,7 @@ static int ov5647_probe(struct i2c_clien
17 struct device_node *np = client->dev.of_node;
18 u32 xclk_freq;
19 int hblank, exposure_max, exposure_def;
20 + struct v4l2_fwnode_device_properties props;
21
22 sensor = devm_kzalloc(dev, sizeof(*sensor), GFP_KERNEL);
23 if (!sensor)
24 @@ -1534,7 +1535,7 @@ static int ov5647_probe(struct i2c_clien
25 mutex_init(&sensor->lock);
26
27 /* Initialise controls. */
28 - v4l2_ctrl_handler_init(&sensor->ctrls, 7);
29 + v4l2_ctrl_handler_init(&sensor->ctrls, 9);
30 v4l2_ctrl_new_std(&sensor->ctrls, &ov5647_ctrl_ops,
31 V4L2_CID_AUTOGAIN,
32 0, /* min */
33 @@ -1598,6 +1599,16 @@ static int ov5647_probe(struct i2c_clien
34 __func__, ret);
35 goto error;
36 }
37 +
38 + ret = v4l2_fwnode_device_parse(&client->dev, &props);
39 + if (ret)
40 + goto error;
41 +
42 + ret = v4l2_ctrl_new_fwnode_properties(&sensor->ctrls, &ov5647_ctrl_ops,
43 + &props);
44 + if (ret)
45 + goto error;
46 +
47 sensor->sd.ctrl_handler = &sensor->ctrls;
48
49 /* Write out the register set over I2C on stream-on. */