本文整理汇总了C++中snd_pcm_hw_constraint_list函数的典型用法代码示例。如果您正苦于以下问题:C++ snd_pcm_hw_constraint_list函数的具体用法?C++ snd_pcm_hw_constraint_list怎么用?C++ snd_pcm_hw_constraint_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了snd_pcm_hw_constraint_list函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ctp_vb_cs42l73_startup
static int ctp_vb_cs42l73_startup(struct snd_pcm_substream *substream)
{
unsigned int device = substream->pcm->device;
pr_debug("%s - applying rate constraint\n", __func__);
switch (device) {
case CTP_VB_AUD_ASP_DEV:
case CTP_VB_AUD_PROBE_DEV:
case CTP_VB_COMMS_FM_DEV:
case CTP_VB_AUD_VIRTUAL_ASP_DEV:
snd_pcm_hw_constraint_list(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_RATE, &constraints_48000);
break;
case CTP_VB_AUD_VSP_DEV:
snd_pcm_hw_constraint_list(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_RATE,
&constraints_16000);
ctp_config_voicecall_flag(substream, true);
break;
case CTP_VB_COMMS_BT_SCO_DEV:
snd_pcm_hw_constraint_list(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_RATE,
&constraints_8000_16000);
break;
default:
pr_err("%s: Invalid device %d\n", __func__, device);
return -EINVAL;
}
return 0;
}
示例2: mt_pcm_mrgrx_open
static int mt_pcm_mrgrx_open(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
int ret = 0;
pr_debug("%s\n", __func__);
snd_soc_set_runtime_hwparams(substream, &mt_pcm_mrgrx_hardware);
ret = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
&mrgrx_constraints_sample_rates);
if (unlikely(ret < 0))
pr_err("snd_pcm_hw_constraint_list failed: 0x%x\n", ret);
ret = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
if (unlikely(ret < 0))
pr_err("snd_pcm_hw_constraint_integer failed: 0x%x\n", ret);
mt_afe_main_clk_on();
mt_afe_dac_clk_on();
if (ret < 0) {
pr_err("%s mt_pcm_mrgrx_close\n", __func__);
mt_pcm_mrgrx_close(substream);
return ret;
}
pr_debug("%s return\n", __func__);
return 0;
}
示例3: arizona_startup
static int arizona_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct snd_soc_codec *codec = dai->codec;
struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec);
struct arizona_dai_priv *dai_priv = &priv->dai[dai->id - 1];
const struct snd_pcm_hw_constraint_list *constraint;
unsigned int base_rate;
switch (dai_priv->clk) {
case ARIZONA_CLK_SYSCLK:
base_rate = priv->sysclk;
break;
case ARIZONA_CLK_ASYNCCLK:
base_rate = priv->asyncclk;
break;
default:
return 0;
}
if (base_rate == 0)
return 0;
if (base_rate % 8000)
constraint = &arizona_44k1_constraint;
else
constraint = &arizona_48k_constraint;
return snd_pcm_hw_constraint_list(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_RATE,
constraint);
}
示例4: 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;
}
示例5: twl6040_startup
static int twl6040_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 twl6040_data *priv = snd_soc_codec_get_drvdata(codec);
if (!priv->sysclk) {
dev_err(codec->dev,
"no mclk configured, call set_sysclk() on init\n");
return -EINVAL;
}
/*
* capture is not supported at 17.64 MHz,
* it's reserved for headset low-power playback scenario
*/
if ((priv->sysclk == 17640000) && substream->stream) {
dev_err(codec->dev,
"capture mode is not supported at %dHz\n",
priv->sysclk);
return -EINVAL;
}
snd_pcm_hw_constraint_list(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_RATE,
priv->sysclk_constraints);
return 0;
}
示例6: ak5558_startup
static int ak5558_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
return snd_pcm_hw_constraint_list(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_RATE,
&ak5558_rate_constraints);
}
示例7: pcm512x_dai_startup_slave
static int pcm512x_dai_startup_slave(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct snd_soc_codec *codec = dai->codec;
struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec);
struct device *dev = dai->dev;
struct regmap *regmap = pcm512x->regmap;
if (IS_ERR(pcm512x->sclk)) {
dev_info(dev, "No SCLK, using BCLK: %ld\n",
PTR_ERR(pcm512x->sclk));
/* Disable reporting of missing SCLK as an error */
regmap_update_bits(regmap, PCM512x_ERROR_DETECT,
PCM512x_IDCH, PCM512x_IDCH);
/* Switch PLL input to BCLK */
regmap_update_bits(regmap, PCM512x_PLL_REF,
PCM512x_SREF, PCM512x_SREF_BCK);
}
return snd_pcm_hw_constraint_list(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_RATE,
&constraints_slave);
}
示例8: mtk_pcm_btcvsd_rx_open
static int mtk_pcm_btcvsd_rx_open(struct snd_pcm_substream *substream)
{
int ret = 0;
struct snd_pcm_runtime *runtime = substream->runtime;
pr_warn("%s\n", __func__);
ret = AudDrv_btcvsd_Allocate_Buffer(1);
runtime->hw = mtk_btcvsd_rx_hardware;
memcpy((void *)(&(runtime->hw)), (void *)&mtk_btcvsd_rx_hardware, sizeof(struct snd_pcm_hardware));
ret = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &constraints_sample_rates);
BT_CVSD_Mem.RX_substream = substream;
do_gettimeofday(&begin_rx);
prev_sec_rx = begin_rx.tv_sec;
prev_usec_rx = begin_rx.tv_usec;
if (ret < 0)
pr_warn("snd_pcm_hw_constraint_integer failed\n");
if (ret < 0) {
pr_err("ret < 0 mtk_pcm_btcvsd_rx_close\n");
mtk_pcm_btcvsd_rx_close(substream);
return ret;
}
/* pr_warn("mtk_pcm_btcvsd_open return\n"); */
return 0;
}
示例9: 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;
}
示例10: mt_pcm_dl1_awb_open
static int mt_pcm_dl1_awb_open(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
int ret = 0;
pr_debug("%s\n", __func__);
snd_soc_set_runtime_hwparams(substream, &mt_pcm_dl1_awb_hardware);
ret = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
&mt_pcm_dl1_awb_constraints_rates);
if (unlikely(ret < 0))
pr_err("%s snd_pcm_hw_constraint_list failed %d\n", __func__, ret);
ret = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
if (unlikely(ret < 0))
pr_err("%s snd_pcm_hw_constraint_integer failed %d\n", __func__, ret);
/* here open audio clocks */
mt_afe_main_clk_on();
mt_afe_emi_clk_on();
if (unlikely(ret < 0)) {
pr_err("%s mt_pcm_dl1_awb_close\n", __func__);
mt_pcm_dl1_awb_close(substream);
return ret;
}
pr_debug("%s return\n", __func__);
return 0;
}
示例11: mtk_pcm_i2s0_open
static int mtk_pcm_i2s0_open(struct snd_pcm_substream *substream)
{
int ret = 0;
struct snd_pcm_runtime *runtime = substream->runtime;
AfeControlSramLock();
if (GetSramState() == SRAM_STATE_FREE)
{
mtk_i2s0_hardware.buffer_bytes_max = GetPLaybackSramFullSize();
mPlaybackSramState = SRAM_STATE_PLAYBACKFULL;
SetSramState(mPlaybackSramState);
}
else
{
mtk_i2s0_hardware.buffer_bytes_max = GetPLaybackSramPartial();
mPlaybackSramState = SRAM_STATE_PLAYBACKPARTIAL;
SetSramState(mPlaybackSramState);
}
AfeControlSramUnLock();
runtime->hw = mtk_i2s0_hardware;
printk("mtk_pcm_i2s0_open\n");
AudDrv_Clk_On();
memcpy((void *)(&(runtime->hw)), (void *)&mtk_i2s0_hardware , sizeof(struct snd_pcm_hardware));
pI2s0MemControl = Get_Mem_ControlT(Soc_Aud_Digital_Block_MEM_DL1);
ret = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
&constraints_sample_rates);
ret = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
if (ret < 0)
{
printk("snd_pcm_hw_constraint_integer failed\n");
}
//print for hw pcm information
printk("mtk_pcm_i2s0_open runtime rate = %d channels = %d substream->pcm->device = %d\n",
runtime->rate, runtime->channels, substream->pcm->device);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
{
printk("SNDRV_PCM_STREAM_PLAYBACK mtkalsa_i2s0_playback_constraints\n");
}
else
{
}
if (ret < 0)
{
printk("mtk_pcm_i2s0_close\n");
mtk_pcm_i2s0_close(substream);
return ret;
}
printk("mtk_pcm_i2s0_open return\n");
AudDrv_Clk_Off();
return 0;
}
示例12: msm_afe_open
static int msm_afe_open(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct pcm_afe_info *prtd = NULL;
int ret = 0;
prtd = kzalloc(sizeof(struct pcm_afe_info), GFP_KERNEL);
if (prtd == NULL) {
pr_err("Failed to allocate memory for msm_audio\n");
return -ENOMEM;
} else
pr_debug("prtd %x\n", (unsigned int)prtd);
mutex_init(&prtd->lock);
spin_lock_init(&prtd->dsp_lock);
prtd->dsp_cnt = 0;
mutex_lock(&prtd->lock);
runtime->hw = msm_afe_hardware;
prtd->substream = substream;
runtime->private_data = prtd;
prtd->audio_client = q6asm_audio_client_alloc(
(app_cb)q6asm_event_handler, prtd);
if (!prtd->audio_client) {
pr_debug("%s: Could not allocate memory\n", __func__);
/*
*/
mutex_unlock(&prtd->lock);
kfree(prtd);
/* */
return -ENOMEM;
}
hrtimer_init(&prtd->hrt, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
prtd->hrt.function = afe_hrtimer_callback;
else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
prtd->hrt.function = afe_hrtimer_rec_callback;
mutex_unlock(&prtd->lock);
ret = snd_pcm_hw_constraint_list(runtime, 0,
SNDRV_PCM_HW_PARAM_RATE,
&constraints_sample_rates);
if (ret < 0)
pr_err("snd_pcm_hw_constraint_list failed\n");
/* 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_err("snd_pcm_hw_constraint_integer failed\n");
return 0;
}
示例13: mtk_pcm_dl1_open
static int mtk_pcm_dl1_open(struct snd_pcm_substream *substream)
{
int ret = 0;
struct snd_pcm_runtime *runtime = substream->runtime;
PRINTK_AUDDRV("mtk_pcm_dl1_open\n");
AfeControlSramLock();
if (GetSramState() == SRAM_STATE_FREE)
{
mtk_pcm_dl1_hardware.buffer_bytes_max = GetPLaybackSramFullSize();
mPlaybackSramState = SRAM_STATE_PLAYBACKFULL;
SetSramState(mPlaybackSramState);
}
else
{
mtk_pcm_dl1_hardware.buffer_bytes_max = GetPLaybackDramSize();
mPlaybackSramState = SRAM_STATE_PLAYBACKDRAM;
}
AfeControlSramUnLock();
if (mPlaybackSramState == SRAM_STATE_PLAYBACKDRAM)
{
AudDrv_Emi_Clk_On();
}
printk("mtk_pcm_dl1_hardware.buffer_bytes_max = %zu mPlaybackSramState = %d\n", mtk_pcm_dl1_hardware.buffer_bytes_max, mPlaybackSramState);
runtime->hw = mtk_pcm_dl1_hardware;
AudDrv_ANA_Clk_On();
AudDrv_Clk_On();
memcpy((void *)(&(runtime->hw)), (void *)&mtk_pcm_dl1_hardware , sizeof(struct snd_pcm_hardware));
pMemControl = Get_Mem_ControlT(Soc_Aud_Digital_Block_MEM_DL1);
ret = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
&constraints_sample_rates);
if (ret < 0)
{
printk("snd_pcm_hw_constraint_integer failed\n");
}
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
{
printk("SNDRV_PCM_STREAM_PLAYBACK mtkalsa_dl1playback_constraints\n");
}
else
{
printk("SNDRV_PCM_STREAM_CAPTURE mtkalsa_dl1playback_constraints\n");
}
if (ret < 0)
{
printk("ret < 0 mtk_soc_pcm_dl1_close\n");
mtk_soc_pcm_dl1_close(substream);
return ret;
}
//PRINTK_AUDDRV("mtk_pcm_dl1_open return\n");
return 0;
}
示例14: snd_rpi_proto_startup
static int snd_rpi_proto_startup(struct snd_pcm_substream *substream)
{
/* Setup constraints, because there is a 12.288 MHz XTAL on the board */
snd_pcm_hw_constraint_list(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_RATE,
&wm8731_constraints_12288000);
return 0;
}
示例15: ctp_startup_fm_xsp
int ctp_startup_fm_xsp(struct snd_pcm_substream *substream)
{
pr_debug("%s - applying rate constraint\n", __func__);
snd_pcm_hw_constraint_list(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_RATE,
&constraints_48000);
return 0;
}