Commit 06cb1eb3 authored by Subhransu S. Prusty's avatar Subhransu S. Prusty Committed by Mark Brown

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: default avatarSubhransu S. Prusty <subhransu.s.prusty@intel.com>
Signed-off-by: default avatarVinod Koul <vinod.koul@intel.com>
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
parent d8499c9b
...@@ -86,7 +86,7 @@ static int sst_platform_compr_free(struct snd_compr_stream *cstream) ...@@ -86,7 +86,7 @@ static int sst_platform_compr_free(struct snd_compr_stream *cstream)
/*need to check*/ /*need to check*/
str_id = stream->id; str_id = stream->id;
if (str_id) if (str_id)
ret_val = stream->compr_ops->close(str_id); ret_val = stream->compr_ops->close(sst->dev, str_id);
module_put(sst->dev->driver->owner); module_put(sst->dev->driver->owner);
kfree(stream); kfree(stream);
pr_debug("%s: %d\n", __func__, ret_val); 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,7 +158,7 @@ static int sst_platform_compr_set_params(struct snd_compr_stream *cstream,
cb.drain_cb_param = cstream; cb.drain_cb_param = cstream;
cb.drain_notify = sst_drain_notify; cb.drain_notify = sst_drain_notify;
retval = stream->compr_ops->open(&str_params, &cb); retval = stream->compr_ops->open(sst->dev, &str_params, &cb);
if (retval < 0) { if (retval < 0) {
pr_err("stream allocation failed %d\n", retval); pr_err("stream allocation failed %d\n", retval);
return retval; return retval;
...@@ -170,10 +170,30 @@ static int sst_platform_compr_set_params(struct snd_compr_stream *cstream, ...@@ -170,10 +170,30 @@ static int sst_platform_compr_set_params(struct snd_compr_stream *cstream,
static int sst_platform_compr_trigger(struct snd_compr_stream *cstream, int cmd) static int sst_platform_compr_trigger(struct snd_compr_stream *cstream, int cmd)
{ {
struct sst_runtime_stream *stream = struct sst_runtime_stream *stream = cstream->runtime->private_data;
cstream->runtime->private_data;
switch (cmd) {
return stream->compr_ops->control(cmd, stream->id); case SNDRV_PCM_TRIGGER_START:
if (stream->compr_ops->stream_start)
return stream->compr_ops->stream_start(sst->dev, stream->id);
case SNDRV_PCM_TRIGGER_STOP:
if (stream->compr_ops->stream_drop)
return stream->compr_ops->stream_drop(sst->dev, stream->id);
case SND_COMPR_TRIGGER_DRAIN:
if (stream->compr_ops->stream_drain)
return stream->compr_ops->stream_drain(sst->dev, stream->id);
case SND_COMPR_TRIGGER_PARTIAL_DRAIN:
if (stream->compr_ops->stream_partial_drain)
return stream->compr_ops->stream_partial_drain(sst->dev, stream->id);
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
if (stream->compr_ops->stream_pause)
return stream->compr_ops->stream_pause(sst->dev, stream->id);
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
if (stream->compr_ops->stream_pause_release)
return stream->compr_ops->stream_pause_release(sst->dev, stream->id);
default:
return -EINVAL;
}
} }
static int sst_platform_compr_pointer(struct snd_compr_stream *cstream, 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,7 +202,7 @@ static int sst_platform_compr_pointer(struct snd_compr_stream *cstream,
struct sst_runtime_stream *stream; struct sst_runtime_stream *stream;
stream = cstream->runtime->private_data; stream = cstream->runtime->private_data;
stream->compr_ops->tstamp(stream->id, tstamp); stream->compr_ops->tstamp(sst->dev, stream->id, tstamp);
tstamp->byte_offset = tstamp->copied_total % tstamp->byte_offset = tstamp->copied_total %
(u32)cstream->runtime->buffer_size; (u32)cstream->runtime->buffer_size;
pr_debug("calc bytes offset/copied bytes as %d\n", tstamp->byte_offset); 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,7 +215,7 @@ static int sst_platform_compr_ack(struct snd_compr_stream *cstream,
struct sst_runtime_stream *stream; struct sst_runtime_stream *stream;
stream = cstream->runtime->private_data; stream = cstream->runtime->private_data;
stream->compr_ops->ack(stream->id, (unsigned long)bytes); stream->compr_ops->ack(sst->dev, stream->id, (unsigned long)bytes);
stream->bytes_written += bytes; stream->bytes_written += bytes;
return 0; return 0;
...@@ -225,7 +245,7 @@ static int sst_platform_compr_set_metadata(struct snd_compr_stream *cstream, ...@@ -225,7 +245,7 @@ static int sst_platform_compr_set_metadata(struct snd_compr_stream *cstream,
struct sst_runtime_stream *stream = struct sst_runtime_stream *stream =
cstream->runtime->private_data; cstream->runtime->private_data;
return stream->compr_ops->set_metadata(stream->id, metadata); return stream->compr_ops->set_metadata(sst->dev, stream->id, metadata);
} }
struct snd_compr_ops sst_platform_compr_ops = { struct snd_compr_ops sst_platform_compr_ops = {
......
...@@ -99,17 +99,24 @@ struct sst_compress_cb { ...@@ -99,17 +99,24 @@ struct sst_compress_cb {
struct compress_sst_ops { struct compress_sst_ops {
const char *name; const char *name;
int (*open) (struct snd_sst_params *str_params, int (*open)(struct device *dev,
struct sst_compress_cb *cb); struct snd_sst_params *str_params, struct sst_compress_cb *cb);
int (*control) (unsigned int cmd, unsigned int str_id); int (*stream_start)(struct device *dev, unsigned int str_id);
int (*tstamp) (unsigned int str_id, struct snd_compr_tstamp *tstamp); int (*stream_drop)(struct device *dev, unsigned int str_id);
int (*ack) (unsigned int str_id, unsigned long bytes); int (*stream_drain)(struct device *dev, unsigned int str_id);
int (*close) (unsigned int str_id); int (*stream_partial_drain)(struct device *dev, unsigned int str_id);
int (*get_caps) (struct snd_compr_caps *caps); int (*stream_pause)(struct device *dev, unsigned int str_id);
int (*get_codec_caps) (struct snd_compr_codec_caps *codec); int (*stream_pause_release)(struct device *dev, unsigned int str_id);
int (*set_metadata) (unsigned int str_id,
int (*tstamp)(struct device *dev, unsigned int str_id,
struct snd_compr_tstamp *tstamp);
int (*ack)(struct device *dev, unsigned int str_id,
unsigned long bytes);
int (*close)(struct device *dev, unsigned int str_id);
int (*get_caps)(struct snd_compr_caps *caps);
int (*get_codec_caps)(struct snd_compr_codec_caps *codec);
int (*set_metadata)(struct device *dev, unsigned int str_id,
struct snd_compr_metadata *mdata); struct snd_compr_metadata *mdata);
}; };
struct sst_ops { struct sst_ops {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment