Lines Matching refs:video

76 sun6i_video_remote_subdev(struct sun6i_video *video, u32 *pad)  in sun6i_video_remote_subdev()  argument
80 remote = media_entity_remote_pad(&video->pad); in sun6i_video_remote_subdev()
97 struct sun6i_video *video = vb2_get_drv_priv(vq); in sun6i_video_queue_setup() local
98 unsigned int size = video->fmt.fmt.pix.sizeimage; in sun6i_video_queue_setup()
114 struct sun6i_video *video = vb2_get_drv_priv(vb->vb2_queue); in sun6i_video_buffer_prepare() local
115 unsigned long size = video->fmt.fmt.pix.sizeimage; in sun6i_video_buffer_prepare()
118 v4l2_err(video->vdev.v4l2_dev, "buffer too small (%lu < %lu)\n", in sun6i_video_buffer_prepare()
127 vbuf->field = video->fmt.fmt.pix.field; in sun6i_video_buffer_prepare()
134 struct sun6i_video *video = vb2_get_drv_priv(vq); in sun6i_video_start_streaming() local
142 video->sequence = 0; in sun6i_video_start_streaming()
144 ret = media_pipeline_start(&video->vdev.entity, &video->vdev.pipe); in sun6i_video_start_streaming()
148 if (video->mbus_code == 0) { in sun6i_video_start_streaming()
153 subdev = sun6i_video_remote_subdev(video, NULL); in sun6i_video_start_streaming()
159 config.pixelformat = video->fmt.fmt.pix.pixelformat; in sun6i_video_start_streaming()
160 config.code = video->mbus_code; in sun6i_video_start_streaming()
161 config.field = video->fmt.fmt.pix.field; in sun6i_video_start_streaming()
162 config.width = video->fmt.fmt.pix.width; in sun6i_video_start_streaming()
163 config.height = video->fmt.fmt.pix.height; in sun6i_video_start_streaming()
165 ret = sun6i_csi_update_config(video->csi, &config); in sun6i_video_start_streaming()
169 spin_lock_irqsave(&video->dma_queue_lock, flags); in sun6i_video_start_streaming()
171 buf = list_first_entry(&video->dma_queue, in sun6i_video_start_streaming()
174 sun6i_csi_update_buf_addr(video->csi, buf->dma_addr); in sun6i_video_start_streaming()
176 sun6i_csi_set_stream(video->csi, true); in sun6i_video_start_streaming()
197 sun6i_csi_update_buf_addr(video->csi, next_buf->dma_addr); in sun6i_video_start_streaming()
199 spin_unlock_irqrestore(&video->dma_queue_lock, flags); in sun6i_video_start_streaming()
201 ret = v4l2_subdev_call(subdev, video, s_stream, 1); in sun6i_video_start_streaming()
208 sun6i_csi_set_stream(video->csi, false); in sun6i_video_start_streaming()
210 media_pipeline_stop(&video->vdev.entity); in sun6i_video_start_streaming()
212 spin_lock_irqsave(&video->dma_queue_lock, flags); in sun6i_video_start_streaming()
213 list_for_each_entry(buf, &video->dma_queue, list) in sun6i_video_start_streaming()
215 INIT_LIST_HEAD(&video->dma_queue); in sun6i_video_start_streaming()
216 spin_unlock_irqrestore(&video->dma_queue_lock, flags); in sun6i_video_start_streaming()
223 struct sun6i_video *video = vb2_get_drv_priv(vq); in sun6i_video_stop_streaming() local
228 subdev = sun6i_video_remote_subdev(video, NULL); in sun6i_video_stop_streaming()
230 v4l2_subdev_call(subdev, video, s_stream, 0); in sun6i_video_stop_streaming()
232 sun6i_csi_set_stream(video->csi, false); in sun6i_video_stop_streaming()
234 media_pipeline_stop(&video->vdev.entity); in sun6i_video_stop_streaming()
237 spin_lock_irqsave(&video->dma_queue_lock, flags); in sun6i_video_stop_streaming()
238 list_for_each_entry(buf, &video->dma_queue, list) in sun6i_video_stop_streaming()
240 INIT_LIST_HEAD(&video->dma_queue); in sun6i_video_stop_streaming()
241 spin_unlock_irqrestore(&video->dma_queue_lock, flags); in sun6i_video_stop_streaming()
249 struct sun6i_video *video = vb2_get_drv_priv(vb->vb2_queue); in sun6i_video_buffer_queue() local
252 spin_lock_irqsave(&video->dma_queue_lock, flags); in sun6i_video_buffer_queue()
254 list_add_tail(&buf->list, &video->dma_queue); in sun6i_video_buffer_queue()
255 spin_unlock_irqrestore(&video->dma_queue_lock, flags); in sun6i_video_buffer_queue()
258 void sun6i_video_frame_done(struct sun6i_video *video) in sun6i_video_frame_done() argument
264 spin_lock(&video->dma_queue_lock); in sun6i_video_frame_done()
266 buf = list_first_entry(&video->dma_queue, in sun6i_video_frame_done()
268 if (list_is_last(&buf->list, &video->dma_queue)) { in sun6i_video_frame_done()
269 dev_dbg(video->csi->dev, "Frame dropped!\n"); in sun6i_video_frame_done()
281 sun6i_csi_update_buf_addr(video->csi, next_buf->dma_addr); in sun6i_video_frame_done()
282 dev_dbg(video->csi->dev, "Frame dropped!\n"); in sun6i_video_frame_done()
289 vbuf->sequence = video->sequence; in sun6i_video_frame_done()
293 if (!list_is_last(&next_buf->list, &video->dma_queue)) { in sun6i_video_frame_done()
296 sun6i_csi_update_buf_addr(video->csi, next_buf->dma_addr); in sun6i_video_frame_done()
298 dev_dbg(video->csi->dev, "Next frame will be dropped!\n"); in sun6i_video_frame_done()
302 video->sequence++; in sun6i_video_frame_done()
303 spin_unlock(&video->dma_queue_lock); in sun6i_video_frame_done()
319 struct sun6i_video *video = video_drvdata(file); in vidioc_querycap() local
322 strscpy(cap->card, video->vdev.name, sizeof(cap->card)); in vidioc_querycap()
324 video->csi->dev->of_node->name); in vidioc_querycap()
345 struct sun6i_video *video = video_drvdata(file); in vidioc_g_fmt_vid_cap() local
347 *fmt = video->fmt; in vidioc_g_fmt_vid_cap()
352 static int sun6i_video_try_fmt(struct sun6i_video *video, in sun6i_video_try_fmt() argument
379 static int sun6i_video_set_fmt(struct sun6i_video *video, struct v4l2_format *f) in sun6i_video_set_fmt() argument
383 ret = sun6i_video_try_fmt(video, f); in sun6i_video_set_fmt()
387 video->fmt = *f; in sun6i_video_set_fmt()
395 struct sun6i_video *video = video_drvdata(file); in vidioc_s_fmt_vid_cap() local
397 if (vb2_is_busy(&video->vb2_vidq)) in vidioc_s_fmt_vid_cap()
400 return sun6i_video_set_fmt(video, f); in vidioc_s_fmt_vid_cap()
406 struct sun6i_video *video = video_drvdata(file); in vidioc_try_fmt_vid_cap() local
408 return sun6i_video_try_fmt(video, f); in vidioc_try_fmt_vid_cap()
469 struct sun6i_video *video = video_drvdata(file); in sun6i_video_open() local
472 if (mutex_lock_interruptible(&video->lock)) in sun6i_video_open()
479 ret = v4l2_pipeline_pm_get(&video->vdev.entity); in sun6i_video_open()
487 ret = sun6i_csi_set_power(video->csi, true); in sun6i_video_open()
491 mutex_unlock(&video->lock); in sun6i_video_open()
497 mutex_unlock(&video->lock); in sun6i_video_open()
503 struct sun6i_video *video = video_drvdata(file); in sun6i_video_close() local
506 mutex_lock(&video->lock); in sun6i_video_close()
512 v4l2_pipeline_pm_put(&video->vdev.entity); in sun6i_video_close()
515 sun6i_csi_set_power(video->csi, false); in sun6i_video_close()
517 mutex_unlock(&video->lock); in sun6i_video_close()
553 struct sun6i_video *video = video_get_drvdata(vdev); in sun6i_video_link_validate() local
557 video->mbus_code = 0; in sun6i_video_link_validate()
560 dev_info(video->csi->dev, in sun6i_video_link_validate()
569 if (!sun6i_csi_is_format_supported(video->csi, in sun6i_video_link_validate()
570 video->fmt.fmt.pix.pixelformat, in sun6i_video_link_validate()
572 dev_err(video->csi->dev, in sun6i_video_link_validate()
574 video->fmt.fmt.pix.pixelformat, in sun6i_video_link_validate()
579 if (source_fmt.format.width != video->fmt.fmt.pix.width || in sun6i_video_link_validate()
580 source_fmt.format.height != video->fmt.fmt.pix.height) { in sun6i_video_link_validate()
581 dev_err(video->csi->dev, in sun6i_video_link_validate()
583 video->fmt.fmt.pix.width, video->fmt.fmt.pix.height, in sun6i_video_link_validate()
588 video->mbus_code = source_fmt.format.code; in sun6i_video_link_validate()
597 int sun6i_video_init(struct sun6i_video *video, struct sun6i_csi *csi, in sun6i_video_init() argument
600 struct video_device *vdev = &video->vdev; in sun6i_video_init()
601 struct vb2_queue *vidq = &video->vb2_vidq; in sun6i_video_init()
605 video->csi = csi; in sun6i_video_init()
608 video->pad.flags = MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_MUST_CONNECT; in sun6i_video_init()
610 ret = media_entity_pads_init(&vdev->entity, 1, &video->pad); in sun6i_video_init()
614 mutex_init(&video->lock); in sun6i_video_init()
616 INIT_LIST_HEAD(&video->dma_queue); in sun6i_video_init()
617 spin_lock_init(&video->dma_queue_lock); in sun6i_video_init()
619 video->sequence = 0; in sun6i_video_init()
627 sun6i_video_set_fmt(video, &fmt); in sun6i_video_init()
632 vidq->drv_priv = video; in sun6i_video_init()
637 vidq->lock = &video->lock; in sun6i_video_init()
657 vdev->lock = &video->lock; in sun6i_video_init()
659 video_set_drvdata(vdev, video); in sun6i_video_init()
671 media_entity_cleanup(&video->vdev.entity); in sun6i_video_init()
672 mutex_destroy(&video->lock); in sun6i_video_init()
676 void sun6i_video_cleanup(struct sun6i_video *video) in sun6i_video_cleanup() argument
678 vb2_video_unregister_device(&video->vdev); in sun6i_video_cleanup()
679 media_entity_cleanup(&video->vdev.entity); in sun6i_video_cleanup()
680 mutex_destroy(&video->lock); in sun6i_video_cleanup()