diff options
-rw-r--r-- | drivers/media/video/saa7134/saa7134-alsa.c | 239 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134-core.c | 27 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134-oss.c | 308 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134.h | 6 |
4 files changed, 288 insertions, 292 deletions
diff --git a/drivers/media/video/saa7134/saa7134-alsa.c b/drivers/media/video/saa7134/saa7134-alsa.c index 7972939cb46c..4f3c42354329 100644 --- a/drivers/media/video/saa7134/saa7134-alsa.c +++ b/drivers/media/video/saa7134/saa7134-alsa.c | |||
@@ -30,7 +30,6 @@ | |||
30 | #include <sound/core.h> | 30 | #include <sound/core.h> |
31 | #include <sound/control.h> | 31 | #include <sound/control.h> |
32 | #include <sound/pcm.h> | 32 | #include <sound/pcm.h> |
33 | #include <sound/rawmidi.h> | ||
34 | #include <sound/initval.h> | 33 | #include <sound/initval.h> |
35 | 34 | ||
36 | #include "saa7134.h" | 35 | #include "saa7134.h" |
@@ -40,29 +39,11 @@ static unsigned int debug = 0; | |||
40 | module_param(debug, int, 0644); | 39 | module_param(debug, int, 0644); |
41 | MODULE_PARM_DESC(debug,"enable debug messages [alsa]"); | 40 | MODULE_PARM_DESC(debug,"enable debug messages [alsa]"); |
42 | 41 | ||
43 | unsigned int dsp_nr = 0; | ||
44 | module_param(dsp_nr, int, 0444); | ||
45 | MODULE_PARM_DESC(dsp_nr, "alsa device number"); | ||
46 | |||
47 | /* | 42 | /* |
48 | * Configuration macros | 43 | * Configuration macros |
49 | */ | 44 | */ |
50 | 45 | ||
51 | /* defaults */ | 46 | /* defaults */ |
52 | #define MAX_BUFFER_SIZE (256*1024) | ||
53 | #define USE_FORMATS SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE | SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_U16_LE | SNDRV_PCM_FMTBIT_U16_BE | ||
54 | #define USE_RATE SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 | ||
55 | #define USE_RATE_MIN 32000 | ||
56 | #define USE_RATE_MAX 48000 | ||
57 | #define USE_CHANNELS_MIN 1 | ||
58 | #define USE_CHANNELS_MAX 2 | ||
59 | #ifndef USE_PERIODS_MIN | ||
60 | #define USE_PERIODS_MIN 2 | ||
61 | #endif | ||
62 | #ifndef USE_PERIODS_MAX | ||
63 | #define USE_PERIODS_MAX 1024 | ||
64 | #endif | ||
65 | |||
66 | #define MIXER_ADDR_TVTUNER 0 | 47 | #define MIXER_ADDR_TVTUNER 0 |
67 | #define MIXER_ADDR_LINE1 1 | 48 | #define MIXER_ADDR_LINE1 1 |
68 | #define MIXER_ADDR_LINE2 2 | 49 | #define MIXER_ADDR_LINE2 2 |
@@ -72,6 +53,9 @@ static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ | |||
72 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ | 53 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ |
73 | static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0}; | 54 | static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0}; |
74 | 55 | ||
56 | module_param_array(index, int, NULL, 0444); | ||
57 | MODULE_PARM_DESC(index, "Index value for SAA7134 capture interface(s)."); | ||
58 | |||
75 | #define dprintk(fmt, arg...) if (debug) \ | 59 | #define dprintk(fmt, arg...) if (debug) \ |
76 | printk(KERN_DEBUG "%s/alsa: " fmt, dev->name , ## arg) | 60 | printk(KERN_DEBUG "%s/alsa: " fmt, dev->name , ## arg) |
77 | 61 | ||
@@ -108,7 +92,7 @@ typedef struct snd_card_saa7134_pcm { | |||
108 | snd_pcm_substream_t *substream; | 92 | snd_pcm_substream_t *substream; |
109 | } snd_card_saa7134_pcm_t; | 93 | } snd_card_saa7134_pcm_t; |
110 | 94 | ||
111 | static snd_card_t *snd_saa7134_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; | 95 | static snd_card_t *snd_saa7134_cards[SNDRV_CARDS]; |
112 | 96 | ||
113 | 97 | ||
114 | /* | 98 | /* |
@@ -124,8 +108,8 @@ static snd_card_t *snd_saa7134_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; | |||
124 | static void saa7134_dma_stop(struct saa7134_dev *dev) | 108 | static void saa7134_dma_stop(struct saa7134_dev *dev) |
125 | 109 | ||
126 | { | 110 | { |
127 | dev->oss.dma_blk = -1; | 111 | dev->dmasound.dma_blk = -1; |
128 | dev->oss.dma_running = 0; | 112 | dev->dmasound.dma_running = 0; |
129 | saa7134_set_dmabits(dev); | 113 | saa7134_set_dmabits(dev); |
130 | } | 114 | } |
131 | 115 | ||
@@ -141,8 +125,8 @@ static void saa7134_dma_stop(struct saa7134_dev *dev) | |||
141 | 125 | ||
142 | static void saa7134_dma_start(struct saa7134_dev *dev) | 126 | static void saa7134_dma_start(struct saa7134_dev *dev) |
143 | { | 127 | { |
144 | dev->oss.dma_blk = 0; | 128 | dev->dmasound.dma_blk = 0; |
145 | dev->oss.dma_running = 1; | 129 | dev->dmasound.dma_running = 1; |
146 | saa7134_set_dmabits(dev); | 130 | saa7134_set_dmabits(dev); |
147 | } | 131 | } |
148 | 132 | ||
@@ -162,7 +146,7 @@ void saa7134_irq_alsa_done(struct saa7134_dev *dev, unsigned long status) | |||
162 | int next_blk, reg = 0; | 146 | int next_blk, reg = 0; |
163 | 147 | ||
164 | spin_lock(&dev->slock); | 148 | spin_lock(&dev->slock); |
165 | if (UNSET == dev->oss.dma_blk) { | 149 | if (UNSET == dev->dmasound.dma_blk) { |
166 | dprintk("irq: recording stopped\n"); | 150 | dprintk("irq: recording stopped\n"); |
167 | goto done; | 151 | goto done; |
168 | } | 152 | } |
@@ -170,11 +154,11 @@ void saa7134_irq_alsa_done(struct saa7134_dev *dev, unsigned long status) | |||
170 | dprintk("irq: lost %ld\n", (status >> 24) & 0x0f); | 154 | dprintk("irq: lost %ld\n", (status >> 24) & 0x0f); |
171 | if (0 == (status & 0x10000000)) { | 155 | if (0 == (status & 0x10000000)) { |
172 | /* odd */ | 156 | /* odd */ |
173 | if (0 == (dev->oss.dma_blk & 0x01)) | 157 | if (0 == (dev->dmasound.dma_blk & 0x01)) |
174 | reg = SAA7134_RS_BA1(6); | 158 | reg = SAA7134_RS_BA1(6); |
175 | } else { | 159 | } else { |
176 | /* even */ | 160 | /* even */ |
177 | if (1 == (dev->oss.dma_blk & 0x01)) | 161 | if (1 == (dev->dmasound.dma_blk & 0x01)) |
178 | reg = SAA7134_RS_BA2(6); | 162 | reg = SAA7134_RS_BA2(6); |
179 | } | 163 | } |
180 | if (0 == reg) { | 164 | if (0 == reg) { |
@@ -183,30 +167,31 @@ void saa7134_irq_alsa_done(struct saa7134_dev *dev, unsigned long status) | |||
183 | goto done; | 167 | goto done; |
184 | } | 168 | } |
185 | 169 | ||
186 | if (dev->oss.read_count >= dev->oss.blksize * (dev->oss.blocks-2)) { | 170 | if (dev->dmasound.read_count >= dev->dmasound.blksize * (dev->dmasound.blocks-2)) { |
187 | dprintk("irq: overrun [full=%d/%d] - Blocks in %d\n",dev->oss.read_count, | 171 | dprintk("irq: overrun [full=%d/%d] - Blocks in %d\n",dev->dmasound.read_count, |
188 | dev->oss.bufsize, dev->oss.blocks); | 172 | dev->dmasound.bufsize, dev->dmasound.blocks); |
173 | snd_pcm_stop(dev->dmasound.substream,SNDRV_PCM_STATE_XRUN); | ||
189 | saa7134_dma_stop(dev); | 174 | saa7134_dma_stop(dev); |
190 | goto done; | 175 | goto done; |
191 | } | 176 | } |
192 | 177 | ||
193 | /* next block addr */ | 178 | /* next block addr */ |
194 | next_blk = (dev->oss.dma_blk + 2) % dev->oss.blocks; | 179 | next_blk = (dev->dmasound.dma_blk + 2) % dev->dmasound.blocks; |
195 | saa_writel(reg,next_blk * dev->oss.blksize); | 180 | saa_writel(reg,next_blk * dev->dmasound.blksize); |
196 | if (debug > 2) | 181 | if (debug > 2) |
197 | dprintk("irq: ok, %s, next_blk=%d, addr=%x, blocks=%u, size=%u, read=%u\n", | 182 | dprintk("irq: ok, %s, next_blk=%d, addr=%x, blocks=%u, size=%u, read=%u\n", |
198 | (status & 0x10000000) ? "even" : "odd ", next_blk, | 183 | (status & 0x10000000) ? "even" : "odd ", next_blk, |
199 | next_blk * dev->oss.blksize, dev->oss.blocks, dev->oss.blksize, dev->oss.read_count); | 184 | next_blk * dev->dmasound.blksize, dev->dmasound.blocks, dev->dmasound.blksize, dev->dmasound.read_count); |
200 | 185 | ||
201 | /* update status & wake waiting readers */ | 186 | /* update status & wake waiting readers */ |
202 | dev->oss.dma_blk = (dev->oss.dma_blk + 1) % dev->oss.blocks; | 187 | dev->dmasound.dma_blk = (dev->dmasound.dma_blk + 1) % dev->dmasound.blocks; |
203 | dev->oss.read_count += dev->oss.blksize; | 188 | dev->dmasound.read_count += dev->dmasound.blksize; |
204 | 189 | ||
205 | dev->oss.recording_on = reg; | 190 | dev->dmasound.recording_on = reg; |
206 | 191 | ||
207 | if (dev->oss.read_count >= snd_pcm_lib_period_bytes(dev->oss.substream)) { | 192 | if (dev->dmasound.read_count >= snd_pcm_lib_period_bytes(dev->dmasound.substream)) { |
208 | spin_unlock(&dev->slock); | 193 | spin_unlock(&dev->slock); |
209 | snd_pcm_period_elapsed(dev->oss.substream); | 194 | snd_pcm_period_elapsed(dev->dmasound.substream); |
210 | spin_lock(&dev->slock); | 195 | spin_lock(&dev->slock); |
211 | } | 196 | } |
212 | done: | 197 | done: |
@@ -262,7 +247,24 @@ out: | |||
262 | static int snd_card_saa7134_capture_trigger(snd_pcm_substream_t * substream, | 247 | static int snd_card_saa7134_capture_trigger(snd_pcm_substream_t * substream, |
263 | int cmd) | 248 | int cmd) |
264 | { | 249 | { |
265 | return 0; | 250 | snd_pcm_runtime_t *runtime = substream->runtime; |
251 | snd_card_saa7134_pcm_t *saapcm = runtime->private_data; | ||
252 | struct saa7134_dev *dev=saapcm->saadev; | ||
253 | int err = 0; | ||
254 | |||
255 | spin_lock_irq(&dev->slock); | ||
256 | if (cmd == SNDRV_PCM_TRIGGER_START) { | ||
257 | /* start dma */ | ||
258 | saa7134_dma_start(dev); | ||
259 | } else if (cmd == SNDRV_PCM_TRIGGER_STOP) { | ||
260 | /* stop dma */ | ||
261 | saa7134_dma_stop(dev); | ||
262 | } else { | ||
263 | err = -EINVAL; | ||
264 | } | ||
265 | spin_unlock_irq(&dev->slock); | ||
266 | |||
267 | return err; | ||
266 | } | 268 | } |
267 | 269 | ||
268 | /* | 270 | /* |
@@ -289,9 +291,9 @@ static int dsp_buffer_conf(struct saa7134_dev *dev, int blksize, int blocks) | |||
289 | if ((blksize * blocks) > 1024*1024) | 291 | if ((blksize * blocks) > 1024*1024) |
290 | blocks = 1024*1024 / blksize; | 292 | blocks = 1024*1024 / blksize; |
291 | 293 | ||
292 | dev->oss.blocks = blocks; | 294 | dev->dmasound.blocks = blocks; |
293 | dev->oss.blksize = blksize; | 295 | dev->dmasound.blksize = blksize; |
294 | dev->oss.bufsize = blksize * blocks; | 296 | dev->dmasound.bufsize = blksize * blocks; |
295 | 297 | ||
296 | dprintk("buffer config: %d blocks / %d bytes, %d kB total\n", | 298 | dprintk("buffer config: %d blocks / %d bytes, %d kB total\n", |
297 | blocks,blksize,blksize * blocks / 1024); | 299 | blocks,blksize,blksize * blocks / 1024); |
@@ -313,11 +315,11 @@ static int dsp_buffer_init(struct saa7134_dev *dev) | |||
313 | { | 315 | { |
314 | int err; | 316 | int err; |
315 | 317 | ||
316 | if (!dev->oss.bufsize) | 318 | if (!dev->dmasound.bufsize) |
317 | BUG(); | 319 | BUG(); |
318 | videobuf_dma_init(&dev->oss.dma); | 320 | videobuf_dma_init(&dev->dmasound.dma); |
319 | err = videobuf_dma_init_kernel(&dev->oss.dma, PCI_DMA_FROMDEVICE, | 321 | err = videobuf_dma_init_kernel(&dev->dmasound.dma, PCI_DMA_FROMDEVICE, |
320 | (dev->oss.bufsize + PAGE_SIZE) >> PAGE_SHIFT); | 322 | (dev->dmasound.bufsize + PAGE_SIZE) >> PAGE_SHIFT); |
321 | if (0 != err) | 323 | if (0 != err) |
322 | return err; | 324 | return err; |
323 | return 0; | 325 | return 0; |
@@ -340,7 +342,6 @@ static int snd_card_saa7134_capture_prepare(snd_pcm_substream_t * substream) | |||
340 | snd_pcm_runtime_t *runtime = substream->runtime; | 342 | snd_pcm_runtime_t *runtime = substream->runtime; |
341 | int err, bswap, sign; | 343 | int err, bswap, sign; |
342 | u32 fmt, control; | 344 | u32 fmt, control; |
343 | unsigned long flags; | ||
344 | snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream); | 345 | snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream); |
345 | struct saa7134_dev *dev; | 346 | struct saa7134_dev *dev; |
346 | snd_card_saa7134_pcm_t *saapcm = runtime->private_data; | 347 | snd_card_saa7134_pcm_t *saapcm = runtime->private_data; |
@@ -351,7 +352,7 @@ static int snd_card_saa7134_capture_prepare(snd_pcm_substream_t * substream) | |||
351 | size = snd_pcm_lib_buffer_bytes(substream); | 352 | size = snd_pcm_lib_buffer_bytes(substream); |
352 | count = snd_pcm_lib_period_bytes(substream); | 353 | count = snd_pcm_lib_period_bytes(substream); |
353 | 354 | ||
354 | saapcm->saadev->oss.substream = substream; | 355 | saapcm->saadev->dmasound.substream = substream; |
355 | bps = runtime->rate * runtime->channels; | 356 | bps = runtime->rate * runtime->channels; |
356 | bps *= snd_pcm_format_width(runtime->format); | 357 | bps *= snd_pcm_format_width(runtime->format); |
357 | bps /= 8; | 358 | bps /= 8; |
@@ -371,13 +372,13 @@ static int snd_card_saa7134_capture_prepare(snd_pcm_substream_t * substream) | |||
371 | goto fail2; | 372 | goto fail2; |
372 | 373 | ||
373 | /* prepare buffer */ | 374 | /* prepare buffer */ |
374 | if (0 != (err = videobuf_dma_pci_map(dev->pci,&dev->oss.dma))) | 375 | if (0 != (err = videobuf_dma_pci_map(dev->pci,&dev->dmasound.dma))) |
375 | return err; | 376 | return err; |
376 | if (0 != (err = saa7134_pgtable_alloc(dev->pci,&dev->oss.pt))) | 377 | if (0 != (err = saa7134_pgtable_alloc(dev->pci,&dev->dmasound.pt))) |
377 | goto fail1; | 378 | goto fail1; |
378 | if (0 != (err = saa7134_pgtable_build(dev->pci,&dev->oss.pt, | 379 | if (0 != (err = saa7134_pgtable_build(dev->pci,&dev->dmasound.pt, |
379 | dev->oss.dma.sglist, | 380 | dev->dmasound.dma.sglist, |
380 | dev->oss.dma.sglen, | 381 | dev->dmasound.dma.sglen, |
381 | 0))) | 382 | 0))) |
382 | goto fail2; | 383 | goto fail2; |
383 | 384 | ||
@@ -427,10 +428,10 @@ static int snd_card_saa7134_capture_prepare(snd_pcm_substream_t * substream) | |||
427 | if (sign) | 428 | if (sign) |
428 | fmt |= 0x04; | 429 | fmt |= 0x04; |
429 | 430 | ||
430 | fmt |= (MIXER_ADDR_TVTUNER == dev->oss.input) ? 0xc0 : 0x80; | 431 | fmt |= (MIXER_ADDR_TVTUNER == dev->dmasound.input) ? 0xc0 : 0x80; |
431 | saa_writeb(SAA7134_NUM_SAMPLES0, ((dev->oss.blksize - 1) & 0x0000ff)); | 432 | saa_writeb(SAA7134_NUM_SAMPLES0, ((dev->dmasound.blksize - 1) & 0x0000ff)); |
432 | saa_writeb(SAA7134_NUM_SAMPLES1, ((dev->oss.blksize - 1) & 0x00ff00) >> 8); | 433 | saa_writeb(SAA7134_NUM_SAMPLES1, ((dev->dmasound.blksize - 1) & 0x00ff00) >> 8); |
433 | saa_writeb(SAA7134_NUM_SAMPLES2, ((dev->oss.blksize - 1) & 0xff0000) >> 16); | 434 | saa_writeb(SAA7134_NUM_SAMPLES2, ((dev->dmasound.blksize - 1) & 0xff0000) >> 16); |
434 | saa_writeb(SAA7134_AUDIO_FORMAT_CTRL, fmt); | 435 | saa_writeb(SAA7134_AUDIO_FORMAT_CTRL, fmt); |
435 | 436 | ||
436 | break; | 437 | break; |
@@ -442,7 +443,7 @@ static int snd_card_saa7134_capture_prepare(snd_pcm_substream_t * substream) | |||
442 | fmt |= (2 << 4); | 443 | fmt |= (2 << 4); |
443 | if (!sign) | 444 | if (!sign) |
444 | fmt |= 0x04; | 445 | fmt |= 0x04; |
445 | saa_writel(SAA7133_NUM_SAMPLES, dev->oss.blksize -1); | 446 | saa_writel(SAA7133_NUM_SAMPLES, dev->dmasound.blksize -1); |
446 | saa_writel(SAA7133_AUDIO_CHANNEL, 0x543210 | (fmt << 24)); | 447 | saa_writel(SAA7133_AUDIO_CHANNEL, 0x543210 | (fmt << 24)); |
447 | //saa_writel(SAA7133_AUDIO_CHANNEL, 0x543210); | 448 | //saa_writel(SAA7133_AUDIO_CHANNEL, 0x543210); |
448 | break; | 449 | break; |
@@ -454,7 +455,7 @@ static int snd_card_saa7134_capture_prepare(snd_pcm_substream_t * substream) | |||
454 | /* dma: setup channel 6 (= AUDIO) */ | 455 | /* dma: setup channel 6 (= AUDIO) */ |
455 | control = SAA7134_RS_CONTROL_BURST_16 | | 456 | control = SAA7134_RS_CONTROL_BURST_16 | |
456 | SAA7134_RS_CONTROL_ME | | 457 | SAA7134_RS_CONTROL_ME | |
457 | (dev->oss.pt.dma >> 12); | 458 | (dev->dmasound.pt.dma >> 12); |
458 | if (bswap) | 459 | if (bswap) |
459 | control |= SAA7134_RS_CONTROL_BSWAP; | 460 | control |= SAA7134_RS_CONTROL_BSWAP; |
460 | 461 | ||
@@ -462,24 +463,20 @@ static int snd_card_saa7134_capture_prepare(snd_pcm_substream_t * substream) | |||
462 | byte, but it doesn't work. So I allocate the DMA using the | 463 | byte, but it doesn't work. So I allocate the DMA using the |
463 | V4L functions, and force ALSA to use that as the DMA area */ | 464 | V4L functions, and force ALSA to use that as the DMA area */ |
464 | 465 | ||
465 | runtime->dma_area = dev->oss.dma.vmalloc; | 466 | runtime->dma_area = dev->dmasound.dma.vmalloc; |
466 | 467 | ||
467 | saa_writel(SAA7134_RS_BA1(6),0); | 468 | saa_writel(SAA7134_RS_BA1(6),0); |
468 | saa_writel(SAA7134_RS_BA2(6),dev->oss.blksize); | 469 | saa_writel(SAA7134_RS_BA2(6),dev->dmasound.blksize); |
469 | saa_writel(SAA7134_RS_PITCH(6),0); | 470 | saa_writel(SAA7134_RS_PITCH(6),0); |
470 | saa_writel(SAA7134_RS_CONTROL(6),control); | 471 | saa_writel(SAA7134_RS_CONTROL(6),control); |
471 | 472 | ||
472 | dev->oss.rate = runtime->rate; | 473 | dev->dmasound.rate = runtime->rate; |
473 | /* start dma */ | ||
474 | spin_lock_irqsave(&dev->slock,flags); | ||
475 | saa7134_dma_start(dev); | ||
476 | spin_unlock_irqrestore(&dev->slock,flags); | ||
477 | 474 | ||
478 | return 0; | 475 | return 0; |
479 | fail2: | 476 | fail2: |
480 | saa7134_pgtable_free(dev->pci,&dev->oss.pt); | 477 | saa7134_pgtable_free(dev->pci,&dev->dmasound.pt); |
481 | fail1: | 478 | fail1: |
482 | videobuf_dma_pci_unmap(dev->pci,&dev->oss.dma); | 479 | videobuf_dma_pci_unmap(dev->pci,&dev->dmasound.dma); |
483 | return err; | 480 | return err; |
484 | 481 | ||
485 | 482 | ||
@@ -504,14 +501,14 @@ static snd_pcm_uframes_t snd_card_saa7134_capture_pointer(snd_pcm_substream_t * | |||
504 | 501 | ||
505 | 502 | ||
506 | 503 | ||
507 | if (dev->oss.read_count) { | 504 | if (dev->dmasound.read_count) { |
508 | dev->oss.read_count -= snd_pcm_lib_period_bytes(substream); | 505 | dev->dmasound.read_count -= snd_pcm_lib_period_bytes(substream); |
509 | dev->oss.read_offset += snd_pcm_lib_period_bytes(substream); | 506 | dev->dmasound.read_offset += snd_pcm_lib_period_bytes(substream); |
510 | if (dev->oss.read_offset == dev->oss.bufsize) | 507 | if (dev->dmasound.read_offset == dev->dmasound.bufsize) |
511 | dev->oss.read_offset = 0; | 508 | dev->dmasound.read_offset = 0; |
512 | } | 509 | } |
513 | 510 | ||
514 | return bytes_to_frames(runtime, dev->oss.read_offset); | 511 | return bytes_to_frames(runtime, dev->dmasound.read_offset); |
515 | } | 512 | } |
516 | 513 | ||
517 | /* | 514 | /* |
@@ -523,18 +520,22 @@ static snd_pcm_hardware_t snd_card_saa7134_capture = | |||
523 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | | 520 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | |
524 | SNDRV_PCM_INFO_BLOCK_TRANSFER | | 521 | SNDRV_PCM_INFO_BLOCK_TRANSFER | |
525 | SNDRV_PCM_INFO_MMAP_VALID), | 522 | SNDRV_PCM_INFO_MMAP_VALID), |
526 | .formats = USE_FORMATS, | 523 | .formats = SNDRV_PCM_FMTBIT_S16_LE | \ |
527 | .rates = USE_RATE, | 524 | SNDRV_PCM_FMTBIT_S16_BE | \ |
528 | .rate_min = USE_RATE_MIN, | 525 | SNDRV_PCM_FMTBIT_S8 | \ |
529 | .rate_max = USE_RATE_MAX, | 526 | SNDRV_PCM_FMTBIT_U8 | \ |
530 | .channels_min = USE_CHANNELS_MIN, | 527 | SNDRV_PCM_FMTBIT_U16_LE | \ |
531 | .channels_max = USE_CHANNELS_MAX, | 528 | SNDRV_PCM_FMTBIT_U16_BE, |
532 | .buffer_bytes_max = MAX_BUFFER_SIZE, | 529 | .rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000, |
530 | .rate_min = 32000, | ||
531 | .rate_max = 48000, | ||
532 | .channels_min = 1, | ||
533 | .channels_max = 2, | ||
534 | .buffer_bytes_max = (256*1024), | ||
533 | .period_bytes_min = 64, | 535 | .period_bytes_min = 64, |
534 | .period_bytes_max = MAX_BUFFER_SIZE, | 536 | .period_bytes_max = (256*1024), |
535 | .periods_min = USE_PERIODS_MIN, | 537 | .periods_min = 2, |
536 | .periods_max = USE_PERIODS_MAX, | 538 | .periods_max = 1024, |
537 | .fifo_size = 0x08070503, | ||
538 | }; | 539 | }; |
539 | 540 | ||
540 | static void snd_card_saa7134_runtime_free(snd_pcm_runtime_t *runtime) | 541 | static void snd_card_saa7134_runtime_free(snd_pcm_runtime_t *runtime) |
@@ -590,14 +591,14 @@ static int snd_card_saa7134_hw_free(snd_pcm_substream_t * substream) | |||
590 | 591 | ||
591 | static int dsp_buffer_free(struct saa7134_dev *dev) | 592 | static int dsp_buffer_free(struct saa7134_dev *dev) |
592 | { | 593 | { |
593 | if (!dev->oss.blksize) | 594 | if (!dev->dmasound.blksize) |
594 | BUG(); | 595 | BUG(); |
595 | 596 | ||
596 | videobuf_dma_free(&dev->oss.dma); | 597 | videobuf_dma_free(&dev->dmasound.dma); |
597 | 598 | ||
598 | dev->oss.blocks = 0; | 599 | dev->dmasound.blocks = 0; |
599 | dev->oss.blksize = 0; | 600 | dev->dmasound.blksize = 0; |
600 | dev->oss.bufsize = 0; | 601 | dev->dmasound.bufsize = 0; |
601 | 602 | ||
602 | return 0; | 603 | return 0; |
603 | } | 604 | } |
@@ -616,16 +617,10 @@ static int snd_card_saa7134_capture_close(snd_pcm_substream_t * substream) | |||
616 | { | 617 | { |
617 | snd_card_saa7134_t *chip = snd_pcm_substream_chip(substream); | 618 | snd_card_saa7134_t *chip = snd_pcm_substream_chip(substream); |
618 | struct saa7134_dev *dev = chip->saadev; | 619 | struct saa7134_dev *dev = chip->saadev; |
619 | unsigned long flags; | ||
620 | |||
621 | /* stop dma */ | ||
622 | spin_lock_irqsave(&dev->slock,flags); | ||
623 | saa7134_dma_stop(dev); | ||
624 | spin_unlock_irqrestore(&dev->slock,flags); | ||
625 | 620 | ||
626 | /* unlock buffer */ | 621 | /* unlock buffer */ |
627 | saa7134_pgtable_free(dev->pci,&dev->oss.pt); | 622 | saa7134_pgtable_free(dev->pci,&dev->dmasound.pt); |
628 | videobuf_dma_pci_unmap(dev->pci,&dev->oss.dma); | 623 | videobuf_dma_pci_unmap(dev->pci,&dev->dmasound.dma); |
629 | 624 | ||
630 | dsp_buffer_free(dev); | 625 | dsp_buffer_free(dev); |
631 | return 0; | 626 | return 0; |
@@ -649,16 +644,16 @@ static int snd_card_saa7134_capture_open(snd_pcm_substream_t * substream) | |||
649 | struct saa7134_dev *dev = saa7134->saadev; | 644 | struct saa7134_dev *dev = saa7134->saadev; |
650 | int err; | 645 | int err; |
651 | 646 | ||
652 | down(&dev->oss.lock); | 647 | down(&dev->dmasound.lock); |
653 | 648 | ||
654 | dev->oss.afmt = SNDRV_PCM_FORMAT_U8; | 649 | dev->dmasound.afmt = SNDRV_PCM_FORMAT_U8; |
655 | dev->oss.channels = 2; | 650 | dev->dmasound.channels = 2; |
656 | dev->oss.read_count = 0; | 651 | dev->dmasound.read_count = 0; |
657 | dev->oss.read_offset = 0; | 652 | dev->dmasound.read_offset = 0; |
658 | 653 | ||
659 | up(&dev->oss.lock); | 654 | up(&dev->dmasound.lock); |
660 | 655 | ||
661 | saapcm = kcalloc(1, sizeof(*saapcm), GFP_KERNEL); | 656 | saapcm = kzalloc(sizeof(*saapcm), GFP_KERNEL); |
662 | if (saapcm == NULL) | 657 | if (saapcm == NULL) |
663 | return -ENOMEM; | 658 | return -ENOMEM; |
664 | saapcm->saadev=saa7134->saadev; | 659 | saapcm->saadev=saa7134->saadev; |
@@ -731,13 +726,10 @@ static int snd_saa7134_volume_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_ | |||
731 | static int snd_saa7134_volume_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) | 726 | static int snd_saa7134_volume_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) |
732 | { | 727 | { |
733 | snd_card_saa7134_t *chip = snd_kcontrol_chip(kcontrol); | 728 | snd_card_saa7134_t *chip = snd_kcontrol_chip(kcontrol); |
734 | unsigned long flags; | ||
735 | int addr = kcontrol->private_value; | 729 | int addr = kcontrol->private_value; |
736 | 730 | ||
737 | spin_lock_irqsave(&chip->mixer_lock, flags); | ||
738 | ucontrol->value.integer.value[0] = chip->mixer_volume[addr][0]; | 731 | ucontrol->value.integer.value[0] = chip->mixer_volume[addr][0]; |
739 | ucontrol->value.integer.value[1] = chip->mixer_volume[addr][1]; | 732 | ucontrol->value.integer.value[1] = chip->mixer_volume[addr][1]; |
740 | spin_unlock_irqrestore(&chip->mixer_lock, flags); | ||
741 | return 0; | 733 | return 0; |
742 | } | 734 | } |
743 | 735 | ||
@@ -815,7 +807,7 @@ static int snd_saa7134_capsrc_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ | |||
815 | chip->capture_source[addr][1] != right; | 807 | chip->capture_source[addr][1] != right; |
816 | chip->capture_source[addr][0] = left; | 808 | chip->capture_source[addr][0] = left; |
817 | chip->capture_source[addr][1] = right; | 809 | chip->capture_source[addr][1] = right; |
818 | dev->oss.input=addr; | 810 | dev->dmasound.input=addr; |
819 | spin_unlock_irqrestore(&chip->mixer_lock, flags); | 811 | spin_unlock_irqrestore(&chip->mixer_lock, flags); |
820 | 812 | ||
821 | 813 | ||
@@ -831,7 +823,7 @@ static int snd_saa7134_capsrc_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ | |||
831 | case MIXER_ADDR_LINE1: | 823 | case MIXER_ADDR_LINE1: |
832 | case MIXER_ADDR_LINE2: | 824 | case MIXER_ADDR_LINE2: |
833 | analog_io = (MIXER_ADDR_LINE1 == addr) ? 0x00 : 0x08; | 825 | analog_io = (MIXER_ADDR_LINE1 == addr) ? 0x00 : 0x08; |
834 | rate = (32000 == dev->oss.rate) ? 0x01 : 0x03; | 826 | rate = (32000 == dev->dmasound.rate) ? 0x01 : 0x03; |
835 | saa_andorb(SAA7134_ANALOG_IO_SELECT, 0x08, analog_io); | 827 | saa_andorb(SAA7134_ANALOG_IO_SELECT, 0x08, analog_io); |
836 | saa_andorb(SAA7134_AUDIO_FORMAT_CTRL, 0xc0, 0x80); | 828 | saa_andorb(SAA7134_AUDIO_FORMAT_CTRL, 0xc0, 0x80); |
837 | saa_andorb(SAA7134_SIF_SAMPLE_FREQ, 0x03, rate); | 829 | saa_andorb(SAA7134_SIF_SAMPLE_FREQ, 0x03, rate); |
@@ -925,7 +917,7 @@ static int snd_saa7134_dev_free(snd_device_t *device) | |||
925 | * | 917 | * |
926 | */ | 918 | */ |
927 | 919 | ||
928 | int alsa_card_saa7134_create (struct saa7134_dev *saadev, unsigned int devicenum) | 920 | int alsa_card_saa7134_create (struct saa7134_dev *saadev) |
929 | { | 921 | { |
930 | static int dev; | 922 | static int dev; |
931 | 923 | ||
@@ -942,12 +934,8 @@ int alsa_card_saa7134_create (struct saa7134_dev *saadev, unsigned int devicenum | |||
942 | if (!enable[dev]) | 934 | if (!enable[dev]) |
943 | return -ENODEV; | 935 | return -ENODEV; |
944 | 936 | ||
945 | if (devicenum) { | 937 | card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); |
946 | card = snd_card_new(devicenum, id[dev], THIS_MODULE, 0); | 938 | |
947 | dsp_nr++; | ||
948 | } else { | ||
949 | card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); | ||
950 | } | ||
951 | if (card == NULL) | 939 | if (card == NULL) |
952 | return -ENOMEM; | 940 | return -ENOMEM; |
953 | 941 | ||
@@ -961,6 +949,7 @@ int alsa_card_saa7134_create (struct saa7134_dev *saadev, unsigned int devicenum | |||
961 | } | 949 | } |
962 | 950 | ||
963 | spin_lock_init(&chip->lock); | 951 | spin_lock_init(&chip->lock); |
952 | spin_lock_init(&chip->mixer_lock); | ||
964 | 953 | ||
965 | chip->saadev = saadev; | 954 | chip->saadev = saadev; |
966 | 955 | ||
@@ -970,18 +959,17 @@ int alsa_card_saa7134_create (struct saa7134_dev *saadev, unsigned int devicenum | |||
970 | chip->irq = saadev->pci->irq; | 959 | chip->irq = saadev->pci->irq; |
971 | chip->iobase = pci_resource_start(saadev->pci, 0); | 960 | chip->iobase = pci_resource_start(saadev->pci, 0); |
972 | 961 | ||
973 | err = request_irq(chip->pci->irq, saa7134_alsa_irq, | 962 | err = request_irq(saadev->pci->irq, saa7134_alsa_irq, |
974 | SA_SHIRQ | SA_INTERRUPT, saadev->name, saadev); | 963 | SA_SHIRQ | SA_INTERRUPT, saadev->name, saadev); |
975 | 964 | ||
976 | if (err < 0) { | 965 | if (err < 0) { |
977 | printk(KERN_ERR "%s: can't get IRQ %d for ALSA\n", | 966 | printk(KERN_ERR "%s: can't get IRQ %d for ALSA\n", |
978 | saadev->name, saadev->pci->irq); | 967 | saadev->name, saadev->pci->irq); |
979 | return err; | 968 | goto __nodev; |
980 | } | 969 | } |
981 | 970 | ||
982 | if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { | 971 | if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { |
983 | snd_saa7134_free(chip); | 972 | goto __nodev; |
984 | return err; | ||
985 | } | 973 | } |
986 | 974 | ||
987 | if ((err = snd_card_saa7134_new_mixer(chip)) < 0) | 975 | if ((err = snd_card_saa7134_new_mixer(chip)) < 0) |
@@ -990,8 +978,6 @@ int alsa_card_saa7134_create (struct saa7134_dev *saadev, unsigned int devicenum | |||
990 | if ((err = snd_card_saa7134_pcm(chip, 0)) < 0) | 978 | if ((err = snd_card_saa7134_pcm(chip, 0)) < 0) |
991 | goto __nodev; | 979 | goto __nodev; |
992 | 980 | ||
993 | spin_lock_init(&chip->mixer_lock); | ||
994 | |||
995 | snd_card_set_dev(card, &chip->pci->dev); | 981 | snd_card_set_dev(card, &chip->pci->dev); |
996 | 982 | ||
997 | /* End of "creation" */ | 983 | /* End of "creation" */ |
@@ -1007,7 +993,7 @@ int alsa_card_saa7134_create (struct saa7134_dev *saadev, unsigned int devicenum | |||
1007 | 993 | ||
1008 | __nodev: | 994 | __nodev: |
1009 | snd_card_free(card); | 995 | snd_card_free(card); |
1010 | kfree(card); | 996 | kfree(chip); |
1011 | return err; | 997 | return err; |
1012 | } | 998 | } |
1013 | 999 | ||
@@ -1028,7 +1014,7 @@ static int saa7134_alsa_init(void) | |||
1028 | 1014 | ||
1029 | list_for_each(list,&saa7134_devlist) { | 1015 | list_for_each(list,&saa7134_devlist) { |
1030 | saadev = list_entry(list, struct saa7134_dev, devlist); | 1016 | saadev = list_entry(list, struct saa7134_dev, devlist); |
1031 | alsa_card_saa7134_create(saadev,dsp_nr); | 1017 | alsa_card_saa7134_create(saadev); |
1032 | } | 1018 | } |
1033 | 1019 | ||
1034 | if (saadev == NULL) | 1020 | if (saadev == NULL) |
@@ -1045,10 +1031,13 @@ static int saa7134_alsa_init(void) | |||
1045 | void saa7134_alsa_exit(void) | 1031 | void saa7134_alsa_exit(void) |
1046 | { | 1032 | { |
1047 | int idx; | 1033 | int idx; |
1034 | |||
1048 | for (idx = 0; idx < SNDRV_CARDS; idx++) { | 1035 | for (idx = 0; idx < SNDRV_CARDS; idx++) { |
1049 | snd_card_free(snd_saa7134_cards[idx]); | 1036 | snd_card_free(snd_saa7134_cards[idx]); |
1050 | } | 1037 | } |
1038 | |||
1051 | printk(KERN_INFO "saa7134 ALSA driver for DMA sound unloaded\n"); | 1039 | printk(KERN_INFO "saa7134 ALSA driver for DMA sound unloaded\n"); |
1040 | |||
1052 | return; | 1041 | return; |
1053 | } | 1042 | } |
1054 | 1043 | ||
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c index 6c329c440572..19b88744fb31 100644 --- a/drivers/media/video/saa7134/saa7134-core.c +++ b/drivers/media/video/saa7134/saa7134-core.c | |||
@@ -194,6 +194,7 @@ void saa7134_track_gpio(struct saa7134_dev *dev, char *msg) | |||
194 | 194 | ||
195 | static int need_empress; | 195 | static int need_empress; |
196 | static int need_dvb; | 196 | static int need_dvb; |
197 | static int need_alsa; | ||
197 | 198 | ||
198 | static int pending_call(struct notifier_block *self, unsigned long state, | 199 | static int pending_call(struct notifier_block *self, unsigned long state, |
199 | void *module) | 200 | void *module) |
@@ -205,6 +206,8 @@ static int pending_call(struct notifier_block *self, unsigned long state, | |||
205 | request_module("saa7134-empress"); | 206 | request_module("saa7134-empress"); |
206 | if (need_dvb) | 207 | if (need_dvb) |
207 | request_module("saa7134-dvb"); | 208 | request_module("saa7134-dvb"); |
209 | if (need_alsa) | ||
210 | request_module("saa7134-alsa"); | ||
208 | return NOTIFY_DONE; | 211 | return NOTIFY_DONE; |
209 | } | 212 | } |
210 | 213 | ||
@@ -469,7 +472,7 @@ int saa7134_set_dmabits(struct saa7134_dev *dev) | |||
469 | } | 472 | } |
470 | 473 | ||
471 | /* audio capture -- dma 3 */ | 474 | /* audio capture -- dma 3 */ |
472 | if (dev->oss.dma_running) { | 475 | if (dev->dmasound.dma_running) { |
473 | ctrl |= SAA7134_MAIN_CTRL_TE6; | 476 | ctrl |= SAA7134_MAIN_CTRL_TE6; |
474 | irq |= SAA7134_IRQ1_INTE_RA3_1 | | 477 | irq |= SAA7134_IRQ1_INTE_RA3_1 | |
475 | SAA7134_IRQ1_INTE_RA3_0; | 478 | SAA7134_IRQ1_INTE_RA3_0; |
@@ -983,6 +986,12 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, | |||
983 | if (card_is_dvb(dev)) | 986 | if (card_is_dvb(dev)) |
984 | request_module_depend("saa7134-dvb",&need_dvb); | 987 | request_module_depend("saa7134-dvb",&need_dvb); |
985 | 988 | ||
989 | if (!oss && alsa) { | ||
990 | dprintk("Requesting ALSA module\n"); | ||
991 | request_module_depend("saa7134-alsa",&need_alsa); | ||
992 | } | ||
993 | |||
994 | |||
986 | v4l2_prio_init(&dev->prio); | 995 | v4l2_prio_init(&dev->prio); |
987 | 996 | ||
988 | /* register v4l devices */ | 997 | /* register v4l devices */ |
@@ -1021,24 +1030,22 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, | |||
1021 | case PCI_DEVICE_ID_PHILIPS_SAA7133: | 1030 | case PCI_DEVICE_ID_PHILIPS_SAA7133: |
1022 | case PCI_DEVICE_ID_PHILIPS_SAA7135: | 1031 | case PCI_DEVICE_ID_PHILIPS_SAA7135: |
1023 | if (oss) { | 1032 | if (oss) { |
1024 | err = dev->oss.minor_dsp = | 1033 | err = dev->dmasound.minor_dsp = |
1025 | register_sound_dsp(&saa7134_dsp_fops, | 1034 | register_sound_dsp(&saa7134_dsp_fops, |
1026 | dsp_nr[dev->nr]); | 1035 | dsp_nr[dev->nr]); |
1027 | if (err < 0) { | 1036 | if (err < 0) { |
1028 | goto fail4; | 1037 | goto fail4; |
1029 | } | 1038 | } |
1030 | printk(KERN_INFO "%s: registered device dsp%d\n", | 1039 | printk(KERN_INFO "%s: registered device dsp%d\n", |
1031 | dev->name,dev->oss.minor_dsp >> 4); | 1040 | dev->name,dev->dmasound.minor_dsp >> 4); |
1032 | 1041 | ||
1033 | err = dev->oss.minor_mixer = | 1042 | err = dev->dmasound.minor_mixer = |
1034 | register_sound_mixer(&saa7134_mixer_fops, | 1043 | register_sound_mixer(&saa7134_mixer_fops, |
1035 | mixer_nr[dev->nr]); | 1044 | mixer_nr[dev->nr]); |
1036 | if (err < 0) | 1045 | if (err < 0) |
1037 | goto fail5; | 1046 | goto fail5; |
1038 | printk(KERN_INFO "%s: registered device mixer%d\n", | 1047 | printk(KERN_INFO "%s: registered device mixer%d\n", |
1039 | dev->name,dev->oss.minor_mixer >> 4); | 1048 | dev->name,dev->dmasound.minor_mixer >> 4); |
1040 | } else if (alsa) { | ||
1041 | request_module("saa7134-alsa"); | ||
1042 | } | 1049 | } |
1043 | break; | 1050 | break; |
1044 | } | 1051 | } |
@@ -1065,7 +1072,7 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, | |||
1065 | case PCI_DEVICE_ID_PHILIPS_SAA7133: | 1072 | case PCI_DEVICE_ID_PHILIPS_SAA7133: |
1066 | case PCI_DEVICE_ID_PHILIPS_SAA7135: | 1073 | case PCI_DEVICE_ID_PHILIPS_SAA7135: |
1067 | if (oss) | 1074 | if (oss) |
1068 | unregister_sound_dsp(dev->oss.minor_dsp); | 1075 | unregister_sound_dsp(dev->dmasound.minor_dsp); |
1069 | break; | 1076 | break; |
1070 | } | 1077 | } |
1071 | fail4: | 1078 | fail4: |
@@ -1123,8 +1130,8 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev) | |||
1123 | case PCI_DEVICE_ID_PHILIPS_SAA7133: | 1130 | case PCI_DEVICE_ID_PHILIPS_SAA7133: |
1124 | case PCI_DEVICE_ID_PHILIPS_SAA7135: | 1131 | case PCI_DEVICE_ID_PHILIPS_SAA7135: |
1125 | if (oss) { | 1132 | if (oss) { |
1126 | unregister_sound_mixer(dev->oss.minor_mixer); | 1133 | unregister_sound_mixer(dev->dmasound.minor_mixer); |
1127 | unregister_sound_dsp(dev->oss.minor_dsp); | 1134 | unregister_sound_dsp(dev->dmasound.minor_dsp); |
1128 | } | 1135 | } |
1129 | break; | 1136 | break; |
1130 | } | 1137 | } |
diff --git a/drivers/media/video/saa7134/saa7134-oss.c b/drivers/media/video/saa7134/saa7134-oss.c index f1b0e0d93d7b..fd53dfcc1644 100644 --- a/drivers/media/video/saa7134/saa7134-oss.c +++ b/drivers/media/video/saa7134/saa7134-oss.c | |||
@@ -59,9 +59,9 @@ static int dsp_buffer_conf(struct saa7134_dev *dev, int blksize, int blocks) | |||
59 | if ((blksize * blocks) > 1024*1024) | 59 | if ((blksize * blocks) > 1024*1024) |
60 | blocks = 1024*1024 / blksize; | 60 | blocks = 1024*1024 / blksize; |
61 | 61 | ||
62 | dev->oss.blocks = blocks; | 62 | dev->dmasound.blocks = blocks; |
63 | dev->oss.blksize = blksize; | 63 | dev->dmasound.blksize = blksize; |
64 | dev->oss.bufsize = blksize * blocks; | 64 | dev->dmasound.bufsize = blksize * blocks; |
65 | 65 | ||
66 | dprintk("buffer config: %d blocks / %d bytes, %d kB total\n", | 66 | dprintk("buffer config: %d blocks / %d bytes, %d kB total\n", |
67 | blocks,blksize,blksize * blocks / 1024); | 67 | blocks,blksize,blksize * blocks / 1024); |
@@ -72,11 +72,11 @@ static int dsp_buffer_init(struct saa7134_dev *dev) | |||
72 | { | 72 | { |
73 | int err; | 73 | int err; |
74 | 74 | ||
75 | if (!dev->oss.bufsize) | 75 | if (!dev->dmasound.bufsize) |
76 | BUG(); | 76 | BUG(); |
77 | videobuf_dma_init(&dev->oss.dma); | 77 | videobuf_dma_init(&dev->dmasound.dma); |
78 | err = videobuf_dma_init_kernel(&dev->oss.dma, PCI_DMA_FROMDEVICE, | 78 | err = videobuf_dma_init_kernel(&dev->dmasound.dma, PCI_DMA_FROMDEVICE, |
79 | (dev->oss.bufsize + PAGE_SIZE) >> PAGE_SHIFT); | 79 | (dev->dmasound.bufsize + PAGE_SIZE) >> PAGE_SHIFT); |
80 | if (0 != err) | 80 | if (0 != err) |
81 | return err; | 81 | return err; |
82 | return 0; | 82 | return 0; |
@@ -84,26 +84,26 @@ static int dsp_buffer_init(struct saa7134_dev *dev) | |||
84 | 84 | ||
85 | static int dsp_buffer_free(struct saa7134_dev *dev) | 85 | static int dsp_buffer_free(struct saa7134_dev *dev) |
86 | { | 86 | { |
87 | if (!dev->oss.blksize) | 87 | if (!dev->dmasound.blksize) |
88 | BUG(); | 88 | BUG(); |
89 | videobuf_dma_free(&dev->oss.dma); | 89 | videobuf_dma_free(&dev->dmasound.dma); |
90 | dev->oss.blocks = 0; | 90 | dev->dmasound.blocks = 0; |
91 | dev->oss.blksize = 0; | 91 | dev->dmasound.blksize = 0; |
92 | dev->oss.bufsize = 0; | 92 | dev->dmasound.bufsize = 0; |
93 | return 0; | 93 | return 0; |
94 | } | 94 | } |
95 | 95 | ||
96 | static void dsp_dma_start(struct saa7134_dev *dev) | 96 | static void dsp_dma_start(struct saa7134_dev *dev) |
97 | { | 97 | { |
98 | dev->oss.dma_blk = 0; | 98 | dev->dmasound.dma_blk = 0; |
99 | dev->oss.dma_running = 1; | 99 | dev->dmasound.dma_running = 1; |
100 | saa7134_set_dmabits(dev); | 100 | saa7134_set_dmabits(dev); |
101 | } | 101 | } |
102 | 102 | ||
103 | static void dsp_dma_stop(struct saa7134_dev *dev) | 103 | static void dsp_dma_stop(struct saa7134_dev *dev) |
104 | { | 104 | { |
105 | dev->oss.dma_blk = -1; | 105 | dev->dmasound.dma_blk = -1; |
106 | dev->oss.dma_running = 0; | 106 | dev->dmasound.dma_running = 0; |
107 | saa7134_set_dmabits(dev); | 107 | saa7134_set_dmabits(dev); |
108 | } | 108 | } |
109 | 109 | ||
@@ -114,18 +114,18 @@ static int dsp_rec_start(struct saa7134_dev *dev) | |||
114 | unsigned long flags; | 114 | unsigned long flags; |
115 | 115 | ||
116 | /* prepare buffer */ | 116 | /* prepare buffer */ |
117 | 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))) |
118 | return err; | 118 | return err; |
119 | if (0 != (err = saa7134_pgtable_alloc(dev->pci,&dev->oss.pt))) | 119 | if (0 != (err = saa7134_pgtable_alloc(dev->pci,&dev->dmasound.pt))) |
120 | goto fail1; | 120 | goto fail1; |
121 | if (0 != (err = saa7134_pgtable_build(dev->pci,&dev->oss.pt, | 121 | if (0 != (err = saa7134_pgtable_build(dev->pci,&dev->dmasound.pt, |
122 | dev->oss.dma.sglist, | 122 | dev->dmasound.dma.sglist, |
123 | dev->oss.dma.sglen, | 123 | dev->dmasound.dma.sglen, |
124 | 0))) | 124 | 0))) |
125 | goto fail2; | 125 | goto fail2; |
126 | 126 | ||
127 | /* sample format */ | 127 | /* sample format */ |
128 | switch (dev->oss.afmt) { | 128 | switch (dev->dmasound.afmt) { |
129 | case AFMT_U8: | 129 | case AFMT_U8: |
130 | case AFMT_S8: fmt = 0x00; break; | 130 | case AFMT_S8: fmt = 0x00; break; |
131 | case AFMT_U16_LE: | 131 | case AFMT_U16_LE: |
@@ -137,14 +137,14 @@ static int dsp_rec_start(struct saa7134_dev *dev) | |||
137 | goto fail2; | 137 | goto fail2; |
138 | } | 138 | } |
139 | 139 | ||
140 | switch (dev->oss.afmt) { | 140 | switch (dev->dmasound.afmt) { |
141 | case AFMT_S8: | 141 | case AFMT_S8: |
142 | case AFMT_S16_LE: | 142 | case AFMT_S16_LE: |
143 | case AFMT_S16_BE: sign = 1; break; | 143 | case AFMT_S16_BE: sign = 1; break; |
144 | default: sign = 0; break; | 144 | default: sign = 0; break; |
145 | } | 145 | } |
146 | 146 | ||
147 | switch (dev->oss.afmt) { | 147 | switch (dev->dmasound.afmt) { |
148 | case AFMT_U16_BE: | 148 | case AFMT_U16_BE: |
149 | case AFMT_S16_BE: bswap = 1; break; | 149 | case AFMT_S16_BE: bswap = 1; break; |
150 | default: bswap = 0; break; | 150 | default: bswap = 0; break; |
@@ -152,58 +152,58 @@ static int dsp_rec_start(struct saa7134_dev *dev) | |||
152 | 152 | ||
153 | switch (dev->pci->device) { | 153 | switch (dev->pci->device) { |
154 | case PCI_DEVICE_ID_PHILIPS_SAA7134: | 154 | case PCI_DEVICE_ID_PHILIPS_SAA7134: |
155 | if (1 == dev->oss.channels) | 155 | if (1 == dev->dmasound.channels) |
156 | fmt |= (1 << 3); | 156 | fmt |= (1 << 3); |
157 | if (2 == dev->oss.channels) | 157 | if (2 == dev->dmasound.channels) |
158 | fmt |= (3 << 3); | 158 | fmt |= (3 << 3); |
159 | if (sign) | 159 | if (sign) |
160 | fmt |= 0x04; | 160 | fmt |= 0x04; |
161 | fmt |= (TV == dev->oss.input) ? 0xc0 : 0x80; | 161 | fmt |= (TV == dev->dmasound.input) ? 0xc0 : 0x80; |
162 | 162 | ||
163 | saa_writeb(SAA7134_NUM_SAMPLES0, ((dev->oss.blksize - 1) & 0x0000ff)); | 163 | saa_writeb(SAA7134_NUM_SAMPLES0, ((dev->dmasound.blksize - 1) & 0x0000ff)); |
164 | saa_writeb(SAA7134_NUM_SAMPLES1, ((dev->oss.blksize - 1) & 0x00ff00) >> 8); | 164 | saa_writeb(SAA7134_NUM_SAMPLES1, ((dev->dmasound.blksize - 1) & 0x00ff00) >> 8); |
165 | saa_writeb(SAA7134_NUM_SAMPLES2, ((dev->oss.blksize - 1) & 0xff0000) >> 16); | 165 | saa_writeb(SAA7134_NUM_SAMPLES2, ((dev->dmasound.blksize - 1) & 0xff0000) >> 16); |
166 | saa_writeb(SAA7134_AUDIO_FORMAT_CTRL, fmt); | 166 | saa_writeb(SAA7134_AUDIO_FORMAT_CTRL, fmt); |
167 | 167 | ||
168 | break; | 168 | break; |
169 | case PCI_DEVICE_ID_PHILIPS_SAA7133: | 169 | case PCI_DEVICE_ID_PHILIPS_SAA7133: |
170 | case PCI_DEVICE_ID_PHILIPS_SAA7135: | 170 | case PCI_DEVICE_ID_PHILIPS_SAA7135: |
171 | if (1 == dev->oss.channels) | 171 | if (1 == dev->dmasound.channels) |
172 | fmt |= (1 << 4); | 172 | fmt |= (1 << 4); |
173 | if (2 == dev->oss.channels) | 173 | if (2 == dev->dmasound.channels) |
174 | fmt |= (2 << 4); | 174 | fmt |= (2 << 4); |
175 | if (!sign) | 175 | if (!sign) |
176 | fmt |= 0x04; | 176 | fmt |= 0x04; |
177 | saa_writel(SAA7133_NUM_SAMPLES, dev->oss.blksize -4); | 177 | saa_writel(SAA7133_NUM_SAMPLES, dev->dmasound.blksize -4); |
178 | saa_writel(SAA7133_AUDIO_CHANNEL, 0x543210 | (fmt << 24)); | 178 | saa_writel(SAA7133_AUDIO_CHANNEL, 0x543210 | (fmt << 24)); |
179 | break; | 179 | break; |
180 | } | 180 | } |
181 | 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", |
182 | dev->oss.afmt, dev->oss.channels, fmt, | 182 | dev->dmasound.afmt, dev->dmasound.channels, fmt, |
183 | bswap ? 'b' : '-'); | 183 | bswap ? 'b' : '-'); |
184 | 184 | ||
185 | /* dma: setup channel 6 (= AUDIO) */ | 185 | /* dma: setup channel 6 (= AUDIO) */ |
186 | control = SAA7134_RS_CONTROL_BURST_16 | | 186 | control = SAA7134_RS_CONTROL_BURST_16 | |
187 | SAA7134_RS_CONTROL_ME | | 187 | SAA7134_RS_CONTROL_ME | |
188 | (dev->oss.pt.dma >> 12); | 188 | (dev->dmasound.pt.dma >> 12); |
189 | if (bswap) | 189 | if (bswap) |
190 | control |= SAA7134_RS_CONTROL_BSWAP; | 190 | control |= SAA7134_RS_CONTROL_BSWAP; |
191 | saa_writel(SAA7134_RS_BA1(6),0); | 191 | saa_writel(SAA7134_RS_BA1(6),0); |
192 | saa_writel(SAA7134_RS_BA2(6),dev->oss.blksize); | 192 | saa_writel(SAA7134_RS_BA2(6),dev->dmasound.blksize); |
193 | saa_writel(SAA7134_RS_PITCH(6),0); | 193 | saa_writel(SAA7134_RS_PITCH(6),0); |
194 | saa_writel(SAA7134_RS_CONTROL(6),control); | 194 | saa_writel(SAA7134_RS_CONTROL(6),control); |
195 | 195 | ||
196 | /* start dma */ | 196 | /* start dma */ |
197 | dev->oss.recording_on = 1; | 197 | dev->dmasound.recording_on = 1; |
198 | spin_lock_irqsave(&dev->slock,flags); | 198 | spin_lock_irqsave(&dev->slock,flags); |
199 | dsp_dma_start(dev); | 199 | dsp_dma_start(dev); |
200 | spin_unlock_irqrestore(&dev->slock,flags); | 200 | spin_unlock_irqrestore(&dev->slock,flags); |
201 | return 0; | 201 | return 0; |
202 | 202 | ||
203 | fail2: | 203 | fail2: |
204 | saa7134_pgtable_free(dev->pci,&dev->oss.pt); | 204 | saa7134_pgtable_free(dev->pci,&dev->dmasound.pt); |
205 | fail1: | 205 | fail1: |
206 | videobuf_dma_pci_unmap(dev->pci,&dev->oss.dma); | 206 | videobuf_dma_pci_unmap(dev->pci,&dev->dmasound.dma); |
207 | return err; | 207 | return err; |
208 | } | 208 | } |
209 | 209 | ||
@@ -211,17 +211,17 @@ static int dsp_rec_stop(struct saa7134_dev *dev) | |||
211 | { | 211 | { |
212 | unsigned long flags; | 212 | unsigned long flags; |
213 | 213 | ||
214 | dprintk("rec_stop dma_blk=%d\n",dev->oss.dma_blk); | 214 | dprintk("rec_stop dma_blk=%d\n",dev->dmasound.dma_blk); |
215 | 215 | ||
216 | /* stop dma */ | 216 | /* stop dma */ |
217 | dev->oss.recording_on = 0; | 217 | dev->dmasound.recording_on = 0; |
218 | spin_lock_irqsave(&dev->slock,flags); | 218 | spin_lock_irqsave(&dev->slock,flags); |
219 | dsp_dma_stop(dev); | 219 | dsp_dma_stop(dev); |
220 | spin_unlock_irqrestore(&dev->slock,flags); | 220 | spin_unlock_irqrestore(&dev->slock,flags); |
221 | 221 | ||
222 | /* unlock buffer */ | 222 | /* unlock buffer */ |
223 | saa7134_pgtable_free(dev->pci,&dev->oss.pt); | 223 | saa7134_pgtable_free(dev->pci,&dev->dmasound.pt); |
224 | videobuf_dma_pci_unmap(dev->pci,&dev->oss.dma); | 224 | videobuf_dma_pci_unmap(dev->pci,&dev->dmasound.dma); |
225 | return 0; | 225 | return 0; |
226 | } | 226 | } |
227 | 227 | ||
@@ -236,35 +236,35 @@ static int dsp_open(struct inode *inode, struct file *file) | |||
236 | 236 | ||
237 | list_for_each(list,&saa7134_devlist) { | 237 | list_for_each(list,&saa7134_devlist) { |
238 | h = list_entry(list, struct saa7134_dev, devlist); | 238 | h = list_entry(list, struct saa7134_dev, devlist); |
239 | if (h->oss.minor_dsp == minor) | 239 | if (h->dmasound.minor_dsp == minor) |
240 | dev = h; | 240 | dev = h; |
241 | } | 241 | } |
242 | if (NULL == dev) | 242 | if (NULL == dev) |
243 | return -ENODEV; | 243 | return -ENODEV; |
244 | 244 | ||
245 | down(&dev->oss.lock); | 245 | down(&dev->dmasound.lock); |
246 | err = -EBUSY; | 246 | err = -EBUSY; |
247 | if (dev->oss.users_dsp) | 247 | if (dev->dmasound.users_dsp) |
248 | goto fail1; | 248 | goto fail1; |
249 | dev->oss.users_dsp++; | 249 | dev->dmasound.users_dsp++; |
250 | file->private_data = dev; | 250 | file->private_data = dev; |
251 | 251 | ||
252 | dev->oss.afmt = AFMT_U8; | 252 | dev->dmasound.afmt = AFMT_U8; |
253 | dev->oss.channels = 1; | 253 | dev->dmasound.channels = 1; |
254 | dev->oss.read_count = 0; | 254 | dev->dmasound.read_count = 0; |
255 | dev->oss.read_offset = 0; | 255 | dev->dmasound.read_offset = 0; |
256 | dsp_buffer_conf(dev,PAGE_SIZE,64); | 256 | dsp_buffer_conf(dev,PAGE_SIZE,64); |
257 | err = dsp_buffer_init(dev); | 257 | err = dsp_buffer_init(dev); |
258 | if (0 != err) | 258 | if (0 != err) |
259 | goto fail2; | 259 | goto fail2; |
260 | 260 | ||
261 | up(&dev->oss.lock); | 261 | up(&dev->dmasound.lock); |
262 | return 0; | 262 | return 0; |
263 | 263 | ||
264 | fail2: | 264 | fail2: |
265 | dev->oss.users_dsp--; | 265 | dev->dmasound.users_dsp--; |
266 | fail1: | 266 | fail1: |
267 | up(&dev->oss.lock); | 267 | up(&dev->dmasound.lock); |
268 | return err; | 268 | return err; |
269 | } | 269 | } |
270 | 270 | ||
@@ -272,13 +272,13 @@ static int dsp_release(struct inode *inode, struct file *file) | |||
272 | { | 272 | { |
273 | struct saa7134_dev *dev = file->private_data; | 273 | struct saa7134_dev *dev = file->private_data; |
274 | 274 | ||
275 | down(&dev->oss.lock); | 275 | down(&dev->dmasound.lock); |
276 | if (dev->oss.recording_on) | 276 | if (dev->dmasound.recording_on) |
277 | dsp_rec_stop(dev); | 277 | dsp_rec_stop(dev); |
278 | dsp_buffer_free(dev); | 278 | dsp_buffer_free(dev); |
279 | dev->oss.users_dsp--; | 279 | dev->dmasound.users_dsp--; |
280 | file->private_data = NULL; | 280 | file->private_data = NULL; |
281 | up(&dev->oss.lock); | 281 | up(&dev->dmasound.lock); |
282 | return 0; | 282 | return 0; |
283 | } | 283 | } |
284 | 284 | ||
@@ -291,12 +291,12 @@ static ssize_t dsp_read(struct file *file, char __user *buffer, | |||
291 | unsigned long flags; | 291 | unsigned long flags; |
292 | int err,ret = 0; | 292 | int err,ret = 0; |
293 | 293 | ||
294 | add_wait_queue(&dev->oss.wq, &wait); | 294 | add_wait_queue(&dev->dmasound.wq, &wait); |
295 | down(&dev->oss.lock); | 295 | down(&dev->dmasound.lock); |
296 | while (count > 0) { | 296 | while (count > 0) { |
297 | /* wait for data if needed */ | 297 | /* wait for data if needed */ |
298 | if (0 == dev->oss.read_count) { | 298 | if (0 == dev->dmasound.read_count) { |
299 | if (!dev->oss.recording_on) { | 299 | if (!dev->dmasound.recording_on) { |
300 | err = dsp_rec_start(dev); | 300 | err = dsp_rec_start(dev); |
301 | if (err < 0) { | 301 | if (err < 0) { |
302 | if (0 == ret) | 302 | if (0 == ret) |
@@ -304,8 +304,8 @@ static ssize_t dsp_read(struct file *file, char __user *buffer, | |||
304 | break; | 304 | break; |
305 | } | 305 | } |
306 | } | 306 | } |
307 | if (dev->oss.recording_on && | 307 | if (dev->dmasound.recording_on && |
308 | !dev->oss.dma_running) { | 308 | !dev->dmasound.dma_running) { |
309 | /* recover from overruns */ | 309 | /* recover from overruns */ |
310 | spin_lock_irqsave(&dev->slock,flags); | 310 | spin_lock_irqsave(&dev->slock,flags); |
311 | dsp_dma_start(dev); | 311 | dsp_dma_start(dev); |
@@ -316,12 +316,12 @@ static ssize_t dsp_read(struct file *file, char __user *buffer, | |||
316 | ret = -EAGAIN; | 316 | ret = -EAGAIN; |
317 | break; | 317 | break; |
318 | } | 318 | } |
319 | up(&dev->oss.lock); | 319 | up(&dev->dmasound.lock); |
320 | set_current_state(TASK_INTERRUPTIBLE); | 320 | set_current_state(TASK_INTERRUPTIBLE); |
321 | if (0 == dev->oss.read_count) | 321 | if (0 == dev->dmasound.read_count) |
322 | schedule(); | 322 | schedule(); |
323 | set_current_state(TASK_RUNNING); | 323 | set_current_state(TASK_RUNNING); |
324 | down(&dev->oss.lock); | 324 | down(&dev->dmasound.lock); |
325 | if (signal_pending(current)) { | 325 | if (signal_pending(current)) { |
326 | if (0 == ret) | 326 | if (0 == ret) |
327 | ret = -EINTR; | 327 | ret = -EINTR; |
@@ -331,12 +331,12 @@ static ssize_t dsp_read(struct file *file, char __user *buffer, | |||
331 | 331 | ||
332 | /* copy data to userspace */ | 332 | /* copy data to userspace */ |
333 | bytes = count; | 333 | bytes = count; |
334 | if (bytes > dev->oss.read_count) | 334 | if (bytes > dev->dmasound.read_count) |
335 | bytes = dev->oss.read_count; | 335 | bytes = dev->dmasound.read_count; |
336 | if (bytes > dev->oss.bufsize - dev->oss.read_offset) | 336 | if (bytes > dev->dmasound.bufsize - dev->dmasound.read_offset) |
337 | bytes = dev->oss.bufsize - dev->oss.read_offset; | 337 | bytes = dev->dmasound.bufsize - dev->dmasound.read_offset; |
338 | if (copy_to_user(buffer + ret, | 338 | if (copy_to_user(buffer + ret, |
339 | dev->oss.dma.vmalloc + dev->oss.read_offset, | 339 | dev->dmasound.dma.vmalloc + dev->dmasound.read_offset, |
340 | bytes)) { | 340 | bytes)) { |
341 | if (0 == ret) | 341 | if (0 == ret) |
342 | ret = -EFAULT; | 342 | ret = -EFAULT; |
@@ -345,13 +345,13 @@ static ssize_t dsp_read(struct file *file, char __user *buffer, | |||
345 | 345 | ||
346 | ret += bytes; | 346 | ret += bytes; |
347 | count -= bytes; | 347 | count -= bytes; |
348 | dev->oss.read_count -= bytes; | 348 | dev->dmasound.read_count -= bytes; |
349 | dev->oss.read_offset += bytes; | 349 | dev->dmasound.read_offset += bytes; |
350 | if (dev->oss.read_offset == dev->oss.bufsize) | 350 | if (dev->dmasound.read_offset == dev->dmasound.bufsize) |
351 | dev->oss.read_offset = 0; | 351 | dev->dmasound.read_offset = 0; |
352 | } | 352 | } |
353 | up(&dev->oss.lock); | 353 | up(&dev->dmasound.lock); |
354 | remove_wait_queue(&dev->oss.wq, &wait); | 354 | remove_wait_queue(&dev->dmasound.wq, &wait); |
355 | return ret; | 355 | return ret; |
356 | } | 356 | } |
357 | 357 | ||
@@ -382,35 +382,35 @@ static int dsp_ioctl(struct inode *inode, struct file *file, | |||
382 | return -EFAULT; | 382 | return -EFAULT; |
383 | /* fall through */ | 383 | /* fall through */ |
384 | case SOUND_PCM_READ_RATE: | 384 | case SOUND_PCM_READ_RATE: |
385 | return put_user(dev->oss.rate, p); | 385 | return put_user(dev->dmasound.rate, p); |
386 | 386 | ||
387 | case SNDCTL_DSP_STEREO: | 387 | case SNDCTL_DSP_STEREO: |
388 | if (get_user(val, p)) | 388 | if (get_user(val, p)) |
389 | return -EFAULT; | 389 | return -EFAULT; |
390 | down(&dev->oss.lock); | 390 | down(&dev->dmasound.lock); |
391 | dev->oss.channels = val ? 2 : 1; | 391 | dev->dmasound.channels = val ? 2 : 1; |
392 | if (dev->oss.recording_on) { | 392 | if (dev->dmasound.recording_on) { |
393 | dsp_rec_stop(dev); | 393 | dsp_rec_stop(dev); |
394 | dsp_rec_start(dev); | 394 | dsp_rec_start(dev); |
395 | } | 395 | } |
396 | up(&dev->oss.lock); | 396 | up(&dev->dmasound.lock); |
397 | return put_user(dev->oss.channels-1, p); | 397 | return put_user(dev->dmasound.channels-1, p); |
398 | 398 | ||
399 | case SNDCTL_DSP_CHANNELS: | 399 | case SNDCTL_DSP_CHANNELS: |
400 | if (get_user(val, p)) | 400 | if (get_user(val, p)) |
401 | return -EFAULT; | 401 | return -EFAULT; |
402 | if (val != 1 && val != 2) | 402 | if (val != 1 && val != 2) |
403 | return -EINVAL; | 403 | return -EINVAL; |
404 | down(&dev->oss.lock); | 404 | down(&dev->dmasound.lock); |
405 | dev->oss.channels = val; | 405 | dev->dmasound.channels = val; |
406 | if (dev->oss.recording_on) { | 406 | if (dev->dmasound.recording_on) { |
407 | dsp_rec_stop(dev); | 407 | dsp_rec_stop(dev); |
408 | dsp_rec_start(dev); | 408 | dsp_rec_start(dev); |
409 | } | 409 | } |
410 | up(&dev->oss.lock); | 410 | up(&dev->dmasound.lock); |
411 | /* fall through */ | 411 | /* fall through */ |
412 | case SOUND_PCM_READ_CHANNELS: | 412 | case SOUND_PCM_READ_CHANNELS: |
413 | return put_user(dev->oss.channels, p); | 413 | return put_user(dev->dmasound.channels, p); |
414 | 414 | ||
415 | case SNDCTL_DSP_GETFMTS: /* Returns a mask */ | 415 | case SNDCTL_DSP_GETFMTS: /* Returns a mask */ |
416 | return put_user(AFMT_U8 | AFMT_S8 | | 416 | return put_user(AFMT_U8 | AFMT_S8 | |
@@ -430,20 +430,20 @@ static int dsp_ioctl(struct inode *inode, struct file *file, | |||
430 | case AFMT_U16_BE: | 430 | case AFMT_U16_BE: |
431 | case AFMT_S16_LE: | 431 | case AFMT_S16_LE: |
432 | case AFMT_S16_BE: | 432 | case AFMT_S16_BE: |
433 | down(&dev->oss.lock); | 433 | down(&dev->dmasound.lock); |
434 | dev->oss.afmt = val; | 434 | dev->dmasound.afmt = val; |
435 | if (dev->oss.recording_on) { | 435 | if (dev->dmasound.recording_on) { |
436 | dsp_rec_stop(dev); | 436 | dsp_rec_stop(dev); |
437 | dsp_rec_start(dev); | 437 | dsp_rec_start(dev); |
438 | } | 438 | } |
439 | up(&dev->oss.lock); | 439 | up(&dev->dmasound.lock); |
440 | return put_user(dev->oss.afmt, p); | 440 | return put_user(dev->dmasound.afmt, p); |
441 | default: | 441 | default: |
442 | return -EINVAL; | 442 | return -EINVAL; |
443 | } | 443 | } |
444 | 444 | ||
445 | case SOUND_PCM_READ_BITS: | 445 | case SOUND_PCM_READ_BITS: |
446 | switch (dev->oss.afmt) { | 446 | switch (dev->dmasound.afmt) { |
447 | case AFMT_U8: | 447 | case AFMT_U8: |
448 | case AFMT_S8: | 448 | case AFMT_S8: |
449 | return put_user(8, p); | 449 | return put_user(8, p); |
@@ -461,18 +461,18 @@ static int dsp_ioctl(struct inode *inode, struct file *file, | |||
461 | return 0; | 461 | return 0; |
462 | 462 | ||
463 | case SNDCTL_DSP_RESET: | 463 | case SNDCTL_DSP_RESET: |
464 | down(&dev->oss.lock); | 464 | down(&dev->dmasound.lock); |
465 | if (dev->oss.recording_on) | 465 | if (dev->dmasound.recording_on) |
466 | dsp_rec_stop(dev); | 466 | dsp_rec_stop(dev); |
467 | up(&dev->oss.lock); | 467 | up(&dev->dmasound.lock); |
468 | return 0; | 468 | return 0; |
469 | case SNDCTL_DSP_GETBLKSIZE: | 469 | case SNDCTL_DSP_GETBLKSIZE: |
470 | return put_user(dev->oss.blksize, p); | 470 | return put_user(dev->dmasound.blksize, p); |
471 | 471 | ||
472 | case SNDCTL_DSP_SETFRAGMENT: | 472 | case SNDCTL_DSP_SETFRAGMENT: |
473 | if (get_user(val, p)) | 473 | if (get_user(val, p)) |
474 | return -EFAULT; | 474 | return -EFAULT; |
475 | if (dev->oss.recording_on) | 475 | if (dev->dmasound.recording_on) |
476 | return -EBUSY; | 476 | return -EBUSY; |
477 | dsp_buffer_free(dev); | 477 | dsp_buffer_free(dev); |
478 | /* used to be arg >> 16 instead of val >> 16; fixed */ | 478 | /* used to be arg >> 16 instead of val >> 16; fixed */ |
@@ -487,9 +487,9 @@ static int dsp_ioctl(struct inode *inode, struct file *file, | |||
487 | case SNDCTL_DSP_GETISPACE: | 487 | case SNDCTL_DSP_GETISPACE: |
488 | { | 488 | { |
489 | audio_buf_info info; | 489 | audio_buf_info info; |
490 | info.fragsize = dev->oss.blksize; | 490 | info.fragsize = dev->dmasound.blksize; |
491 | info.fragstotal = dev->oss.blocks; | 491 | info.fragstotal = dev->dmasound.blocks; |
492 | info.bytes = dev->oss.read_count; | 492 | info.bytes = dev->dmasound.read_count; |
493 | info.fragments = info.bytes / info.fragsize; | 493 | info.fragments = info.bytes / info.fragsize; |
494 | if (copy_to_user(argp, &info, sizeof(info))) | 494 | if (copy_to_user(argp, &info, sizeof(info))) |
495 | return -EFAULT; | 495 | return -EFAULT; |
@@ -505,13 +505,13 @@ static unsigned int dsp_poll(struct file *file, struct poll_table_struct *wait) | |||
505 | struct saa7134_dev *dev = file->private_data; | 505 | struct saa7134_dev *dev = file->private_data; |
506 | unsigned int mask = 0; | 506 | unsigned int mask = 0; |
507 | 507 | ||
508 | poll_wait(file, &dev->oss.wq, wait); | 508 | poll_wait(file, &dev->dmasound.wq, wait); |
509 | 509 | ||
510 | if (0 == dev->oss.read_count) { | 510 | if (0 == dev->dmasound.read_count) { |
511 | down(&dev->oss.lock); | 511 | down(&dev->dmasound.lock); |
512 | if (!dev->oss.recording_on) | 512 | if (!dev->dmasound.recording_on) |
513 | dsp_rec_start(dev); | 513 | dsp_rec_start(dev); |
514 | up(&dev->oss.lock); | 514 | up(&dev->dmasound.lock); |
515 | } else | 515 | } else |
516 | mask |= (POLLIN | POLLRDNORM); | 516 | mask |= (POLLIN | POLLRDNORM); |
517 | return mask; | 517 | return mask; |
@@ -535,7 +535,7 @@ mixer_recsrc_7134(struct saa7134_dev *dev) | |||
535 | { | 535 | { |
536 | int analog_io,rate; | 536 | int analog_io,rate; |
537 | 537 | ||
538 | switch (dev->oss.input) { | 538 | switch (dev->dmasound.input) { |
539 | case TV: | 539 | case TV: |
540 | saa_andorb(SAA7134_AUDIO_FORMAT_CTRL, 0xc0, 0xc0); | 540 | saa_andorb(SAA7134_AUDIO_FORMAT_CTRL, 0xc0, 0xc0); |
541 | saa_andorb(SAA7134_SIF_SAMPLE_FREQ, 0x03, 0x00); | 541 | saa_andorb(SAA7134_SIF_SAMPLE_FREQ, 0x03, 0x00); |
@@ -543,8 +543,8 @@ mixer_recsrc_7134(struct saa7134_dev *dev) | |||
543 | case LINE1: | 543 | case LINE1: |
544 | case LINE2: | 544 | case LINE2: |
545 | case LINE2_LEFT: | 545 | case LINE2_LEFT: |
546 | analog_io = (LINE1 == dev->oss.input) ? 0x00 : 0x08; | 546 | analog_io = (LINE1 == dev->dmasound.input) ? 0x00 : 0x08; |
547 | rate = (32000 == dev->oss.rate) ? 0x01 : 0x03; | 547 | rate = (32000 == dev->dmasound.rate) ? 0x01 : 0x03; |
548 | saa_andorb(SAA7134_ANALOG_IO_SELECT, 0x08, analog_io); | 548 | saa_andorb(SAA7134_ANALOG_IO_SELECT, 0x08, analog_io); |
549 | saa_andorb(SAA7134_AUDIO_FORMAT_CTRL, 0xc0, 0x80); | 549 | saa_andorb(SAA7134_AUDIO_FORMAT_CTRL, 0xc0, 0x80); |
550 | saa_andorb(SAA7134_SIF_SAMPLE_FREQ, 0x03, rate); | 550 | saa_andorb(SAA7134_SIF_SAMPLE_FREQ, 0x03, rate); |
@@ -560,7 +560,7 @@ mixer_recsrc_7133(struct saa7134_dev *dev) | |||
560 | 560 | ||
561 | xbarin = 0x03; // adc | 561 | xbarin = 0x03; // adc |
562 | anabar = 0; | 562 | anabar = 0; |
563 | switch (dev->oss.input) { | 563 | switch (dev->dmasound.input) { |
564 | case TV: | 564 | case TV: |
565 | xbarin = 0; // Demodulator | 565 | xbarin = 0; // Demodulator |
566 | anabar = 2; // DACs | 566 | anabar = 2; // DACs |
@@ -586,9 +586,9 @@ mixer_recsrc(struct saa7134_dev *dev, enum saa7134_audio_in src) | |||
586 | { | 586 | { |
587 | static const char *iname[] = { "Oops", "TV", "LINE1", "LINE2" }; | 587 | static const char *iname[] = { "Oops", "TV", "LINE1", "LINE2" }; |
588 | 588 | ||
589 | dev->oss.count++; | 589 | dev->dmasound.count++; |
590 | dev->oss.input = src; | 590 | dev->dmasound.input = src; |
591 | dprintk("mixer input = %s\n",iname[dev->oss.input]); | 591 | dprintk("mixer input = %s\n",iname[dev->dmasound.input]); |
592 | 592 | ||
593 | switch (dev->pci->device) { | 593 | switch (dev->pci->device) { |
594 | case PCI_DEVICE_ID_PHILIPS_SAA7134: | 594 | case PCI_DEVICE_ID_PHILIPS_SAA7134: |
@@ -640,7 +640,7 @@ static int mixer_open(struct inode *inode, struct file *file) | |||
640 | 640 | ||
641 | list_for_each(list,&saa7134_devlist) { | 641 | list_for_each(list,&saa7134_devlist) { |
642 | h = list_entry(list, struct saa7134_dev, devlist); | 642 | h = list_entry(list, struct saa7134_dev, devlist); |
643 | if (h->oss.minor_mixer == minor) | 643 | if (h->dmasound.minor_mixer == minor) |
644 | dev = h; | 644 | dev = h; |
645 | } | 645 | } |
646 | if (NULL == dev) | 646 | if (NULL == dev) |
@@ -676,7 +676,7 @@ static int mixer_ioctl(struct inode *inode, struct file *file, | |||
676 | memset(&info,0,sizeof(info)); | 676 | memset(&info,0,sizeof(info)); |
677 | strlcpy(info.id, "TV audio", sizeof(info.id)); | 677 | strlcpy(info.id, "TV audio", sizeof(info.id)); |
678 | strlcpy(info.name, dev->name, sizeof(info.name)); | 678 | strlcpy(info.name, dev->name, sizeof(info.name)); |
679 | info.modify_counter = dev->oss.count; | 679 | info.modify_counter = dev->dmasound.count; |
680 | if (copy_to_user(argp, &info, sizeof(info))) | 680 | if (copy_to_user(argp, &info, sizeof(info))) |
681 | return -EFAULT; | 681 | return -EFAULT; |
682 | return 0; | 682 | return 0; |
@@ -698,26 +698,26 @@ static int mixer_ioctl(struct inode *inode, struct file *file, | |||
698 | case MIXER_READ(SOUND_MIXER_RECMASK): | 698 | case MIXER_READ(SOUND_MIXER_RECMASK): |
699 | case MIXER_READ(SOUND_MIXER_DEVMASK): | 699 | case MIXER_READ(SOUND_MIXER_DEVMASK): |
700 | val = SOUND_MASK_LINE1 | SOUND_MASK_LINE2; | 700 | val = SOUND_MASK_LINE1 | SOUND_MASK_LINE2; |
701 | if (32000 == dev->oss.rate) | 701 | if (32000 == dev->dmasound.rate) |
702 | val |= SOUND_MASK_VIDEO; | 702 | val |= SOUND_MASK_VIDEO; |
703 | return put_user(val, p); | 703 | return put_user(val, p); |
704 | 704 | ||
705 | case MIXER_WRITE(SOUND_MIXER_RECSRC): | 705 | case MIXER_WRITE(SOUND_MIXER_RECSRC): |
706 | if (get_user(val, p)) | 706 | if (get_user(val, p)) |
707 | return -EFAULT; | 707 | return -EFAULT; |
708 | input = dev->oss.input; | 708 | input = dev->dmasound.input; |
709 | if (32000 == dev->oss.rate && | 709 | if (32000 == dev->dmasound.rate && |
710 | val & SOUND_MASK_VIDEO && dev->oss.input != TV) | 710 | val & SOUND_MASK_VIDEO && dev->dmasound.input != TV) |
711 | input = TV; | 711 | input = TV; |
712 | if (val & SOUND_MASK_LINE1 && dev->oss.input != LINE1) | 712 | if (val & SOUND_MASK_LINE1 && dev->dmasound.input != LINE1) |
713 | input = LINE1; | 713 | input = LINE1; |
714 | if (val & SOUND_MASK_LINE2 && dev->oss.input != LINE2) | 714 | if (val & SOUND_MASK_LINE2 && dev->dmasound.input != LINE2) |
715 | input = LINE2; | 715 | input = LINE2; |
716 | if (input != dev->oss.input) | 716 | if (input != dev->dmasound.input) |
717 | mixer_recsrc(dev,input); | 717 | mixer_recsrc(dev,input); |
718 | /* fall throuth */ | 718 | /* fall throuth */ |
719 | case MIXER_READ(SOUND_MIXER_RECSRC): | 719 | case MIXER_READ(SOUND_MIXER_RECSRC): |
720 | switch (dev->oss.input) { | 720 | switch (dev->dmasound.input) { |
721 | case TV: ret = SOUND_MASK_VIDEO; break; | 721 | case TV: ret = SOUND_MASK_VIDEO; break; |
722 | case LINE1: ret = SOUND_MASK_LINE1; break; | 722 | case LINE1: ret = SOUND_MASK_LINE1; break; |
723 | case LINE2: ret = SOUND_MASK_LINE2; break; | 723 | case LINE2: ret = SOUND_MASK_LINE2; break; |
@@ -727,7 +727,7 @@ static int mixer_ioctl(struct inode *inode, struct file *file, | |||
727 | 727 | ||
728 | case MIXER_WRITE(SOUND_MIXER_VIDEO): | 728 | case MIXER_WRITE(SOUND_MIXER_VIDEO): |
729 | case MIXER_READ(SOUND_MIXER_VIDEO): | 729 | case MIXER_READ(SOUND_MIXER_VIDEO): |
730 | if (32000 != dev->oss.rate) | 730 | if (32000 != dev->dmasound.rate) |
731 | return -EINVAL; | 731 | return -EINVAL; |
732 | return put_user(100 | 100 << 8, p); | 732 | return put_user(100 | 100 << 8, p); |
733 | 733 | ||
@@ -736,22 +736,22 @@ static int mixer_ioctl(struct inode *inode, struct file *file, | |||
736 | return -EFAULT; | 736 | return -EFAULT; |
737 | val &= 0xff; | 737 | val &= 0xff; |
738 | val = (val <= 50) ? 50 : 100; | 738 | val = (val <= 50) ? 50 : 100; |
739 | dev->oss.line1 = val; | 739 | dev->dmasound.line1 = val; |
740 | mixer_level(dev,LINE1,dev->oss.line1); | 740 | mixer_level(dev,LINE1,dev->dmasound.line1); |
741 | /* fall throuth */ | 741 | /* fall throuth */ |
742 | case MIXER_READ(SOUND_MIXER_LINE1): | 742 | case MIXER_READ(SOUND_MIXER_LINE1): |
743 | return put_user(dev->oss.line1 | dev->oss.line1 << 8, p); | 743 | return put_user(dev->dmasound.line1 | dev->dmasound.line1 << 8, p); |
744 | 744 | ||
745 | case MIXER_WRITE(SOUND_MIXER_LINE2): | 745 | case MIXER_WRITE(SOUND_MIXER_LINE2): |
746 | if (get_user(val, p)) | 746 | if (get_user(val, p)) |
747 | return -EFAULT; | 747 | return -EFAULT; |
748 | val &= 0xff; | 748 | val &= 0xff; |
749 | val = (val <= 50) ? 50 : 100; | 749 | val = (val <= 50) ? 50 : 100; |
750 | dev->oss.line2 = val; | 750 | dev->dmasound.line2 = val; |
751 | mixer_level(dev,LINE2,dev->oss.line2); | 751 | mixer_level(dev,LINE2,dev->dmasound.line2); |
752 | /* fall throuth */ | 752 | /* fall throuth */ |
753 | case MIXER_READ(SOUND_MIXER_LINE2): | 753 | case MIXER_READ(SOUND_MIXER_LINE2): |
754 | return put_user(dev->oss.line2 | dev->oss.line2 << 8, p); | 754 | return put_user(dev->dmasound.line2 | dev->dmasound.line2 << 8, p); |
755 | 755 | ||
756 | default: | 756 | default: |
757 | return -EINVAL; | 757 | return -EINVAL; |
@@ -771,8 +771,8 @@ struct file_operations saa7134_mixer_fops = { | |||
771 | int saa7134_oss_init1(struct saa7134_dev *dev) | 771 | int saa7134_oss_init1(struct saa7134_dev *dev) |
772 | { | 772 | { |
773 | /* general */ | 773 | /* general */ |
774 | init_MUTEX(&dev->oss.lock); | 774 | init_MUTEX(&dev->dmasound.lock); |
775 | init_waitqueue_head(&dev->oss.wq); | 775 | init_waitqueue_head(&dev->dmasound.wq); |
776 | 776 | ||
777 | switch (dev->pci->device) { | 777 | switch (dev->pci->device) { |
778 | case PCI_DEVICE_ID_PHILIPS_SAA7133: | 778 | case PCI_DEVICE_ID_PHILIPS_SAA7133: |
@@ -784,17 +784,17 @@ int saa7134_oss_init1(struct saa7134_dev *dev) | |||
784 | } | 784 | } |
785 | 785 | ||
786 | /* dsp */ | 786 | /* dsp */ |
787 | dev->oss.rate = 32000; | 787 | dev->dmasound.rate = 32000; |
788 | if (oss_rate) | 788 | if (oss_rate) |
789 | dev->oss.rate = oss_rate; | 789 | dev->dmasound.rate = oss_rate; |
790 | dev->oss.rate = (dev->oss.rate > 40000) ? 48000 : 32000; | 790 | dev->dmasound.rate = (dev->dmasound.rate > 40000) ? 48000 : 32000; |
791 | 791 | ||
792 | /* mixer */ | 792 | /* mixer */ |
793 | dev->oss.line1 = 50; | 793 | dev->dmasound.line1 = 50; |
794 | dev->oss.line2 = 50; | 794 | dev->dmasound.line2 = 50; |
795 | mixer_level(dev,LINE1,dev->oss.line1); | 795 | mixer_level(dev,LINE1,dev->dmasound.line1); |
796 | mixer_level(dev,LINE2,dev->oss.line2); | 796 | mixer_level(dev,LINE2,dev->dmasound.line2); |
797 | mixer_recsrc(dev, (dev->oss.rate == 32000) ? TV : LINE2); | 797 | mixer_recsrc(dev, (dev->dmasound.rate == 32000) ? TV : LINE2); |
798 | 798 | ||
799 | return 0; | 799 | return 0; |
800 | } | 800 | } |
@@ -810,7 +810,7 @@ void saa7134_irq_oss_done(struct saa7134_dev *dev, unsigned long status) | |||
810 | int next_blk, reg = 0; | 810 | int next_blk, reg = 0; |
811 | 811 | ||
812 | spin_lock(&dev->slock); | 812 | spin_lock(&dev->slock); |
813 | if (UNSET == dev->oss.dma_blk) { | 813 | if (UNSET == dev->dmasound.dma_blk) { |
814 | dprintk("irq: recording stopped\n"); | 814 | dprintk("irq: recording stopped\n"); |
815 | goto done; | 815 | goto done; |
816 | } | 816 | } |
@@ -818,11 +818,11 @@ void saa7134_irq_oss_done(struct saa7134_dev *dev, unsigned long status) | |||
818 | dprintk("irq: lost %ld\n", (status >> 24) & 0x0f); | 818 | dprintk("irq: lost %ld\n", (status >> 24) & 0x0f); |
819 | if (0 == (status & 0x10000000)) { | 819 | if (0 == (status & 0x10000000)) { |
820 | /* odd */ | 820 | /* odd */ |
821 | if (0 == (dev->oss.dma_blk & 0x01)) | 821 | if (0 == (dev->dmasound.dma_blk & 0x01)) |
822 | reg = SAA7134_RS_BA1(6); | 822 | reg = SAA7134_RS_BA1(6); |
823 | } else { | 823 | } else { |
824 | /* even */ | 824 | /* even */ |
825 | if (1 == (dev->oss.dma_blk & 0x01)) | 825 | if (1 == (dev->dmasound.dma_blk & 0x01)) |
826 | reg = SAA7134_RS_BA2(6); | 826 | reg = SAA7134_RS_BA2(6); |
827 | } | 827 | } |
828 | if (0 == reg) { | 828 | if (0 == reg) { |
@@ -830,25 +830,25 @@ void saa7134_irq_oss_done(struct saa7134_dev *dev, unsigned long status) | |||
830 | (status & 0x10000000) ? "even" : "odd"); | 830 | (status & 0x10000000) ? "even" : "odd"); |
831 | goto done; | 831 | goto done; |
832 | } | 832 | } |
833 | 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)) { |
834 | dprintk("irq: overrun [full=%d/%d]\n",dev->oss.read_count, | 834 | dprintk("irq: overrun [full=%d/%d]\n",dev->dmasound.read_count, |
835 | dev->oss.bufsize); | 835 | dev->dmasound.bufsize); |
836 | dsp_dma_stop(dev); | 836 | dsp_dma_stop(dev); |
837 | goto done; | 837 | goto done; |
838 | } | 838 | } |
839 | 839 | ||
840 | /* next block addr */ | 840 | /* next block addr */ |
841 | next_blk = (dev->oss.dma_blk + 2) % dev->oss.blocks; | 841 | next_blk = (dev->dmasound.dma_blk + 2) % dev->dmasound.blocks; |
842 | saa_writel(reg,next_blk * dev->oss.blksize); | 842 | saa_writel(reg,next_blk * dev->dmasound.blksize); |
843 | if (oss_debug > 2) | 843 | if (oss_debug > 2) |
844 | dprintk("irq: ok, %s, next_blk=%d, addr=%x\n", | 844 | dprintk("irq: ok, %s, next_blk=%d, addr=%x\n", |
845 | (status & 0x10000000) ? "even" : "odd ", next_blk, | 845 | (status & 0x10000000) ? "even" : "odd ", next_blk, |
846 | next_blk * dev->oss.blksize); | 846 | next_blk * dev->dmasound.blksize); |
847 | 847 | ||
848 | /* update status & wake waiting readers */ | 848 | /* update status & wake waiting readers */ |
849 | 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; |
850 | dev->oss.read_count += dev->oss.blksize; | 850 | dev->dmasound.read_count += dev->dmasound.blksize; |
851 | wake_up(&dev->oss.wq); | 851 | wake_up(&dev->dmasound.wq); |
852 | 852 | ||
853 | done: | 853 | done: |
854 | spin_unlock(&dev->slock); | 854 | spin_unlock(&dev->slock); |
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h index 1fdc9e147f87..fb9727471661 100644 --- a/drivers/media/video/saa7134/saa7134.h +++ b/drivers/media/video/saa7134/saa7134.h | |||
@@ -355,8 +355,8 @@ struct saa7134_fh { | |||
355 | struct saa7134_pgtable pt_vbi; | 355 | struct saa7134_pgtable pt_vbi; |
356 | }; | 356 | }; |
357 | 357 | ||
358 | /* oss dsp status */ | 358 | /* dmasound dsp status */ |
359 | struct saa7134_oss { | 359 | struct saa7134_dmasound { |
360 | struct semaphore lock; | 360 | struct semaphore lock; |
361 | int minor_mixer; | 361 | int minor_mixer; |
362 | int minor_dsp; | 362 | int minor_dsp; |
@@ -431,7 +431,7 @@ struct saa7134_dev { | |||
431 | struct video_device *video_dev; | 431 | struct video_device *video_dev; |
432 | struct video_device *radio_dev; | 432 | struct video_device *radio_dev; |
433 | struct video_device *vbi_dev; | 433 | struct video_device *vbi_dev; |
434 | struct saa7134_oss oss; | 434 | struct saa7134_dmasound dmasound; |
435 | 435 | ||
436 | /* infrared remote */ | 436 | /* infrared remote */ |
437 | int has_remote; | 437 | int has_remote; |