Lines Matching +full:convert +full:- +full:sample +full:- +full:format
2 * PCM Interface - misc routines
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #define SND_PCM_FORMAT_UNKNOWN (-1)
37 signed char le; /* 0 = big-endian, 1 = little-endian, -1 = others */
38 signed char signd; /* 0 = unsigned, 1 = signed, -1 = others */
45 static bool valid_format(snd_pcm_format_t format) in valid_format() argument
47 return (INT)format >= 0 && (INT)format <= (INT)SNDRV_PCM_FORMAT_LAST; in valid_format()
52 .width = 8, .phys = 8, .le = -1, .signd = 1,
56 .width = 8, .phys = 8, .le = -1, .signd = 0,
108 .width = 32, .phys = 32, .le = 1, .signd = -1,
112 .width = 32, .phys = 32, .le = 0, .signd = -1,
116 .width = 64, .phys = 64, .le = 1, .signd = -1,
120 .width = 64, .phys = 64, .le = 0, .signd = -1,
124 .width = 32, .phys = 32, .le = 1, .signd = -1,
128 .width = 32, .phys = 32, .le = 0, .signd = -1,
132 .width = 8, .phys = 8, .le = -1, .signd = -1,
136 .width = 8, .phys = 8, .le = -1, .signd = -1,
140 .width = 4, .phys = 4, .le = -1, .signd = -1,
144 .width = 3, .phys = 3, .le = -1, .signd = -1,
148 .width = 5, .phys = 5, .le = -1, .signd = -1,
173 .le = -1, .signd = -1,
176 .le = -1, .signd = -1,
194 /* FIXME: the following format is not defined properly yet */
196 .le = -1, .signd = -1,
247 .width = 3, .phys = 8, .le = -1, .signd = -1,
251 .width = 5, .phys = 8, .le = -1, .signd = -1,
258 * snd_pcm_format_signed - Check the PCM format is signed linear
259 * @format: the format to check
261 * Return: 1 if the given PCM format is signed linear, 0 if unsigned
262 * linear, and a negative error code for non-linear formats.
264 int snd_pcm_format_signed(snd_pcm_format_t format) in snd_pcm_format_signed() argument
267 if (!valid_format(format)) in snd_pcm_format_signed()
268 return -EINVAL; in snd_pcm_format_signed()
269 val = pcm_formats[(INT)format].signd; in snd_pcm_format_signed()
271 return -EINVAL; in snd_pcm_format_signed()
277 * snd_pcm_format_unsigned - Check the PCM format is unsigned linear
278 * @format: the format to check
280 * Return: 1 if the given PCM format is unsigned linear, 0 if signed
281 * linear, and a negative error code for non-linear formats.
283 int snd_pcm_format_unsigned(snd_pcm_format_t format) in snd_pcm_format_unsigned() argument
287 val = snd_pcm_format_signed(format); in snd_pcm_format_unsigned()
295 * snd_pcm_format_linear - Check the PCM format is linear
296 * @format: the format to check
298 * Return: 1 if the given PCM format is linear, 0 if not.
300 int snd_pcm_format_linear(snd_pcm_format_t format) in snd_pcm_format_linear() argument
302 return snd_pcm_format_signed(format) >= 0; in snd_pcm_format_linear()
307 * snd_pcm_format_little_endian - Check the PCM format is little-endian
308 * @format: the format to check
310 * Return: 1 if the given PCM format is little-endian, 0 if
311 * big-endian, or a negative error code if endian not specified.
313 int snd_pcm_format_little_endian(snd_pcm_format_t format) in snd_pcm_format_little_endian() argument
316 if (!valid_format(format)) in snd_pcm_format_little_endian()
317 return -EINVAL; in snd_pcm_format_little_endian()
318 val = pcm_formats[(INT)format].le; in snd_pcm_format_little_endian()
320 return -EINVAL; in snd_pcm_format_little_endian()
326 * snd_pcm_format_big_endian - Check the PCM format is big-endian
327 * @format: the format to check
329 * Return: 1 if the given PCM format is big-endian, 0 if
330 * little-endian, or a negative error code if endian not specified.
332 int snd_pcm_format_big_endian(snd_pcm_format_t format) in snd_pcm_format_big_endian() argument
336 val = snd_pcm_format_little_endian(format); in snd_pcm_format_big_endian()
344 * snd_pcm_format_width - return the bit-width of the format
345 * @format: the format to check
347 * Return: The bit-width of the format, or a negative error code
348 * if unknown format.
350 int snd_pcm_format_width(snd_pcm_format_t format) in snd_pcm_format_width() argument
353 if (!valid_format(format)) in snd_pcm_format_width()
354 return -EINVAL; in snd_pcm_format_width()
355 val = pcm_formats[(INT)format].width; in snd_pcm_format_width()
357 return -EINVAL; in snd_pcm_format_width()
363 * snd_pcm_format_physical_width - return the physical bit-width of the format
364 * @format: the format to check
366 * Return: The physical bit-width of the format, or a negative error code
367 * if unknown format.
369 int snd_pcm_format_physical_width(snd_pcm_format_t format) in snd_pcm_format_physical_width() argument
372 if (!valid_format(format)) in snd_pcm_format_physical_width()
373 return -EINVAL; in snd_pcm_format_physical_width()
374 val = pcm_formats[(INT)format].phys; in snd_pcm_format_physical_width()
376 return -EINVAL; in snd_pcm_format_physical_width()
382 * snd_pcm_format_size - return the byte size of samples on the given format
383 * @format: the format to check
386 * Return: The byte size of the given samples for the format, or a
387 * negative error code if unknown format.
389 ssize_t snd_pcm_format_size(snd_pcm_format_t format, size_t samples) in snd_pcm_format_size() argument
391 int phys_width = snd_pcm_format_physical_width(format); in snd_pcm_format_size()
393 return -EINVAL; in snd_pcm_format_size()
399 * snd_pcm_format_silence_64 - return the silent data in 8 bytes array
400 * @format: the format to check
402 * Return: The format pattern to fill or %NULL if error.
404 const unsigned char *snd_pcm_format_silence_64(snd_pcm_format_t format) in snd_pcm_format_silence_64() argument
406 if (!valid_format(format)) in snd_pcm_format_silence_64()
408 if (! pcm_formats[(INT)format].phys) in snd_pcm_format_silence_64()
410 return pcm_formats[(INT)format].silence; in snd_pcm_format_silence_64()
415 * snd_pcm_format_set_silence - set the silence data on the buffer
416 * @format: the PCM format
424 int snd_pcm_format_set_silence(snd_pcm_format_t format, void *data, unsigned int samples) in snd_pcm_format_set_silence() argument
430 if (!valid_format(format)) in snd_pcm_format_set_silence()
431 return -EINVAL; in snd_pcm_format_set_silence()
434 width = pcm_formats[(INT)format].phys; /* physical width */ in snd_pcm_format_set_silence()
435 pat = pcm_formats[(INT)format].silence; in snd_pcm_format_set_silence()
437 return -EINVAL; in snd_pcm_format_set_silence()
439 if (pcm_formats[(INT)format].signd == 1 || width <= 8) { in snd_pcm_format_set_silence()
444 /* non-zero samples, fill using a loop */ in snd_pcm_format_set_silence()
448 while (samples--) { in snd_pcm_format_set_silence()
456 while (samples--) { in snd_pcm_format_set_silence()
462 while (samples--) { in snd_pcm_format_set_silence()
468 while (samples--) { in snd_pcm_format_set_silence()
474 while (samples--) { in snd_pcm_format_set_silence()
486 * snd_pcm_hw_limit_rates - determine rate_min/rate_max fields
502 if (hw->rates & (1 << i)) { in snd_pcm_hw_limit_rates()
508 return -EINVAL; in snd_pcm_hw_limit_rates()
509 hw->rate_min = rmin; in snd_pcm_hw_limit_rates()
510 hw->rate_max = rmax; in snd_pcm_hw_limit_rates()
516 * snd_pcm_rate_to_rate_bit - converts sample rate to SNDRV_PCM_RATE_xxx bit
517 * @rate: the sample rate to convert
534 * snd_pcm_rate_bit_to_rate - converts SNDRV_PCM_RATE_xxx bit to sample rate
535 * @rate_bit: the rate bit to convert
537 * Return: The sample rate that corresponds to the given SNDRV_PCM_RATE_xxx flag
561 * snd_pcm_rate_mask_intersect - computes the intersection between two rate masks
591 * snd_pcm_rate_range_to_bits - converts rate range to SNDRV_PCM_RATE_xxx bit
592 * @rate_min: the minimum sample rate
593 * @rate_max: the maximum sample rate
596 * only the pre-defined rates like 44100 or 16000.