From d1ed7c37b130500cc3c5b5ed4390192f623abd5d Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Sat, 8 Mar 2008 23:34:43 +0000 Subject: No need to have \n here. panicf() won't output it anyway. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16570 a1c6a512-1295-4272-9138-f99709370657 --- apps/SOURCES | 2 + apps/codecs/Makefile | 1 + apps/codecs/SOURCES | 1 + apps/filetypes.c | 1 + apps/main.c | 4 +- apps/metadata.c | 8 + apps/metadata/metadata_parsers.h | 1 + apps/playback.c | 2 +- apps/player/bmp.c | 199 ++++++++++++ apps/player/bmp.h | 35 +++ apps/plugins/CATEGORIES | 1 + apps/plugins/SOURCES | 11 +- firmware/drivers/ata.c | 63 ++-- firmware/drivers/ata_mmc.c | 2 +- firmware/export/config-player.h | 2 +- firmware/export/id3.h | 1 + firmware/id3.c | 3 + firmware/target/arm/iriver/h10/lcd-h10_5gb.c | 114 +++---- firmware/target/arm/system-pp502x.c | 2 +- firmware/target/coldfire/memcpy-coldfire.S | 440 ++++++++++++++++++++++++++- 20 files changed, 779 insertions(+), 114 deletions(-) create mode 100644 apps/player/bmp.c create mode 100644 apps/player/bmp.h diff --git a/apps/SOURCES b/apps/SOURCES index 0d23f42765..f3cb39fc1f 100644 --- a/apps/SOURCES +++ b/apps/SOURCES @@ -75,6 +75,7 @@ gui/backdrop.c #endif #ifdef HAVE_LCD_CHARCELLS +player/bmp.c player/icons.c player/keyboard.c #endif @@ -129,6 +130,7 @@ metadata/mp4.c metadata/mpc.c metadata/ogg.c metadata/sid.c +metadata/mod.c metadata/spc.c metadata/vorbis.c metadata/wave.c diff --git a/apps/codecs/Makefile b/apps/codecs/Makefile index 5a65341d02..7c066d284d 100644 --- a/apps/codecs/Makefile +++ b/apps/codecs/Makefile @@ -47,6 +47,7 @@ all: $(LINKCODEC) $(ROCKS) ifndef SIMVER $(BUILDDIR)/%.a : % $(CODECDEPS) +$(OBJDIR)/mod.elf : $(OBJDIR)/mod.o $(OBJDIR)/codec_crt0.o $(OBJDIR)/wav.elf : $(OBJDIR)/wav.o $(OBJDIR)/codec_crt0.o $(OBJDIR)/sid.elf : $(OBJDIR)/sid.o $(OBJDIR)/codec_crt0.o $(OBJDIR)/adx.elf : $(OBJDIR)/adx.o $(OBJDIR)/codec_crt0.o diff --git a/apps/codecs/SOURCES b/apps/codecs/SOURCES index a93cb6c0cc..3c0118c1ce 100644 --- a/apps/codecs/SOURCES +++ b/apps/codecs/SOURCES @@ -13,6 +13,7 @@ wma.c aac.c #endif ape.c +mod.c shorten.c aiff.c speex.c diff --git a/apps/filetypes.c b/apps/filetypes.c index 8427bc7450..7cf95553a3 100644 --- a/apps/filetypes.c +++ b/apps/filetypes.c @@ -69,6 +69,7 @@ const struct filetype inbuilt_filetypes[] = { { "m4a", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, { "m4b", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, { "mp4", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, + { "mod", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, { "shn", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, { "aif", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, { "aiff",FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, diff --git a/apps/main.c b/apps/main.c index 15dd1bcef9..b60b089b74 100644 --- a/apps/main.c +++ b/apps/main.c @@ -144,10 +144,10 @@ static int init_dircache(bool preinit) if (preinit) dircache_init(); - + if (!global_settings.dircache) return 0; - + # ifdef HAVE_EEPROM_SETTINGS if (firmware_settings.initialized && firmware_settings.disk_clean && preinit) diff --git a/apps/metadata.c b/apps/metadata.c index 3abbd74c35..303fafc070 100644 --- a/apps/metadata.c +++ b/apps/metadata.c @@ -183,6 +183,14 @@ bool get_metadata(struct mp3entry* id3, int fd, const char* trackname) break; + case AFMT_MOD: + if (!get_mod_metadata(fd, id3)) + { + return false; + } + + break; + case AFMT_SHN: id3->vbr = true; id3->filesize = filesize(fd); diff --git a/apps/metadata/metadata_parsers.h b/apps/metadata/metadata_parsers.h index c3265f8a43..b34d09fe4c 100644 --- a/apps/metadata/metadata_parsers.h +++ b/apps/metadata/metadata_parsers.h @@ -25,6 +25,7 @@ bool get_mp4_metadata(int fd, struct mp3entry* id3); bool get_monkeys_metadata(int fd, struct mp3entry* id3); bool get_musepack_metadata(int fd, struct mp3entry *id3); bool get_sid_metadata(int fd, struct mp3entry* id3); +bool get_mod_metadata(int fd, struct mp3entry* id3); bool get_spc_metadata(int fd, struct mp3entry* id3); bool get_ogg_metadata(int fd, struct mp3entry* id3); bool get_wave_metadata(int fd, struct mp3entry* id3); diff --git a/apps/playback.c b/apps/playback.c index cb9ed3e162..dbaf55fbdd 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -1511,7 +1511,7 @@ int audio_track_count(void) } long audio_filebufused(void) -{ +{ return (long) buf_used(); } diff --git a/apps/player/bmp.c b/apps/player/bmp.c new file mode 100644 index 0000000000..290880c0f7 --- /dev/null +++ b/apps/player/bmp.c @@ -0,0 +1,199 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2002 by Linus Nielsen Feltzing + * + * 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. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +/* +2008-02-24 Jens Arnold: minimalistic version for charcell displays +*/ + +#include +#include +#include +#include "inttypes.h" +#include "debug.h" +#include "lcd.h" +#include "file.h" +#include "config.h" +#include "system.h" +#include "bmp.h" +#include "lcd.h" + +#ifdef __GNUC__ +#define STRUCT_PACKED __attribute__((packed)) +#else +#define STRUCT_PACKED +#pragma pack (push, 2) +#endif + +/* BMP header structure */ +struct bmp_header { + uint16_t type; /* signature - 'BM' */ + uint32_t size; /* file size in bytes */ + uint16_t reserved1; /* 0 */ + uint16_t reserved2; /* 0 */ + uint32_t off_bits; /* offset to bitmap */ + uint32_t struct_size; /* size of this struct (40) */ + int32_t width; /* bmap width in pixels */ + int32_t height; /* bmap height in pixels */ + uint16_t planes; /* num planes - always 1 */ + uint16_t bit_count; /* bits per pixel */ + uint32_t compression; /* compression flag */ + uint32_t size_image; /* image size in bytes */ + int32_t x_pels_per_meter; /* horz resolution */ + int32_t y_pels_per_meter; /* vert resolution */ + uint32_t clr_used; /* 0 -> color table size */ + uint32_t clr_important; /* important color count */ +} STRUCT_PACKED; + +union rgb_union { + struct { /* Little endian */ + unsigned char blue; + unsigned char green; + unsigned char red; + unsigned char reserved; + }; + uint32_t raw; +}; + + +/* little endian functions */ +static inline unsigned readshort(uint16_t *value) +{ + unsigned char* bytes = (unsigned char*) value; + return (unsigned)bytes[0] | ((unsigned)bytes[1] << 8); +} + +static inline uint32_t readlong(uint32_t *value) +{ + unsigned char* bytes = (unsigned char*) value; + return (uint32_t)bytes[0] | ((uint32_t)bytes[1] << 8) | + ((uint32_t)bytes[2] << 16) | ((uint32_t)bytes[3] << 24); +} + +static inline unsigned brightness(union rgb_union color) +{ + return (3 * (unsigned)color.red + 6 * (unsigned)color.green + + (unsigned)color.blue) / 10; +} + +/****************************************************************************** + * read_bmp_file() + * + * Reads a BMP file and puts the data in rockbox format in *data. + * + *****************************************************************************/ +int read_bmp_file(const char* filename, + unsigned char *bitmap, + int maxsize) +{ + struct bmp_header bmph; + int fd, ret; + int width, height, depth; + int row, rowstart, rowstop, rowstep; + unsigned char invert; + unsigned char bmpbuf[4]; /* Buffer for one line */ + uint32_t palette[2]; + + fd = open(filename, O_RDONLY); + + /* Exit if file opening failed */ + if (fd < 0) + { + DEBUGF("read_bmp_file: can't open '%s', rc: %d\n", filename, fd); + return fd * 10 - 1; + } + + /* read fileheader */ + ret = read(fd, &bmph, sizeof(struct bmp_header)); + if (ret < 0) + return ret * 10 - 2; + + if (ret != sizeof(struct bmp_header)) { + DEBUGF("read_bmp_file: can't read BMP header."); + return -3; + } + + width = readlong(&bmph.width); + if (width > 8) + { + DEBUGF("read_bmp_file: Bitmap too wide (%d pixels, max is 8)\n", width); + return -4; + } + + depth = readshort(&bmph.bit_count); + if (depth != 1) + { + DEBUGF("read_bmp_fd: Wrong depth (%d, must be 1)\n", depth); + return -5; + } + + height = readlong(&bmph.height); + if (height < 0) + { /* Top-down BMP file */ + height = -height; + rowstart = 0; + rowstop = height; + rowstep = 1; + } + else + { /* normal BMP */ + rowstart = height - 1; + rowstop = -1; + rowstep = -1; + } + + /* Check if this fits the buffer */ + if (height > maxsize) + { + DEBUGF("read_bmp_fd: Bitmap too high for buffer: %d bytes.\n", height); + return -6; + } + + if (read(fd, palette, 2 * sizeof(uint32_t)) + != 2 * (int)sizeof(uint32_t)) + { + DEBUGF("read_bmp_fd: Can't read color palette\n"); + return -7; + } + invert = (brightness((union rgb_union)palette[1]) + > brightness((union rgb_union)palette[0])) + ? 0xff : 0x00; + + /* Search to the beginning of the image data */ + lseek(fd, (off_t)readlong(&bmph.off_bits), SEEK_SET); + memset(bitmap, 0, height); + + /* loop to read rows and put them to buffer */ + for (row = rowstart; row != rowstop; row += rowstep) + { + /* read one row */ + ret = read(fd, bmpbuf, 4); + if (ret != 4) + { + DEBUGF("read_bmp_fd: error reading image, read returned: %d " + "expected: 4\n", ret); + return -9; + } + bitmap[row] = bmpbuf[0] ^ invert; + } + + DEBUGF("totalsize: %d\n", totalsize); + + close(fd); + return height; /* return the used buffer size. */ +} diff --git a/apps/player/bmp.h b/apps/player/bmp.h new file mode 100644 index 0000000000..ddfa349d9d --- /dev/null +++ b/apps/player/bmp.h @@ -0,0 +1,35 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2002 by Daniel Stenberg + * + * 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. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef _BMP_H_ +#define _BMP_H_ + +/********************************************************************* + * read_bmp_file(), minimalistic version for charcell displays + * + * Reads a 1 bit BMP file and puts the data in a horizontal packed + * 1 bit-per-pixel char array. Width must be <= 8 pixels. + * Returns < 0 for error, or number of bytes used from the bitmap + * buffer, which equals bitmap height. + * + **********************************************/ +int read_bmp_file(const char* filename, + unsigned char *bitmap, + int maxsize); + +#endif diff --git a/apps/plugins/CATEGORIES b/apps/plugins/CATEGORIES index 4b267c162b..c2ad75e0c7 100644 --- a/apps/plugins/CATEGORIES +++ b/apps/plugins/CATEGORIES @@ -80,6 +80,7 @@ stopwatch,apps test_codec,viewers test_disk,apps test_fps,apps +test_grey,apps test_sampr,apps test_scanrate,apps test_viewports,apps diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES index 4f782dc455..7b7edbf5c2 100644 --- a/apps/plugins/SOURCES +++ b/apps/plugins/SOURCES @@ -21,6 +21,7 @@ stats.c stopwatch.c vbrfix.c viewer.c +test_disk.c #ifdef OLYMPUS_MROBE_500 /* remove these once the plugins before it are compileable */ @@ -48,7 +49,10 @@ flipit.c #ifdef HAVE_LCD_BITMAP /* Not for the Player */ brickmania.c maze.c -mazezam.c +mazezam.c +greyscale.c +test_fps.c +test_scanrate.c text_editor.c wavview.c robotfindskitten.c @@ -59,6 +63,10 @@ jpeg.c mandelbrot.c plasma.c +#if LCD_DEPTH < 4 +test_grey.c +#endif + blackjack.c bounce.c bubbles.c @@ -118,6 +126,7 @@ nim.c #if CONFIG_CODEC == SWCODEC /* software codec platforms */ mp3_encoder.c +test_codec.c wav2wv.c #else /* hardware codec platforms */ #ifndef HAVE_MMC /* not for Ondio, has no remote control pin */ diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c index 549a7bf920..db8bdf92a0 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c @@ -89,6 +89,7 @@ static bool initialized = false; static long last_user_activity = -1; long last_disk_activity = -1; +static unsigned long total_sectors; static int multisectors; /* number of supported multisectors */ static unsigned short identify_info[SECTOR_SIZE/2]; @@ -284,6 +285,11 @@ int ata_read_sectors(IF_MV2(int drive,) mutex_lock(&ata_mtx); #endif + if (start + incount > total_sectors) { + ret = -1; + goto error; + } + last_disk_activity = current_tick; spinup_start = current_tick; @@ -293,16 +299,14 @@ int ata_read_sectors(IF_MV2(int drive,) spinup = true; if (poweroff) { if (ata_power_on()) { - mutex_unlock(&ata_mtx); - ata_led(false); - return -1; + ret = -2; + goto error; } } else { if (perform_soft_reset()) { - mutex_unlock(&ata_mtx); - ata_led(false); - return -1; + ret = -2; + goto error; } } } @@ -312,9 +316,8 @@ int ata_read_sectors(IF_MV2(int drive,) SET_REG(ATA_SELECT, ata_device); if (!wait_for_rdy()) { - mutex_unlock(&ata_mtx); - ata_led(false); - return -2; + ret = -3; + goto error; } retry: @@ -371,7 +374,7 @@ int ata_read_sectors(IF_MV2(int drive,) We choose alternative 2. */ perform_soft_reset(); - ret = -4; + ret = -5; goto retry; } @@ -403,7 +406,7 @@ int ata_read_sectors(IF_MV2(int drive,) */ if ( status & (STATUS_BSY | STATUS_ERR | STATUS_DF) ) { perform_soft_reset(); - ret = -5; + ret = -6; goto retry; } @@ -415,13 +418,14 @@ int ata_read_sectors(IF_MV2(int drive,) if(!ret && !wait_for_end_of_transfer()) { perform_soft_reset(); - ret = -3; + ret = -4; goto retry; } break; } - ata_led(false); + error: + ata_led(false); #ifndef MAX_PHYS_SECTOR_SIZE mutex_unlock(&ata_mtx); #endif @@ -489,6 +493,9 @@ int ata_write_sectors(IF_MV2(int drive,) mutex_lock(&ata_mtx); #endif + if (start + count > total_sectors) + panicf("Writing past end of disk"); + last_disk_activity = current_tick; spinup_start = current_tick; @@ -498,16 +505,14 @@ int ata_write_sectors(IF_MV2(int drive,) spinup = true; if (poweroff) { if (ata_power_on()) { - mutex_unlock(&ata_mtx); - ata_led(false); - return -1; + ret = -1; + goto error; } } else { if (perform_soft_reset()) { - mutex_unlock(&ata_mtx); - ata_led(false); - return -1; + ret = -1; + goto error; } } } @@ -515,9 +520,8 @@ int ata_write_sectors(IF_MV2(int drive,) SET_REG(ATA_SELECT, ata_device); if (!wait_for_rdy()) { - mutex_unlock(&ata_mtx); - ata_led(false); - return -2; + ret = -2; + goto error; } #ifdef HAVE_LBA48 @@ -575,8 +579,8 @@ int ata_write_sectors(IF_MV2(int drive,) ret = -4; } + error: ata_led(false); - #ifndef MAX_PHYS_SECTOR_SIZE mutex_unlock(&ata_mtx); #endif @@ -1240,11 +1244,16 @@ int ata_init(void) phys_sector_mult * SECTOR_SIZE); #endif + total_sectors = identify_info[60] | (identify_info[60] << 16); + #ifdef HAVE_LBA48 - if (identify_info[83] & 0x0400 /* 48 bit address support */ - && identify_info[60] == 0xFFFF /* and disk size >= 128 GiB */ - && identify_info[61] == 0x0FFF) /* (needs BigLBA addressing) */ - { + if (identify_info[83] & 0x0400 /* 48 bit address support */ + && total_sectors == 0x0FFFFFFF) /* and disk size >= 128 GiB */ + { /* (needs BigLBA addressing) */ + if (identify_info[102] || identify_info[103]) + panicf("Unsupported disk size, >= 2^32 sectors"); + + total_sectors = identify_info[100] | (identify_info[101] << 16); lba48 = true; /* use BigLBA */ } #endif diff --git a/firmware/drivers/ata_mmc.c b/firmware/drivers/ata_mmc.c index fdd091248f..e0a2b17500 100644 --- a/firmware/drivers/ata_mmc.c +++ b/firmware/drivers/ata_mmc.c @@ -814,7 +814,7 @@ int ata_write_sectors(IF_MV2(int drive,) } if (c_end_addr > card->size) - panicf("Writing past end of card\n"); + panicf("Writing past end of card"); blocksize = card->blocksize; offset = c_addr & (blocksize - 1); diff --git a/firmware/export/config-player.h b/firmware/export/config-player.h index b9e3035951..c69fe8cfcb 100644 --- a/firmware/export/config-player.h +++ b/firmware/export/config-player.h @@ -46,7 +46,7 @@ /* Uncomment this if you want to enable ATA power-off control. * Attention, some players crash when ATA power-off is enabled! */ -//#define HAVE_ATA_POWER_OFF +#define HAVE_ATA_POWER_OFF /* Define this if you control ata power player style (with PB4, new player only) */ diff --git a/firmware/export/id3.h b/firmware/export/id3.h index bb3b6a6fe5..267f1b4afa 100644 --- a/firmware/export/id3.h +++ b/firmware/export/id3.h @@ -49,6 +49,7 @@ enum AFMT_WAVPACK, /* WavPack */ AFMT_ALAC, /* Apple Lossless Audio Codec */ AFMT_AAC, /* Advanced Audio Coding (AAC) in M4A container */ + AFMT_MOD, /* MOD File Format */ AFMT_SHN, /* Shorten */ AFMT_SID, /* SID File Format */ AFMT_ADX, /* ADX File Format */ diff --git a/firmware/id3.c b/firmware/id3.c index f594528910..87b4ce9d31 100644 --- a/firmware/id3.c +++ b/firmware/id3.c @@ -90,6 +90,9 @@ const struct afmt_entry audio_formats[AFMT_NUM_CODECS] = [AFMT_AAC] = AFMT_ENTRY("AAC", "aac", NULL, "mp4\0" ), /* Shorten */ + [AFMT_MOD] = + AFMT_ENTRY("MOD", "mod", NULL, "mod\0" ), + /* Shorten */ [AFMT_SHN] = AFMT_ENTRY("SHN", "shorten", NULL, "shn\0" ), /* SID File Format */ diff --git a/firmware/target/arm/iriver/h10/lcd-h10_5gb.c b/firmware/target/arm/iriver/h10/lcd-h10_5gb.c index 8972fd1e9c..680d2c47a5 100644 --- a/firmware/target/arm/iriver/h10/lcd-h10_5gb.c +++ b/firmware/target/arm/iriver/h10/lcd-h10_5gb.c @@ -108,6 +108,7 @@ void lcd_init_device(void) { CLCD_CLOCK_SRC |= 0xc0000000; /* Set LCD interface clock to PLL */ /* H10 LCD is initialised by the bootloader */ + lcd_write_reg(R_ENTRY_MODE, 0x1030); /* BGR =1, ID1 = 1, ID0 = 1 */ } /*** update functions ***/ @@ -289,88 +290,51 @@ void lcd_yuv_blit(unsigned char * const src[3], /* Update a fraction of the display. */ -void lcd_update_rect(int x0, int y0, int width, int height) +void lcd_update_rect(int x, int y, int width, int height) { - int x1, y1; - int newx,newwidth; - unsigned long *addr; + const fb_data *addr; + int bytes_to_write; + + if (x + width >= LCD_WIDTH) + width = LCD_WIDTH - x; + if (y + height >= LCD_HEIGHT) + height = LCD_HEIGHT - y; + + if ((width <= 0) || (height <= 0)) + return; /* Nothing left to do. 0 would hang the transfer. */ + + /* Ensure x and width are both even, so we can read + * 32-bit aligned data from the framebuffer */ + width = (width + (x & 1) + 1) & ~1; + x &= ~1; + + lcd_write_reg(R_VERT_RAM_ADDR_POS, (LCD_HEIGHT-1) << 8); + lcd_write_reg(R_HORIZ_RAM_ADDR_POS, ((x + width - 1) << 8) | x); + lcd_write_reg(R_RAM_ADDR_SET, (y << 8) | x); - /* Ensure x and width are both even - so we can read 32-bit aligned - data from lcd_framebuffer */ - newx=x0&~1; - newwidth=width&~1; - if (newx+newwidth < x0+width) { newwidth+=2; } - x0=newx; width=newwidth; - - /* calculate the drawing region */ - y1 = (y0 + height) - 1; /* max vert */ - x1 = (x0 + width) - 1; /* max horiz */ - - - /* swap max horiz < start horiz */ - if (y1 < y0) { - int t; - t = y0; - y0 = y1; - y1 = t; - } - - /* swap max vert < start vert */ - if (x1 < x0) { - int t; - t = x0; - x0 = x1; - x1 = t; - } - - /* max horiz << 8 | start horiz */ - lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (x1 << 8) | x0); - - /* max vert << 8 | start vert */ - lcd_write_reg(R_VERT_RAM_ADDR_POS, (y1 << 8) | y0); - - /* start vert << 8 | start horiz */ - lcd_write_reg(R_RAM_ADDR_SET, (y0 << 8) | x0); - - /* start drawing */ lcd_send_cmd(R_WRITE_DATA_2_GRAM); - addr = (unsigned long*)&lcd_framebuffer[y0][x0]; - - while (height > 0) { - int c, r; - int h, pixels_to_write; - - pixels_to_write = (width * height) * 2; - h = height; - - /* calculate how much we can do in one go */ - if (pixels_to_write > 0x10000) { - h = (0x10000/2) / width; - pixels_to_write = (width * h) * 2; - } - - LCD2_BLOCK_CTRL = 0x10000080; - LCD2_BLOCK_CONFIG = 0xc0010000 | (pixels_to_write - 1); - LCD2_BLOCK_CTRL = 0x34000000; + addr = &lcd_framebuffer[y][x]; + bytes_to_write = width * height * sizeof(fb_data); + /* must be <= 0x10000, but that's guaranteed on H10. */ - /* for each row */ - for (r = 0; r < h; r++) { - /* for each column */ - for (c = 0; c < width; c += 2) { - while (!(LCD2_BLOCK_CTRL & LCD2_BLOCK_TXOK)); - - /* output 2 pixels */ - LCD2_BLOCK_DATA = *addr++; - } - addr += (LCD_WIDTH - width)/2; + LCD2_BLOCK_CTRL = 0x10000080; + LCD2_BLOCK_CONFIG = 0xc0010000 | (bytes_to_write - 1); + LCD2_BLOCK_CTRL = 0x34000000; + + do + { + int w = width >> 1; + do + { + while (!(LCD2_BLOCK_CTRL & LCD2_BLOCK_TXOK)); + LCD2_BLOCK_DATA = *(unsigned long*)addr; /* output 2 pixels */ + addr += 2; } - - while (!(LCD2_BLOCK_CTRL & LCD2_BLOCK_READY)); - LCD2_BLOCK_CONFIG = 0; - - height -= h; + while (--w > 0); + addr += LCD_WIDTH - width; } + while (--height > 0); } /* Update the display. diff --git a/firmware/target/arm/system-pp502x.c b/firmware/target/arm/system-pp502x.c index 27d11aa815..a5ed7b2999 100644 --- a/firmware/target/arm/system-pp502x.c +++ b/firmware/target/arm/system-pp502x.c @@ -365,7 +365,7 @@ void system_init(void) #elif defined (IPOD_MINI) /* to be done */ #elif defined (IPOD_MINI2G) - /* to be done */ + /* to be done */ #elif defined (MROBE_100) /* to be done */ #elif defined (ELIO_TPJ1022) diff --git a/firmware/target/coldfire/memcpy-coldfire.S b/firmware/target/coldfire/memcpy-coldfire.S index 523e1f5ed9..dd1a8a66da 100644 --- a/firmware/target/coldfire/memcpy-coldfire.S +++ b/firmware/target/coldfire/memcpy-coldfire.S @@ -38,8 +38,8 @@ * %d0 - destination address (like ANSI version) * * register usage: - * %a0 - current source address - * %a1 - current dest address + * %a1 - current source address + * %a0 - current dest address * %a2 - source end address (in line-copy loops) * %d0 - data / scratch * %d1 - source end address (byte and longword copy) / data / scratch @@ -52,11 +52,439 @@ * if FULLSPEED is undefined. */ memcpy: - move.l (4,%sp),%a1 /* Destination */ - move.l (8,%sp),%a0 /* Source */ - move.l (12,%sp),%d1 /* Length */ + move.l (4, %sp), %a1 /* Destination */ + move.l (8, %sp), %a0 /* Source */ + move.l (12, %sp), %d1 /* Length */ __memcpy_fwd_entry: + +#if 1 /* CODE TEST */ + + cmp.l #5, %d1 + bhs.b .min5 + + move.l %a1, %d0 + jmp.l (2, %pc, %d1.l*4) +.bytes_grid: + rts /* 0 */ + nop +.bytes_1: + move.b (%a0)+, (%a1)+ /* 1 */ + rts + move.w (%a0)+, (%a1)+ /* 2 */ + rts + move.w (%a0)+, (%a1)+ /* 3 */ + bra.s .bytes_1 + move.l (%a0)+, (%a1)+ /* 4 */ + rts + +.min5: + move.l %a0, %d0 + and.l #3, %d0 + jmp.l (2, %pc, %d0.l*2) + bra.s .byte1_off0 + bra.s .byte1_off1 + bra.s .byte1_off2 + /* last table entry coincides with target */ + +.byte1_off3: + move.b (%a0)+, (%a1)+ + subq.l #1, %d1 + bra.s .byte1_off0 + +.byte1_off1: + move.b (%a0)+, (%a1)+ + subq.l #1, %d1 +.byte1_off2: + move.w (%a0)+, (%a1)+ + subq.l #2, %d1 +.byte1_off0: + + move.l %d1, %d0 + cmp.l #16, %d0 + bhs.b .min16 + +.longs: + lsr.l #2, %d0 /* in longwords */ + neg.l %d0 + jmp.l (8, %pc, %d0.l*2) + + move.l (%a0)+, (%a1)+ + move.l (%a0)+, (%a1)+ + move.l (%a0)+, (%a1)+ + move.l (4, %sp), %d0 + and.l #3, %d1 + jmp.l (.bytes_grid - 2 - ., %pc, %d1.l*4) + +.min16: +#if 0 + lea.l (-44, %sp), %sp + movem.l %d2-%d7/%a2-%a6, (%sp) + + +.main_do12_start: + lea.l (main_do12_loop - ., %pc), %a5 + movem.l (%a0), %d6-%d7/%a2-%a3 + bra.b .main_do12_headstore + +.main_do8_start: + lea.l (main_do8_loop - ., %pc), %a5 + movem.l (%a0), %d5-%d7/%a2 + bra.b .main_do8_headstore + +.main_do4_start: + lea.l (main_do4_loop - ., %pc), %a5 + movem.l (%a0), %d4-%d7 +/* .main_do4_headstore: */ + move.l %d4, (%a1)+ +.main_do8_headstore: + move.l %d5, (%a1)+ +.main_do12_headstore: + move.l %d6, (%a1)+ + bra.b .main_bo0_check + +.main_do12_loop: + move.l %d7, %d3 + move.l %a2, %d4 + move.l %a3, %d5 + movem.l (%a0), %d6-%d7/%a2-%a3 + bra.b .main_bo0_store +.main_do8_loop: + move.l %d7, %d3 + move.l %a2, %d4 + movem.l (%a0), %d5-%d7/%a2 + bra.b .main_bo0_store +.main_do4_loop: + move.l %d7, %d3 + movem.l (%a0), %d4-%d7 + bra.b .main_bo0_store +.main_do0_loop: + movem.l (%a0), %d3-%d6 +.main_bo0_store: + lea.l (16, %a0), %a1 + movem.l %d3-%d6, (%a1) + lea.l (16, %a1), %a1 +.main_do0_start: +.main_bo0_check: + sub.l #16, %d1 + blo.b .main_bo0_tail + jmp (%a5) + +.main_bo0_tail: + + + +.main_do13_start: + lea.l (main_do13_loop - ., %pc), %a5 + movem.l (%a0), %d7/%a2-%a4 + move.l %d7, %d0 + lsr.l #8, %d0 + swap %d0 + move.b %d0, (%a1)+ + swap %d0 + move.w %d0, (%a1)+ + bra.b .main_bo1_check + +.main_do9_start: + lea.l (main_do9_loop - ., %pc), %a5 + movem.l (%a0), %d6-%d7/%a2-%a3 + move.l %d6, %d0 + lsr.l #8, %d0 + swap %d0 + move.b %d0, (%a1)+ + swap %d0 + move.w %d0, (%a1)+ + bra.b .main_do9_headstore + +.main_do5_start: + lea.l (main_do5_loop - ., %pc), %a5 + movem.l (%a0), %d5-%d7/%a2 + move.l %d5, %d0 + lsr.l #8, %d0 + swap %d0 + move.b %d0, (%a1)+ + swap %d0 + move.w %d0, (%a1)+ + bra.b .main_do5_headstore + +.main_do1_start: + lea.l (main_do1_loop - ., %pc), %a5 + movem.l (%a0), %d4-%d7 + move.l %d4, %d0 + lsr.l #8, %d0 + swap %d0 + move.b %d0, (%a1)+ + swap %d0 + move.w %d0, (%a1)+ +/* .main_do1_headstore: */ + lsl.l %d2, %d4 + move.l %d5, %d0 + lsr.l #8, %d0 + or.l %d0, %d4 + move.l %d4, (%a1)+ +.main_do5_headstore: + lsl.l %d2, %d5 + move.l %d6, %d0 + lsr.l #8, %d0 + or.l %d0, %d5 + move.l %d5, (%a1)+ +.main_do9_headstore: + lsl.l %d2, %d6 + move.l %d7, %d0 + lsr.l #8, %d0 + or.l %d0, %d6 + move.l %d6, (%a1)+ + bra.b .main_bo1_check + +.main_do13_loop: + move.l %d7, %d3 + move.l %a2, %d4 + move.l %a3, %d5 + move.l %a4, %d6 + movem.l (%a0), %d7/%a2-%a4 + bra.b .main_bo1_store +.main_do9_loop: + move.l %d7, %d3 + move.l %a2, %d4 + move.l %a3, %d5 + movem.l (%a0), %d6-%d7/%a2-%a3 + bra.b .main_bo1_store +.main_do5_loop: + move.l %d7, %d3 + move.l %a2, %d4 + movem.l (%a0), %d5-%d7/%a2 + bra.b .main_bo1_store +.main_do1_loop: + move.l %d7, %d3 + movem.l (%a0), %d4-%d7 +.main_bo1_store: + lea.l (16, %a0), %a1 + lsl.l %d2, %d3 + move.l %d4, %d0 + lsr.l #8, %d0 + or.l %d0, %d3 + lsl.l %d2, %d4 + move.l %d5, %d0 + lsr.l #8, %d0 + or.l %d0, %d4 + lsl.l %d2, %d5 + move.l %d6, %d0 + lsr.l #8, %d0 + or.l %d0, %d5 + lsl.l %d2, %d6 + move.l %d7, %d0 + lsr.l #8, %d0 + or.l %d0, %d6 + movem.l %d3-%d6,(%a1) + lea.l (16, %a1), %a1 +.main_bo1_check: + sub.l #16, %d1 + blo.b .main_bo1_tail + jmp (%a5) + + +.main_do14_start: + lea.l (main_do14_loop - ., %pc), %a5 + movem.l (%a0), %d7/%a2-%a4 + swap %d7 + move.w %d7, (%a1)+ + bra.b .main_bo2_check + +.main_do10_start: + lea.l (main_do10_loop - ., %pc), %a5 + movem.l (%a0), %d6-%d7/%a2-%a3 + swap %d6 + move.w %d6, (%a1)+ + bra.b .main_do10_headstore + +.main_do6_start: + lea.l (main_do6_loop - ., %pc), %a5 + movem.l (%a0), %d5-%d7/%a2 + swap %d5 + move.w %d5, (%a1)+ + bra.b .main_do6_headstore + +.main_do2_start: + lea.l (main_do2_loop - ., %pc), %a5 + movem.l (%a0), %d4-%d7 + swap %d4 + move.w %d4, (%a1)+ +/* .main_do2_headstore: */ + swap %d5 + move.w %d5, %d4 + move.l %d4, (%a1)+ +.main_do6_headstore: + swap %d6 + move.w %d6, %d5 + move.l %d5, (%a1)+ +.main_do10_headstore: + swap %d7 + move.w %d7, %d6 + move.l %d6, (%a1)+ + bra.b .main_bo2_check + +.main_do14_loop: + move.l %d7, %d3 + move.l %a2, %d4 + move.l %a3, %d5 + move.l %a4, %d6 + movem.l (%a0), %d7/%a2-%a4 + bra.b .main_bo1_store +.main_do10_loop: + move.l %d7, %d3 + move.l %a2, %d4 + move.l %a3, %d5 + movem.l (%a0), %d6-%d7/%a2-%a3 + bra.b .main_bo1_store +.main_do6_loop: + move.l %d7, %d3 + move.l %a2, %d4 + movem.l (%a0), %d5-%d7/%a2 + bra.b .main_bo1_store +.main_do2_loop: + move.l %d7, %d3 + movem.l (%a0), %d4-%d7 +.main_bo2_store: + lea.l (16, %a0), %a1 + swap %d4 + move.w %d4,%d3 + swap %d5 + move.w %d5,%d4 + swap %d6 + move.w %d6,%d5 + swap %d7 + move.w %d7,%d6 + movem.l %d3-%d6,(%a1) + lea.l (16, %a1), %a1 +.main_bo2_check + sub.l #16, %d1 + blo.b .main_bo2_tail + jmp (%a5) + + +.main_do15_start: + lea.l (main_do15_loop - ., %pc), %a5 + movem.l (%a0), %d7/%a2-%a4 + move.l %d7, %d0 + lsr.l %d2, %d0 + move.b %d0, (%a1)+ + bra.b .main_bo3_check + +.main_do11_start: + lea.l (main_do11_loop - ., %pc), %a5 + movem.l (%a0), %d6-%d7/%a2-%a3 + move.l %d6, %d0 + lsr.l %d2, %d0 + move.b %d0, (%a1)+ + bra.b .main_do11_headstore + +.main_do7_start: + lea.l (main_do7_loop - ., %pc), %a5 + movem.l (%a0), %d5-%d7/%a2 + move.l %d5, %d0 + lsr.l %d2, %d0 + move.b %d0, (%a1)+ + bra.b .main_do7_headstore + +.main_do3_start: + lea.l (main_do3_loop - ., %pc), %a5 + movem.l (%a0), %d4-%d7 + move.l %d4, %d0 + lsr.l %d2, %d0 + move.b %d0, (%a1)+ +/* .main_do3_headstore: */ + lsl.l #8, %d4 + move.l %d5, %d0 + lsr.l %d2, %d0 + or.l %d0, %d4 + move.l %d4, (%a1)+ +.main_do7_headstore: + lsl.l #8, %d5 + move.l %d6, %d0 + lsr.l %d2, %d0 + or.l %d0, %d5 + move.l %d5, (%a1)+ +.main_do11_headstore: + lsl.l #8, %d6 + move.l %d7, %d0 + lsr.l %d2, %d0 + or.l %d0, %d6 + move.l %d6, (%a1)+ + bra.b .main_bo3_check + +.main_do15_loop: + move.l %d7, %d3 + move.l %a2, %d4 + move.l %a3, %d5 + move.l %a4, %d6 + movem.l (%a0), %d7/%a2-%a4 + bra.b .main_bo1_store +.main_do11_loop: + move.l %d7, %d3 + move.l %a2, %d4 + move.l %a3, %d5 + movem.l (%a0), %d6-%d7/%a2-%a3 + bra.b .main_bo1_store +.main_do7_loop: + move.l %d7, %d3 + move.l %a2, %d4 + movem.l (%a0), %d5-%d7/%a2 + bra.b .main_bo1_store +.main_do3_loop: + move.l %d7, %d3 + movem.l (%a0), %d4-%d7 +.main_bo3_store: + lea.l (16, %a0), %a1 + lsl.l #8, %d3 + move.l %d4, %d0 + lsr.l %d2, %d0 + or.l %d0, %d3 + lsl.l #8, %d4 + move.l %d5, %d0 + lsr.l %d2, %d0 + or.l %d0, %d4 + lsl.l #8, %d5 + move.l %d6, %d0 + lsr.l %d2, %d0 + or.l %d0, %d5 + lsl.l #8, %d6 + move.l %d7, %d0 + lsr.l %d2, %d0 + or.l %d0, %d6 + movem.l %d3-%d6,(%a1) + lea.l (16, %a1), %a1 +.main_bo3_check: + sub.l #16, %d1 + blo.b .main_bo3_tail + jmp (%a5) + + + + movem.l (%sp), %d2-%d7/%a2-%a6 + lea.l (44, %sp), %sp +#else + lea.l (-16, %sp), %sp + movem.l %d2-%d5, (%sp) + sub.l #16, %d1 + +.main_loop: + movem.l (%a0), %d2-%d5 + lea.l (16, %a0), %a0 + movem.l %d2-%d5, (%a1) + lea.l (16, %a1), %a1 + sub.l #16, %d1 + bhs.b .main_loop + + add.l #16, %d1 + movem.l (%sp), %d2-%d5 + lea.l (16, %sp), %sp +#endif + + move.l %d1, %d0 + bra.s .longs + +#else /* CODE TEST */ + add.l %a0,%d1 /* %d1 = source end */ move.l %a0,%d0 @@ -675,6 +1103,8 @@ __memcpy_fwd_entry: .bytes2_end: move.l (4,%sp),%d0 /* return destination */ rts + +#endif /* CODE TEST */ .end: .size memcpy,.end-memcpy -- cgit v1.2.3