⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msp3430.cpp

📁 ati driver
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************//	File:			MSP3430.cpp//	Description:	Micronas Multistandard Sound Processor (MSP) interface.//	Copyright 2001, Carlos Hasan/*******************************************************************************/#include <Debug.h>#include "MSP3430.h"enum MSP3430_register {    MSP3430_CONTROL					= 0x00,				// R/W control register    MSP3430_WR_DEM					= 0x10,				// Write demodulator register    MSP3430_RD_DEM					= 0x11,				// Read demodulator register    MSP3430_WR_DSP					= 0x12,				// Read DSP register    MSP3430_RD_DSP					= 0x13				// Write DSP register};enum MSP3430_control_register {	MSP3430_CONTROL_NORMAL			= 0x0000,			// normal operation mode	MSP3430_CONTROL_RESET			= 0x8000			// reset mode};enum MSP3430_wr_dem_register {	MSP3430_DEM_STANDARD_SEL		= 0x0020,			// standard selection	MSP3430_DEM_MODUS				= 0x0030,			// demodulator options	MSP3430_DEM_I2S_CONFIG			= 0x0040			// I2S configuration};enum MSP3430_rd_dem_register {	MSP3430_DEM_STANDARD_RES		= 0x007e,			// standard detection result	MSP3430_DEM_STATUS				= 0x0200			// status register};enum MSP3430_wr_dsp_register {	// preprocessing	MSP3430_DSP_FM_PRESCALE			= 0x000e,			// FM/AM analog signal prescale		MSP3430_DSP_PRE_FM			= BITS(15:8),		MSP3430_DSP_FM_MATRIX		= BITS(7:0),	MSP3430_DSP_NICAM_PRESCALE		= 0x0010,			// NICAM digital signal prescale		MSP34300_DSP_PRE_NICAM		= BITS(15:8),	MSP3430_DSP_PRE_I2S2			= 0x0012,			// I2S digital signal prescale	MSP3430_DSP_PRE_I2S1			= 0x0016,	MSP3430_DSP_PRE_SCART			= 0x000d,			// SCART prescale	// source select and output channel matrix	MSP3430_DSP_SRC_MAT_MAIN		= 0x0008,			// loudspeaker source and matrix		MSP3430_DSP_SRC_MAIN		= BITS(15:8),		MSP3430_DSP_MAT_MAIN		= BITS(7:0),	MSP3430_DSP_SRC_MAT_AUX			= 0x0009,			// headphone source and matrix		MSP3430_DSP_SRC_AUX			= BITS(15:8),		MSP3430_DSP_MAT_AUX			= BITS(7:0),	MSP3430_DSP_SRC_MAT_SCART1		= 0x000a,			// SCART1 source and matrix		MSP3430_DSP_SRC_SCART1		= BITS(15:8),		MSP3430_DSP_MAT_SCART1		= BITS(7:0),	MSP3430_DSP_SRC_MAT_SCART2		= 0x0041,			// SCART2 source and matrix		MSP3430_DSP_SRC_SCART2		= BITS(15:8),		MSP3430_DSP_MAT_SCART2		= BITS(7:0),	MSP3430_DSP_SRC_MAT_I2S			= 0x000b,			// I2S source and matrix		MSP3430_DSP_SRC_I2S			= BITS(15:8),		MSP3430_DSP_MAT_I2S			= BITS(7:0),	MSP3430_DSP_SRC_MAT_QPEAK		= 0x000c,			// QuasiPeak detector source and matrix		MSP3430_DSP_SRC_QPEAK		= BITS(15:8),		MSP3430_DSP_MAT_QPEAK		= BITS(7:0),		// loudspeaker and headphone processing	MSP3430_DSP_VOL_MAIN			= 0x0000,			// loudspeaker volume	MSP3430_DSP_VOL_AUX				= 0x0006,			// headphone volume	MSP3430_DSP_AVC					= 0x0029,			// automatic volume correction	MSP3430_DSP_BAL_MAIN			= 0x0001,			// loudspeaker balance	MSP3430_DSP_BAL_AUX				= 0x0030,			// headphone balance	MSP3430_DSP_TONE_MODE			= 0x0020,			// select bass/treble or equalizer	MSP3430_DSP_BASS_MAIN			= 0x0002,			// loudspeaker bass	MSP3430_DSP_BASS_AUX			= 0x0031,			// headphone bass	MSP3430_DSP_TREB_MAIN			= 0x0003,			// loudspeaker treble	MSP3430_DSP_TREB_AUX			= 0x0032,			// headphone treble	MSP3430_DSP_EQUAL_BAND1			= 0x0021,			// equalizer coefficients	MSP3430_DSP_EQUAL_BAND2			= 0x0022,	MSP3430_DSP_EQUAL_BAND3			= 0x0023,	MSP3430_DSP_EQUAL_BAND4			= 0x0024,	MSP3430_DSP_EQUAL_BAND5			= 0x0025,	MSP3430_DSP_LOUD_MAIN			= 0x0004,			// loudspeaker loudness	MSP3430_DSP_LOUD_AUX			= 0x0033,			// headphone loudness	MSP3430_DSP_SPAT_MAIN			= 0x0005,			// spatial effects		// subwoofer output channel	MSP3430_DSP_SUBW_LEVEL			= 0x002c,			// subwoofer level	MSP3430_DSP_SUBW_FREQ			= 0x002d,			// subwoofer frequency	// micronas dynamic bass	MSP3430_DSP_MDB_STR				= 0x0068,			// MDB strength	MSP3430_DSP_MDB_LIM				= 0x0069,			// MDB limit	MSP3430_DSP_MDB_HMC				= 0x006a,			// MDB harmonic content	MSP3430_DSP_MDB_LP				= 0x006b,			// MDB low frequency	MSP3430_DSP_MDB_HP				= 0x006c,			// MDB high frequency		// SCART output channel	MSP3430_DSP_VOL_SCART1			= 0x0007,			// SCART1 volume	MSP3430_DSP_VOL_SCART2			= 0x0040,			// SCART2 volume		// SCART switches and digital I/O pins	MSP3430_DSP_ACB_REG				= 0x0013,			// SCART switches	MSP3430_DSP_BEEPER				= 0x0014			// Beeper volume and frequency};enum MSP3430_rd_dsp_register {	// quasi-peak detector readout	MSP3430_DSP_QPEAK_L				= 0x0019,			// Quasipeak detector left and right	MSP3430_DSP_QPEAK_R				= 0x001a,		// MSP 34x0G version readout	MSP3430_DSP_MSP_HARD_REVISION	= 0x001e,			// MSP hardware and revision		MSP3430_DSP_MSP_HARD		= BITS(15:8),		MSP3430_DSP_MSP_REVISION	= BITS(7:0),	MSP3430_DSP_MSP_PRODUCT_ROM		= 0x001f,			// MSP product and ROM version		MSP3430_DSP_MSP_PRODUCT		= BITS(15:8),		MSP3430_DSP_MSP_ROM			= BITS(7:0)};enum MSP3430_sound_standard {	C_MSP3430_AUTOMATIC			= 0x0001,	// Automatic Detection (*)	C_MSP3430_M_FM_STEREO		= 0x0002,	// NTSC M/N (*)	C_MSP3430_BG_FM_STEREO		= 0x0003,	// PAL B/G (*)	C_MSP3430_DK1_FM_STEREO		= 0x0004,	// (*)	C_MSP3430_DK2_FM_STEREO		= 0x0005,	// 	C_MSP3430_DK_FM_MONO		= 0x0006,	// 	C_MSP3430_DK3_FM_STEREO		= 0x0007,	// 	C_MSP3430_BG_NICAM_FM		= 0x0008,	// PAL B/G (*)	C_MSP3430_L_NICAM_AM		= 0x0009,	// (*)	C_MSP3430_I_NICAM_FM		= 0x000A,	// PAL I (*)	C_MSP3430_DK_NICAM_FM		= 0x000B,	// (*)	C_MSP3430_DK_NICAM_FM_HDEV2	= 0x000C,	C_MSP3430_DK_NICAM_FM_HDEV3	= 0x000D,	C_MSP3430_BTSC_STEREO		= 0x0020,	// BTSC Stereo (*)	C_MSP3430_BTSC_MONO_SAP		= 0x0021,	C_MSP3430_M_JAPAN_STEREO	= 0x0030,	// NTSC Japan (*)	C_MSP3430_FM_RADIO			= 0x0040,	// FM Radio (*)	C_MSP3430_SAT_MONO			= 0x0050,	// Satellite Mono	C_MSP3430_SAT_STEREO		= 0x0051,	// Satellite Stereo	C_MSP3430_SAT_ASTRA_RADIO	= 0x0060	// Astra Digital Radio};enum MSP3430_channel_source {	C_MSP3430_SOURCE_FM			= 0x00,		// FM/AM Mono	C_MSP3430_SOURCE_STEREO		= 0x01,		// Stereo or A/B (NICAM)	C_MSP3430_SOURCE_SCART		= 0x02,		// SCART Input	C_MSP3430_SOURCE_LANG_A		= 0x03,		// Stereo/Language A	C_MSP3430_SOURCE_LANG_B		= 0x04,		// Stereo/Language B	C_MSP3430_SOURCE_I2S1		= 0x05,		// I2S1 Input	C_MSP3430_SOURCE_I2S2		= 0x06		// I2S2 Input};enum MSP3430_channel_matrix {	C_MSP3430_MATRIX_SOUND_A	= 0x00,		// Sound A Mono	C_MSP3430_MATRIX_SOUND_B	= 0x10,		// Sound B Mono	C_MSP3430_MATRIX_STEREO		= 0x20,		// Stereo	C_MSP3430_MATRIX_MONO		= 0x30		// Mono};/*-------------------------------------------------------------------System			Sound			Sound				Color				Carrier (MHz)	Modulation			System-------------------------------------------------------------------Satellite		6.5/5.85		FM-Mono/NICAM		PAL				6.5				FM-Mono				7.02/7.2		FM-Stereo			PAL				7.38/7.56		ASTRA Digital Radio				etc.				4.5/4.724212	FM-Stereo (A2)		NTSC-------------------------------------------------------------------NTSC M/N		4.5				FM-FM (EIA-J)		NTSC-------------------------------------------------------------------				4.5				BTSC Stereo + SAP	NTSC, PALFM-Radio		10.7			FM-Stereo Radio		.-------------------------------------------------------------------*/CMSP3430::CMSP3430(CI2CPort & port)	:	fPort(port),		fAddress(0){	PRINT(("CMSP3430::CMSP3430()\n"));		if( fPort.InitCheck() == B_OK ) {		for (fAddress = 0x80; fAddress <= 0x80; fAddress += 0x02) {	        if (fPort.Probe(fAddress)) {	        	PRINT(("CMSP3430::CMSP3430() - Sound Processor found at I2C port 0x%02x\n", fAddress));				break;			}		}	}	if( InitCheck() != B_OK )		PRINT(("CMSP3430::CMSP3430() - Sound processor not found!\n"));}CMSP3430::~CMSP3430(){	PRINT(("CMSP3430::~CMSP3430()\n"));}status_t CMSP3430::InitCheck() const{	status_t res;		res = fPort.InitCheck();	if( res != B_OK )		return res;			return (fAddress >= 0x80 && fAddress <= 0x80) ? B_OK : B_ERROR;}void CMSP3430::SetEnable(bool enable){	PRINT(("CMSP3430::SetEnable(%d)\n", enable));		SetControlRegister(MSP3430_CONTROL_RESET);	SetControlRegister(MSP3430_CONTROL_NORMAL);	if (enable) {		SetRegister(MSP3430_WR_DEM, MSP3430_DEM_MODUS, 0x2003);		SetRegister(MSP3430_WR_DEM, MSP3430_DEM_STANDARD_SEL, C_MSP3430_BTSC_STEREO); // 0x20		SetRegister(MSP3430_WR_DSP, MSP3430_DSP_FM_PRESCALE, 0x2403);		SetRegister(MSP3430_WR_DSP, MSP3430_DSP_SRC_MAT_MAIN, 0x0320);		SetRegister(MSP3430_WR_DSP, MSP3430_DSP_VOL_MAIN, 0x7300);		SetRegister(MSP3430_WR_DSP, MSP3430_DSP_SRC_MAT_MAIN, 0x0320);	}	else {		SetRegister(MSP3430_WR_DSP, MSP3430_DSP_VOL_MAIN, 0x0000);	}}#if 0#pragma mark -void CMSP3430::SetI2S(bool fast){	// select 2 x 16 bit (1024 MHz) or 2 x 32 bit (2048) frequency	SetRegister(MSP3430_WR_DEM, I2S_CONFIG, fast ? 0x0001 : 0x0000);}bool CMSP3430::IsSAP(){	// bilingual sound mode or SAP present?	if ((Register(MSP3430_RD_DEM, STATUS) & 0x0100) != 0x0000)		return true;	return false;}bool CMSP3430::IsMonoNICAM(){	// independent mono sound (only NICAM)?	if ((Register(MSP3430_RD_DEM, STATUS) & 0x0080) != 0x0000)		return true;	return false;}bool CMSP3430::IsStereo(){	// mono/stereo indication	if ((Register(MSP3430_RD_DEM, STATUS) & 0x0040) != 0x0000)		return true;	return false;}bool CMSP3430::IsFM(){	// is analog sound standard (FM or AM) active?	if ((Register(MSP3430_RD_DEM, STATUS) & 0x0120) == 0x0000)		return true;	return false;}bool CMSP3430::IsNICAM(){	// digital sound (NICAM) available?	if ((Register(MSP3430_RD_DEM, STATUS) & 0x0100) == 0x0100)		return true;	return false;}bool CMSP3430::HasSecondaryCarrier(){	// detected secondary carrier (2nd A2 or SAP sub-carrier)	if ((Register(MSP3430_RD_DEM, STATUS) & 0x0004) != 0x0000)		return true;	return false;}	bool CMSP3430::HasPrimaryCarrier(){	// detected primary carrier (Mono or MPX carrier)	if ((Register(MSP3430_RD_DEM, STATUS) & 0x0002) != 0x0000)		return true;	return false;}void CMSP3430::SetStandard(MSP3430_standard standard){	fStandard = standard;		// set sound mode, FM/AM matrix, source channels	switch (standard) {	C_MSP3430_STANDARD_BG_FM:	C_MSP3430_STANDARD_DK_FM:		// Sound Mode	FM Matrix		FM/AM Source	Stereo A/B Source		// ---------------------------------------------------------------		// Mono 		Sound A Mono	Mono			Mono	C_MSP3430_STANDARD_M_KOREA:	C_MSP3430_STANDARD_M_JAPAN:		// Stereo 		Korean Stereo	Stereo			Stereo		// Stereo 		German Stereo	Stereo			Stereo		// Lang A & B	No Matrix		Left=A, Right=B	Left=A, Right=B			C_MSP3430_STANDARD_BG_NICAM:			}		SetDemodulator();}void CMSP3430::SetFMPrescale(int gain, MSP3430_fm_matrix matrix, bool mute){	// set FM/AM prescale and FM matrix mode	fFMPrescale = (mute ? 0x00 : Clamp(gain, 0x00, 0x7f)) << 8;	/// see table 6--17, Appendix B.	switch (matrix) {	case C_MSP3430_MATRIX_NONE:		fFMPrescale |= 0x0000;		break;	case C_MSP3430_MATRIX_GERMAN_STEREO_BG:		fFMPrescale |= 0x0001;		break;	case C_MSP3430_MATRIX_KOREAN_STEREO:		fFMPrescale |= 0x0002;		break;	case C_MSP3430_MATRIX_SOUND_A_MONO:		fFMPrescale |= 0x0003;		break;	case C_MSP3430_MATROX_SOUND_B_MONO:		fFMPrescale |= 0x0004;		break;	}		SetDemodulator();}void CMSP3430::SetNICAMPrescale(int gain, bool mute){	// set NICAM prescale to 0..12 dB	fNICAMPrescale = (mute ? 0x00 : Clamp(0x20 + (0x5f * gain) / 12, 0x20, 0x7f)) << 8;	SetDemodulator();}void CMSP3430::SetI2SPrescale(int gain, bool mute){	// set digital I2S input prescale 0..18 dB	fI2SPrescale = (mute ? 0x00 : Clamp(0x10 + (0x7f * gain) / 18, 0x10, 0x7f) << 8;	SetSCARTInput();}void CMSP3430::SetSCARTPrescale(int gain, bool mute){	// set SCART input signal prescale 0..14 dB	fSCARTPrescale = (mute ? 0x00 : Clamp(0x19 + (0x66 * gain) / 14, 0x19, 0x7f) << 8;	SetSCARTInput();}void CMSP3430::SetSource(MSP3430_source_channel speaker,						 MSP3430_source_channel headphone,						 MSP3430_source_channel scart1,						 MSP3430_source_channel scart2,						 MSP3430_source_channel i2s,						 MSP3430_source_channel qpeak){	// set source and matrix..	// select FM/AM, Stereo A/B, Stereo A, Stereo B, SCART, I2S1 or I2S2 source channels	// and select Sound A Mono, Sound B Mono, Stereo or Mono mode	fSrcMain = loudspeaker;	fSrcAux = headphone;	fSrcSCART1 = scart1;	fSrcSCART2 = scart2;	fSrcI2S = i2s;	fSrcQPeak = qpeak;	SetOutputChannels();}void CMSP3430::SetVolume(int level, bool mute, MSP3430_clipping_mode mode,				MSP3430_automatic_volume automatic){	// set volume between -114 dB and 12 dB with 1 dB step size	fVolume = (mute ? 0x00 : Clamp(level + 0x73, 0x01, 0x7f)) << 8;	switch (mode) {	case C_MSP3430_CLIP_REDUCE_VOLUME:		fVolume |= 0x00;		break;	case C_MSP3430_CLIP_REDUCE_TONE:		fVolume |= 0x01;		break;	case C_MSP3430_CLIP_COMPROMISE:		fVolume |= 0x02;		break;	case C_MSP3430_CLIP_DYNAMIC:		fVolume |= 0x03;		break;	}		// enable/disable automatic volume correction	switch (automatic) {	case C_MSP3430_AUTOMATIC_VOLUME_OFF:		fAVC = 0x0000;		break;	case C_MSP3430_AUTOMATIC_VOLUME_20_MS:		fAVC = 0x8100;		break;	case C_MSP3430_AUTOMATIC_VOLUME_2_SEC:		fAVC = 0x8200;		break;	case C_MSP3430_AUTOMATIC_VOLUME_4_SEC:		fAVC = 0x8400;		break;	case C_MSP3430_AUTOMATIC_VOLUME_8_SEC:		fAVC = 0x8800;		break;	}	SetOutputChannels();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -