From: Michal MalĂ˝ Date: Sun, 16 Aug 2015 09:49:51 +0000 (+0200) Subject: Do not force processing of CONSTANT effects when the memless mode is X-Git-Url: https://gitweb.devoid-pointer.net/?a=commitdiff_plain;h=33109e830a1603dde1c1a1105e36d874d38345d9;p=KLGD_FF_plugin.git Do not force processing of CONSTANT effects when the memless mode is switcehd on --- diff --git a/klgd_ff_plugin.c b/klgd_ff_plugin.c index 2023541..5b2f4cf 100644 --- a/klgd_ff_plugin.c +++ b/klgd_ff_plugin.c @@ -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"); diff --git a/klgd_ff_plugin.h b/klgd_ff_plugin.h index c359879..ea96c7d 100644 --- a/klgd_ff_plugin.h +++ b/klgd_ff_plugin.h @@ -11,16 +11,12 @@ #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 */ diff --git a/klgd_ff_plugin_p.h b/klgd_ff_plugin_p.h index 74eaa22..a18d8cb 100644 --- a/klgd_ff_plugin_p.h +++ b/klgd_ff_plugin_p.h @@ -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; diff --git a/klgdff.c b/klgdff.c index 7ce178a..d988eea 100644 --- 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");