cx18-ioctl.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132
  1. /*
  2. * cx18 ioctl system call
  3. *
  4. * Derived from ivtv-ioctl.c
  5. *
  6. * Copyright (C) 2007 Hans Verkuil <[email protected]>
  7. * Copyright (C) 2008 Andy Walls <[email protected]>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  22. * 02111-1307 USA
  23. */
  24. #include "cx18-driver.h"
  25. #include "cx18-io.h"
  26. #include "cx18-version.h"
  27. #include "cx18-mailbox.h"
  28. #include "cx18-i2c.h"
  29. #include "cx18-queue.h"
  30. #include "cx18-fileops.h"
  31. #include "cx18-vbi.h"
  32. #include "cx18-audio.h"
  33. #include "cx18-video.h"
  34. #include "cx18-streams.h"
  35. #include "cx18-ioctl.h"
  36. #include "cx18-gpio.h"
  37. #include "cx18-controls.h"
  38. #include "cx18-cards.h"
  39. #include "cx18-av-core.h"
  40. #include <media/tveeprom.h>
  41. #include <media/v4l2-event.h>
  42. u16 cx18_service2vbi(int type)
  43. {
  44. switch (type) {
  45. case V4L2_SLICED_TELETEXT_B:
  46. return CX18_SLICED_TYPE_TELETEXT_B;
  47. case V4L2_SLICED_CAPTION_525:
  48. return CX18_SLICED_TYPE_CAPTION_525;
  49. case V4L2_SLICED_WSS_625:
  50. return CX18_SLICED_TYPE_WSS_625;
  51. case V4L2_SLICED_VPS:
  52. return CX18_SLICED_TYPE_VPS;
  53. default:
  54. return 0;
  55. }
  56. }
  57. /* Check if VBI services are allowed on the (field, line) for the video std */
  58. static int valid_service_line(int field, int line, int is_pal)
  59. {
  60. return (is_pal && line >= 6 &&
  61. ((field == 0 && line <= 23) || (field == 1 && line <= 22))) ||
  62. (!is_pal && line >= 10 && line < 22);
  63. }
  64. /*
  65. * For a (field, line, std) and inbound potential set of services for that line,
  66. * return the first valid service of those passed in the incoming set for that
  67. * line in priority order:
  68. * CC, VPS, or WSS over TELETEXT for well known lines
  69. * TELETEXT, before VPS, before CC, before WSS, for other lines
  70. */
  71. static u16 select_service_from_set(int field, int line, u16 set, int is_pal)
  72. {
  73. u16 valid_set = (is_pal ? V4L2_SLICED_VBI_625 : V4L2_SLICED_VBI_525);
  74. int i;
  75. set = set & valid_set;
  76. if (set == 0 || !valid_service_line(field, line, is_pal))
  77. return 0;
  78. if (!is_pal) {
  79. if (line == 21 && (set & V4L2_SLICED_CAPTION_525))
  80. return V4L2_SLICED_CAPTION_525;
  81. } else {
  82. if (line == 16 && field == 0 && (set & V4L2_SLICED_VPS))
  83. return V4L2_SLICED_VPS;
  84. if (line == 23 && field == 0 && (set & V4L2_SLICED_WSS_625))
  85. return V4L2_SLICED_WSS_625;
  86. if (line == 23)
  87. return 0;
  88. }
  89. for (i = 0; i < 32; i++) {
  90. if ((1 << i) & set)
  91. return 1 << i;
  92. }
  93. return 0;
  94. }
  95. /*
  96. * Expand the service_set of *fmt into valid service_lines for the std,
  97. * and clear the passed in fmt->service_set
  98. */
  99. void cx18_expand_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal)
  100. {
  101. u16 set = fmt->service_set;
  102. int f, l;
  103. fmt->service_set = 0;
  104. for (f = 0; f < 2; f++) {
  105. for (l = 0; l < 24; l++)
  106. fmt->service_lines[f][l] = select_service_from_set(f, l, set, is_pal);
  107. }
  108. }
  109. /*
  110. * Sanitize the service_lines in *fmt per the video std, and return 1
  111. * if any service_line is left as valid after santization
  112. */
  113. static int check_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal)
  114. {
  115. int f, l;
  116. u16 set = 0;
  117. for (f = 0; f < 2; f++) {
  118. for (l = 0; l < 24; l++) {
  119. fmt->service_lines[f][l] = select_service_from_set(f, l, fmt->service_lines[f][l], is_pal);
  120. set |= fmt->service_lines[f][l];
  121. }
  122. }
  123. return set != 0;
  124. }
  125. /* Compute the service_set from the assumed valid service_lines of *fmt */
  126. u16 cx18_get_service_set(struct v4l2_sliced_vbi_format *fmt)
  127. {
  128. int f, l;
  129. u16 set = 0;
  130. for (f = 0; f < 2; f++) {
  131. for (l = 0; l < 24; l++)
  132. set |= fmt->service_lines[f][l];
  133. }
  134. return set;
  135. }
  136. static int cx18_g_fmt_vid_cap(struct file *file, void *fh,
  137. struct v4l2_format *fmt)
  138. {
  139. struct cx18_open_id *id = fh2id(fh);
  140. struct cx18 *cx = id->cx;
  141. struct cx18_stream *s = &cx->streams[id->type];
  142. struct v4l2_pix_format *pixfmt = &fmt->fmt.pix;
  143. pixfmt->width = cx->cxhdl.width;
  144. pixfmt->height = cx->cxhdl.height;
  145. pixfmt->colorspace = V4L2_COLORSPACE_SMPTE170M;
  146. pixfmt->field = V4L2_FIELD_INTERLACED;
  147. if (id->type == CX18_ENC_STREAM_TYPE_YUV) {
  148. pixfmt->pixelformat = s->pixelformat;
  149. pixfmt->sizeimage = s->vb_bytes_per_frame;
  150. pixfmt->bytesperline = s->vb_bytes_per_line;
  151. } else {
  152. pixfmt->pixelformat = V4L2_PIX_FMT_MPEG;
  153. pixfmt->sizeimage = 128 * 1024;
  154. pixfmt->bytesperline = 0;
  155. }
  156. return 0;
  157. }
  158. static int cx18_g_fmt_vbi_cap(struct file *file, void *fh,
  159. struct v4l2_format *fmt)
  160. {
  161. struct cx18 *cx = fh2id(fh)->cx;
  162. struct v4l2_vbi_format *vbifmt = &fmt->fmt.vbi;
  163. vbifmt->sampling_rate = 27000000;
  164. vbifmt->offset = 248; /* FIXME - slightly wrong for both 50 & 60 Hz */
  165. vbifmt->samples_per_line = VBI_ACTIVE_SAMPLES - 4;
  166. vbifmt->sample_format = V4L2_PIX_FMT_GREY;
  167. vbifmt->start[0] = cx->vbi.start[0];
  168. vbifmt->start[1] = cx->vbi.start[1];
  169. vbifmt->count[0] = vbifmt->count[1] = cx->vbi.count;
  170. vbifmt->flags = 0;
  171. vbifmt->reserved[0] = 0;
  172. vbifmt->reserved[1] = 0;
  173. return 0;
  174. }
  175. static int cx18_g_fmt_sliced_vbi_cap(struct file *file, void *fh,
  176. struct v4l2_format *fmt)
  177. {
  178. struct cx18 *cx = fh2id(fh)->cx;
  179. struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced;
  180. /* sane, V4L2 spec compliant, defaults */
  181. vbifmt->reserved[0] = 0;
  182. vbifmt->reserved[1] = 0;
  183. vbifmt->io_size = sizeof(struct v4l2_sliced_vbi_data) * 36;
  184. memset(vbifmt->service_lines, 0, sizeof(vbifmt->service_lines));
  185. vbifmt->service_set = 0;
  186. /*
  187. * Fetch the configured service_lines and total service_set from the
  188. * digitizer/slicer. Note, cx18_av_vbi() wipes the passed in
  189. * fmt->fmt.sliced under valid calling conditions
  190. */
  191. if (v4l2_subdev_call(cx->sd_av, vbi, g_sliced_fmt, &fmt->fmt.sliced))
  192. return -EINVAL;
  193. vbifmt->service_set = cx18_get_service_set(vbifmt);
  194. return 0;
  195. }
  196. static int cx18_try_fmt_vid_cap(struct file *file, void *fh,
  197. struct v4l2_format *fmt)
  198. {
  199. struct cx18_open_id *id = fh2id(fh);
  200. struct cx18 *cx = id->cx;
  201. int w = fmt->fmt.pix.width;
  202. int h = fmt->fmt.pix.height;
  203. int min_h = 2;
  204. w = min(w, 720);
  205. w = max(w, 2);
  206. if (id->type == CX18_ENC_STREAM_TYPE_YUV) {
  207. /* YUV height must be a multiple of 32 */
  208. h &= ~0x1f;
  209. min_h = 32;
  210. }
  211. h = min(h, cx->is_50hz ? 576 : 480);
  212. h = max(h, min_h);
  213. fmt->fmt.pix.width = w;
  214. fmt->fmt.pix.height = h;
  215. return 0;
  216. }
  217. static int cx18_try_fmt_vbi_cap(struct file *file, void *fh,
  218. struct v4l2_format *fmt)
  219. {
  220. return cx18_g_fmt_vbi_cap(file, fh, fmt);
  221. }
  222. static int cx18_try_fmt_sliced_vbi_cap(struct file *file, void *fh,
  223. struct v4l2_format *fmt)
  224. {
  225. struct cx18 *cx = fh2id(fh)->cx;
  226. struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced;
  227. vbifmt->io_size = sizeof(struct v4l2_sliced_vbi_data) * 36;
  228. vbifmt->reserved[0] = 0;
  229. vbifmt->reserved[1] = 0;
  230. /* If given a service set, expand it validly & clear passed in set */
  231. if (vbifmt->service_set)
  232. cx18_expand_service_set(vbifmt, cx->is_50hz);
  233. /* Sanitize the service_lines, and compute the new set if any valid */
  234. if (check_service_set(vbifmt, cx->is_50hz))
  235. vbifmt->service_set = cx18_get_service_set(vbifmt);
  236. return 0;
  237. }
  238. static int cx18_s_fmt_vid_cap(struct file *file, void *fh,
  239. struct v4l2_format *fmt)
  240. {
  241. struct cx18_open_id *id = fh2id(fh);
  242. struct cx18 *cx = id->cx;
  243. struct v4l2_subdev_format format = {
  244. .which = V4L2_SUBDEV_FORMAT_ACTIVE,
  245. };
  246. struct cx18_stream *s = &cx->streams[id->type];
  247. int ret;
  248. int w, h;
  249. ret = cx18_try_fmt_vid_cap(file, fh, fmt);
  250. if (ret)
  251. return ret;
  252. w = fmt->fmt.pix.width;
  253. h = fmt->fmt.pix.height;
  254. if (cx->cxhdl.width == w && cx->cxhdl.height == h &&
  255. s->pixelformat == fmt->fmt.pix.pixelformat)
  256. return 0;
  257. if (atomic_read(&cx->ana_capturing) > 0)
  258. return -EBUSY;
  259. s->pixelformat = fmt->fmt.pix.pixelformat;
  260. /* HM12 YUV size is (Y=(h*720) + UV=(h*(720/2)))
  261. UYUV YUV size is (Y=(h*720) + UV=(h*(720))) */
  262. if (s->pixelformat == V4L2_PIX_FMT_HM12) {
  263. s->vb_bytes_per_frame = h * 720 * 3 / 2;
  264. s->vb_bytes_per_line = 720; /* First plane */
  265. } else {
  266. s->vb_bytes_per_frame = h * 720 * 2;
  267. s->vb_bytes_per_line = 1440; /* Packed */
  268. }
  269. format.format.width = cx->cxhdl.width = w;
  270. format.format.height = cx->cxhdl.height = h;
  271. format.format.code = MEDIA_BUS_FMT_FIXED;
  272. v4l2_subdev_call(cx->sd_av, pad, set_fmt, NULL, &format);
  273. return cx18_g_fmt_vid_cap(file, fh, fmt);
  274. }
  275. static int cx18_s_fmt_vbi_cap(struct file *file, void *fh,
  276. struct v4l2_format *fmt)
  277. {
  278. struct cx18_open_id *id = fh2id(fh);
  279. struct cx18 *cx = id->cx;
  280. int ret;
  281. /*
  282. * Changing the Encoder's Raw VBI parameters won't have any effect
  283. * if any analog capture is ongoing
  284. */
  285. if (!cx18_raw_vbi(cx) && atomic_read(&cx->ana_capturing) > 0)
  286. return -EBUSY;
  287. /*
  288. * Set the digitizer registers for raw active VBI.
  289. * Note cx18_av_vbi_wipes out a lot of the passed in fmt under valid
  290. * calling conditions
  291. */
  292. ret = v4l2_subdev_call(cx->sd_av, vbi, s_raw_fmt, &fmt->fmt.vbi);
  293. if (ret)
  294. return ret;
  295. /* Store our new v4l2 (non-)sliced VBI state */
  296. cx->vbi.sliced_in->service_set = 0;
  297. cx->vbi.in.type = V4L2_BUF_TYPE_VBI_CAPTURE;
  298. return cx18_g_fmt_vbi_cap(file, fh, fmt);
  299. }
  300. static int cx18_s_fmt_sliced_vbi_cap(struct file *file, void *fh,
  301. struct v4l2_format *fmt)
  302. {
  303. struct cx18_open_id *id = fh2id(fh);
  304. struct cx18 *cx = id->cx;
  305. int ret;
  306. struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced;
  307. cx18_try_fmt_sliced_vbi_cap(file, fh, fmt);
  308. /*
  309. * Changing the Encoder's Raw VBI parameters won't have any effect
  310. * if any analog capture is ongoing
  311. */
  312. if (cx18_raw_vbi(cx) && atomic_read(&cx->ana_capturing) > 0)
  313. return -EBUSY;
  314. /*
  315. * Set the service_lines requested in the digitizer/slicer registers.
  316. * Note, cx18_av_vbi() wipes some "impossible" service lines in the
  317. * passed in fmt->fmt.sliced under valid calling conditions
  318. */
  319. ret = v4l2_subdev_call(cx->sd_av, vbi, s_sliced_fmt, &fmt->fmt.sliced);
  320. if (ret)
  321. return ret;
  322. /* Store our current v4l2 sliced VBI settings */
  323. cx->vbi.in.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE;
  324. memcpy(cx->vbi.sliced_in, vbifmt, sizeof(*cx->vbi.sliced_in));
  325. return 0;
  326. }
  327. #ifdef CONFIG_VIDEO_ADV_DEBUG
  328. static int cx18_g_register(struct file *file, void *fh,
  329. struct v4l2_dbg_register *reg)
  330. {
  331. struct cx18 *cx = fh2id(fh)->cx;
  332. if (reg->reg & 0x3)
  333. return -EINVAL;
  334. if (reg->reg >= CX18_MEM_OFFSET + CX18_MEM_SIZE)
  335. return -EINVAL;
  336. reg->size = 4;
  337. reg->val = cx18_read_enc(cx, reg->reg);
  338. return 0;
  339. }
  340. static int cx18_s_register(struct file *file, void *fh,
  341. const struct v4l2_dbg_register *reg)
  342. {
  343. struct cx18 *cx = fh2id(fh)->cx;
  344. if (reg->reg & 0x3)
  345. return -EINVAL;
  346. if (reg->reg >= CX18_MEM_OFFSET + CX18_MEM_SIZE)
  347. return -EINVAL;
  348. cx18_write_enc(cx, reg->val, reg->reg);
  349. return 0;
  350. }
  351. #endif
  352. static int cx18_querycap(struct file *file, void *fh,
  353. struct v4l2_capability *vcap)
  354. {
  355. struct cx18_open_id *id = fh2id(fh);
  356. struct cx18_stream *s = video_drvdata(file);
  357. struct cx18 *cx = id->cx;
  358. strlcpy(vcap->driver, CX18_DRIVER_NAME, sizeof(vcap->driver));
  359. strlcpy(vcap->card, cx->card_name, sizeof(vcap->card));
  360. snprintf(vcap->bus_info, sizeof(vcap->bus_info),
  361. "PCI:%s", pci_name(cx->pci_dev));
  362. vcap->capabilities = cx->v4l2_cap; /* capabilities */
  363. vcap->device_caps = s->v4l2_dev_caps; /* device capabilities */
  364. vcap->capabilities |= V4L2_CAP_DEVICE_CAPS;
  365. return 0;
  366. }
  367. static int cx18_enumaudio(struct file *file, void *fh, struct v4l2_audio *vin)
  368. {
  369. struct cx18 *cx = fh2id(fh)->cx;
  370. return cx18_get_audio_input(cx, vin->index, vin);
  371. }
  372. static int cx18_g_audio(struct file *file, void *fh, struct v4l2_audio *vin)
  373. {
  374. struct cx18 *cx = fh2id(fh)->cx;
  375. vin->index = cx->audio_input;
  376. return cx18_get_audio_input(cx, vin->index, vin);
  377. }
  378. static int cx18_s_audio(struct file *file, void *fh, const struct v4l2_audio *vout)
  379. {
  380. struct cx18 *cx = fh2id(fh)->cx;
  381. if (vout->index >= cx->nof_audio_inputs)
  382. return -EINVAL;
  383. cx->audio_input = vout->index;
  384. cx18_audio_set_io(cx);
  385. return 0;
  386. }
  387. static int cx18_enum_input(struct file *file, void *fh, struct v4l2_input *vin)
  388. {
  389. struct cx18 *cx = fh2id(fh)->cx;
  390. /* set it to defaults from our table */
  391. return cx18_get_input(cx, vin->index, vin);
  392. }
  393. static int cx18_cropcap(struct file *file, void *fh,
  394. struct v4l2_cropcap *cropcap)
  395. {
  396. struct cx18 *cx = fh2id(fh)->cx;
  397. if (cropcap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
  398. return -EINVAL;
  399. cropcap->pixelaspect.numerator = cx->is_50hz ? 54 : 11;
  400. cropcap->pixelaspect.denominator = cx->is_50hz ? 59 : 10;
  401. return 0;
  402. }
  403. static int cx18_g_selection(struct file *file, void *fh,
  404. struct v4l2_selection *sel)
  405. {
  406. struct cx18 *cx = fh2id(fh)->cx;
  407. if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
  408. return -EINVAL;
  409. switch (sel->target) {
  410. case V4L2_SEL_TGT_CROP_BOUNDS:
  411. case V4L2_SEL_TGT_CROP_DEFAULT:
  412. sel->r.top = sel->r.left = 0;
  413. sel->r.width = 720;
  414. sel->r.height = cx->is_50hz ? 576 : 480;
  415. break;
  416. default:
  417. return -EINVAL;
  418. }
  419. return 0;
  420. }
  421. static int cx18_enum_fmt_vid_cap(struct file *file, void *fh,
  422. struct v4l2_fmtdesc *fmt)
  423. {
  424. static const struct v4l2_fmtdesc formats[] = {
  425. { 0, V4L2_BUF_TYPE_VIDEO_CAPTURE, 0,
  426. "HM12 (YUV 4:1:1)", V4L2_PIX_FMT_HM12, { 0, 0, 0, 0 }
  427. },
  428. { 1, V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FMT_FLAG_COMPRESSED,
  429. "MPEG", V4L2_PIX_FMT_MPEG, { 0, 0, 0, 0 }
  430. },
  431. { 2, V4L2_BUF_TYPE_VIDEO_CAPTURE, 0,
  432. "UYVY 4:2:2", V4L2_PIX_FMT_UYVY, { 0, 0, 0, 0 }
  433. },
  434. };
  435. if (fmt->index > ARRAY_SIZE(formats) - 1)
  436. return -EINVAL;
  437. *fmt = formats[fmt->index];
  438. return 0;
  439. }
  440. static int cx18_g_input(struct file *file, void *fh, unsigned int *i)
  441. {
  442. struct cx18 *cx = fh2id(fh)->cx;
  443. *i = cx->active_input;
  444. return 0;
  445. }
  446. int cx18_s_input(struct file *file, void *fh, unsigned int inp)
  447. {
  448. struct cx18_open_id *id = fh2id(fh);
  449. struct cx18 *cx = id->cx;
  450. v4l2_std_id std = V4L2_STD_ALL;
  451. const struct cx18_card_video_input *card_input =
  452. cx->card->video_inputs + inp;
  453. if (inp >= cx->nof_inputs)
  454. return -EINVAL;
  455. if (inp == cx->active_input) {
  456. CX18_DEBUG_INFO("Input unchanged\n");
  457. return 0;
  458. }
  459. CX18_DEBUG_INFO("Changing input from %d to %d\n",
  460. cx->active_input, inp);
  461. cx->active_input = inp;
  462. /* Set the audio input to whatever is appropriate for the input type. */
  463. cx->audio_input = cx->card->video_inputs[inp].audio_index;
  464. if (card_input->video_type == V4L2_INPUT_TYPE_TUNER)
  465. std = cx->tuner_std;
  466. cx->streams[CX18_ENC_STREAM_TYPE_MPG].video_dev.tvnorms = std;
  467. cx->streams[CX18_ENC_STREAM_TYPE_YUV].video_dev.tvnorms = std;
  468. cx->streams[CX18_ENC_STREAM_TYPE_VBI].video_dev.tvnorms = std;
  469. /* prevent others from messing with the streams until
  470. we're finished changing inputs. */
  471. cx18_mute(cx);
  472. cx18_video_set_io(cx);
  473. cx18_audio_set_io(cx);
  474. cx18_unmute(cx);
  475. return 0;
  476. }
  477. static int cx18_g_frequency(struct file *file, void *fh,
  478. struct v4l2_frequency *vf)
  479. {
  480. struct cx18 *cx = fh2id(fh)->cx;
  481. if (vf->tuner != 0)
  482. return -EINVAL;
  483. cx18_call_all(cx, tuner, g_frequency, vf);
  484. return 0;
  485. }
  486. int cx18_s_frequency(struct file *file, void *fh, const struct v4l2_frequency *vf)
  487. {
  488. struct cx18_open_id *id = fh2id(fh);
  489. struct cx18 *cx = id->cx;
  490. if (vf->tuner != 0)
  491. return -EINVAL;
  492. cx18_mute(cx);
  493. CX18_DEBUG_INFO("v4l2 ioctl: set frequency %d\n", vf->frequency);
  494. cx18_call_all(cx, tuner, s_frequency, vf);
  495. cx18_unmute(cx);
  496. return 0;
  497. }
  498. static int cx18_g_std(struct file *file, void *fh, v4l2_std_id *std)
  499. {
  500. struct cx18 *cx = fh2id(fh)->cx;
  501. *std = cx->std;
  502. return 0;
  503. }
  504. int cx18_s_std(struct file *file, void *fh, v4l2_std_id std)
  505. {
  506. struct cx18_open_id *id = fh2id(fh);
  507. struct cx18 *cx = id->cx;
  508. if ((std & V4L2_STD_ALL) == 0)
  509. return -EINVAL;
  510. if (std == cx->std)
  511. return 0;
  512. if (test_bit(CX18_F_I_RADIO_USER, &cx->i_flags) ||
  513. atomic_read(&cx->ana_capturing) > 0) {
  514. /* Switching standard would turn off the radio or mess
  515. with already running streams, prevent that by
  516. returning EBUSY. */
  517. return -EBUSY;
  518. }
  519. cx->std = std;
  520. cx->is_60hz = (std & V4L2_STD_525_60) ? 1 : 0;
  521. cx->is_50hz = !cx->is_60hz;
  522. cx2341x_handler_set_50hz(&cx->cxhdl, cx->is_50hz);
  523. cx->cxhdl.width = 720;
  524. cx->cxhdl.height = cx->is_50hz ? 576 : 480;
  525. cx->vbi.count = cx->is_50hz ? 18 : 12;
  526. cx->vbi.start[0] = cx->is_50hz ? 6 : 10;
  527. cx->vbi.start[1] = cx->is_50hz ? 318 : 273;
  528. CX18_DEBUG_INFO("Switching standard to %llx.\n",
  529. (unsigned long long) cx->std);
  530. /* Tuner */
  531. cx18_call_all(cx, video, s_std, cx->std);
  532. return 0;
  533. }
  534. static int cx18_s_tuner(struct file *file, void *fh, const struct v4l2_tuner *vt)
  535. {
  536. struct cx18_open_id *id = fh2id(fh);
  537. struct cx18 *cx = id->cx;
  538. if (vt->index != 0)
  539. return -EINVAL;
  540. cx18_call_all(cx, tuner, s_tuner, vt);
  541. return 0;
  542. }
  543. static int cx18_g_tuner(struct file *file, void *fh, struct v4l2_tuner *vt)
  544. {
  545. struct cx18 *cx = fh2id(fh)->cx;
  546. if (vt->index != 0)
  547. return -EINVAL;
  548. cx18_call_all(cx, tuner, g_tuner, vt);
  549. if (vt->type == V4L2_TUNER_RADIO)
  550. strlcpy(vt->name, "cx18 Radio Tuner", sizeof(vt->name));
  551. else
  552. strlcpy(vt->name, "cx18 TV Tuner", sizeof(vt->name));
  553. return 0;
  554. }
  555. static int cx18_g_sliced_vbi_cap(struct file *file, void *fh,
  556. struct v4l2_sliced_vbi_cap *cap)
  557. {
  558. struct cx18 *cx = fh2id(fh)->cx;
  559. int set = cx->is_50hz ? V4L2_SLICED_VBI_625 : V4L2_SLICED_VBI_525;
  560. int f, l;
  561. if (cap->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE)
  562. return -EINVAL;
  563. cap->service_set = 0;
  564. for (f = 0; f < 2; f++) {
  565. for (l = 0; l < 24; l++) {
  566. if (valid_service_line(f, l, cx->is_50hz)) {
  567. /*
  568. * We can find all v4l2 supported vbi services
  569. * for the standard, on a valid line for the std
  570. */
  571. cap->service_lines[f][l] = set;
  572. cap->service_set |= set;
  573. } else
  574. cap->service_lines[f][l] = 0;
  575. }
  576. }
  577. for (f = 0; f < 3; f++)
  578. cap->reserved[f] = 0;
  579. return 0;
  580. }
  581. static int _cx18_process_idx_data(struct cx18_buffer *buf,
  582. struct v4l2_enc_idx *idx)
  583. {
  584. int consumed, remaining;
  585. struct v4l2_enc_idx_entry *e_idx;
  586. struct cx18_enc_idx_entry *e_buf;
  587. /* Frame type lookup: 1=I, 2=P, 4=B */
  588. const int mapping[8] = {
  589. -1, V4L2_ENC_IDX_FRAME_I, V4L2_ENC_IDX_FRAME_P,
  590. -1, V4L2_ENC_IDX_FRAME_B, -1, -1, -1
  591. };
  592. /*
  593. * Assumption here is that a buf holds an integral number of
  594. * struct cx18_enc_idx_entry objects and is properly aligned.
  595. * This is enforced by the module options on IDX buffer sizes.
  596. */
  597. remaining = buf->bytesused - buf->readpos;
  598. consumed = 0;
  599. e_idx = &idx->entry[idx->entries];
  600. e_buf = (struct cx18_enc_idx_entry *) &buf->buf[buf->readpos];
  601. while (remaining >= sizeof(struct cx18_enc_idx_entry) &&
  602. idx->entries < V4L2_ENC_IDX_ENTRIES) {
  603. e_idx->offset = (((u64) le32_to_cpu(e_buf->offset_high)) << 32)
  604. | le32_to_cpu(e_buf->offset_low);
  605. e_idx->pts = (((u64) (le32_to_cpu(e_buf->pts_high) & 1)) << 32)
  606. | le32_to_cpu(e_buf->pts_low);
  607. e_idx->length = le32_to_cpu(e_buf->length);
  608. e_idx->flags = mapping[le32_to_cpu(e_buf->flags) & 0x7];
  609. e_idx->reserved[0] = 0;
  610. e_idx->reserved[1] = 0;
  611. idx->entries++;
  612. e_idx = &idx->entry[idx->entries];
  613. e_buf++;
  614. remaining -= sizeof(struct cx18_enc_idx_entry);
  615. consumed += sizeof(struct cx18_enc_idx_entry);
  616. }
  617. /* Swallow any partial entries at the end, if there are any */
  618. if (remaining > 0 && remaining < sizeof(struct cx18_enc_idx_entry))
  619. consumed += remaining;
  620. buf->readpos += consumed;
  621. return consumed;
  622. }
  623. static int cx18_process_idx_data(struct cx18_stream *s, struct cx18_mdl *mdl,
  624. struct v4l2_enc_idx *idx)
  625. {
  626. if (s->type != CX18_ENC_STREAM_TYPE_IDX)
  627. return -EINVAL;
  628. if (mdl->curr_buf == NULL)
  629. mdl->curr_buf = list_first_entry(&mdl->buf_list,
  630. struct cx18_buffer, list);
  631. if (list_entry_is_past_end(mdl->curr_buf, &mdl->buf_list, list)) {
  632. /*
  633. * For some reason we've exhausted the buffers, but the MDL
  634. * object still said some data was unread.
  635. * Fix that and bail out.
  636. */
  637. mdl->readpos = mdl->bytesused;
  638. return 0;
  639. }
  640. list_for_each_entry_from(mdl->curr_buf, &mdl->buf_list, list) {
  641. /* Skip any empty buffers in the MDL */
  642. if (mdl->curr_buf->readpos >= mdl->curr_buf->bytesused)
  643. continue;
  644. mdl->readpos += _cx18_process_idx_data(mdl->curr_buf, idx);
  645. /* exit when MDL drained or request satisfied */
  646. if (idx->entries >= V4L2_ENC_IDX_ENTRIES ||
  647. mdl->curr_buf->readpos < mdl->curr_buf->bytesused ||
  648. mdl->readpos >= mdl->bytesused)
  649. break;
  650. }
  651. return 0;
  652. }
  653. static int cx18_g_enc_index(struct file *file, void *fh,
  654. struct v4l2_enc_idx *idx)
  655. {
  656. struct cx18 *cx = fh2id(fh)->cx;
  657. struct cx18_stream *s = &cx->streams[CX18_ENC_STREAM_TYPE_IDX];
  658. s32 tmp;
  659. struct cx18_mdl *mdl;
  660. if (!cx18_stream_enabled(s)) /* Module options inhibited IDX stream */
  661. return -EINVAL;
  662. /* Compute the best case number of entries we can buffer */
  663. tmp = s->buffers -
  664. s->bufs_per_mdl * CX18_ENC_STREAM_TYPE_IDX_FW_MDL_MIN;
  665. if (tmp <= 0)
  666. tmp = 1;
  667. tmp = tmp * s->buf_size / sizeof(struct cx18_enc_idx_entry);
  668. /* Fill out the header of the return structure */
  669. idx->entries = 0;
  670. idx->entries_cap = tmp;
  671. memset(idx->reserved, 0, sizeof(idx->reserved));
  672. /* Pull IDX MDLs and buffers from q_full and populate the entries */
  673. do {
  674. mdl = cx18_dequeue(s, &s->q_full);
  675. if (mdl == NULL) /* No more IDX data right now */
  676. break;
  677. /* Extract the Index entry data from the MDL and buffers */
  678. cx18_process_idx_data(s, mdl, idx);
  679. if (mdl->readpos < mdl->bytesused) {
  680. /* We finished with data remaining, push the MDL back */
  681. cx18_push(s, mdl, &s->q_full);
  682. break;
  683. }
  684. /* We drained this MDL, schedule it to go to the firmware */
  685. cx18_enqueue(s, mdl, &s->q_free);
  686. } while (idx->entries < V4L2_ENC_IDX_ENTRIES);
  687. /* Tell the work handler to send free IDX MDLs to the firmware */
  688. cx18_stream_load_fw_queue(s);
  689. return 0;
  690. }
  691. static struct videobuf_queue *cx18_vb_queue(struct cx18_open_id *id)
  692. {
  693. struct videobuf_queue *q = NULL;
  694. struct cx18 *cx = id->cx;
  695. struct cx18_stream *s = &cx->streams[id->type];
  696. switch (s->vb_type) {
  697. case V4L2_BUF_TYPE_VIDEO_CAPTURE:
  698. q = &s->vbuf_q;
  699. break;
  700. case V4L2_BUF_TYPE_VBI_CAPTURE:
  701. break;
  702. default:
  703. break;
  704. }
  705. return q;
  706. }
  707. static int cx18_streamon(struct file *file, void *priv,
  708. enum v4l2_buf_type type)
  709. {
  710. struct cx18_open_id *id = file->private_data;
  711. struct cx18 *cx = id->cx;
  712. struct cx18_stream *s = &cx->streams[id->type];
  713. /* Start the hardware only if we're the video device */
  714. if ((s->vb_type != V4L2_BUF_TYPE_VIDEO_CAPTURE) &&
  715. (s->vb_type != V4L2_BUF_TYPE_VBI_CAPTURE))
  716. return -EINVAL;
  717. if (id->type != CX18_ENC_STREAM_TYPE_YUV)
  718. return -EINVAL;
  719. /* Establish a buffer timeout */
  720. mod_timer(&s->vb_timeout, msecs_to_jiffies(2000) + jiffies);
  721. return videobuf_streamon(cx18_vb_queue(id));
  722. }
  723. static int cx18_streamoff(struct file *file, void *priv,
  724. enum v4l2_buf_type type)
  725. {
  726. struct cx18_open_id *id = file->private_data;
  727. struct cx18 *cx = id->cx;
  728. struct cx18_stream *s = &cx->streams[id->type];
  729. /* Start the hardware only if we're the video device */
  730. if ((s->vb_type != V4L2_BUF_TYPE_VIDEO_CAPTURE) &&
  731. (s->vb_type != V4L2_BUF_TYPE_VBI_CAPTURE))
  732. return -EINVAL;
  733. if (id->type != CX18_ENC_STREAM_TYPE_YUV)
  734. return -EINVAL;
  735. return videobuf_streamoff(cx18_vb_queue(id));
  736. }
  737. static int cx18_reqbufs(struct file *file, void *priv,
  738. struct v4l2_requestbuffers *rb)
  739. {
  740. struct cx18_open_id *id = file->private_data;
  741. struct cx18 *cx = id->cx;
  742. struct cx18_stream *s = &cx->streams[id->type];
  743. if ((s->vb_type != V4L2_BUF_TYPE_VIDEO_CAPTURE) &&
  744. (s->vb_type != V4L2_BUF_TYPE_VBI_CAPTURE))
  745. return -EINVAL;
  746. return videobuf_reqbufs(cx18_vb_queue(id), rb);
  747. }
  748. static int cx18_querybuf(struct file *file, void *priv,
  749. struct v4l2_buffer *b)
  750. {
  751. struct cx18_open_id *id = file->private_data;
  752. struct cx18 *cx = id->cx;
  753. struct cx18_stream *s = &cx->streams[id->type];
  754. if ((s->vb_type != V4L2_BUF_TYPE_VIDEO_CAPTURE) &&
  755. (s->vb_type != V4L2_BUF_TYPE_VBI_CAPTURE))
  756. return -EINVAL;
  757. return videobuf_querybuf(cx18_vb_queue(id), b);
  758. }
  759. static int cx18_qbuf(struct file *file, void *priv, struct v4l2_buffer *b)
  760. {
  761. struct cx18_open_id *id = file->private_data;
  762. struct cx18 *cx = id->cx;
  763. struct cx18_stream *s = &cx->streams[id->type];
  764. if ((s->vb_type != V4L2_BUF_TYPE_VIDEO_CAPTURE) &&
  765. (s->vb_type != V4L2_BUF_TYPE_VBI_CAPTURE))
  766. return -EINVAL;
  767. return videobuf_qbuf(cx18_vb_queue(id), b);
  768. }
  769. static int cx18_dqbuf(struct file *file, void *priv, struct v4l2_buffer *b)
  770. {
  771. struct cx18_open_id *id = file->private_data;
  772. struct cx18 *cx = id->cx;
  773. struct cx18_stream *s = &cx->streams[id->type];
  774. if ((s->vb_type != V4L2_BUF_TYPE_VIDEO_CAPTURE) &&
  775. (s->vb_type != V4L2_BUF_TYPE_VBI_CAPTURE))
  776. return -EINVAL;
  777. return videobuf_dqbuf(cx18_vb_queue(id), b, file->f_flags & O_NONBLOCK);
  778. }
  779. static int cx18_encoder_cmd(struct file *file, void *fh,
  780. struct v4l2_encoder_cmd *enc)
  781. {
  782. struct cx18_open_id *id = fh2id(fh);
  783. struct cx18 *cx = id->cx;
  784. u32 h;
  785. switch (enc->cmd) {
  786. case V4L2_ENC_CMD_START:
  787. CX18_DEBUG_IOCTL("V4L2_ENC_CMD_START\n");
  788. enc->flags = 0;
  789. return cx18_start_capture(id);
  790. case V4L2_ENC_CMD_STOP:
  791. CX18_DEBUG_IOCTL("V4L2_ENC_CMD_STOP\n");
  792. enc->flags &= V4L2_ENC_CMD_STOP_AT_GOP_END;
  793. cx18_stop_capture(id,
  794. enc->flags & V4L2_ENC_CMD_STOP_AT_GOP_END);
  795. break;
  796. case V4L2_ENC_CMD_PAUSE:
  797. CX18_DEBUG_IOCTL("V4L2_ENC_CMD_PAUSE\n");
  798. enc->flags = 0;
  799. if (!atomic_read(&cx->ana_capturing))
  800. return -EPERM;
  801. if (test_and_set_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags))
  802. return 0;
  803. h = cx18_find_handle(cx);
  804. if (h == CX18_INVALID_TASK_HANDLE) {
  805. CX18_ERR("Can't find valid task handle for "
  806. "V4L2_ENC_CMD_PAUSE\n");
  807. return -EBADFD;
  808. }
  809. cx18_mute(cx);
  810. cx18_vapi(cx, CX18_CPU_CAPTURE_PAUSE, 1, h);
  811. break;
  812. case V4L2_ENC_CMD_RESUME:
  813. CX18_DEBUG_IOCTL("V4L2_ENC_CMD_RESUME\n");
  814. enc->flags = 0;
  815. if (!atomic_read(&cx->ana_capturing))
  816. return -EPERM;
  817. if (!test_and_clear_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags))
  818. return 0;
  819. h = cx18_find_handle(cx);
  820. if (h == CX18_INVALID_TASK_HANDLE) {
  821. CX18_ERR("Can't find valid task handle for "
  822. "V4L2_ENC_CMD_RESUME\n");
  823. return -EBADFD;
  824. }
  825. cx18_vapi(cx, CX18_CPU_CAPTURE_RESUME, 1, h);
  826. cx18_unmute(cx);
  827. break;
  828. default:
  829. CX18_DEBUG_IOCTL("Unknown cmd %d\n", enc->cmd);
  830. return -EINVAL;
  831. }
  832. return 0;
  833. }
  834. static int cx18_try_encoder_cmd(struct file *file, void *fh,
  835. struct v4l2_encoder_cmd *enc)
  836. {
  837. struct cx18 *cx = fh2id(fh)->cx;
  838. switch (enc->cmd) {
  839. case V4L2_ENC_CMD_START:
  840. CX18_DEBUG_IOCTL("V4L2_ENC_CMD_START\n");
  841. enc->flags = 0;
  842. break;
  843. case V4L2_ENC_CMD_STOP:
  844. CX18_DEBUG_IOCTL("V4L2_ENC_CMD_STOP\n");
  845. enc->flags &= V4L2_ENC_CMD_STOP_AT_GOP_END;
  846. break;
  847. case V4L2_ENC_CMD_PAUSE:
  848. CX18_DEBUG_IOCTL("V4L2_ENC_CMD_PAUSE\n");
  849. enc->flags = 0;
  850. break;
  851. case V4L2_ENC_CMD_RESUME:
  852. CX18_DEBUG_IOCTL("V4L2_ENC_CMD_RESUME\n");
  853. enc->flags = 0;
  854. break;
  855. default:
  856. CX18_DEBUG_IOCTL("Unknown cmd %d\n", enc->cmd);
  857. return -EINVAL;
  858. }
  859. return 0;
  860. }
  861. static int cx18_log_status(struct file *file, void *fh)
  862. {
  863. struct cx18 *cx = fh2id(fh)->cx;
  864. struct v4l2_input vidin;
  865. struct v4l2_audio audin;
  866. int i;
  867. CX18_INFO("Version: %s Card: %s\n", CX18_VERSION, cx->card_name);
  868. if (cx->hw_flags & CX18_HW_TVEEPROM) {
  869. struct tveeprom tv;
  870. cx18_read_eeprom(cx, &tv);
  871. }
  872. cx18_call_all(cx, core, log_status);
  873. cx18_get_input(cx, cx->active_input, &vidin);
  874. cx18_get_audio_input(cx, cx->audio_input, &audin);
  875. CX18_INFO("Video Input: %s\n", vidin.name);
  876. CX18_INFO("Audio Input: %s\n", audin.name);
  877. mutex_lock(&cx->gpio_lock);
  878. CX18_INFO("GPIO: direction 0x%08x, value 0x%08x\n",
  879. cx->gpio_dir, cx->gpio_val);
  880. mutex_unlock(&cx->gpio_lock);
  881. CX18_INFO("Tuner: %s\n",
  882. test_bit(CX18_F_I_RADIO_USER, &cx->i_flags) ? "Radio" : "TV");
  883. v4l2_ctrl_handler_log_status(&cx->cxhdl.hdl, cx->v4l2_dev.name);
  884. CX18_INFO("Status flags: 0x%08lx\n", cx->i_flags);
  885. for (i = 0; i < CX18_MAX_STREAMS; i++) {
  886. struct cx18_stream *s = &cx->streams[i];
  887. if (s->video_dev.v4l2_dev == NULL || s->buffers == 0)
  888. continue;
  889. CX18_INFO("Stream %s: status 0x%04lx, %d%% of %d KiB (%d buffers) in use\n",
  890. s->name, s->s_flags,
  891. atomic_read(&s->q_full.depth) * s->bufs_per_mdl * 100
  892. / s->buffers,
  893. (s->buffers * s->buf_size) / 1024, s->buffers);
  894. }
  895. CX18_INFO("Read MPEG/VBI: %lld/%lld bytes\n",
  896. (long long)cx->mpg_data_received,
  897. (long long)cx->vbi_data_inserted);
  898. return 0;
  899. }
  900. static long cx18_default(struct file *file, void *fh, bool valid_prio,
  901. unsigned int cmd, void *arg)
  902. {
  903. struct cx18 *cx = fh2id(fh)->cx;
  904. switch (cmd) {
  905. case VIDIOC_INT_RESET: {
  906. u32 val = *(u32 *)arg;
  907. if ((val == 0) || (val & 0x01))
  908. cx18_call_hw(cx, CX18_HW_GPIO_RESET_CTRL, core, reset,
  909. (u32) CX18_GPIO_RESET_Z8F0811);
  910. break;
  911. }
  912. default:
  913. return -ENOTTY;
  914. }
  915. return 0;
  916. }
  917. static const struct v4l2_ioctl_ops cx18_ioctl_ops = {
  918. .vidioc_querycap = cx18_querycap,
  919. .vidioc_s_audio = cx18_s_audio,
  920. .vidioc_g_audio = cx18_g_audio,
  921. .vidioc_enumaudio = cx18_enumaudio,
  922. .vidioc_enum_input = cx18_enum_input,
  923. .vidioc_cropcap = cx18_cropcap,
  924. .vidioc_g_selection = cx18_g_selection,
  925. .vidioc_g_input = cx18_g_input,
  926. .vidioc_s_input = cx18_s_input,
  927. .vidioc_g_frequency = cx18_g_frequency,
  928. .vidioc_s_frequency = cx18_s_frequency,
  929. .vidioc_s_tuner = cx18_s_tuner,
  930. .vidioc_g_tuner = cx18_g_tuner,
  931. .vidioc_g_enc_index = cx18_g_enc_index,
  932. .vidioc_g_std = cx18_g_std,
  933. .vidioc_s_std = cx18_s_std,
  934. .vidioc_log_status = cx18_log_status,
  935. .vidioc_enum_fmt_vid_cap = cx18_enum_fmt_vid_cap,
  936. .vidioc_encoder_cmd = cx18_encoder_cmd,
  937. .vidioc_try_encoder_cmd = cx18_try_encoder_cmd,
  938. .vidioc_g_fmt_vid_cap = cx18_g_fmt_vid_cap,
  939. .vidioc_g_fmt_vbi_cap = cx18_g_fmt_vbi_cap,
  940. .vidioc_g_fmt_sliced_vbi_cap = cx18_g_fmt_sliced_vbi_cap,
  941. .vidioc_s_fmt_vid_cap = cx18_s_fmt_vid_cap,
  942. .vidioc_s_fmt_vbi_cap = cx18_s_fmt_vbi_cap,
  943. .vidioc_s_fmt_sliced_vbi_cap = cx18_s_fmt_sliced_vbi_cap,
  944. .vidioc_try_fmt_vid_cap = cx18_try_fmt_vid_cap,
  945. .vidioc_try_fmt_vbi_cap = cx18_try_fmt_vbi_cap,
  946. .vidioc_try_fmt_sliced_vbi_cap = cx18_try_fmt_sliced_vbi_cap,
  947. .vidioc_g_sliced_vbi_cap = cx18_g_sliced_vbi_cap,
  948. #ifdef CONFIG_VIDEO_ADV_DEBUG
  949. .vidioc_g_register = cx18_g_register,
  950. .vidioc_s_register = cx18_s_register,
  951. #endif
  952. .vidioc_default = cx18_default,
  953. .vidioc_streamon = cx18_streamon,
  954. .vidioc_streamoff = cx18_streamoff,
  955. .vidioc_reqbufs = cx18_reqbufs,
  956. .vidioc_querybuf = cx18_querybuf,
  957. .vidioc_qbuf = cx18_qbuf,
  958. .vidioc_dqbuf = cx18_dqbuf,
  959. .vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
  960. .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
  961. };
  962. void cx18_set_funcs(struct video_device *vdev)
  963. {
  964. vdev->ioctl_ops = &cx18_ioctl_ops;
  965. }