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