blob: 171d80c1b02071fdadc2e7111e34b0cde49565a6 [file] [log] [blame]
Markus Grabner705ecec2009-02-27 19:43:04 -08001/*
Markus Grabnere1a164d2010-08-23 01:08:25 +02002 * Line6 Linux USB driver - 0.9.1beta
Markus Grabner705ecec2009-02-27 19:43:04 -08003 *
Markus Grabner1027f4762010-08-12 01:35:30 +02004 * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
Markus Grabner705ecec2009-02-27 19:43:04 -08005 *
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
Markus Grabner705ecec2009-02-27 19:43:04 -080012#include <sound/core.h>
13#include <sound/initval.h>
Paul Gortmaker8e336a72011-07-10 13:09:12 -040014#include <linux/export.h>
Markus Grabner705ecec2009-02-27 19:43:04 -080015
Markus Grabner1027f4762010-08-12 01:35:30 +020016#include "driver.h"
17#include "audio.h"
18
Markus Grabner705ecec2009-02-27 19:43:04 -080019/*
20 Initialize the Line6 USB audio system.
21*/
22int line6_init_audio(struct usb_line6 *line6)
23{
Markus Grabner705ecec2009-02-27 19:43:04 -080024 struct snd_card *card;
Alexander Beregalova405f432009-03-29 19:59:13 +040025 int err;
Markus Grabner705ecec2009-02-27 19:43:04 -080026
Takashi Iwaib029a942014-01-29 15:02:40 +010027 err = snd_card_new(line6->ifcdev,
28 SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
29 THIS_MODULE, 0, &card);
Alexander Beregalova405f432009-03-29 19:59:13 +040030 if (err < 0)
31 return err;
Markus Grabner705ecec2009-02-27 19:43:04 -080032
33 line6->card = card;
34
Markus Grabner1027f4762010-08-12 01:35:30 +020035 strcpy(card->id, line6->properties->id);
Markus Grabner705ecec2009-02-27 19:43:04 -080036 strcpy(card->driver, DRIVER_NAME);
Markus Grabner1027f4762010-08-12 01:35:30 +020037 strcpy(card->shortname, line6->properties->name);
Greg Kroah-Hartman027360c2010-09-21 16:58:00 -070038 /* longname is 80 chars - see asound.h */
39 sprintf(card->longname, "Line6 %s at USB %s", line6->properties->name,
40 dev_name(line6->ifcdev));
Markus Grabner705ecec2009-02-27 19:43:04 -080041 return 0;
42}
43
44/*
45 Register the Line6 USB audio system.
46*/
47int line6_register_audio(struct usb_line6 *line6)
48{
49 int err;
50
Greg Kroah-Hartmandfc70562009-02-27 22:41:54 -080051 err = snd_card_register(line6->card);
52 if (err < 0)
Markus Grabner705ecec2009-02-27 19:43:04 -080053 return err;
54
55 return 0;
56}
57
58/*
59 Cleanup the Line6 USB audio system.
60*/
61void line6_cleanup_audio(struct usb_line6 *line6)
62{
63 struct snd_card *card = line6->card;
64
Greg Kroah-Hartman536165d2009-02-27 20:49:46 -080065 if (card == NULL)
Markus Grabner705ecec2009-02-27 19:43:04 -080066 return;
67
68 snd_card_disconnect(card);
69 snd_card_free(card);
Greg Kroah-Hartman536165d2009-02-27 20:49:46 -080070 line6->card = NULL;
Markus Grabner705ecec2009-02-27 19:43:04 -080071}