diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2013-04-03 03:08:19 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2013-04-14 18:46:02 -0400 |
commit | 3eef25107cab65a1158b11ba373fb9b4fc25b4b8 (patch) | |
tree | ab964c2868826e14c4a8ccf83f4e6703d4b97402 | |
parent | cd634f1bfc182e564f33809fdca33027bb99fceb (diff) |
[media] v4l2: drop V4L2_CHIP_MATCH_SUBDEV_NAME
After using the new VIDIOC_DBG_G_CHIP_NAME ioctl I realized that the matching
by name possibility is useless. Just drop it and rename MATCH_SUBDEV_IDX to
just MATCH_SUBDEV.
The v4l2-dbg utility is much better placed to match by name by just enumerating
all bridge and subdev devices until chip_name.name matches.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-ident.xml | 7 | ||||
-rw-r--r-- | Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-name.xml | 18 | ||||
-rw-r--r-- | Documentation/DocBook/media/v4l/vidioc-dbg-g-register.xml | 17 | ||||
-rw-r--r-- | drivers/media/v4l2-core/v4l2-common.c | 3 | ||||
-rw-r--r-- | drivers/media/v4l2-core/v4l2-ioctl.c | 55 | ||||
-rw-r--r-- | include/uapi/linux/videodev2.h | 3 |
6 files changed, 26 insertions, 77 deletions
diff --git a/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-ident.xml b/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-ident.xml index 82e43c6c72b8..921e18550d26 100644 --- a/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-ident.xml +++ b/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-ident.xml | |||
@@ -221,13 +221,8 @@ the values from <xref linkend="chip-ids" />.</entry> | |||
221 | <entry>Match the nth anciliary AC97 chip.</entry> | 221 | <entry>Match the nth anciliary AC97 chip.</entry> |
222 | </row> | 222 | </row> |
223 | <row> | 223 | <row> |
224 | <entry><constant>V4L2_CHIP_MATCH_SUBDEV_NAME</constant></entry> | 224 | <entry><constant>V4L2_CHIP_MATCH_SUBDEV</constant></entry> |
225 | <entry>4</entry> | 225 | <entry>4</entry> |
226 | <entry>Match the sub-device by name. Can't be used with this ioctl.</entry> | ||
227 | </row> | ||
228 | <row> | ||
229 | <entry><constant>V4L2_CHIP_MATCH_SUBDEV_IDX</constant></entry> | ||
230 | <entry>5</entry> | ||
231 | <entry>Match the nth sub-device. Can't be used with this ioctl.</entry> | 226 | <entry>Match the nth sub-device. Can't be used with this ioctl.</entry> |
232 | </row> | 227 | </row> |
233 | </tbody> | 228 | </tbody> |
diff --git a/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-name.xml b/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-name.xml index 5fce8d84288e..fa3bd42ab167 100644 --- a/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-name.xml +++ b/Documentation/DocBook/media/v4l/vidioc-dbg-g-chip-name.xml | |||
@@ -87,16 +87,7 @@ connected to the PCI or USB bus. Non-zero numbers identify specific | |||
87 | parts of the bridge chip such as an AC97 register block.</para> | 87 | parts of the bridge chip such as an AC97 register block.</para> |
88 | 88 | ||
89 | <para>When <structfield>match.type</structfield> is | 89 | <para>When <structfield>match.type</structfield> is |
90 | <constant>V4L2_CHIP_MATCH_SUBDEV_NAME</constant>, | 90 | <constant>V4L2_CHIP_MATCH_SUBDEV</constant>, |
91 | <structfield>match.name</structfield> contains the name of a sub-device. | ||
92 | For instance | ||
93 | <constant>"saa7127 6-0044"</constant> will match the saa7127 sub-device | ||
94 | at the given i2c bus. This match type is not very useful for this ioctl | ||
95 | and is here only for consistency. | ||
96 | </para> | ||
97 | |||
98 | <para>When <structfield>match.type</structfield> is | ||
99 | <constant>V4L2_CHIP_MATCH_SUBDEV_IDX</constant>, | ||
100 | <structfield>match.addr</structfield> selects the nth sub-device. This | 91 | <structfield>match.addr</structfield> selects the nth sub-device. This |
101 | allows you to enumerate over all sub-devices.</para> | 92 | allows you to enumerate over all sub-devices.</para> |
102 | 93 | ||
@@ -207,13 +198,8 @@ is set, then the driver supports reading registers from the device. If | |||
207 | <entry>Match the nth anciliary AC97 chip. Can't be used with this ioctl.</entry> | 198 | <entry>Match the nth anciliary AC97 chip. Can't be used with this ioctl.</entry> |
208 | </row> | 199 | </row> |
209 | <row> | 200 | <row> |
210 | <entry><constant>V4L2_CHIP_MATCH_SUBDEV_NAME</constant></entry> | 201 | <entry><constant>V4L2_CHIP_MATCH_SUBDEV</constant></entry> |
211 | <entry>4</entry> | 202 | <entry>4</entry> |
212 | <entry>Match the sub-device by name.</entry> | ||
213 | </row> | ||
214 | <row> | ||
215 | <entry><constant>V4L2_CHIP_MATCH_SUBDEV_IDX</constant></entry> | ||
216 | <entry>5</entry> | ||
217 | <entry>Match the nth sub-device.</entry> | 203 | <entry>Match the nth sub-device.</entry> |
218 | </row> | 204 | </row> |
219 | </tbody> | 205 | </tbody> |
diff --git a/Documentation/DocBook/media/v4l/vidioc-dbg-g-register.xml b/Documentation/DocBook/media/v4l/vidioc-dbg-g-register.xml index 3082b4149dbe..db7844f2439f 100644 --- a/Documentation/DocBook/media/v4l/vidioc-dbg-g-register.xml +++ b/Documentation/DocBook/media/v4l/vidioc-dbg-g-register.xml | |||
@@ -123,15 +123,7 @@ bus address.</para> | |||
123 | on the TV card.</para> | 123 | on the TV card.</para> |
124 | 124 | ||
125 | <para>When <structfield>match.type</structfield> is | 125 | <para>When <structfield>match.type</structfield> is |
126 | <constant>V4L2_CHIP_MATCH_SUBDEV_NAME</constant>, | 126 | <constant>V4L2_CHIP_MATCH_SUBDEV</constant>, |
127 | <structfield>match.name</structfield> contains the sub-device name. | ||
128 | For instance | ||
129 | <constant>"saa7127 6-0044"</constant> will match this specific saa7127 | ||
130 | sub-device. Again with the &VIDIOC-DBG-G-CHIP-NAME; ioctl you can find | ||
131 | out which sub-devices are present.</para> | ||
132 | |||
133 | <para>When <structfield>match.type</structfield> is | ||
134 | <constant>V4L2_CHIP_MATCH_SUBDEV_IDX</constant>, | ||
135 | <structfield>match.addr</structfield> selects the nth sub-device.</para> | 127 | <structfield>match.addr</structfield> selects the nth sub-device.</para> |
136 | 128 | ||
137 | <note> | 129 | <note> |
@@ -250,13 +242,8 @@ register.</entry> | |||
250 | <entry>Match the nth anciliary AC97 chip.</entry> | 242 | <entry>Match the nth anciliary AC97 chip.</entry> |
251 | </row> | 243 | </row> |
252 | <row> | 244 | <row> |
253 | <entry><constant>V4L2_CHIP_MATCH_SUBDEV_NAME</constant></entry> | 245 | <entry><constant>V4L2_CHIP_MATCH_SUBDEV</constant></entry> |
254 | <entry>4</entry> | 246 | <entry>4</entry> |
255 | <entry>Match the sub-device by name.</entry> | ||
256 | </row> | ||
257 | <row> | ||
258 | <entry><constant>V4L2_CHIP_MATCH_SUBDEV_IDX</constant></entry> | ||
259 | <entry>5</entry> | ||
260 | <entry>Match the nth sub-device.</entry> | 247 | <entry>Match the nth sub-device.</entry> |
261 | </row> | 248 | </row> |
262 | </tbody> | 249 | </tbody> |
diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c index f8fac9cefc3c..3fed63f4e026 100644 --- a/drivers/media/v4l2-core/v4l2-common.c +++ b/drivers/media/v4l2-core/v4l2-common.c | |||
@@ -254,8 +254,7 @@ int v4l2_chip_match_i2c_client(struct i2c_client *c, const struct v4l2_dbg_match | |||
254 | return len && !strncmp(c->driver->driver.name, match->name, len); | 254 | return len && !strncmp(c->driver->driver.name, match->name, len); |
255 | case V4L2_CHIP_MATCH_I2C_ADDR: | 255 | case V4L2_CHIP_MATCH_I2C_ADDR: |
256 | return c->addr == match->addr; | 256 | return c->addr == match->addr; |
257 | case V4L2_CHIP_MATCH_SUBDEV_IDX: | 257 | case V4L2_CHIP_MATCH_SUBDEV: |
258 | case V4L2_CHIP_MATCH_SUBDEV_NAME: | ||
259 | return 1; | 258 | return 1; |
260 | default: | 259 | default: |
261 | return 0; | 260 | return 0; |
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index feac07e50293..7a96162f544f 100644 --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c | |||
@@ -629,8 +629,7 @@ static void v4l_print_dbg_chip_ident(const void *arg, bool write_only) | |||
629 | const struct v4l2_dbg_chip_ident *p = arg; | 629 | const struct v4l2_dbg_chip_ident *p = arg; |
630 | 630 | ||
631 | pr_cont("type=%u, ", p->match.type); | 631 | pr_cont("type=%u, ", p->match.type); |
632 | if (p->match.type == V4L2_CHIP_MATCH_I2C_DRIVER || | 632 | if (p->match.type == V4L2_CHIP_MATCH_I2C_DRIVER) |
633 | p->match.type == V4L2_CHIP_MATCH_SUBDEV_NAME) | ||
634 | pr_cont("name=%.*s, ", | 633 | pr_cont("name=%.*s, ", |
635 | (int)sizeof(p->match.name), p->match.name); | 634 | (int)sizeof(p->match.name), p->match.name); |
636 | else | 635 | else |
@@ -644,8 +643,7 @@ static void v4l_print_dbg_chip_name(const void *arg, bool write_only) | |||
644 | const struct v4l2_dbg_chip_name *p = arg; | 643 | const struct v4l2_dbg_chip_name *p = arg; |
645 | 644 | ||
646 | pr_cont("type=%u, ", p->match.type); | 645 | pr_cont("type=%u, ", p->match.type); |
647 | if (p->match.type == V4L2_CHIP_MATCH_I2C_DRIVER || | 646 | if (p->match.type == V4L2_CHIP_MATCH_I2C_DRIVER) |
648 | p->match.type == V4L2_CHIP_MATCH_SUBDEV_NAME) | ||
649 | pr_cont("name=%.*s, ", | 647 | pr_cont("name=%.*s, ", |
650 | (int)sizeof(p->match.name), p->match.name); | 648 | (int)sizeof(p->match.name), p->match.name); |
651 | else | 649 | else |
@@ -658,8 +656,7 @@ static void v4l_print_dbg_register(const void *arg, bool write_only) | |||
658 | const struct v4l2_dbg_register *p = arg; | 656 | const struct v4l2_dbg_register *p = arg; |
659 | 657 | ||
660 | pr_cont("type=%u, ", p->match.type); | 658 | pr_cont("type=%u, ", p->match.type); |
661 | if (p->match.type == V4L2_CHIP_MATCH_I2C_DRIVER || | 659 | if (p->match.type == V4L2_CHIP_MATCH_I2C_DRIVER) |
662 | p->match.type == V4L2_CHIP_MATCH_SUBDEV_NAME) | ||
663 | pr_cont("name=%.*s, ", | 660 | pr_cont("name=%.*s, ", |
664 | (int)sizeof(p->match.name), p->match.name); | 661 | (int)sizeof(p->match.name), p->match.name); |
665 | else | 662 | else |
@@ -1791,14 +1788,6 @@ static int v4l_log_status(const struct v4l2_ioctl_ops *ops, | |||
1791 | return ret; | 1788 | return ret; |
1792 | } | 1789 | } |
1793 | 1790 | ||
1794 | static bool v4l_dbg_found_match(const struct v4l2_dbg_match *match, | ||
1795 | struct v4l2_subdev *sd, int idx) | ||
1796 | { | ||
1797 | if (match->type == V4L2_CHIP_MATCH_SUBDEV_IDX) | ||
1798 | return match->addr == idx; | ||
1799 | return !strcmp(match->name, sd->name); | ||
1800 | } | ||
1801 | |||
1802 | static int v4l_dbg_g_register(const struct v4l2_ioctl_ops *ops, | 1791 | static int v4l_dbg_g_register(const struct v4l2_ioctl_ops *ops, |
1803 | struct file *file, void *fh, void *arg) | 1792 | struct file *file, void *fh, void *arg) |
1804 | { | 1793 | { |
@@ -1810,14 +1799,12 @@ static int v4l_dbg_g_register(const struct v4l2_ioctl_ops *ops, | |||
1810 | 1799 | ||
1811 | if (!capable(CAP_SYS_ADMIN)) | 1800 | if (!capable(CAP_SYS_ADMIN)) |
1812 | return -EPERM; | 1801 | return -EPERM; |
1813 | if (p->match.type == V4L2_CHIP_MATCH_SUBDEV_IDX || | 1802 | if (p->match.type == V4L2_CHIP_MATCH_SUBDEV) { |
1814 | p->match.type == V4L2_CHIP_MATCH_SUBDEV_NAME) { | ||
1815 | if (vfd->v4l2_dev == NULL) | 1803 | if (vfd->v4l2_dev == NULL) |
1816 | return -EINVAL; | 1804 | return -EINVAL; |
1817 | v4l2_device_for_each_subdev(sd, vfd->v4l2_dev) { | 1805 | v4l2_device_for_each_subdev(sd, vfd->v4l2_dev) |
1818 | if (v4l_dbg_found_match(&p->match, sd, idx++)) | 1806 | if (p->match.addr == idx++) |
1819 | return v4l2_subdev_call(sd, core, g_register, p); | 1807 | return v4l2_subdev_call(sd, core, g_register, p); |
1820 | } | ||
1821 | return -EINVAL; | 1808 | return -EINVAL; |
1822 | } | 1809 | } |
1823 | if (ops->vidioc_g_register) | 1810 | if (ops->vidioc_g_register) |
@@ -1839,14 +1826,12 @@ static int v4l_dbg_s_register(const struct v4l2_ioctl_ops *ops, | |||
1839 | 1826 | ||
1840 | if (!capable(CAP_SYS_ADMIN)) | 1827 | if (!capable(CAP_SYS_ADMIN)) |
1841 | return -EPERM; | 1828 | return -EPERM; |
1842 | if (p->match.type == V4L2_CHIP_MATCH_SUBDEV_IDX || | 1829 | if (p->match.type == V4L2_CHIP_MATCH_SUBDEV) { |
1843 | p->match.type == V4L2_CHIP_MATCH_SUBDEV_NAME) { | ||
1844 | if (vfd->v4l2_dev == NULL) | 1830 | if (vfd->v4l2_dev == NULL) |
1845 | return -EINVAL; | 1831 | return -EINVAL; |
1846 | v4l2_device_for_each_subdev(sd, vfd->v4l2_dev) { | 1832 | v4l2_device_for_each_subdev(sd, vfd->v4l2_dev) |
1847 | if (v4l_dbg_found_match(&p->match, sd, idx++)) | 1833 | if (p->match.addr == idx++) |
1848 | return v4l2_subdev_call(sd, core, s_register, p); | 1834 | return v4l2_subdev_call(sd, core, s_register, p); |
1849 | } | ||
1850 | return -EINVAL; | 1835 | return -EINVAL; |
1851 | } | 1836 | } |
1852 | if (ops->vidioc_s_register) | 1837 | if (ops->vidioc_s_register) |
@@ -1864,8 +1849,7 @@ static int v4l_dbg_g_chip_ident(const struct v4l2_ioctl_ops *ops, | |||
1864 | 1849 | ||
1865 | p->ident = V4L2_IDENT_NONE; | 1850 | p->ident = V4L2_IDENT_NONE; |
1866 | p->revision = 0; | 1851 | p->revision = 0; |
1867 | if (p->match.type == V4L2_CHIP_MATCH_SUBDEV_NAME || | 1852 | if (p->match.type == V4L2_CHIP_MATCH_SUBDEV) |
1868 | p->match.type == V4L2_CHIP_MATCH_SUBDEV_IDX) | ||
1869 | return -EINVAL; | 1853 | return -EINVAL; |
1870 | return ops->vidioc_g_chip_ident(file, fh, p); | 1854 | return ops->vidioc_g_chip_ident(file, fh, p); |
1871 | } | 1855 | } |
@@ -1897,19 +1881,18 @@ static int v4l_dbg_g_chip_name(const struct v4l2_ioctl_ops *ops, | |||
1897 | strlcpy(p->name, "bridge", sizeof(p->name)); | 1881 | strlcpy(p->name, "bridge", sizeof(p->name)); |
1898 | return 0; | 1882 | return 0; |
1899 | 1883 | ||
1900 | case V4L2_CHIP_MATCH_SUBDEV_IDX: | 1884 | case V4L2_CHIP_MATCH_SUBDEV: |
1901 | case V4L2_CHIP_MATCH_SUBDEV_NAME: | ||
1902 | if (vfd->v4l2_dev == NULL) | 1885 | if (vfd->v4l2_dev == NULL) |
1903 | break; | 1886 | break; |
1904 | v4l2_device_for_each_subdev(sd, vfd->v4l2_dev) { | 1887 | v4l2_device_for_each_subdev(sd, vfd->v4l2_dev) { |
1905 | if (v4l_dbg_found_match(&p->match, sd, idx++)) { | 1888 | if (p->match.addr != idx++) |
1906 | if (sd->ops->core && sd->ops->core->s_register) | 1889 | continue; |
1907 | p->flags |= V4L2_CHIP_FL_WRITABLE; | 1890 | if (sd->ops->core && sd->ops->core->s_register) |
1908 | if (sd->ops->core && sd->ops->core->g_register) | 1891 | p->flags |= V4L2_CHIP_FL_WRITABLE; |
1909 | p->flags |= V4L2_CHIP_FL_READABLE; | 1892 | if (sd->ops->core && sd->ops->core->g_register) |
1910 | strlcpy(p->name, sd->name, sizeof(p->name)); | 1893 | p->flags |= V4L2_CHIP_FL_READABLE; |
1911 | return 0; | 1894 | strlcpy(p->name, sd->name, sizeof(p->name)); |
1912 | } | 1895 | return 0; |
1913 | } | 1896 | } |
1914 | break; | 1897 | break; |
1915 | } | 1898 | } |
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index e9c49c5e6416..4c941c103c44 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h | |||
@@ -1812,8 +1812,7 @@ struct v4l2_event_subscription { | |||
1812 | #define V4L2_CHIP_MATCH_I2C_DRIVER 1 /* Match against I2C driver name */ | 1812 | #define V4L2_CHIP_MATCH_I2C_DRIVER 1 /* Match against I2C driver name */ |
1813 | #define V4L2_CHIP_MATCH_I2C_ADDR 2 /* Match against I2C 7-bit address */ | 1813 | #define V4L2_CHIP_MATCH_I2C_ADDR 2 /* Match against I2C 7-bit address */ |
1814 | #define V4L2_CHIP_MATCH_AC97 3 /* Match against anciliary AC97 chip */ | 1814 | #define V4L2_CHIP_MATCH_AC97 3 /* Match against anciliary AC97 chip */ |
1815 | #define V4L2_CHIP_MATCH_SUBDEV_NAME 4 /* Match against subdev name */ | 1815 | #define V4L2_CHIP_MATCH_SUBDEV 4 /* Match against subdev index */ |
1816 | #define V4L2_CHIP_MATCH_SUBDEV_IDX 5 /* Match against subdev index */ | ||
1817 | 1816 | ||
1818 | struct v4l2_dbg_match { | 1817 | struct v4l2_dbg_match { |
1819 | __u32 type; /* Match type */ | 1818 | __u32 type; /* Match type */ |