Skip to content

Commit 41319eb

Browse files
takaswietiwai
authored andcommitted
ALSA: dice: wait just for NOTIFY_CLOCK_ACCEPTED after GLOBAL_CLOCK_SELECT operation
NOTIFY_CLOCK_ACCEPTED notification is always generated as a result of GLOBAL_CLOCK_SELECT operation, however NOTIFY_LOCK_CHG notification doesn't, as long as the selected clock is already configured. In the case, ALSA dice driver waits so long. It's inconvenient for some devices to lock to the sequence of value in syt field of CIP header in rx packets. This commit wait just for NOTIFY_CLOCK_ACCEPTED notification by reverting changes partially done by two commits below: * commit fbeac84 ("ALSA: dice: old firmware optimization for Dice notification") * commit aec045b ("ALSA: dice: change notification mask to detect lock status change") I note that the successful lock to the sequence of value in syt field of CIP header in rx packets results in NOTIFY_EXT_STATUS notification, then EXT_STATUS_ARX1_LOCKED bit stands in GLOBAL_EXTENDED_STATUS register. The notification can occur enough after receiving the batch of rx packets. When the sequence doesn't include value in syt field of CIP header in rx packets adequate to the device, the notification occurs again and the bit is off. Signed-off-by: Takashi Sakamoto <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent dfacca3 commit 41319eb

File tree

2 files changed

+8
-23
lines changed

2 files changed

+8
-23
lines changed

sound/firewire/dice/dice-stream.c

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "dice.h"
1010

1111
#define READY_TIMEOUT_MS 200
12-
#define NOTIFICATION_TIMEOUT_MS (2 * MSEC_PER_SEC)
12+
#define NOTIFICATION_TIMEOUT_MS 100
1313

1414
struct reg_params {
1515
unsigned int count;
@@ -57,13 +57,9 @@ int snd_dice_stream_get_rate_mode(struct snd_dice *dice, unsigned int rate,
5757
return -EINVAL;
5858
}
5959

60-
/*
61-
* This operation has an effect to synchronize GLOBAL_STATUS/GLOBAL_SAMPLE_RATE
62-
* to GLOBAL_STATUS. Especially, just after powering on, these are different.
63-
*/
64-
static int ensure_phase_lock(struct snd_dice *dice, unsigned int rate)
60+
static int select_clock(struct snd_dice *dice, unsigned int rate)
6561
{
66-
__be32 reg, nominal;
62+
__be32 reg;
6763
u32 data;
6864
int i;
6965
int err;
@@ -94,19 +90,8 @@ static int ensure_phase_lock(struct snd_dice *dice, unsigned int rate)
9490
return err;
9591

9692
if (wait_for_completion_timeout(&dice->clock_accepted,
97-
msecs_to_jiffies(NOTIFICATION_TIMEOUT_MS)) == 0) {
98-
/*
99-
* Old versions of Dice firmware transfer no notification when
100-
* the same clock status as current one is set. In this case,
101-
* just check current clock status.
102-
*/
103-
err = snd_dice_transaction_read_global(dice, GLOBAL_STATUS,
104-
&nominal, sizeof(nominal));
105-
if (err < 0)
106-
return err;
107-
if (!(be32_to_cpu(nominal) & STATUS_SOURCE_LOCKED))
108-
return -ETIMEDOUT;
109-
}
93+
msecs_to_jiffies(NOTIFICATION_TIMEOUT_MS)) == 0)
94+
return -ETIMEDOUT;
11095

11196
return 0;
11297
}
@@ -304,7 +289,7 @@ int snd_dice_stream_reserve_duplex(struct snd_dice *dice, unsigned int rate,
304289
// Just after owning the unit (GLOBAL_OWNER), the unit can
305290
// return invalid stream formats. Selecting clock parameters
306291
// have an effect for the unit to refine it.
307-
err = ensure_phase_lock(dice, rate);
292+
err = select_clock(dice, rate);
308293
if (err < 0)
309294
return err;
310295

@@ -646,7 +631,7 @@ int snd_dice_stream_detect_current_formats(struct snd_dice *dice)
646631
* invalid stream formats. Selecting clock parameters have an effect
647632
* for the unit to refine it.
648633
*/
649-
err = ensure_phase_lock(dice, rate);
634+
err = select_clock(dice, rate);
650635
if (err < 0)
651636
return err;
652637

sound/firewire/dice/dice-transaction.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ static void dice_notification(struct fw_card *card, struct fw_request *request,
155155

156156
fw_send_response(card, request, RCODE_COMPLETE);
157157

158-
if (bits & NOTIFY_LOCK_CHG)
158+
if (bits & NOTIFY_CLOCK_ACCEPTED)
159159
complete(&dice->clock_accepted);
160160
wake_up(&dice->hwdep_wait);
161161
}

0 commit comments

Comments
 (0)