xref: /linux/sound/soc/codecs/spdif_receiver.c (revision 8c6086b8b5e7e50519b6d439ec51ac06a956c656)
1cdf60525SVipin Kumar /*
2cdf60525SVipin Kumar  * ALSA SoC SPDIF DIR (Digital Interface Reciever) driver
3cdf60525SVipin Kumar  *
4cdf60525SVipin Kumar  * Based on ALSA SoC SPDIF DIT driver
5cdf60525SVipin Kumar  *
6cdf60525SVipin Kumar  *  This driver is used by controllers which can operate in DIR (SPDI/F) where
7cdf60525SVipin Kumar  *  no codec is needed.  This file provides stub codec that can be used
8cdf60525SVipin Kumar  *  in these configurations. SPEAr SPDIF IN Audio controller uses this driver.
9cdf60525SVipin Kumar  *
10cdf60525SVipin Kumar  * Author:      Vipin Kumar,  <vipin.kumar@st.com>
11cdf60525SVipin Kumar  * Copyright:   (C) 2012  ST Microelectronics
12cdf60525SVipin Kumar  *
13cdf60525SVipin Kumar  * This program is free software; you can redistribute it and/or modify
14cdf60525SVipin Kumar  * it under the terms of the GNU General Public License version 2 as
15cdf60525SVipin Kumar  * published by the Free Software Foundation.
16cdf60525SVipin Kumar  */
17cdf60525SVipin Kumar 
18cdf60525SVipin Kumar #include <linux/module.h>
19cdf60525SVipin Kumar #include <linux/moduleparam.h>
20cdf60525SVipin Kumar #include <linux/slab.h>
21cdf60525SVipin Kumar #include <sound/soc.h>
22cdf60525SVipin Kumar #include <sound/pcm.h>
23cdf60525SVipin Kumar #include <sound/initval.h>
24f9c8ba89SMarek Belisko #include <linux/of.h>
25cdf60525SVipin Kumar 
262f6e3ba0SMark Brown static const struct snd_soc_dapm_widget dir_widgets[] = {
272f6e3ba0SMark Brown 	SND_SOC_DAPM_INPUT("spdif-in"),
282f6e3ba0SMark Brown };
292f6e3ba0SMark Brown 
302f6e3ba0SMark Brown static const struct snd_soc_dapm_route dir_routes[] = {
312f6e3ba0SMark Brown 	{ "Capture", NULL, "spdif-in" },
322f6e3ba0SMark Brown };
332f6e3ba0SMark Brown 
34cdf60525SVipin Kumar #define STUB_RATES	SNDRV_PCM_RATE_8000_192000
35cdf60525SVipin Kumar #define STUB_FORMATS	(SNDRV_PCM_FMTBIT_S16_LE | \
36db5ff954SNicolin Chen 			SNDRV_PCM_FMTBIT_S20_3LE | \
37db5ff954SNicolin Chen 			SNDRV_PCM_FMTBIT_S24_LE  | \
38eb733366SKatsuhiro Suzuki 			SNDRV_PCM_FMTBIT_S32_LE | \
39cdf60525SVipin Kumar 			SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE)
40cdf60525SVipin Kumar 
41*8c6086b8SKuninori Morimoto static struct snd_soc_component_driver soc_codec_spdif_dir = {
422f6e3ba0SMark Brown 	.dapm_widgets		= dir_widgets,
432f6e3ba0SMark Brown 	.num_dapm_widgets	= ARRAY_SIZE(dir_widgets),
442f6e3ba0SMark Brown 	.dapm_routes		= dir_routes,
452f6e3ba0SMark Brown 	.num_dapm_routes	= ARRAY_SIZE(dir_routes),
46*8c6086b8SKuninori Morimoto 	.idle_bias_on		= 1,
47*8c6086b8SKuninori Morimoto 	.use_pmdown_time	= 1,
48*8c6086b8SKuninori Morimoto 	.endianness		= 1,
49*8c6086b8SKuninori Morimoto 	.non_legacy_dai_naming	= 1,
502f6e3ba0SMark Brown };
51cdf60525SVipin Kumar 
52cdf60525SVipin Kumar static struct snd_soc_dai_driver dir_stub_dai = {
53cdf60525SVipin Kumar 	.name		= "dir-hifi",
54cdf60525SVipin Kumar 	.capture	= {
55cdf60525SVipin Kumar 		.stream_name	= "Capture",
56cdf60525SVipin Kumar 		.channels_min	= 1,
57cdf60525SVipin Kumar 		.channels_max	= 384,
58cdf60525SVipin Kumar 		.rates		= STUB_RATES,
59cdf60525SVipin Kumar 		.formats	= STUB_FORMATS,
60cdf60525SVipin Kumar 	},
61cdf60525SVipin Kumar };
62cdf60525SVipin Kumar 
63cdf60525SVipin Kumar static int spdif_dir_probe(struct platform_device *pdev)
64cdf60525SVipin Kumar {
65*8c6086b8SKuninori Morimoto 	return devm_snd_soc_register_component(&pdev->dev,
66*8c6086b8SKuninori Morimoto 			&soc_codec_spdif_dir,
67cdf60525SVipin Kumar 			&dir_stub_dai, 1);
68cdf60525SVipin Kumar }
69cdf60525SVipin Kumar 
70f9c8ba89SMarek Belisko #ifdef CONFIG_OF
71f9c8ba89SMarek Belisko static const struct of_device_id spdif_dir_dt_ids[] = {
72f9c8ba89SMarek Belisko 	{ .compatible = "linux,spdif-dir", },
73f9c8ba89SMarek Belisko 	{ }
74f9c8ba89SMarek Belisko };
75f9c8ba89SMarek Belisko MODULE_DEVICE_TABLE(of, spdif_dir_dt_ids);
76f9c8ba89SMarek Belisko #endif
77f9c8ba89SMarek Belisko 
78cdf60525SVipin Kumar static struct platform_driver spdif_dir_driver = {
79cdf60525SVipin Kumar 	.probe		= spdif_dir_probe,
80cdf60525SVipin Kumar 	.driver		= {
81cdf60525SVipin Kumar 		.name	= "spdif-dir",
82f9c8ba89SMarek Belisko 		.of_match_table = of_match_ptr(spdif_dir_dt_ids),
83cdf60525SVipin Kumar 	},
84cdf60525SVipin Kumar };
85cdf60525SVipin Kumar 
86cdf60525SVipin Kumar module_platform_driver(spdif_dir_driver);
87cdf60525SVipin Kumar 
88cdf60525SVipin Kumar MODULE_DESCRIPTION("ASoC SPDIF DIR driver");
89cdf60525SVipin Kumar MODULE_AUTHOR("Vipin Kumar <vipin.kumar@st.com>");
90cdf60525SVipin Kumar MODULE_LICENSE("GPL");
91