From 4e9ef6f50ac1df020d572924dd57304655fb535d Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Wed, 8 Oct 2008 23:18:49 +0200 Subject: bcm5974 (0.51) unstable; urgency=low * Fine-tuned signal-to-noise ratio, smoother mouse motion. * Interrupt code got minor simplifications. * GFP_ATOMIC completetly removed. -- Henrik Rydberg Mon, 07 Jul 2008 18:09:39 +0200 --- CHANGES | 62 ++++++++++++++++++++++++++++++++++ bcm5974.c | 114 ++++++++++++++++++++++++++++---------------------------------- dkms.conf | 2 +- 3 files changed, 114 insertions(+), 64 deletions(-) create mode 100644 CHANGES diff --git a/CHANGES b/CHANGES new file mode 100644 index 0000000..cd46743 --- /dev/null +++ b/CHANGES @@ -0,0 +1,62 @@ +07JUL2008 version 0.51 +---------------------- + +Fine-tuned signal-to-noise ratio, smoother mouse motion. +Interrupt code got minor simplifications. +GFP_ATOMIC completetly removed. + +06JUL2008 version 0.5 +---------------------- + +Working palm detection, changes for kernel.org, dkms introduced. + +01JUL2008 version 0.42 +---------------------- + +First button click registered, pre/post-reset added. + +29JUN2008 version 0.41 +---------------------- + +The reset_resume kernel function added. + +29JUN2008 version 0.4 +---------------------- + +Both finger pressure and width reported. + +27JUN2008 version 0.31 +---------------------- + +Administrative changes for kernel.org. + +27JUN2008 version 0.3 +---------------------- + +Explicit device structure, use all packages. + +27JUN2008 version 0.23 +---------------------- + +Finger release not reported properly. + +26JUN2008 version 0.22 +---------------------- + +ABS coordinates more stable with synaptics. + +25JUN2008 version 0.21 +---------------------- + +Fixed the relative coordinate scaling. + +25JUN2008 version 0.2 +---------------------- + +Misinterpreted pressure input, noise reduction. + +24JUN2008 version 0.1 +---------------------- + +First version. + diff --git a/bcm5974.c b/bcm5974.c index a7f070f..bc00a38 100644 --- a/bcm5974.c +++ b/bcm5974.c @@ -127,6 +127,7 @@ struct tp_data { /* device-specific parameters */ struct atp_params { int dim; /* logical dimension */ + int fuzz; /* logical noise value */ int devmin; /* device minimum reading */ int devmax; /* device maximum reading */ }; @@ -144,15 +145,6 @@ struct atp_config { struct atp_params y; /* vertical limits */ }; -/* logical trackpad state */ -struct tp_state { - int pressure; /* finger pressure value */ - int width; /* finger width value */ - int abs_x; /* absolute x coordinate */ - int abs_y; /* absolute y coordinate */ - int fingers; /* number of fingers on trackpad */ -}; - /* logical device structure */ struct atp { char phys[64]; @@ -163,11 +155,8 @@ struct atp { int suspended; /* >0: suspended, else open */ struct urb *bt_urb; /* button usb request block */ struct bt_data *bt_data; /* button transferred data */ - unsigned bt_prev_state; /* logical button previous state */ - unsigned bt_state; /* logical button state */ struct urb *tp_urb; /* trackpad usb request block */ struct tp_data *tp_data; /* trackpad transferred data */ - struct tp_state tp_state; /* logical trackpad state */ unsigned tp_valid; /* trackpad sensors valid */ }; @@ -176,7 +165,11 @@ struct atp { #define DIM_WIDTH 16 /* maximum finger width */ #define DIM_X 1280 /* maximum trackpad x value */ #define DIM_Y 800 /* maximum trackpad y value */ -#define SNRATIO 50 /* signal to noise ratio */ + +/* logical signal quality */ +#define SN_PRESSURE 40 /* pressure signal-to-noise ratio */ +#define SN_WIDTH 100 /* width signal-to-noise ratio */ +#define SN_COORD 250 /* coordinate signal-to-noise ratio */ /* device constants */ static const struct atp_config atp_config_table[] = { @@ -186,10 +179,10 @@ static const struct atp_config atp_config_table[] = { ATP_WELLSPRING_JIS, 0x84, sizeof(struct bt_data), 0x81, sizeof(struct tp_data), - { DIM_PRESSURE, 0, 256 }, - { DIM_WIDTH, 0, 2048 }, - { DIM_X, -4824, 5342 }, - { DIM_Y, -172, 5820 } + { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 256 }, + { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 }, + { DIM_X, DIM_X / SN_COORD, -4824, 5342 }, + { DIM_Y, DIM_Y / SN_COORD, -172, 5820 } }, { ATP_WELLSPRING2_ANSI, @@ -197,10 +190,10 @@ static const struct atp_config atp_config_table[] = { ATP_WELLSPRING2_JIS, 0x84, sizeof(struct bt_data), 0x81, sizeof(struct tp_data), - { DIM_PRESSURE, 0, 256 }, - { DIM_WIDTH, 0, 2048 }, - { DIM_X, -4824, 5342 }, - { DIM_Y, -172, 5820 } + { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 256 }, + { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 }, + { DIM_X, DIM_X / SN_COORD, -4824, 5342 }, + { DIM_Y, DIM_Y / SN_COORD, -172, 5820 } }, {} }; @@ -236,45 +229,52 @@ static inline int int2bound(const struct atp_params *p, int x) return s < 0 ? 0 : s >= p->dim ? p->dim - 1 : s; } -/* convert button data to logical button state */ -static int compute_bt_state(struct atp *dev, int size) +/* report button data as logical button state */ +static int report_bt_state(struct atp *dev, int size) { if (size != sizeof(struct bt_data)) return -EIO; - dev->bt_prev_state = dev->bt_state; - dev->bt_state = dev->bt_data->button; + input_report_key(dev->input, BTN_LEFT, dev->bt_data->button); return 0; } -/* convert trackpad data to logical trackpad state */ -static int compute_tp_state(struct atp *dev, int size) +/* report trackpad data as logical trackpad state */ +static int report_tp_state(struct atp *dev, int size) { const struct atp_config *c = &dev->cfg; const struct tp_finger *f = dev->tp_data->finger; const int fingers = (size - 26) / 28; - struct tp_state *s = &dev->tp_state; + int p, w, x, y, n; if (size < 26 || (size - 26) % 28 != 0) return -EIO; if (!fingers) { - s->pressure = 0; - s->fingers = 0; + input_report_abs(dev->input, ABS_PRESSURE, 0); + input_report_key(dev->input, BTN_TOOL_FINGER, false); + input_report_key(dev->input, BTN_TOOL_DOUBLETAP, false); + input_report_key(dev->input, BTN_TOOL_TRIPLETAP, false); return 0; } - dprintk(9, "bcm5974: p: %+05d w: %+05d x: %+05d y: %+05d f: %d\n", - raw2int(f->force_major), raw2int(f->size_major), - raw2int(f->abs_x), raw2int(f->abs_y), fingers); - - s->pressure = int2bound(&c->p, raw2int(f->force_major)); - s->width = int2bound(&c->w, raw2int(f->size_major)); - s->abs_x = int2bound(&c->x, raw2int(f->abs_x) - c->x.devmin); - s->abs_y = int2bound(&c->y, c->y.devmax - raw2int(f->abs_y)); - s->fingers = s->pressure > 0 ? fingers : 0; - + p = raw2int(f->force_major); + w = raw2int(f->size_major); + x = raw2int(f->abs_x); + y = raw2int(f->abs_y); + n = p > 0 ? fingers : 0; + + dprintk(9, "bcm5974: p: %+05d w: %+05d x: %+05d y: %+05d n: %d\n", + p, w, x, y, n); + + input_report_abs(dev->input, ABS_PRESSURE, int2bound(&c->p, p)); + input_report_abs(dev->input, ABS_TOOL_WIDTH, int2bound(&c->w, w)); + input_report_abs(dev->input, ABS_X, int2bound(&c->x, x - c->x.devmin)); + input_report_abs(dev->input, ABS_Y, int2bound(&c->y, c->y.devmax - y)); + input_report_key(dev->input, BTN_TOOL_FINGER, n == 1); + input_report_key(dev->input, BTN_TOOL_DOUBLETAP, n == 2); + input_report_key(dev->input, BTN_TOOL_TRIPLETAP, n > 2); return 0; } @@ -376,20 +376,16 @@ static void irq_button(struct urb *urb) goto exit; } - if (compute_bt_state(dev, dev->bt_urb->actual_length)) { + if (report_bt_state(dev, dev->bt_urb->actual_length)) { dprintk(1, "bcm5974: bad button package, length: %d)\n", dev->bt_urb->actual_length); goto exit; } - /* only report button state changes */ - if (dev->bt_state != dev->bt_prev_state) { - input_report_key(dev->input, BTN_LEFT, dev->bt_data->button); - input_sync(dev->input); - } + input_sync(dev->input); exit: - error = usb_submit_urb(dev->bt_urb, GFP_ATOMIC); + error = usb_submit_urb(dev->bt_urb, GFP_KERNEL); if (error) err("bcm5974: button urb failed: %d", error); } @@ -397,7 +393,6 @@ exit: static void irq_trackpad(struct urb *urb) { struct atp *dev = urb->context; - struct tp_state *state = &dev->tp_state; int error; switch (urb->status) { @@ -420,23 +415,16 @@ static void irq_trackpad(struct urb *urb) goto exit; } - if (compute_tp_state(dev, dev->tp_urb->actual_length)) { + if (report_tp_state(dev, dev->tp_urb->actual_length)) { dprintk(1, "bcm5974: bad trackpad package, length: %d)\n", dev->tp_urb->actual_length); goto exit; } - input_report_abs(dev->input, ABS_PRESSURE, state->pressure); - input_report_abs(dev->input, ABS_TOOL_WIDTH, state->width); - input_report_abs(dev->input, ABS_X, state->abs_x); - input_report_abs(dev->input, ABS_Y, state->abs_y); - input_report_key(dev->input, BTN_TOOL_FINGER, state->fingers == 1); - input_report_key(dev->input, BTN_TOOL_DOUBLETAP, state->fingers == 2); - input_report_key(dev->input, BTN_TOOL_TRIPLETAP, state->fingers > 2); input_sync(dev->input); exit: - error = usb_submit_urb(dev->tp_urb, GFP_ATOMIC); + error = usb_submit_urb(dev->tp_urb, GFP_KERNEL); if (error) err("bcm5974: trackpad urb failed: %d", error); } @@ -446,9 +434,9 @@ static int atp_open(struct input_dev *input) struct atp *dev = input_get_drvdata(input); if (!dev->open) { - if (usb_submit_urb(dev->bt_urb, GFP_ATOMIC)) + if (usb_submit_urb(dev->bt_urb, GFP_KERNEL)) goto error; - if (usb_submit_urb(dev->tp_urb, GFP_ATOMIC)) + if (usb_submit_urb(dev->tp_urb, GFP_KERNEL)) goto err_free_bt_urb; } @@ -557,13 +545,13 @@ static int atp_probe(struct usb_interface *iface, set_bit(EV_ABS, input_dev->evbit); input_set_abs_params(input_dev, ABS_PRESSURE, - 0, cfg->p.dim, cfg->p.dim / SNRATIO, 0); + 0, cfg->p.dim, cfg->p.fuzz, 0); input_set_abs_params(input_dev, ABS_TOOL_WIDTH, - 0, cfg->w.dim, cfg->w.dim / SNRATIO, 0); + 0, cfg->w.dim, cfg->w.fuzz, 0); input_set_abs_params(input_dev, ABS_X, - 0, cfg->x.dim, cfg->x.dim / SNRATIO, 0); + 0, cfg->x.dim, cfg->x.fuzz, 0); input_set_abs_params(input_dev, ABS_Y, - 0, cfg->y.dim, cfg->y.dim / SNRATIO, 0); + 0, cfg->y.dim, cfg->y.fuzz, 0); set_bit(EV_KEY, input_dev->evbit); set_bit(BTN_TOOL_FINGER, input_dev->keybit); diff --git a/dkms.conf b/dkms.conf index 89d112e..615cc69 100644 --- a/dkms.conf +++ b/dkms.conf @@ -1,5 +1,5 @@ PACKAGE_NAME="bcm5974" -PACKAGE_VERSION="0.5" +PACKAGE_VERSION="0.51" MAKE[0]="make -C ${kernel_source_dir} SUBDIRS=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build modules" BUILT_MODULE_NAME[0]="bcm5974" -- cgit v1.2.3