aqt1000-clsh.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /* Copyright (c) 2015-2018, 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 _AQT1000_CLSH_H
  13. #define _AQT1000_CLSH_H
  14. #include <linux/module.h>
  15. #include <linux/slab.h>
  16. #include <sound/soc.h>
  17. #include <linux/kernel.h>
  18. #define CLSH_REQ_ENABLE true
  19. #define CLSH_REQ_DISABLE false
  20. #define AQT_CLSH_EVENT_PRE_DAC 0x01
  21. #define AQT_CLSH_EVENT_POST_PA 0x02
  22. /*
  23. * Basic states for Class H state machine.
  24. * represented as a bit mask within a u8 data type
  25. * bit 0: HPH Left mode
  26. * bit 1: HPH Right mode
  27. */
  28. #define AQT_CLSH_STATE_IDLE 0x00
  29. #define AQT_CLSH_STATE_HPHL (0x01 << 0)
  30. #define AQT_CLSH_STATE_HPHR (0x01 << 1)
  31. /*
  32. * Though number of CLSH states are 2, max state shoulbe be 3
  33. * because state array index starts from 1.
  34. */
  35. #define AQT_CLSH_STATE_MAX 3
  36. #define NUM_CLSH_STATES (0x01 << AQT_CLSH_STATE_MAX)
  37. /* Derived State: Bits 1 and 2 should be set for Headphone stereo */
  38. #define AQT_CLSH_STATE_HPH_ST (AQT_CLSH_STATE_HPHL | \
  39. AQT_CLSH_STATE_HPHR)
  40. enum {
  41. CLS_H_NORMAL = 0, /* Class-H Default */
  42. CLS_H_HIFI, /* Class-H HiFi */
  43. CLS_H_LP, /* Class-H Low Power */
  44. CLS_AB, /* Class-AB Low HIFI*/
  45. CLS_H_LOHIFI, /* LoHIFI */
  46. CLS_H_ULP, /* Ultra Low power */
  47. CLS_AB_HIFI, /* Class-AB */
  48. CLS_NONE, /* None of the above modes */
  49. };
  50. enum {
  51. DAC_GAIN_0DB = 0,
  52. DAC_GAIN_0P2DB,
  53. DAC_GAIN_0P4DB,
  54. DAC_GAIN_0P6DB,
  55. DAC_GAIN_0P8DB,
  56. DAC_GAIN_M0P2DB,
  57. DAC_GAIN_M0P4DB,
  58. DAC_GAIN_M0P6DB,
  59. };
  60. enum {
  61. VREF_FILT_R_0OHM = 0,
  62. VREF_FILT_R_25KOHM,
  63. VREF_FILT_R_50KOHM,
  64. VREF_FILT_R_100KOHM,
  65. };
  66. enum {
  67. DELTA_I_0MA,
  68. DELTA_I_10MA,
  69. DELTA_I_20MA,
  70. DELTA_I_30MA,
  71. DELTA_I_40MA,
  72. DELTA_I_50MA,
  73. };
  74. struct aqt_imped_val {
  75. u32 imped_val;
  76. u8 index;
  77. };
  78. struct aqt_clsh_cdc_data {
  79. u8 state;
  80. int flyback_users;
  81. int buck_users;
  82. int clsh_users;
  83. int interpolator_modes[AQT_CLSH_STATE_MAX];
  84. };
  85. struct aqt_reg_mask_val {
  86. u16 reg;
  87. u8 mask;
  88. u8 val;
  89. };
  90. extern void aqt_clsh_fsm(struct snd_soc_codec *codec,
  91. struct aqt_clsh_cdc_data *cdc_clsh_d,
  92. u8 clsh_event, u8 req_state,
  93. int int_mode);
  94. extern void aqt_clsh_init(struct aqt_clsh_cdc_data *clsh);
  95. extern int aqt_clsh_get_clsh_state(struct aqt_clsh_cdc_data *clsh);
  96. extern void aqt_clsh_imped_config(struct snd_soc_codec *codec, int imped,
  97. bool reset);
  98. #endif /* _AQT1000_CLSH_H */