/**
 * preview_isr - Interrupt Service Routine for Preview wrapper
 * @status: ISP IRQ0STATUS register value
 * @arg1: Currently not used
 * @arg2: Currently not used
 *
 * Interrupt Service Routine for Preview wrapper
 **/
static void prv_isr(unsigned long status, isp_vbq_callback_ptr arg1, void *arg2)
{
	isppreview_enable(0);
	ispresizer_enable(1);

	DPRINTK_ISPPROC("prv_isr\n");
}
Exemple #2
0
/**
 * prev_do_preview - Performs the Preview process
 * @device: Structure containing ISP preview wrapper global information
 * @arg: Currently not used
 *
 * Returns 0 if successful, or -EINVAL if the sent parameters are invalid.
 **/
static int prev_do_preview(struct prev_device *device, int *arg)
{
    int bpp, size;
    int ret = 0;
    u32 out_hsize, out_vsize, out_line_offset;

    dev_dbg(prev_dev, "prev_do_preview E\n");

    if (!device) {
        dev_err(prev_dev, "preview: invalid parameters\n");
        return -EINVAL;
    }

    previewer_set_isp_ctrl();

    if (device->params->size_params.pixsize == PREV_INWIDTH_8BIT)
        bpp = 1;
    else
        bpp = 2;

    size = device->params->size_params.hsize *
           device->params->size_params.vsize * bpp;

    isppreview_config_datapath(PRV_RAW_MEM, PREVIEW_MEM);

    isppreview_try_size(device->params->size_params.hsize,
                        device->params->size_params.vsize,
                        &out_hsize,
                        &out_vsize);


    ret = isppreview_config_inlineoffset(device->params->size_params.hsize
                                         * bpp);
    if (ret)
        goto out;

    out_line_offset = (out_hsize * bpp) & PREV_32BYTES_ALIGN_MASK;

    ret = isppreview_config_outlineoffset(out_line_offset);
    if (ret)
        goto out;

    ret = isppreview_config_size(device->params->size_params.hsize,
                                 device->params->size_params.vsize,
                                 out_hsize, out_vsize);

    device->params->drkf_params.addr = device->isp_addr_lsc;

    prev_hw_setup(device->params);

    ret = isppreview_set_inaddr(device->isp_addr_read);
    if (ret)
        goto out;

    ret = isppreview_set_outaddr(device->isp_addr_read);
    if (ret)
        goto out;

    ret = isp_set_callback(CBK_PREV_DONE, preview_isr, (void *)device,
                           (void *)NULL);
    if (ret) {
        dev_err(prev_dev, "ERROR while setting Previewer callback!\n");
        goto out;
    }
    isppreview_enable(1);

    wait_for_completion_interruptible(&device->wfc);

    ret = isp_unset_callback(CBK_PREV_DONE);

    dev_dbg(prev_dev, "prev_do_preview L\n");
out:
    return ret;
}
Exemple #3
0
/**
 * prev_do_preview - Performs the Preview process
 * @device: Structure containing ISP preview wrapper global information
 * @arg: Currently not used
 *
 * Returns 0 if successful, or -EINVAL if the sent parameters are invalid.
 **/
static int prev_do_preview(struct prev_device *device, int *arg)
{
	u32 out_hsize, out_vsize, out_line_offset, in_line_offset;
	int ret = 0, bpp;

	dev_dbg(prev_dev, "prev_do_preview E\n");

	if (!device) {
		dev_err(prev_dev, "preview: invalid parameters\n");
		return -EINVAL;
	}

	prev_set_isp_ctrl(device->params->features);

	if (device->params->size_params.pixsize == PREV_INWIDTH_8BIT)
		bpp = 1;
	else
		bpp = 2;

 	out_hsize = device->out_hsize;
	out_vsize = device->out_vsize;

	in_line_offset = device->params->size_params.hsize * bpp;

	ret = isppreview_config_inlineoffset(in_line_offset);
	if (ret)
		goto out;

	dev_dbg(prev_dev, "%s: out_pitch %d, output width %d, out_hsize %d, "
						"out_vsize %d\n", __func__,
		device->params->size_params.out_pitch,
		device->params->size_params.out_pitch / bpp,
		out_hsize, out_vsize);

	out_line_offset = (out_hsize * bpp) & PREV_32BYTES_ALIGN_MASK;

	ret = isppreview_config_outlineoffset(out_line_offset);
	if (ret)
		goto out;

	ret = prev_config_size(device->params->size_params.hsize,
					device->params->size_params.vsize);
	if (ret)
		goto out;

	device->params->drkf_params.addr = device->isp_addr_lsc;

	prev_hw_setup(device->params);

	ret = isppreview_set_inaddr(device->isp_addr_read);
	if (ret)
		goto out;

	ret = isppreview_set_outaddr(device->isp_addr_read);
	if (ret)
		goto out;

	ret = isp_set_callback(CBK_PREV_DONE, prev_isr, (void *) device,
							(void *) NULL);
	if (ret) {
		dev_err(prev_dev, "ERROR while setting Previewer callback!\n");
		goto out;
	}

	isppreview_enable(1);
	wait_for_completion_interruptible(&device->wfc);
	isppreview_enable(0);

	ret = isp_unset_callback(CBK_PREV_DONE);

	prev_unset_isp_ctrl();

	dev_dbg(prev_dev, "prev_do_preview L\n");
out:
	return ret;
}
Exemple #4
0
static int prev2resz_ioc_run_engine(struct prev2resz_fhdl *fh)
{
	struct isp_freq_devider *fdiv;
	int rval;

	rval = isppreview_s_pipeline(fh->isp_prev, &fh->prev);
	if (rval != 0)
		return rval;

	rval = isppreview_set_inaddr(fh->isp_prev, fh->src_buff_addr);
	if (rval != 0)
		return rval;

	rval = isppreview_config_inlineoffset(fh->isp_prev,
				fh->prev.in.image.bytesperline);
	if (rval != 0)
		return rval;

	rval = isppreview_set_outaddr(fh->isp_prev, fh->dst_buff_addr);
	if (rval != 0)
		return rval;

	rval = isppreview_config_features(fh->isp_prev, &fh->isp_prev->params);
	if (rval != 0)
		return rval;

	isppreview_set_size(fh->isp_prev, fh->prev.in.image.width,
			    fh->prev.in.image.height);

	/* Set resizer input and output size */
	rval = ispresizer_s_pipeline(fh->isp_resz, &fh->resz);
	if (rval != 0)
		return rval;

	rval = ispresizer_set_outaddr(fh->isp_resz, fh->dst_buff_addr);
	if (rval != 0)
		return rval;

	isp_configure_interface(fh->isp, &p2r_interface);
	/*
	 * Through-put requirement:
	 * Set max OCP freq for 3630 is 200 MHz through-put
	 * is in KByte/s so 200000 KHz * 4 = 800000 KByte/s
	 */
	omap_pm_set_min_bus_tput(fh->isp, OCP_INITIATOR_AGENT, 800000);

	/* Reduces memory bandwidth */
	fdiv = isp_get_upscale_ratio(fh->pipe.in.image.width,
				     fh->pipe.in.image.height,
				     fh->pipe.out.image.width,
				     fh->pipe.out.image.height);
	dev_dbg(p2r_device, "Set the REQ_EXP register = %d.\n",
		fdiv->prev_exp);
	isp_reg_and_or(fh->isp, OMAP3_ISP_IOMEM_SBL, ISPSBL_SDR_REQ_EXP,
		       ~(ISPSBL_SDR_REQ_PRV_EXP_MASK |
		         ISPSBL_SDR_REQ_RSZ_EXP_MASK),
		         fdiv->prev_exp << ISPSBL_SDR_REQ_PRV_EXP_SHIFT);
	isp_start(fh->isp);

	init_completion(&p2r_ctx.resz_complete);
	rval = isp_set_callback(fh->isp, CBK_RESZ_DONE, prev2resz_resz_callback,
			       (void *) NULL, (void *) NULL);
	if (rval) {
		dev_err(p2r_device, "%s: setting resizer callback failed\n",
			__func__);
		return rval;
	}

	ispresizer_enable(fh->isp_resz, 1);
	isppreview_enable(fh->isp_prev, 1);
	rval = wait_for_completion_interruptible_timeout(
			&p2r_ctx.resz_complete, msecs_to_jiffies(1000));
	if (rval == 0)
		dev_crit(p2r_device, "Resizer interrupt timeout exit\n");

	isp_unset_callback(fh->isp, CBK_RESZ_DONE);

	/* Reset Through-put requirement */
	omap_pm_set_min_bus_tput(fh->isp, OCP_INITIATOR_AGENT, -1);

	/* This will flushes the queue */
	if (&fh->src_vbq)
		videobuf_queue_cancel(&fh->src_vbq);
	if (&fh->dst_vbq)
		videobuf_queue_cancel(&fh->dst_vbq);

	return 0;
}
int isp_process_mem_data(struct isp_mem_data *data)
{
	int i;
	int ret = -1;
	struct isp_mem_data *ppreview_user = \
		(struct isp_mem_data *)data;
	struct isp_mem_data preview_param;
	u32 input_buffer_size, output_buffer_size;
	u32 input_nr_pages, output_nr_pages;
	struct page **input_pages = NULL;
	struct page **output_pages = NULL;
	unsigned long isp_addr_in = 0;
	unsigned long  isp_addr_out = 0;
	unsigned long  isp_addr_tmp = 0;
	unsigned long timeout;
	struct isp_mem_resize_data resizer_param;
	u16 cropadjust = 0;

	if (ppreview_user == NULL) {
		printk(KERN_ERR "ISP_PROC_ERR: Invalid user data!\n");
		return -EINVAL;
	}

	memcpy(&preview_param, ppreview_user, \
		sizeof(struct isp_mem_data));

	DPRINTK_ISPPROC("input(%d-%d) - output(%d-%d)\n",
		preview_param.input_width,
		preview_param.input_height,
		preview_param.output_width,
		preview_param.output_height);

	DPRINTK_ISPPROC("start(%d-%d) - end(%d-%d)\n",
		preview_param.left,
		preview_param.top,
		preview_param.crop_width,
		preview_param.crop_height);

	if (ppreview_user->datain == 0 || ppreview_user->dataout == 0)
		return -EINVAL;

	isppreview_enable(0);
	ispresizer_enable(0);
	timeout = jiffies + msecs_to_jiffies(200);
	while (isppreview_busy() ||
			ispresizer_busy()) {
		if (time_after(jiffies, timeout))
			return -EINVAL;
		msleep(1);
	}

	isppreview_save_context();
	ispresizer_save_context();
	isppreview_free();
	ispresizer_free();
	isppreview_request();
	ispresizer_request();

	/* set data path before configuring modules. */
	isppreview_update_datapath(PRV_RAW_MEM, PREVIEW_MEM);
	ispresizer_config_datapath(RSZ_MEM_YUV, 0);

	ret = isppreview_try_size(preview_param.input_width,
		preview_param.input_height,
		&preview_param.output_width,
		&preview_param.output_height);
	if (ret < 0)
		goto exit_cleanup;
	ret = isppreview_config_size(preview_param.input_width,
		preview_param.input_height,
		preview_param.output_width,
		preview_param.output_height);
	if (ret < 0)
		goto exit_cleanup;

	input_buffer_size = ALIGN_TO(ppreview_user->input_width* \
		ppreview_user->input_height*2 , 0x100);
	input_pages = map_user_memory_to_kernel(preview_param.datain,
		input_buffer_size, &input_nr_pages);
	if (input_pages == NULL) {
		ret = -EINVAL;
		printk(KERN_ERR "ISP_PROC_ERR: memory allocation failed\n");
		goto exit_cleanup;
	}

	output_buffer_size = ALIGN_TO(ppreview_user->output_width* \
		ppreview_user->output_height*2, 0x1000);
	output_pages = map_user_memory_to_kernel(preview_param.dataout,
		output_buffer_size, &output_nr_pages);
	if (output_pages == NULL) {
		ret = -EINVAL;
		printk(KERN_ERR "ISP_PROC_ERR: memory allocation failed\n");
		goto exit_cleanup;
	}
	for (i = 0; i < output_nr_pages; ++i)
		flush_dcache_page(output_pages[i]);

	isp_addr_in = ispmmu_vmap_pages(input_pages, input_nr_pages);
	if (IS_ERR((void *)isp_addr_in)) {
		isp_addr_in = 0;
		ret = -EINVAL;
		printk(KERN_ERR "ISP_PROC_ERR: isp mmu map failed\n");
		goto exit_cleanup;
	}
	isp_addr_out = ispmmu_vmap_pages(output_pages, output_nr_pages);
	if (IS_ERR((void *)isp_addr_out)) {
		isp_addr_out = 0;
		ret = -EINVAL;
		printk(KERN_ERR "ISP_PROC_ERR: isp mmu map failed\n");
		goto exit_cleanup;
	}

	/* This buffer must be allocated and mapped to
		the ISP MMU previously. */
	isp_addr_tmp = isp_tmp_buf_addr();
	if (isp_addr_tmp == 0) {
		printk(KERN_ERR "ISP_PROC_ERR: Invalid isp tmp buffer address!\n");
		goto exit_cleanup;
	}

	isppreview_config_inlineoffset(ppreview_user->input_width * 2);
	isppreview_set_inaddr(isp_addr_in);
	isppreview_set_outaddr(isp_addr_tmp);

	resizer_param.input_width = preview_param.output_width;
	resizer_param.input_height = preview_param.output_height;
	resizer_param.output_width = ppreview_user->output_width;
	resizer_param.output_height = ppreview_user->output_height;

	if ((preview_param.left == 0) && (preview_param.top == 0)) {
		ret = ispresizer_try_size(&resizer_param.input_width,
				&resizer_param.input_height,
				&resizer_param.output_width,
				&resizer_param.output_height);
		if (ret < 0)
			goto exit_cleanup;
		ret = ispresizer_config_size(resizer_param.input_width,
				resizer_param.input_height,
				resizer_param.output_width,
				resizer_param.output_height);
		if (ret < 0)
			goto exit_cleanup;
		ispresizer_set_inaddr(isp_addr_tmp);
	} else {
		ispresizer_trycrop(preview_param.left,
				preview_param.top,
				preview_param.crop_width,
				preview_param.crop_height,
				resizer_param.output_width,
				resizer_param.output_height);

		ispresizer_applycrop();

		/* account for pixel loss when using crop*/
		if ((preview_param.input_height > preview_param.output_height)
				&& (preview_param.top > 16))
			cropadjust = 8;
		else
			cropadjust = 0;

		/* pixel alignment in 32bit space, vertical must be 0 per TRM */
		isp_reg_writel(((preview_param.left%16) <<
					ISPRSZ_IN_START_HORZ_ST_SHIFT) |
					(0 <<
					ISPRSZ_IN_START_VERT_ST_SHIFT),
					OMAP3_ISP_IOMEM_RESZ,
					ISPRSZ_IN_START);

		/* Align input address for cropping, per TRM  */
		ispresizer_set_inaddr(isp_addr_tmp -
				(resizer_param.input_width*2*cropadjust) +
				(preview_param.top*resizer_param.input_width*2)
				+ ((preview_param.left/16)*32));
	}

	ispresizer_set_outaddr(isp_addr_out);
	ispresizer_config_inlineoffset(
		ALIGN_TO(resizer_param.input_width*2, 32));

	if (isp_set_callback(CBK_PREV_DONE, prv_isr,
			(void *) NULL, (void *)NULL) != 0) {
		printk(KERN_ERR "ISP_PROC_ERR: Error setting PRV callback.\n");
		goto exit_cleanup;
	}

	if (isp_set_callback(CBK_RESZ_DONE, rsz_isr,
			(void *) NULL, (void *)NULL) != 0) {
		printk(KERN_ERR "ISP_PROC_ERR: Error setting RSZ callback.\n");
		goto exit_cleanup;
	}

	isp_reg_writel(0xFFFFFFFF, OMAP3_ISP_IOMEM_MAIN, ISP_IRQ0STATUS);
	isp_wfc.done = 0;

	/* start preview engine. */
	isppreview_enable(1);

	ret = wait_for_completion_timeout(&isp_wfc, msecs_to_jiffies(1000));
	if (!ret) {
		isppreview_enable(0);
		ispresizer_enable(0);
	}

	timeout = jiffies + msecs_to_jiffies(50);
	while (ispresizer_busy()) {
		msleep(5);
		if (time_after(jiffies, timeout)) {
			printk(KERN_ERR "ISP_RESZ_ERR: Resizer still busy");
			break;
		}
	}

	isp_reg_writel(0xFFFFFFFF, OMAP3_ISP_IOMEM_MAIN, ISP_IRQ0STATUS);
	isp_unset_callback(CBK_PREV_DONE);
	isp_unset_callback(CBK_RESZ_DONE);

exit_cleanup:
	isppreview_restore_context();
	ispresizer_restore_context();

	if (isp_addr_in != 0)
		ispmmu_vunmap(isp_addr_in);
	if (isp_addr_out != 0)
		ispmmu_vunmap(isp_addr_out);
	if (input_pages != NULL) {
		unmap_user_memory_from_kernel(input_pages, input_nr_pages);
		kfree(input_pages);
	}
	if (output_pages != NULL) {
		unmap_user_memory_from_kernel(output_pages, output_nr_pages);
		kfree(output_pages);
	}

	DPRINTK_ISPPROC("exit.\n");

	return ret;
}