/* SPDX-License-Identifier: LGPL-2.1-only OR BSD-3-Clause */
/******************************************************************************
 *
 * This file is provided under a dual license.  When you use or
 * distribute this software, you may choose to be licensed under
 * version 2.1 of the GNU Lesser General Public License
 * ("LGPLv2.1 License") or BSD License.
 *
 * LGPLv2.1 License
 *
 * Copyright(C) 2019 MediaTek Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2.1 of the GNU Lesser General Public
 * License as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html for more
 * details.
 *
 * BSD LICENSE
 *
 * Copyright(C) 2019 MediaTek Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *  * Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *  * 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.
 *  * Neither the name of the copyright holder 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
 * HOLDER 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.
 *
 *****************************************************************************/

/*-----------------------------------------------------------------------------
 *
 * $Author: brianpc.huang $
 * $Date: 2015/05/29 $
 * $RCSfile: mtk_aud_amp_339.h,v $
 * $Revision: #1 $
 *
 *---------------------------------------------------------------------------*/

/** @file mtk_aud_amp_339.h
 *  Brief of file adac_apogee.h. \n
 */

#ifndef MTK_AUD_AMP_339_H
#define MTK_AUD_AMP_339_H

//#define CC_AUD_AMP_SUPPORT_5_1_CH
//---------------------------------------------------------------------------
// Include files
//---------------------------------------------------------------------------

#include "x_typedef.h"
#include "aud_if.h"

//---------------------------------------------------------------------------
// Constant definitions
//---------------------------------------------------------------------------

#define REG_MODE_CTL     0x0A
  #define MASTER_MODE    0x00
  #define SLAVE_MODE     0x20

#define GPIO_PAD_ML  42
#define GPIO_PAD_MC  43
#define GPIO_PAD_MD  44  

//MTK_STA339 ddxi 2051
#define MTK_STA339_DDXI2051_ADDR             0x34 
// MTK_STA339 STA333BW
#ifndef CC_AUD_AMP_STA333BW_SA_1
#define MTK_STA339_STA333BW_ADDR             0x38 
#else 
#define MTK_STA339_STA333BW_ADDR             0x3a
#define MTK_STA339_STA333BW_ADDR_1           0x38  //use 3 amps for 5.1ch
#endif

#define SIF_CLK_DIV                                0x100

#define STA232W_CONFA 0x00
#define STA232W_CONFB 0x01
#define STA232W_CONFC 0x02
#define STA232W_CONFD 0x03
#define STA232W_CONFE 0x04
#define STA232W_CONFF 0x05
#define STA232W_MASMUTE 0x06
#define REG_MTK_STA339_MASTER_VOL_CRL   0x07
   #define MASTER_VOL_0DB           (0x0)
   #define MASTER_VOL_NEG_38DB      (0x4c)
   #define MASTER_VOL_MUTE          (0xff)   
#define REG_MTK_STA339_CHL_1_VOL_CRL    0x08
#define REG_MTK_STA339_CHL_2_VOL_CRL    0x09
#define REG_MTK_STA339_CHL_3_VOL_CRL    0x0a
#define REG_MTK_STA339_AUTOMODE_REG2    0x0c

#define STA232W_AUTOMODE 0x0B
#define STA232W_CH1CONFIG	0x0E
#define STA232W_CH2CONFIG	0x0F
#define STA232W_CH3CONFIG	0x10
#define STA232W_LIMITER_1   0x12
#define STA232W_LIMITER	0x13
#define STA232W_LIMITER_THRESHOLD	0x15

#define STA339_ATTACK1_THRESHOLD 0x32
#define STA339_ATTACK2_THRESHOLD 0x34
#define STA339_RELEASE1_THRESHOLD 0x33
#define STA339_RELEASE2_THRESHOLD 0x35
#define STA339_ATTACK_RATE1 0x12
#define STA339_ATTACK_RATE2 0x14

#define STA339_EQDRC_CFG 0x31
#define STA339_CFADDR    0x16
#define STA339_CFUD      0x26

#define STA339_B1CF1 0x17
#define STA339_B1CF2 0x18
#define STA339_B1CF3 0x19

#define STA339_B2CF1 0x1A
#define STA339_B2CF2 0x1B
#define STA339_B2CF3 0x1C

#define STA339_A1CF1 0x1D
#define STA339_A1CF2 0x1E
#define STA339_A1CF3 0x1F

#define STA339_A2CF1 0x20
#define STA339_A2CF2 0x21
#define STA339_A2CF3 0x22

#define STA339_B0CF1 0x23
#define STA339_B0CF2 0x24
#define STA339_B0CF3 0x25

#define STA559BW_CFADDR         0x16
#define STA559BW_BIQUADST       0x17
#define STA559BW_CFUD           0x26
    #define CFUD_WA             (0x01 << 1)

#define MUTE_ALL_CHL  0x01
#define UNMUTE_ALL_CHL 0

//---------------------------------------------------------------------------
// Public functions
//---------------------------------------------------------------------------

extern AMP_T* AUD_AMP_GetDrvCustFunTbl(void);

#endif /* MTK_AUD_AMP_339_H */


