diff options
Diffstat (limited to 'firmware/target/arm')
7 files changed, 701 insertions, 1 deletions
diff --git a/firmware/target/arm/as3525/clock-target.h b/firmware/target/arm/as3525/clock-target.h index fd8cb021fa..1e55753555 100644 --- a/firmware/target/arm/as3525/clock-target.h +++ b/firmware/target/arm/as3525/clock-target.h | |||
@@ -56,6 +56,8 @@ | |||
56 | #define AS3525_DBOP_FREQ 24000000 | 56 | #define AS3525_DBOP_FREQ 24000000 |
57 | #elif defined(SANSA_E200V2) | 57 | #elif defined(SANSA_E200V2) |
58 | #define AS3525_DBOP_FREQ 8000000 | 58 | #define AS3525_DBOP_FREQ 8000000 |
59 | #elif defined(SANSA_C200V2) | ||
60 | #define AS3525_DBOP_FREQ 8000000 | ||
59 | #endif | 61 | #endif |
60 | 62 | ||
61 | /* macro for not giving a target clock > at the one provided */ | 63 | /* macro for not giving a target clock > at the one provided */ |
diff --git a/firmware/target/arm/as3525/sansa-c200v2/backlight-c200v2.c b/firmware/target/arm/as3525/sansa-c200v2/backlight-c200v2.c new file mode 100644 index 0000000000..ba9db6a1f5 --- /dev/null +++ b/firmware/target/arm/as3525/sansa-c200v2/backlight-c200v2.c | |||
@@ -0,0 +1,71 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: backlight-e200v2-fuze.c 19224 2008-11-26 10:21:03Z pondlife $ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardell | ||
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 | #include "config.h" | ||
22 | #include "backlight-target.h" | ||
23 | #include "system.h" | ||
24 | #include "lcd.h" | ||
25 | #include "backlight.h" | ||
26 | #include "ascodec-target.h" | ||
27 | #include "as3514.h" | ||
28 | |||
29 | /* TODO: This file is copy & pasted from backlight-e200v2-fuze.c, as I think | ||
30 | * it'll be the same for c200v2; prove it */ | ||
31 | void _backlight_set_brightness(int brightness) | ||
32 | { | ||
33 | if (brightness > 0) | ||
34 | _backlight_on(); | ||
35 | else | ||
36 | _backlight_off(); | ||
37 | } | ||
38 | |||
39 | void _backlight_on(void) | ||
40 | { | ||
41 | #ifdef HAVE_LCD_SLEEP | ||
42 | backlight_lcd_sleep_countdown(false); /* stop counter */ | ||
43 | #endif | ||
44 | #ifdef HAVE_LCD_ENABLE | ||
45 | lcd_enable(true); /* power on lcd + visible display */ | ||
46 | #endif | ||
47 | ascodec_write(AS3514_DCDC15, backlight_brightness); | ||
48 | } | ||
49 | |||
50 | void _backlight_off(void) | ||
51 | { | ||
52 | ascodec_write(AS3514_DCDC15, 0x0); | ||
53 | #ifdef HAVE_LCD_ENABLE | ||
54 | lcd_enable(false); /* power off visible display */ | ||
55 | #endif | ||
56 | #ifdef HAVE_LCD_SLEEP | ||
57 | backlight_lcd_sleep_countdown(true); /* start countdown */ | ||
58 | #endif | ||
59 | } | ||
60 | |||
61 | void _buttonlight_on(void) | ||
62 | { | ||
63 | GPIOD_DIR |= (1<<7); | ||
64 | GPIOD_PIN(7) = (1<<7); | ||
65 | } | ||
66 | |||
67 | void _buttonlight_off(void) | ||
68 | { | ||
69 | GPIOD_DIR |= (1<<7); | ||
70 | GPIOD_PIN(7) = 0; | ||
71 | } | ||
diff --git a/firmware/target/arm/as3525/sansa-c200v2/backlight-target.h b/firmware/target/arm/as3525/sansa-c200v2/backlight-target.h new file mode 100644 index 0000000000..e8a60fa881 --- /dev/null +++ b/firmware/target/arm/as3525/sansa-c200v2/backlight-target.h | |||
@@ -0,0 +1,32 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: backlight-target.h 19136 2008-11-18 13:44:27Z dave $ | ||
9 | * | ||
10 | * Copyright (C) 2006 Barry Wardell | ||
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 | #ifndef BACKLIGHT_TARGET_H | ||
22 | #define BACKLIGHT_TARGET_H | ||
23 | |||
24 | #define _backlight_init() true | ||
25 | void _backlight_on(void); | ||
26 | void _backlight_off(void); | ||
27 | void _backlight_set_brightness(int brightness); | ||
28 | int __backlight_is_on(void); | ||
29 | |||
30 | void _buttonlight_on(void); | ||
31 | void _buttonlight_off(void); | ||
32 | #endif | ||
diff --git a/firmware/target/arm/as3525/sansa-c200v2/button-c200v2.c b/firmware/target/arm/as3525/sansa-c200v2/button-c200v2.c new file mode 100644 index 0000000000..18ae41ce97 --- /dev/null +++ b/firmware/target/arm/as3525/sansa-c200v2/button-c200v2.c | |||
@@ -0,0 +1,111 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: button-e200v2.c 19035 2008-11-07 05:31:05Z jdgordon $ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardell | ||
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 | /* Taken from button-h10.c by Barry Wardell and reverse engineering by MrH. */ | ||
23 | |||
24 | #include "system.h" | ||
25 | #include "button.h" | ||
26 | #include "backlight.h" | ||
27 | #include "powermgmt.h" | ||
28 | |||
29 | |||
30 | #ifndef BOOTLOADER | ||
31 | /* Buttons */ | ||
32 | static bool hold_button = false; | ||
33 | static bool hold_button_old = false; | ||
34 | #define _button_hold() hold_button | ||
35 | #else | ||
36 | #define _button_hold() false /* FIXME */ | ||
37 | #endif /* BOOTLOADER */ | ||
38 | static int int_btn = BUTTON_NONE; | ||
39 | |||
40 | void button_init_device(void) | ||
41 | { | ||
42 | } | ||
43 | |||
44 | bool button_hold(void) | ||
45 | { | ||
46 | return _button_hold(); | ||
47 | } | ||
48 | |||
49 | /* device buttons */ | ||
50 | void button_int(void) | ||
51 | { | ||
52 | int delay = 0x50; | ||
53 | int dir_save_c = 0; | ||
54 | int afsel_save_c = 0; | ||
55 | |||
56 | int_btn = BUTTON_NONE; | ||
57 | |||
58 | /* Save the current direction and afsel */ | ||
59 | dir_save_c = GPIOC_DIR; | ||
60 | afsel_save_c = GPIOC_AFSEL; | ||
61 | |||
62 | GPIOA_DIR &= ~(1<<2); | ||
63 | GPIOC_AFSEL &= ~(1<<6|1<<5|1<<4|1<<3); | ||
64 | GPIOC_DIR |= (1<<6|1<<5|1<<4|1<<3); | ||
65 | |||
66 | /* These should not be needed with button event interupts */ | ||
67 | /* they are necessary now to clear out lcd data */ | ||
68 | |||
69 | GPIOC_PIN(6) = (1<<6); | ||
70 | GPIOC_PIN(5) = (1<<5); | ||
71 | GPIOC_PIN(4) = (1<<4); | ||
72 | GPIOC_PIN(3) = (1<<3); | ||
73 | GPIOC_DIR &= ~(1<<6|1<<5|1<<4|1<<3); | ||
74 | |||
75 | while(delay--); | ||
76 | |||
77 | /* direct GPIO connections */ | ||
78 | if (GPIOA_PIN(3)) | ||
79 | int_btn |= BUTTON_POWER; | ||
80 | if (!GPIOC_PIN(6)) | ||
81 | int_btn |= BUTTON_RIGHT; | ||
82 | if (!GPIOC_PIN(5)) | ||
83 | int_btn |= BUTTON_UP; | ||
84 | if (!GPIOC_PIN(4)) | ||
85 | int_btn |= BUTTON_SELECT; | ||
86 | if (!GPIOC_PIN(3)) | ||
87 | int_btn |= BUTTON_DOWN; | ||
88 | |||
89 | /* return to settings needed for lcd */ | ||
90 | GPIOC_DIR = dir_save_c; | ||
91 | GPIOC_AFSEL = afsel_save_c; | ||
92 | } | ||
93 | |||
94 | /* | ||
95 | * Get button pressed from hardware | ||
96 | */ | ||
97 | int button_read_device(void) | ||
98 | { | ||
99 | /* Read buttons directly */ | ||
100 | button_int(); | ||
101 | #ifndef BOOTLOADER | ||
102 | /* light handling */ | ||
103 | if (hold_button != hold_button_old) | ||
104 | { | ||
105 | hold_button_old = hold_button; | ||
106 | backlight_hold_changed(hold_button); | ||
107 | } | ||
108 | #endif /* BOOTLOADER */ | ||
109 | |||
110 | return int_btn; | ||
111 | } | ||
diff --git a/firmware/target/arm/as3525/sansa-c200v2/button-target.h b/firmware/target/arm/as3525/sansa-c200v2/button-target.h new file mode 100644 index 0000000000..cc668c4015 --- /dev/null +++ b/firmware/target/arm/as3525/sansa-c200v2/button-target.h | |||
@@ -0,0 +1,55 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id:$ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Mark Arigo | ||
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 | #ifndef _BUTTON_TARGET_H_ | ||
23 | #define _BUTTON_TARGET_H_ | ||
24 | |||
25 | #include <stdbool.h> | ||
26 | #include "config.h" | ||
27 | |||
28 | #define HAS_BUTTON_HOLD | ||
29 | |||
30 | bool button_hold(void); | ||
31 | void button_init_device(void); | ||
32 | int button_read_device(void); | ||
33 | |||
34 | /* Sandisk Sansa c200 button codes */ | ||
35 | |||
36 | /* Main unit's buttons */ | ||
37 | #define BUTTON_REC 0x00000001 | ||
38 | #define BUTTON_DOWN 0x00000002 | ||
39 | #define BUTTON_RIGHT 0x00000004 | ||
40 | #define BUTTON_LEFT 0x00000008 | ||
41 | #define BUTTON_SELECT 0x00000010 | ||
42 | #define BUTTON_UP 0x00000020 | ||
43 | #define BUTTON_POWER 0x00000040 | ||
44 | #define BUTTON_VOL_UP 0x00000080 | ||
45 | #define BUTTON_VOL_DOWN 0x00000100 | ||
46 | |||
47 | #define BUTTON_MAIN 0x00000fff | ||
48 | |||
49 | /* No Remote control */ | ||
50 | #define BUTTON_REMOTE 0 | ||
51 | |||
52 | #define POWEROFF_BUTTON BUTTON_POWER | ||
53 | #define POWEROFF_COUNT 10 | ||
54 | |||
55 | #endif /* _BUTTON_TARGET_H_ */ | ||
diff --git a/firmware/target/arm/as3525/sansa-c200v2/lcd-c200v2.c b/firmware/target/arm/as3525/sansa-c200v2/lcd-c200v2.c new file mode 100644 index 0000000000..2fc3e1f6c5 --- /dev/null +++ b/firmware/target/arm/as3525/sansa-c200v2/lcd-c200v2.c | |||
@@ -0,0 +1,429 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: lcd-e200v2.c 19453 2008-12-16 02:50:39Z saratoga $ | ||
9 | * | ||
10 | * Copyright (C) 2004 by Linus Nielsen Feltzing | ||
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 | /* FIXME: Copied from e200v2 lcd driver, unlikely to work, but maybe */ | ||
23 | |||
24 | #include "config.h" | ||
25 | |||
26 | #include "cpu.h" | ||
27 | #include "lcd.h" | ||
28 | #include "kernel.h" | ||
29 | #include "thread.h" | ||
30 | #include <string.h> | ||
31 | #include <stdlib.h> | ||
32 | #include "file.h" | ||
33 | #include "debug.h" | ||
34 | #include "system.h" | ||
35 | #include "font.h" | ||
36 | #include "bidi.h" | ||
37 | #include "clock-target.h" | ||
38 | |||
39 | static bool display_on = false; /* is the display turned on? */ | ||
40 | static bool display_flipped = false; | ||
41 | static int y_offset = 0; /* needed for flip */ | ||
42 | |||
43 | /* register defines */ | ||
44 | #define R_START_OSC 0x00 | ||
45 | #define R_DRV_OUTPUT_CONTROL 0x01 | ||
46 | #define R_DRV_WAVEFORM_CONTROL 0x02 | ||
47 | #define R_ENTRY_MODE 0x03 | ||
48 | #define R_COMPARE_REG1 0x04 | ||
49 | #define R_COMPARE_REG2 0x05 | ||
50 | |||
51 | #define R_DISP_CONTROL1 0x07 | ||
52 | #define R_DISP_CONTROL2 0x08 | ||
53 | #define R_DISP_CONTROL3 0x09 | ||
54 | |||
55 | #define R_FRAME_CYCLE_CONTROL 0x0b | ||
56 | #define R_EXT_DISP_IF_CONTROL 0x0c | ||
57 | |||
58 | #define R_POWER_CONTROL1 0x10 | ||
59 | #define R_POWER_CONTROL2 0x11 | ||
60 | #define R_POWER_CONTROL3 0x12 | ||
61 | #define R_POWER_CONTROL4 0x13 | ||
62 | |||
63 | #define R_RAM_ADDR_SET 0x21 | ||
64 | #define R_WRITE_DATA_2_GRAM 0x22 | ||
65 | |||
66 | #define R_GAMMA_FINE_ADJ_POS1 0x30 | ||
67 | #define R_GAMMA_FINE_ADJ_POS2 0x31 | ||
68 | #define R_GAMMA_FINE_ADJ_POS3 0x32 | ||
69 | #define R_GAMMA_GRAD_ADJ_POS 0x33 | ||
70 | |||
71 | #define R_GAMMA_FINE_ADJ_NEG1 0x34 | ||
72 | #define R_GAMMA_FINE_ADJ_NEG2 0x35 | ||
73 | #define R_GAMMA_FINE_ADJ_NEG3 0x36 | ||
74 | #define R_GAMMA_GRAD_ADJ_NEG 0x37 | ||
75 | |||
76 | #define R_GAMMA_AMP_ADJ_RES_POS 0x38 | ||
77 | #define R_GAMMA_AMP_AVG_ADJ_RES_NEG 0x39 | ||
78 | |||
79 | #define R_GATE_SCAN_POS 0x40 | ||
80 | #define R_VERT_SCROLL_CONTROL 0x41 | ||
81 | #define R_1ST_SCR_DRV_POS 0x42 | ||
82 | #define R_2ND_SCR_DRV_POS 0x43 | ||
83 | #define R_HORIZ_RAM_ADDR_POS 0x44 | ||
84 | #define R_VERT_RAM_ADDR_POS 0x45 | ||
85 | |||
86 | #define R_ENTRY_MODE_HORZ 0x7030 | ||
87 | #define R_ENTRY_MODE_VERT 0x7038 | ||
88 | #define R_ENTRY_MODE_SOLID_VERT 0x1038 | ||
89 | |||
90 | /* TODO: Implement this function */ | ||
91 | static void lcd_delay(int x) | ||
92 | { | ||
93 | /* This is just arbitrary - the OF does something more complex */ | ||
94 | x *= 1024; | ||
95 | while (x--); | ||
96 | } | ||
97 | |||
98 | /* DBOP initialisation, do what OF does */ | ||
99 | static void ams3525_dbop_init(void) | ||
100 | { | ||
101 | CGU_DBOP = (1<<3) | CLK_DIV(AS3525_PCLK_FREQ, AS3525_DBOP_FREQ); | ||
102 | |||
103 | DBOP_TIMPOL_01 = 0xe167e167; | ||
104 | DBOP_TIMPOL_23 = 0xe167006e; | ||
105 | DBOP_CTRL = 0x41008; | ||
106 | |||
107 | GPIOB_AFSEL = 0xfc; | ||
108 | GPIOC_AFSEL = 0xff; | ||
109 | |||
110 | DBOP_TIMPOL_23 = 0x6000e; | ||
111 | DBOP_CTRL = 0x51008; | ||
112 | DBOP_TIMPOL_01 = 0x6e167; | ||
113 | DBOP_TIMPOL_23 = 0xa167e06f; | ||
114 | |||
115 | /* TODO: The OF calls some other functions here, but maybe not important */ | ||
116 | } | ||
117 | |||
118 | |||
119 | static void lcd_write_cmd(int cmd) | ||
120 | { | ||
121 | /* Write register */ | ||
122 | DBOP_CTRL &= ~(1<<14); | ||
123 | |||
124 | DBOP_TIMPOL_23 = 0xa167006e; | ||
125 | |||
126 | DBOP_DOUT = cmd; | ||
127 | |||
128 | /* Wait for fifo to empty */ | ||
129 | while ((DBOP_STAT & (1<<10)) == 0); | ||
130 | |||
131 | DBOP_TIMPOL_23 = 0xa167e06f; | ||
132 | } | ||
133 | |||
134 | void lcd_write_data(const fb_data* p_bytes, int count) | ||
135 | { | ||
136 | while (count--) | ||
137 | { | ||
138 | DBOP_DOUT = *p_bytes++; | ||
139 | |||
140 | /* Wait for fifo to empty */ | ||
141 | while ((DBOP_STAT & (1<<10)) == 0); | ||
142 | } | ||
143 | } | ||
144 | |||
145 | static void lcd_write_reg(int reg, int value) | ||
146 | { | ||
147 | unsigned short data = value; | ||
148 | |||
149 | lcd_write_cmd(reg); | ||
150 | lcd_write_data(&data, 1); | ||
151 | } | ||
152 | |||
153 | /*** hardware configuration ***/ | ||
154 | |||
155 | void lcd_set_contrast(int val) | ||
156 | { | ||
157 | (void)val; | ||
158 | } | ||
159 | |||
160 | void lcd_set_invert_display(bool yesno) | ||
161 | { | ||
162 | (void)yesno; | ||
163 | } | ||
164 | |||
165 | static void flip_lcd(bool yesno) | ||
166 | { | ||
167 | (void)yesno; | ||
168 | } | ||
169 | |||
170 | |||
171 | /* turn the display upside down (call lcd_update() afterwards) */ | ||
172 | void lcd_set_flip(bool yesno) | ||
173 | { | ||
174 | display_flipped = yesno; | ||
175 | y_offset = yesno ? 4 : 0; /* FIXME: Is a y_offset needed? */ | ||
176 | |||
177 | if (display_on) | ||
178 | flip_lcd(yesno); | ||
179 | } | ||
180 | |||
181 | static void _display_on(void) | ||
182 | { | ||
183 | /* Initialisation the display the same way as the original firmware */ | ||
184 | |||
185 | lcd_write_reg(R_START_OSC, 0x0001); /* Start Oscilation */ | ||
186 | |||
187 | lcd_write_reg(R_DRV_OUTPUT_CONTROL, 0x011b); /* 220 lines, GS=0, SS=1 */ | ||
188 | |||
189 | /* B/C = 1: n-line inversion form | ||
190 | * EOR = 1: polarity inversion occurs by applying an EOR to odd/even | ||
191 | * frame select signal and an n-line inversion signal. | ||
192 | * FLD = 01b: 1 field interlaced scan, external display iface */ | ||
193 | lcd_write_reg(R_DRV_WAVEFORM_CONTROL, 0x0700); | ||
194 | |||
195 | /* Address counter updated in horizontal direction; left to right; | ||
196 | * vertical increment horizontal increment. | ||
197 | * data format for 8bit transfer or spi = 65k (5,6,5) */ | ||
198 | lcd_write_reg(R_ENTRY_MODE, 0x0030); | ||
199 | |||
200 | /* Replace data on writing to GRAM */ | ||
201 | lcd_write_reg(R_COMPARE_REG1, 0); | ||
202 | lcd_write_reg(R_COMPARE_REG2, 0); | ||
203 | |||
204 | lcd_write_reg(R_DISP_CONTROL1, 0x0000); /* GON = 0, DTE = 0, D1-0 = 00b */ | ||
205 | |||
206 | /* Front porch lines: 2; Back porch lines: 2; */ | ||
207 | lcd_write_reg(R_DISP_CONTROL2, 0x0203); | ||
208 | |||
209 | /* Scan cycle = 0 frames */ | ||
210 | lcd_write_reg(R_DISP_CONTROL3, 0x0000); | ||
211 | |||
212 | /* 16 clocks */ | ||
213 | lcd_write_reg(R_FRAME_CYCLE_CONTROL, 0x0000); | ||
214 | |||
215 | /* 18-bit RGB interface (one transfer/pixel) | ||
216 | * internal clock operation; | ||
217 | * System interface/VSYNC interface */ | ||
218 | lcd_write_reg(R_EXT_DISP_IF_CONTROL, 0x0000); | ||
219 | |||
220 | |||
221 | /* zero everything*/ | ||
222 | lcd_write_reg(R_POWER_CONTROL1, 0x0000); /* STB = 0, SLP = 0 */ | ||
223 | |||
224 | lcd_delay(10); | ||
225 | |||
226 | /* initialise power supply */ | ||
227 | |||
228 | /* DC12-10 = 000b: Step-up1 = clock/8, | ||
229 | * DC02-00 = 000b: Step-up2 = clock/16, | ||
230 | * VC2-0 = 010b: VciOUT = 0.87 * VciLVL */ | ||
231 | lcd_write_reg(R_POWER_CONTROL2, 0x0002); | ||
232 | |||
233 | /* VRH3-0 = 1000b: Vreg1OUT = REGP * 1.90 */ | ||
234 | lcd_write_reg(R_POWER_CONTROL3, 0x0008); | ||
235 | |||
236 | lcd_delay(40); | ||
237 | |||
238 | lcd_write_reg(R_POWER_CONTROL4, 0x0000); /* VCOMG = 0 */ | ||
239 | |||
240 | /* This register is unknown */ | ||
241 | lcd_write_reg(0x56, 0x80f); | ||
242 | |||
243 | |||
244 | lcd_write_reg(R_POWER_CONTROL1, 0x4140); | ||
245 | |||
246 | lcd_delay(10); | ||
247 | |||
248 | lcd_write_reg(R_POWER_CONTROL2, 0x0000); | ||
249 | lcd_write_reg(R_POWER_CONTROL3, 0x0013); | ||
250 | |||
251 | lcd_delay(20); | ||
252 | |||
253 | lcd_write_reg(R_POWER_CONTROL4, 0x6d0e); | ||
254 | |||
255 | lcd_delay(20); | ||
256 | |||
257 | lcd_write_reg(R_POWER_CONTROL4, 0x6d0e); | ||
258 | |||
259 | lcd_write_reg(R_GAMMA_FINE_ADJ_POS1, 0x0002); | ||
260 | lcd_write_reg(R_GAMMA_FINE_ADJ_POS2, 0x0707); | ||
261 | lcd_write_reg(R_GAMMA_FINE_ADJ_POS3, 0x0182); | ||
262 | lcd_write_reg(R_GAMMA_GRAD_ADJ_POS, 0x0203); | ||
263 | lcd_write_reg(R_GAMMA_FINE_ADJ_NEG1, 0x0706); | ||
264 | lcd_write_reg(R_GAMMA_FINE_ADJ_NEG2, 0x0006); | ||
265 | lcd_write_reg(R_GAMMA_FINE_ADJ_NEG3, 0x0706); | ||
266 | lcd_write_reg(R_GAMMA_GRAD_ADJ_NEG, 0x0000); | ||
267 | lcd_write_reg(R_GAMMA_AMP_ADJ_RES_POS, 0x030f); | ||
268 | lcd_write_reg(R_GAMMA_AMP_AVG_ADJ_RES_NEG, 0x0f08); | ||
269 | |||
270 | |||
271 | lcd_write_reg(R_RAM_ADDR_SET, 0); | ||
272 | lcd_write_reg(R_GATE_SCAN_POS, 0); | ||
273 | lcd_write_reg(R_VERT_SCROLL_CONTROL, 0); | ||
274 | |||
275 | lcd_write_reg(R_1ST_SCR_DRV_POS, (LCD_HEIGHT-1) << 8); | ||
276 | lcd_write_reg(R_2ND_SCR_DRV_POS, (LCD_HEIGHT-1) << 8); | ||
277 | |||
278 | lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (LCD_WIDTH-1) << 8); | ||
279 | lcd_write_reg(R_VERT_RAM_ADDR_POS, (LCD_HEIGHT-1) << 8); | ||
280 | |||
281 | |||
282 | lcd_write_reg(R_DISP_CONTROL1, 0x0037); | ||
283 | |||
284 | display_on=true; /* must be done before calling lcd_update() */ | ||
285 | lcd_update(); | ||
286 | } | ||
287 | |||
288 | /* LCD init */ | ||
289 | void lcd_init_device(void) | ||
290 | { | ||
291 | ams3525_dbop_init(); | ||
292 | |||
293 | /* Init GPIOs the same as the OF */ | ||
294 | |||
295 | GPIOA_DIR |= (1<<5); | ||
296 | GPIOA_PIN(5) = 0; | ||
297 | |||
298 | GPIOA_PIN(3) = (1<<3); | ||
299 | |||
300 | GPIOA_DIR |= (3<<3); | ||
301 | |||
302 | GPIOA_PIN(3) = (1<<3); | ||
303 | |||
304 | GPIOA_PIN(4) = 0; /*c80b0040 := 0;*/ | ||
305 | |||
306 | GPIOA_DIR |= (1<<7); | ||
307 | GPIOA_PIN(7) = 0; | ||
308 | |||
309 | lcd_delay(1); | ||
310 | |||
311 | GPIOA_PIN(5) = (1<<5); | ||
312 | |||
313 | lcd_delay(1); | ||
314 | |||
315 | _display_on(); | ||
316 | } | ||
317 | |||
318 | void lcd_enable(bool on) | ||
319 | { | ||
320 | if(display_on!=on) | ||
321 | { | ||
322 | if(on) | ||
323 | { | ||
324 | _display_on(); | ||
325 | lcd_call_enable_hook(); | ||
326 | } | ||
327 | else | ||
328 | { | ||
329 | /* TODO: Implement off sequence */ | ||
330 | display_on=false; | ||
331 | } | ||
332 | } | ||
333 | } | ||
334 | |||
335 | bool lcd_enabled(void) | ||
336 | { | ||
337 | return display_on; | ||
338 | } | ||
339 | |||
340 | void lcd_sleep(void) | ||
341 | { | ||
342 | /* TODO */ | ||
343 | } | ||
344 | |||
345 | /*** update functions ***/ | ||
346 | |||
347 | /* Performance function to blit a YUV bitmap directly to the LCD | ||
348 | * src_x, src_y, width and height should be even | ||
349 | * x, y, width and height have to be within LCD bounds | ||
350 | */ | ||
351 | void lcd_blit_yuv(unsigned char * const src[3], | ||
352 | int src_x, int src_y, int stride, | ||
353 | int x, int y, int width, int height) | ||
354 | { | ||
355 | (void)src; | ||
356 | (void)src_x; | ||
357 | (void)src_y; | ||
358 | (void)stride; | ||
359 | (void)x; | ||
360 | (void)y; | ||
361 | (void)width; | ||
362 | (void)height; | ||
363 | } | ||
364 | |||
365 | /* Update the display. | ||
366 | This must be called after all other LCD functions that change the display. */ | ||
367 | void lcd_update(void) | ||
368 | { | ||
369 | if (!display_on) | ||
370 | return; | ||
371 | |||
372 | lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ); | ||
373 | |||
374 | /* Set start position and window */ | ||
375 | lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (LCD_WIDTH-1) << 8); | ||
376 | lcd_write_reg(R_VERT_RAM_ADDR_POS, | ||
377 | ((y_offset + LCD_HEIGHT-1) << 8) | y_offset); | ||
378 | lcd_write_reg(R_RAM_ADDR_SET, (y_offset) << 8); | ||
379 | |||
380 | lcd_write_cmd(R_WRITE_DATA_2_GRAM); | ||
381 | |||
382 | lcd_write_data((unsigned short *)lcd_framebuffer, LCD_WIDTH*LCD_HEIGHT); | ||
383 | |||
384 | } /* lcd_update */ | ||
385 | |||
386 | |||
387 | /* Update a fraction of the display. */ | ||
388 | void lcd_update_rect(int x, int y, int width, int height) | ||
389 | { | ||
390 | int ymax; | ||
391 | const unsigned short *ptr; | ||
392 | |||
393 | if (!display_on) | ||
394 | return; | ||
395 | |||
396 | if (x + width > LCD_WIDTH) | ||
397 | width = LCD_WIDTH - x; /* Clip right */ | ||
398 | if (x < 0) | ||
399 | width += x, x = 0; /* Clip left */ | ||
400 | if (width <= 0) | ||
401 | return; /* nothing left to do */ | ||
402 | |||
403 | ymax = y + height; | ||
404 | if (ymax > LCD_HEIGHT) | ||
405 | ymax = LCD_HEIGHT; /* Clip bottom */ | ||
406 | if (y < 0) | ||
407 | y = 0; /* Clip top */ | ||
408 | if (y >= ymax) | ||
409 | return; /* nothing left to do */ | ||
410 | |||
411 | lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ); | ||
412 | /* Set start position and window */ | ||
413 | lcd_write_reg(R_HORIZ_RAM_ADDR_POS, | ||
414 | ((x + width-1) << 8) | x); | ||
415 | lcd_write_reg(R_VERT_RAM_ADDR_POS, | ||
416 | ((y_offset + y + height - 1) << 8) | (y_offset + y)); | ||
417 | lcd_write_reg(R_RAM_ADDR_SET, ((y + y_offset) << 8) | x); | ||
418 | |||
419 | lcd_write_cmd(R_WRITE_DATA_2_GRAM); | ||
420 | |||
421 | ptr = (unsigned short *)&lcd_framebuffer[y][x]; | ||
422 | |||
423 | do | ||
424 | { | ||
425 | lcd_write_data(ptr, width); | ||
426 | ptr += LCD_WIDTH; | ||
427 | } | ||
428 | while (++y < ymax); | ||
429 | } /* lcd_update_rect */ | ||
diff --git a/firmware/target/arm/as3525/system-as3525.c b/firmware/target/arm/as3525/system-as3525.c index c2a2e4f47d..f2f2c0b454 100644 --- a/firmware/target/arm/as3525/system-as3525.c +++ b/firmware/target/arm/as3525/system-as3525.c | |||
@@ -183,7 +183,7 @@ static void sdram_init(void) | |||
183 | MPMC_DYNAMIC_tRRD = 2; | 183 | MPMC_DYNAMIC_tRRD = 2; |
184 | MPMC_DYNAMIC_tMRD = 2; | 184 | MPMC_DYNAMIC_tMRD = 2; |
185 | 185 | ||
186 | #if defined(SANSA_CLIP) || defined(SANSA_M200V4) | 186 | #if defined(SANSA_CLIP) || defined(SANSA_M200V4) || defined(SANSA_C200V2) |
187 | /* 16 bits external bus, low power SDRAM, 16 Mbits = 2 Mbytes */ | 187 | /* 16 bits external bus, low power SDRAM, 16 Mbits = 2 Mbytes */ |
188 | #define MEMORY_MODEL 0x21 | 188 | #define MEMORY_MODEL 0x21 |
189 | 189 | ||