@@ -1645,6 +1645,7 @@ static struct snd_soc_acpi_mach *hda_sdw_machine_select(struct snd_sof_dev *sdev
1645
1645
{
1646
1646
struct snd_sof_pdata * pdata = sdev -> pdata ;
1647
1647
const struct snd_soc_acpi_link_adr * link ;
1648
+ struct sdw_extended_slave_id * ids ;
1648
1649
struct snd_soc_acpi_mach * mach ;
1649
1650
struct sof_intel_hda_dev * hdev ;
1650
1651
u32 link_mask ;
@@ -1653,92 +1654,109 @@ static struct snd_soc_acpi_mach *hda_sdw_machine_select(struct snd_sof_dev *sdev
1653
1654
hdev = pdata -> hw_pdata ;
1654
1655
link_mask = hdev -> info .link_mask ;
1655
1656
1657
+ if (!link_mask ) {
1658
+ dev_info (sdev -> dev , "SoundWire links not enabled\n" );
1659
+ return NULL ;
1660
+ }
1661
+
1662
+ if (!hdev -> sdw ) {
1663
+ dev_dbg (sdev -> dev , "SoundWire context not allocated\n" );
1664
+ return NULL ;
1665
+ }
1666
+
1667
+ if (!hdev -> sdw -> num_slaves ) {
1668
+ dev_warn (sdev -> dev , "No SoundWire peripheral detected in ACPI tables\n" );
1669
+ return NULL ;
1670
+ }
1671
+
1656
1672
/*
1657
1673
* Select SoundWire machine driver if needed using the
1658
1674
* alternate tables. This case deals with SoundWire-only
1659
1675
* machines, for mixed cases with I2C/I2S the detection relies
1660
1676
* on the HID list.
1661
1677
*/
1662
- if (link_mask ) {
1663
- for (mach = pdata -> desc -> alt_machines ;
1664
- mach && mach -> link_mask ; mach ++ ) {
1665
- /*
1666
- * On some platforms such as Up Extreme all links
1667
- * are enabled but only one link can be used by
1668
- * external codec. Instead of exact match of two masks,
1669
- * first check whether link_mask of mach is subset of
1670
- * link_mask supported by hw and then go on searching
1671
- * link_adr
1672
- */
1673
- if (~link_mask & mach -> link_mask )
1674
- continue ;
1675
-
1676
- /* No need to match adr if there is no links defined */
1677
- if (!mach -> links )
1678
- break ;
1679
-
1680
- link = mach -> links ;
1681
- for (i = 0 ; i < hdev -> info .count && link -> num_adr ;
1682
- i ++ , link ++ ) {
1683
- /*
1684
- * Try next machine if any expected Slaves
1685
- * are not found on this link.
1686
- */
1687
- if (!snd_soc_acpi_sdw_link_slaves_found (sdev -> dev , link ,
1688
- hdev -> sdw -> ids ,
1689
- hdev -> sdw -> num_slaves ))
1690
- break ;
1691
- }
1692
- /* Found if all Slaves are checked */
1693
- if (i == hdev -> info .count || !link -> num_adr )
1694
- break ;
1695
- }
1696
- if (mach && mach -> link_mask ) {
1697
- int dmic_num = 0 ;
1698
- bool tplg_fixup ;
1699
- const char * tplg_filename ;
1700
-
1701
- mach -> mach_params .links = mach -> links ;
1702
- mach -> mach_params .link_mask = mach -> link_mask ;
1703
- mach -> mach_params .platform = dev_name (sdev -> dev );
1678
+ for (mach = pdata -> desc -> alt_machines ;
1679
+ mach && mach -> link_mask ; mach ++ ) {
1680
+ /*
1681
+ * On some platforms such as Up Extreme all links
1682
+ * are enabled but only one link can be used by
1683
+ * external codec. Instead of exact match of two masks,
1684
+ * first check whether link_mask of mach is subset of
1685
+ * link_mask supported by hw and then go on searching
1686
+ * link_adr
1687
+ */
1688
+ if (~link_mask & mach -> link_mask )
1689
+ continue ;
1704
1690
1705
- if (pdata -> tplg_filename ) {
1706
- tplg_fixup = false;
1707
- } else {
1708
- tplg_fixup = true;
1709
- tplg_filename = mach -> sof_tplg_filename ;
1710
- }
1691
+ /* No need to match adr if there is no links defined */
1692
+ if (!mach -> links )
1693
+ break ;
1711
1694
1695
+ link = mach -> links ;
1696
+ for (i = 0 ; i < hdev -> info .count && link -> num_adr ;
1697
+ i ++ , link ++ ) {
1712
1698
/*
1713
- * DMICs use up to 4 pins and are typically pin-muxed with SoundWire
1714
- * link 2 and 3, or link 1 and 2, thus we only try to enable dmics
1715
- * if all conditions are true:
1716
- * a) 2 or fewer links are used by SoundWire
1717
- * b) the NHLT table reports the presence of microphones
1699
+ * Try next machine if any expected Slaves
1700
+ * are not found on this link.
1718
1701
*/
1719
- if (hweight_long (mach -> link_mask ) <= 2 ) {
1720
- int ret ;
1721
-
1722
- ret = dmic_detect_topology_fixup (sdev , & tplg_filename , "" ,
1723
- & dmic_num , tplg_fixup );
1724
- if (ret < 0 )
1725
- return NULL ;
1726
- }
1727
- if (tplg_fixup )
1728
- pdata -> tplg_filename = tplg_filename ;
1729
- mach -> mach_params .dmic_num = dmic_num ;
1702
+ if (!snd_soc_acpi_sdw_link_slaves_found (sdev -> dev , link ,
1703
+ hdev -> sdw -> ids ,
1704
+ hdev -> sdw -> num_slaves ))
1705
+ break ;
1706
+ }
1707
+ /* Found if all Slaves are checked */
1708
+ if (i == hdev -> info .count || !link -> num_adr )
1709
+ break ;
1710
+ }
1711
+ if (mach && mach -> link_mask ) {
1712
+ int dmic_num = 0 ;
1713
+ bool tplg_fixup ;
1714
+ const char * tplg_filename ;
1715
+
1716
+ mach -> mach_params .links = mach -> links ;
1717
+ mach -> mach_params .link_mask = mach -> link_mask ;
1718
+ mach -> mach_params .platform = dev_name (sdev -> dev );
1719
+
1720
+ if (pdata -> tplg_filename ) {
1721
+ tplg_fixup = false;
1722
+ } else {
1723
+ tplg_fixup = true;
1724
+ tplg_filename = mach -> sof_tplg_filename ;
1725
+ }
1730
1726
1731
- dev_dbg (sdev -> dev ,
1732
- "SoundWire machine driver %s topology %s\n" ,
1733
- mach -> drv_name ,
1734
- pdata -> tplg_filename );
1727
+ /*
1728
+ * DMICs use up to 4 pins and are typically pin-muxed with SoundWire
1729
+ * link 2 and 3, or link 1 and 2, thus we only try to enable dmics
1730
+ * if all conditions are true:
1731
+ * a) 2 or fewer links are used by SoundWire
1732
+ * b) the NHLT table reports the presence of microphones
1733
+ */
1734
+ if (hweight_long (mach -> link_mask ) <= 2 ) {
1735
+ int ret ;
1735
1736
1736
- return mach ;
1737
+ ret = dmic_detect_topology_fixup (sdev , & tplg_filename , "" ,
1738
+ & dmic_num , tplg_fixup );
1739
+ if (ret < 0 )
1740
+ return NULL ;
1737
1741
}
1742
+ if (tplg_fixup )
1743
+ pdata -> tplg_filename = tplg_filename ;
1744
+ mach -> mach_params .dmic_num = dmic_num ;
1738
1745
1739
- dev_info (sdev -> dev , "No SoundWire machine driver found\n" );
1746
+ dev_dbg (sdev -> dev ,
1747
+ "SoundWire machine driver %s topology %s\n" ,
1748
+ mach -> drv_name ,
1749
+ pdata -> tplg_filename );
1750
+
1751
+ return mach ;
1740
1752
}
1741
1753
1754
+ dev_info (sdev -> dev , "No SoundWire machine driver found for the ACPI-reported configuration:\n" );
1755
+ ids = hdev -> sdw -> ids ;
1756
+ for (i = 0 ; i < hdev -> sdw -> num_slaves ; i ++ )
1757
+ dev_info (sdev -> dev , "link %d mfg_id 0x%04x part_id 0x%04x version %#x\n" ,
1758
+ ids [i ].link_id , ids [i ].id .mfg_id , ids [i ].id .part_id , ids [i ].id .sdw_version );
1759
+
1742
1760
return NULL ;
1743
1761
}
1744
1762
#else
0 commit comments