cx18-ioctl.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145
  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->cxhdl.width;
  143. pixfmt->height = cx->cxhdl.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->cxhdl.width == w && cx->cxhdl.height == h)
  261. return 0;
  262. if (atomic_read(&cx->ana_capturing) > 0)
  263. return -EBUSY;
  264. mbus_fmt.width = cx->cxhdl.width = w;
  265. mbus_fmt.height = cx->cxhdl.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->is_50hz = !cx->is_60hz;
  601. cx2341x_handler_set_50hz(&cx->cxhdl, cx->is_50hz);
  602. cx->cxhdl.width = 720;
  603. cx->cxhdl.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. v4l2_ctrl_handler_log_status(&cx->cxhdl.hdl, cx->v4l2_dev.name);
  884. CX18_INFO("Status flags: 0x%08lx\n", cx->i_flags);
  885. for (i = 0; i < CX18_MAX_STREAMS; i++) {
  886. struct cx18_stream *s = &cx->streams[i];
  887. if (s->video_dev == 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 = 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. };
  975. void cx18_set_funcs(struct video_device *vdev)
  976. {
  977. vdev->ioctl_ops = &cx18_ioctl_ops;
  978. }