3 * device driver for Conexant 2388x based TV cards
4 * video4linux video interface
6 * (c) 2003-04 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
8 * (c) 2005-2006 Mauro Carvalho Chehab <mchehab@infradead.org>
10 * - video_ioctl2 conversion
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #include <linux/init.h>
29 #include <linux/list.h>
30 #include <linux/module.h>
31 #include <linux/kmod.h>
32 #include <linux/kernel.h>
33 #include <linux/slab.h>
34 #include <linux/smp_lock.h>
35 #include <linux/interrupt.h>
36 #include <linux/dma-mapping.h>
37 #include <linux/delay.h>
38 #include <linux/kthread.h>
39 #include <asm/div64.h>
42 #include <media/v4l2-common.h>
43 #include <media/v4l2-ioctl.h>
44 #include <media/wm8775.h>
46 MODULE_DESCRIPTION("v4l2 driver module for cx2388x based TV cards");
47 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
48 MODULE_LICENSE("GPL");
50 /* ------------------------------------------------------------------ */
52 static unsigned int video_nr
[] = {[0 ... (CX88_MAXBOARDS
- 1)] = UNSET
};
53 static unsigned int vbi_nr
[] = {[0 ... (CX88_MAXBOARDS
- 1)] = UNSET
};
54 static unsigned int radio_nr
[] = {[0 ... (CX88_MAXBOARDS
- 1)] = UNSET
};
56 module_param_array(video_nr
, int, NULL
, 0444);
57 module_param_array(vbi_nr
, int, NULL
, 0444);
58 module_param_array(radio_nr
, int, NULL
, 0444);
60 MODULE_PARM_DESC(video_nr
,"video device numbers");
61 MODULE_PARM_DESC(vbi_nr
,"vbi device numbers");
62 MODULE_PARM_DESC(radio_nr
,"radio device numbers");
64 static unsigned int video_debug
;
65 module_param(video_debug
,int,0644);
66 MODULE_PARM_DESC(video_debug
,"enable debug messages [video]");
68 static unsigned int irq_debug
;
69 module_param(irq_debug
,int,0644);
70 MODULE_PARM_DESC(irq_debug
,"enable debug messages [IRQ handler]");
72 static unsigned int vid_limit
= 16;
73 module_param(vid_limit
,int,0644);
74 MODULE_PARM_DESC(vid_limit
,"capture memory limit in megabytes");
76 #define dprintk(level,fmt, arg...) if (video_debug >= level) \
77 printk(KERN_DEBUG "%s/0: " fmt, core->name , ## arg)
79 /* ------------------------------------------------------------------- */
82 static const struct cx8800_fmt formats
[] = {
84 .name
= "8 bpp, gray",
85 .fourcc
= V4L2_PIX_FMT_GREY
,
86 .cxformat
= ColorFormatY8
,
88 .flags
= FORMAT_FLAGS_PACKED
,
90 .name
= "15 bpp RGB, le",
91 .fourcc
= V4L2_PIX_FMT_RGB555
,
92 .cxformat
= ColorFormatRGB15
,
94 .flags
= FORMAT_FLAGS_PACKED
,
96 .name
= "15 bpp RGB, be",
97 .fourcc
= V4L2_PIX_FMT_RGB555X
,
98 .cxformat
= ColorFormatRGB15
| ColorFormatBSWAP
,
100 .flags
= FORMAT_FLAGS_PACKED
,
102 .name
= "16 bpp RGB, le",
103 .fourcc
= V4L2_PIX_FMT_RGB565
,
104 .cxformat
= ColorFormatRGB16
,
106 .flags
= FORMAT_FLAGS_PACKED
,
108 .name
= "16 bpp RGB, be",
109 .fourcc
= V4L2_PIX_FMT_RGB565X
,
110 .cxformat
= ColorFormatRGB16
| ColorFormatBSWAP
,
112 .flags
= FORMAT_FLAGS_PACKED
,
114 .name
= "24 bpp RGB, le",
115 .fourcc
= V4L2_PIX_FMT_BGR24
,
116 .cxformat
= ColorFormatRGB24
,
118 .flags
= FORMAT_FLAGS_PACKED
,
120 .name
= "32 bpp RGB, le",
121 .fourcc
= V4L2_PIX_FMT_BGR32
,
122 .cxformat
= ColorFormatRGB32
,
124 .flags
= FORMAT_FLAGS_PACKED
,
126 .name
= "32 bpp RGB, be",
127 .fourcc
= V4L2_PIX_FMT_RGB32
,
128 .cxformat
= ColorFormatRGB32
| ColorFormatBSWAP
| ColorFormatWSWAP
,
130 .flags
= FORMAT_FLAGS_PACKED
,
132 .name
= "4:2:2, packed, YUYV",
133 .fourcc
= V4L2_PIX_FMT_YUYV
,
134 .cxformat
= ColorFormatYUY2
,
136 .flags
= FORMAT_FLAGS_PACKED
,
138 .name
= "4:2:2, packed, UYVY",
139 .fourcc
= V4L2_PIX_FMT_UYVY
,
140 .cxformat
= ColorFormatYUY2
| ColorFormatBSWAP
,
142 .flags
= FORMAT_FLAGS_PACKED
,
146 static const struct cx8800_fmt
* format_by_fourcc(unsigned int fourcc
)
150 for (i
= 0; i
< ARRAY_SIZE(formats
); i
++)
151 if (formats
[i
].fourcc
== fourcc
)
156 /* ------------------------------------------------------------------- */
158 static const struct v4l2_queryctrl no_ctl
= {
160 .flags
= V4L2_CTRL_FLAG_DISABLED
,
163 static const struct cx88_ctrl cx8800_ctls
[] = {
167 .id
= V4L2_CID_BRIGHTNESS
,
168 .name
= "Brightness",
172 .default_value
= 0x7f,
173 .type
= V4L2_CTRL_TYPE_INTEGER
,
176 .reg
= MO_CONTR_BRIGHT
,
181 .id
= V4L2_CID_CONTRAST
,
186 .default_value
= 0x3f,
187 .type
= V4L2_CTRL_TYPE_INTEGER
,
190 .reg
= MO_CONTR_BRIGHT
,
200 .default_value
= 0x7f,
201 .type
= V4L2_CTRL_TYPE_INTEGER
,
208 /* strictly, this only describes only U saturation.
209 * V saturation is handled specially through code.
212 .id
= V4L2_CID_SATURATION
,
213 .name
= "Saturation",
217 .default_value
= 0x7f,
218 .type
= V4L2_CTRL_TYPE_INTEGER
,
221 .reg
= MO_UV_SATURATION
,
226 .id
= V4L2_CID_CHROMA_AGC
,
227 .name
= "Chroma AGC",
230 .default_value
= 0x1,
231 .type
= V4L2_CTRL_TYPE_BOOLEAN
,
233 .reg
= MO_INPUT_FORMAT
,
238 .id
= V4L2_CID_COLOR_KILLER
,
239 .name
= "Color killer",
242 .default_value
= 0x1,
243 .type
= V4L2_CTRL_TYPE_BOOLEAN
,
245 .reg
= MO_INPUT_FORMAT
,
251 .id
= V4L2_CID_AUDIO_MUTE
,
256 .type
= V4L2_CTRL_TYPE_BOOLEAN
,
259 .sreg
= SHADOW_AUD_VOL_CTL
,
264 .id
= V4L2_CID_AUDIO_VOLUME
,
269 .default_value
= 0x3f,
270 .type
= V4L2_CTRL_TYPE_INTEGER
,
273 .sreg
= SHADOW_AUD_VOL_CTL
,
278 .id
= V4L2_CID_AUDIO_BALANCE
,
283 .default_value
= 0x40,
284 .type
= V4L2_CTRL_TYPE_INTEGER
,
287 .sreg
= SHADOW_AUD_BAL_CTL
,
292 enum { CX8800_CTLS
= ARRAY_SIZE(cx8800_ctls
) };
294 /* Must be sorted from low to high control ID! */
295 const u32 cx88_user_ctrls
[] = {
301 V4L2_CID_AUDIO_VOLUME
,
302 V4L2_CID_AUDIO_BALANCE
,
305 V4L2_CID_COLOR_KILLER
,
308 EXPORT_SYMBOL(cx88_user_ctrls
);
310 static const u32
* const ctrl_classes
[] = {
315 int cx8800_ctrl_query(struct cx88_core
*core
, struct v4l2_queryctrl
*qctrl
)
319 if (qctrl
->id
< V4L2_CID_BASE
||
320 qctrl
->id
>= V4L2_CID_LASTP1
)
322 for (i
= 0; i
< CX8800_CTLS
; i
++)
323 if (cx8800_ctls
[i
].v
.id
== qctrl
->id
)
325 if (i
== CX8800_CTLS
) {
329 *qctrl
= cx8800_ctls
[i
].v
;
330 /* Report chroma AGC as inactive when SECAM is selected */
331 if (cx8800_ctls
[i
].v
.id
== V4L2_CID_CHROMA_AGC
&&
332 core
->tvnorm
& V4L2_STD_SECAM
)
333 qctrl
->flags
|= V4L2_CTRL_FLAG_INACTIVE
;
337 EXPORT_SYMBOL(cx8800_ctrl_query
);
339 /* ------------------------------------------------------------------- */
340 /* resource management */
342 static int res_get(struct cx8800_dev
*dev
, struct cx8800_fh
*fh
, unsigned int bit
)
344 struct cx88_core
*core
= dev
->core
;
345 if (fh
->resources
& bit
)
346 /* have it already allocated */
350 mutex_lock(&core
->lock
);
351 if (dev
->resources
& bit
) {
352 /* no, someone else uses it */
353 mutex_unlock(&core
->lock
);
356 /* it's free, grab it */
357 fh
->resources
|= bit
;
358 dev
->resources
|= bit
;
359 dprintk(1,"res: get %d\n",bit
);
360 mutex_unlock(&core
->lock
);
365 int res_check(struct cx8800_fh
*fh
, unsigned int bit
)
367 return (fh
->resources
& bit
);
371 int res_locked(struct cx8800_dev
*dev
, unsigned int bit
)
373 return (dev
->resources
& bit
);
377 void res_free(struct cx8800_dev
*dev
, struct cx8800_fh
*fh
, unsigned int bits
)
379 struct cx88_core
*core
= dev
->core
;
380 BUG_ON((fh
->resources
& bits
) != bits
);
382 mutex_lock(&core
->lock
);
383 fh
->resources
&= ~bits
;
384 dev
->resources
&= ~bits
;
385 dprintk(1,"res: put %d\n",bits
);
386 mutex_unlock(&core
->lock
);
389 /* ------------------------------------------------------------------ */
391 int cx88_video_mux(struct cx88_core
*core
, unsigned int input
)
393 /* struct cx88_core *core = dev->core; */
395 dprintk(1,"video_mux: %d [vmux=%d,gpio=0x%x,0x%x,0x%x,0x%x]\n",
396 input
, INPUT(input
).vmux
,
397 INPUT(input
).gpio0
,INPUT(input
).gpio1
,
398 INPUT(input
).gpio2
,INPUT(input
).gpio3
);
400 cx_andor(MO_INPUT_FORMAT
, 0x03 << 14, INPUT(input
).vmux
<< 14);
401 cx_write(MO_GP3_IO
, INPUT(input
).gpio3
);
402 cx_write(MO_GP0_IO
, INPUT(input
).gpio0
);
403 cx_write(MO_GP1_IO
, INPUT(input
).gpio1
);
404 cx_write(MO_GP2_IO
, INPUT(input
).gpio2
);
406 switch (INPUT(input
).type
) {
407 case CX88_VMUX_SVIDEO
:
408 cx_set(MO_AFECFG_IO
, 0x00000001);
409 cx_set(MO_INPUT_FORMAT
, 0x00010010);
410 cx_set(MO_FILTER_EVEN
, 0x00002020);
411 cx_set(MO_FILTER_ODD
, 0x00002020);
414 cx_clear(MO_AFECFG_IO
, 0x00000001);
415 cx_clear(MO_INPUT_FORMAT
, 0x00010010);
416 cx_clear(MO_FILTER_EVEN
, 0x00002020);
417 cx_clear(MO_FILTER_ODD
, 0x00002020);
421 /* if there are audioroutes defined, we have an external
422 ADC to deal with audio */
423 if (INPUT(input
).audioroute
) {
424 /* The wm8775 module has the "2" route hardwired into
425 the initialization. Some boards may use different
426 routes for different inputs. HVR-1300 surely does */
427 if (core
->board
.audio_chip
&&
428 core
->board
.audio_chip
== V4L2_IDENT_WM8775
) {
429 call_all(core
, audio
, s_routing
,
430 INPUT(input
).audioroute
, 0, 0);
432 /* cx2388's C-ADC is connected to the tuner only.
433 When used with S-Video, that ADC is busy dealing with
434 chroma, so an external must be used for baseband audio */
435 if (INPUT(input
).type
!= CX88_VMUX_TELEVISION
&&
436 INPUT(input
).type
!= CX88_VMUX_CABLE
) {
438 core
->tvaudio
= WW_I2SADC
;
439 cx88_set_tvaudio(core
);
442 cx_write(AUD_I2SCNTL
, 0x0);
443 cx_clear(AUD_CTL
, EN_I2SIN_ENABLE
);
449 EXPORT_SYMBOL(cx88_video_mux
);
451 /* ------------------------------------------------------------------ */
453 static int start_video_dma(struct cx8800_dev
*dev
,
454 struct cx88_dmaqueue
*q
,
455 struct cx88_buffer
*buf
)
457 struct cx88_core
*core
= dev
->core
;
459 /* setup fifo + format */
460 cx88_sram_channel_setup(core
, &cx88_sram_channels
[SRAM_CH21
],
461 buf
->bpl
, buf
->risc
.dma
);
462 cx88_set_scale(core
, buf
->vb
.width
, buf
->vb
.height
, buf
->vb
.field
);
463 cx_write(MO_COLOR_CTRL
, buf
->fmt
->cxformat
| ColorFormatGamma
);
466 cx_write(MO_VIDY_GPCNTRL
,GP_COUNT_CONTROL_RESET
);
470 cx_set(MO_PCI_INTMSK
, core
->pci_irqmask
| PCI_INT_VIDINT
);
472 /* Enables corresponding bits at PCI_INT_STAT:
473 bits 0 to 4: video, audio, transport stream, VIP, Host
475 bits 8 and 9: DMA complete for: SRC, DST
476 bits 10 and 11: BERR signal asserted for RISC: RD, WR
477 bits 12 to 15: BERR signal asserted for: BRDG, SRC, DST, IPB
479 cx_set(MO_VID_INTMSK
, 0x0f0011);
482 cx_set(VID_CAPTURE_CONTROL
,0x06);
485 cx_set(MO_DEV_CNTRL2
, (1<<5));
486 cx_set(MO_VID_DMACNTRL
, 0x11); /* Planar Y and packed FIFO and RISC enable */
492 static int stop_video_dma(struct cx8800_dev
*dev
)
494 struct cx88_core
*core
= dev
->core
;
497 cx_clear(MO_VID_DMACNTRL
, 0x11);
499 /* disable capture */
500 cx_clear(VID_CAPTURE_CONTROL
,0x06);
503 cx_clear(MO_PCI_INTMSK
, PCI_INT_VIDINT
);
504 cx_clear(MO_VID_INTMSK
, 0x0f0011);
509 static int restart_video_queue(struct cx8800_dev
*dev
,
510 struct cx88_dmaqueue
*q
)
512 struct cx88_core
*core
= dev
->core
;
513 struct cx88_buffer
*buf
, *prev
;
515 if (!list_empty(&q
->active
)) {
516 buf
= list_entry(q
->active
.next
, struct cx88_buffer
, vb
.queue
);
517 dprintk(2,"restart_queue [%p/%d]: restart dma\n",
519 start_video_dma(dev
, q
, buf
);
520 list_for_each_entry(buf
, &q
->active
, vb
.queue
)
521 buf
->count
= q
->count
++;
522 mod_timer(&q
->timeout
, jiffies
+BUFFER_TIMEOUT
);
528 if (list_empty(&q
->queued
))
530 buf
= list_entry(q
->queued
.next
, struct cx88_buffer
, vb
.queue
);
532 list_move_tail(&buf
->vb
.queue
, &q
->active
);
533 start_video_dma(dev
, q
, buf
);
534 buf
->vb
.state
= VIDEOBUF_ACTIVE
;
535 buf
->count
= q
->count
++;
536 mod_timer(&q
->timeout
, jiffies
+BUFFER_TIMEOUT
);
537 dprintk(2,"[%p/%d] restart_queue - first active\n",
540 } else if (prev
->vb
.width
== buf
->vb
.width
&&
541 prev
->vb
.height
== buf
->vb
.height
&&
542 prev
->fmt
== buf
->fmt
) {
543 list_move_tail(&buf
->vb
.queue
, &q
->active
);
544 buf
->vb
.state
= VIDEOBUF_ACTIVE
;
545 buf
->count
= q
->count
++;
546 prev
->risc
.jmp
[1] = cpu_to_le32(buf
->risc
.dma
);
547 dprintk(2,"[%p/%d] restart_queue - move to active\n",
556 /* ------------------------------------------------------------------ */
559 buffer_setup(struct videobuf_queue
*q
, unsigned int *count
, unsigned int *size
)
561 struct cx8800_fh
*fh
= q
->priv_data
;
563 *size
= fh
->fmt
->depth
*fh
->width
*fh
->height
>> 3;
566 if (*size
* *count
> vid_limit
* 1024 * 1024)
567 *count
= (vid_limit
* 1024 * 1024) / *size
;
572 buffer_prepare(struct videobuf_queue
*q
, struct videobuf_buffer
*vb
,
573 enum v4l2_field field
)
575 struct cx8800_fh
*fh
= q
->priv_data
;
576 struct cx8800_dev
*dev
= fh
->dev
;
577 struct cx88_core
*core
= dev
->core
;
578 struct cx88_buffer
*buf
= container_of(vb
,struct cx88_buffer
,vb
);
579 struct videobuf_dmabuf
*dma
=videobuf_to_dma(&buf
->vb
);
580 int rc
, init_buffer
= 0;
582 BUG_ON(NULL
== fh
->fmt
);
583 if (fh
->width
< 48 || fh
->width
> norm_maxw(core
->tvnorm
) ||
584 fh
->height
< 32 || fh
->height
> norm_maxh(core
->tvnorm
))
586 buf
->vb
.size
= (fh
->width
* fh
->height
* fh
->fmt
->depth
) >> 3;
587 if (0 != buf
->vb
.baddr
&& buf
->vb
.bsize
< buf
->vb
.size
)
590 if (buf
->fmt
!= fh
->fmt
||
591 buf
->vb
.width
!= fh
->width
||
592 buf
->vb
.height
!= fh
->height
||
593 buf
->vb
.field
!= field
) {
595 buf
->vb
.width
= fh
->width
;
596 buf
->vb
.height
= fh
->height
;
597 buf
->vb
.field
= field
;
601 if (VIDEOBUF_NEEDS_INIT
== buf
->vb
.state
) {
603 if (0 != (rc
= videobuf_iolock(q
,&buf
->vb
,NULL
)))
608 buf
->bpl
= buf
->vb
.width
* buf
->fmt
->depth
>> 3;
609 switch (buf
->vb
.field
) {
611 cx88_risc_buffer(dev
->pci
, &buf
->risc
,
612 dma
->sglist
, 0, UNSET
,
613 buf
->bpl
, 0, buf
->vb
.height
);
615 case V4L2_FIELD_BOTTOM
:
616 cx88_risc_buffer(dev
->pci
, &buf
->risc
,
617 dma
->sglist
, UNSET
, 0,
618 buf
->bpl
, 0, buf
->vb
.height
);
620 case V4L2_FIELD_INTERLACED
:
621 cx88_risc_buffer(dev
->pci
, &buf
->risc
,
622 dma
->sglist
, 0, buf
->bpl
,
624 buf
->vb
.height
>> 1);
626 case V4L2_FIELD_SEQ_TB
:
627 cx88_risc_buffer(dev
->pci
, &buf
->risc
,
629 0, buf
->bpl
* (buf
->vb
.height
>> 1),
631 buf
->vb
.height
>> 1);
633 case V4L2_FIELD_SEQ_BT
:
634 cx88_risc_buffer(dev
->pci
, &buf
->risc
,
636 buf
->bpl
* (buf
->vb
.height
>> 1), 0,
638 buf
->vb
.height
>> 1);
644 dprintk(2,"[%p/%d] buffer_prepare - %dx%d %dbpp \"%s\" - dma=0x%08lx\n",
646 fh
->width
, fh
->height
, fh
->fmt
->depth
, fh
->fmt
->name
,
647 (unsigned long)buf
->risc
.dma
);
649 buf
->vb
.state
= VIDEOBUF_PREPARED
;
653 cx88_free_buffer(q
,buf
);
658 buffer_queue(struct videobuf_queue
*vq
, struct videobuf_buffer
*vb
)
660 struct cx88_buffer
*buf
= container_of(vb
,struct cx88_buffer
,vb
);
661 struct cx88_buffer
*prev
;
662 struct cx8800_fh
*fh
= vq
->priv_data
;
663 struct cx8800_dev
*dev
= fh
->dev
;
664 struct cx88_core
*core
= dev
->core
;
665 struct cx88_dmaqueue
*q
= &dev
->vidq
;
667 /* add jump to stopper */
668 buf
->risc
.jmp
[0] = cpu_to_le32(RISC_JUMP
| RISC_IRQ1
| RISC_CNT_INC
);
669 buf
->risc
.jmp
[1] = cpu_to_le32(q
->stopper
.dma
);
671 if (!list_empty(&q
->queued
)) {
672 list_add_tail(&buf
->vb
.queue
,&q
->queued
);
673 buf
->vb
.state
= VIDEOBUF_QUEUED
;
674 dprintk(2,"[%p/%d] buffer_queue - append to queued\n",
677 } else if (list_empty(&q
->active
)) {
678 list_add_tail(&buf
->vb
.queue
,&q
->active
);
679 start_video_dma(dev
, q
, buf
);
680 buf
->vb
.state
= VIDEOBUF_ACTIVE
;
681 buf
->count
= q
->count
++;
682 mod_timer(&q
->timeout
, jiffies
+BUFFER_TIMEOUT
);
683 dprintk(2,"[%p/%d] buffer_queue - first active\n",
687 prev
= list_entry(q
->active
.prev
, struct cx88_buffer
, vb
.queue
);
688 if (prev
->vb
.width
== buf
->vb
.width
&&
689 prev
->vb
.height
== buf
->vb
.height
&&
690 prev
->fmt
== buf
->fmt
) {
691 list_add_tail(&buf
->vb
.queue
,&q
->active
);
692 buf
->vb
.state
= VIDEOBUF_ACTIVE
;
693 buf
->count
= q
->count
++;
694 prev
->risc
.jmp
[1] = cpu_to_le32(buf
->risc
.dma
);
695 dprintk(2,"[%p/%d] buffer_queue - append to active\n",
699 list_add_tail(&buf
->vb
.queue
,&q
->queued
);
700 buf
->vb
.state
= VIDEOBUF_QUEUED
;
701 dprintk(2,"[%p/%d] buffer_queue - first queued\n",
707 static void buffer_release(struct videobuf_queue
*q
, struct videobuf_buffer
*vb
)
709 struct cx88_buffer
*buf
= container_of(vb
,struct cx88_buffer
,vb
);
711 cx88_free_buffer(q
,buf
);
714 static const struct videobuf_queue_ops cx8800_video_qops
= {
715 .buf_setup
= buffer_setup
,
716 .buf_prepare
= buffer_prepare
,
717 .buf_queue
= buffer_queue
,
718 .buf_release
= buffer_release
,
721 /* ------------------------------------------------------------------ */
724 /* ------------------------------------------------------------------ */
726 static struct videobuf_queue
* get_queue(struct cx8800_fh
*fh
)
729 case V4L2_BUF_TYPE_VIDEO_CAPTURE
:
731 case V4L2_BUF_TYPE_VBI_CAPTURE
:
739 static int get_ressource(struct cx8800_fh
*fh
)
742 case V4L2_BUF_TYPE_VIDEO_CAPTURE
:
743 return RESOURCE_VIDEO
;
744 case V4L2_BUF_TYPE_VBI_CAPTURE
:
752 static int video_open(struct file
*file
)
754 struct video_device
*vdev
= video_devdata(file
);
755 struct cx8800_dev
*dev
= video_drvdata(file
);
756 struct cx88_core
*core
= dev
->core
;
757 struct cx8800_fh
*fh
;
758 enum v4l2_buf_type type
= 0;
761 switch (vdev
->vfl_type
) {
762 case VFL_TYPE_GRABBER
:
763 type
= V4L2_BUF_TYPE_VIDEO_CAPTURE
;
766 type
= V4L2_BUF_TYPE_VBI_CAPTURE
;
773 dprintk(1, "open dev=%s radio=%d type=%s\n",
774 video_device_node_name(vdev
), radio
, v4l2_type_names
[type
]);
776 /* allocate + initialize per filehandle data */
777 fh
= kzalloc(sizeof(*fh
),GFP_KERNEL
);
781 file
->private_data
= fh
;
787 fh
->fmt
= format_by_fourcc(V4L2_PIX_FMT_BGR24
);
789 mutex_lock(&core
->lock
);
791 videobuf_queue_sg_init(&fh
->vidq
, &cx8800_video_qops
,
792 &dev
->pci
->dev
, &dev
->slock
,
793 V4L2_BUF_TYPE_VIDEO_CAPTURE
,
794 V4L2_FIELD_INTERLACED
,
795 sizeof(struct cx88_buffer
),
797 videobuf_queue_sg_init(&fh
->vbiq
, &cx8800_vbi_qops
,
798 &dev
->pci
->dev
, &dev
->slock
,
799 V4L2_BUF_TYPE_VBI_CAPTURE
,
801 sizeof(struct cx88_buffer
),
805 dprintk(1,"video_open: setting radio device\n");
806 cx_write(MO_GP3_IO
, core
->board
.radio
.gpio3
);
807 cx_write(MO_GP0_IO
, core
->board
.radio
.gpio0
);
808 cx_write(MO_GP1_IO
, core
->board
.radio
.gpio1
);
809 cx_write(MO_GP2_IO
, core
->board
.radio
.gpio2
);
810 if (core
->board
.radio
.audioroute
) {
811 if(core
->board
.audio_chip
&&
812 core
->board
.audio_chip
== V4L2_IDENT_WM8775
) {
813 call_all(core
, audio
, s_routing
,
814 core
->board
.radio
.audioroute
, 0, 0);
817 core
->tvaudio
= WW_I2SADC
;
818 cx88_set_tvaudio(core
);
821 core
->tvaudio
= WW_FM
;
822 cx88_set_tvaudio(core
);
823 cx88_set_stereo(core
,V4L2_TUNER_MODE_STEREO
,1);
825 call_all(core
, tuner
, s_radio
);
828 atomic_inc(&core
->users
);
829 mutex_unlock(&core
->lock
);
835 video_read(struct file
*file
, char __user
*data
, size_t count
, loff_t
*ppos
)
837 struct cx8800_fh
*fh
= file
->private_data
;
840 case V4L2_BUF_TYPE_VIDEO_CAPTURE
:
841 if (res_locked(fh
->dev
,RESOURCE_VIDEO
))
843 return videobuf_read_one(&fh
->vidq
, data
, count
, ppos
,
844 file
->f_flags
& O_NONBLOCK
);
845 case V4L2_BUF_TYPE_VBI_CAPTURE
:
846 if (!res_get(fh
->dev
,fh
,RESOURCE_VBI
))
848 return videobuf_read_stream(&fh
->vbiq
, data
, count
, ppos
, 1,
849 file
->f_flags
& O_NONBLOCK
);
857 video_poll(struct file
*file
, struct poll_table_struct
*wait
)
859 struct cx8800_fh
*fh
= file
->private_data
;
860 struct cx88_buffer
*buf
;
861 unsigned int rc
= POLLERR
;
863 if (V4L2_BUF_TYPE_VBI_CAPTURE
== fh
->type
) {
864 if (!res_get(fh
->dev
,fh
,RESOURCE_VBI
))
866 return videobuf_poll_stream(file
, &fh
->vbiq
, wait
);
869 mutex_lock(&fh
->vidq
.vb_lock
);
870 if (res_check(fh
,RESOURCE_VIDEO
)) {
871 /* streaming capture */
872 if (list_empty(&fh
->vidq
.stream
))
874 buf
= list_entry(fh
->vidq
.stream
.next
,struct cx88_buffer
,vb
.stream
);
877 buf
= (struct cx88_buffer
*)fh
->vidq
.read_buf
;
881 poll_wait(file
, &buf
->vb
.done
, wait
);
882 if (buf
->vb
.state
== VIDEOBUF_DONE
||
883 buf
->vb
.state
== VIDEOBUF_ERROR
)
884 rc
= POLLIN
|POLLRDNORM
;
888 mutex_unlock(&fh
->vidq
.vb_lock
);
892 static int video_release(struct file
*file
)
894 struct cx8800_fh
*fh
= file
->private_data
;
895 struct cx8800_dev
*dev
= fh
->dev
;
897 /* turn off overlay */
898 if (res_check(fh
, RESOURCE_OVERLAY
)) {
900 res_free(dev
,fh
,RESOURCE_OVERLAY
);
903 /* stop video capture */
904 if (res_check(fh
, RESOURCE_VIDEO
)) {
905 videobuf_queue_cancel(&fh
->vidq
);
906 res_free(dev
,fh
,RESOURCE_VIDEO
);
908 if (fh
->vidq
.read_buf
) {
909 buffer_release(&fh
->vidq
,fh
->vidq
.read_buf
);
910 kfree(fh
->vidq
.read_buf
);
913 /* stop vbi capture */
914 if (res_check(fh
, RESOURCE_VBI
)) {
915 videobuf_stop(&fh
->vbiq
);
916 res_free(dev
,fh
,RESOURCE_VBI
);
919 videobuf_mmap_free(&fh
->vidq
);
920 videobuf_mmap_free(&fh
->vbiq
);
922 mutex_lock(&dev
->core
->lock
);
923 file
->private_data
= NULL
;
926 if(atomic_dec_and_test(&dev
->core
->users
))
927 call_all(dev
->core
, core
, s_power
, 0);
928 mutex_unlock(&dev
->core
->lock
);
934 video_mmap(struct file
*file
, struct vm_area_struct
* vma
)
936 struct cx8800_fh
*fh
= file
->private_data
;
938 return videobuf_mmap_mapper(get_queue(fh
), vma
);
941 /* ------------------------------------------------------------------ */
942 /* VIDEO CTRL IOCTLS */
944 int cx88_get_control (struct cx88_core
*core
, struct v4l2_control
*ctl
)
946 const struct cx88_ctrl
*c
= NULL
;
950 for (i
= 0; i
< CX8800_CTLS
; i
++)
951 if (cx8800_ctls
[i
].v
.id
== ctl
->id
)
953 if (unlikely(NULL
== c
))
956 value
= c
->sreg
? cx_sread(c
->sreg
) : cx_read(c
->reg
);
958 case V4L2_CID_AUDIO_BALANCE
:
959 ctl
->value
= ((value
& 0x7f) < 0x40) ? ((value
& 0x7f) + 0x40)
960 : (0x7f - (value
& 0x7f));
962 case V4L2_CID_AUDIO_VOLUME
:
963 ctl
->value
= 0x3f - (value
& 0x3f);
966 ctl
->value
= ((value
+ (c
->off
<< c
->shift
)) & c
->mask
) >> c
->shift
;
969 dprintk(1,"get_control id=0x%X(%s) ctrl=0x%02x, reg=0x%02x val=0x%02x (mask 0x%02x)%s\n",
970 ctl
->id
, c
->v
.name
, ctl
->value
, c
->reg
,
971 value
,c
->mask
, c
->sreg
? " [shadowed]" : "");
974 EXPORT_SYMBOL(cx88_get_control
);
976 int cx88_set_control(struct cx88_core
*core
, struct v4l2_control
*ctl
)
978 const struct cx88_ctrl
*c
= NULL
;
981 struct v4l2_control client_ctl
;
983 for (i
= 0; i
< CX8800_CTLS
; i
++) {
984 if (cx8800_ctls
[i
].v
.id
== ctl
->id
) {
988 if (unlikely(NULL
== c
))
991 if (ctl
->value
< c
->v
.minimum
)
992 ctl
->value
= c
->v
.minimum
;
993 if (ctl
->value
> c
->v
.maximum
)
994 ctl
->value
= c
->v
.maximum
;
996 /* Pass changes onto any WM8775 */
997 client_ctl
.id
= ctl
->id
;
999 case V4L2_CID_AUDIO_MUTE
:
1000 client_ctl
.value
= ctl
->value
;
1002 case V4L2_CID_AUDIO_VOLUME
:
1003 client_ctl
.value
= (ctl
->value
) ?
1004 (0x90 + ctl
->value
) << 8 : 0;
1006 case V4L2_CID_AUDIO_BALANCE
:
1007 client_ctl
.value
= ctl
->value
<< 9;
1014 call_hw(core
, WM8775_GID
, core
, s_ctrl
, &client_ctl
);
1018 case V4L2_CID_AUDIO_BALANCE
:
1019 value
= (ctl
->value
< 0x40) ? (0x7f - ctl
->value
) : (ctl
->value
- 0x40);
1021 case V4L2_CID_AUDIO_VOLUME
:
1022 value
= 0x3f - (ctl
->value
& 0x3f);
1024 case V4L2_CID_SATURATION
:
1025 /* special v_sat handling */
1027 value
= ((ctl
->value
- c
->off
) << c
->shift
) & c
->mask
;
1029 if (core
->tvnorm
& V4L2_STD_SECAM
) {
1030 /* For SECAM, both U and V sat should be equal */
1031 value
=value
<<8|value
;
1033 /* Keeps U Saturation proportional to V Sat */
1034 value
=(value
*0x5a)/0x7f<<8|value
;
1038 case V4L2_CID_CHROMA_AGC
:
1039 /* Do not allow chroma AGC to be enabled for SECAM */
1040 value
= ((ctl
->value
- c
->off
) << c
->shift
) & c
->mask
;
1041 if (core
->tvnorm
& V4L2_STD_SECAM
&& value
)
1045 value
= ((ctl
->value
- c
->off
) << c
->shift
) & c
->mask
;
1048 dprintk(1,"set_control id=0x%X(%s) ctrl=0x%02x, reg=0x%02x val=0x%02x (mask 0x%02x)%s\n",
1049 ctl
->id
, c
->v
.name
, ctl
->value
, c
->reg
, value
,
1050 mask
, c
->sreg
? " [shadowed]" : "");
1052 cx_sandor(c
->sreg
, c
->reg
, mask
, value
);
1054 cx_andor(c
->reg
, mask
, value
);
1058 EXPORT_SYMBOL(cx88_set_control
);
1060 static void init_controls(struct cx88_core
*core
)
1062 struct v4l2_control ctrl
;
1065 for (i
= 0; i
< CX8800_CTLS
; i
++) {
1066 ctrl
.id
=cx8800_ctls
[i
].v
.id
;
1067 ctrl
.value
=cx8800_ctls
[i
].v
.default_value
;
1069 cx88_set_control(core
, &ctrl
);
1073 /* ------------------------------------------------------------------ */
1076 static int vidioc_g_fmt_vid_cap(struct file
*file
, void *priv
,
1077 struct v4l2_format
*f
)
1079 struct cx8800_fh
*fh
= priv
;
1081 f
->fmt
.pix
.width
= fh
->width
;
1082 f
->fmt
.pix
.height
= fh
->height
;
1083 f
->fmt
.pix
.field
= fh
->vidq
.field
;
1084 f
->fmt
.pix
.pixelformat
= fh
->fmt
->fourcc
;
1085 f
->fmt
.pix
.bytesperline
=
1086 (f
->fmt
.pix
.width
* fh
->fmt
->depth
) >> 3;
1087 f
->fmt
.pix
.sizeimage
=
1088 f
->fmt
.pix
.height
* f
->fmt
.pix
.bytesperline
;
1092 static int vidioc_try_fmt_vid_cap(struct file
*file
, void *priv
,
1093 struct v4l2_format
*f
)
1095 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1096 const struct cx8800_fmt
*fmt
;
1097 enum v4l2_field field
;
1098 unsigned int maxw
, maxh
;
1100 fmt
= format_by_fourcc(f
->fmt
.pix
.pixelformat
);
1104 field
= f
->fmt
.pix
.field
;
1105 maxw
= norm_maxw(core
->tvnorm
);
1106 maxh
= norm_maxh(core
->tvnorm
);
1108 if (V4L2_FIELD_ANY
== field
) {
1109 field
= (f
->fmt
.pix
.height
> maxh
/2)
1110 ? V4L2_FIELD_INTERLACED
1111 : V4L2_FIELD_BOTTOM
;
1115 case V4L2_FIELD_TOP
:
1116 case V4L2_FIELD_BOTTOM
:
1119 case V4L2_FIELD_INTERLACED
:
1125 f
->fmt
.pix
.field
= field
;
1126 v4l_bound_align_image(&f
->fmt
.pix
.width
, 48, maxw
, 2,
1127 &f
->fmt
.pix
.height
, 32, maxh
, 0, 0);
1128 f
->fmt
.pix
.bytesperline
=
1129 (f
->fmt
.pix
.width
* fmt
->depth
) >> 3;
1130 f
->fmt
.pix
.sizeimage
=
1131 f
->fmt
.pix
.height
* f
->fmt
.pix
.bytesperline
;
1136 static int vidioc_s_fmt_vid_cap(struct file
*file
, void *priv
,
1137 struct v4l2_format
*f
)
1139 struct cx8800_fh
*fh
= priv
;
1140 int err
= vidioc_try_fmt_vid_cap (file
,priv
,f
);
1144 fh
->fmt
= format_by_fourcc(f
->fmt
.pix
.pixelformat
);
1145 fh
->width
= f
->fmt
.pix
.width
;
1146 fh
->height
= f
->fmt
.pix
.height
;
1147 fh
->vidq
.field
= f
->fmt
.pix
.field
;
1151 static int vidioc_querycap (struct file
*file
, void *priv
,
1152 struct v4l2_capability
*cap
)
1154 struct cx8800_dev
*dev
= ((struct cx8800_fh
*)priv
)->dev
;
1155 struct cx88_core
*core
= dev
->core
;
1157 strcpy(cap
->driver
, "cx8800");
1158 strlcpy(cap
->card
, core
->board
.name
, sizeof(cap
->card
));
1159 sprintf(cap
->bus_info
,"PCI:%s",pci_name(dev
->pci
));
1160 cap
->version
= CX88_VERSION_CODE
;
1162 V4L2_CAP_VIDEO_CAPTURE
|
1163 V4L2_CAP_READWRITE
|
1164 V4L2_CAP_STREAMING
|
1165 V4L2_CAP_VBI_CAPTURE
;
1166 if (UNSET
!= core
->board
.tuner_type
)
1167 cap
->capabilities
|= V4L2_CAP_TUNER
;
1171 static int vidioc_enum_fmt_vid_cap (struct file
*file
, void *priv
,
1172 struct v4l2_fmtdesc
*f
)
1174 if (unlikely(f
->index
>= ARRAY_SIZE(formats
)))
1177 strlcpy(f
->description
,formats
[f
->index
].name
,sizeof(f
->description
));
1178 f
->pixelformat
= formats
[f
->index
].fourcc
;
1183 #ifdef CONFIG_VIDEO_V4L1_COMPAT
1184 static int vidiocgmbuf (struct file
*file
, void *priv
, struct video_mbuf
*mbuf
)
1186 struct cx8800_fh
*fh
= priv
;
1188 return videobuf_cgmbuf (get_queue(fh
), mbuf
, 8);
1192 static int vidioc_reqbufs (struct file
*file
, void *priv
, struct v4l2_requestbuffers
*p
)
1194 struct cx8800_fh
*fh
= priv
;
1195 return (videobuf_reqbufs(get_queue(fh
), p
));
1198 static int vidioc_querybuf (struct file
*file
, void *priv
, struct v4l2_buffer
*p
)
1200 struct cx8800_fh
*fh
= priv
;
1201 return (videobuf_querybuf(get_queue(fh
), p
));
1204 static int vidioc_qbuf (struct file
*file
, void *priv
, struct v4l2_buffer
*p
)
1206 struct cx8800_fh
*fh
= priv
;
1207 return (videobuf_qbuf(get_queue(fh
), p
));
1210 static int vidioc_dqbuf (struct file
*file
, void *priv
, struct v4l2_buffer
*p
)
1212 struct cx8800_fh
*fh
= priv
;
1213 return (videobuf_dqbuf(get_queue(fh
), p
,
1214 file
->f_flags
& O_NONBLOCK
));
1217 static int vidioc_streamon(struct file
*file
, void *priv
, enum v4l2_buf_type i
)
1219 struct cx8800_fh
*fh
= priv
;
1220 struct cx8800_dev
*dev
= fh
->dev
;
1222 /* We should remember that this driver also supports teletext, */
1223 /* so we have to test if the v4l2_buf_type is VBI capture data. */
1224 if (unlikely((fh
->type
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
) &&
1225 (fh
->type
!= V4L2_BUF_TYPE_VBI_CAPTURE
)))
1228 if (unlikely(i
!= fh
->type
))
1231 if (unlikely(!res_get(dev
,fh
,get_ressource(fh
))))
1233 return videobuf_streamon(get_queue(fh
));
1236 static int vidioc_streamoff(struct file
*file
, void *priv
, enum v4l2_buf_type i
)
1238 struct cx8800_fh
*fh
= priv
;
1239 struct cx8800_dev
*dev
= fh
->dev
;
1242 if ((fh
->type
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
) &&
1243 (fh
->type
!= V4L2_BUF_TYPE_VBI_CAPTURE
))
1249 res
= get_ressource(fh
);
1250 err
= videobuf_streamoff(get_queue(fh
));
1253 res_free(dev
,fh
,res
);
1257 static int vidioc_s_std (struct file
*file
, void *priv
, v4l2_std_id
*tvnorms
)
1259 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1261 mutex_lock(&core
->lock
);
1262 cx88_set_tvnorm(core
,*tvnorms
);
1263 mutex_unlock(&core
->lock
);
1268 /* only one input in this sample driver */
1269 int cx88_enum_input (struct cx88_core
*core
,struct v4l2_input
*i
)
1271 static const char * const iname
[] = {
1272 [ CX88_VMUX_COMPOSITE1
] = "Composite1",
1273 [ CX88_VMUX_COMPOSITE2
] = "Composite2",
1274 [ CX88_VMUX_COMPOSITE3
] = "Composite3",
1275 [ CX88_VMUX_COMPOSITE4
] = "Composite4",
1276 [ CX88_VMUX_SVIDEO
] = "S-Video",
1277 [ CX88_VMUX_TELEVISION
] = "Television",
1278 [ CX88_VMUX_CABLE
] = "Cable TV",
1279 [ CX88_VMUX_DVB
] = "DVB",
1280 [ CX88_VMUX_DEBUG
] = "for debug only",
1282 unsigned int n
= i
->index
;
1286 if (0 == INPUT(n
).type
)
1288 i
->type
= V4L2_INPUT_TYPE_CAMERA
;
1289 strcpy(i
->name
,iname
[INPUT(n
).type
]);
1290 if ((CX88_VMUX_TELEVISION
== INPUT(n
).type
) ||
1291 (CX88_VMUX_CABLE
== INPUT(n
).type
)) {
1292 i
->type
= V4L2_INPUT_TYPE_TUNER
;
1293 i
->std
= CX88_NORMS
;
1297 EXPORT_SYMBOL(cx88_enum_input
);
1299 static int vidioc_enum_input (struct file
*file
, void *priv
,
1300 struct v4l2_input
*i
)
1302 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1303 return cx88_enum_input (core
,i
);
1306 static int vidioc_g_input (struct file
*file
, void *priv
, unsigned int *i
)
1308 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1314 static int vidioc_s_input (struct file
*file
, void *priv
, unsigned int i
)
1316 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1321 mutex_lock(&core
->lock
);
1322 cx88_newstation(core
);
1323 cx88_video_mux(core
,i
);
1324 mutex_unlock(&core
->lock
);
1330 static int vidioc_queryctrl (struct file
*file
, void *priv
,
1331 struct v4l2_queryctrl
*qctrl
)
1333 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1335 qctrl
->id
= v4l2_ctrl_next(ctrl_classes
, qctrl
->id
);
1336 if (unlikely(qctrl
->id
== 0))
1338 return cx8800_ctrl_query(core
, qctrl
);
1341 static int vidioc_g_ctrl (struct file
*file
, void *priv
,
1342 struct v4l2_control
*ctl
)
1344 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1346 cx88_get_control(core
,ctl
);
1349 static int vidioc_s_ctrl (struct file
*file
, void *priv
,
1350 struct v4l2_control
*ctl
)
1352 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1354 cx88_set_control(core
,ctl
);
1357 static int vidioc_g_tuner (struct file
*file
, void *priv
,
1358 struct v4l2_tuner
*t
)
1360 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1363 if (unlikely(UNSET
== core
->board
.tuner_type
))
1368 strcpy(t
->name
, "Television");
1369 t
->type
= V4L2_TUNER_ANALOG_TV
;
1370 t
->capability
= V4L2_TUNER_CAP_NORM
;
1371 t
->rangehigh
= 0xffffffffUL
;
1373 cx88_get_stereo(core
,t
);
1374 reg
= cx_read(MO_DEVICE_STATUS
);
1375 t
->signal
= (reg
& (1<<5)) ? 0xffff : 0x0000;
1379 static int vidioc_s_tuner (struct file
*file
, void *priv
,
1380 struct v4l2_tuner
*t
)
1382 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1384 if (UNSET
== core
->board
.tuner_type
)
1389 cx88_set_stereo(core
, t
->audmode
, 1);
1393 static int vidioc_g_frequency (struct file
*file
, void *priv
,
1394 struct v4l2_frequency
*f
)
1396 struct cx8800_fh
*fh
= priv
;
1397 struct cx88_core
*core
= fh
->dev
->core
;
1399 if (unlikely(UNSET
== core
->board
.tuner_type
))
1402 /* f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; */
1403 f
->type
= fh
->radio
? V4L2_TUNER_RADIO
: V4L2_TUNER_ANALOG_TV
;
1404 f
->frequency
= core
->freq
;
1406 call_all(core
, tuner
, g_frequency
, f
);
1411 int cx88_set_freq (struct cx88_core
*core
,
1412 struct v4l2_frequency
*f
)
1414 if (unlikely(UNSET
== core
->board
.tuner_type
))
1416 if (unlikely(f
->tuner
!= 0))
1419 mutex_lock(&core
->lock
);
1420 core
->freq
= f
->frequency
;
1421 cx88_newstation(core
);
1422 call_all(core
, tuner
, s_frequency
, f
);
1424 /* When changing channels it is required to reset TVAUDIO */
1426 cx88_set_tvaudio(core
);
1428 mutex_unlock(&core
->lock
);
1432 EXPORT_SYMBOL(cx88_set_freq
);
1434 static int vidioc_s_frequency (struct file
*file
, void *priv
,
1435 struct v4l2_frequency
*f
)
1437 struct cx8800_fh
*fh
= priv
;
1438 struct cx88_core
*core
= fh
->dev
->core
;
1440 if (unlikely(0 == fh
->radio
&& f
->type
!= V4L2_TUNER_ANALOG_TV
))
1442 if (unlikely(1 == fh
->radio
&& f
->type
!= V4L2_TUNER_RADIO
))
1446 cx88_set_freq (core
,f
);
1449 #ifdef CONFIG_VIDEO_ADV_DEBUG
1450 static int vidioc_g_register (struct file
*file
, void *fh
,
1451 struct v4l2_dbg_register
*reg
)
1453 struct cx88_core
*core
= ((struct cx8800_fh
*)fh
)->dev
->core
;
1455 if (!v4l2_chip_match_host(®
->match
))
1457 /* cx2388x has a 24-bit register space */
1458 reg
->val
= cx_read(reg
->reg
& 0xffffff);
1463 static int vidioc_s_register (struct file
*file
, void *fh
,
1464 struct v4l2_dbg_register
*reg
)
1466 struct cx88_core
*core
= ((struct cx8800_fh
*)fh
)->dev
->core
;
1468 if (!v4l2_chip_match_host(®
->match
))
1470 cx_write(reg
->reg
& 0xffffff, reg
->val
);
1475 /* ----------------------------------------------------------- */
1476 /* RADIO ESPECIFIC IOCTLS */
1477 /* ----------------------------------------------------------- */
1479 static int radio_querycap (struct file
*file
, void *priv
,
1480 struct v4l2_capability
*cap
)
1482 struct cx8800_dev
*dev
= ((struct cx8800_fh
*)priv
)->dev
;
1483 struct cx88_core
*core
= dev
->core
;
1485 strcpy(cap
->driver
, "cx8800");
1486 strlcpy(cap
->card
, core
->board
.name
, sizeof(cap
->card
));
1487 sprintf(cap
->bus_info
,"PCI:%s", pci_name(dev
->pci
));
1488 cap
->version
= CX88_VERSION_CODE
;
1489 cap
->capabilities
= V4L2_CAP_TUNER
;
1493 static int radio_g_tuner (struct file
*file
, void *priv
,
1494 struct v4l2_tuner
*t
)
1496 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1498 if (unlikely(t
->index
> 0))
1501 strcpy(t
->name
, "Radio");
1502 t
->type
= V4L2_TUNER_RADIO
;
1504 call_all(core
, tuner
, g_tuner
, t
);
1508 static int radio_enum_input (struct file
*file
, void *priv
,
1509 struct v4l2_input
*i
)
1513 strcpy(i
->name
,"Radio");
1514 i
->type
= V4L2_INPUT_TYPE_TUNER
;
1519 static int radio_g_audio (struct file
*file
, void *priv
, struct v4l2_audio
*a
)
1521 if (unlikely(a
->index
))
1524 strcpy(a
->name
,"Radio");
1528 /* FIXME: Should add a standard for radio */
1530 static int radio_s_tuner (struct file
*file
, void *priv
,
1531 struct v4l2_tuner
*t
)
1533 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1538 call_all(core
, tuner
, s_tuner
, t
);
1543 static int radio_s_audio (struct file
*file
, void *fh
,
1544 struct v4l2_audio
*a
)
1549 static int radio_s_input (struct file
*file
, void *fh
, unsigned int i
)
1554 static int radio_queryctrl (struct file
*file
, void *priv
,
1555 struct v4l2_queryctrl
*c
)
1559 if (c
->id
< V4L2_CID_BASE
||
1560 c
->id
>= V4L2_CID_LASTP1
)
1562 if (c
->id
== V4L2_CID_AUDIO_MUTE
||
1563 c
->id
== V4L2_CID_AUDIO_VOLUME
||
1564 c
->id
== V4L2_CID_AUDIO_BALANCE
) {
1565 for (i
= 0; i
< CX8800_CTLS
; i
++) {
1566 if (cx8800_ctls
[i
].v
.id
== c
->id
)
1569 if (i
== CX8800_CTLS
)
1571 *c
= cx8800_ctls
[i
].v
;
1577 /* ----------------------------------------------------------- */
1579 static void cx8800_vid_timeout(unsigned long data
)
1581 struct cx8800_dev
*dev
= (struct cx8800_dev
*)data
;
1582 struct cx88_core
*core
= dev
->core
;
1583 struct cx88_dmaqueue
*q
= &dev
->vidq
;
1584 struct cx88_buffer
*buf
;
1585 unsigned long flags
;
1587 cx88_sram_channel_dump(core
, &cx88_sram_channels
[SRAM_CH21
]);
1589 cx_clear(MO_VID_DMACNTRL
, 0x11);
1590 cx_clear(VID_CAPTURE_CONTROL
, 0x06);
1592 spin_lock_irqsave(&dev
->slock
,flags
);
1593 while (!list_empty(&q
->active
)) {
1594 buf
= list_entry(q
->active
.next
, struct cx88_buffer
, vb
.queue
);
1595 list_del(&buf
->vb
.queue
);
1596 buf
->vb
.state
= VIDEOBUF_ERROR
;
1597 wake_up(&buf
->vb
.done
);
1598 printk("%s/0: [%p/%d] timeout - dma=0x%08lx\n", core
->name
,
1599 buf
, buf
->vb
.i
, (unsigned long)buf
->risc
.dma
);
1601 restart_video_queue(dev
,q
);
1602 spin_unlock_irqrestore(&dev
->slock
,flags
);
1605 static const char *cx88_vid_irqs
[32] = {
1606 "y_risci1", "u_risci1", "v_risci1", "vbi_risc1",
1607 "y_risci2", "u_risci2", "v_risci2", "vbi_risc2",
1608 "y_oflow", "u_oflow", "v_oflow", "vbi_oflow",
1609 "y_sync", "u_sync", "v_sync", "vbi_sync",
1610 "opc_err", "par_err", "rip_err", "pci_abort",
1613 static void cx8800_vid_irq(struct cx8800_dev
*dev
)
1615 struct cx88_core
*core
= dev
->core
;
1616 u32 status
, mask
, count
;
1618 status
= cx_read(MO_VID_INTSTAT
);
1619 mask
= cx_read(MO_VID_INTMSK
);
1620 if (0 == (status
& mask
))
1622 cx_write(MO_VID_INTSTAT
, status
);
1623 if (irq_debug
|| (status
& mask
& ~0xff))
1624 cx88_print_irqbits(core
->name
, "irq vid",
1625 cx88_vid_irqs
, ARRAY_SIZE(cx88_vid_irqs
),
1628 /* risc op code error */
1629 if (status
& (1 << 16)) {
1630 printk(KERN_WARNING
"%s/0: video risc op code error\n",core
->name
);
1631 cx_clear(MO_VID_DMACNTRL
, 0x11);
1632 cx_clear(VID_CAPTURE_CONTROL
, 0x06);
1633 cx88_sram_channel_dump(core
, &cx88_sram_channels
[SRAM_CH21
]);
1637 if (status
& 0x01) {
1638 spin_lock(&dev
->slock
);
1639 count
= cx_read(MO_VIDY_GPCNT
);
1640 cx88_wakeup(core
, &dev
->vidq
, count
);
1641 spin_unlock(&dev
->slock
);
1645 if (status
& 0x08) {
1646 spin_lock(&dev
->slock
);
1647 count
= cx_read(MO_VBI_GPCNT
);
1648 cx88_wakeup(core
, &dev
->vbiq
, count
);
1649 spin_unlock(&dev
->slock
);
1653 if (status
& 0x10) {
1654 dprintk(2,"stopper video\n");
1655 spin_lock(&dev
->slock
);
1656 restart_video_queue(dev
,&dev
->vidq
);
1657 spin_unlock(&dev
->slock
);
1661 if (status
& 0x80) {
1662 dprintk(2,"stopper vbi\n");
1663 spin_lock(&dev
->slock
);
1664 cx8800_restart_vbi_queue(dev
,&dev
->vbiq
);
1665 spin_unlock(&dev
->slock
);
1669 static irqreturn_t
cx8800_irq(int irq
, void *dev_id
)
1671 struct cx8800_dev
*dev
= dev_id
;
1672 struct cx88_core
*core
= dev
->core
;
1674 int loop
, handled
= 0;
1676 for (loop
= 0; loop
< 10; loop
++) {
1677 status
= cx_read(MO_PCI_INTSTAT
) &
1678 (core
->pci_irqmask
| PCI_INT_VIDINT
);
1681 cx_write(MO_PCI_INTSTAT
, status
);
1684 if (status
& core
->pci_irqmask
)
1685 cx88_core_irq(core
,status
);
1686 if (status
& PCI_INT_VIDINT
)
1687 cx8800_vid_irq(dev
);
1690 printk(KERN_WARNING
"%s/0: irq loop -- clearing mask\n",
1692 cx_write(MO_PCI_INTMSK
,0);
1696 return IRQ_RETVAL(handled
);
1699 /* ----------------------------------------------------------- */
1700 /* exported stuff */
1702 static const struct v4l2_file_operations video_fops
=
1704 .owner
= THIS_MODULE
,
1706 .release
= video_release
,
1710 .ioctl
= video_ioctl2
,
1713 static const struct v4l2_ioctl_ops video_ioctl_ops
= {
1714 .vidioc_querycap
= vidioc_querycap
,
1715 .vidioc_enum_fmt_vid_cap
= vidioc_enum_fmt_vid_cap
,
1716 .vidioc_g_fmt_vid_cap
= vidioc_g_fmt_vid_cap
,
1717 .vidioc_try_fmt_vid_cap
= vidioc_try_fmt_vid_cap
,
1718 .vidioc_s_fmt_vid_cap
= vidioc_s_fmt_vid_cap
,
1719 .vidioc_g_fmt_vbi_cap
= cx8800_vbi_fmt
,
1720 .vidioc_try_fmt_vbi_cap
= cx8800_vbi_fmt
,
1721 .vidioc_s_fmt_vbi_cap
= cx8800_vbi_fmt
,
1722 .vidioc_reqbufs
= vidioc_reqbufs
,
1723 .vidioc_querybuf
= vidioc_querybuf
,
1724 .vidioc_qbuf
= vidioc_qbuf
,
1725 .vidioc_dqbuf
= vidioc_dqbuf
,
1726 .vidioc_s_std
= vidioc_s_std
,
1727 .vidioc_enum_input
= vidioc_enum_input
,
1728 .vidioc_g_input
= vidioc_g_input
,
1729 .vidioc_s_input
= vidioc_s_input
,
1730 .vidioc_queryctrl
= vidioc_queryctrl
,
1731 .vidioc_g_ctrl
= vidioc_g_ctrl
,
1732 .vidioc_s_ctrl
= vidioc_s_ctrl
,
1733 .vidioc_streamon
= vidioc_streamon
,
1734 .vidioc_streamoff
= vidioc_streamoff
,
1735 #ifdef CONFIG_VIDEO_V4L1_COMPAT
1736 .vidiocgmbuf
= vidiocgmbuf
,
1738 .vidioc_g_tuner
= vidioc_g_tuner
,
1739 .vidioc_s_tuner
= vidioc_s_tuner
,
1740 .vidioc_g_frequency
= vidioc_g_frequency
,
1741 .vidioc_s_frequency
= vidioc_s_frequency
,
1742 #ifdef CONFIG_VIDEO_ADV_DEBUG
1743 .vidioc_g_register
= vidioc_g_register
,
1744 .vidioc_s_register
= vidioc_s_register
,
1748 static struct video_device cx8800_vbi_template
;
1750 static const struct video_device cx8800_video_template
= {
1751 .name
= "cx8800-video",
1752 .fops
= &video_fops
,
1753 .ioctl_ops
= &video_ioctl_ops
,
1754 .tvnorms
= CX88_NORMS
,
1755 .current_norm
= V4L2_STD_NTSC_M
,
1758 static const struct v4l2_file_operations radio_fops
=
1760 .owner
= THIS_MODULE
,
1762 .release
= video_release
,
1763 .ioctl
= video_ioctl2
,
1766 static const struct v4l2_ioctl_ops radio_ioctl_ops
= {
1767 .vidioc_querycap
= radio_querycap
,
1768 .vidioc_g_tuner
= radio_g_tuner
,
1769 .vidioc_enum_input
= radio_enum_input
,
1770 .vidioc_g_audio
= radio_g_audio
,
1771 .vidioc_s_tuner
= radio_s_tuner
,
1772 .vidioc_s_audio
= radio_s_audio
,
1773 .vidioc_s_input
= radio_s_input
,
1774 .vidioc_queryctrl
= radio_queryctrl
,
1775 .vidioc_g_ctrl
= vidioc_g_ctrl
,
1776 .vidioc_s_ctrl
= vidioc_s_ctrl
,
1777 .vidioc_g_frequency
= vidioc_g_frequency
,
1778 .vidioc_s_frequency
= vidioc_s_frequency
,
1779 #ifdef CONFIG_VIDEO_ADV_DEBUG
1780 .vidioc_g_register
= vidioc_g_register
,
1781 .vidioc_s_register
= vidioc_s_register
,
1785 static const struct video_device cx8800_radio_template
= {
1786 .name
= "cx8800-radio",
1787 .fops
= &radio_fops
,
1788 .ioctl_ops
= &radio_ioctl_ops
,
1791 /* ----------------------------------------------------------- */
1793 static void cx8800_unregister_video(struct cx8800_dev
*dev
)
1795 if (dev
->radio_dev
) {
1796 if (video_is_registered(dev
->radio_dev
))
1797 video_unregister_device(dev
->radio_dev
);
1799 video_device_release(dev
->radio_dev
);
1800 dev
->radio_dev
= NULL
;
1803 if (video_is_registered(dev
->vbi_dev
))
1804 video_unregister_device(dev
->vbi_dev
);
1806 video_device_release(dev
->vbi_dev
);
1807 dev
->vbi_dev
= NULL
;
1809 if (dev
->video_dev
) {
1810 if (video_is_registered(dev
->video_dev
))
1811 video_unregister_device(dev
->video_dev
);
1813 video_device_release(dev
->video_dev
);
1814 dev
->video_dev
= NULL
;
1818 static int __devinit
cx8800_initdev(struct pci_dev
*pci_dev
,
1819 const struct pci_device_id
*pci_id
)
1821 struct cx8800_dev
*dev
;
1822 struct cx88_core
*core
;
1826 dev
= kzalloc(sizeof(*dev
),GFP_KERNEL
);
1832 if (pci_enable_device(pci_dev
)) {
1836 core
= cx88_core_get(dev
->pci
);
1843 /* print pci info */
1844 pci_read_config_byte(pci_dev
, PCI_CLASS_REVISION
, &dev
->pci_rev
);
1845 pci_read_config_byte(pci_dev
, PCI_LATENCY_TIMER
, &dev
->pci_lat
);
1846 printk(KERN_INFO
"%s/0: found at %s, rev: %d, irq: %d, "
1847 "latency: %d, mmio: 0x%llx\n", core
->name
,
1848 pci_name(pci_dev
), dev
->pci_rev
, pci_dev
->irq
,
1849 dev
->pci_lat
,(unsigned long long)pci_resource_start(pci_dev
,0));
1851 pci_set_master(pci_dev
);
1852 if (!pci_dma_supported(pci_dev
,DMA_BIT_MASK(32))) {
1853 printk("%s/0: Oops: no 32bit PCI DMA ???\n",core
->name
);
1858 /* Initialize VBI template */
1859 memcpy( &cx8800_vbi_template
, &cx8800_video_template
,
1860 sizeof(cx8800_vbi_template
) );
1861 strcpy(cx8800_vbi_template
.name
,"cx8800-vbi");
1863 /* initialize driver struct */
1864 spin_lock_init(&dev
->slock
);
1865 core
->tvnorm
= cx8800_video_template
.current_norm
;
1867 /* init video dma queues */
1868 INIT_LIST_HEAD(&dev
->vidq
.active
);
1869 INIT_LIST_HEAD(&dev
->vidq
.queued
);
1870 dev
->vidq
.timeout
.function
= cx8800_vid_timeout
;
1871 dev
->vidq
.timeout
.data
= (unsigned long)dev
;
1872 init_timer(&dev
->vidq
.timeout
);
1873 cx88_risc_stopper(dev
->pci
,&dev
->vidq
.stopper
,
1874 MO_VID_DMACNTRL
,0x11,0x00);
1876 /* init vbi dma queues */
1877 INIT_LIST_HEAD(&dev
->vbiq
.active
);
1878 INIT_LIST_HEAD(&dev
->vbiq
.queued
);
1879 dev
->vbiq
.timeout
.function
= cx8800_vbi_timeout
;
1880 dev
->vbiq
.timeout
.data
= (unsigned long)dev
;
1881 init_timer(&dev
->vbiq
.timeout
);
1882 cx88_risc_stopper(dev
->pci
,&dev
->vbiq
.stopper
,
1883 MO_VID_DMACNTRL
,0x88,0x00);
1886 err
= request_irq(pci_dev
->irq
, cx8800_irq
,
1887 IRQF_SHARED
| IRQF_DISABLED
, core
->name
, dev
);
1889 printk(KERN_ERR
"%s/0: can't get IRQ %d\n",
1890 core
->name
,pci_dev
->irq
);
1893 cx_set(MO_PCI_INTMSK
, core
->pci_irqmask
);
1895 /* load and configure helper modules */
1897 if (core
->board
.audio_chip
== V4L2_IDENT_WM8775
)
1898 v4l2_i2c_new_subdev(&core
->v4l2_dev
, &core
->i2c_adap
,
1899 NULL
, "wm8775", 0x36 >> 1, NULL
);
1901 if (core
->board
.audio_chip
== V4L2_IDENT_TVAUDIO
) {
1902 /* This probes for a tda9874 as is used on some
1903 Pixelview Ultra boards. */
1904 v4l2_i2c_new_subdev(&core
->v4l2_dev
,
1906 NULL
, "tvaudio", 0, I2C_ADDRS(0xb0 >> 1));
1909 switch (core
->boardnr
) {
1910 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD
:
1911 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD
: {
1912 static const struct i2c_board_info rtc_info
= {
1913 I2C_BOARD_INFO("isl1208", 0x6f)
1916 request_module("rtc-isl1208");
1917 core
->i2c_rtc
= i2c_new_device(&core
->i2c_adap
, &rtc_info
);
1919 /* break intentionally omitted */
1920 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO
:
1921 request_module("ir-kbd-i2c");
1924 /* register v4l devices */
1925 dev
->video_dev
= cx88_vdev_init(core
,dev
->pci
,
1926 &cx8800_video_template
,"video");
1927 video_set_drvdata(dev
->video_dev
, dev
);
1928 err
= video_register_device(dev
->video_dev
,VFL_TYPE_GRABBER
,
1929 video_nr
[core
->nr
]);
1931 printk(KERN_ERR
"%s/0: can't register video device\n",
1935 printk(KERN_INFO
"%s/0: registered device %s [v4l2]\n",
1936 core
->name
, video_device_node_name(dev
->video_dev
));
1938 dev
->vbi_dev
= cx88_vdev_init(core
,dev
->pci
,&cx8800_vbi_template
,"vbi");
1939 video_set_drvdata(dev
->vbi_dev
, dev
);
1940 err
= video_register_device(dev
->vbi_dev
,VFL_TYPE_VBI
,
1943 printk(KERN_ERR
"%s/0: can't register vbi device\n",
1947 printk(KERN_INFO
"%s/0: registered device %s\n",
1948 core
->name
, video_device_node_name(dev
->vbi_dev
));
1950 if (core
->board
.radio
.type
== CX88_RADIO
) {
1951 dev
->radio_dev
= cx88_vdev_init(core
,dev
->pci
,
1952 &cx8800_radio_template
,"radio");
1953 video_set_drvdata(dev
->radio_dev
, dev
);
1954 err
= video_register_device(dev
->radio_dev
,VFL_TYPE_RADIO
,
1955 radio_nr
[core
->nr
]);
1957 printk(KERN_ERR
"%s/0: can't register radio device\n",
1961 printk(KERN_INFO
"%s/0: registered device %s\n",
1962 core
->name
, video_device_node_name(dev
->radio_dev
));
1965 /* everything worked */
1966 pci_set_drvdata(pci_dev
,dev
);
1968 /* initial device configuration */
1969 mutex_lock(&core
->lock
);
1970 cx88_set_tvnorm(core
,core
->tvnorm
);
1971 init_controls(core
);
1972 cx88_video_mux(core
,0);
1973 mutex_unlock(&core
->lock
);
1975 /* start tvaudio thread */
1976 if (core
->board
.tuner_type
!= TUNER_ABSENT
) {
1977 core
->kthread
= kthread_run(cx88_audio_thread
, core
, "cx88 tvaudio");
1978 if (IS_ERR(core
->kthread
)) {
1979 err
= PTR_ERR(core
->kthread
);
1980 printk(KERN_ERR
"%s/0: failed to create cx88 audio thread, err=%d\n",
1987 cx8800_unregister_video(dev
);
1988 free_irq(pci_dev
->irq
, dev
);
1990 cx88_core_put(core
,dev
->pci
);
1996 static void __devexit
cx8800_finidev(struct pci_dev
*pci_dev
)
1998 struct cx8800_dev
*dev
= pci_get_drvdata(pci_dev
);
1999 struct cx88_core
*core
= dev
->core
;
2002 if (core
->kthread
) {
2003 kthread_stop(core
->kthread
);
2004 core
->kthread
= NULL
;
2010 cx88_shutdown(core
); /* FIXME */
2011 pci_disable_device(pci_dev
);
2013 /* unregister stuff */
2015 free_irq(pci_dev
->irq
, dev
);
2016 cx8800_unregister_video(dev
);
2017 pci_set_drvdata(pci_dev
, NULL
);
2020 btcx_riscmem_free(dev
->pci
,&dev
->vidq
.stopper
);
2021 cx88_core_put(core
,dev
->pci
);
2026 static int cx8800_suspend(struct pci_dev
*pci_dev
, pm_message_t state
)
2028 struct cx8800_dev
*dev
= pci_get_drvdata(pci_dev
);
2029 struct cx88_core
*core
= dev
->core
;
2031 /* stop video+vbi capture */
2032 spin_lock(&dev
->slock
);
2033 if (!list_empty(&dev
->vidq
.active
)) {
2034 printk("%s/0: suspend video\n", core
->name
);
2035 stop_video_dma(dev
);
2036 del_timer(&dev
->vidq
.timeout
);
2038 if (!list_empty(&dev
->vbiq
.active
)) {
2039 printk("%s/0: suspend vbi\n", core
->name
);
2040 cx8800_stop_vbi_dma(dev
);
2041 del_timer(&dev
->vbiq
.timeout
);
2043 spin_unlock(&dev
->slock
);
2047 /* FIXME -- shutdown device */
2048 cx88_shutdown(core
);
2050 pci_save_state(pci_dev
);
2051 if (0 != pci_set_power_state(pci_dev
, pci_choose_state(pci_dev
, state
))) {
2052 pci_disable_device(pci_dev
);
2053 dev
->state
.disabled
= 1;
2058 static int cx8800_resume(struct pci_dev
*pci_dev
)
2060 struct cx8800_dev
*dev
= pci_get_drvdata(pci_dev
);
2061 struct cx88_core
*core
= dev
->core
;
2064 if (dev
->state
.disabled
) {
2065 err
=pci_enable_device(pci_dev
);
2067 printk(KERN_ERR
"%s/0: can't enable device\n",
2072 dev
->state
.disabled
= 0;
2074 err
= pci_set_power_state(pci_dev
, PCI_D0
);
2076 printk(KERN_ERR
"%s/0: can't set power state\n", core
->name
);
2077 pci_disable_device(pci_dev
);
2078 dev
->state
.disabled
= 1;
2082 pci_restore_state(pci_dev
);
2084 /* FIXME: re-initialize hardware */
2087 cx88_ir_start(core
);
2089 cx_set(MO_PCI_INTMSK
, core
->pci_irqmask
);
2091 /* restart video+vbi capture */
2092 spin_lock(&dev
->slock
);
2093 if (!list_empty(&dev
->vidq
.active
)) {
2094 printk("%s/0: resume video\n", core
->name
);
2095 restart_video_queue(dev
,&dev
->vidq
);
2097 if (!list_empty(&dev
->vbiq
.active
)) {
2098 printk("%s/0: resume vbi\n", core
->name
);
2099 cx8800_restart_vbi_queue(dev
,&dev
->vbiq
);
2101 spin_unlock(&dev
->slock
);
2107 /* ----------------------------------------------------------- */
2109 static const struct pci_device_id cx8800_pci_tbl
[] = {
2113 .subvendor
= PCI_ANY_ID
,
2114 .subdevice
= PCI_ANY_ID
,
2116 /* --- end of list --- */
2119 MODULE_DEVICE_TABLE(pci
, cx8800_pci_tbl
);
2121 static struct pci_driver cx8800_pci_driver
= {
2123 .id_table
= cx8800_pci_tbl
,
2124 .probe
= cx8800_initdev
,
2125 .remove
= __devexit_p(cx8800_finidev
),
2127 .suspend
= cx8800_suspend
,
2128 .resume
= cx8800_resume
,
2132 static int __init
cx8800_init(void)
2134 printk(KERN_INFO
"cx88/0: cx2388x v4l2 driver version %d.%d.%d loaded\n",
2135 (CX88_VERSION_CODE
>> 16) & 0xff,
2136 (CX88_VERSION_CODE
>> 8) & 0xff,
2137 CX88_VERSION_CODE
& 0xff);
2139 printk(KERN_INFO
"cx2388x: snapshot date %04d-%02d-%02d\n",
2140 SNAPSHOT
/10000, (SNAPSHOT
/100)%100, SNAPSHOT
%100);
2142 return pci_register_driver(&cx8800_pci_driver
);
2145 static void __exit
cx8800_fini(void)
2147 pci_unregister_driver(&cx8800_pci_driver
);
2150 module_init(cx8800_init
);
2151 module_exit(cx8800_fini
);
2153 /* ----------------------------------------------------------- */
2158 * 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