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

📄 tvaudio.c

📁 Linux内核源代码 为压缩文件 是<<Linux内核>>一书中的源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
/* 0x01 - VL in TDA9855 *//* lower 7 bits control gain from -71dB (0x28) to 16dB (0x7f) * in 1dB steps - mute is 0x27 *//* 0x02 - BA in TDA9855 */ /* lower 5 bits control bass gain from -12dB (0x06) to 16.5dB (0x19) * in .5dB steps - 0 is 0x0E *//* 0x03 - TR in TDA9855 *//* 4 bits << 1 control treble gain from -12dB (0x3) to 12dB (0xb) * in 3dB steps - 0 is 0x7 *//* Masks for bits in both chips' subaddresses *//* 0x04 - SW in TDA9855, C4/Control 1 in TDA9850 *//* Unique to TDA9855: *//* 4 bits << 2 control subwoofer/surround gain from -14db (0x1) to 14db (0xf) * in 3dB steps - mute is 0x0 */ /* Unique to TDA9850: *//* lower 4 bits control stereo noise threshold, over which stereo turns off * set to values of 0x00 through 0x0f for Ster1 through Ster16 *//* 0x05 - C5 - Control 1 in TDA9855 , Control 2 in TDA9850*//* Unique to TDA9855: */#define TDA9855_MUTE	1<<7 /* GMU, Mute at outputs */#define TDA9855_AVL	1<<6 /* AVL, Automatic Volume Level */#define TDA9855_LOUD	1<<5 /* Loudness, 1==off */#define TDA9855_SUR	1<<3 /* Surround / Subwoofer 1==.5(L-R) 0==.5(L+R) */			     /* Bits 0 to 3 select various combinations                              * of line in and line out, only the                               * interesting ones are defined */#define TDA9855_EXT	1<<2 /* Selects inputs LIR and LIL.  Pins 41 & 12 */#define TDA9855_INT	0    /* Selects inputs LOR and LOL.  (internal) *//* Unique to TDA9850:  *//* lower 4 bits contol SAP noise threshold, over which SAP turns off * set to values of 0x00 through 0x0f for SAP1 through SAP16 *//* 0x06 - C6 - Control 2 in TDA9855, Control 3 in TDA9850 *//* Common to TDA9855 and TDA9850: */#define TDA985x_SAP	3<<6 /* Selects SAP output, mute if not received */#define TDA985x_STEREO	1<<6 /* Selects Stereo ouput, mono if not received */#define TDA985x_MONO	0    /* Forces Mono output */#define TDA985x_LMU	1<<3 /* Mute (LOR/LOL for 9855, OUTL/OUTR for 9850) *//* Unique to TDA9855: */#define TDA9855_TZCM	1<<5 /* If set, don't mute till zero crossing */#define TDA9855_VZCM	1<<4 /* If set, don't change volume till zero crossing*/#define TDA9855_LINEAR	0    /* Linear Stereo */#define TDA9855_PSEUDO	1    /* Pseudo Stereo */#define TDA9855_SPAT_30	2    /* Spatial Stereo, 30% anti-phase crosstalk */#define TDA9855_SPAT_50	3    /* Spatial Stereo, 52% anti-phase crosstalk */#define TDA9855_E_MONO	7    /* Forced mono - mono select elseware, so useless*//* 0x07 - C7 - Control 3 in TDA9855, Control 4 in TDA9850 *//* Common to both TDA9855 and TDA9850: *//* lower 4 bits control input gain from -3.5dB (0x0) to 4dB (0xF) * in .5dB steps -  0dB is 0x7 *//* 0x08, 0x09 - A1 and A2 (read/write) *//* Common to both TDA9855 and TDA9850: *//* lower 5 bites are wideband and spectral expander alignment * from 0x00 to 0x1f - nominal at 0x0f and 0x10 (read/write) */#define TDA985x_STP	1<<5 /* Stereo Pilot/detect (read-only) */#define TDA985x_SAPP	1<<6 /* SAP Pilot/detect (read-only) */#define TDA985x_STS	1<<7 /* Stereo trigger 1= <35mV 0= <30mV (write-only)*//* 0x0a - A3 *//* Common to both TDA9855 and TDA9850: *//* lower 3 bits control timing current for alignment: -30% (0x0), -20% (0x1), * -10% (0x2), nominal (0x3), +10% (0x6), +20% (0x5), +30% (0x4) */#define TDA985x_ADJ	1<<7 /* Stereo adjust on/off (wideband and spectral */int tda9855_volume(int val) { return val/0x2e8+0x27; }int tda9855_bass(int val)   { return val/0xccc+0x06; }int tda9855_treble(int val) { return (val/0x1c71+0x3)<<1; }int  tda985x_getmode(struct CHIPSTATE *chip){	int mode;	mode = ((TDA985x_STP | TDA985x_SAPP) & 		chip_read(chip)) >> 4;	/* Add mono mode regardless of SAP and stereo */	/* Allows forced mono */	return mode | VIDEO_SOUND_MONO;}void tda985x_setmode(struct CHIPSTATE *chip, int mode){	int update = 1;	int c6 = chip->shadow.bytes[TDA985x_C6+1] & 0x3f;		switch (mode) {	case VIDEO_SOUND_MONO:		c6 |= TDA985x_MONO;		break;	case VIDEO_SOUND_STEREO:		c6 |= TDA985x_STEREO;		break;	case VIDEO_SOUND_LANG1:		c6 |= TDA985x_SAP;		break;	default:		update = 0;	}	if (update)		chip_write(chip,TDA985x_C6,c6);}/* ---------------------------------------------------------------------- *//* audio chip descriptions - defines+functions for tda9873h               *//* Subaddresses for TDA9873H */#define TDA9873_SW	0x00 /* Switching                    */#define TDA9873_AD	0x01 /* Adjust                       */#define TDA9873_PT	0x02 /* Port                         *//* Subaddress 0x00: Switching Data  * B7..B0: * * B1, B0: Input source selection *  0,  0  internal *  1,  0  external stereo *  0,  1  external mono */#define TDA9873_INTERNAL    0#define TDA9873_EXT_STEREO  2#define TDA9873_EXT_MONO    1/*    B3, B2: output signal select * B4    : transmission mode  *  0, 0, 1   Mono *  1, 0, 0   Stereo *  1, 1, 1   Stereo (reversed channel)     *  0, 0, 0   Dual AB *  0, 0, 1   Dual AA *  0, 1, 0   Dual BB *  0, 1, 1   Dual BA */#define TDA9873_TR_MONO     4#define TDA9873_TR_STEREO   1 << 4#define TDA9873_TR_REVERSE  (1 << 3) & (1 << 2)#define TDA9873_TR_DUALA    1 << 2#define TDA9873_TR_DUALB    1 << 3/* output level controls * B5:  output level switch (0 = reduced gain, 1 = normal gain) * B6:  mute                (1 = muted) * B7:  auto-mute           (1 = auto-mute enabled) */#define TDA9873_GAIN_NORMAL 1 << 5#define TDA9873_MUTE        1 << 6#define TDA9873_AUTOMUTE    1 << 7/* Subaddress 0x01:  Adjust/standard *//* Lower 4 bits (C3..C0) control stereo adjustment on R channel (-0.6 - +0.7 dB) * Recommended value is +0 dB */#define	TDA9873_STEREO_ADJ	0x06 /* 0dB gain *//* Bits C6..C4 control FM stantard   * C6, C5, C4 *  0,  0,  0   B/G (PAL FM) *  0,  0,  1   M *  0,  1,  0   D/K(1) *  0,  1,  1   D/K(2) *  1,  0,  0   D/K(3) *  1,  0,  1   I */#define TDA9873_BG		0#define TDA9873_M       1#define TDA9873_DK1     2#define TDA9873_DK2     3#define TDA9873_DK3     4#define TDA9873_I       5/* C7 controls identification response time (1=fast/0=normal) */#define TDA9873_IDR_NORM 0#define TDA9873_IDR_FAST 1 << 7/* Subaddress 0x02: Port data */ /* E1, E0   free programmable ports P1/P2    0,  0   both ports low    0,  1   P1 high    1,  0   P2 high    1,  1   both ports high*/#define TDA9873_PORTS    3/* E2: test port */#define TDA9873_TST_PORT 1 << 2/* E5..E3 control mono output channel (together with transmission mode bit B4) * * E5 E4 E3 B4     OUTM *  0  0  0  0     mono *  0  0  1  0     DUAL B *  0  1  0  1     mono (from stereo decoder) */#define TDA9873_MOUT_MONO   0#define TDA9873_MOUT_FMONO  0#define TDA9873_MOUT_DUALA  0 #define TDA9873_MOUT_DUALB  1 << 3 #define TDA9873_MOUT_ST     1 << 4 #define TDA9873_MOUT_EXTM   (1 << 4 ) & (1 << 3)#define TDA9873_MOUT_EXTL   1 << 5 #define TDA9873_MOUT_EXTR   (1 << 5 ) & (1 << 3)#define TDA9873_MOUT_EXTLR  (1 << 5 ) & (1 << 4)#define TDA9873_MOUT_MUTE   (1 << 5 ) & (1 << 4) & (1 << 3)/* Status bits: (chip read) */#define TDA9873_PONR        0 /* Power-on reset detected if = 1 */#define TDA9873_STEREO      2 /* Stereo sound is identified     */#define TDA9873_DUAL        4 /* Dual sound is identified       */int tda9873_getmode(struct CHIPSTATE *chip){	int val,mode;	val = chip_read(chip);	mode = VIDEO_SOUND_MONO;	if (val & TDA9873_STEREO)		mode |= VIDEO_SOUND_STEREO;	if (val & TDA9873_DUAL)		mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2;	dprintk ("tda9873_getmode(): raw chip read: %d, return: %d\n",		 val, mode);	return mode;}void tda9873_setmode(struct CHIPSTATE *chip, int mode){	int sw_data  = chip->shadow.bytes[TDA9873_SW+1] & 0xe3;	/*	int adj_data = chip->shadow.bytes[TDA9873_AD+1] ; */	dprintk("tda9873_setmode(): chip->shadow.bytes[%d] = %d\n", TDA9873_SW+1, chip->shadow.bytes[TDA9873_SW+1]);	dprintk("tda9873_setmode(): sw_data  = %d\n", sw_data);	switch (mode) {	case VIDEO_SOUND_MONO:		sw_data |= TDA9873_TR_MONO;   		break;	case VIDEO_SOUND_STEREO:		sw_data |= TDA9873_TR_STEREO;		break;	case VIDEO_SOUND_LANG1:		sw_data |= TDA9873_TR_DUALA;		break;	case VIDEO_SOUND_LANG2:		sw_data |= TDA9873_TR_DUALB;		break;	}	dprintk("tda9873_setmode(): req. mode %d; chip_write: %d\n", mode, sw_data);	chip_write(chip,TDA9873_SW,sw_data);}void tda9873_checkmode(struct CHIPSTATE *chip){	int mode = tda9873_getmode(chip);	if (mode & VIDEO_SOUND_STEREO)		tda9873_setmode(chip,VIDEO_SOUND_STEREO);	if (mode & VIDEO_SOUND_LANG1)		tda9873_setmode(chip,VIDEO_SOUND_LANG1);}int tda9873_checkit(struct CHIPSTATE *chip){	int rc;	if (-1 == (rc = chip_read2(chip,254)))		return 0;	return (rc & ~0x1f) == 0x80;}/* ---------------------------------------------------------------------- *//* audio chip descriptions - defines+functions for tea6420                */#define TEA6300_VL         0x00  /* volume left */#define TEA6300_VR         0x01  /* volume right */#define TEA6300_BA         0x02  /* bass */#define TEA6300_TR         0x03  /* treble */#define TEA6300_FA         0x04  /* fader control */#define TEA6300_S          0x05  /* switch register */                                 /* values for those registers: */#define TEA6300_S_SA       0x01  /* stereo A input */#define TEA6300_S_SB       0x02  /* stereo B */#define TEA6300_S_SC       0x04  /* stereo C */#define TEA6300_S_GMU      0x80  /* general mute */#define TEA6420_S_SA       0x00  /* stereo A input */#define TEA6420_S_SB       0x01  /* stereo B */#define TEA6420_S_SC       0x02  /* stereo C */#define TEA6420_S_SD       0x03  /* stereo D */#define TEA6420_S_SE       0x04  /* stereo E */#define TEA6420_S_GMU      0x05  /* general mute */int tea6300_shift10(int val) { return val >> 10; }int tea6300_shift12(int val) { return val >> 12; }/* ---------------------------------------------------------------------- *//* audio chip descriptions - defines+functions for tda8425                */#define TDA8425_VL         0x00  /* volume left */#define TDA8425_VR         0x01  /* volume right */#define TDA8425_BA         0x02  /* bass */#define TDA8425_TR         0x03  /* treble */#define TDA8425_S1         0x08  /* switch functions */                                 /* values for those registers: */#define TDA8425_S1_OFF     0xEE  /* audio off (mute on) */#define TDA8425_S1_ON      0xCE  /* audio on (mute off) - "linear stereo" mode */int tda8425_shift10(int val) { return val >> 10 | 0xc0; }int tda8425_shift12(int val) { return val >> 12 | 0xf0; }/* ---------------------------------------------------------------------- *//* audio chip descriptions - defines+functions for pic16c54 (PV951)       *//* the registers of 16C54, I2C sub address. */#define PIC16C54_REG_KEY_CODE     0x01	       /* Not use. */#define PIC16C54_REG_MISC         0x02/* bit definition of the RESET register, I2C data. */#define PIC16C54_MISC_RESET_REMOTE_CTL 0x01 /* bit 0, Reset to receive the key */                                            /*        code of remote controller */#define PIC16C54_MISC_MTS_MAIN         0x02 /* bit 1 */#define PIC16C54_MISC_MTS_SAP          0x04 /* bit 2 */#define PIC16C54_MISC_MTS_BOTH         0x08 /* bit 3 */#define PIC16C54_MISC_SND_MUTE         0x10 /* bit 4, Mute Audio(Line-in and Tuner) */#define PIC16C54_MISC_SND_NOTMUTE      0x20 /* bit 5 */#define PIC16C54_MISC_SWITCH_TUNER     0x40 /* bit 6	, Switch to Line-in */#define PIC16C54_MISC_SWITCH_LINE      0x80 /* bit 7	, Switch to Tuner *//* ---------------------------------------------------------------------- *//* audio chip descriptions - struct CHIPDESC                              *//* insmod options to enable/disable individual audio chips */int tda8425  = 1;int tda9840  = 1;int tda9850  = 1;int tda9855  = 1;int tda9873  = 1;int tea6300  = 0;int tea6420  = 1;int pic16c54 = 1;MODULE_PARM(tda8425,"i");MODULE_PARM(tda9840,"i");MODULE_PARM(tda9850,"i");MODULE_PARM(tda9855,"i");MODULE_PARM(tda9873,"i");MODULE_PARM(tea6300,"i");MODULE_PARM(tea6420,"i");

⌨️ 快捷键说明

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