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