コード例 #1
0
static int msm_mctl_pp_get_phy_addr(
	struct msm_cam_v4l2_dev_inst *pcam_inst,
	uint32_t frame_handle,
	struct msm_pp_frame *pp_frame)
{
	struct msm_frame_buffer *vb = NULL;
	struct videobuf2_contig_pmem *mem;
	int i, buf_idx = 0;

	vb = (struct msm_frame_buffer *)frame_handle;
	buf_idx = vb->vidbuf.v4l2_buf.index;
	memset(pp_frame, 0, sizeof(struct msm_pp_frame));
	pp_frame->handle = (uint32_t)vb;
	pp_frame->frame_id = vb->vidbuf.v4l2_buf.sequence;
	pp_frame->timestamp = vb->vidbuf.v4l2_buf.timestamp;
	/* Get the cookie for 1st plane and store the path.
	 * Also use this to check the number of planes in
	 * this buffer.*/
	mem = vb2_plane_cookie(&vb->vidbuf, 0);
	pp_frame->image_type = (unsigned short)mem->path;
	if (mem->buffer_type == VIDEOBUF2_SINGLE_PLANE) {
		pp_frame->num_planes = 1;
		pp_frame->sp.addr_offset = mem->addr_offset;
		pp_frame->sp.phy_addr =
			videobuf2_to_pmem_contig(&vb->vidbuf, 0);
		pp_frame->sp.y_off = 0;
		pp_frame->sp.cbcr_off = mem->offset.sp_off.cbcr_off;
		pp_frame->sp.length = mem->size;
		pp_frame->sp.fd = (int)mem->vaddr;
	} else {
		pp_frame->num_planes = pcam_inst->plane_info.num_planes;
		for (i = 0; i < pp_frame->num_planes; i++) {
			mem = vb2_plane_cookie(&vb->vidbuf, i);
			pp_frame->mp[i].addr_offset = mem->addr_offset;
			pp_frame->mp[i].phy_addr =
				videobuf2_to_pmem_contig(&vb->vidbuf, i);
			pp_frame->mp[i].data_offset =
			pcam_inst->buf_offset[buf_idx][i].data_offset;
			pp_frame->mp[i].fd = (int)mem->vaddr;
			pp_frame->mp[i].length = mem->size;
			D("%s frame id %d buffer %d plane %d phy addr 0x%x"
				" fd %d length %d\n", __func__,
				pp_frame->frame_id, buf_idx, i,
				(uint32_t)pp_frame->mp[i].phy_addr,
				pp_frame->mp[i].fd, pp_frame->mp[i].length);
		}
	}
	return 0;
}
コード例 #2
0
static void __buf_queue(struct vb2_buffer *vb, bool force)
{
	struct css2600_isys_queue *aq =
		vb2_queue_to_css2600_isys_queue(vb->vb2_queue);
	struct css2600_isys_video *av = css2600_isys_queue_to_video(aq);
	struct css2600_isys_buffer *ib = to_css2600_isys_buffer(vb);
	struct ia_css_isys_frame_buff_set buf = {
		.output_pins = {
			{
				.payload = {
					.addr =
					*(dma_addr_t *)vb2_plane_cookie(vb, 0),
					/* + 1 due to library issues */
					.out_buf_id = vb->v4l2_buf.index + 1,
				},
				.info = {
					.type_specifics.ft =
					css2600_isys_video_type_specifics(
						av->aq.css_pin_type, av->pfmt),
					.pt = aq->css_pin_type,
					.output_res = {
						.width = av->pix.width,
						.height = av->pix.height,
					},
				},
			},
		},
		.input_pin_set = {
コード例 #3
0
ファイル: nxp-video.c プロジェクト: iTOP4418/kernel-3.4.39
static unsigned long
plane_addr(struct vb2_buffer *vb, u32 plane_no)
{
    void *cookie = vb2_plane_cookie(vb, plane_no);
    dma_addr_t addr = 0;
    WARN_ON(vb2_ion_dma_address(cookie, &addr) != 0);
    return addr;
}
コード例 #4
0
static unsigned long jpeg_vb2_plane_addr(struct vb2_buffer *vb, u32 plane_no)
{
	void *cookie = vb2_plane_cookie(vb, plane_no);
	dma_addr_t dva = 0;

	WARN_ON(vb2_ion_dma_address(cookie, &dva) != 0);

	return dva;
}
コード例 #5
0
unsigned long videobuf2_to_pmem_contig(struct vb2_buffer *vb,
				unsigned int plane_no)
{
	struct videobuf2_contig_pmem *mem;
	mem = vb2_plane_cookie(vb, plane_no);
	BUG_ON(!mem);
	MAGIC_CHECK(mem->magic, MAGIC_PMEM);
	return mem->mapped_phyaddr;
}
コード例 #6
0
unsigned long videobuf2_to_pmem_contig(struct vb2_buffer *vb,
				unsigned int plane_no)
{
	struct videobuf2_contig_pmem *mem;
	mem = vb2_plane_cookie(vb, plane_no);
	BUG_ON(!mem);
	MAGIC_CHECK(mem->magic, MAGIC_PMEM);
/* HTC_START */
	if (!mem->mapped_phyaddr)
		pr_err("%s mem->mapped_phyaddr is null", __func__);
/* HTC_END */
	return mem->mapped_phyaddr;
}
コード例 #7
0
int msm_mctl_do_pp_divert(
    struct msm_cam_media_controller *p_mctl,
    int msg_type, struct msm_free_buf *fbuf,
    uint32_t frame_id, int pp_type)
{
    struct msm_cam_v4l2_dev_inst *pcam_inst;
    int idx, rc = 0;
    int del_buf = 0; /* delete from free queue */
    struct msm_cam_evt_divert_frame div;
    struct msm_frame_buffer *vb = NULL;
    struct videobuf2_contig_pmem *mem;

    idx = msm_mctl_out_type_to_inst_index(
              p_mctl->sync.pcam_sync, msg_type);
    pcam_inst = p_mctl->sync.pcam_sync->dev_inst[idx];
    vb = msm_mctl_buf_find(p_mctl, pcam_inst,
                           del_buf, msg_type, fbuf);
    if (!vb)
        return -EINVAL;
    vb->vidbuf.v4l2_buf.sequence = frame_id;
    mem = vb2_plane_cookie(&vb->vidbuf, 0);
    div.image_mode = pcam_inst->image_mode;
    div.op_mode    = pcam_inst->pcam->op_mode;
    div.inst_idx   = pcam_inst->my_index;
    div.node_idx   = pcam_inst->pcam->vnode_id;
    div.phy_addr   =
        videobuf2_to_pmem_contig(&vb->vidbuf, 0);
    div.phy_offset = mem->addr_offset;
    div.y_off      = 0;
    div.cbcr_off   = mem->offset.sp_off.cbcr_off;
    div.fd         = (int)mem->vaddr;
    div.vb = (uint32_t)vb;
    p_mctl->pp_info.cur_frame_id[pcam_inst->image_mode]++;
    if (p_mctl->pp_info.cur_frame_id[pcam_inst->image_mode] == 0)
        p_mctl->pp_info.cur_frame_id[pcam_inst->image_mode]++;
    div.frame_id   =
        p_mctl->pp_info.cur_frame_id[pcam_inst->image_mode];
    div.path       = mem->path;
    div.length     = mem->size;
    msm_mctl_gettimeofday(&div.timestamp);
    vb->vidbuf.v4l2_buf.timestamp = div.timestamp;
    div.do_pp = pp_type;
    if (!pp_type) {
        p_mctl->pp_info.div_frame[pcam_inst->image_mode].ch_paddr[0] =
            div.phy_addr;
    }
    rc = msm_mctl_pp_buf_divert(p_mctl, pcam_inst, &div);
    return rc;
}
コード例 #8
0
int s5p_mfc_mem_inv_vb(struct vb2_buffer *vb, u32 num_planes)
{
	struct vb2_ion_cookie *cookie;
	int i;
	size_t size;

	for (i = 0; i < num_planes; i++) {
		cookie = vb2_plane_cookie(vb, i);
		if (!cookie)
			continue;

		size = vb->v4l2_planes[i].length;
		vb2_ion_sync_for_device(cookie, 0, size, DMA_FROM_DEVICE);
	}

	return 0;
}
コード例 #9
0
int s5p_mfc_mem_flush_vb(struct vb2_buffer *vb, u32 num_planes)
{
	struct vb2_ion_cookie *cookie;
	int i;
	enum dma_data_direction dir;
	size_t size;

	dir = V4L2_TYPE_IS_OUTPUT(vb->v4l2_buf.type) ?
					DMA_TO_DEVICE : DMA_FROM_DEVICE;

	for (i = 0; i < num_planes; i++) {
		cookie = vb2_plane_cookie(vb, i);
		if (!cookie)
			continue;

		size = vb->v4l2_planes[i].length;
		vb2_ion_sync_for_device(cookie, 0, size, dir);
	}

	return 0;
}
コード例 #10
0
static int msm_mctl_pp_get_phy_addr(
    uint32_t frame_handle,
    struct msm_pp_frame *pp_frame)
{
    struct msm_frame_buffer *vb = NULL;
    struct videobuf2_contig_pmem *mem;

    vb = (struct msm_frame_buffer *)frame_handle;
    mem = vb2_plane_cookie(&vb->vidbuf, 0);
    memset(pp_frame, 0, sizeof(struct msm_pp_frame));
    pp_frame->handle = (uint32_t)vb;
    pp_frame->frame_id = vb->vidbuf.v4l2_buf.sequence;
    pp_frame->image_type = (unsigned short)mem->path;
    pp_frame->timestamp = vb->vidbuf.v4l2_buf.timestamp;
    /* hard coded for now. Will need to expand to MP case */
    pp_frame->num_planes = 1;
    pp_frame->sp.addr_offset = mem->addr_offset;
    pp_frame->sp.phy_addr = videobuf2_to_pmem_contig(&vb->vidbuf, 0);
    pp_frame->sp.y_off = 0;
    pp_frame->sp.cbcr_off = mem->offset.sp_off.cbcr_off;
    pp_frame->sp.length = mem->size;
    pp_frame->sp.fd = (int)mem->vaddr;
    return 0;
}
コード例 #11
0
		},
		.input_pin_set = {
			 .blc_param.addr = 1,
			 .lsc_param.addr = 1,
			 .dpc_param.addr = 1,
		 },
		.send_irq_sof = 1,
		.send_irq_eof = 1,
	};
	unsigned long flags;
	int rval;

	dev_dbg(&av->isys->adev->dev, "buf_queue %d/%p\n", vb->v4l2_buf.index,
		ib);
	dev_dbg(&av->isys->adev->dev, "iova %lu\n",
		(unsigned long)*(dma_addr_t *)vb2_plane_cookie(vb, 0));

	if (!vb->vb2_queue->streaming && !force) {
		dev_dbg(&av->isys->adev->dev,
			"not streaming yet, adding to incoming\n");
		spin_lock_irqsave(&aq->lock, flags);
		list_add(&ib->head, &aq->incoming);
		spin_unlock_irqrestore(&aq->lock, flags);
		return;
	}

	spin_lock_irqsave(&aq->lock, flags);
	list_add(&ib->head, &aq->active);
	spin_unlock_irqrestore(&aq->lock, flags);

	rval = css2600_lib_call(
コード例 #12
0
int msm_mctl_do_pp_divert(
	struct msm_cam_media_controller *p_mctl,
	int msg_type, struct msm_free_buf *fbuf,
	uint32_t frame_id, int pp_type)
{
	struct msm_cam_v4l2_dev_inst *pcam_inst;
	int idx, rc = 0, i, buf_idx;
	int del_buf = 0; /* delete from free queue */
	struct msm_cam_evt_divert_frame div;
	struct msm_frame_buffer *vb = NULL;
	struct videobuf2_contig_pmem *mem;

	idx = msm_mctl_out_type_to_inst_index(
		p_mctl->sync.pcam_sync, msg_type);
	if (idx < 0) {
		pr_err("%s Invalid instance. returning\n", __func__);
		return -EINVAL;
	}
	pcam_inst = p_mctl->sync.pcam_sync->dev_inst[idx];
	vb = msm_mctl_buf_find(p_mctl, pcam_inst,
		  del_buf, msg_type, fbuf);
	if (!vb)
		return -EINVAL;

	vb->vidbuf.v4l2_buf.sequence = frame_id;
	buf_idx = vb->vidbuf.v4l2_buf.index;
	div.image_mode = pcam_inst->image_mode;
	div.op_mode    = pcam_inst->pcam->op_mode;
	div.inst_idx   = pcam_inst->my_index;
	div.node_idx   = pcam_inst->pcam->vnode_id;
	p_mctl->pp_info.cur_frame_id[pcam_inst->image_mode] = frame_id;
	div.frame.frame_id =
		p_mctl->pp_info.cur_frame_id[pcam_inst->image_mode];
#if defined(CONFIG_MSM_IOMMU)
	div.frame.buf_idx  = buf_idx;
#endif

	div.frame.handle = (uint32_t)vb;
	msm_mctl_gettimeofday(&div.frame.timestamp);
	vb->vidbuf.v4l2_buf.timestamp = div.frame.timestamp;
	div.do_pp = pp_type;
	/* Get the cookie for 1st plane and store the path.
	 * Also use this to check the number of planes in
	 * this buffer.*/
	mem = vb2_plane_cookie(&vb->vidbuf, 0);
	div.frame.path = mem->path;
#if defined(CONFIG_MSM_IOMMU)
	div.frame.node_type = VIDEO_NODE;
#endif

	if (mem->buffer_type == VIDEOBUF2_SINGLE_PLANE) {
		/* This buffer contains only 1 plane. Use the
		 * single planar structure to store the info.*/
		div.frame.num_planes	= 1;
		div.frame.sp.phy_addr	=
			videobuf2_to_pmem_contig(&vb->vidbuf, 0);
		div.frame.sp.addr_offset = mem->addr_offset;
		div.frame.sp.y_off      = 0;
		div.frame.sp.cbcr_off   = mem->offset.sp_off.cbcr_off;
		div.frame.sp.fd         = (int)mem->vaddr;
		div.frame.sp.length     = mem->size;
		if (!pp_type)
			p_mctl->pp_info.div_frame[pcam_inst->image_mode].
			ch_paddr[0] = div.frame.sp.phy_addr;
	} else {
		/* This buffer contains multiple planes. Use the mutliplanar
		 * structure to store the info. */
		div.frame.num_planes	= pcam_inst->plane_info.num_planes;
		/* Now traverse through all the planes of the buffer to
		 * fill out the plane info. */
		for (i = 0; i < div.frame.num_planes; i++) {
			mem = vb2_plane_cookie(&vb->vidbuf, i);
			div.frame.mp[i].phy_addr =
				videobuf2_to_pmem_contig(&vb->vidbuf, i);
			div.frame.mp[i].data_offset =
			pcam_inst->buf_offset[buf_idx][i].data_offset;
			div.frame.mp[i].addr_offset =
				mem->addr_offset;
			div.frame.mp[i].fd = (int)mem->vaddr;
			div.frame.mp[i].length = mem->size;
		}
		if (!pp_type)
			p_mctl->pp_info.div_frame[pcam_inst->image_mode].
			ch_paddr[0] = div.frame.mp[0].phy_addr;
	}
	rc = msm_mctl_pp_buf_divert(p_mctl, pcam_inst, &div);
	return rc;
}
コード例 #13
0
int fimc_is_queue_buffer_queue(struct fimc_is_queue *queue,
	const struct fimc_is_vb2 *vb2,
	struct vb2_buffer *vb)
{
	u32 ret = 0, i;
	u32 index;
	u32 ext_size;
	u32 spare;
	struct fimc_is_framemgr *framemgr;
	struct fimc_is_frame *frame;

	index = vb->v4l2_buf.index;
	framemgr = &queue->framemgr;

	BUG_ON(framemgr->id == FRAMEMGR_ID_INVALID);

	for (i = 0; i < vb->num_planes; i++)
		queue->buf_dva[index][i] = vb2->plane_addr(vb, i);

	frame = &framemgr->frame[index];

	/* uninitialized frame need to get info */
	if (!test_bit(FRAME_INI_MEM, &frame->memory))
		goto set_info;

	/* plane count check */
	if (frame->planes != vb->num_planes) {
		err("plane count is changed(%08X != %08X)",
			frame->planes, vb->num_planes);
		ret = -EINVAL;
		goto exit;
	}

	/* plane address check */
	for (i = 0; i < frame->planes; i++) {
		if (frame->dvaddr_buffer[i] != queue->buf_dva[index][i]) {
			err("buffer %d plane %d is changed(%08X != %08X)",
				index, i,
				frame->dvaddr_buffer[i],
				queue->buf_dva[index][i]);
			ret = -EINVAL;
			goto exit;
		}
	}

	goto exit;

set_info:
	if (test_bit(FIMC_IS_QUEUE_BUFFER_PREPARED, &queue->state)) {
		err("already prepared but new index(%d) is came", index);
		ret = -EINVAL;
		goto exit;
	}

	frame->vb = vb;
	frame->planes = vb->num_planes;
	spare = frame->planes - 1;

	for (i = 0; i < frame->planes; i++) {
		frame->dvaddr_buffer[i] = queue->buf_dva[index][i];
#ifdef PRINT_BUFADDR
		info("%04X %d.%d %08X\n", framemgr->id, index, i, frame->dvaddr_buffer[i]);
#endif
	}

	if (framemgr->id & FRAMEMGR_ID_SHOT) {
		ext_size = sizeof(struct camera2_shot_ext) - sizeof(struct camera2_shot);

		/* Create Kvaddr for Metadata */
		queue->buf_kva[index][spare] = vb2->plane_kvaddr(vb, spare);
		if (!queue->buf_kva[index][spare]) {
			err("plane_kvaddr is fail(%08X)", framemgr->id);
			ret = -EINVAL;
			goto exit;
		}

		frame->dvaddr_shot = queue->buf_dva[index][spare] + ext_size;
		frame->kvaddr_shot = queue->buf_kva[index][spare] + ext_size;
		frame->cookie_shot = (u32)vb2_plane_cookie(vb, spare);
		frame->shot = (struct camera2_shot *)frame->kvaddr_shot;
		frame->shot_ext = (struct camera2_shot_ext *)queue->buf_kva[index][spare];
		frame->shot_size = queue->framecfg.size[spare] - ext_size;
#ifdef MEASURE_TIME
		frame->tzone = (struct timeval *)frame->shot_ext->timeZone;
#endif
	} else {
		/* Create Kvaddr for frame sync */
		queue->buf_kva[index][spare] = vb2->plane_kvaddr(vb, spare);
		if (!queue->buf_kva[index][spare]) {
			err("plane_kvaddr is fail(%08X)", framemgr->id);
			ret = -EINVAL;
			goto exit;
		}

		frame->stream = (struct camera2_stream *)queue->buf_kva[index][spare];
		frame->stream->address = queue->buf_kva[index][spare];
		frame->stream_size = queue->framecfg.size[spare];
	}

	set_bit(FRAME_INI_MEM, &frame->memory);

	queue->buf_refcount++;

	if (queue->buf_rdycount == queue->buf_refcount)
		set_bit(FIMC_IS_QUEUE_BUFFER_READY, &queue->state);

	if (queue->buf_maxcount == queue->buf_refcount)
		set_bit(FIMC_IS_QUEUE_BUFFER_PREPARED, &queue->state);

exit:
	return ret;
}