diff options
-rw-r--r-- | sound/isa/sb/emu8000.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/sound/isa/sb/emu8000.c b/sound/isa/sb/emu8000.c index 45fcdff611f9..d25e384fa8c9 100644 --- a/sound/isa/sb/emu8000.c +++ b/sound/isa/sb/emu8000.c | |||
@@ -378,13 +378,12 @@ init_arrays(struct snd_emu8000 *emu) | |||
378 | static void | 378 | static void |
379 | size_dram(struct snd_emu8000 *emu) | 379 | size_dram(struct snd_emu8000 *emu) |
380 | { | 380 | { |
381 | int i, size, detected_size; | 381 | int i, size; |
382 | 382 | ||
383 | if (emu->dram_checked) | 383 | if (emu->dram_checked) |
384 | return; | 384 | return; |
385 | 385 | ||
386 | size = 0; | 386 | size = 0; |
387 | detected_size = 0; | ||
388 | 387 | ||
389 | /* write out a magic number */ | 388 | /* write out a magic number */ |
390 | snd_emu8000_dma_chan(emu, 0, EMU8000_RAM_WRITE); | 389 | snd_emu8000_dma_chan(emu, 0, EMU8000_RAM_WRITE); |
@@ -392,10 +391,19 @@ size_dram(struct snd_emu8000 *emu) | |||
392 | EMU8000_SMALW_WRITE(emu, EMU8000_DRAM_OFFSET); | 391 | EMU8000_SMALW_WRITE(emu, EMU8000_DRAM_OFFSET); |
393 | EMU8000_SMLD_WRITE(emu, UNIQUE_ID1); | 392 | EMU8000_SMLD_WRITE(emu, UNIQUE_ID1); |
394 | snd_emu8000_init_fm(emu); /* This must really be here and not 2 lines back even */ | 393 | snd_emu8000_init_fm(emu); /* This must really be here and not 2 lines back even */ |
394 | snd_emu8000_write_wait(emu); | ||
395 | 395 | ||
396 | while (size < EMU8000_MAX_DRAM) { | 396 | /* |
397 | * Detect first 512 KiB. If a write succeeds at the beginning of a | ||
398 | * 512 KiB page we assume that the whole page is there. | ||
399 | */ | ||
400 | EMU8000_SMALR_WRITE(emu, EMU8000_DRAM_OFFSET); | ||
401 | EMU8000_SMLD_READ(emu); /* discard stale data */ | ||
402 | if (EMU8000_SMLD_READ(emu) != UNIQUE_ID1) | ||
403 | goto skip_detect; /* No RAM */ | ||
404 | snd_emu8000_read_wait(emu); | ||
397 | 405 | ||
398 | size += 512 * 1024; /* increment 512kbytes */ | 406 | for (size = 512 * 1024; size < EMU8000_MAX_DRAM; size += 512 * 1024) { |
399 | 407 | ||
400 | /* Write a unique data on the test address. | 408 | /* Write a unique data on the test address. |
401 | * if the address is out of range, the data is written on | 409 | * if the address is out of range, the data is written on |
@@ -431,18 +439,9 @@ size_dram(struct snd_emu8000 *emu) | |||
431 | snd_emu8000_read_wait(emu); | 439 | snd_emu8000_read_wait(emu); |
432 | 440 | ||
433 | /* Otherwise, it's valid memory. */ | 441 | /* Otherwise, it's valid memory. */ |
434 | detected_size = size + 512 * 1024; | ||
435 | } | ||
436 | |||
437 | /* Distinguish 512 KiB from 0. */ | ||
438 | if (detected_size == 0) { | ||
439 | snd_emu8000_read_wait(emu); | ||
440 | EMU8000_SMALR_WRITE(emu, EMU8000_DRAM_OFFSET); | ||
441 | EMU8000_SMLD_READ(emu); /* discard stale data */ | ||
442 | if (EMU8000_SMLD_READ(emu) == UNIQUE_ID1) | ||
443 | detected_size = 512 * 1024; | ||
444 | } | 442 | } |
445 | 443 | ||
444 | skip_detect: | ||
446 | /* wait until FULL bit in SMAxW register is false */ | 445 | /* wait until FULL bit in SMAxW register is false */ |
447 | for (i = 0; i < 10000; i++) { | 446 | for (i = 0; i < 10000; i++) { |
448 | if ((EMU8000_SMALW_READ(emu) & 0x80000000) == 0) | 447 | if ((EMU8000_SMALW_READ(emu) & 0x80000000) == 0) |
@@ -455,9 +454,9 @@ size_dram(struct snd_emu8000 *emu) | |||
455 | snd_emu8000_dma_chan(emu, 1, EMU8000_RAM_CLOSE); | 454 | snd_emu8000_dma_chan(emu, 1, EMU8000_RAM_CLOSE); |
456 | 455 | ||
457 | snd_printdd("EMU8000 [0x%lx]: %d Kb on-board memory detected\n", | 456 | snd_printdd("EMU8000 [0x%lx]: %d Kb on-board memory detected\n", |
458 | emu->port1, detected_size/1024); | 457 | emu->port1, size/1024); |
459 | 458 | ||
460 | emu->mem_size = detected_size; | 459 | emu->mem_size = size; |
461 | emu->dram_checked = 1; | 460 | emu->dram_checked = 1; |
462 | } | 461 | } |
463 | 462 | ||