video/rockchip: rga2: Support 8K resolution.

Signed-off-by: Yu Qiaowei <cerf.yu@rock-chips.com>
Change-Id: Icf7a3aa835560abab1b7d6981952aa1534a4f694
This commit is contained in:
Yu Qiaowei
2021-03-10 10:42:45 +08:00
committed by Tao Huang
parent e59ba88fc6
commit 190b684905
2 changed files with 35 additions and 10 deletions

View File

@@ -570,6 +570,9 @@ struct rga2_mmu_buf_t {
unsigned int *buf_virtual;
struct page **pages;
u8 buf_order;
u8 pages_order;
};
enum

View File

@@ -65,9 +65,16 @@
#define RGA2_TEST_FLUSH_TIME 0
#define RGA2_INFO_BUS_ERROR 1
#define RGA2_POWER_OFF_DELAY 4*HZ /* 4s */
#define RGA2_TIMEOUT_DELAY (HZ / 5) /* 200ms */
#define RGA2_TIMEOUT_DELAY (HZ / 2) /* 500ms */
#define RGA2_MAJOR 255
#define RGA2_RESET_TIMEOUT 1000
/*
* The maximum input is 8192*8192, the maximum output is 4096*4096
* The size of physical pages requested is:
* ( ( maximum_input_value * maximum_input_value * format_bpp ) / 4K_page_size ) + 1
*/
#define RGA2_PHY_PAGE_SIZE (((8192 * 8192 * 4) / 4096) + 1)
/* Driver information */
#define DRIVER_DESC "RGA2 Device Driver"
@@ -769,7 +776,7 @@ static int rga2_check_param(const struct rga2_req *req)
{
if(!((req->render_mode == color_fill_mode)))
{
if (unlikely((req->src.act_w <= 0) || (req->src.act_w > 8191) || (req->src.act_h <= 0) || (req->src.act_h > 8191)))
if (unlikely((req->src.act_w <= 0) || (req->src.act_w > 8192) || (req->src.act_h <= 0) || (req->src.act_h > 8192)))
{
printk("invalid source resolution act_w = %d, act_h = %d\n", req->src.act_w, req->src.act_h);
return -EINVAL;
@@ -778,7 +785,7 @@ static int rga2_check_param(const struct rga2_req *req)
if(!((req->render_mode == color_fill_mode)))
{
if (unlikely((req->src.vir_w <= 0) || (req->src.vir_w > 8191) || (req->src.vir_h <= 0) || (req->src.vir_h > 8191)))
if (unlikely((req->src.vir_w <= 0) || (req->src.vir_w > 8192) || (req->src.vir_h <= 0) || (req->src.vir_h > 8192)))
{
printk("invalid source resolution vir_w = %d, vir_h = %d\n", req->src.vir_w, req->src.vir_h);
return -EINVAL;
@@ -1485,7 +1492,6 @@ static int rga2_blit(rga2_session *session, struct rga2_req *req)
return -EFAULT;
}
#endif
do {
/* check value if legal */
ret = rga2_check_param(req);
@@ -2600,12 +2606,22 @@ void rga2_test_0(void);
static int __init rga2_init(void)
{
int ret;
int order = 0;
uint32_t *buf_p;
uint32_t *buf;
/* malloc pre scale mid buf mmu table */
buf_p = kmalloc(1024*256, GFP_KERNEL);
/*
* malloc pre scale mid buf mmu table:
* RGA2_PHY_PAGE_SIZE * channel_num * address_size
*/
order = get_order(RGA2_PHY_PAGE_SIZE * 3 * sizeof(buf_p));
buf_p = (uint32_t *)__get_free_pages(GFP_KERNEL, order);
if (buf_p == NULL) {
ERR("Can not alloc pages for mmu_page_table\n");
}
rga2_mmu_buf.buf_virtual = buf_p;
rga2_mmu_buf.buf_order = order;
#if (defined(CONFIG_ARM) && defined(CONFIG_ARM_LPAE))
buf = (uint32_t *)(uint32_t)virt_to_phys((void *)((unsigned long)buf_p));
#else
@@ -2613,10 +2629,15 @@ static int __init rga2_init(void)
#endif
rga2_mmu_buf.buf = buf;
rga2_mmu_buf.front = 0;
rga2_mmu_buf.back = 64*1024;
rga2_mmu_buf.size = 64*1024;
rga2_mmu_buf.back = RGA2_PHY_PAGE_SIZE * 3;
rga2_mmu_buf.size = RGA2_PHY_PAGE_SIZE * 3;
rga2_mmu_buf.pages = kmalloc(32768 * sizeof(struct page *), GFP_KERNEL);
order = get_order(RGA2_PHY_PAGE_SIZE * sizeof(struct page *));
rga2_mmu_buf.pages = (struct page **)__get_free_pages(GFP_KERNEL, order);
if (rga2_mmu_buf.pages == NULL) {
ERR("Can not alloc pages for rga2_mmu_buf.pages\n");
}
rga2_mmu_buf.pages_order = order;
ret = platform_driver_register(&rga2_driver);
if (ret != 0) {
@@ -2655,7 +2676,8 @@ static void __exit rga2_exit(void)
{
rga2_power_off();
kfree(rga2_mmu_buf.buf_virtual);
free_pages((unsigned long)rga2_mmu_buf.buf_virtual, rga2_mmu_buf.buf_order);
free_pages((unsigned long)rga2_mmu_buf.pages, rga2_mmu_buf.pages_order);
platform_driver_unregister(&rga2_driver);
}