@@ -67,6 +67,7 @@ struct snd_jack {
char name[100];
unsigned int key[6]; /* Keep in sync with definitions above */
#endif /* CONFIG_SND_JACK_INPUT_DEV */
+ int hw_status_cache;
void *private_data;
void (*private_free)(struct snd_jack *);
};
@@ -193,8 +193,14 @@ static ssize_t sw_inject_enable_write(struct file *file,
goto exit;
}
+ if (jack_kctl->sw_inject_enable == (!!enable))
+ goto exit;
+
jack_kctl->sw_inject_enable = !!enable;
+ if (!jack_kctl->sw_inject_enable)
+ snd_jack_report(jack_kctl->jack, jack_kctl->jack->hw_status_cache);
+
exit:
kfree(buf);
return ret;
@@ -678,6 +684,8 @@ void snd_jack_report(struct snd_jack *jack, int status)
if (!jack)
return;
+ jack->hw_status_cache = status;
+
list_for_each_entry(jack_kctl, &jack->kctl_list, list)
if (jack_kctl->sw_inject_enable)
mask_bits |= jack_kctl->mask_bits;
Once we enable the sw_inject for a jack_kctl, the hw status change will be blocked, but the hw status still could be reported to snd_jack_report() and be saved to hw_status_cache. After the sw_inject is disabled, we use the last saved hw_status_cache to restore jack's status. Signed-off-by: Hui Wang <hui.wang@canonical.com> --- include/sound/jack.h | 1 + sound/core/jack.c | 8 ++++++++ 2 files changed, 9 insertions(+)