linux/sound/soc/codecs/es83xx-dsm-common.h

/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (c) Intel Corporation, 2022
 * Copyright Everest Semiconductor Co.,Ltd
 */

/* Definitions extracted from ASL file provided at
 * https://github.com/thesofproject/linux/files/9398723/ESSX8326.zip
 */

#ifndef _ES83XX_DSM_COMMON_H
#define _ES83XX_DSM_COMMON_H

/***************************************************
 *  DSM arguments                                  *
 ***************************************************/

#define PLATFORM_MAINMIC_TYPE_ARG
#define PLATFORM_HPMIC_TYPE_ARG
#define PLATFORM_SPK_TYPE_ARG
#define PLATFORM_HPDET_INV_ARG
#define PLATFORM_PCM_TYPE_ARG

#define PLATFORM_MIC_DE_POP_ARG
#define PLATFORM_CODEC_TYPE_ARG
#define PLATFORM_BUS_SLOT_ARG

#define HP_CODEC_LINEIN_PGA_GAIN_ARG
#define MAIN_CODEC_LINEIN_PGA_GAIN_ARG

#define HP_CODEC_D2SEPGA_GAIN_ARG
#define MAIN_CODEC_D2SEPGA_GAIN_ARG

#define HP_CODEC_ADC_VOLUME_ARG
#define MAIN_CODEC_ADC_VOLUME_ARG

#define HP_CODEC_ADC_ALC_ENABLE_ARG
#define MAIN_CODEC_ADC_ALC_ENABLE_ARG

#define HP_CODEC_ADC_ALC_TARGET_LEVEL_ARG
#define MAIN_CODEC_ADC_ALC_TARGET_LEVEL_ARG

#define HP_CODEC_ADC_ALC_MAXGAIN_ARG
#define MAIN_CODEC_ADC_ALC_MAXGAIN_ARG

#define HP_CODEC_ADC_ALC_MINGAIN_ARG
#define MAIN_CODEC_ADC_ALC_MINGAIN_ARG

#define HP_CODEC_ADC_ALC_HLDTIME_ARG
#define MAIN_CODEC_ADC_ALC_HLDTIME_ARG

#define HP_CODEC_ADC_ALC_DCYTIME_ARG
#define MAIN_CODEC_ADC_ALC_DCYTIME_ARG

#define HP_CODEC_ADC_ALC_ATKTIME_ARG
#define MAIN_CODEC_ADC_ALC_ATKTIME_ARG

#define HP_CODEC_ADC_ALC_NGTYPE_ARG
#define MAIN_CODEC_ADC_ALC_NGTYPE_ARG

#define HP_CODEC_ADC_ALC_NGTHLD_ARG
#define MAIN_CODEC_ADC_ALC_NGTHLD_ARG

#define MAIN_CODEC_ADC_GUI_STEP_ARG
#define MAIN_CODEC_ADC_GUI_GAIN_RANGE_ARG

#define HEADPHONE_DUMMY_REMOVE_ENABLE_ARG

#define HP_CODEC_DAC_HPMIX_HIGAIN_ARG
#define SPK_CODEC_DAC_HPMIX_HIGAIN_ARG

#define HP_CODEC_DAC_HPMIX_VOLUME_ARG
#define SPK_CODEC_DAC_HPMIX_VOLUME_ARG

#define HP_CODEC_DAC_HPOUT_VOLUME_ARG
#define SPK_CODEC_DAC_HPOUT_VOLUME_ARG

#define HP_CODEC_LDAC_VOLUME_ARG
#define HP_CODEC_RDAC_VOLUME_ARG

#define SPK_CODEC_LDAC_VOLUME_ARG
#define SPK_CODEC_RDAC_VOLUME_ARG

#define HP_CODEC_DAC_AUTOMUTE_ARG
#define SPK_CODEC_DAC_AUTOMUTE_ARG

#define HP_CODEC_DAC_MONO_ARG
#define SPK_CODEC_DAC_MONO_ARG

#define HP_CTL_IO_LEVEL_ARG
#define SPK_CTL_IO_LEVEL_ARG

#define CODEC_GPIO0_FUNC_ARG
#define CODEC_GPIO1_FUNC_ARG
#define CODEC_GPIO2_FUNC_ARG
#define CODEC_GPIO3_FUNC_ARG
#define CODEC_GPIO4_FUNC_ARG

#define PLATFORM_MCLK_LRCK_FREQ_ARG

/***************************************************
 *  Values for arguments                           *
 ***************************************************/

/* Main and HP Mic */
#define PLATFORM_MIC_DMIC_HIGH_LEVEL
#define PLATFORM_MIC_DMIC_LOW_LEVEL
#define PLATFORM_MIC_AMIC_LIN1RIN1
#define PLATFORM_MIC_AMIC_LIN2RIN2

/* Speaker */
#define PLATFORM_SPK_NONE
#define PLATFORM_SPK_MONO
#define PLATFORM_SPK_STEREO

/* Jack Detection */
#define PLATFORM_HPDET_NORMAL
#define PLATFORM_HPDET_INVERTED

/* PCM type (Port number + protocol) */
/*
 * RETURNED VALUE = 0x00,   PCM PORT0, I2S
 *       0x01,   PCM PORT0, LJ
 *       0x02,   PCM PORT0, RJ
 *       0x03,   PCM PORT0, DSP-A
 *       0x04,   PCM PORT0, DSP-B
 *       0x10,   PCM PORT1, I2S
 *       0x11,   PCM PORT1, LJ
 *       0x12,   PCM PORT1, RJ
 *       0x13,   PCM PORT1, DSP-A
 *       0x14,   PCM PORT1, DSP-B
 *       0xFF,   Use default
 *
 * This is not used in Linux (defined by topology) and in
 * Windows it's always DSP-A
 */

/* Depop */
#define PLATFORM_MIC_DE_POP_OFF
#define PLATFORM_MIC_DE_POP_ON

/* Codec type */
#define PLATFORM_CODEC_8316
#define PLATFORM_CODEC_8326
#define PLATFORM_CODEC_8336
#define PLATFORM_CODEC_8395
#define PLATFORM_CODEC_8396

/* Bus slot (on the host) */
/* BIT[3:0] FOR BUS NUMBER, BIT[7:4] FOR SLOT NUMBER
 * BIT[3:0] 0 for I2S0, 1 for IS21, 2 for I2S2.
 *
 * On Intel platforms this refers to SSP0..2. This information
 * is not really useful for Linux, the information is already
 * inferred from NHLT but can be used to double-check NHLT
 */

/* Volume - Gain */
#define LINEIN_GAIN_0db
#define LINEIN_GAIN_3db
#define LINEIN_GAIN_6db
#define LINEIN_GAIN_9db
#define LINEIN_GAIN_12db
#define LINEIN_GAIN_15db
#define LINEIN_GAIN_18db
#define LINEIN_GAIN_21db
#define LINEIN_GAIN_24db
#define LINEIN_GAIN_27db
#define LINEIN_GAIN_30db

#define ADC_GUI_STEP_3db
#define ADC_GUI_STEP_6db
#define ADC_GUI_STEP_10db

#define D2SEPGA_GAIN_0db
#define D2SEPGA_GAIN_15db

/* ADC volume: base = 0db, -0.5db/setp, 0xc0 <-> -96db */

#define ADC_ALC_DISABLE
#define ADC_ALC_ENABLE

#define ADC_ALC_TARGET_LEVEL_m16_5db
#define ADC_ALC_TARGET_LEVEL_m15db
#define ADC_ALC_TARGET_LEVEL_m13_5db
#define ADC_ALC_TARGET_LEVEL_m12db
#define ADC_ALC_TARGET_LEVEL_m10_5db
#define ADC_ALC_TARGET_LEVEL_m9db
#define ADC_ALC_TARGET_LEVEL_m7_5db
#define ADC_ALC_TARGET_LEVEL_m6db
#define ADC_ALC_TARGET_LEVEL_m4_5db
#define ADC_ALC_TARGET_LEVEL_m_3db
#define ADC_ALC_TARGET_LEVEL_m1_5db

#define ADC_ALC_MAXGAIN_m6_5db
#define ADC_ALC_MAXGAIN_m5db
#define ADC_ALC_MAXGAIN_m3_5db
#define ADC_ALC_MAXGAIN_m2db
#define ADC_ALC_MAXGAIN_m0_5db
#define ADC_ALC_MAXGAIN_1db
#define ADC_ALC_MAXGAIN_2_5db
#define ADC_ALC_MAXGAIN_4db
#define ADC_ALC_MAXGAIN_5_5db
#define ADC_ALC_MAXGAIN_7db
#define ADC_ALC_MAXGAIN_8_5db
#define ADC_ALC_MAXGAIN_10db
#define ADC_ALC_MAXGAIN_11_5db
#define ADC_ALC_MAXGAIN_13db
#define ADC_ALC_MAXGAIN_14_5db
#define ADC_ALC_MAXGAIN_16db
#define ADC_ALC_MAXGAIN_17_5db
#define ADC_ALC_MAXGAIN_19db
#define ADC_ALC_MAXGAIN_20_5db
#define ADC_ALC_MAXGAIN_22db
#define ADC_ALC_MAXGAIN_23_5db
#define ADC_ALC_MAXGAIN_25db
#define ADC_ALC_MAXGAIN_26_5db
#define ADC_ALC_MAXGAIN_28db
#define ADC_ALC_MAXGAIN_29_5db
#define ADC_ALC_MAXGAIN_31db
#define ADC_ALC_MAXGAIN_32_5db
#define ADC_ALC_MAXGAIN_34db
#define ADC_ALC_MAXGAIN_35_5db

#define ADC_ALC_MINGAIN_m12db
#define ADC_ALC_MINGAIN_m10_5db
#define ADC_ALC_MINGAIN_m9db
#define ADC_ALC_MINGAIN_m7_5db
#define ADC_ALC_MINGAIN_m6db
#define ADC_ALC_MINGAIN_m4_51db
#define ADC_ALC_MINGAIN_m3db
#define ADC_ALC_MINGAIN_m1_5db
#define ADC_ALC_MINGAIN_0db
#define ADC_ALC_MINGAIN_1_5db
#define ADC_ALC_MINGAIN_3db
#define ADC_ALC_MINGAIN_4_5db
#define ADC_ALC_MINGAIN_6db
#define ADC_ALC_MINGAIN_7_5db
#define ADC_ALC_MINGAIN_9db
#define ADC_ALC_MINGAIN_10_5db
#define ADC_ALC_MINGAIN_12db
#define ADC_ALC_MINGAIN_13_5db
#define ADC_ALC_MINGAIN_15db
#define ADC_ALC_MINGAIN_16_5db
#define ADC_ALC_MINGAIN_18db
#define ADC_ALC_MINGAIN_19_5db
#define ADC_ALC_MINGAIN_21db
#define ADC_ALC_MINGAIN_22_5db
#define ADC_ALC_MINGAIN_24db
#define ADC_ALC_MINGAIN_25_5db
#define ADC_ALC_MINGAIN_27db
#define ADC_ALC_MINGAIN_28_5db
#define ADC_ALC_MINGAIN_30db

/* ADC volume: step 1dB */

/* ALC Hold, Decay, Attack */
#define ADC_ALC_HLDTIME_0_US
#define ADC_ALC_HLDTIME_0000266_US
#define ADC_ALC_HLDTIME_0000533_US
#define ADC_ALC_HLDTIME_0001066_US
#define ADC_ALC_HLDTIME_0002132_US
#define ADC_ALC_HLDTIME_0004264_US
#define ADC_ALC_HLDTIME_0008538_US
#define ADC_ALC_HLDTIME_0017076_US
#define ADC_ALC_HLDTIME_0034152_US
#define ADC_ALC_HLDTIME_0680000_US
#define ADC_ALC_HLDTIME_1360000_US

#define ADC_ALC_DCYTIME_000410_US
#define ADC_ALC_DCYTIME_000820_US
#define ADC_ALC_DCYTIME_001640_US
#define ADC_ALC_DCYTIME_003280_US
#define ADC_ALC_DCYTIME_006560_US
#define ADC_ALC_DCYTIME_013120_US
#define ADC_ALC_DCYTIME_026240_US
#define ADC_ALC_DCYTIME_058480_US
#define ADC_ALC_DCYTIME_104960_US
#define ADC_ALC_DCYTIME_209920_US
#define ADC_ALC_DCYTIME_420000_US

#define ADC_ALC_ATKTIME_000104_US
#define ADC_ALC_ATKTIME_000208_US
#define ADC_ALC_ATKTIME_000416_US
#define ADC_ALC_ATKTIME_003832_US
#define ADC_ALC_ATKTIME_001664_US
#define ADC_ALC_ATKTIME_003328_US
#define ADC_ALC_ATKTIME_006656_US
#define ADC_ALC_ATKTIME_013312_US
#define ADC_ALC_ATKTIME_026624_US
#define ADC_ALC_ATKTIME_053248_US
#define ADC_ALC_ATKTIME_106496_US

/* ALC Noise Gate */
#define ADC_ALC_NGTYPE_DISABLE
#define ADC_ALC_NGTYPE_ENABLE_HOLD
#define ADC_ALC_NGTYPE_ENABLE_MUTE

#define ADC_ALC_NGTHLD_m76_5db
#define ADC_ALC_NGTHLD_m75db
#define ADC_ALC_NGTHLD_m73_5db
#define ADC_ALC_NGTHLD_m72db
#define ADC_ALC_NGTHLD_m70_5db
#define ADC_ALC_NGTHLD_m69db
#define ADC_ALC_NGTHLD_m67_5db
#define ADC_ALC_NGTHLD_m66db
#define ADC_ALC_NGTHLD_m64_5db
#define ADC_ALC_NGTHLD_m63db
#define ADC_ALC_NGTHLD_m61_5db
#define ADC_ALC_NGTHLD_m60db
#define ADC_ALC_NGTHLD_m58_5db
#define ADC_ALC_NGTHLD_m57db
#define ADC_ALC_NGTHLD_m55_5db
#define ADC_ALC_NGTHLD_m54db
#define ADC_ALC_NGTHLD_m52_5db
#define ADC_ALC_NGTHLD_m51db
#define ADC_ALC_NGTHLD_m49_5db
#define ADC_ALC_NGTHLD_m48db
#define ADC_ALC_NGTHLD_m46_5db
#define ADC_ALC_NGTHLD_m45db
#define ADC_ALC_NGTHLD_m43_5db
#define ADC_ALC_NGTHLD_m42db
#define ADC_ALC_NGTHLD_m40_5db
#define ADC_ALC_NGTHLD_m39db
#define ADC_ALC_NGTHLD_m37_5db
#define ADC_ALC_NGTHLD_m36db
#define ADC_ALC_NGTHLD_m34_5db
#define ADC_ALC_NGTHLD_m33db
#define ADC_ALC_NGTHLD_m31_5db
#define ADC_ALC_NGTHLD_m30db

/* Headphone dummy - Windows Specific flag, not needed for Linux */

/* HPMIX HIGAIN and VOLUME */
#define DAC_HPMIX_HIGAIN_0db
#define DAC_HPMIX_HIGAIN_m6db

#define DAC_HPMIX_VOLUME_m12db
#define DAC_HPMIX_VOLUME_m10_5db
#define DAC_HPMIX_VOLUME_m9db
#define DAC_HPMIX_VOLUME_m7_5db
#define DAC_HPMIX_VOLUME_m6db
#define DAC_HPMIX_VOLUME_m4_5db
#define DAC_HPMIX_VOLUME_m3db
#define DAC_HPMIX_VOLUME_m1_5db
#define DAC_HPMIX_VOLUME_0db

/* HPOUT VOLUME */
#define DAC_HPOUT_VOLUME_0db
#define DAC_HPOUT_VOLUME_m12db
#define DAC_HPOUT_VOLUME_m24db
#define DAC_HPOUT_VOLUME_m48db

/* LDAC/RDAC volume = 0db, -0.5db/setp, 0xc0 <-> -96db */

/* Automute */
#define DAC_AUTOMUTE_NONE
#define DAC_AUTOMUTE_DIGITAL
#define DAC_AUTOMUTE_ANALOG

/* Mono - Windows specific, on Linux the information comes from DAI/topology */
#define HEADPHONE_MONO
#define HEADPHONE_STEREO

/* Speaker and headphone GPIO control */
#define GPIO_CTL_IO_LEVEL_LOW
#define GPIO_CTL_IO_LEVEL_HIGH

/* GPIO */
/* FIXME: for ES8396, no need to use */

/* Platform clocks */
/*
 * BCLK AND MCLK FREQ
 * BIT[7:4] MCLK FREQ
 * 0 - 19.2MHz
 * 1 - 24MHz
 * 2 - 12.288MHz
 * F - Default for 19.2MHz
 *
 * BIT[3:0] BCLK FREQ
 * 0 - 4.8MHz
 * 1 - 2.4MHz
 * 2 - 2.304MHz
 * 3 - 3.072MHz
 * 4 - 4.096MHz
 * F - Default for 4.8MHz
 */

int es83xx_dsm(struct device *dev, int arg, int *value);
int es83xx_dsm_dump(struct device *dev);

#endif