msm-adie-codec.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. #ifndef __LINUX_MFD_MSM_ADIE_CODEC_H
  2. #define __LINUX_MFD_MSM_ADIE_CODEC_H
  3. #include <linux/types.h>
  4. /* Value Represents a entry */
  5. #define ADIE_CODEC_ACTION_ENTRY 0x1
  6. /* Value representing a delay wait */
  7. #define ADIE_CODEC_ACTION_DELAY_WAIT 0x2
  8. /* Value representing a stage reached */
  9. #define ADIE_CODEC_ACTION_STAGE_REACHED 0x3
  10. /* This value is the state after the client sets the path */
  11. #define ADIE_CODEC_PATH_OFF 0x0050
  12. /* State to which client asks the drv to proceed to where it can
  13. * set up the clocks and 0-fill PCM buffers
  14. */
  15. #define ADIE_CODEC_DIGITAL_READY 0x0100
  16. /* State to which client asks the drv to proceed to where it can
  17. * start sending data after internal steady state delay
  18. */
  19. #define ADIE_CODEC_DIGITAL_ANALOG_READY 0x1000
  20. /* Client Asks adie to switch off the Analog portion of the
  21. * the internal codec. After the use of this path
  22. */
  23. #define ADIE_CODEC_ANALOG_OFF 0x0750
  24. /* Client Asks adie to switch off the digital portion of the
  25. * the internal codec. After switching off the analog portion.
  26. *
  27. * 0-fill PCM may or maynot be sent at this point
  28. *
  29. */
  30. #define ADIE_CODEC_DIGITAL_OFF 0x0600
  31. /* State to which client asks the drv to write the default values
  32. * to the registers */
  33. #define ADIE_CODEC_FLASH_IMAGE 0x0001
  34. /* Path type */
  35. #define ADIE_CODEC_RX 0
  36. #define ADIE_CODEC_TX 1
  37. #define ADIE_CODEC_LB 3
  38. #define ADIE_CODEC_MAX 4
  39. #define ADIE_CODEC_PACK_ENTRY(reg, mask, val) ((val)|(mask << 8)|(reg << 16))
  40. #define ADIE_CODEC_UNPACK_ENTRY(packed, reg, mask, val) \
  41. do { \
  42. ((reg) = ((packed >> 16) & (0xff))); \
  43. ((mask) = ((packed >> 8) & (0xff))); \
  44. ((val) = ((packed) & (0xff))); \
  45. } while (0);
  46. struct adie_codec_action_unit {
  47. u32 type;
  48. u32 action;
  49. };
  50. struct adie_codec_hwsetting_entry{
  51. struct adie_codec_action_unit *actions;
  52. u32 action_sz;
  53. u32 freq_plan;
  54. u32 osr;
  55. /* u32 VolMask;
  56. * u32 SidetoneMask;
  57. */
  58. };
  59. struct adie_codec_dev_profile {
  60. u32 path_type; /* RX or TX */
  61. u32 setting_sz;
  62. struct adie_codec_hwsetting_entry *settings;
  63. };
  64. struct adie_codec_register {
  65. u8 reg;
  66. u8 mask;
  67. u8 val;
  68. };
  69. struct adie_codec_register_image {
  70. struct adie_codec_register *regs;
  71. u32 img_sz;
  72. };
  73. struct adie_codec_path;
  74. struct adie_codec_anc_data {
  75. u32 size;
  76. u32 writes[];
  77. };
  78. struct adie_codec_operations {
  79. int codec_id;
  80. int (*codec_open) (struct adie_codec_dev_profile *profile,
  81. struct adie_codec_path **path_pptr);
  82. int (*codec_close) (struct adie_codec_path *path_ptr);
  83. int (*codec_setpath) (struct adie_codec_path *path_ptr,
  84. u32 freq_plan, u32 osr);
  85. int (*codec_proceed_stage) (struct adie_codec_path *path_ptr,
  86. u32 state);
  87. u32 (*codec_freq_supported) (struct adie_codec_dev_profile *profile,
  88. u32 requested_freq);
  89. int (*codec_enable_sidetone) (struct adie_codec_path *rx_path_ptr,
  90. u32 enable);
  91. int (*codec_enable_anc) (struct adie_codec_path *rx_path_ptr,
  92. u32 enable, struct adie_codec_anc_data *calibration_writes);
  93. int (*codec_set_device_digital_volume) (
  94. struct adie_codec_path *path_ptr,
  95. u32 num_channels,
  96. u32 vol_percentage);
  97. int (*codec_set_device_analog_volume) (struct adie_codec_path *path_ptr,
  98. u32 num_channels,
  99. u32 volume);
  100. int (*codec_set_master_mode) (struct adie_codec_path *path_ptr,
  101. u8 master);
  102. };
  103. int adie_codec_register_codec_operations(
  104. const struct adie_codec_operations *codec_ops);
  105. int adie_codec_open(struct adie_codec_dev_profile *profile,
  106. struct adie_codec_path **path_pptr);
  107. int adie_codec_setpath(struct adie_codec_path *path_ptr,
  108. u32 freq_plan, u32 osr);
  109. int adie_codec_proceed_stage(struct adie_codec_path *path_ptr, u32 state);
  110. int adie_codec_close(struct adie_codec_path *path_ptr);
  111. u32 adie_codec_freq_supported(struct adie_codec_dev_profile *profile,
  112. u32 requested_freq);
  113. int adie_codec_enable_sidetone(struct adie_codec_path *rx_path_ptr, u32 enable);
  114. int adie_codec_enable_anc(struct adie_codec_path *rx_path_ptr, u32 enable,
  115. struct adie_codec_anc_data *calibration_writes);
  116. int adie_codec_set_device_digital_volume(struct adie_codec_path *path_ptr,
  117. u32 num_channels, u32 vol_percentage /* in percentage */);
  118. int adie_codec_set_device_analog_volume(struct adie_codec_path *path_ptr,
  119. u32 num_channels, u32 volume /* in percentage */);
  120. int adie_codec_set_master_mode(struct adie_codec_path *path_ptr, u8 master);
  121. #endif