int fimc_is_video_open(struct fimc_is_video_ctx *vctx, void *device, u32 buf_rdycount, struct fimc_is_video *video, u32 video_type, const struct vb2_ops *vb2_ops, const struct fimc_is_queue_ops *src_qops, const struct fimc_is_queue_ops *dst_qops, const struct vb2_mem_ops *mem_ops) { int ret = 0; struct fimc_is_queue *q_src, *q_dst; BUG_ON(!video); BUG_ON(!vb2_ops); BUG_ON(!mem_ops); q_src = &vctx->q_src; q_dst = &vctx->q_dst; q_src->vbq = NULL; q_dst->vbq = NULL; q_src->qops = src_qops; q_dst->qops = dst_qops; vctx->type = video_type; vctx->device = device; vctx->video = video; vctx->vb2_ops = vb2_ops; vctx->mem_ops = mem_ops; mutex_init(&vctx->lock); switch (video_type) { case FIMC_IS_VIDEO_TYPE_OUTPUT: fimc_is_queue_open(q_src, buf_rdycount); q_src->vbq = kzalloc(sizeof(struct vb2_queue), GFP_KERNEL); queue_init(vctx, q_src->vbq, NULL); break; case FIMC_IS_VIDEO_TYPE_CAPTURE: fimc_is_queue_open(q_dst, buf_rdycount); q_dst->vbq = kzalloc(sizeof(struct vb2_queue), GFP_KERNEL); queue_init(vctx, NULL, q_dst->vbq); break; case FIMC_IS_VIDEO_TYPE_M2M: fimc_is_queue_open(q_src, buf_rdycount); fimc_is_queue_open(q_dst, buf_rdycount); q_src->vbq = kzalloc(sizeof(struct vb2_queue), GFP_KERNEL); q_dst->vbq = kzalloc(sizeof(struct vb2_queue), GFP_KERNEL); queue_init(vctx, q_src->vbq, q_dst->vbq); break; default: merr("invalid type(%d)", vctx, video_type); ret = -EINVAL; break; } return ret; }
int fimc_is_video_open(struct fimc_is_video_ctx *vctx, void *device, u32 buf_rdycount, struct fimc_is_video *video, const struct vb2_ops *vb2_ops, const struct fimc_is_queue_ops *qops) { int ret = 0; struct fimc_is_queue *queue; BUG_ON(!vctx); BUG_ON(!video); BUG_ON(!video->vb2); BUG_ON(!vb2_ops); if (!(vctx->state & BIT(FIMC_IS_VIDEO_CLOSE))) { err("[V%02d] already open(%lX)", video->id, vctx->state); return -EEXIST; } queue = GET_QUEUE(vctx); queue->vbq = NULL; queue->qops = qops; vctx->device = device; vctx->subdev = NULL; vctx->video = video; vctx->vb2_ops = vb2_ops; vctx->mem_ops = video->vb2->ops; mutex_init(&vctx->lock); ret = fimc_is_queue_open(queue, buf_rdycount); if (ret) { err("fimc_is_queue_open is fail(%d)", ret); goto p_err; } queue->vbq = kzalloc(sizeof(struct vb2_queue), GFP_KERNEL); if (!queue->vbq) { err("kzalloc is fail"); ret = -ENOMEM; goto p_err; } ret = queue_init(vctx, queue->vbq, NULL); if (ret) { err("queue_init fail"); kfree(queue->vbq); goto p_err; } vctx->state = BIT(FIMC_IS_VIDEO_OPEN); p_err: return ret; }