apps/graphics/ft80x: Simplify some interfaces.

This commit is contained in:
Gregory Nutt 2018-02-25 20:26:24 -06:00
parent 621f2f5e83
commit cdfd5afb33
6 changed files with 50 additions and 142 deletions

View File

@ -208,16 +208,15 @@ int ft80x_putregs(int fd, uint32_t addr, uint8_t nregs,
* Reset to the start of RAM DL memory
*
* Input Parameters:
* fd - The file descriptor of the FT80x device. Opened by the caller
* with write access.
* buffer - An instance of struct ft80x_dlbuffer_s allocated by the caller.
* 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.
*
****************************************************************************/
int ft80x_ramdl_rewind(int fd, FAR struct ft80x_dlbuffer_s *buffer);
int ft80x_ramdl_rewind(int fd);
/****************************************************************************
* Name: ft80x_ramdl_append
@ -228,15 +227,15 @@ int ft80x_ramdl_rewind(int fd, FAR struct ft80x_dlbuffer_s *buffer);
* Input Parameters:
* fd - The file descriptor of the FT80x device. Opened by the caller
* with write access.
* buffer - An instance of struct ft80x_dlbuffer_s allocated by the caller.
* 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.
*
****************************************************************************/
int ft80x_ramdl_append(int fd, FAR struct ft80x_dlbuffer_s *buffer,
FAR const void *data, size_t len);
int ft80x_ramdl_append(int fd, FAR const void *data, size_t len);
/****************************************************************************
* Name: ft80x_ramcmd_append
@ -247,15 +246,15 @@ int ft80x_ramdl_append(int fd, FAR struct ft80x_dlbuffer_s *buffer,
* Input Parameters:
* fd - The file descriptor of the FT80x device. Opened by the caller
* with write access.
* buffer - An instance of struct ft80x_dlbuffer_s allocated by the caller.
* 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.
*
****************************************************************************/
int ft80x_ramcmd_append(int fd, FAR struct ft80x_dlbuffer_s *buffer,
FAR const void *data, size_t len);
int ft80x_ramcmd_append(int fd, FAR const void *data, size_t len);
/****************************************************************************
* Name: ft80x_ramcmd_freespace

View File

@ -290,8 +290,7 @@ int ft80x_audio_playfile(int fd, FAR struct ft80x_dlbuffer_s *buffer,
/* Mute the sound clearing by clearing RAM_G after the current offset.
*
* REVISIT: There is an ugly hack into the display list logic in the
* following 8( I also suspect that the logic is not even correct.
* REVISIT: I suspect that this logic is not correct.
*/
memset.cmd = FT80X_CMD_MEMSET;
@ -299,25 +298,13 @@ int ft80x_audio_playfile(int fd, FAR struct ft80x_dlbuffer_s *buffer,
memset.value = 0;
memset.num = RAMG_MAXOFFSET - offset;
buffer->coproc = true;
buffer->dlsize = 0;
buffer->dloffset = sizeof(struct ft80x_cmd_memset_s);
ret = ft80x_ramcmd_append(fd, buffer, &memset,
sizeof(ft80x_ramcmd_append));
ret = ft80x_coproc_send(fd, (FAR const uint32_t *)&memset, 4);
if (ret < 0)
{
ft80x_err("ERROR: ft80x_ramcmd_append failed: %d\n", ret);
goto errout_with_fd;
}
ret = ft80x_ramcmd_waitfifoempty(fd);
if (ret < 0)
{
ft80x_err("ERROR: ft80x_ramcmd_waitfifoempty failed: %d\n", ret);
goto errout_with_fd;
}
/* If the read pointer is already passed over write pointer */
do

View File

@ -68,9 +68,6 @@
* Send commands to the co-processor via the CMD RAM FIFO. This function
* will not return until the command has been consumed by the co-processor.
*
* This function is similar to ft80x_ramcmd_append() but does not depend
* on a display list.
*
* NOTE: This command is not appropriate use while a display is being
* formed. It is will mess up the CMD RAM FIFO offsets managed by the
* display list logic.
@ -88,97 +85,7 @@
int ft80x_coproc_send(int fd, FAR const uint32_t *cmds, size_t ncmds)
{
struct ft80x_relmem_s wrdesc;
FAR const uint8_t *src;
ssize_t remaining;
size_t wrsize;
uint16_t offset;
uint16_t maxsize;
int ret;
/* Loop until all of the display list commands have been transferred to
* FIFO.
*/
src = (FAR const uint8_t *)cmds;
remaining = ncmds << 2;
do
{
/* Write the number of bytes remaining to be transferred */
wrsize = remaining;
/* Get the amount of free space in the FIFO. */
maxsize = 0;
ret = ft80x_ramcmd_freespace(fd, &offset, &maxsize);
if (ret < 0)
{
ft80x_err("ERROR: ft80x_ramcmd_freespace() failed: %d\n", ret);
return ret;
}
/* If the FIFO full? */
if (maxsize == 0)
{
/* Yes.. wait a bit and try again */
ft80x_warn("WARNING: FIFO is full: %d\n", ret);
usleep(50 * 1000);
continue;
}
/* Limit the write size to the size of the available FIFO memory */
if (wrsize > (size_t)maxsize)
{
wrsize = (size_t)maxsize;
}
/* Perform the transfer */
wrdesc.offset = offset;
wrdesc.nbytes = wrsize;
wrdesc.value = (FAR void *)src; /* Discards 'const' qualifier */
ret = ioctl(fd, FT80X_IOC_PUTRAMCMD,
(unsigned long)((uintptr_t)&wrdesc));
if (ret < 0)
{
int errcode = errno;
ft80x_err("ERROR: ioctl() FT80X_IOC_PUTRAMCMD failed: %d\n",
errcode);
return -errcode;
}
/* Update the command FIFO */
ret = ft80x_putreg16(fd, FT80X_REG_CMD_WRITE, offset + wrsize);
if (ret < 0)
{
ft80x_err("ERROR: ft80x_putreg16() failed: %d\n", ret);
return ret;
}
/* Wait for the FIFO to empty */
ret = ft80x_ramcmd_waitfifoempty(fd);
if (ret < 0)
{
ft80x_err("ERROR: ft80x_ramcmd_waitfifoempty() failed: %d\n", ret);
return ret;
}
/* Set up for the next time through the loop */
remaining -= wrsize;
src += wrsize;
}
while (remaining > 0);
return OK;
return ft80x_ramcmd_append(fd, cmds, ncmds << 2);
}
/****************************************************************************

View File

@ -152,13 +152,13 @@ static int ft80x_dl_append(int fd, FAR struct ft80x_dlbuffer_s *buffer,
{
/* Append data to RAM CMD */
ret = ft80x_ramcmd_append(fd, buffer, data, len);
ret = ft80x_ramcmd_append(fd, data, len);
}
else
{
/* Append data to RAM DL */
ret = ft80x_ramdl_append(fd, buffer, data, len);
ret = ft80x_ramdl_append(fd, data, len);
}
return ret;
@ -215,7 +215,7 @@ int ft80x_dl_start(int fd, FAR struct ft80x_dlbuffer_s *buffer, bool coproc)
* beginning of the hardware display list.
*/
ret = ft80x_ramdl_rewind(fd, buffer);
ret = ft80x_ramdl_rewind(fd);
if (ret < 0)
{
ft80x_err("ERROR: ft80x_ramdl_rewind failed: %d\n", ret);
@ -641,7 +641,7 @@ int ft80x_dl_flush(int fd, FAR struct ft80x_dlbuffer_s *buffer, bool wait)
/* Write the content of the local display buffer to hardware. */
ret = ft80x_dl_append(fd, buffer, buffer->dlbuffer, buffer->dloffset);
ret = ft80x_dl_append(fd, buffer, buffer->dlbuffer, buffer->dloffset);
if (ret < 0)
{
ft80x_err("ERROR: ft80x_dl_append failed: %d\n", ret);

View File

@ -64,17 +64,15 @@
* Input Parameters:
* fd - The file descriptor of the FT80x device. Opened by the caller
* with write access.
* buffer - An instance of struct ft80x_dlbuffer_s allocated by the caller.
* data - A pointer to the start of the data to be written.
* len - The number of bytes to be written.
* 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.
*
****************************************************************************/
int ft80x_ramcmd_append(int fd, FAR struct ft80x_dlbuffer_s *buffer,
FAR const void *data, size_t len)
int ft80x_ramcmd_append(int fd, FAR const void *data, size_t len)
{
struct ft80x_relmem_s wrdesc;
FAR const uint8_t *src;
@ -84,6 +82,9 @@ int ft80x_ramcmd_append(int fd, FAR struct ft80x_dlbuffer_s *buffer,
uint16_t maxsize;
int ret;
DEBUGASSERT(data != NULL && ((uintptr_t)data & 3) == 0 &&
len > 0 && (len & 3) == 0);
/* Loop until all of the display list commands have been transferred to
* FIFO.
*/
@ -116,8 +117,27 @@ int ft80x_ramcmd_append(int fd, FAR struct ft80x_dlbuffer_s *buffer,
if (maxsize == 0)
{
#if 1
/* Yes.. wait for the FIFO to empty, then try again.
*
* REVISIT: Would it not be sufficient to wait only until the
* FIFO is not full?
*/
ft80x_warn("WARNING: FIFO is full: %d\n", ret);
ret = ft80x_ramcmd_waitfifoempty(fd);
if (ret < 0)
{
ft80x_err("ERROR: ft80x_ramcmd_waitfifoempty() failed: %d\n",
ret);
return ret;
}
continue;
#else
ft80x_err("ERROR: FIFO is full: %d\n", ret);
return -ENOSPC;
#endif
}
/* Limit the write size to the size of the available FIFO memory */
@ -152,7 +172,7 @@ int ft80x_ramcmd_append(int fd, FAR struct ft80x_dlbuffer_s *buffer,
return ret;
}
/* Wait for the FIFO to empty if there is more to be sent */
/* Wait for the FIFO to empty */
if (remaining > wrsize)
{
@ -167,8 +187,8 @@ int ft80x_ramcmd_append(int fd, FAR struct ft80x_dlbuffer_s *buffer,
/* Set up for the next time through the loop. */
remaining -= wrsize;
src += wrsize;
remaining -= wrsize;
src += wrsize;
}
while (remaining > 0);

View File

@ -61,21 +61,18 @@
* Reset to the start of RAM DL memory
*
* Input Parameters:
* fd - The file descriptor of the FT80x device. Opened by the caller
* with write access.
* buffer - An instance of struct ft80x_dlbuffer_s allocated by the caller.
* 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.
*
****************************************************************************/
int ft80x_ramdl_rewind(int fd, FAR struct ft80x_dlbuffer_s *buffer)
int ft80x_ramdl_rewind(int fd)
{
off_t pos;
DEBUGASSERT(fd >= 0 && buffer != NULL);
/* Reposition the VFSso that subsequent writes will be to the beginning of
* the hardware display list.
*/
@ -100,7 +97,6 @@ int ft80x_ramdl_rewind(int fd, FAR struct ft80x_dlbuffer_s *buffer)
* Input Parameters:
* fd - The file descriptor of the FT80x device. Opened by the caller
* with write access.
* buffer - An instance of struct ft80x_dlbuffer_s allocated by the caller.
* data - A pointer to the start of the data to be written.
* len - The number of bytes to be written.
*
@ -109,13 +105,12 @@ int ft80x_ramdl_rewind(int fd, FAR struct ft80x_dlbuffer_s *buffer)
*
****************************************************************************/
int ft80x_ramdl_append(int fd, FAR struct ft80x_dlbuffer_s *buffer,
FAR const void *data, size_t len)
int ft80x_ramdl_append(int fd, FAR const void *data, size_t len)
{
size_t nwritten;
DEBUGASSERT(fd >= 0 && buffer != NULL && data != NULL &&
((uintptr_t)data & 3) == 0 && len > 0 && (len & 3) == 0);
DEBUGASSERT(data != NULL && ((uintptr_t)data & 3) == 0 &&
len > 0 && (len & 3) == 0);
/* Write the aligned data directly to the FT80x hardware display list.
*