diff options
Diffstat (limited to 'drivers/media/video/saa7134/saa7134-alsa.c')
-rw-r--r-- | drivers/media/video/saa7134/saa7134-alsa.c | 504 |
1 files changed, 252 insertions, 252 deletions
diff --git a/drivers/media/video/saa7134/saa7134-alsa.c b/drivers/media/video/saa7134/saa7134-alsa.c index 465beac941d7..e9ffe8f144ac 100644 --- a/drivers/media/video/saa7134/saa7134-alsa.c +++ b/drivers/media/video/saa7134/saa7134-alsa.c | |||
@@ -80,11 +80,11 @@ typedef struct snd_card_saa7134 { | |||
80 | spinlock_t mixer_lock; | 80 | spinlock_t mixer_lock; |
81 | int mixer_volume[MIXER_ADDR_LAST+1][2]; | 81 | int mixer_volume[MIXER_ADDR_LAST+1][2]; |
82 | int capture_source[MIXER_ADDR_LAST+1][2]; | 82 | int capture_source[MIXER_ADDR_LAST+1][2]; |
83 | struct pci_dev *pci; | 83 | struct pci_dev *pci; |
84 | struct saa7134_dev *saadev; | 84 | struct saa7134_dev *saadev; |
85 | 85 | ||
86 | unsigned long iobase; | 86 | unsigned long iobase; |
87 | int irq; | 87 | int irq; |
88 | 88 | ||
89 | spinlock_t lock; | 89 | spinlock_t lock; |
90 | } snd_card_saa7134_t; | 90 | } snd_card_saa7134_t; |
@@ -94,7 +94,7 @@ typedef struct snd_card_saa7134 { | |||
94 | */ | 94 | */ |
95 | 95 | ||
96 | typedef struct snd_card_saa7134_pcm { | 96 | typedef struct snd_card_saa7134_pcm { |
97 | struct saa7134_dev *saadev; | 97 | struct saa7134_dev *saadev; |
98 | 98 | ||
99 | spinlock_t lock; | 99 | spinlock_t lock; |
100 | unsigned int pcm_size; /* buffer size */ | 100 | unsigned int pcm_size; /* buffer size */ |
@@ -118,9 +118,9 @@ static snd_card_t *snd_saa7134_cards[SNDRV_CARDS] = SNDRV_DEFAULT_PTR; | |||
118 | static void saa7134_dma_stop(struct saa7134_dev *dev) | 118 | static void saa7134_dma_stop(struct saa7134_dev *dev) |
119 | 119 | ||
120 | { | 120 | { |
121 | dev->oss.dma_blk = -1; | 121 | dev->oss.dma_blk = -1; |
122 | dev->oss.dma_running = 0; | 122 | dev->oss.dma_running = 0; |
123 | saa7134_set_dmabits(dev); | 123 | saa7134_set_dmabits(dev); |
124 | } | 124 | } |
125 | 125 | ||
126 | /* | 126 | /* |
@@ -135,9 +135,9 @@ static void saa7134_dma_stop(struct saa7134_dev *dev) | |||
135 | 135 | ||
136 | static void saa7134_dma_start(struct saa7134_dev *dev) | 136 | static void saa7134_dma_start(struct saa7134_dev *dev) |
137 | { | 137 | { |
138 | dev->oss.dma_blk = 0; | 138 | dev->oss.dma_blk = 0; |
139 | dev->oss.dma_running = 1; | 139 | dev->oss.dma_running = 1; |
140 | saa7134_set_dmabits(dev); | 140 | saa7134_set_dmabits(dev); |
141 | } | 141 | } |
142 | 142 | ||
143 | /* | 143 | /* |
@@ -184,28 +184,28 @@ void saa7134_irq_alsa_done(struct saa7134_dev *dev, unsigned long status) | |||
184 | goto done; | 184 | goto done; |
185 | } | 185 | } |
186 | 186 | ||
187 | /* next block addr */ | 187 | /* next block addr */ |
188 | next_blk = (dev->oss.dma_blk + 2) % dev->oss.blocks; | 188 | next_blk = (dev->oss.dma_blk + 2) % dev->oss.blocks; |
189 | saa_writel(reg,next_blk * dev->oss.blksize); | 189 | saa_writel(reg,next_blk * dev->oss.blksize); |
190 | if (alsa_debug > 2) | 190 | if (alsa_debug > 2) |
191 | dprintk("irq: ok, %s, next_blk=%d, addr=%x, blocks=%u, size=%u, read=%u\n", | 191 | dprintk("irq: ok, %s, next_blk=%d, addr=%x, blocks=%u, size=%u, read=%u\n", |
192 | (status & 0x10000000) ? "even" : "odd ", next_blk, | 192 | (status & 0x10000000) ? "even" : "odd ", next_blk, |
193 | next_blk * dev->oss.blksize, dev->oss.blocks, dev->oss.blksize, dev->oss.read_count); | 193 | next_blk * dev->oss.blksize, dev->oss.blocks, dev->oss.blksize, dev->oss.read_count); |
194 | 194 | ||
195 | 195 | ||
196 | /* update status & wake waiting readers */ | 196 | /* update status & wake waiting readers */ |
197 | dev->oss.dma_blk = (dev->oss.dma_blk + 1) % dev->oss.blocks; | 197 | dev->oss.dma_blk = (dev->oss.dma_blk + 1) % dev->oss.blocks; |
198 | dev->oss.read_count += dev->oss.blksize; | 198 | dev->oss.read_count += dev->oss.blksize; |
199 | 199 | ||
200 | dev->oss.recording_on = reg; | 200 | dev->oss.recording_on = reg; |
201 | 201 | ||
202 | if (dev->oss.read_count >= snd_pcm_lib_period_bytes(dev->oss.substream)) { | 202 | if (dev->oss.read_count >= snd_pcm_lib_period_bytes(dev->oss.substream)) { |
203 | spin_unlock(&dev->slock); | 203 | spin_unlock(&dev->slock); |
204 | snd_pcm_period_elapsed(dev->oss.substream); | 204 | snd_pcm_period_elapsed(dev->oss.substream); |
205 | spin_lock(&dev->slock); | 205 | spin_lock(&dev->slock); |
206 | } | 206 | } |
207 | done: | 207 | done: |
208 | spin_unlock(&dev->slock); | 208 | spin_unlock(&dev->slock); |
209 | 209 | ||
210 | } | 210 | } |
211 | 211 | ||
@@ -239,23 +239,23 @@ static int snd_card_saa7134_capture_trigger(snd_pcm_substream_t * substream, | |||
239 | 239 | ||
240 | static int dsp_buffer_conf(struct saa7134_dev *dev, int blksize, int blocks) | 240 | static int dsp_buffer_conf(struct saa7134_dev *dev, int blksize, int blocks) |
241 | { | 241 | { |
242 | if (blksize < 0x100) | 242 | if (blksize < 0x100) |
243 | blksize = 0x100; | 243 | blksize = 0x100; |
244 | if (blksize > 0x10000) | 244 | if (blksize > 0x10000) |
245 | blksize = 0x10000; | 245 | blksize = 0x10000; |
246 | 246 | ||
247 | if (blocks < 2) | 247 | if (blocks < 2) |
248 | blocks = 2; | 248 | blocks = 2; |
249 | if ((blksize * blocks) > 1024*1024) | 249 | if ((blksize * blocks) > 1024*1024) |
250 | blocks = 1024*1024 / blksize; | 250 | blocks = 1024*1024 / blksize; |
251 | 251 | ||
252 | dev->oss.blocks = blocks; | 252 | dev->oss.blocks = blocks; |
253 | dev->oss.blksize = blksize; | 253 | dev->oss.blksize = blksize; |
254 | dev->oss.bufsize = blksize * blocks; | 254 | dev->oss.bufsize = blksize * blocks; |
255 | 255 | ||
256 | dprintk("buffer config: %d blocks / %d bytes, %d kB total\n", | 256 | dprintk("buffer config: %d blocks / %d bytes, %d kB total\n", |
257 | blocks,blksize,blksize * blocks / 1024); | 257 | blocks,blksize,blksize * blocks / 1024); |
258 | return 0; | 258 | return 0; |
259 | } | 259 | } |
260 | 260 | ||
261 | /* | 261 | /* |
@@ -271,16 +271,16 @@ static int dsp_buffer_conf(struct saa7134_dev *dev, int blksize, int blocks) | |||
271 | 271 | ||
272 | static int dsp_buffer_init(struct saa7134_dev *dev) | 272 | static int dsp_buffer_init(struct saa7134_dev *dev) |
273 | { | 273 | { |
274 | int err; | 274 | int err; |
275 | 275 | ||
276 | if (!dev->oss.bufsize) | 276 | if (!dev->oss.bufsize) |
277 | BUG(); | 277 | BUG(); |
278 | videobuf_dma_init(&dev->oss.dma); | 278 | videobuf_dma_init(&dev->oss.dma); |
279 | err = videobuf_dma_init_kernel(&dev->oss.dma, PCI_DMA_FROMDEVICE, | 279 | err = videobuf_dma_init_kernel(&dev->oss.dma, PCI_DMA_FROMDEVICE, |
280 | (dev->oss.bufsize + PAGE_SIZE) >> PAGE_SHIFT); | 280 | (dev->oss.bufsize + PAGE_SIZE) >> PAGE_SHIFT); |
281 | if (0 != err) | 281 | if (0 != err) |
282 | return err; | 282 | return err; |
283 | return 0; | 283 | return 0; |
284 | } | 284 | } |
285 | 285 | ||
286 | /* | 286 | /* |
@@ -298,18 +298,18 @@ static int dsp_buffer_init(struct saa7134_dev *dev) | |||
298 | static int snd_card_saa7134_capture_prepare(snd_pcm_substream_t * substream) | 298 | static int snd_card_saa7134_capture_prepare(snd_pcm_substream_t * substream) |
299 | { | 299 | { |
300 | snd_pcm_runtime_t *runtime = substream->runtime; | 300 | snd_pcm_runtime_t *runtime = substream->runtime; |
301 | int err, bswap, sign; | 301 | int err, bswap, sign; |
302 | u32 fmt, control; | 302 | u32 fmt, control; |
303 | unsigned long flags; | 303 | unsigned long flags; |
304 | snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream); | 304 | snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream); |
305 | struct saa7134_dev *dev; | 305 | struct saa7134_dev *dev; |
306 | snd_card_saa7134_pcm_t *saapcm = runtime->private_data; | 306 | snd_card_saa7134_pcm_t *saapcm = runtime->private_data; |
307 | unsigned int bps; | 307 | unsigned int bps; |
308 | unsigned long size; | 308 | unsigned long size; |
309 | unsigned count; | 309 | unsigned count; |
310 | 310 | ||
311 | size = snd_pcm_lib_buffer_bytes(substream); | 311 | size = snd_pcm_lib_buffer_bytes(substream); |
312 | count = snd_pcm_lib_period_bytes(substream); | 312 | count = snd_pcm_lib_period_bytes(substream); |
313 | 313 | ||
314 | saapcm->saadev->oss.substream = substream; | 314 | saapcm->saadev->oss.substream = substream; |
315 | bps = runtime->rate * runtime->channels; | 315 | bps = runtime->rate * runtime->channels; |
@@ -324,123 +324,123 @@ static int snd_card_saa7134_capture_prepare(snd_pcm_substream_t * substream) | |||
324 | 324 | ||
325 | dev=saa7134->saadev; | 325 | dev=saa7134->saadev; |
326 | 326 | ||
327 | dsp_buffer_conf(dev,saapcm->pcm_count,(saapcm->pcm_size/saapcm->pcm_count)); | 327 | dsp_buffer_conf(dev,saapcm->pcm_count,(saapcm->pcm_size/saapcm->pcm_count)); |
328 | 328 | ||
329 | err = dsp_buffer_init(dev); | 329 | err = dsp_buffer_init(dev); |
330 | if (0 != err) | 330 | if (0 != err) |
331 | goto fail2; | 331 | goto fail2; |
332 | 332 | ||
333 | /* prepare buffer */ | 333 | /* prepare buffer */ |
334 | if (0 != (err = videobuf_dma_pci_map(dev->pci,&dev->oss.dma))) | 334 | if (0 != (err = videobuf_dma_pci_map(dev->pci,&dev->oss.dma))) |
335 | return err; | 335 | return err; |
336 | if (0 != (err = saa7134_pgtable_alloc(dev->pci,&dev->oss.pt))) | 336 | if (0 != (err = saa7134_pgtable_alloc(dev->pci,&dev->oss.pt))) |
337 | goto fail1; | 337 | goto fail1; |
338 | if (0 != (err = saa7134_pgtable_build(dev->pci,&dev->oss.pt, | 338 | if (0 != (err = saa7134_pgtable_build(dev->pci,&dev->oss.pt, |
339 | dev->oss.dma.sglist, | 339 | dev->oss.dma.sglist, |
340 | dev->oss.dma.sglen, | 340 | dev->oss.dma.sglen, |
341 | 0))) | 341 | 0))) |
342 | goto fail2; | 342 | goto fail2; |
343 | 343 | ||
344 | 344 | ||
345 | 345 | ||
346 | switch (runtime->format) { | 346 | switch (runtime->format) { |
347 | case SNDRV_PCM_FORMAT_U8: | 347 | case SNDRV_PCM_FORMAT_U8: |
348 | case SNDRV_PCM_FORMAT_S8: | 348 | case SNDRV_PCM_FORMAT_S8: |
349 | fmt = 0x00; | 349 | fmt = 0x00; |
350 | break; | 350 | break; |
351 | case SNDRV_PCM_FORMAT_U16_LE: | 351 | case SNDRV_PCM_FORMAT_U16_LE: |
352 | case SNDRV_PCM_FORMAT_U16_BE: | 352 | case SNDRV_PCM_FORMAT_U16_BE: |
353 | case SNDRV_PCM_FORMAT_S16_LE: | 353 | case SNDRV_PCM_FORMAT_S16_LE: |
354 | case SNDRV_PCM_FORMAT_S16_BE: | 354 | case SNDRV_PCM_FORMAT_S16_BE: |
355 | fmt = 0x01; | 355 | fmt = 0x01; |
356 | break; | 356 | break; |
357 | default: | 357 | default: |
358 | err = -EINVAL; | 358 | err = -EINVAL; |
359 | return 1; | 359 | return 1; |
360 | } | 360 | } |
361 | 361 | ||
362 | switch (runtime->format) { | 362 | switch (runtime->format) { |
363 | case SNDRV_PCM_FORMAT_S8: | 363 | case SNDRV_PCM_FORMAT_S8: |
364 | case SNDRV_PCM_FORMAT_S16_LE: | 364 | case SNDRV_PCM_FORMAT_S16_LE: |
365 | case SNDRV_PCM_FORMAT_S16_BE: | 365 | case SNDRV_PCM_FORMAT_S16_BE: |
366 | sign = 1; | 366 | sign = 1; |
367 | break; | 367 | break; |
368 | default: | 368 | default: |
369 | sign = 0; | 369 | sign = 0; |
370 | break; | 370 | break; |
371 | } | 371 | } |
372 | 372 | ||
373 | switch (runtime->format) { | 373 | switch (runtime->format) { |
374 | case SNDRV_PCM_FORMAT_U16_BE: | 374 | case SNDRV_PCM_FORMAT_U16_BE: |
375 | case SNDRV_PCM_FORMAT_S16_BE: | 375 | case SNDRV_PCM_FORMAT_S16_BE: |
376 | bswap = 1; break; | 376 | bswap = 1; break; |
377 | default: | 377 | default: |
378 | bswap = 0; break; | 378 | bswap = 0; break; |
379 | } | 379 | } |
380 | 380 | ||
381 | switch (dev->pci->device) { | 381 | switch (dev->pci->device) { |
382 | case PCI_DEVICE_ID_PHILIPS_SAA7134: | 382 | case PCI_DEVICE_ID_PHILIPS_SAA7134: |
383 | if (1 == runtime->channels) | 383 | if (1 == runtime->channels) |
384 | fmt |= (1 << 3); | 384 | fmt |= (1 << 3); |
385 | if (2 == runtime->channels) | 385 | if (2 == runtime->channels) |
386 | fmt |= (3 << 3); | 386 | fmt |= (3 << 3); |
387 | if (sign) | 387 | if (sign) |
388 | fmt |= 0x04; | 388 | fmt |= 0x04; |
389 | 389 | ||
390 | fmt |= (MIXER_ADDR_TVTUNER == dev->oss.input) ? 0xc0 : 0x80; | 390 | fmt |= (MIXER_ADDR_TVTUNER == dev->oss.input) ? 0xc0 : 0x80; |
391 | saa_writeb(SAA7134_NUM_SAMPLES0, ((dev->oss.blksize - 1) & 0x0000ff)); | 391 | saa_writeb(SAA7134_NUM_SAMPLES0, ((dev->oss.blksize - 1) & 0x0000ff)); |
392 | saa_writeb(SAA7134_NUM_SAMPLES1, ((dev->oss.blksize - 1) & 0x00ff00) >> 8); | 392 | saa_writeb(SAA7134_NUM_SAMPLES1, ((dev->oss.blksize - 1) & 0x00ff00) >> 8); |
393 | saa_writeb(SAA7134_NUM_SAMPLES2, ((dev->oss.blksize - 1) & 0xff0000) >> 16); | 393 | saa_writeb(SAA7134_NUM_SAMPLES2, ((dev->oss.blksize - 1) & 0xff0000) >> 16); |
394 | saa_writeb(SAA7134_AUDIO_FORMAT_CTRL, fmt); | 394 | saa_writeb(SAA7134_AUDIO_FORMAT_CTRL, fmt); |
395 | 395 | ||
396 | break; | 396 | break; |
397 | case PCI_DEVICE_ID_PHILIPS_SAA7133: | 397 | case PCI_DEVICE_ID_PHILIPS_SAA7133: |
398 | case PCI_DEVICE_ID_PHILIPS_SAA7135: | 398 | case PCI_DEVICE_ID_PHILIPS_SAA7135: |
399 | if (1 == runtime->channels) | 399 | if (1 == runtime->channels) |
400 | fmt |= (1 << 4); | 400 | fmt |= (1 << 4); |
401 | if (2 == runtime->channels) | 401 | if (2 == runtime->channels) |
402 | fmt |= (2 << 4); | 402 | fmt |= (2 << 4); |
403 | if (!sign) | 403 | if (!sign) |
404 | fmt |= 0x04; | 404 | fmt |= 0x04; |
405 | saa_writel(SAA7133_NUM_SAMPLES, dev->oss.blksize -1); | 405 | saa_writel(SAA7133_NUM_SAMPLES, dev->oss.blksize -1); |
406 | saa_writel(SAA7133_AUDIO_CHANNEL, 0x543210 | (fmt << 24)); | 406 | saa_writel(SAA7133_AUDIO_CHANNEL, 0x543210 | (fmt << 24)); |
407 | //saa_writel(SAA7133_AUDIO_CHANNEL, 0x543210); | 407 | //saa_writel(SAA7133_AUDIO_CHANNEL, 0x543210); |
408 | break; | 408 | break; |
409 | } | 409 | } |
410 | 410 | ||
411 | dprintk("rec_start: afmt=%d ch=%d => fmt=0x%x swap=%c\n", | 411 | dprintk("rec_start: afmt=%d ch=%d => fmt=0x%x swap=%c\n", |
412 | runtime->format, runtime->channels, fmt, | 412 | runtime->format, runtime->channels, fmt, |
413 | bswap ? 'b' : '-'); | 413 | bswap ? 'b' : '-'); |
414 | /* dma: setup channel 6 (= AUDIO) */ | 414 | /* dma: setup channel 6 (= AUDIO) */ |
415 | control = SAA7134_RS_CONTROL_BURST_16 | | 415 | control = SAA7134_RS_CONTROL_BURST_16 | |
416 | SAA7134_RS_CONTROL_ME | | 416 | SAA7134_RS_CONTROL_ME | |
417 | (dev->oss.pt.dma >> 12); | 417 | (dev->oss.pt.dma >> 12); |
418 | if (bswap) | 418 | if (bswap) |
419 | control |= SAA7134_RS_CONTROL_BSWAP; | 419 | control |= SAA7134_RS_CONTROL_BSWAP; |
420 | 420 | ||
421 | /* I should be able to use runtime->dma_addr in the control | 421 | /* I should be able to use runtime->dma_addr in the control |
422 | byte, but it doesn't work. So I allocate the DMA using the | 422 | byte, but it doesn't work. So I allocate the DMA using the |
423 | V4L functions, and force ALSA to use that as the DMA area */ | 423 | V4L functions, and force ALSA to use that as the DMA area */ |
424 | 424 | ||
425 | runtime->dma_area = dev->oss.dma.vmalloc; | 425 | runtime->dma_area = dev->oss.dma.vmalloc; |
426 | 426 | ||
427 | saa_writel(SAA7134_RS_BA1(6),0); | 427 | saa_writel(SAA7134_RS_BA1(6),0); |
428 | saa_writel(SAA7134_RS_BA2(6),dev->oss.blksize); | 428 | saa_writel(SAA7134_RS_BA2(6),dev->oss.blksize); |
429 | saa_writel(SAA7134_RS_PITCH(6),0); | 429 | saa_writel(SAA7134_RS_PITCH(6),0); |
430 | saa_writel(SAA7134_RS_CONTROL(6),control); | 430 | saa_writel(SAA7134_RS_CONTROL(6),control); |
431 | 431 | ||
432 | dev->oss.rate = runtime->rate; | 432 | dev->oss.rate = runtime->rate; |
433 | /* start dma */ | 433 | /* start dma */ |
434 | spin_lock_irqsave(&dev->slock,flags); | 434 | spin_lock_irqsave(&dev->slock,flags); |
435 | saa7134_dma_start(dev); | 435 | saa7134_dma_start(dev); |
436 | spin_unlock_irqrestore(&dev->slock,flags); | 436 | spin_unlock_irqrestore(&dev->slock,flags); |
437 | 437 | ||
438 | return 0; | 438 | return 0; |
439 | fail2: | 439 | fail2: |
440 | saa7134_pgtable_free(dev->pci,&dev->oss.pt); | 440 | saa7134_pgtable_free(dev->pci,&dev->oss.pt); |
441 | fail1: | 441 | fail1: |
442 | videobuf_dma_pci_unmap(dev->pci,&dev->oss.dma); | 442 | videobuf_dma_pci_unmap(dev->pci,&dev->oss.dma); |
443 | return err; | 443 | return err; |
444 | 444 | ||
445 | 445 | ||
446 | } | 446 | } |
@@ -465,10 +465,10 @@ static snd_pcm_uframes_t snd_card_saa7134_capture_pointer(snd_pcm_substream_t * | |||
465 | 465 | ||
466 | 466 | ||
467 | if (dev->oss.read_count) { | 467 | if (dev->oss.read_count) { |
468 | dev->oss.read_count -= snd_pcm_lib_period_bytes(substream); | 468 | dev->oss.read_count -= snd_pcm_lib_period_bytes(substream); |
469 | dev->oss.read_offset += snd_pcm_lib_period_bytes(substream); | 469 | dev->oss.read_offset += snd_pcm_lib_period_bytes(substream); |
470 | if (dev->oss.read_offset == dev->oss.bufsize) | 470 | if (dev->oss.read_offset == dev->oss.bufsize) |
471 | dev->oss.read_offset = 0; | 471 | dev->oss.read_offset = 0; |
472 | } | 472 | } |
473 | 473 | ||
474 | return bytes_to_frames(runtime, dev->oss.read_offset); | 474 | return bytes_to_frames(runtime, dev->oss.read_offset); |
@@ -480,9 +480,9 @@ static snd_pcm_uframes_t snd_card_saa7134_capture_pointer(snd_pcm_substream_t * | |||
480 | 480 | ||
481 | static snd_pcm_hardware_t snd_card_saa7134_capture = | 481 | static snd_pcm_hardware_t snd_card_saa7134_capture = |
482 | { | 482 | { |
483 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | | 483 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | |
484 | SNDRV_PCM_INFO_BLOCK_TRANSFER | | 484 | SNDRV_PCM_INFO_BLOCK_TRANSFER | |
485 | SNDRV_PCM_INFO_MMAP_VALID), | 485 | SNDRV_PCM_INFO_MMAP_VALID), |
486 | .formats = USE_FORMATS, | 486 | .formats = USE_FORMATS, |
487 | .rates = USE_RATE, | 487 | .rates = USE_RATE, |
488 | .rate_min = USE_RATE_MIN, | 488 | .rate_min = USE_RATE_MIN, |
@@ -550,16 +550,16 @@ static int snd_card_saa7134_hw_free(snd_pcm_substream_t * substream) | |||
550 | 550 | ||
551 | static int dsp_buffer_free(struct saa7134_dev *dev) | 551 | static int dsp_buffer_free(struct saa7134_dev *dev) |
552 | { | 552 | { |
553 | if (!dev->oss.blksize) | 553 | if (!dev->oss.blksize) |
554 | BUG(); | 554 | BUG(); |
555 | 555 | ||
556 | videobuf_dma_free(&dev->oss.dma); | 556 | videobuf_dma_free(&dev->oss.dma); |
557 | 557 | ||
558 | dev->oss.blocks = 0; | 558 | dev->oss.blocks = 0; |
559 | dev->oss.blksize = 0; | 559 | dev->oss.blksize = 0; |
560 | dev->oss.bufsize = 0; | 560 | dev->oss.bufsize = 0; |
561 | 561 | ||
562 | return 0; | 562 | return 0; |
563 | } | 563 | } |
564 | 564 | ||
565 | /* | 565 | /* |
@@ -574,21 +574,21 @@ static int dsp_buffer_free(struct saa7134_dev *dev) | |||
574 | 574 | ||
575 | static int snd_card_saa7134_capture_close(snd_pcm_substream_t * substream) | 575 | static int snd_card_saa7134_capture_close(snd_pcm_substream_t * substream) |
576 | { | 576 | { |
577 | snd_card_saa7134_t *chip = snd_pcm_substream_chip(substream); | 577 | snd_card_saa7134_t *chip = snd_pcm_substream_chip(substream); |
578 | struct saa7134_dev *dev = chip->saadev; | 578 | struct saa7134_dev *dev = chip->saadev; |
579 | unsigned long flags; | 579 | unsigned long flags; |
580 | 580 | ||
581 | /* stop dma */ | 581 | /* stop dma */ |
582 | spin_lock_irqsave(&dev->slock,flags); | 582 | spin_lock_irqsave(&dev->slock,flags); |
583 | saa7134_dma_stop(dev); | 583 | saa7134_dma_stop(dev); |
584 | spin_unlock_irqrestore(&dev->slock,flags); | 584 | spin_unlock_irqrestore(&dev->slock,flags); |
585 | 585 | ||
586 | /* unlock buffer */ | 586 | /* unlock buffer */ |
587 | saa7134_pgtable_free(dev->pci,&dev->oss.pt); | 587 | saa7134_pgtable_free(dev->pci,&dev->oss.pt); |
588 | videobuf_dma_pci_unmap(dev->pci,&dev->oss.dma); | 588 | videobuf_dma_pci_unmap(dev->pci,&dev->oss.dma); |
589 | 589 | ||
590 | dsp_buffer_free(dev); | 590 | dsp_buffer_free(dev); |
591 | return 0; | 591 | return 0; |
592 | } | 592 | } |
593 | 593 | ||
594 | /* | 594 | /* |
@@ -605,18 +605,18 @@ static int snd_card_saa7134_capture_open(snd_pcm_substream_t * substream) | |||
605 | { | 605 | { |
606 | snd_pcm_runtime_t *runtime = substream->runtime; | 606 | snd_pcm_runtime_t *runtime = substream->runtime; |
607 | snd_card_saa7134_pcm_t *saapcm; | 607 | snd_card_saa7134_pcm_t *saapcm; |
608 | snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream); | 608 | snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream); |
609 | struct saa7134_dev *dev = saa7134->saadev; | 609 | struct saa7134_dev *dev = saa7134->saadev; |
610 | int err; | 610 | int err; |
611 | 611 | ||
612 | down(&dev->oss.lock); | 612 | down(&dev->oss.lock); |
613 | 613 | ||
614 | dev->oss.afmt = SNDRV_PCM_FORMAT_U8; | 614 | dev->oss.afmt = SNDRV_PCM_FORMAT_U8; |
615 | dev->oss.channels = 2; | 615 | dev->oss.channels = 2; |
616 | dev->oss.read_count = 0; | 616 | dev->oss.read_count = 0; |
617 | dev->oss.read_offset = 0; | 617 | dev->oss.read_offset = 0; |
618 | 618 | ||
619 | up(&dev->oss.lock); | 619 | up(&dev->oss.lock); |
620 | 620 | ||
621 | saapcm = kcalloc(1, sizeof(*saapcm), GFP_KERNEL); | 621 | saapcm = kcalloc(1, sizeof(*saapcm), GFP_KERNEL); |
622 | if (saapcm == NULL) | 622 | if (saapcm == NULL) |
@@ -630,8 +630,8 @@ static int snd_card_saa7134_capture_open(snd_pcm_substream_t * substream) | |||
630 | runtime->private_free = snd_card_saa7134_runtime_free; | 630 | runtime->private_free = snd_card_saa7134_runtime_free; |
631 | runtime->hw = snd_card_saa7134_capture; | 631 | runtime->hw = snd_card_saa7134_capture; |
632 | 632 | ||
633 | if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) | 633 | if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) |
634 | return err; | 634 | return err; |
635 | 635 | ||
636 | return 0; | 636 | return 0; |
637 | } | 637 | } |
@@ -723,7 +723,7 @@ static int snd_saa7134_volume_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ | |||
723 | right = 20; | 723 | right = 20; |
724 | spin_lock_irqsave(&chip->mixer_lock, flags); | 724 | spin_lock_irqsave(&chip->mixer_lock, flags); |
725 | change = chip->mixer_volume[addr][0] != left || | 725 | change = chip->mixer_volume[addr][0] != left || |
726 | chip->mixer_volume[addr][1] != right; | 726 | chip->mixer_volume[addr][1] != right; |
727 | chip->mixer_volume[addr][0] = left; | 727 | chip->mixer_volume[addr][0] = left; |
728 | chip->mixer_volume[addr][1] = right; | 728 | chip->mixer_volume[addr][1] = right; |
729 | spin_unlock_irqrestore(&chip->mixer_lock, flags); | 729 | spin_unlock_irqrestore(&chip->mixer_lock, flags); |
@@ -764,7 +764,7 @@ static int snd_saa7134_capsrc_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ | |||
764 | unsigned long flags; | 764 | unsigned long flags; |
765 | int change, addr = kcontrol->private_value; | 765 | int change, addr = kcontrol->private_value; |
766 | int left, right; | 766 | int left, right; |
767 | u32 anabar, xbarin; | 767 | u32 anabar, xbarin; |
768 | int analog_io, rate; | 768 | int analog_io, rate; |
769 | struct saa7134_dev *dev; | 769 | struct saa7134_dev *dev; |
770 | 770 | ||
@@ -775,7 +775,7 @@ static int snd_saa7134_capsrc_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ | |||
775 | spin_lock_irqsave(&chip->mixer_lock, flags); | 775 | spin_lock_irqsave(&chip->mixer_lock, flags); |
776 | 776 | ||
777 | change = chip->capture_source[addr][0] != left || | 777 | change = chip->capture_source[addr][0] != left || |
778 | chip->capture_source[addr][1] != right; | 778 | chip->capture_source[addr][1] != right; |
779 | chip->capture_source[addr][0] = left; | 779 | chip->capture_source[addr][0] = left; |
780 | chip->capture_source[addr][1] = right; | 780 | chip->capture_source[addr][1] = right; |
781 | dev->oss.input=addr; | 781 | dev->oss.input=addr; |
@@ -783,57 +783,57 @@ static int snd_saa7134_capsrc_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_ | |||
783 | 783 | ||
784 | 784 | ||
785 | if (change) { | 785 | if (change) { |
786 | switch (dev->pci->device) { | 786 | switch (dev->pci->device) { |
787 | 787 | ||
788 | case PCI_DEVICE_ID_PHILIPS_SAA7134: | 788 | case PCI_DEVICE_ID_PHILIPS_SAA7134: |
789 | switch (addr) { | 789 | switch (addr) { |
790 | case MIXER_ADDR_TVTUNER: | 790 | case MIXER_ADDR_TVTUNER: |
791 | saa_andorb(SAA7134_AUDIO_FORMAT_CTRL, 0xc0, 0xc0); | 791 | saa_andorb(SAA7134_AUDIO_FORMAT_CTRL, 0xc0, 0xc0); |
792 | saa_andorb(SAA7134_SIF_SAMPLE_FREQ, 0x03, 0x00); | 792 | saa_andorb(SAA7134_SIF_SAMPLE_FREQ, 0x03, 0x00); |
793 | break; | 793 | break; |
794 | case MIXER_ADDR_LINE1: | 794 | case MIXER_ADDR_LINE1: |
795 | case MIXER_ADDR_LINE2: | 795 | case MIXER_ADDR_LINE2: |
796 | analog_io = (MIXER_ADDR_LINE1 == addr) ? 0x00 : 0x08; | 796 | analog_io = (MIXER_ADDR_LINE1 == addr) ? 0x00 : 0x08; |
797 | rate = (32000 == dev->oss.rate) ? 0x01 : 0x03; | 797 | rate = (32000 == dev->oss.rate) ? 0x01 : 0x03; |
798 | saa_andorb(SAA7134_ANALOG_IO_SELECT, 0x08, analog_io); | 798 | saa_andorb(SAA7134_ANALOG_IO_SELECT, 0x08, analog_io); |
799 | saa_andorb(SAA7134_AUDIO_FORMAT_CTRL, 0xc0, 0x80); | 799 | saa_andorb(SAA7134_AUDIO_FORMAT_CTRL, 0xc0, 0x80); |
800 | saa_andorb(SAA7134_SIF_SAMPLE_FREQ, 0x03, rate); | 800 | saa_andorb(SAA7134_SIF_SAMPLE_FREQ, 0x03, rate); |
801 | break; | 801 | break; |
802 | } | 802 | } |
803 | 803 | ||
804 | break; | 804 | break; |
805 | case PCI_DEVICE_ID_PHILIPS_SAA7133: | 805 | case PCI_DEVICE_ID_PHILIPS_SAA7133: |
806 | case PCI_DEVICE_ID_PHILIPS_SAA7135: | 806 | case PCI_DEVICE_ID_PHILIPS_SAA7135: |
807 | xbarin = 0x03; // adc | 807 | xbarin = 0x03; // adc |
808 | anabar = 0; | 808 | anabar = 0; |
809 | switch (addr) { | 809 | switch (addr) { |
810 | case MIXER_ADDR_TVTUNER: | 810 | case MIXER_ADDR_TVTUNER: |
811 | xbarin = 0; // Demodulator | 811 | xbarin = 0; // Demodulator |
812 | anabar = 2; // DACs | 812 | anabar = 2; // DACs |
813 | break; | 813 | break; |
814 | case MIXER_ADDR_LINE1: | 814 | case MIXER_ADDR_LINE1: |
815 | anabar = 0; // aux1, aux1 | 815 | anabar = 0; // aux1, aux1 |
816 | break; | 816 | break; |
817 | case MIXER_ADDR_LINE2: | 817 | case MIXER_ADDR_LINE2: |
818 | anabar = 9; // aux2, aux2 | 818 | anabar = 9; // aux2, aux2 |
819 | break; | 819 | break; |
820 | } | 820 | } |
821 | 821 | ||
822 | /* output xbar always main channel */ | 822 | /* output xbar always main channel */ |
823 | saa_dsp_writel(dev, SAA7133_DIGITAL_OUTPUT_SEL1, 0xbbbb10); | 823 | saa_dsp_writel(dev, SAA7133_DIGITAL_OUTPUT_SEL1, 0xbbbb10); |
824 | 824 | ||
825 | if (left || right) { // We've got data, turn the input on | 825 | if (left || right) { // We've got data, turn the input on |
826 | //saa_dsp_writel(dev, SAA7133_DIGITAL_OUTPUT_SEL2, 0x101010); | 826 | //saa_dsp_writel(dev, SAA7133_DIGITAL_OUTPUT_SEL2, 0x101010); |
827 | saa_dsp_writel(dev, SAA7133_DIGITAL_INPUT_XBAR1, xbarin); | 827 | saa_dsp_writel(dev, SAA7133_DIGITAL_INPUT_XBAR1, xbarin); |
828 | saa_writel(SAA7133_ANALOG_IO_SELECT, anabar); | 828 | saa_writel(SAA7133_ANALOG_IO_SELECT, anabar); |
829 | } else { | 829 | } else { |
830 | //saa_dsp_writel(dev, SAA7133_DIGITAL_OUTPUT_SEL2, 0x101010); | 830 | //saa_dsp_writel(dev, SAA7133_DIGITAL_OUTPUT_SEL2, 0x101010); |
831 | saa_dsp_writel(dev, SAA7133_DIGITAL_INPUT_XBAR1, 0); | 831 | saa_dsp_writel(dev, SAA7133_DIGITAL_INPUT_XBAR1, 0); |
832 | saa_writel(SAA7133_ANALOG_IO_SELECT, 0); | 832 | saa_writel(SAA7133_ANALOG_IO_SELECT, 0); |
833 | } | 833 | } |
834 | break; | 834 | break; |
835 | } | 835 | } |
836 | } | 836 | } |
837 | 837 | ||
838 | return change; | 838 | return change; |
839 | } | 839 | } |
@@ -878,8 +878,8 @@ static int snd_saa7134_free(snd_card_saa7134_t *chip) | |||
878 | 878 | ||
879 | static int snd_saa7134_dev_free(snd_device_t *device) | 879 | static int snd_saa7134_dev_free(snd_device_t *device) |
880 | { | 880 | { |
881 | snd_card_saa7134_t *chip = device->device_data; | 881 | snd_card_saa7134_t *chip = device->device_data; |
882 | return snd_saa7134_free(chip); | 882 | return snd_saa7134_free(chip); |
883 | } | 883 | } |
884 | 884 | ||
885 | /* | 885 | /* |
@@ -896,12 +896,12 @@ int alsa_card_saa7134_create(struct saa7134_dev *saadev, unsigned int devicenum) | |||
896 | snd_card_t *card; | 896 | snd_card_t *card; |
897 | snd_card_saa7134_t *chip; | 897 | snd_card_saa7134_t *chip; |
898 | int err; | 898 | int err; |
899 | static snd_device_ops_t ops = { | 899 | static snd_device_ops_t ops = { |
900 | .dev_free = snd_saa7134_dev_free, | 900 | .dev_free = snd_saa7134_dev_free, |
901 | }; | 901 | }; |
902 | 902 | ||
903 | if (dev >= SNDRV_CARDS) | 903 | if (dev >= SNDRV_CARDS) |
904 | return -ENODEV; | 904 | return -ENODEV; |
905 | if (!enable[dev]) | 905 | if (!enable[dev]) |
906 | return -ENODEV; | 906 | return -ENODEV; |
907 | 907 | ||
@@ -918,24 +918,24 @@ int alsa_card_saa7134_create(struct saa7134_dev *saadev, unsigned int devicenum) | |||
918 | /* Card "creation" */ | 918 | /* Card "creation" */ |
919 | 919 | ||
920 | chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); | 920 | chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); |
921 | if (chip == NULL) { | 921 | if (chip == NULL) { |
922 | return -ENOMEM; | 922 | return -ENOMEM; |
923 | } | 923 | } |
924 | 924 | ||
925 | spin_lock_init(&chip->lock); | 925 | spin_lock_init(&chip->lock); |
926 | 926 | ||
927 | chip->saadev = saadev; | 927 | chip->saadev = saadev; |
928 | 928 | ||
929 | chip->card = card; | 929 | chip->card = card; |
930 | 930 | ||
931 | chip->pci = saadev->pci; | 931 | chip->pci = saadev->pci; |
932 | chip->irq = saadev->pci->irq; | 932 | chip->irq = saadev->pci->irq; |
933 | chip->iobase = pci_resource_start(saadev->pci, 0); | 933 | chip->iobase = pci_resource_start(saadev->pci, 0); |
934 | 934 | ||
935 | if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { | 935 | if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { |
936 | snd_saa7134_free(chip); | 936 | snd_saa7134_free(chip); |
937 | return err; | 937 | return err; |
938 | } | 938 | } |
939 | 939 | ||
940 | if ((err = snd_card_saa7134_new_mixer(chip)) < 0) | 940 | if ((err = snd_card_saa7134_new_mixer(chip)) < 0) |
941 | goto __nodev; | 941 | goto __nodev; |
@@ -943,15 +943,15 @@ int alsa_card_saa7134_create(struct saa7134_dev *saadev, unsigned int devicenum) | |||
943 | if ((err = snd_card_saa7134_pcm(chip, 0)) < 0) | 943 | if ((err = snd_card_saa7134_pcm(chip, 0)) < 0) |
944 | goto __nodev; | 944 | goto __nodev; |
945 | 945 | ||
946 | spin_lock_init(&chip->mixer_lock); | 946 | spin_lock_init(&chip->mixer_lock); |
947 | 947 | ||
948 | snd_card_set_dev(card, &chip->pci->dev); | 948 | snd_card_set_dev(card, &chip->pci->dev); |
949 | 949 | ||
950 | /* End of "creation" */ | 950 | /* End of "creation" */ |
951 | 951 | ||
952 | strcpy(card->shortname, "SAA7134"); | 952 | strcpy(card->shortname, "SAA7134"); |
953 | sprintf(card->longname, "%s at 0x%lx irq %d", | 953 | sprintf(card->longname, "%s at 0x%lx irq %d", |
954 | chip->saadev->name, chip->iobase, chip->irq); | 954 | chip->saadev->name, chip->iobase, chip->irq); |
955 | 955 | ||
956 | if ((err = snd_card_register(card)) == 0) { | 956 | if ((err = snd_card_register(card)) == 0) { |
957 | snd_saa7134_cards[dev] = card; | 957 | snd_saa7134_cards[dev] = card; |
@@ -966,8 +966,8 @@ __nodev: | |||
966 | 966 | ||
967 | void alsa_card_saa7134_exit(void) | 967 | void alsa_card_saa7134_exit(void) |
968 | { | 968 | { |
969 | int idx; | 969 | int idx; |
970 | for (idx = 0; idx < SNDRV_CARDS; idx++) { | 970 | for (idx = 0; idx < SNDRV_CARDS; idx++) { |
971 | snd_card_free(snd_saa7134_cards[idx]); | 971 | snd_card_free(snd_saa7134_cards[idx]); |
972 | } | 972 | } |
973 | } | 973 | } |