sst-mfld-platform.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /*
  2. * sst_mfld_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. * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  19. */
  20. #ifndef __SST_PLATFORMDRV_H__
  21. #define __SST_PLATFORMDRV_H__
  22. #include "sst-mfld-dsp.h"
  23. #include "sst-atom-controls.h"
  24. extern struct sst_device *sst;
  25. extern struct snd_compr_ops sst_platform_compr_ops;
  26. #define SST_MONO 1
  27. #define SST_STEREO 2
  28. #define SST_MAX_CAP 5
  29. #define SST_MAX_BUFFER (800*1024)
  30. #define SST_MIN_BUFFER (800*1024)
  31. #define SST_MIN_PERIOD_BYTES 32
  32. #define SST_MAX_PERIOD_BYTES SST_MAX_BUFFER
  33. #define SST_MIN_PERIODS 2
  34. #define SST_MAX_PERIODS (1024*2)
  35. #define SST_FIFO_SIZE 0
  36. struct pcm_stream_info {
  37. int str_id;
  38. void *arg;
  39. void (*period_elapsed) (void *arg);
  40. unsigned long long buffer_ptr;
  41. unsigned long long pcm_delay;
  42. int sfreq;
  43. };
  44. enum sst_drv_status {
  45. SST_PLATFORM_INIT = 1,
  46. SST_PLATFORM_STARTED,
  47. SST_PLATFORM_RUNNING,
  48. SST_PLATFORM_PAUSED,
  49. SST_PLATFORM_DROPPED,
  50. };
  51. enum sst_stream_ops {
  52. STREAM_OPS_PLAYBACK = 0,
  53. STREAM_OPS_CAPTURE,
  54. };
  55. enum sst_audio_device_type {
  56. SND_SST_DEVICE_HEADSET = 1,
  57. SND_SST_DEVICE_IHF,
  58. SND_SST_DEVICE_VIBRA,
  59. SND_SST_DEVICE_HAPTIC,
  60. SND_SST_DEVICE_CAPTURE,
  61. SND_SST_DEVICE_COMPRESS,
  62. };
  63. /* PCM Parameters */
  64. struct sst_pcm_params {
  65. u16 codec; /* codec type */
  66. u8 num_chan; /* 1=Mono, 2=Stereo */
  67. u8 pcm_wd_sz; /* 16/24 - bit*/
  68. u32 reserved; /* Bitrate in bits per second */
  69. u32 sfreq; /* Sampling rate in Hz */
  70. u32 ring_buffer_size;
  71. u32 period_count; /* period elapsed in samples*/
  72. u32 ring_buffer_addr;
  73. };
  74. struct sst_stream_params {
  75. u32 result;
  76. u32 stream_id;
  77. u8 codec;
  78. u8 ops;
  79. u8 stream_type;
  80. u8 device_type;
  81. struct sst_pcm_params sparams;
  82. };
  83. struct sst_compress_cb {
  84. void *param;
  85. void (*compr_cb)(void *param);
  86. void *drain_cb_param;
  87. void (*drain_notify)(void *param);
  88. };
  89. struct compress_sst_ops {
  90. const char *name;
  91. int (*open)(struct device *dev,
  92. struct snd_sst_params *str_params, struct sst_compress_cb *cb);
  93. int (*stream_start)(struct device *dev, unsigned int str_id);
  94. int (*stream_drop)(struct device *dev, unsigned int str_id);
  95. int (*stream_drain)(struct device *dev, unsigned int str_id);
  96. int (*stream_partial_drain)(struct device *dev, unsigned int str_id);
  97. int (*stream_pause)(struct device *dev, unsigned int str_id);
  98. int (*stream_pause_release)(struct device *dev, unsigned int str_id);
  99. int (*tstamp)(struct device *dev, unsigned int str_id,
  100. struct snd_compr_tstamp *tstamp);
  101. int (*ack)(struct device *dev, unsigned int str_id,
  102. unsigned long bytes);
  103. int (*close)(struct device *dev, unsigned int str_id);
  104. int (*get_caps)(struct snd_compr_caps *caps);
  105. int (*get_codec_caps)(struct snd_compr_codec_caps *codec);
  106. int (*set_metadata)(struct device *dev, unsigned int str_id,
  107. struct snd_compr_metadata *mdata);
  108. int (*power)(struct device *dev, bool state);
  109. };
  110. struct sst_ops {
  111. int (*open)(struct device *dev, struct snd_sst_params *str_param);
  112. int (*stream_init)(struct device *dev, struct pcm_stream_info *str_info);
  113. int (*stream_start)(struct device *dev, int str_id);
  114. int (*stream_drop)(struct device *dev, int str_id);
  115. int (*stream_pause)(struct device *dev, int str_id);
  116. int (*stream_pause_release)(struct device *dev, int str_id);
  117. int (*stream_read_tstamp)(struct device *dev, struct pcm_stream_info *str_info);
  118. int (*send_byte_stream)(struct device *dev, struct snd_sst_bytes_v2 *bytes);
  119. int (*close)(struct device *dev, unsigned int str_id);
  120. int (*power)(struct device *dev, bool state);
  121. };
  122. struct sst_runtime_stream {
  123. int stream_status;
  124. unsigned int id;
  125. size_t bytes_written;
  126. struct pcm_stream_info stream_info;
  127. struct sst_ops *ops;
  128. struct compress_sst_ops *compr_ops;
  129. spinlock_t status_lock;
  130. };
  131. struct sst_device {
  132. char *name;
  133. struct device *dev;
  134. struct sst_ops *ops;
  135. struct platform_device *pdev;
  136. struct compress_sst_ops *compr_ops;
  137. };
  138. struct sst_data;
  139. int sst_dsp_init_v2_dpcm(struct snd_soc_platform *platform);
  140. int sst_send_pipe_gains(struct snd_soc_dai *dai, int stream, int mute);
  141. int send_ssp_cmd(struct snd_soc_dai *dai, const char *id, bool enable);
  142. int sst_handle_vb_timer(struct snd_soc_dai *dai, bool enable);
  143. void sst_set_stream_status(struct sst_runtime_stream *stream, int state);
  144. int sst_fill_stream_params(void *substream, const struct sst_data *ctx,
  145. struct snd_sst_params *str_params, bool is_compress);
  146. struct sst_algo_int_control_v2 {
  147. struct soc_mixer_control mc;
  148. u16 module_id; /* module identifieer */
  149. u16 pipe_id; /* location info: pipe_id + instance_id */
  150. u16 instance_id;
  151. unsigned int value; /* Value received is stored here */
  152. };
  153. struct sst_data {
  154. struct platform_device *pdev;
  155. struct sst_platform_data *pdata;
  156. struct snd_sst_bytes_v2 *byte_stream;
  157. struct mutex lock;
  158. struct snd_soc_card *soc_card;
  159. struct sst_cmd_sba_hw_set_ssp ssp_cmd;
  160. };
  161. int sst_register_dsp(struct sst_device *sst);
  162. int sst_unregister_dsp(struct sst_device *sst);
  163. #endif