示例#1
0
int msm_mctl_pp_reserve_free_frame(
	struct msm_cam_media_controller *p_mctl,
	void __user *arg)
{
	struct msm_cam_evt_divert_frame frame;
	int msg_type, image_mode, rc = 0;
	struct msm_free_buf free_buf;
	int idx;
	struct msm_cam_v4l2_dev_inst *pcam_inst;

	memset(&free_buf, 0, sizeof(struct msm_free_buf));
	if (copy_from_user(&frame, arg,
		sizeof(struct msm_cam_evt_divert_frame)))
		return -EFAULT;
	switch (frame.frame.path) {
	case OUTPUT_TYPE_P:
		msg_type = VFE_MSG_OUTPUT_P;
		image_mode = MSM_V4L2_EXT_CAPTURE_MODE_PREVIEW;
		break;
	case OUTPUT_TYPE_S:
		msg_type = VFE_MSG_OUTPUT_S;
		image_mode = MSM_V4L2_EXT_CAPTURE_MODE_MAIN;
		break;
	case OUTPUT_TYPE_V:
		msg_type = VFE_MSG_OUTPUT_V;
		image_mode = MSM_V4L2_EXT_CAPTURE_MODE_VIDEO;
		break;
	case OUTPUT_TYPE_T:
	default:
		rc = -EFAULT;
		return rc;
	}

	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];

	rc = msm_mctl_reserve_free_buf(p_mctl, msg_type, &free_buf);
	if (rc == 0) {
		msm_mctl_pp_get_phy_addr(pcam_inst, free_buf.vb, &frame.frame);
		if (copy_to_user((void *)arg,
				&frame,
				sizeof(frame))) {
			ERR_COPY_TO_USER();
			rc = -EFAULT;
		}
	}
	D("%s: reserve free buf, rc = %d, phy = 0x%x",
		__func__, rc, free_buf.ch_paddr[0]);
	return rc;
}
示例#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;
}
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;
}