From patchwork Wed Jan 24 14:10:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Code Kipper X-Patchwork-Id: 10182627 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D876D60233 for ; Wed, 24 Jan 2018 14:12:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C898528896 for ; Wed, 24 Jan 2018 14:12:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD3BF2889F; Wed, 24 Jan 2018 14:12:24 +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=-4.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4E85528896 for ; Wed, 24 Jan 2018 14:12:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=+ewme4+PrF9RPqosHyzDwG2SxIuJb01qZGnCMFqsHwk=; b=AnFLOuOwyh0EhsHYUkd+gBNw0G xIGW6QBi+z5mQzG/7pKEpJv5tlNnSWGvf5Jp1rkAJVki/vYd1wC1o/syvP9hTyuteASX+jdTyBQLU v4DMRBSqZn3OdghmyqzhltqNu7ZlOkC3zEdnWRlvM/98Nn490rUix9AWVWYk+r/qBpvVa5hF1au5N 3agNmZSmkwD75CJyuN9HGYtusic4BhYa5ZPfWybrW6onPh6SdOrunrbSAmXaTc3GwFxss6EopubeX Z6SwbYZVvGIGqEad2Bb2y65xZHQ9B5T6HMtLakfpssIb4xgGQyuO4xVrePfGNLsQdZN8Q7NAgrJqB HoaydN/g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eeLmm-0007bx-MQ; Wed, 24 Jan 2018 14:12:20 +0000 Received: from mail-lf0-x241.google.com ([2a00:1450:4010:c07::241]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eeLln-00067t-RD for linux-arm-kernel@lists.infradead.org; Wed, 24 Jan 2018 14:11:26 +0000 Received: by mail-lf0-x241.google.com with SMTP id f136so5396739lff.8 for ; Wed, 24 Jan 2018 06:11:06 -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=Z4mbiv/WjUogfRi1khRBXb/8Vp5w+eaGW1TtX+JuIcA=; b=oQrgxBBv65ey9wqeRzjgzr99U/tv4iqnlWFFe9Mz5RhQKcMU80mdBhiZgaOMtRQgYz LOYIJ2P0FXtDY2tRNE3WswE3S7n50WlGikwTTcOh679fSCqSrhdfrxlB1uBI0sOWvnd6 5fE2OBLjC5lcTLjvXueA2amzPwHfKvUjI2ddjAAOtPP+GvJQ5QmIiukDdyA163zI5W8z ed/fPaGh6XFPQwo6hNfY9FJFng6kaeOBRxL4JIoY4YjoNuuq9tM8JHGkMN3VmpUqZIG4 JA6mdyfDuhiKdCPk34Kyk0Nid6NT/zu2FFLGZG3QbRvW3dpIBD+/ZC3vACNBf/+7ylYD DaRA== 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=Z4mbiv/WjUogfRi1khRBXb/8Vp5w+eaGW1TtX+JuIcA=; b=PoKtUf/DVjSeAaxzKDPCvy+xpQH71EVJCH2dRZop0fuBYM6w2itO+Tmxez5H5m4GLN 8QM21yumrW+dt/DuLuniF4jdfYbdzwgZh3KozeCR8cEJncX/B86AJa5d/ZqiHZG7I6bd vCZMlgO4glg5SHUrzd1Ne/u+R80kr1Uwwe9rbuvptyXriNZd7ZTcdv1klp7nNgYG4K6w kxWgYDtr1NsO9AIr6OwA9q4B756dIsoD84fehiTpu/F1oGSRUDPCdKbNlCtW9LFLfuUl FHR4Pegpx0S46wn/3RzhDAdDWAhupxGZsCUGLDVNJIQrHtLzc9+DaA5kkY/8nmGp8dLR R/Yg== X-Gm-Message-State: AKwxyte7e2x8OS256NMDX6A3B1ra8zPQar8pOF23OPDJmr4W2mbk2qhO 9Bk2dkfxOzh1OYbqb88wDkE= X-Google-Smtp-Source: AH8x2266KSb6H+Zy3RZgUp/mIBVjQscR89UWGtRUN9E4u+4W00JxQmUcc8nVyo/Vf9jpxqQR72qn7w== X-Received: by 10.46.33.18 with SMTP id h18mr3524784ljh.18.1516803064796; Wed, 24 Jan 2018 06:11:04 -0800 (PST) Received: from localhost.localdomain (c80-217-9-219.bredband.comhem.se. [80.217.9.219]) by smtp.gmail.com with ESMTPSA id r84sm579227lff.72.2018.01.24.06.11.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Jan 2018 06:11:04 -0800 (PST) From: codekipper@gmail.com To: maxime.ripard@free-electrons.com Subject: [PATCH 1/3] ASoC: sun4i-i2s: Add set_tdm_slot functionality Date: Wed, 24 Jan 2018 15:10:59 +0100 Message-Id: <20180124141101.12867-2-codekipper@gmail.com> X-Mailer: git-send-email 2.16.0 In-Reply-To: <20180124141101.12867-1-codekipper@gmail.com> References: <20180124141101.12867-1-codekipper@gmail.com> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alsa-devel@alsa-project.org, Marcus Cooper , lgirdwood@gmail.com, linux-kernel@vger.kernel.org, be17068@iperbole.bo.it, linux-sunxi@googlegroups.com, broonie@kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Marcus Cooper Some codecs require a different amount of a bit clocks per frame than what is calculated by the sample width. Use the tdm slot bindings to provide this mechanism. Signed-off-by: Marcus Cooper --- sound/soc/sunxi/sun4i-i2s.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index dca1143c1150..d7a9141514cf 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -96,6 +96,7 @@ #define SUN8I_I2S_CTRL_BCLK_OUT BIT(18) #define SUN8I_I2S_CTRL_LRCK_OUT BIT(17) +#define SUN8I_I2S_FMT0_LRCK_MAX_PERIOD (GENMASK(17, 8) >> 8) #define SUN8I_I2S_FMT0_LRCK_PERIOD_MASK GENMASK(17, 8) #define SUN8I_I2S_FMT0_LRCK_PERIOD(period) ((period - 1) << 8) @@ -193,6 +194,9 @@ struct sun4i_i2s { struct regmap_field *field_rxchansel; const struct sun4i_i2s_quirks *variant; + + unsigned int tdm_slots; + unsigned int slot_width; }; struct sun4i_i2s_clk_div { @@ -344,7 +348,7 @@ static int sun4i_i2s_set_clk_rate(struct snd_soc_dai *dai, if (i2s->variant->has_fmt_set_lrck_period) regmap_update_bits(i2s->regmap, SUN4I_I2S_FMT0_REG, SUN8I_I2S_FMT0_LRCK_PERIOD_MASK, - SUN8I_I2S_FMT0_LRCK_PERIOD(32)); + SUN8I_I2S_FMT0_LRCK_PERIOD(word_size)); return 0; } @@ -418,7 +422,8 @@ static int sun4i_i2s_hw_params(struct snd_pcm_substream *substream, sr + i2s->variant->fmt_offset); return sun4i_i2s_set_clk_rate(dai, params_rate(params), - params_width(params)); + i2s->tdm_slots ? + i2s->slot_width : params_width(params)); } static int sun4i_i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) @@ -691,6 +696,19 @@ static int sun4i_i2s_set_sysclk(struct snd_soc_dai *dai, int clk_id, return 0; } +static int sun4i_i2s_set_dai_tdm_slot(struct snd_soc_dai *dai, + unsigned int tx_mask, unsigned int rx_mask, + int slots, int width) +{ + struct sun4i_i2s *i2s = snd_soc_dai_get_drvdata(dai); + + i2s->tdm_slots = slots; + + i2s->slot_width = width; + + return 0; +} + static const struct snd_soc_dai_ops sun4i_i2s_dai_ops = { .hw_params = sun4i_i2s_hw_params, .set_fmt = sun4i_i2s_set_fmt, @@ -698,6 +716,7 @@ static const struct snd_soc_dai_ops sun4i_i2s_dai_ops = { .shutdown = sun4i_i2s_shutdown, .startup = sun4i_i2s_startup, .trigger = sun4i_i2s_trigger, + .set_tdm_slot = sun4i_i2s_set_dai_tdm_slot, }; static int sun4i_i2s_dai_probe(struct snd_soc_dai *dai)