wcd-clsh.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
  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 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #ifndef _WCD_CLSH
  14. #define _WCD_CLSH
  15. #include <linux/stringify.h>
  16. #define WCD_CLSH_STRINGIFY(s) __stringify(s)
  17. #define CLSH_REQ_ENABLE true
  18. #define CLSH_REQ_DISABLE false
  19. #define WCD_CLSH_EVENT_PRE_DAC 0x01
  20. #define WCD_CLSH_EVENT_POST_PA 0x02
  21. /*
  22. * Basic states for Class H state machine.
  23. * represented as a bit mask within a u8 data type
  24. * bit 0: EAR mode
  25. * bit 1: HPH Left mode
  26. * bit 2: HPH Right mode
  27. * bit 3: AUX mode
  28. */
  29. #define WCD_CLSH_STATE_IDLE 0x00
  30. #define WCD_CLSH_STATE_EAR (0x01 << 0)
  31. #define WCD_CLSH_STATE_HPHL (0x01 << 1)
  32. #define WCD_CLSH_STATE_HPHR (0x01 << 2)
  33. #define WCD_CLSH_STATE_AUX (0x01 << 3)
  34. /*
  35. * Though number of CLSH states is 4, max state should be 5
  36. * because state array index starts from 1.
  37. */
  38. #define WCD_CLSH_STATE_MAX 5
  39. #define NUM_CLSH_STATES (0x01 << WCD_CLSH_STATE_MAX)
  40. /* Derived State: Bits 1 and 2 should be set for Headphone stereo */
  41. #define WCD_CLSH_STATE_HPH_ST (WCD_CLSH_STATE_HPHL | \
  42. WCD_CLSH_STATE_HPHR)
  43. #define WCD_CLSH_STATE_HPHL_AUX (WCD_CLSH_STATE_HPHL | \
  44. WCD_CLSH_STATE_AUX)
  45. #define WCD_CLSH_STATE_HPHR_AUX (WCD_CLSH_STATE_HPHR | \
  46. WCD_CLSH_STATE_AUX)
  47. #define WCD_CLSH_STATE_HPH_ST_AUX (WCD_CLSH_STATE_HPH_ST | \
  48. WCD_CLSH_STATE_AUX)
  49. #define WCD_CLSH_STATE_EAR_AUX (WCD_CLSH_STATE_EAR | \
  50. WCD_CLSH_STATE_AUX)
  51. #define WCD_CLSH_STATE_HPHL_EAR (WCD_CLSH_STATE_HPHL | \
  52. WCD_CLSH_STATE_EAR)
  53. #define WCD_CLSH_STATE_HPHR_EAR (WCD_CLSH_STATE_HPHR | \
  54. WCD_CLSH_STATE_EAR)
  55. #define WCD_CLSH_STATE_HPH_ST_EAR (WCD_CLSH_STATE_HPH_ST | \
  56. WCD_CLSH_STATE_EAR)
  57. enum {
  58. CLS_H_NORMAL = 0, /* Class-H Default */
  59. CLS_H_HIFI, /* Class-H HiFi */
  60. CLS_H_LP, /* Class-H Low Power */
  61. CLS_AB, /* Class-AB Low HIFI*/
  62. CLS_H_LOHIFI, /* LoHIFI */
  63. CLS_H_ULP, /* Ultra Low power */
  64. CLS_AB_HIFI, /* Class-AB */
  65. CLS_NONE, /* None of the above modes */
  66. };
  67. /* Class H data that the codec driver will maintain */
  68. struct wcd_clsh_cdc_info {
  69. u8 state;
  70. int flyback_users;
  71. int buck_users;
  72. int interpolator_modes[WCD_CLSH_STATE_MAX];
  73. };
  74. #ifdef CONFIG_SND_SOC_WCD9XXX_V2
  75. extern void wcd_cls_h_fsm(struct snd_soc_codec *codec,
  76. struct wcd_clsh_cdc_info *cdc_clsh_d,
  77. u8 clsh_event, u8 req_state,
  78. int int_mode);
  79. extern void wcd_cls_h_init(struct wcd_clsh_cdc_info *clsh);
  80. #else
  81. extern void wcd_cls_h_fsm(struct snd_soc_codec *codec,
  82. struct wcd_clsh_cdc_info *cdc_clsh_d,
  83. u8 clsh_event, u8 req_state,
  84. int int_mode)
  85. {
  86. }
  87. extern void wcd_cls_h_init(struct wcd_clsh_cdc_info *clsh)
  88. {
  89. }
  90. #endif /* CONFIG_SND_SOC_WCD9XXX_V2 */
  91. #endif