Add linux-next specific files for 20110421
[linux-2.6/next.git] / sound / soc / sh / fsi-hdmi.c
blob9719985eb82d2b4c3169be670cd7138abf41047c
1 /*
2 * FSI - HDMI sound support
4 * Copyright (C) 2010 Renesas Solutions Corp.
5 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
9 * for more details.
12 #include <linux/platform_device.h>
13 #include <sound/sh_fsi.h>
15 struct fsi_hdmi_data {
16 const char *cpu_dai;
17 const char *card;
18 int id;
21 static int fsi_hdmi_dai_init(struct snd_soc_pcm_runtime *rtd)
23 struct snd_soc_dai *cpu = rtd->cpu_dai;
24 int ret;
26 ret = snd_soc_dai_set_fmt(cpu, SND_SOC_DAIFMT_CBM_CFM);
28 return ret;
31 static struct snd_soc_dai_link fsi_dai_link = {
32 .name = "HDMI",
33 .stream_name = "HDMI",
34 .codec_dai_name = "sh_mobile_hdmi-hifi",
35 .platform_name = "sh_fsi2",
36 .codec_name = "sh-mobile-hdmi",
37 .init = fsi_hdmi_dai_init,
40 static struct snd_soc_card fsi_soc_card = {
41 .dai_link = &fsi_dai_link,
42 .num_links = 1,
45 static struct platform_device *fsi_snd_device;
47 static int fsi_hdmi_probe(struct platform_device *pdev)
49 int ret = -ENOMEM;
50 const struct platform_device_id *id_entry;
51 struct fsi_hdmi_data *pdata;
53 id_entry = pdev->id_entry;
54 if (!id_entry) {
55 dev_err(&pdev->dev, "unknown fsi hdmi\n");
56 return -ENODEV;
59 pdata = (struct fsi_hdmi_data *)id_entry->driver_data;
61 fsi_snd_device = platform_device_alloc("soc-audio", pdata->id);
62 if (!fsi_snd_device)
63 goto out;
65 fsi_dai_link.cpu_dai_name = pdata->cpu_dai;
66 fsi_soc_card.name = pdata->card;
68 platform_set_drvdata(fsi_snd_device, &fsi_soc_card);
69 ret = platform_device_add(fsi_snd_device);
71 if (ret)
72 platform_device_put(fsi_snd_device);
74 out:
75 return ret;
78 static int fsi_hdmi_remove(struct platform_device *pdev)
80 platform_device_unregister(fsi_snd_device);
81 return 0;
84 static struct fsi_hdmi_data fsi2_a_hdmi = {
85 .cpu_dai = "fsia-dai",
86 .card = "FSI2A (SH MOBILE HDMI)",
87 .id = FSI_PORT_A,
90 static struct fsi_hdmi_data fsi2_b_hdmi = {
91 .cpu_dai = "fsib-dai",
92 .card = "FSI2B (SH MOBILE HDMI)",
93 .id = FSI_PORT_B,
96 static struct platform_device_id fsi_id_table[] = {
97 /* FSI 2 */
98 { "sh_fsi2_a_hdmi", (kernel_ulong_t)&fsi2_a_hdmi },
99 { "sh_fsi2_b_hdmi", (kernel_ulong_t)&fsi2_b_hdmi },
103 static struct platform_driver fsi_hdmi = {
104 .driver = {
105 .name = "fsi-hdmi-audio",
107 .probe = fsi_hdmi_probe,
108 .remove = fsi_hdmi_remove,
109 .id_table = fsi_id_table,
112 static int __init fsi_hdmi_init(void)
114 return platform_driver_register(&fsi_hdmi);
117 static void __exit fsi_hdmi_exit(void)
119 platform_driver_unregister(&fsi_hdmi);
122 module_init(fsi_hdmi_init);
123 module_exit(fsi_hdmi_exit);
125 MODULE_LICENSE("GPL");
126 MODULE_DESCRIPTION("Generic SH4 FSI-HDMI sound card");
127 MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>");