Merge remote-tracking branch 'origin/upstream/linux-linaro-lsk-v3.10-android' into...
[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_96000
29 #define STUB_FORMATS    SNDRV_PCM_FMTBIT_S16_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 rockchip_hdmi_spdif_audio_probe(struct platform_device *pdev)
46 {
47         int ret;
48
49         //set dev name to driver->name for sound card register
50         dev_set_name(&pdev->dev, "%s", pdev->dev.driver->name);
51
52         ret = snd_soc_register_codec(&pdev->dev, &soc_codec_spdif_dit,
53                         &dit_stub_dai, 1);
54
55         if (ret)
56                 printk("%s() register codec failed:%d\n", __FUNCTION__, ret);
57
58         return ret;
59 }
60
61 static int rockchip_hdmi_spdif_audio_remove(struct platform_device *pdev)
62 {
63         snd_soc_unregister_codec(&pdev->dev);
64
65         return 0;
66 }
67
68 #ifdef CONFIG_OF
69 static const struct of_device_id rockchip_hdmi_spdif_of_match[] = {
70         { .compatible = "hdmi-spdif", },
71         {},
72 };
73 MODULE_DEVICE_TABLE(of, rockchip_hdmi_spdif_of_match);
74 #endif /* CONFIG_OF */
75
76 static struct platform_driver rockchip_hdmi_spdif_audio_driver = {
77         .driver         = {
78                 .name   = "hdmi-spdif",
79                 .owner  = THIS_MODULE,
80                 .of_match_table = of_match_ptr(rockchip_hdmi_spdif_of_match),
81         },
82         .probe          = rockchip_hdmi_spdif_audio_probe,
83         .remove         = rockchip_hdmi_spdif_audio_remove,
84 };
85
86 module_platform_driver(rockchip_hdmi_spdif_audio_driver);
87
88 MODULE_AUTHOR("Steve Chen <schen@mvista.com>");
89 MODULE_DESCRIPTION("SPDIF dummy codec driver");
90 MODULE_LICENSE("GPL");
91 MODULE_ALIAS("platform:" DRV_NAME);