HiFiMAN: Implement lcd powersave mode.
[maemo-rb.git] / firmware / target / arm / rk27xx / lcd-hifiman.c
blob91e55894e55743fbeb4de3f5d234cd975c6c41a0
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2011 Andrew Ryabinin
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.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ****************************************************************************/
23 #include "config.h"
24 #include "kernel.h"
25 #include "lcd.h"
26 #include "system.h"
27 #include "cpu.h"
28 #include "lcdif-rk27xx.h"
30 static bool display_on = false;
32 void lcd_display_init()
34 unsigned int x, y;
36 /* Driving ability setting */
37 lcd_write_reg(0x60, 0x00);
38 lcd_write_reg(0x61, 0x06);
39 lcd_write_reg(0x62, 0x00);
40 lcd_write_reg(0x63, 0xC8);
42 /* Gamma 2.2 Setting */
43 lcd_write_reg(0x40, 0x00);
44 lcd_write_reg(0x41, 0x40);
45 lcd_write_reg(0x42, 0x45);
46 lcd_write_reg(0x43, 0x01);
47 lcd_write_reg(0x44, 0x60);
48 lcd_write_reg(0x45, 0x05);
49 lcd_write_reg(0x46, 0x0C);
50 lcd_write_reg(0x47, 0xD1);
51 lcd_write_reg(0x48, 0x05);
53 lcd_write_reg(0x50, 0x75);
54 lcd_write_reg(0x51, 0x01);
55 lcd_write_reg(0x52, 0x67);
56 lcd_write_reg(0x53, 0x14);
57 lcd_write_reg(0x54, 0xF2);
58 lcd_write_reg(0x55, 0x07);
59 lcd_write_reg(0x56, 0x03);
60 lcd_write_reg(0x57, 0x49);
62 /* Power voltage setting */
63 lcd_write_reg(0x1F, 0x03);
64 lcd_write_reg(0x20, 0x00);
65 lcd_write_reg(0x24, 0x28);
66 lcd_write_reg(0x25, 0x45);
68 lcd_write_reg(0x23, 0x2F);
70 /* Power on setting */
71 lcd_write_reg(0x18, 0x44);
72 lcd_write_reg(0x21, 0x01);
73 lcd_write_reg(0x01, 0x00);
74 lcd_write_reg(0x1C, 0x03);
75 lcd_write_reg(0x19, 0x06);
76 udelay(5);
78 /* Display on setting */
79 lcd_write_reg(0x26, 0x84);
80 udelay(40);
81 lcd_write_reg(0x26, 0xB8);
82 udelay(40);
83 lcd_write_reg(0x26, 0xBC);
84 udelay(40);
86 /* Memmory access setting */
87 lcd_write_reg(0x16, 0x48);
88 /* Setup 16bit mode */
89 lcd_write_reg(0x17, 0x05);
91 /* Set GRAM area */
92 lcd_write_reg(0x02, 0x00);
93 lcd_write_reg(0x03, 0x00);
94 lcd_write_reg(0x04, 0x00);
95 lcd_write_reg(0x05, LCD_HEIGHT - 1);
96 lcd_write_reg(0x06, 0x00);
97 lcd_write_reg(0x07, 0x00);
98 lcd_write_reg(0x08, 0x00);
99 lcd_write_reg(0x09, LCD_WIDTH - 1);
101 /* Start GRAM write */
102 lcd_cmd(0x22);
104 for (x=0; x<LCD_WIDTH; x++)
105 for(y=0; y<LCD_HEIGHT; y++)
106 lcd_data(0x00);
108 display_on = true;
111 void lcd_enable (bool on)
113 if (on)
115 lcd_write_reg(0x18, 0x44);
116 lcd_write_reg(0x21, 0x01);
117 lcd_write_reg(0x01, 0x00);
118 lcd_write_reg(0x1C, 0x03);
119 lcd_write_reg(0x19, 0x06);
120 udelay(5);
121 lcd_write_reg(0x26, 0x84);
122 udelay(40);
123 lcd_write_reg(0x26, 0xB8);
124 udelay(40);
125 lcd_write_reg(0x26, 0xBC);
127 else
129 lcd_write_reg(0x26, 0xB8);
130 udelay(40);
131 lcd_write_reg(0x19, 0x01);
132 udelay(40);
133 lcd_write_reg(0x26, 0xA4);
134 udelay(40);
135 lcd_write_reg(0x26, 0x84);
136 udelay(40);
137 lcd_write_reg(0x1C, 0x00);
138 lcd_write_reg(0x01, 0x02);
139 lcd_write_reg(0x21, 0x00);
141 display_on = on;
145 bool lcd_active()
147 return display_on;
151 void lcd_update_rect(int x, int y, int width, int height)
153 int px = x, py = y;
154 int pxmax = x + width, pymax = y + height;
156 lcd_write_reg(0x03, y);
157 lcd_write_reg(0x05, pymax-1);
158 lcd_write_reg(0x07, x);
159 lcd_write_reg(0x09, pxmax-1);
161 lcd_cmd(0x22);
163 for (px=x; px<pxmax; px++)
164 for (py=y; py<pymax; py++)
165 lcd_data(lcd_framebuffer[py][px]);
168 /* Blit a YUV bitmap directly to the LCD */
169 void lcd_blit_yuv(unsigned char * const src[3],
170 int src_x, int src_y, int stride,
171 int x, int y, int width, int height)
173 (void)src;
174 (void)src_x;
175 (void)src_y;
176 (void)stride;
177 (void)x;
178 (void)y;
179 (void)width;
180 (void)height;