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