firewire-lib: Add some AV/C general commands

This commit adds three commands, which may be used by some firewire device
drivers. These commands are defined in 'AV/C Digital Interface Command Set
General Specification Version 4.2 (2004006, 1394TA)'.

1. PLUG INFO command (10.1)
2. INPUT PLUG SIGNAL FORMAT command (10.10)
3. OUTPUT PLUG SIGNAL FORMAT command (10.11)

By the command 1, the drivers can get the number of plugs for AV/C unit or
subunit.
By the command 2 and 3, the drivers can get/set sampling frequency.

The 'firewire-speakers' already uses INPUT PLUG SIGNAL FORMAT command to set
sampling rate. So this commit also affects the driver.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
firewire-lib: Add quirks for Fireworks

This commit adds three modifications for Echo Audio's Fireworks quirks.

1.Making this module to support both TAG0 and TAG1
In IEC 61883-1, each common isochronous packet (CIP) has 'tag' field in its
packet header. The value is generally 0x01 (CIP header is included = TAG1).
But Fireworks in 'IEC 61883 compliant' mode transmits 'no data' packet with
0x00 (No CIP header is included = TAG0) but the packet includes CIP structure.
To process 'presentation timestamp' for duplex streams synchronization
correctly, this packets needs to be handled.

2.Making this module to calculate data block size and not to check continuity
One of Fireworks device, AudioFirePre8, always reports 8 data block size in
in-packets and the data block counter is incremented by 8. But actual value is
wrong.

3.Making this module to have the numebr of first data blocks for MIDI messages
in out-packet
Fireworks can pick up MIDI messages in first 8 data blocks and ignore in other
data blocks.

I confirm these quirks in firmware version 4.8 to 5.8 for Windows. I didn't
investigate for the other versions. But according to contact person in Echo
Audio, there is no differences between firmwares installed by Windows or OS X.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
fireworks: Add skelton for Fireworks based devices

This commit adds a new driver with no functionality. This driver just
creates/removes card instance according to callbacks.

Current supported devices:
 - Mackie Onyx 400F/1200F
 - Echo AudioFire8(until 2009 July)/AudioFire12
 - Echo AudioFire2/4/8(since 2009 July)/Pre8
 - Echo Fireworks 8/HDMI
 - Gibson Robot Interface pack/GoldTop
fireworks: Add transaction and some commands

Fireworks uses own command and response. This commit adds functionality to
transact and adds some commands required for sound card instance and kernel
streaming.

There are two ways to deliver substance of this transaction:
1.AV/C vendor dependent command for command/response
2.Async transaction to specific addresses for command/response

By way 1, I confirm AudioFire12 cannot correctly response to some commands with
firmware version 5.0 or later. This is also confirmed by FFADO. So this module
implement way 2.

The address for response gives an issue. When this driver allocate own callback
function into the address, then no one can allocate its own callback function.
This situation is not good for applications in user-land. Currently this commit
don't solve this issue. This issue is solved in later commit.

I note there is a command to change the address for response if the device
supports. But this module uses default value. So users should not execute this
command as long as hoping this module works correctly.
fireworks: Add connection and stream management

Fireworks manages connections by CMP and can transmit/receive AMDTP streams
with a few quirks. This commit adds functionality to start/stop the streams.

Major Fireworks products don't support 'SYT-Match' mode, except for
AudioFire12/8(till 2009 July) with firmware version 1.0. Already in previous
commit, this driver don't support such old firmwares in previous commit. So
this commit adds support for non 'SYT-Match' mode.

I note that there is a short gap for MIDI streams when starting PCM data. When
AMDTP streams are running only for MIDI data and PCM data is going to be joined
at different sampling rate, then AMDTP streams are stopped once and started
again after changing sampling rate.

Fireworks quirks:

1.Fireworks transmits packets with both TAG0 and TAG1
In IEC 61883-1, each common isochronous packet (CIP) has 'tag' field in its
packet header. The value is generally 0x01 ('CIP header is included' = TAG1).
But Fireworks in 'IEC 61883 compliant mode' transmits 'no data' packet with 0x00
('No CIP header is included' = TAG0) but actually the packet includes CIP
structure. To handle 'presentation timestamp' for duplex streams
synchronization, this packets must be handled.

2.Fireworks transmits 'no data' packet out of specification
Fireworks transmits 'no data' packet with 'NO-DATA' FDF and no dummy data. It
includes CIP headers only. In IEC 61883-6, 'no data' packet is generated by two
ways. One is empty CIP packet defined in IEC 61883-1. Another is
'special non-empty packet' defined in IEC 61883-6. Fireworks uses strange
combination of them.

3.Fireworks can handle MIDI messages in the first 8 data blocks of out-packet
Fireworks ignores MIDI messages in other data blocks.

4.AudioFirePre8 transmits packets with wrong data block size
One of Fireworks device, AudioFirePre8, always reports 8 data block size in
transmitted packets and increments the data block counter by 8. But this is not
actual value.

I confirm them with firmware version 4.8 or later with Windows. According to
a contact persion in Echo Audio, there is no difference between firmwares
installed by Windows/OS X.
fireworks: Add proc interface for debugging purpose

This commit adds proc interface to output infomation for debugging.
 - firmware information
 - sampling rate and clock source
 - physical metering (linear value)
fireworks: Add MIDI interface

This commit adds a functionality to capture/playback MIDI messages.

When no AMDTP streams are running, this module starts AMDTP stream at current
sampling rate for MIDI stream.
fireworks: Add PCM interface

This commit adds a functionality to capture/playback PCM samples.

When AMDTP stream is already running for PCM or the source of clock is not
internal, available sampling rate is limited at current one.
fireworks: Add hwdep interface

This interface is designed for mixer/control application. To use hwdep
interface, the application can get information about firewire node, can
lock/unlock kernel streaming and can get notification at starting/stopping
kernel streaming.
fireworks: Add command/response functionality into hwdep interface

This commit adds two functionality for hwdep interface, adds two parameters for
this module, add a node for proc interface.

To receive responses from devices, this module already allocate own callback
into private address area in host controller. This means no one can allocate
its own callback to the address. So this module must give a way for user
applications to receive responses.

This commit adds a functionality to receive responses via hwdep interface. The
application can receive responses to read from this interface. To achieve this,
this commit adds a buffer to queue responses. The default size of this buffer is
1024 bytes. This size can be changed to give preferrable size to
'resp_buf_size' parameter for this module. The application should notice rest
of space in this buffer because this module don't push responses when this
buffer has no space.

Additionaly, this commit adds a functionality to transmit commands via hwdep
interface. The application can transmit commands to write into this interface.
I note that the application can transmit one command at once, but can receive
as many responses as possible untill the user-buffer is full.

When using these interfaces, the application must keep maximum number of
sequence number within the number in firewire.h because this module uses this
number to distinguish the response is against the command by the application or
this module.

Usually responses against commands which the application transmits are pushed
into this buffer. But to enable 'resp_buf_debug' parameter for this module, all
responses are pushed into the buffer. When using this mode, I reccomend to
expand the size of buffer.

Finally this commit adds a new node into proc interface to output status of the
buffer.
bebob: Add skelton for BeBoB based devices

This commit add a new driver for BeBoB based devices with no functionality. This
driver just create/remove card instance according to callbacks.

Current supported devices:
 - Edirol FA-66/FA-101
 - PreSonus FIREBOX/FIREPOD
 - BridgeCo RDAudio1/Audio5
 - Mackie Onyx 820/1220/1620/1640 (Firewire I/O Card)
 - Mackie d.2 (Firewire Option)
 - Stanton FinalScratch 2 (ScratchAmp)
 - Tascam  IF-FW DM
 - Apogee Rosetta 200/Rosetta 400 (X-FireWire card)
 - Apogee DA-16X/AD-16X/DD-16X (X-FireWire card)
 - ESI Quotafire610
 - AcousticReality eARMasterOne
 - CME MatrixKFW
 - Phonic HB12/12 MkII/12 Universal
 - Phonic HB18/18 MkII/18 Universal
 - Phonic HB24/24 MkII/24 Universal
 - Phonic FireFly 202/302
 - Lynx Aurora 8/16 (LT-FW)
 - ICON FireXon
 - PrismSound Orpheus/ADA-8XR

Devices possible to be supported if identifying IDs:
 - PreSonus Inspire 1394
 - Mackie Digital X Bus x.200/400
 - CME UF400e
 - Infrasonic DewX/Windy6
 - Rolf Spuler Firewire Guitar
bebob: Add commands and connections/streams management

This commit adds management functionality for connections and streams.
DM1000/BeBob uses CMP to manage connections and uses AMDTP for streams.

This commit also adds some BridgeCo's AV/C extension commands. There are many
BridgeCo's AV/C extension commands but this commit adds below commands in three
category to get device's capability and status:

 1.Extended Plug Info commands
  - Plug Channel Position Specific Data
  - Plug Type Specific Data
  - Cluster(or Section) Info Specific Data
  - Plug Input Specific Data
 2.Extended Stream Format Information commands
  - Extended Stream Format Information Command - Single Request
 3.The other vendor dependent commands
  - Stream presence detection
bebob: Add proc interface for debugging purpose

This commit adds proc interface to get information for debugging.
 - firmware information
 - stream formation
 - current clock source and sampling rate
bebob: Add MIDI interface

This commit adds a functionality to capture/playback MIDI messages.

When no AMDTP streams are running, this module starts AMDTP stream at current
sampling rate for MIDI stream.
bebob: Add PCM interface

This commit adds a functionality to capture/playback PCM samples.

When AMDTP stream is already running for PCM or the source of clock is not
internal, available sampling rate is limited at current one.
bebob: Add hwdep interface

This interface is designed for mixer/control application. To use hwdep
interface, the application can get information about firewire node, can
lock/unlock kernel streaming and can get notification at starting/stopping
kernel streaming.
bebob: Prepare for device specific operations

This commit is for some devices which have its own operations or quirks.

Many functionality should be implemented in user land. Then this commit adds
functionality related to stream such as sampling frequency or clock source. For
help to debug, this commit adds the functionality to get metering information
if it's available.

To help these functionalities, this commit adds some AV/C commands defined in
'AV/C Audio Subunit Specification (1394TA).
bebob: Add support for Terratec PHASE, EWS series and Aureon

This commit allows this driver to support all of models which Terratec produced
with DM1000/BeBoB. They are:
 - PHASE 24 FW
 - PHASE X24 FW
 - PHASE 88 Rack FW
 - EWS MIC2
 - EWS MIC4
 - Aureon 7.1 Firewire

For Phase series, this commit adds a Terratec specific operation. To get source
of clock. AV/C Audio Subunit command is used.

For EWS series and Aureon, this module uses normal operations.
bebob: Add support for Yamaha GO series

This commit allows this driver to support all of models which Yamaha produced
with DM1000/BeBoB. They are:
 - GO44
 - GO46

This commit adds Yamaha specific operations. To get source of clock, AV/C Audio
Subunit command is used.

I note that their appearances are similar to some models of TerraTec; 'Go44' is
similar to 'PHASE 24 FW' and 'GO46' is similar to 'PHASE X24 FW'. But their
combination of Audio/Music subunit are a bit different.
bebob: Add support for Focusrite Saffire/SaffirePro series

This commit allows this driver to support all of models which Focusrite
produces with DM1000/BeBoB. They are:
 - Saffire
 - Saffire LE
 - SaffirePro 10 I/O
 - SaffirePro 26 I/O

This commit adds Focusrite specific operations:
1. Get source of clock
2. Get/Set sampling frequency
3. Get metering information

The driver uses these functionalities to read/write specific address by async
transaction.