Mercurial > pt1
annotate driver/pt1_pci.c @ 36:65c8ac567074
cleaning up:
- eliminate warnings
- remove dangling white spaces
- changed new line code in Makefile from CR+LF to LF
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Fri, 13 Mar 2009 14:32:44 +0900 |
parents | 289794dc265f |
children | c359e7adf700 |
rev | line source |
---|---|
0 | 1 /* pt1-pci.c: A PT1 on PCI bus driver for Linux. */ |
2 #define DRV_NAME "pt1-pci" | |
3 #define DRV_VERSION "1.00" | |
4 #define DRV_RELDATE "11/28/2008" | |
5 | |
6 | |
7 #include <linux/module.h> | |
8 #include <linux/kernel.h> | |
9 #include <linux/errno.h> | |
10 #include <linux/pci.h> | |
11 #include <linux/init.h> | |
12 #include <linux/interrupt.h> | |
13 | |
14 #include <asm/system.h> | |
15 #include <asm/io.h> | |
16 #include <asm/irq.h> | |
17 #include <asm/uaccess.h> | |
18 #include <linux/version.h> | |
19 #include <linux/mutex.h> | |
36 | 20 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23) |
0 | 21 #include <linux/freezer.h> |
22 #else | |
23 #define set_freezable() | |
36 | 24 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11) |
0 | 25 typedef struct pm_message { |
26 int event; | |
27 } pm_message_t; | |
28 #endif | |
29 #endif | |
30 #include <linux/kthread.h> | |
31 #include <linux/dma-mapping.h> | |
32 | |
33 #include <linux/fs.h> | |
34 #include <linux/cdev.h> | |
35 | |
36 #include <linux/ioctl.h> | |
37 | |
38 #include "pt1_com.h" | |
39 #include "pt1_pci.h" | |
40 #include "pt1_tuner.h" | |
41 #include "pt1_i2c.h" | |
42 #include "pt1_tuner_data.h" | |
43 #include "pt1_ioctl.h" | |
44 | |
45 /* These identify the driver base version and may not be removed. */ | |
46 static char version[] __devinitdata = | |
47 KERN_INFO DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " \n"; | |
48 | |
49 MODULE_AUTHOR("Tomoaki Ishikawa tomy@users.sourceforge.jp"); | |
50 #define DRIVER_DESC "PCI earthsoft PT1 driver" | |
51 MODULE_DESCRIPTION(DRIVER_DESC); | |
52 MODULE_LICENSE("GPL"); | |
53 | |
31
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
54 static int debug = 7; /* 1 normal messages, 0 quiet .. 7 verbose. */ |
0 | 55 static int lnb = 0; /* LNB OFF:0 +11V:1 +15V:2 */ |
56 | |
57 module_param(debug, int, 0); | |
58 module_param(lnb, int, 0); | |
59 MODULE_PARM_DESC(debug, "debug level (1-2)"); | |
60 MODULE_PARM_DESC(debug, "LNB level (0:OFF 1:+11V 2:+15V)"); | |
61 | |
62 static struct pci_device_id pt1_pci_tbl[] = { | |
63 { 0x10ee, 0x211a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, | |
64 { 0, } | |
65 }; | |
66 MODULE_DEVICE_TABLE(pci, pt1_pci_tbl); | |
67 #define DEV_NAME "pt1video" | |
68 | |
69 #define MAX_READ_BLOCK 4 // 1度に読み出す最大DMAバッファ数 | |
9
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
70 #define MAX_PCI_DEVICE 128 // 最大64枚 |
0 | 71 #define DMA_SIZE 4096 // DMAバッファサイズ |
36 | 72 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22) |
9
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
73 #define DMA_RING_SIZE 128 // RINGサイズ |
0 | 74 #define DMA_RING_MAX 511 // 1RINGにいくつ詰めるか(1023はNGで511まで) |
9
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
75 #define CHANEL_DMA_SIZE (2*1024*1024) // 地デジ用(16Mbps) |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
76 #define BS_CHANEL_DMA_SIZE (4*1024*1024) // BS用(32Mbps) |
0 | 77 #else |
78 #define DMA_RING_SIZE 28 // RINGサイズ | |
79 #define DMA_RING_MAX 511 // 1RINGにいくつ詰めるか(1023はNGで511まで) | |
80 #define CHANEL_DMA_SIZE (1*128*1024) // 地デジ用(16Mbps) | |
81 #define BS_CHANEL_DMA_SIZE (1*128*1024) // BS用(32Mbps) | |
82 #endif | |
83 | |
84 typedef struct _DMA_CONTROL{ | |
85 dma_addr_t ring_dma[DMA_RING_MAX] ; // DMA情報 | |
86 __u32 *data[DMA_RING_MAX]; | |
87 }DMA_CONTROL; | |
88 | |
89 typedef struct _PT1_CHANNEL PT1_CHANNEL; | |
90 | |
91 typedef struct _pt1_device{ | |
92 unsigned long mmio_start ; | |
93 __u32 mmio_len ; | |
94 void __iomem *regs; | |
95 struct mutex lock ; | |
96 dma_addr_t ring_dma[DMA_RING_SIZE] ; // DMA情報 | |
97 void *dmaptr[DMA_RING_SIZE] ; | |
98 struct task_struct *kthread; | |
99 dev_t dev ; | |
31
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
100 int card_number; |
0 | 101 __u32 base_minor ; |
102 struct cdev cdev[MAX_CHANNEL]; | |
103 wait_queue_head_t dma_wait_q ;// for poll on reading | |
104 DMA_CONTROL dmactl[DMA_RING_SIZE]; | |
105 PT1_CHANNEL *channel[MAX_CHANNEL]; | |
106 }PT1_DEVICE; | |
107 | |
108 typedef struct _MICRO_PACKET{ | |
109 char data[3]; | |
110 char head ; | |
111 }MICRO_PACKET; | |
112 | |
113 struct _PT1_CHANNEL{ | |
114 __u32 valid ; // 使用中フラグ | |
115 __u32 address ; // I2Cアドレス | |
116 __u32 channel ; // チャネル番号 | |
117 int type ; // チャネルタイプ | |
118 __u32 drop ; // パケットドロップ数 | |
119 struct mutex lock ; // CH別mutex_lock用 | |
120 __u32 size ; // DMAされたサイズ | |
121 __u32 maxsize ; // DMA用バッファサイズ | |
122 __u32 bufsize ; // チャネルに割り振られたサイズ | |
123 __u32 overflow ; // オーバーフローエラー発生 | |
124 __u32 counetererr ; // 転送カウンタ1エラー | |
125 __u32 transerr ; // 転送エラー | |
126 __u32 minor ; // マイナー番号 | |
127 __u8 *buf; // CH別受信メモリ | |
128 __u8 req_dma ; // 溢れたチャネル | |
129 PT1_DEVICE *ptr ; // カード別情報 | |
130 wait_queue_head_t wait_q ; // for poll on reading | |
131 }; | |
132 | |
133 // I2Cアドレス(video0, 1 = ISDB-S) (video2, 3 = ISDB-T) | |
134 int i2c_address[MAX_CHANNEL] = {T0_ISDB_S, T1_ISDB_S, T0_ISDB_T, T1_ISDB_T}; | |
135 int real_chanel[MAX_CHANNEL] = {0, 2, 1, 3}; | |
136 int channeltype[MAX_CHANNEL] = {CHANNEL_TYPE_ISDB_S, CHANNEL_TYPE_ISDB_S, | |
137 CHANNEL_TYPE_ISDB_T, CHANNEL_TYPE_ISDB_T}; | |
138 | |
139 static PT1_DEVICE *device[MAX_PCI_DEVICE]; | |
9
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
140 static struct class *pt1video_class; |
0 | 141 |
142 #define PT1MAJOR 251 | |
143 #define DRIVERNAME "pt1video" | |
144 | |
145 static void reset_dma(PT1_DEVICE *dev_conf) | |
146 { | |
147 | |
148 int lp ; | |
149 __u32 addr ; | |
150 int ring_pos = 0; | |
151 int data_pos = 0 ; | |
152 __u32 *dataptr ; | |
153 | |
154 // データ初期化 | |
155 for(ring_pos = 0 ; ring_pos < DMA_RING_SIZE ; ring_pos++){ | |
156 for(data_pos = 0 ; data_pos < DMA_RING_MAX ; data_pos++){ | |
157 dataptr = dev_conf->dmactl[ring_pos].data[data_pos]; | |
9
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
158 dataptr[(DMA_SIZE / sizeof(__u32)) - 2] = 0; |
0 | 159 } |
160 } | |
161 // 転送カウンタをリセット | |
162 writel(0x00000010, dev_conf->regs); | |
163 // 転送カウンタをインクリメント | |
164 for(lp = 0 ; lp < DMA_RING_SIZE ; lp++){ | |
165 writel(0x00000020, dev_conf->regs); | |
166 } | |
167 | |
168 addr = (int)dev_conf->ring_dma[0] ; | |
169 addr >>= 12 ; | |
170 // DMAバッファ設定 | |
171 writel(addr, dev_conf->regs + DMA_ADDR); | |
172 // DMA開始 | |
173 writel(0x0c000040, dev_conf->regs); | |
174 | |
175 } | |
176 static int pt1_thread(void *data) | |
177 { | |
178 PT1_DEVICE *dev_conf = data ; | |
179 PT1_CHANNEL *channel ; | |
180 int ring_pos = 0; | |
181 int data_pos = 0 ; | |
182 int lp ; | |
183 int chno ; | |
184 int lp2 ; | |
185 __u32 *dataptr ; | |
186 __u32 *curdataptr ; | |
187 __u32 val ; | |
188 union mpacket{ | |
189 __u32 val ; | |
190 MICRO_PACKET packet ; | |
191 }micro; | |
192 | |
193 set_freezable(); | |
194 reset_dma(dev_conf); | |
195 printk(KERN_INFO "pt1_thread run\n"); | |
196 | |
197 for(;;){ | |
198 if(kthread_should_stop()){ | |
199 break ; | |
200 } | |
201 | |
202 for(;;){ | |
203 dataptr = dev_conf->dmactl[ring_pos].data[data_pos]; | |
204 // データあり? | |
205 if(dataptr[(DMA_SIZE / sizeof(__u32)) - 2] == 0){ | |
206 break ; | |
207 } | |
208 micro.val = *dataptr ; | |
209 curdataptr = dataptr ; | |
210 data_pos += 1 ; | |
211 for(lp = 0 ; lp < (DMA_SIZE / sizeof(__u32)) ; lp++, dataptr++){ | |
212 micro.val = *dataptr ; | |
213 chno = real_chanel[(((micro.packet.head >> 5) & 0x07) - 1)]; | |
214 channel = dev_conf->channel[chno] ; | |
215 // エラーチェック | |
216 if((micro.packet.head & MICROPACKET_ERROR)){ | |
217 val = readl(dev_conf->regs); | |
218 if((val & BIT_RAM_OVERFLOW)){ | |
219 channel->overflow += 1 ; | |
220 } | |
221 if((val & BIT_INITIATOR_ERROR)){ | |
222 channel->counetererr += 1 ; | |
223 } | |
224 if((val & BIT_INITIATOR_WARNING)){ | |
225 channel->transerr += 1 ; | |
226 } | |
227 // 初期化して先頭から | |
228 reset_dma(dev_conf); | |
229 ring_pos = data_pos = 0 ; | |
230 break ; | |
231 } | |
232 // 未使用チャネルは捨てる | |
233 if(channel->valid == FALSE){ | |
234 continue ; | |
235 } | |
236 mutex_lock(&channel->lock); | |
237 // あふれたら読み出すまで待つ | |
238 while(1){ | |
239 if(channel->size >= (channel->maxsize - 4)){ | |
240 // 該当チャンネルのDMA読みだし待ちにする | |
241 wake_up(&channel->wait_q); | |
242 channel->req_dma = TRUE ; | |
243 mutex_unlock(&channel->lock); | |
244 // タスクに時間を渡す為中断 | |
245 wait_event_timeout(dev_conf->dma_wait_q, (channel->req_dma == FALSE), | |
246 msecs_to_jiffies(500)); | |
247 mutex_lock(&channel->lock); | |
248 channel->drop += 1 ; | |
249 }else{ | |
250 break ; | |
251 } | |
252 } | |
253 // データコピー | |
254 for(lp2 = 2 ; lp2 >= 0 ; lp2--){ | |
255 channel->buf[channel->size] = micro.packet.data[lp2]; | |
256 channel->size += 1 ; | |
257 } | |
258 mutex_unlock(&channel->lock); | |
259 } | |
260 curdataptr[(DMA_SIZE / sizeof(__u32)) - 2] = 0; | |
261 | |
262 if(data_pos >= DMA_RING_MAX){ | |
263 data_pos = 0; | |
264 ring_pos += 1 ; | |
265 // DMAリングが変わった場合はインクリメント | |
266 writel(0x00000020, dev_conf->regs); | |
267 if(ring_pos >= DMA_RING_SIZE){ | |
268 ring_pos = 0 ; | |
269 } | |
270 } | |
271 | |
272 // 頻度を落す(4Kで起動させる) | |
273 for(lp = 0 ; lp < MAX_CHANNEL ; lp++){ | |
274 channel = dev_conf->channel[real_chanel[lp]] ; | |
275 if((channel->size >= DMA_SIZE) && (channel->valid == TRUE)){ | |
276 wake_up(&channel->wait_q); | |
277 } | |
278 } | |
279 } | |
280 schedule_timeout_interruptible(msecs_to_jiffies(1)); | |
281 } | |
282 return 0 ; | |
283 } | |
284 static int pt1_open(struct inode *inode, struct file *file) | |
285 { | |
286 | |
31
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
287 int major = imajor(inode); |
0 | 288 int minor = iminor(inode); |
289 int lp ; | |
290 int lp2 ; | |
291 PT1_CHANNEL *channel ; | |
292 | |
293 for(lp = 0 ; lp < MAX_PCI_DEVICE ; lp++){ | |
294 if(device[lp] == NULL){ | |
295 return -EIO ; | |
296 } | |
31
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
297 |
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
298 if(MAJOR(device[lp]->dev) == major && |
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
299 device[lp]->base_minor <= minor && |
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
300 device[lp]->base_minor + MAX_CHANNEL > minor) { |
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
301 |
0 | 302 mutex_lock(&device[lp]->lock); |
303 for(lp2 = 0 ; lp2 < MAX_CHANNEL ; lp2++){ | |
304 channel = device[lp]->channel[lp2] ; | |
305 if(channel->minor == minor){ | |
306 if(channel->valid == TRUE){ | |
307 mutex_unlock(&device[lp]->lock); | |
308 return -EIO ; | |
309 } | |
310 channel->drop = 0 ; | |
311 channel->valid = TRUE ; | |
312 channel->overflow = 0 ; | |
313 channel->counetererr = 0 ; | |
314 channel->transerr = 0 ; | |
315 file->private_data = channel; | |
316 mutex_lock(&channel->lock); | |
317 // データ初期化 | |
318 channel->size = 0 ; | |
319 mutex_unlock(&channel->lock); | |
320 mutex_unlock(&device[lp]->lock); | |
321 return 0 ; | |
322 } | |
323 } | |
324 } | |
325 } | |
326 return -EIO; | |
327 } | |
328 static int pt1_release(struct inode *inode, struct file *file) | |
329 { | |
330 PT1_CHANNEL *channel = file->private_data; | |
331 | |
332 mutex_lock(&channel->ptr->lock); | |
333 SetStream(channel->ptr->regs, channel->channel, FALSE); | |
334 channel->valid = FALSE ; | |
31
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
335 printk(KERN_INFO "(%d:%d)Drop=%08d:%08d:%08d:%08d\n", imajor(inode), iminor(inode), channel->drop, |
0 | 336 channel->overflow, channel->counetererr, channel->transerr); |
337 channel->overflow = 0 ; | |
338 channel->counetererr = 0 ; | |
339 channel->transerr = 0 ; | |
340 channel->drop = 0 ; | |
341 // 停止している場合は起こす | |
342 if(channel->req_dma == TRUE){ | |
343 channel->req_dma = FALSE ; | |
344 wake_up(&channel->ptr->dma_wait_q); | |
345 } | |
346 mutex_unlock(&channel->ptr->lock); | |
347 return 0; | |
348 } | |
349 | |
350 static ssize_t pt1_read(struct file *file, char __user *buf, size_t cnt, loff_t * ppos) | |
351 { | |
352 PT1_CHANNEL *channel = file->private_data; | |
353 __u32 size ; | |
36 | 354 unsigned long dummy; |
0 | 355 |
356 // 4K単位で起こされるのを待つ(CPU負荷対策) | |
357 if(channel->size < DMA_SIZE){ | |
358 wait_event_timeout(channel->wait_q, (channel->size >= DMA_SIZE), | |
359 msecs_to_jiffies(500)); | |
360 } | |
361 mutex_lock(&channel->lock); | |
362 if(!channel->size){ | |
363 size = 0 ; | |
364 }else{ | |
365 if(cnt < channel->size){ | |
366 // バッファが足りない場合は残りを移動する | |
367 size = cnt ; | |
36 | 368 dummy = copy_to_user(buf, channel->buf, cnt); |
0 | 369 memmove(channel->buf, &channel->buf[cnt], (channel->size - cnt)); |
370 channel->size -= cnt ; | |
371 }else{ | |
372 size = channel->size ; | |
36 | 373 dummy = copy_to_user(buf, channel->buf, size); |
0 | 374 channel->size = 0 ; |
375 } | |
376 } | |
377 // 読み終わったかつ使用しているのがが4K以下 | |
9
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
378 if(channel->req_dma == TRUE){ |
0 | 379 channel->req_dma = FALSE ; |
380 wake_up(&channel->ptr->dma_wait_q); | |
381 } | |
382 mutex_unlock(&channel->lock); | |
383 return size ; | |
384 } | |
385 static int SetFreq(PT1_CHANNEL *channel, FREQUENCY *freq) | |
386 { | |
387 | |
388 switch(channel->type){ | |
389 case CHANNEL_TYPE_ISDB_S: | |
390 { | |
391 ISDB_S_TMCC tmcc ; | |
392 if(bs_tune(channel->ptr->regs, | |
393 &channel->ptr->lock, | |
394 channel->address, | |
395 freq->frequencyno, | |
396 &tmcc) < 0){ | |
397 return -EIO ; | |
398 } | |
399 | |
400 #if 0 | |
401 printk(KERN_INFO "clockmargin = (%x)\n", (tmcc.clockmargin & 0xFF)); | |
402 printk(KERN_INFO "carriermargin = (%x)\n", (tmcc.carriermargin & 0xFF)); | |
403 | |
404 for(lp = 0 ; lp < MAX_BS_TS_ID ; lp++){ | |
405 if(tmcc.ts_id[lp].ts_id == 0xFFFF){ | |
406 continue ; | |
407 } | |
408 printk(KERN_INFO "Slot(%d:%x)\n", lp, tmcc.ts_id[lp].ts_id); | |
409 printk(KERN_INFO "mode (low/high) = (%x:%x)\n", | |
410 tmcc.ts_id[lp].low_mode, tmcc.ts_id[lp].high_mode); | |
411 printk(KERN_INFO "slot (low/high) = (%x:%x)\n", | |
412 tmcc.ts_id[lp].low_slot, | |
413 tmcc.ts_id[lp].high_slot); | |
414 } | |
415 #endif | |
416 ts_lock(channel->ptr->regs, | |
417 &channel->ptr->lock, | |
418 channel->address, | |
419 tmcc.ts_id[freq->slot].ts_id); | |
420 } | |
421 break ; | |
422 case CHANNEL_TYPE_ISDB_T: | |
423 { | |
424 if(isdb_t_frequency(channel->ptr->regs, | |
425 &channel->ptr->lock, | |
426 channel->address, | |
427 freq->frequencyno, freq->slot) < 0){ | |
428 return -EINVAL ; | |
429 } | |
430 } | |
431 } | |
432 return 0 ; | |
433 } | |
36 | 434 static int pt1_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg0) |
0 | 435 { |
436 PT1_CHANNEL *channel = file->private_data; | |
36 | 437 int signal ; |
438 unsigned long dummy; | |
439 void *arg = (void *)arg0; | |
0 | 440 |
441 switch(cmd){ | |
442 case SET_CHANNEL: | |
443 { | |
444 FREQUENCY freq ; | |
36 | 445 dummy = copy_from_user(&freq, arg, sizeof(FREQUENCY)); |
0 | 446 return SetFreq(channel, &freq); |
447 } | |
448 case START_REC: | |
449 SetStream(channel->ptr->regs, channel->channel, TRUE); | |
450 return 0 ; | |
451 case STOP_REC: | |
452 SetStream(channel->ptr->regs, channel->channel, FALSE); | |
453 return 0 ; | |
9
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
454 case GET_SIGNAL_STRENGTH: |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
455 switch(channel->type){ |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
456 case CHANNEL_TYPE_ISDB_S: |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
457 { |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
458 signal = isdb_s_read_signal_strength(channel->ptr->regs, |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
459 &channel->ptr->lock, |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
460 channel->address); |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
461 } |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
462 break ; |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
463 case CHANNEL_TYPE_ISDB_T: |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
464 // calc C/N |
36 | 465 signal = isdb_t_read_signal_strength(channel->ptr->regs, |
9
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
466 &channel->ptr->lock, channel->address); |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
467 break ; |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
468 } |
36 | 469 dummy = copy_to_user(arg, &signal, sizeof(int)); |
9
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
470 return 0 ; |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
471 case LNB_ENABLE: |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
472 if(lnb){ |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
473 settuner_reset(channel->ptr->regs, lnb, TUNER_POWER_ON_RESET_DISABLE); |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
474 } |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
475 return 0 ; |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
476 case LNB_DISABLE: |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
477 if(lnb){ |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
478 settuner_reset(channel->ptr->regs, LNB_OFF, TUNER_POWER_ON_RESET_DISABLE); |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
479 } |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
480 return 0 ; |
0 | 481 } |
482 return -EINVAL; | |
483 } | |
484 | |
485 /* | |
486 */ | |
487 static const struct file_operations pt1_fops = { | |
488 .owner = THIS_MODULE, | |
489 .open = pt1_open, | |
490 .release = pt1_release, | |
491 .read = pt1_read, | |
492 .ioctl = pt1_ioctl, | |
493 .llseek = no_llseek, | |
494 }; | |
495 | |
496 int pt1_makering(struct pci_dev *pdev, PT1_DEVICE *dev_conf) | |
497 { | |
498 int lp ; | |
499 int lp2 ; | |
500 DMA_CONTROL *dmactl; | |
501 __u32 *dmaptr ; | |
502 __u32 addr ; | |
503 __u32 *ptr ; | |
504 | |
505 //DMAリング作成 | |
506 for(lp = 0 ; lp < DMA_RING_SIZE ; lp++){ | |
507 ptr = dev_conf->dmaptr[lp]; | |
508 if(lp == (DMA_RING_SIZE - 1)){ | |
509 addr = (__u32)dev_conf->ring_dma[0]; | |
510 }else{ | |
511 addr = (__u32)dev_conf->ring_dma[(lp + 1)]; | |
512 } | |
513 addr >>= 12 ; | |
514 memcpy(ptr, &addr, sizeof(__u32)); | |
515 ptr += 1 ; | |
516 | |
517 dmactl = &dev_conf->dmactl[lp]; | |
518 for(lp2 = 0 ; lp2 < DMA_RING_MAX ; lp2++){ | |
519 dmaptr = pci_alloc_consistent(pdev, DMA_SIZE, &dmactl->ring_dma[lp2]); | |
520 if(dmaptr == NULL){ | |
521 printk(KERN_INFO "PT1:DMA ALLOC ERROR\n"); | |
522 return -1 ; | |
523 } | |
524 dmactl->data[lp2] = dmaptr ; | |
525 // DMAデータエリア初期化 | |
526 dmaptr[(DMA_SIZE / sizeof(__u32)) - 2] = 0 ; | |
527 addr = (__u32)dmactl->ring_dma[lp2]; | |
528 addr >>= 12 ; | |
529 memcpy(ptr, &addr, sizeof(__u32)); | |
530 ptr += 1 ; | |
531 } | |
532 } | |
533 return 0 ; | |
534 } | |
535 int pt1_dma_init(struct pci_dev *pdev, PT1_DEVICE *dev_conf) | |
536 { | |
537 int lp ; | |
538 void *ptr ; | |
539 | |
540 for(lp = 0 ; lp < DMA_RING_SIZE ; lp++){ | |
541 ptr = pci_alloc_consistent(pdev, DMA_SIZE, &dev_conf->ring_dma[lp]); | |
542 if(ptr == NULL){ | |
543 printk(KERN_INFO "PT1:DMA ALLOC ERROR\n"); | |
544 return -1 ; | |
545 } | |
546 dev_conf->dmaptr[lp] = ptr ; | |
547 } | |
548 | |
549 return pt1_makering(pdev, dev_conf); | |
550 } | |
551 int pt1_dma_free(struct pci_dev *pdev, PT1_DEVICE *dev_conf) | |
552 { | |
553 | |
554 int lp ; | |
555 int lp2 ; | |
556 | |
557 for(lp = 0 ; lp < DMA_RING_SIZE ; lp++){ | |
558 if(dev_conf->dmaptr[lp] != NULL){ | |
559 pci_free_consistent(pdev, DMA_SIZE, | |
560 dev_conf->dmaptr[lp], dev_conf->ring_dma[lp]); | |
561 for(lp2 = 0 ; lp2 < DMA_RING_MAX ; lp2++){ | |
562 if(dev_conf->dmactl[lp].data[lp2] != NULL){ | |
563 pci_free_consistent(pdev, DMA_SIZE, | |
564 dev_conf->dmactl[lp].data[lp2], | |
565 dev_conf->dmactl[lp].ring_dma[lp2]); | |
566 } | |
567 } | |
568 } | |
569 } | |
570 return 0 ; | |
571 } | |
572 static int __devinit pt1_pci_init_one (struct pci_dev *pdev, | |
573 const struct pci_device_id *ent) | |
574 { | |
575 int rc ; | |
576 int lp ; | |
577 int minor ; | |
578 u16 cmd ; | |
579 PT1_DEVICE *dev_conf ; | |
580 PT1_CHANNEL *channel ; | |
36 | 581 struct resource *dummy; |
0 | 582 |
583 rc = pci_enable_device(pdev); | |
584 if (rc) | |
585 return rc; | |
586 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); | |
587 if (rc) { | |
588 printk(KERN_ERR "PT1:DMA MASK ERROR"); | |
589 return rc; | |
590 } | |
591 | |
592 pci_read_config_word(pdev, PCI_COMMAND, &cmd); | |
593 if (!(cmd & PCI_COMMAND_MASTER)) { | |
594 printk(KERN_INFO "Attempting to enable Bus Mastering\n"); | |
595 pci_set_master(pdev); | |
596 pci_read_config_word(pdev, PCI_COMMAND, &cmd); | |
597 if (!(cmd & PCI_COMMAND_MASTER)) { | |
598 printk(KERN_ERR "Bus Mastering is not enabled\n"); | |
599 return -EIO; | |
600 } | |
601 } | |
602 printk(KERN_INFO "Bus Mastering Enabled.\n"); | |
603 | |
604 dev_conf = kzalloc(sizeof(PT1_DEVICE), GFP_KERNEL); | |
605 if(!dev_conf){ | |
606 printk(KERN_ERR "PT1:out of memory !"); | |
607 return -ENOMEM ; | |
608 } | |
609 // PCIアドレスをマップする | |
610 dev_conf->mmio_start = pci_resource_start(pdev, 0); | |
611 dev_conf->mmio_len = pci_resource_len(pdev, 0); | |
36 | 612 dummy = request_mem_region(dev_conf->mmio_start, dev_conf->mmio_len, DEV_NAME); |
613 if (!dummy) { | |
0 | 614 printk(KERN_ERR "PT1: cannot request iomem (0x%llx).\n", (unsigned long long) dev_conf->mmio_start); |
615 goto out_err_regbase; | |
616 } | |
617 | |
618 dev_conf->regs = ioremap(dev_conf->mmio_start, dev_conf->mmio_len); | |
619 if (!dev_conf->regs){ | |
620 printk(KERN_ERR "pt1: Can't remap register area.\n"); | |
621 goto out_err_regbase; | |
622 } | |
623 // 初期化処理 | |
624 if(xc3s_init(dev_conf->regs)){ | |
625 printk(KERN_ERR "Error xc3s_init\n"); | |
626 goto out_err_fpga; | |
627 } | |
628 // チューナリセット | |
629 settuner_reset(dev_conf->regs, LNB_OFF, TUNER_POWER_ON_RESET_ENABLE); | |
630 schedule_timeout_interruptible(msecs_to_jiffies(50)); | |
631 | |
9
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
632 settuner_reset(dev_conf->regs, LNB_OFF, TUNER_POWER_ON_RESET_DISABLE); |
0 | 633 schedule_timeout_interruptible(msecs_to_jiffies(10)); |
634 mutex_init(&dev_conf->lock); | |
635 | |
636 // Tuner 初期化処理 | |
637 for(lp = 0 ; lp < MAX_TUNER ; lp++){ | |
638 rc = tuner_init(dev_conf->regs, &dev_conf->lock, lp); | |
639 if(rc < 0){ | |
640 printk(KERN_ERR "Error tuner_init\n"); | |
641 goto out_err_fpga; | |
642 } | |
643 } | |
644 // 初期化完了 | |
645 for(lp = 0 ; lp < MAX_CHANNEL ; lp++){ | |
36 | 646 set_sleepmode(dev_conf->regs, &dev_conf->lock, |
0 | 647 i2c_address[lp], channeltype[lp], TYPE_SLEEP); |
36 | 648 |
0 | 649 schedule_timeout_interruptible(msecs_to_jiffies(50)); |
650 } | |
651 rc = alloc_chrdev_region(&dev_conf->dev, 0, MAX_CHANNEL, DEV_NAME); | |
652 if(rc < 0){ | |
653 goto out_err_fpga; | |
654 } | |
655 | |
656 // 初期化 | |
657 init_waitqueue_head(&dev_conf->dma_wait_q); | |
658 | |
659 minor = MINOR(dev_conf->dev) ; | |
660 dev_conf->base_minor = minor ; | |
661 for(lp = 0 ; lp < MAX_PCI_DEVICE ; lp++){ | |
31
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
662 printk(KERN_INFO "PT1: device[%d]=%p\n", lp, device[lp]); |
0 | 663 if(device[lp] == NULL){ |
664 device[lp] = dev_conf ; | |
31
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
665 dev_conf->card_number = lp; |
0 | 666 break ; |
667 } | |
668 } | |
669 for(lp = 0 ; lp < MAX_CHANNEL ; lp++){ | |
670 cdev_init(&dev_conf->cdev[lp], &pt1_fops); | |
30
eb694d8e4c7e
setup owner in initialization
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
9
diff
changeset
|
671 dev_conf->cdev[lp].owner = THIS_MODULE; |
31
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
672 cdev_add(&dev_conf->cdev[lp], |
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
673 MKDEV(MAJOR(dev_conf->dev), (MINOR(dev_conf->dev) + lp)), 1); |
0 | 674 channel = kzalloc(sizeof(PT1_CHANNEL), GFP_KERNEL); |
675 if(!channel){ | |
676 printk(KERN_ERR "PT1:out of memory !"); | |
677 return -ENOMEM ; | |
678 } | |
679 | |
680 // 共通情報 | |
681 mutex_init(&channel->lock); | |
682 // 待ち状態を解除 | |
683 channel->req_dma = FALSE ; | |
684 // マイナー番号設定 | |
685 channel->minor = MINOR(dev_conf->dev) + lp ; | |
686 // 対象のI2Cデバイス | |
687 channel->address = i2c_address[lp] ; | |
688 channel->type = channeltype[lp] ; | |
689 // 実際のチューナ番号 | |
690 channel->channel = real_chanel[lp] ; | |
691 channel->ptr = dev_conf ; | |
692 channel->size = 0 ; | |
693 dev_conf->channel[lp] = channel ; | |
694 | |
695 init_waitqueue_head(&channel->wait_q); | |
696 | |
697 switch(channel->type){ | |
698 case CHANNEL_TYPE_ISDB_T: | |
699 channel->maxsize = CHANEL_DMA_SIZE ; | |
700 channel->buf = kzalloc(CHANEL_DMA_SIZE, GFP_KERNEL); | |
701 break ; | |
702 case CHANNEL_TYPE_ISDB_S: | |
703 channel->maxsize = BS_CHANEL_DMA_SIZE ; | |
704 channel->buf = kzalloc(BS_CHANEL_DMA_SIZE, GFP_KERNEL); | |
705 break ; | |
706 } | |
707 if(channel->buf == NULL){ | |
708 goto out_err_v4l; | |
709 } | |
9
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
710 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) |
31
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
711 printk(KERN_INFO "PT1: card_number = %d\n", |
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
712 dev_conf->card_number); |
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
713 device_create(pt1video_class, |
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
714 NULL, |
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
715 MKDEV(MAJOR(dev_conf->dev), |
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
716 (MINOR(dev_conf->dev) + lp)), |
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
717 NULL, |
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
718 "pt1video%u", |
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
719 MINOR(dev_conf->dev) + lp + |
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
720 dev_conf->card_number * MAX_CHANNEL); |
9
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
721 #else |
31
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
722 device_create(pt1video_class, |
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
723 NULL, |
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
724 MKDEV(MAJOR(dev_conf->dev), |
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
725 (MINOR(dev_conf->dev) + lp)), |
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
726 "pt1video%u", |
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
727 MINOR(dev_conf->dev) + lp + |
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
728 dev_conf->card_number * MAX_CHANNEL); |
9
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
729 #endif |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
730 |
0 | 731 #if 0 |
732 dev_conf->vdev[lp] = video_device_alloc(); | |
733 memcpy(dev_conf->vdev[lp], &pt1_template, sizeof(pt1_template)); | |
734 video_set_drvdata(dev_conf->vdev[lp], channel); | |
735 video_register_device(dev_conf->vdev[lp], VFL_TYPE_GRABBER, -1); | |
736 #endif | |
737 } | |
31
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
738 |
0 | 739 if(pt1_dma_init(pdev, dev_conf) < 0){ |
740 goto out_err_dma; | |
741 } | |
742 dev_conf->kthread = kthread_run(pt1_thread, dev_conf, "pt1"); | |
743 pci_set_drvdata(pdev, dev_conf); | |
744 return 0; | |
745 | |
746 out_err_dma: | |
747 pt1_dma_free(pdev, dev_conf); | |
748 out_err_v4l: | |
749 for(lp = 0 ; lp < MAX_CHANNEL ; lp++){ | |
750 if(dev_conf->channel[lp] != NULL){ | |
751 if(dev_conf->channel[lp]->buf != NULL){ | |
752 kfree(dev_conf->channel[lp]->buf); | |
753 } | |
754 kfree(dev_conf->channel[lp]); | |
755 } | |
756 } | |
757 out_err_fpga: | |
758 writel(0xb0b0000, dev_conf->regs); | |
759 writel(0, dev_conf->regs + 4); | |
760 iounmap(dev_conf->regs); | |
761 release_mem_region(dev_conf->mmio_start, dev_conf->mmio_len); | |
762 kfree(dev_conf); | |
763 out_err_regbase: | |
764 return -EIO; | |
765 | |
766 } | |
767 | |
768 static void __devexit pt1_pci_remove_one(struct pci_dev *pdev) | |
769 { | |
770 | |
771 int lp ; | |
772 __u32 val ; | |
773 PT1_DEVICE *dev_conf = (PT1_DEVICE *)pci_get_drvdata(pdev); | |
774 | |
775 if(dev_conf){ | |
776 if(dev_conf->kthread) { | |
777 kthread_stop(dev_conf->kthread); | |
778 dev_conf->kthread = NULL; | |
779 } | |
780 | |
781 // DMA終了 | |
782 writel(0x08080000, dev_conf->regs); | |
783 for(lp = 0 ; lp < 10 ; lp++){ | |
784 val = readl(dev_conf->regs); | |
785 if(!(val & (1 << 6))){ | |
786 break ; | |
787 } | |
788 schedule_timeout_interruptible(msecs_to_jiffies(1)); | |
789 } | |
790 pt1_dma_free(pdev, dev_conf); | |
791 for(lp = 0 ; lp < MAX_CHANNEL ; lp++){ | |
792 if(dev_conf->channel[lp] != NULL){ | |
793 cdev_del(&dev_conf->cdev[lp]); | |
794 kfree(dev_conf->channel[lp]->buf); | |
795 kfree(dev_conf->channel[lp]); | |
796 } | |
31
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
797 device_destroy(pt1video_class, |
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
798 MKDEV(MAJOR(dev_conf->dev), |
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
799 (MINOR(dev_conf->dev) + lp))); |
0 | 800 } |
31
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
801 |
0 | 802 unregister_chrdev_region(dev_conf->dev, MAX_CHANNEL); |
803 writel(0xb0b0000, dev_conf->regs); | |
804 writel(0, dev_conf->regs + 4); | |
805 settuner_reset(dev_conf->regs, LNB_OFF, TUNER_POWER_OFF); | |
806 release_mem_region(dev_conf->mmio_start, dev_conf->mmio_len); | |
807 iounmap(dev_conf->regs); | |
31
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
808 device[dev_conf->card_number] = NULL; |
0 | 809 kfree(dev_conf); |
810 } | |
811 pci_set_drvdata(pdev, NULL); | |
812 } | |
813 #ifdef CONFIG_PM | |
814 | |
815 static int pt1_pci_suspend (struct pci_dev *pdev, pm_message_t state) | |
816 { | |
817 return 0; | |
818 } | |
819 | |
820 static int pt1_pci_resume (struct pci_dev *pdev) | |
821 { | |
822 return 0; | |
823 } | |
824 | |
825 #endif /* CONFIG_PM */ | |
826 | |
827 | |
828 static struct pci_driver pt1_driver = { | |
829 .name = DRV_NAME, | |
830 .probe = pt1_pci_init_one, | |
831 .remove = __devexit_p(pt1_pci_remove_one), | |
832 .id_table = pt1_pci_tbl, | |
833 #ifdef CONFIG_PM | |
834 .suspend = pt1_pci_suspend, | |
835 .resume = pt1_pci_resume, | |
836 #endif /* CONFIG_PM */ | |
837 | |
838 }; | |
839 | |
840 | |
841 static int __init pt1_pci_init(void) | |
842 { | |
36 | 843 printk(version); |
9
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
844 pt1video_class = class_create(THIS_MODULE, DRIVERNAME); |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
845 if (IS_ERR(pt1video_class)) |
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
846 return PTR_ERR(pt1video_class); |
0 | 847 return pci_register_driver(&pt1_driver); |
848 } | |
849 | |
850 | |
851 static void __exit pt1_pci_cleanup(void) | |
852 { | |
9
07b2fc07ff48
updated to current driver to support signal strength.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
0
diff
changeset
|
853 class_destroy(pt1video_class); |
31
289794dc265f
adapted to use of multiple number of pt1:
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
30
diff
changeset
|
854 pci_unregister_driver(&pt1_driver); |
0 | 855 } |
856 | |
857 module_init(pt1_pci_init); | |
858 module_exit(pt1_pci_cleanup); |