firewire-lib: Add macros instead of fixed value

This patch adds some macros for fixed value related to AMDTP
in IEC 61883-6. These macros will also be used by followed patches.

This patch also replace existed fixed value to the corresponding macro.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
firewire-lib: Add "direction" member to amdtp_stream structure

To indicate the direction of amdtp stream, this patch adds "direction" member
to amdtp_stream structure. To determine the direction, this patch also adds
"direction" argument to amdtp_stream_init() function. The amdtp_stream_init()
function is exported and used by firewire-speakers and dice so this patch also
affects them.

This patch just add them. Actual implementation will be done by followed
patches.
firewire-lib: Split some codes into functions to reuse in both streams

Some codes can be reused in handling transmitted stream. This commit adds new
functions. To keep naming consistency, this commit also renames some functions.
firewire-lib: Add support for AMDTP transmit stream and PCM capture

For capturing PCM, this commit adds the functionality to handle transmitted
stream.
firewire-lib: Add support for MIDI capture/playback

For capturing/playbacking MIDI message, this commit adds the functionality to
multiplex MIDI streams into AMDTP sream in IEC 61883-6. As a result, the number
of MIDI ports is limited by 16 ports, for convinience.

And this commit allows to set PCM format even if AMDTP stream already starts.
I suppose the case that PCM data starts to be multiplexed/demultiplexed after
AMDTP stream is already started for MIDI. To distinguish whether PCM or MIDI
functionality starts AMDTP stream, this commit adds amdtp_stream_pcm_running()
and amdtp_stream_midi_running().

IEC 61883-6 refers to AMEI/MMA RP-027 for implementation of MIDI conformant
data. MIDI1.0-2x/3x-SPEED mode is not implemented because these modes need
'negotiation procedure' and 'encapsulation details' but I cannot find
specifications about them.
firewire-lib: give syt value from external handle_out_packet()

For duplex streams with synchronization, this driver pass 'presentation
timestamp' from transmit packets to out packets. This commit is preparation for
this.
firewire-lib: Add support for duplex streams with synchronization

Generally, the devices can synchronize to handle 'presentation timestamp'
in CIP packets. This commit adds the functionality to pick up this timestamp
in packets transmitted by the device, then use it for out packets.

In previous implementation, this module generated the timestamp. Then it acts
as synchronization master. This commit allows this module to act as
synchronization slave.
firewire-lib: Add sort function for transmitted packet

The aim of this commit is to assure the continuity of timestamp in received
packets. Fireworks with firmware version 5.5 or former is a type of device
which transmits packets with a bit disorder.For example,

Index  Payload	CIP header 1  CIP header 2
023    210      3F1100F8      900478E9
024    002      3F1100F8      90FFFFFF
025    210      3F110000      900490E9
026    210      3F110008      9004A4E9
027    210      3F110010      9004B8E9
028    002      3F110010      90FFFFFF
029    210      3F110020      9004E4E8 <-
030    210      3F110018      9004D0E8 <-
031    210      3F110028      9004F8E8
032    002      3F110028      90FFFFFF
033    210      3F110030      900410E8
034    210      3F110038      900424E8
035    210      3F110040      900438E8
036    002      3F110040      90FFFFFF
037    210      3F110050      900464E8 <-
038    210      3F110048      900450E8 <-
039    210      3F110058      900478E8
040    002      3F110058      90FFFFFF
041    210      3F110068      9004A4E8 <-
042    210      3F110060      900490E8 <-
043    210      3F110070      9004B8E8
044    002      3F110070      90FFFFFF
045    210      3F110080      9004E4E7 <-
046    210      3F110078      9004D0E8 <-
firewire-lib: Add transfer delay to synchronized duplex streams

'Presentation timestamp' is expected time to handle the data in a packet. For
example, when the driver reads 'presentation timestamp' in a transmitted
packet, it's for the data in the packet.

Currently, when duplex streams with synchronization mode, this module just pass
'presentation timestamp' from transmitted packets to out packets. This is
enough for actual device but logically it should include 'transfer delay' and
'processing time'. This means the timestamp in out packet should be at future.

To be simple, this commit add only 'transfer delay'.
firewire-lib: Add support for channel mapping

Some devices arrange the position of PCM/MIDI data. This commit allows drivers
to set channel mapping.

To be simple, the mapping table is an array with fixed length. Then the number
of channels for PCM is restricted by 64.
firewire-lib: rename macros, variables and functions related to CMP plug

Referring to IEC 61883-1, oMPR and iMPR, oPCR and iPCR have some fields with
the same role in the same position. This patch renames some local macros, local
variables and function arguments which has "i" in its prefix to reuse them
between oMPR and iMPR, oPCR and iPCR.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
firewire-lib: Add "direction" member to cmp_connection structure

To indicate the direction of connection, this patch adds "direction" member to
cmp_connection structure. To determine the direction, this patch also adds
"direction" argument to cmp_connection_init() function. The
cmp_connection_init() function is exported and used in snd-firewire-speakers so
this patch also affect it.

This patch just add them. Actual implementation will be done by followed
patches.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
firewire-lib: Add handling CMP output connection

To handle CMP output connection, this patch adds some macros, codes with
condition of direction and new functions. Once cmp_connection_init() is
executed with its direction, CMP input and output connection can be
handled by the same way.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
firewire-lib: Add a new function to check others' connection
firewire-lib: Add some AV/C general commands
firewire-lib: Add quirk for BeBoB chipset
firewire-lib: Add quirks for Fireworks chipset
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 the number of each plugs.