v4l2-compat-ioctl32.c 30 KB

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