aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/saa7134/saa7134-oss.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/saa7134/saa7134-oss.c')
-rw-r--r--drivers/media/video/saa7134/saa7134-oss.c375
1 files changed, 188 insertions, 187 deletions
diff --git a/drivers/media/video/saa7134/saa7134-oss.c b/drivers/media/video/saa7134/saa7134-oss.c
index c20630c82f1c..fd53dfcc1644 100644
--- a/drivers/media/video/saa7134/saa7134-oss.c
+++ b/drivers/media/video/saa7134/saa7134-oss.c
@@ -44,6 +44,7 @@ MODULE_PARM_DESC(oss_rate,"sample rate (valid are: 32000,48000)");
44#define dprintk(fmt, arg...) if (oss_debug) \ 44#define dprintk(fmt, arg...) if (oss_debug) \
45 printk(KERN_DEBUG "%s/oss: " fmt, dev->name , ## arg) 45 printk(KERN_DEBUG "%s/oss: " fmt, dev->name , ## arg)
46 46
47
47/* ------------------------------------------------------------------ */ 48/* ------------------------------------------------------------------ */
48 49
49static int dsp_buffer_conf(struct saa7134_dev *dev, int blksize, int blocks) 50static int dsp_buffer_conf(struct saa7134_dev *dev, int blksize, int blocks)
@@ -58,12 +59,12 @@ static int dsp_buffer_conf(struct saa7134_dev *dev, int blksize, int blocks)
58 if ((blksize * blocks) > 1024*1024) 59 if ((blksize * blocks) > 1024*1024)
59 blocks = 1024*1024 / blksize; 60 blocks = 1024*1024 / blksize;
60 61
61 dev->oss.blocks = blocks; 62 dev->dmasound.blocks = blocks;
62 dev->oss.blksize = blksize; 63 dev->dmasound.blksize = blksize;
63 dev->oss.bufsize = blksize * blocks; 64 dev->dmasound.bufsize = blksize * blocks;
64 65
65 dprintk("buffer config: %d blocks / %d bytes, %d kB total\n", 66 dprintk("buffer config: %d blocks / %d bytes, %d kB total\n",
66 blocks,blksize,blksize * blocks / 1024); 67 blocks,blksize,blksize * blocks / 1024);
67 return 0; 68 return 0;
68} 69}
69 70
@@ -71,11 +72,11 @@ static int dsp_buffer_init(struct saa7134_dev *dev)
71{ 72{
72 int err; 73 int err;
73 74
74 if (!dev->oss.bufsize) 75 if (!dev->dmasound.bufsize)
75 BUG(); 76 BUG();
76 videobuf_dma_init(&dev->oss.dma); 77 videobuf_dma_init(&dev->dmasound.dma);
77 err = videobuf_dma_init_kernel(&dev->oss.dma, PCI_DMA_FROMDEVICE, 78 err = videobuf_dma_init_kernel(&dev->dmasound.dma, PCI_DMA_FROMDEVICE,
78 (dev->oss.bufsize + PAGE_SIZE) >> PAGE_SHIFT); 79 (dev->dmasound.bufsize + PAGE_SIZE) >> PAGE_SHIFT);
79 if (0 != err) 80 if (0 != err)
80 return err; 81 return err;
81 return 0; 82 return 0;
@@ -83,26 +84,26 @@ static int dsp_buffer_init(struct saa7134_dev *dev)
83 84
84static int dsp_buffer_free(struct saa7134_dev *dev) 85static int dsp_buffer_free(struct saa7134_dev *dev)
85{ 86{
86 if (!dev->oss.blksize) 87 if (!dev->dmasound.blksize)
87 BUG(); 88 BUG();
88 videobuf_dma_free(&dev->oss.dma); 89 videobuf_dma_free(&dev->dmasound.dma);
89 dev->oss.blocks = 0; 90 dev->dmasound.blocks = 0;
90 dev->oss.blksize = 0; 91 dev->dmasound.blksize = 0;
91 dev->oss.bufsize = 0; 92 dev->dmasound.bufsize = 0;
92 return 0; 93 return 0;
93} 94}
94 95
95static void dsp_dma_start(struct saa7134_dev *dev) 96static void dsp_dma_start(struct saa7134_dev *dev)
96{ 97{
97 dev->oss.dma_blk = 0; 98 dev->dmasound.dma_blk = 0;
98 dev->oss.dma_running = 1; 99 dev->dmasound.dma_running = 1;
99 saa7134_set_dmabits(dev); 100 saa7134_set_dmabits(dev);
100} 101}
101 102
102static void dsp_dma_stop(struct saa7134_dev *dev) 103static void dsp_dma_stop(struct saa7134_dev *dev)
103{ 104{
104 dev->oss.dma_blk = -1; 105 dev->dmasound.dma_blk = -1;
105 dev->oss.dma_running = 0; 106 dev->dmasound.dma_running = 0;
106 saa7134_set_dmabits(dev); 107 saa7134_set_dmabits(dev);
107} 108}
108 109
@@ -113,18 +114,18 @@ static int dsp_rec_start(struct saa7134_dev *dev)
113 unsigned long flags; 114 unsigned long flags;
114 115
115 /* prepare buffer */ 116 /* prepare buffer */
116 if (0 != (err = videobuf_dma_pci_map(dev->pci,&dev->oss.dma))) 117 if (0 != (err = videobuf_dma_pci_map(dev->pci,&dev->dmasound.dma)))
117 return err; 118 return err;
118 if (0 != (err = saa7134_pgtable_alloc(dev->pci,&dev->oss.pt))) 119 if (0 != (err = saa7134_pgtable_alloc(dev->pci,&dev->dmasound.pt)))
119 goto fail1; 120 goto fail1;
120 if (0 != (err = saa7134_pgtable_build(dev->pci,&dev->oss.pt, 121 if (0 != (err = saa7134_pgtable_build(dev->pci,&dev->dmasound.pt,
121 dev->oss.dma.sglist, 122 dev->dmasound.dma.sglist,
122 dev->oss.dma.sglen, 123 dev->dmasound.dma.sglen,
123 0))) 124 0)))
124 goto fail2; 125 goto fail2;
125 126
126 /* sample format */ 127 /* sample format */
127 switch (dev->oss.afmt) { 128 switch (dev->dmasound.afmt) {
128 case AFMT_U8: 129 case AFMT_U8:
129 case AFMT_S8: fmt = 0x00; break; 130 case AFMT_S8: fmt = 0x00; break;
130 case AFMT_U16_LE: 131 case AFMT_U16_LE:
@@ -136,14 +137,14 @@ static int dsp_rec_start(struct saa7134_dev *dev)
136 goto fail2; 137 goto fail2;
137 } 138 }
138 139
139 switch (dev->oss.afmt) { 140 switch (dev->dmasound.afmt) {
140 case AFMT_S8: 141 case AFMT_S8:
141 case AFMT_S16_LE: 142 case AFMT_S16_LE:
142 case AFMT_S16_BE: sign = 1; break; 143 case AFMT_S16_BE: sign = 1; break;
143 default: sign = 0; break; 144 default: sign = 0; break;
144 } 145 }
145 146
146 switch (dev->oss.afmt) { 147 switch (dev->dmasound.afmt) {
147 case AFMT_U16_BE: 148 case AFMT_U16_BE:
148 case AFMT_S16_BE: bswap = 1; break; 149 case AFMT_S16_BE: bswap = 1; break;
149 default: bswap = 0; break; 150 default: bswap = 0; break;
@@ -151,58 +152,58 @@ static int dsp_rec_start(struct saa7134_dev *dev)
151 152
152 switch (dev->pci->device) { 153 switch (dev->pci->device) {
153 case PCI_DEVICE_ID_PHILIPS_SAA7134: 154 case PCI_DEVICE_ID_PHILIPS_SAA7134:
154 if (1 == dev->oss.channels) 155 if (1 == dev->dmasound.channels)
155 fmt |= (1 << 3); 156 fmt |= (1 << 3);
156 if (2 == dev->oss.channels) 157 if (2 == dev->dmasound.channels)
157 fmt |= (3 << 3); 158 fmt |= (3 << 3);
158 if (sign) 159 if (sign)
159 fmt |= 0x04; 160 fmt |= 0x04;
160 fmt |= (TV == dev->oss.input) ? 0xc0 : 0x80; 161 fmt |= (TV == dev->dmasound.input) ? 0xc0 : 0x80;
161 162
162 saa_writeb(SAA7134_NUM_SAMPLES0, ((dev->oss.blksize - 1) & 0x0000ff)); 163 saa_writeb(SAA7134_NUM_SAMPLES0, ((dev->dmasound.blksize - 1) & 0x0000ff));
163 saa_writeb(SAA7134_NUM_SAMPLES1, ((dev->oss.blksize - 1) & 0x00ff00) >> 8); 164 saa_writeb(SAA7134_NUM_SAMPLES1, ((dev->dmasound.blksize - 1) & 0x00ff00) >> 8);
164 saa_writeb(SAA7134_NUM_SAMPLES2, ((dev->oss.blksize - 1) & 0xff0000) >> 16); 165 saa_writeb(SAA7134_NUM_SAMPLES2, ((dev->dmasound.blksize - 1) & 0xff0000) >> 16);
165 saa_writeb(SAA7134_AUDIO_FORMAT_CTRL, fmt); 166 saa_writeb(SAA7134_AUDIO_FORMAT_CTRL, fmt);
166 167
167 break; 168 break;
168 case PCI_DEVICE_ID_PHILIPS_SAA7133: 169 case PCI_DEVICE_ID_PHILIPS_SAA7133:
169 case PCI_DEVICE_ID_PHILIPS_SAA7135: 170 case PCI_DEVICE_ID_PHILIPS_SAA7135:
170 if (1 == dev->oss.channels) 171 if (1 == dev->dmasound.channels)
171 fmt |= (1 << 4); 172 fmt |= (1 << 4);
172 if (2 == dev->oss.channels) 173 if (2 == dev->dmasound.channels)
173 fmt |= (2 << 4); 174 fmt |= (2 << 4);
174 if (!sign) 175 if (!sign)
175 fmt |= 0x04; 176 fmt |= 0x04;
176 saa_writel(0x588 >> 2, dev->oss.blksize -4); 177 saa_writel(SAA7133_NUM_SAMPLES, dev->dmasound.blksize -4);
177 saa_writel(0x58c >> 2, 0x543210 | (fmt << 24)); 178 saa_writel(SAA7133_AUDIO_CHANNEL, 0x543210 | (fmt << 24));
178 break; 179 break;
179 } 180 }
180 dprintk("rec_start: afmt=%d ch=%d => fmt=0x%x swap=%c\n", 181 dprintk("rec_start: afmt=%d ch=%d => fmt=0x%x swap=%c\n",
181 dev->oss.afmt, dev->oss.channels, fmt, 182 dev->dmasound.afmt, dev->dmasound.channels, fmt,
182 bswap ? 'b' : '-'); 183 bswap ? 'b' : '-');
183 184
184 /* dma: setup channel 6 (= AUDIO) */ 185 /* dma: setup channel 6 (= AUDIO) */
185 control = SAA7134_RS_CONTROL_BURST_16 | 186 control = SAA7134_RS_CONTROL_BURST_16 |
186 SAA7134_RS_CONTROL_ME | 187 SAA7134_RS_CONTROL_ME |
187 (dev->oss.pt.dma >> 12); 188 (dev->dmasound.pt.dma >> 12);
188 if (bswap) 189 if (bswap)
189 control |= SAA7134_RS_CONTROL_BSWAP; 190 control |= SAA7134_RS_CONTROL_BSWAP;
190 saa_writel(SAA7134_RS_BA1(6),0); 191 saa_writel(SAA7134_RS_BA1(6),0);
191 saa_writel(SAA7134_RS_BA2(6),dev->oss.blksize); 192 saa_writel(SAA7134_RS_BA2(6),dev->dmasound.blksize);
192 saa_writel(SAA7134_RS_PITCH(6),0); 193 saa_writel(SAA7134_RS_PITCH(6),0);
193 saa_writel(SAA7134_RS_CONTROL(6),control); 194 saa_writel(SAA7134_RS_CONTROL(6),control);
194 195
195 /* start dma */ 196 /* start dma */
196 dev->oss.recording_on = 1; 197 dev->dmasound.recording_on = 1;
197 spin_lock_irqsave(&dev->slock,flags); 198 spin_lock_irqsave(&dev->slock,flags);
198 dsp_dma_start(dev); 199 dsp_dma_start(dev);
199 spin_unlock_irqrestore(&dev->slock,flags); 200 spin_unlock_irqrestore(&dev->slock,flags);
200 return 0; 201 return 0;
201 202
202 fail2: 203 fail2:
203 saa7134_pgtable_free(dev->pci,&dev->oss.pt); 204 saa7134_pgtable_free(dev->pci,&dev->dmasound.pt);
204 fail1: 205 fail1:
205 videobuf_dma_pci_unmap(dev->pci,&dev->oss.dma); 206 videobuf_dma_pci_unmap(dev->pci,&dev->dmasound.dma);
206 return err; 207 return err;
207} 208}
208 209
@@ -210,17 +211,17 @@ static int dsp_rec_stop(struct saa7134_dev *dev)
210{ 211{
211 unsigned long flags; 212 unsigned long flags;
212 213
213 dprintk("rec_stop dma_blk=%d\n",dev->oss.dma_blk); 214 dprintk("rec_stop dma_blk=%d\n",dev->dmasound.dma_blk);
214 215
215 /* stop dma */ 216 /* stop dma */
216 dev->oss.recording_on = 0; 217 dev->dmasound.recording_on = 0;
217 spin_lock_irqsave(&dev->slock,flags); 218 spin_lock_irqsave(&dev->slock,flags);
218 dsp_dma_stop(dev); 219 dsp_dma_stop(dev);
219 spin_unlock_irqrestore(&dev->slock,flags); 220 spin_unlock_irqrestore(&dev->slock,flags);
220 221
221 /* unlock buffer */ 222 /* unlock buffer */
222 saa7134_pgtable_free(dev->pci,&dev->oss.pt); 223 saa7134_pgtable_free(dev->pci,&dev->dmasound.pt);
223 videobuf_dma_pci_unmap(dev->pci,&dev->oss.dma); 224 videobuf_dma_pci_unmap(dev->pci,&dev->dmasound.dma);
224 return 0; 225 return 0;
225} 226}
226 227
@@ -235,35 +236,35 @@ static int dsp_open(struct inode *inode, struct file *file)
235 236
236 list_for_each(list,&saa7134_devlist) { 237 list_for_each(list,&saa7134_devlist) {
237 h = list_entry(list, struct saa7134_dev, devlist); 238 h = list_entry(list, struct saa7134_dev, devlist);
238 if (h->oss.minor_dsp == minor) 239 if (h->dmasound.minor_dsp == minor)
239 dev = h; 240 dev = h;
240 } 241 }
241 if (NULL == dev) 242 if (NULL == dev)
242 return -ENODEV; 243 return -ENODEV;
243 244
244 down(&dev->oss.lock); 245 down(&dev->dmasound.lock);
245 err = -EBUSY; 246 err = -EBUSY;
246 if (dev->oss.users_dsp) 247 if (dev->dmasound.users_dsp)
247 goto fail1; 248 goto fail1;
248 dev->oss.users_dsp++; 249 dev->dmasound.users_dsp++;
249 file->private_data = dev; 250 file->private_data = dev;
250 251
251 dev->oss.afmt = AFMT_U8; 252 dev->dmasound.afmt = AFMT_U8;
252 dev->oss.channels = 1; 253 dev->dmasound.channels = 1;
253 dev->oss.read_count = 0; 254 dev->dmasound.read_count = 0;
254 dev->oss.read_offset = 0; 255 dev->dmasound.read_offset = 0;
255 dsp_buffer_conf(dev,PAGE_SIZE,64); 256 dsp_buffer_conf(dev,PAGE_SIZE,64);
256 err = dsp_buffer_init(dev); 257 err = dsp_buffer_init(dev);
257 if (0 != err) 258 if (0 != err)
258 goto fail2; 259 goto fail2;
259 260
260 up(&dev->oss.lock); 261 up(&dev->dmasound.lock);
261 return 0; 262 return 0;
262 263
263 fail2: 264 fail2:
264 dev->oss.users_dsp--; 265 dev->dmasound.users_dsp--;
265 fail1: 266 fail1:
266 up(&dev->oss.lock); 267 up(&dev->dmasound.lock);
267 return err; 268 return err;
268} 269}
269 270
@@ -271,13 +272,13 @@ static int dsp_release(struct inode *inode, struct file *file)
271{ 272{
272 struct saa7134_dev *dev = file->private_data; 273 struct saa7134_dev *dev = file->private_data;
273 274
274 down(&dev->oss.lock); 275 down(&dev->dmasound.lock);
275 if (dev->oss.recording_on) 276 if (dev->dmasound.recording_on)
276 dsp_rec_stop(dev); 277 dsp_rec_stop(dev);
277 dsp_buffer_free(dev); 278 dsp_buffer_free(dev);
278 dev->oss.users_dsp--; 279 dev->dmasound.users_dsp--;
279 file->private_data = NULL; 280 file->private_data = NULL;
280 up(&dev->oss.lock); 281 up(&dev->dmasound.lock);
281 return 0; 282 return 0;
282} 283}
283 284
@@ -290,12 +291,12 @@ static ssize_t dsp_read(struct file *file, char __user *buffer,
290 unsigned long flags; 291 unsigned long flags;
291 int err,ret = 0; 292 int err,ret = 0;
292 293
293 add_wait_queue(&dev->oss.wq, &wait); 294 add_wait_queue(&dev->dmasound.wq, &wait);
294 down(&dev->oss.lock); 295 down(&dev->dmasound.lock);
295 while (count > 0) { 296 while (count > 0) {
296 /* wait for data if needed */ 297 /* wait for data if needed */
297 if (0 == dev->oss.read_count) { 298 if (0 == dev->dmasound.read_count) {
298 if (!dev->oss.recording_on) { 299 if (!dev->dmasound.recording_on) {
299 err = dsp_rec_start(dev); 300 err = dsp_rec_start(dev);
300 if (err < 0) { 301 if (err < 0) {
301 if (0 == ret) 302 if (0 == ret)
@@ -303,8 +304,8 @@ static ssize_t dsp_read(struct file *file, char __user *buffer,
303 break; 304 break;
304 } 305 }
305 } 306 }
306 if (dev->oss.recording_on && 307 if (dev->dmasound.recording_on &&
307 !dev->oss.dma_running) { 308 !dev->dmasound.dma_running) {
308 /* recover from overruns */ 309 /* recover from overruns */
309 spin_lock_irqsave(&dev->slock,flags); 310 spin_lock_irqsave(&dev->slock,flags);
310 dsp_dma_start(dev); 311 dsp_dma_start(dev);
@@ -315,12 +316,12 @@ static ssize_t dsp_read(struct file *file, char __user *buffer,
315 ret = -EAGAIN; 316 ret = -EAGAIN;
316 break; 317 break;
317 } 318 }
318 up(&dev->oss.lock); 319 up(&dev->dmasound.lock);
319 set_current_state(TASK_INTERRUPTIBLE); 320 set_current_state(TASK_INTERRUPTIBLE);
320 if (0 == dev->oss.read_count) 321 if (0 == dev->dmasound.read_count)
321 schedule(); 322 schedule();
322 set_current_state(TASK_RUNNING); 323 set_current_state(TASK_RUNNING);
323 down(&dev->oss.lock); 324 down(&dev->dmasound.lock);
324 if (signal_pending(current)) { 325 if (signal_pending(current)) {
325 if (0 == ret) 326 if (0 == ret)
326 ret = -EINTR; 327 ret = -EINTR;
@@ -330,12 +331,12 @@ static ssize_t dsp_read(struct file *file, char __user *buffer,
330 331
331 /* copy data to userspace */ 332 /* copy data to userspace */
332 bytes = count; 333 bytes = count;
333 if (bytes > dev->oss.read_count) 334 if (bytes > dev->dmasound.read_count)
334 bytes = dev->oss.read_count; 335 bytes = dev->dmasound.read_count;
335 if (bytes > dev->oss.bufsize - dev->oss.read_offset) 336 if (bytes > dev->dmasound.bufsize - dev->dmasound.read_offset)
336 bytes = dev->oss.bufsize - dev->oss.read_offset; 337 bytes = dev->dmasound.bufsize - dev->dmasound.read_offset;
337 if (copy_to_user(buffer + ret, 338 if (copy_to_user(buffer + ret,
338 dev->oss.dma.vmalloc + dev->oss.read_offset, 339 dev->dmasound.dma.vmalloc + dev->dmasound.read_offset,
339 bytes)) { 340 bytes)) {
340 if (0 == ret) 341 if (0 == ret)
341 ret = -EFAULT; 342 ret = -EFAULT;
@@ -344,13 +345,13 @@ static ssize_t dsp_read(struct file *file, char __user *buffer,
344 345
345 ret += bytes; 346 ret += bytes;
346 count -= bytes; 347 count -= bytes;
347 dev->oss.read_count -= bytes; 348 dev->dmasound.read_count -= bytes;
348 dev->oss.read_offset += bytes; 349 dev->dmasound.read_offset += bytes;
349 if (dev->oss.read_offset == dev->oss.bufsize) 350 if (dev->dmasound.read_offset == dev->dmasound.bufsize)
350 dev->oss.read_offset = 0; 351 dev->dmasound.read_offset = 0;
351 } 352 }
352 up(&dev->oss.lock); 353 up(&dev->dmasound.lock);
353 remove_wait_queue(&dev->oss.wq, &wait); 354 remove_wait_queue(&dev->dmasound.wq, &wait);
354 return ret; 355 return ret;
355} 356}
356 357
@@ -370,53 +371,53 @@ static int dsp_ioctl(struct inode *inode, struct file *file,
370 371
371 if (oss_debug > 1) 372 if (oss_debug > 1)
372 saa7134_print_ioctl(dev->name,cmd); 373 saa7134_print_ioctl(dev->name,cmd);
373 switch (cmd) { 374 switch (cmd) {
374 case OSS_GETVERSION: 375 case OSS_GETVERSION:
375 return put_user(SOUND_VERSION, p); 376 return put_user(SOUND_VERSION, p);
376 case SNDCTL_DSP_GETCAPS: 377 case SNDCTL_DSP_GETCAPS:
377 return 0; 378 return 0;
378 379
379 case SNDCTL_DSP_SPEED: 380 case SNDCTL_DSP_SPEED:
380 if (get_user(val, p)) 381 if (get_user(val, p))
381 return -EFAULT; 382 return -EFAULT;
382 /* fall through */ 383 /* fall through */
383 case SOUND_PCM_READ_RATE: 384 case SOUND_PCM_READ_RATE:
384 return put_user(dev->oss.rate, p); 385 return put_user(dev->dmasound.rate, p);
385 386
386 case SNDCTL_DSP_STEREO: 387 case SNDCTL_DSP_STEREO:
387 if (get_user(val, p)) 388 if (get_user(val, p))
388 return -EFAULT; 389 return -EFAULT;
389 down(&dev->oss.lock); 390 down(&dev->dmasound.lock);
390 dev->oss.channels = val ? 2 : 1; 391 dev->dmasound.channels = val ? 2 : 1;
391 if (dev->oss.recording_on) { 392 if (dev->dmasound.recording_on) {
392 dsp_rec_stop(dev); 393 dsp_rec_stop(dev);
393 dsp_rec_start(dev); 394 dsp_rec_start(dev);
394 } 395 }
395 up(&dev->oss.lock); 396 up(&dev->dmasound.lock);
396 return put_user(dev->oss.channels-1, p); 397 return put_user(dev->dmasound.channels-1, p);
397 398
398 case SNDCTL_DSP_CHANNELS: 399 case SNDCTL_DSP_CHANNELS:
399 if (get_user(val, p)) 400 if (get_user(val, p))
400 return -EFAULT; 401 return -EFAULT;
401 if (val != 1 && val != 2) 402 if (val != 1 && val != 2)
402 return -EINVAL; 403 return -EINVAL;
403 down(&dev->oss.lock); 404 down(&dev->dmasound.lock);
404 dev->oss.channels = val; 405 dev->dmasound.channels = val;
405 if (dev->oss.recording_on) { 406 if (dev->dmasound.recording_on) {
406 dsp_rec_stop(dev); 407 dsp_rec_stop(dev);
407 dsp_rec_start(dev); 408 dsp_rec_start(dev);
408 } 409 }
409 up(&dev->oss.lock); 410 up(&dev->dmasound.lock);
410 /* fall through */ 411 /* fall through */
411 case SOUND_PCM_READ_CHANNELS: 412 case SOUND_PCM_READ_CHANNELS:
412 return put_user(dev->oss.channels, p); 413 return put_user(dev->dmasound.channels, p);
413 414
414 case SNDCTL_DSP_GETFMTS: /* Returns a mask */ 415 case SNDCTL_DSP_GETFMTS: /* Returns a mask */
415 return put_user(AFMT_U8 | AFMT_S8 | 416 return put_user(AFMT_U8 | AFMT_S8 |
416 AFMT_U16_LE | AFMT_U16_BE | 417 AFMT_U16_LE | AFMT_U16_BE |
417 AFMT_S16_LE | AFMT_S16_BE, p); 418 AFMT_S16_LE | AFMT_S16_BE, p);
418 419
419 case SNDCTL_DSP_SETFMT: /* Selects ONE fmt */ 420 case SNDCTL_DSP_SETFMT: /* Selects ONE fmt */
420 if (get_user(val, p)) 421 if (get_user(val, p))
421 return -EFAULT; 422 return -EFAULT;
422 switch (val) { 423 switch (val) {
@@ -429,20 +430,20 @@ static int dsp_ioctl(struct inode *inode, struct file *file,
429 case AFMT_U16_BE: 430 case AFMT_U16_BE:
430 case AFMT_S16_LE: 431 case AFMT_S16_LE:
431 case AFMT_S16_BE: 432 case AFMT_S16_BE:
432 down(&dev->oss.lock); 433 down(&dev->dmasound.lock);
433 dev->oss.afmt = val; 434 dev->dmasound.afmt = val;
434 if (dev->oss.recording_on) { 435 if (dev->dmasound.recording_on) {
435 dsp_rec_stop(dev); 436 dsp_rec_stop(dev);
436 dsp_rec_start(dev); 437 dsp_rec_start(dev);
437 } 438 }
438 up(&dev->oss.lock); 439 up(&dev->dmasound.lock);
439 return put_user(dev->oss.afmt, p); 440 return put_user(dev->dmasound.afmt, p);
440 default: 441 default:
441 return -EINVAL; 442 return -EINVAL;
442 } 443 }
443 444
444 case SOUND_PCM_READ_BITS: 445 case SOUND_PCM_READ_BITS:
445 switch (dev->oss.afmt) { 446 switch (dev->dmasound.afmt) {
446 case AFMT_U8: 447 case AFMT_U8:
447 case AFMT_S8: 448 case AFMT_S8:
448 return put_user(8, p); 449 return put_user(8, p);
@@ -455,23 +456,23 @@ static int dsp_ioctl(struct inode *inode, struct file *file,
455 return -EINVAL; 456 return -EINVAL;
456 } 457 }
457 458
458 case SNDCTL_DSP_NONBLOCK: 459 case SNDCTL_DSP_NONBLOCK:
459 file->f_flags |= O_NONBLOCK; 460 file->f_flags |= O_NONBLOCK;
460 return 0; 461 return 0;
461 462
462 case SNDCTL_DSP_RESET: 463 case SNDCTL_DSP_RESET:
463 down(&dev->oss.lock); 464 down(&dev->dmasound.lock);
464 if (dev->oss.recording_on) 465 if (dev->dmasound.recording_on)
465 dsp_rec_stop(dev); 466 dsp_rec_stop(dev);
466 up(&dev->oss.lock); 467 up(&dev->dmasound.lock);
467 return 0; 468 return 0;
468 case SNDCTL_DSP_GETBLKSIZE: 469 case SNDCTL_DSP_GETBLKSIZE:
469 return put_user(dev->oss.blksize, p); 470 return put_user(dev->dmasound.blksize, p);
470 471
471 case SNDCTL_DSP_SETFRAGMENT: 472 case SNDCTL_DSP_SETFRAGMENT:
472 if (get_user(val, p)) 473 if (get_user(val, p))
473 return -EFAULT; 474 return -EFAULT;
474 if (dev->oss.recording_on) 475 if (dev->dmasound.recording_on)
475 return -EBUSY; 476 return -EBUSY;
476 dsp_buffer_free(dev); 477 dsp_buffer_free(dev);
477 /* used to be arg >> 16 instead of val >> 16; fixed */ 478 /* used to be arg >> 16 instead of val >> 16; fixed */
@@ -479,16 +480,16 @@ static int dsp_ioctl(struct inode *inode, struct file *file,
479 dsp_buffer_init(dev); 480 dsp_buffer_init(dev);
480 return 0; 481 return 0;
481 482
482 case SNDCTL_DSP_SYNC: 483 case SNDCTL_DSP_SYNC:
483 /* NOP */ 484 /* NOP */
484 return 0; 485 return 0;
485 486
486 case SNDCTL_DSP_GETISPACE: 487 case SNDCTL_DSP_GETISPACE:
487 { 488 {
488 audio_buf_info info; 489 audio_buf_info info;
489 info.fragsize = dev->oss.blksize; 490 info.fragsize = dev->dmasound.blksize;
490 info.fragstotal = dev->oss.blocks; 491 info.fragstotal = dev->dmasound.blocks;
491 info.bytes = dev->oss.read_count; 492 info.bytes = dev->dmasound.read_count;
492 info.fragments = info.bytes / info.fragsize; 493 info.fragments = info.bytes / info.fragsize;
493 if (copy_to_user(argp, &info, sizeof(info))) 494 if (copy_to_user(argp, &info, sizeof(info)))
494 return -EFAULT; 495 return -EFAULT;
@@ -504,13 +505,13 @@ static unsigned int dsp_poll(struct file *file, struct poll_table_struct *wait)
504 struct saa7134_dev *dev = file->private_data; 505 struct saa7134_dev *dev = file->private_data;
505 unsigned int mask = 0; 506 unsigned int mask = 0;
506 507
507 poll_wait(file, &dev->oss.wq, wait); 508 poll_wait(file, &dev->dmasound.wq, wait);
508 509
509 if (0 == dev->oss.read_count) { 510 if (0 == dev->dmasound.read_count) {
510 down(&dev->oss.lock); 511 down(&dev->dmasound.lock);
511 if (!dev->oss.recording_on) 512 if (!dev->dmasound.recording_on)
512 dsp_rec_start(dev); 513 dsp_rec_start(dev);
513 up(&dev->oss.lock); 514 up(&dev->dmasound.lock);
514 } else 515 } else
515 mask |= (POLLIN | POLLRDNORM); 516 mask |= (POLLIN | POLLRDNORM);
516 return mask; 517 return mask;
@@ -534,7 +535,7 @@ mixer_recsrc_7134(struct saa7134_dev *dev)
534{ 535{
535 int analog_io,rate; 536 int analog_io,rate;
536 537
537 switch (dev->oss.input) { 538 switch (dev->dmasound.input) {
538 case TV: 539 case TV:
539 saa_andorb(SAA7134_AUDIO_FORMAT_CTRL, 0xc0, 0xc0); 540 saa_andorb(SAA7134_AUDIO_FORMAT_CTRL, 0xc0, 0xc0);
540 saa_andorb(SAA7134_SIF_SAMPLE_FREQ, 0x03, 0x00); 541 saa_andorb(SAA7134_SIF_SAMPLE_FREQ, 0x03, 0x00);
@@ -542,8 +543,8 @@ mixer_recsrc_7134(struct saa7134_dev *dev)
542 case LINE1: 543 case LINE1:
543 case LINE2: 544 case LINE2:
544 case LINE2_LEFT: 545 case LINE2_LEFT:
545 analog_io = (LINE1 == dev->oss.input) ? 0x00 : 0x08; 546 analog_io = (LINE1 == dev->dmasound.input) ? 0x00 : 0x08;
546 rate = (32000 == dev->oss.rate) ? 0x01 : 0x03; 547 rate = (32000 == dev->dmasound.rate) ? 0x01 : 0x03;
547 saa_andorb(SAA7134_ANALOG_IO_SELECT, 0x08, analog_io); 548 saa_andorb(SAA7134_ANALOG_IO_SELECT, 0x08, analog_io);
548 saa_andorb(SAA7134_AUDIO_FORMAT_CTRL, 0xc0, 0x80); 549 saa_andorb(SAA7134_AUDIO_FORMAT_CTRL, 0xc0, 0x80);
549 saa_andorb(SAA7134_SIF_SAMPLE_FREQ, 0x03, rate); 550 saa_andorb(SAA7134_SIF_SAMPLE_FREQ, 0x03, rate);
@@ -559,10 +560,10 @@ mixer_recsrc_7133(struct saa7134_dev *dev)
559 560
560 xbarin = 0x03; // adc 561 xbarin = 0x03; // adc
561 anabar = 0; 562 anabar = 0;
562 switch (dev->oss.input) { 563 switch (dev->dmasound.input) {
563 case TV: 564 case TV:
564 xbarin = 0; // Demodulator 565 xbarin = 0; // Demodulator
565 anabar = 2; // DACs 566 anabar = 2; // DACs
566 break; 567 break;
567 case LINE1: 568 case LINE1:
568 anabar = 0; // aux1, aux1 569 anabar = 0; // aux1, aux1
@@ -585,9 +586,9 @@ mixer_recsrc(struct saa7134_dev *dev, enum saa7134_audio_in src)
585{ 586{
586 static const char *iname[] = { "Oops", "TV", "LINE1", "LINE2" }; 587 static const char *iname[] = { "Oops", "TV", "LINE1", "LINE2" };
587 588
588 dev->oss.count++; 589 dev->dmasound.count++;
589 dev->oss.input = src; 590 dev->dmasound.input = src;
590 dprintk("mixer input = %s\n",iname[dev->oss.input]); 591 dprintk("mixer input = %s\n",iname[dev->dmasound.input]);
591 592
592 switch (dev->pci->device) { 593 switch (dev->pci->device) {
593 case PCI_DEVICE_ID_PHILIPS_SAA7134: 594 case PCI_DEVICE_ID_PHILIPS_SAA7134:
@@ -639,7 +640,7 @@ static int mixer_open(struct inode *inode, struct file *file)
639 640
640 list_for_each(list,&saa7134_devlist) { 641 list_for_each(list,&saa7134_devlist) {
641 h = list_entry(list, struct saa7134_dev, devlist); 642 h = list_entry(list, struct saa7134_dev, devlist);
642 if (h->oss.minor_mixer == minor) 643 if (h->dmasound.minor_mixer == minor)
643 dev = h; 644 dev = h;
644 } 645 }
645 if (NULL == dev) 646 if (NULL == dev)
@@ -666,28 +667,28 @@ static int mixer_ioctl(struct inode *inode, struct file *file,
666 667
667 if (oss_debug > 1) 668 if (oss_debug > 1)
668 saa7134_print_ioctl(dev->name,cmd); 669 saa7134_print_ioctl(dev->name,cmd);
669 switch (cmd) { 670 switch (cmd) {
670 case OSS_GETVERSION: 671 case OSS_GETVERSION:
671 return put_user(SOUND_VERSION, p); 672 return put_user(SOUND_VERSION, p);
672 case SOUND_MIXER_INFO: 673 case SOUND_MIXER_INFO:
673 { 674 {
674 mixer_info info; 675 mixer_info info;
675 memset(&info,0,sizeof(info)); 676 memset(&info,0,sizeof(info));
676 strlcpy(info.id, "TV audio", sizeof(info.id)); 677 strlcpy(info.id, "TV audio", sizeof(info.id));
677 strlcpy(info.name, dev->name, sizeof(info.name)); 678 strlcpy(info.name, dev->name, sizeof(info.name));
678 info.modify_counter = dev->oss.count; 679 info.modify_counter = dev->dmasound.count;
679 if (copy_to_user(argp, &info, sizeof(info))) 680 if (copy_to_user(argp, &info, sizeof(info)))
680 return -EFAULT; 681 return -EFAULT;
681 return 0; 682 return 0;
682 } 683 }
683 case SOUND_OLD_MIXER_INFO: 684 case SOUND_OLD_MIXER_INFO:
684 { 685 {
685 _old_mixer_info info; 686 _old_mixer_info info;
686 memset(&info,0,sizeof(info)); 687 memset(&info,0,sizeof(info));
687 strlcpy(info.id, "TV audio", sizeof(info.id)); 688 strlcpy(info.id, "TV audio", sizeof(info.id));
688 strlcpy(info.name, dev->name, sizeof(info.name)); 689 strlcpy(info.name, dev->name, sizeof(info.name));
689 if (copy_to_user(argp, &info, sizeof(info))) 690 if (copy_to_user(argp, &info, sizeof(info)))
690 return -EFAULT; 691 return -EFAULT;
691 return 0; 692 return 0;
692 } 693 }
693 case MIXER_READ(SOUND_MIXER_CAPS): 694 case MIXER_READ(SOUND_MIXER_CAPS):
@@ -697,26 +698,26 @@ static int mixer_ioctl(struct inode *inode, struct file *file,
697 case MIXER_READ(SOUND_MIXER_RECMASK): 698 case MIXER_READ(SOUND_MIXER_RECMASK):
698 case MIXER_READ(SOUND_MIXER_DEVMASK): 699 case MIXER_READ(SOUND_MIXER_DEVMASK):
699 val = SOUND_MASK_LINE1 | SOUND_MASK_LINE2; 700 val = SOUND_MASK_LINE1 | SOUND_MASK_LINE2;
700 if (32000 == dev->oss.rate) 701 if (32000 == dev->dmasound.rate)
701 val |= SOUND_MASK_VIDEO; 702 val |= SOUND_MASK_VIDEO;
702 return put_user(val, p); 703 return put_user(val, p);
703 704
704 case MIXER_WRITE(SOUND_MIXER_RECSRC): 705 case MIXER_WRITE(SOUND_MIXER_RECSRC):
705 if (get_user(val, p)) 706 if (get_user(val, p))
706 return -EFAULT; 707 return -EFAULT;
707 input = dev->oss.input; 708 input = dev->dmasound.input;
708 if (32000 == dev->oss.rate && 709 if (32000 == dev->dmasound.rate &&
709 val & SOUND_MASK_VIDEO && dev->oss.input != TV) 710 val & SOUND_MASK_VIDEO && dev->dmasound.input != TV)
710 input = TV; 711 input = TV;
711 if (val & SOUND_MASK_LINE1 && dev->oss.input != LINE1) 712 if (val & SOUND_MASK_LINE1 && dev->dmasound.input != LINE1)
712 input = LINE1; 713 input = LINE1;
713 if (val & SOUND_MASK_LINE2 && dev->oss.input != LINE2) 714 if (val & SOUND_MASK_LINE2 && dev->dmasound.input != LINE2)
714 input = LINE2; 715 input = LINE2;
715 if (input != dev->oss.input) 716 if (input != dev->dmasound.input)
716 mixer_recsrc(dev,input); 717 mixer_recsrc(dev,input);
717 /* fall throuth */ 718 /* fall throuth */
718 case MIXER_READ(SOUND_MIXER_RECSRC): 719 case MIXER_READ(SOUND_MIXER_RECSRC):
719 switch (dev->oss.input) { 720 switch (dev->dmasound.input) {
720 case TV: ret = SOUND_MASK_VIDEO; break; 721 case TV: ret = SOUND_MASK_VIDEO; break;
721 case LINE1: ret = SOUND_MASK_LINE1; break; 722 case LINE1: ret = SOUND_MASK_LINE1; break;
722 case LINE2: ret = SOUND_MASK_LINE2; break; 723 case LINE2: ret = SOUND_MASK_LINE2; break;
@@ -726,7 +727,7 @@ static int mixer_ioctl(struct inode *inode, struct file *file,
726 727
727 case MIXER_WRITE(SOUND_MIXER_VIDEO): 728 case MIXER_WRITE(SOUND_MIXER_VIDEO):
728 case MIXER_READ(SOUND_MIXER_VIDEO): 729 case MIXER_READ(SOUND_MIXER_VIDEO):
729 if (32000 != dev->oss.rate) 730 if (32000 != dev->dmasound.rate)
730 return -EINVAL; 731 return -EINVAL;
731 return put_user(100 | 100 << 8, p); 732 return put_user(100 | 100 << 8, p);
732 733
@@ -735,22 +736,22 @@ static int mixer_ioctl(struct inode *inode, struct file *file,
735 return -EFAULT; 736 return -EFAULT;
736 val &= 0xff; 737 val &= 0xff;
737 val = (val <= 50) ? 50 : 100; 738 val = (val <= 50) ? 50 : 100;
738 dev->oss.line1 = val; 739 dev->dmasound.line1 = val;
739 mixer_level(dev,LINE1,dev->oss.line1); 740 mixer_level(dev,LINE1,dev->dmasound.line1);
740 /* fall throuth */ 741 /* fall throuth */
741 case MIXER_READ(SOUND_MIXER_LINE1): 742 case MIXER_READ(SOUND_MIXER_LINE1):
742 return put_user(dev->oss.line1 | dev->oss.line1 << 8, p); 743 return put_user(dev->dmasound.line1 | dev->dmasound.line1 << 8, p);
743 744
744 case MIXER_WRITE(SOUND_MIXER_LINE2): 745 case MIXER_WRITE(SOUND_MIXER_LINE2):
745 if (get_user(val, p)) 746 if (get_user(val, p))
746 return -EFAULT; 747 return -EFAULT;
747 val &= 0xff; 748 val &= 0xff;
748 val = (val <= 50) ? 50 : 100; 749 val = (val <= 50) ? 50 : 100;
749 dev->oss.line2 = val; 750 dev->dmasound.line2 = val;
750 mixer_level(dev,LINE2,dev->oss.line2); 751 mixer_level(dev,LINE2,dev->dmasound.line2);
751 /* fall throuth */ 752 /* fall throuth */
752 case MIXER_READ(SOUND_MIXER_LINE2): 753 case MIXER_READ(SOUND_MIXER_LINE2):
753 return put_user(dev->oss.line2 | dev->oss.line2 << 8, p); 754 return put_user(dev->dmasound.line2 | dev->dmasound.line2 << 8, p);
754 755
755 default: 756 default:
756 return -EINVAL; 757 return -EINVAL;
@@ -770,8 +771,8 @@ struct file_operations saa7134_mixer_fops = {
770int saa7134_oss_init1(struct saa7134_dev *dev) 771int saa7134_oss_init1(struct saa7134_dev *dev)
771{ 772{
772 /* general */ 773 /* general */
773 init_MUTEX(&dev->oss.lock); 774 init_MUTEX(&dev->dmasound.lock);
774 init_waitqueue_head(&dev->oss.wq); 775 init_waitqueue_head(&dev->dmasound.wq);
775 776
776 switch (dev->pci->device) { 777 switch (dev->pci->device) {
777 case PCI_DEVICE_ID_PHILIPS_SAA7133: 778 case PCI_DEVICE_ID_PHILIPS_SAA7133:
@@ -783,17 +784,17 @@ int saa7134_oss_init1(struct saa7134_dev *dev)
783 } 784 }
784 785
785 /* dsp */ 786 /* dsp */
786 dev->oss.rate = 32000; 787 dev->dmasound.rate = 32000;
787 if (oss_rate) 788 if (oss_rate)
788 dev->oss.rate = oss_rate; 789 dev->dmasound.rate = oss_rate;
789 dev->oss.rate = (dev->oss.rate > 40000) ? 48000 : 32000; 790 dev->dmasound.rate = (dev->dmasound.rate > 40000) ? 48000 : 32000;
790 791
791 /* mixer */ 792 /* mixer */
792 dev->oss.line1 = 50; 793 dev->dmasound.line1 = 50;
793 dev->oss.line2 = 50; 794 dev->dmasound.line2 = 50;
794 mixer_level(dev,LINE1,dev->oss.line1); 795 mixer_level(dev,LINE1,dev->dmasound.line1);
795 mixer_level(dev,LINE2,dev->oss.line2); 796 mixer_level(dev,LINE2,dev->dmasound.line2);
796 mixer_recsrc(dev, (dev->oss.rate == 32000) ? TV : LINE2); 797 mixer_recsrc(dev, (dev->dmasound.rate == 32000) ? TV : LINE2);
797 798
798 return 0; 799 return 0;
799} 800}
@@ -809,7 +810,7 @@ void saa7134_irq_oss_done(struct saa7134_dev *dev, unsigned long status)
809 int next_blk, reg = 0; 810 int next_blk, reg = 0;
810 811
811 spin_lock(&dev->slock); 812 spin_lock(&dev->slock);
812 if (UNSET == dev->oss.dma_blk) { 813 if (UNSET == dev->dmasound.dma_blk) {
813 dprintk("irq: recording stopped\n"); 814 dprintk("irq: recording stopped\n");
814 goto done; 815 goto done;
815 } 816 }
@@ -817,11 +818,11 @@ void saa7134_irq_oss_done(struct saa7134_dev *dev, unsigned long status)
817 dprintk("irq: lost %ld\n", (status >> 24) & 0x0f); 818 dprintk("irq: lost %ld\n", (status >> 24) & 0x0f);
818 if (0 == (status & 0x10000000)) { 819 if (0 == (status & 0x10000000)) {
819 /* odd */ 820 /* odd */
820 if (0 == (dev->oss.dma_blk & 0x01)) 821 if (0 == (dev->dmasound.dma_blk & 0x01))
821 reg = SAA7134_RS_BA1(6); 822 reg = SAA7134_RS_BA1(6);
822 } else { 823 } else {
823 /* even */ 824 /* even */
824 if (1 == (dev->oss.dma_blk & 0x01)) 825 if (1 == (dev->dmasound.dma_blk & 0x01))
825 reg = SAA7134_RS_BA2(6); 826 reg = SAA7134_RS_BA2(6);
826 } 827 }
827 if (0 == reg) { 828 if (0 == reg) {
@@ -829,25 +830,25 @@ void saa7134_irq_oss_done(struct saa7134_dev *dev, unsigned long status)
829 (status & 0x10000000) ? "even" : "odd"); 830 (status & 0x10000000) ? "even" : "odd");
830 goto done; 831 goto done;
831 } 832 }
832 if (dev->oss.read_count >= dev->oss.blksize * (dev->oss.blocks-2)) { 833 if (dev->dmasound.read_count >= dev->dmasound.blksize * (dev->dmasound.blocks-2)) {
833 dprintk("irq: overrun [full=%d/%d]\n",dev->oss.read_count, 834 dprintk("irq: overrun [full=%d/%d]\n",dev->dmasound.read_count,
834 dev->oss.bufsize); 835 dev->dmasound.bufsize);
835 dsp_dma_stop(dev); 836 dsp_dma_stop(dev);
836 goto done; 837 goto done;
837 } 838 }
838 839
839 /* next block addr */ 840 /* next block addr */
840 next_blk = (dev->oss.dma_blk + 2) % dev->oss.blocks; 841 next_blk = (dev->dmasound.dma_blk + 2) % dev->dmasound.blocks;
841 saa_writel(reg,next_blk * dev->oss.blksize); 842 saa_writel(reg,next_blk * dev->dmasound.blksize);
842 if (oss_debug > 2) 843 if (oss_debug > 2)
843 dprintk("irq: ok, %s, next_blk=%d, addr=%x\n", 844 dprintk("irq: ok, %s, next_blk=%d, addr=%x\n",
844 (status & 0x10000000) ? "even" : "odd ", next_blk, 845 (status & 0x10000000) ? "even" : "odd ", next_blk,
845 next_blk * dev->oss.blksize); 846 next_blk * dev->dmasound.blksize);
846 847
847 /* update status & wake waiting readers */ 848 /* update status & wake waiting readers */
848 dev->oss.dma_blk = (dev->oss.dma_blk + 1) % dev->oss.blocks; 849 dev->dmasound.dma_blk = (dev->dmasound.dma_blk + 1) % dev->dmasound.blocks;
849 dev->oss.read_count += dev->oss.blksize; 850 dev->dmasound.read_count += dev->dmasound.blksize;
850 wake_up(&dev->oss.wq); 851 wake_up(&dev->dmasound.wq);
851 852
852 done: 853 done:
853 spin_unlock(&dev->slock); 854 spin_unlock(&dev->slock);