apps/graphics/ft80x: Audio buffer size/offset is now configurable.

This commit is contained in:
Gregory Nutt 2018-02-26 09:58:52 -06:00
parent d47f474ed6
commit 9d2b92d75d
5 changed files with 111 additions and 72 deletions

View File

@ -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

View File

@ -125,10 +125,10 @@ struct ft80x_dlbuffer_s; /* Forward reference3 */
* Read an 8-, 16-, or 32-bit FT80x register value. * Read an 8-, 16-, or 32-bit FT80x register value.
* *
* Input Parameters: * Input Parameters:
* fd - The file descriptor of the FT80x device. Opened by the caller * fd - The file descriptor of the FT80x device. Opened by the caller
* with write access. * with write access.
* addr - The 32-bit aligned, 22-bit register value * addr - The 32-bit aligned, 22-bit register value
* value - The location to return the register value * value - The location to return the register value
* *
* Returned Value: * Returned Value:
* Zero (OK) on success. A negated errno value on failure. * Zero (OK) on success. A negated errno value on failure.
@ -146,11 +146,11 @@ int ft80x_getreg32(int fd, uint32_t addr, FAR uint32_t *value);
* Read multiple 32-bit FT80x register values. * Read multiple 32-bit FT80x register values.
* *
* Input Parameters: * Input Parameters:
* fd - The file descriptor of the FT80x device. Opened by the caller * fd - The file descriptor of the FT80x device. Opened by the caller
* with write access. * with write access.
* addr - The 32-bit aligned, 22-bit start register address * addr - The 32-bit aligned, 22-bit start register address
* nregs - The number of registers to read. * nregs - The number of registers to read.
* value - The location to return the register values * value - The location to return the register values
* *
* Returned Value: * Returned Value:
* Zero (OK) on success. A negated errno value on failure. * Zero (OK) on success. A negated errno value on failure.
@ -166,10 +166,10 @@ int ft80x_getregs(int fd, uint32_t addr, uint8_t nregs, FAR uint32_t *value);
* Wtite an 8-, 16-, or 32-bit FT80x register value. * Wtite an 8-, 16-, or 32-bit FT80x register value.
* *
* Input Parameters: * Input Parameters:
* fd - The file descriptor of the FT80x device. Opened by the caller * fd - The file descriptor of the FT80x device. Opened by the caller
* with write access. * with write access.
* addr - The 32-bit aligned, 22-bit register value * addr - The 32-bit aligned, 22-bit register value
* value - The register value to write. * value - The register value to write.
* *
* Returned Value: * Returned Value:
* Zero (OK) on success. A negated errno value on failure. * Zero (OK) on success. A negated errno value on failure.
@ -187,11 +187,11 @@ int ft80x_putreg32(int fd, uint32_t addr, uint32_t value);
* Write multiple 32-bit FT80x register values. * Write multiple 32-bit FT80x register values.
* *
* Input Parameters: * Input Parameters:
* fd - The file descriptor of the FT80x device. Opened by the caller * fd - The file descriptor of the FT80x device. Opened by the caller
* with write access. * with write access.
* addr - The 32-bit aligned, 22-bit start register address * addr - The 32-bit aligned, 22-bit start register address
* nregs - The number of registers to write. * nregs - The number of registers to write.
* value - The of the register values to be written. * value - The of the register values to be written.
* *
* Returned Value: * Returned Value:
* Zero (OK) on success. A negated errno value on failure. * Zero (OK) on success. A negated errno value on failure.
@ -225,10 +225,10 @@ int ft80x_ramdl_rewind(int fd);
* Append new display list data to RAM DL * Append new display list data to RAM DL
* *
* Input Parameters: * Input Parameters:
* fd - The file descriptor of the FT80x device. Opened by the caller * fd - The file descriptor of the FT80x device. Opened by the caller
* with write access. * with write access.
* data - A pointer to the start of the data to be written. * data - A pointer to the start of the data to be written.
* len - The number of bytes to be written. * len - The number of bytes to be written.
* *
* Returned Value: * Returned Value:
* Zero (OK) on success. A negated errno value on failure. * Zero (OK) on success. A negated errno value on failure.
@ -244,10 +244,10 @@ int ft80x_ramdl_append(int fd, FAR const void *data, size_t len);
* Append new display list data to RAM CMD * Append new display list data to RAM CMD
* *
* Input Parameters: * Input Parameters:
* fd - The file descriptor of the FT80x device. Opened by the caller * fd - The file descriptor of the FT80x device. Opened by the caller
* with write access. * with write access.
* data - A pointer to the start of the data to be append to RAM CMD. * data - A pointer to the start of the data to be append to RAM CMD.
* len - The number of bytes to be appended. * len - The number of bytes to be appended.
* *
* Returned Value: * Returned Value:
* Zero (OK) on success. A negated errno value on failure. * Zero (OK) on success. A negated errno value on failure.
@ -286,8 +286,8 @@ uint16_t ft80x_ramcmd_freespace(int fd, FAR uint16_t *offset,
* empty. * empty.
* *
* Input Parameters: * Input Parameters:
* fd - The file descriptor of the FT80x device. Opened by the caller * fd - The file descriptor of the FT80x device. Opened by the caller
* with write access. * with write access.
* *
* Returned Value: * Returned Value:
* Zero (OK) on success. A negated errno value on failure. * Zero (OK) on success. A negated errno value on failure.
@ -303,8 +303,8 @@ int ft80x_ramcmd_waitfifoempty(int fd);
* Perform the display swap operation. * Perform the display swap operation.
* *
* Input Parameters: * Input Parameters:
* fd - The file descriptor of the FT80x device. Opened by the caller * fd - The file descriptor of the FT80x device. Opened by the caller
* with write access. * with write access.
* *
* Returned Value: * Returned Value:
* Zero (OK) on success. A negated errno value on failure. * Zero (OK) on success. A negated errno value on failure.

View File

@ -55,19 +55,29 @@
* 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);

View File

@ -73,10 +73,10 @@
* display list logic. * display list logic.
* *
* Input Parameters: * Input Parameters:
* fd - The file descriptor of the FT80x device. Opened by the caller * fd - The file descriptor of the FT80x device. Opened by the caller
* with write access. * with write access.
* cmds - A list of 32-bit commands to be sent. * cmds - A list of 32-bit commands to be sent.
* ncmds - The number of commands in the list. * ncmds - The number of commands in the list.
* *
* Returned Value: * Returned Value:
* Zero (OK) on success. A negated errno value on failure. * Zero (OK) on success. A negated errno value on failure.
@ -101,8 +101,8 @@ int ft80x_coproc_send(int fd, FAR const uint32_t *cmds, size_t ncmds)
* starting address of RAM_CMD. * starting address of RAM_CMD.
* *
* Input Parameters: * Input Parameters:
* fd - The file descriptor of the FT80x device. Opened by the caller * fd - The file descriptor of the FT80x device. Opened by the caller
* with write access. * with write access.
* *
* Returned Value: * Returned Value:
* Zero (OK) on success. A negated errno value on failure. * Zero (OK) on success. A negated errno value on failure.

View File

@ -278,10 +278,10 @@ int ft80x_dl_create(int fd, FAR struct ft80x_dlbuffer_s *buffer,
* display list logic. * display list logic.
* *
* Input Parameters: * Input Parameters:
* fd - The file descriptor of the FT80x device. Opened by the caller * fd - The file descriptor of the FT80x device. Opened by the caller
* with write access. * with write access.
* cmds - A list of 32-bit commands to be sent. * cmds - A list of 32-bit commands to be sent.
* ncmds - The number of commands in the list. * ncmds - The number of commands in the list.
* *
* Returned Value: * Returned Value:
* Zero (OK) on success. A negated errno value on failure. * Zero (OK) on success. A negated errno value on failure.
@ -303,8 +303,8 @@ int ft80x_coproc_send(int fd, FAR const uint32_t *cmds, size_t ncmds);
* starting address of RAM_CMD. * starting address of RAM_CMD.
* *
* Input Parameters: * Input Parameters:
* fd - The file descriptor of the FT80x device. Opened by the caller * fd - The file descriptor of the FT80x device. Opened by the caller
* with write access. * with write access.
* *
* Returned Value: * Returned Value:
* Zero (OK) on success. A negated errno value on failure. * Zero (OK) on success. A negated errno value on failure.
@ -366,8 +366,8 @@ int ft80x_touch_gettransform(int fd, FAR uint32_t matrix[6]);
* touch 0. * touch 0.
* *
* Input Parameters: * Input Parameters:
* fd - The file descriptor of the FT80x device. Opened by the caller * fd - The file descriptor of the FT80x device. Opened by the caller
* with write access. * with write access.
* *
* Returned Value: * Returned Value:
* A value of 1-255 is returned if a graphics object is touched. Zero is * A value of 1-255 is returned if a graphics object is touched. Zero is
@ -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
@ -460,10 +460,10 @@ int ft80x_audio_playfile(int fd, FAR struct ft80x_dlbuffer_s *buffer,
* Set the backlight intensity via the PWM duty. * Set the backlight intensity via the PWM duty.
* *
* Input Parameters: * Input Parameters:
* fd - The file descriptor of the FT80x device. Opened by the caller * fd - The file descriptor of the FT80x device. Opened by the caller
* with write access. * with write access.
* duty - The new backlight duty (as a percentage 0..100) * duty - The new backlight duty (as a percentage 0..100)
* delay - The duration of the fade in milliseconds. * delay - The duration of the fade in milliseconds.
* *
* Returned Value: * Returned Value:
* Zero (OK) on success. A negated errno value on failure. * Zero (OK) on success. A negated errno value on failure.
@ -479,10 +479,10 @@ int ft80x_backlight_set(int fd, uint8_t duty);
* Change the backlight intensity with a controllable fade. * Change the backlight intensity with a controllable fade.
* *
* Input Parameters: * Input Parameters:
* fd - The file descriptor of the FT80x device. Opened by the caller * fd - The file descriptor of the FT80x device. Opened by the caller
* with write access. * with write access.
* duty - The terminal duty (as a percentage 0..100) * duty - The terminal duty (as a percentage 0..100)
* delay - The duration of the fade in milliseconds (10..16700). * delay - The duration of the fade in milliseconds (10..16700).
* *
* Returned Value: * Returned Value:
* Zero (OK) on success. A negated errno value on failure. * Zero (OK) on success. A negated errno value on failure.