Lines Matching full:vcap
169 struct dcmipp_bytecap_device *vcap = video_drvdata(file); in dcmipp_bytecap_g_fmt_vid_cap() local
171 f->fmt.pix = vcap->format; in dcmipp_bytecap_g_fmt_vid_cap()
179 struct dcmipp_bytecap_device *vcap = video_drvdata(file); in dcmipp_bytecap_try_fmt_vid_cap() local
197 dev_dbg(vcap->dev, "resolution updated: %dx%d -> %dx%d\n", in dcmipp_bytecap_try_fmt_vid_cap()
219 struct dcmipp_bytecap_device *vcap = video_drvdata(file); in dcmipp_bytecap_s_fmt_vid_cap() local
223 if (vb2_is_busy(&vcap->queue)) in dcmipp_bytecap_s_fmt_vid_cap()
230 …dev_dbg(vcap->dev, "%s: format update: old:%ux%u (0x%p4cc, %u, %u, %u, %u) new:%ux%d (0x%p4cc, %u,… in dcmipp_bytecap_s_fmt_vid_cap()
231 vcap->vdev.name, in dcmipp_bytecap_s_fmt_vid_cap()
233 vcap->format.width, vcap->format.height, in dcmipp_bytecap_s_fmt_vid_cap()
234 &vcap->format.pixelformat, vcap->format.colorspace, in dcmipp_bytecap_s_fmt_vid_cap()
235 vcap->format.quantization, vcap->format.xfer_func, in dcmipp_bytecap_s_fmt_vid_cap()
236 vcap->format.ycbcr_enc, in dcmipp_bytecap_s_fmt_vid_cap()
243 vcap->format = f->fmt.pix; in dcmipp_bytecap_s_fmt_vid_cap()
340 static int dcmipp_pipeline_s_stream(struct dcmipp_bytecap_device *vcap, in dcmipp_pipeline_s_stream() argument
350 if (!vcap->s_subdev) { in dcmipp_pipeline_s_stream()
351 pad = media_pad_remote_pad_first(&vcap->vdev.entity.pads[0]); in dcmipp_pipeline_s_stream()
354 vcap->s_subdev = media_entity_to_v4l2_subdev(pad->entity); in dcmipp_pipeline_s_stream()
357 ret = v4l2_subdev_call(vcap->s_subdev, video, s_stream, state); in dcmipp_pipeline_s_stream()
359 dev_err(vcap->dev, "failed to %s streaming (%d)\n", in dcmipp_pipeline_s_stream()
367 static void dcmipp_start_capture(struct dcmipp_bytecap_device *vcap, in dcmipp_start_capture() argument
371 reg_write(vcap, DCMIPP_P0PPM0AR1, buf->addr); in dcmipp_start_capture()
374 reg_write(vcap, DCMIPP_P0DCLMTR, DCMIPP_P0DCLMTR_ENABLE | in dcmipp_start_capture()
378 reg_set(vcap, DCMIPP_P0FCTCR, DCMIPP_P0FCTCR_CPTREQ); in dcmipp_start_capture()
381 static void dcmipp_bytecap_all_buffers_done(struct dcmipp_bytecap_device *vcap, in dcmipp_bytecap_all_buffers_done() argument
386 list_for_each_entry_safe(buf, node, &vcap->buffers, list) { in dcmipp_bytecap_all_buffers_done()
395 struct dcmipp_bytecap_device *vcap = vb2_get_drv_priv(vq); in dcmipp_bytecap_start_streaming() local
396 struct media_entity *entity = &vcap->vdev.entity; in dcmipp_bytecap_start_streaming()
400 vcap->sequence = 0; in dcmipp_bytecap_start_streaming()
401 memset(&vcap->count, 0, sizeof(vcap->count)); in dcmipp_bytecap_start_streaming()
403 ret = pm_runtime_resume_and_get(vcap->dev); in dcmipp_bytecap_start_streaming()
405 dev_err(vcap->dev, "%s: Failed to start streaming, cannot get sync (%d)\n", in dcmipp_bytecap_start_streaming()
410 ret = media_pipeline_start(entity->pads, &vcap->pipe); in dcmipp_bytecap_start_streaming()
412 dev_dbg(vcap->dev, "%s: Failed to start streaming, media pipeline start error (%d)\n", in dcmipp_bytecap_start_streaming()
417 ret = dcmipp_pipeline_s_stream(vcap, 1); in dcmipp_bytecap_start_streaming()
421 spin_lock_irq(&vcap->irqlock); in dcmipp_bytecap_start_streaming()
424 reg_set(vcap, DCMIPP_P0FSCR, DCMIPP_P0FSCR_PIPEN); in dcmipp_bytecap_start_streaming()
430 vcap->next = list_first_entry(&vcap->buffers, typeof(*buf), list); in dcmipp_bytecap_start_streaming()
431 dev_dbg(vcap->dev, "Start with next [%d] %p phy=%pad\n", in dcmipp_bytecap_start_streaming()
432 vcap->next->vb.vb2_buf.index, vcap->next, &vcap->next->addr); in dcmipp_bytecap_start_streaming()
434 dcmipp_start_capture(vcap, vcap->next); in dcmipp_bytecap_start_streaming()
437 vcap->cmier |= DCMIPP_CMIER_P0ALL; in dcmipp_bytecap_start_streaming()
438 reg_set(vcap, DCMIPP_CMIER, vcap->cmier); in dcmipp_bytecap_start_streaming()
440 vcap->state = DCMIPP_RUNNING; in dcmipp_bytecap_start_streaming()
442 spin_unlock_irq(&vcap->irqlock); in dcmipp_bytecap_start_streaming()
449 pm_runtime_put(vcap->dev); in dcmipp_bytecap_start_streaming()
451 spin_lock_irq(&vcap->irqlock); in dcmipp_bytecap_start_streaming()
456 dcmipp_bytecap_all_buffers_done(vcap, VB2_BUF_STATE_QUEUED); in dcmipp_bytecap_start_streaming()
457 vcap->active = NULL; in dcmipp_bytecap_start_streaming()
458 spin_unlock_irq(&vcap->irqlock); in dcmipp_bytecap_start_streaming()
463 static void dcmipp_dump_status(struct dcmipp_bytecap_device *vcap) in dcmipp_dump_status() argument
465 struct device *dev = vcap->dev; in dcmipp_dump_status()
467 dev_dbg(dev, "[DCMIPP_PRSR] =%#10.8x\n", reg_read(vcap, DCMIPP_PRSR)); in dcmipp_dump_status()
468 dev_dbg(dev, "[DCMIPP_P0SR] =%#10.8x\n", reg_read(vcap, DCMIPP_P0SR)); in dcmipp_dump_status()
470 reg_read(vcap, DCMIPP_P0DCCNTR)); in dcmipp_dump_status()
471 dev_dbg(dev, "[DCMIPP_CMSR1] =%#10.8x\n", reg_read(vcap, DCMIPP_CMSR1)); in dcmipp_dump_status()
472 dev_dbg(dev, "[DCMIPP_CMSR2] =%#10.8x\n", reg_read(vcap, DCMIPP_CMSR2)); in dcmipp_dump_status()
481 struct dcmipp_bytecap_device *vcap = vb2_get_drv_priv(vq); in dcmipp_bytecap_stop_streaming() local
485 dcmipp_pipeline_s_stream(vcap, 0); in dcmipp_bytecap_stop_streaming()
488 media_pipeline_stop(vcap->vdev.entity.pads); in dcmipp_bytecap_stop_streaming()
491 reg_clear(vcap, DCMIPP_CMIER, vcap->cmier); in dcmipp_bytecap_stop_streaming()
494 reg_clear(vcap, DCMIPP_P0FCTCR, DCMIPP_P0FCTCR_CPTREQ); in dcmipp_bytecap_stop_streaming()
497 ret = readl_relaxed_poll_timeout(vcap->regs + DCMIPP_P0SR, status, in dcmipp_bytecap_stop_streaming()
502 dev_warn(vcap->dev, "Timeout when stopping\n"); in dcmipp_bytecap_stop_streaming()
505 reg_clear(vcap, DCMIPP_P0FSCR, DCMIPP_P0FSCR_PIPEN); in dcmipp_bytecap_stop_streaming()
507 spin_lock_irq(&vcap->irqlock); in dcmipp_bytecap_stop_streaming()
510 dcmipp_bytecap_all_buffers_done(vcap, VB2_BUF_STATE_ERROR); in dcmipp_bytecap_stop_streaming()
511 INIT_LIST_HEAD(&vcap->buffers); in dcmipp_bytecap_stop_streaming()
513 vcap->active = NULL; in dcmipp_bytecap_stop_streaming()
514 vcap->state = DCMIPP_STOPPED; in dcmipp_bytecap_stop_streaming()
516 spin_unlock_irq(&vcap->irqlock); in dcmipp_bytecap_stop_streaming()
518 dcmipp_dump_status(vcap); in dcmipp_bytecap_stop_streaming()
520 pm_runtime_put(vcap->dev); in dcmipp_bytecap_stop_streaming()
522 if (vcap->count.errors) in dcmipp_bytecap_stop_streaming()
523 …dev_warn(vcap->dev, "Some errors found while streaming: errors=%d (overrun=%d, limit=%d, nactive=%… in dcmipp_bytecap_stop_streaming()
524 vcap->count.errors, vcap->count.overrun, in dcmipp_bytecap_stop_streaming()
525 vcap->count.limit, vcap->count.nactive, in dcmipp_bytecap_stop_streaming()
526 vcap->count.underrun, vcap->count.buffers); in dcmipp_bytecap_stop_streaming()
531 struct dcmipp_bytecap_device *vcap = vb2_get_drv_priv(vb->vb2_queue); in dcmipp_bytecap_buf_prepare() local
536 size = vcap->format.sizeimage; in dcmipp_bytecap_buf_prepare()
539 dev_err(vcap->dev, "%s data will not fit into plane (%lu < %lu)\n", in dcmipp_bytecap_buf_prepare()
554 dev_dbg(vcap->dev, "Setup [%d] phy=%pad size=%zu\n", in dcmipp_bytecap_buf_prepare()
563 struct dcmipp_bytecap_device *vcap = in dcmipp_bytecap_buf_queue() local
568 dev_dbg(vcap->dev, "Queue [%d] %p phy=%pad\n", buf->vb.vb2_buf.index, in dcmipp_bytecap_buf_queue()
571 spin_lock_irq(&vcap->irqlock); in dcmipp_bytecap_buf_queue()
572 list_add_tail(&buf->list, &vcap->buffers); in dcmipp_bytecap_buf_queue()
574 if (vcap->state == DCMIPP_WAIT_FOR_BUFFER) { in dcmipp_bytecap_buf_queue()
575 vcap->next = buf; in dcmipp_bytecap_buf_queue()
576 dev_dbg(vcap->dev, "Restart with next [%d] %p phy=%pad\n", in dcmipp_bytecap_buf_queue()
579 dcmipp_start_capture(vcap, buf); in dcmipp_bytecap_buf_queue()
581 vcap->state = DCMIPP_RUNNING; in dcmipp_bytecap_buf_queue()
584 spin_unlock_irq(&vcap->irqlock); in dcmipp_bytecap_buf_queue()
593 struct dcmipp_bytecap_device *vcap = vb2_get_drv_priv(vq); in dcmipp_bytecap_queue_setup() local
596 size = vcap->format.sizeimage; in dcmipp_bytecap_queue_setup()
600 return sizes[0] < vcap->format.sizeimage ? -EINVAL : 0; in dcmipp_bytecap_queue_setup()
603 sizes[0] = vcap->format.sizeimage; in dcmipp_bytecap_queue_setup()
605 dev_dbg(vcap->dev, "Setup queue, count=%d, size=%d\n", in dcmipp_bytecap_queue_setup()
638 struct dcmipp_bytecap_device *vcap = in dcmipp_bytecap_release() local
641 dcmipp_pads_cleanup(vcap->ved.pads); in dcmipp_bytecap_release()
642 mutex_destroy(&vcap->lock); in dcmipp_bytecap_release()
644 kfree(vcap); in dcmipp_bytecap_release()
649 struct dcmipp_bytecap_device *vcap = in dcmipp_bytecap_ent_release() local
653 vb2_video_unregister_device(&vcap->vdev); in dcmipp_bytecap_ent_release()
656 static void dcmipp_buffer_done(struct dcmipp_bytecap_device *vcap, in dcmipp_buffer_done() argument
667 vbuf->sequence = vcap->sequence++; in dcmipp_buffer_done()
673 dev_dbg(vcap->dev, "Done [%d] %p phy=%pad\n", buf->vb.vb2_buf.index, in dcmipp_buffer_done()
675 vcap->count.buffers++; in dcmipp_buffer_done()
680 dcmipp_bytecap_set_next_frame_or_stop(struct dcmipp_bytecap_device *vcap) in dcmipp_bytecap_set_next_frame_or_stop() argument
682 if (!vcap->next && list_is_singular(&vcap->buffers)) { in dcmipp_bytecap_set_next_frame_or_stop()
689 reg_clear(vcap, DCMIPP_P0FCTCR, DCMIPP_P0FCTCR_CPTREQ); in dcmipp_bytecap_set_next_frame_or_stop()
691 dev_dbg(vcap->dev, "Capture restart is deferred to next buffer queueing\n"); in dcmipp_bytecap_set_next_frame_or_stop()
692 vcap->next = NULL; in dcmipp_bytecap_set_next_frame_or_stop()
693 vcap->state = DCMIPP_WAIT_FOR_BUFFER; in dcmipp_bytecap_set_next_frame_or_stop()
698 if (!vcap->next) in dcmipp_bytecap_set_next_frame_or_stop()
699 vcap->next = list_next_entry(vcap->active, list); in dcmipp_bytecap_set_next_frame_or_stop()
706 reg_write(vcap, DCMIPP_P0PPM0AR1, vcap->next->addr); in dcmipp_bytecap_set_next_frame_or_stop()
707 dev_dbg(vcap->dev, "Write [%d] %p phy=%pad\n", in dcmipp_bytecap_set_next_frame_or_stop()
708 vcap->next->vb.vb2_buf.index, vcap->next, &vcap->next->addr); in dcmipp_bytecap_set_next_frame_or_stop()
712 static void dcmipp_bytecap_process_frame(struct dcmipp_bytecap_device *vcap, in dcmipp_bytecap_process_frame() argument
716 struct dcmipp_buf *buf = vcap->active; in dcmipp_bytecap_process_frame()
719 vcap->count.nactive++; in dcmipp_bytecap_process_frame()
720 vcap->count.errors++; in dcmipp_bytecap_process_frame()
725 dev_dbg(vcap->dev, "frame larger than expected (%zu > %zu)\n", in dcmipp_bytecap_process_frame()
729 vcap->count.limit++; in dcmipp_bytecap_process_frame()
730 vcap->count.errors++; in dcmipp_bytecap_process_frame()
734 dcmipp_buffer_done(vcap, buf, bytesused, err); in dcmipp_bytecap_process_frame()
735 vcap->active = NULL; in dcmipp_bytecap_process_frame()
740 struct dcmipp_bytecap_device *vcap = in dcmipp_bytecap_irq_thread() local
745 spin_lock_irq(&vcap->irqlock); in dcmipp_bytecap_irq_thread()
747 cmsr2 = vcap->cmsr2 & vcap->cmier; in dcmipp_bytecap_irq_thread()
755 vcap->count.errors++; in dcmipp_bytecap_irq_thread()
756 vcap->count.overrun++; in dcmipp_bytecap_irq_thread()
760 vcap->count.frame++; in dcmipp_bytecap_irq_thread()
763 bytesused = reg_read(vcap, DCMIPP_P0DCCNTR); in dcmipp_bytecap_irq_thread()
764 dcmipp_bytecap_process_frame(vcap, bytesused); in dcmipp_bytecap_irq_thread()
768 vcap->count.vsync++; in dcmipp_bytecap_irq_thread()
769 if (vcap->state == DCMIPP_WAIT_FOR_BUFFER) { in dcmipp_bytecap_irq_thread()
770 vcap->count.underrun++; in dcmipp_bytecap_irq_thread()
783 swap(vcap->active, vcap->next); in dcmipp_bytecap_irq_thread()
784 dcmipp_bytecap_set_next_frame_or_stop(vcap); in dcmipp_bytecap_irq_thread()
788 spin_unlock_irq(&vcap->irqlock); in dcmipp_bytecap_irq_thread()
794 struct dcmipp_bytecap_device *vcap = in dcmipp_bytecap_irq_callback() local
798 vcap->cmsr2 = reg_read(vcap, DCMIPP_CMSR2) & vcap->cmier; in dcmipp_bytecap_irq_callback()
799 vcap->count.it++; in dcmipp_bytecap_irq_callback()
802 reg_write(vcap, DCMIPP_CMFCR, vcap->cmsr2); in dcmipp_bytecap_irq_callback()
811 struct dcmipp_bytecap_device *vcap = container_of(vd, in dcmipp_bytecap_link_validate() local
826 if (source_fmt.format.width != vcap->format.width || in dcmipp_bytecap_link_validate()
827 source_fmt.format.height != vcap->format.height) { in dcmipp_bytecap_link_validate()
828 dev_err(vcap->dev, "Wrong width or height %ux%u (%ux%u expected)\n", in dcmipp_bytecap_link_validate()
829 vcap->format.width, vcap->format.height, in dcmipp_bytecap_link_validate()
834 vpix = dcmipp_bytecap_pix_map_by_pixelformat(vcap->format.pixelformat); in dcmipp_bytecap_link_validate()
836 dev_err(vcap->dev, "Wrong mbus_code 0x%x, (0x%x expected)\n", in dcmipp_bytecap_link_validate()
853 struct dcmipp_bytecap_device *vcap; in dcmipp_bytecap_ent_init() local
860 vcap = kzalloc(sizeof(*vcap), GFP_KERNEL); in dcmipp_bytecap_ent_init()
861 if (!vcap) in dcmipp_bytecap_ent_init()
865 vcap->ved.pads = dcmipp_pads_init(1, &pad_flag); in dcmipp_bytecap_ent_init()
866 if (IS_ERR(vcap->ved.pads)) { in dcmipp_bytecap_ent_init()
867 ret = PTR_ERR(vcap->ved.pads); in dcmipp_bytecap_ent_init()
872 vcap->vdev.entity.name = entity_name; in dcmipp_bytecap_ent_init()
873 vcap->vdev.entity.function = MEDIA_ENT_F_IO_V4L; in dcmipp_bytecap_ent_init()
874 vcap->vdev.entity.ops = &dcmipp_bytecap_entity_ops; in dcmipp_bytecap_ent_init()
875 ret = media_entity_pads_init(&vcap->vdev.entity, 1, vcap->ved.pads); in dcmipp_bytecap_ent_init()
880 mutex_init(&vcap->lock); in dcmipp_bytecap_ent_init()
883 q = &vcap->queue; in dcmipp_bytecap_ent_init()
886 q->lock = &vcap->lock; in dcmipp_bytecap_ent_init()
887 q->drv_priv = vcap; in dcmipp_bytecap_ent_init()
910 INIT_LIST_HEAD(&vcap->buffers); in dcmipp_bytecap_ent_init()
911 spin_lock_init(&vcap->irqlock); in dcmipp_bytecap_ent_init()
914 vcap->format = fmt_default; in dcmipp_bytecap_ent_init()
917 vcap->ved.ent = &vcap->vdev.entity; in dcmipp_bytecap_ent_init()
918 vcap->ved.handler = dcmipp_bytecap_irq_callback; in dcmipp_bytecap_ent_init()
919 vcap->ved.thread_fn = dcmipp_bytecap_irq_thread; in dcmipp_bytecap_ent_init()
920 vcap->dev = dev; in dcmipp_bytecap_ent_init()
921 vcap->regs = regs; in dcmipp_bytecap_ent_init()
924 vdev = &vcap->vdev; in dcmipp_bytecap_ent_init()
930 vdev->lock = &vcap->lock; in dcmipp_bytecap_ent_init()
934 video_set_drvdata(vdev, &vcap->ved); in dcmipp_bytecap_ent_init()
940 vcap->vdev.name, ret); in dcmipp_bytecap_ent_init()
944 return &vcap->ved; in dcmipp_bytecap_ent_init()
947 media_entity_cleanup(&vcap->vdev.entity); in dcmipp_bytecap_ent_init()
949 mutex_destroy(&vcap->lock); in dcmipp_bytecap_ent_init()
951 dcmipp_pads_cleanup(vcap->ved.pads); in dcmipp_bytecap_ent_init()
953 kfree(vcap); in dcmipp_bytecap_ent_init()