From patchwork Thu Jul 18 23:34:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13736780 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 52166C3DA61 for ; Thu, 18 Jul 2024 23:40:48 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 737C9B60; Fri, 19 Jul 2024 01:40:36 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 737C9B60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1721346046; bh=F2UskFabeu8dcoyiWll7u/q3jC72ZkeA0VLw0s4OuI8=; h=From:Subject:To:Cc:In-Reply-To:References:Date:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=MrXxRS9sVBx1V53FN3oBYGq1UCgpkfS7D2Ggbt7H44y1RNpCttItwQ/e67t5rgopf jO25uk0pSuC+riG9gZvVx3Sx164wIVu8wk97pSiJF5EiFea0TxaXynxMwO7GhRPY4h X+qfCQm/qs3vpXWXmKOWvgk8/6J3a+ZtIvCHa360= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 74A97F8013D; Fri, 19 Jul 2024 01:40:06 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 84B22F805B6; Fri, 19 Jul 2024 01:40:05 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6B08FF80568; Fri, 19 Jul 2024 01:36:18 +0200 (CEST) Received: from TY3P286CU002.outbound.protection.outlook.com (mail-japaneastazlp170100001.outbound.protection.outlook.com [IPv6:2a01:111:f403:c405::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 9B80CF8026D for ; Fri, 19 Jul 2024 01:34:38 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9B80CF8026D Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=renesas.com header.i=@renesas.com header.a=rsa-sha256 header.s=selector1 header.b=U16Prgig ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nryiFbW+oEMlWcqS6Er3bti7Do+pLwYbP4qnweR7POA3unWLRIYANhODYPuhQFcJVg+Qfk1BuK22848EWHABT+Em6iwY/8nEz0aAreXxIc562d4QUC9KVUDIxMSQl160L4oLD70336A7sWBDmBS1vpW85SL2JMq8svydtxDo9UcsgYEyW4LH9mMVRolQ9Wcutc2Hho5U3ZL/RMhzzzTsdr8qQJ2+u//HMMeFUA9aoNp0cWJ+9aOScPMn/vFEs3qpwiKnPDDFpZqF2Mb145tp1xEyLlOr0S9L4t8YPTbEzcpY9d03JLFQeXBu4kycei5UAfAqQ40GqdrjI85B48wknw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4wmRbdq4Pigsdr7F7mYCn6ASMnWQF5rd1pcGSubaTQ8=; b=juyt6AybySia60AoEXJeOtIgueCqVV7D+73B+eOziLzmdowF56JW+Tr9Lvz7pW/3txOl3YeBs4LqMae3olWefbFDcZ1gy67+Xv1DpNDjClrp16maWazgJ5QJ1SjHYDyzleDpFwOFG5FYCjoVQ8xIWmBH8V4BC6J0mIgYHa7GFT3c60SXNrT5UCS8KMejTxGQ9dhuO4HJZ4BJY/WoLpehzJeX7yj0x1pfGq/ip9gk9mdmoS3S5F/0m4u/4bio9NyV1C1NgGxa22cCoXxZQEqi4Wtt37Hy970XQwUy2lnzqDE6EociOwgGIF/zEXW8FqLYaLVu1hxA+hu311wmciJSjA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=renesas.com; dmarc=pass action=none header.from=renesas.com; dkim=pass header.d=renesas.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesas.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4wmRbdq4Pigsdr7F7mYCn6ASMnWQF5rd1pcGSubaTQ8=; b=U16PrgigBmFx/zmMko5oOk3vtgqYno6TYdpaCFsMjQRGwQiGd01MOQtcVBY7gkHKX1Oa1h+N6+mLmSyEesaqpbJj1YNSNAk01tXIq7fh6STynYyslt+eDLEPzcQtWUTjTtmB/fTAxLI4ow8+iIgRLY1xQNXlk9mU35xQsh4fNU4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=renesas.com; Received: from TYCPR01MB10914.jpnprd01.prod.outlook.com (2603:1096:400:3a9::11) by TYCPR01MB11460.jpnprd01.prod.outlook.com (2603:1096:400:388::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.20; Thu, 18 Jul 2024 23:34:33 +0000 Received: from TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::c568:1028:2fd1:6e11]) by TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::c568:1028:2fd1:6e11%5]) with mapi id 15.20.7784.017; Thu, 18 Jul 2024 23:34:33 +0000 Message-ID: <87y15yl1fa.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [RFC 01/xx] ALSA: add snd_stream_is_playback/capture() macro User-Agent: Wanderlust/2.15.9 Emacs/29.3 Mule/6.0 To: Takashi Iwai , Mark Brown Cc: Linux-ALSA In-Reply-To: <87zfqel1g7.wl-kuninori.morimoto.gx@renesas.com> References: <87zfqel1g7.wl-kuninori.morimoto.gx@renesas.com> Date: Thu, 18 Jul 2024 23:34:33 +0000 X-ClientProxiedBy: TY2PR06CA0041.apcprd06.prod.outlook.com (2603:1096:404:2e::29) To TYCPR01MB10914.jpnprd01.prod.outlook.com (2603:1096:400:3a9::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCPR01MB10914:EE_|TYCPR01MB11460:EE_ X-MS-Office365-Filtering-Correlation-Id: d1356b69-c1b2-40d1-8f9e-08dca7822dd6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|52116014|376014|38350700014; X-Microsoft-Antispam-Message-Info: /9Q6YRsSDX0kurKVSLbBqoOuM4izXcSh/t8AKMaVmNKR6q24amObZxhlLZnaM1Zl7mSLebkdZC0eKEpg81RBkyGSi3k/USY5DdofPwNoDD0YkzSCny9UH3uoheS6Lxc4MbEWzkQqvGe1VYVfFS/71IjJcqurrEdZFvWswmWj2BMhWLPDKrwmDmtq9kRlI8U6Y1uEhiDt6lqVJMSNx4k3PbusVC7L1BvwSyIF5+XLzlHdhIRDqOmQMyWxA5lF390G2MlVhLoRtSnOFrJjvS+SGoysnGJkTXv/elFvJ5/t0x6MQSaFn/VFmx45DAxHHQR7DPw1cfwlYIRYDQVxZ0BULF3lEdqxnlhxXEZa4GLtkcyLXvqy1DNec13ufSTigwUNoMa2BdtIGdju5PIFM0BC7ZwmklbKXjFN1y6xPfJMgnbGn2sQ6iv6MRGO27s+kpxvnqnwHAgJnviwK2hNR7as++GItpIn9dgK+9+wzUuWGSQptjGkWPXpylOFP9L8mGFQ8JE65OxiRVMf86GxW6jGIcm25sUZ9bJWz4uvpBP84CpU5rjWZ9/Hh4og4PC7auPw4HHW0PAgjKSSCFoZg2gU/63qVyuh6p5N+vlm2x7cgf7tDp86qm+TSn1hbinoU/tGKk1UX4ObDtHYrSmByyHj+paycWl52381SXIlKLl2ANaJIr5hNpvWpq+wWejzqSh/zm4aGJKn6RbgOBaoIdf3rrU2FYuAFo9dNVPHuN93VjHdwJm5xTqZOiuPuSDZuTjooRc2msYTaPXhxwMbdDOHmHAQNQR1evQvqMD/mgf4zC2BfMWtFOUVcYsfyV8LUY928Pv/XCDXmkygDqUZuksBgf47ERRKlAte60NJbswTRacMbPV5GInS9Saaka27TmerL0kSjJVLPEP6PnTos/8t5GTx7asdj/YjS+4fPuChgE1FujPWLy6vp+bzqtEipwAEidH2KTlKAdLuIQ24VjlilkqP+DlwO77ZD3Pr8+xOqfccQ5NyQrmWagbr3PPt76KSuovvEJSt/QzHuFRT2B5HvQDDgshHPnqWJLwawcqKTYqOTJFQ4zwJYQ+albHLAONI3s3jgS+uxc82tiWvrdL/FfyeB5BsuY4QFRDRi4DoNupFgLXnl2XWbgAiecG7+/fG+evmQQPrh98NETOgr+I3DCe9n06D0Efr4wBD2/R5c/3Uq92n9DdOM3TMWSqo8OzlNEy+1PF+mBWP5icgjfuYXECbYzuvwdANkM50RcLPiM7jV6YJt9NV/EJeB42zpINaG8C5TDUqgAENb+x5M5hViV0J9xjCX0C8eax3Hke+4E27qiraqDXOpoXcL/bNYJShCK43/cOpEt8ngx5uZmDvun0GRP8yfC5y562Tk0CboDW0c/+vp73BttcVMVyvExROYzgS6jsUXh7bBV3fE1Ns+w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TYCPR01MB10914.jpnprd01.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(52116014)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vaYvov1lk2RjOY4EPeeyeyOQlkxZKTDhQzW99xZkTU2sojvn+bdyLaDAtg5Td0OcyatcDIOiWlnqtRay8EMSJxscCgbp21Z0vCBVsxFqUg+Hq/EPfcpTwKgjonR/EreLhn9YEdDSnwJmO1Mxt97wupio7aE+aa8AsbWO32KjKIvtz5UdAqKXCMelC+hkJHgEWNxhvojI7UVKgGHBH6e89B7wM4yrlpGhRT3wIZe+8hdZTw8nMv3y8Re7mX4i2S/X6WDH05/q271B7a9PtdT8/djNho4o+cvdJvZJzdhX8Le/ugFFs/n5jDcojqgZcHDYjgZUJY/voDYumpZIg7ywm5NmO4P7fSQjYpN/eBP2M7TDsz/Ts0rRQA/F0czbZzGhauZppzjAS9krDy43XNMz3nLJmU2hm3NUTcSpU+xtod0ECWhqOF/qaMhJBXNAun7ecC0lDoMtjs44uJkCpC0xcNYHKIgb/IunQNS44CujQNEb0F6jaPdGQCElj7kI+P7hY66bXgKUf260h2czycVcIa555n2sEbn6efcByNBs1PdGwPVYpu7ibPPf+US/eNzWP2y4R2hSqPs4+JOhgzIfCX869YSB8fByiz4G6CxpZ1ec/p+6rZb1YjdYWIjgHuMj7HHhcKQk+xRbGM6sXR0VnjTnstdgZYZUQHC6qq1dz6GEqvS9si3vpsIjRk15ZD8ojQYK4kGAzcwkugptqabUd8tu2hbLN1cKhFwxk86RgBvUtpAmPQiF5sm8on3dzBaWCHdWXDzOlb+I0ByciUNfZLgh0UI7q3SfGkGUXAkWALS+bjUY8SZeIN8S/foT4ELaECcXni/SNZ62cD8YldTehnOdRalxhwVYhYuM6QQXi2ZqewK1osQacEHzZGeKCuta907cwaZRXu9OLMuAHdlkjh5pt50e9y13tBBKSHjl1Wv8CUK3C3Q31Lu6naxHL0NELwVc88hGxwvJeiHuos4Q7p5Zvd8b7ocZblng02o9TgD1+o1br+ws6lEbdHrwM13VlRBFPx0j/vWK5sxkOH94ygO0pS3G3xf98rweKG5uC3fEY0d7AdiJsKUc2qDHUbv1GIxSelmVwiIxPDNLxeLp4Iem3ATmXoDKXc7xWYCaIbtKo9EmLTVhe4QFGmDeaLvBscfm2aJDtuvKKMJWRPmWDUHKygNbaFSQMj6tskYpeZDyWQVNAMxoaCrCeSp78FXKJeF5OGq2WUVlOn+7o0v9NamSP8JODkocH+xDxCnkqUyYS1TLHfaNbqQRot35Geq18nMYcXvVCl7Wrdqzspe0CcqXw/R6nAaTX/ylqBDgQ80fkZx1kUACAWMpnUumIEwJFSIzmCPillsEwHFuixSF7TdwZbudkxxv9NPXeWqf+KvnnjP97M9duIu4kSPIhinywoVUed07RssyUcMEi/rdxdGTm7NbaXKW8ntE//5fXjmLsJNJzZDdPPiHhVQlhuQfwZwCPKaArmDjPUp2HZIqG0IFB2HbFTMcZEbQYHarQsExKS5dmAVF4CYaux/6CKT875D9Z+Ywo8ElpVb64ZtI1l76RfUBE1zylNXHl6Fu8Y8ITs9o/UvpvCnFogPEuXIsf+8BkMzAuFltSmD+zUuG9NE5wuj8c4bfowW551CYk5o= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: d1356b69-c1b2-40d1-8f9e-08dca7822dd6 X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jul 2024 23:34:33.7075 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: JGxX3E1hPmXAaKb39qrFH6Cqi5qB18uZY+vJbDwnQnt1RQToQcE2MNctmRBxhvClkvdPzN3eo4Fge4FFfw+38pCE4rRm91IvPWsQEUxfuBDevZQu0LpP/267G7pJshk5 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYCPR01MB11460 Message-ID-Hash: K647ZQVPFPKOWR7LXCAXUXHEWSZ5G7SS X-Message-ID-Hash: K647ZQVPFPKOWR7LXCAXUXHEWSZ5G7SS X-MailFrom: kuninori.morimoto.gx@renesas.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Patchwork-State: RFC Many drivers are using below code to know the direction. if (direction == SNDRV_PCM_STREAM_PLAYBACK) Add snd_stream_is_playback/capture() macro to handle it. It also adds snd_substream_is_playback/capture() to handle snd_pcm_substream. Signed-off-by: Kuninori Morimoto --- include/sound/pcm.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/include/sound/pcm.h b/include/sound/pcm.h index 3edd7a7346daa..024dc2b337154 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h @@ -501,6 +501,25 @@ struct snd_pcm_substream { #define SUBSTREAM_BUSY(substream) ((substream)->ref_count > 0) +static inline int snd_stream_is_playback(int stream) +{ + return stream == SNDRV_PCM_STREAM_PLAYBACK; +} + +static inline int snd_stream_is_capture(int stream) +{ + return stream == SNDRV_PCM_STREAM_CAPTURE; +} + +static inline int snd_substream_is_playback(const struct snd_pcm_substream *substream) +{ + return snd_stream_is_playback(substream->stream); +} + +static inline int snd_substream_is_capture(const struct snd_pcm_substream *substream) +{ + return snd_stream_is_capture(substream->stream); +} struct snd_pcm_str { int stream; /* stream (direction) */