Re: [PATCH] ALSA: firewire-tascam: add note for FE-8

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Sep 06, 2019 at 09:55:44PM +0900, Takashi Sakamoto wrote:
> Userspace applications can receive the transaction and parse it for
> control message via Linux FireWire subsystem, without any support by
> ALSA firewire-tascam driver. Therefore the driver gives no support
> for it.

For your information, this is a sample Python 3 script to listen the
transactions, utilizing PyGObject to load Hinawa-2.0 g-i.

```
#!/usr/bin/env python3

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

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

from signal import SIGINT
from struct import unpack, pack
from time import sleep

# Allocate address space to receive notification.
class Fe8Responder(Hinawa.FwResp):
    def __init__(self, unit):
        super().__init__()

        # Allocate within private space.
        addr = 0xffffe0000000
        while addr < 0xfffff0000000:
            try:
                self.register(unit, addr, 0x80)
                break
            except:
                addr += 0x80

        self.addr = addr

    def do_requested(self, tcode):
        frames = self.get_req_frame()

        # Just print the event. Practically translate it to general MIDI
        # messages and send the messages to the other processes via IPC such as
        # ALSA Sequencer.
        for i in range(0, len(frames), 4):
            print('{:08x}'.format(unpack('>I', frames[i:i+4])[0]))

        return Hinawa.FwRcode.COMPLETE


# For a case that the device is detected as '/dev/fw1'.
unit = Hinawa.FwUnit()
unit.open('/dev/fw1')
unit.listen()
resp = Fe8Responder(unit)

req = Hinawa.FwReq()

# Register the address.
addr_hi = pack('>H', unit.get_property('local-node-id'))
addr_hi += pack('>H', (resp.addr & 0xffff00000000) >> 32)
addr_lo = pack('>I', resp.addr & 0xffffffff)
req.write(unit, 0xffff00000314, addr_hi)
req.write(unit, 0xffff00000318, addr_lo)

# Enable notification.
req.write(unit, 0xffff00000310, pack('>I', 1))

# Turn on FireWire LED.
data = [0x00, 0x01, 0x00, 0x8e]
req.write(unit, 0xffff00000404, data)

# Wait for events.
def handle_unix_signal(loop):
    loop.quit()
loop = GLib.MainLoop()
GLib.unix_signal_add(GLib.PRIORITY_HIGH, SIGINT, handle_unix_signal, loop)
loop.run()

# Disable notification.
req.write(unit, 0xffff00000310, pack('>I', 0))

# Turn off FireWire LED.
data = [0x00, 0x00, 0x00, 0x8e]
req.write(unit, 0xffff00000404, data)

del req
del resp
del unit
```


Regards

Takashi Sakamoto
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux