Skip to content

Commit 859969b

Browse files
Sakari Ailusmchehab
authored andcommitted
[media] v4l: Switch from V4L2 OF not V4L2 fwnode API
Switch users of the v4l2_of_ APIs to the more generic v4l2_fwnode_ APIs. Async OF matching is replaced by fwnode matching and OF matching support is removed. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Benoit Parrot <bparrot@ti.com> # i2c/ov2569.c, am437x/am437x-vpfe.c and ti-vpe/cal.c Tested-by: Hans Verkuil <hans.verkuil@cisco.com> # Atmel sama5d3 board + ov2640 sensor Tested-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
1 parent 048ea05 commit 859969b

35 files changed

Lines changed: 212 additions & 175 deletions

‎drivers/media/i2c/Kconfig‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ config VIDEO_ADV7604
209209
depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
210210
depends on GPIOLIB || COMPILE_TEST
211211
select HDMI
212+
select V4L2_FWNODE
212213
---help---
213214
Support for the Analog Devices ADV7604 video decoder.
214215

@@ -322,6 +323,7 @@ config VIDEO_TC358743
322323
tristate "Toshiba TC358743 decoder"
323324
depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
324325
select HDMI
326+
select V4L2_FWNODE
325327
---help---
326328
Support for the Toshiba TC358743 HDMI to MIPI CSI-2 bridge.
327329

@@ -331,6 +333,7 @@ config VIDEO_TC358743
331333
config VIDEO_TVP514X
332334
tristate "Texas Instruments TVP514x video decoder"
333335
depends on VIDEO_V4L2 && I2C
336+
select V4L2_FWNODE
334337
---help---
335338
This is a Video4Linux2 sensor-level driver for the TI TVP5146/47
336339
decoder. It is currently working with the TI OMAP3 camera
@@ -342,6 +345,7 @@ config VIDEO_TVP514X
342345
config VIDEO_TVP5150
343346
tristate "Texas Instruments TVP5150 video decoder"
344347
depends on VIDEO_V4L2 && I2C
348+
select V4L2_FWNODE
345349
---help---
346350
Support for the Texas Instruments TVP5150 video decoder.
347351

@@ -351,6 +355,7 @@ config VIDEO_TVP5150
351355
config VIDEO_TVP7002
352356
tristate "Texas Instruments TVP7002 video decoder"
353357
depends on VIDEO_V4L2 && I2C
358+
select V4L2_FWNODE
354359
---help---
355360
Support for the Texas Instruments TVP7002 video decoder.
356361

@@ -532,6 +537,7 @@ config VIDEO_OV2659
532537
tristate "OmniVision OV2659 sensor support"
533538
depends on VIDEO_V4L2 && I2C
534539
depends on MEDIA_CAMERA_SUPPORT
540+
select V4L2_FWNODE
535541
---help---
536542
This is a Video4Linux2 sensor-level driver for the OmniVision
537543
OV2659 camera.
@@ -544,6 +550,7 @@ config VIDEO_OV5645
544550
depends on OF
545551
depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
546552
depends on MEDIA_CAMERA_SUPPORT
553+
select V4L2_FWNODE
547554
---help---
548555
This is a Video4Linux2 sensor-level driver for the OmniVision
549556
OV5645 camera.
@@ -555,6 +562,7 @@ config VIDEO_OV5647
555562
tristate "OmniVision OV5647 sensor support"
556563
depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
557564
depends on MEDIA_CAMERA_SUPPORT
565+
select V4L2_FWNODE
558566
---help---
559567
This is a Video4Linux2 sensor-level driver for the OmniVision
560568
OV5647 camera.
@@ -647,6 +655,7 @@ config VIDEO_MT9V032
647655
depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
648656
depends on MEDIA_CAMERA_SUPPORT
649657
select REGMAP_I2C
658+
select V4L2_FWNODE
650659
---help---
651660
This is a Video4Linux2 sensor-level driver for the Micron
652661
MT9V032 752x480 CMOS sensor.
@@ -694,6 +703,7 @@ config VIDEO_S5K4ECGX
694703
config VIDEO_S5K5BAF
695704
tristate "Samsung S5K5BAF sensor support"
696705
depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
706+
select V4L2_FWNODE
697707
---help---
698708
This is a V4L2 sensor-level driver for Samsung S5K5BAF 2M
699709
camera sensor with an embedded SoC image signal processor.
@@ -704,6 +714,7 @@ source "drivers/media/i2c/et8ek8/Kconfig"
704714
config VIDEO_S5C73M3
705715
tristate "Samsung S5C73M3 sensor support"
706716
depends on I2C && SPI && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
717+
select V4L2_FWNODE
707718
---help---
708719
This is a V4L2 sensor-level driver for Samsung S5C73M3
709720
8 Mpixel camera.

‎drivers/media/i2c/adv7604.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <linux/i2c.h>
3434
#include <linux/kernel.h>
3535
#include <linux/module.h>
36+
#include <linux/of_graph.h>
3637
#include <linux/slab.h>
3738
#include <linux/v4l2-dv-timings.h>
3839
#include <linux/videodev2.h>
@@ -45,7 +46,7 @@
4546
#include <media/v4l2-device.h>
4647
#include <media/v4l2-event.h>
4748
#include <media/v4l2-dv-timings.h>
48-
#include <media/v4l2-of.h>
49+
#include <media/v4l2-fwnode.h>
4950

5051
static int debug;
5152
module_param(debug, int, 0644);
@@ -3069,7 +3070,7 @@ MODULE_DEVICE_TABLE(of, adv76xx_of_id);
30693070

30703071
static int adv76xx_parse_dt(struct adv76xx_state *state)
30713072
{
3072-
struct v4l2_of_endpoint bus_cfg;
3073+
struct v4l2_fwnode_endpoint bus_cfg;
30733074
struct device_node *endpoint;
30743075
struct device_node *np;
30753076
unsigned int flags;
@@ -3083,7 +3084,7 @@ static int adv76xx_parse_dt(struct adv76xx_state *state)
30833084
if (!endpoint)
30843085
return -EINVAL;
30853086

3086-
ret = v4l2_of_parse_endpoint(endpoint, &bus_cfg);
3087+
ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(endpoint), &bus_cfg);
30873088
if (ret) {
30883089
of_node_put(endpoint);
30893090
return ret;

‎drivers/media/i2c/mt9v032.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/log2.h>
2020
#include <linux/mutex.h>
2121
#include <linux/of.h>
22+
#include <linux/of_graph.h>
2223
#include <linux/regmap.h>
2324
#include <linux/slab.h>
2425
#include <linux/videodev2.h>
@@ -28,7 +29,7 @@
2829
#include <media/i2c/mt9v032.h>
2930
#include <media/v4l2-ctrls.h>
3031
#include <media/v4l2-device.h>
31-
#include <media/v4l2-of.h>
32+
#include <media/v4l2-fwnode.h>
3233
#include <media/v4l2-subdev.h>
3334

3435
/* The first four rows are black rows. The active area spans 753x481 pixels. */
@@ -979,7 +980,7 @@ static struct mt9v032_platform_data *
979980
mt9v032_get_pdata(struct i2c_client *client)
980981
{
981982
struct mt9v032_platform_data *pdata = NULL;
982-
struct v4l2_of_endpoint endpoint;
983+
struct v4l2_fwnode_endpoint endpoint;
983984
struct device_node *np;
984985
struct property *prop;
985986

@@ -990,7 +991,7 @@ mt9v032_get_pdata(struct i2c_client *client)
990991
if (!np)
991992
return NULL;
992993

993-
if (v4l2_of_parse_endpoint(np, &endpoint) < 0)
994+
if (v4l2_fwnode_endpoint_parse(of_fwnode_handle(np), &endpoint) < 0)
994995
goto done;
995996

996997
pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);

‎drivers/media/i2c/ov2659.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@
4242
#include <media/v4l2-ctrls.h>
4343
#include <media/v4l2-device.h>
4444
#include <media/v4l2-event.h>
45+
#include <media/v4l2-fwnode.h>
4546
#include <media/v4l2-image-sizes.h>
4647
#include <media/v4l2-mediabus.h>
47-
#include <media/v4l2-of.h>
4848
#include <media/v4l2-subdev.h>
4949

5050
#define DRIVER_NAME "ov2659"
@@ -1347,7 +1347,7 @@ static struct ov2659_platform_data *
13471347
ov2659_get_pdata(struct i2c_client *client)
13481348
{
13491349
struct ov2659_platform_data *pdata;
1350-
struct v4l2_of_endpoint *bus_cfg;
1350+
struct v4l2_fwnode_endpoint *bus_cfg;
13511351
struct device_node *endpoint;
13521352

13531353
if (!IS_ENABLED(CONFIG_OF) || !client->dev.of_node)
@@ -1357,7 +1357,7 @@ ov2659_get_pdata(struct i2c_client *client)
13571357
if (!endpoint)
13581358
return NULL;
13591359

1360-
bus_cfg = v4l2_of_alloc_parse_endpoint(endpoint);
1360+
bus_cfg = v4l2_fwnode_endpoint_alloc_parse(of_fwnode_handle(endpoint));
13611361
if (IS_ERR(bus_cfg)) {
13621362
pdata = NULL;
13631363
goto done;
@@ -1377,7 +1377,7 @@ ov2659_get_pdata(struct i2c_client *client)
13771377
pdata->link_frequency = bus_cfg->link_frequencies[0];
13781378

13791379
done:
1380-
v4l2_of_free_endpoint(bus_cfg);
1380+
v4l2_fwnode_endpoint_free(bus_cfg);
13811381
of_node_put(endpoint);
13821382
return pdata;
13831383
}

‎drivers/media/i2c/ov5645.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#include <linux/slab.h>
4040
#include <linux/types.h>
4141
#include <media/v4l2-ctrls.h>
42-
#include <media/v4l2-of.h>
42+
#include <media/v4l2-fwnode.h>
4343
#include <media/v4l2-subdev.h>
4444

4545
#define OV5645_VOLTAGE_ANALOG 2800000
@@ -87,7 +87,7 @@ struct ov5645 {
8787
struct device *dev;
8888
struct v4l2_subdev sd;
8989
struct media_pad pad;
90-
struct v4l2_of_endpoint ep;
90+
struct v4l2_fwnode_endpoint ep;
9191
struct v4l2_mbus_framefmt fmt;
9292
struct v4l2_rect crop;
9393
struct clk *xclk;
@@ -1102,7 +1102,8 @@ static int ov5645_probe(struct i2c_client *client,
11021102
return -EINVAL;
11031103
}
11041104

1105-
ret = v4l2_of_parse_endpoint(endpoint, &ov5645->ep);
1105+
ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(endpoint),
1106+
&ov5645->ep);
11061107
if (ret < 0) {
11071108
dev_err(dev, "parsing endpoint node failed\n");
11081109
return ret;

‎drivers/media/i2c/ov5647.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@
2525
#include <linux/init.h>
2626
#include <linux/io.h>
2727
#include <linux/module.h>
28+
#include <linux/of_graph.h>
2829
#include <linux/slab.h>
2930
#include <linux/videodev2.h>
3031
#include <media/v4l2-device.h>
32+
#include <media/v4l2-fwnode.h>
3133
#include <media/v4l2-image-sizes.h>
3234
#include <media/v4l2-mediabus.h>
33-
#include <media/v4l2-of.h>
3435

3536
#define SENSOR_NAME "ov5647"
3637

@@ -510,7 +511,7 @@ static const struct v4l2_subdev_internal_ops ov5647_subdev_internal_ops = {
510511

511512
static int ov5647_parse_dt(struct device_node *np)
512513
{
513-
struct v4l2_of_endpoint bus_cfg;
514+
struct v4l2_fwnode_endpoint bus_cfg;
514515
struct device_node *ep;
515516

516517
int ret;
@@ -519,7 +520,7 @@ static int ov5647_parse_dt(struct device_node *np)
519520
if (!ep)
520521
return -EINVAL;
521522

522-
ret = v4l2_of_parse_endpoint(ep, &bus_cfg);
523+
ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(ep), &bus_cfg);
523524

524525
of_node_put(ep);
525526
return ret;

‎drivers/media/i2c/s5c73m3/s5c73m3-core.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/media.h>
2525
#include <linux/module.h>
2626
#include <linux/of_gpio.h>
27+
#include <linux/of_graph.h>
2728
#include <linux/regulator/consumer.h>
2829
#include <linux/sizes.h>
2930
#include <linux/slab.h>
@@ -35,7 +36,7 @@
3536
#include <media/v4l2-subdev.h>
3637
#include <media/v4l2-mediabus.h>
3738
#include <media/i2c/s5c73m3.h>
38-
#include <media/v4l2-of.h>
39+
#include <media/v4l2-fwnode.h>
3940

4041
#include "s5c73m3.h"
4142

@@ -1602,7 +1603,7 @@ static int s5c73m3_get_platform_data(struct s5c73m3 *state)
16021603
const struct s5c73m3_platform_data *pdata = dev->platform_data;
16031604
struct device_node *node = dev->of_node;
16041605
struct device_node *node_ep;
1605-
struct v4l2_of_endpoint ep;
1606+
struct v4l2_fwnode_endpoint ep;
16061607
int ret;
16071608

16081609
if (!node) {
@@ -1639,7 +1640,7 @@ static int s5c73m3_get_platform_data(struct s5c73m3 *state)
16391640
return 0;
16401641
}
16411642

1642-
ret = v4l2_of_parse_endpoint(node_ep, &ep);
1643+
ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(node_ep), &ep);
16431644
of_node_put(node_ep);
16441645
if (ret)
16451646
return ret;

‎drivers/media/i2c/s5k5baf.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include <media/v4l2-device.h>
3131
#include <media/v4l2-subdev.h>
3232
#include <media/v4l2-mediabus.h>
33-
#include <media/v4l2-of.h>
33+
#include <media/v4l2-fwnode.h>
3434

3535
static int debug;
3636
module_param(debug, int, 0644);
@@ -1841,7 +1841,7 @@ static int s5k5baf_parse_device_node(struct s5k5baf *state, struct device *dev)
18411841
{
18421842
struct device_node *node = dev->of_node;
18431843
struct device_node *node_ep;
1844-
struct v4l2_of_endpoint ep;
1844+
struct v4l2_fwnode_endpoint ep;
18451845
int ret;
18461846

18471847
if (!node) {
@@ -1868,7 +1868,7 @@ static int s5k5baf_parse_device_node(struct s5k5baf *state, struct device *dev)
18681868
return -EINVAL;
18691869
}
18701870

1871-
ret = v4l2_of_parse_endpoint(node_ep, &ep);
1871+
ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(node_ep), &ep);
18721872
of_node_put(node_ep);
18731873
if (ret)
18741874
return ret;

‎drivers/media/i2c/smiapp/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ config VIDEO_SMIAPP
33
depends on I2C && VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API && HAVE_CLK
44
depends on MEDIA_CAMERA_SUPPORT
55
select VIDEO_SMIAPP_PLL
6+
select V4L2_FWNODE
67
---help---
78
This is a generic driver for SMIA++/SMIA camera modules.

‎drivers/media/i2c/smiapp/smiapp-core.c‎

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@
2727
#include <linux/gpio/consumer.h>
2828
#include <linux/module.h>
2929
#include <linux/pm_runtime.h>
30+
#include <linux/property.h>
3031
#include <linux/regulator/consumer.h>
3132
#include <linux/slab.h>
3233
#include <linux/smiapp.h>
3334
#include <linux/v4l2-mediabus.h>
35+
#include <media/v4l2-fwnode.h>
3436
#include <media/v4l2-device.h>
35-
#include <media/v4l2-of.h>
3637

3738
#include "smiapp.h"
3839

@@ -2784,19 +2785,20 @@ static int __maybe_unused smiapp_resume(struct device *dev)
27842785
static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev)
27852786
{
27862787
struct smiapp_hwconfig *hwcfg;
2787-
struct v4l2_of_endpoint *bus_cfg;
2788-
struct device_node *ep;
2788+
struct v4l2_fwnode_endpoint *bus_cfg;
2789+
struct fwnode_handle *ep;
2790+
struct fwnode_handle *fwnode = dev_fwnode(dev);
27892791
int i;
27902792
int rval;
27912793

2792-
if (!dev->of_node)
2794+
if (!fwnode)
27932795
return dev->platform_data;
27942796

2795-
ep = of_graph_get_next_endpoint(dev->of_node, NULL);
2797+
ep = fwnode_graph_get_next_endpoint(fwnode, NULL);
27962798
if (!ep)
27972799
return NULL;
27982800

2799-
bus_cfg = v4l2_of_alloc_parse_endpoint(ep);
2801+
bus_cfg = v4l2_fwnode_endpoint_alloc_parse(ep);
28002802
if (IS_ERR(bus_cfg))
28012803
goto out_err;
28022804

@@ -2817,11 +2819,10 @@ static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev)
28172819
dev_dbg(dev, "lanes %u\n", hwcfg->lanes);
28182820

28192821
/* NVM size is not mandatory */
2820-
of_property_read_u32(dev->of_node, "nokia,nvm-size",
2821-
&hwcfg->nvm_size);
2822+
fwnode_property_read_u32(fwnode, "nokia,nvm-size", &hwcfg->nvm_size);
28222823

2823-
rval = of_property_read_u32(dev->of_node, "clock-frequency",
2824-
&hwcfg->ext_clk);
2824+
rval = fwnode_property_read_u32(fwnode, "clock-frequency",
2825+
&hwcfg->ext_clk);
28252826
if (rval) {
28262827
dev_warn(dev, "can't get clock-frequency\n");
28272828
goto out_err;
@@ -2846,13 +2847,13 @@ static struct smiapp_hwconfig *smiapp_get_hwconfig(struct device *dev)
28462847
dev_dbg(dev, "freq %d: %lld\n", i, hwcfg->op_sys_clock[i]);
28472848
}
28482849

2849-
v4l2_of_free_endpoint(bus_cfg);
2850-
of_node_put(ep);
2850+
v4l2_fwnode_endpoint_free(bus_cfg);
2851+
fwnode_handle_put(ep);
28512852
return hwcfg;
28522853

28532854
out_err:
2854-
v4l2_of_free_endpoint(bus_cfg);
2855-
of_node_put(ep);
2855+
v4l2_fwnode_endpoint_free(bus_cfg);
2856+
fwnode_handle_put(ep);
28562857
return NULL;
28572858
}
28582859

0 commit comments

Comments
 (0)