Lines Matching refs:vp
47 static void camif_cfg_video_path(struct camif_vp *vp) in camif_cfg_video_path() argument
49 WARN_ON(s3c_camif_get_scaler_config(vp, &vp->scaler)); in camif_cfg_video_path()
50 camif_hw_set_scaler(vp); in camif_cfg_video_path()
51 camif_hw_set_flip(vp); in camif_cfg_video_path()
52 camif_hw_set_target_format(vp); in camif_cfg_video_path()
53 camif_hw_set_output_dma(vp); in camif_cfg_video_path()
56 static void camif_prepare_dma_offset(struct camif_vp *vp) in camif_prepare_dma_offset() argument
58 struct camif_frame *f = &vp->out_frame; in camif_prepare_dma_offset()
68 static int s3c_camif_hw_init(struct camif_dev *camif, struct camif_vp *vp) in s3c_camif_hw_init() argument
72 if (camif->sensor.sd == NULL || vp->out_fmt == NULL) in s3c_camif_hw_init()
76 camif_hw_clear_fifo_overflow(vp); in s3c_camif_hw_init()
85 camif_hw_set_input_path(vp); in s3c_camif_hw_init()
86 camif_cfg_video_path(vp); in s3c_camif_hw_init()
87 vp->state &= ~ST_VP_CONFIG; in s3c_camif_hw_init()
98 static int s3c_camif_hw_vp_init(struct camif_dev *camif, struct camif_vp *vp) in s3c_camif_hw_vp_init() argument
102 if (vp->out_fmt == NULL) in s3c_camif_hw_vp_init()
105 camif_prepare_dma_offset(vp); in s3c_camif_hw_vp_init()
107 camif_hw_clear_fifo_overflow(vp); in s3c_camif_hw_vp_init()
108 camif_cfg_video_path(vp); in s3c_camif_hw_vp_init()
109 vp->state &= ~ST_VP_CONFIG; in s3c_camif_hw_vp_init()
150 static int camif_reinitialize(struct camif_vp *vp) in camif_reinitialize() argument
152 struct camif_dev *camif = vp->camif; in camif_reinitialize()
158 streaming = vp->state & ST_VP_SENSOR_STREAMING; in camif_reinitialize()
160 vp->state &= ~(ST_VP_PENDING | ST_VP_RUNNING | ST_VP_OFF | in camif_reinitialize()
165 while (!list_empty(&vp->pending_buf_q)) { in camif_reinitialize()
166 buf = camif_pending_queue_pop(vp); in camif_reinitialize()
170 while (!list_empty(&vp->active_buf_q)) { in camif_reinitialize()
171 buf = camif_active_queue_pop(vp); in camif_reinitialize()
183 static bool s3c_vp_active(struct camif_vp *vp) in s3c_vp_active() argument
185 struct camif_dev *camif = vp->camif; in s3c_vp_active()
190 ret = (vp->state & ST_VP_RUNNING) || (vp->state & ST_VP_PENDING); in s3c_vp_active()
208 static int camif_stop_capture(struct camif_vp *vp) in camif_stop_capture() argument
210 struct camif_dev *camif = vp->camif; in camif_stop_capture()
214 if (!s3c_vp_active(vp)) in camif_stop_capture()
218 vp->state &= ~(ST_VP_OFF | ST_VP_LASTIRQ); in camif_stop_capture()
219 vp->state |= ST_VP_ABORTING; in camif_stop_capture()
222 ret = wait_event_timeout(vp->irq_queue, in camif_stop_capture()
223 !(vp->state & ST_VP_ABORTING), in camif_stop_capture()
228 if (ret == 0 && !(vp->state & ST_VP_OFF)) { in camif_stop_capture()
230 vp->state &= ~(ST_VP_OFF | ST_VP_ABORTING | in camif_stop_capture()
233 camif_hw_disable_capture(vp); in camif_stop_capture()
234 camif_hw_enable_scaler(vp, false); in camif_stop_capture()
239 return camif_reinitialize(vp); in camif_stop_capture()
242 static int camif_prepare_addr(struct camif_vp *vp, struct vb2_buffer *vb, in camif_prepare_addr() argument
245 struct camif_frame *frame = &vp->out_frame; in camif_prepare_addr()
254 vp->out_fmt->colplanes, pix_size); in camif_prepare_addr()
258 switch (vp->out_fmt->colplanes) { in camif_prepare_addr()
271 if (vp->out_fmt->color == IMG_FMT_YCBCR422P) in camif_prepare_addr()
276 if (vp->out_fmt->color == IMG_FMT_YCRCB420) in camif_prepare_addr()
291 struct camif_vp *vp = priv; in s3c_camif_irq_handler() local
292 struct camif_dev *camif = vp->camif; in s3c_camif_irq_handler()
299 camif_hw_clear_pending_irq(vp); in s3c_camif_irq_handler()
301 status = camif_hw_get_status(vp); in s3c_camif_irq_handler()
304 camif_hw_clear_fifo_overflow(vp); in s3c_camif_irq_handler()
308 if (vp->state & ST_VP_ABORTING) { in s3c_camif_irq_handler()
309 if (vp->state & ST_VP_OFF) { in s3c_camif_irq_handler()
311 vp->state &= ~(ST_VP_OFF | ST_VP_ABORTING | in s3c_camif_irq_handler()
313 wake_up(&vp->irq_queue); in s3c_camif_irq_handler()
315 } else if (vp->state & ST_VP_LASTIRQ) { in s3c_camif_irq_handler()
316 camif_hw_disable_capture(vp); in s3c_camif_irq_handler()
317 camif_hw_enable_scaler(vp, false); in s3c_camif_irq_handler()
318 camif_hw_set_lastirq(vp, false); in s3c_camif_irq_handler()
319 vp->state |= ST_VP_OFF; in s3c_camif_irq_handler()
322 camif_hw_set_lastirq(vp, true); in s3c_camif_irq_handler()
323 vp->state |= ST_VP_LASTIRQ; in s3c_camif_irq_handler()
327 if (!list_empty(&vp->pending_buf_q) && (vp->state & ST_VP_RUNNING) && in s3c_camif_irq_handler()
328 !list_empty(&vp->active_buf_q)) { in s3c_camif_irq_handler()
337 vbuf = camif_active_queue_peek(vp, index); in s3c_camif_irq_handler()
342 vbuf->vb.sequence = vp->frame_sequence++; in s3c_camif_irq_handler()
346 vbuf = camif_pending_queue_pop(vp); in s3c_camif_irq_handler()
348 camif_hw_set_output_addr(vp, &vbuf->paddr, index); in s3c_camif_irq_handler()
349 camif_hw_set_output_addr(vp, &vbuf->paddr, index + 2); in s3c_camif_irq_handler()
352 camif_active_queue_add(vp, vbuf); in s3c_camif_irq_handler()
354 } else if (!(vp->state & ST_VP_ABORTING) && in s3c_camif_irq_handler()
355 (vp->state & ST_VP_PENDING)) { in s3c_camif_irq_handler()
356 vp->state |= ST_VP_RUNNING; in s3c_camif_irq_handler()
359 if (vp->state & ST_VP_CONFIG) { in s3c_camif_irq_handler()
360 camif_prepare_dma_offset(vp); in s3c_camif_irq_handler()
362 camif_hw_set_scaler(vp); in s3c_camif_irq_handler()
363 camif_hw_set_flip(vp); in s3c_camif_irq_handler()
368 vp->state &= ~ST_VP_CONFIG; in s3c_camif_irq_handler()
377 struct camif_vp *vp = vb2_get_drv_priv(vq); in start_streaming() local
378 struct camif_dev *camif = vp->camif; in start_streaming()
392 ret = s3c_camif_hw_init(camif, vp); in start_streaming()
394 ret = s3c_camif_hw_vp_init(camif, vp); in start_streaming()
399 camif_reinitialize(vp); in start_streaming()
404 vp->frame_sequence = 0; in start_streaming()
405 vp->state |= ST_VP_PENDING; in start_streaming()
407 if (!list_empty(&vp->pending_buf_q) && in start_streaming()
408 (!(vp->state & ST_VP_STREAMING) || in start_streaming()
409 !(vp->state & ST_VP_SENSOR_STREAMING))) { in start_streaming()
411 camif_hw_enable_scaler(vp, vp->scaler.enable); in start_streaming()
412 camif_hw_enable_capture(vp); in start_streaming()
413 vp->state |= ST_VP_STREAMING; in start_streaming()
415 if (!(vp->state & ST_VP_SENSOR_STREAMING)) { in start_streaming()
416 vp->state |= ST_VP_SENSOR_STREAMING; in start_streaming()
420 v4l2_err(&vp->vdev, "Sensor s_stream failed\n"); in start_streaming()
434 struct camif_vp *vp = vb2_get_drv_priv(vq); in stop_streaming() local
435 camif_stop_capture(vp); in stop_streaming()
444 struct camif_vp *vp = vb2_get_drv_priv(vq); in queue_setup() local
445 struct camif_dev *camif = vp->camif; in queue_setup()
446 struct camif_frame *frame = &vp->out_frame; in queue_setup()
452 fmt = s3c_camif_find_format(vp, &pix->pixelformat, -1); in queue_setup()
457 fmt = vp->out_fmt; in queue_setup()
477 struct camif_vp *vp = vb2_get_drv_priv(vb->vb2_queue); in buffer_prepare() local
479 if (vp->out_fmt == NULL) in buffer_prepare()
482 if (vb2_plane_size(vb, 0) < vp->payload) { in buffer_prepare()
483 v4l2_err(&vp->vdev, "buffer too small: %lu, required: %u\n", in buffer_prepare()
484 vb2_plane_size(vb, 0), vp->payload); in buffer_prepare()
487 vb2_set_plane_payload(vb, 0, vp->payload); in buffer_prepare()
496 struct camif_vp *vp = vb2_get_drv_priv(vb->vb2_queue); in buffer_queue() local
497 struct camif_dev *camif = vp->camif; in buffer_queue()
501 WARN_ON(camif_prepare_addr(vp, &buf->vb.vb2_buf, &buf->paddr)); in buffer_queue()
503 if (!(vp->state & ST_VP_STREAMING) && vp->active_buffers < 2) { in buffer_queue()
505 buf->index = vp->buf_index; in buffer_queue()
507 camif_hw_set_output_addr(vp, &buf->paddr, buf->index); in buffer_queue()
508 camif_hw_set_output_addr(vp, &buf->paddr, buf->index + 2); in buffer_queue()
510 camif_active_queue_add(vp, buf); in buffer_queue()
511 vp->buf_index = !vp->buf_index; in buffer_queue()
513 camif_pending_queue_add(vp, buf); in buffer_queue()
516 if (vb2_is_streaming(&vp->vb_queue) && !list_empty(&vp->pending_buf_q) in buffer_queue()
517 && !(vp->state & ST_VP_STREAMING)) { in buffer_queue()
519 vp->state |= ST_VP_STREAMING; in buffer_queue()
520 camif_hw_enable_scaler(vp, vp->scaler.enable); in buffer_queue()
521 camif_hw_enable_capture(vp); in buffer_queue()
524 if (!(vp->state & ST_VP_SENSOR_STREAMING)) { in buffer_queue()
526 vp->state |= ST_VP_SENSOR_STREAMING; in buffer_queue()
528 v4l2_err(&vp->vdev, "Sensor s_stream failed\n"); in buffer_queue()
550 struct camif_vp *vp = video_drvdata(file); in s3c_camif_open() local
551 struct camif_dev *camif = vp->camif; in s3c_camif_open()
554 pr_debug("[vp%d] state: %#x, owner: %p, pid: %d\n", vp->id, in s3c_camif_open()
555 vp->state, vp->owner, task_pid_nr(current)); in s3c_camif_open()
582 struct camif_vp *vp = video_drvdata(file); in s3c_camif_close() local
583 struct camif_dev *camif = vp->camif; in s3c_camif_close()
586 pr_debug("[vp%d] state: %#x, owner: %p, pid: %d\n", vp->id, in s3c_camif_close()
587 vp->state, vp->owner, task_pid_nr(current)); in s3c_camif_close()
591 if (vp->owner == file->private_data) { in s3c_camif_close()
592 camif_stop_capture(vp); in s3c_camif_close()
593 vb2_queue_release(&vp->vb_queue); in s3c_camif_close()
594 vp->owner = NULL; in s3c_camif_close()
609 struct camif_vp *vp = video_drvdata(file); in s3c_camif_poll() local
610 struct camif_dev *camif = vp->camif; in s3c_camif_poll()
614 if (vp->owner && vp->owner != file->private_data) in s3c_camif_poll()
617 ret = vb2_poll(&vp->vb_queue, file, wait); in s3c_camif_poll()
625 struct camif_vp *vp = video_drvdata(file); in s3c_camif_mmap() local
628 if (vp->owner && vp->owner != file->private_data) in s3c_camif_mmap()
631 ret = vb2_mmap(&vp->vb_queue, vma); in s3c_camif_mmap()
652 struct camif_vp *vp = video_drvdata(file); in s3c_camif_vidioc_querycap() local
657 dev_name(vp->camif->dev), vp->id); in s3c_camif_vidioc_querycap()
668 struct camif_vp *vp = video_drvdata(file); in s3c_camif_vidioc_enum_input() local
669 struct v4l2_subdev *sensor = vp->camif->sensor.sd; in s3c_camif_vidioc_enum_input()
695 struct camif_vp *vp = video_drvdata(file); in s3c_camif_vidioc_enum_fmt() local
698 fmt = s3c_camif_find_format(vp, NULL, f->index); in s3c_camif_vidioc_enum_fmt()
712 struct camif_vp *vp = video_drvdata(file); in s3c_camif_vidioc_g_fmt() local
714 struct camif_frame *frame = &vp->out_frame; in s3c_camif_vidioc_g_fmt()
715 const struct camif_fmt *fmt = vp->out_fmt; in s3c_camif_vidioc_g_fmt()
718 pix->sizeimage = vp->payload; in s3c_camif_vidioc_g_fmt()
729 static int __camif_video_try_format(struct camif_vp *vp, in __camif_video_try_format() argument
733 struct camif_dev *camif = vp->camif; in __camif_video_try_format()
739 fmt = s3c_camif_find_format(vp, &pix->pixelformat, 0); in __camif_video_try_format()
747 pix_lim = &camif->variant->vp_pix_limits[vp->id]; in __camif_video_try_format()
783 struct camif_vp *vp = video_drvdata(file); in s3c_camif_vidioc_try_fmt() local
784 return __camif_video_try_format(vp, &f->fmt.pix, NULL); in s3c_camif_vidioc_try_fmt()
791 struct camif_vp *vp = video_drvdata(file); in s3c_camif_vidioc_s_fmt() local
792 struct camif_frame *out_frame = &vp->out_frame; in s3c_camif_vidioc_s_fmt()
796 pr_debug("[vp%d]\n", vp->id); in s3c_camif_vidioc_s_fmt()
798 if (vb2_is_busy(&vp->vb_queue)) in s3c_camif_vidioc_s_fmt()
801 ret = __camif_video_try_format(vp, &f->fmt.pix, &fmt); in s3c_camif_vidioc_s_fmt()
805 vp->out_fmt = fmt; in s3c_camif_vidioc_s_fmt()
806 vp->payload = pix->sizeimage; in s3c_camif_vidioc_s_fmt()
816 if (vp->owner == NULL) in s3c_camif_vidioc_s_fmt()
817 vp->owner = priv; in s3c_camif_vidioc_s_fmt()
820 out_frame->f_width, out_frame->f_height, vp->payload, fmt->name, in s3c_camif_vidioc_s_fmt()
856 struct camif_vp *vp = video_drvdata(file); in s3c_camif_streamon() local
857 struct camif_dev *camif = vp->camif; in s3c_camif_streamon()
861 pr_debug("[vp%d]\n", vp->id); in s3c_camif_streamon()
866 if (vp->owner && vp->owner != priv) in s3c_camif_streamon()
869 if (s3c_vp_active(vp)) in s3c_camif_streamon()
882 return vb2_streamon(&vp->vb_queue, type); in s3c_camif_streamon()
888 struct camif_vp *vp = video_drvdata(file); in s3c_camif_streamoff() local
889 struct camif_dev *camif = vp->camif; in s3c_camif_streamoff()
892 pr_debug("[vp%d]\n", vp->id); in s3c_camif_streamoff()
897 if (vp->owner && vp->owner != priv) in s3c_camif_streamoff()
900 ret = vb2_streamoff(&vp->vb_queue, type); in s3c_camif_streamoff()
909 struct camif_vp *vp = video_drvdata(file); in s3c_camif_reqbufs() local
913 vp->id, rb->count, vp->owner, priv); in s3c_camif_reqbufs()
915 if (vp->owner && vp->owner != priv) in s3c_camif_reqbufs()
921 vp->owner = NULL; in s3c_camif_reqbufs()
923 ret = vb2_reqbufs(&vp->vb_queue, rb); in s3c_camif_reqbufs()
929 vb2_reqbufs(&vp->vb_queue, rb); in s3c_camif_reqbufs()
933 vp->reqbufs_count = rb->count; in s3c_camif_reqbufs()
934 if (vp->owner == NULL && rb->count > 0) in s3c_camif_reqbufs()
935 vp->owner = priv; in s3c_camif_reqbufs()
943 struct camif_vp *vp = video_drvdata(file); in s3c_camif_querybuf() local
944 return vb2_querybuf(&vp->vb_queue, buf); in s3c_camif_querybuf()
950 struct camif_vp *vp = video_drvdata(file); in s3c_camif_qbuf() local
952 pr_debug("[vp%d]\n", vp->id); in s3c_camif_qbuf()
954 if (vp->owner && vp->owner != priv) in s3c_camif_qbuf()
957 return vb2_qbuf(&vp->vb_queue, buf); in s3c_camif_qbuf()
963 struct camif_vp *vp = video_drvdata(file); in s3c_camif_dqbuf() local
965 pr_debug("[vp%d] sequence: %d\n", vp->id, vp->frame_sequence); in s3c_camif_dqbuf()
967 if (vp->owner && vp->owner != priv) in s3c_camif_dqbuf()
970 return vb2_dqbuf(&vp->vb_queue, buf, file->f_flags & O_NONBLOCK); in s3c_camif_dqbuf()
976 struct camif_vp *vp = video_drvdata(file); in s3c_camif_create_bufs() local
979 if (vp->owner && vp->owner != priv) in s3c_camif_create_bufs()
983 ret = vb2_create_bufs(&vp->vb_queue, create); in s3c_camif_create_bufs()
985 if (!ret && vp->owner == NULL) in s3c_camif_create_bufs()
986 vp->owner = priv; in s3c_camif_create_bufs()
994 struct camif_vp *vp = video_drvdata(file); in s3c_camif_prepare_buf() local
995 return vb2_prepare_buf(&vp->vb_queue, b); in s3c_camif_prepare_buf()
1001 struct camif_vp *vp = video_drvdata(file); in s3c_camif_g_selection() local
1011 sel->r.width = vp->out_frame.f_width; in s3c_camif_g_selection()
1012 sel->r.height = vp->out_frame.f_height; in s3c_camif_g_selection()
1016 sel->r = vp->out_frame.rect; in s3c_camif_g_selection()
1023 static void __camif_try_compose(struct camif_dev *camif, struct camif_vp *vp, in __camif_try_compose() argument
1028 *r = vp->out_frame.rect; in __camif_try_compose()
1038 struct camif_vp *vp = video_drvdata(file); in s3c_camif_s_selection() local
1039 struct camif_dev *camif = vp->camif; in s3c_camif_s_selection()
1047 __camif_try_compose(camif, vp, &rect); in s3c_camif_s_selection()
1051 vp->out_frame.rect = rect; in s3c_camif_s_selection()
1052 vp->state |= ST_VP_CONFIG; in s3c_camif_s_selection()
1091 struct camif_vp *vp = ctrl->priv; in s3c_camif_video_s_ctrl() local
1092 struct camif_dev *camif = vp->camif; in s3c_camif_video_s_ctrl()
1095 pr_debug("[vp%d] ctrl: %s, value: %d\n", vp->id, in s3c_camif_video_s_ctrl()
1102 vp->hflip = ctrl->val; in s3c_camif_video_s_ctrl()
1106 vp->vflip = ctrl->val; in s3c_camif_video_s_ctrl()
1110 vp->state |= ST_VP_CONFIG; in s3c_camif_video_s_ctrl()
1122 struct camif_vp *vp = &camif->vp[idx]; in s3c_camif_register_video_node() local
1123 struct vb2_queue *q = &vp->vb_queue; in s3c_camif_register_video_node()
1124 struct video_device *vfd = &vp->vdev; in s3c_camif_register_video_node()
1130 vp->id == 0 ? "codec" : "preview"); in s3c_camif_register_video_node()
1138 vp->reqbufs_count = 0; in s3c_camif_register_video_node()
1140 INIT_LIST_HEAD(&vp->pending_buf_q); in s3c_camif_register_video_node()
1141 INIT_LIST_HEAD(&vp->active_buf_q); in s3c_camif_register_video_node()
1149 q->drv_priv = vp; in s3c_camif_register_video_node()
1151 q->lock = &vp->camif->lock; in s3c_camif_register_video_node()
1157 vp->pad.flags = MEDIA_PAD_FL_SINK; in s3c_camif_register_video_node()
1158 ret = media_entity_init(&vfd->entity, 1, &vp->pad, 0); in s3c_camif_register_video_node()
1162 video_set_drvdata(vfd, vp); in s3c_camif_register_video_node()
1164 v4l2_ctrl_handler_init(&vp->ctrl_handler, 1); in s3c_camif_register_video_node()
1165 ctrl = v4l2_ctrl_new_std(&vp->ctrl_handler, &s3c_camif_video_ctrl_ops, in s3c_camif_register_video_node()
1168 ctrl->priv = vp; in s3c_camif_register_video_node()
1169 ctrl = v4l2_ctrl_new_std(&vp->ctrl_handler, &s3c_camif_video_ctrl_ops, in s3c_camif_register_video_node()
1172 ctrl->priv = vp; in s3c_camif_register_video_node()
1174 ret = vp->ctrl_handler.error; in s3c_camif_register_video_node()
1178 vfd->ctrl_handler = &vp->ctrl_handler; in s3c_camif_register_video_node()
1189 v4l2_ctrl_handler_free(&vp->ctrl_handler); in s3c_camif_register_video_node()
1199 struct video_device *vfd = &camif->vp[idx].vdev; in s3c_camif_unregister_video_node()
1318 if (vb2_is_busy(&camif->vp[VP_CODEC].vb_queue) || in s3c_camif_subdev_set_fmt()
1319 vb2_is_busy(&camif->vp[VP_PREVIEW].vb_queue)) { in s3c_camif_subdev_set_fmt()
1346 struct camif_frame *frame = &camif->vp[i].out_frame; in s3c_camif_subdev_set_fmt()
1439 struct v4l2_rect *or = &camif->vp[i].out_frame.rect; in __camif_try_crop()
1476 struct camif_vp *vp = &camif->vp[i]; in s3c_camif_subdev_set_selection() local
1477 scaler = vp->scaler; in s3c_camif_subdev_set_selection()
1478 if (s3c_camif_get_scaler_config(vp, &scaler)) in s3c_camif_subdev_set_selection()
1480 vp->scaler = scaler; in s3c_camif_subdev_set_selection()
1481 vp->state |= ST_VP_CONFIG; in s3c_camif_subdev_set_selection()
1541 camif->vp[VP_CODEC].state |= ST_VP_CONFIG; in s3c_camif_subdev_s_ctrl()
1542 camif->vp[VP_PREVIEW].state |= ST_VP_CONFIG; in s3c_camif_subdev_s_ctrl()
1631 struct camif_vp *vp = &camif->vp[i]; in s3c_camif_set_defaults() local
1632 struct camif_frame *f = &vp->out_frame; in s3c_camif_set_defaults()
1634 vp->camif = camif; in s3c_camif_set_defaults()
1635 vp->id = i; in s3c_camif_set_defaults()
1636 vp->offset = camif->variant->vp_offset; in s3c_camif_set_defaults()
1639 vp->fmt_flags = i ? FMT_FL_S3C24XX_PREVIEW : in s3c_camif_set_defaults()
1642 vp->fmt_flags = FMT_FL_S3C64XX; in s3c_camif_set_defaults()
1644 vp->out_fmt = s3c_camif_find_format(vp, NULL, 0); in s3c_camif_set_defaults()
1645 BUG_ON(vp->out_fmt == NULL); in s3c_camif_set_defaults()
1654 vp->scaler.enable = 1; in s3c_camif_set_defaults()
1656 vp->payload = (f->f_width * f->f_height * in s3c_camif_set_defaults()
1657 vp->out_fmt->depth) / 8; in s3c_camif_set_defaults()