cyapa(4), driver for the Cypress APA I2C trackpad

Differential Revision:	https://reviews.freebsd.org/D3068
Reviewed by:	kib, wblock
Approved by:	kib
Relnotes:	yes
This commit is contained in:
Michael Gmelin 2015-07-25 18:14:35 +00:00
parent 371583f6ca
commit 46f07718f7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=285876
6 changed files with 2040 additions and 1 deletions

View File

@ -107,6 +107,7 @@ MAN= aac.4 \
cxgb.4 \
cxgbe.4 \
cy.4 \
cyapa.4 \
da.4 \
dc.4 \
dcons.4 \

200
share/man/man4/cyapa.4 Normal file
View File

@ -0,0 +1,200 @@
.\" Copyright (c) 2015 Michael Gmelin <freebsd@grem.de>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD$
.\"
.Dd July 25, 2015
.Dt CYAPA 4
.Os
.Sh NAME
.Nm cyapa
.Nd Cypress APA trackpad with I2C interface driver
.Sh SYNOPSIS
To compile this driver into the kernel, place the following lines into
the kernel configuration file:
.Bd -ragged -offset indent
.Cd "device cyapa"
.Cd "device ig4"
.Cd "device smbus"
.Ed
.Pp
Alternatively, to load the driver as a module at boot time, place the following line in
.Xr loader.conf 5 :
.Bd -literal -offset indent
cyapa_load="YES"
ig4_load="YES"
.Ed
.Sh DESCRIPTION
The
.Nm
driver provides support for the Cypress APA trackpad.
It emulates the IntelliMouse PS/2 protocol.
It supports basic mouse ioctls, so that
.Xr moused 8
is supported properly.
.Ss Trackpad layout
.Bd -literal
2/3 1/3
+--------------------+------------+
| | Middle |
| | Button |
| Left | |
| Button +------------+
| | Right |
| | Button |
+--------------------+............|
| Thumb/Button Area | 15%
+---------------------------------+
.Ed
.Ss Trackpad features
.Bl -tag -width 8n
.It Va Two finger scrolling
Use two fingers for Z axis scrolling.
.It Va Button down/second finger
While one finger clicks and holds down the touchpad, the second finger can be
used to move the mouse cursor.
This can be useful for drawing or selecting text.
.It Va Thumb/Button area
The lower 15% of the trackpad will not affect the mouse cursor position.
This allows for high precision clicking, by controlling the cursor with the
index finger and pushing/holding the pad down with the thumb.
.It Va Trackpad button
Push physical button.
The left two thirds of the pad issues a LEFT button event.
The upper right corner issues a MIDDLE button event.
The lower right corner issues a RIGHT button.
Optionally, tap to click can be enabled (see below).
.El
.Sh SYSCTL VARIABLES
These
.Xr sysctl 8
variables are available:
.Bl -tag -width 8n
.It Va debug.cyapa_idle_freq
Scan frequency in idle mode, the default is 1.
.It Va debug.cyapa_slow_freq
Scan frequency in slow mode, the default is 20.
.It Va debug.cyapa_norm_freq
Scan frequency in normal mode, the default is 100.
.It Va debug.cyapa_minpressure
Minimum pressure to detect a finger, the default is 12.
.It Va debug.cyapa_enable_tapclick
Controls tap to click.
Possible values:
.Bl -tag -width 8n
.It 0
Tap to click is disabled.
This is the default value.
.It 1
Tap to click always generates a left mouse button event.
.It 2
Tap to click generates left mouse button event if the left 2/3rds of the pad
are tapped and a right mouse button event otherwise.
.It 3
Tap to click generates mouse button events as if the physical button was
pressed (see
.Sx DESCRIPTION
above).
.El
.It Va debug.cyapa_tapclick_min_ticks
Minimum tap duration in ticks to create a click, the default is 1.
.It Va debug.cyapa_tapclick_max_ticks
Maximum tap duration in ticks to create a click, the default is 8.
.It Va debug.cyapa_move_min_ticks
Minimum ticks before cursor movement occurs, the default is 4.
.It Va debug.cyapa_scroll_wait_ticks
Ticks to wait before starting to scroll, the default is 0.
.It Va debug.cyapa_scroll_stick_ticks
Ticks while preventing cursor movement on single finger after scroll,
the default is 15.
.It Va debug.cyapa_thumbarea_percent
Size of bottom thumb area in percent, the default is 15.
.It Va debug.cyapa_debug
Setting this to a non-zero value enables debug output to console and syslog,
the default is 0.
.It Va debug.cyapa_reset
Setting this to a non-zero value reinitializes the device.
The sysctl resets to zero immediately.
.El
.Sh FILES
.Nm
creates
.Pa /dev/cyapa0 ,
which presents the mouse as an
.Ar IntelliMouse PS/2
device.
It supports
.Xr moused 8
levels 0 through 2, level 1 is used by default.
.Sh EXAMPLES
To use
.Nm
with
.Xr moused 8 ,
add the following lines to the
.Xr rc.conf 5
file:
.Pp
.Dl moused_enable="YES"
.Dl moused_port="/dev/cyapa0"
.Pp
If vertical scrolling is not desired, add
.Pp
.Dl moused_flags="-l0"
.Pp
to
.Xr rc.conf 5 .
.Pp
Enable tap to click for the left and the right mouse button and
disable the thumb area by adding these lines to the
.Xr sysctl.conf 5
file:
.Pp
.Dl debug.cyapa_thumbarea_percent=0
.Dl debug.cyapa_enable_tapclick=2
.Sh SEE ALSO
.Xr ig4 4 ,
.Xr moused 4 ,
.Xr smbus 4 ,
.Xr sysmouse 4
.Sh AUTHORS
.An -nosplit
The original
.Nm
driver was written for DragonFly BSD by
.An Matthew Dillon .
.Pp
It has been ported, modified, and enhanced for
.Fx
by
.An Michael Gmelin Aq Mt freebsd@grem.de .
.Pp
This manual page was written by
.An Michael Gmelin Aq Mt freebsd@grem.de .
.Sh BUGS
The
.Nm
driver detects the device based on its I2C address (0x67).
This might have unforeseen consequences if the initialization sequence
is sent to an unknown device at that address.

1707
sys/dev/cyapa/cyapa.c Normal file

File diff suppressed because it is too large Load Diff

124
sys/dev/cyapa/cyapa.h Normal file
View File

@ -0,0 +1,124 @@
/*
* Copyright (c) 2014 The DragonFly Project. All rights reserved.
*
* This code is derived from software contributed to The DragonFly Project
* by Matthew Dillon <dillon@backplane.com> and was subsequently ported
* to FreeBSD by Michael Gmelin <freebsd@grem.de>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of The DragonFly Project nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific, prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _SYS_DEV_SMBUS_CYAPA_CYAPA_H_
#define _SYS_DEV_SMBUS_CYAPA_CYAPA_H_
#define CYAPA_MAX_MT 5
/*
* Boot-time registers. This is the device map
* if (stat & CYAPA_STAT_RUNNING) is 0.
*/
struct cyapa_boot_regs {
uint8_t stat; /* CYAPA_STAT_xxx */
uint8_t boot; /* CYAPA_BOOT_xxx */
uint8_t error;
} __packed;
#define CYAPA_BOOT_BUSY 0x80
#define CYAPA_BOOT_RUNNING 0x10
#define CYAPA_BOOT_DATA_VALID 0x08
#define CYAPA_BOOT_CSUM_VALID 0x01
#define CYAPA_ERROR_INVALID 0x80
#define CYAPA_ERROR_INVALID_KEY 0x40
#define CYAPA_ERROR_BOOTLOADER 0x20
#define CYAPA_ERROR_CMD_CSUM 0x10
#define CYAPA_ERROR_FLASH_PROT 0x08
#define CYAPA_ERROR_FLASH_CSUM 0x04
struct cyapa_regs {
uint8_t stat;
uint8_t fngr;
struct {
uint8_t xy_high; /* 7:4 high 4 bits of x */
uint8_t x_low; /* 3:0 high 4 bits of y */
uint8_t y_low;
uint8_t pressure;
uint8_t id; /* 1-15 incremented each touch */
} touch[CYAPA_MAX_MT];
} __packed;
struct cyapa_cap {
uint8_t prod_ida[5]; /* 0x00 - 0x04 */
uint8_t prod_idb[6]; /* 0x05 - 0x0A */
uint8_t prod_idc[2]; /* 0x0B - 0x0C */
uint8_t reserved[6]; /* 0x0D - 0x12 */
uint8_t buttons; /* 0x13 */
uint8_t gen; /* 0x14, low 4 bits */
uint8_t max_abs_xy_high;/* 0x15 7:4 high x bits, 3:0 high y bits */
uint8_t max_abs_x_low; /* 0x16 */
uint8_t max_abs_y_low; /* 0x17 */
uint8_t phy_siz_xy_high;/* 0x18 7:4 high x bits, 3:0 high y bits */
uint8_t phy_siz_x_low; /* 0x19 */
uint8_t phy_siz_y_low; /* 0x1A */
} __packed;
#define CYAPA_STAT_RUNNING 0x80
#define CYAPA_STAT_PWR_MASK 0x0C
#define CYAPA_PWR_OFF 0x00
#define CYAPA_PWR_IDLE 0x08
#define CYAPA_PWR_ACTIVE 0x0C
#define CYAPA_STAT_DEV_MASK 0x03
#define CYAPA_DEV_NORMAL 0x03
#define CYAPA_DEV_BUSY 0x01
#define CYAPA_FNGR_DATA_VALID 0x08
#define CYAPA_FNGR_MIDDLE 0x04
#define CYAPA_FNGR_RIGHT 0x02
#define CYAPA_FNGR_LEFT 0x01
#define CYAPA_FNGR_NUMFINGERS(c) (((c) >> 4) & 0x0F)
#define CYAPA_TOUCH_X(regs, i) ((((regs)->touch[i].xy_high << 4) & 0x0F00) | \
(regs)->touch[i].x_low)
#define CYAPA_TOUCH_Y(regs, i) ((((regs)->touch[i].xy_high << 8) & 0x0F00) | \
(regs)->touch[i].y_low)
#define CYAPA_TOUCH_P(regs, i) ((regs)->touch[i].pressure)
#define CMD_BOOT_STATUS 0x00 /* only if in boot state */
#define CMD_DEV_STATUS 0x00 /* only if in operational state */
#define CMD_SOFT_RESET 0x28
#define CMD_POWER_MODE 0x29
#define CMD_POWER_MODE_OFF 0x00
#define CMD_POWER_MODE_IDLE 0x14
#define CMD_POWER_MODE_FULL 0xFC
#define CMD_QUERY_CAPABILITIES 0x2A
#endif

View File

@ -1,6 +1,6 @@
# $FreeBSD$
SUBDIR =
SUBDIR += controllers if_ic smbus iicbus iicbb iicsmb iic smb
SUBDIR += controllers if_ic smbus iicbus iicbb iicsmb iic cyapa smb
.include <bsd.subdir.mk>

View File

@ -0,0 +1,7 @@
# $FreeBSD$
.PATH: ${.CURDIR}/../../../dev/cyapa
KMOD = cyapa
SRCS = cyapa.c device_if.h bus_if.h smbus_if.h vnode_if.h
.include <bsd.kmod.mk>