v4l2-compat-ioctl32.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102
  1. /*
  2. * ioctl32.c: Conversion between 32bit and 64bit native ioctls.
  3. * Separated from fs stuff by Arnd Bergmann <arnd@arndb.de>
  4. *
  5. * Copyright (C) 1997-2000 Jakub Jelinek (jakub@redhat.com)
  6. * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be)
  7. * Copyright (C) 2001,2002 Andi Kleen, SuSE Labs
  8. * Copyright (C) 2003 Pavel Machek (pavel@ucw.cz)
  9. * Copyright (C) 2005 Philippe De Muyter (phdm@macqel.be)
  10. * Copyright (C) 2008 Hans Verkuil <hverkuil@xs4all.nl>
  11. *
  12. * These routines maintain argument size conversion between 32bit and 64bit
  13. * ioctls.
  14. */
  15. #include <linux/compat.h>
  16. #include <linux/module.h>
  17. #include <linux/videodev2.h>
  18. #include <linux/v4l2-subdev.h>
  19. #include <media/v4l2-dev.h>
  20. #include <media/v4l2-ioctl.h>
  21. static long native_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
  22. {
  23. long ret = -ENOIOCTLCMD;
  24. if (file->f_op->unlocked_ioctl)
  25. ret = file->f_op->unlocked_ioctl(file, cmd, arg);
  26. return ret;
  27. }
  28. struct v4l2_clip32 {
  29. struct v4l2_rect c;
  30. compat_caddr_t next;
  31. };
  32. struct v4l2_window32 {
  33. struct v4l2_rect w;
  34. __u32 field; /* enum v4l2_field */
  35. __u32 chromakey;
  36. compat_caddr_t clips; /* actually struct v4l2_clip32 * */
  37. __u32 clipcount;
  38. compat_caddr_t bitmap;
  39. };
  40. static int get_v4l2_window32(struct v4l2_window *kp, struct v4l2_window32 __user *up)
  41. {
  42. if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_window32)) ||
  43. copy_from_user(&kp->w, &up->w, sizeof(up->w)) ||
  44. get_user(kp->field, &up->field) ||
  45. get_user(kp->chromakey, &up->chromakey) ||
  46. get_user(kp->clipcount, &up->clipcount))
  47. return -EFAULT;
  48. if (kp->clipcount > 2048)
  49. return -EINVAL;
  50. if (kp->clipcount) {
  51. struct v4l2_clip32 __user *uclips;
  52. struct v4l2_clip __user *kclips;
  53. int n = kp->clipcount;
  54. compat_caddr_t p;
  55. if (get_user(p, &up->clips))
  56. return -EFAULT;
  57. uclips = compat_ptr(p);
  58. kclips = compat_alloc_user_space(n * sizeof(struct v4l2_clip));
  59. kp->clips = kclips;
  60. while (--n >= 0) {
  61. if (copy_in_user(&kclips->c, &uclips->c, sizeof(uclips->c)))
  62. return -EFAULT;
  63. if (put_user(n ? kclips + 1 : NULL, &kclips->next))
  64. return -EFAULT;
  65. uclips += 1;
  66. kclips += 1;
  67. }
  68. } else
  69. kp->clips = NULL;
  70. return 0;
  71. }
  72. static int put_v4l2_window32(struct v4l2_window *kp, struct v4l2_window32 __user *up)
  73. {
  74. if (copy_to_user(&up->w, &kp->w, sizeof(kp->w)) ||
  75. put_user(kp->field, &up->field) ||
  76. put_user(kp->chromakey, &up->chromakey) ||
  77. put_user(kp->clipcount, &up->clipcount))
  78. return -EFAULT;
  79. return 0;
  80. }
  81. static inline int get_v4l2_pix_format(struct v4l2_pix_format *kp, struct v4l2_pix_format __user *up)
  82. {
  83. if (copy_from_user(kp, up, sizeof(struct v4l2_pix_format)))
  84. return -EFAULT;
  85. return 0;
  86. }
  87. static inline int get_v4l2_pix_format_mplane(struct v4l2_pix_format_mplane *kp,
  88. struct v4l2_pix_format_mplane __user *up)
  89. {
  90. if (copy_from_user(kp, up, sizeof(struct v4l2_pix_format_mplane)))
  91. return -EFAULT;
  92. return 0;
  93. }
  94. static inline int put_v4l2_pix_format(struct v4l2_pix_format *kp, struct v4l2_pix_format __user *up)
  95. {
  96. if (copy_to_user(up, kp, sizeof(struct v4l2_pix_format)))
  97. return -EFAULT;
  98. return 0;
  99. }
  100. static inline int put_v4l2_pix_format_mplane(struct v4l2_pix_format_mplane *kp,
  101. struct v4l2_pix_format_mplane __user *up)
  102. {
  103. if (copy_to_user(up, kp, sizeof(struct v4l2_pix_format_mplane)))
  104. return -EFAULT;
  105. return 0;
  106. }
  107. static inline int get_v4l2_vbi_format(struct v4l2_vbi_format *kp, struct v4l2_vbi_format __user *up)
  108. {
  109. if (copy_from_user(kp, up, sizeof(struct v4l2_vbi_format)))
  110. return -EFAULT;
  111. return 0;
  112. }
  113. static inline int put_v4l2_vbi_format(struct v4l2_vbi_format *kp, struct v4l2_vbi_format __user *up)
  114. {
  115. if (copy_to_user(up, kp, sizeof(struct v4l2_vbi_format)))
  116. return -EFAULT;
  117. return 0;
  118. }
  119. static inline int get_v4l2_sliced_vbi_format(struct v4l2_sliced_vbi_format *kp, struct v4l2_sliced_vbi_format __user *up)
  120. {
  121. if (copy_from_user(kp, up, sizeof(struct v4l2_sliced_vbi_format)))
  122. return -EFAULT;
  123. return 0;
  124. }
  125. static inline int put_v4l2_sliced_vbi_format(struct v4l2_sliced_vbi_format *kp, struct v4l2_sliced_vbi_format __user *up)
  126. {
  127. if (copy_to_user(up, kp, sizeof(struct v4l2_sliced_vbi_format)))
  128. return -EFAULT;
  129. return 0;
  130. }
  131. struct v4l2_format32 {
  132. __u32 type; /* enum v4l2_buf_type */
  133. union {
  134. struct v4l2_pix_format pix;
  135. struct v4l2_pix_format_mplane pix_mp;
  136. struct v4l2_window32 win;
  137. struct v4l2_vbi_format vbi;
  138. struct v4l2_sliced_vbi_format sliced;
  139. __u8 raw_data[200]; /* user-defined */
  140. } fmt;
  141. };
  142. /**
  143. * struct v4l2_create_buffers32 - VIDIOC_CREATE_BUFS32 argument
  144. * @index: on return, index of the first created buffer
  145. * @count: entry: number of requested buffers,
  146. * return: number of created buffers
  147. * @memory: buffer memory type
  148. * @format: frame format, for which buffers are requested
  149. * @reserved: future extensions
  150. */
  151. struct v4l2_create_buffers32 {
  152. __u32 index;
  153. __u32 count;
  154. __u32 memory; /* enum v4l2_memory */
  155. struct v4l2_format32 format;
  156. __u32 reserved[8];
  157. };
  158. static int __get_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __user *up)
  159. {
  160. switch (kp->type) {
  161. case V4L2_BUF_TYPE_VIDEO_CAPTURE:
  162. case V4L2_BUF_TYPE_VIDEO_OUTPUT:
  163. return get_v4l2_pix_format(&kp->fmt.pix, &up->fmt.pix);
  164. case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
  165. case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
  166. return get_v4l2_pix_format_mplane(&kp->fmt.pix_mp,
  167. &up->fmt.pix_mp);
  168. case V4L2_BUF_TYPE_VIDEO_OVERLAY:
  169. case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
  170. return get_v4l2_window32(&kp->fmt.win, &up->fmt.win);
  171. case V4L2_BUF_TYPE_VBI_CAPTURE:
  172. case V4L2_BUF_TYPE_VBI_OUTPUT:
  173. return get_v4l2_vbi_format(&kp->fmt.vbi, &up->fmt.vbi);
  174. case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
  175. case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
  176. return get_v4l2_sliced_vbi_format(&kp->fmt.sliced, &up->fmt.sliced);
  177. case V4L2_BUF_TYPE_PRIVATE:
  178. if (copy_from_user(kp, up, sizeof(kp->fmt.raw_data)))
  179. return -EFAULT;
  180. return 0;
  181. default:
  182. printk(KERN_INFO "compat_ioctl32: unexpected VIDIOC_FMT type %d\n",
  183. kp->type);
  184. return -EINVAL;
  185. }
  186. }
  187. static int get_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __user *up)
  188. {
  189. if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_format32)) ||
  190. get_user(kp->type, &up->type))
  191. return -EFAULT;
  192. return __get_v4l2_format32(kp, up);
  193. }
  194. static int get_v4l2_create32(struct v4l2_create_buffers *kp, struct v4l2_create_buffers32 __user *up)
  195. {
  196. if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_create_buffers32)) ||
  197. copy_from_user(kp, up, offsetof(struct v4l2_create_buffers32, format.fmt)))
  198. return -EFAULT;
  199. return __get_v4l2_format32(&kp->format, &up->format);
  200. }
  201. static int __put_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __user *up)
  202. {
  203. switch (kp->type) {
  204. case V4L2_BUF_TYPE_VIDEO_CAPTURE:
  205. case V4L2_BUF_TYPE_VIDEO_OUTPUT:
  206. return put_v4l2_pix_format(&kp->fmt.pix, &up->fmt.pix);
  207. case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
  208. case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
  209. return put_v4l2_pix_format_mplane(&kp->fmt.pix_mp,
  210. &up->fmt.pix_mp);
  211. case V4L2_BUF_TYPE_VIDEO_OVERLAY:
  212. case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:
  213. return put_v4l2_window32(&kp->fmt.win, &up->fmt.win);
  214. case V4L2_BUF_TYPE_VBI_CAPTURE:
  215. case V4L2_BUF_TYPE_VBI_OUTPUT:
  216. return put_v4l2_vbi_format(&kp->fmt.vbi, &up->fmt.vbi);
  217. case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
  218. case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
  219. return put_v4l2_sliced_vbi_format(&kp->fmt.sliced, &up->fmt.sliced);
  220. case V4L2_BUF_TYPE_PRIVATE:
  221. if (copy_to_user(up, kp, sizeof(up->fmt.raw_data)))
  222. return -EFAULT;
  223. return 0;
  224. default:
  225. printk(KERN_INFO "compat_ioctl32: unexpected VIDIOC_FMT type %d\n",
  226. kp->type);
  227. return -EINVAL;
  228. }
  229. }
  230. static int put_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __user *up)
  231. {
  232. if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_format32)) ||
  233. put_user(kp->type, &up->type))
  234. return -EFAULT;
  235. return __put_v4l2_format32(kp, up);
  236. }
  237. static int put_v4l2_create32(struct v4l2_create_buffers *kp, struct v4l2_create_buffers32 __user *up)
  238. {
  239. if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_create_buffers32)) ||
  240. copy_to_user(up, kp, offsetof(struct v4l2_create_buffers32, format.fmt)))
  241. return -EFAULT;
  242. return __put_v4l2_format32(&kp->format, &up->format);
  243. }
  244. struct v4l2_standard32 {
  245. __u32 index;
  246. __u32 id[2]; /* __u64 would get the alignment wrong */
  247. __u8 name[24];
  248. struct v4l2_fract frameperiod; /* Frames, not fields */
  249. __u32 framelines;
  250. __u32 reserved[4];
  251. };
  252. static int get_v4l2_standard32(struct v4l2_standard *kp, struct v4l2_standard32 __user *up)
  253. {
  254. /* other fields are not set by the user, nor used by the driver */
  255. if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_standard32)) ||
  256. get_user(kp->index, &up->index))
  257. return -EFAULT;
  258. return 0;
  259. }
  260. static int put_v4l2_standard32(struct v4l2_standard *kp, struct v4l2_standard32 __user *up)
  261. {
  262. if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_standard32)) ||
  263. put_user(kp->index, &up->index) ||
  264. copy_to_user(up->id, &kp->id, sizeof(__u64)) ||
  265. copy_to_user(up->name, kp->name, 24) ||
  266. copy_to_user(&up->frameperiod, &kp->frameperiod, sizeof(kp->frameperiod)) ||
  267. put_user(kp->framelines, &up->framelines) ||
  268. copy_to_user(up->reserved, kp->reserved, 4 * sizeof(__u32)))
  269. return -EFAULT;
  270. return 0;
  271. }
  272. struct v4l2_plane32 {
  273. __u32 bytesused;
  274. __u32 length;
  275. union {
  276. __u32 mem_offset;
  277. compat_long_t userptr;
  278. } m;
  279. __u32 data_offset;
  280. __u32 reserved[11];
  281. };
  282. struct v4l2_buffer32 {
  283. __u32 index;
  284. __u32 type; /* enum v4l2_buf_type */
  285. __u32 bytesused;
  286. __u32 flags;
  287. __u32 field; /* enum v4l2_field */
  288. struct compat_timeval timestamp;
  289. struct v4l2_timecode timecode;
  290. __u32 sequence;
  291. /* memory location */
  292. __u32 memory; /* enum v4l2_memory */
  293. union {
  294. __u32 offset;
  295. compat_long_t userptr;
  296. compat_caddr_t planes;
  297. } m;
  298. __u32 length;
  299. __u32 reserved2;
  300. __u32 reserved;
  301. };
  302. static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
  303. enum v4l2_memory memory)
  304. {
  305. void __user *up_pln;
  306. compat_long_t p;
  307. if (copy_in_user(up, up32, 2 * sizeof(__u32)) ||
  308. copy_in_user(&up->data_offset, &up32->data_offset,
  309. sizeof(__u32)))
  310. return -EFAULT;
  311. if (memory == V4L2_MEMORY_USERPTR) {
  312. if (get_user(p, &up32->m.userptr))
  313. return -EFAULT;
  314. up_pln = compat_ptr(p);
  315. if (put_user((unsigned long)up_pln, &up->m.userptr))
  316. return -EFAULT;
  317. } else {
  318. if (copy_in_user(&up->m.mem_offset, &up32->m.mem_offset,
  319. sizeof(__u32)))
  320. return -EFAULT;
  321. }
  322. return 0;
  323. }
  324. static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
  325. enum v4l2_memory memory)
  326. {
  327. if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
  328. copy_in_user(&up32->data_offset, &up->data_offset,
  329. sizeof(__u32)))
  330. return -EFAULT;
  331. /* For MMAP, driver might've set up the offset, so copy it back.
  332. * USERPTR stays the same (was userspace-provided), so no copying. */
  333. if (memory == V4L2_MEMORY_MMAP)
  334. if (copy_in_user(&up32->m.mem_offset, &up->m.mem_offset,
  335. sizeof(__u32)))
  336. return -EFAULT;
  337. return 0;
  338. }
  339. static int get_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user *up)
  340. {
  341. struct v4l2_plane32 __user *uplane32;
  342. struct v4l2_plane __user *uplane;
  343. compat_caddr_t p;
  344. int num_planes;
  345. int ret;
  346. if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_buffer32)) ||
  347. get_user(kp->index, &up->index) ||
  348. get_user(kp->type, &up->type) ||
  349. get_user(kp->flags, &up->flags) ||
  350. get_user(kp->memory, &up->memory))
  351. return -EFAULT;
  352. if (V4L2_TYPE_IS_OUTPUT(kp->type))
  353. if (get_user(kp->bytesused, &up->bytesused) ||
  354. get_user(kp->field, &up->field) ||
  355. get_user(kp->timestamp.tv_sec, &up->timestamp.tv_sec) ||
  356. get_user(kp->timestamp.tv_usec,
  357. &up->timestamp.tv_usec))
  358. return -EFAULT;
  359. if (V4L2_TYPE_IS_MULTIPLANAR(kp->type)) {
  360. if (get_user(kp->length, &up->length))
  361. return -EFAULT;
  362. num_planes = kp->length;
  363. if (num_planes == 0) {
  364. kp->m.planes = NULL;
  365. /* num_planes == 0 is legal, e.g. when userspace doesn't
  366. * need planes array on DQBUF*/
  367. return 0;
  368. }
  369. if (get_user(p, &up->m.planes))
  370. return -EFAULT;
  371. uplane32 = compat_ptr(p);
  372. if (!access_ok(VERIFY_READ, uplane32,
  373. num_planes * sizeof(struct v4l2_plane32)))
  374. return -EFAULT;
  375. /* We don't really care if userspace decides to kill itself
  376. * by passing a very big num_planes value */
  377. uplane = compat_alloc_user_space(num_planes *
  378. sizeof(struct v4l2_plane));
  379. kp->m.planes = uplane;
  380. while (--num_planes >= 0) {
  381. ret = get_v4l2_plane32(uplane, uplane32, kp->memory);
  382. if (ret)
  383. return ret;
  384. ++uplane;
  385. ++uplane32;
  386. }
  387. } else {
  388. switch (kp->memory) {
  389. case V4L2_MEMORY_MMAP:
  390. if (get_user(kp->length, &up->length) ||
  391. get_user(kp->m.offset, &up->m.offset))
  392. return -EFAULT;
  393. break;
  394. case V4L2_MEMORY_USERPTR:
  395. {
  396. compat_long_t tmp;
  397. if (get_user(kp->length, &up->length) ||
  398. get_user(tmp, &up->m.userptr))
  399. return -EFAULT;
  400. kp->m.userptr = (unsigned long)compat_ptr(tmp);
  401. }
  402. break;
  403. case V4L2_MEMORY_OVERLAY:
  404. if (get_user(kp->m.offset, &up->m.offset))
  405. return -EFAULT;
  406. break;
  407. }
  408. }
  409. return 0;
  410. }
  411. static int put_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user *up)
  412. {
  413. struct v4l2_plane32 __user *uplane32;
  414. struct v4l2_plane __user *uplane;
  415. compat_caddr_t p;
  416. int num_planes;
  417. int ret;
  418. if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_buffer32)) ||
  419. put_user(kp->index, &up->index) ||
  420. put_user(kp->type, &up->type) ||
  421. put_user(kp->flags, &up->flags) ||
  422. put_user(kp->memory, &up->memory))
  423. return -EFAULT;
  424. if (put_user(kp->bytesused, &up->bytesused) ||
  425. put_user(kp->field, &up->field) ||
  426. put_user(kp->timestamp.tv_sec, &up->timestamp.tv_sec) ||
  427. put_user(kp->timestamp.tv_usec, &up->timestamp.tv_usec) ||
  428. copy_to_user(&up->timecode, &kp->timecode, sizeof(struct v4l2_timecode)) ||
  429. put_user(kp->sequence, &up->sequence) ||
  430. put_user(kp->reserved2, &up->reserved2) ||
  431. put_user(kp->reserved, &up->reserved))
  432. return -EFAULT;
  433. if (V4L2_TYPE_IS_MULTIPLANAR(kp->type)) {
  434. num_planes = kp->length;
  435. if (num_planes == 0)
  436. return 0;
  437. uplane = kp->m.planes;
  438. if (get_user(p, &up->m.planes))
  439. return -EFAULT;
  440. uplane32 = compat_ptr(p);
  441. while (--num_planes >= 0) {
  442. ret = put_v4l2_plane32(uplane, uplane32, kp->memory);
  443. if (ret)
  444. return ret;
  445. ++uplane;
  446. ++uplane32;
  447. }
  448. } else {
  449. switch (kp->memory) {
  450. case V4L2_MEMORY_MMAP:
  451. if (put_user(kp->length, &up->length) ||
  452. put_user(kp->m.offset, &up->m.offset))
  453. return -EFAULT;
  454. break;
  455. case V4L2_MEMORY_USERPTR:
  456. if (put_user(kp->length, &up->length) ||
  457. put_user(kp->m.userptr, &up->m.userptr))
  458. return -EFAULT;
  459. break;
  460. case V4L2_MEMORY_OVERLAY:
  461. if (put_user(kp->m.offset, &up->m.offset))
  462. return -EFAULT;
  463. break;
  464. }
  465. }
  466. return 0;
  467. }
  468. struct v4l2_framebuffer32 {
  469. __u32 capability;
  470. __u32 flags;
  471. compat_caddr_t base;
  472. struct v4l2_pix_format fmt;
  473. };
  474. static int get_v4l2_framebuffer32(struct v4l2_framebuffer *kp, struct v4l2_framebuffer32 __user *up)
  475. {
  476. u32 tmp;
  477. if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_framebuffer32)) ||
  478. get_user(tmp, &up->base) ||
  479. get_user(kp->capability, &up->capability) ||
  480. get_user(kp->flags, &up->flags))
  481. return -EFAULT;
  482. kp->base = compat_ptr(tmp);
  483. get_v4l2_pix_format(&kp->fmt, &up->fmt);
  484. return 0;
  485. }
  486. static int put_v4l2_framebuffer32(struct v4l2_framebuffer *kp, struct v4l2_framebuffer32 __user *up)
  487. {
  488. u32 tmp = (u32)((unsigned long)kp->base);
  489. if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_framebuffer32)) ||
  490. put_user(tmp, &up->base) ||
  491. put_user(kp->capability, &up->capability) ||
  492. put_user(kp->flags, &up->flags))
  493. return -EFAULT;
  494. put_v4l2_pix_format(&kp->fmt, &up->fmt);
  495. return 0;
  496. }
  497. struct v4l2_input32 {
  498. __u32 index; /* Which input */
  499. __u8 name[32]; /* Label */
  500. __u32 type; /* Type of input */
  501. __u32 audioset; /* Associated audios (bitfield) */
  502. __u32 tuner; /* Associated tuner */
  503. v4l2_std_id std;
  504. __u32 status;
  505. __u32 reserved[4];
  506. } __attribute__ ((packed));
  507. /* The 64-bit v4l2_input struct has extra padding at the end of the struct.
  508. Otherwise it is identical to the 32-bit version. */
  509. static inline int get_v4l2_input32(struct v4l2_input *kp, struct v4l2_input32 __user *up)
  510. {
  511. if (copy_from_user(kp, up, sizeof(struct v4l2_input32)))
  512. return -EFAULT;
  513. return 0;
  514. }
  515. static inline int put_v4l2_input32(struct v4l2_input *kp, struct v4l2_input32 __user *up)
  516. {
  517. if (copy_to_user(up, kp, sizeof(struct v4l2_input32)))
  518. return -EFAULT;
  519. return 0;
  520. }
  521. struct v4l2_ext_controls32 {
  522. __u32 ctrl_class;
  523. __u32 count;
  524. __u32 error_idx;
  525. __u32 reserved[2];
  526. compat_caddr_t controls; /* actually struct v4l2_ext_control32 * */
  527. };
  528. struct v4l2_ext_control32 {
  529. __u32 id;
  530. __u32 size;
  531. __u32 reserved2[1];
  532. union {
  533. __s32 value;
  534. __s64 value64;
  535. compat_caddr_t string; /* actually char * */
  536. };
  537. } __attribute__ ((packed));
  538. /* The following function really belong in v4l2-common, but that causes
  539. a circular dependency between modules. We need to think about this, but
  540. for now this will do. */
  541. /* Return non-zero if this control is a pointer type. Currently only
  542. type STRING is a pointer type. */
  543. static inline int ctrl_is_pointer(u32 id)
  544. {
  545. switch (id) {
  546. case V4L2_CID_RDS_TX_PS_NAME:
  547. case V4L2_CID_RDS_TX_RADIO_TEXT:
  548. return 1;
  549. default:
  550. return 0;
  551. }
  552. }
  553. static int get_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext_controls32 __user *up)
  554. {
  555. struct v4l2_ext_control32 __user *ucontrols;
  556. struct v4l2_ext_control __user *kcontrols;
  557. int n;
  558. compat_caddr_t p;
  559. if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_ext_controls32)) ||
  560. get_user(kp->ctrl_class, &up->ctrl_class) ||
  561. get_user(kp->count, &up->count) ||
  562. get_user(kp->error_idx, &up->error_idx) ||
  563. copy_from_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
  564. return -EFAULT;
  565. n = kp->count;
  566. if (n == 0) {
  567. kp->controls = NULL;
  568. return 0;
  569. }
  570. if (get_user(p, &up->controls))
  571. return -EFAULT;
  572. ucontrols = compat_ptr(p);
  573. if (!access_ok(VERIFY_READ, ucontrols,
  574. n * sizeof(struct v4l2_ext_control32)))
  575. return -EFAULT;
  576. kcontrols = compat_alloc_user_space(n * sizeof(struct v4l2_ext_control));
  577. kp->controls = kcontrols;
  578. while (--n >= 0) {
  579. if (copy_in_user(kcontrols, ucontrols, sizeof(*ucontrols)))
  580. return -EFAULT;
  581. if (ctrl_is_pointer(kcontrols->id)) {
  582. void __user *s;
  583. if (get_user(p, &ucontrols->string))
  584. return -EFAULT;
  585. s = compat_ptr(p);
  586. if (put_user(s, &kcontrols->string))
  587. return -EFAULT;
  588. }
  589. ucontrols++;
  590. kcontrols++;
  591. }
  592. return 0;
  593. }
  594. static int put_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext_controls32 __user *up)
  595. {
  596. struct v4l2_ext_control32 __user *ucontrols;
  597. struct v4l2_ext_control __user *kcontrols = kp->controls;
  598. int n = kp->count;
  599. compat_caddr_t p;
  600. if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_ext_controls32)) ||
  601. put_user(kp->ctrl_class, &up->ctrl_class) ||
  602. put_user(kp->count, &up->count) ||
  603. put_user(kp->error_idx, &up->error_idx) ||
  604. copy_to_user(up->reserved, kp->reserved, sizeof(up->reserved)))
  605. return -EFAULT;
  606. if (!kp->count)
  607. return 0;
  608. if (get_user(p, &up->controls))
  609. return -EFAULT;
  610. ucontrols = compat_ptr(p);
  611. if (!access_ok(VERIFY_WRITE, ucontrols,
  612. n * sizeof(struct v4l2_ext_control32)))
  613. return -EFAULT;
  614. while (--n >= 0) {
  615. unsigned size = sizeof(*ucontrols);
  616. /* Do not modify the pointer when copying a pointer control.
  617. The contents of the pointer was changed, not the pointer
  618. itself. */
  619. if (ctrl_is_pointer(kcontrols->id))
  620. size -= sizeof(ucontrols->value64);
  621. if (copy_in_user(ucontrols, kcontrols, size))
  622. return -EFAULT;
  623. ucontrols++;
  624. kcontrols++;
  625. }
  626. return 0;
  627. }
  628. struct v4l2_event32 {
  629. __u32 type;
  630. union {
  631. __u8 data[64];
  632. } u;
  633. __u32 pending;
  634. __u32 sequence;
  635. struct compat_timespec timestamp;
  636. __u32 id;
  637. __u32 reserved[8];
  638. };
  639. static int put_v4l2_event32(struct v4l2_event *kp, struct v4l2_event32 __user *up)
  640. {
  641. if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_event32)) ||
  642. put_user(kp->type, &up->type) ||
  643. copy_to_user(&up->u, &kp->u, sizeof(kp->u)) ||
  644. put_user(kp->pending, &up->pending) ||
  645. put_user(kp->sequence, &up->sequence) ||
  646. put_compat_timespec(&kp->timestamp, &up->timestamp) ||
  647. put_user(kp->id, &up->id) ||
  648. copy_to_user(up->reserved, kp->reserved, 8 * sizeof(__u32)))
  649. return -EFAULT;
  650. return 0;
  651. }
  652. struct v4l2_subdev_edid32 {
  653. __u32 pad;
  654. __u32 start_block;
  655. __u32 blocks;
  656. __u32 reserved[5];
  657. compat_caddr_t edid;
  658. };
  659. static int get_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subdev_edid32 __user *up)
  660. {
  661. u32 tmp;
  662. if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_subdev_edid32)) ||
  663. get_user(kp->pad, &up->pad) ||
  664. get_user(kp->start_block, &up->start_block) ||
  665. get_user(kp->blocks, &up->blocks) ||
  666. get_user(tmp, &up->edid) ||
  667. copy_from_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
  668. return -EFAULT;
  669. kp->edid = compat_ptr(tmp);
  670. return 0;
  671. }
  672. static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subdev_edid32 __user *up)
  673. {
  674. u32 tmp = (u32)((unsigned long)kp->edid);
  675. if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_subdev_edid32)) ||
  676. put_user(kp->pad, &up->pad) ||
  677. put_user(kp->start_block, &up->start_block) ||
  678. put_user(kp->blocks, &up->blocks) ||
  679. put_user(tmp, &up->edid) ||
  680. copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
  681. return -EFAULT;
  682. return 0;
  683. }
  684. #define VIDIOC_G_FMT32 _IOWR('V', 4, struct v4l2_format32)
  685. #define VIDIOC_S_FMT32 _IOWR('V', 5, struct v4l2_format32)
  686. #define VIDIOC_QUERYBUF32 _IOWR('V', 9, struct v4l2_buffer32)
  687. #define VIDIOC_G_FBUF32 _IOR ('V', 10, struct v4l2_framebuffer32)
  688. #define VIDIOC_S_FBUF32 _IOW ('V', 11, struct v4l2_framebuffer32)
  689. #define VIDIOC_QBUF32 _IOWR('V', 15, struct v4l2_buffer32)
  690. #define VIDIOC_DQBUF32 _IOWR('V', 17, struct v4l2_buffer32)
  691. #define VIDIOC_ENUMSTD32 _IOWR('V', 25, struct v4l2_standard32)
  692. #define VIDIOC_ENUMINPUT32 _IOWR('V', 26, struct v4l2_input32)
  693. #define VIDIOC_SUBDEV_G_EDID32 _IOWR('V', 63, struct v4l2_subdev_edid32)
  694. #define VIDIOC_SUBDEV_S_EDID32 _IOWR('V', 64, struct v4l2_subdev_edid32)
  695. #define VIDIOC_TRY_FMT32 _IOWR('V', 64, struct v4l2_format32)
  696. #define VIDIOC_G_EXT_CTRLS32 _IOWR('V', 71, struct v4l2_ext_controls32)
  697. #define VIDIOC_S_EXT_CTRLS32 _IOWR('V', 72, struct v4l2_ext_controls32)
  698. #define VIDIOC_TRY_EXT_CTRLS32 _IOWR('V', 73, struct v4l2_ext_controls32)
  699. #define VIDIOC_DQEVENT32 _IOR ('V', 89, struct v4l2_event32)
  700. #define VIDIOC_CREATE_BUFS32 _IOWR('V', 92, struct v4l2_create_buffers32)
  701. #define VIDIOC_PREPARE_BUF32 _IOWR('V', 93, struct v4l2_buffer32)
  702. #define VIDIOC_OVERLAY32 _IOW ('V', 14, s32)
  703. #define VIDIOC_STREAMON32 _IOW ('V', 18, s32)
  704. #define VIDIOC_STREAMOFF32 _IOW ('V', 19, s32)
  705. #define VIDIOC_G_INPUT32 _IOR ('V', 38, s32)
  706. #define VIDIOC_S_INPUT32 _IOWR('V', 39, s32)
  707. #define VIDIOC_G_OUTPUT32 _IOR ('V', 46, s32)
  708. #define VIDIOC_S_OUTPUT32 _IOWR('V', 47, s32)
  709. static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
  710. {
  711. union {
  712. struct v4l2_format v2f;
  713. struct v4l2_buffer v2b;
  714. struct v4l2_framebuffer v2fb;
  715. struct v4l2_input v2i;
  716. struct v4l2_standard v2s;
  717. struct v4l2_ext_controls v2ecs;
  718. struct v4l2_event v2ev;
  719. struct v4l2_create_buffers v2crt;
  720. struct v4l2_subdev_edid v2edid;
  721. unsigned long vx;
  722. int vi;
  723. } karg;
  724. void __user *up = compat_ptr(arg);
  725. int compatible_arg = 1;
  726. long err = 0;
  727. /* First, convert the command. */
  728. switch (cmd) {
  729. case VIDIOC_G_FMT32: cmd = VIDIOC_G_FMT; break;
  730. case VIDIOC_S_FMT32: cmd = VIDIOC_S_FMT; break;
  731. case VIDIOC_QUERYBUF32: cmd = VIDIOC_QUERYBUF; break;
  732. case VIDIOC_G_FBUF32: cmd = VIDIOC_G_FBUF; break;
  733. case VIDIOC_S_FBUF32: cmd = VIDIOC_S_FBUF; break;
  734. case VIDIOC_QBUF32: cmd = VIDIOC_QBUF; break;
  735. case VIDIOC_DQBUF32: cmd = VIDIOC_DQBUF; break;
  736. case VIDIOC_ENUMSTD32: cmd = VIDIOC_ENUMSTD; break;
  737. case VIDIOC_ENUMINPUT32: cmd = VIDIOC_ENUMINPUT; break;
  738. case VIDIOC_TRY_FMT32: cmd = VIDIOC_TRY_FMT; break;
  739. case VIDIOC_G_EXT_CTRLS32: cmd = VIDIOC_G_EXT_CTRLS; break;
  740. case VIDIOC_S_EXT_CTRLS32: cmd = VIDIOC_S_EXT_CTRLS; break;
  741. case VIDIOC_TRY_EXT_CTRLS32: cmd = VIDIOC_TRY_EXT_CTRLS; break;
  742. case VIDIOC_DQEVENT32: cmd = VIDIOC_DQEVENT; break;
  743. case VIDIOC_OVERLAY32: cmd = VIDIOC_OVERLAY; break;
  744. case VIDIOC_STREAMON32: cmd = VIDIOC_STREAMON; break;
  745. case VIDIOC_STREAMOFF32: cmd = VIDIOC_STREAMOFF; break;
  746. case VIDIOC_G_INPUT32: cmd = VIDIOC_G_INPUT; break;
  747. case VIDIOC_S_INPUT32: cmd = VIDIOC_S_INPUT; break;
  748. case VIDIOC_G_OUTPUT32: cmd = VIDIOC_G_OUTPUT; break;
  749. case VIDIOC_S_OUTPUT32: cmd = VIDIOC_S_OUTPUT; break;
  750. case VIDIOC_CREATE_BUFS32: cmd = VIDIOC_CREATE_BUFS; break;
  751. case VIDIOC_PREPARE_BUF32: cmd = VIDIOC_PREPARE_BUF; break;
  752. case VIDIOC_SUBDEV_G_EDID32: cmd = VIDIOC_SUBDEV_G_EDID; break;
  753. case VIDIOC_SUBDEV_S_EDID32: cmd = VIDIOC_SUBDEV_S_EDID; break;
  754. }
  755. switch (cmd) {
  756. case VIDIOC_OVERLAY:
  757. case VIDIOC_STREAMON:
  758. case VIDIOC_STREAMOFF:
  759. case VIDIOC_S_INPUT:
  760. case VIDIOC_S_OUTPUT:
  761. err = get_user(karg.vi, (s32 __user *)up);
  762. compatible_arg = 0;
  763. break;
  764. case VIDIOC_G_INPUT:
  765. case VIDIOC_G_OUTPUT:
  766. compatible_arg = 0;
  767. break;
  768. case VIDIOC_SUBDEV_G_EDID:
  769. case VIDIOC_SUBDEV_S_EDID:
  770. err = get_v4l2_subdev_edid32(&karg.v2edid, up);
  771. compatible_arg = 0;
  772. break;
  773. case VIDIOC_G_FMT:
  774. case VIDIOC_S_FMT:
  775. case VIDIOC_TRY_FMT:
  776. err = get_v4l2_format32(&karg.v2f, up);
  777. compatible_arg = 0;
  778. break;
  779. case VIDIOC_CREATE_BUFS:
  780. err = get_v4l2_create32(&karg.v2crt, up);
  781. compatible_arg = 0;
  782. break;
  783. case VIDIOC_PREPARE_BUF:
  784. case VIDIOC_QUERYBUF:
  785. case VIDIOC_QBUF:
  786. case VIDIOC_DQBUF:
  787. err = get_v4l2_buffer32(&karg.v2b, up);
  788. compatible_arg = 0;
  789. break;
  790. case VIDIOC_S_FBUF:
  791. err = get_v4l2_framebuffer32(&karg.v2fb, up);
  792. compatible_arg = 0;
  793. break;
  794. case VIDIOC_G_FBUF:
  795. compatible_arg = 0;
  796. break;
  797. case VIDIOC_ENUMSTD:
  798. err = get_v4l2_standard32(&karg.v2s, up);
  799. compatible_arg = 0;
  800. break;
  801. case VIDIOC_ENUMINPUT:
  802. err = get_v4l2_input32(&karg.v2i, up);
  803. compatible_arg = 0;
  804. break;
  805. case VIDIOC_G_EXT_CTRLS:
  806. case VIDIOC_S_EXT_CTRLS:
  807. case VIDIOC_TRY_EXT_CTRLS:
  808. err = get_v4l2_ext_controls32(&karg.v2ecs, up);
  809. compatible_arg = 0;
  810. break;
  811. case VIDIOC_DQEVENT:
  812. compatible_arg = 0;
  813. break;
  814. }
  815. if (err)
  816. return err;
  817. if (compatible_arg)
  818. err = native_ioctl(file, cmd, (unsigned long)up);
  819. else {
  820. mm_segment_t old_fs = get_fs();
  821. set_fs(KERNEL_DS);
  822. err = native_ioctl(file, cmd, (unsigned long)&karg);
  823. set_fs(old_fs);
  824. }
  825. /* Special case: even after an error we need to put the
  826. results back for these ioctls since the error_idx will
  827. contain information on which control failed. */
  828. switch (cmd) {
  829. case VIDIOC_G_EXT_CTRLS:
  830. case VIDIOC_S_EXT_CTRLS:
  831. case VIDIOC_TRY_EXT_CTRLS:
  832. if (put_v4l2_ext_controls32(&karg.v2ecs, up))
  833. err = -EFAULT;
  834. break;
  835. }
  836. if (err)
  837. return err;
  838. switch (cmd) {
  839. case VIDIOC_S_INPUT:
  840. case VIDIOC_S_OUTPUT:
  841. case VIDIOC_G_INPUT:
  842. case VIDIOC_G_OUTPUT:
  843. err = put_user(((s32)karg.vi), (s32 __user *)up);
  844. break;
  845. case VIDIOC_G_FBUF:
  846. err = put_v4l2_framebuffer32(&karg.v2fb, up);
  847. break;
  848. case VIDIOC_DQEVENT:
  849. err = put_v4l2_event32(&karg.v2ev, up);
  850. break;
  851. case VIDIOC_SUBDEV_G_EDID:
  852. case VIDIOC_SUBDEV_S_EDID:
  853. err = put_v4l2_subdev_edid32(&karg.v2edid, up);
  854. break;
  855. case VIDIOC_G_FMT:
  856. case VIDIOC_S_FMT:
  857. case VIDIOC_TRY_FMT:
  858. err = put_v4l2_format32(&karg.v2f, up);
  859. break;
  860. case VIDIOC_CREATE_BUFS:
  861. err = put_v4l2_create32(&karg.v2crt, up);
  862. break;
  863. case VIDIOC_QUERYBUF:
  864. case VIDIOC_QBUF:
  865. case VIDIOC_DQBUF:
  866. err = put_v4l2_buffer32(&karg.v2b, up);
  867. break;
  868. case VIDIOC_ENUMSTD:
  869. err = put_v4l2_standard32(&karg.v2s, up);
  870. break;
  871. case VIDIOC_ENUMINPUT:
  872. err = put_v4l2_input32(&karg.v2i, up);
  873. break;
  874. }
  875. return err;
  876. }
  877. long v4l2_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg)
  878. {
  879. struct video_device *vdev = video_devdata(file);
  880. long ret = -ENOIOCTLCMD;
  881. if (!file->f_op->unlocked_ioctl)
  882. return ret;
  883. switch (cmd) {
  884. case VIDIOC_QUERYCAP:
  885. case VIDIOC_RESERVED:
  886. case VIDIOC_ENUM_FMT:
  887. case VIDIOC_G_FMT32:
  888. case VIDIOC_S_FMT32:
  889. case VIDIOC_REQBUFS:
  890. case VIDIOC_QUERYBUF32:
  891. case VIDIOC_G_FBUF32:
  892. case VIDIOC_S_FBUF32:
  893. case VIDIOC_OVERLAY32:
  894. case VIDIOC_QBUF32:
  895. case VIDIOC_DQBUF32:
  896. case VIDIOC_STREAMON32:
  897. case VIDIOC_STREAMOFF32:
  898. case VIDIOC_G_PARM:
  899. case VIDIOC_S_PARM:
  900. case VIDIOC_G_STD:
  901. case VIDIOC_S_STD:
  902. case VIDIOC_ENUMSTD32:
  903. case VIDIOC_ENUMINPUT32:
  904. case VIDIOC_G_CTRL:
  905. case VIDIOC_S_CTRL:
  906. case VIDIOC_G_TUNER:
  907. case VIDIOC_S_TUNER:
  908. case VIDIOC_G_AUDIO:
  909. case VIDIOC_S_AUDIO:
  910. case VIDIOC_QUERYCTRL:
  911. case VIDIOC_QUERYMENU:
  912. case VIDIOC_G_INPUT32:
  913. case VIDIOC_S_INPUT32:
  914. case VIDIOC_G_OUTPUT32:
  915. case VIDIOC_S_OUTPUT32:
  916. case VIDIOC_ENUMOUTPUT:
  917. case VIDIOC_G_AUDOUT:
  918. case VIDIOC_S_AUDOUT:
  919. case VIDIOC_G_MODULATOR:
  920. case VIDIOC_S_MODULATOR:
  921. case VIDIOC_S_FREQUENCY:
  922. case VIDIOC_G_FREQUENCY:
  923. case VIDIOC_CROPCAP:
  924. case VIDIOC_G_CROP:
  925. case VIDIOC_S_CROP:
  926. case VIDIOC_G_SELECTION:
  927. case VIDIOC_S_SELECTION:
  928. case VIDIOC_G_JPEGCOMP:
  929. case VIDIOC_S_JPEGCOMP:
  930. case VIDIOC_QUERYSTD:
  931. case VIDIOC_TRY_FMT32:
  932. case VIDIOC_ENUMAUDIO:
  933. case VIDIOC_ENUMAUDOUT:
  934. case VIDIOC_G_PRIORITY:
  935. case VIDIOC_S_PRIORITY:
  936. case VIDIOC_G_SLICED_VBI_CAP:
  937. case VIDIOC_LOG_STATUS:
  938. case VIDIOC_G_EXT_CTRLS32:
  939. case VIDIOC_S_EXT_CTRLS32:
  940. case VIDIOC_TRY_EXT_CTRLS32:
  941. case VIDIOC_ENUM_FRAMESIZES:
  942. case VIDIOC_ENUM_FRAMEINTERVALS:
  943. case VIDIOC_G_ENC_INDEX:
  944. case VIDIOC_ENCODER_CMD:
  945. case VIDIOC_TRY_ENCODER_CMD:
  946. case VIDIOC_DECODER_CMD:
  947. case VIDIOC_TRY_DECODER_CMD:
  948. case VIDIOC_DBG_S_REGISTER:
  949. case VIDIOC_DBG_G_REGISTER:
  950. case VIDIOC_DBG_G_CHIP_IDENT:
  951. case VIDIOC_S_HW_FREQ_SEEK:
  952. case VIDIOC_ENUM_DV_PRESETS:
  953. case VIDIOC_S_DV_PRESET:
  954. case VIDIOC_G_DV_PRESET:
  955. case VIDIOC_QUERY_DV_PRESET:
  956. case VIDIOC_S_DV_TIMINGS:
  957. case VIDIOC_G_DV_TIMINGS:
  958. case VIDIOC_DQEVENT:
  959. case VIDIOC_DQEVENT32:
  960. case VIDIOC_SUBSCRIBE_EVENT:
  961. case VIDIOC_UNSUBSCRIBE_EVENT:
  962. case VIDIOC_CREATE_BUFS32:
  963. case VIDIOC_PREPARE_BUF32:
  964. case VIDIOC_ENUM_DV_TIMINGS:
  965. case VIDIOC_QUERY_DV_TIMINGS:
  966. case VIDIOC_DV_TIMINGS_CAP:
  967. case VIDIOC_ENUM_FREQ_BANDS:
  968. case VIDIOC_SUBDEV_G_EDID32:
  969. case VIDIOC_SUBDEV_S_EDID32:
  970. ret = do_video_ioctl(file, cmd, arg);
  971. break;
  972. default:
  973. if (vdev->fops->compat_ioctl32)
  974. ret = vdev->fops->compat_ioctl32(file, cmd, arg);
  975. if (ret == -ENOIOCTLCMD)
  976. printk(KERN_WARNING "compat_ioctl32: "
  977. "unknown ioctl '%c', dir=%d, #%d (0x%08x)\n",
  978. _IOC_TYPE(cmd), _IOC_DIR(cmd), _IOC_NR(cmd),
  979. cmd);
  980. break;
  981. }
  982. return ret;
  983. }
  984. EXPORT_SYMBOL_GPL(v4l2_compat_ioctl32);