diff options
Diffstat (limited to 'firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c')
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c b/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c index f45ffc0349..1401bf8a3f 100644 --- a/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c +++ b/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c | |||
@@ -26,15 +26,14 @@ | |||
26 | #include "system.h" | 26 | #include "system.h" |
27 | #include "kernel.h" | 27 | #include "kernel.h" |
28 | 28 | ||
29 | static volatile bool _lcd_on = false; | 29 | static volatile bool lcd_is_on = false; |
30 | static volatile bool lcd_poweroff = false; | ||
31 | static struct mutex lcd_mtx; | 30 | static struct mutex lcd_mtx; |
32 | 31 | ||
33 | /* LCD init */ | 32 | /* LCD init */ |
34 | void lcd_init_device(void) | 33 | void lcd_init_device(void) |
35 | { | 34 | { |
36 | lcd_init_controller(); | 35 | lcd_init_controller(); |
37 | _lcd_on = true; | 36 | lcd_is_on = true; |
38 | mutex_init(&lcd_mtx); | 37 | mutex_init(&lcd_mtx); |
39 | } | 38 | } |
40 | 39 | ||
@@ -48,16 +47,16 @@ void lcd_enable(bool state) | |||
48 | else | 47 | else |
49 | lcd_off(); | 48 | lcd_off(); |
50 | 49 | ||
51 | _lcd_on = state; | 50 | lcd_is_on = state; |
52 | } | 51 | } |
53 | 52 | ||
54 | bool lcd_enabled(void) | 53 | bool lcd_enabled(void) |
55 | { | 54 | { |
56 | return _lcd_on; | 55 | return lcd_is_on; |
57 | } | 56 | } |
58 | 57 | ||
59 | /* Don't switch threads when in interrupt mode! */ | 58 | /* Don't switch threads when in interrupt mode! */ |
60 | static void lcd_lock(void) | 59 | static inline void lcd_lock(void) |
61 | { | 60 | { |
62 | if(LIKELY(!in_interrupt_mode())) | 61 | if(LIKELY(!in_interrupt_mode())) |
63 | mutex_lock(&lcd_mtx); | 62 | mutex_lock(&lcd_mtx); |
@@ -65,10 +64,19 @@ static void lcd_lock(void) | |||
65 | while( !(REG_DMAC_DCCSR(DMA_LCD_CHANNEL) & DMAC_DCCSR_TT)); | 64 | while( !(REG_DMAC_DCCSR(DMA_LCD_CHANNEL) & DMAC_DCCSR_TT)); |
66 | } | 65 | } |
67 | 66 | ||
68 | static void lcd_unlock(void) | 67 | static inline void lcd_unlock(void) |
69 | { | 68 | { |
70 | if(LIKELY(!in_interrupt_mode())) | 69 | if(LIKELY(!in_interrupt_mode())) |
71 | mutex_unlock(&lcd_mtx); | 70 | mutex_unlock(&lcd_mtx); |
71 | } | ||
72 | |||
73 | static inline void lcd_wait(void) | ||
74 | { | ||
75 | if(LIKELY(!in_interrupt_mode())) | ||
76 | { | ||
77 | while( !(REG_DMAC_DCCSR(DMA_LCD_CHANNEL) & DMAC_DCCSR_TT) ) | ||
78 | yield(); | ||
79 | } | ||
72 | else | 80 | else |
73 | while( !(REG_DMAC_DCCSR(DMA_LCD_CHANNEL) & DMAC_DCCSR_TT)); | 81 | while( !(REG_DMAC_DCCSR(DMA_LCD_CHANNEL) & DMAC_DCCSR_TT)); |
74 | } | 82 | } |
@@ -98,13 +106,7 @@ void lcd_update_rect(int x, int y, int width, int height) | |||
98 | REG_SLCD_CTRL |= SLCD_CTRL_DMA_EN; | 106 | REG_SLCD_CTRL |= SLCD_CTRL_DMA_EN; |
99 | REG_DMAC_DCCSR(DMA_LCD_CHANNEL) |= DMAC_DCCSR_EN; | 107 | REG_DMAC_DCCSR(DMA_LCD_CHANNEL) |= DMAC_DCCSR_EN; |
100 | 108 | ||
101 | if(LIKELY(!in_interrupt_mode())) | 109 | lcd_wait(); |
102 | { | ||
103 | while( !(REG_DMAC_DCCSR(DMA_LCD_CHANNEL) & DMAC_DCCSR_TT) ) | ||
104 | yield(); | ||
105 | } | ||
106 | else | ||
107 | while( !(REG_DMAC_DCCSR(DMA_LCD_CHANNEL) & DMAC_DCCSR_TT)); | ||
108 | 110 | ||
109 | REG_DMAC_DCCSR(DMA_LCD_CHANNEL) &= ~DMAC_DCCSR_EN; | 111 | REG_DMAC_DCCSR(DMA_LCD_CHANNEL) &= ~DMAC_DCCSR_EN; |
110 | 112 | ||
@@ -119,7 +121,7 @@ void lcd_update_rect(int x, int y, int width, int height) | |||
119 | This must be called after all other LCD functions that change the display. */ | 121 | This must be called after all other LCD functions that change the display. */ |
120 | void lcd_update(void) | 122 | void lcd_update(void) |
121 | { | 123 | { |
122 | if (!_lcd_on) | 124 | if (!lcd_is_on) |
123 | return; | 125 | return; |
124 | 126 | ||
125 | lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT); | 127 | lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT); |