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");
49 /* ------------------------------------------------------------------ */
51 static unsigned int video_nr
[] = {[0 ... (CX88_MAXBOARDS
- 1)] = UNSET
};
52 static unsigned int vbi_nr
[] = {[0 ... (CX88_MAXBOARDS
- 1)] = UNSET
};
53 static unsigned int radio_nr
[] = {[0 ... (CX88_MAXBOARDS
- 1)] = UNSET
};
55 module_param_array(video_nr
, int, NULL
, 0444);
56 module_param_array(vbi_nr
, int, NULL
, 0444);
57 module_param_array(radio_nr
, int, NULL
, 0444);
59 MODULE_PARM_DESC(video_nr
,"video device numbers");
60 MODULE_PARM_DESC(vbi_nr
,"vbi device numbers");
61 MODULE_PARM_DESC(radio_nr
,"radio device numbers");
63 static unsigned int video_debug
;
64 module_param(video_debug
,int,0644);
65 MODULE_PARM_DESC(video_debug
,"enable debug messages [video]");
67 static unsigned int irq_debug
;
68 module_param(irq_debug
,int,0644);
69 MODULE_PARM_DESC(irq_debug
,"enable debug messages [IRQ handler]");
71 static unsigned int vid_limit
= 16;
72 module_param(vid_limit
,int,0644);
73 MODULE_PARM_DESC(vid_limit
,"capture memory limit in megabytes");
75 #define dprintk(level,fmt, arg...) if (video_debug >= level) \
76 printk(KERN_DEBUG "%s/0: " fmt, core->name , ## arg)
78 /* ------------------------------------------------------------------- */
81 static const struct cx8800_fmt formats
[] = {
83 .name
= "8 bpp, gray",
84 .fourcc
= V4L2_PIX_FMT_GREY
,
85 .cxformat
= ColorFormatY8
,
87 .flags
= FORMAT_FLAGS_PACKED
,
89 .name
= "15 bpp RGB, le",
90 .fourcc
= V4L2_PIX_FMT_RGB555
,
91 .cxformat
= ColorFormatRGB15
,
93 .flags
= FORMAT_FLAGS_PACKED
,
95 .name
= "15 bpp RGB, be",
96 .fourcc
= V4L2_PIX_FMT_RGB555X
,
97 .cxformat
= ColorFormatRGB15
| ColorFormatBSWAP
,
99 .flags
= FORMAT_FLAGS_PACKED
,
101 .name
= "16 bpp RGB, le",
102 .fourcc
= V4L2_PIX_FMT_RGB565
,
103 .cxformat
= ColorFormatRGB16
,
105 .flags
= FORMAT_FLAGS_PACKED
,
107 .name
= "16 bpp RGB, be",
108 .fourcc
= V4L2_PIX_FMT_RGB565X
,
109 .cxformat
= ColorFormatRGB16
| ColorFormatBSWAP
,
111 .flags
= FORMAT_FLAGS_PACKED
,
113 .name
= "24 bpp RGB, le",
114 .fourcc
= V4L2_PIX_FMT_BGR24
,
115 .cxformat
= ColorFormatRGB24
,
117 .flags
= FORMAT_FLAGS_PACKED
,
119 .name
= "32 bpp RGB, le",
120 .fourcc
= V4L2_PIX_FMT_BGR32
,
121 .cxformat
= ColorFormatRGB32
,
123 .flags
= FORMAT_FLAGS_PACKED
,
125 .name
= "32 bpp RGB, be",
126 .fourcc
= V4L2_PIX_FMT_RGB32
,
127 .cxformat
= ColorFormatRGB32
| ColorFormatBSWAP
| ColorFormatWSWAP
,
129 .flags
= FORMAT_FLAGS_PACKED
,
131 .name
= "4:2:2, packed, YUYV",
132 .fourcc
= V4L2_PIX_FMT_YUYV
,
133 .cxformat
= ColorFormatYUY2
,
135 .flags
= FORMAT_FLAGS_PACKED
,
137 .name
= "4:2:2, packed, UYVY",
138 .fourcc
= V4L2_PIX_FMT_UYVY
,
139 .cxformat
= ColorFormatYUY2
| ColorFormatBSWAP
,
141 .flags
= FORMAT_FLAGS_PACKED
,
145 static const struct cx8800_fmt
* format_by_fourcc(unsigned int fourcc
)
149 for (i
= 0; i
< ARRAY_SIZE(formats
); i
++)
150 if (formats
[i
].fourcc
== fourcc
)
155 /* ------------------------------------------------------------------- */
157 static const struct v4l2_queryctrl no_ctl
= {
159 .flags
= V4L2_CTRL_FLAG_DISABLED
,
162 static const struct cx88_ctrl cx8800_ctls
[] = {
166 .id
= V4L2_CID_BRIGHTNESS
,
167 .name
= "Brightness",
171 .default_value
= 0x7f,
172 .type
= V4L2_CTRL_TYPE_INTEGER
,
175 .reg
= MO_CONTR_BRIGHT
,
180 .id
= V4L2_CID_CONTRAST
,
185 .default_value
= 0x3f,
186 .type
= V4L2_CTRL_TYPE_INTEGER
,
189 .reg
= MO_CONTR_BRIGHT
,
199 .default_value
= 0x7f,
200 .type
= V4L2_CTRL_TYPE_INTEGER
,
207 /* strictly, this only describes only U saturation.
208 * V saturation is handled specially through code.
211 .id
= V4L2_CID_SATURATION
,
212 .name
= "Saturation",
216 .default_value
= 0x7f,
217 .type
= V4L2_CTRL_TYPE_INTEGER
,
220 .reg
= MO_UV_SATURATION
,
225 .id
= V4L2_CID_CHROMA_AGC
,
226 .name
= "Chroma AGC",
229 .default_value
= 0x1,
230 .type
= V4L2_CTRL_TYPE_BOOLEAN
,
232 .reg
= MO_INPUT_FORMAT
,
237 .id
= V4L2_CID_COLOR_KILLER
,
238 .name
= "Color killer",
241 .default_value
= 0x1,
242 .type
= V4L2_CTRL_TYPE_BOOLEAN
,
244 .reg
= MO_INPUT_FORMAT
,
250 .id
= V4L2_CID_AUDIO_MUTE
,
255 .type
= V4L2_CTRL_TYPE_BOOLEAN
,
258 .sreg
= SHADOW_AUD_VOL_CTL
,
263 .id
= V4L2_CID_AUDIO_VOLUME
,
268 .default_value
= 0x3f,
269 .type
= V4L2_CTRL_TYPE_INTEGER
,
272 .sreg
= SHADOW_AUD_VOL_CTL
,
277 .id
= V4L2_CID_AUDIO_BALANCE
,
282 .default_value
= 0x40,
283 .type
= V4L2_CTRL_TYPE_INTEGER
,
286 .sreg
= SHADOW_AUD_BAL_CTL
,
291 enum { CX8800_CTLS
= ARRAY_SIZE(cx8800_ctls
) };
293 /* Must be sorted from low to high control ID! */
294 const u32 cx88_user_ctrls
[] = {
300 V4L2_CID_AUDIO_VOLUME
,
301 V4L2_CID_AUDIO_BALANCE
,
304 V4L2_CID_COLOR_KILLER
,
307 EXPORT_SYMBOL(cx88_user_ctrls
);
309 static const u32
* const ctrl_classes
[] = {
314 int cx8800_ctrl_query(struct cx88_core
*core
, struct v4l2_queryctrl
*qctrl
)
318 if (qctrl
->id
< V4L2_CID_BASE
||
319 qctrl
->id
>= V4L2_CID_LASTP1
)
321 for (i
= 0; i
< CX8800_CTLS
; i
++)
322 if (cx8800_ctls
[i
].v
.id
== qctrl
->id
)
324 if (i
== CX8800_CTLS
) {
328 *qctrl
= cx8800_ctls
[i
].v
;
329 /* Report chroma AGC as inactive when SECAM is selected */
330 if (cx8800_ctls
[i
].v
.id
== V4L2_CID_CHROMA_AGC
&&
331 core
->tvnorm
& V4L2_STD_SECAM
)
332 qctrl
->flags
|= V4L2_CTRL_FLAG_INACTIVE
;
336 EXPORT_SYMBOL(cx8800_ctrl_query
);
338 /* ------------------------------------------------------------------- */
339 /* resource management */
341 static int res_get(struct cx8800_dev
*dev
, struct cx8800_fh
*fh
, unsigned int bit
)
343 struct cx88_core
*core
= dev
->core
;
344 if (fh
->resources
& bit
)
345 /* have it already allocated */
349 mutex_lock(&core
->lock
);
350 if (dev
->resources
& bit
) {
351 /* no, someone else uses it */
352 mutex_unlock(&core
->lock
);
355 /* it's free, grab it */
356 fh
->resources
|= bit
;
357 dev
->resources
|= bit
;
358 dprintk(1,"res: get %d\n",bit
);
359 mutex_unlock(&core
->lock
);
364 int res_check(struct cx8800_fh
*fh
, unsigned int bit
)
366 return (fh
->resources
& bit
);
370 int res_locked(struct cx8800_dev
*dev
, unsigned int bit
)
372 return (dev
->resources
& bit
);
376 void res_free(struct cx8800_dev
*dev
, struct cx8800_fh
*fh
, unsigned int bits
)
378 struct cx88_core
*core
= dev
->core
;
379 BUG_ON((fh
->resources
& bits
) != bits
);
381 mutex_lock(&core
->lock
);
382 fh
->resources
&= ~bits
;
383 dev
->resources
&= ~bits
;
384 dprintk(1,"res: put %d\n",bits
);
385 mutex_unlock(&core
->lock
);
388 /* ------------------------------------------------------------------ */
390 int cx88_video_mux(struct cx88_core
*core
, unsigned int input
)
392 /* struct cx88_core *core = dev->core; */
394 dprintk(1,"video_mux: %d [vmux=%d,gpio=0x%x,0x%x,0x%x,0x%x]\n",
395 input
, INPUT(input
).vmux
,
396 INPUT(input
).gpio0
,INPUT(input
).gpio1
,
397 INPUT(input
).gpio2
,INPUT(input
).gpio3
);
399 cx_andor(MO_INPUT_FORMAT
, 0x03 << 14, INPUT(input
).vmux
<< 14);
400 cx_write(MO_GP3_IO
, INPUT(input
).gpio3
);
401 cx_write(MO_GP0_IO
, INPUT(input
).gpio0
);
402 cx_write(MO_GP1_IO
, INPUT(input
).gpio1
);
403 cx_write(MO_GP2_IO
, INPUT(input
).gpio2
);
405 switch (INPUT(input
).type
) {
406 case CX88_VMUX_SVIDEO
:
407 cx_set(MO_AFECFG_IO
, 0x00000001);
408 cx_set(MO_INPUT_FORMAT
, 0x00010010);
409 cx_set(MO_FILTER_EVEN
, 0x00002020);
410 cx_set(MO_FILTER_ODD
, 0x00002020);
413 cx_clear(MO_AFECFG_IO
, 0x00000001);
414 cx_clear(MO_INPUT_FORMAT
, 0x00010010);
415 cx_clear(MO_FILTER_EVEN
, 0x00002020);
416 cx_clear(MO_FILTER_ODD
, 0x00002020);
420 /* if there are audioroutes defined, we have an external
421 ADC to deal with audio */
422 if (INPUT(input
).audioroute
) {
423 /* The wm8775 module has the "2" route hardwired into
424 the initialization. Some boards may use different
425 routes for different inputs. HVR-1300 surely does */
426 if (core
->board
.audio_chip
&&
427 core
->board
.audio_chip
== V4L2_IDENT_WM8775
) {
428 call_all(core
, audio
, s_routing
,
429 INPUT(input
).audioroute
, 0, 0);
431 /* cx2388's C-ADC is connected to the tuner only.
432 When used with S-Video, that ADC is busy dealing with
433 chroma, so an external must be used for baseband audio */
434 if (INPUT(input
).type
!= CX88_VMUX_TELEVISION
&&
435 INPUT(input
).type
!= CX88_VMUX_CABLE
) {
437 core
->tvaudio
= WW_I2SADC
;
438 cx88_set_tvaudio(core
);
441 cx_write(AUD_I2SCNTL
, 0x0);
442 cx_clear(AUD_CTL
, EN_I2SIN_ENABLE
);
448 EXPORT_SYMBOL(cx88_video_mux
);
450 /* ------------------------------------------------------------------ */
452 static int start_video_dma(struct cx8800_dev
*dev
,
453 struct cx88_dmaqueue
*q
,
454 struct cx88_buffer
*buf
)
456 struct cx88_core
*core
= dev
->core
;
458 /* setup fifo + format */
459 cx88_sram_channel_setup(core
, &cx88_sram_channels
[SRAM_CH21
],
460 buf
->bpl
, buf
->risc
.dma
);
461 cx88_set_scale(core
, buf
->vb
.width
, buf
->vb
.height
, buf
->vb
.field
);
462 cx_write(MO_COLOR_CTRL
, buf
->fmt
->cxformat
| ColorFormatGamma
);
465 cx_write(MO_VIDY_GPCNTRL
,GP_COUNT_CONTROL_RESET
);
469 cx_set(MO_PCI_INTMSK
, core
->pci_irqmask
| PCI_INT_VIDINT
);
471 /* Enables corresponding bits at PCI_INT_STAT:
472 bits 0 to 4: video, audio, transport stream, VIP, Host
474 bits 8 and 9: DMA complete for: SRC, DST
475 bits 10 and 11: BERR signal asserted for RISC: RD, WR
476 bits 12 to 15: BERR signal asserted for: BRDG, SRC, DST, IPB
478 cx_set(MO_VID_INTMSK
, 0x0f0011);
481 cx_set(VID_CAPTURE_CONTROL
,0x06);
484 cx_set(MO_DEV_CNTRL2
, (1<<5));
485 cx_set(MO_VID_DMACNTRL
, 0x11); /* Planar Y and packed FIFO and RISC enable */
491 static int stop_video_dma(struct cx8800_dev
*dev
)
493 struct cx88_core
*core
= dev
->core
;
496 cx_clear(MO_VID_DMACNTRL
, 0x11);
498 /* disable capture */
499 cx_clear(VID_CAPTURE_CONTROL
,0x06);
502 cx_clear(MO_PCI_INTMSK
, PCI_INT_VIDINT
);
503 cx_clear(MO_VID_INTMSK
, 0x0f0011);
508 static int restart_video_queue(struct cx8800_dev
*dev
,
509 struct cx88_dmaqueue
*q
)
511 struct cx88_core
*core
= dev
->core
;
512 struct cx88_buffer
*buf
, *prev
;
514 if (!list_empty(&q
->active
)) {
515 buf
= list_entry(q
->active
.next
, struct cx88_buffer
, vb
.queue
);
516 dprintk(2,"restart_queue [%p/%d]: restart dma\n",
518 start_video_dma(dev
, q
, buf
);
519 list_for_each_entry(buf
, &q
->active
, vb
.queue
)
520 buf
->count
= q
->count
++;
521 mod_timer(&q
->timeout
, jiffies
+BUFFER_TIMEOUT
);
527 if (list_empty(&q
->queued
))
529 buf
= list_entry(q
->queued
.next
, struct cx88_buffer
, vb
.queue
);
531 list_move_tail(&buf
->vb
.queue
, &q
->active
);
532 start_video_dma(dev
, q
, buf
);
533 buf
->vb
.state
= VIDEOBUF_ACTIVE
;
534 buf
->count
= q
->count
++;
535 mod_timer(&q
->timeout
, jiffies
+BUFFER_TIMEOUT
);
536 dprintk(2,"[%p/%d] restart_queue - first active\n",
539 } else if (prev
->vb
.width
== buf
->vb
.width
&&
540 prev
->vb
.height
== buf
->vb
.height
&&
541 prev
->fmt
== buf
->fmt
) {
542 list_move_tail(&buf
->vb
.queue
, &q
->active
);
543 buf
->vb
.state
= VIDEOBUF_ACTIVE
;
544 buf
->count
= q
->count
++;
545 prev
->risc
.jmp
[1] = cpu_to_le32(buf
->risc
.dma
);
546 dprintk(2,"[%p/%d] restart_queue - move to active\n",
555 /* ------------------------------------------------------------------ */
558 buffer_setup(struct videobuf_queue
*q
, unsigned int *count
, unsigned int *size
)
560 struct cx8800_fh
*fh
= q
->priv_data
;
562 *size
= fh
->fmt
->depth
*fh
->width
*fh
->height
>> 3;
565 if (*size
* *count
> vid_limit
* 1024 * 1024)
566 *count
= (vid_limit
* 1024 * 1024) / *size
;
571 buffer_prepare(struct videobuf_queue
*q
, struct videobuf_buffer
*vb
,
572 enum v4l2_field field
)
574 struct cx8800_fh
*fh
= q
->priv_data
;
575 struct cx8800_dev
*dev
= fh
->dev
;
576 struct cx88_core
*core
= dev
->core
;
577 struct cx88_buffer
*buf
= container_of(vb
,struct cx88_buffer
,vb
);
578 struct videobuf_dmabuf
*dma
=videobuf_to_dma(&buf
->vb
);
579 int rc
, init_buffer
= 0;
581 BUG_ON(NULL
== fh
->fmt
);
582 if (fh
->width
< 48 || fh
->width
> norm_maxw(core
->tvnorm
) ||
583 fh
->height
< 32 || fh
->height
> norm_maxh(core
->tvnorm
))
585 buf
->vb
.size
= (fh
->width
* fh
->height
* fh
->fmt
->depth
) >> 3;
586 if (0 != buf
->vb
.baddr
&& buf
->vb
.bsize
< buf
->vb
.size
)
589 if (buf
->fmt
!= fh
->fmt
||
590 buf
->vb
.width
!= fh
->width
||
591 buf
->vb
.height
!= fh
->height
||
592 buf
->vb
.field
!= field
) {
594 buf
->vb
.width
= fh
->width
;
595 buf
->vb
.height
= fh
->height
;
596 buf
->vb
.field
= field
;
600 if (VIDEOBUF_NEEDS_INIT
== buf
->vb
.state
) {
602 if (0 != (rc
= videobuf_iolock(q
,&buf
->vb
,NULL
)))
607 buf
->bpl
= buf
->vb
.width
* buf
->fmt
->depth
>> 3;
608 switch (buf
->vb
.field
) {
610 cx88_risc_buffer(dev
->pci
, &buf
->risc
,
611 dma
->sglist
, 0, UNSET
,
612 buf
->bpl
, 0, buf
->vb
.height
);
614 case V4L2_FIELD_BOTTOM
:
615 cx88_risc_buffer(dev
->pci
, &buf
->risc
,
616 dma
->sglist
, UNSET
, 0,
617 buf
->bpl
, 0, buf
->vb
.height
);
619 case V4L2_FIELD_INTERLACED
:
620 cx88_risc_buffer(dev
->pci
, &buf
->risc
,
621 dma
->sglist
, 0, buf
->bpl
,
623 buf
->vb
.height
>> 1);
625 case V4L2_FIELD_SEQ_TB
:
626 cx88_risc_buffer(dev
->pci
, &buf
->risc
,
628 0, buf
->bpl
* (buf
->vb
.height
>> 1),
630 buf
->vb
.height
>> 1);
632 case V4L2_FIELD_SEQ_BT
:
633 cx88_risc_buffer(dev
->pci
, &buf
->risc
,
635 buf
->bpl
* (buf
->vb
.height
>> 1), 0,
637 buf
->vb
.height
>> 1);
643 dprintk(2,"[%p/%d] buffer_prepare - %dx%d %dbpp \"%s\" - dma=0x%08lx\n",
645 fh
->width
, fh
->height
, fh
->fmt
->depth
, fh
->fmt
->name
,
646 (unsigned long)buf
->risc
.dma
);
648 buf
->vb
.state
= VIDEOBUF_PREPARED
;
652 cx88_free_buffer(q
,buf
);
657 buffer_queue(struct videobuf_queue
*vq
, struct videobuf_buffer
*vb
)
659 struct cx88_buffer
*buf
= container_of(vb
,struct cx88_buffer
,vb
);
660 struct cx88_buffer
*prev
;
661 struct cx8800_fh
*fh
= vq
->priv_data
;
662 struct cx8800_dev
*dev
= fh
->dev
;
663 struct cx88_core
*core
= dev
->core
;
664 struct cx88_dmaqueue
*q
= &dev
->vidq
;
666 /* add jump to stopper */
667 buf
->risc
.jmp
[0] = cpu_to_le32(RISC_JUMP
| RISC_IRQ1
| RISC_CNT_INC
);
668 buf
->risc
.jmp
[1] = cpu_to_le32(q
->stopper
.dma
);
670 if (!list_empty(&q
->queued
)) {
671 list_add_tail(&buf
->vb
.queue
,&q
->queued
);
672 buf
->vb
.state
= VIDEOBUF_QUEUED
;
673 dprintk(2,"[%p/%d] buffer_queue - append to queued\n",
676 } else if (list_empty(&q
->active
)) {
677 list_add_tail(&buf
->vb
.queue
,&q
->active
);
678 start_video_dma(dev
, q
, buf
);
679 buf
->vb
.state
= VIDEOBUF_ACTIVE
;
680 buf
->count
= q
->count
++;
681 mod_timer(&q
->timeout
, jiffies
+BUFFER_TIMEOUT
);
682 dprintk(2,"[%p/%d] buffer_queue - first active\n",
686 prev
= list_entry(q
->active
.prev
, struct cx88_buffer
, vb
.queue
);
687 if (prev
->vb
.width
== buf
->vb
.width
&&
688 prev
->vb
.height
== buf
->vb
.height
&&
689 prev
->fmt
== buf
->fmt
) {
690 list_add_tail(&buf
->vb
.queue
,&q
->active
);
691 buf
->vb
.state
= VIDEOBUF_ACTIVE
;
692 buf
->count
= q
->count
++;
693 prev
->risc
.jmp
[1] = cpu_to_le32(buf
->risc
.dma
);
694 dprintk(2,"[%p/%d] buffer_queue - append to active\n",
698 list_add_tail(&buf
->vb
.queue
,&q
->queued
);
699 buf
->vb
.state
= VIDEOBUF_QUEUED
;
700 dprintk(2,"[%p/%d] buffer_queue - first queued\n",
706 static void buffer_release(struct videobuf_queue
*q
, struct videobuf_buffer
*vb
)
708 struct cx88_buffer
*buf
= container_of(vb
,struct cx88_buffer
,vb
);
710 cx88_free_buffer(q
,buf
);
713 static const struct videobuf_queue_ops cx8800_video_qops
= {
714 .buf_setup
= buffer_setup
,
715 .buf_prepare
= buffer_prepare
,
716 .buf_queue
= buffer_queue
,
717 .buf_release
= buffer_release
,
720 /* ------------------------------------------------------------------ */
723 /* ------------------------------------------------------------------ */
725 static struct videobuf_queue
* get_queue(struct cx8800_fh
*fh
)
728 case V4L2_BUF_TYPE_VIDEO_CAPTURE
:
730 case V4L2_BUF_TYPE_VBI_CAPTURE
:
738 static int get_ressource(struct cx8800_fh
*fh
)
741 case V4L2_BUF_TYPE_VIDEO_CAPTURE
:
742 return RESOURCE_VIDEO
;
743 case V4L2_BUF_TYPE_VBI_CAPTURE
:
751 static int video_open(struct file
*file
)
753 struct video_device
*vdev
= video_devdata(file
);
754 struct cx8800_dev
*dev
= video_drvdata(file
);
755 struct cx88_core
*core
= dev
->core
;
756 struct cx8800_fh
*fh
;
757 enum v4l2_buf_type type
= 0;
760 switch (vdev
->vfl_type
) {
761 case VFL_TYPE_GRABBER
:
762 type
= V4L2_BUF_TYPE_VIDEO_CAPTURE
;
765 type
= V4L2_BUF_TYPE_VBI_CAPTURE
;
772 dprintk(1, "open dev=%s radio=%d type=%s\n",
773 video_device_node_name(vdev
), radio
, v4l2_type_names
[type
]);
775 /* allocate + initialize per filehandle data */
776 fh
= kzalloc(sizeof(*fh
),GFP_KERNEL
);
780 file
->private_data
= fh
;
786 fh
->fmt
= format_by_fourcc(V4L2_PIX_FMT_BGR24
);
788 mutex_lock(&core
->lock
);
790 videobuf_queue_sg_init(&fh
->vidq
, &cx8800_video_qops
,
791 &dev
->pci
->dev
, &dev
->slock
,
792 V4L2_BUF_TYPE_VIDEO_CAPTURE
,
793 V4L2_FIELD_INTERLACED
,
794 sizeof(struct cx88_buffer
),
796 videobuf_queue_sg_init(&fh
->vbiq
, &cx8800_vbi_qops
,
797 &dev
->pci
->dev
, &dev
->slock
,
798 V4L2_BUF_TYPE_VBI_CAPTURE
,
800 sizeof(struct cx88_buffer
),
804 dprintk(1,"video_open: setting radio device\n");
805 cx_write(MO_GP3_IO
, core
->board
.radio
.gpio3
);
806 cx_write(MO_GP0_IO
, core
->board
.radio
.gpio0
);
807 cx_write(MO_GP1_IO
, core
->board
.radio
.gpio1
);
808 cx_write(MO_GP2_IO
, core
->board
.radio
.gpio2
);
809 if (core
->board
.radio
.audioroute
) {
810 if(core
->board
.audio_chip
&&
811 core
->board
.audio_chip
== V4L2_IDENT_WM8775
) {
812 call_all(core
, audio
, s_routing
,
813 core
->board
.radio
.audioroute
, 0, 0);
816 core
->tvaudio
= WW_I2SADC
;
817 cx88_set_tvaudio(core
);
820 core
->tvaudio
= WW_FM
;
821 cx88_set_tvaudio(core
);
822 cx88_set_stereo(core
,V4L2_TUNER_MODE_STEREO
,1);
824 call_all(core
, tuner
, s_radio
);
827 atomic_inc(&core
->users
);
828 mutex_unlock(&core
->lock
);
834 video_read(struct file
*file
, char __user
*data
, size_t count
, loff_t
*ppos
)
836 struct cx8800_fh
*fh
= file
->private_data
;
839 case V4L2_BUF_TYPE_VIDEO_CAPTURE
:
840 if (res_locked(fh
->dev
,RESOURCE_VIDEO
))
842 return videobuf_read_one(&fh
->vidq
, data
, count
, ppos
,
843 file
->f_flags
& O_NONBLOCK
);
844 case V4L2_BUF_TYPE_VBI_CAPTURE
:
845 if (!res_get(fh
->dev
,fh
,RESOURCE_VBI
))
847 return videobuf_read_stream(&fh
->vbiq
, data
, count
, ppos
, 1,
848 file
->f_flags
& O_NONBLOCK
);
856 video_poll(struct file
*file
, struct poll_table_struct
*wait
)
858 struct cx8800_fh
*fh
= file
->private_data
;
859 struct cx88_buffer
*buf
;
860 unsigned int rc
= POLLERR
;
862 if (V4L2_BUF_TYPE_VBI_CAPTURE
== fh
->type
) {
863 if (!res_get(fh
->dev
,fh
,RESOURCE_VBI
))
865 return videobuf_poll_stream(file
, &fh
->vbiq
, wait
);
868 mutex_lock(&fh
->vidq
.vb_lock
);
869 if (res_check(fh
,RESOURCE_VIDEO
)) {
870 /* streaming capture */
871 if (list_empty(&fh
->vidq
.stream
))
873 buf
= list_entry(fh
->vidq
.stream
.next
,struct cx88_buffer
,vb
.stream
);
876 buf
= (struct cx88_buffer
*)fh
->vidq
.read_buf
;
880 poll_wait(file
, &buf
->vb
.done
, wait
);
881 if (buf
->vb
.state
== VIDEOBUF_DONE
||
882 buf
->vb
.state
== VIDEOBUF_ERROR
)
883 rc
= POLLIN
|POLLRDNORM
;
887 mutex_unlock(&fh
->vidq
.vb_lock
);
891 static int video_release(struct file
*file
)
893 struct cx8800_fh
*fh
= file
->private_data
;
894 struct cx8800_dev
*dev
= fh
->dev
;
896 /* turn off overlay */
897 if (res_check(fh
, RESOURCE_OVERLAY
)) {
899 res_free(dev
,fh
,RESOURCE_OVERLAY
);
902 /* stop video capture */
903 if (res_check(fh
, RESOURCE_VIDEO
)) {
904 videobuf_queue_cancel(&fh
->vidq
);
905 res_free(dev
,fh
,RESOURCE_VIDEO
);
907 if (fh
->vidq
.read_buf
) {
908 buffer_release(&fh
->vidq
,fh
->vidq
.read_buf
);
909 kfree(fh
->vidq
.read_buf
);
912 /* stop vbi capture */
913 if (res_check(fh
, RESOURCE_VBI
)) {
914 videobuf_stop(&fh
->vbiq
);
915 res_free(dev
,fh
,RESOURCE_VBI
);
918 videobuf_mmap_free(&fh
->vidq
);
919 videobuf_mmap_free(&fh
->vbiq
);
921 mutex_lock(&dev
->core
->lock
);
922 file
->private_data
= NULL
;
925 if(atomic_dec_and_test(&dev
->core
->users
))
926 call_all(dev
->core
, core
, s_power
, 0);
927 mutex_unlock(&dev
->core
->lock
);
933 video_mmap(struct file
*file
, struct vm_area_struct
* vma
)
935 struct cx8800_fh
*fh
= file
->private_data
;
937 return videobuf_mmap_mapper(get_queue(fh
), vma
);
940 /* ------------------------------------------------------------------ */
941 /* VIDEO CTRL IOCTLS */
943 int cx88_get_control (struct cx88_core
*core
, struct v4l2_control
*ctl
)
945 const struct cx88_ctrl
*c
= NULL
;
949 for (i
= 0; i
< CX8800_CTLS
; i
++)
950 if (cx8800_ctls
[i
].v
.id
== ctl
->id
)
952 if (unlikely(NULL
== c
))
955 value
= c
->sreg
? cx_sread(c
->sreg
) : cx_read(c
->reg
);
957 case V4L2_CID_AUDIO_BALANCE
:
958 ctl
->value
= ((value
& 0x7f) < 0x40) ? ((value
& 0x7f) + 0x40)
959 : (0x7f - (value
& 0x7f));
961 case V4L2_CID_AUDIO_VOLUME
:
962 ctl
->value
= 0x3f - (value
& 0x3f);
965 ctl
->value
= ((value
+ (c
->off
<< c
->shift
)) & c
->mask
) >> c
->shift
;
968 dprintk(1,"get_control id=0x%X(%s) ctrl=0x%02x, reg=0x%02x val=0x%02x (mask 0x%02x)%s\n",
969 ctl
->id
, c
->v
.name
, ctl
->value
, c
->reg
,
970 value
,c
->mask
, c
->sreg
? " [shadowed]" : "");
973 EXPORT_SYMBOL(cx88_get_control
);
975 int cx88_set_control(struct cx88_core
*core
, struct v4l2_control
*ctl
)
977 const struct cx88_ctrl
*c
= NULL
;
980 struct v4l2_control client_ctl
;
982 for (i
= 0; i
< CX8800_CTLS
; i
++) {
983 if (cx8800_ctls
[i
].v
.id
== ctl
->id
) {
987 if (unlikely(NULL
== c
))
990 if (ctl
->value
< c
->v
.minimum
)
991 ctl
->value
= c
->v
.minimum
;
992 if (ctl
->value
> c
->v
.maximum
)
993 ctl
->value
= c
->v
.maximum
;
995 /* Pass changes onto any WM8775 */
996 client_ctl
.id
= ctl
->id
;
998 case V4L2_CID_AUDIO_MUTE
:
999 client_ctl
.value
= ctl
->value
;
1001 case V4L2_CID_AUDIO_VOLUME
:
1002 client_ctl
.value
= (ctl
->value
) ?
1003 (0x90 + ctl
->value
) << 8 : 0;
1005 case V4L2_CID_AUDIO_BALANCE
:
1006 client_ctl
.value
= ctl
->value
<< 9;
1013 call_hw(core
, WM8775_GID
, core
, s_ctrl
, &client_ctl
);
1017 case V4L2_CID_AUDIO_BALANCE
:
1018 value
= (ctl
->value
< 0x40) ? (0x7f - ctl
->value
) : (ctl
->value
- 0x40);
1020 case V4L2_CID_AUDIO_VOLUME
:
1021 value
= 0x3f - (ctl
->value
& 0x3f);
1023 case V4L2_CID_SATURATION
:
1024 /* special v_sat handling */
1026 value
= ((ctl
->value
- c
->off
) << c
->shift
) & c
->mask
;
1028 if (core
->tvnorm
& V4L2_STD_SECAM
) {
1029 /* For SECAM, both U and V sat should be equal */
1030 value
=value
<<8|value
;
1032 /* Keeps U Saturation proportional to V Sat */
1033 value
=(value
*0x5a)/0x7f<<8|value
;
1037 case V4L2_CID_CHROMA_AGC
:
1038 /* Do not allow chroma AGC to be enabled for SECAM */
1039 value
= ((ctl
->value
- c
->off
) << c
->shift
) & c
->mask
;
1040 if (core
->tvnorm
& V4L2_STD_SECAM
&& value
)
1044 value
= ((ctl
->value
- c
->off
) << c
->shift
) & c
->mask
;
1047 dprintk(1,"set_control id=0x%X(%s) ctrl=0x%02x, reg=0x%02x val=0x%02x (mask 0x%02x)%s\n",
1048 ctl
->id
, c
->v
.name
, ctl
->value
, c
->reg
, value
,
1049 mask
, c
->sreg
? " [shadowed]" : "");
1051 cx_sandor(c
->sreg
, c
->reg
, mask
, value
);
1053 cx_andor(c
->reg
, mask
, value
);
1057 EXPORT_SYMBOL(cx88_set_control
);
1059 static void init_controls(struct cx88_core
*core
)
1061 struct v4l2_control ctrl
;
1064 for (i
= 0; i
< CX8800_CTLS
; i
++) {
1065 ctrl
.id
=cx8800_ctls
[i
].v
.id
;
1066 ctrl
.value
=cx8800_ctls
[i
].v
.default_value
;
1068 cx88_set_control(core
, &ctrl
);
1072 /* ------------------------------------------------------------------ */
1075 static int vidioc_g_fmt_vid_cap(struct file
*file
, void *priv
,
1076 struct v4l2_format
*f
)
1078 struct cx8800_fh
*fh
= priv
;
1080 f
->fmt
.pix
.width
= fh
->width
;
1081 f
->fmt
.pix
.height
= fh
->height
;
1082 f
->fmt
.pix
.field
= fh
->vidq
.field
;
1083 f
->fmt
.pix
.pixelformat
= fh
->fmt
->fourcc
;
1084 f
->fmt
.pix
.bytesperline
=
1085 (f
->fmt
.pix
.width
* fh
->fmt
->depth
) >> 3;
1086 f
->fmt
.pix
.sizeimage
=
1087 f
->fmt
.pix
.height
* f
->fmt
.pix
.bytesperline
;
1091 static int vidioc_try_fmt_vid_cap(struct file
*file
, void *priv
,
1092 struct v4l2_format
*f
)
1094 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1095 const struct cx8800_fmt
*fmt
;
1096 enum v4l2_field field
;
1097 unsigned int maxw
, maxh
;
1099 fmt
= format_by_fourcc(f
->fmt
.pix
.pixelformat
);
1103 field
= f
->fmt
.pix
.field
;
1104 maxw
= norm_maxw(core
->tvnorm
);
1105 maxh
= norm_maxh(core
->tvnorm
);
1107 if (V4L2_FIELD_ANY
== field
) {
1108 field
= (f
->fmt
.pix
.height
> maxh
/2)
1109 ? V4L2_FIELD_INTERLACED
1110 : V4L2_FIELD_BOTTOM
;
1114 case V4L2_FIELD_TOP
:
1115 case V4L2_FIELD_BOTTOM
:
1118 case V4L2_FIELD_INTERLACED
:
1124 f
->fmt
.pix
.field
= field
;
1125 v4l_bound_align_image(&f
->fmt
.pix
.width
, 48, maxw
, 2,
1126 &f
->fmt
.pix
.height
, 32, maxh
, 0, 0);
1127 f
->fmt
.pix
.bytesperline
=
1128 (f
->fmt
.pix
.width
* fmt
->depth
) >> 3;
1129 f
->fmt
.pix
.sizeimage
=
1130 f
->fmt
.pix
.height
* f
->fmt
.pix
.bytesperline
;
1135 static int vidioc_s_fmt_vid_cap(struct file
*file
, void *priv
,
1136 struct v4l2_format
*f
)
1138 struct cx8800_fh
*fh
= priv
;
1139 int err
= vidioc_try_fmt_vid_cap (file
,priv
,f
);
1143 fh
->fmt
= format_by_fourcc(f
->fmt
.pix
.pixelformat
);
1144 fh
->width
= f
->fmt
.pix
.width
;
1145 fh
->height
= f
->fmt
.pix
.height
;
1146 fh
->vidq
.field
= f
->fmt
.pix
.field
;
1150 static int vidioc_querycap (struct file
*file
, void *priv
,
1151 struct v4l2_capability
*cap
)
1153 struct cx8800_dev
*dev
= ((struct cx8800_fh
*)priv
)->dev
;
1154 struct cx88_core
*core
= dev
->core
;
1156 strcpy(cap
->driver
, "cx8800");
1157 strlcpy(cap
->card
, core
->board
.name
, sizeof(cap
->card
));
1158 sprintf(cap
->bus_info
,"PCI:%s",pci_name(dev
->pci
));
1159 cap
->version
= CX88_VERSION_CODE
;
1161 V4L2_CAP_VIDEO_CAPTURE
|
1162 V4L2_CAP_READWRITE
|
1163 V4L2_CAP_STREAMING
|
1164 V4L2_CAP_VBI_CAPTURE
;
1165 if (UNSET
!= core
->board
.tuner_type
)
1166 cap
->capabilities
|= V4L2_CAP_TUNER
;
1170 static int vidioc_enum_fmt_vid_cap (struct file
*file
, void *priv
,
1171 struct v4l2_fmtdesc
*f
)
1173 if (unlikely(f
->index
>= ARRAY_SIZE(formats
)))
1176 strlcpy(f
->description
,formats
[f
->index
].name
,sizeof(f
->description
));
1177 f
->pixelformat
= formats
[f
->index
].fourcc
;
1182 #ifdef CONFIG_VIDEO_V4L1_COMPAT
1183 static int vidiocgmbuf (struct file
*file
, void *priv
, struct video_mbuf
*mbuf
)
1185 struct cx8800_fh
*fh
= priv
;
1187 return videobuf_cgmbuf (get_queue(fh
), mbuf
, 8);
1191 static int vidioc_reqbufs (struct file
*file
, void *priv
, struct v4l2_requestbuffers
*p
)
1193 struct cx8800_fh
*fh
= priv
;
1194 return (videobuf_reqbufs(get_queue(fh
), p
));
1197 static int vidioc_querybuf (struct file
*file
, void *priv
, struct v4l2_buffer
*p
)
1199 struct cx8800_fh
*fh
= priv
;
1200 return (videobuf_querybuf(get_queue(fh
), p
));
1203 static int vidioc_qbuf (struct file
*file
, void *priv
, struct v4l2_buffer
*p
)
1205 struct cx8800_fh
*fh
= priv
;
1206 return (videobuf_qbuf(get_queue(fh
), p
));
1209 static int vidioc_dqbuf (struct file
*file
, void *priv
, struct v4l2_buffer
*p
)
1211 struct cx8800_fh
*fh
= priv
;
1212 return (videobuf_dqbuf(get_queue(fh
), p
,
1213 file
->f_flags
& O_NONBLOCK
));
1216 static int vidioc_streamon(struct file
*file
, void *priv
, enum v4l2_buf_type i
)
1218 struct cx8800_fh
*fh
= priv
;
1219 struct cx8800_dev
*dev
= fh
->dev
;
1221 /* We should remember that this driver also supports teletext, */
1222 /* so we have to test if the v4l2_buf_type is VBI capture data. */
1223 if (unlikely((fh
->type
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
) &&
1224 (fh
->type
!= V4L2_BUF_TYPE_VBI_CAPTURE
)))
1227 if (unlikely(i
!= fh
->type
))
1230 if (unlikely(!res_get(dev
,fh
,get_ressource(fh
))))
1232 return videobuf_streamon(get_queue(fh
));
1235 static int vidioc_streamoff(struct file
*file
, void *priv
, enum v4l2_buf_type i
)
1237 struct cx8800_fh
*fh
= priv
;
1238 struct cx8800_dev
*dev
= fh
->dev
;
1241 if ((fh
->type
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
) &&
1242 (fh
->type
!= V4L2_BUF_TYPE_VBI_CAPTURE
))
1248 res
= get_ressource(fh
);
1249 err
= videobuf_streamoff(get_queue(fh
));
1252 res_free(dev
,fh
,res
);
1256 static int vidioc_s_std (struct file
*file
, void *priv
, v4l2_std_id
*tvnorms
)
1258 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1260 mutex_lock(&core
->lock
);
1261 cx88_set_tvnorm(core
,*tvnorms
);
1262 mutex_unlock(&core
->lock
);
1267 /* only one input in this sample driver */
1268 int cx88_enum_input (struct cx88_core
*core
,struct v4l2_input
*i
)
1270 static const char * const iname
[] = {
1271 [ CX88_VMUX_COMPOSITE1
] = "Composite1",
1272 [ CX88_VMUX_COMPOSITE2
] = "Composite2",
1273 [ CX88_VMUX_COMPOSITE3
] = "Composite3",
1274 [ CX88_VMUX_COMPOSITE4
] = "Composite4",
1275 [ CX88_VMUX_SVIDEO
] = "S-Video",
1276 [ CX88_VMUX_TELEVISION
] = "Television",
1277 [ CX88_VMUX_CABLE
] = "Cable TV",
1278 [ CX88_VMUX_DVB
] = "DVB",
1279 [ CX88_VMUX_DEBUG
] = "for debug only",
1281 unsigned int n
= i
->index
;
1285 if (0 == INPUT(n
).type
)
1287 i
->type
= V4L2_INPUT_TYPE_CAMERA
;
1288 strcpy(i
->name
,iname
[INPUT(n
).type
]);
1289 if ((CX88_VMUX_TELEVISION
== INPUT(n
).type
) ||
1290 (CX88_VMUX_CABLE
== INPUT(n
).type
)) {
1291 i
->type
= V4L2_INPUT_TYPE_TUNER
;
1292 i
->std
= CX88_NORMS
;
1296 EXPORT_SYMBOL(cx88_enum_input
);
1298 static int vidioc_enum_input (struct file
*file
, void *priv
,
1299 struct v4l2_input
*i
)
1301 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1302 return cx88_enum_input (core
,i
);
1305 static int vidioc_g_input (struct file
*file
, void *priv
, unsigned int *i
)
1307 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1313 static int vidioc_s_input (struct file
*file
, void *priv
, unsigned int i
)
1315 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1320 mutex_lock(&core
->lock
);
1321 cx88_newstation(core
);
1322 cx88_video_mux(core
,i
);
1323 mutex_unlock(&core
->lock
);
1329 static int vidioc_queryctrl (struct file
*file
, void *priv
,
1330 struct v4l2_queryctrl
*qctrl
)
1332 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1334 qctrl
->id
= v4l2_ctrl_next(ctrl_classes
, qctrl
->id
);
1335 if (unlikely(qctrl
->id
== 0))
1337 return cx8800_ctrl_query(core
, qctrl
);
1340 static int vidioc_g_ctrl (struct file
*file
, void *priv
,
1341 struct v4l2_control
*ctl
)
1343 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1345 cx88_get_control(core
,ctl
);
1348 static int vidioc_s_ctrl (struct file
*file
, void *priv
,
1349 struct v4l2_control
*ctl
)
1351 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1353 cx88_set_control(core
,ctl
);
1356 static int vidioc_g_tuner (struct file
*file
, void *priv
,
1357 struct v4l2_tuner
*t
)
1359 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1362 if (unlikely(UNSET
== core
->board
.tuner_type
))
1367 strcpy(t
->name
, "Television");
1368 t
->type
= V4L2_TUNER_ANALOG_TV
;
1369 t
->capability
= V4L2_TUNER_CAP_NORM
;
1370 t
->rangehigh
= 0xffffffffUL
;
1372 cx88_get_stereo(core
,t
);
1373 reg
= cx_read(MO_DEVICE_STATUS
);
1374 t
->signal
= (reg
& (1<<5)) ? 0xffff : 0x0000;
1378 static int vidioc_s_tuner (struct file
*file
, void *priv
,
1379 struct v4l2_tuner
*t
)
1381 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1383 if (UNSET
== core
->board
.tuner_type
)
1388 cx88_set_stereo(core
, t
->audmode
, 1);
1392 static int vidioc_g_frequency (struct file
*file
, void *priv
,
1393 struct v4l2_frequency
*f
)
1395 struct cx8800_fh
*fh
= priv
;
1396 struct cx88_core
*core
= fh
->dev
->core
;
1398 if (unlikely(UNSET
== core
->board
.tuner_type
))
1401 /* f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; */
1402 f
->type
= fh
->radio
? V4L2_TUNER_RADIO
: V4L2_TUNER_ANALOG_TV
;
1403 f
->frequency
= core
->freq
;
1405 call_all(core
, tuner
, g_frequency
, f
);
1410 int cx88_set_freq (struct cx88_core
*core
,
1411 struct v4l2_frequency
*f
)
1413 if (unlikely(UNSET
== core
->board
.tuner_type
))
1415 if (unlikely(f
->tuner
!= 0))
1418 mutex_lock(&core
->lock
);
1419 core
->freq
= f
->frequency
;
1420 cx88_newstation(core
);
1421 call_all(core
, tuner
, s_frequency
, f
);
1423 /* When changing channels it is required to reset TVAUDIO */
1425 cx88_set_tvaudio(core
);
1427 mutex_unlock(&core
->lock
);
1431 EXPORT_SYMBOL(cx88_set_freq
);
1433 static int vidioc_s_frequency (struct file
*file
, void *priv
,
1434 struct v4l2_frequency
*f
)
1436 struct cx8800_fh
*fh
= priv
;
1437 struct cx88_core
*core
= fh
->dev
->core
;
1439 if (unlikely(0 == fh
->radio
&& f
->type
!= V4L2_TUNER_ANALOG_TV
))
1441 if (unlikely(1 == fh
->radio
&& f
->type
!= V4L2_TUNER_RADIO
))
1445 cx88_set_freq (core
,f
);
1448 #ifdef CONFIG_VIDEO_ADV_DEBUG
1449 static int vidioc_g_register (struct file
*file
, void *fh
,
1450 struct v4l2_dbg_register
*reg
)
1452 struct cx88_core
*core
= ((struct cx8800_fh
*)fh
)->dev
->core
;
1454 if (!v4l2_chip_match_host(®
->match
))
1456 /* cx2388x has a 24-bit register space */
1457 reg
->val
= cx_read(reg
->reg
& 0xffffff);
1462 static int vidioc_s_register (struct file
*file
, void *fh
,
1463 struct v4l2_dbg_register
*reg
)
1465 struct cx88_core
*core
= ((struct cx8800_fh
*)fh
)->dev
->core
;
1467 if (!v4l2_chip_match_host(®
->match
))
1469 cx_write(reg
->reg
& 0xffffff, reg
->val
);
1474 /* ----------------------------------------------------------- */
1475 /* RADIO ESPECIFIC IOCTLS */
1476 /* ----------------------------------------------------------- */
1478 static int radio_querycap (struct file
*file
, void *priv
,
1479 struct v4l2_capability
*cap
)
1481 struct cx8800_dev
*dev
= ((struct cx8800_fh
*)priv
)->dev
;
1482 struct cx88_core
*core
= dev
->core
;
1484 strcpy(cap
->driver
, "cx8800");
1485 strlcpy(cap
->card
, core
->board
.name
, sizeof(cap
->card
));
1486 sprintf(cap
->bus_info
,"PCI:%s", pci_name(dev
->pci
));
1487 cap
->version
= CX88_VERSION_CODE
;
1488 cap
->capabilities
= V4L2_CAP_TUNER
;
1492 static int radio_g_tuner (struct file
*file
, void *priv
,
1493 struct v4l2_tuner
*t
)
1495 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1497 if (unlikely(t
->index
> 0))
1500 strcpy(t
->name
, "Radio");
1501 t
->type
= V4L2_TUNER_RADIO
;
1503 call_all(core
, tuner
, g_tuner
, t
);
1507 static int radio_enum_input (struct file
*file
, void *priv
,
1508 struct v4l2_input
*i
)
1512 strcpy(i
->name
,"Radio");
1513 i
->type
= V4L2_INPUT_TYPE_TUNER
;
1518 static int radio_g_audio (struct file
*file
, void *priv
, struct v4l2_audio
*a
)
1520 if (unlikely(a
->index
))
1523 strcpy(a
->name
,"Radio");
1527 /* FIXME: Should add a standard for radio */
1529 static int radio_s_tuner (struct file
*file
, void *priv
,
1530 struct v4l2_tuner
*t
)
1532 struct cx88_core
*core
= ((struct cx8800_fh
*)priv
)->dev
->core
;
1537 call_all(core
, tuner
, s_tuner
, t
);
1542 static int radio_s_audio (struct file
*file
, void *fh
,
1543 struct v4l2_audio
*a
)
1548 static int radio_s_input (struct file
*file
, void *fh
, unsigned int i
)
1553 static int radio_queryctrl (struct file
*file
, void *priv
,
1554 struct v4l2_queryctrl
*c
)
1558 if (c
->id
< V4L2_CID_BASE
||
1559 c
->id
>= V4L2_CID_LASTP1
)
1561 if (c
->id
== V4L2_CID_AUDIO_MUTE
||
1562 c
->id
== V4L2_CID_AUDIO_VOLUME
||
1563 c
->id
== V4L2_CID_AUDIO_BALANCE
) {
1564 for (i
= 0; i
< CX8800_CTLS
; i
++) {
1565 if (cx8800_ctls
[i
].v
.id
== c
->id
)
1568 if (i
== CX8800_CTLS
)
1570 *c
= cx8800_ctls
[i
].v
;
1576 /* ----------------------------------------------------------- */
1578 static void cx8800_vid_timeout(unsigned long data
)
1580 struct cx8800_dev
*dev
= (struct cx8800_dev
*)data
;
1581 struct cx88_core
*core
= dev
->core
;
1582 struct cx88_dmaqueue
*q
= &dev
->vidq
;
1583 struct cx88_buffer
*buf
;
1584 unsigned long flags
;
1586 cx88_sram_channel_dump(core
, &cx88_sram_channels
[SRAM_CH21
]);
1588 cx_clear(MO_VID_DMACNTRL
, 0x11);
1589 cx_clear(VID_CAPTURE_CONTROL
, 0x06);
1591 spin_lock_irqsave(&dev
->slock
,flags
);
1592 while (!list_empty(&q
->active
)) {
1593 buf
= list_entry(q
->active
.next
, struct cx88_buffer
, vb
.queue
);
1594 list_del(&buf
->vb
.queue
);
1595 buf
->vb
.state
= VIDEOBUF_ERROR
;
1596 wake_up(&buf
->vb
.done
);
1597 printk("%s/0: [%p/%d] timeout - dma=0x%08lx\n", core
->name
,
1598 buf
, buf
->vb
.i
, (unsigned long)buf
->risc
.dma
);
1600 restart_video_queue(dev
,q
);
1601 spin_unlock_irqrestore(&dev
->slock
,flags
);
1604 static const char *cx88_vid_irqs
[32] = {
1605 "y_risci1", "u_risci1", "v_risci1", "vbi_risc1",
1606 "y_risci2", "u_risci2", "v_risci2", "vbi_risc2",
1607 "y_oflow", "u_oflow", "v_oflow", "vbi_oflow",
1608 "y_sync", "u_sync", "v_sync", "vbi_sync",
1609 "opc_err", "par_err", "rip_err", "pci_abort",
1612 static void cx8800_vid_irq(struct cx8800_dev
*dev
)
1614 struct cx88_core
*core
= dev
->core
;
1615 u32 status
, mask
, count
;
1617 status
= cx_read(MO_VID_INTSTAT
);
1618 mask
= cx_read(MO_VID_INTMSK
);
1619 if (0 == (status
& mask
))
1621 cx_write(MO_VID_INTSTAT
, status
);
1622 if (irq_debug
|| (status
& mask
& ~0xff))
1623 cx88_print_irqbits(core
->name
, "irq vid",
1624 cx88_vid_irqs
, ARRAY_SIZE(cx88_vid_irqs
),
1627 /* risc op code error */
1628 if (status
& (1 << 16)) {
1629 printk(KERN_WARNING
"%s/0: video risc op code error\n",core
->name
);
1630 cx_clear(MO_VID_DMACNTRL
, 0x11);
1631 cx_clear(VID_CAPTURE_CONTROL
, 0x06);
1632 cx88_sram_channel_dump(core
, &cx88_sram_channels
[SRAM_CH21
]);
1636 if (status
& 0x01) {
1637 spin_lock(&dev
->slock
);
1638 count
= cx_read(MO_VIDY_GPCNT
);
1639 cx88_wakeup(core
, &dev
->vidq
, count
);
1640 spin_unlock(&dev
->slock
);
1644 if (status
& 0x08) {
1645 spin_lock(&dev
->slock
);
1646 count
= cx_read(MO_VBI_GPCNT
);
1647 cx88_wakeup(core
, &dev
->vbiq
, count
);
1648 spin_unlock(&dev
->slock
);
1652 if (status
& 0x10) {
1653 dprintk(2,"stopper video\n");
1654 spin_lock(&dev
->slock
);
1655 restart_video_queue(dev
,&dev
->vidq
);
1656 spin_unlock(&dev
->slock
);
1660 if (status
& 0x80) {
1661 dprintk(2,"stopper vbi\n");
1662 spin_lock(&dev
->slock
);
1663 cx8800_restart_vbi_queue(dev
,&dev
->vbiq
);
1664 spin_unlock(&dev
->slock
);
1668 static irqreturn_t
cx8800_irq(int irq
, void *dev_id
)
1670 struct cx8800_dev
*dev
= dev_id
;
1671 struct cx88_core
*core
= dev
->core
;
1673 int loop
, handled
= 0;
1675 for (loop
= 0; loop
< 10; loop
++) {
1676 status
= cx_read(MO_PCI_INTSTAT
) &
1677 (core
->pci_irqmask
| PCI_INT_VIDINT
);
1680 cx_write(MO_PCI_INTSTAT
, status
);
1683 if (status
& core
->pci_irqmask
)
1684 cx88_core_irq(core
,status
);
1685 if (status
& PCI_INT_VIDINT
)
1686 cx8800_vid_irq(dev
);
1689 printk(KERN_WARNING
"%s/0: irq loop -- clearing mask\n",
1691 cx_write(MO_PCI_INTMSK
,0);
1695 return IRQ_RETVAL(handled
);
1698 /* ----------------------------------------------------------- */
1699 /* exported stuff */
1701 static const struct v4l2_file_operations video_fops
=
1703 .owner
= THIS_MODULE
,
1705 .release
= video_release
,
1709 .ioctl
= video_ioctl2
,
1712 static const struct v4l2_ioctl_ops video_ioctl_ops
= {
1713 .vidioc_querycap
= vidioc_querycap
,
1714 .vidioc_enum_fmt_vid_cap
= vidioc_enum_fmt_vid_cap
,
1715 .vidioc_g_fmt_vid_cap
= vidioc_g_fmt_vid_cap
,
1716 .vidioc_try_fmt_vid_cap
= vidioc_try_fmt_vid_cap
,
1717 .vidioc_s_fmt_vid_cap
= vidioc_s_fmt_vid_cap
,
1718 .vidioc_g_fmt_vbi_cap
= cx8800_vbi_fmt
,
1719 .vidioc_try_fmt_vbi_cap
= cx8800_vbi_fmt
,
1720 .vidioc_s_fmt_vbi_cap
= cx8800_vbi_fmt
,
1721 .vidioc_reqbufs
= vidioc_reqbufs
,
1722 .vidioc_querybuf
= vidioc_querybuf
,
1723 .vidioc_qbuf
= vidioc_qbuf
,
1724 .vidioc_dqbuf
= vidioc_dqbuf
,
1725 .vidioc_s_std
= vidioc_s_std
,
1726 .vidioc_enum_input
= vidioc_enum_input
,
1727 .vidioc_g_input
= vidioc_g_input
,
1728 .vidioc_s_input
= vidioc_s_input
,
1729 .vidioc_queryctrl
= vidioc_queryctrl
,
1730 .vidioc_g_ctrl
= vidioc_g_ctrl
,
1731 .vidioc_s_ctrl
= vidioc_s_ctrl
,
1732 .vidioc_streamon
= vidioc_streamon
,
1733 .vidioc_streamoff
= vidioc_streamoff
,
1734 #ifdef CONFIG_VIDEO_V4L1_COMPAT
1735 .vidiocgmbuf
= vidiocgmbuf
,
1737 .vidioc_g_tuner
= vidioc_g_tuner
,
1738 .vidioc_s_tuner
= vidioc_s_tuner
,
1739 .vidioc_g_frequency
= vidioc_g_frequency
,
1740 .vidioc_s_frequency
= vidioc_s_frequency
,
1741 #ifdef CONFIG_VIDEO_ADV_DEBUG
1742 .vidioc_g_register
= vidioc_g_register
,
1743 .vidioc_s_register
= vidioc_s_register
,
1747 static struct video_device cx8800_vbi_template
;
1749 static const struct video_device cx8800_video_template
= {
1750 .name
= "cx8800-video",
1751 .fops
= &video_fops
,
1752 .ioctl_ops
= &video_ioctl_ops
,
1753 .tvnorms
= CX88_NORMS
,
1754 .current_norm
= V4L2_STD_NTSC_M
,
1757 static const struct v4l2_file_operations radio_fops
=
1759 .owner
= THIS_MODULE
,
1761 .release
= video_release
,
1762 .ioctl
= video_ioctl2
,
1765 static const struct v4l2_ioctl_ops radio_ioctl_ops
= {
1766 .vidioc_querycap
= radio_querycap
,
1767 .vidioc_g_tuner
= radio_g_tuner
,
1768 .vidioc_enum_input
= radio_enum_input
,
1769 .vidioc_g_audio
= radio_g_audio
,
1770 .vidioc_s_tuner
= radio_s_tuner
,
1771 .vidioc_s_audio
= radio_s_audio
,
1772 .vidioc_s_input
= radio_s_input
,
1773 .vidioc_queryctrl
= radio_queryctrl
,
1774 .vidioc_g_ctrl
= vidioc_g_ctrl
,
1775 .vidioc_s_ctrl
= vidioc_s_ctrl
,
1776 .vidioc_g_frequency
= vidioc_g_frequency
,
1777 .vidioc_s_frequency
= vidioc_s_frequency
,
1778 #ifdef CONFIG_VIDEO_ADV_DEBUG
1779 .vidioc_g_register
= vidioc_g_register
,
1780 .vidioc_s_register
= vidioc_s_register
,
1784 static const struct video_device cx8800_radio_template
= {
1785 .name
= "cx8800-radio",
1786 .fops
= &radio_fops
,
1787 .ioctl_ops
= &radio_ioctl_ops
,
1790 /* ----------------------------------------------------------- */
1792 static void cx8800_unregister_video(struct cx8800_dev
*dev
)
1794 if (dev
->radio_dev
) {
1795 if (video_is_registered(dev
->radio_dev
))
1796 video_unregister_device(dev
->radio_dev
);
1798 video_device_release(dev
->radio_dev
);
1799 dev
->radio_dev
= NULL
;
1802 if (video_is_registered(dev
->vbi_dev
))
1803 video_unregister_device(dev
->vbi_dev
);
1805 video_device_release(dev
->vbi_dev
);
1806 dev
->vbi_dev
= NULL
;
1808 if (dev
->video_dev
) {
1809 if (video_is_registered(dev
->video_dev
))
1810 video_unregister_device(dev
->video_dev
);
1812 video_device_release(dev
->video_dev
);
1813 dev
->video_dev
= NULL
;
1817 static int __devinit
cx8800_initdev(struct pci_dev
*pci_dev
,
1818 const struct pci_device_id
*pci_id
)
1820 struct cx8800_dev
*dev
;
1821 struct cx88_core
*core
;
1825 dev
= kzalloc(sizeof(*dev
),GFP_KERNEL
);
1831 if (pci_enable_device(pci_dev
)) {
1835 core
= cx88_core_get(dev
->pci
);
1842 /* print pci info */
1843 pci_read_config_byte(pci_dev
, PCI_CLASS_REVISION
, &dev
->pci_rev
);
1844 pci_read_config_byte(pci_dev
, PCI_LATENCY_TIMER
, &dev
->pci_lat
);
1845 printk(KERN_INFO
"%s/0: found at %s, rev: %d, irq: %d, "
1846 "latency: %d, mmio: 0x%llx\n", core
->name
,
1847 pci_name(pci_dev
), dev
->pci_rev
, pci_dev
->irq
,
1848 dev
->pci_lat
,(unsigned long long)pci_resource_start(pci_dev
,0));
1850 pci_set_master(pci_dev
);
1851 if (!pci_dma_supported(pci_dev
,DMA_BIT_MASK(32))) {
1852 printk("%s/0: Oops: no 32bit PCI DMA ???\n",core
->name
);
1857 /* Initialize VBI template */
1858 memcpy( &cx8800_vbi_template
, &cx8800_video_template
,
1859 sizeof(cx8800_vbi_template
) );
1860 strcpy(cx8800_vbi_template
.name
,"cx8800-vbi");
1862 /* initialize driver struct */
1863 spin_lock_init(&dev
->slock
);
1864 core
->tvnorm
= cx8800_video_template
.current_norm
;
1866 /* init video dma queues */
1867 INIT_LIST_HEAD(&dev
->vidq
.active
);
1868 INIT_LIST_HEAD(&dev
->vidq
.queued
);
1869 dev
->vidq
.timeout
.function
= cx8800_vid_timeout
;
1870 dev
->vidq
.timeout
.data
= (unsigned long)dev
;
1871 init_timer(&dev
->vidq
.timeout
);
1872 cx88_risc_stopper(dev
->pci
,&dev
->vidq
.stopper
,
1873 MO_VID_DMACNTRL
,0x11,0x00);
1875 /* init vbi dma queues */
1876 INIT_LIST_HEAD(&dev
->vbiq
.active
);
1877 INIT_LIST_HEAD(&dev
->vbiq
.queued
);
1878 dev
->vbiq
.timeout
.function
= cx8800_vbi_timeout
;
1879 dev
->vbiq
.timeout
.data
= (unsigned long)dev
;
1880 init_timer(&dev
->vbiq
.timeout
);
1881 cx88_risc_stopper(dev
->pci
,&dev
->vbiq
.stopper
,
1882 MO_VID_DMACNTRL
,0x88,0x00);
1885 err
= request_irq(pci_dev
->irq
, cx8800_irq
,
1886 IRQF_SHARED
| IRQF_DISABLED
, core
->name
, dev
);
1888 printk(KERN_ERR
"%s/0: can't get IRQ %d\n",
1889 core
->name
,pci_dev
->irq
);
1892 cx_set(MO_PCI_INTMSK
, core
->pci_irqmask
);
1894 /* load and configure helper modules */
1896 if (core
->board
.audio_chip
== V4L2_IDENT_WM8775
)
1897 v4l2_i2c_new_subdev(&core
->v4l2_dev
, &core
->i2c_adap
,
1898 NULL
, "wm8775", 0x36 >> 1, NULL
);
1900 if (core
->board
.audio_chip
== V4L2_IDENT_TVAUDIO
) {
1901 /* This probes for a tda9874 as is used on some
1902 Pixelview Ultra boards. */
1903 v4l2_i2c_new_subdev(&core
->v4l2_dev
,
1905 NULL
, "tvaudio", 0, I2C_ADDRS(0xb0 >> 1));
1908 switch (core
->boardnr
) {
1909 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD
:
1910 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD
: {
1911 static const struct i2c_board_info rtc_info
= {
1912 I2C_BOARD_INFO("isl1208", 0x6f)
1915 request_module("rtc-isl1208");
1916 core
->i2c_rtc
= i2c_new_device(&core
->i2c_adap
, &rtc_info
);
1918 /* break intentionally omitted */
1919 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO
:
1920 request_module("ir-kbd-i2c");
1923 /* register v4l devices */
1924 dev
->video_dev
= cx88_vdev_init(core
,dev
->pci
,
1925 &cx8800_video_template
,"video");
1926 video_set_drvdata(dev
->video_dev
, dev
);
1927 err
= video_register_device(dev
->video_dev
,VFL_TYPE_GRABBER
,
1928 video_nr
[core
->nr
]);
1930 printk(KERN_ERR
"%s/0: can't register video device\n",
1934 printk(KERN_INFO
"%s/0: registered device %s [v4l2]\n",
1935 core
->name
, video_device_node_name(dev
->video_dev
));
1937 dev
->vbi_dev
= cx88_vdev_init(core
,dev
->pci
,&cx8800_vbi_template
,"vbi");
1938 video_set_drvdata(dev
->vbi_dev
, dev
);
1939 err
= video_register_device(dev
->vbi_dev
,VFL_TYPE_VBI
,
1942 printk(KERN_ERR
"%s/0: can't register vbi device\n",
1946 printk(KERN_INFO
"%s/0: registered device %s\n",
1947 core
->name
, video_device_node_name(dev
->vbi_dev
));
1949 if (core
->board
.radio
.type
== CX88_RADIO
) {
1950 dev
->radio_dev
= cx88_vdev_init(core
,dev
->pci
,
1951 &cx8800_radio_template
,"radio");
1952 video_set_drvdata(dev
->radio_dev
, dev
);
1953 err
= video_register_device(dev
->radio_dev
,VFL_TYPE_RADIO
,
1954 radio_nr
[core
->nr
]);
1956 printk(KERN_ERR
"%s/0: can't register radio device\n",
1960 printk(KERN_INFO
"%s/0: registered device %s\n",
1961 core
->name
, video_device_node_name(dev
->radio_dev
));
1964 /* everything worked */
1965 pci_set_drvdata(pci_dev
,dev
);
1967 /* initial device configuration */
1968 mutex_lock(&core
->lock
);
1969 cx88_set_tvnorm(core
,core
->tvnorm
);
1970 init_controls(core
);
1971 cx88_video_mux(core
,0);
1972 mutex_unlock(&core
->lock
);
1974 /* start tvaudio thread */
1975 if (core
->board
.tuner_type
!= TUNER_ABSENT
) {
1976 core
->kthread
= kthread_run(cx88_audio_thread
, core
, "cx88 tvaudio");
1977 if (IS_ERR(core
->kthread
)) {
1978 err
= PTR_ERR(core
->kthread
);
1979 printk(KERN_ERR
"%s/0: failed to create cx88 audio thread, err=%d\n",
1986 cx8800_unregister_video(dev
);
1987 free_irq(pci_dev
->irq
, dev
);
1989 cx88_core_put(core
,dev
->pci
);
1995 static void __devexit
cx8800_finidev(struct pci_dev
*pci_dev
)
1997 struct cx8800_dev
*dev
= pci_get_drvdata(pci_dev
);
1998 struct cx88_core
*core
= dev
->core
;
2001 if (core
->kthread
) {
2002 kthread_stop(core
->kthread
);
2003 core
->kthread
= NULL
;
2009 cx88_shutdown(core
); /* FIXME */
2010 pci_disable_device(pci_dev
);
2012 /* unregister stuff */
2014 free_irq(pci_dev
->irq
, dev
);
2015 cx8800_unregister_video(dev
);
2016 pci_set_drvdata(pci_dev
, NULL
);
2019 btcx_riscmem_free(dev
->pci
,&dev
->vidq
.stopper
);
2020 cx88_core_put(core
,dev
->pci
);
2025 static int cx8800_suspend(struct pci_dev
*pci_dev
, pm_message_t state
)
2027 struct cx8800_dev
*dev
= pci_get_drvdata(pci_dev
);
2028 struct cx88_core
*core
= dev
->core
;
2030 /* stop video+vbi capture */
2031 spin_lock(&dev
->slock
);
2032 if (!list_empty(&dev
->vidq
.active
)) {
2033 printk("%s/0: suspend video\n", core
->name
);
2034 stop_video_dma(dev
);
2035 del_timer(&dev
->vidq
.timeout
);
2037 if (!list_empty(&dev
->vbiq
.active
)) {
2038 printk("%s/0: suspend vbi\n", core
->name
);
2039 cx8800_stop_vbi_dma(dev
);
2040 del_timer(&dev
->vbiq
.timeout
);
2042 spin_unlock(&dev
->slock
);
2046 /* FIXME -- shutdown device */
2047 cx88_shutdown(core
);
2049 pci_save_state(pci_dev
);
2050 if (0 != pci_set_power_state(pci_dev
, pci_choose_state(pci_dev
, state
))) {
2051 pci_disable_device(pci_dev
);
2052 dev
->state
.disabled
= 1;
2057 static int cx8800_resume(struct pci_dev
*pci_dev
)
2059 struct cx8800_dev
*dev
= pci_get_drvdata(pci_dev
);
2060 struct cx88_core
*core
= dev
->core
;
2063 if (dev
->state
.disabled
) {
2064 err
=pci_enable_device(pci_dev
);
2066 printk(KERN_ERR
"%s/0: can't enable device\n",
2071 dev
->state
.disabled
= 0;
2073 err
= pci_set_power_state(pci_dev
, PCI_D0
);
2075 printk(KERN_ERR
"%s/0: can't set power state\n", core
->name
);
2076 pci_disable_device(pci_dev
);
2077 dev
->state
.disabled
= 1;
2081 pci_restore_state(pci_dev
);
2083 /* FIXME: re-initialize hardware */
2086 cx88_ir_start(core
);
2088 cx_set(MO_PCI_INTMSK
, core
->pci_irqmask
);
2090 /* restart video+vbi capture */
2091 spin_lock(&dev
->slock
);
2092 if (!list_empty(&dev
->vidq
.active
)) {
2093 printk("%s/0: resume video\n", core
->name
);
2094 restart_video_queue(dev
,&dev
->vidq
);
2096 if (!list_empty(&dev
->vbiq
.active
)) {
2097 printk("%s/0: resume vbi\n", core
->name
);
2098 cx8800_restart_vbi_queue(dev
,&dev
->vbiq
);
2100 spin_unlock(&dev
->slock
);
2106 /* ----------------------------------------------------------- */
2108 static const struct pci_device_id cx8800_pci_tbl
[] = {
2112 .subvendor
= PCI_ANY_ID
,
2113 .subdevice
= PCI_ANY_ID
,
2115 /* --- end of list --- */
2118 MODULE_DEVICE_TABLE(pci
, cx8800_pci_tbl
);
2120 static struct pci_driver cx8800_pci_driver
= {
2122 .id_table
= cx8800_pci_tbl
,
2123 .probe
= cx8800_initdev
,
2124 .remove
= __devexit_p(cx8800_finidev
),
2126 .suspend
= cx8800_suspend
,
2127 .resume
= cx8800_resume
,
2131 static int __init
cx8800_init(void)
2133 printk(KERN_INFO
"cx88/0: cx2388x v4l2 driver version %d.%d.%d loaded\n",
2134 (CX88_VERSION_CODE
>> 16) & 0xff,
2135 (CX88_VERSION_CODE
>> 8) & 0xff,
2136 CX88_VERSION_CODE
& 0xff);
2138 printk(KERN_INFO
"cx2388x: snapshot date %04d-%02d-%02d\n",
2139 SNAPSHOT
/10000, (SNAPSHOT
/100)%100, SNAPSHOT
%100);
2141 return pci_register_driver(&cx8800_pci_driver
);
2144 static void __exit
cx8800_fini(void)
2146 pci_unregister_driver(&cx8800_pci_driver
);
2149 module_init(cx8800_init
);
2150 module_exit(cx8800_fini
);
2152 /* ----------------------------------------------------------- */
2157 * 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