aboutsummaryrefslogtreecommitdiff
path: root/include/linux/input/rmi_platformdata.h
blob: 8c44d4c71b647a98c1ac322dbfb139a3e2189143 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/**
 *
 * Synaptics RMI platform data definitions for use in board files.
 * Copyright (c) 2007 - 2011, Synaptics Incorporated
 *
 */
/*
 * This file is licensed under the GPL2 license.
 *
 *############################################################################
 * GPL
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 as published
 * by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 *
 *############################################################################
 */

#if !defined(_RMI_PLATFORMDATA_H)
#define _RMI_PLATFORMDATA_H

#define RMI_F01_INDEX 0x01
#define RMI_F11_INDEX 0x11
#define RMI_F19_INDEX 0x19
#define RMI_F34_INDEX 0x34


/* A couple of structs that are useful for frequently occuring constructs,such
 * as coordinate origin offsets or coordinate clipping values.
 */
struct rmi_XY_pair {
	int x;
	int y;
};

struct rmi_range {
	int min;
	int max;
};

/* This contains sensor specific data that is not specialized to I2C or SPI.
 */
struct rmi_sensordata {
	/* This will be called from rmi_register_sensor(). You can use it
	 * to set up gpios, IRQs, and other platform specific infrastructure.
	 */
	int (*rmi_sensor_setup)(void);

	/* This will be called when the sensor is unloaded.  Use this to
	 * release gpios, IRQs, and other platform specific infrastructure.
	 */
	void (*rmi_sensor_teardown)(void);

	/* Use this to specify non-default settings on a per function basis.
	 */
	struct rmi_functiondata_list *perfunctiondata;
};

/* This contains the per-function customization for a given function.We store
 * the data this way in order to avoid allocating a large sparse array
 * typically
 * only a few functions are present on a sensor, and even fewer will be have
 * custom settings.  There is a very small penalty paid for doing a linear
 * search through the list to find a given function's data, but since the list
 * is typically very short and is searched only at system boot time, this is
 * considered acceptable.
 *
 * When adding new fields to a functiondata struct, please follow these rules:
 *     - Where possible, use 0 to indicate that the value should be defaulted.
 *       This works pretty well for bools, ints, and chars.
 *     - Where this is not practical (for example, in coordinate offsets or
 *       range clipping), use a pointer.  Set that pointer to null to indicate
 *       that the value should be defaulted.
 */
struct rmi_functiondata {
	unsigned char	function_index;
	void		*data;
};

/* This can be included in the platformdata for SPI or I2C RMI4 devices to
 * customize the settings of the functions on a given sensor.
 */
struct rmi_functiondata_list {
	unsigned char	count;	/* Number of elements in the array */
	struct		rmi_functiondata *functiondata;
};

struct rmi_f01_functiondata {
	/* What this does is product specific.  For most, but not all, RMI4
	 * devices, you can set this to true in order to request the device
	 * report data at half the usual rate.  This can be useful on slow
	 * CPUs that don't have the resources to process data at the usual
	 * rate.  However, the meaning of this field is product specific, and
	 * you should consult the product spec for your sensor to find out
	 * what this will do.
	 */
	bool	nonstandard_report_rate;
};

struct rmi_f11_functiondata {
	bool		swap_axes;
	bool		flipX;
	bool		flipY;
	int		button_height;
	struct		rmi_XY_pair *offset;
	struct		rmi_range *clipX;
	struct		rmi_range *clipY;
};

struct rmi_button_map {
	unsigned char nbuttons;
	unsigned char *map;
};

struct rmi_f19_functiondata {
	struct rmi_button_map *button_map;
};

#endif