[alsa-devel] Controlling the Tascam FW-1884

Takashi Sakamoto o-takashi at sakamocchi.jp
Sun Oct 7 16:11:11 CEST 2018


Hi Scott,

On Oct 2 2018 12:16, Takashi Sakamoto wrote:
> I have an idea to invervene them:
> 
> 1. For control events, in kernel land, driver module detects
> changes of set of bitflags for physical controls, then queue
> events to tell the change to userspace applications
> (e.g. poll(2)). The queued events include information about
> changed bitflags (e.g. a shape of u32 data). Userspace
> applications execute read(2) then get the bitflags, then parse
> it and emit userspace event by ports in ALSA sequencer
> subsystem.
> The driver and userspace application should pay enough
> attention to share the queue. The driver can drop the oldest
> queued events if the queue is full.
> 
> 2. For level meter, in kernel land, driver module caches the
> recent value. Userspace applications execute ioctl(2) with
> unique command (You can see this kind of commands in
> 'include/uapi/sound/firwire.h').

I prepare two remote branch as 'topic/tascam-userspace-take2' for kernel
driver[1] and libhinawa[2].

The patches for kernel driver adds two features below to firewire-tascam 
module:
  - SNDRV_FIREWIRE_IOCTL_TASCAM_STATUS ioctl command
  - 'struct snd_firewire_event_tascam_ctl' event notification

The patches for libhinawa adds two features below for g-i modules:
  - hinawa_snd_tscm_get_status() method
  - 'control' GObject signal

For example[3]:

```
$ cat test.py
#!/usr/bin/env python3

from sys import exit
from time import sleep

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

unit = Hinawa.SndTscm()
unit.open('/dev/snd/hwC2D0')
unit.listen()

req = Hinawa.FwReq()

def handle_control(self, index, flags):
     print('{0:02d}: {1:08x}'.format(index, flags))
     # data = bytearray(4)
     # You can check the flags and bright LED with proper values
     # in the data array.
     # print(req.write(self, 0xffff00000404, data))

unit.connect('control', handle_control)

while (True):
   msgs = unit.get_status()
   for i in range(len(msgs) // 2):
       left = i
       right = i + len(msgs) // 2
       print('{0:02d}: {1:08x}, {2:02d}: {3:08x}'.format(left, 
msgs[left], right, msgs[right]))
   sleep(0.1)
```

When running any scripts with your local build of libhinawa,
it's useful to set LD_LIBRARY_PATH/GI_TYPELIB_PATH properly.

```
$ export 
LD_LIBRARY_PATH="/home/username/git/libhinawa/build/src:${LD_LIBRARY_PATH}"
$ export 
GI_TYPELIB_PATH="/home/username/git/libhinawa/build/src:${GI_TYPELIB_PATH}"
$ ./sample.py
...
```

When starting packet streaming and operating control surface, you can
see dump with index and bitflags additionally to status dump.

```
...
06: fffeffff
06: ffffffff
06: feffffff
...
```

As I told, kernel driver emits events corresponding to quadlet 05-15.
If there's insufficiency, please inform it to me. If all things look
well, I'll submit patches for next merge window but .

[1] 
https://github.com/takaswie/snd-firewire-improve/tree/topic/tascam-userspace-take2
[2] https://github.com/takaswie/libhinawa/tree/topic/tascam-userspace-take2
[3] https://gist.github.com/takaswie/669fd4254c7b9fd631762fc61ac931f5


Thanks

Takashi Sakamoto


More information about the Alsa-devel mailing list