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