diff options
author | Subhransu S. Prusty <subhransu.s.prusty@intel.com> | 2014-08-21 08:50:49 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-08-27 16:48:37 -0400 |
commit | 06cb1eb3de5c905da60ab91dbf99aaf96a43d043 (patch) | |
tree | 521264b73ea351c0195dbb0fe81baf4ab5a69691 | |
parent | d8499c9b4b03ca88d7c7b4094cb09471658df7c2 (diff) |
ASoC: mfld-compress: Use dedicated function instead of ioctl
Also pass sst device as an argument to function pointer prototypes of
compr_ops. This will be used to derive sst driver context.
Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | sound/soc/intel/sst-mfld-platform-compress.c | 38 | ||||
-rw-r--r-- | sound/soc/intel/sst-mfld-platform.h | 27 |
2 files changed, 46 insertions, 19 deletions
diff --git a/sound/soc/intel/sst-mfld-platform-compress.c b/sound/soc/intel/sst-mfld-platform-compress.c index 29c059ca19e8..59467775c9b8 100644 --- a/sound/soc/intel/sst-mfld-platform-compress.c +++ b/sound/soc/intel/sst-mfld-platform-compress.c | |||
@@ -86,7 +86,7 @@ static int sst_platform_compr_free(struct snd_compr_stream *cstream) | |||
86 | /*need to check*/ | 86 | /*need to check*/ |
87 | str_id = stream->id; | 87 | str_id = stream->id; |
88 | if (str_id) | 88 | if (str_id) |
89 | ret_val = stream->compr_ops->close(str_id); | 89 | ret_val = stream->compr_ops->close(sst->dev, str_id); |
90 | module_put(sst->dev->driver->owner); | 90 | module_put(sst->dev->driver->owner); |
91 | kfree(stream); | 91 | kfree(stream); |
92 | pr_debug("%s: %d\n", __func__, ret_val); | 92 | pr_debug("%s: %d\n", __func__, ret_val); |
@@ -158,7 +158,7 @@ static int sst_platform_compr_set_params(struct snd_compr_stream *cstream, | |||
158 | cb.drain_cb_param = cstream; | 158 | cb.drain_cb_param = cstream; |
159 | cb.drain_notify = sst_drain_notify; | 159 | cb.drain_notify = sst_drain_notify; |
160 | 160 | ||
161 | retval = stream->compr_ops->open(&str_params, &cb); | 161 | retval = stream->compr_ops->open(sst->dev, &str_params, &cb); |
162 | if (retval < 0) { | 162 | if (retval < 0) { |
163 | pr_err("stream allocation failed %d\n", retval); | 163 | pr_err("stream allocation failed %d\n", retval); |
164 | return retval; | 164 | return retval; |
@@ -170,10 +170,30 @@ static int sst_platform_compr_set_params(struct snd_compr_stream *cstream, | |||
170 | 170 | ||
171 | static int sst_platform_compr_trigger(struct snd_compr_stream *cstream, int cmd) | 171 | static int sst_platform_compr_trigger(struct snd_compr_stream *cstream, int cmd) |
172 | { | 172 | { |
173 | struct sst_runtime_stream *stream = | 173 | struct sst_runtime_stream *stream = cstream->runtime->private_data; |
174 | cstream->runtime->private_data; | 174 | |
175 | 175 | switch (cmd) { | |
176 | return stream->compr_ops->control(cmd, stream->id); | 176 | case SNDRV_PCM_TRIGGER_START: |
177 | if (stream->compr_ops->stream_start) | ||
178 | return stream->compr_ops->stream_start(sst->dev, stream->id); | ||
179 | case SNDRV_PCM_TRIGGER_STOP: | ||
180 | if (stream->compr_ops->stream_drop) | ||
181 | return stream->compr_ops->stream_drop(sst->dev, stream->id); | ||
182 | case SND_COMPR_TRIGGER_DRAIN: | ||
183 | if (stream->compr_ops->stream_drain) | ||
184 | return stream->compr_ops->stream_drain(sst->dev, stream->id); | ||
185 | case SND_COMPR_TRIGGER_PARTIAL_DRAIN: | ||
186 | if (stream->compr_ops->stream_partial_drain) | ||
187 | return stream->compr_ops->stream_partial_drain(sst->dev, stream->id); | ||
188 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | ||
189 | if (stream->compr_ops->stream_pause) | ||
190 | return stream->compr_ops->stream_pause(sst->dev, stream->id); | ||
191 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | ||
192 | if (stream->compr_ops->stream_pause_release) | ||
193 | return stream->compr_ops->stream_pause_release(sst->dev, stream->id); | ||
194 | default: | ||
195 | return -EINVAL; | ||
196 | } | ||
177 | } | 197 | } |
178 | 198 | ||
179 | static int sst_platform_compr_pointer(struct snd_compr_stream *cstream, | 199 | static int sst_platform_compr_pointer(struct snd_compr_stream *cstream, |
@@ -182,7 +202,7 @@ static int sst_platform_compr_pointer(struct snd_compr_stream *cstream, | |||
182 | struct sst_runtime_stream *stream; | 202 | struct sst_runtime_stream *stream; |
183 | 203 | ||
184 | stream = cstream->runtime->private_data; | 204 | stream = cstream->runtime->private_data; |
185 | stream->compr_ops->tstamp(stream->id, tstamp); | 205 | stream->compr_ops->tstamp(sst->dev, stream->id, tstamp); |
186 | tstamp->byte_offset = tstamp->copied_total % | 206 | tstamp->byte_offset = tstamp->copied_total % |
187 | (u32)cstream->runtime->buffer_size; | 207 | (u32)cstream->runtime->buffer_size; |
188 | pr_debug("calc bytes offset/copied bytes as %d\n", tstamp->byte_offset); | 208 | pr_debug("calc bytes offset/copied bytes as %d\n", tstamp->byte_offset); |
@@ -195,7 +215,7 @@ static int sst_platform_compr_ack(struct snd_compr_stream *cstream, | |||
195 | struct sst_runtime_stream *stream; | 215 | struct sst_runtime_stream *stream; |
196 | 216 | ||
197 | stream = cstream->runtime->private_data; | 217 | stream = cstream->runtime->private_data; |
198 | stream->compr_ops->ack(stream->id, (unsigned long)bytes); | 218 | stream->compr_ops->ack(sst->dev, stream->id, (unsigned long)bytes); |
199 | stream->bytes_written += bytes; | 219 | stream->bytes_written += bytes; |
200 | 220 | ||
201 | return 0; | 221 | return 0; |
@@ -225,7 +245,7 @@ static int sst_platform_compr_set_metadata(struct snd_compr_stream *cstream, | |||
225 | struct sst_runtime_stream *stream = | 245 | struct sst_runtime_stream *stream = |
226 | cstream->runtime->private_data; | 246 | cstream->runtime->private_data; |
227 | 247 | ||
228 | return stream->compr_ops->set_metadata(stream->id, metadata); | 248 | return stream->compr_ops->set_metadata(sst->dev, stream->id, metadata); |
229 | } | 249 | } |
230 | 250 | ||
231 | struct snd_compr_ops sst_platform_compr_ops = { | 251 | struct snd_compr_ops sst_platform_compr_ops = { |
diff --git a/sound/soc/intel/sst-mfld-platform.h b/sound/soc/intel/sst-mfld-platform.h index faaba10c1dff..0c5b943daff3 100644 --- a/sound/soc/intel/sst-mfld-platform.h +++ b/sound/soc/intel/sst-mfld-platform.h | |||
@@ -99,17 +99,24 @@ struct sst_compress_cb { | |||
99 | 99 | ||
100 | struct compress_sst_ops { | 100 | struct compress_sst_ops { |
101 | const char *name; | 101 | const char *name; |
102 | int (*open) (struct snd_sst_params *str_params, | 102 | int (*open)(struct device *dev, |
103 | struct sst_compress_cb *cb); | 103 | struct snd_sst_params *str_params, struct sst_compress_cb *cb); |
104 | int (*control) (unsigned int cmd, unsigned int str_id); | 104 | int (*stream_start)(struct device *dev, unsigned int str_id); |
105 | int (*tstamp) (unsigned int str_id, struct snd_compr_tstamp *tstamp); | 105 | int (*stream_drop)(struct device *dev, unsigned int str_id); |
106 | int (*ack) (unsigned int str_id, unsigned long bytes); | 106 | int (*stream_drain)(struct device *dev, unsigned int str_id); |
107 | int (*close) (unsigned int str_id); | 107 | int (*stream_partial_drain)(struct device *dev, unsigned int str_id); |
108 | int (*get_caps) (struct snd_compr_caps *caps); | 108 | int (*stream_pause)(struct device *dev, unsigned int str_id); |
109 | int (*get_codec_caps) (struct snd_compr_codec_caps *codec); | 109 | int (*stream_pause_release)(struct device *dev, unsigned int str_id); |
110 | int (*set_metadata) (unsigned int str_id, | 110 | |
111 | int (*tstamp)(struct device *dev, unsigned int str_id, | ||
112 | struct snd_compr_tstamp *tstamp); | ||
113 | int (*ack)(struct device *dev, unsigned int str_id, | ||
114 | unsigned long bytes); | ||
115 | int (*close)(struct device *dev, unsigned int str_id); | ||
116 | int (*get_caps)(struct snd_compr_caps *caps); | ||
117 | int (*get_codec_caps)(struct snd_compr_codec_caps *codec); | ||
118 | int (*set_metadata)(struct device *dev, unsigned int str_id, | ||
111 | struct snd_compr_metadata *mdata); | 119 | struct snd_compr_metadata *mdata); |
112 | |||
113 | }; | 120 | }; |
114 | 121 | ||
115 | struct sst_ops { | 122 | struct sst_ops { |