#include "hda_local.h"
#include "hda_auto_parser.h"
#include "hda_jack.h"
+#include "hda_beep.h"
#include "hda_generic.h"
if (spec->power_down_unused)
codec->power_filter = snd_hda_gen_path_power_filter;
+ if (!spec->no_analog && spec->beep_nid) {
+ err = snd_hda_attach_beep_device(codec, spec->beep_nid);
+ if (err < 0)
+ return err;
+ }
+
return 1;
}
EXPORT_SYMBOL_HDA(snd_hda_gen_parse_auto_config);
*/
void snd_hda_gen_free(struct hda_codec *codec)
{
+ snd_hda_detach_beep_device(codec);
snd_hda_gen_spec_free(codec->spec);
kfree(codec->spec);
codec->spec = NULL;
/* loopback mixing mode */
bool aamix_mode;
+ /* digital beep */
+ hda_nid_t beep_nid;
+
/* for virtual master */
hda_nid_t vmaster_nid;
unsigned int vmaster_tlv[4];
hda_nid_t eapd_nid;
unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
- hda_nid_t beep_dev_nid;
#ifdef ENABLE_AD_STATIC_QUIRKS
const struct snd_kcontrol_new *mixers[6];
.build_controls = ad198x_auto_build_controls,
.build_pcms = snd_hda_gen_build_pcms,
.init = snd_hda_gen_init,
- .free = ad198x_free,
+ .free = snd_hda_gen_free,
.unsol_event = snd_hda_jack_unsol_event,
#ifdef CONFIG_PM
.check_power_status = snd_hda_gen_check_power_status,
if (err < 0)
return err;
- if (spec->beep_dev_nid) {
- err = snd_hda_attach_beep_device(codec, spec->beep_dev_nid);
- if (err < 0)
- return err;
- }
-
codec->patch_ops = ad198x_auto_patch_ops;
return 0;
codec->inv_eapd = 1;
spec->gen.mixer_nid = 0x07;
- spec->beep_dev_nid = 0x19;
+ spec->gen.beep_nid = 0x19;
set_beep_amp(spec, 0x18, 0, HDA_OUTPUT);
/* AD1986A has a hardware problem that it can't share a stream
err = ad198x_parse_auto_config(codec);
if (err < 0) {
- ad198x_free(codec);
+ snd_hda_gen_free(codec);
return err;
}
return err;
spec = codec->spec;
- spec->beep_dev_nid = 0x10;
+ spec->gen.beep_nid = 0x10;
set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
err = ad198x_parse_auto_config(codec);
if (err < 0)
return 0;
error:
- ad198x_free(codec);
+ snd_hda_gen_free(codec);
return err;
}
spec = codec->spec;
spec->gen.mixer_nid = 0x0e;
- spec->beep_dev_nid = 0x10;
+ spec->gen.beep_nid = 0x10;
set_beep_amp(spec, 0x0d, 0, HDA_OUTPUT);
snd_hda_pick_fixup(codec, NULL, ad1981_fixup_tbl, ad1981_fixups);
return 0;
error:
- ad198x_free(codec);
+ snd_hda_gen_free(codec);
return err;
}
spec->gen.mixer_nid = 0x20;
spec->gen.mixer_merge_nid = 0x21;
- spec->beep_dev_nid = 0x10;
+ spec->gen.beep_nid = 0x10;
set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
err = ad198x_parse_auto_config(codec);
if (err < 0)
return 0;
error:
- ad198x_free(codec);
+ snd_hda_gen_free(codec);
return err;
}
spec = codec->spec;
spec->gen.mixer_nid = 0x20;
- spec->beep_dev_nid = 0x10;
+ spec->gen.beep_nid = 0x10;
set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
snd_hda_pick_fixup(codec, NULL, ad1884_fixup_tbl, ad1884_fixups);
return 0;
error:
- ad198x_free(codec);
+ snd_hda_gen_free(codec);
return err;
}
spec->gen.mixer_nid = 0x20;
spec->gen.mixer_merge_nid = 0x21;
- spec->beep_dev_nid = 0x10;
+ spec->gen.beep_nid = 0x10;
set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
err = ad198x_parse_auto_config(codec);
if (err < 0)
return 0;
error:
- ad198x_free(codec);
+ snd_hda_gen_free(codec);
return err;
}
#ifdef CONFIG_SND_HDA_INPUT_BEEP
-#define set_beep_amp(spec, nid, idx, dir) \
- ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir))
+static inline void set_beep_amp(struct conexant_spec *spec, hda_nid_t nid,
+ int idx, int dir)
+{
+ spec->gen.beep_nid = nid;
+ spec->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir);
+}
/* additional beep mixers; the actual parameters are overwritten at build */
static const struct snd_kcontrol_new cxt_beep_mixer[] = {
HDA_CODEC_VOLUME_MONO("Beep Playback Volume", 0, 1, 0, HDA_OUTPUT),
return 0;
}
-static void cx_auto_free(struct hda_codec *codec)
-{
- snd_hda_detach_beep_device(codec);
- snd_hda_gen_free(codec);
-}
-
static const struct hda_codec_ops cx_auto_patch_ops = {
.build_controls = cx_auto_build_controls,
.build_pcms = snd_hda_gen_build_pcms,
.init = snd_hda_gen_init,
- .free = cx_auto_free,
+ .free = snd_hda_gen_free,
.unsol_event = snd_hda_jack_unsol_event,
#ifdef CONFIG_PM
.check_power_status = snd_hda_gen_check_power_status,
goto error;
codec->patch_ops = cx_auto_patch_ops;
- if (spec->beep_amp)
- snd_hda_attach_beep_device(codec, get_amp_nid_(spec->beep_amp));
/* Some laptops with Conexant chips show stalls in S3 resume,
* which falls into the single-cmd mode.
#include "hda_codec.h"
#include "hda_local.h"
#include "hda_auto_parser.h"
-#include "hda_beep.h"
#include "hda_jack.h"
#include "hda_generic.h"
snd_hda_shutup_pins(codec);
}
-static void alc_free(struct hda_codec *codec)
-{
- struct alc_spec *spec = codec->spec;
-
- if (!spec)
- return;
-
- snd_hda_gen_spec_free(&spec->gen);
- snd_hda_detach_beep_device(codec);
- kfree(spec);
-}
+#define alc_free snd_hda_gen_free
#ifdef CONFIG_PM
static void alc_power_eapd(struct hda_codec *codec)
spec = codec->spec;
spec->gen.need_dac_fix = 1;
+ spec->gen.beep_nid = 0x01;
snd_hda_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl,
alc880_fixups);
if (err < 0)
goto error;
- if (!spec->gen.no_analog) {
- err = snd_hda_attach_beep_device(codec, 0x1);
- if (err < 0)
- goto error;
+ if (!spec->gen.no_analog)
set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
- }
codec->patch_ops = alc_patch_ops;
codec->patch_ops.unsol_event = alc880_unsol_event;
* it's almost harmless.
*/
spec->gen.prefer_hp_amp = 1;
+ spec->gen.beep_nid = 0x01;
snd_hda_pick_fixup(codec, alc260_fixup_models, alc260_fixup_tbl,
alc260_fixups);
if (err < 0)
goto error;
- if (!spec->gen.no_analog) {
- err = snd_hda_attach_beep_device(codec, 0x1);
- if (err < 0)
- goto error;
+ if (!spec->gen.no_analog)
set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
- }
codec->patch_ops = alc_patch_ops;
spec->shutup = alc_eapd_shutup;
alc_auto_parse_customize_define(codec);
+ if (has_cdefine_beep(codec))
+ spec->gen.beep_nid = 0x01;
+
/* automatic parse from the BIOS config */
err = alc882_parse_auto_config(codec);
if (err < 0)
goto error;
- if (!spec->gen.no_analog && has_cdefine_beep(codec)) {
- err = snd_hda_attach_beep_device(codec, 0x1);
- if (err < 0)
- goto error;
+ if (!spec->gen.no_analog && spec->gen.beep_nid)
set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
- }
codec->patch_ops = alc_patch_ops;
alc_auto_parse_customize_define(codec);
+ if (has_cdefine_beep(codec))
+ spec->gen.beep_nid = 0x01;
+
/* automatic parse from the BIOS config */
err = alc262_parse_auto_config(codec);
if (err < 0)
goto error;
- if (!spec->gen.no_analog && has_cdefine_beep(codec)) {
- err = snd_hda_attach_beep_device(codec, 0x1);
- if (err < 0)
- goto error;
+ if (!spec->gen.no_analog && spec->gen.beep_nid)
set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
- }
codec->patch_ops = alc_patch_ops;
spec->shutup = alc_eapd_shutup;
static int alc268_parse_auto_config(struct hda_codec *codec)
{
static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 };
- struct alc_spec *spec = codec->spec;
- int err = alc_parse_auto_config(codec, NULL, alc268_ssids);
- if (err > 0) {
- if (!spec->gen.no_analog &&
- spec->gen.autocfg.speaker_pins[0] != 0x1d) {
- add_mixer(spec, alc268_beep_mixer);
- snd_hda_add_verbs(codec, alc268_beep_init_verbs);
- }
- }
- return err;
+ return alc_parse_auto_config(codec, NULL, alc268_ssids);
}
/*
static int patch_alc268(struct hda_codec *codec)
{
struct alc_spec *spec;
- int i, has_beep, err;
+ int err;
/* ALC268 has no aa-loopback mixer */
err = alc_alloc_spec(codec, 0);
return err;
spec = codec->spec;
+ spec->gen.beep_nid = 0x01;
snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups);
snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
if (err < 0)
goto error;
- has_beep = 0;
- for (i = 0; i < spec->num_mixers; i++) {
- if (spec->mixers[i] == alc268_beep_mixer) {
- has_beep = 1;
- break;
- }
- }
-
- if (has_beep) {
- err = snd_hda_attach_beep_device(codec, 0x1);
- if (err < 0)
- goto error;
+ if (err > 0 && !spec->gen.no_analog &&
+ spec->gen.autocfg.speaker_pins[0] != 0x1d) {
+ add_mixer(spec, alc268_beep_mixer);
+ snd_hda_add_verbs(codec, alc268_beep_init_verbs);
if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
/* override the amp caps for beep generator */
snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
alc_auto_parse_customize_define(codec);
+ if (has_cdefine_beep(codec))
+ spec->gen.beep_nid = 0x01;
+
switch (codec->vendor_id) {
case 0x10ec0269:
spec->codec_variant = ALC269_TYPE_ALC269VA;
if (err < 0)
goto error;
- if (!spec->gen.no_analog && has_cdefine_beep(codec)) {
- err = snd_hda_attach_beep_device(codec, 0x1);
- if (err < 0)
- goto error;
+ if (!spec->gen.no_analog && spec->gen.beep_nid)
set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
- }
codec->patch_ops = alc_patch_ops;
#ifdef CONFIG_PM
return err;
spec = codec->spec;
+ spec->gen.beep_nid = 0x23;
snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
if (err < 0)
goto error;
- if (!spec->gen.no_analog) {
- err = snd_hda_attach_beep_device(codec, 0x23);
- if (err < 0)
- goto error;
+ if (!spec->gen.no_analog)
set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
- }
codec->patch_ops = alc_patch_ops;
#ifdef CONFIG_PM
return err;
spec = codec->spec;
+ spec->gen.beep_nid = 0x23;
snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
if (err < 0)
goto error;
- if (!spec->gen.no_analog) {
- err = snd_hda_attach_beep_device(codec, 0x23);
- if (err < 0)
- goto error;
+ if (!spec->gen.no_analog)
set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
- }
codec->patch_ops = alc_patch_ops;
alc_auto_parse_customize_define(codec);
+ if (has_cdefine_beep(codec))
+ spec->gen.beep_nid = 0x01;
+
if ((alc_get_coef0(codec) & (1 << 14)) &&
codec->bus->pci->subsystem_vendor == 0x1025 &&
spec->cdefine.platform_type == 1) {
if (err < 0)
goto error;
- if (!spec->gen.no_analog && has_cdefine_beep(codec)) {
- err = snd_hda_attach_beep_device(codec, 0x1);
- if (err < 0)
- goto error;
+ if (!spec->gen.no_analog && spec->gen.beep_nid) {
switch (codec->vendor_id) {
case 0x10ec0662:
set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
/* beep widgets */
hda_nid_t anabeep_nid;
- hda_nid_t digbeep_nid;
/* SPDIF-out mux */
const char * const *spdif_labels;
/* setup digital beep controls and input device */
#ifdef CONFIG_SND_HDA_INPUT_BEEP
- if (spec->digbeep_nid > 0) {
- hda_nid_t nid = spec->digbeep_nid;
+ if (spec->gen.beep_nid) {
+ hda_nid_t nid = spec->gen.beep_nid;
unsigned int caps;
err = stac_auto_create_beep_ctls(codec, nid);
- if (err < 0)
- return err;
- err = snd_hda_attach_beep_device(codec, nid);
if (err < 0)
return err;
if (codec->beep) {
~spec->eapd_mask);
}
-static void stac_free(struct hda_codec *codec)
-{
- struct sigmatel_spec *spec = codec->spec;
-
- if (!spec)
- return;
-
- snd_hda_gen_spec_free(&spec->gen);
- kfree(spec);
- snd_hda_detach_beep_device(codec);
-}
+#define stac_free snd_hda_gen_free
#ifdef CONFIG_PROC_FS
static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
spec->aloopback_mask = 0x01;
spec->aloopback_shift = 8;
- spec->digbeep_nid = 0x1c;
+ spec->gen.beep_nid = 0x1c; /* digital beep */
/* GPIO0 High = Enable EAPD */
spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
spec->gen.power_down_unused = 1;
spec->gen.mixer_nid = 0x1b;
- spec->digbeep_nid = 0x21;
+ spec->gen.beep_nid = 0x21; /* digital beep */
spec->pwr_nids = stac92hd83xxx_pwr_nids;
spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
spec->default_polarity = -1; /* no default cfg */
spec->gen.own_eapd_ctl = 1;
spec->gen.power_down_unused = 1;
- spec->digbeep_nid = 0x19;
+ spec->gen.beep_nid = 0x19; /* digital beep */
spec->pwr_nids = stac92hd95_pwr_nids;
spec->num_pwrs = ARRAY_SIZE(stac92hd95_pwr_nids);
spec->default_polarity = -1; /* no default cfg */
spec->aloopback_shift = 0;
spec->powerdown_adcs = 1;
- spec->digbeep_nid = 0x26;
+ spec->gen.beep_nid = 0x26; /* digital beep */
spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
spec->pwr_nids = stac92hd71bxx_pwr_nids;
spec->have_spdif_mux = 1;
spec->spdif_labels = stac927x_spdif_labels;
- spec->digbeep_nid = 0x23;
+ spec->gen.beep_nid = 0x23; /* digital beep */
/* GPIO0 High = Enable EAPD */
spec->eapd_mask = spec->gpio_mask = 0x01;
spec->gen.own_eapd_ctl = 1;
spec->have_spdif_mux = 1;
- spec->digbeep_nid = 0x23;
+ spec->gen.beep_nid = 0x23; /* digital beep */
snd_hda_add_verbs(codec, stac9205_core_init);
spec->aloopback_ctl = &stac9205_loopback;