aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hid-tmt300rs.c29
-rw-r--r--hid-tmt300rs.h177
2 files changed, 101 insertions, 105 deletions
diff --git a/hid-tmt300rs.c b/hid-tmt300rs.c
index 3764fc8..0ee8a5d 100644
--- a/hid-tmt300rs.c
+++ b/hid-tmt300rs.c
@@ -115,7 +115,7 @@ static void t300rs_fill_envelope(struct t300rs_packet_envelope *packet_envelope,
static void t300rs_fill_timing(struct t300rs_packet_timing *packet_timing,
uint16_t duration, uint16_t offset){
- packet_timing->start_marker = 0x47;
+ packet_timing->start_marker = 0x4f;
packet_timing->duration = cpu_to_le16(duration);
packet_timing->offset = cpu_to_le16(offset);
@@ -207,8 +207,7 @@ static int t300rs_modify_duration(struct t300rs_device_entry *t300rs,
struct ff_effect old = state->old;
struct t300rs_packet_mod_duration {
struct t300rs_packet_header header;
- padding: 8;
- uint8_t marker;
+ uint16_t marker;
uint16_t duration;
} *packet_mod_duration = (struct t300rs_packet_mod_duration *)t300rs->send_buffer;
@@ -220,7 +219,7 @@ static int t300rs_modify_duration(struct t300rs_device_entry *t300rs,
if (effect.replay.length != old.replay.length) {
t300rs_fill_header(&packet_mod_duration->header, effect.id, 0x49);
- packet_mod_duration->marker = 0x41;
+ packet_mod_duration->marker = cpu_to_le16(0x4100);
packet_mod_duration->duration = cpu_to_le16(duration);
ret = t300rs_send_int(t300rs);
@@ -547,6 +546,7 @@ static int t300rs_upload_constant(struct t300rs_device_entry *t300rs,
struct t300rs_packet_header header;
uint16_t level;
struct t300rs_packet_envelope envelope;
+ uint8_t zero;
struct t300rs_packet_timing timing;
} *packet_constant = (struct t300rs_packet_constant *)t300rs->send_buffer;
@@ -562,7 +562,7 @@ static int t300rs_upload_constant(struct t300rs_device_entry *t300rs,
*/
if (test_bit(FF_EFFECT_PLAYING, &state->flags)
- && test_bit(FF_EFFECT_QUEUE_UPDATE, &state->flags)) {
+ && test_bit(FF_EFFECT_QUEUE_UPDATE, &state->flags)) {
__clear_bit(FF_EFFECT_QUEUE_UPLOAD, &state->flags);
@@ -598,10 +598,11 @@ static int t300rs_upload_ramp(struct t300rs_device_entry *t300rs,
struct t300rs_packet_header header;
uint16_t difference;
uint16_t level;
+ uint8_t zero1[2];
uint16_t duration;
- uint8_t marker;
- uint8_t direction;
+ uint16_t marker;
struct t300rs_packet_envelope envelope;
+ uint8_t direction;
struct t300rs_packet_timing timing;
} *packet_ramp = (struct t300rs_packet_ramp *)t300rs->send_buffer;
@@ -610,7 +611,7 @@ static int t300rs_upload_ramp(struct t300rs_device_entry *t300rs,
int16_t level;
if (test_bit(FF_EFFECT_PLAYING, &state->flags)
- && test_bit(FF_EFFECT_QUEUE_UPDATE, &state->flags)) {
+ && test_bit(FF_EFFECT_QUEUE_UPDATE, &state->flags)) {
__clear_bit(FF_EFFECT_QUEUE_UPLOAD, &state->flags);
@@ -634,7 +635,7 @@ static int t300rs_upload_ramp(struct t300rs_device_entry *t300rs,
packet_ramp->level = cpu_to_le16(level);
packet_ramp->duration = cpu_to_le16(duration);
- packet_ramp->marker = 0x80;
+ packet_ramp->marker = cpu_to_le16(0x8000);
t300rs_fill_envelope(&packet_ramp->envelope, level, duration,
&ramp.envelope);
@@ -662,7 +663,6 @@ static int t300rs_upload_spring(struct t300rs_device_entry *t300rs,
uint16_t right_deadband;
uint16_t left_deadband;
uint8_t spring_start[17];
- struct t300rs_packet_envelope envelope;
struct t300rs_packet_timing timing;
} *packet_spring = (struct t300rs_packet_spring *)t300rs->send_buffer;
@@ -670,7 +670,7 @@ static int t300rs_upload_spring(struct t300rs_device_entry *t300rs,
uint16_t duration, right_coeff, left_coeff, right_deadband, left_deadband, offset;
if (test_bit(FF_EFFECT_PLAYING, &state->flags)
- && test_bit(FF_EFFECT_QUEUE_UPDATE, &state->flags)) {
+ && test_bit(FF_EFFECT_QUEUE_UPDATE, &state->flags)) {
__clear_bit(FF_EFFECT_QUEUE_UPLOAD, &state->flags);
@@ -717,9 +717,7 @@ static int t300rs_upload_damper(struct t300rs_device_entry *t300rs,
uint16_t left_coeff;
uint16_t right_deadband;
uint16_t left_deadband;
- /* space for spring const */
uint8_t damper_start[17];
- struct t300rs_packet_envelope envelope;
struct t300rs_packet_timing timing;
} *packet_damper = (struct t300rs_packet_damper *)t300rs->send_buffer;
@@ -776,8 +774,7 @@ static int t300rs_upload_periodic(struct t300rs_device_entry *t300rs,
uint16_t periodic_offset;
uint16_t phase;
uint16_t period;
-padding : 8;
- uint8_t marker;
+ uint16_t marker;
struct t300rs_packet_envelope envelope;
uint8_t waveform;
struct t300rs_packet_timing timing;
@@ -811,7 +808,7 @@ padding : 8;
packet_periodic->phase = phase;
packet_periodic->period = period;
- packet_periodic->marker = 0x80;
+ packet_periodic->marker = cpu_to_le16(0x8000);
t300rs_fill_envelope(&packet_periodic->envelope, magnitude, duration,
&periodic.envelope);
diff --git a/hid-tmt300rs.h b/hid-tmt300rs.h
index 7566f1a..3f5af4e 100644
--- a/hid-tmt300rs.h
+++ b/hid-tmt300rs.h
@@ -40,45 +40,43 @@ spinlock_t data_lock;
unsigned long data_flags;
static const signed short t300rs_ff_effects[] = {
- FF_CONSTANT,
- FF_RAMP,
- FF_SPRING,
- FF_DAMPER,
- FF_FRICTION,
- FF_INERTIA,
- FF_PERIODIC,
- FF_SINE,
- FF_TRIANGLE,
- FF_SQUARE,
- FF_SAW_UP,
- FF_SAW_DOWN,
- FF_AUTOCENTER,
- FF_GAIN,
- -1
+ FF_CONSTANT,
+ FF_RAMP,
+ FF_SPRING,
+ FF_DAMPER,
+ FF_FRICTION,
+ FF_INERTIA,
+ FF_PERIODIC,
+ FF_SINE,
+ FF_TRIANGLE,
+ FF_SQUARE,
+ FF_SAW_UP,
+ FF_SAW_DOWN,
+ FF_AUTOCENTER,
+ FF_GAIN,
+ -1
};
struct t300rs_effect_state {
- struct ff_effect effect;
- struct ff_effect old;
- bool old_set;
- unsigned long flags;
- unsigned long start_time;
- unsigned long count;
+ struct ff_effect effect;
+ struct ff_effect old;
+ bool old_set;
+ unsigned long flags;
+ unsigned long start_time;
+ unsigned long count;
};
struct __packed t300rs_firmware_response {
- uint8_t unknown0;
- uint8_t unknown1;
- uint8_t firmware_version;
- uint8_t unknown2;
+ uint8_t unused1[2];
+ uint8_t firmware_version;
+ uint8_t unused2;
};
-#define padding unsigned
struct __packed t300rs_packet_header {
-padding : 8;
- uint8_t id;
- uint8_t code;
+ uint8_t zero1;
+ uint8_t id;
+ uint8_t code;
};
struct __packed t300rs_setup_header {
@@ -96,90 +94,91 @@ struct __packed t300rs_packet_envelope {
struct __packed t300rs_packet_timing {
uint8_t start_marker;
uint16_t duration;
+ uint8_t zero1[2];
uint16_t offset;
-padding : 16;
+ uint8_t zero2;
uint16_t end_marker;
};
struct usb_ctrlrequest t300rs_firmware_request = {
- .bRequestType = 0xc1,
- .bRequest = 86,
- .wValue = 0,
- .wIndex = 0,
- .wLength = 8
+ .bRequestType = 0xc1,
+ .bRequest = 86,
+ .wValue = 0,
+ .wIndex = 0,
+ .wLength = 8
};
struct t300rs_device_entry {
- struct hid_device *hdev;
- struct input_dev *input_dev;
- struct hid_report *report;
- struct hid_field *ff_field;
- struct usb_device *usbdev;
- struct usb_interface *usbif;
- struct t300rs_effect_state *states;
- struct t300rs_firmware_response *firmware_response;
- struct hrtimer hrtimer;
+ struct hid_device *hdev;
+ struct input_dev *input_dev;
+ struct hid_report *report;
+ struct hid_field *ff_field;
+ struct usb_device *usbdev;
+ struct usb_interface *usbif;
+ struct t300rs_effect_state *states;
+ struct t300rs_firmware_response *firmware_response;
+ struct hrtimer hrtimer;
- int (*open)(struct input_dev *dev);
- void (*close)(struct input_dev *dev);
+ int (*open)(struct input_dev *dev);
+ void (*close)(struct input_dev *dev);
- spinlock_t lock;
- unsigned long lock_flags;
+ spinlock_t lock;
+ unsigned long lock_flags;
- u8 *send_buffer;
+ u8 *send_buffer;
- u16 range;
- u8 effects_used;
+ u16 range;
+ u8 effects_used;
};
struct t300rs_data {
- unsigned long quirks;
- void *device_props;
+ unsigned long quirks;
+ void *device_props;
};
static __u8 t300rs_rdesc_fixed[] = {
- 0x05, 0x01, 0x09, 0x04, 0xa1,
- 0x01, 0x09, 0x01, 0xa1, 0x00,
- 0x85, 0x07, 0x09, 0x30, 0x15,
- 0x00, 0x27, 0xff, 0xff, 0x00,
- 0x00, 0x35, 0x00, 0x47, 0xff,
- 0xff, 0x00, 0x00, 0x75, 0x10,
- 0x95, 0x01, 0x81, 0x02, 0x09,
- 0x35, 0x26, 0xff, 0x03, 0x46,
- 0xff, 0x03, 0x81, 0x02, 0x09,
- 0x32, 0x81, 0x02, 0x09, 0x31,
- 0x81, 0x02, 0x81, 0x03, 0x05,
- 0x09, 0x19, 0x01, 0x29, 0x0d,
- 0x25, 0x01, 0x45, 0x01, 0x75,
- 0x01, 0x95, 0x0d, 0x81, 0x02,
- 0x75, 0x0b, 0x95, 0x01, 0x81,
- 0x03, 0x05, 0x01, 0x09, 0x39,
- 0x25, 0x07, 0x46, 0x3b, 0x01,
- 0x55, 0x00, 0x65, 0x14, 0x75,
- 0x04, 0x81, 0x42, 0x65, 0x00,
- 0x81, 0x03, 0x85, 0x60, // here 0x0a
- 0x06, 0x00, 0xff, 0x09, 0x60, // here 0x0a
- 0x75, 0x08, 0x95, 0x3f, 0x26,
- 0xff, 0x7f, 0x15, 0x00, 0x46,
- 0xff, 0x7f, 0x36, 0x00, 0x80,
- 0x91, 0x02, 0x85, 0x02, 0x09,
- 0x02, 0x81, 0x02, 0x09, 0x14,
- 0x85, 0x14, 0x81, 0x02, 0xc0,
- 0xc0,
+ 0x05, 0x01, 0x09, 0x04, 0xa1,
+ 0x01, 0x09, 0x01, 0xa1, 0x00,
+ 0x85, 0x07, 0x09, 0x30, 0x15,
+ 0x00, 0x27, 0xff, 0xff, 0x00,
+ 0x00, 0x35, 0x00, 0x47, 0xff,
+ 0xff, 0x00, 0x00, 0x75, 0x10,
+ 0x95, 0x01, 0x81, 0x02, 0x09,
+ 0x35, 0x26, 0xff, 0x03, 0x46,
+ 0xff, 0x03, 0x81, 0x02, 0x09,
+ 0x32, 0x81, 0x02, 0x09, 0x31,
+ 0x81, 0x02, 0x81, 0x03, 0x05,
+ 0x09, 0x19, 0x01, 0x29, 0x0d,
+ 0x25, 0x01, 0x45, 0x01, 0x75,
+ 0x01, 0x95, 0x0d, 0x81, 0x02,
+ 0x75, 0x0b, 0x95, 0x01, 0x81,
+ 0x03, 0x05, 0x01, 0x09, 0x39,
+ 0x25, 0x07, 0x46, 0x3b, 0x01,
+ 0x55, 0x00, 0x65, 0x14, 0x75,
+ 0x04, 0x81, 0x42, 0x65, 0x00,
+ 0x81, 0x03, 0x85, 0x60, // here 0x0a
+ 0x06, 0x00, 0xff, 0x09, 0x60, // here 0x0a
+ 0x75, 0x08, 0x95, 0x3f, 0x26,
+ 0xff, 0x7f, 0x15, 0x00, 0x46,
+ 0xff, 0x7f, 0x36, 0x00, 0x80,
+ 0x91, 0x02, 0x85, 0x02, 0x09,
+ 0x02, 0x81, 0x02, 0x09, 0x14,
+ 0x85, 0x14, 0x81, 0x02, 0xc0,
+ 0xc0,
};
static u8 spring_values[] = {
- 0xa6, 0x6a, 0xa6, 0x6a, 0xfe,
- 0xff, 0xfe, 0xff, 0xfe, 0xff,
- 0xfe, 0xff, 0xdf, 0x58, 0xa6,
- 0x6a, 0x06
+ 0xa6, 0x6a, 0xa6, 0x6a, 0xfe,
+ 0xff, 0xfe, 0xff, 0xfe, 0xff,
+ 0xfe, 0xff, 0xdf, 0x58, 0xa6,
+ 0x6a, 0x06
};
static u8 damper_values[] = {
- 0xfc, 0x7f, 0xfc, 0x7f, 0xfe,
- 0xff, 0xfe, 0xff, 0xfe, 0xff,
- 0xfe, 0xff, 0xfc, 0x7f, 0xfc,
- 0x7f, 0x07
+ 0xfc, 0x7f, 0xfc, 0x7f, 0xfe,
+ 0xff, 0xfe, 0xff, 0xfe, 0xff,
+ 0xfe, 0xff, 0xfc, 0x7f, 0xfc,
+ 0x7f, 0x07
};