forked from len0rd/rockbox
Iriver UDA1380 volume and balance handling is now done in sound.c, similar to archos player; removed pcm_set_volume(). Implemented a dB-linear scale. Sorted & bumped plugin api. Removed audio test from the debug menu.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6741 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
22c15b78c8
commit
4c7da88618
8 changed files with 116 additions and 319 deletions
|
|
@ -59,212 +59,6 @@
|
|||
#endif
|
||||
#include "logfdisp.h"
|
||||
|
||||
#ifdef IRIVER_H100
|
||||
#include "uda1380.h"
|
||||
#include "pcm_playback.h"
|
||||
#include "buffer.h"
|
||||
|
||||
#define CHUNK_SIZE 0x100000 /* Transfer CHUNK_SIZE bytes on
|
||||
each DMA transfer */
|
||||
|
||||
static unsigned char line = 0;
|
||||
static unsigned char *audio_buffer;
|
||||
static int audio_pos;
|
||||
static int audio_size;
|
||||
|
||||
static void puts(const char *fmt, ...)
|
||||
{
|
||||
char buf[80];
|
||||
|
||||
if (line > 15)
|
||||
{
|
||||
lcd_clear_display();
|
||||
line = 0;
|
||||
}
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(buf, sizeof(buf)-1, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
lcd_puts(0, line, buf);
|
||||
lcd_update();
|
||||
|
||||
line++;
|
||||
}
|
||||
|
||||
/* Very basic WAVE-file support.. Just for testing purposes.. */
|
||||
int load_wave(char *filename)
|
||||
{
|
||||
int f, i, num;
|
||||
unsigned char buf[32];
|
||||
unsigned short *p, *end;
|
||||
|
||||
puts("Loading %s..", filename);
|
||||
|
||||
f = open(filename, O_RDONLY);
|
||||
if (f == -1)
|
||||
{
|
||||
puts("File not found");
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(buf,0,32);
|
||||
read(f, buf, 32);
|
||||
if (memcmp(buf, "RIFF", 4) != 0 || memcmp(buf+8, "WAVE", 4) != 0)
|
||||
{
|
||||
puts("Not WAVE");
|
||||
return -1;
|
||||
}
|
||||
if (buf[12+8] != 1 || buf[12+9] != 0 || /* Check PCM format */
|
||||
buf[12+10] != 2 || buf[12+11] != 0) /* Check stereo */
|
||||
{
|
||||
puts("Unsupported format");
|
||||
return -1;
|
||||
}
|
||||
|
||||
audio_size = filesize(f) - 0x30;
|
||||
if (audio_size > 8*1024*1024)
|
||||
audio_size = 8*1024*1024;
|
||||
|
||||
audio_buffer = audiobuf;
|
||||
|
||||
puts("Reading %d bytes..", audio_size);
|
||||
|
||||
lseek(f, 0x30, SEEK_SET); /* Skip wave header */
|
||||
|
||||
read(f, audio_buffer, audio_size);
|
||||
close(f);
|
||||
|
||||
puts("Changing byte order..");
|
||||
end = (unsigned short *)(audio_buffer + audio_size);
|
||||
p = (unsigned short *)audio_buffer;
|
||||
while(p < end)
|
||||
{
|
||||
/* Swap 128k at a time, to allow the other threads to run */
|
||||
num = MIN(0x20000, (int)(end - p));
|
||||
for(i = 0;i < num;i++)
|
||||
{
|
||||
*p = SWAB16(*p);
|
||||
p++;
|
||||
}
|
||||
yield();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Test routined of the UDA1380 codec
|
||||
- Loads a WAVE file and plays it..
|
||||
- Control play/stop, master volume and analog mixer volume
|
||||
|
||||
*/
|
||||
|
||||
int test_tracknum;
|
||||
static void test_trackchange(void)
|
||||
{
|
||||
test_tracknum++;
|
||||
}
|
||||
|
||||
extern int pcmbuf_unplayed_bytes;
|
||||
|
||||
bool uda1380_test(void)
|
||||
{
|
||||
long button;
|
||||
int vol = 0x50;
|
||||
bool done = false;
|
||||
char buf[80];
|
||||
bool play = true;
|
||||
int sz;
|
||||
char *ptr;
|
||||
|
||||
lcd_setmargins(0, 0);
|
||||
lcd_clear_display();
|
||||
lcd_update();
|
||||
|
||||
test_tracknum = 1;
|
||||
|
||||
line = 0;
|
||||
|
||||
if (load_wave("/sample.wav") == -1)
|
||||
goto exit;
|
||||
|
||||
audio_pos = 0;
|
||||
|
||||
puts("Playing..");
|
||||
|
||||
audio_pos = 0;
|
||||
pcm_play_init();
|
||||
pcm_set_frequency(44100);
|
||||
pcm_set_volume(0xff - vol);
|
||||
|
||||
ptr = audio_buffer;
|
||||
for(sz = 0;sz < audio_size;sz += CHUNK_SIZE)
|
||||
{
|
||||
if(!pcm_play_add_chunk(ptr, CHUNK_SIZE, test_trackchange))
|
||||
break;
|
||||
ptr += MIN(CHUNK_SIZE, (audio_size - sz));
|
||||
}
|
||||
|
||||
pcm_play_start();
|
||||
|
||||
while(!done)
|
||||
{
|
||||
snprintf(buf, sizeof(buf), "SAR0: %08lx", SAR0);
|
||||
lcd_puts(0, line, buf);
|
||||
snprintf(buf, sizeof(buf), "DAR0: %08lx", DAR0);
|
||||
lcd_puts(0, line+1, buf);
|
||||
snprintf(buf, sizeof(buf), "BCR0: %08lx", BCR0);
|
||||
lcd_puts(0, line+2, buf);
|
||||
snprintf(buf, sizeof(buf), "DCR0: %08lx", DCR0);
|
||||
lcd_puts(0, line+3, buf);
|
||||
snprintf(buf, sizeof(buf), "DSR0: %02x", DSR0);
|
||||
lcd_puts(0, line+4, buf);
|
||||
snprintf(buf, sizeof(buf), "Track: %d", test_tracknum);
|
||||
lcd_puts(0, line+5, buf);
|
||||
snprintf(buf, sizeof(buf), "Unplayed: %08x", pcmbuf_unplayed_bytes);
|
||||
lcd_puts(0, line+6, buf);
|
||||
lcd_update();
|
||||
|
||||
button = button_get_w_tmo(HZ/2);
|
||||
switch(button)
|
||||
{
|
||||
case BUTTON_ON:
|
||||
play = !play;
|
||||
pcm_play_pause(play);
|
||||
break;
|
||||
|
||||
case BUTTON_UP:
|
||||
if (vol)
|
||||
vol--;
|
||||
|
||||
uda1380_setvol(vol);
|
||||
break;
|
||||
case BUTTON_DOWN:
|
||||
if (vol < 255)
|
||||
vol++;
|
||||
|
||||
uda1380_setvol(vol);
|
||||
break;
|
||||
case BUTTON_OFF:
|
||||
done = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if(!pcm_is_playing())
|
||||
done = true;
|
||||
}
|
||||
|
||||
pcm_play_stop();
|
||||
|
||||
exit:
|
||||
sleep(HZ >> 1); /* Sleep 1/2 second to fade out sound */
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
/* SPECIAL DEBUG STUFF */
|
||||
/*---------------------------------------------------*/
|
||||
|
|
@ -469,7 +263,7 @@ static unsigned flash_read_word(unsigned addr) {
|
|||
Only chips which could be reprogrammed in system will return values.
|
||||
(The mode switch addresses vary between flash manufacturers, hence addr1/2) */
|
||||
/* In IRAM to avoid problems when running directly from Flash */
|
||||
bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device,
|
||||
bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device,
|
||||
unsigned addr1, unsigned addr2)
|
||||
__attribute__ ((section (".icode")));
|
||||
bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device,
|
||||
|
|
@ -2006,9 +1800,6 @@ bool debug_menu(void)
|
|||
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
||||
{ "CPU frequency", dbg_cpufreq },
|
||||
#endif
|
||||
#ifdef IRIVER_H100
|
||||
{ "Audio test", uda1380_test },
|
||||
#endif
|
||||
#if CONFIG_CPU == SH7034
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
#ifdef HAVE_RTC
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue