v4l2-compat-ioctl32.c 33 KB

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