From 43e2c01065df95bac37e2efd15d61c86b736e1c0 Mon Sep 17 00:00:00 2001 From: Daniel Ankers Date: Wed, 22 Nov 2006 00:49:16 +0000 Subject: Sansa doesn't use a Wolfson codec. Various other changes to allow Sansa to compile correctly with a normal build. Based on FS#6336 by Pavel Gnelitsa git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11570 a1c6a512-1295-4272-9138-f99709370657 --- docs/CREDITS | 1 + firmware/export/config-e200.h | 6 ++- firmware/pcm_playback.c | 14 ++++-- firmware/sound.c | 26 ++++++---- firmware/system.c | 6 ++- firmware/target/arm/crt0-pp.S | 18 ++++++- firmware/target/arm/sandisk/sansa-e200/lcd-e200.c | 58 +++++++++++++++++++++-- firmware/usb.c | 3 ++ 8 files changed, 111 insertions(+), 21 deletions(-) diff --git a/docs/CREDITS b/docs/CREDITS index e1946ab7f0..bd52d6a105 100644 --- a/docs/CREDITS +++ b/docs/CREDITS @@ -248,3 +248,4 @@ Austin Appel Andre Smith Travis Hyyppa Ian Webber +Pavel Gnelitsa diff --git a/firmware/export/config-e200.h b/firmware/export/config-e200.h index 947db4185f..1bbdd6021e 100644 --- a/firmware/export/config-e200.h +++ b/firmware/export/config-e200.h @@ -48,8 +48,8 @@ /* The number of bytes reserved for loadable plugins */ #define PLUGIN_BUFFER_SIZE 0x80000 -/* Define this if you have the WM8975 audio codec */ -#define HAVE_WM8731 +/* Use the built-in DAC on the PP5024 */ +#define HAVE_PP5024_CODEC #define AB_REPEAT_ENABLE 1 @@ -121,4 +121,6 @@ #define BOOTFILE_EXT "e200" #define BOOTFILE "rockbox." BOOTFILE_EXT +#define ICODE_ATTR_TREMOR_NOT_MDCT + #endif diff --git a/firmware/pcm_playback.c b/firmware/pcm_playback.c index b35b22f730..a2d09e7c8d 100644 --- a/firmware/pcm_playback.c +++ b/firmware/pcm_playback.c @@ -61,7 +61,7 @@ void pcm_play_pause_unpause(void); #ifndef CPU_COLDFIRE -#if (CONFIG_CPU == S3C2440) +#if (CONFIG_CPU == S3C2440) /* TODO: Implement for Gigabeat For now, just implement some dummy functions. @@ -99,7 +99,8 @@ size_t pcm_get_bytes_waiting(void) } #elif defined(HAVE_WM8975) || defined(HAVE_WM8758) \ - || defined(HAVE_WM8731) || defined(HAVE_WM8721) + || defined(HAVE_WM8731) || defined(HAVE_WM8721) \ + || defined(HAVE_PP5024_CODEC) /* We need to unify this code with the uda1380 code as much as possible, but we will keep it separate during early development. @@ -393,6 +394,11 @@ void fiq(void) } #endif /* CONFIG_CPU == PP5020 || CONFIG_CPU == PP5002 */ +#ifdef HAVE_PP5024_CODEC +void pcm_init(void) +{ +} +#else void pcm_init(void) { pcm_playing = false; @@ -411,7 +417,7 @@ void pcm_init(void) /* Call pcm_play_dma_stop to initialize everything. */ pcm_play_dma_stop(); } - +#endif /* HAVE_PP5024_CODEC */ #elif (CONFIG_CPU == PNX0101) #define DMA_BUF_SAMPLES 0x100 @@ -633,7 +639,7 @@ void pcm_calculate_peaks(int *left, int *right) { #if defined(HAVE_WM8975) || defined(HAVE_WM8758) \ || defined(HAVE_WM8731) || defined(HAVE_WM8721) \ - || (CONFIG_CPU == PNX0101) + || (CONFIG_CPU == PNX0101) || defined(HAVE_PP5024_CODEC) size_t samples = p_size / 4; addr = p; #endif diff --git a/firmware/sound.c b/firmware/sound.c index 7e29fddec5..6bd9b70029 100644 --- a/firmware/sound.c +++ b/firmware/sound.c @@ -89,6 +89,9 @@ static const struct sound_settings_info sound_settings_table[] = { [SOUND_TREBLE] = {"dB", 0, 1, -6, 9, 0, sound_set_treble}, #elif (CONFIG_CPU == PNX0101) [SOUND_VOLUME] = {"dB", 0, 1, -48, 15, 0, sound_set_volume}, +#elif defined(HAVE_PP5024_CODEC) +/* TODO: Make this correct */ + [SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25, sound_set_volume}, #else /* MAS3507D */ [SOUND_VOLUME] = {"dB", 0, 1, -78, 18, -18, sound_set_volume}, [SOUND_BASS] = {"dB", 0, 1, -15, 15, 7, sound_set_bass}, @@ -420,11 +423,17 @@ static int tenthdb2mixer(int db) return -db * 2 / 5; } +#elif defined(HAVE_PP5024_CODEC) +/* TODO: Work out volume/balance/treble/bass interdependency */ +#define VOLUME_MIN 0 +#define VOLUME_MAX 1 + #endif #if (CONFIG_CODEC == MAS3507D) || defined HAVE_UDA1380 \ || defined HAVE_WM8975 || defined HAVE_WM8758 || defined(HAVE_WM8731) \ - || defined(HAVE_WM8721) || defined(HAVE_TLV320) || defined(HAVE_WM8751) + || defined(HAVE_WM8721) || defined(HAVE_TLV320) || defined(HAVE_WM8751) \ + || defined(HAVE_PP5024_CODEC) /* volume/balance/treble/bass interdependency main part */ #define VOLUME_RANGE (VOLUME_MAX - VOLUME_MIN) @@ -599,7 +608,8 @@ void sound_set_volume(int value) mas_codec_writereg(0x10, tmp); #elif (CONFIG_CODEC == MAS3507D) || defined HAVE_UDA1380 \ || defined HAVE_WM8975 || defined HAVE_WM8758 || defined HAVE_WM8731 \ - || defined(HAVE_WM8721) || defined(HAVE_TLV320) || defined(HAVE_WM8751) + || defined(HAVE_WM8721) || defined(HAVE_TLV320) || defined(HAVE_WM8751) \ + || defined(HAVE_PP5024_CODEC) current_volume = value * 10; /* tenth of dB */ set_prescaled_volume(); #elif CONFIG_CPU == PNX0101 @@ -620,8 +630,8 @@ void sound_set_balance(int value) || defined(HAVE_WM8721) || defined(HAVE_TLV320) || defined(HAVE_WM8751) current_balance = value * VOLUME_RANGE / 100; /* tenth of dB */ set_prescaled_volume(); -#elif CONFIG_CPU == PNX0101 - /* TODO: implement for iFP */ +#elif CONFIG_CPU == PNX0101 || defined(HAVE_PP5024_CODEC) + /* TODO: implement for iFP and Sansa */ (void)value; #endif } @@ -647,8 +657,8 @@ void sound_set_bass(int value) current_bass = value * 10; wmcodec_set_bass(value); set_prescaled_volume(); -#elif CONFIG_CPU == PNX0101 - /* TODO: implement for iFP */ +#elif CONFIG_CPU == PNX0101 || defined(HAVE_PP5024_CODEC) + /* TODO: implement for iFP and Sansa */ (void)value; #endif } @@ -673,8 +683,8 @@ void sound_set_treble(int value) wmcodec_set_treble(value); current_treble = value * 10; set_prescaled_volume(); -#elif CONFIG_CPU == PNX0101 - /* TODO: implement for iFP */ +#elif CONFIG_CPU == PNX0101 || defined(HAVE_PP5024_CODEC) + /* TODO: implement for iFP and Sansa */ (void)value; #endif } diff --git a/firmware/system.c b/firmware/system.c index 102ace6273..a5fae26bc5 100644 --- a/firmware/system.c +++ b/firmware/system.c @@ -585,7 +585,7 @@ void UIE(unsigned int pc, unsigned int num) } } -#if CONFIG_CPU==PP5020 +#if CONFIG_CPU==PP5020 || CONFIG_CPU==PP5024 unsigned int ipod_hw_rev; @@ -605,9 +605,11 @@ void irq(void) else if (CPU_HI_INT_STAT & GPIO_MASK) ipod_mini_button_int(); } -#elif (defined IRIVER_H10) || (defined IRIVER_H10_5GB) || defined(ELIO_TPJ1022) +#elif (defined IRIVER_H10) || (defined IRIVER_H10_5GB) || defined(ELIO_TPJ1022) \ + || (defined SANSA_E200) /* TODO: this should really be in the target tree, but moving it there caused crt0.S not to find it while linking */ +/* TODO: Even if it isn't in the target tree, this should be the default case */ void irq(void) { if (CPU_INT_STAT & TIMER1_MASK) diff --git a/firmware/target/arm/crt0-pp.S b/firmware/target/arm/crt0-pp.S index d847d9d943..17b1e8a4a3 100644 --- a/firmware/target/arm/crt0-pp.S +++ b/firmware/target/arm/crt0-pp.S @@ -47,14 +47,28 @@ start: .equ SLEEP, 0x80000000 .equ WAKE, 0x0 .equ SLEEPING, 0x80000000 + .equ CACHE_CTRL, 0x6000c000 #endif msr cpsr_c, #0xd3 /* enter supervisor mode, disable IRQ */ #ifndef BOOTLOADER b pad_skip -.space 50*4 /* (more than enough) space for exception vectors */ + +#if defined(SANSA_E200) +/* mi4tool writes junk between 0xe0 and 0xeb. Avoid this. */ +.space 60*4 /* (more than enough) space for exception vectors */ +#else +.space 50*4 +#endif + pad_skip: +#ifdef SANSA_E200 + /* On the Sansa, copying the vectors fails if the cache is initialised */ + ldr r1, =CACHE_CTRL + mov r2, #0x0 + str r2, [r1] +#endif /* We need to remap memory from wherever SDRAM is mapped natively, to base address 0, so we can put our exception vectors there. We don't want to do this remapping while executing from SDRAM, so we copy the @@ -126,7 +140,7 @@ remap_end: ldr r0, =fiq_handler str r0, [r1, #28] #endif - + #ifndef STUB /* Zero out IBSS */ ldr r2, =_iedata diff --git a/firmware/target/arm/sandisk/sansa-e200/lcd-e200.c b/firmware/target/arm/sandisk/sansa-e200/lcd-e200.c index 2ee191faa5..c2829d11da 100644 --- a/firmware/target/arm/sandisk/sansa-e200/lcd-e200.c +++ b/firmware/target/arm/sandisk/sansa-e200/lcd-e200.c @@ -21,9 +21,7 @@ * ****************************************************************************/ #include "config.h" -#include "cpu.h" #include "lcd.h" -#include "kernel.h" #include "system.h" #define LCD_DATA_IN_GPIO GPIOB_INPUT_VAL @@ -108,6 +106,29 @@ static inline void lcd_write_reg(unsigned int reg, unsigned int data) lcd_send_msg(0x72, data); } +static inline void cache_flush(void) +{ +#ifndef BOOTLOADER + outl(inl(0xf000f044) | 0x2, 0xf000f044); + while ((inl(0x6000c000) & 0x8000) != 0) + { + } +#endif +} + +/* The LCD controller gets passed the address of the framebuffer, but can only + use the physical, not the remapped, address. This is a quick and dirty way + of correcting it */ +static unsigned long phys_fb_address(unsigned long address) +{ + if(address < 0x10000000) + { + return address + 0x10000000; + } else { + return address; + } +} + inline void lcd_init_device(void) { /* All this is magic worked out by MrH */ @@ -158,7 +179,7 @@ inline void lcd_init_device(void) LCD_REG_6 |= (1 << 4); LCD_REG_5 &= ~(1 << 7); - LCD_FB_BASE_REG = (unsigned long)lcd_framebuffer; + LCD_FB_BASE_REG = phys_fb_address((unsigned long)lcd_framebuffer); udelay(100000); @@ -228,6 +249,7 @@ inline void lcd_init_device(void) inline void lcd_update(void) { + cache_flush(); if(!(LCD_REG_6 & 1)) LCD_REG_6 |= 1; } @@ -262,3 +284,33 @@ void lcd_set_flip(bool yesno) /* TODO: Implement lcd_set_flip() */ (void)yesno; } + +/* Blitting functions */ + +void lcd_blit(const fb_data* data, int x, int by, int width, + int bheight, int stride) +{ + /* TODO: Implement lcd_blit() */ + (void)data; + (void)x; + (void)by; + (void)width; + (void)bheight; + (void)stride; +} + +void lcd_yuv_blit(unsigned char * const src[3], + int src_x, int src_y, int stride, + int x, int y, int width, int height) +{ + /* TODO: Implement lcd_blit() */ + (void)src; + (void)src_x; + (void)src_y; + (void)stride; + (void)x; + (void)y; + (void)width; + (void)height; +} + diff --git a/firmware/usb.c b/firmware/usb.c index bde9463a7a..5c800bde03 100644 --- a/firmware/usb.c +++ b/firmware/usb.c @@ -83,6 +83,9 @@ void screen_dump(void); /* Nasty again. Defined in apps/ too */ #elif CONFIG_KEYPAD == IRIVER_H10_PAD #define USBPOWER_BUTTON BUTTON_NONE #define USBPOWER_BTN_IGNORE BUTTON_POWER +#elif CONFIG_KEYPAD == SANSA_E200_PAD +#define USBPOWER_BUTTON BUTTON_SELECT +#define USBPOWER_BTN_IGNORE BUTTON_POWER #endif #endif /* HAVE_USB_POWER */ -- cgit v1.2.3