From patchwork Wed Sep 12 11:47:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 1443061 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id D60ABDF28C for ; Wed, 12 Sep 2012 11:49:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757485Ab2ILLsr (ORCPT ); Wed, 12 Sep 2012 07:48:47 -0400 Received: from na3sys009aog136.obsmtp.com ([74.125.149.85]:37780 "EHLO na3sys009aog136.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754982Ab2ILLq5 (ORCPT ); Wed, 12 Sep 2012 07:46:57 -0400 Received: from mail-ob0-f174.google.com ([209.85.214.174]) (using TLSv1) by na3sys009aob136.postini.com ([74.125.148.12]) with SMTP ID DSNKUFB2MACxQBaEjOYCDzb/1pYZp6QL00a5@postini.com; Wed, 12 Sep 2012 04:46:57 PDT Received: by obbuo13 with SMTP id uo13so2442360obb.19 for ; Wed, 12 Sep 2012 04:46:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=UtGfYuLuyrSU7zB06rd9Tsg/DHBKr8rJ4GDF3kZIIpQ=; b=Bs+zXlEOAqf+J4QwbVynCRbDVCJ6+PsPoE9jGGUtyi1uA0tHvFJ7ScjGyEntxJ0rFU fYFyDCZWdNhRbZs38dFMsZu9caYcwTHelfEdKOINEIWzdy10Pb9VYBaTV9GBXBvF2clS lBTQbh7gsHuQ2OWQWSBnZdlmAYI4dw0m/3rciEEfOn4P4gTLplsVKyYZC7RtQnJ+27YG LS57kd+LssVO0UI15h6jrQXOScDOZf6/7oaHCGarkmIKaooGjxMh/D4tpQlVOIukKqnK 9+fIgwkA36+LWBNSDz/UQzCzE7eocxVpJGbG1NZPPRYWfzRwMWVYWE6h44GC/ppDunkP LIpQ== Received: by 10.60.27.6 with SMTP id p6mr21490995oeg.37.1347450416171; Wed, 12 Sep 2012 04:46:56 -0700 (PDT) Received: from barack.emea.dhcp.ti.com (dragon.ti.com. [192.94.94.33]) by mx.google.com with ESMTPS id c6sm19835570obd.22.2012.09.12.04.46.53 (version=SSLv3 cipher=OTHER); Wed, 12 Sep 2012 04:46:55 -0700 (PDT) From: Peter Ujfalusi To: Mark Brown , Liam Girdwood , Tony Lindgren , Russell King , Vinod Koul , Dan Williams , Jarkko Nikula Cc: alsa-devel@alsa-project.org, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Janusz Krzysztofik , Ricardo Neri Subject: [PATCH 05/11] ASoC: omap-pcm: Prepare to configure the DMA data_type based on stream properties Date: Wed, 12 Sep 2012 14:47:01 +0300 Message-Id: <1347450427-27627-6-git-send-email-peter.ujfalusi@ti.com> X-Mailer: git-send-email 1.7.12 In-Reply-To: <1347450427-27627-1-git-send-email-peter.ujfalusi@ti.com> References: <1347450427-27627-1-git-send-email-peter.ujfalusi@ti.com> X-Gm-Message-State: ALoCoQkfAJTWD40bYdwTSELgckGbq49ls+2R2c0Mb4RJ9Htz3ovmLZri6SqJgKdxRgrbxZPCoV+h Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Based on the format of the stream the omap-pcm can decide alone what data type should be used with by the sDMA. Keep the possibility for OMAP dai drivers to tell omap-pcm if they want to use different data type. This is needed for the omap-hdmi for example which needs 32bit data type even if the stream format is S16_LE. The check if (dma_data->data_type) is safe at the moment since omap-pcm does not support 8bit samples (OMAP_DMA_DATA_TYPE_S8 == 0x00). The next step is to redefine the meaning of dma_data->data_type to unblock this limitation. Signed-off-by: Peter Ujfalusi --- sound/soc/omap/omap-pcm.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c index 02eeb2e..4c13a5f 100644 --- a/sound/soc/omap/omap-pcm.c +++ b/sound/soc/omap/omap-pcm.c @@ -149,6 +149,24 @@ static int omap_pcm_hw_free(struct snd_pcm_substream *substream) return 0; } +static int omap_pcm_get_dma_type(int num_bits) +{ + int data_type; + + switch (num_bits) { + case 16: + data_type = OMAP_DMA_DATA_TYPE_S16; + break; + case 32: + data_type = OMAP_DMA_DATA_TYPE_S32; + break; + default: + data_type = -EINVAL; + break; + } + return data_type; +} + static int omap_pcm_prepare(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; @@ -163,7 +181,16 @@ static int omap_pcm_prepare(struct snd_pcm_substream *substream) return 0; memset(&dma_params, 0, sizeof(dma_params)); - dma_params.data_type = dma_data->data_type; + + if (dma_data->data_type) + dma_params.data_type = dma_data->data_type; + else + dma_params.data_type = omap_pcm_get_dma_type( + snd_pcm_format_physical_width(runtime->format)); + + if (dma_params.data_type < 0) + return dma_params.data_type; + dma_params.trigger = dma_data->dma_req; if (dma_data->packet_size) @@ -195,7 +222,7 @@ static int omap_pcm_prepare(struct snd_pcm_substream *substream) * still can get an interrupt at each period bounary */ bytes = snd_pcm_lib_period_bytes(substream); - dma_params.elem_count = bytes >> dma_data->data_type; + dma_params.elem_count = bytes >> dma_params.data_type; dma_params.frame_count = runtime->periods; omap_set_dma_params(prtd->dma_ch, &dma_params);