Skip to content

ASoC: SOF: topology: use the default hw_config in DAI link init - #758

Merged
plbossart merged 1 commit into
thesofproject:topic/sof-devfrom
dragosht:default_hw_config
Mar 30, 2019
Merged

plbossart merged 1 commit into
thesofproject:topic/sof-devfrom
dragosht:default_hw_config

Conversation

@dragosht

Copy link
Copy Markdown

If multiple hw_configs are provided in the topology, look for the
default one instead of loading the first one found.

Signed-off-by: Dragos Tarcatu dragos_tarcatu@mentor.com

If multiple hw_configs are provided in the topology, look for the
default one instead of loading the first one found.

Signed-off-by: Dragos Tarcatu <dragos_tarcatu@mentor.com>
@dragosht
dragosht force-pushed the default_hw_config branch from 806a92d to 72af409 Compare March 28, 2019 09:43

@plbossart plbossart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dragosht. This looks good to me but I would like to see a test case and a topology that we can use to double-check this. @ranj063 can you review and suggest such a change in sof for tests?

@plbossart
plbossart requested a review from ranj063 March 28, 2019 13:13
@ranj063

ranj063 commented Mar 28, 2019

Copy link
Copy Markdown
Collaborator

@plbossart we could add a second SSP_CONFIG() for the the SSP's in the nocodec to test multiple hw_configs. Today we have the default set to 16-bit format, we could add another one for 24-bit to test this.
I can do this today.

@dragosht

dragosht commented Mar 29, 2019 •

Copy link
Copy Markdown
Author

@ranj063 @plbossart I tested this starting from the m4-preprocessed sof-apl-nocodec.conf and then handcrafted it to use 2 hw_configs for SSP5 with ids 5 and 6. Config 5 is the one generated from the m4, and config 6 changes the TDM slot width to 32 bits and adjusts the bit clock accordingly.

sof-apl-nocodec.conf.txt

SectionHWConfig."SSP5-0" {
    id              "5"
    format          "I2S"
    mclk            "codec_mclk_in"
    mclk_freq       "24576000"    
    bclk            "codec_slave"
    bclk_freq       "1536000"
    fsync           "codec_slave"
    fsync_freq      "48000"
    tdm_slots       "2"
    tdm_slot_width  "16"
    tx_slots        "3"
    rx_slots        "3"
}

SectionHWConfig."SSP5-1" {
    id              "6"
    format          "I2S"
    mclk            "codec_mclk_in"
    mclk_freq       "24576000"    
    bclk            "codec_slave"
    bclk_freq       "3072000"
    fsync           "codec_slave"
    fsync_freq      "48000"
    tdm_slots       "2"
    tdm_slot_width  "32"
    tx_slots        "3"
    rx_slots        "3"
}

SectionBE."NoCodec-5" {
    id "5"
    index "0"
    default_hw_conf_id      "5"

    hw_configs [
            "SSP5-0"
            "SSP5-1"
    ]
    data [
            "DAICONFIG.SSP5_data"
            "DAICONFIG.SSP5_data_common"

    ]
}

And kept the data width to 16 bits. Since this is not part of the HWConfig section, as far as I can tell, some driver changes will be needed if multiple hw_configs would require different data width values.

SectionVendorTuples."DAICONFIG.SSP5_tuples" {
    tokens "sof_ssp_tokens"
    tuples."word" {
            SOF_TKN_INTEL_SSP_SAMPLE_BITS   "16"
    }
    tuples."short" {
            SOF_TKN_INTEL_SSP_MCLK_ID       ""
    }
}

I hw_config 5 is being set as the default:

[    4.069230] sof-audio-pci 0000:00:0e.0: tplg: 2 hw_configs found, default id: 5!
[    4.069234] sof-audio-pci 0000:00:0e.0: sof_link_load: 2 hw_configs found!
[    4.069239] sof-audio-pci 0000:00:0e.0: tplg: config SSP5 fmt 0x4001 mclk 24576000 bclk 1536000 fclk 48000 width (16)16 slots 2 mclk id 0 quirks 0

If hw_config 6:

[    4.048971] sof-audio-pci 0000:00:0e.0: tplg: 2 hw_configs found, default id: 6!
[    4.048973] sof-audio-pci 0000:00:0e.0: sof_link_load: 2 hw_configs found!
[    4.048976] sof-audio-pci 0000:00:0e.0: tplg: config SSP5 fmt 0x4001 mclk 24576000 bclk 3072000 fclk 48000 width (16)32 slots 2 mclk id 0 quirks 0

and if some inexistent id is given:

[    4.121569] sof-audio-pci 0000:00:0e.0: error: default hw_config id: 7 not found!
[    4.131881] sof-audio-pci 0000:00:0e.0: ASoC: physical link loading failed
[    4.147280] sof-audio-pci 0000:00:0e.0: error: tplg component load failed -22
[    4.159951] sof-audio-pci 0000:00:0e.0: error: failed to load DSP topology -22
[    4.174323] sof-audio-pci 0000:00:0e.0: ASoC: failed to probe component -22
[    4.185300] sof-nocodec sof-nocodec: ASoC: failed to instantiate card -22
[    4.193014] sof-nocodec: probe of sof-nocodec failed with error -22

@ranj063 ranj063 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dragosht Thanks for testing this.

@plbossart plbossart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dragosht, 1st patch for the SOF driver!
All we need know is to figure out how to select a non-default config...

@plbossart
plbossart merged commit 1a30233 into thesofproject:topic/sof-dev Mar 30, 2019
@xiulipan

xiulipan commented Apr 1, 2019

Copy link
Copy Markdown

@plbossart @dragosht
I think we may need start from soc layer?

I see it also do some similar thing to the codec. If we need to be able to change hw_config I think we may need to add interface in both part.

linux/sound/soc/soc-topology.c

Lines 2053 to 2064 in f304b5c

static void set_link_hw_format(struct snd_soc_dai_link *link,
struct snd_soc_tplg_link_config *cfg)
{
struct snd_soc_tplg_hw_config *hw_config;
unsigned char bclk_master, fsync_master;
unsigned char invert_bclk, invert_fsync;
int i;
for (i = 0; i < cfg->num_hw_configs; i++) {
hw_config = &cfg->hw_config[i];
if (hw_config->id != cfg->default_hw_config_id)
continue;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants