Mercurial > pt1
annotate driver/pt1_tuner.c @ 74:b6607f6e2851
good citizens never use gray code. wise people never watch TV.
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Sat, 28 Nov 2009 00:12:05 +0900 |
parents | 28f25ec7f962 |
children | 517e61637f7b |
rev | line source |
---|---|
0 | 1 /* pt1-tuner.c: A PT1 on Tuner driver for Linux. */ |
2 | |
3 #include <linux/module.h> | |
4 #include <linux/kernel.h> | |
5 #include <linux/errno.h> | |
6 #include <linux/pci.h> | |
7 #include <linux/init.h> | |
8 #include <linux/interrupt.h> | |
9 #include <linux/mutex.h> | |
10 | |
11 #include <asm/system.h> | |
12 #include <asm/io.h> | |
13 #include <asm/irq.h> | |
14 #include <asm/uaccess.h> | |
15 | |
16 #include "pt1_com.h" | |
17 #include "pt1_pci.h" | |
18 #include "pt1_i2c.h" | |
19 #include "pt1_tuner.h" | |
20 #include "pt1_tuner_data.h" | |
21 | |
22 typedef struct _TUNER_INFO{ | |
23 int isdb_s ; | |
24 int isdb_t ; | |
25 }TUNER_INFO; | |
26 | |
27 TUNER_INFO tuner_info[2] = { | |
28 {T0_ISDB_S, T0_ISDB_T}, | |
29 {T1_ISDB_S, T1_ISDB_T} | |
30 }; | |
31 | |
32 typedef struct _isdb_t_freq_add_table{ | |
33 __u16 pos ; // Äɲ乤ë¥Á¥ã¥ó¥Í¥ë¥Ý¥¸¥·¥ç¥ó | |
34 __u16 add_freq ; // Äɲ乤ëÃÍ | |
35 }isdb_t_freq_add_table; | |
36 | |
37 isdb_t_freq_add_table isdb_t_freq_add[10] = { | |
64
98a92ce5382e
added fake support code for PT2. the PT2 part is not expected to work. be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
38 { 7, 0x8081}, // 0¡Á7Ëø |
0 | 39 { 12, 0x80A1}, // 8¡Á12Ëø |
40 { 21, 0x8062}, // 13¡Á21Ëø | |
41 { 39, 0x80A2}, // 22¡Á39Ëø | |
42 { 51, 0x80E2}, // 40¡Á51Ëø | |
43 { 59, 0x8064}, // 52¡Á59Ëø | |
44 { 75, 0x8084}, // 60¡Á75Ëø | |
45 { 84, 0x80a4}, // 76¡Á84Ëø | |
46 {100, 0x80C4}, // 85¡Á100Ëø | |
47 {112, 0x80E4} // 101¡Á112Ëø | |
48 }; | |
49 | |
64
98a92ce5382e
added fake support code for PT2. the PT2 part is not expected to work. be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
50 void settuner_reset(void __iomem *regs, int cardtype, __u32 lnb, __u32 tuner) |
0 | 51 { |
52 __u32 val = 0; | |
53 switch(lnb){ | |
64
98a92ce5382e
added fake support code for PT2. the PT2 part is not expected to work. be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
54 case LNB_11V: |
65 | 55 val = (1 << BIT_LNB_DOWN); |
56 break ; | |
64
98a92ce5382e
added fake support code for PT2. the PT2 part is not expected to work. be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
57 case LNB_15V: |
65 | 58 val = (1 << BIT_LNB_UP) | (1 << BIT_LNB_DOWN); |
59 break ; | |
0 | 60 } |
61 | |
64
98a92ce5382e
added fake support code for PT2. the PT2 part is not expected to work. be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
62 if(cardtype == PT1) { |
98a92ce5382e
added fake support code for PT2. the PT2 part is not expected to work. be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
63 switch(tuner){ |
98a92ce5382e
added fake support code for PT2. the PT2 part is not expected to work. be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
64 case TUNER_POWER_ON_RESET_ENABLE: |
98a92ce5382e
added fake support code for PT2. the PT2 part is not expected to work. be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
65 val |= (1 << BIT_TUNER); |
98a92ce5382e
added fake support code for PT2. the PT2 part is not expected to work. be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
66 break; |
98a92ce5382e
added fake support code for PT2. the PT2 part is not expected to work. be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
67 case TUNER_POWER_ON_RESET_DISABLE: |
98a92ce5382e
added fake support code for PT2. the PT2 part is not expected to work. be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
68 val |= (1 << BIT_TUNER) | (1 << BIT_RESET); |
98a92ce5382e
added fake support code for PT2. the PT2 part is not expected to work. be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
69 break ; |
98a92ce5382e
added fake support code for PT2. the PT2 part is not expected to work. be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
70 } |
0 | 71 } |
64
98a92ce5382e
added fake support code for PT2. the PT2 part is not expected to work. be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
72 else if(cardtype == PT2) { |
98a92ce5382e
added fake support code for PT2. the PT2 part is not expected to work. be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
73 switch(tuner){ |
98a92ce5382e
added fake support code for PT2. the PT2 part is not expected to work. be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
74 case TUNER_POWER_ON_RESET_ENABLE: |
69
272a8fba970b
added very rough support for PT2.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
65
diff
changeset
|
75 val |= (1 << BIT_TUNER) |
272a8fba970b
added very rough support for PT2.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
65
diff
changeset
|
76 | (1 << BIT_33A1) |
272a8fba970b
added very rough support for PT2.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
65
diff
changeset
|
77 | (1 << BIT_33A2) |
272a8fba970b
added very rough support for PT2.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
65
diff
changeset
|
78 | (1 << BIT_5A_) |
272a8fba970b
added very rough support for PT2.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
65
diff
changeset
|
79 | (1 << BIT_5A1) |
272a8fba970b
added very rough support for PT2.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
65
diff
changeset
|
80 | (1 << BIT_5A2); |
64
98a92ce5382e
added fake support code for PT2. the PT2 part is not expected to work. be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
81 break; |
98a92ce5382e
added fake support code for PT2. the PT2 part is not expected to work. be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
82 case TUNER_POWER_ON_RESET_DISABLE: |
69
272a8fba970b
added very rough support for PT2.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
65
diff
changeset
|
83 val |= (1 << BIT_TUNER) |
272a8fba970b
added very rough support for PT2.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
65
diff
changeset
|
84 | (1 << BIT_RESET) |
272a8fba970b
added very rough support for PT2.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
65
diff
changeset
|
85 | (1 << BIT_33A1) |
272a8fba970b
added very rough support for PT2.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
65
diff
changeset
|
86 | (1 << BIT_33A2) |
272a8fba970b
added very rough support for PT2.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
65
diff
changeset
|
87 | (1 << BIT_5A_) |
272a8fba970b
added very rough support for PT2.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
65
diff
changeset
|
88 | (1 << BIT_5A1) |
272a8fba970b
added very rough support for PT2.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
65
diff
changeset
|
89 | (1 << BIT_5A2); |
64
98a92ce5382e
added fake support code for PT2. the PT2 part is not expected to work. be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
90 break ; |
98a92ce5382e
added fake support code for PT2. the PT2 part is not expected to work. be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
91 } |
98a92ce5382e
added fake support code for PT2. the PT2 part is not expected to work. be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
92 } |
98a92ce5382e
added fake support code for PT2. the PT2 part is not expected to work. be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
93 writel(val, (regs + CFG_REGS_ADDR)); |
0 | 94 } |
69
272a8fba970b
added very rough support for PT2.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
65
diff
changeset
|
95 static int init_isdb_s(void __iomem *regs, int cardtype, struct mutex *lock, __u32 addr) |
0 | 96 { |
97 | |
98 WBLOCK wk; | |
99 int lp ; | |
100 __u32 val ; | |
101 | |
102 // ISDB-S/T½é´ü²½ | |
103 memcpy(&wk, &com_initdata, sizeof(WBLOCK)); | |
104 | |
105 // ½é´ü²½£±(¤Ê¤¼¤«READ¤Ê¤Î¤Ç) | |
106 memcpy(&wk, &isdb_s_init1, sizeof(WBLOCK)); | |
107 wk.addr = addr; | |
108 val = i2c_read(regs, lock, &wk, 1); | |
109 if((val & 0xff) != 0x41){ | |
110 printk(KERN_INFO "PT1:ISDB-S Read(%x)\n", val); | |
111 return -EIO ; | |
112 } | |
71
28f25ec7f962
correct number of initialization data.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
69
diff
changeset
|
113 |
28f25ec7f962
correct number of initialization data.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
69
diff
changeset
|
114 if(cardtype == PT1) { |
28f25ec7f962
correct number of initialization data.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
69
diff
changeset
|
115 for(lp = 0 ; lp < MAX_ISDB_S_INIT ; lp++){ |
69
272a8fba970b
added very rough support for PT2.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
65
diff
changeset
|
116 memcpy(&wk, isdb_s_initial_pt1[lp], sizeof(WBLOCK)); |
71
28f25ec7f962
correct number of initialization data.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
69
diff
changeset
|
117 wk.addr = addr; |
28f25ec7f962
correct number of initialization data.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
69
diff
changeset
|
118 i2c_write(regs, lock, &wk); |
28f25ec7f962
correct number of initialization data.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
69
diff
changeset
|
119 } |
28f25ec7f962
correct number of initialization data.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
69
diff
changeset
|
120 } |
28f25ec7f962
correct number of initialization data.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
69
diff
changeset
|
121 else if(cardtype == PT2) { |
28f25ec7f962
correct number of initialization data.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
69
diff
changeset
|
122 for(lp = 0 ; lp < MAX_ISDB_S_INIT2 ; lp++){ |
69
272a8fba970b
added very rough support for PT2.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
65
diff
changeset
|
123 memcpy(&wk, isdb_s_initial_pt2[lp], sizeof(WBLOCK)); |
71
28f25ec7f962
correct number of initialization data.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
69
diff
changeset
|
124 wk.addr = addr; |
28f25ec7f962
correct number of initialization data.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
69
diff
changeset
|
125 i2c_write(regs, lock, &wk); |
28f25ec7f962
correct number of initialization data.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
69
diff
changeset
|
126 } |
0 | 127 } |
128 | |
129 return 0 ; | |
130 } | |
69
272a8fba970b
added very rough support for PT2.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
65
diff
changeset
|
131 static void init_isdb_t(void __iomem *regs, int cardtype, struct mutex *lock, __u32 addr) |
0 | 132 { |
133 int lp ; | |
134 WBLOCK wk; | |
135 | |
136 // ISDB-S/T½é´ü²½ | |
71
28f25ec7f962
correct number of initialization data.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
69
diff
changeset
|
137 if(cardtype == PT1) { |
28f25ec7f962
correct number of initialization data.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
69
diff
changeset
|
138 for(lp = 0 ; lp < MAX_ISDB_T_INIT ; lp++){ |
69
272a8fba970b
added very rough support for PT2.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
65
diff
changeset
|
139 memcpy(&wk, isdb_t_initial_pt1[lp], sizeof(WBLOCK)); |
71
28f25ec7f962
correct number of initialization data.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
69
diff
changeset
|
140 wk.addr = addr; |
28f25ec7f962
correct number of initialization data.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
69
diff
changeset
|
141 i2c_write(regs, lock, &wk); |
28f25ec7f962
correct number of initialization data.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
69
diff
changeset
|
142 } |
28f25ec7f962
correct number of initialization data.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
69
diff
changeset
|
143 } |
28f25ec7f962
correct number of initialization data.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
69
diff
changeset
|
144 else if(cardtype == PT2) { |
28f25ec7f962
correct number of initialization data.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
69
diff
changeset
|
145 for(lp = 0 ; lp < MAX_ISDB_T_INIT2 ; lp++){ |
69
272a8fba970b
added very rough support for PT2.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
65
diff
changeset
|
146 memcpy(&wk, isdb_t_initial_pt2[lp], sizeof(WBLOCK)); |
71
28f25ec7f962
correct number of initialization data.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
69
diff
changeset
|
147 wk.addr = addr; |
28f25ec7f962
correct number of initialization data.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
69
diff
changeset
|
148 i2c_write(regs, lock, &wk); |
28f25ec7f962
correct number of initialization data.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
69
diff
changeset
|
149 } |
0 | 150 } |
71
28f25ec7f962
correct number of initialization data.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
69
diff
changeset
|
151 } |
0 | 152 |
69
272a8fba970b
added very rough support for PT2.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
65
diff
changeset
|
153 int tuner_init(void __iomem *regs, int cardtype, struct mutex *lock, int tuner_no) |
0 | 154 { |
155 | |
156 int rc ; | |
157 WBLOCK wk; | |
158 | |
159 // ISDB-S/T½é´ü²½ | |
160 memcpy(&wk, &com_initdata, sizeof(WBLOCK)); | |
161 | |
162 // ½é´ü²½(¶¦ÄÌ) | |
163 wk.addr = tuner_info[tuner_no].isdb_t ; | |
164 i2c_write(regs, lock, &wk); | |
165 wk.addr = tuner_info[tuner_no].isdb_s ; | |
166 i2c_write(regs, lock, &wk); | |
167 | |
69
272a8fba970b
added very rough support for PT2.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
65
diff
changeset
|
168 rc = init_isdb_s(regs, cardtype, lock, tuner_info[tuner_no].isdb_s); |
0 | 169 if(rc < 0){ |
170 return rc ; | |
171 } | |
69
272a8fba970b
added very rough support for PT2.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
65
diff
changeset
|
172 init_isdb_t(regs, cardtype, lock, tuner_info[tuner_no].isdb_t); |
0 | 173 |
174 memcpy(&wk, &isdb_s_init21, sizeof(WBLOCK)); | |
175 wk.addr = tuner_info[tuner_no].isdb_s ; | |
176 i2c_write(regs, lock, &wk); | |
177 | |
178 memcpy(&wk, &isdb_t_init17, sizeof(WBLOCK)); | |
179 wk.addr = tuner_info[tuner_no].isdb_t ; | |
180 i2c_write(regs, lock, &wk); | |
181 | |
182 return 0 ; | |
183 } | |
184 void set_sleepmode(void __iomem *regs, struct mutex *lock, int address, int tuner_type, int type) | |
185 { | |
186 WBLOCK wk; | |
187 | |
188 if(type == TYPE_WAKEUP){ | |
189 switch(tuner_type){ | |
64
98a92ce5382e
added fake support code for PT2. the PT2 part is not expected to work. be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
190 case CHANNEL_TYPE_ISDB_S: |
98a92ce5382e
added fake support code for PT2. the PT2 part is not expected to work. be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
191 memcpy(&wk, &isdb_s_wake, sizeof(WBLOCK)); |
98a92ce5382e
added fake support code for PT2. the PT2 part is not expected to work. be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
192 break ; |
98a92ce5382e
added fake support code for PT2. the PT2 part is not expected to work. be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
193 case CHANNEL_TYPE_ISDB_T: |
98a92ce5382e
added fake support code for PT2. the PT2 part is not expected to work. be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
194 memcpy(&wk, &isdb_t_wake, sizeof(WBLOCK)); |
98a92ce5382e
added fake support code for PT2. the PT2 part is not expected to work. be careful!
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
195 break ; |
0 | 196 } |
197 wk.addr = address ; | |
198 i2c_write(regs, lock, &wk); | |
199 } | |
200 switch(tuner_type){ | |
201 case CHANNEL_TYPE_ISDB_S: | |
202 printk(KERN_INFO "PT1:ISDB-S Sleep\n"); | |
203 memcpy(&wk, &isdb_s_sleep, sizeof(WBLOCK)); | |
204 if(type == TYPE_WAKEUP){ | |
205 wk.value[1] = 0x01 ; | |
206 } | |
207 break ; | |
208 case CHANNEL_TYPE_ISDB_T: | |
209 printk(KERN_INFO "PT1:ISDB-T Sleep\n"); | |
210 memcpy(&wk, &isdb_t_sleep, sizeof(WBLOCK)); | |
211 if(type == TYPE_WAKEUP){ | |
212 wk.value[1] = 0x90 ; | |
213 } | |
214 break ; | |
215 } | |
216 wk.addr = address; | |
217 i2c_write(regs, lock, &wk); | |
218 } | |
219 | |
220 int bs_frequency(void __iomem *regs, struct mutex *lock, int addr, int channel) | |
221 { | |
222 int lp ; | |
223 int tmcclock = FALSE ; | |
224 WBLOCK wk; | |
225 __u32 val ; | |
226 | |
227 if(channel >= MAX_BS_CHANNEL){ | |
228 return -EIO ; | |
229 } | |
230 // ISDB-S PLL¥í¥Ã¥¯ | |
231 for(lp = 0 ; lp < MAX_BS_CHANNEL_PLL_COMMAND ; lp++){ | |
232 memcpy(&wk, bs_pll[channel].wblock[lp], sizeof(WBLOCK)); | |
233 wk.addr = addr ; | |
234 i2c_write(regs, lock, &wk); | |
235 } | |
236 | |
237 // PLL¥í¥Ã¥¯³Îǧ | |
238 // ¥Á¥§¥Ã¥¯ÍÑ | |
239 for(lp = 0 ; lp < 200 ; lp++){ | |
240 memcpy(&wk, &bs_pll_lock, sizeof(WBLOCK)); | |
241 wk.addr = addr; | |
242 val = i2c_read(regs, lock, &wk, 1); | |
243 if(((val & 0xFF) != 0) && ((val & 0XFF) != 0XFF)){ | |
244 tmcclock = TRUE ; | |
245 break ; | |
246 } | |
247 } | |
248 | |
249 if(tmcclock == FALSE){ | |
250 printk(KERN_INFO "PLL LOCK ERROR\n"); | |
251 return -EIO; | |
252 } | |
253 | |
254 memcpy(&wk, &bs_tmcc_get_1, sizeof(WBLOCK)); | |
255 wk.addr = addr; | |
256 i2c_write(regs, lock, &wk); | |
257 | |
258 tmcclock = FALSE ; | |
259 | |
260 for(lp = 0 ; lp < 200 ; lp++){ | |
261 memcpy(&wk, &bs_tmcc_get_2, sizeof(WBLOCK)); | |
262 wk.addr = addr; | |
263 | |
264 val = i2c_read(regs, lock, &wk, 1); | |
265 if(((val & 0XFF) != 0XFF) && (!(val & 0x10))){ | |
266 tmcclock = TRUE ; | |
267 break ; | |
268 } | |
269 } | |
270 | |
271 if(tmcclock == FALSE){ | |
272 printk(KERN_INFO "TMCC LOCK ERROR\n"); | |
273 return -EIO; | |
274 } | |
275 | |
276 return 0 ; | |
277 } | |
278 int ts_lock(void __iomem *regs, struct mutex *lock, int addr, __u16 ts_id) | |
279 { | |
280 | |
281 int lp ; | |
282 WBLOCK wk; | |
283 __u32 val ; | |
284 union{ | |
285 __u8 ts[2]; | |
286 __u16 tsid; | |
287 }uts_id ; | |
288 | |
289 uts_id.tsid = ts_id ; | |
290 memcpy(&wk, &bs_set_ts_lock, sizeof(WBLOCK)); | |
291 wk.addr = addr; | |
292 // TS-IDÀßÄê | |
293 wk.value[1] = uts_id.ts[1]; | |
294 wk.value[2] = uts_id.ts[0]; | |
295 i2c_write(regs, lock, &wk); | |
296 | |
297 for(lp = 0 ; lp < 100 ; lp++){ | |
298 memcpy(&wk, &bs_get_ts_lock, sizeof(WBLOCK)); | |
299 wk.addr = addr; | |
300 val = i2c_read(regs, lock, &wk, 2); | |
301 if((val & 0xFFFF) == ts_id){ | |
302 return 0 ; | |
303 } | |
304 } | |
305 printk(KERN_INFO "PT1:ERROR TS-LOCK(%x)\n", ts_id); | |
306 return -EIO ; | |
307 } | |
308 int bs_tune(void __iomem *regs, struct mutex *lock, int addr, int channel, ISDB_S_TMCC *tmcc) | |
309 { | |
310 | |
311 int lp ; | |
312 int lp2; | |
313 WBLOCK wk; | |
314 __u32 val ; | |
315 ISDB_S_TS_ID *tsid ; | |
316 union{ | |
317 __u8 slot[4]; | |
318 __u32 u32slot; | |
319 }ts_slot ; | |
320 union{ | |
321 __u16 ts[2]; | |
322 __u32 tsid; | |
323 }ts_id ; | |
324 | |
325 if(channel >= MAX_BS_CHANNEL){ | |
326 printk(KERN_INFO "Invalid Channel(%d)\n", channel); | |
327 return -EIO ; | |
328 } | |
329 val = bs_frequency(regs, lock, addr, channel); | |
330 if(val == -EIO){ | |
331 return val ; | |
332 } | |
333 | |
334 tsid = &tmcc->ts_id[0] ; | |
335 // ³ºÅö¼þÇÈ¿ô¤ÎTS-ID¤ò¼èÆÀ | |
336 for(lp = 0 ; lp < (MAX_BS_TS_ID / 2) ; lp++){ | |
337 for(lp2 = 0 ; lp2 < 100 ; lp2++){ | |
338 memcpy(&wk, bs_get_ts_id[lp], sizeof(WBLOCK)); | |
339 wk.addr = addr; | |
340 ts_id.tsid = i2c_read(regs, lock, &wk, 4); | |
341 // TS-ID¤¬0¤Î¾ì¹ç¤ÏºÆ¼èÆÀ¤¹¤ë | |
342 if((ts_id.ts[0] != 0) && (ts_id.ts[1] != 0)){ | |
343 break ; | |
344 } | |
345 } | |
346 tsid->ts_id = ts_id.ts[1] ; | |
347 tsid += 1; | |
348 tsid->ts_id = ts_id.ts[0] ; | |
349 tsid += 1; | |
350 } | |
351 | |
352 memcpy(&wk, &bs_get_agc, sizeof(WBLOCK)); | |
353 wk.addr = addr; | |
354 tmcc->agc = i2c_read(regs, lock, &wk, 1); | |
355 | |
356 // TS-IDÊ̤ξðÊó¤ò¼èÆÀ | |
357 tsid = &tmcc->ts_id[0] ; | |
358 for(lp = 0 ; lp < MAX_BS_TS_ID ; lp++, tsid += 1){ | |
359 // TS-ID¤Ê¤·=0XFFFF | |
360 if(tsid->ts_id == 0xFFFF){ | |
361 continue ; | |
362 } | |
363 ts_lock(regs, lock, addr, tsid->ts_id); | |
364 | |
365 //¥¹¥í¥Ã¥È¼èÆÀ | |
366 memcpy(&wk, &bs_get_slot, sizeof(WBLOCK)); | |
367 wk.addr = addr; | |
368 ts_slot.u32slot = i2c_read(regs, lock, &wk, 3); | |
369 tsid->high_mode = 0; | |
370 tsid->low_slot = ts_slot.slot[0] ; | |
371 tsid->high_slot = ts_slot.slot[1] ; | |
372 tsid->low_mode = ts_slot.slot[2] ; | |
373 } | |
374 | |
375 memcpy(&wk, &bs_get_clock, sizeof(WBLOCK)); | |
376 wk.addr = addr; | |
377 tmcc->clockmargin = i2c_read(regs, lock, &wk, 1); | |
378 | |
379 memcpy(&wk, &bs_get_carrir, sizeof(WBLOCK)); | |
380 wk.addr = addr; | |
381 tmcc->carriermargin = i2c_read(regs, lock, &wk, 1); | |
382 return 0 ; | |
383 } | |
9
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
384 int isdb_s_read_signal_strength(void __iomem *regs, struct mutex *lock, int addr) |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
385 { |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
386 WBLOCK wk; |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
387 __u32 val ; |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
388 __u32 val2; |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
389 int val3 ; |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
390 |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
391 memcpy(&wk, &bs_get_signal1, sizeof(WBLOCK)); |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
392 wk.addr = addr; |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
393 val = i2c_read(regs, lock, &wk, 1); |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
394 |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
395 memcpy(&wk, &bs_get_signal2, sizeof(WBLOCK)); |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
396 wk.addr = addr; |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
397 val2 = i2c_read(regs, lock, &wk, 1); |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
398 val3 = (((val << 8) & 0XFF00) | (val2 & 0XFF)); |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
399 |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
400 return val3 ; |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
401 } |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
402 |
0 | 403 __u32 getfrequency_add(__u32 channel) |
404 { | |
405 int lp ; | |
406 | |
407 for(lp = 0 ; lp < 10 ; lp++){ | |
408 if(channel <= isdb_t_freq_add[lp].pos){ | |
409 return isdb_t_freq_add[lp].add_freq ; | |
410 } | |
411 } | |
412 return 0 ; | |
413 } | |
414 __u32 getfrequency(__u32 channel, int addfreq) | |
415 { | |
416 __u32 frequencyoffset = 0; | |
417 __u32 frequencyOffset = 0; | |
418 | |
419 if (12 <= channel){ | |
420 frequencyoffset += 2; | |
421 }else if (17 <= channel){ | |
422 frequencyoffset = 0; | |
423 }else if (63 <= channel){ | |
424 frequencyoffset += 2; | |
425 } | |
426 #if 0 | |
427 return (((93 + channel * 6 + frequencyOffset) + addfreq) * 7) + 400; | |
428 #endif | |
429 frequencyOffset = 93 + channel * 6 + frequencyoffset; | |
430 frequencyOffset = 7 * (frequencyOffset + addfreq); | |
431 return frequencyOffset + 400; | |
432 | |
433 } | |
434 int isdb_t_frequency(void __iomem *regs, struct mutex *lock, int addr, int channel, int addfreq) | |
435 { | |
436 | |
437 int lp ; | |
438 WBLOCK wk; | |
439 __u32 val ; | |
440 int tmcclock = FALSE ; | |
441 union{ | |
442 __u8 charfreq[2]; | |
443 __u16 freq; | |
444 }freq[2] ; | |
445 | |
446 if(channel >= MAX_ISDB_T_CHANNEL){ | |
447 return -EIO ; | |
448 } | |
449 | |
450 freq[0].freq = getfrequency(channel, addfreq); | |
451 freq[1].freq = getfrequency_add(channel); | |
452 //»ØÄê¼þÇÈ¿ô | |
453 memcpy(&wk, &isdb_t_pll_base, sizeof(WBLOCK)); | |
454 wk.addr = addr ; | |
455 // ·×»»¤·¤¿¼þÇÈ¿ô¤òÀßÄê | |
456 wk.value[wk.count] = freq[0].charfreq[1]; | |
457 wk.count += 1 ; | |
458 wk.value[wk.count] = freq[0].charfreq[0]; | |
459 wk.count += 1 ; | |
460 | |
461 // ·×»»¤·¤¿¼þÇÈ¿ôÉղþðÊó¤òÀßÄê | |
462 wk.value[wk.count] = freq[1].charfreq[1]; | |
463 wk.count += 1 ; | |
464 wk.value[wk.count] = freq[1].charfreq[0]; | |
465 wk.count += 1 ; | |
466 | |
467 i2c_write(regs, lock, &wk); | |
468 | |
469 for(lp = 0 ; lp < 100 ; lp++){ | |
470 memcpy(&wk, &isdb_t_pll_lock, sizeof(WBLOCK)); | |
471 wk.addr = addr; | |
472 val = i2c_read(regs, lock, &wk, 1); | |
473 if(((val & 0xFF) != 0XFF) && ((val & 0X50) == 0x50)){ | |
474 tmcclock = TRUE ; | |
475 break ; | |
476 } | |
477 } | |
478 if(tmcclock != TRUE){ | |
479 printk(KERN_INFO "PT1:ISDB-T LOCK NG(%08x)\n", val); | |
480 return -EIO ; | |
481 } | |
482 | |
483 memcpy(&wk, &isdb_t_check_tune, sizeof(WBLOCK)); | |
484 wk.addr = addr ; | |
485 i2c_write(regs, lock, &wk); | |
486 | |
487 tmcclock = FALSE ; | |
488 for(lp = 0 ; lp < 1000 ; lp++){ | |
489 memcpy(&wk, &isdb_t_tune_read, sizeof(WBLOCK)); | |
490 wk.addr = addr; | |
491 val = i2c_read(regs, lock, &wk, 1); | |
492 if(((val & 0xFF) != 0XFF) && ((val & 0X8) != 8)){ | |
493 tmcclock = TRUE ; | |
494 break ; | |
495 } | |
496 } | |
497 if(tmcclock != TRUE){ | |
498 return -EIO ; | |
499 } | |
500 return 0 ; | |
501 } | |
9
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
502 int isdb_t_read_signal_strength(void __iomem *regs, struct mutex *lock, int addr) |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
503 { |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
504 __u32 val ; |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
505 __u32 val2; |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
506 __u32 val3; |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
507 WBLOCK wk; |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
508 |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
509 memcpy(&wk, &isdb_t_signal1, sizeof(WBLOCK)); |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
510 wk.addr = addr; |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
511 val = i2c_read(regs, lock, &wk, 1); |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
512 printk(KERN_INFO "CN(1)Val(%x)\n", val); |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
513 |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
514 memcpy(&wk, &isdb_t_signal2, sizeof(WBLOCK)); |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
515 wk.addr = addr; |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
516 val2 = i2c_read(regs, lock, &wk, 1); |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
517 val3 = (((val << 8) & 0XFF00) | (val2 & 0XFF)); |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
518 return val3 ; |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
519 } |
0 | 520 #if 0 |
521 int isdb_t_tune(void __iomem *regs, struct mutex *lock, int addr, int channel, ISDB_T_TMCC *tmcc) | |
522 { | |
523 | |
524 int lp ; | |
525 int rc ; | |
526 int lp2 ; | |
527 WBLOCK wk; | |
528 __u32 val ; | |
529 | |
530 printk(KERN_INFO "Channel(%d) Start\n", channel); | |
531 if(channel >= MAX_ISDB_T_CHANNEL){ | |
532 return -EIO ; | |
533 } | |
534 rc = isdb_t_frequency(regs, lock, addr, channel); | |
535 if(rc < 0){ | |
536 return -EIO ; | |
537 } | |
538 for(lp = 0 ; lp < 100 ; lp++){ | |
539 memcpy(&wk, &isdb_t_tmcc_read_1, sizeof(WBLOCK)); | |
540 wk.addr = addr; | |
541 val = i2c_read(regs, lock, &wk, 4); | |
542 if((val & 0xFF) != 0){ | |
543 break ; | |
544 } | |
545 } | |
546 printk(KERN_INFO "TMCC(1)Val(%x)\n", val); | |
547 | |
548 for(lp = 0 ; lp < 100 ; lp++){ | |
549 memcpy(&wk, &isdb_t_tmcc_read_2, sizeof(WBLOCK)); | |
550 wk.addr = addr; | |
551 val = i2c_read(regs, lock, &wk, 4); | |
552 if((val & 0xFF) != 0){ | |
553 break ; | |
554 } | |
555 } | |
556 printk(KERN_INFO "TMCC(2)Val(%x)\n", val); | |
557 | |
558 memcpy(&wk, &isdb_t_cn_1, sizeof(WBLOCK)); | |
559 wk.addr = addr; | |
560 val = i2c_read(regs, lock, &wk, 1); | |
561 printk(KERN_INFO "CN(1)Val(%x)\n", val); | |
562 | |
563 memcpy(&wk, &isdb_t_cn_2, sizeof(WBLOCK)); | |
564 wk.addr = addr; | |
565 val = i2c_read(regs, lock, &wk, 1); | |
566 printk(KERN_INFO "CN(2)Val(%x)\n", val); | |
567 | |
568 memcpy(&wk, &isdb_t_agc_1, sizeof(WBLOCK)); | |
569 wk.addr = addr; | |
570 val = i2c_read(regs, lock, &wk, 1); | |
571 printk(KERN_INFO "AGC(1)Val(%x)\n", val); | |
572 | |
573 memcpy(&wk, &isdb_t_agc_2, sizeof(WBLOCK)); | |
574 wk.addr = addr; | |
575 val = i2c_read(regs, lock, &wk, 1); | |
576 printk(KERN_INFO "AGC(2)Val(%x)\n", val); | |
577 return 0; | |
578 } | |
579 #endif |