msm-digital-cdc.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. */
  12. #ifndef MSM_DIGITAL_CDC_H
  13. #define MSM_DIGITAL_CDC_H
  14. #define HPHL_PA_DISABLE (0x01 << 1)
  15. #define HPHR_PA_DISABLE (0x01 << 2)
  16. #define SPKR_PA_DISABLE (0x01 << 3)
  17. #define NUM_DECIMATORS 5
  18. /* Codec supports 1 compander */
  19. enum {
  20. COMPANDER_NONE = 0,
  21. COMPANDER_1, /* HPHL/R */
  22. COMPANDER_MAX,
  23. };
  24. /* Number of output I2S port */
  25. enum {
  26. MSM89XX_RX1 = 0,
  27. MSM89XX_RX2,
  28. MSM89XX_RX3,
  29. MSM89XX_RX_MAX,
  30. };
  31. struct tx_mute_work {
  32. struct msm_dig_priv *dig_cdc;
  33. u32 decimator;
  34. struct delayed_work dwork;
  35. };
  36. struct msm_dig_priv {
  37. struct snd_soc_codec *codec;
  38. u32 comp_enabled[MSM89XX_RX_MAX];
  39. int (*codec_hph_comp_gpio)(bool enable, struct snd_soc_codec *codec);
  40. s32 dmic_1_2_clk_cnt;
  41. s32 dmic_3_4_clk_cnt;
  42. bool dec_active[NUM_DECIMATORS];
  43. int version;
  44. /* Entry for version info */
  45. struct snd_info_entry *entry;
  46. struct snd_info_entry *version_entry;
  47. char __iomem *dig_base;
  48. struct regmap *regmap;
  49. struct notifier_block nblock;
  50. u32 mute_mask;
  51. int dapm_bias_off;
  52. void *handle;
  53. void (*set_compander_mode)(void *handle, int val);
  54. void (*update_clkdiv)(void *handle, int val);
  55. int (*get_cdc_version)(void *handle);
  56. int (*register_notifier)(void *handle,
  57. struct notifier_block *nblock,
  58. bool enable);
  59. struct tx_mute_work tx_mute_dwork[NUM_DECIMATORS];
  60. };
  61. struct dig_ctrl_platform_data {
  62. void *handle;
  63. void (*set_compander_mode)(void *handle, int val);
  64. void (*update_clkdiv)(void *handle, int val);
  65. int (*get_cdc_version)(void *handle);
  66. int (*register_notifier)(void *handle,
  67. struct notifier_block *nblock,
  68. bool enable);
  69. };
  70. struct hpf_work {
  71. struct msm_dig_priv *dig_cdc;
  72. u32 decimator;
  73. u8 tx_hpf_cut_of_freq;
  74. struct delayed_work dwork;
  75. };
  76. /* Codec supports 5 bands */
  77. enum {
  78. BAND1 = 0,
  79. BAND2,
  80. BAND3,
  81. BAND4,
  82. BAND5,
  83. BAND_MAX,
  84. };
  85. #if IS_ENABLED(CONFIG_SND_SOC_DIGITAL_CDC)
  86. extern void msm_dig_cdc_hph_comp_cb(
  87. int (*codec_hph_comp_gpio)(
  88. bool enable, struct snd_soc_codec *codec),
  89. struct snd_soc_codec *codec);
  90. int msm_dig_codec_info_create_codec_entry(struct snd_info_entry *codec_root,
  91. struct snd_soc_codec *codec);
  92. #else /* CONFIG_SND_SOC_DIGITAL_CDC */
  93. static inline void msm_dig_cdc_hph_comp_cb(
  94. int (*codec_hph_comp_gpio)(
  95. bool enable, struct snd_soc_codec *codec),
  96. struct snd_soc_codec *codec)
  97. {
  98. }
  99. static inline int msm_dig_codec_info_create_codec_entry(
  100. struct snd_info_entry *codec_root,
  101. struct snd_soc_codec *codec)
  102. {
  103. return 0;
  104. }
  105. #endif /* CONFIG_SND_SOC_DIGITAL_CDC */
  106. #endif