Пример #1
0
/*
 * omap3isp_hist_init - Module Initialization.
 */
int omap3isp_hist_init(struct isp_device *isp)
{
	struct ispstat *hist = &isp->isp_hist;
	struct omap3isp_hist_config *hist_cfg;
	int ret = -1;

	hist_cfg = devm_kzalloc(isp->dev, sizeof(*hist_cfg), GFP_KERNEL);
	if (hist_cfg == NULL)
		return -ENOMEM;

	hist->isp = isp;

	if (HIST_CONFIG_DMA) {
		struct platform_device *pdev = to_platform_device(isp->dev);
		struct resource *res;
		unsigned int sig = 0;
		dma_cap_mask_t mask;

		dma_cap_zero(mask);
		dma_cap_set(DMA_SLAVE, mask);

		res = platform_get_resource_byname(pdev, IORESOURCE_DMA,
						   "hist");
		if (res)
			sig = res->start;

		hist->dma_ch = dma_request_slave_channel_compat_reason(mask,
				omap_dma_filter_fn, &sig, isp->dev, "hist");
		if (IS_ERR(hist->dma_ch)) {
			ret = PTR_ERR(hist->dma_ch);
			if (ret == -EPROBE_DEFER)
				return ret;

			hist->dma_ch = NULL;
			dev_warn(isp->dev,
				 "hist: DMA channel request failed, using PIO\n");
		} else {
			dev_dbg(isp->dev, "hist: using DMA channel %s\n",
				dma_chan_name(hist->dma_ch));
		}
	}

	hist->ops = &hist_ops;
	hist->priv = hist_cfg;
	hist->event_type = V4L2_EVENT_OMAP3ISP_HIST;

	ret = omap3isp_stat_init(hist, "histogram", &hist_subdev_ops);
	if (ret) {
		if (hist->dma_ch)
			dma_release_channel(hist->dma_ch);
	}

	return ret;
}
Пример #2
0
int omap3isp_hist_init(struct isp_device *isp)
{
    struct ispstat *hist = &isp->isp_hist;
    struct omap3isp_hist_config *hist_cfg;
    int ret = -1;

    hist_cfg = kzalloc(sizeof(*hist_cfg), GFP_KERNEL);
    if (hist_cfg == NULL)
        return -ENOMEM;

    memset(hist, 0, sizeof(*hist));
    if (HIST_CONFIG_DMA)
        ret = omap_request_dma(OMAP24XX_DMA_NO_DEVICE, "DMA_ISP_HIST",
                               hist_dma_cb, hist, &hist->dma_ch);
    if (ret) {
        if (HIST_CONFIG_DMA)
            dev_warn(isp->dev, "hist: DMA request channel failed. "
                     "Using PIO only.\n");
        hist->dma_ch = -1;
    } else {
        dev_dbg(isp->dev, "hist: DMA channel = %d\n", hist->dma_ch);
        hist_dma_config(hist);
        omap_enable_dma_irq(hist->dma_ch, OMAP_DMA_BLOCK_IRQ);
    }

    hist->ops = &hist_ops;
    hist->priv = hist_cfg;
    hist->event_type = V4L2_EVENT_OMAP3ISP_HIST;
    hist->isp = isp;

    ret = omap3isp_stat_init(hist, "histogram", &hist_subdev_ops);
    if (ret) {
        kfree(hist_cfg);
        if (HIST_USING_DMA(hist))
            omap_free_dma(hist->dma_ch);
    }

    return ret;
}