apps/graphics/ft80x: Audio buffer size/offset is now configurable.
This commit is contained in:
parent
d47f474ed6
commit
9d2b92d75d
@ -36,6 +36,34 @@ config GRAPHICS_FT80X_TAG_SIGNAL
|
|||||||
This is the signal that will be received when the co-processor the
|
This is the signal that will be received when the co-processor the
|
||||||
detected touch tag changes.
|
detected touch tag changes.
|
||||||
|
|
||||||
|
config GRAPHICS_FT80X_AUDIO_BUFOFFSET
|
||||||
|
hex "RAM G audio buffer start offset"
|
||||||
|
default 0x00000
|
||||||
|
range 0x00000 0x3f800
|
||||||
|
---help---
|
||||||
|
When playing an audio file, chunks of the audio file will be stored
|
||||||
|
in a circular buffer in graphics RAM (RAMG G, 256Kb).
|
||||||
|
|
||||||
|
CONFIG_GRAPHICS_FT80X_AUDIO_BUFOFFSET is the starting offset in RAM G for that
|
||||||
|
buffer and CONFIG_FT80x_AUDIO_BUFSIZE is the size of the buffer.
|
||||||
|
|
||||||
|
The buffer may, of course, be used for other purposes when not
|
||||||
|
playing an audio file.
|
||||||
|
|
||||||
|
config GRAPHICS_FT80X_AUDIO_BUFSIZE
|
||||||
|
hex "RAM G audio buffer size"
|
||||||
|
default 0x10000
|
||||||
|
range 0x00800 0x38000
|
||||||
|
---help---
|
||||||
|
When playing an audio file, chunks of the audio file will be stored
|
||||||
|
in a circular buffer in graphics RAM (RAMG G, 256Kb).
|
||||||
|
|
||||||
|
CONFIG_GRAPHICS_FT80X_AUDIO_BUFOFFSET is the starting offset in RAM G for that
|
||||||
|
buffer and CONFIG_FT80x_AUDIO_BUFSIZE is the size of the buffer.
|
||||||
|
|
||||||
|
The buffer may, of course, be used for other purposes when not
|
||||||
|
playing an audio file.
|
||||||
|
|
||||||
config GRAPHICS_FT80X_DEBUG_ERROR
|
config GRAPHICS_FT80X_DEBUG_ERROR
|
||||||
bool "Enable error output"
|
bool "Enable error output"
|
||||||
default y
|
default y
|
||||||
|
@ -55,17 +55,27 @@
|
|||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* We will use graphics memory starting at offset zero and through the
|
/* These configuration settings define the graphics memory region that we
|
||||||
* following offset.
|
* will use for audio buffering.
|
||||||
*
|
|
||||||
* REVISIT: Should these not be input parameters?
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define RAMG_MAXOFFSET (64 * 1024)
|
#define AUDIO_BUFOFFSET CONFIG_GRAPHICS_FT80X_AUDIO_BUFOFFSET
|
||||||
#define RAMG_MAXMASK (RAMG_MAXOFFSET - 1)
|
#define AUDIO_BUFSIZE CONFIG_GRAPHICS_FT80X_AUDIO_BUFSIZE
|
||||||
|
#define AUDIO_BUFEND (AUDIO_BUFOFFSET + AUDIO_BUFSIZE)
|
||||||
|
|
||||||
#if FT80X_DL_BUFSIZE > RAMG_MAXOFFSET
|
#if AUDIO_BUFEND > FT80X_RAM_G_SIZE
|
||||||
# define MAX_DLBUFFER RAMG_MAXOFFSET
|
# error "Audio buffer extends beyond RAM G"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define RAMG_STARTADDR (FT80X_RAM_G + AUDIO_BUFOFFSET)
|
||||||
|
#define RAMG_ENDADDR (FT80X_RAM_G + AUDIO_BUFEND)
|
||||||
|
|
||||||
|
/* The display list buffer will be re-purposed as an I/O buffer for the
|
||||||
|
* transfer of audio data to RAM G.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if FT80X_DL_BUFSIZE > AUDIO_BUFSIZE
|
||||||
|
# define MAX_DLBUFFER AUDIO_BUFSIZE
|
||||||
#else
|
#else
|
||||||
# define MAX_DLBUFFER FT80X_DL_BUFSIZE
|
# define MAX_DLBUFFER FT80X_DL_BUFSIZE
|
||||||
#endif
|
#endif
|
||||||
@ -196,7 +206,7 @@ int ft80x_audio_playfile(int fd, FAR struct ft80x_dlbuffer_s *buffer,
|
|||||||
|
|
||||||
if (readptr <= offset)
|
if (readptr <= offset)
|
||||||
{
|
{
|
||||||
freespace = RAMG_MAXOFFSET - offset;
|
freespace = AUDIO_BUFSIZE - offset;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,7 +239,7 @@ int ft80x_audio_playfile(int fd, FAR struct ft80x_dlbuffer_s *buffer,
|
|||||||
}
|
}
|
||||||
while (freespace < MAX_DLBUFFER &&
|
while (freespace < MAX_DLBUFFER &&
|
||||||
freespace < remaining &&
|
freespace < remaining &&
|
||||||
freespace < (RAMG_MAXOFFSET - offset));
|
freespace < (AUDIO_BUFSIZE - offset));
|
||||||
|
|
||||||
/* Clip to the amount that will fit at the tail of the RAM G buffer */
|
/* Clip to the amount that will fit at the tail of the RAM G buffer */
|
||||||
|
|
||||||
@ -268,7 +278,7 @@ int ft80x_audio_playfile(int fd, FAR struct ft80x_dlbuffer_s *buffer,
|
|||||||
|
|
||||||
/* Wrap the offset back to the beginning of the buffer if necessary */
|
/* Wrap the offset back to the beginning of the buffer if necessary */
|
||||||
|
|
||||||
if (offset >= RAMG_MAXOFFSET)
|
if (offset >= AUDIO_BUFSIZE)
|
||||||
{
|
{
|
||||||
offset = 0;
|
offset = 0;
|
||||||
}
|
}
|
||||||
@ -284,7 +294,8 @@ int ft80x_audio_playfile(int fd, FAR struct ft80x_dlbuffer_s *buffer,
|
|||||||
/* Start playing at the beginning of graphics memory */
|
/* Start playing at the beginning of graphics memory */
|
||||||
/* Set the audio playback start address */
|
/* Set the audio playback start address */
|
||||||
|
|
||||||
ret = ft80x_putreg32(fd, FT80X_REG_PLAYBACK_START, FT80X_RAM_G);
|
ret = ft80x_putreg32(fd, FT80X_REG_PLAYBACK_START,
|
||||||
|
RAMG_STARTADDR);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
ft80x_err("ERROR: ft80x_putreg32 failed: %d\n", ret);
|
ft80x_err("ERROR: ft80x_putreg32 failed: %d\n", ret);
|
||||||
@ -294,7 +305,7 @@ int ft80x_audio_playfile(int fd, FAR struct ft80x_dlbuffer_s *buffer,
|
|||||||
/* Set the length of the audio buffer */
|
/* Set the length of the audio buffer */
|
||||||
|
|
||||||
ret = ft80x_putreg32(fd, FT80X_REG_PLAYBACK_LENGTH,
|
ret = ft80x_putreg32(fd, FT80X_REG_PLAYBACK_LENGTH,
|
||||||
RAMG_MAXOFFSET);
|
AUDIO_BUFSIZE);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
ft80x_err("ERROR: ft80x_putreg32 failed: %d\n", ret);
|
ft80x_err("ERROR: ft80x_putreg32 failed: %d\n", ret);
|
||||||
@ -388,10 +399,10 @@ int ft80x_audio_playfile(int fd, FAR struct ft80x_dlbuffer_s *buffer,
|
|||||||
|
|
||||||
if (readptr <= offset)
|
if (readptr <= offset)
|
||||||
{
|
{
|
||||||
if (offset < RAMG_MAXOFFSET)
|
if (offset < AUDIO_BUFSIZE)
|
||||||
{
|
{
|
||||||
memset.ptr = FT80X_RAM_G + offset;
|
memset.ptr = RAMG_STARTADDR + offset;
|
||||||
memset.num = RAMG_MAXOFFSET - offset;
|
memset.num = AUDIO_BUFSIZE - offset;
|
||||||
|
|
||||||
ret = ft80x_coproc_send(fd, (FAR const uint32_t *)&memset, 4);
|
ret = ft80x_coproc_send(fd, (FAR const uint32_t *)&memset, 4);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@ -403,7 +414,7 @@ int ft80x_audio_playfile(int fd, FAR struct ft80x_dlbuffer_s *buffer,
|
|||||||
|
|
||||||
if (readptr > 0)
|
if (readptr > 0)
|
||||||
{
|
{
|
||||||
memset.ptr = FT80X_RAM_G;
|
memset.ptr = RAMG_STARTADDR;
|
||||||
memset.num = readptr;
|
memset.num = readptr;
|
||||||
|
|
||||||
ret = ft80x_coproc_send(fd, (FAR const uint32_t *)&memset, 4);
|
ret = ft80x_coproc_send(fd, (FAR const uint32_t *)&memset, 4);
|
||||||
@ -416,7 +427,7 @@ int ft80x_audio_playfile(int fd, FAR struct ft80x_dlbuffer_s *buffer,
|
|||||||
}
|
}
|
||||||
else /* if (readptr > offset) */
|
else /* if (readptr > offset) */
|
||||||
{
|
{
|
||||||
memset.ptr = FT80X_RAM_G + offset;
|
memset.ptr = RAMG_STARTADDR + offset;
|
||||||
memset.num = readptr - offset;
|
memset.num = readptr - offset;
|
||||||
|
|
||||||
ret = ft80x_coproc_send(fd, (FAR const uint32_t *)&memset, 4);
|
ret = ft80x_coproc_send(fd, (FAR const uint32_t *)&memset, 4);
|
||||||
|
@ -425,7 +425,7 @@ int ft80x_touch_info(int fd, FAR struct ft80x_touchinfo_s *info);
|
|||||||
* Name: ft80x_audio_playfile
|
* Name: ft80x_audio_playfile
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Play an audio file
|
* Play an audio file. Audio files must consist of raw sample data.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* fd - The file descriptor of the FT80x device. Opened by the
|
* fd - The file descriptor of the FT80x device. Opened by the
|
||||||
|
Loading…
x
Reference in New Issue
Block a user