本文整理汇总了C++中snd_pcm_hw_constraint_step函数的典型用法代码示例。如果您正苦于以下问题:C++ snd_pcm_hw_constraint_step函数的具体用法?C++ snd_pcm_hw_constraint_step怎么用?C++ snd_pcm_hw_constraint_step使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了snd_pcm_hw_constraint_step函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cygnus_pcm_open
static int cygnus_pcm_open(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_pcm_runtime *runtime = substream->runtime;
struct cygnus_aio_port *aio;
int ret;
aio = cygnus_dai_get_dma_data(substream);
if (!aio)
return -ENODEV;
dev_dbg(rtd->cpu_dai->dev, "%s port %d\n", __func__, aio->portnum);
snd_soc_set_runtime_hwparams(substream, &cygnus_pcm_hw);
ret = snd_pcm_hw_constraint_step(runtime, 0,
SNDRV_PCM_HW_PARAM_PERIOD_BYTES, PERIOD_BYTES_MIN);
if (ret < 0)
return ret;
ret = snd_pcm_hw_constraint_step(runtime, 0,
SNDRV_PCM_HW_PARAM_BUFFER_BYTES, PERIOD_BYTES_MIN);
if (ret < 0)
return ret;
/*
* Keep track of which substream belongs to which port.
* This info is needed by snd_pcm_period_elapsed() in irq_handler
*/
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
aio->play_stream = substream;
else
aio->capture_stream = substream;
return 0;
}
示例2: 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;
}
示例3: 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;
}
示例4: pxa910_pcm_open
static int pxa910_pcm_open(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_cpu_dai *cpu_dai = rtd->dai->cpu_dai;
struct pxa910_runtime_data *prtd;
int ret;
snd_soc_set_runtime_hwparams(substream, &pxa910_pcm_hardware);
/*
* For mysterious reasons (and despite what the manual says)
* playback samples are lost if the DMA count is not a multiple
* of the DMA burst size. Let's add a rule to enforce that.
*/
ret = snd_pcm_hw_constraint_step(runtime, 0,
SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 32);
if (ret)
goto out;
ret = snd_pcm_hw_constraint_step(runtime, 0,
SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 32);
if (ret)
goto out;
ret = snd_pcm_hw_constraint_integer(runtime,
SNDRV_PCM_HW_PARAM_PERIODS);
if (ret < 0)
goto out;
prtd = kzalloc(sizeof(struct pxa910_runtime_data), GFP_KERNEL);
if (prtd == NULL) {
ret = -ENOMEM;
goto out;
}
prtd->dma_ch = -1;
prtd->squ_desc_array =
prtd->squ_desc_array = pxa910_sram_alloc(PAGE_SIZE, &prtd->squ_desc_array_phys);
if (!prtd->squ_desc_array) {
ret = -ENOMEM;
goto err1;
}
runtime->private_data = prtd;
return 0;
err1:
kfree(prtd);
out:
return ret;
}
示例5: hdmi_dai_startup
static int hdmi_dai_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct hdmi_audio_data *ad = card_drvdata_substream(substream);
int ret;
/*
* Make sure that the period bytes are multiple of the DMA packet size.
* Largest packet size we use is 32 32-bit words = 128 bytes
*/
ret = snd_pcm_hw_constraint_step(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 128);
if (ret < 0) {
dev_err(dai->dev, "could not apply constraint\n");
return ret;
}
snd_soc_dai_set_dma_data(dai, substream, &ad->dma_data);
mutex_lock(&ad->current_stream_lock);
ad->current_stream = substream;
mutex_unlock(&ad->current_stream_lock);
ret = ad->ops->audio_startup(ad->dssdev, hdmi_dai_abort);
if (ret) {
mutex_lock(&ad->current_stream_lock);
ad->current_stream = NULL;
mutex_unlock(&ad->current_stream_lock);
}
return ret;
}
示例6: 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;
}
示例7: 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;
if (cpu_is_omap44xx()) {
/* ABE needs a step of 24 * 4 data bits, and HDMI 32 * 4
* Ensure buffer size satisfies both constraints.
*/
ret = snd_pcm_hw_constraint_step(runtime, 0,
SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 384);
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;
}
示例8: __pxa2xx_pcm_open
int __pxa2xx_pcm_open(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct pxa2xx_runtime_data *rtd;
int ret;
runtime->hw = pxa2xx_pcm_hardware;
/*
*/
ret = snd_pcm_hw_constraint_step(runtime, 0,
SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 32);
if (ret)
goto out;
ret = snd_pcm_hw_constraint_step(runtime, 0,
SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 32);
if (ret)
goto out;
ret = snd_pcm_hw_constraint_integer(runtime,
SNDRV_PCM_HW_PARAM_PERIODS);
if (ret < 0)
goto out;
ret = -ENOMEM;
rtd = kzalloc(sizeof(*rtd), GFP_KERNEL);
if (!rtd)
goto out;
rtd->dma_desc_array =
dma_alloc_writecombine(substream->pcm->card->dev, PAGE_SIZE,
&rtd->dma_desc_array_phys, GFP_KERNEL);
if (!rtd->dma_desc_array)
goto err1;
rtd->dma_ch = -1;
runtime->private_data = rtd;
return 0;
err1:
kfree(rtd);
out:
return ret;
}
示例9: 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;
}
示例10: 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;
}
示例11: cns3xxx_pcm_open
static int cns3xxx_pcm_open(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct cns3xxx_runtime_data *prtd;
int ret;
#ifdef __DEBUG_PATH
printk("%s=>%d\n", __FUNCTION__, __LINE__);
#endif
snd_soc_set_runtime_hwparams(substream, &cns3xxx_pcm_hardware);
/* Enforcing the constraint that period bytes are a multiple of 16 bytes.
* This helps PL330 GDMA innerloop
*/
ret = snd_pcm_hw_constraint_step (runtime, 0,
SNDRV_PCM_HW_PARAM_PERIOD_BYTES,16);
if (ret) goto out;
ret = snd_pcm_hw_constraint_step (runtime,0,
SNDRV_PCM_HW_PARAM_BUFFER_BYTES,16);
if (ret) goto out;
/* To ensure that buffersize 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(struct cns3xxx_runtime_data), GFP_KERNEL);
if (prtd == NULL) {
ret = -ENOMEM;
goto out;
}
prtd->dma_ch = -1;
runtime->private_data = prtd;
return 0;
out:
printk("%s=>%d\n", __FUNCTION__, __LINE__);
return ret;
}
示例12: omap_hdmi_dai_startup
static int omap_hdmi_dai_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
int err;
err = snd_pcm_hw_constraint_step(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 128);
if (err < 0)
return err;
return 0;
}
示例13: aess_open
static int aess_open(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_platform *platform = rtd->platform;
struct omap_abe *abe = snd_soc_platform_get_drvdata(platform);
struct snd_soc_dai *dai = rtd->cpu_dai;
int ret = 0;
mutex_lock(&abe->mutex);
dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
switch (dai->id) {
case OMAP_ABE_FRONTEND_DAI_MODEM:
break;
case OMAP_ABE_FRONTEND_DAI_LP_MEDIA:
snd_soc_set_runtime_hwparams(substream, &omap_abe_hardware);
ret = snd_pcm_hw_constraint_step(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 1024);
break;
default:
/*
* Period size must be aligned with the Audio Engine
* processing loop which is 250 us long
*/
ret = snd_pcm_hw_rule_add(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
omap_abe_hwrule_period_step,
NULL,
SNDRV_PCM_HW_PARAM_PERIOD_SIZE, -1);
break;
}
if (ret < 0) {
dev_err(abe->dev, "failed to set period constraints for DAI %d\n",
dai->id);
goto out;
}
omap_abe_pm_runtime_get_sync(abe);
if (!abe->active++) {
abe->opp.level = 0;
ret = abe_pm_restore_context(abe);
if (ret)
goto out;
omap_aess_wakeup(abe->aess);
}
out:
mutex_unlock(&abe->mutex);
return ret;
}
示例14: omap_hdmi_dai_startup
static int omap_hdmi_dai_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
int err;
/*
* Make sure that the period bytes are multiple of the DMA packet size.
* Largest packet size we use is 32 32-bit words = 128 bytes
*/
err = snd_pcm_hw_constraint_step(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 128);
if (err < 0)
return err;
return 0;
}
示例15: omap_mcbsp_dai_startup
static int omap_mcbsp_dai_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *cpu_dai)
{
struct omap_mcbsp_data *mcbsp_data = snd_soc_dai_get_drvdata(cpu_dai);
int bus_id = mcbsp_data->bus_id;
int err = 0;
if (!cpu_dai->active) {
err = omap_mcbsp_request(bus_id);
cpu_dai->active = 1;
}
/*
* OMAP3 McBSP FIFO is word structured.
* McBSP2 has 1024 + 256 = 1280 word long buffer,
* McBSP1,3,4,5 has 128 word long buffer
* This means that the size of the FIFO depends on the sample format.
* For example on McBSP3:
* 16bit samples: size is 128 * 2 = 256 bytes
* 32bit samples: size is 128 * 4 = 512 bytes
* It is simpler to place constraint for buffer and period based on
* channels.
* McBSP3 as example again (16 or 32 bit samples):
* 1 channel (mono): size is 128 frames (128 words)
* 2 channels (stereo): size is 128 / 2 = 64 frames (2 * 64 words)
* 4 channels: size is 128 / 4 = 32 frames (4 * 32 words)
*/
if (cpu_is_omap34xx() || cpu_is_omap44xx()) {
/*
* Rule for the buffer size. We should not allow
* smaller buffer than the FIFO size to avoid underruns
*/
#if 0 // FIXME: All BE must support hw_rules and constraints */
snd_pcm_hw_rule_add(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_CHANNELS,
omap_mcbsp_hwrule_min_buffersize,
mcbsp_data,
SNDRV_PCM_HW_PARAM_BUFFER_SIZE, -1);
/* Make sure, that the period size is always even */
snd_pcm_hw_constraint_step(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 2);
#endif
}
return err;
}