From patchwork Mon Apr 8 02:31:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10888741 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7172C922 for ; Mon, 8 Apr 2019 02:34:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A130262F2 for ; Mon, 8 Apr 2019 02:34:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B05B2793A; Mon, 8 Apr 2019 02:34:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 85E8826E55 for ; Mon, 8 Apr 2019 02:34:38 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id ABC3A9F4; Mon, 8 Apr 2019 04:33:46 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz ABC3A9F4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1554690876; bh=XR8RHeK5vQHFYFgZoj07WQlUI9DJY+28RTTHEJMwb2E=; h=Date:From:To:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=OmzDa3PphqSbFvIYfx9A5WYAXJs+b2gCLaJRYEQg9zvDFwCgfy21SnJnpQkaj9RzC mxrnRn9WRliG/vIatsuUEGTtpiAE51YoQkkFpwFSivXyyuKtXO58huqCKeccc3HcQ7 C0uNnYBEFPAuVvjarVcq030UqevWEwAElywsasf0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 44D81F89727; Mon, 8 Apr 2019 04:32:02 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 99767F89727; Mon, 8 Apr 2019 04:31:59 +0200 (CEST) Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa1.perex.cz (Postfix) with ESMTP id 16709F8971B for ; Mon, 8 Apr 2019 04:31:53 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 16709F8971B Date: 08 Apr 2019 11:31:51 +0900 X-IronPort-AV: E=Sophos;i="5.60,323,1549897200"; d="scan'208";a="12353934" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 08 Apr 2019 11:31:51 +0900 Received: from morimoto-PC.renesas.com (unknown [10.166.18.140]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id B46CB401C570; Mon, 8 Apr 2019 11:31:51 +0900 (JST) Message-ID: <87v9zp44ud.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto User-Agent: Wanderlust/2.15.9 Emacs/24.5 Mule/6.0 To: Mark Brown In-Reply-To: <87zhp144vs.wl-kuninori.morimoto.gx@renesas.com> References: <87zhp144vs.wl-kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Cc: Linux-ALSA Subject: [alsa-devel] [PATCH 3/7][RFC] ASoC: soc.h: add sound dai_link connection macro X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" X-Virus-Scanned: ClamAV using ClamSMTP Modern style dai_link requests CPU/Codec/Platform component pointer array and its size, but it will be very verbose code. To avoid such scene, this patch adds dai_link connection macro. Signed-off-by: Kuninori Morimoto --- include/sound/soc.h | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/include/sound/soc.h b/include/sound/soc.h index 23463ba..fdde69a 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1043,6 +1043,63 @@ struct snd_soc_dai_link { ((i) < link->num_codecs) && ((codec) = &link->codecs[i]); \ (i)++) +/* + * Sample 1 : Single CPU/Codec/Platform + * + * SND_SOC_DAI_LINK_CCP(single_dsp, + * SND_SOC_DAI_LINK(SDL_CPU("xxx")), + * SND_SOC_DAI_LINK(SDL_CODEC("xxx", "xxx")), + * SND_SOC_DAI_LINK(SDL_PLATFORM("xxx"))); + * + * static struct snd_soc_dai_link xxx = { + * ... + * SND_SOC_LINK_CCP(single_dsp), + * ... + * }; + * + * Sample 2 : Multi CPU/Codec, no Platform + * + * SND_SOC_DAI_LINK_CC(multi_dsp, + * SND_SOC_DAI_LINK(SDL_CPU("xxx"), + * SDL_CPU("xxx")), + * SND_SOC_DAI_LINK(SDL_CODEC("xxx", "xxx"), + * SDL_CODEC("xxx", "xxx"))) + * + * static struct snd_soc_dai_link xxx = { + * ... + * SND_SOC_LINK_CC(multi_dsp), + * ... + * }; + */ +#define SND_SOC_DAI_LINK_CC(name, cpu, codec)\ + static struct snd_soc_dai_link_component name##_cpu[] = cpu;\ + static struct snd_soc_dai_link_component name##_codec[] = codec + +#define SND_SOC_DAI_LINK_CCP(name, cpu, codec, platform)\ + static struct snd_soc_dai_link_component name##_cpu[] = cpu;\ + static struct snd_soc_dai_link_component name##_codec[] = codec;\ + static struct snd_soc_dai_link_component name##_platform[] = platform + +#define SND_SOC_DAI_LINK(param...) { param } +#define SDL_EMPTY() { } +#define SDL_CPU(_dai) { .dai_name = _dai, } +#define SDL_CODEC(_name, _dai) { .name = _name, .dai_name = _dai, } +#define SDL_PLATFORM(_name) { .name = _name } + +#define SND_SOC_LINK_CC(name) \ + .cpus = name##_cpu, \ + .num_cpus = ARRAY_SIZE(name##_cpu), \ + .codecs = name##_codec, \ + .num_codecs = ARRAY_SIZE(name##_codec) + +#define SND_SOC_LINK_CCP(name) \ + .cpus = name##_cpu, \ + .num_cpus = ARRAY_SIZE(name##_cpu), \ + .codecs = name##_codec, \ + .num_codecs = ARRAY_SIZE(name##_codec), \ + .platforms = name##_platform, \ + .num_platforms = ARRAY_SIZE(name##_platform) + struct snd_soc_codec_conf { /* * specify device either by device name, or by