firewire-lib: Add some AV/C general commands

This commit add three commands. I think many devices use these commands.
These commands are defined in 'AV/C Digital Interface Command Set General
Specification Version 4.2 (2004006, 1394TA)'.

1. INPUT PLUG SIGNAL FORMAT command
2. OUTPUT PLUG SIGNAL FORMAT command
3. PLUG INFO command

By the command 1 and 2, the drivers can get/set sampling frequency.
By the command 3, the drivers can get information about plugs.

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

This commit adds three modifications for Fireworks quirks.

1. This module handle transmitted 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-1/6 compliant mode transmits 'no data' packet with
0x00 (No CIP header is included = TAG0) but the packet includes CIP structure.
For duplex streams synchronization, this packets must be handled.

Current firewire-lib supports packet with TAG1. This commit makes firewire-lib
to support both TAG0 and TAG1 for this quirk.

When handling CIP packet with invalid header, this module already output
'Invalid CIP header for AMDTP' log and continue to process.

(I note this 'no data' packet is out of specification because it includes no
dummy data. 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.)

2. This module calculate data block size by itself don't check counter.
One of Fireworks device, AudioFirePre8, always reports 8 data block size in
transmitted packets and the data block counter is incremented by 8. But this is
wrong. This commit force this module to calculate data block size and not to
check counter continuity.

3. The driver can indicate the number of first data blocks in which this module
put MIDI messages for out stream.
This commit add 'blocks_for_midi' member to 'amdtp_stream' structure for this
purpose. 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. I have no investigation
for the other versions.

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

This commit add a new driver with no functionality. This driver just reacts to
firewire bus events and create/remove card instance.

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 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.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 stream with
a few quirks. This commit adds functionality to start/stop streams.

As long as I know, Major Fireworks products don't support 'SYT-Match' mode,
except for AudioFire12/8(till 2009 July) with firmware version 1.0. So this
commit add support for no '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
multiplexed at different sampling rate, then AMDTP streams are stopped once and
started again after changing sampling rate.

Fireworks quirks I confirm with firmware version 4.8 or later with Windows:

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 transmits 'no data' packet with 0x00
('No CIP header is included' = TAG0) but the packet includes CIP structure.
For duplex streams synchronization, this packets must be handled for processing
'presentation timestamp' correctly.

2.Fireworks transmits 'no data' packet out of specification
In IEC 61883-6 compliant mode, 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 a received
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.
fireworks: Add proc interface for debugging purpose

This commit adds proc interface to output infomation for debugging.
 - hardware capabilities
 - 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, MIDI functionality starts AMDTP stream with
current sampling rate.
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 value can be changed to give preferrable value 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 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 the buffer is for responses against commands which the application
transmits. But to enable 'resp_buf_debug' parameter for this module, all
responses are queued into the buffer. When using this mode, I reccomend to
expand the size of buffer.

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

BeBoB is 'BridgeCo enhanced Breakout Box'. This is installed to
DM1000/1000E/1100/1500 chipset. It gives general way for host system to handle
BeBoB based devices.

This commit add a new driver for BeBoB based devices with no functionality. This
driver just reacts to Firewire bus events and create/remove card instance.

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 command and stream management

This commit adds BridgeCo's AV/C extension commands and connection/stream
management. The driver can get channel combination with the commands.
bebob: Add proc interface for debug

This commit adds proc interface to get chipset information and stream
formation for debug.
bebob: Add MIDI interface

This commit adds the functionality to capture/playback MIDI message. MIDI
message is multiplexed/demultiplexed into AMDTP stream.
bebob: Add PCM interface

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

PCM samples are multiplexed/demultiplexed into AMDTP stream safely with stream
helper functions.
bebob: Add hwdep interface to lock/unlock streaming

This is for mixer/control application in user land. The application can
lock/unlock kernel streaming or get notification at starting/stopping kernel
streaming to use hwdep interface.
bebob: Prepare for device specific operations

This commit is for some devices designed for semi-professional use. They have
some model specific functionality and quirks.

Many functionality should be implemented in user land. Then this commit adds
functionality related to stream such as sampling frequency or clock source. And
some device need cue to load firmware. This commit adds this mechanism. For
debugging, this commit adds the functionality to get metering information if
it's available.

To help these functionalities, this commit adds some AV/C commands in 'AV/C
Audio Subunit Specification (1394TA)' and 'Connection and Compatibility
Management(1394TA)'.
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, quirks for three functionalities.

1. Switching source of clock
2. Check clock synchronization

The driver uses these functionalities with AV/C vendor specific commands and
AV/C Audio Subunit commands.
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 Terratec specific operations, quirks for
three functionalities.

1. Switching source of clock
2. Change sampling frequency
3. Check clock synchronization

The driver uses these functionalities with AV/C vendor specific commands and
AV/C Audio Subunit commands.

For EWS series and Aureon, this module uses usual operations.
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, quirks for its four
functionalities.

1. Switching source of clock
2. Change sampling frequency
3. Check clock synchronization
4. Get metering information

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