From patchwork Tue Jul 30 01:33:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 815350 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 85B85C3DA4A for ; Tue, 30 Jul 2024 01:34:05 +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 CEAE0AE8; Tue, 30 Jul 2024 03:33:53 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz CEAE0AE8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1722303243; bh=TtDKbSNql/AqfF87YrEALkDtAxCQRolyOPwj1aiMlQE=; 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=d0Dt2gLcS6j0/njBJkSN33pOyOOYGcxVzPbyDB2umLQ83dR/yh2krFt9VwXnkmjBC g56Kv0wGaa6OOtmvURDvOoubVjQhDoVmpYvqFSeFX+9v/4+ZTH5zP9QX5JMPExm4lA t/+iKYl88tQByaXQjjIB3s7+AsIYk2Eod0789j/I= Received: by alsa1.perex.cz (Postfix, from userid 50401) id A452DF805B5; Tue, 30 Jul 2024 03:33:33 +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 51879F805AF; Tue, 30 Jul 2024 03:33:33 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0BF93F80448; Tue, 30 Jul 2024 03:33:29 +0200 (CEST) Received: from TYVP286CU001.outbound.protection.outlook.com (mail-japaneastazlp170110002.outbound.protection.outlook.com [IPv6:2a01:111:f403:c405::2]) (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 26DFBF8007E for ; Tue, 30 Jul 2024 03:33:19 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 26DFBF8007E 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=LnxmQUm0 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MhjtxZVdpal/AmOsveFvMGKOArJmMm/Bn46WzGpgB1Bkc4JPn2FspfpydJBY7sVbvav06/AtavlmdvO18FOEgLBmUvBmijgZzl6NOq/joq1dNMEJ+NwKKMn9bmHgII+OdNdJH7hclv042fouEEPkb1fRlk+k99wDpMMvSHPR7TUr0Ct3VfqlxwkJEpAy1JiYAlzAbtOAVGouQLEUyw8cMQG+MlcldIIOfQbDa5/mbW0hYoxbjhoFdmu7/+CaEb608YqSkIVpWZHFop7FLJzbtrG5AgwhfIdtTyRn+/0QwEYc3CgNc5T7V1aeH5jt+AP4Ha8RjGLaEMbyMwt20J9vxg== 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=T5k4QMWimaRNAs6BGlCKrh1lMVMXlDZmUW4ASKTi1Tk=; b=x4z3I0erS+H2aCHcSVXU2crwxuUh+Tt/8X98IeCCEfWgRLIhKonxiIXcSr/o4zqkudAGZLhKtQ5SBRpcUEeiwvRQwLjyPHb0GVFcjEbjH2V3D5WsWEABHVm5ke2lAFxOJ3gvvaeim0f1wEhCAeyKeBYY4wQRIWKExNoD9yjlXaiDq3Zwq8gxvuPquXSwa35Py8sDXZmTiuZg3Ylq3oxfHynWzY1pRk3hKBqWHJubBMjzY9uxidX1EPOuULR6YVKVkGK9v+1gXMC0XoIifxb4OgRxD+1+RbWcPFxdCzmRW+t/8yLSQa5Bf7y0qZXORZ0AotKNxUDM1+nRuenSXzKANQ== 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=T5k4QMWimaRNAs6BGlCKrh1lMVMXlDZmUW4ASKTi1Tk=; b=LnxmQUm0xSMy672l6nNVA4WjpnDqGDlw4tfiSTzq5OQ4YsozNOfZ45j6XW1mOPHZSdtDv8k2wi8cM11fMD8eOz/YWOiKyZmBhqwQCP+vqLH36zyxSxLY0NaPJXIiwnNGmyJmpUGMucTjJSSZt2GiXMJ+d/0Lebk+Ow1aVQHrfqw= 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 TYYPR01MB7901.jpnprd01.prod.outlook.com (2603:1096:400:114::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7807.28; Tue, 30 Jul 2024 01:33:14 +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.7807.026; Tue, 30 Jul 2024 01:33:13 +0000 Message-ID: <87zfpzk6jq.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 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 To: Mark Brown Cc: Linux-ALSA In-Reply-To: <871q3bll5c.wl-kuninori.morimoto.gx@renesas.com> References: <871q3bll5c.wl-kuninori.morimoto.gx@renesas.com> Date: Tue, 30 Jul 2024 01:33:13 +0000 X-ClientProxiedBy: TYCP301CA0067.JPNP301.PROD.OUTLOOK.COM (2603:1096:405:7d::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_|TYYPR01MB7901:EE_ X-MS-Office365-Filtering-Correlation-Id: 041edb19-d137-4f65-39bd-08dcb0379455 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|52116014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: S/uMVUfb2++HyGnOw627dSKV/6u/fQMvZVDZw5eUjR0IpotI5nzg3+Qyulihfbt/fVhrQcQHT9Nu9UbwQX1/tBkTSnnr7UtoLcc5ifwyeLXedKshdrtf8vAleVRrfJyZkLmt+UMbG6Ls9ozc2A+XRaGsJL4q2A0mMWvHK59V6Jwthl7RQWIIwpeFnUhQ9+e0OozBbJxULPgMZGlJtOD+4qy8ce4D+CIK9zdqLmZqebkYiuZ4Q/9H+OnDjrRZYz/J1ObtKrd3dxOyzXwsF8FwqV4j6eXJ0qrYcgySUzLoKWE/eTNyUJCekBwMoXVLp9LxxmfRV3ZZ6ATkUvdMTlQTyo8MQ0hXIxQrXnoHQ7JQukPOmqRioJgOARsJD7zmjGLO3dsy5yies2Yol5aaHexmSCS5yC5mZES402WQcI80Wtuq1fr9Gg5NgjmuIrGJXRNGRdj7F10SHkiV1uxf5NeOPIBm/+Qk963BkeLJeknG3ZRP4OvPmKItoF7EXQUvdGhI9UqUO040D14kmdg/iCsdUVFdKEau0R6dyPgWkdANc1iRxHPW9pfaNa/utrFwyRWDuSt1mOjlHJB3L1MZmmzuBPinLYZqHaTJwK96o1CloaGxXBsV0/5MZNrv3OZFBF9WaT+JoXugv4DRG0amOO0ojS7v7th3l6hNuHUWQuZ7jkn/CjR5AcIiCJu4VHkgV+pwrAD+7PMAcUD6FpSb4CSc92INvfceIPvtBXLtnG7iifB7rAe1RMqYZj8ahHQoe07OjOTvcIKSmAuAiHCxUI87PiZ6CCpQvC7xqEgR+VtrtCsxNLyOjf1nDOL1ysiCKy7TnluMuO+8ASj3w3ZzZdTTMOWho3zHNDCdeN5bOupXE+2xt/tG3HQTOh9/vsvWb9WvXVnBxYrHcX7qSwo9zmUZ2HacnedJKCUdI3xxuWQoXg0Mhdq91L9PUsRmEi0SyQFgile+T0XTgv/i8EcAfF7/3b8jZRZpQOasjon/HG0VTpjtdUjTpw0wVz7pyBbI4Mr7VMDATeIr0UbNKLVjHlE8QxNnXM0ocUnkAmjd7dLx4goqXY2QGWfsujIvY0lkhzqI7s9IPJ7BjIL0iG8Q5zJOWm5kKaGJTPBhCYHAwKAwRAd1meE5hJLa695GCncnLQ8UpBiY0RMD/QPNl6enVTt6w5AlwdKuTamPxu6ipkxJZ6LPKWNjTZRLPyc/eEJ5G5nrCV2Y/Vmbpt0oQ+35DDBd7uHwu07HnlpYhtICTGq6NkpTUYoufrV+FJLsdVpOoGYc3Iahv550xf2LgoUlJED8N2qASrfuqj04tcKe7NuzlsyGP9DtNcazsRjbh1Dq/6ehiy18FrYeRoChn+PmIqvLPvX4xC8ESM5It+XDNjj17GLNCllDktK86bXlCkmqly5Higehk2Wo1DuA6w6OiOOhnA== 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)(376014)(52116014)(1800799024)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tOnhnkgX7dWiOReOru6thbB3D4Rv0Q3w2xBARXVroyMj/U2jBB2/E3qNnUubkgbiEfsTRLcX/mxbl65adLmegiTNNd/M2qdCv4hGgiyAPXdWjeq6O6728kcy1LXdrcfx8JW4w8BJQXn3gD8pXJqxAP3t45r68Ffu2xYi7VX4esk+fvyUOqbda9IkKAlLBqOCnB8KL12q3en6cMNS3lSfZLdjoE59nUQwsXCDBFNgqMPGpa46Orbajdo0UyreIivxql8q0czkAAhwRi395tR5bs1Dc1Thtm3uOF35bBDJqXahEcXHEYe3TS3lEwLcYKLFhUriVumcFiS5WyPJKusPl+Q02DnAsBHJRNqrENZrkTm7f4LDOer6soJ3qjsFtJRNbf0aOvRcboAYLXHFvBwziwj93uD75mpFVKd9MmJcxU3grozQyazEbJUxUEiV16F/SG9oCXO2RJ/5AugiqOwzKnFwWKJ9H2bOM1RBQIYE6h4F/efS2Uv9QgiMdjiKQ14DKyoWyAbVSP4Q7FV56Yyw2l9SsDVAK9XMnj+ksW+5JBNbgAJj9X+hTrhj5DFj8Z5vDnmwDYv5rIUuB1qxPKvkp5DxYl3vGzTV04CB/VCk/5OfHp0bhVsxD/nLfRbGjyGJpmQBGMxkxmRF/0Q+CAvaL0YH6NZ8x4l9JjOSL09U21e0s9knJdisDpFlXRsknL/dJOUiIvdhYWAs6aebO9eT0bo9Kp6GLUu0GLBhwyj+X3xcWgQaB7ocDzNJQKfBNLZQ9dz8XY9xUqce09meqpkYV8dWUj2RzEstJSEurIOAHf0sbwEhyqTPQdEbfx6da+6WSV8jtFtsoayWWgrbDWkCNwPJYzbehssHELq390QzOHAPJ4ukD68m0BEH7I1W4P+wH+T6DNdBHiP+hHYxOP0MWIaC04gDY6pdtEVvkLKBXunYJPB7UrAz6iwtD8hZTV2UxgbdlytbKkK5GTG7D/HQ5PWMrmZBiue/4ghwEqGB8oS/kXahRe7k4cXjbwAknVQIQElCbgfD2GNoNd7uBlolS/U4dw5ziPU1ZSR7vj71epwtLuaX9dzX8u/BtPWLUB35JwYui1eBZxFBD45Jn16cSHweVvmVYW5L82ig0I8YwHdJsz7BF176YHGqSLQ/5H3kUkv+MAaugbgY0g5couqAdy7EPGj+Nbn6fW1SieyJ/z39G71eXizvNpczMB578fMloez0vpg2AODWfutSyijnikkmhPEW0zRg1wyWOvw+Iv1WaNor4kkB0OHmRU+j7XCWnXfgGrhRLikKWtOwnzJgK0PJq140UVrjh//ImMqhOLgXHKOxZOOnklc0fZFIegTcHzTfckO5YSCQLurVGnv17AekNwfvBytZkA4JVrSJRVQYcIu/n+2VEcDI7YJOx0SwxT1e0H+fwChJGg3hMbUsgEMa5VTdnsWZBkUWkqFOgJL56DBRGA/3EcSNxUMCGWv48/FSUH9v7/lno4FsB6eKFc5Zpu46RTIs4gt76pHbXARU5sTGMaDOp+UaDzaURh5dVnGJlUHocmYyUJVEA6Vy77z2Pf6mGinh1Afy5JOmG3xW8f8wq0h77GJxhZrZN5o4k2drHgpjNBi5+7OOiLDPUIqrFIrSjjklFDlUHAcUcj0= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 041edb19-d137-4f65-39bd-08dcb0379455 X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2024 01:33:13.9019 (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: pDR3Kz9xhTH2O9DnLrbCqs0Gm6pPjy8MerDKsN9tZ9cqoigJcGlg25qNvNiK51h7Kwjt37b1VNEIcGRt5JLyBUhJPafd1+vUvTChMRaBxC9ng6LUlXtu0Ft2zMIHGBgl X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYYPR01MB7901 Message-ID-Hash: 23MJ3KYOYRG7SFBD5AGRQAZVH3OWNLMF X-Message-ID-Hash: 23MJ3KYOYRG7SFBD5AGRQAZVH3OWNLMF 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 5646525ad7924..961fadc6fbf88 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);