Unverified Commit 7c66c4f7 authored by Mark Brown's avatar Mark Brown
Browse files

ASoC: Intel: add rt722/rt721 support for PTL platform

Merge series from Bard Liao <yung-chuan.liao@linux.intel.com>:

Rt722, rt721 and rt712 codecs are quite similar. Refactor the existing
spk_rtd_init() to support Realtek common multifunction SDCA codecs.
parents 128e5cb6 846a8d3c
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -234,8 +234,7 @@ int asoc_sdw_rt_sdca_jack_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_s
int asoc_sdw_rt_amp_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
int asoc_sdw_rt700_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
int asoc_sdw_rt711_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
int asoc_sdw_rt712_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
int asoc_sdw_rt722_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
int asoc_sdw_rt_mf_sdca_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
int asoc_sdw_rt5682_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
int asoc_sdw_cs42l42_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
int asoc_sdw_cs42l43_hs_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
+8 −0
Original line number Diff line number Diff line
@@ -598,6 +598,14 @@ static const struct dmi_system_id sof_sdw_quirk_table[] = {
		},
		.driver_data = (void *)(SOC_SDW_CODEC_SPKR),
	},
	/* Pantherlake devices*/
	{
		.callback = sof_sdw_quirk_cb,
		.matches = {
			DMI_MATCH(DMI_PRODUCT_FAMILY, "Intel_ptlrvp"),
		},
		.driver_data = (void *)(SOC_SDW_PCH_DMIC),
	},
	{}
};

+55 −7
Original line number Diff line number Diff line
@@ -36,10 +36,10 @@ static const struct snd_soc_acpi_endpoint single_endpoint = {
};

/*
 * RT722 is a multi-function codec, three endpoints are created for
 * its headset, amp and dmic functions.
 * Multi-function codecs with three endpoints created for
 * headset, amp and dmic functions.
 */
static const struct snd_soc_acpi_endpoint rt722_endpoints[] = {
static const struct snd_soc_acpi_endpoint rt_mf_endpoints[] = {
	{
		.num = 0,
		.aggregated = 0,
@@ -69,11 +69,38 @@ static const struct snd_soc_acpi_adr_device rt711_sdca_0_adr[] = {
	}
};

static const struct snd_soc_acpi_adr_device rt721_3_single_adr[] = {
	{
		.adr = 0x000330025d072101ull,
		.num_endpoints = ARRAY_SIZE(rt_mf_endpoints),
		.endpoints = rt_mf_endpoints,
		.name_prefix = "rt721"
	}
};

static const struct snd_soc_acpi_link_adr ptl_rt721_l3[] = {
	{
		.mask = BIT(3),
		.num_adr = ARRAY_SIZE(rt721_3_single_adr),
		.adr_d = rt721_3_single_adr,
	},
	{},
};

static const struct snd_soc_acpi_adr_device rt722_0_single_adr[] = {
	{
		.adr = 0x000030025d072201ull,
		.num_endpoints = ARRAY_SIZE(rt722_endpoints),
		.endpoints = rt722_endpoints,
		.num_endpoints = ARRAY_SIZE(rt_mf_endpoints),
		.endpoints = rt_mf_endpoints,
		.name_prefix = "rt722"
	}
};

static const struct snd_soc_acpi_adr_device rt722_1_single_adr[] = {
	{
		.adr = 0x000130025d072201ull,
		.num_endpoints = ARRAY_SIZE(rt_mf_endpoints),
		.endpoints = rt_mf_endpoints,
		.name_prefix = "rt722"
	}
};
@@ -81,8 +108,8 @@ static const struct snd_soc_acpi_adr_device rt722_0_single_adr[] = {
static const struct snd_soc_acpi_adr_device rt722_3_single_adr[] = {
	{
		.adr = 0x000330025d072201ull,
		.num_endpoints = ARRAY_SIZE(rt722_endpoints),
		.endpoints = rt722_endpoints,
		.num_endpoints = ARRAY_SIZE(rt_mf_endpoints),
		.endpoints = rt_mf_endpoints,
		.name_prefix = "rt722"
	}
};
@@ -96,6 +123,15 @@ static const struct snd_soc_acpi_link_adr ptl_rt722_only[] = {
	{}
};

static const struct snd_soc_acpi_link_adr ptl_rt722_l1[] = {
	{
		.mask = BIT(1),
		.num_adr = ARRAY_SIZE(rt722_1_single_adr),
		.adr_d = rt722_1_single_adr,
	},
	{}
};

static const struct snd_soc_acpi_link_adr ptl_rt722_l3[] = {
	{
		.mask = BIT(3),
@@ -141,12 +177,24 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_ptl_sdw_machines[] = {
		.drv_name = "sof_sdw",
		.sof_tplg_filename = "sof-ptl-rt711.tplg",
	},
	{
		.link_mask = BIT(3),
		.links = ptl_rt721_l3,
		.drv_name = "sof_sdw",
		.sof_tplg_filename = "sof-ptl-rt721.tplg",
	},
	{
		.link_mask = BIT(0),
		.links = ptl_rt722_only,
		.drv_name = "sof_sdw",
		.sof_tplg_filename = "sof-ptl-rt722.tplg",
	},
	{
		.link_mask = BIT(1),
		.links = ptl_rt722_l1,
		.drv_name = "sof_sdw",
		.sof_tplg_filename = "sof-ptl-rt722.tplg",
	},
	{
		.link_mask = BIT(3),
		.links = ptl_rt722_l3,
+1 −2
Original line number Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0-only
snd-soc-sdw-utils-y := soc_sdw_utils.o soc_sdw_dmic.o soc_sdw_rt_dmic.o \
		       soc_sdw_rt700.o soc_sdw_rt711.o 			\
		       soc_sdw_rt712_sdca.o soc_sdw_rt722_sdca.o	\
		       soc_sdw_rt5682.o soc_sdw_rt_sdca_jack_common.o	\
		       soc_sdw_rt_amp.o					\
		       soc_sdw_rt_amp.o soc_sdw_rt_mf_sdca.o		\
		       soc_sdw_bridge_cs35l56.o 			\
		       soc_sdw_cs42l42.o soc_sdw_cs42l43.o 		\
		       soc_sdw_cs_amp.o					\
+0 −48
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
// This file incorporates work covered by the following copyright notice:
// Copyright (c) 2023 Intel Corporation
// Copyright (c) 2024 Advanced Micro Devices, Inc.

/*
 *  soc_sdw_rt712_sdca - Helpers to handle RT712-SDCA from generic machine driver
 */

#include <linux/device.h>
#include <linux/errno.h>
#include <linux/soundwire/sdw.h>
#include <linux/soundwire/sdw_type.h>
#include <sound/control.h>
#include <sound/soc.h>
#include <sound/soc-acpi.h>
#include <sound/soc-dapm.h>
#include <sound/soc_sdw_utils.h>

/*
 * dapm routes for rt712 spk will be registered dynamically according
 * to the number of rt712 spk used. The first two entries will be registered
 * for one codec case, and the last two entries are also registered
 * if two rt712s are used.
 */
static const struct snd_soc_dapm_route rt712_spk_map[] = {
	{ "Speaker", NULL, "rt712 SPOL" },
	{ "Speaker", NULL, "rt712 SPOR" },
};

int asoc_sdw_rt712_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai)
{
	struct snd_soc_card *card = rtd->card;
	int ret;

	card->components = devm_kasprintf(card->dev, GFP_KERNEL,
					  "%s spk:rt712",
					  card->components);
	if (!card->components)
		return -ENOMEM;

	ret = snd_soc_dapm_add_routes(&card->dapm, rt712_spk_map, ARRAY_SIZE(rt712_spk_map));
	if (ret)
		dev_err(rtd->dev, "failed to add SPK map: %d\n", ret);

	return ret;
}
EXPORT_SYMBOL_NS(asoc_sdw_rt712_spk_rtd_init, SND_SOC_SDW_UTILS);
Loading