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>
43 #include <media/wm8775.h>
45 MODULE_DESCRIPTION("v4l2 driver module for cx2388x based TV cards");
46 MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
47 MODULE_LICENSE("GPL");
48 MODULE_VERSION(CX88_VERSION
);
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_SHARPNESS
,
231 .default_value
= 0x0,
232 .type
= V4L2_CTRL_TYPE_INTEGER
,
235 /* NOTE: the value is converted and written to both even
236 and odd registers in the code */
237 .reg
= MO_FILTER_ODD
,
242 .id
= V4L2_CID_CHROMA_AGC
,
243 .name
= "Chroma AGC",
246 .default_value
= 0x1,
247 .type
= V4L2_CTRL_TYPE_BOOLEAN
,
249 .reg
= MO_INPUT_FORMAT
,
254 .id
= V4L2_CID_COLOR_KILLER
,
255 .name
= "Color killer",
258 .default_value
= 0x1,
259 .type
= V4L2_CTRL_TYPE_BOOLEAN
,
261 .reg
= MO_INPUT_FORMAT
,
266 .id
= V4L2_CID_BAND_STOP_FILTER
,
267 .name
= "Notch filter",
271 .default_value
= 0x0,
272 .type
= V4L2_CTRL_TYPE_INTEGER
,
281 .id
= V4L2_CID_AUDIO_MUTE
,
286 .type
= V4L2_CTRL_TYPE_BOOLEAN
,
289 .sreg
= SHADOW_AUD_VOL_CTL
,
294 .id
= V4L2_CID_AUDIO_VOLUME
,
299 .default_value
= 0x3f,
300 .type
= V4L2_CTRL_TYPE_INTEGER
,
303 .sreg
= SHADOW_AUD_VOL_CTL
,
308 .id
= V4L2_CID_AUDIO_BALANCE
,
313 .default_value
= 0x40,
314 .type
= V4L2_CTRL_TYPE_INTEGER
,
317 .sreg
= SHADOW_AUD_BAL_CTL
,
322 enum { CX8800_CTLS
= ARRAY_SIZE(cx8800_ctls
) };
324 /* Must be sorted from low to high control ID! */
325 const u32 cx88_user_ctrls
[] = {
331 V4L2_CID_AUDIO_VOLUME
,
332 V4L2_CID_AUDIO_BALANCE
,
336 V4L2_CID_COLOR_KILLER
,
337 V4L2_CID_BAND_STOP_FILTER
,
340 EXPORT_SYMBOL(cx88_user_ctrls
);
342 static const u32
* const ctrl_classes
[] = {
347 int cx8800_ctrl_query(struct cx88_core
*core
, struct v4l2_queryctrl
*qctrl
)
351 if (qctrl
->id
< V4L2_CID_BASE
||
352 qctrl
->id
>= V4L2_CID_LASTP1
)
354 for (i
= 0; i
< CX8800_CTLS
; i
++)
355 if (cx8800_ctls
[i
].v
.id
== qctrl
->id
)
357 if (i
== CX8800_CTLS
) {
361 *qctrl
= cx8800_ctls
[i
].v
;
362 /* Report chroma AGC as inactive when SECAM is selected */
363 if (cx8800_ctls
[i
].v
.id
== V4L2_CID_CHROMA_AGC
&&
364 core
->tvnorm
& V4L2_STD_SECAM
)
365 qctrl
->flags
|= V4L2_CTRL_FLAG_INACTIVE
;
369 EXPORT_SYMBOL(cx8800_ctrl_query
);
371 /* ------------------------------------------------------------------- */
372 /* resource management */
374 static int res_get(struct cx8800_dev
*dev
, struct cx8800_fh
*fh
, unsigned int bit
)
376 struct cx88_core
*core
= dev
->core
;
377 if (fh
->resources
& bit
)
378 /* have it already allocated */
382 mutex_lock(&core
->lock
);
383 if (dev
->resources
& bit
) {
384 /* no, someone else uses it */
385 mutex_unlock(&core
->lock
);
388 /* it's free, grab it */
389 fh
->resources
|= bit
;
390 dev
->resources
|= bit
;
391 dprintk(1,"res: get %d\n",bit
);
392 mutex_unlock(&core
->lock
);
397 int res_check(struct cx8800_fh
*fh
, unsigned int bit
)
399 return (fh
->resources
& bit
);
403 int res_locked(struct cx8800_dev
*dev
, unsigned int bit
)
405 return (dev
->resources
& bit
);
409 void res_free(struct cx8800_dev
*dev
, struct cx8800_fh
*fh
, unsigned int bits
)
411 struct cx88_core
*core
= dev
->core
;
412 BUG_ON((fh
->resources
& bits
) != bits
);
414 mutex_lock(&core
->lock
);
415 fh
->resources
&= ~bits
;
416 dev
->resources
&= ~bits
;
417 dprintk(1,"res: put %d\n",bits
);
418 mutex_unlock(&core
->lock
);
421 /* ------------------------------------------------------------------ */
423 int cx88_video_mux(struct cx88_core
*core
, unsigned int input
)
425 /* struct cx88_core *core = dev->core; */
427 dprintk(1,"video_mux: %d [vmux=%d,gpio=0x%x,0x%x,0x%x,0x%x]\n",
428 input
, INPUT(input
).vmux
,
429 INPUT(input
).gpio0
,INPUT(input
).gpio1
,
430 INPUT(input
).gpio2
,INPUT(input
).gpio3
);
432 cx_andor(MO_INPUT_FORMAT
, 0x03 << 14, INPUT(input
).vmux
<< 14);
433 cx_write(MO_GP3_IO
, INPUT(input
).gpio3
);
434 cx_write(MO_GP0_IO
, INPUT(input
).gpio0
);
435 cx_write(MO_GP1_IO
, INPUT(input
).gpio1
);
436 cx_write(MO_GP2_IO
, INPUT(input
).gpio2
);
438 switch (INPUT(input
).type
) {
439 case CX88_VMUX_SVIDEO
:
440 cx_set(MO_AFECFG_IO
, 0x00000001);
441 cx_set(MO_INPUT_FORMAT
, 0x00010010);
442 cx_set(MO_FILTER_EVEN
, 0x00002020);
443 cx_set(MO_FILTER_ODD
, 0x00002020);
446 cx_clear(MO_AFECFG_IO
, 0x00000001);
447 cx_clear(MO_INPUT_FORMAT
, 0x00010010);
448 cx_clear(MO_FILTER_EVEN
, 0x00002020);
449 cx_clear(MO_FILTER_ODD
, 0x00002020);
453 /* if there are audioroutes defined, we have an external
454 ADC to deal with audio */
455 if (INPUT(input
).audioroute
) {
456 /* The wm8775 module has the "2" route hardwired into
457 the initialization. Some boards may use different
458 routes for different inputs. HVR-1300 surely does */
459 if (core
->board
.audio_chip
&&
460 core
->board
.audio_chip
== V4L2_IDENT_WM8775
) {
461 call_all(core
, audio
, s_routing
,
462 INPUT(input
).audioroute
, 0, 0);
464 /* cx2388's C-ADC is connected to the tuner only.
465 When used with S-Video, that ADC is busy dealing with
466 chroma, so an external must be used for baseband audio */
467 if (INPUT(input
).type
!= CX88_VMUX_TELEVISION
&&
468 INPUT(input
).type
!= CX88_VMUX_CABLE
) {
470 core
->tvaudio
= WW_I2SADC
;
471 cx88_set_tvaudio(core
);
474 cx_write(AUD_I2SCNTL
, 0x0);
475 cx_clear(AUD_CTL
, EN_I2SIN_ENABLE
);
481 EXPORT_SYMBOL(cx88_video_mux
);
483 /* ------------------------------------------------------------------ */
485 static int start_video_dma(struct cx8800_dev
*dev
,
486 struct cx88_dmaqueue
*q
,
487 struct cx88_buffer
*buf
)
489 struct cx88_core
*core
= dev
->core
;
491 /* setup fifo + format */
492 cx88_sram_channel_setup(core
, &cx88_sram_channels
[SRAM_CH21
],
493 buf
->bpl
, buf
->risc
.dma
);
494 cx88_set_scale(core
, buf
->vb
.width
, buf
->vb
.height
, buf
->vb
.field
);
495 cx_write(MO_COLOR_CTRL
, buf
->fmt
->cxformat
| ColorFormatGamma
);
498 cx_write(MO_VIDY_GPCNTRL
,GP_COUNT_CONTROL_RESET
);
502 cx_set(MO_PCI_INTMSK
, core
->pci_irqmask
| PCI_INT_VIDINT
);
504 /* Enables corresponding bits at PCI_INT_STAT:
505 bits 0 to 4: video, audio, transport stream, VIP, Host
507 bits 8 and 9: DMA complete for: SRC, DST
508 bits 10 and 11: BERR signal asserted for RISC: RD, WR
509 bits 12 to 15: BERR signal asserted for: BRDG, SRC, DST, IPB
511 cx_set(MO_VID_INTMSK
, 0x0f0011);
514 cx_set(VID_CAPTURE_CONTROL
,0x06);
517 cx_set(MO_DEV_CNTRL2
, (1<<5));
518 cx_set(MO_VID_DMACNTRL
, 0x11); /* Planar Y and packed FIFO and RISC enable */
524 static int stop_video_dma(struct cx8800_dev
*dev
)
526 struct cx88_core
*core
= dev
->core
;
529 cx_clear(MO_VID_DMACNTRL
, 0x11);
531 /* disable capture */
532 cx_clear(VID_CAPTURE_CONTROL
,0x06);
535 cx_clear(MO_PCI_INTMSK
, PCI_INT_VIDINT
);
536 cx_clear(MO_VID_INTMSK
, 0x0f0011);
541 static int restart_video_queue(struct cx8800_dev
*dev
,
542 struct cx88_dmaqueue
*q
)
544 struct cx88_core
*core
= dev
->core
;
545 struct cx88_buffer
*buf
, *prev
;
547 if (!list_empty(&q
->active
)) {
548 buf
= list_entry(q
->active
.next
, struct cx88_buffer
, vb
.queue
);
549 dprintk(2,"restart_queue [%p/%d]: restart dma\n",
551 start_video_dma(dev
, q
, buf
);
552 list_for_each_entry(buf
, &q
->active
, vb
.queue
)
553 buf
->count
= q
->count
++;
554 mod_timer(&q
->timeout
, jiffies
+BUFFER_TIMEOUT
);
560 if (list_empty(&q
->queued
))
562 buf
= list_entry(q
->queued
.next
, struct cx88_buffer
, vb
.queue
);
564 list_move_tail(&buf
->vb
.queue
, &q
->active
);
565 start_video_dma(dev
, q
, buf
);
566 buf
->vb
.state
= VIDEOBUF_ACTIVE
;
567 buf
->count
= q
->count
++;
568 mod_timer(&q
->timeout
, jiffies
+BUFFER_TIMEOUT
);
569 dprintk(2,"[%p/%d] restart_queue - first active\n",
572 } else if (prev
->vb
.width
== buf
->vb
.width
&&
573 prev
->vb
.height
== buf
->vb
.height
&&
574 prev
->fmt
== buf
->fmt
) {
575 list_move_tail(&buf
->vb
.queue
, &q
->active
);
576 buf
->vb
.state
= VIDEOBUF_ACTIVE
;
577 buf
->count
= q
->count
++;
578 prev
->risc
.jmp
[1] = cpu_to_le32(buf
->risc
.dma
);
579 dprintk(2,"[%p/%d] restart_queue - move to active\n",
588 /* ------------------------------------------------------------------ */
591 buffer_setup(struct videobuf_queue
*q
, unsigned int *count
, unsigned int *size
)
593 struct cx8800_fh
*fh
= q
->priv_data
;
595 *size
= fh
->fmt
->depth
*fh
->width
*fh
->height
>> 3;
598 if (*size
* *count
> vid_limit
* 1024 * 1024)
599 *count
= (vid_limit
* 1024 * 1024) / *size
;
604 buffer_prepare(struct videobuf_queue
*q
, struct videobuf_buffer
*vb
,
605 enum v4l2_field field
)
607 struct cx8800_fh
*fh
= q
->priv_data
;
608 struct cx8800_dev
*dev
= fh
->dev
;
609 struct cx88_core
*core
= dev
->core
;
610 struct cx88_buffer
*buf
= container_of(vb
,struct cx88_buffer
,vb
);
611 struct videobuf_dmabuf
*dma
=videobuf_to_dma(&buf
->vb
);
612 int rc
, init_buffer
= 0;
614 BUG_ON(NULL
== fh
->fmt
);
615 if (fh
->width
< 48 || fh
->width
> norm_maxw(core
->tvnorm
) ||
616 fh
->height
< 32 || fh
->height
> norm_maxh(core
->tvnorm
))
618 buf
->vb
.size
= (fh
->width
* fh
->height
* fh
->fmt
->depth
) >> 3;
619 if (0 != buf
->vb
.baddr
&& buf
->vb
.bsize
< buf
->vb
.size
)
622 if (buf
->fmt
!= fh
->fmt
||
623 buf
->vb
.width
!= fh
->width
||
624 buf
->vb
.height
!= fh
->height
||
625 buf
->vb
.field
!= field
) {
627 buf
->vb
.width
= fh
->width
;
628 buf
->vb
.height
= fh
->height
;
629 buf
->vb
.field
= field
;
633 if (VIDEOBUF_NEEDS_INIT
== buf
->vb
.state
) {
635 if (0 != (rc
= videobuf_iolock(q
,&buf
->vb
,NULL
)))
640 buf
->bpl
= buf
->vb
.width
* buf
->fmt
->depth
>> 3;
641 switch (buf
->vb
.field
) {
643 cx88_risc_buffer(dev
->pci
, &buf
->risc
,
644 dma
->sglist
, 0, UNSET
,
645 buf
->bpl
, 0, buf
->vb
.height
);
647 case V4L2_FIELD_BOTTOM
:
648 cx88_risc_buffer(dev
->pci
, &buf
->risc
,
649 dma
->sglist
, UNSET
, 0,
650 buf
->bpl
, 0, buf
->vb
.height
);
652 case V4L2_FIELD_INTERLACED
:
653 cx88_risc_buffer(dev
->pci
, &buf
->risc
,
654 dma
->sglist
, 0, buf
->bpl
,
656 buf
->vb
.height
>> 1);
658 case V4L2_FIELD_SEQ_TB
:
659 cx88_risc_buffer(dev
->pci
, &buf
->risc
,
661 0, buf
->bpl
* (buf
->vb
.height
>> 1),
663 buf
->vb
.height
>> 1);
665 case V4L2_FIELD_SEQ_BT
:
666 cx88_risc_buffer(dev
->pci
, &buf
->risc
,
668 buf
->bpl
* (buf
->vb
.height
>> 1), 0,
670 buf
->vb
.height
>> 1);
676 dprintk(2,"[%p/%d] buffer_prepare - %dx%d %dbpp \"%s\" - dma=0x%08lx\n",
678 fh
->width
, fh
->height
, fh
->fmt
->depth
, fh
->fmt
->name
,
679 (unsigned long)buf
->risc
.dma
);
681 buf
->vb
.state
= VIDEOBUF_PREPARED
;
685 cx88_free_buffer(q
,buf
);
690 buffer_queue(struct videobuf_queue
*vq
, struct videobuf_buffer
*vb
)
692 struct cx88_buffer
*buf
= container_of(vb
,struct cx88_buffer
,vb
);
693 struct cx88_buffer
*prev
;
694 struct cx8800_fh
*fh
= vq
->priv_data
;
695 struct cx8800_dev
*dev
= fh
->dev
;
696 struct cx88_core
*core
= dev
->core
;
697 struct cx88_dmaqueue
*q
= &dev
->vidq
;
699 /* add jump to stopper */
700 buf
->risc
.jmp
[0] = cpu_to_le32(RISC_JUMP
| RISC_IRQ1
| RISC_CNT_INC
);
701 buf
->risc
.jmp
[1] = cpu_to_le32(q
->stopper
.dma
);
703 if (!list_empty(&q
->queued
)) {
704 list_add_tail(&buf
->vb
.queue
,&q
->queued
);
705 buf
->vb
.state
= VIDEOBUF_QUEUED
;
706 dprintk(2,"[%p/%d] buffer_queue - append to queued\n",
709 } else if (list_empty(&q
->active
)) {
710 list_add_tail(&buf
->vb
.queue
,&q
->active
);
711 start_video_dma(dev
, q
, buf
);
712 buf
->vb
.state
= VIDEOBUF_ACTIVE
;
713 buf
->count
= q
->count
++;
714 mod_timer(&q
->timeout
, jiffies
+BUFFER_TIMEOUT
);
715 dprintk(2,"[%p/%d] buffer_queue - first active\n",
719 prev
= list_entry(q
->active
.prev
, struct cx88_buffer
, vb
.queue
);
720 if (prev
->vb
.width
== buf
->vb
.width
&&
721 prev
->vb
.height
== buf
->vb
.height
&&
722 prev
->fmt
== buf
->fmt
) {
723 list_add_tail(&buf
->vb
.queue
,&q
->active
);
724 buf
->vb
.state
= VIDEOBUF_ACTIVE
;
725 buf
->count
= q
->count
++;
726 prev
->risc
.jmp
[1] = cpu_to_le32(buf
->risc
.dma
);
727 dprintk(2,"[%p/%d] buffer_queue - append to active\n",
731 list_add_tail(&buf
->vb
.queue
,&q
->queued
);
732 buf
->vb
.state
= VIDEOBUF_QUEUED
;
733 dprintk(2,"[%p/%d] buffer_queue - first queued\n",
739 static void buffer_release(struct videobuf_queue
*q
, struct videobuf_buffer
*vb
)
741 struct cx88_buffer
*buf
= container_of(vb
,struct cx88_buffer
,vb
);
743 cx88_free_buffer(q
,buf
);
746 static const struct videobuf_queue_ops cx8800_video_qops
= {
747 .buf_setup
= buffer_setup
,
748 .buf_prepare
= buffer_prepare
,
749 .buf_queue
= buffer_queue
,
750 .buf_release
= buffer_release
,
753 /* ------------------------------------------------------------------ */
756 /* ------------------------------------------------------------------ */
758 static struct videobuf_queue
* get_queue(struct cx8800_fh
*fh
)
761 case V4L2_BUF_TYPE_VIDEO_CAPTURE
:
763 case V4L2_BUF_TYPE_VBI_CAPTURE
:
771 static int get_ressource(struct cx8800_fh
*fh
)
774 case V4L2_BUF_TYPE_VIDEO_CAPTURE
:
775 return RESOURCE_VIDEO
;
776 case V4L2_BUF_TYPE_VBI_CAPTURE
:
784 static int video_open(struct file
*file
)
786 struct video_device
*vdev
= video_devdata(file
);
787 struct cx8800_dev
*dev
= video_drvdata(file
);
788 struct cx88_core
*core
= dev
->core
;
789 struct cx8800_fh
*fh
;
790 enum v4l2_buf_type type
= 0;
793 switch (vdev
->vfl_type
) {
794 case VFL_TYPE_GRABBER
:
795 type
= V4L2_BUF_TYPE_VIDEO_CAPTURE
;
798 type
= V4L2_BUF_TYPE_VBI_CAPTURE
;
805 dprintk(1, "open dev=%s radio=%d type=%s\n",
806 video_device_node_name(vdev
), radio
, v4l2_type_names
[type
]);
808 /* allocate + initialize per filehandle data */
809 fh
= kzalloc(sizeof(*fh
),GFP_KERNEL
);
813 file
->private_data
= fh
;
819 fh
->fmt
= format_by_fourcc(V4L2_PIX_FMT_BGR24
);
821 mutex_lock(&core
->lock
);
823 videobuf_queue_sg_init(&fh
->vidq
, &cx8800_video_qops
,
824 &dev
->pci
->dev
, &dev
->slock
,
825 V4L2_BUF_TYPE_VIDEO_CAPTURE
,
826 V4L2_FIELD_INTERLACED
,
827 sizeof(struct cx88_buffer
),
829 videobuf_queue_sg_init(&fh
->vbiq
, &cx8800_vbi_qops
,
830 &dev
->pci
->dev
, &dev
->slock
,
831 V4L2_BUF_TYPE_VBI_CAPTURE
,
833 sizeof(struct cx88_buffer
),
837 dprintk(1,"video_open: setting radio device\n");
838 cx_write(MO_GP3_IO
, core
->board
.radio
.gpio3
);
839 cx_write(MO_GP0_IO
, core
->board
.radio
.gpio0
);
840 cx_write(MO_GP1_IO
, core
->board
.radio
.gpio1
);
841 cx_write(MO_GP2_IO
, core
->board
.radio
.gpio2
);
842 if (core
->board
.radio
.audioroute
) {
843 if(core
->board
.audio_chip
&&
844 core
->board
.audio_chip
== V4L2_IDENT_WM8775
) {
845 call_all(core
, audio
, s_routing
,
846 core
->board
.radio
.audioroute
, 0, 0);
849 core
->tvaudio
= WW_I2SADC
;
850 cx88_set_tvaudio(core
);
853 core
->tvaudio
= WW_FM
;
854 cx88_set_tvaudio(core
);
855 cx88_set_stereo(core
,V4L2_TUNER_MODE_STEREO
,1);
857 call_all(core
, tuner
, s_radio
);
861 mutex_unlock(&core
->lock
);
867 video_read(struct file
*file
, char __user
*data
, size_t count
, loff_t
*ppos
)
869 struct cx8800_fh
*fh
= file
->private_data
;
872 case V4L2_BUF_TYPE_VIDEO_CAPTURE
:
873 if (res_locked(fh
->dev
,RESOURCE_VIDEO
))
875 return videobuf_read_one(&fh
->vidq
, data
, count
, ppos
,
876 file
->f_flags
& O_NONBLOCK
);
877 case V4L2_BUF_TYPE_VBI_CAPTURE
:
878 if (!res_get(fh
->dev
,fh
,RESOURCE_VBI
))
880 return videobuf_read_stream(&fh
->vbiq
, data
, count
, ppos
, 1,
881 file
->f_flags
& O_NONBLOCK
);
889 video_poll(struct file
*file
, struct poll_table_struct
*wait
)
891 struct cx8800_fh
*fh
= file
->private_data
;
892 struct cx88_buffer
*buf
;
893 unsigned int rc
= POLLERR
;
895 if (V4L2_BUF_TYPE_VBI_CAPTURE
== fh
->type
) {
896 if (!res_get(fh
->dev
,fh
,RESOURCE_VBI
))
898 return videobuf_poll_stream(file
, &fh
->vbiq
, wait
);
901 mutex_lock(&fh
->vidq
.vb_lock
);
902 if (res_check(fh
,RESOURCE_VIDEO
)) {
903 /* streaming capture */
904 if (list_empty(&fh
->vidq
.stream
))
906 buf
= list_entry(fh
->vidq
.stream
.next
,struct cx88_buffer
,vb
.stream
);
909 buf
= (struct cx88_buffer
*)fh
->vidq
.read_buf
;
913 poll_wait(file
, &buf
->vb
.done
, wait
);
914 if (buf
->vb
.state
== VIDEOBUF_DONE
||
915 buf
->vb
.state
== VIDEOBUF_ERROR
)
916 rc
= POLLIN
|POLLRDNORM
;
920 mutex_unlock(&fh
->vidq
.vb_lock
);
924 static int video_release(struct file
*file
)
926 struct cx8800_fh
*fh
= file
->private_data
;
927 struct cx8800_dev
*dev
= fh
->dev
;
929 /* turn off overlay */
930 if (res_check(fh
, RESOURCE_OVERLAY
)) {
932 res_free(dev
,fh
,RESOURCE_OVERLAY
);
935 /* stop video capture */
936 if (res_check(fh
, RESOURCE_VIDEO
)) {
937 videobuf_queue_cancel(&fh
->vidq
);
938 res_free(dev
,fh
,RESOURCE_VIDEO
);
940 if (fh
->vidq
.read_buf
) {
941 buffer_release(&fh
->vidq
,fh
->vidq
.read_buf
);
942 kfree(fh
->vidq
.read_buf
);
945 /* stop vbi capture */
946 if (res_check(fh
, RESOURCE_VBI
)) {
947 videobuf_stop(&fh
->vbiq
);
948 res_free(dev
,fh
,RESOURCE_VBI
);
951 videobuf_mmap_free(&fh
->vidq
);
952 videobuf_mmap_free(&fh
->vbiq
);
954 mutex_lock(&dev
->core
->lock
);
955 file
->private_data
= NULL
;
959 if (!dev
->core
->users
)
960 call_all(dev
->core
, core
, s_power
, 0);
961 mutex_unlock(&dev
->core
->lock
);
967 video_mmap(struct file
*file
, struct vm_area_struct
* vma
)
969 struct cx8800_fh
*fh
= file
->private_data
;
971 return videobuf_mmap_mapper(get_queue(fh
), vma
);
974 /* ------------------------------------------------------------------ */
975 /* VIDEO CTRL IOCTLS */
977 int cx88_get_control (struct cx88_core
*core
, struct v4l2_control
*ctl
)
979 const struct cx88_ctrl
*c
= NULL
;
983 for (i
= 0; i
< CX8800_CTLS
; i
++)
984 if (cx8800_ctls
[i
].v
.id
== ctl
->id
)
986 if (unlikely(NULL
== c
))
989 value
= c
->sreg
? cx_sread(c
->sreg
) : cx_read(c
->reg
);
991 case V4L2_CID_AUDIO_BALANCE
:
992 ctl
->value
= ((value
& 0x7f) < 0x40) ? ((value
& 0x7f) + 0x40)
993 : (0x7f - (value
& 0x7f));
995 case V4L2_CID_AUDIO_VOLUME
:
996 ctl
->value
= 0x3f - (value
& 0x3f);
998 case V4L2_CID_SHARPNESS
:
999 ctl
->value
= ((value
& 0x0200) ? (((value
& 0x0180) >> 7) + 1)
1003 ctl
->value
= ((value
+ (c
->off
<< c
->shift
)) & c
->mask
) >> c
->shift
;
1006 dprintk(1,"get_control id=0x%X(%s) ctrl=0x%02x, reg=0x%02x val=0x%02x (mask 0x%02x)%s\n",
1007 ctl
->id
, c
->v
.name
, ctl
->value
, c
->reg
,
1008 value
,c
->mask
, c
->sreg
? " [shadowed]" : "");
1011 EXPORT_SYMBOL(cx88_get_control
);
1013 int cx88_set_control(struct cx88_core
*core
, struct v4l2_control
*ctl
)
1015 const struct cx88_ctrl
*c
= NULL
;
1019 for (i
= 0; i
< CX8800_CTLS
; i
++) {
1020 if (cx8800_ctls
[i
].v
.id
== ctl
->id
) {
1021 c
= &cx8800_ctls
[i
];
1024 if (unlikely(NULL
== c
))
1027 if (ctl
->value
< c
->v
.minimum
)
1028 ctl
->value
= c
->v
.minimum
;
1029 if (ctl
->value
> c
->v
.maximum
)
1030 ctl
->value
= c
->v
.maximum
;
1032 /* Pass changes onto any WM8775 */
1033 if (core
->board
.audio_chip
== V4L2_IDENT_WM8775
) {
1034 struct v4l2_control client_ctl
;
1035 memset(&client_ctl
, 0, sizeof(client_ctl
));
1036 client_ctl
.id
= ctl
->id
;
1039 case V4L2_CID_AUDIO_MUTE
:
1040 client_ctl
.value
= ctl
->value
;
1042 case V4L2_CID_AUDIO_VOLUME
:
1043 client_ctl
.value
= (ctl
->value
) ?
1044 (0x90 + ctl
->value
) << 8 : 0;
1046 case V4L2_CID_AUDIO_BALANCE
:
1047 client_ctl
.value
= ctl
->value
<< 9;
1054 call_hw(core
, WM8775_GID
, core
, s_ctrl
, &client_ctl
);
1059 case V4L2_CID_AUDIO_BALANCE
:
1060 value
= (ctl
->value
< 0x40) ? (0x7f - ctl
->value
) : (ctl
->value
- 0x40);
1062 case V4L2_CID_AUDIO_VOLUME
:
1063 value
= 0x3f - (ctl
->value
& 0x3f);
1065 case V4L2_CID_SATURATION
:
1066 /* special v_sat handling */
1068 value
= ((ctl
->value
- c
->off
) << c
->shift
) & c
->mask
;
1070 if (core
->tvnorm
& V4L2_STD_SECAM
) {
1071 /* For SECAM, both U and V sat should be equal */
1072 value
=value
<<8|value
;
1074 /* Keeps U Saturation proportional to V Sat */
1075 value
=(value
*0x5a)/0x7f<<8|value
;
1079 case V4L2_CID_SHARPNESS
:
1080 /* 0b000, 0b100, 0b101, 0b110, or 0b111 */
1081 value
= (ctl
->value
< 1 ? 0 : ((ctl
->value
+ 3) << 7));
1082 /* needs to be set for both fields */
1083 cx_andor(MO_FILTER_EVEN
, mask
, value
);
1085 case V4L2_CID_CHROMA_AGC
:
1086 /* Do not allow chroma AGC to be enabled for SECAM */
1087 value
= ((ctl
->value
- c
->off
) << c
->shift
) & c
->mask
;
1088 if (core
->tvnorm
& V4L2_STD_SECAM
&& value
)
1092 value
= ((ctl
->value
- c
->off
) << c
->shift
) & c
->mask
;
1095 dprintk(1,"set_control id=0x%X(%s) ctrl=0x%02x, reg=0x%02x val=0x%02x (mask 0x%02x)%s\n",
1096 ctl
->id
, c
->v
.name
, ctl
->value
, c
->reg
, value
,
1097 mask
, c
->sreg
? " [shadowed]" : "");
1099 cx_sandor(c
->sreg
, c
->reg
, mask
, value
);
1101 cx_andor(c
->reg
, mask
, value
);
1105 EXPORT_SYMBOL(cx88_set_control
);
1107 static void init_controls(struct cx88_core
*core
)
1109 struct v4l2_control ctrl
;
1112 for (i
= 0; i
< CX8800_CTLS
; i
++) {
1113 ctrl
.id
=cx8800_ctls
[i
].v
.id
;
1114 ctrl
.value
=cx8800_ctls
[i
].v
.default_value
;
1116 cx88_set_control(core
, &ctrl
);
1120 /* ------------------------------------------------------------------ */
1123 static int vidioc_g_fmt_vid_cap(struct file
*file
, void *priv
,
1124 struct v4l2_format
*f
)
1126 struct cx8800_fh
*fh
= priv
;
1128 f
->fmt
.pix
.width
= fh
->width
;
1129 f
->fmt
.pix
.height
= fh
->height
;
1130 f
->fmt
.pix
.field
= fh
->vidq
.field
;
1131 f
->fmt
.pix
.pixelformat
= fh
->fmt
->fourcc
;
1132 f
->fmt
.pix
.bytesperline
=
1133 (f
->fmt
.pix
.width
* fh
->fmt
->depth
) >> 3;
1134 f
->fmt
.pix
.sizeimage
=
1135 f
->fmt
.pix
.height
* f
->fmt
.pix
.bytesperline
;
1139 static int vidioc_try_fmt_vid_cap(struct file
*file
, void *priv
,
1140 struct v4l2_format
*f
)
1142 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1143 const struct cx8800_fmt
*fmt
;
1144 enum v4l2_field field
;
1145 unsigned int maxw
, maxh
;
1147 fmt
= format_by_fourcc(f
->fmt
.pix
.pixelformat
);
1151 field
= f
->fmt
.pix
.field
;
1152 maxw
= norm_maxw(core
->tvnorm
);
1153 maxh
= norm_maxh(core
->tvnorm
);
1155 if (V4L2_FIELD_ANY
== field
) {
1156 field
= (f
->fmt
.pix
.height
> maxh
/2)
1157 ? V4L2_FIELD_INTERLACED
1158 : V4L2_FIELD_BOTTOM
;
1162 case V4L2_FIELD_TOP
:
1163 case V4L2_FIELD_BOTTOM
:
1166 case V4L2_FIELD_INTERLACED
:
1172 f
->fmt
.pix
.field
= field
;
1173 v4l_bound_align_image(&f
->fmt
.pix
.width
, 48, maxw
, 2,
1174 &f
->fmt
.pix
.height
, 32, maxh
, 0, 0);
1175 f
->fmt
.pix
.bytesperline
=
1176 (f
->fmt
.pix
.width
* fmt
->depth
) >> 3;
1177 f
->fmt
.pix
.sizeimage
=
1178 f
->fmt
.pix
.height
* f
->fmt
.pix
.bytesperline
;
1183 static int vidioc_s_fmt_vid_cap(struct file
*file
, void *priv
,
1184 struct v4l2_format
*f
)
1186 struct cx8800_fh
*fh
= priv
;
1187 int err
= vidioc_try_fmt_vid_cap (file
,priv
,f
);
1191 fh
->fmt
= format_by_fourcc(f
->fmt
.pix
.pixelformat
);
1192 fh
->width
= f
->fmt
.pix
.width
;
1193 fh
->height
= f
->fmt
.pix
.height
;
1194 fh
->vidq
.field
= f
->fmt
.pix
.field
;
1198 static int vidioc_querycap (struct file
*file
, void *priv
,
1199 struct v4l2_capability
*cap
)
1201 struct cx8800_dev
*dev
= ((struct cx8800_fh
*)priv
)->dev
;
1202 struct cx88_core
*core
= dev
->core
;
1204 strcpy(cap
->driver
, "cx8800");
1205 strlcpy(cap
->card
, core
->board
.name
, sizeof(cap
->card
));
1206 sprintf(cap
->bus_info
,"PCI:%s",pci_name(dev
->pci
));
1208 V4L2_CAP_VIDEO_CAPTURE
|
1209 V4L2_CAP_READWRITE
|
1210 V4L2_CAP_STREAMING
|
1211 V4L2_CAP_VBI_CAPTURE
;
1212 if (UNSET
!= core
->board
.tuner_type
)
1213 cap
->capabilities
|= V4L2_CAP_TUNER
;
1217 static int vidioc_enum_fmt_vid_cap (struct file
*file
, void *priv
,
1218 struct v4l2_fmtdesc
*f
)
1220 if (unlikely(f
->index
>= ARRAY_SIZE(formats
)))
1223 strlcpy(f
->description
,formats
[f
->index
].name
,sizeof(f
->description
));
1224 f
->pixelformat
= formats
[f
->index
].fourcc
;
1229 static int vidioc_reqbufs (struct file
*file
, void *priv
, struct v4l2_requestbuffers
*p
)
1231 struct cx8800_fh
*fh
= priv
;
1232 return (videobuf_reqbufs(get_queue(fh
), p
));
1235 static int vidioc_querybuf (struct file
*file
, void *priv
, struct v4l2_buffer
*p
)
1237 struct cx8800_fh
*fh
= priv
;
1238 return (videobuf_querybuf(get_queue(fh
), p
));
1241 static int vidioc_qbuf (struct file
*file
, void *priv
, struct v4l2_buffer
*p
)
1243 struct cx8800_fh
*fh
= priv
;
1244 return (videobuf_qbuf(get_queue(fh
), p
));
1247 static int vidioc_dqbuf (struct file
*file
, void *priv
, struct v4l2_buffer
*p
)
1249 struct cx8800_fh
*fh
= priv
;
1250 return (videobuf_dqbuf(get_queue(fh
), p
,
1251 file
->f_flags
& O_NONBLOCK
));
1254 static int vidioc_streamon(struct file
*file
, void *priv
, enum v4l2_buf_type i
)
1256 struct cx8800_fh
*fh
= priv
;
1257 struct cx8800_dev
*dev
= fh
->dev
;
1259 /* We should remember that this driver also supports teletext, */
1260 /* so we have to test if the v4l2_buf_type is VBI capture data. */
1261 if (unlikely((fh
->type
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
) &&
1262 (fh
->type
!= V4L2_BUF_TYPE_VBI_CAPTURE
)))
1265 if (unlikely(i
!= fh
->type
))
1268 if (unlikely(!res_get(dev
,fh
,get_ressource(fh
))))
1270 return videobuf_streamon(get_queue(fh
));
1273 static int vidioc_streamoff(struct file
*file
, void *priv
, enum v4l2_buf_type i
)
1275 struct cx8800_fh
*fh
= priv
;
1276 struct cx8800_dev
*dev
= fh
->dev
;
1279 if ((fh
->type
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
) &&
1280 (fh
->type
!= V4L2_BUF_TYPE_VBI_CAPTURE
))
1286 res
= get_ressource(fh
);
1287 err
= videobuf_streamoff(get_queue(fh
));
1290 res_free(dev
,fh
,res
);
1294 static int vidioc_s_std (struct file
*file
, void *priv
, v4l2_std_id
*tvnorms
)
1296 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1298 mutex_lock(&core
->lock
);
1299 cx88_set_tvnorm(core
,*tvnorms
);
1300 mutex_unlock(&core
->lock
);
1305 /* only one input in this sample driver */
1306 int cx88_enum_input (struct cx88_core
*core
,struct v4l2_input
*i
)
1308 static const char * const iname
[] = {
1309 [ CX88_VMUX_COMPOSITE1
] = "Composite1",
1310 [ CX88_VMUX_COMPOSITE2
] = "Composite2",
1311 [ CX88_VMUX_COMPOSITE3
] = "Composite3",
1312 [ CX88_VMUX_COMPOSITE4
] = "Composite4",
1313 [ CX88_VMUX_SVIDEO
] = "S-Video",
1314 [ CX88_VMUX_TELEVISION
] = "Television",
1315 [ CX88_VMUX_CABLE
] = "Cable TV",
1316 [ CX88_VMUX_DVB
] = "DVB",
1317 [ CX88_VMUX_DEBUG
] = "for debug only",
1319 unsigned int n
= i
->index
;
1323 if (0 == INPUT(n
).type
)
1325 i
->type
= V4L2_INPUT_TYPE_CAMERA
;
1326 strcpy(i
->name
,iname
[INPUT(n
).type
]);
1327 if ((CX88_VMUX_TELEVISION
== INPUT(n
).type
) ||
1328 (CX88_VMUX_CABLE
== INPUT(n
).type
)) {
1329 i
->type
= V4L2_INPUT_TYPE_TUNER
;
1330 i
->std
= CX88_NORMS
;
1334 EXPORT_SYMBOL(cx88_enum_input
);
1336 static int vidioc_enum_input (struct file
*file
, void *priv
,
1337 struct v4l2_input
*i
)
1339 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1340 return cx88_enum_input (core
,i
);
1343 static int vidioc_g_input (struct file
*file
, void *priv
, unsigned int *i
)
1345 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1351 static int vidioc_s_input (struct file
*file
, void *priv
, unsigned int i
)
1353 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1358 mutex_lock(&core
->lock
);
1359 cx88_newstation(core
);
1360 cx88_video_mux(core
,i
);
1361 mutex_unlock(&core
->lock
);
1367 static int vidioc_queryctrl (struct file
*file
, void *priv
,
1368 struct v4l2_queryctrl
*qctrl
)
1370 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1372 qctrl
->id
= v4l2_ctrl_next(ctrl_classes
, qctrl
->id
);
1373 if (unlikely(qctrl
->id
== 0))
1375 return cx8800_ctrl_query(core
, qctrl
);
1378 static int vidioc_g_ctrl (struct file
*file
, void *priv
,
1379 struct v4l2_control
*ctl
)
1381 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1383 cx88_get_control(core
,ctl
);
1386 static int vidioc_s_ctrl (struct file
*file
, void *priv
,
1387 struct v4l2_control
*ctl
)
1389 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1391 cx88_set_control(core
,ctl
);
1394 static int vidioc_g_tuner (struct file
*file
, void *priv
,
1395 struct v4l2_tuner
*t
)
1397 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1400 if (unlikely(UNSET
== core
->board
.tuner_type
))
1405 strcpy(t
->name
, "Television");
1406 t
->type
= V4L2_TUNER_ANALOG_TV
;
1407 t
->capability
= V4L2_TUNER_CAP_NORM
;
1408 t
->rangehigh
= 0xffffffffUL
;
1410 cx88_get_stereo(core
,t
);
1411 reg
= cx_read(MO_DEVICE_STATUS
);
1412 t
->signal
= (reg
& (1<<5)) ? 0xffff : 0x0000;
1416 static int vidioc_s_tuner (struct file
*file
, void *priv
,
1417 struct v4l2_tuner
*t
)
1419 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1421 if (UNSET
== core
->board
.tuner_type
)
1426 cx88_set_stereo(core
, t
->audmode
, 1);
1430 static int vidioc_g_frequency (struct file
*file
, void *priv
,
1431 struct v4l2_frequency
*f
)
1433 struct cx8800_fh
*fh
= priv
;
1434 struct cx88_core
*core
= fh
->dev
->core
;
1436 if (unlikely(UNSET
== core
->board
.tuner_type
))
1439 /* f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; */
1440 f
->type
= fh
->radio
? V4L2_TUNER_RADIO
: V4L2_TUNER_ANALOG_TV
;
1441 f
->frequency
= core
->freq
;
1443 call_all(core
, tuner
, g_frequency
, f
);
1448 int cx88_set_freq (struct cx88_core
*core
,
1449 struct v4l2_frequency
*f
)
1451 if (unlikely(UNSET
== core
->board
.tuner_type
))
1453 if (unlikely(f
->tuner
!= 0))
1456 mutex_lock(&core
->lock
);
1457 core
->freq
= f
->frequency
;
1458 cx88_newstation(core
);
1459 call_all(core
, tuner
, s_frequency
, f
);
1461 /* When changing channels it is required to reset TVAUDIO */
1463 cx88_set_tvaudio(core
);
1465 mutex_unlock(&core
->lock
);
1469 EXPORT_SYMBOL(cx88_set_freq
);
1471 static int vidioc_s_frequency (struct file
*file
, void *priv
,
1472 struct v4l2_frequency
*f
)
1474 struct cx8800_fh
*fh
= priv
;
1475 struct cx88_core
*core
= fh
->dev
->core
;
1477 if (unlikely(0 == fh
->radio
&& f
->type
!= V4L2_TUNER_ANALOG_TV
))
1479 if (unlikely(1 == fh
->radio
&& f
->type
!= V4L2_TUNER_RADIO
))
1483 cx88_set_freq (core
,f
);
1486 #ifdef CONFIG_VIDEO_ADV_DEBUG
1487 static int vidioc_g_register (struct file
*file
, void *fh
,
1488 struct v4l2_dbg_register
*reg
)
1490 struct cx88_core
*core
= ((struct cx8800_fh
*)fh
)->dev
->core
;
1492 if (!v4l2_chip_match_host(®
->match
))
1494 /* cx2388x has a 24-bit register space */
1495 reg
->val
= cx_read(reg
->reg
& 0xffffff);
1500 static int vidioc_s_register (struct file
*file
, void *fh
,
1501 struct v4l2_dbg_register
*reg
)
1503 struct cx88_core
*core
= ((struct cx8800_fh
*)fh
)->dev
->core
;
1505 if (!v4l2_chip_match_host(®
->match
))
1507 cx_write(reg
->reg
& 0xffffff, reg
->val
);
1512 /* ----------------------------------------------------------- */
1513 /* RADIO ESPECIFIC IOCTLS */
1514 /* ----------------------------------------------------------- */
1516 static int radio_querycap (struct file
*file
, void *priv
,
1517 struct v4l2_capability
*cap
)
1519 struct cx8800_dev
*dev
= ((struct cx8800_fh
*)priv
)->dev
;
1520 struct cx88_core
*core
= dev
->core
;
1522 strcpy(cap
->driver
, "cx8800");
1523 strlcpy(cap
->card
, core
->board
.name
, sizeof(cap
->card
));
1524 sprintf(cap
->bus_info
,"PCI:%s", pci_name(dev
->pci
));
1525 cap
->capabilities
= V4L2_CAP_TUNER
;
1529 static int radio_g_tuner (struct file
*file
, void *priv
,
1530 struct v4l2_tuner
*t
)
1532 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1534 if (unlikely(t
->index
> 0))
1537 strcpy(t
->name
, "Radio");
1538 t
->type
= V4L2_TUNER_RADIO
;
1540 call_all(core
, tuner
, g_tuner
, t
);
1544 static int radio_enum_input (struct file
*file
, void *priv
,
1545 struct v4l2_input
*i
)
1549 strcpy(i
->name
,"Radio");
1550 i
->type
= V4L2_INPUT_TYPE_TUNER
;
1555 static int radio_g_audio (struct file
*file
, void *priv
, struct v4l2_audio
*a
)
1557 if (unlikely(a
->index
))
1560 strcpy(a
->name
,"Radio");
1564 /* FIXME: Should add a standard for radio */
1566 static int radio_s_tuner (struct file
*file
, void *priv
,
1567 struct v4l2_tuner
*t
)
1569 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1574 call_all(core
, tuner
, s_tuner
, t
);
1579 static int radio_s_audio (struct file
*file
, void *fh
,
1580 struct v4l2_audio
*a
)
1585 static int radio_s_input (struct file
*file
, void *fh
, unsigned int i
)
1590 static int radio_queryctrl (struct file
*file
, void *priv
,
1591 struct v4l2_queryctrl
*c
)
1595 if (c
->id
< V4L2_CID_BASE
||
1596 c
->id
>= V4L2_CID_LASTP1
)
1598 if (c
->id
== V4L2_CID_AUDIO_MUTE
||
1599 c
->id
== V4L2_CID_AUDIO_VOLUME
||
1600 c
->id
== V4L2_CID_AUDIO_BALANCE
) {
1601 for (i
= 0; i
< CX8800_CTLS
; i
++) {
1602 if (cx8800_ctls
[i
].v
.id
== c
->id
)
1605 if (i
== CX8800_CTLS
)
1607 *c
= cx8800_ctls
[i
].v
;
1613 /* ----------------------------------------------------------- */
1615 static void cx8800_vid_timeout(unsigned long data
)
1617 struct cx8800_dev
*dev
= (struct cx8800_dev
*)data
;
1618 struct cx88_core
*core
= dev
->core
;
1619 struct cx88_dmaqueue
*q
= &dev
->vidq
;
1620 struct cx88_buffer
*buf
;
1621 unsigned long flags
;
1623 cx88_sram_channel_dump(core
, &cx88_sram_channels
[SRAM_CH21
]);
1625 cx_clear(MO_VID_DMACNTRL
, 0x11);
1626 cx_clear(VID_CAPTURE_CONTROL
, 0x06);
1628 spin_lock_irqsave(&dev
->slock
,flags
);
1629 while (!list_empty(&q
->active
)) {
1630 buf
= list_entry(q
->active
.next
, struct cx88_buffer
, vb
.queue
);
1631 list_del(&buf
->vb
.queue
);
1632 buf
->vb
.state
= VIDEOBUF_ERROR
;
1633 wake_up(&buf
->vb
.done
);
1634 printk("%s/0: [%p/%d] timeout - dma=0x%08lx\n", core
->name
,
1635 buf
, buf
->vb
.i
, (unsigned long)buf
->risc
.dma
);
1637 restart_video_queue(dev
,q
);
1638 spin_unlock_irqrestore(&dev
->slock
,flags
);
1641 static const char *cx88_vid_irqs
[32] = {
1642 "y_risci1", "u_risci1", "v_risci1", "vbi_risc1",
1643 "y_risci2", "u_risci2", "v_risci2", "vbi_risc2",
1644 "y_oflow", "u_oflow", "v_oflow", "vbi_oflow",
1645 "y_sync", "u_sync", "v_sync", "vbi_sync",
1646 "opc_err", "par_err", "rip_err", "pci_abort",
1649 static void cx8800_vid_irq(struct cx8800_dev
*dev
)
1651 struct cx88_core
*core
= dev
->core
;
1652 u32 status
, mask
, count
;
1654 status
= cx_read(MO_VID_INTSTAT
);
1655 mask
= cx_read(MO_VID_INTMSK
);
1656 if (0 == (status
& mask
))
1658 cx_write(MO_VID_INTSTAT
, status
);
1659 if (irq_debug
|| (status
& mask
& ~0xff))
1660 cx88_print_irqbits(core
->name
, "irq vid",
1661 cx88_vid_irqs
, ARRAY_SIZE(cx88_vid_irqs
),
1664 /* risc op code error */
1665 if (status
& (1 << 16)) {
1666 printk(KERN_WARNING
"%s/0: video risc op code error\n",core
->name
);
1667 cx_clear(MO_VID_DMACNTRL
, 0x11);
1668 cx_clear(VID_CAPTURE_CONTROL
, 0x06);
1669 cx88_sram_channel_dump(core
, &cx88_sram_channels
[SRAM_CH21
]);
1673 if (status
& 0x01) {
1674 spin_lock(&dev
->slock
);
1675 count
= cx_read(MO_VIDY_GPCNT
);
1676 cx88_wakeup(core
, &dev
->vidq
, count
);
1677 spin_unlock(&dev
->slock
);
1681 if (status
& 0x08) {
1682 spin_lock(&dev
->slock
);
1683 count
= cx_read(MO_VBI_GPCNT
);
1684 cx88_wakeup(core
, &dev
->vbiq
, count
);
1685 spin_unlock(&dev
->slock
);
1689 if (status
& 0x10) {
1690 dprintk(2,"stopper video\n");
1691 spin_lock(&dev
->slock
);
1692 restart_video_queue(dev
,&dev
->vidq
);
1693 spin_unlock(&dev
->slock
);
1697 if (status
& 0x80) {
1698 dprintk(2,"stopper vbi\n");
1699 spin_lock(&dev
->slock
);
1700 cx8800_restart_vbi_queue(dev
,&dev
->vbiq
);
1701 spin_unlock(&dev
->slock
);
1705 static irqreturn_t
cx8800_irq(int irq
, void *dev_id
)
1707 struct cx8800_dev
*dev
= dev_id
;
1708 struct cx88_core
*core
= dev
->core
;
1710 int loop
, handled
= 0;
1712 for (loop
= 0; loop
< 10; loop
++) {
1713 status
= cx_read(MO_PCI_INTSTAT
) &
1714 (core
->pci_irqmask
| PCI_INT_VIDINT
);
1717 cx_write(MO_PCI_INTSTAT
, status
);
1720 if (status
& core
->pci_irqmask
)
1721 cx88_core_irq(core
,status
);
1722 if (status
& PCI_INT_VIDINT
)
1723 cx8800_vid_irq(dev
);
1726 printk(KERN_WARNING
"%s/0: irq loop -- clearing mask\n",
1728 cx_write(MO_PCI_INTMSK
,0);
1732 return IRQ_RETVAL(handled
);
1735 /* ----------------------------------------------------------- */
1736 /* exported stuff */
1738 static const struct v4l2_file_operations video_fops
=
1740 .owner
= THIS_MODULE
,
1742 .release
= video_release
,
1746 .unlocked_ioctl
= video_ioctl2
,
1749 static const struct v4l2_ioctl_ops video_ioctl_ops
= {
1750 .vidioc_querycap
= vidioc_querycap
,
1751 .vidioc_enum_fmt_vid_cap
= vidioc_enum_fmt_vid_cap
,
1752 .vidioc_g_fmt_vid_cap
= vidioc_g_fmt_vid_cap
,
1753 .vidioc_try_fmt_vid_cap
= vidioc_try_fmt_vid_cap
,
1754 .vidioc_s_fmt_vid_cap
= vidioc_s_fmt_vid_cap
,
1755 .vidioc_g_fmt_vbi_cap
= cx8800_vbi_fmt
,
1756 .vidioc_try_fmt_vbi_cap
= cx8800_vbi_fmt
,
1757 .vidioc_s_fmt_vbi_cap
= cx8800_vbi_fmt
,
1758 .vidioc_reqbufs
= vidioc_reqbufs
,
1759 .vidioc_querybuf
= vidioc_querybuf
,
1760 .vidioc_qbuf
= vidioc_qbuf
,
1761 .vidioc_dqbuf
= vidioc_dqbuf
,
1762 .vidioc_s_std
= vidioc_s_std
,
1763 .vidioc_enum_input
= vidioc_enum_input
,
1764 .vidioc_g_input
= vidioc_g_input
,
1765 .vidioc_s_input
= vidioc_s_input
,
1766 .vidioc_queryctrl
= vidioc_queryctrl
,
1767 .vidioc_g_ctrl
= vidioc_g_ctrl
,
1768 .vidioc_s_ctrl
= vidioc_s_ctrl
,
1769 .vidioc_streamon
= vidioc_streamon
,
1770 .vidioc_streamoff
= vidioc_streamoff
,
1771 .vidioc_g_tuner
= vidioc_g_tuner
,
1772 .vidioc_s_tuner
= vidioc_s_tuner
,
1773 .vidioc_g_frequency
= vidioc_g_frequency
,
1774 .vidioc_s_frequency
= vidioc_s_frequency
,
1775 #ifdef CONFIG_VIDEO_ADV_DEBUG
1776 .vidioc_g_register
= vidioc_g_register
,
1777 .vidioc_s_register
= vidioc_s_register
,
1781 static struct video_device cx8800_vbi_template
;
1783 static const struct video_device cx8800_video_template
= {
1784 .name
= "cx8800-video",
1785 .fops
= &video_fops
,
1786 .ioctl_ops
= &video_ioctl_ops
,
1787 .tvnorms
= CX88_NORMS
,
1788 .current_norm
= V4L2_STD_NTSC_M
,
1791 static const struct v4l2_file_operations radio_fops
=
1793 .owner
= THIS_MODULE
,
1795 .release
= video_release
,
1796 .unlocked_ioctl
= video_ioctl2
,
1799 static const struct v4l2_ioctl_ops radio_ioctl_ops
= {
1800 .vidioc_querycap
= radio_querycap
,
1801 .vidioc_g_tuner
= radio_g_tuner
,
1802 .vidioc_enum_input
= radio_enum_input
,
1803 .vidioc_g_audio
= radio_g_audio
,
1804 .vidioc_s_tuner
= radio_s_tuner
,
1805 .vidioc_s_audio
= radio_s_audio
,
1806 .vidioc_s_input
= radio_s_input
,
1807 .vidioc_queryctrl
= radio_queryctrl
,
1808 .vidioc_g_ctrl
= vidioc_g_ctrl
,
1809 .vidioc_s_ctrl
= vidioc_s_ctrl
,
1810 .vidioc_g_frequency
= vidioc_g_frequency
,
1811 .vidioc_s_frequency
= vidioc_s_frequency
,
1812 #ifdef CONFIG_VIDEO_ADV_DEBUG
1813 .vidioc_g_register
= vidioc_g_register
,
1814 .vidioc_s_register
= vidioc_s_register
,
1818 static const struct video_device cx8800_radio_template
= {
1819 .name
= "cx8800-radio",
1820 .fops
= &radio_fops
,
1821 .ioctl_ops
= &radio_ioctl_ops
,
1824 /* ----------------------------------------------------------- */
1826 static void cx8800_unregister_video(struct cx8800_dev
*dev
)
1828 if (dev
->radio_dev
) {
1829 if (video_is_registered(dev
->radio_dev
))
1830 video_unregister_device(dev
->radio_dev
);
1832 video_device_release(dev
->radio_dev
);
1833 dev
->radio_dev
= NULL
;
1836 if (video_is_registered(dev
->vbi_dev
))
1837 video_unregister_device(dev
->vbi_dev
);
1839 video_device_release(dev
->vbi_dev
);
1840 dev
->vbi_dev
= NULL
;
1842 if (dev
->video_dev
) {
1843 if (video_is_registered(dev
->video_dev
))
1844 video_unregister_device(dev
->video_dev
);
1846 video_device_release(dev
->video_dev
);
1847 dev
->video_dev
= NULL
;
1851 static int __devinit
cx8800_initdev(struct pci_dev
*pci_dev
,
1852 const struct pci_device_id
*pci_id
)
1854 struct cx8800_dev
*dev
;
1855 struct cx88_core
*core
;
1859 dev
= kzalloc(sizeof(*dev
),GFP_KERNEL
);
1865 if (pci_enable_device(pci_dev
)) {
1869 core
= cx88_core_get(dev
->pci
);
1876 /* print pci info */
1877 dev
->pci_rev
= pci_dev
->revision
;
1878 pci_read_config_byte(pci_dev
, PCI_LATENCY_TIMER
, &dev
->pci_lat
);
1879 printk(KERN_INFO
"%s/0: found at %s, rev: %d, irq: %d, "
1880 "latency: %d, mmio: 0x%llx\n", core
->name
,
1881 pci_name(pci_dev
), dev
->pci_rev
, pci_dev
->irq
,
1882 dev
->pci_lat
,(unsigned long long)pci_resource_start(pci_dev
,0));
1884 pci_set_master(pci_dev
);
1885 if (!pci_dma_supported(pci_dev
,DMA_BIT_MASK(32))) {
1886 printk("%s/0: Oops: no 32bit PCI DMA ???\n",core
->name
);
1891 /* Initialize VBI template */
1892 memcpy( &cx8800_vbi_template
, &cx8800_video_template
,
1893 sizeof(cx8800_vbi_template
) );
1894 strcpy(cx8800_vbi_template
.name
,"cx8800-vbi");
1896 /* initialize driver struct */
1897 spin_lock_init(&dev
->slock
);
1898 core
->tvnorm
= cx8800_video_template
.current_norm
;
1900 /* init video dma queues */
1901 INIT_LIST_HEAD(&dev
->vidq
.active
);
1902 INIT_LIST_HEAD(&dev
->vidq
.queued
);
1903 dev
->vidq
.timeout
.function
= cx8800_vid_timeout
;
1904 dev
->vidq
.timeout
.data
= (unsigned long)dev
;
1905 init_timer(&dev
->vidq
.timeout
);
1906 cx88_risc_stopper(dev
->pci
,&dev
->vidq
.stopper
,
1907 MO_VID_DMACNTRL
,0x11,0x00);
1909 /* init vbi dma queues */
1910 INIT_LIST_HEAD(&dev
->vbiq
.active
);
1911 INIT_LIST_HEAD(&dev
->vbiq
.queued
);
1912 dev
->vbiq
.timeout
.function
= cx8800_vbi_timeout
;
1913 dev
->vbiq
.timeout
.data
= (unsigned long)dev
;
1914 init_timer(&dev
->vbiq
.timeout
);
1915 cx88_risc_stopper(dev
->pci
,&dev
->vbiq
.stopper
,
1916 MO_VID_DMACNTRL
,0x88,0x00);
1919 err
= request_irq(pci_dev
->irq
, cx8800_irq
,
1920 IRQF_SHARED
| IRQF_DISABLED
, core
->name
, dev
);
1922 printk(KERN_ERR
"%s/0: can't get IRQ %d\n",
1923 core
->name
,pci_dev
->irq
);
1926 cx_set(MO_PCI_INTMSK
, core
->pci_irqmask
);
1928 /* load and configure helper modules */
1930 if (core
->board
.audio_chip
== V4L2_IDENT_WM8775
) {
1931 struct i2c_board_info wm8775_info
= {
1934 .platform_data
= &core
->wm8775_data
,
1936 struct v4l2_subdev
*sd
;
1938 if (core
->boardnr
== CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1
)
1939 core
->wm8775_data
.is_nova_s
= true;
1941 core
->wm8775_data
.is_nova_s
= false;
1943 sd
= v4l2_i2c_new_subdev_board(&core
->v4l2_dev
, &core
->i2c_adap
,
1944 &wm8775_info
, NULL
);
1946 sd
->grp_id
= WM8775_GID
;
1949 if (core
->board
.audio_chip
== V4L2_IDENT_TVAUDIO
) {
1950 /* This probes for a tda9874 as is used on some
1951 Pixelview Ultra boards. */
1952 v4l2_i2c_new_subdev(&core
->v4l2_dev
, &core
->i2c_adap
,
1953 "tvaudio", 0, I2C_ADDRS(0xb0 >> 1));
1956 switch (core
->boardnr
) {
1957 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD
:
1958 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD
: {
1959 static const struct i2c_board_info rtc_info
= {
1960 I2C_BOARD_INFO("isl1208", 0x6f)
1963 request_module("rtc-isl1208");
1964 core
->i2c_rtc
= i2c_new_device(&core
->i2c_adap
, &rtc_info
);
1966 /* break intentionally omitted */
1967 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO
:
1968 request_module("ir-kbd-i2c");
1971 /* Sets device info at pci_dev */
1972 pci_set_drvdata(pci_dev
, dev
);
1974 /* initial device configuration */
1975 mutex_lock(&core
->lock
);
1976 cx88_set_tvnorm(core
, core
->tvnorm
);
1977 init_controls(core
);
1978 cx88_video_mux(core
, 0);
1980 /* register v4l devices */
1981 dev
->video_dev
= cx88_vdev_init(core
,dev
->pci
,
1982 &cx8800_video_template
,"video");
1983 video_set_drvdata(dev
->video_dev
, dev
);
1984 err
= video_register_device(dev
->video_dev
,VFL_TYPE_GRABBER
,
1985 video_nr
[core
->nr
]);
1987 printk(KERN_ERR
"%s/0: can't register video device\n",
1991 printk(KERN_INFO
"%s/0: registered device %s [v4l2]\n",
1992 core
->name
, video_device_node_name(dev
->video_dev
));
1994 dev
->vbi_dev
= cx88_vdev_init(core
,dev
->pci
,&cx8800_vbi_template
,"vbi");
1995 video_set_drvdata(dev
->vbi_dev
, dev
);
1996 err
= video_register_device(dev
->vbi_dev
,VFL_TYPE_VBI
,
1999 printk(KERN_ERR
"%s/0: can't register vbi device\n",
2003 printk(KERN_INFO
"%s/0: registered device %s\n",
2004 core
->name
, video_device_node_name(dev
->vbi_dev
));
2006 if (core
->board
.radio
.type
== CX88_RADIO
) {
2007 dev
->radio_dev
= cx88_vdev_init(core
,dev
->pci
,
2008 &cx8800_radio_template
,"radio");
2009 video_set_drvdata(dev
->radio_dev
, dev
);
2010 err
= video_register_device(dev
->radio_dev
,VFL_TYPE_RADIO
,
2011 radio_nr
[core
->nr
]);
2013 printk(KERN_ERR
"%s/0: can't register radio device\n",
2017 printk(KERN_INFO
"%s/0: registered device %s\n",
2018 core
->name
, video_device_node_name(dev
->radio_dev
));
2021 /* start tvaudio thread */
2022 if (core
->board
.tuner_type
!= TUNER_ABSENT
) {
2023 core
->kthread
= kthread_run(cx88_audio_thread
, core
, "cx88 tvaudio");
2024 if (IS_ERR(core
->kthread
)) {
2025 err
= PTR_ERR(core
->kthread
);
2026 printk(KERN_ERR
"%s/0: failed to create cx88 audio thread, err=%d\n",
2030 mutex_unlock(&core
->lock
);
2035 cx8800_unregister_video(dev
);
2036 free_irq(pci_dev
->irq
, dev
);
2037 mutex_unlock(&core
->lock
);
2039 cx88_core_put(core
,dev
->pci
);
2045 static void __devexit
cx8800_finidev(struct pci_dev
*pci_dev
)
2047 struct cx8800_dev
*dev
= pci_get_drvdata(pci_dev
);
2048 struct cx88_core
*core
= dev
->core
;
2051 if (core
->kthread
) {
2052 kthread_stop(core
->kthread
);
2053 core
->kthread
= NULL
;
2059 cx88_shutdown(core
); /* FIXME */
2060 pci_disable_device(pci_dev
);
2062 /* unregister stuff */
2064 free_irq(pci_dev
->irq
, dev
);
2065 cx8800_unregister_video(dev
);
2066 pci_set_drvdata(pci_dev
, NULL
);
2069 btcx_riscmem_free(dev
->pci
,&dev
->vidq
.stopper
);
2070 cx88_core_put(core
,dev
->pci
);
2075 static int cx8800_suspend(struct pci_dev
*pci_dev
, pm_message_t state
)
2077 struct cx8800_dev
*dev
= pci_get_drvdata(pci_dev
);
2078 struct cx88_core
*core
= dev
->core
;
2080 /* stop video+vbi capture */
2081 spin_lock(&dev
->slock
);
2082 if (!list_empty(&dev
->vidq
.active
)) {
2083 printk("%s/0: suspend video\n", core
->name
);
2084 stop_video_dma(dev
);
2085 del_timer(&dev
->vidq
.timeout
);
2087 if (!list_empty(&dev
->vbiq
.active
)) {
2088 printk("%s/0: suspend vbi\n", core
->name
);
2089 cx8800_stop_vbi_dma(dev
);
2090 del_timer(&dev
->vbiq
.timeout
);
2092 spin_unlock(&dev
->slock
);
2096 /* FIXME -- shutdown device */
2097 cx88_shutdown(core
);
2099 pci_save_state(pci_dev
);
2100 if (0 != pci_set_power_state(pci_dev
, pci_choose_state(pci_dev
, state
))) {
2101 pci_disable_device(pci_dev
);
2102 dev
->state
.disabled
= 1;
2107 static int cx8800_resume(struct pci_dev
*pci_dev
)
2109 struct cx8800_dev
*dev
= pci_get_drvdata(pci_dev
);
2110 struct cx88_core
*core
= dev
->core
;
2113 if (dev
->state
.disabled
) {
2114 err
=pci_enable_device(pci_dev
);
2116 printk(KERN_ERR
"%s/0: can't enable device\n",
2121 dev
->state
.disabled
= 0;
2123 err
= pci_set_power_state(pci_dev
, PCI_D0
);
2125 printk(KERN_ERR
"%s/0: can't set power state\n", core
->name
);
2126 pci_disable_device(pci_dev
);
2127 dev
->state
.disabled
= 1;
2131 pci_restore_state(pci_dev
);
2133 /* FIXME: re-initialize hardware */
2136 cx88_ir_start(core
);
2138 cx_set(MO_PCI_INTMSK
, core
->pci_irqmask
);
2140 /* restart video+vbi capture */
2141 spin_lock(&dev
->slock
);
2142 if (!list_empty(&dev
->vidq
.active
)) {
2143 printk("%s/0: resume video\n", core
->name
);
2144 restart_video_queue(dev
,&dev
->vidq
);
2146 if (!list_empty(&dev
->vbiq
.active
)) {
2147 printk("%s/0: resume vbi\n", core
->name
);
2148 cx8800_restart_vbi_queue(dev
,&dev
->vbiq
);
2150 spin_unlock(&dev
->slock
);
2156 /* ----------------------------------------------------------- */
2158 static const struct pci_device_id cx8800_pci_tbl
[] = {
2162 .subvendor
= PCI_ANY_ID
,
2163 .subdevice
= PCI_ANY_ID
,
2165 /* --- end of list --- */
2168 MODULE_DEVICE_TABLE(pci
, cx8800_pci_tbl
);
2170 static struct pci_driver cx8800_pci_driver
= {
2172 .id_table
= cx8800_pci_tbl
,
2173 .probe
= cx8800_initdev
,
2174 .remove
= __devexit_p(cx8800_finidev
),
2176 .suspend
= cx8800_suspend
,
2177 .resume
= cx8800_resume
,
2181 static int __init
cx8800_init(void)
2183 printk(KERN_INFO
"cx88/0: cx2388x v4l2 driver version %s loaded\n",
2185 return pci_register_driver(&cx8800_pci_driver
);
2188 static void __exit
cx8800_fini(void)
2190 pci_unregister_driver(&cx8800_pci_driver
);
2193 module_init(cx8800_init
);
2194 module_exit(cx8800_fini
);