AudDrv_OffloadCommon.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /******************************************************************************
  2. *
  3. *
  4. * Filename:
  5. * ---------
  6. * AudDrv_OffloadCommon.h
  7. *
  8. * Project:
  9. * --------
  10. * None
  11. *
  12. * Description:
  13. * ------------
  14. * Audio Offload Kernel Definitions
  15. *
  16. * Author:
  17. * -------
  18. * Doug Wang
  19. *
  20. *---------------------------------------------------------------------------
  21. ---
  22. *
  23. *******************************************************************************/
  24. #ifndef AUDIO_OFFLOAD_COMMON_H
  25. #define AUDIO_OFFLOAD_COMMON_H
  26. #include <linux/kernel.h>
  27. #include <linux/module.h>
  28. #include <linux/slab.h>
  29. #include <linux/fs.h>
  30. #include <linux/mm.h>
  31. #include <linux/delay.h>
  32. #include <linux/vmalloc.h>
  33. #include <linux/wait.h>
  34. #include <linux/spinlock.h>
  35. #include <linux/sched.h>
  36. #include <linux/jiffies.h>
  37. #include <linux/string.h>
  38. #include <linux/mutex.h>
  39. #include <linux/time.h>
  40. #include <linux/timer.h>
  41. #include "AudDrv_Def.h"
  42. #include <linux/clk.h>
  43. #include <sound/compress_driver.h>
  44. #include <sound/pcm.h>
  45. /***********************************************************************************
  46. ** OFFLOAD Service Control Message
  47. ************************************************************************************/
  48. #define OFFLOAD_DEVNAME "offloadservice"
  49. #define OFFLOAD_IOC_MAGIC 'a'
  50. /* below is control message */
  51. #define OFFLOADSERVICE_WRITEBLOCK _IO(OFFLOAD_IOC_MAGIC, 0x01)
  52. #define OFFLOADSERVICE_SETGAIN _IO(OFFLOAD_IOC_MAGIC, 0x02)
  53. #define OFFLOADSERVICE_SETMODE _IO(OFFLOAD_IOC_MAGIC, 0x03)
  54. #define OFFLOAD_STATE_INIT 0x1
  55. #define OFFLOAD_STATE_IDLE 0x2
  56. #define OFFLOAD_STATE_PREPARE 0x3
  57. #define OFFLOAD_STATE_RUNNING 0x4
  58. #define OFFLOAD_STATE_PAUSED 0x5
  59. #define OFFLOAD_STATE_DRAIN 0x6
  60. struct AFE_OFFLOAD_T { /* doug */
  61. kal_uint32 data_buffer_size;
  62. void *data_buffer_area;
  63. kal_uint32 temp_buffer_size;
  64. kal_int8 *temp_buffer_area;
  65. kal_int32 u4WriteIdx; /* Previous Write Index. */
  66. kal_int32 u4ReadIdx; /* Previous Write Index. */
  67. kal_uint32 length;
  68. kal_uint32 state;
  69. kal_uint32 pre_state;
  70. kal_uint32 samplerate;
  71. kal_uint32 period_size;
  72. kal_uint32 channels;
  73. kal_uint32 pcmformat;
  74. struct snd_compr_stream *compr_stream;
  75. struct snd_pcm_substream *pcm_stream;
  76. kal_uint32 hw_buffer_size;
  77. kal_uint32 hw_buffer_addr; /* physical address */
  78. kal_int8 *hw_buffer_area; /* virtual pointer */
  79. kal_uint64 copied_total;
  80. kal_uint64 transferred;
  81. kal_uint64 copied;
  82. bool write_blocked;
  83. bool firstbuf;
  84. bool wakelock;
  85. };
  86. struct AFE_OFFLOAD_SERVICE_T {
  87. bool write_blocked;
  88. bool enable;
  89. int offload_mode;
  90. void (*setVol)(int vol);
  91. int hw_gain;
  92. };
  93. enum {
  94. OFFLOAD_MODE_GDMA = 0,
  95. OFFLOAD_MODE_SW,
  96. OFFLOAD_MODE_DSP,
  97. };
  98. void OffloadService_SetWriteblocked(bool flag);
  99. void OffloadService_ReleaseWriteblocked(void);
  100. void OffloadService_SetVolumeCbk(void (*setVol) (int vol));
  101. int OffloadService_GetOffloadMode(void);
  102. void OffloadService_SetEnable(bool enable);
  103. bool OffloadService_GetEnable(void);
  104. int OffloadService_GetVolume(void);
  105. #endif