// SPDX-License-Identifier: GPL-2.0+ /* * Digital Beep Input Interface for HD-audio codec * * Author: Matt Ranostay <[email protected]> * Copyright (c) 2008 Embedded Alley Solutions Inc */ #include <linux/input.h> #include <linux/slab.h> #include <linux/workqueue.h> #include <linux/export.h> #include <sound/core.h> #include "hda_beep.h" #include "hda_local.h" enum { … }; /* generate or stop tone */ static void generate_tone(struct hda_beep *beep, int tone) { … } static void snd_hda_generate_beep(struct work_struct *work) { … } /* (non-standard) Linear beep tone calculation for IDT/STAC codecs * * The tone frequency of beep generator on IDT/STAC codecs is * defined from the 8bit tone parameter, in Hz, * freq = 48000 * (257 - tone) / 1024 * that is from 12kHz to 93.75Hz in steps of 46.875 Hz */ static int beep_linear_tone(struct hda_beep *beep, int hz) { … } /* HD-audio standard beep tone parameter calculation * * The tone frequency in Hz is calculated as * freq = 48000 / (tone * 4) * from 47Hz to 12kHz */ static int beep_standard_tone(struct hda_beep *beep, int hz) { … } static int snd_hda_beep_event(struct input_dev *dev, unsigned int type, unsigned int code, int hz) { … } static void turn_on_beep(struct hda_beep *beep) { … } static void turn_off_beep(struct hda_beep *beep) { … } /** * snd_hda_enable_beep_device - Turn on/off beep sound * @codec: the HDA codec * @enable: flag to turn on/off */ int snd_hda_enable_beep_device(struct hda_codec *codec, int enable) { … } EXPORT_SYMBOL_GPL(…); static int beep_dev_register(struct snd_device *device) { … } static int beep_dev_disconnect(struct snd_device *device) { … } static int beep_dev_free(struct snd_device *device) { … } /** * snd_hda_attach_beep_device - Attach a beep input device * @codec: the HDA codec * @nid: beep NID * * Attach a beep object to the given widget. If beep hint is turned off * explicitly or beep_mode of the codec is turned off, this doesn't nothing. * * Currently, only one beep device is allowed to each codec. */ int snd_hda_attach_beep_device(struct hda_codec *codec, int nid) { … } EXPORT_SYMBOL_GPL(…); /** * snd_hda_detach_beep_device - Detach the beep device * @codec: the HDA codec */ void snd_hda_detach_beep_device(struct hda_codec *codec) { … } EXPORT_SYMBOL_GPL(…); static bool ctl_has_mute(struct snd_kcontrol *kcontrol) { … } /* get/put callbacks for beep mute mixer switches */ /** * snd_hda_mixer_amp_switch_get_beep - Get callback for beep controls * @kcontrol: ctl element * @ucontrol: pointer to get/store the data */ int snd_hda_mixer_amp_switch_get_beep(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { … } EXPORT_SYMBOL_GPL(…); /** * snd_hda_mixer_amp_switch_put_beep - Put callback for beep controls * @kcontrol: ctl element * @ucontrol: pointer to get/store the data */ int snd_hda_mixer_amp_switch_put_beep(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { … } EXPORT_SYMBOL_GPL(…);