static int fimc_is_isp_video_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf) { int ret = 0; struct fimc_is_video_ctx *vctx = file->private_data; struct fimc_is_queue *queue; BUG_ON(!vctx); #ifdef DBG_STREAMING mdbgv_isp("%s(index : %d)\n", vctx, __func__, buf->index); #endif queue = GET_VCTX_QUEUE(vctx, buf); if (!test_bit(FIMC_IS_QUEUE_STREAM_ON, &queue->state)) { merr("stream off state, can NOT qbuf", vctx); ret = -EINVAL; goto p_err; } ret = fimc_is_video_qbuf(file, vctx, buf); if (ret) merr("fimc_is_video_qbuf is fail(%d)", vctx, ret); p_err: return ret; }
static int fimc_is_3a1_stop_streaming(struct vb2_queue *vbq) { int ret = 0; struct fimc_is_video_ctx *vctx = vbq->drv_priv; struct fimc_is_queue *queue; struct fimc_is_device_ischain *device; struct fimc_is_subdev *leader; BUG_ON(!vctx); mdbgv_3a1("%s\n", vctx, __func__); queue = GET_VCTX_QUEUE(vctx, vbq); device = vctx->device; if (!device) { err("device is NULL"); ret = -EINVAL; goto p_err; } leader = &device->group_3ax.leader; ret = fimc_is_queue_stop_streaming(queue, device, leader, vctx); if (ret) merr("fimc_is_queue_stop_streaming is fail(%d)", vctx, ret); p_err: return ret; }
static int fimc_is_isp_video_set_format_mplane(struct file *file, void *fh, struct v4l2_format *format) { int ret = 0; struct fimc_is_video_ctx *vctx = file->private_data; struct fimc_is_queue *queue; struct fimc_is_device_ischain *device; BUG_ON(!vctx); mdbgv_isp("%s\n", vctx, __func__); queue = GET_VCTX_QUEUE(vctx, format); device = vctx->device; ret = fimc_is_video_set_format_mplane(file, vctx, format); if (ret) merr("fimc_is_video_set_format_mplane is fail(%d)", vctx, ret); fimc_is_ischain_isp_s_format(device, queue->framecfg.width, queue->framecfg.height); return ret; }
int fimc_is_video_qbuf(struct file *file, struct fimc_is_video_ctx *vctx, struct v4l2_buffer *buf) { int ret = 0; struct fimc_is_queue *queue; struct vb2_queue *vbq; struct vb2_buffer *vb; BUG_ON(!file); BUG_ON(!vctx); BUG_ON(!buf); buf->flags &= ~V4L2_BUF_FLAG_USE_SYNC; queue = GET_VCTX_QUEUE(vctx, buf); vbq = queue->vbq; if (!vbq) { merr("vbq is NULL", vctx); ret = -EINVAL; goto p_err; } if (vbq->fileio) { merr("file io in progress", vctx); ret = -EBUSY; goto p_err; } if (buf->type != queue->vbq->type) { merr("buf type is invalid(%d != %d)", vctx, buf->type, queue->vbq->type); ret = -EINVAL; goto p_err; } if (buf->index >= vbq->num_buffers) { merr("buffer index%d out of range", vctx, buf->index); ret = -EINVAL; goto p_err; } if (buf->memory != vbq->memory) { merr("invalid memory type%d", vctx, buf->memory); ret = -EINVAL; goto p_err; } vb = vbq->bufs[buf->index]; if (!vb) { merr("vb is NULL", vctx); ret = -EINVAL; goto p_err; } ret = vb2_qbuf(queue->vbq, buf); p_err: return ret; }
int fimc_is_video_dqbuf(struct file *file, struct fimc_is_video_ctx *vctx, struct v4l2_buffer *buf) { int ret = 0; u32 qcount; bool blocking; struct fimc_is_queue *queue; struct fimc_is_framemgr *framemgr; BUG_ON(!file); BUG_ON(!vctx); BUG_ON(!buf); blocking = file->f_flags & O_NONBLOCK; queue = GET_VCTX_QUEUE(vctx, buf); framemgr = &queue->framemgr; if (!queue->vbq) { merr("vbq is NULL", vctx); ret = -EINVAL; goto p_err; } if (buf->type != queue->vbq->type) { merr("buf type is invalid(%d != %d)", vctx, buf->type, queue->vbq->type); ret = -EINVAL; goto p_err; } if (!test_bit(FIMC_IS_QUEUE_STREAM_ON, &queue->state)) { merr("queue is not streamon(%ld)", vctx, queue->state); ret = -EINVAL; goto p_err; } framemgr_e_barrier_irq(framemgr, 0); qcount = framemgr->frame_req_cnt + framemgr->frame_pro_cnt + framemgr->frame_com_cnt; framemgr_x_barrier_irq(framemgr, 0); if (qcount <= 0) { /* HACK : this log is commented until timeout issue fixed */ /* merr("dqbuf can not be executed without qbuf(%d)", vctx, qcount); */ ret = -EINVAL; goto p_err; } ret = vb2_dqbuf(queue->vbq, buf, blocking); p_err: return ret; }
int fimc_is_video_querybuf(struct file *file, struct fimc_is_video_ctx *vctx, struct v4l2_buffer *buf) { int ret = 0; struct fimc_is_queue *queue; queue = GET_VCTX_QUEUE(vctx, buf); ret = vb2_querybuf(queue->vbq, buf); return ret; }
int fimc_is_video_reqbufs(struct file *file, struct fimc_is_video_ctx *vctx, struct v4l2_requestbuffers *request) { int ret = 0; struct fimc_is_framemgr *framemgr; struct fimc_is_queue *queue; BUG_ON(!vctx); BUG_ON(!request); queue = GET_VCTX_QUEUE(vctx, request); if (test_bit(FIMC_IS_QUEUE_STREAM_ON, &queue->state)) { err("video is stream on, not applied"); ret = -EINVAL; goto p_err; } ret = vb2_reqbufs(queue->vbq, request); if (ret) { err("vb2_reqbufs is fail(%d)", ret); goto p_err; } framemgr = &queue->framemgr; queue->buf_maxcount = request->count; if (queue->buf_maxcount == 0) { queue->buf_refcount = 0; clear_bit(FIMC_IS_QUEUE_BUFFER_READY, &queue->state); clear_bit(FIMC_IS_QUEUE_BUFFER_PREPARED, &queue->state); fimc_is_frame_close(framemgr); } else { if (queue->buf_maxcount < queue->buf_rdycount) { err("buffer count is not invalid(%d < %d)", queue->buf_maxcount, queue->buf_rdycount); ret = -EINVAL; goto p_err; } if (!queue->buf_rdycount) set_bit(FIMC_IS_QUEUE_BUFFER_READY, &queue->state); fimc_is_frame_open(framemgr, queue->buf_maxcount); } p_err: return ret; }
int fimc_is_video_set_format_mplane(struct file *file, struct fimc_is_video_ctx *vctx, struct v4l2_format *format) { int ret = 0; struct fimc_is_queue *queue; BUG_ON(!vctx); BUG_ON(!format); queue = GET_VCTX_QUEUE(vctx, format); ret = fimc_is_queue_set_format_mplane(queue, format); mdbgv_vid("set_format(%d x %d)\n", queue->framecfg.width, queue->framecfg.height); return ret; }
static int fimc_is_3a1_queue_setup(struct vb2_queue *vbq, const struct v4l2_format *fmt, unsigned int *num_buffers, unsigned int *num_planes, unsigned int sizes[], void *allocators[]) { int ret = 0; struct fimc_is_video_ctx *vctx = vbq->drv_priv; struct fimc_is_video *video; struct fimc_is_queue *queue; struct fimc_is_core *core; void *alloc_ctx; BUG_ON(!vctx); mdbgv_3a1("%s\n", vctx, __func__); queue = GET_VCTX_QUEUE(vctx, vbq); video = vctx->video; core = video->core; alloc_ctx = core->mem.alloc_ctx; if (*num_buffers < VIDEO_3A1_MIN_BUFFERS) { warn("number of req. buffers is too small(%d->%d)\n", *num_buffers, VIDEO_3A1_MIN_BUFFERS); *num_buffers = VIDEO_3A1_MIN_BUFFERS; } ret = fimc_is_queue_setup(queue, alloc_ctx, num_planes, sizes, allocators); if (ret) merr("fimc_is_queue_setup is fail(%d)", vctx, ret); return ret; }
static int fimc_is_3a1_start_streaming(struct vb2_queue *vbq, unsigned int count) { int ret = 0; struct fimc_is_video_ctx *vctx = vbq->drv_priv; struct fimc_is_queue *queue; struct fimc_is_device_ischain *device; struct fimc_is_subdev *leader; BUG_ON(!vctx); mdbgv_3a1("%s\n", vctx, __func__); queue = GET_VCTX_QUEUE(vctx, vbq); device = vctx->device; leader = &device->group_3ax.leader; ret = fimc_is_queue_start_streaming(queue, device, leader, vctx); if (ret) merr("fimc_is_queue_start_streaming is fail(%d)", vctx, ret); return ret; }