0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef __SST_PLATFORMDRV_H__
0014 #define __SST_PLATFORMDRV_H__
0015
0016 #include "sst-mfld-dsp.h"
0017 #include "sst-atom-controls.h"
0018
0019 extern struct sst_device *sst;
0020 extern const struct snd_compress_ops sst_platform_compress_ops;
0021
0022 #define DRV_NAME "sst"
0023
0024 #define SST_MONO 1
0025 #define SST_STEREO 2
0026 #define SST_MAX_CAP 5
0027
0028 #define SST_MAX_BUFFER (800*1024)
0029 #define SST_MIN_BUFFER (800*1024)
0030 #define SST_MIN_PERIOD_BYTES 32
0031 #define SST_MAX_PERIOD_BYTES SST_MAX_BUFFER
0032 #define SST_MIN_PERIODS 2
0033 #define SST_MAX_PERIODS (1024*2)
0034 #define SST_FIFO_SIZE 0
0035
0036 struct pcm_stream_info {
0037 int str_id;
0038 void *arg;
0039 void (*period_elapsed) (void *arg);
0040 unsigned long long buffer_ptr;
0041 unsigned long long pcm_delay;
0042 int sfreq;
0043 };
0044
0045 enum sst_drv_status {
0046 SST_PLATFORM_INIT = 1,
0047 SST_PLATFORM_STARTED,
0048 SST_PLATFORM_RUNNING,
0049 SST_PLATFORM_PAUSED,
0050 SST_PLATFORM_DROPPED,
0051 };
0052
0053 enum sst_stream_ops {
0054 STREAM_OPS_PLAYBACK = 0,
0055 STREAM_OPS_CAPTURE,
0056 };
0057
0058 enum sst_audio_device_type {
0059 SND_SST_DEVICE_HEADSET = 1,
0060 SND_SST_DEVICE_IHF,
0061 SND_SST_DEVICE_VIBRA,
0062 SND_SST_DEVICE_HAPTIC,
0063 SND_SST_DEVICE_CAPTURE,
0064 SND_SST_DEVICE_COMPRESS,
0065 };
0066
0067
0068 struct sst_pcm_params {
0069 u16 codec;
0070 u8 num_chan;
0071 u8 pcm_wd_sz;
0072 u32 reserved;
0073 u32 sfreq;
0074 u32 ring_buffer_size;
0075 u32 period_count;
0076 u32 ring_buffer_addr;
0077 };
0078
0079 struct sst_stream_params {
0080 u32 result;
0081 u32 stream_id;
0082 u8 codec;
0083 u8 ops;
0084 u8 stream_type;
0085 u8 device_type;
0086 struct sst_pcm_params sparams;
0087 };
0088
0089 struct sst_compress_cb {
0090 void *param;
0091 void (*compr_cb)(void *param);
0092 void *drain_cb_param;
0093 void (*drain_notify)(void *param);
0094 };
0095
0096 struct compress_sst_ops {
0097 const char *name;
0098 int (*open)(struct device *dev,
0099 struct snd_sst_params *str_params, struct sst_compress_cb *cb);
0100 int (*stream_start)(struct device *dev, unsigned int str_id);
0101 int (*stream_drop)(struct device *dev, unsigned int str_id);
0102 int (*stream_drain)(struct device *dev, unsigned int str_id);
0103 int (*stream_partial_drain)(struct device *dev, unsigned int str_id);
0104 int (*stream_pause)(struct device *dev, unsigned int str_id);
0105 int (*stream_pause_release)(struct device *dev, unsigned int str_id);
0106
0107 int (*tstamp)(struct device *dev, unsigned int str_id,
0108 struct snd_compr_tstamp *tstamp);
0109 int (*ack)(struct device *dev, unsigned int str_id,
0110 unsigned long bytes);
0111 int (*close)(struct device *dev, unsigned int str_id);
0112 int (*get_caps)(struct snd_compr_caps *caps);
0113 int (*get_codec_caps)(struct snd_compr_codec_caps *codec);
0114 int (*set_metadata)(struct device *dev, unsigned int str_id,
0115 struct snd_compr_metadata *mdata);
0116 int (*power)(struct device *dev, bool state);
0117 };
0118
0119 struct sst_ops {
0120 int (*open)(struct device *dev, struct snd_sst_params *str_param);
0121 int (*stream_init)(struct device *dev, struct pcm_stream_info *str_info);
0122 int (*stream_start)(struct device *dev, int str_id);
0123 int (*stream_drop)(struct device *dev, int str_id);
0124 int (*stream_pause)(struct device *dev, int str_id);
0125 int (*stream_pause_release)(struct device *dev, int str_id);
0126 int (*stream_read_tstamp)(struct device *dev, struct pcm_stream_info *str_info);
0127 int (*send_byte_stream)(struct device *dev, struct snd_sst_bytes_v2 *bytes);
0128 int (*close)(struct device *dev, unsigned int str_id);
0129 int (*power)(struct device *dev, bool state);
0130 };
0131
0132 struct sst_runtime_stream {
0133 int stream_status;
0134 unsigned int id;
0135 size_t bytes_written;
0136 struct pcm_stream_info stream_info;
0137 struct sst_ops *ops;
0138 struct compress_sst_ops *compr_ops;
0139 spinlock_t status_lock;
0140 };
0141
0142 struct sst_device {
0143 char *name;
0144 struct device *dev;
0145 struct sst_ops *ops;
0146 struct platform_device *pdev;
0147 struct compress_sst_ops *compr_ops;
0148 };
0149
0150 struct sst_data;
0151
0152 int sst_dsp_init_v2_dpcm(struct snd_soc_component *component);
0153 int sst_send_pipe_gains(struct snd_soc_dai *dai, int stream, int mute);
0154 int send_ssp_cmd(struct snd_soc_dai *dai, const char *id, bool enable);
0155 int sst_handle_vb_timer(struct snd_soc_dai *dai, bool enable);
0156
0157 void sst_set_stream_status(struct sst_runtime_stream *stream, int state);
0158 int sst_fill_stream_params(void *substream, const struct sst_data *ctx,
0159 struct snd_sst_params *str_params, bool is_compress);
0160
0161 struct sst_algo_int_control_v2 {
0162 struct soc_mixer_control mc;
0163 u16 module_id;
0164 u16 pipe_id;
0165 u16 instance_id;
0166 unsigned int value;
0167 };
0168 struct sst_data {
0169 struct platform_device *pdev;
0170 struct sst_platform_data *pdata;
0171 struct snd_sst_bytes_v2 *byte_stream;
0172 struct mutex lock;
0173 struct snd_soc_card *soc_card;
0174 struct sst_cmd_sba_hw_set_ssp ssp_cmd;
0175 };
0176 int sst_register_dsp(struct sst_device *dev);
0177 int sst_unregister_dsp(struct sst_device *dev);
0178 #endif