123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- /*
- * soc-util.c -- ALSA SoC Audio Layer utility functions
- *
- * Copyright 2009 Wolfson Microelectronics PLC.
- *
- * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
- * Liam Girdwood <lrg@slimlogic.co.uk>
- *
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- */
- #include <sound/core.h>
- #include <sound/pcm.h>
- #include <sound/pcm_params.h>
- #include <sound/soc.h>
- int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots)
- {
- return sample_size * channels * tdm_slots;
- }
- EXPORT_SYMBOL_GPL(snd_soc_calc_frame_size);
- int snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params)
- {
- int sample_size;
- sample_size = snd_pcm_format_width(params_format(params));
- if (sample_size < 0)
- return sample_size;
- return snd_soc_calc_frame_size(sample_size, params_channels(params),
- 1);
- }
- EXPORT_SYMBOL_GPL(snd_soc_params_to_frame_size);
- int snd_soc_calc_bclk(int fs, int sample_size, int channels, int tdm_slots)
- {
- return fs * snd_soc_calc_frame_size(sample_size, channels, tdm_slots);
- }
- EXPORT_SYMBOL_GPL(snd_soc_calc_bclk);
- int snd_soc_params_to_bclk(struct snd_pcm_hw_params *params)
- {
- int ret;
- ret = snd_soc_params_to_frame_size(params);
- if (ret > 0)
- return ret * params_rate(params);
- else
- return ret;
- }
- EXPORT_SYMBOL_GPL(snd_soc_params_to_bclk);
|