blob: 72a417b3174521e2f67aac7944274351052307e8 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 *
3 * device driver for Conexant 2388x based TV cards
4 * video4linux video interface
5 *
6 * (c) 2003-04 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23#include <linux/init.h>
24#include <linux/list.h>
25#include <linux/module.h>
26#include <linux/moduleparam.h>
27#include <linux/kmod.h>
28#include <linux/kernel.h>
29#include <linux/slab.h>
30#include <linux/interrupt.h>
31#include <linux/delay.h>
32#include <linux/kthread.h>
33#include <asm/div64.h>
34
35#include "cx88.h"
Michael Krufky5e453dc2006-01-09 15:32:31 -020036#include <media/v4l2-common.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
Mauro Carvalho Chehab79436632005-11-08 21:37:49 -080038/* Include V4L1 specific functions. Should be removed soon */
39#include <linux/videodev.h>
40
Linus Torvalds1da177e2005-04-16 15:20:36 -070041MODULE_DESCRIPTION("v4l2 driver module for cx2388x based TV cards");
42MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
43MODULE_LICENSE("GPL");
44
45/* ------------------------------------------------------------------ */
46
47static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
48static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
49static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
50
51module_param_array(video_nr, int, NULL, 0444);
52module_param_array(vbi_nr, int, NULL, 0444);
53module_param_array(radio_nr, int, NULL, 0444);
54
55MODULE_PARM_DESC(video_nr,"video device numbers");
56MODULE_PARM_DESC(vbi_nr,"vbi device numbers");
57MODULE_PARM_DESC(radio_nr,"radio device numbers");
58
59static unsigned int video_debug = 0;
60module_param(video_debug,int,0644);
61MODULE_PARM_DESC(video_debug,"enable debug messages [video]");
62
63static unsigned int irq_debug = 0;
64module_param(irq_debug,int,0644);
65MODULE_PARM_DESC(irq_debug,"enable debug messages [IRQ handler]");
66
67static unsigned int vid_limit = 16;
68module_param(vid_limit,int,0644);
69MODULE_PARM_DESC(vid_limit,"capture memory limit in megabytes");
70
71#define dprintk(level,fmt, arg...) if (video_debug >= level) \
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -070072 printk(KERN_DEBUG "%s/0: " fmt, core->name , ## arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
74/* ------------------------------------------------------------------ */
75
76static LIST_HEAD(cx8800_devlist);
77
78/* ------------------------------------------------------------------- */
79/* static data */
80
81static struct cx88_tvnorm tvnorms[] = {
82 {
83 .name = "NTSC-M",
84 .id = V4L2_STD_NTSC_M,
85 .cxiformat = VideoFormatNTSC,
86 .cxoformat = 0x181f0008,
87 },{
88 .name = "NTSC-JP",
89 .id = V4L2_STD_NTSC_M_JP,
90 .cxiformat = VideoFormatNTSCJapan,
91 .cxoformat = 0x181f0008,
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 },{
93 .name = "PAL-BG",
94 .id = V4L2_STD_PAL_BG,
95 .cxiformat = VideoFormatPAL,
96 .cxoformat = 0x181f0008,
97 },{
98 .name = "PAL-DK",
99 .id = V4L2_STD_PAL_DK,
100 .cxiformat = VideoFormatPAL,
101 .cxoformat = 0x181f0008,
102 },{
103 .name = "PAL-I",
104 .id = V4L2_STD_PAL_I,
105 .cxiformat = VideoFormatPAL,
106 .cxoformat = 0x181f0008,
Mauro Carvalho Chehab4ac97912005-11-08 21:37:43 -0800107 },{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 .name = "PAL-M",
109 .id = V4L2_STD_PAL_M,
110 .cxiformat = VideoFormatPALM,
111 .cxoformat = 0x1c1f0008,
112 },{
113 .name = "PAL-N",
114 .id = V4L2_STD_PAL_N,
115 .cxiformat = VideoFormatPALN,
116 .cxoformat = 0x1c1f0008,
117 },{
118 .name = "PAL-Nc",
119 .id = V4L2_STD_PAL_Nc,
120 .cxiformat = VideoFormatPALNC,
121 .cxoformat = 0x1c1f0008,
122 },{
123 .name = "PAL-60",
124 .id = V4L2_STD_PAL_60,
125 .cxiformat = VideoFormatPAL60,
126 .cxoformat = 0x181f0008,
127 },{
128 .name = "SECAM-L",
129 .id = V4L2_STD_SECAM_L,
130 .cxiformat = VideoFormatSECAM,
131 .cxoformat = 0x181f0008,
132 },{
133 .name = "SECAM-DK",
134 .id = V4L2_STD_SECAM_DK,
135 .cxiformat = VideoFormatSECAM,
136 .cxoformat = 0x181f0008,
137 }
138};
139
140static struct cx8800_fmt formats[] = {
141 {
142 .name = "8 bpp, gray",
143 .fourcc = V4L2_PIX_FMT_GREY,
144 .cxformat = ColorFormatY8,
145 .depth = 8,
146 .flags = FORMAT_FLAGS_PACKED,
147 },{
148 .name = "15 bpp RGB, le",
149 .fourcc = V4L2_PIX_FMT_RGB555,
150 .cxformat = ColorFormatRGB15,
151 .depth = 16,
152 .flags = FORMAT_FLAGS_PACKED,
153 },{
154 .name = "15 bpp RGB, be",
155 .fourcc = V4L2_PIX_FMT_RGB555X,
156 .cxformat = ColorFormatRGB15 | ColorFormatBSWAP,
157 .depth = 16,
158 .flags = FORMAT_FLAGS_PACKED,
159 },{
160 .name = "16 bpp RGB, le",
161 .fourcc = V4L2_PIX_FMT_RGB565,
162 .cxformat = ColorFormatRGB16,
163 .depth = 16,
164 .flags = FORMAT_FLAGS_PACKED,
165 },{
166 .name = "16 bpp RGB, be",
167 .fourcc = V4L2_PIX_FMT_RGB565X,
168 .cxformat = ColorFormatRGB16 | ColorFormatBSWAP,
169 .depth = 16,
170 .flags = FORMAT_FLAGS_PACKED,
171 },{
172 .name = "24 bpp RGB, le",
173 .fourcc = V4L2_PIX_FMT_BGR24,
174 .cxformat = ColorFormatRGB24,
175 .depth = 24,
176 .flags = FORMAT_FLAGS_PACKED,
177 },{
178 .name = "32 bpp RGB, le",
179 .fourcc = V4L2_PIX_FMT_BGR32,
180 .cxformat = ColorFormatRGB32,
181 .depth = 32,
182 .flags = FORMAT_FLAGS_PACKED,
183 },{
184 .name = "32 bpp RGB, be",
185 .fourcc = V4L2_PIX_FMT_RGB32,
186 .cxformat = ColorFormatRGB32 | ColorFormatBSWAP | ColorFormatWSWAP,
187 .depth = 32,
188 .flags = FORMAT_FLAGS_PACKED,
189 },{
190 .name = "4:2:2, packed, YUYV",
191 .fourcc = V4L2_PIX_FMT_YUYV,
192 .cxformat = ColorFormatYUY2,
193 .depth = 16,
194 .flags = FORMAT_FLAGS_PACKED,
195 },{
196 .name = "4:2:2, packed, UYVY",
197 .fourcc = V4L2_PIX_FMT_UYVY,
198 .cxformat = ColorFormatYUY2 | ColorFormatBSWAP,
199 .depth = 16,
200 .flags = FORMAT_FLAGS_PACKED,
201 },
202};
203
204static struct cx8800_fmt* format_by_fourcc(unsigned int fourcc)
205{
206 unsigned int i;
207
208 for (i = 0; i < ARRAY_SIZE(formats); i++)
209 if (formats[i].fourcc == fourcc)
210 return formats+i;
211 return NULL;
212}
213
214/* ------------------------------------------------------------------- */
215
216static const struct v4l2_queryctrl no_ctl = {
217 .name = "42",
218 .flags = V4L2_CTRL_FLAG_DISABLED,
219};
220
221static struct cx88_ctrl cx8800_ctls[] = {
222 /* --- video --- */
223 {
224 .v = {
225 .id = V4L2_CID_BRIGHTNESS,
226 .name = "Brightness",
227 .minimum = 0x00,
228 .maximum = 0xff,
229 .step = 1,
Marcin Rudowski9f9c9072006-03-12 00:03:47 -0300230 .default_value = 0x7f,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231 .type = V4L2_CTRL_TYPE_INTEGER,
232 },
233 .off = 128,
234 .reg = MO_CONTR_BRIGHT,
235 .mask = 0x00ff,
236 .shift = 0,
237 },{
238 .v = {
239 .id = V4L2_CID_CONTRAST,
240 .name = "Contrast",
241 .minimum = 0,
242 .maximum = 0xff,
243 .step = 1,
Mauro Carvalho Chehab70f00042006-01-09 15:25:26 -0200244 .default_value = 0x3f,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 .type = V4L2_CTRL_TYPE_INTEGER,
246 },
Mauro Carvalho Chehab41ef7c12005-07-12 13:58:44 -0700247 .off = 0,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248 .reg = MO_CONTR_BRIGHT,
249 .mask = 0xff00,
250 .shift = 8,
251 },{
252 .v = {
253 .id = V4L2_CID_HUE,
254 .name = "Hue",
255 .minimum = 0,
256 .maximum = 0xff,
257 .step = 1,
Marcin Rudowski9f9c9072006-03-12 00:03:47 -0300258 .default_value = 0x7f,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259 .type = V4L2_CTRL_TYPE_INTEGER,
260 },
Michael Krufky9ac4c1582005-07-07 17:58:38 -0700261 .off = 128,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262 .reg = MO_HUE,
263 .mask = 0x00ff,
264 .shift = 0,
265 },{
266 /* strictly, this only describes only U saturation.
267 * V saturation is handled specially through code.
268 */
269 .v = {
270 .id = V4L2_CID_SATURATION,
271 .name = "Saturation",
272 .minimum = 0,
273 .maximum = 0xff,
274 .step = 1,
Mauro Carvalho Chehab70f00042006-01-09 15:25:26 -0200275 .default_value = 0x7f,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276 .type = V4L2_CTRL_TYPE_INTEGER,
277 },
278 .off = 0,
279 .reg = MO_UV_SATURATION,
280 .mask = 0x00ff,
281 .shift = 0,
282 },{
283 /* --- audio --- */
284 .v = {
285 .id = V4L2_CID_AUDIO_MUTE,
286 .name = "Mute",
287 .minimum = 0,
288 .maximum = 1,
Mauro Carvalho Chehab70f00042006-01-09 15:25:26 -0200289 .default_value = 1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290 .type = V4L2_CTRL_TYPE_BOOLEAN,
291 },
292 .reg = AUD_VOL_CTL,
293 .sreg = SHADOW_AUD_VOL_CTL,
294 .mask = (1 << 6),
295 .shift = 6,
296 },{
297 .v = {
298 .id = V4L2_CID_AUDIO_VOLUME,
299 .name = "Volume",
300 .minimum = 0,
301 .maximum = 0x3f,
302 .step = 1,
Marcin Rudowski9f9c9072006-03-12 00:03:47 -0300303 .default_value = 0x3f,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304 .type = V4L2_CTRL_TYPE_INTEGER,
305 },
306 .reg = AUD_VOL_CTL,
307 .sreg = SHADOW_AUD_VOL_CTL,
308 .mask = 0x3f,
309 .shift = 0,
310 },{
311 .v = {
312 .id = V4L2_CID_AUDIO_BALANCE,
313 .name = "Balance",
314 .minimum = 0,
315 .maximum = 0x7f,
316 .step = 1,
317 .default_value = 0x40,
318 .type = V4L2_CTRL_TYPE_INTEGER,
319 },
320 .reg = AUD_BAL_CTL,
321 .sreg = SHADOW_AUD_BAL_CTL,
322 .mask = 0x7f,
323 .shift = 0,
324 }
325};
Adrian Bunk408b6642005-05-01 08:59:29 -0700326static const int CX8800_CTLS = ARRAY_SIZE(cx8800_ctls);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327
328/* ------------------------------------------------------------------- */
329/* resource management */
330
331static int res_get(struct cx8800_dev *dev, struct cx8800_fh *fh, unsigned int bit)
332{
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700333 struct cx88_core *core = dev->core;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334 if (fh->resources & bit)
335 /* have it already allocated */
336 return 1;
337
338 /* is it free? */
Ingo Molnar3593cab2006-02-07 06:49:14 -0200339 mutex_lock(&core->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 if (dev->resources & bit) {
341 /* no, someone else uses it */
Ingo Molnar3593cab2006-02-07 06:49:14 -0200342 mutex_unlock(&core->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343 return 0;
344 }
345 /* it's free, grab it */
346 fh->resources |= bit;
347 dev->resources |= bit;
348 dprintk(1,"res: get %d\n",bit);
Ingo Molnar3593cab2006-02-07 06:49:14 -0200349 mutex_unlock(&core->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350 return 1;
351}
352
353static
354int res_check(struct cx8800_fh *fh, unsigned int bit)
355{
356 return (fh->resources & bit);
357}
358
359static
360int res_locked(struct cx8800_dev *dev, unsigned int bit)
361{
362 return (dev->resources & bit);
363}
364
365static
366void res_free(struct cx8800_dev *dev, struct cx8800_fh *fh, unsigned int bits)
367{
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700368 struct cx88_core *core = dev->core;
Eric Sesterhennae246012006-03-13 13:17:11 -0300369 BUG_ON((fh->resources & bits) != bits);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370
Ingo Molnar3593cab2006-02-07 06:49:14 -0200371 mutex_lock(&core->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372 fh->resources &= ~bits;
373 dev->resources &= ~bits;
374 dprintk(1,"res: put %d\n",bits);
Ingo Molnar3593cab2006-02-07 06:49:14 -0200375 mutex_unlock(&core->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376}
377
378/* ------------------------------------------------------------------ */
379
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700380/* static int video_mux(struct cx8800_dev *dev, unsigned int input) */
381static int video_mux(struct cx88_core *core, unsigned int input)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382{
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700383 /* struct cx88_core *core = dev->core; */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384
385 dprintk(1,"video_mux: %d [vmux=%d,gpio=0x%x,0x%x,0x%x,0x%x]\n",
386 input, INPUT(input)->vmux,
387 INPUT(input)->gpio0,INPUT(input)->gpio1,
388 INPUT(input)->gpio2,INPUT(input)->gpio3);
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700389 core->input = input;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390 cx_andor(MO_INPUT_FORMAT, 0x03 << 14, INPUT(input)->vmux << 14);
391 cx_write(MO_GP3_IO, INPUT(input)->gpio3);
392 cx_write(MO_GP0_IO, INPUT(input)->gpio0);
393 cx_write(MO_GP1_IO, INPUT(input)->gpio1);
394 cx_write(MO_GP2_IO, INPUT(input)->gpio2);
395
396 switch (INPUT(input)->type) {
397 case CX88_VMUX_SVIDEO:
398 cx_set(MO_AFECFG_IO, 0x00000001);
399 cx_set(MO_INPUT_FORMAT, 0x00010010);
400 cx_set(MO_FILTER_EVEN, 0x00002020);
401 cx_set(MO_FILTER_ODD, 0x00002020);
402 break;
403 default:
404 cx_clear(MO_AFECFG_IO, 0x00000001);
405 cx_clear(MO_INPUT_FORMAT, 0x00010010);
406 cx_clear(MO_FILTER_EVEN, 0x00002020);
407 cx_clear(MO_FILTER_ODD, 0x00002020);
408 break;
409 }
410 return 0;
411}
412
413/* ------------------------------------------------------------------ */
414
415static int start_video_dma(struct cx8800_dev *dev,
416 struct cx88_dmaqueue *q,
417 struct cx88_buffer *buf)
418{
419 struct cx88_core *core = dev->core;
420
421 /* setup fifo + format */
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700422 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH21],
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423 buf->bpl, buf->risc.dma);
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700424 cx88_set_scale(core, buf->vb.width, buf->vb.height, buf->vb.field);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425 cx_write(MO_COLOR_CTRL, buf->fmt->cxformat | ColorFormatGamma);
426
427 /* reset counter */
428 cx_write(MO_VIDY_GPCNTRL,GP_COUNT_CONTROL_RESET);
429 q->count = 1;
430
431 /* enable irqs */
432 cx_set(MO_PCI_INTMSK, core->pci_irqmask | 0x01);
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700433
434 /* Enables corresponding bits at PCI_INT_STAT:
435 bits 0 to 4: video, audio, transport stream, VIP, Host
436 bit 7: timer
437 bits 8 and 9: DMA complete for: SRC, DST
438 bits 10 and 11: BERR signal asserted for RISC: RD, WR
439 bits 12 to 15: BERR signal asserted for: BRDG, SRC, DST, IPB
440 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441 cx_set(MO_VID_INTMSK, 0x0f0011);
442
443 /* enable capture */
444 cx_set(VID_CAPTURE_CONTROL,0x06);
445
446 /* start dma */
447 cx_set(MO_DEV_CNTRL2, (1<<5));
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700448 cx_set(MO_VID_DMACNTRL, 0x11); /* Planar Y and packed FIFO and RISC enable */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449
450 return 0;
451}
452
453static int stop_video_dma(struct cx8800_dev *dev)
454{
455 struct cx88_core *core = dev->core;
456
457 /* stop dma */
458 cx_clear(MO_VID_DMACNTRL, 0x11);
459
460 /* disable capture */
461 cx_clear(VID_CAPTURE_CONTROL,0x06);
462
463 /* disable irqs */
464 cx_clear(MO_PCI_INTMSK, 0x000001);
465 cx_clear(MO_VID_INTMSK, 0x0f0011);
466 return 0;
467}
468
469static int restart_video_queue(struct cx8800_dev *dev,
470 struct cx88_dmaqueue *q)
471{
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700472 struct cx88_core *core = dev->core;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473 struct cx88_buffer *buf, *prev;
474 struct list_head *item;
475
476 if (!list_empty(&q->active)) {
Mauro Carvalho Chehab4ac97912005-11-08 21:37:43 -0800477 buf = list_entry(q->active.next, struct cx88_buffer, vb.queue);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478 dprintk(2,"restart_queue [%p/%d]: restart dma\n",
479 buf, buf->vb.i);
480 start_video_dma(dev, q, buf);
481 list_for_each(item,&q->active) {
482 buf = list_entry(item, struct cx88_buffer, vb.queue);
483 buf->count = q->count++;
484 }
485 mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
486 return 0;
487 }
488
489 prev = NULL;
490 for (;;) {
491 if (list_empty(&q->queued))
492 return 0;
Mauro Carvalho Chehab4ac97912005-11-08 21:37:43 -0800493 buf = list_entry(q->queued.next, struct cx88_buffer, vb.queue);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494 if (NULL == prev) {
495 list_del(&buf->vb.queue);
496 list_add_tail(&buf->vb.queue,&q->active);
497 start_video_dma(dev, q, buf);
498 buf->vb.state = STATE_ACTIVE;
499 buf->count = q->count++;
500 mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
501 dprintk(2,"[%p/%d] restart_queue - first active\n",
502 buf,buf->vb.i);
503
504 } else if (prev->vb.width == buf->vb.width &&
505 prev->vb.height == buf->vb.height &&
506 prev->fmt == buf->fmt) {
507 list_del(&buf->vb.queue);
508 list_add_tail(&buf->vb.queue,&q->active);
509 buf->vb.state = STATE_ACTIVE;
510 buf->count = q->count++;
511 prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
512 dprintk(2,"[%p/%d] restart_queue - move to active\n",
513 buf,buf->vb.i);
514 } else {
515 return 0;
516 }
517 prev = buf;
518 }
519}
520
521/* ------------------------------------------------------------------ */
522
523static int
524buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
525{
526 struct cx8800_fh *fh = q->priv_data;
527
528 *size = fh->fmt->depth*fh->width*fh->height >> 3;
529 if (0 == *count)
530 *count = 32;
531 while (*size * *count > vid_limit * 1024 * 1024)
532 (*count)--;
533 return 0;
534}
535
536static int
537buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
538 enum v4l2_field field)
539{
540 struct cx8800_fh *fh = q->priv_data;
541 struct cx8800_dev *dev = fh->dev;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700542 struct cx88_core *core = dev->core;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543 struct cx88_buffer *buf = container_of(vb,struct cx88_buffer,vb);
544 int rc, init_buffer = 0;
545
546 BUG_ON(NULL == fh->fmt);
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700547 if (fh->width < 48 || fh->width > norm_maxw(core->tvnorm) ||
548 fh->height < 32 || fh->height > norm_maxh(core->tvnorm))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549 return -EINVAL;
550 buf->vb.size = (fh->width * fh->height * fh->fmt->depth) >> 3;
551 if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size)
552 return -EINVAL;
553
554 if (buf->fmt != fh->fmt ||
555 buf->vb.width != fh->width ||
556 buf->vb.height != fh->height ||
557 buf->vb.field != field) {
558 buf->fmt = fh->fmt;
559 buf->vb.width = fh->width;
560 buf->vb.height = fh->height;
561 buf->vb.field = field;
562 init_buffer = 1;
563 }
564
565 if (STATE_NEEDS_INIT == buf->vb.state) {
566 init_buffer = 1;
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -0300567 if (0 != (rc = videobuf_iolock(q,&buf->vb,NULL)))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568 goto fail;
569 }
570
571 if (init_buffer) {
572 buf->bpl = buf->vb.width * buf->fmt->depth >> 3;
573 switch (buf->vb.field) {
574 case V4L2_FIELD_TOP:
575 cx88_risc_buffer(dev->pci, &buf->risc,
576 buf->vb.dma.sglist, 0, UNSET,
577 buf->bpl, 0, buf->vb.height);
578 break;
579 case V4L2_FIELD_BOTTOM:
580 cx88_risc_buffer(dev->pci, &buf->risc,
581 buf->vb.dma.sglist, UNSET, 0,
582 buf->bpl, 0, buf->vb.height);
583 break;
584 case V4L2_FIELD_INTERLACED:
585 cx88_risc_buffer(dev->pci, &buf->risc,
586 buf->vb.dma.sglist, 0, buf->bpl,
587 buf->bpl, buf->bpl,
588 buf->vb.height >> 1);
589 break;
590 case V4L2_FIELD_SEQ_TB:
591 cx88_risc_buffer(dev->pci, &buf->risc,
592 buf->vb.dma.sglist,
593 0, buf->bpl * (buf->vb.height >> 1),
594 buf->bpl, 0,
595 buf->vb.height >> 1);
596 break;
597 case V4L2_FIELD_SEQ_BT:
598 cx88_risc_buffer(dev->pci, &buf->risc,
599 buf->vb.dma.sglist,
600 buf->bpl * (buf->vb.height >> 1), 0,
601 buf->bpl, 0,
602 buf->vb.height >> 1);
603 break;
604 default:
605 BUG();
606 }
607 }
608 dprintk(2,"[%p/%d] buffer_prepare - %dx%d %dbpp \"%s\" - dma=0x%08lx\n",
609 buf, buf->vb.i,
610 fh->width, fh->height, fh->fmt->depth, fh->fmt->name,
611 (unsigned long)buf->risc.dma);
612
613 buf->vb.state = STATE_PREPARED;
614 return 0;
615
616 fail:
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -0300617 cx88_free_buffer(q,buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700618 return rc;
619}
620
621static void
622buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
623{
624 struct cx88_buffer *buf = container_of(vb,struct cx88_buffer,vb);
625 struct cx88_buffer *prev;
626 struct cx8800_fh *fh = vq->priv_data;
627 struct cx8800_dev *dev = fh->dev;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700628 struct cx88_core *core = dev->core;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629 struct cx88_dmaqueue *q = &dev->vidq;
630
631 /* add jump to stopper */
632 buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | RISC_CNT_INC);
633 buf->risc.jmp[1] = cpu_to_le32(q->stopper.dma);
634
635 if (!list_empty(&q->queued)) {
636 list_add_tail(&buf->vb.queue,&q->queued);
637 buf->vb.state = STATE_QUEUED;
638 dprintk(2,"[%p/%d] buffer_queue - append to queued\n",
639 buf, buf->vb.i);
640
641 } else if (list_empty(&q->active)) {
642 list_add_tail(&buf->vb.queue,&q->active);
643 start_video_dma(dev, q, buf);
644 buf->vb.state = STATE_ACTIVE;
645 buf->count = q->count++;
646 mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
647 dprintk(2,"[%p/%d] buffer_queue - first active\n",
648 buf, buf->vb.i);
649
650 } else {
651 prev = list_entry(q->active.prev, struct cx88_buffer, vb.queue);
652 if (prev->vb.width == buf->vb.width &&
653 prev->vb.height == buf->vb.height &&
654 prev->fmt == buf->fmt) {
655 list_add_tail(&buf->vb.queue,&q->active);
656 buf->vb.state = STATE_ACTIVE;
657 buf->count = q->count++;
658 prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
659 dprintk(2,"[%p/%d] buffer_queue - append to active\n",
660 buf, buf->vb.i);
661
662 } else {
663 list_add_tail(&buf->vb.queue,&q->queued);
664 buf->vb.state = STATE_QUEUED;
665 dprintk(2,"[%p/%d] buffer_queue - first queued\n",
666 buf, buf->vb.i);
667 }
668 }
669}
670
671static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
672{
673 struct cx88_buffer *buf = container_of(vb,struct cx88_buffer,vb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -0300675 cx88_free_buffer(q,buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676}
677
Adrian Bunk408b6642005-05-01 08:59:29 -0700678static struct videobuf_queue_ops cx8800_video_qops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679 .buf_setup = buffer_setup,
680 .buf_prepare = buffer_prepare,
681 .buf_queue = buffer_queue,
682 .buf_release = buffer_release,
683};
684
685/* ------------------------------------------------------------------ */
686
Linus Torvalds1da177e2005-04-16 15:20:36 -0700687
688/* ------------------------------------------------------------------ */
689
690static struct videobuf_queue* get_queue(struct cx8800_fh *fh)
691{
692 switch (fh->type) {
693 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
694 return &fh->vidq;
695 case V4L2_BUF_TYPE_VBI_CAPTURE:
696 return &fh->vbiq;
697 default:
698 BUG();
699 return NULL;
700 }
701}
702
703static int get_ressource(struct cx8800_fh *fh)
704{
705 switch (fh->type) {
706 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
707 return RESOURCE_VIDEO;
708 case V4L2_BUF_TYPE_VBI_CAPTURE:
709 return RESOURCE_VBI;
710 default:
711 BUG();
712 return 0;
713 }
714}
715
716static int video_open(struct inode *inode, struct file *file)
717{
718 int minor = iminor(inode);
719 struct cx8800_dev *h,*dev = NULL;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700720 struct cx88_core *core;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721 struct cx8800_fh *fh;
722 struct list_head *list;
723 enum v4l2_buf_type type = 0;
724 int radio = 0;
725
726 list_for_each(list,&cx8800_devlist) {
727 h = list_entry(list, struct cx8800_dev, devlist);
728 if (h->video_dev->minor == minor) {
729 dev = h;
730 type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
731 }
732 if (h->vbi_dev->minor == minor) {
733 dev = h;
734 type = V4L2_BUF_TYPE_VBI_CAPTURE;
735 }
736 if (h->radio_dev &&
737 h->radio_dev->minor == minor) {
738 radio = 1;
739 dev = h;
740 }
741 }
742 if (NULL == dev)
743 return -ENODEV;
744
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700745 core = dev->core;
746
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747 dprintk(1,"open minor=%d radio=%d type=%s\n",
748 minor,radio,v4l2_type_names[type]);
749
750 /* allocate + initialize per filehandle data */
Panagiotis Issaris74081872006-01-11 19:40:56 -0200751 fh = kzalloc(sizeof(*fh),GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700752 if (NULL == fh)
753 return -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700754 file->private_data = fh;
755 fh->dev = dev;
756 fh->radio = radio;
757 fh->type = type;
758 fh->width = 320;
759 fh->height = 240;
760 fh->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24);
761
762 videobuf_queue_init(&fh->vidq, &cx8800_video_qops,
763 dev->pci, &dev->slock,
764 V4L2_BUF_TYPE_VIDEO_CAPTURE,
765 V4L2_FIELD_INTERLACED,
766 sizeof(struct cx88_buffer),
767 fh);
768 videobuf_queue_init(&fh->vbiq, &cx8800_vbi_qops,
769 dev->pci, &dev->slock,
770 V4L2_BUF_TYPE_VBI_CAPTURE,
771 V4L2_FIELD_SEQ_TB,
772 sizeof(struct cx88_buffer),
773 fh);
774
775 if (fh->radio) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700776 int board = core->board;
777 dprintk(1,"video_open: setting radio device\n");
Mauro Carvalho Chehabfd3113e2005-07-31 22:34:43 -0700778 cx_write(MO_GP3_IO, cx88_boards[board].radio.gpio3);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700779 cx_write(MO_GP0_IO, cx88_boards[board].radio.gpio0);
780 cx_write(MO_GP1_IO, cx88_boards[board].radio.gpio1);
781 cx_write(MO_GP2_IO, cx88_boards[board].radio.gpio2);
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700782 core->tvaudio = WW_FM;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700783 cx88_set_tvaudio(core);
784 cx88_set_stereo(core,V4L2_TUNER_MODE_STEREO,1);
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700785 cx88_call_i2c_clients(core,AUDC_SET_RADIO,NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700786 }
787
Mauro Carvalho Chehab4ac97912005-11-08 21:37:43 -0800788 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700789}
790
791static ssize_t
Peter Hagervallf9e7a022005-11-08 21:36:29 -0800792video_read(struct file *file, char __user *data, size_t count, loff_t *ppos)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793{
794 struct cx8800_fh *fh = file->private_data;
795
796 switch (fh->type) {
797 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
798 if (res_locked(fh->dev,RESOURCE_VIDEO))
799 return -EBUSY;
800 return videobuf_read_one(&fh->vidq, data, count, ppos,
801 file->f_flags & O_NONBLOCK);
802 case V4L2_BUF_TYPE_VBI_CAPTURE:
803 if (!res_get(fh->dev,fh,RESOURCE_VBI))
804 return -EBUSY;
805 return videobuf_read_stream(&fh->vbiq, data, count, ppos, 1,
806 file->f_flags & O_NONBLOCK);
807 default:
808 BUG();
809 return 0;
810 }
811}
812
813static unsigned int
814video_poll(struct file *file, struct poll_table_struct *wait)
815{
816 struct cx8800_fh *fh = file->private_data;
817 struct cx88_buffer *buf;
818
819 if (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type) {
820 if (!res_get(fh->dev,fh,RESOURCE_VBI))
821 return POLLERR;
822 return videobuf_poll_stream(file, &fh->vbiq, wait);
823 }
824
825 if (res_check(fh,RESOURCE_VIDEO)) {
826 /* streaming capture */
827 if (list_empty(&fh->vidq.stream))
828 return POLLERR;
829 buf = list_entry(fh->vidq.stream.next,struct cx88_buffer,vb.stream);
830 } else {
831 /* read() capture */
832 buf = (struct cx88_buffer*)fh->vidq.read_buf;
833 if (NULL == buf)
834 return POLLERR;
835 }
836 poll_wait(file, &buf->vb.done, wait);
837 if (buf->vb.state == STATE_DONE ||
838 buf->vb.state == STATE_ERROR)
839 return POLLIN|POLLRDNORM;
840 return 0;
841}
842
843static int video_release(struct inode *inode, struct file *file)
844{
845 struct cx8800_fh *fh = file->private_data;
846 struct cx8800_dev *dev = fh->dev;
847
848 /* turn off overlay */
849 if (res_check(fh, RESOURCE_OVERLAY)) {
850 /* FIXME */
851 res_free(dev,fh,RESOURCE_OVERLAY);
852 }
853
854 /* stop video capture */
855 if (res_check(fh, RESOURCE_VIDEO)) {
856 videobuf_queue_cancel(&fh->vidq);
857 res_free(dev,fh,RESOURCE_VIDEO);
858 }
859 if (fh->vidq.read_buf) {
860 buffer_release(&fh->vidq,fh->vidq.read_buf);
861 kfree(fh->vidq.read_buf);
862 }
863
864 /* stop vbi capture */
865 if (res_check(fh, RESOURCE_VBI)) {
866 if (fh->vbiq.streaming)
867 videobuf_streamoff(&fh->vbiq);
868 if (fh->vbiq.reading)
869 videobuf_read_stop(&fh->vbiq);
870 res_free(dev,fh,RESOURCE_VBI);
871 }
872
873 videobuf_mmap_free(&fh->vidq);
874 videobuf_mmap_free(&fh->vbiq);
875 file->private_data = NULL;
876 kfree(fh);
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700877
878 cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL);
879
Linus Torvalds1da177e2005-04-16 15:20:36 -0700880 return 0;
881}
882
883static int
884video_mmap(struct file *file, struct vm_area_struct * vma)
885{
886 struct cx8800_fh *fh = file->private_data;
887
888 return videobuf_mmap_mapper(get_queue(fh), vma);
889}
890
891/* ------------------------------------------------------------------ */
892
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700893/* static int get_control(struct cx8800_dev *dev, struct v4l2_control *ctl) */
894static int get_control(struct cx88_core *core, struct v4l2_control *ctl)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700895{
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700896 /* struct cx88_core *core = dev->core; */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700897 struct cx88_ctrl *c = NULL;
898 u32 value;
899 int i;
900
901 for (i = 0; i < CX8800_CTLS; i++)
902 if (cx8800_ctls[i].v.id == ctl->id)
903 c = &cx8800_ctls[i];
904 if (NULL == c)
905 return -EINVAL;
906
907 value = c->sreg ? cx_sread(c->sreg) : cx_read(c->reg);
908 switch (ctl->id) {
909 case V4L2_CID_AUDIO_BALANCE:
Marcin Rudowski9f9c9072006-03-12 00:03:47 -0300910 ctl->value = ((value & 0x7f) < 0x40) ? ((value & 0x7f) + 0x40)
911 : (0x7f - (value & 0x7f));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700912 break;
913 case V4L2_CID_AUDIO_VOLUME:
914 ctl->value = 0x3f - (value & 0x3f);
915 break;
916 default:
917 ctl->value = ((value + (c->off << c->shift)) & c->mask) >> c->shift;
918 break;
919 }
Ian Pickworth6457af52006-02-27 00:09:45 -0300920 dprintk(1,"get_control id=0x%X(%s) ctrl=0x%02x, reg=0x%02x val=0x%02x (mask 0x%02x)%s\n",
921 ctl->id, c->v.name, ctl->value, c->reg,
922 value,c->mask, c->sreg ? " [shadowed]" : "");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700923 return 0;
924}
925
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700926/* static int set_control(struct cx8800_dev *dev, struct v4l2_control *ctl) */
927static int set_control(struct cx88_core *core, struct v4l2_control *ctl)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700928{
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700929 /* struct cx88_core *core = dev->core; */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700930 struct cx88_ctrl *c = NULL;
Mauro Carvalho Chehab70f00042006-01-09 15:25:26 -0200931 u32 value,mask;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700932 int i;
Mauro Carvalho Chehab70f00042006-01-09 15:25:26 -0200933 for (i = 0; i < CX8800_CTLS; i++) {
934 if (cx8800_ctls[i].v.id == ctl->id) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700935 c = &cx8800_ctls[i];
Mauro Carvalho Chehab70f00042006-01-09 15:25:26 -0200936 }
937 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700938 if (NULL == c)
939 return -EINVAL;
940
941 if (ctl->value < c->v.minimum)
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700942 ctl->value = c->v.minimum;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700943 if (ctl->value > c->v.maximum)
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700944 ctl->value = c->v.maximum;
Mauro Carvalho Chehab70f00042006-01-09 15:25:26 -0200945 mask=c->mask;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700946 switch (ctl->id) {
947 case V4L2_CID_AUDIO_BALANCE:
Marcin Rudowski9f9c9072006-03-12 00:03:47 -0300948 value = (ctl->value < 0x40) ? (0x7f - ctl->value) : (ctl->value - 0x40);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700949 break;
950 case V4L2_CID_AUDIO_VOLUME:
951 value = 0x3f - (ctl->value & 0x3f);
952 break;
953 case V4L2_CID_SATURATION:
954 /* special v_sat handling */
Mauro Carvalho Chehab70f00042006-01-09 15:25:26 -0200955
956 value = ((ctl->value - c->off) << c->shift) & c->mask;
957
958 if (core->tvnorm->id & V4L2_STD_SECAM) {
959 /* For SECAM, both U and V sat should be equal */
960 value=value<<8|value;
961 } else {
962 /* Keeps U Saturation proportional to V Sat */
963 value=(value*0x5a)/0x7f<<8|value;
964 }
965 mask=0xffff;
966 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700967 default:
968 value = ((ctl->value - c->off) << c->shift) & c->mask;
969 break;
970 }
Ian Pickworth6457af52006-02-27 00:09:45 -0300971 dprintk(1,"set_control id=0x%X(%s) ctrl=0x%02x, reg=0x%02x val=0x%02x (mask 0x%02x)%s\n",
972 ctl->id, c->v.name, ctl->value, c->reg, value,
973 mask, c->sreg ? " [shadowed]" : "");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700974 if (c->sreg) {
Mauro Carvalho Chehab70f00042006-01-09 15:25:26 -0200975 cx_sandor(c->sreg, c->reg, mask, value);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700976 } else {
Mauro Carvalho Chehab70f00042006-01-09 15:25:26 -0200977 cx_andor(c->reg, mask, value);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700978 }
979 return 0;
980}
981
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700982static void init_controls(struct cx88_core *core)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700983{
Mauro Carvalho Chehab70f00042006-01-09 15:25:26 -0200984 struct v4l2_control ctrl;
985 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700986
Mauro Carvalho Chehab70f00042006-01-09 15:25:26 -0200987 for (i = 0; i < CX8800_CTLS; i++) {
988 ctrl.id=cx8800_ctls[i].v.id;
Marcin Rudowski9f9c9072006-03-12 00:03:47 -0300989 ctrl.value=cx8800_ctls[i].v.default_value;
Mauro Carvalho Chehab70f00042006-01-09 15:25:26 -0200990 set_control(core, &ctrl);
991 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700992}
993
994/* ------------------------------------------------------------------ */
995
996static int cx8800_g_fmt(struct cx8800_dev *dev, struct cx8800_fh *fh,
997 struct v4l2_format *f)
998{
999 switch (f->type) {
1000 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
1001 memset(&f->fmt.pix,0,sizeof(f->fmt.pix));
1002 f->fmt.pix.width = fh->width;
1003 f->fmt.pix.height = fh->height;
1004 f->fmt.pix.field = fh->vidq.field;
1005 f->fmt.pix.pixelformat = fh->fmt->fourcc;
1006 f->fmt.pix.bytesperline =
1007 (f->fmt.pix.width * fh->fmt->depth) >> 3;
1008 f->fmt.pix.sizeimage =
1009 f->fmt.pix.height * f->fmt.pix.bytesperline;
1010 return 0;
1011 case V4L2_BUF_TYPE_VBI_CAPTURE:
1012 cx8800_vbi_fmt(dev, f);
1013 return 0;
1014 default:
1015 return -EINVAL;
1016 }
1017}
1018
1019static int cx8800_try_fmt(struct cx8800_dev *dev, struct cx8800_fh *fh,
1020 struct v4l2_format *f)
1021{
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001022 struct cx88_core *core = dev->core;
1023
Linus Torvalds1da177e2005-04-16 15:20:36 -07001024 switch (f->type) {
1025 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
1026 {
1027 struct cx8800_fmt *fmt;
1028 enum v4l2_field field;
1029 unsigned int maxw, maxh;
1030
1031 fmt = format_by_fourcc(f->fmt.pix.pixelformat);
1032 if (NULL == fmt)
1033 return -EINVAL;
1034
1035 field = f->fmt.pix.field;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001036 maxw = norm_maxw(core->tvnorm);
1037 maxh = norm_maxh(core->tvnorm);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001038
1039 if (V4L2_FIELD_ANY == field) {
1040 field = (f->fmt.pix.height > maxh/2)
1041 ? V4L2_FIELD_INTERLACED
1042 : V4L2_FIELD_BOTTOM;
1043 }
1044
1045 switch (field) {
1046 case V4L2_FIELD_TOP:
1047 case V4L2_FIELD_BOTTOM:
1048 maxh = maxh / 2;
1049 break;
1050 case V4L2_FIELD_INTERLACED:
1051 break;
1052 default:
1053 return -EINVAL;
1054 }
1055
1056 f->fmt.pix.field = field;
1057 if (f->fmt.pix.height < 32)
1058 f->fmt.pix.height = 32;
1059 if (f->fmt.pix.height > maxh)
1060 f->fmt.pix.height = maxh;
1061 if (f->fmt.pix.width < 48)
1062 f->fmt.pix.width = 48;
1063 if (f->fmt.pix.width > maxw)
1064 f->fmt.pix.width = maxw;
1065 f->fmt.pix.width &= ~0x03;
1066 f->fmt.pix.bytesperline =
1067 (f->fmt.pix.width * fmt->depth) >> 3;
1068 f->fmt.pix.sizeimage =
1069 f->fmt.pix.height * f->fmt.pix.bytesperline;
1070
1071 return 0;
1072 }
1073 case V4L2_BUF_TYPE_VBI_CAPTURE:
1074 cx8800_vbi_fmt(dev, f);
1075 return 0;
1076 default:
1077 return -EINVAL;
1078 }
1079}
1080
1081static int cx8800_s_fmt(struct cx8800_dev *dev, struct cx8800_fh *fh,
1082 struct v4l2_format *f)
1083{
1084 int err;
1085
1086 switch (f->type) {
1087 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
1088 err = cx8800_try_fmt(dev,fh,f);
1089 if (0 != err)
1090 return err;
1091
1092 fh->fmt = format_by_fourcc(f->fmt.pix.pixelformat);
1093 fh->width = f->fmt.pix.width;
1094 fh->height = f->fmt.pix.height;
1095 fh->vidq.field = f->fmt.pix.field;
1096 return 0;
1097 case V4L2_BUF_TYPE_VBI_CAPTURE:
1098 cx8800_vbi_fmt(dev, f);
1099 return 0;
1100 default:
1101 return -EINVAL;
1102 }
1103}
1104
1105/*
1106 * This function is _not_ called directly, but from
1107 * video_generic_ioctl (and maybe others). userspace
1108 * copying is done already, arg is a kernel pointer.
1109 */
1110static int video_do_ioctl(struct inode *inode, struct file *file,
1111 unsigned int cmd, void *arg)
1112{
1113 struct cx8800_fh *fh = file->private_data;
1114 struct cx8800_dev *dev = fh->dev;
1115 struct cx88_core *core = dev->core;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001116 int err;
1117
1118 if (video_debug > 1)
Michael Krufky5e453dc2006-01-09 15:32:31 -02001119 v4l_print_ioctl(core->name,cmd);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001120 switch (cmd) {
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001121
1122 /* --- capabilities ------------------------------------------ */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001123 case VIDIOC_QUERYCAP:
1124 {
1125 struct v4l2_capability *cap = arg;
1126
1127 memset(cap,0,sizeof(*cap));
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001128 strcpy(cap->driver, "cx8800");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001129 strlcpy(cap->card, cx88_boards[core->board].name,
1130 sizeof(cap->card));
1131 sprintf(cap->bus_info,"PCI:%s",pci_name(dev->pci));
1132 cap->version = CX88_VERSION_CODE;
1133 cap->capabilities =
1134 V4L2_CAP_VIDEO_CAPTURE |
1135 V4L2_CAP_READWRITE |
1136 V4L2_CAP_STREAMING |
1137 V4L2_CAP_VBI_CAPTURE |
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001138 V4L2_CAP_VIDEO_OVERLAY |
Linus Torvalds1da177e2005-04-16 15:20:36 -07001139 0;
1140 if (UNSET != core->tuner_type)
1141 cap->capabilities |= V4L2_CAP_TUNER;
1142 return 0;
1143 }
1144
Linus Torvalds1da177e2005-04-16 15:20:36 -07001145 /* --- capture ioctls ---------------------------------------- */
1146 case VIDIOC_ENUM_FMT:
1147 {
1148 struct v4l2_fmtdesc *f = arg;
1149 enum v4l2_buf_type type;
1150 unsigned int index;
1151
1152 index = f->index;
1153 type = f->type;
1154 switch (type) {
1155 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
1156 if (index >= ARRAY_SIZE(formats))
1157 return -EINVAL;
1158 memset(f,0,sizeof(*f));
1159 f->index = index;
1160 f->type = type;
1161 strlcpy(f->description,formats[index].name,sizeof(f->description));
1162 f->pixelformat = formats[index].fourcc;
1163 break;
1164 default:
1165 return -EINVAL;
1166 }
1167 return 0;
1168 }
1169 case VIDIOC_G_FMT:
1170 {
1171 struct v4l2_format *f = arg;
1172 return cx8800_g_fmt(dev,fh,f);
1173 }
1174 case VIDIOC_S_FMT:
1175 {
1176 struct v4l2_format *f = arg;
1177 return cx8800_s_fmt(dev,fh,f);
1178 }
1179 case VIDIOC_TRY_FMT:
1180 {
1181 struct v4l2_format *f = arg;
1182 return cx8800_try_fmt(dev,fh,f);
1183 }
Mauro Carvalho Chehab79436632005-11-08 21:37:49 -08001184#ifdef HAVE_V4L1
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001185 /* --- streaming capture ------------------------------------- */
1186 case VIDIOCGMBUF:
1187 {
1188 struct video_mbuf *mbuf = arg;
1189 struct videobuf_queue *q;
1190 struct v4l2_requestbuffers req;
1191 unsigned int i;
1192
1193 q = get_queue(fh);
1194 memset(&req,0,sizeof(req));
1195 req.type = q->type;
1196 req.count = 8;
1197 req.memory = V4L2_MEMORY_MMAP;
1198 err = videobuf_reqbufs(q,&req);
1199 if (err < 0)
1200 return err;
1201 memset(mbuf,0,sizeof(*mbuf));
1202 mbuf->frames = req.count;
1203 mbuf->size = 0;
1204 for (i = 0; i < mbuf->frames; i++) {
1205 mbuf->offsets[i] = q->bufs[i]->boff;
1206 mbuf->size += q->bufs[i]->bsize;
1207 }
1208 return 0;
1209 }
Mauro Carvalho Chehab79436632005-11-08 21:37:49 -08001210#endif
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001211 case VIDIOC_REQBUFS:
1212 return videobuf_reqbufs(get_queue(fh), arg);
1213
1214 case VIDIOC_QUERYBUF:
1215 return videobuf_querybuf(get_queue(fh), arg);
1216
1217 case VIDIOC_QBUF:
1218 return videobuf_qbuf(get_queue(fh), arg);
1219
1220 case VIDIOC_DQBUF:
1221 return videobuf_dqbuf(get_queue(fh), arg,
1222 file->f_flags & O_NONBLOCK);
1223
1224 case VIDIOC_STREAMON:
1225 {
1226 int res = get_ressource(fh);
1227
1228 if (!res_get(dev,fh,res))
1229 return -EBUSY;
1230 return videobuf_streamon(get_queue(fh));
1231 }
1232 case VIDIOC_STREAMOFF:
1233 {
1234 int res = get_ressource(fh);
1235
1236 err = videobuf_streamoff(get_queue(fh));
1237 if (err < 0)
1238 return err;
1239 res_free(dev,fh,res);
1240 return 0;
1241 }
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001242 default:
1243 return cx88_do_ioctl( inode, file, fh->radio, core, cmd, arg, video_do_ioctl );
1244 }
1245 return 0;
1246}
1247
1248int cx88_do_ioctl(struct inode *inode, struct file *file, int radio,
Mauro Carvalho Chehab4ac97912005-11-08 21:37:43 -08001249 struct cx88_core *core, unsigned int cmd, void *arg, v4l2_kioctl driver_ioctl)
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001250{
1251 int err;
1252
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -03001253 if (video_debug) {
1254 if (video_debug > 1) {
1255 if (_IOC_DIR(cmd) & _IOC_WRITE)
1256 v4l_printk_ioctl_arg("cx88(w)",cmd, arg);
1257 else if (!_IOC_DIR(cmd) & _IOC_READ) {
1258 v4l_print_ioctl("cx88", cmd);
1259 }
1260 } else
1261 v4l_print_ioctl(core->name,cmd);
1262
1263 }
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001264
1265 switch (cmd) {
1266 /* ---------- tv norms ---------- */
1267 case VIDIOC_ENUMSTD:
1268 {
1269 struct v4l2_standard *e = arg;
1270 unsigned int i;
1271
1272 i = e->index;
1273 if (i >= ARRAY_SIZE(tvnorms))
1274 return -EINVAL;
1275 err = v4l2_video_std_construct(e, tvnorms[e->index].id,
1276 tvnorms[e->index].name);
1277 e->index = i;
1278 if (err < 0)
1279 return err;
1280 return 0;
1281 }
1282 case VIDIOC_G_STD:
1283 {
1284 v4l2_std_id *id = arg;
1285
1286 *id = core->tvnorm->id;
1287 return 0;
1288 }
1289 case VIDIOC_S_STD:
1290 {
1291 v4l2_std_id *id = arg;
1292 unsigned int i;
1293
1294 for(i = 0; i < ARRAY_SIZE(tvnorms); i++)
1295 if (*id & tvnorms[i].id)
1296 break;
1297 if (i == ARRAY_SIZE(tvnorms))
1298 return -EINVAL;
1299
Ingo Molnar3593cab2006-02-07 06:49:14 -02001300 mutex_lock(&core->lock);
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001301 cx88_set_tvnorm(core,&tvnorms[i]);
Ingo Molnar3593cab2006-02-07 06:49:14 -02001302 mutex_unlock(&core->lock);
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001303 return 0;
1304 }
1305
1306 /* ------ input switching ---------- */
1307 case VIDIOC_ENUMINPUT:
1308 {
1309 static const char *iname[] = {
1310 [ CX88_VMUX_COMPOSITE1 ] = "Composite1",
1311 [ CX88_VMUX_COMPOSITE2 ] = "Composite2",
1312 [ CX88_VMUX_COMPOSITE3 ] = "Composite3",
1313 [ CX88_VMUX_COMPOSITE4 ] = "Composite4",
1314 [ CX88_VMUX_SVIDEO ] = "S-Video",
1315 [ CX88_VMUX_TELEVISION ] = "Television",
1316 [ CX88_VMUX_CABLE ] = "Cable TV",
1317 [ CX88_VMUX_DVB ] = "DVB",
1318 [ CX88_VMUX_DEBUG ] = "for debug only",
1319 };
1320 struct v4l2_input *i = arg;
1321 unsigned int n;
1322
1323 n = i->index;
1324 if (n >= 4)
1325 return -EINVAL;
1326 if (0 == INPUT(n)->type)
1327 return -EINVAL;
1328 memset(i,0,sizeof(*i));
1329 i->index = n;
1330 i->type = V4L2_INPUT_TYPE_CAMERA;
1331 strcpy(i->name,iname[INPUT(n)->type]);
1332 if ((CX88_VMUX_TELEVISION == INPUT(n)->type) ||
1333 (CX88_VMUX_CABLE == INPUT(n)->type))
1334 i->type = V4L2_INPUT_TYPE_TUNER;
1335 for (n = 0; n < ARRAY_SIZE(tvnorms); n++)
1336 i->std |= tvnorms[n].id;
1337 return 0;
1338 }
1339 case VIDIOC_G_INPUT:
1340 {
1341 unsigned int *i = arg;
1342
1343 *i = core->input;
1344 return 0;
1345 }
1346 case VIDIOC_S_INPUT:
1347 {
1348 unsigned int *i = arg;
1349
1350 if (*i >= 4)
1351 return -EINVAL;
Ingo Molnar3593cab2006-02-07 06:49:14 -02001352 mutex_lock(&core->lock);
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001353 cx88_newstation(core);
1354 video_mux(core,*i);
Ingo Molnar3593cab2006-02-07 06:49:14 -02001355 mutex_unlock(&core->lock);
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001356 return 0;
1357 }
1358
1359
1360
Linus Torvalds1da177e2005-04-16 15:20:36 -07001361 /* --- controls ---------------------------------------------- */
1362 case VIDIOC_QUERYCTRL:
1363 {
1364 struct v4l2_queryctrl *c = arg;
1365 int i;
1366
1367 if (c->id < V4L2_CID_BASE ||
1368 c->id >= V4L2_CID_LASTP1)
1369 return -EINVAL;
1370 for (i = 0; i < CX8800_CTLS; i++)
1371 if (cx8800_ctls[i].v.id == c->id)
1372 break;
1373 if (i == CX8800_CTLS) {
1374 *c = no_ctl;
1375 return 0;
1376 }
1377 *c = cx8800_ctls[i].v;
1378 return 0;
1379 }
1380 case VIDIOC_G_CTRL:
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001381 return get_control(core,arg);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001382 case VIDIOC_S_CTRL:
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001383 return set_control(core,arg);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001384
1385 /* --- tuner ioctls ------------------------------------------ */
1386 case VIDIOC_G_TUNER:
1387 {
1388 struct v4l2_tuner *t = arg;
1389 u32 reg;
1390
1391 if (UNSET == core->tuner_type)
1392 return -EINVAL;
1393 if (0 != t->index)
1394 return -EINVAL;
1395
1396 memset(t,0,sizeof(*t));
1397 strcpy(t->name, "Television");
1398 t->type = V4L2_TUNER_ANALOG_TV;
1399 t->capability = V4L2_TUNER_CAP_NORM;
1400 t->rangehigh = 0xffffffffUL;
1401
1402 cx88_get_stereo(core ,t);
1403 reg = cx_read(MO_DEVICE_STATUS);
Mauro Carvalho Chehab4ac97912005-11-08 21:37:43 -08001404 t->signal = (reg & (1<<5)) ? 0xffff : 0x0000;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001405 return 0;
1406 }
1407 case VIDIOC_S_TUNER:
1408 {
1409 struct v4l2_tuner *t = arg;
1410
1411 if (UNSET == core->tuner_type)
1412 return -EINVAL;
1413 if (0 != t->index)
1414 return -EINVAL;
1415 cx88_set_stereo(core, t->audmode, 1);
1416 return 0;
1417 }
1418 case VIDIOC_G_FREQUENCY:
1419 {
1420 struct v4l2_frequency *f = arg;
1421
Mauro Carvalho Chehaba82decf2005-07-07 17:58:36 -07001422 memset(f,0,sizeof(*f));
1423
Linus Torvalds1da177e2005-04-16 15:20:36 -07001424 if (UNSET == core->tuner_type)
1425 return -EINVAL;
Mauro Carvalho Chehaba82decf2005-07-07 17:58:36 -07001426
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001427 /* f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; */
1428 f->type = radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
1429 f->frequency = core->freq;
Mauro Carvalho Chehab41ef7c12005-07-12 13:58:44 -07001430
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001431 cx88_call_i2c_clients(core,VIDIOC_G_FREQUENCY,f);
Mauro Carvalho Chehab41ef7c12005-07-12 13:58:44 -07001432
Linus Torvalds1da177e2005-04-16 15:20:36 -07001433 return 0;
1434 }
1435 case VIDIOC_S_FREQUENCY:
1436 {
1437 struct v4l2_frequency *f = arg;
1438
1439 if (UNSET == core->tuner_type)
1440 return -EINVAL;
1441 if (f->tuner != 0)
1442 return -EINVAL;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001443 if (0 == radio && f->type != V4L2_TUNER_ANALOG_TV)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001444 return -EINVAL;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001445 if (1 == radio && f->type != V4L2_TUNER_RADIO)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001446 return -EINVAL;
Ingo Molnar3593cab2006-02-07 06:49:14 -02001447 mutex_lock(&core->lock);
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001448 core->freq = f->frequency;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001449 cx88_newstation(core);
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001450 cx88_call_i2c_clients(core,VIDIOC_S_FREQUENCY,f);
Mauro Carvalho Chehabc5287ba2005-07-15 03:56:28 -07001451
1452 /* When changing channels it is required to reset TVAUDIO */
1453 msleep (10);
1454 cx88_set_tvaudio(core);
1455
Ingo Molnar3593cab2006-02-07 06:49:14 -02001456 mutex_unlock(&core->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001457 return 0;
1458 }
1459
1460 default:
1461 return v4l_compat_translate_ioctl(inode,file,cmd,arg,
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001462 driver_ioctl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001463 }
1464 return 0;
1465}
1466
1467static int video_ioctl(struct inode *inode, struct file *file,
1468 unsigned int cmd, unsigned long arg)
1469{
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -03001470 int retval;
1471
1472 retval=video_usercopy(inode, file, cmd, arg, video_do_ioctl);
1473
1474 if (video_debug > 1) {
1475 if (retval < 0) {
1476 v4l_print_ioctl("cx88(err)", cmd);
1477 printk(KERN_DEBUG "cx88(err): errcode=%d\n",retval);
1478 } else if (_IOC_DIR(cmd) & _IOC_READ)
1479 v4l_printk_ioctl_arg("cx88(r)",cmd, (void *)arg);
1480 }
1481
1482 return retval;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001483}
1484
1485/* ----------------------------------------------------------- */
1486
1487static int radio_do_ioctl(struct inode *inode, struct file *file,
1488 unsigned int cmd, void *arg)
1489{
1490 struct cx8800_fh *fh = file->private_data;
1491 struct cx8800_dev *dev = fh->dev;
1492 struct cx88_core *core = dev->core;
1493
1494 if (video_debug > 1)
Michael Krufky5e453dc2006-01-09 15:32:31 -02001495 v4l_print_ioctl(core->name,cmd);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001496
1497 switch (cmd) {
1498 case VIDIOC_QUERYCAP:
1499 {
1500 struct v4l2_capability *cap = arg;
1501
1502 memset(cap,0,sizeof(*cap));
Mauro Carvalho Chehab4ac97912005-11-08 21:37:43 -08001503 strcpy(cap->driver, "cx8800");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001504 strlcpy(cap->card, cx88_boards[core->board].name,
1505 sizeof(cap->card));
1506 sprintf(cap->bus_info,"PCI:%s", pci_name(dev->pci));
1507 cap->version = CX88_VERSION_CODE;
Mauro Carvalho Chehaba82decf2005-07-07 17:58:36 -07001508 cap->capabilities = V4L2_CAP_TUNER;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001509 return 0;
1510 }
1511 case VIDIOC_G_TUNER:
1512 {
1513 struct v4l2_tuner *t = arg;
1514
1515 if (t->index > 0)
1516 return -EINVAL;
1517
1518 memset(t,0,sizeof(*t));
1519 strcpy(t->name, "Radio");
Elad Lahav48c42592005-11-08 21:37:59 -08001520 t->type = V4L2_TUNER_RADIO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001521
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001522 cx88_call_i2c_clients(core,VIDIOC_G_TUNER,t);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001523 return 0;
1524 }
1525 case VIDIOC_ENUMINPUT:
1526 {
1527 struct v4l2_input *i = arg;
1528
1529 if (i->index != 0)
1530 return -EINVAL;
1531 strcpy(i->name,"Radio");
1532 i->type = V4L2_INPUT_TYPE_TUNER;
1533 return 0;
1534 }
1535 case VIDIOC_G_INPUT:
1536 {
1537 int *i = arg;
1538 *i = 0;
1539 return 0;
1540 }
1541 case VIDIOC_G_AUDIO:
1542 {
1543 struct v4l2_audio *a = arg;
1544
1545 memset(a,0,sizeof(*a));
1546 strcpy(a->name,"Radio");
1547 return 0;
1548 }
1549 case VIDIOC_G_STD:
1550 {
1551 v4l2_std_id *id = arg;
1552 *id = 0;
1553 return 0;
1554 }
Mauro Carvalho Chehab79436632005-11-08 21:37:49 -08001555#ifdef HAVE_V4L1
Mauro Carvalho Chehaba82decf2005-07-07 17:58:36 -07001556 case VIDIOCSTUNER:
1557 {
1558 struct video_tuner *v = arg;
1559
1560 if (v->tuner) /* Only tuner 0 */
1561 return -EINVAL;
1562
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001563 cx88_call_i2c_clients(core,VIDIOCSTUNER,v);
1564 return 0;
Mauro Carvalho Chehaba82decf2005-07-07 17:58:36 -07001565 }
Mauro Carvalho Chehab79436632005-11-08 21:37:49 -08001566#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001567 case VIDIOC_S_TUNER:
Mauro Carvalho Chehaba82decf2005-07-07 17:58:36 -07001568 {
1569 struct v4l2_tuner *t = arg;
1570
1571 if (0 != t->index)
1572 return -EINVAL;
1573
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001574 cx88_call_i2c_clients(core,VIDIOC_S_TUNER,t);
Mauro Carvalho Chehaba82decf2005-07-07 17:58:36 -07001575
1576 return 0;
1577 }
1578
1579 case VIDIOC_S_AUDIO:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001580 case VIDIOC_S_INPUT:
1581 case VIDIOC_S_STD:
1582 return 0;
1583
1584 case VIDIOC_QUERYCTRL:
1585 {
1586 struct v4l2_queryctrl *c = arg;
1587 int i;
1588
1589 if (c->id < V4L2_CID_BASE ||
1590 c->id >= V4L2_CID_LASTP1)
1591 return -EINVAL;
1592 if (c->id == V4L2_CID_AUDIO_MUTE) {
1593 for (i = 0; i < CX8800_CTLS; i++)
1594 if (cx8800_ctls[i].v.id == c->id)
1595 break;
1596 *c = cx8800_ctls[i].v;
1597 } else
1598 *c = no_ctl;
1599 return 0;
1600 }
1601
1602
1603 case VIDIOC_G_CTRL:
1604 case VIDIOC_S_CTRL:
1605 case VIDIOC_G_FREQUENCY:
1606 case VIDIOC_S_FREQUENCY:
1607 return video_do_ioctl(inode,file,cmd,arg);
1608
1609 default:
1610 return v4l_compat_translate_ioctl(inode,file,cmd,arg,
1611 radio_do_ioctl);
1612 }
1613 return 0;
1614};
1615
1616static int radio_ioctl(struct inode *inode, struct file *file,
1617 unsigned int cmd, unsigned long arg)
1618{
1619 return video_usercopy(inode, file, cmd, arg, radio_do_ioctl);
1620};
1621
1622/* ----------------------------------------------------------- */
1623
1624static void cx8800_vid_timeout(unsigned long data)
1625{
1626 struct cx8800_dev *dev = (struct cx8800_dev*)data;
1627 struct cx88_core *core = dev->core;
1628 struct cx88_dmaqueue *q = &dev->vidq;
1629 struct cx88_buffer *buf;
1630 unsigned long flags;
1631
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001632 cx88_sram_channel_dump(core, &cx88_sram_channels[SRAM_CH21]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001633
1634 cx_clear(MO_VID_DMACNTRL, 0x11);
1635 cx_clear(VID_CAPTURE_CONTROL, 0x06);
1636
1637 spin_lock_irqsave(&dev->slock,flags);
1638 while (!list_empty(&q->active)) {
1639 buf = list_entry(q->active.next, struct cx88_buffer, vb.queue);
1640 list_del(&buf->vb.queue);
1641 buf->vb.state = STATE_ERROR;
1642 wake_up(&buf->vb.done);
1643 printk("%s/0: [%p/%d] timeout - dma=0x%08lx\n", core->name,
1644 buf, buf->vb.i, (unsigned long)buf->risc.dma);
1645 }
1646 restart_video_queue(dev,q);
1647 spin_unlock_irqrestore(&dev->slock,flags);
1648}
1649
Mauro Carvalho Chehab41ef7c12005-07-12 13:58:44 -07001650static char *cx88_vid_irqs[32] = {
1651 "y_risci1", "u_risci1", "v_risci1", "vbi_risc1",
1652 "y_risci2", "u_risci2", "v_risci2", "vbi_risc2",
1653 "y_oflow", "u_oflow", "v_oflow", "vbi_oflow",
1654 "y_sync", "u_sync", "v_sync", "vbi_sync",
1655 "opc_err", "par_err", "rip_err", "pci_abort",
1656};
1657
Linus Torvalds1da177e2005-04-16 15:20:36 -07001658static void cx8800_vid_irq(struct cx8800_dev *dev)
1659{
1660 struct cx88_core *core = dev->core;
1661 u32 status, mask, count;
1662
1663 status = cx_read(MO_VID_INTSTAT);
1664 mask = cx_read(MO_VID_INTMSK);
1665 if (0 == (status & mask))
1666 return;
1667 cx_write(MO_VID_INTSTAT, status);
1668 if (irq_debug || (status & mask & ~0xff))
1669 cx88_print_irqbits(core->name, "irq vid",
1670 cx88_vid_irqs, status, mask);
1671
1672 /* risc op code error */
1673 if (status & (1 << 16)) {
1674 printk(KERN_WARNING "%s/0: video risc op code error\n",core->name);
1675 cx_clear(MO_VID_DMACNTRL, 0x11);
1676 cx_clear(VID_CAPTURE_CONTROL, 0x06);
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001677 cx88_sram_channel_dump(core, &cx88_sram_channels[SRAM_CH21]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001678 }
1679
1680 /* risc1 y */
1681 if (status & 0x01) {
1682 spin_lock(&dev->slock);
1683 count = cx_read(MO_VIDY_GPCNT);
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001684 cx88_wakeup(core, &dev->vidq, count);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001685 spin_unlock(&dev->slock);
1686 }
1687
1688 /* risc1 vbi */
1689 if (status & 0x08) {
1690 spin_lock(&dev->slock);
1691 count = cx_read(MO_VBI_GPCNT);
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001692 cx88_wakeup(core, &dev->vbiq, count);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001693 spin_unlock(&dev->slock);
1694 }
1695
1696 /* risc2 y */
1697 if (status & 0x10) {
1698 dprintk(2,"stopper video\n");
1699 spin_lock(&dev->slock);
1700 restart_video_queue(dev,&dev->vidq);
1701 spin_unlock(&dev->slock);
1702 }
1703
1704 /* risc2 vbi */
1705 if (status & 0x80) {
1706 dprintk(2,"stopper vbi\n");
1707 spin_lock(&dev->slock);
1708 cx8800_restart_vbi_queue(dev,&dev->vbiq);
1709 spin_unlock(&dev->slock);
1710 }
1711}
1712
1713static irqreturn_t cx8800_irq(int irq, void *dev_id, struct pt_regs *regs)
1714{
1715 struct cx8800_dev *dev = dev_id;
1716 struct cx88_core *core = dev->core;
1717 u32 status;
1718 int loop, handled = 0;
1719
1720 for (loop = 0; loop < 10; loop++) {
1721 status = cx_read(MO_PCI_INTSTAT) & (core->pci_irqmask | 0x01);
1722 if (0 == status)
1723 goto out;
1724 cx_write(MO_PCI_INTSTAT, status);
1725 handled = 1;
1726
1727 if (status & core->pci_irqmask)
1728 cx88_core_irq(core,status);
1729 if (status & 0x01)
1730 cx8800_vid_irq(dev);
1731 };
1732 if (10 == loop) {
1733 printk(KERN_WARNING "%s/0: irq loop -- clearing mask\n",
1734 core->name);
1735 cx_write(MO_PCI_INTMSK,0);
1736 }
1737
1738 out:
1739 return IRQ_RETVAL(handled);
1740}
1741
1742/* ----------------------------------------------------------- */
1743/* exported stuff */
1744
1745static struct file_operations video_fops =
1746{
1747 .owner = THIS_MODULE,
1748 .open = video_open,
1749 .release = video_release,
1750 .read = video_read,
1751 .poll = video_poll,
1752 .mmap = video_mmap,
1753 .ioctl = video_ioctl,
Arnd Bergmann0d0fbf82006-01-09 15:24:57 -02001754 .compat_ioctl = v4l_compat_ioctl32,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001755 .llseek = no_llseek,
1756};
1757
Adrian Bunk408b6642005-05-01 08:59:29 -07001758static struct video_device cx8800_video_template =
Linus Torvalds1da177e2005-04-16 15:20:36 -07001759{
1760 .name = "cx8800-video",
1761 .type = VID_TYPE_CAPTURE|VID_TYPE_TUNER|VID_TYPE_SCALES,
1762 .hardware = 0,
1763 .fops = &video_fops,
1764 .minor = -1,
1765};
1766
Adrian Bunk408b6642005-05-01 08:59:29 -07001767static struct video_device cx8800_vbi_template =
Linus Torvalds1da177e2005-04-16 15:20:36 -07001768{
1769 .name = "cx8800-vbi",
1770 .type = VID_TYPE_TELETEXT|VID_TYPE_TUNER,
1771 .hardware = 0,
1772 .fops = &video_fops,
1773 .minor = -1,
1774};
1775
1776static struct file_operations radio_fops =
1777{
1778 .owner = THIS_MODULE,
1779 .open = video_open,
1780 .release = video_release,
1781 .ioctl = radio_ioctl,
Arnd Bergmann0d0fbf82006-01-09 15:24:57 -02001782 .compat_ioctl = v4l_compat_ioctl32,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001783 .llseek = no_llseek,
1784};
1785
Adrian Bunk408b6642005-05-01 08:59:29 -07001786static struct video_device cx8800_radio_template =
Linus Torvalds1da177e2005-04-16 15:20:36 -07001787{
1788 .name = "cx8800-radio",
1789 .type = VID_TYPE_TUNER,
1790 .hardware = 0,
1791 .fops = &radio_fops,
1792 .minor = -1,
1793};
1794
1795/* ----------------------------------------------------------- */
1796
1797static void cx8800_unregister_video(struct cx8800_dev *dev)
1798{
1799 if (dev->radio_dev) {
1800 if (-1 != dev->radio_dev->minor)
1801 video_unregister_device(dev->radio_dev);
1802 else
1803 video_device_release(dev->radio_dev);
1804 dev->radio_dev = NULL;
1805 }
1806 if (dev->vbi_dev) {
1807 if (-1 != dev->vbi_dev->minor)
1808 video_unregister_device(dev->vbi_dev);
1809 else
1810 video_device_release(dev->vbi_dev);
1811 dev->vbi_dev = NULL;
1812 }
1813 if (dev->video_dev) {
1814 if (-1 != dev->video_dev->minor)
1815 video_unregister_device(dev->video_dev);
1816 else
1817 video_device_release(dev->video_dev);
1818 dev->video_dev = NULL;
1819 }
1820}
1821
1822static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
1823 const struct pci_device_id *pci_id)
1824{
1825 struct cx8800_dev *dev;
1826 struct cx88_core *core;
1827 int err;
1828
Panagiotis Issaris74081872006-01-11 19:40:56 -02001829 dev = kzalloc(sizeof(*dev),GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001830 if (NULL == dev)
1831 return -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001832
1833 /* pci init */
1834 dev->pci = pci_dev;
1835 if (pci_enable_device(pci_dev)) {
1836 err = -EIO;
1837 goto fail_free;
1838 }
1839 core = cx88_core_get(dev->pci);
1840 if (NULL == core) {
1841 err = -EINVAL;
1842 goto fail_free;
1843 }
1844 dev->core = core;
1845
1846 /* print pci info */
1847 pci_read_config_byte(pci_dev, PCI_CLASS_REVISION, &dev->pci_rev);
Mauro Carvalho Chehab4ac97912005-11-08 21:37:43 -08001848 pci_read_config_byte(pci_dev, PCI_LATENCY_TIMER, &dev->pci_lat);
1849 printk(KERN_INFO "%s/0: found at %s, rev: %d, irq: %d, "
Linus Torvalds1da177e2005-04-16 15:20:36 -07001850 "latency: %d, mmio: 0x%lx\n", core->name,
1851 pci_name(pci_dev), dev->pci_rev, pci_dev->irq,
1852 dev->pci_lat,pci_resource_start(pci_dev,0));
1853
1854 pci_set_master(pci_dev);
1855 if (!pci_dma_supported(pci_dev,0xffffffff)) {
1856 printk("%s/0: Oops: no 32bit PCI DMA ???\n",core->name);
1857 err = -EIO;
1858 goto fail_core;
1859 }
1860
1861 /* initialize driver struct */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001862 spin_lock_init(&dev->slock);
1863 core->tvnorm = tvnorms;
1864
1865 /* init video dma queues */
1866 INIT_LIST_HEAD(&dev->vidq.active);
1867 INIT_LIST_HEAD(&dev->vidq.queued);
1868 dev->vidq.timeout.function = cx8800_vid_timeout;
1869 dev->vidq.timeout.data = (unsigned long)dev;
1870 init_timer(&dev->vidq.timeout);
1871 cx88_risc_stopper(dev->pci,&dev->vidq.stopper,
1872 MO_VID_DMACNTRL,0x11,0x00);
1873
1874 /* init vbi dma queues */
1875 INIT_LIST_HEAD(&dev->vbiq.active);
1876 INIT_LIST_HEAD(&dev->vbiq.queued);
1877 dev->vbiq.timeout.function = cx8800_vbi_timeout;
1878 dev->vbiq.timeout.data = (unsigned long)dev;
1879 init_timer(&dev->vbiq.timeout);
1880 cx88_risc_stopper(dev->pci,&dev->vbiq.stopper,
1881 MO_VID_DMACNTRL,0x88,0x00);
1882
1883 /* get irq */
1884 err = request_irq(pci_dev->irq, cx8800_irq,
1885 SA_SHIRQ | SA_INTERRUPT, core->name, dev);
1886 if (err < 0) {
1887 printk(KERN_ERR "%s: can't get IRQ %d\n",
1888 core->name,pci_dev->irq);
1889 goto fail_core;
1890 }
1891 cx_set(MO_PCI_INTMSK, core->pci_irqmask);
1892
1893 /* load and configure helper modules */
1894 if (TUNER_ABSENT != core->tuner_type)
1895 request_module("tuner");
1896 if (core->tda9887_conf)
1897 request_module("tda9887");
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001898
Linus Torvalds1da177e2005-04-16 15:20:36 -07001899 /* register v4l devices */
1900 dev->video_dev = cx88_vdev_init(core,dev->pci,
1901 &cx8800_video_template,"video");
1902 err = video_register_device(dev->video_dev,VFL_TYPE_GRABBER,
1903 video_nr[core->nr]);
1904 if (err < 0) {
1905 printk(KERN_INFO "%s: can't register video device\n",
1906 core->name);
1907 goto fail_unreg;
1908 }
1909 printk(KERN_INFO "%s/0: registered device video%d [v4l2]\n",
1910 core->name,dev->video_dev->minor & 0x1f);
1911
1912 dev->vbi_dev = cx88_vdev_init(core,dev->pci,&cx8800_vbi_template,"vbi");
1913 err = video_register_device(dev->vbi_dev,VFL_TYPE_VBI,
1914 vbi_nr[core->nr]);
1915 if (err < 0) {
1916 printk(KERN_INFO "%s/0: can't register vbi device\n",
1917 core->name);
1918 goto fail_unreg;
1919 }
1920 printk(KERN_INFO "%s/0: registered device vbi%d\n",
1921 core->name,dev->vbi_dev->minor & 0x1f);
1922
1923 if (core->has_radio) {
1924 dev->radio_dev = cx88_vdev_init(core,dev->pci,
1925 &cx8800_radio_template,"radio");
1926 err = video_register_device(dev->radio_dev,VFL_TYPE_RADIO,
1927 radio_nr[core->nr]);
1928 if (err < 0) {
1929 printk(KERN_INFO "%s/0: can't register radio device\n",
1930 core->name);
1931 goto fail_unreg;
1932 }
1933 printk(KERN_INFO "%s/0: registered device radio%d\n",
1934 core->name,dev->radio_dev->minor & 0x1f);
1935 }
1936
1937 /* everything worked */
1938 list_add_tail(&dev->devlist,&cx8800_devlist);
1939 pci_set_drvdata(pci_dev,dev);
1940
1941 /* initial device configuration */
Ingo Molnar3593cab2006-02-07 06:49:14 -02001942 mutex_lock(&core->lock);
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001943 cx88_set_tvnorm(core,tvnorms);
Mauro Carvalho Chehab70f00042006-01-09 15:25:26 -02001944 init_controls(core);
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001945 video_mux(core,0);
Ingo Molnar3593cab2006-02-07 06:49:14 -02001946 mutex_unlock(&core->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001947
1948 /* start tvaudio thread */
1949 if (core->tuner_type != TUNER_ABSENT)
1950 core->kthread = kthread_run(cx88_audio_thread, core, "cx88 tvaudio");
1951 return 0;
1952
1953fail_unreg:
1954 cx8800_unregister_video(dev);
1955 free_irq(pci_dev->irq, dev);
1956fail_core:
1957 cx88_core_put(core,dev->pci);
1958fail_free:
1959 kfree(dev);
1960 return err;
1961}
1962
1963static void __devexit cx8800_finidev(struct pci_dev *pci_dev)
1964{
Mauro Carvalho Chehab4ac97912005-11-08 21:37:43 -08001965 struct cx8800_dev *dev = pci_get_drvdata(pci_dev);
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001966 struct cx88_core *core = dev->core;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001967
1968 /* stop thread */
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001969 if (core->kthread) {
1970 kthread_stop(core->kthread);
1971 core->kthread = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001972 }
1973
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001974 cx88_shutdown(core); /* FIXME */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001975 pci_disable_device(pci_dev);
1976
1977 /* unregister stuff */
1978
1979 free_irq(pci_dev->irq, dev);
1980 cx8800_unregister_video(dev);
1981 pci_set_drvdata(pci_dev, NULL);
1982
1983 /* free memory */
1984 btcx_riscmem_free(dev->pci,&dev->vidq.stopper);
1985 list_del(&dev->devlist);
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001986 cx88_core_put(core,dev->pci);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001987 kfree(dev);
1988}
1989
1990static int cx8800_suspend(struct pci_dev *pci_dev, pm_message_t state)
1991{
Mauro Carvalho Chehabb45009b2005-06-23 22:05:03 -07001992 struct cx8800_dev *dev = pci_get_drvdata(pci_dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001993 struct cx88_core *core = dev->core;
1994
1995 /* stop video+vbi capture */
1996 spin_lock(&dev->slock);
1997 if (!list_empty(&dev->vidq.active)) {
1998 printk("%s: suspend video\n", core->name);
1999 stop_video_dma(dev);
2000 del_timer(&dev->vidq.timeout);
2001 }
2002 if (!list_empty(&dev->vbiq.active)) {
2003 printk("%s: suspend vbi\n", core->name);
2004 cx8800_stop_vbi_dma(dev);
2005 del_timer(&dev->vbiq.timeout);
2006 }
2007 spin_unlock(&dev->slock);
2008
Linus Torvalds1da177e2005-04-16 15:20:36 -07002009 /* FIXME -- shutdown device */
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07002010 cx88_shutdown(core);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002011
2012 pci_save_state(pci_dev);
2013 if (0 != pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state))) {
2014 pci_disable_device(pci_dev);
2015 dev->state.disabled = 1;
2016 }
2017 return 0;
2018}
2019
2020static int cx8800_resume(struct pci_dev *pci_dev)
2021{
Mauro Carvalho Chehabb45009b2005-06-23 22:05:03 -07002022 struct cx8800_dev *dev = pci_get_drvdata(pci_dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002023 struct cx88_core *core = dev->core;
Mauro Carvalho Chehab08adb9e2005-09-09 13:03:55 -07002024 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002025
2026 if (dev->state.disabled) {
Mauro Carvalho Chehab08adb9e2005-09-09 13:03:55 -07002027 err=pci_enable_device(pci_dev);
2028 if (err) {
2029 printk(KERN_ERR "%s: can't enable device\n",
2030 core->name);
2031 return err;
2032 }
2033
Linus Torvalds1da177e2005-04-16 15:20:36 -07002034 dev->state.disabled = 0;
2035 }
Mauro Carvalho Chehab08adb9e2005-09-09 13:03:55 -07002036 err= pci_set_power_state(pci_dev, PCI_D0);
2037 if (err) {
2038 printk(KERN_ERR "%s: can't enable device\n",
2039 core->name);
2040
2041 pci_disable_device(pci_dev);
2042 dev->state.disabled = 1;
2043
2044 return err;
2045 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002046 pci_restore_state(pci_dev);
2047
Linus Torvalds1da177e2005-04-16 15:20:36 -07002048 /* FIXME: re-initialize hardware */
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07002049 cx88_reset(core);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002050
2051 /* restart video+vbi capture */
2052 spin_lock(&dev->slock);
2053 if (!list_empty(&dev->vidq.active)) {
2054 printk("%s: resume video\n", core->name);
2055 restart_video_queue(dev,&dev->vidq);
2056 }
2057 if (!list_empty(&dev->vbiq.active)) {
2058 printk("%s: resume vbi\n", core->name);
2059 cx8800_restart_vbi_queue(dev,&dev->vbiq);
2060 }
2061 spin_unlock(&dev->slock);
2062
2063 return 0;
2064}
2065
2066/* ----------------------------------------------------------- */
2067
Adrian Bunk408b6642005-05-01 08:59:29 -07002068static struct pci_device_id cx8800_pci_tbl[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002069 {
2070 .vendor = 0x14f1,
2071 .device = 0x8800,
Mauro Carvalho Chehabb45009b2005-06-23 22:05:03 -07002072 .subvendor = PCI_ANY_ID,
2073 .subdevice = PCI_ANY_ID,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002074 },{
2075 /* --- end of list --- */
2076 }
2077};
2078MODULE_DEVICE_TABLE(pci, cx8800_pci_tbl);
2079
2080static struct pci_driver cx8800_pci_driver = {
Mauro Carvalho Chehabb45009b2005-06-23 22:05:03 -07002081 .name = "cx8800",
2082 .id_table = cx8800_pci_tbl,
2083 .probe = cx8800_initdev,
2084 .remove = __devexit_p(cx8800_finidev),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002085
2086 .suspend = cx8800_suspend,
2087 .resume = cx8800_resume,
2088};
2089
2090static int cx8800_init(void)
2091{
2092 printk(KERN_INFO "cx2388x v4l2 driver version %d.%d.%d loaded\n",
2093 (CX88_VERSION_CODE >> 16) & 0xff,
2094 (CX88_VERSION_CODE >> 8) & 0xff,
2095 CX88_VERSION_CODE & 0xff);
2096#ifdef SNAPSHOT
2097 printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
2098 SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
2099#endif
2100 return pci_register_driver(&cx8800_pci_driver);
2101}
2102
2103static void cx8800_fini(void)
2104{
2105 pci_unregister_driver(&cx8800_pci_driver);
2106}
2107
2108module_init(cx8800_init);
2109module_exit(cx8800_fini);
2110
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07002111EXPORT_SYMBOL(cx88_do_ioctl);
2112
Linus Torvalds1da177e2005-04-16 15:20:36 -07002113/* ----------------------------------------------------------- */
2114/*
2115 * Local variables:
2116 * c-basic-offset: 8
2117 * End:
Mauro Carvalho Chehabb45009b2005-06-23 22:05:03 -07002118 * kate: eol "unix"; indent-width 3; remove-trailing-space on; replace-trailing-space-save on; tab-width 8; replace-tabs off; space-indent off; mixed-indent off
Linus Torvalds1da177e2005-04-16 15:20:36 -07002119 */