Lines Matching refs:vp

43 /* Locking: called with vp->camif->slock spinlock held */
44 static void camif_cfg_video_path(struct camif_vp *vp)
46 WARN_ON(s3c_camif_get_scaler_config(vp, &vp->scaler));
47 camif_hw_set_scaler(vp);
48 camif_hw_set_flip(vp);
49 camif_hw_set_target_format(vp);
50 camif_hw_set_output_dma(vp);
53 static void camif_prepare_dma_offset(struct camif_vp *vp)
55 struct camif_frame *f = &vp->out_frame;
65 static int s3c_camif_hw_init(struct camif_dev *camif, struct camif_vp *vp)
69 if (camif->sensor.sd == NULL || vp->out_fmt == NULL)
73 camif_hw_clear_fifo_overflow(vp);
82 camif_hw_set_input_path(vp);
83 camif_cfg_video_path(vp);
84 vp->state &= ~ST_VP_CONFIG;
95 static int s3c_camif_hw_vp_init(struct camif_dev *camif, struct camif_vp *vp)
99 if (vp->out_fmt == NULL)
102 camif_prepare_dma_offset(vp);
104 camif_hw_clear_fifo_overflow(vp);
105 camif_cfg_video_path(vp);
106 vp->state &= ~ST_VP_CONFIG;
149 static int camif_reinitialize(struct camif_vp *vp)
151 struct camif_dev *camif = vp->camif;
157 streaming = vp->state & ST_VP_SENSOR_STREAMING;
159 vp->state &= ~(ST_VP_PENDING | ST_VP_RUNNING | ST_VP_OFF |
164 while (!list_empty(&vp->pending_buf_q)) {
165 buf = camif_pending_queue_pop(vp);
169 while (!list_empty(&vp->active_buf_q)) {
170 buf = camif_active_queue_pop(vp);
182 static bool s3c_vp_active(struct camif_vp *vp)
184 struct camif_dev *camif = vp->camif;
189 ret = (vp->state & ST_VP_RUNNING) || (vp->state & ST_VP_PENDING);
207 static int camif_stop_capture(struct camif_vp *vp)
209 struct camif_dev *camif = vp->camif;
213 if (!s3c_vp_active(vp))
217 vp->state &= ~(ST_VP_OFF | ST_VP_LASTIRQ);
218 vp->state |= ST_VP_ABORTING;
221 ret = wait_event_timeout(vp->irq_queue,
222 !(vp->state & ST_VP_ABORTING),
227 if (ret == 0 && !(vp->state & ST_VP_OFF)) {
229 vp->state &= ~(ST_VP_OFF | ST_VP_ABORTING |
232 camif_hw_disable_capture(vp);
233 camif_hw_enable_scaler(vp, false);
238 return camif_reinitialize(vp);
241 static int camif_prepare_addr(struct camif_vp *vp, struct vb2_buffer *vb,
244 struct camif_frame *frame = &vp->out_frame;
253 vp->out_fmt->colplanes, pix_size);
257 switch (vp->out_fmt->colplanes) {
270 if (vp->out_fmt->color == IMG_FMT_YCBCR422P)
275 if (vp->out_fmt->color == IMG_FMT_YCRCB420)
290 struct camif_vp *vp = priv;
291 struct camif_dev *camif = vp->camif;
298 camif_hw_clear_pending_irq(vp);
300 status = camif_hw_get_status(vp);
303 camif_hw_clear_fifo_overflow(vp);
307 if (vp->state & ST_VP_ABORTING) {
308 if (vp->state & ST_VP_OFF) {
310 vp->state &= ~(ST_VP_OFF | ST_VP_ABORTING |
312 wake_up(&vp->irq_queue);
314 } else if (vp->state & ST_VP_LASTIRQ) {
315 camif_hw_disable_capture(vp);
316 camif_hw_enable_scaler(vp, false);
317 camif_hw_set_lastirq(vp, false);
318 vp->state |= ST_VP_OFF;
321 camif_hw_set_lastirq(vp, true);
322 vp->state |= ST_VP_LASTIRQ;
326 if (!list_empty(&vp->pending_buf_q) && (vp->state & ST_VP_RUNNING) &&
327 !list_empty(&vp->active_buf_q)) {
336 vbuf = camif_active_queue_peek(vp, index);
341 vbuf->vb.sequence = vp->frame_sequence++;
345 vbuf = camif_pending_queue_pop(vp);
347 camif_hw_set_output_addr(vp, &vbuf->paddr, index);
348 camif_hw_set_output_addr(vp, &vbuf->paddr, index + 2);
351 camif_active_queue_add(vp, vbuf);
353 } else if (!(vp->state & ST_VP_ABORTING) &&
354 (vp->state & ST_VP_PENDING)) {
355 vp->state |= ST_VP_RUNNING;
358 if (vp->state & ST_VP_CONFIG) {
359 camif_prepare_dma_offset(vp);
361 camif_hw_set_scaler(vp);
362 camif_hw_set_flip(vp);
367 vp->state &= ~ST_VP_CONFIG;
376 struct camif_vp *vp = vb2_get_drv_priv(vq);
377 struct camif_dev *camif = vp->camif;
391 ret = s3c_camif_hw_init(camif, vp);
393 ret = s3c_camif_hw_vp_init(camif, vp);
398 camif_reinitialize(vp);
403 vp->frame_sequence = 0;
404 vp->state |= ST_VP_PENDING;
406 if (!list_empty(&vp->pending_buf_q) &&
407 (!(vp->state & ST_VP_STREAMING) ||
408 !(vp->state & ST_VP_SENSOR_STREAMING))) {
410 camif_hw_enable_scaler(vp, vp->scaler.enable);
411 camif_hw_enable_capture(vp);
412 vp->state |= ST_VP_STREAMING;
414 if (!(vp->state & ST_VP_SENSOR_STREAMING)) {
415 vp->state |= ST_VP_SENSOR_STREAMING;
419 v4l2_err(&vp->vdev, "Sensor s_stream failed\n");
433 struct camif_vp *vp = vb2_get_drv_priv(vq);
434 camif_stop_capture(vp);
441 struct camif_vp *vp = vb2_get_drv_priv(vq);
442 struct camif_frame *frame = &vp->out_frame;
443 const struct camif_fmt *fmt = vp->out_fmt;
463 struct camif_vp *vp = vb2_get_drv_priv(vb->vb2_queue);
465 if (vp->out_fmt == NULL)
468 if (vb2_plane_size(vb, 0) < vp->payload) {
469 v4l2_err(&vp->vdev, "buffer too small: %lu, required: %u\n",
470 vb2_plane_size(vb, 0), vp->payload);
473 vb2_set_plane_payload(vb, 0, vp->payload);
482 struct camif_vp *vp = vb2_get_drv_priv(vb->vb2_queue);
483 struct camif_dev *camif = vp->camif;
487 WARN_ON(camif_prepare_addr(vp, &buf->vb.vb2_buf, &buf->paddr));
489 if (!(vp->state & ST_VP_STREAMING) && vp->active_buffers < 2) {
491 buf->index = vp->buf_index;
493 camif_hw_set_output_addr(vp, &buf->paddr, buf->index);
494 camif_hw_set_output_addr(vp, &buf->paddr, buf->index + 2);
496 camif_active_queue_add(vp, buf);
497 vp->buf_index = !vp->buf_index;
499 camif_pending_queue_add(vp, buf);
502 if (vb2_is_streaming(&vp->vb_queue) && !list_empty(&vp->pending_buf_q)
503 && !(vp->state & ST_VP_STREAMING)) {
505 vp->state |= ST_VP_STREAMING;
506 camif_hw_enable_scaler(vp, vp->scaler.enable);
507 camif_hw_enable_capture(vp);
510 if (!(vp->state & ST_VP_SENSOR_STREAMING)) {
512 vp->state |= ST_VP_SENSOR_STREAMING;
514 v4l2_err(&vp->vdev, "Sensor s_stream failed\n");
536 struct camif_vp *vp = video_drvdata(file);
537 struct camif_dev *camif = vp->camif;
540 pr_debug("[vp%d] state: %#x, owner: %p, pid: %d\n", vp->id,
541 vp->state, vp->owner, task_pid_nr(current));
568 struct camif_vp *vp = video_drvdata(file);
569 struct camif_dev *camif = vp->camif;
572 pr_debug("[vp%d] state: %#x, owner: %p, pid: %d\n", vp->id,
573 vp->state, vp->owner, task_pid_nr(current));
577 if (vp->owner == file->private_data) {
578 camif_stop_capture(vp);
579 vb2_queue_release(&vp->vb_queue);
580 vp->owner = NULL;
595 struct camif_vp *vp = video_drvdata(file);
596 struct camif_dev *camif = vp->camif;
600 if (vp->owner && vp->owner != file->private_data)
603 ret = vb2_poll(&vp->vb_queue, file, wait);
611 struct camif_vp *vp = video_drvdata(file);
614 if (vp->owner && vp->owner != file->private_data)
617 ret = vb2_mmap(&vp->vb_queue, vma);
638 struct camif_vp *vp = video_drvdata(file);
643 dev_name(vp->camif->dev), vp->id);
650 struct camif_vp *vp = video_drvdata(file);
651 struct v4l2_subdev *sensor = vp->camif->sensor.sd;
677 struct camif_vp *vp = video_drvdata(file);
680 fmt = s3c_camif_find_format(vp, NULL, f->index);
691 struct camif_vp *vp = video_drvdata(file);
693 struct camif_frame *frame = &vp->out_frame;
694 const struct camif_fmt *fmt = vp->out_fmt;
697 pix->sizeimage = vp->payload;
708 static int __camif_video_try_format(struct camif_vp *vp,
712 struct camif_dev *camif = vp->camif;
718 fmt = s3c_camif_find_format(vp, &pix->pixelformat, 0);
726 pix_lim = &camif->variant->vp_pix_limits[vp->id];
762 struct camif_vp *vp = video_drvdata(file);
763 return __camif_video_try_format(vp, &f->fmt.pix, NULL);
770 struct camif_vp *vp = video_drvdata(file);
771 struct camif_frame *out_frame = &vp->out_frame;
775 pr_debug("[vp%d]\n", vp->id);
777 if (vb2_is_busy(&vp->vb_queue))
780 ret = __camif_video_try_format(vp, &f->fmt.pix, &fmt);
784 vp->out_fmt = fmt;
785 vp->payload = pix->sizeimage;
795 if (vp->owner == NULL)
796 vp->owner = priv;
799 out_frame->f_width, out_frame->f_height, vp->payload,
836 struct camif_vp *vp = video_drvdata(file);
837 struct camif_dev *camif = vp->camif;
841 pr_debug("[vp%d]\n", vp->id);
846 if (vp->owner && vp->owner != priv)
849 if (s3c_vp_active(vp))
862 return vb2_streamon(&vp->vb_queue, type);
868 struct camif_vp *vp = video_drvdata(file);
869 struct camif_dev *camif = vp->camif;
872 pr_debug("[vp%d]\n", vp->id);
877 if (vp->owner && vp->owner != priv)
880 ret = vb2_streamoff(&vp->vb_queue, type);
889 struct camif_vp *vp = video_drvdata(file);
892 pr_debug("[vp%d] rb count: %d, owner: %p, priv: %p\n",
893 vp->id, rb->count, vp->owner, priv);
895 if (vp->owner && vp->owner != priv)
901 vp->owner = NULL;
903 ret = vb2_reqbufs(&vp->vb_queue, rb);
909 vb2_reqbufs(&vp->vb_queue, rb);
913 vp->reqbufs_count = rb->count;
914 if (vp->owner == NULL && rb->count > 0)
915 vp->owner = priv;
923 struct camif_vp *vp = video_drvdata(file);
924 return vb2_querybuf(&vp->vb_queue, buf);
930 struct camif_vp *vp = video_drvdata(file);
932 pr_debug("[vp%d]\n", vp->id);
934 if (vp->owner && vp->owner != priv)
937 return vb2_qbuf(&vp->vb_queue, vp->vdev.v4l2_dev->mdev, buf);
943 struct camif_vp *vp = video_drvdata(file);
945 pr_debug("[vp%d] sequence: %d\n", vp->id, vp->frame_sequence);
947 if (vp->owner && vp->owner != priv)
950 return vb2_dqbuf(&vp->vb_queue, buf, file->f_flags & O_NONBLOCK);
956 struct camif_vp *vp = video_drvdata(file);
959 if (vp->owner && vp->owner != priv)
963 ret = vb2_create_bufs(&vp->vb_queue, create);
965 if (!ret && vp->owner == NULL)
966 vp->owner = priv;
974 struct camif_vp *vp = video_drvdata(file);
975 return vb2_prepare_buf(&vp->vb_queue, vp->vdev.v4l2_dev->mdev, b);
981 struct camif_vp *vp = video_drvdata(file);
991 sel->r.width = vp->out_frame.f_width;
992 sel->r.height = vp->out_frame.f_height;
996 sel->r = vp->out_frame.rect;
1003 static void __camif_try_compose(struct camif_dev *camif, struct camif_vp *vp,
1008 *r = vp->out_frame.rect;
1018 struct camif_vp *vp = video_drvdata(file);
1019 struct camif_dev *camif = vp->camif;
1027 __camif_try_compose(camif, vp, &rect);
1031 vp->out_frame.rect = rect;
1032 vp->state |= ST_VP_CONFIG;
1071 struct camif_vp *vp = ctrl->priv;
1072 struct camif_dev *camif = vp->camif;
1075 pr_debug("[vp%d] ctrl: %s, value: %d\n", vp->id,
1082 vp->hflip = ctrl->val;
1086 vp->vflip = ctrl->val;
1090 vp->state |= ST_VP_CONFIG;
1102 struct camif_vp *vp = &camif->vp[idx];
1103 struct vb2_queue *q = &vp->vb_queue;
1104 struct video_device *vfd = &vp->vdev;
1110 vp->id == 0 ? "codec" : "preview");
1118 vp->reqbufs_count = 0;
1120 INIT_LIST_HEAD(&vp->pending_buf_q);
1121 INIT_LIST_HEAD(&vp->active_buf_q);
1129 q->drv_priv = vp;
1131 q->lock = &vp->camif->lock;
1138 vp->pad.flags = MEDIA_PAD_FL_SINK;
1139 ret = media_entity_pads_init(&vfd->entity, 1, &vp->pad);
1143 video_set_drvdata(vfd, vp);
1145 v4l2_ctrl_handler_init(&vp->ctrl_handler, 1);
1146 ctrl = v4l2_ctrl_new_std(&vp->ctrl_handler, &s3c_camif_video_ctrl_ops,
1149 ctrl->priv = vp;
1150 ctrl = v4l2_ctrl_new_std(&vp->ctrl_handler, &s3c_camif_video_ctrl_ops,
1153 ctrl->priv = vp;
1155 ret = vp->ctrl_handler.error;
1159 vfd->ctrl_handler = &vp->ctrl_handler;
1171 v4l2_ctrl_handler_free(&vp->ctrl_handler);
1179 struct video_device *vfd = &camif->vp[idx].vdev;
1299 if (vb2_is_busy(&camif->vp[VP_CODEC].vb_queue) ||
1300 vb2_is_busy(&camif->vp[VP_PREVIEW].vb_queue)) {
1327 struct camif_frame *frame = &camif->vp[i].out_frame;
1420 struct v4l2_rect *or = &camif->vp[i].out_frame.rect;
1457 struct camif_vp *vp = &camif->vp[i];
1458 scaler = vp->scaler;
1459 if (s3c_camif_get_scaler_config(vp, &scaler))
1461 vp->scaler = scaler;
1462 vp->state |= ST_VP_CONFIG;
1522 camif->vp[VP_CODEC].state |= ST_VP_CONFIG;
1523 camif->vp[VP_PREVIEW].state |= ST_VP_CONFIG;
1612 struct camif_vp *vp = &camif->vp[i];
1613 struct camif_frame *f = &vp->out_frame;
1615 vp->camif = camif;
1616 vp->id = i;
1617 vp->offset = camif->variant->vp_offset;
1620 vp->fmt_flags = i ? FMT_FL_S3C24XX_PREVIEW :
1623 vp->fmt_flags = FMT_FL_S3C64XX;
1625 vp->out_fmt = s3c_camif_find_format(vp, NULL, 0);
1626 BUG_ON(vp->out_fmt == NULL);
1635 vp->scaler.enable = 1;
1637 vp->payload = (f->f_width * f->f_height *
1638 vp->out_fmt->depth) / 8;