videodev.c 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766
  1. /*
  2. * Video capture interface for Linux version 2
  3. *
  4. * A generic video device interface for the LINUX operating system
  5. * using a set of device structures/vectors for low level operations.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version
  10. * 2 of the License, or (at your option) any later version.
  11. *
  12. * Authors: Alan Cox, <alan@redhat.com> (version 1)
  13. * Mauro Carvalho Chehab <mchehab@infradead.org> (version 2)
  14. *
  15. * Fixes: 20000516 Claudio Matsuoka <claudio@conectiva.com>
  16. * - Added procfs support
  17. */
  18. #define dbgarg(cmd, fmt, arg...) \
  19. if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) { \
  20. printk (KERN_DEBUG "%s: ", vfd->name); \
  21. v4l_printk_ioctl(cmd); \
  22. printk (KERN_DEBUG "%s: " fmt, vfd->name, ## arg); \
  23. }
  24. #define dbgarg2(fmt, arg...) \
  25. if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) \
  26. printk (KERN_DEBUG "%s: " fmt, vfd->name, ## arg);
  27. #include <linux/module.h>
  28. #include <linux/types.h>
  29. #include <linux/kernel.h>
  30. #include <linux/sched.h>
  31. #include <linux/smp_lock.h>
  32. #include <linux/mm.h>
  33. #include <linux/string.h>
  34. #include <linux/errno.h>
  35. #include <linux/init.h>
  36. #include <linux/kmod.h>
  37. #include <linux/slab.h>
  38. #include <asm/uaccess.h>
  39. #include <asm/system.h>
  40. #define __OLD_VIDIOC_ /* To allow fixing old calls*/
  41. #include <linux/videodev2.h>
  42. #ifdef CONFIG_VIDEO_V4L1
  43. #include <linux/videodev.h>
  44. #endif
  45. #include <media/v4l2-common.h>
  46. #define VIDEO_NUM_DEVICES 256
  47. #define VIDEO_NAME "video4linux"
  48. /*
  49. * sysfs stuff
  50. */
  51. static ssize_t show_name(struct class_device *cd, char *buf)
  52. {
  53. struct video_device *vfd = container_of(cd, struct video_device,
  54. class_dev);
  55. return sprintf(buf,"%.*s\n",(int)sizeof(vfd->name),vfd->name);
  56. }
  57. static CLASS_DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
  58. struct video_device *video_device_alloc(void)
  59. {
  60. struct video_device *vfd;
  61. vfd = kzalloc(sizeof(*vfd),GFP_KERNEL);
  62. return vfd;
  63. }
  64. void video_device_release(struct video_device *vfd)
  65. {
  66. kfree(vfd);
  67. }
  68. static void video_release(struct class_device *cd)
  69. {
  70. struct video_device *vfd = container_of(cd, struct video_device,
  71. class_dev);
  72. #if 1
  73. /* needed until all drivers are fixed */
  74. if (!vfd->release)
  75. return;
  76. #endif
  77. vfd->release(vfd);
  78. }
  79. static struct class video_class = {
  80. .name = VIDEO_NAME,
  81. .release = video_release,
  82. };
  83. /*
  84. * Active devices
  85. */
  86. static struct video_device *video_device[VIDEO_NUM_DEVICES];
  87. static DEFINE_MUTEX(videodev_lock);
  88. struct video_device* video_devdata(struct file *file)
  89. {
  90. return video_device[iminor(file->f_path.dentry->d_inode)];
  91. }
  92. /*
  93. * Open a video device - FIXME: Obsoleted
  94. */
  95. static int video_open(struct inode *inode, struct file *file)
  96. {
  97. unsigned int minor = iminor(inode);
  98. int err = 0;
  99. struct video_device *vfl;
  100. const struct file_operations *old_fops;
  101. if(minor>=VIDEO_NUM_DEVICES)
  102. return -ENODEV;
  103. mutex_lock(&videodev_lock);
  104. vfl=video_device[minor];
  105. if(vfl==NULL) {
  106. mutex_unlock(&videodev_lock);
  107. request_module("char-major-%d-%d", VIDEO_MAJOR, minor);
  108. mutex_lock(&videodev_lock);
  109. vfl=video_device[minor];
  110. if (vfl==NULL) {
  111. mutex_unlock(&videodev_lock);
  112. return -ENODEV;
  113. }
  114. }
  115. old_fops = file->f_op;
  116. file->f_op = fops_get(vfl->fops);
  117. if(file->f_op->open)
  118. err = file->f_op->open(inode,file);
  119. if (err) {
  120. fops_put(file->f_op);
  121. file->f_op = fops_get(old_fops);
  122. }
  123. fops_put(old_fops);
  124. mutex_unlock(&videodev_lock);
  125. return err;
  126. }
  127. /*
  128. * helper function -- handles userspace copying for ioctl arguments
  129. */
  130. #ifdef __OLD_VIDIOC_
  131. static unsigned int
  132. video_fix_command(unsigned int cmd)
  133. {
  134. switch (cmd) {
  135. case VIDIOC_OVERLAY_OLD:
  136. cmd = VIDIOC_OVERLAY;
  137. break;
  138. case VIDIOC_S_PARM_OLD:
  139. cmd = VIDIOC_S_PARM;
  140. break;
  141. case VIDIOC_S_CTRL_OLD:
  142. cmd = VIDIOC_S_CTRL;
  143. break;
  144. case VIDIOC_G_AUDIO_OLD:
  145. cmd = VIDIOC_G_AUDIO;
  146. break;
  147. case VIDIOC_G_AUDOUT_OLD:
  148. cmd = VIDIOC_G_AUDOUT;
  149. break;
  150. case VIDIOC_CROPCAP_OLD:
  151. cmd = VIDIOC_CROPCAP;
  152. break;
  153. }
  154. return cmd;
  155. }
  156. #endif
  157. /*
  158. * Obsolete usercopy function - Should be removed soon
  159. */
  160. int
  161. video_usercopy(struct inode *inode, struct file *file,
  162. unsigned int cmd, unsigned long arg,
  163. int (*func)(struct inode *inode, struct file *file,
  164. unsigned int cmd, void *arg))
  165. {
  166. char sbuf[128];
  167. void *mbuf = NULL;
  168. void *parg = NULL;
  169. int err = -EINVAL;
  170. int is_ext_ctrl;
  171. size_t ctrls_size = 0;
  172. void __user *user_ptr = NULL;
  173. #ifdef __OLD_VIDIOC_
  174. cmd = video_fix_command(cmd);
  175. #endif
  176. is_ext_ctrl = (cmd == VIDIOC_S_EXT_CTRLS || cmd == VIDIOC_G_EXT_CTRLS ||
  177. cmd == VIDIOC_TRY_EXT_CTRLS);
  178. /* Copy arguments into temp kernel buffer */
  179. switch (_IOC_DIR(cmd)) {
  180. case _IOC_NONE:
  181. parg = NULL;
  182. break;
  183. case _IOC_READ:
  184. case _IOC_WRITE:
  185. case (_IOC_WRITE | _IOC_READ):
  186. if (_IOC_SIZE(cmd) <= sizeof(sbuf)) {
  187. parg = sbuf;
  188. } else {
  189. /* too big to allocate from stack */
  190. mbuf = kmalloc(_IOC_SIZE(cmd),GFP_KERNEL);
  191. if (NULL == mbuf)
  192. return -ENOMEM;
  193. parg = mbuf;
  194. }
  195. err = -EFAULT;
  196. if (_IOC_DIR(cmd) & _IOC_WRITE)
  197. if (copy_from_user(parg, (void __user *)arg, _IOC_SIZE(cmd)))
  198. goto out;
  199. break;
  200. }
  201. if (is_ext_ctrl) {
  202. struct v4l2_ext_controls *p = parg;
  203. /* In case of an error, tell the caller that it wasn't
  204. a specific control that caused it. */
  205. p->error_idx = p->count;
  206. user_ptr = (void __user *)p->controls;
  207. if (p->count) {
  208. ctrls_size = sizeof(struct v4l2_ext_control) * p->count;
  209. /* Note: v4l2_ext_controls fits in sbuf[] so mbuf is still NULL. */
  210. mbuf = kmalloc(ctrls_size, GFP_KERNEL);
  211. err = -ENOMEM;
  212. if (NULL == mbuf)
  213. goto out_ext_ctrl;
  214. err = -EFAULT;
  215. if (copy_from_user(mbuf, user_ptr, ctrls_size))
  216. goto out_ext_ctrl;
  217. p->controls = mbuf;
  218. }
  219. }
  220. /* call driver */
  221. err = func(inode, file, cmd, parg);
  222. if (err == -ENOIOCTLCMD)
  223. err = -EINVAL;
  224. if (is_ext_ctrl) {
  225. struct v4l2_ext_controls *p = parg;
  226. p->controls = (void *)user_ptr;
  227. if (p->count && err == 0 && copy_to_user(user_ptr, mbuf, ctrls_size))
  228. err = -EFAULT;
  229. goto out_ext_ctrl;
  230. }
  231. if (err < 0)
  232. goto out;
  233. out_ext_ctrl:
  234. /* Copy results into user buffer */
  235. switch (_IOC_DIR(cmd))
  236. {
  237. case _IOC_READ:
  238. case (_IOC_WRITE | _IOC_READ):
  239. if (copy_to_user((void __user *)arg, parg, _IOC_SIZE(cmd)))
  240. err = -EFAULT;
  241. break;
  242. }
  243. out:
  244. kfree(mbuf);
  245. return err;
  246. }
  247. /*
  248. * open/release helper functions -- handle exclusive opens
  249. * Should be removed soon
  250. */
  251. int video_exclusive_open(struct inode *inode, struct file *file)
  252. {
  253. struct video_device *vfl = video_devdata(file);
  254. int retval = 0;
  255. mutex_lock(&vfl->lock);
  256. if (vfl->users) {
  257. retval = -EBUSY;
  258. } else {
  259. vfl->users++;
  260. }
  261. mutex_unlock(&vfl->lock);
  262. return retval;
  263. }
  264. int video_exclusive_release(struct inode *inode, struct file *file)
  265. {
  266. struct video_device *vfl = video_devdata(file);
  267. vfl->users--;
  268. return 0;
  269. }
  270. static char *v4l2_memory_names[] = {
  271. [V4L2_MEMORY_MMAP] = "mmap",
  272. [V4L2_MEMORY_USERPTR] = "userptr",
  273. [V4L2_MEMORY_OVERLAY] = "overlay",
  274. };
  275. /* FIXME: Those stuff are replicated also on v4l2-common.c */
  276. static char *v4l2_type_names_FIXME[] = {
  277. [V4L2_BUF_TYPE_VIDEO_CAPTURE] = "video-cap",
  278. [V4L2_BUF_TYPE_VIDEO_OVERLAY] = "video-over",
  279. [V4L2_BUF_TYPE_VIDEO_OUTPUT] = "video-out",
  280. [V4L2_BUF_TYPE_VBI_CAPTURE] = "vbi-cap",
  281. [V4L2_BUF_TYPE_VBI_OUTPUT] = "vbi-out",
  282. [V4L2_BUF_TYPE_SLICED_VBI_OUTPUT] = "sliced-vbi-out",
  283. [V4L2_BUF_TYPE_SLICED_VBI_CAPTURE] = "sliced-vbi-capture",
  284. [V4L2_BUF_TYPE_PRIVATE] = "private",
  285. };
  286. static char *v4l2_field_names_FIXME[] = {
  287. [V4L2_FIELD_ANY] = "any",
  288. [V4L2_FIELD_NONE] = "none",
  289. [V4L2_FIELD_TOP] = "top",
  290. [V4L2_FIELD_BOTTOM] = "bottom",
  291. [V4L2_FIELD_INTERLACED] = "interlaced",
  292. [V4L2_FIELD_SEQ_TB] = "seq-tb",
  293. [V4L2_FIELD_SEQ_BT] = "seq-bt",
  294. [V4L2_FIELD_ALTERNATE] = "alternate",
  295. };
  296. #define prt_names(a,arr) (((a)>=0)&&((a)<ARRAY_SIZE(arr)))?arr[a]:"unknown"
  297. static void dbgbuf(unsigned int cmd, struct video_device *vfd,
  298. struct v4l2_buffer *p)
  299. {
  300. struct v4l2_timecode *tc=&p->timecode;
  301. dbgarg (cmd, "%02ld:%02d:%02d.%08ld index=%d, type=%s, "
  302. "bytesused=%d, flags=0x%08d, "
  303. "field=%0d, sequence=%d, memory=%s, offset/userptr=0x%08lx\n",
  304. (p->timestamp.tv_sec/3600),
  305. (int)(p->timestamp.tv_sec/60)%60,
  306. (int)(p->timestamp.tv_sec%60),
  307. p->timestamp.tv_usec,
  308. p->index,
  309. prt_names(p->type,v4l2_type_names_FIXME),
  310. p->bytesused,p->flags,
  311. p->field,p->sequence,
  312. prt_names(p->memory,v4l2_memory_names),
  313. p->m.userptr);
  314. dbgarg2 ("timecode= %02d:%02d:%02d type=%d, "
  315. "flags=0x%08d, frames=%d, userbits=0x%08x\n",
  316. tc->hours,tc->minutes,tc->seconds,
  317. tc->type, tc->flags, tc->frames, *(__u32 *) tc->userbits);
  318. }
  319. static inline void dbgrect(struct video_device *vfd, char *s,
  320. struct v4l2_rect *r)
  321. {
  322. dbgarg2 ("%sRect start at %dx%d, size= %dx%d\n", s, r->left, r->top,
  323. r->width, r->height);
  324. };
  325. static inline void v4l_print_pix_fmt (struct video_device *vfd,
  326. struct v4l2_pix_format *fmt)
  327. {
  328. dbgarg2 ("width=%d, height=%d, format=0x%08x, field=%s, "
  329. "bytesperline=%d sizeimage=%d, colorspace=%d\n",
  330. fmt->width,fmt->height,fmt->pixelformat,
  331. prt_names(fmt->field,v4l2_field_names_FIXME),
  332. fmt->bytesperline,fmt->sizeimage,fmt->colorspace);
  333. };
  334. static int check_fmt (struct video_device *vfd, enum v4l2_buf_type type)
  335. {
  336. switch (type) {
  337. case V4L2_BUF_TYPE_VIDEO_CAPTURE:
  338. if (vfd->vidioc_try_fmt_cap)
  339. return (0);
  340. break;
  341. case V4L2_BUF_TYPE_VIDEO_OVERLAY:
  342. if (vfd->vidioc_try_fmt_overlay)
  343. return (0);
  344. break;
  345. case V4L2_BUF_TYPE_VBI_CAPTURE:
  346. if (vfd->vidioc_try_fmt_vbi)
  347. return (0);
  348. break;
  349. case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
  350. if (vfd->vidioc_try_fmt_vbi_output)
  351. return (0);
  352. break;
  353. case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
  354. if (vfd->vidioc_try_fmt_vbi_capture)
  355. return (0);
  356. break;
  357. case V4L2_BUF_TYPE_VIDEO_OUTPUT:
  358. if (vfd->vidioc_try_fmt_video_output)
  359. return (0);
  360. break;
  361. case V4L2_BUF_TYPE_VBI_OUTPUT:
  362. if (vfd->vidioc_try_fmt_vbi_output)
  363. return (0);
  364. break;
  365. case V4L2_BUF_TYPE_PRIVATE:
  366. if (vfd->vidioc_try_fmt_type_private)
  367. return (0);
  368. break;
  369. }
  370. return (-EINVAL);
  371. }
  372. static int __video_do_ioctl(struct inode *inode, struct file *file,
  373. unsigned int cmd, void *arg)
  374. {
  375. struct video_device *vfd = video_devdata(file);
  376. void *fh = file->private_data;
  377. int ret = -EINVAL;
  378. if ( (vfd->debug & V4L2_DEBUG_IOCTL) &&
  379. !(vfd->debug | V4L2_DEBUG_IOCTL_ARG)) {
  380. v4l_print_ioctl(vfd->name, cmd);
  381. }
  382. if (_IOC_TYPE(cmd)=='v')
  383. return v4l_compat_translate_ioctl(inode,file,cmd,arg,
  384. __video_do_ioctl);
  385. switch(cmd) {
  386. /* --- capabilities ------------------------------------------ */
  387. case VIDIOC_QUERYCAP:
  388. {
  389. struct v4l2_capability *cap = (struct v4l2_capability*)arg;
  390. memset(cap, 0, sizeof(*cap));
  391. if (!vfd->vidioc_querycap)
  392. break;
  393. ret=vfd->vidioc_querycap(file, fh, cap);
  394. if (!ret)
  395. dbgarg (cmd, "driver=%s, card=%s, bus=%s, "
  396. "version=0x%08x, "
  397. "capabilities=0x%08x\n",
  398. cap->driver,cap->card,cap->bus_info,
  399. cap->version,
  400. cap->capabilities);
  401. break;
  402. }
  403. /* --- priority ------------------------------------------ */
  404. case VIDIOC_G_PRIORITY:
  405. {
  406. enum v4l2_priority *p=arg;
  407. if (!vfd->vidioc_g_priority)
  408. break;
  409. ret=vfd->vidioc_g_priority(file, fh, p);
  410. if (!ret)
  411. dbgarg(cmd, "priority is %d\n", *p);
  412. break;
  413. }
  414. case VIDIOC_S_PRIORITY:
  415. {
  416. enum v4l2_priority *p=arg;
  417. if (!vfd->vidioc_s_priority)
  418. break;
  419. dbgarg(cmd, "setting priority to %d\n", *p);
  420. ret=vfd->vidioc_s_priority(file, fh, *p);
  421. break;
  422. }
  423. /* --- capture ioctls ---------------------------------------- */
  424. case VIDIOC_ENUM_FMT:
  425. {
  426. struct v4l2_fmtdesc *f = arg;
  427. enum v4l2_buf_type type;
  428. unsigned int index;
  429. index = f->index;
  430. type = f->type;
  431. memset(f,0,sizeof(*f));
  432. f->index = index;
  433. f->type = type;
  434. switch (type) {
  435. case V4L2_BUF_TYPE_VIDEO_CAPTURE:
  436. if (vfd->vidioc_enum_fmt_cap)
  437. ret=vfd->vidioc_enum_fmt_cap(file, fh, f);
  438. break;
  439. case V4L2_BUF_TYPE_VIDEO_OVERLAY:
  440. if (vfd->vidioc_enum_fmt_overlay)
  441. ret=vfd->vidioc_enum_fmt_overlay(file, fh, f);
  442. break;
  443. case V4L2_BUF_TYPE_VBI_CAPTURE:
  444. if (vfd->vidioc_enum_fmt_vbi)
  445. ret=vfd->vidioc_enum_fmt_vbi(file, fh, f);
  446. break;
  447. case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
  448. if (vfd->vidioc_enum_fmt_vbi_output)
  449. ret=vfd->vidioc_enum_fmt_vbi_output(file,
  450. fh, f);
  451. break;
  452. case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
  453. if (vfd->vidioc_enum_fmt_vbi_capture)
  454. ret=vfd->vidioc_enum_fmt_vbi_capture(file,
  455. fh, f);
  456. break;
  457. case V4L2_BUF_TYPE_VIDEO_OUTPUT:
  458. if (vfd->vidioc_enum_fmt_video_output)
  459. ret=vfd->vidioc_enum_fmt_video_output(file,
  460. fh, f);
  461. break;
  462. case V4L2_BUF_TYPE_VBI_OUTPUT:
  463. if (vfd->vidioc_enum_fmt_vbi_output)
  464. ret=vfd->vidioc_enum_fmt_vbi_output(file,
  465. fh, f);
  466. break;
  467. case V4L2_BUF_TYPE_PRIVATE:
  468. if (vfd->vidioc_enum_fmt_type_private)
  469. ret=vfd->vidioc_enum_fmt_type_private(file,
  470. fh, f);
  471. break;
  472. }
  473. if (!ret)
  474. dbgarg (cmd, "index=%d, type=%d, flags=%d, "
  475. "description=%s,"
  476. " pixelformat=0x%8x\n",
  477. f->index, f->type, f->flags,
  478. f->description,
  479. f->pixelformat);
  480. break;
  481. }
  482. case VIDIOC_G_FMT:
  483. {
  484. struct v4l2_format *f = (struct v4l2_format *)arg;
  485. enum v4l2_buf_type type=f->type;
  486. memset(&f->fmt.pix,0,sizeof(f->fmt.pix));
  487. f->type=type;
  488. /* FIXME: Should be one dump per type */
  489. dbgarg (cmd, "type=%s\n", prt_names(type,
  490. v4l2_type_names_FIXME));
  491. switch (type) {
  492. case V4L2_BUF_TYPE_VIDEO_CAPTURE:
  493. if (vfd->vidioc_g_fmt_cap)
  494. ret=vfd->vidioc_g_fmt_cap(file, fh, f);
  495. if (!ret)
  496. v4l_print_pix_fmt(vfd,&f->fmt.pix);
  497. break;
  498. case V4L2_BUF_TYPE_VIDEO_OVERLAY:
  499. if (vfd->vidioc_g_fmt_overlay)
  500. ret=vfd->vidioc_g_fmt_overlay(file, fh, f);
  501. break;
  502. case V4L2_BUF_TYPE_VBI_CAPTURE:
  503. if (vfd->vidioc_g_fmt_vbi)
  504. ret=vfd->vidioc_g_fmt_vbi(file, fh, f);
  505. break;
  506. case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
  507. if (vfd->vidioc_g_fmt_vbi_output)
  508. ret=vfd->vidioc_g_fmt_vbi_output(file, fh, f);
  509. break;
  510. case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
  511. if (vfd->vidioc_g_fmt_vbi_capture)
  512. ret=vfd->vidioc_g_fmt_vbi_capture(file, fh, f);
  513. break;
  514. case V4L2_BUF_TYPE_VIDEO_OUTPUT:
  515. if (vfd->vidioc_g_fmt_video_output)
  516. ret=vfd->vidioc_g_fmt_video_output(file,
  517. fh, f);
  518. break;
  519. case V4L2_BUF_TYPE_VBI_OUTPUT:
  520. if (vfd->vidioc_g_fmt_vbi_output)
  521. ret=vfd->vidioc_g_fmt_vbi_output(file, fh, f);
  522. break;
  523. case V4L2_BUF_TYPE_PRIVATE:
  524. if (vfd->vidioc_g_fmt_type_private)
  525. ret=vfd->vidioc_g_fmt_type_private(file,
  526. fh, f);
  527. break;
  528. }
  529. break;
  530. }
  531. case VIDIOC_S_FMT:
  532. {
  533. struct v4l2_format *f = (struct v4l2_format *)arg;
  534. /* FIXME: Should be one dump per type */
  535. dbgarg (cmd, "type=%s\n", prt_names(f->type,
  536. v4l2_type_names_FIXME));
  537. switch (f->type) {
  538. case V4L2_BUF_TYPE_VIDEO_CAPTURE:
  539. v4l_print_pix_fmt(vfd,&f->fmt.pix);
  540. if (vfd->vidioc_s_fmt_cap)
  541. ret=vfd->vidioc_s_fmt_cap(file, fh, f);
  542. break;
  543. case V4L2_BUF_TYPE_VIDEO_OVERLAY:
  544. if (vfd->vidioc_s_fmt_overlay)
  545. ret=vfd->vidioc_s_fmt_overlay(file, fh, f);
  546. break;
  547. case V4L2_BUF_TYPE_VBI_CAPTURE:
  548. if (vfd->vidioc_s_fmt_vbi)
  549. ret=vfd->vidioc_s_fmt_vbi(file, fh, f);
  550. break;
  551. case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
  552. if (vfd->vidioc_s_fmt_vbi_output)
  553. ret=vfd->vidioc_s_fmt_vbi_output(file, fh, f);
  554. break;
  555. case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
  556. if (vfd->vidioc_s_fmt_vbi_capture)
  557. ret=vfd->vidioc_s_fmt_vbi_capture(file, fh, f);
  558. break;
  559. case V4L2_BUF_TYPE_VIDEO_OUTPUT:
  560. if (vfd->vidioc_s_fmt_video_output)
  561. ret=vfd->vidioc_s_fmt_video_output(file,
  562. fh, f);
  563. break;
  564. case V4L2_BUF_TYPE_VBI_OUTPUT:
  565. if (vfd->vidioc_s_fmt_vbi_output)
  566. ret=vfd->vidioc_s_fmt_vbi_output(file,
  567. fh, f);
  568. break;
  569. case V4L2_BUF_TYPE_PRIVATE:
  570. if (vfd->vidioc_s_fmt_type_private)
  571. ret=vfd->vidioc_s_fmt_type_private(file,
  572. fh, f);
  573. break;
  574. }
  575. break;
  576. }
  577. case VIDIOC_TRY_FMT:
  578. {
  579. struct v4l2_format *f = (struct v4l2_format *)arg;
  580. /* FIXME: Should be one dump per type */
  581. dbgarg (cmd, "type=%s\n", prt_names(f->type,
  582. v4l2_type_names_FIXME));
  583. switch (f->type) {
  584. case V4L2_BUF_TYPE_VIDEO_CAPTURE:
  585. if (vfd->vidioc_try_fmt_cap)
  586. ret=vfd->vidioc_try_fmt_cap(file, fh, f);
  587. if (!ret)
  588. v4l_print_pix_fmt(vfd,&f->fmt.pix);
  589. break;
  590. case V4L2_BUF_TYPE_VIDEO_OVERLAY:
  591. if (vfd->vidioc_try_fmt_overlay)
  592. ret=vfd->vidioc_try_fmt_overlay(file, fh, f);
  593. break;
  594. case V4L2_BUF_TYPE_VBI_CAPTURE:
  595. if (vfd->vidioc_try_fmt_vbi)
  596. ret=vfd->vidioc_try_fmt_vbi(file, fh, f);
  597. break;
  598. case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:
  599. if (vfd->vidioc_try_fmt_vbi_output)
  600. ret=vfd->vidioc_try_fmt_vbi_output(file,
  601. fh, f);
  602. break;
  603. case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
  604. if (vfd->vidioc_try_fmt_vbi_capture)
  605. ret=vfd->vidioc_try_fmt_vbi_capture(file,
  606. fh, f);
  607. break;
  608. case V4L2_BUF_TYPE_VIDEO_OUTPUT:
  609. if (vfd->vidioc_try_fmt_video_output)
  610. ret=vfd->vidioc_try_fmt_video_output(file,
  611. fh, f);
  612. break;
  613. case V4L2_BUF_TYPE_VBI_OUTPUT:
  614. if (vfd->vidioc_try_fmt_vbi_output)
  615. ret=vfd->vidioc_try_fmt_vbi_output(file,
  616. fh, f);
  617. break;
  618. case V4L2_BUF_TYPE_PRIVATE:
  619. if (vfd->vidioc_try_fmt_type_private)
  620. ret=vfd->vidioc_try_fmt_type_private(file,
  621. fh, f);
  622. break;
  623. }
  624. break;
  625. }
  626. /* FIXME: Those buf reqs could be handled here,
  627. with some changes on videobuf to allow its header to be included at
  628. videodev2.h or being merged at videodev2.
  629. */
  630. case VIDIOC_REQBUFS:
  631. {
  632. struct v4l2_requestbuffers *p=arg;
  633. if (!vfd->vidioc_reqbufs)
  634. break;
  635. ret = check_fmt (vfd, p->type);
  636. if (ret)
  637. break;
  638. ret=vfd->vidioc_reqbufs(file, fh, p);
  639. dbgarg (cmd, "count=%d, type=%s, memory=%s\n",
  640. p->count,
  641. prt_names(p->type,v4l2_type_names_FIXME),
  642. prt_names(p->memory,v4l2_memory_names));
  643. break;
  644. }
  645. case VIDIOC_QUERYBUF:
  646. {
  647. struct v4l2_buffer *p=arg;
  648. if (!vfd->vidioc_querybuf)
  649. break;
  650. ret = check_fmt (vfd, p->type);
  651. if (ret)
  652. break;
  653. ret=vfd->vidioc_querybuf(file, fh, p);
  654. if (!ret)
  655. dbgbuf(cmd,vfd,p);
  656. break;
  657. }
  658. case VIDIOC_QBUF:
  659. {
  660. struct v4l2_buffer *p=arg;
  661. if (!vfd->vidioc_qbuf)
  662. break;
  663. ret = check_fmt (vfd, p->type);
  664. if (ret)
  665. break;
  666. ret=vfd->vidioc_qbuf(file, fh, p);
  667. if (!ret)
  668. dbgbuf(cmd,vfd,p);
  669. break;
  670. }
  671. case VIDIOC_DQBUF:
  672. {
  673. struct v4l2_buffer *p=arg;
  674. if (!vfd->vidioc_dqbuf)
  675. break;
  676. ret = check_fmt (vfd, p->type);
  677. if (ret)
  678. break;
  679. ret=vfd->vidioc_dqbuf(file, fh, p);
  680. if (!ret)
  681. dbgbuf(cmd,vfd,p);
  682. break;
  683. }
  684. case VIDIOC_OVERLAY:
  685. {
  686. int *i = arg;
  687. if (!vfd->vidioc_overlay)
  688. break;
  689. dbgarg (cmd, "value=%d\n",*i);
  690. ret=vfd->vidioc_overlay(file, fh, *i);
  691. break;
  692. }
  693. #ifdef CONFIG_VIDEO_V4L1_COMPAT
  694. /* --- streaming capture ------------------------------------- */
  695. case VIDIOCGMBUF:
  696. {
  697. struct video_mbuf *p=arg;
  698. memset(p,0,sizeof(p));
  699. if (!vfd->vidiocgmbuf)
  700. break;
  701. ret=vfd->vidiocgmbuf(file, fh, p);
  702. if (!ret)
  703. dbgarg (cmd, "size=%d, frames=%d, offsets=0x%08lx\n",
  704. p->size, p->frames,
  705. (unsigned long)p->offsets);
  706. break;
  707. }
  708. #endif
  709. case VIDIOC_G_FBUF:
  710. {
  711. struct v4l2_framebuffer *p=arg;
  712. if (!vfd->vidioc_g_fbuf)
  713. break;
  714. ret=vfd->vidioc_g_fbuf(file, fh, arg);
  715. if (!ret) {
  716. dbgarg (cmd, "capability=%d, flags=%d, base=0x%08lx\n",
  717. p->capability,p->flags,
  718. (unsigned long)p->base);
  719. v4l_print_pix_fmt (vfd, &p->fmt);
  720. }
  721. break;
  722. }
  723. case VIDIOC_S_FBUF:
  724. {
  725. struct v4l2_framebuffer *p=arg;
  726. if (!vfd->vidioc_s_fbuf)
  727. break;
  728. dbgarg (cmd, "capability=%d, flags=%d, base=0x%08lx\n",
  729. p->capability,p->flags,(unsigned long)p->base);
  730. v4l_print_pix_fmt (vfd, &p->fmt);
  731. ret=vfd->vidioc_s_fbuf(file, fh, arg);
  732. break;
  733. }
  734. case VIDIOC_STREAMON:
  735. {
  736. enum v4l2_buf_type i = *(int *)arg;
  737. if (!vfd->vidioc_streamon)
  738. break;
  739. dbgarg (cmd, "type=%s\n", prt_names(i,v4l2_type_names_FIXME));
  740. ret=vfd->vidioc_streamon(file, fh,i);
  741. break;
  742. }
  743. case VIDIOC_STREAMOFF:
  744. {
  745. enum v4l2_buf_type i = *(int *)arg;
  746. if (!vfd->vidioc_streamoff)
  747. break;
  748. dbgarg (cmd, "type=%s\n", prt_names(i,v4l2_type_names_FIXME));
  749. ret=vfd->vidioc_streamoff(file, fh, i);
  750. break;
  751. }
  752. /* ---------- tv norms ---------- */
  753. case VIDIOC_ENUMSTD:
  754. {
  755. struct v4l2_standard *p = arg;
  756. v4l2_std_id id = vfd->tvnorms,curr_id=0;
  757. unsigned int index = p->index,i;
  758. if (index<0) {
  759. ret=-EINVAL;
  760. break;
  761. }
  762. /* Return norm array on a canonical way */
  763. for (i=0;i<= index && id; i++) {
  764. if ( (id & V4L2_STD_PAL) == V4L2_STD_PAL) {
  765. curr_id = V4L2_STD_PAL;
  766. } else if ( (id & V4L2_STD_PAL_BG) == V4L2_STD_PAL_BG) {
  767. curr_id = V4L2_STD_PAL_BG;
  768. } else if ( (id & V4L2_STD_PAL_DK) == V4L2_STD_PAL_DK) {
  769. curr_id = V4L2_STD_PAL_DK;
  770. } else if ( (id & V4L2_STD_PAL_B) == V4L2_STD_PAL_B) {
  771. curr_id = V4L2_STD_PAL_B;
  772. } else if ( (id & V4L2_STD_PAL_B1) == V4L2_STD_PAL_B1) {
  773. curr_id = V4L2_STD_PAL_B1;
  774. } else if ( (id & V4L2_STD_PAL_G) == V4L2_STD_PAL_G) {
  775. curr_id = V4L2_STD_PAL_G;
  776. } else if ( (id & V4L2_STD_PAL_H) == V4L2_STD_PAL_H) {
  777. curr_id = V4L2_STD_PAL_H;
  778. } else if ( (id & V4L2_STD_PAL_I) == V4L2_STD_PAL_I) {
  779. curr_id = V4L2_STD_PAL_I;
  780. } else if ( (id & V4L2_STD_PAL_D) == V4L2_STD_PAL_D) {
  781. curr_id = V4L2_STD_PAL_D;
  782. } else if ( (id & V4L2_STD_PAL_D1) == V4L2_STD_PAL_D1) {
  783. curr_id = V4L2_STD_PAL_D1;
  784. } else if ( (id & V4L2_STD_PAL_K) == V4L2_STD_PAL_K) {
  785. curr_id = V4L2_STD_PAL_K;
  786. } else if ( (id & V4L2_STD_PAL_M) == V4L2_STD_PAL_M) {
  787. curr_id = V4L2_STD_PAL_M;
  788. } else if ( (id & V4L2_STD_PAL_N) == V4L2_STD_PAL_N) {
  789. curr_id = V4L2_STD_PAL_N;
  790. } else if ( (id & V4L2_STD_PAL_Nc) == V4L2_STD_PAL_Nc) {
  791. curr_id = V4L2_STD_PAL_Nc;
  792. } else if ( (id & V4L2_STD_PAL_60) == V4L2_STD_PAL_60) {
  793. curr_id = V4L2_STD_PAL_60;
  794. } else if ( (id & V4L2_STD_NTSC) == V4L2_STD_NTSC) {
  795. curr_id = V4L2_STD_NTSC;
  796. } else if ( (id & V4L2_STD_NTSC_M) == V4L2_STD_NTSC_M) {
  797. curr_id = V4L2_STD_NTSC_M;
  798. } else if ( (id & V4L2_STD_NTSC_M_JP) == V4L2_STD_NTSC_M_JP) {
  799. curr_id = V4L2_STD_NTSC_M_JP;
  800. } else if ( (id & V4L2_STD_NTSC_443) == V4L2_STD_NTSC_443) {
  801. curr_id = V4L2_STD_NTSC_443;
  802. } else if ( (id & V4L2_STD_NTSC_M_KR) == V4L2_STD_NTSC_M_KR) {
  803. curr_id = V4L2_STD_NTSC_M_KR;
  804. } else if ( (id & V4L2_STD_SECAM) == V4L2_STD_SECAM) {
  805. curr_id = V4L2_STD_SECAM;
  806. } else if ( (id & V4L2_STD_SECAM_DK) == V4L2_STD_SECAM_DK) {
  807. curr_id = V4L2_STD_SECAM_DK;
  808. } else if ( (id & V4L2_STD_SECAM_B) == V4L2_STD_SECAM_B) {
  809. curr_id = V4L2_STD_SECAM_B;
  810. } else if ( (id & V4L2_STD_SECAM_D) == V4L2_STD_SECAM_D) {
  811. curr_id = V4L2_STD_SECAM_D;
  812. } else if ( (id & V4L2_STD_SECAM_G) == V4L2_STD_SECAM_G) {
  813. curr_id = V4L2_STD_SECAM_G;
  814. } else if ( (id & V4L2_STD_SECAM_H) == V4L2_STD_SECAM_H) {
  815. curr_id = V4L2_STD_SECAM_H;
  816. } else if ( (id & V4L2_STD_SECAM_K) == V4L2_STD_SECAM_K) {
  817. curr_id = V4L2_STD_SECAM_K;
  818. } else if ( (id & V4L2_STD_SECAM_K1) == V4L2_STD_SECAM_K1) {
  819. curr_id = V4L2_STD_SECAM_K1;
  820. } else if ( (id & V4L2_STD_SECAM_L) == V4L2_STD_SECAM_L) {
  821. curr_id = V4L2_STD_SECAM_L;
  822. } else if ( (id & V4L2_STD_SECAM_LC) == V4L2_STD_SECAM_LC) {
  823. curr_id = V4L2_STD_SECAM_LC;
  824. } else {
  825. break;
  826. }
  827. id &= ~curr_id;
  828. }
  829. if (i<=index)
  830. return -EINVAL;
  831. v4l2_video_std_construct(p, curr_id,v4l2_norm_to_name(curr_id));
  832. p->index = index;
  833. dbgarg (cmd, "index=%d, id=%Ld, name=%s, fps=%d/%d, "
  834. "framelines=%d\n", p->index,
  835. (unsigned long long)p->id, p->name,
  836. p->frameperiod.numerator,
  837. p->frameperiod.denominator,
  838. p->framelines);
  839. ret=0;
  840. break;
  841. }
  842. case VIDIOC_G_STD:
  843. {
  844. v4l2_std_id *id = arg;
  845. *id = vfd->current_norm;
  846. dbgarg (cmd, "value=%Lu\n", (long long unsigned) *id);
  847. ret=0;
  848. break;
  849. }
  850. case VIDIOC_S_STD:
  851. {
  852. v4l2_std_id *id = arg,norm;
  853. dbgarg (cmd, "value=%Lu\n", (long long unsigned) *id);
  854. norm = (*id) & vfd->tvnorms;
  855. if ( vfd->tvnorms && !norm) /* Check if std is supported */
  856. break;
  857. /* Calls the specific handler */
  858. if (vfd->vidioc_s_std)
  859. ret=vfd->vidioc_s_std(file, fh, &norm);
  860. else
  861. ret=-EINVAL;
  862. /* Updates standard information */
  863. if (ret>=0)
  864. vfd->current_norm=norm;
  865. break;
  866. }
  867. case VIDIOC_QUERYSTD:
  868. {
  869. v4l2_std_id *p=arg;
  870. if (!vfd->vidioc_querystd)
  871. break;
  872. ret=vfd->vidioc_querystd(file, fh, arg);
  873. if (!ret)
  874. dbgarg (cmd, "detected std=%Lu\n",
  875. (unsigned long long)*p);
  876. break;
  877. }
  878. /* ------ input switching ---------- */
  879. /* FIXME: Inputs can be handled inside videodev2 */
  880. case VIDIOC_ENUMINPUT:
  881. {
  882. struct v4l2_input *p=arg;
  883. int i=p->index;
  884. if (!vfd->vidioc_enum_input)
  885. break;
  886. memset(p, 0, sizeof(*p));
  887. p->index=i;
  888. ret=vfd->vidioc_enum_input(file, fh, p);
  889. if (!ret)
  890. dbgarg (cmd, "index=%d, name=%s, type=%d, "
  891. "audioset=%d, "
  892. "tuner=%d, std=%Ld, status=%d\n",
  893. p->index,p->name,p->type,p->audioset,
  894. p->tuner,
  895. (unsigned long long)p->std,
  896. p->status);
  897. break;
  898. }
  899. case VIDIOC_G_INPUT:
  900. {
  901. unsigned int *i = arg;
  902. if (!vfd->vidioc_g_input)
  903. break;
  904. ret=vfd->vidioc_g_input(file, fh, i);
  905. if (!ret)
  906. dbgarg (cmd, "value=%d\n",*i);
  907. break;
  908. }
  909. case VIDIOC_S_INPUT:
  910. {
  911. unsigned int *i = arg;
  912. if (!vfd->vidioc_s_input)
  913. break;
  914. dbgarg (cmd, "value=%d\n",*i);
  915. ret=vfd->vidioc_s_input(file, fh, *i);
  916. break;
  917. }
  918. /* ------ output switching ---------- */
  919. case VIDIOC_G_OUTPUT:
  920. {
  921. unsigned int *i = arg;
  922. if (!vfd->vidioc_g_output)
  923. break;
  924. ret=vfd->vidioc_g_output(file, fh, i);
  925. if (!ret)
  926. dbgarg (cmd, "value=%d\n",*i);
  927. break;
  928. }
  929. case VIDIOC_S_OUTPUT:
  930. {
  931. unsigned int *i = arg;
  932. if (!vfd->vidioc_s_output)
  933. break;
  934. dbgarg (cmd, "value=%d\n",*i);
  935. ret=vfd->vidioc_s_output(file, fh, *i);
  936. break;
  937. }
  938. /* --- controls ---------------------------------------------- */
  939. case VIDIOC_QUERYCTRL:
  940. {
  941. struct v4l2_queryctrl *p=arg;
  942. if (!vfd->vidioc_queryctrl)
  943. break;
  944. ret=vfd->vidioc_queryctrl(file, fh, p);
  945. if (!ret)
  946. dbgarg (cmd, "id=%d, type=%d, name=%s, "
  947. "min/max=%d/%d,"
  948. " step=%d, default=%d, flags=0x%08x\n",
  949. p->id,p->type,p->name,p->minimum,
  950. p->maximum,p->step,p->default_value,
  951. p->flags);
  952. break;
  953. }
  954. case VIDIOC_G_CTRL:
  955. {
  956. struct v4l2_control *p = arg;
  957. if (!vfd->vidioc_g_ctrl)
  958. break;
  959. dbgarg(cmd, "Enum for index=%d\n", p->id);
  960. ret=vfd->vidioc_g_ctrl(file, fh, p);
  961. if (!ret)
  962. dbgarg2 ( "id=%d, value=%d\n", p->id, p->value);
  963. break;
  964. }
  965. case VIDIOC_S_CTRL:
  966. {
  967. struct v4l2_control *p = arg;
  968. if (!vfd->vidioc_s_ctrl)
  969. break;
  970. dbgarg (cmd, "id=%d, value=%d\n", p->id, p->value);
  971. ret=vfd->vidioc_s_ctrl(file, fh, p);
  972. break;
  973. }
  974. case VIDIOC_G_EXT_CTRLS:
  975. {
  976. struct v4l2_ext_controls *p = arg;
  977. if (vfd->vidioc_g_ext_ctrls) {
  978. dbgarg(cmd, "count=%d\n", p->count);
  979. ret=vfd->vidioc_g_ext_ctrls(file, fh, p);
  980. }
  981. break;
  982. }
  983. case VIDIOC_S_EXT_CTRLS:
  984. {
  985. struct v4l2_ext_controls *p = arg;
  986. if (vfd->vidioc_s_ext_ctrls) {
  987. dbgarg(cmd, "count=%d\n", p->count);
  988. ret=vfd->vidioc_s_ext_ctrls(file, fh, p);
  989. }
  990. break;
  991. }
  992. case VIDIOC_TRY_EXT_CTRLS:
  993. {
  994. struct v4l2_ext_controls *p = arg;
  995. if (vfd->vidioc_try_ext_ctrls) {
  996. dbgarg(cmd, "count=%d\n", p->count);
  997. ret=vfd->vidioc_try_ext_ctrls(file, fh, p);
  998. }
  999. break;
  1000. }
  1001. case VIDIOC_QUERYMENU:
  1002. {
  1003. struct v4l2_querymenu *p=arg;
  1004. if (!vfd->vidioc_querymenu)
  1005. break;
  1006. ret=vfd->vidioc_querymenu(file, fh, p);
  1007. if (!ret)
  1008. dbgarg (cmd, "id=%d, index=%d, name=%s\n",
  1009. p->id,p->index,p->name);
  1010. break;
  1011. }
  1012. /* --- audio ---------------------------------------------- */
  1013. case VIDIOC_ENUMAUDIO:
  1014. {
  1015. struct v4l2_audio *p=arg;
  1016. if (!vfd->vidioc_enumaudio)
  1017. break;
  1018. dbgarg(cmd, "Enum for index=%d\n", p->index);
  1019. ret=vfd->vidioc_enumaudio(file, fh, p);
  1020. if (!ret)
  1021. dbgarg2("index=%d, name=%s, capability=%d, "
  1022. "mode=%d\n",p->index,p->name,
  1023. p->capability, p->mode);
  1024. break;
  1025. }
  1026. case VIDIOC_G_AUDIO:
  1027. {
  1028. struct v4l2_audio *p=arg;
  1029. __u32 index=p->index;
  1030. if (!vfd->vidioc_g_audio)
  1031. break;
  1032. memset(p,0,sizeof(*p));
  1033. p->index=index;
  1034. dbgarg(cmd, "Get for index=%d\n", p->index);
  1035. ret=vfd->vidioc_g_audio(file, fh, p);
  1036. if (!ret)
  1037. dbgarg2("index=%d, name=%s, capability=%d, "
  1038. "mode=%d\n",p->index,
  1039. p->name,p->capability, p->mode);
  1040. break;
  1041. }
  1042. case VIDIOC_S_AUDIO:
  1043. {
  1044. struct v4l2_audio *p=arg;
  1045. if (!vfd->vidioc_s_audio)
  1046. break;
  1047. dbgarg(cmd, "index=%d, name=%s, capability=%d, "
  1048. "mode=%d\n", p->index, p->name,
  1049. p->capability, p->mode);
  1050. ret=vfd->vidioc_s_audio(file, fh, p);
  1051. break;
  1052. }
  1053. case VIDIOC_ENUMAUDOUT:
  1054. {
  1055. struct v4l2_audioout *p=arg;
  1056. if (!vfd->vidioc_enumaudout)
  1057. break;
  1058. dbgarg(cmd, "Enum for index=%d\n", p->index);
  1059. ret=vfd->vidioc_enumaudout(file, fh, p);
  1060. if (!ret)
  1061. dbgarg2("index=%d, name=%s, capability=%d, "
  1062. "mode=%d\n", p->index, p->name,
  1063. p->capability,p->mode);
  1064. break;
  1065. }
  1066. case VIDIOC_G_AUDOUT:
  1067. {
  1068. struct v4l2_audioout *p=arg;
  1069. if (!vfd->vidioc_g_audout)
  1070. break;
  1071. dbgarg(cmd, "Enum for index=%d\n", p->index);
  1072. ret=vfd->vidioc_g_audout(file, fh, p);
  1073. if (!ret)
  1074. dbgarg2("index=%d, name=%s, capability=%d, "
  1075. "mode=%d\n", p->index, p->name,
  1076. p->capability,p->mode);
  1077. break;
  1078. }
  1079. case VIDIOC_S_AUDOUT:
  1080. {
  1081. struct v4l2_audioout *p=arg;
  1082. if (!vfd->vidioc_s_audout)
  1083. break;
  1084. dbgarg(cmd, "index=%d, name=%s, capability=%d, "
  1085. "mode=%d\n", p->index, p->name,
  1086. p->capability,p->mode);
  1087. ret=vfd->vidioc_s_audout(file, fh, p);
  1088. break;
  1089. }
  1090. case VIDIOC_G_MODULATOR:
  1091. {
  1092. struct v4l2_modulator *p=arg;
  1093. if (!vfd->vidioc_g_modulator)
  1094. break;
  1095. ret=vfd->vidioc_g_modulator(file, fh, p);
  1096. if (!ret)
  1097. dbgarg(cmd, "index=%d, name=%s, "
  1098. "capability=%d, rangelow=%d,"
  1099. " rangehigh=%d, txsubchans=%d\n",
  1100. p->index, p->name,p->capability,
  1101. p->rangelow, p->rangehigh,
  1102. p->txsubchans);
  1103. break;
  1104. }
  1105. case VIDIOC_S_MODULATOR:
  1106. {
  1107. struct v4l2_modulator *p=arg;
  1108. if (!vfd->vidioc_s_modulator)
  1109. break;
  1110. dbgarg(cmd, "index=%d, name=%s, capability=%d, "
  1111. "rangelow=%d, rangehigh=%d, txsubchans=%d\n",
  1112. p->index, p->name,p->capability,p->rangelow,
  1113. p->rangehigh,p->txsubchans);
  1114. ret=vfd->vidioc_s_modulator(file, fh, p);
  1115. break;
  1116. }
  1117. case VIDIOC_G_CROP:
  1118. {
  1119. struct v4l2_crop *p=arg;
  1120. if (!vfd->vidioc_g_crop)
  1121. break;
  1122. ret=vfd->vidioc_g_crop(file, fh, p);
  1123. if (!ret) {
  1124. dbgarg(cmd, "type=%d\n", p->type);
  1125. dbgrect(vfd, "", &p->c);
  1126. }
  1127. break;
  1128. }
  1129. case VIDIOC_S_CROP:
  1130. {
  1131. struct v4l2_crop *p=arg;
  1132. if (!vfd->vidioc_s_crop)
  1133. break;
  1134. dbgarg(cmd, "type=%d\n", p->type);
  1135. dbgrect(vfd, "", &p->c);
  1136. ret=vfd->vidioc_s_crop(file, fh, p);
  1137. break;
  1138. }
  1139. case VIDIOC_CROPCAP:
  1140. {
  1141. struct v4l2_cropcap *p=arg;
  1142. /*FIXME: Should also show v4l2_fract pixelaspect */
  1143. if (!vfd->vidioc_cropcap)
  1144. break;
  1145. dbgarg(cmd, "type=%d\n", p->type);
  1146. dbgrect(vfd, "bounds ", &p->bounds);
  1147. dbgrect(vfd, "defrect ", &p->defrect);
  1148. ret=vfd->vidioc_cropcap(file, fh, p);
  1149. break;
  1150. }
  1151. case VIDIOC_G_MPEGCOMP:
  1152. {
  1153. struct v4l2_mpeg_compression *p=arg;
  1154. /*FIXME: Several fields not shown */
  1155. if (!vfd->vidioc_g_mpegcomp)
  1156. break;
  1157. ret=vfd->vidioc_g_mpegcomp(file, fh, p);
  1158. if (!ret)
  1159. dbgarg (cmd, "ts_pid_pmt=%d, ts_pid_audio=%d,"
  1160. " ts_pid_video=%d, ts_pid_pcr=%d, "
  1161. "ps_size=%d, au_sample_rate=%d, "
  1162. "au_pesid=%c, vi_frame_rate=%d, "
  1163. "vi_frames_per_gop=%d, "
  1164. "vi_bframes_count=%d, vi_pesid=%c\n",
  1165. p->ts_pid_pmt,p->ts_pid_audio,
  1166. p->ts_pid_video,p->ts_pid_pcr,
  1167. p->ps_size, p->au_sample_rate,
  1168. p->au_pesid, p->vi_frame_rate,
  1169. p->vi_frames_per_gop,
  1170. p->vi_bframes_count, p->vi_pesid);
  1171. break;
  1172. }
  1173. case VIDIOC_S_MPEGCOMP:
  1174. {
  1175. struct v4l2_mpeg_compression *p=arg;
  1176. /*FIXME: Several fields not shown */
  1177. if (!vfd->vidioc_s_mpegcomp)
  1178. break;
  1179. dbgarg (cmd, "ts_pid_pmt=%d, ts_pid_audio=%d, "
  1180. "ts_pid_video=%d, ts_pid_pcr=%d, ps_size=%d, "
  1181. "au_sample_rate=%d, au_pesid=%c, "
  1182. "vi_frame_rate=%d, vi_frames_per_gop=%d, "
  1183. "vi_bframes_count=%d, vi_pesid=%c\n",
  1184. p->ts_pid_pmt,p->ts_pid_audio, p->ts_pid_video,
  1185. p->ts_pid_pcr, p->ps_size, p->au_sample_rate,
  1186. p->au_pesid, p->vi_frame_rate,
  1187. p->vi_frames_per_gop, p->vi_bframes_count,
  1188. p->vi_pesid);
  1189. ret=vfd->vidioc_s_mpegcomp(file, fh, p);
  1190. break;
  1191. }
  1192. case VIDIOC_G_JPEGCOMP:
  1193. {
  1194. struct v4l2_jpegcompression *p=arg;
  1195. if (!vfd->vidioc_g_jpegcomp)
  1196. break;
  1197. ret=vfd->vidioc_g_jpegcomp(file, fh, p);
  1198. if (!ret)
  1199. dbgarg (cmd, "quality=%d, APPn=%d, "
  1200. "APP_len=%d, COM_len=%d, "
  1201. "jpeg_markers=%d\n",
  1202. p->quality,p->APPn,p->APP_len,
  1203. p->COM_len,p->jpeg_markers);
  1204. break;
  1205. }
  1206. case VIDIOC_S_JPEGCOMP:
  1207. {
  1208. struct v4l2_jpegcompression *p=arg;
  1209. if (!vfd->vidioc_g_jpegcomp)
  1210. break;
  1211. dbgarg (cmd, "quality=%d, APPn=%d, APP_len=%d, "
  1212. "COM_len=%d, jpeg_markers=%d\n",
  1213. p->quality,p->APPn,p->APP_len,
  1214. p->COM_len,p->jpeg_markers);
  1215. ret=vfd->vidioc_s_jpegcomp(file, fh, p);
  1216. break;
  1217. }
  1218. case VIDIOC_G_PARM:
  1219. {
  1220. struct v4l2_streamparm *p=arg;
  1221. if (vfd->vidioc_g_parm) {
  1222. ret=vfd->vidioc_g_parm(file, fh, p);
  1223. } else {
  1224. struct v4l2_standard s;
  1225. if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
  1226. return -EINVAL;
  1227. v4l2_video_std_construct(&s, vfd->current_norm,
  1228. v4l2_norm_to_name(vfd->current_norm));
  1229. memset(p,0,sizeof(*p));
  1230. p->parm.capture.timeperframe = s.frameperiod;
  1231. ret=0;
  1232. }
  1233. dbgarg (cmd, "type=%d\n", p->type);
  1234. break;
  1235. }
  1236. case VIDIOC_S_PARM:
  1237. {
  1238. struct v4l2_streamparm *p=arg;
  1239. if (!vfd->vidioc_s_parm)
  1240. break;
  1241. dbgarg (cmd, "type=%d\n", p->type);
  1242. ret=vfd->vidioc_s_parm(file, fh, p);
  1243. break;
  1244. }
  1245. case VIDIOC_G_TUNER:
  1246. {
  1247. struct v4l2_tuner *p=arg;
  1248. __u32 index=p->index;
  1249. if (!vfd->vidioc_g_tuner)
  1250. break;
  1251. memset(p,0,sizeof(*p));
  1252. p->index=index;
  1253. ret=vfd->vidioc_g_tuner(file, fh, p);
  1254. if (!ret)
  1255. dbgarg (cmd, "index=%d, name=%s, type=%d, "
  1256. "capability=%d, rangelow=%d, "
  1257. "rangehigh=%d, signal=%d, afc=%d, "
  1258. "rxsubchans=%d, audmode=%d\n",
  1259. p->index, p->name, p->type,
  1260. p->capability, p->rangelow,
  1261. p->rangehigh, p->rxsubchans,
  1262. p->audmode, p->signal, p->afc);
  1263. break;
  1264. }
  1265. case VIDIOC_S_TUNER:
  1266. {
  1267. struct v4l2_tuner *p=arg;
  1268. if (!vfd->vidioc_s_tuner)
  1269. break;
  1270. dbgarg (cmd, "index=%d, name=%s, type=%d, "
  1271. "capability=%d, rangelow=%d, rangehigh=%d, "
  1272. "signal=%d, afc=%d, rxsubchans=%d, "
  1273. "audmode=%d\n",p->index, p->name, p->type,
  1274. p->capability, p->rangelow,p->rangehigh,
  1275. p->rxsubchans, p->audmode, p->signal,
  1276. p->afc);
  1277. ret=vfd->vidioc_s_tuner(file, fh, p);
  1278. break;
  1279. }
  1280. case VIDIOC_G_FREQUENCY:
  1281. {
  1282. struct v4l2_frequency *p=arg;
  1283. if (!vfd->vidioc_g_frequency)
  1284. break;
  1285. memset(p,0,sizeof(*p));
  1286. ret=vfd->vidioc_g_frequency(file, fh, p);
  1287. if (!ret)
  1288. dbgarg (cmd, "tuner=%d, type=%d, frequency=%d\n",
  1289. p->tuner,p->type,p->frequency);
  1290. break;
  1291. }
  1292. case VIDIOC_S_FREQUENCY:
  1293. {
  1294. struct v4l2_frequency *p=arg;
  1295. if (!vfd->vidioc_s_frequency)
  1296. break;
  1297. dbgarg (cmd, "tuner=%d, type=%d, frequency=%d\n",
  1298. p->tuner,p->type,p->frequency);
  1299. ret=vfd->vidioc_s_frequency(file, fh, p);
  1300. break;
  1301. }
  1302. case VIDIOC_G_SLICED_VBI_CAP:
  1303. {
  1304. struct v4l2_sliced_vbi_cap *p=arg;
  1305. if (!vfd->vidioc_g_sliced_vbi_cap)
  1306. break;
  1307. ret=vfd->vidioc_g_sliced_vbi_cap(file, fh, p);
  1308. if (!ret)
  1309. dbgarg (cmd, "service_set=%d\n", p->service_set);
  1310. break;
  1311. }
  1312. case VIDIOC_LOG_STATUS:
  1313. {
  1314. if (!vfd->vidioc_log_status)
  1315. break;
  1316. ret=vfd->vidioc_log_status(file, fh);
  1317. break;
  1318. }
  1319. } /* switch */
  1320. if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) {
  1321. if (ret<0) {
  1322. printk ("%s: err:\n", vfd->name);
  1323. v4l_print_ioctl(vfd->name, cmd);
  1324. }
  1325. }
  1326. return ret;
  1327. }
  1328. int video_ioctl2 (struct inode *inode, struct file *file,
  1329. unsigned int cmd, unsigned long arg)
  1330. {
  1331. char sbuf[128];
  1332. void *mbuf = NULL;
  1333. void *parg = NULL;
  1334. int err = -EINVAL;
  1335. int is_ext_ctrl;
  1336. size_t ctrls_size = 0;
  1337. void __user *user_ptr = NULL;
  1338. #ifdef __OLD_VIDIOC_
  1339. cmd = video_fix_command(cmd);
  1340. #endif
  1341. is_ext_ctrl = (cmd == VIDIOC_S_EXT_CTRLS || cmd == VIDIOC_G_EXT_CTRLS ||
  1342. cmd == VIDIOC_TRY_EXT_CTRLS);
  1343. /* Copy arguments into temp kernel buffer */
  1344. switch (_IOC_DIR(cmd)) {
  1345. case _IOC_NONE:
  1346. parg = NULL;
  1347. break;
  1348. case _IOC_READ:
  1349. case _IOC_WRITE:
  1350. case (_IOC_WRITE | _IOC_READ):
  1351. if (_IOC_SIZE(cmd) <= sizeof(sbuf)) {
  1352. parg = sbuf;
  1353. } else {
  1354. /* too big to allocate from stack */
  1355. mbuf = kmalloc(_IOC_SIZE(cmd),GFP_KERNEL);
  1356. if (NULL == mbuf)
  1357. return -ENOMEM;
  1358. parg = mbuf;
  1359. }
  1360. err = -EFAULT;
  1361. if (_IOC_DIR(cmd) & _IOC_WRITE)
  1362. if (copy_from_user(parg, (void __user *)arg, _IOC_SIZE(cmd)))
  1363. goto out;
  1364. break;
  1365. }
  1366. if (is_ext_ctrl) {
  1367. struct v4l2_ext_controls *p = parg;
  1368. /* In case of an error, tell the caller that it wasn't
  1369. a specific control that caused it. */
  1370. p->error_idx = p->count;
  1371. user_ptr = (void __user *)p->controls;
  1372. if (p->count) {
  1373. ctrls_size = sizeof(struct v4l2_ext_control) * p->count;
  1374. /* Note: v4l2_ext_controls fits in sbuf[] so mbuf is still NULL. */
  1375. mbuf = kmalloc(ctrls_size, GFP_KERNEL);
  1376. err = -ENOMEM;
  1377. if (NULL == mbuf)
  1378. goto out_ext_ctrl;
  1379. err = -EFAULT;
  1380. if (copy_from_user(mbuf, user_ptr, ctrls_size))
  1381. goto out_ext_ctrl;
  1382. p->controls = mbuf;
  1383. }
  1384. }
  1385. /* Handles IOCTL */
  1386. err = __video_do_ioctl(inode, file, cmd, parg);
  1387. if (err == -ENOIOCTLCMD)
  1388. err = -EINVAL;
  1389. if (is_ext_ctrl) {
  1390. struct v4l2_ext_controls *p = parg;
  1391. p->controls = (void *)user_ptr;
  1392. if (p->count && err == 0 && copy_to_user(user_ptr, mbuf, ctrls_size))
  1393. err = -EFAULT;
  1394. goto out_ext_ctrl;
  1395. }
  1396. if (err < 0)
  1397. goto out;
  1398. out_ext_ctrl:
  1399. /* Copy results into user buffer */
  1400. switch (_IOC_DIR(cmd))
  1401. {
  1402. case _IOC_READ:
  1403. case (_IOC_WRITE | _IOC_READ):
  1404. if (copy_to_user((void __user *)arg, parg, _IOC_SIZE(cmd)))
  1405. err = -EFAULT;
  1406. break;
  1407. }
  1408. out:
  1409. kfree(mbuf);
  1410. return err;
  1411. }
  1412. static struct file_operations video_fops;
  1413. /**
  1414. * video_register_device - register video4linux devices
  1415. * @vfd: video device structure we want to register
  1416. * @type: type of device to register
  1417. * @nr: which device number (0 == /dev/video0, 1 == /dev/video1, ...
  1418. * -1 == first free)
  1419. *
  1420. * The registration code assigns minor numbers based on the type
  1421. * requested. -ENFILE is returned in all the device slots for this
  1422. * category are full. If not then the minor field is set and the
  1423. * driver initialize function is called (if non %NULL).
  1424. *
  1425. * Zero is returned on success.
  1426. *
  1427. * Valid types are
  1428. *
  1429. * %VFL_TYPE_GRABBER - A frame grabber
  1430. *
  1431. * %VFL_TYPE_VTX - A teletext device
  1432. *
  1433. * %VFL_TYPE_VBI - Vertical blank data (undecoded)
  1434. *
  1435. * %VFL_TYPE_RADIO - A radio card
  1436. */
  1437. int video_register_device(struct video_device *vfd, int type, int nr)
  1438. {
  1439. int i=0;
  1440. int base;
  1441. int end;
  1442. int ret;
  1443. char *name_base;
  1444. switch(type)
  1445. {
  1446. case VFL_TYPE_GRABBER:
  1447. base=MINOR_VFL_TYPE_GRABBER_MIN;
  1448. end=MINOR_VFL_TYPE_GRABBER_MAX+1;
  1449. name_base = "video";
  1450. break;
  1451. case VFL_TYPE_VTX:
  1452. base=MINOR_VFL_TYPE_VTX_MIN;
  1453. end=MINOR_VFL_TYPE_VTX_MAX+1;
  1454. name_base = "vtx";
  1455. break;
  1456. case VFL_TYPE_VBI:
  1457. base=MINOR_VFL_TYPE_VBI_MIN;
  1458. end=MINOR_VFL_TYPE_VBI_MAX+1;
  1459. name_base = "vbi";
  1460. break;
  1461. case VFL_TYPE_RADIO:
  1462. base=MINOR_VFL_TYPE_RADIO_MIN;
  1463. end=MINOR_VFL_TYPE_RADIO_MAX+1;
  1464. name_base = "radio";
  1465. break;
  1466. default:
  1467. printk(KERN_ERR "%s called with unknown type: %d\n",
  1468. __FUNCTION__, type);
  1469. return -1;
  1470. }
  1471. /* pick a minor number */
  1472. mutex_lock(&videodev_lock);
  1473. if (nr >= 0 && nr < end-base) {
  1474. /* use the one the driver asked for */
  1475. i = base+nr;
  1476. if (NULL != video_device[i]) {
  1477. mutex_unlock(&videodev_lock);
  1478. return -ENFILE;
  1479. }
  1480. } else {
  1481. /* use first free */
  1482. for(i=base;i<end;i++)
  1483. if (NULL == video_device[i])
  1484. break;
  1485. if (i == end) {
  1486. mutex_unlock(&videodev_lock);
  1487. return -ENFILE;
  1488. }
  1489. }
  1490. video_device[i]=vfd;
  1491. vfd->minor=i;
  1492. mutex_unlock(&videodev_lock);
  1493. mutex_init(&vfd->lock);
  1494. /* sysfs class */
  1495. memset(&vfd->class_dev, 0x00, sizeof(vfd->class_dev));
  1496. if (vfd->dev)
  1497. vfd->class_dev.dev = vfd->dev;
  1498. vfd->class_dev.class = &video_class;
  1499. vfd->class_dev.devt = MKDEV(VIDEO_MAJOR, vfd->minor);
  1500. sprintf(vfd->class_dev.class_id, "%s%d", name_base, i - base);
  1501. ret = class_device_register(&vfd->class_dev);
  1502. if (ret < 0) {
  1503. printk(KERN_ERR "%s: class_device_register failed\n",
  1504. __FUNCTION__);
  1505. goto fail_minor;
  1506. }
  1507. ret = class_device_create_file(&vfd->class_dev, &class_device_attr_name);
  1508. if (ret < 0) {
  1509. printk(KERN_ERR "%s: class_device_create_file 'name' failed\n",
  1510. __FUNCTION__);
  1511. goto fail_classdev;
  1512. }
  1513. #if 1
  1514. /* needed until all drivers are fixed */
  1515. if (!vfd->release)
  1516. printk(KERN_WARNING "videodev: \"%s\" has no release callback. "
  1517. "Please fix your driver for proper sysfs support, see "
  1518. "http://lwn.net/Articles/36850/\n", vfd->name);
  1519. #endif
  1520. return 0;
  1521. fail_classdev:
  1522. class_device_unregister(&vfd->class_dev);
  1523. fail_minor:
  1524. mutex_lock(&videodev_lock);
  1525. video_device[vfd->minor] = NULL;
  1526. vfd->minor = -1;
  1527. mutex_unlock(&videodev_lock);
  1528. return ret;
  1529. }
  1530. /**
  1531. * video_unregister_device - unregister a video4linux device
  1532. * @vfd: the device to unregister
  1533. *
  1534. * This unregisters the passed device and deassigns the minor
  1535. * number. Future open calls will be met with errors.
  1536. */
  1537. void video_unregister_device(struct video_device *vfd)
  1538. {
  1539. mutex_lock(&videodev_lock);
  1540. if(video_device[vfd->minor]!=vfd)
  1541. panic("videodev: bad unregister");
  1542. video_device[vfd->minor]=NULL;
  1543. class_device_unregister(&vfd->class_dev);
  1544. mutex_unlock(&videodev_lock);
  1545. }
  1546. /*
  1547. * Video fs operations
  1548. */
  1549. static struct file_operations video_fops=
  1550. {
  1551. .owner = THIS_MODULE,
  1552. .llseek = no_llseek,
  1553. .open = video_open,
  1554. };
  1555. /*
  1556. * Initialise video for linux
  1557. */
  1558. static int __init videodev_init(void)
  1559. {
  1560. int ret;
  1561. printk(KERN_INFO "Linux video capture interface: v2.00\n");
  1562. if (register_chrdev(VIDEO_MAJOR, VIDEO_NAME, &video_fops)) {
  1563. printk(KERN_WARNING "video_dev: unable to get major %d\n", VIDEO_MAJOR);
  1564. return -EIO;
  1565. }
  1566. ret = class_register(&video_class);
  1567. if (ret < 0) {
  1568. unregister_chrdev(VIDEO_MAJOR, VIDEO_NAME);
  1569. printk(KERN_WARNING "video_dev: class_register failed\n");
  1570. return -EIO;
  1571. }
  1572. return 0;
  1573. }
  1574. static void __exit videodev_exit(void)
  1575. {
  1576. class_unregister(&video_class);
  1577. unregister_chrdev(VIDEO_MAJOR, VIDEO_NAME);
  1578. }
  1579. module_init(videodev_init)
  1580. module_exit(videodev_exit)
  1581. EXPORT_SYMBOL(video_register_device);
  1582. EXPORT_SYMBOL(video_unregister_device);
  1583. EXPORT_SYMBOL(video_devdata);
  1584. EXPORT_SYMBOL(video_usercopy);
  1585. EXPORT_SYMBOL(video_exclusive_open);
  1586. EXPORT_SYMBOL(video_exclusive_release);
  1587. EXPORT_SYMBOL(video_ioctl2);
  1588. EXPORT_SYMBOL(video_device_alloc);
  1589. EXPORT_SYMBOL(video_device_release);
  1590. MODULE_AUTHOR("Alan Cox, Mauro Carvalho Chehab <mchehab@infradead.org>");
  1591. MODULE_DESCRIPTION("Device registrar for Video4Linux drivers v2");
  1592. MODULE_LICENSE("GPL");
  1593. /*
  1594. * Local variables:
  1595. * c-basic-offset: 8
  1596. * End:
  1597. */