Faster LCD transfer routines (+35% for the player, +8% for the recorder)

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4577 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jens Arnold 2004-05-06 06:53:07 +00:00
parent 2cae1dae1c
commit e000e242a1

View file

@ -8,6 +8,7 @@
* $Id$ * $Id$
* *
* Copyright (C) 2002 by Alan Korr, speedup by Jörg Hohensohn * Copyright (C) 2002 by Alan Korr, speedup by Jörg Hohensohn
* Further speedup and reorganization by Jens Arnold
* *
* All files in this archive are subject to the GNU General Public License. * All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement. * See the file COPYING in the source tree root for full license agreement.
@ -136,7 +137,6 @@ void lcd_write_data(unsigned char* p_bytes, int count)
{ {
unsigned int byte; unsigned int byte;
unsigned int sda1; /* precalculated SC=low,SD=1 */ unsigned int sda1; /* precalculated SC=low,SD=1 */
unsigned int clk0sda0; /* precalculated SC and SD low */
byte = *p_bytes++ << 24; /* fetch to MSB position */ byte = *p_bytes++ << 24; /* fetch to MSB position */
@ -145,89 +145,108 @@ void lcd_write_data(unsigned char* p_bytes, int count)
/* precalculate the values for later bit toggling, init data write */ /* precalculate the values for later bit toggling, init data write */
asm ( asm (
"mov.b @%2,%0 \n" /* sda1 = PBDRL */ "mov.b @%1,r0 \n" /* r0 = PBDRL */
"or %4,%0 \n" /* sda1 |= LCD_DS | LCD_SD DS and SD high, */ "or %3,r0 \n" /* r0 |= LCD_DS | LCD_SD DS and SD high */
"and %3,%0 \n" /* sda1 &= ~(LCD_CS | LCD_SC) CS and SC low */ "and %2,r0 \n" /* r0 &= ~(LCD_CS | LCD_SC) CS and SC low */
"mov %0,%1 \n" /* sda1 -> clk0sda0 */ "mov.b r0,@%1 \n" /* PBDRL = r0 */
"and %5,%1 \n" /* clk0sda0 &= ~LCD_SD both low */ "mov r0,%0 \n" /* sda1 = r0 */
"mov.b %1,@%2 \n" /* PBDRL = clk0sda0 */
: /* outputs */ : /* outputs */
/* %0 */ "=r"(sda1), /* %0 */ "=r"(sda1)
/* %1 */ "=r"(clk0sda0)
: /* inputs */ : /* inputs */
/* %2 */ "r"(LCDR), /* %1 */ "r"(LCDR),
/* %3 */ "r"(~(LCD_CS | LCD_SC)), /* %2 */ "I"(~(LCD_CS | LCD_SC)),
/* %4 */ "r"(LCD_DS | LCD_SD), /* %3 */ "I"(LCD_DS | LCD_SD)
/* %5 */ "r"(~LCD_SD) : /* trashed */
"r0"
); );
/* unrolled loop to serialize the byte */ /* unrolled loop to serialize the byte */
asm ( asm (
"shll %0 \n" /* shift the MSB into carry */ "shll %0 \n" /* shift the msb into carry */
".align 2 \n"
"bf 1f \n" "mov %1,r0 \n" /* copy precalculated port value */
"mov.b %1,@%4 \n" /* if it was a "1": set SD high, SC low still */ "bt 1f \n" /* data bit = 1? */
"1: \n" "and %5,r0 \n" /* no: r0 &= ~LCD_SD */
"or.b %2,@(r0,gbr) \n" /* rise SC (independent of SD level) */ "1: \n"
"shll %0 \n" /* shift for next round, now for longer hold time */ "shll %0 \n" /* next shift here for alignment */
"mov.b %3,@%4 \n" /* SC and SD low again */ "mov.b r0,@%3 \n" /* set data to port */
"or %2,r0 \n" /* rise SC (independent of SD level) */
"bf 1f \n" "mov.b r0,@%3 \n" /* set to port */
"mov.b %1,@%4 \n"
"1: \n" "mov %1,r0 \n"
"or.b %2,@(r0,gbr) \n" "bt 1f \n"
"shll %0 \n" "and %5,r0 \n"
"mov.b %3,@%4 \n" "1: \n"
"mov.b r0,@%3 \n"
"bf 1f \n" "or %2,r0 \n"
"mov.b %1,@%4 \n" "mov.b r0,@%3 \n"
"1: \n"
"or.b %2,@(r0,gbr) \n" "shll %0 \n"
"shll %0 \n" "mov %1,r0 \n"
"mov.b %3,@%4 \n" "bt 1f \n"
"and %5,r0 \n"
"bf 1f \n" "1: \n"
"mov.b %1,@%4 \n" "shll %0 \n"
"1: \n" "mov.b r0,@%3 \n"
"or.b %2,@(r0,gbr) \n" "or %2,r0 \n"
"shll %0 \n" "mov.b r0,@%3 \n"
"mov.b %3,@%4 \n"
"mov %1,r0 \n"
"bf 1f \n" "bt 1f \n"
"mov.b %1,@%4 \n" "and %5,r0 \n"
"1: \n" "1: \n"
"or.b %2,@(r0,gbr) \n" "mov.b r0,@%3 \n"
"shll %0 \n" "or %2,r0 \n"
"mov.b %3,@%4 \n" "mov.b r0,@%3 \n"
"bf 1f \n" "shll %0 \n"
"mov.b %1,@%4 \n" "mov %1,r0 \n"
"1: \n" "bt 1f \n"
"or.b %2,@(r0,gbr) \n" "and %5,r0 \n"
"shll %0 \n" "1: \n"
"mov.b %3,@%4 \n" "shll %0 \n"
"mov.b r0,@%3 \n"
"bf 1f \n" "or %2,r0 \n"
"mov.b %1,@%4 \n" "mov.b r0,@%3 \n"
"1: \n"
"or.b %2,@(r0,gbr) \n" "mov %1,r0 \n"
"shll %0 \n" "bt 1f \n"
"mov.b %3,@%4 \n" "and %5,r0 \n"
"1: \n"
"bf 1f \n" "mov.b r0,@%3 \n"
"mov.b %1,@%4 \n" /* set SD high, SC low still */ "or %2,r0 \n"
"1: \n" "mov.b r0,@%3 \n"
"or.b %2,@(r0,gbr) \n" /* rise SC (independent of SD level) */
"shll %0 \n"
"or.b %5,@(r0,gbr) \n" /* restore port */ "mov %1,r0 \n"
"bt 1f \n"
"and %5,r0 \n"
"1: \n"
"shll %0 \n"
"mov.b r0,@%3 \n"
"or %2,r0 \n"
"mov.b r0,@%3 \n"
"mov %1,r0 \n"
"bt 1f \n"
"and %5,r0 \n"
"1: \n"
"mov.b r0,@%3 \n"
"or %2,r0 \n"
"mov.b r0,@%3 \n"
"or %4,r0 \n" /* restore port */
"mov.b r0,@%3 \n"
: /* outputs */ : /* outputs */
: /* inputs */ : /* inputs */
/* %0 */ "r"(byte), /* %0 */ "r"(byte),
/* %1 */ "r"(sda1), /* %1 */ "r"(sda1),
/* %2 */ "I"(LCD_SC), /* %2 */ "I"(LCD_SC),
/* %3 */ "r"(clk0sda0), /* %3 */ "r"(LCDR),
/* %4 = r0 */ "z"(LCDR), /* %4 */ "I"(LCD_CS | LCD_DS | LCD_SD | LCD_SC),
/* %5 */ "I"(LCD_CS|LCD_DS|LCD_SD|LCD_SC) /* %5 */ "I"(~(LCD_SD))
: /* trashed */
"r0"
); );
/* This is the place to reenable the interrupts, if we have disabled /* This is the place to reenable the interrupts, if we have disabled
@ -272,12 +291,13 @@ void lcd_write_data(unsigned char* p_bytes, int count)
/* unrolled loop to serialize the byte */ /* unrolled loop to serialize the byte */
asm ( asm (
"shll %0 \n" /* shift the MSB into carry */ "shll %0 \n" /* shift the MSB into carry */
".align 2 \n"
"negc %1, r0 \n" /* carry to SD, SC low */ "negc %1, r0 \n" /* carry to SD, SC low */
"shll %0 \n" /* next shift here for alignment */
"mov.b r0,@%3 \n" /* set data to port */ "mov.b r0,@%3 \n" /* set data to port */
"or %2, r0 \n" /* rise SC (independent of SD level) */ "or %2, r0 \n" /* rise SC (independent of SD level) */
"mov.b r0,@%3 \n" /* set to port */ "mov.b r0,@%3 \n" /* set to port */
"shll %0 \n"
"negc %1, r0 \n" "negc %1, r0 \n"
"mov.b r0,@%3 \n" "mov.b r0,@%3 \n"
"or %2, r0 \n" "or %2, r0 \n"
@ -285,11 +305,11 @@ void lcd_write_data(unsigned char* p_bytes, int count)
"shll %0 \n" "shll %0 \n"
"negc %1, r0 \n" "negc %1, r0 \n"
"shll %0 \n"
"mov.b r0,@%3 \n" "mov.b r0,@%3 \n"
"or %2, r0 \n" "or %2, r0 \n"
"mov.b r0,@%3 \n" "mov.b r0,@%3 \n"
"shll %0 \n"
"negc %1, r0 \n" "negc %1, r0 \n"
"mov.b r0,@%3 \n" "mov.b r0,@%3 \n"
"or %2, r0 \n" "or %2, r0 \n"
@ -297,11 +317,11 @@ void lcd_write_data(unsigned char* p_bytes, int count)
"shll %0 \n" "shll %0 \n"
"negc %1, r0 \n" "negc %1, r0 \n"
"shll %0 \n"
"mov.b r0,@%3 \n" "mov.b r0,@%3 \n"
"or %2, r0 \n" "or %2, r0 \n"
"mov.b r0,@%3 \n" "mov.b r0,@%3 \n"
"shll %0 \n"
"negc %1, r0 \n" "negc %1, r0 \n"
"mov.b r0,@%3 \n" "mov.b r0,@%3 \n"
"or %2, r0 \n" "or %2, r0 \n"
@ -309,11 +329,11 @@ void lcd_write_data(unsigned char* p_bytes, int count)
"shll %0 \n" "shll %0 \n"
"negc %1, r0 \n" "negc %1, r0 \n"
"shll %0 \n"
"mov.b r0,@%3 \n" "mov.b r0,@%3 \n"
"or %2, r0 \n" "or %2, r0 \n"
"mov.b r0,@%3 \n" "mov.b r0,@%3 \n"
"shll %0 \n"
"negc %1, r0 \n" "negc %1, r0 \n"
"mov.b r0,@%3 \n" "mov.b r0,@%3 \n"
"or %2, r0 \n" "or %2, r0 \n"