Merge branch 'linux-linaro-lsk-v4.4-android' of git://git.linaro.org/kernel/linux...
[firefly-linux-kernel-4.4.55.git] / sound / soc / codecs / hdmi_spdif.c
1 /*
2  * ALSA SoC SPDIF DIT driver
3  *
4  *  This driver is used by controllers which can operate in DIT (SPDI/F) where
5  *  no codec is needed.  This file provides stub codec that can be used
6  *  in these configurations. TI DaVinci Audio controller uses this driver.
7  *
8  * Author:      Steve Chen,  <schen@mvista.com>
9  * Copyright:   (C) 2009 MontaVista Software, Inc., <source@mvista.com>
10  * Copyright:   (C) 2009  Texas Instruments, India
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License version 2 as
14  * published by the Free Software Foundation.
15  */
16
17 #include <linux/module.h>
18 #include <linux/moduleparam.h>
19 #include <linux/slab.h>
20 #include <linux/of.h>
21 #include <linux/of_gpio.h>
22 #include <sound/soc.h>
23 #include <sound/pcm.h>
24 #include <sound/initval.h>
25
26 #define DRV_NAME "spdif-dit"
27
28 #define STUB_RATES      SNDRV_PCM_RATE_8000_192000
29 #define STUB_FORMATS    (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE)
30
31
32 static struct snd_soc_codec_driver soc_codec_spdif_dit;
33
34 static struct snd_soc_dai_driver dit_stub_dai = {
35         .name           = "rk-hdmi-spdif-hifi",
36         .playback       = {
37                 .stream_name    = "Playback",
38                 .channels_min   = 1,
39                 .channels_max   = 384,
40                 .rates          = STUB_RATES,
41                 .formats        = STUB_FORMATS,
42         },
43 };
44
45 static int hdmi_spdif_audio_probe(struct platform_device *pdev)
46 {
47         int ret;
48
49         ret = snd_soc_register_codec(&pdev->dev, &soc_codec_spdif_dit,
50                                      &dit_stub_dai, 1);
51
52         if (ret)
53                 dev_err(&pdev->dev, "%s register failed: %d\n",
54                         __func__, ret);
55
56         return ret;
57 }
58
59 static int hdmi_spdif_audio_remove(struct platform_device *pdev)
60 {
61         snd_soc_unregister_codec(&pdev->dev);
62
63         return 0;
64 }
65
66 #ifdef CONFIG_OF
67 static const struct of_device_id hdmi_spdif_of_match[] = {
68         { .compatible = "hdmi-spdif", },
69         {},
70 };
71 MODULE_DEVICE_TABLE(of, hdmi_spdif_of_match);
72 #endif /* CONFIG_OF */
73
74 static struct platform_driver hdmi_spdif_audio_driver = {
75         .driver = {
76                 .name = "hdmi-spdif",
77                 .of_match_table = of_match_ptr(hdmi_spdif_of_match),
78         },
79         .probe = hdmi_spdif_audio_probe,
80         .remove = hdmi_spdif_audio_remove,
81 };
82
83 module_platform_driver(hdmi_spdif_audio_driver);
84
85 MODULE_AUTHOR("Steve Chen <schen@mvista.com>");
86 MODULE_DESCRIPTION("SPDIF dummy codec driver");
87 MODULE_LICENSE("GPL");
88 MODULE_ALIAS("platform:" DRV_NAME);