fsi-hdmi.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. #include <linux/platform_device.h>
  12. #include <sound/sh_fsi.h>
  13. struct fsi_hdmi_data {
  14. const char *cpu_dai;
  15. const char *card;
  16. int id;
  17. };
  18. static int fsi_hdmi_dai_init(struct snd_soc_pcm_runtime *rtd)
  19. {
  20. struct snd_soc_dai *cpu = rtd->cpu_dai;
  21. int ret;
  22. ret = snd_soc_dai_set_fmt(cpu, SND_SOC_DAIFMT_CBM_CFM);
  23. return ret;
  24. }
  25. static struct snd_soc_dai_link fsi_dai_link = {
  26. .name = "HDMI",
  27. .stream_name = "HDMI",
  28. .codec_dai_name = "sh_mobile_hdmi-hifi",
  29. .platform_name = "sh_fsi2",
  30. .codec_name = "sh-mobile-hdmi",
  31. .init = fsi_hdmi_dai_init,
  32. };
  33. static struct snd_soc_card fsi_soc_card = {
  34. .dai_link = &fsi_dai_link,
  35. .num_links = 1,
  36. };
  37. static struct platform_device *fsi_snd_device;
  38. static int fsi_hdmi_probe(struct platform_device *pdev)
  39. {
  40. int ret = -ENOMEM;
  41. const struct platform_device_id *id_entry;
  42. struct fsi_hdmi_data *pdata;
  43. id_entry = pdev->id_entry;
  44. if (!id_entry) {
  45. dev_err(&pdev->dev, "unknown fsi hdmi\n");
  46. return -ENODEV;
  47. }
  48. pdata = (struct fsi_hdmi_data *)id_entry->driver_data;
  49. fsi_snd_device = platform_device_alloc("soc-audio", pdata->id);
  50. if (!fsi_snd_device)
  51. goto out;
  52. fsi_dai_link.cpu_dai_name = pdata->cpu_dai;
  53. fsi_soc_card.name = pdata->card;
  54. platform_set_drvdata(fsi_snd_device, &fsi_soc_card);
  55. ret = platform_device_add(fsi_snd_device);
  56. if (ret)
  57. platform_device_put(fsi_snd_device);
  58. out:
  59. return ret;
  60. }
  61. static int fsi_hdmi_remove(struct platform_device *pdev)
  62. {
  63. platform_device_unregister(fsi_snd_device);
  64. return 0;
  65. }
  66. static struct fsi_hdmi_data fsi2_a_hdmi = {
  67. .cpu_dai = "fsia-dai",
  68. .card = "FSI2A-HDMI",
  69. .id = FSI_PORT_A,
  70. };
  71. static struct fsi_hdmi_data fsi2_b_hdmi = {
  72. .cpu_dai = "fsib-dai",
  73. .card = "FSI2B-HDMI",
  74. .id = FSI_PORT_B,
  75. };
  76. static struct platform_device_id fsi_id_table[] = {
  77. /* FSI 2 */
  78. { "sh_fsi2_a_hdmi", (kernel_ulong_t)&fsi2_a_hdmi },
  79. { "sh_fsi2_b_hdmi", (kernel_ulong_t)&fsi2_b_hdmi },
  80. {},
  81. };
  82. static struct platform_driver fsi_hdmi = {
  83. .driver = {
  84. .name = "fsi-hdmi-audio",
  85. },
  86. .probe = fsi_hdmi_probe,
  87. .remove = fsi_hdmi_remove,
  88. .id_table = fsi_id_table,
  89. };
  90. static int __init fsi_hdmi_init(void)
  91. {
  92. return platform_driver_register(&fsi_hdmi);
  93. }
  94. static void __exit fsi_hdmi_exit(void)
  95. {
  96. platform_driver_unregister(&fsi_hdmi);
  97. }
  98. module_init(fsi_hdmi_init);
  99. module_exit(fsi_hdmi_exit);
  100. MODULE_LICENSE("GPL");
  101. MODULE_DESCRIPTION("Generic SH4 FSI-HDMI sound card");
  102. MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>");