Loading Documentation/sound/alsa/compress_offload.txt +6 −0 Original line number Diff line number Diff line Loading @@ -176,6 +176,11 @@ This is called when end of file is reached. The userspace can inform DSP that EOF is reached and now DSP can start skipping padding delay. Also next write data would belong to next track - set_next_track_param This routine is called to send to DSP codec specific data of subsequent track in gapless before first write. Sequence flow for gapless would be: - Open - Get caps / codec caps Loading @@ -187,6 +192,7 @@ Sequence flow for gapless would be: - Indicaite next track data by sending set_next_track - Set metadata of the next track - then call partial_drain to flush most of buffer in DSP - set codec specific data of subsequent track - Fill data of the next track - DSP switches to second track (note: order for partial_drain and write for next track can be reversed as well) Loading include/sound/compress_driver.h +4 −0 Original line number Diff line number Diff line Loading @@ -95,6 +95,8 @@ struct snd_compr_stream { * This can be called in during stream creation only to set codec params * and the stream properties * @get_params: retrieve the codec parameters, mandatory * @set_next_track_param: send codec specific data of subsequent track * in gapless * @trigger: Trigger operations like start, pause, resume, drain, stop. * This callback is mandatory * @pointer: Retrieve current h/w pointer information. Mandatory Loading @@ -117,6 +119,8 @@ struct snd_compr_ops { struct snd_compr_metadata *metadata); int (*get_metadata)(struct snd_compr_stream *stream, struct snd_compr_metadata *metadata); int (*set_next_track_param)(struct snd_compr_stream *stream, union snd_codec_options *codec_options); int (*trigger)(struct snd_compr_stream *stream, int cmd); int (*pointer)(struct snd_compr_stream *stream, struct snd_compr_tstamp *tstamp); Loading include/uapi/sound/compress_offload.h +4 −0 Original line number Diff line number Diff line Loading @@ -171,6 +171,8 @@ struct snd_compr_metadata { * SNDRV_COMPRESS_STOP: stop a running stream, discarding ring buffer content * and the buffers currently with DSP * SNDRV_COMPRESS_DRAIN: Play till end of buffers and stop after that * SNDRV_COMPRESS_SET_NEXT_TRACK_PARAM: send codec specific data for the next * track in gapless * SNDRV_COMPRESS_IOCTL_VERSION: Query the API version */ #define SNDRV_COMPRESS_IOCTL_VERSION _IOR('C', 0x00, int) Loading @@ -192,6 +194,8 @@ struct snd_compr_metadata { #define SNDRV_COMPRESS_DRAIN _IO('C', 0x34) #define SNDRV_COMPRESS_NEXT_TRACK _IO('C', 0x35) #define SNDRV_COMPRESS_PARTIAL_DRAIN _IO('C', 0x36) #define SNDRV_COMPRESS_SET_NEXT_TRACK_PARAM\ _IOW('C', 0x80, union snd_codec_options) /* * TODO * 1. add mmap support Loading sound/core/compress_offload.c +23 −0 Original line number Diff line number Diff line Loading @@ -758,6 +758,25 @@ static int snd_compr_partial_drain(struct snd_compr_stream *stream) return retval; } static int snd_compr_set_next_track_param(struct snd_compr_stream *stream, unsigned long arg) { union snd_codec_options codec_options; int retval; /* set next track params when stream is running or has been setup */ if (stream->runtime->state != SNDRV_PCM_STATE_SETUP && stream->runtime->state != SNDRV_PCM_STATE_RUNNING) return -EPERM; if (copy_from_user(&codec_options, (void __user *)arg, sizeof(codec_options))) return -EFAULT; retval = stream->ops->set_next_track_param(stream, &codec_options); return retval; } static int snd_compress_simple_ioctls(struct file *file, struct snd_compr_stream *stream, unsigned int cmd, unsigned long arg) Loading Loading @@ -854,6 +873,10 @@ static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg) retval = snd_compr_next_track(stream); break; case _IOC_NR(SNDRV_COMPRESS_SET_NEXT_TRACK_PARAM): retval = snd_compr_set_next_track_param(stream, arg); break; default: mutex_unlock(&stream->device->lock); return snd_compress_simple_ioctls(f, stream, cmd, arg); Loading sound/soc/soc-compress.c +18 −0 Original line number Diff line number Diff line Loading @@ -671,6 +671,22 @@ static int soc_compr_copy(struct snd_compr_stream *cstream, return ret; } static int sst_compr_set_next_track_param(struct snd_compr_stream *cstream, union snd_codec_options *codec_options) { struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_platform *platform = rtd->platform; int ret = 0; if (platform->driver->compr_ops && platform->driver->compr_ops->set_next_track_param) ret = platform->driver->compr_ops->set_next_track_param(cstream, codec_options); return ret; } static int soc_compr_set_metadata(struct snd_compr_stream *cstream, struct snd_compr_metadata *metadata) { Loading Loading @@ -703,6 +719,7 @@ static struct snd_compr_ops soc_compr_ops = { .free = soc_compr_free, .set_params = soc_compr_set_params, .set_metadata = soc_compr_set_metadata, .set_next_track_param = sst_compr_set_next_track_param, .get_metadata = soc_compr_get_metadata, .get_params = soc_compr_get_params, .trigger = soc_compr_trigger, Loading @@ -719,6 +736,7 @@ static struct snd_compr_ops soc_compr_dyn_ops = { .set_params = soc_compr_set_params_fe, .get_params = soc_compr_get_params, .set_metadata = soc_compr_set_metadata, .set_next_track_param = sst_compr_set_next_track_param, .get_metadata = soc_compr_get_metadata, .trigger = soc_compr_trigger_fe, .pointer = soc_compr_pointer, Loading Loading
Documentation/sound/alsa/compress_offload.txt +6 −0 Original line number Diff line number Diff line Loading @@ -176,6 +176,11 @@ This is called when end of file is reached. The userspace can inform DSP that EOF is reached and now DSP can start skipping padding delay. Also next write data would belong to next track - set_next_track_param This routine is called to send to DSP codec specific data of subsequent track in gapless before first write. Sequence flow for gapless would be: - Open - Get caps / codec caps Loading @@ -187,6 +192,7 @@ Sequence flow for gapless would be: - Indicaite next track data by sending set_next_track - Set metadata of the next track - then call partial_drain to flush most of buffer in DSP - set codec specific data of subsequent track - Fill data of the next track - DSP switches to second track (note: order for partial_drain and write for next track can be reversed as well) Loading
include/sound/compress_driver.h +4 −0 Original line number Diff line number Diff line Loading @@ -95,6 +95,8 @@ struct snd_compr_stream { * This can be called in during stream creation only to set codec params * and the stream properties * @get_params: retrieve the codec parameters, mandatory * @set_next_track_param: send codec specific data of subsequent track * in gapless * @trigger: Trigger operations like start, pause, resume, drain, stop. * This callback is mandatory * @pointer: Retrieve current h/w pointer information. Mandatory Loading @@ -117,6 +119,8 @@ struct snd_compr_ops { struct snd_compr_metadata *metadata); int (*get_metadata)(struct snd_compr_stream *stream, struct snd_compr_metadata *metadata); int (*set_next_track_param)(struct snd_compr_stream *stream, union snd_codec_options *codec_options); int (*trigger)(struct snd_compr_stream *stream, int cmd); int (*pointer)(struct snd_compr_stream *stream, struct snd_compr_tstamp *tstamp); Loading
include/uapi/sound/compress_offload.h +4 −0 Original line number Diff line number Diff line Loading @@ -171,6 +171,8 @@ struct snd_compr_metadata { * SNDRV_COMPRESS_STOP: stop a running stream, discarding ring buffer content * and the buffers currently with DSP * SNDRV_COMPRESS_DRAIN: Play till end of buffers and stop after that * SNDRV_COMPRESS_SET_NEXT_TRACK_PARAM: send codec specific data for the next * track in gapless * SNDRV_COMPRESS_IOCTL_VERSION: Query the API version */ #define SNDRV_COMPRESS_IOCTL_VERSION _IOR('C', 0x00, int) Loading @@ -192,6 +194,8 @@ struct snd_compr_metadata { #define SNDRV_COMPRESS_DRAIN _IO('C', 0x34) #define SNDRV_COMPRESS_NEXT_TRACK _IO('C', 0x35) #define SNDRV_COMPRESS_PARTIAL_DRAIN _IO('C', 0x36) #define SNDRV_COMPRESS_SET_NEXT_TRACK_PARAM\ _IOW('C', 0x80, union snd_codec_options) /* * TODO * 1. add mmap support Loading
sound/core/compress_offload.c +23 −0 Original line number Diff line number Diff line Loading @@ -758,6 +758,25 @@ static int snd_compr_partial_drain(struct snd_compr_stream *stream) return retval; } static int snd_compr_set_next_track_param(struct snd_compr_stream *stream, unsigned long arg) { union snd_codec_options codec_options; int retval; /* set next track params when stream is running or has been setup */ if (stream->runtime->state != SNDRV_PCM_STATE_SETUP && stream->runtime->state != SNDRV_PCM_STATE_RUNNING) return -EPERM; if (copy_from_user(&codec_options, (void __user *)arg, sizeof(codec_options))) return -EFAULT; retval = stream->ops->set_next_track_param(stream, &codec_options); return retval; } static int snd_compress_simple_ioctls(struct file *file, struct snd_compr_stream *stream, unsigned int cmd, unsigned long arg) Loading Loading @@ -854,6 +873,10 @@ static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg) retval = snd_compr_next_track(stream); break; case _IOC_NR(SNDRV_COMPRESS_SET_NEXT_TRACK_PARAM): retval = snd_compr_set_next_track_param(stream, arg); break; default: mutex_unlock(&stream->device->lock); return snd_compress_simple_ioctls(f, stream, cmd, arg); Loading
sound/soc/soc-compress.c +18 −0 Original line number Diff line number Diff line Loading @@ -671,6 +671,22 @@ static int soc_compr_copy(struct snd_compr_stream *cstream, return ret; } static int sst_compr_set_next_track_param(struct snd_compr_stream *cstream, union snd_codec_options *codec_options) { struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_soc_platform *platform = rtd->platform; int ret = 0; if (platform->driver->compr_ops && platform->driver->compr_ops->set_next_track_param) ret = platform->driver->compr_ops->set_next_track_param(cstream, codec_options); return ret; } static int soc_compr_set_metadata(struct snd_compr_stream *cstream, struct snd_compr_metadata *metadata) { Loading Loading @@ -703,6 +719,7 @@ static struct snd_compr_ops soc_compr_ops = { .free = soc_compr_free, .set_params = soc_compr_set_params, .set_metadata = soc_compr_set_metadata, .set_next_track_param = sst_compr_set_next_track_param, .get_metadata = soc_compr_get_metadata, .get_params = soc_compr_get_params, .trigger = soc_compr_trigger, Loading @@ -719,6 +736,7 @@ static struct snd_compr_ops soc_compr_dyn_ops = { .set_params = soc_compr_set_params_fe, .get_params = soc_compr_get_params, .set_metadata = soc_compr_set_metadata, .set_next_track_param = sst_compr_set_next_track_param, .get_metadata = soc_compr_get_metadata, .trigger = soc_compr_trigger_fe, .pointer = soc_compr_pointer, Loading