version 4.8.7-11
As usual: - updated config for new options - updated patches - dropped patches already included upstream
This commit is contained in:
parent
d85405ec30
commit
40ed9a9f4c
@ -1,161 +0,0 @@
|
||||
From 5137b354bc8a5c04edb10d83f8bdb0bf8896fd68 Mon Sep 17 00:00:00 2001
|
||||
From: Dmitry Torokhov <dtor@chromium.org>
|
||||
Date: Mon, 18 Jan 2016 22:40:37 -0800
|
||||
Subject: [PATCH] HID: fix out of bound access in extract() and implement()
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
extract() and implement() access buffer containing reports in 64-bit
|
||||
chunks, but there is no guarantee that buffers are padded to 64 bit
|
||||
boundary. In fact, KASAN has caught such OOB access with i2c-hid and
|
||||
Synaptics touch controller.
|
||||
|
||||
Instead of trying to hunt all parties that allocate buffers and make
|
||||
sure they are padded, let's switch extract() and implement() to byte
|
||||
access. It is a bit slower, bit we are not dealing with super fast
|
||||
devices here.
|
||||
|
||||
Also let's fix link to the HID spec while we are at it.
|
||||
|
||||
Signed-off-by: Dmitry Torokhov <dtor@chromium.org>
|
||||
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
|
||||
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
|
||||
---
|
||||
drivers/hid/hid-core.c | 90 ++++++++++++++++++++++++++++++++++++--------------
|
||||
1 file changed, 66 insertions(+), 24 deletions(-)
|
||||
|
||||
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
|
||||
index 7e89288..16c2c66 100644
|
||||
--- a/drivers/hid/hid-core.c
|
||||
+++ b/drivers/hid/hid-core.c
|
||||
@@ -1075,7 +1075,7 @@ static u32 s32ton(__s32 value, unsigned n)
|
||||
* Extract/implement a data field from/to a little endian report (bit array).
|
||||
*
|
||||
* Code sort-of follows HID spec:
|
||||
- * http://www.usb.org/developers/devclass_docs/HID1_11.pdf
|
||||
+ * http://www.usb.org/developers/hidpage/HID1_11.pdf
|
||||
*
|
||||
* While the USB HID spec allows unlimited length bit fields in "report
|
||||
* descriptors", most devices never use more than 16 bits.
|
||||
@@ -1083,20 +1083,37 @@ static u32 s32ton(__s32 value, unsigned n)
|
||||
* Search linux-kernel and linux-usb-devel archives for "hid-core extract".
|
||||
*/
|
||||
|
||||
-__u32 hid_field_extract(const struct hid_device *hid, __u8 *report,
|
||||
- unsigned offset, unsigned n)
|
||||
-{
|
||||
- u64 x;
|
||||
+static u32 __extract(u8 *report, unsigned offset, int n)
|
||||
+{
|
||||
+ unsigned int idx = offset / 8;
|
||||
+ unsigned int bit_nr = 0;
|
||||
+ unsigned int bit_shift = offset % 8;
|
||||
+ int bits_to_copy = 8 - bit_shift;
|
||||
+ u32 value = 0;
|
||||
+ u32 mask = n < 32 ? (1U << n) - 1 : ~0U;
|
||||
+
|
||||
+ while (n > 0) {
|
||||
+ value |= ((u32)report[idx] >> bit_shift) << bit_nr;
|
||||
+ n -= bits_to_copy;
|
||||
+ bit_nr += bits_to_copy;
|
||||
+ bits_to_copy = 8;
|
||||
+ bit_shift = 0;
|
||||
+ idx++;
|
||||
+ }
|
||||
+
|
||||
+ return value & mask;
|
||||
+}
|
||||
|
||||
- if (n > 32)
|
||||
+u32 hid_field_extract(const struct hid_device *hid, u8 *report,
|
||||
+ unsigned offset, unsigned n)
|
||||
+{
|
||||
+ if (n > 32) {
|
||||
hid_warn(hid, "hid_field_extract() called with n (%d) > 32! (%s)\n",
|
||||
n, current->comm);
|
||||
+ n = 32;
|
||||
+ }
|
||||
|
||||
- report += offset >> 3; /* adjust byte index */
|
||||
- offset &= 7; /* now only need bit offset into one byte */
|
||||
- x = get_unaligned_le64(report);
|
||||
- x = (x >> offset) & ((1ULL << n) - 1); /* extract bit field */
|
||||
- return (u32) x;
|
||||
+ return __extract(report, offset, n);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(hid_field_extract);
|
||||
|
||||
@@ -1106,31 +1123,56 @@ EXPORT_SYMBOL_GPL(hid_field_extract);
|
||||
* The data mangled in the bit stream remains in little endian
|
||||
* order the whole time. It make more sense to talk about
|
||||
* endianness of register values by considering a register
|
||||
- * a "cached" copy of the little endiad bit stream.
|
||||
+ * a "cached" copy of the little endian bit stream.
|
||||
*/
|
||||
-static void implement(const struct hid_device *hid, __u8 *report,
|
||||
- unsigned offset, unsigned n, __u32 value)
|
||||
+
|
||||
+static void __implement(u8 *report, unsigned offset, int n, u32 value)
|
||||
+{
|
||||
+ unsigned int idx = offset / 8;
|
||||
+ unsigned int size = offset + n;
|
||||
+ unsigned int bit_shift = offset % 8;
|
||||
+ int bits_to_set = 8 - bit_shift;
|
||||
+ u8 bit_mask = 0xff << bit_shift;
|
||||
+
|
||||
+ while (n - bits_to_set >= 0) {
|
||||
+ report[idx] &= ~bit_mask;
|
||||
+ report[idx] |= value << bit_shift;
|
||||
+ value >>= bits_to_set;
|
||||
+ n -= bits_to_set;
|
||||
+ bits_to_set = 8;
|
||||
+ bit_mask = 0xff;
|
||||
+ bit_shift = 0;
|
||||
+ idx++;
|
||||
+ }
|
||||
+
|
||||
+ /* last nibble */
|
||||
+ if (n) {
|
||||
+ if (size % 8)
|
||||
+ bit_mask &= (1U << (size % 8)) - 1;
|
||||
+ report[idx] &= ~bit_mask;
|
||||
+ report[idx] |= (value << bit_shift) & bit_mask;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void implement(const struct hid_device *hid, u8 *report,
|
||||
+ unsigned offset, unsigned n, u32 value)
|
||||
{
|
||||
- u64 x;
|
||||
- u64 m = (1ULL << n) - 1;
|
||||
+ u64 m;
|
||||
|
||||
- if (n > 32)
|
||||
+ if (n > 32) {
|
||||
hid_warn(hid, "%s() called with n (%d) > 32! (%s)\n",
|
||||
__func__, n, current->comm);
|
||||
+ n = 32;
|
||||
+ }
|
||||
|
||||
+ m = (1ULL << n) - 1;
|
||||
if (value > m)
|
||||
hid_warn(hid, "%s() called with too large value %d! (%s)\n",
|
||||
__func__, value, current->comm);
|
||||
WARN_ON(value > m);
|
||||
value &= m;
|
||||
|
||||
- report += offset >> 3;
|
||||
- offset &= 7;
|
||||
-
|
||||
- x = get_unaligned_le64(report);
|
||||
- x &= ~(m << offset);
|
||||
- x |= ((u64)value) << offset;
|
||||
- put_unaligned_le64(x, report);
|
||||
+ __implement(report, offset, n, value);
|
||||
}
|
||||
|
||||
/*
|
||||
--
|
||||
2.5.5
|
||||
|
@ -1,487 +0,0 @@
|
||||
From 98ee377144935857d8ad5d7d70cdab1da4ede32e Mon Sep 17 00:00:00 2001
|
||||
From: Chris Diamand <chris@diamand.org>
|
||||
Date: Wed, 27 Jan 2016 17:04:35 -0800
|
||||
Subject: [PATCH] Input: byd - add BYD PS/2 touchpad driver
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Driver for the BYD BTP10463 touchpad, found in PC Specialist `Lafite'
|
||||
laptops. This patch sends the magic command sequence which causes the
|
||||
touchpad to stream intellimouse-style packets.
|
||||
|
||||
Gestures are detected inside the touchpad, and exposed as special
|
||||
values in the Z component of each packet - absolute coordinates are
|
||||
not supported, even in the Windows driver. At present, this supports
|
||||
two-finger vertical and horizontal scrolling, and provides the
|
||||
framework to expose the other gestures it can recognize.
|
||||
|
||||
Signed-off-by: Chris Diamand <chris@diamand.org>
|
||||
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
|
||||
[backport to 4.4]
|
||||
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
|
||||
---
|
||||
drivers/input/mouse/Kconfig | 10 ++
|
||||
drivers/input/mouse/Makefile | 1 +
|
||||
drivers/input/mouse/byd.c | 337 +++++++++++++++++++++++++++++++++++++
|
||||
drivers/input/mouse/byd.h | 18 ++
|
||||
drivers/input/mouse/psmouse-base.c | 14 ++
|
||||
drivers/input/mouse/psmouse.h | 1 +
|
||||
6 files changed, 381 insertions(+)
|
||||
create mode 100644 drivers/input/mouse/byd.c
|
||||
create mode 100644 drivers/input/mouse/byd.h
|
||||
|
||||
diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig
|
||||
index 17f97e5..096abb4 100644
|
||||
--- a/drivers/input/mouse/Kconfig
|
||||
+++ b/drivers/input/mouse/Kconfig
|
||||
@@ -48,6 +48,16 @@ config MOUSE_PS2_ALPS
|
||||
|
||||
If unsure, say Y.
|
||||
|
||||
+config MOUSE_PS2_BYD
|
||||
+ bool "BYD PS/2 mouse protocol extension" if EXPERT
|
||||
+ default y
|
||||
+ depends on MOUSE_PS2
|
||||
+ help
|
||||
+ Say Y here if you have a BYD PS/2 touchpad connected to
|
||||
+ your system.
|
||||
+
|
||||
+ If unsure, say Y.
|
||||
+
|
||||
config MOUSE_PS2_LOGIPS2PP
|
||||
bool "Logitech PS/2++ mouse protocol extension" if EXPERT
|
||||
default y
|
||||
diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile
|
||||
index ee6a6e9..6168b13 100644
|
||||
--- a/drivers/input/mouse/Makefile
|
||||
+++ b/drivers/input/mouse/Makefile
|
||||
@@ -28,6 +28,7 @@ cyapatp-objs := cyapa.o cyapa_gen3.o cyapa_gen5.o cyapa_gen6.o
|
||||
psmouse-objs := psmouse-base.o synaptics.o focaltech.o
|
||||
|
||||
psmouse-$(CONFIG_MOUSE_PS2_ALPS) += alps.o
|
||||
+psmouse-$(CONFIG_MOUSE_PS2_BYD) += byd.o
|
||||
psmouse-$(CONFIG_MOUSE_PS2_ELANTECH) += elantech.o
|
||||
psmouse-$(CONFIG_MOUSE_PS2_OLPC) += hgpk.o
|
||||
psmouse-$(CONFIG_MOUSE_PS2_LOGIPS2PP) += logips2pp.o
|
||||
diff --git a/drivers/input/mouse/byd.c b/drivers/input/mouse/byd.c
|
||||
new file mode 100644
|
||||
index 0000000..9425e0f
|
||||
--- /dev/null
|
||||
+++ b/drivers/input/mouse/byd.c
|
||||
@@ -0,0 +1,337 @@
|
||||
+/*
|
||||
+ * BYD TouchPad PS/2 mouse driver
|
||||
+ *
|
||||
+ * Copyright (C) 2015 Chris Diamand <chris@diamand.org>
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify it
|
||||
+ * under the terms of the GNU General Public License version 2 as published by
|
||||
+ * the Free Software Foundation.
|
||||
+ */
|
||||
+
|
||||
+#include <linux/delay.h>
|
||||
+#include <linux/input.h>
|
||||
+#include <linux/libps2.h>
|
||||
+#include <linux/serio.h>
|
||||
+
|
||||
+#include "psmouse.h"
|
||||
+#include "byd.h"
|
||||
+
|
||||
+#define PS2_Y_OVERFLOW BIT_MASK(7)
|
||||
+#define PS2_X_OVERFLOW BIT_MASK(6)
|
||||
+#define PS2_Y_SIGN BIT_MASK(5)
|
||||
+#define PS2_X_SIGN BIT_MASK(4)
|
||||
+#define PS2_ALWAYS_1 BIT_MASK(3)
|
||||
+#define PS2_MIDDLE BIT_MASK(2)
|
||||
+#define PS2_RIGHT BIT_MASK(1)
|
||||
+#define PS2_LEFT BIT_MASK(0)
|
||||
+
|
||||
+/*
|
||||
+ * The touchpad reports gestures in the last byte of each packet. It can take
|
||||
+ * any of the following values:
|
||||
+ */
|
||||
+
|
||||
+/* One-finger scrolling in one of the edge scroll zones. */
|
||||
+#define BYD_SCROLLUP 0xCA
|
||||
+#define BYD_SCROLLDOWN 0x36
|
||||
+#define BYD_SCROLLLEFT 0xCB
|
||||
+#define BYD_SCROLLRIGHT 0x35
|
||||
+/* Two-finger scrolling. */
|
||||
+#define BYD_2DOWN 0x2B
|
||||
+#define BYD_2UP 0xD5
|
||||
+#define BYD_2LEFT 0xD6
|
||||
+#define BYD_2RIGHT 0x2A
|
||||
+/* Pinching in or out. */
|
||||
+#define BYD_ZOOMOUT 0xD8
|
||||
+#define BYD_ZOOMIN 0x28
|
||||
+/* Three-finger swipe. */
|
||||
+#define BYD_3UP 0xD3
|
||||
+#define BYD_3DOWN 0x2D
|
||||
+#define BYD_3LEFT 0xD4
|
||||
+#define BYD_3RIGHT 0x2C
|
||||
+/* Four-finger swipe. */
|
||||
+#define BYD_4UP 0xCD
|
||||
+#define BYD_4DOWN 0x33
|
||||
+
|
||||
+int byd_detect(struct psmouse *psmouse, bool set_properties)
|
||||
+{
|
||||
+ struct ps2dev *ps2dev = &psmouse->ps2dev;
|
||||
+ unsigned char param[4];
|
||||
+
|
||||
+ param[0] = 0x03;
|
||||
+ param[1] = 0x00;
|
||||
+ param[2] = 0x00;
|
||||
+ param[3] = 0x00;
|
||||
+
|
||||
+ if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
|
||||
+ return -1;
|
||||
+ if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
|
||||
+ return -1;
|
||||
+ if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
|
||||
+ return -1;
|
||||
+ if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
|
||||
+ return -1;
|
||||
+ if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO))
|
||||
+ return -1;
|
||||
+
|
||||
+ if (param[1] != 0x03 || param[2] != 0x64)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
+ psmouse_dbg(psmouse, "BYD touchpad detected\n");
|
||||
+
|
||||
+ if (set_properties) {
|
||||
+ psmouse->vendor = "BYD";
|
||||
+ psmouse->name = "TouchPad";
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static psmouse_ret_t byd_process_byte(struct psmouse *psmouse)
|
||||
+{
|
||||
+ struct input_dev *dev = psmouse->dev;
|
||||
+ u8 *pkt = psmouse->packet;
|
||||
+
|
||||
+ if (psmouse->pktcnt > 0 && !(pkt[0] & PS2_ALWAYS_1)) {
|
||||
+ psmouse_warn(psmouse, "Always_1 bit not 1. pkt[0] = %02x\n",
|
||||
+ pkt[0]);
|
||||
+ return PSMOUSE_BAD_DATA;
|
||||
+ }
|
||||
+
|
||||
+ if (psmouse->pktcnt < psmouse->pktsize)
|
||||
+ return PSMOUSE_GOOD_DATA;
|
||||
+
|
||||
+ /* Otherwise, a full packet has been received */
|
||||
+ switch (pkt[3]) {
|
||||
+ case 0: {
|
||||
+ /* Standard packet */
|
||||
+ /* Sign-extend if a sign bit is set. */
|
||||
+ unsigned int signx = pkt[0] & PS2_X_SIGN ? ~0xFF : 0;
|
||||
+ unsigned int signy = pkt[0] & PS2_Y_SIGN ? ~0xFF : 0;
|
||||
+ int dx = signx | (int) pkt[1];
|
||||
+ int dy = signy | (int) pkt[2];
|
||||
+
|
||||
+ input_report_rel(psmouse->dev, REL_X, dx);
|
||||
+ input_report_rel(psmouse->dev, REL_Y, -dy);
|
||||
+
|
||||
+ input_report_key(psmouse->dev, BTN_LEFT, pkt[0] & PS2_LEFT);
|
||||
+ input_report_key(psmouse->dev, BTN_RIGHT, pkt[0] & PS2_RIGHT);
|
||||
+ input_report_key(psmouse->dev, BTN_MIDDLE, pkt[0] & PS2_MIDDLE);
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ case BYD_SCROLLDOWN:
|
||||
+ case BYD_2DOWN:
|
||||
+ input_report_rel(dev, REL_WHEEL, -1);
|
||||
+ break;
|
||||
+
|
||||
+ case BYD_SCROLLUP:
|
||||
+ case BYD_2UP:
|
||||
+ input_report_rel(dev, REL_WHEEL, 1);
|
||||
+ break;
|
||||
+
|
||||
+ case BYD_SCROLLLEFT:
|
||||
+ case BYD_2LEFT:
|
||||
+ input_report_rel(dev, REL_HWHEEL, -1);
|
||||
+ break;
|
||||
+
|
||||
+ case BYD_SCROLLRIGHT:
|
||||
+ case BYD_2RIGHT:
|
||||
+ input_report_rel(dev, REL_HWHEEL, 1);
|
||||
+ break;
|
||||
+
|
||||
+ case BYD_ZOOMOUT:
|
||||
+ case BYD_ZOOMIN:
|
||||
+ case BYD_3UP:
|
||||
+ case BYD_3DOWN:
|
||||
+ case BYD_3LEFT:
|
||||
+ case BYD_3RIGHT:
|
||||
+ case BYD_4UP:
|
||||
+ case BYD_4DOWN:
|
||||
+ break;
|
||||
+
|
||||
+ default:
|
||||
+ psmouse_warn(psmouse,
|
||||
+ "Unrecognized Z: pkt = %02x %02x %02x %02x\n",
|
||||
+ psmouse->packet[0], psmouse->packet[1],
|
||||
+ psmouse->packet[2], psmouse->packet[3]);
|
||||
+ return PSMOUSE_BAD_DATA;
|
||||
+ }
|
||||
+
|
||||
+ input_sync(dev);
|
||||
+
|
||||
+ return PSMOUSE_FULL_PACKET;
|
||||
+}
|
||||
+
|
||||
+/* Send a sequence of bytes, where each is ACKed before the next is sent. */
|
||||
+static int byd_send_sequence(struct psmouse *psmouse, const u8 *seq, size_t len)
|
||||
+{
|
||||
+ unsigned int i;
|
||||
+
|
||||
+ for (i = 0; i < len; ++i) {
|
||||
+ if (ps2_command(&psmouse->ps2dev, NULL, seq[i]))
|
||||
+ return -1;
|
||||
+ }
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+/* Keep scrolling after fingers are removed. */
|
||||
+#define SCROLL_INERTIAL 0x01
|
||||
+#define SCROLL_NO_INERTIAL 0x02
|
||||
+
|
||||
+/* Clicking can be done by tapping or pressing. */
|
||||
+#define CLICK_BOTH 0x01
|
||||
+/* Clicking can only be done by pressing. */
|
||||
+#define CLICK_PRESS_ONLY 0x02
|
||||
+
|
||||
+static int byd_enable(struct psmouse *psmouse)
|
||||
+{
|
||||
+ const u8 seq1[] = { 0xE2, 0x00, 0xE0, 0x02, 0xE0 };
|
||||
+ const u8 seq2[] = {
|
||||
+ 0xD3, 0x01,
|
||||
+ 0xD0, 0x00,
|
||||
+ 0xD0, 0x04,
|
||||
+ /* Whether clicking is done by tapping or pressing. */
|
||||
+ 0xD4, CLICK_PRESS_ONLY,
|
||||
+ 0xD5, 0x01,
|
||||
+ 0xD7, 0x03,
|
||||
+ /* Vertical and horizontal one-finger scroll zone inertia. */
|
||||
+ 0xD8, SCROLL_INERTIAL,
|
||||
+ 0xDA, 0x05,
|
||||
+ 0xDB, 0x02,
|
||||
+ 0xE4, 0x05,
|
||||
+ 0xD6, 0x01,
|
||||
+ 0xDE, 0x04,
|
||||
+ 0xE3, 0x01,
|
||||
+ 0xCF, 0x00,
|
||||
+ 0xD2, 0x03,
|
||||
+ /* Vertical and horizontal two-finger scrolling inertia. */
|
||||
+ 0xE5, SCROLL_INERTIAL,
|
||||
+ 0xD9, 0x02,
|
||||
+ 0xD9, 0x07,
|
||||
+ 0xDC, 0x03,
|
||||
+ 0xDD, 0x03,
|
||||
+ 0xDF, 0x03,
|
||||
+ 0xE1, 0x03,
|
||||
+ 0xD1, 0x00,
|
||||
+ 0xCE, 0x00,
|
||||
+ 0xCC, 0x00,
|
||||
+ 0xE0, 0x00,
|
||||
+ 0xE2, 0x01
|
||||
+ };
|
||||
+ u8 param[4];
|
||||
+
|
||||
+ if (byd_send_sequence(psmouse, seq1, ARRAY_SIZE(seq1)))
|
||||
+ return -1;
|
||||
+
|
||||
+ /* Send a 0x01 command, which should return 4 bytes. */
|
||||
+ if (ps2_command(&psmouse->ps2dev, param, 0x0401))
|
||||
+ return -1;
|
||||
+
|
||||
+ if (byd_send_sequence(psmouse, seq2, ARRAY_SIZE(seq2)))
|
||||
+ return -1;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * Send the set of PS/2 commands required to make it identify as an
|
||||
+ * intellimouse with 4-byte instead of 3-byte packets.
|
||||
+ */
|
||||
+static int byd_send_intellimouse_sequence(struct psmouse *psmouse)
|
||||
+{
|
||||
+ struct ps2dev *ps2dev = &psmouse->ps2dev;
|
||||
+ u8 param[4];
|
||||
+ int i;
|
||||
+ const struct {
|
||||
+ u16 command;
|
||||
+ u8 arg;
|
||||
+ } seq[] = {
|
||||
+ { PSMOUSE_CMD_RESET_BAT, 0 },
|
||||
+ { PSMOUSE_CMD_RESET_BAT, 0 },
|
||||
+ { PSMOUSE_CMD_GETID, 0 },
|
||||
+ { PSMOUSE_CMD_SETSCALE11, 0 },
|
||||
+ { PSMOUSE_CMD_SETSCALE11, 0 },
|
||||
+ { PSMOUSE_CMD_SETSCALE11, 0 },
|
||||
+ { PSMOUSE_CMD_GETINFO, 0 },
|
||||
+ { PSMOUSE_CMD_SETRES, 0x03 },
|
||||
+ { PSMOUSE_CMD_SETRATE, 0xC8 },
|
||||
+ { PSMOUSE_CMD_SETRATE, 0x64 },
|
||||
+ { PSMOUSE_CMD_SETRATE, 0x50 },
|
||||
+ { PSMOUSE_CMD_GETID, 0 },
|
||||
+ { PSMOUSE_CMD_SETRATE, 0xC8 },
|
||||
+ { PSMOUSE_CMD_SETRATE, 0xC8 },
|
||||
+ { PSMOUSE_CMD_SETRATE, 0x50 },
|
||||
+ { PSMOUSE_CMD_GETID, 0 },
|
||||
+ { PSMOUSE_CMD_SETRATE, 0x64 },
|
||||
+ { PSMOUSE_CMD_SETRES, 0x03 },
|
||||
+ { PSMOUSE_CMD_ENABLE, 0 }
|
||||
+ };
|
||||
+
|
||||
+ memset(param, 0, sizeof(param));
|
||||
+ for (i = 0; i < ARRAY_SIZE(seq); ++i) {
|
||||
+ param[0] = seq[i].arg;
|
||||
+ if (ps2_command(ps2dev, param, seq[i].command))
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int byd_reset_touchpad(struct psmouse *psmouse)
|
||||
+{
|
||||
+ if (byd_send_intellimouse_sequence(psmouse))
|
||||
+ return -EIO;
|
||||
+
|
||||
+ if (byd_enable(psmouse))
|
||||
+ return -EIO;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int byd_reconnect(struct psmouse *psmouse)
|
||||
+{
|
||||
+ int retry = 0, error = 0;
|
||||
+
|
||||
+ psmouse_dbg(psmouse, "Reconnect\n");
|
||||
+ do {
|
||||
+ psmouse_reset(psmouse);
|
||||
+ if (retry)
|
||||
+ ssleep(1);
|
||||
+ error = byd_detect(psmouse, 0);
|
||||
+ } while (error && ++retry < 3);
|
||||
+
|
||||
+ if (error)
|
||||
+ return error;
|
||||
+
|
||||
+ psmouse_dbg(psmouse, "Reconnected after %d attempts\n", retry);
|
||||
+
|
||||
+ error = byd_reset_touchpad(psmouse);
|
||||
+ if (error) {
|
||||
+ psmouse_err(psmouse, "Unable to initialize device\n");
|
||||
+ return error;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int byd_init(struct psmouse *psmouse)
|
||||
+{
|
||||
+ struct input_dev *dev = psmouse->dev;
|
||||
+
|
||||
+ if (psmouse_reset(psmouse))
|
||||
+ return -EIO;
|
||||
+
|
||||
+ if (byd_reset_touchpad(psmouse))
|
||||
+ return -EIO;
|
||||
+
|
||||
+ psmouse->reconnect = byd_reconnect;
|
||||
+ psmouse->protocol_handler = byd_process_byte;
|
||||
+ psmouse->pktsize = 4;
|
||||
+ psmouse->resync_time = 0;
|
||||
+
|
||||
+ __set_bit(BTN_MIDDLE, dev->keybit);
|
||||
+ __set_bit(REL_WHEEL, dev->relbit);
|
||||
+ __set_bit(REL_HWHEEL, dev->relbit);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
diff --git a/drivers/input/mouse/byd.h b/drivers/input/mouse/byd.h
|
||||
new file mode 100644
|
||||
index 0000000..d6c120c
|
||||
--- /dev/null
|
||||
+++ b/drivers/input/mouse/byd.h
|
||||
@@ -0,0 +1,18 @@
|
||||
+#ifndef _BYD_H
|
||||
+#define _BYD_H
|
||||
+
|
||||
+#ifdef CONFIG_MOUSE_PS2_BYD
|
||||
+int byd_detect(struct psmouse *psmouse, bool set_properties);
|
||||
+int byd_init(struct psmouse *psmouse);
|
||||
+#else
|
||||
+static inline int byd_detect(struct psmouse *psmouse, bool set_properties)
|
||||
+{
|
||||
+ return -ENOSYS;
|
||||
+}
|
||||
+static inline int byd_init(struct psmouse *psmouse)
|
||||
+{
|
||||
+ return -ENOSYS;
|
||||
+}
|
||||
+#endif /* CONFIG_MOUSE_PS2_BYD */
|
||||
+
|
||||
+#endif /* _BYD_H */
|
||||
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
|
||||
index b9e4ee3..39d1bec 100644
|
||||
--- a/drivers/input/mouse/psmouse-base.c
|
||||
+++ b/drivers/input/mouse/psmouse-base.c
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "cypress_ps2.h"
|
||||
#include "focaltech.h"
|
||||
#include "vmmouse.h"
|
||||
+#include "byd.h"
|
||||
|
||||
#define DRIVER_DESC "PS/2 mouse driver"
|
||||
|
||||
@@ -920,6 +921,11 @@ static int psmouse_extensions(struct psm
|
||||
if (psmouse_do_detect(touchkit_ps2_detect,
|
||||
psmouse, set_properties) == 0)
|
||||
return PSMOUSE_TOUCHKIT_PS2;
|
||||
+
|
||||
+ if (psmouse_do_detect(byd_detect,
|
||||
+ psmouse, set_properties) == 0)
|
||||
+ if (!set_properties || byd_init(psmouse) == 0)
|
||||
+ return PSMOUSE_BYD;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1130,6 +1136,15 @@ static const struct psmouse_protocol psmouse_protocols[] = {
|
||||
.init = vmmouse_init,
|
||||
},
|
||||
#endif
|
||||
+#ifdef CONFIG_MOUSE_PS2_BYD
|
||||
+ {
|
||||
+ .type = PSMOUSE_BYD,
|
||||
+ .name = "BydPS/2",
|
||||
+ .alias = "byd",
|
||||
+ .detect = byd_detect,
|
||||
+ .init = byd_init,
|
||||
+ },
|
||||
+#endif
|
||||
{
|
||||
.type = PSMOUSE_AUTO,
|
||||
.name = "auto",
|
||||
diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
|
||||
index ad5a5a1..e0ca6cd 100644
|
||||
--- a/drivers/input/mouse/psmouse.h
|
||||
+++ b/drivers/input/mouse/psmouse.h
|
||||
@@ -104,6 +104,7 @@ enum psmouse_type {
|
||||
PSMOUSE_CYPRESS,
|
||||
PSMOUSE_FOCALTECH,
|
||||
PSMOUSE_VMMOUSE,
|
||||
+ PSMOUSE_BYD,
|
||||
PSMOUSE_AUTO /* This one should always be last */
|
||||
};
|
||||
|
||||
--
|
||||
2.5.5
|
@ -1,710 +0,0 @@
|
||||
From 2d5f5611dd0de52e9a52b56391a7049a52184e72 Mon Sep 17 00:00:00 2001
|
||||
From: Richard Pospesel <pospeselr@gmail.com>
|
||||
Date: Mon, 14 Mar 2016 09:41:16 -0700
|
||||
Subject: [PATCH] Input: byd - enable absolute mode
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The Windows driver's settings dialog contains a visualization of the
|
||||
regions for the hardware edge scrolling capability, which uses a
|
||||
temporarily-enabled limited-resolution absolute mode.
|
||||
|
||||
This patch enables this during normal operation, and combines the
|
||||
absolute packets with the existing relative packets to provide
|
||||
accurate absolute position and touch reporting.
|
||||
|
||||
It also adds documentation for all known gesture packets and
|
||||
initialization commands.
|
||||
|
||||
Reviewed-by: Chris Diamand <chris@diamand.org>
|
||||
Signed-off-by: Richard Pospesel <pospeselr@gmail.com>
|
||||
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
|
||||
---
|
||||
drivers/input/mouse/byd.c | 565 ++++++++++++++++++++++++-------------
|
||||
drivers/input/mouse/psmouse-base.c | 2 +-
|
||||
2 files changed, 369 insertions(+), 198 deletions(-)
|
||||
|
||||
diff --git a/drivers/input/mouse/byd.c b/drivers/input/mouse/byd.c
|
||||
index 9425e0f..fdc243c 100644
|
||||
--- a/drivers/input/mouse/byd.c
|
||||
+++ b/drivers/input/mouse/byd.c
|
||||
@@ -12,10 +12,12 @@
|
||||
#include <linux/input.h>
|
||||
#include <linux/libps2.h>
|
||||
#include <linux/serio.h>
|
||||
+#include <linux/slab.h>
|
||||
|
||||
#include "psmouse.h"
|
||||
#include "byd.h"
|
||||
|
||||
+/* PS2 Bits */
|
||||
#define PS2_Y_OVERFLOW BIT_MASK(7)
|
||||
#define PS2_X_OVERFLOW BIT_MASK(6)
|
||||
#define PS2_Y_SIGN BIT_MASK(5)
|
||||
@@ -26,69 +28,249 @@
|
||||
#define PS2_LEFT BIT_MASK(0)
|
||||
|
||||
/*
|
||||
- * The touchpad reports gestures in the last byte of each packet. It can take
|
||||
- * any of the following values:
|
||||
+ * BYD pad constants
|
||||
*/
|
||||
|
||||
-/* One-finger scrolling in one of the edge scroll zones. */
|
||||
-#define BYD_SCROLLUP 0xCA
|
||||
-#define BYD_SCROLLDOWN 0x36
|
||||
-#define BYD_SCROLLLEFT 0xCB
|
||||
-#define BYD_SCROLLRIGHT 0x35
|
||||
-/* Two-finger scrolling. */
|
||||
-#define BYD_2DOWN 0x2B
|
||||
-#define BYD_2UP 0xD5
|
||||
-#define BYD_2LEFT 0xD6
|
||||
-#define BYD_2RIGHT 0x2A
|
||||
-/* Pinching in or out. */
|
||||
-#define BYD_ZOOMOUT 0xD8
|
||||
-#define BYD_ZOOMIN 0x28
|
||||
-/* Three-finger swipe. */
|
||||
-#define BYD_3UP 0xD3
|
||||
-#define BYD_3DOWN 0x2D
|
||||
-#define BYD_3LEFT 0xD4
|
||||
-#define BYD_3RIGHT 0x2C
|
||||
-/* Four-finger swipe. */
|
||||
-#define BYD_4UP 0xCD
|
||||
-#define BYD_4DOWN 0x33
|
||||
+/*
|
||||
+ * True device resolution is unknown, however experiments show the
|
||||
+ * resolution is about 111 units/mm.
|
||||
+ * Absolute coordinate packets are in the range 0-255 for both X and Y
|
||||
+ * we pick ABS_X/ABS_Y dimensions which are multiples of 256 and in
|
||||
+ * the right ballpark given the touchpad's physical dimensions and estimate
|
||||
+ * resolution per spec sheet, device active area dimensions are
|
||||
+ * 101.6 x 60.1 mm.
|
||||
+ */
|
||||
+#define BYD_PAD_WIDTH 11264
|
||||
+#define BYD_PAD_HEIGHT 6656
|
||||
+#define BYD_PAD_RESOLUTION 111
|
||||
|
||||
-int byd_detect(struct psmouse *psmouse, bool set_properties)
|
||||
+/*
|
||||
+ * Given the above dimensions, relative packets velocity is in multiples of
|
||||
+ * 1 unit / 11 milliseconds. We use this dt to estimate distance traveled
|
||||
+ */
|
||||
+#define BYD_DT 11
|
||||
+/* Time in jiffies used to timeout various touch events (64 ms) */
|
||||
+#define BYD_TOUCH_TIMEOUT msecs_to_jiffies(64)
|
||||
+
|
||||
+/* BYD commands reverse engineered from windows driver */
|
||||
+
|
||||
+/*
|
||||
+ * Swipe gesture from off-pad to on-pad
|
||||
+ * 0 : disable
|
||||
+ * 1 : enable
|
||||
+ */
|
||||
+#define BYD_CMD_SET_OFFSCREEN_SWIPE 0x10cc
|
||||
+/*
|
||||
+ * Tap and drag delay time
|
||||
+ * 0 : disable
|
||||
+ * 1 - 8 : least to most delay
|
||||
+ */
|
||||
+#define BYD_CMD_SET_TAP_DRAG_DELAY_TIME 0x10cf
|
||||
+/*
|
||||
+ * Physical buttons function mapping
|
||||
+ * 0 : enable
|
||||
+ * 4 : normal
|
||||
+ * 5 : left button custom command
|
||||
+ * 6 : right button custom command
|
||||
+ * 8 : disable
|
||||
+ */
|
||||
+#define BYD_CMD_SET_PHYSICAL_BUTTONS 0x10d0
|
||||
+/*
|
||||
+ * Absolute mode (1 byte X/Y resolution)
|
||||
+ * 0 : disable
|
||||
+ * 2 : enable
|
||||
+ */
|
||||
+#define BYD_CMD_SET_ABSOLUTE_MODE 0x10d1
|
||||
+/*
|
||||
+ * Two finger scrolling
|
||||
+ * 1 : vertical
|
||||
+ * 2 : horizontal
|
||||
+ * 3 : vertical + horizontal
|
||||
+ * 4 : disable
|
||||
+ */
|
||||
+#define BYD_CMD_SET_TWO_FINGER_SCROLL 0x10d2
|
||||
+/*
|
||||
+ * Handedness
|
||||
+ * 1 : right handed
|
||||
+ * 2 : left handed
|
||||
+ */
|
||||
+#define BYD_CMD_SET_HANDEDNESS 0x10d3
|
||||
+/*
|
||||
+ * Tap to click
|
||||
+ * 1 : enable
|
||||
+ * 2 : disable
|
||||
+ */
|
||||
+#define BYD_CMD_SET_TAP 0x10d4
|
||||
+/*
|
||||
+ * Tap and drag
|
||||
+ * 1 : tap and hold to drag
|
||||
+ * 2 : tap and hold to drag + lock
|
||||
+ * 3 : disable
|
||||
+ */
|
||||
+#define BYD_CMD_SET_TAP_DRAG 0x10d5
|
||||
+/*
|
||||
+ * Touch sensitivity
|
||||
+ * 1 - 7 : least to most sensitive
|
||||
+ */
|
||||
+#define BYD_CMD_SET_TOUCH_SENSITIVITY 0x10d6
|
||||
+/*
|
||||
+ * One finger scrolling
|
||||
+ * 1 : vertical
|
||||
+ * 2 : horizontal
|
||||
+ * 3 : vertical + horizontal
|
||||
+ * 4 : disable
|
||||
+ */
|
||||
+#define BYD_CMD_SET_ONE_FINGER_SCROLL 0x10d7
|
||||
+/*
|
||||
+ * One finger scrolling function
|
||||
+ * 1 : free scrolling
|
||||
+ * 2 : edge motion
|
||||
+ * 3 : free scrolling + edge motion
|
||||
+ * 4 : disable
|
||||
+ */
|
||||
+#define BYD_CMD_SET_ONE_FINGER_SCROLL_FUNC 0x10d8
|
||||
+/*
|
||||
+ * Sliding speed
|
||||
+ * 1 - 5 : slowest to fastest
|
||||
+ */
|
||||
+#define BYD_CMD_SET_SLIDING_SPEED 0x10da
|
||||
+/*
|
||||
+ * Edge motion
|
||||
+ * 1 : disable
|
||||
+ * 2 : enable when dragging
|
||||
+ * 3 : enable when dragging and pointing
|
||||
+ */
|
||||
+#define BYD_CMD_SET_EDGE_MOTION 0x10db
|
||||
+/*
|
||||
+ * Left edge region size
|
||||
+ * 0 - 7 : smallest to largest width
|
||||
+ */
|
||||
+#define BYD_CMD_SET_LEFT_EDGE_REGION 0x10dc
|
||||
+/*
|
||||
+ * Top edge region size
|
||||
+ * 0 - 9 : smallest to largest height
|
||||
+ */
|
||||
+#define BYD_CMD_SET_TOP_EDGE_REGION 0x10dd
|
||||
+/*
|
||||
+ * Disregard palm press as clicks
|
||||
+ * 1 - 6 : smallest to largest
|
||||
+ */
|
||||
+#define BYD_CMD_SET_PALM_CHECK 0x10de
|
||||
+/*
|
||||
+ * Right edge region size
|
||||
+ * 0 - 7 : smallest to largest width
|
||||
+ */
|
||||
+#define BYD_CMD_SET_RIGHT_EDGE_REGION 0x10df
|
||||
+/*
|
||||
+ * Bottom edge region size
|
||||
+ * 0 - 9 : smallest to largest height
|
||||
+ */
|
||||
+#define BYD_CMD_SET_BOTTOM_EDGE_REGION 0x10e1
|
||||
+/*
|
||||
+ * Multitouch gestures
|
||||
+ * 1 : enable
|
||||
+ * 2 : disable
|
||||
+ */
|
||||
+#define BYD_CMD_SET_MULTITOUCH 0x10e3
|
||||
+/*
|
||||
+ * Edge motion speed
|
||||
+ * 0 : control with finger pressure
|
||||
+ * 1 - 9 : slowest to fastest
|
||||
+ */
|
||||
+#define BYD_CMD_SET_EDGE_MOTION_SPEED 0x10e4
|
||||
+/*
|
||||
+ * Two finger scolling function
|
||||
+ * 0 : free scrolling
|
||||
+ * 1 : free scrolling (with momentum)
|
||||
+ * 2 : edge motion
|
||||
+ * 3 : free scrolling (with momentum) + edge motion
|
||||
+ * 4 : disable
|
||||
+ */
|
||||
+#define BYD_CMD_SET_TWO_FINGER_SCROLL_FUNC 0x10e5
|
||||
+
|
||||
+/*
|
||||
+ * The touchpad generates a mixture of absolute and relative packets, indicated
|
||||
+ * by the the last byte of each packet being set to one of the following:
|
||||
+ */
|
||||
+#define BYD_PACKET_ABSOLUTE 0xf8
|
||||
+#define BYD_PACKET_RELATIVE 0x00
|
||||
+/* Multitouch gesture packets */
|
||||
+#define BYD_PACKET_PINCH_IN 0xd8
|
||||
+#define BYD_PACKET_PINCH_OUT 0x28
|
||||
+#define BYD_PACKET_ROTATE_CLOCKWISE 0x29
|
||||
+#define BYD_PACKET_ROTATE_ANTICLOCKWISE 0xd7
|
||||
+#define BYD_PACKET_TWO_FINGER_SCROLL_RIGHT 0x2a
|
||||
+#define BYD_PACKET_TWO_FINGER_SCROLL_DOWN 0x2b
|
||||
+#define BYD_PACKET_TWO_FINGER_SCROLL_UP 0xd5
|
||||
+#define BYD_PACKET_TWO_FINGER_SCROLL_LEFT 0xd6
|
||||
+#define BYD_PACKET_THREE_FINGER_SWIPE_RIGHT 0x2c
|
||||
+#define BYD_PACKET_THREE_FINGER_SWIPE_DOWN 0x2d
|
||||
+#define BYD_PACKET_THREE_FINGER_SWIPE_UP 0xd3
|
||||
+#define BYD_PACKET_THREE_FINGER_SWIPE_LEFT 0xd4
|
||||
+#define BYD_PACKET_FOUR_FINGER_DOWN 0x33
|
||||
+#define BYD_PACKET_FOUR_FINGER_UP 0xcd
|
||||
+#define BYD_PACKET_REGION_SCROLL_RIGHT 0x35
|
||||
+#define BYD_PACKET_REGION_SCROLL_DOWN 0x36
|
||||
+#define BYD_PACKET_REGION_SCROLL_UP 0xca
|
||||
+#define BYD_PACKET_REGION_SCROLL_LEFT 0xcb
|
||||
+#define BYD_PACKET_RIGHT_CORNER_CLICK 0xd2
|
||||
+#define BYD_PACKET_LEFT_CORNER_CLICK 0x2e
|
||||
+#define BYD_PACKET_LEFT_AND_RIGHT_CORNER_CLICK 0x2f
|
||||
+#define BYD_PACKET_ONTO_PAD_SWIPE_RIGHT 0x37
|
||||
+#define BYD_PACKET_ONTO_PAD_SWIPE_DOWN 0x30
|
||||
+#define BYD_PACKET_ONTO_PAD_SWIPE_UP 0xd0
|
||||
+#define BYD_PACKET_ONTO_PAD_SWIPE_LEFT 0xc9
|
||||
+
|
||||
+struct byd_data {
|
||||
+ struct timer_list timer;
|
||||
+ s32 abs_x;
|
||||
+ s32 abs_y;
|
||||
+ typeof(jiffies) last_touch_time;
|
||||
+ bool btn_left;
|
||||
+ bool btn_right;
|
||||
+ bool touch;
|
||||
+};
|
||||
+
|
||||
+static void byd_report_input(struct psmouse *psmouse)
|
||||
{
|
||||
- struct ps2dev *ps2dev = &psmouse->ps2dev;
|
||||
- unsigned char param[4];
|
||||
+ struct byd_data *priv = psmouse->private;
|
||||
+ struct input_dev *dev = psmouse->dev;
|
||||
|
||||
- param[0] = 0x03;
|
||||
- param[1] = 0x00;
|
||||
- param[2] = 0x00;
|
||||
- param[3] = 0x00;
|
||||
+ input_report_key(dev, BTN_TOUCH, priv->touch);
|
||||
+ input_report_key(dev, BTN_TOOL_FINGER, priv->touch);
|
||||
|
||||
- if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
|
||||
- return -1;
|
||||
- if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
|
||||
- return -1;
|
||||
- if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
|
||||
- return -1;
|
||||
- if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
|
||||
- return -1;
|
||||
- if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO))
|
||||
- return -1;
|
||||
+ input_report_abs(dev, ABS_X, priv->abs_x);
|
||||
+ input_report_abs(dev, ABS_Y, priv->abs_y);
|
||||
+ input_report_key(dev, BTN_LEFT, priv->btn_left);
|
||||
+ input_report_key(dev, BTN_RIGHT, priv->btn_right);
|
||||
|
||||
- if (param[1] != 0x03 || param[2] != 0x64)
|
||||
- return -ENODEV;
|
||||
+ input_sync(dev);
|
||||
+}
|
||||
|
||||
- psmouse_dbg(psmouse, "BYD touchpad detected\n");
|
||||
+static void byd_clear_touch(unsigned long data)
|
||||
+{
|
||||
+ struct psmouse *psmouse = (struct psmouse *)data;
|
||||
+ struct byd_data *priv = psmouse->private;
|
||||
|
||||
- if (set_properties) {
|
||||
- psmouse->vendor = "BYD";
|
||||
- psmouse->name = "TouchPad";
|
||||
- }
|
||||
+ serio_pause_rx(psmouse->ps2dev.serio);
|
||||
+ priv->touch = false;
|
||||
|
||||
- return 0;
|
||||
+ byd_report_input(psmouse);
|
||||
+
|
||||
+ serio_continue_rx(psmouse->ps2dev.serio);
|
||||
+
|
||||
+ /*
|
||||
+ * Move cursor back to center of pad when we lose touch - this
|
||||
+ * specifically improves user experience when moving cursor with one
|
||||
+ * finger, and pressing a button with another.
|
||||
+ */
|
||||
+ priv->abs_x = BYD_PAD_WIDTH / 2;
|
||||
+ priv->abs_y = BYD_PAD_HEIGHT / 2;
|
||||
}
|
||||
|
||||
static psmouse_ret_t byd_process_byte(struct psmouse *psmouse)
|
||||
{
|
||||
- struct input_dev *dev = psmouse->dev;
|
||||
+ struct byd_data *priv = psmouse->private;
|
||||
u8 *pkt = psmouse->packet;
|
||||
|
||||
if (psmouse->pktcnt > 0 && !(pkt[0] & PS2_ALWAYS_1)) {
|
||||
@@ -102,53 +284,34 @@ static psmouse_ret_t byd_process_byte(struct psmouse *psmouse)
|
||||
|
||||
/* Otherwise, a full packet has been received */
|
||||
switch (pkt[3]) {
|
||||
- case 0: {
|
||||
+ case BYD_PACKET_ABSOLUTE:
|
||||
+ /* Only use absolute packets for the start of movement. */
|
||||
+ if (!priv->touch) {
|
||||
+ /* needed to detect tap */
|
||||
+ typeof(jiffies) tap_time =
|
||||
+ priv->last_touch_time + BYD_TOUCH_TIMEOUT;
|
||||
+ priv->touch = time_after(jiffies, tap_time);
|
||||
+
|
||||
+ /* init abs position */
|
||||
+ priv->abs_x = pkt[1] * (BYD_PAD_WIDTH / 256);
|
||||
+ priv->abs_y = (255 - pkt[2]) * (BYD_PAD_HEIGHT / 256);
|
||||
+ }
|
||||
+ break;
|
||||
+ case BYD_PACKET_RELATIVE: {
|
||||
/* Standard packet */
|
||||
/* Sign-extend if a sign bit is set. */
|
||||
- unsigned int signx = pkt[0] & PS2_X_SIGN ? ~0xFF : 0;
|
||||
- unsigned int signy = pkt[0] & PS2_Y_SIGN ? ~0xFF : 0;
|
||||
- int dx = signx | (int) pkt[1];
|
||||
- int dy = signy | (int) pkt[2];
|
||||
+ u32 signx = pkt[0] & PS2_X_SIGN ? ~0xFF : 0;
|
||||
+ u32 signy = pkt[0] & PS2_Y_SIGN ? ~0xFF : 0;
|
||||
+ s32 dx = signx | (int) pkt[1];
|
||||
+ s32 dy = signy | (int) pkt[2];
|
||||
|
||||
- input_report_rel(psmouse->dev, REL_X, dx);
|
||||
- input_report_rel(psmouse->dev, REL_Y, -dy);
|
||||
+ /* Update position based on velocity */
|
||||
+ priv->abs_x += dx * BYD_DT;
|
||||
+ priv->abs_y -= dy * BYD_DT;
|
||||
|
||||
- input_report_key(psmouse->dev, BTN_LEFT, pkt[0] & PS2_LEFT);
|
||||
- input_report_key(psmouse->dev, BTN_RIGHT, pkt[0] & PS2_RIGHT);
|
||||
- input_report_key(psmouse->dev, BTN_MIDDLE, pkt[0] & PS2_MIDDLE);
|
||||
+ priv->touch = true;
|
||||
break;
|
||||
}
|
||||
-
|
||||
- case BYD_SCROLLDOWN:
|
||||
- case BYD_2DOWN:
|
||||
- input_report_rel(dev, REL_WHEEL, -1);
|
||||
- break;
|
||||
-
|
||||
- case BYD_SCROLLUP:
|
||||
- case BYD_2UP:
|
||||
- input_report_rel(dev, REL_WHEEL, 1);
|
||||
- break;
|
||||
-
|
||||
- case BYD_SCROLLLEFT:
|
||||
- case BYD_2LEFT:
|
||||
- input_report_rel(dev, REL_HWHEEL, -1);
|
||||
- break;
|
||||
-
|
||||
- case BYD_SCROLLRIGHT:
|
||||
- case BYD_2RIGHT:
|
||||
- input_report_rel(dev, REL_HWHEEL, 1);
|
||||
- break;
|
||||
-
|
||||
- case BYD_ZOOMOUT:
|
||||
- case BYD_ZOOMIN:
|
||||
- case BYD_3UP:
|
||||
- case BYD_3DOWN:
|
||||
- case BYD_3LEFT:
|
||||
- case BYD_3RIGHT:
|
||||
- case BYD_4UP:
|
||||
- case BYD_4DOWN:
|
||||
- break;
|
||||
-
|
||||
default:
|
||||
psmouse_warn(psmouse,
|
||||
"Unrecognized Z: pkt = %02x %02x %02x %02x\n",
|
||||
@@ -157,134 +320,76 @@ static psmouse_ret_t byd_process_byte(struct psmouse *psmouse)
|
||||
return PSMOUSE_BAD_DATA;
|
||||
}
|
||||
|
||||
- input_sync(dev);
|
||||
+ priv->btn_left = pkt[0] & PS2_LEFT;
|
||||
+ priv->btn_right = pkt[0] & PS2_RIGHT;
|
||||
|
||||
- return PSMOUSE_FULL_PACKET;
|
||||
-}
|
||||
+ byd_report_input(psmouse);
|
||||
|
||||
-/* Send a sequence of bytes, where each is ACKed before the next is sent. */
|
||||
-static int byd_send_sequence(struct psmouse *psmouse, const u8 *seq, size_t len)
|
||||
-{
|
||||
- unsigned int i;
|
||||
-
|
||||
- for (i = 0; i < len; ++i) {
|
||||
- if (ps2_command(&psmouse->ps2dev, NULL, seq[i]))
|
||||
- return -1;
|
||||
+ /* Reset time since last touch. */
|
||||
+ if (priv->touch) {
|
||||
+ priv->last_touch_time = jiffies;
|
||||
+ mod_timer(&priv->timer, jiffies + BYD_TOUCH_TIMEOUT);
|
||||
}
|
||||
- return 0;
|
||||
-}
|
||||
-
|
||||
-/* Keep scrolling after fingers are removed. */
|
||||
-#define SCROLL_INERTIAL 0x01
|
||||
-#define SCROLL_NO_INERTIAL 0x02
|
||||
-
|
||||
-/* Clicking can be done by tapping or pressing. */
|
||||
-#define CLICK_BOTH 0x01
|
||||
-/* Clicking can only be done by pressing. */
|
||||
-#define CLICK_PRESS_ONLY 0x02
|
||||
|
||||
-static int byd_enable(struct psmouse *psmouse)
|
||||
-{
|
||||
- const u8 seq1[] = { 0xE2, 0x00, 0xE0, 0x02, 0xE0 };
|
||||
- const u8 seq2[] = {
|
||||
- 0xD3, 0x01,
|
||||
- 0xD0, 0x00,
|
||||
- 0xD0, 0x04,
|
||||
- /* Whether clicking is done by tapping or pressing. */
|
||||
- 0xD4, CLICK_PRESS_ONLY,
|
||||
- 0xD5, 0x01,
|
||||
- 0xD7, 0x03,
|
||||
- /* Vertical and horizontal one-finger scroll zone inertia. */
|
||||
- 0xD8, SCROLL_INERTIAL,
|
||||
- 0xDA, 0x05,
|
||||
- 0xDB, 0x02,
|
||||
- 0xE4, 0x05,
|
||||
- 0xD6, 0x01,
|
||||
- 0xDE, 0x04,
|
||||
- 0xE3, 0x01,
|
||||
- 0xCF, 0x00,
|
||||
- 0xD2, 0x03,
|
||||
- /* Vertical and horizontal two-finger scrolling inertia. */
|
||||
- 0xE5, SCROLL_INERTIAL,
|
||||
- 0xD9, 0x02,
|
||||
- 0xD9, 0x07,
|
||||
- 0xDC, 0x03,
|
||||
- 0xDD, 0x03,
|
||||
- 0xDF, 0x03,
|
||||
- 0xE1, 0x03,
|
||||
- 0xD1, 0x00,
|
||||
- 0xCE, 0x00,
|
||||
- 0xCC, 0x00,
|
||||
- 0xE0, 0x00,
|
||||
- 0xE2, 0x01
|
||||
- };
|
||||
- u8 param[4];
|
||||
-
|
||||
- if (byd_send_sequence(psmouse, seq1, ARRAY_SIZE(seq1)))
|
||||
- return -1;
|
||||
-
|
||||
- /* Send a 0x01 command, which should return 4 bytes. */
|
||||
- if (ps2_command(&psmouse->ps2dev, param, 0x0401))
|
||||
- return -1;
|
||||
-
|
||||
- if (byd_send_sequence(psmouse, seq2, ARRAY_SIZE(seq2)))
|
||||
- return -1;
|
||||
-
|
||||
- return 0;
|
||||
+ return PSMOUSE_FULL_PACKET;
|
||||
}
|
||||
|
||||
-/*
|
||||
- * Send the set of PS/2 commands required to make it identify as an
|
||||
- * intellimouse with 4-byte instead of 3-byte packets.
|
||||
- */
|
||||
-static int byd_send_intellimouse_sequence(struct psmouse *psmouse)
|
||||
+static int byd_reset_touchpad(struct psmouse *psmouse)
|
||||
{
|
||||
struct ps2dev *ps2dev = &psmouse->ps2dev;
|
||||
u8 param[4];
|
||||
- int i;
|
||||
+ size_t i;
|
||||
+
|
||||
const struct {
|
||||
u16 command;
|
||||
u8 arg;
|
||||
} seq[] = {
|
||||
- { PSMOUSE_CMD_RESET_BAT, 0 },
|
||||
- { PSMOUSE_CMD_RESET_BAT, 0 },
|
||||
- { PSMOUSE_CMD_GETID, 0 },
|
||||
- { PSMOUSE_CMD_SETSCALE11, 0 },
|
||||
- { PSMOUSE_CMD_SETSCALE11, 0 },
|
||||
- { PSMOUSE_CMD_SETSCALE11, 0 },
|
||||
- { PSMOUSE_CMD_GETINFO, 0 },
|
||||
- { PSMOUSE_CMD_SETRES, 0x03 },
|
||||
+ /*
|
||||
+ * Intellimouse initialization sequence, to get 4-byte instead
|
||||
+ * of 3-byte packets.
|
||||
+ */
|
||||
{ PSMOUSE_CMD_SETRATE, 0xC8 },
|
||||
{ PSMOUSE_CMD_SETRATE, 0x64 },
|
||||
{ PSMOUSE_CMD_SETRATE, 0x50 },
|
||||
{ PSMOUSE_CMD_GETID, 0 },
|
||||
- { PSMOUSE_CMD_SETRATE, 0xC8 },
|
||||
- { PSMOUSE_CMD_SETRATE, 0xC8 },
|
||||
- { PSMOUSE_CMD_SETRATE, 0x50 },
|
||||
- { PSMOUSE_CMD_GETID, 0 },
|
||||
- { PSMOUSE_CMD_SETRATE, 0x64 },
|
||||
- { PSMOUSE_CMD_SETRES, 0x03 },
|
||||
- { PSMOUSE_CMD_ENABLE, 0 }
|
||||
+ { PSMOUSE_CMD_ENABLE, 0 },
|
||||
+ /*
|
||||
+ * BYD-specific initialization, which enables absolute mode and
|
||||
+ * (if desired), the touchpad's built-in gesture detection.
|
||||
+ */
|
||||
+ { 0x10E2, 0x00 },
|
||||
+ { 0x10E0, 0x02 },
|
||||
+ /* The touchpad should reply with 4 seemingly-random bytes */
|
||||
+ { 0x14E0, 0x01 },
|
||||
+ /* Pairs of parameters and values. */
|
||||
+ { BYD_CMD_SET_HANDEDNESS, 0x01 },
|
||||
+ { BYD_CMD_SET_PHYSICAL_BUTTONS, 0x04 },
|
||||
+ { BYD_CMD_SET_TAP, 0x02 },
|
||||
+ { BYD_CMD_SET_ONE_FINGER_SCROLL, 0x04 },
|
||||
+ { BYD_CMD_SET_ONE_FINGER_SCROLL_FUNC, 0x04 },
|
||||
+ { BYD_CMD_SET_EDGE_MOTION, 0x01 },
|
||||
+ { BYD_CMD_SET_PALM_CHECK, 0x00 },
|
||||
+ { BYD_CMD_SET_MULTITOUCH, 0x02 },
|
||||
+ { BYD_CMD_SET_TWO_FINGER_SCROLL, 0x04 },
|
||||
+ { BYD_CMD_SET_TWO_FINGER_SCROLL_FUNC, 0x04 },
|
||||
+ { BYD_CMD_SET_LEFT_EDGE_REGION, 0x00 },
|
||||
+ { BYD_CMD_SET_TOP_EDGE_REGION, 0x00 },
|
||||
+ { BYD_CMD_SET_RIGHT_EDGE_REGION, 0x00 },
|
||||
+ { BYD_CMD_SET_BOTTOM_EDGE_REGION, 0x00 },
|
||||
+ { BYD_CMD_SET_ABSOLUTE_MODE, 0x02 },
|
||||
+ /* Finalize initialization. */
|
||||
+ { 0x10E0, 0x00 },
|
||||
+ { 0x10E2, 0x01 },
|
||||
};
|
||||
|
||||
- memset(param, 0, sizeof(param));
|
||||
for (i = 0; i < ARRAY_SIZE(seq); ++i) {
|
||||
+ memset(param, 0, sizeof(param));
|
||||
param[0] = seq[i].arg;
|
||||
if (ps2_command(ps2dev, param, seq[i].command))
|
||||
- return -1;
|
||||
+ return -EIO;
|
||||
}
|
||||
|
||||
- return 0;
|
||||
-}
|
||||
-
|
||||
-static int byd_reset_touchpad(struct psmouse *psmouse)
|
||||
-{
|
||||
- if (byd_send_intellimouse_sequence(psmouse))
|
||||
- return -EIO;
|
||||
-
|
||||
- if (byd_enable(psmouse))
|
||||
- return -EIO;
|
||||
-
|
||||
+ psmouse_set_state(psmouse, PSMOUSE_ACTIVATED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -314,9 +419,50 @@ static int byd_reconnect(struct psmouse *psmouse)
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static void byd_disconnect(struct psmouse *psmouse)
|
||||
+{
|
||||
+ struct byd_data *priv = psmouse->private;
|
||||
+
|
||||
+ if (priv) {
|
||||
+ del_timer(&priv->timer);
|
||||
+ kfree(psmouse->private);
|
||||
+ psmouse->private = NULL;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+int byd_detect(struct psmouse *psmouse, bool set_properties)
|
||||
+{
|
||||
+ struct ps2dev *ps2dev = &psmouse->ps2dev;
|
||||
+ u8 param[4] = {0x03, 0x00, 0x00, 0x00};
|
||||
+
|
||||
+ if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
|
||||
+ return -1;
|
||||
+ if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
|
||||
+ return -1;
|
||||
+ if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
|
||||
+ return -1;
|
||||
+ if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES))
|
||||
+ return -1;
|
||||
+ if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO))
|
||||
+ return -1;
|
||||
+
|
||||
+ if (param[1] != 0x03 || param[2] != 0x64)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
+ psmouse_dbg(psmouse, "BYD touchpad detected\n");
|
||||
+
|
||||
+ if (set_properties) {
|
||||
+ psmouse->vendor = "BYD";
|
||||
+ psmouse->name = "TouchPad";
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
int byd_init(struct psmouse *psmouse)
|
||||
{
|
||||
struct input_dev *dev = psmouse->dev;
|
||||
+ struct byd_data *priv;
|
||||
|
||||
if (psmouse_reset(psmouse))
|
||||
return -EIO;
|
||||
@@ -324,14 +470,39 @@ int byd_init(struct psmouse *psmouse)
|
||||
if (byd_reset_touchpad(psmouse))
|
||||
return -EIO;
|
||||
|
||||
+ priv = kzalloc(sizeof(*priv), GFP_KERNEL);
|
||||
+ if (!priv)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ memset(priv, 0, sizeof(*priv));
|
||||
+ setup_timer(&priv->timer, byd_clear_touch, (unsigned long) psmouse);
|
||||
+
|
||||
+ psmouse->private = priv;
|
||||
+ psmouse->disconnect = byd_disconnect;
|
||||
psmouse->reconnect = byd_reconnect;
|
||||
psmouse->protocol_handler = byd_process_byte;
|
||||
psmouse->pktsize = 4;
|
||||
psmouse->resync_time = 0;
|
||||
|
||||
- __set_bit(BTN_MIDDLE, dev->keybit);
|
||||
- __set_bit(REL_WHEEL, dev->relbit);
|
||||
- __set_bit(REL_HWHEEL, dev->relbit);
|
||||
+ __set_bit(INPUT_PROP_POINTER, dev->propbit);
|
||||
+ /* Touchpad */
|
||||
+ __set_bit(BTN_TOUCH, dev->keybit);
|
||||
+ __set_bit(BTN_TOOL_FINGER, dev->keybit);
|
||||
+ /* Buttons */
|
||||
+ __set_bit(BTN_LEFT, dev->keybit);
|
||||
+ __set_bit(BTN_RIGHT, dev->keybit);
|
||||
+ __clear_bit(BTN_MIDDLE, dev->keybit);
|
||||
+
|
||||
+ /* Absolute position */
|
||||
+ __set_bit(EV_ABS, dev->evbit);
|
||||
+ input_set_abs_params(dev, ABS_X, 0, BYD_PAD_WIDTH, 0, 0);
|
||||
+ input_set_abs_params(dev, ABS_Y, 0, BYD_PAD_HEIGHT, 0, 0);
|
||||
+ input_abs_set_res(dev, ABS_X, BYD_PAD_RESOLUTION);
|
||||
+ input_abs_set_res(dev, ABS_Y, BYD_PAD_RESOLUTION);
|
||||
+ /* No relative support */
|
||||
+ __clear_bit(EV_REL, dev->evbit);
|
||||
+ __clear_bit(REL_X, dev->relbit);
|
||||
+ __clear_bit(REL_Y, dev->relbit);
|
||||
|
||||
return 0;
|
||||
}
|
||||
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
|
||||
index 39d1bec..5784e20 100644
|
||||
--- a/drivers/input/mouse/psmouse-base.c
|
||||
+++ b/drivers/input/mouse/psmouse-base.c
|
||||
@@ -846,7 +846,7 @@ static const struct psmouse_protocol psmouse_protocols[] = {
|
||||
#ifdef CONFIG_MOUSE_PS2_BYD
|
||||
{
|
||||
.type = PSMOUSE_BYD,
|
||||
- .name = "BydPS/2",
|
||||
+ .name = "BYDPS/2",
|
||||
.alias = "byd",
|
||||
.detect = byd_detect,
|
||||
.init = byd_init,
|
||||
--
|
||||
2.5.5
|
||||
|
@ -1,32 +0,0 @@
|
||||
From 5ad629a82de37cbcaffc17861e07b5ec68ab75f4 Mon Sep 17 00:00:00 2001
|
||||
From: Vladimir Zapolskiy <vz@mleia.com>
|
||||
Date: Tue, 26 Apr 2016 09:50:31 -0700
|
||||
Subject: [PATCH] Input: byd - don't wipe dynamically allocated memory twice
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Since memory for a private data is allocated by kzalloc() there is no
|
||||
need to fill it with zeroes immediately after the allocation.
|
||||
|
||||
Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
|
||||
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
|
||||
---
|
||||
drivers/input/mouse/byd.c | 1 -
|
||||
1 file changed, 1 deletion(-)
|
||||
|
||||
diff --git a/drivers/input/mouse/byd.c b/drivers/input/mouse/byd.c
|
||||
index fdc243c..ec73f75 100644
|
||||
--- a/drivers/input/mouse/byd.c
|
||||
+++ b/drivers/input/mouse/byd.c
|
||||
@@ -474,7 +474,6 @@ int byd_init(struct psmouse *psmouse)
|
||||
if (!priv)
|
||||
return -ENOMEM;
|
||||
|
||||
- memset(priv, 0, sizeof(*priv));
|
||||
setup_timer(&priv->timer, byd_clear_touch, (unsigned long) psmouse);
|
||||
|
||||
psmouse->private = priv;
|
||||
--
|
||||
2.5.5
|
||||
|
@ -1,35 +0,0 @@
|
||||
From 82aaa086019ce0e6fcd3a44c0a2e4329afe988b6 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Diamand <chris@diamand.org>
|
||||
Date: Mon, 9 May 2016 09:30:39 -0700
|
||||
Subject: [PATCH] Input: byd - update copyright header
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
As pointed out by Richard, the changes to the comment got missed off
|
||||
the absolute mode patch somehow.
|
||||
|
||||
Signed-off-by: Chris Diamand <chris@diamand.org>
|
||||
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
|
||||
---
|
||||
drivers/input/mouse/byd.c | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/drivers/input/mouse/byd.c b/drivers/input/mouse/byd.c
|
||||
index fdc243c..e583f8b 100644
|
||||
--- a/drivers/input/mouse/byd.c
|
||||
+++ b/drivers/input/mouse/byd.c
|
||||
@@ -2,6 +2,10 @@
|
||||
* BYD TouchPad PS/2 mouse driver
|
||||
*
|
||||
* Copyright (C) 2015 Chris Diamand <chris@diamand.org>
|
||||
+ * Copyright (C) 2015 Richard Pospesel
|
||||
+ * Copyright (C) 2015 Tai Chi Minh Ralph Eastwood
|
||||
+ * Copyright (C) 2015 Martin Wimpress
|
||||
+ * Copyright (C) 2015 Jay Kuri
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 as published by
|
||||
--
|
||||
2.5.5
|
||||
|
@ -32,9 +32,9 @@ index 9f42526..85b71f5 100644
|
||||
+MODULE_PARM_DESC(no_part_scan, "When adding block devices, always mark them as not to be scanned for partitions");
|
||||
+
|
||||
/**
|
||||
* add_disk - add partitioning information to kernel list
|
||||
* @disk: per-device partitioning information
|
||||
@@ -587,6 +596,9 @@ void add_disk(struct gendisk *disk)
|
||||
* device_add_disk - add partitioning information to kernel list
|
||||
* @parent: parent device for the disk
|
||||
@@ -587,6 +596,9 @@ void device_add_disk(struct device *parent, struct gendisk *disk)
|
||||
dev_t devt;
|
||||
int retval;
|
||||
|
||||
|
@ -1,17 +0,0 @@
|
||||
vhci_get_frame_number is called really often for USB cameras and this message
|
||||
alone is responsible for major performance drop. Since the driver seems to
|
||||
function ok, simply disable the message for now.
|
||||
|
||||
diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
|
||||
index 7fbe19d..313a79b 100644
|
||||
--- a/drivers/usb/usbip/vhci_hcd.c
|
||||
+++ b/drivers/usb/usbip/vhci_hcd.c
|
||||
@@ -928,7 +928,7 @@ static void vhci_stop(struct usb_hcd *hcd)
|
||||
|
||||
static int vhci_get_frame_number(struct usb_hcd *hcd)
|
||||
{
|
||||
- pr_err("Not yet implemented\n");
|
||||
+ //pr_err("Not yet implemented\n");
|
||||
return 0;
|
||||
}
|
||||
|
@ -16,8 +16,8 @@ index 9a7946c..28d6765 100644
|
||||
|
||||
# actual build commands
|
||||
quiet_cmd_vdso32ld = VDSO32L $@
|
||||
- cmd_vdso32ld = $(CROSS32CC) $(c_flags) -Wl,-T $^ -o $@
|
||||
+ cmd_vdso32ld = $(CROSS32CC) $(c_flags) -Wl,-T $^ -o $@ \
|
||||
- cmd_vdso32ld = $(CROSS32CC) $(c_flags) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^)
|
||||
+ cmd_vdso32ld = $(CROSS32CC) $(c_flags) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) \
|
||||
+ $(if $(AFTER_LINK),; $(AFTER_LINK))
|
||||
quiet_cmd_vdso32as = VDSO32A $@
|
||||
cmd_vdso32as = $(CROSS32CC) $(a_flags) -c -o $@ $<
|
||||
@ -30,8 +30,8 @@ index 8c500d8..d27737b 100644
|
||||
|
||||
# actual build commands
|
||||
quiet_cmd_vdso64ld = VDSO64L $@
|
||||
- cmd_vdso64ld = $(CC) $(c_flags) -Wl,-T $^ -o $@
|
||||
+ cmd_vdso64ld = $(CC) $(c_flags) -Wl,-T $^ -o $@ \
|
||||
- cmd_vdso64ld = $(CC) $(c_flags) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^)
|
||||
+ cmd_vdso64ld = $(CC) $(c_flags) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) \
|
||||
+ $(if $(AFTER_LINK),; $(AFTER_LINK))
|
||||
quiet_cmd_vdso64as = VDSO64A $@
|
||||
cmd_vdso64as = $(CC) $(a_flags) -c -o $@ $<
|
||||
|
@ -1,54 +0,0 @@
|
||||
From 3a0d57b60a61eb461504f8ed1845afd5084b7889 Mon Sep 17 00:00:00 2001
|
||||
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
|
||||
Date: Wed, 3 Feb 2016 16:39:21 -0500
|
||||
Subject: [PATCH 3/4] xen/pcifront: Report the errors better.
|
||||
|
||||
The messages should be different depending on the type of error.
|
||||
|
||||
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
|
||||
---
|
||||
arch/x86/include/asm/xen/pci.h | 4 ++--
|
||||
arch/x86/pci/xen.c | 5 ++++-
|
||||
2 files changed, 6 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/arch/x86/include/asm/xen/pci.h b/arch/x86/include/asm/xen/pci.h
|
||||
index 968d57d..f320ee3 100644
|
||||
--- a/arch/x86/include/asm/xen/pci.h
|
||||
+++ b/arch/x86/include/asm/xen/pci.h
|
||||
@@ -57,7 +57,7 @@ static inline int xen_pci_frontend_enable_msi(struct pci_dev *dev,
|
||||
{
|
||||
if (xen_pci_frontend && xen_pci_frontend->enable_msi)
|
||||
return xen_pci_frontend->enable_msi(dev, vectors);
|
||||
- return -ENODEV;
|
||||
+ return -ENOSYS;
|
||||
}
|
||||
static inline void xen_pci_frontend_disable_msi(struct pci_dev *dev)
|
||||
{
|
||||
@@ -69,7 +69,7 @@ static inline int xen_pci_frontend_enable_msix(struct pci_dev *dev,
|
||||
{
|
||||
if (xen_pci_frontend && xen_pci_frontend->enable_msix)
|
||||
return xen_pci_frontend->enable_msix(dev, vectors, nvec);
|
||||
- return -ENODEV;
|
||||
+ return -ENOSYS;
|
||||
}
|
||||
static inline void xen_pci_frontend_disable_msix(struct pci_dev *dev)
|
||||
{
|
||||
diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c
|
||||
index ff31ab4..beac4df 100644
|
||||
--- a/arch/x86/pci/xen.c
|
||||
+++ b/arch/x86/pci/xen.c
|
||||
@@ -196,7 +196,10 @@ static int xen_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
|
||||
return 0;
|
||||
|
||||
error:
|
||||
- dev_err(&dev->dev, "Xen PCI frontend has not registered MSI/MSI-X support!\n");
|
||||
+ if (ret == -ENOSYS)
|
||||
+ dev_err(&dev->dev, "Xen PCI frontend has not registered MSI/MSI-X support!\n");
|
||||
+ else if (ret)
|
||||
+ dev_err(&dev->dev, "Xen PCI frontend error: %d!\n", ret);
|
||||
free:
|
||||
kfree(v);
|
||||
return ret;
|
||||
--
|
||||
2.1.0
|
||||
|
@ -5,13 +5,13 @@ index 4e86393..34493d7 100644
|
||||
@@ -1188,6 +1188,7 @@ static void blkfront_connect(struct blkfront_info *info)
|
||||
unsigned int physical_sector_size;
|
||||
unsigned int binfo;
|
||||
int err;
|
||||
int err, i;
|
||||
+ int removable;
|
||||
|
||||
switch (info->connected) {
|
||||
case BLKIF_STATE_CONNECTED:
|
||||
@@ -1266,6 +1266,12 @@ static void blkfront_connect(struct blkfront_info *info)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
+ err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
|
||||
|
@ -34,19 +34,19 @@ index 2fee2ee..5d7eb04 100644
|
||||
+ struct blkif_response bret;
|
||||
RING_IDX i, rp;
|
||||
unsigned long flags;
|
||||
struct blkfront_info *info = (struct blkfront_info *)dev_id;
|
||||
struct blkfront_ring_info *rinfo = (struct blkfront_ring_info *)dev_id;
|
||||
@@ -1316,8 +1316,8 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id)
|
||||
for (i = info->ring.rsp_cons; i != rp; i++) {
|
||||
for (i = rinfo->ring.rsp_cons; i != rp; i++) {
|
||||
unsigned long id;
|
||||
|
||||
- bret = RING_GET_RESPONSE(&info->ring, i);
|
||||
- bret = RING_GET_RESPONSE(&rinfo->ring, i);
|
||||
- id = bret->id;
|
||||
+ RING_COPY_RESPONSE(&info->ring, i, &bret);
|
||||
+ RING_COPY_RESPONSE(&rinfo->ring, i, &bret);
|
||||
+ id = bret.id;
|
||||
/*
|
||||
* The backend has messed up and given us an id that we would
|
||||
* never have given to it (we stamp it up to BLK_RING_SIZE -
|
||||
@@ -1325,29 +1325,29 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id)
|
||||
@@ -1325,35 +1325,35 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id)
|
||||
*/
|
||||
if (id >= BLK_RING_SIZE(info)) {
|
||||
WARN(1, "%s: response to %s has incorrect id (%ld)\n",
|
||||
@ -56,14 +56,20 @@ index 2fee2ee..5d7eb04 100644
|
||||
* the id is busted. */
|
||||
continue;
|
||||
}
|
||||
req = info->shadow[id].request;
|
||||
req = rinfo->shadow[id].request;
|
||||
|
||||
- if (bret->operation != BLKIF_OP_DISCARD)
|
||||
- blkif_completion(&info->shadow[id], info, bret);
|
||||
+ if (bret.operation != BLKIF_OP_DISCARD)
|
||||
+ blkif_completion(&info->shadow[id], info, &bret);
|
||||
- if (bret->operation != BLKIF_OP_DISCARD) {
|
||||
+ if (bret.operation != BLKIF_OP_DISCARD) {
|
||||
/*
|
||||
* We may need to wait for an extra response if the
|
||||
* I/O request is split in 2
|
||||
*/
|
||||
- if (!blkif_completion(&id, rinfo, bret))
|
||||
+ if (!blkif_completion(&id, rinfo, &bret))
|
||||
continue;
|
||||
}
|
||||
|
||||
if (add_id_to_freelist(info, id)) {
|
||||
if (add_id_to_freelist(rinfo, id)) {
|
||||
WARN(1, "%s: response to %s (id %ld) couldn't be recycled!\n",
|
||||
- info->gd->disk_name, op_name(bret->operation), id);
|
||||
+ info->gd->disk_name, op_name(bret.operation), id);
|
||||
@ -97,7 +103,7 @@ index 2fee2ee..5d7eb04 100644
|
||||
}
|
||||
- if (unlikely(bret->status == BLKIF_RSP_ERROR &&
|
||||
+ if (unlikely(bret.status == BLKIF_RSP_ERROR &&
|
||||
info->shadow[id].req.u.rw.nr_segments == 0)) {
|
||||
rinfo->shadow[id].req.u.rw.nr_segments == 0)) {
|
||||
printk(KERN_WARNING "blkfront: %s: empty %s op failed\n",
|
||||
- info->gd->disk_name, op_name(bret->operation));
|
||||
+ info->gd->disk_name, op_name(bret.operation));
|
||||
|
@ -24,21 +24,41 @@ Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
|
||||
1 file changed, 30 insertions(+), 26 deletions(-)
|
||||
|
||||
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
|
||||
index 5d7eb04..514cf18 100644
|
||||
index e99ea22..7191800 100644
|
||||
--- a/drivers/block/xen-blkfront.c
|
||||
+++ b/drivers/block/xen-blkfront.c
|
||||
@@ -463,27 +463,29 @@ static int blkif_ioctl(struct block_devi
|
||||
static int blkif_queue_discard_req(struct request *req)
|
||||
@@ -520,19 +520,16 @@ static int blkif_ioctl(struct block_device *bdev, fmode_t mode,
|
||||
|
||||
static unsigned long blkif_ring_get_request(struct blkfront_ring_info *rinfo,
|
||||
struct request *req,
|
||||
- struct blkif_request **ring_req)
|
||||
+ struct blkif_request *ring_req)
|
||||
{
|
||||
struct blkfront_info *info = req->rq_disk->private_data;
|
||||
unsigned long id;
|
||||
|
||||
- *ring_req = RING_GET_REQUEST(&rinfo->ring, rinfo->ring.req_prod_pvt);
|
||||
- rinfo->ring.req_prod_pvt++;
|
||||
-
|
||||
id = get_id_from_freelist(rinfo);
|
||||
rinfo->shadow[id].request = req;
|
||||
rinfo->shadow[id].status = REQ_WAITING;
|
||||
rinfo->shadow[id].associated_id = NO_ASSOCIATED_ID;
|
||||
|
||||
- (*ring_req)->u.rw.id = id;
|
||||
+ ring_req->u.rw.id = id;
|
||||
|
||||
return id;
|
||||
}
|
||||
@@ -540,23 +537,28 @@ static unsigned long blkif_ring_get_request(struct blkfront_ring_info *rinfo,
|
||||
static int blkif_queue_discard_req(struct request *req, struct blkfront_ring_info *rinfo)
|
||||
{
|
||||
struct blkfront_info *info = rinfo->dev_info;
|
||||
- struct blkif_request *ring_req;
|
||||
+ struct blkif_request ring_req = { };
|
||||
+ struct blkif_request ring_req = { 0 };
|
||||
unsigned long id;
|
||||
|
||||
/* Fill out a communications ring structure. */
|
||||
- ring_req = RING_GET_REQUEST(&info->ring, info->ring.req_prod_pvt);
|
||||
id = get_id_from_freelist(info);
|
||||
info->shadow[id].request = req;
|
||||
id = blkif_ring_get_request(rinfo, req, &ring_req);
|
||||
|
||||
- ring_req->operation = BLKIF_OP_DISCARD;
|
||||
- ring_req->u.discard.nr_sectors = blk_rq_sectors(req);
|
||||
@ -48,54 +68,37 @@ index 5d7eb04..514cf18 100644
|
||||
+ ring_req.u.discard.nr_sectors = blk_rq_sectors(req);
|
||||
+ ring_req.u.discard.id = id;
|
||||
+ ring_req.u.discard.sector_number = (blkif_sector_t)blk_rq_pos(req);
|
||||
if ((req->cmd_flags & REQ_SECURE) && info->feature_secdiscard)
|
||||
if (req_op(req) == REQ_OP_SECURE_ERASE && info->feature_secdiscard)
|
||||
- ring_req->u.discard.flag = BLKIF_DISCARD_SECURE;
|
||||
+ ring_req.u.discard.flag = BLKIF_DISCARD_SECURE;
|
||||
else
|
||||
- ring_req->u.discard.flag = 0;
|
||||
+ ring_req.u.discard.flag = 0;
|
||||
|
||||
+
|
||||
+ /* make the request available to the backend */
|
||||
+ *RING_GET_REQUEST(&info->ring, info->ring.req_prod_pvt) = ring_req;
|
||||
+ *RING_GET_REQUEST(&rinfo->ring, rinfo->ring.req_prod_pvt) = ring_req;
|
||||
+ wmb();
|
||||
info->ring.req_prod_pvt++;
|
||||
+ rinfo->ring.req_prod_pvt++;
|
||||
|
||||
/* Keep a private copy so we can reissue requests when recovering. */
|
||||
- info->shadow[id].req = *ring_req;
|
||||
+ info->shadow[id].req = ring_req;
|
||||
- rinfo->shadow[id].req = *ring_req;
|
||||
+ rinfo->shadow[id].req = ring_req;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -573,7 +575,7 @@ static void blkif_setup_rw_req_grant(uns
|
||||
static int blkif_queue_rw_req(struct request *req)
|
||||
@@ -688,7 +690,7 @@ static void blkif_setup_extra_req(struct blkif_request *first,
|
||||
static int blkif_queue_rw_req(struct request *req, struct blkfront_ring_info *rinfo)
|
||||
{
|
||||
struct blkfront_info *info = req->rq_disk->private_data;
|
||||
- struct blkif_request *ring_req;
|
||||
+ struct blkif_request ring_req = { };
|
||||
unsigned long id;
|
||||
struct blkfront_info *info = rinfo->dev_info;
|
||||
- struct blkif_request *ring_req, *extra_ring_req = NULL;
|
||||
+ struct blkif_request ring_req = { 0 }, extra_ring_req = { 0 };
|
||||
unsigned long id, extra_id = NO_ASSOCIATED_ID;
|
||||
bool require_extra_req = false;
|
||||
int i;
|
||||
struct setup_rw_req setup = {
|
||||
@@ -435,7 +435,6 @@
|
||||
new_persistent_gnts = 0;
|
||||
|
||||
/* Fill out a communications ring structure. */
|
||||
- ring_req = RING_GET_REQUEST(&info->ring, info->ring.req_prod_pvt);
|
||||
id = get_id_from_freelist(info);
|
||||
info->shadow[id].request = req;
|
||||
|
||||
@@ -632,7 +633,7 @@ static int blkif_queue_rw_req(struct req
|
||||
for_each_sg(info->shadow[id].sg, sg, num_sg, i)
|
||||
num_grant += gnttab_count_grant(sg->offset, sg->length);
|
||||
|
||||
- ring_req->u.rw.id = id;
|
||||
+ ring_req.u.rw.id = id;
|
||||
info->shadow[id].num_sg = num_sg;
|
||||
if (num_grant > BLKIF_MAX_SEGMENTS_PER_REQUEST) {
|
||||
/*
|
||||
@@ -640,16 +641,16 @@ static int blkif_queue_rw_req(struct req
|
||||
@@ -750,16 +752,16 @@ static int blkif_queue_rw_req(struct request *req, struct blkfront_ring_info *ri
|
||||
* BLKIF_OP_WRITE
|
||||
*/
|
||||
BUG_ON(req->cmd_flags & (REQ_FLUSH | REQ_FUA));
|
||||
BUG_ON(req_op(req) == REQ_OP_FLUSH || req->cmd_flags & REQ_FUA);
|
||||
- ring_req->operation = BLKIF_OP_INDIRECT;
|
||||
- ring_req->u.indirect.indirect_op = rq_data_dir(req) ?
|
||||
+ ring_req.operation = BLKIF_OP_INDIRECT;
|
||||
@ -115,47 +118,73 @@ index 5d7eb04..514cf18 100644
|
||||
+ ring_req.u.rw.handle = info->handle;
|
||||
+ ring_req.operation = rq_data_dir(req) ?
|
||||
BLKIF_OP_WRITE : BLKIF_OP_READ;
|
||||
if (req->cmd_flags & (REQ_FLUSH | REQ_FUA)) {
|
||||
if (req_op(req) == REQ_OP_FLUSH || req->cmd_flags & REQ_FUA) {
|
||||
/*
|
||||
@@ -662,21 +663,21 @@ static int blkif_queue_rw_req(struct req
|
||||
switch (info->feature_flush &
|
||||
((REQ_FLUSH|REQ_FUA))) {
|
||||
case REQ_FLUSH|REQ_FUA:
|
||||
@@ -770,15 +772,15 @@ static int blkif_queue_rw_req(struct request *req, struct blkfront_ring_info *ri
|
||||
* since it is guaranteed ordered WRT previous writes.)
|
||||
*/
|
||||
if (info->feature_flush && info->feature_fua)
|
||||
- ring_req->operation =
|
||||
+ ring_req.operation =
|
||||
BLKIF_OP_WRITE_BARRIER;
|
||||
break;
|
||||
case REQ_FLUSH:
|
||||
else if (info->feature_flush)
|
||||
- ring_req->operation =
|
||||
+ ring_req.operation =
|
||||
BLKIF_OP_FLUSH_DISKCACHE;
|
||||
break;
|
||||
default:
|
||||
else
|
||||
- ring_req->operation = 0;
|
||||
+ ring_req.operation = 0;
|
||||
}
|
||||
}
|
||||
- ring_req->u.rw.nr_segments = num_grant;
|
||||
+ ring_req.u.rw.nr_segments = num_grant;
|
||||
if (unlikely(require_extra_req)) {
|
||||
extra_id = blkif_ring_get_request(rinfo, req,
|
||||
&extra_ring_req);
|
||||
@@ -788,7 +790,7 @@ static int blkif_queue_rw_req(struct request *req, struct blkfront_ring_info *ri
|
||||
*/
|
||||
rinfo->shadow[extra_id].num_sg = 0;
|
||||
|
||||
- blkif_setup_extra_req(ring_req, extra_ring_req);
|
||||
+ blkif_setup_extra_req(&ring_req, &extra_ring_req);
|
||||
|
||||
/* Link the 2 requests together */
|
||||
rinfo->shadow[extra_id].associated_id = id;
|
||||
@@ -796,12 +798,12 @@ static int blkif_queue_rw_req(struct request *req, struct blkfront_ring_info *ri
|
||||
}
|
||||
}
|
||||
|
||||
- setup.ring_req = ring_req;
|
||||
+ setup.ring_req = &ring_req;
|
||||
setup.id = id;
|
||||
for_each_sg(info->shadow[id].sg, sg, num_sg, i) {
|
||||
|
||||
setup.require_extra_req = require_extra_req;
|
||||
if (unlikely(require_extra_req))
|
||||
- setup.extra_ring_req = extra_ring_req;
|
||||
+ setup.extra_ring_req = &extra_ring_req;
|
||||
|
||||
for_each_sg(rinfo->shadow[id].sg, sg, num_sg, i) {
|
||||
BUG_ON(sg->offset + sg->length > PAGE_SIZE);
|
||||
@@ -698,10 +699,13 @@ static int blkif_queue_rw_req(struct req
|
||||
@@ -823,10 +825,20 @@ static int blkif_queue_rw_req(struct request *req, struct blkfront_ring_info *ri
|
||||
if (setup.segments)
|
||||
kunmap_atomic(setup.segments);
|
||||
|
||||
+ /* make the request available to the backend */
|
||||
+ *RING_GET_REQUEST(&info->ring, info->ring.req_prod_pvt) = ring_req;
|
||||
+ *RING_GET_REQUEST(&rinfo->ring, rinfo->ring.req_prod_pvt) = ring_req;
|
||||
+ wmb();
|
||||
info->ring.req_prod_pvt++;
|
||||
|
||||
+ rinfo->ring.req_prod_pvt++;
|
||||
/* Keep a private copy so we can reissue requests when recovering. */
|
||||
- info->shadow[id].req = *ring_req;
|
||||
+ info->shadow[id].req = ring_req;
|
||||
- rinfo->shadow[id].req = *ring_req;
|
||||
- if (unlikely(require_extra_req))
|
||||
- rinfo->shadow[extra_id].req = *extra_ring_req;
|
||||
+ rinfo->shadow[id].req = ring_req;
|
||||
+
|
||||
+ if (unlikely(require_extra_req)) {
|
||||
+ *RING_GET_REQUEST(&rinfo->ring, rinfo->ring.req_prod_pvt) = extra_ring_req;
|
||||
+ wmb();
|
||||
+ rinfo->ring.req_prod_pvt++;
|
||||
+ /* Keep a private copy so we can reissue requests when recovering. */
|
||||
+ rinfo->shadow[extra_id].req = extra_ring_req;
|
||||
+ }
|
||||
|
||||
if (new_persistent_gnts)
|
||||
if (max_grefs > 0)
|
||||
gnttab_free_grant_references(setup.gref_head);
|
||||
|
10
series.conf
10
series.conf
@ -5,20 +5,11 @@ patches.xen/xen-netfront-detach-crash.patch
|
||||
patches.xen/0001-mce-hide-EBUSY-initialization-error-on-Xen.patch
|
||||
patches.xen/irq-bind-debug-log.patch
|
||||
|
||||
# Backports
|
||||
patches.backports/0001-HID-fix-out-of-bound-access-in-extract-and-implement.patch
|
||||
# Touchpad driver for Purism laptops
|
||||
patches.backports/0001-Input-byd-add-BYD-PS-2-touchpad-driver.patch
|
||||
patches.backports/0002-Input-byd-enable-absolute-mode.patch
|
||||
patches.backports/0003-Input-byd-don-t-wipe-dynamically-allocated-memory-tw.patch
|
||||
patches.backports/0004-Input-byd-update-copyright-header.patch
|
||||
|
||||
# Additional features
|
||||
#patches.xen/pvops-0100-usb-xen-pvusb-driver.patch
|
||||
patches.xen/pvops-blkfront-removable-flag.patch
|
||||
patches.xen/pvops-blkfront-eject-support.patch
|
||||
|
||||
patches.qubes/usbip-disable-not-implemented-error.patch
|
||||
patches.qubes/0001-block-add-no_part_scan-module-parameter.patch
|
||||
|
||||
# Security fixes
|
||||
@ -30,5 +21,4 @@ patches.xen/xsa155-linux312-0012-xen-blkfront-make-local-copy-of-response-before
|
||||
patches.xen/xsa155-linux44-0013-xen-blkfront-prepare-request-locally-only-then-put-i.patch
|
||||
|
||||
# MSI-X enabled device passthrough fix (#1734)
|
||||
patches.xen/0003-xen-pcifront-Report-the-errors-better.patch
|
||||
patches.xen/pci_op-cleanup.patch
|
||||
|
Loading…
Reference in New Issue
Block a user