本文整理汇总了C++中snd_pcm_hw_constraint_minmax函数的典型用法代码示例。如果您正苦于以下问题:C++ snd_pcm_hw_constraint_minmax函数的具体用法?C++ snd_pcm_hw_constraint_minmax怎么用?C++ snd_pcm_hw_constraint_minmax使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了snd_pcm_hw_constraint_minmax函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wl1273_startup
static int wl1273_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_codec *codec = rtd->codec;
struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec);
switch (wl1273->mode) {
case WL1273_MODE_BT:
snd_pcm_hw_constraint_minmax(substream->runtime,
SNDRV_PCM_HW_PARAM_RATE,
8000, 8000);
snd_pcm_hw_constraint_minmax(substream->runtime,
SNDRV_PCM_HW_PARAM_CHANNELS, 1, 1);
break;
case WL1273_MODE_FM_RX:
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
pr_err("Cannot play in RX mode.\n");
return -EINVAL;
}
break;
case WL1273_MODE_FM_TX:
if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
pr_err("Cannot capture in TX mode.\n");
return -EINVAL;
}
break;
default:
return -EINVAL;
break;
}
return 0;
}
示例2: bcm947xx_pcm_set_constraints
static int bcm947xx_pcm_set_constraints(struct snd_pcm_runtime *runtime,
bcm947xx_i2s_info_t *snd_bcm)
{
int ret;
/* rate */
if ((ret = snd_pcm_hw_constraint_minmax(runtime,
SNDRV_PCM_HW_PARAM_RATE, snd_bcm->rate, snd_bcm->rate)) < 0)
{
DBG("%s SNDRV_PCM_HW_PARAM_RATE failed rate=%d\n", __FUNCTION__, snd_bcm->rate);
goto err;
}
/* channels */
if ((ret = snd_pcm_hw_constraint_minmax(runtime,
SNDRV_PCM_HW_PARAM_CHANNELS, snd_bcm->channels, snd_bcm->channels)) < 0)
{
DBG("%s SNDRV_PCM_HW_PARAM_CHANNELS failed channels=%d\n", __FUNCTION__, snd_bcm->channels);
goto err;
}
/* width */
if ((ret = snd_pcm_hw_constraint_minmax(runtime,
SNDRV_PCM_HW_PARAM_SAMPLE_BITS, snd_bcm->sample_bits, snd_bcm->sample_bits)) < 0)
{
DBG("%s SNDRV_PCM_HW_PARAM_SAMPLE_BITS failed bits=%d\n", __FUNCTION__, snd_bcm->sample_bits);
goto err;
}
err:
if (ret < 0)
DBG("%s return with error %d\n", __FUNCTION__, ret);
return ret;
}
示例3: uda134x_startup
static int uda134x_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct snd_soc_codec *codec = dai->codec;
struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec);
struct snd_pcm_runtime *master_runtime;
if (uda134x->master_substream) {
master_runtime = uda134x->master_substream->runtime;
pr_debug("%s constraining to %d bits at %d\n", __func__,
master_runtime->sample_bits,
master_runtime->rate);
snd_pcm_hw_constraint_minmax(substream->runtime,
SNDRV_PCM_HW_PARAM_RATE,
master_runtime->rate,
master_runtime->rate);
snd_pcm_hw_constraint_minmax(substream->runtime,
SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
master_runtime->sample_bits,
master_runtime->sample_bits);
uda134x->slave_substream = substream;
} else
uda134x->master_substream = substream;
return 0;
}
示例4: lx_pcm_open
static int lx_pcm_open(struct snd_pcm_substream *substream)
{
struct lx6464es *chip = snd_pcm_substream_chip(substream);
struct snd_pcm_runtime *runtime = substream->runtime;
int err = 0;
int board_rate;
snd_printdd("->lx_pcm_open\n");
mutex_lock(&chip->setup_mutex);
/* copy the struct snd_pcm_hardware struct */
runtime->hw = lx_caps;
#if 0
/* buffer-size should better be multiple of period-size */
err = snd_pcm_hw_constraint_integer(runtime,
SNDRV_PCM_HW_PARAM_PERIODS);
if (err < 0) {
snd_printk(KERN_WARNING LXP "could not constrain periods\n");
goto exit;
}
#endif
/* the clock rate cannot be changed */
board_rate = chip->board_sample_rate;
err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_RATE,
board_rate, board_rate);
if (err < 0) {
snd_printk(KERN_WARNING LXP "could not constrain periods\n");
goto exit;
}
/* constrain period size */
err = snd_pcm_hw_constraint_minmax(runtime,
SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
MICROBLAZE_IBL_MIN,
MICROBLAZE_IBL_MAX);
if (err < 0) {
snd_printk(KERN_WARNING LXP
"could not constrain period size\n");
goto exit;
}
snd_pcm_hw_constraint_step(runtime, 0,
SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 32);
snd_pcm_set_sync(substream);
err = 0;
exit:
runtime->private_data = chip;
mutex_unlock(&chip->setup_mutex);
snd_printdd("<-lx_pcm_open, %d\n", err);
return err;
}
示例5: aic3008_dai_startup
static int aic3008_dai_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_codec *codec = rtd->codec;
struct aic3008_priv *aic3008 = snd_soc_codec_get_drvdata(codec);
struct spi_device *spi = codec->control_data;
struct snd_pcm_runtime *master_runtime;
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
aic3008->playback_active++;
else
aic3008->capture_active++;
/* The DAI has shared clocks so if we already have a playback or
* capture going then constrain this substream to match it.
*/
if (aic3008->master_substream) {
master_runtime = aic3008->master_substream->runtime;
/* dev_dbg(&spi->dev, "Constraining to %d bits\n",
master_runtime->sample_bits); */
AUD_DBG("%p Constraining to %d bits\n", &spi->dev,
master_runtime->sample_bits);
snd_pcm_hw_constraint_minmax(substream->runtime,
SNDRV_PCM_HW_PARAM_SAMPLE_BITS, master_runtime->sample_bits,
master_runtime->sample_bits);
aic3008->slave_substream = substream;
} else
aic3008->master_substream = substream;
return 0;
}
示例6: wm8903_startup
static int wm8903_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_device *socdev = rtd->socdev;
struct snd_soc_codec *codec = socdev->card->codec;
struct wm8903_priv *wm8903 = codec->private_data;
struct i2c_client *i2c = codec->control_data;
struct snd_pcm_runtime *master_runtime;
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
wm8903->playback_active++;
else
wm8903->capture_active++;
/* The DAI has shared clocks so if we already have a playback or
* capture going then constrain this substream to match it.
*/
if (wm8903->master_substream) {
master_runtime = wm8903->master_substream->runtime;
dev_dbg(&i2c->dev, "Constraining to %d bits\n",
master_runtime->sample_bits);
snd_pcm_hw_constraint_minmax(substream->runtime,
SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
master_runtime->sample_bits,
master_runtime->sample_bits);
wm8903->slave_substream = substream;
} else
wm8903->master_substream = substream;
return 0;
}
示例7: adau1977_startup
static int adau1977_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct adau1977 *adau1977 = snd_soc_codec_get_drvdata(dai->codec);
u64 formats = 0;
if (adau1977->slot_width == 16)
formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE;
else if (adau1977->right_j || adau1977->slot_width == 24)
formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE |
SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S24_BE;
snd_pcm_hw_constraint_list(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_RATE, &adau1977->constraints);
if (adau1977->master)
snd_pcm_hw_constraint_minmax(substream->runtime,
SNDRV_PCM_HW_PARAM_RATE, 8000, adau1977->max_master_fs);
if (formats != 0)
snd_pcm_hw_constraint_mask64(substream->runtime,
SNDRV_PCM_HW_PARAM_FORMAT, formats);
return 0;
}
示例8: tda1997x_pcm_startup
/* refine sample-rate based on HDMI source */
static int tda1997x_pcm_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct snd_soc_codec *codec = dai->codec;
struct snd_pcm_runtime *rtd = substream->runtime;
tda1997x_audout_fmt_t fmt;
int rate, ret;
ret = tda1997x_get_audout_fmt(&fmt);
if (ret) {
dev_err(codec->dev, "failed to obtain tda1997x info: %d\n",
ret);
return -EIO;
}
rate = fmt.samplerate;
ret = snd_pcm_hw_constraint_minmax(rtd, SNDRV_PCM_HW_PARAM_RATE,
rate, rate);
if (ret > 0)
dev_info(codec->dev, "set samplerate constraint to %dHz\n",
rate);
else
dev_err(codec->dev, "failed to set samplerate constraint "
"to %dHz: %d\n", rate, ret);
return 0;
}
示例9: msm_lsm_open
static int msm_lsm_open(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct lsm_priv *prtd;
int ret = 0;
pr_debug("%s\n", __func__);
prtd = kzalloc(sizeof(struct lsm_priv), GFP_KERNEL);
if (!prtd) {
pr_err("%s: Failed to allocate memory for lsm_priv\n",
__func__);
return -ENOMEM;
}
spin_lock_init(&prtd->event_lock);
init_waitqueue_head(&prtd->event_wait);
prtd->substream = substream;
runtime->private_data = prtd;
runtime->hw = msm_pcm_hardware_capture;
ret = snd_pcm_hw_constraint_list(runtime, 0,
SNDRV_PCM_HW_PARAM_RATE,
&constraints_sample_rates);
if (ret < 0)
pr_info("%s: snd_pcm_hw_constraint_list failed ret %d\n",
__func__, ret);
/* Ensure that buffer size is a multiple of period size */
ret = snd_pcm_hw_constraint_integer(runtime,
SNDRV_PCM_HW_PARAM_PERIODS);
if (ret < 0)
pr_info("%s: snd_pcm_hw_constraint_integer failed ret %d\n",
__func__, ret);
ret = snd_pcm_hw_constraint_minmax(runtime,
SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
CAPTURE_MIN_NUM_PERIODS * CAPTURE_MIN_PERIOD_SIZE,
CAPTURE_MAX_NUM_PERIODS * CAPTURE_MAX_PERIOD_SIZE);
if (ret < 0)
pr_info("%s: constraint for buffer bytes min max ret = %d\n",
__func__, ret);
ret = snd_pcm_hw_constraint_step(runtime, 0,
SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 32);
if (ret < 0) {
pr_info("%s: constraint for period bytes step ret = %d\n",
__func__, ret);
}
ret = snd_pcm_hw_constraint_step(runtime, 0,
SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 32);
if (ret < 0)
pr_info("%s: constraint for buffer bytes step ret = %d\n",
__func__, ret);
prtd->lsm_client = q6lsm_client_alloc(
(lsm_app_cb)lsm_event_handler, prtd);
if (!prtd->lsm_client) {
pr_err("%s: Could not allocate memory\n", __func__);
kfree(prtd);
runtime->private_data = NULL;
return -ENOMEM;
}
return 0;
}
示例10: set_stream_hw
static int set_stream_hw(struct ua101 *ua, struct snd_pcm_substream *substream,
unsigned int channels)
{
int err;
substream->runtime->hw.info =
SNDRV_PCM_INFO_MMAP |
SNDRV_PCM_INFO_MMAP_VALID |
SNDRV_PCM_INFO_BATCH |
SNDRV_PCM_INFO_INTERLEAVED |
SNDRV_PCM_INFO_BLOCK_TRANSFER |
SNDRV_PCM_INFO_FIFO_IN_FRAMES;
substream->runtime->hw.formats = ua->format_bit;
substream->runtime->hw.rates = snd_pcm_rate_to_rate_bit(ua->rate);
substream->runtime->hw.rate_min = ua->rate;
substream->runtime->hw.rate_max = ua->rate;
substream->runtime->hw.channels_min = channels;
substream->runtime->hw.channels_max = channels;
substream->runtime->hw.buffer_bytes_max = 45000 * 1024;
substream->runtime->hw.period_bytes_min = 1;
substream->runtime->hw.period_bytes_max = UINT_MAX;
substream->runtime->hw.periods_min = 2;
substream->runtime->hw.periods_max = UINT_MAX;
err = snd_pcm_hw_constraint_minmax(substream->runtime,
SNDRV_PCM_HW_PARAM_PERIOD_TIME,
1500000 / ua->packets_per_second,
UINT_MAX);
if (err < 0)
return err;
err = snd_pcm_hw_constraint_msbits(substream->runtime, 0, 32, 24);
return err;
}
示例11: emu10k1_playback_constraints
static int emu10k1_playback_constraints(struct snd_pcm_runtime *runtime)
{
int err;
if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0)
return err;
if ((err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 256, UINT_MAX)) < 0)
return err;
return 0;
}
示例12: skl_set_pcm_constrains
static void skl_set_pcm_constrains(struct hdac_ext_bus *ebus,
struct snd_pcm_runtime *runtime)
{
snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
/* avoid wrap-around with wall-clock */
snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_TIME,
20, 178000000);
}
示例13: n810_startup
static int n810_startup(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct snd_soc_pcm_runtime *rtd = substream->private_data;
snd_pcm_hw_constraint_minmax(runtime,
SNDRV_PCM_HW_PARAM_CHANNELS, 2, 2);
n810_ext_control(&rtd->card->dapm);
return clk_prepare_enable(sys_clkout2);
}
示例14: ssm2602_startup
static int ssm2602_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct snd_soc_codec *codec = dai->codec;
struct ssm2602_priv *ssm2602 = snd_soc_codec_get_drvdata(codec);
struct snd_pcm_runtime *master_runtime;
/* The DAI has shared clocks so if we already have a playback or
* capture going then constrain this substream to match it.
* TODO: the ssm2602 allows pairs of non-matching PB/REC rates
*/
if (ssm2602->master_substream) {
master_runtime = ssm2602->master_substream->runtime;
dev_dbg(codec->dev, "Constraining to %d bits at %dHz\n",
master_runtime->sample_bits,
master_runtime->rate);
if (master_runtime->rate != 0)
snd_pcm_hw_constraint_minmax(substream->runtime,
SNDRV_PCM_HW_PARAM_RATE,
master_runtime->rate,
master_runtime->rate);
if (master_runtime->sample_bits != 0)
snd_pcm_hw_constraint_minmax(substream->runtime,
SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
master_runtime->sample_bits,
master_runtime->sample_bits);
ssm2602->slave_substream = substream;
} else
ssm2602->master_substream = substream;
if (ssm2602->sysclk_constraints) {
snd_pcm_hw_constraint_list(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_RATE,
ssm2602->sysclk_constraints);
}
return 0;
}
示例15: ux500_msp_dai_hw_params
static int ux500_msp_dai_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{
unsigned int mask, slots_active;
struct snd_pcm_runtime *runtime = substream->runtime;
struct ux500_msp_i2s_drvdata *drvdata = dev_get_drvdata(dai->dev);
dev_dbg(dai->dev, "%s: MSP %d (%s): Enter.\n",
__func__, dai->id, snd_pcm_stream_str(substream));
switch (drvdata->fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
case SND_SOC_DAIFMT_I2S:
snd_pcm_hw_constraint_minmax(runtime,
SNDRV_PCM_HW_PARAM_CHANNELS,
1, 2);
break;
case SND_SOC_DAIFMT_DSP_B:
case SND_SOC_DAIFMT_DSP_A:
mask = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ?
drvdata->tx_mask :
drvdata->rx_mask;
slots_active = hweight32(mask);
dev_dbg(dai->dev, "TDM-slots active: %d", slots_active);
snd_pcm_hw_constraint_minmax(runtime,
SNDRV_PCM_HW_PARAM_CHANNELS,
slots_active, slots_active);
break;
default:
dev_err(dai->dev,
"%s: Error: Unsupported protocol (fmt = 0x%x)!\n",
__func__, drvdata->fmt);
return -EINVAL;
}
return 0;
}