Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Video for Linux Two |
| 3 | * |
| 4 | * A generic video device interface for the LINUX operating system |
| 5 | * using a set of device structures/vectors for low level operations. |
| 6 | * |
| 7 | * This file replaces the videodev.c file that comes with the |
| 8 | * regular kernel distribution. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or |
| 11 | * modify it under the terms of the GNU General Public License |
| 12 | * as published by the Free Software Foundation; either version |
| 13 | * 2 of the License, or (at your option) any later version. |
| 14 | * |
| 15 | * Author: Bill Dirks <bdirks@pacbell.net> |
| 16 | * based on code by Alan Cox, <alan@cymru.net> |
| 17 | * |
| 18 | */ |
| 19 | |
| 20 | /* |
| 21 | * Video capture interface for Linux |
| 22 | * |
| 23 | * A generic video device interface for the LINUX operating system |
| 24 | * using a set of device structures/vectors for low level operations. |
| 25 | * |
| 26 | * This program is free software; you can redistribute it and/or |
| 27 | * modify it under the terms of the GNU General Public License |
| 28 | * as published by the Free Software Foundation; either version |
| 29 | * 2 of the License, or (at your option) any later version. |
| 30 | * |
| 31 | * Author: Alan Cox, <alan@redhat.com> |
| 32 | * |
| 33 | * Fixes: |
| 34 | */ |
| 35 | |
| 36 | /* |
| 37 | * Video4linux 1/2 integration by Justin Schoeman |
| 38 | * <justin@suntiger.ee.up.ac.za> |
| 39 | * 2.4 PROCFS support ported from 2.4 kernels by |
| 40 | * Iñaki García Etxebarria <garetxe@euskalnet.net> |
| 41 | * Makefile fix by "W. Michael Petullo" <mike@flyn.org> |
| 42 | * 2.4 devfs support ported from 2.4 kernels by |
| 43 | * Dan Merillat <dan@merillat.org> |
| 44 | * Added Gerd Knorrs v4l1 enhancements (Justin Schoeman) |
| 45 | */ |
| 46 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | #include <linux/module.h> |
| 48 | #include <linux/types.h> |
| 49 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | #include <linux/smp_lock.h> |
| 51 | #include <linux/mm.h> |
| 52 | #include <linux/string.h> |
| 53 | #include <linux/errno.h> |
| 54 | #include <asm/uaccess.h> |
| 55 | #include <asm/system.h> |
| 56 | #include <asm/pgtable.h> |
| 57 | #include <asm/io.h> |
| 58 | #include <asm/div64.h> |
Michael Krufky | 5e453dc | 2006-01-09 15:32:31 -0200 | [diff] [blame] | 59 | #include <linux/video_decoder.h> |
Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 60 | #define __OLD_VIDIOC_ /* To allow fixing old calls*/ |
Michael Krufky | 5e453dc | 2006-01-09 15:32:31 -0200 | [diff] [blame] | 61 | #include <media/v4l2-common.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | |
| 63 | #ifdef CONFIG_KMOD |
| 64 | #include <linux/kmod.h> |
| 65 | #endif |
| 66 | |
| 67 | #if defined(CONFIG_UST) || defined(CONFIG_UST_MODULE) |
| 68 | #include <linux/ust.h> |
| 69 | #endif |
| 70 | |
| 71 | |
| 72 | #include <linux/videodev.h> |
| 73 | |
| 74 | MODULE_AUTHOR("Bill Dirks, Justin Schoeman, Gerd Knorr"); |
| 75 | MODULE_DESCRIPTION("misc helper functions for v4l2 device drivers"); |
| 76 | MODULE_LICENSE("GPL"); |
| 77 | |
| 78 | /* |
| 79 | * |
| 80 | * V 4 L 2 D R I V E R H E L P E R A P I |
| 81 | * |
| 82 | */ |
| 83 | |
| 84 | /* |
| 85 | * Video Standard Operations (contributed by Michael Schimek) |
| 86 | */ |
| 87 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | |
Mauro Carvalho Chehab | e75f9ce | 2006-11-20 13:19:20 -0300 | [diff] [blame] | 89 | char *v4l2_norm_to_name(v4l2_std_id id) |
| 90 | { |
| 91 | char *name; |
Mauro Carvalho Chehab | 412297d | 2007-01-07 08:51:05 -0300 | [diff] [blame] | 92 | u32 myid = id; |
Mauro Carvalho Chehab | e75f9ce | 2006-11-20 13:19:20 -0300 | [diff] [blame] | 93 | |
Mauro Carvalho Chehab | 412297d | 2007-01-07 08:51:05 -0300 | [diff] [blame] | 94 | /* HACK: ppc32 architecture doesn't have __ucmpdi2 function to handle |
| 95 | 64 bit comparations. So, on that architecture, with some gcc variants, |
| 96 | compilation fails. Currently, the max value is 30bit wide. |
| 97 | */ |
| 98 | BUG_ON(myid != id); |
| 99 | |
| 100 | switch (myid) { |
Mauro Carvalho Chehab | e75f9ce | 2006-11-20 13:19:20 -0300 | [diff] [blame] | 101 | case V4L2_STD_PAL: |
| 102 | name="PAL"; break; |
| 103 | case V4L2_STD_PAL_BG: |
| 104 | name="PAL-BG"; break; |
| 105 | case V4L2_STD_PAL_DK: |
| 106 | name="PAL-DK"; break; |
| 107 | case V4L2_STD_PAL_B: |
| 108 | name="PAL-B"; break; |
| 109 | case V4L2_STD_PAL_B1: |
| 110 | name="PAL-B1"; break; |
| 111 | case V4L2_STD_PAL_G: |
| 112 | name="PAL-G"; break; |
| 113 | case V4L2_STD_PAL_H: |
| 114 | name="PAL-H"; break; |
| 115 | case V4L2_STD_PAL_I: |
| 116 | name="PAL-I"; break; |
| 117 | case V4L2_STD_PAL_D: |
| 118 | name="PAL-D"; break; |
| 119 | case V4L2_STD_PAL_D1: |
| 120 | name="PAL-D1"; break; |
| 121 | case V4L2_STD_PAL_K: |
| 122 | name="PAL-K"; break; |
| 123 | case V4L2_STD_PAL_M: |
| 124 | name="PAL-M"; break; |
| 125 | case V4L2_STD_PAL_N: |
| 126 | name="PAL-N"; break; |
| 127 | case V4L2_STD_PAL_Nc: |
| 128 | name="PAL-Nc"; break; |
| 129 | case V4L2_STD_PAL_60: |
| 130 | name="PAL-60"; break; |
| 131 | case V4L2_STD_NTSC: |
| 132 | name="NTSC"; break; |
| 133 | case V4L2_STD_NTSC_M: |
| 134 | name="NTSC-M"; break; |
| 135 | case V4L2_STD_NTSC_M_JP: |
| 136 | name="NTSC-M-JP"; break; |
| 137 | case V4L2_STD_NTSC_443: |
| 138 | name="NTSC-443"; break; |
| 139 | case V4L2_STD_NTSC_M_KR: |
| 140 | name="NTSC-M-KR"; break; |
| 141 | case V4L2_STD_SECAM: |
| 142 | name="SECAM"; break; |
| 143 | case V4L2_STD_SECAM_DK: |
| 144 | name="SECAM-DK"; break; |
| 145 | case V4L2_STD_SECAM_B: |
| 146 | name="SECAM-B"; break; |
| 147 | case V4L2_STD_SECAM_D: |
| 148 | name="SECAM-D"; break; |
| 149 | case V4L2_STD_SECAM_G: |
| 150 | name="SECAM-G"; break; |
| 151 | case V4L2_STD_SECAM_H: |
| 152 | name="SECAM-H"; break; |
| 153 | case V4L2_STD_SECAM_K: |
| 154 | name="SECAM-K"; break; |
| 155 | case V4L2_STD_SECAM_K1: |
| 156 | name="SECAM-K1"; break; |
| 157 | case V4L2_STD_SECAM_L: |
| 158 | name="SECAM-L"; break; |
| 159 | case V4L2_STD_SECAM_LC: |
| 160 | name="SECAM-LC"; break; |
| 161 | default: |
| 162 | name="Unknown"; break; |
| 163 | } |
| 164 | |
| 165 | return name; |
| 166 | } |
| 167 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | /* Fill in the fields of a v4l2_standard structure according to the |
| 169 | 'id' and 'transmission' parameters. Returns negative on error. */ |
| 170 | int v4l2_video_std_construct(struct v4l2_standard *vs, |
| 171 | int id, char *name) |
| 172 | { |
| 173 | u32 index = vs->index; |
| 174 | |
| 175 | memset(vs, 0, sizeof(struct v4l2_standard)); |
| 176 | vs->index = index; |
| 177 | vs->id = id; |
Mauro Carvalho Chehab | 3ed33c3 | 2006-02-27 00:08:52 -0300 | [diff] [blame] | 178 | if (id & V4L2_STD_525_60) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | vs->frameperiod.numerator = 1001; |
| 180 | vs->frameperiod.denominator = 30000; |
| 181 | vs->framelines = 525; |
| 182 | } else { |
| 183 | vs->frameperiod.numerator = 1; |
| 184 | vs->frameperiod.denominator = 25; |
| 185 | vs->framelines = 625; |
| 186 | } |
| 187 | strlcpy(vs->name,name,sizeof(vs->name)); |
| 188 | return 0; |
| 189 | } |
| 190 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | /* ----------------------------------------------------------------- */ |
| 192 | /* priority handling */ |
| 193 | |
| 194 | #define V4L2_PRIO_VALID(val) (val == V4L2_PRIORITY_BACKGROUND || \ |
| 195 | val == V4L2_PRIORITY_INTERACTIVE || \ |
| 196 | val == V4L2_PRIORITY_RECORD) |
| 197 | |
| 198 | int v4l2_prio_init(struct v4l2_prio_state *global) |
| 199 | { |
| 200 | memset(global,0,sizeof(*global)); |
| 201 | return 0; |
| 202 | } |
| 203 | |
| 204 | int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local, |
| 205 | enum v4l2_priority new) |
| 206 | { |
| 207 | if (!V4L2_PRIO_VALID(new)) |
| 208 | return -EINVAL; |
| 209 | if (*local == new) |
| 210 | return 0; |
| 211 | |
| 212 | atomic_inc(&global->prios[new]); |
| 213 | if (V4L2_PRIO_VALID(*local)) |
| 214 | atomic_dec(&global->prios[*local]); |
| 215 | *local = new; |
| 216 | return 0; |
| 217 | } |
| 218 | |
| 219 | int v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local) |
| 220 | { |
| 221 | return v4l2_prio_change(global,local,V4L2_PRIORITY_DEFAULT); |
| 222 | } |
| 223 | |
| 224 | int v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority *local) |
| 225 | { |
| 226 | if (V4L2_PRIO_VALID(*local)) |
| 227 | atomic_dec(&global->prios[*local]); |
| 228 | return 0; |
| 229 | } |
| 230 | |
| 231 | enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global) |
| 232 | { |
| 233 | if (atomic_read(&global->prios[V4L2_PRIORITY_RECORD]) > 0) |
| 234 | return V4L2_PRIORITY_RECORD; |
| 235 | if (atomic_read(&global->prios[V4L2_PRIORITY_INTERACTIVE]) > 0) |
| 236 | return V4L2_PRIORITY_INTERACTIVE; |
| 237 | if (atomic_read(&global->prios[V4L2_PRIORITY_BACKGROUND]) > 0) |
| 238 | return V4L2_PRIORITY_BACKGROUND; |
| 239 | return V4L2_PRIORITY_UNSET; |
| 240 | } |
| 241 | |
| 242 | int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority *local) |
| 243 | { |
| 244 | if (*local < v4l2_prio_max(global)) |
| 245 | return -EBUSY; |
| 246 | return 0; |
| 247 | } |
| 248 | |
| 249 | |
| 250 | /* ----------------------------------------------------------------- */ |
Mauro Carvalho Chehab | 2e0d447 | 2006-02-27 00:08:58 -0300 | [diff] [blame] | 251 | /* some arrays for pretty-printing debug messages of enum types */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | |
| 253 | char *v4l2_field_names[] = { |
| 254 | [V4L2_FIELD_ANY] = "any", |
| 255 | [V4L2_FIELD_NONE] = "none", |
| 256 | [V4L2_FIELD_TOP] = "top", |
| 257 | [V4L2_FIELD_BOTTOM] = "bottom", |
| 258 | [V4L2_FIELD_INTERLACED] = "interlaced", |
| 259 | [V4L2_FIELD_SEQ_TB] = "seq-tb", |
| 260 | [V4L2_FIELD_SEQ_BT] = "seq-bt", |
| 261 | [V4L2_FIELD_ALTERNATE] = "alternate", |
| 262 | }; |
| 263 | |
| 264 | char *v4l2_type_names[] = { |
Mauro Carvalho Chehab | ed58014 | 2006-11-16 11:02:28 -0300 | [diff] [blame] | 265 | [V4L2_BUF_TYPE_VIDEO_CAPTURE] = "video-cap", |
| 266 | [V4L2_BUF_TYPE_VIDEO_OVERLAY] = "video-over", |
| 267 | [V4L2_BUF_TYPE_VIDEO_OUTPUT] = "video-out", |
| 268 | [V4L2_BUF_TYPE_VBI_CAPTURE] = "vbi-cap", |
| 269 | [V4L2_BUF_TYPE_VBI_OUTPUT] = "vbi-out", |
| 270 | [V4L2_BUF_TYPE_SLICED_VBI_CAPTURE] = "sliced-vbi-cap", |
| 271 | [V4L2_BUF_TYPE_SLICED_VBI_OUTPUT] = "slicec-vbi-out", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | }; |
| 273 | |
Mauro Carvalho Chehab | 2e0d447 | 2006-02-27 00:08:58 -0300 | [diff] [blame] | 274 | static char *v4l2_memory_names[] = { |
| 275 | [V4L2_MEMORY_MMAP] = "mmap", |
| 276 | [V4L2_MEMORY_USERPTR] = "userptr", |
| 277 | [V4L2_MEMORY_OVERLAY] = "overlay", |
| 278 | }; |
| 279 | |
| 280 | #define prt_names(a,arr) (((a)>=0)&&((a)<ARRAY_SIZE(arr)))?arr[a]:"unknown" |
| 281 | |
Michael Krufky | 5e453dc | 2006-01-09 15:32:31 -0200 | [diff] [blame] | 282 | /* ------------------------------------------------------------------ */ |
| 283 | /* debug help functions */ |
| 284 | |
Mauro Carvalho Chehab | 0dfa9ab | 2006-08-08 09:10:10 -0300 | [diff] [blame] | 285 | #ifdef CONFIG_VIDEO_V4L1_COMPAT |
Michael Krufky | 5e453dc | 2006-01-09 15:32:31 -0200 | [diff] [blame] | 286 | static const char *v4l1_ioctls[] = { |
| 287 | [_IOC_NR(VIDIOCGCAP)] = "VIDIOCGCAP", |
| 288 | [_IOC_NR(VIDIOCGCHAN)] = "VIDIOCGCHAN", |
| 289 | [_IOC_NR(VIDIOCSCHAN)] = "VIDIOCSCHAN", |
| 290 | [_IOC_NR(VIDIOCGTUNER)] = "VIDIOCGTUNER", |
| 291 | [_IOC_NR(VIDIOCSTUNER)] = "VIDIOCSTUNER", |
| 292 | [_IOC_NR(VIDIOCGPICT)] = "VIDIOCGPICT", |
| 293 | [_IOC_NR(VIDIOCSPICT)] = "VIDIOCSPICT", |
| 294 | [_IOC_NR(VIDIOCCAPTURE)] = "VIDIOCCAPTURE", |
| 295 | [_IOC_NR(VIDIOCGWIN)] = "VIDIOCGWIN", |
| 296 | [_IOC_NR(VIDIOCSWIN)] = "VIDIOCSWIN", |
| 297 | [_IOC_NR(VIDIOCGFBUF)] = "VIDIOCGFBUF", |
| 298 | [_IOC_NR(VIDIOCSFBUF)] = "VIDIOCSFBUF", |
| 299 | [_IOC_NR(VIDIOCKEY)] = "VIDIOCKEY", |
| 300 | [_IOC_NR(VIDIOCGFREQ)] = "VIDIOCGFREQ", |
| 301 | [_IOC_NR(VIDIOCSFREQ)] = "VIDIOCSFREQ", |
| 302 | [_IOC_NR(VIDIOCGAUDIO)] = "VIDIOCGAUDIO", |
| 303 | [_IOC_NR(VIDIOCSAUDIO)] = "VIDIOCSAUDIO", |
| 304 | [_IOC_NR(VIDIOCSYNC)] = "VIDIOCSYNC", |
| 305 | [_IOC_NR(VIDIOCMCAPTURE)] = "VIDIOCMCAPTURE", |
| 306 | [_IOC_NR(VIDIOCGMBUF)] = "VIDIOCGMBUF", |
| 307 | [_IOC_NR(VIDIOCGUNIT)] = "VIDIOCGUNIT", |
| 308 | [_IOC_NR(VIDIOCGCAPTURE)] = "VIDIOCGCAPTURE", |
| 309 | [_IOC_NR(VIDIOCSCAPTURE)] = "VIDIOCSCAPTURE", |
| 310 | [_IOC_NR(VIDIOCSPLAYMODE)] = "VIDIOCSPLAYMODE", |
| 311 | [_IOC_NR(VIDIOCSWRITEMODE)] = "VIDIOCSWRITEMODE", |
| 312 | [_IOC_NR(VIDIOCGPLAYINFO)] = "VIDIOCGPLAYINFO", |
| 313 | [_IOC_NR(VIDIOCSMICROCODE)] = "VIDIOCSMICROCODE", |
| 314 | [_IOC_NR(VIDIOCGVBIFMT)] = "VIDIOCGVBIFMT", |
| 315 | [_IOC_NR(VIDIOCSVBIFMT)] = "VIDIOCSVBIFMT" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | }; |
Michael Krufky | 5e453dc | 2006-01-09 15:32:31 -0200 | [diff] [blame] | 317 | #define V4L1_IOCTLS ARRAY_SIZE(v4l1_ioctls) |
| 318 | #endif |
| 319 | |
| 320 | static const char *v4l2_ioctls[] = { |
| 321 | [_IOC_NR(VIDIOC_QUERYCAP)] = "VIDIOC_QUERYCAP", |
| 322 | [_IOC_NR(VIDIOC_RESERVED)] = "VIDIOC_RESERVED", |
| 323 | [_IOC_NR(VIDIOC_ENUM_FMT)] = "VIDIOC_ENUM_FMT", |
| 324 | [_IOC_NR(VIDIOC_G_FMT)] = "VIDIOC_G_FMT", |
| 325 | [_IOC_NR(VIDIOC_S_FMT)] = "VIDIOC_S_FMT", |
| 326 | [_IOC_NR(VIDIOC_G_MPEGCOMP)] = "VIDIOC_G_MPEGCOMP", |
| 327 | [_IOC_NR(VIDIOC_S_MPEGCOMP)] = "VIDIOC_S_MPEGCOMP", |
| 328 | [_IOC_NR(VIDIOC_REQBUFS)] = "VIDIOC_REQBUFS", |
| 329 | [_IOC_NR(VIDIOC_QUERYBUF)] = "VIDIOC_QUERYBUF", |
| 330 | [_IOC_NR(VIDIOC_G_FBUF)] = "VIDIOC_G_FBUF", |
| 331 | [_IOC_NR(VIDIOC_S_FBUF)] = "VIDIOC_S_FBUF", |
| 332 | [_IOC_NR(VIDIOC_OVERLAY)] = "VIDIOC_OVERLAY", |
| 333 | [_IOC_NR(VIDIOC_QBUF)] = "VIDIOC_QBUF", |
| 334 | [_IOC_NR(VIDIOC_DQBUF)] = "VIDIOC_DQBUF", |
| 335 | [_IOC_NR(VIDIOC_STREAMON)] = "VIDIOC_STREAMON", |
| 336 | [_IOC_NR(VIDIOC_STREAMOFF)] = "VIDIOC_STREAMOFF", |
| 337 | [_IOC_NR(VIDIOC_G_PARM)] = "VIDIOC_G_PARM", |
| 338 | [_IOC_NR(VIDIOC_S_PARM)] = "VIDIOC_S_PARM", |
| 339 | [_IOC_NR(VIDIOC_G_STD)] = "VIDIOC_G_STD", |
| 340 | [_IOC_NR(VIDIOC_S_STD)] = "VIDIOC_S_STD", |
| 341 | [_IOC_NR(VIDIOC_ENUMSTD)] = "VIDIOC_ENUMSTD", |
| 342 | [_IOC_NR(VIDIOC_ENUMINPUT)] = "VIDIOC_ENUMINPUT", |
| 343 | [_IOC_NR(VIDIOC_G_CTRL)] = "VIDIOC_G_CTRL", |
| 344 | [_IOC_NR(VIDIOC_S_CTRL)] = "VIDIOC_S_CTRL", |
| 345 | [_IOC_NR(VIDIOC_G_TUNER)] = "VIDIOC_G_TUNER", |
| 346 | [_IOC_NR(VIDIOC_S_TUNER)] = "VIDIOC_S_TUNER", |
| 347 | [_IOC_NR(VIDIOC_G_AUDIO)] = "VIDIOC_G_AUDIO", |
| 348 | [_IOC_NR(VIDIOC_S_AUDIO)] = "VIDIOC_S_AUDIO", |
| 349 | [_IOC_NR(VIDIOC_QUERYCTRL)] = "VIDIOC_QUERYCTRL", |
| 350 | [_IOC_NR(VIDIOC_QUERYMENU)] = "VIDIOC_QUERYMENU", |
| 351 | [_IOC_NR(VIDIOC_G_INPUT)] = "VIDIOC_G_INPUT", |
| 352 | [_IOC_NR(VIDIOC_S_INPUT)] = "VIDIOC_S_INPUT", |
| 353 | [_IOC_NR(VIDIOC_G_OUTPUT)] = "VIDIOC_G_OUTPUT", |
| 354 | [_IOC_NR(VIDIOC_S_OUTPUT)] = "VIDIOC_S_OUTPUT", |
| 355 | [_IOC_NR(VIDIOC_ENUMOUTPUT)] = "VIDIOC_ENUMOUTPUT", |
| 356 | [_IOC_NR(VIDIOC_G_AUDOUT)] = "VIDIOC_G_AUDOUT", |
| 357 | [_IOC_NR(VIDIOC_S_AUDOUT)] = "VIDIOC_S_AUDOUT", |
| 358 | [_IOC_NR(VIDIOC_G_MODULATOR)] = "VIDIOC_G_MODULATOR", |
| 359 | [_IOC_NR(VIDIOC_S_MODULATOR)] = "VIDIOC_S_MODULATOR", |
| 360 | [_IOC_NR(VIDIOC_G_FREQUENCY)] = "VIDIOC_G_FREQUENCY", |
| 361 | [_IOC_NR(VIDIOC_S_FREQUENCY)] = "VIDIOC_S_FREQUENCY", |
| 362 | [_IOC_NR(VIDIOC_CROPCAP)] = "VIDIOC_CROPCAP", |
| 363 | [_IOC_NR(VIDIOC_G_CROP)] = "VIDIOC_G_CROP", |
| 364 | [_IOC_NR(VIDIOC_S_CROP)] = "VIDIOC_S_CROP", |
| 365 | [_IOC_NR(VIDIOC_G_JPEGCOMP)] = "VIDIOC_G_JPEGCOMP", |
| 366 | [_IOC_NR(VIDIOC_S_JPEGCOMP)] = "VIDIOC_S_JPEGCOMP", |
| 367 | [_IOC_NR(VIDIOC_QUERYSTD)] = "VIDIOC_QUERYSTD", |
| 368 | [_IOC_NR(VIDIOC_TRY_FMT)] = "VIDIOC_TRY_FMT", |
| 369 | [_IOC_NR(VIDIOC_ENUMAUDIO)] = "VIDIOC_ENUMAUDIO", |
| 370 | [_IOC_NR(VIDIOC_ENUMAUDOUT)] = "VIDIOC_ENUMAUDOUT", |
| 371 | [_IOC_NR(VIDIOC_G_PRIORITY)] = "VIDIOC_G_PRIORITY", |
| 372 | [_IOC_NR(VIDIOC_S_PRIORITY)] = "VIDIOC_S_PRIORITY", |
| 373 | #if 1 |
| 374 | [_IOC_NR(VIDIOC_G_SLICED_VBI_CAP)] = "VIDIOC_G_SLICED_VBI_CAP", |
| 375 | #endif |
Hans Verkuil | 9cb2318 | 2006-06-18 14:11:08 -0300 | [diff] [blame] | 376 | [_IOC_NR(VIDIOC_LOG_STATUS)] = "VIDIOC_LOG_STATUS", |
| 377 | [_IOC_NR(VIDIOC_G_EXT_CTRLS)] = "VIDIOC_G_EXT_CTRLS", |
| 378 | [_IOC_NR(VIDIOC_S_EXT_CTRLS)] = "VIDIOC_S_EXT_CTRLS", |
| 379 | [_IOC_NR(VIDIOC_TRY_EXT_CTRLS)] = "VIDIOC_TRY_EXT_CTRLS" |
Michael Krufky | 5e453dc | 2006-01-09 15:32:31 -0200 | [diff] [blame] | 380 | }; |
| 381 | #define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls) |
| 382 | |
| 383 | static const char *v4l2_int_ioctls[] = { |
Mauro Carvalho Chehab | 0dfa9ab | 2006-08-08 09:10:10 -0300 | [diff] [blame] | 384 | #ifdef CONFIG_VIDEO_V4L1_COMPAT |
Michael Krufky | 5e453dc | 2006-01-09 15:32:31 -0200 | [diff] [blame] | 385 | [_IOC_NR(DECODER_GET_CAPABILITIES)] = "DECODER_GET_CAPABILITIES", |
| 386 | [_IOC_NR(DECODER_GET_STATUS)] = "DECODER_GET_STATUS", |
| 387 | [_IOC_NR(DECODER_SET_NORM)] = "DECODER_SET_NORM", |
| 388 | [_IOC_NR(DECODER_SET_INPUT)] = "DECODER_SET_INPUT", |
| 389 | [_IOC_NR(DECODER_SET_OUTPUT)] = "DECODER_SET_OUTPUT", |
| 390 | [_IOC_NR(DECODER_ENABLE_OUTPUT)] = "DECODER_ENABLE_OUTPUT", |
| 391 | [_IOC_NR(DECODER_SET_PICTURE)] = "DECODER_SET_PICTURE", |
| 392 | [_IOC_NR(DECODER_SET_GPIO)] = "DECODER_SET_GPIO", |
| 393 | [_IOC_NR(DECODER_INIT)] = "DECODER_INIT", |
| 394 | [_IOC_NR(DECODER_SET_VBI_BYPASS)] = "DECODER_SET_VBI_BYPASS", |
| 395 | [_IOC_NR(DECODER_DUMP)] = "DECODER_DUMP", |
| 396 | #endif |
| 397 | [_IOC_NR(AUDC_SET_RADIO)] = "AUDC_SET_RADIO", |
Michael Krufky | 5e453dc | 2006-01-09 15:32:31 -0200 | [diff] [blame] | 398 | |
| 399 | [_IOC_NR(TUNER_SET_TYPE_ADDR)] = "TUNER_SET_TYPE_ADDR", |
| 400 | [_IOC_NR(TUNER_SET_STANDBY)] = "TUNER_SET_STANDBY", |
| 401 | [_IOC_NR(TDA9887_SET_CONFIG)] = "TDA9887_SET_CONFIG", |
| 402 | |
Hans Verkuil | 3bbe5a8 | 2006-04-01 15:27:52 -0300 | [diff] [blame] | 403 | [_IOC_NR(VIDIOC_INT_S_TUNER_MODE)] = "VIDIOC_INT_S_TUNER_MODE", |
Michael Krufky | 5e453dc | 2006-01-09 15:32:31 -0200 | [diff] [blame] | 404 | [_IOC_NR(VIDIOC_INT_S_REGISTER)] = "VIDIOC_INT_S_REGISTER", |
| 405 | [_IOC_NR(VIDIOC_INT_G_REGISTER)] = "VIDIOC_INT_G_REGISTER", |
| 406 | [_IOC_NR(VIDIOC_INT_RESET)] = "VIDIOC_INT_RESET", |
| 407 | [_IOC_NR(VIDIOC_INT_AUDIO_CLOCK_FREQ)] = "VIDIOC_INT_AUDIO_CLOCK_FREQ", |
| 408 | [_IOC_NR(VIDIOC_INT_DECODE_VBI_LINE)] = "VIDIOC_INT_DECODE_VBI_LINE", |
| 409 | [_IOC_NR(VIDIOC_INT_S_VBI_DATA)] = "VIDIOC_INT_S_VBI_DATA", |
| 410 | [_IOC_NR(VIDIOC_INT_G_VBI_DATA)] = "VIDIOC_INT_G_VBI_DATA", |
| 411 | [_IOC_NR(VIDIOC_INT_G_CHIP_IDENT)] = "VIDIOC_INT_G_CHIP_IDENT", |
Hans Verkuil | 3bbe5a8 | 2006-04-01 15:27:52 -0300 | [diff] [blame] | 412 | [_IOC_NR(VIDIOC_INT_I2S_CLOCK_FREQ)] = "VIDIOC_INT_I2S_CLOCK_FREQ", |
| 413 | [_IOC_NR(VIDIOC_INT_S_STANDBY)] = "VIDIOC_INT_S_STANDBY", |
| 414 | [_IOC_NR(VIDIOC_INT_S_AUDIO_ROUTING)] = "VIDIOC_INT_S_AUDIO_ROUTING", |
| 415 | [_IOC_NR(VIDIOC_INT_G_AUDIO_ROUTING)] = "VIDIOC_INT_G_AUDIO_ROUTING", |
| 416 | [_IOC_NR(VIDIOC_INT_S_VIDEO_ROUTING)] = "VIDIOC_INT_S_VIDEO_ROUTING", |
Hans Verkuil | b7f8292 | 2006-04-02 12:50:42 -0300 | [diff] [blame] | 417 | [_IOC_NR(VIDIOC_INT_G_VIDEO_ROUTING)] = "VIDIOC_INT_G_VIDEO_ROUTING", |
| 418 | [_IOC_NR(VIDIOC_INT_S_CRYSTAL_FREQ)] = "VIDIOC_INT_S_CRYSTAL_FREQ" |
Michael Krufky | 5e453dc | 2006-01-09 15:32:31 -0200 | [diff] [blame] | 419 | }; |
| 420 | #define V4L2_INT_IOCTLS ARRAY_SIZE(v4l2_int_ioctls) |
| 421 | |
Mauro Carvalho Chehab | 0bbb9c1 | 2006-02-27 00:08:55 -0300 | [diff] [blame] | 422 | static void v4l_print_pix_fmt (char *s, struct v4l2_pix_format *fmt) |
| 423 | { |
| 424 | printk ("%s: width=%d, height=%d, format=%d, field=%s, " |
| 425 | "bytesperline=%d sizeimage=%d, colorspace=%d\n", s, |
| 426 | fmt->width,fmt->height,fmt->pixelformat, |
Mauro Carvalho Chehab | 2e0d447 | 2006-02-27 00:08:58 -0300 | [diff] [blame] | 427 | prt_names(fmt->field,v4l2_field_names), |
Mauro Carvalho Chehab | 0bbb9c1 | 2006-02-27 00:08:55 -0300 | [diff] [blame] | 428 | fmt->bytesperline,fmt->sizeimage,fmt->colorspace); |
| 429 | }; |
| 430 | |
Michael Krufky | 5e453dc | 2006-01-09 15:32:31 -0200 | [diff] [blame] | 431 | /* Common ioctl debug function. This function can be used by |
| 432 | external ioctl messages as well as internal V4L ioctl */ |
| 433 | void v4l_printk_ioctl(unsigned int cmd) |
| 434 | { |
| 435 | char *dir; |
| 436 | |
| 437 | switch (_IOC_DIR(cmd)) { |
| 438 | case _IOC_NONE: dir = "--"; break; |
| 439 | case _IOC_READ: dir = "r-"; break; |
| 440 | case _IOC_WRITE: dir = "-w"; break; |
| 441 | case _IOC_READ | _IOC_WRITE: dir = "rw"; break; |
| 442 | default: dir = "*ERR*"; break; |
| 443 | } |
| 444 | switch (_IOC_TYPE(cmd)) { |
| 445 | case 'd': |
| 446 | printk("v4l2_int ioctl %s, dir=%s (0x%08x)\n", |
| 447 | (_IOC_NR(cmd) < V4L2_INT_IOCTLS) ? |
| 448 | v4l2_int_ioctls[_IOC_NR(cmd)] : "UNKNOWN", dir, cmd); |
| 449 | break; |
Mauro Carvalho Chehab | 0dfa9ab | 2006-08-08 09:10:10 -0300 | [diff] [blame] | 450 | #ifdef CONFIG_VIDEO_V4L1_COMPAT |
Michael Krufky | 5e453dc | 2006-01-09 15:32:31 -0200 | [diff] [blame] | 451 | case 'v': |
| 452 | printk("v4l1 ioctl %s, dir=%s (0x%08x)\n", |
| 453 | (_IOC_NR(cmd) < V4L1_IOCTLS) ? |
| 454 | v4l1_ioctls[_IOC_NR(cmd)] : "UNKNOWN", dir, cmd); |
| 455 | break; |
| 456 | #endif |
| 457 | case 'V': |
| 458 | printk("v4l2 ioctl %s, dir=%s (0x%08x)\n", |
| 459 | (_IOC_NR(cmd) < V4L2_IOCTLS) ? |
| 460 | v4l2_ioctls[_IOC_NR(cmd)] : "UNKNOWN", dir, cmd); |
| 461 | break; |
| 462 | |
| 463 | default: |
| 464 | printk("unknown ioctl '%c', dir=%s, #%d (0x%08x)\n", |
| 465 | _IOC_TYPE(cmd), dir, _IOC_NR(cmd), cmd); |
| 466 | } |
| 467 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 469 | /* Common ioctl debug function. This function can be used by |
| 470 | external ioctl messages as well as internal V4L ioctl and its |
| 471 | arguments */ |
| 472 | void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg) |
| 473 | { |
| 474 | printk(s); |
| 475 | printk(": "); |
| 476 | v4l_printk_ioctl(cmd); |
| 477 | switch (cmd) { |
| 478 | case VIDIOC_INT_G_CHIP_IDENT: |
| 479 | { |
| 480 | enum v4l2_chip_ident *p=arg; |
| 481 | printk ("%s: chip ident=%d\n", s, *p); |
| 482 | break; |
| 483 | } |
| 484 | case VIDIOC_G_PRIORITY: |
| 485 | case VIDIOC_S_PRIORITY: |
| 486 | { |
| 487 | enum v4l2_priority *p=arg; |
| 488 | printk ("%s: priority=%d\n", s, *p); |
| 489 | break; |
| 490 | } |
| 491 | case VIDIOC_INT_S_TUNER_MODE: |
| 492 | { |
| 493 | enum v4l2_tuner_type *p=arg; |
| 494 | printk ("%s: tuner type=%d\n", s, *p); |
| 495 | break; |
| 496 | } |
Mauro Carvalho Chehab | 985bc96 | 2006-07-23 06:31:19 -0300 | [diff] [blame] | 497 | #ifdef CONFIG_VIDEO_V4L1_COMPAT |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 498 | case DECODER_SET_VBI_BYPASS: |
| 499 | case DECODER_ENABLE_OUTPUT: |
| 500 | case DECODER_GET_STATUS: |
| 501 | case DECODER_SET_OUTPUT: |
| 502 | case DECODER_SET_INPUT: |
| 503 | case DECODER_SET_GPIO: |
| 504 | case DECODER_SET_NORM: |
| 505 | case VIDIOCCAPTURE: |
| 506 | case VIDIOCSYNC: |
| 507 | case VIDIOCSWRITEMODE: |
Mauro Carvalho Chehab | 985bc96 | 2006-07-23 06:31:19 -0300 | [diff] [blame] | 508 | #endif |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 509 | case TUNER_SET_TYPE_ADDR: |
| 510 | case TUNER_SET_STANDBY: |
| 511 | case TDA9887_SET_CONFIG: |
Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 512 | #ifdef __OLD_VIDIOC_ |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 513 | case VIDIOC_OVERLAY_OLD: |
Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 514 | #endif |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 515 | case VIDIOC_STREAMOFF: |
| 516 | case VIDIOC_G_OUTPUT: |
| 517 | case VIDIOC_S_OUTPUT: |
| 518 | case VIDIOC_STREAMON: |
| 519 | case VIDIOC_G_INPUT: |
| 520 | case VIDIOC_OVERLAY: |
| 521 | case VIDIOC_S_INPUT: |
| 522 | { |
| 523 | int *p=arg; |
| 524 | printk ("%s: value=%d\n", s, *p); |
| 525 | break; |
| 526 | } |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 527 | case VIDIOC_G_AUDIO: |
| 528 | case VIDIOC_S_AUDIO: |
| 529 | case VIDIOC_ENUMAUDIO: |
Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 530 | #ifdef __OLD_VIDIOC_ |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 531 | case VIDIOC_G_AUDIO_OLD: |
Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 532 | #endif |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 533 | { |
| 534 | struct v4l2_audio *p=arg; |
| 535 | |
| 536 | printk ("%s: index=%d, name=%s, capability=%d, mode=%d\n", |
| 537 | s,p->index, p->name,p->capability, p->mode); |
| 538 | break; |
| 539 | } |
| 540 | case VIDIOC_G_AUDOUT: |
| 541 | case VIDIOC_S_AUDOUT: |
| 542 | case VIDIOC_ENUMAUDOUT: |
Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 543 | #ifdef __OLD_VIDIOC_ |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 544 | case VIDIOC_G_AUDOUT_OLD: |
Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 545 | #endif |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 546 | { |
| 547 | struct v4l2_audioout *p=arg; |
| 548 | printk ("%s: index=%d, name=%s, capability=%d, mode=%d\n", s, |
| 549 | p->index, p->name, p->capability,p->mode); |
| 550 | break; |
| 551 | } |
| 552 | case VIDIOC_QBUF: |
| 553 | case VIDIOC_DQBUF: |
| 554 | case VIDIOC_QUERYBUF: |
| 555 | { |
| 556 | struct v4l2_buffer *p=arg; |
| 557 | struct v4l2_timecode *tc=&p->timecode; |
Mauro Carvalho Chehab | 0bbb9c1 | 2006-02-27 00:08:55 -0300 | [diff] [blame] | 558 | printk ("%s: %02ld:%02d:%02d.%08ld index=%d, type=%s, " |
Hans Verkuil | 2474ed4 | 2006-03-19 12:35:57 -0300 | [diff] [blame] | 559 | "bytesused=%d, flags=0x%08x, " |
Mauro Carvalho Chehab | 2e0d447 | 2006-02-27 00:08:58 -0300 | [diff] [blame] | 560 | "field=%0d, sequence=%d, memory=%s, offset/userptr=0x%08lx\n", |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 561 | s, |
| 562 | (p->timestamp.tv_sec/3600), |
| 563 | (int)(p->timestamp.tv_sec/60)%60, |
| 564 | (int)(p->timestamp.tv_sec%60), |
| 565 | p->timestamp.tv_usec, |
Mauro Carvalho Chehab | 0bbb9c1 | 2006-02-27 00:08:55 -0300 | [diff] [blame] | 566 | p->index, |
Mauro Carvalho Chehab | 2e0d447 | 2006-02-27 00:08:58 -0300 | [diff] [blame] | 567 | prt_names(p->type,v4l2_type_names), |
Mauro Carvalho Chehab | 0bbb9c1 | 2006-02-27 00:08:55 -0300 | [diff] [blame] | 568 | p->bytesused,p->flags, |
Mauro Carvalho Chehab | 2e0d447 | 2006-02-27 00:08:58 -0300 | [diff] [blame] | 569 | p->field,p->sequence, |
| 570 | prt_names(p->memory,v4l2_memory_names), |
| 571 | p->m.userptr); |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 572 | printk ("%s: timecode= %02d:%02d:%02d type=%d, " |
Mauro Carvalho Chehab | c18cb01 | 2006-06-23 07:05:22 -0300 | [diff] [blame] | 573 | "flags=0x%08x, frames=%d, userbits=0x%08x\n", |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 574 | s,tc->hours,tc->minutes,tc->seconds, |
Mauro Carvalho Chehab | c18cb01 | 2006-06-23 07:05:22 -0300 | [diff] [blame] | 575 | tc->type, tc->flags, tc->frames, *(__u32 *) tc->userbits); |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 576 | break; |
| 577 | } |
| 578 | case VIDIOC_QUERYCAP: |
| 579 | { |
| 580 | struct v4l2_capability *p=arg; |
Mauro Carvalho Chehab | c7b0ac0 | 2006-03-10 12:29:15 -0300 | [diff] [blame] | 581 | printk ("%s: driver=%s, card=%s, bus=%s, version=0x%08x, " |
| 582 | "capabilities=0x%08x\n", s, |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 583 | p->driver,p->card,p->bus_info, |
| 584 | p->version, |
| 585 | p->capabilities); |
| 586 | break; |
| 587 | } |
| 588 | case VIDIOC_G_CTRL: |
| 589 | case VIDIOC_S_CTRL: |
Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 590 | #ifdef __OLD_VIDIOC_ |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 591 | case VIDIOC_S_CTRL_OLD: |
Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 592 | #endif |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 593 | { |
| 594 | struct v4l2_control *p=arg; |
| 595 | printk ("%s: id=%d, value=%d\n", s, p->id, p->value); |
| 596 | break; |
| 597 | } |
Hans Verkuil | 9cb2318 | 2006-06-18 14:11:08 -0300 | [diff] [blame] | 598 | case VIDIOC_G_EXT_CTRLS: |
| 599 | case VIDIOC_S_EXT_CTRLS: |
| 600 | case VIDIOC_TRY_EXT_CTRLS: |
| 601 | { |
| 602 | struct v4l2_ext_controls *p = arg; |
| 603 | int i; |
| 604 | |
| 605 | printk("%s: ctrl_class=%d, count=%d\n", s, p->ctrl_class, p->count); |
| 606 | for (i = 0; i < p->count; i++) { |
| 607 | struct v4l2_ext_control *c = &p->controls[i]; |
| 608 | if (cmd == VIDIOC_G_EXT_CTRLS) |
| 609 | printk("%s: id=%d\n", s, c->id); |
| 610 | else |
| 611 | printk("%s: id=%d, value=%d\n", s, c->id, c->value); |
| 612 | } |
| 613 | break; |
| 614 | } |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 615 | case VIDIOC_G_CROP: |
| 616 | case VIDIOC_S_CROP: |
| 617 | { |
| 618 | struct v4l2_crop *p=arg; |
| 619 | /*FIXME: Should also show rect structs */ |
| 620 | printk ("%s: type=%d\n", s, p->type); |
| 621 | break; |
| 622 | } |
| 623 | case VIDIOC_CROPCAP: |
Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 624 | #ifdef __OLD_VIDIOC_ |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 625 | case VIDIOC_CROPCAP_OLD: |
Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 626 | #endif |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 627 | { |
| 628 | struct v4l2_cropcap *p=arg; |
| 629 | /*FIXME: Should also show rect structs */ |
| 630 | printk ("%s: type=%d\n", s, p->type); |
| 631 | break; |
| 632 | } |
| 633 | case VIDIOC_INT_DECODE_VBI_LINE: |
| 634 | { |
| 635 | struct v4l2_decode_vbi_line *p=arg; |
| 636 | printk ("%s: is_second_field=%d, ptr=0x%08lx, line=%d, " |
| 637 | "type=%d\n", s, |
| 638 | p->is_second_field,(unsigned long)p->p,p->line,p->type); |
| 639 | break; |
| 640 | } |
| 641 | case VIDIOC_ENUM_FMT: |
| 642 | { |
| 643 | struct v4l2_fmtdesc *p=arg; |
| 644 | printk ("%s: index=%d, type=%d, flags=%d, description=%s," |
| 645 | " pixelformat=%d\n", s, |
| 646 | p->index, p->type, p->flags,p->description, |
| 647 | p->pixelformat); |
| 648 | |
| 649 | break; |
| 650 | } |
| 651 | case VIDIOC_G_FMT: |
| 652 | case VIDIOC_S_FMT: |
| 653 | case VIDIOC_TRY_FMT: |
| 654 | { |
| 655 | struct v4l2_format *p=arg; |
Mauro Carvalho Chehab | 0bbb9c1 | 2006-02-27 00:08:55 -0300 | [diff] [blame] | 656 | printk ("%s: type=%s\n", s, |
Mauro Carvalho Chehab | 2e0d447 | 2006-02-27 00:08:58 -0300 | [diff] [blame] | 657 | prt_names(p->type,v4l2_type_names)); |
Mauro Carvalho Chehab | 0bbb9c1 | 2006-02-27 00:08:55 -0300 | [diff] [blame] | 658 | switch (p->type) { |
| 659 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
| 660 | v4l_print_pix_fmt (s, &p->fmt.pix); |
| 661 | break; |
| 662 | default: |
| 663 | break; |
| 664 | } |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 665 | } |
| 666 | case VIDIOC_G_FBUF: |
| 667 | case VIDIOC_S_FBUF: |
| 668 | { |
| 669 | struct v4l2_framebuffer *p=arg; |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 670 | printk ("%s: capability=%d, flags=%d, base=0x%08lx\n", s, |
| 671 | p->capability,p->flags, (unsigned long)p->base); |
Mauro Carvalho Chehab | 0bbb9c1 | 2006-02-27 00:08:55 -0300 | [diff] [blame] | 672 | v4l_print_pix_fmt (s, &p->fmt); |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 673 | break; |
| 674 | } |
| 675 | case VIDIOC_G_FREQUENCY: |
| 676 | case VIDIOC_S_FREQUENCY: |
| 677 | { |
| 678 | struct v4l2_frequency *p=arg; |
| 679 | printk ("%s: tuner=%d, type=%d, frequency=%d\n", s, |
| 680 | p->tuner,p->type,p->frequency); |
| 681 | break; |
| 682 | } |
| 683 | case VIDIOC_ENUMINPUT: |
| 684 | { |
| 685 | struct v4l2_input *p=arg; |
| 686 | printk ("%s: index=%d, name=%s, type=%d, audioset=%d, " |
Andrew Morton | 5245953 | 2006-03-22 15:01:59 -0300 | [diff] [blame] | 687 | "tuner=%d, std=%Ld, status=%d\n", s, |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 688 | p->index,p->name,p->type,p->audioset, |
Andrew Morton | 5245953 | 2006-03-22 15:01:59 -0300 | [diff] [blame] | 689 | p->tuner, |
| 690 | (unsigned long long)p->std, |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 691 | p->status); |
| 692 | break; |
| 693 | } |
| 694 | case VIDIOC_G_JPEGCOMP: |
| 695 | case VIDIOC_S_JPEGCOMP: |
| 696 | { |
| 697 | struct v4l2_jpegcompression *p=arg; |
| 698 | printk ("%s: quality=%d, APPn=%d, APP_len=%d, COM_len=%d," |
| 699 | " jpeg_markers=%d\n", s, |
| 700 | p->quality,p->APPn,p->APP_len, |
| 701 | p->COM_len,p->jpeg_markers); |
| 702 | break; |
| 703 | } |
| 704 | case VIDIOC_G_MODULATOR: |
| 705 | case VIDIOC_S_MODULATOR: |
| 706 | { |
| 707 | struct v4l2_modulator *p=arg; |
| 708 | printk ("%s: index=%d, name=%s, capability=%d, rangelow=%d," |
| 709 | " rangehigh=%d, txsubchans=%d\n", s, |
| 710 | p->index, p->name,p->capability,p->rangelow, |
| 711 | p->rangehigh,p->txsubchans); |
| 712 | break; |
| 713 | } |
| 714 | case VIDIOC_G_MPEGCOMP: |
| 715 | case VIDIOC_S_MPEGCOMP: |
| 716 | { |
| 717 | struct v4l2_mpeg_compression *p=arg; |
| 718 | /*FIXME: Several fields not shown */ |
| 719 | printk ("%s: ts_pid_pmt=%d, ts_pid_audio=%d, ts_pid_video=%d, " |
| 720 | "ts_pid_pcr=%d, ps_size=%d, au_sample_rate=%d, " |
| 721 | "au_pesid=%c, vi_frame_rate=%d, vi_frames_per_gop=%d, " |
| 722 | "vi_bframes_count=%d, vi_pesid=%c\n", s, |
| 723 | p->ts_pid_pmt,p->ts_pid_audio, p->ts_pid_video, |
| 724 | p->ts_pid_pcr, p->ps_size, p->au_sample_rate, |
| 725 | p->au_pesid, p->vi_frame_rate, |
| 726 | p->vi_frames_per_gop, p->vi_bframes_count, |
| 727 | p->vi_pesid); |
| 728 | break; |
| 729 | } |
| 730 | case VIDIOC_ENUMOUTPUT: |
| 731 | { |
| 732 | struct v4l2_output *p=arg; |
| 733 | printk ("%s: index=%d, name=%s,type=%d, audioset=%d, " |
Andrew Morton | 5245953 | 2006-03-22 15:01:59 -0300 | [diff] [blame] | 734 | "modulator=%d, std=%Ld\n", |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 735 | s,p->index,p->name,p->type,p->audioset, |
Andrew Morton | 5245953 | 2006-03-22 15:01:59 -0300 | [diff] [blame] | 736 | p->modulator, |
| 737 | (unsigned long long)p->std); |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 738 | break; |
| 739 | } |
| 740 | case VIDIOC_QUERYCTRL: |
| 741 | { |
| 742 | struct v4l2_queryctrl *p=arg; |
| 743 | printk ("%s: id=%d, type=%d, name=%s, min/max=%d/%d," |
| 744 | " step=%d, default=%d, flags=0x%08x\n", s, |
| 745 | p->id,p->type,p->name,p->minimum,p->maximum, |
| 746 | p->step,p->default_value,p->flags); |
| 747 | break; |
| 748 | } |
| 749 | case VIDIOC_QUERYMENU: |
| 750 | { |
| 751 | struct v4l2_querymenu *p=arg; |
| 752 | printk ("%s: id=%d, index=%d, name=%s\n", s, |
| 753 | p->id,p->index,p->name); |
| 754 | break; |
| 755 | } |
| 756 | case VIDIOC_INT_G_REGISTER: |
| 757 | case VIDIOC_INT_S_REGISTER: |
| 758 | { |
| 759 | struct v4l2_register *p=arg; |
| 760 | printk ("%s: i2c_id=%d, reg=%lu, val=%d\n", s, |
| 761 | p->i2c_id,p->reg,p->val); |
| 762 | |
| 763 | break; |
| 764 | } |
| 765 | case VIDIOC_REQBUFS: |
| 766 | { |
| 767 | struct v4l2_requestbuffers *p=arg; |
Mauro Carvalho Chehab | 2e0d447 | 2006-02-27 00:08:58 -0300 | [diff] [blame] | 768 | printk ("%s: count=%d, type=%s, memory=%s\n", s, |
| 769 | p->count, |
| 770 | prt_names(p->type,v4l2_type_names), |
| 771 | prt_names(p->memory,v4l2_memory_names)); |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 772 | break; |
| 773 | } |
| 774 | case VIDIOC_INT_S_AUDIO_ROUTING: |
| 775 | case VIDIOC_INT_S_VIDEO_ROUTING: |
| 776 | case VIDIOC_INT_G_AUDIO_ROUTING: |
| 777 | case VIDIOC_INT_G_VIDEO_ROUTING: |
| 778 | { |
| 779 | struct v4l2_routing *p=arg; |
Hans Verkuil | 2474ed4 | 2006-03-19 12:35:57 -0300 | [diff] [blame] | 780 | printk ("%s: input=0x%x, output=0x%x\n", s, p->input, p->output); |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 781 | break; |
| 782 | } |
Hans Verkuil | b7f8292 | 2006-04-02 12:50:42 -0300 | [diff] [blame] | 783 | case VIDIOC_INT_S_CRYSTAL_FREQ: |
| 784 | { |
| 785 | struct v4l2_crystal_freq *p=arg; |
| 786 | printk ("%s: freq=%u, flags=0x%x\n", s, p->freq, p->flags); |
| 787 | break; |
| 788 | } |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 789 | case VIDIOC_G_SLICED_VBI_CAP: |
| 790 | { |
| 791 | struct v4l2_sliced_vbi_cap *p=arg; |
| 792 | printk ("%s: service_set=%d\n", s, |
| 793 | p->service_set); |
| 794 | break; |
| 795 | } |
| 796 | case VIDIOC_INT_S_VBI_DATA: |
| 797 | case VIDIOC_INT_G_VBI_DATA: |
| 798 | { |
| 799 | struct v4l2_sliced_vbi_data *p=arg; |
| 800 | printk ("%s: id=%d, field=%d, line=%d\n", s, |
| 801 | p->id, p->field, p->line); |
| 802 | break; |
| 803 | } |
| 804 | case VIDIOC_ENUMSTD: |
| 805 | { |
| 806 | struct v4l2_standard *p=arg; |
Andrew Morton | 5245953 | 2006-03-22 15:01:59 -0300 | [diff] [blame] | 807 | printk ("%s: index=%d, id=%Ld, name=%s, fps=%d/%d, " |
| 808 | "framelines=%d\n", s, p->index, |
| 809 | (unsigned long long)p->id, p->name, |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 810 | p->frameperiod.numerator, |
| 811 | p->frameperiod.denominator, |
| 812 | p->framelines); |
| 813 | |
| 814 | break; |
| 815 | } |
| 816 | case VIDIOC_G_PARM: |
| 817 | case VIDIOC_S_PARM: |
Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 818 | #ifdef __OLD_VIDIOC_ |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 819 | case VIDIOC_S_PARM_OLD: |
Mauro Carvalho Chehab | 401998f | 2006-06-04 10:06:18 -0300 | [diff] [blame] | 820 | #endif |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 821 | { |
| 822 | struct v4l2_streamparm *p=arg; |
| 823 | printk ("%s: type=%d\n", s, p->type); |
| 824 | |
| 825 | break; |
| 826 | } |
| 827 | case VIDIOC_G_TUNER: |
| 828 | case VIDIOC_S_TUNER: |
| 829 | { |
| 830 | struct v4l2_tuner *p=arg; |
| 831 | printk ("%s: index=%d, name=%s, type=%d, capability=%d, " |
| 832 | "rangelow=%d, rangehigh=%d, signal=%d, afc=%d, " |
| 833 | "rxsubchans=%d, audmode=%d\n", s, |
| 834 | p->index, p->name, p->type, |
| 835 | p->capability, p->rangelow,p->rangehigh, |
| 836 | p->rxsubchans, p->audmode, p->signal, |
| 837 | p->afc); |
| 838 | break; |
| 839 | } |
Mauro Carvalho Chehab | 985bc96 | 2006-07-23 06:31:19 -0300 | [diff] [blame] | 840 | #ifdef CONFIG_VIDEO_V4L1_COMPAT |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 841 | case VIDIOCGVBIFMT: |
| 842 | case VIDIOCSVBIFMT: |
| 843 | { |
| 844 | struct vbi_format *p=arg; |
| 845 | printk ("%s: sampling_rate=%d, samples_per_line=%d, " |
| 846 | "sample_format=%d, start=%d/%d, count=%d/%d, flags=%d\n", s, |
| 847 | p->sampling_rate,p->samples_per_line, |
| 848 | p->sample_format,p->start[0],p->start[1], |
| 849 | p->count[0],p->count[1],p->flags); |
| 850 | break; |
| 851 | } |
| 852 | case VIDIOCGAUDIO: |
| 853 | case VIDIOCSAUDIO: |
| 854 | { |
| 855 | struct video_audio *p=arg; |
| 856 | printk ("%s: audio=%d, volume=%d, bass=%d, treble=%d, " |
| 857 | "flags=%d, name=%s, mode=%d, balance=%d, step=%d\n", |
| 858 | s,p->audio,p->volume,p->bass, p->treble, |
| 859 | p->flags,p->name,p->mode,p->balance,p->step); |
| 860 | break; |
| 861 | } |
| 862 | case VIDIOCGFBUF: |
| 863 | case VIDIOCSFBUF: |
| 864 | { |
| 865 | struct video_buffer *p=arg; |
| 866 | printk ("%s: base=%08lx, height=%d, width=%d, depth=%d, " |
| 867 | "bytesperline=%d\n", s, |
| 868 | (unsigned long) p->base, p->height, p->width, |
| 869 | p->depth,p->bytesperline); |
| 870 | break; |
| 871 | } |
| 872 | case VIDIOCGCAP: |
| 873 | { |
| 874 | struct video_capability *p=arg; |
| 875 | printk ("%s: name=%s, type=%d, channels=%d, audios=%d, " |
| 876 | "maxwidth=%d, maxheight=%d, minwidth=%d, minheight=%d\n", |
| 877 | s,p->name,p->type,p->channels,p->audios, |
| 878 | p->maxwidth,p->maxheight,p->minwidth, |
| 879 | p->minheight); |
| 880 | |
| 881 | break; |
| 882 | } |
| 883 | case VIDIOCGCAPTURE: |
| 884 | case VIDIOCSCAPTURE: |
| 885 | { |
| 886 | struct video_capture *p=arg; |
| 887 | printk ("%s: x=%d, y=%d, width=%d, height=%d, decimation=%d," |
| 888 | " flags=%d\n", s, |
| 889 | p->x, p->y,p->width, p->height, |
| 890 | p->decimation,p->flags); |
| 891 | break; |
| 892 | } |
| 893 | case VIDIOCGCHAN: |
| 894 | case VIDIOCSCHAN: |
| 895 | { |
| 896 | struct video_channel *p=arg; |
| 897 | printk ("%s: channel=%d, name=%s, tuners=%d, flags=%d, " |
| 898 | "type=%d, norm=%d\n", s, |
| 899 | p->channel,p->name,p->tuners, |
| 900 | p->flags,p->type,p->norm); |
| 901 | |
| 902 | break; |
| 903 | } |
| 904 | case VIDIOCSMICROCODE: |
| 905 | { |
| 906 | struct video_code *p=arg; |
| 907 | printk ("%s: loadwhat=%s, datasize=%d\n", s, |
| 908 | p->loadwhat,p->datasize); |
| 909 | break; |
| 910 | } |
| 911 | case DECODER_GET_CAPABILITIES: |
| 912 | { |
| 913 | struct video_decoder_capability *p=arg; |
| 914 | printk ("%s: flags=%d, inputs=%d, outputs=%d\n", s, |
| 915 | p->flags,p->inputs,p->outputs); |
| 916 | break; |
| 917 | } |
| 918 | case DECODER_INIT: |
| 919 | { |
| 920 | struct video_decoder_init *p=arg; |
| 921 | printk ("%s: len=%c\n", s, p->len); |
| 922 | break; |
| 923 | } |
| 924 | case VIDIOCGPLAYINFO: |
| 925 | { |
| 926 | struct video_info *p=arg; |
| 927 | printk ("%s: frame_count=%d, h_size=%d, v_size=%d, " |
| 928 | "smpte_timecode=%d, picture_type=%d, " |
| 929 | "temporal_reference=%d, user_data=%s\n", s, |
| 930 | p->frame_count, p->h_size, |
| 931 | p->v_size, p->smpte_timecode, |
| 932 | p->picture_type, p->temporal_reference, |
| 933 | p->user_data); |
| 934 | break; |
| 935 | } |
| 936 | case VIDIOCKEY: |
| 937 | { |
| 938 | struct video_key *p=arg; |
| 939 | printk ("%s: key=%s, flags=%d\n", s, |
| 940 | p->key, p->flags); |
| 941 | break; |
| 942 | } |
| 943 | case VIDIOCGMBUF: |
| 944 | { |
| 945 | struct video_mbuf *p=arg; |
| 946 | printk ("%s: size=%d, frames=%d, offsets=0x%08lx\n", s, |
| 947 | p->size, |
| 948 | p->frames, |
| 949 | (unsigned long)p->offsets); |
| 950 | break; |
| 951 | } |
| 952 | case VIDIOCMCAPTURE: |
| 953 | { |
| 954 | struct video_mmap *p=arg; |
| 955 | printk ("%s: frame=%d, height=%d, width=%d, format=%d\n", s, |
| 956 | p->frame, |
| 957 | p->height, p->width, |
| 958 | p->format); |
| 959 | break; |
| 960 | } |
| 961 | case VIDIOCGPICT: |
| 962 | case VIDIOCSPICT: |
| 963 | case DECODER_SET_PICTURE: |
| 964 | { |
| 965 | struct video_picture *p=arg; |
| 966 | |
| 967 | printk ("%s: brightness=%d, hue=%d, colour=%d, contrast=%d," |
| 968 | " whiteness=%d, depth=%d, palette=%d\n", s, |
| 969 | p->brightness, p->hue, p->colour, |
| 970 | p->contrast, p->whiteness, p->depth, |
| 971 | p->palette); |
| 972 | break; |
| 973 | } |
| 974 | case VIDIOCSPLAYMODE: |
| 975 | { |
| 976 | struct video_play_mode *p=arg; |
| 977 | printk ("%s: mode=%d, p1=%d, p2=%d\n", s, |
| 978 | p->mode,p->p1,p->p2); |
| 979 | break; |
| 980 | } |
| 981 | case VIDIOCGTUNER: |
| 982 | case VIDIOCSTUNER: |
| 983 | { |
| 984 | struct video_tuner *p=arg; |
| 985 | printk ("%s: tuner=%d, name=%s, rangelow=%ld, rangehigh=%ld, " |
| 986 | "flags=%d, mode=%d, signal=%d\n", s, |
| 987 | p->tuner, p->name,p->rangelow, p->rangehigh, |
| 988 | p->flags,p->mode, p->signal); |
| 989 | break; |
| 990 | } |
| 991 | case VIDIOCGUNIT: |
| 992 | { |
| 993 | struct video_unit *p=arg; |
| 994 | printk ("%s: video=%d, vbi=%d, radio=%d, audio=%d, " |
| 995 | "teletext=%d\n", s, |
| 996 | p->video,p->vbi,p->radio,p->audio,p->teletext); |
| 997 | break; |
| 998 | } |
| 999 | case VIDIOCGWIN: |
| 1000 | case VIDIOCSWIN: |
| 1001 | { |
| 1002 | struct video_window *p=arg; |
| 1003 | printk ("%s: x=%d, y=%d, width=%d, height=%d, chromakey=%d," |
| 1004 | " flags=%d, clipcount=%d\n", s, |
| 1005 | p->x, p->y,p->width, p->height, |
| 1006 | p->chromakey,p->flags, |
| 1007 | p->clipcount); |
| 1008 | break; |
| 1009 | } |
Mauro Carvalho Chehab | 985bc96 | 2006-07-23 06:31:19 -0300 | [diff] [blame] | 1010 | case VIDIOCGFREQ: |
| 1011 | case VIDIOCSFREQ: |
| 1012 | { |
| 1013 | unsigned long *p=arg; |
| 1014 | printk ("%s: value=%lu\n", s, *p); |
| 1015 | break; |
| 1016 | } |
| 1017 | #endif |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 1018 | case VIDIOC_INT_AUDIO_CLOCK_FREQ: |
| 1019 | case VIDIOC_INT_I2S_CLOCK_FREQ: |
| 1020 | case VIDIOC_INT_S_STANDBY: |
Hans Verkuil | 784e8fe4 | 2006-08-26 03:17:58 -0300 | [diff] [blame] | 1021 | case VIDIOC_INT_RESET: |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 1022 | { |
| 1023 | u32 *p=arg; |
| 1024 | |
| 1025 | printk ("%s: value=%d\n", s, *p); |
| 1026 | break; |
| 1027 | } |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 1028 | case VIDIOC_G_STD: |
| 1029 | case VIDIOC_S_STD: |
| 1030 | case VIDIOC_QUERYSTD: |
| 1031 | { |
| 1032 | v4l2_std_id *p=arg; |
| 1033 | |
Andrew Morton | 5245953 | 2006-03-22 15:01:59 -0300 | [diff] [blame] | 1034 | printk ("%s: value=%Lu\n", s, (unsigned long long)*p); |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 1035 | break; |
| 1036 | } |
| 1037 | } |
| 1038 | } |
| 1039 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1040 | /* ----------------------------------------------------------------- */ |
| 1041 | |
Hans Verkuil | 9cb2318 | 2006-06-18 14:11:08 -0300 | [diff] [blame] | 1042 | /* Helper functions for control handling */ |
| 1043 | |
| 1044 | /* Check for correctness of the ctrl's value based on the data from |
| 1045 | struct v4l2_queryctrl and the available menu items. Note that |
| 1046 | menu_items may be NULL, in that case it is ignored. */ |
| 1047 | int v4l2_ctrl_check(struct v4l2_ext_control *ctrl, struct v4l2_queryctrl *qctrl, |
| 1048 | const char **menu_items) |
| 1049 | { |
| 1050 | if (qctrl->flags & V4L2_CTRL_FLAG_DISABLED) |
| 1051 | return -EINVAL; |
| 1052 | if (qctrl->flags & V4L2_CTRL_FLAG_GRABBED) |
| 1053 | return -EBUSY; |
| 1054 | if (qctrl->type == V4L2_CTRL_TYPE_BUTTON || |
| 1055 | qctrl->type == V4L2_CTRL_TYPE_INTEGER64 || |
| 1056 | qctrl->type == V4L2_CTRL_TYPE_CTRL_CLASS) |
| 1057 | return 0; |
| 1058 | if (ctrl->value < qctrl->minimum || ctrl->value > qctrl->maximum) |
| 1059 | return -ERANGE; |
| 1060 | if (qctrl->type == V4L2_CTRL_TYPE_MENU && menu_items != NULL) { |
| 1061 | if (menu_items[ctrl->value] == NULL || |
| 1062 | menu_items[ctrl->value][0] == '\0') |
| 1063 | return -EINVAL; |
| 1064 | } |
| 1065 | return 0; |
| 1066 | } |
| 1067 | |
| 1068 | /* Returns NULL or a character pointer array containing the menu for |
| 1069 | the given control ID. The pointer array ends with a NULL pointer. |
| 1070 | An empty string signifies a menu entry that is invalid. This allows |
| 1071 | drivers to disable certain options if it is not supported. */ |
| 1072 | const char **v4l2_ctrl_get_menu(u32 id) |
| 1073 | { |
| 1074 | static const char *mpeg_audio_sampling_freq[] = { |
| 1075 | "44.1 kHz", |
| 1076 | "48 kHz", |
| 1077 | "32 kHz", |
| 1078 | NULL |
| 1079 | }; |
| 1080 | static const char *mpeg_audio_encoding[] = { |
| 1081 | "Layer I", |
| 1082 | "Layer II", |
| 1083 | "Layer III", |
| 1084 | NULL |
| 1085 | }; |
| 1086 | static const char *mpeg_audio_l1_bitrate[] = { |
| 1087 | "32 kbps", |
| 1088 | "64 kbps", |
| 1089 | "96 kbps", |
| 1090 | "128 kbps", |
| 1091 | "160 kbps", |
| 1092 | "192 kbps", |
| 1093 | "224 kbps", |
| 1094 | "256 kbps", |
| 1095 | "288 kbps", |
| 1096 | "320 kbps", |
| 1097 | "352 kbps", |
| 1098 | "384 kbps", |
| 1099 | "416 kbps", |
| 1100 | "448 kbps", |
| 1101 | NULL |
| 1102 | }; |
| 1103 | static const char *mpeg_audio_l2_bitrate[] = { |
| 1104 | "32 kbps", |
| 1105 | "48 kbps", |
| 1106 | "56 kbps", |
| 1107 | "64 kbps", |
| 1108 | "80 kbps", |
| 1109 | "96 kbps", |
| 1110 | "112 kbps", |
| 1111 | "128 kbps", |
| 1112 | "160 kbps", |
| 1113 | "192 kbps", |
| 1114 | "224 kbps", |
| 1115 | "256 kbps", |
| 1116 | "320 kbps", |
| 1117 | "384 kbps", |
| 1118 | NULL |
| 1119 | }; |
| 1120 | static const char *mpeg_audio_l3_bitrate[] = { |
| 1121 | "32 kbps", |
| 1122 | "40 kbps", |
| 1123 | "48 kbps", |
| 1124 | "56 kbps", |
| 1125 | "64 kbps", |
| 1126 | "80 kbps", |
| 1127 | "96 kbps", |
| 1128 | "112 kbps", |
| 1129 | "128 kbps", |
| 1130 | "160 kbps", |
| 1131 | "192 kbps", |
| 1132 | "224 kbps", |
| 1133 | "256 kbps", |
| 1134 | "320 kbps", |
| 1135 | NULL |
| 1136 | }; |
| 1137 | static const char *mpeg_audio_mode[] = { |
| 1138 | "Stereo", |
| 1139 | "Joint Stereo", |
| 1140 | "Dual", |
| 1141 | "Mono", |
| 1142 | NULL |
| 1143 | }; |
| 1144 | static const char *mpeg_audio_mode_extension[] = { |
| 1145 | "Bound 4", |
| 1146 | "Bound 8", |
| 1147 | "Bound 12", |
| 1148 | "Bound 16", |
| 1149 | NULL |
| 1150 | }; |
| 1151 | static const char *mpeg_audio_emphasis[] = { |
| 1152 | "No Emphasis", |
| 1153 | "50/15 us", |
| 1154 | "CCITT J17", |
| 1155 | NULL |
| 1156 | }; |
| 1157 | static const char *mpeg_audio_crc[] = { |
| 1158 | "No CRC", |
| 1159 | "16-bit CRC", |
| 1160 | NULL |
| 1161 | }; |
| 1162 | static const char *mpeg_video_encoding[] = { |
| 1163 | "MPEG-1", |
| 1164 | "MPEG-2", |
| 1165 | NULL |
| 1166 | }; |
| 1167 | static const char *mpeg_video_aspect[] = { |
| 1168 | "1x1", |
| 1169 | "4x3", |
| 1170 | "16x9", |
| 1171 | "2.21x1", |
| 1172 | NULL |
| 1173 | }; |
| 1174 | static const char *mpeg_video_bitrate_mode[] = { |
| 1175 | "Variable Bitrate", |
| 1176 | "Constant Bitrate", |
| 1177 | NULL |
| 1178 | }; |
| 1179 | static const char *mpeg_stream_type[] = { |
| 1180 | "MPEG-2 Program Stream", |
| 1181 | "MPEG-2 Transport Stream", |
| 1182 | "MPEG-1 System Stream", |
| 1183 | "MPEG-2 DVD-compatible Stream", |
| 1184 | "MPEG-1 VCD-compatible Stream", |
| 1185 | "MPEG-2 SVCD-compatible Stream", |
| 1186 | NULL |
| 1187 | }; |
Hans Verkuil | 8cbde94 | 2006-06-24 14:36:02 -0300 | [diff] [blame] | 1188 | static const char *mpeg_stream_vbi_fmt[] = { |
| 1189 | "No VBI", |
Hans Verkuil | 9952351 | 2006-06-25 11:18:54 -0300 | [diff] [blame] | 1190 | "Private packet, IVTV format", |
Hans Verkuil | 8cbde94 | 2006-06-24 14:36:02 -0300 | [diff] [blame] | 1191 | NULL |
| 1192 | }; |
Hans Verkuil | 9cb2318 | 2006-06-18 14:11:08 -0300 | [diff] [blame] | 1193 | |
| 1194 | switch (id) { |
| 1195 | case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ: |
| 1196 | return mpeg_audio_sampling_freq; |
| 1197 | case V4L2_CID_MPEG_AUDIO_ENCODING: |
| 1198 | return mpeg_audio_encoding; |
| 1199 | case V4L2_CID_MPEG_AUDIO_L1_BITRATE: |
| 1200 | return mpeg_audio_l1_bitrate; |
| 1201 | case V4L2_CID_MPEG_AUDIO_L2_BITRATE: |
| 1202 | return mpeg_audio_l2_bitrate; |
| 1203 | case V4L2_CID_MPEG_AUDIO_L3_BITRATE: |
| 1204 | return mpeg_audio_l3_bitrate; |
| 1205 | case V4L2_CID_MPEG_AUDIO_MODE: |
| 1206 | return mpeg_audio_mode; |
| 1207 | case V4L2_CID_MPEG_AUDIO_MODE_EXTENSION: |
| 1208 | return mpeg_audio_mode_extension; |
| 1209 | case V4L2_CID_MPEG_AUDIO_EMPHASIS: |
| 1210 | return mpeg_audio_emphasis; |
| 1211 | case V4L2_CID_MPEG_AUDIO_CRC: |
| 1212 | return mpeg_audio_crc; |
| 1213 | case V4L2_CID_MPEG_VIDEO_ENCODING: |
| 1214 | return mpeg_video_encoding; |
| 1215 | case V4L2_CID_MPEG_VIDEO_ASPECT: |
| 1216 | return mpeg_video_aspect; |
| 1217 | case V4L2_CID_MPEG_VIDEO_BITRATE_MODE: |
| 1218 | return mpeg_video_bitrate_mode; |
| 1219 | case V4L2_CID_MPEG_STREAM_TYPE: |
| 1220 | return mpeg_stream_type; |
Hans Verkuil | 8cbde94 | 2006-06-24 14:36:02 -0300 | [diff] [blame] | 1221 | case V4L2_CID_MPEG_STREAM_VBI_FMT: |
| 1222 | return mpeg_stream_vbi_fmt; |
Hans Verkuil | 9cb2318 | 2006-06-18 14:11:08 -0300 | [diff] [blame] | 1223 | default: |
| 1224 | return NULL; |
| 1225 | } |
| 1226 | } |
| 1227 | |
| 1228 | /* Fill in a struct v4l2_queryctrl */ |
| 1229 | int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl, s32 min, s32 max, s32 step, s32 def) |
| 1230 | { |
| 1231 | const char *name; |
| 1232 | |
| 1233 | qctrl->flags = 0; |
| 1234 | switch (qctrl->id) { |
| 1235 | /* USER controls */ |
| 1236 | case V4L2_CID_USER_CLASS: name = "User Controls"; break; |
| 1237 | case V4L2_CID_AUDIO_VOLUME: name = "Volume"; break; |
| 1238 | case V4L2_CID_AUDIO_MUTE: name = "Mute"; break; |
| 1239 | case V4L2_CID_AUDIO_BALANCE: name = "Balance"; break; |
| 1240 | case V4L2_CID_AUDIO_BASS: name = "Bass"; break; |
| 1241 | case V4L2_CID_AUDIO_TREBLE: name = "Treble"; break; |
| 1242 | case V4L2_CID_AUDIO_LOUDNESS: name = "Loudness"; break; |
| 1243 | case V4L2_CID_BRIGHTNESS: name = "Brightness"; break; |
| 1244 | case V4L2_CID_CONTRAST: name = "Contrast"; break; |
| 1245 | case V4L2_CID_SATURATION: name = "Saturation"; break; |
| 1246 | case V4L2_CID_HUE: name = "Hue"; break; |
| 1247 | |
| 1248 | /* MPEG controls */ |
| 1249 | case V4L2_CID_MPEG_CLASS: name = "MPEG Encoder Controls"; break; |
| 1250 | case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ: name = "Audio Sampling Frequency"; break; |
| 1251 | case V4L2_CID_MPEG_AUDIO_ENCODING: name = "Audio Encoding Layer"; break; |
| 1252 | case V4L2_CID_MPEG_AUDIO_L1_BITRATE: name = "Audio Layer I Bitrate"; break; |
| 1253 | case V4L2_CID_MPEG_AUDIO_L2_BITRATE: name = "Audio Layer II Bitrate"; break; |
| 1254 | case V4L2_CID_MPEG_AUDIO_L3_BITRATE: name = "Audio Layer III Bitrate"; break; |
| 1255 | case V4L2_CID_MPEG_AUDIO_MODE: name = "Audio Stereo Mode"; break; |
| 1256 | case V4L2_CID_MPEG_AUDIO_MODE_EXTENSION: name = "Audio Stereo Mode Extension"; break; |
| 1257 | case V4L2_CID_MPEG_AUDIO_EMPHASIS: name = "Audio Emphasis"; break; |
| 1258 | case V4L2_CID_MPEG_AUDIO_CRC: name = "Audio CRC"; break; |
| 1259 | case V4L2_CID_MPEG_VIDEO_ENCODING: name = "Video Encoding"; break; |
| 1260 | case V4L2_CID_MPEG_VIDEO_ASPECT: name = "Video Aspect"; break; |
| 1261 | case V4L2_CID_MPEG_VIDEO_B_FRAMES: name = "Video B Frames"; break; |
| 1262 | case V4L2_CID_MPEG_VIDEO_GOP_SIZE: name = "Video GOP Size"; break; |
| 1263 | case V4L2_CID_MPEG_VIDEO_GOP_CLOSURE: name = "Video GOP Closure"; break; |
| 1264 | case V4L2_CID_MPEG_VIDEO_PULLDOWN: name = "Video Pulldown"; break; |
| 1265 | case V4L2_CID_MPEG_VIDEO_BITRATE_MODE: name = "Video Bitrate Mode"; break; |
| 1266 | case V4L2_CID_MPEG_VIDEO_BITRATE: name = "Video Bitrate"; break; |
| 1267 | case V4L2_CID_MPEG_VIDEO_BITRATE_PEAK: name = "Video Peak Bitrate"; break; |
| 1268 | case V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION: name = "Video Temporal Decimation"; break; |
| 1269 | case V4L2_CID_MPEG_STREAM_TYPE: name = "Stream Type"; break; |
| 1270 | case V4L2_CID_MPEG_STREAM_PID_PMT: name = "Stream PMT Program ID"; break; |
| 1271 | case V4L2_CID_MPEG_STREAM_PID_AUDIO: name = "Stream Audio Program ID"; break; |
| 1272 | case V4L2_CID_MPEG_STREAM_PID_VIDEO: name = "Stream Video Program ID"; break; |
| 1273 | case V4L2_CID_MPEG_STREAM_PID_PCR: name = "Stream PCR Program ID"; break; |
| 1274 | case V4L2_CID_MPEG_STREAM_PES_ID_AUDIO: name = "Stream PES Audio ID"; break; |
| 1275 | case V4L2_CID_MPEG_STREAM_PES_ID_VIDEO: name = "Stream PES Video ID"; break; |
Hans Verkuil | 8cbde94 | 2006-06-24 14:36:02 -0300 | [diff] [blame] | 1276 | case V4L2_CID_MPEG_STREAM_VBI_FMT: name = "Stream VBI Format"; break; |
Hans Verkuil | 9cb2318 | 2006-06-18 14:11:08 -0300 | [diff] [blame] | 1277 | |
| 1278 | default: |
| 1279 | return -EINVAL; |
| 1280 | } |
| 1281 | switch (qctrl->id) { |
| 1282 | case V4L2_CID_AUDIO_MUTE: |
| 1283 | case V4L2_CID_AUDIO_LOUDNESS: |
| 1284 | case V4L2_CID_MPEG_VIDEO_GOP_CLOSURE: |
| 1285 | case V4L2_CID_MPEG_VIDEO_PULLDOWN: |
| 1286 | qctrl->type = V4L2_CTRL_TYPE_BOOLEAN; |
| 1287 | min = 0; |
| 1288 | max = step = 1; |
| 1289 | break; |
| 1290 | case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ: |
| 1291 | case V4L2_CID_MPEG_AUDIO_ENCODING: |
| 1292 | case V4L2_CID_MPEG_AUDIO_L1_BITRATE: |
| 1293 | case V4L2_CID_MPEG_AUDIO_L2_BITRATE: |
| 1294 | case V4L2_CID_MPEG_AUDIO_L3_BITRATE: |
| 1295 | case V4L2_CID_MPEG_AUDIO_MODE: |
| 1296 | case V4L2_CID_MPEG_AUDIO_MODE_EXTENSION: |
| 1297 | case V4L2_CID_MPEG_AUDIO_EMPHASIS: |
| 1298 | case V4L2_CID_MPEG_AUDIO_CRC: |
| 1299 | case V4L2_CID_MPEG_VIDEO_ENCODING: |
| 1300 | case V4L2_CID_MPEG_VIDEO_ASPECT: |
| 1301 | case V4L2_CID_MPEG_VIDEO_BITRATE_MODE: |
| 1302 | case V4L2_CID_MPEG_STREAM_TYPE: |
Hans Verkuil | 8cbde94 | 2006-06-24 14:36:02 -0300 | [diff] [blame] | 1303 | case V4L2_CID_MPEG_STREAM_VBI_FMT: |
Hans Verkuil | 9cb2318 | 2006-06-18 14:11:08 -0300 | [diff] [blame] | 1304 | qctrl->type = V4L2_CTRL_TYPE_MENU; |
| 1305 | step = 1; |
| 1306 | break; |
| 1307 | case V4L2_CID_USER_CLASS: |
| 1308 | case V4L2_CID_MPEG_CLASS: |
| 1309 | qctrl->type = V4L2_CTRL_TYPE_CTRL_CLASS; |
| 1310 | qctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY; |
| 1311 | min = max = step = def = 0; |
| 1312 | break; |
| 1313 | default: |
| 1314 | qctrl->type = V4L2_CTRL_TYPE_INTEGER; |
| 1315 | break; |
| 1316 | } |
| 1317 | switch (qctrl->id) { |
| 1318 | case V4L2_CID_MPEG_AUDIO_ENCODING: |
| 1319 | case V4L2_CID_MPEG_AUDIO_MODE: |
| 1320 | case V4L2_CID_MPEG_VIDEO_BITRATE_MODE: |
| 1321 | case V4L2_CID_MPEG_VIDEO_B_FRAMES: |
| 1322 | case V4L2_CID_MPEG_STREAM_TYPE: |
| 1323 | qctrl->flags |= V4L2_CTRL_FLAG_UPDATE; |
| 1324 | break; |
| 1325 | case V4L2_CID_AUDIO_VOLUME: |
| 1326 | case V4L2_CID_AUDIO_BALANCE: |
| 1327 | case V4L2_CID_AUDIO_BASS: |
| 1328 | case V4L2_CID_AUDIO_TREBLE: |
| 1329 | case V4L2_CID_BRIGHTNESS: |
| 1330 | case V4L2_CID_CONTRAST: |
| 1331 | case V4L2_CID_SATURATION: |
| 1332 | case V4L2_CID_HUE: |
| 1333 | qctrl->flags |= V4L2_CTRL_FLAG_SLIDER; |
| 1334 | break; |
| 1335 | } |
| 1336 | qctrl->minimum = min; |
| 1337 | qctrl->maximum = max; |
| 1338 | qctrl->step = step; |
| 1339 | qctrl->default_value = def; |
| 1340 | qctrl->reserved[0] = qctrl->reserved[1] = 0; |
| 1341 | snprintf(qctrl->name, sizeof(qctrl->name), name); |
| 1342 | return 0; |
| 1343 | } |
| 1344 | |
| 1345 | /* Fill in a struct v4l2_queryctrl with standard values based on |
| 1346 | the control ID. */ |
| 1347 | int v4l2_ctrl_query_fill_std(struct v4l2_queryctrl *qctrl) |
| 1348 | { |
| 1349 | switch (qctrl->id) { |
| 1350 | /* USER controls */ |
| 1351 | case V4L2_CID_USER_CLASS: |
| 1352 | case V4L2_CID_MPEG_CLASS: |
| 1353 | return v4l2_ctrl_query_fill(qctrl, 0, 0, 0, 0); |
| 1354 | case V4L2_CID_AUDIO_VOLUME: |
| 1355 | return v4l2_ctrl_query_fill(qctrl, 0, 65535, 65535 / 100, 58880); |
| 1356 | case V4L2_CID_AUDIO_MUTE: |
| 1357 | case V4L2_CID_AUDIO_LOUDNESS: |
| 1358 | return v4l2_ctrl_query_fill(qctrl, 0, 1, 1, 0); |
| 1359 | case V4L2_CID_AUDIO_BALANCE: |
| 1360 | case V4L2_CID_AUDIO_BASS: |
| 1361 | case V4L2_CID_AUDIO_TREBLE: |
| 1362 | return v4l2_ctrl_query_fill(qctrl, 0, 65535, 65535 / 100, 32768); |
| 1363 | case V4L2_CID_BRIGHTNESS: |
| 1364 | return v4l2_ctrl_query_fill(qctrl, 0, 255, 1, 128); |
| 1365 | case V4L2_CID_CONTRAST: |
| 1366 | case V4L2_CID_SATURATION: |
| 1367 | return v4l2_ctrl_query_fill(qctrl, 0, 127, 1, 64); |
| 1368 | case V4L2_CID_HUE: |
| 1369 | return v4l2_ctrl_query_fill(qctrl, -128, 127, 1, 0); |
| 1370 | |
| 1371 | /* MPEG controls */ |
| 1372 | case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ: |
| 1373 | return v4l2_ctrl_query_fill(qctrl, |
| 1374 | V4L2_MPEG_AUDIO_SAMPLING_FREQ_44100, |
| 1375 | V4L2_MPEG_AUDIO_SAMPLING_FREQ_32000, 1, |
| 1376 | V4L2_MPEG_AUDIO_SAMPLING_FREQ_48000); |
| 1377 | case V4L2_CID_MPEG_AUDIO_ENCODING: |
| 1378 | return v4l2_ctrl_query_fill(qctrl, |
| 1379 | V4L2_MPEG_AUDIO_ENCODING_LAYER_1, |
| 1380 | V4L2_MPEG_AUDIO_ENCODING_LAYER_3, 1, |
| 1381 | V4L2_MPEG_AUDIO_ENCODING_LAYER_2); |
| 1382 | case V4L2_CID_MPEG_AUDIO_L1_BITRATE: |
| 1383 | return v4l2_ctrl_query_fill(qctrl, |
| 1384 | V4L2_MPEG_AUDIO_L1_BITRATE_32K, |
| 1385 | V4L2_MPEG_AUDIO_L1_BITRATE_448K, 1, |
| 1386 | V4L2_MPEG_AUDIO_L1_BITRATE_256K); |
| 1387 | case V4L2_CID_MPEG_AUDIO_L2_BITRATE: |
| 1388 | return v4l2_ctrl_query_fill(qctrl, |
| 1389 | V4L2_MPEG_AUDIO_L2_BITRATE_32K, |
| 1390 | V4L2_MPEG_AUDIO_L2_BITRATE_384K, 1, |
| 1391 | V4L2_MPEG_AUDIO_L2_BITRATE_224K); |
| 1392 | case V4L2_CID_MPEG_AUDIO_L3_BITRATE: |
| 1393 | return v4l2_ctrl_query_fill(qctrl, |
| 1394 | V4L2_MPEG_AUDIO_L3_BITRATE_32K, |
| 1395 | V4L2_MPEG_AUDIO_L3_BITRATE_320K, 1, |
| 1396 | V4L2_MPEG_AUDIO_L3_BITRATE_192K); |
| 1397 | case V4L2_CID_MPEG_AUDIO_MODE: |
| 1398 | return v4l2_ctrl_query_fill(qctrl, |
| 1399 | V4L2_MPEG_AUDIO_MODE_STEREO, |
| 1400 | V4L2_MPEG_AUDIO_MODE_MONO, 1, |
| 1401 | V4L2_MPEG_AUDIO_MODE_STEREO); |
| 1402 | case V4L2_CID_MPEG_AUDIO_MODE_EXTENSION: |
| 1403 | return v4l2_ctrl_query_fill(qctrl, |
| 1404 | V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_4, |
| 1405 | V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_16, 1, |
| 1406 | V4L2_MPEG_AUDIO_MODE_EXTENSION_BOUND_4); |
| 1407 | case V4L2_CID_MPEG_AUDIO_EMPHASIS: |
| 1408 | return v4l2_ctrl_query_fill(qctrl, |
| 1409 | V4L2_MPEG_AUDIO_EMPHASIS_NONE, |
| 1410 | V4L2_MPEG_AUDIO_EMPHASIS_CCITT_J17, 1, |
| 1411 | V4L2_MPEG_AUDIO_EMPHASIS_NONE); |
| 1412 | case V4L2_CID_MPEG_AUDIO_CRC: |
| 1413 | return v4l2_ctrl_query_fill(qctrl, |
| 1414 | V4L2_MPEG_AUDIO_CRC_NONE, |
| 1415 | V4L2_MPEG_AUDIO_CRC_CRC16, 1, |
| 1416 | V4L2_MPEG_AUDIO_CRC_NONE); |
| 1417 | case V4L2_CID_MPEG_VIDEO_ENCODING: |
| 1418 | return v4l2_ctrl_query_fill(qctrl, |
| 1419 | V4L2_MPEG_VIDEO_ENCODING_MPEG_1, |
| 1420 | V4L2_MPEG_VIDEO_ENCODING_MPEG_2, 1, |
| 1421 | V4L2_MPEG_VIDEO_ENCODING_MPEG_2); |
| 1422 | case V4L2_CID_MPEG_VIDEO_ASPECT: |
| 1423 | return v4l2_ctrl_query_fill(qctrl, |
| 1424 | V4L2_MPEG_VIDEO_ASPECT_1x1, |
| 1425 | V4L2_MPEG_VIDEO_ASPECT_221x100, 1, |
| 1426 | V4L2_MPEG_VIDEO_ASPECT_4x3); |
| 1427 | case V4L2_CID_MPEG_VIDEO_B_FRAMES: |
| 1428 | return v4l2_ctrl_query_fill(qctrl, 0, 33, 1, 2); |
| 1429 | case V4L2_CID_MPEG_VIDEO_GOP_SIZE: |
| 1430 | return v4l2_ctrl_query_fill(qctrl, 1, 34, 1, 12); |
| 1431 | case V4L2_CID_MPEG_VIDEO_GOP_CLOSURE: |
| 1432 | return v4l2_ctrl_query_fill(qctrl, 0, 1, 1, 1); |
| 1433 | case V4L2_CID_MPEG_VIDEO_PULLDOWN: |
| 1434 | return v4l2_ctrl_query_fill(qctrl, 0, 1, 1, 0); |
| 1435 | case V4L2_CID_MPEG_VIDEO_BITRATE_MODE: |
| 1436 | return v4l2_ctrl_query_fill(qctrl, |
| 1437 | V4L2_MPEG_VIDEO_BITRATE_MODE_VBR, |
| 1438 | V4L2_MPEG_VIDEO_BITRATE_MODE_CBR, 1, |
| 1439 | V4L2_MPEG_VIDEO_BITRATE_MODE_VBR); |
| 1440 | case V4L2_CID_MPEG_VIDEO_BITRATE: |
| 1441 | return v4l2_ctrl_query_fill(qctrl, 0, 27000000, 1, 6000000); |
| 1442 | case V4L2_CID_MPEG_VIDEO_BITRATE_PEAK: |
| 1443 | return v4l2_ctrl_query_fill(qctrl, 0, 27000000, 1, 8000000); |
| 1444 | case V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION: |
| 1445 | return v4l2_ctrl_query_fill(qctrl, 0, 255, 1, 0); |
| 1446 | case V4L2_CID_MPEG_STREAM_TYPE: |
| 1447 | return v4l2_ctrl_query_fill(qctrl, |
| 1448 | V4L2_MPEG_STREAM_TYPE_MPEG2_PS, |
| 1449 | V4L2_MPEG_STREAM_TYPE_MPEG2_SVCD, 1, |
| 1450 | V4L2_MPEG_STREAM_TYPE_MPEG2_PS); |
| 1451 | case V4L2_CID_MPEG_STREAM_PID_PMT: |
| 1452 | return v4l2_ctrl_query_fill(qctrl, 0, (1 << 14) - 1, 1, 16); |
| 1453 | case V4L2_CID_MPEG_STREAM_PID_AUDIO: |
| 1454 | return v4l2_ctrl_query_fill(qctrl, 0, (1 << 14) - 1, 1, 260); |
| 1455 | case V4L2_CID_MPEG_STREAM_PID_VIDEO: |
| 1456 | return v4l2_ctrl_query_fill(qctrl, 0, (1 << 14) - 1, 1, 256); |
| 1457 | case V4L2_CID_MPEG_STREAM_PID_PCR: |
| 1458 | return v4l2_ctrl_query_fill(qctrl, 0, (1 << 14) - 1, 1, 259); |
| 1459 | case V4L2_CID_MPEG_STREAM_PES_ID_AUDIO: |
| 1460 | return v4l2_ctrl_query_fill(qctrl, 0, 255, 1, 0); |
| 1461 | case V4L2_CID_MPEG_STREAM_PES_ID_VIDEO: |
| 1462 | return v4l2_ctrl_query_fill(qctrl, 0, 255, 1, 0); |
Hans Verkuil | 8cbde94 | 2006-06-24 14:36:02 -0300 | [diff] [blame] | 1463 | case V4L2_CID_MPEG_STREAM_VBI_FMT: |
| 1464 | return v4l2_ctrl_query_fill(qctrl, |
| 1465 | V4L2_MPEG_STREAM_VBI_FMT_NONE, |
| 1466 | V4L2_MPEG_STREAM_VBI_FMT_IVTV, 1, |
| 1467 | V4L2_MPEG_STREAM_VBI_FMT_NONE); |
Hans Verkuil | 9cb2318 | 2006-06-18 14:11:08 -0300 | [diff] [blame] | 1468 | default: |
| 1469 | return -EINVAL; |
| 1470 | } |
| 1471 | } |
| 1472 | |
| 1473 | /* Fill in a struct v4l2_querymenu based on the struct v4l2_queryctrl and |
| 1474 | the menu. The qctrl pointer may be NULL, in which case it is ignored. */ |
| 1475 | int v4l2_ctrl_query_menu(struct v4l2_querymenu *qmenu, struct v4l2_queryctrl *qctrl, |
| 1476 | const char **menu_items) |
| 1477 | { |
| 1478 | int i; |
| 1479 | |
| 1480 | if (menu_items == NULL || |
| 1481 | (qctrl && (qmenu->index < qctrl->minimum || qmenu->index > qctrl->maximum))) |
| 1482 | return -EINVAL; |
| 1483 | for (i = 0; i < qmenu->index && menu_items[i]; i++) ; |
| 1484 | if (menu_items[i] == NULL || menu_items[i][0] == '\0') |
| 1485 | return -EINVAL; |
| 1486 | snprintf(qmenu->name, sizeof(qmenu->name), menu_items[qmenu->index]); |
| 1487 | qmenu->reserved = 0; |
| 1488 | return 0; |
| 1489 | } |
| 1490 | |
| 1491 | /* ctrl_classes points to an array of u32 pointers, the last element is |
| 1492 | a NULL pointer. Each u32 array is a 0-terminated array of control IDs. |
| 1493 | Each array must be sorted low to high and belong to the same control |
| 1494 | class. The array of u32 pointer must also be sorted, from low class IDs |
| 1495 | to high class IDs. |
| 1496 | |
| 1497 | This function returns the first ID that follows after the given ID. |
| 1498 | When no more controls are available 0 is returned. */ |
| 1499 | u32 v4l2_ctrl_next(const u32 * const * ctrl_classes, u32 id) |
| 1500 | { |
| 1501 | u32 ctrl_class; |
| 1502 | const u32 *pctrl; |
| 1503 | |
| 1504 | /* if no query is desired, then just return the control ID */ |
| 1505 | if ((id & V4L2_CTRL_FLAG_NEXT_CTRL) == 0) |
| 1506 | return id; |
| 1507 | if (ctrl_classes == NULL) |
| 1508 | return 0; |
| 1509 | id &= V4L2_CTRL_ID_MASK; |
| 1510 | ctrl_class = V4L2_CTRL_ID2CLASS(id); |
| 1511 | id++; /* select next control */ |
| 1512 | /* find first class that matches (or is greater than) the class of |
| 1513 | the ID */ |
| 1514 | while (*ctrl_classes && V4L2_CTRL_ID2CLASS(**ctrl_classes) < ctrl_class) |
| 1515 | ctrl_classes++; |
| 1516 | /* no more classes */ |
| 1517 | if (*ctrl_classes == NULL) |
| 1518 | return 0; |
| 1519 | pctrl = *ctrl_classes; |
| 1520 | /* find first ctrl within the class that is >= ID */ |
| 1521 | while (*pctrl && *pctrl < id) pctrl++; |
| 1522 | if (*pctrl) |
| 1523 | return *pctrl; |
| 1524 | /* we are at the end of the controls of the current class. */ |
| 1525 | /* continue with next class if available */ |
| 1526 | ctrl_classes++; |
| 1527 | if (*ctrl_classes == NULL) |
| 1528 | return 0; |
| 1529 | return **ctrl_classes; |
| 1530 | } |
| 1531 | |
| 1532 | /* ----------------------------------------------------------------- */ |
| 1533 | |
Mauro Carvalho Chehab | e75f9ce | 2006-11-20 13:19:20 -0300 | [diff] [blame] | 1534 | EXPORT_SYMBOL(v4l2_norm_to_name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1535 | EXPORT_SYMBOL(v4l2_video_std_construct); |
| 1536 | |
| 1537 | EXPORT_SYMBOL(v4l2_prio_init); |
| 1538 | EXPORT_SYMBOL(v4l2_prio_change); |
| 1539 | EXPORT_SYMBOL(v4l2_prio_open); |
| 1540 | EXPORT_SYMBOL(v4l2_prio_close); |
| 1541 | EXPORT_SYMBOL(v4l2_prio_max); |
| 1542 | EXPORT_SYMBOL(v4l2_prio_check); |
| 1543 | |
| 1544 | EXPORT_SYMBOL(v4l2_field_names); |
| 1545 | EXPORT_SYMBOL(v4l2_type_names); |
Michael Krufky | 5e453dc | 2006-01-09 15:32:31 -0200 | [diff] [blame] | 1546 | EXPORT_SYMBOL(v4l_printk_ioctl); |
Mauro Carvalho Chehab | 41f38b4 | 2006-02-27 00:08:49 -0300 | [diff] [blame] | 1547 | EXPORT_SYMBOL(v4l_printk_ioctl_arg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1548 | |
Hans Verkuil | 9cb2318 | 2006-06-18 14:11:08 -0300 | [diff] [blame] | 1549 | EXPORT_SYMBOL(v4l2_ctrl_next); |
| 1550 | EXPORT_SYMBOL(v4l2_ctrl_check); |
| 1551 | EXPORT_SYMBOL(v4l2_ctrl_get_menu); |
| 1552 | EXPORT_SYMBOL(v4l2_ctrl_query_menu); |
| 1553 | EXPORT_SYMBOL(v4l2_ctrl_query_fill); |
| 1554 | EXPORT_SYMBOL(v4l2_ctrl_query_fill_std); |
| 1555 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1556 | /* |
| 1557 | * Local variables: |
| 1558 | * c-basic-offset: 8 |
| 1559 | * End: |
| 1560 | */ |