Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: clemens@ladisch.de, tiwai@suse.de
Cc: alsa-devel@alsa-project.org
Subject: Re: [alsa-devel] [PATCH] ALSA: firewire-tascam: add note for FE-8
Date: Fri, 6 Sep 2019 23:18:42 +0900	[thread overview]
Message-ID: <20190906141840.GA18662@workstation> (raw)
In-Reply-To: <20190906125544.13800-1-o-takashi@sakamocchi.jp>

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@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

      parent reply	other threads:[~2019-09-06 14:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-06 12:55 [alsa-devel] [PATCH] ALSA: firewire-tascam: add note for FE-8 Takashi Sakamoto
2019-09-06 13:00 ` Takashi Iwai
2019-09-06 14:18 ` Takashi Sakamoto [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190906141840.GA18662@workstation \
    --to=o-takashi@sakamocchi.jp \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox