rk27xx: Slightly refactor lcd_set_gram_area()
Change-Id: I1040164220dd87b19b58be560eb5b628857bc284
This commit is contained in:
parent
3f4824b94f
commit
ca8154741f
5 changed files with 46 additions and 39 deletions
|
@ -159,15 +159,17 @@ static void lcd_v1_enable (bool on)
|
|||
|
||||
LCDC_CTRL &= ~RGB24B;
|
||||
}
|
||||
static void lcd_v1_set_gram_area(int x, int y, int width, int height)
|
||||
|
||||
static void lcd_v1_set_gram_area(int x_start, int y_start,
|
||||
int x_end, int y_end)
|
||||
{
|
||||
lcdctrl_bypass(1);
|
||||
LCDC_CTRL |= RGB24B;
|
||||
|
||||
lcd_write_reg(0x03, x);
|
||||
lcd_write_reg(0x05, width-1);
|
||||
lcd_write_reg(0x07, y);
|
||||
lcd_write_reg(0x09, height-1);
|
||||
lcd_write_reg(0x03, x_start);
|
||||
lcd_write_reg(0x05, x_end);
|
||||
lcd_write_reg(0x07, y_start);
|
||||
lcd_write_reg(0x09, y_end);
|
||||
|
||||
lcd_cmd(0x22);
|
||||
LCDC_CTRL &= ~RGB24B;
|
||||
|
@ -178,7 +180,7 @@ static void lcd_v1_update_rect(int x, int y, int width, int height)
|
|||
int px = x, py = y;
|
||||
int pxmax = x + width, pymax = y + height;
|
||||
|
||||
lcd_v1_set_gram_area(x, y, pxmax, pymax);
|
||||
lcd_v1_set_gram_area(x, y, pxmax-1, pymax-1);
|
||||
|
||||
for (py=y; py<pymax; py++)
|
||||
for (px=x; px<pxmax; px++)
|
||||
|
@ -291,19 +293,20 @@ static void lcd_v2_enable (bool on)
|
|||
|
||||
}
|
||||
|
||||
static void lcd_v2_set_gram_area(int x, int y, int width, int height)
|
||||
static void lcd_v2_set_gram_area(int x_start, int y_start,
|
||||
int x_end, int y_end)
|
||||
{
|
||||
lcdctrl_bypass(1);
|
||||
LCDC_CTRL |= RGB24B;
|
||||
|
||||
lcd_write_reg(0x36, height-1);
|
||||
lcd_write_reg(0x37, y);
|
||||
lcd_write_reg(0x38, width-1);
|
||||
lcd_write_reg(0x39, x);
|
||||
lcd_write_reg(0x36, y_end);
|
||||
lcd_write_reg(0x37, y_start);
|
||||
lcd_write_reg(0x38, x_end);
|
||||
lcd_write_reg(0x39, x_start);
|
||||
|
||||
/* set GRAM address */
|
||||
lcd_write_reg(0x20, y);
|
||||
lcd_write_reg(0x21, x);
|
||||
lcd_write_reg(0x20, y_start);
|
||||
lcd_write_reg(0x21, x_start);
|
||||
|
||||
lcd_cmd(0x22);
|
||||
LCDC_CTRL &= ~RGB24B;
|
||||
|
@ -314,7 +317,7 @@ static void lcd_v2_update_rect(int x, int y, int width, int height)
|
|||
int px = x, py = y;
|
||||
int pxmax = x + width, pymax = y + height;
|
||||
|
||||
lcd_v2_set_gram_area(x, y, pxmax, pymax);
|
||||
lcd_v2_set_gram_area(x, y, pxmax-1, pymax-1);
|
||||
|
||||
for (py=y; py<pymax; py++)
|
||||
for (px=x; px<pxmax; px++)
|
||||
|
@ -340,12 +343,13 @@ void lcd_enable (bool on)
|
|||
lcd_v2_enable(on);
|
||||
}
|
||||
|
||||
void lcd_set_gram_area(int x, int y, int width, int height)
|
||||
void lcd_set_gram_area(int x_start, int y_start,
|
||||
int x_end, int y_end)
|
||||
{
|
||||
if (lcd_type == LCD_V1)
|
||||
lcd_v1_set_gram_area(x, y, width, height);
|
||||
lcd_v1_set_gram_area(x_start, y_start, x_end, y_end);
|
||||
else
|
||||
lcd_v2_set_gram_area(x, y, width, height);
|
||||
lcd_v2_set_gram_area(x_start, y_start, x_end, y_end);
|
||||
}
|
||||
|
||||
void lcd_update_rect(int x, int y, int width, int height)
|
||||
|
@ -371,9 +375,10 @@ void lcd_enable (bool on)
|
|||
lcd_v1_enable(on);
|
||||
}
|
||||
|
||||
void lcd_set_gram_area(int x, int y, int width, int height)
|
||||
void lcd_set_gram_area(int x_start, int y_start,
|
||||
int x_end, int y_end)
|
||||
{
|
||||
lcd_v1_set_gram_area(x, y, width, height);
|
||||
lcd_v1_set_gram_area(x_start, y_start, x_end, y_end);
|
||||
}
|
||||
|
||||
void lcd_update_rect(int x, int y, int width, int height)
|
||||
|
|
|
@ -246,7 +246,7 @@ void lcd_init_device(void)
|
|||
|
||||
void lcd_update()
|
||||
{
|
||||
lcd_set_gram_area(0, 0, LCD_WIDTH, LCD_HEIGHT);
|
||||
lcd_set_gram_area(0, 0, LCD_WIDTH-1, LCD_HEIGHT-1);
|
||||
lcdctrl_bypass(0);
|
||||
|
||||
commit_discard_dcache_range(FBADDR(0,0), 2*LCD_WIDTH*LCD_HEIGHT);
|
||||
|
|
|
@ -10,6 +10,6 @@ void lcd_write_reg(unsigned int reg, unsigned int val);
|
|||
void lcdctrl_bypass(unsigned int on_off);
|
||||
void lcd_display_init(void);
|
||||
|
||||
void lcd_set_gram_area(int x, int y, int width, int height);
|
||||
void lcd_set_gram_area(int x_start, int y_start, int x_end, int y_end);
|
||||
|
||||
#endif /* _LCDIF_RK27XX_H */
|
||||
|
|
|
@ -151,21 +151,22 @@ void lcd_enable (bool on)
|
|||
LCDC_CTRL &= ~RGB24B;
|
||||
}
|
||||
|
||||
void lcd_set_gram_area(int x, int y, int width, int height)
|
||||
void lcd_set_gram_area(int x_start, int y_start,
|
||||
int x_end, int y_end)
|
||||
{
|
||||
lcdctrl_bypass(1);
|
||||
LCDC_CTRL |= RGB24B;
|
||||
|
||||
lcd_cmd(0x002A);
|
||||
lcd_data((x&0xff00)>>8);
|
||||
lcd_data(x&0x00ff);
|
||||
lcd_data(((width-1)&0xff00)>>8);
|
||||
lcd_data((width-1)&0x00ff);
|
||||
lcd_data((x_start&0xff00)>>8);
|
||||
lcd_data(x_start&0x00ff);
|
||||
lcd_data((x_end&0xff00)>>8);
|
||||
lcd_data(x_end&0x00ff);
|
||||
lcd_cmd(0x002B);
|
||||
lcd_data((y&0xff00)>>8);
|
||||
lcd_data(y&0x00ff);
|
||||
lcd_data(((height-1)&0xff00)>>8);
|
||||
lcd_data((height-1)&0x00ff);
|
||||
lcd_data((y_start&0xff00)>>8);
|
||||
lcd_data(y_start&0x00ff);
|
||||
lcd_data((y_end&0xff00)>>8);
|
||||
lcd_data(y_end&0x00ff);
|
||||
|
||||
lcd_cmd(0x2c);
|
||||
LCDC_CTRL &= ~RGB24B;
|
||||
|
@ -176,7 +177,7 @@ void lcd_update_rect(int x, int y, int width, int height)
|
|||
int px = x, py = y;
|
||||
int pxmax = x + width, pymax = y + height;
|
||||
|
||||
lcd_set_gram_area(x, y, pxmax, pymax);
|
||||
lcd_set_gram_area(x, y, pxmax-1, pymax-1);
|
||||
|
||||
for (py = y; py < pymax; py++)
|
||||
for (px = x; px < pxmax; px++)
|
||||
|
|
|
@ -161,18 +161,19 @@ void lcd_display_init(void)
|
|||
lcd_sleep(false);
|
||||
}
|
||||
|
||||
void lcd_set_gram_area(int x, int y, int width, int height)
|
||||
void lcd_set_gram_area(int x_start, int y_start,
|
||||
int x_end, int y_end)
|
||||
{
|
||||
lcdctrl_bypass(1);
|
||||
LCDC_CTRL |= RGB24B;
|
||||
|
||||
/* addresses setup */
|
||||
lcd_write_reg(WINDOW_H_START, y);
|
||||
lcd_write_reg(WINDOW_H_END, height-1);
|
||||
lcd_write_reg(WINDOW_V_START, x);
|
||||
lcd_write_reg(WINDOW_V_END, width-1);
|
||||
lcd_write_reg(GRAM_H_ADDR, y);
|
||||
lcd_write_reg(GRAM_V_ADDR, x);
|
||||
lcd_write_reg(WINDOW_H_START, y_start);
|
||||
lcd_write_reg(WINDOW_H_END, y_end);
|
||||
lcd_write_reg(WINDOW_V_START, x_start);
|
||||
lcd_write_reg(WINDOW_V_END, x_end);
|
||||
lcd_write_reg(GRAM_H_ADDR, y_start);
|
||||
lcd_write_reg(GRAM_V_ADDR, x_start);
|
||||
|
||||
lcd_cmd(GRAM_WRITE);
|
||||
LCDC_CTRL &= ~RGB24B;
|
||||
|
@ -183,7 +184,7 @@ void lcd_update_rect(int x, int y, int width, int height)
|
|||
int px = x, py = y;
|
||||
int pxmax = x + width, pymax = y + height;
|
||||
|
||||
lcd_set_gram_area(x, y, pxmax, pymax);
|
||||
lcd_set_gram_area(x, y, pxmax-1, pymax-1);
|
||||
|
||||
for (py=y; py<pymax; py++)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue