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