summaryrefslogtreecommitdiff
path: root/goog_touch_interface.h
diff options
context:
space:
mode:
authorSuper Liu <supercjliu@google.com>2022-02-24 22:35:36 +0800
committerTreeHugger Robot <treehugger-gerrit@google.com>2022-03-29 00:24:58 +0000
commitab64b986c78d3eade2dae94bf75ebca87c7f5982 (patch)
tree5b5ff3afac77872795e6ee9524e54959bcf9d143 /goog_touch_interface.h
parent5ca25762e41470339adcf04d392b7970e43d201f (diff)
downloadcommon-ab64b986c78d3eade2dae94bf75ebca87c7f5982.tar.gz
touch/common: create google touch interface.
Doc: go/gti_1p Bug: 201610482 Signed-off-by: Super Liu <supercjliu@google.com> Change-Id: I3a68d91c69c94095d0da9d3691fef79146e243f4
Diffstat (limited to 'goog_touch_interface.h')
-rw-r--r--goog_touch_interface.h103
1 files changed, 103 insertions, 0 deletions
diff --git a/goog_touch_interface.h b/goog_touch_interface.h
new file mode 100644
index 0000000..4b05397
--- /dev/null
+++ b/goog_touch_interface.h
@@ -0,0 +1,103 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Google Touch Interface for Pixel devices.
+ *
+ * Copyright 2022 Google LLC.
+ */
+
+#ifndef _GOOG_TOUCH_INTERFACE_
+#define _GOOG_TOUCH_INTERFACE_
+
+#include "heatmap.h"
+#include "touch_offload.h"
+#include "uapi/input/touch_offload.h"
+
+#define GOOG_LOG_NAME "GTI"
+#define GOOG_DBG(fmt, args...) pr_debug("[%s] %s: " fmt, GOOG_LOG_NAME,\
+ __func__, ##args)
+#define GOOG_LOG(fmt, args...) pr_info("[%s] %s: " fmt, GOOG_LOG_NAME,\
+ __func__, ##args)
+#define GOOG_ERR(fmt, args...) pr_err("[%s] %s: " fmt, GOOG_LOG_NAME,\
+ __func__, ##args)
+#define MAX_COORDS 10
+
+#define KTIME_RELEASE_ALL (ktime_set(0, 0))
+
+/**
+ * struct goog_touch_interfac - Google touch interface data for Pixel.
+ * @vendor_private_data: the private data pointer that used by touch vendor driver.
+ * @dev: pointer to struct device that used by touch vendor driver.
+ * @input_dev: poiner to struct inpu_dev that used by touch vendor driver.
+ * @input_lock: protect the input report between non-offload and offload.
+ * @offload: struct that used by touch offload.
+ * @offload_frame: reserved frame that used by touch offload.
+ * @v4l2: struct that used by v4l2.
+ * @timestamp: irq timestamp from touch vendor driver.
+ * @force_legacy_report: force to directly report input by kernel input API.
+ * @offload_enable: touch offload is running.
+ * @v4l2_enable: v4l2 is running.
+ * @coord_changed: coords was changed and wait to push frame into touch offload.
+ * @offload_id: id that used by touch offload.
+ * @heatmap_buf: heatmap buffer that used by v4l2.
+ * @heatmap_buf_size: heatmap buffer size that used by v4l2.
+ * @slot: slot id that current used by input report.
+ * @get_channel_data_cb: touch vendor driver function callback to get channel data.
+ */
+
+struct goog_touch_interface {
+ void *vendor_private_data;
+ struct device *dev;
+ struct input_dev *input_dev;
+ struct mutex input_lock;
+ struct touch_offload_context offload;
+ struct touch_offload_frame *offload_frame;
+ struct v4l2_heatmap v4l2;
+ ktime_t timestamp;
+
+ bool force_legacy_report;
+ bool offload_enable;
+ bool v4l2_enable;
+ bool coord_changed;
+ union {
+ u8 offload_id_byte[4];
+ u32 offload_id;
+ };
+ u8 *heatmap_buf;
+ u32 heatmap_buf_size;
+ int slot;
+
+ int (*get_channel_data_cb)(void *vendor_private_data,
+ u32 data_type, u8 **ptr, u32 *size);
+};
+
+
+inline bool goog_input_legacy_report(struct goog_touch_interface *gti);
+inline void goog_input_lock(struct goog_touch_interface *gti);
+inline void goog_input_unlock(struct goog_touch_interface *gti);
+inline void goog_input_set_timestamp(
+ struct goog_touch_interface *gti,
+ struct input_dev *dev, ktime_t timestamp);
+inline void goog_input_mt_slot(
+ struct goog_touch_interface *gti,
+ struct input_dev *dev, int slot);
+inline void goog_input_mt_report_slot_state(
+ struct goog_touch_interface *gti,
+ struct input_dev *dev, unsigned int tool_type, bool active);
+inline void goog_input_report_abs(
+ struct goog_touch_interface *gti,
+ struct input_dev *dev, unsigned int code, int value);
+inline void goog_input_report_key(
+ struct goog_touch_interface *gti,
+ struct input_dev *dev, unsigned int code, int value);
+inline void goog_input_sync(struct goog_touch_interface *gti, struct input_dev *dev);
+
+int goog_input_process(struct goog_touch_interface *gti);
+struct goog_touch_interface *goog_touch_interface_probe(
+ void *vendor_private_data,
+ struct device *dev,
+ struct input_dev *input_dev,
+ int (*get_data_cb)(void *, u32, u8 **, u32 *));
+int goog_touch_interface_remove(struct goog_touch_interface *gti);
+
+#endif // _GOOG_TOUCH_INTERFACE_
+