From cf4ce59b3b70238352c7f1729f0f7223214828ad Mon Sep 17 00:00:00 2001 From: hc <hc@nodka.com> Date: Fri, 20 Sep 2024 01:46:19 +0000 Subject: [PATCH] rtl88x2CE_WiFi_linux add concurrent mode --- kernel/sound/firewire/dice/dice.c | 66 +++++++++++++++----------------- 1 files changed, 31 insertions(+), 35 deletions(-) diff --git a/kernel/sound/firewire/dice/dice.c b/kernel/sound/firewire/dice/dice.c index 3d600f4..06c94f0 100644 --- a/kernel/sound/firewire/dice/dice.c +++ b/kernel/sound/firewire/dice/dice.c @@ -1,8 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-only /* * TC Applied Technologies Digital Interface Communications Engine driver * * Copyright (c) Clemens Ladisch <clemens@ladisch.de> - * Licensed under the terms of the GNU General Public License, version 2. */ #include "dice.h" @@ -19,6 +19,7 @@ #define OUI_MAUDIO 0x000d6c #define OUI_MYTEK 0x001ee8 #define OUI_SSL 0x0050c2 // Actually ID reserved by IEEE. +#define OUI_PRESONUS 0x000a92 #define DICE_CATEGORY_ID 0x04 #define WEISS_CATEGORY_ID 0x00 @@ -123,25 +124,12 @@ strcpy(card->mixername, "DICE"); } -static void dice_free(struct snd_dice *dice) -{ - snd_dice_stream_destroy_duplex(dice); - snd_dice_transaction_destroy(dice); - fw_unit_put(dice->unit); - - mutex_destroy(&dice->mutex); - kfree(dice); -} - -/* - * This module releases the FireWire unit data after all ALSA character devices - * are released by applications. This is for releasing stream data or finishing - * transactions safely. Thus at returning from .remove(), this module still keep - * references for the unit. - */ static void dice_card_free(struct snd_card *card) { - dice_free(card->private_data); + struct snd_dice *dice = card->private_data; + + snd_dice_stream_destroy_duplex(dice); + snd_dice_transaction_destroy(dice); } static void do_registration(struct work_struct *work) @@ -156,6 +144,8 @@ &dice->card); if (err < 0) return; + dice->card->private_free = dice_card_free; + dice->card->private_data = dice; err = snd_dice_transaction_init(dice); if (err < 0) @@ -193,19 +183,10 @@ if (err < 0) goto error; - /* - * After registered, dice instance can be released corresponding to - * releasing the sound card instance. - */ - dice->card->private_free = dice_card_free; - dice->card->private_data = dice; dice->registered = true; return; error: - snd_dice_stream_destroy_duplex(dice); - snd_dice_transaction_destroy(dice); - snd_dice_stream_destroy_duplex(dice); snd_card_free(dice->card); dev_info(&dice->unit->device, "Sound card registration failed: %d\n", err); @@ -224,10 +205,9 @@ } /* Allocate this independent of sound card instance. */ - dice = kzalloc(sizeof(struct snd_dice), GFP_KERNEL); - if (dice == NULL) + dice = devm_kzalloc(&unit->device, sizeof(struct snd_dice), GFP_KERNEL); + if (!dice) return -ENOMEM; - dice->unit = fw_unit_get(unit); dev_set_drvdata(&unit->device, dice); @@ -262,12 +242,12 @@ cancel_delayed_work_sync(&dice->dwork); if (dice->registered) { - /* No need to wait for releasing card object in this context. */ - snd_card_free_when_closed(dice->card); - } else { - /* Don't forget this case. */ - dice_free(dice); + // Block till all of ALSA character devices are released. + snd_card_free(dice->card); } + + mutex_destroy(&dice->mutex); + fw_unit_put(dice->unit); } static void dice_bus_reset(struct fw_unit *unit) @@ -375,6 +355,14 @@ .model_id = MODEL_ALESIS_IO_BOTH, .driver_data = (kernel_ulong_t)snd_dice_detect_alesis_formats, }, + // Alesis MasterControl. + { + .match_flags = IEEE1394_MATCH_VENDOR_ID | + IEEE1394_MATCH_MODEL_ID, + .vendor_id = OUI_ALESIS, + .model_id = 0x000002, + .driver_data = (kernel_ulong_t)snd_dice_detect_alesis_mastercontrol_formats, + }, /* Mytek Stereo 192 DSD-DAC. */ { .match_flags = IEEE1394_MATCH_VENDOR_ID | @@ -392,6 +380,14 @@ .vendor_id = OUI_SSL, .model_id = 0x000070, }, + // Presonus FireStudio. + { + .match_flags = IEEE1394_MATCH_VENDOR_ID | + IEEE1394_MATCH_MODEL_ID, + .vendor_id = OUI_PRESONUS, + .model_id = 0x000008, + .driver_data = (kernel_ulong_t)snd_dice_detect_presonus_formats, + }, { .match_flags = IEEE1394_MATCH_VERSION, .version = DICE_INTERFACE, -- Gitblit v1.6.2