From 16464bcaa7d8ab1ca62e66c46457ff432ade4a78 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Mal=C3=BD?= Date: Wed, 1 Oct 2014 15:32:26 +0200 Subject: [PATCH] Pass repeat info to HW-spec driver --- klgd_ff_plugin.c | 7 +++++-- klgd_ff_plugin.h | 1 + klgd_ff_plugin_p.h | 1 + klgdff.c | 12 ++++++------ 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/klgd_ff_plugin.c b/klgd_ff_plugin.c index 9ad78a4..1072bb8 100644 --- a/klgd_ff_plugin.c +++ b/klgd_ff_plugin.c @@ -32,6 +32,7 @@ static int ffpl_replace_effect(struct klgd_plugin_private *priv, struct klgd_com data.effects.cur = &eff->latest; data.effects.old = &eff->active; + data.effects.repeat = eff->repeat; ret = priv->control(dev, s, cmd, data); if (!ret) { eff->active = eff->latest; @@ -51,6 +52,7 @@ static int ffpl_start_effect(struct klgd_plugin_private *priv, struct klgd_comma enum ffpl_control_command cmd; data.effects.old = NULL; + data.effects.repeat = eff->repeat; if (priv->upload_when_started && eff->state == FFPL_UPLOADED) { data.effects.cur = &eff->active; if (eff->uploaded_to_device) @@ -177,9 +179,10 @@ static int ffpl_playback_rq(struct input_dev *dev, int effect_id, int value) klgd_lock_plugins(self->plugins_lock); - if (value) + if (value) { eff->change = FFPL_TO_START; - else + eff->repeat = value; + } else eff->change = FFPL_TO_STOP; klgd_unlock_plugins_sched(self->plugins_lock); diff --git a/klgd_ff_plugin.h b/klgd_ff_plugin.h index f07f9bc..1d5dbb5 100644 --- a/klgd_ff_plugin.h +++ b/klgd_ff_plugin.h @@ -28,6 +28,7 @@ enum ffpl_control_command { struct ffpl_effects { const struct ff_effect *cur; /* Pointer to the effect that is being uploaded/started/stopped/erased */ const struct ff_effect *old; /* Pointer to the currently active effect. Valid only with OWR_* commands, otherwise NULL */ + int repeat; /* How many times to repeat playback - valid only with *_SRT commands */ }; union ffpl_control_data { diff --git a/klgd_ff_plugin_p.h b/klgd_ff_plugin_p.h index 213b964..c45c8c6 100644 --- a/klgd_ff_plugin_p.h +++ b/klgd_ff_plugin_p.h @@ -20,6 +20,7 @@ enum ffpl_state { struct ffpl_effect { struct ff_effect active; /* Last effect submitted to device */ struct ff_effect latest; /* Last effect submitted to us by userspace */ + int repeat; /* How many times to repeat an effect - set in playback_rq */ enum ffpl_st_change change; /* State to which the effect shall be put */ enum ffpl_state state; /* State of the active effect */ bool replace; /* Active effect has to be replaced => active effect shall be erased and latest uploaded */ diff --git a/klgdff.c b/klgdff.c index 63e0b33..f15fc61 100644 --- a/klgdff.c +++ b/klgdff.c @@ -27,9 +27,9 @@ static int klgdff_erase(struct klgd_command_stream *s, const struct ff_effect *e return klgd_append_cmd(s, c); } -static int klgdff_owr_start(struct klgd_command_stream *s, const struct ff_effect *effect, const struct ff_effect *old_effect) +static int klgdff_owr_start(struct klgd_command_stream *s, const struct ff_effect *effect, const struct ff_effect *old_effect, const int repeat) { - char *text = kasprintf(GFP_KERNEL, "Overwriting effect to STARTED state, type %d, id %d, old type %d", effect->type, effect->id, old_effect->type); + char *text = kasprintf(GFP_KERNEL, "Overwriting effect to STARTED state, type %d, id %d, old type %d, repeat %d", effect->type, effect->id, old_effect->type, repeat); size_t len = strlen(text); struct klgd_command *c = klgd_alloc_cmd(len + 1); @@ -69,9 +69,9 @@ static int klgdff_er_stop(struct klgd_command_stream *s, const struct ff_effect return klgd_append_cmd(s, c); } -static int klgdff_start(struct klgd_command_stream *s, const struct ff_effect *effect) +static int klgdff_start(struct klgd_command_stream *s, const struct ff_effect *effect, const int repeat) { - char *text = kasprintf(GFP_KERNEL, "Playing effect, type %d, id %d", effect->type, effect->id); + char *text = kasprintf(GFP_KERNEL, "Playing effect, type %d, id %d, repeat %d", effect->type, effect->id, repeat); size_t len = strlen(text); struct klgd_command *c = klgd_alloc_cmd(len + 1); @@ -170,7 +170,7 @@ int klgdff_control(struct input_dev *dev, struct klgd_command_stream *s, const e return klgdff_upload(s, data.effects.cur); break; case FFPL_UPL_TO_SRT: - return klgdff_start(s, data.effects.cur); + return klgdff_start(s, data.effects.cur, data.effects.repeat); break; case FFPL_SRT_TO_UPL: return klgdff_stop(s, data.effects.cur); @@ -190,7 +190,7 @@ int klgdff_control(struct input_dev *dev, struct klgd_command_stream *s, const e break; /* "Direct" replacing commands */ case FFPL_OWR_TO_SRT: - return klgdff_owr_start(s, data.effects.cur, data.effects.old); + return klgdff_owr_start(s, data.effects.cur, data.effects.old, data.effects.repeat); break; case FFPL_OWR_TO_UPL: return klgdff_owr_upload(s, data.effects.cur, data.effects.old); -- 2.43.5