v4l2-compat-ioctl32.c 30 KB

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