From patchwork Wed Sep 30 17:50:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Code Kipper X-Patchwork-Id: 7301321 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B8E919F536 for ; Wed, 30 Sep 2015 17:52:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D739920660 for ; Wed, 30 Sep 2015 17:52:21 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 2F55B204A7 for ; Wed, 30 Sep 2015 17:52:19 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 11F2B26660B; Wed, 30 Sep 2015 19:52:18 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NO_DNS_FOR_FROM, RCVD_IN_DNSWL_LOW, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id C8F2526640F; Wed, 30 Sep 2015 19:51:14 +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 552B82663EE; Wed, 30 Sep 2015 19:51:13 +0200 (CEST) Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com [209.85.212.175]) by alsa0.perex.cz (Postfix) with ESMTP id BB7EB266186 for ; Wed, 30 Sep 2015 19:51:07 +0200 (CEST) Received: by wiclk2 with SMTP id lk2so73397312wic.1 for ; Wed, 30 Sep 2015 10:51:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=moWng+7IgKDZUGcM3QZHKL9CHI0pnz1BZRZ5ntzcaSA=; b=Shx6117zZ7LH4Qyq2qMIoVps7RjwaADuHEWbwypQwN8OOcRt6sVOHasnQPVUuMBbpN KE5wEunqKNIEStSrOet5JPsfzXB+b3vTFcd/nkLEI/oZlR67E+m8UX5oubtXaFA0Y3i8 pudMLYWqfjXbHfAsDrjfEJ+9sqoizm+REVgWjRXUWta4I7uqGaKUqWEuyk5BkWtTx7WL hAHNY/aAJVxPRF1QoK4GYGU2tZh1TlGiNSrIu7hp06kd4KVygwfaHNS2zk6GcQZM/+jn mS2LKStKVkqPwlW3HpaotAgA25JmtMfaQSDaeuhg7Ky6ztjylCjz7bJyS+8GEwW3cH7i 6cJg== X-Received: by 10.180.103.167 with SMTP id fx7mr5918744wib.89.1443635467423; Wed, 30 Sep 2015 10:51:07 -0700 (PDT) Received: from localhost.localdomain (h-88-30.a230.priv.bahnhof.se. [212.85.88.30]) by smtp.gmail.com with ESMTPSA id bh5sm1792271wjb.42.2015.09.30.10.51.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 30 Sep 2015 10:51:06 -0700 (PDT) From: codekipper@gmail.com To: maxime.ripard@free-electrons.com Date: Wed, 30 Sep 2015 19:50:57 +0200 Message-Id: <1443635458-8873-4-git-send-email-codekipper@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1443635458-8873-1-git-send-email-codekipper@gmail.com> References: <1443635458-8873-1-git-send-email-codekipper@gmail.com> 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 Subject: [alsa-devel] [PATCH v2 3/4] ASoC: sunxi: Add S/PDIF machine driver. X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" 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-Virus-Scanned: ClamAV using ClamSMTP From: Marcus Cooper Signed-off-by: Marcus Cooper --- sound/soc/sunxi/sunxi-machine-spdif.c | 108 ++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 sound/soc/sunxi/sunxi-machine-spdif.c diff --git a/sound/soc/sunxi/sunxi-machine-spdif.c b/sound/soc/sunxi/sunxi-machine-spdif.c new file mode 100644 index 0000000..2adb727 --- /dev/null +++ b/sound/soc/sunxi/sunxi-machine-spdif.c @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2015 Andrea Venturi + * From code by (C) 2013 Freescale Semiconductor, Inc. + * (sound/soc/fsl/imx-spdif.c) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include + +struct sunxi_machine_spdif_data { + struct snd_soc_dai_link dai; + struct snd_soc_card card; +}; + +static int sunxi_machine_spdif_audio_probe(struct platform_device *pdev) +{ + struct device_node *spdif_np, *np = pdev->dev.of_node; + struct sunxi_machine_spdif_data *data; + int ret = 0; + + dev_dbg(&pdev->dev, "%s: Looking for spdif-controller\n", __func__); + spdif_np = of_parse_phandle(np, "spdif-controller", 0); + if (!spdif_np) { + dev_err(&pdev->dev, "failed to find spdif-controller\n"); + ret = -EINVAL; + goto end; + } + + data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); + if (!data) { + ret = -ENOMEM; + goto end; + } + + data->dai.name = "S/PDIF PCM"; + data->dai.stream_name = "S/PDIF PCM"; + data->dai.codec_dai_name = "snd-soc-dummy-dai"; + data->dai.codec_name = "snd-soc-dummy"; + data->dai.cpu_of_node = spdif_np; + data->dai.platform_of_node = spdif_np; + data->dai.playback_only = true; + data->dai.capture_only = true; + + if (of_property_read_bool(np, "spdif-out")) + data->dai.capture_only = false; + + if (of_property_read_bool(np, "spdif-in")) + data->dai.playback_only = false; + + if (data->dai.playback_only && data->dai.capture_only) { + dev_err(&pdev->dev, "no enabled S/PDIF DAI link\n"); + goto end; + } + + data->card.dev = &pdev->dev; + data->card.dai_link = &data->dai; + data->card.num_links = 1; + data->card.owner = THIS_MODULE; + + ret = snd_soc_of_parse_card_name(&data->card, "model"); + if (ret) + goto end; + + ret = devm_snd_soc_register_card(&pdev->dev, &data->card); + if (ret) { + dev_err(&pdev->dev, "snd_soc_register_card failed: %d\n", ret); + goto end; + } + + platform_set_drvdata(pdev, data); + +end: + of_node_put(spdif_np); + + return ret; +} + +static const struct of_device_id sunxi_machine_spdif_dt_ids[] = { + { .compatible = "allwinner,sunxi-audio-spdif", }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, sunxi_machine_spdif_dt_ids); + +static struct platform_driver sunxi_machine_spdif_driver = { + .driver = { + .name = "sunxi-machine-spdif", + .of_match_table = sunxi_machine_spdif_dt_ids, + }, + .probe = sunxi_machine_spdif_audio_probe, +}; + +module_platform_driver(sunxi_machine_spdif_driver); + +MODULE_AUTHOR("Marcus Cooper "); +MODULE_AUTHOR("Andrea Venturi, "); +MODULE_DESCRIPTION("Allwinner sunxi S/PDIF machine driver"); +MODULE_LICENSE("GPL v2");