#include <linux/clk.h>
#include <linux/dmi.h>
#include <linux/i2c.h>
#include <linux/input.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <sound/core.h>
#include <sound/jack.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/rt5682.h>
#include <sound/soc.h>
#include <sound/soc-acpi.h>
#include "../../common/soc-intel-quirks.h"
#include "../../../codecs/rt5682.h"
#include "../utils.h"
#define AVS_RT5682_SSP_CODEC(quirk) …
#define AVS_RT5682_SSP_CODEC_MASK …
#define AVS_RT5682_MCLK_EN …
#define AVS_RT5682_MCLK_24MHZ …
#define AVS_RT5682_CODEC_DAI_NAME …
static unsigned long avs_rt5682_quirk = …;
static int avs_rt5682_quirk_cb(const struct dmi_system_id *id)
{ … }
static const struct dmi_system_id avs_rt5682_quirk_table[] = …;
static const struct snd_kcontrol_new card_controls[] = …;
static const struct snd_soc_dapm_widget card_widgets[] = …;
static const struct snd_soc_dapm_route card_base_routes[] = …;
static const struct snd_soc_jack_pin card_jack_pins[] = …;
static int avs_rt5682_codec_init(struct snd_soc_pcm_runtime *runtime)
{
struct snd_soc_component *component = snd_soc_rtd_to_codec(runtime, 0)->component;
struct snd_soc_card *card = runtime->card;
struct snd_soc_jack_pin *pins;
struct snd_soc_jack *jack;
int num_pins, ret;
jack = snd_soc_card_get_drvdata(card);
num_pins = ARRAY_SIZE(card_jack_pins);
pins = devm_kmemdup(card->dev, card_jack_pins, sizeof(*pins) * num_pins, GFP_KERNEL);
if (!pins)
return -ENOMEM;
if ((avs_rt5682_quirk & AVS_RT5682_MCLK_EN) &&
(avs_rt5682_quirk & AVS_RT5682_MCLK_24MHZ)) {
rt5682_sel_asrc_clk_src(component, RT5682_DA_STEREO1_FILTER |
RT5682_AD_STEREO1_FILTER, RT5682_CLK_SEL_I2S1_ASRC);
}
ret = snd_soc_card_jack_new_pins(card, "Headset Jack", SND_JACK_HEADSET | SND_JACK_BTN_0 |
SND_JACK_BTN_1 | SND_JACK_BTN_2 | SND_JACK_BTN_3, jack,
pins, num_pins);
if (ret) {
dev_err(card->dev, "Headset Jack creation failed: %d\n", ret);
return ret;
}
snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOICECOMMAND);
snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP);
snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN);
ret = snd_soc_component_set_jack(component, jack, NULL);
if (ret) {
dev_err(card->dev, "Headset Jack call-back failed: %d\n", ret);
return ret;
}
return 0;
};
static void avs_rt5682_codec_exit(struct snd_soc_pcm_runtime *rtd)
{ … }
static int
avs_rt5682_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params)
{ … }
static const struct snd_soc_ops avs_rt5682_ops = …;
static int
avs_rt5682_be_fixup(struct snd_soc_pcm_runtime *runtime, struct snd_pcm_hw_params *params)
{ … }
static int avs_create_dai_link(struct device *dev, const char *platform_name, int ssp_port,
int tdm_slot, struct snd_soc_dai_link **dai_link)
{ … }
static int avs_card_suspend_pre(struct snd_soc_card *card)
{ … }
static int avs_card_resume_post(struct snd_soc_card *card)
{ … }
static int avs_rt5682_probe(struct platform_device *pdev)
{ … }
static const struct platform_device_id avs_rt5682_driver_ids[] = …;
MODULE_DEVICE_TABLE(platform, avs_rt5682_driver_ids);
static struct platform_driver avs_rt5682_driver = …;
module_platform_driver(…) …
MODULE_DESCRIPTION(…) …;
MODULE_AUTHOR(…) …;
MODULE_LICENSE(…) …;