drivers/input: Add driver for Goodix GT9XX Touch Panel

This PR adds the driver for Goodix GT9XX I2C Touch Panel, which will be called by PINE64 PinePhone.

Our driver follows the design of the NuttX Driver for [Cypress MBR3108](https://github.com/apache/nuttx/blob/master/drivers/input/cypress_mbr3108.c).

We have documented our driver here: ["NuttX Touch Panel Driver for PinePhone"](https://lupyuen.github.io/articles/touch2#appendix-nuttx-touch-panel-driver-for-pinephone)

`drivers/input/Kconfig`: Added option `INPUT_GT9XX` to select GT9XX Driver

`drivers/input/Make.defs`: Added GT9XX Driver to Makefile

`drivers/input/gt9xx.c`, `gt9xx.h`: I2C Driver for GT9XX Touch Panel
This commit is contained in:
Lee Lup Yuen
2023-01-11 12:06:44 +08:00
committed by Xiang Xiao
parent 6c5cb98e7d
commit 6de5a862cd
4 changed files with 1067 additions and 0 deletions
+23
View File
@@ -499,6 +499,29 @@ config INPUT_CYPRESS_MBR3108_NPOLLWAITERS
endif # INPUT_CYPRESS_MBR3108
config INPUT_GT9XX
bool "Goodix GT9xx Driver"
default n
select INPUT_TOUCHSCREEN
---help---
Enable support for Goodix GT9xx touch panel.
if INPUT_GT9XX
config INPUT_GT9XX_NPOLLWAITERS
int "Number of waiters to poll"
default 1
---help---
Maximum number of threads that can be waiting on poll()
config INPUT_GT9XX_I2C_FREQUENCY
int "I2C frequency (Hz)"
default 400000
---help---
I2C frequency in Hz
endif # INPUT_GT9XX
config INPUT_BUTTONS
bool "Button Inputs"
default n
+4
View File
@@ -72,6 +72,10 @@ ifeq ($(CONFIG_INPUT_CYPRESS_MBR3108),y)
CSRCS += cypress_mbr3108.c
endif
ifeq ($(CONFIG_INPUT_GT9XX),y)
CSRCS += gt9xx.c
endif
ifeq ($(CONFIG_INPUT_BUTTONS),y)
CSRCS += button_upper.c
ifeq ($(CONFIG_INPUT_BUTTONS_LOWER),y)
File diff suppressed because it is too large Load Diff
+84
View File
@@ -0,0 +1,84 @@
/****************************************************************************
* include/nuttx/input/gt9xx.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __INCLUDE_NUTTX_INPUT_GT9XX_H
#define __INCLUDE_NUTTX_INPUT_GT9XX_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/compiler.h>
#include <stdbool.h>
#include <stdint.h>
/****************************************************************************
* Public Types
****************************************************************************/
/* Callback for Board-Specific Operations */
struct gt9xx_board_s
{
/* Attach the Interrupt Handler for Touch Panel */
int (*irq_attach) (const struct gt9xx_board_s *state,
xcpt_t isr,
FAR void *arg);
/* Enable or disable Interrupts for the Touch Panel. Will be called by
* Interrupt Handler.
*/
void (*irq_enable) (const struct gt9xx_board_s *state, bool enable);
/* Power on or off the Touch Panel */
int (*set_power) (const struct gt9xx_board_s *state, bool on);
};
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: gt9xx_register
*
* Description:
* Register the driver for Goodix GT9XX Touch Panel. Attach the
* Interrupt Handler for the Touch Panel and disable Touch Interrupts.
*
* Input Parameters:
* devpath - Device Path (e.g. "/dev/input0")
* dev - I2C Bus
* i2c_devaddr - I2C Address of Touch Panel
* board_config - Callback for Board-Specific Operations
*
* Returned Value:
* Zero (OK) on success; a negated errno value is returned on any failure.
*
****************************************************************************/
int gt9xx_register(FAR const char *devpath,
FAR struct i2c_master_s *dev,
uint8_t i2c_devaddr,
const struct gt9xx_board_s *board_config);
#endif /* __INCLUDE_NUTTX_INPUT_GT9XX_H */