fireworks: Add skelton for Fireworks based devices

This commit adds a new driver for devices based on Fireworks. This driver
just creates/removes card instance according to callbacks.

Fireworks is a board module which Echo Audio produced. This module
consists of three chipsets:
 - Communication chipset for IEEE1394 PHY/Link and IEC 61883-1/6
 - DSP or/and FPGA for signal processing
 - Flash Memory to store firmwares

Current supported devices:
 - Mackie Onyx 400F/1200F
 - Echo AudioFire12/8(until 2009 July)
 - Echo AudioFire2/4/Pre8/8(since 2009 July)
 - 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 driver
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. 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 driver uses default value. So users should not execute this
command as long as hoping this driver 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' modes, except for
AudioFire12/8(till 2009 July) with firmware version 1.0. Already in previous
commit, this driver don't support such old firmwares. So this commit adds
support for non 'SYT-Match' modes.

I note that this driver has a short gap for MIDI streams when starting PCM
stream. 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.

Unfortunately, Fireworks is not fully compliant to IEC 61883-1/6. Some commits
following to this commit add these quirks.
fireworks/firewire-lib: Add a quirk for empty packet with TAG0

Fireworks has a quirk to tranmit empty packets with TAG0. This commit
adds handling this quirk for full duplex stream synchronization.
fireworks/firewire-lib: Add a quirk for the meaning of dbc

Fireworks has a quirk for the value of dbc field in transmitted packets.
For Fireworks, dbc means the end of events in current packet. This is out
of specification.

For example, AudioFire4:
CIP0        CIP1    Payload
01070092 90FFFFFF 02
0107009A 9001E17B 3A <-
010700A2 9001F6E5 3A
010700A2 90FFFFFF 02
010700AA 9001104F 3A <-
010700B2 900125B9 3A
010700BA 90013B23 3A
010700BA 90FFFFFF 02
010700C2 9001548E 3A <-
010700CA 900169F8 3A
010700CA 90FFFFFF 02
010700D2 90018362 3A <-
010700DA 900198CC 3A

According to IEC 61883-1/6, a packet following to empty packet has the same
value for its dbc. But for Fireworks, it's incremented and empty packet has
the same value as previous packet in dbc field.

This commit adds a flag for Fireworks and some codes to checking dbc continuity.
fireworks/firewire-lib: Add a quirk for wrong dbs in tx packets

One of Fireworks firmware, named  as 'AudioFire9', seems to transmit
packets with wrong value of dbs. It's always 0x11 but actual size of
data block is different.

This commit adds a flag for this quirk and some codes to calculate
correct size.
fireworks/firewire-lib: Add a quirk for fixed interval of reported dbc

Fireworks firmware version 5.5 reports fix interval for dbc in each packet.

For example, AudioFire4:
CIP0     CIP1     Payload
00070000 900484FF 72
00070008 9004A8FF 72
00070008 90FFFFFF 02
00070010 9004D0FF 72
00070018 9004C4FF 72
00070020 9004E8FF 72
00070020 90FFFFFF 02
00070028 900410FE 72

The interval of each dbc should be 16 except for empty packet but it's still 8.

This commit adds a flag for this quirk and codes to refer to a fixed value.
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 driver starts AMDTP stream for MIDI
stream at current sampling rate.
fireworks/firewire-lib: Add a quirk of data blocks for MIDI in out-stream

Fireworks has a quirk to ignore MIDI messages in data blocks more than 8.
This commit adds a flag for this quirk and codes to skip 8 or more data
blocks to transfer MIDI messages.
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 driver, add a node for proc interface.

To receive responses from devices, this driver already allocate own callback
into initial memory space in host controller. This means no one can allocate
its own callback to the address. So this driver 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 driver. The application should notice rest
of space in this buffer because this driver 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 in command within the number in firewire.h because this driver
uses this number to distinguish the response is against the command by the
application or this driver.

Usually responses against commands which the application transmits are pushed
into this buffer. But to enable 'resp_buf_debug' parameter for this driver, 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 adds a new driver for BeBoB based devices with no specific
operations. Currently this driver just create/remove card instance according
to callbacks.

BeBoB is 'BridgeCo enhanced Breakout Box'. This is installed to firewire
devices with DM1000//DM1100/DM1500 chipset. It gives common way for host
system to handle BeBoB based devices.

Current supported devices:
 - Edirol FA-66/FA-101
 - PreSonus FIREBOX/FIREPOD/FP10/Inspire1394
 - BridgeCo RDAudio1/Audio5
 - Mackie Onyx 1220/1620/1640 (Firewire I/O Card)
 - Mackie d.2 (Firewire Option)
 - Stanton FinalScratch 2 (ScratchAmp)
 - Tascam IF-FW DM
 - Behringer XENIX UFX 1204/1604
 - Behringer Digital Mixer X32 series (X-UF Card)
 - Apogee Rosetta 200/Rosetta 400 (X-FireWire card)
 - Apogee DA-16X/AD-16X/DD-16X (X-FireWire card)
 - Apogee Ensemble
 - ESI Quotafire610
 - AcousticReality eARMasterOne
 - CME MatrixKFW
 - Phonix Helix Board 12 MkII/18 MkII/24 MkII
 - Phonic Helix Board 12 Universal/18 Universal/24 Universal
 - Lynx Aurora 8/16 (LT-FW)
 - ICON FireXon
 - PrismSound Orpheus/ADA-8XR

Devices possible to be supported if identifying IDs:
 - Apogee Mini-Me Firewire/Mini-DAC Firewire
 - Behringer F-Control Audio 610/1616
 - Cakewalk Sonar Power Studio 66
 - CME UF400e
 - ESI Quotafire XL
 - Infrasonic DewX/Windy6
 - Mackie Digital X Bus x.200/400
 - Phonic Helix Board 12/18/24
 - Phonic FireFly 202/302
 - Rolf Spuler Firewire Guitar

Tested-by: David Henningsson <david.henningsson@canonical.com>
bebob: Add commands and connections/streams management

This commit adds management functionality for connections and streams.
BeBoB uses CMP to manage connections and uses AMDTP for streams.

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

 1.Extended Plug Info commands
  - Plug Channel Position Specific Data
  - Plug Type Specific Data
  - Cluster(Section) Info Specific Data
  - Plug Input Specific Data
 2.Extended Stream Format Information commands
  - Extended Stream Format Information Command - Single Request

For Extended Plug Info commands for Cluster Info Specific Data, I pick up
'section' instead of 'cluster' from document to prevent from misunderstanding
because 'cluster' is also used in IEC 61883-6.
bebob/firewire-lib: Add a quirk for discontinuity at bus reset

This commit adds a flag, which has an effect to skip checking continuity
for first packet. This flag is useful for BeBoB quirk.

Normal BeBoB firmware has a quirk. When receiving bus reset, it transmit
packets with discontinuous value in dbc field.

This causes two situation, one is to abort streaming by firewire-lib as a
result of detecting the discontinuity. Another is to call driver's .update().
These two is generated separately. (The former depends on isochronous stream
and the latter depends on IEEE1394 bus driver.)

When BeBoB driver works with XRUN-recoverable applications, this situation
looks like stream_update_duplex() call following to stream_start_duplex() call
(because applications will call snd_pcm_prepare() immediately).

At bus reset, stream_start_duplex() shouldn't break/establish connections and
stream_update_duplex() should update connections because a caller of
fw_iso_resources_allocate() is responsible for calling
fw_iso_resources_update() on bus reset.

For this purpose, this commit allows BeBoB driver to re-start streams during
transmitting packets, without breaking connections.
bebob: Add proc interface for debugging purpose

This commit adds proc interface to get information belo 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 substream.
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. By using hwdep
interface, the application can get information about firewire node, can
lock/unlock kernel streaming and can get notification at starting/stopping
kernel streaming.