~ubuntu-branches/ubuntu/lucid/linux-rt/lucid

« back to all changes in this revision

Viewing changes to sound/core/oss/pcm_oss.c

  • Committer: Bazaar Package Importer
  • Author(s): Luke Yelavich
  • Date: 2009-08-05 23:00:52 UTC
  • Revision ID: james.westby@ubuntu.com-20090805230052-7xedvqcyk9dnnxb2
Tags: 2.6.31-1.1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include <linux/time.h>
32
32
#include <linux/vmalloc.h>
33
33
#include <linux/moduleparam.h>
 
34
#include <linux/math64.h>
34
35
#include <linux/string.h>
35
36
#include <sound/core.h>
36
37
#include <sound/minors.h>
617
618
#else
618
619
        {
619
620
                u64 bsize = (u64)runtime->oss.buffer_bytes * (u64)bytes;
620
 
                u32 rem;
621
 
                div64_32(&bsize, buffer_size, &rem);
622
 
                return (long)bsize;
 
621
                return div_u64(bsize, buffer_size);
623
622
        }
624
623
#endif
625
624
}
1160
1159
                    runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) {
1161
1160
#ifdef OSS_DEBUG
1162
1161
                        if (runtime->status->state == SNDRV_PCM_STATE_XRUN)
1163
 
                                printk("pcm_oss: write: recovering from XRUN\n");
 
1162
                                printk(KERN_DEBUG "pcm_oss: write: "
 
1163
                                       "recovering from XRUN\n");
1164
1164
                        else
1165
 
                                printk("pcm_oss: write: recovering from SUSPEND\n");
 
1165
                                printk(KERN_DEBUG "pcm_oss: write: "
 
1166
                                       "recovering from SUSPEND\n");
1166
1167
#endif
1167
1168
                        ret = snd_pcm_oss_prepare(substream);
1168
1169
                        if (ret < 0)
1196
1197
                    runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) {
1197
1198
#ifdef OSS_DEBUG
1198
1199
                        if (runtime->status->state == SNDRV_PCM_STATE_XRUN)
1199
 
                                printk("pcm_oss: read: recovering from XRUN\n");
 
1200
                                printk(KERN_DEBUG "pcm_oss: read: "
 
1201
                                       "recovering from XRUN\n");
1200
1202
                        else
1201
 
                                printk("pcm_oss: read: recovering from SUSPEND\n");
 
1203
                                printk(KERN_DEBUG "pcm_oss: read: "
 
1204
                                       "recovering from SUSPEND\n");
1202
1205
#endif
1203
1206
                        ret = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DRAIN, NULL);
1204
1207
                        if (ret < 0)
1242
1245
                    runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) {
1243
1246
#ifdef OSS_DEBUG
1244
1247
                        if (runtime->status->state == SNDRV_PCM_STATE_XRUN)
1245
 
                                printk("pcm_oss: writev: recovering from XRUN\n");
 
1248
                                printk(KERN_DEBUG "pcm_oss: writev: "
 
1249
                                       "recovering from XRUN\n");
1246
1250
                        else
1247
 
                                printk("pcm_oss: writev: recovering from SUSPEND\n");
 
1251
                                printk(KERN_DEBUG "pcm_oss: writev: "
 
1252
                                       "recovering from SUSPEND\n");
1248
1253
#endif
1249
1254
                        ret = snd_pcm_oss_prepare(substream);
1250
1255
                        if (ret < 0)
1278
1283
                    runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) {
1279
1284
#ifdef OSS_DEBUG
1280
1285
                        if (runtime->status->state == SNDRV_PCM_STATE_XRUN)
1281
 
                                printk("pcm_oss: readv: recovering from XRUN\n");
 
1286
                                printk(KERN_DEBUG "pcm_oss: readv: "
 
1287
                                       "recovering from XRUN\n");
1282
1288
                        else
1283
 
                                printk("pcm_oss: readv: recovering from SUSPEND\n");
 
1289
                                printk(KERN_DEBUG "pcm_oss: readv: "
 
1290
                                       "recovering from SUSPEND\n");
1284
1291
#endif
1285
1292
                        ret = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DRAIN, NULL);
1286
1293
                        if (ret < 0)
1533
1540
        init_waitqueue_entry(&wait, current);
1534
1541
        add_wait_queue(&runtime->sleep, &wait);
1535
1542
#ifdef OSS_DEBUG
1536
 
        printk("sync1: size = %li\n", size);
 
1543
        printk(KERN_DEBUG "sync1: size = %li\n", size);
1537
1544
#endif
1538
1545
        while (1) {
1539
1546
                result = snd_pcm_oss_write2(substream, runtime->oss.buffer, size, 1);
1590
1597
                mutex_lock(&runtime->oss.params_lock);
1591
1598
                if (runtime->oss.buffer_used > 0) {
1592
1599
#ifdef OSS_DEBUG
1593
 
                        printk("sync: buffer_used\n");
 
1600
                        printk(KERN_DEBUG "sync: buffer_used\n");
1594
1601
#endif
1595
1602
                        size = (8 * (runtime->oss.period_bytes - runtime->oss.buffer_used) + 7) / width;
1596
1603
                        snd_pcm_format_set_silence(format,
1603
1610
                        }
1604
1611
                } else if (runtime->oss.period_ptr > 0) {
1605
1612
#ifdef OSS_DEBUG
1606
 
                        printk("sync: period_ptr\n");
 
1613
                        printk(KERN_DEBUG "sync: period_ptr\n");
1607
1614
#endif
1608
1615
                        size = runtime->oss.period_bytes - runtime->oss.period_ptr;
1609
1616
                        snd_pcm_format_set_silence(format,
1895
1902
 
1896
1903
static int snd_pcm_oss_nonblock(struct file * file)
1897
1904
{
 
1905
        spin_lock(&file->f_lock);
1898
1906
        file->f_flags |= O_NONBLOCK;
 
1907
        spin_unlock(&file->f_lock);
1899
1908
        return 0;
1900
1909
}
1901
1910
 
1952
1961
        int err, cmd;
1953
1962
 
1954
1963
#ifdef OSS_DEBUG
1955
 
        printk("pcm_oss: trigger = 0x%x\n", trigger);
 
1964
        printk(KERN_DEBUG "pcm_oss: trigger = 0x%x\n", trigger);
1956
1965
#endif
1957
1966
        
1958
1967
        psubstream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK];
2170
2179
        }
2171
2180
 
2172
2181
#ifdef OSS_DEBUG
2173
 
        printk("pcm_oss: space: bytes = %i, fragments = %i, fragstotal = %i, fragsize = %i\n", info.bytes, info.fragments, info.fragstotal, info.fragsize);
 
2182
        printk(KERN_DEBUG "pcm_oss: space: bytes = %i, fragments = %i, "
 
2183
               "fragstotal = %i, fragsize = %i\n",
 
2184
               info.bytes, info.fragments, info.fragstotal, info.fragsize);
2174
2185
#endif
2175
2186
        if (copy_to_user(_info, &info, sizeof(info)))
2176
2187
                return -EFAULT;
2473
2484
        if (((cmd >> 8) & 0xff) != 'P')
2474
2485
                return -EINVAL;
2475
2486
#ifdef OSS_DEBUG
2476
 
        printk("pcm_oss: ioctl = 0x%x\n", cmd);
 
2487
        printk(KERN_DEBUG "pcm_oss: ioctl = 0x%x\n", cmd);
2477
2488
#endif
2478
2489
        switch (cmd) {
2479
2490
        case SNDCTL_DSP_RESET:
2627
2638
#else
2628
2639
        {
2629
2640
                ssize_t res = snd_pcm_oss_read1(substream, buf, count);
2630
 
                printk("pcm_oss: read %li bytes (returned %li bytes)\n", (long)count, (long)res);
 
2641
                printk(KERN_DEBUG "pcm_oss: read %li bytes "
 
2642
                       "(returned %li bytes)\n", (long)count, (long)res);
2631
2643
                return res;
2632
2644
        }
2633
2645
#endif
2646
2658
        substream->f_flags = file->f_flags & O_NONBLOCK;
2647
2659
        result = snd_pcm_oss_write1(substream, buf, count);
2648
2660
#ifdef OSS_DEBUG
2649
 
        printk("pcm_oss: write %li bytes (wrote %li bytes)\n", (long)count, (long)result);
 
2661
        printk(KERN_DEBUG "pcm_oss: write %li bytes (wrote %li bytes)\n",
 
2662
               (long)count, (long)result);
2650
2663
#endif
2651
2664
        return result;
2652
2665
}
2720
2733
        int err;
2721
2734
 
2722
2735
#ifdef OSS_DEBUG
2723
 
        printk("pcm_oss: mmap begin\n");
 
2736
        printk(KERN_DEBUG "pcm_oss: mmap begin\n");
2724
2737
#endif
2725
2738
        pcm_oss_file = file->private_data;
2726
2739
        switch ((area->vm_flags & (VM_READ | VM_WRITE))) {
2770
2783
        runtime->silence_threshold = 0;
2771
2784
        runtime->silence_size = 0;
2772
2785
#ifdef OSS_DEBUG
2773
 
        printk("pcm_oss: mmap ok, bytes = 0x%x\n", runtime->oss.mmap_bytes);
 
2786
        printk(KERN_DEBUG "pcm_oss: mmap ok, bytes = 0x%x\n",
 
2787
               runtime->oss.mmap_bytes);
2774
2788
#endif
2775
2789
        /* In mmap mode we never stop */
2776
2790
        runtime->stop_threshold = runtime->boundary;