HH
VS1005 VSOS A
UDIO
S
UBSYSTEM
VS1005g
11.2
Controlling Sample Rate and Bit Width
11.2.1
IOCTL_AUDIO_SET_RATE_AND_BITS
Set sample rate and number of bits. This is the recommended way of setting the sample
rate and bit width with drivers like e.g I2S where there is a limit to sample rate and bit
width combinations. Note that the sample rate / bit width argument may be larger than
what can be fit into 16 bits, so it needs to be passed through a pointer.
Some drivers have very restricted number of sample rates supported. If you want to
see what sample rate actually was set by the hardware, it is recommended to do a
IOCTL_AUDIO_GET_IRATE or IOCTL_AUDIO_GET_ORATE call to see what you ac-
tually got.
•
labs(rateBits) = sampleRate, may be in fractional sample rate format (Chapter 11.6).
•
if rateBits < 0, then use 32-bit I/O
•
Sets both input and output sample rate, if applicable
•
Not available with Slave Mode drivers
Example:
s_int32 rateBits = -48000; /* Set to 48000 Hz, 32 bits */
if (ioctl(fp, IOCTL_AUDIO_SET_RATE_AND_BITS, (char *)(&rateBits))) {
printf("Couldn't set sample rate and bits\n");
}
11.2.2
IOCTL_AUDIO_GET_IRATE, IOCTL_AUDIO_GET_ORATE
Get integer part of the current sample rate. Note that sample rate may be larger than
what can fit into 16 bits, so it needs to be passed through a 32-bit pointer.
Some drivers have very restricted number of sample rates supported. If you want to
see what sample rate actually was set by the hardware, it is recommended to do a
IOCTL_AUDIO_GET_IRATE or IOCTL_AUDIO_GET_ORATE call to see what you ac-
tually got.
•
Not available with Slave Mode drivers
Example for driver with input:
s_int32 sampleRate;
if (ioctl(fp, IOCTL_AUDIO_GET_IRATE, (char *)(&sampleRate))) {
printf("Couldn't get sample rate\n");
}
Example for driver with output:
s_int32 sampleRate;
if (ioctl(fp, IOCTL_AUDIO_GET_ORATE, (char *)(&sampleRate))) {
printf("Couldn't get sample rate\n");
}
Rev. 3.57
2019-04-10
Page