Add touchscreen calibration IOCTLs, necessary structs, and implement for ATSAMA5D2

CI error
This commit is contained in:
TimJTi
2023-05-23 13:03:56 +01:00
committed by Xiang Xiao
parent 653ea69927
commit c12a122663
2 changed files with 123 additions and 27 deletions
+61 -6
View File
@@ -39,6 +39,8 @@
#include <nuttx/mm/circbuf.h>
#include <nuttx/semaphore.h>
#include <time.h>
#include <inttypes.h>
#include <fixedmath.h>
/****************************************************************************
* Pre-processor Definitions
@@ -48,12 +50,32 @@
/* Common TSC IOCTL commands */
#define TSIOC_SETCALIB _TSIOC(0x0001) /* arg: Pointer to int calibration value */
#define TSIOC_GETCALIB _TSIOC(0x0002) /* arg: Pointer to int calibration value */
#define TSIOC_SETFREQUENCY _TSIOC(0x0003) /* arg: Pointer to uint32_t frequency value */
#define TSIOC_GETFREQUENCY _TSIOC(0x0004) /* arg: Pointer to uint32_t frequency value */
#define TSIOC_GETFWVERSION _TSIOC(0x0005) /* arg: Pointer to uint32_t firmware version value */
#define TSIOC_ENABLEGESTURE _TSIOC(0x0006) /* arg: Pointer to int for enable gesture feature */
#define TSIOC_SETCALIB _TSIOC(0x0001) /* arg: Pointer to
* int Xplate R calibration value
*/
#define TSIOC_GETCALIB _TSIOC(0x0002) /* arg: Pointer to
* int Xplate R calibration value
*/
#define TSIOC_SETFREQUENCY _TSIOC(0x0003) /* arg: Pointer to
* uint32_t frequency value
*/
#define TSIOC_GETFREQUENCY _TSIOC(0x0004) /* arg: Pointer to
* uint32_t frequency value
*/
#define TSIOC_GETFWVERSION _TSIOC(0x0005) /* arg: Pointer to
* uint32_t firmware version
* value
* */
#define TSIOC_ENABLEGESTURE _TSIOC(0x0006) /* arg: Pointer to
* int for enable gesture feature
*/
#define TSIOC_DOACALIB _TSIOC(0x0007) /* arg: none.
* Initiate TS auto calibration
*/
#define TSIOC_CALDATA _TSIOC(0x0008) /* arg: Pointer to
* struct g_tscaldata_s
*/
#define TSIOC_USESCALED _TSIOC(0x0009) /* arg: bool, yes/no */
#define TSC_FIRST 0x0001 /* First common command */
#define TSC_NCMDS 6 /* Six common commands */
@@ -105,10 +127,43 @@
#define TOUCH_SLIDE_RIGHT (0x04)
#define TOUCH_PALM (0x05)
/* Help function */
#define SCALE_TS(x, o, s) (b16toi(b16divb16(((x) - (o)), (s))))
/****************************************************************************
* Public Types
****************************************************************************/
/* This struct is used to store touchscreen calibration data for use by
* low level touichscreen drivers.
*
* It is used as follows:
*
* scaledX = (raw_x - offset_x) / slope_x
* scaledY = (raw_y - offset_y) / slope_y
*
* The calibration values would typically be derived by taking top left and
* bottom right measurements on the actual LCD/touchscreen used:
*
* xSlope = (ActualRightX - ActualLeftX) / (WantedRightX - WantedLeftX)
* xOffset = ActualLeftX - (WantedLeftX * xSlope)
*
* And similarly for the Y values.
*
* ySlope = (ActualBottomY - ActualTopY) / (WantedBottomY - WantedTopY)
* yOffset = ActualTopY - (WantedTopY * ySlope)
*
*/
struct g_tscaldata_s
{
b16_t slope_x;
b16_t offset_x;
b16_t slope_y;
b16_t offset_y;
};
/* This structure contains information about a single touch point.
* Positional units are device specific.
*/