From patchwork Sun Nov 26 23:19:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 747444 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=renesas.com header.i=@renesas.com header.b="N4nDNBje" Received: from JPN01-TYC-obe.outbound.protection.outlook.com (mail-tycjpn01on2090.outbound.protection.outlook.com [40.107.114.90]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AD9E111 for ; Sun, 26 Nov 2023 15:19:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I7fYay3TBqdwt2oPWhByeG6S4UvBALrBf/L6EIT9DkT2ZzO6HxqKsnvaaEuSe9sXG7foJqkOdSpW7BeghdmGqPI5+kisIqzznsZDiKbH3iBpssM0s9AxcglByXKvX3pf1psxeWL1s0WX8kmkqb2lrhQMCFI+c+KHRzKQE4/FUwWoKLqauV5JLrRZYwQzoXcM7FSWE8uMyk/u2cap7fs+vgtLqK5gDc6BCKgLAJHtjVzc87v0hSAgo2h5E0W2WLupq6Xc63Atvm+3Dvj0OJlVtsGb3Y1w4SVB5KCtWDUpauO+qj0OR/xHCB2lWp6R/S7ANNcawIpSMvPHkBo22T0Pow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=9mzn6aEEqfjRey7eAmQFxfH0YJvdMXpBFkFgceCG4ZM=; b=Jp/mCBMPj6mu0LLoBtLOA73kowcpAwgawbtVwWhVUS19dqrCaGJct/yOFTFrmOEzx0ktmK/AY94XXUwRkTsv0UOEFKN3IxnjTIqoPsBOyrf9DMCECIZPyBvYa2SDZgpsyv4sVwv8o2ESH6lMVMnrUoRpv6sJKqa1zyBBs9UCBRlzXlUfyZBfyMj8y8oIgGiYinDa0tQkJW+IzueABLtCJsGzFXpC00Tz0mV8PIORyVQTJ0J2qFABeCQFKPfQb1S4ZA0lBzBlmxj4Nc0sGLA+FLUNa2qOpm/VXNwGKbT5suMEVlcW4FqmgWayKEHsUm04/6f373ox5pQGSoAqUmwZFA== 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=9mzn6aEEqfjRey7eAmQFxfH0YJvdMXpBFkFgceCG4ZM=; b=N4nDNBjetYdvKjRRwyEQr1OS2x8uRklEAe2xi54XIABlf27RQ+G8yfWqjDFKA+W2F4qDLrMNDnx+J5Wwr/gpJi5uYbBHzwi/CYe3L1xzefnVnVjMvSh/cc+sHRand6ewDwhH3W14UBzhL1euJDZPrX7nBpWx3QqQZixTqWQm0+g= 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 OSRPR01MB11697.jpnprd01.prod.outlook.com (2603:1096:604:230::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.27; Sun, 26 Nov 2023 23:19:05 +0000 Received: from TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::16b3:a84d:faa6:4846]) by TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::16b3:a84d:faa6:4846%6]) with mapi id 15.20.7025.022; Sun, 26 Nov 2023 23:19:05 +0000 Message-ID: <87sf4sw1av.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v7 resend 1/5] ASoC: makes CPU/Codec channel connection map more generic User-Agent: Wanderlust/2.15.9 Emacs/27.1 Mule/6.0 To: Pierre-Louis Bossart , Mark Brown , Bard Liao , bard.liao@intel.com, Conor Dooley , Krzysztof Kozlowski , Rob Herring , Jerome Brunet Cc: alsa-devel@alsa-project.org, devicetree@vger.kernel.org In-Reply-To: <87ttp8w1bk.wl-kuninori.morimoto.gx@renesas.com> References: <87ttp8w1bk.wl-kuninori.morimoto.gx@renesas.com> Date: Sun, 26 Nov 2023 23:19:05 +0000 X-ClientProxiedBy: TYCPR01CA0006.jpnprd01.prod.outlook.com (2603:1096:405::18) To TYCPR01MB10914.jpnprd01.prod.outlook.com (2603:1096:400:3a9::11) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCPR01MB10914:EE_|OSRPR01MB11697:EE_ X-MS-Office365-Filtering-Correlation-Id: 2870b504-83f7-4de9-a23c-08dbeed6155f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4KwyhlwcmGfUcwhgR9wQiKyRBl2dRSYwyLJDj0JJ2kOtCUy7nZJ3ys1UsBw1KW/4qDQTIeFrq250AMcsW6Dt5KiosZddNgQ8k2kRoRWjPesOYDr+hIs0lBf+zCVjW7B58d03LFhzYXkQvlHTBuDjwKxgEHo3xD1URDCamO+9jyZ9wm93iqyuCbxXshIlvGRb0fq/tpQhL5AVtScOsnGI+uR2nePgtMHve4zNDvp4wrY7XOdDX3DEg5ozuiMfteQLjCdui8qaA50e6y/lveFhSTBcVePqsKOjNM9H5s05lEhVVNqjujhuS5oM1gawJPl3/1w17hIfkMhaTWW6fJmDyuLKTYh8beqSPfuLC3XLwWIlfL+AiMj3+eElwebqIQ6fIruEPdPbFB29Ky6IGPGfdWXK8MB1yyHu2KttORUnQ/ayXdNDHnAyHv9kx+OSQ07VKRTj4GwI1f712kNgejEm8SZLBSJYlNUUJulN3RtKRO2az3Lx5vXoNnm3TF9E6HVqCYZYy/bVsNDeMRVHQ/Hq26ObrvgMYux28gWsgGRYsfLtaph9M/yqa5ENi3+dbkuGO6CfWNZ1KlasWzbRwQhJBRuchQt7A442xwuPJ2c/cpfy+1ZlygW7XEXZkQAfTWvg/ORrkh8NcU1E/cd199vbOy8KhUnqs3aLCoX2RHrNt9g= 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:(13230031)(39860400002)(396003)(376002)(136003)(366004)(346002)(230922051799003)(1800799012)(186009)(451199024)(64100799003)(7416002)(4326008)(2906002)(30864003)(8676002)(8936002)(41300700001)(26005)(66476007)(110136005)(316002)(66946007)(66556008)(6512007)(52116002)(5660300002)(2616005)(6506007)(83380400001)(966005)(86362001)(38100700002)(38350700005)(6486002)(478600001)(36756003)(41533002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yxhsnOYJ//r1pklrb1leqsV9IKc/BTx1tfASw9A6dDNgO70IiS/yqTHp/B1c5uNLzqNQQVPZdEBMKAJYuoIhwUr/pKM547Q0mr+2ovF006B0n3U9hnVlkGMsJFjRVGemlNfw8pXCdXlthBQcAwz4ib/b1kjcJM9mq2RRNzKLci26hG9vn0U/OP0NHkFj+FQg5DTuwfshUuh7UdkIEtbrpynjIfP6jVRkm9JElUhdldaMuZwjD1uGiQA2NIeKaLP1M1y2yIavdfW77EPiduputl5iARB6sVogb/KiqbxBvfG/zsBx92yKp/XeqYkvahlQyqlzG4WjqOhftJTOebZ4RFyCa5lvHl7YtjEJyqXXuG5WnkA9qU+11U7oS5YdralI3VkL1AXzTRhWigflNVPhddXQ/K2RKBwaa5BJuPvTMMhvhRXfvLrbO68wK/QGFJ7O9SCapxMpU76STJnxqJuxd/76+srCpmZf4JZyHCUEoC3misgMzRFNX1cN8vj1RjXftnrkpZHkz1YDR/D9uet8+rThyRYxx04Qcmwai0ZZyVnA3boJ9Y7PbkmtONcE1mnYi79ccSxJBzO1VksmwRYtwbxdox51Dc5zEZdurRLRPUE2dgXi+1TJhZCq3Ta1N1D8WOQD/lhF7EjPmLBaZKy0B7OeZikK7d3IGyvL7a31zSZ1NGcGdWeD1Gab6GozG49sBG0u+LWI+2y+7fmaYvfPJuFjVPiR7BN9+F6Uv5r4dLiRNRpw6x2JG4Ysu0ydf1NxmdeaG15EsImo/ssoXNOSPvAZHLMxJPbkTZGkUUlc+RTDHai8VXueRnLSlywLML9Bk+etoTYhady0J5RNTFTNTcO5YGyeiLNoNEIk2KQLY6Hnj8Zv5iWwWMlU9GTH1JXziguOnMavzixWU7WqBp4wjeoH9bBYvY5PL5krOsFzMCZqJa06+oVOSZ3X+DU8a5nAjdWEc+YG4nImHTsLhE3r/SxqIOL9LgzdWisPOmtk6ZfeuzuwNvmE6TU5wlJ48lj9zb8/4ZG1q0U0IJmj2ewe4r6mzci4TuuhrlcmV0Z1ChDeNO1cXMiGEzPlskY5EdA1aqFZbUFRZQxv4B8pQOC+hdgfmUoGFISxtvQzRvG6suLMTOzeWb7tGnJf7dsG+MfkAk5MR3OvcUOo1VNZISqIFdBQLqslzstPaVO1CC7aa8fbd59/9QDybMLCaxT0djGeRSHmoGPvr8etlseSux6+w4XH6cRaPMLgtVAX6HJHyaIXRvTIzYtcpbqY1aOW1DrDgfkGf9Z4Yalk0iMgBJ0ZIZf2t4nVZrbo9x28KrpLSzozqoltHd79omH4lqjZS0xzJlfXhxOp+v5OlmUp7Mox0JlMBEXpZ0CelD6IuS/X1vNZmX7Yz5IgM9zdseacz3xG19lu4Xj/k2pCaHxKCOACV8/hOa22rEis2jGD6EwgtdVO9ZIQXyQGso5dTqeP1raPVjWKV1DyevDaAo8veA9RpHDLzmVfX/QrpvKt2V3Tpx0xnA1r7akqJXJl4JEpMpDXc4cwE0ohBrQ2tOGOuvVk7Nn15/7RFFytZMS8s3fjPW7F4MeoqvFx43n5Vr00vw3xWvM7wq2EEwT5UFCUTJ+DnQdRyyLih/4Eibz3FoXXjS4= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2870b504-83f7-4de9-a23c-08dbeed6155f X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Nov 2023 23:19:05.3865 (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: Exbe9ZDnzA3SSbD3NXA7iSFyOpAoX8KXOKcrhlO7wZSY28DmMBnGgglYB6zjiX0JOmT0yHXi6k5rAPLnjfkYKOLmrM0Q+98wedk2LHzu5YnBfld7aFz15BvjfbBN0Ho1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSRPR01MB11697 Current ASoC CPU:Codec = N:M connection is using connection mapping idea, but it is used for N < M case only. We want to use it for any case. By this patch, not only N:M connection, but all existing connection (1:1, 1:N, N:N) will use same connection mapping. Then, because it will use default mapping, no conversion patch is needed to exising drivers. More over, CPU:Codec = N:M (N > M) also supported in the same time. ch_maps array will has CPU/Codec index by this patch. Image CPU0 <---> Codec0 CPU1 <-+-> Codec1 CPU2 <-/ ch_map ch_map[0].cpu = 0 ch_map[0].codec = 0 ch_map[1].cpu = 1 ch_map[1].codec = 1 ch_map[2].cpu = 2 ch_map[2].codec = 1 Link: https://lore.kernel.org/r/87fs6wuszr.wl-kuninori.morimoto.gx@renesas.com Link: https://lore.kernel.org/r/878r7yqeo4.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Kuninori Morimoto Tested-by: Pierre-Louis Bossart Tested-by: Jerome Brunet --- include/sound/soc.h | 56 ++++++++++++++++++- sound/soc/intel/boards/sof_sdw.c | 28 ++++------ sound/soc/soc-core.c | 95 +++++++++++++++++++++++++++++++- sound/soc/soc-dapm.c | 45 ++++----------- sound/soc/soc-pcm.c | 44 +++++---------- 5 files changed, 185 insertions(+), 83 deletions(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index 7792c393e238..f3803c2dc349 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -655,8 +655,45 @@ struct snd_soc_dai_link_component { struct of_phandle_args *dai_args; }; -struct snd_soc_dai_link_codec_ch_map { - unsigned int connected_cpu_id; +/* + * [dai_link->ch_maps Image sample] + * + *------------------------- + * CPU0 <---> Codec0 + * + * ch-map[0].cpu = 0 ch-map[0].codec = 0 + * + *------------------------- + * CPU0 <---> Codec0 + * CPU1 <---> Codec1 + * CPU2 <---> Codec2 + * + * ch-map[0].cpu = 0 ch-map[0].codec = 0 + * ch-map[1].cpu = 1 ch-map[1].codec = 1 + * ch-map[2].cpu = 2 ch-map[2].codec = 2 + * + *------------------------- + * CPU0 <---> Codec0 + * CPU1 <-+-> Codec1 + * CPU2 <-/ + * + * ch-map[0].cpu = 0 ch-map[0].codec = 0 + * ch-map[1].cpu = 1 ch-map[1].codec = 1 + * ch-map[2].cpu = 2 ch-map[2].codec = 1 + * + *------------------------- + * CPU0 <---> Codec0 + * CPU1 <-+-> Codec1 + * \-> Codec2 + * + * ch-map[0].cpu = 0 ch-map[0].codec = 0 + * ch-map[1].cpu = 1 ch-map[1].codec = 1 + * ch-map[2].cpu = 1 ch-map[2].codec = 2 + * + */ +struct snd_soc_dai_link_ch_map { + unsigned int cpu; + unsigned int codec; unsigned int ch_mask; }; @@ -688,7 +725,9 @@ struct snd_soc_dai_link { struct snd_soc_dai_link_component *codecs; unsigned int num_codecs; - struct snd_soc_dai_link_codec_ch_map *codec_ch_maps; + /* num_ch_maps = max(num_cpu, num_codecs) */ + struct snd_soc_dai_link_ch_map *ch_maps; + /* * You MAY specify the link's platform/PCM/DMA driver, either by * device name, or by DT/OF node, but not both. Some forms of link @@ -775,6 +814,10 @@ struct snd_soc_dai_link { #endif }; +static inline int snd_soc_link_num_ch_map(struct snd_soc_dai_link *link) { + return max(link->num_cpus, link->num_codecs); +} + static inline struct snd_soc_dai_link_component* snd_soc_link_to_cpu(struct snd_soc_dai_link *link, int n) { return &(link)->cpus[n]; @@ -808,6 +851,12 @@ snd_soc_link_to_platform(struct snd_soc_dai_link *link, int n) { ((cpu) = snd_soc_link_to_cpu(link, i)); \ (i)++) +#define for_each_link_ch_maps(link, i, ch_map) \ + for ((i) = 0; \ + ((i) < snd_soc_link_num_ch_map(link) && \ + ((ch_map) = link->ch_maps + i)); \ + (i)++) + /* * Sample 1 : Single CPU/Codec/Platform * @@ -1163,6 +1212,7 @@ struct snd_soc_pcm_runtime { ((i) < (rtd)->dai_link->num_cpus + (rtd)->dai_link->num_codecs) && \ ((dai) = (rtd)->dais[i]); \ (i)++) +#define for_each_rtd_ch_maps(rtd, i, ch_maps) for_each_link_ch_maps(rtd->dai_link, i, ch_maps) void snd_soc_close_delayed_work(struct snd_soc_pcm_runtime *rtd); diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c index 3312ad8a563b..2faf7372bad0 100644 --- a/sound/soc/intel/boards/sof_sdw.c +++ b/sound/soc/intel/boards/sof_sdw.c @@ -570,16 +570,14 @@ int sdw_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); + struct snd_soc_dai_link_ch_map *ch_maps; int ch = params_channels(params); - struct snd_soc_dai *codec_dai; - struct snd_soc_dai *cpu_dai; unsigned int ch_mask; int num_codecs; int step; int i; - int j; - if (!rtd->dai_link->codec_ch_maps) + if (!rtd->dai_link->ch_maps) return 0; /* Identical data will be sent to all codecs in playback */ @@ -605,13 +603,9 @@ int sdw_hw_params(struct snd_pcm_substream *substream, * link has more than one codec DAIs. Set codec channel mask and * ASoC will set the corresponding channel numbers for each cpu dai. */ - for_each_rtd_cpu_dais(rtd, i, cpu_dai) { - for_each_rtd_codec_dais(rtd, j, codec_dai) { - if (rtd->dai_link->codec_ch_maps[j].connected_cpu_id != i) - continue; - rtd->dai_link->codec_ch_maps[j].ch_mask = ch_mask << (j * step); - } - } + for_each_link_ch_maps(rtd->dai_link, i, ch_maps) + ch_maps->ch_mask = ch_mask << (i * step); + return 0; } @@ -1350,15 +1344,17 @@ static int get_slave_info(const struct snd_soc_acpi_link_adr *adr_link, return 0; } -static void set_dailink_map(struct snd_soc_dai_link_codec_ch_map *sdw_codec_ch_maps, +static void set_dailink_map(struct snd_soc_dai_link_ch_map *sdw_codec_ch_maps, int codec_num, int cpu_num) { int step; int i; step = codec_num / cpu_num; - for (i = 0; i < codec_num; i++) - sdw_codec_ch_maps[i].connected_cpu_id = i / step; + for (i = 0; i < codec_num; i++) { + sdw_codec_ch_maps[i].cpu = i / step; + sdw_codec_ch_maps[i].codec = i; + } } static const char * const type_strings[] = {"SimpleJack", "SmartAmp", "SmartMic"}; @@ -1453,7 +1449,7 @@ static int create_sdw_dailink(struct snd_soc_card *card, int *link_index, *ignore_pch_dmic = true; for_each_pcm_streams(stream) { - struct snd_soc_dai_link_codec_ch_map *sdw_codec_ch_maps; + struct snd_soc_dai_link_ch_map *sdw_codec_ch_maps; char *name, *cpu_name; int playback, capture; static const char * const sdw_stream_name[] = { @@ -1530,7 +1526,7 @@ static int create_sdw_dailink(struct snd_soc_card *card, int *link_index, dai_links[*link_index].nonatomic = true; set_dailink_map(sdw_codec_ch_maps, codec_num, cpu_dai_num); - dai_links[*link_index].codec_ch_maps = sdw_codec_ch_maps; + dai_links[*link_index].ch_maps = sdw_codec_ch_maps; ret = set_codec_init_func(card, adr_link, dai_links + (*link_index)++, playback, group_id, adr_index, dai_index); if (ret < 0) { diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index b2bd45e87bc3..4ca3319a8e19 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1015,6 +1015,94 @@ static int soc_dai_link_sanity_check(struct snd_soc_card *card, return -EINVAL; } +#define MAX_DEFAULT_CH_MAP_SIZE 7 +static struct snd_soc_dai_link_ch_map default_ch_map_sync[MAX_DEFAULT_CH_MAP_SIZE] = { + { .cpu = 0, .codec = 0 }, + { .cpu = 1, .codec = 1 }, + { .cpu = 2, .codec = 2 }, + { .cpu = 3, .codec = 3 }, + { .cpu = 4, .codec = 4 }, + { .cpu = 5, .codec = 5 }, + { .cpu = 6, .codec = 6 }, +}; +static struct snd_soc_dai_link_ch_map default_ch_map_1cpu[MAX_DEFAULT_CH_MAP_SIZE] = { + { .cpu = 0, .codec = 0 }, + { .cpu = 0, .codec = 1 }, + { .cpu = 0, .codec = 2 }, + { .cpu = 0, .codec = 3 }, + { .cpu = 0, .codec = 4 }, + { .cpu = 0, .codec = 5 }, + { .cpu = 0, .codec = 6 }, +}; +static struct snd_soc_dai_link_ch_map default_ch_map_1codec[MAX_DEFAULT_CH_MAP_SIZE] = { + { .cpu = 0, .codec = 0 }, + { .cpu = 1, .codec = 0 }, + { .cpu = 2, .codec = 0 }, + { .cpu = 3, .codec = 0 }, + { .cpu = 4, .codec = 0 }, + { .cpu = 5, .codec = 0 }, + { .cpu = 6, .codec = 0 }, +}; +static int snd_soc_compensate_channel_connection_map(struct snd_soc_card *card, + struct snd_soc_dai_link *dai_link) +{ + struct snd_soc_dai_link_ch_map *ch_maps; + int i; + + /* + * dai_link->ch_maps indicates how CPU/Codec are connected. + * It will be a map seen from a larger number of DAI. + * see + * soc.h :: [dai_link->ch_maps Image sample] + */ + + /* it should have ch_maps if connection was N:M */ + if (dai_link->num_cpus > 1 && dai_link->num_codecs > 1 && + dai_link->num_cpus != dai_link->num_codecs && !dai_link->ch_maps) { + dev_err(card->dev, "need to have ch_maps when N:M connction (%s)", + dai_link->name); + return -EINVAL; + } + + /* do nothing if it has own maps */ + if (dai_link->ch_maps) + goto sanity_check; + + /* check default map size */ + if (dai_link->num_cpus > MAX_DEFAULT_CH_MAP_SIZE || + dai_link->num_codecs > MAX_DEFAULT_CH_MAP_SIZE) { + dev_err(card->dev, "soc-core.c needs update default_connection_maps"); + return -EINVAL; + } + + /* Compensate missing map for ... */ + if (dai_link->num_cpus == dai_link->num_codecs) + dai_link->ch_maps = default_ch_map_sync; /* for 1:1 or N:N */ + else if (dai_link->num_cpus < dai_link->num_codecs) + dai_link->ch_maps = default_ch_map_1cpu; /* for 1:N */ + else + dai_link->ch_maps = default_ch_map_1codec; /* for N:1 */ + +sanity_check: + dev_dbg(card->dev, "dai_link %s\n", dai_link->stream_name); + for_each_link_ch_maps(dai_link, i, ch_maps) { + if ((ch_maps->cpu >= dai_link->num_cpus) || + (ch_maps->codec >= dai_link->num_codecs)) { + dev_err(card->dev, + "unexpected dai_link->ch_maps[%d] index (cpu(%d/%d) codec(%d/%d))", + i, + ch_maps->cpu, dai_link->num_cpus, + ch_maps->codec, dai_link->num_codecs); + return -EINVAL; + } + + dev_dbg(card->dev, " [%d] cpu%d <-> codec%d\n", + i, ch_maps->cpu, ch_maps->codec); + } + + return 0; +} + /** * snd_soc_remove_pcm_runtime - Remove a pcm_runtime from card * @card: The ASoC card to which the pcm_runtime has @@ -1121,8 +1209,13 @@ int snd_soc_add_pcm_runtimes(struct snd_soc_card *card, int num_dai_link) { for (int i = 0; i < num_dai_link; i++) { - int ret = snd_soc_add_pcm_runtime(card, dai_link + i); + int ret; + + ret = snd_soc_compensate_channel_connection_map(card, dai_link + i); + if (ret < 0) + return ret; + ret = snd_soc_add_pcm_runtime(card, dai_link + i); if (ret < 0) return ret; } diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 3844f777c87b..3d72084b6a34 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -4438,11 +4438,14 @@ static void soc_dapm_dai_stream_event(struct snd_soc_dai *dai, int stream, void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card) { struct snd_soc_pcm_runtime *rtd; + struct snd_soc_dai *cpu_dai; struct snd_soc_dai *codec_dai; - int i; /* for each BE DAI link... */ for_each_card_rtds(card, rtd) { + struct snd_soc_dai_link_ch_map *ch_maps; + int i; + /* * dynamic FE links have no fixed DAI mapping. * CODEC<->CODEC links have no direct connection. @@ -4450,39 +4453,15 @@ void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card) if (rtd->dai_link->dynamic) continue; - if (rtd->dai_link->num_cpus == 1) { - for_each_rtd_codec_dais(rtd, i, codec_dai) - dapm_connect_dai_pair(card, rtd, codec_dai, - snd_soc_rtd_to_cpu(rtd, 0)); - } else if (rtd->dai_link->num_codecs == rtd->dai_link->num_cpus) { - for_each_rtd_codec_dais(rtd, i, codec_dai) - dapm_connect_dai_pair(card, rtd, codec_dai, - snd_soc_rtd_to_cpu(rtd, i)); - } else if (rtd->dai_link->num_codecs > rtd->dai_link->num_cpus) { - int cpu_id; - - if (!rtd->dai_link->codec_ch_maps) { - dev_err(card->dev, "%s: no codec channel mapping table provided\n", - __func__); - continue; - } + /* + * see + * soc.h :: [dai_link->ch_maps Image sample] + */ + for_each_rtd_ch_maps(rtd, i, ch_maps) { + cpu_dai = snd_soc_rtd_to_cpu(rtd, ch_maps->cpu); + codec_dai = snd_soc_rtd_to_codec(rtd, ch_maps->codec); - for_each_rtd_codec_dais(rtd, i, codec_dai) { - cpu_id = rtd->dai_link->codec_ch_maps[i].connected_cpu_id; - if (cpu_id >= rtd->dai_link->num_cpus) { - dev_err(card->dev, - "%s: dai_link %s cpu_id %d too large, num_cpus is %d\n", - __func__, rtd->dai_link->name, cpu_id, - rtd->dai_link->num_cpus); - continue; - } - dapm_connect_dai_pair(card, rtd, codec_dai, - snd_soc_rtd_to_cpu(rtd, cpu_id)); - } - } else { - dev_err(card->dev, - "%s: codec number %d < cpu number %d is not supported\n", - __func__, rtd->dai_link->num_codecs, rtd->dai_link->num_cpus); + dapm_connect_dai_pair(card, rtd, codec_dai, cpu_dai); } } } diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 323e4d7b6adf..c20573aeb756 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -1050,6 +1050,7 @@ static int __soc_pcm_hw_params(struct snd_soc_pcm_runtime *rtd, } for_each_rtd_cpu_dais(rtd, i, cpu_dai) { + struct snd_soc_dai_link_ch_map *ch_maps; unsigned int ch_mask = 0; int j; @@ -1063,22 +1064,20 @@ static int __soc_pcm_hw_params(struct snd_soc_pcm_runtime *rtd, /* copy params for each cpu */ tmp_params = *params; - if (!rtd->dai_link->codec_ch_maps) - goto hw_params; /* * construct cpu channel mask by combining ch_mask of each * codec which maps to the cpu. + * see + * soc.h :: [dai_link->ch_maps Image sample] */ - for_each_rtd_codec_dais(rtd, j, codec_dai) { - if (rtd->dai_link->codec_ch_maps[j].connected_cpu_id == i) - ch_mask |= rtd->dai_link->codec_ch_maps[j].ch_mask; - } + for_each_rtd_ch_maps(rtd, j, ch_maps) + if (ch_maps->cpu == i) + ch_mask |= ch_maps->ch_mask; /* fixup cpu channel number */ if (ch_mask) soc_pcm_codec_params_fixup(&tmp_params, ch_mask); -hw_params: ret = snd_soc_dai_hw_params(cpu_dai, substream, &tmp_params); if (ret < 0) goto out; @@ -2826,35 +2825,20 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd, } } } else { + struct snd_soc_dai_link_ch_map *ch_maps; struct snd_soc_dai *codec_dai; /* Adapt stream for codec2codec links */ int cpu_capture = snd_soc_get_stream_cpu(dai_link, SNDRV_PCM_STREAM_CAPTURE); int cpu_playback = snd_soc_get_stream_cpu(dai_link, SNDRV_PCM_STREAM_PLAYBACK); - for_each_rtd_codec_dais(rtd, i, codec_dai) { - if (dai_link->num_cpus == 1) { - cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); - } else if (dai_link->num_cpus == dai_link->num_codecs) { - cpu_dai = snd_soc_rtd_to_cpu(rtd, i); - } else if (rtd->dai_link->num_codecs > rtd->dai_link->num_cpus) { - int cpu_id; - - if (!rtd->dai_link->codec_ch_maps) { - dev_err(rtd->card->dev, "%s: no codec channel mapping table provided\n", - __func__); - return -EINVAL; - } - - cpu_id = rtd->dai_link->codec_ch_maps[i].connected_cpu_id; - cpu_dai = snd_soc_rtd_to_cpu(rtd, cpu_id); - } else { - dev_err(rtd->card->dev, - "%s codec number %d < cpu number %d is not supported\n", - __func__, rtd->dai_link->num_codecs, - rtd->dai_link->num_cpus); - return -EINVAL; - } + /* + * see + * soc.h :: [dai_link->ch_maps Image sample] + */ + for_each_rtd_ch_maps(rtd, i, ch_maps) { + cpu_dai = snd_soc_rtd_to_cpu(rtd, ch_maps->cpu); + codec_dai = snd_soc_rtd_to_codec(rtd, ch_maps->codec); if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_PLAYBACK) && snd_soc_dai_stream_valid(cpu_dai, cpu_playback)) From patchwork Sun Nov 26 23:19:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 747443 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=renesas.com header.i=@renesas.com header.b="iKvvKVG/" Received: from JPN01-TYC-obe.outbound.protection.outlook.com (mail-tycjpn01on2101.outbound.protection.outlook.com [40.107.114.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09A87102 for ; Sun, 26 Nov 2023 15:19:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jULpaWMc5jWbgEw6/teEbczKIraiPKlE/7J/VUSsxLo141Gpzym1r5pcsZPk/6RzosHy2Y6VMc22B9TVqTav/WByM2rAZ8w9E/DKtf6GkaBM3WbilkERJHoqpYaFf93uPh0zKrnGcqb69bZymT2hcdi451QkpeuxMO5fcgdvGSggIVsEDV/Qd69AsH/sobAd1mNWAt0EZkkJn6GG+X5xcwy1TykYz9FIPhJBMQdO+v8AHBILJQRvVheuG9CoBrAHPJgyGg9RErHUPw1bp9oFbkliYV20zuSKU37wTcDkZ+ENsqmzk4CPDbU4G6UvtJJtjibz7Qg2QlNJepuv3Dhyrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=rh+zD44dFT2EJaVtm9IsUpVq9y8f8ECkxLzw1/NSXoU=; b=inGtxFS+vKNskYetqvOfp9a2157uBRiFz9sBi9uN+RJaO1Jle0pGHB1j1XUDVM31NIHA5YuTAL2beIzetv+gBPFqCGjOD0+OOGr+Ywb1TQKOEEDTxzM0rxD0QTWMYk9zYqhcXJMpp7KElbcG+amhOrtHg/wvKKb6tLaMifkN5O40G6B8Z/6ESGGOSHkOS0D7/wejXlVeVz8ZIJEfz833f78vsdK9cZvBFF4sqvFAx6bTHDoAUdbZRQM4rJgmqCDa5viY+NIldEDp23qCIcDLp8Ka93VF77F7bGfcuVGsgkfXMcAXceEN2biC0Mn0+hHTl8jdkFlCOE9iZ5cEPMyC8Q== 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=rh+zD44dFT2EJaVtm9IsUpVq9y8f8ECkxLzw1/NSXoU=; b=iKvvKVG/Bq4SzzUdJPyXzCpAs/CcXS1c5i4i+kJATkgdXwMeJLRZD9/q6Eu5ITRLUKGfhYi0IIKaflKEZJWqRvEjXivijWZ4RgeR1IKeZVwq+cblwKwsgeWVgURgjxbTYJ+DoTtkHggVaIAzcgVUeMOQY7WaHSk6M56e8AGi8wg= 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 OSRPR01MB11697.jpnprd01.prod.outlook.com (2603:1096:604:230::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.27; Sun, 26 Nov 2023 23:19:17 +0000 Received: from TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::16b3:a84d:faa6:4846]) by TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::16b3:a84d:faa6:4846%6]) with mapi id 15.20.7025.022; Sun, 26 Nov 2023 23:19:15 +0000 Message-ID: <87plzww1ak.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v7 resend 3/5] ASoC: audio-graph-card2: add CPU:Codec = N:M support User-Agent: Wanderlust/2.15.9 Emacs/27.1 Mule/6.0 To: Pierre-Louis Bossart , Mark Brown , Bard Liao , bard.liao@intel.com, Conor Dooley , Krzysztof Kozlowski , Rob Herring , Jerome Brunet Cc: alsa-devel@alsa-project.org, devicetree@vger.kernel.org In-Reply-To: <87ttp8w1bk.wl-kuninori.morimoto.gx@renesas.com> References: <87ttp8w1bk.wl-kuninori.morimoto.gx@renesas.com> Date: Sun, 26 Nov 2023 23:19:15 +0000 X-ClientProxiedBy: TYCP286CA0153.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:383::15) To TYCPR01MB10914.jpnprd01.prod.outlook.com (2603:1096:400:3a9::11) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCPR01MB10914:EE_|OSRPR01MB11697:EE_ X-MS-Office365-Filtering-Correlation-Id: 4992634e-f001-43e3-5ad9-08dbeed61b85 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9YSRDArtrl6s4ITYVC2AV1sUiGMSQ5E03sZeOlD9TyUv79uYkgmo7sbyjZJ1o0RezPoHayPr4ROvnJwBD2PYaeF4cmg5Oq3dljNVzOYPa8ymcQFiK8bERqCoflQLbb/b2/OtQ/hHBPPlRCol4IpM7MDzzCTOgSDWNNcAQUrmZG2IW2DldgNA6SpV1+ORmDBPxosS6Sz5kweP2acEtNorwPiwLBJ/y42hsN8Nd/yMUvpuTATv52aM58YCV+lI8Eb1AjnmOyrUr+lrHt1Ve04K78bWUDxm5JThHP+UWQp1NgJAbMJdlzfSPlvAIiFGvCqbp6QZVr2apMhmn54KtDxGeaIqaF/hDZjesTUVwZxRNDnAQt6cfOEHdIxsc9TwIxGc4ylcJc5uimg5a9L+9I7L2pS7XjP1d6PlB+Uj1FmEntHP7I1Pm0/pV3FF33K47qim5W/2CCXGi6h7vwIxm8U5mgUXOoAu30Y0tbHpS258I840+dM0EIzWWoUcqhEOn9XBXoGrjz7y5bsf2yUzD3W/3hFtwmsstUhe1VVrnj2Gol480yw1Vb0y+jVdPjo8v68O+ofup+3c+ZmZTqpWomnrd7APakospU6wTc/49bZ21hKkqSz71J5QOZBdjocW5hQpe/bAOIh0LsUR5ALaaRphOg== 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:(13230031)(39860400002)(396003)(376002)(136003)(366004)(346002)(230922051799003)(1800799012)(186009)(451199024)(64100799003)(7416002)(4326008)(2906002)(8676002)(8936002)(41300700001)(26005)(66476007)(110136005)(316002)(66946007)(66556008)(6512007)(52116002)(5660300002)(2616005)(6506007)(83380400001)(86362001)(38100700002)(38350700005)(6486002)(478600001)(36756003)(2013699003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OwngzbvwZMalIi2XVD68SvQg59kQlwWb2jnp5StvnPfwJDiXB5fPtWBIXs4FJpkAVgzVNYyxfK+dtO2fHEMAh7fAQNGo3oBv8bPAn8nGWM2uYvclXNxXwhNA4ELzmOGpLqEW1iYh9VIyUw9gWsz1UFLNbMkiBRx/8AhXrVgw49tO/4BAnt0jGM+YFFoxq0hJuyzdVntrMUb8YV3OzRxDLODmRMkXLGXJNI9Jc+Ya4Y0ahLDkkGjN4Z/dc145/w4iGACqTzCoU1EXaHiwNT3iWZQ7a8rELOH9mJP93EsWpfpLlS4U4znwHcIKW5kjCerwbGJtPH+l+Y3f0KRwVggADkeNPfVDd0OX8O+fbc/7O3NGMa57Rt5M6/R8EU7OoO6+T4wVnPAAibmjjBCZksNNsuOSEMdNUdqMDnWwEImZ+JXyre688B81Q/jfHesuvwB2l/wk1OO7ULpiWZrAYXr0W7F/QwbLFMUm6HEyVcJoQOudC+a0KZGbx7PYU+Gt4dJITaZXJT1/w2qERgarhhfQUZTaURpgm050PhjGLfG0T83by//J3fJgNuBIb5ioADeQOrOgA2RYfS+G4zAM4xd1Y09p9PFfnQVAokCn1mKF7jtSABwgSNNxng2Dp4rUjAHW8edNF5yIBmNwUJLRQxvC9g6RPLaqwigKqCEy6J5H7E/y9oKtsta6kyJhiVBGnuiw1d8Q//Mnr53piF1TXoDKMdecV4tUWLvNv6U95LaWWEnJeGuVU8s4YAU/9d65FkonAVwaMJigfvebqoulJ1lwI7Zvg+x2ez21MS64ebeKac3TJhG3JlryB7vspzhSbiPeIUxo6VSAlVZ3YRCfEdRLiBsD6S8iys0A2YqZt5askt1c9i+PEsd46HqqxhaVCv+0V0q5Kvj4KFzIvl53sJKOc3GlJvhEANoyCVZchvYg1j6Tq8FmxDFVVu5btsgQ9WAcCbGmdU9FrdhzYdukc1sdpz4h7aNjRoU34t5RLnXPge+7x1wnER3NAI0hFuqJuZrVi/GzLc3+SUQtOMR/MNOsFEQBUlHDTwLSRCxiWKfQPD4Uc89fr2VUaApAqWLTMEoEWjMEvZxFjd/qD1U/IrW5Cmm5Hb8iV22zaHFv76Dr1X9AN3XNxfQfthL/BwtSab7Hpw+at9giAaHOeH0QBiJWggr5EXJjwruDTDz2ilh23YjWIV9jAE7RguJlTpSbwOfRX15KJh4C8Zxz+RgKh/UAglT/lWOBiIiPaDHZMXXcUzkkFajfBlTcPn4Oy34V/Kn1HoQ/Ky7HxZWsXnuWRdaQ+rb/hBydPqRXstb8tsnpDqB2VeKpS0dsABHzRoqeJASVlVdu7usIuxS5jZ0Pu4Wzt6SzxOlc5Jr3W7w0BF+swypVksNQMvUmR39XcZ0k2o452XV9SyZbCbNngy+myEFJRSnPRmUgsXDdQTGKCSHaNloRVTgcHAWk0J6pkERhOr4/GM2hX4gKzfr58FMT59GRjfo4URK+vqh/dIhsRMGpf5Tsagcrm14w6ieXxH8Nb9rxcTZDSCN9aMqIzpHDuAvzNgFgYgrLhBsgFF3504LtbIGDm8x/QWO63VJSH2tNVBj/cdVCqvuax6myJ5BB4HghyWoXtKOJp0q1pqRbMtIN0Ec= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4992634e-f001-43e3-5ad9-08dbeed61b85 X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Nov 2023 23:19:15.6457 (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: r+a+7a4lvikNSBhS3bYlUk7acGQxqpFatGXnx89JpwIXjdBAyKSL5fjN6NxAIYFrRjkiNMKobvbSCq7IEqpkPvkwKCqVkbn1myi1JbyAOe3exgstxIO4BIuyRzJi/z9c X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSRPR01MB11697 Now ASoC is supporting CPU:Codec = N:M support. This patch enables it on Audio Graph Card2. Signed-off-by: Kuninori Morimoto --- sound/soc/generic/audio-graph-card2.c | 225 +++++++++++++++++++++++--- 1 file changed, 202 insertions(+), 23 deletions(-) diff --git a/sound/soc/generic/audio-graph-card2.c b/sound/soc/generic/audio-graph-card2.c index c564f630abf6..d9e10308a508 100644 --- a/sound/soc/generic/audio-graph-card2.c +++ b/sound/soc/generic/audio-graph-card2.c @@ -504,40 +504,203 @@ static int __graph_parse_node(struct simple_util_priv *priv, return 0; } -static int graph_parse_node(struct simple_util_priv *priv, - enum graph_type gtype, - struct device_node *port, - struct link_info *li, int is_cpu) +static int graph_parse_node_multi_nm(struct snd_soc_dai_link *dai_link, + int *nm_idx, int cpu_idx, + struct device_node *mcpu_port) { - struct device_node *ep; - int ret = 0; + /* + * +---+ +---+ + * | X|<-@------->|x | + * | | | | + * cpu0 <--|A 1|<--------->|4 a|-> codec0 + * cpu1 <--|B 2|<-----+--->|5 b|-> codec1 + * cpu2 <--|C 3|<----/ +---+ + * +---+ + * + * multi { + * ports { + * port@0 { mcpu_top_ep {... = mcodec_ep; }; }; // (X) to pair + * port@1 { mcpu0_ep { ... = cpu0_ep; }; // (A) Multi Element + * mcpu0_ep_0 { ... = mcodec0_ep_0; }; }; // (1) connected Codec + * port@2 { mcpu1_ep { ... = cpu1_ep; }; // (B) Multi Element + * mcpu1_ep_0 { ... = mcodec1_ep_0; }; }; // (2) connected Codec + * port@3 { mcpu2_ep { ... = cpu2_ep; }; // (C) Multi Element + * mcpu2_ep_0 { ... = mcodec1_ep_1; }; }; // (3) connected Codec + * }; + * + * ports { + * port@0 { mcodec_top_ep {... = mcpu_ep; }; }; // (x) to pair + * port@1 { mcodec0_ep { ... = codec0_ep; }; // (a) Multi Element + * mcodec0_ep_0 { ... = mcpu0_ep_0; }; }; // (4) connected CPU + * port@2 { mcodec1_ep { ... = codec1_ep; }; // (b) Multi Element + * mcodec1_ep_0 { ... = mcpu1_ep_0; }; // (5) connected CPU + * mcodec1_ep_1 { ... = mcpu2_ep_0; }; }; // (5) connected CPU + * }; + * }; + */ + struct device_node *mcpu_ep = port_to_endpoint(mcpu_port); + struct device_node *mcpu_ep_n = mcpu_ep; + struct device_node *mcpu_port_top = of_get_next_child(of_get_parent(mcpu_port), NULL); + struct device_node *mcpu_ep_top = port_to_endpoint(mcpu_port_top); + struct device_node *mcodec_ep_top = of_graph_get_remote_endpoint(mcpu_ep_top); + struct device_node *mcodec_port_top = of_get_parent(mcodec_ep_top); + struct device_node *mcodec_ports = of_get_parent(mcodec_port_top); + int nm_max = max(dai_link->num_cpus, dai_link->num_codecs); + int ret = -EINVAL; - if (graph_lnk_is_multi(port)) { - int idx; + if (cpu_idx > dai_link->num_cpus) + goto mcpu_err; - of_node_get(port); + while (1) { + struct device_node *mcodec_ep_n; + struct device_node *mcodec_port_i; + struct device_node *mcodec_port; + int codec_idx; - for (idx = 0;; idx++) { - ep = graph_get_next_multi_ep(&port); - if (!ep) - break; + if (*nm_idx > nm_max) + break; - ret = __graph_parse_node(priv, gtype, ep, - li, is_cpu, idx); - of_node_put(ep); - if (ret < 0) + mcpu_ep_n = of_get_next_child(mcpu_port, mcpu_ep_n); + if (!mcpu_ep_n) { + ret = 0; + break; + } + + mcodec_ep_n = of_graph_get_remote_endpoint(mcpu_ep_n); + mcodec_port = of_get_parent(mcodec_ep_n); + + if (mcodec_ports != of_get_parent(mcodec_port)) + goto mcpu_err; + + codec_idx = 0; + mcodec_port_i = of_get_next_child(mcodec_ports, NULL); + while (1) { + if (codec_idx > dai_link->num_codecs) + goto mcodec_err; + + mcodec_port_i = of_get_next_child(mcodec_ports, mcodec_port_i); + + if (!mcodec_port_i) + goto mcodec_err; + + if (mcodec_port_i == mcodec_port) break; + + codec_idx++; } - } else { - /* Single CPU / Codec */ - ep = port_to_endpoint(port); - ret = __graph_parse_node(priv, gtype, ep, li, is_cpu, 0); + + dai_link->ch_maps[*nm_idx].cpu = cpu_idx; + dai_link->ch_maps[*nm_idx].codec = codec_idx; + + (*nm_idx)++; + + of_node_put(mcodec_port_i); +mcodec_err: + of_node_put(mcodec_port); + of_node_put(mcpu_ep_n); + of_node_put(mcodec_ep_n); + } +mcpu_err: + of_node_put(mcpu_ep); + of_node_put(mcpu_port_top); + of_node_put(mcpu_ep_top); + of_node_put(mcodec_ep_top); + of_node_put(mcodec_port_top); + of_node_put(mcodec_ports); + + return ret; +} + +static int graph_parse_node_multi(struct simple_util_priv *priv, + enum graph_type gtype, + struct device_node *port, + struct link_info *li, int is_cpu) +{ + struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); + struct device *dev = simple_priv_to_dev(priv); + struct device_node *ep; + int ret = -ENOMEM; + int nm_idx = 0; + int nm_max = max(dai_link->num_cpus, dai_link->num_codecs); + + /* + * create ch_maps if CPU:Codec = N:M + * DPCM is out of scope + */ + if (gtype != GRAPH_DPCM && !dai_link->ch_maps && + dai_link->num_cpus > 1 && dai_link->num_codecs > 1 && + dai_link->num_cpus != dai_link->num_codecs) { + + dai_link->ch_maps = devm_kcalloc(dev, nm_max, + sizeof(struct snd_soc_dai_link_ch_map), GFP_KERNEL); + if (!dai_link->ch_maps) + goto multi_err; + } + + for (int idx = 0;; idx++) { + /* + * multi { + * ports { + * port@0 { ... }; // to pair + * port@1 { mcpu1_ep { ... = cpu1_ep };}; // Multi Element + * port@2 { mcpu2_ep { ... = cpu2_ep };}; // Multi Element + * }; + * }; + * + * cpu { + * ports { + * port@0 { cpu1_ep { ... = mcpu1_ep };}; + * }; + * }; + */ + ep = graph_get_next_multi_ep(&port); + if (!ep) + break; + + ret = __graph_parse_node(priv, gtype, ep, li, is_cpu, idx); of_node_put(ep); + if (ret < 0) + goto multi_err; + + /* CPU:Codec = N:M */ + if (is_cpu && dai_link->ch_maps) { + ret = graph_parse_node_multi_nm(dai_link, &nm_idx, idx, port); + if (ret < 0) + goto multi_err; + } } + if (is_cpu && dai_link->ch_maps && (nm_idx != nm_max)) + ret = -EINVAL; + +multi_err: return ret; } +static int graph_parse_node_single(struct simple_util_priv *priv, + enum graph_type gtype, + struct device_node *port, + struct link_info *li, int is_cpu) +{ + struct device_node *ep = port_to_endpoint(port); + int ret = __graph_parse_node(priv, gtype, ep, li, is_cpu, 0); + + of_node_put(ep); + + return ret; +} + +static int graph_parse_node(struct simple_util_priv *priv, + enum graph_type gtype, + struct device_node *port, + struct link_info *li, int is_cpu) +{ + if (graph_lnk_is_multi(port)) + return graph_parse_node_multi(priv, gtype, port, li, is_cpu); + else + return graph_parse_node_single(priv, gtype, port, li, is_cpu); +} + static void graph_parse_daifmt(struct device_node *node, unsigned int *daifmt, unsigned int *bit_frame) { @@ -929,8 +1092,24 @@ static int graph_counter(struct device_node *lnk) * * ignore first lnk part */ - if (graph_lnk_is_multi(lnk)) - return of_graph_get_endpoint_count(of_get_parent(lnk)) - 1; + if (graph_lnk_is_multi(lnk)) { + struct device_node *ports = of_get_parent(lnk); + struct device_node *port = NULL; + int cnt = 0; + + /* + * CPU/Codec = N:M case has many endpoints. + * We can't use of_graph_get_endpoint_count() here + */ + while(1) { + port = of_get_next_child(ports, port); + if (!port) + break; + cnt++; + } + + return cnt - 1; + } /* * Single CPU / Codec */ From patchwork Sun Nov 26 23:19:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 747442 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=renesas.com header.i=@renesas.com header.b="l8I4UbzZ" Received: from JPN01-TYC-obe.outbound.protection.outlook.com (mail-tycjpn01on2101.outbound.protection.outlook.com [40.107.114.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB945111 for ; Sun, 26 Nov 2023 15:19:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MaF/IUBQM8E/gSckRDFZoehi85CZSw6Rs5eagzJkWFB3OTNPyiJ07xTj6HymMgM9jxVA35pUVpZX5HuaQ/7qiC2O4OXxN1Lk5R09aITbKU1lZjMZ/PO16Q9GszZBsjrHjUEmtixX02C2+UMXzztia/Iyc5nYY17ElRlTHBRWr4kd0nDwunAv5bVJDZk2oUC049lJwruHZQVZgromlPktLWEcfjeVxQegZTp2WENZr6IIaFLH7s7mu3HbBMHfB+NKrof8MoFIJaldbUKQQGxuiFBEdjqdQs0z+JeaDw1FOhjZc12tlvWjuzEwd38KrXcxvOdoP9vVuqqWwnBexzmNjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=ufCmAgxj4vWDs+5p6C0t9sXW43Dw7ngQaq3vAMp+Z9Y=; b=XEKd+qNmJvR4h5SmfO7js66rKHn/Rye+yRW+dsxuptx28s8EMPhtzuQg7tb+qOsBoKEhJCJ0qupeya0qciCdfTABmB3ZJEXhPdOMXiddTE23WV7/6vg0XKEMBxqR2POK1HoyggCxDQIOzFiBlgv01olmvRrYFj84ig1+hPSLxJYAPJLlqltdGFo3GpdPqChpW3ome+qmSr0cTm9TF1M1H8Pv30GZJPxhrpOzqih/qgJKp4OTcpA/GQUkIdyZ104cE/FhNa2zVL38NRdw8d1w8yZfdPS2+3ypxNKtv4/dDYIyGRWl97waRS5+XLGmorApzcbfmRIRmFRSMmLqy2c4jw== 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=ufCmAgxj4vWDs+5p6C0t9sXW43Dw7ngQaq3vAMp+Z9Y=; b=l8I4UbzZw4Ev1N9iuek9tkux3Z9gselzusZXbXBvO69RnB8b+8O/lJmmgDq22UsSqJh9joqN2mVfXamT8EVjYgUXR1dSn/KjH1+/4bYBrLJUdbFjBODZoH4DZs6ZTGauWtTOo7iGg0iDZLGiXoon81D0Q3haczmHGxu/ZIqcEnE= 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 OSRPR01MB11697.jpnprd01.prod.outlook.com (2603:1096:604:230::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.27; Sun, 26 Nov 2023 23:19:23 +0000 Received: from TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::16b3:a84d:faa6:4846]) by TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::16b3:a84d:faa6:4846%6]) with mapi id 15.20.7025.022; Sun, 26 Nov 2023 23:19:22 +0000 Message-ID: <87msv0w1ad.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v7 resend 5/5] ASoC: audio-graph-card2-custom-sample: add CPU/Codec = N:M sample User-Agent: Wanderlust/2.15.9 Emacs/27.1 Mule/6.0 To: Pierre-Louis Bossart , Mark Brown , Bard Liao , bard.liao@intel.com, Conor Dooley , Krzysztof Kozlowski , Rob Herring , Jerome Brunet Cc: alsa-devel@alsa-project.org, devicetree@vger.kernel.org In-Reply-To: <87ttp8w1bk.wl-kuninori.morimoto.gx@renesas.com> References: <87ttp8w1bk.wl-kuninori.morimoto.gx@renesas.com> Date: Sun, 26 Nov 2023 23:19:22 +0000 X-ClientProxiedBy: TYCP286CA0087.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:2b3::18) To TYCPR01MB10914.jpnprd01.prod.outlook.com (2603:1096:400:3a9::11) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCPR01MB10914:EE_|OSRPR01MB11697:EE_ X-MS-Office365-Filtering-Correlation-Id: 2c4c6824-aeb2-4548-4417-08dbeed61fe1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s69WLMWMi7bUqG/MphReyBBeEMLYAI7Dt8z+L9ZCZuzACZKBhHmQaG0Bt/xeorZJoVHACEUZ+l2uYLTsuqvzDbrEcrS3aknD1Lx3uCB7/J6VWnRB80TvLXA1QqiAgiPkvYisXz4J824rlP3hsbGasgB1l72nEWJa/nFnU2xvSHnnkP6Ca8r3DQ2hRm14yHuS9EGKHr9YeABRGJNHDtOHDj7kyyHOSB8fZO/rPeAse1cuWc6IKan3OnGwTTJbK7nk655n9lm8UipCczJfZRmkC36OOa7Ke9k9tOeh0JtPgqXUJmqEU2ZVxt1WQmOIsqi27WGLSfMvX7bAwMo3vDB1ksDx31mltJGNem/KCpyI4rBYt4zxjCS7EsaWTsrrIY7oFtf/P7rJF39ab+j8z70qocNacAqy4u1JYDeqfg1OHtbA4xyQN11MqXS/ia5eq8VkA30TJ0saFcY+2bmSYKaZxIARZc10v+b8QM1E5ZtmKFqwHKszrbbT38DhdNCdqo4w3UYWGIHyeuoXv2COWTbigJqC5q6ZqpBqzijBGkDAjQr5/mrlH0mWDB1bTKA5do42YPxjxqtahlLoPGACtiuWEjHzHk2NhzYgZkem/DeugvWDazx/2FrlR67zcNA1bFUQaq0wv01AyucRVRzE7ul1+Q== 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:(13230031)(39860400002)(396003)(376002)(136003)(366004)(346002)(230922051799003)(1800799012)(186009)(451199024)(64100799003)(7416002)(4326008)(2906002)(8676002)(8936002)(41300700001)(26005)(66476007)(110136005)(316002)(66946007)(66556008)(6512007)(52116002)(5660300002)(2616005)(6506007)(83380400001)(86362001)(38100700002)(38350700005)(6486002)(478600001)(36756003)(2013699003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GuiYLlYPeCMkRVvV89pzi45mN3SaDNMIy+ToBL5lt4Dpc1tqFsAZKELeUzyLC6LHErvDktkdw33NXs/kFhDxub4+Y/90pnHDPmgDgkbZCtD9dH/2LQGDYidH/ayrygolyBCRYYbxuPZQCYJE2ppnUAfNt67ekektNpYEor+36uI1Lud0Lv3GIE727C6G+HoX/yTlVc5R3VHyfyKFb7boTvZkrR7S+2UfkH9C90E7SLEtYNixHSp3Z2SqHYsfYTR7klMxMtFyyEkO8sar+pPOLHxmuwQkqvxohCzDo8Mey89D1MCb5CXKEWcH4OnQMluronDt3/DwvyV6r0sELs9ElfvZY/jVph7qmdOPo+DR7vYDmcFDR8vkVME/sIjFVRgo3ctkkBqZAg3DeaiRUAUuZiVxtd4pU9mgDXY6UljaAEUIM10AMgAA1tJ9lxGZ91/0Oc445bL4nKAgTIBuUoCcipI8B4tnYePPLfrJgIYU0TUVXtHQdm1GqZmhFj0ukITCO4ukJsUc/LPPGWCJKSzeZV3g4wPOMjfE1reYNLyQ2oqH0+75PvCs2Juw1o+nyAogvrhL0UyhiEfipLu4UiLb9qcSGAKJ5drXIbDBz1Z3BomSq99+JZEgftgMI2u65Xr5dd+5vaZ8riEzlgLzEK/yeqQx4xtRwyypKxn4nBAyN4Svld0Dhv8rjHk3r8TfWpY3BiVX4JpsVn1lTpGd+gAfdOnAWDUVcPZlib8I0HrxZGUXs7vC5VWnJWThvy3kcdp3umlOngmyCJzCEtYFUTUfpRqqTCeMScGDkQ59skPWxN6co4RjkFAn5WlTMqLSRqoLXTvMeSCWIat9mibV5ROCoWonKLme7YUngIMBdHo9LBNylPXe2AhHhFVCvHxD2ckJugVy1vjF0oBAjlq4LKAZVaRWG7XP6BP9a4mR4cyyDjdwPo1q+0kZwzYYP5Tbvh/rw+No5Mfv9yMrO+g04F8MVFJFkjZHG2uVSo+FJq8LTHdxzy8zdQgvh3I/Ti5acavyC2rE9JlePstgNkR1rqBtEEowM612d8HlIMX6FrryB4vGCYIHfv3pH4BNPZ4XWeimY2dCmJsAtc3AgbNAKlUd0Q6YLHJhTvTZAlw+2MdClCkxoPvA5AHcaCs7LODbRPRYqZo9Rrx+npnyD+YLXtW+gHe4KGgBCHNEOkcRJS73rn0fmejEUxNOBep6S11PMVYUqtvmGxpmJxHtGeV+bnmJ0Sz4GSb2pQ4DJohTEl/uHgNDrkzaCy1I81y7J5QgeNhUp19wjkCcQY2AR9SSspCdBxaFGKWbKxxx2R/9EXI000GvFXoxUEuDhbkPnsNjJbVA2ohhwV9dQKUbpW9ZzqSKizknq4VN+cf8SGrsInNHtABHaLUUqZg6/8a7yZL6MXdT15zfh97tjAnuGQ8B1psMLDlSkDGOG8kYHAWfARs6R6snaZ/NhkjovSvoA/+QGOzygNmn38bV8qyQ/EqSgpfiUQd4VwsSjI4MJCcxqjHSSVNBEerQ2xj7pwKcYr6+1/hutZIYfqQDQ8oES9FXwtWaeTyTWO99BpUL95kU+hl7FHyMWCP8UX+PIIje6tmFHynQG5B9tLsvS8Bx08ys3LaxlKZhF3JhFt27EB98XWKBQZM= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2c4c6824-aeb2-4548-4417-08dbeed61fe1 X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Nov 2023 23:19:22.9187 (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: 4XTuMYM8+uXMSx2Dkhda1uaFr13/jWd9RzbqRGVOM/+BllOqY8LslVzDyTq7nAc/15syVbeyTkgQ7nHqH3tBN3HmV10fHU3ok1MiQiLUFr1weMeQlKJQOLxyc6F2kJqP X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSRPR01MB11697 Now ASoC is supporting CPU/Codec = N:M connection. This patch adds its sample settings. But One note here is that it has many type of samples, it reached to maximum of sound minor number. Therefore, new sample is disabled so far. If you want to try it, you need to disable some other one instead. Signed-off-by: Kuninori Morimoto --- .../audio-graph-card2-custom-sample.dtsi | 199 ++++++++++++++++++ 1 file changed, 199 insertions(+) diff --git a/sound/soc/generic/audio-graph-card2-custom-sample.dtsi b/sound/soc/generic/audio-graph-card2-custom-sample.dtsi index 7e2cd9cc3fa8..9efd31206c9b 100644 --- a/sound/soc/generic/audio-graph-card2-custom-sample.dtsi +++ b/sound/soc/generic/audio-graph-card2-custom-sample.dtsi @@ -64,6 +64,26 @@ / { * cpu2 <--| | | |-> codec2 * +-+ +-+ * + * [Multi-CPU/Codec-1] + * + * +-+ +-+ + * | |<-@--------->| | + * | | | | + * cpu8 <--| |<----------->| |-> codec14 + * cpu9 <--| |<---+------->| |-> codec15 + * +-+ \------>| |-> codec16 + * +-+ + * + * [Multi-CPU/Codec-2] + * + * +-+ +-+ + * | |<-@--------->| | + * | | | | + * cpu10 <-| |<----------->| |-> codec17 + * cpu11 <-| |<-----+----->| |-> codec18 + * cpu12 <-| |<----/ +-+ + * +-+ + * * [DPCM] * * CPU3/CPU4 are converting rate to 44100 @@ -156,6 +176,26 @@ &sm0 */ &mcpu0 + /* + * [Multi-CPU/Codec-1]: cpu side only + * cpu8/cpu9/codec14/codec15/codec16 + * + * Because it will reach to the maximum of sound minor number, + * disable it so far. + * If you want to try it, please disable some other one instead. + */ + //&mcpu1 + + /* + * [Multi-CPU/Codec-2]: cpu side only + * cpu10/cpu11/cpu12/codec17/codec18 + * + * Because it will reach to the maximum of sound minor number, + * disable it so far. + * If you want to try it, please disable some other one instead. + */ + //&mcpu2 + /* * [DPCM]: both FE / BE * cpu3/cpu4/codec3 @@ -295,6 +335,150 @@ ports@5 { port@1 { reg = <1>; smcodec1_ep: endpoint { remote-endpoint = <&codec12_ep>; };};/* (A) Multi Element */ port@2 { reg = <2>; smcodec2_ep: endpoint { remote-endpoint = <&codec13_ep>; };};/* (B) Multi Element */ }; + + /* + * [Multi-CPU-1] + * + * +---+ +---+ + * | X|<-@------->|x | + * | | | | + * cpu8 <--|A 1|<--------->|3 a|-> codec14 + * cpu9 <--|B 2|<---+----->|4 b|-> codec15 + * +---+ \---->|5 c|-> codec16 + * +---+ + */ + ports@6 { + reg = <6>; + #address-cells = <1>; + #size-cells = <0>; + mcpu1: port@0 { reg = <0>; mcpu10_ep: endpoint { remote-endpoint = <&mcodec10_ep>; };}; /* (X) to pair */ + port@1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + mcpu11_ep: endpoint@0 { reg = <0>; remote-endpoint = <&cpu8_ep>; }; /* (A) Multi Element */ + mcpu11_ep_0: endpoint@1 { reg = <1>; remote-endpoint = <&mcodec11_ep_0>; }; /* (1) connected Codec */ + }; + port@2 { + #address-cells = <1>; + #size-cells = <0>; + reg = <2>; + mcpu12_ep: endpoint@0 { reg = <0>; remote-endpoint = <&cpu9_ep>; }; /* (B) Multi Element */ + mcpu12_ep_0: endpoint@1 { reg = <1>; remote-endpoint = <&mcodec12_ep_0>; }; /* (2) connected Codec */ + mcpu12_ep_1: endpoint@2 { reg = <2>; remote-endpoint = <&mcodec13_ep_0>; }; /* (2) connected Codec */ + }; + }; + + /* + * [Multi-Codec-1] + * + * +---+ +---+ + * | X|<-@------->|x | + * | | | | + * cpu8 <--|A 1|<--------->|3 a|-> codec14 + * cpu9 <--|B 2|<---+----->|4 b|-> codec15 + * +---+ \---->|5 c|-> codec16 + * +---+ + */ + ports@7 { + reg = <7>; + #address-cells = <1>; + #size-cells = <0>; + port@0 { reg = <0>; mcodec10_ep: endpoint { remote-endpoint = <&mcpu10_ep>; };}; /* (x) to pair */ + port@1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + mcodec11_ep: endpoint@0 { reg = <0>; remote-endpoint = <&codec14_ep>; }; /* (a) Multi Element */ + mcodec11_ep_0: endpoint@1 { reg = <1>; remote-endpoint = <&mcpu11_ep_0>; }; /* (3) connected CPU */ + }; + port@2 { + #address-cells = <1>; + #size-cells = <0>; + reg = <2>; + mcodec12_ep: endpoint@0 { reg = <0>; remote-endpoint = <&codec15_ep>; }; /* (b) Multi Element */ + mcodec12_ep_0: endpoint@1 { reg = <1>; remote-endpoint = <&mcpu12_ep_0>; }; /* (4) connected CPU */ + }; + port@3 { + #address-cells = <1>; + #size-cells = <0>; + reg = <3>; + mcodec13_ep: endpoint@0 { reg = <0>; remote-endpoint = <&codec16_ep>; }; /* (c) Multi Element */ + mcodec13_ep_0: endpoint@1 { reg = <1>; remote-endpoint = <&mcpu12_ep_1>; }; /* (5) connected CPU */ + }; + }; + + /* + * [Multi-CPU-2] + * + * +---+ +---+ + * | X|<-@------->|x | + * | | | | + * cpu10 <-|A 1|<--------->|4 a|-> codec17 + * cpu11 <-|B 2|<-----+--->|5 b|-> codec18 + * cpu12 <-|C 3|<----/ +---+ + * +---+ + */ + ports@8 { + reg = <8>; + #address-cells = <1>; + #size-cells = <0>; + mcpu2: port@0 { reg = <0>; mcpu20_ep: endpoint { remote-endpoint = <&mcodec20_ep>; };}; /* (X) to pair */ + port@1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + mcpu21_ep: endpoint@0 { reg = <0>; remote-endpoint = <&cpu10_ep>; }; /* (A) Multi Element */ + mcpu21_ep_0: endpoint@1 { reg = <1>; remote-endpoint = <&mcodec21_ep_0>; }; /* (1) connected Codec */ + }; + port@2 { + #address-cells = <1>; + #size-cells = <0>; + reg = <2>; + mcpu22_ep: endpoint@0 { reg = <0>; remote-endpoint = <&cpu11_ep>; }; /* (B) Multi Element */ + mcpu22_ep_0: endpoint@1 { reg = <1>; remote-endpoint = <&mcodec22_ep_0>; }; /* (2) connected Codec */ + }; + port@3 { + #address-cells = <1>; + #size-cells = <0>; + reg = <3>; + mcpu23_ep: endpoint@0 { reg = <0>; remote-endpoint = <&cpu12_ep>; }; /* (C) Multi Element */ + mcpu23_ep_0: endpoint@1 { reg = <1>; remote-endpoint = <&mcodec22_ep_1>; }; /* (3) connected Codec */ + }; + }; + + /* + * [Multi-Codec-2] + * + * +---+ +---+ + * | X|<-@------->|x | + * | | | | + * cpu10 <-|A 1|<--------->|4 a|-> codec17 + * cpu11 <-|B 2|<-----+--->|5 b|-> codec18 + * cpu12 <-|C 3|<----/ +---+ + * +---+ + */ + ports@9 { + reg = <9>; + #address-cells = <1>; + #size-cells = <0>; + port@0 { reg = <0>; mcodec20_ep: endpoint { remote-endpoint = <&mcpu20_ep>; };}; /* (x) to pair */ + port@1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + mcodec21_ep: endpoint@0 { reg = <0>; remote-endpoint = <&codec17_ep>; }; /* (a) Multi Element */ + mcodec21_ep_0: endpoint@1 { reg = <1>; remote-endpoint = <&mcpu21_ep_0>; }; /* (4) connected CPU */ + }; + port@2 { + #address-cells = <1>; + #size-cells = <0>; + reg = <2>; + mcodec22_ep: endpoint@0 { reg = <0>; remote-endpoint = <&codec18_ep>; }; /* (b) Multi Element */ + mcodec22_ep_0: endpoint@1 { reg = <1>; remote-endpoint = <&mcpu22_ep_0>; }; /* (5) connected CPU */ + mcodec22_ep_1: endpoint@2 { reg = <2>; remote-endpoint = <&mcpu23_ep_0>; }; /* (5) connected CPU */ + }; + }; }; dpcm { @@ -440,6 +624,14 @@ ports { /* [Semi-Multi] */ sm0: port@7 { reg = <7>; cpu7_ep: endpoint { remote-endpoint = <&smcodec0_ep>; }; }; + + /* [Multi-CPU-1] */ + port@8 { reg = <8>; cpu8_ep: endpoint { remote-endpoint = <&mcpu11_ep>; }; }; + port@9 { reg = <9>; cpu9_ep: endpoint { remote-endpoint = <&mcpu12_ep>; }; }; + /* [Multi-CPU-2] */ + port@a { reg = <10>; cpu10_ep: endpoint { remote-endpoint = <&mcpu21_ep>; }; }; + port@b { reg = <11>; cpu11_ep: endpoint { remote-endpoint = <&mcpu22_ep>; }; }; + port@c { reg = <12>; cpu12_ep: endpoint { remote-endpoint = <&mcpu23_ep>; }; }; }; }; @@ -498,6 +690,13 @@ port@3 { port@c { reg = <12>; codec12_ep: endpoint { remote-endpoint = <&smcodec1_ep>; }; }; port@d { reg = <13>; codec13_ep: endpoint { remote-endpoint = <&smcodec2_ep>; }; }; + /* [Multi-Codec-1] */ + port@e { reg = <14>; codec14_ep: endpoint { remote-endpoint = <&mcodec11_ep>; }; }; + port@f { reg = <15>; codec15_ep: endpoint { remote-endpoint = <&mcodec12_ep>; }; }; + port@10 { reg = <16>; codec16_ep: endpoint { remote-endpoint = <&mcodec13_ep>; }; }; + /* [Multi-Codec-2] */ + port@11 { reg = <17>; codec17_ep: endpoint { remote-endpoint = <&mcodec21_ep>; }; }; + port@12 { reg = <18>; codec18_ep: endpoint { remote-endpoint = <&mcodec22_ep>; }; }; }; }; };