Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp6029075ybg; Tue, 22 Oct 2019 11:59:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqxZk5D8D/yhy9h3DyfVM08hODlV2rNIl8iZY9NehdQnIYQzC65JfqYHridUygh6dg1cmB+m X-Received: by 2002:a17:906:1942:: with SMTP id b2mr29000477eje.36.1571770750356; Tue, 22 Oct 2019 11:59:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571770750; cv=none; d=google.com; s=arc-20160816; b=lYdG+1bhrucB6KvkCrK4quBsWMH6AvDqZF+tQ5HPokdKWcbPqPKI6Fo0fRKM0OZE9U O3Jw0gWUc36bcLjyf+Z0H0y4nfMHg0v6FWaepq/4GaIFPsyE7gxv08sHVopDoyIDX6Qm rqk5x85mTbJLwhc39xkap3khlRm1fctdDSdedsFvG26UWpVYI+lwkXOXbaCrZ6R0qi+f 5hz9KwxEKrRD67bOIT3E+7/o3rCfyscVyr3/mZwbxW8V4xco/gFNvCALGH12fibn8ny+ KOA1syz/8I1g+RkF0fRwsk/+ZWVFTwyQ+P854fFuQFeJiqC0j8lN8Uteu+O8+YunxaXO 5n9w== 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 :message-id:date:subject:cc:to:from; bh=7eYTJSjXMJ38VZy7KJWHB6F9A9RcYijrcxQyGeG3Who=; b=Cop4EQu+p2EMyyJP3boq4DLd1ETzG9Kolw+vmCyB7fTw4f+tC7o8SVS514UNh0qGqS d2WzGUhrB1zNXY9J2LxEDfC8K9eSpecgRU6ClEzqvC128qcUqBQL0CPVvaxz1q/I3a57 Bkj0JxdrBT+oxD7Z59fzquY32i4E71OYjEemDKM1JQ8y5lBsOyDc7zTiTFXKAGvugwSg CGDAZOQaG1uy/sDxp7wNv3K8XonhjjUdvlG3OfVlANs/sPZtLoUUWg7Zu/T0u2M67SwF qU3tw3h9QawZ9QQnhbFeTwr91Yv3veHrLCZTwF1ChlG0NpyZUzfnZouZPdRTOyJHwdVq hiTg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h2si11896728edw.29.2019.10.22.11.58.46; Tue, 22 Oct 2019 11:59:10 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387913AbfJVSze (ORCPT + 99 others); Tue, 22 Oct 2019 14:55:34 -0400 Received: from smtp1.de.adit-jv.com ([93.241.18.167]:34787 "EHLO smtp1.de.adit-jv.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727851AbfJVSze (ORCPT ); Tue, 22 Oct 2019 14:55:34 -0400 Received: from localhost (smtp1.de.adit-jv.com [127.0.0.1]) by smtp1.de.adit-jv.com (Postfix) with ESMTP id 710263C0579; Tue, 22 Oct 2019 20:55:32 +0200 (CEST) Received: from smtp1.de.adit-jv.com ([127.0.0.1]) by localhost (smtp1.de.adit-jv.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Vq_DkLNWpUpD; Tue, 22 Oct 2019 20:55:27 +0200 (CEST) Received: from HI2EXCH01.adit-jv.com (hi2exch01.adit-jv.com [10.72.92.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by smtp1.de.adit-jv.com (Postfix) with ESMTPS id 354CC3C009D; Tue, 22 Oct 2019 20:55:27 +0200 (CEST) Received: from vmlxhi-102.adit-jv.com (10.72.93.184) by HI2EXCH01.adit-jv.com (10.72.92.24) with Microsoft SMTP Server (TLS) id 14.3.468.0; Tue, 22 Oct 2019 20:55:26 +0200 From: Eugeniu Rosca To: Kuninori Morimoto , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , , CC: Eugeniu Rosca , Eugeniu Rosca , Jiada Wang , Andrew Gabbasov , Timo Wischer Subject: [PATCH] ASoC: rsnd: dma: set bus width to data width for monaural data Date: Tue, 22 Oct 2019 20:55:18 +0200 Message-ID: <20191022185518.12838-1-erosca@de.adit-jv.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.72.93.184] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiada Wang According to R-Car3 HW manual 40.3.3 (Data Format on Audio Local Bus), in case of monaural data writing or reading through Audio-DMAC, it's always in Left Justified format, so both src and dst DMA Bus width should be equal to physical data width. Therefore set src and dst's DMA bus width to: - [monaural case] data width - [non-monaural case] 32bits (as prior applying the patch) Cc: Andrew Gabbasov Cc: Timo Wischer Signed-off-by: Jiada Wang Signed-off-by: Eugeniu Rosca --- sound/soc/sh/rcar/dma.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/sound/soc/sh/rcar/dma.c b/sound/soc/sh/rcar/dma.c index 28f65eba2bb4..95aa26d62e4f 100644 --- a/sound/soc/sh/rcar/dma.c +++ b/sound/soc/sh/rcar/dma.c @@ -165,14 +165,40 @@ static int rsnd_dmaen_start(struct rsnd_mod *mod, struct device *dev = rsnd_priv_to_dev(priv); struct dma_async_tx_descriptor *desc; struct dma_slave_config cfg = {}; + enum dma_slave_buswidth buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES; int is_play = rsnd_io_is_play(io); int ret; + /* + * in case of monaural data writing or reading through Audio-DMAC + * data is always in Left Justified format, so both src and dst + * DMA Bus width need to be set equal to physical data width. + */ + if (rsnd_runtime_channel_original(io) == 1) { + struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); + int bits = snd_pcm_format_physical_width(runtime->format); + + switch (bits) { + case 8: + buswidth = DMA_SLAVE_BUSWIDTH_1_BYTE; + break; + case 16: + buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES; + break; + case 32: + buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES; + break; + default: + dev_err(dev, "invalid format width %d\n", bits); + return -EINVAL; + } + } + cfg.direction = is_play ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM; cfg.src_addr = dma->src_addr; cfg.dst_addr = dma->dst_addr; - cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; - cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; + cfg.src_addr_width = buswidth; + cfg.dst_addr_width = buswidth; dev_dbg(dev, "%s %pad -> %pad\n", rsnd_mod_name(mod), -- 2.23.0