summaryrefslogtreecommitdiff
path: root/firmware/export
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-10-06 22:27:27 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-10-06 22:27:27 +0000
commit6077e5b7c85c0d6f5963e4aadb215faf2c4d10d2 (patch)
treea6bc91ee4168e83617e942eeaea46e5523e82420 /firmware/export
parentf6de0d4083a4fcb6da57f271e1f8ccaf715e571d (diff)
downloadrockbox-6077e5b7c85c0d6f5963e4aadb215faf2c4d10d2.tar.gz
rockbox-6077e5b7c85c0d6f5963e4aadb215faf2c4d10d2.zip
Unify PCM interface just above the hardware driver level for all targets including the sims. Perform lockout of audio callback when changing states. Weird new playback or recording trouble? Check before and after this revision first though things seem quite sound.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15006 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/export')
-rw-r--r--firmware/export/audio.h2
-rw-r--r--firmware/export/pcm.h122
-rw-r--r--firmware/export/pcm_playback.h65
-rw-r--r--firmware/export/pcm_record.h34
-rw-r--r--firmware/export/pp5002.h20
-rw-r--r--firmware/export/pp5020.h90
6 files changed, 229 insertions, 104 deletions
diff --git a/firmware/export/audio.h b/firmware/export/audio.h
index b55c46a573..84275cca2a 100644
--- a/firmware/export/audio.h
+++ b/firmware/export/audio.h
@@ -26,7 +26,7 @@
26 many files. */ 26 many files. */
27#if CONFIG_CODEC == SWCODEC 27#if CONFIG_CODEC == SWCODEC
28#include "pcm_sampr.h" 28#include "pcm_sampr.h"
29#include "pcm_playback.h" 29#include "pcm.h"
30#ifdef HAVE_RECORDING 30#ifdef HAVE_RECORDING
31#include "pcm_record.h" 31#include "pcm_record.h"
32#include "id3.h" 32#include "id3.h"
diff --git a/firmware/export/pcm.h b/firmware/export/pcm.h
new file mode 100644
index 0000000000..a875479a2d
--- /dev/null
+++ b/firmware/export/pcm.h
@@ -0,0 +1,122 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 by Linus Nielsen Feltzing
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#ifndef PCM_PLAYBACK_H
20#define PCM_PLAYBACK_H
21
22#include <sys/types.h>
23
24/** RAW PCM routines used with playback and recording **/
25
26/* Typedef for registered callback */
27typedef void (*pcm_more_callback_type)(unsigned char **start,
28 size_t *size);
29typedef int (*pcm_more_callback_type2)(int status);
30
31/* set the pcm frequency - use values in hw_sampr_list
32 * use -1 for the default frequency
33 */
34void pcm_set_frequency(unsigned int frequency);
35/* apply settings to hardware immediately */
36void pcm_apply_settings(void);
37
38/** RAW PCM playback routines **/
39
40/* Reenterable locks for locking and unlocking the playback interrupt */
41void pcm_play_lock(void);
42void pcm_play_unlock(void);
43
44void pcm_init(void);
45void pcm_postinit(void);
46
47/* This is for playing "raw" PCM data */
48void pcm_play_data(pcm_more_callback_type get_more,
49 unsigned char* start, size_t size);
50
51void pcm_calculate_peaks(int *left, int *right);
52size_t pcm_get_bytes_waiting(void);
53
54void pcm_play_stop(void);
55void pcm_mute(bool mute);
56void pcm_play_pause(bool play);
57bool pcm_is_paused(void);
58bool pcm_is_playing(void);
59
60/** The following are for internal use between pcm.c and target-
61 specific portion **/
62
63extern unsigned long pcm_curr_sampr;
64
65/* the registered callback function to ask for more mp3 data */
66extern volatile pcm_more_callback_type pcm_callback_for_more;
67extern volatile bool pcm_playing;
68extern volatile bool pcm_paused;
69
70void pcm_play_dma_lock(void);
71void pcm_play_dma_unlock(void);
72void pcm_play_dma_init(void);
73void pcm_play_dma_start(const void *addr, size_t size);
74void pcm_play_dma_stop(void);
75void pcm_play_dma_pause(bool pause);
76void pcm_play_dma_stopped_callback(void);
77const void * pcm_play_dma_get_peak_buffer(int *count);
78
79#ifdef HAVE_RECORDING
80
81/** RAW PCM recording routines **/
82
83/* Reenterable locks for locking and unlocking the recording interrupt */
84void pcm_rec_lock(void);
85void pcm_rec_unlock(void);
86
87/* Initialize pcm recording interface */
88void pcm_init_recording(void);
89/* Uninitialze pcm recording interface */
90void pcm_close_recording(void);
91
92/* Start recording "raw" PCM data */
93void pcm_record_data(pcm_more_callback_type2 more_ready,
94 void *start, size_t size);
95
96/* Stop tranferring data into supplied buffer */
97void pcm_stop_recording(void);
98
99/* Continue transferring data in - call during interrupt handler */
100void pcm_record_more(void *start, size_t size);
101
102void pcm_calculate_rec_peaks(int *left, int *right);
103
104/** The following are for internal use between pcm.c and target-
105 specific portion **/
106extern volatile const void *pcm_rec_peak_addr;
107/* the registered callback function for when more data is available */
108extern volatile pcm_more_callback_type2 pcm_callback_more_ready;
109/* DMA transfer in is currently active */
110extern volatile bool pcm_recording;
111
112/* APIs implemented in the target-specific portion */
113void pcm_rec_dma_init(void);
114void pcm_rec_dma_close(void);
115void pcm_rec_dma_start(void *addr, size_t size);
116void pcm_rec_dma_stop(void);
117void pcm_rec_dma_stopped_callback(void);
118const void * pcm_rec_dma_get_peak_buffer(int *count);
119
120#endif /* HAVE_RECORDING */
121
122#endif /* PCM_PLAYBACK_H */
diff --git a/firmware/export/pcm_playback.h b/firmware/export/pcm_playback.h
deleted file mode 100644
index 351b1fa23f..0000000000
--- a/firmware/export/pcm_playback.h
+++ /dev/null
@@ -1,65 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 by Linus Nielsen Feltzing
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#ifndef PCM_PLAYBACK_H
20#define PCM_PLAYBACK_H
21
22#include <sys/types.h>
23
24/* Typedef for registered callback (play and record) */
25typedef void (*pcm_more_callback_type)(unsigned char **start,
26 size_t *size);
27typedef int (*pcm_more_callback_type2)(int status);
28
29void pcm_init(void);
30void pcm_postinit(void);
31
32/* set the pcm frequency - use values in hw_sampr_list
33 * use -1 for the default frequency
34 */
35void pcm_set_frequency(unsigned int frequency);
36/* apply settings to hardware immediately */
37void pcm_apply_settings(void);
38
39/* This is for playing "raw" PCM data */
40void pcm_play_data(pcm_more_callback_type get_more,
41 unsigned char* start, size_t size);
42
43void pcm_calculate_peaks(int *left, int *right);
44size_t pcm_get_bytes_waiting(void);
45
46void pcm_play_stop(void);
47void pcm_mute(bool mute);
48void pcm_play_pause(bool play);
49bool pcm_is_paused(void);
50bool pcm_is_playing(void);
51
52/** The following are for internal use between pcm_playback.c and target-
53 specific portion **/
54
55/* the registered callback function to ask for more mp3 data */
56extern volatile pcm_more_callback_type pcm_callback_for_more;
57extern volatile bool pcm_playing;
58extern volatile bool pcm_paused;
59
60extern void pcm_play_dma_start(const void *addr, size_t size);
61extern void pcm_play_dma_stop(void);
62extern void pcm_play_pause_pause(void);
63extern void pcm_play_pause_unpause(void);
64
65#endif /* PCM_PLAYBACK_H */
diff --git a/firmware/export/pcm_record.h b/firmware/export/pcm_record.h
index 19c10cb228..814eb73b3a 100644
--- a/firmware/export/pcm_record.h
+++ b/firmware/export/pcm_record.h
@@ -44,28 +44,6 @@
44#define PCMREC_E_CHUNK_OVF 0x80010000 44#define PCMREC_E_CHUNK_OVF 0x80010000
45#endif /* DEBUG */ 45#endif /* DEBUG */
46 46
47/**
48 * RAW pcm data recording
49 * These calls are nescessary only when using the raw pcm apis directly.
50 */
51
52/* Initialize pcm recording interface */
53void pcm_init_recording(void);
54/* Uninitialze pcm recording interface */
55void pcm_close_recording(void);
56
57/* Start recording "raw" PCM data */
58void pcm_record_data(pcm_more_callback_type2 more_ready,
59 void *start, size_t size);
60
61/* Stop tranferring data into supplied buffer */
62void pcm_stop_recording(void);
63
64/* Continue transferring data in - call during interrupt handler */
65void pcm_record_more(void *start, size_t size);
66
67void pcm_calculate_rec_peaks(int *left, int *right);
68
69/** General functions for high level codec recording **/ 47/** General functions for high level codec recording **/
70/* pcm_rec_error_clear is deprecated for general use. audio_error_clear 48/* pcm_rec_error_clear is deprecated for general use. audio_error_clear
71 should be used */ 49 should be used */
@@ -83,16 +61,4 @@ int pcm_get_num_unprocessed(void);
83 61
84/* audio.h contains audio_* recording functions */ 62/* audio.h contains audio_* recording functions */
85 63
86
87/** The following are for internal use between pcm_record.c and target-
88 specific portion **/
89/* the registered callback function for when more data is available */
90extern volatile pcm_more_callback_type2 pcm_callback_more_ready;
91/* DMA transfer in is currently active */
92extern volatile bool pcm_recording;
93
94/* APIs implemented in the target-specific portion */
95extern void pcm_rec_dma_start(void *addr, size_t size);
96extern void pcm_rec_dma_stop(void);
97
98#endif /* PCM_RECORD_H */ 64#endif /* PCM_RECORD_H */
diff --git a/firmware/export/pp5002.h b/firmware/export/pp5002.h
index f566b5cd04..730e42b66d 100644
--- a/firmware/export/pp5002.h
+++ b/firmware/export/pp5002.h
@@ -26,12 +26,28 @@
26 26
27#define IPOD_LCD_BASE 0xc0001000 27#define IPOD_LCD_BASE 0xc0001000
28 28
29#define IISCONFIG (*(volatile unsigned long *)(0xc0002500)) 29/* Processor ID */
30#define PROCESSOR_ID (*(volatile unsigned long *)(0xc4000000))
30 31
32#define PROC_ID_CPU 0x55
33#define PROC_ID_COP 0xaa
34
35#define IISCONFIG (*(volatile unsigned long *)(0xc0002500))
31#define IISFIFO_CFG (*(volatile unsigned long *)(0xc000251c)) 36#define IISFIFO_CFG (*(volatile unsigned long *)(0xc000251c))
32#define IISFIFO_WR (*(volatile unsigned long *)(0xc0002540)) 37#define IISFIFO_WR (*(volatile unsigned long *)(0xc0002540))
33#define IISFIFO_RD (*(volatile unsigned long *)(0xc0002580)) 38#define IISFIFO_RD (*(volatile unsigned long *)(0xc0002580))
34 39
40/* IISCONFIG bits: */
41#define IIS_TXFIFOEN (1 << 2)
42#define IIS_TX_FREE_MASK (0xf << 23)
43#define IIS_TX_FREE_COUNT ((IISFIFO_CFG & IIS_TX_FREE_MASK) >> 23)
44
45/* IISFIFO_CFG bits: */
46#define IIS_IRQTX_REG IISFIFO_CFG
47#define IIS_IRQTX (1 << 9)
48
49#define I2C_BASE 0xc0008000
50
35#define IDE_BASE 0xc0003000 51#define IDE_BASE 0xc0003000
36 52
37#define IDE_CFG_STATUS (*(volatile unsigned long *)(0xc0003024)) 53#define IDE_CFG_STATUS (*(volatile unsigned long *)(0xc0003024))
@@ -103,6 +119,8 @@
103#define DMA_OUT_MASK (1 << DMA_OUT_IRQ) 119#define DMA_OUT_MASK (1 << DMA_OUT_IRQ)
104#define DMA_IN_MASK (1 << DMA_IN_IRQ) 120#define DMA_IN_MASK (1 << DMA_IN_IRQ)
105 121
122/* Yes, there is I2S_MASK but this cleans up the pcm code */
123#define IIS_MASK DMA_OUT_MASK
106 124
107#define TIMER1_CFG (*(volatile unsigned long *)(0xcf001100)) 125#define TIMER1_CFG (*(volatile unsigned long *)(0xcf001100))
108#define TIMER1_VAL (*(volatile unsigned long *)(0xcf001104)) 126#define TIMER1_VAL (*(volatile unsigned long *)(0xcf001104))
diff --git a/firmware/export/pp5020.h b/firmware/export/pp5020.h
index af78101583..981ab318c5 100644
--- a/firmware/export/pp5020.h
+++ b/firmware/export/pp5020.h
@@ -84,7 +84,7 @@
84#define TIMER1_IRQ 0 84#define TIMER1_IRQ 0
85#define TIMER2_IRQ 1 85#define TIMER2_IRQ 1
86#define MAILBOX_IRQ 4 86#define MAILBOX_IRQ 4
87#define I2S_IRQ 10 87#define IIS_IRQ 10
88#define IDE_IRQ 23 88#define IDE_IRQ 23
89#define USB_IRQ 24 89#define USB_IRQ 24
90#define FIREWIRE_IRQ 25 90#define FIREWIRE_IRQ 25
@@ -97,7 +97,7 @@
97#define TIMER1_MASK (1 << TIMER1_IRQ) 97#define TIMER1_MASK (1 << TIMER1_IRQ)
98#define TIMER2_MASK (1 << TIMER2_IRQ) 98#define TIMER2_MASK (1 << TIMER2_IRQ)
99#define MAILBOX_MASK (1 << MAILBOX_IRQ) 99#define MAILBOX_MASK (1 << MAILBOX_IRQ)
100#define I2S_MASK (1 << I2S_IRQ) 100#define IIS_MASK (1 << IIS_IRQ)
101#define IDE_MASK (1 << IDE_IRQ) 101#define IDE_MASK (1 << IDE_IRQ)
102#define USB_MASK (1 << USB_IRQ) 102#define USB_MASK (1 << USB_IRQ)
103#define FIREWIRE_MASK (1 << FIREWIRE_IRQ) 103#define FIREWIRE_MASK (1 << FIREWIRE_IRQ)
@@ -307,12 +307,96 @@
307 307
308#define INIT_USB 0x80000000 308#define INIT_USB 0x80000000
309 309
310/* I2S */ 310/* IIS */
311#define IISCONFIG (*(volatile unsigned long*)(0x70002800)) 311#define IISCONFIG (*(volatile unsigned long*)(0x70002800))
312#define IISFIFO_CFG (*(volatile unsigned long*)(0x7000280c)) 312#define IISFIFO_CFG (*(volatile unsigned long*)(0x7000280c))
313#define IISFIFO_WR (*(volatile unsigned long*)(0x70002840)) 313#define IISFIFO_WR (*(volatile unsigned long*)(0x70002840))
314#define IISFIFO_RD (*(volatile unsigned long*)(0x70002880)) 314#define IISFIFO_RD (*(volatile unsigned long*)(0x70002880))
315 315
316/**
317 * IISCONFIG bits:
318 * | 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 |
319 * | RESET | |TXFIFOEN|RXFIFOEN| | ???? | MS | ???? |
320 * | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
321 * | | | | | | | | |
322 * | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 |
323 * | | | | | Bus Format[1:0] | Size[1:0] |
324 * | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
325 * | | Size Format[2:0] | ???? | ???? | IRQTX | IRQRX |
326 */
327
328/* All IIS formats send MSB first */
329#define IIS_RESET (1 << 31)
330#define IIS_TXFIFOEN (1 << 29)
331#define IIS_RXFIFOEN (1 << 28)
332#define IIS_MASTER (1 << 25)
333#define IIS_IRQTX (1 << 1)
334#define IIS_IRQRX (1 << 0)
335
336#define IIS_IRQTX_REG IISCONFIG
337#define IIS_IRQRX_REG IISCONFIG
338
339/* Data format on the IIS bus */
340#define IIS_FORMAT_MASK (0x3 << 10)
341#define IIS_FORMAT_IIS (0x0 << 10) /* Standard IIS - leading dummy bit */
342#define IIS_FORMAT_1 (0x1 << 10)
343#define IIS_FORMAT_LJUST (0x2 << 10) /* Left justified - no dummy bit */
344#define IIS_FORMAT_3 (0x3 << 10)
345/* Other formats not yet known */
346
347/* Data size on IIS bus */
348#define IIS_SIZE_MASK (0x3 << 8)
349#define IIS_SIZE_16BIT (0x0 << 8)
350/* Other sizes not yet known */
351
352/* Data size/format on IIS FIFO */
353#define IIS_FIFO_FORMAT_MASK (0x7 << 4)
354#define IIS_FIFO_FORMAT_0 (0x0 << 4)
355/* Big-endian formats - data sent to the FIFO must be big endian.
356 * I forgot which is which size but did test them. */
357#define IIS_FIFO_FORMAT_1 (0x1 << 4)
358#define IIS_FIFO_FORMAT_2 (0x2 << 4)
359 /* 32bit-MSB-little endian */
360#define IIS_FIFO_FORMAT_LE32 (0x3 << 4)
361 /* 16bit-MSB-little endian */
362#define IIS_FIFO_FORMAT_LE16 (0x4 << 4)
363
364/* FIFO formats 0x5 and above seem equivalent to 0x4 ?? */
365
366/**
367 * IISFIFO_CFG bits:
368 * | 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 |
369 * | | | RXFull[5:0] |
370 * | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
371 * | | | TXFree[5:0] |
372 * | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 |
373 * | | | | RXCLR | | | | TXCLR |
374 * | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
375 * | | | RX_FULL_LVL | | | TX_EMPTY_LVL |
376 */
377
378/* handy macros to extract the FIFO counts */
379#define IIS_RX_FULL_MASK (0x3f << 24)
380#define IIS_RX_FULL_COUNT \
381 ((IISFIFO_CFG & IIS_RX_FULL_MASK) >> 24)
382
383#define IIS_TX_FREE_MASK (0x3f << 16)
384#define IIS_TX_FREE_COUNT \
385 ((IISFIFO_CFG & IIS_TX_FREE_MASK) >> 16)
386
387#define IIS_RXCLR (1 << 12)
388#define IIS_TXCLR (1 << 8)
389/* Number of slots */
390#define IIS_RX_FULL_LVL_4 (0x1 << 4)
391#define IIS_RX_FULL_LVL_8 (0x2 << 4)
392#define IIS_RX_FULL_LVL_12 (0x3 << 4)
393
394#define IIS_TX_EMPTY_LVL_4 (0x1 << 0)
395#define IIS_TX_EMPTY_LVL_8 (0x2 << 0)
396#define IIS_TX_EMPTY_LVL_12 (0x3 << 0)
397
398/* Note: didn't bother to see of levels 0 and 16 actually work */
399
316/* Serial Controller */ 400/* Serial Controller */
317#define SERIAL0 (*(volatile unsigned long*)(0x70006000)) 401#define SERIAL0 (*(volatile unsigned long*)(0x70006000))
318#define SERIAL1 (*(volatile unsigned long*)(0x70006040)) 402#define SERIAL1 (*(volatile unsigned long*)(0x70006040))