Example #1
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_negotiate_output_size(struct prev_device *prvdev,
				u32 *out_hsize, u32 *out_vsize)
{
	int bpp, ret, outh, outv;

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

	isppreview_config_datapath(PRV_RAW_MEM, PREVIEW_MEM);

	ret = isppreview_try_size(prvdev->params->size_params.hsize,
				prvdev->params->size_params.vsize, &outh, &outv);
	if (ret) {
		dev_err(prev_dev, "ERROR while try size!\n");
		return -1;
	}

	dev_dbg(prev_dev, "%s: try size %dx%d -> %dx%d\n", __func__,
		prvdev->params->size_params.hsize,
		prvdev->params->size_params.vsize, outh, outv);

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

	if (outh > (prvdev->params->size_params.out_pitch / bpp))
		outh = prvdev->params->size_params.out_pitch / bpp;

	*out_hsize = outh;
	*out_vsize = outv;
	return 0;
}
Example #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;
}