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/interrupt.h>
35 #include <linux/dma-mapping.h>
36 #include <linux/delay.h>
37 #include <linux/kthread.h>
38 #include <asm/div64.h>
41 #include <media/v4l2-common.h>
42 #include <media/v4l2-ioctl.h>
44 MODULE_DESCRIPTION("v4l2 driver module for cx2388x based TV cards");
45 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
46 MODULE_LICENSE("GPL");
48 /* ------------------------------------------------------------------ */
50 static unsigned int video_nr
[] = {[0 ... (CX88_MAXBOARDS
- 1)] = UNSET
};
51 static unsigned int vbi_nr
[] = {[0 ... (CX88_MAXBOARDS
- 1)] = UNSET
};
52 static unsigned int radio_nr
[] = {[0 ... (CX88_MAXBOARDS
- 1)] = UNSET
};
54 module_param_array(video_nr
, int, NULL
, 0444);
55 module_param_array(vbi_nr
, int, NULL
, 0444);
56 module_param_array(radio_nr
, int, NULL
, 0444);
58 MODULE_PARM_DESC(video_nr
,"video device numbers");
59 MODULE_PARM_DESC(vbi_nr
,"vbi device numbers");
60 MODULE_PARM_DESC(radio_nr
,"radio device numbers");
62 static unsigned int video_debug
;
63 module_param(video_debug
,int,0644);
64 MODULE_PARM_DESC(video_debug
,"enable debug messages [video]");
66 static unsigned int irq_debug
;
67 module_param(irq_debug
,int,0644);
68 MODULE_PARM_DESC(irq_debug
,"enable debug messages [IRQ handler]");
70 static unsigned int vid_limit
= 16;
71 module_param(vid_limit
,int,0644);
72 MODULE_PARM_DESC(vid_limit
,"capture memory limit in megabytes");
74 #define dprintk(level,fmt, arg...) if (video_debug >= level) \
75 printk(KERN_DEBUG "%s/0: " fmt, core->name , ## arg)
77 /* ------------------------------------------------------------------ */
79 static LIST_HEAD(cx8800_devlist
);
81 /* ------------------------------------------------------------------- */
84 static struct cx8800_fmt formats
[] = {
86 .name
= "8 bpp, gray",
87 .fourcc
= V4L2_PIX_FMT_GREY
,
88 .cxformat
= ColorFormatY8
,
90 .flags
= FORMAT_FLAGS_PACKED
,
92 .name
= "15 bpp RGB, le",
93 .fourcc
= V4L2_PIX_FMT_RGB555
,
94 .cxformat
= ColorFormatRGB15
,
96 .flags
= FORMAT_FLAGS_PACKED
,
98 .name
= "15 bpp RGB, be",
99 .fourcc
= V4L2_PIX_FMT_RGB555X
,
100 .cxformat
= ColorFormatRGB15
| ColorFormatBSWAP
,
102 .flags
= FORMAT_FLAGS_PACKED
,
104 .name
= "16 bpp RGB, le",
105 .fourcc
= V4L2_PIX_FMT_RGB565
,
106 .cxformat
= ColorFormatRGB16
,
108 .flags
= FORMAT_FLAGS_PACKED
,
110 .name
= "16 bpp RGB, be",
111 .fourcc
= V4L2_PIX_FMT_RGB565X
,
112 .cxformat
= ColorFormatRGB16
| ColorFormatBSWAP
,
114 .flags
= FORMAT_FLAGS_PACKED
,
116 .name
= "24 bpp RGB, le",
117 .fourcc
= V4L2_PIX_FMT_BGR24
,
118 .cxformat
= ColorFormatRGB24
,
120 .flags
= FORMAT_FLAGS_PACKED
,
122 .name
= "32 bpp RGB, le",
123 .fourcc
= V4L2_PIX_FMT_BGR32
,
124 .cxformat
= ColorFormatRGB32
,
126 .flags
= FORMAT_FLAGS_PACKED
,
128 .name
= "32 bpp RGB, be",
129 .fourcc
= V4L2_PIX_FMT_RGB32
,
130 .cxformat
= ColorFormatRGB32
| ColorFormatBSWAP
| ColorFormatWSWAP
,
132 .flags
= FORMAT_FLAGS_PACKED
,
134 .name
= "4:2:2, packed, YUYV",
135 .fourcc
= V4L2_PIX_FMT_YUYV
,
136 .cxformat
= ColorFormatYUY2
,
138 .flags
= FORMAT_FLAGS_PACKED
,
140 .name
= "4:2:2, packed, UYVY",
141 .fourcc
= V4L2_PIX_FMT_UYVY
,
142 .cxformat
= ColorFormatYUY2
| ColorFormatBSWAP
,
144 .flags
= FORMAT_FLAGS_PACKED
,
148 static struct cx8800_fmt
* format_by_fourcc(unsigned int fourcc
)
152 for (i
= 0; i
< ARRAY_SIZE(formats
); i
++)
153 if (formats
[i
].fourcc
== fourcc
)
158 /* ------------------------------------------------------------------- */
160 static const struct v4l2_queryctrl no_ctl
= {
162 .flags
= V4L2_CTRL_FLAG_DISABLED
,
165 static struct cx88_ctrl cx8800_ctls
[] = {
169 .id
= V4L2_CID_BRIGHTNESS
,
170 .name
= "Brightness",
174 .default_value
= 0x7f,
175 .type
= V4L2_CTRL_TYPE_INTEGER
,
178 .reg
= MO_CONTR_BRIGHT
,
183 .id
= V4L2_CID_CONTRAST
,
188 .default_value
= 0x3f,
189 .type
= V4L2_CTRL_TYPE_INTEGER
,
192 .reg
= MO_CONTR_BRIGHT
,
202 .default_value
= 0x7f,
203 .type
= V4L2_CTRL_TYPE_INTEGER
,
210 /* strictly, this only describes only U saturation.
211 * V saturation is handled specially through code.
214 .id
= V4L2_CID_SATURATION
,
215 .name
= "Saturation",
219 .default_value
= 0x7f,
220 .type
= V4L2_CTRL_TYPE_INTEGER
,
223 .reg
= MO_UV_SATURATION
,
228 .id
= V4L2_CID_CHROMA_AGC
,
229 .name
= "Chroma AGC",
232 .default_value
= 0x1,
233 .type
= V4L2_CTRL_TYPE_BOOLEAN
,
235 .reg
= MO_INPUT_FORMAT
,
240 .id
= V4L2_CID_COLOR_KILLER
,
241 .name
= "Color killer",
244 .default_value
= 0x1,
245 .type
= V4L2_CTRL_TYPE_BOOLEAN
,
247 .reg
= MO_INPUT_FORMAT
,
253 .id
= V4L2_CID_AUDIO_MUTE
,
258 .type
= V4L2_CTRL_TYPE_BOOLEAN
,
261 .sreg
= SHADOW_AUD_VOL_CTL
,
266 .id
= V4L2_CID_AUDIO_VOLUME
,
271 .default_value
= 0x3f,
272 .type
= V4L2_CTRL_TYPE_INTEGER
,
275 .sreg
= SHADOW_AUD_VOL_CTL
,
280 .id
= V4L2_CID_AUDIO_BALANCE
,
285 .default_value
= 0x40,
286 .type
= V4L2_CTRL_TYPE_INTEGER
,
289 .sreg
= SHADOW_AUD_BAL_CTL
,
294 static const int CX8800_CTLS
= ARRAY_SIZE(cx8800_ctls
);
296 /* Must be sorted from low to high control ID! */
297 const u32 cx88_user_ctrls
[] = {
303 V4L2_CID_AUDIO_VOLUME
,
304 V4L2_CID_AUDIO_BALANCE
,
307 V4L2_CID_COLOR_KILLER
,
310 EXPORT_SYMBOL(cx88_user_ctrls
);
312 static const u32
*ctrl_classes
[] = {
317 int cx8800_ctrl_query(struct cx88_core
*core
, struct v4l2_queryctrl
*qctrl
)
321 if (qctrl
->id
< V4L2_CID_BASE
||
322 qctrl
->id
>= V4L2_CID_LASTP1
)
324 for (i
= 0; i
< CX8800_CTLS
; i
++)
325 if (cx8800_ctls
[i
].v
.id
== qctrl
->id
)
327 if (i
== CX8800_CTLS
) {
331 *qctrl
= cx8800_ctls
[i
].v
;
332 /* Report chroma AGC as inactive when SECAM is selected */
333 if (cx8800_ctls
[i
].v
.id
== V4L2_CID_CHROMA_AGC
&&
334 core
->tvnorm
& V4L2_STD_SECAM
)
335 qctrl
->flags
|= V4L2_CTRL_FLAG_INACTIVE
;
339 EXPORT_SYMBOL(cx8800_ctrl_query
);
341 /* ------------------------------------------------------------------- */
342 /* resource management */
344 static int res_get(struct cx8800_dev
*dev
, struct cx8800_fh
*fh
, unsigned int bit
)
346 struct cx88_core
*core
= dev
->core
;
347 if (fh
->resources
& bit
)
348 /* have it already allocated */
352 mutex_lock(&core
->lock
);
353 if (dev
->resources
& bit
) {
354 /* no, someone else uses it */
355 mutex_unlock(&core
->lock
);
358 /* it's free, grab it */
359 fh
->resources
|= bit
;
360 dev
->resources
|= bit
;
361 dprintk(1,"res: get %d\n",bit
);
362 mutex_unlock(&core
->lock
);
367 int res_check(struct cx8800_fh
*fh
, unsigned int bit
)
369 return (fh
->resources
& bit
);
373 int res_locked(struct cx8800_dev
*dev
, unsigned int bit
)
375 return (dev
->resources
& bit
);
379 void res_free(struct cx8800_dev
*dev
, struct cx8800_fh
*fh
, unsigned int bits
)
381 struct cx88_core
*core
= dev
->core
;
382 BUG_ON((fh
->resources
& bits
) != bits
);
384 mutex_lock(&core
->lock
);
385 fh
->resources
&= ~bits
;
386 dev
->resources
&= ~bits
;
387 dprintk(1,"res: put %d\n",bits
);
388 mutex_unlock(&core
->lock
);
391 /* ------------------------------------------------------------------ */
393 int cx88_video_mux(struct cx88_core
*core
, unsigned int input
)
395 /* struct cx88_core *core = dev->core; */
397 dprintk(1,"video_mux: %d [vmux=%d,gpio=0x%x,0x%x,0x%x,0x%x]\n",
398 input
, INPUT(input
).vmux
,
399 INPUT(input
).gpio0
,INPUT(input
).gpio1
,
400 INPUT(input
).gpio2
,INPUT(input
).gpio3
);
402 cx_andor(MO_INPUT_FORMAT
, 0x03 << 14, INPUT(input
).vmux
<< 14);
403 cx_write(MO_GP3_IO
, INPUT(input
).gpio3
);
404 cx_write(MO_GP0_IO
, INPUT(input
).gpio0
);
405 cx_write(MO_GP1_IO
, INPUT(input
).gpio1
);
406 cx_write(MO_GP2_IO
, INPUT(input
).gpio2
);
408 switch (INPUT(input
).type
) {
409 case CX88_VMUX_SVIDEO
:
410 cx_set(MO_AFECFG_IO
, 0x00000001);
411 cx_set(MO_INPUT_FORMAT
, 0x00010010);
412 cx_set(MO_FILTER_EVEN
, 0x00002020);
413 cx_set(MO_FILTER_ODD
, 0x00002020);
416 cx_clear(MO_AFECFG_IO
, 0x00000001);
417 cx_clear(MO_INPUT_FORMAT
, 0x00010010);
418 cx_clear(MO_FILTER_EVEN
, 0x00002020);
419 cx_clear(MO_FILTER_ODD
, 0x00002020);
423 /* if there are audioroutes defined, we have an external
424 ADC to deal with audio */
425 if (INPUT(input
).audioroute
) {
426 /* The wm8775 module has the "2" route hardwired into
427 the initialization. Some boards may use different
428 routes for different inputs. HVR-1300 surely does */
429 if (core
->board
.audio_chip
&&
430 core
->board
.audio_chip
== V4L2_IDENT_WM8775
) {
431 struct v4l2_routing route
;
433 route
.input
= INPUT(input
).audioroute
;
434 call_all(core
, audio
, s_routing
, &route
);
436 /* cx2388's C-ADC is connected to the tuner only.
437 When used with S-Video, that ADC is busy dealing with
438 chroma, so an external must be used for baseband audio */
439 if (INPUT(input
).type
!= CX88_VMUX_TELEVISION
) {
441 core
->tvaudio
= WW_I2SADC
;
442 cx88_set_tvaudio(core
);
445 cx_write(AUD_I2SCNTL
, 0x0);
446 cx_clear(AUD_CTL
, EN_I2SIN_ENABLE
);
452 EXPORT_SYMBOL(cx88_video_mux
);
454 /* ------------------------------------------------------------------ */
456 static int start_video_dma(struct cx8800_dev
*dev
,
457 struct cx88_dmaqueue
*q
,
458 struct cx88_buffer
*buf
)
460 struct cx88_core
*core
= dev
->core
;
462 /* setup fifo + format */
463 cx88_sram_channel_setup(core
, &cx88_sram_channels
[SRAM_CH21
],
464 buf
->bpl
, buf
->risc
.dma
);
465 cx88_set_scale(core
, buf
->vb
.width
, buf
->vb
.height
, buf
->vb
.field
);
466 cx_write(MO_COLOR_CTRL
, buf
->fmt
->cxformat
| ColorFormatGamma
);
469 cx_write(MO_VIDY_GPCNTRL
,GP_COUNT_CONTROL_RESET
);
473 cx_set(MO_PCI_INTMSK
, core
->pci_irqmask
| PCI_INT_VIDINT
);
475 /* Enables corresponding bits at PCI_INT_STAT:
476 bits 0 to 4: video, audio, transport stream, VIP, Host
478 bits 8 and 9: DMA complete for: SRC, DST
479 bits 10 and 11: BERR signal asserted for RISC: RD, WR
480 bits 12 to 15: BERR signal asserted for: BRDG, SRC, DST, IPB
482 cx_set(MO_VID_INTMSK
, 0x0f0011);
485 cx_set(VID_CAPTURE_CONTROL
,0x06);
488 cx_set(MO_DEV_CNTRL2
, (1<<5));
489 cx_set(MO_VID_DMACNTRL
, 0x11); /* Planar Y and packed FIFO and RISC enable */
495 static int stop_video_dma(struct cx8800_dev
*dev
)
497 struct cx88_core
*core
= dev
->core
;
500 cx_clear(MO_VID_DMACNTRL
, 0x11);
502 /* disable capture */
503 cx_clear(VID_CAPTURE_CONTROL
,0x06);
506 cx_clear(MO_PCI_INTMSK
, PCI_INT_VIDINT
);
507 cx_clear(MO_VID_INTMSK
, 0x0f0011);
512 static int restart_video_queue(struct cx8800_dev
*dev
,
513 struct cx88_dmaqueue
*q
)
515 struct cx88_core
*core
= dev
->core
;
516 struct cx88_buffer
*buf
, *prev
;
518 if (!list_empty(&q
->active
)) {
519 buf
= list_entry(q
->active
.next
, struct cx88_buffer
, vb
.queue
);
520 dprintk(2,"restart_queue [%p/%d]: restart dma\n",
522 start_video_dma(dev
, q
, buf
);
523 list_for_each_entry(buf
, &q
->active
, vb
.queue
)
524 buf
->count
= q
->count
++;
525 mod_timer(&q
->timeout
, jiffies
+BUFFER_TIMEOUT
);
531 if (list_empty(&q
->queued
))
533 buf
= list_entry(q
->queued
.next
, struct cx88_buffer
, vb
.queue
);
535 list_move_tail(&buf
->vb
.queue
, &q
->active
);
536 start_video_dma(dev
, q
, buf
);
537 buf
->vb
.state
= VIDEOBUF_ACTIVE
;
538 buf
->count
= q
->count
++;
539 mod_timer(&q
->timeout
, jiffies
+BUFFER_TIMEOUT
);
540 dprintk(2,"[%p/%d] restart_queue - first active\n",
543 } else if (prev
->vb
.width
== buf
->vb
.width
&&
544 prev
->vb
.height
== buf
->vb
.height
&&
545 prev
->fmt
== buf
->fmt
) {
546 list_move_tail(&buf
->vb
.queue
, &q
->active
);
547 buf
->vb
.state
= VIDEOBUF_ACTIVE
;
548 buf
->count
= q
->count
++;
549 prev
->risc
.jmp
[1] = cpu_to_le32(buf
->risc
.dma
);
550 dprintk(2,"[%p/%d] restart_queue - move to active\n",
559 /* ------------------------------------------------------------------ */
562 buffer_setup(struct videobuf_queue
*q
, unsigned int *count
, unsigned int *size
)
564 struct cx8800_fh
*fh
= q
->priv_data
;
566 *size
= fh
->fmt
->depth
*fh
->width
*fh
->height
>> 3;
569 while (*size
* *count
> vid_limit
* 1024 * 1024)
575 buffer_prepare(struct videobuf_queue
*q
, struct videobuf_buffer
*vb
,
576 enum v4l2_field field
)
578 struct cx8800_fh
*fh
= q
->priv_data
;
579 struct cx8800_dev
*dev
= fh
->dev
;
580 struct cx88_core
*core
= dev
->core
;
581 struct cx88_buffer
*buf
= container_of(vb
,struct cx88_buffer
,vb
);
582 struct videobuf_dmabuf
*dma
=videobuf_to_dma(&buf
->vb
);
583 int rc
, init_buffer
= 0;
585 BUG_ON(NULL
== fh
->fmt
);
586 if (fh
->width
< 48 || fh
->width
> norm_maxw(core
->tvnorm
) ||
587 fh
->height
< 32 || fh
->height
> norm_maxh(core
->tvnorm
))
589 buf
->vb
.size
= (fh
->width
* fh
->height
* fh
->fmt
->depth
) >> 3;
590 if (0 != buf
->vb
.baddr
&& buf
->vb
.bsize
< buf
->vb
.size
)
593 if (buf
->fmt
!= fh
->fmt
||
594 buf
->vb
.width
!= fh
->width
||
595 buf
->vb
.height
!= fh
->height
||
596 buf
->vb
.field
!= field
) {
598 buf
->vb
.width
= fh
->width
;
599 buf
->vb
.height
= fh
->height
;
600 buf
->vb
.field
= field
;
604 if (VIDEOBUF_NEEDS_INIT
== buf
->vb
.state
) {
606 if (0 != (rc
= videobuf_iolock(q
,&buf
->vb
,NULL
)))
611 buf
->bpl
= buf
->vb
.width
* buf
->fmt
->depth
>> 3;
612 switch (buf
->vb
.field
) {
614 cx88_risc_buffer(dev
->pci
, &buf
->risc
,
615 dma
->sglist
, 0, UNSET
,
616 buf
->bpl
, 0, buf
->vb
.height
);
618 case V4L2_FIELD_BOTTOM
:
619 cx88_risc_buffer(dev
->pci
, &buf
->risc
,
620 dma
->sglist
, UNSET
, 0,
621 buf
->bpl
, 0, buf
->vb
.height
);
623 case V4L2_FIELD_INTERLACED
:
624 cx88_risc_buffer(dev
->pci
, &buf
->risc
,
625 dma
->sglist
, 0, buf
->bpl
,
627 buf
->vb
.height
>> 1);
629 case V4L2_FIELD_SEQ_TB
:
630 cx88_risc_buffer(dev
->pci
, &buf
->risc
,
632 0, buf
->bpl
* (buf
->vb
.height
>> 1),
634 buf
->vb
.height
>> 1);
636 case V4L2_FIELD_SEQ_BT
:
637 cx88_risc_buffer(dev
->pci
, &buf
->risc
,
639 buf
->bpl
* (buf
->vb
.height
>> 1), 0,
641 buf
->vb
.height
>> 1);
647 dprintk(2,"[%p/%d] buffer_prepare - %dx%d %dbpp \"%s\" - dma=0x%08lx\n",
649 fh
->width
, fh
->height
, fh
->fmt
->depth
, fh
->fmt
->name
,
650 (unsigned long)buf
->risc
.dma
);
652 buf
->vb
.state
= VIDEOBUF_PREPARED
;
656 cx88_free_buffer(q
,buf
);
661 buffer_queue(struct videobuf_queue
*vq
, struct videobuf_buffer
*vb
)
663 struct cx88_buffer
*buf
= container_of(vb
,struct cx88_buffer
,vb
);
664 struct cx88_buffer
*prev
;
665 struct cx8800_fh
*fh
= vq
->priv_data
;
666 struct cx8800_dev
*dev
= fh
->dev
;
667 struct cx88_core
*core
= dev
->core
;
668 struct cx88_dmaqueue
*q
= &dev
->vidq
;
670 /* add jump to stopper */
671 buf
->risc
.jmp
[0] = cpu_to_le32(RISC_JUMP
| RISC_IRQ1
| RISC_CNT_INC
);
672 buf
->risc
.jmp
[1] = cpu_to_le32(q
->stopper
.dma
);
674 if (!list_empty(&q
->queued
)) {
675 list_add_tail(&buf
->vb
.queue
,&q
->queued
);
676 buf
->vb
.state
= VIDEOBUF_QUEUED
;
677 dprintk(2,"[%p/%d] buffer_queue - append to queued\n",
680 } else if (list_empty(&q
->active
)) {
681 list_add_tail(&buf
->vb
.queue
,&q
->active
);
682 start_video_dma(dev
, q
, buf
);
683 buf
->vb
.state
= VIDEOBUF_ACTIVE
;
684 buf
->count
= q
->count
++;
685 mod_timer(&q
->timeout
, jiffies
+BUFFER_TIMEOUT
);
686 dprintk(2,"[%p/%d] buffer_queue - first active\n",
690 prev
= list_entry(q
->active
.prev
, struct cx88_buffer
, vb
.queue
);
691 if (prev
->vb
.width
== buf
->vb
.width
&&
692 prev
->vb
.height
== buf
->vb
.height
&&
693 prev
->fmt
== buf
->fmt
) {
694 list_add_tail(&buf
->vb
.queue
,&q
->active
);
695 buf
->vb
.state
= VIDEOBUF_ACTIVE
;
696 buf
->count
= q
->count
++;
697 prev
->risc
.jmp
[1] = cpu_to_le32(buf
->risc
.dma
);
698 dprintk(2,"[%p/%d] buffer_queue - append to active\n",
702 list_add_tail(&buf
->vb
.queue
,&q
->queued
);
703 buf
->vb
.state
= VIDEOBUF_QUEUED
;
704 dprintk(2,"[%p/%d] buffer_queue - first queued\n",
710 static void buffer_release(struct videobuf_queue
*q
, struct videobuf_buffer
*vb
)
712 struct cx88_buffer
*buf
= container_of(vb
,struct cx88_buffer
,vb
);
714 cx88_free_buffer(q
,buf
);
717 static struct videobuf_queue_ops cx8800_video_qops
= {
718 .buf_setup
= buffer_setup
,
719 .buf_prepare
= buffer_prepare
,
720 .buf_queue
= buffer_queue
,
721 .buf_release
= buffer_release
,
724 /* ------------------------------------------------------------------ */
727 /* ------------------------------------------------------------------ */
729 static struct videobuf_queue
* get_queue(struct cx8800_fh
*fh
)
732 case V4L2_BUF_TYPE_VIDEO_CAPTURE
:
734 case V4L2_BUF_TYPE_VBI_CAPTURE
:
742 static int get_ressource(struct cx8800_fh
*fh
)
745 case V4L2_BUF_TYPE_VIDEO_CAPTURE
:
746 return RESOURCE_VIDEO
;
747 case V4L2_BUF_TYPE_VBI_CAPTURE
:
755 static int video_open(struct file
*file
)
757 int minor
= video_devdata(file
)->minor
;
758 struct cx8800_dev
*h
,*dev
= NULL
;
759 struct cx88_core
*core
;
760 struct cx8800_fh
*fh
;
761 enum v4l2_buf_type type
= 0;
765 list_for_each_entry(h
, &cx8800_devlist
, devlist
) {
766 if (h
->video_dev
->minor
== minor
) {
768 type
= V4L2_BUF_TYPE_VIDEO_CAPTURE
;
770 if (h
->vbi_dev
->minor
== minor
) {
772 type
= V4L2_BUF_TYPE_VBI_CAPTURE
;
775 h
->radio_dev
->minor
== minor
) {
787 dprintk(1,"open minor=%d radio=%d type=%s\n",
788 minor
,radio
,v4l2_type_names
[type
]);
790 /* allocate + initialize per filehandle data */
791 fh
= kzalloc(sizeof(*fh
),GFP_KERNEL
);
796 file
->private_data
= fh
;
802 fh
->fmt
= format_by_fourcc(V4L2_PIX_FMT_BGR24
);
804 videobuf_queue_sg_init(&fh
->vidq
, &cx8800_video_qops
,
805 &dev
->pci
->dev
, &dev
->slock
,
806 V4L2_BUF_TYPE_VIDEO_CAPTURE
,
807 V4L2_FIELD_INTERLACED
,
808 sizeof(struct cx88_buffer
),
810 videobuf_queue_sg_init(&fh
->vbiq
, &cx8800_vbi_qops
,
811 &dev
->pci
->dev
, &dev
->slock
,
812 V4L2_BUF_TYPE_VBI_CAPTURE
,
814 sizeof(struct cx88_buffer
),
818 dprintk(1,"video_open: setting radio device\n");
819 cx_write(MO_GP3_IO
, core
->board
.radio
.gpio3
);
820 cx_write(MO_GP0_IO
, core
->board
.radio
.gpio0
);
821 cx_write(MO_GP1_IO
, core
->board
.radio
.gpio1
);
822 cx_write(MO_GP2_IO
, core
->board
.radio
.gpio2
);
823 if (core
->board
.radio
.audioroute
) {
824 if(core
->board
.audio_chip
&&
825 core
->board
.audio_chip
== V4L2_IDENT_WM8775
) {
826 struct v4l2_routing route
;
828 route
.input
= core
->board
.radio
.audioroute
;
829 call_all(core
, audio
, s_routing
, &route
);
832 core
->tvaudio
= WW_I2SADC
;
833 cx88_set_tvaudio(core
);
836 core
->tvaudio
= WW_FM
;
837 cx88_set_tvaudio(core
);
838 cx88_set_stereo(core
,V4L2_TUNER_MODE_STEREO
,1);
840 call_all(core
, tuner
, s_radio
);
844 atomic_inc(&core
->users
);
850 video_read(struct file
*file
, char __user
*data
, size_t count
, loff_t
*ppos
)
852 struct cx8800_fh
*fh
= file
->private_data
;
855 case V4L2_BUF_TYPE_VIDEO_CAPTURE
:
856 if (res_locked(fh
->dev
,RESOURCE_VIDEO
))
858 return videobuf_read_one(&fh
->vidq
, data
, count
, ppos
,
859 file
->f_flags
& O_NONBLOCK
);
860 case V4L2_BUF_TYPE_VBI_CAPTURE
:
861 if (!res_get(fh
->dev
,fh
,RESOURCE_VBI
))
863 return videobuf_read_stream(&fh
->vbiq
, data
, count
, ppos
, 1,
864 file
->f_flags
& O_NONBLOCK
);
872 video_poll(struct file
*file
, struct poll_table_struct
*wait
)
874 struct cx8800_fh
*fh
= file
->private_data
;
875 struct cx88_buffer
*buf
;
877 if (V4L2_BUF_TYPE_VBI_CAPTURE
== fh
->type
) {
878 if (!res_get(fh
->dev
,fh
,RESOURCE_VBI
))
880 return videobuf_poll_stream(file
, &fh
->vbiq
, wait
);
883 if (res_check(fh
,RESOURCE_VIDEO
)) {
884 /* streaming capture */
885 if (list_empty(&fh
->vidq
.stream
))
887 buf
= list_entry(fh
->vidq
.stream
.next
,struct cx88_buffer
,vb
.stream
);
890 buf
= (struct cx88_buffer
*)fh
->vidq
.read_buf
;
894 poll_wait(file
, &buf
->vb
.done
, wait
);
895 if (buf
->vb
.state
== VIDEOBUF_DONE
||
896 buf
->vb
.state
== VIDEOBUF_ERROR
)
897 return POLLIN
|POLLRDNORM
;
901 static int video_release(struct file
*file
)
903 struct cx8800_fh
*fh
= file
->private_data
;
904 struct cx8800_dev
*dev
= fh
->dev
;
906 /* turn off overlay */
907 if (res_check(fh
, RESOURCE_OVERLAY
)) {
909 res_free(dev
,fh
,RESOURCE_OVERLAY
);
912 /* stop video capture */
913 if (res_check(fh
, RESOURCE_VIDEO
)) {
914 videobuf_queue_cancel(&fh
->vidq
);
915 res_free(dev
,fh
,RESOURCE_VIDEO
);
917 if (fh
->vidq
.read_buf
) {
918 buffer_release(&fh
->vidq
,fh
->vidq
.read_buf
);
919 kfree(fh
->vidq
.read_buf
);
922 /* stop vbi capture */
923 if (res_check(fh
, RESOURCE_VBI
)) {
924 videobuf_stop(&fh
->vbiq
);
925 res_free(dev
,fh
,RESOURCE_VBI
);
928 videobuf_mmap_free(&fh
->vidq
);
929 videobuf_mmap_free(&fh
->vbiq
);
930 file
->private_data
= NULL
;
933 if(atomic_dec_and_test(&dev
->core
->users
))
934 call_all(dev
->core
, core
, s_standby
, 0);
940 video_mmap(struct file
*file
, struct vm_area_struct
* vma
)
942 struct cx8800_fh
*fh
= file
->private_data
;
944 return videobuf_mmap_mapper(get_queue(fh
), vma
);
947 /* ------------------------------------------------------------------ */
948 /* VIDEO CTRL IOCTLS */
950 int cx88_get_control (struct cx88_core
*core
, struct v4l2_control
*ctl
)
952 struct cx88_ctrl
*c
= NULL
;
956 for (i
= 0; i
< CX8800_CTLS
; i
++)
957 if (cx8800_ctls
[i
].v
.id
== ctl
->id
)
959 if (unlikely(NULL
== c
))
962 value
= c
->sreg
? cx_sread(c
->sreg
) : cx_read(c
->reg
);
964 case V4L2_CID_AUDIO_BALANCE
:
965 ctl
->value
= ((value
& 0x7f) < 0x40) ? ((value
& 0x7f) + 0x40)
966 : (0x7f - (value
& 0x7f));
968 case V4L2_CID_AUDIO_VOLUME
:
969 ctl
->value
= 0x3f - (value
& 0x3f);
972 ctl
->value
= ((value
+ (c
->off
<< c
->shift
)) & c
->mask
) >> c
->shift
;
975 dprintk(1,"get_control id=0x%X(%s) ctrl=0x%02x, reg=0x%02x val=0x%02x (mask 0x%02x)%s\n",
976 ctl
->id
, c
->v
.name
, ctl
->value
, c
->reg
,
977 value
,c
->mask
, c
->sreg
? " [shadowed]" : "");
980 EXPORT_SYMBOL(cx88_get_control
);
982 int cx88_set_control(struct cx88_core
*core
, struct v4l2_control
*ctl
)
984 struct cx88_ctrl
*c
= NULL
;
988 for (i
= 0; i
< CX8800_CTLS
; i
++) {
989 if (cx8800_ctls
[i
].v
.id
== ctl
->id
) {
993 if (unlikely(NULL
== c
))
996 if (ctl
->value
< c
->v
.minimum
)
997 ctl
->value
= c
->v
.minimum
;
998 if (ctl
->value
> c
->v
.maximum
)
999 ctl
->value
= c
->v
.maximum
;
1002 case V4L2_CID_AUDIO_BALANCE
:
1003 value
= (ctl
->value
< 0x40) ? (0x7f - ctl
->value
) : (ctl
->value
- 0x40);
1005 case V4L2_CID_AUDIO_VOLUME
:
1006 value
= 0x3f - (ctl
->value
& 0x3f);
1008 case V4L2_CID_SATURATION
:
1009 /* special v_sat handling */
1011 value
= ((ctl
->value
- c
->off
) << c
->shift
) & c
->mask
;
1013 if (core
->tvnorm
& V4L2_STD_SECAM
) {
1014 /* For SECAM, both U and V sat should be equal */
1015 value
=value
<<8|value
;
1017 /* Keeps U Saturation proportional to V Sat */
1018 value
=(value
*0x5a)/0x7f<<8|value
;
1022 case V4L2_CID_CHROMA_AGC
:
1023 /* Do not allow chroma AGC to be enabled for SECAM */
1024 value
= ((ctl
->value
- c
->off
) << c
->shift
) & c
->mask
;
1025 if (core
->tvnorm
& V4L2_STD_SECAM
&& value
)
1029 value
= ((ctl
->value
- c
->off
) << c
->shift
) & c
->mask
;
1032 dprintk(1,"set_control id=0x%X(%s) ctrl=0x%02x, reg=0x%02x val=0x%02x (mask 0x%02x)%s\n",
1033 ctl
->id
, c
->v
.name
, ctl
->value
, c
->reg
, value
,
1034 mask
, c
->sreg
? " [shadowed]" : "");
1036 cx_sandor(c
->sreg
, c
->reg
, mask
, value
);
1038 cx_andor(c
->reg
, mask
, value
);
1042 EXPORT_SYMBOL(cx88_set_control
);
1044 static void init_controls(struct cx88_core
*core
)
1046 struct v4l2_control ctrl
;
1049 for (i
= 0; i
< CX8800_CTLS
; i
++) {
1050 ctrl
.id
=cx8800_ctls
[i
].v
.id
;
1051 ctrl
.value
=cx8800_ctls
[i
].v
.default_value
;
1053 cx88_set_control(core
, &ctrl
);
1057 /* ------------------------------------------------------------------ */
1060 static int vidioc_g_fmt_vid_cap(struct file
*file
, void *priv
,
1061 struct v4l2_format
*f
)
1063 struct cx8800_fh
*fh
= priv
;
1065 f
->fmt
.pix
.width
= fh
->width
;
1066 f
->fmt
.pix
.height
= fh
->height
;
1067 f
->fmt
.pix
.field
= fh
->vidq
.field
;
1068 f
->fmt
.pix
.pixelformat
= fh
->fmt
->fourcc
;
1069 f
->fmt
.pix
.bytesperline
=
1070 (f
->fmt
.pix
.width
* fh
->fmt
->depth
) >> 3;
1071 f
->fmt
.pix
.sizeimage
=
1072 f
->fmt
.pix
.height
* f
->fmt
.pix
.bytesperline
;
1076 static int vidioc_try_fmt_vid_cap(struct file
*file
, void *priv
,
1077 struct v4l2_format
*f
)
1079 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1080 struct cx8800_fmt
*fmt
;
1081 enum v4l2_field field
;
1082 unsigned int maxw
, maxh
;
1084 fmt
= format_by_fourcc(f
->fmt
.pix
.pixelformat
);
1088 field
= f
->fmt
.pix
.field
;
1089 maxw
= norm_maxw(core
->tvnorm
);
1090 maxh
= norm_maxh(core
->tvnorm
);
1092 if (V4L2_FIELD_ANY
== field
) {
1093 field
= (f
->fmt
.pix
.height
> maxh
/2)
1094 ? V4L2_FIELD_INTERLACED
1095 : V4L2_FIELD_BOTTOM
;
1099 case V4L2_FIELD_TOP
:
1100 case V4L2_FIELD_BOTTOM
:
1103 case V4L2_FIELD_INTERLACED
:
1109 f
->fmt
.pix
.field
= field
;
1110 if (f
->fmt
.pix
.height
< 32)
1111 f
->fmt
.pix
.height
= 32;
1112 if (f
->fmt
.pix
.height
> maxh
)
1113 f
->fmt
.pix
.height
= maxh
;
1114 if (f
->fmt
.pix
.width
< 48)
1115 f
->fmt
.pix
.width
= 48;
1116 if (f
->fmt
.pix
.width
> maxw
)
1117 f
->fmt
.pix
.width
= maxw
;
1118 f
->fmt
.pix
.width
&= ~0x03;
1119 f
->fmt
.pix
.bytesperline
=
1120 (f
->fmt
.pix
.width
* fmt
->depth
) >> 3;
1121 f
->fmt
.pix
.sizeimage
=
1122 f
->fmt
.pix
.height
* f
->fmt
.pix
.bytesperline
;
1127 static int vidioc_s_fmt_vid_cap(struct file
*file
, void *priv
,
1128 struct v4l2_format
*f
)
1130 struct cx8800_fh
*fh
= priv
;
1131 int err
= vidioc_try_fmt_vid_cap (file
,priv
,f
);
1135 fh
->fmt
= format_by_fourcc(f
->fmt
.pix
.pixelformat
);
1136 fh
->width
= f
->fmt
.pix
.width
;
1137 fh
->height
= f
->fmt
.pix
.height
;
1138 fh
->vidq
.field
= f
->fmt
.pix
.field
;
1142 static int vidioc_querycap (struct file
*file
, void *priv
,
1143 struct v4l2_capability
*cap
)
1145 struct cx8800_dev
*dev
= ((struct cx8800_fh
*)priv
)->dev
;
1146 struct cx88_core
*core
= dev
->core
;
1148 strcpy(cap
->driver
, "cx8800");
1149 strlcpy(cap
->card
, core
->board
.name
, sizeof(cap
->card
));
1150 sprintf(cap
->bus_info
,"PCI:%s",pci_name(dev
->pci
));
1151 cap
->version
= CX88_VERSION_CODE
;
1153 V4L2_CAP_VIDEO_CAPTURE
|
1154 V4L2_CAP_READWRITE
|
1155 V4L2_CAP_STREAMING
|
1156 V4L2_CAP_VBI_CAPTURE
;
1157 if (UNSET
!= core
->board
.tuner_type
)
1158 cap
->capabilities
|= V4L2_CAP_TUNER
;
1162 static int vidioc_enum_fmt_vid_cap (struct file
*file
, void *priv
,
1163 struct v4l2_fmtdesc
*f
)
1165 if (unlikely(f
->index
>= ARRAY_SIZE(formats
)))
1168 strlcpy(f
->description
,formats
[f
->index
].name
,sizeof(f
->description
));
1169 f
->pixelformat
= formats
[f
->index
].fourcc
;
1174 #ifdef CONFIG_VIDEO_V4L1_COMPAT
1175 static int vidiocgmbuf (struct file
*file
, void *priv
, struct video_mbuf
*mbuf
)
1177 struct cx8800_fh
*fh
= priv
;
1179 return videobuf_cgmbuf (get_queue(fh
), mbuf
, 8);
1183 static int vidioc_reqbufs (struct file
*file
, void *priv
, struct v4l2_requestbuffers
*p
)
1185 struct cx8800_fh
*fh
= priv
;
1186 return (videobuf_reqbufs(get_queue(fh
), p
));
1189 static int vidioc_querybuf (struct file
*file
, void *priv
, struct v4l2_buffer
*p
)
1191 struct cx8800_fh
*fh
= priv
;
1192 return (videobuf_querybuf(get_queue(fh
), p
));
1195 static int vidioc_qbuf (struct file
*file
, void *priv
, struct v4l2_buffer
*p
)
1197 struct cx8800_fh
*fh
= priv
;
1198 return (videobuf_qbuf(get_queue(fh
), p
));
1201 static int vidioc_dqbuf (struct file
*file
, void *priv
, struct v4l2_buffer
*p
)
1203 struct cx8800_fh
*fh
= priv
;
1204 return (videobuf_dqbuf(get_queue(fh
), p
,
1205 file
->f_flags
& O_NONBLOCK
));
1208 static int vidioc_streamon(struct file
*file
, void *priv
, enum v4l2_buf_type i
)
1210 struct cx8800_fh
*fh
= priv
;
1211 struct cx8800_dev
*dev
= fh
->dev
;
1213 /* We should remember that this driver also supports teletext, */
1214 /* so we have to test if the v4l2_buf_type is VBI capture data. */
1215 if (unlikely((fh
->type
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
) &&
1216 (fh
->type
!= V4L2_BUF_TYPE_VBI_CAPTURE
)))
1219 if (unlikely(i
!= fh
->type
))
1222 if (unlikely(!res_get(dev
,fh
,get_ressource(fh
))))
1224 return videobuf_streamon(get_queue(fh
));
1227 static int vidioc_streamoff(struct file
*file
, void *priv
, enum v4l2_buf_type i
)
1229 struct cx8800_fh
*fh
= priv
;
1230 struct cx8800_dev
*dev
= fh
->dev
;
1233 if ((fh
->type
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
) &&
1234 (fh
->type
!= V4L2_BUF_TYPE_VBI_CAPTURE
))
1240 res
= get_ressource(fh
);
1241 err
= videobuf_streamoff(get_queue(fh
));
1244 res_free(dev
,fh
,res
);
1248 static int vidioc_s_std (struct file
*file
, void *priv
, v4l2_std_id
*tvnorms
)
1250 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1252 mutex_lock(&core
->lock
);
1253 cx88_set_tvnorm(core
,*tvnorms
);
1254 mutex_unlock(&core
->lock
);
1259 /* only one input in this sample driver */
1260 int cx88_enum_input (struct cx88_core
*core
,struct v4l2_input
*i
)
1262 static const char *iname
[] = {
1263 [ CX88_VMUX_COMPOSITE1
] = "Composite1",
1264 [ CX88_VMUX_COMPOSITE2
] = "Composite2",
1265 [ CX88_VMUX_COMPOSITE3
] = "Composite3",
1266 [ CX88_VMUX_COMPOSITE4
] = "Composite4",
1267 [ CX88_VMUX_SVIDEO
] = "S-Video",
1268 [ CX88_VMUX_TELEVISION
] = "Television",
1269 [ CX88_VMUX_CABLE
] = "Cable TV",
1270 [ CX88_VMUX_DVB
] = "DVB",
1271 [ CX88_VMUX_DEBUG
] = "for debug only",
1273 unsigned int n
= i
->index
;
1277 if (0 == INPUT(n
).type
)
1279 i
->type
= V4L2_INPUT_TYPE_CAMERA
;
1280 strcpy(i
->name
,iname
[INPUT(n
).type
]);
1281 if ((CX88_VMUX_TELEVISION
== INPUT(n
).type
) ||
1282 (CX88_VMUX_CABLE
== INPUT(n
).type
))
1283 i
->type
= V4L2_INPUT_TYPE_TUNER
;
1284 i
->std
= CX88_NORMS
;
1287 EXPORT_SYMBOL(cx88_enum_input
);
1289 static int vidioc_enum_input (struct file
*file
, void *priv
,
1290 struct v4l2_input
*i
)
1292 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1293 return cx88_enum_input (core
,i
);
1296 static int vidioc_g_input (struct file
*file
, void *priv
, unsigned int *i
)
1298 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1304 static int vidioc_s_input (struct file
*file
, void *priv
, unsigned int i
)
1306 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1311 mutex_lock(&core
->lock
);
1312 cx88_newstation(core
);
1313 cx88_video_mux(core
,i
);
1314 mutex_unlock(&core
->lock
);
1320 static int vidioc_queryctrl (struct file
*file
, void *priv
,
1321 struct v4l2_queryctrl
*qctrl
)
1323 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1325 qctrl
->id
= v4l2_ctrl_next(ctrl_classes
, qctrl
->id
);
1326 if (unlikely(qctrl
->id
== 0))
1328 return cx8800_ctrl_query(core
, qctrl
);
1331 static int vidioc_g_ctrl (struct file
*file
, void *priv
,
1332 struct v4l2_control
*ctl
)
1334 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1336 cx88_get_control(core
,ctl
);
1339 static int vidioc_s_ctrl (struct file
*file
, void *priv
,
1340 struct v4l2_control
*ctl
)
1342 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1344 cx88_set_control(core
,ctl
);
1347 static int vidioc_g_tuner (struct file
*file
, void *priv
,
1348 struct v4l2_tuner
*t
)
1350 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1353 if (unlikely(UNSET
== core
->board
.tuner_type
))
1358 strcpy(t
->name
, "Television");
1359 t
->type
= V4L2_TUNER_ANALOG_TV
;
1360 t
->capability
= V4L2_TUNER_CAP_NORM
;
1361 t
->rangehigh
= 0xffffffffUL
;
1363 cx88_get_stereo(core
,t
);
1364 reg
= cx_read(MO_DEVICE_STATUS
);
1365 t
->signal
= (reg
& (1<<5)) ? 0xffff : 0x0000;
1369 static int vidioc_s_tuner (struct file
*file
, void *priv
,
1370 struct v4l2_tuner
*t
)
1372 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1374 if (UNSET
== core
->board
.tuner_type
)
1379 cx88_set_stereo(core
, t
->audmode
, 1);
1383 static int vidioc_g_frequency (struct file
*file
, void *priv
,
1384 struct v4l2_frequency
*f
)
1386 struct cx8800_fh
*fh
= priv
;
1387 struct cx88_core
*core
= fh
->dev
->core
;
1389 if (unlikely(UNSET
== core
->board
.tuner_type
))
1392 /* f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; */
1393 f
->type
= fh
->radio
? V4L2_TUNER_RADIO
: V4L2_TUNER_ANALOG_TV
;
1394 f
->frequency
= core
->freq
;
1396 call_all(core
, tuner
, g_frequency
, f
);
1401 int cx88_set_freq (struct cx88_core
*core
,
1402 struct v4l2_frequency
*f
)
1404 if (unlikely(UNSET
== core
->board
.tuner_type
))
1406 if (unlikely(f
->tuner
!= 0))
1409 mutex_lock(&core
->lock
);
1410 core
->freq
= f
->frequency
;
1411 cx88_newstation(core
);
1412 call_all(core
, tuner
, s_frequency
, f
);
1414 /* When changing channels it is required to reset TVAUDIO */
1416 cx88_set_tvaudio(core
);
1418 mutex_unlock(&core
->lock
);
1422 EXPORT_SYMBOL(cx88_set_freq
);
1424 static int vidioc_s_frequency (struct file
*file
, void *priv
,
1425 struct v4l2_frequency
*f
)
1427 struct cx8800_fh
*fh
= priv
;
1428 struct cx88_core
*core
= fh
->dev
->core
;
1430 if (unlikely(0 == fh
->radio
&& f
->type
!= V4L2_TUNER_ANALOG_TV
))
1432 if (unlikely(1 == fh
->radio
&& f
->type
!= V4L2_TUNER_RADIO
))
1436 cx88_set_freq (core
,f
);
1439 #ifdef CONFIG_VIDEO_ADV_DEBUG
1440 static int vidioc_g_register (struct file
*file
, void *fh
,
1441 struct v4l2_dbg_register
*reg
)
1443 struct cx88_core
*core
= ((struct cx8800_fh
*)fh
)->dev
->core
;
1445 if (!v4l2_chip_match_host(®
->match
))
1447 /* cx2388x has a 24-bit register space */
1448 reg
->val
= cx_read(reg
->reg
& 0xffffff);
1453 static int vidioc_s_register (struct file
*file
, void *fh
,
1454 struct v4l2_dbg_register
*reg
)
1456 struct cx88_core
*core
= ((struct cx8800_fh
*)fh
)->dev
->core
;
1458 if (!v4l2_chip_match_host(®
->match
))
1460 cx_write(reg
->reg
& 0xffffff, reg
->val
);
1465 /* ----------------------------------------------------------- */
1466 /* RADIO ESPECIFIC IOCTLS */
1467 /* ----------------------------------------------------------- */
1469 static int radio_querycap (struct file
*file
, void *priv
,
1470 struct v4l2_capability
*cap
)
1472 struct cx8800_dev
*dev
= ((struct cx8800_fh
*)priv
)->dev
;
1473 struct cx88_core
*core
= dev
->core
;
1475 strcpy(cap
->driver
, "cx8800");
1476 strlcpy(cap
->card
, core
->board
.name
, sizeof(cap
->card
));
1477 sprintf(cap
->bus_info
,"PCI:%s", pci_name(dev
->pci
));
1478 cap
->version
= CX88_VERSION_CODE
;
1479 cap
->capabilities
= V4L2_CAP_TUNER
;
1483 static int radio_g_tuner (struct file
*file
, void *priv
,
1484 struct v4l2_tuner
*t
)
1486 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1488 if (unlikely(t
->index
> 0))
1491 strcpy(t
->name
, "Radio");
1492 t
->type
= V4L2_TUNER_RADIO
;
1494 call_all(core
, tuner
, g_tuner
, t
);
1498 static int radio_enum_input (struct file
*file
, void *priv
,
1499 struct v4l2_input
*i
)
1503 strcpy(i
->name
,"Radio");
1504 i
->type
= V4L2_INPUT_TYPE_TUNER
;
1509 static int radio_g_audio (struct file
*file
, void *priv
, struct v4l2_audio
*a
)
1511 if (unlikely(a
->index
))
1514 strcpy(a
->name
,"Radio");
1518 /* FIXME: Should add a standard for radio */
1520 static int radio_s_tuner (struct file
*file
, void *priv
,
1521 struct v4l2_tuner
*t
)
1523 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1528 call_all(core
, tuner
, s_tuner
, t
);
1533 static int radio_s_audio (struct file
*file
, void *fh
,
1534 struct v4l2_audio
*a
)
1539 static int radio_s_input (struct file
*file
, void *fh
, unsigned int i
)
1544 static int radio_queryctrl (struct file
*file
, void *priv
,
1545 struct v4l2_queryctrl
*c
)
1549 if (c
->id
< V4L2_CID_BASE
||
1550 c
->id
>= V4L2_CID_LASTP1
)
1552 if (c
->id
== V4L2_CID_AUDIO_MUTE
) {
1553 for (i
= 0; i
< CX8800_CTLS
; i
++)
1554 if (cx8800_ctls
[i
].v
.id
== c
->id
)
1556 *c
= cx8800_ctls
[i
].v
;
1562 /* ----------------------------------------------------------- */
1564 static void cx8800_vid_timeout(unsigned long data
)
1566 struct cx8800_dev
*dev
= (struct cx8800_dev
*)data
;
1567 struct cx88_core
*core
= dev
->core
;
1568 struct cx88_dmaqueue
*q
= &dev
->vidq
;
1569 struct cx88_buffer
*buf
;
1570 unsigned long flags
;
1572 cx88_sram_channel_dump(core
, &cx88_sram_channels
[SRAM_CH21
]);
1574 cx_clear(MO_VID_DMACNTRL
, 0x11);
1575 cx_clear(VID_CAPTURE_CONTROL
, 0x06);
1577 spin_lock_irqsave(&dev
->slock
,flags
);
1578 while (!list_empty(&q
->active
)) {
1579 buf
= list_entry(q
->active
.next
, struct cx88_buffer
, vb
.queue
);
1580 list_del(&buf
->vb
.queue
);
1581 buf
->vb
.state
= VIDEOBUF_ERROR
;
1582 wake_up(&buf
->vb
.done
);
1583 printk("%s/0: [%p/%d] timeout - dma=0x%08lx\n", core
->name
,
1584 buf
, buf
->vb
.i
, (unsigned long)buf
->risc
.dma
);
1586 restart_video_queue(dev
,q
);
1587 spin_unlock_irqrestore(&dev
->slock
,flags
);
1590 static char *cx88_vid_irqs
[32] = {
1591 "y_risci1", "u_risci1", "v_risci1", "vbi_risc1",
1592 "y_risci2", "u_risci2", "v_risci2", "vbi_risc2",
1593 "y_oflow", "u_oflow", "v_oflow", "vbi_oflow",
1594 "y_sync", "u_sync", "v_sync", "vbi_sync",
1595 "opc_err", "par_err", "rip_err", "pci_abort",
1598 static void cx8800_vid_irq(struct cx8800_dev
*dev
)
1600 struct cx88_core
*core
= dev
->core
;
1601 u32 status
, mask
, count
;
1603 status
= cx_read(MO_VID_INTSTAT
);
1604 mask
= cx_read(MO_VID_INTMSK
);
1605 if (0 == (status
& mask
))
1607 cx_write(MO_VID_INTSTAT
, status
);
1608 if (irq_debug
|| (status
& mask
& ~0xff))
1609 cx88_print_irqbits(core
->name
, "irq vid",
1610 cx88_vid_irqs
, ARRAY_SIZE(cx88_vid_irqs
),
1613 /* risc op code error */
1614 if (status
& (1 << 16)) {
1615 printk(KERN_WARNING
"%s/0: video risc op code error\n",core
->name
);
1616 cx_clear(MO_VID_DMACNTRL
, 0x11);
1617 cx_clear(VID_CAPTURE_CONTROL
, 0x06);
1618 cx88_sram_channel_dump(core
, &cx88_sram_channels
[SRAM_CH21
]);
1622 if (status
& 0x01) {
1623 spin_lock(&dev
->slock
);
1624 count
= cx_read(MO_VIDY_GPCNT
);
1625 cx88_wakeup(core
, &dev
->vidq
, count
);
1626 spin_unlock(&dev
->slock
);
1630 if (status
& 0x08) {
1631 spin_lock(&dev
->slock
);
1632 count
= cx_read(MO_VBI_GPCNT
);
1633 cx88_wakeup(core
, &dev
->vbiq
, count
);
1634 spin_unlock(&dev
->slock
);
1638 if (status
& 0x10) {
1639 dprintk(2,"stopper video\n");
1640 spin_lock(&dev
->slock
);
1641 restart_video_queue(dev
,&dev
->vidq
);
1642 spin_unlock(&dev
->slock
);
1646 if (status
& 0x80) {
1647 dprintk(2,"stopper vbi\n");
1648 spin_lock(&dev
->slock
);
1649 cx8800_restart_vbi_queue(dev
,&dev
->vbiq
);
1650 spin_unlock(&dev
->slock
);
1654 static irqreturn_t
cx8800_irq(int irq
, void *dev_id
)
1656 struct cx8800_dev
*dev
= dev_id
;
1657 struct cx88_core
*core
= dev
->core
;
1659 int loop
, handled
= 0;
1661 for (loop
= 0; loop
< 10; loop
++) {
1662 status
= cx_read(MO_PCI_INTSTAT
) &
1663 (core
->pci_irqmask
| PCI_INT_VIDINT
);
1666 cx_write(MO_PCI_INTSTAT
, status
);
1669 if (status
& core
->pci_irqmask
)
1670 cx88_core_irq(core
,status
);
1671 if (status
& PCI_INT_VIDINT
)
1672 cx8800_vid_irq(dev
);
1675 printk(KERN_WARNING
"%s/0: irq loop -- clearing mask\n",
1677 cx_write(MO_PCI_INTMSK
,0);
1681 return IRQ_RETVAL(handled
);
1684 /* ----------------------------------------------------------- */
1685 /* exported stuff */
1687 static const struct v4l2_file_operations video_fops
=
1689 .owner
= THIS_MODULE
,
1691 .release
= video_release
,
1695 .ioctl
= video_ioctl2
,
1698 static const struct v4l2_ioctl_ops video_ioctl_ops
= {
1699 .vidioc_querycap
= vidioc_querycap
,
1700 .vidioc_enum_fmt_vid_cap
= vidioc_enum_fmt_vid_cap
,
1701 .vidioc_g_fmt_vid_cap
= vidioc_g_fmt_vid_cap
,
1702 .vidioc_try_fmt_vid_cap
= vidioc_try_fmt_vid_cap
,
1703 .vidioc_s_fmt_vid_cap
= vidioc_s_fmt_vid_cap
,
1704 .vidioc_g_fmt_vbi_cap
= cx8800_vbi_fmt
,
1705 .vidioc_try_fmt_vbi_cap
= cx8800_vbi_fmt
,
1706 .vidioc_s_fmt_vbi_cap
= cx8800_vbi_fmt
,
1707 .vidioc_reqbufs
= vidioc_reqbufs
,
1708 .vidioc_querybuf
= vidioc_querybuf
,
1709 .vidioc_qbuf
= vidioc_qbuf
,
1710 .vidioc_dqbuf
= vidioc_dqbuf
,
1711 .vidioc_s_std
= vidioc_s_std
,
1712 .vidioc_enum_input
= vidioc_enum_input
,
1713 .vidioc_g_input
= vidioc_g_input
,
1714 .vidioc_s_input
= vidioc_s_input
,
1715 .vidioc_queryctrl
= vidioc_queryctrl
,
1716 .vidioc_g_ctrl
= vidioc_g_ctrl
,
1717 .vidioc_s_ctrl
= vidioc_s_ctrl
,
1718 .vidioc_streamon
= vidioc_streamon
,
1719 .vidioc_streamoff
= vidioc_streamoff
,
1720 #ifdef CONFIG_VIDEO_V4L1_COMPAT
1721 .vidiocgmbuf
= vidiocgmbuf
,
1723 .vidioc_g_tuner
= vidioc_g_tuner
,
1724 .vidioc_s_tuner
= vidioc_s_tuner
,
1725 .vidioc_g_frequency
= vidioc_g_frequency
,
1726 .vidioc_s_frequency
= vidioc_s_frequency
,
1727 #ifdef CONFIG_VIDEO_ADV_DEBUG
1728 .vidioc_g_register
= vidioc_g_register
,
1729 .vidioc_s_register
= vidioc_s_register
,
1733 static struct video_device cx8800_vbi_template
;
1735 static struct video_device cx8800_video_template
= {
1736 .name
= "cx8800-video",
1737 .fops
= &video_fops
,
1739 .ioctl_ops
= &video_ioctl_ops
,
1740 .tvnorms
= CX88_NORMS
,
1741 .current_norm
= V4L2_STD_NTSC_M
,
1744 static const struct v4l2_file_operations radio_fops
=
1746 .owner
= THIS_MODULE
,
1748 .release
= video_release
,
1749 .ioctl
= video_ioctl2
,
1752 static const struct v4l2_ioctl_ops radio_ioctl_ops
= {
1753 .vidioc_querycap
= radio_querycap
,
1754 .vidioc_g_tuner
= radio_g_tuner
,
1755 .vidioc_enum_input
= radio_enum_input
,
1756 .vidioc_g_audio
= radio_g_audio
,
1757 .vidioc_s_tuner
= radio_s_tuner
,
1758 .vidioc_s_audio
= radio_s_audio
,
1759 .vidioc_s_input
= radio_s_input
,
1760 .vidioc_queryctrl
= radio_queryctrl
,
1761 .vidioc_g_ctrl
= vidioc_g_ctrl
,
1762 .vidioc_s_ctrl
= vidioc_s_ctrl
,
1763 .vidioc_g_frequency
= vidioc_g_frequency
,
1764 .vidioc_s_frequency
= vidioc_s_frequency
,
1765 #ifdef CONFIG_VIDEO_ADV_DEBUG
1766 .vidioc_g_register
= vidioc_g_register
,
1767 .vidioc_s_register
= vidioc_s_register
,
1771 static struct video_device cx8800_radio_template
= {
1772 .name
= "cx8800-radio",
1773 .fops
= &radio_fops
,
1775 .ioctl_ops
= &radio_ioctl_ops
,
1778 /* ----------------------------------------------------------- */
1780 static void cx8800_unregister_video(struct cx8800_dev
*dev
)
1782 if (dev
->radio_dev
) {
1783 if (-1 != dev
->radio_dev
->minor
)
1784 video_unregister_device(dev
->radio_dev
);
1786 video_device_release(dev
->radio_dev
);
1787 dev
->radio_dev
= NULL
;
1790 if (-1 != dev
->vbi_dev
->minor
)
1791 video_unregister_device(dev
->vbi_dev
);
1793 video_device_release(dev
->vbi_dev
);
1794 dev
->vbi_dev
= NULL
;
1796 if (dev
->video_dev
) {
1797 if (-1 != dev
->video_dev
->minor
)
1798 video_unregister_device(dev
->video_dev
);
1800 video_device_release(dev
->video_dev
);
1801 dev
->video_dev
= NULL
;
1805 static int __devinit
cx8800_initdev(struct pci_dev
*pci_dev
,
1806 const struct pci_device_id
*pci_id
)
1808 struct cx8800_dev
*dev
;
1809 struct cx88_core
*core
;
1813 dev
= kzalloc(sizeof(*dev
),GFP_KERNEL
);
1819 if (pci_enable_device(pci_dev
)) {
1823 core
= cx88_core_get(dev
->pci
);
1830 /* print pci info */
1831 pci_read_config_byte(pci_dev
, PCI_CLASS_REVISION
, &dev
->pci_rev
);
1832 pci_read_config_byte(pci_dev
, PCI_LATENCY_TIMER
, &dev
->pci_lat
);
1833 printk(KERN_INFO
"%s/0: found at %s, rev: %d, irq: %d, "
1834 "latency: %d, mmio: 0x%llx\n", core
->name
,
1835 pci_name(pci_dev
), dev
->pci_rev
, pci_dev
->irq
,
1836 dev
->pci_lat
,(unsigned long long)pci_resource_start(pci_dev
,0));
1838 pci_set_master(pci_dev
);
1839 if (!pci_dma_supported(pci_dev
,DMA_32BIT_MASK
)) {
1840 printk("%s/0: Oops: no 32bit PCI DMA ???\n",core
->name
);
1845 /* Initialize VBI template */
1846 memcpy( &cx8800_vbi_template
, &cx8800_video_template
,
1847 sizeof(cx8800_vbi_template
) );
1848 strcpy(cx8800_vbi_template
.name
,"cx8800-vbi");
1850 /* initialize driver struct */
1851 spin_lock_init(&dev
->slock
);
1852 core
->tvnorm
= cx8800_video_template
.current_norm
;
1854 /* init video dma queues */
1855 INIT_LIST_HEAD(&dev
->vidq
.active
);
1856 INIT_LIST_HEAD(&dev
->vidq
.queued
);
1857 dev
->vidq
.timeout
.function
= cx8800_vid_timeout
;
1858 dev
->vidq
.timeout
.data
= (unsigned long)dev
;
1859 init_timer(&dev
->vidq
.timeout
);
1860 cx88_risc_stopper(dev
->pci
,&dev
->vidq
.stopper
,
1861 MO_VID_DMACNTRL
,0x11,0x00);
1863 /* init vbi dma queues */
1864 INIT_LIST_HEAD(&dev
->vbiq
.active
);
1865 INIT_LIST_HEAD(&dev
->vbiq
.queued
);
1866 dev
->vbiq
.timeout
.function
= cx8800_vbi_timeout
;
1867 dev
->vbiq
.timeout
.data
= (unsigned long)dev
;
1868 init_timer(&dev
->vbiq
.timeout
);
1869 cx88_risc_stopper(dev
->pci
,&dev
->vbiq
.stopper
,
1870 MO_VID_DMACNTRL
,0x88,0x00);
1873 err
= request_irq(pci_dev
->irq
, cx8800_irq
,
1874 IRQF_SHARED
| IRQF_DISABLED
, core
->name
, dev
);
1876 printk(KERN_ERR
"%s/0: can't get IRQ %d\n",
1877 core
->name
,pci_dev
->irq
);
1880 cx_set(MO_PCI_INTMSK
, core
->pci_irqmask
);
1882 /* load and configure helper modules */
1884 if (core
->board
.audio_chip
== V4L2_IDENT_WM8775
)
1885 v4l2_i2c_new_subdev(&core
->i2c_adap
,
1886 "wm8775", "wm8775", 0x36 >> 1);
1888 if (core
->board
.audio_chip
== V4L2_IDENT_TVAUDIO
) {
1889 /* This probes for a tda9874 as is used on some
1890 Pixelview Ultra boards. */
1891 static const unsigned short i2c_addr
[] = {
1892 0xb0 >> 1, I2C_CLIENT_END
1895 v4l2_i2c_new_probed_subdev(&core
->i2c_adap
,
1896 "tvaudio", "tvaudio", i2c_addr
);
1899 switch (core
->boardnr
) {
1900 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD
:
1901 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD
: {
1902 static struct i2c_board_info rtc_info
= {
1903 I2C_BOARD_INFO("isl1208", 0x6f)
1906 request_module("rtc-isl1208");
1907 core
->i2c_rtc
= i2c_new_device(&core
->i2c_adap
, &rtc_info
);
1909 /* break intentionally omitted */
1910 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO
:
1911 request_module("ir-kbd-i2c");
1914 /* register v4l devices */
1915 dev
->video_dev
= cx88_vdev_init(core
,dev
->pci
,
1916 &cx8800_video_template
,"video");
1917 err
= video_register_device(dev
->video_dev
,VFL_TYPE_GRABBER
,
1918 video_nr
[core
->nr
]);
1920 printk(KERN_ERR
"%s/0: can't register video device\n",
1924 printk(KERN_INFO
"%s/0: registered device video%d [v4l2]\n",
1925 core
->name
, dev
->video_dev
->num
);
1927 dev
->vbi_dev
= cx88_vdev_init(core
,dev
->pci
,&cx8800_vbi_template
,"vbi");
1928 err
= video_register_device(dev
->vbi_dev
,VFL_TYPE_VBI
,
1931 printk(KERN_ERR
"%s/0: can't register vbi device\n",
1935 printk(KERN_INFO
"%s/0: registered device vbi%d\n",
1936 core
->name
, dev
->vbi_dev
->num
);
1938 if (core
->board
.radio
.type
== CX88_RADIO
) {
1939 dev
->radio_dev
= cx88_vdev_init(core
,dev
->pci
,
1940 &cx8800_radio_template
,"radio");
1941 err
= video_register_device(dev
->radio_dev
,VFL_TYPE_RADIO
,
1942 radio_nr
[core
->nr
]);
1944 printk(KERN_ERR
"%s/0: can't register radio device\n",
1948 printk(KERN_INFO
"%s/0: registered device radio%d\n",
1949 core
->name
, dev
->radio_dev
->num
);
1952 /* everything worked */
1953 list_add_tail(&dev
->devlist
,&cx8800_devlist
);
1954 pci_set_drvdata(pci_dev
,dev
);
1956 /* initial device configuration */
1957 mutex_lock(&core
->lock
);
1958 cx88_set_tvnorm(core
,core
->tvnorm
);
1959 init_controls(core
);
1960 cx88_video_mux(core
,0);
1961 mutex_unlock(&core
->lock
);
1963 /* start tvaudio thread */
1964 if (core
->board
.tuner_type
!= TUNER_ABSENT
) {
1965 core
->kthread
= kthread_run(cx88_audio_thread
, core
, "cx88 tvaudio");
1966 if (IS_ERR(core
->kthread
)) {
1967 err
= PTR_ERR(core
->kthread
);
1968 printk(KERN_ERR
"%s/0: failed to create cx88 audio thread, err=%d\n",
1975 cx8800_unregister_video(dev
);
1976 free_irq(pci_dev
->irq
, dev
);
1978 cx88_core_put(core
,dev
->pci
);
1984 static void __devexit
cx8800_finidev(struct pci_dev
*pci_dev
)
1986 struct cx8800_dev
*dev
= pci_get_drvdata(pci_dev
);
1987 struct cx88_core
*core
= dev
->core
;
1990 if (core
->kthread
) {
1991 kthread_stop(core
->kthread
);
1992 core
->kthread
= NULL
;
1996 cx88_ir_stop(core
, core
->ir
);
1998 cx88_shutdown(core
); /* FIXME */
1999 pci_disable_device(pci_dev
);
2001 /* unregister stuff */
2003 free_irq(pci_dev
->irq
, dev
);
2004 cx8800_unregister_video(dev
);
2005 pci_set_drvdata(pci_dev
, NULL
);
2008 btcx_riscmem_free(dev
->pci
,&dev
->vidq
.stopper
);
2009 list_del(&dev
->devlist
);
2010 cx88_core_put(core
,dev
->pci
);
2015 static int cx8800_suspend(struct pci_dev
*pci_dev
, pm_message_t state
)
2017 struct cx8800_dev
*dev
= pci_get_drvdata(pci_dev
);
2018 struct cx88_core
*core
= dev
->core
;
2020 /* stop video+vbi capture */
2021 spin_lock(&dev
->slock
);
2022 if (!list_empty(&dev
->vidq
.active
)) {
2023 printk("%s/0: suspend video\n", core
->name
);
2024 stop_video_dma(dev
);
2025 del_timer(&dev
->vidq
.timeout
);
2027 if (!list_empty(&dev
->vbiq
.active
)) {
2028 printk("%s/0: suspend vbi\n", core
->name
);
2029 cx8800_stop_vbi_dma(dev
);
2030 del_timer(&dev
->vbiq
.timeout
);
2032 spin_unlock(&dev
->slock
);
2035 cx88_ir_stop(core
, core
->ir
);
2036 /* FIXME -- shutdown device */
2037 cx88_shutdown(core
);
2039 pci_save_state(pci_dev
);
2040 if (0 != pci_set_power_state(pci_dev
, pci_choose_state(pci_dev
, state
))) {
2041 pci_disable_device(pci_dev
);
2042 dev
->state
.disabled
= 1;
2047 static int cx8800_resume(struct pci_dev
*pci_dev
)
2049 struct cx8800_dev
*dev
= pci_get_drvdata(pci_dev
);
2050 struct cx88_core
*core
= dev
->core
;
2053 if (dev
->state
.disabled
) {
2054 err
=pci_enable_device(pci_dev
);
2056 printk(KERN_ERR
"%s/0: can't enable device\n",
2061 dev
->state
.disabled
= 0;
2063 err
= pci_set_power_state(pci_dev
, PCI_D0
);
2065 printk(KERN_ERR
"%s/0: can't set power state\n", core
->name
);
2066 pci_disable_device(pci_dev
);
2067 dev
->state
.disabled
= 1;
2071 pci_restore_state(pci_dev
);
2073 /* FIXME: re-initialize hardware */
2076 cx88_ir_start(core
, core
->ir
);
2078 cx_set(MO_PCI_INTMSK
, core
->pci_irqmask
);
2080 /* restart video+vbi capture */
2081 spin_lock(&dev
->slock
);
2082 if (!list_empty(&dev
->vidq
.active
)) {
2083 printk("%s/0: resume video\n", core
->name
);
2084 restart_video_queue(dev
,&dev
->vidq
);
2086 if (!list_empty(&dev
->vbiq
.active
)) {
2087 printk("%s/0: resume vbi\n", core
->name
);
2088 cx8800_restart_vbi_queue(dev
,&dev
->vbiq
);
2090 spin_unlock(&dev
->slock
);
2096 /* ----------------------------------------------------------- */
2098 static struct pci_device_id cx8800_pci_tbl
[] = {
2102 .subvendor
= PCI_ANY_ID
,
2103 .subdevice
= PCI_ANY_ID
,
2105 /* --- end of list --- */
2108 MODULE_DEVICE_TABLE(pci
, cx8800_pci_tbl
);
2110 static struct pci_driver cx8800_pci_driver
= {
2112 .id_table
= cx8800_pci_tbl
,
2113 .probe
= cx8800_initdev
,
2114 .remove
= __devexit_p(cx8800_finidev
),
2116 .suspend
= cx8800_suspend
,
2117 .resume
= cx8800_resume
,
2121 static int cx8800_init(void)
2123 printk(KERN_INFO
"cx88/0: cx2388x v4l2 driver version %d.%d.%d loaded\n",
2124 (CX88_VERSION_CODE
>> 16) & 0xff,
2125 (CX88_VERSION_CODE
>> 8) & 0xff,
2126 CX88_VERSION_CODE
& 0xff);
2128 printk(KERN_INFO
"cx2388x: snapshot date %04d-%02d-%02d\n",
2129 SNAPSHOT
/10000, (SNAPSHOT
/100)%100, SNAPSHOT
%100);
2131 return pci_register_driver(&cx8800_pci_driver
);
2134 static void cx8800_fini(void)
2136 pci_unregister_driver(&cx8800_pci_driver
);
2139 module_init(cx8800_init
);
2140 module_exit(cx8800_fini
);
2142 /* ----------------------------------------------------------- */
2147 * 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