aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2020-07-10 18:42:11 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2020-07-10 18:42:11 +0300
commit11c7bb0526d1ddd20d86b9cb2981b3a213d40404 (patch)
tree64edb8b4d660b5dd2e5edfc8e4af11da67cc02c2
parent2031f19d346e5abcfaa1feb35103fba52dd5c55c (diff)
downloadhid-tmff2-11c7bb0526d1ddd20d86b9cb2981b3a213d40404.tar.gz
hid-tmff2-11c7bb0526d1ddd20d86b9cb2981b3a213d40404.zip
incorrect usage of git
-rw-r--r--hid-tmt300rs.c92
-rw-r--r--hid-tmt300rs.h6
-rw-r--r--hid-tmt300rs.kobin537752 -> 527336 bytes
-rw-r--r--hid-tmt300rs.mod.c4
-rw-r--r--hid-tmt300rs.mod.obin144040 -> 144040 bytes
-rw-r--r--hid-tmt300rs.obin395304 -> 384888 bytes
6 files changed, 46 insertions, 56 deletions
diff --git a/hid-tmt300rs.c b/hid-tmt300rs.c
index b8f0a30..bab04ec 100644
--- a/hid-tmt300rs.c
+++ b/hid-tmt300rs.c
@@ -71,7 +71,6 @@ static int t300rs_play_effect(struct t300rs_device_entry *t300rs, struct t300rs_
hid_err(t300rs->hdev, "failed starting effect play\n");
}
- hid_info(t300rs->hdev, "sent play\n");
kfree(send_buffer);
return ret;
}
@@ -89,7 +88,7 @@ static int t300rs_stop_effect(struct t300rs_device_entry *t300rs, struct t300rs_
hid_err(t300rs->hdev, "failed stopping effect play\n");
}
- hid_info(t300rs->hdev, "stopping effect\n");
+ kfree(send_buffer);
return ret;
}
@@ -160,7 +159,6 @@ static int t300rs_upload_constant(struct t300rs_device_entry *t300rs, struct t30
if(ret){
hid_err(t300rs->hdev, "failed uploading constant effect\n");
}
- hid_info(t300rs->hdev, "uploading constant");
kfree(send_buffer);
return ret;
}
@@ -225,7 +223,6 @@ static int t300rs_upload_ramp(struct t300rs_device_entry *t300rs, struct t300rs_
hid_err(t300rs->hdev, "failed uploading ramp");
}
kfree(send_buffer);
- hid_info(t300rs->hdev, "uploading ramp");
return ret;
}
@@ -256,8 +253,6 @@ static int t300rs_upload_spring(struct t300rs_device_entry *t300rs, struct t300r
le_duration = cpu_to_le16(effect.replay.length);
le_offset = cpu_to_le16(effect.replay.delay);
- hid_info(t300rs->hdev, "coeffs: %x vs %x\n", le_right_coeff, spring.right_coeff);
-
send_buffer[4] = le_right_coeff & 0xff;
send_buffer[5] = le_right_coeff >> 8;
@@ -287,7 +282,6 @@ static int t300rs_upload_spring(struct t300rs_device_entry *t300rs, struct t300r
hid_err(t300rs->hdev, "failed uploading spring\n");
}
kfree(send_buffer);
- hid_info(t300rs->hdev, "uploading spring");
return ret;
}
@@ -318,8 +312,6 @@ static int t300rs_upload_damper(struct t300rs_device_entry *t300rs, struct t300r
le_duration = cpu_to_le16(effect.replay.length);
le_offset = cpu_to_le16(effect.replay.delay);
- hid_info(t300rs->hdev, "coeffs: %x vs %x\n", le_right_coeff, spring.right_coeff);
-
send_buffer[4] = le_right_coeff & 0xff;
send_buffer[5] = le_right_coeff >> 8;
@@ -348,10 +340,8 @@ static int t300rs_upload_damper(struct t300rs_device_entry *t300rs, struct t300r
if(ret){
hid_err(t300rs->hdev, "failed uploading spring\n");
}
-
- hid_info(t300rs->hdev, "uploading spring");
+ kfree(send_buffer);
return ret;
- return 0;
}
static int t300rs_upload_periodic(struct t300rs_device_entry *t300rs, struct t300rs_effect_state *state){
@@ -367,10 +357,8 @@ static int t300rs_upload_periodic(struct t300rs_device_entry *t300rs, struct t30
__clear_bit(FF_EFFECT_PLAYING, &state->flags);
}
-
magnitude = (periodic.magnitude * fixp_sin16(effect.direction * 360 / 0x10000)) / 0x7fff;
- hid_warn(t300rs->hdev, "magnitude %i vs %i\n", periodic.magnitude, magnitude);
le_magnitude = cpu_to_le16(magnitude);
le_phase = cpu_to_le16(periodic.phase);
le_periodic_offset = cpu_to_le16(periodic.offset);
@@ -415,8 +403,8 @@ static int t300rs_upload_periodic(struct t300rs_device_entry *t300rs, struct t30
if(ret){
hid_err(t300rs->hdev, "failed uploading periodic effect");
}
+
kfree(send_buffer);
- hid_info(t300rs->hdev, "uploaded periodic effect");
return ret;
}
@@ -441,34 +429,23 @@ static int t300rs_upload_effect(struct t300rs_device_entry *t300rs, struct t300r
}
static int t300rs_timer_helper(struct t300rs_device_entry *t300rs){
- struct usbhid_device *usbhid = t300rs->hdev->driver_data;
struct t300rs_effect_state *state;
- int current_period, effect_id, ret;
-
- if(usbhid->outhead != usbhid->outtail){
- current_period = timer_msecs;
- timer_msecs *= 2;
- hid_info(t300rs->hdev, "commands stacking up, increasing timer period\n");
- return current_period;
- }
-
+ unsigned long jiffies_now = JIFFIES2MS(jiffies);
+ int max_count = 0, effect_id, ret;
+
for(effect_id = 0; effect_id < T300RS_MAX_EFFECTS; ++effect_id){
state = &t300rs->states[effect_id];
- /*
- * alright, for now no count support
- * if(test_bit(FF_EFFECT_PLAYING, &state->flags)){
- if(JIFFIES2MS(jiffies) - state->start_time >= state->effect.replay.length){
- hid_info(t300rs->hdev, "maybe dangerous?");
+ if(test_bit(FF_EFFECT_PLAYING, &state->flags)){
+ if((jiffies_now - state->start_time) >= state->effect.replay.length){
__clear_bit(FF_EFFECT_PLAYING, &state->flags);
if(state->count){
__set_bit(FF_EFFECT_QUEUE_START, &state->flags);
- state->count--;
}
}
- }*/
+ }
if(test_bit(FF_EFFECT_QUEUE_UPLOAD, &state->flags)){
__clear_bit(FF_EFFECT_QUEUE_UPLOAD, &state->flags);
@@ -484,13 +461,15 @@ static int t300rs_timer_helper(struct t300rs_device_entry *t300rs){
__clear_bit(FF_EFFECT_QUEUE_START, &state->flags);
__set_bit(FF_EFFECT_PLAYING, &state->flags);
- state->start_time = JIFFIES2MS(jiffies);
-
ret = t300rs_play_effect(t300rs, state);
if(ret){
hid_err(t300rs->hdev, "failed starting effects\n");
return ret;
}
+
+ if(state->count){
+ state->count--;
+ }
}
if(test_bit(FF_EFFECT_QUEUE_STOP, &state->flags)){
@@ -503,29 +482,31 @@ static int t300rs_timer_helper(struct t300rs_device_entry *t300rs){
return ret;
}
}
+
+ if(state->count > max_count){
+ max_count = state->count;
+ }
}
- return 0;
+ return max_count;
}
static enum hrtimer_restart t300rs_timer(struct hrtimer *t){
struct t300rs_device_entry *t300rs = container_of(t, struct t300rs_device_entry, hrtimer);
- int overruns, delay_timer;
+ int max_count;
- delay_timer = t300rs_timer_helper(t300rs);
+ spin_lock_irqsave(&t300rs->lock, t300rs->lock_flags);
- if(delay_timer){
- hrtimer_forward_now(&t300rs->hrtimer, ms_to_ktime(delay_timer));
- return HRTIMER_RESTART;
- }
+ max_count = t300rs_timer_helper(t300rs);
+
+ spin_unlock_irqrestore(&t300rs->lock, t300rs->lock_flags);
- if(t300rs->effects_used){
- overruns = hrtimer_forward_now(&t300rs->hrtimer, ms_to_ktime(timer_msecs));
- overruns--;
+ if(max_count > 0){
+ hrtimer_forward_now(&t300rs->hrtimer, ms_to_ktime(timer_msecs));
return HRTIMER_RESTART;
} else {
return HRTIMER_NORESTART;
- }
+ }
}
@@ -572,19 +553,19 @@ static int t300rs_play(struct input_dev *dev, int effect_id, int value){
__set_bit(FF_EFFECT_QUEUE_STOP, &state->flags);
} else {
t300rs->effects_used++;
-
- if(!hrtimer_active(&t300rs->hrtimer)){
- hrtimer_start(&t300rs->hrtimer, ms_to_ktime(timer_msecs), HRTIMER_MODE_REL);
- }
}
state->count = value;
-
+ state->start_time = JIFFIES2MS(jiffies);
__set_bit(FF_EFFECT_QUEUE_START, &state->flags);
+
} else {
__set_bit(FF_EFFECT_QUEUE_STOP, &state->flags);
t300rs->effects_used--;
+ }
+ if(!hrtimer_active(&t300rs->hrtimer)){
+ hrtimer_start(&t300rs->hrtimer, ms_to_ktime(timer_msecs), HRTIMER_MODE_REL);
}
spin_unlock_irqrestore(&t300rs->lock, t300rs->lock_flags);
@@ -757,6 +738,7 @@ int t300rs_init(struct hid_device *hdev, const signed short *ff_bits){
struct usb_device *usbdev = interface_to_usbdev(usbif);
struct hid_report *report;
struct ff_device *ff;
+ char range[10] = "54000"; /* approx 900 degress */
int i, ret;
drv_data = hid_get_drvdata(hdev);
@@ -872,6 +854,10 @@ int t300rs_init(struct hid_device *hdev, const signed short *ff_bits){
hrtimer_init(&t300rs->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
t300rs->hrtimer.function = t300rs_timer;
+
+ t300rs_range_store(dev, &dev_attr_range, range, 10);
+ t300rs_set_gain(input_dev, 0xffff);
+
t300rs_open(input_dev);
hid_info(hdev, "force feedback for T300RS\n");
return 0;
@@ -958,7 +944,7 @@ static int t300rs_probe(struct hid_device *hdev, const struct hid_device_id *id)
}
/* lord have mercy */
- t300rs_preinit(hdev);
+ //t300rs_preinit(hdev);
ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF);
if(ret){
@@ -983,6 +969,7 @@ static void t300rs_remove(struct hid_device *hdev){
struct t300rs_device_entry *t300rs;
struct t300rs_data *drv_data;
+ spin_lock_irqsave(&lock, lock_flags);
device_remove_file(&hdev->dev, &dev_attr_range);
drv_data = hid_get_drvdata(hdev);
@@ -994,6 +981,9 @@ static void t300rs_remove(struct hid_device *hdev){
kfree(drv_data);
kfree(t300rs);
hid_hw_stop(hdev);
+
+ spin_unlock_irqrestore(&lock, lock_flags);
+
return;
}
diff --git a/hid-tmt300rs.h b/hid-tmt300rs.h
index 1cc3424..b308627 100644
--- a/hid-tmt300rs.h
+++ b/hid-tmt300rs.h
@@ -4,10 +4,10 @@
#include <linux/ktime.h>
#include <linux/fixp-arith.h>
-#define T300RS_MAX_EFFECTS FF_MAX_EFFECTS
+#define T300RS_MAX_EFFECTS 16
#define T300RS_BUFFER_LENGTH 64
-#define DEFAULT_TIMER_PERIOD 16 /* the wheel seems to be bad at stuff*/
+#define DEFAULT_TIMER_PERIOD 4 /* the wheel seems to be bad at stuff*/
#define FF_EFFECT_QUEUE_UPLOAD 0
#define FF_EFFECT_QUEUE_START 1
@@ -44,7 +44,7 @@ static const signed short t300rs_ff_effects[] = {
struct t300rs_effect_state {
struct ff_effect effect;
unsigned long flags;
- unsigned int start_time;
+ unsigned long start_time;
unsigned long count;
};
diff --git a/hid-tmt300rs.ko b/hid-tmt300rs.ko
index 7ec9bb8..07d01f3 100644
--- a/hid-tmt300rs.ko
+++ b/hid-tmt300rs.ko
Binary files differ
diff --git a/hid-tmt300rs.mod.c b/hid-tmt300rs.mod.c
index d10c5bb..a114b1d 100644
--- a/hid-tmt300rs.mod.c
+++ b/hid-tmt300rs.mod.c
@@ -29,6 +29,7 @@ __used __section(__versions) = {
{ 0xb7aa9422, "__hid_register_driver" },
{ 0x414fc2a1, "hid_hw_start" },
{ 0xcd9e657d, "hid_open_report" },
+ { 0x59e59766, "_dev_info" },
{ 0x1ee7d3cd, "hrtimer_init" },
{ 0x7d42edf, "device_create_file" },
{ 0xb3e1146a, "input_ff_create" },
@@ -39,10 +40,8 @@ __used __section(__versions) = {
{ 0x4a3ad70e, "wait_for_completion_timeout" },
{ 0x608741b5, "__init_swait_queue_head" },
{ 0xdecd0b29, "__stack_chk_fail" },
- { 0x15ba50a6, "jiffies" },
{ 0xdc21e866, "hrtimer_forward" },
{ 0x2ea2c95c, "__x86_indirect_thunk_rax" },
- { 0x59e59766, "_dev_info" },
{ 0x20000329, "simple_strtoul" },
{ 0xc27f683d, "kmem_cache_alloc_trace" },
{ 0x46a9479b, "kmalloc_caches" },
@@ -54,6 +53,7 @@ __used __section(__versions) = {
{ 0x9c59e5d5, "device_remove_file" },
{ 0xfbdfc558, "hrtimer_start_range_ns" },
{ 0xb4ff6bb6, "hrtimer_active" },
+ { 0x15ba50a6, "jiffies" },
{ 0xc85d768e, "_dev_warn" },
{ 0xadd72fe9, "usb_free_urb" },
{ 0x316d1bda, "_dev_err" },
diff --git a/hid-tmt300rs.mod.o b/hid-tmt300rs.mod.o
index 95b6880..5ab5b8c 100644
--- a/hid-tmt300rs.mod.o
+++ b/hid-tmt300rs.mod.o
Binary files differ
diff --git a/hid-tmt300rs.o b/hid-tmt300rs.o
index 743d20b..a01b321 100644
--- a/hid-tmt300rs.o
+++ b/hid-tmt300rs.o
Binary files differ