Merge branch android-common-3.10
[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 #undef  DEBUG_HDMI_SPDIF
27 #define DEBUG_HDMI_SPDIF 0
28
29 #if DEBUG_HDMI_SPDIF
30 #define RK_HDMISPDIF_DBG(x...) pr_info("hdmi_spdif:"x)
31 #else
32 #define RK_HDMISPDIF_DBG(x...) do { } while (0)
33 #endif
34
35
36 #define DRV_NAME "spdif-dit"
37
38 #define STUB_RATES      SNDRV_PCM_RATE_8000_96000
39 #define STUB_FORMATS    SNDRV_PCM_FMTBIT_S16_LE
40
41
42 static struct snd_soc_codec_driver soc_codec_spdif_dit;
43
44 static struct snd_soc_dai_driver dit_stub_dai = {
45         .name           = "rk-hdmi-spdif-hifi",
46         .playback       = {
47                 .stream_name    = "Playback",
48                 .channels_min   = 1,
49                 .channels_max   = 384,
50                 .rates          = STUB_RATES,
51                 .formats        = STUB_FORMATS,
52         },
53 };
54
55 static int hdmi_spdif_audio_probe(struct platform_device *pdev)
56 {
57         int ret;
58
59         /* set dev name to driver->name for sound card register. */
60         dev_set_name(&pdev->dev, "%s", pdev->dev.driver->name);
61
62         ret = snd_soc_register_codec(&pdev->
63                 dev, &soc_codec_spdif_dit, &dit_stub_dai, 1);
64
65         if (ret)
66                 RK_HDMISPDIF_DBG("%s register codec failed:%d\n"
67                 , __func__, ret);
68
69         return ret;
70 }
71
72 static int hdmi_spdif_audio_remove(struct platform_device *pdev)
73 {
74         snd_soc_unregister_codec(&pdev->dev);
75
76         return 0;
77 }
78
79 #ifdef CONFIG_OF
80 static const struct of_device_id hdmi_spdif_of_match[] = {
81         { .compatible = "hdmi-spdif", },
82         {},
83 };
84 MODULE_DEVICE_TABLE(of, hdmi_spdif_of_match);
85 #endif /* CONFIG_OF */
86
87 static struct platform_driver hdmi_spdif_audio_driver = {
88         .driver    = {
89                 .name           = "hdmi-spdif",
90                 .owner          = THIS_MODULE,
91                 .of_match_table = of_match_ptr(hdmi_spdif_of_match),
92         },
93         .probe     = hdmi_spdif_audio_probe,
94         .remove    = hdmi_spdif_audio_remove,
95 };
96
97 module_platform_driver(hdmi_spdif_audio_driver);
98
99 MODULE_AUTHOR("Steve Chen <schen@mvista.com>");
100 MODULE_DESCRIPTION("SPDIF dummy codec driver");
101 MODULE_LICENSE("GPL");
102 MODULE_ALIAS("platform:" DRV_NAME);