cx18-ioctl.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150
  1. /*
  2. * cx18 ioctl system call
  3. *
  4. * Derived from ivtv-ioctl.c
  5. *
  6. * Copyright (C) 2007 Hans Verkuil <hverkuil@xs4all.nl>
  7. * Copyright (C) 2008 Andy Walls <awalls@md.metrocast.net>
  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-chip-ident.h>
  42. #include <linux/i2c-id.h>
  43. u16 cx18_service2vbi(int type)
  44. {
  45. switch (type) {
  46. case V4L2_SLICED_TELETEXT_B:
  47. return CX18_SLICED_TYPE_TELETEXT_B;
  48. case V4L2_SLICED_CAPTION_525:
  49. return CX18_SLICED_TYPE_CAPTION_525;
  50. case V4L2_SLICED_WSS_625:
  51. return CX18_SLICED_TYPE_WSS_625;
  52. case V4L2_SLICED_VPS:
  53. return CX18_SLICED_TYPE_VPS;
  54. default:
  55. return 0;
  56. }
  57. }
  58. /* Check if VBI services are allowed on the (field, line) for the video std */
  59. static int valid_service_line(int field, int line, int is_pal)
  60. {
  61. return (is_pal && line >= 6 &&
  62. ((field == 0 && line <= 23) || (field == 1 && line <= 22))) ||
  63. (!is_pal && line >= 10 && line < 22);
  64. }
  65. /*
  66. * For a (field, line, std) and inbound potential set of services for that line,
  67. * return the first valid service of those passed in the incoming set for that
  68. * line in priority order:
  69. * CC, VPS, or WSS over TELETEXT for well known lines
  70. * TELETEXT, before VPS, before CC, before WSS, for other lines
  71. */
  72. static u16 select_service_from_set(int field, int line, u16 set, int is_pal)
  73. {
  74. u16 valid_set = (is_pal ? V4L2_SLICED_VBI_625 : V4L2_SLICED_VBI_525);
  75. int i;
  76. set = set & valid_set;
  77. if (set == 0 || !valid_service_line(field, line, is_pal))
  78. return 0;
  79. if (!is_pal) {
  80. if (line == 21 && (set & V4L2_SLICED_CAPTION_525))
  81. return V4L2_SLICED_CAPTION_525;
  82. } else {
  83. if (line == 16 && field == 0 && (set & V4L2_SLICED_VPS))
  84. return V4L2_SLICED_VPS;
  85. if (line == 23 && field == 0 && (set & V4L2_SLICED_WSS_625))
  86. return V4L2_SLICED_WSS_625;
  87. if (line == 23)
  88. return 0;
  89. }
  90. for (i = 0; i < 32; i++) {
  91. if ((1 << i) & set)
  92. return 1 << i;
  93. }
  94. return 0;
  95. }
  96. /*
  97. * Expand the service_set of *fmt into valid service_lines for the std,
  98. * and clear the passed in fmt->service_set
  99. */
  100. void cx18_expand_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal)
  101. {
  102. u16 set = fmt->service_set;
  103. int f, l;
  104. fmt->service_set = 0;
  105. for (f = 0; f < 2; f++) {
  106. for (l = 0; l < 24; l++)
  107. fmt->service_lines[f][l] = select_service_from_set(f, l, set, is_pal);
  108. }
  109. }
  110. /*
  111. * Sanitize the service_lines in *fmt per the video std, and return 1
  112. * if any service_line is left as valid after santization
  113. */
  114. static int check_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal)
  115. {
  116. int f, l;
  117. u16 set = 0;
  118. for (f = 0; f < 2; f++) {
  119. for (l = 0; l < 24; l++) {
  120. fmt->service_lines[f][l] = select_service_from_set(f, l, fmt->service_lines[f][l], is_pal);
  121. set |= fmt->service_lines[f][l];
  122. }
  123. }
  124. return set != 0;
  125. }
  126. /* Compute the service_set from the assumed valid service_lines of *fmt */
  127. u16 cx18_get_service_set(struct v4l2_sliced_vbi_format *fmt)
  128. {
  129. int f, l;
  130. u16 set = 0;
  131. for (f = 0; f < 2; f++) {
  132. for (l = 0; l < 24; l++)
  133. set |= fmt->service_lines[f][l];
  134. }
  135. return set;
  136. }
  137. static int cx18_g_fmt_vid_cap(struct file *file, void *fh,
  138. struct v4l2_format *fmt)
  139. {
  140. struct cx18_open_id *id = fh;
  141. struct cx18 *cx = id->cx;
  142. struct v4l2_pix_format *pixfmt = &fmt->fmt.pix;
  143. pixfmt->width = cx->params.width;
  144. pixfmt->height = cx->params.height;
  145. pixfmt->colorspace = V4L2_COLORSPACE_SMPTE170M;
  146. pixfmt->field = V4L2_FIELD_INTERLACED;
  147. pixfmt->priv = 0;
  148. if (id->type == CX18_ENC_STREAM_TYPE_YUV) {
  149. pixfmt->pixelformat = V4L2_PIX_FMT_HM12;
  150. /* YUV size is (Y=(h*720) + UV=(h*(720/2))) */
  151. pixfmt->sizeimage = pixfmt->height * 720 * 3 / 2;
  152. pixfmt->bytesperline = 720;
  153. } else {
  154. pixfmt->pixelformat = V4L2_PIX_FMT_MPEG;
  155. pixfmt->sizeimage = 128 * 1024;
  156. pixfmt->bytesperline = 0;
  157. }
  158. return 0;
  159. }
  160. static int cx18_g_fmt_vbi_cap(struct file *file, void *fh,
  161. struct v4l2_format *fmt)
  162. {
  163. struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
  164. struct v4l2_vbi_format *vbifmt = &fmt->fmt.vbi;
  165. vbifmt->sampling_rate = 27000000;
  166. vbifmt->offset = 248; /* FIXME - slightly wrong for both 50 & 60 Hz */
  167. vbifmt->samples_per_line = vbi_active_samples - 4;
  168. vbifmt->sample_format = V4L2_PIX_FMT_GREY;
  169. vbifmt->start[0] = cx->vbi.start[0];
  170. vbifmt->start[1] = cx->vbi.start[1];
  171. vbifmt->count[0] = vbifmt->count[1] = cx->vbi.count;
  172. vbifmt->flags = 0;
  173. vbifmt->reserved[0] = 0;
  174. vbifmt->reserved[1] = 0;
  175. return 0;
  176. }
  177. static int cx18_g_fmt_sliced_vbi_cap(struct file *file, void *fh,
  178. struct v4l2_format *fmt)
  179. {
  180. struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
  181. struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced;
  182. /* sane, V4L2 spec compliant, defaults */
  183. vbifmt->reserved[0] = 0;
  184. vbifmt->reserved[1] = 0;
  185. vbifmt->io_size = sizeof(struct v4l2_sliced_vbi_data) * 36;
  186. memset(vbifmt->service_lines, 0, sizeof(vbifmt->service_lines));
  187. vbifmt->service_set = 0;
  188. /*
  189. * Fetch the configured service_lines and total service_set from the
  190. * digitizer/slicer. Note, cx18_av_vbi() wipes the passed in
  191. * fmt->fmt.sliced under valid calling conditions
  192. */
  193. if (v4l2_subdev_call(cx->sd_av, vbi, g_sliced_fmt, &fmt->fmt.sliced))
  194. return -EINVAL;
  195. /* Ensure V4L2 spec compliant output */
  196. vbifmt->reserved[0] = 0;
  197. vbifmt->reserved[1] = 0;
  198. vbifmt->io_size = sizeof(struct v4l2_sliced_vbi_data) * 36;
  199. vbifmt->service_set = cx18_get_service_set(vbifmt);
  200. return 0;
  201. }
  202. static int cx18_try_fmt_vid_cap(struct file *file, void *fh,
  203. struct v4l2_format *fmt)
  204. {
  205. struct cx18_open_id *id = fh;
  206. struct cx18 *cx = id->cx;
  207. int w = fmt->fmt.pix.width;
  208. int h = fmt->fmt.pix.height;
  209. int min_h = 2;
  210. w = min(w, 720);
  211. w = max(w, 2);
  212. if (id->type == CX18_ENC_STREAM_TYPE_YUV) {
  213. /* YUV height must be a multiple of 32 */
  214. h &= ~0x1f;
  215. min_h = 32;
  216. }
  217. h = min(h, cx->is_50hz ? 576 : 480);
  218. h = max(h, min_h);
  219. cx18_g_fmt_vid_cap(file, fh, fmt);
  220. fmt->fmt.pix.width = w;
  221. fmt->fmt.pix.height = h;
  222. return 0;
  223. }
  224. static int cx18_try_fmt_vbi_cap(struct file *file, void *fh,
  225. struct v4l2_format *fmt)
  226. {
  227. return cx18_g_fmt_vbi_cap(file, fh, fmt);
  228. }
  229. static int cx18_try_fmt_sliced_vbi_cap(struct file *file, void *fh,
  230. struct v4l2_format *fmt)
  231. {
  232. struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
  233. struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced;
  234. vbifmt->io_size = sizeof(struct v4l2_sliced_vbi_data) * 36;
  235. vbifmt->reserved[0] = 0;
  236. vbifmt->reserved[1] = 0;
  237. /* If given a service set, expand it validly & clear passed in set */
  238. if (vbifmt->service_set)
  239. cx18_expand_service_set(vbifmt, cx->is_50hz);
  240. /* Sanitize the service_lines, and compute the new set if any valid */
  241. if (check_service_set(vbifmt, cx->is_50hz))
  242. vbifmt->service_set = cx18_get_service_set(vbifmt);
  243. return 0;
  244. }
  245. static int cx18_s_fmt_vid_cap(struct file *file, void *fh,
  246. struct v4l2_format *fmt)
  247. {
  248. struct cx18_open_id *id = fh;
  249. struct cx18 *cx = id->cx;
  250. struct v4l2_mbus_framefmt mbus_fmt;
  251. int ret;
  252. int w, h;
  253. ret = v4l2_prio_check(&cx->prio, id->prio);
  254. if (ret)
  255. return ret;
  256. ret = cx18_try_fmt_vid_cap(file, fh, fmt);
  257. if (ret)
  258. return ret;
  259. w = fmt->fmt.pix.width;
  260. h = fmt->fmt.pix.height;
  261. if (cx->params.width == w && cx->params.height == h)
  262. return 0;
  263. if (atomic_read(&cx->ana_capturing) > 0)
  264. return -EBUSY;
  265. mbus_fmt.width = cx->params.width = w;
  266. mbus_fmt.height = cx->params.height = h;
  267. mbus_fmt.code = V4L2_MBUS_FMT_FIXED;
  268. v4l2_subdev_call(cx->sd_av, video, s_mbus_fmt, &mbus_fmt);
  269. return cx18_g_fmt_vid_cap(file, fh, fmt);
  270. }
  271. static int cx18_s_fmt_vbi_cap(struct file *file, void *fh,
  272. struct v4l2_format *fmt)
  273. {
  274. struct cx18_open_id *id = fh;
  275. struct cx18 *cx = id->cx;
  276. int ret;
  277. ret = v4l2_prio_check(&cx->prio, id->prio);
  278. if (ret)
  279. return ret;
  280. /*
  281. * Changing the Encoder's Raw VBI parameters won't have any effect
  282. * if any analog capture is ongoing
  283. */
  284. if (!cx18_raw_vbi(cx) && atomic_read(&cx->ana_capturing) > 0)
  285. return -EBUSY;
  286. /*
  287. * Set the digitizer registers for raw active VBI.
  288. * Note cx18_av_vbi_wipes out alot of the passed in fmt under valid
  289. * calling conditions
  290. */
  291. ret = v4l2_subdev_call(cx->sd_av, vbi, s_raw_fmt, &fmt->fmt.vbi);
  292. if (ret)
  293. return ret;
  294. /* Store our new v4l2 (non-)sliced VBI state */
  295. cx->vbi.sliced_in->service_set = 0;
  296. cx->vbi.in.type = V4L2_BUF_TYPE_VBI_CAPTURE;
  297. return cx18_g_fmt_vbi_cap(file, fh, fmt);
  298. }
  299. static int cx18_s_fmt_sliced_vbi_cap(struct file *file, void *fh,
  300. struct v4l2_format *fmt)
  301. {
  302. struct cx18_open_id *id = fh;
  303. struct cx18 *cx = id->cx;
  304. int ret;
  305. struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced;
  306. ret = v4l2_prio_check(&cx->prio, id->prio);
  307. if (ret)
  308. return ret;
  309. cx18_try_fmt_sliced_vbi_cap(file, fh, fmt);
  310. /*
  311. * Changing the Encoder's Raw VBI parameters won't have any effect
  312. * if any analog capture is ongoing
  313. */
  314. if (cx18_raw_vbi(cx) && atomic_read(&cx->ana_capturing) > 0)
  315. return -EBUSY;
  316. /*
  317. * Set the service_lines requested in the digitizer/slicer registers.
  318. * Note, cx18_av_vbi() wipes some "impossible" service lines in the
  319. * passed in fmt->fmt.sliced under valid calling conditions
  320. */
  321. ret = v4l2_subdev_call(cx->sd_av, vbi, s_sliced_fmt, &fmt->fmt.sliced);
  322. if (ret)
  323. return ret;
  324. /* Store our current v4l2 sliced VBI settings */
  325. cx->vbi.in.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE;
  326. memcpy(cx->vbi.sliced_in, vbifmt, sizeof(*cx->vbi.sliced_in));
  327. return 0;
  328. }
  329. static int cx18_g_chip_ident(struct file *file, void *fh,
  330. struct v4l2_dbg_chip_ident *chip)
  331. {
  332. struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
  333. int err = 0;
  334. chip->ident = V4L2_IDENT_NONE;
  335. chip->revision = 0;
  336. switch (chip->match.type) {
  337. case V4L2_CHIP_MATCH_HOST:
  338. switch (chip->match.addr) {
  339. case 0:
  340. chip->ident = V4L2_IDENT_CX23418;
  341. chip->revision = cx18_read_reg(cx, 0xC72028);
  342. break;
  343. case 1:
  344. /*
  345. * The A/V decoder is always present, but in the rare
  346. * case that the card doesn't have analog, we don't
  347. * use it. We find it w/o using the cx->sd_av pointer
  348. */
  349. cx18_call_hw(cx, CX18_HW_418_AV,
  350. core, g_chip_ident, chip);
  351. break;
  352. default:
  353. /*
  354. * Could return ident = V4L2_IDENT_UNKNOWN if we had
  355. * other host chips at higher addresses, but we don't
  356. */
  357. err = -EINVAL; /* per V4L2 spec */
  358. break;
  359. }
  360. break;
  361. case V4L2_CHIP_MATCH_I2C_DRIVER:
  362. /* If needed, returns V4L2_IDENT_AMBIGUOUS without extra work */
  363. cx18_call_all(cx, core, g_chip_ident, chip);
  364. break;
  365. case V4L2_CHIP_MATCH_I2C_ADDR:
  366. /*
  367. * We could return V4L2_IDENT_UNKNOWN, but we don't do the work
  368. * to look if a chip is at the address with no driver. That's a
  369. * dangerous thing to do with EEPROMs anyway.
  370. */
  371. cx18_call_all(cx, core, g_chip_ident, chip);
  372. break;
  373. default:
  374. err = -EINVAL;
  375. break;
  376. }
  377. return err;
  378. }
  379. #ifdef CONFIG_VIDEO_ADV_DEBUG
  380. static int cx18_cxc(struct cx18 *cx, unsigned int cmd, void *arg)
  381. {
  382. struct v4l2_dbg_register *regs = arg;
  383. if (!capable(CAP_SYS_ADMIN))
  384. return -EPERM;
  385. if (regs->reg >= CX18_MEM_OFFSET + CX18_MEM_SIZE)
  386. return -EINVAL;
  387. regs->size = 4;
  388. if (cmd == VIDIOC_DBG_S_REGISTER)
  389. cx18_write_enc(cx, regs->val, regs->reg);
  390. else
  391. regs->val = cx18_read_enc(cx, regs->reg);
  392. return 0;
  393. }
  394. static int cx18_g_register(struct file *file, void *fh,
  395. struct v4l2_dbg_register *reg)
  396. {
  397. struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
  398. if (v4l2_chip_match_host(&reg->match))
  399. return cx18_cxc(cx, VIDIOC_DBG_G_REGISTER, reg);
  400. /* FIXME - errors shouldn't be ignored */
  401. cx18_call_all(cx, core, g_register, reg);
  402. return 0;
  403. }
  404. static int cx18_s_register(struct file *file, void *fh,
  405. struct v4l2_dbg_register *reg)
  406. {
  407. struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
  408. if (v4l2_chip_match_host(&reg->match))
  409. return cx18_cxc(cx, VIDIOC_DBG_S_REGISTER, reg);
  410. /* FIXME - errors shouldn't be ignored */
  411. cx18_call_all(cx, core, s_register, reg);
  412. return 0;
  413. }
  414. #endif
  415. static int cx18_g_priority(struct file *file, void *fh, enum v4l2_priority *p)
  416. {
  417. struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
  418. *p = v4l2_prio_max(&cx->prio);
  419. return 0;
  420. }
  421. static int cx18_s_priority(struct file *file, void *fh, enum v4l2_priority prio)
  422. {
  423. struct cx18_open_id *id = fh;
  424. struct cx18 *cx = id->cx;
  425. return v4l2_prio_change(&cx->prio, &id->prio, prio);
  426. }
  427. static int cx18_querycap(struct file *file, void *fh,
  428. struct v4l2_capability *vcap)
  429. {
  430. struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
  431. strlcpy(vcap->driver, CX18_DRIVER_NAME, sizeof(vcap->driver));
  432. strlcpy(vcap->card, cx->card_name, sizeof(vcap->card));
  433. snprintf(vcap->bus_info, sizeof(vcap->bus_info),
  434. "PCI:%s", pci_name(cx->pci_dev));
  435. vcap->version = CX18_DRIVER_VERSION; /* version */
  436. vcap->capabilities = cx->v4l2_cap; /* capabilities */
  437. return 0;
  438. }
  439. static int cx18_enumaudio(struct file *file, void *fh, struct v4l2_audio *vin)
  440. {
  441. struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
  442. return cx18_get_audio_input(cx, vin->index, vin);
  443. }
  444. static int cx18_g_audio(struct file *file, void *fh, struct v4l2_audio *vin)
  445. {
  446. struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
  447. vin->index = cx->audio_input;
  448. return cx18_get_audio_input(cx, vin->index, vin);
  449. }
  450. static int cx18_s_audio(struct file *file, void *fh, struct v4l2_audio *vout)
  451. {
  452. struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
  453. if (vout->index >= cx->nof_audio_inputs)
  454. return -EINVAL;
  455. cx->audio_input = vout->index;
  456. cx18_audio_set_io(cx);
  457. return 0;
  458. }
  459. static int cx18_enum_input(struct file *file, void *fh, struct v4l2_input *vin)
  460. {
  461. struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
  462. /* set it to defaults from our table */
  463. return cx18_get_input(cx, vin->index, vin);
  464. }
  465. static int cx18_cropcap(struct file *file, void *fh,
  466. struct v4l2_cropcap *cropcap)
  467. {
  468. struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
  469. if (cropcap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
  470. return -EINVAL;
  471. cropcap->bounds.top = cropcap->bounds.left = 0;
  472. cropcap->bounds.width = 720;
  473. cropcap->bounds.height = cx->is_50hz ? 576 : 480;
  474. cropcap->pixelaspect.numerator = cx->is_50hz ? 59 : 10;
  475. cropcap->pixelaspect.denominator = cx->is_50hz ? 54 : 11;
  476. cropcap->defrect = cropcap->bounds;
  477. return 0;
  478. }
  479. static int cx18_s_crop(struct file *file, void *fh, struct v4l2_crop *crop)
  480. {
  481. struct cx18_open_id *id = fh;
  482. struct cx18 *cx = id->cx;
  483. int ret;
  484. ret = v4l2_prio_check(&cx->prio, id->prio);
  485. if (ret)
  486. return ret;
  487. if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
  488. return -EINVAL;
  489. CX18_DEBUG_WARN("VIDIOC_S_CROP not implemented\n");
  490. return -EINVAL;
  491. }
  492. static int cx18_g_crop(struct file *file, void *fh, struct v4l2_crop *crop)
  493. {
  494. struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
  495. if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
  496. return -EINVAL;
  497. CX18_DEBUG_WARN("VIDIOC_G_CROP not implemented\n");
  498. return -EINVAL;
  499. }
  500. static int cx18_enum_fmt_vid_cap(struct file *file, void *fh,
  501. struct v4l2_fmtdesc *fmt)
  502. {
  503. static struct v4l2_fmtdesc formats[] = {
  504. { 0, V4L2_BUF_TYPE_VIDEO_CAPTURE, 0,
  505. "HM12 (YUV 4:1:1)", V4L2_PIX_FMT_HM12, { 0, 0, 0, 0 }
  506. },
  507. { 1, V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FMT_FLAG_COMPRESSED,
  508. "MPEG", V4L2_PIX_FMT_MPEG, { 0, 0, 0, 0 }
  509. }
  510. };
  511. if (fmt->index > 1)
  512. return -EINVAL;
  513. *fmt = formats[fmt->index];
  514. return 0;
  515. }
  516. static int cx18_g_input(struct file *file, void *fh, unsigned int *i)
  517. {
  518. struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
  519. *i = cx->active_input;
  520. return 0;
  521. }
  522. int cx18_s_input(struct file *file, void *fh, unsigned int inp)
  523. {
  524. struct cx18_open_id *id = fh;
  525. struct cx18 *cx = id->cx;
  526. int ret;
  527. ret = v4l2_prio_check(&cx->prio, id->prio);
  528. if (ret)
  529. return ret;
  530. if (inp >= cx->nof_inputs)
  531. return -EINVAL;
  532. if (inp == cx->active_input) {
  533. CX18_DEBUG_INFO("Input unchanged\n");
  534. return 0;
  535. }
  536. CX18_DEBUG_INFO("Changing input from %d to %d\n",
  537. cx->active_input, inp);
  538. cx->active_input = inp;
  539. /* Set the audio input to whatever is appropriate for the input type. */
  540. cx->audio_input = cx->card->video_inputs[inp].audio_index;
  541. /* prevent others from messing with the streams until
  542. we're finished changing inputs. */
  543. cx18_mute(cx);
  544. cx18_video_set_io(cx);
  545. cx18_audio_set_io(cx);
  546. cx18_unmute(cx);
  547. return 0;
  548. }
  549. static int cx18_g_frequency(struct file *file, void *fh,
  550. struct v4l2_frequency *vf)
  551. {
  552. struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
  553. if (vf->tuner != 0)
  554. return -EINVAL;
  555. cx18_call_all(cx, tuner, g_frequency, vf);
  556. return 0;
  557. }
  558. int cx18_s_frequency(struct file *file, void *fh, struct v4l2_frequency *vf)
  559. {
  560. struct cx18_open_id *id = fh;
  561. struct cx18 *cx = id->cx;
  562. int ret;
  563. ret = v4l2_prio_check(&cx->prio, id->prio);
  564. if (ret)
  565. return ret;
  566. if (vf->tuner != 0)
  567. return -EINVAL;
  568. cx18_mute(cx);
  569. CX18_DEBUG_INFO("v4l2 ioctl: set frequency %d\n", vf->frequency);
  570. cx18_call_all(cx, tuner, s_frequency, vf);
  571. cx18_unmute(cx);
  572. return 0;
  573. }
  574. static int cx18_g_std(struct file *file, void *fh, v4l2_std_id *std)
  575. {
  576. struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
  577. *std = cx->std;
  578. return 0;
  579. }
  580. int cx18_s_std(struct file *file, void *fh, v4l2_std_id *std)
  581. {
  582. struct cx18_open_id *id = fh;
  583. struct cx18 *cx = id->cx;
  584. int ret;
  585. ret = v4l2_prio_check(&cx->prio, id->prio);
  586. if (ret)
  587. return ret;
  588. if ((*std & V4L2_STD_ALL) == 0)
  589. return -EINVAL;
  590. if (*std == cx->std)
  591. return 0;
  592. if (test_bit(CX18_F_I_RADIO_USER, &cx->i_flags) ||
  593. atomic_read(&cx->ana_capturing) > 0) {
  594. /* Switching standard would turn off the radio or mess
  595. with already running streams, prevent that by
  596. returning EBUSY. */
  597. return -EBUSY;
  598. }
  599. cx->std = *std;
  600. cx->is_60hz = (*std & V4L2_STD_525_60) ? 1 : 0;
  601. cx->params.is_50hz = cx->is_50hz = !cx->is_60hz;
  602. cx->params.width = 720;
  603. cx->params.height = cx->is_50hz ? 576 : 480;
  604. cx->vbi.count = cx->is_50hz ? 18 : 12;
  605. cx->vbi.start[0] = cx->is_50hz ? 6 : 10;
  606. cx->vbi.start[1] = cx->is_50hz ? 318 : 273;
  607. CX18_DEBUG_INFO("Switching standard to %llx.\n",
  608. (unsigned long long) cx->std);
  609. /* Tuner */
  610. cx18_call_all(cx, core, s_std, cx->std);
  611. return 0;
  612. }
  613. static int cx18_s_tuner(struct file *file, void *fh, struct v4l2_tuner *vt)
  614. {
  615. struct cx18_open_id *id = fh;
  616. struct cx18 *cx = id->cx;
  617. int ret;
  618. ret = v4l2_prio_check(&cx->prio, id->prio);
  619. if (ret)
  620. return ret;
  621. if (vt->index != 0)
  622. return -EINVAL;
  623. cx18_call_all(cx, tuner, s_tuner, vt);
  624. return 0;
  625. }
  626. static int cx18_g_tuner(struct file *file, void *fh, struct v4l2_tuner *vt)
  627. {
  628. struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
  629. if (vt->index != 0)
  630. return -EINVAL;
  631. cx18_call_all(cx, tuner, g_tuner, vt);
  632. if (test_bit(CX18_F_I_RADIO_USER, &cx->i_flags)) {
  633. strlcpy(vt->name, "cx18 Radio Tuner", sizeof(vt->name));
  634. vt->type = V4L2_TUNER_RADIO;
  635. } else {
  636. strlcpy(vt->name, "cx18 TV Tuner", sizeof(vt->name));
  637. vt->type = V4L2_TUNER_ANALOG_TV;
  638. }
  639. return 0;
  640. }
  641. static int cx18_g_sliced_vbi_cap(struct file *file, void *fh,
  642. struct v4l2_sliced_vbi_cap *cap)
  643. {
  644. struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
  645. int set = cx->is_50hz ? V4L2_SLICED_VBI_625 : V4L2_SLICED_VBI_525;
  646. int f, l;
  647. if (cap->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE)
  648. return -EINVAL;
  649. cap->service_set = 0;
  650. for (f = 0; f < 2; f++) {
  651. for (l = 0; l < 24; l++) {
  652. if (valid_service_line(f, l, cx->is_50hz)) {
  653. /*
  654. * We can find all v4l2 supported vbi services
  655. * for the standard, on a valid line for the std
  656. */
  657. cap->service_lines[f][l] = set;
  658. cap->service_set |= set;
  659. } else
  660. cap->service_lines[f][l] = 0;
  661. }
  662. }
  663. for (f = 0; f < 3; f++)
  664. cap->reserved[f] = 0;
  665. return 0;
  666. }
  667. static int _cx18_process_idx_data(struct cx18_buffer *buf,
  668. struct v4l2_enc_idx *idx)
  669. {
  670. int consumed, remaining;
  671. struct v4l2_enc_idx_entry *e_idx;
  672. struct cx18_enc_idx_entry *e_buf;
  673. /* Frame type lookup: 1=I, 2=P, 4=B */
  674. const int mapping[8] = {
  675. -1, V4L2_ENC_IDX_FRAME_I, V4L2_ENC_IDX_FRAME_P,
  676. -1, V4L2_ENC_IDX_FRAME_B, -1, -1, -1
  677. };
  678. /*
  679. * Assumption here is that a buf holds an integral number of
  680. * struct cx18_enc_idx_entry objects and is properly aligned.
  681. * This is enforced by the module options on IDX buffer sizes.
  682. */
  683. remaining = buf->bytesused - buf->readpos;
  684. consumed = 0;
  685. e_idx = &idx->entry[idx->entries];
  686. e_buf = (struct cx18_enc_idx_entry *) &buf->buf[buf->readpos];
  687. while (remaining >= sizeof(struct cx18_enc_idx_entry) &&
  688. idx->entries < V4L2_ENC_IDX_ENTRIES) {
  689. e_idx->offset = (((u64) le32_to_cpu(e_buf->offset_high)) << 32)
  690. | le32_to_cpu(e_buf->offset_low);
  691. e_idx->pts = (((u64) (le32_to_cpu(e_buf->pts_high) & 1)) << 32)
  692. | le32_to_cpu(e_buf->pts_low);
  693. e_idx->length = le32_to_cpu(e_buf->length);
  694. e_idx->flags = mapping[le32_to_cpu(e_buf->flags) & 0x7];
  695. e_idx->reserved[0] = 0;
  696. e_idx->reserved[1] = 0;
  697. idx->entries++;
  698. e_idx = &idx->entry[idx->entries];
  699. e_buf++;
  700. remaining -= sizeof(struct cx18_enc_idx_entry);
  701. consumed += sizeof(struct cx18_enc_idx_entry);
  702. }
  703. /* Swallow any partial entries at the end, if there are any */
  704. if (remaining > 0 && remaining < sizeof(struct cx18_enc_idx_entry))
  705. consumed += remaining;
  706. buf->readpos += consumed;
  707. return consumed;
  708. }
  709. static int cx18_process_idx_data(struct cx18_stream *s, struct cx18_mdl *mdl,
  710. struct v4l2_enc_idx *idx)
  711. {
  712. if (s->type != CX18_ENC_STREAM_TYPE_IDX)
  713. return -EINVAL;
  714. if (mdl->curr_buf == NULL)
  715. mdl->curr_buf = list_first_entry(&mdl->buf_list,
  716. struct cx18_buffer, list);
  717. if (list_entry_is_past_end(mdl->curr_buf, &mdl->buf_list, list)) {
  718. /*
  719. * For some reason we've exhausted the buffers, but the MDL
  720. * object still said some data was unread.
  721. * Fix that and bail out.
  722. */
  723. mdl->readpos = mdl->bytesused;
  724. return 0;
  725. }
  726. list_for_each_entry_from(mdl->curr_buf, &mdl->buf_list, list) {
  727. /* Skip any empty buffers in the MDL */
  728. if (mdl->curr_buf->readpos >= mdl->curr_buf->bytesused)
  729. continue;
  730. mdl->readpos += _cx18_process_idx_data(mdl->curr_buf, idx);
  731. /* exit when MDL drained or request satisfied */
  732. if (idx->entries >= V4L2_ENC_IDX_ENTRIES ||
  733. mdl->curr_buf->readpos < mdl->curr_buf->bytesused ||
  734. mdl->readpos >= mdl->bytesused)
  735. break;
  736. }
  737. return 0;
  738. }
  739. static int cx18_g_enc_index(struct file *file, void *fh,
  740. struct v4l2_enc_idx *idx)
  741. {
  742. struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
  743. struct cx18_stream *s = &cx->streams[CX18_ENC_STREAM_TYPE_IDX];
  744. s32 tmp;
  745. struct cx18_mdl *mdl;
  746. if (!cx18_stream_enabled(s)) /* Module options inhibited IDX stream */
  747. return -EINVAL;
  748. /* Compute the best case number of entries we can buffer */
  749. tmp = s->buffers -
  750. s->bufs_per_mdl * CX18_ENC_STREAM_TYPE_IDX_FW_MDL_MIN;
  751. if (tmp <= 0)
  752. tmp = 1;
  753. tmp = tmp * s->buf_size / sizeof(struct cx18_enc_idx_entry);
  754. /* Fill out the header of the return structure */
  755. idx->entries = 0;
  756. idx->entries_cap = tmp;
  757. memset(idx->reserved, 0, sizeof(idx->reserved));
  758. /* Pull IDX MDLs and buffers from q_full and populate the entries */
  759. do {
  760. mdl = cx18_dequeue(s, &s->q_full);
  761. if (mdl == NULL) /* No more IDX data right now */
  762. break;
  763. /* Extract the Index entry data from the MDL and buffers */
  764. cx18_process_idx_data(s, mdl, idx);
  765. if (mdl->readpos < mdl->bytesused) {
  766. /* We finished with data remaining, push the MDL back */
  767. cx18_push(s, mdl, &s->q_full);
  768. break;
  769. }
  770. /* We drained this MDL, schedule it to go to the firmware */
  771. cx18_enqueue(s, mdl, &s->q_free);
  772. } while (idx->entries < V4L2_ENC_IDX_ENTRIES);
  773. /* Tell the work handler to send free IDX MDLs to the firmware */
  774. cx18_stream_load_fw_queue(s);
  775. return 0;
  776. }
  777. static int cx18_encoder_cmd(struct file *file, void *fh,
  778. struct v4l2_encoder_cmd *enc)
  779. {
  780. struct cx18_open_id *id = fh;
  781. struct cx18 *cx = id->cx;
  782. u32 h;
  783. switch (enc->cmd) {
  784. case V4L2_ENC_CMD_START:
  785. CX18_DEBUG_IOCTL("V4L2_ENC_CMD_START\n");
  786. enc->flags = 0;
  787. return cx18_start_capture(id);
  788. case V4L2_ENC_CMD_STOP:
  789. CX18_DEBUG_IOCTL("V4L2_ENC_CMD_STOP\n");
  790. enc->flags &= V4L2_ENC_CMD_STOP_AT_GOP_END;
  791. cx18_stop_capture(id,
  792. enc->flags & V4L2_ENC_CMD_STOP_AT_GOP_END);
  793. break;
  794. case V4L2_ENC_CMD_PAUSE:
  795. CX18_DEBUG_IOCTL("V4L2_ENC_CMD_PAUSE\n");
  796. enc->flags = 0;
  797. if (!atomic_read(&cx->ana_capturing))
  798. return -EPERM;
  799. if (test_and_set_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags))
  800. return 0;
  801. h = cx18_find_handle(cx);
  802. if (h == CX18_INVALID_TASK_HANDLE) {
  803. CX18_ERR("Can't find valid task handle for "
  804. "V4L2_ENC_CMD_PAUSE\n");
  805. return -EBADFD;
  806. }
  807. cx18_mute(cx);
  808. cx18_vapi(cx, CX18_CPU_CAPTURE_PAUSE, 1, h);
  809. break;
  810. case V4L2_ENC_CMD_RESUME:
  811. CX18_DEBUG_IOCTL("V4L2_ENC_CMD_RESUME\n");
  812. enc->flags = 0;
  813. if (!atomic_read(&cx->ana_capturing))
  814. return -EPERM;
  815. if (!test_and_clear_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags))
  816. return 0;
  817. h = cx18_find_handle(cx);
  818. if (h == CX18_INVALID_TASK_HANDLE) {
  819. CX18_ERR("Can't find valid task handle for "
  820. "V4L2_ENC_CMD_RESUME\n");
  821. return -EBADFD;
  822. }
  823. cx18_vapi(cx, CX18_CPU_CAPTURE_RESUME, 1, h);
  824. cx18_unmute(cx);
  825. break;
  826. default:
  827. CX18_DEBUG_IOCTL("Unknown cmd %d\n", enc->cmd);
  828. return -EINVAL;
  829. }
  830. return 0;
  831. }
  832. static int cx18_try_encoder_cmd(struct file *file, void *fh,
  833. struct v4l2_encoder_cmd *enc)
  834. {
  835. struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
  836. switch (enc->cmd) {
  837. case V4L2_ENC_CMD_START:
  838. CX18_DEBUG_IOCTL("V4L2_ENC_CMD_START\n");
  839. enc->flags = 0;
  840. break;
  841. case V4L2_ENC_CMD_STOP:
  842. CX18_DEBUG_IOCTL("V4L2_ENC_CMD_STOP\n");
  843. enc->flags &= V4L2_ENC_CMD_STOP_AT_GOP_END;
  844. break;
  845. case V4L2_ENC_CMD_PAUSE:
  846. CX18_DEBUG_IOCTL("V4L2_ENC_CMD_PAUSE\n");
  847. enc->flags = 0;
  848. break;
  849. case V4L2_ENC_CMD_RESUME:
  850. CX18_DEBUG_IOCTL("V4L2_ENC_CMD_RESUME\n");
  851. enc->flags = 0;
  852. break;
  853. default:
  854. CX18_DEBUG_IOCTL("Unknown cmd %d\n", enc->cmd);
  855. return -EINVAL;
  856. }
  857. return 0;
  858. }
  859. static int cx18_log_status(struct file *file, void *fh)
  860. {
  861. struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
  862. struct v4l2_input vidin;
  863. struct v4l2_audio audin;
  864. int i;
  865. CX18_INFO("================= START STATUS CARD #%d "
  866. "=================\n", cx->instance);
  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. cx2341x_log_status(&cx->params, 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 == 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. CX18_INFO("================== END STATUS CARD #%d "
  899. "==================\n", cx->instance);
  900. return 0;
  901. }
  902. static long cx18_default(struct file *file, void *fh, int cmd, void *arg)
  903. {
  904. struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
  905. switch (cmd) {
  906. case VIDIOC_INT_RESET: {
  907. u32 val = *(u32 *)arg;
  908. if ((val == 0) || (val & 0x01))
  909. cx18_call_hw(cx, CX18_HW_GPIO_RESET_CTRL, core, reset,
  910. (u32) CX18_GPIO_RESET_Z8F0811);
  911. break;
  912. }
  913. default:
  914. return -EINVAL;
  915. }
  916. return 0;
  917. }
  918. long cx18_v4l2_ioctl(struct file *filp, unsigned int cmd,
  919. unsigned long arg)
  920. {
  921. struct video_device *vfd = video_devdata(filp);
  922. struct cx18_open_id *id = (struct cx18_open_id *)filp->private_data;
  923. struct cx18 *cx = id->cx;
  924. long res;
  925. mutex_lock(&cx->serialize_lock);
  926. /* FIXME - consolidate v4l2_prio_check()'s here */
  927. if (cx18_debug & CX18_DBGFLG_IOCTL)
  928. vfd->debug = V4L2_DEBUG_IOCTL | V4L2_DEBUG_IOCTL_ARG;
  929. res = video_ioctl2(filp, cmd, arg);
  930. vfd->debug = 0;
  931. mutex_unlock(&cx->serialize_lock);
  932. return res;
  933. }
  934. static const struct v4l2_ioctl_ops cx18_ioctl_ops = {
  935. .vidioc_querycap = cx18_querycap,
  936. .vidioc_g_priority = cx18_g_priority,
  937. .vidioc_s_priority = cx18_s_priority,
  938. .vidioc_s_audio = cx18_s_audio,
  939. .vidioc_g_audio = cx18_g_audio,
  940. .vidioc_enumaudio = cx18_enumaudio,
  941. .vidioc_enum_input = cx18_enum_input,
  942. .vidioc_cropcap = cx18_cropcap,
  943. .vidioc_s_crop = cx18_s_crop,
  944. .vidioc_g_crop = cx18_g_crop,
  945. .vidioc_g_input = cx18_g_input,
  946. .vidioc_s_input = cx18_s_input,
  947. .vidioc_g_frequency = cx18_g_frequency,
  948. .vidioc_s_frequency = cx18_s_frequency,
  949. .vidioc_s_tuner = cx18_s_tuner,
  950. .vidioc_g_tuner = cx18_g_tuner,
  951. .vidioc_g_enc_index = cx18_g_enc_index,
  952. .vidioc_g_std = cx18_g_std,
  953. .vidioc_s_std = cx18_s_std,
  954. .vidioc_log_status = cx18_log_status,
  955. .vidioc_enum_fmt_vid_cap = cx18_enum_fmt_vid_cap,
  956. .vidioc_encoder_cmd = cx18_encoder_cmd,
  957. .vidioc_try_encoder_cmd = cx18_try_encoder_cmd,
  958. .vidioc_g_fmt_vid_cap = cx18_g_fmt_vid_cap,
  959. .vidioc_g_fmt_vbi_cap = cx18_g_fmt_vbi_cap,
  960. .vidioc_g_fmt_sliced_vbi_cap = cx18_g_fmt_sliced_vbi_cap,
  961. .vidioc_s_fmt_vid_cap = cx18_s_fmt_vid_cap,
  962. .vidioc_s_fmt_vbi_cap = cx18_s_fmt_vbi_cap,
  963. .vidioc_s_fmt_sliced_vbi_cap = cx18_s_fmt_sliced_vbi_cap,
  964. .vidioc_try_fmt_vid_cap = cx18_try_fmt_vid_cap,
  965. .vidioc_try_fmt_vbi_cap = cx18_try_fmt_vbi_cap,
  966. .vidioc_try_fmt_sliced_vbi_cap = cx18_try_fmt_sliced_vbi_cap,
  967. .vidioc_g_sliced_vbi_cap = cx18_g_sliced_vbi_cap,
  968. .vidioc_g_chip_ident = cx18_g_chip_ident,
  969. #ifdef CONFIG_VIDEO_ADV_DEBUG
  970. .vidioc_g_register = cx18_g_register,
  971. .vidioc_s_register = cx18_s_register,
  972. #endif
  973. .vidioc_default = cx18_default,
  974. .vidioc_queryctrl = cx18_queryctrl,
  975. .vidioc_querymenu = cx18_querymenu,
  976. .vidioc_g_ext_ctrls = cx18_g_ext_ctrls,
  977. .vidioc_s_ext_ctrls = cx18_s_ext_ctrls,
  978. .vidioc_try_ext_ctrls = cx18_try_ext_ctrls,
  979. };
  980. void cx18_set_funcs(struct video_device *vdev)
  981. {
  982. vdev->ioctl_ops = &cx18_ioctl_ops;
  983. }