| Linux kernel & device driver programming |
| [ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] |
1 /* 1
2 * Driver for the Conexant CX23885 PCIe bridg
3 *
4 * Copyright (c) 2007 Steven Toth <stoth@haup
5 *
6 * This program is free software; you can red
7 * it under the terms of the GNU General Publ
8 * the Free Software Foundation; either versi
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope th
12 * but WITHOUT ANY WARRANTY; without even the
13 * MERCHANTABILITY or FITNESS FOR A PARTICULA
14 *
15 * GNU General Public License for more detail
16 *
17 * You should have received a copy of the GNU
18 * along with this program; if not, write to
19 * Foundation, Inc., 675 Mass Ave, Cambridge,
20 */
21
22 #include <linux/init.h>
23 #include <linux/list.h>
24 #include <linux/module.h>
25 #include <linux/moduleparam.h>
26 #include <linux/kmod.h>
27 #include <linux/kernel.h>
28 #include <linux/slab.h>
29 #include <linux/interrupt.h>
30 #include <linux/delay.h>
31 #include <linux/kthread.h>
32 #include <asm/div64.h>
33
34 #include "cx23885.h"
35 #include <media/v4l2-common.h>
36
37 #ifdef CONFIG_VIDEO_V4L1_COMPAT
38 /* Include V4L1 specific functions. Should be
39 #include <linux/videodev.h>
40 #endif
41
42 MODULE_DESCRIPTION("v4l2 driver module for cx2
43 MODULE_AUTHOR("Steven Toth <stoth@hauppauge.co
44 MODULE_LICENSE("GPL");
45
46 /* -------------------------------------------
47
48 static unsigned int video_nr[] = {[0 ... (CX23
49 static unsigned int vbi_nr[] = {[0 ... (CX23
50 static unsigned int radio_nr[] = {[0 ... (CX23
51
52 module_param_array(video_nr, int, NULL, 0444);
53 module_param_array(vbi_nr, int, NULL, 0444);
54 module_param_array(radio_nr, int, NULL, 0444);
55
56 MODULE_PARM_DESC(video_nr, "video device numbe
57 MODULE_PARM_DESC(vbi_nr, "vbi device numbers")
58 MODULE_PARM_DESC(radio_nr, "radio device numbe
59
60 static unsigned int video_debug;
61 module_param(video_debug, int, 0644);
62 MODULE_PARM_DESC(video_debug, "enable debug me
63
64 static unsigned int irq_debug;
65 module_param(irq_debug, int, 0644);
66 MODULE_PARM_DESC(irq_debug, "enable debug mess
67
68 static unsigned int vid_limit = 16;
69 module_param(vid_limit, int, 0644);
70 MODULE_PARM_DESC(vid_limit, "capture memory li
71
72 #define dprintk(level, fmt, arg...)\
73 do { if (video_debug >= level)\
74 printk(KERN_DEBUG "%s/0: " fmt
75 } while (0)
76
77 /* -------------------------------------------
78 /* static data
79
80 #define FORMAT_FLAGS_PACKED 0x01
81
82 static struct cx23885_fmt formats[] = {
83 {
84 .name = "8 bpp, gray",
85 .fourcc = V4L2_PIX_FMT_GREY,
86 .depth = 8,
87 .flags = FORMAT_FLAGS_PACKE
88 }, {
89 .name = "15 bpp RGB, le",
90 .fourcc = V4L2_PIX_FMT_RGB55
91 .depth = 16,
92 .flags = FORMAT_FLAGS_PACKE
93 }, {
94 .name = "15 bpp RGB, be",
95 .fourcc = V4L2_PIX_FMT_RGB55
96 .depth = 16,
97 .flags = FORMAT_FLAGS_PACKE
98 }, {
99 .name = "16 bpp RGB, le",
100 .fourcc = V4L2_PIX_FMT_RGB56
101 .depth = 16,
102 .flags = FORMAT_FLAGS_PACKE
103 }, {
104 .name = "16 bpp RGB, be",
105 .fourcc = V4L2_PIX_FMT_RGB56
106 .depth = 16,
107 .flags = FORMAT_FLAGS_PACKE
108 }, {
109 .name = "24 bpp RGB, le",
110 .fourcc = V4L2_PIX_FMT_BGR24
111 .depth = 24,
112 .flags = FORMAT_FLAGS_PACKE
113 }, {
114 .name = "32 bpp RGB, le",
115 .fourcc = V4L2_PIX_FMT_BGR32
116 .depth = 32,
117 .flags = FORMAT_FLAGS_PACKE
118 }, {
119 .name = "32 bpp RGB, be",
120 .fourcc = V4L2_PIX_FMT_RGB32
121 .depth = 32,
122 .flags = FORMAT_FLAGS_PACKE
123 }, {
124 .name = "4:2:2, packed, YU
125 .fourcc = V4L2_PIX_FMT_YUYV,
126 .depth = 16,
127 .flags = FORMAT_FLAGS_PACKE
128 }, {
129 .name = "4:2:2, packed, UY
130 .fourcc = V4L2_PIX_FMT_UYVY,
131 .depth = 16,
132 .flags = FORMAT_FLAGS_PACKE
133 },
134 };
135
136 static struct cx23885_fmt *format_by_fourcc(un
137 {
138 unsigned int i;
139
140 for (i = 0; i < ARRAY_SIZE(formats); i
141 if (formats[i].fourcc == fourc
142 return formats+i;
143
144 printk(KERN_ERR "%s(0x%08x) NOT FOUND\
145 return NULL;
146 }
147
148 /* -------------------------------------------
149
150 static const struct v4l2_queryctrl no_ctl = {
151 .name = "42",
152 .flags = V4L2_CTRL_FLAG_DISABLED,
153 };
154
155 static struct cx23885_ctrl cx23885_ctls[] = {
156 /* --- video --- */
157 {
158 .v = {
159 .id = V4L2_
160 .name = "Brig
161 .minimum = 0x00,
162 .maximum = 0xff,
163 .step = 1,
164 .default_value = 0x7f,
165 .type = V4L2_
166 },
167 .off = 128,
168 .reg = LUMA_
169 .mask = 0x00f
170 .shift = 0,
171 }, {
172 .v = {
173 .id = V4L2_
174 .name = "Cont
175 .minimum = 0,
176 .maximum = 0xff,
177 .step = 1,
178 .default_value = 0x3f,
179 .type = V4L2_
180 },
181 .off = 0,
182 .reg = LUMA_
183 .mask = 0xff0
184 .shift = 8,
185 }, {
186 .v = {
187 .id = V4L2_
188 .name = "Hue"
189 .minimum = 0,
190 .maximum = 0xff,
191 .step = 1,
192 .default_value = 0x7f,
193 .type = V4L2_
194 },
195 .off = 128,
196 .reg = CHROM
197 .mask = 0xff0
198 .shift = 16,
199 }, {
200 /* strictly, this only describ
201 * V saturation is handled spe
202 */
203 .v = {
204 .id = V4L2_
205 .name = "Satu
206 .minimum = 0,
207 .maximum = 0xff,
208 .step = 1,
209 .default_value = 0x7f,
210 .type = V4L2_
211 },
212 .off = 0,
213 .reg = CHROM
214 .mask = 0x00f
215 .shift = 0,
216 }, {
217 /* --- audio --- */
218 .v = {
219 .id = V4L2_
220 .name = "Mute
221 .minimum = 0,
222 .maximum = 1,
223 .default_value = 1,
224 .type = V4L2_
225 },
226 .reg = PATH1
227 .mask = (0x1f
228 .shift = 24,
229 }, {
230 .v = {
231 .id = V4L2_
232 .name = "Volu
233 .minimum = 0,
234 .maximum = 0x3f,
235 .step = 1,
236 .default_value = 0x3f,
237 .type = V4L2_
238 },
239 .reg = PATH1
240 .mask = 0xff,
241 .shift = 0,
242 }
243 };
244 static const int CX23885_CTLS = ARRAY_SIZE(cx2
245
246 const u32 cx23885_user_ctrls[] = {
247 V4L2_CID_USER_CLASS,
248 V4L2_CID_BRIGHTNESS,
249 V4L2_CID_CONTRAST,
250 V4L2_CID_SATURATION,
251 V4L2_CID_HUE,
252 V4L2_CID_AUDIO_VOLUME,
253 V4L2_CID_AUDIO_MUTE,
254 0
255 };
256 EXPORT_SYMBOL(cx23885_user_ctrls);
257
258 static const u32 *ctrl_classes[] = {
259 cx23885_user_ctrls,
260 NULL
261 };
262
263 void cx23885_video_wakeup(struct cx23885_dev *
264 struct cx23885_dmaqueue *q, u
265 {
266 struct cx23885_buffer *buf;
267 int bc;
268
269 for (bc = 0;; bc++) {
270 if (list_empty(&q->active))
271 break;
272 buf = list_entry(q->active.nex
273 struct cx2388
274
275 /* count comes from the hw and
276 * this trick handles wrap-aro
277 * up to 32767 buffers in flig
278 if ((s16) (count - buf->count)
279 break;
280
281 do_gettimeofday(&buf->vb.ts);
282 dprintk(2, "[%p/%d] wakeup reg
283 count, buf->count);
284 buf->vb.state = VIDEOBUF_DONE;
285 list_del(&buf->vb.queue);
286 wake_up(&buf->vb.done);
287 }
288 if (list_empty(&q->active)) {
289 del_timer(&q->timeout);
290 } else {
291 mod_timer(&q->timeout, jiffies
292 }
293 if (bc != 1)
294 printk(KERN_ERR "%s: %d buffer
295 __FUNCTION__, bc);
296 }
297
298 int cx23885_set_tvnorm(struct cx23885_dev *dev
299 {
300 dprintk(1, "%s(norm = 0x%08x) name: [%
301 __FUNCTION__,
302 (unsigned int)norm,
303 v4l2_norm_to_name(norm));
304
305 dev->tvnorm = norm;
306
307 /* Tell the analog tuner/demods */
308 cx23885_call_i2c_clients(&dev->i2c_bus
309
310 /* Tell the internal A/V decoder */
311 cx23885_call_i2c_clients(&dev->i2c_bus
312
313 return 0;
314 }
315
316 struct video_device *cx23885_vdev_init(struct
317 struct pci
318 struct vid
319 char *type
320 {
321 struct video_device *vfd;
322 dprintk(1, "%s()\n", __FUNCTION__);
323
324 vfd = video_device_alloc();
325 if (NULL == vfd)
326 return NULL;
327 *vfd = *template;
328 vfd->minor = -1;
329 vfd->dev = &pci->dev;
330 vfd->release = video_device_release;
331 snprintf(vfd->name, sizeof(vfd->name),
332 dev->name, type, cx23885_boar
333 return vfd;
334 }
335
336 int cx23885_ctrl_query(struct v4l2_queryctrl *
337 {
338 int i;
339
340 if (qctrl->id < V4L2_CID_BASE ||
341 qctrl->id >= V4L2_CID_LASTP1)
342 return -EINVAL;
343 for (i = 0; i < CX23885_CTLS; i++)
344 if (cx23885_ctls[i].v.id == qc
345 break;
346 if (i == CX23885_CTLS) {
347 *qctrl = no_ctl;
348 return 0;
349 }
350 *qctrl = cx23885_ctls[i].v;
351 return 0;
352 }
353 EXPORT_SYMBOL(cx23885_ctrl_query);
354
355 /* -------------------------------------------
356 /* resource management
357
358 static int res_get(struct cx23885_dev *dev, st
359 unsigned int bit)
360 {
361 dprintk(1, "%s()\n", __FUNCTION__);
362 if (fh->resources & bit)
363 /* have it already allocated *
364 return 1;
365
366 /* is it free? */
367 mutex_lock(&dev->lock);
368 if (dev->resources & bit) {
369 /* no, someone else uses it */
370 mutex_unlock(&dev->lock);
371 return 0;
372 }
373 /* it's free, grab it */
374 fh->resources |= bit;
375 dev->resources |= bit;
376 dprintk(1, "res: get %d\n", bit);
377 mutex_unlock(&dev->lock);
378 return 1;
379 }
380
381 static int res_check(struct cx23885_fh *fh, un
382 {
383 return (fh->resources & bit);
384 }
385
386 static int res_locked(struct cx23885_dev *dev,
387 {
388 return (dev->resources & bit);
389 }
390
391 static void res_free(struct cx23885_dev *dev,
392 unsigned int bits)
393 {
394 BUG_ON((fh->resources & bits) != bits)
395 dprintk(1, "%s()\n", __FUNCTION__);
396
397 mutex_lock(&dev->lock);
398 fh->resources &= ~bits;
399 dev->resources &= ~bits;
400 dprintk(1, "res: put %d\n", bits);
401 mutex_unlock(&dev->lock);
402 }
403
404 int cx23885_video_mux(struct cx23885_dev *dev,
405 {
406 struct v4l2_routing route;
407 memset(&route, 0, sizeof(route));
408
409 dprintk(1, "%s() video_mux: %d [vmux=%
410 __FUNCTION__,
411 input, INPUT(input)->vmux,
412 INPUT(input)->gpio0, INPUT(inp
413 INPUT(input)->gpio2, INPUT(inp
414 dev->input = input;
415
416 route.input = INPUT(input)->vmux;
417
418 /* Tell the internal A/V decoder */
419 cx23885_call_i2c_clients(&dev->i2c_bus
420 VIDIOC_INT_S_VIDEO_ROUTING, &r
421
422 return 0;
423 }
424 EXPORT_SYMBOL(cx23885_video_mux);
425
426 /* -------------------------------------------
427 int cx23885_set_scale(struct cx23885_dev *dev,
428 unsigned int height, enum v4l2_field f
429 {
430 dprintk(1, "%s()\n", __FUNCTION__);
431 return 0;
432 }
433
434 static int cx23885_start_video_dma(struct cx23
435 struct cx23885_dmaq
436 struct cx23885_buff
437 {
438 dprintk(1, "%s()\n", __FUNCTION__);
439
440 /* setup fifo + format */
441 cx23885_sram_channel_setup(dev, &dev->
442 buf->bpl, buf-
443 cx23885_set_scale(dev, buf->vb.width,
444
445 /* reset counter */
446 cx_write(VID_A_GPCNT_CTL, 3);
447 q->count = 1;
448
449 /* enable irq */
450 cx_set(PCI_INT_MSK, cx_read(PCI_INT_MS
451 cx_set(VID_A_INT_MSK, 0x000011);
452
453 /* start dma */
454 cx_set(DEV_CNTRL2, (1<<5));
455 cx_set(VID_A_DMA_CTL, 0x11); /* FIFO a
456
457 return 0;
458 }
459
460
461 static int cx23885_restart_video_queue(struct
462 struct cx23885_
463 {
464 struct cx23885_buffer *buf, *prev;
465 struct list_head *item;
466 dprintk(1, "%s()\n", __FUNCTION__);
467
468 if (!list_empty(&q->active)) {
469 buf = list_entry(q->active.nex
470 vb.queue);
471 dprintk(2, "restart_queue [%p/
472 buf, buf->vb.i);
473 cx23885_start_video_dma(dev, q
474 list_for_each(item, &q->active
475 buf = list_entry(item,
476 vb.queue);
477 buf->count = q->cou
478 }
479 mod_timer(&q->timeout, jiffies
480 return 0;
481 }
482
483 prev = NULL;
484 for (;;) {
485 if (list_empty(&q->queued))
486 return 0;
487 buf = list_entry(q->queued.nex
488 vb.queue);
489 if (NULL == prev) {
490 list_move_tail(&buf->v
491 cx23885_start_video_dm
492 buf->vb.state = VIDEOB
493 buf->count = q->cou
494 mod_timer(&q->timeout,
495 dprintk(2, "[%p/%d] re
496 buf, buf->vb.i
497
498 } else if (prev->vb.width ==
499 prev->vb.height ==
500 prev->fmt ==
501 list_move_tail(&buf->v
502 buf->vb.state = VIDEOB
503 buf->count = q->cou
504 prev->risc.jmp[1] = cp
505 prev->risc.jmp[2] = cp
506 dprintk(2, "[%p/%d] re
507 buf, buf->vb.i
508 } else {
509 return 0;
510 }
511 prev = buf;
512 }
513 }
514
515 static int buffer_setup(struct videobuf_queue
516 unsigned int *size)
517 {
518 struct cx23885_fh *fh = q->priv_data;
519
520 *size = fh->fmt->depth*fh->width*fh->h
521 if (0 == *count)
522 *count = 32;
523 while (*size * *count > vid_limit * 10
524 (*count)--;
525 return 0;
526 }
527
528 static int buffer_prepare(struct videobuf_queu
529 enum v4l2_field field)
530 {
531 struct cx23885_fh *fh = q->priv_data;
532 struct cx23885_dev *dev = fh->dev;
533 struct cx23885_buffer *buf =
534 container_of(vb, struct cx2388
535 int rc, init_buffer = 0;
536 u32 line0_offset, line1_offset;
537 struct videobuf_dmabuf *dma = videobuf
538
539 BUG_ON(NULL == fh->fmt);
540 if (fh->width < 48 || fh->width > no
541 fh->height < 32 || fh->height > no
542 return -EINVAL;
543 buf->vb.size = (fh->width * fh->height
544 if (0 != buf->vb.baddr && buf->vb.bs
545 return -EINVAL;
546
547 if (buf->fmt != fh->fmt ||
548 buf->vb.width != fh->width ||
549 buf->vb.height != fh->height ||
550 buf->vb.field != field) {
551 buf->fmt = fh->fmt;
552 buf->vb.width = fh->width;
553 buf->vb.height = fh->height;
554 buf->vb.field = field;
555 init_buffer = 1;
556 }
557
558 if (VIDEOBUF_NEEDS_INIT == buf->vb.sta
559 init_buffer = 1;
560 rc = videobuf_iolock(q, &buf->
561 if (0 != rc)
562 goto fail;
563 }
564
565 if (init_buffer) {
566 buf->bpl = buf->vb.width * buf
567 switch (buf->vb.field) {
568 case V4L2_FIELD_TOP:
569 cx23885_risc_buffer(de
570 dma->
571 buf->
572 break;
573 case V4L2_FIELD_BOTTOM:
574 cx23885_risc_buffer(de
575 dma->
576 buf->
577 break;
578 case V4L2_FIELD_INTERLACED:
579 if (dev->tvnorm & V4L2
580 /* cx25840 tra
581 dprintk(1, "%s
582 __FUNC
583 line0_offset =
584 line1_offset =
585 } else {
586 /* All other f
587 dprintk(1, "%s
588 __FUNC
589 line0_offset =
590 line1_offset =
591 }
592 cx23885_risc_buffer(de
593 dma->s
594 line1_
595 buf->b
596 buf->v
597 break;
598 case V4L2_FIELD_SEQ_TB:
599 cx23885_risc_buffer(de
600 dma->
601 0, bu
602 buf->
603 buf->
604 break;
605 case V4L2_FIELD_SEQ_BT:
606 cx23885_risc_buffer(de
607 dma->
608 buf->
609 buf->
610 buf->
611 break;
612 default:
613 BUG();
614 }
615 }
616 dprintk(2, "[%p/%d] buffer_prep - %dx%
617 buf, buf->vb.i,
618 fh->width, fh->height, fh->fmt
619 (unsigned long)buf->risc.dma);
620
621 buf->vb.state = VIDEOBUF_PREPARED;
622 return 0;
623
624 fail:
625 cx23885_free_buffer(q, buf);
626 return rc;
627 }
628
629 static void buffer_queue(struct videobuf_queue
630 {
631 struct cx23885_buffer *buf = contain
632 struct cx23885_buffer, vb);
633 struct cx23885_buffer *prev;
634 struct cx23885_fh *fh = vq->pr
635 struct cx23885_dev *dev = fh->de
636 struct cx23885_dmaqueue *q = &dev->
637
638 /* add jump to stopper */
639 buf->risc.jmp[0] = cpu_to_le32(RISC_JU
640 buf->risc.jmp[1] = cpu_to_le32(q->stop
641 buf->risc.jmp[2] = cpu_to_le32(0); /*
642
643 if (!list_empty(&q->queued)) {
644 list_add_tail(&buf->vb.queue,
645 buf->vb.state = VIDEOBUF_QUEUE
646 dprintk(2, "[%p/%d] buffer_que
647 buf, buf->vb.i);
648
649 } else if (list_empty(&q->active)) {
650 list_add_tail(&buf->vb.queue,
651 cx23885_start_video_dma(dev, q
652 buf->vb.state = VIDEOBUF_ACTIV
653 buf->count = q->count++;
654 mod_timer(&q->timeout, jiffies
655 dprintk(2, "[%p/%d] buffer_que
656 buf, buf->vb.i);
657
658 } else {
659 prev = list_entry(q->active.pr
660 vb.queue);
661 if (prev->vb.width == buf->vb
662 prev->vb.height == buf->vb
663 prev->fmt == buf->fm
664 list_add_tail(&buf->vb
665 buf->vb.state = VIDEOB
666 buf->count = q->cou
667 prev->risc.jmp[1] = cp
668 /* 64 bit bits 63-32 *
669 prev->risc.jmp[2] = cp
670 dprintk(2, "[%p/%d] bu
671 buf, buf->vb.i
672
673 } else {
674 list_add_tail(&buf->vb
675 buf->vb.state = VIDEOB
676 dprintk(2, "[%p/%d] bu
677 buf, buf->vb.i
678 }
679 }
680 }
681
682 static void buffer_release(struct videobuf_que
683 struct videobuf_buffer *vb)
684 {
685 struct cx23885_buffer *buf = container
686 struct cx23885_buffer, vb);
687
688 cx23885_free_buffer(q, buf);
689 }
690
691 static struct videobuf_queue_ops cx23885_video
692 .buf_setup = buffer_setup,
693 .buf_prepare = buffer_prepare,
694 .buf_queue = buffer_queue,
695 .buf_release = buffer_release,
696 };
697
698 static struct videobuf_queue *get_queue(struct
699 {
700 switch (fh->type) {
701 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
702 return &fh->vidq;
703 case V4L2_BUF_TYPE_VBI_CAPTURE:
704 return &fh->vbiq;
705 default:
706 BUG();
707 return NULL;
708 }
709 }
710
711 static int get_resource(struct cx23885_fh *fh)
712 {
713 switch (fh->type) {
714 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
715 return RESOURCE_VIDEO;
716 case V4L2_BUF_TYPE_VBI_CAPTURE:
717 return RESOURCE_VBI;
718 default:
719 BUG();
720 return 0;
721 }
722 }
723
724 static int video_open(struct inode *inode, str
725 {
726 int minor = iminor(inode);
727 struct cx23885_dev *h, *dev = NULL;
728 struct cx23885_fh *fh;
729 struct list_head *list;
730 enum v4l2_buf_type type = 0;
731 int radio = 0;
732
733 list_for_each(list, &cx23885_devlist)
734 h = list_entry(list, struct cx
735 if (h->video_dev->minor == min
736 dev = h;
737 type = V4L2_BUF_TYPE_V
738 }
739 if (h->vbi_dev &&
740 h->vbi_dev->minor == minor)
741 dev = h;
742 type = V4L2_BUF_TYPE_V
743 }
744 if (h->radio_dev &&
745 h->radio_dev->minor == min
746 radio = 1;
747 dev = h;
748 }
749 }
750 if (NULL == dev)
751 return -ENODEV;
752
753 dprintk(1, "open minor=%d radio=%d typ
754 minor, radio, v4l2_type_names[
755
756 /* allocate + initialize per filehandl
757 fh = kzalloc(sizeof(*fh), GFP_KERNEL);
758 if (NULL == fh)
759 return -ENOMEM;
760 file->private_data = fh;
761 fh->dev = dev;
762 fh->radio = radio;
763 fh->type = type;
764 fh->width = 320;
765 fh->height = 240;
766 fh->fmt = format_by_fourcc(V4L2_P
767
768 videobuf_queue_pci_init(&fh->vidq, &cx
769 dev->pci, &dev->sl
770 V4L2_BUF_TYPE_VIDE
771 V4L2_FIELD_INTERLA
772 sizeof(struct cx23
773 fh);
774
775 dprintk(1, "post videobuf_queue_init()
776
777
778 return 0;
779 }
780
781 static ssize_t video_read(struct file *file, c
782 size_t count, loff_t *ppos)
783 {
784 struct cx23885_fh *fh = file->private_
785
786 switch (fh->type) {
787 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
788 if (res_locked(fh->dev, RESOUR
789 return -EBUSY;
790 return videobuf_read_one(&fh->
791 file-
792 case V4L2_BUF_TYPE_VBI_CAPTURE:
793 if (!res_get(fh->dev, fh, RESO
794 return -EBUSY;
795 return videobuf_read_stream(&f
796 fi
797 default:
798 BUG();
799 return 0;
800 }
801 }
802
803 static unsigned int video_poll(struct file *fi
804 struct poll_table_struct *wait)
805 {
806 struct cx23885_fh *fh = file->private_
807 struct cx23885_buffer *buf;
808
809 if (V4L2_BUF_TYPE_VBI_CAPTURE == fh->t
810 if (!res_get(fh->dev, fh, RESO
811 return POLLERR;
812 return videobuf_poll_stream(fi
813 }
814
815 if (res_check(fh, RESOURCE_VIDEO)) {
816 /* streaming capture */
817 if (list_empty(&fh->vidq.strea
818 return POLLERR;
819 buf = list_entry(fh->vidq.stre
820 struct cx23885_buffer,
821 } else {
822 /* read() capture */
823 buf = (struct cx23885_buffer *
824 if (NULL == buf)
825 return POLLERR;
826 }
827 poll_wait(file, &buf->vb.done, wait);
828 if (buf->vb.state == VIDEOBUF_DONE ||
829 buf->vb.state == VIDEOBUF_ERROR)
830 return POLLIN|POLLRDNORM;
831 return 0;
832 }
833
834 static int video_release(struct inode *inode,
835 {
836 struct cx23885_fh *fh = file->private_
837 struct cx23885_dev *dev = fh->dev;
838
839 /* turn off overlay */
840 if (res_check(fh, RESOURCE_OVERLAY)) {
841 /* FIXME */
842 res_free(dev, fh, RESOURCE_OVE
843 }
844
845 /* stop video capture */
846 if (res_check(fh, RESOURCE_VIDEO)) {
847 videobuf_queue_cancel(&fh->vid
848 res_free(dev, fh, RESOURCE_VID
849 }
850 if (fh->vidq.read_buf) {
851 buffer_release(&fh->vidq, fh->
852 kfree(fh->vidq.read_buf);
853 }
854
855 /* stop vbi capture */
856 if (res_check(fh, RESOURCE_VBI)) {
857 if (fh->vbiq.streaming)
858 videobuf_streamoff(&fh
859 if (fh->vbiq.reading)
860 videobuf_read_stop(&fh
861 res_free(dev, fh, RESOURCE_VBI
862 }
863
864 videobuf_mmap_free(&fh->vidq);
865 file->private_data = NULL;
866 kfree(fh);
867
868 /* We are not putting the tuner to sle
869 * we want to use the mpeg encoder in
870 * tuner video. Closing this will resu
871 */
872
873 return 0;
874 }
875
876 static int video_mmap(struct file *file, struc
877 {
878 struct cx23885_fh *fh = file->private_
879
880 return videobuf_mmap_mapper(get_queue(
881 }
882
883 /* -------------------------------------------
884 /* VIDEO CTRL IOCTLS
885
886 int cx23885_get_control(struct cx23885_dev *de
887 {
888 dprintk(1, "%s() calling cx25840(VIDIO
889 cx23885_call_i2c_clients(&dev->i2c_bus
890 return 0;
891 }
892 EXPORT_SYMBOL(cx23885_get_control);
893
894 int cx23885_set_control(struct cx23885_dev *de
895 {
896 dprintk(1, "%s() calling cx25840(VIDIO
897 " (disabled - no action)\n", _
898 return 0;
899 }
900 EXPORT_SYMBOL(cx23885_set_control);
901
902 static void init_controls(struct cx23885_dev *
903 {
904 struct v4l2_control ctrl;
905 int i;
906
907 for (i = 0; i < CX23885_CTLS; i++) {
908 ctrl.id = cx23885_ctls[i].v.id
909 ctrl.value = cx23885_ctls[i].v
910
911 cx23885_set_control(dev, &ctrl
912 }
913 }
914
915 /* -------------------------------------------
916 /* VIDEO IOCTLS
917
918 static int vidioc_g_fmt_cap(struct file *file,
919 struct v4l2_format *f)
920 {
921 struct cx23885_fh *fh = priv;
922
923 f->fmt.pix.width = fh->width;
924 f->fmt.pix.height = fh->height;
925 f->fmt.pix.field = fh->vidq.fie
926 f->fmt.pix.pixelformat = fh->fmt->fou
927 f->fmt.pix.bytesperline =
928 (f->fmt.pix.width * fh->fmt->d
929 f->fmt.pix.sizeimage =
930 f->fmt.pix.height * f->fmt.pix
931
932 return 0;
933 }
934
935 static int vidioc_try_fmt_cap(struct file *fil
936 struct v4l2_format *f)
937 {
938 struct cx23885_dev *dev = ((struct cx2
939 struct cx23885_fmt *fmt;
940 enum v4l2_field field;
941 unsigned int maxw, maxh;
942
943 fmt = format_by_fourcc(f->fmt.pix.pixe
944 if (NULL == fmt)
945 return -EINVAL;
946
947 field = f->fmt.pix.field;
948 maxw = norm_maxw(dev->tvnorm);
949 maxh = norm_maxh(dev->tvnorm);
950
951 if (V4L2_FIELD_ANY == field) {
952 field = (f->fmt.pix.height > m
953 ? V4L2_FIELD_INTERLACE
954 : V4L2_FIELD_BOTTOM;
955 }
956
957 switch (field) {
958 case V4L2_FIELD_TOP:
959 case V4L2_FIELD_BOTTOM:
960 maxh = maxh / 2;
961 break;
962 case V4L2_FIELD_INTERLACED:
963 break;
964 default:
965 return -EINVAL;
966 }
967
968 f->fmt.pix.field = field;
969 if (f->fmt.pix.height < 32)
970 f->fmt.pix.height = 32;
971 if (f->fmt.pix.height > maxh)
972 f->fmt.pix.height = maxh;
973 if (f->fmt.pix.width < 48)
974 f->fmt.pix.width = 48;
975 if (f->fmt.pix.width > maxw)
976 f->fmt.pix.width = maxw;
977 f->fmt.pix.width &= ~0x03;
978 f->fmt.pix.bytesperline =
979 (f->fmt.pix.width * fmt->depth
980 f->fmt.pix.sizeimage =
981 f->fmt.pix.height * f->fmt.pix
982
983 return 0;
984 }
985
986 static int vidioc_s_fmt_cap(struct file *file,
987 struct v4l2_format *f)
988 {
989 struct cx23885_fh *fh = priv;
990 struct cx23885_dev *dev = ((struct cx
991 int err;
992
993 dprintk(2, "%s()\n", __FUNCTION__);
994 err = vidioc_try_fmt_cap(file, priv, f
995
996 if (0 != err)
997 return err;
998 fh->fmt = format_by_fourcc(f->f
999 fh->width = f->fmt.pix.width;
1000 fh->height = f->fmt.pix.height;
1001 fh->vidq.field = f->fmt.pix.field;
1002 dprintk(2, "%s() width=%d height=%d f
1003 fh->width, fh->height, fh->vi
1004 cx23885_call_i2c_clients(&dev->i2c_bu
1005 return 0;
1006 }
1007
1008 static int vidioc_querycap(struct file *file,
1009 struct v4l2_capability *cap)
1010 {
1011 struct cx23885_dev *dev = ((struct c
1012
1013 strcpy(cap->driver, "cx23885");
1014 strlcpy(cap->card, cx23885_boards[dev
1015 sizeof(cap->card));
1016 sprintf(cap->bus_info, "PCIe:%s", pci
1017 cap->version = CX23885_VERSION_CODE;
1018 cap->capabilities =
1019 V4L2_CAP_VIDEO_CAPTURE |
1020 V4L2_CAP_READWRITE |
1021 V4L2_CAP_STREAMING |
1022 V4L2_CAP_VBI_CAPTURE;
1023 if (UNSET != dev->tuner_type)
1024 cap->capabilities |= V4L2_CAP
1025 return 0;
1026 }
1027
1028 static int vidioc_enum_fmt_cap(struct file *f
1029 struct v4l2_fmtdesc *f)
1030 {
1031 if (unlikely(f->index >= ARRAY_SIZE(f
1032 return -EINVAL;
1033
1034 strlcpy(f->description, formats[f->in
1035 sizeof(f->description));
1036 f->pixelformat = formats[f->index].fo
1037
1038 return 0;
1039 }
1040
1041 #ifdef CONFIG_VIDEO_V4L1_COMPAT
1042 static int vidiocgmbuf(struct file *file, voi
1043 struct video_mbuf *mbuf)
1044 {
1045 struct cx23885_fh *fh = priv;
1046 struct videobuf_queue *q;
1047 struct v4l2_requestbuffers req;
1048 unsigned int i;
1049 int err;
1050
1051 q = get_queue(fh);
1052 memset(&req, 0, sizeof(req));
1053 req.type = q->type;
1054 req.count = 8;
1055 req.memory = V4L2_MEMORY_MMAP;
1056 err = videobuf_reqbufs(q, &req);
1057 if (err < 0)
1058 return err;
1059
1060 mbuf->frames = req.count;
1061 mbuf->size = 0;
1062 for (i = 0; i < mbuf->frames; i++) {
1063 mbuf->offsets[i] = q->bufs[i
1064 mbuf->size += q->bufs[i
1065 }
1066 return 0;
1067 }
1068 #endif
1069
1070 static int vidioc_reqbufs(struct file *file,
1071 struct v4l2_requestbuffers *p)
1072 {
1073 struct cx23885_fh *fh = priv;
1074 return (videobuf_reqbufs(get_queue(fh
1075 }
1076
1077 static int vidioc_querybuf(struct file *file,
1078 struct v4l2_buffer *p)
1079 {
1080 struct cx23885_fh *fh = priv;
1081 return (videobuf_querybuf(get_queue(f
1082 }
1083
1084 static int vidioc_qbuf(struct file *file, voi
1085 struct v4l2_buffer *p)
1086 {
1087 struct cx23885_fh *fh = priv;
1088 return (videobuf_qbuf(get_queue(fh),
1089 }
1090
1091 static int vidioc_dqbuf(struct file *file, vo
1092 struct v4l2_buffer *p)
1093 {
1094 struct cx23885_fh *fh = priv;
1095 return (videobuf_dqbuf(get_queue(fh),
1096 file->f_flags
1097 }
1098
1099 static int vidioc_streamon(struct file *file,
1100 enum v4l2_buf_type i)
1101 {
1102 struct cx23885_fh *fh = priv;
1103 struct cx23885_dev *dev = fh->dev;
1104 dprintk(1, "%s()\n", __FUNCTION__);
1105
1106 if (unlikely(fh->type != V4L2_BUF_TYP
1107 return -EINVAL;
1108 if (unlikely(i != fh->type))
1109 return -EINVAL;
1110
1111 if (unlikely(!res_get(dev, fh, get_re
1112 return -EBUSY;
1113 return videobuf_streamon(get_queue(fh
1114 }
1115
1116 static int vidioc_streamoff(struct file *file
1117 {
1118 struct cx23885_fh *fh = priv;
1119 struct cx23885_dev *dev = fh->dev;
1120 int err, res;
1121 dprintk(1, "%s()\n", __FUNCTION__);
1122
1123 if (fh->type != V4L2_BUF_TYPE_VIDEO_C
1124 return -EINVAL;
1125 if (i != fh->type)
1126 return -EINVAL;
1127
1128 res = get_resource(fh);
1129 err = videobuf_streamoff(get_queue(fh
1130 if (err < 0)
1131 return err;
1132 res_free(dev, fh, res);
1133 return 0;
1134 }
1135
1136 static int vidioc_s_std(struct file *file, vo
1137 {
1138 struct cx23885_dev *dev = ((struct cx
1139 dprintk(1, "%s()\n", __FUNCTION__);
1140
1141 mutex_lock(&dev->lock);
1142 cx23885_set_tvnorm(dev, *tvnorms);
1143 mutex_unlock(&dev->lock);
1144
1145 return 0;
1146 }
1147
1148 int cx23885_enum_input(struct cx23885_dev *de
1149 {
1150 static const char *iname[] = {
1151 [CX23885_VMUX_COMPOSITE1] = "
1152 [CX23885_VMUX_COMPOSITE2] = "
1153 [CX23885_VMUX_COMPOSITE3] = "
1154 [CX23885_VMUX_COMPOSITE4] = "
1155 [CX23885_VMUX_SVIDEO] = "
1156 [CX23885_VMUX_TELEVISION] = "
1157 [CX23885_VMUX_CABLE] = "
1158 [CX23885_VMUX_DVB] = "
1159 [CX23885_VMUX_DEBUG] = "
1160 };
1161 unsigned int n;
1162 dprintk(1, "%s()\n", __FUNCTION__);
1163
1164 n = i->index;
1165 if (n >= 4)
1166 return -EINVAL;
1167
1168 if (0 == INPUT(n)->type)
1169 return -EINVAL;
1170
1171 memset(i, 0, sizeof(*i));
1172 i->index = n;
1173 i->type = V4L2_INPUT_TYPE_CAMERA;
1174 strcpy(i->name, iname[INPUT(n)->type]
1175 if ((CX23885_VMUX_TELEVISION == INPUT
1176 (CX23885_VMUX_CABLE == INPUT(
1177 i->type = V4L2_INPUT_TYPE_TUN
1178 i->std = CX23885_NORMS;
1179 return 0;
1180 }
1181 EXPORT_SYMBOL(cx23885_enum_input);
1182
1183 static int vidioc_enum_input(struct file *fil
1184 struct v4l2_i
1185 {
1186 struct cx23885_dev *dev = ((struct cx
1187 dprintk(1, "%s()\n", __FUNCTION__);
1188 return cx23885_enum_input(dev, i);
1189 }
1190
1191 static int vidioc_g_input(struct file *file,
1192 {
1193 struct cx23885_dev *dev = ((struct cx
1194
1195 *i = dev->input;
1196 dprintk(1, "%s() returns %d\n", __FUN
1197 return 0;
1198 }
1199
1200 static int vidioc_s_input(struct file *file,
1201 {
1202 struct cx23885_dev *dev = ((struct cx
1203
1204 dprintk(1, "%s(%d)\n", __FUNCTION__,
1205
1206 if (i >= 4) {
1207 dprintk(1, "%s() -EINVAL\n",
1208 return -EINVAL;
1209 }
1210
1211 mutex_lock(&dev->lock);
1212 cx23885_video_mux(dev, i);
1213 mutex_unlock(&dev->lock);
1214 return 0;
1215 }
1216
1217 static int vidioc_queryctrl(struct file *file
1218 struct v4l2_q
1219 {
1220 qctrl->id = v4l2_ctrl_next(ctrl_class
1221 if (unlikely(qctrl->id == 0))
1222 return -EINVAL;
1223 return cx23885_ctrl_query(qctrl);
1224 }
1225
1226 static int vidioc_g_ctrl(struct file *file, v
1227 struct v4l2_c
1228 {
1229 struct cx23885_dev *dev = ((struct cx
1230
1231 return cx23885_get_control(dev, ctl);
1232 }
1233
1234 static int vidioc_s_ctrl(struct file *file, v
1235 struct v4l2_c
1236 {
1237 struct cx23885_dev *dev = ((struct cx
1238
1239 return cx23885_set_control(dev, ctl);
1240 }
1241
1242 static int vidioc_g_tuner(struct file *file,
1243 struct v4l2_t
1244 {
1245 struct cx23885_dev *dev = ((struct cx
1246
1247 if (unlikely(UNSET == dev->tuner_type
1248 return -EINVAL;
1249 if (0 != t->index)
1250 return -EINVAL;
1251
1252 strcpy(t->name, "Television");
1253 t->type = V4L2_TUNER_ANALOG_TV;
1254 t->capability = V4L2_TUNER_CAP_NORM;
1255 t->rangehigh = 0xffffffffUL;
1256 t->signal = 0xffff ; /* LOCKED */
1257 return 0;
1258 }
1259
1260 static int vidioc_s_tuner(struct file *file,
1261 struct v4l2_t
1262 {
1263 struct cx23885_dev *dev = ((struct cx
1264
1265 if (UNSET == dev->tuner_type)
1266 return -EINVAL;
1267 if (0 != t->index)
1268 return -EINVAL;
1269 return 0;
1270 }
1271
1272 static int vidioc_g_frequency(struct file *fi
1273 struct v4l2_f
1274 {
1275 struct cx23885_fh *fh = priv;
1276 struct cx23885_dev *dev = fh->dev;
1277
1278 if (unlikely(UNSET == dev->tuner_type
1279 return -EINVAL;
1280
1281 /* f->type = fh->radio ? V4L2_TUNER_R
1282 f->type = fh->radio ? V4L2_TUNER_RADI
1283 f->frequency = dev->freq;
1284
1285 cx23885_call_i2c_clients(&dev->i2c_bu
1286
1287 return 0;
1288 }
1289
1290 int cx23885_set_freq(struct cx23885_dev *dev,
1291 {
1292 if (unlikely(UNSET == dev->tuner_type
1293 return -EINVAL;
1294 if (unlikely(f->tuner != 0))
1295 return -EINVAL;
1296
1297 mutex_lock(&dev->lock);
1298 dev->freq = f->frequency;
1299
1300 cx23885_call_i2c_clients(&dev->i2c_bu
1301
1302 /* When changing channels it is requi
1303 msleep(10);
1304
1305 mutex_unlock(&dev->lock);
1306
1307 return 0;
1308 }
1309 EXPORT_SYMBOL(cx23885_set_freq);
1310
1311 static int vidioc_s_frequency(struct file *fi
1312 struct v4l2_f
1313 {
1314 struct cx23885_fh *fh = priv;
1315 struct cx23885_dev *dev = fh->dev;
1316
1317 if (unlikely(0 == fh->radio && f->typ
1318 return -EINVAL;
1319 if (unlikely(1 == fh->radio && f->typ
1320 return -EINVAL;
1321
1322 return
1323 cx23885_set_freq(dev, f);
1324 }
1325
1326 #ifdef CONFIG_VIDEO_ADV_DEBUG
1327 static int vidioc_g_register(struct file *fil
1328 struct v4l2_r
1329 {
1330 struct cx23885_dev *dev = ((struct cx
1331
1332 if (!v4l2_chip_match_host(reg->match_
1333 return -EINVAL;
1334
1335 cx23885_call_i2c_clients(&dev->i2c_bu
1336
1337 return 0;
1338 }
1339
1340 static int vidioc_s_register(struct file *fil
1341 struct v4l2_r
1342 {
1343 struct cx23885_dev *dev = ((struct cx
1344
1345 if (!v4l2_chip_match_host(reg->match_
1346 return -EINVAL;
1347
1348 cx23885_call_i2c_clients(&dev->i2c_bu
1349
1350 return 0;
1351 }
1352 #endif
1353
1354 /* ------------------------------------------
1355
1356 static void cx23885_vid_timeout(unsigned long
1357 {
1358 struct cx23885_dev *dev = (struct cx2
1359 struct cx23885_dmaqueue *q = &dev->vi
1360 struct cx23885_buffer *buf;
1361 unsigned long flags;
1362
1363 cx23885_sram_channel_dump(dev, &dev->
1364
1365 cx_clear(VID_A_DMA_CTL, 0x11);
1366
1367 spin_lock_irqsave(&dev->slock, flags)
1368 while (!list_empty(&q->active)) {
1369 buf = list_entry(q->active.ne
1370 struct cx23885_buffer
1371 list_del(&buf->vb.queue);
1372 buf->vb.state = VIDEOBUF_ERRO
1373 wake_up(&buf->vb.done);
1374 printk(KERN_ERR "%s/0: [%p/%d
1375 dev->name, buf, buf->
1376 (unsigned long)buf->r
1377 }
1378 cx23885_restart_video_queue(dev, q);
1379 spin_unlock_irqrestore(&dev->slock, f
1380 }
1381
1382 int cx23885_video_irq(struct cx23885_dev *dev
1383 {
1384 u32 mask, count;
1385 int handled = 0;
1386
1387 mask = cx_read(VID_A_INT_MSK);
1388 if (0 == (status & mask))
1389 return handled;
1390 cx_write(VID_A_INT_STAT, status);
1391
1392 dprintk(2, "%s() status = 0x%08x\n",
1393 /* risc op code error */
1394 if (status & (1 << 16)) {
1395 printk(KERN_WARNING "%s/0: vi
1396 dev->name);
1397 cx_clear(VID_A_DMA_CTL, 0x11)
1398 cx23885_sram_channel_dump(dev
1399 }
1400
1401 /* risc1 y */
1402 if (status & 0x01) {
1403 spin_lock(&dev->slock);
1404 count = cx_read(VID_A_GPCNT);
1405 cx23885_video_wakeup(dev, &de
1406 spin_unlock(&dev->slock);
1407 handled++;
1408 }
1409 /* risc2 y */
1410 if (status & 0x10) {
1411 dprintk(2, "stopper video\n")
1412 spin_lock(&dev->slock);
1413 cx23885_restart_video_queue(d
1414 spin_unlock(&dev->slock);
1415 handled++;
1416 }
1417
1418 return handled;
1419 }
1420
1421 /* ------------------------------------------
1422 /* exported stuff
1423
1424 static const struct file_operations video_fop
1425 .owner = THIS_MODULE,
1426 .open = video_open,
1427 .release = video_release,
1428 .read = video_read,
1429 .poll = video_poll,
1430 .mmap = video_mmap,
1431 .ioctl = video_ioctl2,
1432 .compat_ioctl = v4l_compat_ioctl32,
1433 .llseek = no_llseek,
1434 };
1435
1436 static struct video_device cx23885_vbi_templa
1437 static struct video_device cx23885_video_temp
1438 .name = "cx23885-vide
1439 .type = VID_TYPE_CAPT
1440 .fops = &video_fops,
1441 .minor = -1,
1442 .vidioc_querycap = vidioc_queryc
1443 .vidioc_enum_fmt_cap = vidioc_enum_f
1444 .vidioc_g_fmt_cap = vidioc_g_fmt_
1445 .vidioc_try_fmt_cap = vidioc_try_fm
1446 .vidioc_s_fmt_cap = vidioc_s_fmt_
1447 .vidioc_g_fmt_vbi = cx23885_vbi_f
1448 .vidioc_try_fmt_vbi = cx23885_vbi_f
1449 .vidioc_s_fmt_vbi = cx23885_vbi_f
1450 .vidioc_reqbufs = vidioc_reqbuf
1451 .vidioc_querybuf = vidioc_queryb
1452 .vidioc_qbuf = vidioc_qbuf,
1453 .vidioc_dqbuf = vidioc_dqbuf,
1454 .vidioc_s_std = vidioc_s_std,
1455 .vidioc_enum_input = vidioc_enum_i
1456 .vidioc_g_input = vidioc_g_inpu
1457 .vidioc_s_input = vidioc_s_inpu
1458 .vidioc_queryctrl = vidioc_queryc
1459 .vidioc_g_ctrl = vidioc_g_ctrl
1460 .vidioc_s_ctrl = vidioc_s_ctrl
1461 .vidioc_streamon = vidioc_stream
1462 .vidioc_streamoff = vidioc_stream
1463 #ifdef CONFIG_VIDEO_V4L1_COMPAT
1464 .vidiocgmbuf = vidiocgmbuf,
1465 #endif
1466 .vidioc_g_tuner = vidioc_g_tune
1467 .vidioc_s_tuner = vidioc_s_tune
1468 .vidioc_g_frequency = vidioc_g_freq
1469 .vidioc_s_frequency = vidioc_s_freq
1470 #ifdef CONFIG_VIDEO_ADV_DEBUG
1471 .vidioc_g_register = vidioc_g_regi
1472 .vidioc_s_register = vidioc_s_regi
1473 #endif
1474 .tvnorms = CX23885_NORMS
1475 .current_norm = V4L2_STD_NTSC
1476 };
1477
1478 static const struct file_operations radio_fop
1479 .owner = THIS_MODULE,
1480 .open = video_open,
1481 .release = video_release,
1482 .ioctl = video_ioctl2,
1483 .compat_ioctl = v4l_compat_ioctl32,
1484 .llseek = no_llseek,
1485 };
1486
1487
1488 void cx23885_video_unregister(struct cx23885_
1489 {
1490 dprintk(1, "%s()\n", __FUNCTION__);
1491 cx_clear(PCI_INT_MSK, 1);
1492
1493 if (dev->video_dev) {
1494 if (-1 != dev->video_dev->min
1495 video_unregister_devi
1496 else
1497 video_device_release(
1498 dev->video_dev = NULL;
1499
1500 btcx_riscmem_free(dev->pci, &
1501 }
1502 }
1503
1504 int cx23885_video_register(struct cx23885_dev
1505 {
1506 int err;
1507
1508 dprintk(1, "%s()\n", __FUNCTION__);
1509 spin_lock_init(&dev->slock);
1510
1511 /* Initialize VBI template */
1512 memcpy(&cx23885_vbi_template, &cx2388
1513 sizeof(cx23885_vbi_template))
1514 strcpy(cx23885_vbi_template.name, "cx
1515 cx23885_vbi_template.type = VID_TYPE_
1516
1517 dev->tvnorm = cx23885_video_template.
1518
1519 /* init video dma queues */
1520 INIT_LIST_HEAD(&dev->vidq.active);
1521 INIT_LIST_HEAD(&dev->vidq.queued);
1522 dev->vidq.timeout.function = cx23885_
1523 dev->vidq.timeout.data = (unsigned lo
1524 init_timer(&dev->vidq.timeout);
1525 cx23885_risc_stopper(dev->pci, &dev->
1526 VID_A_DMA_CTL, 0x11, 0x00);
1527
1528 /* Don't enable VBI yet */
1529 cx_set(PCI_INT_MSK, 1);
1530
1531
1532 /* register v4l devices */
1533 dev->video_dev = cx23885_vdev_init(de
1534 &cx23885_video_template, "vid
1535 err = video_register_device(dev->vide
1536 video_nr[
1537 if (err < 0) {
1538 printk(KERN_INFO "%s: can't r
1539 dev->name);
1540 goto fail_unreg;
1541 }
1542 printk(KERN_INFO "%s/0: registered de
1543 dev->name, dev->video_dev->min
1544 /* initial device configuration */
1545 mutex_lock(&dev->lock);
1546 cx23885_set_tvnorm(dev, dev->tvnorm);
1547 init_controls(dev);
1548 cx23885_video_mux(dev, 0);
1549 mutex_unlock(&dev->lock);
1550
1551 return 0;
1552
1553 fail_unreg:
1554 cx23885_video_unregister(dev);
1555 return err;
1556 }
1557
1558
| This page was automatically generated by the LXR engine. |