From patchwork Fri May 29 13:31:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Nie X-Patchwork-Id: 49218 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 39D67218E7 for ; Fri, 29 May 2015 13:35:52 +0000 (UTC) Received: by laat2 with SMTP id t2sf20706426laa.2 for ; Fri, 29 May 2015 06:35:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :mime-version:content-type:content-transfer-encoding:errors-to :sender:x-original-sender:x-original-authentication-results :mailing-list; bh=D4cqO/kgKuu2tWiw5iRvpvhVmfVx4CcA+C1/kkXLQ58=; b=iERjaN369PrQdYKj2qgexNK+Hx05jzYvmvh08EbhUrzwXExFGihA1KhLh08dMX8ti3 7tF8FH0IfpWM3wJi50g0HOj+7cIgWinbT4bFvXG0UAXp35ZgooNrxfLWjQC+gu8iqAhy 8tb1tcDOrDgxsln2T51OFov+3CQwCps2WOguC2Kdik00BeEz/3z7enQUqZL6B7Ph6nCY i9f9xxLXWkLNz3WenrWFrc/FRRZ6yYipf00F0m/FgFS77cHxjrhKd4mmLEIjQTfj3fDW 4BYFJLI09RT95ifYsqY8KieI9GGMbH1UvUDNdbORRY96HWNbM8TA4fY0m2qrmbT8+SCU JQCw== X-Gm-Message-State: ALoCoQnrmXrqA90TkVMVBSOTYuTnJWvB2HUp5SwO7pEyObSa67xCgxgeMlRSD3v2zDzYbHEkjFi+ X-Received: by 10.112.166.137 with SMTP id zg9mr7419641lbb.11.1432906551117; Fri, 29 May 2015 06:35:51 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.206.98 with SMTP id ln2ls86777lac.91.gmail; Fri, 29 May 2015 06:35:51 -0700 (PDT) X-Received: by 10.112.134.167 with SMTP id pl7mr7964440lbb.50.1432906550973; Fri, 29 May 2015 06:35:50 -0700 (PDT) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id k9si4699250lah.119.2015.05.29.06.35.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 May 2015 06:35:50 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by labko7 with SMTP id ko7so52315484lab.2 for ; Fri, 29 May 2015 06:35:50 -0700 (PDT) X-Received: by 10.112.198.74 with SMTP id ja10mr8013060lbc.19.1432906550544; Fri, 29 May 2015 06:35:50 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp339654lbb; Fri, 29 May 2015 06:35:49 -0700 (PDT) X-Received: by 10.194.59.79 with SMTP id x15mr14960325wjq.81.1432906549458; Fri, 29 May 2015 06:35:49 -0700 (PDT) Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id k5si3551178wix.79.2015.05.29.06.35.48; Fri, 29 May 2015 06:35:49 -0700 (PDT) Received-SPF: neutral (google.com: 77.48.224.243 is neither permitted nor denied by best guess record for domain of alsa-devel-bounces@alsa-project.org) client-ip=77.48.224.243; Received: by alsa0.perex.cz (Postfix, from userid 1000) id A020E2668FC; Fri, 29 May 2015 15:35:47 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.2.4 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id EA09B266838; Fri, 29 May 2015 15:33:20 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 4B3F7266838; Fri, 29 May 2015 15:33:19 +0200 (CEST) Received: from mail-pa0-f43.google.com (mail-pa0-f43.google.com [209.85.220.43]) by alsa0.perex.cz (Postfix) with ESMTP id DBB4726683F for ; Fri, 29 May 2015 15:32:24 +0200 (CEST) Received: by pacrp13 with SMTP id rp13so13113576pac.2 for ; Fri, 29 May 2015 06:32:24 -0700 (PDT) X-Received: by 10.66.154.111 with SMTP id vn15mr14896929pab.108.1432906344089; Fri, 29 May 2015 06:32:24 -0700 (PDT) Received: from localhost.localdomain ([107.6.117.178]) by mx.google.com with ESMTPSA id he9sm5675442pbc.7.2015.05.29.06.32.16 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 May 2015 06:32:23 -0700 (PDT) From: Jun Nie To: broonie@kernel.org, lgirdwood@gmail.com Date: Fri, 29 May 2015 21:31:21 +0800 Message-Id: <1432906281-27698-7-git-send-email-jun.nie@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1432906281-27698-1-git-send-email-jun.nie@linaro.org> References: <1432906281-27698-1-git-send-email-jun.nie@linaro.org> Cc: alsa-devel@alsa-project.org, shawn.guo@linaro.org, wan.zhijun@zte.com.cn, Jun Nie Subject: [alsa-devel] [PATCH v3 6/6] ASoC: zx: add zx296702 hdmi codec X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: 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-bounces@alsa-project.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: jun.nie@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Add zx296702 hdmi codec to enable SPDIF and I2S output via HDMI. The SPDIF/I2S route is exclusive with current software config and need specify which is valid in defconfig. Signed-off-by: Jun Nie --- include/sound/zx_hdmi_audio.h | 7 +++ sound/soc/codecs/Kconfig | 3 + sound/soc/codecs/Makefile | 1 + sound/soc/codecs/zx296702_hdmi.c | 121 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 132 insertions(+) create mode 100644 include/sound/zx_hdmi_audio.h create mode 100644 sound/soc/codecs/zx296702_hdmi.c diff --git a/include/sound/zx_hdmi_audio.h b/include/sound/zx_hdmi_audio.h new file mode 100644 index 0000000..7eb0e81 --- /dev/null +++ b/include/sound/zx_hdmi_audio.h @@ -0,0 +1,7 @@ +#ifndef __ZX_HDMI_AUDIO_H__ +#define __ZX_HDMI_AUDIO_H__ + +int zx_hdmi_audio_cfg(int audio_codec, int audio_way, + u32 sample_rate, u32 sample_len); +void zx_hdmi_audio_en(int on); +#endif /* __ZX_HDMI_AUDIO_H__ */ diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 061c465..1ba34ca 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -844,6 +844,9 @@ config SND_SOC_WM9712 config SND_SOC_WM9713 tristate +config SND_SOC_ZX_HDMI + tristate + # Amp config SND_SOC_LM4857 tristate diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index abe2d7e..b6c4630 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -357,6 +357,7 @@ obj-$(CONFIG_SND_SOC_WM9712) += snd-soc-wm9712.o obj-$(CONFIG_SND_SOC_WM9713) += snd-soc-wm9713.o obj-$(CONFIG_SND_SOC_WM_ADSP) += snd-soc-wm-adsp.o obj-$(CONFIG_SND_SOC_WM_HUBS) += snd-soc-wm-hubs.o +obj-$(CONFIG_SND_SOC_ZX_HDMI) += zx296702_hdmi.o # Amp obj-$(CONFIG_SND_SOC_MAX9877) += snd-soc-max9877.o diff --git a/sound/soc/codecs/zx296702_hdmi.c b/sound/soc/codecs/zx296702_hdmi.c new file mode 100644 index 0000000..b256e54 --- /dev/null +++ b/sound/soc/codecs/zx296702_hdmi.c @@ -0,0 +1,121 @@ +/* + * ALSA SoC codec driver for HDMI audio codecs. + * Copyright (C) 2015 Linaro + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + */ +#include +#include +#include +#include +#include +#include + +#define DRV_NAME "zx-hdmi-codec" + +static int zx_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ +#ifdef CONFIG_ZX_HDMI_SND_SPDIF + zx_hdmi_audio_cfg(1, 0, params_rate(params), +#endif +#ifdef CONFIG_ZX_HDMI_SND_I2S + zx_hdmi_audio_cfg(1, 1, params_rate(params), +#endif + params_physical_width(params)); + return 0; +} + +static int zx_trigger(struct snd_pcm_substream *substream, int cmd, + struct snd_soc_dai *dai) +{ + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_RESUME: + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: +#ifdef CONFIG_ZX_HDMI_SND_SPDIF + zx_hdmi_audio_en(1); +#endif + break; + + case SNDRV_PCM_TRIGGER_STOP: + case SNDRV_PCM_TRIGGER_SUSPEND: + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: +#ifdef CONFIG_ZX_HDMI_SND_SPDIF + /* Mute HDMI before disabling spdif */ + zx_hdmi_audio_en(0); +#endif + break; + + default: + return -EINVAL; + } + + return 0; +} + +static const struct snd_soc_dai_ops zx_dai_ops = { + .trigger = zx_trigger, + .hw_params = zx_hw_params, +}; + +static struct snd_soc_dai_driver zx_hdmi_codec_dai = { + .name = "zx-hdmi-hifi", + .playback = { + .stream_name = "Playback", + .channels_min = 2, + .channels_max = 8, + .rates = SNDRV_PCM_RATE_32000 | + SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | + SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | + SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000, + .formats = SNDRV_PCM_FMTBIT_S16_LE | + SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE, + .sig_bits = 24, + }, + .ops = &zx_dai_ops, +}; + +#ifdef CONFIG_OF +static const struct of_device_id zx_hdmi_audio_codec_ids[] = { + { .compatible = "zte,hdmi-audio", }, + { } +}; +MODULE_DEVICE_TABLE(of, zx_hdmi_audio_codec_ids); +#endif + +static struct snd_soc_codec_driver zx_hdmi_codec = { +}; + +static int zx_hdmi_codec_probe(struct platform_device *pdev) +{ + return snd_soc_register_codec(&pdev->dev, &zx_hdmi_codec, + &zx_hdmi_codec_dai, 1); +} + +static int zx_hdmi_codec_remove(struct platform_device *pdev) +{ + snd_soc_unregister_codec(&pdev->dev); + return 0; +} + +static struct platform_driver zx_hdmi_codec_driver = { + .driver = { + .name = DRV_NAME, + .of_match_table = of_match_ptr(zx_hdmi_audio_codec_ids), + }, + + .probe = zx_hdmi_codec_probe, + .remove = zx_hdmi_codec_remove, +}; + +module_platform_driver(zx_hdmi_codec_driver); + +MODULE_AUTHOR("Jun Nie "); +MODULE_DESCRIPTION("ZX296702 ASoC HDMI codec driver"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:" DRV_NAME);