audio.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Line6 Linux USB driver - 0.9.1beta
  3. *
  4. * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation, version 2.
  9. *
  10. */
  11. #include <sound/core.h>
  12. #include <sound/initval.h>
  13. #include <linux/export.h>
  14. #include "driver.h"
  15. #include "audio.h"
  16. /*
  17. Initialize the Line6 USB audio system.
  18. */
  19. int line6_init_audio(struct usb_line6 *line6)
  20. {
  21. struct snd_card *card;
  22. int err;
  23. err = snd_card_new(line6->ifcdev,
  24. SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
  25. THIS_MODULE, 0, &card);
  26. if (err < 0)
  27. return err;
  28. line6->card = card;
  29. strcpy(card->id, line6->properties->id);
  30. strcpy(card->driver, DRIVER_NAME);
  31. strcpy(card->shortname, line6->properties->name);
  32. /* longname is 80 chars - see asound.h */
  33. sprintf(card->longname, "Line6 %s at USB %s", line6->properties->name,
  34. dev_name(line6->ifcdev));
  35. return 0;
  36. }
  37. /*
  38. Register the Line6 USB audio system.
  39. */
  40. int line6_register_audio(struct usb_line6 *line6)
  41. {
  42. int err;
  43. err = snd_card_register(line6->card);
  44. if (err < 0)
  45. return err;
  46. return 0;
  47. }
  48. /*
  49. Cleanup the Line6 USB audio system.
  50. */
  51. void line6_cleanup_audio(struct usb_line6 *line6)
  52. {
  53. struct snd_card *card = line6->card;
  54. if (card == NULL)
  55. return;
  56. snd_card_disconnect(card);
  57. snd_card_free(card);
  58. line6->card = NULL;
  59. }