2d790eeb7d484a2af5d3d9175a4b952079f36ed2
[firefly-linux-kernel-4.4.55.git] / sound / soc / codecs / hdmi_i2s.c
1 /*
2  * hdmi_i2s.c  --  HDMI i2s audio for rockchip
3  *
4  * Copyright 2013 Rockship
5  * Author: chenjq <chenjq@rock-chips.com>
6  */
7
8 #include <linux/module.h>
9 #include <linux/moduleparam.h>
10 #include <linux/slab.h>
11 #include <linux/of.h>
12 #include <linux/of_gpio.h>
13 #include <sound/soc.h>
14 #include <sound/pcm.h>
15 #include <sound/initval.h>
16
17 #if 0
18 #define DBG(x...) printk(KERN_INFO "hdmi i2s:"x)
19 #else
20 #define DBG(x...) do { } while (0)
21 #endif
22
23 struct snd_soc_dai_driver hdmi_i2s_dai = {
24         .name = "rk-hdmi-i2s-hifi",
25         .playback = {
26                 .stream_name = "HiFi Playback",
27                 .channels_min = 2,
28                 .channels_max = 2,
29                 .rates = (SNDRV_PCM_RATE_32000 |
30                         SNDRV_PCM_RATE_44100 |
31                         SNDRV_PCM_RATE_48000 |
32                         SNDRV_PCM_RATE_96000 |
33                         SNDRV_PCM_RATE_192000),
34                 .formats = (SNDRV_PCM_FMTBIT_S16_LE |
35                         SNDRV_PCM_FMTBIT_S20_3LE |
36                         SNDRV_PCM_FMTBIT_S24_LE),
37         },
38 };
39
40 static struct snd_soc_codec_driver soc_codec_dev_hdmi_i2s;
41
42 static int rockchip_hdmi_i2s_audio_probe(struct platform_device *pdev)
43 {
44         int ret;
45
46         //set dev name to driver->name for sound card register
47         dev_set_name(&pdev->dev, "%s", pdev->dev.driver->name);
48
49         ret = snd_soc_register_codec(&pdev->dev,
50                 &soc_codec_dev_hdmi_i2s,
51                 &hdmi_i2s_dai, 1);
52
53         if (ret)
54                 printk("%s() register card failed:%d\n", __FUNCTION__, ret);
55
56         return ret;
57 }
58
59 static int rockchip_hdmi_i2s_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 rockchip_hdmi_i2s_of_match[] = {
68         { .compatible = "hdmi-i2s", },
69         {},
70 };
71 MODULE_DEVICE_TABLE(of, rockchip_hdmi_i2s_of_match);
72 #endif /* CONFIG_OF */
73
74 static struct platform_driver rockchip_hdmi_i2s_audio_driver = {
75         .driver         = {
76                 .name   = "hdmi-i2s",
77                 .owner  = THIS_MODULE,
78                 .of_match_table = of_match_ptr(rockchip_hdmi_i2s_of_match),
79         },
80         .probe          = rockchip_hdmi_i2s_audio_probe,
81         .remove         = rockchip_hdmi_i2s_audio_remove,
82 };
83
84 module_platform_driver(rockchip_hdmi_i2s_audio_driver);
85
86 MODULE_DESCRIPTION("HDMI I2S Controller Driver");
87 MODULE_LICENSE("GPL");
88 MODULE_ALIAS("platform:hdmi-i2s");