powermac.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /*
  2. * Driver for PowerMac AWACS
  3. * Copyright (c) 2001 by Takashi Iwai <tiwai@suse.de>
  4. * based on dmasound.c.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. #include <sound/driver.h>
  21. #include <linux/init.h>
  22. #include <linux/moduleparam.h>
  23. #include <sound/core.h>
  24. #include <sound/initval.h>
  25. #include "pmac.h"
  26. #include "awacs.h"
  27. #include "burgundy.h"
  28. #define CHIP_NAME "PMac"
  29. MODULE_DESCRIPTION("PowerMac");
  30. MODULE_SUPPORTED_DEVICE("{{Apple,PowerMac}}");
  31. MODULE_LICENSE("GPL");
  32. static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */
  33. static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */
  34. static int enable_beep = 1;
  35. module_param(index, int, 0444);
  36. MODULE_PARM_DESC(index, "Index value for " CHIP_NAME " soundchip.");
  37. module_param(id, charp, 0444);
  38. MODULE_PARM_DESC(id, "ID string for " CHIP_NAME " soundchip.");
  39. module_param(enable_beep, bool, 0444);
  40. MODULE_PARM_DESC(enable_beep, "Enable beep using PCM.");
  41. /*
  42. * card entry
  43. */
  44. static snd_card_t *snd_pmac_card = NULL;
  45. /*
  46. */
  47. static int __init snd_pmac_probe(void)
  48. {
  49. snd_card_t *card;
  50. pmac_t *chip;
  51. char *name_ext;
  52. int err;
  53. card = snd_card_new(index, id, THIS_MODULE, 0);
  54. if (card == NULL)
  55. return -ENOMEM;
  56. if ((err = snd_pmac_new(card, &chip)) < 0)
  57. goto __error;
  58. switch (chip->model) {
  59. case PMAC_BURGUNDY:
  60. strcpy(card->driver, "PMac Burgundy");
  61. strcpy(card->shortname, "PowerMac Burgundy");
  62. sprintf(card->longname, "%s (Dev %d) Sub-frame %d",
  63. card->shortname, chip->device_id, chip->subframe);
  64. if ((err = snd_pmac_burgundy_init(chip)) < 0)
  65. goto __error;
  66. break;
  67. case PMAC_DACA:
  68. strcpy(card->driver, "PMac DACA");
  69. strcpy(card->shortname, "PowerMac DACA");
  70. sprintf(card->longname, "%s (Dev %d) Sub-frame %d",
  71. card->shortname, chip->device_id, chip->subframe);
  72. if ((err = snd_pmac_daca_init(chip)) < 0)
  73. goto __error;
  74. break;
  75. case PMAC_TUMBLER:
  76. case PMAC_SNAPPER:
  77. name_ext = chip->model == PMAC_TUMBLER ? "Tumbler" : "Snapper";
  78. sprintf(card->driver, "PMac %s", name_ext);
  79. sprintf(card->shortname, "PowerMac %s", name_ext);
  80. sprintf(card->longname, "%s (Dev %d) Sub-frame %d",
  81. card->shortname, chip->device_id, chip->subframe);
  82. if ( snd_pmac_tumbler_init(chip) < 0 || snd_pmac_tumbler_post_init() < 0)
  83. goto __error;
  84. break;
  85. case PMAC_TOONIE:
  86. strcpy(card->driver, "PMac Toonie");
  87. strcpy(card->shortname, "PowerMac Toonie");
  88. strcpy(card->longname, card->shortname);
  89. if ((err = snd_pmac_toonie_init(chip)) < 0)
  90. goto __error;
  91. break;
  92. case PMAC_AWACS:
  93. case PMAC_SCREAMER:
  94. name_ext = chip->model == PMAC_SCREAMER ? "Screamer" : "AWACS";
  95. sprintf(card->driver, "PMac %s", name_ext);
  96. sprintf(card->shortname, "PowerMac %s", name_ext);
  97. if (chip->is_pbook_3400)
  98. name_ext = " [PB3400]";
  99. else if (chip->is_pbook_G3)
  100. name_ext = " [PBG3]";
  101. else
  102. name_ext = "";
  103. sprintf(card->longname, "%s%s Rev %d",
  104. card->shortname, name_ext, chip->revision);
  105. if ((err = snd_pmac_awacs_init(chip)) < 0)
  106. goto __error;
  107. break;
  108. default:
  109. snd_printk("unsupported hardware %d\n", chip->model);
  110. err = -EINVAL;
  111. goto __error;
  112. }
  113. if ((err = snd_pmac_pcm_new(chip)) < 0)
  114. goto __error;
  115. chip->initialized = 1;
  116. if (enable_beep)
  117. snd_pmac_attach_beep(chip);
  118. if ((err = snd_card_register(card)) < 0)
  119. goto __error;
  120. snd_pmac_card = card;
  121. return 0;
  122. __error:
  123. snd_card_free(card);
  124. return err;
  125. }
  126. /*
  127. * MODULE stuff
  128. */
  129. static int __init alsa_card_pmac_init(void)
  130. {
  131. int err;
  132. if ((err = snd_pmac_probe()) < 0)
  133. return err;
  134. return 0;
  135. }
  136. static void __exit alsa_card_pmac_exit(void)
  137. {
  138. if (snd_pmac_card)
  139. snd_card_free(snd_pmac_card);
  140. }
  141. module_init(alsa_card_pmac_init)
  142. module_exit(alsa_card_pmac_exit)