All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rander Wang <rander.wang@linux.intel.com>
To: broonie@kernel.org, pierre-louis.bossart@linux.intel.com,
	alsa-devel@alsa-project.org
Cc: Rander Wang <rander.wang@linux.intel.com>
Subject: [RFC] ASoC: Intel: skl_hda_dsp_common: set long name for skl_hda_card
Date: Tue, 21 May 2019 15:07:41 +0800	[thread overview]
Message-ID: <20190521070741.65866-1-rander.wang@linux.intel.com> (raw)

skl_hda_generic machine driver is used by many different devices
and userspace uses the card long name to differentiate devices.
The card long name is figured out by DMI info and is in format
of "vendor-product-version-board". Ucm file is searched by this
card long name and one problem is different devices can't share
one ucm file based on this type of long name. We have three different
product devices with the same codecs and audio settings, and these
devices can share the same ucm setting, but now we need to provide
three ucm files with different long names, because we can't get a
same long name from DMI info.

The solution is to provide card long name in machine driver like
bytcr_rt5640 and ASoC will use this long name to generate final long
name. The card long name is composed of codec name, input and output
enabled by devices. The long name should be initialized after hda codec
is initialized and before sound card checking long name which is done
after dai link initialization, so the long name is set in codec dai
link initialization function.

Possible card long names may be:
skl-hda-ALC233-config135440
skl-hda-ALC700-config69649
skl-hda-ALC3204-config135185

Tested on intel hda platform whiskylake with SOF driver and gemilake
with intel SST driver

Signed-off-by: Rander Wang <rander.wang@linux.intel.com>
---
 sound/soc/intel/boards/skl_hda_dsp_common.c | 54 +++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/sound/soc/intel/boards/skl_hda_dsp_common.c b/sound/soc/intel/boards/skl_hda_dsp_common.c
index 8b68f41a5b88..0193d2138e16 100644
--- a/sound/soc/intel/boards/skl_hda_dsp_common.c
+++ b/sound/soc/intel/boards/skl_hda_dsp_common.c
@@ -11,11 +11,18 @@
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
 #include <sound/soc.h>
+#include <sound/hda_codec.h>
+#include "../../../pci/hda/hda_jack.h"
+#include "../../../pci/hda/hda_local.h"
+#include "../../../pci/hda/hda_auto_parser.h"
+#include "../../../pci/hda/hda_generic.h"
 #include "../../codecs/hdac_hdmi.h"
+#include "../../codecs/hdac_hda.h"
 #include "../skylake/skl.h"
 #include "skl_hda_dsp_common.h"
 
 #define NAME_SIZE	32
+static char skl_hda_long_name[NAME_SIZE];
 
 int skl_hda_hdmi_add_pcm(struct snd_soc_card *card, int device)
 {
@@ -39,6 +46,52 @@ int skl_hda_hdmi_add_pcm(struct snd_soc_card *card, int device)
 	return 0;
 }
 
+int skl_hda_long_name_init(struct snd_soc_pcm_runtime *rtd)
+{
+	struct snd_soc_rtdcom_list *new_rtdcom;
+	struct snd_soc_component *component;
+	struct hdac_hda_priv *hda_pvt;
+	struct auto_pin_cfg *autocfg;
+	struct hda_gen_spec *spec;
+	struct snd_soc_card *card;
+	const char *name;
+	int config;
+
+	name = rtd->dai_link->codecs->name;
+	card = rtd->card;
+
+	list_for_each_entry(new_rtdcom, &rtd->component_list, list) {
+		component = new_rtdcom->component;
+		if (name && strcmp(component->name, name) == 0) {
+			hda_pvt = snd_soc_component_get_drvdata(component);
+
+			if (!hda_pvt)
+				return -EINVAL;
+
+			spec = hda_pvt->codec.spec;
+			autocfg = &spec->autocfg;
+
+			/*
+			 * config is figured out by combining the number of
+			 * enabled input and output.
+			 */
+			config = autocfg->speaker_outs | (autocfg->hp_outs << 4)
+				| (autocfg->dig_outs << 8)
+				| (autocfg->line_outs << 12)
+				| (autocfg->num_inputs << 16);
+			snprintf(skl_hda_long_name, sizeof(skl_hda_long_name),
+				 "skl-hda-%s-config%d",
+				 hda_pvt->codec.core.chip_name,
+				 config);
+
+			card->long_name = skl_hda_long_name;
+			break;
+		}
+	}
+
+	return 0;
+}
+
 /* skl_hda_digital audio interface glue - connects codec <--> CPU */
 struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS] = {
 	/* Back End DAI links */
@@ -79,6 +132,7 @@ struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS] = {
 		.dpcm_playback = 1,
 		.dpcm_capture = 1,
 		.no_pcm = 1,
+		.init = skl_hda_long_name_init,
 	},
 	{
 		.name = "Digital Playback and Capture",
-- 
2.14.1

             reply	other threads:[~2019-05-21  7:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-21  7:07 Rander Wang [this message]
2019-05-21 14:38 ` [RFC] ASoC: Intel: skl_hda_dsp_common: set long name for skl_hda_card Pierre-Louis Bossart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190521070741.65866-1-rander.wang@linux.intel.com \
    --to=rander.wang@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=pierre-louis.bossart@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.