Initial commit
[xorg_rtime.git] / xorg-server-1.4 / hw / xfree86 / i2c / tda8425.c
blob7631a08630de21f6cc2e17d97b4b6b7379875dc4
1 #ifdef HAVE_XORG_CONFIG_H
2 #include <xorg-config.h>
3 #endif
5 #include "xf86.h"
6 #include "xf86i2c.h"
7 #include "tda8425.h"
8 #include "i2c_def.h"
10 #define TDA8425(a,b) { \
11 data[0]=a; \
12 data[1]=b; \
13 I2C_WriteRead(&(t->d), data, 2, NULL, 0); \
16 TDA8425Ptr Detect_tda8425(I2CBusPtr b, I2CSlaveAddr addr, Bool force)
18 TDA8425Ptr t;
20 t = xcalloc(1, sizeof(TDA8425Rec));
21 if(t == NULL) return NULL;
22 t->d.DevName = "TDA8425 BTSC Stereo Audio Processor";
23 t->d.SlaveAddr = addr;
24 t->d.pI2CBus = b;
25 t->d.NextDev = NULL;
26 t->d.StartTimeout = b->StartTimeout;
27 t->d.BitTimeout = b->BitTimeout;
28 t->d.AcknTimeout = b->AcknTimeout;
29 t->d.ByteTimeout = b->ByteTimeout;
31 if(!force && !I2CProbeAddress(b, addr))
33 xfree(t);
34 return NULL;
37 /* set default parameters */
38 if(!I2CDevInit(&(t->d)))
40 xfree(t);
41 return NULL;
44 return t;
47 Bool tda8425_init(TDA8425Ptr t)
49 t->stereo = 3; /* 3 = Spacial 2 = Linear 1 = Pseudo 0 = Forced mono */
50 t->v_left = 0xFF; /* FF - C0 */
51 t->v_right = 0xFF; /* FF - C0 */
52 t->bass = 0xF6; /* 0xFF - 0xF0 */
53 t->treble = 0xF6; /* 0xFF - 0xF0 */
54 t->src_sel = 3; /* 3 - stereo */
55 t->mute = TRUE;
56 t->mux = 0; /* 0 - source one, 1 -source 2 */
58 tda8425_setaudio(t);
59 return TRUE;
62 void tda8425_setaudio(TDA8425Ptr t)
64 I2CByte data[2];
66 TDA8425(0x00, t->v_left );
67 TDA8425(0x01, t->v_right );
68 TDA8425(0x02, t->bass );
69 TDA8425(0x03, t->treble );
70 TDA8425(0x08, 0xC0 | (t->mute ? 0x20 : 0x0) | (t->stereo << 3) | (t->src_sel << 1) |
71 t->mux);
74 void tda8425_mute(TDA8425Ptr t, Bool mute)
76 t->mute = mute;
77 tda8425_setaudio(t);