audio_policy.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. * Copyright (c) 2016 Actions Semi Co., Inc.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /**
  7. * @file
  8. * @brief audio policy.
  9. */
  10. #ifndef __AUDIO_POLICY_H__
  11. #define __AUDIO_POLICY_H__
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. #include <audio_hal.h>
  16. #include <media_effect_param.h>
  17. /**
  18. * @defgroup audio_policy_apis Auido policy APIs
  19. * @{
  20. */
  21. struct audio_policy_t {
  22. uint8_t audio_out_channel;
  23. uint8_t tts_fixed_volume:1;
  24. uint8_t volume_saveto_nvram:1;
  25. uint8_t audio_out_volume_level;
  26. uint8_t tts_max_volume;
  27. uint8_t tts_min_volume;
  28. s16_t audio_in_linein_gain;
  29. s16_t audio_in_fm_gain;
  30. s16_t audio_in_mic_gain;
  31. uint8_t voice_aec_tail_length_8k;
  32. uint8_t voice_aec_tail_length_16k;
  33. const short *music_da_table; /* 0.1 dB */
  34. const int *music_pa_table; /* 0.001 dB */
  35. const short *voice_da_table; /* 0.1 dB */
  36. const int *voice_pa_table; /* 0.001 dB */
  37. const short *usound_da_table; /* 0.1 dB */
  38. const int *usound_pa_table; /* 0.001 dB */
  39. const short *tts_da_table; /* 0.1 dB */
  40. const int *tts_pa_table; /* 0.001 dB */
  41. aset_volume_table_v2_t *aset_volume_table;
  42. };
  43. typedef enum {
  44. AEC_REF_TYPE_SF = 1,
  45. AEC_REF_TYPE_HW = 2,
  46. } aec_type;
  47. /**
  48. * @cond INTERNAL_HIDDEN
  49. */
  50. int audio_policy_get_out_channel_type(uint8_t stream_type);
  51. int audio_policy_get_out_channel_id(uint8_t stream_type);
  52. int audio_policy_get_out_channel_mode(uint8_t stream_type);
  53. /* return 0 for decoder decided */
  54. int audio_policy_get_out_pcm_channel_num(uint8_t stream_type);
  55. int audio_policy_get_out_pcm_frame_size(uint8_t stream_type);
  56. int audio_policy_get_out_channel_asrc_alloc_method(uint8_t stream_type);
  57. int audio_policy_get_out_input_start_threshold(uint8_t stream_type,
  58. uint8_t exf_stream_type, uint8_t sample_rate, uint8_t channels, uint8_t tws_mode, uint8_t format);
  59. int audio_policy_get_out_input_stop_threshold(uint8_t stream_type,
  60. uint8_t exf_stream_type, uint8_t sample_rate, uint8_t channels, uint8_t tws_mode);
  61. int audio_policy_get_out_audio_mode(uint8_t stream_type);
  62. uint8_t audio_policy_get_out_effect_type(uint8_t stream_type,
  63. uint8_t efx_stream_type, bool is_tws);
  64. int audio_policy_is_out_channel_aec_reference(uint8_t stream_type);
  65. int audio_policy_is_out_channel_aec_reference(uint8_t stream_type);
  66. uint8_t audio_policy_get_record_effect_type(uint8_t stream_type,
  67. uint8_t efx_stream_type);
  68. int audio_policy_get_record_audio_mode(uint8_t stream_type);
  69. int audio_policy_get_record_channel_id(uint8_t stream_type);
  70. int audio_policy_get_record_adc_gain(uint8_t stream_type);
  71. int audio_policy_get_record_input_gain(uint8_t stream_type);
  72. int audio_policy_get_record_channel_mode(uint8_t stream_type);
  73. int audio_policy_get_record_channel_type(uint8_t stream_type);
  74. int audio_policy_get_volume_level(void);
  75. /* return volume in 0.001 dB */
  76. int audio_policy_get_pa_volume(uint8_t stream_type, uint8_t volume_level);
  77. int audio_policy_get_pa_class(uint8_t stream_type);
  78. /* return volume in 0.1 dB */
  79. int audio_policy_get_da_volume(uint8_t stream_type, uint8_t volume_level);
  80. int audio_policy_get_record_channel_support_aec(uint8_t stream_type);
  81. int audio_policy_get_record_channel_aec_tail_length(uint8_t stream_type, uint8_t sample_rate, bool in_debug);
  82. int audio_policy_get_channel_resample(uint8_t stream_type);
  83. int audio_policy_get_output_support_multi_track(uint8_t stream_type);
  84. int audio_policy_check_tts_fixed_volume();
  85. int audio_policy_check_save_volume_to_nvram(void);
  86. int audio_policy_get_increase_threshold(int format);
  87. int audio_policy_get_reduce_threshold(int format);
  88. /* @volume_db in 0.1 dB */
  89. int audio_policy_get_volume_level_by_db(uint8_t stream_type, int volume_db);
  90. aset_volume_table_v2_t *audio_policy_get_aset_volume_table(void);
  91. int audio_policy_is_master_mix_channel(uint8_t stream_type);
  92. int audio_policy_get_record_aec_block_size(uint8_t format_type);
  93. int audio_policy_get_record_channel_mix_channel(uint8_t stream_type);
  94. int audio_policy_get_aec_reference_type(void);
  95. int audio_policy_get_out_channel_aec_reference_stream_type(uint8_t stream_type);
  96. int audio_policy_check_snoop_tws_support(void);
  97. /**
  98. * INTERNAL_HIDDEN @endcond
  99. */
  100. /**
  101. * @brief Register user audio policy to audio system
  102. *
  103. * This routine Register user audio policy to audio system, must be called when system
  104. * init. if not set user audio policy ,system may used default policy for audio system.
  105. *
  106. * @param user_policy user sudio policy
  107. *
  108. * @return 0 excute successed , others failed
  109. */
  110. int audio_policy_register(const struct audio_policy_t *user_policy);
  111. /**
  112. * @} end defgroup audio_policy_apis
  113. */
  114. #ifdef __cplusplus
  115. }
  116. #endif
  117. #endif