1bit and 2bit LCD drivers: Low-level bit handling optimisations.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10225 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
ed00b17305
commit
393f31cc43
5 changed files with 76 additions and 32 deletions
|
@ -152,7 +152,10 @@ static void fgblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
|
|
||||||
static void solidblock(unsigned char *address, unsigned mask, unsigned bits)
|
static void solidblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
{
|
{
|
||||||
*address = (*address & ~mask) | (bits & mask);
|
unsigned data = *(char *)address;
|
||||||
|
|
||||||
|
bits ^= data;
|
||||||
|
*address = data ^ (bits & mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits)
|
static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
|
@ -172,7 +175,10 @@ static void fginvblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
|
|
||||||
static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits)
|
static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
{
|
{
|
||||||
*address = (*address & ~mask) | (~bits & mask);
|
unsigned data = *(char *)address;
|
||||||
|
|
||||||
|
bits = ~bits ^ data;
|
||||||
|
*address = data ^ (bits & mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
lcd_blockfunc_type* pgfx_blockfuncs[8] = {
|
lcd_blockfunc_type* pgfx_blockfuncs[8] = {
|
||||||
|
|
|
@ -197,24 +197,29 @@ static void bgblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
ICODE_ATTR;
|
ICODE_ATTR;
|
||||||
static void bgblock(unsigned char *address, unsigned mask, unsigned bits)
|
static void bgblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
{
|
{
|
||||||
mask &= ~bits;
|
unsigned data = *address;
|
||||||
*address = (*address & ~mask) | (bg_pattern & mask);
|
|
||||||
|
*address = data ^ ((data ^ bg_pattern) & mask & ~bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fgblock(unsigned char *address, unsigned mask, unsigned bits)
|
static void fgblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
ICODE_ATTR;
|
ICODE_ATTR;
|
||||||
static void fgblock(unsigned char *address, unsigned mask, unsigned bits)
|
static void fgblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
{
|
{
|
||||||
mask &= bits;
|
unsigned data = *address;
|
||||||
*address = (*address & ~mask) | (fg_pattern & mask);
|
|
||||||
|
*address = data ^ ((data ^ fg_pattern) & mask & bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void solidblock(unsigned char *address, unsigned mask, unsigned bits)
|
static void solidblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
ICODE_ATTR;
|
ICODE_ATTR;
|
||||||
static void solidblock(unsigned char *address, unsigned mask, unsigned bits)
|
static void solidblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
{
|
{
|
||||||
*address = (*address & ~mask) | (bits & mask & fg_pattern)
|
unsigned data = *address;
|
||||||
| (~bits & mask & bg_pattern);
|
unsigned bgp = bg_pattern;
|
||||||
|
|
||||||
|
bits = bgp ^ ((bgp ^ fg_pattern) & bits);
|
||||||
|
*address = data ^ ((data ^ bits) & mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits)
|
static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
|
@ -228,24 +233,29 @@ static void bginvblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
ICODE_ATTR;
|
ICODE_ATTR;
|
||||||
static void bginvblock(unsigned char *address, unsigned mask, unsigned bits)
|
static void bginvblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
{
|
{
|
||||||
mask &= bits;
|
unsigned data = *address;
|
||||||
*address = (*address & ~mask) | (bg_pattern & mask);
|
|
||||||
|
*address = data ^ ((data ^ bg_pattern) & mask & bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fginvblock(unsigned char *address, unsigned mask, unsigned bits)
|
static void fginvblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
ICODE_ATTR;
|
ICODE_ATTR;
|
||||||
static void fginvblock(unsigned char *address, unsigned mask, unsigned bits)
|
static void fginvblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
{
|
{
|
||||||
mask &= ~bits;
|
unsigned data = *address;
|
||||||
*address = (*address & ~mask) | (fg_pattern & mask);
|
|
||||||
|
*address = data ^ ((data ^ fg_pattern) & mask & ~bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits)
|
static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
ICODE_ATTR;
|
ICODE_ATTR;
|
||||||
static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits)
|
static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
{
|
{
|
||||||
*address = (*address & ~mask) | (~bits & mask & fg_pattern)
|
unsigned data = *address;
|
||||||
| (bits & mask & bg_pattern);
|
unsigned fgp = fg_pattern;
|
||||||
|
|
||||||
|
bits = fgp ^ ((fgp ^ bg_pattern) & bits);
|
||||||
|
*address = data ^ ((data ^ bits) & mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
lcd_blockfunc_type* const lcd_blockfuncs[8] = {
|
lcd_blockfunc_type* const lcd_blockfuncs[8] = {
|
||||||
|
@ -255,7 +265,10 @@ lcd_blockfunc_type* const lcd_blockfuncs[8] = {
|
||||||
|
|
||||||
static inline void setblock(unsigned char *address, unsigned mask, unsigned bits)
|
static inline void setblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
{
|
{
|
||||||
*address = (*address & ~mask) | (bits & mask);
|
unsigned data = *address;
|
||||||
|
|
||||||
|
bits ^= data;
|
||||||
|
*address = data ^ (bits & mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** drawing functions ***/
|
/*** drawing functions ***/
|
||||||
|
|
|
@ -716,7 +716,10 @@ static void solidblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
ICODE_ATTR;
|
ICODE_ATTR;
|
||||||
static void solidblock(unsigned char *address, unsigned mask, unsigned bits)
|
static void solidblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
{
|
{
|
||||||
*address = (*address & ~mask) | (bits & mask);
|
unsigned data = *address;
|
||||||
|
|
||||||
|
bits ^= data;
|
||||||
|
*address = data ^ (bits & mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits)
|
static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
|
@ -744,7 +747,10 @@ static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
ICODE_ATTR;
|
ICODE_ATTR;
|
||||||
static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits)
|
static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
{
|
{
|
||||||
*address = (*address & ~mask) | (~bits & mask);
|
unsigned data = *address;
|
||||||
|
|
||||||
|
bits = ~bits ^ data;
|
||||||
|
*address = data ^ (bits & mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
lcd_blockfunc_type* const lcd_remote_blockfuncs[8] = {
|
lcd_blockfunc_type* const lcd_remote_blockfuncs[8] = {
|
||||||
|
|
|
@ -397,24 +397,29 @@ static void bgblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
ICODE_ATTR;
|
ICODE_ATTR;
|
||||||
static void bgblock(unsigned char *address, unsigned mask, unsigned bits)
|
static void bgblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
{
|
{
|
||||||
mask &= ~bits;
|
unsigned data = *address;
|
||||||
*address = (*address & ~mask) | (bg_pattern & mask);
|
|
||||||
|
*address = data ^ ((data ^ bg_pattern) & mask & ~bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fgblock(unsigned char *address, unsigned mask, unsigned bits)
|
static void fgblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
ICODE_ATTR;
|
ICODE_ATTR;
|
||||||
static void fgblock(unsigned char *address, unsigned mask, unsigned bits)
|
static void fgblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
{
|
{
|
||||||
mask &= bits;
|
unsigned data = *address;
|
||||||
*address = (*address & ~mask) | (fg_pattern & mask);
|
|
||||||
|
*address = data ^ ((data ^ fg_pattern) & mask & bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void solidblock(unsigned char *address, unsigned mask, unsigned bits)
|
static void solidblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
ICODE_ATTR;
|
ICODE_ATTR;
|
||||||
static void solidblock(unsigned char *address, unsigned mask, unsigned bits)
|
static void solidblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
{
|
{
|
||||||
*address = (*address & ~mask) | (bits & mask & fg_pattern)
|
unsigned data = *address;
|
||||||
| (~bits & mask & bg_pattern);
|
unsigned bgp = bg_pattern;
|
||||||
|
|
||||||
|
bits = bgp ^ ((bgp ^ fg_pattern) & bits);
|
||||||
|
*address = data ^ ((data ^ bits) & mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits)
|
static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
|
@ -428,24 +433,29 @@ static void bginvblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
ICODE_ATTR;
|
ICODE_ATTR;
|
||||||
static void bginvblock(unsigned char *address, unsigned mask, unsigned bits)
|
static void bginvblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
{
|
{
|
||||||
mask &= bits;
|
unsigned data = *address;
|
||||||
*address = (*address & ~mask) | (bg_pattern & mask);
|
|
||||||
|
*address = data ^ ((data ^ bg_pattern) & mask & bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fginvblock(unsigned char *address, unsigned mask, unsigned bits)
|
static void fginvblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
ICODE_ATTR;
|
ICODE_ATTR;
|
||||||
static void fginvblock(unsigned char *address, unsigned mask, unsigned bits)
|
static void fginvblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
{
|
{
|
||||||
mask &= ~bits;
|
unsigned data = *address;
|
||||||
*address = (*address & ~mask) | (fg_pattern & mask);
|
|
||||||
|
*address = data ^ ((data ^ fg_pattern) & mask & ~bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits)
|
static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
ICODE_ATTR;
|
ICODE_ATTR;
|
||||||
static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits)
|
static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
{
|
{
|
||||||
*address = (*address & ~mask) | (~bits & mask & fg_pattern)
|
unsigned data = *address;
|
||||||
| (bits & mask & bg_pattern);
|
unsigned fgp = fg_pattern;
|
||||||
|
|
||||||
|
bits = fgp ^ ((fgp ^ bg_pattern) & bits);
|
||||||
|
*address = data ^ ((data ^ bits) & mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
lcd_blockfunc_type* const lcd_blockfuncs[8] = {
|
lcd_blockfunc_type* const lcd_blockfuncs[8] = {
|
||||||
|
@ -455,7 +465,10 @@ lcd_blockfunc_type* const lcd_blockfuncs[8] = {
|
||||||
|
|
||||||
static inline void setblock(unsigned char *address, unsigned mask, unsigned bits)
|
static inline void setblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
{
|
{
|
||||||
*address = (*address & ~mask) | (bits & mask);
|
unsigned data = *address;
|
||||||
|
|
||||||
|
bits ^= data;
|
||||||
|
*address = data ^ (bits & mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** drawing functions ***/
|
/*** drawing functions ***/
|
||||||
|
|
|
@ -441,7 +441,10 @@ static void solidblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
ICODE_ATTR;
|
ICODE_ATTR;
|
||||||
static void solidblock(unsigned char *address, unsigned mask, unsigned bits)
|
static void solidblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
{
|
{
|
||||||
*address = (*address & ~mask) | (bits & mask);
|
unsigned data = *(char*)address;
|
||||||
|
|
||||||
|
bits ^= data;
|
||||||
|
*address = data ^ (bits & mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits)
|
static void flipinvblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
|
@ -469,7 +472,10 @@ static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
ICODE_ATTR;
|
ICODE_ATTR;
|
||||||
static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits)
|
static void solidinvblock(unsigned char *address, unsigned mask, unsigned bits)
|
||||||
{
|
{
|
||||||
*address = (*address & ~mask) | (~bits & mask);
|
unsigned data = *(char *)address;
|
||||||
|
|
||||||
|
bits = ~bits ^ data;
|
||||||
|
*address = data ^ (bits & mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
lcd_blockfunc_type* const lcd_blockfuncs[8] = {
|
lcd_blockfunc_type* const lcd_blockfuncs[8] = {
|
||||||
|
|
Loading…
Reference in a new issue