summaryrefslogtreecommitdiff
path: root/drivers/input/touchscreen/touchright.c
blob: 35ba46c6ad2d3f77530da62710d6ffacf72792aa (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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/*
 * Touchright serial touchscreen driver
 *
 * Copyright (c) 2006 Rick Koch <n1gp@hotmail.com>
 *
 * Based on MicroTouch driver (drivers/input/touchscreen/mtouch.c)
 * Copyright (c) 2004 Vojtech Pavlik
 * and Dan Streetman <ddstreet@ieee.org>
 */

/*
 * 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.
 */

#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/input.h>
#include <linux/serio.h>
#include <linux/init.h>

#define DRIVER_DESC	"Touchright serial touchscreen driver"

MODULE_AUTHOR("Rick Koch <n1gp@hotmail.com>");
MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE("GPL");

/*
 * Definitions & global arrays.
 */

#define TR_FORMAT_TOUCH_BIT	0x01
#define TR_FORMAT_STATUS_BYTE	0x40
#define TR_FORMAT_STATUS_MASK	~TR_FORMAT_TOUCH_BIT

#define TR_LENGTH 5

#define TR_MIN_XC 0
#define TR_MAX_XC 0x1ff
#define TR_MIN_YC 0
#define TR_MAX_YC 0x1ff

/*
 * Per-touchscreen data.
 */

struct tr {
	struct input_dev *dev;
	struct serio *serio;
	int idx;
	unsigned char data[TR_LENGTH];
	char phys[32];
};

static irqreturn_t tr_interrupt(struct serio *serio,
		unsigned char data, unsigned int flags)
{
	struct tr *tr = serio_get_drvdata(serio);
	struct input_dev *dev = tr->dev;

	tr->data[tr->idx] = data;

	if ((tr->data[0] & TR_FORMAT_STATUS_MASK) == TR_FORMAT_STATUS_BYTE) {
		if (++tr->idx == TR_LENGTH) {
			input_report_abs(dev, ABS_X,
				(tr->data[1] << 5) | (tr->data[2] >> 1));
			input_report_abs(dev, ABS_Y,
				(tr->data[3] << 5) | (tr->data[4] >> 1));
			input_report_key(dev, BTN_TOUCH,
				tr->data[0] & TR_FORMAT_TOUCH_BIT);
			input_sync(dev);
			tr->idx = 0;
		}
	}

	return IRQ_HANDLED;
}

/*
 * tr_disconnect() is the opposite of tr_connect()
 */

static void tr_disconnect(struct serio *serio)
{
	struct tr *tr = serio_get_drvdata(serio);

	input_get_device(tr->dev);
	input_unregister_device(tr->dev);
	serio_close(serio);
	serio_set_drvdata(serio, NULL);
	input_put_device(tr->dev);
	kfree(tr);
}

/*
 * tr_connect() is the routine that is called when someone adds a
 * new serio device that supports the Touchright protocol and registers it as
 * an input device.
 */

static int tr_connect(struct serio *serio, struct serio_driver *drv)
{
	struct tr *tr;
	struct input_dev *input_dev;
	int err;

	tr = kzalloc(sizeof(struct tr), GFP_KERNEL);
	input_dev = input_allocate_device();
	if (!tr || !input_dev) {
		err = -ENOMEM;
		goto fail1;
	}

	tr->serio = serio;
	tr->dev = input_dev;
	snprintf(tr->phys, sizeof(tr->phys), "%s/input0", serio->phys);

	input_dev->private = tr;
	input_dev->name = "Touchright Serial TouchScreen";
	input_dev->phys = tr->phys;
	input_dev->id.bustype = BUS_RS232;
	input_dev->id.vendor = SERIO_TOUCHRIGHT;
	input_dev->id.product = 0;
	input_dev->id.version = 0x0100;
	input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
	input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
	input_set_abs_params(tr->dev, ABS_X, TR_MIN_XC, TR_MAX_XC, 0, 0);
	input_set_abs_params(tr->dev, ABS_Y, TR_MIN_YC, TR_MAX_YC, 0, 0);

	serio_set_drvdata(serio, tr);

	err = serio_open(serio, drv);
	if (err)
		goto fail2;

	err = input_register_device(tr->dev);
	if (err)
		goto fail3;

	return 0;

 fail3:	serio_close(serio);
 fail2:	serio_set_drvdata(serio, NULL);
 fail1:	input_free_device(input_dev);
	kfree(tr);
	return err;
}

/*
 * The serio driver structure.
 */

static struct serio_device_id tr_serio_ids[] = {
	{
		.type	= SERIO_RS232,
		.proto	= SERIO_TOUCHRIGHT,
		.id	= SERIO_ANY,
		.extra	= SERIO_ANY,
	},
	{ 0 }
};

MODULE_DEVICE_TABLE(serio, tr_serio_ids);

static struct serio_driver tr_drv = {
	.driver		= {
		.name	= "touchright",
	},
	.description	= DRIVER_DESC,
	.id_table	= tr_serio_ids,
	.interrupt	= tr_interrupt,
	.connect	= tr_connect,
	.disconnect	= tr_disconnect,
};

/*
 * The functions for inserting/removing us as a module.
 */

static int __init tr_init(void)
{
	return serio_register_driver(&tr_drv);
}

static void __exit tr_exit(void)
{
	serio_unregister_driver(&tr_drv);
}

module_init(tr_init);
module_exit(tr_exit);
ice-6-3-0 Unnamed repository; edit this file to name it for gitweb.root
summaryrefslogtreecommitdiff
AgeCommit message (Expand)AuthorFilesLines
2018-08-06ja translation of 'No Fill'cp-5.3-65cp-5.3-64cp-5.3-63cp-5.3-60cp-5.3-59cp-5.3-58cp-5.3-57cp-5.3-56cp-5.3-55co-5.3-63cd-5.3-61distro/collabora/cp-5.3distro/collabora/cd-5.3-3.4distro/collabora/cd-5.3-3.2Andras Timar1-1/+1
2018-07-30Updated Korean translationAndras Timar3-676/+422
2018-07-30Updated Japanese translationAndras Timar4-44/+33
2018-05-23remove extra ~ characters from German translationcp-5.3-53cp-5.3-52cp-5.3-51cp-5.3-50cp-5.3-49cp-5.3-47Andras Timar1-2/+2
2018-01-12Translation of backported features (from libreoffice-6-0)cp-5.3-66cp-5.3-46cp-5.3-44cp-5.3-43cp-5.3-42cp-5.3-41cp-5.3-40cp-5.3-39cp-5.3-38cp-5.3-37co-5.3-67co-5.3-66co-5.3-65co-5.3-58Andras Timar590-8995/+44502
2018-01-11update translations for 5.3.7 rc2Christian Lohmaier161-2878/+2882
2017-10-04update translations for 5.3.7 rc1libreoffice-5-3Christian Lohmaier218-3515/+2982
2017-08-21another set of translation updated for 5.3.6 rc1Christian Lohmaier26-326/+326
2017-08-16update translations for 5.3.6 rc1Christian Lohmaier161-2079/+2098
2017-07-30update translations for 5.3.5 rc2Christian Lohmaier380-7909/+7869
2017-07-12update translationsChristian Lohmaier2021-135235/+1027494
2017-06-13update translations for 5.3.4 rc2Christian Lohmaier113-3120/+2580
2017-06-01update translations for 5.3.4 rc1Christian Lohmaier373-10925/+20113
2017-05-03update translations for 5.3.3 rc2cp-5.3-36cp-5.3-35cp-5.3-33cp-5.3-32cp-5.3-29cp-5.3-28cp-5.3-26cp-5.3-25cp-5.3-24cp-5.3-22cp-5.3-21cp-5.3-19cp-5.3-18cp-5.3-17cp-5.3-15cp-5.3-14cp-5.3-13cp-5.3-12cp-5.3-11cd-5.3-23Christian Lohmaier224-2037/+2207
2017-04-18update templates for 5.3.3 rc1cp-5.3-9cp-5.3-8-wincp-5.3-8cp-5.3-7cp-5.3-6cp-5.3-10Christian Lohmaier1115-6536/+11101
2017-03-29update translations for 5.3.2 rc2Christian Lohmaier435-7270/+7253
2017-03-16update translations for 5.3.2 rc1Christian Lohmaier250-5537/+5490
2017-03-07update translations for 5.3.1 rc2Christian Lohmaier180-3786/+3755
2017-02-28update translations for 5.3.1 rc2cp-5.3-4cp-5.3-3cp-5.3-2cp-5.3-1Christian Lohmaier449-9305/+9232
2017-02-20update translations for 5.3.1 rc1Christian Lohmaier364-7615/+7592
2017-02-16update translations for 5.3.1 rc1Christian Lohmaier362-6308/+6292
2017-01-26update translations for 5.3.0 rc3Christian Lohmaier1010-24017/+23493
2017-01-18Updated Slovenian translationAndras Timar9-67/+76
2017-01-16update templates for 5.3.0 rc2Christian Lohmaier909-21403/+25423
2017-01-12Updated Slovenian translationAndras Timar23-52/+52
2017-01-10update translations for 5.3.0 rc2Christian Lohmaier2529-213516/+82308
2017-01-07Updated Slovenian translationAndras Timar51-173/+173
2016-12-28Updated Slovenian translationAndras Timar40-879/+699
2016-12-23update translations for 5.3.0 rc1Christian Lohmaier1707-52369/+180379
2016-12-22Update Slovenian translation (notebookbar)Andras Timar5-31/+31
2016-12-20Updated Slovenian translationAndras Timar15-337/+300
2016-12-14Updated Slovenian translationAndras Timar22-383/+575
2016-12-10update translations for 5.3.0 beta2Christian Lohmaier4249-477403/+364911
2016-11-23Branch libreoffice-5-3Christian Lohmaier0-0/+0
2016-11-23update translations for 5.3.0 beta1libreoffice-5-3-branch-pointChristian Lohmaier