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;
}
Exemple #2
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;
}
Exemple #3
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;
}
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;
}