cx18-ioctl.c 31 KB

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