Lines Matching full:video
494 struct mxc_isi_video *video = &pipe->video; in mxc_isi_video_frame_write_done() local
500 spin_lock(&video->buf_lock); in mxc_isi_video_frame_write_done()
560 buf = list_first_entry_or_null(&video->out_active, in mxc_isi_video_frame_write_done()
591 video->frame_count += 2; in mxc_isi_video_frame_write_done()
596 next_buf = list_first_entry_or_null(&video->out_pending, in mxc_isi_video_frame_write_done()
599 next_buf = list_first_entry_or_null(&video->out_discard, in mxc_isi_video_frame_write_done()
629 video->frame_count += 2; in mxc_isi_video_frame_write_done()
637 list_move_tail(&next_buf->list, &video->out_active); in mxc_isi_video_frame_write_done()
641 buf->v4l2_buf.sequence = video->frame_count; in mxc_isi_video_frame_write_done()
645 list_move_tail(&buf->list, &video->out_discard); in mxc_isi_video_frame_write_done()
648 video->frame_count++; in mxc_isi_video_frame_write_done()
651 spin_unlock(&video->buf_lock); in mxc_isi_video_frame_write_done()
654 static void mxc_isi_video_free_discard_buffers(struct mxc_isi_video *video) in mxc_isi_video_free_discard_buffers() argument
658 for (i = 0; i < video->pix.num_planes; i++) { in mxc_isi_video_free_discard_buffers()
659 struct mxc_isi_dma_buffer *buf = &video->discard_buffer[i]; in mxc_isi_video_free_discard_buffers()
664 dma_free_coherent(video->pipe->isi->dev, buf->size, buf->addr, in mxc_isi_video_free_discard_buffers()
670 static int mxc_isi_video_alloc_discard_buffers(struct mxc_isi_video *video) in mxc_isi_video_alloc_discard_buffers() argument
675 for (i = 0; i < video->pix.num_planes; i++) { in mxc_isi_video_alloc_discard_buffers()
676 struct mxc_isi_dma_buffer *buf = &video->discard_buffer[i]; in mxc_isi_video_alloc_discard_buffers()
678 buf->size = PAGE_ALIGN(video->pix.plane_fmt[i].sizeimage); in mxc_isi_video_alloc_discard_buffers()
679 buf->addr = dma_alloc_coherent(video->pipe->isi->dev, buf->size, in mxc_isi_video_alloc_discard_buffers()
682 mxc_isi_video_free_discard_buffers(video); in mxc_isi_video_alloc_discard_buffers()
686 dev_dbg(video->pipe->isi->dev, in mxc_isi_video_alloc_discard_buffers()
692 for (i = 0; i < ARRAY_SIZE(video->buf_discard); ++i) { in mxc_isi_video_alloc_discard_buffers()
693 struct mxc_isi_buffer *buf = &video->buf_discard[i]; in mxc_isi_video_alloc_discard_buffers()
697 for (j = 0; j < video->pix.num_planes; ++j) in mxc_isi_video_alloc_discard_buffers()
698 buf->dma_addrs[j] = video->discard_buffer[j].dma; in mxc_isi_video_alloc_discard_buffers()
704 static int mxc_isi_video_validate_format(struct mxc_isi_video *video) in mxc_isi_video_validate_format() argument
709 struct v4l2_subdev *sd = &video->pipe->sd; in mxc_isi_video_validate_format()
714 info = mxc_isi_format_by_fourcc(video->pix.pixelformat, in mxc_isi_video_validate_format()
719 format->width != video->pix.width || in mxc_isi_video_validate_format()
720 format->height != video->pix.height) { in mxc_isi_video_validate_format()
721 dev_dbg(video->pipe->isi->dev, in mxc_isi_video_validate_format()
724 info->mbus_code, video->pix.width, video->pix.height); in mxc_isi_video_validate_format()
733 static void mxc_isi_video_return_buffers(struct mxc_isi_video *video, in mxc_isi_video_return_buffers() argument
738 spin_lock_irq(&video->buf_lock); in mxc_isi_video_return_buffers()
740 while (!list_empty(&video->out_active)) { in mxc_isi_video_return_buffers()
741 buf = list_first_entry(&video->out_active, in mxc_isi_video_return_buffers()
750 while (!list_empty(&video->out_pending)) { in mxc_isi_video_return_buffers()
751 buf = list_first_entry(&video->out_pending, in mxc_isi_video_return_buffers()
757 while (!list_empty(&video->out_discard)) { in mxc_isi_video_return_buffers()
758 buf = list_first_entry(&video->out_discard, in mxc_isi_video_return_buffers()
763 INIT_LIST_HEAD(&video->out_active); in mxc_isi_video_return_buffers()
764 INIT_LIST_HEAD(&video->out_pending); in mxc_isi_video_return_buffers()
765 INIT_LIST_HEAD(&video->out_discard); in mxc_isi_video_return_buffers()
767 spin_unlock_irq(&video->buf_lock); in mxc_isi_video_return_buffers()
770 static void mxc_isi_video_queue_first_buffers(struct mxc_isi_video *video) in mxc_isi_video_queue_first_buffers() argument
775 lockdep_assert_held(&video->buf_lock); in mxc_isi_video_queue_first_buffers()
785 discard = list_empty(&video->out_pending) ? 2 in mxc_isi_video_queue_first_buffers()
786 : list_is_singular(&video->out_pending) ? 1 in mxc_isi_video_queue_first_buffers()
795 list = i < discard ? &video->out_discard : &video->out_pending; in mxc_isi_video_queue_first_buffers()
798 mxc_isi_channel_set_outbuf(video->pipe, buf->dma_addrs, buf_id); in mxc_isi_video_queue_first_buffers()
800 list_move_tail(&buf->list, &video->out_active); in mxc_isi_video_queue_first_buffers()
887 struct mxc_isi_video *video = vb2_get_drv_priv(q); in mxc_isi_vb2_queue_setup() local
889 return mxc_isi_video_queue_setup(&video->pix, video->fmtinfo, in mxc_isi_vb2_queue_setup()
896 struct mxc_isi_video *video = vb2_get_drv_priv(vb2->vb2_queue); in mxc_isi_vb2_buffer_init() local
898 mxc_isi_video_buffer_init(vb2, buf->dma_addrs, video->fmtinfo, in mxc_isi_vb2_buffer_init()
899 &video->pix); in mxc_isi_vb2_buffer_init()
906 struct mxc_isi_video *video = vb2_get_drv_priv(vb2->vb2_queue); in mxc_isi_vb2_buffer_prepare() local
908 return mxc_isi_video_buffer_prepare(video->pipe->isi, vb2, in mxc_isi_vb2_buffer_prepare()
909 video->fmtinfo, &video->pix); in mxc_isi_vb2_buffer_prepare()
916 struct mxc_isi_video *video = vb2_get_drv_priv(vb2->vb2_queue); in mxc_isi_vb2_buffer_queue() local
918 spin_lock_irq(&video->buf_lock); in mxc_isi_vb2_buffer_queue()
919 list_add_tail(&buf->list, &video->out_pending); in mxc_isi_vb2_buffer_queue()
920 spin_unlock_irq(&video->buf_lock); in mxc_isi_vb2_buffer_queue()
923 static void mxc_isi_video_init_channel(struct mxc_isi_video *video) in mxc_isi_video_init_channel() argument
925 struct mxc_isi_pipe *pipe = video->pipe; in mxc_isi_video_init_channel()
929 mutex_lock(video->ctrls.handler.lock); in mxc_isi_video_init_channel()
930 mxc_isi_channel_set_alpha(pipe, video->ctrls.alpha); in mxc_isi_video_init_channel()
931 mxc_isi_channel_set_flip(pipe, video->ctrls.hflip, video->ctrls.vflip); in mxc_isi_video_init_channel()
932 mutex_unlock(video->ctrls.handler.lock); in mxc_isi_video_init_channel()
934 mxc_isi_channel_set_output_format(pipe, video->fmtinfo, &video->pix); in mxc_isi_video_init_channel()
939 struct mxc_isi_video *video = vb2_get_drv_priv(q); in mxc_isi_vb2_start_streaming() local
944 mxc_isi_video_init_channel(video); in mxc_isi_vb2_start_streaming()
946 spin_lock_irq(&video->buf_lock); in mxc_isi_vb2_start_streaming()
949 for (i = 0; i < ARRAY_SIZE(video->buf_discard); ++i) { in mxc_isi_vb2_start_streaming()
950 struct mxc_isi_buffer *buf = &video->buf_discard[i]; in mxc_isi_vb2_start_streaming()
952 list_add_tail(&buf->list, &video->out_discard); in mxc_isi_vb2_start_streaming()
956 mxc_isi_video_queue_first_buffers(video); in mxc_isi_vb2_start_streaming()
959 video->frame_count = 0; in mxc_isi_vb2_start_streaming()
961 spin_unlock_irq(&video->buf_lock); in mxc_isi_vb2_start_streaming()
963 ret = mxc_isi_pipe_enable(video->pipe); in mxc_isi_vb2_start_streaming()
970 mxc_isi_channel_put(video->pipe); in mxc_isi_vb2_start_streaming()
971 mxc_isi_video_return_buffers(video, VB2_BUF_STATE_QUEUED); in mxc_isi_vb2_start_streaming()
977 struct mxc_isi_video *video = vb2_get_drv_priv(q); in mxc_isi_vb2_stop_streaming() local
979 mxc_isi_pipe_disable(video->pipe); in mxc_isi_vb2_stop_streaming()
980 mxc_isi_channel_put(video->pipe); in mxc_isi_vb2_stop_streaming()
982 mxc_isi_video_return_buffers(video, VB2_BUF_STATE_ERROR); in mxc_isi_vb2_stop_streaming()
1007 struct mxc_isi_video *video = ctrl_to_isi_video(ctrl); in mxc_isi_video_s_ctrl() local
1011 video->ctrls.alpha = ctrl->val; in mxc_isi_video_s_ctrl()
1014 video->ctrls.vflip = ctrl->val; in mxc_isi_video_s_ctrl()
1017 video->ctrls.hflip = ctrl->val; in mxc_isi_video_s_ctrl()
1028 static int mxc_isi_video_ctrls_create(struct mxc_isi_video *video) in mxc_isi_video_ctrls_create() argument
1030 struct v4l2_ctrl_handler *handler = &video->ctrls.handler; in mxc_isi_video_ctrls_create()
1050 video->vdev.ctrl_handler = handler; in mxc_isi_video_ctrls_create()
1055 static void mxc_isi_video_ctrls_delete(struct mxc_isi_video *video) in mxc_isi_video_ctrls_delete() argument
1057 v4l2_ctrl_handler_free(&video->ctrls.handler); in mxc_isi_video_ctrls_delete()
1116 struct mxc_isi_video *video = video_drvdata(file); in mxc_isi_video_g_fmt() local
1118 f->fmt.pix_mp = video->pix; in mxc_isi_video_g_fmt()
1126 struct mxc_isi_video *video = video_drvdata(file); in mxc_isi_video_try_fmt() local
1128 mxc_isi_format_try(video->pipe, &f->fmt.pix_mp, MXC_ISI_VIDEO_CAP); in mxc_isi_video_try_fmt()
1135 struct mxc_isi_video *video = video_drvdata(file); in mxc_isi_video_s_fmt() local
1138 if (vb2_is_busy(&video->vb2_q)) in mxc_isi_video_s_fmt()
1141 video->fmtinfo = mxc_isi_format_try(video->pipe, pix, MXC_ISI_VIDEO_CAP); in mxc_isi_video_s_fmt()
1142 video->pix = *pix; in mxc_isi_video_s_fmt()
1150 struct mxc_isi_video *video = video_drvdata(file); in mxc_isi_video_streamon() local
1151 struct media_device *mdev = &video->pipe->isi->media_dev; in mxc_isi_video_streamon()
1155 if (vb2_queue_is_busy(&video->vb2_q, file)) in mxc_isi_video_streamon()
1159 * Get a pipeline for the video node and start it. This must be done in mxc_isi_video_streamon()
1166 ret = mxc_isi_pipe_acquire(video->pipe, &mxc_isi_video_frame_write_done); in mxc_isi_video_streamon()
1172 pipe = media_entity_pipeline(&video->vdev.entity) ? : &video->pipe->pipe; in mxc_isi_video_streamon()
1174 ret = __video_device_pipeline_start(&video->vdev, pipe); in mxc_isi_video_streamon()
1182 /* Verify that the video format matches the output of the subdev. */ in mxc_isi_video_streamon()
1183 ret = mxc_isi_video_validate_format(video); in mxc_isi_video_streamon()
1188 ret = mxc_isi_video_alloc_discard_buffers(video); in mxc_isi_video_streamon()
1192 ret = vb2_streamon(&video->vb2_q, type); in mxc_isi_video_streamon()
1196 video->is_streaming = true; in mxc_isi_video_streamon()
1201 mxc_isi_video_free_discard_buffers(video); in mxc_isi_video_streamon()
1203 video_device_pipeline_stop(&video->vdev); in mxc_isi_video_streamon()
1205 mxc_isi_pipe_release(video->pipe); in mxc_isi_video_streamon()
1209 static void mxc_isi_video_cleanup_streaming(struct mxc_isi_video *video) in mxc_isi_video_cleanup_streaming() argument
1211 lockdep_assert_held(&video->lock); in mxc_isi_video_cleanup_streaming()
1213 if (!video->is_streaming) in mxc_isi_video_cleanup_streaming()
1216 mxc_isi_video_free_discard_buffers(video); in mxc_isi_video_cleanup_streaming()
1217 video_device_pipeline_stop(&video->vdev); in mxc_isi_video_cleanup_streaming()
1218 mxc_isi_pipe_release(video->pipe); in mxc_isi_video_cleanup_streaming()
1220 video->is_streaming = false; in mxc_isi_video_cleanup_streaming()
1226 struct mxc_isi_video *video = video_drvdata(file); in mxc_isi_video_streamoff() local
1233 mxc_isi_video_cleanup_streaming(video); in mxc_isi_video_streamoff()
1241 struct mxc_isi_video *video = video_drvdata(file); in mxc_isi_video_enum_framesizes() local
1257 max_width = video->pipe->id == video->pipe->isi->pdata->num_channels - 1 in mxc_isi_video_enum_framesizes()
1304 * Video device file operations
1309 struct mxc_isi_video *video = video_drvdata(file); in mxc_isi_video_open() local
1316 ret = pm_runtime_resume_and_get(video->pipe->isi->dev); in mxc_isi_video_open()
1327 struct mxc_isi_video *video = video_drvdata(file); in mxc_isi_video_release() local
1332 dev_err(video->pipe->isi->dev, "%s fail\n", __func__); in mxc_isi_video_release()
1334 mutex_lock(&video->lock); in mxc_isi_video_release()
1335 mxc_isi_video_cleanup_streaming(video); in mxc_isi_video_release()
1336 mutex_unlock(&video->lock); in mxc_isi_video_release()
1338 pm_runtime_put(video->pipe->isi->dev); in mxc_isi_video_release()
1357 struct mxc_isi_video *video = &pipe->video; in mxc_isi_video_suspend() local
1359 if (!video->is_streaming) in mxc_isi_video_suspend()
1365 spin_lock_irq(&video->buf_lock); in mxc_isi_video_suspend()
1372 while (!list_empty(&video->out_active)) { in mxc_isi_video_suspend()
1374 list_last_entry(&video->out_active, in mxc_isi_video_suspend()
1378 list_move(&buf->list, &video->out_discard); in mxc_isi_video_suspend()
1380 list_move(&buf->list, &video->out_pending); in mxc_isi_video_suspend()
1383 spin_unlock_irq(&video->buf_lock); in mxc_isi_video_suspend()
1388 struct mxc_isi_video *video = &pipe->video; in mxc_isi_video_resume() local
1390 if (!video->is_streaming) in mxc_isi_video_resume()
1393 mxc_isi_video_init_channel(video); in mxc_isi_video_resume()
1395 spin_lock_irq(&video->buf_lock); in mxc_isi_video_resume()
1396 mxc_isi_video_queue_first_buffers(video); in mxc_isi_video_resume()
1397 spin_unlock_irq(&video->buf_lock); in mxc_isi_video_resume()
1409 struct mxc_isi_video *video = &pipe->video; in mxc_isi_video_register() local
1410 struct v4l2_pix_format_mplane *pix = &video->pix; in mxc_isi_video_register()
1411 struct video_device *vdev = &video->vdev; in mxc_isi_video_register()
1412 struct vb2_queue *q = &video->vb2_q; in mxc_isi_video_register()
1415 video->pipe = pipe; in mxc_isi_video_register()
1417 mutex_init(&video->lock); in mxc_isi_video_register()
1418 spin_lock_init(&video->buf_lock); in mxc_isi_video_register()
1427 video->fmtinfo = mxc_isi_format_try(video->pipe, pix, MXC_ISI_VIDEO_CAP); in mxc_isi_video_register()
1438 vdev->lock = &video->lock; in mxc_isi_video_register()
1442 video_set_drvdata(vdev, video); in mxc_isi_video_register()
1444 INIT_LIST_HEAD(&video->out_pending); in mxc_isi_video_register()
1445 INIT_LIST_HEAD(&video->out_active); in mxc_isi_video_register()
1446 INIT_LIST_HEAD(&video->out_discard); in mxc_isi_video_register()
1451 q->drv_priv = video; in mxc_isi_video_register()
1457 q->lock = &video->lock; in mxc_isi_video_register()
1464 video->pad.flags = MEDIA_PAD_FL_SINK; in mxc_isi_video_register()
1466 ret = media_entity_pads_init(&vdev->entity, 1, &video->pad); in mxc_isi_video_register()
1470 ret = mxc_isi_video_ctrls_create(video); in mxc_isi_video_register()
1491 mxc_isi_video_ctrls_delete(video); in mxc_isi_video_register()
1500 struct mxc_isi_video *video = &pipe->video; in mxc_isi_video_unregister() local
1501 struct video_device *vdev = &video->vdev; in mxc_isi_video_unregister()
1503 mutex_lock(&video->lock); in mxc_isi_video_unregister()
1507 mxc_isi_video_ctrls_delete(video); in mxc_isi_video_unregister()
1511 mutex_unlock(&video->lock); in mxc_isi_video_unregister()