~ubuntu-branches/ubuntu/intrepid/xserver-xgl/intrepid

« back to all changes in this revision

Viewing changes to hw/xfree86/i2c/tda8425.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthew Garrett
  • Date: 2006-02-13 14:21:43 UTC
  • Revision ID: james.westby@ubuntu.com-20060213142143-mad6z9xzem7hzxz9
Tags: upstream-7.0.0
ImportĀ upstreamĀ versionĀ 7.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifdef HAVE_XORG_CONFIG_H
 
2
#include <xorg-config.h>
 
3
#endif
 
4
 
 
5
#include "xf86.h"
 
6
#include "xf86i2c.h"
 
7
#include "tda8425.h"
 
8
#include "i2c_def.h"
 
9
 
 
10
#define TDA8425(a,b)    { \
 
11
                data[0]=a; \
 
12
                data[1]=b; \
 
13
                I2C_WriteRead(&(t->d), data, 2, NULL, 0); \
 
14
                }
 
15
 
 
16
TDA8425Ptr Detect_tda8425(I2CBusPtr b, I2CSlaveAddr addr, Bool force)
 
17
{
 
18
  TDA8425Ptr t;
 
19
  
 
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;
 
30
  
 
31
  if(!force && !I2CProbeAddress(b, addr))
 
32
  {
 
33
     xfree(t);
 
34
     return NULL;
 
35
  }
 
36
  
 
37
  /* set default parameters */
 
38
  if(!I2CDevInit(&(t->d)))
 
39
  {
 
40
     xfree(t);
 
41
     return NULL;
 
42
  }
 
43
 
 
44
  return t;  
 
45
}
 
46
 
 
47
Bool tda8425_init(TDA8425Ptr t)
 
48
{
 
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 */
 
57
  
 
58
  tda8425_setaudio(t);
 
59
  return TRUE;
 
60
}
 
61
 
 
62
void tda8425_setaudio(TDA8425Ptr t)
 
63
{
 
64
    I2CByte data[2];
 
65
 
 
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); 
 
72
}
 
73
 
 
74
void tda8425_mute(TDA8425Ptr t, Bool mute)
 
75
{
 
76
   t->mute = mute;
 
77
   tda8425_setaudio(t);
 
78
}