soc-dai.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #include "board.h"
  2. #include "os_adapt.h"
  3. #include "FreeRTOS.h"
  4. #include "soc-dai.h"
  5. #include <string.h>
  6. #include <stdio.h>
  7. #define MAX_CODEC_NUM 4
  8. static struct codec_register_inf codec_tab[MAX_CODEC_NUM] = {0};
  9. static int codec_count = 0;
  10. extern void es7243e_init(void);
  11. extern void es8156_init(void);
  12. int audio_codec_register(struct codec_register_inf codec_reg_info)
  13. {
  14. if (codec_count < MAX_CODEC_NUM) {
  15. codec_tab[codec_count++] = codec_reg_info;
  16. } else {
  17. printf("%s, failed to register the codec!\n", __func__);
  18. return -1;
  19. }
  20. return 0;
  21. }
  22. struct codec_register_inf *get_codec_register_inf(const char *name)
  23. {
  24. int i;
  25. if (!name) {
  26. printf("%s, name null !\n", __func__);
  27. return NULL;
  28. }
  29. for (i=0; i<MAX_CODEC_NUM; i++) {
  30. if (strcmp(name, codec_tab[i].name) == 0) {
  31. return &codec_tab[i];
  32. }
  33. }
  34. return NULL;
  35. }
  36. void audio_codec_init(void)
  37. {
  38. #if (AUDIO_CODEC_ADC_IC == AUDIO_CODEC_ADC_ES7243E)
  39. es7243e_init();
  40. #endif
  41. #if (AUDIO_CODEC_DAC_IC == AUDIO_CODEC_DAC_ES8156)
  42. es8156_init();
  43. #endif
  44. }