From patchwork Mon Nov 9 21:21:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Marinushkin X-Patchwork-Id: 11892591 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF40FC2D0A3 for ; Mon, 9 Nov 2020 21:20:32 +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 24D70206CB for ; Mon, 9 Nov 2020 21:20:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="d5E8duAF"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=birdec.com header.i=@birdec.com header.b="aS05Lz9U" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 24D70206CB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=birdec.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 3381F16AB; Mon, 9 Nov 2020 22:19:38 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3381F16AB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1604956828; bh=dQ57fT2sshq9Z2CiuTOnMV92Q5OnOFMqlI0hT/C1bcM=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=d5E8duAFcY2aybDMWjO+QNrpsf+q7WB8z2nYUNmAUKH+IV9MLYEeR/vXkAKMY6ZsO kcLpKC7R2oaDR4N06akG4PIxFsCUp/Z/ej6Y8acGXL/B5VZ/aoJ2g3zxnH1rbo4cIC A6jNlu0MCOF4XTZCq7rdfqIUGtYiG0ajTyMzOZoQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id ACA6CF801F5; Mon, 9 Nov 2020 22:19:37 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C91DCF8020C; Mon, 9 Nov 2020 22:19:36 +0100 (CET) Received: from host.euro-space.net (host.euro-space.net [87.117.239.2]) (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 5406EF800BA for ; Mon, 9 Nov 2020 22:19:28 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5406EF800BA Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=birdec.com header.i=@birdec.com header.b="aS05Lz9U" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=birdec.com; s=default; h=Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version :Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=CYkwsVIaLlOhxjKhcFdBd4Owd+Ss0IqNzEdDmO2watg=; b=aS05Lz9Ugh7EwhcU6cpwgxoyO+ uvZRCfsKa7rs3aM2zDjLcAfOB5D8qYnGE2KHOgSifm/6dHs4T7+AaTC16+GV6l9s0KnKRGjrocGc8 wQTkumOW8EdLP7MJlXmUYSrc+SIuhjZruPuybI4VqxJQrtTn4J7ObqxSbrFFTY33hf7KYXN5AKmWg fE+XZy1wJ1cQB2ap9ZFksXU4Fy1924ZWH3zFcMNwbHtYrSOAnwVZqBql1bfkMb+dFtEkvL2y/TObM y4rUODXpkFxxvmAuqiPtLDNu1I3ozklnpaDYynjwYiSliRvybicJd8wcXVFgP8JXSsHX7jjy5fxHP gAMif7kA==; Received: from dynamic-089-014-103-027.89.14.pool.telefonica.de ([89.14.103.27]:44520 helo=gentoo0.localdomain) by host.euro-space.net with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1kcEZS-0000xS-SE; Mon, 09 Nov 2020 21:19:26 +0000 From: Kirill Marinushkin To: Mark Brown , Takashi Iwai , Liam Girdwood Subject: [PATCH] ASoC: pcm512x: Add support for data formats RJ and LJ Date: Mon, 9 Nov 2020 22:21:33 +0100 Message-Id: <20201109212133.25869-1-kmarinushkin@birdec.com> X-Mailer: git-send-email 2.13.6 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - host.euro-space.net X-AntiAbuse: Original Domain - alsa-project.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - birdec.com X-Get-Message-Sender-Via: host.euro-space.net: authenticated_id: kmarinushkin@birdec.com X-Authenticated-Sender: host.euro-space.net: kmarinushkin@birdec.com X-Source: X-Source-Args: X-Source-Dir: Cc: alsa-devel@alsa-project.org, Kuninori Morimoto , Kirill Marinushkin , linux-kernel@vger.kernel.org, Peter Ujfalusi , Matthias Reichl 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" Currently, pcm512x driver supports only I2S data format. This commit adds RJ and LJ as well. I don't expect regression WRT existing sound cards, because: * default value in corresponding register of pcm512x codec is 0 == I2S * existing in-tree sound cards with pcm512x codec are configured for I2S * i don't see how existing off-tree sound cards with pcm512x codec could be configured differently - it would not work * tested explicitly, that there is no regression with Raspberry Pi + sound card `sound/soc/bcm/hifiberry_dacplus.c` Signed-off-by: Kirill Marinushkin Cc: Mark Brown Cc: Takashi Iwai Cc: Liam Girdwood Cc: Matthias Reichl Cc: Kuninori Morimoto Cc: Peter Ujfalusi Cc: alsa-devel@alsa-project.org Cc: linux-kernel@vger.kernel.org --- sound/soc/codecs/pcm512x.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c index 8153d3d01654..c6e975fb4a43 100644 --- a/sound/soc/codecs/pcm512x.c +++ b/sound/soc/codecs/pcm512x.c @@ -1167,6 +1167,7 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream, struct snd_soc_component *component = dai->component; struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); int alen; + int afmt; int gpio; int clock_output; int master_mode; @@ -1195,6 +1196,22 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } + switch (pcm512x->fmt & SND_SOC_DAIFMT_FORMAT_MASK) { + case SND_SOC_DAIFMT_I2S: + afmt = PCM512x_AFMT_I2S; + break; + case SND_SOC_DAIFMT_RIGHT_J: + afmt = PCM512x_AFMT_RTJ; + break; + case SND_SOC_DAIFMT_LEFT_J: + afmt = PCM512x_AFMT_LTJ; + break; + default: + dev_err(component->dev, "unsupported DAI format: 0x%x\n", + pcm512x->fmt); + return -EINVAL; + } + switch (pcm512x->fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBS_CFS: ret = regmap_update_bits(pcm512x->regmap, @@ -1236,6 +1253,13 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream, return ret; } + ret = regmap_update_bits(pcm512x->regmap, PCM512x_I2S_1, + PCM512x_AFMT, afmt); + if (ret != 0) { + dev_err(component->dev, "Failed to set data format: %d\n", ret); + return ret; + } + if (pcm512x->pll_out) { ret = regmap_write(pcm512x->regmap, PCM512x_FLEX_A, 0x11); if (ret != 0) {