sound/soc/intel/avs/boards/rt5682.c

Source file repositories/reference/linux-study-clean/sound/soc/intel/avs/boards/rt5682.c

File Facts

System
Linux kernel
Corpus path
sound/soc/intel/avs/boards/rt5682.c
Extension
.c
Size
10100 bytes
Lines
346
Domain
Driver Families
Bucket
sound/soc
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0-only
//
// Copyright(c) 2021-2022 Intel Corporation
//
// Authors: Cezary Rojewski <cezary.rojewski@intel.com>
//          Amadeusz Slawinski <amadeuszx.slawinski@linux.intel.com>
//

#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)	((quirk) & GENMASK(2, 0))
#define AVS_RT5682_SSP_CODEC_MASK	(GENMASK(2, 0))
#define AVS_RT5682_MCLK_EN		BIT(3)
#define AVS_RT5682_MCLK_24MHZ		BIT(4)
#define AVS_RT5682_CODEC_DAI_NAME	"rt5682-aif1"

/* Default: MCLK on, MCLK 19.2M, SSP0 */
static unsigned long avs_rt5682_quirk = AVS_RT5682_MCLK_EN | AVS_RT5682_SSP_CODEC(0);

static int avs_rt5682_quirk_cb(const struct dmi_system_id *id)
{
	avs_rt5682_quirk = (unsigned long)id->driver_data;
	return 1;
}

static const struct dmi_system_id avs_rt5682_quirk_table[] = {
	{
		.callback = avs_rt5682_quirk_cb,
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "Intel Corporation"),
			DMI_MATCH(DMI_PRODUCT_NAME, "WhiskeyLake Client"),
		},
		.driver_data = (void *)(AVS_RT5682_MCLK_EN |
					AVS_RT5682_MCLK_24MHZ |
					AVS_RT5682_SSP_CODEC(1)),
	},
	{
		.callback = avs_rt5682_quirk_cb,
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "Intel Corporation"),
			DMI_MATCH(DMI_PRODUCT_NAME, "Ice Lake Client"),
		},
		.driver_data = (void *)(AVS_RT5682_MCLK_EN |
					AVS_RT5682_SSP_CODEC(0)),
	},
	{}
};

static const struct snd_kcontrol_new card_controls[] = {
	SOC_DAPM_PIN_SWITCH("Headphone Jack"),
	SOC_DAPM_PIN_SWITCH("Headset Mic"),
};

static const struct snd_soc_dapm_widget card_widgets[] = {
	SND_SOC_DAPM_HP("Headphone Jack", NULL),
	SND_SOC_DAPM_MIC("Headset Mic", NULL),
};

static const struct snd_soc_dapm_route card_base_routes[] = {
	/* HP jack connectors - unknown if we have jack detect */
	{ "Headphone Jack", NULL, "HPOL" },
	{ "Headphone Jack", NULL, "HPOR" },

	/* other jacks */
	{ "IN1P", NULL, "Headset Mic" },
};

static const struct snd_soc_jack_pin card_jack_pins[] = {
	{
		.pin = "Headphone Jack",
		.mask = SND_JACK_HEADPHONE,
	},
	{
		.pin = "Headset Mic",
		.mask = SND_JACK_MICROPHONE,

Annotation

Implementation Notes