fsi-hdmi.c 2.6 KB

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