Unverified Commit f2b45923 authored by Mark Brown's avatar Mark Brown
Browse files

Add support for cs42l45 into the Intel machine driver

Merge series from Charles Keepax <ckeepax@opensource.cirrus.com>:

Now that the full class driver is in place we can add support to the
Intel machine driver for Cirrus's new SDCA audio CODEC the cs42l45. This
makes some minor tweaks to the machine driver itself to support SDCA
devices, and then adds the necessary tables etc. to define the device.

Note, this series shouldn't have any dependencies on the other series of
improvements to the class driver that is already on the list. So either
can be merged first.
parents 86dc090f 1e645bca
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -611,7 +611,7 @@ enum sdca_entity0_controls {
#define SDCA_CTL_NDAI_PACKETTYPE_NAME			"NDAI Packet Type"
#define SDCA_CTL_MIXER_NAME				"Mixer"
#define SDCA_CTL_SELECTOR_NAME				"Selector"
#define SDCA_CTL_MUTE_NAME				"Mute"
#define SDCA_CTL_MUTE_NAME				"Channel"
#define SDCA_CTL_CHANNEL_VOLUME_NAME			"Channel Volume"
#define SDCA_CTL_AGC_NAME				"AGC"
#define SDCA_CTL_BASS_BOOST_NAME			"Bass Boost"
@@ -1456,6 +1456,8 @@ int sdca_parse_function(struct device *dev, struct sdw_slave *sdw,
			struct sdca_function_desc *desc,
			struct sdca_function_data *function);

const char *sdca_find_terminal_name(enum sdca_terminal_type type);

struct sdca_control *sdca_selector_find_control(struct device *dev,
						struct sdca_entity *entity,
						const int sel);
+14 −3
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@
#include <sound/soc-acpi.h>

#define SOC_SDW_MAX_DAI_NUM             8
#define SOC_SDW_MAX_AUX_NUM		2
#define SOC_SDW_MAX_NO_PROPS		2
#define SOC_SDW_JACK_JDSRC(quirk)	((quirk) & GENMASK(3, 0))

@@ -45,6 +46,7 @@ struct asoc_sdw_codec_info;

struct asoc_sdw_dai_info {
	const bool direction[2]; /* playback & capture support */
	const char *codec_name;
	const char *dai_name;
	const char *component_name;
	const int dai_type;
@@ -64,10 +66,13 @@ struct asoc_sdw_dai_info {
	bool quirk_exclude;
};

struct asoc_sdw_aux_info {
	const char *codec_name;
};

struct asoc_sdw_codec_info {
	const int part_id;
	const int version_id;
	const char *codec_name;
	const char *name_prefix;
	int amp_num;
	const u8 acpi_id[ACPI_ID_LEN];
@@ -75,6 +80,8 @@ struct asoc_sdw_codec_info {
	const struct snd_soc_ops *ops;
	struct asoc_sdw_dai_info dais[SOC_SDW_MAX_DAI_NUM];
	const int dai_num;
	struct asoc_sdw_aux_info auxs[SOC_SDW_MAX_AUX_NUM];
	const int aux_num;

	int (*codec_card_late_probe)(struct snd_soc_card *card);

@@ -131,7 +138,7 @@ int asoc_sdw_hw_free(struct snd_pcm_substream *substream);
void asoc_sdw_shutdown(struct snd_pcm_substream *substream);

const char *asoc_sdw_get_codec_name(struct device *dev,
				    const struct asoc_sdw_codec_info *codec_info,
				    const struct asoc_sdw_dai_info *dai_info,
				    const struct snd_soc_acpi_link_adr *adr_link,
				    int adr_index);

@@ -165,13 +172,15 @@ int asoc_sdw_init_simple_dai_link(struct device *dev, struct snd_soc_dai_link *d
				  int no_pcm, int (*init)(struct snd_soc_pcm_runtime *rtd),
				  const struct snd_soc_ops *ops);

int asoc_sdw_count_sdw_endpoints(struct snd_soc_card *card, int *num_devs, int *num_ends);
int asoc_sdw_count_sdw_endpoints(struct snd_soc_card *card,
				 int *num_devs, int *num_ends, int *num_aux);

struct asoc_sdw_dailink *asoc_sdw_find_dailink(struct asoc_sdw_dailink *dailinks,
					       const struct snd_soc_acpi_endpoint *new);
int asoc_sdw_get_dai_type(u32 type);

int asoc_sdw_parse_sdw_endpoints(struct snd_soc_card *card,
				 struct snd_soc_aux_dev *soc_aux,
				 struct asoc_sdw_dailink *soc_dais,
				 struct asoc_sdw_endpoint *soc_ends,
				 int *num_devs);
@@ -248,6 +257,8 @@ int asoc_sdw_cs42l42_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_da
int asoc_sdw_cs42l43_hs_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
int asoc_sdw_cs42l43_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
int asoc_sdw_cs42l43_dmic_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
int asoc_sdw_cs42l45_hs_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
int asoc_sdw_cs42l45_dmic_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
int asoc_sdw_cs_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
int asoc_sdw_maxim_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
/* TI */
+15 −4
Original line number Diff line number Diff line
@@ -360,20 +360,25 @@ static int soc_card_dai_links_create(struct snd_soc_card *card)
	struct snd_soc_acpi_mach_params *mach_params = &mach->mach_params;
	struct asoc_sdw_endpoint *soc_ends __free(kfree) = NULL;
	struct asoc_sdw_dailink *soc_dais __free(kfree) = NULL;
	struct snd_soc_aux_dev *soc_aux;
	struct snd_soc_codec_conf *codec_conf;
	struct snd_soc_dai_link *dai_links;
	int num_devs = 0;
	int num_ends = 0;
	int num_aux = 0;
	int num_confs;
	int num_links;
	int be_id = 0;
	int ret;

	ret = asoc_sdw_count_sdw_endpoints(card, &num_devs, &num_ends);
	ret = asoc_sdw_count_sdw_endpoints(card, &num_devs, &num_ends, &num_aux);
	if (ret < 0) {
		dev_err(dev, "failed to count devices/endpoints: %d\n", ret);
		return ret;
	}

	num_confs = num_ends;

	/* One per DAI link, worst case is a DAI link for every endpoint */
	soc_dais = kcalloc(num_ends, sizeof(*soc_dais), GFP_KERNEL);
	if (!soc_dais)
@@ -384,7 +389,11 @@ static int soc_card_dai_links_create(struct snd_soc_card *card)
	if (!soc_ends)
		return -ENOMEM;

	ret = asoc_sdw_parse_sdw_endpoints(card, soc_dais, soc_ends, &num_devs);
	soc_aux = devm_kcalloc(dev, num_aux, sizeof(*soc_aux), GFP_KERNEL);
	if (!soc_aux)
		return -ENOMEM;

	ret = asoc_sdw_parse_sdw_endpoints(card, soc_aux, soc_dais, soc_ends, &num_confs);
	if (ret < 0)
		return ret;

@@ -396,7 +405,7 @@ static int soc_card_dai_links_create(struct snd_soc_card *card)

	dev_dbg(dev, "sdw %d, dmic %d", sdw_be_num, dmic_num);

	codec_conf = devm_kcalloc(dev, num_devs, sizeof(*codec_conf), GFP_KERNEL);
	codec_conf = devm_kcalloc(dev, num_confs, sizeof(*codec_conf), GFP_KERNEL);
	if (!codec_conf)
		return -ENOMEM;

@@ -407,9 +416,11 @@ static int soc_card_dai_links_create(struct snd_soc_card *card)
		return -ENOMEM;

	card->codec_conf = codec_conf;
	card->num_configs = num_devs;
	card->num_configs = num_confs;
	card->dai_link = dai_links;
	card->num_links = num_links;
	card->aux_dev = soc_aux;
	card->num_aux_devs = num_aux;

	/* SDW */
	if (sdw_be_num) {
+10 −2
Original line number Diff line number Diff line
@@ -272,15 +272,17 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
	struct snd_soc_acpi_mach_params *mach_params = &mach->mach_params;
	struct asoc_sdw_endpoint *sof_ends __free(kfree) = NULL;
	struct asoc_sdw_dailink *sof_dais __free(kfree) = NULL;
	struct snd_soc_aux_dev *sof_aux;
	struct snd_soc_codec_conf *codec_conf;
	struct snd_soc_dai_link *dai_links;
	int num_devs = 0;
	int num_ends = 0;
	int num_aux = 0;
	int num_links;
	int be_id = 0;
	int ret;

	ret = asoc_sdw_count_sdw_endpoints(card, &num_devs, &num_ends);
	ret = asoc_sdw_count_sdw_endpoints(card, &num_devs, &num_ends, &num_aux);
	if (ret < 0) {
		dev_err(dev, "failed to count devices/endpoints: %d\n", ret);
		return ret;
@@ -296,7 +298,11 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
	if (!sof_ends)
		return -ENOMEM;

	ret = asoc_sdw_parse_sdw_endpoints(card, sof_dais, sof_ends, &num_devs);
	sof_aux = devm_kcalloc(dev, num_aux, sizeof(*sof_aux), GFP_KERNEL);
	if (!sof_aux)
		return -ENOMEM;

	ret = asoc_sdw_parse_sdw_endpoints(card, sof_aux, sof_dais, sof_ends, &num_devs);
	if (ret < 0)
		return ret;

@@ -322,6 +328,8 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
	card->num_configs = num_devs;
	card->dai_link = dai_links;
	card->num_links = num_links;
	card->aux_dev = sof_aux;
	card->num_aux_devs = num_aux;

	/* SDW */
	if (sdw_be_num) {
+17 −4
Original line number Diff line number Diff line
@@ -1189,8 +1189,11 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
	struct asoc_sdw_codec_info *ssp_info;
	struct asoc_sdw_endpoint *sof_ends;
	struct asoc_sdw_dailink *sof_dais;
	struct snd_soc_aux_dev *sof_aux;
	int num_devs = 0;
	int num_ends = 0;
	int num_aux = 0;
	int num_confs;
	struct snd_soc_dai_link *dai_links;
	int num_links;
	int be_id = 0;
@@ -1198,12 +1201,14 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
	unsigned long ssp_mask;
	int ret;

	ret = asoc_sdw_count_sdw_endpoints(card, &num_devs, &num_ends);
	ret = asoc_sdw_count_sdw_endpoints(card, &num_devs, &num_ends, &num_aux);
	if (ret < 0) {
		dev_err(dev, "failed to count devices/endpoints: %d\n", ret);
		return ret;
	}

	num_confs = num_ends;

	/*
	 * One per DAI link, worst case is a DAI link for every endpoint, also
	 * add one additional to act as a terminator such that code can iterate
@@ -1220,7 +1225,13 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
		goto err_dai;
	}

	ret = asoc_sdw_parse_sdw_endpoints(card, sof_dais, sof_ends, &num_devs);
	sof_aux = devm_kcalloc(dev, num_aux, sizeof(*sof_aux), GFP_KERNEL);
	if (!sof_aux) {
		ret = -ENOMEM;
		goto err_dai;
	}

	ret = asoc_sdw_parse_sdw_endpoints(card, sof_aux, sof_dais, sof_ends, &num_confs);
	if (ret < 0)
		goto err_end;

@@ -1268,7 +1279,7 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
		sdw_be_num, ssp_num, dmic_num,
		intel_ctx->hdmi.idisp_codec ? hdmi_num : 0, bt_num);

	codec_conf = devm_kcalloc(dev, num_devs, sizeof(*codec_conf), GFP_KERNEL);
	codec_conf = devm_kcalloc(dev, num_confs, sizeof(*codec_conf), GFP_KERNEL);
	if (!codec_conf) {
		ret = -ENOMEM;
		goto err_end;
@@ -1283,9 +1294,11 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
	}

	card->codec_conf = codec_conf;
	card->num_configs = num_devs;
	card->num_configs = num_confs;
	card->dai_link = dai_links;
	card->num_links = num_links;
	card->aux_dev = sof_aux;
	card->num_aux_devs = num_aux;

	/* SDW */
	if (sdw_be_num) {
Loading