forked from len0rd/rockbox
m:robe 100
- lcd driver tidied up and optimised - lcd flip and inverse display enabled (based on logikdax driver and work by lowlight) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16944 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
abd09919ca
commit
f51f98e134
2 changed files with 178 additions and 96 deletions
|
|
@ -32,10 +32,10 @@
|
||||||
#define LCD_PIXELFORMAT VERTICAL_PACKING
|
#define LCD_PIXELFORMAT VERTICAL_PACKING
|
||||||
|
|
||||||
/* define this if you can flip your LCD */
|
/* define this if you can flip your LCD */
|
||||||
/*#define HAVE_LCD_FLIP*/
|
#define HAVE_LCD_FLIP
|
||||||
|
|
||||||
/* define this if you can invert the colours on your LCD */
|
/* define this if you can invert the colours on your LCD */
|
||||||
/*#define HAVE_LCD_INVERT*/
|
#define HAVE_LCD_INVERT
|
||||||
|
|
||||||
/*#define IRAM_LCDFRAMEBUFFER IDATA_ATTR */ /* put the lcd frame buffer in IRAM */
|
/*#define IRAM_LCDFRAMEBUFFER IDATA_ATTR */ /* put the lcd frame buffer in IRAM */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,18 +22,109 @@
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
|
||||||
/* send LCD data */
|
/* The m:robe 100 display has a register set that is very similar to the
|
||||||
static void lcd_send_data(unsigned data)
|
Solomon SSD1815 */
|
||||||
{
|
|
||||||
while (LCD1_CONTROL & LCD1_BUSY_MASK); /* wait for LCD */
|
/*** definitions ***/
|
||||||
LCD1_DATA = data;
|
|
||||||
}
|
#define LCD_SET_LOWER_COLUMN_ADDRESS ((char)0x00)
|
||||||
|
#define LCD_SET_HIGHER_COLUMN_ADDRESS ((char)0x10)
|
||||||
|
#define LCD_SET_INTERNAL_REGULATOR_RESISTOR_RATIO ((char)0x20)
|
||||||
|
#define LCD_SET_POWER_CONTROL_REGISTER ((char)0x28)
|
||||||
|
#define LCD_SET_DISPLAY_START_LINE ((char)0x40)
|
||||||
|
#define LCD_SET_CONTRAST_CONTROL_REGISTER ((char)0x81)
|
||||||
|
#define LCD_SET_SEGMENT_REMAP ((char)0xA0)
|
||||||
|
#define LCD_SET_LCD_BIAS ((char)0xA2)
|
||||||
|
#define LCD_SET_ENTIRE_DISPLAY_OFF ((char)0xA4)
|
||||||
|
#define LCD_SET_ENTIRE_DISPLAY_ON ((char)0xA5)
|
||||||
|
#define LCD_SET_NORMAL_DISPLAY ((char)0xA6)
|
||||||
|
#define LCD_SET_REVERSE_DISPLAY ((char)0xA7)
|
||||||
|
#define LCD_SET_MULTIPLEX_RATIO ((char)0xA8)
|
||||||
|
#define LCD_SET_BIAS_TC_OSC ((char)0xA9)
|
||||||
|
#define LCD_SET_1OVER4_BIAS_RATIO ((char)0xAA)
|
||||||
|
#define LCD_SET_INDICATOR_OFF ((char)0xAC)
|
||||||
|
#define LCD_SET_INDICATOR_ON ((char)0xAD)
|
||||||
|
#define LCD_SET_DISPLAY_OFF ((char)0xAE)
|
||||||
|
#define LCD_SET_DISPLAY_ON ((char)0xAF)
|
||||||
|
#define LCD_SET_PAGE_ADDRESS ((char)0xB0)
|
||||||
|
#define LCD_SET_COM_OUTPUT_SCAN_DIRECTION ((char)0xC0)
|
||||||
|
#define LCD_SET_TOTAL_FRAME_PHASES ((char)0xD2)
|
||||||
|
#define LCD_SET_DISPLAY_OFFSET ((char)0xD3)
|
||||||
|
#define LCD_SET_READ_MODIFY_WRITE_MODE ((char)0xE0)
|
||||||
|
#define LCD_SOFTWARE_RESET ((char)0xE2)
|
||||||
|
#define LCD_NOP ((char)0xE3)
|
||||||
|
#define LCD_SET_END_OF_READ_MODIFY_WRITE_MODE ((char)0xEE)
|
||||||
|
|
||||||
|
/* LCD command codes */
|
||||||
|
|
||||||
|
#define LCD_CNTL_RESET 0xe2 /* Software reset */
|
||||||
|
#define LCD_CNTL_POWER 0x2f /* Power control */
|
||||||
|
#define LCD_CNTL_CONTRAST 0x81 /* Contrast */
|
||||||
|
#define LCD_CNTL_OUTSCAN 0xc8 /* Output scan direction */
|
||||||
|
#define LCD_CNTL_SEGREMAP 0xa1 /* Segment remap */
|
||||||
|
#define LCD_CNTL_DISPON 0xaf /* Display on */
|
||||||
|
|
||||||
|
#define LCD_CNTL_PAGE 0xb0 /* Page address */
|
||||||
|
#define LCD_CNTL_HIGHCOL 0x10 /* Upper column address */
|
||||||
|
#define LCD_CNTL_LOWCOL 0x00 /* Lower column address */
|
||||||
|
|
||||||
/* send LCD command */
|
/* send LCD command */
|
||||||
static void lcd_send_command(unsigned cmd)
|
|
||||||
|
void lcd_write_command(int byte)
|
||||||
{
|
{
|
||||||
while (LCD1_CONTROL & LCD1_BUSY_MASK); /* wait for LCD */
|
while (LCD1_CONTROL & LCD1_BUSY_MASK); /* wait for LCD */
|
||||||
LCD1_CMD = cmd;
|
LCD1_CMD = byte;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* send LCD data */
|
||||||
|
|
||||||
|
void lcd_write_data(const fb_data* p_bytes, int count)
|
||||||
|
{
|
||||||
|
while (count--)
|
||||||
|
{
|
||||||
|
while (LCD1_CONTROL & LCD1_BUSY_MASK); /* wait for LCD */
|
||||||
|
LCD1_DATA = *(p_bytes++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int xoffset; /* needed for flip */
|
||||||
|
|
||||||
|
/*** hardware configuration ***/
|
||||||
|
|
||||||
|
int lcd_default_contrast(void)
|
||||||
|
{
|
||||||
|
return DEFAULT_CONTRAST_SETTING;
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcd_set_contrast(int val)
|
||||||
|
{
|
||||||
|
lcd_write_command(LCD_CNTL_CONTRAST);
|
||||||
|
lcd_write_command(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcd_set_invert_display(bool yesno)
|
||||||
|
{
|
||||||
|
if (yesno)
|
||||||
|
lcd_write_command(LCD_SET_REVERSE_DISPLAY);
|
||||||
|
else
|
||||||
|
lcd_write_command(LCD_SET_NORMAL_DISPLAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* turn the display upside down (call lcd_update() afterwards) */
|
||||||
|
void lcd_set_flip(bool yesno)
|
||||||
|
{
|
||||||
|
if (!yesno)
|
||||||
|
{
|
||||||
|
/* normal */
|
||||||
|
lcd_write_command(LCD_SET_COM_OUTPUT_SCAN_DIRECTION | 0xc);
|
||||||
|
xoffset = 240 - LCD_WIDTH; /* 240 colums minus the 160 we have */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* upside-down */
|
||||||
|
lcd_write_command(LCD_SET_COM_OUTPUT_SCAN_DIRECTION);
|
||||||
|
xoffset = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* LCD init */
|
/* LCD init */
|
||||||
|
|
@ -59,59 +150,35 @@ void lcd_init_device(void)
|
||||||
LCD1_CONTROL = 0x694;
|
LCD1_CONTROL = 0x694;
|
||||||
|
|
||||||
/* OF just reads these */
|
/* OF just reads these */
|
||||||
i = LCD1_CONTROL;
|
LCD1_CONTROL;
|
||||||
i = inl(0x70003004);
|
inl(0x70003004);
|
||||||
i = LCD1_CMD;
|
LCD1_CMD;
|
||||||
i = inl(0x7000300c);
|
inl(0x7000300c);
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* this is skipped in the OF */
|
|
||||||
LCD1_CONTROL &= ~0x200;
|
|
||||||
LCD1_CONTROL &= ~0x800;
|
|
||||||
LCD1_CONTROL &= ~0x400;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LCD1_CONTROL |= 0x1;
|
LCD1_CONTROL |= 0x1;
|
||||||
udelay(15000);
|
udelay(15000);
|
||||||
|
|
||||||
lcd_send_command(0xe2);
|
lcd_write_command(LCD_SOFTWARE_RESET); /* 0xE2 */
|
||||||
lcd_send_command(0x2f);
|
lcd_write_command(LCD_SET_POWER_CONTROL_REGISTER + 7); /* 0x2F */
|
||||||
lcd_send_command(0x26);
|
/* power control register: op-amp=1, regulator=1, booster=1 */
|
||||||
lcd_send_command(0xcc);
|
lcd_write_command(LCD_SET_INTERNAL_REGULATOR_RESISTOR_RATIO + 6); /* 0x26 */
|
||||||
lcd_send_command(0xe8);
|
|
||||||
lcd_send_command(0x81);
|
|
||||||
lcd_send_command(0);
|
|
||||||
lcd_send_command(0x40);
|
|
||||||
lcd_send_command(0xa6);
|
|
||||||
lcd_send_command(0x88);
|
|
||||||
lcd_send_command(0xb0);
|
|
||||||
lcd_send_command(0x10);
|
|
||||||
lcd_send_command(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*** hardware configuration ***/
|
lcd_set_flip(false); /* 0xCC */
|
||||||
int lcd_default_contrast(void)
|
|
||||||
{
|
|
||||||
return DEFAULT_CONTRAST_SETTING;
|
|
||||||
}
|
|
||||||
|
|
||||||
void lcd_set_contrast(int val)
|
lcd_write_command(0xe8);
|
||||||
{
|
|
||||||
lcd_send_command(0x81);
|
|
||||||
lcd_send_command(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
void lcd_set_invert_display(bool yesno)
|
lcd_set_contrast(lcd_default_contrast()); /* 0x80, 0x00 */
|
||||||
{
|
|
||||||
/* TODO: Implement lcd_set_invert_display() */
|
|
||||||
(void)yesno;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* turn the display upside down (call lcd_update() afterwards) */
|
lcd_write_command(LCD_SET_DISPLAY_START_LINE + 0); /* 0x40 */
|
||||||
void lcd_set_flip(bool yesno)
|
lcd_write_command(LCD_SET_NORMAL_DISPLAY); /* 0xA6 */
|
||||||
{
|
|
||||||
/* TODO: Implement lcd_set_flip() */
|
lcd_write_command(0x88);
|
||||||
(void)yesno;
|
|
||||||
|
lcd_write_command(LCD_SET_PAGE_ADDRESS); /* 0xB0 */
|
||||||
|
lcd_write_command(LCD_SET_HIGHER_COLUMN_ADDRESS + 0); /* 0x10 */
|
||||||
|
lcd_write_command(LCD_SET_LOWER_COLUMN_ADDRESS + 0); /* 0x00 */
|
||||||
|
|
||||||
|
lcd_write_command(LCD_SET_DISPLAY_ON); /* 0xAF */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** update functions ***/
|
/*** update functions ***/
|
||||||
|
|
@ -121,21 +188,29 @@ void lcd_set_flip(bool yesno)
|
||||||
void lcd_blit_mono(const unsigned char* data, int x, int by, int width,
|
void lcd_blit_mono(const unsigned char* data, int x, int by, int width,
|
||||||
int bheight, int stride)
|
int bheight, int stride)
|
||||||
{
|
{
|
||||||
/* TODO: Implement lcd_blit() */
|
int cmd1, cmd2;
|
||||||
(void)data;
|
|
||||||
(void)x;
|
cmd1 = LCD_CNTL_HIGHCOL | (((x + xoffset) >> 4) & 0xf);
|
||||||
(void)by;
|
cmd2 = LCD_CNTL_LOWCOL | ((x + xoffset) & 0xf);
|
||||||
(void)width;
|
|
||||||
(void)bheight;
|
/* Copy display bitmap to hardware */
|
||||||
(void)stride;
|
while (bheight--)
|
||||||
|
{
|
||||||
|
lcd_write_command(LCD_CNTL_PAGE | (by++ & 0xff));
|
||||||
|
lcd_write_command(cmd1);
|
||||||
|
lcd_write_command(cmd2);
|
||||||
|
|
||||||
|
lcd_write_data(data, width);
|
||||||
|
|
||||||
|
data += stride;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Performance function that works with an external buffer
|
/* Performance function that works with an external buffer
|
||||||
note that by and bheight are in 4-pixel units! */
|
note that by and bheight are in 8-pixel units! */
|
||||||
void lcd_blit_grey_phase(unsigned char *values, unsigned char *phases,
|
void lcd_blit_grey_phase(unsigned char *values, unsigned char *phases,
|
||||||
int x, int by, int width, int bheight, int stride)
|
int x, int by, int width, int bheight, int stride)
|
||||||
{
|
{
|
||||||
/* TODO: Implement lcd_grey_phase_blit() */
|
|
||||||
(void)values;
|
(void)values;
|
||||||
(void)phases;
|
(void)phases;
|
||||||
(void)x;
|
(void)x;
|
||||||
|
|
@ -147,46 +222,53 @@ void lcd_blit_grey_phase(unsigned char *values, unsigned char *phases,
|
||||||
|
|
||||||
/* Update the display.
|
/* Update the display.
|
||||||
This must be called after all other LCD functions that change the display. */
|
This must be called after all other LCD functions that change the display. */
|
||||||
|
void lcd_update(void) ICODE_ATTR;
|
||||||
void lcd_update(void)
|
void lcd_update(void)
|
||||||
{
|
{
|
||||||
lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
|
int y, cmd1, cmd2;
|
||||||
|
|
||||||
|
cmd1 = LCD_CNTL_HIGHCOL | (((xoffset) >> 4) & 0xf);
|
||||||
|
cmd2 = LCD_CNTL_LOWCOL | ((xoffset) & 0xf);
|
||||||
|
|
||||||
|
/* Copy display bitmap to hardware */
|
||||||
|
for (y = 0; y < LCD_FBHEIGHT; y++)
|
||||||
|
{
|
||||||
|
lcd_write_command (LCD_CNTL_PAGE | (y & 0xf));
|
||||||
|
lcd_write_command(cmd1);
|
||||||
|
lcd_write_command(cmd2);
|
||||||
|
|
||||||
|
lcd_write_data (lcd_framebuffer[y], LCD_WIDTH);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update a fraction of the display. */
|
/* Update a fraction of the display. */
|
||||||
void lcd_update_rect(int x0, int y0, int width, int height)
|
void lcd_update_rect(int, int, int, int) ICODE_ATTR;
|
||||||
|
void lcd_update_rect(int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
unsigned char *addr;
|
int ymax, cmd1, cmd2;
|
||||||
unsigned int cmd0, cmd1, cmd2;
|
|
||||||
int r, c, x1, y1, start_row, last_row;
|
|
||||||
|
|
||||||
x1 = (x0 + width) - 1;
|
/* The Y coordinates have to work on even 8 pixel rows */
|
||||||
y1 = (y0 + height) - 1;
|
ymax = (y + height - 1) >> 3;
|
||||||
if ((x1 <= 0) || (y1 <= 0))
|
y >>= 3;
|
||||||
return;
|
|
||||||
|
|
||||||
if(x1 >= LCD_WIDTH)
|
if(x + width > LCD_WIDTH)
|
||||||
x1 = LCD_WIDTH - 1;
|
width = LCD_WIDTH - x;
|
||||||
|
if (width <= 0)
|
||||||
|
return; /* nothing left to do, 0 is harmful to lcd_write_data() */
|
||||||
|
if(ymax >= LCD_FBHEIGHT)
|
||||||
|
ymax = LCD_FBHEIGHT-1;
|
||||||
|
|
||||||
if(y1 >= LCD_HEIGHT)
|
|
||||||
y1 = LCD_HEIGHT - 1;
|
|
||||||
|
|
||||||
start_row = y0/8;
|
cmd1 = LCD_CNTL_HIGHCOL | (((x + xoffset) >> 4) & 0xf);
|
||||||
last_row = y1/8;
|
cmd2 = LCD_CNTL_LOWCOL | ((x + xoffset) & 0xf);
|
||||||
|
|
||||||
cmd1 = (x0 & 0xff) >> 4;
|
/* Copy specified rectange bitmap to hardware */
|
||||||
cmd1 = (cmd1 + 5) | 0x10;
|
for (; y <= ymax; y++)
|
||||||
cmd2 = x0 & 0xf;
|
{
|
||||||
|
lcd_write_command(LCD_CNTL_PAGE | (y & 0xf));
|
||||||
|
lcd_write_command(cmd1);
|
||||||
|
lcd_write_command(cmd2);
|
||||||
|
|
||||||
for (r = start_row; r <= last_row; r++) {
|
lcd_write_data (&lcd_framebuffer[y][x], width);
|
||||||
cmd0 = (r & 0xff) | 0xb0;
|
|
||||||
lcd_send_command(cmd0);
|
|
||||||
lcd_send_command(cmd1);
|
|
||||||
lcd_send_command(cmd2);
|
|
||||||
|
|
||||||
addr = (unsigned char*)&lcd_framebuffer[r][x0];
|
|
||||||
for (c = x0; c <= x1; c++)
|
|
||||||
lcd_send_data(*(addr++));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lcd_send_command(0xaf);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue