/*
* Apple USB Touchpad (for post-February 2005 PowerBooks and MacBooks) driver
*
* Copyright (C) 2001-2004 Greg Kroah-Hartman (greg@kroah.com)
* Copyright (C) 2005-2008 Johannes Berg (johannes@sipsolutions.net)
* Copyright (C) 2005-2008 Stelian Pop (stelian@popies.net)
* Copyright (C) 2005 Frank Arnold (frank@scirocco-5v-turbo.de)
* Copyright (C) 2005 Peter Osterlund (petero2@telia.com)
* Copyright (C) 2005 Michael Hanselmann (linux-kernel@hansmi.ch)
* Copyright (C) 2006 Nicolas Boichat (nicolas@boichat.ch)
* Copyright (C) 2007-2008 Sven Anders (anders@anduras.de)
*
* Thanks to Alex Harper <basilisk@foobox.net> for his inputs.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/usb/input.h>
/*
* Note: We try to keep the touchpad aspect ratio while still doing only
* simple arithmetics:
* 0 <= x <= (xsensors - 1) * xfact
* 0 <= y <= (ysensors - 1) * yfact
*/
struct atp_info {
int xsensors; /* number of X sensors */
int xsensors_17; /* 17" models have more sensors */
int ysensors; /* number of Y sensors */
int xfact; /* X multiplication factor */
int yfact; /* Y multiplication factor */
int datalen; /* size of USB transfers */
void (*callback)(struct urb *); /* callback function */
int fuzz; /* fuzz touchpad generates */
};
static void atp_complete_geyser_1_2(struct urb *urb);
static void atp_complete_geyser_3_4(struct urb *urb);
static const struct atp_info fountain_info = {
.xsensors = 16,
.xsensors_17 = 26,
.ysensors = 16,
.xfact = 64,
.yfact = 43,
.datalen = 81,
.callback = atp_complete_geyser_1_2,
.fuzz = 16,
};
static const struct atp_info geyser1_info = {
.xsensors = 16,
.xsensors_17 = 26,
.ysensors = 16,
.xfact = 64,
.yfact = 43,
.datalen = 81,
.callback = atp_complete_geyser_1_2,
.fuzz = 16,
};
static const struct atp_info geyser2_info = {
.xsensors = 15,
.xsensors_17 = 20,
.ysensors = 9,
.xfact = 64,
.yfact = 43,
.datalen = 64,
.callback = atp_complete_geyser_1_2,
.fuzz = 0,
};
static const struct atp_info geyser3_info = {
.xsensors = 20,
.ysensors = 10,
.xfact = 64,
.yfact = 64,
.datalen = 64,
.callback = atp_complete_geyser_3_4,
.fuzz = 0,
};
static const struct atp_info geyser4_info = {
.xsensors = 20,
.ysensors = 10,
.xfact = 64,
.yfact = 64,
.datalen = 64,
.callback = atp_complete_geyser_3_4,
.fuzz = 0,
};
#define ATP_DEVICE(prod, info) \
{ \
.match_flags = USB_DEVICE_ID_MATCH_DEVICE | \
USB_DEVICE_ID_MATCH_INT_CLASS | \
USB_DEVICE_ID_MATCH_INT_PROTOCOL, \
.idVendor = 0x05ac, /* Apple */ \
.idProduct = (prod), \
.bInterfaceClass = 0x03, \
.bInterfaceProtocol = 0x02, \
.driver_info = (unsigned long) &info, \
}
/*
* Table of devices (Product IDs) that work with this driver.
* (The names come from Info.plist in AppleUSBTrackpad.kext,
* According to Info.plist Geyser IV is the same as Geyser III.)
*/
static struct usb_device_id atp_table[] = {
/* PowerBooks Feb 2005, iBooks G4 */
ATP_DEVICE(0x020e, fountain_info), /* FOUNTAIN ANSI */
ATP_DEVICE(0x020f, fountain_info), /* FOUNTAIN ISO */
ATP_DEVICE(0x030a, fountain_info), /* FOUNTAIN TP ONLY */
ATP_DEVICE(0x030b, geyser1_info), /* GEYSER 1 TP ONLY */
/* PowerBooks Oct 2005 */
ATP_DEVICE(0x0214, geyser2_info), /* GEYSER 2 ANSI */
ATP_DEVICE(0x0215, geyser2_info), /* GEYSER 2 ISO */
ATP_DEVICE(0x0216, geyser2_info), /* GEYSER 2 JIS */
/* Core Duo MacBook & MacBook Pro */
ATP_DEVICE(0x0217, geyser3_info), /* GEYSER 3 ANSI */
ATP_DEVICE(0x0218, geyser3_info), /* GEYSER 3 ISO */
ATP_DEVICE(0x0219, geyser3_info), /* GEYSER 3 JIS */
/* Core2 Duo MacBook & MacBook Pro */
ATP_DEVICE(0x021a, geyser4_info), /* GEYSER 4 ANSI */
ATP_DEVICE(0x021b, geyser4_info), /* GEYSER 4 ISO */
ATP_DEVICE(0x021c, geyser4_info), /* GEYSER 4 JIS */
/* Core2 Duo MacBook3,1 */
ATP_DEVICE(0x0229, geyser4_info), /* GEYSER 4 HF ANSI */
ATP_DEVICE(0x022a, geyser4_info), /* GEYSER 4 HF ISO */
ATP_DEVICE(0x022b, geyser4_info), /* GEYSER 4 HF JIS */
/* Terminating entry */
{ }