linux/sound/soc/sunxi/sun8i-codec-analog.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * This driver supports the analog controls for the internal codec
 * found in Allwinner's A31s, A23, A33 and H3 SoCs.
 *
 * Copyright 2016 Chen-Yu Tsai <[email protected]>
 */

#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>

#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include <sound/tlv.h>

#include "sun8i-adda-pr-regmap.h"

/* Codec analog control register offsets and bit fields */
#define SUN8I_ADDA_HP_VOLC
#define SUN8I_ADDA_HP_VOLC_PA_CLK_GATE
#define SUN8I_ADDA_HP_VOLC_HP_VOL
#define SUN8I_ADDA_LOMIXSC
#define SUN8I_ADDA_LOMIXSC_MIC1
#define SUN8I_ADDA_LOMIXSC_MIC2
#define SUN8I_ADDA_LOMIXSC_PHONE
#define SUN8I_ADDA_LOMIXSC_PHONEN
#define SUN8I_ADDA_LOMIXSC_LINEINL
#define SUN8I_ADDA_LOMIXSC_DACL
#define SUN8I_ADDA_LOMIXSC_DACR
#define SUN8I_ADDA_ROMIXSC
#define SUN8I_ADDA_ROMIXSC_MIC1
#define SUN8I_ADDA_ROMIXSC_MIC2
#define SUN8I_ADDA_ROMIXSC_PHONE
#define SUN8I_ADDA_ROMIXSC_PHONEP
#define SUN8I_ADDA_ROMIXSC_LINEINR
#define SUN8I_ADDA_ROMIXSC_DACR
#define SUN8I_ADDA_ROMIXSC_DACL
#define SUN8I_ADDA_DAC_PA_SRC
#define SUN8I_ADDA_DAC_PA_SRC_DACAREN
#define SUN8I_ADDA_DAC_PA_SRC_DACALEN
#define SUN8I_ADDA_DAC_PA_SRC_RMIXEN
#define SUN8I_ADDA_DAC_PA_SRC_LMIXEN
#define SUN8I_ADDA_DAC_PA_SRC_RHPPAMUTE
#define SUN8I_ADDA_DAC_PA_SRC_LHPPAMUTE
#define SUN8I_ADDA_DAC_PA_SRC_RHPIS
#define SUN8I_ADDA_DAC_PA_SRC_LHPIS
#define SUN8I_ADDA_PHONEIN_GCTRL
#define SUN8I_ADDA_PHONEIN_GCTRL_PHONEPG
#define SUN8I_ADDA_PHONEIN_GCTRL_PHONENG
#define SUN8I_ADDA_LINEIN_GCTRL
#define SUN8I_ADDA_LINEIN_GCTRL_LINEING
#define SUN8I_ADDA_LINEIN_GCTRL_PHONEG
#define SUN8I_ADDA_MICIN_GCTRL
#define SUN8I_ADDA_MICIN_GCTRL_MIC1G
#define SUN8I_ADDA_MICIN_GCTRL_MIC2G
#define SUN8I_ADDA_PAEN_HP_CTRL
#define SUN8I_ADDA_PAEN_HP_CTRL_HPPAEN
#define SUN8I_ADDA_PAEN_HP_CTRL_LINEOUTEN
#define SUN8I_ADDA_PAEN_HP_CTRL_HPCOM_FC
#define SUN8I_ADDA_PAEN_HP_CTRL_COMPTEN
#define SUN8I_ADDA_PAEN_HP_CTRL_PA_ANTI_POP_CTRL
#define SUN8I_ADDA_PAEN_HP_CTRL_LTRNMUTE
#define SUN8I_ADDA_PAEN_HP_CTRL_RTLNMUTE
#define SUN8I_ADDA_PHONEOUT_CTRL
#define SUN8I_ADDA_PHONEOUT_CTRL_PHONEOUTG
#define SUN8I_ADDA_PHONEOUT_CTRL_PHONEOUTEN
#define SUN8I_ADDA_PHONEOUT_CTRL_PHONEOUT_MIC1
#define SUN8I_ADDA_PHONEOUT_CTRL_PHONEOUT_MIC2
#define SUN8I_ADDA_PHONEOUT_CTRL_PHONEOUT_RMIX
#define SUN8I_ADDA_PHONEOUT_CTRL_PHONEOUT_LMIX
#define SUN8I_ADDA_PHONE_GAIN_CTRL
#define SUN8I_ADDA_PHONE_GAIN_CTRL_LINEOUT_VOL
#define SUN8I_ADDA_PHONE_GAIN_CTRL_PHONEPREG
#define SUN8I_ADDA_MIC2G_CTRL
#define SUN8I_ADDA_MIC2G_CTRL_MIC2AMPEN
#define SUN8I_ADDA_MIC2G_CTRL_MIC2BOOST
#define SUN8I_ADDA_MIC2G_CTRL_LINEOUTLEN
#define SUN8I_ADDA_MIC2G_CTRL_LINEOUTREN
#define SUN8I_ADDA_MIC2G_CTRL_LINEOUTLSRC
#define SUN8I_ADDA_MIC2G_CTRL_LINEOUTRSRC
#define SUN8I_ADDA_MIC1G_MICBIAS_CTRL
#define SUN8I_ADDA_MIC1G_MICBIAS_CTRL_HMICBIASEN
#define SUN8I_ADDA_MIC1G_MICBIAS_CTRL_MMICBIASEN
#define SUN8I_ADDA_MIC1G_MICBIAS_CTRL_HMICBIAS_MODE
#define SUN8I_ADDA_MIC1G_MICBIAS_CTRL_MIC1AMPEN
#define SUN8I_ADDA_MIC1G_MICBIAS_CTRL_MIC1BOOST
#define SUN8I_ADDA_LADCMIXSC
#define SUN8I_ADDA_LADCMIXSC_MIC1
#define SUN8I_ADDA_LADCMIXSC_MIC2
#define SUN8I_ADDA_LADCMIXSC_PHONE
#define SUN8I_ADDA_LADCMIXSC_PHONEN
#define SUN8I_ADDA_LADCMIXSC_LINEINL
#define SUN8I_ADDA_LADCMIXSC_OMIXRL
#define SUN8I_ADDA_LADCMIXSC_OMIXRR
#define SUN8I_ADDA_RADCMIXSC
#define SUN8I_ADDA_RADCMIXSC_MIC1
#define SUN8I_ADDA_RADCMIXSC_MIC2
#define SUN8I_ADDA_RADCMIXSC_PHONE
#define SUN8I_ADDA_RADCMIXSC_PHONEP
#define SUN8I_ADDA_RADCMIXSC_LINEINR
#define SUN8I_ADDA_RADCMIXSC_OMIXR
#define SUN8I_ADDA_RADCMIXSC_OMIXL
#define SUN8I_ADDA_RES
#define SUN8I_ADDA_RES_MMICBIAS_SEL
#define SUN8I_ADDA_RES_PA_ANTI_POP_CTRL
#define SUN8I_ADDA_ADC_AP_EN
#define SUN8I_ADDA_ADC_AP_EN_ADCREN
#define SUN8I_ADDA_ADC_AP_EN_ADCLEN
#define SUN8I_ADDA_ADC_AP_EN_ADCG

/* mixer controls */
static const struct snd_kcontrol_new sun8i_codec_mixer_controls[] =;

/* mixer controls */
static const struct snd_kcontrol_new sun8i_v3s_codec_mixer_controls[] =;

/* ADC mixer controls */
static const struct snd_kcontrol_new sun8i_codec_adc_mixer_controls[] =;

/* ADC mixer controls */
static const struct snd_kcontrol_new sun8i_v3s_codec_adc_mixer_controls[] =;

/* volume / mute controls */
static const DECLARE_TLV_DB_SCALE(sun8i_codec_out_mixer_pregain_scale,
				  -450, 150, 0);
static const DECLARE_TLV_DB_RANGE(sun8i_codec_mic_gain_scale,
	0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
	1, 7, TLV_DB_SCALE_ITEM(2400, 300, 0),
);

static const struct snd_kcontrol_new sun8i_codec_common_controls[] =;

static const struct snd_soc_dapm_widget sun8i_codec_common_widgets[] =;

static const struct snd_soc_dapm_widget sun8i_codec_mixer_widgets[] =;

static const struct snd_soc_dapm_widget sun8i_v3s_codec_mixer_widgets[] =;

static const struct snd_soc_dapm_route sun8i_codec_common_routes[] =;

static const struct snd_soc_dapm_route sun8i_codec_mixer_routes[] =;

/* headphone specific controls, widgets, and routes */
static const DECLARE_TLV_DB_SCALE(sun8i_codec_hp_vol_scale, -6300, 100, 1);
static const struct snd_kcontrol_new sun8i_codec_headphone_controls[] =;

static const char * const sun8i_codec_hp_src_enum_text[] =;

static SOC_ENUM_DOUBLE_DECL(sun8i_codec_hp_src_enum,
			    SUN8I_ADDA_DAC_PA_SRC,
			    SUN8I_ADDA_DAC_PA_SRC_LHPIS,
			    SUN8I_ADDA_DAC_PA_SRC_RHPIS,
			    sun8i_codec_hp_src_enum_text);

static const struct snd_kcontrol_new sun8i_codec_hp_src[] =;

static int sun8i_headphone_amp_event(struct snd_soc_dapm_widget *w,
				     struct snd_kcontrol *k, int event)
{}

static const struct snd_soc_dapm_widget sun8i_codec_headphone_widgets[] =;

static const struct snd_soc_dapm_route sun8i_codec_headphone_routes[] =;

static int sun8i_codec_add_headphone(struct snd_soc_component *cmpnt)
{}

/* mbias specific widget */
static const struct snd_soc_dapm_widget sun8i_codec_mbias_widgets[] =;

static int sun8i_codec_add_mbias(struct snd_soc_component *cmpnt)
{}

/* hmic specific widget */
static const struct snd_soc_dapm_widget sun8i_codec_hmic_widgets[] =;

static int sun8i_codec_add_hmic(struct snd_soc_component *cmpnt)
{}

/* line in specific controls, widgets and rines */
static const struct snd_kcontrol_new sun8i_codec_linein_controls[] =;

static const struct snd_soc_dapm_widget sun8i_codec_linein_widgets[] =;

static const struct snd_soc_dapm_route sun8i_codec_linein_routes[] =;

static int sun8i_codec_add_linein(struct snd_soc_component *cmpnt)
{}


/* line out specific controls, widgets and routes */
static const DECLARE_TLV_DB_RANGE(sun8i_codec_lineout_vol_scale,
	0, 1, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 1),
	2, 31, TLV_DB_SCALE_ITEM(-4350, 150, 0),
);
static const struct snd_kcontrol_new sun8i_codec_lineout_controls[] =;

static const char * const sun8i_codec_lineout_src_enum_text[] =;

static SOC_ENUM_DOUBLE_DECL(sun8i_codec_lineout_src_enum,
			    SUN8I_ADDA_MIC2G_CTRL,
			    SUN8I_ADDA_MIC2G_CTRL_LINEOUTLSRC,
			    SUN8I_ADDA_MIC2G_CTRL_LINEOUTRSRC,
			    sun8i_codec_lineout_src_enum_text);

static const struct snd_kcontrol_new sun8i_codec_lineout_src[] =;

static const struct snd_soc_dapm_widget sun8i_codec_lineout_widgets[] =;

static const struct snd_soc_dapm_route sun8i_codec_lineout_routes[] =;

static int sun8i_codec_add_lineout(struct snd_soc_component *cmpnt)
{}

/* mic2 specific controls, widgets and routes */
static const struct snd_kcontrol_new sun8i_codec_mic2_controls[] =;

static const struct snd_soc_dapm_widget sun8i_codec_mic2_widgets[] =;

static const struct snd_soc_dapm_route sun8i_codec_mic2_routes[] =;

static int sun8i_codec_add_mic2(struct snd_soc_component *cmpnt)
{}

struct sun8i_codec_analog_quirks {};

static const struct sun8i_codec_analog_quirks sun8i_a23_quirks =;

static const struct sun8i_codec_analog_quirks sun8i_h3_quirks =;

static int sun8i_codec_analog_add_mixer(struct snd_soc_component *cmpnt,
					const struct sun8i_codec_analog_quirks *quirks)
{}

static const struct sun8i_codec_analog_quirks sun8i_v3s_quirks =;

static int sun8i_codec_analog_cmpnt_probe(struct snd_soc_component *cmpnt)
{}

static const struct snd_soc_component_driver sun8i_codec_analog_cmpnt_drv =;

static const struct of_device_id sun8i_codec_analog_of_match[] =;
MODULE_DEVICE_TABLE(of, sun8i_codec_analog_of_match);

static int sun8i_codec_analog_probe(struct platform_device *pdev)
{}

static struct platform_driver sun8i_codec_analog_driver =;
module_platform_driver();

MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_LICENSE();
MODULE_ALIAS();