wm1250-ev1.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * Driver for the 1250-EV1 audio I/O module
  3. *
  4. * Copyright 2011 Wolfson Microelectronics plc
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation; either version 2 of the License, or (at your
  9. * option) any later version.
  10. *
  11. */
  12. #include <linux/init.h>
  13. #include <linux/module.h>
  14. #include <linux/i2c.h>
  15. #include <sound/soc.h>
  16. #include <sound/soc-dapm.h>
  17. static const struct snd_soc_dapm_widget wm1250_ev1_dapm_widgets[] = {
  18. SND_SOC_DAPM_ADC("ADC", "wm1250-ev1 Capture", SND_SOC_NOPM, 0, 0),
  19. SND_SOC_DAPM_DAC("DAC", "wm1250-ev1 Playback", SND_SOC_NOPM, 0, 0),
  20. SND_SOC_DAPM_INPUT("WM1250 Input"),
  21. SND_SOC_DAPM_OUTPUT("WM1250 Output"),
  22. };
  23. static const struct snd_soc_dapm_route wm1250_ev1_dapm_routes[] = {
  24. { "ADC", NULL, "WM1250 Input" },
  25. { "WM1250 Output", NULL, "DAC" },
  26. };
  27. static struct snd_soc_dai_driver wm1250_ev1_dai = {
  28. .name = "wm1250-ev1",
  29. .playback = {
  30. .stream_name = "Playback",
  31. .channels_min = 1,
  32. .channels_max = 1,
  33. .rates = SNDRV_PCM_RATE_8000,
  34. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  35. },
  36. .capture = {
  37. .stream_name = "Capture",
  38. .channels_min = 1,
  39. .channels_max = 1,
  40. .rates = SNDRV_PCM_RATE_8000,
  41. .formats = SNDRV_PCM_FMTBIT_S16_LE,
  42. },
  43. };
  44. static struct snd_soc_codec_driver soc_codec_dev_wm1250_ev1 = {
  45. .dapm_widgets = wm1250_ev1_dapm_widgets,
  46. .num_dapm_widgets = ARRAY_SIZE(wm1250_ev1_dapm_widgets),
  47. .dapm_routes = wm1250_ev1_dapm_routes,
  48. .num_dapm_routes = ARRAY_SIZE(wm1250_ev1_dapm_routes),
  49. };
  50. static int __devinit wm1250_ev1_probe(struct i2c_client *i2c,
  51. const struct i2c_device_id *id)
  52. {
  53. return snd_soc_register_codec(&i2c->dev, &soc_codec_dev_wm1250_ev1,
  54. &wm1250_ev1_dai, 1);
  55. }
  56. static int __devexit wm1250_ev1_remove(struct i2c_client *i2c)
  57. {
  58. snd_soc_unregister_codec(&i2c->dev);
  59. return 0;
  60. }
  61. static const struct i2c_device_id wm1250_ev1_i2c_id[] = {
  62. { "wm1250-ev1", 0 },
  63. { }
  64. };
  65. MODULE_DEVICE_TABLE(i2c, wm1250_ev1_i2c_id);
  66. static struct i2c_driver wm1250_ev1_i2c_driver = {
  67. .driver = {
  68. .name = "wm1250-ev1",
  69. .owner = THIS_MODULE,
  70. },
  71. .probe = wm1250_ev1_probe,
  72. .remove = __devexit_p(wm1250_ev1_remove),
  73. .id_table = wm1250_ev1_i2c_id,
  74. };
  75. static int __init wm1250_ev1_modinit(void)
  76. {
  77. int ret = 0;
  78. ret = i2c_add_driver(&wm1250_ev1_i2c_driver);
  79. if (ret != 0)
  80. pr_err("Failed to register WM1250-EV1 I2C driver: %d\n", ret);
  81. return ret;
  82. }
  83. module_init(wm1250_ev1_modinit);
  84. static void __exit wm1250_ev1_exit(void)
  85. {
  86. i2c_del_driver(&wm1250_ev1_i2c_driver);
  87. }
  88. module_exit(wm1250_ev1_exit);
  89. MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
  90. MODULE_DESCRIPTION("WM1250-EV1 audio I/O module driver");
  91. MODULE_LICENSE("GPL");