media: pci: ipu3-cio2: Obtain remote pad from endpoint
Subsystems (2)
Sakari Ailus
maintainerPATCH v2 1/1 media: pci: ipu3-cio2: Obtain remote pad from endpoint
Use the endpoint fwnode to find out the remote pad, instead of using the first source pad found. Also improve error messages.
---
since v1:
- Drop pad variable.
- Wrap long lines.
drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-)
drivers/media/pci/intel/ipu3/ipu3-cio2-main.c +15 -16
@@ -1373,6 +1373,7 @@ static const struct v4l2_subdev_ops cio2_subdev_ops = {struct sensor_async_subdev {struct v4l2_async_subdev asd;struct csi2_bus_info csi2; +struct fwnode_endpoint endpoint; };#define to_sensor_asd (asd) container_of(asd, struct sensor_async_subdev, asd)
@@ -1417,31 +1418,28 @@ static int cio2_notifier_complete(struct v4l2_async_notifier *notifier)struct sensor_async_subdev *s_asd;struct v4l2_async_subdev *asd;struct cio2_queue *q; -unsigned int pad;int ret;list_for_each_entry (asd, &cio2->notifier.asd_list, asd_list) { s_asd =to_sensor_asd (asd); q = &cio2->queue[s_asd->csi2.port]; -for (pad =0 ; pad < q->sensor->entity.num_pads; pad++) -if (q->sensor->entity.pads[pad].flags & -MEDIA_PAD_FL_SOURCE ) -break ; - -if (pad == q->sensor->entity.num_pads) { -dev_err (dev,"failed to find src pad for %s\n" , - q->sensor->name); -return -ENXIO ; + ret =media_entity_get_fwnode_pad (&q->sensor->entity, + s_asd->endpoint.local_fwnode, +MEDIA_PAD_FL_SOURCE ); +if (ret <0 ) { +dev_err (dev,"no endpoint for %pfw (%d)\n" , + s_asd->endpoint.local_fwnode, ret); +return ret; } - ret =media_create_pad_link ( - &q->sensor->entity, pad, - &q->subdev.entity,CIO2_PAD_SINK , -0 ); + ret =media_create_pad_link (&q->sensor->entity, ret, + &q->subdev.entity,CIO2_PAD_SINK , +0 );if (ret) { -dev_err (dev,"failed to create link for %s\n" , - q->sensor->name); +dev_err (dev,"failed to create link for %s (endpoint %pfw, error %d)\n" , + q->sensor->name, s_asd->endpoint.local_fwnode, + ret);return ret; } }
@@ -1485,6 +1483,7 @@ static int cio2_parse_firmware(struct cio2_device *cio2) goto err_parse; } + s_asd->endpoint = vep.base; s_asd->csi2.port = vep.base.port; s_asd->csi2.lanes = vep.bus.mipi_csi2.num_data_lanes;
Signature · 1 line
2.30.2
Sakari,
Thanks for your patch.
Quoted 52 lines · Sakari Ailus
Use the endpoint fwnode to find out the remote pad, instead of using the first source pad found. Also improve error messages.
Signed-off-by Sakari Ailus <[email protected]>---
since v1:- Drop pad variable.
- Wrap long lines.
drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-)drivers/media/pci/intel/ipu3/ipu3-cio2-main.c +7
-10@@ -1373,6 +1373,7 @@ static const struct v4l2_subdev_ops cio2_subdev_ops = {struct sensor_async_subdev {struct v4l2_async_subdev asd;struct csi2_bus_info csi2; +struct fwnode_endpoint endpoint; };#define to_sensor_asd (asd) container_of(asd, struct sensor_async_subdev, asd)@@ -1417,31 +1418,28 @@ static int cio2_notifier_complete(struct v4l2_async_notifier *notifier)struct sensor_async_subdev *s_asd;struct v4l2_async_subdev *asd;struct cio2_queue *q; -unsigned int pad;int ret;list_for_each_entry (asd, &cio2->notifier.asd_list, asd_list) { s_asd =to_sensor_asd (asd); q = &cio2->queue[s_asd->csi2.port]; -for (pad =0 ; pad < q->sensor->entity.num_pads; pad++) -if (q->sensor->entity.pads[pad].flags & -MEDIA_PAD_FL_SOURCE ) -break ; - -if (pad == q->sensor->entity.num_pads) { -dev_err (dev,"failed to find src pad for %s\n" , - q->sensor->name); -return -ENXIO ; + ret =media_entity_get_fwnode_pad (&q->sensor->entity, + s_asd->endpoint.local_fwnode, +MEDIA_PAD_FL_SOURCE ); +if (ret <0 ) { +dev_err (dev,"no endpoint for %pfw (%d)\n" , + s_asd->endpoint.local_fwnode, ret);
drivers/media/pci/intel/ipu3/ipu3-cio2-main.c static int cio2_notifier_complete(struct v4l2_async_notifier *notifier) · line 1438
Quoted 10 lines
drivers/media/pci/intel/ipu3/ipu3-cio2-main.c +4
-4+return ret; } - ret =media_create_pad_link ( - &q->sensor->entity, pad, - &q->subdev.entity,CIO2_PAD_SINK , -0 ); + ret =media_create_pad_link (&q->sensor->entity, ret, + &q->subdev.entity,CIO2_PAD_SINK , +0 );
Is there some cases that sensor has multiple source pads?
drivers/media/pci/intel/ipu3/ipu3-cio2-main.c static int cio2_notifier_complete(struct v4l2_async_notifier *notifier) · line 1440
Quoted 4 lines
drivers/media/pci/intel/ipu3/ipu3-cio2-main.c +1
-2if (ret) { -dev_err (dev,"failed to create link for %s\n" , - q->sensor->name); + dev_err(dev, "failed to create link for %s (endpoint %pfw, error %d)\n",
Over 80, but it looks fine ;).
Quoted 14 lines
drivers/media/pci/intel/ipu3/ipu3-cio2-main.c +3
-0+ q->sensor->name, s_asd->endpoint.local_fwnode, + ret);return ret; } }@@ -1485,6 +1483,7 @@ static int cio2_parse_firmware(struct cio2_device *cio2) goto err_parse; } + s_asd->endpoint = vep.base; s_asd->csi2.port = vep.base.port; s_asd->csi2.lanes = vep.bus.mipi_csi2.num_data_lanes;
Signature · 2 lines
Best regards, Bingbu Cao
Sakari Ailus
maintainerHi Bingbu,
Quoted 61 lines · Bingbu Cao
Sakari,
Thanks for your patch.
Quoted 55 lines · Sakari Ailus
Use the endpoint fwnode to find out the remote pad, instead of using the first source pad found. Also improve error messages.
Signed-off-by Sakari Ailus <[email protected]>---
since v1:- Drop pad variable.
- Wrap long lines.
drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-)drivers/media/pci/intel/ipu3/ipu3-cio2-main.c +8
-10@@ -1373,6 +1373,7 @@ static const struct v4l2_subdev_ops cio2_subdev_ops = {struct sensor_async_subdev {struct v4l2_async_subdev asd;struct csi2_bus_info csi2; +struct fwnode_endpoint endpoint; };#define to_sensor_asd (asd) container_of(asd, struct sensor_async_subdev, asd)@@ -1417,31 +1418,28 @@ static int cio2_notifier_complete(struct v4l2_async_notifier *notifier)struct sensor_async_subdev *s_asd;struct v4l2_async_subdev *asd;struct cio2_queue *q; -unsigned int pad;int ret;list_for_each_entry (asd, &cio2->notifier.asd_list, asd_list) { s_asd =to_sensor_asd (asd); q = &cio2->queue[s_asd->csi2.port]; -for (pad =0 ; pad < q->sensor->entity.num_pads; pad++) -if (q->sensor->entity.pads[pad].flags & -MEDIA_PAD_FL_SOURCE ) -break ; - -if (pad == q->sensor->entity.num_pads) { -dev_err (dev,"failed to find src pad for %s\n" , - q->sensor->name); -return -ENXIO ; + ret =media_entity_get_fwnode_pad (&q->sensor->entity, + s_asd->endpoint.local_fwnode, +MEDIA_PAD_FL_SOURCE ); +if (ret <0 ) { +dev_err (dev,"no endpoint for %pfw (%d)\n" , + s_asd->endpoint.local_fwnode, ret); +return ret; }
Quoted 9 lines
drivers/media/pci/intel/ipu3/ipu3-cio2-main.c static int cio2_notifier_complete(struct v4l2_async_notifier *notifier) · line 1438
Quoted 7 lines
drivers/media/pci/intel/ipu3/ipu3-cio2-main.c +3
-4- ret =media_create_pad_link ( - &q->sensor->entity, pad, - &q->subdev.entity,CIO2_PAD_SINK , -0 ); + ret =media_create_pad_link (&q->sensor->entity, ret, + &q->subdev.entity,CIO2_PAD_SINK , +0 );Is there some cases that sensor has multiple source pads?
Then you'll have multiple connections between different ports --- and multiple links as well.
Signature · 1 line
Sakari Ailus
kernel test robot
build botkernel test robot noticed the following build warnings:
Hi Sakari,
kernel test robot noticed the following build warnings:
[auto build test WARNING on media-tree/master]
[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#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Sakari-Ailus/media-pci-ipu3-cio2-Obtain-remote-pad-from-endpoint/20230508-144532 base: git://linuxtv.org/media_tree.git master patch link: https://lore.kernel.org/r/20230508064123.979451-1-sakari.ailus%40linux.intel.com patch subject: [PATCH v2 1/1] media: pci: ipu3-cio2: Obtain remote pad from endpoint config: i386-allyesconfig (https://download.01.org/0day-ci/archive/20230508/[email protected]/config) compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce (this is a W=1 build):
# https://github.com/intel-lab-lkp/linux/commit/68c87524825aee53569c763e18948d5571271fa9
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Sakari-Ailus/media-pci-ipu3-cio2-Obtain-remote-pad-from-endpoint/20230508-144532 git checkout 68c87524825aee53569c763e18948d5571271fa9
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=i386 olddefconfig
make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/media/pci/intel/ipu3/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
drivers/media/pci/intel/ipu3/ipu3-cio2-main.c: In function 'cio2_notifier_complete':
>> drivers/media/pci/intel/ipu3/ipu3-cio2-main.c:1428:66: warning: passing argument 2 of 'media_entity_get_fwnode_pad' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
1428 | s_asd->endpoint.local_fwnode,
| ~~~~~~~~~~~~~~~^~~~~~~~~~~~~
In file included from include/media/media-device.h:20,
from include/media/media-request.h:20,
from include/media/v4l2-ctrls.h:14,
from drivers/media/pci/intel/ipu3/ipu3-cio2-main.c:25:
include/media/media-entity.h:1082:55: note: expected 'struct fwnode_handle *' but argument is of type 'const struct fwnode_handle *'
1082 | struct fwnode_handle *fwnode,
| ~~~~~~~~~~~~~~~~~~~~~~^~~~~~vim +1428 drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
1412
1413 /* .complete() is called after all subdevices have been located */
1414 static int cio2_notifier_complete(struct v4l2_async_notifier *notifier)
1415 {
1416 struct cio2_device *cio2 = to_cio2_device(notifier);
1417 struct device *dev = &cio2->pci_dev->dev;
1418 struct sensor_async_subdev *s_asd;
1419 struct v4l2_async_subdev *asd;
1420 struct cio2_queue *q;
1421 int ret;
1422
1423 list_for_each_entry(asd, &cio2->notifier.asd_list, asd_list) {
1424 s_asd = to_sensor_asd(asd);
1425 q = &cio2->queue[s_asd->csi2.port];
1426
1427 ret = media_entity_get_fwnode_pad(&q->sensor->entity,
> 1428 s_asd->endpoint.local_fwnode,
1429 MEDIA_PAD_FL_SOURCE);
1430 if (ret < 0) {
1431 dev_err(dev, "no endpoint for %pfw (%d)\n",
1432 s_asd->endpoint.local_fwnode, ret);
1433 return ret;
1434 }
1435
1436 ret = media_create_pad_link(&q->sensor->entity, ret,
1437 &q->subdev.entity, CIO2_PAD_SINK,
1438 0);
1439 if (ret) {
1440 dev_err(dev, "failed to create link for %s (endpoint %pfw, error %d)\n",
1441 q->sensor->name, s_asd->endpoint.local_fwnode,
1442 ret);
1443 return ret;
1444 }
1445 }
1446
1447 return v4l2_device_register_subdev_nodes(&cio2->v4l2_dev);
1448 }
1449
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Sakari,
kernel test robot noticed the following build errors:
[auto build test ERROR on media-tree/master]
[also build test ERROR on sailus-media-tree/streams linus/master v6.4-rc1 next-20230508] [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#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Sakari-Ailus/media-pci-ipu3-cio2-Obtain-remote-pad-from-endpoint/20230508-144532 base: git://linuxtv.org/media_tree.git master patch link: https://lore.kernel.org/r/20230508064123.979451-1-sakari.ailus%40linux.intel.com patch subject: [PATCH v2 1/1] media: pci: ipu3-cio2: Obtain remote pad from endpoint config: x86_64-buildonly-randconfig-r002-20230508 (https://download.01.org/0day-ci/archive/20230508/[email protected]/config) compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
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/intel-lab-lkp/linux/commit/68c87524825aee53569c763e18948d5571271fa9
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Sakari-Ailus/media-pci-ipu3-cio2-Obtain-remote-pad-from-endpoint/20230508-144532 git checkout 68c87524825aee53569c763e18948d5571271fa9
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/media/pci/intel/ipu3/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> drivers/media/pci/intel/ipu3/ipu3-cio2-main.c:1428:9: error: passing 'const struct fwnode_handle *' to parameter of type 'struct fwnode_handle *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
s_asd->endpoint.local_fwnode,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/media/media-entity.h:1082:27: note: passing argument to parameter 'fwnode' here
struct fwnode_handle *fwnode,
^
1 error generated.
vim +1428 drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
1412
1413 /* .complete() is called after all subdevices have been located */
1414 static int cio2_notifier_complete(struct v4l2_async_notifier *notifier)
1415 {
1416 struct cio2_device *cio2 = to_cio2_device(notifier);
1417 struct device *dev = &cio2->pci_dev->dev;
1418 struct sensor_async_subdev *s_asd;
1419 struct v4l2_async_subdev *asd;
1420 struct cio2_queue *q;
1421 int ret;
1422
1423 list_for_each_entry(asd, &cio2->notifier.asd_list, asd_list) {
1424 s_asd = to_sensor_asd(asd);
1425 q = &cio2->queue[s_asd->csi2.port];
1426
1427 ret = media_entity_get_fwnode_pad(&q->sensor->entity,
> 1428 s_asd->endpoint.local_fwnode,
1429 MEDIA_PAD_FL_SOURCE);
1430 if (ret < 0) {
1431 dev_err(dev, "no endpoint for %pfw (%d)\n",
1432 s_asd->endpoint.local_fwnode, ret);
1433 return ret;
1434 }
1435
1436 ret = media_create_pad_link(&q->sensor->entity, ret,
1437 &q->subdev.entity, CIO2_PAD_SINK,
1438 0);
1439 if (ret) {
1440 dev_err(dev, "failed to create link for %s (endpoint %pfw, error %d)\n",
1441 q->sensor->name, s_asd->endpoint.local_fwnode,
1442 ret);
1443 return ret;
1444 }
1445 }
1446
1447 return v4l2_device_register_subdev_nodes(&cio2->v4l2_dev);
1448 }
1449
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests