cx18-ioctl.c 32 KB

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