v4l2-compat-ioctl32.c 30 KB

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