1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * sst_mfld_platform.h - Intel MID Platform driver header file
5 * Copyright (C) 2010 Intel Corp
6 * Author: Vinod Koul <vinod.koul@intel.com>
7 * Author: Harsha Priya <priya.harsha@intel.com>
8 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13 #ifndef __SST_PLATFORMDRV_H__
14 #define __SST_PLATFORMDRV_H__
16 #include "sst-mfld-dsp.h"
17 #include "sst-atom-controls.h"
19 extern struct sst_device *sst;
20 extern const struct snd_compress_ops sst_platform_compress_ops;
22 #define DRV_NAME "sst"
28 #define SST_MAX_BUFFER (800*1024)
29 #define SST_MIN_BUFFER (800*1024)
30 #define SST_MIN_PERIOD_BYTES 32
31 #define SST_MAX_PERIOD_BYTES SST_MAX_BUFFER
32 #define SST_MIN_PERIODS 2
33 #define SST_MAX_PERIODS (1024*2)
34 #define SST_FIFO_SIZE 0
36 struct pcm_stream_info {
39 void (*period_elapsed) (void *arg);
40 unsigned long long buffer_ptr;
41 unsigned long long pcm_delay;
46 SST_PLATFORM_INIT = 1,
54 STREAM_OPS_PLAYBACK = 0,
58 enum sst_audio_device_type {
59 SND_SST_DEVICE_HEADSET = 1,
62 SND_SST_DEVICE_HAPTIC,
63 SND_SST_DEVICE_CAPTURE,
64 SND_SST_DEVICE_COMPRESS,
68 struct sst_pcm_params {
69 u16 codec; /* codec type */
70 u8 num_chan; /* 1=Mono, 2=Stereo */
71 u8 pcm_wd_sz; /* 16/24 - bit*/
72 u32 reserved; /* Bitrate in bits per second */
73 u32 sfreq; /* Sampling rate in Hz */
75 u32 period_count; /* period elapsed in samples*/
79 struct sst_stream_params {
86 struct sst_pcm_params sparams;
89 struct sst_compress_cb {
91 void (*compr_cb)(void *param);
93 void (*drain_notify)(void *param);
96 struct compress_sst_ops {
98 int (*open)(struct device *dev,
99 struct snd_sst_params *str_params, struct sst_compress_cb *cb);
100 int (*stream_start)(struct device *dev, unsigned int str_id);
101 int (*stream_drop)(struct device *dev, unsigned int str_id);
102 int (*stream_drain)(struct device *dev, unsigned int str_id);
103 int (*stream_partial_drain)(struct device *dev, unsigned int str_id);
104 int (*stream_pause)(struct device *dev, unsigned int str_id);
105 int (*stream_pause_release)(struct device *dev, unsigned int str_id);
107 int (*tstamp)(struct device *dev, unsigned int str_id,
108 struct snd_compr_tstamp *tstamp);
109 int (*ack)(struct device *dev, unsigned int str_id,
110 unsigned long bytes);
111 int (*close)(struct device *dev, 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 int (*set_metadata)(struct device *dev, unsigned int str_id,
115 struct snd_compr_metadata *mdata);
116 int (*power)(struct device *dev, bool state);
120 int (*open)(struct device *dev, struct snd_sst_params *str_param);
121 int (*stream_init)(struct device *dev, struct pcm_stream_info *str_info);
122 int (*stream_start)(struct device *dev, int str_id);
123 int (*stream_drop)(struct device *dev, int str_id);
124 int (*stream_pause)(struct device *dev, int str_id);
125 int (*stream_pause_release)(struct device *dev, int str_id);
126 int (*stream_read_tstamp)(struct device *dev, struct pcm_stream_info *str_info);
127 int (*send_byte_stream)(struct device *dev, struct snd_sst_bytes_v2 *bytes);
128 int (*close)(struct device *dev, unsigned int str_id);
129 int (*power)(struct device *dev, bool state);
132 struct sst_runtime_stream {
135 size_t bytes_written;
136 struct pcm_stream_info stream_info;
138 struct compress_sst_ops *compr_ops;
139 spinlock_t status_lock;
146 struct platform_device *pdev;
147 struct compress_sst_ops *compr_ops;
152 int sst_dsp_init_v2_dpcm(struct snd_soc_component *component);
153 int sst_send_pipe_gains(struct snd_soc_dai *dai, int stream, int mute);
154 int send_ssp_cmd(struct snd_soc_dai *dai, const char *id, bool enable);
155 int sst_handle_vb_timer(struct snd_soc_dai *dai, bool enable);
157 void sst_set_stream_status(struct sst_runtime_stream *stream, int state);
158 int sst_fill_stream_params(void *substream, const struct sst_data *ctx,
159 struct snd_sst_params *str_params, bool is_compress);
161 struct sst_algo_int_control_v2 {
162 struct soc_mixer_control mc;
163 u16 module_id; /* module identifieer */
164 u16 pipe_id; /* location info: pipe_id + instance_id */
166 unsigned int value; /* Value received is stored here */
169 struct platform_device *pdev;
170 struct sst_platform_data *pdata;
171 struct snd_sst_bytes_v2 *byte_stream;
173 struct snd_soc_card *soc_card;
174 struct sst_cmd_sba_hw_set_ssp ssp_cmd;
176 int sst_register_dsp(struct sst_device *dev);
177 int sst_unregister_dsp(struct sst_device *dev);