diff options
Diffstat (limited to 'firmware/target/arm/imx233/creative-zenxfi2/lcd-zenxfi2.c')
-rw-r--r-- | firmware/target/arm/imx233/creative-zenxfi2/lcd-zenxfi2.c | 84 |
1 files changed, 14 insertions, 70 deletions
diff --git a/firmware/target/arm/imx233/creative-zenxfi2/lcd-zenxfi2.c b/firmware/target/arm/imx233/creative-zenxfi2/lcd-zenxfi2.c index 9ff64c4c14..0131a39233 100644 --- a/firmware/target/arm/imx233/creative-zenxfi2/lcd-zenxfi2.c +++ b/firmware/target/arm/imx233/creative-zenxfi2/lcd-zenxfi2.c | |||
@@ -34,66 +34,15 @@ static bool lcd_on; | |||
34 | #endif | 34 | #endif |
35 | static unsigned lcd_yuv_options = 0; | 35 | static unsigned lcd_yuv_options = 0; |
36 | 36 | ||
37 | static void setup_parameters(void) | 37 | static void setup_lcdif(void) |
38 | { | 38 | { |
39 | imx233_lcdif_reset(); | 39 | imx233_lcdif_init(); |
40 | imx233_lcdif_set_lcd_databus_width(BV_LCDIF_CTRL_LCD_DATABUS_WIDTH__18_BIT); | 40 | imx233_lcdif_set_lcd_databus_width(18); |
41 | imx233_lcdif_set_word_length(BV_LCDIF_CTRL_WORD_LENGTH__18_BIT); | 41 | imx233_lcdif_set_word_length(18); |
42 | imx233_lcdif_set_timings(2, 2, 3, 3); | 42 | imx233_lcdif_set_timings(2, 2, 3, 3); |
43 | imx233_lcdif_enable_underflow_recover(true); | 43 | imx233_lcdif_enable_underflow_recover(true); |
44 | } | 44 | imx233_lcdif_enable(true); |
45 | 45 | imx233_lcdif_setup_system_pins(18); | |
46 | static void setup_lcd_pins(bool use_lcdif) | ||
47 | { | ||
48 | imx233_pinctrl_acquire(1, 18, "lcd reset"); | ||
49 | imx233_pinctrl_acquire(1, 19, "lcd rs"); | ||
50 | imx233_pinctrl_acquire(1, 20, "lcd wr"); | ||
51 | imx233_pinctrl_acquire(1, 21, "lcd cs"); | ||
52 | imx233_pinctrl_acquire(1, 22, "lcd dotclk"); | ||
53 | imx233_pinctrl_acquire(1, 23, "lcd enable"); | ||
54 | imx233_pinctrl_acquire(1, 24, "lcd hsync"); | ||
55 | imx233_pinctrl_acquire(1, 25, "lcd vsync"); | ||
56 | //imx233_pinctrl_acquire_mask(1, 0x3ffff, "lcd data"); | ||
57 | if(use_lcdif) | ||
58 | { | ||
59 | imx233_pinctrl_set_function(1, 25, PINCTRL_FUNCTION_MAIN); /* lcd_vsync */ | ||
60 | imx233_pinctrl_set_function(1, 21, PINCTRL_FUNCTION_MAIN); /* lcd_cs */ | ||
61 | imx233_pinctrl_set_function(1, 22, PINCTRL_FUNCTION_MAIN); /* lcd_dotclk */ | ||
62 | imx233_pinctrl_set_function(1, 23, PINCTRL_FUNCTION_MAIN); /* lcd_enable */ | ||
63 | imx233_pinctrl_set_function(1, 24, PINCTRL_FUNCTION_MAIN); /* lcd_hsync */ | ||
64 | imx233_pinctrl_set_function(1, 18, PINCTRL_FUNCTION_MAIN); /* lcd_reset */ | ||
65 | imx233_pinctrl_set_function(1, 19, PINCTRL_FUNCTION_MAIN); /* lcd_rs */ | ||
66 | imx233_pinctrl_set_function(1, 16, PINCTRL_FUNCTION_MAIN); /* lcd_d16 */ | ||
67 | imx233_pinctrl_set_function(1, 17, PINCTRL_FUNCTION_MAIN); /* lcd_d17 */ | ||
68 | imx233_pinctrl_set_function(1, 20, PINCTRL_FUNCTION_MAIN); /* lcd_wr */ | ||
69 | HW_PINCTRL_MUXSELn_CLR(2) = 0xffffffff; /* lcd_d{0-15} */ | ||
70 | } | ||
71 | else | ||
72 | { | ||
73 | HW_PINCTRL_MUXSELn_SET(2) = 0xffffffff; /* lcd_d{0-15} */ | ||
74 | HW_PINCTRL_DOEn_CLR(1) = 0x3ffffff; /* lcd_{d{0-17},reset,rs,wr,cs,dotclk,enable,hsync,vsync} */ | ||
75 | imx233_pinctrl_set_function(1, 16, PINCTRL_FUNCTION_GPIO); /* lcd_d16 */ | ||
76 | imx233_pinctrl_set_function(1, 17, PINCTRL_FUNCTION_GPIO); /* lcd_d17 */ | ||
77 | imx233_pinctrl_set_function(1, 19, PINCTRL_FUNCTION_GPIO); /* lcd_rs */ | ||
78 | imx233_pinctrl_set_function(1, 20, PINCTRL_FUNCTION_GPIO); /* lcd_wr */ | ||
79 | imx233_pinctrl_set_function(1, 21, PINCTRL_FUNCTION_GPIO); /* lcd_cs */ | ||
80 | imx233_pinctrl_set_function(1, 22, PINCTRL_FUNCTION_GPIO); /* lcd_dotclk */ | ||
81 | imx233_pinctrl_set_function(1, 23, PINCTRL_FUNCTION_GPIO); /* lcd_enable */ | ||
82 | imx233_pinctrl_set_function(1, 24, PINCTRL_FUNCTION_GPIO); /* lcd_hsync */ | ||
83 | imx233_pinctrl_set_function(1, 25, PINCTRL_FUNCTION_GPIO); /* lcd_vsync */ | ||
84 | } | ||
85 | } | ||
86 | |||
87 | static void common_lcd_enable(bool enable) | ||
88 | { | ||
89 | imx233_lcdif_enable(enable); | ||
90 | setup_lcd_pins(enable); /* use GPIO pins when disable */ | ||
91 | } | ||
92 | |||
93 | static void setup_lcdif(void) | ||
94 | { | ||
95 | setup_parameters(); | ||
96 | common_lcd_enable(true); | ||
97 | imx233_lcdif_enable_bus_master(true); | 46 | imx233_lcdif_enable_bus_master(true); |
98 | } | 47 | } |
99 | 48 | ||
@@ -120,13 +69,13 @@ static void lcd_write_reg(uint32_t reg, uint32_t data) | |||
120 | { | 69 | { |
121 | uint32_t old_reg = reg; | 70 | uint32_t old_reg = reg; |
122 | /* get back to 18-bit word length */ | 71 | /* get back to 18-bit word length */ |
123 | imx233_lcdif_set_word_length(BV_LCDIF_CTRL_WORD_LENGTH__18_BIT); | 72 | imx233_lcdif_set_word_length(18); |
124 | reg = encode_16_to_18(reg); | 73 | reg = encode_16_to_18(reg); |
125 | data = encode_16_to_18(data); | 74 | data = encode_16_to_18(data); |
126 | 75 | ||
127 | imx233_lcdif_pio_send(false, 2, ®); | 76 | imx233_lcdif_pio_send(false, 1, ®); |
128 | if(old_reg != 0 && old_reg != 0x202) | 77 | if(old_reg != 0 && old_reg != 0x202) |
129 | imx233_lcdif_pio_send(true, 2, &data); | 78 | imx233_lcdif_pio_send(true, 1, &data); |
130 | } | 79 | } |
131 | 80 | ||
132 | #define REG_MDELAY 0xffffffff | 81 | #define REG_MDELAY 0xffffffff |
@@ -208,11 +157,11 @@ void lcd_init_device(void) | |||
208 | setup_lcdif_clock(); | 157 | setup_lcdif_clock(); |
209 | 158 | ||
210 | // reset device | 159 | // reset device |
211 | BF_SET(LCDIF_CTRL1, RESET); | 160 | imx233_lcdif_reset_lcd(true); |
212 | mdelay(50); | 161 | mdelay(50); |
213 | BF_CLR(LCDIF_CTRL1, RESET); | 162 | imx233_lcdif_reset_lcd(false); |
214 | mdelay(10); | 163 | mdelay(10); |
215 | BF_SET(LCDIF_CTRL1, RESET); | 164 | imx233_lcdif_reset_lcd(true); |
216 | 165 | ||
217 | lcd_init_seq(); | 166 | lcd_init_seq(); |
218 | #ifdef HAVE_LCD_ENABLE | 167 | #ifdef HAVE_LCD_ENABLE |
@@ -247,12 +196,8 @@ void lcd_enable(bool enable) | |||
247 | 196 | ||
248 | lcd_on = enable; | 197 | lcd_on = enable; |
249 | 198 | ||
250 | if(enable) | ||
251 | common_lcd_enable(true); | ||
252 | lcd_enable_seq(enable); | 199 | lcd_enable_seq(enable); |
253 | if(!enable) | 200 | if(enable) |
254 | common_lcd_enable(false); | ||
255 | else | ||
256 | send_event(LCD_EVENT_ACTIVATION, NULL); | 201 | send_event(LCD_EVENT_ACTIVATION, NULL); |
257 | } | 202 | } |
258 | #endif | 203 | #endif |
@@ -283,9 +228,8 @@ void lcd_update_rect(int x, int y, int w, int h) | |||
283 | lcd_write_reg(0x201, 0); | 228 | lcd_write_reg(0x201, 0); |
284 | lcd_write_reg(0x202, 0); | 229 | lcd_write_reg(0x202, 0); |
285 | imx233_lcdif_wait_ready(); | 230 | imx233_lcdif_wait_ready(); |
286 | imx233_lcdif_set_word_length(BV_LCDIF_CTRL_WORD_LENGTH__16_BIT); | 231 | imx233_lcdif_set_word_length(16); |
287 | imx233_lcdif_set_byte_packing_format(0xf); /* two pixels per 32-bit word */ | 232 | imx233_lcdif_set_byte_packing_format(0xf); /* two pixels per 32-bit word */ |
288 | imx233_lcdif_set_data_format(false, false, false); /* RGB565, don't care, don't care */ | ||
289 | 233 | ||
290 | /* there are two cases here: | 234 | /* there are two cases here: |
291 | * - either width = LCD_WIDTH and we can directly memcopy a part of lcd_framebuffer to FRAME | 235 | * - either width = LCD_WIDTH and we can directly memcopy a part of lcd_framebuffer to FRAME |