adapt SOF to use snd-hda-codec-hdmi
Subsystems (4)
Kai Vehmanen
maintainerv3 cover adapt SOF to use snd-hda-codec-hdmi
Hi all,
here's the third round for this series that adapts SOF to use snd-hda-codec-hdmi (patch_hdmi.c) codec driver instead of hdac_hdmi (soc/codecs/hdac_hdmi.c). The primary goal is to unify the HDMI codec implementation between DSP and non-DSP HDA configurations, offer same interface to user-space and reduce maintenance load for all.
This is now first series without the RFC tag. The series has all machine drivers converted that are directly impacted.
v3 changes:
- Merged two mst_no_extra_pcms patches (Takashi's feedback).
- Use mach_params instead of module name lookups to determine which codec driver is used at runtime (Pierre's feedback).
- Extended machine driver support to four more drivers. This includes now all machine drivers which are used with SOF and which support HDMI audio. With this patchset, the machine drivers continue to work with both SOF and SST DSP drivers, and can be configured to use hdac-hdmi also with SOF (via kernel module parameter -> this is for distros to provide backwards compatibility for UCM files).
- Various smaller cleanups across the patchset.
Feature and testing info:
- Tested on multiple Intel platforms supported by SOF.
- Tested with ALSA console tools as well as with Pulseaudio.
- requires Pulseaudio 12.x or newer, see
https://lists.freedesktop.org/archives/pulseaudio-discuss/2019-August/031358.html
- HDMI, DP, DP-MST with multi-monitor use-scenarios work ok.
- New feature for SOF: ELD /proc fs works just like in DSP-less mode.
- New feature for SOF: jack detection works out-of-the-box with Pulseaudio (no need for card specific UCM for HDMI)
Kai Vehmanen (10):
ALSA: hda/hdmi - implement mst_no_extra_pcms flag
ALSA: hda/hdmi - allow control creation without a linked pcm
ASoC: hdac_hda: add support for HDMI/DP as a HDA codec
ASoC: SOF: Intel: add support for snd-hda-codec-hdmi
ASoC: Intel: skl-hda-dsp-generic: use snd-hda-codec-hdmi
ASoC: Intel: skl-hda-dsp-generic: fix include guard name
ASoC: Intel: bxt-da7219-max98357a: common hdmi codec support
ASoC: Intel: glk_rt5682_max98357a: common hdmi codec support
ASoC: intel: sof_rt5682: common hdmi codec support
ASoC: Intel: bxt_rt298: common hdmi codec support
include/sound/hda_codec.h | 1 + include/sound/soc-acpi.h | 2 + sound/pci/hda/patch_hdmi.c | 23 +++-- sound/soc/codecs/hdac_hda.c | 95 ++++++++++++++++--- sound/soc/codecs/hdac_hda.h | 12 ++- sound/soc/intel/boards/bxt_da7219_max98357a.c | 11 +++ sound/soc/intel/boards/bxt_rt298.c | 11 +++ sound/soc/intel/boards/glk_rt5682_max98357a.c | 11 +++ sound/soc/intel/boards/hda_dsp_common.h | 87 +++++++++++++++++ sound/soc/intel/boards/skl_hda_dsp_common.c | 10 +- sound/soc/intel/boards/skl_hda_dsp_common.h | 27 +++++- sound/soc/intel/boards/skl_hda_dsp_generic.c | 1 + sound/soc/intel/boards/sof_rt5682.c | 11 +++ sound/soc/sof/intel/Kconfig | 10 ++ sound/soc/sof/intel/hda-codec.c | 19 +++- sound/soc/sof/intel/hda.c | 6 ++ sound/soc/sof/intel/hda.h | 6 +- 17 files changed, 315 insertions(+), 28 deletions(-) create mode 100644 sound/soc/intel/boards/hda_dsp_common.h
Signature · 6 lines
2.17.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Kai Vehmanen
maintainerPATCH v3 1/10 ALSA: hda/hdmi - implement mst_no_extra_pcms flag
When mst_no_extra_pcms flag is set, the codec should not use backup PCMs to handle DP-MST scenarios. Instead a simple 1:1 mapping is assumed between PCMs and converters.
--- include/sound/hda_codec.h | 1 + sound/pci/hda/patch_hdmi.c | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-)
include/sound/hda_codec.h +1 -0
@@ -254,6 +254,7 @@ struct hda_codec { unsigned int force_pin_prefix:1; /* Add location prefix */ unsigned int link_down_at_suspend:1; /* link down at runtime suspend */ unsigned int relaxed_resume:1; /* don't resume forcibly for jack */ + unsigned int mst_no_extra_pcms:1; /* no backup PCMs for DP-MST */#ifdef CONFIG_PM unsigned long power_on_acct;
sound/pci/hda/patch_hdmi.c +14 -5
@@ -2072,15 +2072,24 @@ static bool is_hdmi_pcm_attached(struct hdac_device *hdac, int pcm_idx)static int generic_hdmi_build_pcms (struct hda_codec *codec) {struct hdmi_spec *spec = codec->spec; -int idx; +int idx, pcm_num;/* * for non-mst mode, pcm number is the same as before -* for DP MST mode, pcm number is (nid number + dev_num - 1) -* dev_num is the device entry number in a pin -* +* for DP MST mode without extra PCM, pcm number is same +* for DP MST mode with extra PCMs, pcm number is +* (nid number + dev_num - 1) +* dev_num is the device entry number in a pin */ -for (idx =0 ; idx < spec->num_nids + spec->dev_num -1 ; idx++) { + +if (codec->mst_no_extra_pcms) + pcm_num = spec->num_nids; +else + pcm_num = spec->num_nids + spec->dev_num -1 ; + +codec_dbg (codec,"hdmi: pcm_num set to %d\n" , pcm_num); + +for (idx =0 ; idx < pcm_num; idx++) {struct hda_pcm *info;struct hda_pcm_stream *pstr;
Signature · 6 lines
2.17.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Re: [alsa-devel] [PATCH v3 01/10] ALSA: hda/hdmi - implement mst_no_extra_pcms flag
Quoted 3 lines · Kai Vehmanen
When
mst_no_extra_pcmsflag is set, the codec should not use backup PCMs to handle DP-MST scenarios. Instead a simple 1:1 mapping is assumed between PCMs and converters.
mst_no_extra_pcms is not set, which makes it hard to review and get the picture of what this does.
Quoted 44 lines
Signed-off-by Kai Vehmanen <[email protected]>--- include/sound/hda_codec.h | 1 + sound/pci/hda/patch_hdmi.c | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-)include/sound/hda_codec.h +1
-0@@ -254,6 +254,7 @@ struct hda_codec { unsigned int force_pin_prefix:1; /* Add location prefix */ unsigned int link_down_at_suspend:1; /* link down at runtime suspend */ unsigned int relaxed_resume:1; /* don't resume forcibly for jack */ + unsigned int mst_no_extra_pcms:1; /* no backup PCMs for DP-MST */#ifdef CONFIG_PM unsigned long power_on_acct;sound/pci/hda/patch_hdmi.c +7
-5@@ -2072,15 +2072,24 @@ static bool is_hdmi_pcm_attached(struct hdac_device *hdac, int pcm_idx)static int generic_hdmi_build_pcms (struct hda_codec *codec) {struct hdmi_spec *spec = codec->spec; -int idx; +int idx, pcm_num;/* * for non-mst mode, pcm number is the same as before -* for DP MST mode, pcm number is (nid number + dev_num - 1) -* dev_num is the device entry number in a pin -* +* for DP MST mode without extra PCM, pcm number is same +* for DP MST mode with extra PCMs, pcm number is +* (nid number + dev_num - 1) +* dev_num is the device entry number in a pin */ -for (idx =0 ; idx < spec->num_nids + spec->dev_num -1 ; idx++) { + +if (codec->mst_no_extra_pcms)
sound/pci/hda/patch_hdmi.c static bool is_hdmi_pcm_attached(struct hdac_device *hdac, int pcm_idx) · line 2095
Quoted 10 lines
sound/pci/hda/patch_hdmi.c +7
-0+ pcm_num = spec->num_nids; + else + pcm_num = spec->num_nids + spec->dev_num -1 ; + +codec_dbg (codec,"hdmi: pcm_num set to %d\n" , pcm_num); + +for (idx =0 ; idx < pcm_num; idx++) {struct hda_pcm *info;struct hda_pcm_stream *pstr;
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Kai Vehmanen
maintainerRe: [alsa-devel] [PATCH v3 01/10] ALSA: hda/hdmi - implement mst_no_extra_pcms flag
Hey,
Quoted 9 lines · Pierre-Louis Bossart
Quoted 3 lines · Kai Vehmanen
When
mst_no_extra_pcmsflag is set, the codec should not use backup PCMs to handle DP-MST scenarios. Instead a simple 1:1 mapping is assumed between PCMs and converters.
mst_no_extra_pcmsis not set, which makes it hard to review and get the picture of what this does.
this flag is used in patch 3 of the series. I didn't want to combine the patches 1&3 as patch 3 is modifying sound/soc/codecs/hdac_hda.c.
Let me try to improve the commit message a bit to explain why this is needed. In short, if patch_hdmi.c creates virtual PCMs for routing purposes (current behaviour with snd_hda_intel in non-DSP mode), it will be impossible to match them to PCMs in ASoC topology. Thus to enable users like SOF (could be others), patch_hdmi.c needs to expose a mode where physical converters are mapped to a fixed set of PCMs (-> this is the mst_no_extra_pcms mode).
Br, Kai
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Kai Vehmanen
maintainerPATCH v3 2/10 ALSA: hda/hdmi - allow control creation without a linked pcm
In reply to Kai VehmanenFix the logic in generic_hdmi_build_controls() to identify unused hda_pcm entries by searching for SNDRV_PCM_INVALID_DEVICE. This matches with logic in snd_hda_codec_build_pcms().
--- sound/pci/hda/patch_hdmi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/pci/hda/patch_hdmi.c +3 -1
@@ -2183,11 +2183,13 @@ static int generic_hdmi_build_jack(struct hda_codec *codec, int pcm_idx)static int generic_hdmi_build_controls (struct hda_codec *codec) {struct hdmi_spec *spec = codec->spec; +struct hda_pcm *hda_pcm;int dev, err;int pin_idx, pcm_idx;for (pcm_idx =0 ; pcm_idx < spec->pcm_used; pcm_idx++) { -if (!get_pcm_rec (spec, pcm_idx)->pcm) { + hda_pcm =get_pcm_rec (spec, pcm_idx); +if (hda_pcm->device ==SNDRV_PCM_INVALID_DEVICE ) {/* no PCM: mark this for skipping permanently */ set_bit (pcm_idx, &spec->pcm_bitmap);continue ;
Signature · 6 lines
2.17.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Re: [alsa-devel] [PATCH v3 02/10] ALSA: hda/hdmi - allow control creation without a linked pcm
Quoted 15 lines · Kai Vehmanen
Fix the logic in
generic_hdmi_build_controls()to identify unusedhda_pcmentries by searching forSNDRV_PCM_INVALID_DEVICE. This matches with logic insnd_hda_codec_build_pcms().Signed-off-by Kai Vehmanen <[email protected]>--- sound/pci/hda/patch_hdmi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)sound/pci/hda/patch_hdmi.c +0
-0@@ -2183,11 +2183,13 @@ static int generic_hdmi_build_jack(struct hda_codec *codec, int pcm_idx)static int generic_hdmi_build_controls (struct hda_codec *codec)
sound/pci/hda/patch_hdmi.c static int generic_hdmi_build_jack(struct hda_codec *codec, int pcm_idx) · line 2192
Quoted 10 lines
sound/pci/hda/patch_hdmi.c +3
-1{struct hdmi_spec *spec = codec->spec; +struct hda_pcm *hda_pcm;int dev, err;int pin_idx, pcm_idx;for (pcm_idx =0 ; pcm_idx < spec->pcm_used; pcm_idx++) { -if (!get_pcm_rec (spec, pcm_idx)->pcm) { + hda_pcm =get_pcm_rec (spec, pcm_idx); +if (hda_pcm->device ==SNDRV_PCM_INVALID_DEVICE ) {
I find it hard to follow the logic.
Before this patch only device 0 would be considered NO_PCM
Not it's -1, so wondering if this is a fix unrelated to this series or if there is a dependency on follow-up patches?
#define SNDRV_PCM_INVALID_DEVICE (-1)
sound/pci/hda/patch_hdmi.c static int generic_hdmi_build_jack(struct hda_codec *codec, int pcm_idx) · line 2195
Quoted 4 lines
sound/pci/hda/patch_hdmi.c +0
-0/* no PCM: mark this for skipping permanently */ set_bit (pcm_idx, &spec->pcm_bitmap);continue ;
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Kai Vehmanen
maintainerRe: [alsa-devel] [PATCH v3 02/10] ALSA: hda/hdmi - allow control creation without a linked pcm
Hi,
Quoted 4 lines · Pierre-Louis Bossart
Quoted 3 lines · Kai Vehmanen
Fix the logic in
generic_hdmi_build_controls()to identify unusedhda_pcmentries by searching forSNDRV_PCM_INVALID_DEVICE. This matches with logic insnd_hda_codec_build_pcms().
[...]
Quoted 8 lines
sound/pci/hda/patch_hdmi.c static int generic_hdmi_build_jack(struct hda_codec *codec, int pcm_idx) · line 2192
Quoted 3 lines
sound/pci/hda/patch_hdmi.c +2
-1-if (!get_pcm_rec (spec, pcm_idx)->pcm) { + hda_pcm =get_pcm_rec (spec, pcm_idx); +if (hda_pcm->device ==SNDRV_PCM_INVALID_DEVICE ) {I find it hard to follow the logic.
Before this patch only device 0 would be consideredNO_PCMNot it's -1, so wondering if this is a fix unrelated to this series or if there is a dependency on follow-up patches?
the intent was to align with logic in hda_codec.c:snd_hda_codec_build_pcms() which is the common function to create the HDA driver PCM state. In that function:
» list_for_each_entry(cpcm, &codec->pcm_list_head, list) {
[...]
» » dev = get_empty_pcm_device(bus, cpcm->pcm_type);
» » if (dev < 0) {
» » » cpcm->device = SNDRV_PCM_INVALID_DEVICE;
» » » continue; /* no fatal error */
» » }... i.e. if no PCM is attached, it is marked withSNDRV_PCM_INVALID_DEVICE to cpcm->device.
The logic in patch_hdmi.c, which deduced the same information by looking at another field (cpcm>->pcm), seems wrong and thus the fix.
Now, this used to be critical for this patch series as well, but you are right that is no longer the case (I added passing of the PCM handle so we can reuse all the kcontrol code in patch_hdmi.c and with that this patch is no longer mandatory for SOF usage).
I retested the series without the patch and all seems fine, so let's simplify the series by dropping this.
Br, Kai
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Kai Vehmanen
maintainerPATCH v3 3/10 ASoC: hdac_hda: add support for HDMI/DP as a HDA codec
In reply to Kai VehmanenHandle all HDA codecs using same logic, including HDMI/DP.
Call to snd_hda_codec_build_controls() is delayed for HDMI/DP HDA devices. This is needed to discover the PCM device numbers as defined in topology.
--- sound/soc/codecs/hdac_hda.c | 95 ++++++++++++++++++++++++++++++++----- sound/soc/codecs/hdac_hda.h | 12 ++++- 2 files changed, 94 insertions(+), 13 deletions(-)
sound/soc/codecs/hdac_hda.c +83 -12
@@ -16,11 +16,8 @@#include <sound/hdaudio_ext.h> #include <sound/hda_codec.h> #include <sound/hda_register.h> -#include "hdac_hda.h" -#define HDAC_ANALOG_DAI_ID 0 -#define HDAC_DIGITAL_DAI_ID 1 -#define HDAC_ALT_ANALOG_DAI_ID 2 +#include "hdac_hda.h" #define STUB_FORMATS (SNDRV_PCM_FMTBIT_S8 | \ SNDRV_PCM_FMTBIT_U8 | \
@@ -121,7 +118,46 @@ static struct snd_soc_dai_driver hdac_hda_dais[] = { .formats = STUB_FORMATS, .sig_bits = 24, }, -} +}, +{ + .id = HDAC_HDMI_0_DAI_ID, + .name = "intel-hdmi-hifi1", + .ops = &hdac_hda_dai_ops, + .playback = { + .stream_name = "hifi1", + .channels_min = 1, + .channels_max = 16, + .rates = SNDRV_PCM_RATE_8000_192000, + .formats = STUB_FORMATS, + .sig_bits = 24, + }, +}, +{ + .id = HDAC_HDMI_1_DAI_ID, + .name = "intel-hdmi-hifi2", + .ops = &hdac_hda_dai_ops, + .playback = { + .stream_name = "hifi2", + .channels_min = 1, + .channels_max = 16, + .rates = SNDRV_PCM_RATE_8000_192000, + .formats = STUB_FORMATS, + .sig_bits = 24, + }, +}, +{ + .id = HDAC_HDMI_2_DAI_ID, + .name = "intel-hdmi-hifi3", + .ops = &hdac_hda_dai_ops, + .playback = { + .stream_name = "hifi3", + .channels_min = 1, + .channels_max = 16, + .rates = SNDRV_PCM_RATE_8000_192000, + .formats = STUB_FORMATS, + .sig_bits = 24, + }, +}, };
@@ -135,10 +171,11 @@ static int hdac_hda_dai_set_tdm_slot(struct snd_soc_dai *dai, hda_pvt =snd_soc_component_get_drvdata (component); pcm = &hda_pvt->pcm[dai->id]; +if (tx_mask) - pcm[dai->id].stream_tag[SNDRV_PCM_STREAM_PLAYBACK ] = tx_mask; + pcm->stream_tag[SNDRV_PCM_STREAM_PLAYBACK ] = tx_mask;else - pcm[dai->id].stream_tag[SNDRV_PCM_STREAM_CAPTURE ] = rx_mask; + pcm->stream_tag[SNDRV_PCM_STREAM_CAPTURE ] = rx_mask;return 0 ; }
@@ -278,6 +315,12 @@ static struct hda_pcm *snd_soc_find_pcm_from_dai(struct hdac_hda_priv *hda_pvt,struct hda_pcm *cpcm;const char *pcm_name; +/* +* map DAI ID to the closest matching PCM name, using the naming +* scheme used by hda-codec snd_hda_gen_build_pcms() and for +* HDMI in hda_codec patch_hdmi.c) +*/ +switch (dai->id) {case HDAC_ANALOG_DAI_ID : pcm_name ="Analog" ;
@@ -288,13 +331,22 @@ static struct hda_pcm *snd_soc_find_pcm_from_dai(struct hdac_hda_priv *hda_pvt,case HDAC_ALT_ANALOG_DAI_ID : pcm_name ="Alt Analog" ;break ; +case HDAC_HDMI_0_DAI_ID : + pcm_name ="HDMI 0" ; +break ; +case HDAC_HDMI_1_DAI_ID : + pcm_name ="HDMI 1" ; +break ; +case HDAC_HDMI_2_DAI_ID : + pcm_name ="HDMI 2" ; +break ;default :dev_err (&hcodec->core.dev,"invalid dai id %d\n" , dai->id);return NULL ; }list_for_each_entry (cpcm, &hcodec->pcm_list_head, list) { -if (strpbrk (cpcm->name, pcm_name)) +if (strstr (cpcm->name, pcm_name))return cpcm; }
@@ -302,6 +354,18 @@ static struct hda_pcm *snd_soc_find_pcm_from_dai(struct hdac_hda_priv *hda_pvt,return NULL ; } +static bool is_hdmi_codec (struct hda_codec *hcodec) +{ +struct hda_pcm *cpcm; + +list_for_each_entry (cpcm, &hcodec->pcm_list_head, list) { +if (cpcm->pcm_type ==HDA_PCM_TYPE_HDMI ) +return true; + } + +return false; +} +static int hdac_hda_codec_probe (struct snd_soc_component *component) { struct hdac_hda_priv *hda_pvt =
@@ -366,16 +430,23 @@ static int hdac_hda_codec_probe(struct snd_soc_component *component)dev_dbg (&hdev->dev,"no patch file found\n" ); } +/* configure codec for 1:1 PCM:DAI mapping */ + hcodec->mst_no_extra_pcms =1 ; + ret =snd_hda_codec_parse_pcms (hcodec);if (ret <0 ) {dev_err (&hdev->dev,"unable to map pcms to dai %d\n" , ret); goto error; } - ret =snd_hda_codec_build_controls (hcodec); -if (ret <0 ) { -dev_err (&hdev->dev,"unable to create controls %d\n" , ret); - goto error; +/* HDMI controls need to be created in machine drivers */ +if (!is_hdmi_codec (hcodec)) { + ret =snd_hda_codec_build_controls (hcodec); +if (ret <0 ) { +dev_err (&hdev->dev,"unable to create controls %d\n" , + ret); + goto error; + } } hcodec->core.lazy_cache = true;
sound/soc/codecs/hdac_hda.h +11 -1
@@ -6,6 +6,16 @@ #ifndef __HDAC_HDA_H__ #define __HDAC_HDA_H__ +enum { + HDAC_ANALOG_DAI_ID = 0, + HDAC_DIGITAL_DAI_ID, + HDAC_ALT_ANALOG_DAI_ID, + HDAC_HDMI_0_DAI_ID, + HDAC_HDMI_1_DAI_ID, + HDAC_HDMI_2_DAI_ID, + HDAC_LAST_DAI_ID = HDAC_HDMI_2_DAI_ID, +}; + struct hdac_hda_pcm { int stream_tag[2]; unsigned int format_val[2];
@@ -13,7 +23,7 @@ struct hdac_hda_pcm {struct hdac_hda_priv {struct hda_codec codec; -struct hdac_hda_pcm pcm[2 ]; +struct hdac_hda_pcm pcm[HDAC_LAST_DAI_ID ]; };#define hdac_to_hda_priv (_hdac) \
Signature · 6 lines
2.17.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Re: [alsa-devel] [PATCH v3 03/10] ASoC: hdac_hda: add support for HDMI/DP as a HDA codec
Quoted 33 lines · Kai Vehmanen
Handle all HDA codecs using same logic, including HDMI/DP.
Call to
snd_hda_codec_build_controls()is delayed for HDMI/DP HDA devices. This is needed to discover the PCM device numbers as defined in topology.Signed-off-by Kai Vehmanen <[email protected]>--- sound/soc/codecs/hdac_hda.c | 95 ++++++++++++++++++++++++++++++++----- sound/soc/codecs/hdac_hda.h | 12 ++++- 2 files changed, 94 insertions(+), 13 deletions(-)sound/soc/codecs/hdac_hda.c +1
-4@@ -16,11 +16,8 @@#include <sound/hdaudio_ext.h> #include <sound/hda_codec.h> #include <sound/hda_register.h> -#include "hdac_hda.h" -#define HDAC_ANALOG_DAI_ID 0 -#define HDAC_DIGITAL_DAI_ID 1 -#define HDAC_ALT_ANALOG_DAI_ID 2 +#include "hdac_hda.h" #define STUB_FORMATS (SNDRV_PCM_FMTBIT_S8 | \ SNDRV_PCM_FMTBIT_U8 | \@@ -121,7 +118,46 @@ static struct snd_soc_dai_driver hdac_hda_dais[] = { .formats = STUB_FORMATS, .sig_bits = 24, },
sound/soc/codecs/hdac_hda.c static struct snd_soc_dai_driver hdac_hda_dais[] = { · line 129
Quoted 10 lines
sound/soc/codecs/hdac_hda.c +9
-1-} +}, +{ + .id = HDAC_HDMI_0_DAI_ID, + .name = "intel-hdmi-hifi1", + .ops = &hdac_hda_dai_ops, + .playback = { + .stream_name = "hifi1", + .channels_min = 1, + .channels_max = 16,
IIRC HDMI only deals with 8ch?
sound/soc/codecs/hdac_hda.c static struct snd_soc_dai_driver hdac_hda_dais[] = { · line 130
Quoted 1 line
sound/soc/codecs/hdac_hda.c +1
-0+ .rates = SNDRV_PCM_RATE_8000_192000,
And frequencies above 32kHz
Quoted 154 lines
sound/soc/codecs/hdac_hda.c +72
-7+ .formats = STUB_FORMATS, + .sig_bits = 24, + }, +}, +{ + .id = HDAC_HDMI_1_DAI_ID, + .name = "intel-hdmi-hifi2", + .ops = &hdac_hda_dai_ops, + .playback = { + .stream_name = "hifi2", + .channels_min = 1, + .channels_max = 16, + .rates = SNDRV_PCM_RATE_8000_192000, + .formats = STUB_FORMATS, + .sig_bits = 24, + }, +}, +{ + .id = HDAC_HDMI_2_DAI_ID, + .name = "intel-hdmi-hifi3", + .ops = &hdac_hda_dai_ops, + .playback = { + .stream_name = "hifi3", + .channels_min = 1, + .channels_max = 16, + .rates = SNDRV_PCM_RATE_8000_192000, + .formats = STUB_FORMATS, + .sig_bits = 24, + }, +}, };@@ -135,10 +171,11 @@ static int hdac_hda_dai_set_tdm_slot(struct snd_soc_dai *dai, hda_pvt =snd_soc_component_get_drvdata (component); pcm = &hda_pvt->pcm[dai->id]; +if (tx_mask) - pcm[dai->id].stream_tag[SNDRV_PCM_STREAM_PLAYBACK ] = tx_mask; + pcm->stream_tag[SNDRV_PCM_STREAM_PLAYBACK ] = tx_mask;else - pcm[dai->id].stream_tag[SNDRV_PCM_STREAM_CAPTURE ] = rx_mask; + pcm->stream_tag[SNDRV_PCM_STREAM_CAPTURE ] = rx_mask;return 0 ; }@@ -278,6 +315,12 @@ static struct hda_pcm *snd_soc_find_pcm_from_dai(struct hdac_hda_priv *hda_pvt,struct hda_pcm *cpcm;const char *pcm_name; +/* +* map DAI ID to the closest matching PCM name, using the naming +* scheme used by hda-codec snd_hda_gen_build_pcms() and for +* HDMI in hda_codec patch_hdmi.c) +*/ +switch (dai->id) {case HDAC_ANALOG_DAI_ID : pcm_name ="Analog" ;@@ -288,13 +331,22 @@ static struct hda_pcm *snd_soc_find_pcm_from_dai(struct hdac_hda_priv *hda_pvt,case HDAC_ALT_ANALOG_DAI_ID : pcm_name ="Alt Analog" ;break ; +case HDAC_HDMI_0_DAI_ID : + pcm_name ="HDMI 0" ; +break ; +case HDAC_HDMI_1_DAI_ID : + pcm_name ="HDMI 1" ; +break ; +case HDAC_HDMI_2_DAI_ID : + pcm_name ="HDMI 2" ; +break ;default :dev_err (&hcodec->core.dev,"invalid dai id %d\n" , dai->id);return NULL ; }list_for_each_entry (cpcm, &hcodec->pcm_list_head, list) { -if (strpbrk (cpcm->name, pcm_name)) +if (strstr (cpcm->name, pcm_name))return cpcm; }@@ -302,6 +354,18 @@ static struct hda_pcm *snd_soc_find_pcm_from_dai(struct hdac_hda_priv *hda_pvt,return NULL ; } +static bool is_hdmi_codec (struct hda_codec *hcodec) +{ +struct hda_pcm *cpcm; + +list_for_each_entry (cpcm, &hcodec->pcm_list_head, list) { +if (cpcm->pcm_type ==HDA_PCM_TYPE_HDMI ) +return true; + } + +return false; +} +static int hdac_hda_codec_probe (struct snd_soc_component *component) { struct hdac_hda_priv *hda_pvt =@@ -366,16 +430,23 @@ static int hdac_hda_codec_probe(struct snd_soc_component *component)dev_dbg (&hdev->dev,"no patch file found\n" ); } +/* configure codec for 1:1 PCM:DAI mapping */ + hcodec->mst_no_extra_pcms =1 ; + ret =snd_hda_codec_parse_pcms (hcodec);if (ret <0 ) {dev_err (&hdev->dev,"unable to map pcms to dai %d\n" , ret); goto error; } - ret =snd_hda_codec_build_controls (hcodec); -if (ret <0 ) { -dev_err (&hdev->dev,"unable to create controls %d\n" , ret); - goto error; +/* HDMI controls need to be created in machine drivers */ +if (!is_hdmi_codec (hcodec)) { + ret =snd_hda_codec_build_controls (hcodec); +if (ret <0 ) { +dev_err (&hdev->dev,"unable to create controls %d\n" , + ret); + goto error; + } } hcodec->core.lazy_cache = true;sound/soc/codecs/hdac_hda.h +10
-0@@ -6,6 +6,16 @@ #ifndef __HDAC_HDA_H__ #define __HDAC_HDA_H__ +enum { + HDAC_ANALOG_DAI_ID = 0, + HDAC_DIGITAL_DAI_ID, + HDAC_ALT_ANALOG_DAI_ID, + HDAC_HDMI_0_DAI_ID, + HDAC_HDMI_1_DAI_ID, + HDAC_HDMI_2_DAI_ID, + HDAC_LAST_DAI_ID = HDAC_HDMI_2_DAI_ID, +}; + struct hdac_hda_pcm { int stream_tag[2]; unsigned int format_val[2];
sound/soc/codecs/hdac_hda.h struct hdac_hda_pcm { · line 29
Quoted 8 lines
sound/soc/codecs/hdac_hda.h +1
-1@@ -13,7 +23,7 @@ struct hdac_hda_pcm {struct hdac_hda_priv {struct hda_codec codec; -struct hdac_hda_pcm pcm[2 ]; +struct hdac_hda_pcm pcm[HDAC_LAST_DAI_ID ]; };#define hdac_to_hda_priv (_hdac) \
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Kai Vehmanen
maintainerRe: [alsa-devel] [PATCH v3 03/10] ASoC: hdac_hda: add support for HDMI/DP as a HDA codec
Hi,
Quoted 10 lines · Pierre-Louis Bossart
sound/soc/codecs/hdac_hda.c static struct snd_soc_dai_driver hdac_hda_dais[] = { · line 129
Quoted 7 lines · Kai Vehmanen
sound/soc/codecs/hdac_hda.c +7
-0+ .id = HDAC_HDMI_0_DAI_ID, + .name = "intel-hdmi-hifi1", + .ops = &hdac_hda_dai_ops, + .playback = { + .stream_name = "hifi1", + .channels_min = 1, + .channels_max = 16,IIRC HDMI only deals with 8ch?
good catch. I had just copied these from hdac-hda.c. HDMI2.0 actually bumped this from 8 to 32 channels.
The constraints remain pretty wide and unsupported configurations will be caught at runtime in PCM open in patch_hdmi.c where requested channel count is compared to ELD information.
In comparison, the hdac-hdmi does query and add some static constraints with snd_hdac_query_supported_pcm(), but e.g. for channels it just sets min/max to 2.
Quoted 3 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ .rates = SNDRV_PCM_RATE_8000_192000,And frequencies above 32kHz
Ack, will fix. I'll probably keep the maximum at 192kHz. HDMI2.0/DP1.4 in fact bumped maximum to 1536kHz, but practically that is probably for 8x192kHz (or 32x48kHz) audio.
Br, Kai
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Kai Vehmanen
maintainerPATCH v3 4/10 ASoC: SOF: Intel: add support for snd-hda-codec-hdmi
In reply to Kai VehmanenAdd support to implement HDMI/DP audio by using the common snd-hda-codec-hdmi driver.
Change of codec driver affects user-space as the the two drivers expose different mixer controls. A new kernel module option "use_common_hdmi" is added to user-space to indicate which interface should be used. The default driver can be selected via a Kconfig option.
--- sound/soc/sof/intel/Kconfig | 10 ++++++++++ sound/soc/sof/intel/hda-codec.c | 19 +++++++++++++++---- sound/soc/sof/intel/hda.c | 6 ++++++ sound/soc/sof/intel/hda.h | 6 ++++-- 4 files changed, 35 insertions(+), 6 deletions(-)
sound/soc/sof/intel/Kconfig +10 -0
@@ -273,6 +273,16 @@ config SND_SOC_SOF_HDA_AUDIO_CODEC Say Y if you want to enable HDAudio codecs with SOF. If unsure select "N". +config SND_SOC_SOF_HDA_COMMON_HDMI_CODEC + bool "SOF common HDA HDMI codec driver" + depends on SND_SOC_SOF_HDA_LINK + depends on SND_HDA_CODEC_HDMI + help + This adds support for HDMI audio by using the common HDA + HDMI/DisplayPort codec driver. + Say Y if you want to use the common codec driver with SOF. + If unsure select "Y". + endif ## SND_SOC_SOF_HDA_COMMON config SND_SOC_SOF_HDA_LINK_BASELINE
sound/soc/sof/intel/hda-codec.c +15 -4
@@ -84,6 +84,8 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address) {#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC )struct hdac_hda_priv *hda_priv; +struct snd_soc_acpi_mach_params *mach_params =0 ; +struct snd_sof_pdata *pdata = sdev->pdata;#endif struct hda_bus *hbus =sof_to_hbus (sdev);struct hdac_device *hdev;
@@ -113,8 +115,16 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address)if (ret <0 )return ret; -/* use legacy bus only for HDA codecs, idisp uses ext bus */ -if ((resp &0xFFFF0000 ) !=IDISP_VID_INTEL ) { +if (pdata->machine) + mach_params = (struct snd_soc_acpi_mach_params *) + &pdata->machine->mach_params; + +/* +* if common HDMI codec driver is not used, codec load +* is skipped here and hdac_hdmi is used instead +*/ +if ((mach_params && mach_params->common_hdmi_codec_drv) || + (resp &0xFFFF0000 ) !=IDISP_VID_INTEL ) { hdev->type =HDA_DEV_LEGACY ;hda_codec_load_module (&hda_priv->codec); }
@@ -155,7 +165,8 @@ int hda_codec_probe_bus(struct snd_sof_dev *sdev) }EXPORT_SYMBOL (hda_codec_probe_bus); -#if IS_ENABLED (CONFIG_SND_SOC_HDAC_HDMI ) +#if IS_ENABLED (CONFIG_SND_HDA_CODEC_HDMI ) || \ +IS_ENABLED (CONFIG_SND_SOC_HDAC_HDMI )void hda_codec_i915_get (struct snd_sof_dev *sdev) {
@@ -204,6 +215,6 @@ int hda_codec_i915_exit(struct snd_sof_dev *sdev) }EXPORT_SYMBOL (hda_codec_i915_exit); -#endif /* CONFIG_SND_SOC_HDAC_HDMI */ +#endif MODULE_LICENSE ("Dual BSD/GPL" );
sound/soc/sof/intel/hda.c +6 -0
@@ -54,6 +54,11 @@ MODULE_PARM_DESC(use_msi, "SOF HDA use PCI MSI mode");static int hda_dmic_num =-1 ;module_param_named (dmic_num, hda_dmic_num, int,0444 );MODULE_PARM_DESC (dmic_num,"SOF HDA DMIC number" ); + +static bool hda_codec_use_common_hdmi = +IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_COMMON_HDMI_CODEC ); +module_param_named (use_common_hdmi, hda_codec_use_common_hdmi, bool,0444 ); +MODULE_PARM_DESC (use_common_hdmi,"SOF HDA use common HDMI codec driver" );#endif static const struct hda_dsp_msg_code hda_dsp_rom_msg[] = {
@@ -458,6 +463,7 @@ static int hda_init_caps(struct snd_sof_dev *sdev) &pdata->machine->mach_params; mach_params->codec_mask = bus->codec_mask; mach_params->platform =dev_name (sdev->dev); + mach_params->common_hdmi_codec_drv = hda_codec_use_common_hdmi; }/* create codec instances */
sound/soc/sof/intel/hda.h +4 -2
@@ -562,7 +562,9 @@ void hda_codec_jack_check(struct snd_sof_dev *sdev);#endif /* CONFIG_SND_SOC_SOF_HDA */ -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) &&IS_ENABLED (CONFIG_SND_SOC_HDAC_HDMI ) +#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) && \ + (IS_ENABLED (CONFIG_SND_HDA_CODEC_HDMI ) || \ +IS_ENABLED (CONFIG_SND_SOC_HDAC_HDMI ))void hda_codec_i915_get (struct snd_sof_dev *sdev);void hda_codec_i915_put (struct snd_sof_dev *sdev);
@@ -576,7 +578,7 @@ static inline void hda_codec_i915_put(struct snd_sof_dev *sdev) { }static inline int hda_codec_i915_init (struct snd_sof_dev *sdev) {return 0 ; }static inline int hda_codec_i915_exit (struct snd_sof_dev *sdev) {return 0 ; } -#endif /* CONFIG_SND_SOC_SOF_HDA && CONFIG_SND_SOC_HDAC_HDMI */ +#endif /* * Trace Control.
Signature · 6 lines
2.17.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Re: [alsa-devel] [PATCH v3 04/10] ASoC: SOF: Intel: add support for snd-hda-codec-hdmi
Quoted 59 lines · Kai Vehmanen
Add support to implement HDMI/DP audio by using the common snd-hda-codec-hdmi driver.
Change of codec driver affects user-space as the the two drivers expose different mixer controls. A new kernel module option "
use_common_hdmi" is added to user-space to indicate which interface should be used. The default driver can be selected via aKconfigoption.Signed-off-by Kai Vehmanen <[email protected]>--- sound/soc/sof/intel/Kconfig | 10 ++++++++++ sound/soc/sof/intel/hda-codec.c | 19 +++++++++++++++---- sound/soc/sof/intel/hda.c | 6 ++++++ sound/soc/sof/intel/hda.h | 6 ++++-- 4 files changed, 35 insertions(+), 6 deletions(-)sound/soc/sof/intel/Kconfig +10
-0@@ -273,6 +273,16 @@ config SND_SOC_SOF_HDA_AUDIO_CODEC Say Y if you want to enable HDAudio codecs with SOF. If unsure select "N". +config SND_SOC_SOF_HDA_COMMON_HDMI_CODEC + bool "SOF common HDA HDMI codec driver" + depends on SND_SOC_SOF_HDA_LINK + depends on SND_HDA_CODEC_HDMI + help + This adds support for HDMI audio by using the common HDA + HDMI/DisplayPort codec driver. + Say Y if you want to use the common codec driver with SOF. + If unsure select "Y". + endif ## SND_SOC_SOF_HDA_COMMON config SND_SOC_SOF_HDA_LINK_BASELINEsound/soc/sof/intel/hda-codec.c +4
-2@@ -84,6 +84,8 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address) {#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC )struct hdac_hda_priv *hda_priv; +struct snd_soc_acpi_mach_params *mach_params =0 ; +struct snd_sof_pdata *pdata = sdev->pdata;#endif struct hda_bus *hbus =sof_to_hbus (sdev);struct hdac_device *hdev;@@ -113,8 +115,16 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address)if (ret <0 )return ret; -/* use legacy bus only for HDA codecs, idisp uses ext bus */ -if ((resp &0xFFFF0000 ) !=IDISP_VID_INTEL ) { +if (pdata->machine) + mach_params = (struct snd_soc_acpi_mach_params *)
sound/soc/sof/intel/hda-codec.c static int hda_codec_probe(struct snd_sof_dev *sdev, int address) · line 129
Quoted 10 lines
sound/soc/sof/intel/hda-codec.c +8
-0+ &pdata->machine->mach_params; + +/* +* if common HDMI codec driver is not used, codec load +* is skipped here and hdac_hdmi is used instead +*/ +if ((mach_params && mach_params->common_hdmi_codec_drv) || + (resp &0xFFFF0000 ) !=IDISP_VID_INTEL ) { hdev->type =HDA_DEV_LEGACY ;hda_codec_load_module (&hda_priv->codec);
This part is might be problematic. For SoundWire stuff, I had to move all the machine detection part out of hda_init_caps() and at the end of hda_dsp_probe. It's not final since I am still trying to figure out what the earliest time I can power-up the SoundWire IP is, but it would help if you don't make strong assumptions on when mach_params is set. The fact that all this code is currently in hda_init_caps() is not really by design, more because of incremental code changes.
Quoted 60 lines
sound/soc/sof/intel/hda-codec.c +3
-2}@@ -155,7 +165,8 @@ int hda_codec_probe_bus(struct snd_sof_dev *sdev) }EXPORT_SYMBOL (hda_codec_probe_bus); -#if IS_ENABLED (CONFIG_SND_SOC_HDAC_HDMI ) +#if IS_ENABLED (CONFIG_SND_HDA_CODEC_HDMI ) || \ +IS_ENABLED (CONFIG_SND_SOC_HDAC_HDMI )void hda_codec_i915_get (struct snd_sof_dev *sdev) {@@ -204,6 +215,6 @@ int hda_codec_i915_exit(struct snd_sof_dev *sdev) }EXPORT_SYMBOL (hda_codec_i915_exit); -#endif /* CONFIG_SND_SOC_HDAC_HDMI */ +#endif MODULE_LICENSE ("Dual BSD/GPL" );sound/soc/sof/intel/hda.c +6
-0@@ -54,6 +54,11 @@ MODULE_PARM_DESC(use_msi, "SOF HDA use PCI MSI mode");static int hda_dmic_num =-1 ;module_param_named (dmic_num, hda_dmic_num, int,0444 );MODULE_PARM_DESC (dmic_num,"SOF HDA DMIC number" ); + +static bool hda_codec_use_common_hdmi = +IS_ENABLED (CONFIG_SND_SOC_SOF_HDA_COMMON_HDMI_CODEC ); +module_param_named (use_common_hdmi, hda_codec_use_common_hdmi, bool,0444 ); +MODULE_PARM_DESC (use_common_hdmi,"SOF HDA use common HDMI codec driver" );#endif static const struct hda_dsp_msg_code hda_dsp_rom_msg[] = {@@ -458,6 +463,7 @@ static int hda_init_caps(struct snd_sof_dev *sdev) &pdata->machine->mach_params; mach_params->codec_mask = bus->codec_mask; mach_params->platform =dev_name (sdev->dev); + mach_params->common_hdmi_codec_drv = hda_codec_use_common_hdmi; }/* create codec instances */ sound/soc/sof/intel/hda.h +3
-1@@ -562,7 +562,9 @@ void hda_codec_jack_check(struct snd_sof_dev *sdev);#endif /* CONFIG_SND_SOC_SOF_HDA */ -#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) &&IS_ENABLED (CONFIG_SND_SOC_HDAC_HDMI ) +#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA ) && \ + (IS_ENABLED (CONFIG_SND_HDA_CODEC_HDMI ) || \ +IS_ENABLED (CONFIG_SND_SOC_HDAC_HDMI ))void hda_codec_i915_get (struct snd_sof_dev *sdev);void hda_codec_i915_put (struct snd_sof_dev *sdev);
sound/soc/sof/intel/hda.h static inline void hda_codec_i915_put(struct snd_sof_dev *sdev) { } · line 584
Quoted 8 lines
sound/soc/sof/intel/hda.h +1
-1@@ -576,7 +578,7 @@ static inline void hda_codec_i915_put(struct snd_sof_dev *sdev) { }static inline int hda_codec_i915_init (struct snd_sof_dev *sdev) {return 0 ; }static inline int hda_codec_i915_exit (struct snd_sof_dev *sdev) {return 0 ; } -#endif /* CONFIG_SND_SOC_SOF_HDA && CONFIG_SND_SOC_HDAC_HDMI */ +#endif /* * Trace Control.
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Kai Vehmanen
maintainerRe: [alsa-devel] [PATCH v3 04/10] ASoC: SOF: Intel: add support for snd-hda-codec-hdmi
Hey,
Quoted 3 lines · Pierre-Louis Bossart
Quoted 3 lines
sound/soc/sof/intel/hda-codec.c +0
-0@@ -84,6 +84,8 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int
[...]
Quoted 9 lines
sound/soc/sof/intel/hda-codec.c static int hda_codec_probe(struct snd_sof_dev *sdev, int address) · line 129
Quoted 8 lines
sound/soc/sof/intel/hda-codec.c +6
-0+/* +* if common HDMI codec driver is not used, codec load +* is skipped here and hdac_hdmi is used instead +*/ +if ((mach_params && mach_params->common_hdmi_codec_drv) || + (resp &0xFFFF0000 ) !=IDISP_VID_INTEL ) { hdev->type =HDA_DEV_LEGACY ;hda_codec_load_module (&hda_priv->codec);
Quoted 7 lines
This part is might be problematic. For SoundWire stuff, I had to move all the machine detection part out of
hda_init_caps()and at the end ofhda_dsp_probe. It's not final since I am still trying to figure out what the earliest time I can power-up the SoundWire IP is, but it would help if you don't make strong assumptions on whenmach_paramsis set. The fact that all this code is currently inhda_init_caps()is not really by design, more because of incremental code changes.
hmm. Currently the settings part of 'common_hdmi_codec_drv' is in in init_caps, just before call to hda_codec_probe_bus() (which uses the flag). There are also other fields set there (like mach_params->codec_mask), so issues should apply to codec_mask passing as well. I.e. if functionality is moved out from init_caps, the call to bus probe should be moved as well.
Other options to pass the flag do not seem good. We don't want to add hw specific stuff like this to snd_sof_dev or hdac_bus (latter used to pass "codec_mask"). If this becomes an issue, maybe we just need an explicit parameter to hda_codec_probe_bus(), and/or move the module parameter directly to intel/hda-codec.c. Both are a bit ugly, but at least contained in the "sof/intel/" subfolder.
Br, Kai
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Re: [alsa-devel] [PATCH v3 04/10] ASoC: SOF: Intel: add support for snd-hda-codec-hdmi
Quoted 31 lines · Kai Vehmanen
Hey,
Quoted 3 lines · Pierre-Louis Bossart
Quoted 3 lines
sound/soc/sof/intel/hda-codec.c +0
-0@@ -84,6 +84,8 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int[...]
Quoted 9 lines
sound/soc/sof/intel/hda-codec.c static int hda_codec_probe(struct snd_sof_dev *sdev, int address) · line 129
Quoted 8 lines
sound/soc/sof/intel/hda-codec.c +6
-0+/* +* if common HDMI codec driver is not used, codec load +* is skipped here and hdac_hdmi is used instead +*/ +if ((mach_params && mach_params->common_hdmi_codec_drv) || + (resp &0xFFFF0000 ) !=IDISP_VID_INTEL ) { hdev->type =HDA_DEV_LEGACY ;hda_codec_load_module (&hda_priv->codec);Quoted 7 lines
This part is might be problematic. For SoundWire stuff, I had to move all the machine detection part out of
hda_init_caps()and at the end ofhda_dsp_probe. It's not final since I am still trying to figure out what the earliest time I can power-up the SoundWire IP is, but it would help if you don't make strong assumptions on whenmach_paramsis set. The fact that all this code is currently inhda_init_caps()is not really by design, more because of incremental code changes.hmm. Currently the settings part of '
common_hdmi_codec_drv' is in ininit_caps, just before call tohda_codec_probe_bus()(which uses the flag). There are also other fields set there (likemach_params->codec_mask), so issues should apply tocodec_maskpassing as well. I.e. if functionality is moved out frominit_caps, the call to bus probe should be moved as well.
Quoted 6 lines
Other options to pass the flag do not seem good. We don't want to add hw specific stuff like this to
snd_sof_devorhdac_bus(latter used to pass "codec_mask"). If this becomes an issue, maybe we just need an explicit parameter tohda_codec_probe_bus(), and/or move the module parameter directly tointel/hda-codec.c. Both are a bit ugly, but at least contained in the "sof/intel/" subfolder.
never mind, with the SoundWire plumbing rework we can do all the machine driver checks in hda_init_caps. I split the ACPI scan, driver probe and startup in 3 steps so we have more freedom. Before this rework I was constrained to detect the ACPI stuff only when the hardware was powered, which was after init_caps. In short don't worry about me/SoundWire.
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Kai Vehmanen
maintainerPATCH v3 5/10 ASoC: Intel: skl-hda-dsp-generic: use snd-hda-codec-hdmi
In reply to Kai VehmanenAdd support for using snd-hda-codec-hdmi driver for HDMI/DP instead of ASoC hdac-hdmi. This is aligned with how other HDA codecs are already handled.
When snd-hda-codec-hdmi is used, the PCM device numbers are parsed from card topology and passed to the codec driver. This needs to be done at runtime as topology changes may affect PCM device allocation.
--- include/sound/soc-acpi.h | 2 + sound/soc/intel/boards/hda_dsp_common.h | 87 ++++++++++++++++++++ sound/soc/intel/boards/skl_hda_dsp_common.c | 10 ++- sound/soc/intel/boards/skl_hda_dsp_common.h | 23 ++++++ sound/soc/intel/boards/skl_hda_dsp_generic.c | 1 + 5 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 sound/soc/intel/boards/hda_dsp_common.h
include/sound/soc-acpi.h +2 -0
@@ -60,12 +60,14 @@ static inline struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg)* @acpi_ipc_irq_index: used for BYT-CR detection * @platform: string used for HDaudio codec support * @codec_mask: used for HDAudio support +* @common_hdmi_codec_drv: use commom HDAudio HDMI codec driver */ struct snd_soc_acpi_mach_params {u32 acpi_ipc_irq_index;const char *platform;u32 codec_mask;u32 dmic_num; +bool common_hdmi_codec_drv; };/**
sound/soc/intel/boards/hda_dsp_common.h new file +87 -0
87 lines not on this page · raw message
sound/soc/intel/boards/skl_hda_dsp_common.c +9 -1
@@ -14,6 +14,9 @@#include "../../codecs/hdac_hdmi.h" #include "skl_hda_dsp_common.h" +#include <sound/hda_codec.h> +#include "../../codecs/hdac_hda.h" +#define NAME_SIZE 32int skl_hda_hdmi_add_pcm (struct snd_soc_card *card,int device)
@@ -136,14 +139,19 @@ int skl_hda_hdmi_jack_init(struct snd_soc_card *card)char jack_name[NAME_SIZE ];int err; +if (ctx->common_hdmi_codec_drv) +return skl_hda_hdmi_build_controls (card); +list_for_each_entry (pcm, &ctx->hdmi_pcm_list, head) { +if (!pcm) +continue ; + component = pcm->codec_dai->component;snprintf (jack_name,sizeof (jack_name),"HDMI/DP, pcm=%d Jack" , pcm->device); err =snd_soc_card_jack_new (card, jack_name,SND_JACK_AVOUT , &pcm->hdmi_jack,NULL ,0 ); -if (err)return err;
sound/soc/intel/boards/skl_hda_dsp_common.h +23 -0
@@ -14,6 +14,9 @@#include <linux/platform_device.h> #include <sound/core.h> #include <sound/jack.h> +#include <sound/hda_codec.h> +#include "../../codecs/hdac_hda.h" +#include "hda_dsp_common.h" #define HDA_DSP_MAX_BE_DAI_LINKS 7
@@ -29,10 +32,30 @@ struct skl_hda_private {int pcm_count;int dai_index;const char *platform_name; +bool common_hdmi_codec_drv; };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); +/* +* Search card topology and register HDMI PCM related controls +* to codec driver. +*/ +static inline int skl_hda_hdmi_build_controls (struct snd_soc_card *card) +{ +struct skl_hda_private *ctx =snd_soc_card_get_drvdata (card); +struct snd_soc_component *component; +struct skl_hda_hdmi_pcm *pcm; + + pcm = list_first_entry(&ctx->hdmi_pcm_list, struct skl_hda_hdmi_pcm, + head); + component = pcm->codec_dai->component; +if (!component) +return -EINVAL ; + +return hda_dsp_hdmi_build_controls (card, component); +} +#endif /* __SOUND_SOC_HDA_DSP_COMMON_H */
sound/soc/intel/boards/skl_hda_dsp_generic.c +1 -0
@@ -178,6 +178,7 @@ static int skl_hda_audio_probe(struct platform_device *pdev) ctx->pcm_count = hda_soc_card.num_links; ctx->dai_index =1 ;/* hdmi codec dai name starts from index 1 */ ctx->platform_name = mach->mach_params.platform; + ctx->common_hdmi_codec_drv = mach->mach_params.common_hdmi_codec_drv; hda_soc_card.dev = &pdev->dev;snd_soc_card_set_drvdata (&hda_soc_card, ctx);
Signature · 6 lines
2.17.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Re: [alsa-devel] [PATCH v3 05/10] ASoC: Intel: skl-hda-dsp-generic: use snd-hda-codec-hdmi
Quoted 25 lines · Kai Vehmanen
Add support for using snd-hda-codec-hdmi driver for HDMI/DP instead of ASoC hdac-hdmi. This is aligned with how other HDA codecs are already handled.
When snd-hda-codec-hdmi is used, the PCM device numbers are parsed from card topology and passed to the codec driver. This needs to be done at runtime as topology changes may affect PCM device allocation.
Signed-off-by Kai Vehmanen <[email protected]>--- include/sound/soc-acpi.h | 2 + sound/soc/intel/boards/hda_dsp_common.h | 87 ++++++++++++++++++++ sound/soc/intel/boards/skl_hda_dsp_common.c | 10 ++- sound/soc/intel/boards/skl_hda_dsp_common.h | 23 ++++++ sound/soc/intel/boards/skl_hda_dsp_generic.c | 1 + 5 files changed, 122 insertions(+), 1 deletion(-)create mode 100644
sound/soc/intel/boards/hda_dsp_common.hinclude/sound/soc-acpi.h +0
-0@@ -60,12 +60,14 @@ static inline struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg)* @acpi_ipc_irq_index: used for BYT-CR detection
include/sound/soc-acpi.h static inline struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg) · line 70
Quoted 10 lines
include/sound/soc-acpi.h +2
-0* @platform: string used for HDaudio codec support * @codec_mask: used for HDAudio support +* @common_hdmi_codec_drv: use commom HDAudio HDMI codec driver */ struct snd_soc_acpi_mach_params {u32 acpi_ipc_irq_index;const char *platform;u32 codec_mask;u32 dmic_num; +bool common_hdmi_codec_drv;
That change would need to be moved to a separate patch earlier to avoid breaking compilation of patch 4
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Kai Vehmanen
maintainerPATCH v3 6/10 ASoC: Intel: skl-hda-dsp-generic: fix include guard name
In reply to Kai VehmanenMatch the include guard define to actual filename. The source directory now has an actual hda_dsp_common.h header, so the old include guard may cause confusion.
--- sound/soc/intel/boards/skl_hda_dsp_common.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/intel/boards/skl_hda_dsp_common.h +2 -2
@@ -8,8 +8,8 @@* platforms with HDA Codecs. */ -#ifndef __SOUND_SOC_HDA_DSP_COMMON_H -#define __SOUND_SOC_HDA_DSP_COMMON_H +#ifndef __SKL_HDA_DSP_COMMON_H +#define __SKL_HDA_DSP_COMMON_H#include <linux/module.h> #include <linux/platform_device.h> #include <sound/core.h>
Signature · 6 lines
2.17.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Kai Vehmanen
maintainerPATCH v3 7/10 ASoC: Intel: bxt-da7219-max98357a: common hdmi codec support
In reply to Kai VehmanenAdd support for using snd-hda-codec-hdmi driver for HDMI/DP instead of ASoC hdac-hdmi. This is aligned with how other HDA codecs are already handled.
--- sound/soc/intel/boards/bxt_da7219_max98357a.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
sound/soc/intel/boards/bxt_da7219_max98357a.c +11 -0
@@ -21,6 +21,7 @@#include "../../codecs/da7219.h" #include "../../codecs/da7219-aad.h" #include "../common/soc-intel-quirks.h" +#include "hda_dsp_common.h" #define BXT_DIALOG_CODEC_DAI "da7219-hifi"#define BXT_MAXIM_CODEC_DAI "HiFi"
@@ -38,6 +39,7 @@ struct bxt_hdmi_pcm {struct bxt_card_private {struct list_head hdmi_pcm_list; +bool common_hdmi_codec_drv; };enum {
@@ -615,6 +617,13 @@ static int bxt_card_late_probe(struct snd_soc_card *card)snd_soc_dapm_add_routes (&card->dapm, broxton_map,ARRAY_SIZE (broxton_map)); + pcm = list_first_entry(&ctx->hdmi_pcm_list, struct bxt_hdmi_pcm, + head); + component = pcm->codec_dai->component; + +if (ctx->common_hdmi_codec_drv) +return hda_dsp_hdmi_build_controls (card, component); +list_for_each_entry (pcm, &ctx->hdmi_pcm_list, head) { component = pcm->codec_dai->component; snprintf(jack_name, sizeof(jack_name),
@@ -720,6 +729,8 @@ static int broxton_audio_probe(struct platform_device *pdev)if (ret)return ret; + ctx->common_hdmi_codec_drv = mach->mach_params.common_hdmi_codec_drv; +return devm_snd_soc_register_card (&pdev->dev, &broxton_audio_card); }
Signature · 6 lines
2.17.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Kai Vehmanen
maintainerPATCH v3 8/10 ASoC: Intel: glk_rt5682_max98357a: common hdmi codec support
In reply to Kai VehmanenAdd support for using snd-hda-codec-hdmi driver for HDMI/DP instead of ASoC hdac-hdmi. This is aligned with how other HDA codecs are already handled.
--- sound/soc/intel/boards/glk_rt5682_max98357a.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
sound/soc/intel/boards/glk_rt5682_max98357a.c +11 -0
@@ -19,6 +19,7 @@#include <sound/soc-acpi.h> #include "../../codecs/rt5682.h" #include "../../codecs/hdac_hdmi.h" +#include "hda_dsp_common.h" /* The platform clock outputs 19.2Mhz clock to codec as I2S MCLK */ #define GLK_PLAT_CLK_FREQ 19200000
@@ -41,6 +42,7 @@ struct glk_hdmi_pcm {struct glk_card_private {struct snd_soc_jack geminilake_headset;struct list_head hdmi_pcm_list; +bool common_hdmi_codec_drv; };enum {
@@ -545,6 +547,13 @@ static int glk_card_late_probe(struct snd_soc_card *card)int err =0 ;int i =0 ; + pcm = list_first_entry(&ctx->hdmi_pcm_list, struct glk_hdmi_pcm, + head); + component = pcm->codec_dai->component; + +if (ctx->common_hdmi_codec_drv) +return hda_dsp_hdmi_build_controls (card, component); +list_for_each_entry (pcm, &ctx->hdmi_pcm_list, head) { component = pcm->codec_dai->component; snprintf(jack_name, sizeof(jack_name),
@@ -612,6 +621,8 @@ static int geminilake_audio_probe(struct platform_device *pdev)if (ret)return ret; + ctx->common_hdmi_codec_drv = mach->mach_params.common_hdmi_codec_drv; +return devm_snd_soc_register_card (&pdev->dev, card); }
Signature · 6 lines
2.17.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Kai Vehmanen
maintainerPATCH v3 9/10 ASoC: intel: sof_rt5682: common hdmi codec support
In reply to Kai VehmanenAdd support for using snd-hda-codec-hdmi driver for HDMI/DP instead of ASoC hdac-hdmi. This is aligned with how other HDA codecs are already handled.
--- sound/soc/intel/boards/sof_rt5682.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
sound/soc/intel/boards/sof_rt5682.c +11 -0
@@ -21,6 +21,7 @@#include "../../codecs/rt5682.h" #include "../../codecs/hdac_hdmi.h" #include "../common/soc-intel-quirks.h" +#include "hda_dsp_common.h" #define NAME_SIZE 32
@@ -53,6 +54,7 @@ struct sof_card_private {struct clk *mclk;struct snd_soc_jack sof_headset;struct list_head hdmi_pcm_list; +bool common_hdmi_codec_drv; };static int sof_rt5682_quirk_cb (const struct dmi_system_id *id)
@@ -274,6 +276,13 @@ static int sof_card_late_probe(struct snd_soc_card *card)if (is_legacy_cpu)return 0 ; + pcm = list_first_entry(&ctx->hdmi_pcm_list, struct sof_hdmi_pcm, + head); + component = pcm->codec_dai->component; + +if (ctx->common_hdmi_codec_drv) +return hda_dsp_hdmi_build_controls (card, component); +list_for_each_entry (pcm, &ctx->hdmi_pcm_list, head) { component = pcm->codec_dai->component; snprintf(jack_name, sizeof(jack_name),
@@ -615,6 +624,8 @@ static int sof_audio_probe(struct platform_device *pdev)if (ret)return ret; + ctx->common_hdmi_codec_drv = mach->mach_params.common_hdmi_codec_drv; +snd_soc_card_set_drvdata (&sof_audio_card_rt5682, ctx); return devm_snd_soc_register_card(&pdev->dev,
Signature · 6 lines
2.17.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Kai Vehmanen
maintainerPATCH v3 10/10 ASoC: Intel: bxt_rt298: common hdmi codec support
In reply to Kai VehmanenAdd support for using snd-hda-codec-hdmi driver for HDMI/DP instead of ASoC hdac-hdmi. This is aligned with how other HDA codecs are already handled.
--- sound/soc/intel/boards/bxt_rt298.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
sound/soc/intel/boards/bxt_rt298.c +11 -0
@@ -18,6 +18,7 @@#include <sound/pcm_params.h> #include "../../codecs/hdac_hdmi.h" #include "../../codecs/rt298.h" +#include "hda_dsp_common.h" /* Headset jack detection DAPM pins */ static struct snd_soc_jack broxton_headset;
@@ -31,6 +32,7 @@ struct bxt_hdmi_pcm {struct bxt_rt286_private {struct list_head hdmi_pcm_list; +bool common_hdmi_codec_drv; };enum {
@@ -527,6 +529,13 @@ static int bxt_card_late_probe(struct snd_soc_card *card)int err, i =0 ;char jack_name[NAME_SIZE ]; + pcm = list_first_entry(&ctx->hdmi_pcm_list, struct bxt_hdmi_pcm, + head); + component = pcm->codec_dai->component; + +if (ctx->common_hdmi_codec_drv) +return hda_dsp_hdmi_build_controls (card, component); +list_for_each_entry (pcm, &ctx->hdmi_pcm_list, head) { component = pcm->codec_dai->component; snprintf(jack_name, sizeof(jack_name),
@@ -626,6 +635,8 @@ static int broxton_audio_probe(struct platform_device *pdev)if (ret)return ret; + ctx->common_hdmi_codec_drv = mach->mach_params.common_hdmi_codec_drv; +return devm_snd_soc_register_card (&pdev->dev, card); }
Signature · 6 lines
2.17.1 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel