Lines Matching +full:gpio1 +full:- +full:cfg
1 // SPDX-License-Identifier: GPL-2.0-or-later
9 #include "cx23885-video.h"
23 #include <media/v4l2-common.h>
24 #include <media/v4l2-ioctl.h>
25 #include <media/v4l2-event.h>
26 #include "cx23885-ioctl.h"
29 #include <media/drv-intf/cx25840.h>
35 /* ------------------------------------------------------------------ */
37 static unsigned int video_nr[] = {[0 ... (CX23885_MAXBOARDS - 1)] = UNSET };
38 static unsigned int vbi_nr[] = {[0 ... (CX23885_MAXBOARDS - 1)] = UNSET };
64 /* ------------------------------------------------------------------- */
86 /* ------------------------------------------------------------------- */
93 if (list_empty(&q->active)) in cx23885_video_wakeup()
95 buf = list_entry(q->active.next, in cx23885_video_wakeup()
98 buf->vb.sequence = q->count++; in cx23885_video_wakeup()
99 buf->vb.vb2_buf.timestamp = ktime_get_ns(); in cx23885_video_wakeup()
101 buf->vb.vb2_buf.index, count, q->count); in cx23885_video_wakeup()
102 list_del(&buf->queue); in cx23885_video_wakeup()
103 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE); in cx23885_video_wakeup()
118 if (dev->tvnorm == norm) in cx23885_set_tvnorm()
121 if (dev->tvnorm != norm) { in cx23885_set_tvnorm()
122 if (vb2_is_busy(&dev->vb2_vidq) || vb2_is_busy(&dev->vb2_vbiq) || in cx23885_set_tvnorm()
123 vb2_is_busy(&dev->vb2_mpegq)) in cx23885_set_tvnorm()
124 return -EBUSY; in cx23885_set_tvnorm()
127 dev->tvnorm = norm; in cx23885_set_tvnorm()
128 dev->width = 720; in cx23885_set_tvnorm()
129 dev->height = norm_maxh(norm); in cx23885_set_tvnorm()
130 dev->field = V4L2_FIELD_INTERLACED; in cx23885_set_tvnorm()
134 format.format.width = dev->width; in cx23885_set_tvnorm()
135 format.format.height = dev->height; in cx23885_set_tvnorm()
136 format.format.field = dev->field; in cx23885_set_tvnorm()
154 vfd->v4l2_dev = &dev->v4l2_dev; in cx23885_vdev_init()
155 vfd->release = video_device_release; in cx23885_vdev_init()
156 vfd->lock = &dev->lock; in cx23885_vdev_init()
157 snprintf(vfd->name, sizeof(vfd->name), "%s (%s)", in cx23885_vdev_init()
158 cx23885_boards[dev->board].name, type); in cx23885_vdev_init()
171 return i2c_transfer(&dev->i2c_bus[2].i2c_adap, &msg, 1); in cx23885_flatiron_write()
186 ret = i2c_transfer(&dev->i2c_bus[2].i2c_adap, &msg[0], 2); in cx23885_flatiron_read()
213 return -EINVAL; in cx23885_flatiron_mux()
215 val |= 0x20; /* Enable clock to delta-sigma and dec filter */ in cx23885_flatiron_mux()
232 input, INPUT(input)->vmux, in cx23885_video_mux()
233 INPUT(input)->gpio0, INPUT(input)->gpio1, in cx23885_video_mux()
234 INPUT(input)->gpio2, INPUT(input)->gpio3); in cx23885_video_mux()
235 dev->input = input; in cx23885_video_mux()
237 if (dev->board == CX23885_BOARD_MYGICA_X8506 || in cx23885_video_mux()
238 dev->board == CX23885_BOARD_MAGICPRO_PROHDTVE2 || in cx23885_video_mux()
239 dev->board == CX23885_BOARD_MYGICA_X8507) { in cx23885_video_mux()
241 if (INPUT(input)->type == CX23885_VMUX_TELEVISION) in cx23885_video_mux()
246 v4l2_subdev_call(dev->sd_cx25840, video, s_routing, in cx23885_video_mux()
247 INPUT(input)->vmux, 0, 0); in cx23885_video_mux()
249 if ((dev->board == CX23885_BOARD_HAUPPAUGE_HVR1800) || in cx23885_video_mux()
250 (dev->board == CX23885_BOARD_MPX885) || in cx23885_video_mux()
251 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1250) || in cx23885_video_mux()
252 (dev->board == CX23885_BOARD_HAUPPAUGE_IMPACTVCBE) || in cx23885_video_mux()
253 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1255) || in cx23885_video_mux()
254 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1255_22111) || in cx23885_video_mux()
255 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1265_K4) || in cx23885_video_mux()
256 (dev->board == CX23885_BOARD_HAUPPAUGE_QUADHD_ATSC) || in cx23885_video_mux()
257 (dev->board == CX23885_BOARD_HAUPPAUGE_QUADHD_DVB) || in cx23885_video_mux()
258 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1850) || in cx23885_video_mux()
259 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR5525) || in cx23885_video_mux()
260 (dev->board == CX23885_BOARD_MYGICA_X8507) || in cx23885_video_mux()
261 (dev->board == CX23885_BOARD_AVERMEDIA_HC81R) || in cx23885_video_mux()
262 (dev->board == CX23885_BOARD_VIEWCAST_260E) || in cx23885_video_mux()
263 (dev->board == CX23885_BOARD_VIEWCAST_460E) || in cx23885_video_mux()
264 (dev->board == CX23885_BOARD_AVERMEDIA_CE310B)) { in cx23885_video_mux()
266 v4l2_subdev_call(dev->sd_cx25840, audio, s_routing, in cx23885_video_mux()
267 INPUT(input)->amux, 0, 0); in cx23885_video_mux()
269 if (INPUT(input)->amux == CX25840_AUDIO7) in cx23885_video_mux()
271 else if (INPUT(input)->amux == CX25840_AUDIO6) in cx23885_video_mux()
291 if (INPUT(input)->amux == CX25840_AUDIO7) in cx23885_audio_mux()
293 else if (INPUT(input)->amux == CX25840_AUDIO6) in cx23885_audio_mux()
303 /* ------------------------------------------------------------------ */
314 cx23885_sram_channel_setup(dev, &dev->sram_channels[SRAM_CH01], in cx23885_start_video_dma()
315 buf->bpl, buf->risc.dma); in cx23885_start_video_dma()
319 q->count = 0; in cx23885_start_video_dma()
336 struct cx23885_dev *dev = q->drv_priv; in queue_setup()
339 sizes[0] = (dev->fmt->depth * dev->width * dev->height) >> 3; in queue_setup()
347 struct cx23885_dev *dev = vb->vb2_queue->drv_priv; in buffer_prepare()
354 buf->bpl = (dev->width * dev->fmt->depth) >> 3; in buffer_prepare()
356 if (vb2_plane_size(vb, 0) < dev->height * buf->bpl) in buffer_prepare()
357 return -EINVAL; in buffer_prepare()
358 vb2_set_plane_payload(vb, 0, dev->height * buf->bpl); in buffer_prepare()
360 switch (dev->field) { in buffer_prepare()
362 ret = cx23885_risc_buffer(dev->pci, &buf->risc, in buffer_prepare()
363 sgt->sgl, 0, UNSET, in buffer_prepare()
364 buf->bpl, 0, dev->height); in buffer_prepare()
367 ret = cx23885_risc_buffer(dev->pci, &buf->risc, in buffer_prepare()
368 sgt->sgl, UNSET, 0, in buffer_prepare()
369 buf->bpl, 0, dev->height); in buffer_prepare()
372 if (dev->tvnorm & V4L2_STD_525_60) in buffer_prepare()
378 if (cx23885_boards[dev->board].force_bff) in buffer_prepare()
386 line0_offset = buf->bpl; in buffer_prepare()
393 line1_offset = buf->bpl; in buffer_prepare()
395 ret = cx23885_risc_buffer(dev->pci, &buf->risc, in buffer_prepare()
396 sgt->sgl, line0_offset, in buffer_prepare()
398 buf->bpl, buf->bpl, in buffer_prepare()
399 dev->height >> 1); in buffer_prepare()
402 ret = cx23885_risc_buffer(dev->pci, &buf->risc, in buffer_prepare()
403 sgt->sgl, in buffer_prepare()
404 0, buf->bpl * (dev->height >> 1), in buffer_prepare()
405 buf->bpl, 0, in buffer_prepare()
406 dev->height >> 1); in buffer_prepare()
409 ret = cx23885_risc_buffer(dev->pci, &buf->risc, in buffer_prepare()
410 sgt->sgl, in buffer_prepare()
411 buf->bpl * (dev->height >> 1), 0, in buffer_prepare()
412 buf->bpl, 0, in buffer_prepare()
413 dev->height >> 1); in buffer_prepare()
416 return -EINVAL; /* should not happen */ in buffer_prepare()
418 dprintk(2, "[%p/%d] buffer_init - %dx%d %dbpp 0x%08x - dma=0x%08lx\n", in buffer_prepare()
419 buf, buf->vb.vb2_buf.index, in buffer_prepare()
420 dev->width, dev->height, dev->fmt->depth, dev->fmt->fourcc, in buffer_prepare()
421 (unsigned long)buf->risc.dma); in buffer_prepare()
431 cx23885_free_buffer(vb->vb2_queue->drv_priv, buf); in buffer_finish()
452 * The end-result of all this that you only get an interrupt when a buffer
458 struct cx23885_dev *dev = vb->vb2_queue->drv_priv; in buffer_queue()
462 struct cx23885_dmaqueue *q = &dev->vidq; in buffer_queue()
466 buf->risc.cpu[1] = cpu_to_le32(buf->risc.dma + 12); in buffer_queue()
467 buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_CNT_INC); in buffer_queue()
468 buf->risc.jmp[1] = cpu_to_le32(buf->risc.dma + 12); in buffer_queue()
469 buf->risc.jmp[2] = cpu_to_le32(0); /* bits 63-32 */ in buffer_queue()
471 spin_lock_irqsave(&dev->slock, flags); in buffer_queue()
472 if (list_empty(&q->active)) { in buffer_queue()
473 list_add_tail(&buf->queue, &q->active); in buffer_queue()
474 dprintk(2, "[%p/%d] buffer_queue - first active\n", in buffer_queue()
475 buf, buf->vb.vb2_buf.index); in buffer_queue()
477 buf->risc.cpu[0] |= cpu_to_le32(RISC_IRQ1); in buffer_queue()
478 prev = list_entry(q->active.prev, struct cx23885_buffer, in buffer_queue()
480 list_add_tail(&buf->queue, &q->active); in buffer_queue()
481 prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); in buffer_queue()
482 dprintk(2, "[%p/%d] buffer_queue - append to active\n", in buffer_queue()
483 buf, buf->vb.vb2_buf.index); in buffer_queue()
485 spin_unlock_irqrestore(&dev->slock, flags); in buffer_queue()
490 struct cx23885_dev *dev = q->drv_priv; in cx23885_start_streaming()
491 struct cx23885_dmaqueue *dmaq = &dev->vidq; in cx23885_start_streaming()
492 struct cx23885_buffer *buf = list_entry(dmaq->active.next, in cx23885_start_streaming()
501 struct cx23885_dev *dev = q->drv_priv; in cx23885_stop_streaming()
502 struct cx23885_dmaqueue *dmaq = &dev->vidq; in cx23885_stop_streaming()
506 spin_lock_irqsave(&dev->slock, flags); in cx23885_stop_streaming()
507 while (!list_empty(&dmaq->active)) { in cx23885_stop_streaming()
508 struct cx23885_buffer *buf = list_entry(dmaq->active.next, in cx23885_stop_streaming()
511 list_del(&buf->queue); in cx23885_stop_streaming()
512 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); in cx23885_stop_streaming()
514 spin_unlock_irqrestore(&dev->slock, flags); in cx23885_stop_streaming()
528 /* ------------------------------------------------------------------ */
536 f->fmt.pix.width = dev->width; in vidioc_g_fmt_vid_cap()
537 f->fmt.pix.height = dev->height; in vidioc_g_fmt_vid_cap()
538 f->fmt.pix.field = dev->field; in vidioc_g_fmt_vid_cap()
539 f->fmt.pix.pixelformat = dev->fmt->fourcc; in vidioc_g_fmt_vid_cap()
540 f->fmt.pix.bytesperline = in vidioc_g_fmt_vid_cap()
541 (f->fmt.pix.width * dev->fmt->depth) >> 3; in vidioc_g_fmt_vid_cap()
542 f->fmt.pix.sizeimage = in vidioc_g_fmt_vid_cap()
543 f->fmt.pix.height * f->fmt.pix.bytesperline; in vidioc_g_fmt_vid_cap()
544 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; in vidioc_g_fmt_vid_cap()
557 fmt = format_by_fourcc(f->fmt.pix.pixelformat); in vidioc_try_fmt_vid_cap()
559 return -EINVAL; in vidioc_try_fmt_vid_cap()
561 field = f->fmt.pix.field; in vidioc_try_fmt_vid_cap()
563 maxh = norm_maxh(dev->tvnorm); in vidioc_try_fmt_vid_cap()
566 field = (f->fmt.pix.height > maxh/2) in vidioc_try_fmt_vid_cap()
585 f->fmt.pix.field = field; in vidioc_try_fmt_vid_cap()
586 v4l_bound_align_image(&f->fmt.pix.width, 48, maxw, 2, in vidioc_try_fmt_vid_cap()
587 &f->fmt.pix.height, 32, maxh, 0, 0); in vidioc_try_fmt_vid_cap()
588 f->fmt.pix.bytesperline = in vidioc_try_fmt_vid_cap()
589 (f->fmt.pix.width * fmt->depth) >> 3; in vidioc_try_fmt_vid_cap()
590 f->fmt.pix.sizeimage = in vidioc_try_fmt_vid_cap()
591 f->fmt.pix.height * f->fmt.pix.bytesperline; in vidioc_try_fmt_vid_cap()
592 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; in vidioc_try_fmt_vid_cap()
612 if (vb2_is_busy(&dev->vb2_vidq) || vb2_is_busy(&dev->vb2_vbiq) || in vidioc_s_fmt_vid_cap()
613 vb2_is_busy(&dev->vb2_mpegq)) in vidioc_s_fmt_vid_cap()
614 return -EBUSY; in vidioc_s_fmt_vid_cap()
616 dev->fmt = format_by_fourcc(f->fmt.pix.pixelformat); in vidioc_s_fmt_vid_cap()
617 dev->width = f->fmt.pix.width; in vidioc_s_fmt_vid_cap()
618 dev->height = f->fmt.pix.height; in vidioc_s_fmt_vid_cap()
619 dev->field = f->fmt.pix.field; in vidioc_s_fmt_vid_cap()
621 dev->width, dev->height, dev->field); in vidioc_s_fmt_vid_cap()
622 v4l2_fill_mbus_format(&format.format, &f->fmt.pix, MEDIA_BUS_FMT_FIXED); in vidioc_s_fmt_vid_cap()
624 v4l2_fill_pix_format(&f->fmt.pix, &format.format); in vidioc_s_fmt_vid_cap()
625 /* set_fmt overwrites f->fmt.pix.field, restore it */ in vidioc_s_fmt_vid_cap()
626 f->fmt.pix.field = dev->field; in vidioc_s_fmt_vid_cap()
635 strscpy(cap->driver, "cx23885", sizeof(cap->driver)); in vidioc_querycap()
636 strscpy(cap->card, cx23885_boards[dev->board].name, in vidioc_querycap()
637 sizeof(cap->card)); in vidioc_querycap()
638 sprintf(cap->bus_info, "PCIe:%s", pci_name(dev->pci)); in vidioc_querycap()
639 cap->capabilities = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING | in vidioc_querycap()
643 switch (dev->board) { /* i2c device tuners */ in vidioc_querycap()
648 cap->capabilities |= V4L2_CAP_TUNER; in vidioc_querycap()
651 if (dev->tuner_type != TUNER_ABSENT) in vidioc_querycap()
652 cap->capabilities |= V4L2_CAP_TUNER; in vidioc_querycap()
661 if (unlikely(f->index >= ARRAY_SIZE(formats))) in vidioc_enum_fmt_vid_cap()
662 return -EINVAL; in vidioc_enum_fmt_vid_cap()
664 f->pixelformat = formats[f->index].fourcc; in vidioc_enum_fmt_vid_cap()
673 bool is_50hz = dev->tvnorm & V4L2_STD_625_50; in vidioc_g_pixelaspect()
676 return -EINVAL; in vidioc_g_pixelaspect()
678 f->numerator = is_50hz ? 54 : 11; in vidioc_g_pixelaspect()
679 f->denominator = is_50hz ? 59 : 10; in vidioc_g_pixelaspect()
689 if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) in vidioc_g_selection()
690 return -EINVAL; in vidioc_g_selection()
692 switch (sel->target) { in vidioc_g_selection()
695 sel->r.top = 0; in vidioc_g_selection()
696 sel->r.left = 0; in vidioc_g_selection()
697 sel->r.width = 720; in vidioc_g_selection()
698 sel->r.height = norm_maxh(dev->tvnorm); in vidioc_g_selection()
701 return -EINVAL; in vidioc_g_selection()
711 *id = dev->tvnorm; in vidioc_g_std()
730 [CX23885_VMUX_SVIDEO] = "S-Video", in cx23885_enum_input()
740 n = i->index; in cx23885_enum_input()
742 return -EINVAL; in cx23885_enum_input()
744 if (0 == INPUT(n)->type) in cx23885_enum_input()
745 return -EINVAL; in cx23885_enum_input()
747 i->index = n; in cx23885_enum_input()
748 i->type = V4L2_INPUT_TYPE_CAMERA; in cx23885_enum_input()
749 strscpy(i->name, iname[INPUT(n)->type], sizeof(i->name)); in cx23885_enum_input()
750 i->std = CX23885_NORMS; in cx23885_enum_input()
751 if ((CX23885_VMUX_TELEVISION == INPUT(n)->type) || in cx23885_enum_input()
752 (CX23885_VMUX_CABLE == INPUT(n)->type)) { in cx23885_enum_input()
753 i->type = V4L2_INPUT_TYPE_TUNER; in cx23885_enum_input()
754 i->audioset = 4; in cx23885_enum_input()
756 /* Two selectable audio inputs for non-tv inputs */ in cx23885_enum_input()
757 i->audioset = 3; in cx23885_enum_input()
760 if (dev->input == n) { in cx23885_enum_input()
766 call_all(dev, video, g_input_status, &i->status); in cx23885_enum_input()
784 *i = dev->input; in cx23885_get_input()
801 dprintk(1, "%s() -EINVAL\n", __func__); in cx23885_set_input()
802 return -EINVAL; in cx23885_set_input()
805 if (INPUT(i)->type == 0) in cx23885_set_input()
806 return -EINVAL; in cx23885_set_input()
840 n = i->index; in cx23885_query_audinput()
842 return -EINVAL; in cx23885_query_audinput()
845 i->index = n; in cx23885_query_audinput()
846 strscpy(i->name, iname[n], sizeof(i->name)); in cx23885_query_audinput()
847 i->capability = V4L2_AUDCAP_STEREO; in cx23885_query_audinput()
863 if ((CX23885_VMUX_TELEVISION == INPUT(dev->input)->type) || in vidioc_g_audinput()
864 (CX23885_VMUX_CABLE == INPUT(dev->input)->type)) in vidioc_g_audinput()
865 i->index = 2; in vidioc_g_audinput()
867 i->index = dev->audinput; in vidioc_g_audinput()
868 dprintk(1, "%s(input=%d)\n", __func__, i->index); in vidioc_g_audinput()
878 if ((CX23885_VMUX_TELEVISION == INPUT(dev->input)->type) || in vidioc_s_audinput()
879 (CX23885_VMUX_CABLE == INPUT(dev->input)->type)) { in vidioc_s_audinput()
880 return i->index != 2 ? -EINVAL : 0; in vidioc_s_audinput()
882 if (i->index > 1) in vidioc_s_audinput()
883 return -EINVAL; in vidioc_s_audinput()
885 dprintk(1, "%s(%d)\n", __func__, i->index); in vidioc_s_audinput()
887 dev->audinput = i->index; in vidioc_s_audinput()
891 cx23885_flatiron_mux(dev, dev->audinput + 1); in vidioc_s_audinput()
900 switch (dev->board) { /* i2c device tuners */ in vidioc_g_tuner()
907 if (dev->tuner_type == TUNER_ABSENT) in vidioc_g_tuner()
908 return -EINVAL; in vidioc_g_tuner()
911 if (0 != t->index) in vidioc_g_tuner()
912 return -EINVAL; in vidioc_g_tuner()
914 strscpy(t->name, "Television", sizeof(t->name)); in vidioc_g_tuner()
925 switch (dev->board) { /* i2c device tuners */ in vidioc_s_tuner()
932 if (dev->tuner_type == TUNER_ABSENT) in vidioc_s_tuner()
933 return -EINVAL; in vidioc_s_tuner()
936 if (0 != t->index) in vidioc_s_tuner()
937 return -EINVAL; in vidioc_s_tuner()
949 switch (dev->board) { /* i2c device tuners */ in vidioc_g_frequency()
956 if (dev->tuner_type == TUNER_ABSENT) in vidioc_g_frequency()
957 return -EINVAL; in vidioc_g_frequency()
960 f->type = V4L2_TUNER_ANALOG_TV; in vidioc_g_frequency()
961 f->frequency = dev->freq; in vidioc_g_frequency()
973 switch (dev->board) { /* i2c device tuners */ in cx23885_set_freq()
980 if (dev->tuner_type == TUNER_ABSENT) in cx23885_set_freq()
981 return -EINVAL; in cx23885_set_freq()
984 if (unlikely(f->tuner != 0)) in cx23885_set_freq()
985 return -EINVAL; in cx23885_set_freq()
987 dev->freq = f->frequency; in cx23885_set_freq()
990 mute = v4l2_ctrl_find(&dev->ctrl_handler, V4L2_CID_AUDIO_MUTE); in cx23885_set_freq()
1020 .std = dev->tvnorm, in cx23885_set_freq_via_ops()
1021 .frequency = f->frequency in cx23885_set_freq_via_ops()
1024 dev->freq = f->frequency; in cx23885_set_freq_via_ops()
1027 mute = v4l2_ctrl_find(&dev->ctrl_handler, V4L2_CID_AUDIO_MUTE); in cx23885_set_freq_via_ops()
1036 params.frequency, f->tuner, params.std); in cx23885_set_freq_via_ops()
1038 vfe = vb2_dvb_get_frontend(&dev->ts2.frontends, 1); in cx23885_set_freq_via_ops()
1040 return -EINVAL; in cx23885_set_freq_via_ops()
1043 fe = vfe->dvb.frontend; in cx23885_set_freq_via_ops()
1045 if ((dev->board == CX23885_BOARD_HAUPPAUGE_HVR1850) || in cx23885_set_freq_via_ops()
1046 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1255) || in cx23885_set_freq_via_ops()
1047 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1255_22111) || in cx23885_set_freq_via_ops()
1048 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1265_K4) || in cx23885_set_freq_via_ops()
1049 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR5525) || in cx23885_set_freq_via_ops()
1050 (dev->board == CX23885_BOARD_HAUPPAUGE_QUADHD_DVB) || in cx23885_set_freq_via_ops()
1051 (dev->board == CX23885_BOARD_HAUPPAUGE_QUADHD_ATSC)) in cx23885_set_freq_via_ops()
1052 fe = &dev->ts1.analog_fe; in cx23885_set_freq_via_ops()
1054 if (fe && fe->ops.tuner_ops.set_analog_params) { in cx23885_set_freq_via_ops()
1055 call_all(dev, video, s_std, dev->tvnorm); in cx23885_set_freq_via_ops()
1056 fe->ops.tuner_ops.set_analog_params(fe, ¶ms); in cx23885_set_freq_via_ops()
1077 switch (dev->board) { in cx23885_set_frequency()
1100 /* ----------------------------------------------------------- */
1122 dev->name); in cx23885_video_irq()
1124 &dev->sram_channels[SRAM_CH01]); in cx23885_video_irq()
1128 dprintk(7, " (VID_BC_MSK_SYNC 0x%08x) video lines miss-match\n", in cx23885_video_irq()
1139 spin_lock(&dev->slock); in cx23885_video_irq()
1141 cx23885_video_wakeup(dev, &dev->vidq, count); in cx23885_video_irq()
1142 spin_unlock(&dev->slock); in cx23885_video_irq()
1152 /* ----------------------------------------------------------- */
1207 .name = "cx23885-video",
1218 if (dev->vbi_dev) { in cx23885_video_unregister()
1219 if (video_is_registered(dev->vbi_dev)) in cx23885_video_unregister()
1220 video_unregister_device(dev->vbi_dev); in cx23885_video_unregister()
1222 video_device_release(dev->vbi_dev); in cx23885_video_unregister()
1223 dev->vbi_dev = NULL; in cx23885_video_unregister()
1225 if (dev->video_dev) { in cx23885_video_unregister()
1226 if (video_is_registered(dev->video_dev)) in cx23885_video_unregister()
1227 video_unregister_device(dev->video_dev); in cx23885_video_unregister()
1229 video_device_release(dev->video_dev); in cx23885_video_unregister()
1230 dev->video_dev = NULL; in cx23885_video_unregister()
1233 if (dev->audio_dev) in cx23885_video_unregister()
1246 strscpy(cx23885_vbi_template.name, "cx23885-vbi", in cx23885_video_register()
1249 dev->tvnorm = V4L2_STD_NTSC_M; in cx23885_video_register()
1250 dev->fmt = format_by_fourcc(V4L2_PIX_FMT_YUYV); in cx23885_video_register()
1251 dev->field = V4L2_FIELD_INTERLACED; in cx23885_video_register()
1252 dev->width = 720; in cx23885_video_register()
1253 dev->height = norm_maxh(dev->tvnorm); in cx23885_video_register()
1256 INIT_LIST_HEAD(&dev->vidq.active); in cx23885_video_register()
1259 INIT_LIST_HEAD(&dev->vbiq.active); in cx23885_video_register()
1263 if ((TUNER_ABSENT != dev->tuner_type) && in cx23885_video_register()
1264 ((dev->tuner_bus == 0) || (dev->tuner_bus == 1))) { in cx23885_video_register()
1267 if (dev->tuner_addr) in cx23885_video_register()
1268 sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, in cx23885_video_register()
1269 &dev->i2c_bus[dev->tuner_bus].i2c_adap, in cx23885_video_register()
1270 "tuner", dev->tuner_addr, NULL); in cx23885_video_register()
1272 sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, in cx23885_video_register()
1273 &dev->i2c_bus[dev->tuner_bus].i2c_adap, in cx23885_video_register()
1280 tun_setup.type = dev->tuner_type; in cx23885_video_register()
1286 if ((dev->board == CX23885_BOARD_LEADTEK_WINFAST_PXTV1200) || in cx23885_video_register()
1287 (dev->board == CX23885_BOARD_LEADTEK_WINFAST_PXPVR2200)) { in cx23885_video_register()
1292 struct v4l2_priv_tun_config cfg = { in cx23885_video_register() local
1293 .tuner = dev->tuner_type, in cx23885_video_register()
1296 v4l2_subdev_call(sd, tuner, s_config, &cfg); in cx23885_video_register()
1299 if (dev->board == CX23885_BOARD_AVERMEDIA_HC81R) { in cx23885_video_register()
1301 .fname = "xc3028L-v36.fw", in cx23885_video_register()
1304 struct v4l2_priv_tun_config cfg = { in cx23885_video_register() local
1305 .tuner = dev->tuner_type, in cx23885_video_register()
1308 v4l2_subdev_call(sd, tuner, s_config, &cfg); in cx23885_video_register()
1314 mutex_lock(&dev->lock); in cx23885_video_register()
1315 cx23885_set_tvnorm(dev, dev->tvnorm); in cx23885_video_register()
1318 mutex_unlock(&dev->lock); in cx23885_video_register()
1320 q = &dev->vb2_vidq; in cx23885_video_register()
1321 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; in cx23885_video_register()
1322 q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ; in cx23885_video_register()
1323 q->gfp_flags = GFP_DMA32; in cx23885_video_register()
1324 q->min_queued_buffers = 2; in cx23885_video_register()
1325 q->drv_priv = dev; in cx23885_video_register()
1326 q->buf_struct_size = sizeof(struct cx23885_buffer); in cx23885_video_register()
1327 q->ops = &cx23885_video_qops; in cx23885_video_register()
1328 q->mem_ops = &vb2_dma_sg_memops; in cx23885_video_register()
1329 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; in cx23885_video_register()
1330 q->lock = &dev->lock; in cx23885_video_register()
1331 q->dev = &dev->pci->dev; in cx23885_video_register()
1337 q = &dev->vb2_vbiq; in cx23885_video_register()
1338 q->type = V4L2_BUF_TYPE_VBI_CAPTURE; in cx23885_video_register()
1339 q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ; in cx23885_video_register()
1340 q->gfp_flags = GFP_DMA32; in cx23885_video_register()
1341 q->min_queued_buffers = 2; in cx23885_video_register()
1342 q->drv_priv = dev; in cx23885_video_register()
1343 q->buf_struct_size = sizeof(struct cx23885_buffer); in cx23885_video_register()
1344 q->ops = &cx23885_vbi_qops; in cx23885_video_register()
1345 q->mem_ops = &vb2_dma_sg_memops; in cx23885_video_register()
1346 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; in cx23885_video_register()
1347 q->lock = &dev->lock; in cx23885_video_register()
1348 q->dev = &dev->pci->dev; in cx23885_video_register()
1355 dev->video_dev = cx23885_vdev_init(dev, dev->pci, in cx23885_video_register()
1357 if (!dev->video_dev) { in cx23885_video_register()
1358 err = -ENOMEM; in cx23885_video_register()
1361 dev->video_dev->queue = &dev->vb2_vidq; in cx23885_video_register()
1362 dev->video_dev->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING | in cx23885_video_register()
1364 switch (dev->board) { /* i2c device tuners */ in cx23885_video_register()
1369 dev->video_dev->device_caps |= V4L2_CAP_TUNER; in cx23885_video_register()
1372 if (dev->tuner_type != TUNER_ABSENT) in cx23885_video_register()
1373 dev->video_dev->device_caps |= V4L2_CAP_TUNER; in cx23885_video_register()
1376 err = video_register_device(dev->video_dev, VFL_TYPE_VIDEO, in cx23885_video_register()
1377 video_nr[dev->nr]); in cx23885_video_register()
1380 dev->name); in cx23885_video_register()
1384 dev->name, video_device_node_name(dev->video_dev)); in cx23885_video_register()
1387 dev->vbi_dev = cx23885_vdev_init(dev, dev->pci, in cx23885_video_register()
1389 if (!dev->vbi_dev) { in cx23885_video_register()
1390 err = -ENOMEM; in cx23885_video_register()
1393 dev->vbi_dev->queue = &dev->vb2_vbiq; in cx23885_video_register()
1394 dev->vbi_dev->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING | in cx23885_video_register()
1396 switch (dev->board) { /* i2c device tuners */ in cx23885_video_register()
1401 dev->vbi_dev->device_caps |= V4L2_CAP_TUNER; in cx23885_video_register()
1404 if (dev->tuner_type != TUNER_ABSENT) in cx23885_video_register()
1405 dev->vbi_dev->device_caps |= V4L2_CAP_TUNER; in cx23885_video_register()
1407 err = video_register_device(dev->vbi_dev, VFL_TYPE_VBI, in cx23885_video_register()
1408 vbi_nr[dev->nr]); in cx23885_video_register()
1411 dev->name); in cx23885_video_register()
1415 dev->name, video_device_node_name(dev->vbi_dev)); in cx23885_video_register()
1418 dev->audio_dev = cx23885_audio_register(dev); in cx23885_video_register()