sst-mfld-platform.h 5.1 KB

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