/*
* Force feedback driver for USB HID PID compliant devices
*
* Copyright (c) 2005, 2006 Anssi Hannula <anssi.hannula@gmail.com>
*/
/*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* #define DEBUG */
#define debug(format, arg...) pr_debug("hid-pidff: " format "\n" , ## arg)
#include <linux/input.h>
#include <linux/slab.h>
#include <linux/usb.h>
#include <linux/hid.h>
#include "usbhid.h"
#define PID_EFFECTS_MAX 64
/* Report usage table used to put reports into an array */
#define PID_SET_EFFECT 0
#define PID_EFFECT_OPERATION 1
#define PID_DEVICE_GAIN 2
#define PID_POOL 3
#define PID_BLOCK_LOAD 4
#define PID_BLOCK_FREE 5
#define PID_DEVICE_CONTROL 6
#define PID_CREATE_NEW_EFFECT 7
#define PID_REQUIRED_REPORTS 7
#define PID_SET_ENVELOPE 8
#define PID_SET_CONDITION 9
#define PID_SET_PERIODIC 10
#define PID_SET_CONSTANT 11
#define PID_SET_RAMP 12
static const u8 pidff_reports[] = {
0x21, 0x77, 0x7d, 0x7f, 0x89, 0x90, 0x96, 0xab,
0x5a, 0x5f, 0x6e, 0x73, 0x74
};
/* device_control is really 0x95, but 0x96 specified as it is the usage of
the only field in that report */
/* Value usage tables used to put fields and values into arrays */
#define PID_EFFECT_BLOCK_INDEX 0
#define PID_DURATION 1
#define PID_GAIN 2
#define PID_TRIGGER_BUTTON 3
#define PID_TRIGGER_REPEAT_INT 4
#define PID_DIRECTION_ENABLE 5
#define PID_START_DELAY 6
static const u8 pidff_set_effect[] = {
0x22, 0x50, 0x52, 0x53, 0x54, 0x56, 0xa7
};
#define PID_ATTACK_LEVEL 1
#define PID_ATTACK_TIME 2
#define PID_FADE_LEVEL 3
#define PID_FADE_TIME 4
static const u8 pidff_set_envelope[] = { 0x22, 0x5b, 0x5c, 0x5d, 0x5e };
#define PID_PARAM_BLOCK_OFFSET 1
#define PID_CP_OFFSET 2
#define PID_POS_COEFFICIENT 3
#define PID_NEG_COEFFICIENT 4
#define PID_POS_SATURATION 5
#define PID_NEG_SATURATION 6
#define PID_DEAD_BAND 7
static const u8 pidff_set_condition[] = {
0x22, 0x23, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65
};
#define PID_MAGNITUDE 1
#define PID_OFFSET 2
#define PID_PHASE 3
#define PID_PERIOD 4
static const u8 pidff_set_periodic[] = { 0x22, 0x70, 0x6f, 0x71, 0x72 };
static const u8 pidff_set_constant[] = { 0x22, 0x70 };
#define PID_RAMP_START 1
#define PID_RAMP_END 2
static const u8 pidff_set_ramp[] = { 0x22, 0x75, 0x76 };
#define PID_RAM_POOL_AVAILABLE 1
static const u8 pidff_block_load[] = { 0x22, 0xac };
#define PID_LOOP_COUNT 1
static