Commit 43fb2919 authored by Mark Brown's avatar Mark Brown

Merge series "ASoC: Intel: bytcr_rt5640: Add support for devices with only a...

Merge series "ASoC: Intel: bytcr_rt5640: Add support for devices with only a headphone jack (no speakers/mic)" from Hans de Goede <hdegoede@redhat.com>:

Hi All,

This series adds support for devices with only a headphone jack
(no speakers/internal mic). Specifically this adds support for the
Mele PCG03 Mini PC. But the new no-speakers and no-internal-mic quirks
will likely be useful on other devices too.

Regards,

Hans
parents 8b66d7c5 df330321
...@@ -35,6 +35,7 @@ enum { ...@@ -35,6 +35,7 @@ enum {
BYT_RT5640_DMIC2_MAP, BYT_RT5640_DMIC2_MAP,
BYT_RT5640_IN1_MAP, BYT_RT5640_IN1_MAP,
BYT_RT5640_IN3_MAP, BYT_RT5640_IN3_MAP,
BYT_RT5640_NO_INTERNAL_MIC_MAP,
}; };
enum { enum {
...@@ -71,6 +72,7 @@ enum { ...@@ -71,6 +72,7 @@ enum {
#define BYT_RT5640_SSP0_AIF2 BIT(21) #define BYT_RT5640_SSP0_AIF2 BIT(21)
#define BYT_RT5640_MCLK_EN BIT(22) #define BYT_RT5640_MCLK_EN BIT(22)
#define BYT_RT5640_MCLK_25MHZ BIT(23) #define BYT_RT5640_MCLK_25MHZ BIT(23)
#define BYT_RT5640_NO_SPEAKERS BIT(24)
#define BYTCR_INPUT_DEFAULTS \ #define BYTCR_INPUT_DEFAULTS \
(BYT_RT5640_IN3_MAP | \ (BYT_RT5640_IN3_MAP | \
...@@ -116,6 +118,9 @@ static void log_quirks(struct device *dev) ...@@ -116,6 +118,9 @@ static void log_quirks(struct device *dev)
case BYT_RT5640_IN3_MAP: case BYT_RT5640_IN3_MAP:
dev_info(dev, "quirk IN3_MAP enabled\n"); dev_info(dev, "quirk IN3_MAP enabled\n");
break; break;
case BYT_RT5640_NO_INTERNAL_MIC_MAP:
dev_info(dev, "quirk NO_INTERNAL_MIC_MAP enabled\n");
break;
default: default:
dev_err(dev, "quirk map 0x%x is not supported, microphone input will not work\n", map); dev_err(dev, "quirk map 0x%x is not supported, microphone input will not work\n", map);
break; break;
...@@ -132,6 +137,8 @@ static void log_quirks(struct device *dev) ...@@ -132,6 +137,8 @@ static void log_quirks(struct device *dev)
dev_info(dev, "quirk JD_NOT_INV enabled\n"); dev_info(dev, "quirk JD_NOT_INV enabled\n");
if (byt_rt5640_quirk & BYT_RT5640_MONO_SPEAKER) if (byt_rt5640_quirk & BYT_RT5640_MONO_SPEAKER)
dev_info(dev, "quirk MONO_SPEAKER enabled\n"); dev_info(dev, "quirk MONO_SPEAKER enabled\n");
if (byt_rt5640_quirk & BYT_RT5640_NO_SPEAKERS)
dev_info(dev, "quirk NO_SPEAKERS enabled\n");
if (byt_rt5640_quirk & BYT_RT5640_DIFF_MIC) if (byt_rt5640_quirk & BYT_RT5640_DIFF_MIC)
dev_info(dev, "quirk DIFF_MIC enabled\n"); dev_info(dev, "quirk DIFF_MIC enabled\n");
if (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) { if (byt_rt5640_quirk & BYT_RT5640_SSP0_AIF1) {
...@@ -613,6 +620,15 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = { ...@@ -613,6 +620,15 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = {
BYT_RT5640_SSP0_AIF1 | BYT_RT5640_SSP0_AIF1 |
BYT_RT5640_MCLK_EN), BYT_RT5640_MCLK_EN),
}, },
{ /* Mele PCG03 Mini PC */
.matches = {
DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Mini PC"),
DMI_EXACT_MATCH(DMI_BOARD_NAME, "Mini PC"),
},
.driver_data = (void *)(BYT_RT5640_NO_INTERNAL_MIC_MAP |
BYT_RT5640_NO_SPEAKERS |
BYT_RT5640_SSP0_AIF1),
},
{ /* MPMAN Converter 9, similar hw as the I.T.Works TW891 2-in-1 */ { /* MPMAN Converter 9, similar hw as the I.T.Works TW891 2-in-1 */
.matches = { .matches = {
DMI_MATCH(DMI_SYS_VENDOR, "MPMAN"), DMI_MATCH(DMI_SYS_VENDOR, "MPMAN"),
...@@ -873,8 +889,8 @@ static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime) ...@@ -873,8 +889,8 @@ static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime)
struct snd_soc_card *card = runtime->card; struct snd_soc_card *card = runtime->card;
struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card); struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card);
struct snd_soc_component *component = asoc_rtd_to_codec(runtime, 0)->component; struct snd_soc_component *component = asoc_rtd_to_codec(runtime, 0)->component;
const struct snd_soc_dapm_route *custom_map; const struct snd_soc_dapm_route *custom_map = NULL;
int num_routes; int num_routes = 0;
int ret; int ret;
card->dapm.idle_bias_off = true; card->dapm.idle_bias_off = true;
...@@ -909,13 +925,14 @@ static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime) ...@@ -909,13 +925,14 @@ static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime)
custom_map = byt_rt5640_intmic_in3_map; custom_map = byt_rt5640_intmic_in3_map;
num_routes = ARRAY_SIZE(byt_rt5640_intmic_in3_map); num_routes = ARRAY_SIZE(byt_rt5640_intmic_in3_map);
break; break;
case BYT_RT5640_DMIC1_MAP:
custom_map = byt_rt5640_intmic_dmic1_map;
num_routes = ARRAY_SIZE(byt_rt5640_intmic_dmic1_map);
break;
case BYT_RT5640_DMIC2_MAP: case BYT_RT5640_DMIC2_MAP:
custom_map = byt_rt5640_intmic_dmic2_map; custom_map = byt_rt5640_intmic_dmic2_map;
num_routes = ARRAY_SIZE(byt_rt5640_intmic_dmic2_map); num_routes = ARRAY_SIZE(byt_rt5640_intmic_dmic2_map);
break; break;
default:
custom_map = byt_rt5640_intmic_dmic1_map;
num_routes = ARRAY_SIZE(byt_rt5640_intmic_dmic1_map);
} }
ret = snd_soc_dapm_add_routes(&card->dapm, custom_map, num_routes); ret = snd_soc_dapm_add_routes(&card->dapm, custom_map, num_routes);
...@@ -946,7 +963,7 @@ static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime) ...@@ -946,7 +963,7 @@ static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime)
ret = snd_soc_dapm_add_routes(&card->dapm, ret = snd_soc_dapm_add_routes(&card->dapm,
byt_rt5640_mono_spk_map, byt_rt5640_mono_spk_map,
ARRAY_SIZE(byt_rt5640_mono_spk_map)); ARRAY_SIZE(byt_rt5640_mono_spk_map));
} else { } else if (!(byt_rt5640_quirk & BYT_RT5640_NO_SPEAKERS)) {
ret = snd_soc_dapm_add_routes(&card->dapm, ret = snd_soc_dapm_add_routes(&card->dapm,
byt_rt5640_stereo_spk_map, byt_rt5640_stereo_spk_map,
ARRAY_SIZE(byt_rt5640_stereo_spk_map)); ARRAY_SIZE(byt_rt5640_stereo_spk_map));
...@@ -1187,7 +1204,8 @@ struct acpi_chan_package { /* ACPICA seems to require 64 bit integers */ ...@@ -1187,7 +1204,8 @@ struct acpi_chan_package { /* ACPICA seems to require 64 bit integers */
static int snd_byt_rt5640_mc_probe(struct platform_device *pdev) static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
static const char * const map_name[] = { "dmic1", "dmic2", "in1", "in3" }; static const char * const map_name[] = { "dmic1", "dmic2", "in1", "in3", "none" };
__maybe_unused const char *spk_type;
const struct dmi_system_id *dmi_id; const struct dmi_system_id *dmi_id;
struct byt_rt5640_private *priv; struct byt_rt5640_private *priv;
struct snd_soc_acpi_mach *mach; struct snd_soc_acpi_mach *mach;
...@@ -1196,7 +1214,7 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev) ...@@ -1196,7 +1214,7 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
bool sof_parent; bool sof_parent;
int ret_val = 0; int ret_val = 0;
int dai_index = 0; int dai_index = 0;
int i; int i, cfg_spk;
is_bytcr = false; is_bytcr = false;
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
...@@ -1335,16 +1353,24 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev) ...@@ -1335,16 +1353,24 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
} }
} }
if (byt_rt5640_quirk & BYT_RT5640_NO_SPEAKERS) {
cfg_spk = 0;
spk_type = "none";
} else if (byt_rt5640_quirk & BYT_RT5640_MONO_SPEAKER) {
cfg_spk = 1;
spk_type = "mono";
} else {
cfg_spk = 2;
spk_type = "stereo";
}
snprintf(byt_rt5640_components, sizeof(byt_rt5640_components), snprintf(byt_rt5640_components, sizeof(byt_rt5640_components),
"cfg-spk:%s cfg-mic:%s", "cfg-spk:%d cfg-mic:%s", cfg_spk,
(byt_rt5640_quirk & BYT_RT5640_MONO_SPEAKER) ? "1" : "2",
map_name[BYT_RT5640_MAP(byt_rt5640_quirk)]); map_name[BYT_RT5640_MAP(byt_rt5640_quirk)]);
byt_rt5640_card.components = byt_rt5640_components; byt_rt5640_card.components = byt_rt5640_components;
#if !IS_ENABLED(CONFIG_SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES) #if !IS_ENABLED(CONFIG_SND_SOC_INTEL_USER_FRIENDLY_LONG_NAMES)
snprintf(byt_rt5640_long_name, sizeof(byt_rt5640_long_name), snprintf(byt_rt5640_long_name, sizeof(byt_rt5640_long_name),
"bytcr-rt5640-%s-spk-%s-mic", "bytcr-rt5640-%s-spk-%s-mic", spk_type,
(byt_rt5640_quirk & BYT_RT5640_MONO_SPEAKER) ?
"mono" : "stereo",
map_name[BYT_RT5640_MAP(byt_rt5640_quirk)]); map_name[BYT_RT5640_MAP(byt_rt5640_quirk)]);
byt_rt5640_card.long_name = byt_rt5640_long_name; byt_rt5640_card.long_name = byt_rt5640_long_name;
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment