Skip to content

Commit

Permalink
ASoC: mfld-compress: Use dedicated function instead of ioctl
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Subhransu S. Prusty authored and Mark Brown committed Aug 27, 2014
1 parent d8499c9 commit 06cb1eb
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 19 deletions.
38 changes: 29 additions & 9 deletions sound/soc/intel/sst-mfld-platform-compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static int sst_platform_compr_free(struct snd_compr_stream *cstream)
/*need to check*/
str_id = stream->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);
kfree(stream);
pr_debug("%s: %d\n", __func__, ret_val);
Expand Down Expand Up @@ -158,7 +158,7 @@ static int sst_platform_compr_set_params(struct snd_compr_stream *cstream,
cb.drain_cb_param = cstream;
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) {
pr_err("stream allocation failed %d\n", retval);
return retval;
Expand All @@ -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)
{
struct sst_runtime_stream *stream =
cstream->runtime->private_data;

return stream->compr_ops->control(cmd, stream->id);
struct sst_runtime_stream *stream = cstream->runtime->private_data;

switch (cmd) {
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,
Expand All @@ -182,7 +202,7 @@ static int sst_platform_compr_pointer(struct snd_compr_stream *cstream,
struct sst_runtime_stream *stream;

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 %
(u32)cstream->runtime->buffer_size;
pr_debug("calc bytes offset/copied bytes as %d\n", tstamp->byte_offset);
Expand All @@ -195,7 +215,7 @@ static int sst_platform_compr_ack(struct snd_compr_stream *cstream,
struct sst_runtime_stream *stream;

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;

return 0;
Expand Down Expand Up @@ -225,7 +245,7 @@ static int sst_platform_compr_set_metadata(struct snd_compr_stream *cstream,
struct sst_runtime_stream *stream =
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 = {
Expand Down
27 changes: 17 additions & 10 deletions sound/soc/intel/sst-mfld-platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,24 @@ struct sst_compress_cb {

struct compress_sst_ops {
const char *name;
int (*open) (struct snd_sst_params *str_params,
struct sst_compress_cb *cb);
int (*control) (unsigned int cmd, unsigned int str_id);
int (*tstamp) (unsigned int str_id, struct snd_compr_tstamp *tstamp);
int (*ack) (unsigned int str_id, unsigned long bytes);
int (*close) (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) (unsigned int str_id,
int (*open)(struct device *dev,
struct snd_sst_params *str_params, struct sst_compress_cb *cb);
int (*stream_start)(struct device *dev, unsigned int str_id);
int (*stream_drop)(struct device *dev, unsigned int str_id);
int (*stream_drain)(struct device *dev, unsigned int str_id);
int (*stream_partial_drain)(struct device *dev, unsigned int str_id);
int (*stream_pause)(struct device *dev, unsigned int str_id);
int (*stream_pause_release)(struct device *dev, 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 sst_ops {
Expand Down

0 comments on commit 06cb1eb

Please sign in to comment.