wm8994.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. * wm8994.h -- WM8994 Soc Audio driver
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #ifndef _WM8994_H
  9. #define _WM8994_H
  10. #include <sound/soc.h>
  11. #include <linux/firmware.h>
  12. #include <linux/completion.h>
  13. #include <linux/workqueue.h>
  14. #include <linux/mutex.h>
  15. #include "wm_hubs.h"
  16. /* Sources for AIF1/2 SYSCLK - use with set_dai_sysclk() */
  17. #define WM8994_SYSCLK_MCLK1 1
  18. #define WM8994_SYSCLK_MCLK2 2
  19. #define WM8994_SYSCLK_FLL1 3
  20. #define WM8994_SYSCLK_FLL2 4
  21. /* OPCLK is also configured with set_dai_sysclk, specify division*10 as rate. */
  22. #define WM8994_SYSCLK_OPCLK 5
  23. #define WM8994_FLL1 1
  24. #define WM8994_FLL2 2
  25. #define WM8994_FLL_SRC_MCLK1 1
  26. #define WM8994_FLL_SRC_MCLK2 2
  27. #define WM8994_FLL_SRC_LRCLK 3
  28. #define WM8994_FLL_SRC_BCLK 4
  29. #define WM8994_FLL_SRC_INTERNAL 5
  30. enum wm8994_vmid_mode {
  31. WM8994_VMID_NORMAL,
  32. WM8994_VMID_FORCE,
  33. };
  34. typedef void (*wm1811_micdet_cb)(void *data);
  35. typedef void (*wm1811_mic_id_cb)(void *data, u16 status);
  36. int wm8994_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack,
  37. int micbias);
  38. int wm8958_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack,
  39. wm1811_micdet_cb cb, void *det_cb_data,
  40. wm1811_mic_id_cb id_cb, void *id_cb_data);
  41. int wm8994_vmid_mode(struct snd_soc_codec *codec, enum wm8994_vmid_mode mode);
  42. int wm8958_aif_ev(struct snd_soc_dapm_widget *w,
  43. struct snd_kcontrol *kcontrol, int event);
  44. void wm8958_dsp2_init(struct snd_soc_codec *codec);
  45. struct wm8994_micdet {
  46. struct snd_soc_jack *jack;
  47. bool detecting;
  48. };
  49. /* codec private data */
  50. struct wm8994_fll_config {
  51. int src;
  52. int in;
  53. int out;
  54. };
  55. #define WM8994_NUM_DRC 3
  56. #define WM8994_NUM_EQ 3
  57. struct wm8994;
  58. struct wm8994_priv {
  59. struct wm_hubs_data hubs;
  60. struct wm8994 *wm8994;
  61. int sysclk[2];
  62. int sysclk_rate[2];
  63. int mclk[2];
  64. int aifclk[2];
  65. int aifdiv[2];
  66. int channels[2];
  67. struct wm8994_fll_config fll[2], fll_suspend[2];
  68. struct completion fll_locked[2];
  69. bool fll_locked_irq;
  70. bool fll_byp;
  71. bool clk_has_run;
  72. int vmid_refcount;
  73. int active_refcount;
  74. enum wm8994_vmid_mode vmid_mode;
  75. int dac_rates[2];
  76. int lrclk_shared[2];
  77. int mbc_ena[3];
  78. int hpf1_ena[3];
  79. int hpf2_ena[3];
  80. int vss_ena[3];
  81. int enh_eq_ena[3];
  82. /* Platform dependant DRC configuration */
  83. const char **drc_texts;
  84. int drc_cfg[WM8994_NUM_DRC];
  85. struct soc_enum drc_enum;
  86. /* Platform dependant ReTune mobile configuration */
  87. int num_retune_mobile_texts;
  88. const char **retune_mobile_texts;
  89. int retune_mobile_cfg[WM8994_NUM_EQ];
  90. struct soc_enum retune_mobile_enum;
  91. /* Platform dependant MBC configuration */
  92. int mbc_cfg;
  93. const char **mbc_texts;
  94. struct soc_enum mbc_enum;
  95. /* Platform dependant VSS configuration */
  96. int vss_cfg;
  97. const char **vss_texts;
  98. struct soc_enum vss_enum;
  99. /* Platform dependant VSS HPF configuration */
  100. int vss_hpf_cfg;
  101. const char **vss_hpf_texts;
  102. struct soc_enum vss_hpf_enum;
  103. /* Platform dependant enhanced EQ configuration */
  104. int enh_eq_cfg;
  105. const char **enh_eq_texts;
  106. struct soc_enum enh_eq_enum;
  107. struct mutex accdet_lock;
  108. struct wm8994_micdet micdet[2];
  109. struct delayed_work mic_work;
  110. struct delayed_work open_circuit_work;
  111. struct delayed_work mic_complete_work;
  112. u16 mic_status;
  113. bool mic_detecting;
  114. bool jack_mic;
  115. int btn_mask;
  116. bool jackdet;
  117. int jackdet_mode;
  118. struct delayed_work jackdet_bootstrap;
  119. int micdet_irq;
  120. wm1811_micdet_cb micd_cb;
  121. void *micd_cb_data;
  122. wm1811_mic_id_cb mic_id_cb;
  123. void *mic_id_cb_data;
  124. unsigned int aif1clk_enable:1;
  125. unsigned int aif2clk_enable:1;
  126. unsigned int aif1clk_disable:1;
  127. unsigned int aif2clk_disable:1;
  128. struct mutex fw_lock;
  129. int dsp_active;
  130. const struct firmware *cur_fw;
  131. const struct firmware *mbc;
  132. const struct firmware *mbc_vss;
  133. const struct firmware *enh_eq;
  134. };
  135. #endif