Skip to content

Commit a3bb17a

Browse files
Stefan Bindingsmb49
authored andcommitted
ALSA: hda: hda_component: Add pre and post playback hooks to hda_component
BugLink: https://bugs.launchpad.net/bugs/2029199 These hooks can be used to add callbacks that would be run before and after the main playback hooks. These hooks would be called for all amps, before moving on to the next hook, i.e. pre_playback_hook would be called for all amps, before the playback_hook is called for all amps, then finally the post_playback_hook is called for all amps. Signed-off-by: Stefan Binding <sbinding@opensource.cirrus.com> Link: https://lore.kernel.org/r/20230721151816.2080453-8-sbinding@opensource.cirrus.com Signed-off-by: Takashi Iwai <tiwai@suse.de> (cherry picked from commit 4eae4892c5bdef990b4b80997b813e2443d6554c linux-next) Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
1 parent 9e7808b commit a3bb17a

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

sound/pci/hda/hda_component.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,7 @@ struct hda_component {
1515
struct device *dev;
1616
char name[HDA_MAX_NAME_SIZE];
1717
struct hda_codec *codec;
18+
void (*pre_playback_hook)(struct device *dev, int action);
1819
void (*playback_hook)(struct device *dev, int action);
20+
void (*post_playback_hook)(struct device *dev, int action);
1921
};

sound/pci/hda/patch_realtek.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6700,9 +6700,17 @@ static void comp_generic_playback_hook(struct hda_pcm_stream *hinfo, struct hda_
67006700
int i;
67016701

67026702
for (i = 0; i < HDA_MAX_COMPONENTS; i++) {
6703-
if (spec->comps[i].dev)
6703+
if (spec->comps[i].dev && spec->comps[i].pre_playback_hook)
6704+
spec->comps[i].pre_playback_hook(spec->comps[i].dev, action);
6705+
}
6706+
for (i = 0; i < HDA_MAX_COMPONENTS; i++) {
6707+
if (spec->comps[i].dev && spec->comps[i].playback_hook)
67046708
spec->comps[i].playback_hook(spec->comps[i].dev, action);
67056709
}
6710+
for (i = 0; i < HDA_MAX_COMPONENTS; i++) {
6711+
if (spec->comps[i].dev && spec->comps[i].post_playback_hook)
6712+
spec->comps[i].post_playback_hook(spec->comps[i].dev, action);
6713+
}
67066714
}
67076715

67086716
struct cs35l41_dev_name {

0 commit comments

Comments
 (0)