mirror of https://gitee.com/openkylin/linux.git
[media] omap3isp: ccdc: Use the DMA API for LSC
Replace the OMAP-specific IOMMU API usage by the DMA API for LSC. The table is now allocated using dma_alloc_coherent() and the related sg table is retrieved using dma_get_sgtable() for sync operations. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Sakari Ailus <sakari.ailus@iki.fi> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
This commit is contained in:
parent
0e24e90f2c
commit
d33186d0be
|
@ -206,7 +206,8 @@ static int ccdc_lsc_validate_config(struct isp_ccdc_device *ccdc,
|
||||||
* ccdc_lsc_program_table - Program Lens Shading Compensation table address.
|
* ccdc_lsc_program_table - Program Lens Shading Compensation table address.
|
||||||
* @ccdc: Pointer to ISP CCDC device.
|
* @ccdc: Pointer to ISP CCDC device.
|
||||||
*/
|
*/
|
||||||
static void ccdc_lsc_program_table(struct isp_ccdc_device *ccdc, u32 addr)
|
static void ccdc_lsc_program_table(struct isp_ccdc_device *ccdc,
|
||||||
|
dma_addr_t addr)
|
||||||
{
|
{
|
||||||
isp_reg_writel(to_isp_device(ccdc), addr,
|
isp_reg_writel(to_isp_device(ccdc), addr,
|
||||||
OMAP3_ISP_IOMEM_CCDC, ISPCCDC_LSC_TABLE_BASE);
|
OMAP3_ISP_IOMEM_CCDC, ISPCCDC_LSC_TABLE_BASE);
|
||||||
|
@ -333,7 +334,7 @@ static int __ccdc_lsc_configure(struct isp_ccdc_device *ccdc,
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
|
||||||
ccdc_lsc_setup_regs(ccdc, &req->config);
|
ccdc_lsc_setup_regs(ccdc, &req->config);
|
||||||
ccdc_lsc_program_table(ccdc, req->table);
|
ccdc_lsc_program_table(ccdc, req->table.dma);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,11 +369,12 @@ static void ccdc_lsc_free_request(struct isp_ccdc_device *ccdc,
|
||||||
if (req == NULL)
|
if (req == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (req->iovm)
|
if (req->table.addr) {
|
||||||
dma_unmap_sg(isp->dev, req->iovm->sgt->sgl,
|
sg_free_table(&req->table.sgt);
|
||||||
req->iovm->sgt->nents, DMA_TO_DEVICE);
|
dma_free_coherent(isp->dev, req->config.size, req->table.addr,
|
||||||
if (req->table)
|
req->table.dma);
|
||||||
omap_iommu_vfree(isp->domain, isp->dev, req->table);
|
}
|
||||||
|
|
||||||
kfree(req);
|
kfree(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,7 +418,6 @@ static int ccdc_lsc_config(struct isp_ccdc_device *ccdc,
|
||||||
struct isp_device *isp = to_isp_device(ccdc);
|
struct isp_device *isp = to_isp_device(ccdc);
|
||||||
struct ispccdc_lsc_config_req *req;
|
struct ispccdc_lsc_config_req *req;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
void *table;
|
|
||||||
u16 update;
|
u16 update;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -444,38 +445,31 @@ static int ccdc_lsc_config(struct isp_ccdc_device *ccdc,
|
||||||
|
|
||||||
req->enable = 1;
|
req->enable = 1;
|
||||||
|
|
||||||
req->table = omap_iommu_vmalloc(isp->domain, isp->dev, 0,
|
req->table.addr = dma_alloc_coherent(isp->dev, req->config.size,
|
||||||
req->config.size, IOMMU_FLAG);
|
&req->table.dma,
|
||||||
if (IS_ERR_VALUE(req->table)) {
|
GFP_KERNEL);
|
||||||
req->table = 0;
|
if (req->table.addr == NULL) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
req->iovm = omap_find_iovm_area(isp->dev, req->table);
|
ret = dma_get_sgtable(isp->dev, &req->table.sgt,
|
||||||
if (req->iovm == NULL) {
|
req->table.addr, req->table.dma,
|
||||||
ret = -ENOMEM;
|
req->config.size);
|
||||||
|
if (ret < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
|
||||||
|
|
||||||
if (!dma_map_sg(isp->dev, req->iovm->sgt->sgl,
|
dma_sync_sg_for_cpu(isp->dev, req->table.sgt.sgl,
|
||||||
req->iovm->sgt->nents, DMA_TO_DEVICE)) {
|
req->table.sgt.nents, DMA_TO_DEVICE);
|
||||||
ret = -ENOMEM;
|
|
||||||
req->iovm = NULL;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
dma_sync_sg_for_cpu(isp->dev, req->iovm->sgt->sgl,
|
if (copy_from_user(req->table.addr, config->lsc,
|
||||||
req->iovm->sgt->nents, DMA_TO_DEVICE);
|
req->config.size)) {
|
||||||
|
|
||||||
table = omap_da_to_va(isp->dev, req->table);
|
|
||||||
if (copy_from_user(table, config->lsc, req->config.size)) {
|
|
||||||
ret = -EFAULT;
|
ret = -EFAULT;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
dma_sync_sg_for_device(isp->dev, req->iovm->sgt->sgl,
|
dma_sync_sg_for_device(isp->dev, req->table.sgt.sgl,
|
||||||
req->iovm->sgt->nents, DMA_TO_DEVICE);
|
req->table.sgt.nents, DMA_TO_DEVICE);
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_lock_irqsave(&ccdc->lsc.req_lock, flags);
|
spin_lock_irqsave(&ccdc->lsc.req_lock, flags);
|
||||||
|
|
|
@ -57,8 +57,12 @@ struct ispccdc_lsc_config_req {
|
||||||
struct list_head list;
|
struct list_head list;
|
||||||
struct omap3isp_ccdc_lsc_config config;
|
struct omap3isp_ccdc_lsc_config config;
|
||||||
unsigned char enable;
|
unsigned char enable;
|
||||||
u32 table;
|
|
||||||
struct iovm_struct *iovm;
|
struct {
|
||||||
|
void *addr;
|
||||||
|
dma_addr_t dma;
|
||||||
|
struct sg_table sgt;
|
||||||
|
} table;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue