This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / drivers / media / dvb / frontends / dib3000-common.h
1 /*
2  * .h-files for the common use of the frontend drivers made by DiBcom
3  * DiBcom 3000-MB/MC/P
4  *
5  * DiBcom (http://www.dibcom.fr/)
6  *
7  * Copyright (C) 2004 Patrick Boettcher (patrick.boettcher@desy.de)
8  *
9  * based on GPL code from DibCom, which has
10  *
11  * Copyright (C) 2004 Amaury Demol for DiBcom (ademol@dibcom.fr)
12  *
13  *      This program is free software; you can redistribute it and/or
14  *      modify it under the terms of the GNU General Public License as
15  *      published by the Free Software Foundation, version 2.
16  *
17  * Acknowledgements
18  *
19  *  Amaury Demol (ademol@dibcom.fr) from DiBcom for providing specs and driver
20  *  sources, on which this driver (and the dvb-dibusb) are based.
21  *
22  * see Documentation/dvb/README.dibusb for more information
23  *
24  */
25
26 #ifndef DIB3000_COMMON_H
27 #define DIB3000_COMMON_H
28
29 #include "dvb_frontend.h"
30 #include "dib3000.h"
31
32 /* info and err, taken from usb.h, if there is anything available like by default,
33  * please change !
34  */
35 #define err(format, arg...) printk(KERN_ERR "%s: " format "\n" , __FILE__ , ## arg)
36 #define info(format, arg...) printk(KERN_INFO "%s: " format "\n" , __FILE__ , ## arg)
37 #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n" , __FILE__ , ## arg)
38
39 /* a PID for the pid_filter list, when in use */
40 struct dib3000_pid
41 {
42         u16 pid;
43         int active;
44 };
45
46 /* frontend state */
47 struct dib3000_state {
48         struct i2c_adapter* i2c;
49
50         struct dvb_frontend_ops ops;
51
52 /* configuration settings */
53         struct dib3000_config config;
54
55         spinlock_t pid_list_lock;
56         struct dib3000_pid *pid_list;
57
58         int feedcount;
59
60         struct dvb_frontend frontend;
61         int timing_offset;
62         int timing_offset_comp_done;
63 };
64
65 /* commonly used methods by the dib3000mb/mc/p frontend */
66 extern int dib3000_read_reg(struct dib3000_state *state, u16 reg);
67 extern int dib3000_write_reg(struct dib3000_state *state, u16 reg, u16 val);
68
69 extern int dib3000_init_pid_list(struct dib3000_state *state, int num);
70 extern void dib3000_dealloc_pid_list(struct dib3000_state *state);
71 extern int dib3000_get_pid_index(struct dib3000_pid pid_list[], int num_pids,
72         int pid, spinlock_t *pid_list_lock,int onoff);
73
74 extern int dib3000_search_status(u16 irq,u16 lock);
75
76 /* handy shortcuts */
77 #define rd(reg) dib3000_read_reg(state,reg)
78
79 #define wr(reg,val) if (dib3000_write_reg(state,reg,val)) \
80         { err("while sending 0x%04x to 0x%04x.",val,reg); return -EREMOTEIO; }
81
82 #define wr_foreach(a,v) { int i; \
83         if (sizeof(a) != sizeof(v)) \
84                 err("sizeof: %d %d is different",sizeof(a),sizeof(v));\
85         for (i=0; i < sizeof(a)/sizeof(u16); i++) \
86                 wr(a[i],v[i]); \
87         }
88
89 #define set_or(reg,val) wr(reg,rd(reg) | val)
90
91 #define set_and(reg,val) wr(reg,rd(reg) & val)
92
93
94 /* debug */
95
96 #ifdef CONFIG_DVB_DIBCOM_DEBUG
97 #define dprintk(level,args...) \
98     do { if ((debug & level)) { printk(args); } } while (0)
99 #else
100 #define dprintk(args...) do { } while (0)
101 #endif
102
103 /* mask for enabling a specific pid for the pid_filter */
104 #define DIB3000_ACTIVATE_PID_FILTERING  (0x2000)
105
106 /* common values for tuning */
107 #define DIB3000_ALPHA_0                                 (     0)
108 #define DIB3000_ALPHA_1                                 (     1)
109 #define DIB3000_ALPHA_2                                 (     2)
110 #define DIB3000_ALPHA_4                                 (     4)
111
112 #define DIB3000_CONSTELLATION_QPSK              (     0)
113 #define DIB3000_CONSTELLATION_16QAM             (     1)
114 #define DIB3000_CONSTELLATION_64QAM             (     2)
115
116 #define DIB3000_GUARD_TIME_1_32                 (     0)
117 #define DIB3000_GUARD_TIME_1_16                 (     1)
118 #define DIB3000_GUARD_TIME_1_8                  (     2)
119 #define DIB3000_GUARD_TIME_1_4                  (     3)
120
121 #define DIB3000_TRANSMISSION_MODE_2K    (     0)
122 #define DIB3000_TRANSMISSION_MODE_8K    (     1)
123
124 #define DIB3000_SELECT_LP                               (     0)
125 #define DIB3000_SELECT_HP                               (     1)
126
127 #define DIB3000_FEC_1_2                                 (     1)
128 #define DIB3000_FEC_2_3                                 (     2)
129 #define DIB3000_FEC_3_4                                 (     3)
130 #define DIB3000_FEC_5_6                                 (     5)
131 #define DIB3000_FEC_7_8                                 (     7)
132
133 #define DIB3000_HRCH_OFF                                (     0)
134 #define DIB3000_HRCH_ON                                 (     1)
135
136 #define DIB3000_DDS_INVERSION_OFF               (     0)
137 #define DIB3000_DDS_INVERSION_ON                (     1)
138
139 #define DIB3000_TUNER_WRITE_ENABLE(a)   (0xffff & (a << 7))
140 #define DIB3000_TUNER_WRITE_DISABLE(a)  (0xffff & ((a << 7) | (1 << 7)))
141
142 /* for auto search */
143 extern u16 dib3000_seq[2][2][2];
144
145 #define DIB3000_REG_MANUFACTOR_ID               (  1025)
146 #define DIB3000_I2C_ID_DIBCOM                   (0x01b3)
147
148 #define DIB3000_REG_DEVICE_ID                   (  1026)
149 #define DIB3000MB_DEVICE_ID                             (0x3000)
150 #define DIB3000MC_DEVICE_ID                             (0x3001)
151 #define DIB3000P_DEVICE_ID                              (0x3002)
152
153 #endif // DIB3000_COMMON_H