1#ifndef __MSP3430_H__
2#define __MSP3430_H__
3
4#include "xf86i2c.h"
5
6typedef struct {
7        I2CDevRec d;
8
9	int standard;
10	int connector;
11	int mode;
12
13        CARD8 hardware_version, major_revision, product_code, rom_version;
14#ifdef MSP_DEBUG
15	CARD8 registers_present[256];
16#endif
17
18	CARD16 chip_id;
19	CARD8  chip_family;
20	Bool  recheck;		/*reinitialization needed after channel change */
21	CARD8 c_format;		/*current state of audio format */
22	CARD16 c_standard;	/*current state of standard register */
23	CARD8	c_source;	/*current state of source register */
24	CARD8	c_matrix;	/*current state of matrix register */
25	CARD8	c_fmmatrix;	/*current state of fmmatrix register */
26	int		c_mode;	/* current state of mode for autoswitchimg */
27	CARD8	volume;
28	} MSP3430Rec, * MSP3430Ptr;
29
30
31#define MSP3430_ADDR_1      0x80
32#define MSP3430_ADDR_2		0x84
33#define MSP3430_ADDR_3		0x88
34
35#define MSP3430_PAL		1
36#define MSP3430_NTSC		2
37#define MSP3430_PAL_DK1         (0x100 | MSP3430_PAL)
38#define MSP3430_SECAM           3
39
40#define MSP3430_CONNECTOR_1     1   /* tuner on AIW cards */
41#define MSP3430_CONNECTOR_2     2   /* SVideo on AIW cards */
42#define MSP3430_CONNECTOR_3     3   /* composite on AIW cards */
43
44#define MSP3430_ADDR(a)         ((a)->d.SlaveAddr)
45
46#define MSP3430_FAST_MUTE	0xFF
47/* a handy volume transform function, -1000..1000 -> 0x01..0x7F */
48#define MSP3430_VOLUME(value) (0x01+(0x7F-0x01)*log(value+1001)/log(2001))
49
50/*----------------------------------------------------------*/
51
52/* MSP chip families */
53#define MSPFAMILY_UNKNOWN	0
54#define MSPFAMILY_34x0D		1
55#define MSPFAMILY_34x5D		2
56#define MSPFAMILY_34x0G		3
57#define MSPFAMILY_34x5G		4
58
59/* values for MSP standard */
60#define MSPSTANDARD_UNKNOWN	0x00
61#define MSPSTANDARD_AUTO	0x01
62#define MSPSTANDARD_FM_M	0x02
63#define MSPSTANDARD_FM_BG	0x03
64#define MSPSTANDARD_FM_DK1	0x04
65#define MSPSTANDARD_FM_DK2	0x04
66#define MSPSTANDARD_NICAM_BG	0x08
67#define MSPSTANDARD_NICAM_L	0x09
68#define MSPSTANDARD_NICAM_I	0x0A
69#define MSPSTANDARD_NICAM_DK	0x0B
70
71/* values for MSP format */
72#define MSPFORMAT_UNKNOWN	0x00
73#define MSPFORMAT_FM		0x10
74#define MSPFORMAT_1xFM		0x00|MSPFORMAT_FM
75#define MSPFORMAT_2xFM		0x01|MSPFORMAT_FM
76#define MSPFORMAT_NICAM		0x20
77#define MSPFORMAT_NICAM_FM	0x00|MSPFORMAT_NICAM
78#define MSPFORMAT_NICAM_AM	0x01|MSPFORMAT_NICAM
79#define MSPFORMAT_SCART		0x30
80
81/* values for MSP mode */
82#define MSPMODE_UNKNOWN		0
83/* automatic modes */
84#define MSPMODE_STEREO_AB	1
85#define MSPMODE_STEREO_A	2
86#define MSPMODE_STEREO_B	3
87/* forced modes */
88#define MSPMODE_MONO		4
89#define MSPMODE_STEREO		5
90#define MSPMODE_AB			6
91#define MSPMODE_A			7
92#define MSPMODE_B			8
93/*----------------------------------------------------------*/
94
95#define xf86_InitMSP3430	InitMSP3430
96extern _X_EXPORT void InitMSP3430(MSP3430Ptr m);
97#define xf86_DetectMSP3430	DetectMSP3430
98extern _X_EXPORT MSP3430Ptr DetectMSP3430(I2CBusPtr b, I2CSlaveAddr addr);
99#define xf86_ResetMSP3430	ResetMSP3430
100extern _X_EXPORT void ResetMSP3430(MSP3430Ptr m);
101#define xf86_MSP3430SetVolume	MSP3430SetVolume
102extern _X_EXPORT void MSP3430SetVolume (MSP3430Ptr m, CARD8 value);
103#define xf86_MSP3430SetSAP	MSP3430SetSAP
104extern _X_EXPORT void MSP3430SetSAP (MSP3430Ptr m, int mode);
105
106#define MSP3430SymbolsList \
107		"InitMSP3430", \
108		"DetectMSP3430", \
109		"ResetMSP3430", \
110		"MSP3430SetVolume", \
111		"MSP3430SetSAP"
112
113#endif
114