static void unicam_videobuf_queue(struct vb2_buffer *vb) { struct soc_camera_device *icd = soc_camera_from_vb2q(vb->vb2_queue); struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); struct unicam_camera_dev *unicam_dev = ici->priv; struct unicam_camera_buffer *buf = to_unicam_camera_vb(vb); unsigned long flags; dprintk("-enter"); dprintk("vb=0x%p vbuf=0x%p pbuf=0x%p size=%lu", vb, vb2_plane_vaddr(vb, 0), (void *)vb2_dma_contig_plane_dma_addr(vb, 0), vb2_get_plane_payload(vb, 0)); spin_lock_irqsave(&unicam_dev->lock, flags); list_add_tail(&buf->queue, &unicam_dev->capture); if (!unicam_dev->active) { unicam_dev->active = vb; /* use this buffer to trigger capture */ /* Configure HW only is streamon has been done * else only update active, HW would be configured * by streamon */ if(unicam_dev->streaming){ unicam_camera_update_buf(unicam_dev); if (unicam_dev->if_params.if_mode == V4L2_SUBDEV_SENSOR_MODE_SERIAL_CSI2) unicam_camera_capture(unicam_dev); } } spin_unlock_irqrestore(&unicam_dev->lock, flags); dprintk("-exit"); }
static int unicam_videobuf_init(struct vb2_buffer *vb) { struct unicam_camera_buffer *buf = to_unicam_camera_vb(vb); INIT_LIST_HEAD(&buf->queue); buf->magic = UNICAM_BUF_MAGIC; return 0; }
static int unicam_videobuf_init(struct vb2_buffer *vb) { struct soc_camera_device *icd = soc_camera_from_vb2q(vb->vb2_queue); struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); struct unicam_camera_dev *unicam_dev = ici->priv; struct unicam_camera_buffer *buf = to_unicam_camera_vb(vb); unsigned long flags; spin_lock_irqsave(&unicam_dev->lock, flags); INIT_LIST_HEAD(&buf->queue); spin_unlock_irqrestore(&unicam_dev->lock, flags); buf->magic = UNICAM_BUF_MAGIC; return 0; }
static void unicam_videobuf_queue(struct vb2_buffer *vb) { struct soc_camera_device *icd = soc_camera_from_vb2q(vb->vb2_queue); struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); struct unicam_camera_dev *unicam_dev = ici->priv; struct unicam_camera_buffer *buf = to_unicam_camera_vb(vb); unsigned long flags; struct int_desc idesc; pr_debug("-enter"); pr_debug("vb=0x%p pbuf=0x%p size=%lu", vb, (void *)vb2_plane_dma_addr(vb, 0), vb2_get_plane_payload(vb, 0)); /* pr_info("Q 0x%x\n", vb2_plane_paddr(vb, 0)); */ spin_lock_irqsave(&unicam_dev->lock, flags); list_add_tail(&buf->queue, &unicam_dev->capture); if(unicam_dev->cap_mode && unicam_dev->cap_done){ pr_info("Cap mode and already captured\n"); spin_unlock_irqrestore(&unicam_dev->lock, flags); return; } if ((!unicam_dev->active)) { unicam_dev->active = vb; unicam_camera_update_buf(unicam_dev); if (atomic_read(&unicam_dev->streaming)) { mm_csi0_start_rx(); /* set data capture */ if (unicam_dev->if_params.if_mode == V4L2_SUBDEV_SENSOR_MODE_SERIAL_CSI2) { idesc.fsi = 1; idesc.fei = 1; idesc.lci = 0; idesc.die = 1; idesc.dataline = 2; mm_csi0_config_int(&idesc, IMAGE_BUFFER); mm_csi0_config_int(&idesc, DATA_BUFFER); unicam_camera_capture(unicam_dev); } else { idesc.fsi = 0; idesc.fei = 0; idesc.lci = unicam_dev->icd->user_height; idesc.die = 0; idesc.dataline = 0; mm_csi0_config_int(&idesc, IMAGE_BUFFER); } } } spin_unlock_irqrestore(&unicam_dev->lock, flags); pr_debug("-exit"); }
static void unicam_videobuf_release(struct vb2_buffer *vb) { struct soc_camera_device *icd = soc_camera_from_vb2q(vb->vb2_queue); struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); struct unicam_camera_dev *unicam_dev = ici->priv; struct unicam_camera_buffer *buf = to_unicam_camera_vb(vb); unsigned long flags; pr_debug("-enter"); pr_debug("vb=0x%p pbuf=0x%p size=%lu", vb, (void *)vb2_plane_dma_addr(vb, 0), vb2_get_plane_payload(vb, 0)); spin_lock_irqsave(&unicam_dev->lock, flags); if (buf->magic == UNICAM_BUF_MAGIC) list_del_init(&buf->queue); spin_unlock_irqrestore(&unicam_dev->lock, flags); pr_debug("-exit"); }
static irqreturn_t unicam_camera_isr(int irq, void *arg) { struct unicam_camera_dev *unicam_dev = (struct unicam_camera_dev *)arg; #if 1 struct v4l2_subdev *sd = soc_camera_to_subdev(unicam_dev->icd); #endif int ret; struct int_desc idesc; struct rx_stat_list rx; u32 isr_status, raw_stat; static unsigned int t1 = 0, t2 = 0, fps = 0; struct buffer_desc im0; dma_addr_t dma_addr; unsigned long flags; /* has the interrupt occured for Channel 0? */ memset(&rx, 0x00, sizeof(struct rx_stat_list)); raw_stat = mm_csi0_get_rx_stat(&rx, 1); if (atomic_read(&unicam_dev->streaming) == 0) { memset(&idesc, 0x00, sizeof(struct int_desc)); isr_status = mm_csi0_get_int_stat(&idesc, 1); pr_err("ISR triggered after stop stat=0x%x istat=0x%x\n", raw_stat, isr_status); goto out; } else if (rx.is) { memset(&idesc, 0x00, sizeof(struct int_desc)); isr_status = mm_csi0_get_int_stat(&idesc, 1); if (idesc.fsi) { if (rx.ps) pr_info("Panic at frame start\n"); } if (idesc.fei || idesc.lci){ struct vb2_buffer *vb = unicam_dev->active; /* FS and FE handling */ if (rx.ps) pr_info("Panic at frame or lineend\n"); fps++; if (t1 == 0 && t2 == 0) t1 = t2 = jiffies_to_msecs(jiffies); t2 = jiffies_to_msecs(jiffies); if (t2 - t1 > 1000) { pr_info(" sensor fps = %d panic count %d\n", fps, unicam_dev->panic_count); fps = 0; t1 = t2; } atomic_set(&unicam_dev->cam_triggered, 0); /*atomic_set(&unicam_dev->retry_count, 0); del_timer(&(unicam_dev->unicam_timer));*/ pr_debug("frame received"); if (!vb) { pr_err("%s: vb is not active\n",__func__); goto out; } if (unicam_dev->skip_frames <= 0) { struct v4l2_control ctrl; int ret = -1; ctrl.value = 0; ctrl.id = V4L2_CID_CAMERA_READ_MODE_CHANGE_REG; ret = v4l2_subdev_call(sd, core, g_ctrl, &ctrl); if ((ret >= 0) && (ctrl.value > 0)) { /* capture mode is not ready yet */ unicam_dev->skip_frames = ctrl.value; pr_info("%s: sensor mode change in process ,need_skip_frame=%d\n", __func__, ctrl.value); } } if (likely(unicam_dev->skip_frames <= 0)) { spin_lock_irqsave(&unicam_dev->lock, flags); list_del_init(&to_unicam_camera_vb(vb)->queue); spin_unlock_irqrestore(&unicam_dev->lock, flags); do_gettimeofday(&vb->v4l2_buf.timestamp); vb->v4l2_planes[0].bytesused = 0; if (unicam_dev->icd->current_fmt->code == V4L2_MBUS_FMT_JPEG_1X8) { } else { ret = 1; } vb2_buffer_done(vb, VB2_BUF_STATE_DONE); spin_lock_irqsave(&unicam_dev->lock, flags); if (atomic_read(&unicam_dev->stopping) == 1) { up(&unicam_dev->stop_sem); unicam_dev->active = NULL; } else if (!list_empty(&unicam_dev->capture)) { unicam_dev->active = &list_entry(unicam_dev-> capture.next, struct unicam_camera_buffer, queue)->vb; } else {
static irqreturn_t unicam_camera_isr(int irq, void *arg) { struct unicam_camera_dev *unicam_dev = (struct unicam_camera_dev *)arg; unsigned int status; unsigned int reg_status; int ret; CSL_CAM_BUFFER_STATUS_st_t bufStatus; unsigned int bytes_used; unsigned long flags; static unsigned int t1 = 0, t2 = 0, fps = 0; spin_lock_irqsave(&unicam_dev->lock, flags); if (!unicam_dev->streaming) { pr_err("Interrupt triggered after stopping camera!\n"); spin_unlock_irqrestore(&unicam_dev->lock, flags); return IRQ_HANDLED; } else { spin_unlock_irqrestore(&unicam_dev->lock, flags); } /* has the interrupt occured for Channel 0? */ reg_status = csl_cam_get_rx_status(unicam_dev->cslCamHandle, (CSL_CAM_RX_STATUS_t *) &status); dprintk("received unicam interrupt reg_status=0x%x status=0x%x\n", reg_status, status); if (status & CSL_CAM_RX_INT) { /* get and clear interrupt status */ reg_status = csl_cam_get_intr_status(unicam_dev->cslCamHandle, (CSL_CAM_INTERRUPT_t *) &status); if (status & CSL_CAM_INT_FRAME_START) { status = status & ~CSL_CAM_INT_FRAME_START; if (reg_status & 0x2000) pr_err("Camera: Urgent request was signalled at FS!!!\n"); } if ((status & CSL_CAM_INT_FRAME_END) || (status & CSL_CAM_INT_LINE_COUNT)) { struct vb2_buffer *vb = unicam_dev->active; status &= ~(CSL_CAM_INT_FRAME_END | CSL_CAM_INT_LINE_COUNT); fps++; if (reg_status & 0x2000) pr_err("Camera: Urgent request was signalled at FE!!!!\n"); if (t1 == 0 && t2 == 0) t1 = t2 = jiffies_to_msecs(jiffies); t2 = jiffies_to_msecs(jiffies); if (t2 - t1 > 1000) { printk(" sensor fps = %d \n", fps); fps = 0; t1 = t2; } dprintk("frame received"); /* csl_cam_register_display(unicam_dev->cslCamHandle);*/ if (!vb) goto out; /* mark the buffer done */ /* queue another buffer and trigger capture */ if (likely(unicam_dev->skip_frames <= 0)) { spin_lock_irqsave(&unicam_dev->lock, flags); list_del_init(&to_unicam_camera_vb(vb)->queue); spin_unlock_irqrestore(&unicam_dev->lock, flags); do_gettimeofday(&vb->v4l2_buf.timestamp); vb->v4l2_planes[0].bytesused = 0; if (unicam_dev->icd->current_fmt->code == V4L2_MBUS_FMT_JPEG_1X8) { ret = csl_cam_get_buffer_status (unicam_dev->cslCamHandle, CSL_CAM_DATA, &bufStatus); if (ret == CSL_CAM_OK) { bytes_used = (bufStatus.write_ptr - bufStatus.buffer_st. start_addr); vb->v4l2_planes[0].bytesused = bytes_used; } else dev_warn(unicam_dev->dev, "%s:failed to get buffer status", __func__); } else { ret = csl_cam_get_buffer_status (unicam_dev->cslCamHandle, CSL_CAM_IMAGE, &bufStatus); if (ret == CSL_CAM_OK) { dprintk("Buffer Status:"); dprintk("addr:0x%x size:0x%x" "ls:%d wp:0x%x" "ppl:%d lpf:%d", bufStatus.buffer_st. start_addr, bufStatus.buffer_st. size, bufStatus.buffer_st. line_stride, bufStatus.write_ptr, bufStatus. bytes_per_line, bufStatus. lines_per_frame); } } vb2_buffer_done(vb, VB2_BUF_STATE_DONE); spin_lock_irqsave(&unicam_dev->lock, flags); if (unicam_dev->stopping) { up(&unicam_dev->stop_sem); unicam_dev->active = NULL; } else if (!list_empty(&unicam_dev->capture)) { unicam_dev->active = &list_entry(unicam_dev-> capture.next, struct unicam_camera_buffer, queue)->vb; } else {