diff options
Diffstat (limited to 'firmware/target/arm/imx233/creative-zenmozaic/lcd-zenmozaic.c')
-rw-r--r-- | firmware/target/arm/imx233/creative-zenmozaic/lcd-zenmozaic.c | 152 |
1 files changed, 152 insertions, 0 deletions
diff --git a/firmware/target/arm/imx233/creative-zenmozaic/lcd-zenmozaic.c b/firmware/target/arm/imx233/creative-zenmozaic/lcd-zenmozaic.c new file mode 100644 index 0000000000..eac36676ae --- /dev/null +++ b/firmware/target/arm/imx233/creative-zenmozaic/lcd-zenmozaic.c | |||
@@ -0,0 +1,152 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (c) 2013 by Amaury Pouly | ||
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 <sys/types.h> /* off_t */ | ||
22 | #include <string.h> | ||
23 | #include "cpu.h" | ||
24 | #include "system.h" | ||
25 | #include "backlight-target.h" | ||
26 | #include "lcd.h" | ||
27 | #include "lcdif-imx233.h" | ||
28 | #include "clkctrl-imx233.h" | ||
29 | #include "pinctrl-imx233.h" | ||
30 | #include "dcp-imx233.h" | ||
31 | #include "logf.h" | ||
32 | #ifndef BOOTLOADER | ||
33 | #include "button.h" | ||
34 | #include "font.h" | ||
35 | #include "action.h" | ||
36 | #endif | ||
37 | |||
38 | #ifdef HAVE_LCD_ENABLE | ||
39 | static bool lcd_on; | ||
40 | #endif | ||
41 | |||
42 | static void lcd_write_reg(uint16_t reg, uint16_t value) | ||
43 | { | ||
44 | imx233_lcdif_set_data_swizzle(3); | ||
45 | imx233_lcdif_pio_send(false, 2, ®); | ||
46 | if(reg != 0x22) | ||
47 | imx233_lcdif_pio_send(true, 2, &value); | ||
48 | } | ||
49 | |||
50 | void lcd_init_device(void) | ||
51 | { | ||
52 | /* clock at 24MHZ */ | ||
53 | imx233_clkctrl_enable(CLK_PIX, false); | ||
54 | imx233_clkctrl_set_div(CLK_PIX, 3); | ||
55 | imx233_clkctrl_set_bypass(CLK_PIX, true); /* use XTAL */ | ||
56 | imx233_clkctrl_enable(CLK_PIX, true); | ||
57 | imx233_lcdif_init(); | ||
58 | imx233_lcdif_setup_system_pins(8); | ||
59 | imx233_lcdif_set_timings(2, 2, 2, 2); | ||
60 | imx233_lcdif_set_word_length(8); | ||
61 | |||
62 | lcd_write_reg(0, 1); | ||
63 | lcd_write_reg(3, 0); | ||
64 | |||
65 | lcd_write_reg(3, 0x510); | ||
66 | lcd_write_reg(9, 8); | ||
67 | lcd_write_reg(0xc, 0); | ||
68 | lcd_write_reg(0xd, 0); | ||
69 | lcd_write_reg(0xe, 0); | ||
70 | lcd_write_reg(0x5b, 4); | ||
71 | lcd_write_reg(0xd, 0x10); | ||
72 | lcd_write_reg(9, 0); | ||
73 | lcd_write_reg(3, 0x10); | ||
74 | lcd_write_reg(0xd, 0x14); | ||
75 | lcd_write_reg(0xe, 0x2b12); | ||
76 | lcd_write_reg(1, 0x21f); | ||
77 | lcd_write_reg(2, 0x700); | ||
78 | lcd_write_reg(5, 0x30); | ||
79 | lcd_write_reg(6, 0); | ||
80 | lcd_write_reg(8, 0x202); | ||
81 | lcd_write_reg(0xa, 0x3); // OF uses 0xc0003 with 3 transfers/pixels | ||
82 | lcd_write_reg(0xb, 0); | ||
83 | lcd_write_reg(0xf, 0); | ||
84 | lcd_write_reg(0x10, 0); | ||
85 | lcd_write_reg(0x11, 0); | ||
86 | lcd_write_reg(0x14, 0x9f00); | ||
87 | lcd_write_reg(0x15, 0x9f00); | ||
88 | lcd_write_reg(0x16, 0x7f00); | ||
89 | lcd_write_reg(0x17, 0x9f00); | ||
90 | lcd_write_reg(0x20, 0); | ||
91 | lcd_write_reg(0x21, 0); | ||
92 | lcd_write_reg(0x23, 0); | ||
93 | lcd_write_reg(0x24, 0); | ||
94 | lcd_write_reg(0x25, 0); | ||
95 | lcd_write_reg(0x26, 0); | ||
96 | lcd_write_reg(0x30, 0x707); | ||
97 | lcd_write_reg(0x31, 0x504); | ||
98 | lcd_write_reg(0x32, 7); | ||
99 | lcd_write_reg(0x33, 0x307); | ||
100 | lcd_write_reg(0x34, 7); | ||
101 | lcd_write_reg(0x35, 0x400); | ||
102 | lcd_write_reg(0x36, 0x607); | ||
103 | lcd_write_reg(0x37, 0x703); | ||
104 | lcd_write_reg(0x3a, 0x1a0d); | ||
105 | lcd_write_reg(0x3b, 0x1309); | ||
106 | |||
107 | lcd_write_reg(9, 4); | ||
108 | lcd_write_reg(7, 5); | ||
109 | lcd_write_reg(7, 0x25); | ||
110 | lcd_write_reg(7, 0x27); | ||
111 | lcd_write_reg(0x5b, 0); | ||
112 | lcd_write_reg(7, 0x37); | ||
113 | #ifdef HAVE_LCD_ENABLE | ||
114 | lcd_on = true; | ||
115 | #endif | ||
116 | } | ||
117 | |||
118 | #ifdef HAVE_LCD_ENABLE | ||
119 | bool lcd_active(void) | ||
120 | { | ||
121 | return lcd_on; | ||
122 | } | ||
123 | |||
124 | void lcd_enable(bool enable) | ||
125 | { | ||
126 | if(lcd_on == enable) | ||
127 | return; | ||
128 | |||
129 | lcd_on = enable; | ||
130 | } | ||
131 | #endif | ||
132 | |||
133 | void lcd_update(void) | ||
134 | { | ||
135 | lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT); | ||
136 | } | ||
137 | |||
138 | void lcd_update_rect(int x, int y, int w, int h) | ||
139 | { | ||
140 | #ifdef HAVE_LCD_ENABLE | ||
141 | if(!lcd_on) | ||
142 | return; | ||
143 | #endif | ||
144 | |||
145 | imx233_lcdif_wait_ready(); | ||
146 | lcd_write_reg(0x16, x | (x + w - 1) << 8); | ||
147 | lcd_write_reg(0x17, y | (y + h - 1) << 8); | ||
148 | lcd_write_reg(0x21, y * LCD_WIDTH + x); | ||
149 | lcd_write_reg(0x22, 0); | ||
150 | for(int yy = y; yy < y + h; yy++) | ||
151 | imx233_lcdif_pio_send(true, 2 * w, FBADDR(x, yy)); | ||
152 | } | ||