📄 ddx8001.c
字号:
//=============================================================================
// File Name: ddx8001.c
//
// Copyright 2003 Cirrus Logic Corporation
//
// Description:
// board interface to the Apogee ddx-8000 pwm board
//
// Modification History:
//
// $Id: ddx8001.c,v 1.2 2005/04/29 10:22:00 michaell Exp $
// $Log: ddx8001.c,v $
// Revision 1.2 2005/04/29 10:22:00 michaell
// merge 2.6 into head
//
// Revision 1.1.1.1 2005/03/07 08:07:07 dchien
// Import Sonata2_2-6-3
//
// Revision 1.5 2004/10/28 17:01:58 jchou
// adjust bass manager gain to make gains uniform
//
// Revision 1.4 2004/10/28 00:53:55 jchou
// bug 25142: simplified bass management
//
// Revision 1.3 2004/10/27 22:58:18 jchou
// bug 25142: simplified bass management
//
// Revision 1.2 2004/08/25 22:33:45 jchou
// bug 24732: concerto merge
//
// Revision 1.1.6.1 2004/07/21 16:22:38 jminor
// Concerto merge to CONCERTO_20040720. Driver directories.
//
// Revision 1.1.4.1 2004/05/18 22:10:44 jminor
// Bug 19031, merge of DRIVER directories.
//
// Revision 1.1.2.2 2004/04/06 21:40:21 pdsouza
// Set channel volume to +10dB to meet dolby requirements
//
// Revision 1.1.2.1 2004/03/26 02:34:09 pdsouza
// Initial check in of PWM driver
//
// Revision 1.2.10.1 2003/12/09 23:20:50 pdsouza
// Merged PWM driver and seven dot 1 features
//
// Revision 1.2 2003/11/12 18:01:30 dclark
// POST_DVDEV_SONATA_MERGE
//
// Revision 1.1.2.1 2003/10/23 19:49:41 chouston
// DVDEV_SONATA_MERGE_20031014 - import of cdb98200, dvd_rx, dvd_rx_200 targets
// from dvdev
//
// Revision 1.2 2003/03/26 22:55:57 jtodd
// Integrated #2845
//
// Revision 1.1.2.2 2003/03/26 15:41:37 jcody
// bugzilla 2845 - fixed 'USE_DDX8001' directive
//
// Revision 1.1.2.1 2003/03/26 15:11:22 jcody
// bugzilla 2845: Added initial support for the Apogee DDX8001 board
//
//
//============================================================================
#include "apiconfig.h"
#if USE_PWM
#include "apitypes.h"
#include "chips.h"
#define DEBUG_CPU 0
#include "eromdbg.h"
#include "ddx8001.h"
#include "apii2c.h"
#include "osapi.h"
#include "delay.h"
//-----------------------------------------------------------------------------
// Local definitions
//-----------------------------------------------------------------------------
#define DEBUG_MSG
#ifdef DEBUG_MSG
#define DEBUG_OUT(fmt, args...) { ERomPrintFunc (DEBUG_CPU, fmt, ## args); }
#else
#define DEBUG_OUT(fmt, args...)
#endif
#define CHECK_RETURN(ret) \
if (SUCCESS != ret) \
{ \
ErrPrint("Error communicating to DDX8001\n"); \
DEBUG_OUT("Error communicating to DDX8001\n"); \
return FAIL; \
}
// for individual channel volumes, this will be 0 dB. //
//DRC - OLD#define DEFAULT_VOL 0x3c
#define DEFAULT_VOL 0x30
#define VOL_NEG_30DB 108
#define VOL_NEG_50DB 148
#define VOL_HARD_MUTE 255
#define VOL_2DB_STEP 4
#define VOL_1DB_STEP 2
//-----------------------------------------------------------------------------
// Local variables
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Local functions
//-----------------------------------------------------------------------------
//================= GLOBAL FUNCTIONS =====================
// || ||
// || ||
// - - - -
// \ / \ /
// \/ \/
//
//-----------------------------------------------------------------------------
// Function:
int PWM_Init(
//
// Description:
// Initializes the DDX8001 PWM board
//
// Parameters:
void
)
// Returns: SUCCESS or FAIL
//-----------------------------------------------------------------------------
{
Uint32 data;
Uint8 retval;
DEBUG_OUT("PWM_Init start\n");
//Set DDX8001 for MCLK for 256fs, Sampling freq of 32, 44.1 and 48Khz, Bypass DSP,
data = 0x83;
retval = API_SendI2C (PWM_I2C_ADDR, DDX8001_REG_CONFA, data);
CHECK_RETURN(retval);
// Set DDX8001 for I2S 24 bit data
data = 0x00;
retval |= API_SendI2C (PWM_I2C_ADDR, DDX8001_REG_CONFB, data);
CHECK_RETURN(retval);
// Set DDX8001 for Max Power Correction adn DDX-2060 power mode
data = 0xc2;
retval |= API_SendI2C (PWM_I2C_ADDR, DDX8001_REG_CONFD, data);
CHECK_RETURN(retval);
// Set DDX8001 for DC blocking, DRC enabled, De-emphasis disabled, pwm speed for 384khz
data = 0x00;
retval |= API_SendI2C (PWM_I2C_ADDR, DDX8001_REG_CONFF, data);
CHECK_RETURN(retval);
// Set DDX8001 to enable PWM out, Disable Serial I2S out, Disable clock out, Disable AM mode,
data = 0x00;
retval |= API_SendI2C (PWM_I2C_ADDR, DDX8001_REG_CONFG, data);
CHECK_RETURN(retval);
// Set DDX8001 for Zero-Crossing Volume Enabled:, Soft Volume Enabled:, Zero-Detect Mute Enabled:, Invalid Input Detect Auto-Mute Enabled:
// Binary Output Mode Clock Loss Detection Enabled, Auto EAPD on Clock Loss Enabled
data = 0xfe;
retval |= API_SendI2C (PWM_I2C_ADDR, DDX8001_REG_CONFH, data);
CHECK_RETURN(retval);
// Set DDX8001 to disable external PWM
data = 0x00;
retval |= API_SendI2C (PWM_I2C_ADDR, DDX8001_REG_CONFI, data);
CHECK_RETURN(retval);
// Set DDX8001 to Mute outputs
data = 0x00;
retval |= API_SendI2C (PWM_I2C_ADDR, DDX8001_REG_MMUTE, data);
CHECK_RETURN(retval);
// Set individual channel volume to +10. The channel volume in the DSP have been set to -10 to
// allow a user to set a level of +10
// remember to add a gain of +6 db to all channels except subwoofer to compensate for bass management
// subwoofer also requires a +6 db gain -- +5 by spec and +1 db by adjusting bass management just to make it uniform.
data = 0x40;
retval |= API_SendI2C (PWM_I2C_ADDR, DDX8001_REG_C1VOL, data);
CHECK_RETURN(retval);
data = 0x40;
retval |= API_SendI2C (PWM_I2C_ADDR, DDX8001_REG_C2VOL, data);
CHECK_RETURN(retval);
data = 0x40;
retval |= API_SendI2C (PWM_I2C_ADDR, DDX8001_REG_C3VOL, data);
CHECK_RETURN(retval);
data = 0x40;
retval |= API_SendI2C (PWM_I2C_ADDR, DDX8001_REG_C4VOL, data);
CHECK_RETURN(retval);
data = 0x40;
retval |= API_SendI2C (PWM_I2C_ADDR, DDX8001_REG_C5VOL, data);
CHECK_RETURN(retval);
data = 0x40;
retval |= API_SendI2C (PWM_I2C_ADDR, DDX8001_REG_C6VOL, data);
CHECK_RETURN(retval);
data = 0x40;
retval |= API_SendI2C (PWM_I2C_ADDR, DDX8001_REG_C7VOL, data);
CHECK_RETURN(retval);
data = 0x40;
retval |= API_SendI2C (PWM_I2C_ADDR, DDX8001_REG_C8VOL, data);
CHECK_RETURN(retval);
// Set DDX8001 Master volume to 0db
data = 0x00;
retval |= API_SendI2C (PWM_I2C_ADDR, DDX8001_REG_MVOL, data);
CHECK_RETURN(retval);
DEBUG_OUT("PWM_Init success\n");
return SUCCESS;
}
//-----------------------------------------------------------------------------
// Function:
int PWM_AmpOn(
//
// Description:
// Turns the external High power amp on
//
// Parameters:
void
)
// Returns: SUCCESS or FAIL
//-----------------------------------------------------------------------------
{
Uint8 data;
Uint8 retval;
DEBUG_OUT("PWM_AmpOn start\n");
// Set DDX8001 to enable PWM out
data = 0x80;
retval = API_SendI2C (PWM_I2C_ADDR, DDX8001_REG_CONFI, data);
Delay_ms(100);
CHECK_RETURN(retval);
// Set DDX8001 to UnMute outputs
// data = 0x00;
// retval |= API_SendI2C (PWM_I2C_ADDR, DDX8001_REG_MMUTE, data);
// CHECK_RETURN(retval);
DEBUG_OUT("PWM_AmpOn success\n");
return SUCCESS;
}
//-----------------------------------------------------------------------------
// Function:
int PWM_AmpOff(
//
// Description:
// Turns the external High power amp off
//
// Parameters:
void
)
// Returns: SUCCESS or FAIL
//-----------------------------------------------------------------------------
{
Uint8 data;
Uint8 retval;
DEBUG_OUT("PWM_AmpOff start\n");
// Set DDX8001 to Mute outputs
// data = 0x01;
// retval = API_SendI2C (PWM_I2C_ADDR, DDX8001_REG_MMUTE, data);
// CHECK_RETURN(retval);
// Set DDX8001 for Disable PWM out
data = 0x00;
retval = API_SendI2C (PWM_I2C_ADDR, DDX8001_REG_CONFI, data);
Delay_ms(100);
CHECK_RETURN(retval);
DEBUG_OUT("PWM_AmpOff success\n");
return SUCCESS;
}
#endif //USE_PWM
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -