1 // SPDX-License-Identifier: GPL-2.0-only 2 // Copyright (c) 2023 Intel Corporation 3 4 /* 5 * sof_sdw_cs_amp - Helpers to handle CS35L56 from generic machine driver 6 */ 7 8 #include <linux/device.h> 9 #include <linux/errno.h> 10 #include <sound/soc.h> 11 #include <sound/soc-acpi.h> 12 #include "sof_sdw_common.h" 13 14 #define CODEC_NAME_SIZE 8 15 16 static int cs_spk_init(struct snd_soc_pcm_runtime *rtd) 17 { 18 const char *dai_name = rtd->dai_link->codecs->dai_name; 19 struct snd_soc_card *card = rtd->card; 20 char codec_name[CODEC_NAME_SIZE]; 21 22 snprintf(codec_name, CODEC_NAME_SIZE, "%s", dai_name); 23 card->components = devm_kasprintf(card->dev, GFP_KERNEL, 24 "%s spk:%s", 25 card->components, codec_name); 26 if (!card->components) 27 return -ENOMEM; 28 29 return 0; 30 } 31 32 33 int sof_sdw_cs_amp_init(struct snd_soc_card *card, 34 const struct snd_soc_acpi_link_adr *link, 35 struct snd_soc_dai_link *dai_links, 36 struct sof_sdw_codec_info *info, 37 bool playback) 38 { 39 /* Count amp number and do init on playback link only. */ 40 if (!playback) 41 return 0; 42 43 info->amp_num++; 44 dai_links->init = cs_spk_init; 45 46 return 0; 47 } 48