xref: /linux/sound/soc/codecs/spdif_transmitter.c (revision 3a39d672e7f48b8d6b91a09afa4b55352773b4b5)
1d2912cb1SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
2ee492cfcSMarek Belisko /*
3ee492cfcSMarek Belisko  * ALSA SoC SPDIF DIT driver
4ee492cfcSMarek Belisko  *
5ee492cfcSMarek Belisko  *  This driver is used by controllers which can operate in DIT (SPDI/F) where
6ee492cfcSMarek Belisko  *  no codec is needed.  This file provides stub codec that can be used
7ee492cfcSMarek Belisko  *  in these configurations. TI DaVinci Audio controller uses this driver.
8ee492cfcSMarek Belisko  *
9ee492cfcSMarek Belisko  * Author:      Steve Chen,  <schen@mvista.com>
10ee492cfcSMarek Belisko  * Copyright:   (C) 2009 MontaVista Software, Inc., <source@mvista.com>
11ee492cfcSMarek Belisko  * Copyright:   (C) 2009  Texas Instruments, India
12ee492cfcSMarek Belisko  */
13ee492cfcSMarek Belisko 
14ee492cfcSMarek Belisko #include <linux/module.h>
15ee492cfcSMarek Belisko #include <linux/moduleparam.h>
16ee492cfcSMarek Belisko #include <linux/slab.h>
17ee492cfcSMarek Belisko #include <sound/soc.h>
18ee492cfcSMarek Belisko #include <sound/pcm.h>
19ee492cfcSMarek Belisko #include <sound/initval.h>
201b7c8b35SMarek Belisko #include <linux/of.h>
21ee492cfcSMarek Belisko 
22ee492cfcSMarek Belisko #define DRV_NAME "spdif-dit"
23ee492cfcSMarek Belisko 
24*8055c0cdSJerome Brunet #define STUB_RATES	(SNDRV_PCM_RATE_8000_768000 | \
25*8055c0cdSJerome Brunet 			 SNDRV_PCM_RATE_128000)
26db5ff954SNicolin Chen #define STUB_FORMATS	(SNDRV_PCM_FMTBIT_S16_LE | \
27db5ff954SNicolin Chen 			SNDRV_PCM_FMTBIT_S20_3LE | \
28eb733366SKatsuhiro Suzuki 			SNDRV_PCM_FMTBIT_S24_LE  | \
29eb733366SKatsuhiro Suzuki 			SNDRV_PCM_FMTBIT_S32_LE)
30ee492cfcSMarek Belisko 
316ad70948SRussell King static const struct snd_soc_dapm_widget dit_widgets[] = {
326ad70948SRussell King 	SND_SOC_DAPM_OUTPUT("spdif-out"),
336ad70948SRussell King };
346ad70948SRussell King 
35fc606148SMark Brown static const struct snd_soc_dapm_route dit_routes[] = {
366ad70948SRussell King 	{ "spdif-out", NULL, "Playback" },
376ad70948SRussell King };
386ad70948SRussell King 
393860978cSKuninori Morimoto static struct snd_soc_component_driver soc_codec_spdif_dit = {
406ad70948SRussell King 	.dapm_widgets		= dit_widgets,
416ad70948SRussell King 	.num_dapm_widgets	= ARRAY_SIZE(dit_widgets),
426ad70948SRussell King 	.dapm_routes		= dit_routes,
436ad70948SRussell King 	.num_dapm_routes	= ARRAY_SIZE(dit_routes),
443860978cSKuninori Morimoto 	.idle_bias_on		= 1,
453860978cSKuninori Morimoto 	.use_pmdown_time	= 1,
463860978cSKuninori Morimoto 	.endianness		= 1,
476ad70948SRussell King };
48ee492cfcSMarek Belisko 
49ee492cfcSMarek Belisko static struct snd_soc_dai_driver dit_stub_dai = {
50ee492cfcSMarek Belisko 	.name		= "dit-hifi",
51ee492cfcSMarek Belisko 	.playback 	= {
52ee492cfcSMarek Belisko 		.stream_name	= "Playback",
53ee492cfcSMarek Belisko 		.channels_min	= 1,
54ee492cfcSMarek Belisko 		.channels_max	= 384,
55ee492cfcSMarek Belisko 		.rates		= STUB_RATES,
56ee492cfcSMarek Belisko 		.formats	= STUB_FORMATS,
57ee492cfcSMarek Belisko 	},
58ee492cfcSMarek Belisko };
59ee492cfcSMarek Belisko 
spdif_dit_probe(struct platform_device * pdev)60ee492cfcSMarek Belisko static int spdif_dit_probe(struct platform_device *pdev)
61ee492cfcSMarek Belisko {
623860978cSKuninori Morimoto 	return devm_snd_soc_register_component(&pdev->dev,
633860978cSKuninori Morimoto 			&soc_codec_spdif_dit,
64ee492cfcSMarek Belisko 			&dit_stub_dai, 1);
65ee492cfcSMarek Belisko }
66ee492cfcSMarek Belisko 
671b7c8b35SMarek Belisko #ifdef CONFIG_OF
681b7c8b35SMarek Belisko static const struct of_device_id spdif_dit_dt_ids[] = {
691b7c8b35SMarek Belisko 	{ .compatible = "linux,spdif-dit", },
701b7c8b35SMarek Belisko 	{ }
711b7c8b35SMarek Belisko };
721b7c8b35SMarek Belisko MODULE_DEVICE_TABLE(of, spdif_dit_dt_ids);
731b7c8b35SMarek Belisko #endif
741b7c8b35SMarek Belisko 
75ee492cfcSMarek Belisko static struct platform_driver spdif_dit_driver = {
76ee492cfcSMarek Belisko 	.probe		= spdif_dit_probe,
77ee492cfcSMarek Belisko 	.driver		= {
78ee492cfcSMarek Belisko 		.name	= DRV_NAME,
791b7c8b35SMarek Belisko 		.of_match_table = of_match_ptr(spdif_dit_dt_ids),
80ee492cfcSMarek Belisko 	},
81ee492cfcSMarek Belisko };
82ee492cfcSMarek Belisko 
83ee492cfcSMarek Belisko module_platform_driver(spdif_dit_driver);
84ee492cfcSMarek Belisko 
85ee492cfcSMarek Belisko MODULE_AUTHOR("Steve Chen <schen@mvista.com>");
86ee492cfcSMarek Belisko MODULE_DESCRIPTION("SPDIF dummy codec driver");
87ee492cfcSMarek Belisko MODULE_LICENSE("GPL");
88ee492cfcSMarek Belisko MODULE_ALIAS("platform:" DRV_NAME);
89