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_reqbufs(struct file *file, struct fimc_is_video_ctx *vctx, struct v4l2_requestbuffers *request) { int ret = 0; struct fimc_is_queue *queue; struct fimc_is_framemgr *framemgr; BUG_ON(!vctx); BUG_ON(!request); if (!(vctx->state & (BIT(FIMC_IS_VIDEO_S_FORMAT) | BIT(FIMC_IS_VIDEO_STOP) | BIT(FIMC_IS_VIDEO_S_BUFS)))) { err("[V%02d] invalid reqbufs is requested(%lX)", vctx->video->id, vctx->state); return -EINVAL; } queue = GET_QUEUE(vctx); if (test_bit(FIMC_IS_QUEUE_STREAM_ON, &queue->state)) { err("video is stream on, not applied"); ret = -EINVAL; goto p_err; } ret = CALL_QOPS(queue, request_bufs, GET_DEVICE(vctx), request->count); if (ret) { err("request_bufs is fail(%d)", ret); 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_req = 0; queue->buf_pre = 0; queue->buf_que = 0; queue->buf_com = 0; queue->buf_dqe = 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; } ret = fimc_is_frame_open(framemgr, queue->buf_maxcount); if (ret) { err("[V%02d] fimc_is_frame_open is fail(%d)", vctx->video->id, ret); goto p_err; } } vctx->state = BIT(FIMC_IS_VIDEO_S_BUFS); p_err: return ret; }