pvrusb2-v4l2.c 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219
  1. /*
  2. *
  3. * $Id$
  4. *
  5. * Copyright (C) 2005 Mike Isely <isely@pobox.com>
  6. * Copyright (C) 2004 Aurelien Alleaume <slts@free.fr>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. *
  21. */
  22. #include <linux/kernel.h>
  23. #include <linux/version.h>
  24. #include "pvrusb2-context.h"
  25. #include "pvrusb2-hdw.h"
  26. #include "pvrusb2.h"
  27. #include "pvrusb2-debug.h"
  28. #include "pvrusb2-v4l2.h"
  29. #include "pvrusb2-ioread.h"
  30. #include <linux/videodev2.h>
  31. #include <media/v4l2-dev.h>
  32. #include <media/v4l2-common.h>
  33. struct pvr2_v4l2_dev;
  34. struct pvr2_v4l2_fh;
  35. struct pvr2_v4l2;
  36. struct pvr2_v4l2_dev {
  37. struct video_device devbase; /* MUST be first! */
  38. struct pvr2_v4l2 *v4lp;
  39. struct pvr2_context_stream *stream;
  40. /* Information about this device: */
  41. enum pvr2_config config; /* Expected stream format */
  42. int v4l_type; /* V4L defined type for this device node */
  43. enum pvr2_v4l_type minor_type; /* pvr2-understood minor device type */
  44. };
  45. struct pvr2_v4l2_fh {
  46. struct pvr2_channel channel;
  47. struct pvr2_v4l2_dev *dev_info;
  48. enum v4l2_priority prio;
  49. struct pvr2_ioread *rhp;
  50. struct file *file;
  51. struct pvr2_v4l2 *vhead;
  52. struct pvr2_v4l2_fh *vnext;
  53. struct pvr2_v4l2_fh *vprev;
  54. wait_queue_head_t wait_data;
  55. int fw_mode_flag;
  56. int prev_input_val;
  57. };
  58. struct pvr2_v4l2 {
  59. struct pvr2_channel channel;
  60. struct pvr2_v4l2_fh *vfirst;
  61. struct pvr2_v4l2_fh *vlast;
  62. struct v4l2_prio_state prio;
  63. /* streams - Note that these must be separately, individually,
  64. * allocated pointers. This is because the v4l core is going to
  65. * manage their deletion - separately, individually... */
  66. struct pvr2_v4l2_dev *dev_video;
  67. struct pvr2_v4l2_dev *dev_radio;
  68. };
  69. static int video_nr[PVR_NUM] = {[0 ... PVR_NUM-1] = -1};
  70. module_param_array(video_nr, int, NULL, 0444);
  71. MODULE_PARM_DESC(video_nr, "Offset for device's video dev minor");
  72. static int radio_nr[PVR_NUM] = {[0 ... PVR_NUM-1] = -1};
  73. module_param_array(radio_nr, int, NULL, 0444);
  74. MODULE_PARM_DESC(radio_nr, "Offset for device's radio dev minor");
  75. static int vbi_nr[PVR_NUM] = {[0 ... PVR_NUM-1] = -1};
  76. module_param_array(vbi_nr, int, NULL, 0444);
  77. MODULE_PARM_DESC(vbi_nr, "Offset for device's vbi dev minor");
  78. static struct v4l2_capability pvr_capability ={
  79. .driver = "pvrusb2",
  80. .card = "Hauppauge WinTV pvr-usb2",
  81. .bus_info = "usb",
  82. .version = KERNEL_VERSION(0,8,0),
  83. .capabilities = (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VBI_CAPTURE |
  84. V4L2_CAP_TUNER | V4L2_CAP_AUDIO | V4L2_CAP_RADIO |
  85. V4L2_CAP_READWRITE),
  86. .reserved = {0,0,0,0}
  87. };
  88. static struct v4l2_tuner pvr_v4l2_tuners[]= {
  89. {
  90. .index = 0,
  91. .name = "TV Tuner",
  92. .type = V4L2_TUNER_ANALOG_TV,
  93. .capability = (V4L2_TUNER_CAP_NORM |
  94. V4L2_TUNER_CAP_STEREO |
  95. V4L2_TUNER_CAP_LANG1 |
  96. V4L2_TUNER_CAP_LANG2),
  97. .rangelow = 0,
  98. .rangehigh = 0,
  99. .rxsubchans = V4L2_TUNER_SUB_STEREO,
  100. .audmode = V4L2_TUNER_MODE_STEREO,
  101. .signal = 0,
  102. .afc = 0,
  103. .reserved = {0,0,0,0}
  104. }
  105. };
  106. static struct v4l2_fmtdesc pvr_fmtdesc [] = {
  107. {
  108. .index = 0,
  109. .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
  110. .flags = V4L2_FMT_FLAG_COMPRESSED,
  111. .description = "MPEG1/2",
  112. // This should really be V4L2_PIX_FMT_MPEG, but xawtv
  113. // breaks when I do that.
  114. .pixelformat = 0, // V4L2_PIX_FMT_MPEG,
  115. .reserved = { 0, 0, 0, 0 }
  116. }
  117. };
  118. #define PVR_FORMAT_PIX 0
  119. #define PVR_FORMAT_VBI 1
  120. static struct v4l2_format pvr_format [] = {
  121. [PVR_FORMAT_PIX] = {
  122. .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
  123. .fmt = {
  124. .pix = {
  125. .width = 720,
  126. .height = 576,
  127. // This should really be V4L2_PIX_FMT_MPEG,
  128. // but xawtv breaks when I do that.
  129. .pixelformat = 0, // V4L2_PIX_FMT_MPEG,
  130. .field = V4L2_FIELD_INTERLACED,
  131. .bytesperline = 0, // doesn't make sense
  132. // here
  133. //FIXME : Don't know what to put here...
  134. .sizeimage = (32*1024),
  135. .colorspace = 0, // doesn't make sense here
  136. .priv = 0
  137. }
  138. }
  139. },
  140. [PVR_FORMAT_VBI] = {
  141. .type = V4L2_BUF_TYPE_VBI_CAPTURE,
  142. .fmt = {
  143. .vbi = {
  144. .sampling_rate = 27000000,
  145. .offset = 248,
  146. .samples_per_line = 1443,
  147. .sample_format = V4L2_PIX_FMT_GREY,
  148. .start = { 0, 0 },
  149. .count = { 0, 0 },
  150. .flags = 0,
  151. .reserved = { 0, 0 }
  152. }
  153. }
  154. }
  155. };
  156. static const char *get_v4l_name(int v4l_type)
  157. {
  158. switch (v4l_type) {
  159. case VFL_TYPE_GRABBER: return "video";
  160. case VFL_TYPE_RADIO: return "radio";
  161. case VFL_TYPE_VBI: return "vbi";
  162. default: return "?";
  163. }
  164. }
  165. /*
  166. * pvr_ioctl()
  167. *
  168. * This is part of Video 4 Linux API. The procedure handles ioctl() calls.
  169. *
  170. */
  171. static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file,
  172. unsigned int cmd, void *arg)
  173. {
  174. struct pvr2_v4l2_fh *fh = file->private_data;
  175. struct pvr2_v4l2 *vp = fh->vhead;
  176. struct pvr2_v4l2_dev *dev_info = fh->dev_info;
  177. struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
  178. int ret = -EINVAL;
  179. if (pvrusb2_debug & PVR2_TRACE_V4LIOCTL) {
  180. v4l_print_ioctl(pvr2_hdw_get_driver_name(hdw),cmd);
  181. }
  182. if (!pvr2_hdw_dev_ok(hdw)) {
  183. pvr2_trace(PVR2_TRACE_ERROR_LEGS,
  184. "ioctl failed - bad or no context");
  185. return -EFAULT;
  186. }
  187. /* check priority */
  188. switch (cmd) {
  189. case VIDIOC_S_CTRL:
  190. case VIDIOC_S_STD:
  191. case VIDIOC_S_INPUT:
  192. case VIDIOC_S_TUNER:
  193. case VIDIOC_S_FREQUENCY:
  194. ret = v4l2_prio_check(&vp->prio, &fh->prio);
  195. if (ret)
  196. return ret;
  197. }
  198. switch (cmd) {
  199. case VIDIOC_QUERYCAP:
  200. {
  201. struct v4l2_capability *cap = arg;
  202. memcpy(cap, &pvr_capability, sizeof(struct v4l2_capability));
  203. ret = 0;
  204. break;
  205. }
  206. case VIDIOC_G_PRIORITY:
  207. {
  208. enum v4l2_priority *p = arg;
  209. *p = v4l2_prio_max(&vp->prio);
  210. ret = 0;
  211. break;
  212. }
  213. case VIDIOC_S_PRIORITY:
  214. {
  215. enum v4l2_priority *prio = arg;
  216. ret = v4l2_prio_change(&vp->prio, &fh->prio, *prio);
  217. break;
  218. }
  219. case VIDIOC_ENUMSTD:
  220. {
  221. struct v4l2_standard *vs = (struct v4l2_standard *)arg;
  222. int idx = vs->index;
  223. ret = pvr2_hdw_get_stdenum_value(hdw,vs,idx+1);
  224. break;
  225. }
  226. case VIDIOC_G_STD:
  227. {
  228. int val = 0;
  229. ret = pvr2_ctrl_get_value(
  230. pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_STDCUR),&val);
  231. *(v4l2_std_id *)arg = val;
  232. break;
  233. }
  234. case VIDIOC_S_STD:
  235. {
  236. ret = pvr2_ctrl_set_value(
  237. pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_STDCUR),
  238. *(v4l2_std_id *)arg);
  239. break;
  240. }
  241. case VIDIOC_ENUMINPUT:
  242. {
  243. struct pvr2_ctrl *cptr;
  244. struct v4l2_input *vi = (struct v4l2_input *)arg;
  245. struct v4l2_input tmp;
  246. unsigned int cnt;
  247. cptr = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_INPUT);
  248. memset(&tmp,0,sizeof(tmp));
  249. tmp.index = vi->index;
  250. ret = 0;
  251. switch (vi->index) {
  252. case PVR2_CVAL_INPUT_TV:
  253. case PVR2_CVAL_INPUT_RADIO:
  254. tmp.type = V4L2_INPUT_TYPE_TUNER;
  255. break;
  256. case PVR2_CVAL_INPUT_SVIDEO:
  257. case PVR2_CVAL_INPUT_COMPOSITE:
  258. tmp.type = V4L2_INPUT_TYPE_CAMERA;
  259. break;
  260. default:
  261. ret = -EINVAL;
  262. break;
  263. }
  264. if (ret < 0) break;
  265. cnt = 0;
  266. pvr2_ctrl_get_valname(cptr,vi->index,
  267. tmp.name,sizeof(tmp.name)-1,&cnt);
  268. tmp.name[cnt] = 0;
  269. /* Don't bother with audioset, since this driver currently
  270. always switches the audio whenever the video is
  271. switched. */
  272. /* Handling std is a tougher problem. It doesn't make
  273. sense in cases where a device might be multi-standard.
  274. We could just copy out the current value for the
  275. standard, but it can change over time. For now just
  276. leave it zero. */
  277. memcpy(vi, &tmp, sizeof(tmp));
  278. ret = 0;
  279. break;
  280. }
  281. case VIDIOC_G_INPUT:
  282. {
  283. struct pvr2_ctrl *cptr;
  284. struct v4l2_input *vi = (struct v4l2_input *)arg;
  285. int val;
  286. cptr = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_INPUT);
  287. val = 0;
  288. ret = pvr2_ctrl_get_value(cptr,&val);
  289. vi->index = val;
  290. break;
  291. }
  292. case VIDIOC_S_INPUT:
  293. {
  294. struct v4l2_input *vi = (struct v4l2_input *)arg;
  295. ret = pvr2_ctrl_set_value(
  296. pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_INPUT),
  297. vi->index);
  298. break;
  299. }
  300. case VIDIOC_ENUMAUDIO:
  301. {
  302. ret = -EINVAL;
  303. break;
  304. }
  305. case VIDIOC_G_AUDIO:
  306. {
  307. ret = -EINVAL;
  308. break;
  309. }
  310. case VIDIOC_S_AUDIO:
  311. {
  312. ret = -EINVAL;
  313. break;
  314. }
  315. case VIDIOC_G_TUNER:
  316. {
  317. struct v4l2_tuner *vt = (struct v4l2_tuner *)arg;
  318. unsigned int status_mask;
  319. int val;
  320. if (vt->index !=0) break;
  321. status_mask = pvr2_hdw_get_signal_status(hdw);
  322. memcpy(vt, &pvr_v4l2_tuners[vt->index],
  323. sizeof(struct v4l2_tuner));
  324. vt->signal = 0;
  325. if (status_mask & PVR2_SIGNAL_OK) {
  326. if (status_mask & PVR2_SIGNAL_STEREO) {
  327. vt->rxsubchans = V4L2_TUNER_SUB_STEREO;
  328. } else {
  329. vt->rxsubchans = V4L2_TUNER_SUB_MONO;
  330. }
  331. if (status_mask & PVR2_SIGNAL_SAP) {
  332. vt->rxsubchans |= (V4L2_TUNER_SUB_LANG1 |
  333. V4L2_TUNER_SUB_LANG2);
  334. }
  335. vt->signal = 65535;
  336. }
  337. val = 0;
  338. ret = pvr2_ctrl_get_value(
  339. pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_AUDIOMODE),
  340. &val);
  341. vt->audmode = val;
  342. break;
  343. }
  344. case VIDIOC_S_TUNER:
  345. {
  346. struct v4l2_tuner *vt=(struct v4l2_tuner *)arg;
  347. if (vt->index != 0)
  348. break;
  349. ret = pvr2_ctrl_set_value(
  350. pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_AUDIOMODE),
  351. vt->audmode);
  352. }
  353. case VIDIOC_S_FREQUENCY:
  354. {
  355. const struct v4l2_frequency *vf = (struct v4l2_frequency *)arg;
  356. unsigned long fv;
  357. fv = vf->frequency;
  358. if (vf->type == V4L2_TUNER_RADIO) {
  359. fv = (fv * 125) / 2;
  360. } else {
  361. fv = fv * 62500;
  362. }
  363. ret = pvr2_ctrl_set_value(
  364. pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_FREQUENCY),fv);
  365. break;
  366. }
  367. case VIDIOC_G_FREQUENCY:
  368. {
  369. struct v4l2_frequency *vf = (struct v4l2_frequency *)arg;
  370. int val = 0;
  371. int cur_input = PVR2_CVAL_INPUT_TV;
  372. ret = pvr2_ctrl_get_value(
  373. pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_FREQUENCY),
  374. &val);
  375. if (ret != 0) break;
  376. pvr2_ctrl_get_value(
  377. pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_INPUT),
  378. &cur_input);
  379. if (cur_input == PVR2_CVAL_INPUT_RADIO) {
  380. val = (val * 2) / 125;
  381. vf->frequency = val;
  382. vf->type = V4L2_TUNER_RADIO;
  383. } else {
  384. val /= 62500;
  385. vf->frequency = val;
  386. vf->type = V4L2_TUNER_ANALOG_TV;
  387. }
  388. break;
  389. }
  390. case VIDIOC_ENUM_FMT:
  391. {
  392. struct v4l2_fmtdesc *fd = (struct v4l2_fmtdesc *)arg;
  393. /* Only one format is supported : mpeg.*/
  394. if (fd->index != 0)
  395. break;
  396. memcpy(fd, pvr_fmtdesc, sizeof(struct v4l2_fmtdesc));
  397. ret = 0;
  398. break;
  399. }
  400. case VIDIOC_G_FMT:
  401. {
  402. struct v4l2_format *vf = (struct v4l2_format *)arg;
  403. int val;
  404. switch(vf->type) {
  405. case V4L2_BUF_TYPE_VIDEO_CAPTURE:
  406. memcpy(vf, &pvr_format[PVR_FORMAT_PIX],
  407. sizeof(struct v4l2_format));
  408. val = 0;
  409. pvr2_ctrl_get_value(
  410. pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_HRES),
  411. &val);
  412. vf->fmt.pix.width = val;
  413. val = 0;
  414. pvr2_ctrl_get_value(
  415. pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_VRES),
  416. &val);
  417. vf->fmt.pix.height = val;
  418. ret = 0;
  419. break;
  420. case V4L2_BUF_TYPE_VBI_CAPTURE:
  421. // ????? Still need to figure out to do VBI correctly
  422. ret = -EINVAL;
  423. break;
  424. default:
  425. ret = -EINVAL;
  426. break;
  427. }
  428. break;
  429. }
  430. case VIDIOC_TRY_FMT:
  431. case VIDIOC_S_FMT:
  432. {
  433. struct v4l2_format *vf = (struct v4l2_format *)arg;
  434. ret = 0;
  435. switch(vf->type) {
  436. case V4L2_BUF_TYPE_VIDEO_CAPTURE: {
  437. int lmin,lmax;
  438. struct pvr2_ctrl *hcp,*vcp;
  439. int h = vf->fmt.pix.height;
  440. int w = vf->fmt.pix.width;
  441. hcp = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_HRES);
  442. vcp = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_VRES);
  443. lmin = pvr2_ctrl_get_min(hcp);
  444. lmax = pvr2_ctrl_get_max(hcp);
  445. if (w < lmin) {
  446. w = lmin;
  447. } else if (w > lmax) {
  448. w = lmax;
  449. }
  450. lmin = pvr2_ctrl_get_min(vcp);
  451. lmax = pvr2_ctrl_get_max(vcp);
  452. if (h < lmin) {
  453. h = lmin;
  454. } else if (h > lmax) {
  455. h = lmax;
  456. }
  457. memcpy(vf, &pvr_format[PVR_FORMAT_PIX],
  458. sizeof(struct v4l2_format));
  459. vf->fmt.pix.width = w;
  460. vf->fmt.pix.height = h;
  461. if (cmd == VIDIOC_S_FMT) {
  462. pvr2_ctrl_set_value(hcp,vf->fmt.pix.width);
  463. pvr2_ctrl_set_value(vcp,vf->fmt.pix.height);
  464. }
  465. } break;
  466. case V4L2_BUF_TYPE_VBI_CAPTURE:
  467. // ????? Still need to figure out to do VBI correctly
  468. ret = -EINVAL;
  469. break;
  470. default:
  471. ret = -EINVAL;
  472. break;
  473. }
  474. break;
  475. }
  476. case VIDIOC_STREAMON:
  477. {
  478. if (!fh->dev_info->stream) {
  479. /* No stream defined for this node. This means
  480. that we're not currently allowed to stream from
  481. this node. */
  482. ret = -EPERM;
  483. break;
  484. }
  485. ret = pvr2_hdw_set_stream_type(hdw,dev_info->config);
  486. if (ret < 0) return ret;
  487. ret = pvr2_hdw_set_streaming(hdw,!0);
  488. break;
  489. }
  490. case VIDIOC_STREAMOFF:
  491. {
  492. if (!fh->dev_info->stream) {
  493. /* No stream defined for this node. This means
  494. that we're not currently allowed to stream from
  495. this node. */
  496. ret = -EPERM;
  497. break;
  498. }
  499. ret = pvr2_hdw_set_streaming(hdw,0);
  500. break;
  501. }
  502. case VIDIOC_QUERYCTRL:
  503. {
  504. struct pvr2_ctrl *cptr;
  505. struct v4l2_queryctrl *vc = (struct v4l2_queryctrl *)arg;
  506. ret = 0;
  507. if (vc->id & V4L2_CTRL_FLAG_NEXT_CTRL) {
  508. cptr = pvr2_hdw_get_ctrl_nextv4l(
  509. hdw,(vc->id & ~V4L2_CTRL_FLAG_NEXT_CTRL));
  510. if (cptr) vc->id = pvr2_ctrl_get_v4lid(cptr);
  511. } else {
  512. cptr = pvr2_hdw_get_ctrl_v4l(hdw,vc->id);
  513. }
  514. if (!cptr) {
  515. pvr2_trace(PVR2_TRACE_V4LIOCTL,
  516. "QUERYCTRL id=0x%x not implemented here",
  517. vc->id);
  518. ret = -EINVAL;
  519. break;
  520. }
  521. pvr2_trace(PVR2_TRACE_V4LIOCTL,
  522. "QUERYCTRL id=0x%x mapping name=%s (%s)",
  523. vc->id,pvr2_ctrl_get_name(cptr),
  524. pvr2_ctrl_get_desc(cptr));
  525. strlcpy(vc->name,pvr2_ctrl_get_desc(cptr),sizeof(vc->name));
  526. vc->flags = pvr2_ctrl_get_v4lflags(cptr);
  527. vc->default_value = pvr2_ctrl_get_def(cptr);
  528. switch (pvr2_ctrl_get_type(cptr)) {
  529. case pvr2_ctl_enum:
  530. vc->type = V4L2_CTRL_TYPE_MENU;
  531. vc->minimum = 0;
  532. vc->maximum = pvr2_ctrl_get_cnt(cptr) - 1;
  533. vc->step = 1;
  534. break;
  535. case pvr2_ctl_bool:
  536. vc->type = V4L2_CTRL_TYPE_BOOLEAN;
  537. vc->minimum = 0;
  538. vc->maximum = 1;
  539. vc->step = 1;
  540. break;
  541. case pvr2_ctl_int:
  542. vc->type = V4L2_CTRL_TYPE_INTEGER;
  543. vc->minimum = pvr2_ctrl_get_min(cptr);
  544. vc->maximum = pvr2_ctrl_get_max(cptr);
  545. vc->step = 1;
  546. break;
  547. default:
  548. pvr2_trace(PVR2_TRACE_V4LIOCTL,
  549. "QUERYCTRL id=0x%x name=%s not mappable",
  550. vc->id,pvr2_ctrl_get_name(cptr));
  551. ret = -EINVAL;
  552. break;
  553. }
  554. break;
  555. }
  556. case VIDIOC_QUERYMENU:
  557. {
  558. struct v4l2_querymenu *vm = (struct v4l2_querymenu *)arg;
  559. unsigned int cnt = 0;
  560. ret = pvr2_ctrl_get_valname(pvr2_hdw_get_ctrl_v4l(hdw,vm->id),
  561. vm->index,
  562. vm->name,sizeof(vm->name)-1,
  563. &cnt);
  564. vm->name[cnt] = 0;
  565. break;
  566. }
  567. case VIDIOC_G_CTRL:
  568. {
  569. struct v4l2_control *vc = (struct v4l2_control *)arg;
  570. int val = 0;
  571. ret = pvr2_ctrl_get_value(pvr2_hdw_get_ctrl_v4l(hdw,vc->id),
  572. &val);
  573. vc->value = val;
  574. break;
  575. }
  576. case VIDIOC_S_CTRL:
  577. {
  578. struct v4l2_control *vc = (struct v4l2_control *)arg;
  579. ret = pvr2_ctrl_set_value(pvr2_hdw_get_ctrl_v4l(hdw,vc->id),
  580. vc->value);
  581. break;
  582. }
  583. case VIDIOC_G_EXT_CTRLS:
  584. {
  585. struct v4l2_ext_controls *ctls =
  586. (struct v4l2_ext_controls *)arg;
  587. struct v4l2_ext_control *ctrl;
  588. unsigned int idx;
  589. int val;
  590. for (idx = 0; idx < ctls->count; idx++) {
  591. ctrl = ctls->controls + idx;
  592. ret = pvr2_ctrl_get_value(
  593. pvr2_hdw_get_ctrl_v4l(hdw,ctrl->id),&val);
  594. if (ret) {
  595. ctls->error_idx = idx;
  596. break;
  597. }
  598. /* Ensure that if read as a 64 bit value, the user
  599. will still get a hopefully sane value */
  600. ctrl->value64 = 0;
  601. ctrl->value = val;
  602. }
  603. break;
  604. }
  605. case VIDIOC_S_EXT_CTRLS:
  606. {
  607. struct v4l2_ext_controls *ctls =
  608. (struct v4l2_ext_controls *)arg;
  609. struct v4l2_ext_control *ctrl;
  610. unsigned int idx;
  611. for (idx = 0; idx < ctls->count; idx++) {
  612. ctrl = ctls->controls + idx;
  613. ret = pvr2_ctrl_set_value(
  614. pvr2_hdw_get_ctrl_v4l(hdw,ctrl->id),
  615. ctrl->value);
  616. if (ret) {
  617. ctls->error_idx = idx;
  618. break;
  619. }
  620. }
  621. break;
  622. }
  623. case VIDIOC_TRY_EXT_CTRLS:
  624. {
  625. struct v4l2_ext_controls *ctls =
  626. (struct v4l2_ext_controls *)arg;
  627. struct v4l2_ext_control *ctrl;
  628. struct pvr2_ctrl *pctl;
  629. unsigned int idx;
  630. /* For the moment just validate that the requested control
  631. actually exists. */
  632. for (idx = 0; idx < ctls->count; idx++) {
  633. ctrl = ctls->controls + idx;
  634. pctl = pvr2_hdw_get_ctrl_v4l(hdw,ctrl->id);
  635. if (!pctl) {
  636. ret = -EINVAL;
  637. ctls->error_idx = idx;
  638. break;
  639. }
  640. }
  641. break;
  642. }
  643. case VIDIOC_LOG_STATUS:
  644. {
  645. pvr2_hdw_trigger_module_log(hdw);
  646. ret = 0;
  647. break;
  648. }
  649. #ifdef CONFIG_VIDEO_ADV_DEBUG
  650. case VIDIOC_INT_G_REGISTER:
  651. case VIDIOC_INT_S_REGISTER:
  652. {
  653. u32 val;
  654. struct v4l2_register *req = (struct v4l2_register *)arg;
  655. if (cmd == VIDIOC_INT_S_REGISTER) val = req->val;
  656. ret = pvr2_hdw_register_access(
  657. hdw,req->i2c_id,req->reg,
  658. cmd == VIDIOC_INT_S_REGISTER,&val);
  659. if (cmd == VIDIOC_INT_G_REGISTER) req->val = val;
  660. break;
  661. }
  662. #endif
  663. default :
  664. ret = v4l_compat_translate_ioctl(inode,file,cmd,
  665. arg,pvr2_v4l2_do_ioctl);
  666. }
  667. pvr2_hdw_commit_ctl(hdw);
  668. if (ret < 0) {
  669. if (pvrusb2_debug & PVR2_TRACE_V4LIOCTL) {
  670. pvr2_trace(PVR2_TRACE_V4LIOCTL,
  671. "pvr2_v4l2_do_ioctl failure, ret=%d",ret);
  672. } else {
  673. if (pvrusb2_debug & PVR2_TRACE_V4LIOCTL) {
  674. pvr2_trace(PVR2_TRACE_V4LIOCTL,
  675. "pvr2_v4l2_do_ioctl failure, ret=%d"
  676. " command was:",ret);
  677. v4l_print_ioctl(pvr2_hdw_get_driver_name(hdw),
  678. cmd);
  679. }
  680. }
  681. } else {
  682. pvr2_trace(PVR2_TRACE_V4LIOCTL,
  683. "pvr2_v4l2_do_ioctl complete, ret=%d (0x%x)",
  684. ret,ret);
  685. }
  686. return ret;
  687. }
  688. static void pvr2_v4l2_dev_destroy(struct pvr2_v4l2_dev *dip)
  689. {
  690. int minor_id = dip->devbase.minor;
  691. struct pvr2_hdw *hdw = dip->v4lp->channel.mc_head->hdw;
  692. enum pvr2_config cfg = dip->config;
  693. int v4l_type = dip->v4l_type;
  694. pvr2_hdw_v4l_store_minor_number(hdw,dip->minor_type,-1);
  695. /* Paranoia */
  696. dip->v4lp = NULL;
  697. dip->stream = NULL;
  698. /* Actual deallocation happens later when all internal references
  699. are gone. */
  700. video_unregister_device(&dip->devbase);
  701. printk(KERN_INFO "pvrusb2: unregistered device %s%u [%s]\n",
  702. get_v4l_name(v4l_type),minor_id & 0x1f,
  703. pvr2_config_get_name(cfg));
  704. }
  705. static void pvr2_v4l2_destroy_no_lock(struct pvr2_v4l2 *vp)
  706. {
  707. if (vp->dev_video) {
  708. pvr2_v4l2_dev_destroy(vp->dev_video);
  709. vp->dev_video = 0;
  710. }
  711. if (vp->dev_radio) {
  712. pvr2_v4l2_dev_destroy(vp->dev_radio);
  713. vp->dev_radio = 0;
  714. }
  715. pvr2_trace(PVR2_TRACE_STRUCT,"Destroying pvr2_v4l2 id=%p",vp);
  716. pvr2_channel_done(&vp->channel);
  717. kfree(vp);
  718. }
  719. static void pvr2_video_device_release(struct video_device *vdev)
  720. {
  721. struct pvr2_v4l2_dev *dev;
  722. dev = container_of(vdev,struct pvr2_v4l2_dev,devbase);
  723. kfree(dev);
  724. }
  725. static void pvr2_v4l2_internal_check(struct pvr2_channel *chp)
  726. {
  727. struct pvr2_v4l2 *vp;
  728. vp = container_of(chp,struct pvr2_v4l2,channel);
  729. if (!vp->channel.mc_head->disconnect_flag) return;
  730. if (vp->vfirst) return;
  731. pvr2_v4l2_destroy_no_lock(vp);
  732. }
  733. static int pvr2_v4l2_ioctl(struct inode *inode, struct file *file,
  734. unsigned int cmd, unsigned long arg)
  735. {
  736. /* Temporary hack : use ivtv api until a v4l2 one is available. */
  737. #define IVTV_IOC_G_CODEC 0xFFEE7703
  738. #define IVTV_IOC_S_CODEC 0xFFEE7704
  739. if (cmd == IVTV_IOC_G_CODEC || cmd == IVTV_IOC_S_CODEC) return 0;
  740. return video_usercopy(inode, file, cmd, arg, pvr2_v4l2_do_ioctl);
  741. }
  742. static int pvr2_v4l2_release(struct inode *inode, struct file *file)
  743. {
  744. struct pvr2_v4l2_fh *fhp = file->private_data;
  745. struct pvr2_v4l2 *vp = fhp->vhead;
  746. struct pvr2_context *mp = fhp->vhead->channel.mc_head;
  747. struct pvr2_hdw *hdw = fhp->channel.mc_head->hdw;
  748. pvr2_trace(PVR2_TRACE_OPEN_CLOSE,"pvr2_v4l2_release");
  749. if (fhp->rhp) {
  750. struct pvr2_stream *sp;
  751. pvr2_hdw_set_streaming(hdw,0);
  752. sp = pvr2_ioread_get_stream(fhp->rhp);
  753. if (sp) pvr2_stream_set_callback(sp,NULL,NULL);
  754. pvr2_ioread_destroy(fhp->rhp);
  755. fhp->rhp = NULL;
  756. }
  757. v4l2_prio_close(&vp->prio, &fhp->prio);
  758. file->private_data = NULL;
  759. pvr2_context_enter(mp); do {
  760. /* Restore the previous input selection, if it makes sense
  761. to do so. */
  762. if (fhp->dev_info->v4l_type == VFL_TYPE_RADIO) {
  763. struct pvr2_ctrl *cp;
  764. int pval;
  765. cp = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_INPUT);
  766. pvr2_ctrl_get_value(cp,&pval);
  767. /* Only restore if we're still selecting the radio */
  768. if (pval == PVR2_CVAL_INPUT_RADIO) {
  769. pvr2_ctrl_set_value(cp,fhp->prev_input_val);
  770. pvr2_hdw_commit_ctl(hdw);
  771. }
  772. }
  773. if (fhp->vnext) {
  774. fhp->vnext->vprev = fhp->vprev;
  775. } else {
  776. vp->vlast = fhp->vprev;
  777. }
  778. if (fhp->vprev) {
  779. fhp->vprev->vnext = fhp->vnext;
  780. } else {
  781. vp->vfirst = fhp->vnext;
  782. }
  783. fhp->vnext = NULL;
  784. fhp->vprev = NULL;
  785. fhp->vhead = NULL;
  786. pvr2_channel_done(&fhp->channel);
  787. pvr2_trace(PVR2_TRACE_STRUCT,
  788. "Destroying pvr_v4l2_fh id=%p",fhp);
  789. kfree(fhp);
  790. if (vp->channel.mc_head->disconnect_flag && !vp->vfirst) {
  791. pvr2_v4l2_destroy_no_lock(vp);
  792. }
  793. } while (0); pvr2_context_exit(mp);
  794. return 0;
  795. }
  796. static int pvr2_v4l2_open(struct inode *inode, struct file *file)
  797. {
  798. struct pvr2_v4l2_dev *dip; /* Our own context pointer */
  799. struct pvr2_v4l2_fh *fhp;
  800. struct pvr2_v4l2 *vp;
  801. struct pvr2_hdw *hdw;
  802. dip = container_of(video_devdata(file),struct pvr2_v4l2_dev,devbase);
  803. vp = dip->v4lp;
  804. hdw = vp->channel.hdw;
  805. pvr2_trace(PVR2_TRACE_OPEN_CLOSE,"pvr2_v4l2_open");
  806. if (!pvr2_hdw_dev_ok(hdw)) {
  807. pvr2_trace(PVR2_TRACE_OPEN_CLOSE,
  808. "pvr2_v4l2_open: hardware not ready");
  809. return -EIO;
  810. }
  811. fhp = kmalloc(sizeof(*fhp),GFP_KERNEL);
  812. if (!fhp) {
  813. return -ENOMEM;
  814. }
  815. memset(fhp,0,sizeof(*fhp));
  816. init_waitqueue_head(&fhp->wait_data);
  817. fhp->dev_info = dip;
  818. pvr2_context_enter(vp->channel.mc_head); do {
  819. pvr2_trace(PVR2_TRACE_STRUCT,"Creating pvr_v4l2_fh id=%p",fhp);
  820. pvr2_channel_init(&fhp->channel,vp->channel.mc_head);
  821. fhp->vnext = NULL;
  822. fhp->vprev = vp->vlast;
  823. if (vp->vlast) {
  824. vp->vlast->vnext = fhp;
  825. } else {
  826. vp->vfirst = fhp;
  827. }
  828. vp->vlast = fhp;
  829. fhp->vhead = vp;
  830. /* Opening the /dev/radioX device implies a mode switch.
  831. So execute that here. Note that you can get the
  832. IDENTICAL effect merely by opening the normal video
  833. device and setting the input appropriately. */
  834. if (dip->v4l_type == VFL_TYPE_RADIO) {
  835. struct pvr2_ctrl *cp;
  836. cp = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_INPUT);
  837. pvr2_ctrl_get_value(cp,&fhp->prev_input_val);
  838. pvr2_ctrl_set_value(cp,PVR2_CVAL_INPUT_RADIO);
  839. pvr2_hdw_commit_ctl(hdw);
  840. }
  841. } while (0); pvr2_context_exit(vp->channel.mc_head);
  842. fhp->file = file;
  843. file->private_data = fhp;
  844. v4l2_prio_open(&vp->prio,&fhp->prio);
  845. fhp->fw_mode_flag = pvr2_hdw_cpufw_get_enabled(hdw);
  846. return 0;
  847. }
  848. static void pvr2_v4l2_notify(struct pvr2_v4l2_fh *fhp)
  849. {
  850. wake_up(&fhp->wait_data);
  851. }
  852. static int pvr2_v4l2_iosetup(struct pvr2_v4l2_fh *fh)
  853. {
  854. int ret;
  855. struct pvr2_stream *sp;
  856. struct pvr2_hdw *hdw;
  857. if (fh->rhp) return 0;
  858. if (!fh->dev_info->stream) {
  859. /* No stream defined for this node. This means that we're
  860. not currently allowed to stream from this node. */
  861. return -EPERM;
  862. }
  863. /* First read() attempt. Try to claim the stream and start
  864. it... */
  865. if ((ret = pvr2_channel_claim_stream(&fh->channel,
  866. fh->dev_info->stream)) != 0) {
  867. /* Someone else must already have it */
  868. return ret;
  869. }
  870. fh->rhp = pvr2_channel_create_mpeg_stream(fh->dev_info->stream);
  871. if (!fh->rhp) {
  872. pvr2_channel_claim_stream(&fh->channel,NULL);
  873. return -ENOMEM;
  874. }
  875. hdw = fh->channel.mc_head->hdw;
  876. sp = fh->dev_info->stream->stream;
  877. pvr2_stream_set_callback(sp,(pvr2_stream_callback)pvr2_v4l2_notify,fh);
  878. pvr2_hdw_set_stream_type(hdw,fh->dev_info->config);
  879. pvr2_hdw_set_streaming(hdw,!0);
  880. ret = pvr2_ioread_set_enabled(fh->rhp,!0);
  881. return ret;
  882. }
  883. static ssize_t pvr2_v4l2_read(struct file *file,
  884. char __user *buff, size_t count, loff_t *ppos)
  885. {
  886. struct pvr2_v4l2_fh *fh = file->private_data;
  887. int ret;
  888. if (fh->fw_mode_flag) {
  889. struct pvr2_hdw *hdw = fh->channel.mc_head->hdw;
  890. char *tbuf;
  891. int c1,c2;
  892. int tcnt = 0;
  893. unsigned int offs = *ppos;
  894. tbuf = kmalloc(PAGE_SIZE,GFP_KERNEL);
  895. if (!tbuf) return -ENOMEM;
  896. while (count) {
  897. c1 = count;
  898. if (c1 > PAGE_SIZE) c1 = PAGE_SIZE;
  899. c2 = pvr2_hdw_cpufw_get(hdw,offs,tbuf,c1);
  900. if (c2 < 0) {
  901. tcnt = c2;
  902. break;
  903. }
  904. if (!c2) break;
  905. if (copy_to_user(buff,tbuf,c2)) {
  906. tcnt = -EFAULT;
  907. break;
  908. }
  909. offs += c2;
  910. tcnt += c2;
  911. buff += c2;
  912. count -= c2;
  913. *ppos += c2;
  914. }
  915. kfree(tbuf);
  916. return tcnt;
  917. }
  918. if (!fh->rhp) {
  919. ret = pvr2_v4l2_iosetup(fh);
  920. if (ret) {
  921. return ret;
  922. }
  923. }
  924. for (;;) {
  925. ret = pvr2_ioread_read(fh->rhp,buff,count);
  926. if (ret >= 0) break;
  927. if (ret != -EAGAIN) break;
  928. if (file->f_flags & O_NONBLOCK) break;
  929. /* Doing blocking I/O. Wait here. */
  930. ret = wait_event_interruptible(
  931. fh->wait_data,
  932. pvr2_ioread_avail(fh->rhp) >= 0);
  933. if (ret < 0) break;
  934. }
  935. return ret;
  936. }
  937. static unsigned int pvr2_v4l2_poll(struct file *file, poll_table *wait)
  938. {
  939. unsigned int mask = 0;
  940. struct pvr2_v4l2_fh *fh = file->private_data;
  941. int ret;
  942. if (fh->fw_mode_flag) {
  943. mask |= POLLIN | POLLRDNORM;
  944. return mask;
  945. }
  946. if (!fh->rhp) {
  947. ret = pvr2_v4l2_iosetup(fh);
  948. if (ret) return POLLERR;
  949. }
  950. poll_wait(file,&fh->wait_data,wait);
  951. if (pvr2_ioread_avail(fh->rhp) >= 0) {
  952. mask |= POLLIN | POLLRDNORM;
  953. }
  954. return mask;
  955. }
  956. static const struct file_operations vdev_fops = {
  957. .owner = THIS_MODULE,
  958. .open = pvr2_v4l2_open,
  959. .release = pvr2_v4l2_release,
  960. .read = pvr2_v4l2_read,
  961. .ioctl = pvr2_v4l2_ioctl,
  962. .llseek = no_llseek,
  963. .poll = pvr2_v4l2_poll,
  964. };
  965. #define VID_HARDWARE_PVRUSB2 38 /* FIXME : need a good value */
  966. static struct video_device vdev_template = {
  967. .owner = THIS_MODULE,
  968. .type = VID_TYPE_CAPTURE | VID_TYPE_TUNER,
  969. .type2 = (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VBI_CAPTURE
  970. | V4L2_CAP_TUNER | V4L2_CAP_AUDIO
  971. | V4L2_CAP_READWRITE),
  972. .hardware = VID_HARDWARE_PVRUSB2,
  973. .fops = &vdev_fops,
  974. };
  975. static void pvr2_v4l2_dev_init(struct pvr2_v4l2_dev *dip,
  976. struct pvr2_v4l2 *vp,
  977. int v4l_type)
  978. {
  979. int mindevnum;
  980. int unit_number;
  981. int *nr_ptr = 0;
  982. dip->v4lp = vp;
  983. dip->v4l_type = v4l_type;
  984. switch (v4l_type) {
  985. case VFL_TYPE_GRABBER:
  986. dip->stream = &vp->channel.mc_head->video_stream;
  987. dip->config = pvr2_config_mpeg;
  988. dip->minor_type = pvr2_v4l_type_video;
  989. nr_ptr = video_nr;
  990. if (!dip->stream) {
  991. err("Failed to set up pvrusb2 v4l video dev"
  992. " due to missing stream instance");
  993. return;
  994. }
  995. break;
  996. case VFL_TYPE_VBI:
  997. dip->config = pvr2_config_vbi;
  998. dip->minor_type = pvr2_v4l_type_vbi;
  999. nr_ptr = vbi_nr;
  1000. break;
  1001. case VFL_TYPE_RADIO:
  1002. dip->config = pvr2_config_pcm;
  1003. dip->minor_type = pvr2_v4l_type_radio;
  1004. nr_ptr = radio_nr;
  1005. break;
  1006. default:
  1007. /* Bail out (this should be impossible) */
  1008. err("Failed to set up pvrusb2 v4l dev"
  1009. " due to unrecognized config");
  1010. return;
  1011. }
  1012. memcpy(&dip->devbase,&vdev_template,sizeof(vdev_template));
  1013. dip->devbase.release = pvr2_video_device_release;
  1014. mindevnum = -1;
  1015. unit_number = pvr2_hdw_get_unit_number(vp->channel.mc_head->hdw);
  1016. if (nr_ptr && (unit_number >= 0) && (unit_number < PVR_NUM)) {
  1017. mindevnum = nr_ptr[unit_number];
  1018. }
  1019. if ((video_register_device(&dip->devbase,
  1020. dip->v4l_type, mindevnum) < 0) &&
  1021. (video_register_device(&dip->devbase,
  1022. dip->v4l_type, -1) < 0)) {
  1023. err("Failed to register pvrusb2 v4l device");
  1024. }
  1025. printk(KERN_INFO "pvrusb2: registered device %s%u [%s]\n",
  1026. get_v4l_name(dip->v4l_type),dip->devbase.minor & 0x1f,
  1027. pvr2_config_get_name(dip->config));
  1028. pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw,
  1029. dip->minor_type,dip->devbase.minor);
  1030. }
  1031. struct pvr2_v4l2 *pvr2_v4l2_create(struct pvr2_context *mnp)
  1032. {
  1033. struct pvr2_v4l2 *vp;
  1034. vp = kmalloc(sizeof(*vp),GFP_KERNEL);
  1035. if (!vp) return vp;
  1036. memset(vp,0,sizeof(*vp));
  1037. vp->dev_video = kmalloc(sizeof(*vp->dev_video),GFP_KERNEL);
  1038. vp->dev_radio = kmalloc(sizeof(*vp->dev_radio),GFP_KERNEL);
  1039. if (!(vp->dev_video && vp->dev_radio)) {
  1040. if (vp->dev_video) kfree(vp->dev_video);
  1041. if (vp->dev_radio) kfree(vp->dev_radio);
  1042. kfree(vp);
  1043. return NULL;
  1044. }
  1045. memset(vp->dev_video,0,sizeof(*vp->dev_video));
  1046. memset(vp->dev_radio,0,sizeof(*vp->dev_radio));
  1047. pvr2_channel_init(&vp->channel,mnp);
  1048. pvr2_trace(PVR2_TRACE_STRUCT,"Creating pvr2_v4l2 id=%p",vp);
  1049. vp->channel.check_func = pvr2_v4l2_internal_check;
  1050. /* register streams */
  1051. pvr2_v4l2_dev_init(vp->dev_video,vp,VFL_TYPE_GRABBER);
  1052. pvr2_v4l2_dev_init(vp->dev_radio,vp,VFL_TYPE_RADIO);
  1053. return vp;
  1054. }
  1055. /*
  1056. Stuff for Emacs to see, in order to encourage consistent editing style:
  1057. *** Local Variables: ***
  1058. *** mode: c ***
  1059. *** fill-column: 75 ***
  1060. *** tab-width: 8 ***
  1061. *** c-basic-offset: 8 ***
  1062. *** End: ***
  1063. */