Merge series "ASoC: Intel: boards: use software node API" from Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>:

This is an update on an earlier contribution from Heikki Krogerus

The function device_add_properties() is going to be removed.
Replacing it with software node API equivalents.

Thanks for Hans de Goede and Andy Shevchenko for their comments,
suggestions and Reviewed-by tags on GitHub. The review thread can be
found at https://github.com/thesofproject/linux/pull/3041)

v3 changes:
Fixed nit-picks from Andy: label, return value, missing commas/periods.
Added Andy's Reviewed-by tag

v2 changes: feedback from Andy and Hans
Better error handling
Codec reference is kept until the .remove callback
Remove bus search to find device

v1 changes from Heikki's patches:
Avoid the use of devm_ routines for Baytrail machine drivers.

Heikki Krogerus (1):
  ASoC: Intel: boards: use software node API in Atom boards

Pierre-Louis Bossart (7):
  ASoC: Intel: boards: harden codec property handling
  ASoC: Intel: boards: handle errors with acpi_dev_get_first_match_dev()
  ASoC: Intel: boards: get codec device with ACPI instead of bus search
  ASoC: Intel: sof_sdw: pass card information to init/exit functions
  ASoC: Intel: sof_sdw_rt711*: keep codec device reference until remove
  ASoC: Intel: use software node API in SoundWire machines
  ASoC: Intel: remove device_properties for Atom boards

 sound/soc/intel/boards/bytcht_es8316.c      | 31 ++++++++--
 sound/soc/intel/boards/bytcr_rt5640.c       | 60 +++++++++++++++-----
 sound/soc/intel/boards/bytcr_rt5651.c       | 63 ++++++++++++++-------
 sound/soc/intel/boards/sof_sdw.c            | 20 ++++---
 sound/soc/intel/boards/sof_sdw_common.h     | 37 +++++++-----
 sound/soc/intel/boards/sof_sdw_max98373.c   |  3 +-
 sound/soc/intel/boards/sof_sdw_rt1308.c     |  3 +-
 sound/soc/intel/boards/sof_sdw_rt1316.c     |  3 +-
 sound/soc/intel/boards/sof_sdw_rt5682.c     |  3 +-
 sound/soc/intel/boards/sof_sdw_rt700.c      |  3 +-
 sound/soc/intel/boards/sof_sdw_rt711.c      | 51 +++++++++--------
 sound/soc/intel/boards/sof_sdw_rt711_sdca.c | 52 +++++++++--------
 sound/soc/intel/boards/sof_sdw_rt715.c      |  3 +-
 sound/soc/intel/boards/sof_sdw_rt715_sdca.c |  3 +-
 14 files changed, 223 insertions(+), 112 deletions(-)

--
2.25.1
This commit is contained in:
Mark Brown 2021-08-13 17:49:06 +01:00
commit 31e53e137c
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
14 changed files with 223 additions and 112 deletions

View File

@ -37,6 +37,7 @@ struct byt_cht_es8316_private {
struct clk *mclk;
struct snd_soc_jack jack;
struct gpio_desc *speaker_en_gpio;
struct device *codec_dev;
bool speaker_en;
};
@ -461,6 +462,7 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
const struct dmi_system_id *dmi_id;
struct device *dev = &pdev->dev;
struct snd_soc_acpi_mach *mach;
struct fwnode_handle *fwnode;
const char *platform_name;
struct acpi_device *adev;
struct device *codec_dev;
@ -491,6 +493,9 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
"i2c-%s", acpi_dev_name(adev));
put_device(&adev->dev);
byt_cht_es8316_dais[dai_index].codecs->name = codec_name;
} else {
dev_err(&pdev->dev, "Error cannot find '%s' dev\n", mach->id);
return -ENXIO;
}
/* override plaform name, if required */
@ -535,15 +540,25 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
}
/* get speaker enable GPIO */
codec_dev = bus_find_device_by_name(&i2c_bus_type, NULL, codec_name);
codec_dev = acpi_get_first_physical_node(adev);
if (!codec_dev)
return -EPROBE_DEFER;
priv->codec_dev = get_device(codec_dev);
if (quirk & BYT_CHT_ES8316_JD_INVERTED)
props[cnt++] = PROPERTY_ENTRY_BOOL("everest,jack-detect-inverted");
if (cnt) {
ret = device_add_properties(codec_dev, props);
fwnode = fwnode_create_software_node(props, NULL);
if (IS_ERR(fwnode)) {
put_device(codec_dev);
return PTR_ERR(fwnode);
}
ret = device_add_software_node(codec_dev, to_software_node(fwnode));
fwnode_handle_put(fwnode);
if (ret) {
put_device(codec_dev);
return ret;
@ -555,7 +570,6 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
gpiod_get_index(codec_dev, "speaker-enable", 0,
/* see comment in byt_cht_es8316_resume */
GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE);
put_device(codec_dev);
if (IS_ERR(priv->speaker_en_gpio)) {
ret = PTR_ERR(priv->speaker_en_gpio);
@ -567,7 +581,7 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
dev_err(dev, "get speaker GPIO failed: %d\n", ret);
fallthrough;
case -EPROBE_DEFER:
return ret;
goto err_put_codec;
}
}
@ -605,10 +619,15 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
if (ret) {
gpiod_put(priv->speaker_en_gpio);
dev_err(dev, "snd_soc_register_card failed: %d\n", ret);
return ret;
goto err_put_codec;
}
platform_set_drvdata(pdev, &byt_cht_es8316_card);
return 0;
err_put_codec:
device_remove_software_node(priv->codec_dev);
put_device(priv->codec_dev);
return ret;
}
static int snd_byt_cht_es8316_mc_remove(struct platform_device *pdev)
@ -617,6 +636,8 @@ static int snd_byt_cht_es8316_mc_remove(struct platform_device *pdev)
struct byt_cht_es8316_private *priv = snd_soc_card_get_drvdata(card);
gpiod_put(priv->speaker_en_gpio);
device_remove_software_node(priv->codec_dev);
put_device(priv->codec_dev);
return 0;
}

View File

@ -90,6 +90,7 @@ enum {
struct byt_rt5640_private {
struct snd_soc_jack jack;
struct clk *mclk;
struct device *codec_dev;
};
static bool is_bytcr;
@ -969,15 +970,13 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = {
* Note this MUST be called before snd_soc_register_card(), so that the props
* are in place before the codec component driver's probe function parses them.
*/
static int byt_rt5640_add_codec_device_props(const char *i2c_dev_name)
static int byt_rt5640_add_codec_device_props(struct device *i2c_dev,
struct byt_rt5640_private *priv)
{
struct property_entry props[MAX_NO_PROPS] = {};
struct device *i2c_dev;
int ret, cnt = 0;
i2c_dev = bus_find_device_by_name(&i2c_bus_type, NULL, i2c_dev_name);
if (!i2c_dev)
return -EPROBE_DEFER;
struct fwnode_handle *fwnode;
int cnt = 0;
int ret;
switch (BYT_RT5640_MAP(byt_rt5640_quirk)) {
case BYT_RT5640_DMIC1_MAP:
@ -1017,8 +1016,15 @@ static int byt_rt5640_add_codec_device_props(const char *i2c_dev_name)
if (byt_rt5640_quirk & BYT_RT5640_JD_NOT_INV)
props[cnt++] = PROPERTY_ENTRY_BOOL("realtek,jack-detect-not-inverted");
ret = device_add_properties(i2c_dev, props);
put_device(i2c_dev);
fwnode = fwnode_create_software_node(props, NULL);
if (IS_ERR(fwnode)) {
/* put_device() is handled in caller */
return PTR_ERR(fwnode);
}
ret = device_add_software_node(i2c_dev, to_software_node(fwnode));
fwnode_handle_put(fwnode);
return ret;
}
@ -1367,6 +1373,7 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
struct snd_soc_acpi_mach *mach;
const char *platform_name;
struct acpi_device *adev;
struct device *codec_dev;
bool sof_parent;
int ret_val = 0;
int dai_index = 0;
@ -1399,6 +1406,9 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
"i2c-%s", acpi_dev_name(adev));
put_device(&adev->dev);
byt_rt5640_dais[dai_index].codecs->name = byt_rt5640_codec_name;
} else {
dev_err(&pdev->dev, "Error cannot find '%s' dev\n", mach->id);
return -ENXIO;
}
/*
@ -1475,10 +1485,15 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
byt_rt5640_quirk = quirk_override;
}
codec_dev = acpi_get_first_physical_node(adev);
if (!codec_dev)
return -EPROBE_DEFER;
priv->codec_dev = get_device(codec_dev);
/* Must be called before register_card, also see declaration comment. */
ret_val = byt_rt5640_add_codec_device_props(byt_rt5640_codec_name);
ret_val = byt_rt5640_add_codec_device_props(codec_dev, priv);
if (ret_val)
return ret_val;
goto err_device;
log_quirks(&pdev->dev);
@ -1509,7 +1524,7 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
* for all other errors, including -EPROBE_DEFER
*/
if (ret_val != -ENOENT)
return ret_val;
goto err;
byt_rt5640_quirk &= ~BYT_RT5640_MCLK_EN;
}
}
@ -1553,7 +1568,7 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
ret_val = snd_soc_fixup_dai_links_platform_name(&byt_rt5640_card,
platform_name);
if (ret_val)
return ret_val;
goto err;
sof_parent = snd_soc_acpi_sof_parent(&pdev->dev);
@ -1575,10 +1590,26 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
if (ret_val) {
dev_err(&pdev->dev, "devm_snd_soc_register_card failed %d\n",
ret_val);
return ret_val;
goto err;
}
platform_set_drvdata(pdev, &byt_rt5640_card);
return ret_val;
err:
device_remove_software_node(priv->codec_dev);
err_device:
put_device(priv->codec_dev);
return ret_val;
}
static int snd_byt_rt5640_mc_remove(struct platform_device *pdev)
{
struct snd_soc_card *card = platform_get_drvdata(pdev);
struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card);
device_remove_software_node(priv->codec_dev);
put_device(priv->codec_dev);
return 0;
}
static struct platform_driver snd_byt_rt5640_mc_driver = {
@ -1586,6 +1617,7 @@ static struct platform_driver snd_byt_rt5640_mc_driver = {
.name = "bytcr_rt5640",
},
.probe = snd_byt_rt5640_mc_probe,
.remove = snd_byt_rt5640_mc_remove,
};
module_platform_driver(snd_byt_rt5640_mc_driver);

View File

@ -85,6 +85,7 @@ struct byt_rt5651_private {
struct gpio_desc *ext_amp_gpio;
struct gpio_desc *hp_detect;
struct snd_soc_jack jack;
struct device *codec_dev;
};
static const struct acpi_gpio_mapping *byt_rt5651_gpios;
@ -527,10 +528,13 @@ static const struct dmi_system_id byt_rt5651_quirk_table[] = {
* Note this MUST be called before snd_soc_register_card(), so that the props
* are in place before the codec component driver's probe function parses them.
*/
static int byt_rt5651_add_codec_device_props(struct device *i2c_dev)
static int byt_rt5651_add_codec_device_props(struct device *i2c_dev,
struct byt_rt5651_private *priv)
{
struct property_entry props[MAX_NO_PROPS] = {};
struct fwnode_handle *fwnode;
int cnt = 0;
int ret;
props[cnt++] = PROPERTY_ENTRY_U32("realtek,jack-detect-source",
BYT_RT5651_JDSRC(byt_rt5651_quirk));
@ -547,7 +551,17 @@ static int byt_rt5651_add_codec_device_props(struct device *i2c_dev)
if (byt_rt5651_quirk & BYT_RT5651_JD_NOT_INV)
props[cnt++] = PROPERTY_ENTRY_BOOL("realtek,jack-detect-not-inverted");
return device_add_properties(i2c_dev, props);
fwnode = fwnode_create_software_node(props, NULL);
if (IS_ERR(fwnode)) {
/* put_device(i2c_dev) is handled in caller */
return PTR_ERR(fwnode);
}
ret = device_add_software_node(i2c_dev, to_software_node(fwnode));
fwnode_handle_put(fwnode);
return ret;
}
static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime)
@ -920,13 +934,13 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
byt_rt5651_dais[dai_index].codecs->name = byt_rt5651_codec_name;
} else {
dev_err(&pdev->dev, "Error cannot find '%s' dev\n", mach->id);
return -ENODEV;
return -ENXIO;
}
codec_dev = bus_find_device_by_name(&i2c_bus_type, NULL,
byt_rt5651_codec_name);
codec_dev = acpi_get_first_physical_node(adev);
if (!codec_dev)
return -EPROBE_DEFER;
priv->codec_dev = get_device(codec_dev);
/*
* swap SSP0 if bytcr is detected
@ -994,11 +1008,9 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
}
/* Must be called before register_card, also see declaration comment. */
ret_val = byt_rt5651_add_codec_device_props(codec_dev);
if (ret_val) {
put_device(codec_dev);
return ret_val;
}
ret_val = byt_rt5651_add_codec_device_props(codec_dev, priv);
if (ret_val)
goto err_device;
/* Cherry Trail devices use an external amplifier enable gpio */
if (soc_intel_is_cht() && !byt_rt5651_gpios)
@ -1022,8 +1034,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
ret_val);
fallthrough;
case -EPROBE_DEFER:
put_device(codec_dev);
return ret_val;
goto err;
}
}
priv->hp_detect = devm_fwnode_gpiod_get(&pdev->dev,
@ -1042,14 +1053,11 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
ret_val);
fallthrough;
case -EPROBE_DEFER:
put_device(codec_dev);
return ret_val;
goto err;
}
}
}
put_device(codec_dev);
log_quirks(&pdev->dev);
if ((byt_rt5651_quirk & BYT_RT5651_SSP2_AIF2) ||
@ -1073,7 +1081,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
* for all other errors, including -EPROBE_DEFER
*/
if (ret_val != -ENOENT)
return ret_val;
goto err;
byt_rt5651_quirk &= ~BYT_RT5651_MCLK_EN;
}
}
@ -1102,7 +1110,7 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
ret_val = snd_soc_fixup_dai_links_platform_name(&byt_rt5651_card,
platform_name);
if (ret_val)
return ret_val;
goto err;
sof_parent = snd_soc_acpi_sof_parent(&pdev->dev);
@ -1124,10 +1132,26 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
if (ret_val) {
dev_err(&pdev->dev, "devm_snd_soc_register_card failed %d\n",
ret_val);
return ret_val;
goto err;
}
platform_set_drvdata(pdev, &byt_rt5651_card);
return ret_val;
err:
device_remove_software_node(priv->codec_dev);
err_device:
put_device(priv->codec_dev);
return ret_val;
}
static int snd_byt_rt5651_mc_remove(struct platform_device *pdev)
{
struct snd_soc_card *card = platform_get_drvdata(pdev);
struct byt_rt5651_private *priv = snd_soc_card_get_drvdata(card);
device_remove_software_node(priv->codec_dev);
put_device(priv->codec_dev);
return 0;
}
static struct platform_driver snd_byt_rt5651_mc_driver = {
@ -1135,6 +1159,7 @@ static struct platform_driver snd_byt_rt5651_mc_driver = {
.name = "bytcr_rt5651",
},
.probe = snd_byt_rt5651_mc_probe,
.remove = snd_byt_rt5651_mc_remove,
};
module_platform_driver(snd_byt_rt5651_mc_driver);

View File

@ -352,7 +352,8 @@ static const struct snd_soc_ops sdw_ops = {
.shutdown = sdw_shutdown,
};
static int sof_sdw_mic_codec_mockup_init(const struct snd_soc_acpi_link_adr *link,
static int sof_sdw_mic_codec_mockup_init(struct snd_soc_card *card,
const struct snd_soc_acpi_link_adr *link,
struct snd_soc_dai_link *dai_links,
struct sof_sdw_codec_info *info,
bool playback)
@ -697,7 +698,8 @@ static int create_codec_dai_name(struct device *dev,
return 0;
}
static int set_codec_init_func(const struct snd_soc_acpi_link_adr *link,
static int set_codec_init_func(struct snd_soc_card *card,
const struct snd_soc_acpi_link_adr *link,
struct snd_soc_dai_link *dai_links,
bool playback, int group_id)
{
@ -720,7 +722,8 @@ static int set_codec_init_func(const struct snd_soc_acpi_link_adr *link,
if (link->adr_d[i].endpoints->group_id != group_id)
continue;
if (codec_info_list[codec_index].init)
codec_info_list[codec_index].init(link,
codec_info_list[codec_index].init(card,
link,
dai_links,
&codec_info_list[codec_index],
playback);
@ -805,7 +808,8 @@ static int get_slave_info(const struct snd_soc_acpi_link_adr *adr_link,
return 0;
}
static int create_sdw_dailink(struct device *dev, int *be_index,
static int create_sdw_dailink(struct snd_soc_card *card,
struct device *dev, int *be_index,
struct snd_soc_dai_link *dai_links,
int sdw_be_num, int sdw_cpu_dai_num,
struct snd_soc_dai_link_component *cpus,
@ -926,7 +930,7 @@ static int create_sdw_dailink(struct device *dev, int *be_index,
codecs, codec_num,
NULL, &sdw_ops);
ret = set_codec_init_func(link, dai_links + (*be_index)++,
ret = set_codec_init_func(card, link, dai_links + (*be_index)++,
playback, group_id);
if (ret < 0) {
dev_err(dev, "failed to init codec %d", codec_index);
@ -1107,7 +1111,7 @@ static int sof_card_dai_links_create(struct device *dev,
group_generated[endpoint->group_id])
continue;
ret = create_sdw_dailink(dev, &be_id, links, sdw_be_num,
ret = create_sdw_dailink(card, dev, &be_id, links, sdw_be_num,
sdw_cpu_dai_num, cpus, adr_link,
&cpu_id, group_generated,
codec_conf, codec_conf_count,
@ -1170,7 +1174,7 @@ SSP:
ssp_components, 1,
NULL, info->ops);
ret = info->init(NULL, links + link_id, info, 0);
ret = info->init(card, NULL, links + link_id, info, 0);
if (ret < 0)
return ret;
@ -1393,7 +1397,7 @@ static int mc_remove(struct platform_device *pdev)
for_each_card_prelinks(card, j, link) {
if (!strcmp(link->codecs[0].dai_name,
codec_info_list[i].dai_name)) {
ret = codec_info_list[i].exit(&pdev->dev, link);
ret = codec_info_list[i].exit(card, link);
if (ret)
dev_warn(&pdev->dev,
"codec exit failed %d\n",

View File

@ -62,12 +62,13 @@ struct sof_sdw_codec_info {
const char *dai_name;
const struct snd_soc_ops *ops;
int (*init)(const struct snd_soc_acpi_link_adr *link,
int (*init)(struct snd_soc_card *card,
const struct snd_soc_acpi_link_adr *link,
struct snd_soc_dai_link *dai_links,
struct sof_sdw_codec_info *info,
bool playback);
int (*exit)(struct device *dev, struct snd_soc_dai_link *dai_link);
int (*exit)(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link);
bool late_probe;
int (*codec_card_late_probe)(struct snd_soc_card *card);
};
@ -76,6 +77,7 @@ struct mc_private {
struct list_head hdmi_pcm_list;
bool idisp_codec;
struct snd_soc_jack sdw_headset;
struct device *headset_codec_dev; /* only one headset per card */
};
extern unsigned long sof_sdw_quirk;
@ -95,21 +97,24 @@ int sof_sdw_hdmi_card_late_probe(struct snd_soc_card *card);
int sof_sdw_dmic_init(struct snd_soc_pcm_runtime *rtd);
/* RT711 support */
int sof_sdw_rt711_init(const struct snd_soc_acpi_link_adr *link,
int sof_sdw_rt711_init(struct snd_soc_card *card,
const struct snd_soc_acpi_link_adr *link,
struct snd_soc_dai_link *dai_links,
struct sof_sdw_codec_info *info,
bool playback);
int sof_sdw_rt711_exit(struct device *dev, struct snd_soc_dai_link *dai_link);
int sof_sdw_rt711_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link);
/* RT711-SDCA support */
int sof_sdw_rt711_sdca_init(const struct snd_soc_acpi_link_adr *link,
int sof_sdw_rt711_sdca_init(struct snd_soc_card *card,
const struct snd_soc_acpi_link_adr *link,
struct snd_soc_dai_link *dai_links,
struct sof_sdw_codec_info *info,
bool playback);
int sof_sdw_rt711_sdca_exit(struct device *dev, struct snd_soc_dai_link *dai_link);
int sof_sdw_rt711_sdca_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link);
/* RT700 support */
int sof_sdw_rt700_init(const struct snd_soc_acpi_link_adr *link,
int sof_sdw_rt700_init(struct snd_soc_card *card,
const struct snd_soc_acpi_link_adr *link,
struct snd_soc_dai_link *dai_links,
struct sof_sdw_codec_info *info,
bool playback);
@ -117,31 +122,36 @@ int sof_sdw_rt700_init(const struct snd_soc_acpi_link_adr *link,
/* RT1308 support */
extern struct snd_soc_ops sof_sdw_rt1308_i2s_ops;
int sof_sdw_rt1308_init(const struct snd_soc_acpi_link_adr *link,
int sof_sdw_rt1308_init(struct snd_soc_card *card,
const struct snd_soc_acpi_link_adr *link,
struct snd_soc_dai_link *dai_links,
struct sof_sdw_codec_info *info,
bool playback);
/* RT1316 support */
int sof_sdw_rt1316_init(const struct snd_soc_acpi_link_adr *link,
int sof_sdw_rt1316_init(struct snd_soc_card *card,
const struct snd_soc_acpi_link_adr *link,
struct snd_soc_dai_link *dai_links,
struct sof_sdw_codec_info *info,
bool playback);
/* RT715 support */
int sof_sdw_rt715_init(const struct snd_soc_acpi_link_adr *link,
int sof_sdw_rt715_init(struct snd_soc_card *card,
const struct snd_soc_acpi_link_adr *link,
struct snd_soc_dai_link *dai_links,
struct sof_sdw_codec_info *info,
bool playback);
/* RT715-SDCA support */
int sof_sdw_rt715_sdca_init(const struct snd_soc_acpi_link_adr *link,
int sof_sdw_rt715_sdca_init(struct snd_soc_card *card,
const struct snd_soc_acpi_link_adr *link,
struct snd_soc_dai_link *dai_links,
struct sof_sdw_codec_info *info,
bool playback);
/* MAX98373 support */
int sof_sdw_mx8373_init(const struct snd_soc_acpi_link_adr *link,
int sof_sdw_mx8373_init(struct snd_soc_card *card,
const struct snd_soc_acpi_link_adr *link,
struct snd_soc_dai_link *dai_links,
struct sof_sdw_codec_info *info,
bool playback);
@ -149,7 +159,8 @@ int sof_sdw_mx8373_init(const struct snd_soc_acpi_link_adr *link,
int sof_sdw_mx8373_late_probe(struct snd_soc_card *card);
/* RT5682 support */
int sof_sdw_rt5682_init(const struct snd_soc_acpi_link_adr *link,
int sof_sdw_rt5682_init(struct snd_soc_card *card,
const struct snd_soc_acpi_link_adr *link,
struct snd_soc_dai_link *dai_links,
struct sof_sdw_codec_info *info,
bool playback);

View File

@ -120,7 +120,8 @@ static const struct snd_soc_ops max_98373_sdw_ops = {
.shutdown = sdw_shutdown,
};
int sof_sdw_mx8373_init(const struct snd_soc_acpi_link_adr *link,
int sof_sdw_mx8373_init(struct snd_soc_card *card,
const struct snd_soc_acpi_link_adr *link,
struct snd_soc_dai_link *dai_links,
struct sof_sdw_codec_info *info,
bool playback)

View File

@ -127,7 +127,8 @@ struct snd_soc_ops sof_sdw_rt1308_i2s_ops = {
.hw_params = rt1308_i2s_hw_params,
};
int sof_sdw_rt1308_init(const struct snd_soc_acpi_link_adr *link,
int sof_sdw_rt1308_init(struct snd_soc_card *card,
const struct snd_soc_acpi_link_adr *link,
struct snd_soc_dai_link *dai_links,
struct sof_sdw_codec_info *info,
bool playback)

View File

@ -89,7 +89,8 @@ static int all_spk_init(struct snd_soc_pcm_runtime *rtd)
return second_spk_init(rtd);
}
int sof_sdw_rt1316_init(const struct snd_soc_acpi_link_adr *link,
int sof_sdw_rt1316_init(struct snd_soc_card *card,
const struct snd_soc_acpi_link_adr *link,
struct snd_soc_dai_link *dai_links,
struct sof_sdw_codec_info *info,
bool playback)

View File

@ -111,7 +111,8 @@ static int rt5682_rtd_init(struct snd_soc_pcm_runtime *rtd)
return ret;
}
int sof_sdw_rt5682_init(const struct snd_soc_acpi_link_adr *link,
int sof_sdw_rt5682_init(struct snd_soc_card *card,
const struct snd_soc_acpi_link_adr *link,
struct snd_soc_dai_link *dai_links,
struct sof_sdw_codec_info *info,
bool playback)

View File

@ -110,7 +110,8 @@ static int rt700_rtd_init(struct snd_soc_pcm_runtime *rtd)
return ret;
}
int sof_sdw_rt700_init(const struct snd_soc_acpi_link_adr *link,
int sof_sdw_rt700_init(struct snd_soc_card *card,
const struct snd_soc_acpi_link_adr *link,
struct snd_soc_dai_link *dai_links,
struct sof_sdw_codec_info *info,
bool playback)

View File

@ -21,23 +21,23 @@
* Note this MUST be called before snd_soc_register_card(), so that the props
* are in place before the codec component driver's probe function parses them.
*/
static int rt711_add_codec_device_props(const char *sdw_dev_name)
static int rt711_add_codec_device_props(struct device *sdw_dev)
{
struct property_entry props[MAX_NO_PROPS] = {};
struct device *sdw_dev;
struct fwnode_handle *fwnode;
int ret;
sdw_dev = bus_find_device_by_name(&sdw_bus_type, NULL, sdw_dev_name);
if (!sdw_dev)
return -EPROBE_DEFER;
if (!SOF_RT711_JDSRC(sof_sdw_quirk))
return 0;
props[0] = PROPERTY_ENTRY_U32("realtek,jd-src", SOF_RT711_JDSRC(sof_sdw_quirk));
if (SOF_RT711_JDSRC(sof_sdw_quirk)) {
props[0] = PROPERTY_ENTRY_U32("realtek,jd-src",
SOF_RT711_JDSRC(sof_sdw_quirk));
}
fwnode = fwnode_create_software_node(props, NULL);
if (IS_ERR(fwnode))
return PTR_ERR(fwnode);
ret = device_add_properties(sdw_dev, props);
put_device(sdw_dev);
ret = device_add_software_node(sdw_dev, to_software_node(fwnode));
fwnode_handle_put(fwnode);
return ret;
}
@ -135,26 +135,24 @@ static int rt711_rtd_init(struct snd_soc_pcm_runtime *rtd)
return ret;
}
int sof_sdw_rt711_exit(struct device *dev, struct snd_soc_dai_link *dai_link)
int sof_sdw_rt711_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link)
{
struct device *sdw_dev;
struct mc_private *ctx = snd_soc_card_get_drvdata(card);
sdw_dev = bus_find_device_by_name(&sdw_bus_type, NULL,
dai_link->codecs[0].name);
if (!sdw_dev)
return -EINVAL;
device_remove_properties(sdw_dev);
put_device(sdw_dev);
device_remove_software_node(ctx->headset_codec_dev);
put_device(ctx->headset_codec_dev);
return 0;
}
int sof_sdw_rt711_init(const struct snd_soc_acpi_link_adr *link,
int sof_sdw_rt711_init(struct snd_soc_card *card,
const struct snd_soc_acpi_link_adr *link,
struct snd_soc_dai_link *dai_links,
struct sof_sdw_codec_info *info,
bool playback)
{
struct mc_private *ctx = snd_soc_card_get_drvdata(card);
struct device *sdw_dev;
int ret;
/*
@ -164,9 +162,16 @@ int sof_sdw_rt711_init(const struct snd_soc_acpi_link_adr *link,
if (!playback)
return 0;
ret = rt711_add_codec_device_props(dai_links->codecs[0].name);
if (ret < 0)
sdw_dev = bus_find_device_by_name(&sdw_bus_type, NULL, dai_links->codecs[0].name);
if (!sdw_dev)
return -EPROBE_DEFER;
ret = rt711_add_codec_device_props(sdw_dev);
if (ret < 0) {
put_device(sdw_dev);
return ret;
}
ctx->headset_codec_dev = sdw_dev;
dai_links->init = rt711_rtd_init;

View File

@ -21,23 +21,24 @@
* Note this MUST be called before snd_soc_register_card(), so that the props
* are in place before the codec component driver's probe function parses them.
*/
static int rt711_sdca_add_codec_device_props(const char *sdw_dev_name)
static int rt711_sdca_add_codec_device_props(struct device *sdw_dev)
{
struct property_entry props[MAX_NO_PROPS] = {};
struct device *sdw_dev;
struct fwnode_handle *fwnode;
int ret;
sdw_dev = bus_find_device_by_name(&sdw_bus_type, NULL, sdw_dev_name);
if (!sdw_dev)
return -EPROBE_DEFER;
if (!SOF_RT711_JDSRC(sof_sdw_quirk))
return 0;
if (SOF_RT711_JDSRC(sof_sdw_quirk)) {
props[0] = PROPERTY_ENTRY_U32("realtek,jd-src",
SOF_RT711_JDSRC(sof_sdw_quirk));
}
props[0] = PROPERTY_ENTRY_U32("realtek,jd-src", SOF_RT711_JDSRC(sof_sdw_quirk));
ret = device_add_properties(sdw_dev, props);
put_device(sdw_dev);
fwnode = fwnode_create_software_node(props, NULL);
if (IS_ERR(fwnode))
return PTR_ERR(fwnode);
ret = device_add_software_node(sdw_dev, to_software_node(fwnode));
fwnode_handle_put(fwnode);
return ret;
}
@ -135,26 +136,24 @@ static int rt711_sdca_rtd_init(struct snd_soc_pcm_runtime *rtd)
return ret;
}
int sof_sdw_rt711_sdca_exit(struct device *dev, struct snd_soc_dai_link *dai_link)
int sof_sdw_rt711_sdca_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link)
{
struct device *sdw_dev;
struct mc_private *ctx = snd_soc_card_get_drvdata(card);
sdw_dev = bus_find_device_by_name(&sdw_bus_type, NULL,
dai_link->codecs[0].name);
if (!sdw_dev)
return -EINVAL;
device_remove_properties(sdw_dev);
put_device(sdw_dev);
device_remove_software_node(ctx->headset_codec_dev);
put_device(ctx->headset_codec_dev);
return 0;
}
int sof_sdw_rt711_sdca_init(const struct snd_soc_acpi_link_adr *link,
int sof_sdw_rt711_sdca_init(struct snd_soc_card *card,
const struct snd_soc_acpi_link_adr *link,
struct snd_soc_dai_link *dai_links,
struct sof_sdw_codec_info *info,
bool playback)
{
struct mc_private *ctx = snd_soc_card_get_drvdata(card);
struct device *sdw_dev;
int ret;
/*
@ -164,9 +163,16 @@ int sof_sdw_rt711_sdca_init(const struct snd_soc_acpi_link_adr *link,
if (!playback)
return 0;
ret = rt711_sdca_add_codec_device_props(dai_links->codecs[0].name);
if (ret < 0)
sdw_dev = bus_find_device_by_name(&sdw_bus_type, NULL, dai_links->codecs[0].name);
if (!sdw_dev)
return -EPROBE_DEFER;
ret = rt711_sdca_add_codec_device_props(sdw_dev);
if (ret < 0) {
put_device(sdw_dev);
return ret;
}
ctx->headset_codec_dev = sdw_dev;
dai_links->init = rt711_sdca_rtd_init;

View File

@ -24,7 +24,8 @@ static int rt715_rtd_init(struct snd_soc_pcm_runtime *rtd)
return 0;
}
int sof_sdw_rt715_init(const struct snd_soc_acpi_link_adr *link,
int sof_sdw_rt715_init(struct snd_soc_card *card,
const struct snd_soc_acpi_link_adr *link,
struct snd_soc_dai_link *dai_links,
struct sof_sdw_codec_info *info,
bool playback)

View File

@ -24,7 +24,8 @@ static int rt715_sdca_rtd_init(struct snd_soc_pcm_runtime *rtd)
return 0;
}
int sof_sdw_rt715_sdca_init(const struct snd_soc_acpi_link_adr *link,
int sof_sdw_rt715_sdca_init(struct snd_soc_card *card,
const struct snd_soc_acpi_link_adr *link,
struct snd_soc_dai_link *dai_links,
struct sof_sdw_codec_info *info,
bool playback)