接口设计
Driver 层接口设计
以下接口是 Touch 设备驱动框架的标准接口。
struct rt_touch_ops { rt_size_t (*touch_readpoint)(struct rt_touch_device *touch, void *buf, rt_size_t touch_num); rt_err_t (*touch_control)(struct rt_touch_device *touch, int cmd, void *arg); };
函数原型 | rt_size_t drv_rtp_read_point(struct rt_touch_device *touch, void *buf, rt_size_t touch_num) |
---|---|
功能说明 | 打开 RTP 设备,驱动会使能 RTP 控制器 |
参数定义 | touch - 指向 Touch 设备 buf - 用于保存返回的坐标事件信息,struct rt_touch_data 类型 num - 要读取的坐标个数,目前 固定为 1 |
返回值 | 1,成功读取到一个坐标事件; 0,失败 |
注意事项 | - |
函数原型 | rt_err_t drv_rtp_control(struct rt_touch_device *touch, int cmd, void *arg) |
---|---|
功能说明 | RTP 驱动的 ioctl 接口 |
参数定义 | touch - 指向 Touch 设备 cmd - ioctl 命令码 ioctl 命令相应的参数 |
返回值 | 0,成功;<0,失败 |
注意事项 | 目前仅支持 RTP 中断的使能和关闭,其他 ioctl 命令将返回-1 |
HAL 层接口设计
HAL 层的函数接口声明存放在 hal_rtp.h
中,主要接口有:
void hal_rtp_status_show(struct aic_rtp_dev *rtp); void hal_rtp_enable(struct aic_rtp_dev *rtp, int en); void hal_rtp_int_enable(struct aic_rtp_dev *rtp, int en); void hal_rtp_auto_mode(struct aic_rtp_dev *rtp); irqreturn_t hal_rtp_isr(int irq, void *arg); u32 hal_rtp_ebuf_read_space(struct aic_rtp_ebuf *ebuf); #define hal_rtp_ebuf_write_space(buf) \ (AIC_RTP_EVT_BUF_SIZE - hal_rtp_ebuf_read_space(buf)) #define hal_rtp_ebuf_full(buf) (hal_rtp_ebuf_write_space(buf) == 0) #define hal_rtp_ebuf_empty(buf) (hal_rtp_ebuf_read_space((buf)) == 0) s32 hal_rtp_ebuf_write(struct aic_rtp_ebuf *ebuf, struct aic_rtp_event *e); s32 hal_rtp_ebuf_read(struct aic_rtp_ebuf *ebuf, struct aic_rtp_event *e);