sound/firewire/bebob/bebob_pcm.c

Source file repositories/reference/linux-study-clean/sound/firewire/bebob/bebob_pcm.c

File Facts

System
Linux kernel
Corpus path
sound/firewire/bebob/bebob_pcm.c
Extension
.c
Size
9408 bytes
Lines
369
Domain
Driver Families
Bucket
sound/firewire
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (err < 0) {
				dev_err(&bebob->unit->device,
					"fail to get sampling rate: %d\n", err);
				goto err_locked;
			}

			substream->runtime->hw.rate_min = sampling_rate;
			substream->runtime->hw.rate_max = sampling_rate;

			if (frames_per_period > 0) {
				err = snd_pcm_hw_constraint_minmax(substream->runtime,
								   SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
								   frames_per_period, frames_per_period);
				if (err < 0)
					goto err_locked;

				err = snd_pcm_hw_constraint_minmax(substream->runtime,
								   SNDRV_PCM_HW_PARAM_BUFFER_SIZE,
								   frames_per_buffer, frames_per_buffer);
				if (err < 0)
					goto err_locked;
			}
		}
	}

	snd_pcm_set_sync(substream);

	return 0;
err_locked:
	snd_bebob_stream_lock_release(bebob);
	return err;
}

static int
pcm_close(struct snd_pcm_substream *substream)
{
	struct snd_bebob *bebob = substream->private_data;
	snd_bebob_stream_lock_release(bebob);
	return 0;
}

static int pcm_hw_params(struct snd_pcm_substream *substream,
			 struct snd_pcm_hw_params *hw_params)
{
	struct snd_bebob *bebob = substream->private_data;
	int err = 0;

	if (substream->runtime->state == SNDRV_PCM_STATE_OPEN) {
		unsigned int rate = params_rate(hw_params);
		unsigned int frames_per_period = params_period_size(hw_params);
		unsigned int frames_per_buffer = params_buffer_size(hw_params);

		guard(mutex)(&bebob->mutex);
		err = snd_bebob_stream_reserve_duplex(bebob, rate,
					frames_per_period, frames_per_buffer);
		if (err >= 0)
			++bebob->substreams_counter;
	}

	return err;
}

static int pcm_hw_free(struct snd_pcm_substream *substream)
{
	struct snd_bebob *bebob = substream->private_data;

	guard(mutex)(&bebob->mutex);

	if (substream->runtime->state != SNDRV_PCM_STATE_OPEN)
		bebob->substreams_counter--;

	snd_bebob_stream_stop_duplex(bebob);

	return 0;
}

static int
pcm_capture_prepare(struct snd_pcm_substream *substream)
{
	struct snd_bebob *bebob = substream->private_data;
	int err;

	err = snd_bebob_stream_start_duplex(bebob);
	if (err >= 0)
		amdtp_stream_pcm_prepare(&bebob->tx_stream);

	return err;
}
static int
pcm_playback_prepare(struct snd_pcm_substream *substream)

Annotation

Implementation Notes