From patchwork Wed Dec 12 09:25:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hui Wang X-Patchwork-Id: 1011704 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43FBJV1vrSz9sDr; Wed, 12 Dec 2018 20:26:18 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1gX0mT-0000Hh-3Y; Wed, 12 Dec 2018 09:26:13 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1gX0mQ-0000G6-2j for kernel-team@lists.ubuntu.com; Wed, 12 Dec 2018 09:26:10 +0000 Received: from [125.35.49.90] (helo=hwang4-Lenovo-V480c.bluefin) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1gX0mP-0002iI-5v for kernel-team@lists.ubuntu.com; Wed, 12 Dec 2018 09:26:09 +0000 From: Hui Wang To: kernel-team@lists.ubuntu.com Subject: [SRU][Bionic/OEM-B][PATCH 1/6] UBUNTU: SAUCE: ASoC: Intel: kbl: (no-up) Add Kabylake machine driver for RT5660 Date: Wed, 12 Dec 2018 17:25:54 +0800 Message-Id: <20181212092600.4505-2-hui.wang@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181212092600.4505-1-hui.wang@canonical.com> References: <20181212092600.4505-1-hui.wang@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Shrirang Bagul BugLink: https://bugs.launchpad.net/bugs/1807334 Signed-off-by: Shrirang Bagul Signed-off-by: Hui Wang --- sound/soc/intel/boards/Kconfig | 13 + sound/soc/intel/boards/Makefile | 2 + sound/soc/intel/boards/kbl_rt5660.c | 535 ++++++++++++++++++++++++++++ 3 files changed, 550 insertions(+) create mode 100644 sound/soc/intel/boards/kbl_rt5660.c diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig index afe8c3514c5e..590be8dfb211 100644 --- a/sound/soc/intel/boards/Kconfig +++ b/sound/soc/intel/boards/Kconfig @@ -243,6 +243,19 @@ config SND_SOC_INTEL_BXT_RT298_MACH Say Y if you have such a device. If unsure select "N". +config SND_SOC_INTEL_KBL_RT5660_MACH + tristate "ASoC Audio driver for KBL with RT5660 in I2S Mode" + depends on X86_INTEL_LPSS && I2C + select SND_SOC_INTEL_SST + depends on SND_SOC_INTEL_SKYLAKE + select SND_SOC_RT5660 + select SND_SOC_HDAC_HDMI + help + This adds support for ASoC Onboard Codec I2S machine driver. This will + create an alsa sound card for RT5660 (ALC3277) . + Say Y if you have such a device. + If unsure select "N". + config SND_SOC_INTEL_KBL_RT5663_MAX98927_MACH tristate "ASoC Audio driver for KBL with RT5663 and MAX98927 in I2S Mode" depends on X86_INTEL_LPSS && I2C diff --git a/sound/soc/intel/boards/Makefile b/sound/soc/intel/boards/Makefile index b803c5148a0b..edcd62475c55 100644 --- a/sound/soc/intel/boards/Makefile +++ b/sound/soc/intel/boards/Makefile @@ -15,6 +15,7 @@ snd-soc-sst-cht-bsw-max98090_ti-objs := cht_bsw_max98090_ti.o snd-soc-sst-byt-cht-da7213-objs := bytcht_da7213.o snd-soc-sst-byt-cht-es8316-objs := bytcht_es8316.o snd-soc-sst-byt-cht-nocodec-objs := bytcht_nocodec.o +snd-soc-kbl_rt5660-objs := kbl_rt5660.o snd-soc-kbl_rt5663_max98927-objs := kbl_rt5663_max98927.o snd-soc-kbl_rt5663_rt5514_max98927-objs := kbl_rt5663_rt5514_max98927.o snd-soc-skl_rt286-objs := skl_rt286.o @@ -37,6 +38,7 @@ obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_MAX98090_TI_MACH) += snd-soc-sst-cht-bsw-max9 obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_DA7213_MACH) += snd-soc-sst-byt-cht-da7213.o obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_ES8316_MACH) += snd-soc-sst-byt-cht-es8316.o obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH) += snd-soc-sst-byt-cht-nocodec.o +obj-$(CONFIG_SND_SOC_INTEL_KBL_RT5660_MACH) += snd-soc-kbl_rt5660.o obj-$(CONFIG_SND_SOC_INTEL_KBL_RT5663_MAX98927_MACH) += snd-soc-kbl_rt5663_max98927.o obj-$(CONFIG_SND_SOC_INTEL_KBL_RT5663_RT5514_MAX98927_MACH) += snd-soc-kbl_rt5663_rt5514_max98927.o obj-$(CONFIG_SND_SOC_INTEL_SKL_RT286_MACH) += snd-soc-skl_rt286.o diff --git a/sound/soc/intel/boards/kbl_rt5660.c b/sound/soc/intel/boards/kbl_rt5660.c new file mode 100644 index 000000000000..6f92dd9e522d --- /dev/null +++ b/sound/soc/intel/boards/kbl_rt5660.c @@ -0,0 +1,535 @@ +/* + * Intel Kabylake I2S Machine Driver with RT5660 Codecs + * + * Copyright (C) 2018 Shrirang Bagul + * + * Modified from: + * Intel Skylake I2S Machine driver + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License version + * 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../codecs/rt5660.h" +#include "../../codecs/hdac_hdmi.h" +#include "../skylake/skl.h" + +#define KBL_ALC3277_CODEC_DAI "rt5660-aif1" + +static struct snd_soc_jack skylake_hdmi[3]; + +struct kbl_hdmi_pcm { + struct list_head head; + struct snd_soc_dai *codec_dai; + int device; +}; + +struct kbl_rt5660_private { + struct clk *mclk; + struct gpio_desc *gpio_lo_mute; + struct list_head hdmi_pcm_list; +}; + +enum { + KBL_DPCM_AUDIO_5660_PB = 0, + KBL_DPCM_AUDIO_5660_CP, + KBL_DPCM_AUDIO_5660_HDMI1_PB, + KBL_DPCM_AUDIO_5660_HDMI2_PB, + KBL_DPCM_AUDIO_5660_HDMI3_PB, +}; + +static int kabylake_5660_event_lineout(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *k, int event) +{ + struct snd_soc_dapm_context *dapm = w->dapm; + struct kbl_rt5660_private *priv = snd_soc_card_get_drvdata(dapm->card); + + gpiod_set_value_cansleep(priv->gpio_lo_mute, + !(SND_SOC_DAPM_EVENT_ON(event))); + + return 0; +} + +static const struct snd_kcontrol_new kabylake_5660_controls[] = { + SOC_DAPM_PIN_SWITCH("Line In"), + SOC_DAPM_PIN_SWITCH("Line Out"), +}; + +static const struct snd_soc_dapm_widget kabylake_5660_widgets[] = { + SND_SOC_DAPM_MIC("Line In", NULL), + SND_SOC_DAPM_LINE("Line Out", kabylake_5660_event_lineout), + SND_SOC_DAPM_SPK("DP", NULL), + SND_SOC_DAPM_SPK("HDMI", NULL), +}; + +static const struct snd_soc_dapm_route kabylake_5660_map[] = { + /* other jacks */ + {"IN1P", NULL, "Line In"}, + {"IN2P", NULL, "Line In"}, + {"Line Out", NULL, "LOUTR"}, + {"Line Out", NULL, "LOUTL"}, + + + { "HDMI", NULL, "hif5 Output" }, + { "DP", NULL, "hif6 Output" }, + + /* CODEC BE connections */ + { "AIF1 Playback", NULL, "ssp0 Tx"}, + { "ssp0 Tx", NULL, "codec0_out"}, + { "ssp0 Tx", NULL, "codec1_out"}, + + { "codec0_in", NULL, "ssp0 Rx" }, + { "codec1_in", NULL, "ssp0 Rx" }, + { "ssp0 Rx", NULL, "AIF1 Capture" }, + + { "hifi3", NULL, "iDisp3 Tx"}, + { "iDisp3 Tx", NULL, "iDisp3_out"}, + { "hifi2", NULL, "iDisp2 Tx"}, + { "iDisp2 Tx", NULL, "iDisp2_out"}, + { "hifi1", NULL, "iDisp1 Tx"}, + { "iDisp1 Tx", NULL, "iDisp1_out"}, +}; + +static int kabylake_rt5660_codec_init(struct snd_soc_pcm_runtime *rtd) +{ + int ret; + struct kbl_rt5660_private *ctx = snd_soc_card_get_drvdata(rtd->card); + struct snd_soc_codec *codec = rtd->codec; + + /* Request rt5660 GPIO for lineout mute control */ + ctx->gpio_lo_mute = devm_gpiod_get_index(codec->dev, + "lineout-mute", 0, 0); + if (IS_ERR(ctx->gpio_lo_mute)) { + dev_err(rtd->card->dev, "Can't find GPIO_MUTE# gpio\n"); + return PTR_ERR(ctx->gpio_lo_mute); + } + + ret = gpiod_direction_output(ctx->gpio_lo_mute, 1); + if (ret) { + dev_err(rtd->dev, "failed to set lineout-mute gpio %d\n", ret); + return ret; + } + + return ret; +} + +static int kabylake_hdmi_init(struct snd_soc_pcm_runtime *rtd, int device) +{ + struct kbl_rt5660_private *ctx = snd_soc_card_get_drvdata(rtd->card); + struct snd_soc_dai *dai = rtd->codec_dai; + struct kbl_hdmi_pcm *pcm; + + pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL); + if (!pcm) + return -ENOMEM; + + pcm->device = device; + pcm->codec_dai = dai; + + list_add_tail(&pcm->head, &ctx->hdmi_pcm_list); + + return 0; +} + +static int kabylake_5660_hdmi1_init(struct snd_soc_pcm_runtime *rtd) +{ + return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_5660_HDMI1_PB); +} + +static int kabylake_5660_hdmi2_init(struct snd_soc_pcm_runtime *rtd) +{ + return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_5660_HDMI2_PB); +} + +static int kabylake_5660_hdmi3_init(struct snd_soc_pcm_runtime *rtd) +{ + return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_5660_HDMI3_PB); +} + +static unsigned int rates[] = { + 48000, +}; + +static const struct snd_pcm_hw_constraint_list constraints_rates = { + .count = ARRAY_SIZE(rates), + .list = rates, + .mask = 0, +}; + +static unsigned int channels[] = { + 2, +}; + +static const struct snd_pcm_hw_constraint_list constraints_channels = { + .count = ARRAY_SIZE(channels), + .list = channels, + .mask = 0, +}; + +static int kbl_fe_startup(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + + /* + * On this platform for PCM device we support, + * 48Khz + * stereo + * 16 bit audio + */ + + runtime->hw.channels_max = 2; + snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, + &constraints_channels); + + runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE; + snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16); + + snd_pcm_hw_constraint_list(runtime, 0, + SNDRV_PCM_HW_PARAM_RATE, &constraints_rates); + + return 0; +} + +static const struct snd_soc_ops kabylake_rt5660_fe_ops = { + .startup = kbl_fe_startup, +}; + +static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_hw_params *params) +{ + struct snd_interval *rate = hw_param_interval(params, + SNDRV_PCM_HW_PARAM_RATE); + struct snd_interval *channels = hw_param_interval(params, + SNDRV_PCM_HW_PARAM_CHANNELS); + struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); + struct snd_soc_dpcm *dpcm = container_of( + params, struct snd_soc_dpcm, hw_params); + struct snd_soc_dai_link *fe_dai_link = dpcm->fe->dai_link; + struct snd_soc_dai_link *be_dai_link = dpcm->be->dai_link; + + /* + * The ADSP will convert the FE rate to 48k, stereo, 24 bit + */ + if (!strcmp(fe_dai_link->name, "Kbl Audio Port") || + !strcmp(fe_dai_link->name, "Kbl Audio Headset Playback") || + !strcmp(fe_dai_link->name, "Kbl Audio Capture Port")) { + rate->min = rate->max = 48000; + channels->min = channels->max = 2; + snd_mask_none(fmt); + snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE); + } + /* + * The speaker on the SSP0 supports S16_LE and not S24_LE. + * thus changing the mask here + */ + if (!strcmp(be_dai_link->name, "SSP0-Codec")) + snd_mask_set(fmt, SNDRV_PCM_FORMAT_S16_LE); + + return 0; +} + +static int kabylake_rt5660_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_dai *codec_dai = rtd->codec_dai; + int ret; + + ret = snd_soc_dai_set_sysclk(codec_dai, + RT5660_SCLK_S_MCLK, 24576000, SND_SOC_CLOCK_IN); + if (ret < 0) + dev_err(rtd->dev, "snd_soc_dai_set_sysclk err = %d\n", ret); + + return ret; +} + +static struct snd_soc_ops kabylake_rt5660_ops = { + .hw_params = kabylake_rt5660_hw_params, +}; + +static int kabylake_ssp0_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + int ret = 0; + + ret = snd_soc_dai_set_tdm_slot(rtd->cpu_dai, 0x3, 0x3, 2, 24); + if (ret < 0) { + dev_err(rtd->dev, "can't set I2S config, err %d\n", ret); + return ret; + } + + return ret; +} + +static struct snd_soc_ops kabylake_ssp0_ops = { + .hw_params = kabylake_ssp0_hw_params, +}; + +static unsigned int rates_16000[] = { + 16000, +}; + +static const struct snd_pcm_hw_constraint_list constraints_16000 = { + .count = ARRAY_SIZE(rates_16000), + .list = rates_16000, +}; + +static const unsigned int ch_mono[] = { + 1, +}; + +static const struct snd_pcm_hw_constraint_list constraints_refcap = { + .count = ARRAY_SIZE(ch_mono), + .list = ch_mono, +}; + +static int kabylake_refcap_startup(struct snd_pcm_substream *substream) +{ + substream->runtime->hw.channels_max = 1; + snd_pcm_hw_constraint_list(substream->runtime, 0, + SNDRV_PCM_HW_PARAM_CHANNELS, + &constraints_refcap); + + return snd_pcm_hw_constraint_list(substream->runtime, 0, + SNDRV_PCM_HW_PARAM_RATE, + &constraints_16000); +} + +static struct snd_soc_ops skylaye_refcap_ops = { + .startup = kabylake_refcap_startup, +}; + +/* kabylake digital audio interface glue - connects codec <--> CPU */ +static struct snd_soc_dai_link kabylake_5660_dais[] = { + /* Front End DAI links */ + [KBL_DPCM_AUDIO_5660_PB] = { + .name = "Kbl Audio Port", + .stream_name = "Audio", + .cpu_dai_name = "System Pin", + .platform_name = "0000:00:1f.3", + .dynamic = 1, + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .nonatomic = 1, + .trigger = { + SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, + .dpcm_playback = 1, + .ops = &kabylake_rt5660_fe_ops, + }, + [KBL_DPCM_AUDIO_5660_CP] = { + .name = "Kbl Audio Capture Port", + .stream_name = "Audio Record", + .cpu_dai_name = "System Pin", + .platform_name = "0000:00:1f.3", + .dynamic = 1, + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .nonatomic = 1, + .trigger = { + SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, + .dpcm_capture = 1, + .ops = &kabylake_rt5660_fe_ops, + }, + [KBL_DPCM_AUDIO_5660_HDMI1_PB] = { + .name = "Kbl HDMI Port1", + .stream_name = "Hdmi1", + .cpu_dai_name = "HDMI1 Pin", + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .platform_name = "0000:00:1f.3", + .dpcm_playback = 1, + .init = NULL, + .trigger = { + SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, + .nonatomic = 1, + .dynamic = 1, + }, + [KBL_DPCM_AUDIO_5660_HDMI2_PB] = { + .name = "Kbl HDMI Port2", + .stream_name = "Hdmi2", + .cpu_dai_name = "HDMI2 Pin", + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .platform_name = "0000:00:1f.3", + .dpcm_playback = 1, + .init = NULL, + .trigger = { + SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, + .nonatomic = 1, + .dynamic = 1, + }, + [KBL_DPCM_AUDIO_5660_HDMI3_PB] = { + .name = "Kbl HDMI Port3", + .stream_name = "Hdmi3", + .cpu_dai_name = "HDMI3 Pin", + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .platform_name = "0000:00:1f.3", + .trigger = { + SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, + .dpcm_playback = 1, + .init = NULL, + .nonatomic = 1, + .dynamic = 1, + }, + + /* Back End DAI links */ + { + /* SSP0 - Codec */ + .name = "SSP0-Codec", + .id = 0, + .cpu_dai_name = "SSP0 Pin", + .platform_name = "0000:00:1f.3", + .no_pcm = 1, + .codec_name = "i2c-10EC3277:00", + .codec_dai_name = KBL_ALC3277_CODEC_DAI, + .init = kabylake_rt5660_codec_init, + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, + .ignore_pmdown_time = 1, + .be_hw_params_fixup = kabylake_ssp_fixup, + .ops = &kabylake_rt5660_ops, + .dpcm_playback = 1, + .dpcm_capture = 1, + }, + { + .name = "iDisp1", + .id = 1, + .cpu_dai_name = "iDisp1 Pin", + .codec_name = "ehdaudio0D2", + .codec_dai_name = "intel-hdmi-hifi1", + .platform_name = "0000:00:1f.3", + .dpcm_playback = 1, + .init = kabylake_5660_hdmi1_init, + .no_pcm = 1, + }, + { + .name = "iDisp2", + .id = 2, + .cpu_dai_name = "iDisp2 Pin", + .codec_name = "ehdaudio0D2", + .codec_dai_name = "intel-hdmi-hifi2", + .platform_name = "0000:00:1f.3", + .init = kabylake_5660_hdmi2_init, + .dpcm_playback = 1, + .no_pcm = 1, + }, + { + .name = "iDisp3", + .id = 3, + .cpu_dai_name = "iDisp3 Pin", + .codec_name = "ehdaudio0D2", + .codec_dai_name = "intel-hdmi-hifi3", + .platform_name = "0000:00:1f.3", + .init = kabylake_5660_hdmi3_init, + .dpcm_playback = 1, + .no_pcm = 1, + }, +}; + +#define NAME_SIZE 32 +static int kabylake_card_late_probe(struct snd_soc_card *card) +{ + struct kbl_rt5660_private *ctx = snd_soc_card_get_drvdata(card); + struct kbl_hdmi_pcm *pcm; + struct snd_soc_codec *codec = NULL; + int err, i = 0; + char jack_name[NAME_SIZE]; + + list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { + codec = pcm->codec_dai->codec; + snprintf(jack_name, sizeof(jack_name), + "HDMI/DP, pcm=%d Jack", pcm->device); + err = snd_soc_card_jack_new(card, jack_name, + SND_JACK_AVOUT, &skylake_hdmi[i], + NULL, 0); + + if (err) + return err; + + err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device, + &skylake_hdmi[i]); + if (err < 0) + return err; + + i++; + } + + if (!codec) + return -EINVAL; + + return hdac_hdmi_jack_port_init(codec, &card->dapm); +} + +/* kabylake audio machine driver for RT5660 */ +static struct snd_soc_card kabylake_audio_card_rt5660 = { + .name = "kblrt5660", + .owner = THIS_MODULE, + .dai_link = kabylake_5660_dais, + .num_links = ARRAY_SIZE(kabylake_5660_dais), + .controls = kabylake_5660_controls, + .num_controls = ARRAY_SIZE(kabylake_5660_controls), + .dapm_widgets = kabylake_5660_widgets, + .num_dapm_widgets = ARRAY_SIZE(kabylake_5660_widgets), + .dapm_routes = kabylake_5660_map, + .num_dapm_routes = ARRAY_SIZE(kabylake_5660_map), + .fully_routed = true, + .late_probe = kabylake_card_late_probe, +}; + +static int kabylake_audio_probe(struct platform_device *pdev) +{ + struct kbl_rt5660_private *ctx; + + ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_ATOMIC); + if (!ctx) + return -ENOMEM; + + INIT_LIST_HEAD(&ctx->hdmi_pcm_list); + + kabylake_audio_card_rt5660.dev = &pdev->dev; + snd_soc_card_set_drvdata(&kabylake_audio_card_rt5660, ctx); + + return devm_snd_soc_register_card(&pdev->dev, &kabylake_audio_card_rt5660); +} + +static const struct platform_device_id kbl_board_ids[] = { + { .name = "skl_alc3277_i2s" }, + { .name = "kbl_alc3277_i2s" }, + { } +}; + +static struct platform_driver kabylake_audio = { + .probe = kabylake_audio_probe, + .driver = { + .name = "kbl_alc3277_i2s", + .pm = &snd_soc_pm_ops, + }, + .id_table = kbl_board_ids, +}; + +module_platform_driver(kabylake_audio) + +/* Module information */ +MODULE_DESCRIPTION("Audio Machine driver-RT5660 in I2S mode"); +MODULE_AUTHOR("Shrirang Bagul "); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:skl_alc3277_i2s"); +MODULE_ALIAS("platform:kbl_alc3277_i2s"); From patchwork Wed Dec 12 09:25:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hui Wang X-Patchwork-Id: 1011705 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43FBJW1SlXz9sC7; Wed, 12 Dec 2018 20:26:19 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1gX0mU-0000J0-Bd; Wed, 12 Dec 2018 09:26:14 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1gX0mR-0000Gn-Pj for kernel-team@lists.ubuntu.com; Wed, 12 Dec 2018 09:26:11 +0000 Received: from [125.35.49.90] (helo=hwang4-Lenovo-V480c.bluefin) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1gX0mQ-0002iI-Rj for kernel-team@lists.ubuntu.com; Wed, 12 Dec 2018 09:26:11 +0000 From: Hui Wang To: kernel-team@lists.ubuntu.com Subject: [SRU][Bionic/OEM-B][PATCH 2/6] UBUNTU: SAUCE: ASoC: Intel: Kbl: (no-up) Add ACPI GPIO mapping for lineout-mute Date: Wed, 12 Dec 2018 17:25:55 +0800 Message-Id: <20181212092600.4505-3-hui.wang@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181212092600.4505-1-hui.wang@canonical.com> References: <20181212092600.4505-1-hui.wang@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Shrirang Bagul BugLink: https://bugs.launchpad.net/bugs/1807334 Signed-off-by: Shrirang Bagul Signed-off-by: Hui Wang --- sound/soc/intel/boards/kbl_rt5660.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/sound/soc/intel/boards/kbl_rt5660.c b/sound/soc/intel/boards/kbl_rt5660.c index 6f92dd9e522d..b0c6383d77ba 100644 --- a/sound/soc/intel/boards/kbl_rt5660.c +++ b/sound/soc/intel/boards/kbl_rt5660.c @@ -106,26 +106,31 @@ static const struct snd_soc_dapm_route kabylake_5660_map[] = { { "iDisp1 Tx", NULL, "iDisp1_out"}, }; +static const struct acpi_gpio_params lineout_mute_gpio = { 0, 0, true }; + +static const struct acpi_gpio_mapping acpi_rt5660_gpios[] = { + { "lineout-mute-gpios", &lineout_mute_gpio , 1 }, + { NULL }, +}; + static int kabylake_rt5660_codec_init(struct snd_soc_pcm_runtime *rtd) { int ret; struct kbl_rt5660_private *ctx = snd_soc_card_get_drvdata(rtd->card); struct snd_soc_codec *codec = rtd->codec; + ret = devm_acpi_dev_add_driver_gpios(codec->dev, acpi_rt5660_gpios); + if (ret) + dev_warn(codec->dev, "Failed to add driver gpios\n"); + /* Request rt5660 GPIO for lineout mute control */ - ctx->gpio_lo_mute = devm_gpiod_get_index(codec->dev, - "lineout-mute", 0, 0); + ctx->gpio_lo_mute = devm_gpiod_get(codec->dev, "lineout-mute", + GPIOD_OUT_HIGH); if (IS_ERR(ctx->gpio_lo_mute)) { dev_err(rtd->card->dev, "Can't find GPIO_MUTE# gpio\n"); return PTR_ERR(ctx->gpio_lo_mute); } - ret = gpiod_direction_output(ctx->gpio_lo_mute, 1); - if (ret) { - dev_err(rtd->dev, "failed to set lineout-mute gpio %d\n", ret); - return ret; - } - return ret; } From patchwork Wed Dec 12 09:25:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hui Wang X-Patchwork-Id: 1011706 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43FBJX5b7Bz9sN8; Wed, 12 Dec 2018 20:26:20 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1gX0mV-0000KA-J8; Wed, 12 Dec 2018 09:26:15 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1gX0mT-0000Hv-EO for kernel-team@lists.ubuntu.com; Wed, 12 Dec 2018 09:26:13 +0000 Received: from [125.35.49.90] (helo=hwang4-Lenovo-V480c.bluefin) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1gX0mS-0002iI-Gn for kernel-team@lists.ubuntu.com; Wed, 12 Dec 2018 09:26:13 +0000 From: Hui Wang To: kernel-team@lists.ubuntu.com Subject: [SRU][Bionic/OEM-B][PATCH 3/6] UBUNTU: SAUCE: ASoC: rt5660: (no-up) Move platform code to board file Date: Wed, 12 Dec 2018 17:25:56 +0800 Message-Id: <20181212092600.4505-4-hui.wang@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181212092600.4505-1-hui.wang@canonical.com> References: <20181212092600.4505-1-hui.wang@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Shrirang Bagul BugLink: https://bugs.launchpad.net/bugs/1807334 ACPI GPIO table is defined on platform basis. Remove their definitions from the Codec driver and include them in the machine driver instead (where it belongs). Signed-off-by: Shrirang Bagul Signed-off-by: Hui Wang --- sound/soc/codecs/rt5660.c | 25 ------------------------- sound/soc/intel/boards/bytcr_rt5660.c | 19 ++++++++++++++----- 2 files changed, 14 insertions(+), 30 deletions(-) diff --git a/sound/soc/codecs/rt5660.c b/sound/soc/codecs/rt5660.c index 39dc2289d651..30d32a7678a2 100644 --- a/sound/soc/codecs/rt5660.c +++ b/sound/soc/codecs/rt5660.c @@ -9,7 +9,6 @@ * published by the Free Software Foundation. */ -#include #include #include #include @@ -1251,26 +1250,6 @@ static const struct acpi_device_id rt5660_acpi_match[] = { }; MODULE_DEVICE_TABLE(acpi, rt5660_acpi_match); -static const struct acpi_gpio_params audio_wake_intr_gpio = { 0, 0, false }; -static const struct acpi_gpio_params lineout_mute_gpio = { 1, 0, true }; - -static const struct acpi_gpio_mapping byt_rt5660_gpios[] = { - { "audio-wake-intr-gpios", &audio_wake_intr_gpio, 1 }, - { "lineout-mute-gpios", &lineout_mute_gpio , 1 }, - { NULL }, -}; - -static void rt5660_read_acpi_properties(struct rt5660_priv *rt5660, - struct device *dev) -{ - int ret; - - ret = acpi_dev_add_driver_gpios(ACPI_COMPANION(dev), - byt_rt5660_gpios); - if (ret) - dev_warn(dev, "Failed to add driver gpios\n"); -} - static int rt5660_parse_dt(struct rt5660_priv *rt5660, struct device *dev) { rt5660->pdata.in1_diff = device_property_read_bool(dev, @@ -1310,10 +1289,6 @@ static int rt5660_i2c_probe(struct i2c_client *i2c, rt5660->pdata = *pdata; else if (i2c->dev.of_node) rt5660_parse_dt(rt5660, &i2c->dev); - else if (ACPI_HANDLE(&i2c->dev)) - rt5660_read_acpi_properties(rt5660, &i2c->dev); - else - return -EINVAL; rt5660->regmap = devm_regmap_init_i2c(i2c, &rt5660_regmap); if (IS_ERR(rt5660->regmap)) { diff --git a/sound/soc/intel/boards/bytcr_rt5660.c b/sound/soc/intel/boards/bytcr_rt5660.c index f0e3e4125f07..30c711c86260 100644 --- a/sound/soc/intel/boards/bytcr_rt5660.c +++ b/sound/soc/intel/boards/bytcr_rt5660.c @@ -193,6 +193,15 @@ static int byt_rt5660_aif1_hw_params(struct snd_pcm_substream *substream, return 0; } +static const struct acpi_gpio_params audio_wake_intr_gpio = { 0, 0, false }; +static const struct acpi_gpio_params lineout_mute_gpio = { 1, 0, true }; + +static const struct acpi_gpio_mapping byt_rt5660_gpios[] = { + { "audio-wake-intr-gpios", &audio_wake_intr_gpio, 1 }, + { "lineout-mute-gpios", &lineout_mute_gpio , 1 }, + { NULL }, +}; + static int byt_rt5660_init(struct snd_soc_pcm_runtime *runtime) { struct snd_soc_card *card = runtime->card; @@ -200,18 +209,18 @@ static int byt_rt5660_init(struct snd_soc_pcm_runtime *runtime) struct snd_soc_codec *codec = runtime->codec; int ret; + ret = devm_acpi_dev_add_driver_gpios(codec->dev, byt_rt5660_gpios); + if (ret) + dev_warn(codec->dev, "Failed to add driver gpios\n"); + /* Request rt5660 GPIO for lineout mute control */ priv->gpio_lo_mute = devm_gpiod_get_index(codec->dev, - "lineout-mute", 0, 0); + "lineout-mute", 0, GPIOD_OUT_HIGH); if (IS_ERR(priv->gpio_lo_mute)) { dev_err(card->dev, "Can't find GPIO_MUTE# gpio\n"); return PTR_ERR(priv->gpio_lo_mute); } - ret = gpiod_direction_output(priv->gpio_lo_mute, 1); - if (ret) - return ret; - if (byt_rt5660_quirk & BYT_RT5660_MCLK_EN) { /* * The firmware might enable the clock at From patchwork Wed Dec 12 09:25:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hui Wang X-Patchwork-Id: 1011707 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43FBJb4pbYz9s2P; Wed, 12 Dec 2018 20:26:23 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1gX0mX-0000Lz-UV; Wed, 12 Dec 2018 09:26:17 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1gX0mV-0000Jb-2d for kernel-team@lists.ubuntu.com; Wed, 12 Dec 2018 09:26:15 +0000 Received: from [125.35.49.90] (helo=hwang4-Lenovo-V480c.bluefin) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1gX0mU-0002iI-5n for kernel-team@lists.ubuntu.com; Wed, 12 Dec 2018 09:26:14 +0000 From: Hui Wang To: kernel-team@lists.ubuntu.com Subject: [SRU][Bionic/OEM-B][PATCH 4/6] UBUNTU: SAUCE: ASoC: Intel: (no-up) Add Skylake/Kabylake alc3277 i2s machine driver entry Date: Wed, 12 Dec 2018 17:25:57 +0800 Message-Id: <20181212092600.4505-5-hui.wang@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181212092600.4505-1-hui.wang@canonical.com> References: <20181212092600.4505-1-hui.wang@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Shrirang Bagul BugLink: https://bugs.launchpad.net/bugs/1807334 ALC3277 codec (RT5660) is sported on Dell Edge IoT 7XXX gateways. This patch adds the I2S machine driver entry. Signed-off-by: Shrirang Bagul Signed-off-by: Hui Wang --- sound/soc/intel/skylake/skl.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c index 31d8634e8aa1..4dbe4daf2717 100644 --- a/sound/soc/intel/skylake/skl.c +++ b/sound/soc/intel/skylake/skl.c @@ -929,6 +929,11 @@ static struct snd_soc_acpi_mach sst_skl_devdata[] = { .quirk_data = &skl_codecs, .pdata = &skl_dmic_data }, + { + .id = "10EC3277", + .drv_name = "skl_alc3277_i2s", + .fw_filename = "intel/dsp_fw_release.bin", + }, {} }; @@ -991,7 +996,11 @@ static struct snd_soc_acpi_mach sst_kbl_devdata[] = { .drv_name = "kbl_rt5663", .fw_filename = "intel/dsp_fw_kbl.bin", }, - + { + .id = "10EC3277", + .drv_name = "kbl_alc3277_i2s", + .fw_filename = "intel/dsp_fw_kbl.bin", + }, {} }; From patchwork Wed Dec 12 09:25:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hui Wang X-Patchwork-Id: 1011708 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43FBJg42X5z9sMQ; Wed, 12 Dec 2018 20:26:27 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1gX0mb-0000Op-0v; Wed, 12 Dec 2018 09:26:21 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1gX0mW-0000Kz-Nt for kernel-team@lists.ubuntu.com; Wed, 12 Dec 2018 09:26:16 +0000 Received: from [125.35.49.90] (helo=hwang4-Lenovo-V480c.bluefin) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1gX0mV-0002iI-RG for kernel-team@lists.ubuntu.com; Wed, 12 Dec 2018 09:26:16 +0000 From: Hui Wang To: kernel-team@lists.ubuntu.com Subject: [SRU][Bionic/OEM-B][PATCH 5/6] UBUNTU: SAUCE: ASoC: Intel: (no-up) Update Skylake/Kabylake alc3277 i2s machine driver Date: Wed, 12 Dec 2018 17:25:58 +0800 Message-Id: <20181212092600.4505-6-hui.wang@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181212092600.4505-1-hui.wang@canonical.com> References: <20181212092600.4505-1-hui.wang@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" BugLink: https://bugs.launchpad.net/bugs/1807334 Add jack detection GPIO and change to use BCLK rather than MCLK for codec. Signed-off-by: Hui Wang --- sound/soc/intel/boards/kbl_rt5660.c | 146 ++++++++++++++-------------- 1 file changed, 74 insertions(+), 72 deletions(-) diff --git a/sound/soc/intel/boards/kbl_rt5660.c b/sound/soc/intel/boards/kbl_rt5660.c index b0c6383d77ba..9e5498885c3a 100644 --- a/sound/soc/intel/boards/kbl_rt5660.c +++ b/sound/soc/intel/boards/kbl_rt5660.c @@ -85,39 +85,66 @@ static const struct snd_soc_dapm_route kabylake_5660_map[] = { {"Line Out", NULL, "LOUTR"}, {"Line Out", NULL, "LOUTL"}, - - { "HDMI", NULL, "hif5 Output" }, - { "DP", NULL, "hif6 Output" }, - /* CODEC BE connections */ { "AIF1 Playback", NULL, "ssp0 Tx"}, { "ssp0 Tx", NULL, "codec0_out"}, - { "ssp0 Tx", NULL, "codec1_out"}, { "codec0_in", NULL, "ssp0 Rx" }, - { "codec1_in", NULL, "ssp0 Rx" }, + { "ssp0 Rx", NULL, "AIF1 Capture" }, - { "hifi3", NULL, "iDisp3 Tx"}, - { "iDisp3 Tx", NULL, "iDisp3_out"}, { "hifi2", NULL, "iDisp2 Tx"}, { "iDisp2 Tx", NULL, "iDisp2_out"}, { "hifi1", NULL, "iDisp1 Tx"}, { "iDisp1 Tx", NULL, "iDisp1_out"}, }; -static const struct acpi_gpio_params lineout_mute_gpio = { 0, 0, true }; +#define GPIO_LINEOUT_MUTE_INDEX 0 +#define GPIO_LINEOUT_DET_INDEX 3 +#define GPIO_LINEIN_DET_INDEX 4 + +static const struct acpi_gpio_params lineout_mute_gpio = { GPIO_LINEOUT_MUTE_INDEX, 0, true }; +static const struct acpi_gpio_params lineout_det_gpio = { GPIO_LINEOUT_DET_INDEX, 0, false }; +static const struct acpi_gpio_params mic_det_gpio = { GPIO_LINEIN_DET_INDEX, 0, false }; static const struct acpi_gpio_mapping acpi_rt5660_gpios[] = { { "lineout-mute-gpios", &lineout_mute_gpio , 1 }, + { "lineout-det-gpios", &lineout_det_gpio, 1 }, + { "mic-det-gpios", &mic_det_gpio, 1 }, { NULL }, }; +static struct snd_soc_jack lineout_jack; +static struct snd_soc_jack mic_jack; + +static struct snd_soc_jack_pin lineout_jack_pin = { + .pin = "Line Out", + .mask = SND_JACK_LINEOUT, +}; + +static struct snd_soc_jack_pin mic_jack_pin = { + .pin = "Line In", + .mask = SND_JACK_MICROPHONE, +}; + +static struct snd_soc_jack_gpio lineout_jack_gpio = { + .name = "lineout-det", + .report = SND_JACK_LINEOUT, + .debounce_time = 200, +}; + +static struct snd_soc_jack_gpio mic_jack_gpio = { + .name = "mic-det", + .report = SND_JACK_MICROPHONE, + .debounce_time = 200, +}; + static int kabylake_rt5660_codec_init(struct snd_soc_pcm_runtime *rtd) { int ret; struct kbl_rt5660_private *ctx = snd_soc_card_get_drvdata(rtd->card); struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); ret = devm_acpi_dev_add_driver_gpios(codec->dev, acpi_rt5660_gpios); if (ret) @@ -131,6 +158,33 @@ static int kabylake_rt5660_codec_init(struct snd_soc_pcm_runtime *rtd) return PTR_ERR(ctx->gpio_lo_mute); } + /* Create and initialize headphone jack */ + if (!snd_soc_card_jack_new(rtd->card, "Lineout Jack", + SND_JACK_LINEOUT, &lineout_jack, + &lineout_jack_pin, 1)) { + lineout_jack_gpio.gpiod_dev = codec->dev; + if (snd_soc_jack_add_gpios(&lineout_jack, 1, + &lineout_jack_gpio)) + dev_err(codec->dev, "Can't add Lineout jack gpio\n"); + } else { + dev_err(codec->dev, "Can't create Lineout jack\n"); + } + + /* Create and initialize mic jack */ + if (!snd_soc_card_jack_new(rtd->card, "Mic Jack", + SND_JACK_MICROPHONE, &mic_jack, + &mic_jack_pin, 1)) { + mic_jack_gpio.gpiod_dev = codec->dev; + if (snd_soc_jack_add_gpios(&mic_jack, 1, &mic_jack_gpio)) + dev_err(codec->dev, "Can't add mic jack gpio\n"); + } else { + dev_err(codec->dev, "Can't create mic jack\n"); + } + + snd_soc_dapm_force_enable_pin(dapm, "MICBIAS1"); + snd_soc_dapm_force_enable_pin(dapm, "BST1"); + snd_soc_dapm_force_enable_pin(dapm, "BST2"); + return ret; } @@ -226,25 +280,17 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dpcm *dpcm = container_of( params, struct snd_soc_dpcm, hw_params); struct snd_soc_dai_link *fe_dai_link = dpcm->fe->dai_link; - struct snd_soc_dai_link *be_dai_link = dpcm->be->dai_link; /* * The ADSP will convert the FE rate to 48k, stereo, 24 bit */ if (!strcmp(fe_dai_link->name, "Kbl Audio Port") || - !strcmp(fe_dai_link->name, "Kbl Audio Headset Playback") || !strcmp(fe_dai_link->name, "Kbl Audio Capture Port")) { rate->min = rate->max = 48000; channels->min = channels->max = 2; snd_mask_none(fmt); snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE); } - /* - * The speaker on the SSP0 supports S16_LE and not S24_LE. - * thus changing the mask here - */ - if (!strcmp(be_dai_link->name, "SSP0-Codec")) - snd_mask_set(fmt, SNDRV_PCM_FORMAT_S16_LE); return 0; } @@ -257,68 +303,24 @@ static int kabylake_rt5660_hw_params(struct snd_pcm_substream *substream, int ret; ret = snd_soc_dai_set_sysclk(codec_dai, - RT5660_SCLK_S_MCLK, 24576000, SND_SOC_CLOCK_IN); - if (ret < 0) - dev_err(rtd->dev, "snd_soc_dai_set_sysclk err = %d\n", ret); - - return ret; -} - -static struct snd_soc_ops kabylake_rt5660_ops = { - .hw_params = kabylake_rt5660_hw_params, -}; - -static int kabylake_ssp0_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - int ret = 0; - - ret = snd_soc_dai_set_tdm_slot(rtd->cpu_dai, 0x3, 0x3, 2, 24); + RT5660_SCLK_S_PLL1, params_rate(params) * 512, SND_SOC_CLOCK_IN); if (ret < 0) { - dev_err(rtd->dev, "can't set I2S config, err %d\n", ret); + dev_err(rtd->dev, "snd_soc_dai_set_sysclk err = %d\n", ret); return ret; } - return ret; -} - -static struct snd_soc_ops kabylake_ssp0_ops = { - .hw_params = kabylake_ssp0_hw_params, -}; - -static unsigned int rates_16000[] = { - 16000, -}; - -static const struct snd_pcm_hw_constraint_list constraints_16000 = { - .count = ARRAY_SIZE(rates_16000), - .list = rates_16000, -}; - -static const unsigned int ch_mono[] = { - 1, -}; - -static const struct snd_pcm_hw_constraint_list constraints_refcap = { - .count = ARRAY_SIZE(ch_mono), - .list = ch_mono, -}; + ret = snd_soc_dai_set_pll(codec_dai, 0, + RT5660_PLL1_S_BCLK, + params_rate(params) * 50, + params_rate(params) * 512); + if (ret < 0) + dev_err(codec_dai->dev, "can't set codec pll: %d\n", ret); -static int kabylake_refcap_startup(struct snd_pcm_substream *substream) -{ - substream->runtime->hw.channels_max = 1; - snd_pcm_hw_constraint_list(substream->runtime, 0, - SNDRV_PCM_HW_PARAM_CHANNELS, - &constraints_refcap); - - return snd_pcm_hw_constraint_list(substream->runtime, 0, - SNDRV_PCM_HW_PARAM_RATE, - &constraints_16000); + return ret; } -static struct snd_soc_ops skylaye_refcap_ops = { - .startup = kabylake_refcap_startup, +static struct snd_soc_ops kabylake_rt5660_ops = { + .hw_params = kabylake_rt5660_hw_params, }; /* kabylake digital audio interface glue - connects codec <--> CPU */ From patchwork Wed Dec 12 09:25:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hui Wang X-Patchwork-Id: 1011709 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43FBJj0Cm1z9sCV; Wed, 12 Dec 2018 20:26:29 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1gX0mc-0000Pp-0C; Wed, 12 Dec 2018 09:26:22 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1gX0mY-0000Ma-KI for kernel-team@lists.ubuntu.com; Wed, 12 Dec 2018 09:26:18 +0000 Received: from [125.35.49.90] (helo=hwang4-Lenovo-V480c.bluefin) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1gX0mX-0002iI-Hn for kernel-team@lists.ubuntu.com; Wed, 12 Dec 2018 09:26:18 +0000 From: Hui Wang To: kernel-team@lists.ubuntu.com Subject: [SRU][Bionic/OEM-B][PATCH 6/6] UBUNTU: [Config] CONFIG_SND_SOC_INTEL_KBL_RT5660_MACH=m Date: Wed, 12 Dec 2018 17:25:59 +0800 Message-Id: <20181212092600.4505-7-hui.wang@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181212092600.4505-1-hui.wang@canonical.com> References: <20181212092600.4505-1-hui.wang@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Shrirang Bagul BugLink: https://bugs.launchpad.net/bugs/1807334 Signed-off-by: Shrirang Bagul Signed-off-by: Hui Wang --- debian.master/config/config.common.ubuntu | 1 + 1 file changed, 1 insertion(+) diff --git a/debian.master/config/config.common.ubuntu b/debian.master/config/config.common.ubuntu index 56ba49ff623d..39be1d8478b9 100644 --- a/debian.master/config/config.common.ubuntu +++ b/debian.master/config/config.common.ubuntu @@ -8488,6 +8488,7 @@ CONFIG_SND_SOC_INTEL_CHT_BSW_RT5672_MACH=m CONFIG_SND_SOC_INTEL_COMMON=m CONFIG_SND_SOC_INTEL_HASWELL=m CONFIG_SND_SOC_INTEL_HASWELL_MACH=m +CONFIG_SND_SOC_INTEL_KBL_RT5660_MACH=m CONFIG_SND_SOC_INTEL_KBL_RT5663_MAX98927_MACH=m CONFIG_SND_SOC_INTEL_KBL_RT5663_RT5514_MAX98927_MACH=m CONFIG_SND_SOC_INTEL_MACH=m