From patchwork Wed Aug 21 02:28:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 821346 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 2E363C531DF for ; Wed, 21 Aug 2024 02:29:46 +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 B3D9B836; Wed, 21 Aug 2024 04:29:33 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B3D9B836 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1724207383; bh=Z9HQMCTtjq5jVNbFmJOGI2szu4Why9Xyist5j/hnIdI=; h=To:Cc:In-Reply-To:References:From:Subject:Date:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=JSMj/v17LXjQBhy7VTRyp3dJcVovBt2+6u7zkYxrX2Yzr0oUdgHmxJyEnbTmqZQAh +ru4n3W6OdLIVDFtrs9ddZATPPTY8FPQs8XWUrK/bcHu8w9qh6oJScByLx2s/mowRm yikBjSKuSIMyI+TT8iREGvSjfnqZfC2EDYhZSgd8= Received: by alsa1.perex.cz (Postfix, from userid 50401) id CF0FFF805B1; Wed, 21 Aug 2024 04:29:22 +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 B2942F805A9; Wed, 21 Aug 2024 04:29:22 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 495EBF8049C; Wed, 21 Aug 2024 04:29:18 +0200 (CEST) Received: from OS0P286CU011.outbound.protection.outlook.com (mail-japanwestazlp170100001.outbound.protection.outlook.com [IPv6:2a01:111:f403:c406::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 B4F7BF8025E for ; Wed, 21 Aug 2024 04:29:03 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B4F7BF8025E 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=JkbRPw6v ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=niTBRKsITGH8Sd4g7N94BWA/l9zSidxeD5PWNCOa6dZ3lhT9eO3J+sNxgaOh42yQkf82+A7fSr8PZkKl0IBUXzcRMywdSM7YkZjQW+k5nhkIMcIAUPav9Rp5BTsgs0b4tHXXdRdlgxsu/v44epq0OGfP76/XkQI/BfwqQcN9tvrFjmTkyK5ItI0Jm8HoGSuCGgBUV5jh54f5dMfWzqwAnBPtWrrFHqP+R0Iu+L8uDLhg7c/gUGSQ3bP8QFczXebb/AL7tCypnCF+PFlzvWLOD52BbZssb+o+cSqwRQ8CZP+8OUhIuqEukxyupyKFqlSE4SP7J4M2t4i9sns0op46ig== 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=XGirFK46gfKBrPpMgri2VH0OCXwC05M4/9v2mS1WE+c=; b=L6E0CPK2j9ERVdDqps9QQHkY2k/N6kWXHE4z4JajeRwpO51nH7ZaIqL0YlxXXCJCxBsg8kb1Se4XRVe8QCGSzfOzf0+lvCsGfWhDwiK/nEJlUXFC54KjB8hGeUUClxxmPHtFMAOvJNqYOJXwbW3u3ByRYaTQt0/0vR+vIKv4U2yuGyPrc9cZXbq7Ao7zPkjunUy6hLVcsuP0BJXfWbFmADnnuIvVbi80bXc0rYLbORb4J5+N85GG04ZdRLYaRXLi7DSab0q1bd+Ypy+yvRdBcEFEY4z6mB1UccLbdW4mOrvfXTYMPqQ5UaNUtBfmtPM+s/D9gv5ZSYIDneCfWEPiCQ== 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=XGirFK46gfKBrPpMgri2VH0OCXwC05M4/9v2mS1WE+c=; b=JkbRPw6v6XC0f4e1OgJ3quLWoB0cp6yOQdImqXeMG4aC81fdb7YDwIeIgxUPam/DiQGqtUbuvsRpN0eCfTfNo29kTWML6YNlLExLXujXXrgpS58T6/zJVB/aaC4gOg7XbspU3oYwZS9NFZaOptLBMu0pQKielJy5jh7XKYxKl7g= 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 TYRPR01MB12156.jpnprd01.prod.outlook.com (2603:1096:405:ff::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.19; Wed, 21 Aug 2024 02:28:58 +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.7875.016; Wed, 21 Aug 2024 02:28:58 +0000 Message-ID: <87jzgaa9sm.wl-kuninori.morimoto.gx@renesas.com> To: Mark Brown Cc: Linux-ALSA In-Reply-To: <87le0qa9tc.wl-kuninori.morimoto.gx@renesas.com> References: <87le0qa9tc.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v2 1/2] ASoC: soc-pcm: move snd_soc_dpcm_can_be_xxx() to top User-Agent: Wanderlust/2.15.9 Emacs/29.3 Mule/6.0 Date: Wed, 21 Aug 2024 02:28:57 +0000 X-ClientProxiedBy: TYAPR01CA0176.jpnprd01.prod.outlook.com (2603:1096:404:ba::20) To TYCPR01MB10914.jpnprd01.prod.outlook.com (2603:1096:400:3a9::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCPR01MB10914:EE_|TYRPR01MB12156:EE_ X-MS-Office365-Filtering-Correlation-Id: 92f411d3-ad74-4fef-ac46-08dcc18902a8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|52116014|1800799024|376014|38350700014; X-Microsoft-Antispam-Message-Info: higIQck+jRJDFP4gowFmN+MdyGTzcfyYHD8d605u12e0Y/H/jw7IZSj2kyYmBVwzWx5p0SzIXaG7WpKtulSZzJYcwEY+2uStGIBZUx0VHjlqAAEFpEumdbjznsWVpXVytcYcIq7TKsRTf85IiXzL6h+G2qwJOHaz/A6zhjicwGVVOwz9f1X0VeY4jcIiOwgk0SIj51wNzE0lUDk4+g0hX2zVpdYRoRzuhO8r5a7CsWSPrpuPDafa9h/aRbsX1tMg1dfmIbhLl37h5OYGVcOJlPWd60cwk6DIXpOU6V9A9rqAIBk5o0AxHpKIIT2F3lyDHcKRD8CvqFaB047O+DyiOfQn14mtbDW3N2PmBK0i9kP2U30rVxpc3d7dpzEbaS16cvw89MdrnlZelc56jwj0Wi8dSgtIITBT3Z/xe+j5De4Luayp69hbYVO6SGn4vKWWux/ob9TBgR8kLa+3yxe9DZA5X3G3qzKyypBoK3s0VdtQzCikIL6h8EsTiHXZPMYSsZH0sXo2pBVUAprpuvzyisCT2KPy4NymRqPeL1SZG9S7QW67t0af54eGVrVaK95a0C33JfsJPQZFm9+H07T1qMivVa6q1FVGA9mCSmPRlMDm1NKXQ7784CtKlkkPeZSf/keDkyM0tQTmA5FB1mZJV8qmzXoVxxX+0zzd1rvMaT5Pr6P3avCFVV3ZOtIfgdaBTtABY9m3PKsCF0tFHQABczQWXcWTGwSfkqTK2QbSL5mMIv3fpf7p95MBe49wdU/2ZEGEdfzIWu9ritySwxYJrkpw2Y3JHdd56Y4Glc8c4FKhDuLzuwkKTFO/TxG7sro7G9Rc9YdZBw2MjIzGC+MM5Xg54/jS699JrlTSQ4CWaNAXFIV2imLQtctS6ZPx2YcalPQC3dAa3UfQwHd3o8sAx8tK7cfCFJUjk91E/In2mqRC1pZS7Oi8cyY9U2tUoT8nRLRG+iDad8w+m204fyp502PYDPQdHfq2krTb/0eVHquX4FwRTPGu8ptFnNrSKgWjJLBYbFoisE/lsH5EwzPNUPCYD4PRCQlRTl0udYyTFXFrB+dvfxFnISdHZ1jDmpSFjeFJBe+GHnhOJksxs2FVLe0S7QriWdcHsADY7f6lwXdxdgIngfEeogr0FkDooG96fGk0xqr5oD/F+tIM4sn/N1R8RIH2OtJjYjWDwz68NTDQiVn4MTYGcULCUBoFz/Xi5NaMw9tLOYIDAXD39vy5vpU2njuoon32zn9NkMfmeCObM0E5U0WOGBgIKSuaEVNy5vQRmVoCMwGfSEkcvbtnsQIW1rC8LPg9cAgNi3GuuaJbqdIWTXUOLzVBkhmsVHO+GkV8WbFnSryJNqaSmRUJGtvvD1zZphETkxrdozbbV5nUU40dnYBm49am+txAYeYq7vpYkDkShJ2/Ziz+BDd9tw== 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)(52116014)(1800799024)(376014)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iU09FYA7EgFGMj/EwWwvweKjqP25NUbXv19aIesGjUN5zGUYXs1tZtK6fYpboDuIW5lD6lGou1wfu3cBbJrQDO7yX3y22t0nZCYhdk2fO9vWrmsUgcnmu85r2NHdDOkH4AiVv7ZkDASOBa0ynd0N4F4abhdslB/2k4EjdbEAeWh3vHrjs/DfR63a542I81P7GACXFD+hHsco8c8U7lO9Il+1uUGdPoF9MnQFptEx58rsixI/jI5zZsW+WywDhGMI+Vvtx41bNfAZkvaz1neSPiKKDyA9fhObVn/b6YEgkn4nKbQcVsaP4BG87o3srB+fiMnGARkMfix0Dls4RqXEBiRzrmKbButJqj/nd49mjwre7YJNbZaMSQC/WvuZEDg/7Tj0CmisHbqAkwRV/mfwDdE6ZUaS2r+7ID8SzuCDUFxxWi6kLE/qNkD9kC0a35wTvioZezeT9O07I2A/zRzuEtHigooIXxJ+QVTF7krgOLx3PqwfqHqEuKbLNjlsdz7NMRiyGTQpo3IImeH1JLy8v1csEwmfbZuZ9ascNGZKa9zQL7D/+72ghmkZh5+gBzL9D3VbXx7w1/+SqONYc+yZRSCGjGsiUPQ81D5FJqmHx6yyP6BtU/6yUAs3NRyJREoWoTAMZYFtoCtdFLvJJUsrHTthVwncgxjbjv6EWvDdzi6PhnsDzliMypfkC7wfkhiDXl5BGHytQcmWcYjCqXjGMKx85JpKKEbz5rV96Wz5T1oTApMiTtYEhc1KkRCnO5NKxqoe2V0m2Uo/pW8jkSkGLCvDP6h64v4e/yGQ+EDjma7t+9vR02/5emnb77sC1G+pYBl+6Am4ZFS7WdEhGVtZe5UDV28K90xgzeO/I+UscvvZkZ/aQs5Ew6dL7Nb62TyKuoC4zSKOgC3+bHoAhYOPbZuyA19odXB+l88FJWbehc0WAlV58coxe/KTlpRoWVCYq0E1tBMAvIRFAvjbmTZ/GGzHgv1LbnP8IVIWifX6B8Mboplxk9eHjKOM4LGvPVrUJjipJVJ4Cov7b4zug1kL6erN1eJTW8Fazg26dnBRHQmyv32he9bTcxeE/kc3kMcUJKp8emx6Yk11nfMttVigSpd87nV9+pPTi+eBAN45l8aN+D0Ph7ajLctatokAJRpi2lNNrvOl/k6sM8mv0Pl5YU1f4LHwM3LHyRlHat7QWt0m/lxUd2LjLvjOcmxDIeLGNLf7/Q/9ZYVlMKcxV3EfR5jD3w86FyRlP9nrwNY8GDo8k3FWYK5VBP7GkPNF2W14YoxfmdRntrA5j8TqjlDnKe5AZP9LWJqXW+F6QEsG4JRVFsGRG1Vr5wgZchd0mhiXGPEwx6j3XwWw6dcIVYWUjVFZ8OPLUHkcxFW6PrJRxvjAY42eZy7vbCGmqYe17nxKdTEgX6+hmOx58VIv435UWIvdmpvZBXPV+GjfTjMBnJXG/OLMRO1B7o+1js8eL3I9qq/HSP+bf9rBOtiAV4WylJGnc6IuAKwHMeT2ttW/BCEpA2OMdE68ZcT2a4V+gqUVoVcUEIVTTLL+vHTexZz1AlUU/q2miI2LWbifVhM1fQ6zB9xwrxfkecdDPioBWgm9ihvA+09IJSh0pDmM4ngUmyMFancx+Xyu9NORVKWZuZI= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 92f411d3-ad74-4fef-ac46-08dcc18902a8 X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2024 02:28:57.9622 (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: mrTN1Gfp4RKEjJ04yeNDxk7287ISxxFKk5suxmwO800BLYsL/bBquK7wa3J66Yzxx5YI8X7vvt6UxRNKbcligOlbw0Riik2WC85+PHz0V3j0NIJ/ap+hlVZk5kD2cq17 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYRPR01MB12156 Message-ID-Hash: DMY3NMZLQ3JVADKTSZSAB4BFICIPQBA5 X-Message-ID-Hash: DMY3NMZLQ3JVADKTSZSAB4BFICIPQBA5 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: This patch moves snd_soc_dpcm_can_be_xxx() functions to top of soc-pcm.c This is prepare for cleanup. Signed-off-by: Kuninori Morimoto --- sound/soc/soc-pcm.c | 204 ++++++++++++++++++++++---------------------- 1 file changed, 102 insertions(+), 102 deletions(-) diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index baf8b81e7110..667d8dff1314 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -49,6 +49,108 @@ static inline int _soc_pcm_ret(struct snd_soc_pcm_runtime *rtd, return ret; } +/* is the current PCM operation for this FE ? */ +int snd_soc_dpcm_fe_can_update(struct snd_soc_pcm_runtime *fe, int stream) +{ + if (fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_FE) + return 1; + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_dpcm_fe_can_update); + +/* is the current PCM operation for this BE ? */ +int snd_soc_dpcm_be_can_update(struct snd_soc_pcm_runtime *fe, + struct snd_soc_pcm_runtime *be, int stream) +{ + if ((fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_FE) || + ((fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_BE) && + be->dpcm[stream].runtime_update)) + return 1; + return 0; +} +EXPORT_SYMBOL_GPL(snd_soc_dpcm_be_can_update); + +static int snd_soc_dpcm_check_state(struct snd_soc_pcm_runtime *fe, + struct snd_soc_pcm_runtime *be, + int stream, + const enum snd_soc_dpcm_state *states, + int num_states) +{ + struct snd_soc_dpcm *dpcm; + int state; + int ret = 1; + int i; + + for_each_dpcm_fe(be, stream, dpcm) { + + if (dpcm->fe == fe) + continue; + + state = dpcm->fe->dpcm[stream].state; + for (i = 0; i < num_states; i++) { + if (state == states[i]) { + ret = 0; + break; + } + } + } + + /* it's safe to do this BE DAI */ + return ret; +} + +/* + * We can only hw_free, stop, pause or suspend a BE DAI if any of it's FE + * are not running, paused or suspended for the specified stream direction. + */ +int snd_soc_dpcm_can_be_free_stop(struct snd_soc_pcm_runtime *fe, + struct snd_soc_pcm_runtime *be, int stream) +{ + const enum snd_soc_dpcm_state state[] = { + SND_SOC_DPCM_STATE_START, + SND_SOC_DPCM_STATE_PAUSED, + SND_SOC_DPCM_STATE_SUSPEND, + }; + + return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state)); +} +EXPORT_SYMBOL_GPL(snd_soc_dpcm_can_be_free_stop); + +/* + * We can only change hw params a BE DAI if any of it's FE are not prepared, + * running, paused or suspended for the specified stream direction. + */ +int snd_soc_dpcm_can_be_params(struct snd_soc_pcm_runtime *fe, + struct snd_soc_pcm_runtime *be, int stream) +{ + const enum snd_soc_dpcm_state state[] = { + SND_SOC_DPCM_STATE_START, + SND_SOC_DPCM_STATE_PAUSED, + SND_SOC_DPCM_STATE_SUSPEND, + SND_SOC_DPCM_STATE_PREPARE, + }; + + return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state)); +} +EXPORT_SYMBOL_GPL(snd_soc_dpcm_can_be_params); + +/* + * We can only prepare a BE DAI if any of it's FE are not prepared, + * running or paused for the specified stream direction. + */ +int snd_soc_dpcm_can_be_prepared(struct snd_soc_pcm_runtime *fe, + struct snd_soc_pcm_runtime *be, int stream) +{ + const enum snd_soc_dpcm_state state[] = { + SND_SOC_DPCM_STATE_START, + SND_SOC_DPCM_STATE_PAUSED, + SND_SOC_DPCM_STATE_PREPARE, + }; + + return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state)); +} +EXPORT_SYMBOL_GPL(snd_soc_dpcm_can_be_prepared); + #define DPCM_MAX_BE_USERS 8 static inline const char *soc_cpu_dai_name(struct snd_soc_pcm_runtime *rtd) @@ -2960,27 +3062,6 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) return ret; } -/* is the current PCM operation for this FE ? */ -int snd_soc_dpcm_fe_can_update(struct snd_soc_pcm_runtime *fe, int stream) -{ - if (fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_FE) - return 1; - return 0; -} -EXPORT_SYMBOL_GPL(snd_soc_dpcm_fe_can_update); - -/* is the current PCM operation for this BE ? */ -int snd_soc_dpcm_be_can_update(struct snd_soc_pcm_runtime *fe, - struct snd_soc_pcm_runtime *be, int stream) -{ - if ((fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_FE) || - ((fe->dpcm[stream].runtime_update == SND_SOC_DPCM_UPDATE_BE) && - be->dpcm[stream].runtime_update)) - return 1; - return 0; -} -EXPORT_SYMBOL_GPL(snd_soc_dpcm_be_can_update); - /* get the substream for this BE */ struct snd_pcm_substream * snd_soc_dpcm_get_substream(struct snd_soc_pcm_runtime *be, int stream) @@ -2988,84 +3069,3 @@ struct snd_pcm_substream * return be->pcm->streams[stream].substream; } EXPORT_SYMBOL_GPL(snd_soc_dpcm_get_substream); - -static int snd_soc_dpcm_check_state(struct snd_soc_pcm_runtime *fe, - struct snd_soc_pcm_runtime *be, - int stream, - const enum snd_soc_dpcm_state *states, - int num_states) -{ - struct snd_soc_dpcm *dpcm; - int state; - int ret = 1; - int i; - - for_each_dpcm_fe(be, stream, dpcm) { - - if (dpcm->fe == fe) - continue; - - state = dpcm->fe->dpcm[stream].state; - for (i = 0; i < num_states; i++) { - if (state == states[i]) { - ret = 0; - break; - } - } - } - - /* it's safe to do this BE DAI */ - return ret; -} - -/* - * We can only hw_free, stop, pause or suspend a BE DAI if any of it's FE - * are not running, paused or suspended for the specified stream direction. - */ -int snd_soc_dpcm_can_be_free_stop(struct snd_soc_pcm_runtime *fe, - struct snd_soc_pcm_runtime *be, int stream) -{ - const enum snd_soc_dpcm_state state[] = { - SND_SOC_DPCM_STATE_START, - SND_SOC_DPCM_STATE_PAUSED, - SND_SOC_DPCM_STATE_SUSPEND, - }; - - return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state)); -} -EXPORT_SYMBOL_GPL(snd_soc_dpcm_can_be_free_stop); - -/* - * We can only change hw params a BE DAI if any of it's FE are not prepared, - * running, paused or suspended for the specified stream direction. - */ -int snd_soc_dpcm_can_be_params(struct snd_soc_pcm_runtime *fe, - struct snd_soc_pcm_runtime *be, int stream) -{ - const enum snd_soc_dpcm_state state[] = { - SND_SOC_DPCM_STATE_START, - SND_SOC_DPCM_STATE_PAUSED, - SND_SOC_DPCM_STATE_SUSPEND, - SND_SOC_DPCM_STATE_PREPARE, - }; - - return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state)); -} -EXPORT_SYMBOL_GPL(snd_soc_dpcm_can_be_params); - -/* - * We can only prepare a BE DAI if any of it's FE are not prepared, - * running or paused for the specified stream direction. - */ -int snd_soc_dpcm_can_be_prepared(struct snd_soc_pcm_runtime *fe, - struct snd_soc_pcm_runtime *be, int stream) -{ - const enum snd_soc_dpcm_state state[] = { - SND_SOC_DPCM_STATE_START, - SND_SOC_DPCM_STATE_PAUSED, - SND_SOC_DPCM_STATE_PREPARE, - }; - - return snd_soc_dpcm_check_state(fe, be, stream, state, ARRAY_SIZE(state)); -} -EXPORT_SYMBOL_GPL(snd_soc_dpcm_can_be_prepared);