#include <linux/module.h>
#include <linux/input.h>
#include <linux/input/mt.h>
#include <linux/ctype.h>
#include <linux/libps2.h>
#include <linux/serio.h>
#include <linux/jiffies.h>
#include <linux/slab.h>
#include "psmouse.h"
#include "sentelic.h"
#define FSP_CMD_TIMEOUT …
#define FSP_CMD_TIMEOUT2 …
#define GET_ABS_X(packet) …
#define GET_ABS_Y(packet) …
static const char fsp_drv_ver[] = …;
static unsigned char fsp_test_swap_cmd(unsigned char reg_val)
{ … }
static unsigned char fsp_test_invert_cmd(unsigned char reg_val)
{ … }
static int fsp_reg_read(struct psmouse *psmouse, int reg_addr, int *reg_val)
{ … }
static int fsp_reg_write(struct psmouse *psmouse, int reg_addr, int reg_val)
{ … }
static int fsp_reg_write_enable(struct psmouse *psmouse, bool enable)
{ … }
static int fsp_page_reg_read(struct psmouse *psmouse, int *reg_val)
{ … }
static int fsp_page_reg_write(struct psmouse *psmouse, int reg_val)
{ … }
static int fsp_get_version(struct psmouse *psmouse, int *version)
{ … }
static int fsp_get_revision(struct psmouse *psmouse, int *rev)
{ … }
static int fsp_get_sn(struct psmouse *psmouse, int *sn)
{ … }
static int fsp_get_buttons(struct psmouse *psmouse, int *btn)
{ … }
static int fsp_opc_tag_enable(struct psmouse *psmouse, bool enable)
{ … }
static int fsp_onpad_vscr(struct psmouse *psmouse, bool enable)
{ … }
static int fsp_onpad_hscr(struct psmouse *psmouse, bool enable)
{ … }
static ssize_t fsp_attr_set_setreg(struct psmouse *psmouse, void *data,
const char *buf, size_t count)
{ … }
PSMOUSE_DEFINE_WO_ATTR(…);
static ssize_t fsp_attr_show_getreg(struct psmouse *psmouse,
void *data, char *buf)
{ … }
static ssize_t fsp_attr_set_getreg(struct psmouse *psmouse, void *data,
const char *buf, size_t count)
{ … }
PSMOUSE_DEFINE_ATTR(…);
static ssize_t fsp_attr_show_pagereg(struct psmouse *psmouse,
void *data, char *buf)
{ … }
static ssize_t fsp_attr_set_pagereg(struct psmouse *psmouse, void *data,
const char *buf, size_t count)
{ … }
PSMOUSE_DEFINE_ATTR(…);
static ssize_t fsp_attr_show_vscroll(struct psmouse *psmouse,
void *data, char *buf)
{ … }
static ssize_t fsp_attr_set_vscroll(struct psmouse *psmouse, void *data,
const char *buf, size_t count)
{ … }
PSMOUSE_DEFINE_ATTR(…);
static ssize_t fsp_attr_show_hscroll(struct psmouse *psmouse,
void *data, char *buf)
{ … }
static ssize_t fsp_attr_set_hscroll(struct psmouse *psmouse, void *data,
const char *buf, size_t count)
{ … }
PSMOUSE_DEFINE_ATTR(…);
static ssize_t fsp_attr_show_flags(struct psmouse *psmouse,
void *data, char *buf)
{ … }
static ssize_t fsp_attr_set_flags(struct psmouse *psmouse, void *data,
const char *buf, size_t count)
{ … }
PSMOUSE_DEFINE_ATTR(…);
static ssize_t fsp_attr_show_ver(struct psmouse *psmouse,
void *data, char *buf)
{ … }
PSMOUSE_DEFINE_RO_ATTR(…);
static struct attribute *fsp_attributes[] = …;
static struct attribute_group fsp_attribute_group = …;
#ifdef FSP_DEBUG
static void fsp_packet_debug(struct psmouse *psmouse, unsigned char packet[])
{
static unsigned int ps2_packet_cnt;
static unsigned int ps2_last_second;
unsigned int jiffies_msec;
const char *packet_type = "UNKNOWN";
unsigned short abs_x = 0, abs_y = 0;
switch (packet[0] >> FSP_PKT_TYPE_SHIFT) {
case FSP_PKT_TYPE_ABS:
packet_type = "Absolute";
abs_x = GET_ABS_X(packet);
abs_y = GET_ABS_Y(packet);
break;
case FSP_PKT_TYPE_NORMAL:
packet_type = "Normal";
break;
case FSP_PKT_TYPE_NOTIFY:
packet_type = "Notify";
break;
case FSP_PKT_TYPE_NORMAL_OPC:
packet_type = "Normal-OPC";
break;
}
ps2_packet_cnt++;
jiffies_msec = jiffies_to_msecs(jiffies);
psmouse_dbg(psmouse,
"%08dms %s packets: %02x, %02x, %02x, %02x; "
"abs_x: %d, abs_y: %d\n",
jiffies_msec, packet_type,
packet[0], packet[1], packet[2], packet[3], abs_x, abs_y);
if (jiffies_msec - ps2_last_second > 1000) {
psmouse_dbg(psmouse, "PS/2 packets/sec = %d\n", ps2_packet_cnt);
ps2_packet_cnt = 0;
ps2_last_second = jiffies_msec;
}
}
#else
static void fsp_packet_debug(struct psmouse *psmouse, unsigned char packet[])
{ … }
#endif
static void fsp_set_slot(struct input_dev *dev, int slot, bool active,
unsigned int x, unsigned int y)
{ … }
static psmouse_ret_t fsp_process_byte(struct psmouse *psmouse)
{ … }
static int fsp_activate_protocol(struct psmouse *psmouse)
{ … }
static int fsp_set_input_params(struct psmouse *psmouse)
{ … }
int fsp_detect(struct psmouse *psmouse, bool set_properties)
{ … }
static void fsp_reset(struct psmouse *psmouse)
{ … }
static void fsp_disconnect(struct psmouse *psmouse)
{ … }
static int fsp_reconnect(struct psmouse *psmouse)
{ … }
int fsp_init(struct psmouse *psmouse)
{ … }