.. | .. |
---|
1 | | -/*
|
---|
2 | | - * Copyright (C) 2012 ROCKCHIP, Inc.
|
---|
3 | | - *
|
---|
4 | | - * This software is licensed under the terms of the GNU General Public
|
---|
5 | | - * License version 2, as published by the Free Software Foundation, and
|
---|
6 | | - * may be copied, distributed, and modified under those terms.
|
---|
7 | | - *
|
---|
8 | | - * This program is distributed in the hope that it will be useful,
|
---|
9 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
10 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
11 | | - * GNU General Public License for more details.
|
---|
12 | | - *
|
---|
13 | | - */
|
---|
14 | | -
|
---|
15 | | -#define pr_fmt(fmt) "rga: " fmt
|
---|
16 | | -#include <linux/kernel.h>
|
---|
17 | | -#include <linux/init.h>
|
---|
18 | | -#include <linux/module.h>
|
---|
19 | | -#include <linux/platform_device.h>
|
---|
20 | | -#include <linux/sched.h>
|
---|
21 | | -#include <linux/mutex.h>
|
---|
22 | | -#include <linux/err.h>
|
---|
23 | | -#include <linux/clk.h>
|
---|
24 | | -#include <asm/delay.h>
|
---|
25 | | -#include <linux/dma-mapping.h>
|
---|
26 | | -#include <linux/delay.h>
|
---|
27 | | -#include <asm/io.h>
|
---|
28 | | -#include <linux/irq.h>
|
---|
29 | | -#include <linux/interrupt.h>
|
---|
30 | | -//#include <mach/io.h>
|
---|
31 | | -//#include <mach/irqs.h>
|
---|
32 | | -#include <linux/fs.h>
|
---|
33 | | -#include <linux/uaccess.h>
|
---|
34 | | -#include <linux/miscdevice.h>
|
---|
35 | | -#include <linux/poll.h>
|
---|
36 | | -#include <linux/delay.h>
|
---|
37 | | -#include <linux/wait.h>
|
---|
38 | | -#include <linux/syscalls.h>
|
---|
39 | | -#include <linux/timer.h>
|
---|
40 | | -#include <linux/time.h>
|
---|
41 | | -#include <asm/cacheflush.h>
|
---|
42 | | -#include <linux/slab.h>
|
---|
43 | | -#include <linux/fb.h>
|
---|
44 | | -#include <linux/wakelock.h>
|
---|
| 1 | +/* |
---|
| 2 | + * Copyright (C) 2012 ROCKCHIP, Inc. |
---|
| 3 | + * |
---|
| 4 | + * This software is licensed under the terms of the GNU General Public |
---|
| 5 | + * License version 2, as published by the Free Software Foundation, and |
---|
| 6 | + * may be copied, distributed, and modified under those terms. |
---|
| 7 | + * |
---|
| 8 | + * This program is distributed in the hope that it will be useful, |
---|
| 9 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 10 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 11 | + * GNU General Public License for more details. |
---|
| 12 | + * |
---|
| 13 | + */ |
---|
| 14 | + |
---|
| 15 | +#define pr_fmt(fmt) "rga: " fmt |
---|
| 16 | +#include <linux/kernel.h> |
---|
| 17 | +#include <linux/init.h> |
---|
| 18 | +#include <linux/module.h> |
---|
| 19 | +#include <linux/platform_device.h> |
---|
| 20 | +#include <linux/sched.h> |
---|
| 21 | +#include <linux/mutex.h> |
---|
| 22 | +#include <linux/err.h> |
---|
| 23 | +#include <linux/clk.h> |
---|
| 24 | +#include <asm/delay.h> |
---|
| 25 | +#include <linux/dma-mapping.h> |
---|
| 26 | +#include <linux/delay.h> |
---|
| 27 | +#include <asm/io.h> |
---|
| 28 | +#include <linux/irq.h> |
---|
| 29 | +#include <linux/interrupt.h> |
---|
| 30 | +//#include <mach/io.h> |
---|
| 31 | +//#include <mach/irqs.h> |
---|
| 32 | +#include <linux/fs.h> |
---|
| 33 | +#include <linux/uaccess.h> |
---|
| 34 | +#include <linux/miscdevice.h> |
---|
| 35 | +#include <linux/poll.h> |
---|
| 36 | +#include <linux/delay.h> |
---|
| 37 | +#include <linux/wait.h> |
---|
| 38 | +#include <linux/syscalls.h> |
---|
| 39 | +#include <linux/timer.h> |
---|
| 40 | +#include <linux/time.h> |
---|
| 41 | +#include <asm/cacheflush.h> |
---|
| 42 | +#include <linux/slab.h> |
---|
| 43 | +#include <linux/fb.h> |
---|
| 44 | +#include <linux/wakelock.h> |
---|
45 | 45 | #include <linux/version.h> |
---|
46 | 46 | #include <linux/debugfs.h> |
---|
47 | 47 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) |
---|
.. | .. |
---|
53 | 53 | #include <linux/rockchip_ion.h> |
---|
54 | 54 | #endif |
---|
55 | 55 | |
---|
56 | | -#include "rga.h"
|
---|
57 | | -#include "rga_reg_info.h"
|
---|
58 | | -#include "rga_mmu_info.h"
|
---|
59 | | -#include "RGA_API.h"
|
---|
60 | | -
|
---|
61 | | -#define RGA_TEST_CASE 0
|
---|
62 | | -
|
---|
63 | | -#define RGA_TEST_FLUSH_TIME 0
|
---|
64 | | -#define RGA_INFO_BUS_ERROR 1
|
---|
65 | | -
|
---|
66 | | -#define PRE_SCALE_BUF_SIZE 2048*1024*4
|
---|
67 | | -
|
---|
68 | | -#define RGA_POWER_OFF_DELAY 4*HZ /* 4s */
|
---|
69 | | -#define RGA_TIMEOUT_DELAY 2*HZ /* 2s */
|
---|
70 | | -
|
---|
71 | | -#define RGA_MAJOR 255
|
---|
72 | | -
|
---|
73 | | -#if defined(CONFIG_ARCH_RK2928) || defined(CONFIG_ARCH_RK3026)
|
---|
74 | | -#define RK30_RGA_PHYS RK2928_RGA_PHYS
|
---|
75 | | -#define RK30_RGA_SIZE RK2928_RGA_SIZE
|
---|
76 | | -#endif
|
---|
77 | | -#define RGA_RESET_TIMEOUT 1000
|
---|
78 | | -
|
---|
79 | | -/* Driver information */
|
---|
80 | | -#define DRIVER_DESC "RGA Device Driver"
|
---|
81 | | -#define DRIVER_NAME "rga"
|
---|
82 | | -
|
---|
83 | | -
|
---|
84 | | -ktime_t rga_start;
|
---|
85 | | -ktime_t rga_end;
|
---|
86 | | -
|
---|
87 | | -rga_session rga_session_global;
|
---|
88 | | -
|
---|
89 | | -long (*rga_ioctl_kernel_p)(struct rga_req *);
|
---|
90 | | -
|
---|
| 56 | +#include "rga.h" |
---|
| 57 | +#include "rga_reg_info.h" |
---|
| 58 | +#include "rga_mmu_info.h" |
---|
| 59 | +#include "RGA_API.h" |
---|
| 60 | + |
---|
| 61 | +#define RGA_TEST_CASE 0 |
---|
| 62 | + |
---|
| 63 | +#define RGA_TEST_FLUSH_TIME 0 |
---|
| 64 | +#define RGA_INFO_BUS_ERROR 1 |
---|
| 65 | + |
---|
| 66 | +#define RGA_PRE_SCALE_BUF_SIZE (2048 * 2048 * 4) |
---|
| 67 | +#define RGA_PRE_SCALE_PAGE_SIZE (RGA_PRE_SCALE_BUF_SIZE >> PAGE_SHIFT) |
---|
| 68 | + |
---|
| 69 | +#define RGA_POWER_OFF_DELAY 4*HZ /* 4s */ |
---|
| 70 | +#define RGA_TIMEOUT_DELAY 2*HZ /* 2s */ |
---|
| 71 | + |
---|
| 72 | +#define RGA_MAJOR 255 |
---|
| 73 | + |
---|
| 74 | +#if defined(CONFIG_ARCH_RK2928) || defined(CONFIG_ARCH_RK3026) |
---|
| 75 | +#define RK30_RGA_PHYS RK2928_RGA_PHYS |
---|
| 76 | +#define RK30_RGA_SIZE RK2928_RGA_SIZE |
---|
| 77 | +#endif |
---|
| 78 | +#define RGA_RESET_TIMEOUT 1000 |
---|
| 79 | + |
---|
| 80 | +/* Driver information */ |
---|
| 81 | +#define DRIVER_DESC "RGA Device Driver" |
---|
| 82 | +#define DRIVER_NAME "rga" |
---|
| 83 | + |
---|
| 84 | + |
---|
| 85 | +ktime_t rga_start; |
---|
| 86 | +ktime_t rga_end; |
---|
| 87 | + |
---|
| 88 | +static rga_session rga_session_global; |
---|
| 89 | + |
---|
| 90 | +long (*rga_ioctl_kernel_p)(struct rga_req *); |
---|
| 91 | + |
---|
91 | 92 | #if RGA_DEBUGFS |
---|
92 | 93 | unsigned char RGA_TEST_REG; |
---|
93 | 94 | unsigned char RGA_TEST_MSG; |
---|
.. | .. |
---|
96 | 97 | unsigned char RGA_NONUSE; |
---|
97 | 98 | unsigned char RGA_INT_FLAG; |
---|
98 | 99 | #endif |
---|
99 | | -
|
---|
100 | | -struct rga_drvdata {
|
---|
101 | | - struct miscdevice miscdev;
|
---|
102 | | - struct device *dev; |
---|
103 | | - void *rga_base;
|
---|
104 | | - int irq;
|
---|
105 | | -
|
---|
106 | | - struct delayed_work power_off_work;
|
---|
107 | | - void (*rga_irq_callback)(int rga_retval); //callback function used by aync call
|
---|
108 | | - struct wake_lock wake_lock;
|
---|
109 | | -
|
---|
110 | | - struct clk *pd_rga;
|
---|
111 | | - struct clk *aclk_rga;
|
---|
112 | | - struct clk *hclk_rga;
|
---|
113 | | -
|
---|
114 | | - //#if defined(CONFIG_ION_ROCKCHIP) |
---|
115 | | - struct ion_client *ion_client; |
---|
116 | | - //#endif |
---|
117 | | - char *version; |
---|
118 | | -};
|
---|
119 | | -
|
---|
120 | | -static struct rga_drvdata *drvdata;
|
---|
121 | | -rga_service_info rga_service;
|
---|
122 | | -struct rga_mmu_buf_t rga_mmu_buf;
|
---|
123 | | -
|
---|
124 | | -
|
---|
125 | | -#if defined(CONFIG_ION_ROCKCHIP)
|
---|
126 | | -extern struct ion_client *rockchip_ion_client_create(const char * name);
|
---|
127 | | -#endif
|
---|
128 | | -
|
---|
129 | | -static int rga_blit_async(rga_session *session, struct rga_req *req);
|
---|
130 | | -static void rga_del_running_list(void);
|
---|
131 | | -static void rga_del_running_list_timeout(void);
|
---|
132 | | -static void rga_try_set_reg(void);
|
---|
133 | | -
|
---|
134 | | -
|
---|
135 | | -/* Logging */
|
---|
136 | | -#define RGA_DEBUG 1
|
---|
137 | | -#if RGA_DEBUG
|
---|
138 | | -#define DBG(format, args...) printk(KERN_DEBUG "%s: " format, DRIVER_NAME, ## args)
|
---|
139 | | -#define ERR(format, args...) printk(KERN_ERR "%s: " format, DRIVER_NAME, ## args)
|
---|
140 | | -#define WARNING(format, args...) printk(KERN_WARN "%s: " format, DRIVER_NAME, ## args)
|
---|
141 | | -#define INFO(format, args...) printk(KERN_INFO "%s: " format, DRIVER_NAME, ## args)
|
---|
142 | | -#else
|
---|
143 | | -#define DBG(format, args...)
|
---|
144 | | -#define ERR(format, args...)
|
---|
145 | | -#define WARNING(format, args...)
|
---|
146 | | -#define INFO(format, args...)
|
---|
147 | | -#endif
|
---|
148 | | -
|
---|
| 100 | + |
---|
| 101 | +struct rga_drvdata *rga_drvdata; |
---|
| 102 | +rga_service_info rga_service; |
---|
| 103 | +struct rga_mmu_buf_t rga_mmu_buf; |
---|
| 104 | + |
---|
| 105 | + |
---|
| 106 | +#if defined(CONFIG_ION_ROCKCHIP) |
---|
| 107 | +extern struct ion_client *rockchip_ion_client_create(const char * name); |
---|
| 108 | +#endif |
---|
| 109 | + |
---|
| 110 | +static int rga_blit_async(rga_session *session, struct rga_req *req); |
---|
| 111 | +static void rga_del_running_list(void); |
---|
| 112 | +static void rga_del_running_list_timeout(void); |
---|
| 113 | +static void rga_try_set_reg(void); |
---|
| 114 | + |
---|
| 115 | + |
---|
| 116 | +/* Logging */ |
---|
| 117 | +#define RGA_DEBUG 1 |
---|
| 118 | +#if RGA_DEBUG |
---|
| 119 | +#define DBG(format, args...) printk(KERN_DEBUG "%s: " format, DRIVER_NAME, ## args) |
---|
| 120 | +#define ERR(format, args...) printk(KERN_ERR "%s: " format, DRIVER_NAME, ## args) |
---|
| 121 | +#define WARNING(format, args...) printk(KERN_WARN "%s: " format, DRIVER_NAME, ## args) |
---|
| 122 | +#define INFO(format, args...) printk(KERN_INFO "%s: " format, DRIVER_NAME, ## args) |
---|
| 123 | +#else |
---|
| 124 | +#define DBG(format, args...) |
---|
| 125 | +#define ERR(format, args...) |
---|
| 126 | +#define WARNING(format, args...) |
---|
| 127 | +#define INFO(format, args...) |
---|
| 128 | +#endif |
---|
| 129 | + |
---|
149 | 130 | #if RGA_DEBUGFS |
---|
150 | 131 | static const char *rga_get_cmd_mode_str(u32 cmd) |
---|
151 | 132 | { |
---|
.. | .. |
---|
219 | 200 | else if (req_rga->sina == -65536 && req_rga->cosa == 0) |
---|
220 | 201 | /* totate 270 */ |
---|
221 | 202 | return "rotate 270 "; |
---|
| 203 | + return "UNF"; |
---|
222 | 204 | case 0x2: |
---|
223 | 205 | return "xmirror"; |
---|
224 | 206 | case 0x3: |
---|
.. | .. |
---|
427 | 409 | } |
---|
428 | 410 | #endif |
---|
429 | 411 | |
---|
430 | | -static inline void rga_write(u32 b, u32 r)
|
---|
431 | | -{
|
---|
432 | | - __raw_writel(b, drvdata->rga_base + r);
|
---|
433 | | -}
|
---|
434 | | -
|
---|
435 | | -static inline u32 rga_read(u32 r)
|
---|
436 | | -{
|
---|
437 | | - return __raw_readl(drvdata->rga_base + r);
|
---|
438 | | -}
|
---|
439 | | -
|
---|
440 | | -static void rga_soft_reset(void)
|
---|
441 | | -{
|
---|
442 | | - u32 i;
|
---|
443 | | - u32 reg;
|
---|
444 | | -
|
---|
445 | | - rga_write(1, RGA_SYS_CTRL); //RGA_SYS_CTRL
|
---|
446 | | -
|
---|
447 | | - for(i = 0; i < RGA_RESET_TIMEOUT; i++)
|
---|
448 | | - {
|
---|
449 | | - reg = rga_read(RGA_SYS_CTRL) & 1; //RGA_SYS_CTRL
|
---|
450 | | -
|
---|
451 | | - if(reg == 0)
|
---|
452 | | - break;
|
---|
453 | | -
|
---|
454 | | - udelay(1);
|
---|
455 | | - }
|
---|
456 | | -
|
---|
457 | | - if(i == RGA_RESET_TIMEOUT)
|
---|
458 | | - ERR("soft reset timeout.\n");
|
---|
459 | | -}
|
---|
460 | | -
|
---|
461 | | -static void rga_dump(void)
|
---|
462 | | -{
|
---|
463 | | - int running;
|
---|
464 | | - struct rga_reg *reg, *reg_tmp;
|
---|
465 | | - rga_session *session, *session_tmp;
|
---|
466 | | -
|
---|
467 | | - running = atomic_read(&rga_service.total_running);
|
---|
468 | | - printk("rga total_running %d\n", running);
|
---|
469 | | -
|
---|
470 | | - #if 0
|
---|
471 | | -
|
---|
472 | | - /* Dump waiting list info */
|
---|
473 | | - if (!list_empty(&rga_service.waiting))
|
---|
474 | | - {
|
---|
475 | | - list_head *next;
|
---|
476 | | -
|
---|
477 | | - next = &rga_service.waiting;
|
---|
478 | | -
|
---|
479 | | - printk("rga_service dump waiting list\n");
|
---|
480 | | -
|
---|
481 | | - do
|
---|
482 | | - {
|
---|
483 | | - reg = list_entry(next->next, struct rga_reg, status_link);
|
---|
484 | | - running = atomic_read(®->session->task_running);
|
---|
485 | | - num_done = atomic_read(®->session->num_done);
|
---|
486 | | - printk("rga session pid %d, done %d, running %d\n", reg->session->pid, num_done, running);
|
---|
487 | | - next = next->next;
|
---|
488 | | - }
|
---|
489 | | - while(!list_empty(next));
|
---|
490 | | - }
|
---|
491 | | -
|
---|
492 | | - /* Dump running list info */
|
---|
493 | | - if (!list_empty(&rga_service.running))
|
---|
494 | | - {
|
---|
495 | | - printk("rga_service dump running list\n");
|
---|
496 | | -
|
---|
497 | | - list_head *next;
|
---|
498 | | -
|
---|
499 | | - next = &rga_service.running;
|
---|
500 | | - do
|
---|
501 | | - {
|
---|
502 | | - reg = list_entry(next->next, struct rga_reg, status_link);
|
---|
503 | | - running = atomic_read(®->session->task_running);
|
---|
504 | | - num_done = atomic_read(®->session->num_done);
|
---|
505 | | - printk("rga session pid %d, done %d, running %d:\n", reg->session->pid, num_done, running);
|
---|
506 | | - next = next->next;
|
---|
507 | | - }
|
---|
508 | | - while(!list_empty(next));
|
---|
509 | | - }
|
---|
510 | | - #endif
|
---|
511 | | -
|
---|
512 | | - list_for_each_entry_safe(session, session_tmp, &rga_service.session, list_session)
|
---|
513 | | - {
|
---|
514 | | - printk("session pid %d:\n", session->pid);
|
---|
515 | | - running = atomic_read(&session->task_running);
|
---|
516 | | - printk("task_running %d\n", running);
|
---|
517 | | - list_for_each_entry_safe(reg, reg_tmp, &session->waiting, session_link)
|
---|
518 | | - {
|
---|
| 412 | +static inline void rga_write(u32 b, u32 r) |
---|
| 413 | +{ |
---|
| 414 | + __raw_writel(b, rga_drvdata->rga_base + r); |
---|
| 415 | +} |
---|
| 416 | + |
---|
| 417 | +static inline u32 rga_read(u32 r) |
---|
| 418 | +{ |
---|
| 419 | + return __raw_readl(rga_drvdata->rga_base + r); |
---|
| 420 | +} |
---|
| 421 | + |
---|
| 422 | +static void rga_soft_reset(void) |
---|
| 423 | +{ |
---|
| 424 | + u32 i; |
---|
| 425 | + u32 reg; |
---|
| 426 | + |
---|
| 427 | + rga_write(1, RGA_SYS_CTRL); //RGA_SYS_CTRL |
---|
| 428 | + |
---|
| 429 | + for(i = 0; i < RGA_RESET_TIMEOUT; i++) |
---|
| 430 | + { |
---|
| 431 | + reg = rga_read(RGA_SYS_CTRL) & 1; //RGA_SYS_CTRL |
---|
| 432 | + |
---|
| 433 | + if(reg == 0) |
---|
| 434 | + break; |
---|
| 435 | + |
---|
| 436 | + udelay(1); |
---|
| 437 | + } |
---|
| 438 | + |
---|
| 439 | + if(i == RGA_RESET_TIMEOUT) |
---|
| 440 | + ERR("soft reset timeout.\n"); |
---|
| 441 | +} |
---|
| 442 | + |
---|
| 443 | +static void rga_dump(void) |
---|
| 444 | +{ |
---|
| 445 | + int running; |
---|
| 446 | + struct rga_reg *reg, *reg_tmp; |
---|
| 447 | + rga_session *session, *session_tmp; |
---|
| 448 | + |
---|
| 449 | + running = atomic_read(&rga_service.total_running); |
---|
| 450 | + printk("rga total_running %d\n", running); |
---|
| 451 | + |
---|
| 452 | + #if 0 |
---|
| 453 | + |
---|
| 454 | + /* Dump waiting list info */ |
---|
| 455 | + if (!list_empty(&rga_service.waiting)) |
---|
| 456 | + { |
---|
| 457 | + list_head *next; |
---|
| 458 | + |
---|
| 459 | + next = &rga_service.waiting; |
---|
| 460 | + |
---|
| 461 | + printk("rga_service dump waiting list\n"); |
---|
| 462 | + |
---|
| 463 | + do |
---|
| 464 | + { |
---|
| 465 | + reg = list_entry(next->next, struct rga_reg, status_link); |
---|
| 466 | + running = atomic_read(®->session->task_running); |
---|
| 467 | + num_done = atomic_read(®->session->num_done); |
---|
| 468 | + printk("rga session pid %d, done %d, running %d\n", reg->session->pid, num_done, running); |
---|
| 469 | + next = next->next; |
---|
| 470 | + } |
---|
| 471 | + while(!list_empty(next)); |
---|
| 472 | + } |
---|
| 473 | + |
---|
| 474 | + /* Dump running list info */ |
---|
| 475 | + if (!list_empty(&rga_service.running)) |
---|
| 476 | + { |
---|
| 477 | + printk("rga_service dump running list\n"); |
---|
| 478 | + |
---|
| 479 | + list_head *next; |
---|
| 480 | + |
---|
| 481 | + next = &rga_service.running; |
---|
| 482 | + do |
---|
| 483 | + { |
---|
| 484 | + reg = list_entry(next->next, struct rga_reg, status_link); |
---|
| 485 | + running = atomic_read(®->session->task_running); |
---|
| 486 | + num_done = atomic_read(®->session->num_done); |
---|
| 487 | + printk("rga session pid %d, done %d, running %d:\n", reg->session->pid, num_done, running); |
---|
| 488 | + next = next->next; |
---|
| 489 | + } |
---|
| 490 | + while(!list_empty(next)); |
---|
| 491 | + } |
---|
| 492 | + #endif |
---|
| 493 | + |
---|
| 494 | + list_for_each_entry_safe(session, session_tmp, &rga_service.session, list_session) |
---|
| 495 | + { |
---|
| 496 | + printk("session pid %d:\n", session->pid); |
---|
| 497 | + running = atomic_read(&session->task_running); |
---|
| 498 | + printk("task_running %d\n", running); |
---|
| 499 | + list_for_each_entry_safe(reg, reg_tmp, &session->waiting, session_link) |
---|
| 500 | + { |
---|
519 | 501 | printk("waiting register set 0x %.lu\n", (unsigned long)reg); |
---|
520 | | - }
|
---|
521 | | - list_for_each_entry_safe(reg, reg_tmp, &session->running, session_link)
|
---|
522 | | - {
|
---|
| 502 | + } |
---|
| 503 | + list_for_each_entry_safe(reg, reg_tmp, &session->running, session_link) |
---|
| 504 | + { |
---|
523 | 505 | printk("running register set 0x %.lu\n", (unsigned long)reg); |
---|
524 | | - }
|
---|
525 | | - }
|
---|
526 | | -}
|
---|
527 | | -
|
---|
528 | | -static inline void rga_queue_power_off_work(void)
|
---|
529 | | -{
|
---|
| 506 | + } |
---|
| 507 | + } |
---|
| 508 | +} |
---|
| 509 | + |
---|
| 510 | +static inline void rga_queue_power_off_work(void) |
---|
| 511 | +{ |
---|
530 | 512 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) |
---|
531 | | - queue_delayed_work(system_wq, &drvdata->power_off_work, RGA_POWER_OFF_DELAY);
|
---|
| 513 | + queue_delayed_work(system_wq, &rga_drvdata->power_off_work, RGA_POWER_OFF_DELAY); |
---|
532 | 514 | #else |
---|
533 | | - queue_delayed_work(system_nrt_wq, &drvdata->power_off_work, RGA_POWER_OFF_DELAY); |
---|
| 515 | + queue_delayed_work(system_nrt_wq, &rga_drvdata->power_off_work, RGA_POWER_OFF_DELAY); |
---|
534 | 516 | #endif |
---|
535 | | -}
|
---|
536 | | -
|
---|
537 | | -/* Caller must hold rga_service.lock */
|
---|
538 | | -static void rga_power_on(void)
|
---|
539 | | -{
|
---|
540 | | - static ktime_t last;
|
---|
541 | | - ktime_t now = ktime_get();
|
---|
542 | | -
|
---|
543 | | - if (ktime_to_ns(ktime_sub(now, last)) > NSEC_PER_SEC) {
|
---|
544 | | - cancel_delayed_work_sync(&drvdata->power_off_work);
|
---|
545 | | - rga_queue_power_off_work();
|
---|
546 | | - last = now;
|
---|
547 | | - }
|
---|
548 | | - if (rga_service.enable)
|
---|
549 | | - return;
|
---|
550 | | -
|
---|
| 517 | +} |
---|
| 518 | + |
---|
| 519 | +/* Caller must hold rga_service.lock */ |
---|
| 520 | +static void rga_power_on(void) |
---|
| 521 | +{ |
---|
| 522 | + static ktime_t last; |
---|
| 523 | + ktime_t now = ktime_get(); |
---|
| 524 | + |
---|
| 525 | + if (ktime_to_ns(ktime_sub(now, last)) > NSEC_PER_SEC) { |
---|
| 526 | + cancel_delayed_work_sync(&rga_drvdata->power_off_work); |
---|
| 527 | + rga_queue_power_off_work(); |
---|
| 528 | + last = now; |
---|
| 529 | + } |
---|
| 530 | + if (rga_service.enable) |
---|
| 531 | + return; |
---|
| 532 | + |
---|
551 | 533 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) |
---|
552 | | - clk_prepare_enable(drvdata->aclk_rga); |
---|
553 | | - clk_prepare_enable(drvdata->hclk_rga); |
---|
554 | | - pm_runtime_get_sync(drvdata->dev); |
---|
| 534 | + clk_prepare_enable(rga_drvdata->aclk_rga); |
---|
| 535 | + clk_prepare_enable(rga_drvdata->hclk_rga); |
---|
| 536 | + pm_runtime_get_sync(rga_drvdata->dev); |
---|
555 | 537 | #else |
---|
556 | | - clk_prepare_enable(drvdata->aclk_rga); |
---|
557 | | - clk_prepare_enable(drvdata->hclk_rga); |
---|
558 | | - if (drvdata->pd_rga) |
---|
559 | | - clk_prepare_enable(drvdata->pd_rga); |
---|
| 538 | + clk_prepare_enable(rga_drvdata->aclk_rga); |
---|
| 539 | + clk_prepare_enable(rga_drvdata->hclk_rga); |
---|
| 540 | + if (rga_drvdata->pd_rga) |
---|
| 541 | + clk_prepare_enable(rga_drvdata->pd_rga); |
---|
560 | 542 | #endif |
---|
561 | 543 | |
---|
562 | | - wake_lock(&drvdata->wake_lock);
|
---|
563 | | - rga_service.enable = true;
|
---|
564 | | -}
|
---|
| 544 | + wake_lock(&rga_drvdata->wake_lock); |
---|
| 545 | + rga_service.enable = true; |
---|
| 546 | +} |
---|
565 | 547 | |
---|
566 | | -/* Caller must hold rga_service.lock */
|
---|
567 | | -static void rga_power_off(void)
|
---|
568 | | -{
|
---|
569 | | - int total_running;
|
---|
570 | | -
|
---|
571 | | - if (!rga_service.enable) {
|
---|
572 | | - return;
|
---|
573 | | - }
|
---|
574 | | -
|
---|
575 | | - total_running = atomic_read(&rga_service.total_running);
|
---|
576 | | - if (total_running) {
|
---|
577 | | - pr_err("power off when %d task running!!\n", total_running);
|
---|
578 | | - mdelay(50);
|
---|
579 | | - pr_err("delay 50 ms for running task\n");
|
---|
580 | | - rga_dump();
|
---|
581 | | - }
|
---|
582 | | -
|
---|
| 548 | +/* Caller must hold rga_service.lock */ |
---|
| 549 | +static void rga_power_off(void) |
---|
| 550 | +{ |
---|
| 551 | + int total_running; |
---|
| 552 | + |
---|
| 553 | + if (!rga_service.enable) { |
---|
| 554 | + return; |
---|
| 555 | + } |
---|
| 556 | + |
---|
| 557 | + total_running = atomic_read(&rga_service.total_running); |
---|
| 558 | + if (total_running) { |
---|
| 559 | + pr_err("power off when %d task running!!\n", total_running); |
---|
| 560 | + mdelay(50); |
---|
| 561 | + pr_err("delay 50 ms for running task\n"); |
---|
| 562 | + rga_dump(); |
---|
| 563 | + } |
---|
| 564 | + |
---|
583 | 565 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) |
---|
584 | | - pm_runtime_put(drvdata->dev); |
---|
585 | | - clk_disable_unprepare(drvdata->aclk_rga); |
---|
586 | | - clk_disable_unprepare(drvdata->hclk_rga); |
---|
| 566 | + pm_runtime_put(rga_drvdata->dev); |
---|
| 567 | + clk_disable_unprepare(rga_drvdata->aclk_rga); |
---|
| 568 | + clk_disable_unprepare(rga_drvdata->hclk_rga); |
---|
587 | 569 | #else |
---|
588 | | - if (drvdata->pd_rga) |
---|
589 | | - clk_disable_unprepare(drvdata->pd_rga); |
---|
590 | | - clk_disable_unprepare(drvdata->aclk_rga); |
---|
591 | | - clk_disable_unprepare(drvdata->hclk_rga); |
---|
| 570 | + if (rga_drvdata->pd_rga) |
---|
| 571 | + clk_disable_unprepare(rga_drvdata->pd_rga); |
---|
| 572 | + clk_disable_unprepare(rga_drvdata->aclk_rga); |
---|
| 573 | + clk_disable_unprepare(rga_drvdata->hclk_rga); |
---|
592 | 574 | #endif |
---|
593 | | - wake_unlock(&drvdata->wake_lock);
|
---|
594 | | - rga_service.enable = false;
|
---|
595 | | -}
|
---|
596 | | -
|
---|
597 | | -static void rga_power_off_work(struct work_struct *work)
|
---|
598 | | -{
|
---|
599 | | - if (mutex_trylock(&rga_service.lock)) {
|
---|
600 | | - rga_power_off();
|
---|
601 | | - mutex_unlock(&rga_service.lock);
|
---|
602 | | - } else {
|
---|
603 | | - /* Come back later if the device is busy... */
|
---|
| 575 | + wake_unlock(&rga_drvdata->wake_lock); |
---|
| 576 | + rga_service.enable = false; |
---|
| 577 | +} |
---|
| 578 | + |
---|
| 579 | +static void rga_power_off_work(struct work_struct *work) |
---|
| 580 | +{ |
---|
| 581 | + if (mutex_trylock(&rga_service.lock)) { |
---|
| 582 | + rga_power_off(); |
---|
| 583 | + mutex_unlock(&rga_service.lock); |
---|
| 584 | + } else { |
---|
| 585 | + /* Come back later if the device is busy... */ |
---|
604 | 586 | |
---|
605 | 587 | rga_queue_power_off_work(); |
---|
606 | 588 | } |
---|
.. | .. |
---|
647 | 629 | |
---|
648 | 630 | static int rga_get_result(rga_session *session, unsigned long arg) |
---|
649 | 631 | { |
---|
650 | | - //printk("rga_get_result %d\n",drvdata->rga_result); |
---|
| 632 | + //printk("rga_get_result %d\n",rga_drvdata->rga_result); |
---|
651 | 633 | |
---|
652 | 634 | int ret = 0; |
---|
653 | 635 | |
---|
.. | .. |
---|
734 | 716 | cmd_buf = (uint32_t *)rga_service.cmd_buff + offset*32; |
---|
735 | 717 | reg_p = (uint32_t *)reg->cmd_reg; |
---|
736 | 718 | |
---|
737 | | - for(i=0; i<32; i++)
|
---|
| 719 | + for(i=0; i<32; i++) |
---|
738 | 720 | cmd_buf[i] = reg_p[i]; |
---|
739 | 721 | } |
---|
740 | 722 | |
---|
.. | .. |
---|
842 | 824 | |
---|
843 | 825 | rga_copy_reg(reg, 0); |
---|
844 | 826 | rga_reg_from_wait_to_run(reg); |
---|
845 | | - #ifdef CONFIG_ARM |
---|
846 | | - dmac_flush_range(&rga_service.cmd_buff[0], &rga_service.cmd_buff[32]); |
---|
847 | | - outer_flush_range(virt_to_phys(&rga_service.cmd_buff[0]),virt_to_phys(&rga_service.cmd_buff[32])); |
---|
848 | | - #elif defined(CONFIG_ARM64) |
---|
849 | | - __dma_flush_range(&rga_service.cmd_buff[0], &rga_service.cmd_buff[32]); |
---|
850 | | - #endif |
---|
| 827 | + rga_dma_flush_range(&rga_service.cmd_buff[0], &rga_service.cmd_buff[32]); |
---|
851 | 828 | |
---|
852 | 829 | rga_soft_reset(); |
---|
853 | 830 | |
---|
.. | .. |
---|
874 | 851 | rga_write((0x1<<2)|(0x1<<3), RGA_SYS_CTRL); |
---|
875 | 852 | |
---|
876 | 853 | /* All CMD finish int */ |
---|
877 | | - rga_write(rga_read(RGA_INT)|(0x1<<10)|(0x1<<8), RGA_INT); |
---|
| 854 | + rga_write(rga_read(RGA_INT)|(0x1<<10)|(0x1<<9)|(0x1<<8), RGA_INT); |
---|
878 | 855 | |
---|
879 | 856 | #if RGA_DEBUGFS |
---|
880 | | - if (RGA_TEST_REG) |
---|
| 857 | + if (RGA_TEST_TIME) |
---|
881 | 858 | rga_start = ktime_get(); |
---|
882 | 859 | #endif |
---|
883 | 860 | |
---|
.. | .. |
---|
1034 | 1011 | dst_offset = req->line_draw_info.line_width; |
---|
1035 | 1012 | |
---|
1036 | 1013 | if (req->src.yrgb_addr) { |
---|
1037 | | - hdl = ion_import_dma_buf(drvdata->ion_client, req->src.yrgb_addr); |
---|
| 1014 | + hdl = ion_import_dma_buf(rga_drvdata->ion_client, req->src.yrgb_addr); |
---|
1038 | 1015 | if (IS_ERR(hdl)) { |
---|
1039 | 1016 | ret = PTR_ERR(hdl); |
---|
1040 | 1017 | pr_err("RGA ERROR ion buf handle\n"); |
---|
.. | .. |
---|
1049 | 1026 | |
---|
1050 | 1027 | #if RGA_DEBUGFS |
---|
1051 | 1028 | if (RGA_CHECK_MODE) { |
---|
1052 | | - vaddr = ion_map_kernel(drvdata->ion_client, hdl); |
---|
| 1029 | + vaddr = ion_map_kernel(rga_drvdata->ion_client, hdl); |
---|
1053 | 1030 | if (vaddr) |
---|
1054 | 1031 | rga_memory_check(vaddr, req->src.vir_h, req->src.vir_w, |
---|
1055 | 1032 | req->src.format, req->src.yrgb_addr); |
---|
1056 | | - ion_unmap_kernel(drvdata->ion_client, hdl); |
---|
| 1033 | + ion_unmap_kernel(rga_drvdata->ion_client, hdl); |
---|
1057 | 1034 | } |
---|
1058 | 1035 | #endif |
---|
1059 | 1036 | if ((req->mmu_info.mmu_flag >> 8) & 1) { |
---|
1060 | | - req->sg_src = ion_sg_table(drvdata->ion_client, hdl); |
---|
| 1037 | + req->sg_src = ion_sg_table(rga_drvdata->ion_client, hdl); |
---|
1061 | 1038 | req->src.yrgb_addr = req->src.uv_addr; |
---|
1062 | 1039 | req->src.uv_addr = req->src.yrgb_addr + (req->src.vir_w * req->src.vir_h); |
---|
1063 | 1040 | req->src.v_addr = req->src.uv_addr + (req->src.vir_w * req->src.vir_h)/4; |
---|
1064 | 1041 | } |
---|
1065 | 1042 | else { |
---|
1066 | | - ion_phys(drvdata->ion_client, hdl, &phy_addr, &len); |
---|
| 1043 | + ion_phys(rga_drvdata->ion_client, hdl, &phy_addr, &len); |
---|
1067 | 1044 | req->src.yrgb_addr = phy_addr + src_offset; |
---|
1068 | 1045 | req->src.uv_addr = req->src.yrgb_addr + (req->src.vir_w * req->src.vir_h); |
---|
1069 | 1046 | req->src.v_addr = req->src.uv_addr + (req->src.vir_w * req->src.vir_h)/4; |
---|
1070 | 1047 | } |
---|
1071 | | - ion_free(drvdata->ion_client, hdl); |
---|
| 1048 | + ion_free(rga_drvdata->ion_client, hdl); |
---|
1072 | 1049 | } |
---|
1073 | 1050 | else { |
---|
1074 | 1051 | req->src.yrgb_addr = req->src.uv_addr; |
---|
.. | .. |
---|
1077 | 1054 | } |
---|
1078 | 1055 | |
---|
1079 | 1056 | if(req->dst.yrgb_addr) { |
---|
1080 | | - hdl = ion_import_dma_buf(drvdata->ion_client, req->dst.yrgb_addr); |
---|
| 1057 | + hdl = ion_import_dma_buf(rga_drvdata->ion_client, req->dst.yrgb_addr); |
---|
1081 | 1058 | if (IS_ERR(hdl)) { |
---|
1082 | 1059 | ret = PTR_ERR(hdl); |
---|
1083 | 1060 | printk("RGA2 ERROR ion buf handle\n"); |
---|
.. | .. |
---|
1092 | 1069 | |
---|
1093 | 1070 | #if RGA_DEBUGFS |
---|
1094 | 1071 | if (RGA_CHECK_MODE) { |
---|
1095 | | - vaddr = ion_map_kernel(drvdata->ion_client, hdl); |
---|
| 1072 | + vaddr = ion_map_kernel(rga_drvdata->ion_client, hdl); |
---|
1096 | 1073 | if (vaddr) |
---|
1097 | 1074 | rga_memory_check(vaddr, req->src.vir_h, req->src.vir_w, |
---|
1098 | 1075 | req->src.format, req->src.yrgb_addr); |
---|
1099 | | - ion_unmap_kernel(drvdata->ion_client, hdl); |
---|
| 1076 | + ion_unmap_kernel(rga_drvdata->ion_client, hdl); |
---|
1100 | 1077 | } |
---|
1101 | 1078 | #endif |
---|
1102 | 1079 | if ((req->mmu_info.mmu_flag >> 10) & 1) { |
---|
1103 | | - req->sg_dst = ion_sg_table(drvdata->ion_client, hdl); |
---|
| 1080 | + req->sg_dst = ion_sg_table(rga_drvdata->ion_client, hdl); |
---|
1104 | 1081 | req->dst.yrgb_addr = req->dst.uv_addr; |
---|
1105 | 1082 | req->dst.uv_addr = req->dst.yrgb_addr + (req->dst.vir_w * req->dst.vir_h); |
---|
1106 | 1083 | req->dst.v_addr = req->dst.uv_addr + (req->dst.vir_w * req->dst.vir_h)/4; |
---|
1107 | 1084 | } |
---|
1108 | 1085 | else { |
---|
1109 | | - ion_phys(drvdata->ion_client, hdl, &phy_addr, &len); |
---|
| 1086 | + ion_phys(rga_drvdata->ion_client, hdl, &phy_addr, &len); |
---|
1110 | 1087 | req->dst.yrgb_addr = phy_addr + dst_offset; |
---|
1111 | 1088 | req->dst.uv_addr = req->dst.yrgb_addr + (req->dst.vir_w * req->dst.vir_h); |
---|
1112 | 1089 | req->dst.v_addr = req->dst.uv_addr + (req->dst.vir_w * req->dst.vir_h)/4; |
---|
1113 | 1090 | } |
---|
1114 | | - ion_free(drvdata->ion_client, hdl); |
---|
| 1091 | + ion_free(rga_drvdata->ion_client, hdl); |
---|
1115 | 1092 | } |
---|
1116 | 1093 | else { |
---|
1117 | 1094 | req->dst.yrgb_addr = req->dst.uv_addr; |
---|
.. | .. |
---|
1138 | 1115 | int ret = 0; |
---|
1139 | 1116 | void *vaddr = NULL; |
---|
1140 | 1117 | |
---|
1141 | | - rga_dev = drvdata->dev; |
---|
| 1118 | + rga_dev = rga_drvdata->dev; |
---|
1142 | 1119 | yrgb_addr = (int)img->yrgb_addr; |
---|
1143 | 1120 | vir_w = img->vir_w; |
---|
1144 | 1121 | vir_h = img->vir_h; |
---|
.. | .. |
---|
1590 | 1567 | if (RGA_TEST_TIME) { |
---|
1591 | 1568 | rga_end = ktime_get(); |
---|
1592 | 1569 | rga_end = ktime_sub(rga_end, rga_start); |
---|
1593 | | - DBG("sync one cmd end time %d\n", (int)ktime_to_us(rga_end)); |
---|
| 1570 | + DBG("sync one cmd end time %d us\n", (int)ktime_to_us(rga_end)); |
---|
1594 | 1571 | } |
---|
1595 | 1572 | #endif |
---|
1596 | 1573 | |
---|
.. | .. |
---|
1618 | 1595 | memset(&req, 0x0, sizeof(req)); |
---|
1619 | 1596 | #if RGA_DEBUGFS |
---|
1620 | 1597 | if (RGA_TEST_MSG) |
---|
1621 | | - DBG("cmd is %s\n", rga_get_cmd_mode_str(cmd)); |
---|
| 1598 | + DBG("cmd is %s(0x%x)\n", rga_get_cmd_mode_str(cmd), cmd); |
---|
1622 | 1599 | if (RGA_NONUSE) { |
---|
1623 | 1600 | mutex_unlock(&rga_service.mutex); |
---|
1624 | 1601 | return 0; |
---|
.. | .. |
---|
1658 | 1635 | ret = rga_get_result(session, arg); |
---|
1659 | 1636 | break; |
---|
1660 | 1637 | case RGA_GET_VERSION: |
---|
1661 | | - if (!drvdata->version) { |
---|
1662 | | - drvdata->version = kzalloc(16, GFP_KERNEL); |
---|
1663 | | - if (!drvdata->version) { |
---|
| 1638 | + if (!rga_drvdata->version) { |
---|
| 1639 | + rga_drvdata->version = kzalloc(16, GFP_KERNEL); |
---|
| 1640 | + if (!rga_drvdata->version) { |
---|
1664 | 1641 | ret = -ENOMEM; |
---|
1665 | 1642 | break; |
---|
1666 | 1643 | } |
---|
1667 | 1644 | rga_power_on(); |
---|
1668 | 1645 | udelay(1); |
---|
1669 | 1646 | if (rga_read(RGA_VERSION) == 0x02018632) |
---|
1670 | | - snprintf(drvdata->version, 16, "1.6"); |
---|
| 1647 | + snprintf(rga_drvdata->version, 16, "1.6"); |
---|
1671 | 1648 | else |
---|
1672 | | - snprintf(drvdata->version, 16, "1.003"); |
---|
| 1649 | + snprintf(rga_drvdata->version, 16, "1.003"); |
---|
1673 | 1650 | } |
---|
1674 | 1651 | |
---|
1675 | | - ret = copy_to_user((void *)arg, drvdata->version, 16); |
---|
| 1652 | + ret = copy_to_user((void *)arg, rga_drvdata->version, 16); |
---|
1676 | 1653 | break; |
---|
1677 | 1654 | default: |
---|
1678 | | - ERR("unknown ioctl cmd!\n"); |
---|
1679 | 1655 | ret = -EINVAL; |
---|
1680 | 1656 | break; |
---|
1681 | 1657 | } |
---|
.. | .. |
---|
1764 | 1740 | { |
---|
1765 | 1741 | pr_err("rga_service session %d still has %d task running when closing\n", session->pid, task_running); |
---|
1766 | 1742 | msleep(100); |
---|
1767 | | - /*ͬ²½*/ |
---|
1768 | 1743 | } |
---|
1769 | 1744 | |
---|
1770 | 1745 | wake_up(&session->wait); |
---|
.. | .. |
---|
1801 | 1776 | DBG("irq INT[%x], STATS[%x]\n", rga_read(RGA_INT), rga_read(RGA_STATUS)); |
---|
1802 | 1777 | #endif |
---|
1803 | 1778 | /*if error interrupt then soft reset hardware*/ |
---|
1804 | | - if (rga_read(RGA_INT) & 0x01) { |
---|
| 1779 | + if (rga_read(RGA_INT) & 0x03) { |
---|
1805 | 1780 | pr_err("Err irq INT[%x], STATS[%x]\n", rga_read(RGA_INT), rga_read(RGA_STATUS)); |
---|
1806 | 1781 | rga_soft_reset(); |
---|
1807 | 1782 | } |
---|
1808 | 1783 | /*clear INT */ |
---|
1809 | | - rga_write(rga_read(RGA_INT) | (0x1<<6) | (0x1<<7) | (0x1<<4), RGA_INT); |
---|
| 1784 | + rga_write(rga_read(RGA_INT) | (0x1<<6) | (0x1<<7) | (0x1<<5) | (0x1<<4), RGA_INT); |
---|
1810 | 1785 | |
---|
1811 | 1786 | return IRQ_WAKE_THREAD; |
---|
1812 | 1787 | } |
---|
.. | .. |
---|
1892 | 1867 | |
---|
1893 | 1868 | platform_set_drvdata(pdev, data); |
---|
1894 | 1869 | data->dev = &pdev->dev; |
---|
1895 | | - drvdata = data; |
---|
| 1870 | + rga_drvdata = data; |
---|
1896 | 1871 | |
---|
1897 | 1872 | #if defined(CONFIG_ION_ROCKCHIP) |
---|
1898 | 1873 | data->ion_client = rockchip_ion_client_create("rga"); |
---|
.. | .. |
---|
2094 | 2069 | unsigned int *pstd; |
---|
2095 | 2070 | unsigned int *pnow; |
---|
2096 | 2071 | |
---|
2097 | | - data = drvdata; |
---|
| 2072 | + data = rga_drvdata; |
---|
2098 | 2073 | srcW = 1280; |
---|
2099 | 2074 | srcH = 720; |
---|
2100 | 2075 | dstW = 1280; |
---|
.. | .. |
---|
2235 | 2210 | memset(src1_buf, 0x50, 400 * 200 * 4); |
---|
2236 | 2211 | memset(dst1_buf, 0x00, 400 * 200 * 4); |
---|
2237 | 2212 | |
---|
2238 | | -#ifdef CONFIG_ARM |
---|
2239 | | - dmac_flush_range(&src1_buf[0], &src1_buf[400 * 200]); |
---|
2240 | | - outer_flush_range(virt_to_phys(&src1_buf[0]), virt_to_phys(&src1_buf[400 * 200])); |
---|
2241 | | - dmac_flush_range(&dst1_buf[0], &dst1_buf[400 * 200]); |
---|
2242 | | - outer_flush_range(virt_to_phys(&dst1_buf[0]), virt_to_phys(&dst1_buf[400 * 200])); |
---|
2243 | | -#elif defined(CONFIG_ARM64) |
---|
2244 | | - __dma_flush_range(&src1_buf[0], &src1_buf[400 * 200]); |
---|
2245 | | - __dma_flush_range(&dst1_buf[0], &dst1_buf[400 * 200]); |
---|
2246 | | -#endif |
---|
| 2213 | + rga_dma_flush_range(&src1_buf[0], &src1_buf[400 * 200]); |
---|
2247 | 2214 | |
---|
2248 | 2215 | DBG("\n********************************\n"); |
---|
2249 | 2216 | DBG("************ RGA_TEST ************\n"); |
---|
.. | .. |
---|
2304 | 2271 | } |
---|
2305 | 2272 | #endif |
---|
2306 | 2273 | #endif |
---|
2307 | | -
|
---|
2308 | | -void rga_test_0(void);
|
---|
2309 | | -void rga_test_1(void);
|
---|
2310 | | -
|
---|
2311 | | -static int __init rga_init(void)
|
---|
2312 | | -{
|
---|
2313 | | - int ret;
|
---|
2314 | | - uint32_t *mmu_buf;
|
---|
2315 | | - unsigned long *mmu_buf_virtual;
|
---|
2316 | | - uint32_t i;
|
---|
2317 | | - uint32_t *buf_p;
|
---|
2318 | | - uint32_t *buf; |
---|
2319 | 2274 | |
---|
2320 | | - /* malloc pre scale mid buf mmu table */
|
---|
2321 | | - mmu_buf = kzalloc(1024*8, GFP_KERNEL);
|
---|
2322 | | - mmu_buf_virtual = kzalloc(1024*2*sizeof(unsigned long), GFP_KERNEL);
|
---|
2323 | | - if(mmu_buf == NULL) {
|
---|
2324 | | - printk(KERN_ERR "RGA get Pre Scale buff failed. \n");
|
---|
2325 | | - return -1;
|
---|
2326 | | - }
|
---|
2327 | | - if (mmu_buf_virtual == NULL) {
|
---|
2328 | | - return -1;
|
---|
2329 | | - }
|
---|
2330 | | -
|
---|
2331 | | - /* malloc 4 M buf */
|
---|
2332 | | - for(i=0; i<1024; i++) {
|
---|
2333 | | - buf_p = (uint32_t *)__get_free_page(GFP_KERNEL|__GFP_ZERO);
|
---|
2334 | | - if(buf_p == NULL) {
|
---|
2335 | | - printk(KERN_ERR "RGA init pre scale buf falied\n");
|
---|
2336 | | - return -ENOMEM;
|
---|
2337 | | - }
|
---|
2338 | | - mmu_buf[i] = virt_to_phys((void *)((unsigned long)buf_p));
|
---|
2339 | | - mmu_buf_virtual[i] = (unsigned long)buf_p;
|
---|
2340 | | - }
|
---|
2341 | | -
|
---|
2342 | | - rga_service.pre_scale_buf = (uint32_t *)mmu_buf;
|
---|
2343 | | - rga_service.pre_scale_buf_virtual = (unsigned long *)mmu_buf_virtual;
|
---|
2344 | | -
|
---|
2345 | | - buf_p = kmalloc(1024*256, GFP_KERNEL);
|
---|
2346 | | - rga_mmu_buf.buf_virtual = buf_p;
|
---|
| 2275 | +void rga_test_0(void); |
---|
| 2276 | +void rga_test_1(void); |
---|
| 2277 | + |
---|
| 2278 | +static int __init rga_init(void) |
---|
| 2279 | +{ |
---|
| 2280 | + int i, ret; |
---|
| 2281 | + void * pre_scale_page_buf; |
---|
| 2282 | + uint32_t *pre_scale_page_table; |
---|
| 2283 | + uint32_t *mmu_base; |
---|
| 2284 | + struct page **pages; |
---|
| 2285 | + |
---|
| 2286 | + /* malloc pre scale mid buf mmu table */ |
---|
| 2287 | + pre_scale_page_table = kzalloc(RGA_PRE_SCALE_PAGE_SIZE * sizeof(*pre_scale_page_table), |
---|
| 2288 | + GFP_KERNEL); |
---|
| 2289 | + if(pre_scale_page_table == NULL) { |
---|
| 2290 | + pr_err("RGA alloc pre-scale page table failed.\n"); |
---|
| 2291 | + return -ENOMEM; |
---|
| 2292 | + } |
---|
| 2293 | + |
---|
| 2294 | + /* alloc reserved pre-scale buf */ |
---|
| 2295 | + for(i = 0; i < RGA_PRE_SCALE_PAGE_SIZE; i++) { |
---|
| 2296 | + pre_scale_page_buf = (void *)__get_free_page(GFP_KERNEL | __GFP_ZERO); |
---|
| 2297 | + if(pre_scale_page_buf == NULL) { |
---|
| 2298 | + printk(KERN_ERR "RGA init pre scale page_table[%d] falied\n", i); |
---|
| 2299 | + ret = -ENOMEM; |
---|
| 2300 | + goto free_pre_scale_page_table; |
---|
| 2301 | + } |
---|
| 2302 | + pre_scale_page_table[i] = (uint32_t)virt_to_phys(pre_scale_page_buf); |
---|
| 2303 | + } |
---|
| 2304 | + |
---|
| 2305 | + mmu_base = kmalloc(1024 * 256, GFP_KERNEL); |
---|
| 2306 | + if (mmu_base == NULL) { |
---|
| 2307 | + pr_err("RGA alloc mmu buffer failed.\n"); |
---|
| 2308 | + ret = -ENOMEM; |
---|
| 2309 | + goto free_pre_scale_page_table; |
---|
| 2310 | + } |
---|
| 2311 | + |
---|
| 2312 | + pages = kmalloc((32768)* sizeof(struct page *), GFP_KERNEL); |
---|
| 2313 | + if (pages == NULL) { |
---|
| 2314 | + pr_err("RGA alloc pages buffer failed.\n"); |
---|
| 2315 | + ret = -ENOMEM; |
---|
| 2316 | + goto free_mmu_base; |
---|
| 2317 | + } |
---|
| 2318 | + |
---|
| 2319 | + ret = platform_driver_register(&rga_driver); |
---|
| 2320 | + if (ret != 0) { |
---|
| 2321 | + printk(KERN_ERR "Platform device register failed (%d).\n", ret); |
---|
| 2322 | + goto free_pages_buf; |
---|
| 2323 | + } |
---|
| 2324 | + |
---|
| 2325 | + rga_service.pre_scale_buf = pre_scale_page_table; |
---|
| 2326 | + |
---|
| 2327 | + rga_mmu_buf.buf_virtual = mmu_base; |
---|
2347 | 2328 | #if (defined(CONFIG_ARM) && defined(CONFIG_ARM_LPAE)) |
---|
2348 | | - buf = (uint32_t *)(uint32_t)virt_to_phys((void *)((unsigned long)buf_p)); |
---|
| 2329 | + rga_mmu_buf.buf = (uint32_t *)(uint32_t)virt_to_phys((void *)((unsigned long)mmu_base)); |
---|
2349 | 2330 | #else |
---|
2350 | | - buf = (uint32_t *)virt_to_phys((void *)((unsigned long)buf_p)); |
---|
| 2331 | + rga_mmu_buf.buf = (uint32_t *)virt_to_phys((void *)((unsigned long)mmu_base)); |
---|
2351 | 2332 | #endif |
---|
2352 | | - rga_mmu_buf.buf = buf; |
---|
2353 | | - rga_mmu_buf.front = 0;
|
---|
2354 | | - rga_mmu_buf.back = 64*1024;
|
---|
2355 | | - rga_mmu_buf.size = 64*1024;
|
---|
2356 | | -
|
---|
2357 | | - rga_mmu_buf.pages = kmalloc((32768)* sizeof(struct page *), GFP_KERNEL);
|
---|
2358 | | -
|
---|
2359 | | - if ((ret = platform_driver_register(&rga_driver)) != 0)
|
---|
2360 | | - {
|
---|
2361 | | - printk(KERN_ERR "Platform device register failed (%d).\n", ret);
|
---|
2362 | | - return ret;
|
---|
2363 | | - }
|
---|
2364 | | -
|
---|
2365 | | - {
|
---|
2366 | | - rga_session_global.pid = 0x0000ffff;
|
---|
2367 | | - INIT_LIST_HEAD(&rga_session_global.waiting);
|
---|
2368 | | - INIT_LIST_HEAD(&rga_session_global.running);
|
---|
2369 | | - INIT_LIST_HEAD(&rga_session_global.list_session);
|
---|
2370 | | -
|
---|
2371 | | - INIT_LIST_HEAD(&rga_service.waiting);
|
---|
2372 | | - INIT_LIST_HEAD(&rga_service.running);
|
---|
2373 | | - INIT_LIST_HEAD(&rga_service.done);
|
---|
2374 | | - INIT_LIST_HEAD(&rga_service.session);
|
---|
2375 | | -
|
---|
2376 | | - init_waitqueue_head(&rga_session_global.wait);
|
---|
2377 | | - //mutex_lock(&rga_service.lock);
|
---|
2378 | | - list_add_tail(&rga_session_global.list_session, &rga_service.session);
|
---|
2379 | | - //mutex_unlock(&rga_service.lock);
|
---|
2380 | | - atomic_set(&rga_session_global.task_running, 0);
|
---|
2381 | | - atomic_set(&rga_session_global.num_done, 0);
|
---|
2382 | | - }
|
---|
2383 | | -
|
---|
2384 | | - #if RGA_TEST_CASE |
---|
| 2333 | + rga_mmu_buf.front = 0; |
---|
| 2334 | + rga_mmu_buf.back = 64*1024; |
---|
| 2335 | + rga_mmu_buf.size = 64*1024; |
---|
| 2336 | + |
---|
| 2337 | + rga_mmu_buf.pages = pages; |
---|
| 2338 | + |
---|
| 2339 | + rga_session_global.pid = 0x0000ffff; |
---|
| 2340 | + INIT_LIST_HEAD(&rga_session_global.waiting); |
---|
| 2341 | + INIT_LIST_HEAD(&rga_session_global.running); |
---|
| 2342 | + INIT_LIST_HEAD(&rga_session_global.list_session); |
---|
| 2343 | + |
---|
| 2344 | + INIT_LIST_HEAD(&rga_service.waiting); |
---|
| 2345 | + INIT_LIST_HEAD(&rga_service.running); |
---|
| 2346 | + INIT_LIST_HEAD(&rga_service.done); |
---|
| 2347 | + INIT_LIST_HEAD(&rga_service.session); |
---|
| 2348 | + |
---|
| 2349 | + init_waitqueue_head(&rga_session_global.wait); |
---|
| 2350 | + //mutex_lock(&rga_service.lock); |
---|
| 2351 | + list_add_tail(&rga_session_global.list_session, &rga_service.session); |
---|
| 2352 | + //mutex_unlock(&rga_service.lock); |
---|
| 2353 | + atomic_set(&rga_session_global.task_running, 0); |
---|
| 2354 | + atomic_set(&rga_session_global.num_done, 0); |
---|
| 2355 | + |
---|
| 2356 | +#if RGA_TEST_CASE |
---|
2385 | 2357 | rga_test_0(); |
---|
2386 | 2358 | #endif |
---|
2387 | 2359 | #if RGA_DEBUGFS |
---|
2388 | 2360 | rga_debugfs_add(); |
---|
2389 | 2361 | #endif |
---|
2390 | | -
|
---|
2391 | | - INFO("Module initialized.\n");
|
---|
2392 | | -
|
---|
2393 | | - return 0;
|
---|
2394 | | -}
|
---|
2395 | | -
|
---|
2396 | | -static void __exit rga_exit(void)
|
---|
2397 | | -{
|
---|
2398 | | - uint32_t i;
|
---|
2399 | | -
|
---|
2400 | | - rga_power_off();
|
---|
2401 | | -
|
---|
2402 | | - for(i=0; i<1024; i++)
|
---|
2403 | | - {
|
---|
2404 | | - if((unsigned long)rga_service.pre_scale_buf_virtual[i])
|
---|
2405 | | - {
|
---|
2406 | | - __free_page((void *)rga_service.pre_scale_buf_virtual[i]);
|
---|
2407 | | - }
|
---|
2408 | | - }
|
---|
2409 | | -
|
---|
2410 | | - if(rga_service.pre_scale_buf != NULL) {
|
---|
2411 | | - kfree((uint8_t *)rga_service.pre_scale_buf);
|
---|
2412 | | - }
|
---|
2413 | | -
|
---|
2414 | | - kfree(rga_mmu_buf.buf_virtual); |
---|
2415 | 2362 | |
---|
| 2363 | + INFO("RGA Module initialized.\n"); |
---|
| 2364 | + |
---|
| 2365 | + return 0; |
---|
| 2366 | + |
---|
| 2367 | +free_pages_buf: |
---|
| 2368 | + kfree(pages); |
---|
| 2369 | + |
---|
| 2370 | +free_mmu_base: |
---|
| 2371 | + kfree(mmu_base); |
---|
| 2372 | + |
---|
| 2373 | +free_pre_scale_page_table: |
---|
| 2374 | + for (i = 0; i < RGA_PRE_SCALE_PAGE_SIZE; i++) |
---|
| 2375 | + if (pre_scale_page_table[i] != 0) |
---|
| 2376 | + kfree(phys_to_virt((phys_addr_t)pre_scale_page_table[i])); |
---|
| 2377 | + |
---|
| 2378 | + kfree(pre_scale_page_table); |
---|
| 2379 | + |
---|
| 2380 | + return ret; |
---|
| 2381 | +} |
---|
| 2382 | + |
---|
| 2383 | +static void __exit rga_exit(void) |
---|
| 2384 | +{ |
---|
| 2385 | + phys_addr_t pre_scale_buf; |
---|
| 2386 | + |
---|
| 2387 | + rga_power_off(); |
---|
| 2388 | + |
---|
| 2389 | + if (rga_service.pre_scale_buf != NULL) { |
---|
| 2390 | + pre_scale_buf = (phys_addr_t)rga_service.pre_scale_buf[0]; |
---|
| 2391 | + if (pre_scale_buf) |
---|
| 2392 | + kfree(phys_to_virt(pre_scale_buf)); |
---|
| 2393 | + kfree(rga_service.pre_scale_buf); |
---|
| 2394 | + } |
---|
| 2395 | + kfree(rga_mmu_buf.buf_virtual); |
---|
2416 | 2396 | kfree(rga_mmu_buf.pages); |
---|
2417 | 2397 | |
---|
2418 | | - platform_driver_unregister(&rga_driver);
|
---|
2419 | | -}
|
---|
| 2398 | + platform_driver_unregister(&rga_driver); |
---|
| 2399 | +} |
---|
2420 | 2400 | |
---|
2421 | 2401 | #if RGA_TEST_CASE |
---|
2422 | 2402 | |
---|
2423 | | -extern struct fb_info * rk_get_fb(int fb_id);
|
---|
2424 | | -EXPORT_SYMBOL(rk_get_fb);
|
---|
2425 | | -
|
---|
2426 | | -extern void rk_direct_fb_show(struct fb_info * fbi);
|
---|
2427 | | -EXPORT_SYMBOL(rk_direct_fb_show);
|
---|
2428 | | -
|
---|
2429 | | -unsigned int src_buf[1920*1080];
|
---|
2430 | | -unsigned int dst_buf[1920*1080];
|
---|
2431 | | -//unsigned int tmp_buf[1920*1080 * 2];
|
---|
2432 | | -
|
---|
2433 | | -void rga_test_0(void)
|
---|
2434 | | -{
|
---|
2435 | | - struct rga_req req;
|
---|
2436 | | - rga_session session;
|
---|
2437 | | - unsigned int *src, *dst;
|
---|
2438 | | - uint32_t i, j;
|
---|
2439 | | - uint8_t *p;
|
---|
2440 | | - uint8_t t;
|
---|
2441 | | - uint32_t *dst0, *dst1, *dst2;
|
---|
2442 | | -
|
---|
2443 | | - struct fb_info *fb;
|
---|
2444 | | -
|
---|
2445 | | - session.pid = current->pid;
|
---|
2446 | | - INIT_LIST_HEAD(&session.waiting);
|
---|
2447 | | - INIT_LIST_HEAD(&session.running);
|
---|
2448 | | - INIT_LIST_HEAD(&session.list_session);
|
---|
2449 | | - init_waitqueue_head(&session.wait);
|
---|
2450 | | - /* no need to protect */
|
---|
2451 | | - list_add_tail(&session.list_session, &rga_service.session);
|
---|
2452 | | - atomic_set(&session.task_running, 0);
|
---|
2453 | | - atomic_set(&session.num_done, 0);
|
---|
2454 | | - //file->private_data = (void *)session;
|
---|
2455 | | -
|
---|
2456 | | - fb = rk_get_fb(0);
|
---|
2457 | | -
|
---|
2458 | | - memset(&req, 0, sizeof(struct rga_req));
|
---|
2459 | | - src = src_buf;
|
---|
2460 | | - dst = dst_buf;
|
---|
2461 | | -
|
---|
2462 | | - memset(src_buf, 0x80, 1024*600*4);
|
---|
2463 | | -
|
---|
2464 | | - dmac_flush_range(&src_buf[0], &src_buf[1024*600]);
|
---|
2465 | | - outer_flush_range(virt_to_phys(&src_buf[0]),virt_to_phys(&src_buf[1024*600]));
|
---|
2466 | | -
|
---|
2467 | | -
|
---|
2468 | | - #if 0
|
---|
2469 | | - memset(src_buf, 0x80, 800*480*4);
|
---|
2470 | | - memset(dst_buf, 0xcc, 800*480*4);
|
---|
2471 | | -
|
---|
2472 | | - dmac_flush_range(&dst_buf[0], &dst_buf[800*480]);
|
---|
2473 | | - outer_flush_range(virt_to_phys(&dst_buf[0]),virt_to_phys(&dst_buf[800*480]));
|
---|
2474 | | - #endif
|
---|
2475 | | -
|
---|
2476 | | - dst0 = &dst_buf[0];
|
---|
2477 | | - //dst1 = &dst_buf[1280*800*4];
|
---|
2478 | | - //dst2 = &dst_buf[1280*800*4*2];
|
---|
2479 | | -
|
---|
2480 | | - i = j = 0;
|
---|
2481 | | -
|
---|
2482 | | - printk("\n********************************\n");
|
---|
2483 | | - printk("************ RGA_TEST ************\n");
|
---|
2484 | | - printk("********************************\n\n");
|
---|
2485 | | -
|
---|
2486 | | - req.src.act_w = 1024;
|
---|
2487 | | - req.src.act_h = 600;
|
---|
2488 | | -
|
---|
2489 | | - req.src.vir_w = 1024;
|
---|
2490 | | - req.src.vir_h = 600;
|
---|
2491 | | - req.src.yrgb_addr = (uint32_t)virt_to_phys(src);
|
---|
2492 | | - req.src.uv_addr = (uint32_t)(req.src.yrgb_addr + 1080*1920);
|
---|
2493 | | - req.src.v_addr = (uint32_t)virt_to_phys(src);
|
---|
2494 | | - req.src.format = RK_FORMAT_RGBA_8888;
|
---|
2495 | | -
|
---|
2496 | | - req.dst.act_w = 600;
|
---|
2497 | | - req.dst.act_h = 352;
|
---|
2498 | | -
|
---|
2499 | | - req.dst.vir_w = 1280;
|
---|
2500 | | - req.dst.vir_h = 800;
|
---|
2501 | | - req.dst.x_offset = 600;
|
---|
2502 | | - req.dst.y_offset = 0;
|
---|
2503 | | -
|
---|
2504 | | - dst = dst0;
|
---|
2505 | | -
|
---|
2506 | | - req.dst.yrgb_addr = ((uint32_t)virt_to_phys(dst));
|
---|
2507 | | -
|
---|
2508 | | - //req.dst.format = RK_FORMAT_RGB_565;
|
---|
2509 | | -
|
---|
2510 | | - req.clip.xmin = 0;
|
---|
2511 | | - req.clip.xmax = 1279;
|
---|
2512 | | - req.clip.ymin = 0;
|
---|
2513 | | - req.clip.ymax = 799;
|
---|
2514 | | -
|
---|
2515 | | - //req.render_mode = color_fill_mode;
|
---|
2516 | | - //req.fg_color = 0x80ffffff;
|
---|
2517 | | -
|
---|
2518 | | - req.rotate_mode = 1;
|
---|
2519 | | - //req.scale_mode = 2;
|
---|
2520 | | -
|
---|
2521 | | - //req.alpha_rop_flag = 0;
|
---|
2522 | | - //req.alpha_rop_mode = 0x19;
|
---|
2523 | | - //req.PD_mode = 3;
|
---|
2524 | | -
|
---|
2525 | | - req.sina = 65536;
|
---|
2526 | | - req.cosa = 0;
|
---|
2527 | | -
|
---|
2528 | | - //req.mmu_info.mmu_flag = 0x21;
|
---|
2529 | | - //req.mmu_info.mmu_en = 1;
|
---|
2530 | | -
|
---|
2531 | | - //printk("src = %.8x\n", req.src.yrgb_addr);
|
---|
2532 | | - //printk("src = %.8x\n", req.src.uv_addr);
|
---|
2533 | | - //printk("dst = %.8x\n", req.dst.yrgb_addr);
|
---|
2534 | | -
|
---|
2535 | | -
|
---|
2536 | | - rga_blit_sync(&session, &req);
|
---|
2537 | | -
|
---|
2538 | | - #if 1
|
---|
2539 | | - fb->var.bits_per_pixel = 32;
|
---|
2540 | | -
|
---|
2541 | | - fb->var.xres = 1280;
|
---|
2542 | | - fb->var.yres = 800;
|
---|
2543 | | -
|
---|
2544 | | - fb->var.red.length = 8;
|
---|
2545 | | - fb->var.red.offset = 0;
|
---|
2546 | | - fb->var.red.msb_right = 0;
|
---|
2547 | | -
|
---|
2548 | | - fb->var.green.length = 8;
|
---|
2549 | | - fb->var.green.offset = 8;
|
---|
2550 | | - fb->var.green.msb_right = 0;
|
---|
2551 | | -
|
---|
2552 | | - fb->var.blue.length = 8;
|
---|
2553 | | -
|
---|
2554 | | - fb->var.blue.offset = 16;
|
---|
2555 | | - fb->var.blue.msb_right = 0;
|
---|
2556 | | -
|
---|
2557 | | - fb->var.transp.length = 8;
|
---|
2558 | | - fb->var.transp.offset = 24;
|
---|
2559 | | - fb->var.transp.msb_right = 0;
|
---|
2560 | | -
|
---|
2561 | | - fb->var.nonstd &= (~0xff);
|
---|
2562 | | - fb->var.nonstd |= 1;
|
---|
2563 | | -
|
---|
2564 | | - fb->fix.smem_start = virt_to_phys(dst);
|
---|
2565 | | -
|
---|
2566 | | - rk_direct_fb_show(fb);
|
---|
2567 | | - #endif
|
---|
2568 | | -
|
---|
2569 | | -}
|
---|
2570 | | -
|
---|
2571 | | -#endif
|
---|
| 2403 | +extern struct fb_info * rk_get_fb(int fb_id); |
---|
| 2404 | +EXPORT_SYMBOL(rk_get_fb); |
---|
| 2405 | + |
---|
| 2406 | +extern void rk_direct_fb_show(struct fb_info * fbi); |
---|
| 2407 | +EXPORT_SYMBOL(rk_direct_fb_show); |
---|
| 2408 | + |
---|
| 2409 | +unsigned int src_buf[1920*1080]; |
---|
| 2410 | +unsigned int dst_buf[1920*1080]; |
---|
| 2411 | +//unsigned int tmp_buf[1920*1080 * 2]; |
---|
| 2412 | + |
---|
| 2413 | +void rga_test_0(void) |
---|
| 2414 | +{ |
---|
| 2415 | + struct rga_req req; |
---|
| 2416 | + rga_session session; |
---|
| 2417 | + unsigned int *src, *dst; |
---|
| 2418 | + uint32_t i, j; |
---|
| 2419 | + uint8_t *p; |
---|
| 2420 | + uint8_t t; |
---|
| 2421 | + uint32_t *dst0, *dst1, *dst2; |
---|
| 2422 | + |
---|
| 2423 | + struct fb_info *fb; |
---|
| 2424 | + |
---|
| 2425 | + session.pid = current->pid; |
---|
| 2426 | + INIT_LIST_HEAD(&session.waiting); |
---|
| 2427 | + INIT_LIST_HEAD(&session.running); |
---|
| 2428 | + INIT_LIST_HEAD(&session.list_session); |
---|
| 2429 | + init_waitqueue_head(&session.wait); |
---|
| 2430 | + /* no need to protect */ |
---|
| 2431 | + list_add_tail(&session.list_session, &rga_service.session); |
---|
| 2432 | + atomic_set(&session.task_running, 0); |
---|
| 2433 | + atomic_set(&session.num_done, 0); |
---|
| 2434 | + //file->private_data = (void *)session; |
---|
| 2435 | + |
---|
| 2436 | + fb = rk_get_fb(0); |
---|
| 2437 | + |
---|
| 2438 | + memset(&req, 0, sizeof(struct rga_req)); |
---|
| 2439 | + src = src_buf; |
---|
| 2440 | + dst = dst_buf; |
---|
| 2441 | + |
---|
| 2442 | + memset(src_buf, 0x80, 1024*600*4); |
---|
| 2443 | + |
---|
| 2444 | + dmac_flush_range(&src_buf[0], &src_buf[1024*600]); |
---|
| 2445 | + outer_flush_range(virt_to_phys(&src_buf[0]),virt_to_phys(&src_buf[1024*600])); |
---|
| 2446 | + |
---|
| 2447 | + |
---|
| 2448 | + #if 0 |
---|
| 2449 | + memset(src_buf, 0x80, 800*480*4); |
---|
| 2450 | + memset(dst_buf, 0xcc, 800*480*4); |
---|
| 2451 | + |
---|
| 2452 | + dmac_flush_range(&dst_buf[0], &dst_buf[800*480]); |
---|
| 2453 | + outer_flush_range(virt_to_phys(&dst_buf[0]),virt_to_phys(&dst_buf[800*480])); |
---|
| 2454 | + #endif |
---|
| 2455 | + |
---|
| 2456 | + dst0 = &dst_buf[0]; |
---|
| 2457 | + //dst1 = &dst_buf[1280*800*4]; |
---|
| 2458 | + //dst2 = &dst_buf[1280*800*4*2]; |
---|
| 2459 | + |
---|
| 2460 | + i = j = 0; |
---|
| 2461 | + |
---|
| 2462 | + printk("\n********************************\n"); |
---|
| 2463 | + printk("************ RGA_TEST ************\n"); |
---|
| 2464 | + printk("********************************\n\n"); |
---|
| 2465 | + |
---|
| 2466 | + req.src.act_w = 1024; |
---|
| 2467 | + req.src.act_h = 600; |
---|
| 2468 | + |
---|
| 2469 | + req.src.vir_w = 1024; |
---|
| 2470 | + req.src.vir_h = 600; |
---|
| 2471 | + req.src.yrgb_addr = (uint32_t)virt_to_phys(src); |
---|
| 2472 | + req.src.uv_addr = (uint32_t)(req.src.yrgb_addr + 1080*1920); |
---|
| 2473 | + req.src.v_addr = (uint32_t)virt_to_phys(src); |
---|
| 2474 | + req.src.format = RK_FORMAT_RGBA_8888; |
---|
| 2475 | + |
---|
| 2476 | + req.dst.act_w = 600; |
---|
| 2477 | + req.dst.act_h = 352; |
---|
| 2478 | + |
---|
| 2479 | + req.dst.vir_w = 1280; |
---|
| 2480 | + req.dst.vir_h = 800; |
---|
| 2481 | + req.dst.x_offset = 600; |
---|
| 2482 | + req.dst.y_offset = 0; |
---|
| 2483 | + |
---|
| 2484 | + dst = dst0; |
---|
| 2485 | + |
---|
| 2486 | + req.dst.yrgb_addr = ((uint32_t)virt_to_phys(dst)); |
---|
| 2487 | + |
---|
| 2488 | + //req.dst.format = RK_FORMAT_RGB_565; |
---|
| 2489 | + |
---|
| 2490 | + req.clip.xmin = 0; |
---|
| 2491 | + req.clip.xmax = 1279; |
---|
| 2492 | + req.clip.ymin = 0; |
---|
| 2493 | + req.clip.ymax = 799; |
---|
| 2494 | + |
---|
| 2495 | + //req.render_mode = color_fill_mode; |
---|
| 2496 | + //req.fg_color = 0x80ffffff; |
---|
| 2497 | + |
---|
| 2498 | + req.rotate_mode = 1; |
---|
| 2499 | + //req.scale_mode = 2; |
---|
| 2500 | + |
---|
| 2501 | + //req.alpha_rop_flag = 0; |
---|
| 2502 | + //req.alpha_rop_mode = 0x19; |
---|
| 2503 | + //req.PD_mode = 3; |
---|
| 2504 | + |
---|
| 2505 | + req.sina = 65536; |
---|
| 2506 | + req.cosa = 0; |
---|
| 2507 | + |
---|
| 2508 | + //req.mmu_info.mmu_flag = 0x21; |
---|
| 2509 | + //req.mmu_info.mmu_en = 1; |
---|
| 2510 | + |
---|
| 2511 | + //printk("src = %.8x\n", req.src.yrgb_addr); |
---|
| 2512 | + //printk("src = %.8x\n", req.src.uv_addr); |
---|
| 2513 | + //printk("dst = %.8x\n", req.dst.yrgb_addr); |
---|
| 2514 | + |
---|
| 2515 | + |
---|
| 2516 | + rga_blit_sync(&session, &req); |
---|
| 2517 | + |
---|
| 2518 | + #if 1 |
---|
| 2519 | + fb->var.bits_per_pixel = 32; |
---|
| 2520 | + |
---|
| 2521 | + fb->var.xres = 1280; |
---|
| 2522 | + fb->var.yres = 800; |
---|
| 2523 | + |
---|
| 2524 | + fb->var.red.length = 8; |
---|
| 2525 | + fb->var.red.offset = 0; |
---|
| 2526 | + fb->var.red.msb_right = 0; |
---|
| 2527 | + |
---|
| 2528 | + fb->var.green.length = 8; |
---|
| 2529 | + fb->var.green.offset = 8; |
---|
| 2530 | + fb->var.green.msb_right = 0; |
---|
| 2531 | + |
---|
| 2532 | + fb->var.blue.length = 8; |
---|
| 2533 | + |
---|
| 2534 | + fb->var.blue.offset = 16; |
---|
| 2535 | + fb->var.blue.msb_right = 0; |
---|
| 2536 | + |
---|
| 2537 | + fb->var.transp.length = 8; |
---|
| 2538 | + fb->var.transp.offset = 24; |
---|
| 2539 | + fb->var.transp.msb_right = 0; |
---|
| 2540 | + |
---|
| 2541 | + fb->var.nonstd &= (~0xff); |
---|
| 2542 | + fb->var.nonstd |= 1; |
---|
| 2543 | + |
---|
| 2544 | + fb->fix.smem_start = virt_to_phys(dst); |
---|
| 2545 | + |
---|
| 2546 | + rk_direct_fb_show(fb); |
---|
| 2547 | + #endif |
---|
| 2548 | + |
---|
| 2549 | +} |
---|
| 2550 | + |
---|
| 2551 | +#endif |
---|
2572 | 2552 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 0)) |
---|
2573 | 2553 | fs_initcall(rga_init); |
---|
2574 | 2554 | #else |
---|
2575 | 2555 | module_init(rga_init); |
---|
2576 | 2556 | #endif |
---|
2577 | | -module_exit(rga_exit);
|
---|
2578 | | -
|
---|
2579 | | -/* Module information */
|
---|
2580 | | -MODULE_AUTHOR("zsq@rock-chips.com");
|
---|
2581 | | -MODULE_DESCRIPTION("Driver for rga device");
|
---|
2582 | | -MODULE_LICENSE("GPL");
|
---|
| 2557 | +module_exit(rga_exit); |
---|
| 2558 | + |
---|
| 2559 | +/* Module information */ |
---|
| 2560 | +MODULE_AUTHOR("zsq@rock-chips.com"); |
---|
| 2561 | +MODULE_DESCRIPTION("Driver for rga device"); |
---|
| 2562 | +MODULE_LICENSE("GPL"); |
---|