Skip to content

Commit

Permalink
ASoC: intel/sdw_utils: move rt700 and rt711 codec helper functions
Browse files Browse the repository at this point in the history
Move RT700 and RT711 Soundwire codec helper functions to common
place holder so that it can be used by other platform machine driver.

Link: thesofproject#5068
Signed-off-by: Vijendar Mukunda <[email protected]>
Reviewed-by: Bard Liao <[email protected]>
Reviewed-by: Pierre-Louis Bossart <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
vijendarmukunda authored and broonie committed Aug 1, 2024
1 parent da5b183 commit 8e84fd2
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 20 deletions.
9 changes: 9 additions & 0 deletions include/sound/soc_sdw_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ const char *asoc_sdw_get_codec_name(struct device *dev,
/* DMIC support */
int asoc_sdw_dmic_init(struct snd_soc_pcm_runtime *rtd);

/* RT711 support */
int asoc_sdw_rt711_init(struct snd_soc_card *card,
struct snd_soc_dai_link *dai_links,
struct asoc_sdw_codec_info *info,
bool playback);
int asoc_sdw_rt711_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link);

/* RT711-SDCA support */
int asoc_sdw_rt_sdca_jack_init(struct snd_soc_card *card,
struct snd_soc_dai_link *dai_links,
Expand All @@ -95,6 +102,8 @@ int asoc_sdw_rt_sdca_jack_exit(struct snd_soc_card *card, struct snd_soc_dai_lin
/* dai_link init callbacks */
int asoc_sdw_rt_dmic_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
int asoc_sdw_rt_sdca_jack_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
int asoc_sdw_rt700_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
int asoc_sdw_rt711_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
int asoc_sdw_rt712_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
int asoc_sdw_rt722_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
int asoc_sdw_rt5682_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
Expand Down
1 change: 0 additions & 1 deletion sound/soc/intel/boards/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ snd-soc-sof-ssp-amp-y := sof_ssp_amp.o
snd-soc-sof-sdw-y += sof_sdw.o \
sof_sdw_maxim.o sof_sdw_rt_amp.o \
bridge_cs35l56.o \
sof_sdw_rt700.o sof_sdw_rt711.o \
sof_sdw_cs42l42.o sof_sdw_cs42l43.o \
sof_sdw_cs_amp.o \
sof_sdw_hdmi.o
Expand Down
9 changes: 0 additions & 9 deletions sound/soc/intel/boards/sof_sdw_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,6 @@ int sof_sdw_hdmi_init(struct snd_soc_pcm_runtime *rtd);

int sof_sdw_hdmi_card_late_probe(struct snd_soc_card *card);

/* RT711 support */
int asoc_sdw_rt711_init(struct snd_soc_card *card,
struct snd_soc_dai_link *dai_links,
struct asoc_sdw_codec_info *info,
bool playback);
int asoc_sdw_rt711_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link);

/* RT1308 I2S support */
extern const struct snd_soc_ops soc_sdw_rt1308_i2s_ops;

Expand Down Expand Up @@ -142,8 +135,6 @@ int asoc_sdw_cs42l43_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_so
int asoc_sdw_cs42l43_dmic_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
int asoc_sdw_cs_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
int asoc_sdw_maxim_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
int asoc_sdw_rt700_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
int asoc_sdw_rt711_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);
int asoc_sdw_rt_amp_spk_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai);

#endif
1 change: 1 addition & 0 deletions sound/soc/sdw_utils/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# SPDX-License-Identifier: GPL-2.0-only
snd-soc-sdw-utils-y := soc_sdw_utils.o soc_sdw_dmic.o soc_sdw_rt_dmic.o \
soc_sdw_rt700.o soc_sdw_rt711.o \
soc_sdw_rt712_sdca.o soc_sdw_rt722_sdca.o \
soc_sdw_rt5682.o soc_sdw_rt_sdca_jack_common.o
obj-$(CONFIG_SND_SOC_SDW_UTILS) += snd-soc-sdw-utils.o
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// SPDX-License-Identifier: GPL-2.0-only
// This file incorporates work covered by the following copyright notice:
// Copyright (c) 2020 Intel Corporation
// Copyright (c) 2024 Advanced Micro Devices, Inc.

/*
* sof_sdw_rt700 - Helpers to handle RT700 from generic machine driver
* soc_sdw_rt700 - Helpers to handle RT700 from generic machine driver
*/

#include <linux/device.h>
Expand All @@ -13,7 +15,7 @@
#include <sound/soc-acpi.h>
#include <sound/soc-dapm.h>
#include <sound/jack.h>
#include "sof_sdw_common.h"
#include <sound/soc_sdw_utils.h>

static const struct snd_soc_dapm_route rt700_map[] = {
/* Headphones */
Expand Down Expand Up @@ -83,4 +85,4 @@ int asoc_sdw_rt700_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai

return ret;
}
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_BOARD_HELPERS);
EXPORT_SYMBOL_NS(asoc_sdw_rt700_rtd_init, SND_SOC_SDW_UTILS);
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// SPDX-License-Identifier: GPL-2.0-only
// This file incorporates work covered by the following copyright notice:
// Copyright (c) 2020 Intel Corporation
// Copyright (c) 2024 Advanced Micro Devices, Inc.

/*
* sof_sdw_rt711 - Helpers to handle RT711 from generic machine driver
* soc_sdw_rt711 - Helpers to handle RT711 from generic machine driver
*/

#include <linux/device.h>
Expand All @@ -15,21 +17,21 @@
#include <sound/soc-acpi.h>
#include <sound/soc-dapm.h>
#include <sound/jack.h>
#include "sof_sdw_common.h"
#include <sound/soc_sdw_utils.h>

/*
* 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(struct device *sdw_dev)
static int rt711_add_codec_device_props(struct device *sdw_dev, unsigned long quirk)
{
struct property_entry props[SOC_SDW_MAX_NO_PROPS] = {};
struct fwnode_handle *fwnode;
int ret;

if (!SOC_SDW_JACK_JDSRC(sof_sdw_quirk))
if (!SOC_SDW_JACK_JDSRC(quirk))
return 0;
props[0] = PROPERTY_ENTRY_U32("realtek,jd-src", SOC_SDW_JACK_JDSRC(sof_sdw_quirk));
props[0] = PROPERTY_ENTRY_U32("realtek,jd-src", SOC_SDW_JACK_JDSRC(quirk));

fwnode = fwnode_create_software_node(props, NULL);
if (IS_ERR(fwnode))
Expand Down Expand Up @@ -110,6 +112,7 @@ int asoc_sdw_rt711_rtd_init(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai

return ret;
}
EXPORT_SYMBOL_NS(asoc_sdw_rt711_rtd_init, SND_SOC_SDW_UTILS);

int asoc_sdw_rt711_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link)
{
Expand All @@ -123,6 +126,7 @@ int asoc_sdw_rt711_exit(struct snd_soc_card *card, struct snd_soc_dai_link *dai_

return 0;
}
EXPORT_SYMBOL_NS(asoc_sdw_rt711_exit, SND_SOC_SDW_UTILS);

int asoc_sdw_rt711_init(struct snd_soc_card *card,
struct snd_soc_dai_link *dai_links,
Expand All @@ -144,7 +148,7 @@ int asoc_sdw_rt711_init(struct snd_soc_card *card,
if (!sdw_dev)
return -EPROBE_DEFER;

ret = rt711_add_codec_device_props(sdw_dev);
ret = rt711_add_codec_device_props(sdw_dev, ctx->mc_quirk);
if (ret < 0) {
put_device(sdw_dev);
return ret;
Expand All @@ -153,4 +157,4 @@ int asoc_sdw_rt711_init(struct snd_soc_card *card,

return 0;
}
MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_BOARD_HELPERS);
EXPORT_SYMBOL_NS(asoc_sdw_rt711_init, SND_SOC_SDW_UTILS);

0 comments on commit 8e84fd2

Please sign in to comment.