msm-digital-cdc.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 (*update_clkdiv)(void *handle, int val);
  54. int (*get_cdc_version)(void *handle);
  55. int (*register_notifier)(void *handle,
  56. struct notifier_block *nblock,
  57. bool enable);
  58. struct tx_mute_work tx_mute_dwork[NUM_DECIMATORS];
  59. };
  60. struct dig_ctrl_platform_data {
  61. void *handle;
  62. void (*update_clkdiv)(void *handle, int val);
  63. int (*get_cdc_version)(void *handle);
  64. int (*register_notifier)(void *handle,
  65. struct notifier_block *nblock,
  66. bool enable);
  67. };
  68. struct hpf_work {
  69. struct msm_dig_priv *dig_cdc;
  70. u32 decimator;
  71. u8 tx_hpf_cut_of_freq;
  72. struct delayed_work dwork;
  73. };
  74. /* Codec supports 5 bands */
  75. enum {
  76. BAND1 = 0,
  77. BAND2,
  78. BAND3,
  79. BAND4,
  80. BAND5,
  81. BAND_MAX,
  82. };
  83. extern void msm_dig_cdc_hph_comp_cb(
  84. int (*codec_hph_comp_gpio)(
  85. bool enable, struct snd_soc_codec *codec),
  86. struct snd_soc_codec *codec);
  87. int msm_dig_codec_info_create_codec_entry(struct snd_info_entry *codec_root,
  88. struct snd_soc_codec *codec);
  89. #endif