Lines Matching +full:input +full:- +full:depth
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 /* ------------------------------------------------------------------- */
71 .depth = 16,
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()
203 static int cx23885_flatiron_mux(struct cx23885_dev *dev, int input) in cx23885_flatiron_mux() argument
206 dprintk(1, "%s(input = %d)\n", __func__, input); in cx23885_flatiron_mux()
208 if (input == 1) in cx23885_flatiron_mux()
210 else if (input == 2) in cx23885_flatiron_mux()
213 return -EINVAL; in cx23885_flatiron_mux()
215 val |= 0x20; /* Enable clock to delta-sigma and dec filter */ in cx23885_flatiron_mux()
228 static int cx23885_video_mux(struct cx23885_dev *dev, unsigned int input) in cx23885_video_mux() argument
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()
278 static int cx23885_audio_mux(struct cx23885_dev *dev, unsigned int input) in cx23885_audio_mux() argument
280 dprintk(1, "%s(input=%d)\n", __func__, input); in cx23885_audio_mux()
288 * devs to specify which baseband input they need, or just default in cx23885_audio_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()
346 struct cx23885_dev *dev = vb->vb2_queue->drv_priv; in buffer_prepare()
353 buf->bpl = (dev->width * dev->fmt->depth) >> 3; in buffer_prepare()
355 if (vb2_plane_size(vb, 0) < dev->height * buf->bpl) in buffer_prepare()
356 return -EINVAL; in buffer_prepare()
357 vb2_set_plane_payload(vb, 0, dev->height * buf->bpl); in buffer_prepare()
359 switch (dev->field) { in buffer_prepare()
361 cx23885_risc_buffer(dev->pci, &buf->risc, in buffer_prepare()
362 sgt->sgl, 0, UNSET, in buffer_prepare()
363 buf->bpl, 0, dev->height); in buffer_prepare()
366 cx23885_risc_buffer(dev->pci, &buf->risc, in buffer_prepare()
367 sgt->sgl, UNSET, 0, in buffer_prepare()
368 buf->bpl, 0, dev->height); in buffer_prepare()
371 if (dev->tvnorm & V4L2_STD_525_60) in buffer_prepare()
377 if (cx23885_boards[dev->board].force_bff) in buffer_prepare()
385 line0_offset = buf->bpl; in buffer_prepare()
392 line1_offset = buf->bpl; in buffer_prepare()
394 cx23885_risc_buffer(dev->pci, &buf->risc, in buffer_prepare()
395 sgt->sgl, line0_offset, in buffer_prepare()
397 buf->bpl, buf->bpl, in buffer_prepare()
398 dev->height >> 1); in buffer_prepare()
401 cx23885_risc_buffer(dev->pci, &buf->risc, in buffer_prepare()
402 sgt->sgl, in buffer_prepare()
403 0, buf->bpl * (dev->height >> 1), in buffer_prepare()
404 buf->bpl, 0, in buffer_prepare()
405 dev->height >> 1); in buffer_prepare()
408 cx23885_risc_buffer(dev->pci, &buf->risc, in buffer_prepare()
409 sgt->sgl, in buffer_prepare()
410 buf->bpl * (dev->height >> 1), 0, in buffer_prepare()
411 buf->bpl, 0, in buffer_prepare()
412 dev->height >> 1); in buffer_prepare()
417 dprintk(2, "[%p/%d] buffer_init - %dx%d %dbpp 0x%08x - dma=0x%08lx\n", in buffer_prepare()
418 buf, buf->vb.vb2_buf.index, in buffer_prepare()
419 dev->width, dev->height, dev->fmt->depth, dev->fmt->fourcc, in buffer_prepare()
420 (unsigned long)buf->risc.dma); in buffer_prepare()
430 cx23885_free_buffer(vb->vb2_queue->drv_priv, buf); in buffer_finish()
451 * The end-result of all this that you only get an interrupt when a buffer
457 struct cx23885_dev *dev = vb->vb2_queue->drv_priv; in buffer_queue()
461 struct cx23885_dmaqueue *q = &dev->vidq; in buffer_queue()
465 buf->risc.cpu[1] = cpu_to_le32(buf->risc.dma + 12); in buffer_queue()
466 buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_CNT_INC); in buffer_queue()
467 buf->risc.jmp[1] = cpu_to_le32(buf->risc.dma + 12); in buffer_queue()
468 buf->risc.jmp[2] = cpu_to_le32(0); /* bits 63-32 */ in buffer_queue()
470 spin_lock_irqsave(&dev->slock, flags); in buffer_queue()
471 if (list_empty(&q->active)) { in buffer_queue()
472 list_add_tail(&buf->queue, &q->active); in buffer_queue()
473 dprintk(2, "[%p/%d] buffer_queue - first active\n", in buffer_queue()
474 buf, buf->vb.vb2_buf.index); in buffer_queue()
476 buf->risc.cpu[0] |= cpu_to_le32(RISC_IRQ1); in buffer_queue()
477 prev = list_entry(q->active.prev, struct cx23885_buffer, in buffer_queue()
479 list_add_tail(&buf->queue, &q->active); in buffer_queue()
480 prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); in buffer_queue()
481 dprintk(2, "[%p/%d] buffer_queue - append to active\n", in buffer_queue()
482 buf, buf->vb.vb2_buf.index); in buffer_queue()
484 spin_unlock_irqrestore(&dev->slock, flags); in buffer_queue()
489 struct cx23885_dev *dev = q->drv_priv; in cx23885_start_streaming()
490 struct cx23885_dmaqueue *dmaq = &dev->vidq; in cx23885_start_streaming()
491 struct cx23885_buffer *buf = list_entry(dmaq->active.next, in cx23885_start_streaming()
500 struct cx23885_dev *dev = q->drv_priv; in cx23885_stop_streaming()
501 struct cx23885_dmaqueue *dmaq = &dev->vidq; in cx23885_stop_streaming()
505 spin_lock_irqsave(&dev->slock, flags); in cx23885_stop_streaming()
506 while (!list_empty(&dmaq->active)) { in cx23885_stop_streaming()
507 struct cx23885_buffer *buf = list_entry(dmaq->active.next, in cx23885_stop_streaming()
510 list_del(&buf->queue); in cx23885_stop_streaming()
511 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); in cx23885_stop_streaming()
513 spin_unlock_irqrestore(&dev->slock, flags); in cx23885_stop_streaming()
527 /* ------------------------------------------------------------------ */
535 f->fmt.pix.width = dev->width; in vidioc_g_fmt_vid_cap()
536 f->fmt.pix.height = dev->height; in vidioc_g_fmt_vid_cap()
537 f->fmt.pix.field = dev->field; in vidioc_g_fmt_vid_cap()
538 f->fmt.pix.pixelformat = dev->fmt->fourcc; in vidioc_g_fmt_vid_cap()
539 f->fmt.pix.bytesperline = in vidioc_g_fmt_vid_cap()
540 (f->fmt.pix.width * dev->fmt->depth) >> 3; in vidioc_g_fmt_vid_cap()
541 f->fmt.pix.sizeimage = in vidioc_g_fmt_vid_cap()
542 f->fmt.pix.height * f->fmt.pix.bytesperline; in vidioc_g_fmt_vid_cap()
543 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; in vidioc_g_fmt_vid_cap()
556 fmt = format_by_fourcc(f->fmt.pix.pixelformat); in vidioc_try_fmt_vid_cap()
558 return -EINVAL; in vidioc_try_fmt_vid_cap()
560 field = f->fmt.pix.field; in vidioc_try_fmt_vid_cap()
562 maxh = norm_maxh(dev->tvnorm); in vidioc_try_fmt_vid_cap()
565 field = (f->fmt.pix.height > maxh/2) in vidioc_try_fmt_vid_cap()
584 f->fmt.pix.field = field; in vidioc_try_fmt_vid_cap()
585 v4l_bound_align_image(&f->fmt.pix.width, 48, maxw, 2, in vidioc_try_fmt_vid_cap()
586 &f->fmt.pix.height, 32, maxh, 0, 0); in vidioc_try_fmt_vid_cap()
587 f->fmt.pix.bytesperline = in vidioc_try_fmt_vid_cap()
588 (f->fmt.pix.width * fmt->depth) >> 3; in vidioc_try_fmt_vid_cap()
589 f->fmt.pix.sizeimage = in vidioc_try_fmt_vid_cap()
590 f->fmt.pix.height * f->fmt.pix.bytesperline; in vidioc_try_fmt_vid_cap()
591 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; in vidioc_try_fmt_vid_cap()
611 if (vb2_is_busy(&dev->vb2_vidq) || vb2_is_busy(&dev->vb2_vbiq) || in vidioc_s_fmt_vid_cap()
612 vb2_is_busy(&dev->vb2_mpegq)) in vidioc_s_fmt_vid_cap()
613 return -EBUSY; in vidioc_s_fmt_vid_cap()
615 dev->fmt = format_by_fourcc(f->fmt.pix.pixelformat); in vidioc_s_fmt_vid_cap()
616 dev->width = f->fmt.pix.width; in vidioc_s_fmt_vid_cap()
617 dev->height = f->fmt.pix.height; in vidioc_s_fmt_vid_cap()
618 dev->field = f->fmt.pix.field; in vidioc_s_fmt_vid_cap()
620 dev->width, dev->height, dev->field); in vidioc_s_fmt_vid_cap()
621 v4l2_fill_mbus_format(&format.format, &f->fmt.pix, MEDIA_BUS_FMT_FIXED); in vidioc_s_fmt_vid_cap()
623 v4l2_fill_pix_format(&f->fmt.pix, &format.format); in vidioc_s_fmt_vid_cap()
624 /* set_fmt overwrites f->fmt.pix.field, restore it */ in vidioc_s_fmt_vid_cap()
625 f->fmt.pix.field = dev->field; in vidioc_s_fmt_vid_cap()
634 strscpy(cap->driver, "cx23885", sizeof(cap->driver)); in vidioc_querycap()
635 strscpy(cap->card, cx23885_boards[dev->board].name, in vidioc_querycap()
636 sizeof(cap->card)); in vidioc_querycap()
637 sprintf(cap->bus_info, "PCIe:%s", pci_name(dev->pci)); in vidioc_querycap()
638 cap->capabilities = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING | in vidioc_querycap()
642 switch (dev->board) { /* i2c device tuners */ in vidioc_querycap()
647 cap->capabilities |= V4L2_CAP_TUNER; in vidioc_querycap()
650 if (dev->tuner_type != TUNER_ABSENT) in vidioc_querycap()
651 cap->capabilities |= V4L2_CAP_TUNER; in vidioc_querycap()
660 if (unlikely(f->index >= ARRAY_SIZE(formats))) in vidioc_enum_fmt_vid_cap()
661 return -EINVAL; in vidioc_enum_fmt_vid_cap()
663 f->pixelformat = formats[f->index].fourcc; in vidioc_enum_fmt_vid_cap()
672 bool is_50hz = dev->tvnorm & V4L2_STD_625_50; in vidioc_g_pixelaspect()
675 return -EINVAL; in vidioc_g_pixelaspect()
677 f->numerator = is_50hz ? 54 : 11; in vidioc_g_pixelaspect()
678 f->denominator = is_50hz ? 59 : 10; in vidioc_g_pixelaspect()
688 if (sel->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) in vidioc_g_selection()
689 return -EINVAL; in vidioc_g_selection()
691 switch (sel->target) { in vidioc_g_selection()
694 sel->r.top = 0; in vidioc_g_selection()
695 sel->r.left = 0; in vidioc_g_selection()
696 sel->r.width = 720; in vidioc_g_selection()
697 sel->r.height = norm_maxh(dev->tvnorm); in vidioc_g_selection()
700 return -EINVAL; in vidioc_g_selection()
710 *id = dev->tvnorm; in vidioc_g_std()
729 [CX23885_VMUX_SVIDEO] = "S-Video", in cx23885_enum_input()
739 n = i->index; in cx23885_enum_input()
741 return -EINVAL; in cx23885_enum_input()
743 if (0 == INPUT(n)->type) in cx23885_enum_input()
744 return -EINVAL; in cx23885_enum_input()
746 i->index = n; in cx23885_enum_input()
747 i->type = V4L2_INPUT_TYPE_CAMERA; in cx23885_enum_input()
748 strscpy(i->name, iname[INPUT(n)->type], sizeof(i->name)); in cx23885_enum_input()
749 i->std = CX23885_NORMS; in cx23885_enum_input()
750 if ((CX23885_VMUX_TELEVISION == INPUT(n)->type) || in cx23885_enum_input()
751 (CX23885_VMUX_CABLE == INPUT(n)->type)) { in cx23885_enum_input()
752 i->type = V4L2_INPUT_TYPE_TUNER; in cx23885_enum_input()
753 i->audioset = 4; in cx23885_enum_input()
755 /* Two selectable audio inputs for non-tv inputs */ in cx23885_enum_input()
756 i->audioset = 3; in cx23885_enum_input()
759 if (dev->input == n) { in cx23885_enum_input()
760 /* enum'd input matches our configured input. in cx23885_enum_input()
765 call_all(dev, video, g_input_status, &i->status); in cx23885_enum_input()
783 *i = dev->input; in cx23885_get_input()
800 dprintk(1, "%s() -EINVAL\n", __func__); in cx23885_set_input()
801 return -EINVAL; in cx23885_set_input()
804 if (INPUT(i)->type == 0) in cx23885_set_input()
805 return -EINVAL; in cx23885_set_input()
809 /* By default establish the default audio input for the card also */ in cx23885_set_input()
839 n = i->index; in cx23885_query_audinput()
841 return -EINVAL; in cx23885_query_audinput()
844 i->index = n; in cx23885_query_audinput()
845 strscpy(i->name, iname[n], sizeof(i->name)); in cx23885_query_audinput()
846 i->capability = V4L2_AUDCAP_STEREO; in cx23885_query_audinput()
862 if ((CX23885_VMUX_TELEVISION == INPUT(dev->input)->type) || in vidioc_g_audinput()
863 (CX23885_VMUX_CABLE == INPUT(dev->input)->type)) in vidioc_g_audinput()
864 i->index = 2; in vidioc_g_audinput()
866 i->index = dev->audinput; in vidioc_g_audinput()
867 dprintk(1, "%s(input=%d)\n", __func__, i->index); in vidioc_g_audinput()
877 if ((CX23885_VMUX_TELEVISION == INPUT(dev->input)->type) || in vidioc_s_audinput()
878 (CX23885_VMUX_CABLE == INPUT(dev->input)->type)) { in vidioc_s_audinput()
879 return i->index != 2 ? -EINVAL : 0; in vidioc_s_audinput()
881 if (i->index > 1) in vidioc_s_audinput()
882 return -EINVAL; in vidioc_s_audinput()
884 dprintk(1, "%s(%d)\n", __func__, i->index); in vidioc_s_audinput()
886 dev->audinput = i->index; in vidioc_s_audinput()
890 cx23885_flatiron_mux(dev, dev->audinput + 1); in vidioc_s_audinput()
899 switch (dev->board) { /* i2c device tuners */ in vidioc_g_tuner()
906 if (dev->tuner_type == TUNER_ABSENT) in vidioc_g_tuner()
907 return -EINVAL; in vidioc_g_tuner()
910 if (0 != t->index) in vidioc_g_tuner()
911 return -EINVAL; in vidioc_g_tuner()
913 strscpy(t->name, "Television", sizeof(t->name)); in vidioc_g_tuner()
924 switch (dev->board) { /* i2c device tuners */ in vidioc_s_tuner()
931 if (dev->tuner_type == TUNER_ABSENT) in vidioc_s_tuner()
932 return -EINVAL; in vidioc_s_tuner()
935 if (0 != t->index) in vidioc_s_tuner()
936 return -EINVAL; in vidioc_s_tuner()
948 switch (dev->board) { /* i2c device tuners */ in vidioc_g_frequency()
955 if (dev->tuner_type == TUNER_ABSENT) in vidioc_g_frequency()
956 return -EINVAL; in vidioc_g_frequency()
959 f->type = V4L2_TUNER_ANALOG_TV; in vidioc_g_frequency()
960 f->frequency = dev->freq; in vidioc_g_frequency()
972 switch (dev->board) { /* i2c device tuners */ in cx23885_set_freq()
979 if (dev->tuner_type == TUNER_ABSENT) in cx23885_set_freq()
980 return -EINVAL; in cx23885_set_freq()
983 if (unlikely(f->tuner != 0)) in cx23885_set_freq()
984 return -EINVAL; in cx23885_set_freq()
986 dev->freq = f->frequency; in cx23885_set_freq()
989 mute = v4l2_ctrl_find(&dev->ctrl_handler, V4L2_CID_AUDIO_MUTE); in cx23885_set_freq()
1019 .std = dev->tvnorm, in cx23885_set_freq_via_ops()
1020 .frequency = f->frequency in cx23885_set_freq_via_ops()
1023 dev->freq = f->frequency; in cx23885_set_freq_via_ops()
1026 mute = v4l2_ctrl_find(&dev->ctrl_handler, V4L2_CID_AUDIO_MUTE); in cx23885_set_freq_via_ops()
1035 params.frequency, f->tuner, params.std); in cx23885_set_freq_via_ops()
1037 vfe = vb2_dvb_get_frontend(&dev->ts2.frontends, 1); in cx23885_set_freq_via_ops()
1039 return -EINVAL; in cx23885_set_freq_via_ops()
1042 fe = vfe->dvb.frontend; in cx23885_set_freq_via_ops()
1044 if ((dev->board == CX23885_BOARD_HAUPPAUGE_HVR1850) || in cx23885_set_freq_via_ops()
1045 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1255) || in cx23885_set_freq_via_ops()
1046 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1255_22111) || in cx23885_set_freq_via_ops()
1047 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1265_K4) || in cx23885_set_freq_via_ops()
1048 (dev->board == CX23885_BOARD_HAUPPAUGE_HVR5525) || in cx23885_set_freq_via_ops()
1049 (dev->board == CX23885_BOARD_HAUPPAUGE_QUADHD_DVB) || in cx23885_set_freq_via_ops()
1050 (dev->board == CX23885_BOARD_HAUPPAUGE_QUADHD_ATSC)) in cx23885_set_freq_via_ops()
1051 fe = &dev->ts1.analog_fe; in cx23885_set_freq_via_ops()
1053 if (fe && fe->ops.tuner_ops.set_analog_params) { in cx23885_set_freq_via_ops()
1054 call_all(dev, video, s_std, dev->tvnorm); in cx23885_set_freq_via_ops()
1055 fe->ops.tuner_ops.set_analog_params(fe, ¶ms); in cx23885_set_freq_via_ops()
1076 switch (dev->board) { in cx23885_set_frequency()
1099 /* ----------------------------------------------------------- */
1121 dev->name); in cx23885_video_irq()
1123 &dev->sram_channels[SRAM_CH01]); in cx23885_video_irq()
1127 dprintk(7, " (VID_BC_MSK_SYNC 0x%08x) video lines miss-match\n", in cx23885_video_irq()
1138 spin_lock(&dev->slock); in cx23885_video_irq()
1140 cx23885_video_wakeup(dev, &dev->vidq, count); in cx23885_video_irq()
1141 spin_unlock(&dev->slock); in cx23885_video_irq()
1151 /* ----------------------------------------------------------- */
1206 .name = "cx23885-video",
1217 if (dev->vbi_dev) { in cx23885_video_unregister()
1218 if (video_is_registered(dev->vbi_dev)) in cx23885_video_unregister()
1219 video_unregister_device(dev->vbi_dev); in cx23885_video_unregister()
1221 video_device_release(dev->vbi_dev); in cx23885_video_unregister()
1222 dev->vbi_dev = NULL; in cx23885_video_unregister()
1224 if (dev->video_dev) { in cx23885_video_unregister()
1225 if (video_is_registered(dev->video_dev)) in cx23885_video_unregister()
1226 video_unregister_device(dev->video_dev); in cx23885_video_unregister()
1228 video_device_release(dev->video_dev); in cx23885_video_unregister()
1229 dev->video_dev = NULL; in cx23885_video_unregister()
1232 if (dev->audio_dev) in cx23885_video_unregister()
1245 strscpy(cx23885_vbi_template.name, "cx23885-vbi", in cx23885_video_register()
1248 dev->tvnorm = V4L2_STD_NTSC_M; in cx23885_video_register()
1249 dev->fmt = format_by_fourcc(V4L2_PIX_FMT_YUYV); in cx23885_video_register()
1250 dev->field = V4L2_FIELD_INTERLACED; in cx23885_video_register()
1251 dev->width = 720; in cx23885_video_register()
1252 dev->height = norm_maxh(dev->tvnorm); in cx23885_video_register()
1255 INIT_LIST_HEAD(&dev->vidq.active); in cx23885_video_register()
1258 INIT_LIST_HEAD(&dev->vbiq.active); in cx23885_video_register()
1262 if ((TUNER_ABSENT != dev->tuner_type) && in cx23885_video_register()
1263 ((dev->tuner_bus == 0) || (dev->tuner_bus == 1))) { in cx23885_video_register()
1266 if (dev->tuner_addr) in cx23885_video_register()
1267 sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, in cx23885_video_register()
1268 &dev->i2c_bus[dev->tuner_bus].i2c_adap, in cx23885_video_register()
1269 "tuner", dev->tuner_addr, NULL); in cx23885_video_register()
1271 sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, in cx23885_video_register()
1272 &dev->i2c_bus[dev->tuner_bus].i2c_adap, in cx23885_video_register()
1279 tun_setup.type = dev->tuner_type; in cx23885_video_register()
1285 if ((dev->board == CX23885_BOARD_LEADTEK_WINFAST_PXTV1200) || in cx23885_video_register()
1286 (dev->board == CX23885_BOARD_LEADTEK_WINFAST_PXPVR2200)) { in cx23885_video_register()
1292 .tuner = dev->tuner_type, in cx23885_video_register()
1298 if (dev->board == CX23885_BOARD_AVERMEDIA_HC81R) { in cx23885_video_register()
1300 .fname = "xc3028L-v36.fw", in cx23885_video_register()
1304 .tuner = dev->tuner_type, in cx23885_video_register()
1313 mutex_lock(&dev->lock); in cx23885_video_register()
1314 cx23885_set_tvnorm(dev, dev->tvnorm); in cx23885_video_register()
1317 mutex_unlock(&dev->lock); in cx23885_video_register()
1319 q = &dev->vb2_vidq; in cx23885_video_register()
1320 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; in cx23885_video_register()
1321 q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ; in cx23885_video_register()
1322 q->gfp_flags = GFP_DMA32; in cx23885_video_register()
1323 q->min_buffers_needed = 2; in cx23885_video_register()
1324 q->drv_priv = dev; in cx23885_video_register()
1325 q->buf_struct_size = sizeof(struct cx23885_buffer); in cx23885_video_register()
1326 q->ops = &cx23885_video_qops; in cx23885_video_register()
1327 q->mem_ops = &vb2_dma_sg_memops; in cx23885_video_register()
1328 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; in cx23885_video_register()
1329 q->lock = &dev->lock; in cx23885_video_register()
1330 q->dev = &dev->pci->dev; in cx23885_video_register()
1336 q = &dev->vb2_vbiq; in cx23885_video_register()
1337 q->type = V4L2_BUF_TYPE_VBI_CAPTURE; in cx23885_video_register()
1338 q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ; in cx23885_video_register()
1339 q->gfp_flags = GFP_DMA32; in cx23885_video_register()
1340 q->min_buffers_needed = 2; in cx23885_video_register()
1341 q->drv_priv = dev; in cx23885_video_register()
1342 q->buf_struct_size = sizeof(struct cx23885_buffer); in cx23885_video_register()
1343 q->ops = &cx23885_vbi_qops; in cx23885_video_register()
1344 q->mem_ops = &vb2_dma_sg_memops; in cx23885_video_register()
1345 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; in cx23885_video_register()
1346 q->lock = &dev->lock; in cx23885_video_register()
1347 q->dev = &dev->pci->dev; in cx23885_video_register()
1354 dev->video_dev = cx23885_vdev_init(dev, dev->pci, in cx23885_video_register()
1356 dev->video_dev->queue = &dev->vb2_vidq; in cx23885_video_register()
1357 dev->video_dev->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING | in cx23885_video_register()
1359 switch (dev->board) { /* i2c device tuners */ in cx23885_video_register()
1364 dev->video_dev->device_caps |= V4L2_CAP_TUNER; in cx23885_video_register()
1367 if (dev->tuner_type != TUNER_ABSENT) in cx23885_video_register()
1368 dev->video_dev->device_caps |= V4L2_CAP_TUNER; in cx23885_video_register()
1371 err = video_register_device(dev->video_dev, VFL_TYPE_VIDEO, in cx23885_video_register()
1372 video_nr[dev->nr]); in cx23885_video_register()
1375 dev->name); in cx23885_video_register()
1379 dev->name, video_device_node_name(dev->video_dev)); in cx23885_video_register()
1382 dev->vbi_dev = cx23885_vdev_init(dev, dev->pci, in cx23885_video_register()
1384 dev->vbi_dev->queue = &dev->vb2_vbiq; in cx23885_video_register()
1385 dev->vbi_dev->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING | in cx23885_video_register()
1387 switch (dev->board) { /* i2c device tuners */ in cx23885_video_register()
1392 dev->vbi_dev->device_caps |= V4L2_CAP_TUNER; in cx23885_video_register()
1395 if (dev->tuner_type != TUNER_ABSENT) in cx23885_video_register()
1396 dev->vbi_dev->device_caps |= V4L2_CAP_TUNER; in cx23885_video_register()
1398 err = video_register_device(dev->vbi_dev, VFL_TYPE_VBI, in cx23885_video_register()
1399 vbi_nr[dev->nr]); in cx23885_video_register()
1402 dev->name); in cx23885_video_register()
1406 dev->name, video_device_node_name(dev->vbi_dev)); in cx23885_video_register()
1409 dev->audio_dev = cx23885_audio_register(dev); in cx23885_video_register()