Skip to content

Conversation

jorisverhaegen
Copy link

These 2 ioctl are under review to be added to kernel. See https://lore.kernel.org/linux-sound/[email protected]/T/#t

This pull request should be merged after this kernel is available.

Kernel has upgraded compress headers and bumped version to 0.4.0,
so update this header as well.
Add get_tstamp64 using the new ioctl SNDRV_COMPRESS_TSTAMP64.
}

static int compress_hw_get_tstamp64(void *data,
unsigned long long *samples, unsigned int *sampling_rate)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to use forced 64-bit type like __u64 instead long long. But it's probably for the discussion. The other exported functions do not force 32-bit types.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I retained the C standard types for consistency with the existing API as you mentioned. Long long is guaranteed to be at least 64 bits wide so it won't cause any truncation issues.

Read the version when opened and cache it to reduce ioctl calls.
Refactor compress_hw_get_hpointer to use the new SNDRV_COMPRESS_AVAIL64
which benefits from overflow safety.
@jorisverhaegen jorisverhaegen force-pushed the verhaegen_409961928_overflow_fix branch from 248f7fd to 8f7cb7c Compare August 1, 2025 11:07
@jorisverhaegen jorisverhaegen requested a review from perexg August 1, 2025 11:15
time = kavail64.tstamp.pcm_io_frames % kavail64.tstamp.sampling_rate;
tstamp->tv_nsec = time * 1000000000 / kavail64.tstamp.sampling_rate;
return 0;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont see compress_hw_get_tstamp() updated. compress_hw_write() uses AVAIL ioctl, that should be updated too...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comment!

I dont see compress_hw_get_tstamp() updated

Correct, I added a parallel compress_hw_get_tstamp64 to get the 64 bit struct.
On the other hand, compress_hw_get_tstamp has been unchanged, still returning the 32 bit structure via ioctl SNDRV_COMPRESS_TSTAMP which will stay supported in the kernel forever.

compress_hw_write() uses AVAIL ioctl, that should be updated too...

There is no benefit in using AVAIL64 here since only the avail field of the structure is being used (was already 64 bit). The only difference between AVAIL and AVAIL64 return value is the tstamp field which is unused in compress_hw_write

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants