From patchwork Mon May 11 03:16:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sia Jee Heng X-Patchwork-Id: 11539655 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2FF7D139F for ; Mon, 11 May 2020 03:31:46 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B62AB20746 for ; Mon, 11 May 2020 03:31:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="LPeWGdtH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B62AB20746 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 092B71661; Mon, 11 May 2020 05:30:58 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 092B71661 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1589167904; bh=OCnoVpjZuzeyPykHwK9AlEwcRpV7E9uMuT6f2cxq7+4=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=LPeWGdtHn4u/83Trf8u05OPqV/hnMHdcOItJD0mfV5G+yNdT53oxOtVib0l3WNP7I OLexCsBrFLbkhxlFqR1OnBjAco/tpgZyn3/8To/TwPNIwNipIBeSLDYrsHozrUpI9O UPuON7Fzsb2BrsL/MFAfA780falsPISdk8MWntwY= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id A80E0F8029B; Mon, 11 May 2020 05:29:24 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9991FF8014C; Mon, 11 May 2020 05:29:04 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on alsa1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 55A2EF8014C for ; Mon, 11 May 2020 05:28:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 55A2EF8014C IronPort-SDR: 2eGdvmG56gdSIeLNAt/RUKYPlsZiYQ3Zcyk+ARjEJRyRPNQnpA+Dc0KM6SrcbPM549aZeqY5JF pO1bMCMNSKJA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 May 2020 20:28:53 -0700 IronPort-SDR: cYyaAsNLwz6zYN56IzkafeCqjkeayc0OiFBTO72rVXq11EEmdbCZszrX7TYxBY+YevG9VmW7BM ZxL/9LvCuCCA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,378,1583222400"; d="scan'208";a="265024245" Received: from unknown (HELO jsia-HP-Z620-Workstation.png.intel.com) ([10.221.118.135]) by orsmga006.jf.intel.com with ESMTP; 10 May 2020 20:28:51 -0700 From: Sia Jee Heng To: Subject: [PATCH 2/4] ASoC: Intel: Boards: Add KeemBay machine driver Date: Mon, 11 May 2020 11:16:02 +0800 Message-Id: <1589166964-8985-3-git-send-email-jee.heng.sia@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1589166964-8985-1-git-send-email-jee.heng.sia@intel.com> References: <1589166964-8985-1-git-send-email-jee.heng.sia@intel.com> Cc: liam.r.girdwood@linux.intel.com, broonie@kernel.org, tiwai@suse.com, pierre-louis.bossart@linux.intel.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Add KeemBay machine driver which glues the tlv320aic3204 codec driver and kmb_platform driver to form the asoc sound driver. Signed-off-by: Michael Sit Wei Hong Signed-off-by: Sia Jee Heng --- sound/soc/intel/boards/kmb_tlv3204.c | 144 +++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 sound/soc/intel/boards/kmb_tlv3204.c diff --git a/sound/soc/intel/boards/kmb_tlv3204.c b/sound/soc/intel/boards/kmb_tlv3204.c new file mode 100644 index 0000000..813c291 --- /dev/null +++ b/sound/soc/intel/boards/kmb_tlv3204.c @@ -0,0 +1,144 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* KeemBay ASOC Machine driver + * + * Copyright (C) 2020 Intel Corporation. + * + */ + +#include +#include +#include +#include "../../codecs/tlv320aic32x4.h" + +static unsigned int channels[] = { + 2, +}; + +static struct snd_pcm_hw_constraint_list constraints_ch = { + .count = ARRAY_SIZE(channels), + .list = channels, +}; + +static unsigned int rates[] = { + 16000, + 48000, +}; + +static struct snd_pcm_hw_constraint_list constraints_rates = { + .count = ARRAY_SIZE(rates), + .list = rates, +}; + +static int kmb_mach_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 = asoc_rtd_to_codec(rtd, 0); + int ret; + unsigned int sysclk; + + /* As per codec datasheet Sysclk = 256 * fs */ + sysclk = 12288000; + + /* set the codec system clock */ + ret = snd_soc_dai_set_sysclk(codec_dai, 1, sysclk, SND_SOC_CLOCK_IN); + if (ret < 0) + dev_err(rtd->dev, "snd_soc_dai_set_sysclk err = %d\n", ret); + + return ret; +} + +static int kmb_mach_dai_link_startup(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *str_runtime; + + str_runtime = substream->runtime; + + snd_pcm_hw_constraint_list(str_runtime, 0, + SNDRV_PCM_HW_PARAM_CHANNELS, + &constraints_ch); + + snd_pcm_hw_constraint_list(str_runtime, 0, + SNDRV_PCM_HW_PARAM_RATE, + &constraints_rates); + + return 0; +} + +static const struct snd_soc_ops kmb_mach_dai_link_ops = { + .startup = kmb_mach_dai_link_startup, + .hw_params = kmb_mach_hw_params, +}; + +static const struct snd_soc_dapm_widget aic32x4_dapm_widgets[] = { + SND_SOC_DAPM_MIC("External Mic", NULL), + SND_SOC_DAPM_HP("Headphone", NULL), +}; + +static const struct snd_soc_dapm_route aic32x4_dapm_routes[] = { + {"Headphone", NULL, "HPL"}, + {"Headphone", NULL, "HPR"}, + {"IN3_R", NULL, "External Mic"}, + {"IN3_L", NULL, "External Mic"}, +}; + +/* Linking platform to the codec-drivers */ +SND_SOC_DAILINK_DEFS(link1, + DAILINK_COMP_ARRAY(COMP_CPU("20140000.i2s")), + DAILINK_COMP_ARRAY(COMP_CODEC("tlv320aic32x4.2-0018", + "tlv320aic32x4-hifi")), + DAILINK_COMP_ARRAY(COMP_PLATFORM("20140000.i2s"))); + +/* kmb digital audio interface glue */ +static struct snd_soc_dai_link kmb_mach_dais[] = { + { + .name = "tlv320aic32x4", + .stream_name = "TLV320AIC32X4", + .ops = &kmb_mach_dai_link_ops, + .dai_fmt = SND_SOC_DAIFMT_I2S | + SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, + SND_SOC_DAILINK_REG(link1), + }, +}; + +/* kmb audio machine driver */ +static struct snd_soc_card kmb_mach = { + .name = "kmb_audio_card", + .dai_link = kmb_mach_dais, + .num_links = ARRAY_SIZE(kmb_mach_dais), + .dapm_routes = aic32x4_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(aic32x4_dapm_routes), + .dapm_widgets = aic32x4_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(aic32x4_dapm_widgets), + .fully_routed = true, +}; + +static int kmb_mach_audio_probe(struct platform_device *pdev) +{ + kmb_mach.dev = &pdev->dev; + + return devm_snd_soc_register_card(&pdev->dev, &kmb_mach); +} + +static const struct of_device_id kmb_mach_of_match[] = { + { .compatible = "intel,kmb-snd-asoc", }, + {} +}; + +static struct platform_driver kmb_mach_audio = { + .probe = kmb_mach_audio_probe, + .driver = { + .name = "kmb_tlv3204", + .of_match_table = kmb_mach_of_match, + }, +}; + +module_platform_driver(kmb_mach_audio) + +/* Module information */ +MODULE_DESCRIPTION("Intel Audio tlv3204 machine driver for KeemBay"); +MODULE_AUTHOR("Sia Jee Heng "); +MODULE_AUTHOR("Sit, Michael Wei Hong "); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:kmb_tlv3204");