ALSA: hda - Move beep helper functions to hda_beep.c
authorTakashi Iwai <tiwai@suse.de>
Tue, 3 Jul 2012 15:27:57 +0000 (17:27 +0200)
committerTakashi Iwai <tiwai@suse.de>
Tue, 3 Jul 2012 16:31:36 +0000 (18:31 +0200)
Move snd_hda_mixer_amp_switch_put_beep() to hda_beep.c as a clean up
to remove one more ifdef.

Also add the corresponding get callback to return consistently the
digital beep state independently from the mixer amp value.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/hda_beep.c
sound/pci/hda/hda_codec.c
sound/pci/hda/hda_local.h

index 662de6e58b6fec627262579462bf5af9d93adc01..336b4b3a80b91785fcb29ca099a38b71e407db60 100644 (file)
@@ -231,3 +231,31 @@ void snd_hda_detach_beep_device(struct hda_codec *codec)
        }
 }
 EXPORT_SYMBOL_HDA(snd_hda_detach_beep_device);
+
+/* get/put callbacks for beep mute mixer switches */
+int snd_hda_mixer_amp_switch_get_beep(struct snd_kcontrol *kcontrol,
+                                     struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct hda_beep *beep = codec->beep;
+       if (beep) {
+               ucontrol->value.integer.value[0] =
+                       ucontrol->value.integer.value[1] =
+                       beep->enabled;
+               return 0;
+       }
+       return snd_hda_mixer_amp_switch_get(kcontrol, ucontrol);
+}
+EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_switch_get_beep);
+
+int snd_hda_mixer_amp_switch_put_beep(struct snd_kcontrol *kcontrol,
+                                     struct snd_ctl_elem_value *ucontrol)
+{
+       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct hda_beep *beep = codec->beep;
+       if (beep)
+               snd_hda_enable_beep_device(codec,
+                                          *ucontrol->value.integer.value);
+       return snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
+}
+EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_switch_put_beep);
index 51cb2a2e4fce03fbfdce96fb4b2c1b23063d45ed..ddac4288615d77ec79d5c66b99b835e9ae60d243 100644 (file)
@@ -2676,25 +2676,6 @@ int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol,
 }
 EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_switch_put);
 
-#ifdef CONFIG_SND_HDA_INPUT_BEEP
-/**
- * snd_hda_mixer_amp_switch_put_beep - Put callback for a beep AMP switch
- *
- * This function calls snd_hda_enable_beep_device(), which behaves differently
- * depending on beep_mode option.
- */
-int snd_hda_mixer_amp_switch_put_beep(struct snd_kcontrol *kcontrol,
-                                     struct snd_ctl_elem_value *ucontrol)
-{
-       struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
-       long *valp = ucontrol->value.integer.value;
-
-       snd_hda_enable_beep_device(codec, *valp);
-       return snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
-}
-EXPORT_SYMBOL_HDA(snd_hda_mixer_amp_switch_put_beep);
-#endif /* CONFIG_SND_HDA_INPUT_BEEP */
-
 /*
  * bound volume controls
  *
index 9a096a8e0fc5b8cb01ce7620956c9bd5848eec4e..1b4c12941baa3f2f250913c556624870c1e15b48 100644 (file)
@@ -89,7 +89,7 @@
        { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xcidx, \
          .subdevice = HDA_SUBDEV_AMP_FLAG, \
          .info = snd_hda_mixer_amp_switch_info, \
-         .get = snd_hda_mixer_amp_switch_get, \
+         .get = snd_hda_mixer_amp_switch_get_beep, \
          .put = snd_hda_mixer_amp_switch_put_beep, \
          .private_value = HDA_COMPOSE_AMP_VAL(nid, channel, xindex, direction) }
 #else
@@ -121,6 +121,8 @@ int snd_hda_mixer_amp_switch_get(struct snd_kcontrol *kcontrol,
 int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol,
                                 struct snd_ctl_elem_value *ucontrol);
 #ifdef CONFIG_SND_HDA_INPUT_BEEP
+int snd_hda_mixer_amp_switch_get_beep(struct snd_kcontrol *kcontrol,
+                                     struct snd_ctl_elem_value *ucontrol);
 int snd_hda_mixer_amp_switch_put_beep(struct snd_kcontrol *kcontrol,
                                      struct snd_ctl_elem_value *ucontrol);
 #endif