From: zsq Date: Mon, 11 Aug 2014 07:24:58 +0000 (+0800) Subject: rga mmu use ionmmu passed X-Git-Tag: firefly_0821_release~4916^2~13 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=0e7e9ec42cc07f821b04e0d5d17cbf4225e88d16;p=firefly-linux-kernel-4.4.55.git rga mmu use ionmmu passed --- diff --git a/arch/arm/boot/dts/rk312x.dtsi b/arch/arm/boot/dts/rk312x.dtsi index 04e51f2ee1d8..35aa3c9c4dd8 100755 --- a/arch/arm/boot/dts/rk312x.dtsi +++ b/arch/arm/boot/dts/rk312x.dtsi @@ -709,7 +709,7 @@ }; rga: rga@1010c000 { - compatible = "rockchip,rga_drv"; + compatible = "rockchip,rk312x-rga"; reg = <0x1010c000 0x1000>; interrupts = ; clocks = <&clk_gates0 11>, <&clk_gates1 4>; diff --git a/drivers/video/rockchip/rga/rga.h b/drivers/video/rockchip/rga/rga.h index fbd36e2f1f33..bd121895cc4e 100755 --- a/drivers/video/rockchip/rga/rga.h +++ b/drivers/video/rockchip/rga/rga.h @@ -383,8 +383,6 @@ typedef struct rga_service_info { uint32_t *pre_scale_buf; atomic_t int_disable; /* 0 int enable 1 int disable */ atomic_t cmd_num; - atomic_t src_format_swt; - int last_prc_src_format; atomic_t rga_working; bool enable; diff --git a/drivers/video/rockchip/rga/rga_drv.c b/drivers/video/rockchip/rga/rga_drv.c index 59b571eaacac..2a506f805ec0 100755 --- a/drivers/video/rockchip/rga/rga_drv.c +++ b/drivers/video/rockchip/rga/rga_drv.c @@ -151,6 +151,8 @@ static void print_info(struct rga_req *req) printk("clip.xmin = %d, clip.xmax = %d. clip.ymin = %d, clip.ymax = %d\n", req->clip.xmin, req->clip.xmax, req->clip.ymin, req->clip.ymax); + printk("mmu_flag = %.8x\n", req->mmu_info.mmu_flag); + //printk("alpha_rop_flag = %.8x\n", req->alpha_rop_flag); //printk("alpha_rop_mode = %.8x\n", req->alpha_rop_mode); //printk("PD_mode = %.8x\n", req->PD_mode); @@ -1198,7 +1200,7 @@ static struct miscdevice rga_dev ={ #if defined(CONFIG_OF) static const struct of_device_id rockchip_rga_dt_ids[] = { - { .compatible = "rockchip,rga_drv", }, + { .compatible = "rockchip,rk312x-rga", }, {}, }; #endif @@ -1213,8 +1215,6 @@ static int rga_drv_probe(struct platform_device *pdev) mutex_init(&rga_service.lock); mutex_init(&rga_service.mutex); atomic_set(&rga_service.total_running, 0); - atomic_set(&rga_service.src_format_swt, 0); - rga_service.last_prc_src_format = 1; /* default is yuv first*/ rga_service.enable = false; rga_ioctl_kernel_p = rga_ioctl_kernel_imp; diff --git a/drivers/video/rockchip/rga/rga_mmu_info.c b/drivers/video/rockchip/rga/rga_mmu_info.c index a0152787a03c..dbbc43c6aea9 100755 --- a/drivers/video/rockchip/rga/rga_mmu_info.c +++ b/drivers/video/rockchip/rga/rga_mmu_info.c @@ -467,7 +467,6 @@ static int rga_mmu_info_BitBlt_mode(struct rga_reg *reg, struct rga_req *req) return -EINVAL; } - /* Cal out the needed mem size */ AllSize = SrcMemSize + DstMemSize; @@ -485,8 +484,7 @@ static int rga_mmu_info_BitBlt_mode(struct rga_reg *reg, struct rga_req *req) break; } - if((req->mmu_info.mmu_flag >> 8) & 1) - { + if((req->mmu_info.mmu_flag >> 8) & 1) { if (req->sg_src) { ret = rga_MapION(req->sg_src, &MMU_Base[0], SrcMemSize); } @@ -499,18 +497,12 @@ static int rga_mmu_info_BitBlt_mode(struct rga_reg *reg, struct rga_req *req) } } } - else - { + else { MMU_p = MMU_Base; - if(req->src.yrgb_addr == (uint32_t)rga_service.pre_scale_buf) - { - /* Down scale ratio over 2, Last prc */ - /* MMU table copy from pre scale table */ - + if(req->src.yrgb_addr == (uint32_t)rga_service.pre_scale_buf) { for(i=0; immu_info.mmu_flag >> 10) & 1) { - ret = rga_MapUserMemory(&pages[SrcMemSize], &MMU_Base[SrcMemSize], DstStart, DstMemSize); - if (ret < 0) { - pr_err("rga map dst memory failed\n"); - status = ret; - break; + if (req->sg_dst) { + ret = rga_MapION(req->sg_dst, &MMU_Base[SrcMemSize], DstMemSize); + } + else { + ret = rga_MapUserMemory(&pages[SrcMemSize], &MMU_Base[SrcMemSize], DstStart, DstMemSize); + if (ret < 0) { + pr_err("rga map dst memory failed\n"); + status = ret; + break; + } } } else { MMU_p = MMU_Base + SrcMemSize; - for(i=0; isrc.uv_addr = (req->src.uv_addr & (~PAGE_MASK)) | (uv_size << PAGE_SHIFT); req->src.v_addr = (req->src.v_addr & (~PAGE_MASK)) | (v_size << PAGE_SHIFT); + uv_size = (req->dst.uv_addr - (DstStart << PAGE_SHIFT)) >> PAGE_SHIFT; + req->dst.yrgb_addr = (req->dst.yrgb_addr & (~PAGE_MASK)) | (SrcMemSize << PAGE_SHIFT); + req->dst.uv_addr = (req->dst.uv_addr & (~PAGE_MASK)) | ((SrcMemSize + uv_size) << PAGE_SHIFT); /*record the malloc buf for the cmd end to release*/ reg->MMU_base = MMU_Base; @@ -762,23 +761,23 @@ static int rga_mmu_info_color_fill_mode(struct rga_reg *reg, struct rga_req *req break; } - if (req->dst.yrgb_addr < KERNEL_SPACE_VALID) - { - ret = rga_MapUserMemory(&pages[0], &MMU_Base[0], DstStart, DstMemSize); - if (ret < 0) { - pr_err("rga map dst memory failed\n"); - status = ret; - break; + if (req->dst.yrgb_addr < KERNEL_SPACE_VALID) { + if (req->sg_dst) { + ret = rga_MapION(req->sg_dst, &MMU_Base[0], DstMemSize); + } + else { + ret = rga_MapUserMemory(&pages[0], &MMU_Base[0], DstStart, DstMemSize); + if (ret < 0) { + pr_err("rga map dst memory failed\n"); + status = ret; + break; + } } } - else - { + else { MMU_p = MMU_Base; - for(i=0; isrc.yrgb_addr, req->src.uv_addr, req->src.v_addr, req->src.format, req->src.vir_w, req->src.vir_h, @@ -1079,8 +1077,7 @@ static int rga_mmu_info_pre_scale_mode(struct rga_reg *reg, struct rga_req *req) AllSize = SrcMemSize + DstMemSize; pages = kzalloc((AllSize)* sizeof(struct page *), GFP_KERNEL); - if(pages == NULL) - { + if(pages == NULL) { pr_err("RGA MMU malloc pages mem failed\n"); status = RGA_MALLOC_ERROR; break; @@ -1098,55 +1095,51 @@ static int rga_mmu_info_pre_scale_mode(struct rga_reg *reg, struct rga_req *req) } /* map src pages */ - if (req->src.yrgb_addr < KERNEL_SPACE_VALID) - { - ret = rga_MapUserMemory(&pages[0], &MMU_Base[0], SrcStart, SrcMemSize); - if (ret < 0) { - pr_err("rga map src memory failed\n"); - status = ret; - break; + if ((req->mmu_info.mmu_flag >> 8) & 1) { + if (req->sg_src) { + ret = rga_MapION(req->sg_src, &MMU_Base[0], SrcMemSize); + } + else { + ret = rga_MapUserMemory(&pages[0], &MMU_Base[0], SrcStart, SrcMemSize); + if (ret < 0) { + pr_err("rga map src memory failed\n"); + status = ret; + break; + } } } - else - { + else { MMU_p = MMU_Base; for(i=0; idst.yrgb_addr >= KERNEL_SPACE_VALID) + if((req->mmu_info.mmu_flag >> 10) & 1) { + if (req->sg_dst) { + ret = rga_MapION(req->sg_dst, &MMU_Base[SrcMemSize], DstMemSize); + } + else { + ret = rga_MapUserMemory(&pages[SrcMemSize], &MMU_Base[SrcMemSize], DstStart, DstMemSize); + if (ret < 0) { + pr_err("rga map dst memory failed\n"); + status = ret; + break; + } + } + } + else { /* kernel space */ MMU_p = MMU_Base + SrcMemSize; - if(req->dst.yrgb_addr == (uint32_t)rga_service.pre_scale_buf) - { + if(req->dst.yrgb_addr == (uint32_t)rga_service.pre_scale_buf) { for(i=0; i