Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: audio-graph-scu-card: remove audio-graph-scu-card

It is already merged into audio-graph-card.
audio-graph-scu-card is no longer needed.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Kuninori Morimoto and committed by
Mark Brown
61c263ac e4f4fdfc

-512
-9
sound/soc/generic/Kconfig
··· 24 24 This option enables generic simple sound card support 25 25 with OF-graph DT bindings. 26 26 It also support DPCM of multi CPU single Codec ststem. 27 - 28 - config SND_AUDIO_GRAPH_SCU_CARD 29 - tristate "ASoC Audio Graph SCU sound card support" 30 - depends on OF 31 - select SND_SIMPLE_CARD_UTILS 32 - help 33 - This option enables generic simple SCU sound card support 34 - with OF-graph DT bindings. 35 - It supports DPCM of multi CPU single Codec ststem.
-2
sound/soc/generic/Makefile
··· 3 3 snd-soc-simple-card-objs := simple-card.o 4 4 snd-soc-simple-scu-card-objs := simple-scu-card.o 5 5 snd-soc-audio-graph-card-objs := audio-graph-card.o 6 - snd-soc-audio-graph-scu-card-objs := audio-graph-scu-card.o 7 6 8 7 obj-$(CONFIG_SND_SIMPLE_CARD_UTILS) += snd-soc-simple-card-utils.o 9 8 obj-$(CONFIG_SND_SIMPLE_CARD) += snd-soc-simple-card.o 10 9 obj-$(CONFIG_SND_SIMPLE_SCU_CARD) += snd-soc-simple-scu-card.o 11 10 obj-$(CONFIG_SND_AUDIO_GRAPH_CARD) += snd-soc-audio-graph-card.o 12 - obj-$(CONFIG_SND_AUDIO_GRAPH_SCU_CARD) += snd-soc-audio-graph-scu-card.o
-501
sound/soc/generic/audio-graph-scu-card.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - // 3 - // ASoC audio graph SCU sound card support 4 - // 5 - // Copyright (C) 2017 Renesas Solutions Corp. 6 - // Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> 7 - // 8 - // based on 9 - // ${LINUX}/sound/soc/generic/simple-scu-card.c 10 - // ${LINUX}/sound/soc/generic/audio-graph-card.c 11 - 12 - #include <linux/clk.h> 13 - #include <linux/device.h> 14 - #include <linux/gpio.h> 15 - #include <linux/module.h> 16 - #include <linux/of.h> 17 - #include <linux/of_device.h> 18 - #include <linux/of_gpio.h> 19 - #include <linux/of_graph.h> 20 - #include <linux/platform_device.h> 21 - #include <linux/string.h> 22 - #include <sound/jack.h> 23 - #include <sound/simple_card_utils.h> 24 - 25 - struct graph_card_data { 26 - struct snd_soc_card snd_card; 27 - struct graph_dai_props { 28 - struct asoc_simple_dai *cpu_dai; 29 - struct asoc_simple_dai *codec_dai; 30 - struct snd_soc_dai_link_component codecs; 31 - struct snd_soc_dai_link_component platform; 32 - struct asoc_simple_card_data adata; 33 - struct snd_soc_codec_conf *codec_conf; 34 - } *dai_props; 35 - struct snd_soc_dai_link *dai_link; 36 - struct asoc_simple_dai *dais; 37 - struct asoc_simple_card_data adata; 38 - struct snd_soc_codec_conf *codec_conf; 39 - }; 40 - 41 - #define graph_priv_to_card(priv) (&(priv)->snd_card) 42 - #define graph_priv_to_props(priv, i) ((priv)->dai_props + (i)) 43 - #define graph_priv_to_dev(priv) (graph_priv_to_card(priv)->dev) 44 - #define graph_priv_to_link(priv, i) (graph_priv_to_card(priv)->dai_link + (i)) 45 - 46 - #define PREFIX "audio-graph-card," 47 - 48 - static int asoc_graph_card_startup(struct snd_pcm_substream *substream) 49 - { 50 - struct snd_soc_pcm_runtime *rtd = substream->private_data; 51 - struct graph_card_data *priv = snd_soc_card_get_drvdata(rtd->card); 52 - struct graph_dai_props *dai_props = graph_priv_to_props(priv, rtd->num); 53 - int ret = 0; 54 - 55 - ret = asoc_simple_card_clk_enable(dai_props->cpu_dai); 56 - if (ret) 57 - return ret; 58 - 59 - ret = asoc_simple_card_clk_enable(dai_props->codec_dai); 60 - if (ret) 61 - asoc_simple_card_clk_disable(dai_props->cpu_dai); 62 - 63 - return ret; 64 - } 65 - 66 - static void asoc_graph_card_shutdown(struct snd_pcm_substream *substream) 67 - { 68 - struct snd_soc_pcm_runtime *rtd = substream->private_data; 69 - struct graph_card_data *priv = snd_soc_card_get_drvdata(rtd->card); 70 - struct graph_dai_props *dai_props = graph_priv_to_props(priv, rtd->num); 71 - 72 - asoc_simple_card_clk_disable(dai_props->cpu_dai); 73 - 74 - asoc_simple_card_clk_disable(dai_props->codec_dai); 75 - } 76 - 77 - static const struct snd_soc_ops asoc_graph_card_ops = { 78 - .startup = asoc_graph_card_startup, 79 - .shutdown = asoc_graph_card_shutdown, 80 - }; 81 - 82 - static int asoc_graph_card_dai_init(struct snd_soc_pcm_runtime *rtd) 83 - { 84 - struct graph_card_data *priv = snd_soc_card_get_drvdata(rtd->card); 85 - struct graph_dai_props *dai_props = graph_priv_to_props(priv, rtd->num); 86 - int ret = 0; 87 - 88 - ret = asoc_simple_card_init_dai(rtd->codec_dai, 89 - dai_props->codec_dai); 90 - if (ret < 0) 91 - return ret; 92 - 93 - ret = asoc_simple_card_init_dai(rtd->cpu_dai, 94 - dai_props->cpu_dai); 95 - if (ret < 0) 96 - return ret; 97 - 98 - return 0; 99 - } 100 - 101 - static int asoc_graph_card_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, 102 - struct snd_pcm_hw_params *params) 103 - { 104 - struct graph_card_data *priv = snd_soc_card_get_drvdata(rtd->card); 105 - struct graph_dai_props *dai_props = graph_priv_to_props(priv, rtd->num); 106 - 107 - asoc_simple_card_convert_fixup(&dai_props->adata, params); 108 - 109 - /* overwrite by top level adata if exist */ 110 - asoc_simple_card_convert_fixup(&priv->adata, params); 111 - 112 - return 0; 113 - } 114 - 115 - static int asoc_graph_card_dai_link_of(struct device_node *cpu_ep, 116 - struct device_node *codec_ep, 117 - struct graph_card_data *priv, 118 - int *dai_idx, int link_idx, 119 - int *conf_idx, int is_fe) 120 - { 121 - struct device *dev = graph_priv_to_dev(priv); 122 - struct snd_soc_dai_link *dai_link = graph_priv_to_link(priv, link_idx); 123 - struct graph_dai_props *dai_props = graph_priv_to_props(priv, link_idx); 124 - struct snd_soc_card *card = graph_priv_to_card(priv); 125 - struct device_node *ep = is_fe ? cpu_ep : codec_ep; 126 - struct device_node *node = of_graph_get_port_parent(ep); 127 - struct asoc_simple_dai *dai; 128 - int ret; 129 - 130 - if (is_fe) { 131 - struct snd_soc_dai_link_component *codecs; 132 - 133 - /* BE is dummy */ 134 - codecs = dai_link->codecs; 135 - codecs->of_node = NULL; 136 - codecs->dai_name = "snd-soc-dummy-dai"; 137 - codecs->name = "snd-soc-dummy"; 138 - 139 - /* FE settings */ 140 - dai_link->dynamic = 1; 141 - dai_link->dpcm_merged_format = 1; 142 - 143 - dai = 144 - dai_props->cpu_dai = &priv->dais[(*dai_idx)++]; 145 - 146 - ret = asoc_simple_card_parse_graph_cpu(ep, dai_link); 147 - if (ret) 148 - return ret; 149 - 150 - ret = asoc_simple_card_parse_clk_cpu(dev, ep, dai_link, dai); 151 - if (ret < 0) 152 - return ret; 153 - 154 - ret = asoc_simple_card_set_dailink_name(dev, dai_link, 155 - "fe.%s", 156 - dai_link->cpu_dai_name); 157 - if (ret < 0) 158 - return ret; 159 - 160 - /* card->num_links includes Codec */ 161 - asoc_simple_card_canonicalize_cpu(dai_link, 162 - of_graph_get_endpoint_count(dai_link->cpu_of_node) == 1); 163 - } else { 164 - struct snd_soc_codec_conf *cconf; 165 - 166 - /* FE is dummy */ 167 - dai_link->cpu_of_node = NULL; 168 - dai_link->cpu_dai_name = "snd-soc-dummy-dai"; 169 - dai_link->cpu_name = "snd-soc-dummy"; 170 - 171 - /* BE settings */ 172 - dai_link->no_pcm = 1; 173 - dai_link->be_hw_params_fixup = asoc_graph_card_be_hw_params_fixup; 174 - 175 - dai = 176 - dai_props->codec_dai = &priv->dais[(*dai_idx)++]; 177 - 178 - cconf = 179 - dai_props->codec_conf = &priv->codec_conf[(*conf_idx)++]; 180 - 181 - ret = asoc_simple_card_parse_graph_codec(ep, dai_link); 182 - if (ret < 0) 183 - return ret; 184 - 185 - ret = asoc_simple_card_parse_clk_codec(dev, ep, dai_link, dai); 186 - if (ret < 0) 187 - return ret; 188 - 189 - ret = asoc_simple_card_set_dailink_name(dev, dai_link, 190 - "be.%s", 191 - dai_link->codecs->dai_name); 192 - if (ret < 0) 193 - return ret; 194 - 195 - /* check "prefix" from top node */ 196 - snd_soc_of_parse_audio_prefix(card, cconf, 197 - dai_link->codecs->of_node, 198 - "prefix"); 199 - /* check "prefix" from each node if top doesn't have */ 200 - if (!cconf->of_node) 201 - snd_soc_of_parse_node_prefix(node, cconf, 202 - dai_link->codecs->of_node, 203 - PREFIX "prefix"); 204 - } 205 - 206 - asoc_simple_card_parse_convert(dev, node, PREFIX, &dai_props->adata); 207 - 208 - ret = asoc_simple_card_of_parse_tdm(ep, dai); 209 - if (ret) 210 - return ret; 211 - 212 - ret = asoc_simple_card_canonicalize_dailink(dai_link); 213 - if (ret < 0) 214 - return ret; 215 - 216 - ret = asoc_simple_card_parse_daifmt(dev, cpu_ep, codec_ep, 217 - NULL, &dai_link->dai_fmt); 218 - if (ret < 0) 219 - return ret; 220 - 221 - dai_link->dpcm_playback = 1; 222 - dai_link->dpcm_capture = 1; 223 - dai_link->ops = &asoc_graph_card_ops; 224 - dai_link->init = asoc_graph_card_dai_init; 225 - 226 - return 0; 227 - } 228 - 229 - static int asoc_graph_card_parse_of(struct graph_card_data *priv) 230 - { 231 - struct of_phandle_iterator it; 232 - struct device *dev = graph_priv_to_dev(priv); 233 - struct snd_soc_card *card = graph_priv_to_card(priv); 234 - struct device_node *node = dev->of_node; 235 - struct device_node *cpu_port; 236 - struct device_node *cpu_ep; 237 - struct device_node *codec_ep; 238 - struct device_node *codec_port; 239 - struct device_node *codec_port_old; 240 - int dai_idx, link_idx, conf_idx, ret; 241 - int rc, codec; 242 - 243 - if (!node) 244 - return -EINVAL; 245 - 246 - /* 247 - * we need to consider "widgets", "mclk-fs" around here 248 - * see simple-card 249 - */ 250 - 251 - ret = asoc_simple_card_of_parse_routing(card, NULL); 252 - if (ret < 0) 253 - return ret; 254 - 255 - asoc_simple_card_parse_convert(dev, node, NULL, &priv->adata); 256 - 257 - /* 258 - * it supports multi CPU, single CODEC only here 259 - * see asoc_graph_get_dais_count 260 - */ 261 - 262 - link_idx = 0; 263 - dai_idx = 0; 264 - conf_idx = 0; 265 - codec_port_old = NULL; 266 - for (codec = 0; codec < 2; codec++) { 267 - /* 268 - * To listup valid sounds continuously, 269 - * detect all CPU-dummy first, and 270 - * detect all dummy-Codec second 271 - */ 272 - of_for_each_phandle(&it, rc, node, "dais", NULL, 0) { 273 - cpu_port = it.node; 274 - cpu_ep = of_get_next_child(cpu_port, NULL); 275 - codec_ep = of_graph_get_remote_endpoint(cpu_ep); 276 - codec_port = of_graph_get_port_parent(codec_ep); 277 - 278 - of_node_put(cpu_ep); 279 - of_node_put(codec_ep); 280 - of_node_put(cpu_port); 281 - of_node_put(codec_port); 282 - it.node = NULL; 283 - 284 - if (codec) { 285 - if (codec_port_old == codec_port) 286 - continue; 287 - 288 - codec_port_old = codec_port; 289 - } 290 - 291 - ret = asoc_graph_card_dai_link_of(cpu_ep, codec_ep, 292 - priv, &dai_idx, 293 - link_idx++, &conf_idx, 294 - !codec); 295 - if (ret < 0) 296 - goto parse_of_err; 297 - } 298 - } 299 - 300 - ret = asoc_simple_card_parse_card_name(card, NULL); 301 - if (ret) 302 - goto parse_of_err; 303 - 304 - if ((card->num_links != link_idx) || 305 - (card->num_configs != conf_idx)) { 306 - dev_err(dev, "dai_link or codec_config wrong (%d/%d, %d/%d)\n", 307 - card->num_links, link_idx, card->num_configs, conf_idx); 308 - ret = -EINVAL; 309 - goto parse_of_err; 310 - } 311 - 312 - ret = 0; 313 - 314 - parse_of_err: 315 - return ret; 316 - } 317 - 318 - static void asoc_graph_get_dais_count(struct device *dev, 319 - int *link_num, 320 - int *dais_num, 321 - int *ccnf_num) 322 - { 323 - struct of_phandle_iterator it; 324 - struct device_node *node = dev->of_node; 325 - struct device_node *cpu_port; 326 - struct device_node *cpu_ep; 327 - struct device_node *codec_ep; 328 - struct device_node *codec_port; 329 - struct device_node *codec_port_old; 330 - struct device_node *codec_port_old2; 331 - int rc; 332 - 333 - /* 334 - * link_num : number of links. 335 - * CPU-Codec / CPU-dummy / dummy-Codec 336 - * dais_num : number of DAIs 337 - * ccnf_num : number of codec_conf 338 - * same number for dummy-Codec 339 - * 340 - * ex1) 341 - * CPU0 --- Codec0 link : 5 342 - * CPU1 --- Codec1 dais : 7 343 - * CPU2 -/ ccnf : 1 344 - * CPU3 --- Codec2 345 - * 346 - * => 5 links = 2xCPU-Codec + 2xCPU-dummy + 1xdummy-Codec 347 - * => 7 DAIs = 4xCPU + 3xCodec 348 - * => 1 ccnf = 1xdummy-Codec 349 - * 350 - * ex2) 351 - * CPU0 --- Codec0 link : 5 352 - * CPU1 --- Codec1 dais : 6 353 - * CPU2 -/ ccnf : 1 354 - * CPU3 -/ 355 - * 356 - * => 5 links = 1xCPU-Codec + 3xCPU-dummy + 1xdummy-Codec 357 - * => 6 DAIs = 4xCPU + 2xCodec 358 - * => 1 ccnf = 1xdummy-Codec 359 - * 360 - * ex3) 361 - * CPU0 --- Codec0 link : 6 362 - * CPU1 -/ dais : 6 363 - * CPU2 --- Codec1 ccnf : 2 364 - * CPU3 -/ 365 - * 366 - * => 6 links = 0xCPU-Codec + 4xCPU-dummy + 2xdummy-Codec 367 - * => 6 DAIs = 4xCPU + 2xCodec 368 - * => 2 ccnf = 2xdummy-Codec 369 - */ 370 - codec_port_old = NULL; 371 - codec_port_old2 = NULL; 372 - of_for_each_phandle(&it, rc, node, "dais", NULL, 0) { 373 - cpu_port = it.node; 374 - cpu_ep = of_get_next_child(cpu_port, NULL); 375 - codec_ep = of_graph_get_remote_endpoint(cpu_ep); 376 - codec_port = of_graph_get_port_parent(codec_ep); 377 - 378 - of_node_put(cpu_ep); 379 - of_node_put(codec_ep); 380 - of_node_put(codec_port); 381 - 382 - (*link_num)++; 383 - (*dais_num)++; 384 - 385 - if (codec_port_old == codec_port) { 386 - if (codec_port_old2 != codec_port_old) { 387 - (*link_num)++; 388 - (*ccnf_num)++; 389 - } 390 - 391 - codec_port_old2 = codec_port_old; 392 - continue; 393 - } 394 - 395 - (*dais_num)++; 396 - codec_port_old = codec_port; 397 - } 398 - } 399 - 400 - static int asoc_graph_card_probe(struct platform_device *pdev) 401 - { 402 - struct graph_card_data *priv; 403 - struct snd_soc_dai_link *dai_link; 404 - struct graph_dai_props *dai_props; 405 - struct asoc_simple_dai *dais; 406 - struct device *dev = &pdev->dev; 407 - struct snd_soc_card *card; 408 - struct snd_soc_codec_conf *cconf; 409 - int lnum = 0, dnum = 0, cnum = 0; 410 - int ret, i; 411 - 412 - /* Allocate the private data and the DAI link array */ 413 - priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 414 - if (!priv) 415 - return -ENOMEM; 416 - 417 - asoc_graph_get_dais_count(dev, &lnum, &dnum, &cnum); 418 - if (!lnum || !dnum) 419 - return -EINVAL; 420 - 421 - dai_props = devm_kcalloc(dev, lnum, sizeof(*dai_props), GFP_KERNEL); 422 - dai_link = devm_kcalloc(dev, lnum, sizeof(*dai_link), GFP_KERNEL); 423 - dais = devm_kcalloc(dev, dnum, sizeof(*dais), GFP_KERNEL); 424 - cconf = devm_kcalloc(dev, cnum, sizeof(*cconf), GFP_KERNEL); 425 - if (!dai_props || !dai_link || !dais) 426 - return -ENOMEM; 427 - 428 - /* 429 - * Use snd_soc_dai_link_component instead of legacy style 430 - * It is codec only. but cpu/platform will be supported in the future. 431 - * see 432 - * soc-core.c :: snd_soc_init_multicodec() 433 - */ 434 - for (i = 0; i < lnum; i++) { 435 - dai_link[i].codecs = &dai_props[i].codecs; 436 - dai_link[i].num_codecs = 1; 437 - dai_link[i].platform = &dai_props[i].platform; 438 - } 439 - 440 - priv->dai_props = dai_props; 441 - priv->dai_link = dai_link; 442 - priv->dais = dais; 443 - priv->codec_conf = cconf; 444 - 445 - /* Init snd_soc_card */ 446 - card = graph_priv_to_card(priv); 447 - card->owner = THIS_MODULE; 448 - card->dev = dev; 449 - card->dai_link = priv->dai_link; 450 - card->num_links = lnum; 451 - card->codec_conf = cconf; 452 - card->num_configs = cnum; 453 - 454 - ret = asoc_graph_card_parse_of(priv); 455 - if (ret < 0) { 456 - if (ret != -EPROBE_DEFER) 457 - dev_err(dev, "parse error %d\n", ret); 458 - goto err; 459 - } 460 - 461 - snd_soc_card_set_drvdata(card, priv); 462 - 463 - ret = devm_snd_soc_register_card(dev, card); 464 - if (ret < 0) 465 - goto err; 466 - 467 - return 0; 468 - err: 469 - asoc_simple_card_clean_reference(card); 470 - 471 - return ret; 472 - } 473 - 474 - static int asoc_graph_card_remove(struct platform_device *pdev) 475 - { 476 - struct snd_soc_card *card = platform_get_drvdata(pdev); 477 - 478 - return asoc_simple_card_clean_reference(card); 479 - } 480 - 481 - static const struct of_device_id asoc_graph_of_match[] = { 482 - { .compatible = "audio-graph-scu-card", }, 483 - {}, 484 - }; 485 - MODULE_DEVICE_TABLE(of, asoc_graph_of_match); 486 - 487 - static struct platform_driver asoc_graph_card = { 488 - .driver = { 489 - .name = "asoc-audio-graph-scu-card", 490 - .pm = &snd_soc_pm_ops, 491 - .of_match_table = asoc_graph_of_match, 492 - }, 493 - .probe = asoc_graph_card_probe, 494 - .remove = asoc_graph_card_remove, 495 - }; 496 - module_platform_driver(asoc_graph_card); 497 - 498 - MODULE_ALIAS("platform:asoc-audio-graph-scu-card"); 499 - MODULE_LICENSE("GPL v2"); 500 - MODULE_DESCRIPTION("ASoC Audio Graph SCU Sound Card"); 501 - MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>");