Lines Matching +full:input +full:- +full:depth

1 // SPDX-License-Identifier: GPL-2.0-or-later
7 * (c) 2003-04 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
9 * (c) 2005-2006 Mauro Carvalho Chehab <mchehab@kernel.org>
10 * - Multituner support
11 * - video_ioctl2 conversion
12 * - PAL/M fixes
24 #include <linux/dma-mapping.h>
29 #include <media/v4l2-common.h>
30 #include <media/v4l2-ioctl.h>
31 #include <media/v4l2-event.h>
39 /* ------------------------------------------------------------------ */
41 static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42 static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
43 static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
67 /* ------------------------------------------------------------------- */
74 .depth = 8,
79 .depth = 16,
84 .depth = 16,
89 .depth = 16,
94 .depth = 16,
99 .depth = 24,
104 .depth = 32,
110 .depth = 32,
115 .depth = 16,
120 .depth = 16,
135 /* ------------------------------------------------------------------- */
154 /* --- video --- */
243 /* --- audio --- */
280 /* ------------------------------------------------------------------ */
282 int cx88_video_mux(struct cx88_core *core, unsigned int input) in cx88_video_mux() argument
284 /* struct cx88_core *core = dev->core; */ in cx88_video_mux()
287 input, INPUT(input).vmux, in cx88_video_mux()
288 INPUT(input).gpio0, INPUT(input).gpio1, in cx88_video_mux()
289 INPUT(input).gpio2, INPUT(input).gpio3); in cx88_video_mux()
290 core->input = input; in cx88_video_mux()
291 cx_andor(MO_INPUT_FORMAT, 0x03 << 14, INPUT(input).vmux << 14); in cx88_video_mux()
292 cx_write(MO_GP3_IO, INPUT(input).gpio3); in cx88_video_mux()
293 cx_write(MO_GP0_IO, INPUT(input).gpio0); in cx88_video_mux()
294 cx_write(MO_GP1_IO, INPUT(input).gpio1); in cx88_video_mux()
295 cx_write(MO_GP2_IO, INPUT(input).gpio2); in cx88_video_mux()
297 switch (INPUT(input).type) { in cx88_video_mux()
316 if (INPUT(input).audioroute) { in cx88_video_mux()
320 * routes for different inputs. HVR-1300 surely does in cx88_video_mux()
322 if (core->sd_wm8775) { in cx88_video_mux()
324 INPUT(input).audioroute, 0, 0); in cx88_video_mux()
327 * cx2388's C-ADC is connected to the tuner only. in cx88_video_mux()
328 * When used with S-Video, that ADC is busy dealing with in cx88_video_mux()
331 if (INPUT(input).type != CX88_VMUX_TELEVISION && in cx88_video_mux()
332 INPUT(input).type != CX88_VMUX_CABLE) { in cx88_video_mux()
334 core->tvaudio = WW_I2SADC; in cx88_video_mux()
347 /* ------------------------------------------------------------------ */
353 struct cx88_core *core = dev->core; in start_video_dma()
357 buf->bpl, buf->risc.dma); in start_video_dma()
358 cx88_set_scale(core, core->width, core->height, core->field); in start_video_dma()
359 cx_write(MO_COLOR_CTRL, dev->fmt->cxformat | ColorFormatGamma); in start_video_dma()
363 q->count = 0; in start_video_dma()
366 cx_set(MO_PCI_INTMSK, core->pci_irqmask | PCI_INT_VIDINT); in start_video_dma()
390 struct cx88_core *core = dev->core; in stop_video_dma()
409 if (!list_empty(&q->active)) { in restart_video_queue()
410 buf = list_entry(q->active.next, struct cx88_buffer, list); in restart_video_queue()
412 buf, buf->vb.vb2_buf.index); in restart_video_queue()
418 /* ------------------------------------------------------------------ */
424 struct cx8800_dev *dev = q->drv_priv; in queue_setup()
425 struct cx88_core *core = dev->core; in queue_setup()
428 sizes[0] = (dev->fmt->depth * core->width * core->height) >> 3; in queue_setup()
436 struct cx8800_dev *dev = vb->vb2_queue->drv_priv; in buffer_prepare()
437 struct cx88_core *core = dev->core; in buffer_prepare()
441 buf->bpl = core->width * dev->fmt->depth >> 3; in buffer_prepare()
443 if (vb2_plane_size(vb, 0) < core->height * buf->bpl) in buffer_prepare()
444 return -EINVAL; in buffer_prepare()
445 vb2_set_plane_payload(vb, 0, core->height * buf->bpl); in buffer_prepare()
447 switch (core->field) { in buffer_prepare()
449 ret = cx88_risc_buffer(dev->pci, &buf->risc, in buffer_prepare()
450 sgt->sgl, 0, UNSET, in buffer_prepare()
451 buf->bpl, 0, core->height); in buffer_prepare()
454 ret = cx88_risc_buffer(dev->pci, &buf->risc, in buffer_prepare()
455 sgt->sgl, UNSET, 0, in buffer_prepare()
456 buf->bpl, 0, core->height); in buffer_prepare()
459 ret = cx88_risc_buffer(dev->pci, &buf->risc, in buffer_prepare()
460 sgt->sgl, in buffer_prepare()
461 0, buf->bpl * (core->height >> 1), in buffer_prepare()
462 buf->bpl, 0, in buffer_prepare()
463 core->height >> 1); in buffer_prepare()
466 ret = cx88_risc_buffer(dev->pci, &buf->risc, in buffer_prepare()
467 sgt->sgl, in buffer_prepare()
468 buf->bpl * (core->height >> 1), 0, in buffer_prepare()
469 buf->bpl, 0, in buffer_prepare()
470 core->height >> 1); in buffer_prepare()
474 ret = cx88_risc_buffer(dev->pci, &buf->risc, in buffer_prepare()
475 sgt->sgl, 0, buf->bpl, in buffer_prepare()
476 buf->bpl, buf->bpl, in buffer_prepare()
477 core->height >> 1); in buffer_prepare()
481 "[%p/%d] %s - %dx%d %dbpp 0x%08x - dma=0x%08lx\n", in buffer_prepare()
482 buf, buf->vb.vb2_buf.index, __func__, in buffer_prepare()
483 core->width, core->height, dev->fmt->depth, dev->fmt->fourcc, in buffer_prepare()
484 (unsigned long)buf->risc.dma); in buffer_prepare()
491 struct cx8800_dev *dev = vb->vb2_queue->drv_priv; in buffer_finish()
493 struct cx88_riscmem *risc = &buf->risc; in buffer_finish()
495 if (risc->cpu) in buffer_finish()
496 dma_free_coherent(&dev->pci->dev, risc->size, risc->cpu, in buffer_finish()
497 risc->dma); in buffer_finish()
504 struct cx8800_dev *dev = vb->vb2_queue->drv_priv; in buffer_queue()
507 struct cx88_dmaqueue *q = &dev->vidq; in buffer_queue()
510 buf->risc.cpu[1] = cpu_to_le32(buf->risc.dma + 8); in buffer_queue()
511 buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_CNT_INC); in buffer_queue()
512 buf->risc.jmp[1] = cpu_to_le32(buf->risc.dma + 8); in buffer_queue()
514 if (list_empty(&q->active)) { in buffer_queue()
515 list_add_tail(&buf->list, &q->active); in buffer_queue()
516 dprintk(2, "[%p/%d] buffer_queue - first active\n", in buffer_queue()
517 buf, buf->vb.vb2_buf.index); in buffer_queue()
520 buf->risc.cpu[0] |= cpu_to_le32(RISC_IRQ1); in buffer_queue()
521 prev = list_entry(q->active.prev, struct cx88_buffer, list); in buffer_queue()
522 list_add_tail(&buf->list, &q->active); in buffer_queue()
523 prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); in buffer_queue()
524 dprintk(2, "[%p/%d] buffer_queue - append to active\n", in buffer_queue()
525 buf, buf->vb.vb2_buf.index); in buffer_queue()
531 struct cx8800_dev *dev = q->drv_priv; in start_streaming()
532 struct cx88_dmaqueue *dmaq = &dev->vidq; in start_streaming()
533 struct cx88_buffer *buf = list_entry(dmaq->active.next, in start_streaming()
542 struct cx8800_dev *dev = q->drv_priv; in stop_streaming()
543 struct cx88_core *core = dev->core; in stop_streaming()
544 struct cx88_dmaqueue *dmaq = &dev->vidq; in stop_streaming()
549 spin_lock_irqsave(&dev->slock, flags); in stop_streaming()
550 while (!list_empty(&dmaq->active)) { in stop_streaming()
551 struct cx88_buffer *buf = list_entry(dmaq->active.next, in stop_streaming()
554 list_del(&buf->list); in stop_streaming()
555 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); in stop_streaming()
557 spin_unlock_irqrestore(&dev->slock, flags); in stop_streaming()
571 /* ------------------------------------------------------------------ */
576 struct cx88_core *core = dev->core; in radio_open()
582 cx_write(MO_GP3_IO, core->board.radio.gpio3); in radio_open()
583 cx_write(MO_GP0_IO, core->board.radio.gpio0); in radio_open()
584 cx_write(MO_GP1_IO, core->board.radio.gpio1); in radio_open()
585 cx_write(MO_GP2_IO, core->board.radio.gpio2); in radio_open()
586 if (core->board.radio.audioroute) { in radio_open()
587 if (core->sd_wm8775) { in radio_open()
589 core->board.radio.audioroute, 0, 0); in radio_open()
592 core->tvaudio = WW_I2SADC; in radio_open()
596 core->tvaudio = WW_FM; in radio_open()
604 /* ------------------------------------------------------------------ */
610 container_of(ctrl->handler, struct cx88_core, video_hdl); in cx8800_s_vid_ctrl()
611 const struct cx88_ctrl *cc = ctrl->priv; in cx8800_s_vid_ctrl()
614 mask = cc->mask; in cx8800_s_vid_ctrl()
615 switch (ctrl->id) { in cx8800_s_vid_ctrl()
619 value = ((ctrl->val - cc->off) << cc->shift) & cc->mask; in cx8800_s_vid_ctrl()
621 if (core->tvnorm & V4L2_STD_SECAM) { in cx8800_s_vid_ctrl()
632 value = (ctrl->val < 1 ? 0 : ((ctrl->val + 3) << 7)); in cx8800_s_vid_ctrl()
637 value = ((ctrl->val - cc->off) << cc->shift) & cc->mask; in cx8800_s_vid_ctrl()
640 value = ((ctrl->val - cc->off) << cc->shift) & cc->mask; in cx8800_s_vid_ctrl()
645 ctrl->id, ctrl->name, ctrl->val, cc->reg, value, in cx8800_s_vid_ctrl()
646 mask, cc->sreg ? " [shadowed]" : ""); in cx8800_s_vid_ctrl()
647 if (cc->sreg) in cx8800_s_vid_ctrl()
648 cx_sandor(cc->sreg, cc->reg, mask, value); in cx8800_s_vid_ctrl()
650 cx_andor(cc->reg, mask, value); in cx8800_s_vid_ctrl()
657 container_of(ctrl->handler, struct cx88_core, audio_hdl); in cx8800_s_aud_ctrl()
658 const struct cx88_ctrl *cc = ctrl->priv; in cx8800_s_aud_ctrl()
662 if (core->sd_wm8775) { in cx8800_s_aud_ctrl()
663 switch (ctrl->id) { in cx8800_s_aud_ctrl()
665 wm8775_s_ctrl(core, ctrl->id, ctrl->val); in cx8800_s_aud_ctrl()
668 wm8775_s_ctrl(core, ctrl->id, (ctrl->val) ? in cx8800_s_aud_ctrl()
669 (0x90 + ctrl->val) << 8 : 0); in cx8800_s_aud_ctrl()
672 wm8775_s_ctrl(core, ctrl->id, ctrl->val << 9); in cx8800_s_aud_ctrl()
679 mask = cc->mask; in cx8800_s_aud_ctrl()
680 switch (ctrl->id) { in cx8800_s_aud_ctrl()
682 value = (ctrl->val < 0x40) ? in cx8800_s_aud_ctrl()
683 (0x7f - ctrl->val) : (ctrl->val - 0x40); in cx8800_s_aud_ctrl()
686 value = 0x3f - (ctrl->val & 0x3f); in cx8800_s_aud_ctrl()
689 value = ((ctrl->val - cc->off) << cc->shift) & cc->mask; in cx8800_s_aud_ctrl()
694 ctrl->id, ctrl->name, ctrl->val, cc->reg, value, in cx8800_s_aud_ctrl()
695 mask, cc->sreg ? " [shadowed]" : ""); in cx8800_s_aud_ctrl()
696 if (cc->sreg) in cx8800_s_aud_ctrl()
697 cx_sandor(cc->sreg, cc->reg, mask, value); in cx8800_s_aud_ctrl()
699 cx_andor(cc->reg, mask, value); in cx8800_s_aud_ctrl()
703 /* ------------------------------------------------------------------ */
710 struct cx88_core *core = dev->core; in vidioc_g_fmt_vid_cap()
712 f->fmt.pix.width = core->width; in vidioc_g_fmt_vid_cap()
713 f->fmt.pix.height = core->height; in vidioc_g_fmt_vid_cap()
714 f->fmt.pix.field = core->field; in vidioc_g_fmt_vid_cap()
715 f->fmt.pix.pixelformat = dev->fmt->fourcc; in vidioc_g_fmt_vid_cap()
716 f->fmt.pix.bytesperline = in vidioc_g_fmt_vid_cap()
717 (f->fmt.pix.width * dev->fmt->depth) >> 3; in vidioc_g_fmt_vid_cap()
718 f->fmt.pix.sizeimage = in vidioc_g_fmt_vid_cap()
719 f->fmt.pix.height * f->fmt.pix.bytesperline; in vidioc_g_fmt_vid_cap()
720 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; in vidioc_g_fmt_vid_cap()
728 struct cx88_core *core = dev->core; in vidioc_try_fmt_vid_cap()
733 fmt = format_by_fourcc(f->fmt.pix.pixelformat); in vidioc_try_fmt_vid_cap()
735 return -EINVAL; in vidioc_try_fmt_vid_cap()
737 maxw = norm_maxw(core->tvnorm); in vidioc_try_fmt_vid_cap()
738 maxh = norm_maxh(core->tvnorm); in vidioc_try_fmt_vid_cap()
740 field = f->fmt.pix.field; in vidioc_try_fmt_vid_cap()
750 field = (f->fmt.pix.height > maxh / 2) in vidioc_try_fmt_vid_cap()
758 v4l_bound_align_image(&f->fmt.pix.width, 48, maxw, 2, in vidioc_try_fmt_vid_cap()
759 &f->fmt.pix.height, 32, maxh, 0, 0); in vidioc_try_fmt_vid_cap()
760 f->fmt.pix.field = field; in vidioc_try_fmt_vid_cap()
761 f->fmt.pix.bytesperline = in vidioc_try_fmt_vid_cap()
762 (f->fmt.pix.width * fmt->depth) >> 3; in vidioc_try_fmt_vid_cap()
763 f->fmt.pix.sizeimage = in vidioc_try_fmt_vid_cap()
764 f->fmt.pix.height * f->fmt.pix.bytesperline; in vidioc_try_fmt_vid_cap()
765 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; in vidioc_try_fmt_vid_cap()
774 struct cx88_core *core = dev->core; in vidioc_s_fmt_vid_cap()
779 if (vb2_is_busy(&dev->vb2_vidq) || vb2_is_busy(&dev->vb2_vbiq)) in vidioc_s_fmt_vid_cap()
780 return -EBUSY; in vidioc_s_fmt_vid_cap()
781 if (core->dvbdev && vb2_is_busy(&core->dvbdev->vb2_mpegq)) in vidioc_s_fmt_vid_cap()
782 return -EBUSY; in vidioc_s_fmt_vid_cap()
783 dev->fmt = format_by_fourcc(f->fmt.pix.pixelformat); in vidioc_s_fmt_vid_cap()
784 core->width = f->fmt.pix.width; in vidioc_s_fmt_vid_cap()
785 core->height = f->fmt.pix.height; in vidioc_s_fmt_vid_cap()
786 core->field = f->fmt.pix.field; in vidioc_s_fmt_vid_cap()
793 strscpy(cap->card, core->board.name, sizeof(cap->card)); in cx88_querycap()
794 cap->capabilities = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING | in cx88_querycap()
797 if (core->board.tuner_type != UNSET) in cx88_querycap()
798 cap->capabilities |= V4L2_CAP_TUNER; in cx88_querycap()
799 if (core->board.radio.type == CX88_RADIO) in cx88_querycap()
800 cap->capabilities |= V4L2_CAP_RADIO; in cx88_querycap()
809 struct cx88_core *core = dev->core; in vidioc_querycap()
811 strscpy(cap->driver, "cx8800", sizeof(cap->driver)); in vidioc_querycap()
818 if (unlikely(f->index >= ARRAY_SIZE(formats))) in vidioc_enum_fmt_vid_cap()
819 return -EINVAL; in vidioc_enum_fmt_vid_cap()
821 f->pixelformat = formats[f->index].fourcc; in vidioc_enum_fmt_vid_cap()
829 struct cx88_core *core = dev->core; in vidioc_g_std()
831 *tvnorm = core->tvnorm; in vidioc_g_std()
838 struct cx88_core *core = dev->core; in vidioc_s_std()
843 /* only one input in this sample driver */
851 [CX88_VMUX_SVIDEO] = "S-Video", in cx88_enum_input()
857 unsigned int n = i->index; in cx88_enum_input()
860 return -EINVAL; in cx88_enum_input()
861 if (!INPUT(n).type) in cx88_enum_input()
862 return -EINVAL; in cx88_enum_input()
863 i->type = V4L2_INPUT_TYPE_CAMERA; in cx88_enum_input()
864 strscpy(i->name, iname[INPUT(n).type], sizeof(i->name)); in cx88_enum_input()
865 if ((INPUT(n).type == CX88_VMUX_TELEVISION) || in cx88_enum_input()
866 (INPUT(n).type == CX88_VMUX_CABLE)) in cx88_enum_input()
867 i->type = V4L2_INPUT_TYPE_TUNER; in cx88_enum_input()
869 i->std = CX88_NORMS; in cx88_enum_input()
878 struct cx88_core *core = dev->core; in vidioc_enum_input()
886 struct cx88_core *core = dev->core; in vidioc_g_input()
888 *i = core->input; in vidioc_g_input()
895 struct cx88_core *core = dev->core; in vidioc_s_input()
898 return -EINVAL; in vidioc_s_input()
899 if (!INPUT(i).type) in vidioc_s_input()
900 return -EINVAL; in vidioc_s_input()
911 struct cx88_core *core = dev->core; in vidioc_g_tuner()
914 if (unlikely(core->board.tuner_type == UNSET)) in vidioc_g_tuner()
915 return -EINVAL; in vidioc_g_tuner()
916 if (t->index != 0) in vidioc_g_tuner()
917 return -EINVAL; in vidioc_g_tuner()
919 strscpy(t->name, "Television", sizeof(t->name)); in vidioc_g_tuner()
920 t->capability = V4L2_TUNER_CAP_NORM; in vidioc_g_tuner()
921 t->rangehigh = 0xffffffffUL; in vidioc_g_tuner()
926 t->signal = (reg & (1 << 5)) ? 0xffff : 0x0000; in vidioc_g_tuner()
934 struct cx88_core *core = dev->core; in vidioc_s_tuner()
936 if (core->board.tuner_type == UNSET) in vidioc_s_tuner()
937 return -EINVAL; in vidioc_s_tuner()
938 if (t->index != 0) in vidioc_s_tuner()
939 return -EINVAL; in vidioc_s_tuner()
941 cx88_set_stereo(core, t->audmode, 1); in vidioc_s_tuner()
949 struct cx88_core *core = dev->core; in vidioc_g_frequency()
951 if (unlikely(core->board.tuner_type == UNSET)) in vidioc_g_frequency()
952 return -EINVAL; in vidioc_g_frequency()
953 if (f->tuner) in vidioc_g_frequency()
954 return -EINVAL; in vidioc_g_frequency()
956 f->frequency = core->freq; in vidioc_g_frequency()
968 if (unlikely(core->board.tuner_type == UNSET)) in cx88_set_freq()
969 return -EINVAL; in cx88_set_freq()
970 if (unlikely(f->tuner != 0)) in cx88_set_freq()
971 return -EINVAL; in cx88_set_freq()
976 core->freq = new_freq.frequency; in cx88_set_freq()
990 struct cx88_core *core = dev->core; in vidioc_s_frequency()
1000 struct cx88_core *core = dev->core; in vidioc_g_register()
1002 /* cx2388x has a 24-bit register space */ in vidioc_g_register()
1003 reg->val = cx_read(reg->reg & 0xfffffc); in vidioc_g_register()
1004 reg->size = 4; in vidioc_g_register()
1012 struct cx88_core *core = dev->core; in vidioc_s_register()
1014 cx_write(reg->reg & 0xfffffc, reg->val); in vidioc_s_register()
1019 /* ----------------------------------------------------------- */
1021 /* ----------------------------------------------------------- */
1027 struct cx88_core *core = dev->core; in radio_g_tuner()
1029 if (unlikely(t->index > 0)) in radio_g_tuner()
1030 return -EINVAL; in radio_g_tuner()
1032 strscpy(t->name, "Radio", sizeof(t->name)); in radio_g_tuner()
1042 struct cx88_core *core = dev->core; in radio_s_tuner()
1044 if (t->index != 0) in radio_s_tuner()
1045 return -EINVAL; in radio_s_tuner()
1051 /* ----------------------------------------------------------- */
1063 struct cx88_core *core = dev->core; in cx8800_vid_irq()
1086 spin_lock(&dev->slock); in cx8800_vid_irq()
1088 cx88_wakeup(core, &dev->vidq, count); in cx8800_vid_irq()
1089 spin_unlock(&dev->slock); in cx8800_vid_irq()
1094 spin_lock(&dev->slock); in cx8800_vid_irq()
1096 cx88_wakeup(core, &dev->vbiq, count); in cx8800_vid_irq()
1097 spin_unlock(&dev->slock); in cx8800_vid_irq()
1104 struct cx88_core *core = dev->core; in cx8800_irq()
1110 (core->pci_irqmask | PCI_INT_VIDINT); in cx8800_irq()
1116 if (status & core->pci_irqmask) in cx8800_irq()
1122 pr_warn("irq loop -- clearing mask\n"); in cx8800_irq()
1130 /* ----------------------------------------------------------- */
1173 .name = "cx8800-video",
1206 .name = "cx8800-vbi",
1235 .name = "cx8800-radio",
1248 /* ----------------------------------------------------------- */
1252 video_unregister_device(&dev->radio_dev); in cx8800_unregister_video()
1253 video_unregister_device(&dev->vbi_dev); in cx8800_unregister_video()
1254 video_unregister_device(&dev->video_dev); in cx8800_unregister_video()
1268 return -ENOMEM; in cx8800_initdev()
1271 dev->pci = pci_dev; in cx8800_initdev()
1273 err = -EIO; in cx8800_initdev()
1276 core = cx88_core_get(dev->pci); in cx8800_initdev()
1278 err = -EINVAL; in cx8800_initdev()
1281 dev->core = core; in cx8800_initdev()
1284 dev->pci_rev = pci_dev->revision; in cx8800_initdev()
1285 pci_read_config_byte(pci_dev, PCI_LATENCY_TIMER, &dev->pci_lat); in cx8800_initdev()
1287 pci_name(pci_dev), dev->pci_rev, pci_dev->irq, in cx8800_initdev()
1288 dev->pci_lat, in cx8800_initdev()
1292 err = dma_set_mask(&pci_dev->dev, DMA_BIT_MASK(32)); in cx8800_initdev()
1299 spin_lock_init(&dev->slock); in cx8800_initdev()
1302 INIT_LIST_HEAD(&dev->vidq.active); in cx8800_initdev()
1305 INIT_LIST_HEAD(&dev->vbiq.active); in cx8800_initdev()
1308 err = request_irq(pci_dev->irq, cx8800_irq, in cx8800_initdev()
1309 IRQF_SHARED, core->name, dev); in cx8800_initdev()
1311 pr_err("can't get IRQ %d\n", pci_dev->irq); in cx8800_initdev()
1314 cx_set(MO_PCI_INTMSK, core->pci_irqmask); in cx8800_initdev()
1320 vc = v4l2_ctrl_new_std(&core->audio_hdl, &cx8800_ctrl_aud_ops, in cx8800_initdev()
1321 cc->id, cc->minimum, cc->maximum, in cx8800_initdev()
1322 cc->step, cc->default_value); in cx8800_initdev()
1324 err = core->audio_hdl.error; in cx8800_initdev()
1327 vc->priv = (void *)cc; in cx8800_initdev()
1334 vc = v4l2_ctrl_new_std(&core->video_hdl, &cx8800_ctrl_vid_ops, in cx8800_initdev()
1335 cc->id, cc->minimum, cc->maximum, in cx8800_initdev()
1336 cc->step, cc->default_value); in cx8800_initdev()
1338 err = core->video_hdl.error; in cx8800_initdev()
1341 vc->priv = (void *)cc; in cx8800_initdev()
1342 if (vc->id == V4L2_CID_CHROMA_AGC) in cx8800_initdev()
1343 core->chroma_agc = vc; in cx8800_initdev()
1345 v4l2_ctrl_add_handler(&core->video_hdl, &core->audio_hdl, NULL, false); in cx8800_initdev()
1349 if (core->board.audio_chip == CX88_AUDIO_WM8775) { in cx8800_initdev()
1353 .platform_data = &core->wm8775_data, in cx8800_initdev()
1357 if (core->boardnr == CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1) in cx8800_initdev()
1358 core->wm8775_data.is_nova_s = true; in cx8800_initdev()
1360 core->wm8775_data.is_nova_s = false; in cx8800_initdev()
1362 sd = v4l2_i2c_new_subdev_board(&core->v4l2_dev, &core->i2c_adap, in cx8800_initdev()
1365 core->sd_wm8775 = sd; in cx8800_initdev()
1366 sd->grp_id = WM8775_GID; in cx8800_initdev()
1370 if (core->board.audio_chip == CX88_AUDIO_TVAUDIO) { in cx8800_initdev()
1375 v4l2_i2c_new_subdev(&core->v4l2_dev, &core->i2c_adap, in cx8800_initdev()
1379 switch (core->boardnr) { in cx8800_initdev()
1386 request_module("rtc-isl1208"); in cx8800_initdev()
1387 core->i2c_rtc = i2c_new_client_device(&core->i2c_adap, &rtc_info); in cx8800_initdev()
1392 request_module("ir-kbd-i2c"); in cx8800_initdev()
1398 dev->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); in cx8800_initdev()
1400 /* Maintain a reference so cx88-blackbird can query the 8800 device. */ in cx8800_initdev()
1401 core->v4ldev = dev; in cx8800_initdev()
1404 mutex_lock(&core->lock); in cx8800_initdev()
1406 v4l2_ctrl_handler_setup(&core->video_hdl); in cx8800_initdev()
1407 v4l2_ctrl_handler_setup(&core->audio_hdl); in cx8800_initdev()
1410 q = &dev->vb2_vidq; in cx8800_initdev()
1411 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; in cx8800_initdev()
1412 q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ; in cx8800_initdev()
1413 q->gfp_flags = GFP_DMA32; in cx8800_initdev()
1414 q->min_buffers_needed = 2; in cx8800_initdev()
1415 q->drv_priv = dev; in cx8800_initdev()
1416 q->buf_struct_size = sizeof(struct cx88_buffer); in cx8800_initdev()
1417 q->ops = &cx8800_video_qops; in cx8800_initdev()
1418 q->mem_ops = &vb2_dma_sg_memops; in cx8800_initdev()
1419 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; in cx8800_initdev()
1420 q->lock = &core->lock; in cx8800_initdev()
1421 q->dev = &dev->pci->dev; in cx8800_initdev()
1427 q = &dev->vb2_vbiq; in cx8800_initdev()
1428 q->type = V4L2_BUF_TYPE_VBI_CAPTURE; in cx8800_initdev()
1429 q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ; in cx8800_initdev()
1430 q->gfp_flags = GFP_DMA32; in cx8800_initdev()
1431 q->min_buffers_needed = 2; in cx8800_initdev()
1432 q->drv_priv = dev; in cx8800_initdev()
1433 q->buf_struct_size = sizeof(struct cx88_buffer); in cx8800_initdev()
1434 q->ops = &cx8800_vbi_qops; in cx8800_initdev()
1435 q->mem_ops = &vb2_dma_sg_memops; in cx8800_initdev()
1436 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; in cx8800_initdev()
1437 q->lock = &core->lock; in cx8800_initdev()
1438 q->dev = &dev->pci->dev; in cx8800_initdev()
1445 cx88_vdev_init(core, dev->pci, &dev->video_dev, in cx8800_initdev()
1447 video_set_drvdata(&dev->video_dev, dev); in cx8800_initdev()
1448 dev->video_dev.ctrl_handler = &core->video_hdl; in cx8800_initdev()
1449 dev->video_dev.queue = &dev->vb2_vidq; in cx8800_initdev()
1450 dev->video_dev.device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING | in cx8800_initdev()
1452 if (core->board.tuner_type != UNSET) in cx8800_initdev()
1453 dev->video_dev.device_caps |= V4L2_CAP_TUNER; in cx8800_initdev()
1454 err = video_register_device(&dev->video_dev, VFL_TYPE_VIDEO, in cx8800_initdev()
1455 video_nr[core->nr]); in cx8800_initdev()
1461 video_device_node_name(&dev->video_dev)); in cx8800_initdev()
1463 cx88_vdev_init(core, dev->pci, &dev->vbi_dev, in cx8800_initdev()
1465 video_set_drvdata(&dev->vbi_dev, dev); in cx8800_initdev()
1466 dev->vbi_dev.queue = &dev->vb2_vbiq; in cx8800_initdev()
1467 dev->vbi_dev.device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING | in cx8800_initdev()
1469 if (core->board.tuner_type != UNSET) in cx8800_initdev()
1470 dev->vbi_dev.device_caps |= V4L2_CAP_TUNER; in cx8800_initdev()
1471 err = video_register_device(&dev->vbi_dev, VFL_TYPE_VBI, in cx8800_initdev()
1472 vbi_nr[core->nr]); in cx8800_initdev()
1478 video_device_node_name(&dev->vbi_dev)); in cx8800_initdev()
1480 if (core->board.radio.type == CX88_RADIO) { in cx8800_initdev()
1481 cx88_vdev_init(core, dev->pci, &dev->radio_dev, in cx8800_initdev()
1483 video_set_drvdata(&dev->radio_dev, dev); in cx8800_initdev()
1484 dev->radio_dev.ctrl_handler = &core->audio_hdl; in cx8800_initdev()
1485 dev->radio_dev.device_caps = V4L2_CAP_RADIO | V4L2_CAP_TUNER; in cx8800_initdev()
1486 err = video_register_device(&dev->radio_dev, VFL_TYPE_RADIO, in cx8800_initdev()
1487 radio_nr[core->nr]); in cx8800_initdev()
1493 video_device_node_name(&dev->radio_dev)); in cx8800_initdev()
1497 if (core->board.tuner_type != UNSET) { in cx8800_initdev()
1498 core->kthread = kthread_run(cx88_audio_thread, in cx8800_initdev()
1500 if (IS_ERR(core->kthread)) { in cx8800_initdev()
1501 err = PTR_ERR(core->kthread); in cx8800_initdev()
1506 mutex_unlock(&core->lock); in cx8800_initdev()
1512 mutex_unlock(&core->lock); in cx8800_initdev()
1514 free_irq(pci_dev->irq, dev); in cx8800_initdev()
1516 core->v4ldev = NULL; in cx8800_initdev()
1517 cx88_core_put(core, dev->pci); in cx8800_initdev()
1528 struct cx88_core *core = dev->core; in cx8800_finidev()
1531 if (core->kthread) { in cx8800_finidev()
1532 kthread_stop(core->kthread); in cx8800_finidev()
1533 core->kthread = NULL; in cx8800_finidev()
1536 if (core->ir) in cx8800_finidev()
1543 free_irq(pci_dev->irq, dev); in cx8800_finidev()
1547 core->v4ldev = NULL; in cx8800_finidev()
1550 cx88_core_put(core, dev->pci); in cx8800_finidev()
1557 struct cx88_core *core = dev->core; in cx8800_suspend()
1561 spin_lock_irqsave(&dev->slock, flags); in cx8800_suspend()
1562 if (!list_empty(&dev->vidq.active)) { in cx8800_suspend()
1566 if (!list_empty(&dev->vbiq.active)) { in cx8800_suspend()
1570 spin_unlock_irqrestore(&dev->slock, flags); in cx8800_suspend()
1572 if (core->ir) in cx8800_suspend()
1574 /* FIXME -- shutdown device */ in cx8800_suspend()
1577 dev->state.disabled = 1; in cx8800_suspend()
1584 struct cx88_core *core = dev->core; in cx8800_resume()
1587 dev->state.disabled = 0; in cx8800_resume()
1589 /* FIXME: re-initialize hardware */ in cx8800_resume()
1591 if (core->ir) in cx8800_resume()
1594 cx_set(MO_PCI_INTMSK, core->pci_irqmask); in cx8800_resume()
1597 spin_lock_irqsave(&dev->slock, flags); in cx8800_resume()
1598 if (!list_empty(&dev->vidq.active)) { in cx8800_resume()
1600 restart_video_queue(dev, &dev->vidq); in cx8800_resume()
1602 if (!list_empty(&dev->vbiq.active)) { in cx8800_resume()
1604 cx8800_restart_vbi_queue(dev, &dev->vbiq); in cx8800_resume()
1606 spin_unlock_irqrestore(&dev->slock, flags); in cx8800_resume()
1611 /* ----------------------------------------------------------- */
1620 /* --- end of list --- */