cx18-ioctl.c 31 KB

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