Lines Matching refs:voutdev
64 static void get_timings(struct mgb4_vout_dev *voutdev, in get_timings() argument
67 struct mgb4_regs *video = &voutdev->mgbdev->video; in get_timings()
68 const struct mgb4_vout_regs *regs = &voutdev->config->regs; in get_timings()
82 timings->bt.pixelclock = voutdev->freq * 1000; in get_timings()
91 static void return_all_buffers(struct mgb4_vout_dev *voutdev, in return_all_buffers() argument
97 spin_lock_irqsave(&voutdev->qlock, flags); in return_all_buffers()
98 list_for_each_entry_safe(buf, node, &voutdev->buf_list, list) { in return_all_buffers()
102 spin_unlock_irqrestore(&voutdev->qlock, flags); in return_all_buffers()
109 struct mgb4_vout_dev *voutdev = vb2_get_drv_priv(q); in queue_setup() local
110 struct mgb4_regs *video = &voutdev->mgbdev->video; in queue_setup()
111 u32 config = mgb4_read_reg(video, voutdev->config->regs.config); in queue_setup()
113 unsigned int size = (voutdev->width + voutdev->padding) * voutdev->height in queue_setup()
121 if (test_bit(0, &voutdev->mgbdev->io_reconfig)) in queue_setup()
144 struct mgb4_vout_dev *voutdev = vb2_get_drv_priv(vb->vb2_queue); in buffer_prepare() local
145 struct device *dev = &voutdev->mgbdev->pdev->dev; in buffer_prepare()
146 struct mgb4_regs *video = &voutdev->mgbdev->video; in buffer_prepare()
147 u32 config = mgb4_read_reg(video, voutdev->config->regs.config); in buffer_prepare()
149 unsigned int size = (voutdev->width + voutdev->padding) * voutdev->height in buffer_prepare()
177 struct mgb4_vout_dev *voutdev = vb2_get_drv_priv(vq); in stop_streaming() local
178 struct mgb4_dev *mgbdev = voutdev->mgbdev; in stop_streaming()
179 int irq = xdma_get_user_irq(mgbdev->xdev, voutdev->config->irq); in stop_streaming()
182 cancel_work_sync(&voutdev->dma_work); in stop_streaming()
183 mgb4_mask_reg(&mgbdev->video, voutdev->config->regs.config, 0x2, 0x0); in stop_streaming()
184 return_all_buffers(voutdev, VB2_BUF_STATE_ERROR); in stop_streaming()
189 struct mgb4_vout_dev *voutdev = vb2_get_drv_priv(vq); in start_streaming() local
190 struct mgb4_dev *mgbdev = voutdev->mgbdev; in start_streaming()
194 const struct mgb4_vout_config *config = voutdev->config; in start_streaming()
204 return_all_buffers(voutdev, VB2_BUF_STATE_QUEUED); in start_streaming()
208 buf = list_first_entry(&voutdev->buf_list, struct mgb4_frame_buffer, in start_streaming()
210 list_del_init(voutdev->buf_list.next); in start_streaming()
249 struct mgb4_vin_dev *voutdev = video_drvdata(file); in vidioc_enum_fmt() local
250 struct mgb4_regs *video = &voutdev->mgbdev->video; in vidioc_enum_fmt()
265 struct mgb4_vout_dev *voutdev = video_drvdata(file); in vidioc_g_fmt() local
266 struct mgb4_regs *video = &voutdev->mgbdev->video; in vidioc_g_fmt()
267 u32 config = mgb4_read_reg(video, voutdev->config->regs.config); in vidioc_g_fmt()
269 f->fmt.pix.width = voutdev->width; in vidioc_g_fmt()
270 f->fmt.pix.height = voutdev->height; in vidioc_g_fmt()
283 f->fmt.pix.bytesperline = (f->fmt.pix.width + voutdev->padding) * 2; in vidioc_g_fmt()
287 f->fmt.pix.bytesperline = (f->fmt.pix.width + voutdev->padding) * 4; in vidioc_g_fmt()
297 struct mgb4_vout_dev *voutdev = video_drvdata(file); in vidioc_try_fmt() local
298 struct mgb4_regs *video = &voutdev->mgbdev->video; in vidioc_try_fmt()
301 f->fmt.pix.width = voutdev->width; in vidioc_try_fmt()
302 f->fmt.pix.height = voutdev->height; in vidioc_try_fmt()
329 struct mgb4_vout_dev *voutdev = video_drvdata(file); in vidioc_s_fmt() local
330 struct mgb4_regs *video = &voutdev->mgbdev->video; in vidioc_s_fmt()
334 if (vb2_is_busy(&voutdev->queue)) in vidioc_s_fmt()
341 config = mgb4_read_reg(video, voutdev->config->regs.config); in vidioc_s_fmt()
360 mgb4_write_reg(video, voutdev->config->regs.config, config); in vidioc_s_fmt()
362 voutdev->padding = (f->fmt.pix.bytesperline - (f->fmt.pix.width in vidioc_s_fmt()
364 mgb4_write_reg(video, voutdev->config->regs.padding, voutdev->padding); in vidioc_s_fmt()
396 struct mgb4_vout_dev *voutdev = video_drvdata(file); in vidioc_enum_frameintervals() local
397 struct mgb4_regs *video = &voutdev->mgbdev->video; in vidioc_enum_frameintervals()
405 if (ival->width != voutdev->width || ival->height != voutdev->height) in vidioc_enum_frameintervals()
408 get_timings(voutdev, &timings); in vidioc_enum_frameintervals()
424 struct mgb4_vout_dev *voutdev = video_drvdata(file); in vidioc_g_parm() local
425 struct mgb4_regs *video = &voutdev->mgbdev->video; in vidioc_g_parm()
433 timer = mgb4_read_reg(video, voutdev->config->regs.timer); in vidioc_g_parm()
435 get_timings(voutdev, &timings); in vidioc_g_parm()
452 struct mgb4_vout_dev *voutdev = video_drvdata(file); in vidioc_s_parm() local
453 struct mgb4_regs *video = &voutdev->mgbdev->video; in vidioc_s_parm()
462 get_timings(voutdev, &timings); in vidioc_s_parm()
469 mgb4_write_reg(video, voutdev->config->regs.timer, timer); in vidioc_s_parm()
478 struct mgb4_vout_dev *voutdev = video_drvdata(file); in vidioc_g_dv_timings() local
480 get_timings(voutdev, timings); in vidioc_g_dv_timings()
488 struct mgb4_vout_dev *voutdev = video_drvdata(file); in vidioc_s_dv_timings() local
490 get_timings(voutdev, timings); in vidioc_s_dv_timings()
538 struct mgb4_vout_dev *voutdev = video_drvdata(file); in fh_open() local
539 struct mgb4_regs *video = &voutdev->mgbdev->video; in fh_open()
540 struct device *dev = &voutdev->mgbdev->pdev->dev; in fh_open()
545 config = mgb4_read_reg(video, voutdev->config->regs.config); in fh_open()
546 if ((config & 0xc) >> 2 != voutdev->config->id + MGB4_VIN_DEVICES) { in fh_open()
551 mutex_lock(&voutdev->lock); in fh_open()
560 resolution = mgb4_read_reg(video, voutdev->config->regs.resolution); in fh_open()
561 voutdev->width = resolution >> 16; in fh_open()
562 voutdev->height = resolution & 0xFFFF; in fh_open()
565 mutex_unlock(&voutdev->lock); in fh_open()
581 struct mgb4_vout_dev *voutdev = container_of(work, struct mgb4_vout_dev, in dma_transfer() local
583 struct device *dev = &voutdev->mgbdev->pdev->dev; in dma_transfer()
584 struct mgb4_regs *video = &voutdev->mgbdev->video; in dma_transfer()
590 spin_lock_irqsave(&voutdev->qlock, flags); in dma_transfer()
591 if (!list_empty(&voutdev->buf_list)) { in dma_transfer()
592 buf = list_first_entry(&voutdev->buf_list, in dma_transfer()
594 list_del_init(voutdev->buf_list.next); in dma_transfer()
596 spin_unlock_irqrestore(&voutdev->qlock, flags); in dma_transfer()
601 addr = mgb4_read_reg(video, voutdev->config->regs.address); in dma_transfer()
608 rv = mgb4_dma_transfer(voutdev->mgbdev, voutdev->config->dma_channel, in dma_transfer()
621 struct mgb4_vout_dev *voutdev = (struct mgb4_vout_dev *)ctx; in handler() local
622 struct mgb4_regs *video = &voutdev->mgbdev->video; in handler()
624 schedule_work(&voutdev->dma_work); in handler()
626 mgb4_write_reg(video, 0xB4, 1U << voutdev->config->irq); in handler()
631 static int ser_init(struct mgb4_vout_dev *voutdev, int id) in ser_init() argument
635 struct mgb4_i2c_client *ser = &voutdev->ser; in ser_init()
636 struct device *dev = &voutdev->mgbdev->pdev->dev; in ser_init()
638 if (MGB4_IS_GMSL(voutdev->mgbdev)) in ser_init()
641 rv = mgb4_i2c_init(ser, voutdev->mgbdev->i2c_adap, info, 8); in ser_init()
660 static void fpga_init(struct mgb4_vout_dev *voutdev) in fpga_init() argument
662 struct mgb4_regs *video = &voutdev->mgbdev->video; in fpga_init()
663 const struct mgb4_vout_regs *regs = &voutdev->config->regs; in fpga_init()
673 voutdev->freq = mgb4_cmt_set_vout_freq(voutdev, 61150 >> 1) << 1; in fpga_init()
676 (voutdev->config->id + MGB4_VIN_DEVICES) << 2 | 1 << 4); in fpga_init()
680 static void debugfs_init(struct mgb4_vout_dev *voutdev) in debugfs_init() argument
682 struct mgb4_regs *video = &voutdev->mgbdev->video; in debugfs_init()
684 voutdev->debugfs = debugfs_create_dir(voutdev->vdev.name, in debugfs_init()
685 voutdev->mgbdev->debugfs); in debugfs_init()
686 if (!voutdev->debugfs) in debugfs_init()
689 voutdev->regs[0].name = "CONFIG"; in debugfs_init()
690 voutdev->regs[0].offset = voutdev->config->regs.config; in debugfs_init()
691 voutdev->regs[1].name = "STATUS"; in debugfs_init()
692 voutdev->regs[1].offset = voutdev->config->regs.status; in debugfs_init()
693 voutdev->regs[2].name = "RESOLUTION"; in debugfs_init()
694 voutdev->regs[2].offset = voutdev->config->regs.resolution; in debugfs_init()
695 voutdev->regs[3].name = "VIDEO_PARAMS_1"; in debugfs_init()
696 voutdev->regs[3].offset = voutdev->config->regs.hsync; in debugfs_init()
697 voutdev->regs[4].name = "VIDEO_PARAMS_2"; in debugfs_init()
698 voutdev->regs[4].offset = voutdev->config->regs.vsync; in debugfs_init()
699 voutdev->regs[5].name = "FRAME_LIMIT"; in debugfs_init()
700 voutdev->regs[5].offset = voutdev->config->regs.frame_limit; in debugfs_init()
701 voutdev->regs[6].name = "PADDING_PIXELS"; in debugfs_init()
702 voutdev->regs[6].offset = voutdev->config->regs.padding; in debugfs_init()
704 voutdev->regs[7].name = "TIMER"; in debugfs_init()
705 voutdev->regs[7].offset = voutdev->config->regs.timer; in debugfs_init()
706 voutdev->regset.nregs = 8; in debugfs_init()
708 voutdev->regset.nregs = 7; in debugfs_init()
711 voutdev->regset.base = video->membase; in debugfs_init()
712 voutdev->regset.regs = voutdev->regs; in debugfs_init()
714 debugfs_create_regset32("registers", 0444, voutdev->debugfs, in debugfs_init()
715 &voutdev->regset); in debugfs_init()
723 struct mgb4_vout_dev *voutdev; in mgb4_vout_create() local
727 voutdev = kzalloc(sizeof(*voutdev), GFP_KERNEL); in mgb4_vout_create()
728 if (!voutdev) in mgb4_vout_create()
731 voutdev->mgbdev = mgbdev; in mgb4_vout_create()
732 voutdev->config = &vout_cfg[id]; in mgb4_vout_create()
735 INIT_LIST_HEAD(&voutdev->buf_list); in mgb4_vout_create()
736 spin_lock_init(&voutdev->qlock); in mgb4_vout_create()
739 INIT_WORK(&voutdev->dma_work, dma_transfer); in mgb4_vout_create()
742 irq = xdma_get_user_irq(mgbdev->xdev, voutdev->config->irq); in mgb4_vout_create()
743 rv = request_irq(irq, handler, 0, "mgb4-vout", voutdev); in mgb4_vout_create()
750 fpga_init(voutdev); in mgb4_vout_create()
753 rv = ser_init(voutdev, id); in mgb4_vout_create()
758 rv = v4l2_device_register(dev, &voutdev->v4l2dev); in mgb4_vout_create()
764 mutex_init(&voutdev->lock); in mgb4_vout_create()
766 voutdev->queue.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; in mgb4_vout_create()
767 voutdev->queue.io_modes = VB2_MMAP | VB2_DMABUF | VB2_WRITE; in mgb4_vout_create()
768 voutdev->queue.buf_struct_size = sizeof(struct mgb4_frame_buffer); in mgb4_vout_create()
769 voutdev->queue.ops = &queue_ops; in mgb4_vout_create()
770 voutdev->queue.mem_ops = &vb2_dma_sg_memops; in mgb4_vout_create()
771 voutdev->queue.gfp_flags = GFP_DMA32; in mgb4_vout_create()
772 voutdev->queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; in mgb4_vout_create()
773 voutdev->queue.min_queued_buffers = 2; in mgb4_vout_create()
774 voutdev->queue.drv_priv = voutdev; in mgb4_vout_create()
775 voutdev->queue.lock = &voutdev->lock; in mgb4_vout_create()
776 voutdev->queue.dev = dev; in mgb4_vout_create()
777 rv = vb2_queue_init(&voutdev->queue); in mgb4_vout_create()
783 snprintf(voutdev->vdev.name, sizeof(voutdev->vdev.name), "mgb4-out%d", in mgb4_vout_create()
785 voutdev->vdev.device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_READWRITE in mgb4_vout_create()
787 voutdev->vdev.vfl_dir = VFL_DIR_TX; in mgb4_vout_create()
788 voutdev->vdev.fops = &video_fops; in mgb4_vout_create()
789 voutdev->vdev.ioctl_ops = &video_ioctl_ops; in mgb4_vout_create()
790 voutdev->vdev.release = video_device_release_empty; in mgb4_vout_create()
791 voutdev->vdev.v4l2_dev = &voutdev->v4l2dev; in mgb4_vout_create()
792 voutdev->vdev.lock = &voutdev->lock; in mgb4_vout_create()
793 voutdev->vdev.queue = &voutdev->queue; in mgb4_vout_create()
794 video_set_drvdata(&voutdev->vdev, voutdev); in mgb4_vout_create()
796 rv = video_register_device(&voutdev->vdev, VFL_TYPE_VIDEO, -1); in mgb4_vout_create()
805 rv = device_add_groups(&voutdev->vdev.dev, groups); in mgb4_vout_create()
812 debugfs_init(voutdev); in mgb4_vout_create()
815 return voutdev; in mgb4_vout_create()
818 video_unregister_device(&voutdev->vdev); in mgb4_vout_create()
820 v4l2_device_unregister(&voutdev->v4l2dev); in mgb4_vout_create()
822 free_irq(irq, voutdev); in mgb4_vout_create()
824 kfree(voutdev); in mgb4_vout_create()
829 void mgb4_vout_free(struct mgb4_vout_dev *voutdev) in mgb4_vout_free() argument
832 int irq = xdma_get_user_irq(voutdev->mgbdev->xdev, voutdev->config->irq); in mgb4_vout_free()
834 free_irq(irq, voutdev); in mgb4_vout_free()
837 debugfs_remove_recursive(voutdev->debugfs); in mgb4_vout_free()
840 groups = MGB4_IS_GMSL(voutdev->mgbdev) in mgb4_vout_free()
842 device_remove_groups(&voutdev->vdev.dev, groups); in mgb4_vout_free()
844 mgb4_i2c_free(&voutdev->ser); in mgb4_vout_free()
845 video_unregister_device(&voutdev->vdev); in mgb4_vout_free()
846 v4l2_device_unregister(&voutdev->v4l2dev); in mgb4_vout_free()
848 kfree(voutdev); in mgb4_vout_free()