Lines Matching +full:gop +full:- +full:port +full:- +full:id

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Support for a cx23416 mpeg encoder via cx2388x host port.
9 * (c) 2005-2006 Mauro Carvalho Chehab <mchehab@kernel.org>
10 * - video_ioctl2 conversion
24 #include <media/v4l2-common.h>
25 #include <media/v4l2-ioctl.h>
26 #include <media/v4l2-event.h>
27 #include <media/drv-intf/cx2341x.h>
44 /* ------------------------------------------------------------------ */
48 /* defines below are from ivtv-driver.h */
71 BLACKBIRD_END_AT_GOP, /* stop at the end of gop, generate irq */
142 BLACKBIRD_NOTIFICATION_NO_MAILBOX = -1,
187 /* ------------------------------------------------------------------ */
197 /* host port setup */ in host_setup()
206 /* ------------------------------------------------------------------ */
234 return -1; in wait_ready_gpio0_bit1()
316 /* ------------------------------------------------------------------ */
332 memory_read(dev->core, dev->mailbox - 4, &value); in blackbird_mbox_func()
336 return -EIO; in blackbird_mbox_func()
339 memory_read(dev->core, dev->mailbox, &flag); in blackbird_mbox_func()
342 return -EIO; in blackbird_mbox_func()
346 memory_write(dev->core, dev->mailbox, flag); in blackbird_mbox_func()
349 memory_write(dev->core, dev->mailbox + 1, command); /* command code */ in blackbird_mbox_func()
351 memory_write(dev->core, dev->mailbox + 3, IVTV_API_STD_TIMEOUT); in blackbird_mbox_func()
353 memory_write(dev->core, dev->mailbox + 4 + i, data[i]); in blackbird_mbox_func()
357 memory_write(dev->core, dev->mailbox + 4 + i, 0); in blackbird_mbox_func()
360 memory_write(dev->core, dev->mailbox, flag); in blackbird_mbox_func()
365 memory_read(dev->core, dev->mailbox, &flag); in blackbird_mbox_func()
370 return -EIO; in blackbird_mbox_func()
377 memory_read(dev->core, dev->mailbox + 4 + i, data + i); in blackbird_mbox_func()
381 memory_read(dev->core, dev->mailbox + 2, &retval); in blackbird_mbox_func()
385 memory_write(dev->core, dev->mailbox, flag); in blackbird_mbox_func()
389 /* ------------------------------------------------------------------ */
424 memory_read(dev->core, i, &value); in blackbird_find_mailbox()
435 return -EIO; in blackbird_find_mailbox()
449 retval = register_write(dev->core, IVTV_REG_VPU, 0xFFFFFFED); in blackbird_load_firmware()
450 retval |= register_write(dev->core, IVTV_REG_HW_BLOCKS, in blackbird_load_firmware()
452 retval |= register_write(dev->core, IVTV_REG_ENC_SDRAM_REFRESH, in blackbird_load_firmware()
454 retval |= register_write(dev->core, IVTV_REG_ENC_SDRAM_PRECHARGE, in blackbird_load_firmware()
457 retval |= register_write(dev->core, IVTV_REG_APU, 0); in blackbird_load_firmware()
463 &dev->pci->dev); in blackbird_load_firmware()
469 return -EIO; in blackbird_load_firmware()
472 if (firmware->size != BLACKBIRD_FIRM_IMAGE_SIZE) { in blackbird_load_firmware()
474 firmware->size, BLACKBIRD_FIRM_IMAGE_SIZE); in blackbird_load_firmware()
476 return -EINVAL; in blackbird_load_firmware()
479 if (memcmp(firmware->data, magic, 8) != 0) { in blackbird_load_firmware()
482 return -EINVAL; in blackbird_load_firmware()
487 dataptr = (__le32 *)firmware->data; in blackbird_load_firmware()
488 for (i = 0; i < (firmware->size >> 2); i++) { in blackbird_load_firmware()
491 memory_write(dev->core, i, value); in blackbird_load_firmware()
496 for (i--; i >= 0; i--) { in blackbird_load_firmware()
497 memory_read(dev->core, i, &value); in blackbird_load_firmware()
498 checksum -= ~value; in blackbird_load_firmware()
503 return -EIO; in blackbird_load_firmware()
507 retval |= register_write(dev->core, IVTV_REG_HW_BLOCKS, in blackbird_load_firmware()
509 retval |= register_read(dev->core, IVTV_REG_SPU, &value); in blackbird_load_firmware()
510 retval |= register_write(dev->core, IVTV_REG_SPU, value & 0xFFFFFFFE); in blackbird_load_firmware()
513 retval |= register_read(dev->core, IVTV_REG_VPU, &value); in blackbird_load_firmware()
514 retval |= register_write(dev->core, IVTV_REG_VPU, value & 0xFFFFFFE8); in blackbird_load_firmware()
525 …* ------------------------------------------------------------------------------------------------…
526 …* MPEG-1 | MPEG1 | 352x288PAL | (CBR) | 1000:Optimal | 2000 Kbps | 25fps | MPG1 Layer2 | 224…
527 …* MPEG-2 | MPEG2 | 720x576PAL | VBR | 600 :Good | 4000 Kbps | 25fps | MPG1 Layer2 | 224…
537 struct cx88_core *core = dev->core; in blackbird_codec_settings()
541 core->height, core->width); in blackbird_codec_settings()
543 dev->cxhdl.width = core->width; in blackbird_codec_settings()
544 dev->cxhdl.height = core->height; in blackbird_codec_settings()
545 cx2341x_handler_set_50hz(&dev->cxhdl, in blackbird_codec_settings()
546 dev->core->tvnorm & V4L2_STD_625_50); in blackbird_codec_settings()
547 cx2341x_handler_setup(&dev->cxhdl); in blackbird_codec_settings()
552 struct cx88_core *core = dev->core; in blackbird_initialize_codec()
568 return -1; in blackbird_initialize_codec()
570 dev->mailbox = retval; in blackbird_initialize_codec()
576 return -1; in blackbird_initialize_codec()
584 return -1; in blackbird_initialize_codec()
589 cx_write(MO_PINMUX_IO, 0x88); /* 656-8bit IO and enable MPEG parallel IO */ in blackbird_initialize_codec()
591 cx_write(MO_VBOS_CONTROL, 0x84A00); /* no 656 mode, 8-bit pixels, disable VBI */ in blackbird_initialize_codec()
592 cx_clear(MO_OUTPUT_FORMAT, 0x0008); /* Normal Y-limits to let the mpeg encoder sync */ in blackbird_initialize_codec()
608 struct cx88_core *core = dev->core; in blackbird_start_codec()
613 int lastchange = -1; in blackbird_start_codec()
635 cx2341x_handler_set_busy(&dev->cxhdl, 1); in blackbird_start_codec()
651 cx2341x_handler_set_busy(&dev->cxhdl, 0); in blackbird_stop_codec()
656 /* ------------------------------------------------------------------ */
662 struct cx8802_dev *dev = q->drv_priv; in queue_setup()
665 dev->ts_packet_size = 188 * 4; in queue_setup()
666 dev->ts_packet_count = 32; in queue_setup()
667 sizes[0] = dev->ts_packet_size * dev->ts_packet_count; in queue_setup()
674 struct cx8802_dev *dev = vb->vb2_queue->drv_priv; in buffer_prepare()
677 return cx8802_buf_prepare(vb->vb2_queue, dev, buf); in buffer_prepare()
683 struct cx8802_dev *dev = vb->vb2_queue->drv_priv; in buffer_finish()
685 struct cx88_riscmem *risc = &buf->risc; in buffer_finish()
687 if (risc->cpu) in buffer_finish()
688 dma_free_coherent(&dev->pci->dev, risc->size, risc->cpu, in buffer_finish()
689 risc->dma); in buffer_finish()
696 struct cx8802_dev *dev = vb->vb2_queue->drv_priv; in buffer_queue()
704 struct cx8802_dev *dev = q->drv_priv; in start_streaming()
705 struct cx88_dmaqueue *dmaq = &dev->mpegq; in start_streaming()
715 err = -ENODEV; in start_streaming()
719 err = drv->request_acquire(drv); in start_streaming()
727 drv->request_release(drv); in start_streaming()
728 err = -EINVAL; in start_streaming()
734 buf = list_entry(dmaq->active.next, struct cx88_buffer, list); in start_streaming()
740 spin_lock_irqsave(&dev->slock, flags); in start_streaming()
741 while (!list_empty(&dmaq->active)) { in start_streaming()
742 struct cx88_buffer *buf = list_entry(dmaq->active.next, in start_streaming()
745 list_del(&buf->list); in start_streaming()
746 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_QUEUED); in start_streaming()
748 spin_unlock_irqrestore(&dev->slock, flags); in start_streaming()
754 struct cx8802_dev *dev = q->drv_priv; in stop_streaming()
755 struct cx88_dmaqueue *dmaq = &dev->mpegq; in stop_streaming()
766 drv->request_release(drv); in stop_streaming()
768 spin_lock_irqsave(&dev->slock, flags); in stop_streaming()
769 while (!list_empty(&dmaq->active)) { in stop_streaming()
770 struct cx88_buffer *buf = list_entry(dmaq->active.next, in stop_streaming()
773 list_del(&buf->list); in stop_streaming()
774 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); in stop_streaming()
776 spin_unlock_irqrestore(&dev->slock, flags); in stop_streaming()
790 /* ------------------------------------------------------------------ */
796 struct cx88_core *core = dev->core; in vidioc_querycap()
798 strscpy(cap->driver, "cx88_blackbird", sizeof(cap->driver)); in vidioc_querycap()
805 if (f->index != 0) in vidioc_enum_fmt_vid_cap()
806 return -EINVAL; in vidioc_enum_fmt_vid_cap()
808 f->pixelformat = V4L2_PIX_FMT_MPEG; in vidioc_enum_fmt_vid_cap()
816 struct cx88_core *core = dev->core; in vidioc_g_fmt_vid_cap()
818 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; in vidioc_g_fmt_vid_cap()
819 f->fmt.pix.bytesperline = 0; in vidioc_g_fmt_vid_cap()
820 f->fmt.pix.sizeimage = dev->ts_packet_size * dev->ts_packet_count; in vidioc_g_fmt_vid_cap()
821 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; in vidioc_g_fmt_vid_cap()
822 f->fmt.pix.width = core->width; in vidioc_g_fmt_vid_cap()
823 f->fmt.pix.height = core->height; in vidioc_g_fmt_vid_cap()
824 f->fmt.pix.field = core->field; in vidioc_g_fmt_vid_cap()
832 struct cx88_core *core = dev->core; in vidioc_try_fmt_vid_cap()
836 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; in vidioc_try_fmt_vid_cap()
837 f->fmt.pix.bytesperline = 0; in vidioc_try_fmt_vid_cap()
838 f->fmt.pix.sizeimage = dev->ts_packet_size * dev->ts_packet_count; in vidioc_try_fmt_vid_cap()
839 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; in vidioc_try_fmt_vid_cap()
841 maxw = norm_maxw(core->tvnorm); in vidioc_try_fmt_vid_cap()
842 maxh = norm_maxh(core->tvnorm); in vidioc_try_fmt_vid_cap()
844 field = f->fmt.pix.field; in vidioc_try_fmt_vid_cap()
854 field = (f->fmt.pix.height > maxh / 2) in vidioc_try_fmt_vid_cap()
862 v4l_bound_align_image(&f->fmt.pix.width, 48, maxw, 2, in vidioc_try_fmt_vid_cap()
863 &f->fmt.pix.height, 32, maxh, 0, 0); in vidioc_try_fmt_vid_cap()
864 f->fmt.pix.field = field; in vidioc_try_fmt_vid_cap()
872 struct cx88_core *core = dev->core; in vidioc_s_fmt_vid_cap()
874 if (vb2_is_busy(&dev->vb2_mpegq)) in vidioc_s_fmt_vid_cap()
875 return -EBUSY; in vidioc_s_fmt_vid_cap()
876 if (core->v4ldev && (vb2_is_busy(&core->v4ldev->vb2_vidq) || in vidioc_s_fmt_vid_cap()
877 vb2_is_busy(&core->v4ldev->vb2_vbiq))) in vidioc_s_fmt_vid_cap()
878 return -EBUSY; in vidioc_s_fmt_vid_cap()
880 core->width = f->fmt.pix.width; in vidioc_s_fmt_vid_cap()
881 core->height = f->fmt.pix.height; in vidioc_s_fmt_vid_cap()
882 core->field = f->fmt.pix.field; in vidioc_s_fmt_vid_cap()
883 cx88_set_scale(core, f->fmt.pix.width, f->fmt.pix.height, in vidioc_s_fmt_vid_cap()
884 f->fmt.pix.field); in vidioc_s_fmt_vid_cap()
886 f->fmt.pix.height, f->fmt.pix.width); in vidioc_s_fmt_vid_cap()
894 struct cx88_core *core = dev->core; in vidioc_s_frequency()
897 if (unlikely(core->board.tuner_type == UNSET)) in vidioc_s_frequency()
898 return -EINVAL; in vidioc_s_frequency()
899 if (unlikely(f->tuner != 0)) in vidioc_s_frequency()
900 return -EINVAL; in vidioc_s_frequency()
901 streaming = vb2_start_streaming_called(&dev->vb2_mpegq); in vidioc_s_frequency()
907 cx88_set_scale(core, core->width, core->height, core->field); in vidioc_s_frequency()
916 struct cx88_core *core = dev->core; in vidioc_log_status()
919 snprintf(name, sizeof(name), "%s/2", core->name); in vidioc_log_status()
921 v4l2_ctrl_handler_log_status(&dev->cxhdl.hdl, name); in vidioc_log_status()
929 struct cx88_core *core = dev->core; in vidioc_enum_input()
938 struct cx88_core *core = dev->core; in vidioc_g_frequency()
940 if (unlikely(core->board.tuner_type == UNSET)) in vidioc_g_frequency()
941 return -EINVAL; in vidioc_g_frequency()
942 if (unlikely(f->tuner != 0)) in vidioc_g_frequency()
943 return -EINVAL; in vidioc_g_frequency()
945 f->frequency = core->freq; in vidioc_g_frequency()
954 struct cx88_core *core = dev->core; in vidioc_g_input()
956 *i = core->input; in vidioc_g_input()
963 struct cx88_core *core = dev->core; in vidioc_s_input()
966 return -EINVAL; in vidioc_s_input()
968 return -EINVAL; in vidioc_s_input()
979 struct cx88_core *core = dev->core; in vidioc_g_tuner()
982 if (unlikely(core->board.tuner_type == UNSET)) in vidioc_g_tuner()
983 return -EINVAL; in vidioc_g_tuner()
984 if (t->index != 0) in vidioc_g_tuner()
985 return -EINVAL; in vidioc_g_tuner()
987 strscpy(t->name, "Television", sizeof(t->name)); in vidioc_g_tuner()
988 t->capability = V4L2_TUNER_CAP_NORM; in vidioc_g_tuner()
989 t->rangehigh = 0xffffffffUL; in vidioc_g_tuner()
994 t->signal = (reg & (1 << 5)) ? 0xffff : 0x0000; in vidioc_g_tuner()
1002 struct cx88_core *core = dev->core; in vidioc_s_tuner()
1004 if (core->board.tuner_type == UNSET) in vidioc_s_tuner()
1005 return -EINVAL; in vidioc_s_tuner()
1006 if (t->index != 0) in vidioc_s_tuner()
1007 return -EINVAL; in vidioc_s_tuner()
1009 cx88_set_stereo(core, t->audmode, 1); in vidioc_s_tuner()
1016 struct cx88_core *core = dev->core; in vidioc_g_std()
1018 *tvnorm = core->tvnorm; in vidioc_g_std()
1022 static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id id) in vidioc_s_std() argument
1025 struct cx88_core *core = dev->core; in vidioc_s_std()
1027 return cx88_set_tvnorm(core, id); in vidioc_s_std()
1073 /* ------------------------------------------------------------------ */
1078 struct cx88_core *core = drv->core; in cx8802_blackbird_advise_acquire()
1081 switch (core->boardnr) { in cx8802_blackbird_advise_acquire()
1087 * We're being given access to re-arrange the GPIOs. in cx8802_blackbird_advise_acquire()
1097 /* tri-state the cx22702 pins */ in cx8802_blackbird_advise_acquire()
1102 err = -ENODEV; in cx8802_blackbird_advise_acquire()
1110 struct cx88_core *core = drv->core; in cx8802_blackbird_advise_release()
1113 switch (core->boardnr) { in cx8802_blackbird_advise_release()
1118 err = -ENODEV; in cx8802_blackbird_advise_release()
1125 video_unregister_device(&dev->mpeg_dev); in blackbird_unregister_video()
1132 cx88_vdev_init(dev->core, dev->pci, &dev->mpeg_dev, in blackbird_register_video()
1134 dev->mpeg_dev.ctrl_handler = &dev->cxhdl.hdl; in blackbird_register_video()
1135 video_set_drvdata(&dev->mpeg_dev, dev); in blackbird_register_video()
1136 dev->mpeg_dev.queue = &dev->vb2_mpegq; in blackbird_register_video()
1137 dev->mpeg_dev.device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING | in blackbird_register_video()
1139 if (dev->core->board.tuner_type != UNSET) in blackbird_register_video()
1140 dev->mpeg_dev.device_caps |= V4L2_CAP_TUNER; in blackbird_register_video()
1141 err = video_register_device(&dev->mpeg_dev, VFL_TYPE_VIDEO, -1); in blackbird_register_video()
1147 video_device_node_name(&dev->mpeg_dev)); in blackbird_register_video()
1151 /* ----------------------------------------------------------- */
1155 struct cx88_core *core = drv->core; in cx8802_blackbird_probe()
1156 struct cx8802_dev *dev = core->dvbdev; in cx8802_blackbird_probe()
1161 dprintk(1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n", in cx8802_blackbird_probe()
1162 core->boardnr, in cx8802_blackbird_probe()
1163 core->name, in cx8802_blackbird_probe()
1164 core->pci_bus, in cx8802_blackbird_probe()
1165 core->pci_slot); in cx8802_blackbird_probe()
1167 err = -ENODEV; in cx8802_blackbird_probe()
1168 if (!(core->board.mpeg & CX88_MPEG_BLACKBIRD)) in cx8802_blackbird_probe()
1171 dev->cxhdl.port = CX2341X_PORT_STREAMING; in cx8802_blackbird_probe()
1172 dev->cxhdl.width = core->width; in cx8802_blackbird_probe()
1173 dev->cxhdl.height = core->height; in cx8802_blackbird_probe()
1174 dev->cxhdl.func = blackbird_mbox_func; in cx8802_blackbird_probe()
1175 dev->cxhdl.priv = dev; in cx8802_blackbird_probe()
1176 err = cx2341x_handler_init(&dev->cxhdl, 36); in cx8802_blackbird_probe()
1179 v4l2_ctrl_add_handler(&dev->cxhdl.hdl, &core->video_hdl, NULL, false); in cx8802_blackbird_probe()
1183 host_setup(dev->core); in cx8802_blackbird_probe()
1189 cx88_set_tvnorm(core, core->tvnorm); in cx8802_blackbird_probe()
1191 cx2341x_handler_set_50hz(&dev->cxhdl, core->height == 576); in cx8802_blackbird_probe()
1192 cx2341x_handler_setup(&dev->cxhdl); in cx8802_blackbird_probe()
1194 q = &dev->vb2_mpegq; in cx8802_blackbird_probe()
1195 q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; in cx8802_blackbird_probe()
1196 q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF | VB2_READ; in cx8802_blackbird_probe()
1197 q->gfp_flags = GFP_DMA32; in cx8802_blackbird_probe()
1198 q->min_queued_buffers = 2; in cx8802_blackbird_probe()
1199 q->drv_priv = dev; in cx8802_blackbird_probe()
1200 q->buf_struct_size = sizeof(struct cx88_buffer); in cx8802_blackbird_probe()
1201 q->ops = &blackbird_qops; in cx8802_blackbird_probe()
1202 q->mem_ops = &vb2_dma_sg_memops; in cx8802_blackbird_probe()
1203 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; in cx8802_blackbird_probe()
1204 q->lock = &core->lock; in cx8802_blackbird_probe()
1205 q->dev = &dev->pci->dev; in cx8802_blackbird_probe()
1221 struct cx88_core *core = drv->core; in cx8802_blackbird_remove()
1222 struct cx8802_dev *dev = core->dvbdev; in cx8802_blackbird_remove()
1225 blackbird_unregister_video(drv->core->dvbdev); in cx8802_blackbird_remove()
1226 v4l2_ctrl_handler_free(&dev->cxhdl.hdl); in cx8802_blackbird_remove()