From patchwork Mon Feb 25 16:42:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Van Asbroeck X-Patchwork-Id: 10828935 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0AC10180E for ; Mon, 25 Feb 2019 17:09:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE4C12A043 for ; Mon, 25 Feb 2019 17:09:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D1FD72A071; Mon, 25 Feb 2019 17:09:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8E38C2A043 for ; Mon, 25 Feb 2019 17:09:08 +0000 (UTC) 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 A94391678; Mon, 25 Feb 2019 17:42:53 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A94391678 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1551113023; bh=dYsEnLtilDU/oOF0Nu9o4JvpC0masay2fXTpAMufh2s=; h=From:To:Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=AZh/+7rpOZ38RzDvKS902PpANPb38IlNQTU0jMozyNQ2JVPfjVQVImXIOTDFzfKfB eFUhFnyfGQML/kHC8QBgyE/xtVuNvoEkpEEU5msUocJPT/J7WgHaYHL8FLpOmKyBMS sptgBCZ+rsBI5j+7Aoeyd+QWhVjlcljNGtw8+KWQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 9DD46F89664; Mon, 25 Feb 2019 17:42:32 +0100 (CET) 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 6EF14F89667; Mon, 25 Feb 2019 17:42:31 +0100 (CET) Received: from mail-it1-x142.google.com (mail-it1-x142.google.com [IPv6:2607:f8b0:4864:20::142]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 17BC0F89650 for ; Mon, 25 Feb 2019 17:42:27 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 17BC0F89650 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="oZ59o3M0" Received: by mail-it1-x142.google.com with SMTP id r11so13705101itc.2 for ; Mon, 25 Feb 2019 08:42:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=2HfjMFbNkwkIi9QX5DnuZACXZriGZ0EFMFMTCzNqLmI=; b=oZ59o3M0nA03UgExMmrj8vgE39kQqtPXaLJdyCyAe7rb25N/uCly+iKet5Gwk9LVjP OhFjdMpLpNkIv50l1g7jlDZGS4iRPgTpKO7U/5uR+WOhlY5STqnx4wn5uu3i/5oBhrTl d/L6opDXVrD/uMRK52JFldTWQLdUbzXmI96tGOt2PxKVHK0WjnDsZKCVIrs6ieijBwiP A2fS2baexPrjF0jS8NY4vVtLAZ0lahSniVeVDsayE2cDqv+06l2xjZzsQdvnoF8LWGMg n+0pa3/LlSbeuoGvbdnonav90VPxTx1z+DEvx4DkB27vRxXpU+uiSEk/JwwqtHWzeVqs hwlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=2HfjMFbNkwkIi9QX5DnuZACXZriGZ0EFMFMTCzNqLmI=; b=R5Un9gNKs0aMhiKpwxfAysp3ZWJXveoWZlnBUef93vxinPag2xdzyyfaNn/SYsWHXM OLL9dN63OTwq2ac7InT+07KbB147LBGSphXUM9zn6ew9eiiZ1Hya79QvCoQKgfasyTob 9e0Nc3Lx4iXEAQzF75fPnUQqF+geJ1l77bB1Q0t/I5Jy/jWk5FBY3ENXnMT0BzRravlV whiCAWeE3T3afYyHJRAsxAPKAnj+47mOGVBkRUq/hXYOPz0G42HFRabrlf7Lxv9AuJbp q/o1uADOAb7Mga98UhrM7XILCX7TRXIp75IcFxa4kZrvb/YUPzGQrwB8AwW1Sc5VYfFl VdPQ== X-Gm-Message-State: AHQUAuZnqGyAnYbWq+CiP6IcX8ELRGQFCrbi4UF15Jpfq+koTapwW+Zt Pmr+gp0rGwjGY/pEi1dkNAg= X-Google-Smtp-Source: AHgI3Iao76/9nHjOvhtGofwVHiGzIfP0htaKU1aEOBSfwp7QOOHnTgcfACBbKClT/YErj56TnK7kMQ== X-Received: by 2002:a02:1ac3:: with SMTP id 186mr5489957jai.96.1551112945576; Mon, 25 Feb 2019 08:42:25 -0800 (PST) Received: from svens-asus.arcx.com ([184.94.50.30]) by smtp.gmail.com with ESMTPSA id l2sm4049549ioj.55.2019.02.25.08.42.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Feb 2019 08:42:24 -0800 (PST) From: Sven Van Asbroeck X-Google-Original-From: Sven Van Asbroeck To: Russell King - ARM Linux admin , Mark Brown , Peter Ujfalusi , Jyri Sarha Date: Mon, 25 Feb 2019 11:42:17 -0500 Message-Id: <20190225164218.19439-1-TheSven73@gmail.com> X-Mailer: git-send-email 2.17.1 Cc: alsa-devel@alsa-project.org, Kuninori Morimoto , David Airlie , Takashi Iwai , Liam Girdwood , dri-devel@lists.freedesktop.org, Daniel Vetter Subject: [alsa-devel] [RFC PATCH 1/2] ASoC: simple-card: add support for bclk_ratio 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP In some situations, codec configuration will depend on the bclk_ratio generated by the cpu dai. The tda998x hdmi transmitter is an example of this. Allow simple-card to set the bclk_ratio via the 'bclk-slot-ratio' devicetree property, which describes the bclk to slot rate ratio. This value is converted to the bclk to sample ratio before being passed into set_bclk_ratio(). Signed-off-by: Sven Van Asbroeck --- sound/soc/generic/simple-card.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 3fe34417ec89..61e9ba4e9b58 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -25,6 +25,7 @@ struct simple_card_data { struct asoc_simple_card_data adata; struct snd_soc_codec_conf *codec_conf; unsigned int mclk_fs; + unsigned int bclk_slot_ratio; } *dai_props; struct asoc_simple_jack hp_jack; struct asoc_simple_jack mic_jack; @@ -97,7 +98,7 @@ static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream, struct simple_card_data *priv = snd_soc_card_get_drvdata(rtd->card); struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num); - unsigned int mclk, mclk_fs = 0; + unsigned int mclk, bclk_ratio, mclk_fs = 0, bclk_slot_ratio = 0; int ret = 0; if (dai_props->mclk_fs) @@ -124,6 +125,23 @@ static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream, if (ret && ret != -ENOTSUPP) goto err; } + + if (dai_props->bclk_slot_ratio) + bclk_slot_ratio = dai_props->bclk_slot_ratio; + + if (bclk_slot_ratio) { + /* FIXME do we need to care about TDM slots here ? */ + bclk_ratio = snd_soc_calc_frame_size(bclk_slot_ratio, + params_channels(params), 1); + + ret = snd_soc_dai_set_bclk_ratio(codec_dai, bclk_ratio); + if (ret && ret != -ENOTSUPP) + goto err; + + ret = snd_soc_dai_set_bclk_ratio(cpu_dai, bclk_ratio); + if (ret && ret != -ENOTSUPP) + goto err; + } return 0; err: return ret; @@ -277,6 +295,12 @@ static int asoc_simple_card_dai_link_of_dpcm(struct device_node *top, of_property_read_u32(node, prop, &dai_props->mclk_fs); of_property_read_u32(np, prop, &dai_props->mclk_fs); + snprintf(prop, sizeof(prop), "%sbclk-slot-ratio", prefix); + of_property_read_u32(top, PREFIX "bclk-slot-ratio", + &dai_props->bclk_slot_ratio); + of_property_read_u32(node, prop, &dai_props->bclk_slot_ratio); + of_property_read_u32(np, prop, &dai_props->bclk_slot_ratio); + ret = asoc_simple_card_parse_daifmt(dev, node, codec, prefix, &dai_link->dai_fmt); if (ret < 0) @@ -349,6 +373,13 @@ static int asoc_simple_card_dai_link_of(struct device_node *top, of_property_read_u32(cpu, prop, &dai_props->mclk_fs); of_property_read_u32(codec, prop, &dai_props->mclk_fs); + snprintf(prop, sizeof(prop), "%sbclk-slot-ratio", prefix); + of_property_read_u32(top, PREFIX "bclk-slot-ratio", + &dai_props->bclk_slot_ratio); + of_property_read_u32(node, prop, &dai_props->bclk_slot_ratio); + of_property_read_u32(cpu, prop, &dai_props->bclk_slot_ratio); + of_property_read_u32(codec, prop, &dai_props->bclk_slot_ratio); + ret = asoc_simple_card_parse_cpu(cpu, dai_link, DAI, CELL, &single_cpu); if (ret < 0) From patchwork Mon Feb 25 16:42:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Van Asbroeck X-Patchwork-Id: 10828933 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 917B6922 for ; Mon, 25 Feb 2019 17:09:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71CFD29F7D for ; Mon, 25 Feb 2019 17:09:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 639732A0D5; Mon, 25 Feb 2019 17:09:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 84BC729F7D for ; Mon, 25 Feb 2019 17:09:08 +0000 (UTC) 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 80BFB166C; Mon, 25 Feb 2019 17:43:38 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 80BFB166C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1551113068; bh=tdV7P2dbiPVzPRFrpoV6R3/TL/AxjUlZgy5q7t7oOYY=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=idGO2TXHviyWkikikUsUHKfSa83tRCQ8Z7SEg77fuzC03+8Xb/rTqftE9I7LN1ggD d5Ps2yq6P+1qsEnniKPW+hhAD9Z6rVudIFsWorWh5ibZDnoAU4Cko1tZBWhOuh/70s X8auMacsE1lMcs30b+XXRwVYxKrjMLfgKABMJvYs= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 48D15F8966C; Mon, 25 Feb 2019 17:42:35 +0100 (CET) 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 BFFFAF8965C; Mon, 25 Feb 2019 17:42:31 +0100 (CET) Received: from mail-it1-x144.google.com (mail-it1-x144.google.com [IPv6:2607:f8b0:4864:20::144]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id A5256F89656 for ; Mon, 25 Feb 2019 17:42:28 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A5256F89656 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dsMeTdjt" Received: by mail-it1-x144.google.com with SMTP id i2so14287335ite.5 for ; Mon, 25 Feb 2019 08:42:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=G573mII/H/07wIJC4l9XC5m8MWa4IzbRGvELz9c19NA=; b=dsMeTdjt9kifROuXHJXJAEqW32aBeg0MKpOBn+iJbuaBIhcyY2rjXnNTm2LUO7UBwV SPAg3YMdO6xxbCX3n3s78yzcGx9pq4LkT35WQVgeRoJzuWB+kbAiwJbRiiX2vMJaegDk aeUfPl6I27eTfgDTksf6xH/tIo7kP2wvQrwUExShZisFhQ3pupp60j2tIHbFShpV7t5P QhADb/CXDXy58GdXzlWmFT0VKJi33zWJk9hUQfiGheqfV12GOuBngmKluyUMOsvwdhVr 0sf3Du39cg5+SJdL+qN6Vu5YUecal5GFgjcSRNwv1YWlWWZ/3P9Em4KGahQTXm5+Zii9 /vbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=G573mII/H/07wIJC4l9XC5m8MWa4IzbRGvELz9c19NA=; b=bj6woaeO82fxlY3sOQVbnGPElIjtGKZb15NTUxxetmsxf+eY4XYqcaeiUewthi7vCz c0KqqA07t5JYYZGyHYM4e39/cHndw/LcU7SouCrTRUr18b/8RoDuBh2TGXj3BkNm00aN 2quynopFh7A1uZj/ZoUyHdRnS/x0eRqv4cCgAuLXWGT4NyaAIp1WB0+Y9B3vgduReppX aef8Fd7atqO5uNuvd2Toc8JH4dhFbGIJllYgrwx94meWvTgtxbTH379QZKYEceNPCaag Zl3jQZt9OApxG7lZ++WopG5nL0GfGfmo83Cb1KfiaoWi7RG322VjI42WlAdyuaiBrALu fWeg== X-Gm-Message-State: AHQUAuZnwUR9bcoCNl+kXt6OItxZKquHGZzUdiGEgx4+G90y2OpwMp4v TTmZ5YyseVU+Id1lefnFAqQ= X-Google-Smtp-Source: AHgI3IYYytotseBqN5azYu9+KA3bnqza6FH4lViNZE0TSuPCDyuubvld15kZs9WneOBt1V9uk8iE6g== X-Received: by 2002:a24:f804:: with SMTP id a4mr1277627ith.2.1551112946697; Mon, 25 Feb 2019 08:42:26 -0800 (PST) Received: from svens-asus.arcx.com ([184.94.50.30]) by smtp.gmail.com with ESMTPSA id l2sm4049549ioj.55.2019.02.25.08.42.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Feb 2019 08:42:26 -0800 (PST) From: Sven Van Asbroeck X-Google-Original-From: Sven Van Asbroeck To: Russell King - ARM Linux admin , Mark Brown , Peter Ujfalusi , Jyri Sarha Date: Mon, 25 Feb 2019 11:42:18 -0500 Message-Id: <20190225164218.19439-2-TheSven73@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190225164218.19439-1-TheSven73@gmail.com> References: <20190225164218.19439-1-TheSven73@gmail.com> Cc: alsa-devel@alsa-project.org, Kuninori Morimoto , David Airlie , Takashi Iwai , Liam Girdwood , dri-devel@lists.freedesktop.org, Daniel Vetter Subject: [alsa-devel] [RFC PATCH 2/2] ASoC: core: standardize snd_soc_dai_set_bclk_ratio() behaviour 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP snd_soc_dai_set_bclk_ratio() should behave like other snd_soc_dai_XXX functions, and return -ENOTSUPP if the callback in driver->ops is NULL. Signed-off-by: Sven Van Asbroeck --- sound/soc/soc-core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 50617db05c46..5611caf25ea3 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -2550,10 +2550,11 @@ EXPORT_SYMBOL_GPL(snd_soc_component_set_pll); */ int snd_soc_dai_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) { - if (dai->driver->ops->set_bclk_ratio) - return dai->driver->ops->set_bclk_ratio(dai, ratio); - else + if (dai->driver == NULL) return -EINVAL; + if (dai->driver->ops->set_bclk_ratio == NULL) + return -ENOTSUPP; + return dai->driver->ops->set_bclk_ratio(dai, ratio); } EXPORT_SYMBOL_GPL(snd_soc_dai_set_bclk_ratio);