media: rockchip: ispp: reserved memory using rdma_sg ops

Change-Id: I7bc3cb977c56fc6c81c15baa67d38e3ce59a409f
Signed-off-by: Cai YiWei <cyw@rock-chips.com>
This commit is contained in:
Cai YiWei
2021-06-04 14:36:13 +08:00
committed by Tao Huang
parent 72e161eacb
commit dd1b793a86
4 changed files with 17 additions and 9 deletions

View File

@@ -86,7 +86,7 @@ int rkispp_allow_buffer(struct rkispp_device *dev,
}
buf->mem_priv = mem_priv;
if (dev->hw_dev->is_mmu) {
if (dev->hw_dev->is_dma_sg_ops) {
sg_tbl = (struct sg_table *)g_ops->cookie(mem_priv);
buf->dma_addr = sg_dma_address(sg_tbl->sgl);
} else {
@@ -312,7 +312,7 @@ static int rkispp_init_pool(struct rkispp_hw_dev *hw, struct rkisp_ispp_buf *dbu
ret = g_ops->map_dmabuf(mem);
if (ret)
goto err;
if (hw->is_mmu) {
if (hw->is_dma_sg_ops) {
sg_tbl = (struct sg_table *)g_ops->cookie(mem);
pool->dma[i] = sg_dma_address(sg_tbl->sgl);
} else {

View File

@@ -227,6 +227,7 @@ static int rkispp_hw_probe(struct platform_device *pdev)
struct rkispp_hw_dev *hw_dev;
struct resource *res;
int i, ret, irq;
bool is_mem_reserved = true;
match = of_match_node(rkispp_hw_of_match, node);
if (IS_ERR(match))
@@ -325,23 +326,29 @@ static int rkispp_hw_probe(struct platform_device *pdev)
hw_dev->is_single = true;
hw_dev->is_fec_ext = false;
hw_dev->is_dma_contig = true;
hw_dev->is_dma_sg_ops = false;
hw_dev->is_shutdown = false;
hw_dev->is_first = true;
hw_dev->first_frame_dma = -1;
hw_dev->is_mmu = is_iommu_enable(dev);
ret = of_reserved_mem_device_init(dev);
if (ret) {
is_mem_reserved = false;
if (!hw_dev->is_mmu)
dev_warn(dev, "No reserved memory region. default cma area!\n");
dev_info(dev, "No reserved memory region. default cma area!\n");
else
hw_dev->is_dma_contig = false;
}
if (!hw_dev->is_mmu)
hw_dev->mem_ops = &vb2_dma_contig_memops;
else if (!hw_dev->is_dma_contig)
hw_dev->mem_ops = &vb2_dma_sg_memops;
else
if (is_mem_reserved) {
/* reserved memory using rdma_sg */
hw_dev->mem_ops = &vb2_rdma_sg_memops;
hw_dev->is_dma_sg_ops = true;
} else if (hw_dev->is_mmu) {
hw_dev->mem_ops = &vb2_dma_sg_memops;
hw_dev->is_dma_sg_ops = true;
} else {
hw_dev->mem_ops = &vb2_dma_contig_memops;
}
rkispp_register_fec(hw_dev);
pm_runtime_enable(&pdev->dev);

View File

@@ -59,6 +59,7 @@ struct rkispp_hw_dev {
bool is_single;
bool is_fec_ext;
bool is_dma_contig;
bool is_dma_sg_ops;
bool is_shutdown;
bool is_first;
};

View File

@@ -1505,7 +1505,7 @@ static void rkispp_buf_queue(struct vb2_buffer *vb)
memset(isppbuf->buff_addr, 0, sizeof(isppbuf->buff_addr));
for (i = 0; i < cap_fmt->mplanes; i++) {
vb2_plane_vaddr(vb, i);
if (stream->isppdev->hw_dev->is_mmu) {
if (stream->isppdev->hw_dev->is_dma_sg_ops) {
sgt = vb2_dma_sg_plane_desc(vb, i);
isppbuf->buff_addr[i] = sg_dma_address(sgt->sgl);
} else {