static int gsc_capture_queue_setup(struct vb2_queue *vq,
			const struct v4l2_format *fmt, unsigned int *num_buffers,
			unsigned int *num_planes, unsigned int sizes[],
			void *allocators[])
{
	struct gsc_ctx *ctx = vq->drv_priv;
	struct gsc_fmt *ffmt = ctx->d_frame.fmt;
	int i, ret = 0;

	if (!ffmt)
		return -EINVAL;

	*num_planes = ffmt->num_planes;

	for (i = 0; i < ffmt->num_planes; i++) {
		sizes[i] = get_plane_size(&ctx->d_frame, i);
		allocators[i] = ctx->gsc_dev->alloc_ctx;
	}

	ret = vb2_queue_init(vq);
	if (ret) {
		gsc_err("failed to init vb2_queue");
		return ret;
	}

	return 0;
}
Exemplo n.º 2
0
static int queue_setup(struct vb2_queue *vq,  const struct v4l2_format *pfmt,
		       unsigned int *num_buffers, unsigned int *num_planes,
		       unsigned int sizes[], void *allocators[])
{
	struct fimc_ctx *ctx = vq->drv_priv;
	struct fimc_fmt *fmt = ctx->d_frame.fmt;
	int i;

	if (!fmt)
		return -EINVAL;

	*num_planes = fmt->memplanes;

	for (i = 0; i < fmt->memplanes; i++) {
		sizes[i] = get_plane_size(&ctx->d_frame, i);
		allocators[i] = ctx->fimc_dev->alloc_ctx;
	}

	return 0;
}
Exemplo n.º 3
0
static int gsc_m2m_queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt,
				unsigned int *num_buffers, unsigned int *num_planes,
				unsigned int sizes[], void *allocators[])
{
	struct gsc_ctx *ctx = vb2_get_drv_priv(vq);
	struct gsc_frame *frame;
	int i;

	frame = ctx_get_frame(ctx, vq->type);
	if (IS_ERR(frame))
		return PTR_ERR(frame);

	if (!frame->fmt)
		return -EINVAL;

	*num_planes = frame->fmt->num_planes;
	for (i = 0; i < frame->fmt->num_planes; i++) {
		sizes[i] = get_plane_size(frame, i);
		allocators[i] = ctx->gsc_dev->alloc_ctx;
	}
	return 0;
}
Exemplo n.º 4
0
static int buffer_prepare(struct vb2_buffer *vb)
{
    struct vb2_queue *vq = vb->vb2_queue;
    struct fimc_ctx *ctx = vq->drv_priv;
    struct v4l2_device *v4l2_dev = &ctx->fimc_dev->m2m.v4l2_dev;
    int i;

    if (!ctx->d_frame.fmt || vq->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
        return -EINVAL;

    for (i = 0; i < ctx->d_frame.fmt->memplanes; i++) {
        unsigned long size = get_plane_size(&ctx->d_frame, i);

        if (vb2_plane_size(vb, i) < size) {
            v4l2_err(v4l2_dev, "User buffer too small (%ld < %ld)\n",
                     vb2_plane_size(vb, i), size);
            return -EINVAL;
        }

        vb2_set_plane_payload(vb, i, size);
    }

    return 0;
}