* Re: [PATCH] RFC: media: v4l2-subdev: add subdev-wide config struct
2021-04-09 13:36 [PATCH] RFC: media: v4l2-subdev: add subdev-wide config struct Tomi Valkeinen
@ 2021-04-09 16:28 ` kernel test robot
2021-04-09 16:29 ` kernel test robot
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2021-04-09 16:28 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 13718 bytes --]
Hi Tomi,
[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.12-rc6 next-20210409]
[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/Tomi-Valkeinen/RFC-media-v4l2-subdev-add-subdev-wide-config-struct/20210409-213822
base: git://linuxtv.org/media_tree.git master
config: m68k-allmodconfig (attached as .config)
compiler: m68k-linux-gcc (GCC) 9.3.0
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/4690ebdd6fd3180366038788f7df1fa2420f00c9
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Tomi-Valkeinen/RFC-media-v4l2-subdev-add-subdev-wide-config-struct/20210409-213822
git checkout 4690ebdd6fd3180366038788f7df1fa2420f00c9
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=m68k
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
In file included from include/linux/kernel.h:10,
from include/linux/delay.h:22,
from drivers/staging/media/imx/imx-ic-prpencvf.c:11:
include/linux/scatterlist.h: In function 'sg_set_buf':
arch/m68k/include/asm/page_mm.h:174:49: warning: ordered comparison of pointer with null pointer [-Wextra]
174 | #define virt_addr_valid(kaddr) ((void *)(kaddr) >= (void *)PAGE_OFFSET && (void *)(kaddr) < high_memory)
| ^~
include/linux/compiler.h:78:42: note: in definition of macro 'unlikely'
78 | # define unlikely(x) __builtin_expect(!!(x), 0)
| ^
include/linux/scatterlist.h:137:2: note: in expansion of macro 'BUG_ON'
137 | BUG_ON(!virt_addr_valid(buf));
| ^~~~~~
include/linux/scatterlist.h:137:10: note: in expansion of macro 'virt_addr_valid'
137 | BUG_ON(!virt_addr_valid(buf));
| ^~~~~~~~~~~~~~~
drivers/staging/media/imx/imx-ic-prpencvf.c: In function '__prp_get_fmt':
>> drivers/staging/media/imx/imx-ic-prpencvf.c:796:51: error: passing argument 2 of 'v4l2_subdev_get_try_format' from incompatible pointer type [-Werror=incompatible-pointer-types]
796 | return v4l2_subdev_get_try_format(&ic_priv->sd, cfg, pad);
| ^~~
| |
| struct v4l2_subdev_pad_config *
In file included from include/media/v4l2-device.h:13,
from drivers/staging/media/imx/imx-ic-prpencvf.c:19:
include/media/v4l2-subdev.h:957:34: note: expected 'struct v4l2_subdev_config *' but argument is of type 'struct v4l2_subdev_pad_config *'
957 | struct v4l2_subdev_config *cfg,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
drivers/staging/media/imx/imx-ic-prpencvf.c: At top level:
>> drivers/staging/media/imx/imx-ic-prpencvf.c:1300:14: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *)' [-Werror=incompatible-pointer-types]
1300 | .init_cfg = imx_media_init_cfg,
| ^~~~~~~~~~~~~~~~~~
drivers/staging/media/imx/imx-ic-prpencvf.c:1300:14: note: (near initialization for 'prp_pad_ops.init_cfg')
>> drivers/staging/media/imx/imx-ic-prpencvf.c:1301:20: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_mbus_code_enum *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_mbus_code_enum *)' [-Werror=incompatible-pointer-types]
1301 | .enum_mbus_code = prp_enum_mbus_code,
| ^~~~~~~~~~~~~~~~~~
drivers/staging/media/imx/imx-ic-prpencvf.c:1301:20: note: (near initialization for 'prp_pad_ops.enum_mbus_code')
>> drivers/staging/media/imx/imx-ic-prpencvf.c:1302:21: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_frame_size_enum *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_frame_size_enum *)' [-Werror=incompatible-pointer-types]
1302 | .enum_frame_size = prp_enum_frame_size,
| ^~~~~~~~~~~~~~~~~~~
drivers/staging/media/imx/imx-ic-prpencvf.c:1302:21: note: (near initialization for 'prp_pad_ops.enum_frame_size')
drivers/staging/media/imx/imx-ic-prpencvf.c:1303:13: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_format *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_format *)' [-Werror=incompatible-pointer-types]
1303 | .get_fmt = prp_get_fmt,
| ^~~~~~~~~~~
drivers/staging/media/imx/imx-ic-prpencvf.c:1303:13: note: (near initialization for 'prp_pad_ops.get_fmt')
drivers/staging/media/imx/imx-ic-prpencvf.c:1304:13: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_format *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_format *)' [-Werror=incompatible-pointer-types]
1304 | .set_fmt = prp_set_fmt,
| ^~~~~~~~~~~
drivers/staging/media/imx/imx-ic-prpencvf.c:1304:13: note: (near initialization for 'prp_pad_ops.set_fmt')
cc1: some warnings being treated as errors
--
In file included from include/linux/dev_printk.h:14,
from include/linux/device.h:15,
from drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c:9:
include/linux/scatterlist.h: In function 'sg_set_buf':
arch/m68k/include/asm/page_mm.h:174:49: warning: ordered comparison of pointer with null pointer [-Wextra]
174 | #define virt_addr_valid(kaddr) ((void *)(kaddr) >= (void *)PAGE_OFFSET && (void *)(kaddr) < high_memory)
| ^~
include/linux/compiler.h:78:42: note: in definition of macro 'unlikely'
78 | # define unlikely(x) __builtin_expect(!!(x), 0)
| ^
include/linux/scatterlist.h:137:2: note: in expansion of macro 'BUG_ON'
137 | BUG_ON(!virt_addr_valid(buf));
| ^~~~~~
include/linux/scatterlist.h:137:10: note: in expansion of macro 'virt_addr_valid'
137 | BUG_ON(!virt_addr_valid(buf));
| ^~~~~~~~~~~~~~~
drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c: In function 'sun4i_csi_subdev_init_cfg':
>> drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c:276:43: error: passing argument 2 of 'v4l2_subdev_get_try_format' from incompatible pointer type [-Werror=incompatible-pointer-types]
276 | fmt = v4l2_subdev_get_try_format(subdev, cfg, CSI_SUBDEV_SINK);
| ^~~
| |
| struct v4l2_subdev_pad_config *
In file included from include/media/v4l2-mc.h:15,
from drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c:13:
include/media/v4l2-subdev.h:957:34: note: expected 'struct v4l2_subdev_config *' but argument is of type 'struct v4l2_subdev_pad_config *'
957 | struct v4l2_subdev_config *cfg,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c: In function 'sun4i_csi_subdev_get_fmt':
drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c:290:51: error: passing argument 2 of 'v4l2_subdev_get_try_format' from incompatible pointer type [-Werror=incompatible-pointer-types]
290 | subdev_fmt = v4l2_subdev_get_try_format(subdev, cfg, fmt->pad);
| ^~~
| |
| struct v4l2_subdev_pad_config *
In file included from include/media/v4l2-mc.h:15,
from drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c:13:
include/media/v4l2-subdev.h:957:34: note: expected 'struct v4l2_subdev_config *' but argument is of type 'struct v4l2_subdev_pad_config *'
957 | struct v4l2_subdev_config *cfg,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c: In function 'sun4i_csi_subdev_set_fmt':
drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c:307:51: error: passing argument 2 of 'v4l2_subdev_get_try_format' from incompatible pointer type [-Werror=incompatible-pointer-types]
307 | subdev_fmt = v4l2_subdev_get_try_format(subdev, cfg, fmt->pad);
| ^~~
| |
| struct v4l2_subdev_pad_config *
In file included from include/media/v4l2-mc.h:15,
from drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c:13:
include/media/v4l2-subdev.h:957:34: note: expected 'struct v4l2_subdev_config *' but argument is of type 'struct v4l2_subdev_pad_config *'
957 | struct v4l2_subdev_config *cfg,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c: At top level:
>> drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c:339:14: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *)' [-Werror=incompatible-pointer-types]
339 | .init_cfg = sun4i_csi_subdev_init_cfg,
| ^~~~~~~~~~~~~~~~~~~~~~~~~
drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c:339:14: note: (near initialization for 'sun4i_csi_subdev_pad_ops.init_cfg')
>> drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c:340:13: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_format *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_format *)' [-Werror=incompatible-pointer-types]
340 | .get_fmt = sun4i_csi_subdev_get_fmt,
| ^~~~~~~~~~~~~~~~~~~~~~~~
drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c:340:13: note: (near initialization for 'sun4i_csi_subdev_pad_ops.get_fmt')
drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c:341:13: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_format *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_format *)' [-Werror=incompatible-pointer-types]
341 | .set_fmt = sun4i_csi_subdev_set_fmt,
| ^~~~~~~~~~~~~~~~~~~~~~~~
drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c:341:13: note: (near initialization for 'sun4i_csi_subdev_pad_ops.set_fmt')
>> drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c:342:20: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_mbus_code_enum *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_mbus_code_enum *)' [-Werror=incompatible-pointer-types]
342 | .enum_mbus_code = sun4i_csi_subdev_enum_mbus_code,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c:342:20: note: (near initialization for 'sun4i_csi_subdev_pad_ops.enum_mbus_code')
cc1: some warnings being treated as errors
vim +/v4l2_subdev_get_try_format +796 drivers/staging/media/imx/imx-ic-prpencvf.c
f0d9c8924e2c33 Steve Longerbeam 2017-06-07 788
f0d9c8924e2c33 Steve Longerbeam 2017-06-07 789 static struct v4l2_mbus_framefmt *
f0d9c8924e2c33 Steve Longerbeam 2017-06-07 790 __prp_get_fmt(struct prp_priv *priv, struct v4l2_subdev_pad_config *cfg,
f0d9c8924e2c33 Steve Longerbeam 2017-06-07 791 unsigned int pad, enum v4l2_subdev_format_whence which)
f0d9c8924e2c33 Steve Longerbeam 2017-06-07 792 {
f0d9c8924e2c33 Steve Longerbeam 2017-06-07 793 struct imx_ic_priv *ic_priv = priv->ic_priv;
f0d9c8924e2c33 Steve Longerbeam 2017-06-07 794
f0d9c8924e2c33 Steve Longerbeam 2017-06-07 795 if (which == V4L2_SUBDEV_FORMAT_TRY)
f0d9c8924e2c33 Steve Longerbeam 2017-06-07 @796 return v4l2_subdev_get_try_format(&ic_priv->sd, cfg, pad);
f0d9c8924e2c33 Steve Longerbeam 2017-06-07 797 else
f0d9c8924e2c33 Steve Longerbeam 2017-06-07 798 return &priv->format_mbus[pad];
f0d9c8924e2c33 Steve Longerbeam 2017-06-07 799 }
f0d9c8924e2c33 Steve Longerbeam 2017-06-07 800
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 59852 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] RFC: media: v4l2-subdev: add subdev-wide config struct
2021-04-09 13:36 [PATCH] RFC: media: v4l2-subdev: add subdev-wide config struct Tomi Valkeinen
2021-04-09 16:28 ` kernel test robot
@ 2021-04-09 16:29 ` kernel test robot
2021-04-18 16:07 ` Laurent Pinchart
2021-04-20 15:35 ` Sakari Ailus
3 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2021-04-09 16:29 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 44076 bytes --]
Hi Tomi,
[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.12-rc6 next-20210409]
[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/Tomi-Valkeinen/RFC-media-v4l2-subdev-add-subdev-wide-config-struct/20210409-213822
base: git://linuxtv.org/media_tree.git master
config: parisc-randconfig-r003-20210409 (attached as .config)
compiler: hppa-linux-gcc (GCC) 9.3.0
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/4690ebdd6fd3180366038788f7df1fa2420f00c9
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Tomi-Valkeinen/RFC-media-v4l2-subdev-add-subdev-wide-config-struct/20210409-213822
git checkout 4690ebdd6fd3180366038788f7df1fa2420f00c9
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=parisc
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
drivers/media/i2c/tda1997x.c: In function 'tda1997x_init_cfg':
>> drivers/media/i2c/tda1997x.c:1726:38: error: passing argument 2 of 'v4l2_subdev_get_try_format' from incompatible pointer type [-Werror=incompatible-pointer-types]
1726 | mf = v4l2_subdev_get_try_format(sd, cfg, 0);
| ^~~
| |
| struct v4l2_subdev_pad_config *
In file included from include/media/v4l2-device.h:13,
from drivers/media/i2c/tda1997x.c:20:
include/media/v4l2-subdev.h:957:34: note: expected 'struct v4l2_subdev_config *' but argument is of type 'struct v4l2_subdev_pad_config *'
957 | struct v4l2_subdev_config *cfg,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
drivers/media/i2c/tda1997x.c: In function 'tda1997x_get_format':
drivers/media/i2c/tda1997x.c:1778:40: error: passing argument 2 of 'v4l2_subdev_get_try_format' from incompatible pointer type [-Werror=incompatible-pointer-types]
1778 | fmt = v4l2_subdev_get_try_format(sd, cfg, format->pad);
| ^~~
| |
| struct v4l2_subdev_pad_config *
In file included from include/media/v4l2-device.h:13,
from drivers/media/i2c/tda1997x.c:20:
include/media/v4l2-subdev.h:957:34: note: expected 'struct v4l2_subdev_config *' but argument is of type 'struct v4l2_subdev_pad_config *'
957 | struct v4l2_subdev_config *cfg,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
drivers/media/i2c/tda1997x.c: In function 'tda1997x_set_format':
drivers/media/i2c/tda1997x.c:1812:40: error: passing argument 2 of 'v4l2_subdev_get_try_format' from incompatible pointer type [-Werror=incompatible-pointer-types]
1812 | fmt = v4l2_subdev_get_try_format(sd, cfg, format->pad);
| ^~~
| |
| struct v4l2_subdev_pad_config *
In file included from include/media/v4l2-device.h:13,
from drivers/media/i2c/tda1997x.c:20:
include/media/v4l2-subdev.h:957:34: note: expected 'struct v4l2_subdev_config *' but argument is of type 'struct v4l2_subdev_pad_config *'
957 | struct v4l2_subdev_config *cfg,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
drivers/media/i2c/tda1997x.c: At top level:
>> drivers/media/i2c/tda1997x.c:1911:14: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *)' [-Werror=incompatible-pointer-types]
1911 | .init_cfg = tda1997x_init_cfg,
| ^~~~~~~~~~~~~~~~~
drivers/media/i2c/tda1997x.c:1911:14: note: (near initialization for 'tda1997x_pad_ops.init_cfg')
>> drivers/media/i2c/tda1997x.c:1912:20: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_mbus_code_enum *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_mbus_code_enum *)' [-Werror=incompatible-pointer-types]
1912 | .enum_mbus_code = tda1997x_enum_mbus_code,
| ^~~~~~~~~~~~~~~~~~~~~~~
drivers/media/i2c/tda1997x.c:1912:20: note: (near initialization for 'tda1997x_pad_ops.enum_mbus_code')
>> drivers/media/i2c/tda1997x.c:1913:13: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_format *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_format *)' [-Werror=incompatible-pointer-types]
1913 | .get_fmt = tda1997x_get_format,
| ^~~~~~~~~~~~~~~~~~~
drivers/media/i2c/tda1997x.c:1913:13: note: (near initialization for 'tda1997x_pad_ops.get_fmt')
drivers/media/i2c/tda1997x.c:1914:13: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_format *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_format *)' [-Werror=incompatible-pointer-types]
1914 | .set_fmt = tda1997x_set_format,
| ^~~~~~~~~~~~~~~~~~~
drivers/media/i2c/tda1997x.c:1914:13: note: (near initialization for 'tda1997x_pad_ops.set_fmt')
cc1: some warnings being treated as errors
--
>> drivers/media/i2c/saa7115.c:1615:13: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_format *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_format *)' [-Werror=incompatible-pointer-types]
1615 | .set_fmt = saa711x_set_fmt,
| ^~~~~~~~~~~~~~~
drivers/media/i2c/saa7115.c:1615:13: note: (near initialization for 'saa711x_pad_ops.set_fmt')
cc1: some warnings being treated as errors
--
>> drivers/media/i2c/adv7170.c:325:20: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_mbus_code_enum *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_mbus_code_enum *)' [-Werror=incompatible-pointer-types]
325 | .enum_mbus_code = adv7170_enum_mbus_code,
| ^~~~~~~~~~~~~~~~~~~~~~
drivers/media/i2c/adv7170.c:325:20: note: (near initialization for 'adv7170_pad_ops.enum_mbus_code')
>> drivers/media/i2c/adv7170.c:326:13: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_format *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_format *)' [-Werror=incompatible-pointer-types]
326 | .get_fmt = adv7170_get_fmt,
| ^~~~~~~~~~~~~~~
drivers/media/i2c/adv7170.c:326:13: note: (near initialization for 'adv7170_pad_ops.get_fmt')
drivers/media/i2c/adv7170.c:327:13: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_format *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_format *)' [-Werror=incompatible-pointer-types]
327 | .set_fmt = adv7170_set_fmt,
| ^~~~~~~~~~~~~~~
drivers/media/i2c/adv7170.c:327:13: note: (near initialization for 'adv7170_pad_ops.set_fmt')
cc1: some warnings being treated as errors
--
drivers/media/i2c/adv7180.c: In function 'adv7180_get_pad_format':
>> drivers/media/i2c/adv7180.c:708:52: error: passing argument 2 of 'v4l2_subdev_get_try_format' from incompatible pointer type [-Werror=incompatible-pointer-types]
708 | format->format = *v4l2_subdev_get_try_format(sd, cfg, 0);
| ^~~
| |
| struct v4l2_subdev_pad_config *
In file included from include/media/v4l2-device.h:13,
from drivers/media/i2c/adv7180.c:20:
include/media/v4l2-subdev.h:957:34: note: expected 'struct v4l2_subdev_config *' but argument is of type 'struct v4l2_subdev_pad_config *'
957 | struct v4l2_subdev_config *cfg,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
drivers/media/i2c/adv7180.c: In function 'adv7180_set_pad_format':
drivers/media/i2c/adv7180.c:745:45: error: passing argument 2 of 'v4l2_subdev_get_try_format' from incompatible pointer type [-Werror=incompatible-pointer-types]
745 | framefmt = v4l2_subdev_get_try_format(sd, cfg, 0);
| ^~~
| |
| struct v4l2_subdev_pad_config *
In file included from include/media/v4l2-device.h:13,
from drivers/media/i2c/adv7180.c:20:
include/media/v4l2-subdev.h:957:34: note: expected 'struct v4l2_subdev_config *' but argument is of type 'struct v4l2_subdev_pad_config *'
957 | struct v4l2_subdev_config *cfg,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
drivers/media/i2c/adv7180.c: At top level:
>> drivers/media/i2c/adv7180.c:868:14: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *)' [-Werror=incompatible-pointer-types]
868 | .init_cfg = adv7180_init_cfg,
| ^~~~~~~~~~~~~~~~
drivers/media/i2c/adv7180.c:868:14: note: (near initialization for 'adv7180_pad_ops.init_cfg')
>> drivers/media/i2c/adv7180.c:869:20: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_mbus_code_enum *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_mbus_code_enum *)' [-Werror=incompatible-pointer-types]
869 | .enum_mbus_code = adv7180_enum_mbus_code,
| ^~~~~~~~~~~~~~~~~~~~~~
drivers/media/i2c/adv7180.c:869:20: note: (near initialization for 'adv7180_pad_ops.enum_mbus_code')
>> drivers/media/i2c/adv7180.c:870:13: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_format *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_format *)' [-Werror=incompatible-pointer-types]
870 | .set_fmt = adv7180_set_pad_format,
| ^~~~~~~~~~~~~~~~~~~~~~
drivers/media/i2c/adv7180.c:870:13: note: (near initialization for 'adv7180_pad_ops.set_fmt')
drivers/media/i2c/adv7180.c:871:13: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_format *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_format *)' [-Werror=incompatible-pointer-types]
871 | .get_fmt = adv7180_get_pad_format,
| ^~~~~~~~~~~~~~~~~~~~~~
drivers/media/i2c/adv7180.c:871:13: note: (near initialization for 'adv7180_pad_ops.get_fmt')
cc1: some warnings being treated as errors
--
>> drivers/media/i2c/adv7183.c:513:20: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_mbus_code_enum *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_mbus_code_enum *)' [-Werror=incompatible-pointer-types]
513 | .enum_mbus_code = adv7183_enum_mbus_code,
| ^~~~~~~~~~~~~~~~~~~~~~
drivers/media/i2c/adv7183.c:513:20: note: (near initialization for 'adv7183_pad_ops.enum_mbus_code')
>> drivers/media/i2c/adv7183.c:514:13: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_format *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_format *)' [-Werror=incompatible-pointer-types]
514 | .get_fmt = adv7183_get_fmt,
| ^~~~~~~~~~~~~~~
drivers/media/i2c/adv7183.c:514:13: note: (near initialization for 'adv7183_pad_ops.get_fmt')
drivers/media/i2c/adv7183.c:515:13: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_format *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_format *)' [-Werror=incompatible-pointer-types]
515 | .set_fmt = adv7183_set_fmt,
| ^~~~~~~~~~~~~~~
drivers/media/i2c/adv7183.c:515:13: note: (near initialization for 'adv7183_pad_ops.set_fmt')
cc1: some warnings being treated as errors
--
drivers/media/i2c/adv7842.c: In function 'adv7842_get_format':
>> drivers/media/i2c/adv7842.c:2095:40: error: passing argument 2 of 'v4l2_subdev_get_try_format' from incompatible pointer type [-Werror=incompatible-pointer-types]
2095 | fmt = v4l2_subdev_get_try_format(sd, cfg, format->pad);
| ^~~
| |
| struct v4l2_subdev_pad_config *
In file included from include/media/v4l2-device.h:13,
from drivers/media/i2c/adv7842.c:30:
include/media/v4l2-subdev.h:957:34: note: expected 'struct v4l2_subdev_config *' but argument is of type 'struct v4l2_subdev_pad_config *'
957 | struct v4l2_subdev_config *cfg,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
drivers/media/i2c/adv7842.c: In function 'adv7842_set_format':
drivers/media/i2c/adv7842.c:2127:40: error: passing argument 2 of 'v4l2_subdev_get_try_format' from incompatible pointer type [-Werror=incompatible-pointer-types]
2127 | fmt = v4l2_subdev_get_try_format(sd, cfg, format->pad);
| ^~~
| |
| struct v4l2_subdev_pad_config *
In file included from include/media/v4l2-device.h:13,
from drivers/media/i2c/adv7842.c:30:
include/media/v4l2-subdev.h:957:34: note: expected 'struct v4l2_subdev_config *' but argument is of type 'struct v4l2_subdev_pad_config *'
957 | struct v4l2_subdev_config *cfg,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
drivers/media/i2c/adv7842.c: At top level:
>> drivers/media/i2c/adv7842.c:3300:20: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_mbus_code_enum *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_mbus_code_enum *)' [-Werror=incompatible-pointer-types]
3300 | .enum_mbus_code = adv7842_enum_mbus_code,
| ^~~~~~~~~~~~~~~~~~~~~~
drivers/media/i2c/adv7842.c:3300:20: note: (near initialization for 'adv7842_pad_ops.enum_mbus_code')
>> drivers/media/i2c/adv7842.c:3301:13: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_format *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_format *)' [-Werror=incompatible-pointer-types]
3301 | .get_fmt = adv7842_get_format,
| ^~~~~~~~~~~~~~~~~~
drivers/media/i2c/adv7842.c:3301:13: note: (near initialization for 'adv7842_pad_ops.get_fmt')
drivers/media/i2c/adv7842.c:3302:13: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_format *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_format *)' [-Werror=incompatible-pointer-types]
3302 | .set_fmt = adv7842_set_format,
| ^~~~~~~~~~~~~~~~~~
drivers/media/i2c/adv7842.c:3302:13: note: (near initialization for 'adv7842_pad_ops.set_fmt')
cc1: some warnings being treated as errors
--
drivers/media/i2c/adv7511-v4l2.c: In function 'adv7511_get_fmt':
>> drivers/media/i2c/adv7511-v4l2.c:1264:40: error: passing argument 2 of 'v4l2_subdev_get_try_format' from incompatible pointer type [-Werror=incompatible-pointer-types]
1264 | fmt = v4l2_subdev_get_try_format(sd, cfg, format->pad);
| ^~~
| |
| struct v4l2_subdev_pad_config *
In file included from include/media/v4l2-device.h:13,
from drivers/media/i2c/adv7511-v4l2.c:24:
include/media/v4l2-subdev.h:957:34: note: expected 'struct v4l2_subdev_config *' but argument is of type 'struct v4l2_subdev_pad_config *'
957 | struct v4l2_subdev_config *cfg,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
drivers/media/i2c/adv7511-v4l2.c: In function 'adv7511_set_fmt':
drivers/media/i2c/adv7511-v4l2.c:1319:40: error: passing argument 2 of 'v4l2_subdev_get_try_format' from incompatible pointer type [-Werror=incompatible-pointer-types]
1319 | fmt = v4l2_subdev_get_try_format(sd, cfg, format->pad);
| ^~~
| |
| struct v4l2_subdev_pad_config *
In file included from include/media/v4l2-device.h:13,
from drivers/media/i2c/adv7511-v4l2.c:24:
include/media/v4l2-subdev.h:957:34: note: expected 'struct v4l2_subdev_config *' but argument is of type 'struct v4l2_subdev_pad_config *'
957 | struct v4l2_subdev_config *cfg,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
drivers/media/i2c/adv7511-v4l2.c: At top level:
>> drivers/media/i2c/adv7511-v4l2.c:1426:20: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_mbus_code_enum *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_mbus_code_enum *)' [-Werror=incompatible-pointer-types]
1426 | .enum_mbus_code = adv7511_enum_mbus_code,
| ^~~~~~~~~~~~~~~~~~~~~~
drivers/media/i2c/adv7511-v4l2.c:1426:20: note: (near initialization for 'adv7511_pad_ops.enum_mbus_code')
>> drivers/media/i2c/adv7511-v4l2.c:1427:13: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_format *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_format *)' [-Werror=incompatible-pointer-types]
1427 | .get_fmt = adv7511_get_fmt,
| ^~~~~~~~~~~~~~~
drivers/media/i2c/adv7511-v4l2.c:1427:13: note: (near initialization for 'adv7511_pad_ops.get_fmt')
drivers/media/i2c/adv7511-v4l2.c:1428:13: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_format *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_format *)' [-Werror=incompatible-pointer-types]
1428 | .set_fmt = adv7511_set_fmt,
| ^~~~~~~~~~~~~~~
drivers/media/i2c/adv7511-v4l2.c:1428:13: note: (near initialization for 'adv7511_pad_ops.set_fmt')
cc1: some warnings being treated as errors
--
drivers/media/i2c/tvp5150.c: In function 'tvp5150_get_pad_crop':
>> drivers/media/i2c/tvp5150.c:1038:49: error: passing argument 2 of 'v4l2_subdev_get_try_crop' from incompatible pointer type [-Werror=incompatible-pointer-types]
1038 | return v4l2_subdev_get_try_crop(&decoder->sd, cfg, pad);
| ^~~
| |
| struct v4l2_subdev_pad_config *
In file included from include/media/v4l2-device.h:13,
from drivers/media/i2c/tvp5150.c:19:
include/media/v4l2-subdev.h:975:32: note: expected 'struct v4l2_subdev_config *' but argument is of type 'struct v4l2_subdev_pad_config *'
975 | struct v4l2_subdev_config *cfg,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
drivers/media/i2c/tvp5150.c: At top level:
>> drivers/media/i2c/tvp5150.c:1733:14: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *)' [-Werror=incompatible-pointer-types]
1733 | .init_cfg = tvp5150_init_cfg,
| ^~~~~~~~~~~~~~~~
drivers/media/i2c/tvp5150.c:1733:14: note: (near initialization for 'tvp5150_pad_ops.init_cfg')
>> drivers/media/i2c/tvp5150.c:1734:20: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_mbus_code_enum *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_mbus_code_enum *)' [-Werror=incompatible-pointer-types]
1734 | .enum_mbus_code = tvp5150_enum_mbus_code,
| ^~~~~~~~~~~~~~~~~~~~~~
drivers/media/i2c/tvp5150.c:1734:20: note: (near initialization for 'tvp5150_pad_ops.enum_mbus_code')
>> drivers/media/i2c/tvp5150.c:1735:21: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_frame_size_enum *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_frame_size_enum *)' [-Werror=incompatible-pointer-types]
1735 | .enum_frame_size = tvp5150_enum_frame_size,
| ^~~~~~~~~~~~~~~~~~~~~~~
drivers/media/i2c/tvp5150.c:1735:21: note: (near initialization for 'tvp5150_pad_ops.enum_frame_size')
>> drivers/media/i2c/tvp5150.c:1736:13: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_format *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_format *)' [-Werror=incompatible-pointer-types]
1736 | .set_fmt = tvp5150_fill_fmt,
| ^~~~~~~~~~~~~~~~
drivers/media/i2c/tvp5150.c:1736:13: note: (near initialization for 'tvp5150_pad_ops.set_fmt')
drivers/media/i2c/tvp5150.c:1737:13: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_format *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_format *)' [-Werror=incompatible-pointer-types]
1737 | .get_fmt = tvp5150_fill_fmt,
| ^~~~~~~~~~~~~~~~
drivers/media/i2c/tvp5150.c:1737:13: note: (near initialization for 'tvp5150_pad_ops.get_fmt')
>> drivers/media/i2c/tvp5150.c:1738:19: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_selection *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_selection *)' [-Werror=incompatible-pointer-types]
1738 | .get_selection = tvp5150_get_selection,
| ^~~~~~~~~~~~~~~~~~~~~
drivers/media/i2c/tvp5150.c:1738:19: note: (near initialization for 'tvp5150_pad_ops.get_selection')
drivers/media/i2c/tvp5150.c:1739:19: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_selection *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_selection *)' [-Werror=incompatible-pointer-types]
1739 | .set_selection = tvp5150_set_selection,
| ^~~~~~~~~~~~~~~~~~~~~
drivers/media/i2c/tvp5150.c:1739:19: note: (near initialization for 'tvp5150_pad_ops.set_selection')
cc1: some warnings being treated as errors
--
>> drivers/media/i2c/tw9910.c:915:20: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_mbus_code_enum *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_mbus_code_enum *)' [-Werror=incompatible-pointer-types]
915 | .enum_mbus_code = tw9910_enum_mbus_code,
| ^~~~~~~~~~~~~~~~~~~~~
drivers/media/i2c/tw9910.c:915:20: note: (near initialization for 'tw9910_subdev_pad_ops.enum_mbus_code')
>> drivers/media/i2c/tw9910.c:916:19: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_selection *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_selection *)' [-Werror=incompatible-pointer-types]
916 | .get_selection = tw9910_get_selection,
| ^~~~~~~~~~~~~~~~~~~~
drivers/media/i2c/tw9910.c:916:19: note: (near initialization for 'tw9910_subdev_pad_ops.get_selection')
>> drivers/media/i2c/tw9910.c:917:13: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_format *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_format *)' [-Werror=incompatible-pointer-types]
917 | .get_fmt = tw9910_get_fmt,
| ^~~~~~~~~~~~~~
drivers/media/i2c/tw9910.c:917:13: note: (near initialization for 'tw9910_subdev_pad_ops.get_fmt')
drivers/media/i2c/tw9910.c:918:13: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_format *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_format *)' [-Werror=incompatible-pointer-types]
918 | .set_fmt = tw9910_set_fmt,
| ^~~~~~~~~~~~~~
drivers/media/i2c/tw9910.c:918:13: note: (near initialization for 'tw9910_subdev_pad_ops.set_fmt')
cc1: some warnings being treated as errors
--
>> drivers/media/i2c/ml86v7667.c:298:20: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_mbus_code_enum *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_mbus_code_enum *)' [-Werror=incompatible-pointer-types]
298 | .enum_mbus_code = ml86v7667_enum_mbus_code,
| ^~~~~~~~~~~~~~~~~~~~~~~~
drivers/media/i2c/ml86v7667.c:298:20: note: (near initialization for 'ml86v7667_subdev_pad_ops.enum_mbus_code')
>> drivers/media/i2c/ml86v7667.c:299:13: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_format *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_format *)' [-Werror=incompatible-pointer-types]
299 | .get_fmt = ml86v7667_fill_fmt,
| ^~~~~~~~~~~~~~~~~~
drivers/media/i2c/ml86v7667.c:299:13: note: (near initialization for 'ml86v7667_subdev_pad_ops.get_fmt')
drivers/media/i2c/ml86v7667.c:300:13: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_format *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_format *)' [-Werror=incompatible-pointer-types]
300 | .set_fmt = ml86v7667_fill_fmt,
| ^~~~~~~~~~~~~~~~~~
drivers/media/i2c/ml86v7667.c:300:13: note: (near initialization for 'ml86v7667_subdev_pad_ops.set_fmt')
cc1: some warnings being treated as errors
--
>> drivers/media/i2c/saa717x.c:1214:13: error: initialization of 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_config *, struct v4l2_subdev_format *)' from incompatible pointer type 'int (*)(struct v4l2_subdev *, struct v4l2_subdev_pad_config *, struct v4l2_subdev_format *)' [-Werror=incompatible-pointer-types]
1214 | .set_fmt = saa717x_set_fmt,
| ^~~~~~~~~~~~~~~
drivers/media/i2c/saa717x.c:1214:13: note: (near initialization for 'saa717x_pad_ops.set_fmt')
cc1: some warnings being treated as errors
..
vim +/v4l2_subdev_get_try_format +1726 drivers/media/i2c/tda1997x.c
9ac0038db9a7e1 Tim Harvey 2018-02-15 1714
9ac0038db9a7e1 Tim Harvey 2018-02-15 1715
9ac0038db9a7e1 Tim Harvey 2018-02-15 1716 /* -----------------------------------------------------------------------------
9ac0038db9a7e1 Tim Harvey 2018-02-15 1717 * v4l2_subdev_pad_ops
9ac0038db9a7e1 Tim Harvey 2018-02-15 1718 */
9ac0038db9a7e1 Tim Harvey 2018-02-15 1719
9ac0038db9a7e1 Tim Harvey 2018-02-15 1720 static int tda1997x_init_cfg(struct v4l2_subdev *sd,
9ac0038db9a7e1 Tim Harvey 2018-02-15 1721 struct v4l2_subdev_pad_config *cfg)
9ac0038db9a7e1 Tim Harvey 2018-02-15 1722 {
9ac0038db9a7e1 Tim Harvey 2018-02-15 1723 struct tda1997x_state *state = to_state(sd);
9ac0038db9a7e1 Tim Harvey 2018-02-15 1724 struct v4l2_mbus_framefmt *mf;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1725
9ac0038db9a7e1 Tim Harvey 2018-02-15 @1726 mf = v4l2_subdev_get_try_format(sd, cfg, 0);
9ac0038db9a7e1 Tim Harvey 2018-02-15 1727 mf->code = state->mbus_codes[0];
9ac0038db9a7e1 Tim Harvey 2018-02-15 1728
9ac0038db9a7e1 Tim Harvey 2018-02-15 1729 return 0;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1730 }
9ac0038db9a7e1 Tim Harvey 2018-02-15 1731
9ac0038db9a7e1 Tim Harvey 2018-02-15 1732 static int tda1997x_enum_mbus_code(struct v4l2_subdev *sd,
9ac0038db9a7e1 Tim Harvey 2018-02-15 1733 struct v4l2_subdev_pad_config *cfg,
9ac0038db9a7e1 Tim Harvey 2018-02-15 1734 struct v4l2_subdev_mbus_code_enum *code)
9ac0038db9a7e1 Tim Harvey 2018-02-15 1735 {
9ac0038db9a7e1 Tim Harvey 2018-02-15 1736 struct tda1997x_state *state = to_state(sd);
9ac0038db9a7e1 Tim Harvey 2018-02-15 1737
9ac0038db9a7e1 Tim Harvey 2018-02-15 1738 v4l_dbg(1, debug, state->client, "%s %d\n", __func__, code->index);
9ac0038db9a7e1 Tim Harvey 2018-02-15 1739 if (code->index >= ARRAY_SIZE(state->mbus_codes))
9ac0038db9a7e1 Tim Harvey 2018-02-15 1740 return -EINVAL;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1741
9ac0038db9a7e1 Tim Harvey 2018-02-15 1742 if (!state->mbus_codes[code->index])
9ac0038db9a7e1 Tim Harvey 2018-02-15 1743 return -EINVAL;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1744
9ac0038db9a7e1 Tim Harvey 2018-02-15 1745 code->code = state->mbus_codes[code->index];
9ac0038db9a7e1 Tim Harvey 2018-02-15 1746
9ac0038db9a7e1 Tim Harvey 2018-02-15 1747 return 0;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1748 }
9ac0038db9a7e1 Tim Harvey 2018-02-15 1749
9ac0038db9a7e1 Tim Harvey 2018-02-15 1750 static void tda1997x_fill_format(struct tda1997x_state *state,
9ac0038db9a7e1 Tim Harvey 2018-02-15 1751 struct v4l2_mbus_framefmt *format)
9ac0038db9a7e1 Tim Harvey 2018-02-15 1752 {
9ac0038db9a7e1 Tim Harvey 2018-02-15 1753 const struct v4l2_bt_timings *bt;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1754
9ac0038db9a7e1 Tim Harvey 2018-02-15 1755 memset(format, 0, sizeof(*format));
9ac0038db9a7e1 Tim Harvey 2018-02-15 1756 bt = &state->timings.bt;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1757 format->width = bt->width;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1758 format->height = bt->height;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1759 format->colorspace = state->colorimetry.colorspace;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1760 format->field = (bt->interlaced) ?
9ac0038db9a7e1 Tim Harvey 2018-02-15 1761 V4L2_FIELD_SEQ_TB : V4L2_FIELD_NONE;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1762 }
9ac0038db9a7e1 Tim Harvey 2018-02-15 1763
9ac0038db9a7e1 Tim Harvey 2018-02-15 1764 static int tda1997x_get_format(struct v4l2_subdev *sd,
9ac0038db9a7e1 Tim Harvey 2018-02-15 1765 struct v4l2_subdev_pad_config *cfg,
9ac0038db9a7e1 Tim Harvey 2018-02-15 1766 struct v4l2_subdev_format *format)
9ac0038db9a7e1 Tim Harvey 2018-02-15 1767 {
9ac0038db9a7e1 Tim Harvey 2018-02-15 1768 struct tda1997x_state *state = to_state(sd);
9ac0038db9a7e1 Tim Harvey 2018-02-15 1769
9ac0038db9a7e1 Tim Harvey 2018-02-15 1770 v4l_dbg(1, debug, state->client, "%s pad=%d which=%d\n",
9ac0038db9a7e1 Tim Harvey 2018-02-15 1771 __func__, format->pad, format->which);
9ac0038db9a7e1 Tim Harvey 2018-02-15 1772
9ac0038db9a7e1 Tim Harvey 2018-02-15 1773 tda1997x_fill_format(state, &format->format);
9ac0038db9a7e1 Tim Harvey 2018-02-15 1774
9ac0038db9a7e1 Tim Harvey 2018-02-15 1775 if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
9ac0038db9a7e1 Tim Harvey 2018-02-15 1776 struct v4l2_mbus_framefmt *fmt;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1777
9ac0038db9a7e1 Tim Harvey 2018-02-15 1778 fmt = v4l2_subdev_get_try_format(sd, cfg, format->pad);
9ac0038db9a7e1 Tim Harvey 2018-02-15 1779 format->format.code = fmt->code;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1780 } else
9ac0038db9a7e1 Tim Harvey 2018-02-15 1781 format->format.code = state->mbus_code;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1782
9ac0038db9a7e1 Tim Harvey 2018-02-15 1783 return 0;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1784 }
9ac0038db9a7e1 Tim Harvey 2018-02-15 1785
9ac0038db9a7e1 Tim Harvey 2018-02-15 1786 static int tda1997x_set_format(struct v4l2_subdev *sd,
9ac0038db9a7e1 Tim Harvey 2018-02-15 1787 struct v4l2_subdev_pad_config *cfg,
9ac0038db9a7e1 Tim Harvey 2018-02-15 1788 struct v4l2_subdev_format *format)
9ac0038db9a7e1 Tim Harvey 2018-02-15 1789 {
9ac0038db9a7e1 Tim Harvey 2018-02-15 1790 struct tda1997x_state *state = to_state(sd);
9ac0038db9a7e1 Tim Harvey 2018-02-15 1791 u32 code = 0;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1792 int i;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1793
9ac0038db9a7e1 Tim Harvey 2018-02-15 1794 v4l_dbg(1, debug, state->client, "%s pad=%d which=%d fmt=0x%x\n",
9ac0038db9a7e1 Tim Harvey 2018-02-15 1795 __func__, format->pad, format->which, format->format.code);
9ac0038db9a7e1 Tim Harvey 2018-02-15 1796
9ac0038db9a7e1 Tim Harvey 2018-02-15 1797 for (i = 0; i < ARRAY_SIZE(state->mbus_codes); i++) {
9ac0038db9a7e1 Tim Harvey 2018-02-15 1798 if (format->format.code == state->mbus_codes[i]) {
9ac0038db9a7e1 Tim Harvey 2018-02-15 1799 code = state->mbus_codes[i];
9ac0038db9a7e1 Tim Harvey 2018-02-15 1800 break;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1801 }
9ac0038db9a7e1 Tim Harvey 2018-02-15 1802 }
9ac0038db9a7e1 Tim Harvey 2018-02-15 1803 if (!code)
9ac0038db9a7e1 Tim Harvey 2018-02-15 1804 code = state->mbus_codes[0];
9ac0038db9a7e1 Tim Harvey 2018-02-15 1805
9ac0038db9a7e1 Tim Harvey 2018-02-15 1806 tda1997x_fill_format(state, &format->format);
9ac0038db9a7e1 Tim Harvey 2018-02-15 1807 format->format.code = code;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1808
9ac0038db9a7e1 Tim Harvey 2018-02-15 1809 if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
9ac0038db9a7e1 Tim Harvey 2018-02-15 1810 struct v4l2_mbus_framefmt *fmt;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1811
9ac0038db9a7e1 Tim Harvey 2018-02-15 1812 fmt = v4l2_subdev_get_try_format(sd, cfg, format->pad);
9ac0038db9a7e1 Tim Harvey 2018-02-15 1813 *fmt = format->format;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1814 } else {
9ac0038db9a7e1 Tim Harvey 2018-02-15 1815 int ret = tda1997x_setup_format(state, format->format.code);
9ac0038db9a7e1 Tim Harvey 2018-02-15 1816
9ac0038db9a7e1 Tim Harvey 2018-02-15 1817 if (ret)
9ac0038db9a7e1 Tim Harvey 2018-02-15 1818 return ret;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1819 /* mbus_code has changed - re-configure csc/vidout */
9ac0038db9a7e1 Tim Harvey 2018-02-15 1820 tda1997x_configure_csc(sd);
9ac0038db9a7e1 Tim Harvey 2018-02-15 1821 tda1997x_configure_vidout(state);
9ac0038db9a7e1 Tim Harvey 2018-02-15 1822 }
9ac0038db9a7e1 Tim Harvey 2018-02-15 1823
9ac0038db9a7e1 Tim Harvey 2018-02-15 1824 return 0;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1825 }
9ac0038db9a7e1 Tim Harvey 2018-02-15 1826
9ac0038db9a7e1 Tim Harvey 2018-02-15 1827 static int tda1997x_get_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
9ac0038db9a7e1 Tim Harvey 2018-02-15 1828 {
9ac0038db9a7e1 Tim Harvey 2018-02-15 1829 struct tda1997x_state *state = to_state(sd);
9ac0038db9a7e1 Tim Harvey 2018-02-15 1830
9ac0038db9a7e1 Tim Harvey 2018-02-15 1831 v4l_dbg(1, debug, state->client, "%s pad=%d\n", __func__, edid->pad);
9ac0038db9a7e1 Tim Harvey 2018-02-15 1832 memset(edid->reserved, 0, sizeof(edid->reserved));
9ac0038db9a7e1 Tim Harvey 2018-02-15 1833
9ac0038db9a7e1 Tim Harvey 2018-02-15 1834 if (edid->start_block == 0 && edid->blocks == 0) {
9ac0038db9a7e1 Tim Harvey 2018-02-15 1835 edid->blocks = state->edid.blocks;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1836 return 0;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1837 }
9ac0038db9a7e1 Tim Harvey 2018-02-15 1838
9ac0038db9a7e1 Tim Harvey 2018-02-15 1839 if (!state->edid.present)
9ac0038db9a7e1 Tim Harvey 2018-02-15 1840 return -ENODATA;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1841
9ac0038db9a7e1 Tim Harvey 2018-02-15 1842 if (edid->start_block >= state->edid.blocks)
9ac0038db9a7e1 Tim Harvey 2018-02-15 1843 return -EINVAL;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1844
9ac0038db9a7e1 Tim Harvey 2018-02-15 1845 if (edid->start_block + edid->blocks > state->edid.blocks)
9ac0038db9a7e1 Tim Harvey 2018-02-15 1846 edid->blocks = state->edid.blocks - edid->start_block;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1847
9ac0038db9a7e1 Tim Harvey 2018-02-15 1848 memcpy(edid->edid, state->edid.edid + edid->start_block * 128,
9ac0038db9a7e1 Tim Harvey 2018-02-15 1849 edid->blocks * 128);
9ac0038db9a7e1 Tim Harvey 2018-02-15 1850
9ac0038db9a7e1 Tim Harvey 2018-02-15 1851 return 0;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1852 }
9ac0038db9a7e1 Tim Harvey 2018-02-15 1853
9ac0038db9a7e1 Tim Harvey 2018-02-15 1854 static int tda1997x_set_edid(struct v4l2_subdev *sd, struct v4l2_edid *edid)
9ac0038db9a7e1 Tim Harvey 2018-02-15 1855 {
9ac0038db9a7e1 Tim Harvey 2018-02-15 1856 struct tda1997x_state *state = to_state(sd);
9ac0038db9a7e1 Tim Harvey 2018-02-15 1857 int i;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1858
9ac0038db9a7e1 Tim Harvey 2018-02-15 1859 v4l_dbg(1, debug, state->client, "%s pad=%d\n", __func__, edid->pad);
9ac0038db9a7e1 Tim Harvey 2018-02-15 1860 memset(edid->reserved, 0, sizeof(edid->reserved));
9ac0038db9a7e1 Tim Harvey 2018-02-15 1861
9ac0038db9a7e1 Tim Harvey 2018-02-15 1862 if (edid->start_block != 0)
9ac0038db9a7e1 Tim Harvey 2018-02-15 1863 return -EINVAL;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1864
9ac0038db9a7e1 Tim Harvey 2018-02-15 1865 if (edid->blocks == 0) {
9ac0038db9a7e1 Tim Harvey 2018-02-15 1866 state->edid.blocks = 0;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1867 state->edid.present = 0;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1868 tda1997x_disable_edid(sd);
9ac0038db9a7e1 Tim Harvey 2018-02-15 1869 return 0;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1870 }
9ac0038db9a7e1 Tim Harvey 2018-02-15 1871
9ac0038db9a7e1 Tim Harvey 2018-02-15 1872 if (edid->blocks > 2) {
9ac0038db9a7e1 Tim Harvey 2018-02-15 1873 edid->blocks = 2;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1874 return -E2BIG;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1875 }
9ac0038db9a7e1 Tim Harvey 2018-02-15 1876
9ac0038db9a7e1 Tim Harvey 2018-02-15 1877 tda1997x_disable_edid(sd);
9ac0038db9a7e1 Tim Harvey 2018-02-15 1878
9ac0038db9a7e1 Tim Harvey 2018-02-15 1879 /* write base EDID */
9ac0038db9a7e1 Tim Harvey 2018-02-15 1880 for (i = 0; i < 128; i++)
9ac0038db9a7e1 Tim Harvey 2018-02-15 1881 io_write(sd, REG_EDID_IN_BYTE0 + i, edid->edid[i]);
9ac0038db9a7e1 Tim Harvey 2018-02-15 1882
9ac0038db9a7e1 Tim Harvey 2018-02-15 1883 /* write CEA Extension */
9ac0038db9a7e1 Tim Harvey 2018-02-15 1884 for (i = 0; i < 128; i++)
9ac0038db9a7e1 Tim Harvey 2018-02-15 1885 io_write(sd, REG_EDID_IN_BYTE128 + i, edid->edid[i+128]);
9ac0038db9a7e1 Tim Harvey 2018-02-15 1886
0806bc0afbb415 Tim Harvey 2019-02-05 1887 /* store state */
0806bc0afbb415 Tim Harvey 2019-02-05 1888 memcpy(state->edid.edid, edid->edid, 256);
0806bc0afbb415 Tim Harvey 2019-02-05 1889 state->edid.blocks = edid->blocks;
0806bc0afbb415 Tim Harvey 2019-02-05 1890
9ac0038db9a7e1 Tim Harvey 2018-02-15 1891 tda1997x_enable_edid(sd);
9ac0038db9a7e1 Tim Harvey 2018-02-15 1892
9ac0038db9a7e1 Tim Harvey 2018-02-15 1893 return 0;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1894 }
9ac0038db9a7e1 Tim Harvey 2018-02-15 1895
9ac0038db9a7e1 Tim Harvey 2018-02-15 1896 static int tda1997x_get_dv_timings_cap(struct v4l2_subdev *sd,
9ac0038db9a7e1 Tim Harvey 2018-02-15 1897 struct v4l2_dv_timings_cap *cap)
9ac0038db9a7e1 Tim Harvey 2018-02-15 1898 {
9ac0038db9a7e1 Tim Harvey 2018-02-15 1899 *cap = tda1997x_dv_timings_cap;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1900 return 0;
9ac0038db9a7e1 Tim Harvey 2018-02-15 1901 }
9ac0038db9a7e1 Tim Harvey 2018-02-15 1902
9ac0038db9a7e1 Tim Harvey 2018-02-15 1903 static int tda1997x_enum_dv_timings(struct v4l2_subdev *sd,
9ac0038db9a7e1 Tim Harvey 2018-02-15 1904 struct v4l2_enum_dv_timings *timings)
9ac0038db9a7e1 Tim Harvey 2018-02-15 1905 {
9ac0038db9a7e1 Tim Harvey 2018-02-15 1906 return v4l2_enum_dv_timings_cap(timings, &tda1997x_dv_timings_cap,
9ac0038db9a7e1 Tim Harvey 2018-02-15 1907 NULL, NULL);
9ac0038db9a7e1 Tim Harvey 2018-02-15 1908 }
9ac0038db9a7e1 Tim Harvey 2018-02-15 1909
9ac0038db9a7e1 Tim Harvey 2018-02-15 1910 static const struct v4l2_subdev_pad_ops tda1997x_pad_ops = {
9ac0038db9a7e1 Tim Harvey 2018-02-15 @1911 .init_cfg = tda1997x_init_cfg,
9ac0038db9a7e1 Tim Harvey 2018-02-15 @1912 .enum_mbus_code = tda1997x_enum_mbus_code,
9ac0038db9a7e1 Tim Harvey 2018-02-15 @1913 .get_fmt = tda1997x_get_format,
9ac0038db9a7e1 Tim Harvey 2018-02-15 1914 .set_fmt = tda1997x_set_format,
9ac0038db9a7e1 Tim Harvey 2018-02-15 1915 .get_edid = tda1997x_get_edid,
9ac0038db9a7e1 Tim Harvey 2018-02-15 1916 .set_edid = tda1997x_set_edid,
9ac0038db9a7e1 Tim Harvey 2018-02-15 1917 .dv_timings_cap = tda1997x_get_dv_timings_cap,
9ac0038db9a7e1 Tim Harvey 2018-02-15 1918 .enum_dv_timings = tda1997x_enum_dv_timings,
9ac0038db9a7e1 Tim Harvey 2018-02-15 1919 };
9ac0038db9a7e1 Tim Harvey 2018-02-15 1920
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 25295 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] RFC: media: v4l2-subdev: add subdev-wide config struct
2021-04-09 13:36 [PATCH] RFC: media: v4l2-subdev: add subdev-wide config struct Tomi Valkeinen
2021-04-09 16:28 ` kernel test robot
2021-04-09 16:29 ` kernel test robot
@ 2021-04-18 16:07 ` Laurent Pinchart
2021-04-20 11:52 ` Hans Verkuil
2021-04-20 15:35 ` Sakari Ailus
3 siblings, 1 reply; 7+ messages in thread
From: Laurent Pinchart @ 2021-04-18 16:07 UTC (permalink / raw)
To: Tomi Valkeinen
Cc: Mauro Carvalho Chehab, Hans Verkuil, linux-media, Sakari Ailus
Hi Tomi,
Thank you for the patch.
Hans, Sakari, could you share your opinion on this ? I see lots of
potential in this proposal (both for bikeshedding, and for actual
value). We need an ack on the concept, and likely naming scheme too,
before developing a final patch, as it's lots of churn in lots of
drivers.
On Fri, Apr 09, 2021 at 04:36:59PM +0300, Tomi Valkeinen wrote:
> We have 'struct v4l2_subdev_pad_config' which contains configuration for
> a single pad used for the TRY functionality, and an array of those
> structs is passed to various v4l2_subdev_pad_ops.
>
> I was working on subdev internal routing between pads, and realized that
> there's no way to add TRY functionality for routes, which is not pad
> specific configuration. Adding a separate struct for try-route config
> wouldn't work either, as e.g. set-fmt needs to know the try-route
> configuration to propagate the settings.
>
> This patch adds a new struct, 'struct v4l2_subdev_config' (which at the
> moment only contains the v4l2_subdev_pad_config array) and the new
> struct is used in most of the places where v4l2_subdev_pad_config was
> used. All v4l2_subdev_pad_ops functions taking v4l2_subdev_pad_config
> are changed to instead take v4l2_subdev_config.
>
> Two drivers are changed to work with the above changes (drivers for HW
> which I have) as an example.
>
> I worked on a semantic patch (included below, my first spatch...) to do
> this change to all drivers, but hit lots of problems with non-trivial
> uses of v4l2_subdev_pad_config.
>
> As it looks like substantial amount of manual work is needed, I'm
> posting this RFC to get an ack on the changes before continuing that
> work.
>
> @ v4l2_subdev_pad_ops @
> identifier pad_ops;
> identifier func;
> @@
>
> (
> static const struct v4l2_subdev_pad_ops pad_ops = {
> ...,
> .enum_mbus_code = func,
> ...,
> };
> |
> static const struct v4l2_subdev_pad_ops pad_ops = {
> ...,
> .enum_frame_size = func,
> ...,
> };
> |
> static const struct v4l2_subdev_pad_ops pad_ops = {
> ...,
> .enum_frame_interval = func,
> ...,
> };
> |
> static const struct v4l2_subdev_pad_ops pad_ops = {
> ...,
> .get_fmt = func,
> ...,
> };
> |
> static const struct v4l2_subdev_pad_ops pad_ops = {
> ...,
> .set_fmt = func,
> ...,
> };
> |
> static const struct v4l2_subdev_pad_ops pad_ops = {
> ...,
> .get_selection = func,
> ...,
> };
> |
> static const struct v4l2_subdev_pad_ops pad_ops = {
> ...,
> .set_selection = func,
> ...,
> };
> |
> static const struct v4l2_subdev_pad_ops pad_ops = {
> ...,
> .init_cfg = func,
> ...,
> };
> )
>
> @@
> identifier v4l2_subdev_pad_ops.func;
> identifier sd;
> identifier cfg;
> @@
>
> func(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> ...
> )
> {
> ...
> }
>
> @@
> identifier v4l2_subdev_pad_ops.func;
> identifier sd;
> identifier cfg;
> @@
>
> func(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg
> + struct v4l2_subdev_config *cfg
> )
> {
> ...
> }
>
> @@
> struct v4l2_subdev_fh *fh;
> @@
> - fh->pad
> + &fh->cfg
>
> @@
> identifier func;
> identifier cfg;
> @@
>
> func(...,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> ...)
> {
> ...
> }
>
> @@
> struct v4l2_subdev_config *cfg;
> @@
> {
> <...
> (
> - cfg->try_fmt
> + cfg->pad_configs->try_fmt
> |
> - cfg->try_crop
> + cfg->pad_configs->try_crop
> |
> - cfg->try_compose
> + cfg->pad_configs->try_compose
> )
> ...>
> }
>
> @@
> identifier pad_cfg;
> @@
> {
> ...
> struct v4l2_subdev_pad_config pad_cfg;
> + struct v4l2_subdev_config cfg = { .pad_configs = &pad_cfg };
> <...
> - &pad_cfg
> + &cfg
> ...>
> }
>
This doesn't look too bad (although the last change seems a bit weird),
but I suppose it's not the whole story, as you've mentioned above.
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> ---
> drivers/media/i2c/ov5640.c | 10 +--
> drivers/media/platform/ti-vpe/cal-camerarx.c | 12 +--
> drivers/media/v4l2-core/v4l2-subdev.c | 85 ++++++++++----------
> include/media/v4l2-subdev.h | 49 +++++------
> 4 files changed, 78 insertions(+), 78 deletions(-)
>
> diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
> index 14f3afa7721a..7c76c0754426 100644
> --- a/drivers/media/i2c/ov5640.c
> +++ b/drivers/media/i2c/ov5640.c
> @@ -2227,7 +2227,7 @@ static int ov5640_try_frame_interval(struct ov5640_dev *sensor,
> }
>
> static int ov5640_get_fmt(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_format *format)
> {
> struct ov5640_dev *sensor = to_ov5640_dev(sd);
> @@ -2285,7 +2285,7 @@ static int ov5640_try_fmt_internal(struct v4l2_subdev *sd,
> }
>
> static int ov5640_set_fmt(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_format *format)
> {
> struct ov5640_dev *sensor = to_ov5640_dev(sd);
> @@ -2818,7 +2818,7 @@ static int ov5640_init_controls(struct ov5640_dev *sensor)
> }
>
> static int ov5640_enum_frame_size(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_frame_size_enum *fse)
> {
> if (fse->pad != 0)
> @@ -2838,7 +2838,7 @@ static int ov5640_enum_frame_size(struct v4l2_subdev *sd,
>
> static int ov5640_enum_frame_interval(
> struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_frame_interval_enum *fie)
> {
> struct ov5640_dev *sensor = to_ov5640_dev(sd);
> @@ -2924,7 +2924,7 @@ static int ov5640_s_frame_interval(struct v4l2_subdev *sd,
> }
>
> static int ov5640_enum_mbus_code(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_mbus_code_enum *code)
> {
> if (code->pad != 0)
> diff --git a/drivers/media/platform/ti-vpe/cal-camerarx.c b/drivers/media/platform/ti-vpe/cal-camerarx.c
> index cbe6114908de..c708c61f2188 100644
> --- a/drivers/media/platform/ti-vpe/cal-camerarx.c
> +++ b/drivers/media/platform/ti-vpe/cal-camerarx.c
> @@ -586,7 +586,7 @@ static inline struct cal_camerarx *to_cal_camerarx(struct v4l2_subdev *sd)
>
> static struct v4l2_mbus_framefmt *
> cal_camerarx_get_pad_format(struct cal_camerarx *phy,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> unsigned int pad, u32 which)
> {
> switch (which) {
> @@ -611,7 +611,7 @@ static int cal_camerarx_sd_s_stream(struct v4l2_subdev *sd, int enable)
> }
>
> static int cal_camerarx_sd_enum_mbus_code(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_mbus_code_enum *code)
> {
> struct cal_camerarx *phy = to_cal_camerarx(sd);
> @@ -639,7 +639,7 @@ static int cal_camerarx_sd_enum_mbus_code(struct v4l2_subdev *sd,
> }
>
> static int cal_camerarx_sd_enum_frame_size(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_frame_size_enum *fse)
> {
> struct cal_camerarx *phy = to_cal_camerarx(sd);
> @@ -679,7 +679,7 @@ static int cal_camerarx_sd_enum_frame_size(struct v4l2_subdev *sd,
> }
>
> static int cal_camerarx_sd_get_fmt(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_format *format)
> {
> struct cal_camerarx *phy = to_cal_camerarx(sd);
> @@ -692,7 +692,7 @@ static int cal_camerarx_sd_get_fmt(struct v4l2_subdev *sd,
> }
>
> static int cal_camerarx_sd_set_fmt(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_format *format)
> {
> struct cal_camerarx *phy = to_cal_camerarx(sd);
> @@ -742,7 +742,7 @@ static int cal_camerarx_sd_set_fmt(struct v4l2_subdev *sd,
> }
>
> static int cal_camerarx_sd_init_cfg(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg)
> + struct v4l2_subdev_config *cfg)
> {
> struct v4l2_subdev_format format = {
> .which = cfg ? V4L2_SUBDEV_FORMAT_TRY
> diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
> index 956dafab43d4..248fa4ee9356 100644
> --- a/drivers/media/v4l2-core/v4l2-subdev.c
> +++ b/drivers/media/v4l2-core/v4l2-subdev.c
> @@ -26,19 +26,18 @@
> #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
> static int subdev_fh_init(struct v4l2_subdev_fh *fh, struct v4l2_subdev *sd)
> {
> - if (sd->entity.num_pads) {
> - fh->pad = v4l2_subdev_alloc_pad_config(sd);
> - if (fh->pad == NULL)
> - return -ENOMEM;
> - }
> + int ret;
> +
> + ret = v4l2_subdev_init_config(sd, &fh->cfg);
> + if (ret)
> + return ret;
>
> return 0;
> }
>
> static void subdev_fh_free(struct v4l2_subdev_fh *fh)
> {
> - v4l2_subdev_free_pad_config(fh->pad);
> - fh->pad = NULL;
> + v4l2_subdev_uninit_config(&fh->cfg);
> }
>
> static int subdev_open(struct file *file)
> @@ -146,7 +145,7 @@ static inline int check_pad(struct v4l2_subdev *sd, u32 pad)
> return 0;
> }
>
> -static int check_cfg(u32 which, struct v4l2_subdev_pad_config *cfg)
> +static int check_cfg(u32 which, struct v4l2_subdev_config *cfg)
> {
> if (which == V4L2_SUBDEV_FORMAT_TRY && !cfg)
> return -EINVAL;
> @@ -155,7 +154,7 @@ static int check_cfg(u32 which, struct v4l2_subdev_pad_config *cfg)
> }
>
> static inline int check_format(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_format *format)
> {
> if (!format)
> @@ -166,7 +165,7 @@ static inline int check_format(struct v4l2_subdev *sd,
> }
>
> static int call_get_fmt(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_format *format)
> {
> return check_format(sd, cfg, format) ? :
> @@ -174,7 +173,7 @@ static int call_get_fmt(struct v4l2_subdev *sd,
> }
>
> static int call_set_fmt(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_format *format)
> {
> return check_format(sd, cfg, format) ? :
> @@ -182,7 +181,7 @@ static int call_set_fmt(struct v4l2_subdev *sd,
> }
>
> static int call_enum_mbus_code(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_mbus_code_enum *code)
> {
> if (!code)
> @@ -194,7 +193,7 @@ static int call_enum_mbus_code(struct v4l2_subdev *sd,
> }
>
> static int call_enum_frame_size(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_frame_size_enum *fse)
> {
> if (!fse)
> @@ -229,7 +228,7 @@ static int call_s_frame_interval(struct v4l2_subdev *sd,
> }
>
> static int call_enum_frame_interval(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_frame_interval_enum *fie)
> {
> if (!fie)
> @@ -241,7 +240,7 @@ static int call_enum_frame_interval(struct v4l2_subdev *sd,
> }
>
> static inline int check_selection(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_selection *sel)
> {
> if (!sel)
> @@ -252,7 +251,7 @@ static inline int check_selection(struct v4l2_subdev *sd,
> }
>
> static int call_get_selection(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_selection *sel)
> {
> return check_selection(sd, cfg, sel) ? :
> @@ -260,7 +259,7 @@ static int call_get_selection(struct v4l2_subdev *sd,
> }
>
> static int call_set_selection(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_selection *sel)
> {
> return check_selection(sd, cfg, sel) ? :
> @@ -506,7 +505,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
>
> memset(format->reserved, 0, sizeof(format->reserved));
> memset(format->format.reserved, 0, sizeof(format->format.reserved));
> - return v4l2_subdev_call(sd, pad, get_fmt, subdev_fh->pad, format);
> + return v4l2_subdev_call(sd, pad, get_fmt, &subdev_fh->cfg, format);
> }
>
> case VIDIOC_SUBDEV_S_FMT: {
> @@ -517,7 +516,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
>
> memset(format->reserved, 0, sizeof(format->reserved));
> memset(format->format.reserved, 0, sizeof(format->format.reserved));
> - return v4l2_subdev_call(sd, pad, set_fmt, subdev_fh->pad, format);
> + return v4l2_subdev_call(sd, pad, set_fmt, &subdev_fh->cfg, format);
> }
>
> case VIDIOC_SUBDEV_G_CROP: {
> @@ -531,7 +530,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
> sel.target = V4L2_SEL_TGT_CROP;
>
> rval = v4l2_subdev_call(
> - sd, pad, get_selection, subdev_fh->pad, &sel);
> + sd, pad, get_selection, &subdev_fh->cfg, &sel);
>
> crop->rect = sel.r;
>
> @@ -553,7 +552,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
> sel.r = crop->rect;
>
> rval = v4l2_subdev_call(
> - sd, pad, set_selection, subdev_fh->pad, &sel);
> + sd, pad, set_selection, &subdev_fh->cfg, &sel);
>
> crop->rect = sel.r;
>
> @@ -564,7 +563,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
> struct v4l2_subdev_mbus_code_enum *code = arg;
>
> memset(code->reserved, 0, sizeof(code->reserved));
> - return v4l2_subdev_call(sd, pad, enum_mbus_code, subdev_fh->pad,
> + return v4l2_subdev_call(sd, pad, enum_mbus_code, &subdev_fh->cfg,
> code);
> }
>
> @@ -572,7 +571,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
> struct v4l2_subdev_frame_size_enum *fse = arg;
>
> memset(fse->reserved, 0, sizeof(fse->reserved));
> - return v4l2_subdev_call(sd, pad, enum_frame_size, subdev_fh->pad,
> + return v4l2_subdev_call(sd, pad, enum_frame_size, &subdev_fh->cfg,
> fse);
> }
>
> @@ -597,7 +596,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
> struct v4l2_subdev_frame_interval_enum *fie = arg;
>
> memset(fie->reserved, 0, sizeof(fie->reserved));
> - return v4l2_subdev_call(sd, pad, enum_frame_interval, subdev_fh->pad,
> + return v4l2_subdev_call(sd, pad, enum_frame_interval, &subdev_fh->cfg,
> fie);
> }
>
> @@ -606,7 +605,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
>
> memset(sel->reserved, 0, sizeof(sel->reserved));
> return v4l2_subdev_call(
> - sd, pad, get_selection, subdev_fh->pad, sel);
> + sd, pad, get_selection, &subdev_fh->cfg, sel);
> }
>
> case VIDIOC_SUBDEV_S_SELECTION: {
> @@ -617,7 +616,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
>
> memset(sel->reserved, 0, sizeof(sel->reserved));
> return v4l2_subdev_call(
> - sd, pad, set_selection, subdev_fh->pad, sel);
> + sd, pad, set_selection, &subdev_fh->cfg, sel);
> }
>
> case VIDIOC_G_EDID: {
So far, it's a pretty simple change :-)
I'd actually take it one step further (on top of course), and store an
instance of v4l2_subdev_config in v4l2_subdev for the active
configuration. This can massively simplify subdev drivers.
> @@ -892,35 +891,35 @@ int v4l2_subdev_link_validate(struct media_link *link)
> }
> EXPORT_SYMBOL_GPL(v4l2_subdev_link_validate);
>
> -struct v4l2_subdev_pad_config *
> -v4l2_subdev_alloc_pad_config(struct v4l2_subdev *sd)
> +int v4l2_subdev_init_config(struct v4l2_subdev *sd, struct v4l2_subdev_config *cfg)
Line wrap (and below too).
> {
> - struct v4l2_subdev_pad_config *cfg;
> int ret;
>
> - if (!sd->entity.num_pads)
> - return NULL;
> -
> - cfg = kvmalloc_array(sd->entity.num_pads, sizeof(*cfg),
> - GFP_KERNEL | __GFP_ZERO);
> - if (!cfg)
> - return NULL;
> + if (sd->entity.num_pads) {
> + cfg->pad_configs = kvmalloc_array(sd->entity.num_pads, sizeof(*cfg->pad_configs),
> + GFP_KERNEL | __GFP_ZERO);
> + if (!cfg->pad_configs)
> + return -ENOMEM;
> + } else {
> + cfg->pad_configs = NULL;
> + }
How about memsetting the whole structure to 0 first ?
>
> ret = v4l2_subdev_call(sd, pad, init_cfg, cfg);
> if (ret < 0 && ret != -ENOIOCTLCMD) {
> - kvfree(cfg);
> - return NULL;
> + kvfree(cfg->pad_configs);
> + return ret;
> }
>
> - return cfg;
> + return 0;
> }
> -EXPORT_SYMBOL_GPL(v4l2_subdev_alloc_pad_config);
> +EXPORT_SYMBOL_GPL(v4l2_subdev_init_config);
>
> -void v4l2_subdev_free_pad_config(struct v4l2_subdev_pad_config *cfg)
> +void v4l2_subdev_uninit_config(struct v4l2_subdev_config *cfg)
> {
> - kvfree(cfg);
> + kvfree(cfg->pad_configs);
> }
> -EXPORT_SYMBOL_GPL(v4l2_subdev_free_pad_config);
> +EXPORT_SYMBOL_GPL(v4l2_subdev_uninit_config);
> +
> #endif /* CONFIG_MEDIA_CONTROLLER */
>
> void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops)
> diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
> index d0e9a5bdb08b..1873e527987a 100644
> --- a/include/media/v4l2-subdev.h
> +++ b/include/media/v4l2-subdev.h
> @@ -623,6 +623,10 @@ struct v4l2_subdev_pad_config {
> struct v4l2_rect try_compose;
> };
>
> +struct v4l2_subdev_config {
> + struct v4l2_subdev_pad_config *pad_configs;
s/pad_configs/pads/ ?
I'm tempted to also store the number of pads here. It would be redundant
as the value is available from the v4l2_subdev structure, but it would
allow operating on v4l2_subdev_config without a subdev pointer. Or,
possibly better, we could store a pointer to the subdev.
I'm also tempted to name the structure v4l2_subdev_state, as that's what
it stores. I may be biased by DRM/KMS, but I don't see a downside in
using identical names for identical concepts.
> +};
> +
> /**
> * struct v4l2_subdev_pad_ops - v4l2-subdev pad level operations
> *
> @@ -687,27 +691,27 @@ struct v4l2_subdev_pad_config {
> */
> struct v4l2_subdev_pad_ops {
> int (*init_cfg)(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg);
> + struct v4l2_subdev_config *cfg);
> int (*enum_mbus_code)(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_mbus_code_enum *code);
> int (*enum_frame_size)(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_frame_size_enum *fse);
> int (*enum_frame_interval)(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_frame_interval_enum *fie);
> int (*get_fmt)(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_format *format);
> int (*set_fmt)(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_format *format);
> int (*get_selection)(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_selection *sel);
> int (*set_selection)(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_selection *sel);
> int (*get_edid)(struct v4l2_subdev *sd, struct v4l2_edid *edid);
> int (*set_edid)(struct v4l2_subdev *sd, struct v4l2_edid *edid);
> @@ -925,7 +929,7 @@ struct v4l2_subdev_fh {
> struct v4l2_fh vfh;
> struct module *owner;
> #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
> - struct v4l2_subdev_pad_config *pad;
> + struct v4l2_subdev_config cfg;
> #endif
> };
>
> @@ -950,12 +954,12 @@ struct v4l2_subdev_fh {
> */
> static inline struct v4l2_mbus_framefmt *
> v4l2_subdev_get_try_format(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> unsigned int pad)
> {
> if (WARN_ON(pad >= sd->entity.num_pads))
> pad = 0;
> - return &cfg[pad].try_fmt;
> + return &cfg->pad_configs[pad].try_fmt;
> }
>
> /**
> @@ -968,12 +972,12 @@ v4l2_subdev_get_try_format(struct v4l2_subdev *sd,
> */
> static inline struct v4l2_rect *
> v4l2_subdev_get_try_crop(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> unsigned int pad)
> {
> if (WARN_ON(pad >= sd->entity.num_pads))
> pad = 0;
> - return &cfg[pad].try_crop;
> + return &cfg->pad_configs[pad].try_crop;
> }
>
> /**
> @@ -986,12 +990,12 @@ v4l2_subdev_get_try_crop(struct v4l2_subdev *sd,
> */
> static inline struct v4l2_rect *
> v4l2_subdev_get_try_compose(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> unsigned int pad)
> {
> if (WARN_ON(pad >= sd->entity.num_pads))
> pad = 0;
> - return &cfg[pad].try_compose;
> + return &cfg->pad_configs[pad].try_compose;
> }
>
> #endif
> @@ -1093,20 +1097,17 @@ int v4l2_subdev_link_validate_default(struct v4l2_subdev *sd,
> int v4l2_subdev_link_validate(struct media_link *link);
>
> /**
> - * v4l2_subdev_alloc_pad_config - Allocates memory for pad config
> + * v4l2_subdev_init_config - initialize v4l2_subdev_config
> *
> - * @sd: pointer to struct v4l2_subdev
> + * Must call v4l2_subdev_uninit_config() when config is no longer needed.
> */
> -struct
> -v4l2_subdev_pad_config *v4l2_subdev_alloc_pad_config(struct v4l2_subdev *sd);
> +int v4l2_subdev_init_config(struct v4l2_subdev *sd, struct v4l2_subdev_config *cfg);
>
> /**
> - * v4l2_subdev_free_pad_config - Frees memory allocated by
> - * v4l2_subdev_alloc_pad_config().
> - *
> - * @cfg: pointer to &struct v4l2_subdev_pad_config
> + * v4l2_subdev_uninit_config - uninitialize v4l2_subdev_config
> */
> -void v4l2_subdev_free_pad_config(struct v4l2_subdev_pad_config *cfg);
> +void v4l2_subdev_uninit_config(struct v4l2_subdev_config *cfg);
Finally, still on the naming topic, if you agree with v4l2_subdev_state,
I'd name the function v4l2_subdev_state_init() and
v4l2_subdev_state_cleanup(). I have a feeling we may be better off
allocating states dynamically (storing a pointer in v4l2_subdev_fh
instead of embedding an instance), in which case
v4l2_subdev_state_alloc() and v4l2_subdev_state_free() would be better,
but that's just a feeling at this point.
> +
> #endif /* CONFIG_MEDIA_CONTROLLER */
>
> /**
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] RFC: media: v4l2-subdev: add subdev-wide config struct
2021-04-18 16:07 ` Laurent Pinchart
@ 2021-04-20 11:52 ` Hans Verkuil
0 siblings, 0 replies; 7+ messages in thread
From: Hans Verkuil @ 2021-04-20 11:52 UTC (permalink / raw)
To: Laurent Pinchart, Tomi Valkeinen
Cc: Mauro Carvalho Chehab, Hans Verkuil, linux-media, Sakari Ailus
On 18/04/2021 18:07, Laurent Pinchart wrote:
> Hi Tomi,
>
> Thank you for the patch.
>
> Hans, Sakari, could you share your opinion on this ? I see lots of
> potential in this proposal (both for bikeshedding, and for actual
> value). We need an ack on the concept, and likely naming scheme too,
> before developing a final patch, as it's lots of churn in lots of
> drivers.
>
> On Fri, Apr 09, 2021 at 04:36:59PM +0300, Tomi Valkeinen wrote:
>> We have 'struct v4l2_subdev_pad_config' which contains configuration for
>> a single pad used for the TRY functionality, and an array of those
>> structs is passed to various v4l2_subdev_pad_ops.
>>
>> I was working on subdev internal routing between pads, and realized that
>> there's no way to add TRY functionality for routes, which is not pad
>> specific configuration. Adding a separate struct for try-route config
>> wouldn't work either, as e.g. set-fmt needs to know the try-route
>> configuration to propagate the settings.
>>
>> This patch adds a new struct, 'struct v4l2_subdev_config' (which at the
>> moment only contains the v4l2_subdev_pad_config array) and the new
>> struct is used in most of the places where v4l2_subdev_pad_config was
>> used. All v4l2_subdev_pad_ops functions taking v4l2_subdev_pad_config
>> are changed to instead take v4l2_subdev_config.
>>
>> Two drivers are changed to work with the above changes (drivers for HW
>> which I have) as an example.
>>
>> I worked on a semantic patch (included below, my first spatch...) to do
>> this change to all drivers, but hit lots of problems with non-trivial
>> uses of v4l2_subdev_pad_config.
>>
>> As it looks like substantial amount of manual work is needed, I'm
>> posting this RFC to get an ack on the changes before continuing that
>> work.
>>
>> @ v4l2_subdev_pad_ops @
>> identifier pad_ops;
>> identifier func;
>> @@
>>
>> (
>> static const struct v4l2_subdev_pad_ops pad_ops = {
>> ...,
>> .enum_mbus_code = func,
>> ...,
>> };
>> |
>> static const struct v4l2_subdev_pad_ops pad_ops = {
>> ...,
>> .enum_frame_size = func,
>> ...,
>> };
>> |
>> static const struct v4l2_subdev_pad_ops pad_ops = {
>> ...,
>> .enum_frame_interval = func,
>> ...,
>> };
>> |
>> static const struct v4l2_subdev_pad_ops pad_ops = {
>> ...,
>> .get_fmt = func,
>> ...,
>> };
>> |
>> static const struct v4l2_subdev_pad_ops pad_ops = {
>> ...,
>> .set_fmt = func,
>> ...,
>> };
>> |
>> static const struct v4l2_subdev_pad_ops pad_ops = {
>> ...,
>> .get_selection = func,
>> ...,
>> };
>> |
>> static const struct v4l2_subdev_pad_ops pad_ops = {
>> ...,
>> .set_selection = func,
>> ...,
>> };
>> |
>> static const struct v4l2_subdev_pad_ops pad_ops = {
>> ...,
>> .init_cfg = func,
>> ...,
>> };
>> )
>>
>> @@
>> identifier v4l2_subdev_pad_ops.func;
>> identifier sd;
>> identifier cfg;
>> @@
>>
>> func(struct v4l2_subdev *sd,
>> - struct v4l2_subdev_pad_config *cfg,
>> + struct v4l2_subdev_config *cfg,
>> ...
>> )
>> {
>> ...
>> }
>>
>> @@
>> identifier v4l2_subdev_pad_ops.func;
>> identifier sd;
>> identifier cfg;
>> @@
>>
>> func(struct v4l2_subdev *sd,
>> - struct v4l2_subdev_pad_config *cfg
>> + struct v4l2_subdev_config *cfg
>> )
>> {
>> ...
>> }
>>
>> @@
>> struct v4l2_subdev_fh *fh;
>> @@
>> - fh->pad
>> + &fh->cfg
>>
>> @@
>> identifier func;
>> identifier cfg;
>> @@
>>
>> func(...,
>> - struct v4l2_subdev_pad_config *cfg,
>> + struct v4l2_subdev_config *cfg,
>> ...)
>> {
>> ...
>> }
>>
>> @@
>> struct v4l2_subdev_config *cfg;
>> @@
>> {
>> <...
>> (
>> - cfg->try_fmt
>> + cfg->pad_configs->try_fmt
>> |
>> - cfg->try_crop
>> + cfg->pad_configs->try_crop
>> |
>> - cfg->try_compose
>> + cfg->pad_configs->try_compose
>> )
>> ...>
>> }
>>
>> @@
>> identifier pad_cfg;
>> @@
>> {
>> ...
>> struct v4l2_subdev_pad_config pad_cfg;
>> + struct v4l2_subdev_config cfg = { .pad_configs = &pad_cfg };
>> <...
>> - &pad_cfg
>> + &cfg
>> ...>
>> }
>>
>
> This doesn't look too bad (although the last change seems a bit weird),
> but I suppose it's not the whole story, as you've mentioned above.
>
>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
>> ---
>> drivers/media/i2c/ov5640.c | 10 +--
>> drivers/media/platform/ti-vpe/cal-camerarx.c | 12 +--
>> drivers/media/v4l2-core/v4l2-subdev.c | 85 ++++++++++----------
>> include/media/v4l2-subdev.h | 49 +++++------
>> 4 files changed, 78 insertions(+), 78 deletions(-)
>>
>> diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
>> index 14f3afa7721a..7c76c0754426 100644
>> --- a/drivers/media/i2c/ov5640.c
>> +++ b/drivers/media/i2c/ov5640.c
>> @@ -2227,7 +2227,7 @@ static int ov5640_try_frame_interval(struct ov5640_dev *sensor,
>> }
>>
>> static int ov5640_get_fmt(struct v4l2_subdev *sd,
>> - struct v4l2_subdev_pad_config *cfg,
>> + struct v4l2_subdev_config *cfg,
>> struct v4l2_subdev_format *format)
>> {
>> struct ov5640_dev *sensor = to_ov5640_dev(sd);
>> @@ -2285,7 +2285,7 @@ static int ov5640_try_fmt_internal(struct v4l2_subdev *sd,
>> }
>>
>> static int ov5640_set_fmt(struct v4l2_subdev *sd,
>> - struct v4l2_subdev_pad_config *cfg,
>> + struct v4l2_subdev_config *cfg,
>> struct v4l2_subdev_format *format)
>> {
>> struct ov5640_dev *sensor = to_ov5640_dev(sd);
>> @@ -2818,7 +2818,7 @@ static int ov5640_init_controls(struct ov5640_dev *sensor)
>> }
>>
>> static int ov5640_enum_frame_size(struct v4l2_subdev *sd,
>> - struct v4l2_subdev_pad_config *cfg,
>> + struct v4l2_subdev_config *cfg,
>> struct v4l2_subdev_frame_size_enum *fse)
>> {
>> if (fse->pad != 0)
>> @@ -2838,7 +2838,7 @@ static int ov5640_enum_frame_size(struct v4l2_subdev *sd,
>>
>> static int ov5640_enum_frame_interval(
>> struct v4l2_subdev *sd,
>> - struct v4l2_subdev_pad_config *cfg,
>> + struct v4l2_subdev_config *cfg,
>> struct v4l2_subdev_frame_interval_enum *fie)
>> {
>> struct ov5640_dev *sensor = to_ov5640_dev(sd);
>> @@ -2924,7 +2924,7 @@ static int ov5640_s_frame_interval(struct v4l2_subdev *sd,
>> }
>>
>> static int ov5640_enum_mbus_code(struct v4l2_subdev *sd,
>> - struct v4l2_subdev_pad_config *cfg,
>> + struct v4l2_subdev_config *cfg,
>> struct v4l2_subdev_mbus_code_enum *code)
>> {
>> if (code->pad != 0)
>> diff --git a/drivers/media/platform/ti-vpe/cal-camerarx.c b/drivers/media/platform/ti-vpe/cal-camerarx.c
>> index cbe6114908de..c708c61f2188 100644
>> --- a/drivers/media/platform/ti-vpe/cal-camerarx.c
>> +++ b/drivers/media/platform/ti-vpe/cal-camerarx.c
>> @@ -586,7 +586,7 @@ static inline struct cal_camerarx *to_cal_camerarx(struct v4l2_subdev *sd)
>>
>> static struct v4l2_mbus_framefmt *
>> cal_camerarx_get_pad_format(struct cal_camerarx *phy,
>> - struct v4l2_subdev_pad_config *cfg,
>> + struct v4l2_subdev_config *cfg,
>> unsigned int pad, u32 which)
>> {
>> switch (which) {
>> @@ -611,7 +611,7 @@ static int cal_camerarx_sd_s_stream(struct v4l2_subdev *sd, int enable)
>> }
>>
>> static int cal_camerarx_sd_enum_mbus_code(struct v4l2_subdev *sd,
>> - struct v4l2_subdev_pad_config *cfg,
>> + struct v4l2_subdev_config *cfg,
>> struct v4l2_subdev_mbus_code_enum *code)
>> {
>> struct cal_camerarx *phy = to_cal_camerarx(sd);
>> @@ -639,7 +639,7 @@ static int cal_camerarx_sd_enum_mbus_code(struct v4l2_subdev *sd,
>> }
>>
>> static int cal_camerarx_sd_enum_frame_size(struct v4l2_subdev *sd,
>> - struct v4l2_subdev_pad_config *cfg,
>> + struct v4l2_subdev_config *cfg,
>> struct v4l2_subdev_frame_size_enum *fse)
>> {
>> struct cal_camerarx *phy = to_cal_camerarx(sd);
>> @@ -679,7 +679,7 @@ static int cal_camerarx_sd_enum_frame_size(struct v4l2_subdev *sd,
>> }
>>
>> static int cal_camerarx_sd_get_fmt(struct v4l2_subdev *sd,
>> - struct v4l2_subdev_pad_config *cfg,
>> + struct v4l2_subdev_config *cfg,
>> struct v4l2_subdev_format *format)
>> {
>> struct cal_camerarx *phy = to_cal_camerarx(sd);
>> @@ -692,7 +692,7 @@ static int cal_camerarx_sd_get_fmt(struct v4l2_subdev *sd,
>> }
>>
>> static int cal_camerarx_sd_set_fmt(struct v4l2_subdev *sd,
>> - struct v4l2_subdev_pad_config *cfg,
>> + struct v4l2_subdev_config *cfg,
>> struct v4l2_subdev_format *format)
>> {
>> struct cal_camerarx *phy = to_cal_camerarx(sd);
>> @@ -742,7 +742,7 @@ static int cal_camerarx_sd_set_fmt(struct v4l2_subdev *sd,
>> }
>>
>> static int cal_camerarx_sd_init_cfg(struct v4l2_subdev *sd,
>> - struct v4l2_subdev_pad_config *cfg)
>> + struct v4l2_subdev_config *cfg)
>> {
>> struct v4l2_subdev_format format = {
>> .which = cfg ? V4L2_SUBDEV_FORMAT_TRY
>> diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
>> index 956dafab43d4..248fa4ee9356 100644
>> --- a/drivers/media/v4l2-core/v4l2-subdev.c
>> +++ b/drivers/media/v4l2-core/v4l2-subdev.c
>> @@ -26,19 +26,18 @@
>> #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
>> static int subdev_fh_init(struct v4l2_subdev_fh *fh, struct v4l2_subdev *sd)
>> {
>> - if (sd->entity.num_pads) {
>> - fh->pad = v4l2_subdev_alloc_pad_config(sd);
>> - if (fh->pad == NULL)
>> - return -ENOMEM;
>> - }
>> + int ret;
>> +
>> + ret = v4l2_subdev_init_config(sd, &fh->cfg);
>> + if (ret)
>> + return ret;
>>
>> return 0;
>> }
>>
>> static void subdev_fh_free(struct v4l2_subdev_fh *fh)
>> {
>> - v4l2_subdev_free_pad_config(fh->pad);
>> - fh->pad = NULL;
>> + v4l2_subdev_uninit_config(&fh->cfg);
>> }
>>
>> static int subdev_open(struct file *file)
>> @@ -146,7 +145,7 @@ static inline int check_pad(struct v4l2_subdev *sd, u32 pad)
>> return 0;
>> }
>>
>> -static int check_cfg(u32 which, struct v4l2_subdev_pad_config *cfg)
>> +static int check_cfg(u32 which, struct v4l2_subdev_config *cfg)
>> {
>> if (which == V4L2_SUBDEV_FORMAT_TRY && !cfg)
>> return -EINVAL;
>> @@ -155,7 +154,7 @@ static int check_cfg(u32 which, struct v4l2_subdev_pad_config *cfg)
>> }
>>
>> static inline int check_format(struct v4l2_subdev *sd,
>> - struct v4l2_subdev_pad_config *cfg,
>> + struct v4l2_subdev_config *cfg,
>> struct v4l2_subdev_format *format)
>> {
>> if (!format)
>> @@ -166,7 +165,7 @@ static inline int check_format(struct v4l2_subdev *sd,
>> }
>>
>> static int call_get_fmt(struct v4l2_subdev *sd,
>> - struct v4l2_subdev_pad_config *cfg,
>> + struct v4l2_subdev_config *cfg,
>> struct v4l2_subdev_format *format)
>> {
>> return check_format(sd, cfg, format) ? :
>> @@ -174,7 +173,7 @@ static int call_get_fmt(struct v4l2_subdev *sd,
>> }
>>
>> static int call_set_fmt(struct v4l2_subdev *sd,
>> - struct v4l2_subdev_pad_config *cfg,
>> + struct v4l2_subdev_config *cfg,
>> struct v4l2_subdev_format *format)
>> {
>> return check_format(sd, cfg, format) ? :
>> @@ -182,7 +181,7 @@ static int call_set_fmt(struct v4l2_subdev *sd,
>> }
>>
>> static int call_enum_mbus_code(struct v4l2_subdev *sd,
>> - struct v4l2_subdev_pad_config *cfg,
>> + struct v4l2_subdev_config *cfg,
>> struct v4l2_subdev_mbus_code_enum *code)
>> {
>> if (!code)
>> @@ -194,7 +193,7 @@ static int call_enum_mbus_code(struct v4l2_subdev *sd,
>> }
>>
>> static int call_enum_frame_size(struct v4l2_subdev *sd,
>> - struct v4l2_subdev_pad_config *cfg,
>> + struct v4l2_subdev_config *cfg,
>> struct v4l2_subdev_frame_size_enum *fse)
>> {
>> if (!fse)
>> @@ -229,7 +228,7 @@ static int call_s_frame_interval(struct v4l2_subdev *sd,
>> }
>>
>> static int call_enum_frame_interval(struct v4l2_subdev *sd,
>> - struct v4l2_subdev_pad_config *cfg,
>> + struct v4l2_subdev_config *cfg,
>> struct v4l2_subdev_frame_interval_enum *fie)
>> {
>> if (!fie)
>> @@ -241,7 +240,7 @@ static int call_enum_frame_interval(struct v4l2_subdev *sd,
>> }
>>
>> static inline int check_selection(struct v4l2_subdev *sd,
>> - struct v4l2_subdev_pad_config *cfg,
>> + struct v4l2_subdev_config *cfg,
>> struct v4l2_subdev_selection *sel)
>> {
>> if (!sel)
>> @@ -252,7 +251,7 @@ static inline int check_selection(struct v4l2_subdev *sd,
>> }
>>
>> static int call_get_selection(struct v4l2_subdev *sd,
>> - struct v4l2_subdev_pad_config *cfg,
>> + struct v4l2_subdev_config *cfg,
>> struct v4l2_subdev_selection *sel)
>> {
>> return check_selection(sd, cfg, sel) ? :
>> @@ -260,7 +259,7 @@ static int call_get_selection(struct v4l2_subdev *sd,
>> }
>>
>> static int call_set_selection(struct v4l2_subdev *sd,
>> - struct v4l2_subdev_pad_config *cfg,
>> + struct v4l2_subdev_config *cfg,
>> struct v4l2_subdev_selection *sel)
>> {
>> return check_selection(sd, cfg, sel) ? :
>> @@ -506,7 +505,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
>>
>> memset(format->reserved, 0, sizeof(format->reserved));
>> memset(format->format.reserved, 0, sizeof(format->format.reserved));
>> - return v4l2_subdev_call(sd, pad, get_fmt, subdev_fh->pad, format);
>> + return v4l2_subdev_call(sd, pad, get_fmt, &subdev_fh->cfg, format);
>> }
>>
>> case VIDIOC_SUBDEV_S_FMT: {
>> @@ -517,7 +516,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
>>
>> memset(format->reserved, 0, sizeof(format->reserved));
>> memset(format->format.reserved, 0, sizeof(format->format.reserved));
>> - return v4l2_subdev_call(sd, pad, set_fmt, subdev_fh->pad, format);
>> + return v4l2_subdev_call(sd, pad, set_fmt, &subdev_fh->cfg, format);
>> }
>>
>> case VIDIOC_SUBDEV_G_CROP: {
>> @@ -531,7 +530,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
>> sel.target = V4L2_SEL_TGT_CROP;
>>
>> rval = v4l2_subdev_call(
>> - sd, pad, get_selection, subdev_fh->pad, &sel);
>> + sd, pad, get_selection, &subdev_fh->cfg, &sel);
>>
>> crop->rect = sel.r;
>>
>> @@ -553,7 +552,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
>> sel.r = crop->rect;
>>
>> rval = v4l2_subdev_call(
>> - sd, pad, set_selection, subdev_fh->pad, &sel);
>> + sd, pad, set_selection, &subdev_fh->cfg, &sel);
>>
>> crop->rect = sel.r;
>>
>> @@ -564,7 +563,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
>> struct v4l2_subdev_mbus_code_enum *code = arg;
>>
>> memset(code->reserved, 0, sizeof(code->reserved));
>> - return v4l2_subdev_call(sd, pad, enum_mbus_code, subdev_fh->pad,
>> + return v4l2_subdev_call(sd, pad, enum_mbus_code, &subdev_fh->cfg,
>> code);
>> }
>>
>> @@ -572,7 +571,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
>> struct v4l2_subdev_frame_size_enum *fse = arg;
>>
>> memset(fse->reserved, 0, sizeof(fse->reserved));
>> - return v4l2_subdev_call(sd, pad, enum_frame_size, subdev_fh->pad,
>> + return v4l2_subdev_call(sd, pad, enum_frame_size, &subdev_fh->cfg,
>> fse);
>> }
>>
>> @@ -597,7 +596,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
>> struct v4l2_subdev_frame_interval_enum *fie = arg;
>>
>> memset(fie->reserved, 0, sizeof(fie->reserved));
>> - return v4l2_subdev_call(sd, pad, enum_frame_interval, subdev_fh->pad,
>> + return v4l2_subdev_call(sd, pad, enum_frame_interval, &subdev_fh->cfg,
>> fie);
>> }
>>
>> @@ -606,7 +605,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
>>
>> memset(sel->reserved, 0, sizeof(sel->reserved));
>> return v4l2_subdev_call(
>> - sd, pad, get_selection, subdev_fh->pad, sel);
>> + sd, pad, get_selection, &subdev_fh->cfg, sel);
>> }
>>
>> case VIDIOC_SUBDEV_S_SELECTION: {
>> @@ -617,7 +616,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
>>
>> memset(sel->reserved, 0, sizeof(sel->reserved));
>> return v4l2_subdev_call(
>> - sd, pad, set_selection, subdev_fh->pad, sel);
>> + sd, pad, set_selection, &subdev_fh->cfg, sel);
>> }
>>
>> case VIDIOC_G_EDID: {
>
> So far, it's a pretty simple change :-)
>
> I'd actually take it one step further (on top of course), and store an
> instance of v4l2_subdev_config in v4l2_subdev for the active
> configuration. This can massively simplify subdev drivers.
Hmm, struct v4l2_subdev_pad_config talks about try_fmt/crop/compose, that
would be weird for the active configuration.
I guess you would have to experiment a bit with this.
>
>> @@ -892,35 +891,35 @@ int v4l2_subdev_link_validate(struct media_link *link)
>> }
>> EXPORT_SYMBOL_GPL(v4l2_subdev_link_validate);
>>
>> -struct v4l2_subdev_pad_config *
>> -v4l2_subdev_alloc_pad_config(struct v4l2_subdev *sd)
>> +int v4l2_subdev_init_config(struct v4l2_subdev *sd, struct v4l2_subdev_config *cfg)
>
> Line wrap (and below too).
>
>> {
>> - struct v4l2_subdev_pad_config *cfg;
>> int ret;
>>
>> - if (!sd->entity.num_pads)
>> - return NULL;
>> -
>> - cfg = kvmalloc_array(sd->entity.num_pads, sizeof(*cfg),
>> - GFP_KERNEL | __GFP_ZERO);
>> - if (!cfg)
>> - return NULL;
>> + if (sd->entity.num_pads) {
>> + cfg->pad_configs = kvmalloc_array(sd->entity.num_pads, sizeof(*cfg->pad_configs),
>> + GFP_KERNEL | __GFP_ZERO);
>> + if (!cfg->pad_configs)
>> + return -ENOMEM;
>> + } else {
>> + cfg->pad_configs = NULL;
>> + }
>
> How about memsetting the whole structure to 0 first ?
>
>>
>> ret = v4l2_subdev_call(sd, pad, init_cfg, cfg);
>> if (ret < 0 && ret != -ENOIOCTLCMD) {
>> - kvfree(cfg);
>> - return NULL;
>> + kvfree(cfg->pad_configs);
>> + return ret;
>> }
>>
>> - return cfg;
>> + return 0;
>> }
>> -EXPORT_SYMBOL_GPL(v4l2_subdev_alloc_pad_config);
>> +EXPORT_SYMBOL_GPL(v4l2_subdev_init_config);
>>
>> -void v4l2_subdev_free_pad_config(struct v4l2_subdev_pad_config *cfg)
>> +void v4l2_subdev_uninit_config(struct v4l2_subdev_config *cfg)
>> {
>> - kvfree(cfg);
>> + kvfree(cfg->pad_configs);
>> }
>> -EXPORT_SYMBOL_GPL(v4l2_subdev_free_pad_config);
>> +EXPORT_SYMBOL_GPL(v4l2_subdev_uninit_config);
>> +
>> #endif /* CONFIG_MEDIA_CONTROLLER */
>>
>> void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops)
>> diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
>> index d0e9a5bdb08b..1873e527987a 100644
>> --- a/include/media/v4l2-subdev.h
>> +++ b/include/media/v4l2-subdev.h
>> @@ -623,6 +623,10 @@ struct v4l2_subdev_pad_config {
>> struct v4l2_rect try_compose;
>> };
>>
>> +struct v4l2_subdev_config {
>> + struct v4l2_subdev_pad_config *pad_configs;
>
> s/pad_configs/pads/ ?
I agree.
>
> I'm tempted to also store the number of pads here. It would be redundant
> as the value is available from the v4l2_subdev structure, but it would
> allow operating on v4l2_subdev_config without a subdev pointer. Or,
> possibly better, we could store a pointer to the subdev.
>
> I'm also tempted to name the structure v4l2_subdev_state, as that's what
> it stores. I may be biased by DRM/KMS, but I don't see a downside in
> using identical names for identical concepts.
I like v4l2_subdev_state better than v4l2_subdev_config, so I would be OK
with such a change.
>
>> +};
>> +
>> /**
>> * struct v4l2_subdev_pad_ops - v4l2-subdev pad level operations
>> *
>> @@ -687,27 +691,27 @@ struct v4l2_subdev_pad_config {
>> */
>> struct v4l2_subdev_pad_ops {
>> int (*init_cfg)(struct v4l2_subdev *sd,
If we do change the name, then this probably should be renamed to init_state as well.
>> - struct v4l2_subdev_pad_config *cfg);
>> + struct v4l2_subdev_config *cfg);
>> int (*enum_mbus_code)(struct v4l2_subdev *sd,
>> - struct v4l2_subdev_pad_config *cfg,
>> + struct v4l2_subdev_config *cfg,
>> struct v4l2_subdev_mbus_code_enum *code);
>> int (*enum_frame_size)(struct v4l2_subdev *sd,
>> - struct v4l2_subdev_pad_config *cfg,
>> + struct v4l2_subdev_config *cfg,
>> struct v4l2_subdev_frame_size_enum *fse);
>> int (*enum_frame_interval)(struct v4l2_subdev *sd,
>> - struct v4l2_subdev_pad_config *cfg,
>> + struct v4l2_subdev_config *cfg,
>> struct v4l2_subdev_frame_interval_enum *fie);
>> int (*get_fmt)(struct v4l2_subdev *sd,
>> - struct v4l2_subdev_pad_config *cfg,
>> + struct v4l2_subdev_config *cfg,
>> struct v4l2_subdev_format *format);
>> int (*set_fmt)(struct v4l2_subdev *sd,
>> - struct v4l2_subdev_pad_config *cfg,
>> + struct v4l2_subdev_config *cfg,
>> struct v4l2_subdev_format *format);
>> int (*get_selection)(struct v4l2_subdev *sd,
>> - struct v4l2_subdev_pad_config *cfg,
>> + struct v4l2_subdev_config *cfg,
>> struct v4l2_subdev_selection *sel);
>> int (*set_selection)(struct v4l2_subdev *sd,
>> - struct v4l2_subdev_pad_config *cfg,
>> + struct v4l2_subdev_config *cfg,
>> struct v4l2_subdev_selection *sel);
>> int (*get_edid)(struct v4l2_subdev *sd, struct v4l2_edid *edid);
>> int (*set_edid)(struct v4l2_subdev *sd, struct v4l2_edid *edid);
>> @@ -925,7 +929,7 @@ struct v4l2_subdev_fh {
>> struct v4l2_fh vfh;
>> struct module *owner;
>> #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
>> - struct v4l2_subdev_pad_config *pad;
>> + struct v4l2_subdev_config cfg;
And of course cfg becomes 'state' too.
>> #endif
>> };
>>
>> @@ -950,12 +954,12 @@ struct v4l2_subdev_fh {
>> */
>> static inline struct v4l2_mbus_framefmt *
>> v4l2_subdev_get_try_format(struct v4l2_subdev *sd,
>> - struct v4l2_subdev_pad_config *cfg,
>> + struct v4l2_subdev_config *cfg,
>> unsigned int pad)
>> {
>> if (WARN_ON(pad >= sd->entity.num_pads))
>> pad = 0;
>> - return &cfg[pad].try_fmt;
>> + return &cfg->pad_configs[pad].try_fmt;
>> }
>>
>> /**
>> @@ -968,12 +972,12 @@ v4l2_subdev_get_try_format(struct v4l2_subdev *sd,
>> */
>> static inline struct v4l2_rect *
>> v4l2_subdev_get_try_crop(struct v4l2_subdev *sd,
>> - struct v4l2_subdev_pad_config *cfg,
>> + struct v4l2_subdev_config *cfg,
>> unsigned int pad)
>> {
>> if (WARN_ON(pad >= sd->entity.num_pads))
>> pad = 0;
>> - return &cfg[pad].try_crop;
>> + return &cfg->pad_configs[pad].try_crop;
>> }
>>
>> /**
>> @@ -986,12 +990,12 @@ v4l2_subdev_get_try_crop(struct v4l2_subdev *sd,
>> */
>> static inline struct v4l2_rect *
>> v4l2_subdev_get_try_compose(struct v4l2_subdev *sd,
>> - struct v4l2_subdev_pad_config *cfg,
>> + struct v4l2_subdev_config *cfg,
>> unsigned int pad)
>> {
>> if (WARN_ON(pad >= sd->entity.num_pads))
>> pad = 0;
>> - return &cfg[pad].try_compose;
>> + return &cfg->pad_configs[pad].try_compose;
>> }
>>
>> #endif
>> @@ -1093,20 +1097,17 @@ int v4l2_subdev_link_validate_default(struct v4l2_subdev *sd,
>> int v4l2_subdev_link_validate(struct media_link *link);
>>
>> /**
>> - * v4l2_subdev_alloc_pad_config - Allocates memory for pad config
>> + * v4l2_subdev_init_config - initialize v4l2_subdev_config
>> *
>> - * @sd: pointer to struct v4l2_subdev
>> + * Must call v4l2_subdev_uninit_config() when config is no longer needed.
>> */
>> -struct
>> -v4l2_subdev_pad_config *v4l2_subdev_alloc_pad_config(struct v4l2_subdev *sd);
>> +int v4l2_subdev_init_config(struct v4l2_subdev *sd, struct v4l2_subdev_config *cfg);
>>
>> /**
>> - * v4l2_subdev_free_pad_config - Frees memory allocated by
>> - * v4l2_subdev_alloc_pad_config().
>> - *
>> - * @cfg: pointer to &struct v4l2_subdev_pad_config
>> + * v4l2_subdev_uninit_config - uninitialize v4l2_subdev_config
>> */
>> -void v4l2_subdev_free_pad_config(struct v4l2_subdev_pad_config *cfg);
>> +void v4l2_subdev_uninit_config(struct v4l2_subdev_config *cfg);
>
> Finally, still on the naming topic, if you agree with v4l2_subdev_state,
> I'd name the function v4l2_subdev_state_init() and
> v4l2_subdev_state_cleanup(). I have a feeling we may be better off
> allocating states dynamically (storing a pointer in v4l2_subdev_fh
> instead of embedding an instance), in which case
> v4l2_subdev_state_alloc() and v4l2_subdev_state_free() would be better,
> but that's just a feeling at this point.
>
>> +
>> #endif /* CONFIG_MEDIA_CONTROLLER */
>>
>> /**
>
Regards,
Hans
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] RFC: media: v4l2-subdev: add subdev-wide config struct
2021-04-09 13:36 [PATCH] RFC: media: v4l2-subdev: add subdev-wide config struct Tomi Valkeinen
` (2 preceding siblings ...)
2021-04-18 16:07 ` Laurent Pinchart
@ 2021-04-20 15:35 ` Sakari Ailus
2021-04-20 15:38 ` Sakari Ailus
3 siblings, 1 reply; 7+ messages in thread
From: Sakari Ailus @ 2021-04-20 15:35 UTC (permalink / raw)
To: Tomi Valkeinen
Cc: Mauro Carvalho Chehab, Hans Verkuil, linux-media,
Laurent Pinchart
Moi,
Thanks for the patch.
On Fri, Apr 09, 2021 at 04:36:59PM +0300, Tomi Valkeinen wrote:
> We have 'struct v4l2_subdev_pad_config' which contains configuration for
> a single pad used for the TRY functionality, and an array of those
> structs is passed to various v4l2_subdev_pad_ops.
>
> I was working on subdev internal routing between pads, and realized that
> there's no way to add TRY functionality for routes, which is not pad
> specific configuration. Adding a separate struct for try-route config
> wouldn't work either, as e.g. set-fmt needs to know the try-route
> configuration to propagate the settings.
>
> This patch adds a new struct, 'struct v4l2_subdev_config' (which at the
> moment only contains the v4l2_subdev_pad_config array) and the new
> struct is used in most of the places where v4l2_subdev_pad_config was
> used. All v4l2_subdev_pad_ops functions taking v4l2_subdev_pad_config
> are changed to instead take v4l2_subdev_config.
>
> Two drivers are changed to work with the above changes (drivers for HW
> which I have) as an example.
>
> I worked on a semantic patch (included below, my first spatch...) to do
> this change to all drivers, but hit lots of problems with non-trivial
> uses of v4l2_subdev_pad_config.
>
> As it looks like substantial amount of manual work is needed, I'm
> posting this RFC to get an ack on the changes before continuing that
> work.
Previously the try configuration has been just about pads, and routing
isn't specific to them now.
I think this change makes sense.
Please see my comments below.
>
> @ v4l2_subdev_pad_ops @
> identifier pad_ops;
> identifier func;
> @@
>
> (
> static const struct v4l2_subdev_pad_ops pad_ops = {
> ...,
> .enum_mbus_code = func,
> ...,
> };
> |
> static const struct v4l2_subdev_pad_ops pad_ops = {
> ...,
> .enum_frame_size = func,
> ...,
> };
> |
> static const struct v4l2_subdev_pad_ops pad_ops = {
> ...,
> .enum_frame_interval = func,
> ...,
> };
> |
> static const struct v4l2_subdev_pad_ops pad_ops = {
> ...,
> .get_fmt = func,
> ...,
> };
> |
> static const struct v4l2_subdev_pad_ops pad_ops = {
> ...,
> .set_fmt = func,
> ...,
> };
> |
> static const struct v4l2_subdev_pad_ops pad_ops = {
> ...,
> .get_selection = func,
> ...,
> };
> |
> static const struct v4l2_subdev_pad_ops pad_ops = {
> ...,
> .set_selection = func,
> ...,
> };
> |
> static const struct v4l2_subdev_pad_ops pad_ops = {
> ...,
> .init_cfg = func,
> ...,
> };
> )
>
> @@
> identifier v4l2_subdev_pad_ops.func;
> identifier sd;
> identifier cfg;
> @@
>
> func(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> ...
> )
> {
> ...
> }
>
> @@
> identifier v4l2_subdev_pad_ops.func;
> identifier sd;
> identifier cfg;
> @@
>
> func(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg
> + struct v4l2_subdev_config *cfg
> )
> {
> ...
> }
>
> @@
> struct v4l2_subdev_fh *fh;
> @@
> - fh->pad
> + &fh->cfg
>
> @@
> identifier func;
> identifier cfg;
> @@
>
> func(...,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> ...)
> {
> ...
> }
>
> @@
> struct v4l2_subdev_config *cfg;
> @@
> {
> <...
> (
> - cfg->try_fmt
> + cfg->pad_configs->try_fmt
> |
> - cfg->try_crop
> + cfg->pad_configs->try_crop
> |
> - cfg->try_compose
> + cfg->pad_configs->try_compose
> )
> ...>
> }
>
> @@
> identifier pad_cfg;
> @@
> {
> ...
> struct v4l2_subdev_pad_config pad_cfg;
> + struct v4l2_subdev_config cfg = { .pad_configs = &pad_cfg };
> <...
> - &pad_cfg
> + &cfg
> ...>
> }
>
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> ---
> drivers/media/i2c/ov5640.c | 10 +--
> drivers/media/platform/ti-vpe/cal-camerarx.c | 12 +--
> drivers/media/v4l2-core/v4l2-subdev.c | 85 ++++++++++----------
> include/media/v4l2-subdev.h | 49 +++++------
> 4 files changed, 78 insertions(+), 78 deletions(-)
>
> diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
> index 14f3afa7721a..7c76c0754426 100644
> --- a/drivers/media/i2c/ov5640.c
> +++ b/drivers/media/i2c/ov5640.c
> @@ -2227,7 +2227,7 @@ static int ov5640_try_frame_interval(struct ov5640_dev *sensor,
> }
>
> static int ov5640_get_fmt(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_format *format)
> {
> struct ov5640_dev *sensor = to_ov5640_dev(sd);
> @@ -2285,7 +2285,7 @@ static int ov5640_try_fmt_internal(struct v4l2_subdev *sd,
> }
>
> static int ov5640_set_fmt(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_format *format)
> {
> struct ov5640_dev *sensor = to_ov5640_dev(sd);
> @@ -2818,7 +2818,7 @@ static int ov5640_init_controls(struct ov5640_dev *sensor)
> }
>
> static int ov5640_enum_frame_size(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_frame_size_enum *fse)
> {
> if (fse->pad != 0)
> @@ -2838,7 +2838,7 @@ static int ov5640_enum_frame_size(struct v4l2_subdev *sd,
>
> static int ov5640_enum_frame_interval(
> struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_frame_interval_enum *fie)
> {
> struct ov5640_dev *sensor = to_ov5640_dev(sd);
> @@ -2924,7 +2924,7 @@ static int ov5640_s_frame_interval(struct v4l2_subdev *sd,
> }
>
> static int ov5640_enum_mbus_code(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_mbus_code_enum *code)
> {
> if (code->pad != 0)
> diff --git a/drivers/media/platform/ti-vpe/cal-camerarx.c b/drivers/media/platform/ti-vpe/cal-camerarx.c
> index cbe6114908de..c708c61f2188 100644
> --- a/drivers/media/platform/ti-vpe/cal-camerarx.c
> +++ b/drivers/media/platform/ti-vpe/cal-camerarx.c
> @@ -586,7 +586,7 @@ static inline struct cal_camerarx *to_cal_camerarx(struct v4l2_subdev *sd)
>
> static struct v4l2_mbus_framefmt *
> cal_camerarx_get_pad_format(struct cal_camerarx *phy,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> unsigned int pad, u32 which)
> {
> switch (which) {
> @@ -611,7 +611,7 @@ static int cal_camerarx_sd_s_stream(struct v4l2_subdev *sd, int enable)
> }
>
> static int cal_camerarx_sd_enum_mbus_code(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_mbus_code_enum *code)
> {
> struct cal_camerarx *phy = to_cal_camerarx(sd);
> @@ -639,7 +639,7 @@ static int cal_camerarx_sd_enum_mbus_code(struct v4l2_subdev *sd,
> }
>
> static int cal_camerarx_sd_enum_frame_size(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_frame_size_enum *fse)
> {
> struct cal_camerarx *phy = to_cal_camerarx(sd);
> @@ -679,7 +679,7 @@ static int cal_camerarx_sd_enum_frame_size(struct v4l2_subdev *sd,
> }
>
> static int cal_camerarx_sd_get_fmt(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_format *format)
> {
> struct cal_camerarx *phy = to_cal_camerarx(sd);
> @@ -692,7 +692,7 @@ static int cal_camerarx_sd_get_fmt(struct v4l2_subdev *sd,
> }
>
> static int cal_camerarx_sd_set_fmt(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_format *format)
> {
> struct cal_camerarx *phy = to_cal_camerarx(sd);
> @@ -742,7 +742,7 @@ static int cal_camerarx_sd_set_fmt(struct v4l2_subdev *sd,
> }
>
> static int cal_camerarx_sd_init_cfg(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg)
> + struct v4l2_subdev_config *cfg)
> {
> struct v4l2_subdev_format format = {
> .which = cfg ? V4L2_SUBDEV_FORMAT_TRY
> diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
> index 956dafab43d4..248fa4ee9356 100644
> --- a/drivers/media/v4l2-core/v4l2-subdev.c
> +++ b/drivers/media/v4l2-core/v4l2-subdev.c
> @@ -26,19 +26,18 @@
> #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
> static int subdev_fh_init(struct v4l2_subdev_fh *fh, struct v4l2_subdev *sd)
> {
> - if (sd->entity.num_pads) {
> - fh->pad = v4l2_subdev_alloc_pad_config(sd);
> - if (fh->pad == NULL)
> - return -ENOMEM;
> - }
> + int ret;
> +
> + ret = v4l2_subdev_init_config(sd, &fh->cfg);
> + if (ret)
> + return ret;
You can do:
return v4l2_subdev_init_config(sd, &fh->cfg);
>
> return 0;
> }
>
> static void subdev_fh_free(struct v4l2_subdev_fh *fh)
> {
> - v4l2_subdev_free_pad_config(fh->pad);
> - fh->pad = NULL;
> + v4l2_subdev_uninit_config(&fh->cfg);
> }
>
> static int subdev_open(struct file *file)
> @@ -146,7 +145,7 @@ static inline int check_pad(struct v4l2_subdev *sd, u32 pad)
> return 0;
> }
>
> -static int check_cfg(u32 which, struct v4l2_subdev_pad_config *cfg)
> +static int check_cfg(u32 which, struct v4l2_subdev_config *cfg)
> {
> if (which == V4L2_SUBDEV_FORMAT_TRY && !cfg)
> return -EINVAL;
> @@ -155,7 +154,7 @@ static int check_cfg(u32 which, struct v4l2_subdev_pad_config *cfg)
> }
>
> static inline int check_format(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_format *format)
> {
> if (!format)
> @@ -166,7 +165,7 @@ static inline int check_format(struct v4l2_subdev *sd,
> }
>
> static int call_get_fmt(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_format *format)
> {
> return check_format(sd, cfg, format) ? :
> @@ -174,7 +173,7 @@ static int call_get_fmt(struct v4l2_subdev *sd,
> }
>
> static int call_set_fmt(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_format *format)
> {
> return check_format(sd, cfg, format) ? :
> @@ -182,7 +181,7 @@ static int call_set_fmt(struct v4l2_subdev *sd,
> }
>
> static int call_enum_mbus_code(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_mbus_code_enum *code)
> {
> if (!code)
> @@ -194,7 +193,7 @@ static int call_enum_mbus_code(struct v4l2_subdev *sd,
> }
>
> static int call_enum_frame_size(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_frame_size_enum *fse)
> {
> if (!fse)
> @@ -229,7 +228,7 @@ static int call_s_frame_interval(struct v4l2_subdev *sd,
> }
>
> static int call_enum_frame_interval(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_frame_interval_enum *fie)
> {
> if (!fie)
> @@ -241,7 +240,7 @@ static int call_enum_frame_interval(struct v4l2_subdev *sd,
> }
>
> static inline int check_selection(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_selection *sel)
> {
> if (!sel)
> @@ -252,7 +251,7 @@ static inline int check_selection(struct v4l2_subdev *sd,
> }
>
> static int call_get_selection(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_selection *sel)
> {
> return check_selection(sd, cfg, sel) ? :
> @@ -260,7 +259,7 @@ static int call_get_selection(struct v4l2_subdev *sd,
> }
>
> static int call_set_selection(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_selection *sel)
> {
> return check_selection(sd, cfg, sel) ? :
> @@ -506,7 +505,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
>
> memset(format->reserved, 0, sizeof(format->reserved));
> memset(format->format.reserved, 0, sizeof(format->format.reserved));
> - return v4l2_subdev_call(sd, pad, get_fmt, subdev_fh->pad, format);
> + return v4l2_subdev_call(sd, pad, get_fmt, &subdev_fh->cfg, format);
> }
>
> case VIDIOC_SUBDEV_S_FMT: {
> @@ -517,7 +516,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
>
> memset(format->reserved, 0, sizeof(format->reserved));
> memset(format->format.reserved, 0, sizeof(format->format.reserved));
> - return v4l2_subdev_call(sd, pad, set_fmt, subdev_fh->pad, format);
> + return v4l2_subdev_call(sd, pad, set_fmt, &subdev_fh->cfg, format);
> }
>
> case VIDIOC_SUBDEV_G_CROP: {
> @@ -531,7 +530,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
> sel.target = V4L2_SEL_TGT_CROP;
>
> rval = v4l2_subdev_call(
> - sd, pad, get_selection, subdev_fh->pad, &sel);
> + sd, pad, get_selection, &subdev_fh->cfg, &sel);
>
> crop->rect = sel.r;
>
> @@ -553,7 +552,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
> sel.r = crop->rect;
>
> rval = v4l2_subdev_call(
> - sd, pad, set_selection, subdev_fh->pad, &sel);
> + sd, pad, set_selection, &subdev_fh->cfg, &sel);
>
> crop->rect = sel.r;
>
> @@ -564,7 +563,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
> struct v4l2_subdev_mbus_code_enum *code = arg;
>
> memset(code->reserved, 0, sizeof(code->reserved));
> - return v4l2_subdev_call(sd, pad, enum_mbus_code, subdev_fh->pad,
> + return v4l2_subdev_call(sd, pad, enum_mbus_code, &subdev_fh->cfg,
> code);
> }
>
> @@ -572,7 +571,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
> struct v4l2_subdev_frame_size_enum *fse = arg;
>
> memset(fse->reserved, 0, sizeof(fse->reserved));
> - return v4l2_subdev_call(sd, pad, enum_frame_size, subdev_fh->pad,
> + return v4l2_subdev_call(sd, pad, enum_frame_size, &subdev_fh->cfg,
> fse);
> }
>
> @@ -597,7 +596,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
> struct v4l2_subdev_frame_interval_enum *fie = arg;
>
> memset(fie->reserved, 0, sizeof(fie->reserved));
> - return v4l2_subdev_call(sd, pad, enum_frame_interval, subdev_fh->pad,
> + return v4l2_subdev_call(sd, pad, enum_frame_interval, &subdev_fh->cfg,
> fie);
> }
>
> @@ -606,7 +605,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
>
> memset(sel->reserved, 0, sizeof(sel->reserved));
> return v4l2_subdev_call(
> - sd, pad, get_selection, subdev_fh->pad, sel);
> + sd, pad, get_selection, &subdev_fh->cfg, sel);
> }
>
> case VIDIOC_SUBDEV_S_SELECTION: {
> @@ -617,7 +616,7 @@ static long subdev_do_ioctl(struct file *file, unsigned int cmd, void *arg)
>
> memset(sel->reserved, 0, sizeof(sel->reserved));
> return v4l2_subdev_call(
> - sd, pad, set_selection, subdev_fh->pad, sel);
> + sd, pad, set_selection, &subdev_fh->cfg, sel);
> }
>
> case VIDIOC_G_EDID: {
> @@ -892,35 +891,35 @@ int v4l2_subdev_link_validate(struct media_link *link)
> }
> EXPORT_SYMBOL_GPL(v4l2_subdev_link_validate);
>
> -struct v4l2_subdev_pad_config *
> -v4l2_subdev_alloc_pad_config(struct v4l2_subdev *sd)
> +int v4l2_subdev_init_config(struct v4l2_subdev *sd, struct v4l2_subdev_config *cfg)
> {
> - struct v4l2_subdev_pad_config *cfg;
> int ret;
>
> - if (!sd->entity.num_pads)
> - return NULL;
> -
> - cfg = kvmalloc_array(sd->entity.num_pads, sizeof(*cfg),
> - GFP_KERNEL | __GFP_ZERO);
> - if (!cfg)
> - return NULL;
> + if (sd->entity.num_pads) {
> + cfg->pad_configs = kvmalloc_array(sd->entity.num_pads, sizeof(*cfg->pad_configs),
> + GFP_KERNEL | __GFP_ZERO);
> + if (!cfg->pad_configs)
> + return -ENOMEM;
> + } else {
> + cfg->pad_configs = NULL;
> + }
>
> ret = v4l2_subdev_call(sd, pad, init_cfg, cfg);
> if (ret < 0 && ret != -ENOIOCTLCMD) {
> - kvfree(cfg);
> - return NULL;
> + kvfree(cfg->pad_configs);
You can call v4l2_subdev_uninit_config() here...
> + return ret;
> }
>
> - return cfg;
> + return 0;
> }
> -EXPORT_SYMBOL_GPL(v4l2_subdev_alloc_pad_config);
> +EXPORT_SYMBOL_GPL(v4l2_subdev_init_config);
>
> -void v4l2_subdev_free_pad_config(struct v4l2_subdev_pad_config *cfg)
> +void v4l2_subdev_uninit_config(struct v4l2_subdev_config *cfg)
> {
> - kvfree(cfg);
> + kvfree(cfg->pad_configs);
Please set cfg->pad_configs to NULL here.
> }
> -EXPORT_SYMBOL_GPL(v4l2_subdev_free_pad_config);
> +EXPORT_SYMBOL_GPL(v4l2_subdev_uninit_config);
> +
> #endif /* CONFIG_MEDIA_CONTROLLER */
>
> void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops)
> diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
> index d0e9a5bdb08b..1873e527987a 100644
> --- a/include/media/v4l2-subdev.h
> +++ b/include/media/v4l2-subdev.h
> @@ -623,6 +623,10 @@ struct v4l2_subdev_pad_config {
> struct v4l2_rect try_compose;
> };
>
> +struct v4l2_subdev_config {
> + struct v4l2_subdev_pad_config *pad_configs;
Could this be called just "pad"?
> +};
> +
> /**
> * struct v4l2_subdev_pad_ops - v4l2-subdev pad level operations
> *
> @@ -687,27 +691,27 @@ struct v4l2_subdev_pad_config {
> */
> struct v4l2_subdev_pad_ops {
> int (*init_cfg)(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg);
> + struct v4l2_subdev_config *cfg);
> int (*enum_mbus_code)(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_mbus_code_enum *code);
> int (*enum_frame_size)(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_frame_size_enum *fse);
> int (*enum_frame_interval)(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_frame_interval_enum *fie);
> int (*get_fmt)(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_format *format);
> int (*set_fmt)(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_format *format);
> int (*get_selection)(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_selection *sel);
> int (*set_selection)(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> struct v4l2_subdev_selection *sel);
> int (*get_edid)(struct v4l2_subdev *sd, struct v4l2_edid *edid);
> int (*set_edid)(struct v4l2_subdev *sd, struct v4l2_edid *edid);
> @@ -925,7 +929,7 @@ struct v4l2_subdev_fh {
> struct v4l2_fh vfh;
> struct module *owner;
> #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
> - struct v4l2_subdev_pad_config *pad;
> + struct v4l2_subdev_config cfg;
> #endif
> };
>
> @@ -950,12 +954,12 @@ struct v4l2_subdev_fh {
> */
> static inline struct v4l2_mbus_framefmt *
> v4l2_subdev_get_try_format(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> unsigned int pad)
> {
> if (WARN_ON(pad >= sd->entity.num_pads))
> pad = 0;
> - return &cfg[pad].try_fmt;
> + return &cfg->pad_configs[pad].try_fmt;
> }
>
> /**
> @@ -968,12 +972,12 @@ v4l2_subdev_get_try_format(struct v4l2_subdev *sd,
> */
> static inline struct v4l2_rect *
> v4l2_subdev_get_try_crop(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> unsigned int pad)
> {
> if (WARN_ON(pad >= sd->entity.num_pads))
> pad = 0;
> - return &cfg[pad].try_crop;
> + return &cfg->pad_configs[pad].try_crop;
> }
>
> /**
> @@ -986,12 +990,12 @@ v4l2_subdev_get_try_crop(struct v4l2_subdev *sd,
> */
> static inline struct v4l2_rect *
> v4l2_subdev_get_try_compose(struct v4l2_subdev *sd,
> - struct v4l2_subdev_pad_config *cfg,
> + struct v4l2_subdev_config *cfg,
> unsigned int pad)
> {
> if (WARN_ON(pad >= sd->entity.num_pads))
> pad = 0;
> - return &cfg[pad].try_compose;
> + return &cfg->pad_configs[pad].try_compose;
> }
>
> #endif
> @@ -1093,20 +1097,17 @@ int v4l2_subdev_link_validate_default(struct v4l2_subdev *sd,
> int v4l2_subdev_link_validate(struct media_link *link);
>
> /**
> - * v4l2_subdev_alloc_pad_config - Allocates memory for pad config
> + * v4l2_subdev_init_config - initialize v4l2_subdev_config
> *
> - * @sd: pointer to struct v4l2_subdev
> + * Must call v4l2_subdev_uninit_config() when config is no longer needed.
> */
> -struct
> -v4l2_subdev_pad_config *v4l2_subdev_alloc_pad_config(struct v4l2_subdev *sd);
> +int v4l2_subdev_init_config(struct v4l2_subdev *sd, struct v4l2_subdev_config *cfg);
>
> /**
> - * v4l2_subdev_free_pad_config - Frees memory allocated by
> - * v4l2_subdev_alloc_pad_config().
> - *
> - * @cfg: pointer to &struct v4l2_subdev_pad_config
> + * v4l2_subdev_uninit_config - uninitialize v4l2_subdev_config
> */
> -void v4l2_subdev_free_pad_config(struct v4l2_subdev_pad_config *cfg);
> +void v4l2_subdev_uninit_config(struct v4l2_subdev_config *cfg);
> +
> #endif /* CONFIG_MEDIA_CONTROLLER */
>
> /**
--
Kind regards,
Sakari Ailus
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] RFC: media: v4l2-subdev: add subdev-wide config struct
2021-04-20 15:35 ` Sakari Ailus
@ 2021-04-20 15:38 ` Sakari Ailus
0 siblings, 0 replies; 7+ messages in thread
From: Sakari Ailus @ 2021-04-20 15:38 UTC (permalink / raw)
To: Tomi Valkeinen
Cc: Mauro Carvalho Chehab, Hans Verkuil, linux-media,
Laurent Pinchart
A few more more mundane comments...
On Tue, Apr 20, 2021 at 06:35:10PM +0300, Sakari Ailus wrote:
...
> > +int v4l2_subdev_init_config(struct v4l2_subdev *sd, struct v4l2_subdev_config *cfg)
> > {
> > - struct v4l2_subdev_pad_config *cfg;
> > int ret;
> >
> > - if (!sd->entity.num_pads)
> > - return NULL;
> > -
> > - cfg = kvmalloc_array(sd->entity.num_pads, sizeof(*cfg),
> > - GFP_KERNEL | __GFP_ZERO);
> > - if (!cfg)
> > - return NULL;
> > + if (sd->entity.num_pads) {
> > + cfg->pad_configs = kvmalloc_array(sd->entity.num_pads, sizeof(*cfg->pad_configs),
> > + GFP_KERNEL | __GFP_ZERO);
Please also pay attention to line length and aligning arguments.
...
> > @@ -1093,20 +1097,17 @@ int v4l2_subdev_link_validate_default(struct v4l2_subdev *sd,
> > int v4l2_subdev_link_validate(struct media_link *link);
> >
> > /**
> > - * v4l2_subdev_alloc_pad_config - Allocates memory for pad config
> > + * v4l2_subdev_init_config - initialize v4l2_subdev_config
> > *
> > - * @sd: pointer to struct v4l2_subdev
> > + * Must call v4l2_subdev_uninit_config() when config is no longer needed.
> > */
> > -struct
> > -v4l2_subdev_pad_config *v4l2_subdev_alloc_pad_config(struct v4l2_subdev *sd);
> > +int v4l2_subdev_init_config(struct v4l2_subdev *sd, struct v4l2_subdev_config *cfg);
This should be wrapped, too... there are some others as well in this patch
I think.
--
Sakari Ailus
^ permalink raw reply [flat|nested] 7+ messages in thread