AudDrv_OffloadCommon.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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 <mach/irqs.h>
  42. #include <mach/sync_write.h>
  43. #include <linux/xlog.h>
  44. #include <mach/mt_typedefs.h>*/
  45. #include "AudDrv_Def.h"
  46. #ifndef CONFIG_MTK_CLKMGR
  47. #include <linux/clk.h>
  48. #else
  49. #include <mach/mt_clkmgr.h>
  50. #endif
  51. #include <sound/compress_driver.h>
  52. #include <sound/pcm.h>
  53. #include "AudDrv_Common.h"
  54. /***********************************************************************************
  55. ** OFFLOAD Service Control Message
  56. ************************************************************************************/
  57. #define OFFLOAD_DEVNAME "offloadservice"
  58. #define OFFLOAD_IOC_MAGIC 'a'
  59. /* below is control message */
  60. #define OFFLOADSERVICE_WRITEBLOCK _IO(OFFLOAD_IOC_MAGIC, 0x01)
  61. #define OFFLOADSERVICE_SETGAIN _IO(OFFLOAD_IOC_MAGIC, 0x02)
  62. #define OFFLOADSERVICE_SETMODE _IO(OFFLOAD_IOC_MAGIC, 0x03)
  63. #define OFFLOAD_STATE_INIT 0x1
  64. #define OFFLOAD_STATE_IDLE 0x2
  65. #define OFFLOAD_STATE_PREPARE 0x3
  66. #define OFFLOAD_STATE_RUNNING 0x4
  67. #define OFFLOAD_STATE_PAUSED 0x5
  68. #define OFFLOAD_STATE_DRAIN 0x6
  69. struct AFE_OFFLOAD_T { /* doug */
  70. kal_uint32 data_buffer_size;
  71. void *data_buffer_area;
  72. kal_uint32 temp_buffer_size;
  73. kal_int8 *temp_buffer_area;
  74. kal_int32 u4WriteIdx; /* Previous Write Index. */
  75. kal_int32 u4ReadIdx; /* Previous Write Index. */
  76. kal_uint32 length;
  77. kal_uint32 state;
  78. kal_uint32 pre_state;
  79. kal_uint32 samplerate;
  80. kal_uint32 period_size;
  81. kal_uint32 channels;
  82. kal_uint32 pcmformat;
  83. struct snd_compr_stream *compr_stream;
  84. struct snd_pcm_substream *pcm_stream;
  85. kal_uint32 hw_buffer_size;
  86. kal_uint32 hw_buffer_addr; /* physical address */
  87. kal_int8 *hw_buffer_area; /* virtual pointer */
  88. kal_uint64 copied_total;
  89. kal_uint64 transferred;
  90. kal_uint64 copied;
  91. bool write_blocked;
  92. bool firstbuf;
  93. bool wakelock;
  94. };
  95. struct AFE_OFFLOAD_SERVICE_T {
  96. bool write_blocked;
  97. bool enable;
  98. int offload_mode;
  99. void (*setVol)(int vol);
  100. int hw_gain;
  101. };
  102. enum {
  103. OFFLOAD_MODE_GDMA = 0,
  104. OFFLOAD_MODE_SW,
  105. OFFLOAD_MODE_DSP,
  106. };
  107. void OffloadService_SetWriteblocked(bool flag);
  108. void OffloadService_ReleaseWriteblocked(void);
  109. void OffloadService_SetVolumeCbk(void (*setVol) (int vol));
  110. int OffloadService_GetOffloadMode(void);
  111. void OffloadService_SetEnable(bool enable);
  112. bool OffloadService_GetEnable(void);
  113. int OffloadService_GetVolume(void);
  114. #endif