sst_platform.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. * sst_platform.h - Intel MID Platform driver header file
  3. *
  4. * Copyright (C) 2010 Intel Corp
  5. * Author: Vinod Koul <vinod.koul@intel.com>
  6. * Author: Harsha Priya <priya.harsha@intel.com>
  7. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; version 2 of the License.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program; if not, write to the Free Software Foundation, Inc.,
  20. * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  21. *
  22. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  23. *
  24. *
  25. */
  26. #ifndef __SST_PLATFORMDRV_H__
  27. #define __SST_PLATFORMDRV_H__
  28. #include "sst_dsp.h"
  29. #define SST_MONO 1
  30. #define SST_STEREO 2
  31. #define SST_MAX_CAP 5
  32. #define SST_MIN_RATE 8000
  33. #define SST_MAX_RATE 48000
  34. #define SST_MIN_CHANNEL 1
  35. #define SST_MAX_CHANNEL 5
  36. #define SST_MAX_BUFFER (800*1024)
  37. #define SST_MIN_BUFFER (800*1024)
  38. #define SST_MIN_PERIOD_BYTES 32
  39. #define SST_MAX_PERIOD_BYTES SST_MAX_BUFFER
  40. #define SST_MIN_PERIODS 2
  41. #define SST_MAX_PERIODS (1024*2)
  42. #define SST_FIFO_SIZE 0
  43. struct pcm_stream_info {
  44. int str_id;
  45. void *mad_substream;
  46. void (*period_elapsed) (void *mad_substream);
  47. unsigned long long buffer_ptr;
  48. int sfreq;
  49. };
  50. enum sst_drv_status {
  51. SST_PLATFORM_INIT = 1,
  52. SST_PLATFORM_STARTED,
  53. SST_PLATFORM_RUNNING,
  54. SST_PLATFORM_PAUSED,
  55. SST_PLATFORM_DROPPED,
  56. };
  57. enum sst_controls {
  58. SST_SND_ALLOC = 0x00,
  59. SST_SND_PAUSE = 0x01,
  60. SST_SND_RESUME = 0x02,
  61. SST_SND_DROP = 0x03,
  62. SST_SND_FREE = 0x04,
  63. SST_SND_BUFFER_POINTER = 0x05,
  64. SST_SND_STREAM_INIT = 0x06,
  65. SST_SND_START = 0x07,
  66. SST_MAX_CONTROLS = 0x07,
  67. };
  68. enum sst_stream_ops {
  69. STREAM_OPS_PLAYBACK = 0,
  70. STREAM_OPS_CAPTURE,
  71. };
  72. enum sst_audio_device_type {
  73. SND_SST_DEVICE_HEADSET = 1,
  74. SND_SST_DEVICE_IHF,
  75. SND_SST_DEVICE_VIBRA,
  76. SND_SST_DEVICE_HAPTIC,
  77. SND_SST_DEVICE_CAPTURE,
  78. SND_SST_DEVICE_COMPRESS,
  79. };
  80. /* PCM Parameters */
  81. struct sst_pcm_params {
  82. u16 codec; /* codec type */
  83. u8 num_chan; /* 1=Mono, 2=Stereo */
  84. u8 pcm_wd_sz; /* 16/24 - bit*/
  85. u32 reserved; /* Bitrate in bits per second */
  86. u32 sfreq; /* Sampling rate in Hz */
  87. u32 ring_buffer_size;
  88. u32 period_count; /* period elapsed in samples*/
  89. u32 ring_buffer_addr;
  90. };
  91. struct sst_stream_params {
  92. u32 result;
  93. u32 stream_id;
  94. u8 codec;
  95. u8 ops;
  96. u8 stream_type;
  97. u8 device_type;
  98. struct sst_pcm_params sparams;
  99. };
  100. struct sst_compress_cb {
  101. void *param;
  102. void (*compr_cb)(void *param);
  103. };
  104. struct compress_sst_ops {
  105. const char *name;
  106. int (*open) (struct snd_sst_params *str_params,
  107. struct sst_compress_cb *cb);
  108. int (*control) (unsigned int cmd, unsigned int str_id);
  109. int (*tstamp) (unsigned int str_id, struct snd_compr_tstamp *tstamp);
  110. int (*ack) (unsigned int str_id, unsigned long bytes);
  111. int (*close) (unsigned int str_id);
  112. int (*get_caps) (struct snd_compr_caps *caps);
  113. int (*get_codec_caps) (struct snd_compr_codec_caps *codec);
  114. };
  115. struct sst_ops {
  116. int (*open) (struct sst_stream_params *str_param);
  117. int (*device_control) (int cmd, void *arg);
  118. int (*close) (unsigned int str_id);
  119. };
  120. struct sst_runtime_stream {
  121. int stream_status;
  122. unsigned int id;
  123. size_t bytes_written;
  124. struct pcm_stream_info stream_info;
  125. struct sst_ops *ops;
  126. struct compress_sst_ops *compr_ops;
  127. spinlock_t status_lock;
  128. };
  129. struct sst_device {
  130. char *name;
  131. struct device *dev;
  132. struct sst_ops *ops;
  133. struct compress_sst_ops *compr_ops;
  134. };
  135. int sst_register_dsp(struct sst_device *sst);
  136. int sst_unregister_dsp(struct sst_device *sst);
  137. #endif