pos = pos->next;
list_move_tail(&pitem->list, &wq->free_queue);
spin_unlock(&wq->lock);
-
+ /* if dma buf detach it */
+ if (pitem->config.src_dma_cfg.dma_used) {
+ ge2d_dma_buffer_unmap((struct aml_dma_cfg *
+ )pitem->config.src_dma_cfg.dma_cfg);
+ pitem->config.src_dma_cfg.dma_used = 0;
+ kfree(pitem->config.src_dma_cfg.dma_cfg);
+ }
+ if (pitem->config.src2_dma_cfg.dma_used) {
+ ge2d_dma_buffer_unmap((struct aml_dma_cfg *
+ )pitem->config.src2_dma_cfg.dma_cfg);
+ pitem->config.src2_dma_cfg.dma_used = 0;
+ kfree(pitem->config.src2_dma_cfg.dma_cfg);
+ }
+ if (pitem->config.dst_dma_cfg.dma_used) {
+ ge2d_dma_buffer_unmap((struct aml_dma_cfg *
+ )pitem->config.dst_dma_cfg.dma_cfg);
+ pitem->config.dst_dma_cfg.dma_used = 0;
+ kfree(pitem->config.dst_dma_cfg.dma_cfg);
+ }
pitem = (struct ge2d_queue_item_s *)pos;
} while (pos != head);
ge2d_manager.last_wq = wq;
return IRQ_HANDLED;
}
+struct ge2d_dma_cfg_s *ge2d_wq_get_dma_cfg(struct ge2d_context_s *wq,
+ unsigned int data_type)
+{
+ struct ge2d_dma_cfg_s *dma_cfg = NULL;
+
+ switch (data_type) {
+ case AML_GE2D_SRC:
+ dma_cfg = &wq->config.src_dma_cfg;
+ break;
+ case AML_GE2D_SRC2:
+ dma_cfg = &wq->config.src2_dma_cfg;
+ break;
+ case AML_GE2D_DST:
+ dma_cfg = &wq->config.dst_dma_cfg;
+ break;
+ default:
+ ge2d_log_err("wrong data_type\n");
+ break;
+ }
+
+ return dma_cfg;
+}
+
struct ge2d_src1_data_s *ge2d_wq_get_src_data(struct ge2d_context_s *wq)
{
return &wq->config.src1_data;
}
static int build_ge2d_addr_config_dma(
+ struct ge2d_context_s *context,
struct config_planes_ion_s *plane,
unsigned int format,
unsigned int *addr,
unsigned int *stride,
- unsigned int dir
+ unsigned int dir,
+ unsigned int data_type
)
{
int ret = -1;
bpp_value);
if (plane) {
if (plane[0].shared_fd) {
- struct aml_dma_cfg cfg;
+ struct ge2d_dma_cfg_s *cfg = NULL;
+ struct aml_dma_cfg *dma_cfg = NULL;
- cfg.fd = plane[0].shared_fd;
- cfg.dev = &(ge2d_manager.pdev->dev);
- cfg.dir = dir;
- ret = ge2d_dma_buffer_get_phys(&cfg, &addr_temp);
+ cfg = ge2d_wq_get_dma_cfg(context, data_type);
+ if (!cfg)
+ return -1;
+ cfg->dma_used = 1;
+ dma_cfg = kzalloc(sizeof(*dma_cfg), GFP_KERNEL);
+ dma_cfg->fd = plane[0].shared_fd;
+ dma_cfg->dev = &(ge2d_manager.pdev->dev);
+ dma_cfg->dir = dir;
+ cfg->dma_cfg = dma_cfg;
+ ret = ge2d_dma_buffer_get_phys(dma_cfg, &addr_temp);
if (ret != 0)
return ret;
}
}
return ret;
}
-static int build_ge2d_config_ex_dma(struct config_planes_ion_s *plane,
+static int build_ge2d_config_ex_dma(struct ge2d_context_s *context,
+ struct config_planes_ion_s *plane,
unsigned int format,
unsigned int *canvas_index,
int index,
unsigned int *r_offset,
- unsigned int dir)
+ unsigned int dir,
+ unsigned int data_type)
{
int bpp_value = bpp(format);
int ret = -1;
index &= 0xff;
if (plane) {
if (plane[0].shared_fd) {
- struct aml_dma_cfg cfg;
+ struct ge2d_dma_cfg_s *cfg = NULL;
+ struct aml_dma_cfg *dma_cfg = NULL;
- cfg.fd = plane[0].shared_fd;
- cfg.dev = &(ge2d_manager.pdev->dev);
- cfg.dir = dir;
- ret = ge2d_dma_buffer_get_phys(&cfg, &addr);
+ cfg = ge2d_wq_get_dma_cfg(context, data_type);
+ if (!cfg)
+ return -1;
+ cfg->dma_used = 1;
+ dma_cfg = kzalloc(sizeof(*dma_cfg), GFP_KERNEL);
+ dma_cfg->fd = plane[0].shared_fd;
+ dma_cfg->dev = &(ge2d_manager.pdev->dev);
+ dma_cfg->dir = dir;
+ cfg->dma_cfg = dma_cfg;
+ ret = ge2d_dma_buffer_get_phys(dma_cfg, &addr);
ge2d_log_info("phys: addr=%lx\n", addr);
if (ret != 0)
return ret;
} else if (ge2d_config_mem->src1_mem_alloc_type ==
AML_GE2D_MEM_DMABUF) {
if (build_ge2d_addr_config_dma(
+ context,
&ge2d_config->src_planes[0],
ge2d_config->src_para.format,
&src_addr,
&src_stride,
- DMA_TO_DEVICE) < 0)
+ DMA_TO_DEVICE,
+ AML_GE2D_SRC) < 0)
return -1;
ge2d_log_dbg("ge2d dma alloc phy_addr:0x%x,stride=0x%x,format:0x%x\n",
src_addr,
} else if (ge2d_config_mem->src1_mem_alloc_type ==
AML_GE2D_MEM_DMABUF) {
if (build_ge2d_config_ex_dma(
+ context,
&ge2d_config->src_planes[0],
ge2d_config->src_para.format,
&index,
ALLOC_CANVAS_INDEX +
alloc_canvas_offset,
&alloc_canvas_offset,
- DMA_TO_DEVICE) < 0)
+ DMA_TO_DEVICE,
+ AML_GE2D_SRC) < 0)
return -1;
ge2d_config->src_para.canvas_index = index;
ge2d_log_dbg("ge2d dma alloc canvas index:0x%x, format:0x%x\n",
} else if (ge2d_config_mem->src2_mem_alloc_type ==
AML_GE2D_MEM_DMABUF) {
if (build_ge2d_addr_config_dma(
+ context,
&ge2d_config->src2_planes[0],
ge2d_config->src2_para.format,
&src2_addr,
&src2_stride,
- DMA_TO_DEVICE) < 0)
+ DMA_TO_DEVICE,
+ AML_GE2D_SRC2) < 0)
return -1;
ge2d_log_dbg("ge2d dma alloc phy_addr:0x%x,stride=0x%x,format:0x%x\n",
src2_addr,
} else if (ge2d_config_mem->src2_mem_alloc_type ==
AML_GE2D_MEM_DMABUF) {
if (build_ge2d_config_ex_dma(
+ context,
&ge2d_config->src2_planes[0],
ge2d_config->src2_para.format,
&index,
ALLOC_CANVAS_INDEX +
alloc_canvas_offset,
&alloc_canvas_offset,
- DMA_TO_DEVICE) < 0)
+ DMA_TO_DEVICE,
+ AML_GE2D_SRC2) < 0)
return -1;
ge2d_config->src2_para.canvas_index = index;
ge2d_log_dbg("ge2d src2 dma alloc, canvas index:0x%x,format:0x%x\n",
} else if (ge2d_config_mem->dst_mem_alloc_type ==
AML_GE2D_MEM_DMABUF) {
if (build_ge2d_addr_config_dma(
+ context,
&ge2d_config->dst_planes[0],
ge2d_config->dst_para.format,
&dst_addr,
&dst_stride,
- DMA_FROM_DEVICE) < 0)
+ DMA_FROM_DEVICE,
+ AML_GE2D_DST) < 0)
return -1;
ge2d_log_dbg("ge2d dma alloc phy_addr:0x%x,stride=0x%x,format:0x%x\n",
dst_addr,
} else if (ge2d_config_mem->dst_mem_alloc_type ==
AML_GE2D_MEM_DMABUF) {
if (build_ge2d_config_ex_dma(
+ context,
&ge2d_config->dst_planes[0],
ge2d_config->dst_para.format,
&index,
ALLOC_CANVAS_INDEX +
alloc_canvas_offset,
&alloc_canvas_offset,
- DMA_FROM_DEVICE) < 0)
+ DMA_FROM_DEVICE,
+ AML_GE2D_DST) < 0)
return -1;
ge2d_config->dst_para.canvas_index = index;
ge2d_log_dbg("ge2d: dst dma alloc, index:0x%x, format:0x%x\n",