xref: /haiku/src/add-ons/kernel/bus_managers/ps2/ps2_synaptics.h (revision 49efa33dd091a76d6475d1216dc8c56f606ebb6b)
1f229f567SAxel Dörfler /*
22c494653SAxel Dörfler  * Copyright 2008-2010, Haiku, Inc.
3f229f567SAxel Dörfler  * Distributed under the terms of the MIT License.
4f229f567SAxel Dörfler  *
52c494653SAxel Dörfler  * Authors:
6f229f567SAxel Dörfler  *		Clemens Zeidler (haiku@Clemens-Zeidler.de)
7f229f567SAxel Dörfler  */
834eb485aSAxel Dörfler #ifndef PS2_SYNAPTICS_H
934eb485aSAxel Dörfler #define PS2_SYNAPTICS_H
106849a228SStephan Aßmus 
11f229f567SAxel Dörfler 
126849a228SStephan Aßmus #include <KernelExport.h>
136849a228SStephan Aßmus 
146849a228SStephan Aßmus #include "packet_buffer.h"
15f229f567SAxel Dörfler #include "ps2_service.h"
166849a228SStephan Aßmus 
176849a228SStephan Aßmus 
186849a228SStephan Aßmus #define SYN_TOUCHPAD			0x47
19*49efa33dSPulkoMandy 
20*49efa33dSPulkoMandy // Synaptics modes (values of the "mode" field in synaptics_cookie)
21*49efa33dSPulkoMandy #define SYN_MODE_ABSOLUTE		(1 << 7)
22*49efa33dSPulkoMandy 	// Absolute mode reports the absolute X/Y position of the finger,
23*49efa33dSPulkoMandy 	// instead of relative X/Y movement
24*49efa33dSPulkoMandy 
25*49efa33dSPulkoMandy #define SYN_MODE_W				(1 << 0)
26*49efa33dSPulkoMandy 	// Adds finger width (W) value in addition to absolute X/Y
27*49efa33dSPulkoMandy #define SYN_MODE_EXTENDED_W		(1 << 2)
28*49efa33dSPulkoMandy 	// Supports tracking for multiple fingers
296849a228SStephan Aßmus #define SYN_FOUR_BYTE_CHILD		(1 << 1)
30*49efa33dSPulkoMandy 	// Guest packets size for pass-through device
31*49efa33dSPulkoMandy #define SYN_MODE_SLEEP			(1 << 3)
326849a228SStephan Aßmus 	// Low power sleep mode
33*49efa33dSPulkoMandy #define SYN_MODE_PASSTHROUGH_ACPI			(1 << 4)
34*49efa33dSPulkoMandy #define SYN_MODE_PASSTHROUGH_TRANSPARENT	(1 << 5)
35*49efa33dSPulkoMandy #define SYN_MODE_HIGH_RATE					(1 << 6)
36*49efa33dSPulkoMandy 	// Use 80 packets per second instead of 40
37*49efa33dSPulkoMandy 
386849a228SStephan Aßmus // Synaptics Passthrough port
396849a228SStephan Aßmus #define SYN_CHANGE_MODE			0x14
406849a228SStephan Aßmus #define SYN_PASSTHROUGH_CMD		0x28
416849a228SStephan Aßmus 
426849a228SStephan Aßmus 
43802b6330SStephan Aßmus #define SYNAPTICS_HISTORY_SIZE	256
446849a228SStephan Aßmus 
456849a228SStephan Aßmus // no touchpad / left / right button pressed
46802b6330SStephan Aßmus #define IS_SYN_PT_PACKAGE(val) ((val[0] & 0xFC) == 0x84 \
47802b6330SStephan Aßmus 	&& (val[3] & 0xCC) == 0xc4)
486849a228SStephan Aßmus 
496849a228SStephan Aßmus 
50802b6330SStephan Aßmus typedef struct {
516849a228SStephan Aßmus 	ps2_dev*			dev;
526849a228SStephan Aßmus 
536849a228SStephan Aßmus 	sem_id				synaptics_sem;
54e637ccf5SClemens Zeidler struct packet_buffer*	synaptics_ring_buffer;
556849a228SStephan Aßmus 	size_t				packet_index;
56e637ccf5SClemens Zeidler 	uint8				buffer[PS2_PACKET_SYNAPTICS];
576849a228SStephan Aßmus 	uint8				mode;
586849a228SStephan Aßmus } synaptics_cookie;
596849a228SStephan Aßmus 
606849a228SStephan Aßmus 
6134eb485aSAxel Dörfler status_t synaptics_pass_through_set_packet_size(ps2_dev *dev, uint8 size);
62802b6330SStephan Aßmus status_t passthrough_command(ps2_dev *dev, uint8 cmd, const uint8 *out,
63802b6330SStephan Aßmus 	int out_count, uint8 *in, int in_count, bigtime_t timeout);
646849a228SStephan Aßmus status_t probe_synaptics(ps2_dev *dev);
656849a228SStephan Aßmus 
666849a228SStephan Aßmus status_t synaptics_open(const char *name, uint32 flags, void **_cookie);
676849a228SStephan Aßmus status_t synaptics_close(void *_cookie);
686849a228SStephan Aßmus status_t synaptics_freecookie(void *_cookie);
696849a228SStephan Aßmus status_t synaptics_ioctl(void *_cookie, uint32 op, void *buffer, size_t length);
706849a228SStephan Aßmus 
716849a228SStephan Aßmus int32 synaptics_handle_int(ps2_dev *dev);
726849a228SStephan Aßmus void synaptics_disconnect(ps2_dev *dev);
736849a228SStephan Aßmus 
74e637ccf5SClemens Zeidler extern device_hooks gSynapticsDeviceHooks;
756849a228SStephan Aßmus 
7634eb485aSAxel Dörfler #endif	// PS2_SYNAPTICS_H
77