forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-09-20 cf4ce59b3b70238352c7f1729f0f7223214828ad
kernel/sound/firewire/dice/dice.c
....@@ -1,8 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * TC Applied Technologies Digital Interface Communications Engine driver
34 *
45 * Copyright (c) Clemens Ladisch <clemens@ladisch.de>
5
- * Licensed under the terms of the GNU General Public License, version 2.
66 */
77
88 #include "dice.h"
....@@ -19,6 +19,7 @@
1919 #define OUI_MAUDIO 0x000d6c
2020 #define OUI_MYTEK 0x001ee8
2121 #define OUI_SSL 0x0050c2 // Actually ID reserved by IEEE.
22
+#define OUI_PRESONUS 0x000a92
2223
2324 #define DICE_CATEGORY_ID 0x04
2425 #define WEISS_CATEGORY_ID 0x00
....@@ -123,25 +124,12 @@
123124 strcpy(card->mixername, "DICE");
124125 }
125126
126
-static void dice_free(struct snd_dice *dice)
127
-{
128
- snd_dice_stream_destroy_duplex(dice);
129
- snd_dice_transaction_destroy(dice);
130
- fw_unit_put(dice->unit);
131
-
132
- mutex_destroy(&dice->mutex);
133
- kfree(dice);
134
-}
135
-
136
-/*
137
- * This module releases the FireWire unit data after all ALSA character devices
138
- * are released by applications. This is for releasing stream data or finishing
139
- * transactions safely. Thus at returning from .remove(), this module still keep
140
- * references for the unit.
141
- */
142127 static void dice_card_free(struct snd_card *card)
143128 {
144
- dice_free(card->private_data);
129
+ struct snd_dice *dice = card->private_data;
130
+
131
+ snd_dice_stream_destroy_duplex(dice);
132
+ snd_dice_transaction_destroy(dice);
145133 }
146134
147135 static void do_registration(struct work_struct *work)
....@@ -156,6 +144,8 @@
156144 &dice->card);
157145 if (err < 0)
158146 return;
147
+ dice->card->private_free = dice_card_free;
148
+ dice->card->private_data = dice;
159149
160150 err = snd_dice_transaction_init(dice);
161151 if (err < 0)
....@@ -193,19 +183,10 @@
193183 if (err < 0)
194184 goto error;
195185
196
- /*
197
- * After registered, dice instance can be released corresponding to
198
- * releasing the sound card instance.
199
- */
200
- dice->card->private_free = dice_card_free;
201
- dice->card->private_data = dice;
202186 dice->registered = true;
203187
204188 return;
205189 error:
206
- snd_dice_stream_destroy_duplex(dice);
207
- snd_dice_transaction_destroy(dice);
208
- snd_dice_stream_destroy_duplex(dice);
209190 snd_card_free(dice->card);
210191 dev_info(&dice->unit->device,
211192 "Sound card registration failed: %d\n", err);
....@@ -224,10 +205,9 @@
224205 }
225206
226207 /* Allocate this independent of sound card instance. */
227
- dice = kzalloc(sizeof(struct snd_dice), GFP_KERNEL);
228
- if (dice == NULL)
208
+ dice = devm_kzalloc(&unit->device, sizeof(struct snd_dice), GFP_KERNEL);
209
+ if (!dice)
229210 return -ENOMEM;
230
-
231211 dice->unit = fw_unit_get(unit);
232212 dev_set_drvdata(&unit->device, dice);
233213
....@@ -262,12 +242,12 @@
262242 cancel_delayed_work_sync(&dice->dwork);
263243
264244 if (dice->registered) {
265
- /* No need to wait for releasing card object in this context. */
266
- snd_card_free_when_closed(dice->card);
267
- } else {
268
- /* Don't forget this case. */
269
- dice_free(dice);
245
+ // Block till all of ALSA character devices are released.
246
+ snd_card_free(dice->card);
270247 }
248
+
249
+ mutex_destroy(&dice->mutex);
250
+ fw_unit_put(dice->unit);
271251 }
272252
273253 static void dice_bus_reset(struct fw_unit *unit)
....@@ -375,6 +355,14 @@
375355 .model_id = MODEL_ALESIS_IO_BOTH,
376356 .driver_data = (kernel_ulong_t)snd_dice_detect_alesis_formats,
377357 },
358
+ // Alesis MasterControl.
359
+ {
360
+ .match_flags = IEEE1394_MATCH_VENDOR_ID |
361
+ IEEE1394_MATCH_MODEL_ID,
362
+ .vendor_id = OUI_ALESIS,
363
+ .model_id = 0x000002,
364
+ .driver_data = (kernel_ulong_t)snd_dice_detect_alesis_mastercontrol_formats,
365
+ },
378366 /* Mytek Stereo 192 DSD-DAC. */
379367 {
380368 .match_flags = IEEE1394_MATCH_VENDOR_ID |
....@@ -392,6 +380,14 @@
392380 .vendor_id = OUI_SSL,
393381 .model_id = 0x000070,
394382 },
383
+ // Presonus FireStudio.
384
+ {
385
+ .match_flags = IEEE1394_MATCH_VENDOR_ID |
386
+ IEEE1394_MATCH_MODEL_ID,
387
+ .vendor_id = OUI_PRESONUS,
388
+ .model_id = 0x000008,
389
+ .driver_data = (kernel_ulong_t)snd_dice_detect_presonus_formats,
390
+ },
395391 {
396392 .match_flags = IEEE1394_MATCH_VERSION,
397393 .version = DICE_INTERFACE,