Continue to slim down 'wacom_intuos_irq' by moving all decoding and reporting of pen packet data into the 'wacom_intuos_general' function.
NOTE: This patch was backported earlier, but only as far back as 2.6.38. To make backporting the next few patches easier, we complete this backport all the way to 2.6.30. Signed-off-by: Jason Gerecke <jason.gere...@wacom.com> Signed-off-by: Jiri Kosina <jkos...@suse.cz> [jason.gere...@wacom.com: Imported into input-wacom repository (16e0a6a)] Signed-off-by: Jason Gerecke <jason.gere...@wacom.com> [jason.gere...@wacom.com: backported from input-wacom 633f39b] Signed-off-by: Jason Gerecke <jason.gere...@wacom.com> [jason.gere...@wacom.com: backported from input-wacom (bd286ad)] Signed-off-by: Jason Gerecke <jason.gere...@wacom.com> --- 2.6.30/wacom_wac.c | 96 ++++++++++++++++++++++++++---------------------------- 2.6.36/wacom_wac.c | 92 +++++++++++++++++++++++++-------------------------- 2 files changed, 92 insertions(+), 96 deletions(-) diff --git a/2.6.30/wacom_wac.c b/2.6.30/wacom_wac.c index 6ea5aa7..16e6fdd 100644 --- a/2.6.30/wacom_wac.c +++ b/2.6.30/wacom_wac.c @@ -884,6 +884,20 @@ static int wacom_intuos_general(struct wacom_wac *wacom) (features->type == CINTIQ && !(data[1] & 0x40))) return 1; + if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_CINTIQ && + data[0] != WACOM_REPORT_INTUOS_PEN) + return 0; + + if (features->type >= INTUOS3S) { + input_report_abs(input, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1)); + input_report_abs(input, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1)); + input_report_abs(input, ABS_DISTANCE, ((data[9] >> 2) & 0x3f)); + } else { + input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[2])); + input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[4])); + input_report_abs(input, ABS_DISTANCE, ((data[9] >> 3) & 0x1f)); + } + /* general pen packet */ if ((data[1] & 0xb8) == 0xa0) { t = (data[6] << 2) | ((data[7] >> 6) & 3); @@ -908,54 +922,6 @@ static int wacom_intuos_general(struct wacom_wac *wacom) ((data[7] << 1) & 0x7e) | (data[8] >> 7)); input_report_abs(input, ABS_TILT_Y, data[8] & 0x7f); } - return 0; -} - -static int wacom_intuos_irq(struct wacom_wac *wacom) -{ - struct wacom_features *features = &wacom->features; - unsigned char *data = wacom->data; - struct input_dev *input = wacom->input; - unsigned int t; - int idx = 0, result; - - if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_INTUOSREAD - && data[0] != WACOM_REPORT_INTUOSWRITE && data[0] != WACOM_REPORT_INTUOSPAD - && data[0] != WACOM_REPORT_INTUOS_PEN - && data[0] != WACOM_REPORT_CINTIQ && data[0] != WACOM_REPORT_CINTIQPAD - && data[0] != WACOM_REPORT_INTUOS5PAD) { - dbg("wacom_intuos_irq: received unknown report #%d", data[0]); - return 0; - } - - /* tool number */ - if (features->type == INTUOS) - idx = data[1] & 0x01; - - /* process pad events */ - result = wacom_intuos_pad(wacom); - if (result) - return result; - - /* process in/out prox events */ - result = wacom_intuos_inout(wacom); - if (result) - return result - 1; - - /* process general packets */ - result = wacom_intuos_general(wacom); - if (result) - return result - 1; - - if (features->type >= INTUOS3S) { - input_report_abs(input, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1)); - input_report_abs(input, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1)); - input_report_abs(input, ABS_DISTANCE, ((data[9] >> 2) & 0x3f)); - } else { - input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[2])); - input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[4])); - input_report_abs(input, ABS_DISTANCE, ((data[9] >> 3) & 0x1f)); - } /* 4D mouse, 2D mouse, marker pen rotation, tilt mouse, or Lens cursor packets */ if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0 || (data[1] & 0xbc) == 0xac) { @@ -1031,7 +997,39 @@ static int wacom_intuos_irq(struct wacom_wac *wacom) input_report_key(input, wacom->tool[idx], 1); input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]); wacom->reporting_data = true; - return 1; + return 2; +} + +static int wacom_intuos_irq(struct wacom_wac *wacom) +{ + unsigned char *data = wacom->data; + int result; + + if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_INTUOSREAD + && data[0] != WACOM_REPORT_INTUOSWRITE && data[0] != WACOM_REPORT_INTUOSPAD + && data[0] != WACOM_REPORT_INTUOS_PEN + && data[0] != WACOM_REPORT_CINTIQ && data[0] != WACOM_REPORT_CINTIQPAD + && data[0] != WACOM_REPORT_INTUOS5PAD) { + dbg("wacom_intuos_irq: received unknown report #%d", data[0]); + return 0; + } + + /* process pad events */ + result = wacom_intuos_pad(wacom); + if (result) + return result; + + /* process in/out prox events */ + result = wacom_intuos_inout(wacom); + if (result) + return result - 1; + + /* process general packets */ + result = wacom_intuos_general(wacom); + if (result) + return result - 1; + + return 0; } static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len) diff --git a/2.6.36/wacom_wac.c b/2.6.36/wacom_wac.c index 09d187b..2395231 100644 --- a/2.6.36/wacom_wac.c +++ b/2.6.36/wacom_wac.c @@ -681,6 +681,20 @@ static int wacom_intuos_general(struct wacom_wac *wacom) (features->type == CINTIQ && !(data[1] & 0x40))) return 1; + if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_INTUOSREAD && + data[0] != WACOM_REPORT_INTUOSWRITE) + return 0; + + if (features->type >= INTUOS3S) { + input_report_abs(input, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1)); + input_report_abs(input, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1)); + input_report_abs(input, ABS_DISTANCE, ((data[9] >> 2) & 0x3f)); + } else { + input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[2])); + input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[4])); + input_report_abs(input, ABS_DISTANCE, ((data[9] >> 3) & 0x1f)); + } + /* general pen packet */ if ((data[1] & 0xb8) == 0xa0) { t = (data[6] << 2) | ((data[7] >> 6) & 3); @@ -704,52 +718,6 @@ static int wacom_intuos_general(struct wacom_wac *wacom) ((data[7] << 1) & 0x7e) | (data[8] >> 7)); input_report_abs(input, ABS_TILT_Y, data[8] & 0x7f); } - return 0; -} - -static int wacom_intuos_irq(struct wacom_wac *wacom) -{ - struct wacom_features *features = &wacom->features; - unsigned char *data = wacom->data; - struct input_dev *input = wacom->input; - unsigned int t; - int idx = 0, result; - - if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_INTUOSREAD - && data[0] != WACOM_REPORT_INTUOSWRITE && data[0] != WACOM_REPORT_INTUOSPAD - && data[0] != WACOM_REPORT_INTUOS5PAD) { - dbg("wacom_intuos_irq: received unknown report #%d", data[0]); - return 0; - } - - /* tool number */ - if (features->type == INTUOS) - idx = data[1] & 0x01; - - /* process pad events */ - result = wacom_intuos_pad(wacom); - if (result) - return result; - - /* process in/out prox events */ - result = wacom_intuos_inout(wacom); - if (result) - return result - 1; - - /* process general packets */ - result = wacom_intuos_general(wacom); - if (result) - return result - 1; - - if (features->type >= INTUOS3S) { - input_report_abs(input, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1)); - input_report_abs(input, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1)); - input_report_abs(input, ABS_DISTANCE, ((data[9] >> 2) & 0x3f)); - } else { - input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[2])); - input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[4])); - input_report_abs(input, ABS_DISTANCE, ((data[9] >> 3) & 0x1f)); - } /* 4D mouse, 2D mouse, marker pen rotation, tilt mouse, or Lens cursor packets */ if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0 || (data[1] & 0xbc) == 0xac) { @@ -825,7 +793,37 @@ static int wacom_intuos_irq(struct wacom_wac *wacom) input_report_key(input, wacom->tool[idx], 1); input_event(input, EV_MSC, MSC_SERIAL, wacom->serial[idx]); wacom->reporting_data = true; - return 1; + return 2; +} + +static int wacom_intuos_irq(struct wacom_wac *wacom) +{ + unsigned char *data = wacom->data; + int result; + + if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_INTUOSREAD + && data[0] != WACOM_REPORT_INTUOSWRITE && data[0] != WACOM_REPORT_INTUOSPAD + && data[0] != WACOM_REPORT_INTUOS5PAD) { + dbg("wacom_intuos_irq: received unknown report #%d", data[0]); + return 0; + } + + /* process pad events */ + result = wacom_intuos_pad(wacom); + if (result) + return result; + + /* process in/out prox events */ + result = wacom_intuos_inout(wacom); + if (result) + return result - 1; + + /* process general packets */ + result = wacom_intuos_general(wacom); + if (result) + return result - 1; + + return 0; } static int wacom_mt_touch(struct wacom_wac *wacom) -- 2.10.2 ------------------------------------------------------------------------------ _______________________________________________ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel