diff --git a/graphics/ft80x/Kconfig b/graphics/ft80x/Kconfig index 5b8a24e14..7e7b05dcc 100644 --- a/graphics/ft80x/Kconfig +++ b/graphics/ft80x/Kconfig @@ -36,6 +36,34 @@ config GRAPHICS_FT80X_TAG_SIGNAL This is the signal that will be received when the co-processor the 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 bool "Enable error output" default y diff --git a/graphics/ft80x/ft80x.h b/graphics/ft80x/ft80x.h index 7cc9ede3a..fa2224c83 100644 --- a/graphics/ft80x/ft80x.h +++ b/graphics/ft80x/ft80x.h @@ -125,10 +125,10 @@ struct ft80x_dlbuffer_s; /* Forward reference3 */ * Read an 8-, 16-, or 32-bit FT80x register value. * * Input Parameters: - * fd - The file descriptor of the FT80x device. Opened by the caller - * with write access. - * addr - The 32-bit aligned, 22-bit register value - * value - The location to return the register value + * fd - The file descriptor of the FT80x device. Opened by the caller + * with write access. + * addr - The 32-bit aligned, 22-bit register value + * value - The location to return the register value * * Returned Value: * 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. * * Input Parameters: - * fd - The file descriptor of the FT80x device. Opened by the caller - * with write access. - * addr - The 32-bit aligned, 22-bit start register address - * nregs - The number of registers to read. - * value - The location to return the register values + * fd - The file descriptor of the FT80x device. Opened by the caller + * with write access. + * addr - The 32-bit aligned, 22-bit start register address + * nregs - The number of registers to read. + * value - The location to return the register values * * Returned Value: * 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. * * Input Parameters: - * fd - The file descriptor of the FT80x device. Opened by the caller - * with write access. - * addr - The 32-bit aligned, 22-bit register value - * value - The register value to write. + * fd - The file descriptor of the FT80x device. Opened by the caller + * with write access. + * addr - The 32-bit aligned, 22-bit register value + * value - The register value to write. * * Returned Value: * 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. * * Input Parameters: - * fd - The file descriptor of the FT80x device. Opened by the caller - * with write access. - * addr - The 32-bit aligned, 22-bit start register address - * nregs - The number of registers to write. - * value - The of the register values to be written. + * fd - The file descriptor of the FT80x device. Opened by the caller + * with write access. + * addr - The 32-bit aligned, 22-bit start register address + * nregs - The number of registers to write. + * value - The of the register values to be written. * * Returned Value: * 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 * * Input Parameters: - * fd - The file descriptor of the FT80x device. Opened by the caller - * with write access. - * data - A pointer to the start of the data to be written. - * len - The number of bytes to be written. + * fd - The file descriptor of the FT80x device. Opened by the caller + * with write access. + * data - A pointer to the start of the data to be written. + * len - The number of bytes to be written. * * Returned Value: * 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 * * Input Parameters: - * fd - The file descriptor of the FT80x device. Opened by the caller - * with write access. - * data - A pointer to the start of the data to be append to RAM CMD. - * len - The number of bytes to be appended. + * fd - The file descriptor of the FT80x device. Opened by the caller + * with write access. + * data - A pointer to the start of the data to be append to RAM CMD. + * len - The number of bytes to be appended. * * Returned Value: * 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. * * Input Parameters: - * fd - The file descriptor of the FT80x device. Opened by the caller - * with write access. + * fd - The file descriptor of the FT80x device. Opened by the caller + * with write access. * * Returned Value: * 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. * * Input Parameters: - * fd - The file descriptor of the FT80x device. Opened by the caller - * with write access. + * fd - The file descriptor of the FT80x device. Opened by the caller + * with write access. * * Returned Value: * Zero (OK) on success. A negated errno value on failure. diff --git a/graphics/ft80x/ft80x_audio.c b/graphics/ft80x/ft80x_audio.c index 1455709eb..19ab76661 100644 --- a/graphics/ft80x/ft80x_audio.c +++ b/graphics/ft80x/ft80x_audio.c @@ -55,19 +55,29 @@ * Pre-processor Definitions ****************************************************************************/ -/* We will use graphics memory starting at offset zero and through the - * following offset. - * - * REVISIT: Should these not be input parameters? +/* These configuration settings define the graphics memory region that we + * will use for audio buffering. */ -#define RAMG_MAXOFFSET (64 * 1024) -#define RAMG_MAXMASK (RAMG_MAXOFFSET - 1) +#define AUDIO_BUFOFFSET CONFIG_GRAPHICS_FT80X_AUDIO_BUFOFFSET +#define AUDIO_BUFSIZE CONFIG_GRAPHICS_FT80X_AUDIO_BUFSIZE +#define AUDIO_BUFEND (AUDIO_BUFOFFSET + AUDIO_BUFSIZE) -#if FT80X_DL_BUFSIZE > RAMG_MAXOFFSET -# define MAX_DLBUFFER RAMG_MAXOFFSET +#if AUDIO_BUFEND > FT80X_RAM_G_SIZE +# 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 -# define MAX_DLBUFFER FT80X_DL_BUFSIZE +# define MAX_DLBUFFER FT80X_DL_BUFSIZE #endif /**************************************************************************** @@ -196,7 +206,7 @@ int ft80x_audio_playfile(int fd, FAR struct ft80x_dlbuffer_s *buffer, if (readptr <= offset) { - freespace = RAMG_MAXOFFSET - offset; + freespace = AUDIO_BUFSIZE - offset; break; } @@ -229,7 +239,7 @@ int ft80x_audio_playfile(int fd, FAR struct ft80x_dlbuffer_s *buffer, } while (freespace < MAX_DLBUFFER && 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 */ @@ -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 */ - if (offset >= RAMG_MAXOFFSET) + if (offset >= AUDIO_BUFSIZE) { 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 */ /* 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) { 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 */ ret = ft80x_putreg32(fd, FT80X_REG_PLAYBACK_LENGTH, - RAMG_MAXOFFSET); + AUDIO_BUFSIZE); if (ret < 0) { 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 (offset < RAMG_MAXOFFSET) + if (offset < AUDIO_BUFSIZE) { - memset.ptr = FT80X_RAM_G + offset; - memset.num = RAMG_MAXOFFSET - offset; + memset.ptr = RAMG_STARTADDR + offset; + memset.num = AUDIO_BUFSIZE - offset; ret = ft80x_coproc_send(fd, (FAR const uint32_t *)&memset, 4); if (ret < 0) @@ -403,7 +414,7 @@ int ft80x_audio_playfile(int fd, FAR struct ft80x_dlbuffer_s *buffer, if (readptr > 0) { - memset.ptr = FT80X_RAM_G; + memset.ptr = RAMG_STARTADDR; memset.num = readptr; 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) */ { - memset.ptr = FT80X_RAM_G + offset; + memset.ptr = RAMG_STARTADDR + offset; memset.num = readptr - offset; ret = ft80x_coproc_send(fd, (FAR const uint32_t *)&memset, 4); diff --git a/graphics/ft80x/ft80x_coproc.c b/graphics/ft80x/ft80x_coproc.c index 5daf2ee8e..763ce517c 100644 --- a/graphics/ft80x/ft80x_coproc.c +++ b/graphics/ft80x/ft80x_coproc.c @@ -73,10 +73,10 @@ * display list logic. * * Input Parameters: - * fd - The file descriptor of the FT80x device. Opened by the caller - * with write access. - * cmds - A list of 32-bit commands to be sent. - * ncmds - The number of commands in the list. + * fd - The file descriptor of the FT80x device. Opened by the caller + * with write access. + * cmds - A list of 32-bit commands to be sent. + * ncmds - The number of commands in the list. * * Returned Value: * 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. * * Input Parameters: - * fd - The file descriptor of the FT80x device. Opened by the caller - * with write access. + * fd - The file descriptor of the FT80x device. Opened by the caller + * with write access. * * Returned Value: * Zero (OK) on success. A negated errno value on failure. diff --git a/include/graphics/ft80x.h b/include/graphics/ft80x.h index 6d9116a63..95911be38 100644 --- a/include/graphics/ft80x.h +++ b/include/graphics/ft80x.h @@ -278,10 +278,10 @@ int ft80x_dl_create(int fd, FAR struct ft80x_dlbuffer_s *buffer, * display list logic. * * Input Parameters: - * fd - The file descriptor of the FT80x device. Opened by the caller - * with write access. - * cmds - A list of 32-bit commands to be sent. - * ncmds - The number of commands in the list. + * fd - The file descriptor of the FT80x device. Opened by the caller + * with write access. + * cmds - A list of 32-bit commands to be sent. + * ncmds - The number of commands in the list. * * Returned Value: * 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. * * Input Parameters: - * fd - The file descriptor of the FT80x device. Opened by the caller - * with write access. + * fd - The file descriptor of the FT80x device. Opened by the caller + * with write access. * * Returned Value: * 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. * * Input Parameters: - * fd - The file descriptor of the FT80x device. Opened by the caller - * with write access. + * fd - The file descriptor of the FT80x device. Opened by the caller + * with write access. * * Returned Value: * 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 * * Description: - * Play an audio file + * Play an audio file. Audio files must consist of raw sample data. * * Input Parameters: * 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. * * Input Parameters: - * fd - The file descriptor of the FT80x device. Opened by the caller - * with write access. - * duty - The new backlight duty (as a percentage 0..100) - * delay - The duration of the fade in milliseconds. + * fd - The file descriptor of the FT80x device. Opened by the caller + * with write access. + * duty - The new backlight duty (as a percentage 0..100) + * delay - The duration of the fade in milliseconds. * * Returned Value: * 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. * * Input Parameters: - * fd - The file descriptor of the FT80x device. Opened by the caller - * with write access. - * duty - The terminal duty (as a percentage 0..100) - * delay - The duration of the fade in milliseconds (10..16700). + * fd - The file descriptor of the FT80x device. Opened by the caller + * with write access. + * duty - The terminal duty (as a percentage 0..100) + * delay - The duration of the fade in milliseconds (10..16700). * * Returned Value: * Zero (OK) on success. A negated errno value on failure.