linux/drivers/input/mouse/alps.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * ALPS touchpad PS/2 mouse driver
 *
 * Copyright (c) 2003 Neil Brown <[email protected]>
 * Copyright (c) 2003-2005 Peter Osterlund <[email protected]>
 * Copyright (c) 2004 Dmitry Torokhov <[email protected]>
 * Copyright (c) 2005 Vojtech Pavlik <[email protected]>
 * Copyright (c) 2009 Sebastian Kapfer <[email protected]>
 *
 * ALPS detection, tap switching and status querying info is taken from
 * tpconfig utility (by C. Scott Ananian and Bruce Kall).
 */

#include <linux/slab.h>
#include <linux/input.h>
#include <linux/input/mt.h>
#include <linux/serio.h>
#include <linux/libps2.h>
#include <linux/dmi.h>

#include "psmouse.h"
#include "alps.h"
#include "trackpoint.h"

/*
 * Definitions for ALPS version 3 and 4 command mode protocol
 */
#define ALPS_CMD_NIBBLE_10

#define ALPS_REG_BASE_RUSHMORE
#define ALPS_REG_BASE_V7
#define ALPS_REG_BASE_PINNACLE

static const struct alps_nibble_commands alps_v3_nibble_commands[] =;

static const struct alps_nibble_commands alps_v4_nibble_commands[] =;

static const struct alps_nibble_commands alps_v6_nibble_commands[] =;


#define ALPS_DUALPOINT
#define ALPS_PASS

#define ALPS_WHEEL
#define ALPS_FW_BK_1
#define ALPS_FW_BK_2
#define ALPS_FOUR_BUTTONS
#define ALPS_PS2_INTERLEAVED
#define ALPS_STICK_BITS
#define ALPS_BUTTONPAD
#define ALPS_DUALPOINT_WITH_PRESSURE

static const struct alps_model_info alps_model_data[] =;

static const struct alps_protocol_info alps_v3_protocol_data =;

static const struct alps_protocol_info alps_v3_rushmore_data =;

static const struct alps_protocol_info alps_v4_protocol_data =;

static const struct alps_protocol_info alps_v5_protocol_data =;

static const struct alps_protocol_info alps_v7_protocol_data =;

static const struct alps_protocol_info alps_v8_protocol_data =;

static const struct alps_protocol_info alps_v9_protocol_data =;

/*
 * Some v2 models report the stick buttons in separate bits
 */
static const struct dmi_system_id alps_dmi_has_separate_stick_buttons[] =;

static void alps_set_abs_params_st(struct alps_data *priv,
				   struct input_dev *dev1);
static void alps_set_abs_params_semi_mt(struct alps_data *priv,
					struct input_dev *dev1);
static void alps_set_abs_params_v7(struct alps_data *priv,
				   struct input_dev *dev1);
static void alps_set_abs_params_ss4_v2(struct alps_data *priv,
				       struct input_dev *dev1);

/* Packet formats are described in Documentation/input/devices/alps.rst */

static bool alps_is_valid_first_byte(struct alps_data *priv,
				     unsigned char data)
{}

static void alps_report_buttons(struct input_dev *dev1, struct input_dev *dev2,
				int left, int right, int middle)
{}

static void alps_process_packet_v1_v2(struct psmouse *psmouse)
{}

static void alps_get_bitmap_points(unsigned int map,
				   struct alps_bitmap_point *low,
				   struct alps_bitmap_point *high,
				   int *fingers)
{}

/*
 * Process bitmap data from semi-mt protocols. Returns the number of
 * fingers detected. A return value of 0 means at least one of the
 * bitmaps was empty.
 *
 * The bitmaps don't have enough data to track fingers, so this function
 * only generates points representing a bounding box of all contacts.
 * These points are returned in fields->mt when the return value
 * is greater than 0.
 */
static int alps_process_bitmap(struct alps_data *priv,
			       struct alps_fields *fields)
{}

static void alps_set_slot(struct input_dev *dev, int slot, int x, int y)
{}

static void alps_report_mt_data(struct psmouse *psmouse, int n)
{}

static void alps_report_semi_mt_data(struct psmouse *psmouse, int fingers)
{}

static void alps_process_trackstick_packet_v3(struct psmouse *psmouse)
{}

static void alps_decode_buttons_v3(struct alps_fields *f, unsigned char *p)
{}

static int alps_decode_pinnacle(struct alps_fields *f, unsigned char *p,
				 struct psmouse *psmouse)
{}

static int alps_decode_rushmore(struct alps_fields *f, unsigned char *p,
				 struct psmouse *psmouse)
{}

static int alps_decode_dolphin(struct alps_fields *f, unsigned char *p,
				struct psmouse *psmouse)
{}

static void alps_process_touchpad_packet_v3_v5(struct psmouse *psmouse)
{}

static void alps_process_packet_v3(struct psmouse *psmouse)
{}

static void alps_process_packet_v6(struct psmouse *psmouse)
{}

static void alps_process_packet_v4(struct psmouse *psmouse)
{}

static bool alps_is_valid_package_v7(struct psmouse *psmouse)
{}

static unsigned char alps_get_packet_id_v7(char *byte)
{}

static void alps_get_finger_coordinate_v7(struct input_mt_pos *mt,
					  unsigned char *pkt,
					  unsigned char pkt_id)
{}

static int alps_get_mt_count(struct input_mt_pos *mt)
{}

static int alps_decode_packet_v7(struct alps_fields *f,
				  unsigned char *p,
				  struct psmouse *psmouse)
{}

static void alps_process_trackstick_packet_v7(struct psmouse *psmouse)
{}

static void alps_process_touchpad_packet_v7(struct psmouse *psmouse)
{}

static void alps_process_packet_v7(struct psmouse *psmouse)
{}

static enum SS4_PACKET_ID alps_get_pkt_id_ss4_v2(unsigned char *byte)
{}

static int alps_decode_ss4_v2(struct alps_fields *f,
			      unsigned char *p, struct psmouse *psmouse)
{}

static void alps_process_packet_ss4_v2(struct psmouse *psmouse)
{}

static bool alps_is_valid_package_ss4_v2(struct psmouse *psmouse)
{}

static DEFINE_MUTEX(alps_mutex);

static int alps_do_register_bare_ps2_mouse(struct alps_data *priv)
{}

static void alps_register_bare_ps2_mouse(struct work_struct *work)
{}

static void alps_report_bare_ps2_packet(struct psmouse *psmouse,
					unsigned char packet[],
					bool report_buttons)
{}

static psmouse_ret_t alps_handle_interleaved_ps2(struct psmouse *psmouse)
{}

static void alps_flush_packet(struct timer_list *t)
{}

static psmouse_ret_t alps_process_byte(struct psmouse *psmouse)
{}

static int alps_command_mode_send_nibble(struct psmouse *psmouse, int nibble)
{}

static int alps_command_mode_set_addr(struct psmouse *psmouse, int addr)
{}

static int __alps_command_mode_read_reg(struct psmouse *psmouse, int addr)
{}

static int alps_command_mode_read_reg(struct psmouse *psmouse, int addr)
{}

static int __alps_command_mode_write_reg(struct psmouse *psmouse, u8 value)
{}

static int alps_command_mode_write_reg(struct psmouse *psmouse, int addr,
				       u8 value)
{}

static int alps_rpt_cmd(struct psmouse *psmouse, int init_command,
			int repeated_command, unsigned char *param)
{}

static bool alps_check_valid_firmware_id(unsigned char id[])
{}

static int alps_enter_command_mode(struct psmouse *psmouse)
{}

static inline int alps_exit_command_mode(struct psmouse *psmouse)
{}

/*
 * For DualPoint devices select the device that should respond to
 * subsequent commands. It looks like glidepad is behind stickpointer,
 * I'd thought it would be other way around...
 */
static int alps_passthrough_mode_v2(struct psmouse *psmouse, bool enable)
{}

static int alps_absolute_mode_v1_v2(struct psmouse *psmouse)
{}

static int alps_monitor_mode_send_word(struct psmouse *psmouse, u16 word)
{}

static int alps_monitor_mode_write_reg(struct psmouse *psmouse,
				       u16 addr, u16 value)
{}

static int alps_monitor_mode(struct psmouse *psmouse, bool enable)
{}

static int alps_absolute_mode_v6(struct psmouse *psmouse)
{}

static int alps_get_status(struct psmouse *psmouse, char *param)
{}

/*
 * Turn touchpad tapping on or off. The sequences are:
 * 0xE9 0xF5 0xF5 0xF3 0x0A to enable,
 * 0xE9 0xF5 0xF5 0xE8 0x00 to disable.
 * My guess that 0xE9 (GetInfo) is here as a sync point.
 * For models that also have stickpointer (DualPoints) its tapping
 * is controlled separately (0xE6 0xE6 0xE6 0xF3 0x14|0x0A) but
 * we don't fiddle with it.
 */
static int alps_tap_mode(struct psmouse *psmouse, int enable)
{}

/*
 * alps_poll() - poll the touchpad for current motion packet.
 * Used in resync.
 */
static int alps_poll(struct psmouse *psmouse)
{}

static int alps_hw_init_v1_v2(struct psmouse *psmouse)
{}

/* Must be in passthrough mode when calling this function */
static int alps_trackstick_enter_extended_mode_v3_v6(struct psmouse *psmouse)
{}

static int alps_hw_init_v6(struct psmouse *psmouse)
{}

/*
 * Enable or disable passthrough mode to the trackstick.
 */
static int alps_passthrough_mode_v3(struct psmouse *psmouse,
				    int reg_base, bool enable)
{}

/* Must be in command mode when calling this function */
static int alps_absolute_mode_v3(struct psmouse *psmouse)
{}

static int alps_probe_trackstick_v3_v7(struct psmouse *psmouse, int reg_base)
{}

static int alps_setup_trackstick_v3(struct psmouse *psmouse, int reg_base)
{}

static int alps_hw_init_v3(struct psmouse *psmouse)
{}

static int alps_get_v3_v7_resolution(struct psmouse *psmouse, int reg_pitch)
{}

static int alps_hw_init_rushmore_v3(struct psmouse *psmouse)
{}

/* Must be in command mode when calling this function */
static int alps_absolute_mode_v4(struct psmouse *psmouse)
{}

static int alps_hw_init_v4(struct psmouse *psmouse)
{}

static int alps_get_otp_values_ss4_v2(struct psmouse *psmouse,
				      unsigned char index, unsigned char otp[])
{}

static int alps_update_device_area_ss4_v2(unsigned char otp[][4],
					  struct alps_data *priv)
{}

static int alps_update_btn_info_ss4_v2(unsigned char otp[][4],
				       struct alps_data *priv)
{}

static int alps_update_dual_info_ss4_v2(unsigned char otp[][4],
					struct alps_data *priv,
					struct psmouse *psmouse)
{}

static int alps_set_defaults_ss4_v2(struct psmouse *psmouse,
				    struct alps_data *priv)
{}

static int alps_dolphin_get_device_area(struct psmouse *psmouse,
					struct alps_data *priv)
{}

static int alps_hw_init_dolphin_v1(struct psmouse *psmouse)
{}

static int alps_hw_init_v7(struct psmouse *psmouse)
{}

static int alps_hw_init_ss4_v2(struct psmouse *psmouse)
{}

static int alps_set_protocol(struct psmouse *psmouse,
			     struct alps_data *priv,
			     const struct alps_protocol_info *protocol)
{}

static const struct alps_protocol_info *alps_match_table(unsigned char *e7,
							 unsigned char *ec)
{}

static bool alps_is_cs19_trackpoint(struct psmouse *psmouse)
{}

static int alps_identify(struct psmouse *psmouse, struct alps_data *priv)
{}

static int alps_reconnect(struct psmouse *psmouse)
{}

static void alps_disconnect(struct psmouse *psmouse)
{}

static void alps_set_abs_params_st(struct alps_data *priv,
				   struct input_dev *dev1)
{}

static void alps_set_abs_params_mt_common(struct alps_data *priv,
					  struct input_dev *dev1)
{}

static void alps_set_abs_params_semi_mt(struct alps_data *priv,
					struct input_dev *dev1)
{}

static void alps_set_abs_params_v7(struct alps_data *priv,
				   struct input_dev *dev1)
{}

static void alps_set_abs_params_ss4_v2(struct alps_data *priv,
				       struct input_dev *dev1)
{}

int alps_init(struct psmouse *psmouse)
{}

int alps_detect(struct psmouse *psmouse, bool set_properties)
{}