Kuninori Morimoto | 41a686e | 2010-08-31 14:46:53 +0900 | [diff] [blame] | 1 | /* |
| 2 | * FSI - HDMI sound support |
| 3 | * |
| 4 | * Copyright (C) 2010 Renesas Solutions Corp. |
| 5 | * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> |
| 6 | * |
| 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. |
| 10 | */ |
| 11 | |
| 12 | #include <linux/platform_device.h> |
Paul Gortmaker | da155d5 | 2011-07-15 12:38:28 -0400 | [diff] [blame] | 13 | #include <linux/module.h> |
Kuninori Morimoto | 41a686e | 2010-08-31 14:46:53 +0900 | [diff] [blame] | 14 | #include <sound/sh_fsi.h> |
Kuninori Morimoto | 41a686e | 2010-08-31 14:46:53 +0900 | [diff] [blame] | 15 | |
Kuninori Morimoto | 3f25c9c | 2011-01-24 10:09:02 +0900 | [diff] [blame] | 16 | struct fsi_hdmi_data { |
| 17 | const char *cpu_dai; |
| 18 | const char *card; |
| 19 | int id; |
| 20 | }; |
| 21 | |
Kuninori Morimoto | 4d805f7 | 2011-01-20 11:46:02 +0900 | [diff] [blame] | 22 | static int fsi_hdmi_dai_init(struct snd_soc_pcm_runtime *rtd) |
| 23 | { |
| 24 | struct snd_soc_dai *cpu = rtd->cpu_dai; |
| 25 | int ret; |
| 26 | |
| 27 | ret = snd_soc_dai_set_fmt(cpu, SND_SOC_DAIFMT_CBM_CFM); |
| 28 | |
| 29 | return ret; |
| 30 | } |
| 31 | |
Kuninori Morimoto | 41a686e | 2010-08-31 14:46:53 +0900 | [diff] [blame] | 32 | static struct snd_soc_dai_link fsi_dai_link = { |
| 33 | .name = "HDMI", |
| 34 | .stream_name = "HDMI", |
Kuninori Morimoto | 41a686e | 2010-08-31 14:46:53 +0900 | [diff] [blame] | 35 | .codec_dai_name = "sh_mobile_hdmi-hifi", |
| 36 | .platform_name = "sh_fsi2", |
| 37 | .codec_name = "sh-mobile-hdmi", |
Kuninori Morimoto | 4d805f7 | 2011-01-20 11:46:02 +0900 | [diff] [blame] | 38 | .init = fsi_hdmi_dai_init, |
Kuninori Morimoto | 41a686e | 2010-08-31 14:46:53 +0900 | [diff] [blame] | 39 | }; |
| 40 | |
| 41 | static struct snd_soc_card fsi_soc_card = { |
Kuninori Morimoto | 41a686e | 2010-08-31 14:46:53 +0900 | [diff] [blame] | 42 | .dai_link = &fsi_dai_link, |
| 43 | .num_links = 1, |
| 44 | }; |
| 45 | |
| 46 | static struct platform_device *fsi_snd_device; |
| 47 | |
Kuninori Morimoto | 3f25c9c | 2011-01-24 10:09:02 +0900 | [diff] [blame] | 48 | static int fsi_hdmi_probe(struct platform_device *pdev) |
Kuninori Morimoto | 41a686e | 2010-08-31 14:46:53 +0900 | [diff] [blame] | 49 | { |
| 50 | int ret = -ENOMEM; |
Kuninori Morimoto | 3f25c9c | 2011-01-24 10:09:02 +0900 | [diff] [blame] | 51 | const struct platform_device_id *id_entry; |
| 52 | struct fsi_hdmi_data *pdata; |
Kuninori Morimoto | 41a686e | 2010-08-31 14:46:53 +0900 | [diff] [blame] | 53 | |
Kuninori Morimoto | 3f25c9c | 2011-01-24 10:09:02 +0900 | [diff] [blame] | 54 | id_entry = pdev->id_entry; |
| 55 | if (!id_entry) { |
| 56 | dev_err(&pdev->dev, "unknown fsi hdmi\n"); |
| 57 | return -ENODEV; |
| 58 | } |
| 59 | |
| 60 | pdata = (struct fsi_hdmi_data *)id_entry->driver_data; |
| 61 | |
| 62 | fsi_snd_device = platform_device_alloc("soc-audio", pdata->id); |
Kuninori Morimoto | 41a686e | 2010-08-31 14:46:53 +0900 | [diff] [blame] | 63 | if (!fsi_snd_device) |
| 64 | goto out; |
| 65 | |
Kuninori Morimoto | 3f25c9c | 2011-01-24 10:09:02 +0900 | [diff] [blame] | 66 | fsi_dai_link.cpu_dai_name = pdata->cpu_dai; |
| 67 | fsi_soc_card.name = pdata->card; |
| 68 | |
Kuninori Morimoto | 41a686e | 2010-08-31 14:46:53 +0900 | [diff] [blame] | 69 | platform_set_drvdata(fsi_snd_device, &fsi_soc_card); |
| 70 | ret = platform_device_add(fsi_snd_device); |
| 71 | |
| 72 | if (ret) |
| 73 | platform_device_put(fsi_snd_device); |
| 74 | |
| 75 | out: |
| 76 | return ret; |
| 77 | } |
| 78 | |
Kuninori Morimoto | 3f25c9c | 2011-01-24 10:09:02 +0900 | [diff] [blame] | 79 | static int fsi_hdmi_remove(struct platform_device *pdev) |
Kuninori Morimoto | 41a686e | 2010-08-31 14:46:53 +0900 | [diff] [blame] | 80 | { |
| 81 | platform_device_unregister(fsi_snd_device); |
Kuninori Morimoto | 3f25c9c | 2011-01-24 10:09:02 +0900 | [diff] [blame] | 82 | return 0; |
| 83 | } |
| 84 | |
| 85 | static struct fsi_hdmi_data fsi2_a_hdmi = { |
| 86 | .cpu_dai = "fsia-dai", |
Kuninori Morimoto | 2c7beb9 | 2011-07-05 00:16:17 -0700 | [diff] [blame] | 87 | .card = "FSI2A-HDMI", |
Kuninori Morimoto | 3f25c9c | 2011-01-24 10:09:02 +0900 | [diff] [blame] | 88 | .id = FSI_PORT_A, |
| 89 | }; |
| 90 | |
| 91 | static struct fsi_hdmi_data fsi2_b_hdmi = { |
| 92 | .cpu_dai = "fsib-dai", |
Kuninori Morimoto | 2c7beb9 | 2011-07-05 00:16:17 -0700 | [diff] [blame] | 93 | .card = "FSI2B-HDMI", |
Kuninori Morimoto | 3f25c9c | 2011-01-24 10:09:02 +0900 | [diff] [blame] | 94 | .id = FSI_PORT_B, |
| 95 | }; |
| 96 | |
| 97 | static struct platform_device_id fsi_id_table[] = { |
| 98 | /* FSI 2 */ |
| 99 | { "sh_fsi2_a_hdmi", (kernel_ulong_t)&fsi2_a_hdmi }, |
| 100 | { "sh_fsi2_b_hdmi", (kernel_ulong_t)&fsi2_b_hdmi }, |
| 101 | {}, |
| 102 | }; |
| 103 | |
| 104 | static struct platform_driver fsi_hdmi = { |
| 105 | .driver = { |
| 106 | .name = "fsi-hdmi-audio", |
| 107 | }, |
| 108 | .probe = fsi_hdmi_probe, |
| 109 | .remove = fsi_hdmi_remove, |
| 110 | .id_table = fsi_id_table, |
| 111 | }; |
| 112 | |
| 113 | static int __init fsi_hdmi_init(void) |
| 114 | { |
| 115 | return platform_driver_register(&fsi_hdmi); |
| 116 | } |
| 117 | |
| 118 | static void __exit fsi_hdmi_exit(void) |
| 119 | { |
| 120 | platform_driver_unregister(&fsi_hdmi); |
Kuninori Morimoto | 41a686e | 2010-08-31 14:46:53 +0900 | [diff] [blame] | 121 | } |
| 122 | |
| 123 | module_init(fsi_hdmi_init); |
| 124 | module_exit(fsi_hdmi_exit); |
| 125 | |
| 126 | MODULE_LICENSE("GPL"); |
| 127 | MODULE_DESCRIPTION("Generic SH4 FSI-HDMI sound card"); |
| 128 | MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>"); |