Enable HDA Codec support on Intel Platforms (Series2)
Subsystems (3)
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 work 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.
Changes in v2:
- Resolved review comments and rebased to latest kernel.
- added module load support for codec drivers.
Rakesh Ughreja (10):
ALSA - Ext hda: add wait for codec to respond after link reset
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 - split snd_hda_codec_new function
ALSA: hdac: remove memory allocation from snd_hdac_ext_bus_device_init
ALSA: hdac: add extended ops in the hdac_bus
ASoC: hdac_hda: add asoc extension for legacy HDA codec drivers
ASoC: Intel: Boards: add support for HDA codecs
include/sound/hdaudio.h | 9 + include/sound/hdaudio_ext.h | 6 +- sound/hda/ext/hdac_ext_bus.c | 12 +- sound/hda/ext/hdac_ext_controller.c | 8 + sound/pci/hda/hda_bind.c | 12 + sound/pci/hda/hda_codec.c | 68 +++- sound/pci/hda/hda_codec.h | 2 + sound/soc/codecs/Kconfig | 5 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/hdac_hda.c | 464 +++++++++++++++++++++++++++ sound/soc/codecs/hdac_hda.h | 23 ++ sound/soc/intel/boards/Kconfig | 9 + sound/soc/intel/boards/Makefile | 2 + sound/soc/intel/boards/skl_hda_dsp_common.c | 131 ++++++++ sound/soc/intel/boards/skl_hda_dsp_common.h | 35 ++ sound/soc/intel/boards/skl_hda_dsp_generic.c | 175 ++++++++++ sound/soc/intel/skylake/skl-pcm.c | 70 +++- sound/soc/intel/skylake/skl.c | 119 ++++++- sound/soc/intel/skylake/skl.h | 12 +- 19 files changed, 1115 insertions(+), 49 deletions(-) create mode 100644 sound/soc/codecs/hdac_hda.c create mode 100644 sound/soc/codecs/hdac_hda.h 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
PATCH v2 1/10 ALSA - Ext hda: add wait for codec to respond after link reset
As per HDA spec section 4.3 - Codec Discovery, the software shall wait for atleast 521usec for codec to respond after link reset. With the multi-link capability each link is turned ON/OFF individually. Link controller drives reset signal when it is turned ON.
--- sound/hda/ext/hdac_ext_controller.c | 8 ++++++++ 1 file changed, 8 insertions(+)
sound/hda/ext/hdac_ext_controller.c +8 -0
@@ -271,6 +271,14 @@ int snd_hdac_ext_bus_link_get(struct hdac_bus *bus, } ret =snd_hdac_ext_bus_link_power_up (link); + +/* +* wait for 521usec for codec to report status +* HDA spec section 4.3 - Codec Discovery +*/ +udelay (521 ); + bus->codec_mask =snd_hdac_chip_readw (bus,STATESTS ); +dev_dbg (bus->dev,"codec_mask = 0x%lx\n" , bus->codec_mask); }mutex_unlock (&bus->lock);
Signature · 1 line
2.7.4
PATCH v2 2/10 ASoC: Intel: Boards: Machine driver for Intel platforms
In reply to Rakesh UghrejaAdd machine driver for Intel platforms (SKL/KBL/BXT/APL) with HDA and iDisp codecs. This patch adds support for only iDisp (HDMI/DP) codec. In the following patches support for HDA codecs will be added.
This should work for other Intel platforms as well e.g. GLK,CNL however this series is not tested on all the platforms.
--- sound/soc/intel/boards/Kconfig | 8 ++ sound/soc/intel/boards/Makefile | 2 + sound/soc/intel/boards/skl_hda_dsp_common.c | 107 +++++++++++++++++++++ sound/soc/intel/boards/skl_hda_dsp_common.h | 35 +++++++ sound/soc/intel/boards/skl_hda_dsp_generic.c | 136 +++++++++++++++++++++++++++ sound/soc/intel/skylake/skl.h | 2 + 6 files changed, 290 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 +8 -0
@@ -279,6 +279,14 @@ config SND_SOC_INTEL_KBL_DA7219_MAX98357A_MACH This adds support for ASoC Onboard Codec I2S machine driver. This will create an alsa sound card for DA7219 + MAX98357A I2S audio codec. Say Y if you have such a device. + +config SND_SOC_INTEL_SKL_HDA_DSP_GENERIC_MACH + tristate "SKL/KBL/BXT/APL with HDA Codecs" + select SND_SOC_HDAC_HDMI + help + This adds support for ASoC machine driver for Intel platforms + SKL/KBL/BXT/APL with iDisp, HDA audio codecs. + Say Y or m if you have such a device. This is a recommended option. If unsure select "N". endif ## SND_SOC_INTEL_SKYLAKE
sound/soc/intel/boards/Makefile +2 -0
@@ -19,6 +19,7 @@ snd-soc-kbl_da7219_max98357a-objs := kbl_da7219_max98357a.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
@@ -44,3 +45,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 +107 -0
107 lines not on this page · raw message
sound/soc/intel/boards/skl_hda_dsp_common.h new file +35 -0
@@ -0,0 +1,35 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright(c) 2015-17 Intel Corporation. + +/* +* This file defines data structures used in Machine Driver for Intel +* platforms with HDA Codecs. +*/ + +#ifndef __SOUND_SOC_HDA_DSP_COMMON_H +#define __SOUND_SOC_HDA_DSP_COMMON_H +#include <linux/module.h> +#include <linux/platform_device.h> +#include <sound/core.h> +#include <sound/jack.h> + +#define HDA_DSP_MAX_BE_DAI_LINKS 3 + +struct skl_hda_hdmi_pcm { +struct list_head head; +struct snd_soc_dai *codec_dai; +struct snd_soc_jack hdmi_jack; +int device; +}; + +struct skl_hda_private { +struct list_head hdmi_pcm_list; +int pcm_count; +const char *platform_name; +}; + +extern struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS ]; +int skl_hda_hdmi_jack_init (struct snd_soc_card *card); +int skl_hda_hdmi_add_pcm (struct snd_soc_card *card,int device); + +#endif /* __SOUND_SOC_HDA_DSP_COMMON_H */
sound/soc/intel/boards/skl_hda_dsp_generic.c new file +136 -0
136 lines not on this page · raw message
sound/soc/intel/skylake/skl.h +2 -0
@@ -113,6 +113,8 @@ struct skl_dma_params {struct skl_machine_pdata {u32 dmic_num;bool use_tplg_pcm;/* use dais and dai links from topology */ +const char *platform; +u32 codec_mask; };struct skl_dsp_ops {
Signature · 1 line
2.7.4
PATCH v2 3/10 ASoC: Intel: Skylake: Add entry in sst_acpi_mach for HDA codecs
In reply to Rakesh UghrejaWhen no I2S based codec entries are found in the BIOS, check if there are any HDA codecs detected on the bus. Based on the number of codecs found take appropriate action in machine driver. If there are two HDA codecs i.e. iDisp + HDA found on the bus, register DAIs and DAI links for both. If only one codec i.e. iDisp is found then load only iDisp machine driver.
--- sound/soc/intel/skylake/skl.c | 60 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 55 insertions(+), 5 deletions(-)
sound/soc/intel/skylake/skl.c +55 -5
@@ -442,6 +442,24 @@ static struct skl_ssp_clk skl_ssp_clks[] = { {.name = "ssp5_sclkfs"}, }; +static struct snd_soc_acpi_mach *skl_find_hda_machine (struct skl *skl, +struct snd_soc_acpi_mach *machines) +{ + +struct hdac_bus *bus =skl_to_bus (skl); +struct snd_soc_acpi_mach *mach; + +/* check if we have any codecs detected on bus */ +if (bus->codec_mask ==0 ) +return NULL ; + +for (mach = machines; mach->id[0 ]; mach++) { +if (!strcmp (mach->id,"HDA_GEN" )) +return mach; + } +return NULL ; +} +static int skl_find_machine (struct skl *skl,void *driver_data) {struct hdac_bus *bus =skl_to_bus (skl);
@@ -450,8 +468,12 @@ static int skl_find_machine(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_find_hda_machine (skl, driver_data); +if (mach ==NULL ) { +dev_err (bus->dev,"No matching machine driver found\n" ); +return -ENODEV ; + } } skl->mach = mach;
@@ -466,8 +488,9 @@ static int skl_find_machine(struct skl *skl, void *driver_data)static int skl_machine_device_register (struct skl *skl) { -struct hdac_bus *bus =skl_to_bus (skl);struct snd_soc_acpi_mach *mach = skl->mach; +struct hdac_bus *bus =skl_to_bus (skl); +struct skl_machine_pdata *pdata;struct platform_device *pdev;int ret;
@@ -484,8 +507,12 @@ static int skl_machine_device_register(struct skl *skl)return -EIO ; } -if (mach->pdata) +if (mach->pdata) { + pdata = (struct skl_machine_pdata *)mach->pdata; + pdata->platform =dev_name (bus->dev); + pdata->codec_mask = bus->codec_mask;dev_set_drvdata (&pdev->dev, mach->pdata); + } skl->i2s_dev = pdev;
@@ -1030,6 +1057,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, + }, {} };
@@ -1046,6 +1081,14 @@ static struct snd_soc_acpi_mach sst_bxtp_devdata[] = { .machine_quirk = snd_soc_acpi_codec_list, .quirk_data = &bxt_codecs, }, + { + .id = "HDA_GEN", + .drv_name = "skl_hda_generic", + .fw_filename = "intel/dsp_fw_bxtn.bin", + .machine_quirk = NULL, + .quirk_data = NULL, + .pdata = &cnl_pdata, + }, {} };
@@ -1100,7 +1143,14 @@ static struct snd_soc_acpi_mach sst_kbl_devdata[] = { .quirk_data = &kbl_7219_98357_codecs, .pdata = &skl_dmic_data }, - + { + .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
PATCH v2 4/10 ASoC: Intel: Skylake: add HDA BE DAIs
In reply to Rakesh UghrejaAdd support for HDA BE DAIs in SKL platform driver.
--- sound/soc/intel/skylake/skl-pcm.c | 70 ++++++++++++++++++++++++++++++++------- 1 file changed, 58 insertions(+), 12 deletions(-)
sound/soc/intel/skylake/skl-pcm.c +58 -12
@@ -32,6 +32,7 @@#define HDA_MONO 1#define HDA_STEREO 2#define HDA_QUAD 4 +#define HDA_MAX 8static const struct snd_pcm_hardware azx_pcm_hw = { .info = (SNDRV_PCM_INFO_MMAP |
@@ -541,7 +542,10 @@ static int skl_link_hw_params(struct snd_pcm_substream *substream, stream_tag =hdac_stream (link_dev)->stream_tag;/* set the stream tag in the codec dai dma params */ -snd_soc_dai_set_tdm_slot (codec_dai, stream_tag,0 ,0 ,0 ); +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) +snd_soc_dai_set_tdm_slot (codec_dai, stream_tag,0 ,0 ,0 ); +else +snd_soc_dai_set_tdm_slot (codec_dai,0 , stream_tag,0 ,0 ); p_params.s_fmt =snd_pcm_format_width (params_format (params)); p_params.ch =params_channels (params);
@@ -967,21 +971,63 @@ 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, - .channels_max = HDA_STEREO, - .rates = SNDRV_PCM_RATE_48000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, + .stream_name = "Analog CPU Playback", + .channels_min = HDA_MONO, + .channels_max = HDA_MAX, + .rates = SNDRV_PCM_RATE_8000_192000, + .formats =SNDRV_PCM_FMTBIT_S16_LE |SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S32_LE, }, .capture = { - .stream_name = "HD-Codec Rx", - .channels_min = HDA_STEREO, - .channels_max = HDA_STEREO, - .rates = SNDRV_PCM_RATE_48000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, + .stream_name = "Analog CPU Capture", + .channels_min = HDA_MONO, + .channels_max = HDA_MAX, + .rates = SNDRV_PCM_RATE_8000_192000, + .formats =SNDRV_PCM_FMTBIT_S16_LE |SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S32_LE, + }, +}, +{ + .name = "Alt Analog CPU DAI", + .ops = &skl_link_dai_ops, + .playback = { + .stream_name = "Alt Analog CPU Playback", + .channels_min = HDA_MONO, + .channels_max = HDA_MAX, + .rates = SNDRV_PCM_RATE_8000_192000, + .formats =SNDRV_PCM_FMTBIT_S16_LE |SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S32_LE, + }, + .capture = { + .stream_name = "Alt Analog CPU Capture", + .channels_min = HDA_MONO, + .channels_max = HDA_MAX, + .rates = SNDRV_PCM_RATE_8000_192000, + .formats =SNDRV_PCM_FMTBIT_S16_LE |SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S32_LE, + }, +}, +{ + .name = "Digital CPU DAI", + .ops = &skl_link_dai_ops, + .playback = { + .stream_name = "Digital CPU Playback", + .channels_min = HDA_MONO, + .channels_max = HDA_MAX, + .rates = SNDRV_PCM_RATE_8000_192000, + .formats =SNDRV_PCM_FMTBIT_S16_LE |SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S32_LE, + }, + .capture = { + .stream_name = "Digital CPU Capture", + .channels_min = HDA_MONO, + .channels_max = HDA_MAX, + .rates = SNDRV_PCM_RATE_8000_192000, + .formats =SNDRV_PCM_FMTBIT_S16_LE |SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S32_LE, }, }, };
Signature · 1 line
2.7.4
PATCH v2 5/10 ASoC: Intel: Skylake: use hda_bus instead of hdac_bus
In reply to Rakesh UghrejaUse hda_bus instead of hdac_bus in the SKL ASoC platform driver to enable reuse of legacy HDA codec drivers.
--- sound/soc/intel/skylake/skl.c | 10 +++++++++- sound/soc/intel/skylake/skl.h | 10 +++++++--- 2 files changed, 16 insertions(+), 4 deletions(-)
sound/soc/intel/skylake/skl.c +9 -1
@@ -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;
@@ -638,7 +639,7 @@ static int probe_codec(struct hdac_bus *bus, int addr)mutex_unlock (&bus->cmd_mutex);if (res ==-1 )return -EIO ; -dev_dbg (bus->dev,"codec #%d probed OK\n" , addr); +dev_dbg (bus->dev,"codec #%d probed OK: %x\n" , addr, res);return snd_hdac_ext_bus_device_init (bus, addr); }
@@ -777,6 +778,7 @@ static int skl_create(struct pci_dev *pci, {struct skl *skl;struct hdac_bus *bus; +struct hda_bus *hbus;int err;
@@ -792,6 +794,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 ;
@@ -799,6 +802,11 @@ static int skl_create(struct pci_dev *pci,INIT_WORK (&skl->probe_work, skl_probe_work); bus->bdl_pos_adj =0 ; +mutex_init (&hbus->prepare_mutex); + hbus->pci = pci; + hbus->mixer_assigned =-1 ; + hbus->modelname ="sklbus" ; + *rskl = skl;return 0 ;
sound/soc/intel/skylake/skl.h +7 -3
@@ -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
@@ -67,7 +68,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 */
@@ -101,8 +102,11 @@ struct skl {struct snd_soc_acpi_mach *mach; }; -#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
PATCH v2 6/10 ALSA: hda - split snd_hda_codec_new function
In reply to Rakesh UghrejaSplit snd_hda_codec_new into two separate functions. snd_hda_codec_device_init allocates memory and registers with bus. snd_hda_codec_device_new initialializes the fields and performs snd_device_new. This enables reuse of legacy HDA codec drivers as ASoC codec drivers.
In addition mark some functions with EXPORT_SYMBOL_GPL so that it can be called by ASoC wrapper around the legacy HDA driver (hdac_hda).
--- sound/pci/hda/hda_codec.c | 68 +++++++++++++++++++++++++++++++++++------------ sound/pci/hda/hda_codec.h | 2 ++ 2 files changed, 53 insertions(+), 17 deletions(-)
sound/pci/hda/hda_codec.c +51 -17
@@ -856,6 +856,39 @@ static void snd_hda_codec_dev_release(struct device *dev)kfree (codec); } +#define DEV_NAME_LEN 31 + +static int snd_hda_codec_device_init (struct hda_bus *bus,struct snd_card *card, +unsigned int codec_addr,struct hda_codec **codecp) +{ +char name[DEV_NAME_LEN ]; +struct hda_codec *codec; +int err; + +dev_dbg (card->dev,"%s: entry\n" , __func__); + +if (snd_BUG_ON (!bus)) +return -EINVAL ; +if (snd_BUG_ON (codec_addr >HDA_MAX_CODEC_ADDRESS )) +return -EINVAL ; + + codec =kzalloc (sizeof (*codec),GFP_KERNEL ); +if (!codec) +return -ENOMEM ; + +sprintf (name,"hdaudioC%dD%d" , card->number, codec_addr); + err =snd_hdac_device_init (&codec->core, &bus->core, name, codec_addr); +if (err <0 ) { +kfree (codec); +return err; + } + + codec->core.type =HDA_DEV_LEGACY ; + *codecp = codec; + +return err; +} +/** * snd_hda_codec_new - create a HDA codec * @bus: the bus to assign
@@ -867,7 +900,19 @@ static void snd_hda_codec_dev_release(struct device *dev)int snd_hda_codec_new (struct hda_bus *bus,struct snd_card *card,unsigned int codec_addr,struct hda_codec **codecp) { -struct hda_codec *codec; +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); +} +EXPORT_SYMBOL_GPL (snd_hda_codec_new); + +int snd_hda_codec_device_new (struct hda_bus *bus,struct snd_card *card, +unsigned int codec_addr,struct hda_codec *codec) +{char component[31 ];hda_nid_t fg;int err;
@@ -877,25 +922,14 @@ int snd_hda_codec_new(struct hda_bus *bus, struct snd_card *card, .dev_free = snd_hda_codec_dev_free, }; +dev_dbg (card->dev,"%s: entry\n" , __func__); +if (snd_BUG_ON (!bus))return -EINVAL ;if (snd_BUG_ON (codec_addr >HDA_MAX_CODEC_ADDRESS ))return -EINVAL ; - 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.dev.release = snd_hda_codec_dev_release; - codec->core.type =HDA_DEV_LEGACY ; codec->core.exec_verb = codec_exec_verb; codec->bus = bus;
@@ -955,15 +989,13 @@ int snd_hda_codec_new(struct hda_bus *bus, struct snd_card *card,if (err <0 ) goto error; -if (codecp) - *codecp = codec;return 0 ; error:put_device (hda_codec_dev (codec));return err; } -EXPORT_SYMBOL_GPL (snd_hda_codec_new); +EXPORT_SYMBOL_GPL (snd_hda_codec_device_new);/** * snd_hda_codec_update_widgets - Refresh widget caps and pin defaults
@@ -2979,6 +3011,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
@@ -3184,6 +3217,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)
sound/pci/hda/hda_codec.h +2 -0
@@ -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_codec_device_new (struct hda_bus *bus,struct snd_card *card, +unsigned int codec_addr,struct hda_codec *codec);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
PATCH v2 7/10 ALSA: hdac: remove memory allocation from snd_hdac_ext_bus_device_init
In reply to Rakesh UghrejaRemove memory allocation within snd_hdac_ext_bus_device_init, to make its behaviour identical to snd_hdac_bus_device_init. So that caller can allocate the parent data structure containing hdac_device. This API change helps in reusing the legacy HDA codec drivers with ASoC platform drivers.
--- include/sound/hdaudio_ext.h | 3 ++- sound/hda/ext/hdac_ext_bus.c | 8 ++------ sound/soc/intel/skylake/skl.c | 8 +++++++- 3 files changed, 11 insertions(+), 8 deletions(-)
include/sound/hdaudio_ext.h +2 -1
@@ -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 -6
@@ -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);
sound/soc/intel/skylake/skl.c +7 -1
@@ -632,6 +632,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);
@@ -641,7 +643,11 @@ static int probe_codec(struct hdac_bus *bus, int addr)return -EIO ;dev_dbg (bus->dev,"codec #%d probed OK: %x\n" , addr, res); -return snd_hdac_ext_bus_device_init (bus, addr); + 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 */
Signature · 1 line
2.7.4
PATCH v2 8/10 ALSA: hdac: add extended ops in the hdac_bus
In reply to Rakesh UghrejaAdd extended ops in the hdac_bus to allow calling the ASoC HDAC library ops to reuse the legacy HDA codec drivers with ASoC framework. Extended ops are used by the legacy codec drivers to call into hdac_hda library, in the subsequent patches..
--- include/sound/hdaudio.h | 9 +++++++++ include/sound/hdaudio_ext.h | 3 ++- sound/hda/ext/hdac_ext_bus.c | 4 +++- sound/soc/intel/skylake/skl.c | 2 +- 4 files changed, 15 insertions(+), 3 deletions(-)
include/sound/hdaudio.h +9 -0
@@ -214,6 +214,14 @@ struct hdac_bus_ops { };/* +* ops used for ASoC HDA codec drivers +*/ +struct hdac_ext_bus_ops { +int (*hdev_attach)(struct hdac_device *hdev); +int (*hdev_detach)(struct hdac_device *hdev); +}; + +/* * Lowlevel I/O operators */ struct hdac_io_ops {
@@ -268,6 +276,7 @@ struct hdac_bus {struct device *dev;const struct hdac_bus_ops *ops;const struct hdac_io_ops *io_ops; +const struct hdac_ext_bus_ops *ext_ops;/* h/w resources */ unsigned long addr;
include/sound/hdaudio_ext.h +2 -1
@@ -6,7 +6,8 @@int snd_hdac_ext_bus_init (struct hdac_bus *bus,struct device *dev,const struct hdac_bus_ops *ops, -const struct hdac_io_ops *io_ops); +const struct hdac_io_ops *io_ops, +const struct hdac_ext_bus_ops *ext_ops);void snd_hdac_ext_bus_exit (struct hdac_bus *bus); int snd_hdac_ext_bus_device_init(struct hdac_bus *bus, int addr,
sound/hda/ext/hdac_ext_bus.c +3 -1
@@ -89,7 +89,8 @@ static const struct hdac_io_ops hdac_ext_default_io = {*/ int snd_hdac_ext_bus_init (struct hdac_bus *bus,struct device *dev,const struct hdac_bus_ops *ops, -const struct hdac_io_ops *io_ops) +const struct hdac_io_ops *io_ops, +const struct hdac_ext_bus_ops *ext_ops) {int ret;static int idx;
@@ -102,6 +103,7 @@ int snd_hdac_ext_bus_init(struct hdac_bus *bus, struct device *dev,if (ret <0 )return ret; + bus->ext_ops = ext_ops;INIT_LIST_HEAD (&bus->hlink_list); bus->idx = idx++;
sound/soc/intel/skylake/skl.c +1 -1
@@ -802,7 +802,7 @@ static int skl_create(struct pci_dev *pci, hbus =skl_to_hbus (skl); bus =skl_to_bus (skl); -snd_hdac_ext_bus_init (bus, &pci->dev, &bus_core_ops, io_ops); +snd_hdac_ext_bus_init (bus, &pci->dev, &bus_core_ops, io_ops,NULL ); bus->use_posbuf =1 ; skl->pci = pci;INIT_WORK (&skl->probe_work, skl_probe_work);
Signature · 1 line
2.7.4
PATCH v2 9/10 ASoC: hdac_hda: add asoc extension for legacy HDA codec drivers
In reply to Rakesh UghrejaThis patch adds a kernel module which is used by the legacy HDA codec drivers as library. This implements hdac_ext_bus_ops to enable the reuse of legacy HDA codec drivers with ASoC platform drivers.
--- sound/pci/hda/hda_bind.c | 12 ++ sound/soc/codecs/Kconfig | 5 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/hdac_hda.c | 464 ++++++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/hdac_hda.h | 23 +++ 5 files changed, 506 insertions(+) create mode 100644 sound/soc/codecs/hdac_hda.c create mode 100644 sound/soc/codecs/hdac_hda.h
sound/pci/hda/hda_bind.c +12 -0
@@ -81,6 +81,12 @@ static int hda_codec_driver_probe(struct device *dev)hda_codec_patch_t patch;int err; +if (codec->bus->core.ext_ops) { +if (WARN_ON (!codec->bus->core.ext_ops->hdev_attach)) +return -EINVAL ; +return codec->bus->core.ext_ops->hdev_attach (&codec->core); + } +if (WARN_ON (!codec->preset))return -EINVAL ;
@@ -134,6 +140,12 @@ static int hda_codec_driver_remove(struct device *dev) {struct hda_codec *codec =dev_to_hda_codec (dev); +if (codec->bus->core.ext_ops) { +if (WARN_ON (!codec->bus->core.ext_ops->hdev_detach)) +return -EINVAL ; +return codec->bus->core.ext_ops->hdev_detach (&codec->core); + } +if (codec->patch_ops.free) codec->patch_ops.free (codec);snd_hda_codec_cleanup_for_unbind (codec);
sound/soc/codecs/Kconfig +5 -0
@@ -82,6 +82,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
@@ -607,6 +608,10 @@ config SND_SOC_HDAC_HDMI select SND_PCM_ELD select HDMI +config SND_SOC_HDAC_HDA + tristate + select SND_HDA + config SND_SOC_ICS43432 tristate
sound/soc/codecs/Makefile +2 -0
@@ -77,6 +77,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
@@ -327,6 +328,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 +464 -0
464 lines not on this page · raw message
sound/soc/codecs/hdac_hda.h new file +23 -0
@@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright(c) 2015-17 Intel Corporation. + +#ifndef __HDAC_HDA_H__ +#define __HDAC_HDA_H__ + +struct hdac_hda_pcm { +int stream_tag[2 ]; +}; + +struct hdac_hda_priv { +struct hda_codec codec; +struct snd_soc_codec *scodec; +struct hdac_hda_pcm pcm[2 ]; +}; + +#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) + +struct hdac_ext_bus_ops *snd_soc_hdac_hda_get_ops (void ); + +#endif /* __HDAC_HDA_H__ */
Signature · 1 line
2.7.4
PATCH v2 10/10 ASoC: Intel: Boards: add support for HDA codecs
In reply to Rakesh UghrejaAdd 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 | 24 ++++++++++++++ sound/soc/intel/boards/skl_hda_dsp_common.h | 2 +- sound/soc/intel/boards/skl_hda_dsp_generic.c | 39 +++++++++++++++++++++++ sound/soc/intel/skylake/skl.c | 47 +++++++++++++++++++++++++--- 5 files changed, 108 insertions(+), 5 deletions(-)
sound/soc/intel/boards/Kconfig +1 -0
@@ -283,6 +283,7 @@ config SND_SOC_INTEL_KBL_DA7219_MAX98357A_MACH config SND_SOC_INTEL_SKL_HDA_DSP_GENERIC_MACH tristate "SKL/KBL/BXT/APL with HDA Codecs" select SND_SOC_HDAC_HDMI + select SND_SOC_HDAC_HDA help This adds support for ASoC machine driver for Intel platforms SKL/KBL/BXT/APL with iDisp, HDA audio codecs.
sound/soc/intel/boards/skl_hda_dsp_common.c +24 -0
@@ -73,6 +73,30 @@ struct snd_soc_dai_link skl_hda_be_dai_links[HDA_DSP_MAX_BE_DAI_LINKS] = { .dpcm_playback = 1, .no_pcm = 1, }, + { + .name = "Analog Playback and Capture", + .id = 4, + .cpu_dai_name = "Analog CPU DAI", + .codec_name = "ehdaudio0D0", + .codec_dai_name = "Analog Codec DAI", + .platform_name = "0000:00:1f.3", + .dpcm_playback = 1, + .dpcm_capture = 1, + .init = NULL, + .no_pcm = 1, + }, + { + .name = "Digital Playback and Capture", + .id = 5, + .cpu_dai_name = "Digital CPU DAI", + .codec_name = "ehdaudio0D0", + .codec_dai_name = "Digital Codec DAI", + .platform_name = "0000:00:1f.3", + .dpcm_playback = 1, + .dpcm_capture = 1, + .init = NULL, + .no_pcm = 1, + }, };int skl_hda_hdmi_jack_init (struct snd_soc_card *card)
sound/soc/intel/boards/skl_hda_dsp_common.h +1 -1
@@ -13,7 +13,7 @@#include <sound/core.h> #include <sound/jack.h> -#define HDA_DSP_MAX_BE_DAI_LINKS 3 +#define HDA_DSP_MAX_BE_DAI_LINKS 5struct skl_hda_hdmi_pcm {struct list_head head;
sound/soc/intel/boards/skl_hda_dsp_generic.c +39 -0
@@ -16,6 +16,16 @@#include "../skylake/skl.h" #include "skl_hda_dsp_common.h" + +static const struct snd_soc_dapm_widget skl_hda_widgets[] = { +SND_SOC_DAPM_HP ("Analog Out" ,NULL ), +SND_SOC_DAPM_MIC ("Analog In" ,NULL ), +SND_SOC_DAPM_HP ("Alt Analog Out" ,NULL ), +SND_SOC_DAPM_MIC ("Alt Analog In" ,NULL ), +SND_SOC_DAPM_SPK ("Digital Out" ,NULL ), +SND_SOC_DAPM_MIC ("Digital In" ,NULL ), +}; +static const struct snd_soc_dapm_route skl_hda_map[] = { {"hifi3" ,NULL ,"iDisp3 Tx" },
@@ -24,6 +34,29 @@ static const struct snd_soc_dapm_route skl_hda_map[] = { { "iDisp2 Tx", NULL, "iDisp2_out"}, { "hifi1", NULL, "iDisp1 Tx"}, { "iDisp1 Tx", NULL, "iDisp1_out"}, + + { "Analog Out", NULL, "Codec Output Pin1" }, + { "Digital Out", NULL, "Codec Output Pin2" }, + { "Alt Analog Out", NULL, "Codec Output Pin3" }, + + { "Codec Input Pin1", NULL, "Analog In" }, + { "Codec Input Pin2", NULL, "Digital In" }, + { "Codec Input Pin3", NULL, "Alt Analog In" }, + +/* CODEC BE connections */ + { "Analog Codec Playback", NULL, "Analog CPU Playback" }, + { "Analog CPU Playback", NULL, "codec0_out" }, + { "Digital Codec Playback", NULL, "Digital CPU Playback" }, + { "Digital CPU Playback", NULL, "codec1_out" }, + { "Alt Analog Codec Playback", NULL, "Alt Analog CPU Playback" }, + { "Alt Analog CPU Playback", NULL, "codec2_out" }, + + { "codec0_in", NULL, "Analog CPU Capture" }, + { "Analog CPU Capture", NULL, "Analog Codec Capture" }, + { "codec1_in", NULL, "Digital CPU Capture" }, + { "Digital CPU Capture", NULL, "Digital Codec Capture" }, + { "codec2_in", NULL, "Alt Analog CPU Capture" }, + { "Alt Analog CPU Capture", NULL, "Alt Analog Codec Capture" }, };static int skl_hda_card_late_probe (struct snd_soc_card *card)
@@ -52,6 +85,7 @@ static struct snd_soc_card hda_soc_card = { .name = "skl_hda_card", .owner = THIS_MODULE, .dai_link = skl_hda_be_dai_links, + .dapm_widgets = skl_hda_widgets, .dapm_routes = skl_hda_map, .add_dai_link = skl_hda_add_dai_link, .fully_routed = true,
@@ -75,6 +109,11 @@ static int skl_hda_fill_card_info(struct skl_machine_pdata *pdata)if (codec_count ==1 && pdata->codec_mask &IDISP_CODEC_MASK ) { num_links =IDISP_DAI_COUNT ; num_route =IDISP_ROUTE_COUNT ; + }else if (codec_count ==2 && codec_mask &IDISP_CODEC_MASK ) { + num_links =ARRAY_SIZE (skl_hda_be_dai_links); + num_route =ARRAY_SIZE (skl_hda_map), + card->dapm_widgets = skl_hda_widgets; + card->num_dapm_widgets =ARRAY_SIZE (skl_hda_widgets); }else {return -EINVAL ; }
sound/soc/intel/skylake/skl.c +43 -4
86 lines not on this page · raw message
Signature · 1 line
2.7.4