alsa-project / snd-firewire-ctl-services

A set of server programs for audio and music units on IEEE 1394 bus supported by Linux sound subsystem a.k.a. ALSA.
GNU General Public License v3.0
34 stars 5 forks source link

Linux file operation error: , No flag detected: val: 0x00000030 mask: 0x0000008c Tascam FW-1884 #188

Open Esavojt opened 3 weeks ago

Esavojt commented 3 weeks ago

Hello, I have a tascam FW-1884 mixer running under debian 12 and when using the snd-firewire-tascam-ctl-service snd 0 command i get these messages at the end before the program exits:

2024-08-25T15:30:23.552907Z DEBUG cache: snd_firewire_tascam_ctl_service::isoch_ctls: params=AnalogOutputPair0 res=Ok(())
2024-08-25T15:30:23.553854Z DEBUG cache: snd_firewire_tascam_ctl_service::isoch_ctls: params=TascamOpticalIfaceParameters { capture_source: Coaxial, output_source: StreamInputPairs } res=Err(Error { domain: g-file-error-quark, code: 6, message: "No flag detected: val: 0x00000030 mask: 0x0000008c" })
Linux file operation error: , No flag detected: val: 0x00000030 mask: 0x0000008c

This is my output of the firmware version:

mix@mix:~/snd-firewire-ctl-services$ cat /proc/asound/card0/firewire/firmware 
Register: 20 (0x00000014)
FPGA:     49 (0x00010031)
ARM:      173 (0x000100ad)
Hardware: 3 (0x00030000)

I have downgraded from the 183 version to this version in hope that it would work, as it didn't work before. The mixer works correctly under windows. Thanks for helping.

takaswie commented 2 weeks ago

Hi @Esavojt ,

Thanks for your report. It seems that the issue is quite similar to the one reported at #187 .

The patch in my post would suppress the issue, but it is not complete solution yet.

No flag detected: val: 0x00000030 mask: 0x0000008c

Furthermore, the value 0x30 is not what I expected. I guess that there is another uncleared configuration related to the bits in the register, and need further investigation.

Esavojt commented 2 weeks ago

Hi, thanks for your answer, i am currently trying different optical/coaxial routing in windows and then looking what your service returns, i will be back with the results. Tried switching a setting and the service works.

Esavojt commented 2 weeks ago

Hi, I have found out that when I select ADAT 1:8 as the optical output and when setting the coax out and spdif in settings I can get different values:

| Optical output | Coax out              | SPDIF in             | resulting value |
|----------------|-----------------------|----------------------|-----------------|
| ADAT 1:8       | SPDIF 1:2             | Coax to SPDIF 1:2    | 0x30            |
| ADAT 1:8       | SPDIF 1:2             | Optical to SPDIF 1:2 | 0x31            |
| ADAT 1:8       | Duplicate of ANLG 1:2 | Coax to SPDIF 1:2    | 0x32            |
| ADAT 1:8       | Duplicate of ANLG 1:2 | Optical to SPDIF 1:2 | 0x33            |

The interesting thing is that when I did it the first time, the service worked fine, but after that when I tried it second time, the service errored out with these values. When switching from ADAT 1:8 to Analog Outputs 1:8, everything works fine.

takaswie commented 2 weeks ago

Hi,

Thanks for your investigation.

The configuration for the source of coaxial output (Coax out in the table) is programmed in the following lines, and it looks conforming to the result.

$ cat -n protocols/tascam/src/isoch.rs
 ...
 538 /// The specification of coaxial output interface.
 539 pub trait TascamIsochCoaxialOutputSpecification {}
 540 
 541 const COAXIAL_OUTPUT_SOURCES: [(CoaxialOutputSource, u32, u32); 2] = [
 542     (CoaxialOutputSource::StreamInputPair, 0x00000002, 0x00020000),
 543     (
 544         CoaxialOutputSource::AnalogOutputPair0,
 545         0x00000000,
 546         0x00000200,
 547     ),
 548 ];
 549 
 550 impl<O> TascamIsochWhollyCachableParamsOperation<CoaxialOutputSource> for O
 551 where
 552     O: TascamIsochCoaxialOutputSpecification,
 553 {
 554     fn cache_wholly(
 555         req: &mut FwReq,
 556         node: &mut FwNode,
 557         states: &mut CoaxialOutputSource,
 558         timeout_ms: u32,
 559     ) -> Result<(), Error> {
         ...
 563     }
 564 }
 565 
 566 impl<O> TascamIsochWhollyUpdatableParamsOperation<CoaxialOutputSource> for O
 567 where
 568     O: TascamIsochCoaxialOutputSpecification,
 569 {
 570     fn update_wholly(
 571         req: &mut FwReq,
 572         node: &mut FwNode,
 573         states: &CoaxialOutputSource,
 574         timeout_ms: u32,
 575     ) -> Result<(), Error> {
         ...
 579     }
 580 }
 ...

The configuration for the source of SPDIF capture (SPDIF in in the table) is programmed in the following lines with the configuration for the source of optical output (Optical output in the table):

$ cat -n protocols/tascam/src/isoch.rs
 ...
 584 /// Source of S/PDIF input.
 585 #[derive(Debug, Copy, Clone, PartialEq, Eq)]
 586 pub enum SpdifCaptureSource {
 587     /// To coaxial interface.
 588     Coaxial,
 589     /// To optical interface.
 590     Optical,
 591 }
 592 
 593 impl Default for SpdifCaptureSource {
 594     fn default() -> Self {
 595         Self::Coaxial
 596     }
 597 }
 598 
 599 /// Source of optical output.
 600 #[derive(Debug, Copy, Clone, PartialEq, Eq)]
 601 pub enum OpticalOutputSource {
 602     /// 4 pairs in stream inputs.
 603     StreamInputPairs,
 604     /// Mirror of coaxial output 0 and 1.
 605     CoaxialOutputPair0,
 606     /// Analog input 0 and 1.
 607     AnalogInputPair0,
 608     /// Mirror of analog output 0, 1, 2, 3, 4, 5, 6, 7, and 8.
 609     AnalogOutputPairs,
 610 }
 611 
 612 impl Default for OpticalOutputSource {
 613     fn default() -> Self {
 614         Self::StreamInputPairs
 615     }
 616 }
 617 
 618 /// The parameters of digital input and output interfaces.
 619 #[derive(Default, Debug, Copy, Clone, PartialEq, Eq)]
 620 pub struct TascamOpticalIfaceParameters {
 621     /// The input interface from which the S/PDIF signal is captured.
 622     pub capture_source: SpdifCaptureSource,
 623     /// The source signal of optical output interface.
 624     pub output_source: OpticalOutputSource,
 625 }
 626 
 627 /// The specification of digital interfaces.
 628 pub trait TascamIsochOpticalIfaceSpecification {
 629     const OPTICAL_OUTPUT_SOURCES: &'static [(OpticalOutputSource, u32, u32)];
 630 }
 631 
 632 const SPDIF_CAPTURE_SOURCES: &[(SpdifCaptureSource, u32, u32)] = &[
 633     (SpdifCaptureSource::Coaxial, 0x00000000, 0x00010000),
 634     (SpdifCaptureSource::Optical, 0x00000001, 0x00000100),
 635 ];
 636 
 637 impl<O> TascamIsochWhollyCachableParamsOperation<TascamOpticalIfaceParameters> for O
 638 where
 639     O: TascamIsochOpticalIfaceSpecification,
 640 {
 641     fn cache_wholly(
 642         req: &mut FwReq,
 643         node: &mut FwNode,
 644         states: &mut TascamOpticalIfaceParameters,
 645         timeout_ms: u32,
 646     ) -> Result<(), Error> {
 ...         ...
 656     }
 657 }
 658 
 659 impl<O> TascamIsochWhollyUpdatableParamsOperation<TascamOpticalIfaceParameters> for O
 660 where
 661     O: TascamIsochOpticalIfaceSpecification,
 662 {
 663     /// Update whole parameters.
 664     fn update_wholly(
 665         req: &mut FwReq,
 666         node: &mut FwNode,
 667         states: &TascamOpticalIfaceParameters,
 668         timeout_ms: u32,
 669     ) -> Result<(), Error> {
             ...
 678     }
 679 }
 ...

The bitflags in SPDIF_CAPTURE_SOURCES looks conforming to the result, so we should focus just on the implementation of TascamIsochOpticalIfaceSpecification for Fw1884Protocol structure:

$ cat -n protocols/tascam/src/isoch/fw1884.rs
     ...
  72 impl TascamIsochOpticalIfaceSpecification for Fw1884Protocol {
  73     const OPTICAL_OUTPUT_SOURCES: &'static [(OpticalOutputSource, u32, u32)] = &[
  74         (
  75             OpticalOutputSource::StreamInputPairs,
  76             0x00000080,
  77             0x0000c000,
  78         ),
  79         (
  80             OpticalOutputSource::CoaxialOutputPair0,
  81             0x00000004,
  82             0x00080400,
  83         ),
  84         (
  85             OpticalOutputSource::AnalogInputPair0,
  86             0x00000088,
  87             0x00048800,
  88         ),
  89         (
  90             OpticalOutputSource::AnalogOutputPairs,
  91             0x00000008,
  92             0x00840800,
  93         ),
  94     ];
  95 }
     ...

If the above bitflags were comforming, the ADAT 1:8 matches to the first entry of OPTICAL_OUTPUT_SOURCES and should have resulted in 0x00000080 in the value. However, in both your case and #187 it is not. On the other hand, in my device, it matches. So we need to clear the role of bitflag 0x00000080, but not yet...