]> Devoid-pointer.net GitWeb - KLGD_FF_plugin.git/commitdiff
Do not force processing of CONSTANT effects when the memless mode is
authorMichal Malý <madcatxster@devoid-pointer.net>
Sun, 16 Aug 2015 09:49:51 +0000 (11:49 +0200)
committerMichal Malý <madcatxster@devoid-pointer.net>
Sun, 16 Aug 2015 09:49:51 +0000 (11:49 +0200)
switcehd on

klgd_ff_plugin.c
klgd_ff_plugin.h
klgd_ff_plugin_p.h
klgdff.c

index 2023541e489cb97ab1814a76dbb690592b69b116..5b2f4cf9686b456fe06833283c0bad8acf5941b1 100644 (file)
@@ -24,7 +24,7 @@ static bool ffpl_process_memless(const struct klgd_plugin_private *priv, const s
 {
        switch (eff->type) {
        case FF_CONSTANT:
-               return priv->memless_mode;
+               return priv->memless_constant;
        case FF_PERIODIC:
                return priv->memless_periodic;
        case FF_RAMP:
@@ -570,7 +570,7 @@ static int ffpl_playback_rq(struct input_dev *dev, int effect_id, int value)
 
        eff->repeat = value;
        if (value > 0) {
-               if (priv->control_timing && ffpl_process_memless(priv, &eff->active))
+               if (ffpl_process_memless(priv, &eff->latest))
                        ffpl_calculate_trip_times(eff, now);
                else
                        eff->start_at = now; /* Start the effect right away and let the device deal with the timing */
@@ -614,8 +614,10 @@ static int ffpl_upload_rq(struct input_dev *dev, struct ff_effect *effect, struc
                        eff->change = FFPL_TO_UPDATE;
                        eff->trigger = FFPL_TRIG_UPDATE;
                }
-       } else
+       } else {
                eff->change = FFPL_TO_UPLOAD;
+               eff->trigger = FFPL_TRIG_NOW;
+       }
 
        spin_unlock_irq(&dev->event_lock);
        klgd_unlock_plugins_sched(self->plugins_lock);
@@ -902,7 +904,7 @@ static void ffpl_advance_trigger(const struct klgd_plugin_private *priv, struct
                        eff->trigger = FFPL_TRIG_RECALC;
                        break;
                }
-               if (eff->latest.replay.length && priv->control_timing && ffpl_process_memless(priv, &eff->latest))
+               if (eff->latest.replay.length && ffpl_process_memless(priv, &eff->latest))
                        eff->trigger = FFPL_TRIG_STOP;
                else
                        eff->trigger = FFPL_TRIG_NONE;
@@ -913,14 +915,14 @@ static void ffpl_advance_trigger(const struct klgd_plugin_private *priv, struct
        case FFPL_TRIG_RECALC:
                if (ffpl_needs_recalculation(priv, &eff->active, eff->start_at, eff->stop_at, now))
                        break;
-               if (eff->active.replay.length && priv->control_timing && ffpl_process_memless(priv, &eff->active)) {
+               if (eff->active.replay.length && ffpl_process_memless(priv, &eff->active)) {
                        eff->trigger = FFPL_TRIG_STOP;
                        break;
                }
                eff->trigger = FFPL_TRIG_NONE;
                break;
        case FFPL_TRIG_STOP:
-               if (eff->repeat > 0 && priv->control_timing && ffpl_process_memless(priv, &eff->active)) {
+               if (eff->repeat > 0 && ffpl_process_memless(priv, &eff->active)) {
                        eff->trigger = FFPL_TRIG_RESTART;
                        break;
                }
@@ -1326,22 +1328,22 @@ int ffpl_init_plugin(struct klgd_plugin **plugin, struct input_dev *dev, const s
                priv->has_owr_to_srt = true;
                printk("KLGDFF: Using REPLACE STARTED\n");
        }
-       if (FFPL_MEMLESS_MODE & flags) {
-               priv->memless_mode = true;
-               priv->control_timing = true;
+
+       if ((FFPL_MEMLESS_CONSTANT | FFPL_MEMLESS_PERIODIC | FFPL_MEMLESS_RAMP) & flags) {
+               if (!test_bit(FF_CONSTANT - FF_EFFECT_MIN, &priv->supported_effects)) {
+                       printk(KERN_ERR "The driver asked for memless mode but the device does not support FF_CONSTANT\n");
+                       ret = -EINVAL;
+                       goto err_out2;
+               }
        }
-       if (FFPL_MEMLESS_PERIODIC & flags) {
-               priv->memless_mode = true;
+
+       if (FFPL_MEMLESS_CONSTANT & flags)
+               priv->memless_constant = true;
+       if (FFPL_MEMLESS_PERIODIC & flags)
                priv->memless_periodic = true;
-               priv->control_timing = true;
-       }
-       if (FFPL_MEMLESS_RAMP & flags) {
-               priv->memless_mode = true;
+       if (FFPL_MEMLESS_RAMP & flags)
                priv->memless_ramp = true;
-               priv->control_timing = true;
-       }
-       if (FFPL_CONTROL_TIMING & flags)
-             priv->control_timing = true;
+
        if (FFPL_HAS_NATIVE_GAIN & flags) {
                priv->has_native_gain = true;
                printk(KERN_NOTICE "KLGDFF: Using HAS_NATIVE_GAIN\n");
index c359879d39b76d17a333f20509ab86ac0108fd3d..ea96c7dd2612488358442058de314f71b2ef8125 100644 (file)
 #define FFPL_REPLACE_UPLOADED BIT(4) /* Device can accept a new effect to UPLOADED state without the need to explicitly stop and erase the previously uploaded effect beforehand */
 #define FFPL_REPLACE_STARTED BIT(5) /* Device can accept a new effect to STARTED state without the need to explicitly stop and erase the previously uploaded effect beforehand */
 
-#define FFPL_MEMLESS_MODE BIT(6)     /* Device cannot process effects by itself and required KLGD-FF to do all calculations for it. */
+#define FFPL_MEMLESS_CONSTANT BIT(6)     /* Device cannot process FF_CONSTANT by itself and requires KLGD-FF to calculate overall force.
+                                           Device must support FF_CONSTANT for this to work. */
 #define FFPL_MEMLESS_PERIODIC BIT(7) /* Device cannot process FF_PERIODIC by itself and requires KLGD-FF to calculate the overall force.
-                                       Device must support FF_CONSTANT for this to work.
-                                       This flag implies FFPL_MEMLESS_MODE */
+                                       Device must support FF_CONSTANT for this to work. */
 #define FFPL_MEMLESS_RAMP BIT(8)     /* Device cannot process FF_RAMP by itself and requires KLGD-FF to calculate the overall force.
-                                       Device must support FF_CONSTANT for this to work.
-                                       This flag implies FFPL_MEMLESS_MODE */
-#define FFPL_CONTROL_TIMING BIT(9)   /* Device cannot handle effects with finite duration, delays and repeated effects. Let KLGD-FF take care
-                                       of starting, stopping and restarting effects at appropriate times.
-                                       FFPL_MEMLESS_MODE implies this flag. */
+                                       Device must support FF_CONSTANT for this to work. */
 
 #define FFPL_HAS_NATIVE_GAIN BIT(15)  /* Device can adjust the gain by itself */
 #define FFPL_HAS_AUTOCENTER BIT(16) /* Device supports autocentering */
index 74eaa2240a716c81eae3b4f9c91490f33f0dfb79..a18d8cb2a8c0127cc852c375a07f85b97289d0e7 100644 (file)
@@ -64,11 +64,10 @@ struct klgd_plugin_private {
        bool has_owr_to_srt;
        bool has_native_gain;
        bool has_autocenter;
-       bool memless_mode;
+       bool memless_constant;
        bool memless_periodic;
        bool memless_ramp;
-       bool control_timing;
-       u32 padding_caps:20;
+       u32 padding_caps:21;
        /* Device-wide state changes */
        bool change_gain;
        bool change_autocenter;
index 7ce178a097ef367e808b29fa9cca7d23ae6c0341..d988eeaee0b20ab793a45d40a1ec74461c8c09f2 100644 (file)
--- a/klgdff.c
+++ b/klgdff.c
@@ -356,7 +356,7 @@ static int __init klgdff_init(void)
        input_set_abs_params(dev, ABS_Y, -0x7fff, 0x7fff, 0, 0);
 
        ret = ffpl_init_plugin(&ff_plugin, dev, EFFECT_COUNT, ffbits,
-                              FFPL_HAS_EMP_TO_SRT | FFPL_REPLACE_STARTED | FFPL_HAS_AUTOCENTER | FFPL_MEMLESS_MODE,
+                              FFPL_HAS_EMP_TO_SRT | FFPL_REPLACE_STARTED | FFPL_HAS_AUTOCENTER | FFPL_MEMLESS_RAMP,
                               klgdff_control, &test_user);
        if (ret) {
                printk(KERN_ERR "KLGDFF-TD: Cannot init plugin\n");