diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-07-30 13:22:44 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-07-30 13:22:44 -0400 |
commit | c893e7c64e36087dceb4662917976a81d1754fc0 (patch) | |
tree | 30e441fe3e13fc8fcf9690bfe5222f404e19daa0 /drivers/media/video/v4l2-ioctl.c | |
parent | ec3ed85f926f4e900bc48cec6e72abbe6475321f (diff) | |
parent | 2cefabc00ffdc1f22f960df946ae41b163081d5e (diff) |
Merge branch 'patches_for_v3.6' into v4l_for_linus
* patches_for_v3.6: (174 commits)
v4l: Export v4l2-common.h in include/linux/Kbuild
media: Revert "[media] Terratec Cinergy S2 USB HD Rev.2"
[media] media: Use pr_info not homegrown pr_reg macro
[media] Terratec Cinergy S2 USB HD Rev.2
[media] v4l: Correct conflicting V4L2 subdev selection API documentation
[media] Feature removal: V4L2 selections API target and flag definitions
[media] v4l: Unify selection flags documentation
[media] v4l: Unify selection flags
[media] v4l: Common documentation for selection targets
[media] v4l: Unify selection targets across V4L2 and V4L2 subdev interfaces
[media] v4l: Remove "_ACTUAL" from subdev selection API target definition names
[media] V4L: Remove "_ACTIVE" from the selection target name definitions
[media] media: dvb-usb: print mac address via native %pM
[media] s5p-tv: Use module_i2c_driver in sii9234_drv.c file
[media] media: gpio-ir-recv: add allowed_protos for platform data
[media] s5p-jpeg: Use module_platform_driver in jpeg-core.c file
[media] saa7134: fix spelling of detach in label
[media] cx88-blackbird: replace ioctl by unlocked_ioctl
[media] cx88: don't use current_norm
[media] cx88: fix a number of v4l2-compliance violations
...
Diffstat (limited to 'drivers/media/video/v4l2-ioctl.c')
-rw-r--r-- | drivers/media/video/v4l2-ioctl.c | 3285 |
1 files changed, 1614 insertions, 1671 deletions
diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index d7fa8962d8b3..70e0efb127a6 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c | |||
@@ -27,27 +27,7 @@ | |||
27 | #include <media/v4l2-event.h> | 27 | #include <media/v4l2-event.h> |
28 | #include <media/v4l2-device.h> | 28 | #include <media/v4l2-device.h> |
29 | #include <media/v4l2-chip-ident.h> | 29 | #include <media/v4l2-chip-ident.h> |
30 | 30 | #include <media/videobuf2-core.h> | |
31 | #define dbgarg(cmd, fmt, arg...) \ | ||
32 | do { \ | ||
33 | if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) { \ | ||
34 | printk(KERN_DEBUG "%s: ", vfd->name); \ | ||
35 | v4l_printk_ioctl(cmd); \ | ||
36 | printk(" " fmt, ## arg); \ | ||
37 | } \ | ||
38 | } while (0) | ||
39 | |||
40 | #define dbgarg2(fmt, arg...) \ | ||
41 | do { \ | ||
42 | if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) \ | ||
43 | printk(KERN_DEBUG "%s: " fmt, vfd->name, ## arg);\ | ||
44 | } while (0) | ||
45 | |||
46 | #define dbgarg3(fmt, arg...) \ | ||
47 | do { \ | ||
48 | if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) \ | ||
49 | printk(KERN_CONT "%s: " fmt, vfd->name, ## arg);\ | ||
50 | } while (0) | ||
51 | 31 | ||
52 | /* Zero out the end of the struct pointed to by p. Everything after, but | 32 | /* Zero out the end of the struct pointed to by p. Everything after, but |
53 | * not including, the specified field is cleared. */ | 33 | * not including, the specified field is cleared. */ |
@@ -183,207 +163,507 @@ static const char *v4l2_memory_names[] = { | |||
183 | /* ------------------------------------------------------------------ */ | 163 | /* ------------------------------------------------------------------ */ |
184 | /* debug help functions */ | 164 | /* debug help functions */ |
185 | 165 | ||
186 | struct v4l2_ioctl_info { | 166 | static void v4l_print_querycap(const void *arg, bool write_only) |
187 | unsigned int ioctl; | 167 | { |
188 | u16 flags; | 168 | const struct v4l2_capability *p = arg; |
189 | const char * const name; | ||
190 | }; | ||
191 | 169 | ||
192 | /* This control needs a priority check */ | 170 | pr_cont("driver=%s, card=%s, bus=%s, version=0x%08x, " |
193 | #define INFO_FL_PRIO (1 << 0) | 171 | "capabilities=0x%08x, device_caps=0x%08x\n", |
194 | /* This control can be valid if the filehandle passes a control handler. */ | 172 | p->driver, p->card, p->bus_info, |
195 | #define INFO_FL_CTRL (1 << 1) | 173 | p->version, p->capabilities, p->device_caps); |
174 | } | ||
196 | 175 | ||
197 | #define IOCTL_INFO(_ioctl, _flags) [_IOC_NR(_ioctl)] = { \ | 176 | static void v4l_print_enuminput(const void *arg, bool write_only) |
198 | .ioctl = _ioctl, \ | 177 | { |
199 | .flags = _flags, \ | 178 | const struct v4l2_input *p = arg; |
200 | .name = #_ioctl, \ | 179 | |
180 | pr_cont("index=%u, name=%s, type=%u, audioset=0x%x, tuner=%u, " | ||
181 | "std=0x%08Lx, status=0x%x, capabilities=0x%x\n", | ||
182 | p->index, p->name, p->type, p->audioset, p->tuner, | ||
183 | (unsigned long long)p->std, p->status, p->capabilities); | ||
201 | } | 184 | } |
202 | 185 | ||
203 | static struct v4l2_ioctl_info v4l2_ioctls[] = { | 186 | static void v4l_print_enumoutput(const void *arg, bool write_only) |
204 | IOCTL_INFO(VIDIOC_QUERYCAP, 0), | 187 | { |
205 | IOCTL_INFO(VIDIOC_ENUM_FMT, 0), | 188 | const struct v4l2_output *p = arg; |
206 | IOCTL_INFO(VIDIOC_G_FMT, 0), | ||
207 | IOCTL_INFO(VIDIOC_S_FMT, INFO_FL_PRIO), | ||
208 | IOCTL_INFO(VIDIOC_REQBUFS, INFO_FL_PRIO), | ||
209 | IOCTL_INFO(VIDIOC_QUERYBUF, 0), | ||
210 | IOCTL_INFO(VIDIOC_G_FBUF, 0), | ||
211 | IOCTL_INFO(VIDIOC_S_FBUF, INFO_FL_PRIO), | ||
212 | IOCTL_INFO(VIDIOC_OVERLAY, INFO_FL_PRIO), | ||
213 | IOCTL_INFO(VIDIOC_QBUF, 0), | ||
214 | IOCTL_INFO(VIDIOC_DQBUF, 0), | ||
215 | IOCTL_INFO(VIDIOC_STREAMON, INFO_FL_PRIO), | ||
216 | IOCTL_INFO(VIDIOC_STREAMOFF, INFO_FL_PRIO), | ||
217 | IOCTL_INFO(VIDIOC_G_PARM, 0), | ||
218 | IOCTL_INFO(VIDIOC_S_PARM, INFO_FL_PRIO), | ||
219 | IOCTL_INFO(VIDIOC_G_STD, 0), | ||
220 | IOCTL_INFO(VIDIOC_S_STD, INFO_FL_PRIO), | ||
221 | IOCTL_INFO(VIDIOC_ENUMSTD, 0), | ||
222 | IOCTL_INFO(VIDIOC_ENUMINPUT, 0), | ||
223 | IOCTL_INFO(VIDIOC_G_CTRL, INFO_FL_CTRL), | ||
224 | IOCTL_INFO(VIDIOC_S_CTRL, INFO_FL_PRIO | INFO_FL_CTRL), | ||
225 | IOCTL_INFO(VIDIOC_G_TUNER, 0), | ||
226 | IOCTL_INFO(VIDIOC_S_TUNER, INFO_FL_PRIO), | ||
227 | IOCTL_INFO(VIDIOC_G_AUDIO, 0), | ||
228 | IOCTL_INFO(VIDIOC_S_AUDIO, INFO_FL_PRIO), | ||
229 | IOCTL_INFO(VIDIOC_QUERYCTRL, INFO_FL_CTRL), | ||
230 | IOCTL_INFO(VIDIOC_QUERYMENU, INFO_FL_CTRL), | ||
231 | IOCTL_INFO(VIDIOC_G_INPUT, 0), | ||
232 | IOCTL_INFO(VIDIOC_S_INPUT, INFO_FL_PRIO), | ||
233 | IOCTL_INFO(VIDIOC_G_OUTPUT, 0), | ||
234 | IOCTL_INFO(VIDIOC_S_OUTPUT, INFO_FL_PRIO), | ||
235 | IOCTL_INFO(VIDIOC_ENUMOUTPUT, 0), | ||
236 | IOCTL_INFO(VIDIOC_G_AUDOUT, 0), | ||
237 | IOCTL_INFO(VIDIOC_S_AUDOUT, INFO_FL_PRIO), | ||
238 | IOCTL_INFO(VIDIOC_G_MODULATOR, 0), | ||
239 | IOCTL_INFO(VIDIOC_S_MODULATOR, INFO_FL_PRIO), | ||
240 | IOCTL_INFO(VIDIOC_G_FREQUENCY, 0), | ||
241 | IOCTL_INFO(VIDIOC_S_FREQUENCY, INFO_FL_PRIO), | ||
242 | IOCTL_INFO(VIDIOC_CROPCAP, 0), | ||
243 | IOCTL_INFO(VIDIOC_G_CROP, 0), | ||
244 | IOCTL_INFO(VIDIOC_S_CROP, INFO_FL_PRIO), | ||
245 | IOCTL_INFO(VIDIOC_G_SELECTION, 0), | ||
246 | IOCTL_INFO(VIDIOC_S_SELECTION, INFO_FL_PRIO), | ||
247 | IOCTL_INFO(VIDIOC_G_JPEGCOMP, 0), | ||
248 | IOCTL_INFO(VIDIOC_S_JPEGCOMP, INFO_FL_PRIO), | ||
249 | IOCTL_INFO(VIDIOC_QUERYSTD, 0), | ||
250 | IOCTL_INFO(VIDIOC_TRY_FMT, 0), | ||
251 | IOCTL_INFO(VIDIOC_ENUMAUDIO, 0), | ||
252 | IOCTL_INFO(VIDIOC_ENUMAUDOUT, 0), | ||
253 | IOCTL_INFO(VIDIOC_G_PRIORITY, 0), | ||
254 | IOCTL_INFO(VIDIOC_S_PRIORITY, INFO_FL_PRIO), | ||
255 | IOCTL_INFO(VIDIOC_G_SLICED_VBI_CAP, 0), | ||
256 | IOCTL_INFO(VIDIOC_LOG_STATUS, 0), | ||
257 | IOCTL_INFO(VIDIOC_G_EXT_CTRLS, INFO_FL_CTRL), | ||
258 | IOCTL_INFO(VIDIOC_S_EXT_CTRLS, INFO_FL_PRIO | INFO_FL_CTRL), | ||
259 | IOCTL_INFO(VIDIOC_TRY_EXT_CTRLS, 0), | ||
260 | IOCTL_INFO(VIDIOC_ENUM_FRAMESIZES, 0), | ||
261 | IOCTL_INFO(VIDIOC_ENUM_FRAMEINTERVALS, 0), | ||
262 | IOCTL_INFO(VIDIOC_G_ENC_INDEX, 0), | ||
263 | IOCTL_INFO(VIDIOC_ENCODER_CMD, INFO_FL_PRIO), | ||
264 | IOCTL_INFO(VIDIOC_TRY_ENCODER_CMD, 0), | ||
265 | IOCTL_INFO(VIDIOC_DECODER_CMD, INFO_FL_PRIO), | ||
266 | IOCTL_INFO(VIDIOC_TRY_DECODER_CMD, 0), | ||
267 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
268 | IOCTL_INFO(VIDIOC_DBG_S_REGISTER, 0), | ||
269 | IOCTL_INFO(VIDIOC_DBG_G_REGISTER, 0), | ||
270 | #endif | ||
271 | IOCTL_INFO(VIDIOC_DBG_G_CHIP_IDENT, 0), | ||
272 | IOCTL_INFO(VIDIOC_S_HW_FREQ_SEEK, INFO_FL_PRIO), | ||
273 | IOCTL_INFO(VIDIOC_ENUM_DV_PRESETS, 0), | ||
274 | IOCTL_INFO(VIDIOC_S_DV_PRESET, INFO_FL_PRIO), | ||
275 | IOCTL_INFO(VIDIOC_G_DV_PRESET, 0), | ||
276 | IOCTL_INFO(VIDIOC_QUERY_DV_PRESET, 0), | ||
277 | IOCTL_INFO(VIDIOC_S_DV_TIMINGS, INFO_FL_PRIO), | ||
278 | IOCTL_INFO(VIDIOC_G_DV_TIMINGS, 0), | ||
279 | IOCTL_INFO(VIDIOC_DQEVENT, 0), | ||
280 | IOCTL_INFO(VIDIOC_SUBSCRIBE_EVENT, 0), | ||
281 | IOCTL_INFO(VIDIOC_UNSUBSCRIBE_EVENT, 0), | ||
282 | IOCTL_INFO(VIDIOC_CREATE_BUFS, INFO_FL_PRIO), | ||
283 | IOCTL_INFO(VIDIOC_PREPARE_BUF, 0), | ||
284 | IOCTL_INFO(VIDIOC_ENUM_DV_TIMINGS, 0), | ||
285 | IOCTL_INFO(VIDIOC_QUERY_DV_TIMINGS, 0), | ||
286 | IOCTL_INFO(VIDIOC_DV_TIMINGS_CAP, 0), | ||
287 | }; | ||
288 | #define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls) | ||
289 | 189 | ||
290 | bool v4l2_is_known_ioctl(unsigned int cmd) | 190 | pr_cont("index=%u, name=%s, type=%u, audioset=0x%x, " |
191 | "modulator=%u, std=0x%08Lx, capabilities=0x%x\n", | ||
192 | p->index, p->name, p->type, p->audioset, p->modulator, | ||
193 | (unsigned long long)p->std, p->capabilities); | ||
194 | } | ||
195 | |||
196 | static void v4l_print_audio(const void *arg, bool write_only) | ||
291 | { | 197 | { |
292 | if (_IOC_NR(cmd) >= V4L2_IOCTLS) | 198 | const struct v4l2_audio *p = arg; |
293 | return false; | 199 | |
294 | return v4l2_ioctls[_IOC_NR(cmd)].ioctl == cmd; | 200 | if (write_only) |
201 | pr_cont("index=%u, mode=0x%x\n", p->index, p->mode); | ||
202 | else | ||
203 | pr_cont("index=%u, name=%s, capability=0x%x, mode=0x%x\n", | ||
204 | p->index, p->name, p->capability, p->mode); | ||
295 | } | 205 | } |
296 | 206 | ||
297 | /* Common ioctl debug function. This function can be used by | 207 | static void v4l_print_audioout(const void *arg, bool write_only) |
298 | external ioctl messages as well as internal V4L ioctl */ | ||
299 | void v4l_printk_ioctl(unsigned int cmd) | ||
300 | { | 208 | { |
301 | char *dir, *type; | 209 | const struct v4l2_audioout *p = arg; |
302 | 210 | ||
303 | switch (_IOC_TYPE(cmd)) { | 211 | if (write_only) |
304 | case 'd': | 212 | pr_cont("index=%u\n", p->index); |
305 | type = "v4l2_int"; | 213 | else |
214 | pr_cont("index=%u, name=%s, capability=0x%x, mode=0x%x\n", | ||
215 | p->index, p->name, p->capability, p->mode); | ||
216 | } | ||
217 | |||
218 | static void v4l_print_fmtdesc(const void *arg, bool write_only) | ||
219 | { | ||
220 | const struct v4l2_fmtdesc *p = arg; | ||
221 | |||
222 | pr_cont("index=%u, type=%s, flags=0x%x, pixelformat=%c%c%c%c, description='%s'\n", | ||
223 | p->index, prt_names(p->type, v4l2_type_names), | ||
224 | p->flags, (p->pixelformat & 0xff), | ||
225 | (p->pixelformat >> 8) & 0xff, | ||
226 | (p->pixelformat >> 16) & 0xff, | ||
227 | (p->pixelformat >> 24) & 0xff, | ||
228 | p->description); | ||
229 | } | ||
230 | |||
231 | static void v4l_print_format(const void *arg, bool write_only) | ||
232 | { | ||
233 | const struct v4l2_format *p = arg; | ||
234 | const struct v4l2_pix_format *pix; | ||
235 | const struct v4l2_pix_format_mplane *mp; | ||
236 | const struct v4l2_vbi_format *vbi; | ||
237 | const struct v4l2_sliced_vbi_format *sliced; | ||
238 | const struct v4l2_window *win; | ||
239 | const struct v4l2_clip *clip; | ||
240 | unsigned i; | ||
241 | |||
242 | pr_cont("type=%s", prt_names(p->type, v4l2_type_names)); | ||
243 | switch (p->type) { | ||
244 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | ||
245 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: | ||
246 | pix = &p->fmt.pix; | ||
247 | pr_cont(", width=%u, height=%u, " | ||
248 | "pixelformat=%c%c%c%c, field=%s, " | ||
249 | "bytesperline=%u sizeimage=%u, colorspace=%d\n", | ||
250 | pix->width, pix->height, | ||
251 | (pix->pixelformat & 0xff), | ||
252 | (pix->pixelformat >> 8) & 0xff, | ||
253 | (pix->pixelformat >> 16) & 0xff, | ||
254 | (pix->pixelformat >> 24) & 0xff, | ||
255 | prt_names(pix->field, v4l2_field_names), | ||
256 | pix->bytesperline, pix->sizeimage, | ||
257 | pix->colorspace); | ||
306 | break; | 258 | break; |
307 | case 'V': | 259 | case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: |
308 | if (_IOC_NR(cmd) >= V4L2_IOCTLS) { | 260 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: |
309 | type = "v4l2"; | 261 | mp = &p->fmt.pix_mp; |
310 | break; | 262 | pr_cont(", width=%u, height=%u, " |
263 | "format=%c%c%c%c, field=%s, " | ||
264 | "colorspace=%d, num_planes=%u\n", | ||
265 | mp->width, mp->height, | ||
266 | (mp->pixelformat & 0xff), | ||
267 | (mp->pixelformat >> 8) & 0xff, | ||
268 | (mp->pixelformat >> 16) & 0xff, | ||
269 | (mp->pixelformat >> 24) & 0xff, | ||
270 | prt_names(mp->field, v4l2_field_names), | ||
271 | mp->colorspace, mp->num_planes); | ||
272 | for (i = 0; i < mp->num_planes; i++) | ||
273 | printk(KERN_DEBUG "plane %u: bytesperline=%u sizeimage=%u\n", i, | ||
274 | mp->plane_fmt[i].bytesperline, | ||
275 | mp->plane_fmt[i].sizeimage); | ||
276 | break; | ||
277 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: | ||
278 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: | ||
279 | win = &p->fmt.win; | ||
280 | pr_cont(", wxh=%dx%d, x,y=%d,%d, field=%s, " | ||
281 | "chromakey=0x%08x, bitmap=%p, " | ||
282 | "global_alpha=0x%02x\n", | ||
283 | win->w.width, win->w.height, | ||
284 | win->w.left, win->w.top, | ||
285 | prt_names(win->field, v4l2_field_names), | ||
286 | win->chromakey, win->bitmap, win->global_alpha); | ||
287 | clip = win->clips; | ||
288 | for (i = 0; i < win->clipcount; i++) { | ||
289 | printk(KERN_DEBUG "clip %u: wxh=%dx%d, x,y=%d,%d\n", | ||
290 | i, clip->c.width, clip->c.height, | ||
291 | clip->c.left, clip->c.top); | ||
292 | clip = clip->next; | ||
311 | } | 293 | } |
312 | printk("%s", v4l2_ioctls[_IOC_NR(cmd)].name); | 294 | break; |
313 | return; | 295 | case V4L2_BUF_TYPE_VBI_CAPTURE: |
314 | default: | 296 | case V4L2_BUF_TYPE_VBI_OUTPUT: |
315 | type = "unknown"; | 297 | vbi = &p->fmt.vbi; |
298 | pr_cont(", sampling_rate=%u, offset=%u, samples_per_line=%u, " | ||
299 | "sample_format=%c%c%c%c, start=%u,%u, count=%u,%u\n", | ||
300 | vbi->sampling_rate, vbi->offset, | ||
301 | vbi->samples_per_line, | ||
302 | (vbi->sample_format & 0xff), | ||
303 | (vbi->sample_format >> 8) & 0xff, | ||
304 | (vbi->sample_format >> 16) & 0xff, | ||
305 | (vbi->sample_format >> 24) & 0xff, | ||
306 | vbi->start[0], vbi->start[1], | ||
307 | vbi->count[0], vbi->count[1]); | ||
308 | break; | ||
309 | case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: | ||
310 | case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: | ||
311 | sliced = &p->fmt.sliced; | ||
312 | pr_cont(", service_set=0x%08x, io_size=%d\n", | ||
313 | sliced->service_set, sliced->io_size); | ||
314 | for (i = 0; i < 24; i++) | ||
315 | printk(KERN_DEBUG "line[%02u]=0x%04x, 0x%04x\n", i, | ||
316 | sliced->service_lines[0][i], | ||
317 | sliced->service_lines[1][i]); | ||
318 | break; | ||
319 | case V4L2_BUF_TYPE_PRIVATE: | ||
320 | pr_cont("\n"); | ||
321 | break; | ||
316 | } | 322 | } |
323 | } | ||
317 | 324 | ||
318 | switch (_IOC_DIR(cmd)) { | 325 | static void v4l_print_framebuffer(const void *arg, bool write_only) |
319 | case _IOC_NONE: dir = "--"; break; | 326 | { |
320 | case _IOC_READ: dir = "r-"; break; | 327 | const struct v4l2_framebuffer *p = arg; |
321 | case _IOC_WRITE: dir = "-w"; break; | 328 | |
322 | case _IOC_READ | _IOC_WRITE: dir = "rw"; break; | 329 | pr_cont("capability=0x%x, flags=0x%x, base=0x%p, width=%u, " |
323 | default: dir = "*ERR*"; break; | 330 | "height=%u, pixelformat=%c%c%c%c, " |
324 | } | 331 | "bytesperline=%u sizeimage=%u, colorspace=%d\n", |
325 | printk("%s ioctl '%c', dir=%s, #%d (0x%08x)", | 332 | p->capability, p->flags, p->base, |
326 | type, _IOC_TYPE(cmd), dir, _IOC_NR(cmd), cmd); | 333 | p->fmt.width, p->fmt.height, |
334 | (p->fmt.pixelformat & 0xff), | ||
335 | (p->fmt.pixelformat >> 8) & 0xff, | ||
336 | (p->fmt.pixelformat >> 16) & 0xff, | ||
337 | (p->fmt.pixelformat >> 24) & 0xff, | ||
338 | p->fmt.bytesperline, p->fmt.sizeimage, | ||
339 | p->fmt.colorspace); | ||
340 | } | ||
341 | |||
342 | static void v4l_print_buftype(const void *arg, bool write_only) | ||
343 | { | ||
344 | pr_cont("type=%s\n", prt_names(*(u32 *)arg, v4l2_type_names)); | ||
345 | } | ||
346 | |||
347 | static void v4l_print_modulator(const void *arg, bool write_only) | ||
348 | { | ||
349 | const struct v4l2_modulator *p = arg; | ||
350 | |||
351 | if (write_only) | ||
352 | pr_cont("index=%u, txsubchans=0x%x", p->index, p->txsubchans); | ||
353 | else | ||
354 | pr_cont("index=%u, name=%s, capability=0x%x, " | ||
355 | "rangelow=%u, rangehigh=%u, txsubchans=0x%x\n", | ||
356 | p->index, p->name, p->capability, | ||
357 | p->rangelow, p->rangehigh, p->txsubchans); | ||
358 | } | ||
359 | |||
360 | static void v4l_print_tuner(const void *arg, bool write_only) | ||
361 | { | ||
362 | const struct v4l2_tuner *p = arg; | ||
363 | |||
364 | if (write_only) | ||
365 | pr_cont("index=%u, audmode=%u\n", p->index, p->audmode); | ||
366 | else | ||
367 | pr_cont("index=%u, name=%s, type=%u, capability=0x%x, " | ||
368 | "rangelow=%u, rangehigh=%u, signal=%u, afc=%d, " | ||
369 | "rxsubchans=0x%x, audmode=%u\n", | ||
370 | p->index, p->name, p->type, | ||
371 | p->capability, p->rangelow, | ||
372 | p->rangehigh, p->signal, p->afc, | ||
373 | p->rxsubchans, p->audmode); | ||
374 | } | ||
375 | |||
376 | static void v4l_print_frequency(const void *arg, bool write_only) | ||
377 | { | ||
378 | const struct v4l2_frequency *p = arg; | ||
379 | |||
380 | pr_cont("tuner=%u, type=%u, frequency=%u\n", | ||
381 | p->tuner, p->type, p->frequency); | ||
382 | } | ||
383 | |||
384 | static void v4l_print_standard(const void *arg, bool write_only) | ||
385 | { | ||
386 | const struct v4l2_standard *p = arg; | ||
387 | |||
388 | pr_cont("index=%u, id=0x%Lx, name=%s, fps=%u/%u, " | ||
389 | "framelines=%u\n", p->index, | ||
390 | (unsigned long long)p->id, p->name, | ||
391 | p->frameperiod.numerator, | ||
392 | p->frameperiod.denominator, | ||
393 | p->framelines); | ||
394 | } | ||
395 | |||
396 | static void v4l_print_std(const void *arg, bool write_only) | ||
397 | { | ||
398 | pr_cont("std=0x%08Lx\n", *(const long long unsigned *)arg); | ||
327 | } | 399 | } |
328 | EXPORT_SYMBOL(v4l_printk_ioctl); | ||
329 | 400 | ||
330 | static void dbgbuf(unsigned int cmd, struct video_device *vfd, | 401 | static void v4l_print_hw_freq_seek(const void *arg, bool write_only) |
331 | struct v4l2_buffer *p) | ||
332 | { | 402 | { |
333 | struct v4l2_timecode *tc = &p->timecode; | 403 | const struct v4l2_hw_freq_seek *p = arg; |
334 | struct v4l2_plane *plane; | 404 | |
405 | pr_cont("tuner=%u, type=%u, seek_upward=%u, wrap_around=%u, spacing=%u\n", | ||
406 | p->tuner, p->type, p->seek_upward, p->wrap_around, p->spacing); | ||
407 | } | ||
408 | |||
409 | static void v4l_print_requestbuffers(const void *arg, bool write_only) | ||
410 | { | ||
411 | const struct v4l2_requestbuffers *p = arg; | ||
412 | |||
413 | pr_cont("count=%d, type=%s, memory=%s\n", | ||
414 | p->count, | ||
415 | prt_names(p->type, v4l2_type_names), | ||
416 | prt_names(p->memory, v4l2_memory_names)); | ||
417 | } | ||
418 | |||
419 | static void v4l_print_buffer(const void *arg, bool write_only) | ||
420 | { | ||
421 | const struct v4l2_buffer *p = arg; | ||
422 | const struct v4l2_timecode *tc = &p->timecode; | ||
423 | const struct v4l2_plane *plane; | ||
335 | int i; | 424 | int i; |
336 | 425 | ||
337 | dbgarg(cmd, "%02ld:%02d:%02d.%08ld index=%d, type=%s, " | 426 | pr_cont("%02ld:%02d:%02d.%08ld index=%d, type=%s, " |
338 | "flags=0x%08d, field=%0d, sequence=%d, memory=%s\n", | 427 | "flags=0x%08x, field=%s, sequence=%d, memory=%s", |
339 | p->timestamp.tv_sec / 3600, | 428 | p->timestamp.tv_sec / 3600, |
340 | (int)(p->timestamp.tv_sec / 60) % 60, | 429 | (int)(p->timestamp.tv_sec / 60) % 60, |
341 | (int)(p->timestamp.tv_sec % 60), | 430 | (int)(p->timestamp.tv_sec % 60), |
342 | (long)p->timestamp.tv_usec, | 431 | (long)p->timestamp.tv_usec, |
343 | p->index, | 432 | p->index, |
344 | prt_names(p->type, v4l2_type_names), | 433 | prt_names(p->type, v4l2_type_names), |
345 | p->flags, p->field, p->sequence, | 434 | p->flags, prt_names(p->field, v4l2_field_names), |
346 | prt_names(p->memory, v4l2_memory_names)); | 435 | p->sequence, prt_names(p->memory, v4l2_memory_names)); |
347 | 436 | ||
348 | if (V4L2_TYPE_IS_MULTIPLANAR(p->type) && p->m.planes) { | 437 | if (V4L2_TYPE_IS_MULTIPLANAR(p->type) && p->m.planes) { |
438 | pr_cont("\n"); | ||
349 | for (i = 0; i < p->length; ++i) { | 439 | for (i = 0; i < p->length; ++i) { |
350 | plane = &p->m.planes[i]; | 440 | plane = &p->m.planes[i]; |
351 | dbgarg2("plane %d: bytesused=%d, data_offset=0x%08x " | 441 | printk(KERN_DEBUG |
352 | "offset/userptr=0x%08lx, length=%d\n", | 442 | "plane %d: bytesused=%d, data_offset=0x%08x " |
443 | "offset/userptr=0x%lx, length=%d\n", | ||
353 | i, plane->bytesused, plane->data_offset, | 444 | i, plane->bytesused, plane->data_offset, |
354 | plane->m.userptr, plane->length); | 445 | plane->m.userptr, plane->length); |
355 | } | 446 | } |
356 | } else { | 447 | } else { |
357 | dbgarg2("bytesused=%d, offset/userptr=0x%08lx, length=%d\n", | 448 | pr_cont("bytesused=%d, offset/userptr=0x%lx, length=%d\n", |
358 | p->bytesused, p->m.userptr, p->length); | 449 | p->bytesused, p->m.userptr, p->length); |
359 | } | 450 | } |
360 | 451 | ||
361 | dbgarg2("timecode=%02d:%02d:%02d type=%d, " | 452 | printk(KERN_DEBUG "timecode=%02d:%02d:%02d type=%d, " |
362 | "flags=0x%08d, frames=%d, userbits=0x%08x\n", | 453 | "flags=0x%08x, frames=%d, userbits=0x%08x\n", |
363 | tc->hours, tc->minutes, tc->seconds, | 454 | tc->hours, tc->minutes, tc->seconds, |
364 | tc->type, tc->flags, tc->frames, *(__u32 *)tc->userbits); | 455 | tc->type, tc->flags, tc->frames, *(__u32 *)tc->userbits); |
365 | } | 456 | } |
366 | 457 | ||
367 | static inline void dbgrect(struct video_device *vfd, char *s, | 458 | static void v4l_print_create_buffers(const void *arg, bool write_only) |
368 | struct v4l2_rect *r) | ||
369 | { | 459 | { |
370 | dbgarg2("%sRect start at %dx%d, size=%dx%d\n", s, r->left, r->top, | 460 | const struct v4l2_create_buffers *p = arg; |
371 | r->width, r->height); | 461 | |
372 | }; | 462 | pr_cont("index=%d, count=%d, memory=%s, ", |
463 | p->index, p->count, | ||
464 | prt_names(p->memory, v4l2_memory_names)); | ||
465 | v4l_print_format(&p->format, write_only); | ||
466 | } | ||
373 | 467 | ||
374 | static void dbgtimings(struct video_device *vfd, | 468 | static void v4l_print_streamparm(const void *arg, bool write_only) |
375 | const struct v4l2_dv_timings *p) | ||
376 | { | 469 | { |
470 | const struct v4l2_streamparm *p = arg; | ||
471 | |||
472 | pr_cont("type=%s", prt_names(p->type, v4l2_type_names)); | ||
473 | |||
474 | if (p->type == V4L2_BUF_TYPE_VIDEO_CAPTURE || | ||
475 | p->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { | ||
476 | const struct v4l2_captureparm *c = &p->parm.capture; | ||
477 | |||
478 | pr_cont(", capability=0x%x, capturemode=0x%x, timeperframe=%d/%d, " | ||
479 | "extendedmode=%d, readbuffers=%d\n", | ||
480 | c->capability, c->capturemode, | ||
481 | c->timeperframe.numerator, c->timeperframe.denominator, | ||
482 | c->extendedmode, c->readbuffers); | ||
483 | } else if (p->type == V4L2_BUF_TYPE_VIDEO_OUTPUT || | ||
484 | p->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { | ||
485 | const struct v4l2_outputparm *c = &p->parm.output; | ||
486 | |||
487 | pr_cont(", capability=0x%x, outputmode=0x%x, timeperframe=%d/%d, " | ||
488 | "extendedmode=%d, writebuffers=%d\n", | ||
489 | c->capability, c->outputmode, | ||
490 | c->timeperframe.numerator, c->timeperframe.denominator, | ||
491 | c->extendedmode, c->writebuffers); | ||
492 | } | ||
493 | } | ||
494 | |||
495 | static void v4l_print_queryctrl(const void *arg, bool write_only) | ||
496 | { | ||
497 | const struct v4l2_queryctrl *p = arg; | ||
498 | |||
499 | pr_cont("id=0x%x, type=%d, name=%s, min/max=%d/%d, " | ||
500 | "step=%d, default=%d, flags=0x%08x\n", | ||
501 | p->id, p->type, p->name, | ||
502 | p->minimum, p->maximum, | ||
503 | p->step, p->default_value, p->flags); | ||
504 | } | ||
505 | |||
506 | static void v4l_print_querymenu(const void *arg, bool write_only) | ||
507 | { | ||
508 | const struct v4l2_querymenu *p = arg; | ||
509 | |||
510 | pr_cont("id=0x%x, index=%d\n", p->id, p->index); | ||
511 | } | ||
512 | |||
513 | static void v4l_print_control(const void *arg, bool write_only) | ||
514 | { | ||
515 | const struct v4l2_control *p = arg; | ||
516 | |||
517 | pr_cont("id=0x%x, value=%d\n", p->id, p->value); | ||
518 | } | ||
519 | |||
520 | static void v4l_print_ext_controls(const void *arg, bool write_only) | ||
521 | { | ||
522 | const struct v4l2_ext_controls *p = arg; | ||
523 | int i; | ||
524 | |||
525 | pr_cont("class=0x%x, count=%d, error_idx=%d", | ||
526 | p->ctrl_class, p->count, p->error_idx); | ||
527 | for (i = 0; i < p->count; i++) { | ||
528 | if (p->controls[i].size) | ||
529 | pr_cont(", id/val=0x%x/0x%x", | ||
530 | p->controls[i].id, p->controls[i].value); | ||
531 | else | ||
532 | pr_cont(", id/size=0x%x/%u", | ||
533 | p->controls[i].id, p->controls[i].size); | ||
534 | } | ||
535 | pr_cont("\n"); | ||
536 | } | ||
537 | |||
538 | static void v4l_print_cropcap(const void *arg, bool write_only) | ||
539 | { | ||
540 | const struct v4l2_cropcap *p = arg; | ||
541 | |||
542 | pr_cont("type=%s, bounds wxh=%dx%d, x,y=%d,%d, " | ||
543 | "defrect wxh=%dx%d, x,y=%d,%d\n, " | ||
544 | "pixelaspect %d/%d\n", | ||
545 | prt_names(p->type, v4l2_type_names), | ||
546 | p->bounds.width, p->bounds.height, | ||
547 | p->bounds.left, p->bounds.top, | ||
548 | p->defrect.width, p->defrect.height, | ||
549 | p->defrect.left, p->defrect.top, | ||
550 | p->pixelaspect.numerator, p->pixelaspect.denominator); | ||
551 | } | ||
552 | |||
553 | static void v4l_print_crop(const void *arg, bool write_only) | ||
554 | { | ||
555 | const struct v4l2_crop *p = arg; | ||
556 | |||
557 | pr_cont("type=%s, wxh=%dx%d, x,y=%d,%d\n", | ||
558 | prt_names(p->type, v4l2_type_names), | ||
559 | p->c.width, p->c.height, | ||
560 | p->c.left, p->c.top); | ||
561 | } | ||
562 | |||
563 | static void v4l_print_selection(const void *arg, bool write_only) | ||
564 | { | ||
565 | const struct v4l2_selection *p = arg; | ||
566 | |||
567 | pr_cont("type=%s, target=%d, flags=0x%x, wxh=%dx%d, x,y=%d,%d\n", | ||
568 | prt_names(p->type, v4l2_type_names), | ||
569 | p->target, p->flags, | ||
570 | p->r.width, p->r.height, p->r.left, p->r.top); | ||
571 | } | ||
572 | |||
573 | static void v4l_print_jpegcompression(const void *arg, bool write_only) | ||
574 | { | ||
575 | const struct v4l2_jpegcompression *p = arg; | ||
576 | |||
577 | pr_cont("quality=%d, APPn=%d, APP_len=%d, " | ||
578 | "COM_len=%d, jpeg_markers=0x%x\n", | ||
579 | p->quality, p->APPn, p->APP_len, | ||
580 | p->COM_len, p->jpeg_markers); | ||
581 | } | ||
582 | |||
583 | static void v4l_print_enc_idx(const void *arg, bool write_only) | ||
584 | { | ||
585 | const struct v4l2_enc_idx *p = arg; | ||
586 | |||
587 | pr_cont("entries=%d, entries_cap=%d\n", | ||
588 | p->entries, p->entries_cap); | ||
589 | } | ||
590 | |||
591 | static void v4l_print_encoder_cmd(const void *arg, bool write_only) | ||
592 | { | ||
593 | const struct v4l2_encoder_cmd *p = arg; | ||
594 | |||
595 | pr_cont("cmd=%d, flags=0x%x\n", | ||
596 | p->cmd, p->flags); | ||
597 | } | ||
598 | |||
599 | static void v4l_print_decoder_cmd(const void *arg, bool write_only) | ||
600 | { | ||
601 | const struct v4l2_decoder_cmd *p = arg; | ||
602 | |||
603 | pr_cont("cmd=%d, flags=0x%x\n", p->cmd, p->flags); | ||
604 | |||
605 | if (p->cmd == V4L2_DEC_CMD_START) | ||
606 | pr_info("speed=%d, format=%u\n", | ||
607 | p->start.speed, p->start.format); | ||
608 | else if (p->cmd == V4L2_DEC_CMD_STOP) | ||
609 | pr_info("pts=%llu\n", p->stop.pts); | ||
610 | } | ||
611 | |||
612 | static void v4l_print_dbg_chip_ident(const void *arg, bool write_only) | ||
613 | { | ||
614 | const struct v4l2_dbg_chip_ident *p = arg; | ||
615 | |||
616 | pr_cont("type=%u, ", p->match.type); | ||
617 | if (p->match.type == V4L2_CHIP_MATCH_I2C_DRIVER) | ||
618 | pr_cont("name=%s, ", p->match.name); | ||
619 | else | ||
620 | pr_cont("addr=%u, ", p->match.addr); | ||
621 | pr_cont("chip_ident=%u, revision=0x%x\n", | ||
622 | p->ident, p->revision); | ||
623 | } | ||
624 | |||
625 | static void v4l_print_dbg_register(const void *arg, bool write_only) | ||
626 | { | ||
627 | const struct v4l2_dbg_register *p = arg; | ||
628 | |||
629 | pr_cont("type=%u, ", p->match.type); | ||
630 | if (p->match.type == V4L2_CHIP_MATCH_I2C_DRIVER) | ||
631 | pr_cont("name=%s, ", p->match.name); | ||
632 | else | ||
633 | pr_cont("addr=%u, ", p->match.addr); | ||
634 | pr_cont("reg=0x%llx, val=0x%llx\n", | ||
635 | p->reg, p->val); | ||
636 | } | ||
637 | |||
638 | static void v4l_print_dv_enum_presets(const void *arg, bool write_only) | ||
639 | { | ||
640 | const struct v4l2_dv_enum_preset *p = arg; | ||
641 | |||
642 | pr_cont("index=%u, preset=%u, name=%s, width=%u, height=%u\n", | ||
643 | p->index, p->preset, p->name, p->width, p->height); | ||
644 | } | ||
645 | |||
646 | static void v4l_print_dv_preset(const void *arg, bool write_only) | ||
647 | { | ||
648 | const struct v4l2_dv_preset *p = arg; | ||
649 | |||
650 | pr_cont("preset=%u\n", p->preset); | ||
651 | } | ||
652 | |||
653 | static void v4l_print_dv_timings(const void *arg, bool write_only) | ||
654 | { | ||
655 | const struct v4l2_dv_timings *p = arg; | ||
656 | |||
377 | switch (p->type) { | 657 | switch (p->type) { |
378 | case V4L2_DV_BT_656_1120: | 658 | case V4L2_DV_BT_656_1120: |
379 | dbgarg2("bt-656/1120:interlaced=%d," | 659 | pr_cont("type=bt-656/1120, interlaced=%u, " |
380 | " pixelclock=%lld," | 660 | "pixelclock=%llu, " |
381 | " width=%d, height=%d, polarities=%x," | 661 | "width=%u, height=%u, polarities=0x%x, " |
382 | " hfrontporch=%d, hsync=%d," | 662 | "hfrontporch=%u, hsync=%u, " |
383 | " hbackporch=%d, vfrontporch=%d," | 663 | "hbackporch=%u, vfrontporch=%u, " |
384 | " vsync=%d, vbackporch=%d," | 664 | "vsync=%u, vbackporch=%u, " |
385 | " il_vfrontporch=%d, il_vsync=%d," | 665 | "il_vfrontporch=%u, il_vsync=%u, " |
386 | " il_vbackporch=%d, standards=%x, flags=%x\n", | 666 | "il_vbackporch=%u, standards=0x%x, flags=0x%x\n", |
387 | p->bt.interlaced, p->bt.pixelclock, | 667 | p->bt.interlaced, p->bt.pixelclock, |
388 | p->bt.width, p->bt.height, | 668 | p->bt.width, p->bt.height, |
389 | p->bt.polarities, p->bt.hfrontporch, | 669 | p->bt.polarities, p->bt.hfrontporch, |
@@ -394,67 +674,173 @@ static void dbgtimings(struct video_device *vfd, | |||
394 | p->bt.standards, p->bt.flags); | 674 | p->bt.standards, p->bt.flags); |
395 | break; | 675 | break; |
396 | default: | 676 | default: |
397 | dbgarg2("Unknown type %d!\n", p->type); | 677 | pr_cont("type=%d\n", p->type); |
398 | break; | 678 | break; |
399 | } | 679 | } |
400 | } | 680 | } |
401 | 681 | ||
402 | static inline void v4l_print_pix_fmt(struct video_device *vfd, | 682 | static void v4l_print_enum_dv_timings(const void *arg, bool write_only) |
403 | struct v4l2_pix_format *fmt) | ||
404 | { | 683 | { |
405 | dbgarg2("width=%d, height=%d, format=%c%c%c%c, field=%s, " | 684 | const struct v4l2_enum_dv_timings *p = arg; |
406 | "bytesperline=%d sizeimage=%d, colorspace=%d\n", | 685 | |
407 | fmt->width, fmt->height, | 686 | pr_cont("index=%u, ", p->index); |
408 | (fmt->pixelformat & 0xff), | 687 | v4l_print_dv_timings(&p->timings, write_only); |
409 | (fmt->pixelformat >> 8) & 0xff, | 688 | } |
410 | (fmt->pixelformat >> 16) & 0xff, | ||
411 | (fmt->pixelformat >> 24) & 0xff, | ||
412 | prt_names(fmt->field, v4l2_field_names), | ||
413 | fmt->bytesperline, fmt->sizeimage, fmt->colorspace); | ||
414 | }; | ||
415 | 689 | ||
416 | static inline void v4l_print_pix_fmt_mplane(struct video_device *vfd, | 690 | static void v4l_print_dv_timings_cap(const void *arg, bool write_only) |
417 | struct v4l2_pix_format_mplane *fmt) | ||
418 | { | 691 | { |
419 | int i; | 692 | const struct v4l2_dv_timings_cap *p = arg; |
693 | |||
694 | switch (p->type) { | ||
695 | case V4L2_DV_BT_656_1120: | ||
696 | pr_cont("type=bt-656/1120, width=%u-%u, height=%u-%u, " | ||
697 | "pixelclock=%llu-%llu, standards=0x%x, capabilities=0x%x\n", | ||
698 | p->bt.min_width, p->bt.max_width, | ||
699 | p->bt.min_height, p->bt.max_height, | ||
700 | p->bt.min_pixelclock, p->bt.max_pixelclock, | ||
701 | p->bt.standards, p->bt.capabilities); | ||
702 | break; | ||
703 | default: | ||
704 | pr_cont("type=%u\n", p->type); | ||
705 | break; | ||
706 | } | ||
707 | } | ||
420 | 708 | ||
421 | dbgarg2("width=%d, height=%d, format=%c%c%c%c, field=%s, " | 709 | static void v4l_print_frmsizeenum(const void *arg, bool write_only) |
422 | "colorspace=%d, num_planes=%d\n", | 710 | { |
423 | fmt->width, fmt->height, | 711 | const struct v4l2_frmsizeenum *p = arg; |
424 | (fmt->pixelformat & 0xff), | ||
425 | (fmt->pixelformat >> 8) & 0xff, | ||
426 | (fmt->pixelformat >> 16) & 0xff, | ||
427 | (fmt->pixelformat >> 24) & 0xff, | ||
428 | prt_names(fmt->field, v4l2_field_names), | ||
429 | fmt->colorspace, fmt->num_planes); | ||
430 | 712 | ||
431 | for (i = 0; i < fmt->num_planes; ++i) | 713 | pr_cont("index=%u, pixelformat=%c%c%c%c, type=%u", |
432 | dbgarg2("plane %d: bytesperline=%d sizeimage=%d\n", i, | 714 | p->index, |
433 | fmt->plane_fmt[i].bytesperline, | 715 | (p->pixel_format & 0xff), |
434 | fmt->plane_fmt[i].sizeimage); | 716 | (p->pixel_format >> 8) & 0xff, |
717 | (p->pixel_format >> 16) & 0xff, | ||
718 | (p->pixel_format >> 24) & 0xff, | ||
719 | p->type); | ||
720 | switch (p->type) { | ||
721 | case V4L2_FRMSIZE_TYPE_DISCRETE: | ||
722 | pr_cont(" wxh=%ux%u\n", | ||
723 | p->discrete.width, p->discrete.height); | ||
724 | break; | ||
725 | case V4L2_FRMSIZE_TYPE_STEPWISE: | ||
726 | pr_cont(" min=%ux%u, max=%ux%u, step=%ux%u\n", | ||
727 | p->stepwise.min_width, p->stepwise.min_height, | ||
728 | p->stepwise.step_width, p->stepwise.step_height, | ||
729 | p->stepwise.max_width, p->stepwise.max_height); | ||
730 | break; | ||
731 | case V4L2_FRMSIZE_TYPE_CONTINUOUS: | ||
732 | /* fall through */ | ||
733 | default: | ||
734 | pr_cont("\n"); | ||
735 | break; | ||
736 | } | ||
435 | } | 737 | } |
436 | 738 | ||
437 | static inline void v4l_print_ext_ctrls(unsigned int cmd, | 739 | static void v4l_print_frmivalenum(const void *arg, bool write_only) |
438 | struct video_device *vfd, struct v4l2_ext_controls *c, int show_vals) | ||
439 | { | 740 | { |
440 | __u32 i; | 741 | const struct v4l2_frmivalenum *p = arg; |
441 | 742 | ||
442 | if (!(vfd->debug & V4L2_DEBUG_IOCTL_ARG)) | 743 | pr_cont("index=%u, pixelformat=%c%c%c%c, wxh=%ux%u, type=%u", |
443 | return; | 744 | p->index, |
444 | dbgarg(cmd, ""); | 745 | (p->pixel_format & 0xff), |
445 | printk(KERN_CONT "class=0x%x", c->ctrl_class); | 746 | (p->pixel_format >> 8) & 0xff, |
446 | for (i = 0; i < c->count; i++) { | 747 | (p->pixel_format >> 16) & 0xff, |
447 | if (show_vals && !c->controls[i].size) | 748 | (p->pixel_format >> 24) & 0xff, |
448 | printk(KERN_CONT " id/val=0x%x/0x%x", | 749 | p->width, p->height, p->type); |
449 | c->controls[i].id, c->controls[i].value); | 750 | switch (p->type) { |
751 | case V4L2_FRMIVAL_TYPE_DISCRETE: | ||
752 | pr_cont(" fps=%d/%d\n", | ||
753 | p->discrete.numerator, | ||
754 | p->discrete.denominator); | ||
755 | break; | ||
756 | case V4L2_FRMIVAL_TYPE_STEPWISE: | ||
757 | pr_cont(" min=%d/%d, max=%d/%d, step=%d/%d\n", | ||
758 | p->stepwise.min.numerator, | ||
759 | p->stepwise.min.denominator, | ||
760 | p->stepwise.max.numerator, | ||
761 | p->stepwise.max.denominator, | ||
762 | p->stepwise.step.numerator, | ||
763 | p->stepwise.step.denominator); | ||
764 | break; | ||
765 | case V4L2_FRMIVAL_TYPE_CONTINUOUS: | ||
766 | /* fall through */ | ||
767 | default: | ||
768 | pr_cont("\n"); | ||
769 | break; | ||
770 | } | ||
771 | } | ||
772 | |||
773 | static void v4l_print_event(const void *arg, bool write_only) | ||
774 | { | ||
775 | const struct v4l2_event *p = arg; | ||
776 | const struct v4l2_event_ctrl *c; | ||
777 | |||
778 | pr_cont("type=0x%x, pending=%u, sequence=%u, id=%u, " | ||
779 | "timestamp=%lu.%9.9lu\n", | ||
780 | p->type, p->pending, p->sequence, p->id, | ||
781 | p->timestamp.tv_sec, p->timestamp.tv_nsec); | ||
782 | switch (p->type) { | ||
783 | case V4L2_EVENT_VSYNC: | ||
784 | printk(KERN_DEBUG "field=%s\n", | ||
785 | prt_names(p->u.vsync.field, v4l2_field_names)); | ||
786 | break; | ||
787 | case V4L2_EVENT_CTRL: | ||
788 | c = &p->u.ctrl; | ||
789 | printk(KERN_DEBUG "changes=0x%x, type=%u, ", | ||
790 | c->changes, c->type); | ||
791 | if (c->type == V4L2_CTRL_TYPE_INTEGER64) | ||
792 | pr_cont("value64=%lld, ", c->value64); | ||
450 | else | 793 | else |
451 | printk(KERN_CONT " id=0x%x,size=%u", | 794 | pr_cont("value=%d, ", c->value); |
452 | c->controls[i].id, c->controls[i].size); | 795 | pr_cont("flags=0x%x, minimum=%d, maximum=%d, step=%d," |
796 | " default_value=%d\n", | ||
797 | c->flags, c->minimum, c->maximum, | ||
798 | c->step, c->default_value); | ||
799 | break; | ||
800 | case V4L2_EVENT_FRAME_SYNC: | ||
801 | pr_cont("frame_sequence=%u\n", | ||
802 | p->u.frame_sync.frame_sequence); | ||
803 | break; | ||
453 | } | 804 | } |
454 | printk(KERN_CONT "\n"); | 805 | } |
455 | }; | ||
456 | 806 | ||
457 | static inline int check_ext_ctrls(struct v4l2_ext_controls *c, int allow_priv) | 807 | static void v4l_print_event_subscription(const void *arg, bool write_only) |
808 | { | ||
809 | const struct v4l2_event_subscription *p = arg; | ||
810 | |||
811 | pr_cont("type=0x%x, id=0x%x, flags=0x%x\n", | ||
812 | p->type, p->id, p->flags); | ||
813 | } | ||
814 | |||
815 | static void v4l_print_sliced_vbi_cap(const void *arg, bool write_only) | ||
816 | { | ||
817 | const struct v4l2_sliced_vbi_cap *p = arg; | ||
818 | int i; | ||
819 | |||
820 | pr_cont("type=%s, service_set=0x%08x\n", | ||
821 | prt_names(p->type, v4l2_type_names), p->service_set); | ||
822 | for (i = 0; i < 24; i++) | ||
823 | printk(KERN_DEBUG "line[%02u]=0x%04x, 0x%04x\n", i, | ||
824 | p->service_lines[0][i], | ||
825 | p->service_lines[1][i]); | ||
826 | } | ||
827 | |||
828 | static void v4l_print_u32(const void *arg, bool write_only) | ||
829 | { | ||
830 | pr_cont("value=%u\n", *(const u32 *)arg); | ||
831 | } | ||
832 | |||
833 | static void v4l_print_newline(const void *arg, bool write_only) | ||
834 | { | ||
835 | pr_cont("\n"); | ||
836 | } | ||
837 | |||
838 | static void v4l_print_default(const void *arg, bool write_only) | ||
839 | { | ||
840 | pr_cont("driver-specific ioctl\n"); | ||
841 | } | ||
842 | |||
843 | static int check_ext_ctrls(struct v4l2_ext_controls *c, int allow_priv) | ||
458 | { | 844 | { |
459 | __u32 i; | 845 | __u32 i; |
460 | 846 | ||
@@ -536,1615 +922,1159 @@ static int check_fmt(const struct v4l2_ioctl_ops *ops, enum v4l2_buf_type type) | |||
536 | return -EINVAL; | 922 | return -EINVAL; |
537 | } | 923 | } |
538 | 924 | ||
539 | static long __video_do_ioctl(struct file *file, | 925 | static int v4l_querycap(const struct v4l2_ioctl_ops *ops, |
540 | unsigned int cmd, void *arg) | 926 | struct file *file, void *fh, void *arg) |
541 | { | 927 | { |
542 | struct video_device *vfd = video_devdata(file); | 928 | struct v4l2_capability *cap = (struct v4l2_capability *)arg; |
543 | const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops; | ||
544 | void *fh = file->private_data; | ||
545 | struct v4l2_fh *vfh = NULL; | ||
546 | int use_fh_prio = 0; | ||
547 | long ret = -ENOTTY; | ||
548 | 929 | ||
549 | if (ops == NULL) { | 930 | cap->version = LINUX_VERSION_CODE; |
550 | printk(KERN_WARNING "videodev: \"%s\" has no ioctl_ops.\n", | 931 | return ops->vidioc_querycap(file, fh, cap); |
551 | vfd->name); | 932 | } |
552 | return ret; | ||
553 | } | ||
554 | |||
555 | if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags)) { | ||
556 | vfh = file->private_data; | ||
557 | use_fh_prio = test_bit(V4L2_FL_USE_FH_PRIO, &vfd->flags); | ||
558 | } | ||
559 | 933 | ||
560 | if (v4l2_is_known_ioctl(cmd)) { | 934 | static int v4l_s_input(const struct v4l2_ioctl_ops *ops, |
561 | struct v4l2_ioctl_info *info = &v4l2_ioctls[_IOC_NR(cmd)]; | 935 | struct file *file, void *fh, void *arg) |
936 | { | ||
937 | return ops->vidioc_s_input(file, fh, *(unsigned int *)arg); | ||
938 | } | ||
562 | 939 | ||
563 | if (!test_bit(_IOC_NR(cmd), vfd->valid_ioctls) && | 940 | static int v4l_s_output(const struct v4l2_ioctl_ops *ops, |
564 | !((info->flags & INFO_FL_CTRL) && vfh && vfh->ctrl_handler)) | 941 | struct file *file, void *fh, void *arg) |
565 | return -ENOTTY; | 942 | { |
943 | return ops->vidioc_s_output(file, fh, *(unsigned int *)arg); | ||
944 | } | ||
566 | 945 | ||
567 | if (use_fh_prio && (info->flags & INFO_FL_PRIO)) { | 946 | static int v4l_g_priority(const struct v4l2_ioctl_ops *ops, |
568 | ret = v4l2_prio_check(vfd->prio, vfh->prio); | 947 | struct file *file, void *fh, void *arg) |
569 | if (ret) | 948 | { |
570 | return ret; | 949 | struct video_device *vfd; |
571 | } | 950 | u32 *p = arg; |
572 | } | ||
573 | 951 | ||
574 | if ((vfd->debug & V4L2_DEBUG_IOCTL) && | 952 | if (ops->vidioc_g_priority) |
575 | !(vfd->debug & V4L2_DEBUG_IOCTL_ARG)) { | 953 | return ops->vidioc_g_priority(file, fh, arg); |
576 | v4l_print_ioctl(vfd->name, cmd); | 954 | vfd = video_devdata(file); |
577 | printk(KERN_CONT "\n"); | 955 | *p = v4l2_prio_max(&vfd->v4l2_dev->prio); |
578 | } | 956 | return 0; |
957 | } | ||
579 | 958 | ||
580 | switch (cmd) { | 959 | static int v4l_s_priority(const struct v4l2_ioctl_ops *ops, |
960 | struct file *file, void *fh, void *arg) | ||
961 | { | ||
962 | struct video_device *vfd; | ||
963 | struct v4l2_fh *vfh; | ||
964 | u32 *p = arg; | ||
965 | |||
966 | if (ops->vidioc_s_priority) | ||
967 | return ops->vidioc_s_priority(file, fh, *p); | ||
968 | vfd = video_devdata(file); | ||
969 | vfh = file->private_data; | ||
970 | return v4l2_prio_change(&vfd->v4l2_dev->prio, &vfh->prio, *p); | ||
971 | } | ||
581 | 972 | ||
582 | /* --- capabilities ------------------------------------------ */ | 973 | static int v4l_enuminput(const struct v4l2_ioctl_ops *ops, |
583 | case VIDIOC_QUERYCAP: | 974 | struct file *file, void *fh, void *arg) |
584 | { | 975 | { |
585 | struct v4l2_capability *cap = (struct v4l2_capability *)arg; | 976 | struct v4l2_input *p = arg; |
586 | |||
587 | cap->version = LINUX_VERSION_CODE; | ||
588 | ret = ops->vidioc_querycap(file, fh, cap); | ||
589 | if (!ret) | ||
590 | dbgarg(cmd, "driver=%s, card=%s, bus=%s, " | ||
591 | "version=0x%08x, " | ||
592 | "capabilities=0x%08x, " | ||
593 | "device_caps=0x%08x\n", | ||
594 | cap->driver, cap->card, cap->bus_info, | ||
595 | cap->version, | ||
596 | cap->capabilities, | ||
597 | cap->device_caps); | ||
598 | break; | ||
599 | } | ||
600 | 977 | ||
601 | /* --- priority ------------------------------------------ */ | 978 | /* |
602 | case VIDIOC_G_PRIORITY: | 979 | * We set the flags for CAP_PRESETS, CAP_CUSTOM_TIMINGS & |
603 | { | 980 | * CAP_STD here based on ioctl handler provided by the |
604 | enum v4l2_priority *p = arg; | 981 | * driver. If the driver doesn't support these |
982 | * for a specific input, it must override these flags. | ||
983 | */ | ||
984 | if (ops->vidioc_s_std) | ||
985 | p->capabilities |= V4L2_IN_CAP_STD; | ||
986 | if (ops->vidioc_s_dv_preset) | ||
987 | p->capabilities |= V4L2_IN_CAP_PRESETS; | ||
988 | if (ops->vidioc_s_dv_timings) | ||
989 | p->capabilities |= V4L2_IN_CAP_CUSTOM_TIMINGS; | ||
990 | |||
991 | return ops->vidioc_enum_input(file, fh, p); | ||
992 | } | ||
605 | 993 | ||
606 | if (ops->vidioc_g_priority) { | 994 | static int v4l_enumoutput(const struct v4l2_ioctl_ops *ops, |
607 | ret = ops->vidioc_g_priority(file, fh, p); | 995 | struct file *file, void *fh, void *arg) |
608 | } else if (use_fh_prio) { | 996 | { |
609 | *p = v4l2_prio_max(&vfd->v4l2_dev->prio); | 997 | struct v4l2_output *p = arg; |
610 | ret = 0; | ||
611 | } | ||
612 | if (!ret) | ||
613 | dbgarg(cmd, "priority is %d\n", *p); | ||
614 | break; | ||
615 | } | ||
616 | case VIDIOC_S_PRIORITY: | ||
617 | { | ||
618 | enum v4l2_priority *p = arg; | ||
619 | 998 | ||
620 | dbgarg(cmd, "setting priority to %d\n", *p); | 999 | /* |
621 | if (ops->vidioc_s_priority) | 1000 | * We set the flags for CAP_PRESETS, CAP_CUSTOM_TIMINGS & |
622 | ret = ops->vidioc_s_priority(file, fh, *p); | 1001 | * CAP_STD here based on ioctl handler provided by the |
623 | else | 1002 | * driver. If the driver doesn't support these |
624 | ret = v4l2_prio_change(&vfd->v4l2_dev->prio, | 1003 | * for a specific output, it must override these flags. |
625 | &vfh->prio, *p); | 1004 | */ |
626 | break; | 1005 | if (ops->vidioc_s_std) |
627 | } | 1006 | p->capabilities |= V4L2_OUT_CAP_STD; |
1007 | if (ops->vidioc_s_dv_preset) | ||
1008 | p->capabilities |= V4L2_OUT_CAP_PRESETS; | ||
1009 | if (ops->vidioc_s_dv_timings) | ||
1010 | p->capabilities |= V4L2_OUT_CAP_CUSTOM_TIMINGS; | ||
1011 | |||
1012 | return ops->vidioc_enum_output(file, fh, p); | ||
1013 | } | ||
628 | 1014 | ||
629 | /* --- capture ioctls ---------------------------------------- */ | 1015 | static int v4l_enum_fmt(const struct v4l2_ioctl_ops *ops, |
630 | case VIDIOC_ENUM_FMT: | 1016 | struct file *file, void *fh, void *arg) |
631 | { | 1017 | { |
632 | struct v4l2_fmtdesc *f = arg; | 1018 | struct v4l2_fmtdesc *p = arg; |
633 | 1019 | ||
634 | ret = -EINVAL; | 1020 | switch (p->type) { |
635 | switch (f->type) { | 1021 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
636 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 1022 | if (unlikely(!ops->vidioc_enum_fmt_vid_cap)) |
637 | if (likely(ops->vidioc_enum_fmt_vid_cap)) | ||
638 | ret = ops->vidioc_enum_fmt_vid_cap(file, fh, f); | ||
639 | break; | ||
640 | case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: | ||
641 | if (likely(ops->vidioc_enum_fmt_vid_cap_mplane)) | ||
642 | ret = ops->vidioc_enum_fmt_vid_cap_mplane(file, | ||
643 | fh, f); | ||
644 | break; | 1023 | break; |
645 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: | 1024 | return ops->vidioc_enum_fmt_vid_cap(file, fh, arg); |
646 | if (likely(ops->vidioc_enum_fmt_vid_overlay)) | 1025 | case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: |
647 | ret = ops->vidioc_enum_fmt_vid_overlay(file, | 1026 | if (unlikely(!ops->vidioc_enum_fmt_vid_cap_mplane)) |
648 | fh, f); | ||
649 | break; | 1027 | break; |
650 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: | 1028 | return ops->vidioc_enum_fmt_vid_cap_mplane(file, fh, arg); |
651 | if (likely(ops->vidioc_enum_fmt_vid_out)) | 1029 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: |
652 | ret = ops->vidioc_enum_fmt_vid_out(file, fh, f); | 1030 | if (unlikely(!ops->vidioc_enum_fmt_vid_overlay)) |
653 | break; | 1031 | break; |
654 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: | 1032 | return ops->vidioc_enum_fmt_vid_overlay(file, fh, arg); |
655 | if (likely(ops->vidioc_enum_fmt_vid_out_mplane)) | 1033 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: |
656 | ret = ops->vidioc_enum_fmt_vid_out_mplane(file, | 1034 | if (unlikely(!ops->vidioc_enum_fmt_vid_out)) |
657 | fh, f); | ||
658 | break; | 1035 | break; |
659 | case V4L2_BUF_TYPE_PRIVATE: | 1036 | return ops->vidioc_enum_fmt_vid_out(file, fh, arg); |
660 | if (likely(ops->vidioc_enum_fmt_type_private)) | 1037 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: |
661 | ret = ops->vidioc_enum_fmt_type_private(file, | 1038 | if (unlikely(!ops->vidioc_enum_fmt_vid_out_mplane)) |
662 | fh, f); | ||
663 | break; | 1039 | break; |
664 | default: | 1040 | return ops->vidioc_enum_fmt_vid_out_mplane(file, fh, arg); |
1041 | case V4L2_BUF_TYPE_PRIVATE: | ||
1042 | if (unlikely(!ops->vidioc_enum_fmt_type_private)) | ||
665 | break; | 1043 | break; |
666 | } | 1044 | return ops->vidioc_enum_fmt_type_private(file, fh, arg); |
667 | if (likely(!ret)) | ||
668 | dbgarg(cmd, "index=%d, type=%d, flags=%d, " | ||
669 | "pixelformat=%c%c%c%c, description='%s'\n", | ||
670 | f->index, f->type, f->flags, | ||
671 | (f->pixelformat & 0xff), | ||
672 | (f->pixelformat >> 8) & 0xff, | ||
673 | (f->pixelformat >> 16) & 0xff, | ||
674 | (f->pixelformat >> 24) & 0xff, | ||
675 | f->description); | ||
676 | break; | ||
677 | } | 1045 | } |
678 | case VIDIOC_G_FMT: | 1046 | return -EINVAL; |
679 | { | 1047 | } |
680 | struct v4l2_format *f = (struct v4l2_format *)arg; | 1048 | |
681 | 1049 | static int v4l_g_fmt(const struct v4l2_ioctl_ops *ops, | |
682 | /* FIXME: Should be one dump per type */ | 1050 | struct file *file, void *fh, void *arg) |
683 | dbgarg(cmd, "type=%s\n", prt_names(f->type, v4l2_type_names)); | 1051 | { |
684 | 1052 | struct v4l2_format *p = arg; | |
685 | ret = -EINVAL; | 1053 | |
686 | switch (f->type) { | 1054 | switch (p->type) { |
687 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 1055 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
688 | if (ops->vidioc_g_fmt_vid_cap) | 1056 | if (unlikely(!ops->vidioc_g_fmt_vid_cap)) |
689 | ret = ops->vidioc_g_fmt_vid_cap(file, fh, f); | ||
690 | if (!ret) | ||
691 | v4l_print_pix_fmt(vfd, &f->fmt.pix); | ||
692 | break; | 1057 | break; |
693 | case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: | 1058 | return ops->vidioc_g_fmt_vid_cap(file, fh, arg); |
694 | if (ops->vidioc_g_fmt_vid_cap_mplane) | 1059 | case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: |
695 | ret = ops->vidioc_g_fmt_vid_cap_mplane(file, | 1060 | if (unlikely(!ops->vidioc_g_fmt_vid_cap_mplane)) |
696 | fh, f); | ||
697 | if (!ret) | ||
698 | v4l_print_pix_fmt_mplane(vfd, &f->fmt.pix_mp); | ||
699 | break; | 1061 | break; |
700 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: | 1062 | return ops->vidioc_g_fmt_vid_cap_mplane(file, fh, arg); |
701 | if (likely(ops->vidioc_g_fmt_vid_overlay)) | 1063 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: |
702 | ret = ops->vidioc_g_fmt_vid_overlay(file, | 1064 | if (unlikely(!ops->vidioc_g_fmt_vid_overlay)) |
703 | fh, f); | ||
704 | break; | 1065 | break; |
705 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: | 1066 | return ops->vidioc_g_fmt_vid_overlay(file, fh, arg); |
706 | if (ops->vidioc_g_fmt_vid_out) | 1067 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: |
707 | ret = ops->vidioc_g_fmt_vid_out(file, fh, f); | 1068 | if (unlikely(!ops->vidioc_g_fmt_vid_out)) |
708 | if (!ret) | ||
709 | v4l_print_pix_fmt(vfd, &f->fmt.pix); | ||
710 | break; | 1069 | break; |
711 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: | 1070 | return ops->vidioc_g_fmt_vid_out(file, fh, arg); |
712 | if (ops->vidioc_g_fmt_vid_out_mplane) | 1071 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: |
713 | ret = ops->vidioc_g_fmt_vid_out_mplane(file, | 1072 | if (unlikely(!ops->vidioc_g_fmt_vid_out_mplane)) |
714 | fh, f); | ||
715 | if (!ret) | ||
716 | v4l_print_pix_fmt_mplane(vfd, &f->fmt.pix_mp); | ||
717 | break; | 1073 | break; |
718 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: | 1074 | return ops->vidioc_g_fmt_vid_out_mplane(file, fh, arg); |
719 | if (likely(ops->vidioc_g_fmt_vid_out_overlay)) | 1075 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: |
720 | ret = ops->vidioc_g_fmt_vid_out_overlay(file, | 1076 | if (unlikely(!ops->vidioc_g_fmt_vid_out_overlay)) |
721 | fh, f); | ||
722 | break; | 1077 | break; |
723 | case V4L2_BUF_TYPE_VBI_CAPTURE: | 1078 | return ops->vidioc_g_fmt_vid_out_overlay(file, fh, arg); |
724 | if (likely(ops->vidioc_g_fmt_vbi_cap)) | 1079 | case V4L2_BUF_TYPE_VBI_CAPTURE: |
725 | ret = ops->vidioc_g_fmt_vbi_cap(file, fh, f); | 1080 | if (unlikely(!ops->vidioc_g_fmt_vbi_cap)) |
726 | break; | 1081 | break; |
727 | case V4L2_BUF_TYPE_VBI_OUTPUT: | 1082 | return ops->vidioc_g_fmt_vbi_cap(file, fh, arg); |
728 | if (likely(ops->vidioc_g_fmt_vbi_out)) | 1083 | case V4L2_BUF_TYPE_VBI_OUTPUT: |
729 | ret = ops->vidioc_g_fmt_vbi_out(file, fh, f); | 1084 | if (unlikely(!ops->vidioc_g_fmt_vbi_out)) |
730 | break; | 1085 | break; |
731 | case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: | 1086 | return ops->vidioc_g_fmt_vbi_out(file, fh, arg); |
732 | if (likely(ops->vidioc_g_fmt_sliced_vbi_cap)) | 1087 | case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: |
733 | ret = ops->vidioc_g_fmt_sliced_vbi_cap(file, | 1088 | if (unlikely(!ops->vidioc_g_fmt_sliced_vbi_cap)) |
734 | fh, f); | ||
735 | break; | 1089 | break; |
736 | case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: | 1090 | return ops->vidioc_g_fmt_sliced_vbi_cap(file, fh, arg); |
737 | if (likely(ops->vidioc_g_fmt_sliced_vbi_out)) | 1091 | case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: |
738 | ret = ops->vidioc_g_fmt_sliced_vbi_out(file, | 1092 | if (unlikely(!ops->vidioc_g_fmt_sliced_vbi_out)) |
739 | fh, f); | ||
740 | break; | 1093 | break; |
741 | case V4L2_BUF_TYPE_PRIVATE: | 1094 | return ops->vidioc_g_fmt_sliced_vbi_out(file, fh, arg); |
742 | if (likely(ops->vidioc_g_fmt_type_private)) | 1095 | case V4L2_BUF_TYPE_PRIVATE: |
743 | ret = ops->vidioc_g_fmt_type_private(file, | 1096 | if (unlikely(!ops->vidioc_g_fmt_type_private)) |
744 | fh, f); | ||
745 | break; | 1097 | break; |
746 | } | 1098 | return ops->vidioc_g_fmt_type_private(file, fh, arg); |
747 | break; | ||
748 | } | 1099 | } |
749 | case VIDIOC_S_FMT: | 1100 | return -EINVAL; |
750 | { | 1101 | } |
751 | struct v4l2_format *f = (struct v4l2_format *)arg; | ||
752 | |||
753 | ret = -EINVAL; | ||
754 | 1102 | ||
755 | /* FIXME: Should be one dump per type */ | 1103 | static int v4l_s_fmt(const struct v4l2_ioctl_ops *ops, |
756 | dbgarg(cmd, "type=%s\n", prt_names(f->type, v4l2_type_names)); | 1104 | struct file *file, void *fh, void *arg) |
1105 | { | ||
1106 | struct v4l2_format *p = arg; | ||
757 | 1107 | ||
758 | switch (f->type) { | 1108 | switch (p->type) { |
759 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 1109 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
760 | CLEAR_AFTER_FIELD(f, fmt.pix); | 1110 | if (unlikely(!ops->vidioc_s_fmt_vid_cap)) |
761 | v4l_print_pix_fmt(vfd, &f->fmt.pix); | ||
762 | if (ops->vidioc_s_fmt_vid_cap) | ||
763 | ret = ops->vidioc_s_fmt_vid_cap(file, fh, f); | ||
764 | break; | 1111 | break; |
765 | case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: | 1112 | CLEAR_AFTER_FIELD(p, fmt.pix); |
766 | CLEAR_AFTER_FIELD(f, fmt.pix_mp); | 1113 | return ops->vidioc_s_fmt_vid_cap(file, fh, arg); |
767 | v4l_print_pix_fmt_mplane(vfd, &f->fmt.pix_mp); | 1114 | case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: |
768 | if (ops->vidioc_s_fmt_vid_cap_mplane) | 1115 | if (unlikely(!ops->vidioc_s_fmt_vid_cap_mplane)) |
769 | ret = ops->vidioc_s_fmt_vid_cap_mplane(file, | ||
770 | fh, f); | ||
771 | break; | 1116 | break; |
772 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: | 1117 | CLEAR_AFTER_FIELD(p, fmt.pix_mp); |
773 | CLEAR_AFTER_FIELD(f, fmt.win); | 1118 | return ops->vidioc_s_fmt_vid_cap_mplane(file, fh, arg); |
774 | if (ops->vidioc_s_fmt_vid_overlay) | 1119 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: |
775 | ret = ops->vidioc_s_fmt_vid_overlay(file, | 1120 | if (unlikely(!ops->vidioc_s_fmt_vid_overlay)) |
776 | fh, f); | ||
777 | break; | 1121 | break; |
778 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: | 1122 | CLEAR_AFTER_FIELD(p, fmt.win); |
779 | CLEAR_AFTER_FIELD(f, fmt.pix); | 1123 | return ops->vidioc_s_fmt_vid_overlay(file, fh, arg); |
780 | v4l_print_pix_fmt(vfd, &f->fmt.pix); | 1124 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: |
781 | if (ops->vidioc_s_fmt_vid_out) | 1125 | if (unlikely(!ops->vidioc_s_fmt_vid_out)) |
782 | ret = ops->vidioc_s_fmt_vid_out(file, fh, f); | ||
783 | break; | 1126 | break; |
784 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: | 1127 | CLEAR_AFTER_FIELD(p, fmt.pix); |
785 | CLEAR_AFTER_FIELD(f, fmt.pix_mp); | 1128 | return ops->vidioc_s_fmt_vid_out(file, fh, arg); |
786 | v4l_print_pix_fmt_mplane(vfd, &f->fmt.pix_mp); | 1129 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: |
787 | if (ops->vidioc_s_fmt_vid_out_mplane) | 1130 | if (unlikely(!ops->vidioc_s_fmt_vid_out_mplane)) |
788 | ret = ops->vidioc_s_fmt_vid_out_mplane(file, | ||
789 | fh, f); | ||
790 | break; | 1131 | break; |
791 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: | 1132 | CLEAR_AFTER_FIELD(p, fmt.pix_mp); |
792 | CLEAR_AFTER_FIELD(f, fmt.win); | 1133 | return ops->vidioc_s_fmt_vid_out_mplane(file, fh, arg); |
793 | if (ops->vidioc_s_fmt_vid_out_overlay) | 1134 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: |
794 | ret = ops->vidioc_s_fmt_vid_out_overlay(file, | 1135 | if (unlikely(!ops->vidioc_s_fmt_vid_out_overlay)) |
795 | fh, f); | ||
796 | break; | 1136 | break; |
797 | case V4L2_BUF_TYPE_VBI_CAPTURE: | 1137 | CLEAR_AFTER_FIELD(p, fmt.win); |
798 | CLEAR_AFTER_FIELD(f, fmt.vbi); | 1138 | return ops->vidioc_s_fmt_vid_out_overlay(file, fh, arg); |
799 | if (likely(ops->vidioc_s_fmt_vbi_cap)) | 1139 | case V4L2_BUF_TYPE_VBI_CAPTURE: |
800 | ret = ops->vidioc_s_fmt_vbi_cap(file, fh, f); | 1140 | if (unlikely(!ops->vidioc_s_fmt_vbi_cap)) |
801 | break; | 1141 | break; |
802 | case V4L2_BUF_TYPE_VBI_OUTPUT: | 1142 | CLEAR_AFTER_FIELD(p, fmt.vbi); |
803 | CLEAR_AFTER_FIELD(f, fmt.vbi); | 1143 | return ops->vidioc_s_fmt_vbi_cap(file, fh, arg); |
804 | if (likely(ops->vidioc_s_fmt_vbi_out)) | 1144 | case V4L2_BUF_TYPE_VBI_OUTPUT: |
805 | ret = ops->vidioc_s_fmt_vbi_out(file, fh, f); | 1145 | if (unlikely(!ops->vidioc_s_fmt_vbi_out)) |
806 | break; | 1146 | break; |
807 | case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: | 1147 | CLEAR_AFTER_FIELD(p, fmt.vbi); |
808 | CLEAR_AFTER_FIELD(f, fmt.sliced); | 1148 | return ops->vidioc_s_fmt_vbi_out(file, fh, arg); |
809 | if (likely(ops->vidioc_s_fmt_sliced_vbi_cap)) | 1149 | case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: |
810 | ret = ops->vidioc_s_fmt_sliced_vbi_cap(file, | 1150 | if (unlikely(!ops->vidioc_s_fmt_sliced_vbi_cap)) |
811 | fh, f); | ||
812 | break; | 1151 | break; |
813 | case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: | 1152 | CLEAR_AFTER_FIELD(p, fmt.sliced); |
814 | CLEAR_AFTER_FIELD(f, fmt.sliced); | 1153 | return ops->vidioc_s_fmt_sliced_vbi_cap(file, fh, arg); |
815 | if (likely(ops->vidioc_s_fmt_sliced_vbi_out)) | 1154 | case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: |
816 | ret = ops->vidioc_s_fmt_sliced_vbi_out(file, | 1155 | if (unlikely(!ops->vidioc_s_fmt_sliced_vbi_out)) |
817 | fh, f); | ||
818 | |||
819 | break; | 1156 | break; |
820 | case V4L2_BUF_TYPE_PRIVATE: | 1157 | CLEAR_AFTER_FIELD(p, fmt.sliced); |
821 | /* CLEAR_AFTER_FIELD(f, fmt.raw_data); <- does nothing */ | 1158 | return ops->vidioc_s_fmt_sliced_vbi_out(file, fh, arg); |
822 | if (likely(ops->vidioc_s_fmt_type_private)) | 1159 | case V4L2_BUF_TYPE_PRIVATE: |
823 | ret = ops->vidioc_s_fmt_type_private(file, | 1160 | if (unlikely(!ops->vidioc_s_fmt_type_private)) |
824 | fh, f); | ||
825 | break; | 1161 | break; |
826 | } | 1162 | return ops->vidioc_s_fmt_type_private(file, fh, arg); |
827 | break; | ||
828 | } | 1163 | } |
829 | case VIDIOC_TRY_FMT: | 1164 | return -EINVAL; |
830 | { | 1165 | } |
831 | struct v4l2_format *f = (struct v4l2_format *)arg; | 1166 | |
832 | 1167 | static int v4l_try_fmt(const struct v4l2_ioctl_ops *ops, | |
833 | /* FIXME: Should be one dump per type */ | 1168 | struct file *file, void *fh, void *arg) |
834 | dbgarg(cmd, "type=%s\n", prt_names(f->type, | 1169 | { |
835 | v4l2_type_names)); | 1170 | struct v4l2_format *p = arg; |
836 | ret = -EINVAL; | 1171 | |
837 | switch (f->type) { | 1172 | switch (p->type) { |
838 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 1173 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
839 | CLEAR_AFTER_FIELD(f, fmt.pix); | 1174 | if (unlikely(!ops->vidioc_try_fmt_vid_cap)) |
840 | if (ops->vidioc_try_fmt_vid_cap) | ||
841 | ret = ops->vidioc_try_fmt_vid_cap(file, fh, f); | ||
842 | if (!ret) | ||
843 | v4l_print_pix_fmt(vfd, &f->fmt.pix); | ||
844 | break; | 1175 | break; |
845 | case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: | 1176 | CLEAR_AFTER_FIELD(p, fmt.pix); |
846 | CLEAR_AFTER_FIELD(f, fmt.pix_mp); | 1177 | return ops->vidioc_try_fmt_vid_cap(file, fh, arg); |
847 | if (ops->vidioc_try_fmt_vid_cap_mplane) | 1178 | case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: |
848 | ret = ops->vidioc_try_fmt_vid_cap_mplane(file, | 1179 | if (unlikely(!ops->vidioc_try_fmt_vid_cap_mplane)) |
849 | fh, f); | ||
850 | if (!ret) | ||
851 | v4l_print_pix_fmt_mplane(vfd, &f->fmt.pix_mp); | ||
852 | break; | 1180 | break; |
853 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: | 1181 | CLEAR_AFTER_FIELD(p, fmt.pix_mp); |
854 | CLEAR_AFTER_FIELD(f, fmt.win); | 1182 | return ops->vidioc_try_fmt_vid_cap_mplane(file, fh, arg); |
855 | if (likely(ops->vidioc_try_fmt_vid_overlay)) | 1183 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: |
856 | ret = ops->vidioc_try_fmt_vid_overlay(file, | 1184 | if (unlikely(!ops->vidioc_try_fmt_vid_overlay)) |
857 | fh, f); | ||
858 | break; | 1185 | break; |
859 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: | 1186 | CLEAR_AFTER_FIELD(p, fmt.win); |
860 | CLEAR_AFTER_FIELD(f, fmt.pix); | 1187 | return ops->vidioc_try_fmt_vid_overlay(file, fh, arg); |
861 | if (ops->vidioc_try_fmt_vid_out) | 1188 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: |
862 | ret = ops->vidioc_try_fmt_vid_out(file, fh, f); | 1189 | if (unlikely(!ops->vidioc_try_fmt_vid_out)) |
863 | if (!ret) | ||
864 | v4l_print_pix_fmt(vfd, &f->fmt.pix); | ||
865 | break; | 1190 | break; |
866 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: | 1191 | CLEAR_AFTER_FIELD(p, fmt.pix); |
867 | CLEAR_AFTER_FIELD(f, fmt.pix_mp); | 1192 | return ops->vidioc_try_fmt_vid_out(file, fh, arg); |
868 | if (ops->vidioc_try_fmt_vid_out_mplane) | 1193 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: |
869 | ret = ops->vidioc_try_fmt_vid_out_mplane(file, | 1194 | if (unlikely(!ops->vidioc_try_fmt_vid_out_mplane)) |
870 | fh, f); | ||
871 | if (!ret) | ||
872 | v4l_print_pix_fmt_mplane(vfd, &f->fmt.pix_mp); | ||
873 | break; | 1195 | break; |
874 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: | 1196 | CLEAR_AFTER_FIELD(p, fmt.pix_mp); |
875 | CLEAR_AFTER_FIELD(f, fmt.win); | 1197 | return ops->vidioc_try_fmt_vid_out_mplane(file, fh, arg); |
876 | if (likely(ops->vidioc_try_fmt_vid_out_overlay)) | 1198 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: |
877 | ret = ops->vidioc_try_fmt_vid_out_overlay(file, | 1199 | if (unlikely(!ops->vidioc_try_fmt_vid_out_overlay)) |
878 | fh, f); | ||
879 | break; | 1200 | break; |
880 | case V4L2_BUF_TYPE_VBI_CAPTURE: | 1201 | CLEAR_AFTER_FIELD(p, fmt.win); |
881 | CLEAR_AFTER_FIELD(f, fmt.vbi); | 1202 | return ops->vidioc_try_fmt_vid_out_overlay(file, fh, arg); |
882 | if (likely(ops->vidioc_try_fmt_vbi_cap)) | 1203 | case V4L2_BUF_TYPE_VBI_CAPTURE: |
883 | ret = ops->vidioc_try_fmt_vbi_cap(file, fh, f); | 1204 | if (unlikely(!ops->vidioc_try_fmt_vbi_cap)) |
884 | break; | 1205 | break; |
885 | case V4L2_BUF_TYPE_VBI_OUTPUT: | 1206 | CLEAR_AFTER_FIELD(p, fmt.vbi); |
886 | CLEAR_AFTER_FIELD(f, fmt.vbi); | 1207 | return ops->vidioc_try_fmt_vbi_cap(file, fh, arg); |
887 | if (likely(ops->vidioc_try_fmt_vbi_out)) | 1208 | case V4L2_BUF_TYPE_VBI_OUTPUT: |
888 | ret = ops->vidioc_try_fmt_vbi_out(file, fh, f); | 1209 | if (unlikely(!ops->vidioc_try_fmt_vbi_out)) |
889 | break; | 1210 | break; |
890 | case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: | 1211 | CLEAR_AFTER_FIELD(p, fmt.vbi); |
891 | CLEAR_AFTER_FIELD(f, fmt.sliced); | 1212 | return ops->vidioc_try_fmt_vbi_out(file, fh, arg); |
892 | if (likely(ops->vidioc_try_fmt_sliced_vbi_cap)) | 1213 | case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: |
893 | ret = ops->vidioc_try_fmt_sliced_vbi_cap(file, | 1214 | if (unlikely(!ops->vidioc_try_fmt_sliced_vbi_cap)) |
894 | fh, f); | ||
895 | break; | 1215 | break; |
896 | case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: | 1216 | CLEAR_AFTER_FIELD(p, fmt.sliced); |
897 | CLEAR_AFTER_FIELD(f, fmt.sliced); | 1217 | return ops->vidioc_try_fmt_sliced_vbi_cap(file, fh, arg); |
898 | if (likely(ops->vidioc_try_fmt_sliced_vbi_out)) | 1218 | case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: |
899 | ret = ops->vidioc_try_fmt_sliced_vbi_out(file, | 1219 | if (unlikely(!ops->vidioc_try_fmt_sliced_vbi_out)) |
900 | fh, f); | ||
901 | break; | 1220 | break; |
902 | case V4L2_BUF_TYPE_PRIVATE: | 1221 | CLEAR_AFTER_FIELD(p, fmt.sliced); |
903 | /* CLEAR_AFTER_FIELD(f, fmt.raw_data); <- does nothing */ | 1222 | return ops->vidioc_try_fmt_sliced_vbi_out(file, fh, arg); |
904 | if (likely(ops->vidioc_try_fmt_type_private)) | 1223 | case V4L2_BUF_TYPE_PRIVATE: |
905 | ret = ops->vidioc_try_fmt_type_private(file, | 1224 | if (unlikely(!ops->vidioc_try_fmt_type_private)) |
906 | fh, f); | ||
907 | break; | 1225 | break; |
908 | } | 1226 | return ops->vidioc_try_fmt_type_private(file, fh, arg); |
909 | break; | ||
910 | } | 1227 | } |
911 | /* FIXME: Those buf reqs could be handled here, | 1228 | return -EINVAL; |
912 | with some changes on videobuf to allow its header to be included at | 1229 | } |
913 | videodev2.h or being merged at videodev2. | ||
914 | */ | ||
915 | case VIDIOC_REQBUFS: | ||
916 | { | ||
917 | struct v4l2_requestbuffers *p = arg; | ||
918 | |||
919 | ret = check_fmt(ops, p->type); | ||
920 | if (ret) | ||
921 | break; | ||
922 | 1230 | ||
923 | if (p->type < V4L2_BUF_TYPE_PRIVATE) | 1231 | static int v4l_streamon(const struct v4l2_ioctl_ops *ops, |
924 | CLEAR_AFTER_FIELD(p, memory); | 1232 | struct file *file, void *fh, void *arg) |
1233 | { | ||
1234 | return ops->vidioc_streamon(file, fh, *(unsigned int *)arg); | ||
1235 | } | ||
925 | 1236 | ||
926 | ret = ops->vidioc_reqbufs(file, fh, p); | 1237 | static int v4l_streamoff(const struct v4l2_ioctl_ops *ops, |
927 | dbgarg(cmd, "count=%d, type=%s, memory=%s\n", | 1238 | struct file *file, void *fh, void *arg) |
928 | p->count, | 1239 | { |
929 | prt_names(p->type, v4l2_type_names), | 1240 | return ops->vidioc_streamoff(file, fh, *(unsigned int *)arg); |
930 | prt_names(p->memory, v4l2_memory_names)); | 1241 | } |
931 | break; | ||
932 | } | ||
933 | case VIDIOC_QUERYBUF: | ||
934 | { | ||
935 | struct v4l2_buffer *p = arg; | ||
936 | 1242 | ||
937 | ret = check_fmt(ops, p->type); | 1243 | static int v4l_g_tuner(const struct v4l2_ioctl_ops *ops, |
938 | if (ret) | 1244 | struct file *file, void *fh, void *arg) |
939 | break; | 1245 | { |
1246 | struct video_device *vfd = video_devdata(file); | ||
1247 | struct v4l2_tuner *p = arg; | ||
940 | 1248 | ||
941 | ret = ops->vidioc_querybuf(file, fh, p); | 1249 | p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ? |
942 | if (!ret) | 1250 | V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; |
943 | dbgbuf(cmd, vfd, p); | 1251 | return ops->vidioc_g_tuner(file, fh, p); |
944 | break; | 1252 | } |
945 | } | ||
946 | case VIDIOC_QBUF: | ||
947 | { | ||
948 | struct v4l2_buffer *p = arg; | ||
949 | 1253 | ||
950 | ret = check_fmt(ops, p->type); | 1254 | static int v4l_s_tuner(const struct v4l2_ioctl_ops *ops, |
951 | if (ret) | 1255 | struct file *file, void *fh, void *arg) |
952 | break; | 1256 | { |
1257 | struct video_device *vfd = video_devdata(file); | ||
1258 | struct v4l2_tuner *p = arg; | ||
953 | 1259 | ||
954 | ret = ops->vidioc_qbuf(file, fh, p); | 1260 | p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ? |
955 | if (!ret) | 1261 | V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; |
956 | dbgbuf(cmd, vfd, p); | 1262 | return ops->vidioc_s_tuner(file, fh, p); |
957 | break; | 1263 | } |
958 | } | ||
959 | case VIDIOC_DQBUF: | ||
960 | { | ||
961 | struct v4l2_buffer *p = arg; | ||
962 | 1264 | ||
963 | ret = check_fmt(ops, p->type); | 1265 | static int v4l_g_frequency(const struct v4l2_ioctl_ops *ops, |
964 | if (ret) | 1266 | struct file *file, void *fh, void *arg) |
965 | break; | 1267 | { |
1268 | struct video_device *vfd = video_devdata(file); | ||
1269 | struct v4l2_frequency *p = arg; | ||
966 | 1270 | ||
967 | ret = ops->vidioc_dqbuf(file, fh, p); | 1271 | p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ? |
968 | if (!ret) | 1272 | V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; |
969 | dbgbuf(cmd, vfd, p); | 1273 | return ops->vidioc_g_frequency(file, fh, p); |
970 | break; | 1274 | } |
971 | } | ||
972 | case VIDIOC_OVERLAY: | ||
973 | { | ||
974 | int *i = arg; | ||
975 | 1275 | ||
976 | dbgarg(cmd, "value=%d\n", *i); | 1276 | static int v4l_s_frequency(const struct v4l2_ioctl_ops *ops, |
977 | ret = ops->vidioc_overlay(file, fh, *i); | 1277 | struct file *file, void *fh, void *arg) |
978 | break; | 1278 | { |
979 | } | 1279 | struct video_device *vfd = video_devdata(file); |
980 | case VIDIOC_G_FBUF: | 1280 | struct v4l2_frequency *p = arg; |
981 | { | 1281 | enum v4l2_tuner_type type; |
982 | struct v4l2_framebuffer *p = arg; | ||
983 | |||
984 | ret = ops->vidioc_g_fbuf(file, fh, arg); | ||
985 | if (!ret) { | ||
986 | dbgarg(cmd, "capability=0x%x, flags=%d, base=0x%08lx\n", | ||
987 | p->capability, p->flags, | ||
988 | (unsigned long)p->base); | ||
989 | v4l_print_pix_fmt(vfd, &p->fmt); | ||
990 | } | ||
991 | break; | ||
992 | } | ||
993 | case VIDIOC_S_FBUF: | ||
994 | { | ||
995 | struct v4l2_framebuffer *p = arg; | ||
996 | |||
997 | dbgarg(cmd, "capability=0x%x, flags=%d, base=0x%08lx\n", | ||
998 | p->capability, p->flags, (unsigned long)p->base); | ||
999 | v4l_print_pix_fmt(vfd, &p->fmt); | ||
1000 | ret = ops->vidioc_s_fbuf(file, fh, arg); | ||
1001 | break; | ||
1002 | } | ||
1003 | case VIDIOC_STREAMON: | ||
1004 | { | ||
1005 | enum v4l2_buf_type i = *(int *)arg; | ||
1006 | 1282 | ||
1007 | dbgarg(cmd, "type=%s\n", prt_names(i, v4l2_type_names)); | 1283 | type = (vfd->vfl_type == VFL_TYPE_RADIO) ? |
1008 | ret = ops->vidioc_streamon(file, fh, i); | 1284 | V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; |
1009 | break; | 1285 | if (p->type != type) |
1010 | } | 1286 | return -EINVAL; |
1011 | case VIDIOC_STREAMOFF: | 1287 | return ops->vidioc_s_frequency(file, fh, p); |
1012 | { | 1288 | } |
1013 | enum v4l2_buf_type i = *(int *)arg; | ||
1014 | 1289 | ||
1015 | dbgarg(cmd, "type=%s\n", prt_names(i, v4l2_type_names)); | 1290 | static int v4l_enumstd(const struct v4l2_ioctl_ops *ops, |
1016 | ret = ops->vidioc_streamoff(file, fh, i); | 1291 | struct file *file, void *fh, void *arg) |
1017 | break; | 1292 | { |
1018 | } | 1293 | struct video_device *vfd = video_devdata(file); |
1019 | /* ---------- tv norms ---------- */ | 1294 | struct v4l2_standard *p = arg; |
1020 | case VIDIOC_ENUMSTD: | 1295 | v4l2_std_id id = vfd->tvnorms, curr_id = 0; |
1021 | { | 1296 | unsigned int index = p->index, i, j = 0; |
1022 | struct v4l2_standard *p = arg; | 1297 | const char *descr = ""; |
1023 | v4l2_std_id id = vfd->tvnorms, curr_id = 0; | 1298 | |
1024 | unsigned int index = p->index, i, j = 0; | 1299 | /* Return norm array in a canonical way */ |
1025 | const char *descr = ""; | 1300 | for (i = 0; i <= index && id; i++) { |
1026 | 1301 | /* last std value in the standards array is 0, so this | |
1027 | if (id == 0) | 1302 | while always ends there since (id & 0) == 0. */ |
1028 | break; | 1303 | while ((id & standards[j].std) != standards[j].std) |
1029 | ret = -EINVAL; | ||
1030 | |||
1031 | /* Return norm array in a canonical way */ | ||
1032 | for (i = 0; i <= index && id; i++) { | ||
1033 | /* last std value in the standards array is 0, so this | ||
1034 | while always ends there since (id & 0) == 0. */ | ||
1035 | while ((id & standards[j].std) != standards[j].std) | ||
1036 | j++; | ||
1037 | curr_id = standards[j].std; | ||
1038 | descr = standards[j].descr; | ||
1039 | j++; | 1304 | j++; |
1040 | if (curr_id == 0) | 1305 | curr_id = standards[j].std; |
1041 | break; | 1306 | descr = standards[j].descr; |
1042 | if (curr_id != V4L2_STD_PAL && | 1307 | j++; |
1043 | curr_id != V4L2_STD_SECAM && | 1308 | if (curr_id == 0) |
1044 | curr_id != V4L2_STD_NTSC) | ||
1045 | id &= ~curr_id; | ||
1046 | } | ||
1047 | if (i <= index) | ||
1048 | break; | 1309 | break; |
1049 | 1310 | if (curr_id != V4L2_STD_PAL && | |
1050 | v4l2_video_std_construct(p, curr_id, descr); | 1311 | curr_id != V4L2_STD_SECAM && |
1051 | 1312 | curr_id != V4L2_STD_NTSC) | |
1052 | dbgarg(cmd, "index=%d, id=0x%Lx, name=%s, fps=%d/%d, " | 1313 | id &= ~curr_id; |
1053 | "framelines=%d\n", p->index, | ||
1054 | (unsigned long long)p->id, p->name, | ||
1055 | p->frameperiod.numerator, | ||
1056 | p->frameperiod.denominator, | ||
1057 | p->framelines); | ||
1058 | |||
1059 | ret = 0; | ||
1060 | break; | ||
1061 | } | ||
1062 | case VIDIOC_G_STD: | ||
1063 | { | ||
1064 | v4l2_std_id *id = arg; | ||
1065 | |||
1066 | /* Calls the specific handler */ | ||
1067 | if (ops->vidioc_g_std) | ||
1068 | ret = ops->vidioc_g_std(file, fh, id); | ||
1069 | else if (vfd->current_norm) { | ||
1070 | ret = 0; | ||
1071 | *id = vfd->current_norm; | ||
1072 | } | ||
1073 | |||
1074 | if (likely(!ret)) | ||
1075 | dbgarg(cmd, "std=0x%08Lx\n", (long long unsigned)*id); | ||
1076 | break; | ||
1077 | } | 1314 | } |
1078 | case VIDIOC_S_STD: | 1315 | if (i <= index) |
1079 | { | 1316 | return -EINVAL; |
1080 | v4l2_std_id *id = arg, norm; | ||
1081 | |||
1082 | dbgarg(cmd, "std=%08Lx\n", (long long unsigned)*id); | ||
1083 | |||
1084 | ret = -EINVAL; | ||
1085 | norm = (*id) & vfd->tvnorms; | ||
1086 | if (vfd->tvnorms && !norm) /* Check if std is supported */ | ||
1087 | break; | ||
1088 | |||
1089 | /* Calls the specific handler */ | ||
1090 | ret = ops->vidioc_s_std(file, fh, &norm); | ||
1091 | |||
1092 | /* Updates standard information */ | ||
1093 | if (ret >= 0) | ||
1094 | vfd->current_norm = norm; | ||
1095 | break; | ||
1096 | } | ||
1097 | case VIDIOC_QUERYSTD: | ||
1098 | { | ||
1099 | v4l2_std_id *p = arg; | ||
1100 | |||
1101 | /* | ||
1102 | * If nothing detected, it should return all supported | ||
1103 | * Drivers just need to mask the std argument, in order | ||
1104 | * to remove the standards that don't apply from the mask. | ||
1105 | * This means that tuners, audio and video decoders can join | ||
1106 | * their efforts to improve the standards detection | ||
1107 | */ | ||
1108 | *p = vfd->tvnorms; | ||
1109 | ret = ops->vidioc_querystd(file, fh, arg); | ||
1110 | if (!ret) | ||
1111 | dbgarg(cmd, "detected std=%08Lx\n", | ||
1112 | (unsigned long long)*p); | ||
1113 | break; | ||
1114 | } | ||
1115 | /* ------ input switching ---------- */ | ||
1116 | /* FIXME: Inputs can be handled inside videodev2 */ | ||
1117 | case VIDIOC_ENUMINPUT: | ||
1118 | { | ||
1119 | struct v4l2_input *p = arg; | ||
1120 | 1317 | ||
1121 | /* | 1318 | v4l2_video_std_construct(p, curr_id, descr); |
1122 | * We set the flags for CAP_PRESETS, CAP_CUSTOM_TIMINGS & | 1319 | return 0; |
1123 | * CAP_STD here based on ioctl handler provided by the | 1320 | } |
1124 | * driver. If the driver doesn't support these | ||
1125 | * for a specific input, it must override these flags. | ||
1126 | */ | ||
1127 | if (ops->vidioc_s_std) | ||
1128 | p->capabilities |= V4L2_IN_CAP_STD; | ||
1129 | if (ops->vidioc_s_dv_preset) | ||
1130 | p->capabilities |= V4L2_IN_CAP_PRESETS; | ||
1131 | if (ops->vidioc_s_dv_timings) | ||
1132 | p->capabilities |= V4L2_IN_CAP_CUSTOM_TIMINGS; | ||
1133 | |||
1134 | ret = ops->vidioc_enum_input(file, fh, p); | ||
1135 | if (!ret) | ||
1136 | dbgarg(cmd, "index=%d, name=%s, type=%d, " | ||
1137 | "audioset=%d, " | ||
1138 | "tuner=%d, std=%08Lx, status=%d\n", | ||
1139 | p->index, p->name, p->type, p->audioset, | ||
1140 | p->tuner, | ||
1141 | (unsigned long long)p->std, | ||
1142 | p->status); | ||
1143 | break; | ||
1144 | } | ||
1145 | case VIDIOC_G_INPUT: | ||
1146 | { | ||
1147 | unsigned int *i = arg; | ||
1148 | 1321 | ||
1149 | ret = ops->vidioc_g_input(file, fh, i); | 1322 | static int v4l_g_std(const struct v4l2_ioctl_ops *ops, |
1150 | if (!ret) | 1323 | struct file *file, void *fh, void *arg) |
1151 | dbgarg(cmd, "value=%d\n", *i); | 1324 | { |
1152 | break; | 1325 | struct video_device *vfd = video_devdata(file); |
1153 | } | 1326 | v4l2_std_id *id = arg; |
1154 | case VIDIOC_S_INPUT: | ||
1155 | { | ||
1156 | unsigned int *i = arg; | ||
1157 | 1327 | ||
1158 | dbgarg(cmd, "value=%d\n", *i); | 1328 | /* Calls the specific handler */ |
1159 | ret = ops->vidioc_s_input(file, fh, *i); | 1329 | if (ops->vidioc_g_std) |
1160 | break; | 1330 | return ops->vidioc_g_std(file, fh, arg); |
1331 | if (vfd->current_norm) { | ||
1332 | *id = vfd->current_norm; | ||
1333 | return 0; | ||
1161 | } | 1334 | } |
1335 | return -ENOTTY; | ||
1336 | } | ||
1162 | 1337 | ||
1163 | /* ------ output switching ---------- */ | 1338 | static int v4l_s_std(const struct v4l2_ioctl_ops *ops, |
1164 | case VIDIOC_ENUMOUTPUT: | 1339 | struct file *file, void *fh, void *arg) |
1165 | { | 1340 | { |
1166 | struct v4l2_output *p = arg; | 1341 | struct video_device *vfd = video_devdata(file); |
1167 | 1342 | v4l2_std_id *id = arg, norm; | |
1168 | /* | 1343 | int ret; |
1169 | * We set the flags for CAP_PRESETS, CAP_CUSTOM_TIMINGS & | ||
1170 | * CAP_STD here based on ioctl handler provided by the | ||
1171 | * driver. If the driver doesn't support these | ||
1172 | * for a specific output, it must override these flags. | ||
1173 | */ | ||
1174 | if (ops->vidioc_s_std) | ||
1175 | p->capabilities |= V4L2_OUT_CAP_STD; | ||
1176 | if (ops->vidioc_s_dv_preset) | ||
1177 | p->capabilities |= V4L2_OUT_CAP_PRESETS; | ||
1178 | if (ops->vidioc_s_dv_timings) | ||
1179 | p->capabilities |= V4L2_OUT_CAP_CUSTOM_TIMINGS; | ||
1180 | |||
1181 | ret = ops->vidioc_enum_output(file, fh, p); | ||
1182 | if (!ret) | ||
1183 | dbgarg(cmd, "index=%d, name=%s, type=%d, " | ||
1184 | "audioset=0x%x, " | ||
1185 | "modulator=%d, std=0x%08Lx\n", | ||
1186 | p->index, p->name, p->type, p->audioset, | ||
1187 | p->modulator, (unsigned long long)p->std); | ||
1188 | break; | ||
1189 | } | ||
1190 | case VIDIOC_G_OUTPUT: | ||
1191 | { | ||
1192 | unsigned int *i = arg; | ||
1193 | 1344 | ||
1194 | ret = ops->vidioc_g_output(file, fh, i); | 1345 | norm = (*id) & vfd->tvnorms; |
1195 | if (!ret) | 1346 | if (vfd->tvnorms && !norm) /* Check if std is supported */ |
1196 | dbgarg(cmd, "value=%d\n", *i); | 1347 | return -EINVAL; |
1197 | break; | ||
1198 | } | ||
1199 | case VIDIOC_S_OUTPUT: | ||
1200 | { | ||
1201 | unsigned int *i = arg; | ||
1202 | 1348 | ||
1203 | dbgarg(cmd, "value=%d\n", *i); | 1349 | /* Calls the specific handler */ |
1204 | ret = ops->vidioc_s_output(file, fh, *i); | 1350 | ret = ops->vidioc_s_std(file, fh, &norm); |
1205 | break; | ||
1206 | } | ||
1207 | 1351 | ||
1208 | /* --- controls ---------------------------------------------- */ | 1352 | /* Updates standard information */ |
1209 | case VIDIOC_QUERYCTRL: | 1353 | if (ret >= 0) |
1210 | { | 1354 | vfd->current_norm = norm; |
1211 | struct v4l2_queryctrl *p = arg; | 1355 | return ret; |
1212 | 1356 | } | |
1213 | if (vfh && vfh->ctrl_handler) | ||
1214 | ret = v4l2_queryctrl(vfh->ctrl_handler, p); | ||
1215 | else if (vfd->ctrl_handler) | ||
1216 | ret = v4l2_queryctrl(vfd->ctrl_handler, p); | ||
1217 | else if (ops->vidioc_queryctrl) | ||
1218 | ret = ops->vidioc_queryctrl(file, fh, p); | ||
1219 | else | ||
1220 | break; | ||
1221 | if (!ret) | ||
1222 | dbgarg(cmd, "id=0x%x, type=%d, name=%s, min/max=%d/%d, " | ||
1223 | "step=%d, default=%d, flags=0x%08x\n", | ||
1224 | p->id, p->type, p->name, | ||
1225 | p->minimum, p->maximum, | ||
1226 | p->step, p->default_value, p->flags); | ||
1227 | else | ||
1228 | dbgarg(cmd, "id=0x%x\n", p->id); | ||
1229 | break; | ||
1230 | } | ||
1231 | case VIDIOC_G_CTRL: | ||
1232 | { | ||
1233 | struct v4l2_control *p = arg; | ||
1234 | |||
1235 | if (vfh && vfh->ctrl_handler) | ||
1236 | ret = v4l2_g_ctrl(vfh->ctrl_handler, p); | ||
1237 | else if (vfd->ctrl_handler) | ||
1238 | ret = v4l2_g_ctrl(vfd->ctrl_handler, p); | ||
1239 | else if (ops->vidioc_g_ctrl) | ||
1240 | ret = ops->vidioc_g_ctrl(file, fh, p); | ||
1241 | else if (ops->vidioc_g_ext_ctrls) { | ||
1242 | struct v4l2_ext_controls ctrls; | ||
1243 | struct v4l2_ext_control ctrl; | ||
1244 | |||
1245 | ctrls.ctrl_class = V4L2_CTRL_ID2CLASS(p->id); | ||
1246 | ctrls.count = 1; | ||
1247 | ctrls.controls = &ctrl; | ||
1248 | ctrl.id = p->id; | ||
1249 | ctrl.value = p->value; | ||
1250 | if (check_ext_ctrls(&ctrls, 1)) { | ||
1251 | ret = ops->vidioc_g_ext_ctrls(file, fh, &ctrls); | ||
1252 | if (ret == 0) | ||
1253 | p->value = ctrl.value; | ||
1254 | } | ||
1255 | } else | ||
1256 | break; | ||
1257 | if (!ret) | ||
1258 | dbgarg(cmd, "id=0x%x, value=%d\n", p->id, p->value); | ||
1259 | else | ||
1260 | dbgarg(cmd, "id=0x%x\n", p->id); | ||
1261 | break; | ||
1262 | } | ||
1263 | case VIDIOC_S_CTRL: | ||
1264 | { | ||
1265 | struct v4l2_control *p = arg; | ||
1266 | struct v4l2_ext_controls ctrls; | ||
1267 | struct v4l2_ext_control ctrl; | ||
1268 | |||
1269 | if (!(vfh && vfh->ctrl_handler) && !vfd->ctrl_handler && | ||
1270 | !ops->vidioc_s_ctrl && !ops->vidioc_s_ext_ctrls) | ||
1271 | break; | ||
1272 | 1357 | ||
1273 | dbgarg(cmd, "id=0x%x, value=%d\n", p->id, p->value); | 1358 | static int v4l_querystd(const struct v4l2_ioctl_ops *ops, |
1359 | struct file *file, void *fh, void *arg) | ||
1360 | { | ||
1361 | struct video_device *vfd = video_devdata(file); | ||
1362 | v4l2_std_id *p = arg; | ||
1363 | |||
1364 | /* | ||
1365 | * If nothing detected, it should return all supported | ||
1366 | * standard. | ||
1367 | * Drivers just need to mask the std argument, in order | ||
1368 | * to remove the standards that don't apply from the mask. | ||
1369 | * This means that tuners, audio and video decoders can join | ||
1370 | * their efforts to improve the standards detection. | ||
1371 | */ | ||
1372 | *p = vfd->tvnorms; | ||
1373 | return ops->vidioc_querystd(file, fh, arg); | ||
1374 | } | ||
1274 | 1375 | ||
1275 | if (vfh && vfh->ctrl_handler) { | 1376 | static int v4l_s_hw_freq_seek(const struct v4l2_ioctl_ops *ops, |
1276 | ret = v4l2_s_ctrl(vfh, vfh->ctrl_handler, p); | 1377 | struct file *file, void *fh, void *arg) |
1277 | break; | 1378 | { |
1278 | } | 1379 | struct video_device *vfd = video_devdata(file); |
1279 | if (vfd->ctrl_handler) { | 1380 | struct v4l2_hw_freq_seek *p = arg; |
1280 | ret = v4l2_s_ctrl(NULL, vfd->ctrl_handler, p); | 1381 | enum v4l2_tuner_type type; |
1281 | break; | ||
1282 | } | ||
1283 | if (ops->vidioc_s_ctrl) { | ||
1284 | ret = ops->vidioc_s_ctrl(file, fh, p); | ||
1285 | break; | ||
1286 | } | ||
1287 | if (!ops->vidioc_s_ext_ctrls) | ||
1288 | break; | ||
1289 | 1382 | ||
1290 | ctrls.ctrl_class = V4L2_CTRL_ID2CLASS(p->id); | 1383 | type = (vfd->vfl_type == VFL_TYPE_RADIO) ? |
1291 | ctrls.count = 1; | 1384 | V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; |
1292 | ctrls.controls = &ctrl; | 1385 | if (p->type != type) |
1293 | ctrl.id = p->id; | 1386 | return -EINVAL; |
1294 | ctrl.value = p->value; | 1387 | return ops->vidioc_s_hw_freq_seek(file, fh, p); |
1295 | if (check_ext_ctrls(&ctrls, 1)) | 1388 | } |
1296 | ret = ops->vidioc_s_ext_ctrls(file, fh, &ctrls); | ||
1297 | else | ||
1298 | ret = -EINVAL; | ||
1299 | break; | ||
1300 | } | ||
1301 | case VIDIOC_G_EXT_CTRLS: | ||
1302 | { | ||
1303 | struct v4l2_ext_controls *p = arg; | ||
1304 | |||
1305 | p->error_idx = p->count; | ||
1306 | if (vfh && vfh->ctrl_handler) | ||
1307 | ret = v4l2_g_ext_ctrls(vfh->ctrl_handler, p); | ||
1308 | else if (vfd->ctrl_handler) | ||
1309 | ret = v4l2_g_ext_ctrls(vfd->ctrl_handler, p); | ||
1310 | else if (ops->vidioc_g_ext_ctrls) | ||
1311 | ret = check_ext_ctrls(p, 0) ? | ||
1312 | ops->vidioc_g_ext_ctrls(file, fh, p) : | ||
1313 | -EINVAL; | ||
1314 | else | ||
1315 | break; | ||
1316 | v4l_print_ext_ctrls(cmd, vfd, p, !ret); | ||
1317 | break; | ||
1318 | } | ||
1319 | case VIDIOC_S_EXT_CTRLS: | ||
1320 | { | ||
1321 | struct v4l2_ext_controls *p = arg; | ||
1322 | 1389 | ||
1323 | p->error_idx = p->count; | 1390 | static int v4l_reqbufs(const struct v4l2_ioctl_ops *ops, |
1324 | if (!(vfh && vfh->ctrl_handler) && !vfd->ctrl_handler && | 1391 | struct file *file, void *fh, void *arg) |
1325 | !ops->vidioc_s_ext_ctrls) | 1392 | { |
1326 | break; | 1393 | struct v4l2_requestbuffers *p = arg; |
1327 | v4l_print_ext_ctrls(cmd, vfd, p, 1); | 1394 | int ret = check_fmt(ops, p->type); |
1328 | if (vfh && vfh->ctrl_handler) | ||
1329 | ret = v4l2_s_ext_ctrls(vfh, vfh->ctrl_handler, p); | ||
1330 | else if (vfd->ctrl_handler) | ||
1331 | ret = v4l2_s_ext_ctrls(NULL, vfd->ctrl_handler, p); | ||
1332 | else if (check_ext_ctrls(p, 0)) | ||
1333 | ret = ops->vidioc_s_ext_ctrls(file, fh, p); | ||
1334 | else | ||
1335 | ret = -EINVAL; | ||
1336 | break; | ||
1337 | } | ||
1338 | case VIDIOC_TRY_EXT_CTRLS: | ||
1339 | { | ||
1340 | struct v4l2_ext_controls *p = arg; | ||
1341 | 1395 | ||
1342 | p->error_idx = p->count; | 1396 | if (ret) |
1343 | if (!(vfh && vfh->ctrl_handler) && !vfd->ctrl_handler && | 1397 | return ret; |
1344 | !ops->vidioc_try_ext_ctrls) | ||
1345 | break; | ||
1346 | v4l_print_ext_ctrls(cmd, vfd, p, 1); | ||
1347 | if (vfh && vfh->ctrl_handler) | ||
1348 | ret = v4l2_try_ext_ctrls(vfh->ctrl_handler, p); | ||
1349 | else if (vfd->ctrl_handler) | ||
1350 | ret = v4l2_try_ext_ctrls(vfd->ctrl_handler, p); | ||
1351 | else if (check_ext_ctrls(p, 0)) | ||
1352 | ret = ops->vidioc_try_ext_ctrls(file, fh, p); | ||
1353 | else | ||
1354 | ret = -EINVAL; | ||
1355 | break; | ||
1356 | } | ||
1357 | case VIDIOC_QUERYMENU: | ||
1358 | { | ||
1359 | struct v4l2_querymenu *p = arg; | ||
1360 | |||
1361 | if (vfh && vfh->ctrl_handler) | ||
1362 | ret = v4l2_querymenu(vfh->ctrl_handler, p); | ||
1363 | else if (vfd->ctrl_handler) | ||
1364 | ret = v4l2_querymenu(vfd->ctrl_handler, p); | ||
1365 | else if (ops->vidioc_querymenu) | ||
1366 | ret = ops->vidioc_querymenu(file, fh, p); | ||
1367 | else | ||
1368 | break; | ||
1369 | if (!ret) | ||
1370 | dbgarg(cmd, "id=0x%x, index=%d, name=%s\n", | ||
1371 | p->id, p->index, p->name); | ||
1372 | else | ||
1373 | dbgarg(cmd, "id=0x%x, index=%d\n", | ||
1374 | p->id, p->index); | ||
1375 | break; | ||
1376 | } | ||
1377 | /* --- audio ---------------------------------------------- */ | ||
1378 | case VIDIOC_ENUMAUDIO: | ||
1379 | { | ||
1380 | struct v4l2_audio *p = arg; | ||
1381 | |||
1382 | ret = ops->vidioc_enumaudio(file, fh, p); | ||
1383 | if (!ret) | ||
1384 | dbgarg(cmd, "index=%d, name=%s, capability=0x%x, " | ||
1385 | "mode=0x%x\n", p->index, p->name, | ||
1386 | p->capability, p->mode); | ||
1387 | else | ||
1388 | dbgarg(cmd, "index=%d\n", p->index); | ||
1389 | break; | ||
1390 | } | ||
1391 | case VIDIOC_G_AUDIO: | ||
1392 | { | ||
1393 | struct v4l2_audio *p = arg; | ||
1394 | |||
1395 | ret = ops->vidioc_g_audio(file, fh, p); | ||
1396 | if (!ret) | ||
1397 | dbgarg(cmd, "index=%d, name=%s, capability=0x%x, " | ||
1398 | "mode=0x%x\n", p->index, | ||
1399 | p->name, p->capability, p->mode); | ||
1400 | else | ||
1401 | dbgarg(cmd, "index=%d\n", p->index); | ||
1402 | break; | ||
1403 | } | ||
1404 | case VIDIOC_S_AUDIO: | ||
1405 | { | ||
1406 | struct v4l2_audio *p = arg; | ||
1407 | |||
1408 | dbgarg(cmd, "index=%d, name=%s, capability=0x%x, " | ||
1409 | "mode=0x%x\n", p->index, p->name, | ||
1410 | p->capability, p->mode); | ||
1411 | ret = ops->vidioc_s_audio(file, fh, p); | ||
1412 | break; | ||
1413 | } | ||
1414 | case VIDIOC_ENUMAUDOUT: | ||
1415 | { | ||
1416 | struct v4l2_audioout *p = arg; | ||
1417 | |||
1418 | dbgarg(cmd, "Enum for index=%d\n", p->index); | ||
1419 | ret = ops->vidioc_enumaudout(file, fh, p); | ||
1420 | if (!ret) | ||
1421 | dbgarg2("index=%d, name=%s, capability=%d, " | ||
1422 | "mode=%d\n", p->index, p->name, | ||
1423 | p->capability, p->mode); | ||
1424 | break; | ||
1425 | } | ||
1426 | case VIDIOC_G_AUDOUT: | ||
1427 | { | ||
1428 | struct v4l2_audioout *p = arg; | ||
1429 | |||
1430 | ret = ops->vidioc_g_audout(file, fh, p); | ||
1431 | if (!ret) | ||
1432 | dbgarg2("index=%d, name=%s, capability=%d, " | ||
1433 | "mode=%d\n", p->index, p->name, | ||
1434 | p->capability, p->mode); | ||
1435 | break; | ||
1436 | } | ||
1437 | case VIDIOC_S_AUDOUT: | ||
1438 | { | ||
1439 | struct v4l2_audioout *p = arg; | ||
1440 | 1398 | ||
1441 | dbgarg(cmd, "index=%d, name=%s, capability=%d, " | 1399 | if (p->type < V4L2_BUF_TYPE_PRIVATE) |
1442 | "mode=%d\n", p->index, p->name, | 1400 | CLEAR_AFTER_FIELD(p, memory); |
1443 | p->capability, p->mode); | ||
1444 | 1401 | ||
1445 | ret = ops->vidioc_s_audout(file, fh, p); | 1402 | return ops->vidioc_reqbufs(file, fh, p); |
1446 | break; | 1403 | } |
1447 | } | ||
1448 | case VIDIOC_G_MODULATOR: | ||
1449 | { | ||
1450 | struct v4l2_modulator *p = arg; | ||
1451 | |||
1452 | ret = ops->vidioc_g_modulator(file, fh, p); | ||
1453 | if (!ret) | ||
1454 | dbgarg(cmd, "index=%d, name=%s, " | ||
1455 | "capability=%d, rangelow=%d," | ||
1456 | " rangehigh=%d, txsubchans=%d\n", | ||
1457 | p->index, p->name, p->capability, | ||
1458 | p->rangelow, p->rangehigh, | ||
1459 | p->txsubchans); | ||
1460 | break; | ||
1461 | } | ||
1462 | case VIDIOC_S_MODULATOR: | ||
1463 | { | ||
1464 | struct v4l2_modulator *p = arg; | ||
1465 | |||
1466 | dbgarg(cmd, "index=%d, name=%s, capability=%d, " | ||
1467 | "rangelow=%d, rangehigh=%d, txsubchans=%d\n", | ||
1468 | p->index, p->name, p->capability, p->rangelow, | ||
1469 | p->rangehigh, p->txsubchans); | ||
1470 | ret = ops->vidioc_s_modulator(file, fh, p); | ||
1471 | break; | ||
1472 | } | ||
1473 | case VIDIOC_G_CROP: | ||
1474 | { | ||
1475 | struct v4l2_crop *p = arg; | ||
1476 | 1404 | ||
1477 | dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names)); | 1405 | static int v4l_querybuf(const struct v4l2_ioctl_ops *ops, |
1406 | struct file *file, void *fh, void *arg) | ||
1407 | { | ||
1408 | struct v4l2_buffer *p = arg; | ||
1409 | int ret = check_fmt(ops, p->type); | ||
1478 | 1410 | ||
1479 | if (ops->vidioc_g_crop) { | 1411 | return ret ? ret : ops->vidioc_querybuf(file, fh, p); |
1480 | ret = ops->vidioc_g_crop(file, fh, p); | 1412 | } |
1481 | } else { | ||
1482 | /* simulate capture crop using selection api */ | ||
1483 | struct v4l2_selection s = { | ||
1484 | .type = p->type, | ||
1485 | }; | ||
1486 | |||
1487 | /* crop means compose for output devices */ | ||
1488 | if (V4L2_TYPE_IS_OUTPUT(p->type)) | ||
1489 | s.target = V4L2_SEL_TGT_COMPOSE_ACTIVE; | ||
1490 | else | ||
1491 | s.target = V4L2_SEL_TGT_CROP_ACTIVE; | ||
1492 | |||
1493 | ret = ops->vidioc_g_selection(file, fh, &s); | ||
1494 | |||
1495 | /* copying results to old structure on success */ | ||
1496 | if (!ret) | ||
1497 | p->c = s.r; | ||
1498 | } | ||
1499 | 1413 | ||
1500 | if (!ret) | 1414 | static int v4l_qbuf(const struct v4l2_ioctl_ops *ops, |
1501 | dbgrect(vfd, "", &p->c); | 1415 | struct file *file, void *fh, void *arg) |
1502 | break; | 1416 | { |
1503 | } | 1417 | struct v4l2_buffer *p = arg; |
1504 | case VIDIOC_S_CROP: | 1418 | int ret = check_fmt(ops, p->type); |
1505 | { | ||
1506 | struct v4l2_crop *p = arg; | ||
1507 | 1419 | ||
1508 | dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names)); | 1420 | return ret ? ret : ops->vidioc_qbuf(file, fh, p); |
1509 | dbgrect(vfd, "", &p->c); | 1421 | } |
1510 | 1422 | ||
1511 | if (ops->vidioc_s_crop) { | 1423 | static int v4l_dqbuf(const struct v4l2_ioctl_ops *ops, |
1512 | ret = ops->vidioc_s_crop(file, fh, p); | 1424 | struct file *file, void *fh, void *arg) |
1513 | } else { | 1425 | { |
1514 | /* simulate capture crop using selection api */ | 1426 | struct v4l2_buffer *p = arg; |
1515 | struct v4l2_selection s = { | 1427 | int ret = check_fmt(ops, p->type); |
1516 | .type = p->type, | ||
1517 | .r = p->c, | ||
1518 | }; | ||
1519 | |||
1520 | /* crop means compose for output devices */ | ||
1521 | if (V4L2_TYPE_IS_OUTPUT(p->type)) | ||
1522 | s.target = V4L2_SEL_TGT_COMPOSE_ACTIVE; | ||
1523 | else | ||
1524 | s.target = V4L2_SEL_TGT_CROP_ACTIVE; | ||
1525 | |||
1526 | ret = ops->vidioc_s_selection(file, fh, &s); | ||
1527 | } | ||
1528 | break; | ||
1529 | } | ||
1530 | case VIDIOC_G_SELECTION: | ||
1531 | { | ||
1532 | struct v4l2_selection *p = arg; | ||
1533 | 1428 | ||
1534 | dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names)); | 1429 | return ret ? ret : ops->vidioc_dqbuf(file, fh, p); |
1430 | } | ||
1535 | 1431 | ||
1536 | ret = ops->vidioc_g_selection(file, fh, p); | 1432 | static int v4l_create_bufs(const struct v4l2_ioctl_ops *ops, |
1537 | if (!ret) | 1433 | struct file *file, void *fh, void *arg) |
1538 | dbgrect(vfd, "", &p->r); | 1434 | { |
1539 | break; | 1435 | struct v4l2_create_buffers *create = arg; |
1540 | } | 1436 | int ret = check_fmt(ops, create->format.type); |
1541 | case VIDIOC_S_SELECTION: | ||
1542 | { | ||
1543 | struct v4l2_selection *p = arg; | ||
1544 | 1437 | ||
1438 | return ret ? ret : ops->vidioc_create_bufs(file, fh, create); | ||
1439 | } | ||
1545 | 1440 | ||
1546 | dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names)); | 1441 | static int v4l_prepare_buf(const struct v4l2_ioctl_ops *ops, |
1547 | dbgrect(vfd, "", &p->r); | 1442 | struct file *file, void *fh, void *arg) |
1443 | { | ||
1444 | struct v4l2_buffer *b = arg; | ||
1445 | int ret = check_fmt(ops, b->type); | ||
1548 | 1446 | ||
1549 | ret = ops->vidioc_s_selection(file, fh, p); | 1447 | return ret ? ret : ops->vidioc_prepare_buf(file, fh, b); |
1550 | break; | 1448 | } |
1551 | } | ||
1552 | case VIDIOC_CROPCAP: | ||
1553 | { | ||
1554 | struct v4l2_cropcap *p = arg; | ||
1555 | |||
1556 | /*FIXME: Should also show v4l2_fract pixelaspect */ | ||
1557 | dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names)); | ||
1558 | if (ops->vidioc_cropcap) { | ||
1559 | ret = ops->vidioc_cropcap(file, fh, p); | ||
1560 | } else { | ||
1561 | struct v4l2_selection s = { .type = p->type }; | ||
1562 | 1449 | ||
1563 | /* obtaining bounds */ | 1450 | static int v4l_g_parm(const struct v4l2_ioctl_ops *ops, |
1564 | if (V4L2_TYPE_IS_OUTPUT(p->type)) | 1451 | struct file *file, void *fh, void *arg) |
1565 | s.target = V4L2_SEL_TGT_COMPOSE_BOUNDS; | 1452 | { |
1566 | else | 1453 | struct video_device *vfd = video_devdata(file); |
1567 | s.target = V4L2_SEL_TGT_CROP_BOUNDS; | 1454 | struct v4l2_streamparm *p = arg; |
1455 | v4l2_std_id std; | ||
1456 | int ret = check_fmt(ops, p->type); | ||
1568 | 1457 | ||
1569 | ret = ops->vidioc_g_selection(file, fh, &s); | 1458 | if (ret) |
1570 | if (ret) | 1459 | return ret; |
1571 | break; | 1460 | if (ops->vidioc_g_parm) |
1572 | p->bounds = s.r; | 1461 | return ops->vidioc_g_parm(file, fh, p); |
1462 | std = vfd->current_norm; | ||
1463 | if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && | ||
1464 | p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) | ||
1465 | return -EINVAL; | ||
1466 | p->parm.capture.readbuffers = 2; | ||
1467 | if (ops->vidioc_g_std) | ||
1468 | ret = ops->vidioc_g_std(file, fh, &std); | ||
1469 | if (ret == 0) | ||
1470 | v4l2_video_std_frame_period(std, | ||
1471 | &p->parm.capture.timeperframe); | ||
1472 | return ret; | ||
1473 | } | ||
1573 | 1474 | ||
1574 | /* obtaining defrect */ | 1475 | static int v4l_s_parm(const struct v4l2_ioctl_ops *ops, |
1575 | if (V4L2_TYPE_IS_OUTPUT(p->type)) | 1476 | struct file *file, void *fh, void *arg) |
1576 | s.target = V4L2_SEL_TGT_COMPOSE_DEFAULT; | 1477 | { |
1577 | else | 1478 | struct v4l2_streamparm *p = arg; |
1578 | s.target = V4L2_SEL_TGT_CROP_DEFAULT; | 1479 | int ret = check_fmt(ops, p->type); |
1579 | 1480 | ||
1580 | ret = ops->vidioc_g_selection(file, fh, &s); | 1481 | return ret ? ret : ops->vidioc_s_parm(file, fh, p); |
1581 | if (ret) | 1482 | } |
1582 | break; | ||
1583 | p->defrect = s.r; | ||
1584 | 1483 | ||
1585 | /* setting trivial pixelaspect */ | 1484 | static int v4l_queryctrl(const struct v4l2_ioctl_ops *ops, |
1586 | p->pixelaspect.numerator = 1; | 1485 | struct file *file, void *fh, void *arg) |
1587 | p->pixelaspect.denominator = 1; | 1486 | { |
1588 | } | 1487 | struct video_device *vfd = video_devdata(file); |
1488 | struct v4l2_queryctrl *p = arg; | ||
1489 | struct v4l2_fh *vfh = fh; | ||
1490 | |||
1491 | if (vfh && vfh->ctrl_handler) | ||
1492 | return v4l2_queryctrl(vfh->ctrl_handler, p); | ||
1493 | if (vfd->ctrl_handler) | ||
1494 | return v4l2_queryctrl(vfd->ctrl_handler, p); | ||
1495 | if (ops->vidioc_queryctrl) | ||
1496 | return ops->vidioc_queryctrl(file, fh, p); | ||
1497 | return -ENOTTY; | ||
1498 | } | ||
1589 | 1499 | ||
1590 | if (!ret) { | 1500 | static int v4l_querymenu(const struct v4l2_ioctl_ops *ops, |
1591 | dbgrect(vfd, "bounds ", &p->bounds); | 1501 | struct file *file, void *fh, void *arg) |
1592 | dbgrect(vfd, "defrect ", &p->defrect); | 1502 | { |
1593 | } | 1503 | struct video_device *vfd = video_devdata(file); |
1594 | break; | 1504 | struct v4l2_querymenu *p = arg; |
1595 | } | 1505 | struct v4l2_fh *vfh = fh; |
1596 | case VIDIOC_G_JPEGCOMP: | 1506 | |
1597 | { | 1507 | if (vfh && vfh->ctrl_handler) |
1598 | struct v4l2_jpegcompression *p = arg; | 1508 | return v4l2_querymenu(vfh->ctrl_handler, p); |
1599 | 1509 | if (vfd->ctrl_handler) | |
1600 | ret = ops->vidioc_g_jpegcomp(file, fh, p); | 1510 | return v4l2_querymenu(vfd->ctrl_handler, p); |
1601 | if (!ret) | 1511 | if (ops->vidioc_querymenu) |
1602 | dbgarg(cmd, "quality=%d, APPn=%d, " | 1512 | return ops->vidioc_querymenu(file, fh, p); |
1603 | "APP_len=%d, COM_len=%d, " | 1513 | return -ENOTTY; |
1604 | "jpeg_markers=%d\n", | 1514 | } |
1605 | p->quality, p->APPn, p->APP_len, | ||
1606 | p->COM_len, p->jpeg_markers); | ||
1607 | break; | ||
1608 | } | ||
1609 | case VIDIOC_S_JPEGCOMP: | ||
1610 | { | ||
1611 | struct v4l2_jpegcompression *p = arg; | ||
1612 | |||
1613 | dbgarg(cmd, "quality=%d, APPn=%d, APP_len=%d, " | ||
1614 | "COM_len=%d, jpeg_markers=%d\n", | ||
1615 | p->quality, p->APPn, p->APP_len, | ||
1616 | p->COM_len, p->jpeg_markers); | ||
1617 | ret = ops->vidioc_s_jpegcomp(file, fh, p); | ||
1618 | break; | ||
1619 | } | ||
1620 | case VIDIOC_G_ENC_INDEX: | ||
1621 | { | ||
1622 | struct v4l2_enc_idx *p = arg; | ||
1623 | |||
1624 | ret = ops->vidioc_g_enc_index(file, fh, p); | ||
1625 | if (!ret) | ||
1626 | dbgarg(cmd, "entries=%d, entries_cap=%d\n", | ||
1627 | p->entries, p->entries_cap); | ||
1628 | break; | ||
1629 | } | ||
1630 | case VIDIOC_ENCODER_CMD: | ||
1631 | { | ||
1632 | struct v4l2_encoder_cmd *p = arg; | ||
1633 | 1515 | ||
1634 | ret = ops->vidioc_encoder_cmd(file, fh, p); | 1516 | static int v4l_g_ctrl(const struct v4l2_ioctl_ops *ops, |
1635 | if (!ret) | 1517 | struct file *file, void *fh, void *arg) |
1636 | dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags); | 1518 | { |
1637 | break; | 1519 | struct video_device *vfd = video_devdata(file); |
1520 | struct v4l2_control *p = arg; | ||
1521 | struct v4l2_fh *vfh = fh; | ||
1522 | struct v4l2_ext_controls ctrls; | ||
1523 | struct v4l2_ext_control ctrl; | ||
1524 | |||
1525 | if (vfh && vfh->ctrl_handler) | ||
1526 | return v4l2_g_ctrl(vfh->ctrl_handler, p); | ||
1527 | if (vfd->ctrl_handler) | ||
1528 | return v4l2_g_ctrl(vfd->ctrl_handler, p); | ||
1529 | if (ops->vidioc_g_ctrl) | ||
1530 | return ops->vidioc_g_ctrl(file, fh, p); | ||
1531 | if (ops->vidioc_g_ext_ctrls == NULL) | ||
1532 | return -ENOTTY; | ||
1533 | |||
1534 | ctrls.ctrl_class = V4L2_CTRL_ID2CLASS(p->id); | ||
1535 | ctrls.count = 1; | ||
1536 | ctrls.controls = &ctrl; | ||
1537 | ctrl.id = p->id; | ||
1538 | ctrl.value = p->value; | ||
1539 | if (check_ext_ctrls(&ctrls, 1)) { | ||
1540 | int ret = ops->vidioc_g_ext_ctrls(file, fh, &ctrls); | ||
1541 | |||
1542 | if (ret == 0) | ||
1543 | p->value = ctrl.value; | ||
1544 | return ret; | ||
1638 | } | 1545 | } |
1639 | case VIDIOC_TRY_ENCODER_CMD: | 1546 | return -EINVAL; |
1640 | { | 1547 | } |
1641 | struct v4l2_encoder_cmd *p = arg; | ||
1642 | 1548 | ||
1643 | ret = ops->vidioc_try_encoder_cmd(file, fh, p); | 1549 | static int v4l_s_ctrl(const struct v4l2_ioctl_ops *ops, |
1644 | if (!ret) | 1550 | struct file *file, void *fh, void *arg) |
1645 | dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags); | 1551 | { |
1646 | break; | 1552 | struct video_device *vfd = video_devdata(file); |
1647 | } | 1553 | struct v4l2_control *p = arg; |
1648 | case VIDIOC_DECODER_CMD: | 1554 | struct v4l2_fh *vfh = fh; |
1649 | { | 1555 | struct v4l2_ext_controls ctrls; |
1650 | struct v4l2_decoder_cmd *p = arg; | 1556 | struct v4l2_ext_control ctrl; |
1557 | |||
1558 | if (vfh && vfh->ctrl_handler) | ||
1559 | return v4l2_s_ctrl(vfh, vfh->ctrl_handler, p); | ||
1560 | if (vfd->ctrl_handler) | ||
1561 | return v4l2_s_ctrl(NULL, vfd->ctrl_handler, p); | ||
1562 | if (ops->vidioc_s_ctrl) | ||
1563 | return ops->vidioc_s_ctrl(file, fh, p); | ||
1564 | if (ops->vidioc_s_ext_ctrls == NULL) | ||
1565 | return -ENOTTY; | ||
1566 | |||
1567 | ctrls.ctrl_class = V4L2_CTRL_ID2CLASS(p->id); | ||
1568 | ctrls.count = 1; | ||
1569 | ctrls.controls = &ctrl; | ||
1570 | ctrl.id = p->id; | ||
1571 | ctrl.value = p->value; | ||
1572 | if (check_ext_ctrls(&ctrls, 1)) | ||
1573 | return ops->vidioc_s_ext_ctrls(file, fh, &ctrls); | ||
1574 | return -EINVAL; | ||
1575 | } | ||
1651 | 1576 | ||
1652 | ret = ops->vidioc_decoder_cmd(file, fh, p); | 1577 | static int v4l_g_ext_ctrls(const struct v4l2_ioctl_ops *ops, |
1653 | if (!ret) | 1578 | struct file *file, void *fh, void *arg) |
1654 | dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags); | 1579 | { |
1655 | break; | 1580 | struct video_device *vfd = video_devdata(file); |
1656 | } | 1581 | struct v4l2_ext_controls *p = arg; |
1657 | case VIDIOC_TRY_DECODER_CMD: | 1582 | struct v4l2_fh *vfh = fh; |
1658 | { | 1583 | |
1659 | struct v4l2_decoder_cmd *p = arg; | 1584 | p->error_idx = p->count; |
1585 | if (vfh && vfh->ctrl_handler) | ||
1586 | return v4l2_g_ext_ctrls(vfh->ctrl_handler, p); | ||
1587 | if (vfd->ctrl_handler) | ||
1588 | return v4l2_g_ext_ctrls(vfd->ctrl_handler, p); | ||
1589 | if (ops->vidioc_g_ext_ctrls == NULL) | ||
1590 | return -ENOTTY; | ||
1591 | return check_ext_ctrls(p, 0) ? ops->vidioc_g_ext_ctrls(file, fh, p) : | ||
1592 | -EINVAL; | ||
1593 | } | ||
1660 | 1594 | ||
1661 | ret = ops->vidioc_try_decoder_cmd(file, fh, p); | 1595 | static int v4l_s_ext_ctrls(const struct v4l2_ioctl_ops *ops, |
1662 | if (!ret) | 1596 | struct file *file, void *fh, void *arg) |
1663 | dbgarg(cmd, "cmd=%d, flags=%x\n", p->cmd, p->flags); | 1597 | { |
1664 | break; | 1598 | struct video_device *vfd = video_devdata(file); |
1665 | } | 1599 | struct v4l2_ext_controls *p = arg; |
1666 | case VIDIOC_G_PARM: | 1600 | struct v4l2_fh *vfh = fh; |
1667 | { | 1601 | |
1668 | struct v4l2_streamparm *p = arg; | 1602 | p->error_idx = p->count; |
1603 | if (vfh && vfh->ctrl_handler) | ||
1604 | return v4l2_s_ext_ctrls(vfh, vfh->ctrl_handler, p); | ||
1605 | if (vfd->ctrl_handler) | ||
1606 | return v4l2_s_ext_ctrls(NULL, vfd->ctrl_handler, p); | ||
1607 | if (ops->vidioc_s_ext_ctrls == NULL) | ||
1608 | return -ENOTTY; | ||
1609 | return check_ext_ctrls(p, 0) ? ops->vidioc_s_ext_ctrls(file, fh, p) : | ||
1610 | -EINVAL; | ||
1611 | } | ||
1669 | 1612 | ||
1670 | if (ops->vidioc_g_parm) { | 1613 | static int v4l_try_ext_ctrls(const struct v4l2_ioctl_ops *ops, |
1671 | ret = check_fmt(ops, p->type); | 1614 | struct file *file, void *fh, void *arg) |
1672 | if (ret) | 1615 | { |
1673 | break; | 1616 | struct video_device *vfd = video_devdata(file); |
1674 | ret = ops->vidioc_g_parm(file, fh, p); | 1617 | struct v4l2_ext_controls *p = arg; |
1675 | } else { | 1618 | struct v4l2_fh *vfh = fh; |
1676 | v4l2_std_id std = vfd->current_norm; | 1619 | |
1620 | p->error_idx = p->count; | ||
1621 | if (vfh && vfh->ctrl_handler) | ||
1622 | return v4l2_try_ext_ctrls(vfh->ctrl_handler, p); | ||
1623 | if (vfd->ctrl_handler) | ||
1624 | return v4l2_try_ext_ctrls(vfd->ctrl_handler, p); | ||
1625 | if (ops->vidioc_try_ext_ctrls == NULL) | ||
1626 | return -ENOTTY; | ||
1627 | return check_ext_ctrls(p, 0) ? ops->vidioc_try_ext_ctrls(file, fh, p) : | ||
1628 | -EINVAL; | ||
1629 | } | ||
1677 | 1630 | ||
1678 | ret = -EINVAL; | 1631 | static int v4l_g_crop(const struct v4l2_ioctl_ops *ops, |
1679 | if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 1632 | struct file *file, void *fh, void *arg) |
1680 | break; | 1633 | { |
1634 | struct v4l2_crop *p = arg; | ||
1635 | struct v4l2_selection s = { | ||
1636 | .type = p->type, | ||
1637 | }; | ||
1638 | int ret; | ||
1639 | |||
1640 | if (ops->vidioc_g_crop) | ||
1641 | return ops->vidioc_g_crop(file, fh, p); | ||
1642 | /* simulate capture crop using selection api */ | ||
1643 | |||
1644 | /* crop means compose for output devices */ | ||
1645 | if (V4L2_TYPE_IS_OUTPUT(p->type)) | ||
1646 | s.target = V4L2_SEL_TGT_COMPOSE_ACTIVE; | ||
1647 | else | ||
1648 | s.target = V4L2_SEL_TGT_CROP_ACTIVE; | ||
1649 | |||
1650 | ret = ops->vidioc_g_selection(file, fh, &s); | ||
1651 | |||
1652 | /* copying results to old structure on success */ | ||
1653 | if (!ret) | ||
1654 | p->c = s.r; | ||
1655 | return ret; | ||
1656 | } | ||
1681 | 1657 | ||
1682 | ret = 0; | 1658 | static int v4l_s_crop(const struct v4l2_ioctl_ops *ops, |
1683 | p->parm.capture.readbuffers = 2; | 1659 | struct file *file, void *fh, void *arg) |
1684 | if (ops->vidioc_g_std) | 1660 | { |
1685 | ret = ops->vidioc_g_std(file, fh, &std); | 1661 | struct v4l2_crop *p = arg; |
1686 | if (ret == 0) | 1662 | struct v4l2_selection s = { |
1687 | v4l2_video_std_frame_period(std, | 1663 | .type = p->type, |
1688 | &p->parm.capture.timeperframe); | 1664 | .r = p->c, |
1689 | } | 1665 | }; |
1666 | |||
1667 | if (ops->vidioc_s_crop) | ||
1668 | return ops->vidioc_s_crop(file, fh, p); | ||
1669 | /* simulate capture crop using selection api */ | ||
1670 | |||
1671 | /* crop means compose for output devices */ | ||
1672 | if (V4L2_TYPE_IS_OUTPUT(p->type)) | ||
1673 | s.target = V4L2_SEL_TGT_COMPOSE_ACTIVE; | ||
1674 | else | ||
1675 | s.target = V4L2_SEL_TGT_CROP_ACTIVE; | ||
1676 | |||
1677 | return ops->vidioc_s_selection(file, fh, &s); | ||
1678 | } | ||
1690 | 1679 | ||
1691 | dbgarg(cmd, "type=%d\n", p->type); | 1680 | static int v4l_cropcap(const struct v4l2_ioctl_ops *ops, |
1692 | break; | 1681 | struct file *file, void *fh, void *arg) |
1693 | } | 1682 | { |
1694 | case VIDIOC_S_PARM: | 1683 | struct v4l2_cropcap *p = arg; |
1695 | { | 1684 | struct v4l2_selection s = { .type = p->type }; |
1696 | struct v4l2_streamparm *p = arg; | 1685 | int ret; |
1697 | 1686 | ||
1698 | ret = check_fmt(ops, p->type); | 1687 | if (ops->vidioc_cropcap) |
1699 | if (ret) | 1688 | return ops->vidioc_cropcap(file, fh, p); |
1700 | break; | ||
1701 | 1689 | ||
1702 | dbgarg(cmd, "type=%d\n", p->type); | 1690 | /* obtaining bounds */ |
1703 | ret = ops->vidioc_s_parm(file, fh, p); | 1691 | if (V4L2_TYPE_IS_OUTPUT(p->type)) |
1704 | break; | 1692 | s.target = V4L2_SEL_TGT_COMPOSE_BOUNDS; |
1705 | } | 1693 | else |
1706 | case VIDIOC_G_TUNER: | 1694 | s.target = V4L2_SEL_TGT_CROP_BOUNDS; |
1707 | { | ||
1708 | struct v4l2_tuner *p = arg; | ||
1709 | 1695 | ||
1710 | p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ? | 1696 | ret = ops->vidioc_g_selection(file, fh, &s); |
1711 | V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; | 1697 | if (ret) |
1712 | ret = ops->vidioc_g_tuner(file, fh, p); | 1698 | return ret; |
1713 | if (!ret) | 1699 | p->bounds = s.r; |
1714 | dbgarg(cmd, "index=%d, name=%s, type=%d, " | ||
1715 | "capability=0x%x, rangelow=%d, " | ||
1716 | "rangehigh=%d, signal=%d, afc=%d, " | ||
1717 | "rxsubchans=0x%x, audmode=%d\n", | ||
1718 | p->index, p->name, p->type, | ||
1719 | p->capability, p->rangelow, | ||
1720 | p->rangehigh, p->signal, p->afc, | ||
1721 | p->rxsubchans, p->audmode); | ||
1722 | break; | ||
1723 | } | ||
1724 | case VIDIOC_S_TUNER: | ||
1725 | { | ||
1726 | struct v4l2_tuner *p = arg; | ||
1727 | 1700 | ||
1728 | p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ? | 1701 | /* obtaining defrect */ |
1729 | V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; | 1702 | if (V4L2_TYPE_IS_OUTPUT(p->type)) |
1730 | dbgarg(cmd, "index=%d, name=%s, type=%d, " | 1703 | s.target = V4L2_SEL_TGT_COMPOSE_DEFAULT; |
1731 | "capability=0x%x, rangelow=%d, " | 1704 | else |
1732 | "rangehigh=%d, signal=%d, afc=%d, " | 1705 | s.target = V4L2_SEL_TGT_CROP_DEFAULT; |
1733 | "rxsubchans=0x%x, audmode=%d\n", | ||
1734 | p->index, p->name, p->type, | ||
1735 | p->capability, p->rangelow, | ||
1736 | p->rangehigh, p->signal, p->afc, | ||
1737 | p->rxsubchans, p->audmode); | ||
1738 | ret = ops->vidioc_s_tuner(file, fh, p); | ||
1739 | break; | ||
1740 | } | ||
1741 | case VIDIOC_G_FREQUENCY: | ||
1742 | { | ||
1743 | struct v4l2_frequency *p = arg; | ||
1744 | 1706 | ||
1745 | p->type = (vfd->vfl_type == VFL_TYPE_RADIO) ? | 1707 | ret = ops->vidioc_g_selection(file, fh, &s); |
1746 | V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; | 1708 | if (ret) |
1747 | ret = ops->vidioc_g_frequency(file, fh, p); | 1709 | return ret; |
1748 | if (!ret) | 1710 | p->defrect = s.r; |
1749 | dbgarg(cmd, "tuner=%d, type=%d, frequency=%d\n", | ||
1750 | p->tuner, p->type, p->frequency); | ||
1751 | break; | ||
1752 | } | ||
1753 | case VIDIOC_S_FREQUENCY: | ||
1754 | { | ||
1755 | struct v4l2_frequency *p = arg; | ||
1756 | enum v4l2_tuner_type type; | ||
1757 | 1711 | ||
1758 | type = (vfd->vfl_type == VFL_TYPE_RADIO) ? | 1712 | /* setting trivial pixelaspect */ |
1759 | V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; | 1713 | p->pixelaspect.numerator = 1; |
1760 | dbgarg(cmd, "tuner=%d, type=%d, frequency=%d\n", | 1714 | p->pixelaspect.denominator = 1; |
1761 | p->tuner, p->type, p->frequency); | 1715 | return 0; |
1762 | if (p->type != type) | 1716 | } |
1763 | ret = -EINVAL; | ||
1764 | else | ||
1765 | ret = ops->vidioc_s_frequency(file, fh, p); | ||
1766 | break; | ||
1767 | } | ||
1768 | case VIDIOC_G_SLICED_VBI_CAP: | ||
1769 | { | ||
1770 | struct v4l2_sliced_vbi_cap *p = arg; | ||
1771 | 1717 | ||
1772 | /* Clear up to type, everything after type is zerod already */ | 1718 | static int v4l_log_status(const struct v4l2_ioctl_ops *ops, |
1773 | memset(p, 0, offsetof(struct v4l2_sliced_vbi_cap, type)); | 1719 | struct file *file, void *fh, void *arg) |
1720 | { | ||
1721 | struct video_device *vfd = video_devdata(file); | ||
1722 | int ret; | ||
1723 | |||
1724 | if (vfd->v4l2_dev) | ||
1725 | pr_info("%s: ================= START STATUS =================\n", | ||
1726 | vfd->v4l2_dev->name); | ||
1727 | ret = ops->vidioc_log_status(file, fh); | ||
1728 | if (vfd->v4l2_dev) | ||
1729 | pr_info("%s: ================== END STATUS ==================\n", | ||
1730 | vfd->v4l2_dev->name); | ||
1731 | return ret; | ||
1732 | } | ||
1774 | 1733 | ||
1775 | dbgarg(cmd, "type=%s\n", prt_names(p->type, v4l2_type_names)); | 1734 | static int v4l_dbg_g_register(const struct v4l2_ioctl_ops *ops, |
1776 | ret = ops->vidioc_g_sliced_vbi_cap(file, fh, p); | 1735 | struct file *file, void *fh, void *arg) |
1777 | if (!ret) | 1736 | { |
1778 | dbgarg2("service_set=%d\n", p->service_set); | ||
1779 | break; | ||
1780 | } | ||
1781 | case VIDIOC_LOG_STATUS: | ||
1782 | { | ||
1783 | if (vfd->v4l2_dev) | ||
1784 | pr_info("%s: ================= START STATUS =================\n", | ||
1785 | vfd->v4l2_dev->name); | ||
1786 | ret = ops->vidioc_log_status(file, fh); | ||
1787 | if (vfd->v4l2_dev) | ||
1788 | pr_info("%s: ================== END STATUS ==================\n", | ||
1789 | vfd->v4l2_dev->name); | ||
1790 | break; | ||
1791 | } | ||
1792 | case VIDIOC_DBG_G_REGISTER: | ||
1793 | { | ||
1794 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 1737 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
1795 | struct v4l2_dbg_register *p = arg; | 1738 | struct v4l2_dbg_register *p = arg; |
1796 | 1739 | ||
1797 | if (!capable(CAP_SYS_ADMIN)) | 1740 | if (!capable(CAP_SYS_ADMIN)) |
1798 | ret = -EPERM; | 1741 | return -EPERM; |
1799 | else | 1742 | return ops->vidioc_g_register(file, fh, p); |
1800 | ret = ops->vidioc_g_register(file, fh, p); | 1743 | #else |
1744 | return -ENOTTY; | ||
1801 | #endif | 1745 | #endif |
1802 | break; | 1746 | } |
1803 | } | 1747 | |
1804 | case VIDIOC_DBG_S_REGISTER: | 1748 | static int v4l_dbg_s_register(const struct v4l2_ioctl_ops *ops, |
1805 | { | 1749 | struct file *file, void *fh, void *arg) |
1750 | { | ||
1806 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 1751 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
1807 | struct v4l2_dbg_register *p = arg; | 1752 | struct v4l2_dbg_register *p = arg; |
1808 | 1753 | ||
1809 | if (!capable(CAP_SYS_ADMIN)) | 1754 | if (!capable(CAP_SYS_ADMIN)) |
1810 | ret = -EPERM; | 1755 | return -EPERM; |
1811 | else | 1756 | return ops->vidioc_s_register(file, fh, p); |
1812 | ret = ops->vidioc_s_register(file, fh, p); | 1757 | #else |
1758 | return -ENOTTY; | ||
1813 | #endif | 1759 | #endif |
1814 | break; | 1760 | } |
1815 | } | ||
1816 | case VIDIOC_DBG_G_CHIP_IDENT: | ||
1817 | { | ||
1818 | struct v4l2_dbg_chip_ident *p = arg; | ||
1819 | |||
1820 | p->ident = V4L2_IDENT_NONE; | ||
1821 | p->revision = 0; | ||
1822 | ret = ops->vidioc_g_chip_ident(file, fh, p); | ||
1823 | if (!ret) | ||
1824 | dbgarg(cmd, "chip_ident=%u, revision=0x%x\n", p->ident, p->revision); | ||
1825 | break; | ||
1826 | } | ||
1827 | case VIDIOC_S_HW_FREQ_SEEK: | ||
1828 | { | ||
1829 | struct v4l2_hw_freq_seek *p = arg; | ||
1830 | enum v4l2_tuner_type type; | ||
1831 | 1761 | ||
1832 | type = (vfd->vfl_type == VFL_TYPE_RADIO) ? | 1762 | static int v4l_dbg_g_chip_ident(const struct v4l2_ioctl_ops *ops, |
1833 | V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; | 1763 | struct file *file, void *fh, void *arg) |
1834 | dbgarg(cmd, | 1764 | { |
1835 | "tuner=%u, type=%u, seek_upward=%u, wrap_around=%u, spacing=%u\n", | 1765 | struct v4l2_dbg_chip_ident *p = arg; |
1836 | p->tuner, p->type, p->seek_upward, p->wrap_around, p->spacing); | ||
1837 | if (p->type != type) | ||
1838 | ret = -EINVAL; | ||
1839 | else | ||
1840 | ret = ops->vidioc_s_hw_freq_seek(file, fh, p); | ||
1841 | break; | ||
1842 | } | ||
1843 | case VIDIOC_ENUM_FRAMESIZES: | ||
1844 | { | ||
1845 | struct v4l2_frmsizeenum *p = arg; | ||
1846 | 1766 | ||
1847 | ret = ops->vidioc_enum_framesizes(file, fh, p); | 1767 | p->ident = V4L2_IDENT_NONE; |
1848 | dbgarg(cmd, | 1768 | p->revision = 0; |
1849 | "index=%d, pixelformat=%c%c%c%c, type=%d ", | 1769 | return ops->vidioc_g_chip_ident(file, fh, p); |
1850 | p->index, | 1770 | } |
1851 | (p->pixel_format & 0xff), | ||
1852 | (p->pixel_format >> 8) & 0xff, | ||
1853 | (p->pixel_format >> 16) & 0xff, | ||
1854 | (p->pixel_format >> 24) & 0xff, | ||
1855 | p->type); | ||
1856 | switch (p->type) { | ||
1857 | case V4L2_FRMSIZE_TYPE_DISCRETE: | ||
1858 | dbgarg3("width = %d, height=%d\n", | ||
1859 | p->discrete.width, p->discrete.height); | ||
1860 | break; | ||
1861 | case V4L2_FRMSIZE_TYPE_STEPWISE: | ||
1862 | dbgarg3("min %dx%d, max %dx%d, step %dx%d\n", | ||
1863 | p->stepwise.min_width, p->stepwise.min_height, | ||
1864 | p->stepwise.step_width, p->stepwise.step_height, | ||
1865 | p->stepwise.max_width, p->stepwise.max_height); | ||
1866 | break; | ||
1867 | case V4L2_FRMSIZE_TYPE_CONTINUOUS: | ||
1868 | dbgarg3("continuous\n"); | ||
1869 | break; | ||
1870 | default: | ||
1871 | dbgarg3("- Unknown type!\n"); | ||
1872 | } | ||
1873 | 1771 | ||
1874 | break; | 1772 | static int v4l_dqevent(const struct v4l2_ioctl_ops *ops, |
1875 | } | 1773 | struct file *file, void *fh, void *arg) |
1876 | case VIDIOC_ENUM_FRAMEINTERVALS: | 1774 | { |
1877 | { | 1775 | return v4l2_event_dequeue(fh, arg, file->f_flags & O_NONBLOCK); |
1878 | struct v4l2_frmivalenum *p = arg; | 1776 | } |
1879 | |||
1880 | ret = ops->vidioc_enum_frameintervals(file, fh, p); | ||
1881 | dbgarg(cmd, | ||
1882 | "index=%d, pixelformat=%d, width=%d, height=%d, type=%d ", | ||
1883 | p->index, p->pixel_format, | ||
1884 | p->width, p->height, p->type); | ||
1885 | switch (p->type) { | ||
1886 | case V4L2_FRMIVAL_TYPE_DISCRETE: | ||
1887 | dbgarg2("fps=%d/%d\n", | ||
1888 | p->discrete.numerator, | ||
1889 | p->discrete.denominator); | ||
1890 | break; | ||
1891 | case V4L2_FRMIVAL_TYPE_STEPWISE: | ||
1892 | dbgarg2("min=%d/%d, max=%d/%d, step=%d/%d\n", | ||
1893 | p->stepwise.min.numerator, | ||
1894 | p->stepwise.min.denominator, | ||
1895 | p->stepwise.max.numerator, | ||
1896 | p->stepwise.max.denominator, | ||
1897 | p->stepwise.step.numerator, | ||
1898 | p->stepwise.step.denominator); | ||
1899 | break; | ||
1900 | case V4L2_FRMIVAL_TYPE_CONTINUOUS: | ||
1901 | dbgarg2("continuous\n"); | ||
1902 | break; | ||
1903 | default: | ||
1904 | dbgarg2("- Unknown type!\n"); | ||
1905 | } | ||
1906 | break; | ||
1907 | } | ||
1908 | case VIDIOC_ENUM_DV_PRESETS: | ||
1909 | { | ||
1910 | struct v4l2_dv_enum_preset *p = arg; | ||
1911 | |||
1912 | ret = ops->vidioc_enum_dv_presets(file, fh, p); | ||
1913 | if (!ret) | ||
1914 | dbgarg(cmd, | ||
1915 | "index=%d, preset=%d, name=%s, width=%d," | ||
1916 | " height=%d ", | ||
1917 | p->index, p->preset, p->name, p->width, | ||
1918 | p->height); | ||
1919 | break; | ||
1920 | } | ||
1921 | case VIDIOC_S_DV_PRESET: | ||
1922 | { | ||
1923 | struct v4l2_dv_preset *p = arg; | ||
1924 | 1777 | ||
1925 | dbgarg(cmd, "preset=%d\n", p->preset); | 1778 | static int v4l_subscribe_event(const struct v4l2_ioctl_ops *ops, |
1926 | ret = ops->vidioc_s_dv_preset(file, fh, p); | 1779 | struct file *file, void *fh, void *arg) |
1927 | break; | 1780 | { |
1928 | } | 1781 | return ops->vidioc_subscribe_event(fh, arg); |
1929 | case VIDIOC_G_DV_PRESET: | 1782 | } |
1930 | { | ||
1931 | struct v4l2_dv_preset *p = arg; | ||
1932 | 1783 | ||
1933 | ret = ops->vidioc_g_dv_preset(file, fh, p); | 1784 | static int v4l_unsubscribe_event(const struct v4l2_ioctl_ops *ops, |
1934 | if (!ret) | 1785 | struct file *file, void *fh, void *arg) |
1935 | dbgarg(cmd, "preset=%d\n", p->preset); | 1786 | { |
1936 | break; | 1787 | return ops->vidioc_unsubscribe_event(fh, arg); |
1937 | } | 1788 | } |
1938 | case VIDIOC_QUERY_DV_PRESET: | ||
1939 | { | ||
1940 | struct v4l2_dv_preset *p = arg; | ||
1941 | 1789 | ||
1942 | ret = ops->vidioc_query_dv_preset(file, fh, p); | 1790 | static int v4l_g_sliced_vbi_cap(const struct v4l2_ioctl_ops *ops, |
1943 | if (!ret) | 1791 | struct file *file, void *fh, void *arg) |
1944 | dbgarg(cmd, "preset=%d\n", p->preset); | 1792 | { |
1945 | break; | 1793 | struct v4l2_sliced_vbi_cap *p = arg; |
1946 | } | ||
1947 | case VIDIOC_S_DV_TIMINGS: | ||
1948 | { | ||
1949 | struct v4l2_dv_timings *p = arg; | ||
1950 | |||
1951 | dbgtimings(vfd, p); | ||
1952 | switch (p->type) { | ||
1953 | case V4L2_DV_BT_656_1120: | ||
1954 | ret = ops->vidioc_s_dv_timings(file, fh, p); | ||
1955 | break; | ||
1956 | default: | ||
1957 | ret = -EINVAL; | ||
1958 | break; | ||
1959 | } | ||
1960 | break; | ||
1961 | } | ||
1962 | case VIDIOC_G_DV_TIMINGS: | ||
1963 | { | ||
1964 | struct v4l2_dv_timings *p = arg; | ||
1965 | 1794 | ||
1966 | ret = ops->vidioc_g_dv_timings(file, fh, p); | 1795 | /* Clear up to type, everything after type is zeroed already */ |
1967 | if (!ret) | 1796 | memset(p, 0, offsetof(struct v4l2_sliced_vbi_cap, type)); |
1968 | dbgtimings(vfd, p); | ||
1969 | break; | ||
1970 | } | ||
1971 | case VIDIOC_ENUM_DV_TIMINGS: | ||
1972 | { | ||
1973 | struct v4l2_enum_dv_timings *p = arg; | ||
1974 | 1797 | ||
1975 | if (!ops->vidioc_enum_dv_timings) | 1798 | return ops->vidioc_g_sliced_vbi_cap(file, fh, p); |
1976 | break; | 1799 | } |
1977 | 1800 | ||
1978 | ret = ops->vidioc_enum_dv_timings(file, fh, p); | 1801 | struct v4l2_ioctl_info { |
1979 | if (!ret) { | 1802 | unsigned int ioctl; |
1980 | dbgarg(cmd, "index=%d: ", p->index); | 1803 | u32 flags; |
1981 | dbgtimings(vfd, &p->timings); | 1804 | const char * const name; |
1982 | } | 1805 | union { |
1983 | break; | 1806 | u32 offset; |
1807 | int (*func)(const struct v4l2_ioctl_ops *ops, | ||
1808 | struct file *file, void *fh, void *p); | ||
1809 | }; | ||
1810 | void (*debug)(const void *arg, bool write_only); | ||
1811 | }; | ||
1812 | |||
1813 | /* This control needs a priority check */ | ||
1814 | #define INFO_FL_PRIO (1 << 0) | ||
1815 | /* This control can be valid if the filehandle passes a control handler. */ | ||
1816 | #define INFO_FL_CTRL (1 << 1) | ||
1817 | /* This is a standard ioctl, no need for special code */ | ||
1818 | #define INFO_FL_STD (1 << 2) | ||
1819 | /* This is ioctl has its own function */ | ||
1820 | #define INFO_FL_FUNC (1 << 3) | ||
1821 | /* Queuing ioctl */ | ||
1822 | #define INFO_FL_QUEUE (1 << 4) | ||
1823 | /* Zero struct from after the field to the end */ | ||
1824 | #define INFO_FL_CLEAR(v4l2_struct, field) \ | ||
1825 | ((offsetof(struct v4l2_struct, field) + \ | ||
1826 | sizeof(((struct v4l2_struct *)0)->field)) << 16) | ||
1827 | #define INFO_FL_CLEAR_MASK (_IOC_SIZEMASK << 16) | ||
1828 | |||
1829 | #define IOCTL_INFO_STD(_ioctl, _vidioc, _debug, _flags) \ | ||
1830 | [_IOC_NR(_ioctl)] = { \ | ||
1831 | .ioctl = _ioctl, \ | ||
1832 | .flags = _flags | INFO_FL_STD, \ | ||
1833 | .name = #_ioctl, \ | ||
1834 | .offset = offsetof(struct v4l2_ioctl_ops, _vidioc), \ | ||
1835 | .debug = _debug, \ | ||
1836 | } | ||
1837 | |||
1838 | #define IOCTL_INFO_FNC(_ioctl, _func, _debug, _flags) \ | ||
1839 | [_IOC_NR(_ioctl)] = { \ | ||
1840 | .ioctl = _ioctl, \ | ||
1841 | .flags = _flags | INFO_FL_FUNC, \ | ||
1842 | .name = #_ioctl, \ | ||
1843 | .func = _func, \ | ||
1844 | .debug = _debug, \ | ||
1984 | } | 1845 | } |
1985 | case VIDIOC_QUERY_DV_TIMINGS: | ||
1986 | { | ||
1987 | struct v4l2_dv_timings *p = arg; | ||
1988 | 1846 | ||
1989 | if (!ops->vidioc_query_dv_timings) | 1847 | static struct v4l2_ioctl_info v4l2_ioctls[] = { |
1990 | break; | 1848 | IOCTL_INFO_FNC(VIDIOC_QUERYCAP, v4l_querycap, v4l_print_querycap, 0), |
1849 | IOCTL_INFO_FNC(VIDIOC_ENUM_FMT, v4l_enum_fmt, v4l_print_fmtdesc, INFO_FL_CLEAR(v4l2_fmtdesc, type)), | ||
1850 | IOCTL_INFO_FNC(VIDIOC_G_FMT, v4l_g_fmt, v4l_print_format, INFO_FL_CLEAR(v4l2_format, type)), | ||
1851 | IOCTL_INFO_FNC(VIDIOC_S_FMT, v4l_s_fmt, v4l_print_format, INFO_FL_PRIO), | ||
1852 | IOCTL_INFO_FNC(VIDIOC_REQBUFS, v4l_reqbufs, v4l_print_requestbuffers, INFO_FL_PRIO | INFO_FL_QUEUE), | ||
1853 | IOCTL_INFO_FNC(VIDIOC_QUERYBUF, v4l_querybuf, v4l_print_buffer, INFO_FL_QUEUE | INFO_FL_CLEAR(v4l2_buffer, length)), | ||
1854 | IOCTL_INFO_STD(VIDIOC_G_FBUF, vidioc_g_fbuf, v4l_print_framebuffer, 0), | ||
1855 | IOCTL_INFO_STD(VIDIOC_S_FBUF, vidioc_s_fbuf, v4l_print_framebuffer, INFO_FL_PRIO), | ||
1856 | IOCTL_INFO_STD(VIDIOC_OVERLAY, vidioc_overlay, v4l_print_u32, INFO_FL_PRIO), | ||
1857 | IOCTL_INFO_FNC(VIDIOC_QBUF, v4l_qbuf, v4l_print_buffer, INFO_FL_QUEUE), | ||
1858 | IOCTL_INFO_FNC(VIDIOC_DQBUF, v4l_dqbuf, v4l_print_buffer, INFO_FL_QUEUE), | ||
1859 | IOCTL_INFO_FNC(VIDIOC_STREAMON, v4l_streamon, v4l_print_buftype, INFO_FL_PRIO | INFO_FL_QUEUE), | ||
1860 | IOCTL_INFO_FNC(VIDIOC_STREAMOFF, v4l_streamoff, v4l_print_buftype, INFO_FL_PRIO | INFO_FL_QUEUE), | ||
1861 | IOCTL_INFO_FNC(VIDIOC_G_PARM, v4l_g_parm, v4l_print_streamparm, INFO_FL_CLEAR(v4l2_streamparm, type)), | ||
1862 | IOCTL_INFO_FNC(VIDIOC_S_PARM, v4l_s_parm, v4l_print_streamparm, INFO_FL_PRIO), | ||
1863 | IOCTL_INFO_FNC(VIDIOC_G_STD, v4l_g_std, v4l_print_std, 0), | ||
1864 | IOCTL_INFO_FNC(VIDIOC_S_STD, v4l_s_std, v4l_print_std, INFO_FL_PRIO), | ||
1865 | IOCTL_INFO_FNC(VIDIOC_ENUMSTD, v4l_enumstd, v4l_print_standard, INFO_FL_CLEAR(v4l2_standard, index)), | ||
1866 | IOCTL_INFO_FNC(VIDIOC_ENUMINPUT, v4l_enuminput, v4l_print_enuminput, INFO_FL_CLEAR(v4l2_input, index)), | ||
1867 | IOCTL_INFO_FNC(VIDIOC_G_CTRL, v4l_g_ctrl, v4l_print_control, INFO_FL_CTRL | INFO_FL_CLEAR(v4l2_control, id)), | ||
1868 | IOCTL_INFO_FNC(VIDIOC_S_CTRL, v4l_s_ctrl, v4l_print_control, INFO_FL_PRIO | INFO_FL_CTRL), | ||
1869 | IOCTL_INFO_FNC(VIDIOC_G_TUNER, v4l_g_tuner, v4l_print_tuner, INFO_FL_CLEAR(v4l2_tuner, index)), | ||
1870 | IOCTL_INFO_FNC(VIDIOC_S_TUNER, v4l_s_tuner, v4l_print_tuner, INFO_FL_PRIO), | ||
1871 | IOCTL_INFO_STD(VIDIOC_G_AUDIO, vidioc_g_audio, v4l_print_audio, 0), | ||
1872 | IOCTL_INFO_STD(VIDIOC_S_AUDIO, vidioc_s_audio, v4l_print_audio, INFO_FL_PRIO), | ||
1873 | IOCTL_INFO_FNC(VIDIOC_QUERYCTRL, v4l_queryctrl, v4l_print_queryctrl, INFO_FL_CTRL | INFO_FL_CLEAR(v4l2_queryctrl, id)), | ||
1874 | IOCTL_INFO_FNC(VIDIOC_QUERYMENU, v4l_querymenu, v4l_print_querymenu, INFO_FL_CTRL | INFO_FL_CLEAR(v4l2_querymenu, index)), | ||
1875 | IOCTL_INFO_STD(VIDIOC_G_INPUT, vidioc_g_input, v4l_print_u32, 0), | ||
1876 | IOCTL_INFO_FNC(VIDIOC_S_INPUT, v4l_s_input, v4l_print_u32, INFO_FL_PRIO), | ||
1877 | IOCTL_INFO_STD(VIDIOC_G_OUTPUT, vidioc_g_output, v4l_print_u32, 0), | ||
1878 | IOCTL_INFO_FNC(VIDIOC_S_OUTPUT, v4l_s_output, v4l_print_u32, INFO_FL_PRIO), | ||
1879 | IOCTL_INFO_FNC(VIDIOC_ENUMOUTPUT, v4l_enumoutput, v4l_print_enumoutput, INFO_FL_CLEAR(v4l2_output, index)), | ||
1880 | IOCTL_INFO_STD(VIDIOC_G_AUDOUT, vidioc_g_audout, v4l_print_audioout, 0), | ||
1881 | IOCTL_INFO_STD(VIDIOC_S_AUDOUT, vidioc_s_audout, v4l_print_audioout, INFO_FL_PRIO), | ||
1882 | IOCTL_INFO_STD(VIDIOC_G_MODULATOR, vidioc_g_modulator, v4l_print_modulator, INFO_FL_CLEAR(v4l2_modulator, index)), | ||
1883 | IOCTL_INFO_STD(VIDIOC_S_MODULATOR, vidioc_s_modulator, v4l_print_modulator, INFO_FL_PRIO), | ||
1884 | IOCTL_INFO_FNC(VIDIOC_G_FREQUENCY, v4l_g_frequency, v4l_print_frequency, INFO_FL_CLEAR(v4l2_frequency, tuner)), | ||
1885 | IOCTL_INFO_FNC(VIDIOC_S_FREQUENCY, v4l_s_frequency, v4l_print_frequency, INFO_FL_PRIO), | ||
1886 | IOCTL_INFO_FNC(VIDIOC_CROPCAP, v4l_cropcap, v4l_print_cropcap, INFO_FL_CLEAR(v4l2_cropcap, type)), | ||
1887 | IOCTL_INFO_FNC(VIDIOC_G_CROP, v4l_g_crop, v4l_print_crop, INFO_FL_CLEAR(v4l2_crop, type)), | ||
1888 | IOCTL_INFO_FNC(VIDIOC_S_CROP, v4l_s_crop, v4l_print_crop, INFO_FL_PRIO), | ||
1889 | IOCTL_INFO_STD(VIDIOC_G_SELECTION, vidioc_g_selection, v4l_print_selection, 0), | ||
1890 | IOCTL_INFO_STD(VIDIOC_S_SELECTION, vidioc_s_selection, v4l_print_selection, INFO_FL_PRIO), | ||
1891 | IOCTL_INFO_STD(VIDIOC_G_JPEGCOMP, vidioc_g_jpegcomp, v4l_print_jpegcompression, 0), | ||
1892 | IOCTL_INFO_STD(VIDIOC_S_JPEGCOMP, vidioc_s_jpegcomp, v4l_print_jpegcompression, INFO_FL_PRIO), | ||
1893 | IOCTL_INFO_FNC(VIDIOC_QUERYSTD, v4l_querystd, v4l_print_std, 0), | ||
1894 | IOCTL_INFO_FNC(VIDIOC_TRY_FMT, v4l_try_fmt, v4l_print_format, 0), | ||
1895 | IOCTL_INFO_STD(VIDIOC_ENUMAUDIO, vidioc_enumaudio, v4l_print_audio, INFO_FL_CLEAR(v4l2_audio, index)), | ||
1896 | IOCTL_INFO_STD(VIDIOC_ENUMAUDOUT, vidioc_enumaudout, v4l_print_audioout, INFO_FL_CLEAR(v4l2_audioout, index)), | ||
1897 | IOCTL_INFO_FNC(VIDIOC_G_PRIORITY, v4l_g_priority, v4l_print_u32, 0), | ||
1898 | IOCTL_INFO_FNC(VIDIOC_S_PRIORITY, v4l_s_priority, v4l_print_u32, INFO_FL_PRIO), | ||
1899 | IOCTL_INFO_FNC(VIDIOC_G_SLICED_VBI_CAP, v4l_g_sliced_vbi_cap, v4l_print_sliced_vbi_cap, INFO_FL_CLEAR(v4l2_sliced_vbi_cap, type)), | ||
1900 | IOCTL_INFO_FNC(VIDIOC_LOG_STATUS, v4l_log_status, v4l_print_newline, 0), | ||
1901 | IOCTL_INFO_FNC(VIDIOC_G_EXT_CTRLS, v4l_g_ext_ctrls, v4l_print_ext_controls, INFO_FL_CTRL), | ||
1902 | IOCTL_INFO_FNC(VIDIOC_S_EXT_CTRLS, v4l_s_ext_ctrls, v4l_print_ext_controls, INFO_FL_PRIO | INFO_FL_CTRL), | ||
1903 | IOCTL_INFO_FNC(VIDIOC_TRY_EXT_CTRLS, v4l_try_ext_ctrls, v4l_print_ext_controls, 0), | ||
1904 | IOCTL_INFO_STD(VIDIOC_ENUM_FRAMESIZES, vidioc_enum_framesizes, v4l_print_frmsizeenum, INFO_FL_CLEAR(v4l2_frmsizeenum, pixel_format)), | ||
1905 | IOCTL_INFO_STD(VIDIOC_ENUM_FRAMEINTERVALS, vidioc_enum_frameintervals, v4l_print_frmivalenum, INFO_FL_CLEAR(v4l2_frmivalenum, height)), | ||
1906 | IOCTL_INFO_STD(VIDIOC_G_ENC_INDEX, vidioc_g_enc_index, v4l_print_enc_idx, 0), | ||
1907 | IOCTL_INFO_STD(VIDIOC_ENCODER_CMD, vidioc_encoder_cmd, v4l_print_encoder_cmd, INFO_FL_PRIO | INFO_FL_CLEAR(v4l2_encoder_cmd, flags)), | ||
1908 | IOCTL_INFO_STD(VIDIOC_TRY_ENCODER_CMD, vidioc_try_encoder_cmd, v4l_print_encoder_cmd, INFO_FL_CLEAR(v4l2_encoder_cmd, flags)), | ||
1909 | IOCTL_INFO_STD(VIDIOC_DECODER_CMD, vidioc_decoder_cmd, v4l_print_decoder_cmd, INFO_FL_PRIO), | ||
1910 | IOCTL_INFO_STD(VIDIOC_TRY_DECODER_CMD, vidioc_try_decoder_cmd, v4l_print_decoder_cmd, 0), | ||
1911 | IOCTL_INFO_FNC(VIDIOC_DBG_S_REGISTER, v4l_dbg_s_register, v4l_print_dbg_register, 0), | ||
1912 | IOCTL_INFO_FNC(VIDIOC_DBG_G_REGISTER, v4l_dbg_g_register, v4l_print_dbg_register, 0), | ||
1913 | IOCTL_INFO_FNC(VIDIOC_DBG_G_CHIP_IDENT, v4l_dbg_g_chip_ident, v4l_print_dbg_chip_ident, 0), | ||
1914 | IOCTL_INFO_FNC(VIDIOC_S_HW_FREQ_SEEK, v4l_s_hw_freq_seek, v4l_print_hw_freq_seek, INFO_FL_PRIO), | ||
1915 | IOCTL_INFO_STD(VIDIOC_ENUM_DV_PRESETS, vidioc_enum_dv_presets, v4l_print_dv_enum_presets, 0), | ||
1916 | IOCTL_INFO_STD(VIDIOC_S_DV_PRESET, vidioc_s_dv_preset, v4l_print_dv_preset, INFO_FL_PRIO), | ||
1917 | IOCTL_INFO_STD(VIDIOC_G_DV_PRESET, vidioc_g_dv_preset, v4l_print_dv_preset, 0), | ||
1918 | IOCTL_INFO_STD(VIDIOC_QUERY_DV_PRESET, vidioc_query_dv_preset, v4l_print_dv_preset, 0), | ||
1919 | IOCTL_INFO_STD(VIDIOC_S_DV_TIMINGS, vidioc_s_dv_timings, v4l_print_dv_timings, INFO_FL_PRIO), | ||
1920 | IOCTL_INFO_STD(VIDIOC_G_DV_TIMINGS, vidioc_g_dv_timings, v4l_print_dv_timings, 0), | ||
1921 | IOCTL_INFO_FNC(VIDIOC_DQEVENT, v4l_dqevent, v4l_print_event, 0), | ||
1922 | IOCTL_INFO_FNC(VIDIOC_SUBSCRIBE_EVENT, v4l_subscribe_event, v4l_print_event_subscription, 0), | ||
1923 | IOCTL_INFO_FNC(VIDIOC_UNSUBSCRIBE_EVENT, v4l_unsubscribe_event, v4l_print_event_subscription, 0), | ||
1924 | IOCTL_INFO_FNC(VIDIOC_CREATE_BUFS, v4l_create_bufs, v4l_print_create_buffers, INFO_FL_PRIO | INFO_FL_QUEUE), | ||
1925 | IOCTL_INFO_FNC(VIDIOC_PREPARE_BUF, v4l_prepare_buf, v4l_print_buffer, INFO_FL_QUEUE), | ||
1926 | IOCTL_INFO_STD(VIDIOC_ENUM_DV_TIMINGS, vidioc_enum_dv_timings, v4l_print_enum_dv_timings, 0), | ||
1927 | IOCTL_INFO_STD(VIDIOC_QUERY_DV_TIMINGS, vidioc_query_dv_timings, v4l_print_dv_timings, 0), | ||
1928 | IOCTL_INFO_STD(VIDIOC_DV_TIMINGS_CAP, vidioc_dv_timings_cap, v4l_print_dv_timings_cap, 0), | ||
1929 | }; | ||
1930 | #define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls) | ||
1991 | 1931 | ||
1992 | ret = ops->vidioc_query_dv_timings(file, fh, p); | 1932 | bool v4l2_is_known_ioctl(unsigned int cmd) |
1993 | if (!ret) | 1933 | { |
1994 | dbgtimings(vfd, p); | 1934 | if (_IOC_NR(cmd) >= V4L2_IOCTLS) |
1995 | break; | 1935 | return false; |
1996 | } | 1936 | return v4l2_ioctls[_IOC_NR(cmd)].ioctl == cmd; |
1997 | case VIDIOC_DV_TIMINGS_CAP: | 1937 | } |
1998 | { | ||
1999 | struct v4l2_dv_timings_cap *p = arg; | ||
2000 | 1938 | ||
2001 | if (!ops->vidioc_dv_timings_cap) | 1939 | struct mutex *v4l2_ioctl_get_lock(struct video_device *vdev, unsigned cmd) |
2002 | break; | 1940 | { |
1941 | if (_IOC_NR(cmd) >= V4L2_IOCTLS) | ||
1942 | return vdev->lock; | ||
1943 | if (test_bit(_IOC_NR(cmd), vdev->disable_locking)) | ||
1944 | return NULL; | ||
1945 | if (vdev->queue && vdev->queue->lock && | ||
1946 | (v4l2_ioctls[_IOC_NR(cmd)].flags & INFO_FL_QUEUE)) | ||
1947 | return vdev->queue->lock; | ||
1948 | return vdev->lock; | ||
1949 | } | ||
2003 | 1950 | ||
2004 | ret = ops->vidioc_dv_timings_cap(file, fh, p); | 1951 | /* Common ioctl debug function. This function can be used by |
2005 | if (ret) | 1952 | external ioctl messages as well as internal V4L ioctl */ |
2006 | break; | 1953 | void v4l_printk_ioctl(const char *prefix, unsigned int cmd) |
2007 | switch (p->type) { | 1954 | { |
2008 | case V4L2_DV_BT_656_1120: | 1955 | const char *dir, *type; |
2009 | dbgarg(cmd, | ||
2010 | "type=%d, width=%u-%u, height=%u-%u, " | ||
2011 | "pixelclock=%llu-%llu, standards=%x, capabilities=%x ", | ||
2012 | p->type, | ||
2013 | p->bt.min_width, p->bt.max_width, | ||
2014 | p->bt.min_height, p->bt.max_height, | ||
2015 | p->bt.min_pixelclock, p->bt.max_pixelclock, | ||
2016 | p->bt.standards, p->bt.capabilities); | ||
2017 | break; | ||
2018 | default: | ||
2019 | dbgarg(cmd, "unknown type "); | ||
2020 | break; | ||
2021 | } | ||
2022 | break; | ||
2023 | } | ||
2024 | case VIDIOC_DQEVENT: | ||
2025 | { | ||
2026 | struct v4l2_event *ev = arg; | ||
2027 | 1956 | ||
2028 | ret = v4l2_event_dequeue(fh, ev, file->f_flags & O_NONBLOCK); | 1957 | if (prefix) |
2029 | if (ret < 0) { | 1958 | printk(KERN_DEBUG "%s: ", prefix); |
2030 | dbgarg(cmd, "no pending events?"); | ||
2031 | break; | ||
2032 | } | ||
2033 | dbgarg(cmd, | ||
2034 | "pending=%d, type=0x%8.8x, sequence=%d, " | ||
2035 | "timestamp=%lu.%9.9lu ", | ||
2036 | ev->pending, ev->type, ev->sequence, | ||
2037 | ev->timestamp.tv_sec, ev->timestamp.tv_nsec); | ||
2038 | break; | ||
2039 | } | ||
2040 | case VIDIOC_SUBSCRIBE_EVENT: | ||
2041 | { | ||
2042 | struct v4l2_event_subscription *sub = arg; | ||
2043 | 1959 | ||
2044 | ret = ops->vidioc_subscribe_event(fh, sub); | 1960 | switch (_IOC_TYPE(cmd)) { |
2045 | if (ret < 0) { | 1961 | case 'd': |
2046 | dbgarg(cmd, "failed, ret=%ld", ret); | 1962 | type = "v4l2_int"; |
2047 | break; | ||
2048 | } | ||
2049 | dbgarg(cmd, "type=0x%8.8x", sub->type); | ||
2050 | break; | 1963 | break; |
2051 | } | 1964 | case 'V': |
2052 | case VIDIOC_UNSUBSCRIBE_EVENT: | 1965 | if (_IOC_NR(cmd) >= V4L2_IOCTLS) { |
2053 | { | 1966 | type = "v4l2"; |
2054 | struct v4l2_event_subscription *sub = arg; | ||
2055 | |||
2056 | ret = ops->vidioc_unsubscribe_event(fh, sub); | ||
2057 | if (ret < 0) { | ||
2058 | dbgarg(cmd, "failed, ret=%ld", ret); | ||
2059 | break; | 1967 | break; |
2060 | } | 1968 | } |
2061 | dbgarg(cmd, "type=0x%8.8x", sub->type); | 1969 | pr_cont("%s", v4l2_ioctls[_IOC_NR(cmd)].name); |
1970 | return; | ||
1971 | default: | ||
1972 | type = "unknown"; | ||
2062 | break; | 1973 | break; |
2063 | } | 1974 | } |
2064 | case VIDIOC_CREATE_BUFS: | ||
2065 | { | ||
2066 | struct v4l2_create_buffers *create = arg; | ||
2067 | 1975 | ||
2068 | ret = check_fmt(ops, create->format.type); | 1976 | switch (_IOC_DIR(cmd)) { |
2069 | if (ret) | 1977 | case _IOC_NONE: dir = "--"; break; |
2070 | break; | 1978 | case _IOC_READ: dir = "r-"; break; |
1979 | case _IOC_WRITE: dir = "-w"; break; | ||
1980 | case _IOC_READ | _IOC_WRITE: dir = "rw"; break; | ||
1981 | default: dir = "*ERR*"; break; | ||
1982 | } | ||
1983 | pr_cont("%s ioctl '%c', dir=%s, #%d (0x%08x)", | ||
1984 | type, _IOC_TYPE(cmd), dir, _IOC_NR(cmd), cmd); | ||
1985 | } | ||
1986 | EXPORT_SYMBOL(v4l_printk_ioctl); | ||
2071 | 1987 | ||
2072 | ret = ops->vidioc_create_bufs(file, fh, create); | 1988 | static long __video_do_ioctl(struct file *file, |
1989 | unsigned int cmd, void *arg) | ||
1990 | { | ||
1991 | struct video_device *vfd = video_devdata(file); | ||
1992 | const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops; | ||
1993 | bool write_only = false; | ||
1994 | struct v4l2_ioctl_info default_info; | ||
1995 | const struct v4l2_ioctl_info *info; | ||
1996 | void *fh = file->private_data; | ||
1997 | struct v4l2_fh *vfh = NULL; | ||
1998 | int use_fh_prio = 0; | ||
1999 | int debug = vfd->debug; | ||
2000 | long ret = -ENOTTY; | ||
2073 | 2001 | ||
2074 | dbgarg(cmd, "count=%d @ %d\n", create->count, create->index); | 2002 | if (ops == NULL) { |
2075 | break; | 2003 | pr_warn("%s: has no ioctl_ops.\n", |
2004 | video_device_node_name(vfd)); | ||
2005 | return ret; | ||
2076 | } | 2006 | } |
2077 | case VIDIOC_PREPARE_BUF: | ||
2078 | { | ||
2079 | struct v4l2_buffer *b = arg; | ||
2080 | 2007 | ||
2081 | ret = check_fmt(ops, b->type); | 2008 | if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags)) { |
2082 | if (ret) | 2009 | vfh = file->private_data; |
2083 | break; | 2010 | use_fh_prio = test_bit(V4L2_FL_USE_FH_PRIO, &vfd->flags); |
2011 | } | ||
2084 | 2012 | ||
2085 | ret = ops->vidioc_prepare_buf(file, fh, b); | 2013 | if (v4l2_is_known_ioctl(cmd)) { |
2014 | info = &v4l2_ioctls[_IOC_NR(cmd)]; | ||
2086 | 2015 | ||
2087 | dbgarg(cmd, "index=%d", b->index); | 2016 | if (!test_bit(_IOC_NR(cmd), vfd->valid_ioctls) && |
2088 | break; | 2017 | !((info->flags & INFO_FL_CTRL) && vfh && vfh->ctrl_handler)) |
2089 | } | 2018 | goto done; |
2090 | default: | ||
2091 | if (!ops->vidioc_default) | ||
2092 | break; | ||
2093 | ret = ops->vidioc_default(file, fh, use_fh_prio ? | ||
2094 | v4l2_prio_check(vfd->prio, vfh->prio) >= 0 : 0, | ||
2095 | cmd, arg); | ||
2096 | break; | ||
2097 | } /* switch */ | ||
2098 | 2019 | ||
2099 | if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) { | 2020 | if (use_fh_prio && (info->flags & INFO_FL_PRIO)) { |
2100 | if (ret < 0) { | 2021 | ret = v4l2_prio_check(vfd->prio, vfh->prio); |
2101 | v4l_print_ioctl(vfd->name, cmd); | 2022 | if (ret) |
2102 | printk(KERN_CONT " error %ld\n", ret); | 2023 | goto done; |
2024 | } | ||
2025 | } else { | ||
2026 | default_info.ioctl = cmd; | ||
2027 | default_info.flags = 0; | ||
2028 | default_info.debug = v4l_print_default; | ||
2029 | info = &default_info; | ||
2030 | } | ||
2031 | |||
2032 | write_only = _IOC_DIR(cmd) == _IOC_WRITE; | ||
2033 | if (write_only && debug > V4L2_DEBUG_IOCTL) { | ||
2034 | v4l_printk_ioctl(video_device_node_name(vfd), cmd); | ||
2035 | pr_cont(": "); | ||
2036 | info->debug(arg, write_only); | ||
2037 | } | ||
2038 | if (info->flags & INFO_FL_STD) { | ||
2039 | typedef int (*vidioc_op)(struct file *file, void *fh, void *p); | ||
2040 | const void *p = vfd->ioctl_ops; | ||
2041 | const vidioc_op *vidioc = p + info->offset; | ||
2042 | |||
2043 | ret = (*vidioc)(file, fh, arg); | ||
2044 | } else if (info->flags & INFO_FL_FUNC) { | ||
2045 | ret = info->func(ops, file, fh, arg); | ||
2046 | } else if (!ops->vidioc_default) { | ||
2047 | ret = -ENOTTY; | ||
2048 | } else { | ||
2049 | ret = ops->vidioc_default(file, fh, | ||
2050 | use_fh_prio ? v4l2_prio_check(vfd->prio, vfh->prio) >= 0 : 0, | ||
2051 | cmd, arg); | ||
2052 | } | ||
2053 | |||
2054 | done: | ||
2055 | if (debug) { | ||
2056 | if (write_only && debug > V4L2_DEBUG_IOCTL) { | ||
2057 | if (ret < 0) | ||
2058 | printk(KERN_DEBUG "%s: error %ld\n", | ||
2059 | video_device_node_name(vfd), ret); | ||
2060 | return ret; | ||
2061 | } | ||
2062 | v4l_printk_ioctl(video_device_node_name(vfd), cmd); | ||
2063 | if (ret < 0) | ||
2064 | pr_cont(": error %ld\n", ret); | ||
2065 | else if (debug == V4L2_DEBUG_IOCTL) | ||
2066 | pr_cont("\n"); | ||
2067 | else if (_IOC_DIR(cmd) == _IOC_NONE) | ||
2068 | info->debug(arg, write_only); | ||
2069 | else { | ||
2070 | pr_cont(": "); | ||
2071 | info->debug(arg, write_only); | ||
2103 | } | 2072 | } |
2104 | } | 2073 | } |
2105 | 2074 | ||
2106 | return ret; | 2075 | return ret; |
2107 | } | 2076 | } |
2108 | 2077 | ||
2109 | /* In some cases, only a few fields are used as input, i.e. when the app sets | ||
2110 | * "index" and then the driver fills in the rest of the structure for the thing | ||
2111 | * with that index. We only need to copy up the first non-input field. */ | ||
2112 | static unsigned long cmd_input_size(unsigned int cmd) | ||
2113 | { | ||
2114 | /* Size of structure up to and including 'field' */ | ||
2115 | #define CMDINSIZE(cmd, type, field) \ | ||
2116 | case VIDIOC_##cmd: \ | ||
2117 | return offsetof(struct v4l2_##type, field) + \ | ||
2118 | sizeof(((struct v4l2_##type *)0)->field); | ||
2119 | |||
2120 | switch (cmd) { | ||
2121 | CMDINSIZE(ENUM_FMT, fmtdesc, type); | ||
2122 | CMDINSIZE(G_FMT, format, type); | ||
2123 | CMDINSIZE(QUERYBUF, buffer, length); | ||
2124 | CMDINSIZE(G_PARM, streamparm, type); | ||
2125 | CMDINSIZE(ENUMSTD, standard, index); | ||
2126 | CMDINSIZE(ENUMINPUT, input, index); | ||
2127 | CMDINSIZE(G_CTRL, control, id); | ||
2128 | CMDINSIZE(G_TUNER, tuner, index); | ||
2129 | CMDINSIZE(QUERYCTRL, queryctrl, id); | ||
2130 | CMDINSIZE(QUERYMENU, querymenu, index); | ||
2131 | CMDINSIZE(ENUMOUTPUT, output, index); | ||
2132 | CMDINSIZE(G_MODULATOR, modulator, index); | ||
2133 | CMDINSIZE(G_FREQUENCY, frequency, tuner); | ||
2134 | CMDINSIZE(CROPCAP, cropcap, type); | ||
2135 | CMDINSIZE(G_CROP, crop, type); | ||
2136 | CMDINSIZE(ENUMAUDIO, audio, index); | ||
2137 | CMDINSIZE(ENUMAUDOUT, audioout, index); | ||
2138 | CMDINSIZE(ENCODER_CMD, encoder_cmd, flags); | ||
2139 | CMDINSIZE(TRY_ENCODER_CMD, encoder_cmd, flags); | ||
2140 | CMDINSIZE(G_SLICED_VBI_CAP, sliced_vbi_cap, type); | ||
2141 | CMDINSIZE(ENUM_FRAMESIZES, frmsizeenum, pixel_format); | ||
2142 | CMDINSIZE(ENUM_FRAMEINTERVALS, frmivalenum, height); | ||
2143 | default: | ||
2144 | return _IOC_SIZE(cmd); | ||
2145 | } | ||
2146 | } | ||
2147 | |||
2148 | static int check_array_args(unsigned int cmd, void *parg, size_t *array_size, | 2078 | static int check_array_args(unsigned int cmd, void *parg, size_t *array_size, |
2149 | void * __user *user_ptr, void ***kernel_ptr) | 2079 | void * __user *user_ptr, void ***kernel_ptr) |
2150 | { | 2080 | { |
@@ -2219,7 +2149,20 @@ video_usercopy(struct file *file, unsigned int cmd, unsigned long arg, | |||
2219 | 2149 | ||
2220 | err = -EFAULT; | 2150 | err = -EFAULT; |
2221 | if (_IOC_DIR(cmd) & _IOC_WRITE) { | 2151 | if (_IOC_DIR(cmd) & _IOC_WRITE) { |
2222 | unsigned long n = cmd_input_size(cmd); | 2152 | unsigned int n = _IOC_SIZE(cmd); |
2153 | |||
2154 | /* | ||
2155 | * In some cases, only a few fields are used as input, | ||
2156 | * i.e. when the app sets "index" and then the driver | ||
2157 | * fills in the rest of the structure for the thing | ||
2158 | * with that index. We only need to copy up the first | ||
2159 | * non-input field. | ||
2160 | */ | ||
2161 | if (v4l2_is_known_ioctl(cmd)) { | ||
2162 | u32 flags = v4l2_ioctls[_IOC_NR(cmd)].flags; | ||
2163 | if (flags & INFO_FL_CLEAR_MASK) | ||
2164 | n = (flags & INFO_FL_CLEAR_MASK) >> 16; | ||
2165 | } | ||
2223 | 2166 | ||
2224 | if (copy_from_user(parg, (void __user *)arg, n)) | 2167 | if (copy_from_user(parg, (void __user *)arg, n)) |
2225 | goto out; | 2168 | goto out; |