All of lore.kernel.org
 help / color / mirror / Atom feed
* Old firmware version for Dice II ASIC
@ 2018-04-18 10:24 Takashi Sakamoto
  2018-04-19  8:54 ` Clemens Ladisch
  0 siblings, 1 reply; 5+ messages in thread
From: Takashi Sakamoto @ 2018-04-18 10:24 UTC (permalink / raw)
  To: Clemens Ladisch; +Cc: alsa-devel

Hi Clemens,

Recently I get Alesis Multimix 12 FireWire and work for ALSA dice driver
to support it. This unit uses ASIC of 'WaveFront DICE II STD' and TCAT
extended application protocol is not supported.

Unfortunately, the driver in v4.17-rc1 can't handle this unit, due to
validation of address sections for global space.

$ dmesg
snd_dice fw1.0: Sound card registration failed: -19

(sound/firewire/dice/dice-transaction.c)
265 static int get_subaddrs(struct snd_dice *dice)
266 {
267     static const int min_values[10] = {
268             10, 0x64 / 4,
269             10, 0x18 / 4,
270             10, 0x18 / 4,
271             0, 0,
272             0, 0,
273     };
         ...
290     err = snd_fw_transaction(dice->unit, TCODE_READ_BLOCK_REQUEST,
291                      DICE_PRIVATE_SPACE, pointers,
292                      sizeof(__be32) * ARRAY_SIZE(min_values), 0);
293     if (err < 0)
294         goto end;
295
296     for (i = 0; i < ARRAY_SIZE(min_values); ++i) {
297         data = be32_to_cpu(pointers[i]);
298         if (data < min_values[i] || data >= 0x40000) {
299             err = -ENODEV;
300             goto end;
301         }
302     }

The condition 'data < min_values[i]' is evaluated as true at a second
iteration (i = 1). A quadlet of 0xffffe0000004-7 has 0x000018 and this
is less than 0x19 (= 0x64 / 4) in fact.

$ ./firewire-request /dev/fw1 read 0xffffe0000000 28
result: 000: 00 00 00 0a 00 00 00 18 00 00 00 22 00 00 00 8a
result: 010: 00 00 00 ac 00 00 01 12 00 00 00 00 00 00 00 00
result: 020: 00 00 00 00 00 00 00 00

In line 183 of 'sound/firewire/dice/dice-interface.h', I can see below
comments:

(sound/firewire/dice/dice-interface.h)
175 #define GLOBAL_SAMPLE_RATE              0x05c
...
181 #define GLOBAL_VERSION                  0x060
182
183 /* Some old firmware versions do not have the following global 
registers: */
...
188 #define GLOBAL_CLOCK_CAPABILITIES       0x064

But this is not proper in my case because the maximum offset on global
sub-address space is 0x05c in quadlet unit.

Well, this unit supports 44.1/48.0 kHz and use internal/Rx1 as its
sampling clock source according to user manual. This is what in
'check_clock_caps()'.

(sound/firewire/dice/dice.c)
  96 static int check_clock_caps(struct snd_dice *dice)
  97 {
101     /* some very old firmwares don't tell about their clock support */
102     if (dice->clock_caps > 0) {
         ...
109     } else {
110         /* this should be supported by any device */
111         dice->clock_caps = CLOCK_CAP_RATE_44100 |
112                            CLOCK_CAP_RATE_48000 |
113                            CLOCK_CAP_SOURCE_ARX1 |
114                            CLOCK_CAP_SOURCE_INTERNAL;
115     }

In my opinion, GLOBAL_VERSION offset belongs to global address space for
newer firmware version. Would I request any comment to you for this
idea?


Regards

Takashi Sakamoto

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Old firmware version for Dice II ASIC
  2018-04-18 10:24 Old firmware version for Dice II ASIC Takashi Sakamoto
@ 2018-04-19  8:54 ` Clemens Ladisch
  2018-04-19 12:49   ` Takashi Sakamoto
  0 siblings, 1 reply; 5+ messages in thread
From: Clemens Ladisch @ 2018-04-19  8:54 UTC (permalink / raw)
  To: Takashi Sakamoto; +Cc: alsa-devel

Takashi Sakamoto wrote:
> Recently I get Alesis Multimix 12 FireWire and work for ALSA dice driver
> to support it. This unit uses ASIC of 'WaveFront DICE II STD' and TCAT
> extended application protocol is not supported.
>
> Unfortunately, the driver in v4.17-rc1 can't handle this unit, due to
> validation of address sections for global space.
> [...]
> (sound/firewire/dice/dice-interface.h)
> 175 #define GLOBAL_SAMPLE_RATE              0x05c
> ...
> 181 #define GLOBAL_VERSION                  0x060
> 182
> 183 /* Some old firmware versions do not have the following global registers: */
> ...
> 188 #define GLOBAL_CLOCK_CAPABILITIES       0x064
>
> But this is not proper in my case because the maximum offset on global
> sub-address space is 0x05c in quadlet unit.

IIRC that comment was based on the documentation.  Apparently, there was
a misunderstanding of "size 0x60" vs. "up to the register at 0x60".

> In my opinion, GLOBAL_VERSION offset belongs to global address space for
> newer firmware version.

I agree; if this is how the hardware behaves, then this is what the driver
should support.

The version register is checked only once (in get_subaddrs()) and does not
actually affect the behaviour of the driver, so it would not hurt to simply
omit that check on the old firmware.  (And the "quadlets >= 90" check in
dice_proc_read() needs to be adjusted.)


Regards,
Clemens

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Old firmware version for Dice II ASIC
  2018-04-19  8:54 ` Clemens Ladisch
@ 2018-04-19 12:49   ` Takashi Sakamoto
  2018-04-19 16:21     ` Clemens Ladisch
  0 siblings, 1 reply; 5+ messages in thread
From: Takashi Sakamoto @ 2018-04-19 12:49 UTC (permalink / raw)
  To: Clemens Ladisch; +Cc: alsa-devel

Hi Clemens,

Thanks for your comment.

On Apr 19 2018 17:54, Clemens Ladisch wrote:
> Takashi Sakamoto wrote:
>> Recently I get Alesis Multimix 12 FireWire and work for ALSA dice driver
>> to support it. This unit uses ASIC of 'WaveFront DICE II STD' and TCAT
>> extended application protocol is not supported.
>>
>> Unfortunately, the driver in v4.17-rc1 can't handle this unit, due to
>> validation of address sections for global space.
>> [...]
>> (sound/firewire/dice/dice-interface.h)
>> 175 #define GLOBAL_SAMPLE_RATE              0x05c
>> ...
>> 181 #define GLOBAL_VERSION                  0x060
>> 182
>> 183 /* Some old firmware versions do not have the following global registers: */
>> ...
>> 188 #define GLOBAL_CLOCK_CAPABILITIES       0x064
>>
>> But this is not proper in my case because the maximum offset on global
>> sub-address space is 0x05c in quadlet unit.
> 
> IIRC that comment was based on the documentation.  Apparently, there was
> a misunderstanding of "size 0x60" vs. "up to the register at 0x60".

Aha. I'm OK.

 From my curiosity, do you know which version of DICE firstly supports 
GLOBAL_VERSION register? Can you read it on the documentation?

>> In my opinion, GLOBAL_VERSION offset belongs to global address space for
>> newer firmware version.
> 
> I agree; if this is how the hardware behaves, then this is what the driver
> should support.
>
> The version register is checked only once (in get_subaddrs()) and does not
> actually affect the behaviour of the driver, so it would not hurt to simply
> omit that check on the old firmware.  (And the "quadlets >= 90" check in
> dice_proc_read() needs to be adjusted.)

Hm. The check is applied to the other spaces such as rx/tx, so I'd like 
to leave it as is. With this patch[1], ALSA dice driver can handle the 
unit. In this weekend, I'll post it. Your reviewing is very helpful.

[1] 
https://github.com/takaswie/snd-firewire-improve/commit/1889e06b9593e16da2812010ffd5a8e4b9bc777d


Thanks

Takashi Sakamoto

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Old firmware version for Dice II ASIC
  2018-04-19 12:49   ` Takashi Sakamoto
@ 2018-04-19 16:21     ` Clemens Ladisch
  2018-04-21  4:10       ` Takashi Sakamoto
  0 siblings, 1 reply; 5+ messages in thread
From: Clemens Ladisch @ 2018-04-19 16:21 UTC (permalink / raw)
  To: Takashi Sakamoto; +Cc: alsa-devel

Takashi Sakamoto wrote:
> On Apr 19 2018 17:54, Clemens Ladisch wrote:
>> Takashi Sakamoto wrote:
>>> 183 /* Some old firmware versions do not have the following global registers: */
>>> ...
>>> 188 #define GLOBAL_CLOCK_CAPABILITIES       0x064
>>>
>>> But this is not proper in my case because the maximum offset on global
>>> sub-address space is 0x05c in quadlet unit.
>>
>> IIRC that comment was based on the documentation.  Apparently, there was
>> a misunderstanding of "size 0x60" vs. "up to the register at 0x60".
>
> From my curiosity, do you know which version of DICE firstly supports GLOBAL_VERSION register? Can you read it on the documentation?

I misremembered: I did not find anything about this in the documentation.

This is derived from TCAT's host driver, which unconditionally reads everything
up to the clock capabilities register, and checks for a size larger than 0x64
to detect if the firmware supports clock capabilities.

>> The version register is checked only once (in get_subaddrs()) and does not
>> actually affect the behaviour of the driver, so it would not hurt to simply
>> omit that check on the old firmware.
>
> Hm. The check is applied to the other spaces such as rx/tx, so I'd like to
> leave it as is.

Sorry, "that check" meant the version check for 0x01000000.  Your patch
already implements what I suggested.

> With this patch[1], ALSA dice driver can handle the unit. In this weekend, I'll post it. Your reviewing is very helpful.
>
> [1] https://github.com/takaswie/snd-firewire-improve/commit/1889e06b9593e16da2812010ffd5a8e4b9bc777d

> +	/* Old firmware doesn't support these fields. */
> +	if (dice->clock_caps == 0) {
> +		dice->sync_offset = be32_to_cpu(pointers[6]) * 4;
> +		dice->rsrv_offset = be32_to_cpu(pointers[8]) * 4;
> +	}

Shouldn't this be clock_caps!=0?


Regards,
Clemens

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Old firmware version for Dice II ASIC
  2018-04-19 16:21     ` Clemens Ladisch
@ 2018-04-21  4:10       ` Takashi Sakamoto
  0 siblings, 0 replies; 5+ messages in thread
From: Takashi Sakamoto @ 2018-04-21  4:10 UTC (permalink / raw)
  To: Clemens Ladisch; +Cc: alsa-devel

Hi,

On Apr 20 2018 01:21, Clemens Ladisch wrote:
> Takashi Sakamoto wrote:
>> On Apr 19 2018 17:54, Clemens Ladisch wrote:
>>> Takashi Sakamoto wrote:
>>>> 183 /* Some old firmware versions do not have the following global registers: */
>>>> ...
>>>> 188 #define GLOBAL_CLOCK_CAPABILITIES       0x064
>>>>
>>>> But this is not proper in my case because the maximum offset on global
>>>> sub-address space is 0x05c in quadlet unit.
>>>
>>> IIRC that comment was based on the documentation.  Apparently, there was
>>> a misunderstanding of "size 0x60" vs. "up to the register at 0x60".
>>
>>  From my curiosity, do you know which version of DICE firstly supports GLOBAL_VERSION register? Can you read it on the documentation?
> 
> I misremembered: I did not find anything about this in the documentation.
> 
> This is derived from TCAT's host driver, which unconditionally reads everything
> up to the clock capabilities register, and checks for a size larger than 0x64
> to detect if the firmware supports clock capabilities.

Hm. In a case of this device with the firmware, I experienced that the 
latest proprietary driver for windows 7 (v3.5.3.8671) [1] cannot detect 
it. I can see below message.

"Driver error: Device firmware operation error
Check the driver configuration or device connections."

Additionally, Alesis had released v3.0.81.1080 driver for windows XP and 
this included v2.0 firmware[2] (but it's not clear that which DICE 
version is used for this release).

In my reasoning, DICE firmware loses backward compatibility in its early 
stage (e.g. DICE v1.0.2) due to the GLOBAL_VERSION register. And in 
coincidence the unit has the old version firmware.

>>> The version register is checked only once (in get_subaddrs()) and does not
>>> actually affect the behaviour of the driver, so it would not hurt to simply
>>> omit that check on the old firmware.
>>
>> Hm. The check is applied to the other spaces such as rx/tx, so I'd like to
>> leave it as is.
> 
> Sorry, "that check" meant the version check for 0x01000000.  Your patch
> already implements what I suggested.
> 
>> With this patch[1], ALSA dice driver can handle the unit. In this weekend, I'll post it. Your reviewing is very helpful.
>>
>> [1] https://github.com/takaswie/snd-firewire-improve/commit/1889e06b9593e16da2812010ffd5a8e4b9bc777d
> 
>> +	/* Old firmware doesn't support these fields. */
>> +	if (dice->clock_caps == 0) {
>> +		dice->sync_offset = be32_to_cpu(pointers[6]) * 4;
>> +		dice->rsrv_offset = be32_to_cpu(pointers[8]) * 4;
>> +	}
> 
> Shouldn't this be clock_caps!=0?

Yep, I did mistake. I pushed fixed one to my repository.

[1] This version is available at below URL:
http://www.alesis.com/products/view/multimix-12-firewire
[2] I can find a web page at internet archive:
http://web.archive.org/web/20080227094953/http://www.alesis.com:80/multimix12firewire


Thanks

Takashi Sakamoto

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-04-21  4:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-18 10:24 Old firmware version for Dice II ASIC Takashi Sakamoto
2018-04-19  8:54 ` Clemens Ladisch
2018-04-19 12:49   ` Takashi Sakamoto
2018-04-19 16:21     ` Clemens Ladisch
2018-04-21  4:10       ` Takashi Sakamoto

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.