GithubHelp home page GithubHelp logo

Comments (19)

takaswie avatar takaswie commented on September 28, 2024

Hi,

Thanks for your report and I'm sorry for the inconvenience.

Recently Linux kernel got changes for year 2038 issue and UAPI header of Linux sound subsystem was changed. On the other hand, in my repository, old headers are included. This is the cause of issue.

from linux-firewire-dkms.

takaswie avatar takaswie commented on September 28, 2024

I'll try to backport patches including the changes.

from linux-firewire-dkms.

takaswie avatar takaswie commented on September 28, 2024
$ git log --oneline v5.7 include/uapi/sound/asound.h include/uapi/sound/asequencer.h
46b770f720bd ALSA: uapi: Fix sparse warning
a103a3989993 ALSA: control: Fix incompatible protocol error
bd3eb4e87eb3 ALSA: ctl: bump protocol version up to v2.1.0
ff16351e3f30 ALSA: ctl: remove dimen member from elem_info structure
542283566679 ALSA: ctl: remove unused macro for timestamping of elem_value
7fd7d6c50451 ALSA: uapi: Fix typos and header inclusion in asound.h
1cfaef961703 ALSA: bump uapi version numbers
80fe7430c708 ALSA: add new 32-bit layout for snd_pcm_mmap_status/control
07094ae6f952 ALSA: Avoid using timespec for struct snd_timer_tread
d9e5582c4bb2 ALSA: Avoid using timespec for struct snd_rawmidi_status
3ddee7f88aaf ALSA: Avoid using timespec for struct snd_pcm_status
a4e7dd35b9da ALSA: Avoid using timespec for struct snd_ctl_elem_value
a07804cc7472 ALSA: Avoid using timespec for struct snd_timer_status
b5bdbb6ccd11 ALSA: uapi: #include <time.h> in asound.h
a98401518def ALSA: timer: fix wrong comment to refer to 'SNDRV_TIMER_PSFLG_*'
...

As long as I investigated, the above patches should be backported.

from linux-firewire-dkms.

takaswie avatar takaswie commented on September 28, 2024

@danielmellado Would you please try HEAD of topic/backport-y2038-changes branch and report the result?

from linux-firewire-dkms.

danielmellado avatar danielmellado commented on September 28, 2024

Now it did work and compile just fine, thanks for your quick response!

from linux-firewire-dkms.

danielmellado avatar danielmellado commented on September 28, 2024

In any case, I've another doubt, which is outside of the scope of this bug, so will probably just cc alsa-devel, but after modprobing snd-firewire-lib and snd-firewire-motu and doing alsactl restore I would've expected to see my MOTU 896HD at /proc/asound/cards. Am I missing some usage of the modules? Thanks in advance!

from linux-firewire-dkms.

takaswie avatar takaswie commented on September 28, 2024

I would've expected to see my MOTU 896HD at /proc/asound/cards.

MOTU 896HD is supported neither in this repository[1] nor upstream[2], since I've had no chance to access to the device (it's still expensive even if enough later being discontinued).

If I expect your cooperation, I will work to support it. However, current ALSA firewire-motu driver still has some issues about media clock recovery and it's likely that I cannot meet your request fully.

[1] https://github.com/takaswie/snd-firewire-improve/blob/master/sound/firewire/motu/motu.c#L186
[2] https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git/tree/sound/firewire/motu/motu.c?h=for-next#n186

Regards

from linux-firewire-dkms.

danielmellado avatar danielmellado commented on September 28, 2024

Hi @takaswie, yeah, that'd be awesome! Let me know how I can help you achieve that! For now I've got the device working with libffado + jack / pulseaudio bridge but it'd be really cool to have it under alsa. Regarding the device, feel free to reach me out in order to get any logs/info/tests you'd like me to run over it. Thanks a lot!

from linux-firewire-dkms.

takaswie avatar takaswie commented on September 28, 2024

Hi @takaswie, yeah, that'd be awesome! Let me know how I can help you achieve that! For now
I've got the device working with libffado + jack / pulseaudio bridge but it'd be really cool to have it
under alsa. Regarding the device, feel free to reach me out in order to get any logs/info/tests you'd
like me to run over it. Thanks a lot!

Hm.

If you're satisfied to FFADO stack, I think it better just to use it, because it takes you a batch of free time and efforts to assist my work. In a point of life, time is finite and expensive. It's better to use the time for more important thing to you.

Novertheless you are going to assist my work, I'm glad to hear it and make some instructions to gather device data.

Thanks

from linux-firewire-dkms.

danielmellado avatar danielmellado commented on September 28, 2024

Hi @takaswie, I'd love seeing this working under alsa and I'm pretty sure that I can save some time to help you with that, so let me know on what should we start with ;)

from linux-firewire-dkms.

takaswie avatar takaswie commented on September 28, 2024

Hi @danielmellado,

I'm sorry to be late for reply but I was pretty busy for my work of ALSA control services in userspace[1].

In a couple of days, I'm prepare python 3 script to retrieve data for your model. It's libhinawa[2] application and I'd like you to install the library with gobject-introspection[3] support in advance.

[1] https://mailman.alsa-project.org/pipermail/alsa-devel/2020-July/170331.html
[2] https://github.com/alsa-project/libhinawa
[3] https://gi.readthedocs.io/en/latest/

Thanks for your patience.

from linux-firewire-dkms.

takaswie avatar takaswie commented on September 28, 2024

Hi @danielmellado ,

In a couple of days, I'm prepare python 3 script to retrieve data for your model. It's libhinawa[2] application and I'd like you to install the library with gobject-introspection[3] support in advance.

I forgot to note that PyGObject is required to load libhinawa in Python 3 runtime via gobject introspection.

Well, I prepare for below Python 3 script to detect information required for packet streaming in 896HD case.

#!/usr/bin/env python3

import gi
gi.require_version('GLib', '2.0')
gi.require_version('Hinawa', '3.0')
from gi.repository import GLib, Hinawa

from struct import unpack
from threading import Thread

ADDR_BASE = 0xfffff0000000

RATES = (
    44100,
    48000,
    88200,
    96000,
    176400,
    192000,
)

def detect_clock_status(req, node):
    V2_CLOCK_STATUS_OFFSET = 0x0b14

    V2_CLOCK_RATE_MASK = 0x00000038
    V2_CLOCK_RATE_SHIFT = 3
    V2_CLOCK_SRC_MASK = 0x00000007
    V2_CLOCK_SRC_SHIFT = 0
    V2_CLOCK_FETCH_ENABLE = 0x02000000
    V2_CLOCK_MODEL_SPECIFIC = 0x04000000

    # Parse for rate of sampling clock.
    req = Hinawa.FwReq.new()
    frames = req.transaction(node, Hinawa.FwTcode.READ_QUADLET_REQUEST,
                             ADDR_BASE + V2_CLOCK_STATUS_OFFSET, 4, [0] * 4)
    val = unpack('>I', frames)[0]
    print('  0x0b14: {:08x}'.format(val))

    rate = (val & V2_CLOCK_RATE_MASK) >> V2_CLOCK_RATE_SHIFT
    if rate < len(RATES):
        print('    rate configuration: {}'.format(RATES[rate]))

    # Parse for source of sampling clock.
    src = (val & V2_CLOCK_SRC_MASK) >> V2_CLOCK_SRC_SHIFT;
    if src == 0:
        label = 'internal'
    elif src == 2:
        label = 'S/PDIF on coax'
    elif src == 4:
        label = 'Word on BNC'
    else:
        label = 'Unknown({})'.format(src)
    print('    src configuration: {}'.format(label))

def detect_io_conf(req, node):
    V2_IN_OUT_CONF_OFFSET = 0x0c04

    V2_OPT_OUT_IFACE_MASK = 0x00000c00
    V2_OPT_OUT_IFACE_SHIFT = 10
    V2_OPT_IN_IFACE_MASK = 0x00000300
    V2_OPT_IN_IFACE_SHIFT = 8

    V2_OPT_IFACE_MODES = (
        'None',
        'ADAT',
        'S/PDIF',
    )

    req = Hinawa.FwReq.new()
    frames = req.transaction(node, Hinawa.FwTcode.READ_QUADLET_REQUEST,
                             ADDR_BASE + V2_IN_OUT_CONF_OFFSET, 4, [0] * 4)
    val = unpack('>I', frames)[0]
    print('  0x0b14: {:08x}'.format(val))

    # Parse for optical output interface.
    opt_out_iface = (val & V2_OPT_OUT_IFACE_MASK) >> V2_OPT_OUT_IFACE_SHIFT
    if opt_out_iface < len(V2_OPT_IFACE_MODES):
        label = V2_OPT_IFACE_MODES[opt_out_iface]
    else:
        label = 'Unkown({})'.format(opt_out_iface)
    print('    opt out iface configuration: {}'.format(label))

    # Parse for optical input interface.
    opt_in_iface = (val & V2_OPT_IN_IFACE_MASK) >> V2_OPT_IN_IFACE_SHIFT
    if opt_in_iface < len(V2_OPT_IFACE_MODES):
        label = V2_OPT_IFACE_MODES[opt_in_iface]
    else:
        label = 'Unkown({})'.format(opt_in_iface)
    print('    opt in iface configuration: {}'.format(label))

unit = Hinawa.SndMotu.new()
unit.open('/dev/snd/hwC2D0')

ctx = GLib.MainContext.new()

src = unit.create_source()
src.attach(ctx)
src = unit.get_node().create_source()
src.attach(ctx)

dispatcher = GLib.MainLoop.new(ctx, False)
th = Thread(target=lambda d: d.run(), args=(dispatcher, ))
th.start()

req = Hinawa.FwReq.new()

print('Detect clock status:')
detect_clock_status(req, unit.get_node())

print('Detect I/O configuration:')
detect_io_conf(req, unit.get_node())

dispatcher.quit()
th.join()

When you have enough permissions for ALSA HwDep character device (/dev/snd/hwC%uD%u) and Linux FireWire character device (/dev/fw%u), executing the above Python 3 script brings below output:

$ python3 896hd-detect
Detect clock status:
  0x0b14: 04000000
    rate configuration: 44100
    src configuration: internal
Detect I/O configuration:
  0x0b14: 03000001
    opt out iface configuration: None
    opt in iface configuration: None

What I'd like you to check is the information about I/O configuration. Motu 896HD has some knobs to control internal configuration. By the knobs, you can change optical input/output configuration between None or ADAT. You can check whether the above script can detect the configuration correctly or not when changing the configuration by hand.

Cheers.

from linux-firewire-dkms.

danielmellado avatar danielmellado commented on September 28, 2024

Hi @takaswie, sorry for the delay as well! I ran into some issues when installing libhinawa. Although I got all the dependencies, I guess something is wrong there, after I do ninja install:

$ meson -Dgtk_doc=true . build
The Meson build system
Version: 0.55.0
Source dir: /home/dmellado/Devel/daniel/alsa/libhinawa
Build dir: /home/dmellado/Devel/daniel/alsa/libhinawa/build
Build type: native build
Using 'PKG_CONFIG_PATH' from environment with value: '/usr/lib64/pkgconfig:/usr/share/pkgconfig:/usr/local/lib64/pkgconfig'
Using 'PKG_CONFIG_PATH' from environment with value: '/usr/lib64/pkgconfig:/usr/share/pkgconfig:/usr/local/lib64/pkgconfig'
Project name: libhinawa
Project version: 2.0.0
C compiler for the host machine: cc (gcc 10.2.1 "cc (GCC) 10.2.1 20200723 (Red Hat 10.2.1-1)")
C linker for the host machine: cc ld.bfd 2.34-4
Host machine cpu family: x86_64
Host machine cpu: x86_64
Has header "backport.h" : YES 
Configuring config.h using configuration
Found pkg-config: /usr/bin/pkg-config (1.6.3)
Using 'PKG_CONFIG_PATH' from environment with value: '/usr/lib64/pkgconfig:/usr/share/pkgconfig:/usr/local/lib64/pkgconfig'
Run-time dependency gobject-2.0 found: YES 2.64.4
Found pkg-config: /usr/bin/pkg-config (1.6.3)
Using 'PKG_CONFIG_PATH' from environment with value: '/usr/lib64/pkgconfig:/usr/share/pkgconfig:/usr/local/lib64/pkgconfig'
Program glib-genmarshal found: YES
Program glib-mkenums found: YES
Program glib-mkenums found: YES
Using 'PKG_CONFIG_PATH' from environment with value: '/usr/lib64/pkgconfig:/usr/share/pkgconfig:/usr/local/lib64/pkgconfig'
Build-time dependency gobject-introspection-1.0 found: YES 1.64.1
Program g_ir_scanner found: YES (/usr/bin/g-ir-scanner)
Program g_ir_compiler found: YES (/usr/bin/g-ir-compiler)
Configuring version.xml using configuration
Program gtkdoc-scan found: YES
Program gtkdoc-scangobj found: YES
Program gtkdoc-mkdb found: YES
Program gtkdoc-mkhtml found: YES
Program gtkdoc-fixxref found: YES
Program fw-node found: YES
Program fw-req found: YES
Program fw-resp found: YES
Program fw-fcp found: YES
Program snd-unit found: YES
Program hinawa-enum found: YES
Program snd-dice found: YES
Program snd-efw found: YES
Program snd-dg00x found: YES
Program snd-motu found: YES
Program snd-tscm found: YES
Build targets in project: 9

Found ninja-1.10.0 at /usr/bin/ninja
$ ninja
[1/19] Generating hinawa_sigs_marshal_h with a custom command
INFO: Reading ../src/hinawa_sigs_marshal.list...
[2/19] Generating hinawa_sigs_marshal_c with a custom command
INFO: Reading ../src/hinawa_sigs_marshal.list...
[18/19] Generating Hinawa-3.0.gir with a custom command
g-ir-scanner: link: gcc -pthread -o /home/dmellado/Devel/daniel/alsa/libhinawa/build/tmp-introspect1h9kbibh/Hinawa-3.0 /home/dmellado/Devel/daniel/alsa/libhinawa/build/tmp-introspect1h9kbibh/Hinawa-3.0.o -L. -Wl,-rpath,. -Wl,--no-as-needed -L/home/dmellado/Devel/daniel/alsa/libhinawa/build/src -Wl,-rpath,/home/dmellado/Devel/daniel/alsa/libhinawa/build/src -lhinawa -lgobject-2.0 -lglib-2.0 -lgirepository-1.0 -lgio-2.0 -lgobject-2.0 -Wl,--export-dynamic -lgmodule-2.0 -pthread -lglib-2.0 -lglib-2.0
[19/19] Generating Hinawa-3.0.typelib with a custom command
$sudo ninja install
[0/1] Installing files.
Installing src/hinawa_enums.h to /usr/local/include/libhinawa
Installing src/libhinawa.so.2.0.0 to /usr/local/lib64
Installing src/Hinawa-3.0.gir to /usr/local/share/gir-1.0
Installing src/Hinawa-3.0.typelib to /usr/local/lib64/girepository-1.0
Installing /home/dmellado/Devel/daniel/alsa/libhinawa/src/fw_node.h to /usr/local/include/libhinawa
Installing /home/dmellado/Devel/daniel/alsa/libhinawa/src/fw_resp.h to /usr/local/include/libhinawa
Installing /home/dmellado/Devel/daniel/alsa/libhinawa/src/fw_req.h to /usr/local/include/libhinawa
Installing /home/dmellado/Devel/daniel/alsa/libhinawa/src/fw_fcp.h to /usr/local/include/libhinawa
Installing /home/dmellado/Devel/daniel/alsa/libhinawa/src/snd_unit.h to /usr/local/include/libhinawa
Installing /home/dmellado/Devel/daniel/alsa/libhinawa/src/snd_dice.h to /usr/local/include/libhinawa
Installing /home/dmellado/Devel/daniel/alsa/libhinawa/src/snd_efw.h to /usr/local/include/libhinawa
Installing /home/dmellado/Devel/daniel/alsa/libhinawa/src/snd_dg00x.h to /usr/local/include/libhinawa
Installing /home/dmellado/Devel/daniel/alsa/libhinawa/src/snd_motu.h to /usr/local/include/libhinawa
Installing /home/dmellado/Devel/daniel/alsa/libhinawa/src/snd_tscm.h to /usr/local/include/libhinawa
Installing /home/dmellado/Devel/daniel/alsa/libhinawa/src/hinawa_enum_types.h to /usr/local/include/libhinawa
Installing /home/dmellado/Devel/daniel/alsa/libhinawa/build/meson-private/hinawa.pc to /usr/local/lib64/pkgconfig
Running custom install script '/usr/bin/meson --internal gtkdoc --sourcedir=/home/dmellado/Devel/daniel/alsa/libhinawa --builddir=/home/dmellado/Devel/daniel/alsa/libhinawa/build --subdir=doc/reference --headerdirs=/home/dmellado/Devel/daniel/alsa/libhinawa/src@@/home/dmellado/Devel/daniel/alsa/libhinawa/build/src --mainfile=hinawa-docs.xml --modulename=hinawa --moduleversion= --mode=auto --gtkdoc-scan=/usr/bin/gtkdoc-scan --gtkdoc-scangobj=/usr/bin/gtkdoc-scangobj --gtkdoc-mkdb=/usr/bin/gtkdoc-mkdb --gtkdoc-mkhtml=/usr/bin/gtkdoc-mkhtml --gtkdoc-fixxref=/usr/bin/gtkdoc-fixxref --scanargs=--ignore-headers=internal.h backport.h --gobjects-types-file=/home/dmellado/Devel/daniel/alsa/libhinawa/doc/reference/hinawa.types --html-assets=/home/dmellado/Devel/daniel/alsa/libhinawa/doc/reference/overview.png --content-files= --cc=cc --ld=cc --cflags=-I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include --ldflags=-L/home/dmellado/Devel/daniel/alsa/libhinawa/build/src -Wl,-rpath,/home/dmellado/Devel/daniel/alsa/libhinawa/build/src -lhinawa -lgobject-2.0 -lglib-2.0'
Building documentation for hinawa
html/HinawaFwFcp.html:128: warning: no link for: "api-index-1.3." -> (1.3.).
html/HinawaFwFcp.html:139: warning: no link for: "GError" -> (<span class="type">GError</span>).
html/HinawaFwFcp.html:192: warning: no link for: "api-index-1.4." -> (1.4.).
html/HinawaFwNode.html:134: warning: no link for: "G-SIGNAL-RUN-LAST:CAPS" -> (Run Last).
html/HinawaFwNode.html:255: warning: no link for: "GSource" -> (<span class="type">GSource</span>).
html/HinawaFwResp.html:331: warning: no link for: "HinawaTcode" -> (<span class="type">HinawaTcode</span>).
html/HinawaFwResp.html:344: warning: no link for: "HinawaRcode" -> (<span class="type">HinawaRcode</span>).
html/HinawaSndUnit.html:250: warning: no link for: "api-index-2.0." -> (2.0.).
html/HinawaSndUnit.html:406: warning: no link for: "g-object-free" -> (<code class="function">g_object_free()</code>).
html/HinawaSndUnit.html:457: warning: no link for: "TRUE:CAPS" -> (<code class="literal">TRUE</code>).
html/HinawaSndUnit.html:457: warning: no link for: "FALSE:CAPS" -> (<code class="literal">FALSE</code>).
html/index-all.html:156: warning: no link for: "HAVE-SND-DG00X:CAPS" -> (HAVE_SND_DG00X).
html/index-all.html:156: warning: no link for: "hinawa-config" -> (config).
html/index-all.html:160: warning: no link for: "HAVE-SND-DICE:CAPS" -> (HAVE_SND_DICE).
html/index-all.html:164: warning: no link for: "HAVE-SND-EFW:CAPS" -> (HAVE_SND_EFW).
html/index-all.html:168: warning: no link for: "HAVE-SND-MOTU:CAPS" -> (HAVE_SND_MOTU).
html/index-all.html:172: warning: no link for: "HAVE-SND-TSCM:CAPS" -> (HAVE_SND_TSCM).
html/index-all.html:177: warning: no link for: "hinawa-sigs-marshal-ENUM--ENUM" -> (hinawa_sigs_marshal_ENUM__ENUM).
html/index-all.html:177: warning: no link for: "hinawa-hinawa-sigs-marshal" -> (hinawa_sigs_marshal).
html/index-all.html:181: warning: no link for: "hinawa-sigs-marshal-VOID--UINT-UINT-UINT" -> (hinawa_sigs_marshal_VOID__UINT_UINT_UINT).
html/index-all.html:310: warning: no link for: "VERSION:CAPS" -> (VERSION).
html/index-all.html:315: warning: no link for: "WITH-BACKPORT:CAPS" -> (WITH_BACKPORT).```

But when I run your script I get the following:

$ ./motu896hd.py 
Traceback (most recent call last):
  File "./motu896hd.py", line 5, in <module>
    gi.require_version('Hinawa', '3.0')
  File "/usr/lib64/python3.8/site-packages/gi/__init__.py", line 129, in require_version
    raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Hinawa not available

I thought this could be related to some path and so so I even generated an rpm based on your instructions (just changing tar.gz to tar.xz, as it's the new format used now). If I go and install the rpm libhinawa-2.0.0-1.fc32.x86_64.rpm and libhinawa-devel-2.0.0-1.fc32.x86_64.rpm I got the following running the script.

$ ./motu896hd.py 
Traceback (most recent call last):
  File "./motu896hd.py", line 92, in <module>
    unit.open('/dev/snd/hwC2D0')
gi.repository.GLib.Error: "HinawaSndUnit": 220: No such file or directory (2)

That leads me to think that there's some issue on the path or something, but if you could lend me a hand on this it would be extremely helpful. Thanks!

from linux-firewire-dkms.

danielmellado avatar danielmellado commented on September 28, 2024

btw, wouldn't you be on freenode? maybe that'd make things easier ;)

from linux-firewire-dkms.

danielmellado avatar danielmellado commented on September 28, 2024

also, on /dev/snd I don't get to see any `hwC2D0' device, but

[$ ls /dev/snd/
by-id  by-path  controlC0  controlC1  controlC2  hwC0D0  hwC0D2  pcmC0D0c  pcmC0D0p  pcmC0D10p  pcmC0D3p  pcmC0D7p  pcmC0D8p  pcmC0D9p  pcmC1D0c  pcmC1D0p  pcmC2D0c  seq  timer

from linux-firewire-dkms.

danielmellado avatar danielmellado commented on September 28, 2024

changing that to hwC0D2 just in case, and it doesn't seem to be the proper one:

./motu896hd.py 
Traceback (most recent call last):
  File "./motu896hd.py", line 93, in <module>
    unit.open('/dev/snd/hwC0D2')
gi.repository.GLib.Error: "HinawaSndUnit": 226: Inappropriate ioctl for device (25)

from linux-firewire-dkms.

takaswie avatar takaswie commented on September 28, 2024

Oops. How stupid I am...

$ ./motu896hd.py 
Traceback (most recent call last):
  File "./motu896hd.py", line 92, in <module>
    unit.open('/dev/snd/hwC2D0')
gi.repository.GLib.Error: "HinawaSndUnit": 220: No such file or directory (2)

ALSA firewire-motu driver doesn't handle your unit yet. So the instance should be from HinawaFwNode instead of HinawaSndUnit...

btw, wouldn't you be on freenode? maybe that'd make things easier ;)

Would you please decide which channel in which we are going to log?

Thanks

from linux-firewire-dkms.

takaswie avatar takaswie commented on September 28, 2024

This rewritten code should work for your HD896:

#!/usr/bin/env python3

import gi
gi.require_version('GLib', '2.0')
gi.require_version('Hinawa', '3.0')
from gi.repository import GLib, Hinawa

from struct import unpack
from threading import Thread

ADDR_BASE = 0xfffff0000000

RATES = (
    44100,
    48000,
    88200,
    96000,
    176400,
    192000,
)

def detect_clock_status(req, node):
    V2_CLOCK_STATUS_OFFSET = 0x0b14

    V2_CLOCK_RATE_MASK = 0x00000038
    V2_CLOCK_RATE_SHIFT = 3
    V2_CLOCK_SRC_MASK = 0x00000007
    V2_CLOCK_SRC_SHIFT = 0
    V2_CLOCK_FETCH_ENABLE = 0x02000000
    V2_CLOCK_MODEL_SPECIFIC = 0x04000000

    # Parse for rate of sampling clock.
    req = Hinawa.FwReq.new()
    frames = req.transaction(node, Hinawa.FwTcode.READ_QUADLET_REQUEST,
                             ADDR_BASE + V2_CLOCK_STATUS_OFFSET, 4, [0] * 4)
    val = unpack('>I', frames)[0]
    print('  0x0b14: {:08x}'.format(val))

    rate = (val & V2_CLOCK_RATE_MASK) >> V2_CLOCK_RATE_SHIFT
    if rate < len(RATES):
        print('    rate configuration: {}'.format(RATES[rate]))

    # Parse for source of sampling clock.
    src = (val & V2_CLOCK_SRC_MASK) >> V2_CLOCK_SRC_SHIFT;
    if src == 0:
        label = 'internal'
    elif src == 2:
        label = 'S/PDIF on coax'
    elif src == 4:
        label = 'Word on BNC'
    else:
        label = 'Unknown({})'.format(src)
    print('    src configuration: {}'.format(label))

def detect_io_conf(req, node):
    V2_IN_OUT_CONF_OFFSET = 0x0c04

    V2_OPT_OUT_IFACE_MASK = 0x00000c00
    V2_OPT_OUT_IFACE_SHIFT = 10
    V2_OPT_IN_IFACE_MASK = 0x00000300
    V2_OPT_IN_IFACE_SHIFT = 8

    V2_OPT_IFACE_MODES = (
        'None',
        'ADAT',
        'S/PDIF',
    )

    req = Hinawa.FwReq.new()
    frames = req.transaction(node, Hinawa.FwTcode.READ_QUADLET_REQUEST,
                             ADDR_BASE + V2_IN_OUT_CONF_OFFSET, 4, [0] * 4)
    val = unpack('>I', frames)[0]
    print('  0x0b14: {:08x}'.format(val))

    # Parse for optical output interface.
    opt_out_iface = (val & V2_OPT_OUT_IFACE_MASK) >> V2_OPT_OUT_IFACE_SHIFT
    if opt_out_iface < len(V2_OPT_IFACE_MODES):
        label = V2_OPT_IFACE_MODES[opt_out_iface]
    else:
        label = 'Unkown({})'.format(opt_out_iface)
    print('    opt out iface configuration: {}'.format(label))

    # Parse for optical input interface.
    opt_in_iface = (val & V2_OPT_IN_IFACE_MASK) >> V2_OPT_IN_IFACE_SHIFT
    if opt_in_iface < len(V2_OPT_IFACE_MODES):
        label = V2_OPT_IFACE_MODES[opt_in_iface]
    else:
        label = 'Unkown({})'.format(opt_in_iface)
    print('    opt in iface configuration: {}'.format(label))

node = Hinawa.FwNode.new()
node.open('/dev/fw1')

ctx = GLib.MainContext.new()

src = node.create_source()
src.attach(ctx)

dispatcher = GLib.MainLoop.new(ctx, False)
th = Thread(target=lambda d: d.run(), args=(dispatcher, ))
th.start()

req = Hinawa.FwReq.new()

print('Detect clock status:')
detect_clock_status(req, node)

print('Detect I/O configuration:')
detect_io_conf(req, node)

dispatcher.quit()
th.join()

The diff from the previous version:

$ diff -u prev motu896hd.py 
--- prev	2020-08-06 18:42:46.426353678 +0900
+++ motu896hd.py	2020-08-06 18:41:28.852895533 +0900
@@ -88,14 +88,12 @@
         label = 'Unkown({})'.format(opt_in_iface)
     print('    opt in iface configuration: {}'.format(label))
 
-unit = Hinawa.SndMotu.new()
-unit.open('/dev/snd/hwC2D0')
+node = Hinawa.FwNode.new()
+node.open('/dev/fw1')
 
 ctx = GLib.MainContext.new()
 
-src = unit.create_source()
-src.attach(ctx)
-src = unit.get_node().create_source()
+src = node.create_source()
 src.attach(ctx)
 
 dispatcher = GLib.MainLoop.new(ctx, False)
@@ -105,10 +103,10 @@
 req = Hinawa.FwReq.new()
 
 print('Detect clock status:')
-detect_clock_status(req, unit.get_node())
+detect_clock_status(req, node)
 
 print('Detect I/O configuration:')
-detect_io_conf(req, unit.get_node())
+detect_io_conf(req, node)
 
 dispatcher.quit()
 th.join()

Thanks

from linux-firewire-dkms.

takaswie avatar takaswie commented on September 28, 2024

And let us move to another issue in which we discuss about MOTU 896HD support ;)

from linux-firewire-dkms.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.