drivers/lcd: Add FT80x IOCTL commands to access individual registers.

This commit is contained in:
Gregory Nutt 2018-02-18 12:39:15 -06:00
parent be73c65b64
commit 65513d58e3
3 changed files with 196 additions and 32 deletions

View File

@ -632,16 +632,16 @@ static int ft80x_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
}
break;
/* FT80X_IOC_GETRESULT32:
/* FT80X_IOC_GETDL32:
* Description: Read a 32-bit value from the display list.
* Argument: A reference to an instance of struct ft80x_result32_s.
* Argument: A reference to an instance of struct ft80x_dlmem_s.
* Returns: The 32-bit value read from the display list.
*/
case FT80X_IOC_GETRESULT32:
case FT80X_IOC_GETDL32:
{
FAR struct ft80x_result32_s *result =
(FAR struct ft80x_result32_s *)((uintptr_t)arg);
FAR struct ft80x_dlmem_s *result =
(FAR struct ft80x_dlmem_s *)((uintptr_t)arg);
if (result == NULL || ((uintptr_t)&result->offset & 3) != 0 ||
result->offset >= FT80X_RAM_DL_SIZE)
@ -657,25 +657,139 @@ static int ft80x_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
}
break;
/* FT80X_IOC_GETTRACKER:
* Description: After CMD_TRACK has been issued, the coprocessor
* will update the TRACKER register with new position
* data.
* Argument: A pointer to a writable uint32_t memory location.
* Returns: The new content of the tracker register.
/* FT80X_IOC_GETREG8:
* Description: Read an 8-bit register value from the FT80x.
* Argument: A reference to an instance of struct ft80x_register_s.
* Returns: The 8-bit value read from the display list.
*/
case FT80X_IOC_GETTRACKER:
case FT80X_IOC_GETREG8:
{
FAR uint32_t *tracker = (FAR uint32_t *)((uintptr_t)arg);
FAR struct ft80x_register_s *reg =
(FAR struct ft80x_register_s *)((uintptr_t)arg);
if (tracker == NULL)
if (reg == NULL || ((uintptr_t)&reg->addr & 3) != 0)
{
ret = -EINVAL;
}
else
{
*tracker = ft80x_read_word(priv, FT80X_REG_TRACKER);
reg->value.u8 = ft80x_read_byte(priv, reg->addr);
ret = OK;
}
}
break;
/* FT80X_IOC_GETREG16:
* Description: Read a 16-bit register value from the FT80x.
* Argument: A reference to an instance of struct ft80x_register_s.
* Returns: The 16-bit value read from the display list.
*/
case FT80X_IOC_GETREG16:
{
FAR struct ft80x_register_s *reg =
(FAR struct ft80x_register_s *)((uintptr_t)arg);
if (reg == NULL || ((uintptr_t)&reg->addr & 3) != 0)
{
ret = -EINVAL;
}
else
{
reg->value.u16 = ft80x_read_hword(priv, reg->addr);
ret = OK;
}
}
break;
/* FT80X_IOC_GETREG32:
* Description: Read a 32-bit register value from the FT80x.
* Argument: A reference to an instance of struct ft80x_register_s.
* Returns: The 32-bit value read from the display list.
*/
case FT80X_IOC_GETREG32:
{
FAR struct ft80x_register_s *reg =
(FAR struct ft80x_register_s *)((uintptr_t)arg);
if (reg == NULL || ((uintptr_t)&reg->addr & 3) != 0)
{
ret = -EINVAL;
}
else
{
reg->value.u32 = ft80x_read_word(priv, reg->addr);
ret = OK;
}
}
break;
/* FT80X_IOC_PUTREG8:
* Description: Write an 8-bit register value to the FT80x.
* Argument: A reference to an instance of struct ft80x_register_s.
* Returns: None.
*/
case FT80X_IOC_PUTREG8:
{
FAR struct ft80x_register_s *reg =
(FAR struct ft80x_register_s *)((uintptr_t)arg);
if (reg == NULL || ((uintptr_t)&reg->addr & 3) != 0)
{
ret = -EINVAL;
}
else
{
ft80x_write_byte(priv, reg->addr, reg->value.u8);
ret = OK;
}
}
break;
/* FT80X_IOC_PUTREG16:
* Description: Write a 16-bit register value to the FT80x.
* Argument: A reference to an instance of struct ft80x_register_s.
* Returns: None.
*/
case FT80X_IOC_PUTREG16:
{
FAR struct ft80x_register_s *reg =
(FAR struct ft80x_register_s *)((uintptr_t)arg);
if (reg == NULL || ((uintptr_t)&reg->addr & 3) != 0)
{
ret = -EINVAL;
}
else
{
ft80x_write_hword(priv, reg->addr, reg->value.u16);
ret = OK;
}
}
break;
/* FT80X_IOC_PUTREG32:
* Description: Write a 32-bit register value to the FT80x.
* Argument: A reference to an instance of struct ft80x_register_s.
* Returns: None.
*/
case FT80X_IOC_PUTREG32:
{
FAR struct ft80x_register_s *reg =
(FAR struct ft80x_register_s *)((uintptr_t)arg);
if (reg == NULL || ((uintptr_t)&reg->addr & 3) != 0)
{
ret = -EINVAL;
}
else
{
ft80x_write_word(priv, reg->addr, reg->value.u32);
ret = OK;
}
}

View File

@ -124,18 +124,42 @@
* display list offset.
*
* Output values from display commands are not automatically written back in
* either case but must be subsequently obtained using FT80X_IOC_GETRESULT32.
* either case but must be subsequently obtained using FT80X_IOC_GETDL32.
*
* FT80X_IOC_GETRESULT32:
* FT80X_IOC_GETDL32:
* Description: Read a 32-bit value from the display list.
* Argument: A reference to an instance of struct ft80x_result32_s below.
* Argument: A reference to an instance of struct ft80x_dlmem_s below.
* Returns: The 32-bit value read from the display list.
*
* FT80X_IOC_GETTRACKER:
* Description: After CMD_TRACK has been issued, the co-processor will update
* the TRACKER register with new position data.
* Argument: A pointer to a writable uint32_t memory location.
* Returns: The new content of the tracker register.
* FT80X_IOC_GETREG8:
* Description: Read an 8-bit register value from the FT80x.
* Argument: A reference to an instance of struct ft80x_register_s below.
* Returns: The 8-bit value read from the display list.
*
* FT80X_IOC_GETREG16:
* Description: Read a 16-bit register value from the FT80x.
* Argument: A reference to an instance of struct ft80x_register_s below.
* Returns: The 16-bit value read from the display list.
*
* FT80X_IOC_GETREG32:
* Description: Read a 32-bit register value from the FT80x.
* Argument: A reference to an instance of struct ft80x_register_s below.
* Returns: The 32-bit value read from the display list.
*
* FT80X_IOC_PUTREG8:
* Description: Write an 8-bit register value to the FT80x.
* Argument: A reference to an instance of struct ft80x_register_s below.
* Returns: None.
*
* FT80X_IOC_PUTREG16:
* Description: Write a 16-bit register value to the FT80x.
* Argument: A reference to an instance of struct ft80x_register_s below.
* Returns: None.
*
* FT80X_IOC_PUTREG32:
* Description: Write a 32-bit register value to the FT80x.
* Argument: A reference to an instance of struct ft80x_register_s below.
* Returns: None.
*
* FT80X_IOC_EVENTNOTIFY:
* Description: Setup to receive a signal when there is a change in any
@ -151,9 +175,14 @@
#define FT80X_IOC_CREATEDL _LCDIOC(FT80X_NIOCTL_BASE + 0)
#define FT80X_IOC_APPENDDL _LCDIOC(FT80X_NIOCTL_BASE + 1)
#define FT80X_IOC_GETRESULT32 _LCDIOC(FT80X_NIOCTL_BASE + 2)
#define FT80X_IOC_GETTRACKER _LCDIOC(FT80X_NIOCTL_BASE + 3)
#define FT80X_IOC_EVENTNOTIFY _LCDIOC(FT80X_NIOCTL_BASE + 4)
#define FT80X_IOC_GETDL32 _LCDIOC(FT80X_NIOCTL_BASE + 2)
#define FT80X_IOC_GETREG8 _LCDIOC(FT80X_NIOCTL_BASE + 3)
#define FT80X_IOC_GETREG16 _LCDIOC(FT80X_NIOCTL_BASE + 4)
#define FT80X_IOC_GETREG32 _LCDIOC(FT80X_NIOCTL_BASE + 5)
#define FT80X_IOC_PUTREG8 _LCDIOC(FT80X_NIOCTL_BASE + 6)
#define FT80X_IOC_PUTREG16 _LCDIOC(FT80X_NIOCTL_BASE + 7)
#define FT80X_IOC_PUTREG32 _LCDIOC(FT80X_NIOCTL_BASE + 8)
#define FT80X_IOC_EVENTNOTIFY _LCDIOC(FT80X_NIOCTL_BASE + 9)
/* FT80x Display List Commands **********************************************/
/* Host commands. 3 word commands. The first word begins with 0b01, the next two are zero */
@ -1055,17 +1084,17 @@ struct ft80x_cmd_translate_s
struct ft80x_displaylist_s
{
uint32_t dlsize; /* Size of the display list in bytes (input) */
struct ft80x_dlcmd_s cmd; /* First command in the display list (input) */
uint32_t dlsize; /* Size of the display list in bytes */
struct ft80x_dlcmd_s cmd; /* First command in the display list */
};
/* This structure is used with the FT80X_IOC_GETRESULT32 IOCTL command to
/* This structure is used with the FT80X_IOC_GETDL32 IOCTL command to
* retrieve the result of the display list operation from display list memory.
*/
struct ft80x_result32_s
struct ft80x_dlmem_s
{
uint32_t offset; /* 32-bit aligned offset into the display list (input) */
uint32_t offset; /* 32-bit aligned offset into the display list */
uint32_t value; /* 32-bit value read from display list + offset */
};
@ -1093,6 +1122,27 @@ struct ft80x_notify_s
bool enable; /* True: enable notification; false: disable */
};
/* This structure is used with the FT80X_IOC_GETREGnn and FT80X_IOC_PUTREGnn
* IOCTL commands to describe the requested register access.
*
* NOTES:
* - For FT80X_IOC_GETREGnn, the value is an output; for FT80X_IOC_PUTREGnn,
* the value is an input.
* - The union field used to access the register value depends on the width
* of the requested access.
*/
struct ft80x_register_s
{
uint32_t addr; /* 32-bit aligned register address */
union
{
uint8_t u8; /* 8-bit register value */
uint16_t u16; /* 16-bit register value */
uint32_t u32; /* 32-bit register value */
} value;
};
/****************************************************************************
* Public Function Prototypes
****************************************************************************/

View File

@ -50,7 +50,7 @@
/* IOCTL commands set aside for FT80x character driver */
#define FT80X_NIOCTL_CMDS 3
#define FT80X_NIOCTL_CMDS 10
#define FT80X_NIOCTL_BASE 0x0001
#endif /* __INCLUDE_NUTTX_INPUT_LCD_IOCTL_H */