Example #1
0
static int isp_video_buffer_prepare(struct isp_video_buffer *buf)
{
    struct isp_video_fh *vfh = isp_video_queue_to_isp_video_fh(buf->queue);
    struct isp_buffer *buffer = to_isp_buffer(buf);
    struct isp_video *video = vfh->video;
    unsigned long addr;

    /* Refuse to prepare the buffer is the video node has registered an
     * error. We don't need to take any lock here as the operation is
     * inherently racy. The authoritative check will be performed in the
     * queue handler, which can't return an error, this check is just a best
     * effort to notify userspace as early as possible.
     */
    if (unlikely(video->error))
        return -EIO;

    addr = ispmmu_vmap(video->isp, buf->sglist, buf->sglen);
    if (IS_ERR_VALUE(addr))
        return -EIO;

    if (!IS_ALIGNED(addr, 32)) {
        dev_dbg(video->isp->dev, "Buffer address must be "
                "aligned to 32 bytes boundary.\n");
        ispmmu_vunmap(video->isp, buffer->isp_addr);
        return -EINVAL;
    }

    buf->vbuf.bytesused = vfh->format.fmt.pix.sizeimage;
    buffer->isp_addr = addr;
    return 0;
}
static int isp_video_buffer_prepare(struct isp_video_buffer *buf)
{
    struct isp_video_fh *vfh = isp_video_queue_to_isp_video_fh(buf->queue);
    struct isp_buffer *buffer = to_isp_buffer(buf);
    struct isp_video *video = vfh->video;
    unsigned long addr;

    addr = ispmmu_vmap(video->isp, buf->sglist, buf->sglen);
    if (IS_ERR_VALUE(addr))
        return -EIO;

    if (!IS_ALIGNED(addr, 32)) {
        dev_dbg(video->isp->dev, "Buffer address must be "
                "aligned to 32 bytes boundary.\n");
        ispmmu_vunmap(video->isp, buffer->isp_addr);
        return -EINVAL;
    }

    buf->vbuf.bytesused = vfh->format.fmt.pix.sizeimage;
    buffer->isp_addr = addr;
    return 0;
}
Example #3
0
/**
 * prev2resz_vbq_prepare - Videobuffer is prepared and mmapped.
 */
static int prev2resz_vbq_prepare(struct videobuf_queue *q,
				 struct videobuf_buffer *vb,
				 enum v4l2_field field)
{
	struct prev2resz_fhdl *fhdl = q->priv_data;
	struct videobuf_dmabuf *dma  = videobuf_to_dma(vb);
	dma_addr_t isp_addr;
	int err = 0;

	if (!vb->baddr) {
		dev_err(p2r_device, "%s: No user buffer allocated\n",
			__func__);
		return -EINVAL;
	}

	if (q->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
		spin_lock(&fhdl->dst_vbq_lock);
		vb->size = fhdl->pipe.out.image.bytesperline *
			   fhdl->pipe.out.image.height;
		vb->width = fhdl->pipe.out.image.width;
		vb->height = fhdl->pipe.out.image.height;
		vb->bsize = vb->size;
		vb->field = field;
		spin_unlock(&fhdl->dst_vbq_lock);
	} else if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
		spin_lock(&fhdl->src_vbq_lock);
		vb->size = fhdl->pipe.in.image.bytesperline *
			   fhdl->pipe.in.image.height;
		vb->width = fhdl->pipe.in.image.width;
		vb->height = fhdl->pipe.in.image.height;
		vb->bsize = vb->size;
		vb->field = field;
		spin_unlock(&fhdl->src_vbq_lock);
	} else {
		return -EINVAL;
	}

	if (vb->state == VIDEOBUF_NEEDS_INIT) {
		dev_dbg(p2r_device, "baddr = %08x\n", (int)vb->baddr);
		err = videobuf_iolock(q, vb, NULL);
		if (!err) {
			isp_addr = ispmmu_vmap(fhdl->isp, dma->sglist,
					       dma->sglen);
			if (!isp_addr) {
				err = -EIO;
			} else {
				if (q->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
					fhdl->dst_buff_addr = isp_addr;
				else if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
					fhdl->src_buff_addr = isp_addr;
				else
					return -EINVAL;
			}
		}
	}

	if (!err) {
		if (q->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
			spin_lock(&fhdl->dst_vbq_lock);
			vb->state = VIDEOBUF_PREPARED;
			spin_unlock(&fhdl->dst_vbq_lock);
		} else if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
			spin_lock(&fhdl->src_vbq_lock);
			vb->state = VIDEOBUF_PREPARED;
			spin_unlock(&fhdl->src_vbq_lock);
		}
	} else {
		prev2resz_vbq_release(q, vb);
	}

	return err;
}