sound/soc/codecs/aw88395/aw88395.c

Source file repositories/reference/linux-study-clean/sound/soc/codecs/aw88395/aw88395.c

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/aw88395/aw88395.c
Extension
.c
Size
15381 bytes
Lines
579
Domain
Driver Families
Bucket
sound/soc
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 (ret) {
			dev_err(aw88395->aw_pa->dev, "aw88395 device start failed. retry = %d", i);
			ret = aw88395_dev_fw_update(aw88395->aw_pa, AW88395_DSP_FW_UPDATE_ON, true);
			if (ret < 0) {
				dev_err(aw88395->aw_pa->dev, "fw update failed");
				continue;
			}
		} else {
			dev_info(aw88395->aw_pa->dev, "start success\n");
			break;
		}
	}
}

static void aw88395_startup_work(struct work_struct *work)
{
	struct aw88395 *aw88395 =
		container_of(work, struct aw88395, start_work.work);

	mutex_lock(&aw88395->lock);
	aw88395_start_pa(aw88395);
	mutex_unlock(&aw88395->lock);
}

static void aw88395_start(struct aw88395 *aw88395, bool sync_start)
{
	int ret;

	if (aw88395->aw_pa->fw_status != AW88395_DEV_FW_OK)
		return;

	if (aw88395->aw_pa->status == AW88395_DEV_PW_ON)
		return;

	ret = aw88395_dev_fw_update(aw88395->aw_pa, AW88395_DSP_FW_UPDATE_OFF, true);
	if (ret < 0) {
		dev_err(aw88395->aw_pa->dev, "fw update failed.");
		return;
	}

	if (sync_start == AW88395_SYNC_START)
		aw88395_start_pa(aw88395);
	else
		queue_delayed_work(system_dfl_wq,
			&aw88395->start_work,
			AW88395_START_WORK_DELAY_MS);
}

static struct snd_soc_dai_driver aw88395_dai[] = {
	{
		.name = "aw88395-aif",
		.id = 1,
		.playback = {
			.stream_name = "Speaker_Playback",
			.channels_min = 1,
			.channels_max = 2,
			.rates = AW88395_RATES,
			.formats = AW88395_FORMATS,
		},
		.capture = {
			.stream_name = "Speaker_Capture",
			.channels_min = 1,
			.channels_max = 2,
			.rates = AW88395_RATES,
			.formats = AW88395_FORMATS,
		},
	},
};

static int aw88395_get_fade_in_time(struct snd_kcontrol *kcontrol,
	struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
	struct aw88395 *aw88395 = snd_soc_component_get_drvdata(component);
	struct aw_device *aw_dev = aw88395->aw_pa;

	ucontrol->value.integer.value[0] = aw_dev->fade_in_time;

	return 0;
}

static int aw88395_set_fade_in_time(struct snd_kcontrol *kcontrol,
	struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
	struct aw88395 *aw88395 = snd_soc_component_get_drvdata(component);
	struct soc_mixer_control *mc =
		(struct soc_mixer_control *)kcontrol->private_value;
	struct aw_device *aw_dev = aw88395->aw_pa;
	int time;

Annotation

Implementation Notes