Skip to contentSkip to conversation

Enable HDA Codec support on Intel Platforms (Series2)

RFC Superseded Rakesh Ughreja 3 participants 24 messages Dec 11, 2017 – Dec 13, 2017

Subsystems (3)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover Enable HDA Codec support on Intel Platforms (Series2)

Many Intel platforms (SKL, KBL) etc. in the market supports enhanced audio capabilities which also includes DSP processing. This patch carry forwards the works that is done in the previous series to enable HD Audio codecs on such platforms.

This patch series adds ASoC HDA codec driver for Intel platforms. It is written by reusing the legacy HDA ALSA codec driver. Intention is to maximize the reuse and minimize the changes in the legacy HDA codec driver.

I would like to receive feedback before proceeding further on this direction.

INFO:
- This series is tested on KBL based product (Dell XPS 13).
- Basic playback is working with headset and speakers.
- HDMI playback is working.
- Capture operation is not tested.
- More platforms and use cases coverage can be added once we have basic agreement in terms of the overall approach.

Changes in v2:
- Using Topology framework to create DAIs and DAI Links
- Moved most commonly used functions into a separate file for machine driver
- Implemented separate Realtek ASoC HDA Driver driver for Realtek HDA codecs. It is just a driver registration wrapper which reuses the legacy HDA codec driver. This allows the removes the limitation that was present in v1.
- Implemented the review feedback.

Rakesh Ughreja (11):
ASoC: Intel: Boards: Machine driver for Intel platforms
ASoC: Intel: Skylake: Add entry in sst_acpi_mach for HDA codecs
ASoC: Intel: Skylake: add HDA BE DAIs
ASoC: Intel: Skylake: use hda_bus instead of hdac_bus
ALSA: hda - make some of the functions externally visible
ASoC: hdac_hda: add ASoC based HDA codec driver
ALSA: hda: add new API snd_hda_asoc_codec_new for ASoC codec drivers
ASoC: hdac_hda: add DAI, widgets and related ops
ASoC: hdac_hda: add runtime PM support
ASoC: patch_realtek: add ASoC based Realtek HDA codec driver patch
ASoC: Intel: Boards: add support for HDA codecs

 include/sound/hdaudio_ext.h                  |   3 +-
 sound/hda/ext/hdac_ext_bus.c                 |   9 +-
 sound/pci/hda/hda_codec.c                    | 109 ++++-
 sound/pci/hda/hda_codec.h                    |   4 +
 sound/pci/hda/patch_realtek.c                |   3 +-
 sound/soc/codecs/Kconfig                     |  12 +
 sound/soc/codecs/Makefile                    |   4 +
 sound/soc/codecs/hdac_hda.c                  | 628 +++++++++++++++++++++++++++
 sound/soc/codecs/hdac_hda.h                  |  26 ++
 sound/soc/codecs/patch_realtek.c             |  48 ++
 sound/soc/intel/boards/Kconfig               |  11 +
 sound/soc/intel/boards/Makefile              |   2 +
 sound/soc/intel/boards/skl_hda_dsp_common.c  | 173 ++++++++
 sound/soc/intel/boards/skl_hda_dsp_common.h  |  42 ++
 sound/soc/intel/boards/skl_hda_dsp_generic.c | 141 ++++++
 sound/soc/intel/skylake/skl-pcm.c            |  32 +-
 sound/soc/intel/skylake/skl.c                |  79 +++-
 sound/soc/intel/skylake/skl.h                |  10 +-
 18 files changed, 1311 insertions(+), 25 deletions(-)
 create mode 100644 sound/soc/codecs/hdac_hda.c
 create mode 100644 sound/soc/codecs/hdac_hda.h
 create mode 100644 sound/soc/codecs/patch_realtek.c
 create mode 100644 sound/soc/intel/boards/skl_hda_dsp_common.c
 create mode 100644 sound/soc/intel/boards/skl_hda_dsp_common.h
 create mode 100644 sound/soc/intel/boards/skl_hda_dsp_generic.c
Signature · 1 line
2.7.4
#1 lore raw

RFC v2 1/11 ASoC: Intel: Boards: Machine driver for Intel platforms

Add machine driver for Intel platforms(SKL/KBL) with HDA and iDisp codecs. This patch adds support for only iDisp (HDMI/DP) codec. In the following patch support for HDA codec will be added.

This should work for other Intel platforms as well e.g. BXT,GLK,CNL however this series is not tested on all the platforms.

---
 sound/soc/intel/boards/Kconfig               |  10 +++
 sound/soc/intel/boards/Makefile              |   2 +
 sound/soc/intel/boards/skl_hda_dsp_common.c  | 130 +++++++++++++++++++++++++++
 sound/soc/intel/boards/skl_hda_dsp_common.h  |  42 +++++++++
 sound/soc/intel/boards/skl_hda_dsp_generic.c | 112 +++++++++++++++++++++++
 5 files changed, 296 insertions(+)
 create mode 100644 sound/soc/intel/boards/skl_hda_dsp_common.c
 create mode 100644 sound/soc/intel/boards/skl_hda_dsp_common.h
 create mode 100644 sound/soc/intel/boards/skl_hda_dsp_generic.c
sound/soc/intel/boards/Kconfig +10 -0
index 6f75470..e01137d 100644
@@ -262,4 +262,14 @@ config SND_SOC_INTEL_KBL_RT5663_RT5514_MAX98927_MACH
           Say Y if you have such a device.
           If unsure select "N".
 
+config SND_SOC_INTEL_SKL_HDA_DSP_GENERIC_MACH
+        tristate "ASoC Audio driver for SKL/KBL with HDA Codecs"
+        select SND_SOC_INTEL_SST
+        depends on SND_SOC_INTEL_SKYLAKE
+        select SND_SOC_HDAC_HDMI
+        help
+          This adds support for ASoC Onboard Codec HDA machine driver. This will
+          create an alsa sound card for HDA Codecs.
+          Say Y if you have such a device.
+          If unsure select "N".
 endif
sound/soc/intel/boards/Makefile +2 -0
index 69d2dfa..7f6ab8e 100644
@@ -17,6 +17,7 @@ snd-soc-sst-byt-cht-nocodec-objs := bytcht_nocodec.o
 snd-soc-kbl_rt5663_max98927-objs := kbl_rt5663_max98927.o
 snd-soc-kbl_rt5663_rt5514_max98927-objs := kbl_rt5663_rt5514_max98927.o
 snd-soc-skl_rt286-objs := skl_rt286.o
+snd-soc-skl_hda_dsp-objs := skl_hda_dsp_generic.o skl_hda_dsp_common.o
 snd-skl_nau88l25_max98357a-objs := skl_nau88l25_max98357a.o
 snd-soc-skl_nau88l25_ssm4567-objs := skl_nau88l25_ssm4567.o
 
@@ -40,3 +41,4 @@ obj-$(CONFIG_SND_SOC_INTEL_KBL_RT5663_RT5514_MAX98927_MACH) += snd-soc-kbl_rt566
 obj-$(CONFIG_SND_SOC_INTEL_SKL_RT286_MACH) += snd-soc-skl_rt286.o
 obj-$(CONFIG_SND_SOC_INTEL_SKL_NAU88L25_MAX98357A_MACH) += snd-skl_nau88l25_max98357a.o
 obj-$(CONFIG_SND_SOC_INTEL_SKL_NAU88L25_SSM4567_MACH) += snd-soc-skl_nau88l25_ssm4567.o
+obj-$(CONFIG_SND_SOC_INTEL_SKL_HDA_DSP_GENERIC_MACH) += snd-soc-skl_hda_dsp.o
sound/soc/intel/boards/skl_hda_dsp_common.c new file +130 -0

130 lines not on this page · raw message

sound/soc/intel/boards/skl_hda_dsp_common.h new file +42 -0

42 lines not on this page · raw message

sound/soc/intel/boards/skl_hda_dsp_generic.c new file +112 -0

112 lines not on this page · raw message

Signature · 1 line
2.7.4
#2 lore raw

RFC v2 2/11 ASoC: Intel: Skylake: Add entry in sst_acpi_mach for HDA codecs

In reply to Rakesh Ughreja

When no I2S based codecs are detected in the BIOS, check if there are any HDA codecs present. If yes, load the corresponding machine driver.

TODO:
support for detecting the presence of HDA codec is not implemented. it will be implemented in the next revision.

---
 sound/soc/intel/skylake/skl.c | 46 ++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 43 insertions(+), 3 deletions(-)
sound/soc/intel/skylake/skl.c +43 -3
index 6fc2173..b99c1d8 100644
@@ -442,6 +442,26 @@ static struct skl_ssp_clk skl_ssp_clks[] = {
 						{.name = "ssp5_sclkfs"},
 };
 
+static struct snd_soc_acpi_mach *skl_probe_hda_machine(
+					struct snd_soc_acpi_mach *machines)
+{
+
+	struct snd_soc_acpi_mach *mach;
+
+	/*
+	 * FIXME:
+	 * First check if there are any HDA codecs present on the system
+	 * then search the match table.
+	 * For now this function is not detecting the presence of any
+	 * HDA codecs.
+	 */
+	for (mach = machines; mach->id[0]; mach++) {
+		if (!strcmp(mach->id, "HDA_GEN"))
+			return mach;
+	}
+	return NULL;
+}
+
 static int skl_machine_device_register(struct skl *skl, void *driver_data)
 {
 	struct hdac_bus *bus = skl_to_bus(skl);
@@ -451,9 +471,14 @@ static int skl_machine_device_register(struct skl *skl, void *driver_data)
 
 	mach = snd_soc_acpi_find_machine(mach);
 	if (mach == NULL) {
-		dev_err(bus->dev, "No matching machine driver found\n");
-		return -ENODEV;
+		dev_dbg(bus->dev, "No matching I2S machine driver found\n");
+		mach = skl_probe_hda_machine(driver_data);
+		if (mach == NULL) {
+			dev_err(bus->dev, "No matching machine driver found\n");
+			return -ENODEV;
+		}
 	}
+
 	skl->fw_name = mach->fw_filename;
 
 	pdev = platform_device_alloc(mach->drv_name, -1);
@@ -1005,6 +1030,14 @@ static struct snd_soc_acpi_mach sst_skl_devdata[] = {
 		.quirk_data = &skl_codecs,
 		.pdata = &skl_dmic_data
 	},
+	{
+		.id = "HDA_GEN",
+		.drv_name = "skl_hda_generic",
+		.fw_filename = "intel/dsp_fw_release.bin",
+		.machine_quirk = NULL,
+		.quirk_data = NULL,
+		.pdata = &cnl_pdata,
+	},
 	{}
 };
 
@@ -1067,7 +1100,14 @@ static struct snd_soc_acpi_mach sst_kbl_devdata[] = {
 		.drv_name = "kbl_rt5663",
 		.fw_filename = "intel/dsp_fw_kbl.bin",
 	},
-
+	{
+		.id = "HDA_GEN",
+		.drv_name = "skl_hda_generic",
+		.fw_filename = "intel/dsp_fw_kbl.bin",
+		.machine_quirk = NULL,
+		.quirk_data = NULL,
+		.pdata = &cnl_pdata,
+	},
 	{}
 };
 
Signature · 1 line
2.7.4
#3 lore raw

RFC v2 3/11 ASoC: Intel: Skylake: add HDA BE DAIs

In reply to Rakesh Ughreja

Add support for HDA BE DAIs in SKL platform driver.

---
 sound/soc/intel/skylake/skl-pcm.c | 32 +++++++++++++++++++++++++-------
 1 file changed, 25 insertions(+), 7 deletions(-)
sound/soc/intel/skylake/skl-pcm.c +25 -7
index 02cdb1c..6cd6640 100644
@@ -956,21 +956,39 @@ static struct snd_soc_dai_driver skl_platform_dai[] = {
 	},
 },
 {
-	.name = "HD-Codec Pin",
+	.name = "Analog CPU DAI",
 	.ops = &skl_link_dai_ops,
 	.playback = {
-		.stream_name = "HD-Codec Tx",
-		.channels_min = HDA_STEREO,
+		.stream_name = "Analog CPU Playback",
+		.channels_min = HDA_MONO,
 		.channels_max = HDA_STEREO,
 		.rates = SNDRV_PCM_RATE_48000,
-		.formats = SNDRV_PCM_FMTBIT_S16_LE,
+		.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
 	},
 	.capture = {
-		.stream_name = "HD-Codec Rx",
-		.channels_min = HDA_STEREO,
+		.stream_name = "Analog CPU Capture",
+		.channels_min = HDA_MONO,
 		.channels_max = HDA_STEREO,
 		.rates = SNDRV_PCM_RATE_48000,
-		.formats = SNDRV_PCM_FMTBIT_S16_LE,
+		.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
+	},
+},
+{
+	.name = "Digital CPU DAI",
+	.ops = &skl_link_dai_ops,
+	.playback = {
+		.stream_name = "Digital CPU Playback",
+		.channels_min = HDA_MONO,
+		.channels_max = HDA_STEREO,
+		.rates = SNDRV_PCM_RATE_48000,
+		.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
+	},
+	.capture = {
+		.stream_name = "Digital CPU Capture",
+		.channels_min = HDA_MONO,
+		.channels_max = HDA_STEREO,
+		.rates = SNDRV_PCM_RATE_48000,
+		.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE,
 	},
 },
 };
Signature · 1 line
2.7.4
#4 lore raw

RFC v2 4/11 ASoC: Intel: Skylake: use hda_bus instead of hdac_bus

In reply to Rakesh Ughreja

This patch prepares SKL platform driver to make reuse of legacy HDA codec drivers. It does following things.

use hda_bus instead of hdac_bus in the SKL platform driver to align with the legacy controller driver.

modify snd_hdac_ext_bus_device_init definition to align with snd_hdac_bus_device_init, used by legacy drivers. Memory for hdac_device is allocated by the caller

---
 include/sound/hdaudio_ext.h   |  3 ++-
 sound/hda/ext/hdac_ext_bus.c  |  9 ++-------
 sound/soc/intel/skylake/skl.c | 27 ++++++++++++++++++++++++++-
 sound/soc/intel/skylake/skl.h | 10 +++++++---
 4 files changed, 37 insertions(+), 12 deletions(-)
include/sound/hdaudio_ext.h +2 -1
index 3c30247..c188b80 100644
@@ -9,7 +9,8 @@ int snd_hdac_ext_bus_init(struct hdac_bus *bus, struct device *dev,
 		      const struct hdac_io_ops *io_ops);
 
 void snd_hdac_ext_bus_exit(struct hdac_bus *bus);
-int snd_hdac_ext_bus_device_init(struct hdac_bus *bus, int addr);
+int snd_hdac_ext_bus_device_init(struct hdac_bus *bus, int addr,
+						struct hdac_device *hdev);
 void snd_hdac_ext_bus_device_exit(struct hdac_device *hdev);
 void snd_hdac_ext_bus_device_remove(struct hdac_bus *bus);
 
sound/hda/ext/hdac_ext_bus.c +2 -7
index 52f0776..e4bcb76 100644
@@ -135,16 +135,12 @@ static void default_release(struct device *dev)
  *
  * Returns zero for success or a negative error code.
  */
-int snd_hdac_ext_bus_device_init(struct hdac_bus *bus, int addr)
+int snd_hdac_ext_bus_device_init(struct hdac_bus *bus, int addr,
+					struct hdac_device *hdev)
 {
-	struct hdac_device *hdev = NULL;
 	char name[15];
 	int ret;
 
-	hdev = kzalloc(sizeof(*hdev), GFP_KERNEL);
-	if (!hdev)
-		return -ENOMEM;
-
 	hdev->bus = bus;
 
 	snprintf(name, sizeof(name), "ehdaudio%dD%d", bus->idx, addr);
@@ -175,7 +171,6 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_device_init);
 void snd_hdac_ext_bus_device_exit(struct hdac_device *hdev)
 {
 	snd_hdac_device_exit(hdev);
-	kfree(hdev);
 }
 EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_device_exit);
 
sound/soc/intel/skylake/skl.c +26 -1
index b99c1d8..c2e9c19 100644
@@ -35,6 +35,7 @@
 #include "skl.h"
 #include "skl-sst-dsp.h"
 #include "skl-sst-ipc.h"
+#include "../../../pci/hda/hda_codec.h"
 
 static struct skl_machine_pdata skl_dmic_data;
 
@@ -617,6 +618,8 @@ static int probe_codec(struct hdac_bus *bus, int addr)
 	unsigned int cmd = (addr << 28) | (AC_NODE_ROOT << 20) |
 		(AC_VERB_PARAMETERS << 8) | AC_PAR_VENDOR_ID;
 	unsigned int res = -1;
+	struct skl *skl = bus_to_skl(bus);
+	struct hdac_device *hdev;
 
 	mutex_lock(&bus->cmd_mutex);
 	snd_hdac_bus_send_cmd(bus, cmd);
@@ -626,7 +629,19 @@ static int probe_codec(struct hdac_bus *bus, int addr)
 		return -EIO;
 	dev_dbg(bus->dev, "codec #%d probed OK\n", addr);
 
-	return snd_hdac_ext_bus_device_init(bus, addr);
+	/*
+	 * FIXME:
+	 * The legacy HDA controller driver allocates data structure
+	 * for hda_codec. Ideally it should allocate only hdac_device
+	 * so that it has no dependency on the data structure of the
+	 * codec driver. If legacy controller driver can be changed this
+	 * code change can be avoided.
+	 */
+	hdev = devm_kzalloc(&skl->pci->dev, sizeof(*hdev), GFP_KERNEL);
+	if (!hdev)
+		return -ENOMEM;
+
+	return snd_hdac_ext_bus_device_init(bus, addr, hdev);
 }
 
 /* Codec initialization */
@@ -751,6 +766,7 @@ static int skl_create(struct pci_dev *pci,
 {
 	struct skl *skl;
 	struct hdac_bus *bus;
+	struct hda_bus *hbus;
 
 	int err;
 
@@ -766,6 +782,7 @@ static int skl_create(struct pci_dev *pci,
 		return -ENOMEM;
 	}
 
+	hbus = skl_to_hbus(skl);
 	bus = skl_to_bus(skl);
 	snd_hdac_ext_bus_init(bus, &pci->dev, &bus_core_ops, io_ops);
 	bus->use_posbuf = 1;
@@ -773,6 +790,14 @@ static int skl_create(struct pci_dev *pci,
 	INIT_WORK(&skl->probe_work, skl_probe_work);
 	bus->bdl_pos_adj = 0;
 
+	/*
+	 * TODO: other parameters can be taken the way it is taken by
+	 * legacy HDA driver
+	 */
+	mutex_init(&hbus->prepare_mutex);
+	hbus->pci = pci;
+	hbus->mixer_assigned = -1;
+
 	*rskl = skl;
 
 	return 0;
sound/soc/intel/skylake/skl.h +7 -3
index f3a48a4..777508f 100644
@@ -26,6 +26,7 @@
 #include <sound/soc.h>
 #include "skl-nhlt.h"
 #include "skl-ssp-clk.h"
+#include "../../../pci/hda/hda_codec.h"
 
 #define SKL_SUSPEND_DELAY 2000
 
@@ -63,7 +64,7 @@ struct skl_fw_config {
 };
 
 struct skl {
-	struct hdac_bus hbus;
+	struct hda_bus hbus;
 	struct pci_dev *pci;
 
 	unsigned int init_done:1; /* delayed init status */
@@ -96,8 +97,11 @@ struct skl {
 	struct skl_fw_config cfg;
 };
 
-#define skl_to_bus(s)  (&(s)->hbus)
-#define bus_to_skl(bus) container_of(bus, struct skl, hbus)
+#define skl_to_bus(s)  (&(s)->hbus.core)
+#define bus_to_skl(bus) container_of(bus, struct skl, hbus.core)
+
+#define skl_to_hbus(s) (&(s)->hbus)
+#define hbus_to_skl(hbus) container_of(hbus, struct skl, hbus)
 
 /* to pass dai dma data */
 struct skl_dma_params {
Signature · 1 line
2.7.4
#5 lore raw

RFC v2 5/11 ALSA: hda - make some of the functions externally visible

In reply to Rakesh Ughreja

Mark some functions with EXPORT_SYMBOL_GPL so that it can be called by other kernel modules. These APIs would be called by ASoC based HDA codec driver which will be added in the later patches.

---
 sound/pci/hda/hda_codec.c | 9 +++++++--
 sound/pci/hda/hda_codec.h | 2 ++
 2 files changed, 9 insertions(+), 2 deletions(-)
sound/pci/hda/hda_codec.c +7 -2
index e018ecb..085fd9e 100644
@@ -2903,7 +2903,7 @@ static void hda_call_codec_resume(struct hda_codec *codec)
 	atomic_dec(&codec->core.in_pm);
 }
 
-static int hda_codec_runtime_suspend(struct device *dev)
+int hda_codec_runtime_suspend(struct device *dev)
 {
 	struct hda_codec *codec = dev_to_hda_codec(dev);
 	struct hda_pcm *pcm;
@@ -2919,8 +2919,9 @@ static int hda_codec_runtime_suspend(struct device *dev)
 	snd_hdac_link_power(&codec->core, false);
 	return 0;
 }
+EXPORT_SYMBOL_GPL(hda_codec_runtime_suspend);
 
-static int hda_codec_runtime_resume(struct device *dev)
+int hda_codec_runtime_resume(struct device *dev)
 {
 	struct hda_codec *codec = dev_to_hda_codec(dev);
 
@@ -2930,6 +2931,7 @@ static int hda_codec_runtime_resume(struct device *dev)
 	pm_runtime_mark_last_busy(dev);
 	return 0;
 }
+EXPORT_SYMBOL_GPL(hda_codec_runtime_resume);
 #endif /* CONFIG_PM */
 
 /* referred in hda_bind.c */
@@ -3005,6 +3007,7 @@ int snd_hda_codec_build_controls(struct hda_codec *codec)
 	sync_power_up_states(codec);
 	return 0;
 }
+EXPORT_SYMBOL_GPL(snd_hda_codec_build_controls);
 
 /*
  * PCM stuff
@@ -3210,6 +3213,7 @@ int snd_hda_codec_parse_pcms(struct hda_codec *codec)
 
 	return 0;
 }
+EXPORT_SYMBOL_GPL(snd_hda_codec_parse_pcms);
 
 /* assign all PCMs of the given codec */
 int snd_hda_codec_build_pcms(struct hda_codec *codec)
@@ -3246,6 +3250,7 @@ int snd_hda_codec_build_pcms(struct hda_codec *codec)
 
 	return 0;
 }
+EXPORT_SYMBOL_GPL(snd_hda_codec_build_pcms);
 
 /**
  * snd_hda_add_new_ctls - create controls from the array
sound/pci/hda/hda_codec.h +2 -0
index 681c360..d3099db 100644
@@ -497,6 +497,8 @@ int hda_call_check_power_status(struct hda_codec *codec, hda_nid_t nid)
 #ifdef CONFIG_PM
 void snd_hda_set_power_save(struct hda_bus *bus, int delay);
 void snd_hda_update_power_acct(struct hda_codec *codec);
+int hda_codec_runtime_suspend(struct device *dev);
+int hda_codec_runtime_resume(struct device *dev);
 #else
 static inline void snd_hda_set_power_save(struct hda_bus *bus, int delay) {}
 #endif
Signature · 1 line
2.7.4
#6 lore raw

RFC v2 6/11 ASoC: hdac_hda: add ASoC based HDA codec driver

In reply to Rakesh Ughreja

This patch adds ASoC based HDA codec driver that can be used with all Intel platforms.

---
 sound/soc/codecs/Kconfig      |  6 +++
 sound/soc/codecs/Makefile     |  2 +
 sound/soc/codecs/hdac_hda.c   | 92 +++++++++++++++++++++++++++++++++++++++++++
 sound/soc/codecs/hdac_hda.h   | 26 ++++++++++++
 sound/soc/intel/skylake/skl.c | 10 ++++-
 5 files changed, 134 insertions(+), 2 deletions(-)
 create mode 100644 sound/soc/codecs/hdac_hda.c
 create mode 100644 sound/soc/codecs/hdac_hda.h
sound/soc/codecs/Kconfig +6 -0
index ba5de07..1d41d11 100644
@@ -79,6 +79,7 @@ config SND_SOC_ALL_CODECS
 	select SND_SOC_ES7134
 	select SND_SOC_GTM601
 	select SND_SOC_HDAC_HDMI
+	select SND_SOC_HDAC_HDA
 	select SND_SOC_ICS43432
 	select SND_SOC_INNO_RK3036
 	select SND_SOC_ISABELLE if I2C
@@ -581,6 +582,11 @@ config SND_SOC_HDAC_HDMI
 	select SND_PCM_ELD
 	select HDMI
 
+config SND_SOC_HDAC_HDA
+	tristate
+	select SND_HDA_EXT_CORE
+	select SND_PCM_ELD
+
 config SND_SOC_ICS43432
 	tristate
 
sound/soc/codecs/Makefile +2 -0
index 0977349..dd5f90f 100644
@@ -73,6 +73,7 @@ snd-soc-es8328-i2c-objs := es8328-i2c.o
 snd-soc-es8328-spi-objs := es8328-spi.o
 snd-soc-gtm601-objs := gtm601.o
 snd-soc-hdac-hdmi-objs := hdac_hdmi.o
+snd-soc-hdac-hda-objs := hdac_hda.o
 snd-soc-ics43432-objs := ics43432.o
 snd-soc-inno-rk3036-objs := inno_rk3036.o
 snd-soc-isabelle-objs := isabelle.o
@@ -317,6 +318,7 @@ obj-$(CONFIG_SND_SOC_ES8328_I2C)+= snd-soc-es8328-i2c.o
 obj-$(CONFIG_SND_SOC_ES8328_SPI)+= snd-soc-es8328-spi.o
 obj-$(CONFIG_SND_SOC_GTM601)    += snd-soc-gtm601.o
 obj-$(CONFIG_SND_SOC_HDAC_HDMI) += snd-soc-hdac-hdmi.o
+obj-$(CONFIG_SND_SOC_HDAC_HDA) += snd-soc-hdac-hda.o
 obj-$(CONFIG_SND_SOC_ICS43432)	+= snd-soc-ics43432.o
 obj-$(CONFIG_SND_SOC_INNO_RK3036)	+= snd-soc-inno-rk3036.o
 obj-$(CONFIG_SND_SOC_ISABELLE)	+= snd-soc-isabelle.o
sound/soc/codecs/hdac_hda.c new file +92 -0

92 lines not on this page · raw message

sound/soc/codecs/hdac_hda.h new file +26 -0
new file mode 100644
index 0000000..baecbb2
@@ -0,0 +1,26 @@
+#ifndef __HDAC_HDA_H__
+#define __HDAC_HDA_H__
+
+struct hdac_hda_priv {
+	struct hda_codec codec;
+	struct hda_bus *hbus;
+	int stream_tag;
+
+	struct snd_soc_codec *scodec;
+};
+
+#define hdac_to_hda_priv(_hdac) \
+			container_of(_hdac, struct hdac_hda_priv, codec.core)
+#define hdac_to_hda_codec(_hdac) container_of(_hdac, struct hda_codec, core)
+
+int __hdac_hda_codec_driver_register(struct hdac_driver *drv,
+				const char *name, struct module *owner);
+#define hdac_hda_codec_driver_register(drv) \
+	__hdac_hda_codec_driver_register(drv, KBUILD_MODNAME, THIS_MODULE)
+void hdac_hda_codec_driver_unregister(struct hdac_driver *drv);
+
+#define module_hdac_hda_codec_driver(drv) \
+	module_driver(drv, hdac_hda_codec_driver_register, \
+					hdac_hda_codec_driver_unregister)
+
+#endif /* __HDAC_HDA_H__ */
sound/soc/intel/skylake/skl.c +8 -2
index c2e9c19..a56a916 100644
@@ -36,6 +36,7 @@
 #include "skl-sst-dsp.h"
 #include "skl-sst-ipc.h"
 #include "../../../pci/hda/hda_codec.h"
+#include "../../../soc/codecs/hdac_hda.h"
 
 static struct skl_machine_pdata skl_dmic_data;
 
@@ -619,6 +620,7 @@ static int probe_codec(struct hdac_bus *bus, int addr)
 		(AC_VERB_PARAMETERS << 8) | AC_PAR_VENDOR_ID;
 	unsigned int res = -1;
 	struct skl *skl = bus_to_skl(bus);
+	struct hdac_hda_priv *hda_codec;
 	struct hdac_device *hdev;
 
 	mutex_lock(&bus->cmd_mutex);
@@ -637,10 +639,14 @@ static int probe_codec(struct hdac_bus *bus, int addr)
 	 * codec driver. If legacy controller driver can be changed this
 	 * code change can be avoided.
 	 */
-	hdev = devm_kzalloc(&skl->pci->dev, sizeof(*hdev), GFP_KERNEL);
-	if (!hdev)
+	hda_codec = devm_kzalloc(&skl->pci->dev, sizeof(*hda_codec),
+								GFP_KERNEL);
+	if (!hda_codec)
 		return -ENOMEM;
 
+	hda_codec->hbus = skl_to_hbus(skl);
+	hdev = &hda_codec->codec.core;
+
 	return snd_hdac_ext_bus_device_init(bus, addr, hdev);
 }
 
Signature · 1 line
2.7.4
#7 lore raw

RFC v2 7/11 ALSA: hda: add new API snd_hda_asoc_codec_new for ASoC codec drivers

In reply to Rakesh Ughreja

Add API snd_hda_asoc_codec_new, to be called by generic ASoC codec driver to create the hda_codec instance.

---
 sound/pci/hda/hda_codec.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++
 sound/pci/hda/hda_codec.h |   2 +
 2 files changed, 102 insertions(+)
sound/pci/hda/hda_codec.c +100 -0
index 085fd9e..215b04d 100644
@@ -965,6 +965,106 @@ int snd_hda_codec_new(struct hda_bus *bus, struct snd_card *card,
 }
 EXPORT_SYMBOL_GPL(snd_hda_codec_new);
 
+/*
+ * FIXME:
+ * This function is very simillar to snd_hda_codec_new, but requires
+ * some special change for ASoC based codec drivers.
+ * Both functions can be combined into one.
+ */
+int snd_hda_asoc_codec_new(struct hda_bus *bus, struct snd_card *card,
+			unsigned int codec_addr, struct hda_codec **codecp)
+{
+	struct hda_codec *codec = NULL;
+	hda_nid_t fg;
+	int err;
+	static struct snd_device_ops dev_ops = {
+		.dev_register = snd_hda_codec_dev_register,
+		.dev_disconnect = snd_hda_codec_dev_disconnect,
+		.dev_free = snd_hda_codec_dev_free,
+	};
+	struct snd_device *snd_dev;
+
+	if (snd_BUG_ON(!codecp))
+		return -EINVAL;
+	if (snd_BUG_ON(!bus))
+		return -EINVAL;
+	if (snd_BUG_ON(codec_addr > HDA_MAX_CODEC_ADDRESS))
+		return -EINVAL;
+
+	codec = *codecp;
+
+	codec->core.exec_verb = codec_exec_verb;
+	codec->bus = bus;
+	codec->card = card;
+	codec->addr = codec_addr;
+	mutex_init(&codec->spdif_mutex);
+	mutex_init(&codec->control_mutex);
+	snd_array_init(&codec->mixers, sizeof(struct hda_nid_item), 32);
+	snd_array_init(&codec->nids, sizeof(struct hda_nid_item), 32);
+	snd_array_init(&codec->init_pins, sizeof(struct hda_pincfg), 16);
+	snd_array_init(&codec->driver_pins, sizeof(struct hda_pincfg), 16);
+	snd_array_init(&codec->cvt_setups, sizeof(struct hda_cvt_setup), 8);
+	snd_array_init(&codec->spdif_out, sizeof(struct hda_spdif_out), 16);
+	snd_array_init(&codec->jacktbl, sizeof(struct hda_jack_tbl), 16);
+	snd_array_init(&codec->verbs, sizeof(struct hda_verb *), 8);
+	INIT_LIST_HEAD(&codec->conn_list);
+	INIT_LIST_HEAD(&codec->pcm_list_head);
+
+	INIT_DELAYED_WORK(&codec->jackpoll_work, hda_jackpoll_work);
+	codec->depop_delay = -1;
+	codec->fixup_id = HDA_FIXUP_ID_NOT_SET;
+
+#ifdef CONFIG_PM
+	codec->power_jiffies = jiffies;
+#endif
+
+	if (codec->bus->modelname) {
+		codec->modelname = kstrdup(codec->bus->modelname, GFP_KERNEL);
+		if (!codec->modelname) {
+			err = -ENOMEM;
+			goto error;
+		}
+	}
+
+	fg = codec->core.afg ? codec->core.afg : codec->core.mfg;
+	err = read_widget_caps(codec, fg);
+	if (err < 0)
+		goto error;
+
+	err = read_pin_defaults(codec);
+	if (err < 0)
+		goto error;
+
+	/* power-up all before initialization */
+	hda_set_power_state(codec, AC_PWRST_D0);
+
+	snd_hda_codec_proc_new(codec);
+
+	snd_hda_create_hwdep(codec);
+
+	err = snd_device_new(card, SNDRV_DEV_CODEC, codec, &dev_ops);
+	if (err < 0)
+		goto error;
+
+	list_for_each_entry(snd_dev, &card->devices, list) {
+		if (snd_dev->type == SNDRV_DEV_CODEC) {
+			void *device_data = snd_dev->device_data;
+
+			err = snd_device_register(card, device_data);
+			if (err < 0)
+				dev_err(bus->core.dev,
+				"device_register_all failed err = %d\n", err);
+		}
+	}
+
+	return 0;
+
+error:
+	put_device(hda_codec_dev(codec));
+	return err;
+}
+EXPORT_SYMBOL_GPL(snd_hda_asoc_codec_new);
+
 /**
  * snd_hda_codec_update_widgets - Refresh widget caps and pin defaults
  * @codec: the HDA codec
sound/pci/hda/hda_codec.h +2 -0
index d3099db..d863092 100644
@@ -307,6 +307,8 @@ struct hda_codec {
  */
 int snd_hda_codec_new(struct hda_bus *bus, struct snd_card *card,
 		      unsigned int codec_addr, struct hda_codec **codecp);
+int snd_hda_asoc_codec_new(struct hda_bus *bus, struct snd_card *card,
+		      unsigned int codec_addr, struct hda_codec **codecp);
 int snd_hda_codec_configure(struct hda_codec *codec);
 int snd_hda_codec_update_widgets(struct hda_codec *codec);
 
Signature · 1 line
2.7.4
#8 lore raw

RFC v2 8/11 ASoC: hdac_hda: add DAI, widgets and related ops

In reply to Rakesh Ughreja

Add support for widgets, routes, DAI and related handlers.

---
 sound/soc/codecs/hdac_hda.c | 487 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 487 insertions(+)
sound/soc/codecs/hdac_hda.c +487 -0
index 0a80fe8..78730b8 100644
@@ -28,6 +28,484 @@
 #include "../../pci/hda/hda_codec.h"
 #include "hdac_hda.h"
 
+#define STUB_FORMATS	(SNDRV_PCM_FMTBIT_S8 | \
+			SNDRV_PCM_FMTBIT_U8 | \
+			SNDRV_PCM_FMTBIT_S16_LE | \
+			SNDRV_PCM_FMTBIT_U16_LE | \
+			SNDRV_PCM_FMTBIT_S24_LE | \
+			SNDRV_PCM_FMTBIT_U24_LE | \
+			SNDRV_PCM_FMTBIT_S32_LE | \
+			SNDRV_PCM_FMTBIT_U32_LE | \
+			SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE)
+
+static int hdac_hda_dai_open(struct snd_pcm_substream *substream,
+			struct snd_soc_dai *dai);
+static void hdac_hda_dai_close(struct snd_pcm_substream *substream,
+		struct snd_soc_dai *dai);
+static int hdac_hda_dai_prepare(struct snd_pcm_substream *substream,
+				struct snd_soc_dai *dai);
+static int hdac_hda_dai_hw_params(struct snd_pcm_substream *substream,
+	struct snd_pcm_hw_params *hparams, struct snd_soc_dai *dai);
+static int hdac_hda_dai_hw_free(struct snd_pcm_substream *substream,
+				struct snd_soc_dai *dai);
+static int hdac_hda_dai_set_tdm_slot(struct snd_soc_dai *dai,
+		unsigned int tx_mask, unsigned int rx_mask,
+		int slots, int slot_width);
+static struct hda_pcm *snd_soc_find_pcm_from_dai(struct hdac_hda_priv *hda_pvt,
+						struct snd_soc_dai *dai);
+
+static struct snd_soc_dai_ops hdac_hda_dai_ops = {
+	.startup = hdac_hda_dai_open,
+	.shutdown = hdac_hda_dai_close,
+	.prepare = hdac_hda_dai_prepare,
+	.hw_params = hdac_hda_dai_hw_params,
+	.hw_free = hdac_hda_dai_hw_free,
+	.set_tdm_slot = hdac_hda_dai_set_tdm_slot,
+};
+
+static struct snd_soc_dai_driver hdac_hda_dais[] = {
+{
+	.name = "Analog Codec DAI",
+	.ops = &hdac_hda_dai_ops,
+	.playback = {
+		.stream_name	= "Analog Codec Playback",
+		.channels_min	= 1,
+		.channels_max	= 16,
+		.rates		= SNDRV_PCM_RATE_8000_192000,
+		.formats	= STUB_FORMATS,
+		.sig_bits	= 24,
+	},
+	.capture = {
+		.stream_name    = "Analog Codec Capture",
+		.channels_min   = 1,
+		.channels_max   = 16,
+		.rates = SNDRV_PCM_RATE_8000_192000,
+		.formats = STUB_FORMATS,
+		.sig_bits = 24,
+	},
+},
+{
+	.name = "Digital Codec DAI",
+	.ops = &hdac_hda_dai_ops,
+	.playback = {
+		.stream_name    = "Digital Codec Playback",
+		.channels_min   = 1,
+		.channels_max   = 16,
+		.rates          = SNDRV_PCM_RATE_8000_192000,
+		.formats        = STUB_FORMATS,
+		.sig_bits = 24,
+	},
+	.capture = {
+		.stream_name    = "Digital Codec Capture",
+		.channels_min   = 1,
+		.channels_max   = 16,
+		.rates = SNDRV_PCM_RATE_8000_192000,
+		.formats = STUB_FORMATS,
+		.sig_bits = 24,
+	},
+}
+};
+
+static int hdac_codec_match(struct hdac_device *hdev, struct hdac_driver *drv)
+{
+	struct hda_codec *codec = hdac_to_hda_codec(hdev);
+	const struct hda_device_id *list;
+	u32 id, rev_id;
+
+	if (!codec) {
+		dev_err(&hdev->dev, "%p\n", codec);
+		return 0;
+	}
+
+	/* check probe_id instead of vendor_id if set */
+	id = codec->probe_id ? codec->probe_id : codec->core.vendor_id;
+	rev_id = codec->core.revision_id;
+
+	dev_dbg(&hdev->dev, "%s: probe_id=0x%x and vendor_id=0x%x\n",
+			__func__, codec->probe_id, codec->core.vendor_id);
+
+	for (list = drv->id_table; list->vendor_id; list++) {
+		if (list->vendor_id == id &&
+			(!list->rev_id || list->rev_id == rev_id)) {
+			codec->preset = list;
+			dev_dbg(&hdev->dev, "found patch file %x\n", id);
+			return 1;
+		}
+	}
+	return 0;
+}
+
+static int hdac_hda_dai_set_tdm_slot(struct snd_soc_dai *dai,
+		unsigned int tx_mask, unsigned int rx_mask,
+		int slots, int slot_width)
+{
+	struct hdac_hda_priv *hda_pvt = snd_soc_dai_get_drvdata(dai);
+	struct hdac_device *hdev = &hda_pvt->codec.core;
+
+	hda_pvt->stream_tag = tx_mask;
+	dev_dbg(&hdev->dev, "%s: strm_tag: %d\n", __func__,
+						hda_pvt->stream_tag);
+	return 0;
+}
+
+static int hdac_hda_dai_hw_params(struct snd_pcm_substream *substream,
+	struct snd_pcm_hw_params *hparams, struct snd_soc_dai *dai)
+{
+	struct hdac_hda_priv *hda_pvt = snd_soc_dai_get_drvdata(dai);
+	struct hdac_device *hdev = &hda_pvt->codec.core;
+
+	dev_dbg(&hdev->dev, "%s: entry\n", __func__);
+
+	/*
+	 * TODO:
+	 * verify if the parameters are supported by the codec
+	 */
+	return 0;
+}
+
+static int hdac_hda_dai_hw_free(struct snd_pcm_substream *substream,
+				struct snd_soc_dai *dai)
+{
+	struct hdac_hda_priv *hda_pvt = snd_soc_dai_get_drvdata(dai);
+	struct hdac_device *hdev = &hda_pvt->codec.core;
+	struct snd_pcm_runtime *runtime = substream->runtime;
+	struct hda_pcm_stream *hda_stream;
+	struct hda_pcm *pcm;
+
+	dev_dbg(&hdev->dev, "%s: entry\n", __func__);
+
+	pcm = snd_soc_find_pcm_from_dai(hda_pvt, dai);
+	if (pcm == NULL)
+		return -EINVAL;
+
+	dev_dbg(&hdev->dev, "pcm = %s: rate=%d ch=%d fmt=%d\n", pcm->name,
+		runtime->rate, runtime->channels, runtime->format);
+
+	hda_stream = &pcm->stream[substream->stream];
+
+	snd_hda_codec_cleanup(&hda_pvt->codec, hda_stream, substream);
+
+	return 0;
+}
+
+static int hdac_hda_dai_prepare(struct snd_pcm_substream *substream,
+				struct snd_soc_dai *dai)
+{
+	int ret = 0;
+	struct hdac_hda_priv *hda_pvt = snd_soc_dai_get_drvdata(dai);
+	struct hdac_device *hdev = &hda_pvt->codec.core;
+	struct snd_pcm_runtime *runtime = substream->runtime;
+	struct hda_pcm_stream *hda_stream;
+	unsigned int format_val;
+	struct hda_pcm *pcm;
+
+	dev_dbg(&hdev->dev, "%s: entry\n", __func__);
+
+	pcm = snd_soc_find_pcm_from_dai(hda_pvt, dai);
+	if (pcm == NULL)
+		return -EINVAL;
+
+	dev_dbg(&hdev->dev, "pcm = %s: rate=%d ch=%d fmt=%d\n", pcm->name,
+		runtime->rate, runtime->channels, runtime->format);
+
+	hda_stream = &pcm->stream[substream->stream];
+
+	dev_dbg(&hdev->dev, "fmt=0x%llx rate=0x%x maxbps=%d\n",
+		hda_stream->formats, hda_stream->rates, hda_stream->maxbps);
+
+	format_val = snd_hdac_calc_stream_format(runtime->rate,
+						runtime->channels,
+						runtime->format,
+						hda_stream->maxbps,
+						0);
+	if (!format_val) {
+		dev_err(&hdev->dev,
+			"invalid format_val, rate=%d, ch=%d, format=%d\n",
+			runtime->rate, runtime->channels, runtime->format);
+		return -EINVAL;
+	}
+
+	ret = snd_hda_codec_prepare(&hda_pvt->codec, hda_stream,
+			hda_pvt->stream_tag, format_val, substream);
+	if (ret < 0) {
+		dev_err(&hdev->dev, "codec prepare failed %d\n", ret);
+		return ret;
+	}
+
+	dev_dbg(&hdev->dev, "%s: exit\n", __func__);
+	return ret;
+}
+
+static int hdac_hda_dai_open(struct snd_pcm_substream *substream,
+			struct snd_soc_dai *dai)
+{
+	struct hdac_hda_priv *hda_pvt = snd_soc_dai_get_drvdata(dai);
+	struct hdac_device *hdev = &hda_pvt->codec.core;
+	struct snd_pcm_runtime *runtime = substream->runtime;
+	struct hda_pcm *pcm;
+	struct hda_pcm_stream *hda_stream;
+	int ret = 0;
+
+	dev_dbg(&hdev->dev, "%s: entry\n", __func__);
+
+	pcm = snd_soc_find_pcm_from_dai(hda_pvt, dai);
+	if (pcm == NULL)
+		return -EINVAL;
+
+	dev_dbg(&hdev->dev, "pcm = %s: rate=%d ch=%d fmt=%d\n", pcm->name,
+		runtime->rate, runtime->channels, runtime->format);
+
+	hda_stream = &pcm->stream[substream->stream];
+
+	snd_hda_codec_pcm_get(pcm);
+
+	if (hda_stream->ops.open)
+		ret = hda_stream->ops.open(hda_stream, &hda_pvt->codec,
+								substream);
+	else
+		ret = -ENODEV;
+
+	dev_dbg(&hdev->dev, "%s: exit=%d\n", __func__, ret);
+
+	return 0;
+}
+
+static void hdac_hda_dai_close(struct snd_pcm_substream *substream,
+		struct snd_soc_dai *dai)
+{
+	struct hdac_hda_priv *hda_pvt = snd_soc_dai_get_drvdata(dai);
+	struct hdac_device *hdev = &hda_pvt->codec.core;
+	struct hda_pcm *pcm;
+	struct hda_pcm_stream *hda_stream;
+
+	dev_dbg(&hdev->dev, "%s: entry\n", __func__);
+
+	pcm = snd_soc_find_pcm_from_dai(hda_pvt, dai);
+	if (pcm == NULL)
+		return;
+
+	hda_stream = &pcm->stream[substream->stream];
+
+	if (hda_stream->ops.open)
+		hda_stream->ops.close(hda_stream, &hda_pvt->codec, substream);
+
+	snd_hda_codec_pcm_put(pcm);
+}
+
+static struct hda_pcm *snd_soc_find_pcm_from_dai(struct hdac_hda_priv *hda_pvt,
+						struct snd_soc_dai *dai)
+{
+
+	struct hda_pcm *cpcm;
+	struct hda_codec *hcodec = &hda_pvt->codec;
+	const char *pcm_name;
+
+	if (strpbrk(dai->name, "Analog"))
+		pcm_name = "Analog";
+	else
+		pcm_name = "Digital";
+
+	dev_dbg(&hcodec->core.dev, "DAI %s\n", pcm_name);
+
+	list_for_each_entry(cpcm, &hcodec->pcm_list_head, list) {
+		dev_dbg(&hcodec->core.dev, "PCM %s\n", cpcm->name);
+		if (strpbrk(cpcm->name, pcm_name))
+			return cpcm;
+	}
+
+	dev_err(&hcodec->core.dev, "didn't find PCM for DAI %s\n", dai->name);
+	return NULL;
+}
+
+static int hdac_hda_codec_probe(struct snd_soc_codec *codec)
+{
+	struct hdac_hda_priv *hda_pvt = snd_soc_codec_get_drvdata(codec);
+	struct hdac_device *hdev = &hda_pvt->codec.core;
+	struct hdac_ext_link *hlink = NULL;
+	struct hda_codec *hcodec = &hda_pvt->codec;
+	struct snd_soc_dapm_context *dapm =
+			snd_soc_component_get_dapm(&codec->component);
+	int ret, i = 0;
+	u16 codec_mask;
+	hda_codec_patch_t patch;
+	struct hdac_driver *hdrv = drv_to_hdac_driver(hdev->dev.driver);
+
+	dev_dbg(&hdev->dev, "%s: Entry in_pm=%d pm_usage=%d\n", __func__,
+			hdev->in_pm.counter,
+			hdev->dev.power.usage_count.counter);
+
+	hda_pvt->scodec = codec;
+	hlink = snd_hdac_ext_bus_get_link(hdev->bus,
+					dev_name(&hdev->dev));
+	if (!hlink) {
+		dev_err(&hdev->dev, "hdac link not found\n");
+		return -EIO;
+	}
+
+	ret = snd_hdac_ext_bus_link_get(hdev->bus, hlink);
+
+	udelay(1000);
+	do {
+		codec_mask = snd_hdac_chip_readw(hdev->bus, STATESTS);
+		if (codec_mask)
+			break;
+			i++;
+		udelay(100);
+	} while (i < 100);
+
+	if (!codec_mask) {
+		dev_err(&hdev->dev, "No codecs found after link reset\n");
+		return -EIO;
+	}
+
+	snd_hdac_chip_writew(hdev->bus, STATESTS, STATESTS_INT_MASK);
+
+	dev_dbg(&hdev->dev, "before card created in_pm=%d pm_usage=%d\n",
+			hdev->in_pm.counter,
+			hdev->dev.power.usage_count.counter);
+
+	ret = snd_hda_asoc_codec_new(hda_pvt->hbus,
+			codec->component.card->snd_card, hdev->addr,
+			&hcodec);
+	if (ret < 0) {
+		dev_err(codec->dev, "%s: failed to create hda codec %d\n",
+					__func__, ret);
+		return ret;
+	}
+
+	/*
+	 * snd_hda_codec_new1 decrements the usage count and so get the pm
+	 * count else the device will be powered off
+	 */
+	pm_runtime_get_noresume(&hdev->dev);
+
+	hda_pvt->hbus->card = dapm->card->snd_card;
+
+	dev_dbg(&hdev->dev, "after card created in_pm=%d pm_usage=%d\n",
+			hdev->in_pm.counter,
+			hdev->dev.power.usage_count.counter);
+
+	ret = hdac_codec_match(hdev, hdrv);
+	if (ret < 1) {
+		dev_err(codec->dev, "no match found for the codec\n");
+		return ret;
+	}
+
+	patch = (hda_codec_patch_t)hcodec->preset->driver_data;
+	if (patch) {
+		ret = patch(hcodec);
+		if (ret < 0) {
+			dev_err(codec->dev, "no match found for the codec\n");
+			return ret;
+		}
+	} else {
+		dev_dbg(&hdev->dev, "no patch file found\n");
+	}
+
+	ret = snd_hda_codec_set_name(hcodec, hcodec->preset->name);
+	if (ret < 0) {
+		dev_err(codec->dev, "unable to set name %s\n",
+				hcodec->preset->name);
+		return ret;
+	}
+
+	ret = snd_hdac_regmap_init(&hcodec->core);
+	if (ret < 0) {
+		dev_err(codec->dev, "regmap init failed\n");
+		return ret;
+	}
+
+	ret = snd_hda_codec_parse_pcms(hcodec);
+	if (ret < 0) {
+		dev_err(&hdev->dev, "unable to map pcms to dai %d\n", ret);
+		return ret;
+	}
+
+	ret = snd_hda_codec_build_controls(hcodec);
+	if (ret < 0) {
+		dev_err(&hdev->dev, "unable to create controls %d\n", ret);
+		return ret;
+	}
+
+	hcodec->core.lazy_cache = true;
+
+	/*
+	 * hdac_device core already sets the state to active and calls
+	 * get_noresume. So enable runtime and set the device to suspend.
+	 * pm_runtime_enable is also called during codec registeration
+	 */
+	pm_runtime_put(&hdev->dev);
+	pm_runtime_suspend(&hdev->dev);
+
+	dev_dbg(&hdev->dev, "%s: exit\n", __func__);
+
+	return 0;
+}
+
+static int hdac_hda_codec_remove(struct snd_soc_codec *codec)
+{
+	struct hdac_hda_priv *hda_pvt = snd_soc_codec_get_drvdata(codec);
+	struct hdac_device *hdev = &hda_pvt->codec.core;
+	struct hdac_ext_link *hlink = NULL;
+
+	dev_dbg(&hdev->dev, "%s: entry\n", __func__);
+
+	hlink = snd_hdac_ext_bus_get_link(hdev->bus, dev_name(&hdev->dev));
+	if (!hlink) {
+		dev_err(&hdev->dev, "hdac link not found\n");
+		return -EIO;
+	}
+
+	snd_hdac_ext_bus_link_put(hdev->bus, hlink);
+
+	pm_runtime_disable(&hdev->dev);
+
+	return 0;
+}
+
+
+static const struct snd_soc_dapm_route hdac_hda_dapm_routes[] = {
+	{"AIF1TX", NULL, "Codec Input Pin1"},
+	{"AIF2TX", NULL, "Codec Input Pin2"},
+
+	{"Codec Output Pin1", NULL, "AIF1RX"},
+	{"Codec Output Pin2", NULL, "AIF2RX"},
+};
+
+static const struct snd_soc_dapm_widget hdac_hda_dapm_widgets[] = {
+
+	/* Audio Interface */
+	SND_SOC_DAPM_AIF_IN("AIF1RX", "Analog Codec Playback", 0,
+							SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_AIF_IN("AIF2RX", "Digital Codec Playback", 0,
+							SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_AIF_OUT("AIF1TX", "Analog Codec Capture", 0,
+							SND_SOC_NOPM, 0, 0),
+	SND_SOC_DAPM_AIF_OUT("AIF2TX", "Digital Codec Capture", 0,
+							SND_SOC_NOPM, 0, 0),
+
+	/* Input Pins */
+	SND_SOC_DAPM_INPUT("Codec Input Pin1"),
+	SND_SOC_DAPM_INPUT("Codec Input Pin2"),
+
+	/* Output Pins */
+	SND_SOC_DAPM_OUTPUT("Codec Output Pin1"),
+	SND_SOC_DAPM_OUTPUT("Codec Output Pin2"),
+};
+
+
+static struct snd_soc_codec_driver hdac_hda_codec = {
+	.probe		= hdac_hda_codec_probe,
+	.remove		= hdac_hda_codec_remove,
+	.idle_bias_off = true,
+	.component_driver = {
+		.dapm_widgets           = hdac_hda_dapm_widgets,
+		.num_dapm_widgets       = ARRAY_SIZE(hdac_hda_dapm_widgets),
+		.dapm_routes            = hdac_hda_dapm_routes,
+		.num_dapm_routes        = ARRAY_SIZE(hdac_hda_dapm_routes),
+	},
+};
+
 static int hdac_hda_dev_probe(struct hdac_device *hdev)
 {
 	struct hdac_ext_link *hlink = NULL;
@@ -48,6 +526,14 @@ static int hdac_hda_dev_probe(struct hdac_device *hdev)
 	if (hda_pvt == NULL)
 		return -ENOMEM;
 
+	/* ASoC specific initialization */
+	ret = snd_soc_register_codec(&hdev->dev, &hdac_hda_codec, hdac_hda_dais,
+					 ARRAY_SIZE(hdac_hda_dais));
+	if (ret < 0) {
+		dev_err(&hdev->dev, "failed to register HDA codec %d\n", ret);
+		return ret;
+	}
+
 	dev_set_drvdata(&hdev->dev, hda_pvt);
 	snd_hdac_ext_bus_link_put(hdev->bus, hlink);
 
@@ -57,6 +543,7 @@ static int hdac_hda_dev_probe(struct hdac_device *hdev)
 static int hdac_hda_dev_remove(struct hdac_device *hdev)
 {
 	dev_dbg(&hdev->dev, "%s: entry\n", __func__);
+	snd_soc_unregister_codec(&hdev->dev);
 	return 0;
 }
 
Signature · 1 line
2.7.4
#9 lore raw

RFC v2 9/11 ASoC: hdac_hda: add runtime PM support

In reply to Rakesh Ughreja

Add power management support.

---
 sound/soc/codecs/hdac_hda.c | 49 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
sound/soc/codecs/hdac_hda.c +49 -0
index 78730b8..1db467b2 100644
@@ -547,8 +547,57 @@ static int hdac_hda_dev_remove(struct hdac_device *hdev)
 	return 0;
 }
 
+#ifdef CONFIG_PM
+static int hdac_hda_runtime_suspend(struct device *dev)
+{
+	struct hdac_device *hdac = dev_to_hdac_dev(dev);
+	struct hdac_bus *bus = hdac->bus;
+	struct hdac_ext_link *hlink = NULL;
+
+	dev_dbg(dev, "%s: entry\n", __func__);
+
+	dev_dbg(dev, "calling legacy codec suspend\n");
+	hda_codec_runtime_suspend(dev);
+	dev_dbg(dev, "legacy codec suspended\n");
+
+	hlink = snd_hdac_ext_bus_get_link(bus, dev_name(dev));
+	if (!hlink) {
+		dev_err(dev, "hdac link not found\n");
+		return -EIO;
+	}
+	snd_hdac_ext_bus_link_put(bus, hlink);
+	return 0;
+}
+
+static int hdac_hda_runtime_resume(struct device *dev)
+{
+	struct hdac_device *hdac = dev_to_hdac_dev(dev);
+	struct hdac_bus *bus = hdac->bus;
+	struct hdac_ext_link *hlink = NULL;
+
+	dev_dbg(dev, "%s: entry\n", __func__);
+
+	/* controller may not have been initialized for the first time */
+	if (!bus)
+		return 0;
+
+	hlink = snd_hdac_ext_bus_get_link(bus, dev_name(dev));
+	if (!hlink) {
+		dev_err(dev, "hdac link not found\n");
+		return -EIO;
+	}
+	snd_hdac_ext_bus_link_get(bus, hlink);
+
+	dev_dbg(dev, "calling legacy codec resume\n");
+	hda_codec_runtime_resume(dev);
+	dev_dbg(dev, "%s: exit\n", __func__);
+
+	return 0;
+}
+#else
 #define hdac_hda_runtime_suspend NULL
 #define hdac_hda_runtime_resume NULL
+#endif
 
 static const struct dev_pm_ops hdac_hda_pm = {
 	SET_RUNTIME_PM_OPS(hdac_hda_runtime_suspend,
Signature · 1 line
2.7.4
#10 lore raw

RFC v2 10/11 ASoC: patch_realtek: add ASoC based Realtek HDA codec driver patch

In reply to Rakesh Ughreja

This patch adds support for ASoC HDA codec driver for realtek codecs.

---
 sound/pci/hda/patch_realtek.c    |  3 ++-
 sound/soc/codecs/Kconfig         |  6 +++++
 sound/soc/codecs/Makefile        |  2 ++
 sound/soc/codecs/patch_realtek.c | 48 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 58 insertions(+), 1 deletion(-)
 create mode 100644 sound/soc/codecs/patch_realtek.c
sound/pci/hda/patch_realtek.c +2 -1
index 921a10e..88a965c 100644
@@ -7903,7 +7903,7 @@ static int patch_alc680(struct hda_codec *codec)
 /*
  * patch entries
  */
-static const struct hda_device_id snd_hda_id_realtek[] = {
+const struct hda_device_id snd_hda_id_realtek[] = {
 	HDA_CODEC_ENTRY(0x10ec0215, "ALC215", patch_alc269),
 	HDA_CODEC_ENTRY(0x10ec0221, "ALC221", patch_alc269),
 	HDA_CODEC_ENTRY(0x10ec0225, "ALC225", patch_alc269),
@@ -7974,6 +7974,7 @@ static const struct hda_device_id snd_hda_id_realtek[] = {
 	HDA_CODEC_ENTRY(0x10ec1220, "ALC1220", patch_alc882),
 	{} /* terminator */
 };
+EXPORT_SYMBOL_GPL(snd_hda_id_realtek);
 MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_realtek);
 
 MODULE_LICENSE("GPL");
sound/soc/codecs/Kconfig +6 -0
index 1d41d11..97fd997 100644
@@ -80,6 +80,7 @@ config SND_SOC_ALL_CODECS
 	select SND_SOC_GTM601
 	select SND_SOC_HDAC_HDMI
 	select SND_SOC_HDAC_HDA
+	select SND_SOC_HDA_REALTEK
 	select SND_SOC_ICS43432
 	select SND_SOC_INNO_RK3036
 	select SND_SOC_ISABELLE if I2C
@@ -587,6 +588,11 @@ config SND_SOC_HDAC_HDA
 	select SND_HDA_EXT_CORE
 	select SND_PCM_ELD
 
+config SND_SOC_HDA_REALTEK
+	select SND_HDA_CODEC_REALTEK
+	select SND_SOC_HDAC_HDA
+	tristate "Realtek ASoC HDA Codec Driver patch"
+
 config SND_SOC_ICS43432
 	tristate
 
sound/soc/codecs/Makefile +2 -0
index dd5f90f..158ee89 100644
@@ -102,6 +102,7 @@ snd-soc-nau8810-objs := nau8810.o
 snd-soc-nau8824-objs := nau8824.o
 snd-soc-nau8825-objs := nau8825.o
 snd-soc-hdmi-codec-objs := hdmi-codec.o
+snd-soc-patch_realtek-objs := patch_realtek.o
 snd-soc-pcm1681-objs := pcm1681.o
 snd-soc-pcm179x-codec-objs := pcm179x.o
 snd-soc-pcm179x-i2c-objs := pcm179x-i2c.o
@@ -319,6 +320,7 @@ obj-$(CONFIG_SND_SOC_ES8328_SPI)+= snd-soc-es8328-spi.o
 obj-$(CONFIG_SND_SOC_GTM601)    += snd-soc-gtm601.o
 obj-$(CONFIG_SND_SOC_HDAC_HDMI) += snd-soc-hdac-hdmi.o
 obj-$(CONFIG_SND_SOC_HDAC_HDA) += snd-soc-hdac-hda.o
+obj-$(CONFIG_SND_SOC_HDA_REALTEK)	+= snd-soc-patch_realtek.o
 obj-$(CONFIG_SND_SOC_ICS43432)	+= snd-soc-ics43432.o
 obj-$(CONFIG_SND_SOC_INNO_RK3036)	+= snd-soc-inno-rk3036.o
 obj-$(CONFIG_SND_SOC_ISABELLE)	+= snd-soc-isabelle.o
sound/soc/codecs/patch_realtek.c new file +48 -0

48 lines not on this page · raw message

Signature · 1 line
2.7.4
#11 lore raw

RFC v2 11/11 ASoC: Intel: Boards: add support for HDA codecs

In reply to Rakesh Ughreja

Add support for HDA codecs. add required widgets, controls, routes and dai links for the same.

---
 sound/soc/intel/boards/Kconfig               |  1 +
 sound/soc/intel/boards/skl_hda_dsp_common.c  | 43 ++++++++++++++++++++++++++++
 sound/soc/intel/boards/skl_hda_dsp_common.h  |  2 +-
 sound/soc/intel/boards/skl_hda_dsp_generic.c | 29 +++++++++++++++++++
 4 files changed, 74 insertions(+), 1 deletion(-)
sound/soc/intel/boards/Kconfig +1 -0
index e01137d..c146297f 100644
@@ -267,6 +267,7 @@ config SND_SOC_INTEL_SKL_HDA_DSP_GENERIC_MACH
         select SND_SOC_INTEL_SST
         depends on SND_SOC_INTEL_SKYLAKE
         select SND_SOC_HDAC_HDMI
+        select SND_SOC_HDAC_HDA
         help
           This adds support for ASoC Onboard Codec HDA machine driver. This will
           create an alsa sound card for HDA Codecs.
sound/soc/intel/boards/skl_hda_dsp_common.c +43 -0

55 lines not on this page · raw message

sound/soc/intel/boards/skl_hda_dsp_common.h +1 -1
index c9cb66b..463938a 100644
@@ -21,7 +21,7 @@
 #include <sound/jack.h>
 #define __SOUND_SOC_HDA_DSP_COMMON_H
 
-#define HDA_DSP_MAX_BE_DAI_LINKS 3
+#define HDA_DSP_MAX_BE_DAI_LINKS 5
 
 struct skl_hda_hdmi_pcm {
 	struct list_head head;
sound/soc/intel/boards/skl_hda_dsp_generic.c +29 -0
index 2d2b901..e0d7e12 100644
@@ -25,8 +25,33 @@
 #include "../skylake/skl.h"
 #include "skl_hda_dsp_common.h"
 
+static const struct snd_kcontrol_new skl_hda_controls[] = {
+	SOC_DAPM_PIN_SWITCH("Headphone"),
+	SOC_DAPM_PIN_SWITCH("Headset Mic"),
+};
+
+static const struct snd_soc_dapm_widget skl_hda_widgets[] = {
+	SND_SOC_DAPM_HP("Headphone", NULL),
+	SND_SOC_DAPM_MIC("Headset Mic", NULL),
+	SND_SOC_DAPM_SPK("Codec Speaker", NULL),
+	SND_SOC_DAPM_MIC("Codec Mic", NULL),
+};
+
 static const struct snd_soc_dapm_route skl_hda_map[] = {
 
+	/* HP jack connectors - unknown if we have jack detection */
+	{ "Headphone", NULL, "Codec Output Pin1" },
+	{ "Codec Speaker", NULL, "Codec Output Pin2" },
+	{ "Codec Input Pin2", NULL, "Codec Mic" },
+	{ "Codec Input Pin1", NULL, "Headset Mic" },
+
+	/* CODEC BE connections */
+	{ "Analog Codec Playback", NULL, "Analog CPU Playback" },
+	{ "Analog CPU Playback", NULL, "codec0_out" },
+
+	{ "codec0_in", NULL, "Analog CPU Capture" },
+	{ "Analog CPU Capture", NULL, "Analog Codec Capture" },
+
 	{ "hifi3", NULL, "iDisp3 Tx"},
 	{ "iDisp3 Tx", NULL, "iDisp3_out"},
 	{ "hifi2", NULL, "iDisp2 Tx"},
@@ -63,6 +88,10 @@ static struct snd_soc_card hda_soc_card = {
 	.owner = THIS_MODULE,
 	.dai_link = skl_hda_be_dai_links,
 	.num_links = ARRAY_SIZE(skl_hda_be_dai_links),
+	.controls = skl_hda_controls,
+	.num_controls = ARRAY_SIZE(skl_hda_controls),
+	.dapm_widgets = skl_hda_widgets,
+	.num_dapm_widgets = ARRAY_SIZE(skl_hda_widgets),
 	.dapm_routes = skl_hda_map,
 	.num_dapm_routes = ARRAY_SIZE(skl_hda_map),
 	.add_dai_link = skl_hda_add_dai_link,
Signature · 1 line
2.7.4
#12 lore raw
In reply to Rakesh Ughreja
Quoted 21 lines · Rakesh Ughreja

Many Intel platforms (SKL, KBL) etc. in the market supports enhanced audio capabilities which also includes DSP processing. This patch carry forwards the works that is done in the previous series to enable HD Audio codecs on such platforms.

This patch series adds ASoC HDA codec driver for Intel platforms. It is written by reusing the legacy HDA ALSA codec driver. Intention is to maximize the reuse and minimize the changes in the legacy HDA codec driver.

I would like to receive feedback before proceeding further on this direction.

INFO:
- This series is tested on KBL based product (Dell XPS 13).
- Basic playback is working with headset and speakers.
- HDMI playback is working.
- Capture operation is not tested.
- More platforms and use cases coverage can be added once we have basic agreement in terms of the overall approach.

Quoted 7 lines

Changes in v2:
- Using Topology framework to create DAIs and DAI Links
- Moved most commonly used functions into a separate file for machine driver
- Implemented separate Realtek ASoC HDA Driver driver for Realtek HDA codecs. It is just a driver registration wrapper which reuses the legacy HDA codec driver. This allows the removes the limitation that was present in v1.
- Implemented the review feedback.

Looking through the patchset quickly, I have a mixed feeling with it. I see you're trying to get it working with minimal changes, which is good in one side. OTOH, it is unacceptably messy, in special, because the device creation and registration phases are mixed up.

And exporting each codec table doesn't look nice. We need to find a better way...

thanks,

Takashi

#13 lore raw
Quoted 39 lines

-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Monday, December 11, 2017 4:53 PM
To: Ughreja, Rakesh A <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Koul, Vinod <[email protected]>; Patches Audio <[email protected]>
Subject: Re: [RFC v2 00/11] Enable HDA Codec support on Intel Platforms (Series2)

Quoted 21 lines · Rakesh Ughreja

Many Intel platforms (SKL, KBL) etc. in the market supports enhanced audio capabilities which also includes DSP processing. This patch carry forwards the works that is done in the previous series to enable HD Audio codecs on such platforms.

This patch series adds ASoC HDA codec driver for Intel platforms. It is written by reusing the legacy HDA ALSA codec driver. Intention is to maximize the reuse and minimize the changes in the legacy HDA codec driver.

I would like to receive feedback before proceeding further on this direction.

INFO:
- This series is tested on KBL based product (Dell XPS 13).
- Basic playback is working with headset and speakers.
- HDMI playback is working.
- Capture operation is not tested.
- More platforms and use cases coverage can be added once we have basic agreement in terms of the overall approach.

Quoted 4 lines

Changes in v2:
- Using Topology framework to create DAIs and DAI Links
- Moved most commonly used functions into a separate file for machine driver
- Implemented separate Realtek ASoC HDA Driver driver for Realtek HDA

Quoted 7 lines

codecs.

Quoted 3 lines

It is just a driver registration wrapper which reuses the legacy HDA codec driver. This allows the removes the limitation that was present in v1.
- Implemented the review feedback.

Looking through the patchset quickly, I have a mixed feeling with it. I see you're trying to get it working with minimal changes, which is

Thanks once again for the quick feedback.

Quoted 2 lines

good in one side. OTOH, it is unacceptably messy, in special, because the device creation and registration phases are mixed up.

I am not sure if I understand this fully. "Device creation and registration phases are mixed up". If you can explain bit more, I can try to improve it.

Quoted 3 lines

And exporting each codec table doesn't look nice. We need to find a better way...

Do you think accessing the codec table via some EXPORT function is a better way ?

Quoted 5 lines

thanks,

Takashi

#14 lore raw
Quoted 7 lines · Rakesh A
Quoted 3 lines

good in one side. OTOH, it is unacceptably messy, in special, because the device creation and registration phases are mixed up.

I am not sure if I understand this fully. "Device creation and registration phases are mixed up". If you can explain bit more, I can try to improve it.

e.g. in the patch 7, snd_hda_asoc_codec_new() has the code like:

+int snd_hda_asoc_codec_new(struct hda_bus *bus, struct snd_card *card,
+ unsigned int codec_addr, struct hda_codec **codecp)
+{
+ struct hda_codec *codec = NULL;
....
+ err = snd_device_new(card, SNDRV_DEV_CODEC, codec, &dev_ops);

which means that the device is being created in this function. At the same time, however, this function tries to register that codec device itself soon after the above:

+ list_for_each_entry(snd_dev, &card->devices, list) {
+ if (snd_dev->type == SNDRV_DEV_CODEC) {
+ void *device_data = snd_dev->device_data;
+
+ err = snd_device_register(card, device_data);
+ if (err < 0)

This is wrong. The registration must happen at a later stage once after all components get ready. After all, that's the reason we have the dev_register individual callback in snd_dev_ops.

The exception is a case with multiple probe-bindings like USB-audio that matches multiple times per interface. But it's an exception, and not applied to the normal probe. (And if any, you should just register the whole via snd_card_register() call.)

Quoted 5 lines
Quoted 2 lines

And exporting each codec table doesn't look nice. We need to find a better way...

Do you think accessing the codec table via some EXPORT function is a better way ?

We need more consideration. I don't think we have done it fully enough. At least, exporting each table sounds like a bad idea. Ideally, we should re-use the whole codec driver as is; i.e. the single codec probe should work for both legacy and ext controllers.

Takashi

#15 lore raw
Quoted 42 lines

-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Monday, December 11, 2017 8:51 PM
To: Ughreja, Rakesh A <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Koul, Vinod <[email protected]>; Patches Audio <[email protected]>
Subject: Re: [RFC v2 00/11] Enable HDA Codec support on Intel Platforms (Series2)

Quoted 7 lines · Rakesh A
Quoted 3 lines

good in one side. OTOH, it is unacceptably messy, in special, because the device creation and registration phases are mixed up.

I am not sure if I understand this fully. "Device creation and registration phases are mixed up". If you can explain bit more, I can try to improve it.

e.g. in the patch 7, snd_hda_asoc_codec_new() has the code like:

(quoted diff) +5 -0
+int snd_hda_asoc_codec_new(struct hda_bus *bus, struct snd_card *card,
+			unsigned int codec_addr, struct hda_codec **codecp)
+{
+	struct hda_codec *codec = NULL;
....
+	err = snd_device_new(card, SNDRV_DEV_CODEC, codec, &dev_ops);

which means that the device is being created in this function. At the same time, however, this function tries to register that codec device itself soon after the above:

(quoted diff) +6 -0
+	list_for_each_entry(snd_dev, &card->devices, list) {
+		if (snd_dev->type == SNDRV_DEV_CODEC) {
+			void *device_data = snd_dev->device_data;
+
+			err = snd_device_register(card, device_data);
+			if (err < 0)
Quoted 3 lines

This is wrong. The registration must happen at a later stage once after all components get ready. After all, that's the reason we have the dev_register individual callback in snd_dev_ops.

So when you say "after all the components get ready" what exactly you are referring to ?

I am calling snd_hda_asoc_codec_new function from probe function of hdac_driver. So I was thinking that since the codec is already enumerated from the bus point of view, I can register. What am I missing here ?

Quoted 9 lines

The exception is a case with multiple probe-bindings like USB-audio that matches multiple times per interface. But it's an exception, and not applied to the normal probe. (And if any, you should just register the whole via snd_card_register() call.)

Quoted 3 lines
Quoted 2 lines

And exporting each codec table doesn't look nice. We need to find a better way...

Quoted 7 lines
Quoted 2 lines

Do you think accessing the codec table via some EXPORT function is a better way ?

We need more consideration. I don't think we have done it fully enough. At least, exporting each table sounds like a bad idea. Ideally, we should re-use the whole codec driver as is; i.e. the single codec probe should work for both legacy and ext controllers.

The generic hdac_hda driver uses the legacy driver APIs once the hdac_dev is enumerated on the hdac_bus.
While the legacy driver APIs are used by controller driver.

Do you think it's a wrong path to go ? Should the legacy driver APIs be called directly from ASoC platform driver ?

#16 lore raw
Quoted 50 lines · Rakesh A
Quoted 43 lines

-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Monday, December 11, 2017 8:51 PM
To: Ughreja, Rakesh A <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Koul, Vinod <[email protected]>; Patches Audio <[email protected]>
Subject: Re: [RFC v2 00/11] Enable HDA Codec support on Intel Platforms (Series2)

Quoted 7 lines · Rakesh A
Quoted 3 lines

good in one side. OTOH, it is unacceptably messy, in special, because the device creation and registration phases are mixed up.

I am not sure if I understand this fully. "Device creation and registration phases are mixed up". If you can explain bit more, I can try to improve it.

e.g. in the patch 7, snd_hda_asoc_codec_new() has the code like:

(quoted diff) +5 -0
+int snd_hda_asoc_codec_new(struct hda_bus *bus, struct snd_card *card,
+			unsigned int codec_addr, struct hda_codec **codecp)
+{
+	struct hda_codec *codec = NULL;
....
+	err = snd_device_new(card, SNDRV_DEV_CODEC, codec, &dev_ops);

which means that the device is being created in this function. At the same time, however, this function tries to register that codec device itself soon after the above:

(quoted diff) +6 -0
+	list_for_each_entry(snd_dev, &card->devices, list) {
+		if (snd_dev->type == SNDRV_DEV_CODEC) {
+			void *device_data = snd_dev->device_data;
+
+			err = snd_device_register(card, device_data);
+			if (err < 0)
Quoted 3 lines

This is wrong. The registration must happen at a later stage once after all components get ready. After all, that's the reason we have the dev_register individual callback in snd_dev_ops.

So when you say "after all the components get ready" what exactly you are referring to ?

Quoted 3 lines

I am calling snd_hda_asoc_codec_new function from probe function of hdac_driver. So I was thinking that since the codec is already enumerated from the bus point of view, I can register. What am I missing here ?

The registration should be triggered from the top-level, i.e. the controller driver, once after all codecs get probed. Otherwise, it becomes racy. The user-space will start poking the device before all the stuff becomes ready.

That said, at the point when the codec is probed, the card shouldn't be registered yet. The card gets registered after the all components are bound and become ready -- which is done a single snd_card_register() call. At this point, the access points to user-space are provided.

Quoted 16 lines
Quoted 8 lines

The exception is a case with multiple probe-bindings like USB-audio that matches multiple times per interface. But it's an exception, and not applied to the normal probe. (And if any, you should just register the whole via snd_card_register() call.)

Quoted 3 lines
Quoted 2 lines

And exporting each codec table doesn't look nice. We need to find a better way...

Quoted 7 lines
Quoted 2 lines

Do you think accessing the codec table via some EXPORT function is a better way ?

We need more consideration. I don't think we have done it fully enough. At least, exporting each table sounds like a bad idea. Ideally, we should re-use the whole codec driver as is; i.e. the single codec probe should work for both legacy and ext controllers.

Quoted 6 lines

The generic hdac_hda driver uses the legacy driver APIs once the hdac_dev is enumerated on the hdac_bus.
While the legacy driver APIs are used by controller driver.

Do you think it's a wrong path to go ? Should the legacy driver APIs be called directly from ASoC platform driver ?

The ideal situation would be that there is no difference in the codec driver level which controller driver to bind. It means we'd need some stuff from the legacy helper merged into the hda-core, and I'm not sure how difficult it would be.

Takashi

#17 lore raw
Quoted 13 lines

-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Tuesday, December 12, 2017 12:19 AM
To: Ughreja, Rakesh A <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Koul, Vinod <[email protected]>; Patches Audio <[email protected]>
Subject: Re: [RFC v2 00/11] Enable HDA Codec support on Intel Platforms (Series2)

Quoted 4 lines

The registration should be triggered from the top-level, i.e. the controller driver, once after all codecs get probed. Otherwise, it becomes racy. The user-space will start poking the device before all the stuff becomes ready.

Thank you very much, I understand now.

Quoted 6 lines

That said, at the point when the codec is probed, the card shouldn't be registered yet. The card gets registered after the all components are bound and become ready -- which is done a single snd_card_register() call. At this point, the access points to user-space are provided.

So based on your suggestion when I relooked at the code, I could remove the new function that I added. I could completely reuse the existing function with little change.

Does it look okay ?

Following is the patch, which I tested and it works for me.
I will include this in next series but for now it's only for quick reference.

I am calling this API from the hdac_hda codec driver with argument HDA_DEV_ASOC to make sure that it does not register with the bus again. I am not able to call this API from ASoC Platform driver because I don't have snd_card pointer at the time of machine driver probe.

Following is the patch.
---------------------------
Modify snd_hda_codec_new API so that it can work for legacy as well as ASoC codec drivers. The API takes an additional argument dev_type as HDA_DEV_LEGACY or HDA_DEV_ASOC to distinguish the caller.

---
 sound/pci/hda/hda_codec.c      | 30 +++++++++++++++++++-----------
 sound/pci/hda/hda_codec.h      |  3 ++-
 sound/pci/hda/hda_controller.c |  2 +-
 3 files changed, 22 insertions(+), 13 deletions(-)
sound/pci/hda/hda_codec.c +19 -11
index 085fd9e..252779c 100644
@@ -865,7 +865,8 @@ static void snd_hda_codec_dev_release(struct device *dev)
  * Returns 0 if successful, or a negative error code.
  */
 int snd_hda_codec_new(struct hda_bus *bus, struct snd_card *card,
-		      unsigned int codec_addr, struct hda_codec **codecp)
+		      unsigned int codec_addr, struct hda_codec **codecp,
+			unsigned int dev_type)
 {
 	struct hda_codec *codec;
 	char component[31];
@@ -882,20 +883,27 @@ int snd_hda_codec_new(struct hda_bus *bus, struct snd_card *card,
 	if (snd_BUG_ON(codec_addr > HDA_MAX_CODEC_ADDRESS))
 		return -EINVAL;
 
-	codec = kzalloc(sizeof(*codec), GFP_KERNEL);
-	if (!codec)
-		return -ENOMEM;
+	if (dev_type == HDA_DEV_LEGACY) {
 
-	sprintf(component, "hdaudioC%dD%d", card->number, codec_addr);
-	err = snd_hdac_device_init(&codec->core, &bus->core, component,
-				   codec_addr);
-	if (err < 0) {
-		kfree(codec);
-		return err;
+		codec = kzalloc(sizeof(*codec), GFP_KERNEL);
+		if (!codec)
+			return -ENOMEM;
+
+		sprintf(component, "hdaudioC%dD%d", card->number, codec_addr);
+		err = snd_hdac_device_init(&codec->core, &bus->core, component,
+						codec_addr);
+		if (err < 0) {
+			kfree(codec);
+			return err;
+		}
+
+		codec->core.type = HDA_DEV_LEGACY;
+
+	} else {
+		codec = *codecp;
 	}
 
 	codec->core.dev.release = snd_hda_codec_dev_release;
-	codec->core.type = HDA_DEV_LEGACY;
 	codec->core.exec_verb = codec_exec_verb;
 
 	codec->bus = bus;
sound/pci/hda/hda_codec.h +2 -1
index d3099db..92815b7 100644
@@ -306,7 +306,8 @@ struct hda_codec {
  * constructors
  */
 int snd_hda_codec_new(struct hda_bus *bus, struct snd_card *card,
-		      unsigned int codec_addr, struct hda_codec **codecp);
+			unsigned int codec_addr, struct hda_codec **codecp,
+			unsigned int dev_type);
 int snd_hda_codec_configure(struct hda_codec *codec);
 int snd_hda_codec_update_widgets(struct hda_codec *codec);
 
sound/pci/hda/hda_controller.c +1 -1
index d1eb148..ec887d7 100644
@@ -1318,7 +1318,7 @@ int azx_probe_codecs(struct azx *chip, unsigned int max_slots)
 	for (c = 0; c < max_slots; c++) {
 		if ((bus->codec_mask & (1 << c)) & chip->codec_probe_mask) {
 			struct hda_codec *codec;
-			err = snd_hda_codec_new(&chip->bus, chip->card, c, &codec);
+			err = snd_hda_codec_new(&chip->bus, chip->card, c, &codec, HDA_DEV_LEGACY);
 			if (err < 0)
 				continue;
 			codec->jackpoll_interval = get_jackpoll_interval(chip);
Signature · 1 line
2.7.4
#18 lore raw
Quoted 28 lines · Rakesh A
Quoted 14 lines

-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Tuesday, December 12, 2017 12:19 AM
To: Ughreja, Rakesh A <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Koul, Vinod <[email protected]>; Patches Audio <[email protected]>
Subject: Re: [RFC v2 00/11] Enable HDA Codec support on Intel Platforms (Series2)

Quoted 4 lines

The registration should be triggered from the top-level, i.e. the controller driver, once after all codecs get probed. Otherwise, it becomes racy. The user-space will start poking the device before all the stuff becomes ready.

Thank you very much, I understand now.

Quoted 6 lines

That said, at the point when the codec is probed, the card shouldn't be registered yet. The card gets registered after the all components are bound and become ready -- which is done a single snd_card_register() call. At this point, the access points to user-space are provided.

Quoted 5 lines

So based on your suggestion when I relooked at the code, I could remove the new function that I added. I could completely reuse the existing function with little change.

Does it look okay ?

Lesser, better :)

Quoted 8 lines

Following is the patch, which I tested and it works for me.
I will include this in next series but for now it's only for quick reference.

I am calling this API from the hdac_hda codec driver with argument HDA_DEV_ASOC to make sure that it does not register with the bus again. I am not able to call this API from ASoC Platform driver because I don't have snd_card pointer at the time of machine driver probe.

Quoted 5 lines

Following is the patch.
---------------------------
Modify snd_hda_codec_new API so that it can work for legacy as well as ASoC codec drivers. The API takes an additional argument dev_type as HDA_DEV_LEGACY or HDA_DEV_ASOC to distinguish the caller.

The idea looks good, but I'd prefer different functions instead of mutating the behavior depending on the flag. i.e. keep snd_hda_codec_new(), and introduce another API (snd_hda_codec_init() or whatever). ASoC driver can call the latter while the legacy driver keeps calling the former.

This would factor out the allocation and snd_hdac_device_init() calls from the old snd_hda_codec_new() to a new snd_hda_codec_new(). snd_hda_codec_init() would do the rest. snd_hda_codec_new() calls snd_hda_codec_init() at the end of the function.

Does this sound good for you?

thanks,

Takashi

Quoted 90 lines
---
 sound/pci/hda/hda_codec.c      | 30 +++++++++++++++++++-----------
 sound/pci/hda/hda_codec.h      |  3 ++-
 sound/pci/hda/hda_controller.c |  2 +-
 3 files changed, 22 insertions(+), 13 deletions(-)
sound/pci/hda/hda_codec.c +19 -11
index 085fd9e..252779c 100644
@@ -865,7 +865,8 @@ static void snd_hda_codec_dev_release(struct device *dev)
  * Returns 0 if successful, or a negative error code.
  */
 int snd_hda_codec_new(struct hda_bus *bus, struct snd_card *card,
-		      unsigned int codec_addr, struct hda_codec **codecp)
+		      unsigned int codec_addr, struct hda_codec **codecp,
+			unsigned int dev_type)
 {
 	struct hda_codec *codec;
 	char component[31];
@@ -882,20 +883,27 @@ int snd_hda_codec_new(struct hda_bus *bus, struct snd_card *card,
 	if (snd_BUG_ON(codec_addr > HDA_MAX_CODEC_ADDRESS))
 		return -EINVAL;
 
-	codec = kzalloc(sizeof(*codec), GFP_KERNEL);
-	if (!codec)
-		return -ENOMEM;
+	if (dev_type == HDA_DEV_LEGACY) {
 
-	sprintf(component, "hdaudioC%dD%d", card->number, codec_addr);
-	err = snd_hdac_device_init(&codec->core, &bus->core, component,
-				   codec_addr);
-	if (err < 0) {
-		kfree(codec);
-		return err;
+		codec = kzalloc(sizeof(*codec), GFP_KERNEL);
+		if (!codec)
+			return -ENOMEM;
+
+		sprintf(component, "hdaudioC%dD%d", card->number, codec_addr);
+		err = snd_hdac_device_init(&codec->core, &bus->core, component,
+						codec_addr);
+		if (err < 0) {
+			kfree(codec);
+			return err;
+		}
+
+		codec->core.type = HDA_DEV_LEGACY;
+
+	} else {
+		codec = *codecp;
 	}
 
 	codec->core.dev.release = snd_hda_codec_dev_release;
-	codec->core.type = HDA_DEV_LEGACY;
 	codec->core.exec_verb = codec_exec_verb;
 
 	codec->bus = bus;
sound/pci/hda/hda_codec.h +2 -1
index d3099db..92815b7 100644
@@ -306,7 +306,8 @@ struct hda_codec {
  * constructors
  */
 int snd_hda_codec_new(struct hda_bus *bus, struct snd_card *card,
-		      unsigned int codec_addr, struct hda_codec **codecp);
+			unsigned int codec_addr, struct hda_codec **codecp,
+			unsigned int dev_type);
 int snd_hda_codec_configure(struct hda_codec *codec);
 int snd_hda_codec_update_widgets(struct hda_codec *codec);
 
sound/pci/hda/hda_controller.c +1 -1
index d1eb148..ec887d7 100644
@@ -1318,7 +1318,7 @@ int azx_probe_codecs(struct azx *chip, unsigned int max_slots)
 	for (c = 0; c < max_slots; c++) {
 		if ((bus->codec_mask & (1 << c)) & chip->codec_probe_mask) {
 			struct hda_codec *codec;
-			err = snd_hda_codec_new(&chip->bus, chip->card, c, &codec);
+			err = snd_hda_codec_new(&chip->bus, chip->card, c, &codec, HDA_DEV_LEGACY);
 			if (err < 0)
 				continue;
 			codec->jackpoll_interval = get_jackpoll_interval(chip);
Signature · 1 line
2.7.4
#19 lore raw
Quoted 22 lines

-----Original Message-----
From: [email protected] [mailto:alsa-devel-bounces@alsa- project.org] On Behalf Of Takashi Iwai
Sent: Tuesday, December 12, 2017 10:21 PM
To: Ughreja, Rakesh A <[email protected]>
Cc: [email protected]; Koul, Vinod <[email protected]>; pierre- [email protected]; [email protected]; Patches Audio <[email protected]>; [email protected]
Subject: Re: [alsa-devel] [RFC v2 00/11] Enable HDA Codec support on Intel Platforms (Series2)

The idea looks good, but I'd prefer different functions instead of mutating the behavior depending on the flag. i.e. keep snd_hda_codec_new(), and introduce another API (snd_hda_codec_init() or whatever). ASoC driver can call the latter while the legacy driver keeps calling the former.

Quoted 6 lines

This would factor out the allocation and snd_hdac_device_init() calls from the old snd_hda_codec_new() to a new snd_hda_codec_new(). snd_hda_codec_init() would do the rest. snd_hda_codec_new() calls snd_hda_codec_init() at the end of the function.

Does this sound good for you?

I think I got this :) Thanks. Here is the skeleton code. I split the existing function snd_hda_codec_new into two parts.

1. snd_hda_codec_device_init()
2. snd_hda_codec_device_new()

So the new body of existing function snd_hda_codec_new looks like.

int snd_hda_codec_new(struct hda_bus *bus, struct snd_card *card,
unsigned int codec_addr, struct hda_codec **codecp)

{                                                                               
        int ret;                                                                
                                                                                
        ret = snd_hda_codec_device_init(bus, card, codec_addr, codecp);         
        if (ret < 0)                                                            
                return ret;                                                     
                                                                                
        return snd_hda_codec_device_new(bus, card, codec_addr, *codecp);        
}

The ASoC driver would call only snd_hda_codec_device_new.
If you have any suggestions for the function names, I can change it before I post the next series.

Now switching over to the id_table problem. In the current series it is accessed using extern, in the patch_realtek.c file. So we really have two different KO files. One for legacy HDA driver and second for ASoC HDA driver.

Would you like to keep them as two separate KO files or prefer to have a single KO file ?

#20 lore raw
In reply to Ughreja, Rakesh A

Hi,
Where is your code located? Since I have got a macbook pro 2016 and I believe this feature is a prerequisite to get any sound working. I would love to test it with my cirrus logic 8409 HDA soundcard.

Bests,
Joël

Quoted 136 lines · Rakesh A
Quoted 13 lines

-----Original Message-----
From: Takashi Iwai [mailto:[email protected]]
Sent: Tuesday, December 12, 2017 12:19 AM
To: Ughreja, Rakesh A <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Koul, Vinod <[email protected]>; Patches Audio <[email protected]>
Subject: Re: [RFC v2 00/11] Enable HDA Codec support on Intel Platforms (Series2)

Quoted 4 lines

The registration should be triggered from the top-level, i.e. the controller driver, once after all codecs get probed. Otherwise, it becomes racy. The user-space will start poking the device before all the stuff becomes ready.

Thank you very much, I understand now.

Quoted 6 lines

That said, at the point when the codec is probed, the card shouldn't be registered yet. The card gets registered after the all components are bound and become ready -- which is done a single snd_card_register() call. At this point, the access points to user-space are provided.

So based on your suggestion when I relooked at the code, I could remove the new function that I added. I could completely reuse the existing function with little change.

Does it look okay ?

Following is the patch, which I tested and it works for me.
I will include this in next series but for now it's only for quick reference.

I am calling this API from the hdac_hda codec driver with argument HDA_DEV_ASOC to make sure that it does not register with the bus again. I am not able to call this API from ASoC Platform driver because I don't have snd_card pointer at the time of machine driver probe.

Following is the patch.
---------------------------
Modify snd_hda_codec_new API so that it can work for legacy as well as ASoC codec drivers. The API takes an additional argument dev_type as HDA_DEV_LEGACY or HDA_DEV_ASOC to distinguish the caller.

---
 sound/pci/hda/hda_codec.c      | 30 +++++++++++++++++++-----------
 sound/pci/hda/hda_codec.h      |  3 ++-
 sound/pci/hda/hda_controller.c |  2 +-
 3 files changed, 22 insertions(+), 13 deletions(-)
sound/pci/hda/hda_codec.c +19 -11
index 085fd9e..252779c 100644
@@ -865,7 +865,8 @@ static void snd_hda_codec_dev_release(struct device *dev)
  * Returns 0 if successful, or a negative error code.
  */
 int snd_hda_codec_new(struct hda_bus *bus, struct snd_card *card,
-                     unsigned int codec_addr, struct hda_codec **codecp)
+                     unsigned int codec_addr, struct hda_codec **codecp,
+                       unsigned int dev_type)
 {
        struct hda_codec *codec;
        char component[31];
@@ -882,20 +883,27 @@ int snd_hda_codec_new(struct hda_bus *bus, struct snd_card *card,
        if (snd_BUG_ON(codec_addr > HDA_MAX_CODEC_ADDRESS))
                return -EINVAL;
 
-       codec = kzalloc(sizeof(*codec), GFP_KERNEL);
-       if (!codec)
-               return -ENOMEM;
+       if (dev_type == HDA_DEV_LEGACY) {
 
-       sprintf(component, "hdaudioC%dD%d", card->number, codec_addr);
-       err = snd_hdac_device_init(&codec->core, &bus->core, component,
-                                  codec_addr);
-       if (err < 0) {
-               kfree(codec);
-               return err;
+               codec = kzalloc(sizeof(*codec), GFP_KERNEL);
+               if (!codec)
+                       return -ENOMEM;
+
+               sprintf(component, "hdaudioC%dD%d", card->number, codec_addr);
+               err = snd_hdac_device_init(&codec->core, &bus->core, component,
+                                               codec_addr);
+               if (err < 0) {
+                       kfree(codec);
+                       return err;
+               }
+
+               codec->core.type = HDA_DEV_LEGACY;
+
+       } else {
+               codec = *codecp;
        }
 
        codec->core.dev.release = snd_hda_codec_dev_release;
-       codec->core.type = HDA_DEV_LEGACY;
        codec->core.exec_verb = codec_exec_verb;
 
        codec->bus = bus;
sound/pci/hda/hda_codec.h +2 -1
index d3099db..92815b7 100644
@@ -306,7 +306,8 @@ struct hda_codec {
  * constructors
  */
 int snd_hda_codec_new(struct hda_bus *bus, struct snd_card *card,
-                     unsigned int codec_addr, struct hda_codec **codecp);
+                       unsigned int codec_addr, struct hda_codec **codecp,
+                       unsigned int dev_type);
 int snd_hda_codec_configure(struct hda_codec *codec);
 int snd_hda_codec_update_widgets(struct hda_codec *codec);
 
sound/pci/hda/hda_controller.c +1 -2
index d1eb148..ec887d7 100644
@@ -1318,7 +1318,7 @@ int azx_probe_codecs(struct azx *chip, unsigned int max_slots)
        for (c = 0; c < max_slots; c++) {
                if ((bus->codec_mask & (1 << c)) & chip->codec_probe_mask) {
                        struct hda_codec *codec;
-                       err = snd_hda_codec_new(&chip->bus, chip->card, c, &codec);
+                       err = snd_hda_codec_new(&chip->bus, chip->card, c, &codec, HDA_DEV_LEGACY);
                        if (err < 0)
                                continue;
                        codec->jackpoll_interval = get_jackpoll_interval(chip);
--

2.7.4

Quoted 4 lines

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#21 lore raw
Quoted 14 lines

-----Original Message-----
From: [email protected] [mailto:alsa-devel-bounces@alsa- project.org] On Behalf Of Joël Krähemann
Sent: Tuesday, December 12, 2017 11:52 PM
To: Ughreja, Rakesh A <[email protected]>
Cc: [email protected]; Takashi Iwai <[email protected]>; pierre- [email protected]; Patches Audio <[email protected]>; [email protected]; Koul, Vinod <[email protected]>; [email protected]
Subject: Re: [alsa-devel] [RFC v2 00/11] Enable HDA Codec support on Intel Platforms (Series2)

Quoted 4 lines

Hi,
Where is your code located? Since I have got a macbook pro 2016 and I believe this feature is a prerequisite to get any sound working. I would love to test it with my cirrus logic 8409 HDA soundcard.

My last series was rebased on top of Mark's for-next tree. You would need Topology file, which I can send via email. But before I do that I want to confirm if you have the right things enabled.

Do you know if it is based on 6th Generation (SKL) or 7th Generation(KBL) of Intel core ? You will need to download the DSP Firmware binary file based on this.
Also I am not sure if the DSP functionality is enabled on the MAC systems. If you compile snd-hda-core.ko in debug mode, it prints the capabilities. I can check that from the logs.

Regards,
Rakesh

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#22 lore raw

Hi,
I am pretty sure it contains this integrated circuit: MAX98357BEWL It is a DSP. Why is a need for firmware?

It is a Intel Core i5-6360U

https://bugzilla.kernel.org/show_bug.cgi?id=195671

Bests,
Joël

Quoted 23 lines · Rakesh A
Quoted 14 lines

-----Original Message-----
From: [email protected] [mailto:alsa-devel-bounces@alsa- project.org] On Behalf Of Joël Krähemann
Sent: Tuesday, December 12, 2017 11:52 PM
To: Ughreja, Rakesh A <[email protected]>
Cc: [email protected]; Takashi Iwai <[email protected]>; pierre- [email protected]; Patches Audio <[email protected]>; [email protected]; Koul, Vinod <[email protected]>; [email protected]
Subject: Re: [alsa-devel] [RFC v2 00/11] Enable HDA Codec support on Intel Platforms (Series2)

Quoted 4 lines

Hi,
Where is your code located? Since I have got a macbook pro 2016 and I believe this feature is a prerequisite to get any sound working. I would love to test it with my cirrus logic 8409 HDA soundcard.

My last series was rebased on top of Mark's for-next tree. You would need Topology file, which I can send via email. But before I do that I want to confirm if you have the right things enabled.

Quoted 8 lines

Do you know if it is based on 6th Generation (SKL) or 7th Generation(KBL) of Intel core ? You will need to download the DSP Firmware binary file based on this.
Also I am not sure if the DSP functionality is enabled on the MAC systems. If you compile snd-hda-core.ko in debug mode, it prints the capabilities. I can check that from the logs.

Regards,
Rakesh

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#23 lore raw
Quoted 13 lines

-----Original Message-----
From: Joël Krähemann [mailto:[email protected]]
Sent: Wednesday, December 13, 2017 12:21 AM
To: Ughreja, Rakesh A <[email protected]>
Cc: [email protected]; Takashi Iwai <[email protected]>; pierre- [email protected]; Patches Audio <[email protected]>; [email protected]; Koul, Vinod <[email protected]>; [email protected]
Subject: Re: [alsa-devel] [RFC v2 00/11] Enable HDA Codec support on Intel Platforms (Series2)

Quoted 7 lines

Hi,
I am pretty sure it contains this integrated circuit: MAX98357BEWL It is a DSP. Why is a need for firmware?

It is a Intel Core i5-6360U

https://bugzilla.kernel.org/show_bug.cgi?id=195671

After looking at the Bugzilla it looks like you are looking for something else.

Recent Intel platforms contains HD Audio controllers with Integrated DSPs. Intel releases firmware which runs on this DSPs. You can connect various codecs e.g. I2S, HDA etc. Support for I2S based codecs is already available in the kernel today. However support for HDA codecs connected via DSP is not yet upstreamed. I am trying to do it.

In your case the DSP functionality is part of the Maxim HDA codec. My work is to enable the DSP functionality on the Intel SoC. So it may not help you directly.

Regards,
Rakesh

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel