[CPUFREQ] Misc cleanups in ondemand.
[linux-2.6/next.git] / drivers / media / dvb / frontends / dib3000-common.c
blob1a4f1f7c228a1e112fc0ad1c4040c6c72dab833e
1 #include "dib3000-common.h"
3 #ifdef CONFIG_DVB_DIBCOM_DEBUG
4 static int debug;
5 module_param(debug, int, 0644);
6 MODULE_PARM_DESC(debug, "set debugging level (1=info,2=i2c,4=srch (|-able)).");
7 #endif
8 #define deb_info(args...) dprintk(0x01,args)
9 #define deb_i2c(args...) dprintk(0x02,args)
10 #define deb_srch(args...) dprintk(0x04,args)
13 int dib3000_read_reg(struct dib3000_state *state, u16 reg)
15 u8 wb[] = { ((reg >> 8) | 0x80) & 0xff, reg & 0xff };
16 u8 rb[2];
17 struct i2c_msg msg[] = {
18 { .addr = state->config.demod_address, .flags = 0, .buf = wb, .len = 2 },
19 { .addr = state->config.demod_address, .flags = I2C_M_RD, .buf = rb, .len = 2 },
22 if (i2c_transfer(state->i2c, msg, 2) != 2)
23 deb_i2c("i2c read error\n");
25 deb_i2c("reading i2c bus (reg: %5d 0x%04x, val: %5d 0x%04x)\n",reg,reg,
26 (rb[0] << 8) | rb[1],(rb[0] << 8) | rb[1]);
28 return (rb[0] << 8) | rb[1];
31 int dib3000_write_reg(struct dib3000_state *state, u16 reg, u16 val)
33 u8 b[] = {
34 (reg >> 8) & 0xff, reg & 0xff,
35 (val >> 8) & 0xff, val & 0xff,
37 struct i2c_msg msg[] = {
38 { .addr = state->config.demod_address, .flags = 0, .buf = b, .len = 4 }
40 deb_i2c("writing i2c bus (reg: %5d 0x%04x, val: %5d 0x%04x)\n",reg,reg,val,val);
42 return i2c_transfer(state->i2c,msg, 1) != 1 ? -EREMOTEIO : 0;
45 int dib3000_search_status(u16 irq,u16 lock)
47 if (irq & 0x02) {
48 if (lock & 0x01) {
49 deb_srch("auto search succeeded\n");
50 return 1; // auto search succeeded
51 } else {
52 deb_srch("auto search not successful\n");
53 return 0; // auto search failed
55 } else if (irq & 0x01) {
56 deb_srch("auto search failed\n");
57 return 0; // auto search failed
59 return -1; // try again
62 /* for auto search */
63 u16 dib3000_seq[2][2][2] = /* fft,gua, inv */
64 { /* fft */
65 { /* gua */
66 { 0, 1 }, /* 0 0 { 0,1 } */
67 { 3, 9 }, /* 0 1 { 0,1 } */
70 { 2, 5 }, /* 1 0 { 0,1 } */
71 { 6, 11 }, /* 1 1 { 0,1 } */
75 MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de");
76 MODULE_DESCRIPTION("Common functions for the dib3000mb/dib3000mc dvb frontend drivers");
77 MODULE_LICENSE("GPL");
79 EXPORT_SYMBOL(dib3000_seq);
81 EXPORT_SYMBOL(dib3000_read_reg);
82 EXPORT_SYMBOL(dib3000_write_reg);
83 EXPORT_SYMBOL(dib3000_search_status);