*参照元 [#h2e020d9] #backlinks *説明 [#b2eff44c] -パス: [[linux-2.6.33/sound/core/pcm_native.c]] -FIXME: これは何? --説明 **引数 [#f0c822e8] -struct snd_pcm_substream *substream -- --[[linux-2.6.33/snd_pcm_substream]] struct snd_pcm_hw_params *params -struct snd_pcm_hw_params *params -- --[[linux-2.6.33/snd_pcm_hw_params]] **返り値 [#pb977496] -int **参考 [#m6f00da6] *実装 [#fb31f3fc] static int snd_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_pcm_runtime *runtime; int err, usecs; unsigned int bits; snd_pcm_uframes_t frames; - --[[linux-2.6.33/snd_pcm_runtime]] - --[[linux-2.6.33/snd_pcm_uframes_t]] if (PCM_RUNTIME_CHECK(substream)) return -ENXIO; - --[[linux-2.6.33/PCM_RUNTIME_CHECK()]] runtime = substream->runtime; snd_pcm_stream_lock_irq(substream); - --[[linux-2.6.33/snd_pcm_stream_lock_irq()]] switch (runtime->status->state) { case SNDRV_PCM_STATE_OPEN: case SNDRV_PCM_STATE_SETUP: case SNDRV_PCM_STATE_PREPARED: break; default: snd_pcm_stream_unlock_irq(substream); return -EBADFD; } snd_pcm_stream_unlock_irq(substream); - --[[linux-2.6.33/SNDRV_PCM_STATE_OPEN]] - --[[linux-2.6.33/SNDRV_PCM_STATE_SETUP]] - --[[linux-2.6.33/SNDRV_PCM_STATE_PREPARED]] - --[[linux-2.6.33/snd_pcm_stream_unlock_irq()]] #if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE) - --[[linux-2.6.33/CONFIG_SND_PCM_OSS]] - --[[linux-2.6.33/CONFIG_SND_PCM_OSS_MODULE]] if (!substream->oss.oss) #endif if (atomic_read(&substream->mmap_count)) return -EBADFD; - --[[linux-2.6.33/atomic_read()]] params->rmask = ~0U; err = snd_pcm_hw_refine(substream, params); if (err < 0) goto _error; - --[[linux-2.6.33/snd_pcm_hw_refine()]] err = snd_pcm_hw_params_choose(substream, params); if (err < 0) goto _error; - --[[linux-2.6.33/snd_pcm_hw_params_choose()]] if (substream->ops->hw_params != NULL) { err = substream->ops->hw_params(substream, params); if (err < 0) goto _error; } - --substream->ops は snd_pcm_ops 型のメンバ --[[linux-2.6.33/snd_pcm_ops]] runtime->access = params_access(params); runtime->format = params_format(params); runtime->subformat = params_subformat(params); runtime->channels = params_channels(params); runtime->rate = params_rate(params); runtime->period_size = params_period_size(params); runtime->periods = params_periods(params); runtime->buffer_size = params_buffer_size(params); runtime->info = params->info; runtime->rate_num = params->rate_num; runtime->rate_den = params->rate_den; - --[[linux-2.6.33/params_access()]] - --[[linux-2.6.33/params_format()]] - --[[linux-2.6.33/params_subformat()]] - --[[linux-2.6.33/params_channels()]] - --[[linux-2.6.33/params_rate()]] - --[[linux-2.6.33/params_period_size()]] - --[[linux-2.6.33/params_periods()]] - --[[linux-2.6.33/params_buffer_size()]] bits = snd_pcm_format_physical_width(runtime->format); runtime->sample_bits = bits; bits *= runtime->channels; runtime->frame_bits = bits; frames = 1; - --[[linux-2.6.33/snd_pcm_format_physical_width()]] while (bits % 8 != 0) { bits *= 2; frames *= 2; } runtime->byte_align = bits / 8; runtime->min_align = frames; /* Default sw params */ runtime->tstamp_mode = SNDRV_PCM_TSTAMP_NONE; runtime->period_step = 1; runtime->control->avail_min = runtime->period_size; runtime->start_threshold = 1; runtime->stop_threshold = runtime->buffer_size; runtime->silence_threshold = 0; runtime->silence_size = 0; runtime->boundary = runtime->buffer_size; while (runtime->boundary * 2 <= LONG_MAX - runtime->buffer_size) runtime->boundary *= 2; - --[[linux-2.6.33/SNDRV_PCM_TSTAMP_NONE]] snd_pcm_timer_resolution_change(substream); runtime->status->state = SNDRV_PCM_STATE_SETUP; - --[[linux-2.6.33/snd_pcm_timer_resolution_change()]] - --[[linux-2.6.33/SNDRV_PCM_STATE_SETUP]] pm_qos_remove_requirement(PM_QOS_CPU_DMA_LATENCY, substream->latency_id); - --[[linux-2.6.33/pm_qos_remove_requirement()]] - --[[linux-2.6.33/PM_QOS_CPU_DMA_LATENCY]] if ((usecs = period_to_usecs(runtime)) >= 0) pm_qos_add_requirement(PM_QOS_CPU_DMA_LATENCY, substream->latency_id, usecs); - --[[linux-2.6.33/period_to_usecs()]] - --[[linux-2.6.33/pm_qos_add_requirement()]] return 0; _error: /* hardware might be unuseable from this time, so we force application to retry to set the correct hardware parameter settings */ runtime->status->state = SNDRV_PCM_STATE_OPEN; if (substream->ops->hw_free != NULL) substream->ops->hw_free(substream); - --[[linux-2.6.33/SNDRV_PCM_STATE_OPEN]] return err; } *コメント [#e3348165]