[PATCH v4 3/3] ALSA: compress_offload: Add SNDRV_COMPRESS_AVAIL64 ioctl
George Verhaegen
verhaegen at google.com
Thu Aug 21 01:53:44 PDT 2025
On Tue, 5 Aug 2025 at 06:50, Vinod Koul <vkoul at kernel.org> wrote:
> > static size_t snd_compr_calc_avail(struct snd_compr_stream *stream,
> > - struct snd_compr_avail *avail)
> > + struct snd_compr_avail64 *avail)
> > {
> > - struct snd_compr_tstamp64 tstamp64 = { 0 };
> > -
> > memset(avail, 0, sizeof(*avail));
> > - snd_compr_update_tstamp(stream, &tstamp64);
> > - snd_compr_tstamp32_from_64(&avail->tstamp, &tstamp64);
> > + snd_compr_update_tstamp(stream, &avail->tstamp);
> > /* Still need to return avail even if tstamp can't be filled in */
> >
> > if (stream->runtime->total_bytes_available == 0 &&
> > @@ -233,32 +230,47 @@ static size_t snd_compr_calc_avail(struct snd_compr_stream *stream,
> > }
> >
> > avail->avail = stream->runtime->total_bytes_available -
> > - stream->runtime->total_bytes_transferred;
> > + stream->runtime->total_bytes_transferred;
>
> Lets not do formatting changes in current patch please
I'm happy to revert the formatting changes. Are you only referring to
the alignment of the subtraction operation (avail->avail), or
something else too? Note that the second line of the function
signature of snd_compr_calc_avail got re-aligned by clang-format due
to an actual change (type change to struct snd_compr_avail64) so I
assume the re-alignment here is OK, but please confirm.
> > if (stream->direction == SND_COMPRESS_PLAYBACK)
> > avail->avail = stream->runtime->buffer_size - avail->avail;
> >
> > - pr_debug("ret avail as %llu\n", avail->avail);
> > + pr_debug("ret avail as %zu\n", (size_t)avail->avail);
> > return avail->avail;
> > }
> >
> > static inline size_t snd_compr_get_avail(struct snd_compr_stream *stream)
> > {
> > - struct snd_compr_avail avail;
> > + struct snd_compr_avail64 avail;
> >
> > return snd_compr_calc_avail(stream, &avail);
> > }
> >
> > -static int
> > -snd_compr_ioctl_avail(struct snd_compr_stream *stream, unsigned long arg)
> > +static void snd_compr_avail32_from_64(struct snd_compr_avail *avail32,
> > + const struct snd_compr_avail64 *avail64)
> > {
> > - struct snd_compr_avail ioctl_avail;
> > + avail32->avail = avail64->avail;
> > + snd_compr_tstamp32_from_64(&avail32->tstamp, &avail64->tstamp);
> > +}
> > +
> > +static int snd_compr_ioctl_avail(struct snd_compr_stream *stream,
> > + unsigned long arg, bool is_32bit)
> > +{
> > + struct snd_compr_avail64 ioctl_avail64;
> > + struct snd_compr_avail ioctl_avail32;
> > size_t avail;
> > + const void *copy_from = &ioctl_avail64;
> > + size_t copy_size = sizeof(ioctl_avail64);
> >
> > if (stream->direction == SND_COMPRESS_ACCEL)
> > return -EBADFD;
> >
> > - avail = snd_compr_calc_avail(stream, &ioctl_avail);
> > - ioctl_avail.avail = avail;
> > + avail = snd_compr_calc_avail(stream, &ioctl_avail64);
> > + ioctl_avail64.avail = avail;
> > + if (is_32bit) {
> > + snd_compr_avail32_from_64(&ioctl_avail32, &ioctl_avail64);
> > + copy_from = &ioctl_avail32;
> > + copy_size = sizeof(ioctl_avail32);
> > + }
>
> Same comment as previous patch
As agreed in the previous patch, will leave as is.
Thanks,
George
More information about the linux-arm-kernel
mailing list