diff options
Diffstat (limited to 'firmware/target/coldfire/iaudio')
-rwxr-xr-x | firmware/target/coldfire/iaudio/x5/lcd-remote-target.h | 6 | ||||
-rwxr-xr-x | firmware/target/coldfire/iaudio/x5/lcd-remote-x5.c | 130 |
2 files changed, 114 insertions, 22 deletions
diff --git a/firmware/target/coldfire/iaudio/x5/lcd-remote-target.h b/firmware/target/coldfire/iaudio/x5/lcd-remote-target.h index 72d4ed9fb2..8c20526ff3 100755 --- a/firmware/target/coldfire/iaudio/x5/lcd-remote-target.h +++ b/firmware/target/coldfire/iaudio/x5/lcd-remote-target.h | |||
@@ -19,12 +19,16 @@ | |||
19 | #ifndef LCD_REMOTE_TARGET_H | 19 | #ifndef LCD_REMOTE_TARGET_H |
20 | #define LCD_REMOTE_TARGET_H | 20 | #define LCD_REMOTE_TARGET_H |
21 | 21 | ||
22 | void lcd_remote_init_device(void); | ||
22 | void lcd_remote_write_command(int cmd); | 23 | void lcd_remote_write_command(int cmd); |
23 | void lcd_remote_write_command_ex(int cmd, int data); | 24 | void lcd_remote_write_command_ex(int cmd, int data); |
24 | void lcd_remote_write_data(const unsigned char* p_bytes, int count); | 25 | void lcd_remote_write_data(const unsigned char* p_bytes, int count); |
25 | bool remote_detect(void); | 26 | bool remote_detect(void); |
26 | void lcd_remote_powersave(bool on); | 27 | void lcd_remote_powersave(bool on); |
27 | void lcd_remote_set_contrast(int val); | 28 | void lcd_remote_set_contrast(int val); |
28 | void remote_set_row_and_col(int row, int col); | 29 | void lcd_remote_on(void); |
30 | void lcd_remote_off(void); | ||
31 | |||
32 | extern bool remote_initialized; | ||
29 | 33 | ||
30 | #endif | 34 | #endif |
diff --git a/firmware/target/coldfire/iaudio/x5/lcd-remote-x5.c b/firmware/target/coldfire/iaudio/x5/lcd-remote-x5.c index c1ec00f0e7..586104fc0a 100755 --- a/firmware/target/coldfire/iaudio/x5/lcd-remote-x5.c +++ b/firmware/target/coldfire/iaudio/x5/lcd-remote-x5.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include "config.h" | 19 | #include "config.h" |
20 | #include "system.h" | 20 | #include "system.h" |
21 | #include "kernel.h" | 21 | #include "kernel.h" |
22 | #include "lcd-remote.h" | ||
22 | 23 | ||
23 | /* The LCD in the iAudio M3/M5/X5 remote control is a Tomato LSI 0350 */ | 24 | /* The LCD in the iAudio M3/M5/X5 remote control is a Tomato LSI 0350 */ |
24 | 25 | ||
@@ -39,6 +40,7 @@ | |||
39 | #define LCD_SET_GRAY 0x88 | 40 | #define LCD_SET_GRAY 0x88 |
40 | #define LCD_SET_PWM_FRC 0x90 | 41 | #define LCD_SET_PWM_FRC 0x90 |
41 | #define LCD_SET_POWER_SAVE 0xa8 | 42 | #define LCD_SET_POWER_SAVE 0xa8 |
43 | #define LCD_REVERSE 0xa6 | ||
42 | 44 | ||
43 | #define CS_LO and_l(~0x00000020, &GPIO1_OUT) | 45 | #define CS_LO and_l(~0x00000020, &GPIO1_OUT) |
44 | #define CS_HI or_l(0x00000020, &GPIO1_OUT) | 46 | #define CS_HI or_l(0x00000020, &GPIO1_OUT) |
@@ -51,8 +53,12 @@ | |||
51 | 53 | ||
52 | #define LCD_REMOTE_DEFAULT_CONTRAST 0x18; | 54 | #define LCD_REMOTE_DEFAULT_CONTRAST 0x18; |
53 | 55 | ||
56 | /* cached settings values */ | ||
57 | static bool cached_invert = false; | ||
58 | static bool cached_flip = false; | ||
54 | static int cached_contrast = LCD_REMOTE_DEFAULT_CONTRAST; | 59 | static int cached_contrast = LCD_REMOTE_DEFAULT_CONTRAST; |
55 | static bool remote_initialized = false; | 60 | |
61 | bool remote_initialized = false; | ||
56 | 62 | ||
57 | static void remote_write(unsigned char byte, bool is_command) | 63 | static void remote_write(unsigned char byte, bool is_command) |
58 | { | 64 | { |
@@ -94,13 +100,6 @@ void lcd_remote_write_data(const unsigned char* p_bytes, int count) | |||
94 | remote_write(*p_bytes++, false); | 100 | remote_write(*p_bytes++, false); |
95 | } | 101 | } |
96 | 102 | ||
97 | void remote_set_row_and_col(int row, int col) | ||
98 | { | ||
99 | lcd_remote_write_command(LCD_SET_PAGE | (row & 0xf)); | ||
100 | lcd_remote_write_command_ex(LCD_SET_COLUMN | ((col >> 4) & 0xf), | ||
101 | col & 0xf); | ||
102 | } | ||
103 | |||
104 | int lcd_remote_default_contrast(void) | 103 | int lcd_remote_default_contrast(void) |
105 | { | 104 | { |
106 | return LCD_REMOTE_DEFAULT_CONTRAST; | 105 | return LCD_REMOTE_DEFAULT_CONTRAST; |
@@ -108,24 +107,27 @@ int lcd_remote_default_contrast(void) | |||
108 | 107 | ||
109 | void lcd_remote_powersave(bool on) | 108 | void lcd_remote_powersave(bool on) |
110 | { | 109 | { |
111 | if (on) | 110 | if(remote_initialized) { |
112 | lcd_remote_write_command(LCD_SET_POWER_SAVE | 1); | 111 | if (on) |
113 | else | 112 | lcd_remote_write_command(LCD_SET_POWER_SAVE | 1); |
114 | lcd_remote_write_command(LCD_SET_POWER_SAVE | 1); | 113 | else |
114 | lcd_remote_write_command(LCD_SET_POWER_SAVE | 1); | ||
115 | } | ||
115 | } | 116 | } |
116 | 117 | ||
117 | void lcd_remote_set_contrast(int val) | 118 | void lcd_remote_set_contrast(int val) |
118 | { | 119 | { |
119 | cached_contrast = val; | 120 | cached_contrast = val; |
120 | lcd_remote_write_command_ex(LCD_SET_VOLUME, val); | 121 | if(remote_initialized) |
122 | lcd_remote_write_command_ex(LCD_SET_VOLUME, val); | ||
121 | } | 123 | } |
122 | 124 | ||
123 | bool remote_detect(void) | 125 | bool remote_detect(void) |
124 | { | 126 | { |
125 | return (GPIO_READ & 0x01000000); | 127 | return (GPIO_READ & 0x01000000)?false:true; |
126 | } | 128 | } |
127 | 129 | ||
128 | void remote_init(void) | 130 | void lcd_remote_init_device(void) |
129 | { | 131 | { |
130 | or_l(0x0000e000, &GPIO_OUT); | 132 | or_l(0x0000e000, &GPIO_OUT); |
131 | or_l(0x0000e000, &GPIO_ENABLE); | 133 | or_l(0x0000e000, &GPIO_ENABLE); |
@@ -135,17 +137,18 @@ void remote_init(void) | |||
135 | or_l(0x00000020, &GPIO1_ENABLE); | 137 | or_l(0x00000020, &GPIO1_ENABLE); |
136 | or_l(0x00000020, &GPIO1_FUNCTION); | 138 | or_l(0x00000020, &GPIO1_FUNCTION); |
137 | 139 | ||
140 | and_l(~0x01000000, &GPIO_OUT); | ||
141 | and_l(~0x01000000, &GPIO_ENABLE); | ||
142 | or_l(0x01000000, &GPIO_FUNCTION); | ||
143 | } | ||
144 | |||
145 | void lcd_remote_on(void) | ||
146 | { | ||
138 | sleep(10); | 147 | sleep(10); |
139 | 148 | ||
140 | lcd_remote_write_command(LCD_SET_DUTY_RATIO); | 149 | lcd_remote_write_command(LCD_SET_DUTY_RATIO); |
141 | lcd_remote_write_command(0x70); /* 1/128 */ | 150 | lcd_remote_write_command(0x70); /* 1/128 */ |
142 | 151 | ||
143 | lcd_remote_write_command(LCD_SELECT_ADC | 1); /* Reverse direction */ | ||
144 | lcd_remote_write_command(LCD_SELECT_SHL | 8); /* Reverse direction */ | ||
145 | |||
146 | lcd_remote_write_command(LCD_SET_COM0); | ||
147 | lcd_remote_write_command(0x00); | ||
148 | |||
149 | lcd_remote_write_command(LCD_OSC_ON); | 152 | lcd_remote_write_command(LCD_OSC_ON); |
150 | 153 | ||
151 | lcd_remote_write_command(LCD_SELECT_DCDC | 2); /* DC/DC 5xboost */ | 154 | lcd_remote_write_command(LCD_SELECT_DCDC | 2); /* DC/DC 5xboost */ |
@@ -173,5 +176,90 @@ void remote_init(void) | |||
173 | 176 | ||
174 | remote_initialized = true; | 177 | remote_initialized = true; |
175 | 178 | ||
179 | lcd_remote_set_flip(cached_flip); | ||
176 | lcd_remote_set_contrast(cached_contrast); | 180 | lcd_remote_set_contrast(cached_contrast); |
181 | lcd_remote_set_invert_display(cached_invert); | ||
182 | } | ||
183 | |||
184 | void lcd_remote_off(void) | ||
185 | { | ||
186 | remote_initialized = false; | ||
187 | CS_HI; | ||
188 | RS_HI; | ||
189 | } | ||
190 | |||
191 | /* Update the display. | ||
192 | This must be called after all other LCD functions that change the display. */ | ||
193 | void lcd_remote_update(void) ICODE_ATTR; | ||
194 | void lcd_remote_update(void) | ||
195 | { | ||
196 | int y; | ||
197 | if(remote_initialized) { | ||
198 | for(y = 0;y < LCD_REMOTE_HEIGHT/8;y++) { | ||
199 | /* Copy display bitmap to hardware. | ||
200 | The COM48-COM63 lines are not connected so we have to skip | ||
201 | them. Further, the column address doesn't wrap, so we | ||
202 | have to update one page at a time. */ | ||
203 | lcd_remote_write_command(LCD_SET_PAGE | (y>5?y+2:y)); | ||
204 | lcd_remote_write_command_ex(LCD_SET_COLUMN | 0, 0); | ||
205 | lcd_remote_write_data((unsigned char *)lcd_remote_framebuffer[y], | ||
206 | LCD_REMOTE_WIDTH*2); | ||
207 | } | ||
208 | } | ||
209 | } | ||
210 | |||
211 | /* Update a fraction of the display. */ | ||
212 | void lcd_remote_update_rect(int, int, int, int) ICODE_ATTR; | ||
213 | void lcd_remote_update_rect(int x, int y, int width, int height) | ||
214 | { | ||
215 | if(remote_initialized) { | ||
216 | int ymax; | ||
217 | |||
218 | /* The Y coordinates have to work on even 8 pixel rows */ | ||
219 | ymax = (y + height-1) >> 3; | ||
220 | y >>= 3; | ||
221 | |||
222 | if(x + width > LCD_REMOTE_WIDTH) | ||
223 | width = LCD_REMOTE_WIDTH - x; | ||
224 | if (width <= 0) | ||
225 | return; /* nothing left to do, 0 is harmful to lcd_write_data() */ | ||
226 | if(ymax >= LCD_REMOTE_HEIGHT) | ||
227 | ymax = LCD_REMOTE_HEIGHT-1; | ||
228 | |||
229 | /* Copy specified rectangle bitmap to hardware | ||
230 | COM48-COM63 are not connected, so we need to skip those */ | ||
231 | for (; y <= ymax; y++) | ||
232 | { | ||
233 | lcd_remote_write_command(LCD_SET_PAGE | | ||
234 | ((y > 5?y + 2:y) & 0xf)); | ||
235 | lcd_remote_write_command_ex(LCD_SET_COLUMN | ((x >> 4) & 0xf), | ||
236 | x & 0xf); | ||
237 | |||
238 | lcd_remote_write_data ( | ||
239 | (unsigned char *)&lcd_remote_framebuffer[y][x], width*2); | ||
240 | } | ||
241 | } | ||
242 | } | ||
243 | |||
244 | void lcd_remote_set_invert_display(bool yesno) | ||
245 | { | ||
246 | cached_invert = yesno; | ||
247 | if(remote_initialized) | ||
248 | lcd_remote_write_command(LCD_REVERSE | yesno); | ||
249 | } | ||
250 | |||
251 | void lcd_remote_set_flip(bool yesno) | ||
252 | { | ||
253 | cached_flip = yesno; | ||
254 | if(remote_initialized) { | ||
255 | if(yesno) { | ||
256 | lcd_remote_write_command(LCD_SELECT_ADC | 0); | ||
257 | lcd_remote_write_command(LCD_SELECT_SHL | 0); | ||
258 | lcd_remote_write_command_ex(LCD_SET_COM0, 16); | ||
259 | } else { | ||
260 | lcd_remote_write_command(LCD_SELECT_ADC | 1); | ||
261 | lcd_remote_write_command(LCD_SELECT_SHL | 8); | ||
262 | lcd_remote_write_command_ex(LCD_SET_COM0, 0); | ||
263 | } | ||
264 | } | ||
177 | } | 265 | } |