本文整理汇总了C++中snd_pcm_hw_constraint_integer函数的典型用法代码示例。如果您正苦于以下问题:C++ snd_pcm_hw_constraint_integer函数的具体用法?C++ snd_pcm_hw_constraint_integer怎么用?C++ snd_pcm_hw_constraint_integer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了snd_pcm_hw_constraint_integer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: omap_pcm_open
static int omap_pcm_open(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct omap_runtime_data *prtd;
int ret;
snd_soc_set_runtime_hwparams(substream, &omap_pcm_hardware);
/* 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)
goto out;
prtd = kzalloc(sizeof(*prtd), GFP_KERNEL);
if (prtd == NULL) {
ret = -ENOMEM;
goto out;
}
spin_lock_init(&prtd->lock);
runtime->private_data = prtd;
out:
return ret;
}
示例2: snd_ca0106_pcm_open_playback_channel
/* open_playback callback */
static int snd_ca0106_pcm_open_playback_channel(snd_pcm_substream_t *substream, int channel_id)
{
ca0106_t *chip = snd_pcm_substream_chip(substream);
ca0106_channel_t *channel = &(chip->playback_channels[channel_id]);
ca0106_pcm_t *epcm;
snd_pcm_runtime_t *runtime = substream->runtime;
int err;
epcm = kzalloc(sizeof(*epcm), GFP_KERNEL);
if (epcm == NULL)
return -ENOMEM;
epcm->emu = chip;
epcm->substream = substream;
epcm->channel_id=channel_id;
runtime->private_data = epcm;
runtime->private_free = snd_ca0106_pcm_free_substream;
runtime->hw = snd_ca0106_playback_hw;
channel->emu = chip;
channel->number = channel_id;
channel->use=1;
//printk("open:channel_id=%d, chip=%p, channel=%p\n",channel_id, chip, channel);
//channel->interrupt = snd_ca0106_pcm_channel_interrupt;
channel->epcm=epcm;
if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0)
return err;
if ((err = snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 64)) < 0)
return err;
return 0;
}
示例3: mxs_pcm_open
static int mxs_pcm_open(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct mxs_runtime_data *prtd;
int ret;
/* Ensure that buffer size is a multiple of the period size */
ret = snd_pcm_hw_constraint_integer(runtime,
SNDRV_PCM_HW_PARAM_PERIODS);
if (ret < 0)
return ret;
snd_soc_set_runtime_hwparams(substream, &mxs_pcm_hardware);
prtd = kzalloc(sizeof(struct mxs_runtime_data), GFP_KERNEL);
if (prtd == NULL)
return -ENOMEM;
runtime->private_data = prtd;
ret = mxs_pcm_dma_request(substream);
if (ret) {
printk(KERN_ERR "mxs_pcm: Failed to request channels\n");
kfree(prtd);
return ret;
}
return 0;
}
示例4: snd_dmaengine_pcm_open
int snd_dmaengine_pcm_open(struct snd_pcm_substream *substream,
dma_filter_fn filter_fn, void *filter_data)
{
struct dmaengine_pcm_runtime_data *prtd;
int ret;
ret = snd_pcm_hw_constraint_integer(substream->runtime,
SNDRV_PCM_HW_PARAM_PERIODS);
if (ret < 0)
return ret;
prtd = kzalloc(sizeof(*prtd), GFP_KERNEL);
if (!prtd)
return -ENOMEM;
ret = dmaengine_pcm_request_channel(prtd, filter_fn, filter_data);
if (ret < 0) {
kfree(prtd);
return ret;
}
substream->runtime->private_data = prtd;
return 0;
}
示例5: lola_pcm_open
static int lola_pcm_open(struct snd_pcm_substream *substream)
{
struct lola *chip = snd_pcm_substream_chip(substream);
struct lola_pcm *pcm = lola_get_pcm(substream);
struct lola_stream *str = lola_get_stream(substream);
struct snd_pcm_runtime *runtime = substream->runtime;
mutex_lock(&chip->open_mutex);
if (str->opened) {
mutex_unlock(&chip->open_mutex);
return -EBUSY;
}
str->substream = substream;
str->master = NULL;
str->opened = 1;
runtime->hw = lola_pcm_hw;
runtime->hw.channels_max = pcm->num_streams - str->index;
if (chip->sample_rate) {
/* sample rate is locked */
runtime->hw.rate_min = chip->sample_rate;
runtime->hw.rate_max = chip->sample_rate;
} else {
runtime->hw.rate_min = chip->sample_rate_min;
runtime->hw.rate_max = chip->sample_rate_max;
}
chip->ref_count_rate++;
snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
/* period size = multiple of chip->granularity (8, 16 or 32 frames)*/
snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_SIZE,
chip->granularity);
snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
chip->granularity);
mutex_unlock(&chip->open_mutex);
return 0;
}
示例6: bf5xx_pcm_open
static int bf5xx_pcm_open(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
struct sport_device *sport_handle = snd_soc_dai_get_drvdata(cpu_dai);
struct snd_pcm_runtime *runtime = substream->runtime;
struct snd_dma_buffer *buf = &substream->dma_buffer;
int ret;
pr_debug("%s enter\n", __func__);
snd_soc_set_runtime_hwparams(substream, &bf5xx_pcm_hardware);
ret = snd_pcm_hw_constraint_integer(runtime,
SNDRV_PCM_HW_PARAM_PERIODS);
if (ret < 0)
goto out;
if (sport_handle != NULL) {
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
sport_handle->tx_buf = buf->area;
else
sport_handle->rx_buf = buf->area;
runtime->private_data = sport_handle;
} else {
pr_err("sport_handle is NULL\n");
return -1;
}
return 0;
out:
return ret;
}
示例7: ctp_comms_dai_link_startup
static int ctp_comms_dai_link_startup(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *str_runtime;
str_runtime = substream->runtime;
WARN(!substream->pcm, "CTP Comms Machine: ERROR NULL substream->pcm\n");
if (!substream->pcm)
return -EINVAL;
/* set the runtime hw parameter with local snd_pcm_hardware struct */
switch (substream->pcm->device) {
case CTP_RHB_COMMS_BT_SCO_DEV:
str_runtime->hw = BT_sco_hw_param;
break;
case CTP_RHB_COMMS_MSIC_VOIP_DEV:
str_runtime->hw = VOIP_alsa_hw_param;
break;
case CTP_RHB_COMMS_IFX_MODEM_DEV:
str_runtime->hw = IFX_modem_alsa_hw_param;
break;
default:
pr_err("CTP Comms Machine: bad PCM Device = %d\n",
substream->pcm->device);
}
return snd_pcm_hw_constraint_integer(str_runtime,
SNDRV_PCM_HW_PARAM_PERIODS);
}
示例8: 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;
}
示例9: 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;
}
示例10: snd_dmaengine_pcm_open
/**
* snd_dmaengine_pcm_open - Open a dmaengine based PCM substream
* @substream: PCM substream
* @chan: DMA channel to use for data transfers
*
* Returns 0 on success, a negative error code otherwise.
*
* The function should usually be called from the pcm open callback. Note that
* this function will use private_data field of the substream's runtime. So it
* is not availabe to your pcm driver implementation.
*/
int snd_dmaengine_pcm_open(struct snd_pcm_substream *substream,
struct dma_chan *chan)
{
struct dmaengine_pcm_runtime_data *prtd;
int ret;
if (!chan)
return -ENXIO;
ret = snd_pcm_hw_constraint_integer(substream->runtime,
SNDRV_PCM_HW_PARAM_PERIODS);
if (ret < 0)
return ret;
prtd = kzalloc(sizeof(*prtd), GFP_KERNEL);
if (!prtd)
return -ENOMEM;
prtd->dma_chan = chan;
substream->runtime->private_data = prtd;
#ifdef CONFIG_SND_PXA_SSP_DUMP
INIT_WORK(&prtd->playback_dump_work, playback_dump_handler);
INIT_WORK(&prtd->capture_dump_work, capture_dump_handler);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
if (!ssp_playback_wq)
ssp_playback_wq =
create_singlethread_workqueue("ssp_playback");
pr_debug("[pxa-ssp]: Create playback dump file\n");
prtd->playback_fp = filp_open(DUMP_FILE1, O_RDWR | O_CREAT
| O_LARGEFILE, S_IRWXU | S_IRWXG | S_IRWXO);
if (IS_ERR(prtd->playback_fp)) {
pr_info("playback dump file create error %d\n",
(int)prtd->playback_fp);
prtd->playback_fp = 0;
}
prtd->playback_runtime = substream->runtime;
} else {
if (!ssp_capture_wq)
ssp_capture_wq =
create_singlethread_workqueue("ssp_capture");
pr_debug("[pxa-ssp]: Create capture dump file\n");
prtd->capture_fp = filp_open(DUMP_FILE2, O_RDWR | O_CREAT
| O_LARGEFILE, S_IRWXU | S_IRWXG | S_IRWXO);
if (IS_ERR(prtd->capture_fp)) {
pr_info("capture dump file create error %d\n",
(int)prtd->capture_fp);
prtd->capture_fp = 0;
}
prtd->capture_runtime = substream->runtime;
}
#endif
return 0;
}
示例11: tegra_pcm_open
static int tegra_pcm_open(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct tegra_runtime_data *prtd;
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct tegra_pcm_dma_params * dmap;
int ret = 0;
prtd = kzalloc(sizeof(struct tegra_runtime_data), GFP_KERNEL);
if (prtd == NULL)
return -ENOMEM;
runtime->private_data = prtd;
prtd->substream = substream;
spin_lock_init(&prtd->lock);
dmap = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
if (dmap) {
prtd->dma_req[0].dev = prtd;
prtd->dma_req[1].dev = prtd;
prtd->dma_chan = tegra_dma_allocate_channel(
TEGRA_DMA_MODE_CONTINUOUS_SINGLE,
"pcm");
if (prtd->dma_chan == NULL) {
ret = -ENOMEM;
goto err;
}
}
/* Set HW params now that initialization is complete */
snd_soc_set_runtime_hwparams(substream, &tegra_pcm_hardware);
/* Ensure period size is multiple of 8 */
ret = snd_pcm_hw_constraint_step(runtime, 0,
SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 0x8);
if (ret < 0)
goto err;
/* 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)
goto err;
return 0;
err:
if (prtd->dma_chan) {
tegra_dma_free_channel(prtd->dma_chan);
}
kfree(prtd);
return ret;
}
示例12: msm_compr_open
static int msm_compr_open(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct snd_soc_pcm_runtime *soc_prtd = substream->private_data;
struct compr_audio *compr;
struct msm_audio *prtd;
int ret = 0;
/* Capture path */
if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
return -EINVAL;
pr_debug("%s\n", __func__);
compr = kzalloc(sizeof(struct compr_audio), GFP_KERNEL);
if (compr == NULL) {
pr_err("Failed to allocate memory for msm_audio\n");
return -ENOMEM;
}
prtd = &compr->prtd;
prtd->substream = substream;
prtd->audio_client = q6asm_audio_client_alloc(
(app_cb)compr_event_handler, compr);
if (!prtd->audio_client) {
pr_info("%s: Could not allocate memory\n", __func__);
kfree(prtd);
return -ENOMEM;
}
prtd->audio_client->perf_mode = false;
runtime->hw = msm_compr_hardware_playback;
pr_info("%s: session ID %d\n", __func__, prtd->audio_client->session);
prtd->session_id = prtd->audio_client->session;
msm_pcm_routing_reg_phy_stream(soc_prtd->dai_link->be_id,
prtd->audio_client->perf_mode,
prtd->session_id, substream->stream);
prtd->cmd_ack = 1;
ret = snd_pcm_hw_constraint_list(runtime, 0,
SNDRV_PCM_HW_PARAM_RATE,
&constraints_sample_rates);
if (ret < 0)
pr_info("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_info("snd_pcm_hw_constraint_integer failed\n");
prtd->dsp_cnt = 0;
atomic_set(&prtd->pending_buffer, 1);
compr->codec = FORMAT_MP3;
populate_codec_list(compr, runtime);
runtime->private_data = compr;
return 0;
}
示例13: 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;
dev_dbg(chip->card->dev, "->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) {
dev_warn(chip->card->dev, "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_single(runtime, SNDRV_PCM_HW_PARAM_RATE,
board_rate);
if (err < 0) {
dev_warn(chip->card->dev, "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) {
dev_warn(chip->card->dev,
"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);
dev_dbg(chip->card->dev, "<-lx_pcm_open, %d\n", err);
return err;
}
示例14: mtk_capture_pcm_open
static int mtk_capture_pcm_open(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
int ret = 0;
AudDrv_Clk_On();
AudDrv_ADC_Clk_On();
VUL_Control_context = Get_Mem_ControlT(Soc_Aud_Digital_Block_MEM_VUL);
// can allocate sram_dbg
AfeControlSramLock();
if (GetSramState() == SRAM_STATE_FREE )
{
printk("mtk_capture_pcm_open use sram \n");
mtk_capture_hardware.buffer_bytes_max = GetCaptureSramSize();
SetSramState(SRAM_STATE_CAPTURE);
mCaptureUseSram = true;
}
else
{
printk("mtk_capture_pcm_open use dram \n");
mtk_capture_hardware.buffer_bytes_max = UL1_MAX_BUFFER_SIZE;
}
AfeControlSramUnLock();
runtime->hw = mtk_capture_hardware;
memcpy((void *)(&(runtime->hw)), (void *)&mtk_capture_hardware , sizeof(struct snd_pcm_hardware));
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");
}
if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
{
}
else
{
}
if (ret < 0)
{
printk("mtk_capture_pcm_close\n");
mtk_capture_pcm_close(substream);
return ret;
}
if(mCaptureUseSram == false)
{
AudDrv_Emi_Clk_On();
}
printk("mtk_capture_pcm_open return\n");
return 0;
}
示例15: 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;
}