xref: /haiku/src/add-ons/kernel/bus_managers/ps2/ps2_synaptics.h (revision ac078a5b110045de12089052a685a6a080545db1)
1 /*
2  * Copyright 2008-2010, Haiku, Inc.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Clemens Zeidler (haiku@Clemens-Zeidler.de)
7  */
8 #ifndef PS2_SYNAPTICS_H
9 #define PS2_SYNAPTICS_H
10 
11 
12 #include <KernelExport.h>
13 
14 #include <touchpad_settings.h>
15 
16 #include "movement_maker.h"
17 #include "packet_buffer.h"
18 #include "ps2_service.h"
19 
20 
21 #define SYN_TOUCHPAD			0x47
22 // Synaptics modes
23 #define SYN_ABSOLUTE_MODE		0x80
24 // Absolute plus w mode
25 #define SYN_ABSOLUTE_W_MODE		0x81
26 #define SYN_FOUR_BYTE_CHILD		(1 << 1)
27 // Low power sleep mode
28 #define SYN_SLEEP_MODE			0x0C
29 // Synaptics Passthrough port
30 #define SYN_CHANGE_MODE			0x14
31 #define SYN_PASSTHROUGH_CMD		0x28
32 
33 
34 #define SYNAPTICS_HISTORY_SIZE	256
35 
36 // no touchpad / left / right button pressed
37 #define IS_SYN_PT_PACKAGE(val) ((val[0] & 0xFC) == 0x84 \
38 	&& (val[3] & 0xCC) == 0xc4)
39 
40 
41 typedef struct {
42 	uint8 majorVersion;
43 	uint8 minorVersion;
44 
45 	bool capExtended;
46 	bool capSleep;
47 	bool capFourButtons;
48 	bool capMultiFinger;
49 	bool capPalmDetection;
50 	bool capPassThrough;
51 } touchpad_info;
52 
53 
54 typedef struct {
55 	ps2_dev*			dev;
56 
57 	sem_id				synaptics_sem;
58 struct packet_buffer*	synaptics_ring_buffer;
59 	size_t				packet_index;
60 	uint8				buffer[PS2_PACKET_SYNAPTICS];
61 	uint8				mode;
62 
63 	TouchpadMovement	movementMaker;
64 
65 	touchpad_settings	settings;
66 } synaptics_cookie;
67 
68 
69 status_t synaptics_pass_through_set_packet_size(ps2_dev *dev, uint8 size);
70 status_t passthrough_command(ps2_dev *dev, uint8 cmd, const uint8 *out,
71 	int out_count, uint8 *in, int in_count, bigtime_t timeout);
72 status_t probe_synaptics(ps2_dev *dev);
73 
74 status_t synaptics_open(const char *name, uint32 flags, void **_cookie);
75 status_t synaptics_close(void *_cookie);
76 status_t synaptics_freecookie(void *_cookie);
77 status_t synaptics_ioctl(void *_cookie, uint32 op, void *buffer, size_t length);
78 
79 int32 synaptics_handle_int(ps2_dev *dev);
80 void synaptics_disconnect(ps2_dev *dev);
81 
82 extern device_hooks gSynapticsDeviceHooks;
83 
84 #endif	// PS2_SYNAPTICS_H
85