Skip to contentSkip to conversation

media: tw9910: Allow to probe from device tree

RFC In review Fabio Estevam 4 participants 15 messages Aug 27, 2021 – Sep 17, 2021

Subsystems (5)
lore
Share & tools
lore

Fabio Estevam

author reviewer
#0 lore raw

RFC 1/3 media: tw9910: Allow to probe from device tree

Currently the driver only probes via platform data passed from board file.

Allow to probe from device tree too.

---
Hi,

I am currently sending this series as RFC because I was not able to get the TW9990 to work on a imx6sx board yet.

# media-ctl -p
Media controller API version 5.14.0

Media device information
------------------------
driver imx7-csi
model imx-media
serial
bus info
hw revision 0x0
driver version 5.14.0

Device topology
- entity 1: csi (2 pads, 2 links)

            type V4L2 subdev subtype Unknown flags 0
            device node name /dev/v4l-subdev0
	pad0: Sink
		[fmt:UYVY8_2X8/800x600 field:none colorspace:srgb xfer:srgb ycbcr:601 quantization:lim-range]
		<- "tw9910 2-0044":0 [ENABLED,IMMUTABLE]
	pad1: Source
		[fmt:UYVY8_2X8/800x600 field:none colorspace:srgb xfer:srgb ycbcr:601 quantization:lim-range]
		-> "csi capture":0 [ENABLED,IMMUTABLE]

- entity 4: csi capture (1 pad, 1 link)
type Node subtype V4L flags 0
device node name /dev/video0
pad0: Sink
<- "csi":1 [ENABLED,IMMUTABLE]

- entity 10: tw9910 2-0044 (1 pad, 1 link)

             type V4L2 subdev subtype Decoder flags 0
             device node name /dev/v4l-subdev1
	pad0: Source
		[fmt:UYVY8_2X8/640x480 field:interlaced-bt colorspace:smpte170m
		 crop.bounds:(0,0)/640x480
		 crop:(0,0)/640x480]
		-> "csi":0 [ENABLED,IMMUTABLE]

I get the following error when setting up the pipeline:

media-ctl -l "'tw9910 2-0044':0 -> 'csi':0[1]"
media-ctl -l "'csi':1 -> 'csi capture':0[1]"
media-ctl -v -V "'tw9910 2-0044':0 [fmt:UYVY8_2X8/800x480 field:any]"

Opening media device /dev/media0
Enumerating entities
Found 3 entities
Enumerating pads and links
Setting up format UYVY8_2X8 800x480 on pad tw9910 2-0044/0 Unable to set format: No such device or address (-6) Unable to setup formats: No such device or address (6)

This -6 (ENXIO) error comes from:

tw9910_set_frame() ---> tw9910_mask_set() ---> i2c_smbus_read_byte_data():

static int tw9910_mask_set(struct i2c_client *client, u8 command,
u8 mask, u8 set)

{
	s32 val = i2c_smbus_read_byte_data(client, command);

I am able to dump TW9990 registers via i2cdetect and also via the probe function, so I2C access is OK.

Not sure why I am getting these i2c_smbus_read_byte_data() errors.

Any ideas?

Thanks!

 drivers/media/i2c/tw9910.c | 47 ++++++++++++++++++++++++++++++--------
 1 file changed, 38 insertions(+), 9 deletions(-)
drivers/media/i2c/tw9910.c +38 -9
index 09f5b3986928..04f3c2dbc1cc 100644
@@ -22,6 +22,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/slab.h>
 #include <linux/v4l2-mediabus.h>
 #include <linux/videodev2.h>
@@ -928,22 +929,27 @@ static const struct v4l2_subdev_ops tw9910_subdev_ops = {
  * i2c_driver function
  */
 
+static int tw9910_parse_dt(struct i2c_client *client, struct tw9910_priv *priv)
+{
+	priv->info = devm_kzalloc(&client->dev, sizeof(*priv->info), GFP_KERNEL);
+	if (!priv->info)
+		return -ENOMEM;
+
+	/* Use default for now. Will retrieve from dt later */
+	priv->info->mpout = 0;
+	priv->info->buswidth = 8;
+
+	return 0;
+}
+
 static int tw9910_probe(struct i2c_client *client,
 			const struct i2c_device_id *did)
 
 {
 	struct tw9910_priv		*priv;
-	struct tw9910_video_info	*info;
 	struct i2c_adapter		*adapter = client->adapter;
 	int ret;
 
-	if (!client->dev.platform_data) {
-		dev_err(&client->dev, "TW9910: missing platform data!\n");
-		return -EINVAL;
-	}
-
-	info = client->dev.platform_data;
-
 	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
 		dev_err(&client->dev,
 			"I2C-Adapter doesn't support I2C_FUNC_SMBUS_BYTE_DATA\n");
@@ -954,7 +960,18 @@ static int tw9910_probe(struct i2c_client *client,
 	if (!priv)
 		return -ENOMEM;
 
-	priv->info = info;
+	if (IS_ENABLED(CONFIG_OF) && client->dev.of_node) {
+		ret = tw9910_parse_dt(client, priv);
+		if (ret < 0) {
+			v4l_err(client, "DT parsing error\n");
+			return ret;
+		}
+	} else if (client->dev.platform_data) {
+		priv->info = client->dev.platform_data;
+	} else {
+		v4l_err(client, "No platform data!\n");
+		return -ENODEV;
+	}
 
 	v4l2_i2c_subdev_init(&priv->subdev, client, &tw9910_subdev_ops);
 
@@ -1007,13 +1024,25 @@ static int tw9910_remove(struct i2c_client *client)
 
 static const struct i2c_device_id tw9910_id[] = {
 	{ "tw9910", 0 },
+	{ "tw9990", 0 },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, tw9910_id);
 
+#ifdef CONFIG_OF
+static const struct of_device_id tw9910_of_id[] = {
+	{ .compatible = "renesas,tw9910", },
+	{ .compatible = "renesas,tw9990", },
+	{ },
+};
+
+MODULE_DEVICE_TABLE(of, tw9910_of_id);
+#endif
+
 static struct i2c_driver tw9910_i2c_driver = {
 	.driver = {
 		.name = "tw9910",
+		.of_match_table = of_match_ptr(tw9910_of_id),
 	},
 	.probe    = tw9910_probe,
 	.remove   = tw9910_remove,
Signature · 1 line
2.25.1
author reviewer
#1 lore raw

RFC 2/3 media: tw9910: Allow the TW9990 to probe

Currently the driver rejects to probe when the ID is different from the TW9910 one.

Allow TW9990 to probe by allowing its ID too.

---
 drivers/media/i2c/tw9910.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/tw9910.c +1 -1
index 04f3c2dbc1cc..0411b8ea9bda 100644
@@ -859,7 +859,7 @@ static int tw9910_video_probe(struct i2c_client *client)
 	priv->revision = GET_REV(id);
 	id = GET_ID(id);
 
-	if (id != 0x0b || priv->revision > 0x01) {
+	if ((id != 0x0b && id != 0x00) || priv->revision > 0x01) {
 		dev_err(&client->dev, "Product ID error %x:%x\n",
 			id, priv->revision);
 		ret = -ENODEV;
Signature · 1 line
2.25.1
#2 lore raw

Re: [RFC 2/3] media: tw9910: Allow the TW9990 to probe

Hi Fabio,

Quoted 15 lines · Fabio Estevam

Currently the driver rejects to probe when the ID is different from the TW9910 one.

Allow TW9990 to probe by allowing its ID too.

---
 drivers/media/i2c/tw9910.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/tw9910.c +0 -0
index 04f3c2dbc1cc..0411b8ea9bda 100644

drivers/media/i2c/tw9910.c static int tw9910_video_probe(struct i2c_client *client) · line 862

Quoted 5 lines
drivers/media/i2c/tw9910.c +1 -1
@@ -859,7 +859,7 @@ static int tw9910_video_probe(struct i2c_client *client)
 	priv->revision = GET_REV(id);
 	id = GET_ID(id);
 
-	if (id != 0x0b || priv->revision > 0x01) {
+	if ((id != 0x0b && id != 0x00) || priv->revision > 0x01) {

I would define these. Up to you!

Quoted 6 lines
drivers/media/i2c/tw9910.c +0 -1
 		dev_err(&client->dev, "Product ID error %x:%x\n",
 			id, priv->revision);
 		ret = -ENODEV;
--

2.25.1

author reviewer
#3 lore raw

RFC 3/3 media: tw9910: Initialize the entity type

In reply to Fabio Estevam

Currently the following warning is seen:

imx7-csi 2214000.csi: Entity type for entity tw9910 2-0044 was not initialized!

Initialize the entity type accordingly.

---
 drivers/media/i2c/tw9910.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
drivers/media/i2c/tw9910.c +15 -3
index 0411b8ea9bda..ad4149073ba4 100644
@@ -228,6 +228,7 @@ struct tw9910_scale_ctrl {
 
 struct tw9910_priv {
 	struct v4l2_subdev		subdev;
+	struct media_pad		pad;
 	struct clk			*clk;
 	struct tw9910_video_info	*info;
 	struct gpio_desc		*pdn_gpio;
@@ -948,6 +949,7 @@ static int tw9910_probe(struct i2c_client *client,
 {
 	struct tw9910_priv		*priv;
 	struct i2c_adapter		*adapter = client->adapter;
+	struct v4l2_subdev *sd;
 	int ret;
 
 	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
@@ -973,14 +975,22 @@ static int tw9910_probe(struct i2c_client *client,
 		return -ENODEV;
 	}
 
-	v4l2_i2c_subdev_init(&priv->subdev, client, &tw9910_subdev_ops);
+	sd = &priv->subdev;
+	v4l2_i2c_subdev_init(sd, client, &tw9910_subdev_ops);
+	priv->pad.flags = MEDIA_PAD_FL_SOURCE;
+	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS;
+	sd->entity.function = MEDIA_ENT_F_ATV_DECODER;
+	ret = media_entity_pads_init(&sd->entity, 1, &priv->pad);
+	if (ret)
+		return ret;
 
 	priv->clk = clk_get(&client->dev, "xti");
 	if (PTR_ERR(priv->clk) == -ENOENT) {
 		priv->clk = NULL;
 	} else if (IS_ERR(priv->clk)) {
 		dev_err(&client->dev, "Unable to get xti clock\n");
-		return PTR_ERR(priv->clk);
+		ret = PTR_ERR(priv->clk);
+		goto media_entity_cleanup;
 	}
 
 	priv->pdn_gpio = gpiod_get_optional(&client->dev, "pdn",
@@ -1006,7 +1016,9 @@ static int tw9910_probe(struct i2c_client *client,
 		gpiod_put(priv->pdn_gpio);
 error_clk_put:
 	clk_put(priv->clk);
-
+	
+media_entity_cleanup:
+	media_entity_cleanup(&sd->entity);
 	return ret;
 }
 
Signature · 1 line
2.25.1
#4 lore raw

Re: [RFC 3/3] media: tw9910: Initialize the entity type

[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch]

Hi Fabio,

[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on linuxtv-media/master]
[also build test ERROR on v5.14-rc7 next-20210827]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Fabio-Estevam/media-tw9910-Allow-to-probe-from-device-tree/20210827-210316
base:   git://linuxtv.org/media_tree.git master
config: i386-randconfig-r001-20210827 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 4e1a164d7bd53653f79decc121afe784d2fde0a7)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/075fb2f026178ddd4d7d04706f68fd8dff50e22b
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Fabio-Estevam/media-tw9910-Allow-to-probe-from-device-tree/20210827-210316 git checkout 075fb2f026178ddd4d7d04706f68fd8dff50e22b
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross O=build_dir ARCH=i386 SHELL=/bin/bash drivers/media/i2c/

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

>> drivers/media/i2c/tw9910.c:982:6: error: no member named 'entity' in 'struct v4l2_subdev'
           sd->entity.function = MEDIA_ENT_F_ATV_DECODER;
           ~~  ^
   drivers/media/i2c/tw9910.c:983:36: error: no member named 'entity' in 'struct v4l2_subdev'
           ret = media_entity_pads_init(&sd->entity, 1, &priv->pad);
                                         ~~  ^

2 errors generated.

vim +982 drivers/media/i2c/tw9910.c

945
946 static int tw9910_probe(struct i2c_client *client,
947 const struct i2c_device_id *did)
948
949 {
950 struct tw9910_priv *priv;
951 struct i2c_adapter *adapter = client->adapter;
952 struct v4l2_subdev *sd;
953 int ret;
954
955 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
956 dev_err(&client->dev,
957 "I2C-Adapter doesn't support I2C_FUNC_SMBUS_BYTE_DATA\n");
958 return -EIO;
959 }
960
961 priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
962 if (!priv)
963 return -ENOMEM;
964
965 if (IS_ENABLED(CONFIG_OF) && client->dev.of_node) {
966 ret = tw9910_parse_dt(client, priv);
967 if (ret < 0) {
968 v4l_err(client, "DT parsing error\n");
969 return ret;
970 }
971 } else if (client->dev.platform_data) {
972 priv->info = client->dev.platform_data;
973 } else {
974 v4l_err(client, "No platform data!\n");
975 return -ENODEV;
976 }
977
978 sd = &priv->subdev;
979 v4l2_i2c_subdev_init(sd, client, &tw9910_subdev_ops);
980 priv->pad.flags = MEDIA_PAD_FL_SOURCE;
981 sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS;

 > 982		sd->entity.function = MEDIA_ENT_F_ATV_DECODER;

983 ret = media_entity_pads_init(&sd->entity, 1, &priv->pad);
984 if (ret)
985 return ret;
986
987 priv->clk = clk_get(&client->dev, "xti");
988 if (PTR_ERR(priv->clk) == -ENOENT) {
989 priv->clk = NULL;
990 } else if (IS_ERR(priv->clk)) {
991 dev_err(&client->dev, "Unable to get xti clock\n");
992 ret = PTR_ERR(priv->clk);
993 goto media_entity_cleanup;
994 }
995
996 priv->pdn_gpio = gpiod_get_optional(&client->dev, "pdn",
997 GPIOD_OUT_HIGH);
998 if (IS_ERR(priv->pdn_gpio)) {
999 dev_info(&client->dev, "Unable to get GPIO \"pdn\"");
1000 ret = PTR_ERR(priv->pdn_gpio);
1001 goto error_clk_put;
1002 }
1003
1004 ret = tw9910_video_probe(client);
1005 if (ret < 0)
1006 goto error_gpio_put;
1007
1008 ret = v4l2_async_register_subdev(&priv->subdev);
1009 if (ret)
1010 goto error_gpio_put;
1011
1012 return ret;
1013
1014 error_gpio_put:
1015 if (priv->pdn_gpio)
1016 gpiod_put(priv->pdn_gpio);
1017 error_clk_put:
1018 clk_put(priv->clk);
1019
1020 media_entity_cleanup:
1021 media_entity_cleanup(&sd->entity);
1022 return ret;
1023 }
1024

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#5 lore raw

Re: [RFC 3/3] media: tw9910: Initialize the entity type

In reply to Fabio Estevam
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch]

Hi Fabio,

[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on linuxtv-media/master]
[also build test ERROR on v5.14-rc7 next-20210827]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Fabio-Estevam/media-tw9910-Allow-to-probe-from-device-tree/20210827-210316
base:   git://linuxtv.org/media_tree.git master
config: i386-randconfig-r031-20200605 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

reproduce (this is a W=1 build):
# https://github.com/0day-ci/linux/commit/075fb2f026178ddd4d7d04706f68fd8dff50e22b
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Fabio-Estevam/media-tw9910-Allow-to-probe-from-device-tree/20210827-210316 git checkout 075fb2f026178ddd4d7d04706f68fd8dff50e22b
# save the attached .config to linux build tree
mkdir build_dir
make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/media/i2c/

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

drivers/media/i2c/tw9910.c: In function 'tw9910_probe':

>> drivers/media/i2c/tw9910.c:982:4: error: 'struct v4l2_subdev' has no member named 'entity'
     982 |  sd->entity.function = MEDIA_ENT_F_ATV_DECODER;
         |    ^~
   drivers/media/i2c/tw9910.c:983:34: error: 'struct v4l2_subdev' has no member named 'entity'
     983 |  ret = media_entity_pads_init(&sd->entity, 1, &priv->pad);
         |                                  ^~

vim +982 drivers/media/i2c/tw9910.c

945
946 static int tw9910_probe(struct i2c_client *client,
947 const struct i2c_device_id *did)
948
949 {
950 struct tw9910_priv *priv;
951 struct i2c_adapter *adapter = client->adapter;
952 struct v4l2_subdev *sd;
953 int ret;
954
955 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
956 dev_err(&client->dev,
957 "I2C-Adapter doesn't support I2C_FUNC_SMBUS_BYTE_DATA\n");
958 return -EIO;
959 }
960
961 priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
962 if (!priv)
963 return -ENOMEM;
964
965 if (IS_ENABLED(CONFIG_OF) && client->dev.of_node) {
966 ret = tw9910_parse_dt(client, priv);
967 if (ret < 0) {
968 v4l_err(client, "DT parsing error\n");
969 return ret;
970 }
971 } else if (client->dev.platform_data) {
972 priv->info = client->dev.platform_data;
973 } else {
974 v4l_err(client, "No platform data!\n");
975 return -ENODEV;
976 }
977
978 sd = &priv->subdev;
979 v4l2_i2c_subdev_init(sd, client, &tw9910_subdev_ops);
980 priv->pad.flags = MEDIA_PAD_FL_SOURCE;
981 sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS;

 > 982		sd->entity.function = MEDIA_ENT_F_ATV_DECODER;

983 ret = media_entity_pads_init(&sd->entity, 1, &priv->pad);
984 if (ret)
985 return ret;
986
987 priv->clk = clk_get(&client->dev, "xti");
988 if (PTR_ERR(priv->clk) == -ENOENT) {
989 priv->clk = NULL;
990 } else if (IS_ERR(priv->clk)) {
991 dev_err(&client->dev, "Unable to get xti clock\n");
992 ret = PTR_ERR(priv->clk);
993 goto media_entity_cleanup;
994 }
995
996 priv->pdn_gpio = gpiod_get_optional(&client->dev, "pdn",
997 GPIOD_OUT_HIGH);
998 if (IS_ERR(priv->pdn_gpio)) {
999 dev_info(&client->dev, "Unable to get GPIO \"pdn\"");
1000 ret = PTR_ERR(priv->pdn_gpio);
1001 goto error_clk_put;
1002 }
1003
1004 ret = tw9910_video_probe(client);
1005 if (ret < 0)
1006 goto error_gpio_put;
1007
1008 ret = v4l2_async_register_subdev(&priv->subdev);
1009 if (ret)
1010 goto error_gpio_put;
1011
1012 return ret;
1013
1014 error_gpio_put:
1015 if (priv->pdn_gpio)
1016 gpiod_put(priv->pdn_gpio);
1017 error_clk_put:
1018 clk_put(priv->clk);
1019
1020 media_entity_cleanup:
1021 media_entity_cleanup(&sd->entity);
1022 return ret;
1023 }
1024

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#6 lore raw

Re: [RFC 3/3] media: tw9910: Initialize the entity type

In reply to Fabio Estevam

Hi Fabio,

Quoted 24 lines · Fabio Estevam

Currently the following warning is seen:

imx7-csi 2214000.csi: Entity type for entity tw9910 2-0044 was not initialized!

Initialize the entity type accordingly.

---
 drivers/media/i2c/tw9910.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
drivers/media/i2c/tw9910.c +1 -0
index 0411b8ea9bda..ad4149073ba4 100644
@@ -228,6 +228,7 @@ struct tw9910_scale_ctrl {
 
 struct tw9910_priv {
 	struct v4l2_subdev		subdev;
+	struct media_pad		pad;
 	struct clk			*clk;
 	struct tw9910_video_info	*info;
 	struct gpio_desc		*pdn_gpio;

drivers/media/i2c/tw9910.c static int tw9910_probe(struct i2c_client *client, · line 952

Quoted 4 lines
drivers/media/i2c/tw9910.c +1 -0
@@ -948,6 +949,7 @@ static int tw9910_probe(struct i2c_client *client,
 {
 	struct tw9910_priv		*priv;
 	struct i2c_adapter		*adapter = client->adapter;
+	struct v4l2_subdev *sd;

As questionable as it could be, the existing variables are aligned differently.

drivers/media/i2c/tw9910.c static int tw9910_probe(struct i2c_client *client, · line 982

Quoted 13 lines
drivers/media/i2c/tw9910.c +5 -1
 	int ret;
 
 	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
@@ -973,14 +975,22 @@ static int tw9910_probe(struct i2c_client *client,
 		return -ENODEV;
 	}
 
-	v4l2_i2c_subdev_init(&priv->subdev, client, &tw9910_subdev_ops);
+	sd = &priv->subdev;
+	v4l2_i2c_subdev_init(sd, client, &tw9910_subdev_ops);
+	priv->pad.flags = MEDIA_PAD_FL_SOURCE;
+	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS;
+	sd->entity.function = MEDIA_ENT_F_ATV_DECODER;

Seems appropriate!

Quoted 16 lines
drivers/media/i2c/tw9910.c +5 -1
+	ret = media_entity_pads_init(&sd->entity, 1, &priv->pad);
+	if (ret)
+		return ret;
 
 	priv->clk = clk_get(&client->dev, "xti");
 	if (PTR_ERR(priv->clk) == -ENOENT) {
 		priv->clk = NULL;
 	} else if (IS_ERR(priv->clk)) {
 		dev_err(&client->dev, "Unable to get xti clock\n");
-		return PTR_ERR(priv->clk);
+		ret = PTR_ERR(priv->clk);
+		goto media_entity_cleanup;
 	}
 
 	priv->pdn_gpio = gpiod_get_optional(&client->dev, "pdn",

drivers/media/i2c/tw9910.c static int tw9910_probe(struct i2c_client *client, · line 1019

Quoted 5 lines
drivers/media/i2c/tw9910.c +1 -1
@@ -1006,7 +1016,9 @@ static int tw9910_probe(struct i2c_client *client,
 		gpiod_put(priv->pdn_gpio);
 error_clk_put:
 	clk_put(priv->clk);
-
+

Rougue tab, or is it my mail client ?

Quoted 8 lines
drivers/media/i2c/tw9910.c +2 -1
+media_entity_cleanup:
+	media_entity_cleanup(&sd->entity);
 	return ret;
 }
 
--

2.25.1

author reviewer
#7 lore raw
In reply to Fabio Estevam
Quoted 72 lines · Fabio Estevam

Currently the driver only probes via platform data passed from board file.

Allow to probe from device tree too.

---
Hi,

I am currently sending this series as RFC because I was not able to get the TW9990 to work on a imx6sx board yet.

# media-ctl -p
Media controller API version 5.14.0

Media device information
------------------------
driver imx7-csi
model imx-media
serial
bus info
hw revision 0x0
driver version 5.14.0

Device topology
- entity 1: csi (2 pads, 2 links)

            type V4L2 subdev subtype Unknown flags 0
            device node name /dev/v4l-subdev0
        pad0: Sink
                [fmt:UYVY8_2X8/800x600 field:none colorspace:srgb xfer:srgb ycbcr:601 quantization:lim-range]
                <- "tw9910 2-0044":0 [ENABLED,IMMUTABLE]
        pad1: Source
                [fmt:UYVY8_2X8/800x600 field:none colorspace:srgb xfer:srgb ycbcr:601 quantization:lim-range]
                -> "csi capture":0 [ENABLED,IMMUTABLE]

- entity 4: csi capture (1 pad, 1 link)
type Node subtype V4L flags 0
device node name /dev/video0
pad0: Sink
<- "csi":1 [ENABLED,IMMUTABLE]

- entity 10: tw9910 2-0044 (1 pad, 1 link)

             type V4L2 subdev subtype Decoder flags 0
             device node name /dev/v4l-subdev1
        pad0: Source
                [fmt:UYVY8_2X8/640x480 field:interlaced-bt colorspace:smpte170m
                 crop.bounds:(0,0)/640x480
                 crop:(0,0)/640x480]
                -> "csi":0 [ENABLED,IMMUTABLE]

I get the following error when setting up the pipeline:

media-ctl -l "'tw9910 2-0044':0 -> 'csi':0[1]"
media-ctl -l "'csi':1 -> 'csi capture':0[1]"
media-ctl -v -V "'tw9910 2-0044':0 [fmt:UYVY8_2X8/800x480 field:any]"

Opening media device /dev/media0
Enumerating entities
Found 3 entities
Enumerating pads and links
Setting up format UYVY8_2X8 800x480 on pad tw9910 2-0044/0 Unable to set format: No such device or address (-6) Unable to setup formats: No such device or address (6)

This -6 (ENXIO) error comes from:

tw9910_set_frame() ---> tw9910_mask_set() ---> i2c_smbus_read_byte_data():

static int tw9910_mask_set(struct i2c_client *client, u8 command,
u8 mask, u8 set)

Quoted 7 lines
{
        s32 val = i2c_smbus_read_byte_data(client, command);

I am able to dump TW9990 registers via i2cdetect and also via the probe function, so I2C access is OK.

Not sure why I am getting these i2c_smbus_read_byte_data() errors.

I found the reason: the tw9910 driver was getting unpowered in the incorrect place.
This problem was present prior to the DT conversion.

I will send a fix for it soon.

Thanks

#8 lore raw
In reply to Fabio Estevam

Hi Fabio,

Quoted 11 lines · Fabio Estevam

Currently the driver only probes via platform data passed from board file.

Allow to probe from device tree too.

---
Hi,

I am currently sending this series as RFC because I was not able to get the TW9990 to work on a imx6sx board yet.

I'm sorry but I've no access to any TW99xx device at the moment to test with

Quoted 60 lines
# media-ctl -p
Media controller API version 5.14.0

Media device information
------------------------
driver imx7-csi
model imx-media
serial
bus info
hw revision 0x0
driver version 5.14.0

Device topology
- entity 1: csi (2 pads, 2 links)

            type V4L2 subdev subtype Unknown flags 0
            device node name /dev/v4l-subdev0
	pad0: Sink
		[fmt:UYVY8_2X8/800x600 field:none colorspace:srgb xfer:srgb ycbcr:601 quantization:lim-range]
		<- "tw9910 2-0044":0 [ENABLED,IMMUTABLE]
	pad1: Source
		[fmt:UYVY8_2X8/800x600 field:none colorspace:srgb xfer:srgb ycbcr:601 quantization:lim-range]
		-> "csi capture":0 [ENABLED,IMMUTABLE]

- entity 4: csi capture (1 pad, 1 link)
type Node subtype V4L flags 0
device node name /dev/video0
pad0: Sink
<- "csi":1 [ENABLED,IMMUTABLE]

- entity 10: tw9910 2-0044 (1 pad, 1 link)

             type V4L2 subdev subtype Decoder flags 0
             device node name /dev/v4l-subdev1
	pad0: Source
		[fmt:UYVY8_2X8/640x480 field:interlaced-bt colorspace:smpte170m
		 crop.bounds:(0,0)/640x480
		 crop:(0,0)/640x480]
		-> "csi":0 [ENABLED,IMMUTABLE]

I get the following error when setting up the pipeline:

media-ctl -l "'tw9910 2-0044':0 -> 'csi':0[1]"
media-ctl -l "'csi':1 -> 'csi capture':0[1]"
media-ctl -v -V "'tw9910 2-0044':0 [fmt:UYVY8_2X8/800x480 field:any]"

Opening media device /dev/media0
Enumerating entities
Found 3 entities
Enumerating pads and links
Setting up format UYVY8_2X8 800x480 on pad tw9910 2-0044/0 Unable to set format: No such device or address (-6) Unable to setup formats: No such device or address (6)

This -6 (ENXIO) error comes from:

tw9910_set_frame() ---> tw9910_mask_set() ---> i2c_smbus_read_byte_data():

static int tw9910_mask_set(struct i2c_client *client, u8 command,
u8 mask, u8 set)

Quoted 7 lines
{
	s32 val = i2c_smbus_read_byte_data(client, command);

I am able to dump TW9990 registers via i2cdetect and also via the probe function, so I2C access is OK.

Not sure why I am getting these i2c_smbus_read_byte_data() errors.

There's an

	tw9910_s_power(&priv->subdev, 0);

at the end of the video_probe() function.

The driver handles power management with the legacy s_power() call chain, and the receiver driver needs to v4l2_pipeline_pm_get() which the imx driver does when the capture node is open.

Just an hint, you might have noticed already

Quoted 15 lines

Any ideas?

Thanks!

 drivers/media/i2c/tw9910.c | 47 ++++++++++++++++++++++++++++++--------
 1 file changed, 38 insertions(+), 9 deletions(-)
drivers/media/i2c/tw9910.c +0 -0
index 09f5b3986928..04f3c2dbc1cc 100644

drivers/media/i2c/tw9910.c line 25

Quoted 4 lines
drivers/media/i2c/tw9910.c +1 -0
@@ -22,6 +22,7 @@
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/of.h>

If you need this for struct of_device_id then you should include <linux/mod_devicetable.h>

drivers/media/i2c/tw9910.c static const struct v4l2_subdev_ops tw9910_subdev_ops = { · line 935

Quoted 11 lines
drivers/media/i2c/tw9910.c +4 -0
 #include <linux/slab.h>
 #include <linux/v4l2-mediabus.h>
 #include <linux/videodev2.h>
@@ -928,22 +929,27 @@ static const struct v4l2_subdev_ops tw9910_subdev_ops = {
  * i2c_driver function
  */
 
+static int tw9910_parse_dt(struct i2c_client *client, struct tw9910_priv *priv)
+{
+	priv->info = devm_kzalloc(&client->dev, sizeof(*priv->info), GFP_KERNEL);
+	if (!priv->info)

IS_ERR_OR_NULL() ?

drivers/media/i2c/tw9910.c static const struct v4l2_subdev_ops tw9910_subdev_ops = { · line 936

Quoted 1 line
drivers/media/i2c/tw9910.c +1 -0
+		return -ENOMEM;

PTR_ERR() ?

Quoted 48 lines
drivers/media/i2c/tw9910.c +20 -9
+
+	/* Use default for now. Will retrieve from dt later */
+	priv->info->mpout = 0;
+	priv->info->buswidth = 8;
+
+	return 0;
+}
+
 static int tw9910_probe(struct i2c_client *client,
 			const struct i2c_device_id *did)
 
 {
 	struct tw9910_priv		*priv;
-	struct tw9910_video_info	*info;
 	struct i2c_adapter		*adapter = client->adapter;
 	int ret;
 
-	if (!client->dev.platform_data) {
-		dev_err(&client->dev, "TW9910: missing platform data!\n");
-		return -EINVAL;
-	}
-
-	info = client->dev.platform_data;
-
 	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) {
 		dev_err(&client->dev,
 			"I2C-Adapter doesn't support I2C_FUNC_SMBUS_BYTE_DATA\n");
@@ -954,7 +960,18 @@ static int tw9910_probe(struct i2c_client *client,
 	if (!priv)
 		return -ENOMEM;
 
-	priv->info = info;
+	if (IS_ENABLED(CONFIG_OF) && client->dev.of_node) {
+		ret = tw9910_parse_dt(client, priv);
+		if (ret < 0) {
+			v4l_err(client, "DT parsing error\n");
+			return ret;
+		}
+	} else if (client->dev.platform_data) {
+		priv->info = client->dev.platform_data;
+	} else {
+		v4l_err(client, "No platform data!\n");
+		return -ENODEV;
+	}
 
 	v4l2_i2c_subdev_init(&priv->subdev, client, &tw9910_subdev_ops);
 

drivers/media/i2c/tw9910.c static int tw9910_remove(struct i2c_client *client) · line 1027

Quoted 4 lines
drivers/media/i2c/tw9910.c +1 -0
@@ -1007,13 +1024,25 @@ static int tw9910_remove(struct i2c_client *client)
 
 static const struct i2c_device_id tw9910_id[] = {
 	{ "tw9910", 0 },
+	{ "tw9990", 0 },

Unrelated to this patch maybe ?

drivers/media/i2c/tw9910.c static int tw9910_remove(struct i2c_client *client) · line 1032

Quoted 5 lines
drivers/media/i2c/tw9910.c +1 -0
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, tw9910_id);
 
+#ifdef CONFIG_OF

I think this can be dropped ?

drivers/media/i2c/tw9910.c static int tw9910_remove(struct i2c_client *client) · line 1035

Quoted 3 lines
drivers/media/i2c/tw9910.c +3 -0
+static const struct of_device_id tw9910_of_id[] = {
+	{ .compatible = "renesas,tw9910", },
+	{ .compatible = "renesas,tw9990", },

TW9910 was originally manufactured by Techwell, then bought by Intersil, then bought by Renesas. Not sure what I would use as the chip is still marketed as "Techwell" and the public documentation released by "Intersil", according to my web searches..

Quoted 16 lines
drivers/media/i2c/tw9910.c +7 -1
+	{ },
+};
+
+MODULE_DEVICE_TABLE(of, tw9910_of_id);
+#endif
+
 static struct i2c_driver tw9910_i2c_driver = {
 	.driver = {
 		.name = "tw9910",
+		.of_match_table = of_match_ptr(tw9910_of_id),
 	},
 	.probe    = tw9910_probe,
 	.remove   = tw9910_remove,
--

2.25.1

author reviewer
#9 lore raw

Hi Jacopo,

Quoted 11 lines · Jacopo Mondi

There's an

        tw9910_s_power(&priv->subdev, 0);

at the end of the video_probe() function.

The driver handles power management with the legacy s_power() call chain, and the receiver driver needs to v4l2_pipeline_pm_get() which the imx driver does when the capture node is open.

Just an hint, you might have noticed already

Thanks for your comments and review. Yes, I have fixed the I2C errors.

I plan to re-submit the entire series after I get the TW9990 to work on my imx6sx-based board.

The capture driver is drivers/staging/media/imx/imx7-media-csi.c.

Currently, I am not able to get the stream to start.

This is the configuration I am using:

media-ctl -l "'tw9910 2-0044':0 -> 'csi':0[1]"
media-ctl -l "'csi':1 -> 'csi capture':0[1]"
media-ctl -v -V "'tw9910 2-0044':0 [fmt:UYVY8_2X8/720x480 field:any]" Opening media device /dev/media0
Enumerating entities
Found 3 entities
Enumerating pads and links
Setting up format UYVY8_2X8 720x480 on pad tw9910 2-0044/0 Format set: UYVY8_2X8 720x480
Setting up format UYVY8_2X8 720x480 on pad csi/0
Format set: UYVY8_2X8 720x480

Then I launch the capture stream command:

v4l2-ctl --stream-mmap -d /dev/video1

but nothing happens here, no >>>>> frame indication progress is shown.

If I hit CTRL + C then I get:

[  715.467623] csi: wait last EOF timeout

Any suggestions?

Thanks

author reviewer
#10 lore raw
Quoted 40 lines · Fabio Estevam

Hi Jacopo,

Quoted 11 lines · Jacopo Mondi

There's an

        tw9910_s_power(&priv->subdev, 0);

at the end of the video_probe() function.

The driver handles power management with the legacy s_power() call chain, and the receiver driver needs to v4l2_pipeline_pm_get() which the imx driver does when the capture node is open.

Just an hint, you might have noticed already

Thanks for your comments and review. Yes, I have fixed the I2C errors.

I plan to re-submit the entire series after I get the TW9990 to work on my imx6sx-based board.

The capture driver is drivers/staging/media/imx/imx7-media-csi.c.

Currently, I am not able to get the stream to start.

This is the configuration I am using:

media-ctl -l "'tw9910 2-0044':0 -> 'csi':0[1]"
media-ctl -l "'csi':1 -> 'csi capture':0[1]"
media-ctl -v -V "'tw9910 2-0044':0 [fmt:UYVY8_2X8/720x480 field:any]" Opening media device /dev/media0
Enumerating entities
Found 3 entities
Enumerating pads and links
Setting up format UYVY8_2X8 720x480 on pad tw9910 2-0044/0 Format set: UYVY8_2X8 720x480
Setting up format UYVY8_2X8 720x480 on pad csi/0
Format set: UYVY8_2X8 720x480

Quoted 8 lines

Then I launch the capture stream command:

v4l2-ctl --stream-mmap -d /dev/video1

but nothing happens here, no >>>>> frame indication progress is shown.

If I hit CTRL + C then I get:

[  715.467623] csi: wait last EOF timeout

I also need to set the video standard to PAL:

# v4l2-ctl --device /dev/v4l-subdev1 --set-standard PAL
Standard set to 000000ff
# media-ctl -l "'tw9910 2-0044':0 -> 'csi':0[1]"
# media-ctl -l "'csi':1 -> 'csi capture':0[1]"
# media-ctl -v -V "'tw9910 2-0044':0 [fmt:UYVY8_2X8/720x576
field:interlaced-bt]"
Opening media device /dev/media0
Enumerating entities
Found 3 entities
Enumerating pads and links
Setting up format UYVY8_2X8 720x576 on pad tw9910 2-0044/0
Format set: UYVY8_2X8 720x576
Setting up format UYVY8_2X8 720x576 on pad csi/0
Format set: UYVY8_2X8 720x576
# v4l2-ctl --stream-mmap -d /dev/video1
[   38.554032] priv->vdev.fmt.fmt.pix.width is 800
[   38.561444] f.fmt.pix.width is 720
[   38.567607] priv->vdev.fmt.fmt.pix.height is 600
[   38.574973] f.fmt.pix.height is 576
[   38.580992] priv->vdev.cc->cs is 1
[   38.586958] cc->cs is 1
[   38.591761] priv->vdev.compose.width is 800
[   38.598420] compose.width is 720
[   38.604048] priv->vdev.compose.height is 600
[   38.610681] compose.height is 576
[   38.616347] csi: capture format not valid
VIDIOC_STREAMON returned -1 (Broken pipe)

I added some printk debug lines to show the mismatch that prevents the pipeline to start in capture_validate_fmt():

(quoted diff) +0 -0

b/drivers/staging/media/imx/imx-media-capture.c
index b2f2cb3d6a60..511625981e93 100644

drivers/staging/media/imx/imx-media-capture.c +2 -0
@@ -552,6 +552,21 @@ static int capture_validate_fmt(struct capture_priv *priv)
        ret = __capture_try_fmt_vid_cap(priv, &fmt_src, &f, &cc, &compose);
        if (ret)
                return ret;
+
+       pr_err("priv->vdev.fmt.fmt.pix.width is %d\n",

priv->vdev.fmt.fmt.pix.width);
+ pr_err("f.fmt.pix.width is %d\n", f.fmt.pix.width);
+
+ pr_err("priv->vdev.fmt.fmt.pix.height is %d\n",
priv->vdev.fmt.fmt.pix.height);
+ pr_err("f.fmt.pix.height is %d\n", f.fmt.pix.height );
+
+ pr_err("priv->vdev.cc->cs is %d\n", priv->vdev.cc->cs);
+ pr_err("cc->cs is %d\n", cc->cs);
+
+ pr_err("priv->vdev.compose.width is %d\n", priv->vdev.compose.width);
+ pr_err("compose.width is %d\n", compose.width);
+
+ pr_err("priv->vdev.compose.height is %d\n", priv->vdev.compose.height);
+ pr_err("compose.height is %d\n", compose.height);

        return (priv->vdev.fmt.fmt.pix.width != f.fmt.pix.width ||
                priv->vdev.fmt.fmt.pix.height != f.fmt.pix.height ||

Any ideas as to whu such mismatch happens?

Thanks

#11 lore raw

Hi Fabio,

Quoted 115 lines · Fabio Estevam
Quoted 40 lines · Fabio Estevam

Hi Jacopo,

Quoted 11 lines · Jacopo Mondi

There's an

        tw9910_s_power(&priv->subdev, 0);

at the end of the video_probe() function.

The driver handles power management with the legacy s_power() call chain, and the receiver driver needs to v4l2_pipeline_pm_get() which the imx driver does when the capture node is open.

Just an hint, you might have noticed already

Thanks for your comments and review. Yes, I have fixed the I2C errors.

I plan to re-submit the entire series after I get the TW9990 to work on my imx6sx-based board.

The capture driver is drivers/staging/media/imx/imx7-media-csi.c.

Currently, I am not able to get the stream to start.

This is the configuration I am using:

media-ctl -l "'tw9910 2-0044':0 -> 'csi':0[1]"
media-ctl -l "'csi':1 -> 'csi capture':0[1]"
media-ctl -v -V "'tw9910 2-0044':0 [fmt:UYVY8_2X8/720x480 field:any]" Opening media device /dev/media0
Enumerating entities
Found 3 entities
Enumerating pads and links
Setting up format UYVY8_2X8 720x480 on pad tw9910 2-0044/0 Format set: UYVY8_2X8 720x480
Setting up format UYVY8_2X8 720x480 on pad csi/0
Format set: UYVY8_2X8 720x480

Quoted 8 lines

Then I launch the capture stream command:

v4l2-ctl --stream-mmap -d /dev/video1

but nothing happens here, no >>>>> frame indication progress is shown.

If I hit CTRL + C then I get:

[  715.467623] csi: wait last EOF timeout

I also need to set the video standard to PAL:

# v4l2-ctl --device /dev/v4l-subdev1 --set-standard PAL
Standard set to 000000ff
# media-ctl -l "'tw9910 2-0044':0 -> 'csi':0[1]"
# media-ctl -l "'csi':1 -> 'csi capture':0[1]"
# media-ctl -v -V "'tw9910 2-0044':0 [fmt:UYVY8_2X8/720x576
field:interlaced-bt]"
Opening media device /dev/media0
Enumerating entities
Found 3 entities
Enumerating pads and links
Setting up format UYVY8_2X8 720x576 on pad tw9910 2-0044/0
Format set: UYVY8_2X8 720x576
Setting up format UYVY8_2X8 720x576 on pad csi/0
Format set: UYVY8_2X8 720x576
# v4l2-ctl --stream-mmap -d /dev/video1
[   38.554032] priv->vdev.fmt.fmt.pix.width is 800
[   38.561444] f.fmt.pix.width is 720
[   38.567607] priv->vdev.fmt.fmt.pix.height is 600
[   38.574973] f.fmt.pix.height is 576
[   38.580992] priv->vdev.cc->cs is 1
[   38.586958] cc->cs is 1
[   38.591761] priv->vdev.compose.width is 800
[   38.598420] compose.width is 720
[   38.604048] priv->vdev.compose.height is 600
[   38.610681] compose.height is 576
[   38.616347] csi: capture format not valid
VIDIOC_STREAMON returned -1 (Broken pipe)

I added some printk debug lines to show the mismatch that prevents the pipeline to start in capture_validate_fmt():

drivers/staging/media/imx/imx-media-capture.c +15 -0
index b2f2cb3d6a60..511625981e93 100644
@@ -552,6 +552,21 @@ static int capture_validate_fmt(struct capture_priv *priv)
        ret = __capture_try_fmt_vid_cap(priv, &fmt_src, &f, &cc, &compose);
        if (ret)
                return ret;
+
+       pr_err("priv->vdev.fmt.fmt.pix.width is %d\n",
 priv->vdev.fmt.fmt.pix.width);
+       pr_err("f.fmt.pix.width is %d\n", f.fmt.pix.width);
+
+       pr_err("priv->vdev.fmt.fmt.pix.height is %d\n",
 priv->vdev.fmt.fmt.pix.height);
+       pr_err("f.fmt.pix.height is %d\n", f.fmt.pix.height );
+
+       pr_err("priv->vdev.cc->cs is %d\n", priv->vdev.cc->cs);
+       pr_err("cc->cs is %d\n", cc->cs);
+
+       pr_err("priv->vdev.compose.width is %d\n", priv->vdev.compose.width);
+       pr_err("compose.width is %d\n", compose.width);
+
+       pr_err("priv->vdev.compose.height is %d\n", priv->vdev.compose.height);
+       pr_err("compose.height is %d\n", compose.height);
 
        return (priv->vdev.fmt.fmt.pix.width != f.fmt.pix.width ||
                priv->vdev.fmt.fmt.pix.height != f.fmt.pix.height ||
Quoted 1 line

Any ideas as to whu such mismatch happens?

Looking at this code it looks like you are using an old tree, Laurent meanwhile have sent a patch that change this function:

a9512b261afd ("media: imx: capture: Simplify capture_validate_fmt() implementation")

can you test with the latest code as see if you have the same problems.

------
Cheers,
Rui

author reviewer
#12 lore raw

Hi Rui,

Quoted 7 lines · Rui Miguel Silva

Looking at this code it looks like you are using an old tree, Laurent meanwhile have sent a patch that change this function:

a9512b261afd ("media: imx: capture: Simplify capture_validate_fmt() implementation")

can you test with the latest code as see if you have the same problems.

I have just tested on 5.15-rc1 and this is what I get:

# v4l2-ctl --device /dev/v4l-subdev1 --set-standard PAL
Standard set to 000000ff
# media-ctl -l "'tw9910 2-0044':0 -> 'csi':0[1]"
# media-ctl -l "'csi':1 -> 'csi capture':0[1]"
# media-ctl -v -V "'tw9910 2-0044':0 [fmt:UYVY8_2X8/720x576
field:interlaced-bt]"
Opening media device /dev/media0
Enumerating entities
Found 3 entities
Enumerating pads and links
Setting up format UYVY8_2X8 720x576 on pad tw9910 2-0044/0
Format set: UYVY8_2X8 720x576
Setting up format UYVY8_2X8 720x576 on pad csi/0
Format set: UYVY8_2X8 720x576
# v4l2-ctl --stream-mmap -d /dev/video1
[   26.860654] priv->vdev.compose.width is 640
[   26.865419] fmt_src.format.width is 720
[   26.869390] priv->vdev.compose.height is 480
[   26.874268] compose.height is 576
[   26.877716] imx7-csi 2214000.csi: capture format not valid
VIDIOC_STREAMON returned -1 (Broken pipe)

Do you know why I am getting such a width/height mismatch?

Thanks,

Fabio Estevam

#13 lore raw

Oi Fabio,

Quoted 29 lines · Fabio Estevam

Hi Rui,

Quoted 7 lines · Rui Miguel Silva

Looking at this code it looks like you are using an old tree, Laurent meanwhile have sent a patch that change this function:

a9512b261afd ("media: imx: capture: Simplify capture_validate_fmt() implementation")

can you test with the latest code as see if you have the same problems.

I have just tested on 5.15-rc1 and this is what I get:

# v4l2-ctl --device /dev/v4l-subdev1 --set-standard PAL
Standard set to 000000ff
# media-ctl -l "'tw9910 2-0044':0 -> 'csi':0[1]"
# media-ctl -l "'csi':1 -> 'csi capture':0[1]"
# media-ctl -v -V "'tw9910 2-0044':0 [fmt:UYVY8_2X8/720x576
field:interlaced-bt]"
Opening media device /dev/media0
Enumerating entities
Found 3 entities
Enumerating pads and links
Setting up format UYVY8_2X8 720x576 on pad tw9910 2-0044/0
Format set: UYVY8_2X8 720x576
Setting up format UYVY8_2X8 720x576 on pad csi/0
Format set: UYVY8_2X8 720x576
Quoted 2 lines
# v4l2-ctl --stream-mmap -d /dev/video1
[   26.860654] priv->vdev.compose.width is 640

This looks like the default pix width (IMX_MEDIA_DEF_PIX_WIDTH)

Quoted 2 lines
[   26.865419] fmt_src.format.width is 720
[   26.869390] priv->vdev.compose.height is 480

and this the default pix height (IMX_MEDIA_DEF_PIX_HEIGHT)

Quoted 4 lines
[   26.874268] compose.height is 576
[   26.877716] imx7-csi 2214000.csi: capture format not valid

VIDIOC_STREAMON returned -1 (Broken pipe)
Do you know why I am getting such a width/height mismatch?

So, it seems like it is not configuring the pads, don't you need to do a media-ctl -V in the csi:0?

or maybe dump the output of media-ctl -p and check the links and pads configurations.

Hope this helps.

Cheers,
Rui

author reviewer
#14 lore raw

Hi Rui,

Quoted 2 lines · Rui Miguel Silva

So, it seems like it is not configuring the pads, don't you need to do a media-ctl -V in the csi:0?

Thanks for the suggestion. I tried passing media-ctl -V to csi:0:

# v4l2-ctl --device /dev/v4l-subdev1 --set-standard PAL
Standard set to 000000ff
# media-ctl -l "'tw9910 2-0044':0 -> 'csi':0[1]"
# media-ctl -l "'csi':1 -> 'csi capture':0[1]"
# media-ctl -v -V "'tw9910 2-0044':0 [fmt:UYVY8_2X8/720x576
field:interlaced-bt]"
# media-ctl -v -V "'csi':0 [fmt:UYVY8_2X8/720x576 field:interlaced-bt]"

Does this look correct?

Opening media device /dev/media0
Enumerating entities
Found 3 entities
Enumerating pads and links
Setting up format UYVY8_2X8 720x576 on pad tw9910 2-0044/0 Format set: UYVY8_2X8 720x576
Setting up format UYVY8_2X8 720x576 on pad csi/0 Format set: UYVY8_2X8 720x576
Opening media device /dev/media0
Enumerating entities
Found 3 entities
Enumerating pads and links
Setting up format UYVY8_2X8 720x576 on pad csi/0 Format set: UYVY8_2X8 720x576

# v4l2-ctl --stream-mmap -d /dev/video1
[   50.969910] priv->vdev.compose.width is 640
[   50.974685] fmt_src.format.width is 720
[   50.978659] priv->vdev.compose.height is 480
[   50.983208] compose.height is 576
[   50.986646] imx7-csi 2214000.csi: capture format not valid
VIDIOC_STREAMON returned -1 (Broken pipe)

but still getting the width/height mismatch.

# media-ctl -p
Media controller API version 5.15.0

Media device information
------------------------
driver imx7-csi
model imx-media
serial
bus info
hw revision 0x0
driver version 5.15.0

Device topology
- entity 1: csi (2 pads, 2 links)
type V4L2 subdev subtype Unknown flags 0 device node name /dev/v4l-subdev0
pad0: Sink
[fmt:UYVY8_2X8/720x576 field:none colorspace:srgb xfer:srgb ycbcr:601 quantization:lim-range]
<- "tw9910 2-0044":0 [ENABLED,IMMUTABLE]
pad1: Source
[fmt:UYVY8_2X8/720x576 field:none colorspace:srgb xfer:srgb ycbcr:601 quantization:lim-range]
-> "csi capture":0 [ENABLED,IMMUTABLE]

- entity 4: csi capture (1 pad, 1 link)
type Node subtype V4L flags 0
device node name /dev/video1
pad0: Sink
<- "csi":1 [ENABLED,IMMUTABLE]

- entity 10: tw9910 2-0044 (1 pad, 1 link)
type V4L2 subdev subtype Decoder flags 0 device node name /dev/v4l-subdev1
pad0: Source
[fmt:UYVY8_2X8/720x576 field:interlaced-bt colorspace:smpte170m crop.bounds:(0,0)/768x576
crop:(0,0)/768x576]
-> "csi":0 [ENABLED,IMMUTABLE]

Thanks

Quoted 7 lines

or maybe dump the output of media-ctl -p and check the links and pads configurations.

Hope this helps.

Cheers,
Rui