sound/soc/codecs/aw87390.c

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

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/aw87390.c
Extension
.c
Size
16861 bytes
Lines
620
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 (data[i] == AW87390_DELAY_REG_ADDR) {
			usleep_range(data[i + 1] * AW87390_REG_DELAY_TIME,
					data[i + 1] * AW87390_REG_DELAY_TIME + 10);
			continue;
		}
		ret = regmap_write(aw_dev->regmap, data[i], data[i + 1]);
		if (ret)
			return ret;
	}

	return 0;
}

static int aw87390_dev_get_prof_name(struct aw_device *aw_dev, int index, char **prof_name)
{
	struct aw_prof_info *prof_info = &aw_dev->prof_info;
	struct aw_prof_desc *prof_desc;

	if ((index >= aw_dev->prof_info.count) || (index < 0)) {
		dev_err(aw_dev->dev, "index[%d] overflow count[%d]\n",
			index, aw_dev->prof_info.count);
		return -EINVAL;
	}

	prof_desc = &aw_dev->prof_info.prof_desc[index];

	*prof_name = prof_info->prof_name_list[prof_desc->id];

	return 0;
}

static int aw87390_dev_get_prof_data(struct aw_device *aw_dev, int index,
			struct aw_prof_desc **prof_desc)
{
	if ((index >= aw_dev->prof_info.count) || (index < 0)) {
		dev_err(aw_dev->dev, "%s: index[%d] overflow count[%d]\n",
				__func__, index, aw_dev->prof_info.count);
		return -EINVAL;
	}

	*prof_desc = &aw_dev->prof_info.prof_desc[index];

	return 0;
}

static int aw87390_dev_fw_update(struct aw_device *aw_dev)
{
	struct aw_prof_desc *prof_index_desc;
	struct aw_sec_data_desc *sec_desc;
	char *prof_name;
	int ret;

	ret = aw87390_dev_get_prof_name(aw_dev, aw_dev->prof_index, &prof_name);
	if (ret) {
		dev_err(aw_dev->dev, "get prof name failed\n");
		return -EINVAL;
	}

	dev_dbg(aw_dev->dev, "start update %s", prof_name);

	ret = aw87390_dev_get_prof_data(aw_dev, aw_dev->prof_index, &prof_index_desc);
	if (ret) {
		dev_err(aw_dev->dev, "aw87390_dev_get_prof_data failed\n");
		return ret;
	}

	/* update reg */
	sec_desc = prof_index_desc->sec_desc;
	ret = aw87390_dev_reg_update(aw_dev, sec_desc[AW88395_DATA_TYPE_REG].data,
					sec_desc[AW88395_DATA_TYPE_REG].len);
	if (ret) {
		dev_err(aw_dev->dev, "update reg failed\n");
		return ret;
	}

	aw_dev->prof_cur = aw_dev->prof_index;

	return 0;
}

static int aw87390_power_off(struct aw_device *aw_dev)
{
	int ret;

	if (aw_dev->status == AW87390_DEV_PW_OFF) {
		dev_dbg(aw_dev->dev, "already power off\n");
		return 0;
	}

	ret = regmap_write(aw_dev->regmap, AW87390_SYSCTRL_REG, AW87390_POWER_DOWN_VALUE);

Annotation

Implementation Notes