From 6ad5c94c75b2e33f3cf29229ecce59d875f1c1ee Mon Sep 17 00:00:00 2001 From: zsq Date: Wed, 28 Mar 2012 19:30:22 -0800 Subject: [PATCH] add yuv input support --- drivers/video/rockchip/rga/rga_drv.c | 64 +++++++++------- drivers/video/rockchip/rga/rga_mmu_info.c | 89 +++++++++++++---------- 2 files changed, 86 insertions(+), 67 deletions(-) diff --git a/drivers/video/rockchip/rga/rga_drv.c b/drivers/video/rockchip/rga/rga_drv.c index e5e5ebb3384a..9121030d319d 100755 --- a/drivers/video/rockchip/rga/rga_drv.c +++ b/drivers/video/rockchip/rga/rga_drv.c @@ -642,6 +642,13 @@ static int rga_blit_async(rga_session *session, struct rga_req *req) uint32_t saw, sah, daw, dah; req2 = NULL; + + #if RGA_TEST + printk("src.yrgb_addr = %.8x, src.uv_addr = %.8x, src.v_addr = %.8x\n", + req->src.yrgb_addr, req->src.uv_addr, req->src.v_addr); + printk("dst.yrgb_addr = %.8x, dst.uv_addr = %.8x, dst.v_addr = %.8x\n", + req->dst.yrgb_addr, req->dst.uv_addr, req->dst.v_addr); + #endif saw = req->src.act_w; sah = req->src.act_h; @@ -681,7 +688,7 @@ static int rga_blit_async(rga_session *session, struct rga_req *req) num = 1; } - rga_power_on(); + //rga_power_on(); atomic_set(®->int_enable, 1); rga_try_set_reg(num); @@ -712,6 +719,14 @@ static int rga_blit_sync(rga_session *session, struct rga_req *req) daw = req->dst.act_w; dah = req->dst.act_h; + #if RGA_TEST + + printk("src.yrgb_addr = %.8x, src.uv_addr = %.8x, src.v_addr = %.8x\n", + req->src.yrgb_addr, req->src.uv_addr, req->src.v_addr); + printk("dst.yrgb_addr = %.8x, dst.uv_addr = %.8x, dst.v_addr = %.8x\n", + req->dst.yrgb_addr, req->dst.uv_addr, req->dst.v_addr); + #endif + do { if((req->render_mode == bitblt_mode) && (((saw>>1) >= daw) || ((sah>>1) >= dah))) @@ -751,7 +766,7 @@ static int rga_blit_sync(rga_session *session, struct rga_req *req) num = 1; } - rga_power_on(); + //rga_power_on(); atomic_set(®->int_enable, 1); rga_try_set_reg(num); @@ -779,7 +794,7 @@ static int rga_blit_sync(rga_session *session, struct rga_req *req) kfree(req2); } - return ret; + return -EFAULT; } @@ -910,7 +925,7 @@ static irqreturn_t rga_irq(int irq, void *dev_id) if(((rga_read(RGA_STATUS) & 0x1) != 0))// idle { - printk("RGA is not idle!\n"); + printk(" INT ERROR RGA is not idle!\n"); rga_soft_reset(); } @@ -1236,7 +1251,7 @@ static int __init rga_init(void) mmu_buf = (uint32_t *)kmalloc(1024*8, GFP_KERNEL); if(mmu_buf == NULL) { - ERR("RGA get Pre Scale buff failed. \n"); + printk(KERN_ERR "RGA get Pre Scale buff failed. \n"); return -1; } @@ -1246,7 +1261,7 @@ static int __init rga_init(void) buf_p = (uint32_t *)__get_free_page(GFP_KERNEL); if(buf_p == NULL) { - printk("RGA init pre scale buf falied\n"); + printk(KERN_ERR "RGA init pre scale buf falied\n"); return -ENOMEM; } @@ -1257,18 +1272,10 @@ static int __init rga_init(void) if ((ret = platform_driver_register(&rga_driver)) != 0) { - ERR("Platform device register failed (%d).\n", ret); + printk(KERN_ERR "Platform device register failed (%d).\n", ret); return ret; } - #if 0 - { - uint32_t i; - for(i=0; i<10; i++) - rga_test_0(); - } - #endif - //rga_test_0(); INFO("Module initialized.\n"); @@ -1296,14 +1303,18 @@ static void __exit rga_exit(void) #if 0 + +#include "320x240_swap0_Y4200.h" +#include "320x240_swap0_UV4200.h" +#include "320x240_swap0_ABGR8888.h" + + extern struct fb_info * rk_get_fb(int fb_id); EXPORT_SYMBOL(rk_get_fb); extern void rk_direct_fb_show(struct fb_info * fbi); EXPORT_SYMBOL(rk_direct_fb_show); -extern uint32_t ABGR8888_320_240_swap0[240][320]; -//unsigned int src_buf[1280*800]; unsigned int dst_buf[1280*800]; void rga_test_0(void) @@ -1328,7 +1339,7 @@ void rga_test_0(void) fb = rk_get_fb(0); memset(&req, 0, sizeof(struct rga_req)); - src = ABGR8888_320_240_swap0; + src = Y4200_320_240_swap0; dst = dst_buf; #if 0 @@ -1348,11 +1359,11 @@ void rga_test_0(void) req.src.vir_w = 320; req.src.vir_h = 240; req.src.yrgb_addr = (uint32_t)src; - req.src.uv_addr = ((uint32_t)src + 1920*1080); - req.src.format = 0; + req.src.uv_addr = (uint32_t)UV4200_320_240_swap0; + req.src.format = 0xa; - req.dst.act_w = 320; - req.dst.act_h = 240; + req.dst.act_w = 100; + req.dst.act_h = 80; req.dst.vir_w = 1280; req.dst.vir_h = 800; @@ -1364,11 +1375,7 @@ void rga_test_0(void) req.clip.xmax = 1279; req.clip.ymin = 0; req.clip.ymax = 799; - - req.render_mode = color_fill_mode ; - req.color_fill_mode = 0; - req.fg_color = 0xa0a0a0a0; - + req.rotate_mode = 1; req.scale_mode = 2; @@ -1403,6 +1410,9 @@ void rga_test_0(void) fb->var.transp.offset = 24; fb->var.transp.msb_right = 0; + fb->var.nonstd &= (~0xff); + fb->var.nonstd |= 1; + fb->fix.smem_start = virt_to_phys(dst); rk_direct_fb_show(fb); diff --git a/drivers/video/rockchip/rga/rga_mmu_info.c b/drivers/video/rockchip/rga/rga_mmu_info.c index 7fcc95fa9c1d..467e5fcbf6dd 100755 --- a/drivers/video/rockchip/rga/rga_mmu_info.c +++ b/drivers/video/rockchip/rga/rga_mmu_info.c @@ -18,7 +18,6 @@ #include "rga_mmu_info.h" extern rga_service_info rga_service; -extern int mmu_buf[1024]; #define KERNEL_SPACE_VALID 0xc0000000 @@ -274,12 +273,11 @@ static int rga_MapUserMemory(struct page **pages, break; } - pfn = pte_pfn(*pte); - - Address = ((pfn << PAGE_SHIFT) | (((unsigned long)((Memory + i) << PAGE_SHIFT)) & ~PAGE_MASK)); - + pfn = pte_pfn(*pte); + Address = ((pfn << PAGE_SHIFT) | (((unsigned long)((Memory + i) << PAGE_SHIFT)) & ~PAGE_MASK)); pte_unmap_unlock(pte, ptl); - + + #if 0 /* Free the page table. */ if (pages != NULL) { @@ -297,6 +295,7 @@ static int rga_MapUserMemory(struct page **pages, } } } + #endif pageTable[i] = Address; } @@ -331,7 +330,9 @@ static int rga_MapUserMemory(struct page **pages, { /* Get the physical address from page struct. */ pageTable[i] = page_to_phys(pages[i]); - } + } + + return 0; } while(0); @@ -370,6 +371,7 @@ static int rga_mmu_info_BitBlt_mode(struct rga_reg *reg, struct rga_req *req) uint32_t *MMU_Base, *MMU_p; int ret; int status; + uint32_t uv_size, v_size; struct page **pages = NULL; @@ -488,20 +490,15 @@ static int rga_mmu_info_BitBlt_mode(struct rga_reg *reg, struct rga_req *req) /* zsq * change the buf address in req struct */ - #if 0 - printk("CMDMemSize is %.8x\n", CMDMemSize); - printk("SrcMemSize is %.8x\n", SrcMemSize); - printk("DstMemSize is %.8x\n", DstMemSize); - printk("CMDStart is %.8x\n", CMDStart); - printk("SrcStart is %.8x\n", SrcStart); - printk("DstStart is %.8x\n", DstStart); - #endif - req->mmu_info.base_addr = (virt_to_phys(MMU_Base)>>2); + req->mmu_info.base_addr = (virt_to_phys(MMU_Base)>>2); + uv_size = (req->src.uv_addr - (SrcStart << PAGE_SHIFT)) >> PAGE_SHIFT; + v_size = (req->src.v_addr - (SrcStart << PAGE_SHIFT)) >> PAGE_SHIFT; + req->src.yrgb_addr = (req->src.yrgb_addr & (~PAGE_MASK)) | (CMDMemSize << PAGE_SHIFT); - req->src.uv_addr = (req->src.uv_addr & (~PAGE_MASK)) | (CMDMemSize << PAGE_SHIFT); - req->src.v_addr = (req->src.v_addr & (~PAGE_MASK)) | (CMDMemSize << PAGE_SHIFT); + req->src.uv_addr = (req->src.uv_addr & (~PAGE_MASK)) | ((CMDMemSize + uv_size) << PAGE_SHIFT); + req->src.v_addr = (req->src.v_addr & (~PAGE_MASK)) | ((CMDMemSize + v_size) << PAGE_SHIFT); req->dst.yrgb_addr = (req->dst.yrgb_addr & (~PAGE_MASK)) | ((CMDMemSize + SrcMemSize) << PAGE_SHIFT); @@ -624,7 +621,7 @@ static int rga_mmu_info_color_palette_mode(struct rga_reg *reg, struct rga_req * ret = rga_MapUserMemory(&pages[CMDMemSize + SrcMemSize], &MMU_Base[CMDMemSize + SrcMemSize], DstStart, DstMemSize); if (ret < 0) { - pr_err("rga map dst memory failed"); + pr_err("rga map dst memory failed\n"); status = ret; break; } @@ -710,14 +707,14 @@ static int rga_mmu_info_color_fill_mode(struct rga_reg *reg, struct rga_req *req pages = (struct page **)kmalloc(AllSize * sizeof(struct page *), GFP_KERNEL); if(pages == NULL) { - pr_err("RGA MMU malloc pages mem failed"); + pr_err("RGA MMU malloc pages mem failed\n"); status = RGA_MALLOC_ERROR; break; } MMU_Base = (uint32_t *)kmalloc(AllSize * sizeof(uint32_t), GFP_KERNEL); if(pages == NULL) { - pr_err("RGA MMU malloc MMU_Base point failed"); + pr_err("RGA MMU malloc MMU_Base point failed\n"); status = RGA_MALLOC_ERROR; break; } @@ -730,7 +727,7 @@ static int rga_mmu_info_color_fill_mode(struct rga_reg *reg, struct rga_req *req { ret = rga_MapUserMemory(&pages[CMDMemSize], &MMU_Base[CMDMemSize], DstStart, DstMemSize); if (ret < 0) { - pr_err("rga map dst memory failed"); + pr_err("rga map dst memory failed\n"); status = ret; break; } @@ -809,14 +806,14 @@ static int rga_mmu_info_line_point_drawing_mode(struct rga_reg *reg, struct rga_ pages = (struct page **)kmalloc(AllSize * sizeof(struct page *), GFP_KERNEL); if(pages == NULL) { - pr_err("RGA MMU malloc pages mem failed"); + pr_err("RGA MMU malloc pages mem failed\n"); status = RGA_MALLOC_ERROR; break; } MMU_Base = (uint32_t *)kmalloc(AllSize * sizeof(uint32_t), GFP_KERNEL); if(pages == NULL) { - pr_err("RGA MMU malloc MMU_Base point failed"); + pr_err("RGA MMU malloc MMU_Base point failed\n"); status = RGA_MALLOC_ERROR; break; } @@ -829,7 +826,7 @@ static int rga_mmu_info_line_point_drawing_mode(struct rga_reg *reg, struct rga_ { ret = rga_MapUserMemory(&pages[CMDMemSize], &MMU_Base[CMDMemSize], DstStart, DstMemSize); if (ret < 0) { - pr_err("rga map dst memory failed"); + pr_err("rga map dst memory failed\n"); status = ret; break; } @@ -887,6 +884,7 @@ static int rga_mmu_info_blur_sharp_filter_mode(struct rga_reg *reg, struct rga_r uint32_t AllSize; uint32_t *MMU_Base, *MMU_p; int ret, status; + uint32_t uv_size, v_size; MMU_Base = NULL; @@ -980,12 +978,21 @@ static int rga_mmu_info_blur_sharp_filter_mode(struct rga_reg *reg, struct rga_r * for the reason of lie to MMU */ req->mmu_info.base_addr = (virt_to_phys(MMU_Base) >> 2); + + uv_size = (req->src.uv_addr - (SrcStart << PAGE_SHIFT)) >> PAGE_SHIFT; + v_size = (req->src.v_addr - (SrcStart << PAGE_SHIFT)) >> PAGE_SHIFT; req->src.yrgb_addr = (req->src.yrgb_addr & (~PAGE_MASK)) | (CMDMemSize << PAGE_SHIFT); - req->src.uv_addr = (req->src.uv_addr & (~PAGE_MASK)) | (CMDMemSize << PAGE_SHIFT); - req->src.v_addr = (req->src.v_addr & (~PAGE_MASK)) | (CMDMemSize << PAGE_SHIFT); + req->src.uv_addr = (req->src.uv_addr & (~PAGE_MASK)) | ((CMDMemSize + uv_size) << PAGE_SHIFT); + req->src.v_addr = (req->src.v_addr & (~PAGE_MASK)) | ((CMDMemSize + v_size) << PAGE_SHIFT); + + uv_size = (req->dst.uv_addr - (DstStart << PAGE_SHIFT)) >> PAGE_SHIFT; + v_size = (req->dst.v_addr - (DstStart << PAGE_SHIFT)) >> PAGE_SHIFT; req->dst.yrgb_addr = (req->dst.yrgb_addr & (~PAGE_MASK)) | ((CMDMemSize + SrcMemSize) << PAGE_SHIFT); + req->dst.uv_addr = (req->dst.uv_addr & (~PAGE_MASK)) | ((CMDMemSize + SrcMemSize + uv_size) << PAGE_SHIFT); + req->dst.v_addr = (req->dst.v_addr & (~PAGE_MASK)) | ((CMDMemSize + SrcMemSize + v_size) << PAGE_SHIFT); + /*record the malloc buf for the cmd end to release*/ reg->MMU_base = MMU_Base; @@ -1024,6 +1031,7 @@ static int rga_mmu_info_pre_scale_mode(struct rga_reg *reg, struct rga_req *req) uint32_t *MMU_Base, *MMU_p; int ret; int status; + uint32_t uv_size, v_size; MMU_Base = NULL; @@ -1052,15 +1060,6 @@ static int rga_mmu_info_pre_scale_mode(struct rga_reg *reg, struct rga_req *req) } AllSize = SrcMemSize + DstMemSize + CMDMemSize; - - - #if 0 - printk("AllSize = %d\n", AllSize); - printk("SrcSize = %d\n", SrcMemSize); - printk("CMDSize = %d\n", CMDMemSize); - printk("DstSize = %d\n", DstMemSize); - printk("DstStart = %d\n", DstStart); - #endif pages = (struct page **)kmalloc(AllSize * sizeof(struct page *), GFP_KERNEL); if(pages == NULL) @@ -1146,11 +1145,19 @@ static int rga_mmu_info_pre_scale_mode(struct rga_reg *reg, struct rga_req *req) req->mmu_info.base_addr = (virt_to_phys(MMU_Base)>>2); + uv_size = (req->src.uv_addr - (SrcStart << PAGE_SHIFT)) >> PAGE_SHIFT; + v_size = (req->src.v_addr - (SrcStart << PAGE_SHIFT)) >> PAGE_SHIFT; + req->src.yrgb_addr = (req->src.yrgb_addr & (~PAGE_MASK)) | (CMDMemSize << PAGE_SHIFT); - req->src.uv_addr = (req->src.uv_addr & (~PAGE_MASK)) | (CMDMemSize << PAGE_SHIFT); - req->src.v_addr = (req->src.v_addr & (~PAGE_MASK)) | (CMDMemSize << PAGE_SHIFT); + req->src.uv_addr = (req->src.uv_addr & (~PAGE_MASK)) | ((CMDMemSize + uv_size) << PAGE_SHIFT); + req->src.v_addr = (req->src.v_addr & (~PAGE_MASK)) | ((CMDMemSize + v_size) << PAGE_SHIFT); + + uv_size = (req->dst.uv_addr - (DstStart << PAGE_SHIFT)) >> PAGE_SHIFT; + v_size = (req->dst.v_addr - (DstStart << PAGE_SHIFT)) >> PAGE_SHIFT; req->dst.yrgb_addr = (req->dst.yrgb_addr & (~PAGE_MASK)) | ((CMDMemSize + SrcMemSize) << PAGE_SHIFT); + req->dst.uv_addr = (req->dst.uv_addr & (~PAGE_MASK)) | ((CMDMemSize + SrcMemSize + uv_size) << PAGE_SHIFT); + req->dst.v_addr = (req->dst.v_addr & (~PAGE_MASK)) | ((CMDMemSize + SrcMemSize + v_size) << PAGE_SHIFT); /*record the malloc buf for the cmd end to release*/ reg->MMU_base = MMU_Base; @@ -1278,7 +1285,7 @@ static int rga_mmu_info_update_palette_table_mode(struct rga_reg *reg, struct rg static int rga_mmu_info_update_patten_buff_mode(struct rga_reg *reg, struct rga_req *req) { - int SrcMemSize, DstMemSize, CMDMemSize; + int SrcMemSize, CMDMemSize; uint32_t SrcStart, CMDStart; struct page **pages = NULL; uint32_t i; @@ -1286,6 +1293,8 @@ static int rga_mmu_info_update_patten_buff_mode(struct rga_reg *reg, struct rga_ uint32_t *MMU_Base, *MMU_p; int ret, status; + MMU_Base = MMU_p = 0; + do { @@ -1301,7 +1310,7 @@ static int rga_mmu_info_update_patten_buff_mode(struct rga_reg *reg, struct rga_ return -EINVAL; } - AllSize = SrcMemSize + DstMemSize + CMDMemSize; + AllSize = SrcMemSize + CMDMemSize; pages = (struct page **)kmalloc(AllSize * sizeof(struct page *), GFP_KERNEL); if(pages == NULL) { -- 2.34.1