• Home
  • Raw
  • Download

Lines Matching refs:vc

49 static void tw686x_buf_done(struct tw686x_video_channel *vc,  in tw686x_buf_done()  argument
52 struct tw686x_dma_desc *desc = &vc->dma_descs[pb]; in tw686x_buf_done()
53 struct tw686x_dev *dev = vc->dev; in tw686x_buf_done()
57 if (vc->curr_bufs[pb]) { in tw686x_buf_done()
58 vb = &vc->curr_bufs[pb]->vb; in tw686x_buf_done()
61 vb->sequence = vc->sequence++; in tw686x_buf_done()
71 vc->pb = !pb; in tw686x_buf_done()
77 static void tw686x_memcpy_dma_free(struct tw686x_video_channel *vc, in tw686x_memcpy_dma_free() argument
80 struct tw686x_dma_desc *desc = &vc->dma_descs[pb]; in tw686x_memcpy_dma_free()
81 struct tw686x_dev *dev = vc->dev; in tw686x_memcpy_dma_free()
101 static int tw686x_memcpy_dma_alloc(struct tw686x_video_channel *vc, in tw686x_memcpy_dma_alloc() argument
104 struct tw686x_dev *dev = vc->dev; in tw686x_memcpy_dma_alloc()
105 u32 reg = pb ? VDMA_B_ADDR[vc->ch] : VDMA_P_ADDR[vc->ch]; in tw686x_memcpy_dma_alloc()
109 WARN(vc->dma_descs[pb].virt, in tw686x_memcpy_dma_alloc()
112 len = (vc->width * vc->height * vc->format->depth) >> 3; in tw686x_memcpy_dma_alloc()
114 &vc->dma_descs[pb].phys, GFP_KERNEL); in tw686x_memcpy_dma_alloc()
118 vc->ch, pb ? "B" : "P"); in tw686x_memcpy_dma_alloc()
121 vc->dma_descs[pb].size = len; in tw686x_memcpy_dma_alloc()
122 vc->dma_descs[pb].virt = virt; in tw686x_memcpy_dma_alloc()
123 reg_write(dev, reg, vc->dma_descs[pb].phys); in tw686x_memcpy_dma_alloc()
128 static void tw686x_memcpy_buf_refill(struct tw686x_video_channel *vc, in tw686x_memcpy_buf_refill() argument
133 while (!list_empty(&vc->vidq_queued)) { in tw686x_memcpy_buf_refill()
135 buf = list_first_entry(&vc->vidq_queued, in tw686x_memcpy_buf_refill()
139 vc->curr_bufs[pb] = buf; in tw686x_memcpy_buf_refill()
142 vc->curr_bufs[pb] = NULL; in tw686x_memcpy_buf_refill()
154 static void tw686x_contig_buf_refill(struct tw686x_video_channel *vc, in tw686x_contig_buf_refill() argument
159 while (!list_empty(&vc->vidq_queued)) { in tw686x_contig_buf_refill()
160 u32 reg = pb ? VDMA_B_ADDR[vc->ch] : VDMA_P_ADDR[vc->ch]; in tw686x_contig_buf_refill()
163 buf = list_first_entry(&vc->vidq_queued, in tw686x_contig_buf_refill()
168 reg_write(vc->dev, reg, phys); in tw686x_contig_buf_refill()
171 vc->curr_bufs[pb] = buf; in tw686x_contig_buf_refill()
174 vc->curr_bufs[pb] = NULL; in tw686x_contig_buf_refill()
224 static void tw686x_sg_buf_refill(struct tw686x_video_channel *vc, in tw686x_sg_buf_refill() argument
227 struct tw686x_dev *dev = vc->dev; in tw686x_sg_buf_refill()
230 while (!list_empty(&vc->vidq_queued)) { in tw686x_sg_buf_refill()
233 buf = list_first_entry(&vc->vidq_queued, in tw686x_sg_buf_refill()
237 buf_len = (vc->width * vc->height * vc->format->depth) >> 3; in tw686x_sg_buf_refill()
238 if (tw686x_sg_desc_fill(vc->sg_descs[pb], buf, buf_len)) { in tw686x_sg_buf_refill()
241 vc->ch, pb ? "B" : "P"); in tw686x_sg_buf_refill()
247 vc->curr_bufs[pb] = buf; in tw686x_sg_buf_refill()
251 vc->curr_bufs[pb] = NULL; in tw686x_sg_buf_refill()
254 static void tw686x_sg_dma_free(struct tw686x_video_channel *vc, in tw686x_sg_dma_free() argument
257 struct tw686x_dma_desc *desc = &vc->dma_descs[pb]; in tw686x_sg_dma_free()
258 struct tw686x_dev *dev = vc->dev; in tw686x_sg_dma_free()
266 vc->sg_descs[pb] = NULL; in tw686x_sg_dma_free()
269 static int tw686x_sg_dma_alloc(struct tw686x_video_channel *vc, in tw686x_sg_dma_alloc() argument
272 struct tw686x_dma_desc *desc = &vc->dma_descs[pb]; in tw686x_sg_dma_alloc()
273 struct tw686x_dev *dev = vc->dev; in tw686x_sg_dma_alloc()
274 u32 reg = pb ? DMA_PAGE_TABLE1_ADDR[vc->ch] : in tw686x_sg_dma_alloc()
275 DMA_PAGE_TABLE0_ADDR[vc->ch]; in tw686x_sg_dma_alloc()
284 vc->ch, pb ? "B" : "P"); in tw686x_sg_dma_alloc()
291 vc->ch * TW686X_SG_TABLE_SIZE; in tw686x_sg_dma_alloc()
294 vc->sg_descs[pb] = virt; in tw686x_sg_dma_alloc()
320 struct tw686x_video_channel *vc = &dev->video_channels[ch]; in tw686x_sg_setup() local
323 vc->dma_descs[pb].size = sg_table_size; in tw686x_sg_setup()
401 static void tw686x_set_framerate(struct tw686x_video_channel *vc, in tw686x_set_framerate() argument
406 i = tw686x_fps_idx(fps, TW686X_MAX_FPS(vc->video_standard)); in tw686x_set_framerate()
407 reg_write(vc->dev, VIDEO_FIELD_CTRL[vc->ch], fps_map[i]); in tw686x_set_framerate()
408 vc->fps = tw686x_real_fps(i, TW686X_MAX_FPS(vc->video_standard)); in tw686x_set_framerate()
425 struct tw686x_video_channel *vc = vb2_get_drv_priv(vq); in tw686x_queue_setup() local
427 (vc->width * vc->height * vc->format->depth) >> 3; in tw686x_queue_setup()
449 struct tw686x_video_channel *vc = vb2_get_drv_priv(vb->vb2_queue); in tw686x_buf_queue() local
450 struct tw686x_dev *dev = vc->dev; in tw686x_buf_queue()
466 spin_lock_irqsave(&vc->qlock, flags); in tw686x_buf_queue()
467 list_add_tail(&buf->list, &vc->vidq_queued); in tw686x_buf_queue()
468 spin_unlock_irqrestore(&vc->qlock, flags); in tw686x_buf_queue()
471 static void tw686x_clear_queue(struct tw686x_video_channel *vc, in tw686x_clear_queue() argument
476 while (!list_empty(&vc->vidq_queued)) { in tw686x_clear_queue()
479 buf = list_first_entry(&vc->vidq_queued, in tw686x_clear_queue()
486 if (vc->curr_bufs[pb]) in tw686x_clear_queue()
487 vb2_buffer_done(&vc->curr_bufs[pb]->vb.vb2_buf, state); in tw686x_clear_queue()
488 vc->curr_bufs[pb] = NULL; in tw686x_clear_queue()
494 struct tw686x_video_channel *vc = vb2_get_drv_priv(vq); in tw686x_start_streaming() local
495 struct tw686x_dev *dev = vc->dev; in tw686x_start_streaming()
509 spin_lock_irqsave(&vc->qlock, flags); in tw686x_start_streaming()
513 (!vc->dma_descs[0].virt || !vc->dma_descs[1].virt)) { in tw686x_start_streaming()
514 spin_unlock_irqrestore(&vc->qlock, flags); in tw686x_start_streaming()
517 vc->num); in tw686x_start_streaming()
523 dev->dma_ops->buf_refill(vc, pb); in tw686x_start_streaming()
524 spin_unlock_irqrestore(&vc->qlock, flags); in tw686x_start_streaming()
526 vc->sequence = 0; in tw686x_start_streaming()
527 vc->pb = 0; in tw686x_start_streaming()
530 tw686x_enable_channel(dev, vc->ch); in tw686x_start_streaming()
538 spin_lock_irqsave(&vc->qlock, flags); in tw686x_start_streaming()
539 tw686x_clear_queue(vc, VB2_BUF_STATE_QUEUED); in tw686x_start_streaming()
540 spin_unlock_irqrestore(&vc->qlock, flags); in tw686x_start_streaming()
546 struct tw686x_video_channel *vc = vb2_get_drv_priv(vq); in tw686x_stop_streaming() local
547 struct tw686x_dev *dev = vc->dev; in tw686x_stop_streaming()
556 tw686x_disable_channel(dev, vc->ch); in tw686x_stop_streaming()
558 spin_lock_irqsave(&vc->qlock, flags); in tw686x_stop_streaming()
559 tw686x_clear_queue(vc, VB2_BUF_STATE_ERROR); in tw686x_stop_streaming()
560 spin_unlock_irqrestore(&vc->qlock, flags); in tw686x_stop_streaming()
565 struct tw686x_video_channel *vc = vb2_get_drv_priv(vb->vb2_queue); in tw686x_buf_prepare() local
567 (vc->width * vc->height * vc->format->depth) >> 3; in tw686x_buf_prepare()
587 struct tw686x_video_channel *vc; in tw686x_s_ctrl() local
591 vc = container_of(ctrl->handler, struct tw686x_video_channel, in tw686x_s_ctrl()
593 dev = vc->dev; in tw686x_s_ctrl()
594 ch = vc->ch; in tw686x_s_ctrl()
625 struct tw686x_video_channel *vc = video_drvdata(file); in tw686x_g_fmt_vid_cap() local
626 struct tw686x_dev *dev = vc->dev; in tw686x_g_fmt_vid_cap()
628 f->fmt.pix.width = vc->width; in tw686x_g_fmt_vid_cap()
629 f->fmt.pix.height = vc->height; in tw686x_g_fmt_vid_cap()
631 f->fmt.pix.pixelformat = vc->format->fourcc; in tw686x_g_fmt_vid_cap()
633 f->fmt.pix.bytesperline = (f->fmt.pix.width * vc->format->depth) / 8; in tw686x_g_fmt_vid_cap()
641 struct tw686x_video_channel *vc = video_drvdata(file); in tw686x_try_fmt_vid_cap() local
642 struct tw686x_dev *dev = vc->dev; in tw686x_try_fmt_vid_cap()
643 unsigned int video_height = TW686X_VIDEO_HEIGHT(vc->video_standard); in tw686x_try_fmt_vid_cap()
670 static int tw686x_set_format(struct tw686x_video_channel *vc, in tw686x_set_format() argument
674 struct tw686x_dev *dev = vc->dev; in tw686x_set_format()
678 vc->format = format_by_fourcc(pixelformat); in tw686x_set_format()
679 vc->width = width; in tw686x_set_format()
680 vc->height = height; in tw686x_set_format()
685 dev->dma_ops->free(vc, pb); in tw686x_set_format()
688 err = dev->dma_ops->alloc(vc, pb); in tw686x_set_format()
691 dev->dma_ops->free(vc, 0); in tw686x_set_format()
697 val = reg_read(vc->dev, VDMA_CHANNEL_CONFIG[vc->ch]); in tw686x_set_format()
699 if (vc->width <= TW686X_VIDEO_WIDTH / 2) in tw686x_set_format()
704 if (vc->height <= TW686X_VIDEO_HEIGHT(vc->video_standard) / 2) in tw686x_set_format()
716 0 : vc->ch * TW686X_MAX_SG_DESC_COUNT; in tw686x_set_format()
723 val |= vc->format->mode << 20; in tw686x_set_format()
724 reg_write(vc->dev, VDMA_CHANNEL_CONFIG[vc->ch], val); in tw686x_set_format()
727 dma_width = (vc->width * 2) & 0x7ff; in tw686x_set_format()
728 dma_height = vc->height / 2; in tw686x_set_format()
729 dma_line_width = (vc->width * 2) & 0x7ff; in tw686x_set_format()
731 reg_write(vc->dev, VDMA_WHP[vc->ch], val); in tw686x_set_format()
738 struct tw686x_video_channel *vc = video_drvdata(file); in tw686x_s_fmt_vid_cap() local
743 if (vb2_is_busy(&vc->vidq)) in tw686x_s_fmt_vid_cap()
746 area = vc->width * vc->height; in tw686x_s_fmt_vid_cap()
752 return tw686x_set_format(vc, f->fmt.pix.pixelformat, in tw686x_s_fmt_vid_cap()
760 struct tw686x_video_channel *vc = video_drvdata(file); in tw686x_querycap() local
761 struct tw686x_dev *dev = vc->dev; in tw686x_querycap()
770 static int tw686x_set_standard(struct tw686x_video_channel *vc, v4l2_std_id id) in tw686x_set_standard() argument
791 vc->video_standard = id; in tw686x_set_standard()
792 reg_write(vc->dev, SDT[vc->ch], val); in tw686x_set_standard()
794 val = reg_read(vc->dev, VIDEO_CONTROL1); in tw686x_set_standard()
796 val &= ~(1 << (SYS_MODE_DMA_SHIFT + vc->ch)); in tw686x_set_standard()
798 val |= (1 << (SYS_MODE_DMA_SHIFT + vc->ch)); in tw686x_set_standard()
799 reg_write(vc->dev, VIDEO_CONTROL1, val); in tw686x_set_standard()
806 struct tw686x_video_channel *vc = video_drvdata(file); in tw686x_s_std() local
810 if (vc->video_standard == id) in tw686x_s_std()
813 if (vb2_is_busy(&vc->vidq)) in tw686x_s_std()
816 ret = tw686x_set_standard(vc, id); in tw686x_s_std()
831 tw686x_set_framerate(vc, vc->fps); in tw686x_s_std()
837 struct tw686x_video_channel *vc = video_drvdata(file); in tw686x_querystd() local
838 struct tw686x_dev *dev = vc->dev; in tw686x_querystd()
842 if (vb2_is_streaming(&vc->vidq)) in tw686x_querystd()
846 old_std = reg_read(dev, SDT[vc->ch]); in tw686x_querystd()
847 reg_write(dev, SDT[vc->ch], 0x7); in tw686x_querystd()
848 reg_write(dev, SDT_EN[vc->ch], 0xff); in tw686x_querystd()
853 detected_std = reg_read(dev, SDT[vc->ch]); in tw686x_querystd()
858 reg_write(dev, SDT[vc->ch], old_std); in tw686x_querystd()
895 struct tw686x_video_channel *vc = video_drvdata(file); in tw686x_g_std() local
897 *id = vc->video_standard; in tw686x_g_std()
904 struct tw686x_video_channel *vc = video_drvdata(file); in tw686x_enum_framesizes() local
912 fsize->stepwise.max_height = TW686X_VIDEO_HEIGHT(vc->video_standard); in tw686x_enum_framesizes()
921 struct tw686x_video_channel *vc = video_drvdata(file); in tw686x_enum_frameintervals() local
922 int max_fps = TW686X_MAX_FPS(vc->video_standard); in tw686x_enum_frameintervals()
940 struct tw686x_video_channel *vc = video_drvdata(file); in tw686x_g_parm() local
949 cp->timeperframe.denominator = vc->fps; in tw686x_g_parm()
956 struct tw686x_video_channel *vc = video_drvdata(file); in tw686x_s_parm() local
962 if (vb2_is_busy(&vc->vidq)) in tw686x_s_parm()
966 if (vc->fps != fps) in tw686x_s_parm()
967 tw686x_set_framerate(vc, fps); in tw686x_s_parm()
980 static void tw686x_set_input(struct tw686x_video_channel *vc, unsigned int i) in tw686x_set_input() argument
984 vc->input = i; in tw686x_set_input()
986 val = reg_read(vc->dev, VDMA_CHANNEL_CONFIG[vc->ch]); in tw686x_set_input()
989 reg_write(vc->dev, VDMA_CHANNEL_CONFIG[vc->ch], val); in tw686x_set_input()
994 struct tw686x_video_channel *vc = video_drvdata(file); in tw686x_s_input() local
998 if (i == vc->input) in tw686x_s_input()
1003 if (vb2_is_busy(&vc->vidq)) in tw686x_s_input()
1006 tw686x_set_input(vc, i); in tw686x_s_input()
1012 struct tw686x_video_channel *vc = video_drvdata(file); in tw686x_g_input() local
1014 *i = vc->input; in tw686x_g_input()
1021 struct tw686x_video_channel *vc = video_drvdata(file); in tw686x_enum_input() local
1029 i->std = vc->device->tvnorms; in tw686x_enum_input()
1032 vidstat = reg_read(vc->dev, VIDSTAT[vc->ch]); in tw686x_enum_input()
1090 struct tw686x_video_channel *vc; in tw686x_video_irq() local
1095 vc = &dev->video_channels[ch]; in tw686x_video_irq()
1102 if (vc->no_signal && !(fifo_status & BIT(ch))) { in tw686x_video_irq()
1104 "video%d: signal recovered\n", vc->num); in tw686x_video_irq()
1105 vc->no_signal = false; in tw686x_video_irq()
1107 vc->pb = 0; in tw686x_video_irq()
1110 vc->no_signal = !!(fifo_status & BIT(ch)); in tw686x_video_irq()
1113 if (!vc->no_signal) { in tw686x_video_irq()
1121 "video%d: FIFO error\n", vc->num); in tw686x_video_irq()
1123 vc->pb = 0; in tw686x_video_irq()
1129 if (vc->pb != pb) { in tw686x_video_irq()
1133 vc->num); in tw686x_video_irq()
1135 vc->pb = 0; in tw686x_video_irq()
1139 spin_lock_irqsave(&vc->qlock, flags); in tw686x_video_irq()
1140 tw686x_buf_done(vc, pb); in tw686x_video_irq()
1141 dev->dma_ops->buf_refill(vc, pb); in tw686x_video_irq()
1142 spin_unlock_irqrestore(&vc->qlock, flags); in tw686x_video_irq()
1151 struct tw686x_video_channel *vc = &dev->video_channels[ch]; in tw686x_video_free() local
1153 video_unregister_device(vc->device); in tw686x_video_free()
1157 dev->dma_ops->free(vc, pb); in tw686x_video_free()
1187 struct tw686x_video_channel *vc = &dev->video_channels[ch]; in tw686x_video_init() local
1189 vc->dev = dev; in tw686x_video_init()
1190 vc->ch = ch; in tw686x_video_init()
1194 struct tw686x_video_channel *vc = &dev->video_channels[ch]; in tw686x_video_init() local
1197 mutex_init(&vc->vb_mutex); in tw686x_video_init()
1198 spin_lock_init(&vc->qlock); in tw686x_video_init()
1199 INIT_LIST_HEAD(&vc->vidq_queued); in tw686x_video_init()
1202 err = tw686x_set_standard(vc, V4L2_STD_NTSC); in tw686x_video_init()
1206 err = tw686x_set_format(vc, formats[0].fourcc, in tw686x_video_init()
1208 TW686X_VIDEO_HEIGHT(vc->video_standard), in tw686x_video_init()
1213 tw686x_set_input(vc, 0); in tw686x_video_init()
1214 tw686x_set_framerate(vc, 30); in tw686x_video_init()
1219 vc->vidq.io_modes = VB2_READ | VB2_MMAP | VB2_DMABUF; in tw686x_video_init()
1220 vc->vidq.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; in tw686x_video_init()
1221 vc->vidq.drv_priv = vc; in tw686x_video_init()
1222 vc->vidq.buf_struct_size = sizeof(struct tw686x_v4l2_buf); in tw686x_video_init()
1223 vc->vidq.ops = &tw686x_video_qops; in tw686x_video_init()
1224 vc->vidq.mem_ops = dev->dma_ops->mem_ops; in tw686x_video_init()
1225 vc->vidq.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; in tw686x_video_init()
1226 vc->vidq.min_buffers_needed = 2; in tw686x_video_init()
1227 vc->vidq.lock = &vc->vb_mutex; in tw686x_video_init()
1228 vc->vidq.gfp_flags = dev->dma_mode != TW686X_DMA_MODE_MEMCPY ? in tw686x_video_init()
1230 vc->vidq.dev = &dev->pci_dev->dev; in tw686x_video_init()
1232 err = vb2_queue_init(&vc->vidq); in tw686x_video_init()
1239 err = v4l2_ctrl_handler_init(&vc->ctrl_handler, 4); in tw686x_video_init()
1245 v4l2_ctrl_new_std(&vc->ctrl_handler, &ctrl_ops, in tw686x_video_init()
1247 v4l2_ctrl_new_std(&vc->ctrl_handler, &ctrl_ops, in tw686x_video_init()
1249 v4l2_ctrl_new_std(&vc->ctrl_handler, &ctrl_ops, in tw686x_video_init()
1251 v4l2_ctrl_new_std(&vc->ctrl_handler, &ctrl_ops, in tw686x_video_init()
1253 err = vc->ctrl_handler.error; in tw686x_video_init()
1257 err = v4l2_ctrl_handler_setup(&vc->ctrl_handler); in tw686x_video_init()
1274 vdev->queue = &vc->vidq; in tw686x_video_init()
1277 vdev->lock = &vc->vb_mutex; in tw686x_video_init()
1278 vdev->ctrl_handler = &vc->ctrl_handler; in tw686x_video_init()
1281 vc->device = vdev; in tw686x_video_init()
1282 video_set_drvdata(vdev, vc); in tw686x_video_init()
1289 vc->num = vdev->num; in tw686x_video_init()