forked from len0rd/rockbox
iPod - Initial skeleton of an audio driver
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8248 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
d22938286e
commit
a472ed5114
4 changed files with 404 additions and 10 deletions
|
|
@ -26,6 +26,8 @@
|
|||
#include "i2c.h"
|
||||
#if defined(HAVE_UDA1380)
|
||||
#include "uda1380.h"
|
||||
#elif defined(HAVE_WM8975)
|
||||
#include "wm8975.h"
|
||||
#elif defined(HAVE_TLV320)
|
||||
#include "tlv320.h"
|
||||
#endif
|
||||
|
|
@ -343,50 +345,139 @@ void pcm_init(void)
|
|||
|
||||
#elif defined(HAVE_WM8975)
|
||||
|
||||
/* TODO: Implement for iPod - we should probably move the UDA1380 and
|
||||
WM8975 specific code into separate files.
|
||||
|
||||
For now, just implement some dummy functions.
|
||||
/* We need to unify this code with the uda1380 code as much as possible, but
|
||||
we will keep it separate during early development.
|
||||
*/
|
||||
|
||||
static bool pcm_playing;
|
||||
static bool pcm_paused;
|
||||
static int pcm_freq = 0x6; /* 44.1 is default */
|
||||
|
||||
static unsigned char *next_start;
|
||||
static long next_size;
|
||||
|
||||
/* Set up the DMA transfer that kicks in when the audio FIFO gets empty */
|
||||
static void dma_start(const void *addr, long size)
|
||||
{
|
||||
pcm_playing = true;
|
||||
|
||||
addr = (void *)((unsigned long)addr & ~3); /* Align data */
|
||||
size &= ~3; /* Size must be multiple of 4 */
|
||||
|
||||
return;
|
||||
|
||||
/* This is the uda1380 code */
|
||||
#if 0
|
||||
/* Reset the audio FIFO */
|
||||
|
||||
/* Set up DMA transfer */
|
||||
SAR0 = ((unsigned long)addr); /* Source address */
|
||||
DAR0 = (unsigned long)&PDOR3; /* Destination address */
|
||||
BCR0 = size; /* Bytes to transfer */
|
||||
|
||||
/* Enable the FIFO and force one write to it */
|
||||
IIS2CONFIG = IIS_DEFPARM(pcm_freq);
|
||||
|
||||
DCR0 = DMA_INT | DMA_EEXT | DMA_CS | DMA_SINC | DMA_START;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Stops the DMA transfer and interrupt */
|
||||
static void dma_stop(void)
|
||||
{
|
||||
pcm_playing = false;
|
||||
|
||||
#if 0
|
||||
/* This is the uda1380 code */
|
||||
DCR0 = 0;
|
||||
DSR0 = 1;
|
||||
/* Reset the FIFO */
|
||||
IIS2CONFIG = IIS_RESET | IIS_DEFPARM(pcm_freq);
|
||||
#endif
|
||||
next_start = NULL;
|
||||
next_size = 0;
|
||||
pcm_paused = false;
|
||||
}
|
||||
|
||||
|
||||
void pcm_init(void)
|
||||
{
|
||||
pcm_playing = false;
|
||||
pcm_paused = false;
|
||||
|
||||
/* Initialize default register values. */
|
||||
wm8975_init();
|
||||
|
||||
/* The uda1380 needs a sleep(HZ) here - do we need one? */
|
||||
|
||||
/* Power on */
|
||||
wm8975_enable_output(true);
|
||||
|
||||
/* Unmute the master channel (DAC should be at zero point now). */
|
||||
wm8975_mute(false);
|
||||
|
||||
/* Call dma_stop to initialize everything. */
|
||||
dma_stop();
|
||||
}
|
||||
|
||||
void pcm_set_frequency(unsigned int frequency)
|
||||
{
|
||||
(void)frequency;
|
||||
pcm_freq=frequency;
|
||||
}
|
||||
|
||||
/* the registered callback function to ask for more mp3 data */
|
||||
static void (*callback_for_more)(unsigned char**, long*) = NULL;
|
||||
|
||||
void pcm_play_data(void (*get_more)(unsigned char** start, long* size))
|
||||
{
|
||||
(void)get_more;
|
||||
unsigned char *start;
|
||||
long size;
|
||||
|
||||
callback_for_more = get_more;
|
||||
|
||||
get_more((unsigned char **)&start, (long *)&size);
|
||||
get_more(&next_start, &next_size);
|
||||
|
||||
dma_start(start, size);
|
||||
}
|
||||
|
||||
void pcm_play_stop(void)
|
||||
{
|
||||
if (pcm_playing) {
|
||||
dma_stop();
|
||||
}
|
||||
}
|
||||
|
||||
void pcm_play_pause(bool play)
|
||||
{
|
||||
(void)play;
|
||||
if(pcm_paused && play && next_size)
|
||||
{
|
||||
logf("unpause");
|
||||
/* We need to enable DMA here */
|
||||
}
|
||||
else if(!pcm_paused && !play)
|
||||
{
|
||||
logf("pause");
|
||||
/* We need to disable DMA here */
|
||||
}
|
||||
pcm_paused = !play;
|
||||
}
|
||||
|
||||
bool pcm_is_paused(void)
|
||||
{
|
||||
return false;
|
||||
return pcm_paused;
|
||||
}
|
||||
|
||||
bool pcm_is_playing(void)
|
||||
{
|
||||
return false;
|
||||
return pcm_playing;
|
||||
}
|
||||
|
||||
void pcm_calculate_peaks(int *left, int *right)
|
||||
{
|
||||
(void)left;
|
||||
(void)right;
|
||||
*left=0;
|
||||
*right=0;
|
||||
}
|
||||
|
||||
long pcm_get_bytes_waiting(void)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue