From: Michal MalĂ˝ Date: Sun, 16 Aug 2015 10:56:18 +0000 (+0200) Subject: Skip effect that are to be processed later in the processing loop X-Git-Url: https://gitweb.devoid-pointer.net/?a=commitdiff_plain;h=d0af02c68736e6dd0adf270be7126c6696023593;p=KLGD_FF_plugin.git Skip effect that are to be processed later in the processing loop --- diff --git a/klgd_ff_plugin.c b/klgd_ff_plugin.c index 001d62b..8404f27 100644 --- a/klgd_ff_plugin.c +++ b/klgd_ff_plugin.c @@ -43,8 +43,6 @@ inline static bool ffpl_handle_timing(const struct klgd_plugin_private *priv, co case FF_INERTIA: case FF_SPRING: return true; - default: - return false; } } @@ -536,6 +534,7 @@ static void ffpl_calculate_trip_times(struct ffpl_effect *eff, const unsigned lo eff->start_at = now + msecs_to_jiffies(ueff->replay.delay); eff->updated_at = eff->start_at; + eff->touch_at = eff->start_at; if (ueff->replay.delay) printk(KERN_NOTICE "KLGDFF: Delayed effect will be started at %lu, now: %lu\n", eff->start_at, now); @@ -700,6 +699,11 @@ static int ffpl_handle_combinable_effects(struct klgd_plugin_private *priv, stru int ret; struct ffpl_effect *eff = &priv->effects[idx]; + if (time_before(now, eff->touch_at)) { + printk(KERN_NOTICE "KLGDFF: Combinable effect is to be processed at a later time, skipping\n"); + continue; + } + if (eff->replace) { /* Uncombinable effect is about to be replaced by a combinable one */ if (ffpl_process_memless(priv, &eff->latest)) { @@ -1002,6 +1006,12 @@ static int ffpl_get_commands(struct klgd_plugin *self, struct klgd_command_strea struct ffpl_effect *eff = &priv->effects[idx]; printk(KERN_NOTICE "KLGDFF: Processing effect %lu\n", idx); + + if (time_before(now, eff->touch_at)) { + printk(KERN_NOTICE "KLGDFF: Next change of the effect is schededuled for the future\n"); + continue; + } + ret = ffpl_handle_state_change(priv, *s, eff, now); /* TODO: Do something useful with the return code */ if (ret) { @@ -1045,7 +1055,7 @@ static bool ffpl_get_update_time(struct klgd_plugin *self, const unsigned long n eff->change = FFPL_TO_START; break; case FFPL_TRIG_STOP: - /* Small processing delays might cause us to miss the precise stop point */ + /* Small processing delays might make us to miss the precise stop point */ current_t = time_before(eff->stop_at, now) ? now : eff->stop_at; eff->change = FFPL_TO_STOP; eff->repeat--; @@ -1058,6 +1068,8 @@ static bool ffpl_get_update_time(struct klgd_plugin *self, const unsigned long n continue; } + eff->touch_at = current_t; + if (!events++) { printk(KERN_NOTICE "KLGDFF: First event\n"); *t = current_t; diff --git a/klgd_ff_plugin_p.h b/klgd_ff_plugin_p.h index 25f8dd7..60dac45 100644 --- a/klgd_ff_plugin_p.h +++ b/klgd_ff_plugin_p.h @@ -41,6 +41,7 @@ struct ffpl_effect { unsigned long start_at; /* Time when to start the effect - in jiffies */ unsigned long stop_at; /* Time when to stop the effect - in jiffies */ unsigned long updated_at; /* Time when the effect was recalculated last time - in jiffies */ + unsigned long touch_at; /* Time of the next modification of the effect - in jiffies */ u16 playback_time; /* Used internally by effect processor to calculate periods */ bool recalculate; /* Effect shall be recalculated in the respective processing loop */ };