From 14ca71fd7e2d049c0b03a6d268f2c163b7a634b9 Mon Sep 17 00:00:00 2001 From: bsvt Date: Wed, 13 Sep 2017 02:11:33 -0700 Subject: [PATCH] Split alc5658 scripts and declarations file --- os/drivers/audio/alc5658.c | 142 +------------- os/drivers/audio/alc5658.h | 294 +++++++++------------------- os/drivers/audio/alc5658reg.h | 123 ++++++++++++ os/drivers/audio/alc5658scripts.h | 397 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 615 insertions(+), 341 deletions(-) create mode 100644 os/drivers/audio/alc5658reg.h create mode 100644 os/drivers/audio/alc5658scripts.h diff --git a/os/drivers/audio/alc5658.c b/os/drivers/audio/alc5658.c index d5cbda5..7287351 100644 --- a/os/drivers/audio/alc5658.c +++ b/os/drivers/audio/alc5658.c @@ -15,48 +15,6 @@ * language governing permissions and limitations under the License. * ****************************************************************************/ -/**************************************************************************** - * drivers/audio/alc5658.c - * - * Audio device driver for Wolfson Microelectronics ALC5658 Audio codec. - * - * Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * References: - * - "ALC5658 Ultra Low Power CODEC for Portable Audio Applications, Pre- - * Production", September 2012, Rev 3.3, Wolfson Microelectronics - * - * - The framework for this driver is based on Ken Pettit's VS1053 driver. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ /**************************************************************************** * Included Files @@ -90,110 +48,12 @@ #include #include "alc5658.h" +#include "alc5658scripts.h" /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ -#define ALC5658_DEFAULT_SAMPRATE 48000 -#define ALC5658_DEFAULT_NCHANNELS 2 -#define ALC5658_DEFAULT_BPSAMP 16 -#define FAIL 0xFFFF - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -#if !defined(CONFIG_ALC5658_REGDUMP) && !defined(CONFIG_ALC5658_CLKDEBUG) -static -#endif -uint16_t alc5658_readreg(FAR struct alc5658_dev_s *priv, uint16_t regaddr); -static void alc5658_writereg(FAR struct alc5658_dev_s *priv, uint16_t regaddr, uint16_t regval); -static void alc5658_takesem(sem_t *sem); -static uint16_t alc5658_modifyreg(FAR struct alc5658_dev_s *priv, uint16_t regaddr, uint16_t set, uint16_t clear); - -#define alc5658_givesem(s) sem_post(s) - -#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME -static inline uint16_t alc5658_scalevolume(uint16_t volume, b16_t scale); -static void alc5658_setvolume(FAR struct alc5658_dev_s *priv, uint16_t volume, bool mute); -#endif -#ifndef CONFIG_AUDIO_EXCLUDE_TONE -static void alc5658_setbass(FAR struct alc5658_dev_s *priv, uint8_t bass); -static void alc5658_settreble(FAR struct alc5658_dev_s *priv, uint8_t treble); -#endif - -static void alc5658_setdatawidth(FAR struct alc5658_dev_s *priv); -static void alc5658_setbitrate(FAR struct alc5658_dev_s *priv); - -/* Audio lower half methods (and close friends) */ - -static int alc5658_getcaps(FAR struct audio_lowerhalf_s *dev, int type, FAR struct audio_caps_s *caps); -#ifdef CONFIG_AUDIO_MULTI_SESSION -static int alc5658_configure(FAR struct audio_lowerhalf_s *dev, FAR void *session, FAR const struct audio_caps_s *caps); -#else -static int alc5658_configure(FAR struct audio_lowerhalf_s *dev, FAR const struct audio_caps_s *caps); -#endif -static int alc5658_shutdown(FAR struct audio_lowerhalf_s *dev); -static void alc5658_senddone(FAR struct i2s_dev_s *i2s, FAR struct ap_buffer_s *apb, FAR void *arg, int result); -static void alc5658_returnbuffers(FAR struct alc5658_dev_s *priv); -static int alc5658_sendbuffer(FAR struct alc5658_dev_s *priv); - -#ifdef CONFIG_AUDIO_MULTI_SESSION -static int alc5658_start(FAR struct audio_lowerhalf_s *dev, FAR void *session); -#else -static int alc5658_start(FAR struct audio_lowerhalf_s *dev); -#endif -#ifndef CONFIG_AUDIO_EXCLUDE_STOP -#ifdef CONFIG_AUDIO_MULTI_SESSION -static int alc5658_stop(FAR struct audio_lowerhalf_s *dev, FAR void *session); -#else -static int alc5658_stop(FAR struct audio_lowerhalf_s *dev); -#endif -#endif -#ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME -#ifdef CONFIG_AUDIO_MULTI_SESSION -static int alc5658_pause(FAR struct audio_lowerhalf_s *dev, FAR void *session); -static int alc5658_resume(FAR struct audio_lowerhalf_s *dev, FAR void *session); -#else -static int alc5658_pause(FAR struct audio_lowerhalf_s *dev); -static int alc5658_resume(FAR struct audio_lowerhalf_s *dev); -#endif -#endif -static int alc5658_enqueuebuffer(FAR struct audio_lowerhalf_s *dev, FAR struct ap_buffer_s *apb); -static int alc5658_cancelbuffer(FAR struct audio_lowerhalf_s *dev, FAR struct ap_buffer_s *apb); -static int alc5658_ioctl(FAR struct audio_lowerhalf_s *dev, int cmd, unsigned long arg); -#ifdef CONFIG_AUDIO_MULTI_SESSION -static int alc5658_reserve(FAR struct audio_lowerhalf_s *dev, FAR void **session); -#else -static int alc5658_reserve(FAR struct audio_lowerhalf_s *dev); -#endif -#ifdef CONFIG_AUDIO_MULTI_SESSION -static int alc5658_release(FAR struct audio_lowerhalf_s *dev, FAR void *session); -#else -static int alc5658_release(FAR struct audio_lowerhalf_s *dev); -#endif - -/* Interrupt handling an worker thread */ - -#ifdef ALC5658_USE_FFLOCK_INT -static void alc5658_interrupt_work(FAR void *arg); -static int alc5658_interrupt(FAR const struct alc5658_lower_s *lower, FAR void *arg); -#endif - -static void *alc5658_workerthread(pthread_addr_t pvarg); - -/* Initialization */ - -static void alc5658_audio_output(FAR struct alc5658_dev_s *priv); -static void alc5658_audio_input(FAR struct alc5658_dev_s *priv); -#ifdef ALC5658_USE_FFLOCK_INT -static void alc5658_configure_ints(FAR struct alc5658_dev_s *priv); -#else -#define alc5658_configure_ints(p) -#endif -static void alc5658_hw_reset(FAR struct alc5658_dev_s *priv); - /**************************************************************************** * Private Data ****************************************************************************/ diff --git a/os/drivers/audio/alc5658.h b/os/drivers/audio/alc5658.h index eb3a5b2..826e914 100644 --- a/os/drivers/audio/alc5658.h +++ b/os/drivers/audio/alc5658.h @@ -15,41 +15,6 @@ * language governing permissions and limitations under the License. * ****************************************************************************/ -/**************************************************************************** - * drivers/audio/alc5658.h - * - * Copyright (C) 2014 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************/ - #ifndef __DRIVERS_AUDIO_ALC5658_H #define __DRIVERS_AUDIO_ALC5658_H @@ -59,167 +24,19 @@ #include #include - -#include -#include - -#include #include +#include #ifdef CONFIG_AUDIO /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ - -/* Registers Addresses ******************************************************/ - -typedef enum { - ALC5658_RESET = 0x0000, - ALC5658_SPO_VOL = 0x0001, - ALC5658_HP_VOL = 0x0002, - ALC5658_LOUT_CTRL1 = 0x0003, - ALC5658_LOUT_CTRL2 = 0x0004, - ALC5658_HPOUT_VLML = 0x0005, - ALC5658_HPOUT_VLMR = 0x0006, - ALC5658_SPDIF_CTRL1 = 0x0008, - ALC5658_SPDIF_CTRL2 = 0x0009, - ALC5658_SPDIF_CTRL3 = 0x0036, - ALC5658_IN1_CTRL = 0x000C, - ALC5658_INL_VLM = 0x000F, - - ALC5658_SIDETONE = 0x0018, - - /* DIGITAL Volume */ - ALC5658_DAC_L1R1_VLM = 0x0019, - ALC5658_DAC_L2R2_VLM = 0x001A, - ALC5658_DAC_L2R2_MUTE = 0x001B, - - /* DIGITAL Mixers */ - ALC5658_ADC_2_DAC_MXR = 0x0029, - ALC5658_DAC_STR_MXR = 0x002A, - ALC5658_DAC_MN_MXR = 0x002B, - ALC5658_DAC_LB_SDTONE = 0x002C, - ALC5658_COPY_MODE = 0x002F, - - /* Analog DAC Source */ - ALC5658_DAC_SRC = 0x002D, - - /* ANALOG Mixers */ - ALC5658_SPKMIXL = 0x0046, - ALC5658_SPKMIXR = 0x0047, - ALC5658_SPOMIX = 0x0048, - ALC5658_OUTMIXL1 = 0x004D, - ALC5658_OUTMIXL2 = 0x004E, - ALC5658_OUTMIXR1 = 0x004F, - ALC5658_OUTMIXR2 = 0x0050, - ALC5658_LOUTMIX = 0x0052, - - /* Power management */ - ALC5658_PWR_MNG1 = 0x0061, - ALC5658_PWR_MNG2 = 0x0062, - ALC5658_PWR_MNG3 = 0x0063, - ALC5658_PWR_MNG4 = 0x0064, - ALC5658_PWR_MNG5 = 0x0065, - ALC5658_PWR_MNG6 = 0x0066, - ALC5658_PWR_MNG7 = 0x0067, - - /* DIGITAL ports comtrol */ - ALC5658_IF_DTCT = 0x006B, - ALC5658_I2S1_CTRL = 0x0070, - ALC5658_I2S2_CTRL = 0x0071, - ALC5658_ADDA_CLK = 0x0073, - ALC5658_ADDA_HPF = 0x0074, - - /* TDM */ - ALC5658_TDM_CTRL1 = 0x0077, - ALC5658_TDM_CTRL2 = 0x0078, - ALC5658_TDM_CTRL3 = 0x0079, - ALC5658_TDM_CTRL4 = 0x007A, - - /* Global Clock */ - ALC5658_GLBL_CLK = 0x0080, - ALC5658_GLBL_PLL1 = 0x0081, - ALC5658_GLBL_PLL2 = 0x0082, - ALC5658_GLBL_ASRC1 = 0x0083, - ALC5658_GLBL_ASRC2 = 0x0084, - ALC5658_GLBL_ASRC3 = 0x0085, - ALC5658_GLBL_ASRC4 = 0x008A, - - /* Amplifiers */ - ALC5658_HP_AMP = 0x008E, - ALC5658_SPK_AMP = 0x00A0, - -} ALC5658_REG; - -typedef struct { - uint16_t addr; - uint16_t val; - unsigned int delay; -} t_codec_init_script_entry; - -t_codec_init_script_entry codec_reset_script[] = { - {0x0000, 0x0000, 0}, -}; - -t_codec_init_script_entry codec_init_script[] = { - {0x0000, 0x0000, 0}, - {0x006E, 0xFFFF, 0}, - {0x006F, 0xFFFF, 0}, - {0x0080, 0x8000, 0}, - {0x0094, 0x0280, 0}, - {0x0111, 0xA502, 0}, - {0x0125, 0x0430, 0}, - {0x013A, 0x3020, 0}, - {0x0073, 0x1770, 0}, - -//{0x0070, 0x8020, 0}, - {0x0070, 0x0000, 0}, - {0x007B, 0x0003, 0}, - - {0x00FA, 0x0001, 0}, - {0x0091, 0x0C16, 0}, - {0x0063, 0xA23E, 60}, - {0x0063, 0xF23E, 50}, - {0x0062, 0x0400, 50}, - {0x0061, 0x8080, 10}, - {0x0029, 0x8080, 0}, - {0x002A, 0xAAAA, 0}, - {0x002D, 0x0000, 0}, - {0x008E, 0x0009, 50}, - {0x0061, 0x8C80, 50}, - {0x0091, 0x0E16, 50}, - {0x0040, 0x0505, 0}, - {0x0065, 0x0180, 0}, - {0x013C, 0x3C05, 0}, - {0x01DF, 0x02C1, 0}, - {0x01DF, 0x2CC1, 0}, - {0x01DE, 0x5100, 0}, - {0x01E4, 0x0014, 0}, - {0x01DE, 0xD100, 30}, - {0x01DF, 0x2CC1, 0}, - {0x01DE, 0x4900, 0}, - {0x01E4, 0x0016, 0}, - {0x01DE, 0xC900, 250}, - {0x01DF, 0x2CC1, 0}, - {0x0002, 0x0000, 0}, - {0x01DE, 0x4500, 0}, - {0x01E4, 0x001F, 0}, - {0x01DE, 0xC500, 800}, - {0x0040, 0x0808, 0}, - {0x0065, 0x0000, 0}, - {0x013C, 0x2005, 0}, - {0x01E4, 0x0000, 0}, - {0x01DF, 0x20C0, 0}, - {0x0073, 0x0770, 0}, - {0x0080, 0x0000, 0}, - {0x0160, 0x8EC0, 0}, - {0x008E, 0x0019, 0}, - {0x0015, 0xC0F0, 0}, - {0x0015, 0x87F9, 0}, - {0x0094, 0x0180, 0}, - {0x00FB, 0x3000, 0}, -}; + +#define ALC5658_DEFAULT_SAMPRATE 48000 +#define ALC5658_DEFAULT_NCHANNELS 2 +#define ALC5658_DEFAULT_BPSAMP 16 +#define FAIL 0xFFFF /* Commonly defined and redefined macros */ @@ -286,7 +103,7 @@ struct alc5658_dev_s { }; /**************************************************************************** - * Public Data + * Private Declarations ****************************************************************************/ #ifdef CONFIG_ALC5658_CLKDEBUG @@ -294,17 +111,94 @@ extern const uint8_t g_sysclk_scaleb1[ALC5658_BCLK_MAXDIV + 1]; extern const uint8_t g_fllratio[ALC5658_NFLLRATIO]; #endif -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ +#if defined(CONFIG_ALC5658_REGDUMP) || defined(CONFIG_ALC5658_CLKDEBUG) +static uint16_t alc5658_readreg(FAR struct alc5658_dev_s *priv, uint16_t regaddr); +#endif +static void alc5658_writereg(FAR struct alc5658_dev_s *priv, uint16_t regaddr, uint16_t regval); +static void alc5658_takesem(sem_t *sem); +static uint16_t alc5658_modifyreg(FAR struct alc5658_dev_s *priv, uint16_t regaddr, uint16_t set, uint16_t clear); -/**************************************************************************** - * Name: alc5658_readreg - * - * Description - * Read the specified 16-bit register from the ALC5658 device. - * - ****************************************************************************/ +#define alc5658_givesem(s) sem_post(s) + +#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME +static inline uint16_t alc5658_scalevolume(uint16_t volume, b16_t scale); +static void alc5658_setvolume(FAR struct alc5658_dev_s *priv, uint16_t volume, bool mute); +#endif +#ifndef CONFIG_AUDIO_EXCLUDE_TONE +static void alc5658_setbass(FAR struct alc5658_dev_s *priv, uint8_t bass); +static void alc5658_settreble(FAR struct alc5658_dev_s *priv, uint8_t treble); +#endif + +static void alc5658_setdatawidth(FAR struct alc5658_dev_s *priv); +static void alc5658_setbitrate(FAR struct alc5658_dev_s *priv); + +/* Audio lower half methods (and close friends) */ + +static int alc5658_getcaps(FAR struct audio_lowerhalf_s *dev, int type, FAR struct audio_caps_s *caps); +#ifdef CONFIG_AUDIO_MULTI_SESSION +static int alc5658_configure(FAR struct audio_lowerhalf_s *dev, FAR void *session, FAR const struct audio_caps_s *caps); +#else +static int alc5658_configure(FAR struct audio_lowerhalf_s *dev, FAR const struct audio_caps_s *caps); +#endif +static int alc5658_shutdown(FAR struct audio_lowerhalf_s *dev); +static void alc5658_senddone(FAR struct i2s_dev_s *i2s, FAR struct ap_buffer_s *apb, FAR void *arg, int result); +static void alc5658_returnbuffers(FAR struct alc5658_dev_s *priv); +static int alc5658_sendbuffer(FAR struct alc5658_dev_s *priv); + +#ifdef CONFIG_AUDIO_MULTI_SESSION +static int alc5658_start(FAR struct audio_lowerhalf_s *dev, FAR void *session); +#else +static int alc5658_start(FAR struct audio_lowerhalf_s *dev); +#endif +#ifndef CONFIG_AUDIO_EXCLUDE_STOP +#ifdef CONFIG_AUDIO_MULTI_SESSION +static int alc5658_stop(FAR struct audio_lowerhalf_s *dev, FAR void *session); +#else +static int alc5658_stop(FAR struct audio_lowerhalf_s *dev); +#endif +#endif +#ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME +#ifdef CONFIG_AUDIO_MULTI_SESSION +static int alc5658_pause(FAR struct audio_lowerhalf_s *dev, FAR void *session); +static int alc5658_resume(FAR struct audio_lowerhalf_s *dev, FAR void *session); +#else +static int alc5658_pause(FAR struct audio_lowerhalf_s *dev); +static int alc5658_resume(FAR struct audio_lowerhalf_s *dev); +#endif +#endif +static int alc5658_enqueuebuffer(FAR struct audio_lowerhalf_s *dev, FAR struct ap_buffer_s *apb); +static int alc5658_cancelbuffer(FAR struct audio_lowerhalf_s *dev, FAR struct ap_buffer_s *apb); +static int alc5658_ioctl(FAR struct audio_lowerhalf_s *dev, int cmd, unsigned long arg); +#ifdef CONFIG_AUDIO_MULTI_SESSION +static int alc5658_reserve(FAR struct audio_lowerhalf_s *dev, FAR void **session); +#else +static int alc5658_reserve(FAR struct audio_lowerhalf_s *dev); +#endif +#ifdef CONFIG_AUDIO_MULTI_SESSION +static int alc5658_release(FAR struct audio_lowerhalf_s *dev, FAR void *session); +#else +static int alc5658_release(FAR struct audio_lowerhalf_s *dev); +#endif + +/* Interrupt handling an worker thread */ + +#ifdef ALC5658_USE_FFLOCK_INT +static void alc5658_interrupt_work(FAR void *arg); +static int alc5658_interrupt(FAR const struct alc5658_lower_s *lower, FAR void *arg); +#endif + +static void *alc5658_workerthread(pthread_addr_t pvarg); + +/* Initialization */ + +static void alc5658_audio_output(FAR struct alc5658_dev_s *priv); +static void alc5658_audio_input(FAR struct alc5658_dev_s *priv); +#ifdef ALC5658_USE_FFLOCK_INT +static void alc5658_configure_ints(FAR struct alc5658_dev_s *priv); +#else +#define alc5658_configure_ints(p) +#endif +static void alc5658_hw_reset(FAR struct alc5658_dev_s *priv); #if defined(CONFIG_ALC5658_REGDUMP) || defined(CONFIG_ALC5658_CLKDEBUG) struct alc5658_dev_s; diff --git a/os/drivers/audio/alc5658reg.h b/os/drivers/audio/alc5658reg.h new file mode 100644 index 0000000..b19661e --- /dev/null +++ b/os/drivers/audio/alc5658reg.h @@ -0,0 +1,123 @@ +/**************************************************************************** + * + * Copyright 2017 Samsung Electronics All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the License. + * + ****************************************************************************/ +#ifndef __DRIVERS_AUDIO_ALC5658REG_H +#define __DRIVERS_AUDIO_ALC5658REG_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ +#ifdef CONFIG_AUDIO + +#include +#include + +/* Registers Addresses ******************************************************/ +typedef enum { + ALC5658_RESET = 0x0000, + ALC5658_SPO_VOL = 0x0001, + ALC5658_HPOUT_MUTE = 0x0002, + ALC5658_LOUT_CTRL1 = 0x0003, + ALC5658_LOUT_CTRL2 = 0x0004, + ALC5658_HPOUT_VLML = 0x0005, + ALC5658_HPOUT_VLMR = 0x0006, + ALC5658_SPDIF_CTRL1 = 0x0008, + ALC5658_SPDIF_CTRL2 = 0x0009, + ALC5658_SPDIF_CTRL3 = 0x0036, + ALC5658_IN1_CTRL = 0x000C, + ALC5658_INL_VLM = 0x000F, + ALC5658_SIDETONE = 0x0018, + /* DIGITAL Volume */ + ALC5658_DAC_L1R1_VLM = 0x0019, + ALC5658_DAC_L2R2_VLM = 0x001A, + ALC5658_DAC_L2R2_MUTE = 0x001B, + /* DIGITAL Mixers */ + ALC5658_ADC_STR1_MXR = 0x0026, + ALC5658_ADC_MONO_MXR = 0x0027, + ALC5658_ADC_2_DAC_MXR = 0x0029, + ALC5658_DAC_STR_MXR = 0x002A, + ALC5658_DAC_MONO_MXR = 0x002B, + ALC5658_DAC_LB_SDTONE = 0x002C, + ALC5658_COPY_MODE = 0x002F, + /* Analog DAC Source */ + ALC5658_DAC_SRC = 0x002D, + ALC5658_RECMIX1L_CTRL_1 = 0x003B, + ALC5658_RECMIX1L_CTRL_2 = 0x003C, + ALC5658_RECMIX1R_CTRL_1 = 0x003D, + ALC5658_RECMIX1R_CTRL_2 = 0x003E, + /* ANALOG Mixers */ + ALC5658_SPKMIXL = 0x0046, + ALC5658_SPKMIXR = 0x0047, + ALC5658_SPOMIX = 0x0048, + ALC5658_OUTMIXL1 = 0x004D, + ALC5658_OUTMIXL2 = 0x004E, + ALC5658_OUTMIXR1 = 0x004F, + ALC5658_OUTMIXR2 = 0x0050, + ALC5658_LOUTMIX = 0x0052, + /* Power management */ + ALC5658_PWR_MNG1 = 0x0061, + ALC5658_PWR_MNG2 = 0x0062, + ALC5658_PWR_MNG3 = 0x0063, + ALC5658_PWR_MNG4 = 0x0064, + ALC5658_PWR_MNG5 = 0x0065, + ALC5658_PWR_MNG6 = 0x0066, + ALC5658_PWR_MNG7 = 0x0067, + /* DIGITAL ports control */ + ALC5658_IF_DTCT = 0x006B, + ALC5658_006E = 0x006E, + ALC5658_006F = 0x006F, + ALC5658_I2S1_CTRL = 0x0070, + ALC5658_I2S2_CTRL = 0x0071, + ALC5658_ADDA_CLK = 0x0073, + ALC5658_ADDA_HPF = 0x0074, + ALC5658_007B = 0x007B, + /* TDM */ + ALC5658_TDM_CTRL1 = 0x0077, + ALC5658_TDM_CTRL2 = 0x0078, + ALC5658_TDM_CTRL3 = 0x0079, + ALC5658_TDM_CTRL4 = 0x007A, + /* Global Clock */ + ALC5658_GLBL_CLK = 0x0080, + ALC5658_GLBL_PLL1 = 0x0081, + ALC5658_GLBL_PLL2 = 0x0082, + ALC5658_GLBL_ASRC1 = 0x0083, + ALC5658_GLBL_ASRC2 = 0x0084, + ALC5658_GLBL_ASRC3 = 0x0085, + ALC5658_GLBL_ASRC4 = 0x008A, + /* Amplifiers */ + ALC5658_HP_AMP = 0x008E, + ALC5658_SPK_AMP = 0x00A0, + ALC5658_0091 = 0x0091, + ALC5658_INTCLK_CTRL = 0x0094, + ALC5658_GNRL_CTRL = 0x00FA, + ALC5658_GNRL_CTRL2 = 0x00FB, + ALC5658_0111 = 0x0111, + ALC5658_0125 = 0x0125, + ALC5658_ADDA_RST1 = 0x013A, + ALC5658_ADDA_RST2 = 0x013B, + ALC5658_0x013C = 0x013C, + ALC5658_NOISE_G_M1_CTRL1 = 0x0015, + ALC5658_NOISE_G_M2_CTRL = 0x0160, + ALC5658_0x01DE = 0x01DE, + ALC5658_0x01DF = 0x01DF, + ALC5658_0x01E4 = 0x01E4, + ALC5658_0040 = 0x0040, + ALC5658_0010 = 0x0010, +} ALC5658_REG; + +#endif /* CONFIG_AUDIO */ +#endif /* __DRIVERS_AUDIO_ALC5658REG_H */ diff --git a/os/drivers/audio/alc5658scripts.h b/os/drivers/audio/alc5658scripts.h new file mode 100644 index 0000000..de3597d --- /dev/null +++ b/os/drivers/audio/alc5658scripts.h @@ -0,0 +1,397 @@ +/**************************************************************************** + * + * Copyright 2016 Samsung Electronics All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the License. + * + ****************************************************************************/ +#ifndef __DRIVERS_AUDIO_ALC5658SCRIPTS_H +#define __DRIVERS_AUDIO_ALC5658SCRIPTS_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ +#ifdef CONFIG_AUDIO + +#include "alc5658reg.h" + +/* TYPEDEFS */ +typedef struct { + ALC5658_REG addr; + uint16_t val; + unsigned int delay; +} t_codec_init_script_entry; + +typedef struct { + ALC5658_REG addr; + char *name; +} t_codec_dump_entry; + +t_codec_init_script_entry codec_reset_script[] = { + {ALC5658_RESET, 0x0000, 0}, /* Reset */ +}; + +t_codec_init_script_entry codec_stop_script[] = { + {ALC5658_RESET, 0x0000, 0}, /* Reset */ + {ALC5658_I2S1_CTRL, 0x8000, 0}, /* Switch into slave to stop data transfer */ +}; + +t_codec_init_script_entry codec_init_script[] = { + {ALC5658_RESET, 0x0000, 0}, /* Reset */ + {ALC5658_006E, 0xFFFF, 0}, /* NO INFO IN DOCUMENTATION!!! */ + {ALC5658_006F, 0xFFFF, 0}, /* NO INFO IN DOCUMENTATION!!! */ + {ALC5658_GLBL_CLK, 0x8000, 0}, /* RC CLK, No dividers */ + {ALC5658_INTCLK_CTRL, 0x0280, 0}, /* ??? Enable ALL int CLK, even more than in documentation */ + {ALC5658_0111, 0xA502, 0}, /* NO INFO IN DOCUMENTATION!!! */ + {ALC5658_0125, 0x0430, 0}, /* NO INFO IN DOCUMENTATION!!! */ + {ALC5658_ADDA_RST1, 0x3020, 0}, /* ??? DAC1, DAC2 + alpha clock enable */ + {ALC5658_ADDA_CLK, 0x1770, 0}, /* I2Sprediv1 = 2, bclk_ms2 = 16bits(32FS), I2Sprediv2 = 7, something reserved, dac/adc 128Fs */ + {ALC5658_I2S1_CTRL, 0x0000, 0}, /* Master, off/normal/I2S... 16bit */ + {ALC5658_007B, 0x0003, 0}, /* Select 64*FS for BCLK in master mode, No Info in documentation */ + {ALC5658_GNRL_CTRL, 0x0001, 0}, /* Enable Gate mode, Use(pass) Noise Gain Mode2 CTRL */ + {ALC5658_0091, 0x0C16, 0}, /* NO INFO IN DOCUMENTATION!!! */ + {ALC5658_PWR_MNG3, 0xA23E, 60}, /* VREF1 on, fast VREF1, VREF2 on, fast VREF2, MBIAS on, LOUT off, MBIAS bandgap off, HP L/R ON, HPamp x5, LDO1 out 1.2V */ + {ALC5658_PWR_MNG3, 0xF23E, 50}, /* VREF1 on, SLOW VREF1, VREF2 on, SLOW VREF2, MBIAS on, LOUT off, MBIAS bandgap off, HP L/R ON, HPamp x5, LDO1 out 1.2V */ + {ALC5658_PWR_MNG2, 0x0400, 50}, /* pow_dac_stereo1_filter ON */ + {ALC5658_PWR_MNG1, 0x8080, 10}, /* en_i2s1, Pow_ldo_dacref ON */ + {ALC5658_ADC_2_DAC_MXR, 0x8080, 0}, /* Mu_stereo1_adc_mixer_l/r MUTE */ + {ALC5658_DAC_STR_MXR, 0xAAAA, 0}, /* Default, mute all */ + {ALC5658_DAC_SRC, 0x0000, 0}, /* Default, no mixers (direct) */ + {ALC5658_HP_AMP, 0x0009, 50}, /* en_out_hp - OFF, pow_pump_hp - ON, pow_capless - ON */ + {ALC5658_PWR_MNG1, 0x8C80, 50}, /* en_i2s1, pow_dac1_l/r, Pow_ldo_dacref - ON */ + {ALC5658_0091, 0x0E16, 50}, /* NO INFO IN DOCUMENTATION!!! */ + {ALC5658_0040, 0x0505, 0}, /* NO INFO IN DOCUMENTATION!!! */ + {ALC5658_PWR_MNG5, 0x0180, 0}, /* Does not match with documentation */ + {ALC5658_0x013C, 0x3C05, 0}, /* NO INFO IN DOCUMENTATION!!! */ + {ALC5658_0x01DF, 0x02C1, 0}, /* NO INFO IN DOCUMENTATION!!! */ + {ALC5658_0x01DF, 0x2CC1, 0}, /* NO INFO IN DOCUMENTATION!!! */ + {ALC5658_0x01DE, 0x5100, 0}, /* NO INFO IN DOCUMENTATION!!! */ + {ALC5658_0x01E4, 0x0014, 0}, /* NO INFO IN DOCUMENTATION!!! */ + {ALC5658_0x01DE, 0xD100, 30}, /* NO INFO IN DOCUMENTATION!!! */ + {ALC5658_0x01DF, 0x2CC1, 0}, /* NO INFO IN DOCUMENTATION!!! */ + {ALC5658_0x01DE, 0x4900, 0}, /* NO INFO IN DOCUMENTATION!!! */ + {ALC5658_0x01E4, 0x0016, 0}, /* NO INFO IN DOCUMENTATION!!! */ + {ALC5658_0x01DE, 0xC900, 250}, /* NO INFO IN DOCUMENTATION!!! */ + {ALC5658_0x01DF, 0x2CC1, 0}, /* NO INFO IN DOCUMENTATION!!! */ + {ALC5658_HPOUT_MUTE, 0x0000, 0}, /* UNMUTE HP Output */ + {ALC5658_0x01DE, 0x4500, 0}, /* NO INFO IN DOCUMENTATION!!! */ + {ALC5658_0x01E4, 0x001F, 0}, /* NO INFO IN DOCUMENTATION!!! */ + {ALC5658_0x01DE, 0xC500, 800}, /* NO INFO IN DOCUMENTATION!!! */ + {ALC5658_0040, 0x0808, 0}, /* NO INFO IN DOCUMENTATION!!! */ + {ALC5658_PWR_MNG5, 0x0000, 0}, /* Default, PLL, LDO2, Speaker VDD off */ + {ALC5658_0x013C, 0x2005, 0}, /* NO INFO IN DOCUMENTATION!!! */ + {ALC5658_0x01E4, 0x0000, 0}, /* NO INFO IN DOCUMENTATION!!! */ + {ALC5658_0x01DF, 0x20C0, 0}, /* NO INFO IN DOCUMENTATION!!! */ + {ALC5658_ADDA_CLK, 0x0770, 0}, /* I2Sprediv1 = 2, bclk_ms2 = 16bits(32FS), I2Sprediv2 = 7, something reserved, dac/adc 128Fs */ + {ALC5658_GLBL_CLK, 0x0000, 0}, /* MCLK, No dividers */ + {ALC5658_NOISE_G_M2_CTRL, 0x8EC0, 0}, /* Stereo_noise_gate_mode2_en - ENABLE */ + {ALC5658_HP_AMP, 0x0019, 0}, /* en_out_hp - ON, pow_pump_hp - ON, pow_capless - ON */ + {ALC5658_NOISE_G_M1_CTRL1, 0xC0F0, 0}, /* Noise_gate_mode1_en, Noise_gate_mode1_auto_en - EN, Noise_gate_mode1_threshold -78dB, DOES NOT MATCH WITH DOCUMENTATION !!! */ + {ALC5658_NOISE_G_M1_CTRL1, 0x87F9, 0}, /* Blah blah blah, eventually enable Noise gate function >:( */ + {ALC5658_INTCLK_CTRL, 0x0180, 0}, /* Probably enable Pow_int_clk1/2, does not match with DOC !!! */ + {ALC5658_GNRL_CTRL2, 0x3000, 0}, /* Noise_gate_mode1/2_hp enable, DOES NOT MATCH WITH DOCUMENTATION */ +}; + +t_codec_init_script_entry codec_initial_script[] = { + {ALC5658_RESET, 0x0000, 0}, + {ALC5658_0111, 0xA502, 0}, + {ALC5658_ADDA_RST1, 0x3030, 0}, /* ??? DAC1, DAC2 + alpha clock enable */ + {ALC5658_006E, 0xEF00, 0}, + {ALC5658_006F, 0xEFFC, 0}, + {ALC5658_INTCLK_CTRL, 0x0280, 0}, /* ??? Enable ALL int CLK, even more than in documentation */ + {ALC5658_GLBL_CLK, 0x8000, 0}, /* RC CLK, No dividers */ + {ALC5658_I2S1_CTRL, 0x0000, 0}, /* Master, off/normal/I2S... 16bit */ + {ALC5658_ADDA_CLK, 0x1770, 0}, /* I2Sprediv1 = 2, bclk_ms2 = 16bits(32FS), I2Sprediv2 = 7, something reserved, dac/adc 128Fs */ + {ALC5658_0091, 0x0C16, 0}, + {ALC5658_PWR_MNG3, 0xAA7E, 60}, /* VREF1 on, fast VREF1, VREF2 on, fast VREF2, MBIAS on, LOUT off, MBIAS bandgap off, HP L/R ON, HPamp x5, LDO1 out 1.2V */ + {ALC5658_PWR_MNG3, 0xFE7E, 50}, /* VREF1 on, SLOW VREF1, VREF2 on, SLOW VREF2, MBIAS on, LOUT off, MBIAS bandgap off, HP L/R ON, HPamp x5, LDO1 out 1.2V */ + {ALC5658_PWR_MNG5, 0x0004, 0}, /* LDO2 ON */ + {ALC5658_PWR_MNG2, 0x0400, 50}, /* pow_dac_stereo1_filter ON */ + {ALC5658_PWR_MNG1, 0x0080, 10}, /* Pow_ldo_dacref ON */ + {ALC5658_ADC_2_DAC_MXR, 0x8080, 0}, /* Mu_stereo1_adc_mixer_l/r MUTE */ + {ALC5658_DAC_STR_MXR, 0xAAAA, 0}, /* Default, mute all */ + {ALC5658_DAC_SRC, 0x0000, 0}, /* Default, no mixers (direct) */ + {ALC5658_HP_AMP, 0x0009, 50}, /* en_out_hp - OFF, pow_pump_hp - ON, pow_capless - ON */ + {ALC5658_PWR_MNG1, 0x0F80, 50}, /* pow_dac1_l/r, pow_dac2_l/r, Pow_ldo_dacref - ON */ + {ALC5658_0091, 0x0E16, 50}, + {ALC5658_0040, 0x0505, 0}, + {ALC5658_PWR_MNG5, 0x0184, 0}, /* ???NonDescribed, LDO2 ON */ + {ALC5658_0x013C, 0x3C05, 0}, + {ALC5658_0x01DF, 0x2cc1, 6}, + {ALC5658_0x01DE, 0x5100, 6}, + {ALC5658_0x01E4, 0x0014, 6}, + {ALC5658_0x01DE, 0xd100, 30}, + {ALC5658_0x01DF, 0x20C1, 0}, + {ALC5658_0x01DF, 0x2CC1, 0}, + {ALC5658_0x01DE, 0x4900, 0}, + {ALC5658_0x01E4, 0x0016, 0}, + {ALC5658_0x01DE, 0xC900, 250}, + {ALC5658_0x01DF, 0x2CC1, 0}, + {ALC5658_HPOUT_MUTE, 0x0000, 0}, /* UNMUTE HP Output */ + {ALC5658_0x01DE, 0x4500, 0}, + {ALC5658_0x01E4, 0x001F, 0}, + {ALC5658_0x01DE, 0xC500, 600}, + {ALC5658_0x01E4, 0x0000, 0}, + {ALC5658_0x01DF, 0x20C0, 0}, + {ALC5658_0040, 0x0808, 0}, + {ALC5658_PWR_MNG5, 0x0000, 0}, /* LDO2 OFF */ + {ALC5658_0x013C, 0x2005, 0}, + {ALC5658_PWR_MNG6, 0x0000, 0}, /* MIXERs OFF */ + {ALC5658_PWR_MNG7, 0x0000, 0}, /* VOL Out/In ctrl, MIC in det OFF */ + {ALC5658_PWR_MNG1, 0x0000, 0}, /* I2S, DAC, ADC, SPDIFF, CLASS D OFF */ + {ALC5658_PWR_MNG2, 0x0000, 0}, /* Filters, PDM I/F OFF */ + {ALC5658_PWR_MNG3, 0x003C, 0}, /* HP L/R ON, HPamp x5, LDO1 out 0.9V */ + {ALC5658_GLBL_CLK, 0x0000, 0}, /* MCLK, No dividers */ + {ALC5658_ADDA_CLK, 0x0770, 0}, /* I2Sprediv1 = 2, bclk_ms2 = 16bits(32FS), I2Sprediv2 = 7, something reserved, dac/adc 128Fs */ + {ALC5658_INTCLK_CTRL, 0x0080, 0}, /* Probably enable Pow_int_clk1/2, does not match with DOC !!! */ +}; + +t_codec_init_script_entry codec_init_out_script[] = { + {ALC5658_RESET, 0x0000, 0}, + {ALC5658_006E, 0xFFFF, 0}, + {ALC5658_006F, 0xFFFF, 0}, + {ALC5658_GNRL_CTRL, 0x8001, 0}, /* Bypass_noise_gate_mode2 BYPASS, digital_gate_ctrl ENABLE */ + {ALC5658_ADDA_RST1, 0x3030, 0}, /* ??? DAC1, DAC2 + alpha clock enable */ + {ALC5658_GLBL_PLL1, 0x0302, 0}, /* k = 2, n = 8 */ + {ALC5658_GLBL_PLL2, 0x0800, 0}, /* m - bypass */ + {ALC5658_ADDA_CLK, 0x1110, 0}, /* I2Sprediv1 = 2, bclk_ms2 = 16bits(32FS), I2Sprediv2 = 2, something reserved, dac/adc 128Fs */ + {ALC5658_0091, 0x0C16, 0}, + {ALC5658_PWR_MNG3, 0xA23E, 20}, /* VREF1 on, fast VREF1, VREF2 on, fast VREF2, MBIAS on, LOUT off, MBIAS bandgap off, HP L/R ON, HPamp x5, LDO1 out 1.2V */ + {ALC5658_PWR_MNG3, 0xF23E, 0}, /* VREF1 on, SLOW VREF1, VREF2 on, SLOW VREF2, MBIAS on, LOUT off, MBIAS bandgap off, HP L/R ON, HPamp x5, LDO1 out 1.2V */ + {ALC5658_PWR_MNG5, 0x0040, 0}, /* LDO2 ON */ + {ALC5658_GLBL_CLK, 0x4000, 0}, /* PLL1, No dividers */ + {ALC5658_GLBL_ASRC4, 0x0100, 0}, /* sel_i2s2_asrc = ASRC2 */ + {ALC5658_GLBL_ASRC1, 0x1300, 0}, /* En_i2s2_asrc - EN, Sel_mono_dac_l/r_mode EN */ + {ALC5658_GLBL_ASRC2, 0x0220, 0}, /* sel_da_filter_monol_track = clk_i2s2_track, sel_da_filter_monor_track = clk_i2s2_track */ + {ALC5658_PWR_MNG1, 0xC080, 0}, /* en_i2s1/en_i2s2, Pow_ldo_dacref ON */ + {ALC5658_HP_AMP, 0x0009, 0}, /* en_out_hp - OFF, pow_pump_hp - ON, pow_capless - ON */ + {ALC5658_PWR_MNG1, 0xCC80, 0}, /* en_i2s1/en_i2s2, pow_dac1_l/r, Pow_ldo_dacref ON */ + {ALC5658_0091, 0x0E16, 0}, + {ALC5658_PWR_MNG2, 0x0700, 0}, /* pow_dac_stereo1_filter, pow_dac_monol/r_filter ON */ + {ALC5658_HPOUT_MUTE, 0x0000, 0}, /* OFF */ + {ALC5658_0091, 0x0E1E, 0}, + {ALC5658_006E, 0xFFFF, 0}, + {ALC5658_006F, 0xFFFF, 0}, + {ALC5658_I2S1_CTRL, 0x0000, 0}, //MASTER 32FS + {ALC5658_DAC_STR_MXR, 0x2A8A, 0}, /* mu_stereo_dacl1_mixl, mu_stereo_dacr1_mixr unmute */ + {ALC5658_DAC_SRC, 0x000F, 0}, /* DAC1 stereo, DAC2 mono */ + {ALC5658_HP_AMP, 0x0019, 0}, /* en_out_hp - ON, pow_pump_hp - ON, pow_capless - ON */ + {ALC5658_TDM_CTRL2, 0x000C, 0}, //loopback +}; + +t_codec_init_script_entry codec_init_in_script[] = { + {ALC5658_RESET, 0x0000, 0}, + {ALC5658_ADDA_RST1, 0x3030, 0}, /* ??? DAC1, DAC2 + alpha clock enable */ + {ALC5658_ADDA_RST2, 0x3030, 0}, /* ??? ADC1, ADC2 + alpha clock enable */ + {ALC5658_006E, 0xEF00, 0}, + {ALC5658_006F, 0xEFFC, 0}, + {ALC5658_I2S1_CTRL, 0x0000, 0}, /* Master, off/normal/I2S... 16bit */ + {ALC5658_GNRL_CTRL, 0x8001, 0}, /* Bypass_noise_gate_mode2 BYPASS, digital_gate_ctrl ENABLE */ + {ALC5658_ADDA_CLK, 0x0000, 0}, /* I2Sprediv1 = 1, bclk_ms2 = 16bits(32FS), I2Sprediv2 = 1, something reserved, dac/adc 128Fs */ + {ALC5658_PWR_MNG3, 0xA2BE, 50}, /* VREF1 on, fast VREF1, VREF2 on, fast VREF2, MBIAS on, LOUT off, MBIAS bandgap ON, HP L/R ON, HPamp x5, LDO1 out 1.2V */ + {ALC5658_PWR_MNG3, 0xF2BE, 0}, /* VREF1 on, slow VREF1, VREF2 on, slow VREF2, MBIAS on, LOUT off, MBIAS bandgap ON, HP L/R ON, HPamp x5, LDO1 out 1.2V */ + {ALC5658_PWR_MNG1, 0x8098, 0}, /* en_i2s1, Pow_ldo_dacref, pow_adc1_l/r ON */ + {ALC5658_PWR_MNG1, 0x8C80, 0}, /* en_i2s1, pow_dac1_l/r Pow_ldo_dacref, pow_adc1_l/r ON */ + {ALC5658_0091, 0x0E16, 0}, + {ALC5658_PWR_MNG2, 0xB400, 0}, /* pow_adc_stereo1_filter, pow_adc_monol/r_filter, pow_dac_stereo1_filter ON */ + {ALC5658_0010, 0x3040, 0}, //CRT Mbias1 path + {ALC5658_PWR_MNG4, 0xC860, 0}, //enable mbias1 /* pow_bst1, pow_bst2, pow_micbias1_digital, pow_bst1-2, pow_bst2-2 ON */ + {ALC5658_PWR_MNG1, 0x8C98, 0}, /* en_i2s1, pow_dac1_l/r, Pow_ldo_dacref, pow_adc1_l/r ON */ + {ALC5658_PWR_MNG6, 0x0C00, 0}, /* pow_recmix1l/r ON */ + {ALC5658_PWR_MNG7, 0x0300, 0}, /* ?extra bits set? pow_inl_vol ON */ + {ALC5658_IN1_CTRL, 0x3000, 0}, /* Gain -12dB + 0.75dB*0x30 */ + {ALC5658_RECMIX1L_CTRL_2, 0x005F, 0}, /* Default, all mute */ + {ALC5658_RECMIX1R_CTRL_2, 0x005F, 0}, /* Default, all mute */ + {ALC5658_ADC_STR1_MXR, 0x6020, 0}, /* mu_stereo1_adcl1 unmute, sel_stereo1_adc1 Sel, mu_stereo1_adcr1 unmute */ + {ALC5658_ADC_2_DAC_MXR, 0x0000, 100}, /* Mu_stereo1_adc_mixer_l/r unmute */ + {ALC5658_DAC_MONO_MXR, 0x2A8A, 0}, /* mu_mono_dacl1_mixl/r unmute */ + {ALC5658_ADC_MONO_MXR, 0x4040, 0}, /* mu_mono_adcl1 UM, sel_mono_adcl1/2 - Mono_DAC_Mixer_L, mu_mono_adcr1 UM, Sel_mono_adcr1/2 - Mono_DAC_Mixer_R, sel_mono_adcr - ADC1_L, Sel_mono_dmic_r - DMIC1_R */ + {ALC5658_DAC_SRC, 0x000F, 0}, /* DAC1 stereo, DAC2 mono */ + {ALC5658_TDM_CTRL1, 0x00F0, 0}, /* TDM IN/OUT 32bit LEN Applicable in master mode ??? */ + {ALC5658_TDM_CTRL2, 0x0000, 0}, /* rx_adc_data_sel - IF_ADC1 / IF_ADC2 / DAC_REF / Null */ +}; + +t_codec_init_script_entry codec_init_inout_script1[] = { + {ALC5658_RESET, 0x0000, 0}, + {ALC5658_006E, 0xEF00, 0}, + {ALC5658_006F, 0xEFFC, 0}, + {ALC5658_GNRL_CTRL, 0x8001, 0}, + {ALC5658_ADDA_RST1, 0x3030, 0}, + {ALC5658_ADDA_RST2, 0x3030, 0}, +}; + +t_codec_init_script_entry codec_init_pll_8K[] = { + {ALC5658_GLBL_PLL1, 0x0302, 0}, + {ALC5658_GLBL_PLL2, 0x0800, 0}, + {ALC5658_ADDA_CLK, 0x6110, 0}, +}; + +t_codec_init_script_entry codec_init_pll_11K[] = { + {ALC5658_GLBL_PLL1, 0x4883, 0}, + {ALC5658_GLBL_PLL2, 0xE000, 0}, + {ALC5658_ADDA_CLK, 0x5110, 0}, +}; + +t_codec_init_script_entry codec_init_pll_16K[] = { + {ALC5658_GLBL_PLL1, 0x0302, 0}, + {ALC5658_GLBL_PLL2, 0x0800, 0}, + {ALC5658_ADDA_CLK, 0x4110, 0}, +}; + +t_codec_init_script_entry codec_init_pll_22K[] = { + {ALC5658_GLBL_PLL1, 0x4883, 0}, + {ALC5658_GLBL_PLL2, 0xE000, 0}, + {ALC5658_ADDA_CLK, 0x3110, 0}, +}; + +t_codec_init_script_entry codec_init_pll_32K[] = { + {ALC5658_GLBL_PLL1, 0x0302, 0}, + {ALC5658_GLBL_PLL2, 0x0800, 0}, + {ALC5658_ADDA_CLK, 0x2110, 0}, +}; + +t_codec_init_script_entry codec_init_pll_44K[] = { + {ALC5658_GLBL_PLL1, 0x4883, 0}, + {ALC5658_GLBL_PLL2, 0xE000, 0}, + {ALC5658_ADDA_CLK, 0x1110, 0}, +}; + +t_codec_init_script_entry codec_init_pll_48K[] = { + {ALC5658_GLBL_PLL1, 0x0302, 0}, + {ALC5658_GLBL_PLL2, 0x0800, 0}, + {ALC5658_ADDA_CLK, 0x1110, 0}, +}; + +t_codec_init_script_entry codec_init_inout_script2[] = { + {ALC5658_0091, 0x0C16, 0}, + {ALC5658_PWR_MNG3, 0xA2BE, 20}, + {ALC5658_PWR_MNG3, 0xF2BE, 0}, + {ALC5658_PWR_MNG5, 0x0040, 0}, + {ALC5658_GLBL_CLK, 0x4000, 0}, + {ALC5658_GLBL_ASRC4, 0x0100, 0}, + {ALC5658_GLBL_ASRC1, 0x1300, 0}, + {ALC5658_GLBL_ASRC2, 0x0220, 0}, + {ALC5658_PWR_MNG1, 0xC080, 0}, + {ALC5658_HP_AMP, 0x0009, 0}, + {ALC5658_PWR_MNG1, 0xCC80, 0}, + {ALC5658_PWR_MNG1, 0xCC98, 0}, + {ALC5658_0091, 0x0E16, 0}, + {ALC5658_PWR_MNG2, 0xB700, 0}, + {ALC5658_PWR_MNG4, 0xC860, 0}, //enable mbias1 + {ALC5658_PWR_MNG6, 0x0C00, 0}, + {ALC5658_PWR_MNG7, 0x0300, 0}, + {ALC5658_HPOUT_MUTE, 0x8080, 0}, // MUTE OUTPUT + {ALC5658_0091, 0x0E1E, 0}, + {ALC5658_I2S1_CTRL, 0x0000, 0}, + {ALC5658_DAC_STR_MXR, 0x2A8A, 0}, + {ALC5658_DAC_SRC, 0x000F, 0}, + {ALC5658_HP_AMP, 0x0019, 0}, + {ALC5658_0010, 0x3040, 0}, //CRT Mbias1 path + {ALC5658_IN1_CTRL, 0x0000, 0}, //BST1 gain (minimal) + {ALC5658_RECMIX1L_CTRL_2, 0x005F, 0}, //BST1 + {ALC5658_RECMIX1R_CTRL_2, 0x005F, 0}, //BST1 + {ALC5658_ADC_STR1_MXR, 0x6020, 0}, + {ALC5658_ADC_2_DAC_MXR, 0x8080, 100}, + {ALC5658_DAC_MONO_MXR, 0x2A8A, 0}, + {ALC5658_ADC_MONO_MXR, 0x4040, 0}, + {ALC5658_DAC_SRC, 0x000F, 0}, + {ALC5658_TDM_CTRL1, 0x00F0, 0}, + {ALC5658_TDM_CTRL2, 0x0000, 0}, + +}; + +t_codec_dump_entry codec_dump_script[] = { + {ALC5658_RESET, "ALC5658_RESET"}, + {ALC5658_SPO_VOL, "ALC5658_SPO_VOL"}, + {ALC5658_HPOUT_MUTE, "ALC5658_HPOUT_MUTE"}, + {ALC5658_LOUT_CTRL1, "ALC5658_LOUT_CTRL1"}, + {ALC5658_LOUT_CTRL2, "ALC5658_LOUT_CTRL2"}, + {ALC5658_HPOUT_VLML, "ALC5658_HPOUT_VLML"}, + {ALC5658_HPOUT_VLMR, "ALC5658_HPOUT_VLMR"}, + {ALC5658_SPDIF_CTRL1, "ALC5658_SPDIF_CTRL1"}, + {ALC5658_SPDIF_CTRL2, "ALC5658_SPDIF_CTRL2"}, + {ALC5658_SPDIF_CTRL3, "ALC5658_SPDIF_CTRL3"}, + {ALC5658_IN1_CTRL, "ALC5658_IN1_CTRL"}, + {ALC5658_INL_VLM, "ALC5658_INL_VLM"}, + {ALC5658_SIDETONE, "ALC5658_SIDETONE"}, + {ALC5658_DAC_L1R1_VLM, "ALC5658_DAC_L1R1_VLM"}, + {ALC5658_DAC_L2R2_VLM, "ALC5658_DAC_L2R2_VLM"}, + {ALC5658_DAC_L2R2_MUTE, "ALC5658_DAC_L2R2_MUTE"}, + {ALC5658_ADC_STR1_MXR, "ALC5658_ADC_STR1_MXR"}, + {ALC5658_ADC_MONO_MXR, "ALC5658_ADC_MONO_MXR"}, + {ALC5658_ADC_2_DAC_MXR, "ALC5658_ADC_2_DAC_MXR"}, + {ALC5658_DAC_STR_MXR, "ALC5658_DAC_STR_MXR"}, + {ALC5658_DAC_MONO_MXR, "ALC5658_DAC_MONO_MXR"}, + {ALC5658_DAC_LB_SDTONE, "ALC5658_DAC_LB_SDTONE"}, + {ALC5658_COPY_MODE, "ALC5658_COPY_MODE"}, + {ALC5658_DAC_SRC, "ALC5658_DAC_SRC"}, + {ALC5658_RECMIX1L_CTRL_1, "ALC5658_RECMIX1L_CTRL_1"}, + {ALC5658_RECMIX1L_CTRL_2, "ALC5658_RECMIX1L_CTRL_2"}, + {ALC5658_RECMIX1R_CTRL_1, "ALC5658_RECMIX1R_CTRL_1"}, + {ALC5658_RECMIX1R_CTRL_2, "ALC5658_RECMIX1R_CTRL_2"}, + {ALC5658_SPKMIXL, "ALC5658_SPKMIXL"}, + {ALC5658_SPKMIXR, "ALC5658_SPKMIXR"}, + {ALC5658_SPOMIX, "ALC5658_SPOMIX"}, + {ALC5658_OUTMIXL1, "ALC5658_OUTMIXL1"}, + {ALC5658_OUTMIXL2, "ALC5658_OUTMIXL2"}, + {ALC5658_OUTMIXR1, "ALC5658_OUTMIXR1"}, + {ALC5658_OUTMIXR2, "ALC5658_OUTMIXR2"}, + {ALC5658_LOUTMIX, "ALC5658_LOUTMIX"}, + {ALC5658_PWR_MNG1, "ALC5658_PWR_MNG1"}, + {ALC5658_PWR_MNG2, "ALC5658_PWR_MNG2"}, + {ALC5658_PWR_MNG3, "ALC5658_PWR_MNG3"}, + {ALC5658_PWR_MNG4, "ALC5658_PWR_MNG4"}, + {ALC5658_PWR_MNG5, "ALC5658_PWR_MNG5"}, + {ALC5658_PWR_MNG6, "ALC5658_PWR_MNG6"}, + {ALC5658_PWR_MNG7, "ALC5658_PWR_MNG7"}, + {ALC5658_IF_DTCT, "ALC5658_IF_DTCT"}, + {ALC5658_006E, "ALC5658_006E"}, + {ALC5658_006F, "ALC5658_006F"}, + {ALC5658_I2S1_CTRL, "ALC5658_I2S1_CTRL"}, + {ALC5658_I2S2_CTRL, "ALC5658_I2S2_CTRL"}, + {ALC5658_ADDA_CLK, "ALC5658_ADDA_CLK"}, + {ALC5658_ADDA_HPF, "ALC5658_ADDA_HPF"}, + {ALC5658_007B, "ALC5658_007B"}, + {ALC5658_TDM_CTRL1, "ALC5658_TDM_CTRL1"}, + {ALC5658_TDM_CTRL2, "ALC5658_TDM_CTRL2"}, + {ALC5658_TDM_CTRL3, "ALC5658_TDM_CTRL3"}, + {ALC5658_TDM_CTRL4, "ALC5658_TDM_CTRL4"}, + {ALC5658_GLBL_CLK, "ALC5658_GLBL_CLK"}, + {ALC5658_GLBL_PLL1, "ALC5658_GLBL_PLL1"}, + {ALC5658_GLBL_PLL2, "ALC5658_GLBL_PLL2"}, + {ALC5658_GLBL_ASRC1, "ALC5658_GLBL_ASRC1"}, + {ALC5658_GLBL_ASRC2, "ALC5658_GLBL_ASRC2"}, + {ALC5658_GLBL_ASRC3, "ALC5658_GLBL_ASRC3"}, + {ALC5658_GLBL_ASRC4, "ALC5658_GLBL_ASRC4"}, + {ALC5658_HP_AMP, "ALC5658_HP_AMP"}, + {ALC5658_SPK_AMP, "ALC5658_SPK_AMP"}, + {ALC5658_0091, "ALC5658_0091"}, + {ALC5658_INTCLK_CTRL, "ALC5658_INTCLK_CTRL"}, + {ALC5658_GNRL_CTRL, "ALC5658_GNRL_CTRL"}, + {ALC5658_GNRL_CTRL2, "ALC5658_GNRL_CTRL2"}, + {ALC5658_0111, "ALC5658_0111"}, + {ALC5658_0125, "ALC5658_0125"}, + {ALC5658_ADDA_RST1, "ALC5658_ADDA_RST1"}, + {ALC5658_ADDA_RST2, "ALC5658_ADDA_RST2"}, + {ALC5658_0x013C, "ALC5658_0x013C"}, + {ALC5658_NOISE_G_M1_CTRL1, "ALC5658_NOISE_G_M1_CTRL1"}, + {ALC5658_NOISE_G_M2_CTRL, "ALC5658_NOISE_G_M2_CTRL"}, + {ALC5658_0x01DE, "ALC5658_0x01DE"}, + {ALC5658_0x01DF, "ALC5658_0x01DF"}, + {ALC5658_0x01E4, "ALC5658_0x01E4"}, + {ALC5658_0040, "ALC5658_0040"}, + {ALC5658_0010, "ALC5658_0010"}, +}; + +#endif /* CONFIG_AUDIO */ +#endif /* __DRIVERS_AUDIO_ALC5658SCRIPTS_H */ -- 2.7.4