Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp7169204ybp; Wed, 16 Oct 2019 04:58:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqznVb/hE62kHHRkBbRzBtKREdPjuE+eKMZ0Yk6MSrozldWo/gchABXrS0t7Umf+oi6G6tc6 X-Received: by 2002:a50:f704:: with SMTP id g4mr38135049edn.255.1571227105817; Wed, 16 Oct 2019 04:58:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571227105; cv=none; d=google.com; s=arc-20160816; b=TAg1OrJTrFShQtYBNZbqF8LXJliGFDWsG2WpUU0srEV5ygqbkxZLrIgCAnZNHnn4/P y/YR2XPsdkRVdHr0LI4xpzwO3BPnGTEtLthqg84rc8qWv10E8MyZ8PZcXYajyjuLeww2 WE0+1Tk9Y4xt3XFmEPuqA4V+0o85ord1CDcuiM45OJBk8+FWz1P/7EhrwBklCmiv/V86 axsQcbA2HPbOsHN3ejeShayHkvMedv9MMGc/wgO5AJcaM4lAL96s3TPD7NHo6StuG5Fo qyU4cA5Ho77NNC8N/A//39YQLM6x8y8LnN8rZD5FItnvue6Kj1KqMnVBX/ZC4zUJgiGn Q8/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=FfnwO8vvijCwZxuUL06QD5Tx1fxFqAFTG2kXsJEWJMY=; b=qBzlq4XJoYOEVGYrE2uusmyCzMsicpGd4gleeB/SpuLGR6IW5i9qVBwGofYuYGCcJ0 YBupGgjf7wV5WTzDYcVph4dZ+bLmcqzr5J863S7xIJQoH/f1MVzYWHn+o+FTS5f4vJTP +9RMoASfm1rUVWNArJhNbmEwhrpDJgF06oZowjMLyrskjDeRdQKytgNAMPnYdQjpfpV6 9LRuEOA67jvJT7HulBcxfOe5Gp0kf/fPnm8RfUqOoNGWbK8zo2CXKKmvSt5b6UXbNe8b JVs0IcHSCkAeXUoosjyas1Ij/MjsP4bAHncwD8zLxUkiKSqB+ugdPOZ7npKrW70jnfmd 3wUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=P7jKcqJW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f11si15697656ejw.116.2019.10.16.04.58.03; Wed, 16 Oct 2019 04:58:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=P7jKcqJW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389713AbfJPHHw (ORCPT + 99 others); Wed, 16 Oct 2019 03:07:52 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:40010 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389634AbfJPHHv (ORCPT ); Wed, 16 Oct 2019 03:07:51 -0400 Received: by mail-lf1-f68.google.com with SMTP id f23so1009886lfk.7 for ; Wed, 16 Oct 2019 00:07:49 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=FfnwO8vvijCwZxuUL06QD5Tx1fxFqAFTG2kXsJEWJMY=; b=P7jKcqJWpHrW1gaub0fSy2vbAtI/feqgoOpswUlXO9Je+VTo59n3zc/RFhfKNPOHYo X5RCZt1cS1NVGjTKtTS5zTsXPdX2MFhM5jti2LrRKX0HtZjSy6X89TEvTCgHOH6dZApV JhSyjrS8Jv3ik/H7deMyV9fRxuNoNZdx8yPbx2I5BvIs5Y1NXhK115S8cbJvzlW7wgwr m7YhX1l8TsMUm9UfJOnlonv/WJ92jOmqjnwJc2+N757v9eYaQ0dXoLImO+zfrilQHiuR 3zAm4rCjVZcgWEW0V4HPRLXhOKetlFT2zdktVefFU2P696B8kikobkWenLpt4C8fmDap BJcA== 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:mime-version:content-transfer-encoding; bh=FfnwO8vvijCwZxuUL06QD5Tx1fxFqAFTG2kXsJEWJMY=; b=ZIhPubbKh5NvxVQiBAxGeWywWnDZlP7UojpX77owKIwT657W7Umy80IhDWPXz+dy4h Qn8ElgLDlCMCKgUi6HEWnMXmWGr+vVuKcAVcI92oQVeJmuXnUWdgn86nFNpSF1/Qy83L OUiMyfVR8FV+UdiL+B39MNzCaHp/WhT4HcZSB4pOD+EAyKpxkEU1L5m+CRXn30UkV5dx qLbdwCbYX2KDHa7zbS5Xwq87a3Mq+I/5GGPonRnhynG4XNUFCkdepBgXo6fKtvn56ziP 5XcwCpcuA5bRjHHPXdnKUMs6kXXRY0uGbhCrhnp6Dxw9BanBkq0qYvCNCoa+MlulYjIQ 31/Q== X-Gm-Message-State: APjAAAUOophYsu8C747CAtcmMHR0M6nlIVHacPHI3QnKaSremgRLhCp/ gylSSe2Pt/p563GoghwsTzEwkKHC X-Received: by 2002:a05:6512:403:: with SMTP id u3mr11797775lfk.135.1571209669188; Wed, 16 Oct 2019 00:07:49 -0700 (PDT) Received: from localhost.localdomain (c213-102-65-51.bredband.comhem.se. [213.102.65.51]) by smtp.gmail.com with ESMTPSA id j191sm1361493lfj.49.2019.10.16.00.07.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2019 00:07:48 -0700 (PDT) From: codekipper@gmail.com To: mripard@kernel.org, wens@csie.org, linux-sunxi@googlegroups.com Cc: linux-arm-kernel@lists.infradead.org, lgirdwood@gmail.com, broonie@kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, be17068@iperbole.bo.it, Marcus Cooper Subject: [PATCH v6 5/7] ASoC: sun4i-i2s: Add functions for RX and TX channel mapping Date: Wed, 16 Oct 2019 09:07:38 +0200 Message-Id: <20191016070740.121435-6-codekipper@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191016070740.121435-1-codekipper@gmail.com> References: <20191016070740.121435-1-codekipper@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marcus Cooper As we will eventually add multi-channel audio support to the i2s then create function calls as opposed to regmap fields to add support for different devices. Signed-off-by: Marcus Cooper --- sound/soc/sunxi/sun4i-i2s.c | 45 +++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index 19988d61a085..63ae9da180f2 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -165,6 +165,8 @@ struct sun4i_i2s_quirks { void (*set_rxchanen)(const struct sun4i_i2s *, int); void (*set_txchansel)(const struct sun4i_i2s *, int, int); void (*set_rxchansel)(const struct sun4i_i2s *, int); + void (*set_txchanmap)(const struct sun4i_i2s *, int, int); + void (*set_rxchanmap)(const struct sun4i_i2s *, int); }; struct sun4i_i2s { @@ -405,8 +407,8 @@ static int sun4i_i2s_set_chan_cfg(const struct sun4i_i2s *i2s, unsigned int channels = params_channels(params); /* Map the channels for playback and capture */ - regmap_write(i2s->regmap, SUN4I_I2S_TX_CHAN_MAP_REG, 0x76543210); - regmap_write(i2s->regmap, SUN4I_I2S_RX_CHAN_MAP_REG, 0x00003210); + i2s->variant->set_txchanmap(i2s, 0, 0x76543210); + i2s->variant->set_rxchanmap(i2s, 0x00003210); /* Configure the channels */ i2s->variant->set_txchansel(i2s, 0, channels); @@ -426,8 +428,8 @@ static int sun8i_i2s_set_chan_cfg(const struct sun4i_i2s *i2s, slots = i2s->slots; /* Map the channels for playback and capture */ - regmap_write(i2s->regmap, SUN8I_I2S_TX_CHAN_MAP_REG, 0x76543210); - regmap_write(i2s->regmap, SUN8I_I2S_RX_CHAN_MAP_REG, 0x76543210); + i2s->variant->set_txchanmap(i2s, 0, 0x76543210); + i2s->variant->set_rxchanmap(i2s, 0x00003210); /* Configure the channels */ i2s->variant->set_txchansel(i2s, 0, channels); @@ -534,6 +536,31 @@ static void sun8i_i2s_set_rxchansel(const struct sun4i_i2s *i2s, int channel) SUN8I_I2S_TX_CHAN_SEL(channel)); } +static void sun4i_i2s_set_txchanmap(const struct sun4i_i2s *i2s, int output, + int channel) +{ + if (output == 0) + regmap_write(i2s->regmap, SUN4I_I2S_TX_CHAN_MAP_REG, channel); +} + +static void sun8i_i2s_set_txchanmap(const struct sun4i_i2s *i2s, int output, + int channel) +{ + if (output >= 0 && output < 4) + regmap_write(i2s->regmap, + SUN8I_I2S_TX_CHAN_MAP_REG + (output * 4), channel); +} + +static void sun4i_i2s_set_rxchanmap(const struct sun4i_i2s *i2s, int channel) +{ + regmap_write(i2s->regmap, SUN4I_I2S_RX_CHAN_MAP_REG, channel); +} + +static void sun8i_i2s_set_rxchanmap(const struct sun4i_i2s *i2s, int channel) +{ + regmap_write(i2s->regmap, SUN8I_I2S_RX_CHAN_MAP_REG, channel); +} + static int sun4i_i2s_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) @@ -1154,6 +1181,8 @@ static const struct sun4i_i2s_quirks sun4i_a10_i2s_quirks = { .set_fmt = sun4i_i2s_set_soc_fmt, .set_txchansel = sun4i_i2s_set_txchansel, .set_rxchansel = sun4i_i2s_set_rxchansel, + .set_txchanmap = sun4i_i2s_set_txchanmap, + .set_rxchanmap = sun4i_i2s_set_rxchanmap, }; static const struct sun4i_i2s_quirks sun6i_a31_i2s_quirks = { @@ -1174,6 +1203,8 @@ static const struct sun4i_i2s_quirks sun6i_a31_i2s_quirks = { .set_fmt = sun4i_i2s_set_soc_fmt, .set_txchansel = sun4i_i2s_set_txchansel, .set_rxchansel = sun4i_i2s_set_rxchansel, + .set_txchanmap = sun4i_i2s_set_txchanmap, + .set_rxchanmap = sun4i_i2s_set_rxchanmap, }; /* @@ -1199,6 +1230,8 @@ static const struct sun4i_i2s_quirks sun8i_a83t_i2s_quirks = { .set_fmt = sun4i_i2s_set_soc_fmt, .set_txchansel = sun4i_i2s_set_txchansel, .set_rxchansel = sun4i_i2s_set_rxchansel, + .set_txchanmap = sun4i_i2s_set_txchanmap, + .set_rxchanmap = sun4i_i2s_set_rxchanmap, }; static const struct sun4i_i2s_quirks sun8i_h3_i2s_quirks = { @@ -1223,6 +1256,8 @@ static const struct sun4i_i2s_quirks sun8i_h3_i2s_quirks = { .set_rxchanen = sun8i_i2s_set_rxchanen, .set_txchansel = sun8i_i2s_set_txchansel, .set_rxchansel = sun8i_i2s_set_rxchansel, + .set_txchanmap = sun8i_i2s_set_txchanmap, + .set_rxchanmap = sun8i_i2s_set_rxchanmap, }; static const struct sun4i_i2s_quirks sun50i_a64_codec_i2s_quirks = { @@ -1243,6 +1278,8 @@ static const struct sun4i_i2s_quirks sun50i_a64_codec_i2s_quirks = { .set_fmt = sun4i_i2s_set_soc_fmt, .set_txchansel = sun4i_i2s_set_txchansel, .set_rxchansel = sun4i_i2s_set_rxchansel, + .set_txchanmap = sun4i_i2s_set_txchanmap, + .set_rxchanmap = sun4i_i2s_set_rxchanmap, }; static int sun4i_i2s_init_regmap_fields(struct device *dev, -- 2.23.0