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