diff options
author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2014-12-08 10:10:40 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2014-12-10 04:46:46 -0500 |
commit | fec7b7536207897693e708411dcb95909d56c431 (patch) | |
tree | 20ddf4a16d5669eaed1f2874cca52ce520a1a7bc /sound/firewire | |
parent | a113ff886b9a6e892dd4107be1fd7883cf020885 (diff) |
ALSA: oxfw: Change the way to name card
This is a preparation for more models. In following commit, members
of 'struct snd_card' related to name becomes to consists of vendor and
model strings in device's config-rom.
Current supported devices also has strings in their config rom, but the
strings are too long to name sound card, thus this driver still keep
hard-coded vendor and model names for them.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Acked-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/firewire')
-rw-r--r-- | sound/firewire/oxfw/oxfw.c | 53 | ||||
-rw-r--r-- | sound/firewire/oxfw/oxfw.h | 4 |
2 files changed, 34 insertions, 23 deletions
diff --git a/sound/firewire/oxfw/oxfw.c b/sound/firewire/oxfw/oxfw.c index 951d9a4e2102..dd576bf61c37 100644 --- a/sound/firewire/oxfw/oxfw.c +++ b/sound/firewire/oxfw/oxfw.c | |||
@@ -25,14 +25,34 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>"); | |||
25 | MODULE_LICENSE("GPL v2"); | 25 | MODULE_LICENSE("GPL v2"); |
26 | MODULE_ALIAS("snd-firewire-speakers"); | 26 | MODULE_ALIAS("snd-firewire-speakers"); |
27 | 27 | ||
28 | static u32 oxfw_read_firmware_version(struct fw_unit *unit) | 28 | static int name_card(struct snd_oxfw *oxfw) |
29 | { | 29 | { |
30 | __be32 data; | 30 | struct fw_device *fw_dev = fw_parent_device(oxfw->unit); |
31 | const char *d, *v, *m; | ||
32 | u32 firmware; | ||
31 | int err; | 33 | int err; |
32 | 34 | ||
33 | err = snd_fw_transaction(unit, TCODE_READ_QUADLET_REQUEST, | 35 | err = snd_fw_transaction(oxfw->unit, TCODE_READ_QUADLET_REQUEST, |
34 | OXFORD_FIRMWARE_ID_ADDRESS, &data, 4, 0); | 36 | OXFORD_FIRMWARE_ID_ADDRESS, &firmware, 4, 0); |
35 | return err >= 0 ? be32_to_cpu(data) : 0; | 37 | if (err < 0) |
38 | goto end; | ||
39 | be32_to_cpus(&firmware); | ||
40 | |||
41 | d = oxfw->device_info->driver_name; | ||
42 | v = oxfw->device_info->vendor_name; | ||
43 | m = oxfw->device_info->model_name; | ||
44 | |||
45 | strcpy(oxfw->card->driver, d); | ||
46 | strcpy(oxfw->card->mixername, m); | ||
47 | strcpy(oxfw->card->shortname, m); | ||
48 | |||
49 | snprintf(oxfw->card->longname, sizeof(oxfw->card->longname), | ||
50 | "%s %s (OXFW%x %04x), GUID %08x%08x at %s, S%d", | ||
51 | v, m, firmware >> 20, firmware & 0xffff, | ||
52 | fw_dev->config_rom[3], fw_dev->config_rom[4], | ||
53 | dev_name(&oxfw->unit->device), 100 << fw_dev->max_speed); | ||
54 | end: | ||
55 | return err; | ||
36 | } | 56 | } |
37 | 57 | ||
38 | static void oxfw_card_free(struct snd_card *card) | 58 | static void oxfw_card_free(struct snd_card *card) |
@@ -45,10 +65,8 @@ static void oxfw_card_free(struct snd_card *card) | |||
45 | static int oxfw_probe(struct fw_unit *unit, | 65 | static int oxfw_probe(struct fw_unit *unit, |
46 | const struct ieee1394_device_id *id) | 66 | const struct ieee1394_device_id *id) |
47 | { | 67 | { |
48 | struct fw_device *fw_dev = fw_parent_device(unit); | ||
49 | struct snd_card *card; | 68 | struct snd_card *card; |
50 | struct snd_oxfw *oxfw; | 69 | struct snd_oxfw *oxfw; |
51 | u32 firmware; | ||
52 | int err; | 70 | int err; |
53 | 71 | ||
54 | err = snd_card_new(&unit->device, -1, NULL, THIS_MODULE, | 72 | err = snd_card_new(&unit->device, -1, NULL, THIS_MODULE, |
@@ -63,16 +81,9 @@ static int oxfw_probe(struct fw_unit *unit, | |||
63 | oxfw->unit = unit; | 81 | oxfw->unit = unit; |
64 | oxfw->device_info = (const struct device_info *)id->driver_data; | 82 | oxfw->device_info = (const struct device_info *)id->driver_data; |
65 | 83 | ||
66 | strcpy(card->driver, oxfw->device_info->driver_name); | 84 | err = name_card(oxfw); |
67 | strcpy(card->shortname, oxfw->device_info->short_name); | 85 | if (err < 0) |
68 | firmware = oxfw_read_firmware_version(unit); | 86 | goto error; |
69 | snprintf(card->longname, sizeof(card->longname), | ||
70 | "%s (OXFW%x %04x), GUID %08x%08x at %s, S%d", | ||
71 | oxfw->device_info->long_name, | ||
72 | firmware >> 20, firmware & 0xffff, | ||
73 | fw_dev->config_rom[3], fw_dev->config_rom[4], | ||
74 | dev_name(&unit->device), 100 << fw_dev->max_speed); | ||
75 | strcpy(card->mixername, "OXFW"); | ||
76 | 87 | ||
77 | err = snd_oxfw_create_pcm(oxfw); | 88 | err = snd_oxfw_create_pcm(oxfw); |
78 | if (err < 0) | 89 | if (err < 0) |
@@ -123,8 +134,8 @@ static void oxfw_remove(struct fw_unit *unit) | |||
123 | 134 | ||
124 | static const struct device_info griffin_firewave = { | 135 | static const struct device_info griffin_firewave = { |
125 | .driver_name = "FireWave", | 136 | .driver_name = "FireWave", |
126 | .short_name = "FireWave", | 137 | .vendor_name = "Griffin", |
127 | .long_name = "Griffin FireWave Surround", | 138 | .model_name = "FireWave", |
128 | .pcm_constraints = firewave_constraints, | 139 | .pcm_constraints = firewave_constraints, |
129 | .mixer_channels = 6, | 140 | .mixer_channels = 6, |
130 | .mute_fb_id = 0x01, | 141 | .mute_fb_id = 0x01, |
@@ -133,8 +144,8 @@ static const struct device_info griffin_firewave = { | |||
133 | 144 | ||
134 | static const struct device_info lacie_speakers = { | 145 | static const struct device_info lacie_speakers = { |
135 | .driver_name = "FWSpeakers", | 146 | .driver_name = "FWSpeakers", |
136 | .short_name = "FireWire Speakers", | 147 | .vendor_name = "LaCie", |
137 | .long_name = "LaCie FireWire Speakers", | 148 | .model_name = "FireWire Speakers", |
138 | .pcm_constraints = lacie_speakers_constraints, | 149 | .pcm_constraints = lacie_speakers_constraints, |
139 | .mixer_channels = 1, | 150 | .mixer_channels = 1, |
140 | .mute_fb_id = 0x01, | 151 | .mute_fb_id = 0x01, |
diff --git a/sound/firewire/oxfw/oxfw.h b/sound/firewire/oxfw/oxfw.h index 6164bf3e1f5a..a61c75cbaba8 100644 --- a/sound/firewire/oxfw/oxfw.h +++ b/sound/firewire/oxfw/oxfw.h | |||
@@ -28,8 +28,8 @@ | |||
28 | 28 | ||
29 | struct device_info { | 29 | struct device_info { |
30 | const char *driver_name; | 30 | const char *driver_name; |
31 | const char *short_name; | 31 | const char *vendor_name; |
32 | const char *long_name; | 32 | const char *model_name; |
33 | int (*pcm_constraints)(struct snd_pcm_runtime *runtime); | 33 | int (*pcm_constraints)(struct snd_pcm_runtime *runtime); |
34 | unsigned int mixer_channels; | 34 | unsigned int mixer_channels; |
35 | u8 mute_fb_id; | 35 | u8 mute_fb_id; |