Skip to content

Commit

Permalink
Merge branch 'thesofproject:topic/sof-dev' into topic/sof-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
vijendarmukunda committed Nov 22, 2023
2 parents fdc3632 + 0f2bd45 commit 89a8988
Show file tree
Hide file tree
Showing 24 changed files with 545 additions and 437 deletions.
8 changes: 8 additions & 0 deletions drivers/soundwire/amd_manager.c
Expand Up @@ -907,6 +907,14 @@ static int amd_sdw_manager_probe(struct platform_device *pdev)
amd_manager->bus.clk_stop_timeout = 200;
amd_manager->bus.link_id = amd_manager->instance;

/*
* Due to BIOS compatibility, the two links are exposed within
* the scope of a single controller. If this changes, the
* controller_id will have to be updated with drv_data
* information.
*/
amd_manager->bus.controller_id = 0;

switch (amd_manager->instance) {
case ACP_SDW0:
amd_manager->num_dout_ports = AMD_SDW0_MAX_TX_PORTS;
Expand Down
4 changes: 4 additions & 0 deletions drivers/soundwire/bus.c
Expand Up @@ -22,6 +22,10 @@ static int sdw_get_id(struct sdw_bus *bus)
return rc;

bus->id = rc;

if (bus->controller_id == -1)
bus->controller_id = rc;

return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/soundwire/debugfs.c
Expand Up @@ -20,7 +20,7 @@ void sdw_bus_debugfs_init(struct sdw_bus *bus)
return;

/* create the debugfs master-N */
snprintf(name, sizeof(name), "master-%d-%d", bus->id, bus->link_id);
snprintf(name, sizeof(name), "master-%d-%d", bus->controller_id, bus->link_id);
bus->debugfs = debugfs_create_dir(name, sdw_debugfs_root);
}

Expand Down
3 changes: 3 additions & 0 deletions drivers/soundwire/intel_auxdevice.c
Expand Up @@ -234,6 +234,9 @@ static int intel_link_probe(struct auxiliary_device *auxdev,
cdns->instance = sdw->instance;
cdns->msg_count = 0;

/* single controller for all SoundWire links */
bus->controller_id = 0;

bus->link_id = auxdev->id;
bus->clk_stop_timeout = 1;

Expand Down
2 changes: 1 addition & 1 deletion drivers/soundwire/master.c
Expand Up @@ -145,7 +145,7 @@ int sdw_master_device_add(struct sdw_bus *bus, struct device *parent,
md->dev.fwnode = fwnode;
md->dev.dma_mask = parent->dma_mask;

dev_set_name(&md->dev, "sdw-master-%d", bus->id);
dev_set_name(&md->dev, "sdw-master-%d-%d", bus->controller_id, bus->link_id);

ret = device_register(&md->dev);
if (ret) {
Expand Down
3 changes: 3 additions & 0 deletions drivers/soundwire/qcom.c
Expand Up @@ -1624,6 +1624,9 @@ static int qcom_swrm_probe(struct platform_device *pdev)
}
}

/* FIXME: is there a DT-defined value to use ? */
ctrl->bus.controller_id = -1;

ret = sdw_bus_master_add(&ctrl->bus, dev, dev->fwnode);
if (ret) {
dev_err(dev, "Failed to register Soundwire controller (%d)\n",
Expand Down
12 changes: 6 additions & 6 deletions drivers/soundwire/slave.c
Expand Up @@ -39,14 +39,14 @@ int sdw_slave_add(struct sdw_bus *bus,
slave->dev.fwnode = fwnode;

if (id->unique_id == SDW_IGNORED_UNIQUE_ID) {
/* name shall be sdw:link:mfg:part:class */
dev_set_name(&slave->dev, "sdw:%01x:%04x:%04x:%02x",
bus->link_id, id->mfg_id, id->part_id,
/* name shall be sdw:ctrl:link:mfg:part:class */
dev_set_name(&slave->dev, "sdw:%01x:%01x:%04x:%04x:%02x",
bus->controller_id, bus->link_id, id->mfg_id, id->part_id,
id->class_id);
} else {
/* name shall be sdw:link:mfg:part:class:unique */
dev_set_name(&slave->dev, "sdw:%01x:%04x:%04x:%02x:%01x",
bus->link_id, id->mfg_id, id->part_id,
/* name shall be sdw:ctrl:link:mfg:part:class:unique */
dev_set_name(&slave->dev, "sdw:%01x:%01x:%04x:%04x:%02x:%01x",
bus->controller_id, bus->link_id, id->mfg_id, id->part_id,
id->class_id, id->unique_id);
}

Expand Down
4 changes: 3 additions & 1 deletion include/linux/soundwire/sdw.h
Expand Up @@ -886,7 +886,8 @@ struct sdw_master_ops {
* struct sdw_bus - SoundWire bus
* @dev: Shortcut to &bus->md->dev to avoid changing the entire code.
* @md: Master device
* @link_id: Link id number, can be 0 to N, unique for each Master
* @controller_id: system-unique controller ID. If set to -1, the bus @id will be used.
* @link_id: Link id number, can be 0 to N, unique for each Controller
* @id: bus system-wide unique id
* @slaves: list of Slaves on this bus
* @assigned: Bitmap for Slave device numbers.
Expand Down Expand Up @@ -918,6 +919,7 @@ struct sdw_master_ops {
struct sdw_bus {
struct device *dev;
struct sdw_master_device *md;
int controller_id;
unsigned int link_id;
int id;
struct list_head slaves;
Expand Down
10 changes: 10 additions & 0 deletions include/sound/intel-nhlt.h
Expand Up @@ -143,6 +143,9 @@ intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt,
u32 bus_id, u8 link_type, u8 vbps, u8 bps,
u8 num_ch, u32 rate, u8 dir, u8 dev_type);

int intel_nhlt_ssp_device_type(struct device *dev, struct nhlt_acpi_table *nhlt,
u8 virtual_bus_id);

#else

static inline struct nhlt_acpi_table *intel_nhlt_init(struct device *dev)
Expand Down Expand Up @@ -184,6 +187,13 @@ intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt,
return NULL;
}

static inline int intel_nhlt_ssp_device_type(struct device *dev,
struct nhlt_acpi_table *nhlt,
u8 virtual_bus_id)
{
return -EINVAL;
}

#endif

#endif
59 changes: 55 additions & 4 deletions sound/hda/intel-nhlt.c
Expand Up @@ -238,7 +238,7 @@ EXPORT_SYMBOL(intel_nhlt_ssp_mclk_mask);

static struct nhlt_specific_cfg *
nhlt_get_specific_cfg(struct device *dev, struct nhlt_fmt *fmt, u8 num_ch,
u32 rate, u8 vbps, u8 bps)
u32 rate, u8 vbps, u8 bps, bool ignore_vbps)
{
struct nhlt_fmt_cfg *cfg = fmt->fmt_config;
struct wav_fmt *wfmt;
Expand All @@ -255,8 +255,12 @@ nhlt_get_specific_cfg(struct device *dev, struct nhlt_fmt *fmt, u8 num_ch,
dev_dbg(dev, "Endpoint format: ch=%d fmt=%d/%d rate=%d\n",
wfmt->channels, _vbps, _bps, wfmt->samples_per_sec);

/*
* When looking for exact match of configuration ignore the vbps
* from NHLT table when ignore_vbps is true
*/
if (wfmt->channels == num_ch && wfmt->samples_per_sec == rate &&
vbps == _vbps && bps == _bps)
(ignore_vbps || vbps == _vbps) && bps == _bps)
return &cfg->config;

cfg = (struct nhlt_fmt_cfg *)(cfg->config.caps + cfg->config.size);
Expand Down Expand Up @@ -289,6 +293,7 @@ intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt,
{
struct nhlt_specific_cfg *cfg;
struct nhlt_endpoint *epnt;
bool ignore_vbps = false;
struct nhlt_fmt *fmt;
int i;

Expand All @@ -298,7 +303,26 @@ intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt,
dev_dbg(dev, "Looking for configuration:\n");
dev_dbg(dev, " vbus_id=%d link_type=%d dir=%d, dev_type=%d\n",
bus_id, link_type, dir, dev_type);
dev_dbg(dev, " ch=%d fmt=%d/%d rate=%d\n", num_ch, vbps, bps, rate);
if (link_type == NHLT_LINK_DMIC && bps == 32 && (vbps == 24 || vbps == 32)) {
/*
* The DMIC hardware supports only one type of 32 bits sample
* size, which is 24 bit sampling on the MSB side and bits[1:0]
* are used for indicating the channel number.
* It has been observed that some NHLT tables have the vbps
* specified as 32 while some uses 24.
* The format these variations describe are identical, the
* hardware is configured and behaves the same way.
* Note: when the samples assumed to be vbps=32 then the 'noise'
* introduced by the lower two bits (channel number) have no
* real life implication on audio quality.
*/
dev_dbg(dev,
" ch=%d fmt=%d rate=%d (vbps is ignored for DMIC 32bit format)\n",
num_ch, bps, rate);
ignore_vbps = true;
} else {
dev_dbg(dev, " ch=%d fmt=%d/%d rate=%d\n", num_ch, vbps, bps, rate);
}
dev_dbg(dev, "Endpoint count=%d\n", nhlt->endpoint_count);

epnt = (struct nhlt_endpoint *)nhlt->desc;
Expand All @@ -307,7 +331,8 @@ intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt,
if (nhlt_check_ep_match(dev, epnt, bus_id, link_type, dir, dev_type)) {
fmt = (struct nhlt_fmt *)(epnt->config.caps + epnt->config.size);

cfg = nhlt_get_specific_cfg(dev, fmt, num_ch, rate, vbps, bps);
cfg = nhlt_get_specific_cfg(dev, fmt, num_ch, rate,
vbps, bps, ignore_vbps);
if (cfg)
return cfg;
}
Expand All @@ -318,3 +343,29 @@ intel_nhlt_get_endpoint_blob(struct device *dev, struct nhlt_acpi_table *nhlt,
return NULL;
}
EXPORT_SYMBOL(intel_nhlt_get_endpoint_blob);

int intel_nhlt_ssp_device_type(struct device *dev, struct nhlt_acpi_table *nhlt,
u8 virtual_bus_id)
{
struct nhlt_endpoint *epnt;
int i;

if (!nhlt)
return -EINVAL;

epnt = (struct nhlt_endpoint *)nhlt->desc;
for (i = 0; i < nhlt->endpoint_count; i++) {
/* for SSP link the virtual bus id is the SSP port number */
if (epnt->linktype == NHLT_LINK_SSP &&
epnt->virtual_bus_id == virtual_bus_id) {
dev_dbg(dev, "SSP%d: dev_type=%d\n", virtual_bus_id,
epnt->device_type);
return epnt->device_type;
}

epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length);
}

return -EINVAL;
}
EXPORT_SYMBOL(intel_nhlt_ssp_device_type);
127 changes: 127 additions & 0 deletions sound/soc/intel/boards/sof_board_helpers.c
Expand Up @@ -248,6 +248,133 @@ int sof_intel_board_set_intel_hdmi_link(struct device *dev,
}
EXPORT_SYMBOL_NS(sof_intel_board_set_intel_hdmi_link, SND_SOC_INTEL_SOF_BOARD_HELPERS);

int sof_intel_board_set_ssp_amp_link(struct device *dev,
struct snd_soc_dai_link *link, int be_id,
enum sof_ssp_codec amp_type, int ssp_amp)
{
struct snd_soc_dai_link_component *cpus;

dev_dbg(dev, "link %d: ssp amp %s, ssp %d\n", be_id,
sof_ssp_get_codec_name(amp_type), ssp_amp);

/* link name */
link->name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-Codec", ssp_amp);
if (!link->name)
return -ENOMEM;

/* cpus */
cpus = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link_component),
GFP_KERNEL);
if (!cpus)
return -ENOMEM;

cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", ssp_amp);
if (!cpus->dai_name)
return -ENOMEM;

link->cpus = cpus;
link->num_cpus = 1;

/* codecs - caller to handle */

/* platforms */
link->platforms = platform_component;
link->num_platforms = ARRAY_SIZE(platform_component);

link->id = be_id;
link->no_pcm = 1;
link->dpcm_capture = 1; /* feedback stream or firmware-generated echo reference */
link->dpcm_playback = 1;

return 0;
}
EXPORT_SYMBOL_NS(sof_intel_board_set_ssp_amp_link, SND_SOC_INTEL_SOF_BOARD_HELPERS);

int sof_intel_board_set_bt_link(struct device *dev,
struct snd_soc_dai_link *link, int be_id,
int ssp_bt)
{
struct snd_soc_dai_link_component *cpus;

dev_dbg(dev, "link %d: bt offload, ssp %d\n", be_id, ssp_bt);

/* link name */
link->name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-BT", ssp_bt);
if (!link->name)
return -ENOMEM;

/* cpus */
cpus = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link_component),
GFP_KERNEL);
if (!cpus)
return -ENOMEM;

cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", ssp_bt);
if (!cpus->dai_name)
return -ENOMEM;

link->cpus = cpus;
link->num_cpus = 1;

/* codecs */
link->codecs = &snd_soc_dummy_dlc;
link->num_codecs = 1;

/* platforms */
link->platforms = platform_component;
link->num_platforms = ARRAY_SIZE(platform_component);

link->id = be_id;
link->no_pcm = 1;
link->dpcm_capture = 1;
link->dpcm_playback = 1;

return 0;
}
EXPORT_SYMBOL_NS(sof_intel_board_set_bt_link, SND_SOC_INTEL_SOF_BOARD_HELPERS);

int sof_intel_board_set_hdmi_in_link(struct device *dev,
struct snd_soc_dai_link *link, int be_id,
int ssp_hdmi)
{
struct snd_soc_dai_link_component *cpus;

dev_dbg(dev, "link %d: hdmi-in, ssp %d\n", be_id, ssp_hdmi);

/* link name */
link->name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-HDMI", ssp_hdmi);
if (!link->name)
return -ENOMEM;

/* cpus */
cpus = devm_kzalloc(dev, sizeof(struct snd_soc_dai_link_component),
GFP_KERNEL);
if (!cpus)
return -ENOMEM;

cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", ssp_hdmi);
if (!cpus->dai_name)
return -ENOMEM;

link->cpus = cpus;
link->num_cpus = 1;

/* codecs */
link->codecs = &snd_soc_dummy_dlc;
link->num_codecs = 1;

/* platforms */
link->platforms = platform_component;
link->num_platforms = ARRAY_SIZE(platform_component);

link->id = be_id;
link->no_pcm = 1;
link->dpcm_capture = 1;

return 0;
}
EXPORT_SYMBOL_NS(sof_intel_board_set_hdmi_in_link, SND_SOC_INTEL_SOF_BOARD_HELPERS);

MODULE_DESCRIPTION("ASoC Intel SOF Machine Driver Board Helpers");
MODULE_AUTHOR("Brent Lu <brent.lu@intel.com>");
MODULE_LICENSE("GPL");
Expand Down
18 changes: 18 additions & 0 deletions sound/soc/intel/boards/sof_board_helpers.h
Expand Up @@ -31,6 +31,10 @@ struct sof_rt5682_private {
* @dmic_be_num: number of Intel PCH DMIC BE link
* @hdmi_num: number of Intel HDMI BE link
* @ssp_codec: ssp port number of headphone BE link
* @ssp_amp: ssp port number of speaker BE link
* @ssp_bt: ssp port number of BT offload BE link
* @ssp_mask_hdmi_in: ssp port mask of HDMI-IN BE link
* @bt_offload_present: true to create BT offload BE link
* @rt5682: private data for rt5682 machine driver
*/
struct sof_card_private {
Expand All @@ -44,6 +48,11 @@ struct sof_card_private {
int hdmi_num;

int ssp_codec;
int ssp_amp;
int ssp_bt;
unsigned long ssp_mask_hdmi_in;

bool bt_offload_present;

union {
struct sof_rt5682_private rt5682;
Expand All @@ -66,5 +75,14 @@ int sof_intel_board_set_dmic_link(struct device *dev,
int sof_intel_board_set_intel_hdmi_link(struct device *dev,
struct snd_soc_dai_link *link, int be_id,
int hdmi_id, bool idisp_codec);
int sof_intel_board_set_ssp_amp_link(struct device *dev,
struct snd_soc_dai_link *link, int be_id,
enum sof_ssp_codec amp_type, int ssp_amp);
int sof_intel_board_set_bt_link(struct device *dev,
struct snd_soc_dai_link *link, int be_id,
int ssp_bt);
int sof_intel_board_set_hdmi_in_link(struct device *dev,
struct snd_soc_dai_link *link, int be_id,
int ssp_hdmi);

#endif /* __SOF_INTEL_BOARD_HELPERS_H */

0 comments on commit 89a8988

Please sign in to comment.