Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 08d48d49 authored by Meng Wang's avatar Meng Wang
Browse files

ASoC: AQT1000: add codec entry for AQT1000 codec



Add codec entry for AQT1000 codec to support ADIE calibration.
Add new hwdep node AQT1000_CODEC_HWDEP_NODE to store ANC/MBHC
calibration data.

Change-Id: I8b5ff9a2cfe2a0a8ac593b63b20b28697dc975bf
Signed-off-by: default avatarMeng Wang <mwang@codeaurora.org>
parent 3e42fefa
Loading
Loading
Loading
Loading
+78 −1
Original line number Diff line number Diff line
@@ -39,13 +39,14 @@
#include "../wcdcal-hwdep.h"
#include "aqt1000-internal.h"

#define AQT1000_CODEC_HWDEP_NODE 1001
#define AQT1000_TX_UNMUTE_DELAY_MS 40
#define  TX_HPF_CUT_OFF_FREQ_MASK 0x60
#define  CF_MIN_3DB_4HZ     0x0
#define  CF_MIN_3DB_75HZ    0x1
#define  CF_MIN_3DB_150HZ   0x2

#define AQT_VERSION_ENTRY_SIZE 17

static struct interp_sample_rate sr_val_tbl[] = {
	{8000, 0x0}, {16000, 0x1}, {32000, 0x3}, {48000, 0x4}, {96000, 0x5},
	{192000, 0x6}, {384000, 0x7}, {44100, 0x9}, {88200, 0xA},
@@ -3024,6 +3025,82 @@ static int aqt_set_micbias(struct aqt1000 *aqt,
	return 0;
}

static ssize_t aqt_codec_version_read(struct snd_info_entry *entry,
					void *file_private_data,
					struct file *file,
					char __user *buf, size_t count,
					loff_t pos)
{
	char buffer[AQT_VERSION_ENTRY_SIZE];
	int len = 0;

	len = snprintf(buffer, sizeof(buffer), "AQT1000_1_0\n");

	return simple_read_from_buffer(buf, count, &pos, buffer, len);
}

static struct snd_info_entry_ops aqt_codec_info_ops = {
	.read = aqt_codec_version_read,
};

/*
 * aqt_codec_info_create_codec_entry - creates aqt1000 module
 * @codec_root: The parent directory
 * @codec: Codec instance
 *
 * Creates aqt1000 module and version entry under the given
 * parent directory.
 *
 * Return: 0 on success or negative error code on failure.
 */
int aqt_codec_info_create_codec_entry(struct snd_info_entry *codec_root,
				struct snd_soc_codec *codec)
{
	struct snd_info_entry *version_entry;
	struct aqt1000 *aqt;
	struct snd_soc_card *card;

	if (!codec_root || !codec)
		return -EINVAL;

	aqt = snd_soc_codec_get_drvdata(codec);
	if (!aqt) {
		dev_dbg(codec->dev, "%s: aqt is NULL\n", __func__);
		return _EINVAL;
	}
	card = codec->component.card;
	aqt->entry = snd_info_create_subdir(codec_root->module,
					   "aqt1000", codec_root);
	if (!aqt->entry) {
		dev_dbg(codec->dev, "%s: failed to create aqt1000 entry\n",
			__func__);
		return -ENOMEM;
	}

	version_entry = snd_info_create_card_entry(card->snd_card,
						  "version",
						   aqt->entry);
	if (!version_entry) {
		dev_dbg(codec->dev, "%s: failed to create aqt1000 version entry\n",
			__func__);
		return -ENOMEM;
	}

	version_entry->private_data = aqt;
	version_entry->size = AQT_VERSION_ENTRY_SIZE;
	version_entry->content = SNDRV_INFO_CONTENT_DATA;
	version_entry->c.ops = &aqt_codec_info_ops;

	if (snd_info_register(version_entry) < 0) {
		snd_info_free_entry(version_entry);
		return -ENOMEM;
	}
	aqt->version_entry = version_entry;

	return 0;
}
EXPORT_SYMBOL(aqt_codec_info_create_codec_entry);

static const struct aqt_reg_mask_val aqt_codec_reg_init[] = {
	{AQT1000_CHIP_CFG0_CLK_CFG_MCLK, 0x04, 0x00},
	{AQT1000_CHIP_CFG0_EFUSE_CTL, 0x01, 0x01},
+4 −0
Original line number Diff line number Diff line
@@ -220,6 +220,10 @@ struct aqt1000 {
	struct irq_domain *virq;
	int irq;
	int irq_base;

	/* Entry for version info */
	struct snd_info_entry *entry;
	struct snd_info_entry *version_entry;
};

#endif /* AQT1000_H */
+1 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
#define _CALIB_HWDEP_H

#define WCD9XXX_CODEC_HWDEP_NODE    1000
#define AQT1000_CODEC_HWDEP_NODE    1001
enum wcd_cal_type {
	WCD9XXX_MIN_CAL,
	WCD9XXX_ANC_CAL = WCD9XXX_MIN_CAL,