1
0
Fork 0
forked from len0rd/rockbox

More M:Robe 500 work: PCM stopping and pausing roughly works, added some keymaps for the WPS screen, and peakmeter now works properly.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20511 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Karl Kurbjun 2009-03-24 16:40:31 +00:00
parent a5501d68cc
commit 2670e3f038
11 changed files with 210 additions and 117 deletions

View file

@ -39,8 +39,6 @@
#define BUTTON_UP BUTTON_RC_PLAY
#define BUTTON_DOWN BUTTON_RC_DOWN
//#define BUTTON_LEFT BUTTON_RC_REW
//#define BUTTON_RIGHT BUTTON_RC_FF
#define BUTTON_SELECT BUTTON_RC_HEART
#define BUTTON_MENU BUTTON_RC_MODE
@ -66,8 +64,29 @@ static const struct button_mapping button_context_standard[] = {
LAST_ITEM_IN_LIST
}; /* button_context_standard */
static const struct button_mapping button_context_wps[] = {
{ ACTION_WPS_PLAY, BUTTON_RC_PLAY|BUTTON_REL, BUTTON_RC_PLAY },
{ ACTION_WPS_STOP, BUTTON_RC_DOWN|BUTTON_REL, BUTTON_RC_DOWN },
{ ACTION_WPS_SKIPNEXT, BUTTON_RC_FF|BUTTON_REL, BUTTON_RC_FF },
{ ACTION_WPS_SKIPPREV, BUTTON_RC_REW|BUTTON_REL, BUTTON_RC_REW },
{ ACTION_WPS_SEEKBACK, BUTTON_RC_REW|BUTTON_REPEAT,BUTTON_NONE },
{ ACTION_WPS_SEEKFWD, BUTTON_RC_FF|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_WPS_STOPSEEK, BUTTON_RC_REW|BUTTON_REL, BUTTON_RC_REW|BUTTON_REPEAT },
{ ACTION_WPS_STOPSEEK, BUTTON_RC_FF|BUTTON_REL, BUTTON_RC_FF|BUTTON_REPEAT },
{ ACTION_WPS_VOLDOWN, BUTTON_RC_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_WPS_VOLDOWN, BUTTON_RC_VOL_DOWN, BUTTON_NONE },
{ ACTION_WPS_VOLUP, BUTTON_RC_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
{ ACTION_WPS_VOLUP, BUTTON_RC_VOL_UP, BUTTON_NONE },
{ ACTION_WPS_QUICKSCREEN, BUTTON_RC_MODE|BUTTON_REPEAT, BUTTON_RC_MODE },
{ ACTION_WPS_MENU, BUTTON_RC_MODE|BUTTON_REL, BUTTON_RC_MODE },
{ ACTION_WPS_CONTEXT, BUTTON_RC_HEART|BUTTON_REPEAT, BUTTON_RC_HEART },
{ ACTION_WPS_BROWSE, BUTTON_RC_HEART|BUTTON_REL, BUTTON_RC_HEART },
LAST_ITEM_IN_LIST
}; /* button_context_wps */

View file

@ -29,16 +29,18 @@
#include "debug.h"
#include "sprintf.h"
#include "font.h"
#include "pcm.h"
#include "debug-target.h"
#include "lcd-target.h"
#include "dsp-target.h"
#include "dsp/ipc.h"
#ifndef CREATIVE_ZVx
#include "tsc2100.h"
#endif
#if defined(PCM_TEST)
/* Leaving this in for potential debugging for other targets */
#include "pcm.h"
#include "debug-target.h"
#include "dsp-target.h"
#include "dsp/ipc.h"
#define ARM_BUFFER_SIZE (PCM_SIZE)
static signed short *the_rover = (signed short *)0x1900000;
@ -61,9 +63,11 @@ void pcmtest_get_more(unsigned char** start, size_t* size)
DEBUGF("pcm_sdram at 0x%08lx, sdem_addr 0x%08lx",
(unsigned long)the_rover, (unsigned long)sdem_addr);
}
#endif
bool __dbg_ports(void)
{
#if defined(PCM_TEST)
int fd;
int bytes;
@ -74,6 +78,7 @@ bool __dbg_ports(void)
DEBUGF("read %d rover bytes", bytes);
pcm_play_data(&pcmtest_get_more,(unsigned char*)the_rover, ARM_BUFFER_SIZE);
#endif
return false;
}

View file

@ -24,6 +24,7 @@
#include "arm.h"
#include "registers.h"
#include "ipc.h"
#include "dma.h"
volatile struct ipc_message status;
@ -33,7 +34,19 @@ interrupt void handle_int0(void) {
IFR = 1;
acked = 1;
waiting = 0;
rebuffer();
if(dma0_stopped==0)
{
if(!(DMPREC&0x01))
{
DMPREC |= 1;
audiohw_start();
}
else
{
rebuffer();
}
}
}
void startack(void)

View file

@ -52,38 +52,58 @@ unsigned short sdem_level=0;
unsigned short last_size;
/* This tells us which half of the DSP buffer (data) is free */
unsigned short dma0_unlocked;
unsigned short dma0_unlocked;
int waiting=0;
volatile unsigned short dma0_stopped=1;
short waiting=0;
/* rebuffer sets up the next SDRAM to SARAM transfer and tells the ARM when it
* is done with a buffer.
*/
/* Notes: Right now this can handle buffer sizes that are smaller even multiples
* of DSP_BUFFER_SIZE cleanly. It won't fail with buffers that are larger or
* non-multiples, but it won't sound right. The upper limit on larger buffers
* is the size of a short. If larger buffer sizes are needed the code on the
* ARM side needs to be changed to update a full long.
/* Notes: The upper limit on larger buffers is the size of a short. If larger
* buffer sizes are needed the code on the ARM side needs to be changed to
* update a full long.
*/
void rebuffer(void)
{
unsigned long sdem_addr;
if(dma0_stopped==1) /* Stop */
{
DMPREC&=0xFFFE; /* Stop MCBSP DMA0 */
audiohw_stop();
DMSFC0 = 2 << 12 | 1 << 11;
sdem_level=0;
return;
}
if(dsp_level==DSP_BUFFER_SIZE || sdem_level==sdem_dsp_size)
{
if(dma0_stopped==2) /* Pause */
{
DMPREC&=0xFFFE; /* Stop MCBSP DMA0 */
audiohw_stop();
return;
}
}
/* If the sdem_level is equal to the buffer size the ARM code gave
* (sdem_dsp_size) then reset the size and ask the arm for another buffer
*/
if(sdem_level==sdem_dsp_size)
{
{
sdem_level=0;
/* Get a new buffer (location and size) from ARM */
status.msg = MSG_REFILL;
waiting=1;
waiting=1;
startack();
}
if(!waiting)
{
{
/* Size is in bytes (but forced 32 bit transfers */
if( (dsp_level + (sdem_dsp_size - sdem_level) ) > DSP_BUFFER_SIZE)
{
@ -130,7 +150,7 @@ void rebuffer(void)
interrupt void handle_dma0(void)
{
/* Byte offset to half-buffer locked by DMA0.
0 for top, PCM_SIZE/2(0x4000) for bottom */
0 for top, PCM_SIZE/2 for bottom */
unsigned short dma0_locked;
IFR = 1 << 6;
@ -156,18 +176,18 @@ interrupt void handle_dmac(void) {
dsp_level+=last_size;
sdem_level+=last_size;
if(dsp_level<DSP_BUFFER_SIZE)
{
rebuffer();
}
}
}
void dma_init(void) {
/* Configure SARAM to McBSP DMA */
/* Event XEVT0, 32-bit transfers, 0 frame count */
DMSFC0 = 2 << 12 | 1 << 11;
DMSFC0 = 2 << 12 | 1 << 11;
/* Interrupts generated, Half and full buffer.
* ABU mode, From data space with postincrement, to data space with no
@ -183,8 +203,8 @@ void dma_init(void) {
DMDST0 = (unsigned short)&DXR20;
/* Set the size of the buffer */
DMCTR0 = sizeof(data);
DMCTR0 = sizeof(data);
/* Run, Rudolf, run! (with DMA0 interrupts) */
DMPREC = 2 << 6 | 1;
/* Setup DMA0 interrupts and start the transfer */
DMPREC = 2 << 6;
}

View file

@ -24,6 +24,8 @@
#include "ipc.h"
void dma_init(void);
void dma_init(void);
extern volatile unsigned short dma0_stopped;
#endif

File diff suppressed because one or more lines are too long

View file

@ -27,9 +27,6 @@
#include <math.h>
void main(void) {
// register int i;
// register signed short *p;
TCR = 1 << 4; /* Stop the timer. */
IMR = 0xffff; /* Unmask all interrupts. */
IFR = IFR; /* Clear all pending interrupts. */
@ -39,8 +36,6 @@ void main(void) {
dma_init();
audiohw_postinit();
debugf("DSP inited...");
for (;;) {

View file

@ -35,8 +35,13 @@ void audiohw_init(void)
0-bit data delay */
}
void audiohw_postinit(void)
void audiohw_start(void)
{
/* Trigger first XEVT0 */
SPCR20 |= 1;
}
audiohw_stop(void)
{
/* Reset the transmitter */
SPCR20&=0xFFFE;
}

View file

@ -29,15 +29,31 @@
#include "dsp/ipc.h"
#include "mmu-arm.h"
/* These are global to save some latency when pcm_play_dma_get_peak_buffer is
* called.
*/
static unsigned char *start;
static size_t size;
void pcm_postinit(void)
{
audiohw_postinit();
}
/* Return the current location in the SDRAM to SARAM transfer along with the
* number of bytes read in the current buffer (count). There is latency with
* this method equivalent to ~ the size of the SARAM buffer since there is
* another buffer between your ears and this calculation, but this works for
* key clicks and an approximate peak meter.
*/
const void * pcm_play_dma_get_peak_buffer(int *count)
{
(void) count;
return 0;
int cnt = DSP_(_sdem_level);
unsigned long addr = (unsigned long) start +cnt;
*count = (cnt & 0xFFFFF) >> 1;
return (void *)((addr + 2) & ~3);
}
void pcm_play_dma_init(void)
@ -49,6 +65,7 @@ void pcm_play_dma_init(void)
dsp_reset();
dsp_load(dsp_image);
dsp_wake();
}
void pcm_dma_apply_settings(void)
@ -56,6 +73,9 @@ void pcm_dma_apply_settings(void)
audiohw_set_frequency(pcm_fsel);
}
/* Note that size is actually limited to the size of a short right now due to
* the implementation on the DSP side (and the way that we access it)
*/
void pcm_play_dma_start(const void *addr, size_t size)
{
unsigned long sdem_addr=(unsigned long)addr - CONFIG_SDRAM_START;
@ -63,12 +83,14 @@ void pcm_play_dma_start(const void *addr, size_t size)
DSP_(_sdem_addrl) = sdem_addr & 0xffff;
DSP_(_sdem_addrh) = sdem_addr >> 16;
DSP_(_sdem_dsp_size) = size;
DSP_(_dma0_stopped)=0;
dsp_wake();
}
void pcm_play_dma_stop(void)
{
DSP_(_dma0_stopped)=1;
}
void pcm_play_lock(void)
@ -83,7 +105,15 @@ void pcm_play_unlock(void)
void pcm_play_dma_pause(bool pause)
{
(void) pause;
if (pause)
{
DSP_(_dma0_stopped)=2;
}
else
{
DSP_(_dma0_stopped)=0;
dsp_wake();
}
}
size_t pcm_get_bytes_waiting(void)
@ -93,8 +123,6 @@ size_t pcm_get_bytes_waiting(void)
void DSPHINT(void)
{
static unsigned char *start;
static size_t size;
register pcm_more_callback_type get_more; /* No stack for this */
unsigned int i;
@ -111,9 +139,6 @@ void DSPHINT(void)
buffer[i] = dsp_message.payload.debugf.buffer[i];
}
/* Release shared area to DSP. */
dsp_wake();
DEBUGF("DSP: %s", buffer);
break;
@ -121,27 +146,28 @@ void DSPHINT(void)
/* Buffer empty. Try to get more. */
get_more = pcm_callback_for_more;
size = 0;
if (get_more == NULL || (get_more(&start, &size), size == 0))
{
/* Callback missing or no more DMA to do */
pcm_play_dma_stop();
pcm_play_dma_stopped_callback();
/* Callback missing or no more DMA to do */
pcm_play_dma_stop();
pcm_play_dma_stopped_callback();
}
else
{
unsigned long sdem_addr=(unsigned long)start - CONFIG_SDRAM_START;
/* Flush any pending cache writes */
clean_dcache_range(start, size);
clean_dcache_range(start, size);
/* set the new DMA values */
DSP_(_sdem_addrl) = sdem_addr & 0xffff;
/* set the new DMA values */
DSP_(_sdem_addrl) = sdem_addr & 0xffff;
DSP_(_sdem_addrh) = sdem_addr >> 16;
DSP_(_sdem_dsp_size) = size;
DEBUGF("pcm_sdram at 0x%08lx, sdem_addr 0x%08lx",
DEBUGF("pcm_sdram at 0x%08lx, sdem_addr 0x%08lx",
(unsigned long)start, (unsigned long)sdem_addr);
}
break;
default:
DEBUGF("DSP: unknown msg 0x%04x", dsp_message.msg);

View file

@ -40,11 +40,16 @@ void power_init(void)
unsigned int power_input_status(void)
{
if(IO_GIO_BITSET1&(1<<9))
{
return POWER_INPUT_MAIN_CHARGER;
}
return POWER_INPUT_NONE;
}
/* Returns true if the unit is charging the batteries. */
bool charging_state(void) {
bool charging_state(void)
{
return false;
}
@ -67,5 +72,6 @@ void power_off(void)
_backlight_off();
sleep(HZ);
/* Hard shutdown */
IO_GIO_DIR1&=~(1<<10);
IO_GIO_BITSET1|=1<<10;
}

View file

@ -39,8 +39,8 @@ static unsigned int uart1_recieve_count, uart1_recieve_read, uart1_recieve_write
void uart_init(void)
{
// 8-N-1
IO_UART1_MSR=0x8000;
IO_UART1_BRSR=0x0057;
IO_UART1_MSR = 0x8000;
IO_UART1_BRSR = 0x0057;
IO_UART1_RFCR = 0x8010; /* Trigger later */
/* gio 27 is input, uart1 rx
gio 28 is output, uart1 tx */