static int mxc_hdmi_codec_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct mxc_hdmi_priv *hdmi_priv = snd_soc_dai_get_drvdata(dai); struct snd_pcm_runtime *runtime = substream->runtime; int ret; clk_enable(hdmi_priv->isfr_clk); clk_enable(hdmi_priv->iahb_clk); pr_debug("%s hdmi clks: isfr:%d iahb:%d\n", __func__, (int)clk_get_rate(hdmi_priv->isfr_clk), (int)clk_get_rate(hdmi_priv->iahb_clk)); ret = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &playback_rate_constraints); if (ret < 0) return ret; ret = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); if (ret < 0) return ret; hdmi_set_audio_flat(0); hdmi_set_audio_infoframe(); return 0; }
static int snd_atiixp_pcm_open(struct snd_pcm_substream *substream, struct atiixp_dma *dma, int pcm_type) { struct atiixp *chip = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; int err; if (snd_BUG_ON(!dma->ops || !dma->ops->enable_dma)) return -EINVAL; if (dma->opened) return -EBUSY; dma->substream = substream; runtime->hw = snd_atiixp_pcm_hw; dma->ac97_pcm_type = pcm_type; if (pcm_type >= 0) { runtime->hw.rates = chip->pcms[pcm_type]->rates; snd_pcm_limit_hw_rates(runtime); } else { /* direct SPDIF */ runtime->hw.formats = SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE; } if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) return err; runtime->private_data = dma; /* enable DMA bits */ spin_lock_irq(&chip->reg_lock); dma->ops->enable_dma(chip, 1); spin_unlock_irq(&chip->reg_lock); dma->opened = 1; return 0; }
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; }
/* 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; }
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; }
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; }
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; }
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; }
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); }
/* open callback */ static int snd_vortex_pcm_open(struct snd_pcm_substream *substream) { vortex_t *vortex = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; int err; /* Force equal size periods */ if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) return err; /* Avoid PAGE_SIZE boundary to fall inside of a period. */ if ((err = snd_pcm_hw_constraint_pow2(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES)) < 0) return err; if (VORTEX_PCM_TYPE(substream->pcm) != VORTEX_PCM_WT) { #ifndef CHIP_AU8820 if (VORTEX_PCM_TYPE(substream->pcm) == VORTEX_PCM_A3D) { runtime->hw = snd_vortex_playback_hw_a3d; } #endif if (VORTEX_PCM_TYPE(substream->pcm) == VORTEX_PCM_SPDIF) { runtime->hw = snd_vortex_playback_hw_spdif; switch (vortex->spdif_sr) { case 32000: runtime->hw.rates = SNDRV_PCM_RATE_32000; break; case 44100: runtime->hw.rates = SNDRV_PCM_RATE_44100; break; case 48000: runtime->hw.rates = SNDRV_PCM_RATE_48000; break; } } if (VORTEX_PCM_TYPE(substream->pcm) == VORTEX_PCM_ADB || VORTEX_PCM_TYPE(substream->pcm) == VORTEX_PCM_I2S) runtime->hw = snd_vortex_playback_hw_adb; #ifdef CHIP_AU8830 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && VORTEX_PCM_TYPE(substream->pcm) == VORTEX_PCM_ADB) { runtime->hw.channels_max = 4; snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, &hw_constraints_au8830_channels); } #endif substream->runtime->private_data = NULL; } #ifndef CHIP_AU8810 else { runtime->hw = snd_vortex_playback_hw_wt; substream->runtime->private_data = NULL; } #endif return 0; }
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; }
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; }
/** * 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; }
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; }
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; }
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; }
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; }
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; }
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); }
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); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { dmap = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); setup_dma_tx_request(&prtd->dma_req[0], dmap); setup_dma_tx_request(&prtd->dma_req[1], dmap); } else { dmap = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); setup_dma_rx_request(&prtd->dma_req[0], dmap); setup_dma_rx_request(&prtd->dma_req[1], dmap); } prtd->dma_req[0].dev = prtd; prtd->dma_req[1].dev = prtd; prtd->dma_chan = tegra_dma_allocate_channel(TEGRA_DMA_MODE_ONESHOT); if (prtd->dma_chan == NULL) { ret = -ENOMEM; goto err; } /* */ snd_soc_set_runtime_hwparams(substream, &tegra_pcm_hardware); /* */ 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; }
static int mtk_voice_extint_pcm_open(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; int err = 0; int ret = 0; AudDrv_Clk_On(); AudDrv_ADC_Clk_On(); printk("mtk_voice_extint_pcm_open\n"); if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { printk("%s with SNDRV_PCM_STREAM_CAPTURE \n",__func__); runtime->rate = 16000; if(Voice_ExtInt_Status != 0) { return 0; } } runtime->hw = mtk_pcm_hardware; memcpy((void *)(&(runtime->hw)), (void *)&mtk_pcm_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"); } //print for hw pcm information printk("mtk_voice_extint_pcm_open runtime rate = %d channels = %d \n", runtime->rate, runtime->channels); runtime->hw.info |= SNDRV_PCM_INFO_INTERLEAVED; runtime->hw.info |= SNDRV_PCM_INFO_NONINTERLEAVED; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { printk("SNDRV_PCM_STREAM_PLAYBACK mtkalsa_voice_extint_constraints\n"); runtime->rate = 16000; } else { } if (err < 0) { printk("mtk_voice_extint_close\n"); mtk_voice_extint_close(substream); return err; } printk("mtk_voice_extint_pcm_open return\n"); return 0; }
static int dw_pcm_open(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *rtd = substream->private_data; struct dw_i2s_dev *dev = snd_soc_dai_get_drvdata(rtd->cpu_dai); snd_soc_set_runtime_hwparams(substream, &dw_pcm_hardware); snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); runtime->private_data = dev; return 0; }
static int rsnd_pcm_open(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; int ret = 0; snd_soc_set_runtime_hwparams(substream, &rsnd_pcm_hardware); ret = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); return ret; }
static int snd_ivtv_pcm_capture_open(struct snd_pcm_substream *substream) { struct snd_ivtv_card *itvsc = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; struct v4l2_device *v4l2_dev = itvsc->v4l2_dev; struct ivtv *itv = to_ivtv(v4l2_dev); struct ivtv_stream *s; struct ivtv_open_id item; int ret; /* Instruct the CX2341[56] to start sending packets */ snd_ivtv_lock(itvsc); if (ivtv_init_on_first_open(itv)) { snd_ivtv_unlock(itvsc); return -ENXIO; } s = &itv->streams[IVTV_ENC_STREAM_TYPE_PCM]; v4l2_fh_init(&item.fh, s->vdev); item.itv = itv; item.type = s->type; /* See if the stream is available */ if (ivtv_claim_stream(&item, item.type)) { /* No, it's already in use */ snd_ivtv_unlock(itvsc); return -EBUSY; } if (test_bit(IVTV_F_S_STREAMOFF, &s->s_flags) || test_and_set_bit(IVTV_F_S_STREAMING, &s->s_flags)) { /* We're already streaming. No additional action required */ snd_ivtv_unlock(itvsc); return 0; } runtime->hw = snd_ivtv_hw_capture; snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); itvsc->capture_pcm_substream = substream; runtime->private_data = itv; itv->pcm_announce_callback = ivtv_alsa_announce_pcm_data; /* Not currently streaming, so start it up */ set_bit(IVTV_F_S_STREAMING, &s->s_flags); ret = ivtv_start_v4l2_encode_stream(s); snd_ivtv_unlock(itvsc); return ret; }
static int sunxi_pcm_open(struct snd_pcm_substream *substream) { int ret = 0; struct snd_soc_pcm_runtime *rtd = substream->private_data; struct device *dev = rtd->platform->dev; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { /* Set HW params now that initialization is complete */ snd_soc_set_runtime_hwparams(substream, &sunxi_pcm_play_hardware); ret = snd_pcm_hw_constraint_integer(substream->runtime, SNDRV_PCM_HW_PARAM_PERIODS); if (ret < 0) return ret; #ifdef CONFIG_ARCH_SUN9IW1 ret = snd_dmaengine_pcm_open(substream, sunxi_rdma_filter_fn, (void *)SUNXI_RDMA_DRV); #else ret = snd_dmaengine_pcm_open(substream, NULL, NULL); #endif if (ret) { dev_err(dev, "dmaengine pcm open failed with err %d\n", ret); } } else { /* Set HW params now that initialization is complete */ snd_soc_set_runtime_hwparams(substream, &sunxi_pcm_capture_hardware); ret = snd_pcm_hw_constraint_integer(substream->runtime, SNDRV_PCM_HW_PARAM_PERIODS); if (ret < 0) return ret; #ifdef CONFIG_ARCH_SUN9IW1 ret = snd_dmaengine_pcm_open(substream, sunxi_rdma_filter_fn, SUNXI_RDMA_DRV); #else ret = snd_dmaengine_pcm_open(substream, NULL, NULL); #endif if (ret) { dev_err(dev, "dmaengine pcm open failed with err %d\n", ret); } } return 0; }
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; }
static int sun7i_pcm_open(struct snd_pcm_substream *substream) { struct sun7i_playback_runtime_data *play_prtd = NULL; struct sun7i_capture_runtime_data *capture_prtd = NULL; struct snd_pcm_runtime *play_runtime = NULL; struct snd_pcm_runtime *capture_runtime = NULL; /*pr_info("CAPTUR:sun7i_i2sdma.c::func:%s(line:%d)\n",__func__,__LINE__);*/ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { play_runtime = substream->runtime; snd_pcm_hw_constraint_integer(play_runtime, SNDRV_PCM_HW_PARAM_PERIODS); snd_soc_set_runtime_hwparams(substream, &sun7i_pcm_play_hardware); play_prtd = kzalloc(sizeof(struct sun7i_playback_runtime_data), GFP_KERNEL); if (play_prtd == NULL) { return -ENOMEM; } spin_lock_init(&play_prtd->lock); play_runtime->private_data = play_prtd; } else { capture_runtime = substream->runtime; snd_pcm_hw_constraint_integer(capture_runtime, SNDRV_PCM_HW_PARAM_PERIODS); snd_soc_set_runtime_hwparams(substream, &sun7i_pcm_capture_hardware); capture_prtd = kzalloc(sizeof(struct sun7i_capture_runtime_data), GFP_KERNEL); if (capture_prtd == NULL) return -ENOMEM; spin_lock_init(&capture_prtd->lock); capture_runtime->private_data = capture_prtd; } return 0; }
static int snd_cs5535audio_capture_open(struct snd_pcm_substream *substream) { int err; struct cs5535audio *cs5535au = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; runtime->hw = snd_cs5535audio_capture; cs5535au->capture_substream = substream; runtime->private_data = &(cs5535au->dmas[CS5535AUDIO_DMA_CAPTURE]); if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) return err; return 0; }
/** * snd_intelmad_open- to set runtime parameters during stream start * * @substream: substream for which the function is called * @type: audio device type * * This function is called by ALSA framework when stream is started */ static int snd_intelmad_open(struct snd_pcm_substream *substream, enum snd_sst_audio_device_type type) { struct snd_intelmad *intelmaddata; struct snd_pcm_runtime *runtime; struct mad_stream_pvt *stream; WARN_ON(!substream); pr_debug("snd_intelmad_open called\n"); intelmaddata = snd_pcm_substream_chip(substream); runtime = substream->runtime; /* set the runtime hw parameter with local snd_pcm_hardware struct */ runtime->hw = snd_intelmad_stream; if (intelmaddata->cpu_id == CPU_CHIP_LINCROFT) { /* * MRST firmware currently denies stereo recording requests. */ if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { runtime->hw.formats = (SNDRV_PCM_FMTBIT_S16 | SNDRV_PCM_FMTBIT_U16); runtime->hw.channels_max = 1; } } if (intelmaddata->cpu_id == CPU_CHIP_PENWELL) { runtime->hw = snd_intelmad_stream; runtime->hw.rates = SNDRV_PCM_RATE_48000; runtime->hw.rate_min = MAX_RATE; runtime->hw.formats = (SNDRV_PCM_FMTBIT_S24 | SNDRV_PCM_FMTBIT_U24); if (intelmaddata->sstdrv_ops->scard_ops->input_dev_id == AMIC) runtime->hw.channels_max = MAX_CHANNEL_AMIC; else runtime->hw.channels_max = MAX_CHANNEL_DMIC; } /* setup the internal datastruture stream pointers based on it being playback or capture stream */ stream = kzalloc(sizeof(*stream), GFP_KERNEL); if (!stream) return -ENOMEM; stream->stream_info.str_id = 0; stream->device = type; stream->stream_status = INIT; runtime->private_data = stream; return snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); }
static int msm_pcm_open(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct msm_audio *prtd; int ret = 0; prtd = kzalloc(sizeof(struct msm_audio), GFP_KERNEL); if (prtd == NULL) { ret = -ENOMEM; return ret; } if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { runtime->hw = msm_pcm_playback_hardware; prtd->dir = SNDRV_PCM_STREAM_PLAYBACK; prtd->playback_substream = substream; prtd->eos_ack = 0; ret = msm_audio_volume_update(PCMPLAYBACK_DECODERID, msm_vol_ctl.volume, msm_vol_ctl.pan); } else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { runtime->hw = msm_pcm_capture_hardware; prtd->dir = SNDRV_PCM_STREAM_CAPTURE; prtd->capture_substream = substream; } ret = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &constraints_sample_rates); if (ret < 0) goto out; /* 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->ops = &snd_msm_audio_ops; prtd->out[0].used = BUF_INVALID_LEN; prtd->out_head = 1; /* point to second buffer on startup */ runtime->private_data = prtd; ret = alsa_adsp_configure(prtd); if (ret) goto out; copy_count = 0; return 0; out: kfree(prtd); return ret; }