blob: a454ede568a542feb8f6fa9591eaa2b6c712ebe9 [file] [log] [blame]
Hans Verkuil1c1e45d2008-04-28 20:24:33 -03001/*
2 * cx18 ioctl system call
3 *
4 * Derived from ivtv-ioctl.c
5 *
6 * Copyright (C) 2007 Hans Verkuil <hverkuil@xs4all.nl>
Andy Walls1ed9dcc2008-11-22 01:37:34 -03007 * Copyright (C) 2008 Andy Walls <awalls@radix.net>
Hans Verkuil1c1e45d2008-04-28 20:24:33 -03008 *
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
25#include "cx18-driver.h"
Andy Wallsb1526422008-08-30 16:03:44 -030026#include "cx18-io.h"
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030027#include "cx18-version.h"
28#include "cx18-mailbox.h"
29#include "cx18-i2c.h"
30#include "cx18-queue.h"
31#include "cx18-fileops.h"
32#include "cx18-vbi.h"
33#include "cx18-audio.h"
34#include "cx18-video.h"
35#include "cx18-streams.h"
36#include "cx18-ioctl.h"
37#include "cx18-gpio.h"
38#include "cx18-controls.h"
39#include "cx18-cards.h"
40#include "cx18-av-core.h"
41#include <media/tveeprom.h>
42#include <media/v4l2-chip-ident.h>
43#include <linux/i2c-id.h>
44
Andy Wallsc1994082009-02-05 22:37:49 -030045static int cx18_vbi_streaming(struct cx18 *cx)
46{
47 struct cx18_stream *s_vbi = &cx->streams[CX18_ENC_STREAM_TYPE_VBI];
48 return (s_vbi->handle != CX18_INVALID_TASK_HANDLE) &&
49 test_bit(CX18_F_S_STREAMING, &s_vbi->s_flags);
50}
51
Mauro Carvalho Chehabaed6abd2008-04-29 21:38:51 -030052u16 cx18_service2vbi(int type)
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030053{
54 switch (type) {
55 case V4L2_SLICED_TELETEXT_B:
56 return CX18_SLICED_TYPE_TELETEXT_B;
57 case V4L2_SLICED_CAPTION_525:
58 return CX18_SLICED_TYPE_CAPTION_525;
59 case V4L2_SLICED_WSS_625:
60 return CX18_SLICED_TYPE_WSS_625;
61 case V4L2_SLICED_VPS:
62 return CX18_SLICED_TYPE_VPS;
63 default:
64 return 0;
65 }
66}
67
Andy Wallsc1994082009-02-05 22:37:49 -030068/* Check if VBI services are allowed on the (field, line) for the video std */
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030069static int valid_service_line(int field, int line, int is_pal)
70{
Andy Wallsc1994082009-02-05 22:37:49 -030071 return (is_pal && line >= 6 &&
72 ((field == 0 && line <= 23) || (field == 1 && line <= 22))) ||
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030073 (!is_pal && line >= 10 && line < 22);
74}
75
Andy Wallsc1994082009-02-05 22:37:49 -030076/*
77 * For a (field, line, std) and inbound potential set of services for that line,
78 * return the first valid service of those passed in the incoming set for that
79 * line in priority order:
80 * CC, VPS, or WSS over TELETEXT for well known lines
81 * TELETEXT, before VPS, before CC, before WSS, for other lines
82 */
Hans Verkuil1c1e45d2008-04-28 20:24:33 -030083static u16 select_service_from_set(int field, int line, u16 set, int is_pal)
84{
85 u16 valid_set = (is_pal ? V4L2_SLICED_VBI_625 : V4L2_SLICED_VBI_525);
86 int i;
87
88 set = set & valid_set;
89 if (set == 0 || !valid_service_line(field, line, is_pal))
90 return 0;
91 if (!is_pal) {
92 if (line == 21 && (set & V4L2_SLICED_CAPTION_525))
93 return V4L2_SLICED_CAPTION_525;
94 } else {
95 if (line == 16 && field == 0 && (set & V4L2_SLICED_VPS))
96 return V4L2_SLICED_VPS;
97 if (line == 23 && field == 0 && (set & V4L2_SLICED_WSS_625))
98 return V4L2_SLICED_WSS_625;
99 if (line == 23)
100 return 0;
101 }
102 for (i = 0; i < 32; i++) {
103 if ((1 << i) & set)
104 return 1 << i;
105 }
106 return 0;
107}
108
Andy Wallsc1994082009-02-05 22:37:49 -0300109/*
110 * Expand the service_set of *fmt into valid service_lines for the std,
111 * and clear the passed in fmt->service_set
112 */
Mauro Carvalho Chehabaed6abd2008-04-29 21:38:51 -0300113void cx18_expand_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal)
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300114{
115 u16 set = fmt->service_set;
116 int f, l;
117
118 fmt->service_set = 0;
119 for (f = 0; f < 2; f++) {
120 for (l = 0; l < 24; l++)
121 fmt->service_lines[f][l] = select_service_from_set(f, l, set, is_pal);
122 }
123}
124
Andy Wallsc1994082009-02-05 22:37:49 -0300125/*
126 * Sanitize the service_lines in *fmt per the video std, and return 1
127 * if any service_line is left as valid after santization
128 */
Andy Walls302df972009-01-31 00:33:02 -0300129static int check_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal)
130{
131 int f, l;
132 u16 set = 0;
133
134 for (f = 0; f < 2; f++) {
135 for (l = 0; l < 24; l++) {
136 fmt->service_lines[f][l] = select_service_from_set(f, l, fmt->service_lines[f][l], is_pal);
137 set |= fmt->service_lines[f][l];
138 }
139 }
140 return set != 0;
141}
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300142
Andy Wallsc1994082009-02-05 22:37:49 -0300143/* Compute the service_set from the assumed valid service_lines of *fmt */
Mauro Carvalho Chehabaed6abd2008-04-29 21:38:51 -0300144u16 cx18_get_service_set(struct v4l2_sliced_vbi_format *fmt)
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300145{
146 int f, l;
147 u16 set = 0;
148
149 for (f = 0; f < 2; f++) {
150 for (l = 0; l < 24; l++)
151 set |= fmt->service_lines[f][l];
152 }
153 return set;
154}
155
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300156static int cx18_g_fmt_vid_cap(struct file *file, void *fh,
157 struct v4l2_format *fmt)
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300158{
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300159 struct cx18_open_id *id = fh;
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300160 struct cx18 *cx = id->cx;
Hans Verkuil0b5a30e2008-06-21 09:22:19 -0300161 struct v4l2_pix_format *pixfmt = &fmt->fmt.pix;
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300162
Hans Verkuil0b5a30e2008-06-21 09:22:19 -0300163 pixfmt->width = cx->params.width;
164 pixfmt->height = cx->params.height;
165 pixfmt->colorspace = V4L2_COLORSPACE_SMPTE170M;
166 pixfmt->field = V4L2_FIELD_INTERLACED;
167 pixfmt->priv = 0;
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300168 if (id->type == CX18_ENC_STREAM_TYPE_YUV) {
Hans Verkuil0b5a30e2008-06-21 09:22:19 -0300169 pixfmt->pixelformat = V4L2_PIX_FMT_HM12;
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300170 /* YUV size is (Y=(h*w) + UV=(h*(w/2))) */
Hans Verkuil0b5a30e2008-06-21 09:22:19 -0300171 pixfmt->sizeimage =
172 pixfmt->height * pixfmt->width +
173 pixfmt->height * (pixfmt->width / 2);
174 pixfmt->bytesperline = 720;
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300175 } else {
Hans Verkuil0b5a30e2008-06-21 09:22:19 -0300176 pixfmt->pixelformat = V4L2_PIX_FMT_MPEG;
177 pixfmt->sizeimage = 128 * 1024;
178 pixfmt->bytesperline = 0;
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300179 }
180 return 0;
181}
182
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300183static int cx18_g_fmt_vbi_cap(struct file *file, void *fh,
184 struct v4l2_format *fmt)
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300185{
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300186 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
Hans Verkuil0b5a30e2008-06-21 09:22:19 -0300187 struct v4l2_vbi_format *vbifmt = &fmt->fmt.vbi;
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300188
Hans Verkuil0b5a30e2008-06-21 09:22:19 -0300189 vbifmt->sampling_rate = 27000000;
Andy Wallsc1994082009-02-05 22:37:49 -0300190 vbifmt->offset = 248; /* FIXME - slightly wrong for both 50 & 60 Hz */
Andy Walls302df972009-01-31 00:33:02 -0300191 vbifmt->samples_per_line = vbi_active_samples - 4;
Hans Verkuil0b5a30e2008-06-21 09:22:19 -0300192 vbifmt->sample_format = V4L2_PIX_FMT_GREY;
193 vbifmt->start[0] = cx->vbi.start[0];
194 vbifmt->start[1] = cx->vbi.start[1];
195 vbifmt->count[0] = vbifmt->count[1] = cx->vbi.count;
196 vbifmt->flags = 0;
197 vbifmt->reserved[0] = 0;
198 vbifmt->reserved[1] = 0;
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300199 return 0;
200}
201
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300202static int cx18_g_fmt_sliced_vbi_cap(struct file *file, void *fh,
203 struct v4l2_format *fmt)
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300204{
Andy Walls302df972009-01-31 00:33:02 -0300205 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
206 struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced;
207
Andy Wallsc1994082009-02-05 22:37:49 -0300208 /* sane, V4L2 spec compliant, defaults */
Andy Walls302df972009-01-31 00:33:02 -0300209 vbifmt->reserved[0] = 0;
210 vbifmt->reserved[1] = 0;
211 vbifmt->io_size = sizeof(struct v4l2_sliced_vbi_data) * 36;
212 memset(vbifmt->service_lines, 0, sizeof(vbifmt->service_lines));
Andy Wallsc1994082009-02-05 22:37:49 -0300213 vbifmt->service_set = 0;
Andy Walls302df972009-01-31 00:33:02 -0300214
Andy Wallsc1994082009-02-05 22:37:49 -0300215 /*
216 * Fetch the configured service_lines and total service_set from the
217 * digitizer/slicer. Note, cx18_av_vbi() wipes the passed in
218 * fmt->fmt.sliced under valid calling conditions
219 */
220 if (cx18_av_cmd(cx, VIDIOC_G_FMT, fmt))
221 return -EINVAL;
222
223 /* Ensure V4L2 spec compliant output */
224 vbifmt->reserved[0] = 0;
225 vbifmt->reserved[1] = 0;
226 vbifmt->io_size = sizeof(struct v4l2_sliced_vbi_data) * 36;
Andy Walls302df972009-01-31 00:33:02 -0300227 vbifmt->service_set = cx18_get_service_set(vbifmt);
228 return 0;
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300229}
230
231static int cx18_try_fmt_vid_cap(struct file *file, void *fh,
232 struct v4l2_format *fmt)
233{
234 struct cx18_open_id *id = fh;
235 struct cx18 *cx = id->cx;
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300236 int w = fmt->fmt.pix.width;
237 int h = fmt->fmt.pix.height;
238
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300239 w = min(w, 720);
240 w = max(w, 1);
241 h = min(h, cx->is_50hz ? 576 : 480);
242 h = max(h, 2);
243 cx18_g_fmt_vid_cap(file, fh, fmt);
244 fmt->fmt.pix.width = w;
245 fmt->fmt.pix.height = h;
246 return 0;
247}
248
249static int cx18_try_fmt_vbi_cap(struct file *file, void *fh,
250 struct v4l2_format *fmt)
251{
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300252 return cx18_g_fmt_vbi_cap(file, fh, fmt);
253}
254
255static int cx18_try_fmt_sliced_vbi_cap(struct file *file, void *fh,
256 struct v4l2_format *fmt)
257{
Andy Walls302df972009-01-31 00:33:02 -0300258 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
259 struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced;
260
261 vbifmt->io_size = sizeof(struct v4l2_sliced_vbi_data) * 36;
262 vbifmt->reserved[0] = 0;
263 vbifmt->reserved[1] = 0;
264
Andy Wallsc1994082009-02-05 22:37:49 -0300265 /* If given a service set, expand it validly & clear passed in set */
Andy Walls302df972009-01-31 00:33:02 -0300266 if (vbifmt->service_set)
267 cx18_expand_service_set(vbifmt, cx->is_50hz);
Andy Wallsc1994082009-02-05 22:37:49 -0300268 /* Sanitize the service_lines, and compute the new set if any valid */
269 if (check_service_set(vbifmt, cx->is_50hz))
270 vbifmt->service_set = cx18_get_service_set(vbifmt);
Andy Walls302df972009-01-31 00:33:02 -0300271 return 0;
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300272}
273
274static int cx18_s_fmt_vid_cap(struct file *file, void *fh,
275 struct v4l2_format *fmt)
276{
277 struct cx18_open_id *id = fh;
278 struct cx18 *cx = id->cx;
279 int ret;
Hans Verkuileffc3462008-09-06 08:24:37 -0300280 int w, h;
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300281
282 ret = v4l2_prio_check(&cx->prio, &id->prio);
283 if (ret)
284 return ret;
285
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300286 ret = cx18_try_fmt_vid_cap(file, fh, fmt);
287 if (ret)
288 return ret;
Hans Verkuileffc3462008-09-06 08:24:37 -0300289 w = fmt->fmt.pix.width;
290 h = fmt->fmt.pix.height;
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300291
292 if (cx->params.width == w && cx->params.height == h)
293 return 0;
294
295 if (atomic_read(&cx->ana_capturing) > 0)
296 return -EBUSY;
297
298 cx->params.width = w;
299 cx->params.height = h;
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300300 cx18_av_cmd(cx, VIDIOC_S_FMT, fmt);
301 return cx18_g_fmt_vid_cap(file, fh, fmt);
302}
303
304static int cx18_s_fmt_vbi_cap(struct file *file, void *fh,
305 struct v4l2_format *fmt)
306{
307 struct cx18_open_id *id = fh;
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300308 struct cx18 *cx = id->cx;
309 int ret;
310
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300311 ret = v4l2_prio_check(&cx->prio, &id->prio);
312 if (ret)
313 return ret;
314
Andy Wallsc1994082009-02-05 22:37:49 -0300315 if (!cx18_raw_vbi(cx) && cx18_vbi_streaming(cx))
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300316 return -EBUSY;
317
Andy Wallsc1994082009-02-05 22:37:49 -0300318 /*
319 * Set the digitizer registers for raw active VBI.
320 * Note cx18_av_vbi_wipes out alot of the passed in fmt under valid
321 * calling conditions
322 */
323 ret = cx18_av_cmd(cx, VIDIOC_S_FMT, fmt);
324 if (ret)
325 return ret;
326
327 /* Store our new v4l2 (non-)sliced VBI state */
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300328 cx->vbi.sliced_in->service_set = 0;
Andy Wallsdd073432008-12-12 16:24:04 -0300329 cx->vbi.in.type = V4L2_BUF_TYPE_VBI_CAPTURE;
Andy Wallsc1994082009-02-05 22:37:49 -0300330
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300331 return cx18_g_fmt_vbi_cap(file, fh, fmt);
332}
333
334static int cx18_s_fmt_sliced_vbi_cap(struct file *file, void *fh,
335 struct v4l2_format *fmt)
336{
Andy Walls302df972009-01-31 00:33:02 -0300337 struct cx18_open_id *id = fh;
338 struct cx18 *cx = id->cx;
339 int ret;
340 struct v4l2_sliced_vbi_format *vbifmt = &fmt->fmt.sliced;
341
342 ret = v4l2_prio_check(&cx->prio, &id->prio);
343 if (ret)
344 return ret;
345
Andy Wallsc1994082009-02-05 22:37:49 -0300346 cx18_try_fmt_sliced_vbi_cap(file, fh, fmt);
347
348 if (cx18_raw_vbi(cx) && cx18_vbi_streaming(cx))
349 return -EBUSY;
350 /*
351 * Set the service_lines requested in the digitizer/slicer registers.
352 * Note, cx18_av_vbi() wipes some "impossible" service lines in the
353 * passed in fmt->fmt.sliced under valid calling conditions
354 */
355 ret = cx18_av_cmd(cx, VIDIOC_S_FMT, fmt);
Andy Walls302df972009-01-31 00:33:02 -0300356 if (ret)
357 return ret;
Andy Wallsc1994082009-02-05 22:37:49 -0300358 /* Store our current v4l2 sliced VBI settings */
Andy Walls302df972009-01-31 00:33:02 -0300359 cx->vbi.in.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE;
Andy Walls302df972009-01-31 00:33:02 -0300360 memcpy(cx->vbi.sliced_in, vbifmt, sizeof(*cx->vbi.sliced_in));
361 return 0;
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300362}
363
364static int cx18_g_chip_ident(struct file *file, void *fh,
Hans Verkuilaecde8b52008-12-30 07:14:19 -0300365 struct v4l2_dbg_chip_ident *chip)
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300366{
367 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
368
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300369 chip->ident = V4L2_IDENT_NONE;
370 chip->revision = 0;
Hans Verkuilaecde8b52008-12-30 07:14:19 -0300371 if (v4l2_chip_match_host(&chip->match)) {
372 chip->ident = V4L2_IDENT_CX23418;
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300373 return 0;
374 }
Hans Verkuilaecde8b52008-12-30 07:14:19 -0300375 cx18_call_i2c_clients(cx, VIDIOC_DBG_G_CHIP_IDENT, chip);
376 return 0;
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300377}
378
Hans Verkuil36ecd492008-06-25 06:00:17 -0300379#ifdef CONFIG_VIDEO_ADV_DEBUG
380static int cx18_cxc(struct cx18 *cx, unsigned int cmd, void *arg)
381{
Hans Verkuilaecde8b52008-12-30 07:14:19 -0300382 struct v4l2_dbg_register *regs = arg;
Hans Verkuil36ecd492008-06-25 06:00:17 -0300383 unsigned long flags;
384
385 if (!capable(CAP_SYS_ADMIN))
386 return -EPERM;
387 if (regs->reg >= CX18_MEM_OFFSET + CX18_MEM_SIZE)
388 return -EINVAL;
389
390 spin_lock_irqsave(&cx18_cards_lock, flags);
Hans Verkuilaecde8b52008-12-30 07:14:19 -0300391 regs->size = 4;
Hans Verkuil36ecd492008-06-25 06:00:17 -0300392 if (cmd == VIDIOC_DBG_G_REGISTER)
Andy Wallsb1526422008-08-30 16:03:44 -0300393 regs->val = cx18_read_enc(cx, regs->reg);
Hans Verkuil36ecd492008-06-25 06:00:17 -0300394 else
Andy Wallsb1526422008-08-30 16:03:44 -0300395 cx18_write_enc(cx, regs->val, regs->reg);
Hans Verkuil36ecd492008-06-25 06:00:17 -0300396 spin_unlock_irqrestore(&cx18_cards_lock, flags);
397 return 0;
398}
399
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300400static int cx18_g_register(struct file *file, void *fh,
Hans Verkuilaecde8b52008-12-30 07:14:19 -0300401 struct v4l2_dbg_register *reg)
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300402{
403 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
404
Hans Verkuilaecde8b52008-12-30 07:14:19 -0300405 if (v4l2_chip_match_host(&reg->match))
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300406 return cx18_cxc(cx, VIDIOC_DBG_G_REGISTER, reg);
Hans Verkuilaecde8b52008-12-30 07:14:19 -0300407 cx18_call_i2c_clients(cx, VIDIOC_DBG_G_REGISTER, reg);
408 return 0;
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300409}
410
411static int cx18_s_register(struct file *file, void *fh,
Hans Verkuilaecde8b52008-12-30 07:14:19 -0300412 struct v4l2_dbg_register *reg)
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300413{
414 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
415
Hans Verkuilaecde8b52008-12-30 07:14:19 -0300416 if (v4l2_chip_match_host(&reg->match))
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300417 return cx18_cxc(cx, VIDIOC_DBG_S_REGISTER, reg);
Hans Verkuilaecde8b52008-12-30 07:14:19 -0300418 cx18_call_i2c_clients(cx, VIDIOC_DBG_S_REGISTER, reg);
419 return 0;
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300420}
Hans Verkuil36ecd492008-06-25 06:00:17 -0300421#endif
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300422
423static int cx18_g_priority(struct file *file, void *fh, enum v4l2_priority *p)
424{
425 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
426
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300427 *p = v4l2_prio_max(&cx->prio);
428 return 0;
429}
430
431static int cx18_s_priority(struct file *file, void *fh, enum v4l2_priority prio)
432{
433 struct cx18_open_id *id = fh;
434 struct cx18 *cx = id->cx;
435
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300436 return v4l2_prio_change(&cx->prio, &id->prio, prio);
437}
438
439static int cx18_querycap(struct file *file, void *fh,
440 struct v4l2_capability *vcap)
441{
442 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
443
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300444 strlcpy(vcap->driver, CX18_DRIVER_NAME, sizeof(vcap->driver));
445 strlcpy(vcap->card, cx->card_name, sizeof(vcap->card));
Andy Walls3d059132009-01-10 21:54:39 -0300446 snprintf(vcap->bus_info, sizeof(vcap->bus_info),
447 "PCI:%s", pci_name(cx->pci_dev));
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300448 vcap->version = CX18_DRIVER_VERSION; /* version */
449 vcap->capabilities = cx->v4l2_cap; /* capabilities */
450 return 0;
451}
452
453static int cx18_enumaudio(struct file *file, void *fh, struct v4l2_audio *vin)
454{
455 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
456
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300457 return cx18_get_audio_input(cx, vin->index, vin);
458}
459
460static int cx18_g_audio(struct file *file, void *fh, struct v4l2_audio *vin)
461{
462 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
463
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300464 vin->index = cx->audio_input;
465 return cx18_get_audio_input(cx, vin->index, vin);
466}
467
468static int cx18_s_audio(struct file *file, void *fh, struct v4l2_audio *vout)
469{
470 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
471
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300472 if (vout->index >= cx->nof_audio_inputs)
473 return -EINVAL;
474 cx->audio_input = vout->index;
475 cx18_audio_set_io(cx);
476 return 0;
477}
478
479static int cx18_enum_input(struct file *file, void *fh, struct v4l2_input *vin)
480{
481 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
482
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300483 /* set it to defaults from our table */
484 return cx18_get_input(cx, vin->index, vin);
485}
486
487static int cx18_cropcap(struct file *file, void *fh,
488 struct v4l2_cropcap *cropcap)
489{
490 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
491
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300492 if (cropcap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
493 return -EINVAL;
494 cropcap->bounds.top = cropcap->bounds.left = 0;
495 cropcap->bounds.width = 720;
496 cropcap->bounds.height = cx->is_50hz ? 576 : 480;
497 cropcap->pixelaspect.numerator = cx->is_50hz ? 59 : 10;
498 cropcap->pixelaspect.denominator = cx->is_50hz ? 54 : 11;
499 cropcap->defrect = cropcap->bounds;
500 return 0;
501}
502
503static int cx18_s_crop(struct file *file, void *fh, struct v4l2_crop *crop)
504{
505 struct cx18_open_id *id = fh;
506 struct cx18 *cx = id->cx;
507 int ret;
508
509 ret = v4l2_prio_check(&cx->prio, &id->prio);
510 if (ret)
511 return ret;
512
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300513 if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
514 return -EINVAL;
515 return cx18_av_cmd(cx, VIDIOC_S_CROP, crop);
516}
517
518static int cx18_g_crop(struct file *file, void *fh, struct v4l2_crop *crop)
519{
520 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
521
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300522 if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
523 return -EINVAL;
524 return cx18_av_cmd(cx, VIDIOC_G_CROP, crop);
525}
526
527static int cx18_enum_fmt_vid_cap(struct file *file, void *fh,
528 struct v4l2_fmtdesc *fmt)
529{
530 static struct v4l2_fmtdesc formats[] = {
531 { 0, V4L2_BUF_TYPE_VIDEO_CAPTURE, 0,
532 "HM12 (YUV 4:1:1)", V4L2_PIX_FMT_HM12, { 0, 0, 0, 0 }
533 },
534 { 1, V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FMT_FLAG_COMPRESSED,
535 "MPEG", V4L2_PIX_FMT_MPEG, { 0, 0, 0, 0 }
536 }
537 };
538
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300539 if (fmt->index > 1)
540 return -EINVAL;
541 *fmt = formats[fmt->index];
542 return 0;
543}
544
545static int cx18_g_input(struct file *file, void *fh, unsigned int *i)
546{
547 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
548
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300549 *i = cx->active_input;
550 return 0;
551}
552
553int cx18_s_input(struct file *file, void *fh, unsigned int inp)
554{
555 struct cx18_open_id *id = fh;
556 struct cx18 *cx = id->cx;
557 int ret;
558
559 ret = v4l2_prio_check(&cx->prio, &id->prio);
560 if (ret)
561 return ret;
562
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300563 if (inp < 0 || inp >= cx->nof_inputs)
564 return -EINVAL;
565
566 if (inp == cx->active_input) {
567 CX18_DEBUG_INFO("Input unchanged\n");
568 return 0;
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300569 }
570
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300571 CX18_DEBUG_INFO("Changing input from %d to %d\n",
572 cx->active_input, inp);
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300573
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300574 cx->active_input = inp;
575 /* Set the audio input to whatever is appropriate for the input type. */
576 cx->audio_input = cx->card->video_inputs[inp].audio_index;
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300577
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300578 /* prevent others from messing with the streams until
579 we're finished changing inputs. */
580 cx18_mute(cx);
581 cx18_video_set_io(cx);
582 cx18_audio_set_io(cx);
583 cx18_unmute(cx);
584 return 0;
585}
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300586
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300587static int cx18_g_frequency(struct file *file, void *fh,
588 struct v4l2_frequency *vf)
589{
590 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
591
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300592 if (vf->tuner != 0)
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300593 return -EINVAL;
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300594
595 cx18_call_i2c_clients(cx, VIDIOC_G_FREQUENCY, vf);
596 return 0;
597}
598
599int cx18_s_frequency(struct file *file, void *fh, struct v4l2_frequency *vf)
600{
601 struct cx18_open_id *id = fh;
602 struct cx18 *cx = id->cx;
603 int ret;
604
605 ret = v4l2_prio_check(&cx->prio, &id->prio);
606 if (ret)
607 return ret;
608
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300609 if (vf->tuner != 0)
610 return -EINVAL;
611
612 cx18_mute(cx);
613 CX18_DEBUG_INFO("v4l2 ioctl: set frequency %d\n", vf->frequency);
614 cx18_call_i2c_clients(cx, VIDIOC_S_FREQUENCY, vf);
615 cx18_unmute(cx);
616 return 0;
617}
618
619static int cx18_g_std(struct file *file, void *fh, v4l2_std_id *std)
620{
621 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
622
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300623 *std = cx->std;
624 return 0;
625}
626
627int cx18_s_std(struct file *file, void *fh, v4l2_std_id *std)
628{
629 struct cx18_open_id *id = fh;
630 struct cx18 *cx = id->cx;
631 int ret;
632
633 ret = v4l2_prio_check(&cx->prio, &id->prio);
634 if (ret)
635 return ret;
636
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300637 if ((*std & V4L2_STD_ALL) == 0)
638 return -EINVAL;
639
640 if (*std == cx->std)
641 return 0;
642
643 if (test_bit(CX18_F_I_RADIO_USER, &cx->i_flags) ||
644 atomic_read(&cx->ana_capturing) > 0) {
645 /* Switching standard would turn off the radio or mess
646 with already running streams, prevent that by
647 returning EBUSY. */
648 return -EBUSY;
649 }
650
651 cx->std = *std;
652 cx->is_60hz = (*std & V4L2_STD_525_60) ? 1 : 0;
653 cx->params.is_50hz = cx->is_50hz = !cx->is_60hz;
654 cx->params.width = 720;
655 cx->params.height = cx->is_50hz ? 576 : 480;
656 cx->vbi.count = cx->is_50hz ? 18 : 12;
657 cx->vbi.start[0] = cx->is_50hz ? 6 : 10;
658 cx->vbi.start[1] = cx->is_50hz ? 318 : 273;
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300659 CX18_DEBUG_INFO("Switching standard to %llx.\n",
660 (unsigned long long) cx->std);
661
662 /* Tuner */
663 cx18_call_i2c_clients(cx, VIDIOC_S_STD, &cx->std);
664 return 0;
665}
666
667static int cx18_s_tuner(struct file *file, void *fh, struct v4l2_tuner *vt)
668{
669 struct cx18_open_id *id = fh;
670 struct cx18 *cx = id->cx;
671 int ret;
672
673 ret = v4l2_prio_check(&cx->prio, &id->prio);
674 if (ret)
675 return ret;
676
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300677 if (vt->index != 0)
678 return -EINVAL;
679
680 /* Setting tuner can only set audio mode */
681 cx18_call_i2c_clients(cx, VIDIOC_S_TUNER, vt);
682
683 return 0;
684}
685
686static int cx18_g_tuner(struct file *file, void *fh, struct v4l2_tuner *vt)
687{
688 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
689
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300690 if (vt->index != 0)
691 return -EINVAL;
692
693 cx18_call_i2c_clients(cx, VIDIOC_G_TUNER, vt);
694
695 if (test_bit(CX18_F_I_RADIO_USER, &cx->i_flags)) {
696 strlcpy(vt->name, "cx18 Radio Tuner", sizeof(vt->name));
697 vt->type = V4L2_TUNER_RADIO;
698 } else {
699 strlcpy(vt->name, "cx18 TV Tuner", sizeof(vt->name));
700 vt->type = V4L2_TUNER_ANALOG_TV;
701 }
702
703 return 0;
704}
705
706static int cx18_g_sliced_vbi_cap(struct file *file, void *fh,
707 struct v4l2_sliced_vbi_cap *cap)
708{
Andy Walls302df972009-01-31 00:33:02 -0300709 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
710 int set = cx->is_50hz ? V4L2_SLICED_VBI_625 : V4L2_SLICED_VBI_525;
711 int f, l;
712
Andy Wallsc1994082009-02-05 22:37:49 -0300713 if (cap->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE)
714 return -EINVAL;
715
716 cap->service_set = 0;
717 for (f = 0; f < 2; f++) {
718 for (l = 0; l < 24; l++) {
719 if (valid_service_line(f, l, cx->is_50hz)) {
720 /*
721 * We can find all v4l2 supported vbi services
722 * for the standard, on a valid line for the std
723 */
724 cap->service_lines[f][l] = set;
725 cap->service_set |= set;
726 } else
727 cap->service_lines[f][l] = 0;
Andy Walls302df972009-01-31 00:33:02 -0300728 }
Andy Walls302df972009-01-31 00:33:02 -0300729 }
Andy Wallsc1994082009-02-05 22:37:49 -0300730 for (f = 0; f < 3; f++)
731 cap->reserved[f] = 0;
732 return 0;
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300733}
734
735static int cx18_g_enc_index(struct file *file, void *fh,
736 struct v4l2_enc_idx *idx)
737{
738 return -EINVAL;
739}
740
741static int cx18_encoder_cmd(struct file *file, void *fh,
742 struct v4l2_encoder_cmd *enc)
743{
744 struct cx18_open_id *id = fh;
745 struct cx18 *cx = id->cx;
Andy Wallsd3c5e702008-08-23 16:42:29 -0300746 u32 h;
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300747
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300748 switch (enc->cmd) {
749 case V4L2_ENC_CMD_START:
750 CX18_DEBUG_IOCTL("V4L2_ENC_CMD_START\n");
751 enc->flags = 0;
752 return cx18_start_capture(id);
753
754 case V4L2_ENC_CMD_STOP:
755 CX18_DEBUG_IOCTL("V4L2_ENC_CMD_STOP\n");
756 enc->flags &= V4L2_ENC_CMD_STOP_AT_GOP_END;
757 cx18_stop_capture(id,
758 enc->flags & V4L2_ENC_CMD_STOP_AT_GOP_END);
759 break;
760
761 case V4L2_ENC_CMD_PAUSE:
762 CX18_DEBUG_IOCTL("V4L2_ENC_CMD_PAUSE\n");
763 enc->flags = 0;
764 if (!atomic_read(&cx->ana_capturing))
765 return -EPERM;
766 if (test_and_set_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags))
767 return 0;
Andy Wallsd3c5e702008-08-23 16:42:29 -0300768 h = cx18_find_handle(cx);
769 if (h == CX18_INVALID_TASK_HANDLE) {
770 CX18_ERR("Can't find valid task handle for "
771 "V4L2_ENC_CMD_PAUSE\n");
772 return -EBADFD;
773 }
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300774 cx18_mute(cx);
Andy Wallsd3c5e702008-08-23 16:42:29 -0300775 cx18_vapi(cx, CX18_CPU_CAPTURE_PAUSE, 1, h);
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300776 break;
777
778 case V4L2_ENC_CMD_RESUME:
779 CX18_DEBUG_IOCTL("V4L2_ENC_CMD_RESUME\n");
780 enc->flags = 0;
781 if (!atomic_read(&cx->ana_capturing))
782 return -EPERM;
783 if (!test_and_clear_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags))
784 return 0;
Andy Wallsd3c5e702008-08-23 16:42:29 -0300785 h = cx18_find_handle(cx);
786 if (h == CX18_INVALID_TASK_HANDLE) {
787 CX18_ERR("Can't find valid task handle for "
788 "V4L2_ENC_CMD_RESUME\n");
789 return -EBADFD;
790 }
791 cx18_vapi(cx, CX18_CPU_CAPTURE_RESUME, 1, h);
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300792 cx18_unmute(cx);
793 break;
794
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300795 default:
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300796 CX18_DEBUG_IOCTL("Unknown cmd %d\n", enc->cmd);
797 return -EINVAL;
798 }
799 return 0;
800}
801
802static int cx18_try_encoder_cmd(struct file *file, void *fh,
803 struct v4l2_encoder_cmd *enc)
804{
805 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
806
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300807 switch (enc->cmd) {
808 case V4L2_ENC_CMD_START:
809 CX18_DEBUG_IOCTL("V4L2_ENC_CMD_START\n");
810 enc->flags = 0;
811 break;
812
813 case V4L2_ENC_CMD_STOP:
814 CX18_DEBUG_IOCTL("V4L2_ENC_CMD_STOP\n");
815 enc->flags &= V4L2_ENC_CMD_STOP_AT_GOP_END;
816 break;
817
818 case V4L2_ENC_CMD_PAUSE:
819 CX18_DEBUG_IOCTL("V4L2_ENC_CMD_PAUSE\n");
820 enc->flags = 0;
821 break;
822
823 case V4L2_ENC_CMD_RESUME:
824 CX18_DEBUG_IOCTL("V4L2_ENC_CMD_RESUME\n");
825 enc->flags = 0;
826 break;
827
828 default:
829 CX18_DEBUG_IOCTL("Unknown cmd %d\n", enc->cmd);
830 return -EINVAL;
831 }
832 return 0;
833}
834
835static int cx18_log_status(struct file *file, void *fh)
836{
837 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
838 struct v4l2_input vidin;
839 struct v4l2_audio audin;
840 int i;
841
Andy Wallse0f28b62009-01-10 14:13:46 -0300842 CX18_INFO("================= START STATUS CARD #%d "
843 "=================\n", cx->num);
844 CX18_INFO("Version: %s Card: %s\n", CX18_VERSION, cx->card_name);
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300845 if (cx->hw_flags & CX18_HW_TVEEPROM) {
846 struct tveeprom tv;
847
848 cx18_read_eeprom(cx, &tv);
849 }
850 cx18_call_i2c_clients(cx, VIDIOC_LOG_STATUS, NULL);
851 cx18_get_input(cx, cx->active_input, &vidin);
852 cx18_get_audio_input(cx, cx->audio_input, &audin);
853 CX18_INFO("Video Input: %s\n", vidin.name);
854 CX18_INFO("Audio Input: %s\n", audin.name);
Andy Walls8abdd002008-07-13 19:05:25 -0300855 mutex_lock(&cx->gpio_lock);
Hans Verkuil3d66c402008-06-21 11:19:34 -0300856 CX18_INFO("GPIO: direction 0x%08x, value 0x%08x\n",
857 cx->gpio_dir, cx->gpio_val);
Andy Walls8abdd002008-07-13 19:05:25 -0300858 mutex_unlock(&cx->gpio_lock);
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300859 CX18_INFO("Tuner: %s\n",
860 test_bit(CX18_F_I_RADIO_USER, &cx->i_flags) ? "Radio" : "TV");
861 cx2341x_log_status(&cx->params, cx->name);
862 CX18_INFO("Status flags: 0x%08lx\n", cx->i_flags);
863 for (i = 0; i < CX18_MAX_STREAMS; i++) {
864 struct cx18_stream *s = &cx->streams[i];
865
Andy Walls3d059132009-01-10 21:54:39 -0300866 if (s->video_dev == NULL || s->buffers == 0)
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300867 continue;
868 CX18_INFO("Stream %s: status 0x%04lx, %d%% of %d KiB (%d buffers) in use\n",
869 s->name, s->s_flags,
Andy Walls66c2a6b2008-12-08 23:02:45 -0300870 atomic_read(&s->q_full.buffers) * 100 / s->buffers,
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300871 (s->buffers * s->buf_size) / 1024, s->buffers);
872 }
873 CX18_INFO("Read MPEG/VBI: %lld/%lld bytes\n",
874 (long long)cx->mpg_data_received,
875 (long long)cx->vbi_data_inserted);
876 CX18_INFO("================== END STATUS CARD #%d ==================\n", cx->num);
877 return 0;
878}
879
Hans Verkuil069b7472008-12-30 07:04:34 -0300880static long cx18_default(struct file *file, void *fh, int cmd, void *arg)
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300881{
882 struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;
883
884 switch (cmd) {
885 case VIDIOC_INT_S_AUDIO_ROUTING: {
886 struct v4l2_routing *route = arg;
Hans Verkuil37f89f92008-06-22 11:57:31 -0300887
888 CX18_DEBUG_IOCTL("VIDIOC_INT_S_AUDIO_ROUTING(%d, %d)\n",
889 route->input, route->output);
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300890 cx18_audio_set_route(cx, route);
891 break;
892 }
Andy Walls02fa2722008-07-13 19:30:15 -0300893
894 case VIDIOC_INT_RESET: {
895 u32 val = *(u32 *)arg;
896
897 if ((val == 0) || (val & 0x01))
898 cx18_reset_ir_gpio(&cx->i2c_algo_cb_data[0]);
899 break;
900 }
901
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300902 default:
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300903 return -EINVAL;
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300904 }
905 return 0;
906}
907
Hans Verkuil069b7472008-12-30 07:04:34 -0300908long cx18_v4l2_ioctl(struct file *filp, unsigned int cmd,
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300909 unsigned long arg)
910{
Hans Verkuil37f89f92008-06-22 11:57:31 -0300911 struct video_device *vfd = video_devdata(filp);
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300912 struct cx18_open_id *id = (struct cx18_open_id *)filp->private_data;
913 struct cx18 *cx = id->cx;
Hans Verkuil069b7472008-12-30 07:04:34 -0300914 long res;
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300915
916 mutex_lock(&cx->serialize_lock);
Hans Verkuil37f89f92008-06-22 11:57:31 -0300917
918 if (cx18_debug & CX18_DBGFLG_IOCTL)
919 vfd->debug = V4L2_DEBUG_IOCTL | V4L2_DEBUG_IOCTL_ARG;
Hans Verkuilbec43662008-12-30 06:58:20 -0300920 res = video_ioctl2(filp, cmd, arg);
Hans Verkuil37f89f92008-06-22 11:57:31 -0300921 vfd->debug = 0;
Hans Verkuil1c1e45d2008-04-28 20:24:33 -0300922 mutex_unlock(&cx->serialize_lock);
923 return res;
924}
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300925
Hans Verkuila3998102008-07-21 02:57:38 -0300926static const struct v4l2_ioctl_ops cx18_ioctl_ops = {
927 .vidioc_querycap = cx18_querycap,
928 .vidioc_g_priority = cx18_g_priority,
929 .vidioc_s_priority = cx18_s_priority,
930 .vidioc_s_audio = cx18_s_audio,
931 .vidioc_g_audio = cx18_g_audio,
932 .vidioc_enumaudio = cx18_enumaudio,
933 .vidioc_enum_input = cx18_enum_input,
934 .vidioc_cropcap = cx18_cropcap,
935 .vidioc_s_crop = cx18_s_crop,
936 .vidioc_g_crop = cx18_g_crop,
937 .vidioc_g_input = cx18_g_input,
938 .vidioc_s_input = cx18_s_input,
939 .vidioc_g_frequency = cx18_g_frequency,
940 .vidioc_s_frequency = cx18_s_frequency,
941 .vidioc_s_tuner = cx18_s_tuner,
942 .vidioc_g_tuner = cx18_g_tuner,
943 .vidioc_g_enc_index = cx18_g_enc_index,
944 .vidioc_g_std = cx18_g_std,
945 .vidioc_s_std = cx18_s_std,
946 .vidioc_log_status = cx18_log_status,
947 .vidioc_enum_fmt_vid_cap = cx18_enum_fmt_vid_cap,
948 .vidioc_encoder_cmd = cx18_encoder_cmd,
949 .vidioc_try_encoder_cmd = cx18_try_encoder_cmd,
950 .vidioc_g_fmt_vid_cap = cx18_g_fmt_vid_cap,
951 .vidioc_g_fmt_vbi_cap = cx18_g_fmt_vbi_cap,
952 .vidioc_g_fmt_sliced_vbi_cap = cx18_g_fmt_sliced_vbi_cap,
953 .vidioc_s_fmt_vid_cap = cx18_s_fmt_vid_cap,
954 .vidioc_s_fmt_vbi_cap = cx18_s_fmt_vbi_cap,
955 .vidioc_s_fmt_sliced_vbi_cap = cx18_s_fmt_sliced_vbi_cap,
956 .vidioc_try_fmt_vid_cap = cx18_try_fmt_vid_cap,
957 .vidioc_try_fmt_vbi_cap = cx18_try_fmt_vbi_cap,
958 .vidioc_try_fmt_sliced_vbi_cap = cx18_try_fmt_sliced_vbi_cap,
959 .vidioc_g_sliced_vbi_cap = cx18_g_sliced_vbi_cap,
960 .vidioc_g_chip_ident = cx18_g_chip_ident,
961#ifdef CONFIG_VIDEO_ADV_DEBUG
962 .vidioc_g_register = cx18_g_register,
963 .vidioc_s_register = cx18_s_register,
964#endif
965 .vidioc_default = cx18_default,
966 .vidioc_queryctrl = cx18_queryctrl,
967 .vidioc_querymenu = cx18_querymenu,
968 .vidioc_g_ext_ctrls = cx18_g_ext_ctrls,
969 .vidioc_s_ext_ctrls = cx18_s_ext_ctrls,
970 .vidioc_try_ext_ctrls = cx18_try_ext_ctrls,
971};
972
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300973void cx18_set_funcs(struct video_device *vdev)
974{
Hans Verkuila3998102008-07-21 02:57:38 -0300975 vdev->ioctl_ops = &cx18_ioctl_ops;
Andy Walls3b6fe58f2008-06-21 08:36:31 -0300976}