diff options
Diffstat (limited to 'firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c')
-rwxr-xr-x | firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c b/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c new file mode 100755 index 0000000000..429178aeee --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c | |||
@@ -0,0 +1,94 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 by Maurus Cuelenaere | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "config.h" | ||
23 | #include "jz4740.h" | ||
24 | #include "lcd.h" | ||
25 | #include "lcd-target.h" | ||
26 | |||
27 | static volatile bool _lcd_on = false; | ||
28 | static volatile bool lcd_poweroff = false; | ||
29 | |||
30 | /* LCD init */ | ||
31 | void lcd_init_device(void) | ||
32 | { | ||
33 | lcd_init_controller(); | ||
34 | _lcd_on = true; | ||
35 | } | ||
36 | |||
37 | void lcd_enable(bool state) | ||
38 | { | ||
39 | if(state) | ||
40 | lcd_on(); | ||
41 | else | ||
42 | lcd_off(); | ||
43 | |||
44 | _lcd_on = state; | ||
45 | } | ||
46 | |||
47 | bool lcd_enabled(void) | ||
48 | { | ||
49 | return _lcd_on; | ||
50 | } | ||
51 | |||
52 | #define LCDADDR(x, y) ((unsigned int)&lcd_framebuffer[(y)][(x)]) | ||
53 | #define LCD_UNCACHED(addr) ((unsigned int)(addr) | 0xA0000000) | ||
54 | |||
55 | /* Update a fraction of the display. */ | ||
56 | void lcd_update_rect(int x, int y, int width, int height) | ||
57 | { | ||
58 | /* HACKY... */ | ||
59 | x=0; y=0; width=400; height=240; | ||
60 | lcd_set_target(x, y, width-1, height-1); | ||
61 | |||
62 | REG_DMAC_DCCSR(0) = 0; | ||
63 | REG_DMAC_DRSR(0) = DMAC_DRSR_RS_SLCD; /* source = SLCD */ | ||
64 | REG_DMAC_DSAR(0) = LCDADDR(x,y) & 0x1FFFFFFF; | ||
65 | #if 0 | ||
66 | REG_DMAC_DTAR(0) = LCD_UNCACHED(SLCD_FIFO); | ||
67 | #else | ||
68 | REG_DMAC_DTAR(0) = 0x130500B0; /* SLCD_FIFO */ | ||
69 | #endif | ||
70 | REG_DMAC_DTCR(0) = (width*height); | ||
71 | |||
72 | REG_DMAC_DCMD(0) = (DMAC_DCMD_SAI | DMAC_DCMD_RDIL_IGN | DMAC_DCMD_SWDH_32 /* (1 << 23) | (0 << 16) | (0 << 14) */ | ||
73 | | DMAC_DCMD_DWDH_16 | DMAC_DCMD_DS_16BIT); /* | (2 << 12) | (3 << 8) */ | ||
74 | REG_DMAC_DCCSR(0) = (DMAC_DCCSR_NDES | DMAC_DCCSR_EN); /* (1 << 31) | (1 << 0) */ | ||
75 | |||
76 | jz_flush_icache(); | ||
77 | |||
78 | REG_DMAC_DMACR = DMAC_DMACR_DMAE; | ||
79 | |||
80 | while( !(REG_DMAC_DCCSR(0) & DMAC_DCCSR_TT) ) | ||
81 | asm("nop"); | ||
82 | |||
83 | //REG_DMAC_DCCSR(0) &= ~DMAC_DCCSR_TT; | ||
84 | } | ||
85 | |||
86 | /* Update the display. | ||
87 | This must be called after all other LCD functions that change the display. */ | ||
88 | void lcd_update(void) | ||
89 | { | ||
90 | if (!_lcd_on) | ||
91 | return; | ||
92 | |||
93 | lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT); | ||
94 | } | ||