diff options
author | Dana Conrad <dconrad@fastmail.com> | 2021-06-26 12:07:11 -0500 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2021-07-18 12:14:35 +0000 |
commit | 3e7a09cb0dee0ee04b5c77f427bf89d990ec8d0b (patch) | |
tree | be1eb7e1d4166f60b245a0603e9f7dc11e1f5614 /firmware/target/mips/ingenic_x1000/erosqnative/lcd-erosqnative.c | |
parent | 64a24591aec049682167b193700a07572fc04c4c (diff) | |
download | rockbox-3e7a09cb0dee0ee04b5c77f427bf89d990ec8d0b.tar.gz rockbox-3e7a09cb0dee0ee04b5c77f427bf89d990ec8d0b.zip |
New Port: Eros Q Native
What works:
- LCD: 16-bit RGB565
- all buttons, including scrollwheel
- SD Card
- Battery level and charging/not charging status
- USB
- audio
- sample rate switching
- HP / LO detect, with "safe" fixed LO volume -
LO volume will only be put to user-defined max volume
if headphones are not present.
- rtc
- Plugins build, tried a couple and they seem OK
- Bootloader, installable to nand via usbboot
What doesn't work:
- Dual Boot
- power on/off has intermittent, low volume audio click
(sometimes it's completely silent, sometimes there's
a click)
- Audio uses 16-bit volume scaling, so clicking/popping
is pretty bad at lower volumes - need 32 bit volume
scaling, 24 bit I2S data
- USB HID keys not yet defined
- no jztool support
Unknowns:
- Stereo Switch pins: Direction select, AC_DC
(probably not even hooked up)
- What is the actual purpose of the Stereo Swtich?
- How does the bluetooth module connect?
"Someday" stuff:
- get LCD working at higher bit depth
- Bluetooth
Change-Id: I70dda8fc092c6e3f4352f2245e4164193f803c33
Diffstat (limited to 'firmware/target/mips/ingenic_x1000/erosqnative/lcd-erosqnative.c')
-rw-r--r-- | firmware/target/mips/ingenic_x1000/erosqnative/lcd-erosqnative.c | 188 |
1 files changed, 188 insertions, 0 deletions
diff --git a/firmware/target/mips/ingenic_x1000/erosqnative/lcd-erosqnative.c b/firmware/target/mips/ingenic_x1000/erosqnative/lcd-erosqnative.c new file mode 100644 index 0000000000..073bddb8b4 --- /dev/null +++ b/firmware/target/mips/ingenic_x1000/erosqnative/lcd-erosqnative.c | |||
@@ -0,0 +1,188 @@ | |||
1 | |||
2 | /*************************************************************************** | ||
3 | * __________ __ ___. | ||
4 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
5 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
6 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
7 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
8 | * \/ \/ \/ \/ \/ | ||
9 | * $Id$ | ||
10 | * | ||
11 | * Copyright (C) 2021 Aidan MacDonald, Dana Conrad | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or | ||
14 | * modify it under the terms of the GNU General Public License | ||
15 | * as published by the Free Software Foundation; either version 2 | ||
16 | * of the License, or (at your option) any later version. | ||
17 | * | ||
18 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
19 | * KIND, either express or implied. | ||
20 | * | ||
21 | ****************************************************************************/ | ||
22 | |||
23 | #include "lcd.h" | ||
24 | #include "kernel.h" | ||
25 | #include "lcd-x1000.h" | ||
26 | #include "gpio-x1000.h" | ||
27 | #include "system.h" | ||
28 | |||
29 | /* for reference on these command/data hex values, see the mipi dcs lcd spec. * | ||
30 | * Not everything here is there, but all the standard stuff is. */ | ||
31 | |||
32 | static const uint32_t erosqnative_lcd_cmd_enable[] = { | ||
33 | /* Set EXTC? */ | ||
34 | LCD_INSTR_CMD, 0xc8, | ||
35 | LCD_INSTR_DAT, 0xff, | ||
36 | LCD_INSTR_DAT, 0x93, | ||
37 | LCD_INSTR_DAT, 0x42, | ||
38 | /* Set Address Mode */ | ||
39 | LCD_INSTR_CMD, 0x36, | ||
40 | LCD_INSTR_DAT, 0xd8, | ||
41 | /* Pixel Format Set */ | ||
42 | LCD_INSTR_CMD, 0x3a, | ||
43 | //LCD_INSTR_DAT, 0x66, /* OF specified 18 bpp */ | ||
44 | LCD_INSTR_DAT, 0x05, /* RB seems to be happier dealing with 16 bits/pixel */ | ||
45 | /* Power Control 1? */ | ||
46 | LCD_INSTR_CMD, 0xc0, | ||
47 | LCD_INSTR_DAT, 0x15, | ||
48 | LCD_INSTR_DAT, 0x15, | ||
49 | /* Power Control 2? */ | ||
50 | LCD_INSTR_CMD, 0xc1, | ||
51 | LCD_INSTR_DAT, 0x01, | ||
52 | /* VCOM? */ | ||
53 | LCD_INSTR_CMD, 0xc5, | ||
54 | LCD_INSTR_DAT, 0xda, | ||
55 | /* ?? */ | ||
56 | LCD_INSTR_CMD, 0xb1, | ||
57 | LCD_INSTR_DAT, 0x00, | ||
58 | LCD_INSTR_DAT, 0x1b, | ||
59 | /* ?? */ | ||
60 | LCD_INSTR_CMD, 0xb4, | ||
61 | LCD_INSTR_DAT, 0x02, | ||
62 | /* Positive gamma correction? */ | ||
63 | LCD_INSTR_CMD, 0xe0, | ||
64 | LCD_INSTR_DAT, 0x0f, | ||
65 | LCD_INSTR_DAT, 0x13, | ||
66 | LCD_INSTR_DAT, 0x17, | ||
67 | LCD_INSTR_DAT, 0x04, | ||
68 | LCD_INSTR_DAT, 0x13, | ||
69 | LCD_INSTR_DAT, 0x07, | ||
70 | LCD_INSTR_DAT, 0x40, | ||
71 | LCD_INSTR_DAT, 0x39, | ||
72 | LCD_INSTR_DAT, 0x4f, | ||
73 | LCD_INSTR_DAT, 0x06, | ||
74 | LCD_INSTR_DAT, 0x0d, | ||
75 | LCD_INSTR_DAT, 0x0a, | ||
76 | LCD_INSTR_DAT, 0x1f, | ||
77 | LCD_INSTR_DAT, 0x22, | ||
78 | LCD_INSTR_DAT, 0x00, | ||
79 | /* Negative gamma correction? */ | ||
80 | LCD_INSTR_CMD, 0xe1, | ||
81 | LCD_INSTR_DAT, 0x00, | ||
82 | LCD_INSTR_DAT, 0x21, | ||
83 | LCD_INSTR_DAT, 0x24, | ||
84 | LCD_INSTR_DAT, 0x03, | ||
85 | LCD_INSTR_DAT, 0x0f, | ||
86 | LCD_INSTR_DAT, 0x05, | ||
87 | LCD_INSTR_DAT, 0x38, | ||
88 | LCD_INSTR_DAT, 0x32, | ||
89 | LCD_INSTR_DAT, 0x49, | ||
90 | LCD_INSTR_DAT, 0x00, | ||
91 | LCD_INSTR_DAT, 0x09, | ||
92 | LCD_INSTR_DAT, 0x08, | ||
93 | LCD_INSTR_DAT, 0x32, | ||
94 | LCD_INSTR_DAT, 0x35, | ||
95 | LCD_INSTR_DAT, 0x0f, | ||
96 | /* Exit Sleep */ | ||
97 | LCD_INSTR_CMD, 0x11, | ||
98 | LCD_INSTR_UDELAY, 120000, | ||
99 | /* Display On */ | ||
100 | LCD_INSTR_CMD, 0x29, | ||
101 | LCD_INSTR_UDELAY, 20000, | ||
102 | }; | ||
103 | |||
104 | /* sleep and wake copied directly from m3k */ | ||
105 | static const uint32_t erosqnative_lcd_cmd_sleep[] = { | ||
106 | /* Display OFF */ | ||
107 | LCD_INSTR_CMD, 0x28, | ||
108 | /* Sleep IN */ | ||
109 | LCD_INSTR_CMD, 0x10, | ||
110 | LCD_INSTR_UDELAY, 5000, | ||
111 | LCD_INSTR_END, | ||
112 | }; | ||
113 | |||
114 | static const uint32_t erosqnative_lcd_cmd_wake[] = { | ||
115 | /* Sleep OUT */ | ||
116 | LCD_INSTR_CMD, 0x11, | ||
117 | LCD_INSTR_UDELAY, 5000, | ||
118 | /* Display ON */ | ||
119 | LCD_INSTR_CMD, 0x29, | ||
120 | LCD_INSTR_END, | ||
121 | }; | ||
122 | |||
123 | /* As far as I can tell, this is a sequence of commands sent before each | ||
124 | * DMA set. Original in OF was: | ||
125 | * {0x2c, 0x2c, 0x2c, 0x2c} | ||
126 | * But this set from the m3k seems to work the same, and makes more sense | ||
127 | * to me: | ||
128 | * {0x00, 0x00, 0x00, 0x2c} | ||
129 | * This command is more than likely going to be the same | ||
130 | * for any old mipi lcd on the market, maybe. I really don't think we need | ||
131 | * to send "write_memory_start four times in a row. */ | ||
132 | static const uint8_t __attribute__((aligned(64))) | ||
133 | erosqnative_lcd_dma_wr_cmd[] = {0x2c, 0x2c, 0x2c, 0x2c}; | ||
134 | |||
135 | const struct lcd_tgt_config lcd_tgt_config = { | ||
136 | .bus_width = 8, | ||
137 | .cmd_width = 8, | ||
138 | .use_6800_mode = 0, | ||
139 | .use_serial = 0, | ||
140 | .clk_polarity = 0, | ||
141 | .dc_polarity = 0, | ||
142 | .wr_polarity = 1, | ||
143 | .te_enable = 0, /* OF had TE enabled (1) */ | ||
144 | .te_polarity = 1, | ||
145 | .te_narrow = 0, | ||
146 | .dma_wr_cmd_buf = &erosqnative_lcd_dma_wr_cmd, | ||
147 | .dma_wr_cmd_size = sizeof(erosqnative_lcd_dma_wr_cmd), | ||
148 | }; | ||
149 | |||
150 | void lcd_tgt_enable(bool enable) | ||
151 | { | ||
152 | if(enable) { | ||
153 | /* power up the panel */ | ||
154 | gpio_set_level(GPIO_LCD_PWR, 1); | ||
155 | mdelay(20); | ||
156 | gpio_set_level(GPIO_LCD_RESET, 1); | ||
157 | mdelay(12); | ||
158 | |||
159 | /* set the clock */ | ||
160 | lcd_set_clock(X1000_CLK_SCLK_A, 20000000); | ||
161 | |||
162 | /* toggle chip select low (active) */ | ||
163 | gpio_set_level(GPIO_LCD_RD, 1); | ||
164 | gpio_set_level(GPIO_LCD_CE, 1); | ||
165 | mdelay(5); | ||
166 | gpio_set_level(GPIO_LCD_CE, 0); | ||
167 | |||
168 | lcd_exec_commands(&erosqnative_lcd_cmd_enable[0]); | ||
169 | } else { | ||
170 | /* doesn't flash white if we don't do anything... */ | ||
171 | #if 0 | ||
172 | lcd_exec_commands(&erosqnative_lcd_cmd_sleep[0]); | ||
173 | |||
174 | mdelay(115); // copied from m3k | ||
175 | |||
176 | gpio_set_level(GPIO_LCD_PWR, 0); | ||
177 | gpio_set_level(GPIO_LCD_RESET, 0); | ||
178 | #endif | ||
179 | } | ||
180 | } | ||
181 | |||
182 | void lcd_tgt_sleep(bool sleep) | ||
183 | { | ||
184 | if(sleep) | ||
185 | lcd_exec_commands(&erosqnative_lcd_cmd_sleep[0]); | ||
186 | else | ||
187 | lcd_exec_commands(&erosqnative_lcd_cmd_wake[0]); | ||
188 | } | ||