if (cmdlist->src_mmu_pages) {
reg = RGA_MMU_SRC_BASE - RGA_MODE_BASE_REG;
- dest[reg >> 2] = virt_to_phys(cmdlist->src_mmu_pages) >> 4;
+ dest[reg >> 2] =
+ virt_to_phys(cmdlist->src_mmu_pages) >> 4;
mmu_ctrl |= 0x7;
}
if (cmdlist->dst_mmu_pages) {
reg = RGA_MMU_DST_BASE - RGA_MODE_BASE_REG;
- dest[reg >> 2] = virt_to_phys(cmdlist->dst_mmu_pages) >> 4;
+ dest[reg >> 2] =
+ virt_to_phys(cmdlist->dst_mmu_pages) >> 4;
mmu_ctrl |= 0x7 << 8;
}
if (cmdlist->src1_mmu_pages) {
reg = RGA_MMU_SRC1_BASE - RGA_MODE_BASE_REG;
- dest[reg >> 2] = virt_to_phys(cmdlist->src1_mmu_pages) >> 4;
+ dest[reg >> 2] =
+ virt_to_phys(cmdlist->src1_mmu_pages) >> 4;
mmu_ctrl |= 0x7 << 4;
}
index = cmdlist->last - 2 * (i + 1);
reg = cmdlist->data[index];
- switch (reg) {
- case RGA_BUF_TYPE_GEMFD | RGA_DST_Y_RGB_BASE_ADDR:
- case RGA_BUF_TYPE_GEMFD | RGA_SRC_Y_RGB_BASE_ADDR:
- case RGA_BUF_TYPE_GEMFD | RGA_SRC1_RGB_BASE_ADDR:
+ switch (reg & 0xffff) {
+ case RGA_DST_Y_RGB_BASE_ADDR:
+ case RGA_SRC_Y_RGB_BASE_ADDR:
+ case RGA_SRC1_RGB_BASE_ADDR:
break;
-
- case RGA_BUF_TYPE_USERPTR | RGA_DST_Y_RGB_BASE_ADDR:
- case RGA_BUF_TYPE_USERPTR | RGA_SRC_Y_RGB_BASE_ADDR:
- case RGA_BUF_TYPE_USERPTR | RGA_SRC1_RGB_BASE_ADDR:
- goto err;
-
default:
if (reg < RGA_MODE_BASE_REG || reg > RGA_MODE_MAX_REG)
goto err;
return -EINVAL;
}
-static struct dma_buf_attachment *
-rga_gem_buf_to_pages(struct rockchip_rga *rga, void **mmu_pages, int fd)
+static struct dma_buf_attachment *rga_gem_buf_to_pages(struct rockchip_rga *rga,
+ void **mmu_pages, int fd,
+ int flush)
{
struct dma_buf_attachment *attach;
struct dma_buf *dmabuf;
for (p = 0; p < len; p++) {
dma_addr_t phys = address + (p << PAGE_SHIFT);
-
pages[mapped_size + p] = phys;
}
mapped_size += len;
}
+ if (flush)
+ dma_sync_sg_for_device(rga->drm_dev->dev, sgt->sgl, sgt->nents,
+ DMA_TO_DEVICE);
+
dma_sync_single_for_device(rga->drm_dev->dev, virt_to_phys(pages),
8 * PAGE_SIZE, DMA_TO_DEVICE);
for (i = 0; i < cmdlist->last / 2; i++) {
int index = cmdlist->last - 2 * (i + 1);
-
- switch (cmdlist->data[index]) {
- case RGA_SRC1_RGB_BASE_ADDR | RGA_BUF_TYPE_GEMFD:
- fd = cmdlist->data[index + 1];
- attach = rga_gem_buf_to_pages(rga, &mmu_pages, fd);
- if (IS_ERR(attach))
- return PTR_ERR(attach);
-
- cmdlist->src1_attach = attach;
- cmdlist->src1_mmu_pages = mmu_pages;
+ int flush = cmdlist->data[index] & RGA_BUF_TYPE_FLUSH;
+
+ switch (cmdlist->data[index] & 0xffff) {
+ case RGA_SRC1_RGB_BASE_ADDR:
+ if (cmdlist->data[index] & RGA_BUF_TYPE_GEMFD) {
+ fd = cmdlist->data[index + 1];
+ attach =
+ rga_gem_buf_to_pages(rga, &mmu_pages, fd,
+ flush);
+ if (IS_ERR(attach))
+ return PTR_ERR(attach);
+
+ cmdlist->src1_attach = attach;
+ cmdlist->src1_mmu_pages = mmu_pages;
+ }
break;
-
- case RGA_SRC_Y_RGB_BASE_ADDR | RGA_BUF_TYPE_GEMFD:
- fd = cmdlist->data[index + 1];
- attach = rga_gem_buf_to_pages(rga, &mmu_pages, fd);
- if (IS_ERR(attach))
- return PTR_ERR(attach);
-
- cmdlist->src_attach = attach;
- cmdlist->src_mmu_pages = mmu_pages;
+ case RGA_SRC_Y_RGB_BASE_ADDR:
+ if (cmdlist->data[index] & RGA_BUF_TYPE_GEMFD) {
+ fd = cmdlist->data[index + 1];
+ attach =
+ rga_gem_buf_to_pages(rga, &mmu_pages, fd,
+ flush);
+ if (IS_ERR(attach))
+ return PTR_ERR(attach);
+
+ cmdlist->src_attach = attach;
+ cmdlist->src_mmu_pages = mmu_pages;
+ }
break;
-
- case RGA_DST_Y_RGB_BASE_ADDR | RGA_BUF_TYPE_GEMFD:
- fd = cmdlist->data[index + 1];
- attach = rga_gem_buf_to_pages(rga, &mmu_pages, fd);
- if (IS_ERR(attach))
- return PTR_ERR(attach);
-
- cmdlist->dst_attach = attach;
- cmdlist->dst_mmu_pages = mmu_pages;
+ case RGA_DST_Y_RGB_BASE_ADDR:
+ if (cmdlist->data[index] & RGA_BUF_TYPE_GEMFD) {
+ fd = cmdlist->data[index + 1];
+ attach =
+ rga_gem_buf_to_pages(rga, &mmu_pages, fd,
+ flush);
+ if (IS_ERR(attach))
+ return PTR_ERR(attach);
+
+ cmdlist->dst_attach = attach;
+ cmdlist->dst_mmu_pages = mmu_pages;
+ }
break;
}
}