linux/drivers/hid/usbhid/hid-pidff.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 *  Force feedback driver for USB HID PID compliant devices
 *
 *  Copyright (c) 2005, 2006 Anssi Hannula <[email protected]>
 */

/*
 */

/* #define DEBUG */

#define pr_fmt(fmt)

#include <linux/input.h>
#include <linux/slab.h>
#include <linux/usb.h>

#include <linux/hid.h>

#include "usbhid.h"

#define PID_EFFECTS_MAX

/* Report usage table used to put reports into an array */

#define PID_SET_EFFECT
#define PID_EFFECT_OPERATION
#define PID_DEVICE_GAIN
#define PID_POOL
#define PID_BLOCK_LOAD
#define PID_BLOCK_FREE
#define PID_DEVICE_CONTROL
#define PID_CREATE_NEW_EFFECT

#define PID_REQUIRED_REPORTS

#define PID_SET_ENVELOPE
#define PID_SET_CONDITION
#define PID_SET_PERIODIC
#define PID_SET_CONSTANT
#define PID_SET_RAMP
static const u8 pidff_reports[] =;

/* 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

#define PID_DURATION
#define PID_GAIN
#define PID_TRIGGER_BUTTON
#define PID_TRIGGER_REPEAT_INT
#define PID_DIRECTION_ENABLE
#define PID_START_DELAY
static const u8 pidff_set_effect[] =;

#define PID_ATTACK_LEVEL
#define PID_ATTACK_TIME
#define PID_FADE_LEVEL
#define PID_FADE_TIME
static const u8 pidff_set_envelope[] =;

#define PID_PARAM_BLOCK_OFFSET
#define PID_CP_OFFSET
#define PID_POS_COEFFICIENT
#define PID_NEG_COEFFICIENT
#define PID_POS_SATURATION
#define PID_NEG_SATURATION
#define PID_DEAD_BAND
static const u8 pidff_set_condition[] =;

#define PID_MAGNITUDE
#define PID_OFFSET
#define PID_PHASE
#define PID_PERIOD
static const u8 pidff_set_periodic[] =;
static const u8 pidff_set_constant[] =;

#define PID_RAMP_START
#define PID_RAMP_END
static const u8 pidff_set_ramp[] =;

#define PID_RAM_POOL_AVAILABLE
static const u8 pidff_block_load[] =;

#define PID_LOOP_COUNT
static const u8 pidff_effect_operation[] =;

static const u8 pidff_block_free[] =;

#define PID_DEVICE_GAIN_FIELD
static const u8 pidff_device_gain[] =;

#define PID_RAM_POOL_SIZE
#define PID_SIMULTANEOUS_MAX
#define PID_DEVICE_MANAGED_POOL
static const u8 pidff_pool[] =;

/* Special field key tables used to put special field keys into arrays */

#define PID_ENABLE_ACTUATORS
#define PID_RESET
static const u8 pidff_device_control[] =;

#define PID_CONSTANT
#define PID_RAMP
#define PID_SQUARE
#define PID_SINE
#define PID_TRIANGLE
#define PID_SAW_UP
#define PID_SAW_DOWN
#define PID_SPRING
#define PID_DAMPER
#define PID_INERTIA
#define PID_FRICTION
static const u8 pidff_effect_types[] =;

#define PID_BLOCK_LOAD_SUCCESS
#define PID_BLOCK_LOAD_FULL
static const u8 pidff_block_load_status[] =;

#define PID_EFFECT_START
#define PID_EFFECT_STOP
static const u8 pidff_effect_operation_status[] =;

struct pidff_usage {};

struct pidff_device {};

/*
 * Scale an unsigned value with range 0..max for the given field
 */
static int pidff_rescale(int i, int max, struct hid_field *field)
{}

/*
 * Scale a signed value in range -0x8000..0x7fff for the given field
 */
static int pidff_rescale_signed(int i, struct hid_field *field)
{}

static void pidff_set(struct pidff_usage *usage, u16 value)
{}

static void pidff_set_signed(struct pidff_usage *usage, s16 value)
{}

/*
 * Send envelope report to the device
 */
static void pidff_set_envelope_report(struct pidff_device *pidff,
				      struct ff_envelope *envelope)
{}

/*
 * Test if the new envelope differs from old one
 */
static int pidff_needs_set_envelope(struct ff_envelope *envelope,
				    struct ff_envelope *old)
{}

/*
 * Send constant force report to the device
 */
static void pidff_set_constant_force_report(struct pidff_device *pidff,
					    struct ff_effect *effect)
{}

/*
 * Test if the constant parameters have changed between effects
 */
static int pidff_needs_set_constant(struct ff_effect *effect,
				    struct ff_effect *old)
{}

/*
 * Send set effect report to the device
 */
static void pidff_set_effect_report(struct pidff_device *pidff,
				    struct ff_effect *effect)
{}

/*
 * Test if the values used in set_effect have changed
 */
static int pidff_needs_set_effect(struct ff_effect *effect,
				  struct ff_effect *old)
{}

/*
 * Send periodic effect report to the device
 */
static void pidff_set_periodic_report(struct pidff_device *pidff,
				      struct ff_effect *effect)
{}

/*
 * Test if periodic effect parameters have changed
 */
static int pidff_needs_set_periodic(struct ff_effect *effect,
				    struct ff_effect *old)
{}

/*
 * Send condition effect reports to the device
 */
static void pidff_set_condition_report(struct pidff_device *pidff,
				       struct ff_effect *effect)
{}

/*
 * Test if condition effect parameters have changed
 */
static int pidff_needs_set_condition(struct ff_effect *effect,
				     struct ff_effect *old)
{}

/*
 * Send ramp force report to the device
 */
static void pidff_set_ramp_force_report(struct pidff_device *pidff,
					struct ff_effect *effect)
{}

/*
 * Test if ramp force parameters have changed
 */
static int pidff_needs_set_ramp(struct ff_effect *effect, struct ff_effect *old)
{}

/*
 * Send a request for effect upload to the device
 *
 * Returns 0 if device reported success, -ENOSPC if the device reported memory
 * is full. Upon unknown response the function will retry for 60 times, if
 * still unsuccessful -EIO is returned.
 */
static int pidff_request_effect_upload(struct pidff_device *pidff, int efnum)
{}

/*
 * Play the effect with PID id n times
 */
static void pidff_playback_pid(struct pidff_device *pidff, int pid_id, int n)
{}

/*
 * Play the effect with effect id @effect_id for @value times
 */
static int pidff_playback(struct input_dev *dev, int effect_id, int value)
{}

/*
 * Erase effect with PID id
 */
static void pidff_erase_pid(struct pidff_device *pidff, int pid_id)
{}

/*
 * Stop and erase effect with effect_id
 */
static int pidff_erase_effect(struct input_dev *dev, int effect_id)
{}

/*
 * Effect upload handler
 */
static int pidff_upload_effect(struct input_dev *dev, struct ff_effect *effect,
			       struct ff_effect *old)
{}

/*
 * set_gain() handler
 */
static void pidff_set_gain(struct input_dev *dev, u16 gain)
{}

static void pidff_autocenter(struct pidff_device *pidff, u16 magnitude)
{}

/*
 * pidff_set_autocenter() handler
 */
static void pidff_set_autocenter(struct input_dev *dev, u16 magnitude)
{}

/*
 * Find fields from a report and fill a pidff_usage
 */
static int pidff_find_fields(struct pidff_usage *usage, const u8 *table,
			     struct hid_report *report, int count, int strict)
{}

/*
 * Return index into pidff_reports for the given usage
 */
static int pidff_check_usage(int usage)
{}

/*
 * Find the reports and fill pidff->reports[]
 * report_type specifies either OUTPUT or FEATURE reports
 */
static void pidff_find_reports(struct hid_device *hid, int report_type,
			       struct pidff_device *pidff)
{}

/*
 * Test if the required reports have been found
 */
static int pidff_reports_ok(struct pidff_device *pidff)
{}

/*
 * Find a field with a specific usage within a report
 */
static struct hid_field *pidff_find_special_field(struct hid_report *report,
						  int usage, int enforce_min)
{}

/*
 * Fill a pidff->*_id struct table
 */
static int pidff_find_special_keys(int *keys, struct hid_field *fld,
				   const u8 *usagetable, int count)
{}

#define PIDFF_FIND_SPECIAL_KEYS(keys, field, name)

/*
 * Find and check the special fields
 */
static int pidff_find_special_fields(struct pidff_device *pidff)
{}

/*
 * Find the implemented effect types
 */
static int pidff_find_effects(struct pidff_device *pidff,
			      struct input_dev *dev)
{}

#define PIDFF_FIND_FIELDS(name, report, strict)

/*
 * Fill and check the pidff_usages
 */
static int pidff_init_fields(struct pidff_device *pidff, struct input_dev *dev)
{}

/*
 * Reset the device
 */
static void pidff_reset(struct pidff_device *pidff)
{}

/*
 * Test if autocenter modification is using the supported method
 */
static int pidff_check_autocenter(struct pidff_device *pidff,
				  struct input_dev *dev)
{}

/*
 * Check if the device is PID and initialize it
 */
int hid_pidff_init(struct hid_device *hid)
{}