msm-digital-cdc.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 msm_dig_priv {
  32. struct snd_soc_codec *codec;
  33. u32 comp_enabled[MSM89XX_RX_MAX];
  34. int (*codec_hph_comp_gpio)(bool enable, struct snd_soc_codec *codec);
  35. s32 dmic_1_2_clk_cnt;
  36. s32 dmic_3_4_clk_cnt;
  37. bool dec_active[NUM_DECIMATORS];
  38. int version;
  39. /* Entry for version info */
  40. struct snd_info_entry *entry;
  41. struct snd_info_entry *version_entry;
  42. char __iomem *dig_base;
  43. struct regmap *regmap;
  44. struct notifier_block nblock;
  45. u32 mute_mask;
  46. int dapm_bias_off;
  47. void *handle;
  48. void (*update_clkdiv)(void *handle, int val);
  49. int (*get_cdc_version)(void *handle);
  50. int (*register_notifier)(void *handle,
  51. struct notifier_block *nblock,
  52. bool enable);
  53. };
  54. struct dig_ctrl_platform_data {
  55. void *handle;
  56. void (*update_clkdiv)(void *handle, int val);
  57. int (*get_cdc_version)(void *handle);
  58. int (*register_notifier)(void *handle,
  59. struct notifier_block *nblock,
  60. bool enable);
  61. };
  62. struct hpf_work {
  63. struct msm_dig_priv *dig_cdc;
  64. u32 decimator;
  65. u8 tx_hpf_cut_of_freq;
  66. struct delayed_work dwork;
  67. };
  68. /* Codec supports 5 bands */
  69. enum {
  70. BAND1 = 0,
  71. BAND2,
  72. BAND3,
  73. BAND4,
  74. BAND5,
  75. BAND_MAX,
  76. };
  77. extern void msm_dig_cdc_hph_comp_cb(
  78. int (*codec_hph_comp_gpio)(
  79. bool enable, struct snd_soc_codec *codec),
  80. struct snd_soc_codec *codec);
  81. int msm_dig_codec_info_create_codec_entry(struct snd_info_entry *codec_root,
  82. struct snd_soc_codec *codec);
  83. #endif