aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/soc/intel/sst-mfld-platform-pcm.c102
-rw-r--r--sound/soc/intel/sst-mfld-platform.h2
2 files changed, 71 insertions, 33 deletions
diff --git a/sound/soc/intel/sst-mfld-platform-pcm.c b/sound/soc/intel/sst-mfld-platform-pcm.c
index 80879e5fcb49..6e7bfb1bc4aa 100644
--- a/sound/soc/intel/sst-mfld-platform-pcm.c
+++ b/sound/soc/intel/sst-mfld-platform-pcm.c
@@ -143,52 +143,90 @@ static inline int sst_get_stream_status(struct sst_runtime_stream *stream)
143 return state; 143 return state;
144} 144}
145 145
146static void sst_fill_alloc_params(struct snd_pcm_substream *substream,
147 struct snd_sst_alloc_params_ext *alloc_param)
148{
149 unsigned int channels;
150 snd_pcm_uframes_t period_size;
151 ssize_t periodbytes;
152 ssize_t buffer_bytes = snd_pcm_lib_buffer_bytes(substream);
153 u32 buffer_addr = virt_to_phys(substream->dma_buffer.area);
154
155 channels = substream->runtime->channels;
156 period_size = substream->runtime->period_size;
157 periodbytes = samples_to_bytes(substream->runtime, period_size);
158 alloc_param->ring_buf_info[0].addr = buffer_addr;
159 alloc_param->ring_buf_info[0].size = buffer_bytes;
160 alloc_param->sg_count = 1;
161 alloc_param->reserved = 0;
162 alloc_param->frag_size = periodbytes * channels;
163
164}
146static void sst_fill_pcm_params(struct snd_pcm_substream *substream, 165static void sst_fill_pcm_params(struct snd_pcm_substream *substream,
147 struct sst_pcm_params *param) 166 struct snd_sst_stream_params *param)
148{ 167{
168 param->uc.pcm_params.num_chan = (u8) substream->runtime->channels;
169 param->uc.pcm_params.pcm_wd_sz = substream->runtime->sample_bits;
170 param->uc.pcm_params.sfreq = substream->runtime->rate;
149 171
150 param->num_chan = (u8) substream->runtime->channels; 172 /* PCM stream via ALSA interface */
151 param->pcm_wd_sz = substream->runtime->sample_bits; 173 param->uc.pcm_params.use_offload_path = 0;
152 param->reserved = 0; 174 param->uc.pcm_params.reserved2 = 0;
153 param->sfreq = substream->runtime->rate; 175 memset(param->uc.pcm_params.channel_map, 0, sizeof(u8));
154 param->ring_buffer_size = snd_pcm_lib_buffer_bytes(substream); 176
155 param->period_count = substream->runtime->period_size; 177}
156 param->ring_buffer_addr = virt_to_phys(substream->dma_buffer.area); 178int sst_fill_stream_params(void *substream,
157 pr_debug("period_cnt = %d\n", param->period_count); 179 struct snd_sst_params *str_params, bool is_compress)
158 pr_debug("sfreq= %d, wd_sz = %d\n", param->sfreq, param->pcm_wd_sz); 180{
181 struct snd_pcm_substream *pstream = NULL;
182 struct snd_compr_stream *cstream = NULL;
183
184 if (is_compress == true)
185 cstream = (struct snd_compr_stream *)substream;
186 else
187 pstream = (struct snd_pcm_substream *)substream;
188
189 str_params->stream_type = SST_STREAM_TYPE_MUSIC;
190
191 /* For pcm streams */
192 if (pstream)
193 str_params->ops = (u8)pstream->stream;
194 if (cstream)
195 str_params->ops = (u8)cstream->direction;
196
197 return 0;
159} 198}
160 199
161static int sst_platform_alloc_stream(struct snd_pcm_substream *substream) 200static int sst_platform_alloc_stream(struct snd_pcm_substream *substream,
201 struct snd_soc_platform *platform)
162{ 202{
163 struct sst_runtime_stream *stream = 203 struct sst_runtime_stream *stream =
164 substream->runtime->private_data; 204 substream->runtime->private_data;
165 struct sst_pcm_params param = {0}; 205 struct snd_sst_stream_params param = {{{0,},},};
166 struct sst_stream_params str_params = {0}; 206 struct snd_sst_params str_params = {0};
167 int ret_val; 207 struct snd_sst_alloc_params_ext alloc_params = {0};
208 int ret_val = 0;
168 209
169 /* set codec params and inform SST driver the same */ 210 /* set codec params and inform SST driver the same */
170 sst_fill_pcm_params(substream, &param); 211 sst_fill_pcm_params(substream, &param);
212 sst_fill_alloc_params(substream, &alloc_params);
171 substream->runtime->dma_area = substream->dma_buffer.area; 213 substream->runtime->dma_area = substream->dma_buffer.area;
172 str_params.sparams = param; 214 str_params.sparams = param;
173 str_params.codec = param.codec; 215 str_params.aparams = alloc_params;
174 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 216 str_params.codec = SST_CODEC_TYPE_PCM;
175 str_params.ops = STREAM_OPS_PLAYBACK; 217
176 str_params.device_type = substream->pcm->device + 1; 218 /* fill the device type and stream id to pass to SST driver */
177 pr_debug("Playbck stream,Device %d\n", 219 ret_val = sst_fill_stream_params(substream, &str_params, false);
178 substream->pcm->device);
179 } else {
180 str_params.ops = STREAM_OPS_CAPTURE;
181 str_params.device_type = SND_SST_DEVICE_CAPTURE;
182 pr_debug("Capture stream,Device %d\n",
183 substream->pcm->device);
184 }
185 ret_val = stream->ops->open(&str_params);
186 pr_debug("SST_SND_PLAY/CAPTURE ret_val = %x\n", ret_val);
187 if (ret_val < 0) 220 if (ret_val < 0)
188 return ret_val; 221 return ret_val;
189 222
190 stream->stream_info.str_id = ret_val; 223 stream->stream_info.str_id = str_params.stream_id;
191 pr_debug("str id : %d\n", stream->stream_info.str_id); 224
225 ret_val = stream->ops->open(&str_params);
226 if (ret_val <= 0)
227 return ret_val;
228
229
192 return ret_val; 230 return ret_val;
193} 231}
194 232
@@ -300,8 +338,8 @@ static int sst_media_prepare(struct snd_pcm_substream *substream,
300 return ret_val; 338 return ret_val;
301 } 339 }
302 340
303 ret_val = sst_platform_alloc_stream(substream); 341 ret_val = sst_platform_alloc_stream(substream, dai->platform);
304 if (ret_val < 0) 342 if (ret_val <= 0)
305 return ret_val; 343 return ret_val;
306 snprintf(substream->pcm->id, sizeof(substream->pcm->id), 344 snprintf(substream->pcm->id, sizeof(substream->pcm->id),
307 "%d", stream->stream_info.str_id); 345 "%d", stream->stream_info.str_id);
diff --git a/sound/soc/intel/sst-mfld-platform.h b/sound/soc/intel/sst-mfld-platform.h
index 33a0a2776238..aa5ddbb26d93 100644
--- a/sound/soc/intel/sst-mfld-platform.h
+++ b/sound/soc/intel/sst-mfld-platform.h
@@ -125,7 +125,7 @@ struct compress_sst_ops {
125}; 125};
126 126
127struct sst_ops { 127struct sst_ops {
128 int (*open) (struct sst_stream_params *str_param); 128 int (*open) (struct snd_sst_params *str_param);
129 int (*device_control) (int cmd, void *arg); 129 int (*device_control) (int cmd, void *arg);
130 int (*close) (unsigned int str_id); 130 int (*close) (unsigned int str_id);
131}; 131};