Commit graph

506 commits

Author SHA1 Message Date
Takashi Sakamoto c30076568d ALSA: dice: get the number of MBLA data channel at opening PCM substream
This commit is a preparation to remove members related to channel cache
for the number of channels for multi bit linear audio data and MIDI
ports. This commit changes the way to get the number of multi bit linear
audio data channel. It's directly retrieved by asynchronous transactions
to some registers.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-02-09 12:22:10 +01:00
Takashi Sakamoto b9022f4d2c ALSA: dice: add MIDI ports according to current number of MIDI substreams
This commit changes the way to add ALSA MIDI ports. This driver read the
number of multiplexed MIDI substreams from hardware register, then adds the
same number of ALSA MIDI ports. This commit is based on my assumption that
the number is fixed at all of supported sampling transfer frequency.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-02-09 12:22:09 +01:00
Takashi Sakamoto 1bc8e12d94 ALSA: dice: limit stream to current sampling transfer frequency.
In previous commit, ALSA Dice driver limits PCM substreams at current
sampling transfer frequency and current number of Multi bit linear audio
data channel. Thus, the driver has no need to start AMDTP streams at
the other sampling transfer frequency except for current one. This is due
to Dice interface design.

This commit limits AMDTP stream at current sampling transfer frequency,
according to the design.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-02-09 12:22:09 +01:00
Takashi Sakamoto 0d5ee195b1 ALSA: dice: limit to current sampling transfer frequency
ALSA PCM core has a functionality for rule of PCM substream parameters.
Typically, when userspace opens PCM character devices, each driver adds
its own rules to PCM substream according to design of hardware. When the
userspace executes hw_params ioctl with favorite parameters, the actual
parameters are calculated according to the rules and the given parameters.
Then, the result is returned to userspace.

Currently, ALSA Dice driver has the rule between channels and rates, while
Dice interface design doesn't allow drivers to retrieve all of the
combinations. Dice drivers are just allowed to get current sampling
transfer frequency and the number of multi bit linear audio data channels
in an data block of an AMDTP packet.

This commit purges the rule, and limit PCM substreams to current sampling
transfer frequency, following to the interface design.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-02-09 12:22:08 +01:00
Geert Uytterhoeven b8cb3750ce ALSA: firewire-digi00x: Drop bogus const type qualifier on dot_scrt()
sound/firewire/digi00x/amdtp-dot.c:67: warning: type qualifiers ignored on function return type

Drop the bogus "const" type qualifier on the return type of dot_scrt()
to fix this.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-02-09 12:16:52 +01:00
Takashi Sakamoto 56661a2ed5 ALSA: firewire-tascam: remove needless member for control and status message
Commit 3beab0f844 added a member for control and status message, while
it's planned and not implemented yet.

This commit removes it.

Fixes: 3beab0f844fa('ALSA: firewire-tascam: add support for outgoing MIDI messages by asynchronous transaction')
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-02-05 12:47:14 +01:00
Takashi Sakamoto 61ebe49964 ALSA: firewire-tascam: remove a flag for controller
Currently, 'struct snd_tscm_spec' has a member named as 'is_controller' to
identify MIDI controller. This member was originally added to skip
parse control and status messages in isochronous packets for non-controller
model.

As long as I investigate, FW-1804 (non-controller) also transfers the
control and status message, thus it becomes meaningless.

This commit removes it.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-02-05 12:46:15 +01:00
Takashi Sakamoto 3e78e1518e ALSA: firewire-tascam: add support for FW-1804
This model supports:
 * maximum 12 PCM channels for PCM playback
 * maximum 18 PCM channels for PCM capture
 * 4 ports for MIDI playback
 * 4 ports for MIDI capture
 * control and status messages in tx isochronous packets
 * up to 96.0 kHz

This commit adds support for the model. As the other supported models,
all of available PCM channels are always enabled.

As I described in commit c0949b2785, Ilya Zimnovich had investigated
TASCAM FireWire series in 2011 with his FW-1804. In his report, this model
has internal multiplexer and any software implementation can control it.
Following to the design of ALSA firewire stack, this commit won't
implement it. It should be in userspace via Linux fw character device.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-02-05 12:46:07 +01:00
Takashi Sakamoto 5d2560a427 ALSA: firewire-tascam: fix NULL pointer dereference when model identification fails
When unsupported models are connected, snd-firewire-tascam module causes
NULL pointer dereference in fw_core_remove_address_handler() (due to
list_del_rcu()).

This commit prevents this bug.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-02-05 12:45:59 +01:00
Lucas Tanure 07905298e4 ALSA: bebob: Use a signed return type for get_formation_index
The return type "unsigned int" was used by the get_formation_index function
despite of the aspect that it will eventually return a negative	error code.
So, change to signed int and get index by reference in the parameters.

Done with the help of Coccinelle.

[Fix the missing braces suggested by Julia Lawall -- tiwai]

Signed-off-by: Lucas Tanure <tanure@linux.com>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Tested-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-01-26 11:38:53 +01:00
Takashi Sakamoto 2eb65d67af ALSA: dice: expand timeout to wait for Dice notification
Some users have reported that their Dice based models generate ETIMEDOUT
when starting PCM playback. It means that current timeout (=100msec) is
not enough for their models to transfer notifications.

This commit expands the timeout up to 2 sec. As a result, in a worst case,
any operations to start AMDTP streams takes 2 sec or more. Then, in
userspace, snd_pcm_hw_params(), snd_pcm_prepare(), snd_pcm_recover(),
snd_rawmidi_open(), snd_seq_connect_from() and snd_seq_connect_to() may
take the time.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-01-06 10:18:54 +01:00
Takashi Sakamoto a2875a92b8 ALSA: dice: purge transaction initialization at timeout of Dice notification
In previous commit, card registration is processed under situation
with few bus reset. There's no need to add a workaround of transaction
re-initialization at timeout.

This commit purges the re-initialization.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-01-06 10:18:54 +01:00
Takashi Sakamoto b59fb1900b ALSA: dice: postpone card registration
Some models based on ASIC for Dice II series (STD, CP) change their
hardware configurations after appearing on IEEE 1394 bus. This is due to
interactions of boot loader (RedBoot), firmwares (eCos) and vendor's
configurations. This causes current ALSA dice driver to get wrong
information about the hardware's capability because its probe function
runs just after detecting unit of the model.

As long as I investigated, it takes a bit time (less than 1 second) to load
the firmware after bootstrap. Just after loaded, the driver can get
information about the unit. Then the hardware is initialized according to
vendor's configurations. After, the got information becomes wrong.
Between bootstrap, firmware loading and post configuration, some bus resets
are observed.

This commit offloads most processing of probe function into workqueue and
schedules the workqueue after successive bus resets. This has an effect to
get correct hardware information and avoid involvement to bus reset storm.

For code simplicity, this change effects all of Dice-based models, i.e.
Dice II, Dice Jr., Dice Mini and Dice III.

I use a loose strategy to manage a race condition between the work and the
bus reset. This is due to a specification of dice transaction. When bus
reset occurs, registered address for the transaction is cleared. Drivers
must re-register their own address again. While, this operation is required
for the work because the work includes to wait for the transaction. This
commit uses no lock primitives for the race condition. Instead, checking
'registered' member of 'struct snd_dice' avoid executing the work again.
If sound card is not registered, the work can be scheduled again by bus
reset handler.

When .remove callback is executed, the sound card is going to be released.
The work should not be pending or executed in the releasing. This commit
uses cancel_delayed_work_sync() in .remove callback and wait till the
pending work finished. After .remove callback, .update callback is not
executed, therefore no works are scheduled again.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-01-06 10:18:53 +01:00
Takashi Sakamoto 4a47a87def ALSA: dice: split subaddress check from category check
Before allocating an instance of sound card, ALSA dice driver checks
chip_ID_hi in Bus information block of Config ROM, then also checks
subaddresses. The former operation reads cache of Config ROM in Linux
FireWire subsystem, while the latter operation sends read transaction.
The latter can be merged into initialization of transaction system.

This commit splits these two operations to reduce needless transactions
in probe processing.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-01-06 10:18:52 +01:00
Takashi Sakamoto de5126cc3c ALSA: oxfw: add stream format quirk for SCS.1 models
As long as I investigate SCS.1m, this model reports to transfer/receive
PCM data channels/MIDI conformant data channels in tx/rx AMDTP packet.
There's a contradiction that this model actually has no analog/digital
capture port for PCM frames and no physical MIDI ports.

I guess that SCS.1d also has the contradiction. This model has no
analog/digital ports for PCM frames and no physical MIDI ports, thus it
requires no streaming functionality.

This commit adds some modification codes to handle the contradiction,
as much as possible. Unfortunately, this module adds one PCM playback
substream for SCS.1d so as SCS.1m.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-12-22 11:51:32 +01:00
Takashi Sakamoto 9e2004f9ce ALSA: oxfw: obsolete scs1x module
Now ALSA oxfw driver gains functionalities which scs1x module has.

This commit obsoletes the scs1x module, and adds a line of MODULE_ALIAS
to load oxfw module instead of scs1x module.

In scs1x module, the name of 'shortname' field is fixed as 'SCS1x'. This
field is used to name MIDI ports for both of SCS.1m and SCS.1d. This is
not good because typically some SCS.1m and SCS.1d are used in the same
system. It's better to distinguish them according to name of the ports.
This commit applies model name in config ROM to the 'shortname'.

For the name of 'driver' and 'longname', this commit uses the same way
applied to the other models. This change may not bring disadvantages to
users because userspace applications use ALSA rawmidi or seq interface
and these interfaces are not influenced by them directly.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-12-22 11:51:31 +01:00
Takashi Sakamoto 6f5dcb28df ALSA: oxfw: add MIDI playback port for SCS.1 models
This commit adds MIDI playback ports so that scs1x driver has.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-12-22 11:51:31 +01:00
Takashi Sakamoto d7d20e7781 ALSA: oxfw: copy handlers of asynchronous transaction for MIDI playback
This commit copies some functions of asynchronous transactions for MIDI
playback, to merge scs1x module. The features of payload in asynchronous
transaction are the same as captured MIDI messages.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-12-22 11:51:30 +01:00
Takashi Sakamoto 8250427dc1 ALSA: oxfw: add MIDI capture port for SCS.1 models
This commit adds MIDI capture so that scs1x driver has.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-12-22 11:51:29 +01:00
Takashi Sakamoto 13b8b78c7f ALSA: oxfw: copy handlers of asynchronous transaction for MIDI capture
This commit copies some functions of asynchronous transactions for MIDI
capture, to merge scs1x module. The features of payload in asynchronous
transaction are:

 * System exclusive messages for SCS.1 are encoded without ID data. In
   this encoding scheme, 4 bits in LSB are available. The bits are squashed
   in payload byte. Thus, one payload byte transfers two MIDI messages.
 * The first byte of payload byte means:
  * 0x00: depending on second payload byte
   * 0xf9: including escaped system exclusive messages for SCS.1, up to
     3 byte (= 6 MIDI messages)
   * the others: including MIDI 1.0 messages
  * the others: including escaped system exclusive messages for SCS.1, up
    to 64 bytes

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-12-22 11:51:29 +01:00
Takashi Sakamoto e3315b439c ALSA: oxfw: allocate own address region for SCS.1 series
When physical controls on SCS.1 models are operated, the models transfer
MIDI messages in asynchronous transactions on IEEE 1394 bus. The models
have a register to have an address for the transactions, and drivers
can register own address for this purpose.

This commit keeps a region of address, registers it and adds a handler for
the transactions.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-12-22 11:51:28 +01:00
Takashi Sakamoto 3f47152a1c ALSA: oxfw: add scs1x layer
Stanton Controllers and Systems 1 (SCS.1) series is supported by ALSA
scs1x driver. This driver just supports MIDI functionality. On the other
hand, models in this series are based on OXFW971 and ALSA OXFW driver can
support them.

SCS.1 series has MIDI functionality to control its surface state such as
LED lighting. When operating physical knobs and faders, the models
generate MIDI messages. These MIDI messages are transferred by asynchronous
transactions. These transactions are really model-specific and ALSA OXFW
driver requires the functionality so as scs1x module implements.

This commit adds scs1x layer as a preparation to merge scs1x driver to
oxfw driver.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-12-22 11:51:27 +01:00
Takashi Sakamoto d6ce6bbd7d ALSA: oxfw: rename a structure so that it means backward compatibility to old drivers
In former commits, some model-specific members are split from the
structure. The structure is just to keep names for compatibility to old
drivers.

This commit arranges name of the structure and localize it.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-12-22 11:50:31 +01:00
Takashi Sakamoto 3e2f45708e ALSA: oxfw: move model-specific parameters from common structure
In previous commit, some members are moved from 'struct snd_oxfw' because
they're model-specific. There are also the other model-specific parameters
in 'struct device_info'.

This commit moves these members to model-specific structure.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-12-22 11:50:31 +01:00
Takashi Sakamoto 40540de503 ALSA: oxfw: move model-specific members from common structure
Currently, 'struct snd_oxfw' has some members for models supported by old
firewire-speakers driver, while these members are useless to the other
models.

This commit allocates new memory block and moves these members to
model-specific structure.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-12-22 11:50:30 +01:00
Takashi Sakamoto c582cc66b9 ALSA: oxfw: enable to keep memory block for model-specific structure
ALSA oxfw driver should have backward compatibility to old
firewire-speakers driver. Additionally, in future commit, scs1x driver
will be merged. It's nice to add a pointer to have a memory block for
model-specific structures.

This commit adds a member to 'struct snd_oxfw' for this aim. Deallocation
is done at freeing ALSA card structure.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-12-22 11:50:29 +01:00
Takashi Iwai f2777c1344 Merge branch 'topic/firewire-update' into for-next 2015-12-16 12:09:10 +01:00
Takashi Sakamoto 5ce8cc4844 ALSA: oxfw: gather model-dependent conditions to a function
Adding control elements is just for models supported by old
firewire-speakers modules. The processing should be in a function to add
model-dependent quirk.

This commit moves the codes to the function. As a result, the function
should handle error state, thus this commit also changes prototype of
the function.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-12-15 16:30:05 +01:00
Takashi Sakamoto 27e6663501 ALSA: oxfw: reuse driver entry to detect quirks
Currently, assignment to model-dependent quirk is corresponding to
asynchronous transactions on IEEE 1394 bus. This is also achieved with
device entry.

This commit changes the processing of model-dependent quirk with the
entry. As a result, the transactions are sent only for Loud models.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-12-15 16:30:04 +01:00
Takashi Sakamoto eab8e4e461 ALSA: oxfw: change function prototype for AV/C Audio Subunit command
ALSA OXFW driver uses AV/C Audio Subunit commands to control some models.
The commands get/set the state of Feature function block of the subunit.
The commands are not specific to OXFW, thus there's a possibility to use
them in the other drivers.

Currently, helper functions for the commands require 'struct snd_oxfw',
although, it's not necessarily required. It's better to change prototype
of the functions without the structure for future use.

This commit changes the prototype.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-12-15 16:30:04 +01:00
Takashi Sakamoto 29aa09acb2 ALSA: oxfw: rename local functions for control elements so that they represent as local
This commit renames local functions with prefix 'spkr_', so that they're
for firewire-speakers.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-12-15 16:30:03 +01:00
Takashi Sakamoto f3a0e32a6f ALSA: oxfw: rename a file for control elements so that it's for model-specific
In ALSA firewire stack, drivers basically has no control elements. This
is due to the fact that each model has own functionality even if they use
the same communication chipset. Implementing all of the functionalities in
kernel space unreasonably increases our efforts to maintain the stack. In
most case, these functionalities can be implemented in userspace via Linux
fw character devices.

However, ALSA OXFW driver has control elements comes from old
firewire-speakers driver. Adding the elements is in a file names as
'oxfw-control.c', while the elements are really model-specific. The
name is confusing because it gives an idea to handle control elements
for all of OXFW-based models.

This commit renames the file so that it's just for models supported by
old firewire-speakers driver.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-12-15 16:30:02 +01:00
Takashi Sakamoto 4d2c50a0a9 ALSA: fireworks: change type of substream counter from atomic_t to unsigned int
The counter is incremented/decremented in critical section protected with
mutex. Therefore, no need to use atomic_t.

This commit changes the type to unsigned int.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-11-14 17:53:46 +01:00
Takashi Sakamoto ea54a37442 ALSA: fireworks: move mutex from function callees to callers
Currently, critical section is protected by mutex in functions of
fireworks_stream.c. Callers increments/decrements substreams counter
before calling the functions. Moving mutex to the callers code allows
to change type of the substeram counter from atomic_t to unsigned int.

This commit is a preparation for obsoleting usage of atomic_t for
substream counter.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-11-14 17:53:41 +01:00
Takashi Sakamoto 5d5563b14f ALSA: dice: fix detection of Loud devices
Commit a471fcde8c ("ALSA: dice: fix detection of Weiss devices") adds
a quirk of Weiss models. According to users' reports, Loud models also
have the similar quirk. They have 0x10 in the category field.

This commit adds support for Mackie Onyx Blackbird and Onyx-i series.
As long as I know, Dice-based models produced by
Focusrite/Alesis/PreSonus/M-Audio/TC Electronic have default value (0x04)
in their category field, thus it may be reasonable to add a condition
statement for Loud models, instead of removing the check of category value.

Reported-by: Rouge Etienne <erouge.externe@m6.fr>
Reported-by: Etilem <contact@etilem.net>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-11-14 17:50:57 +01:00
Takashi Sakamoto 94d505e974 ALSA: oxfw: add an comment to Kconfig for TASCAM FireOne
A commit to add support for this model should have added a comment
about this model to Kconfig.

Fixes: 759a2f40c9fa('ALSA: oxfw: add an entry for TASCAM FireOne')
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-11-08 09:04:36 +01:00
Takashi Sakamoto d1482fb335 ALSA: firewire-digi00x: add another rawmidi character device for MIDI control ports
Digi 002/003 family uses two ways to transfer MIDI messages. They're
different mechanisms, while it's better to handle the ways in different
ALSA rawmidi character devices because one character device has just a
set of operations.

This commit adds another rawmidi character device for control MIDI port. As
a result, first rawmidi character device is just for MIDI messages
transferred by isochronous packets.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-30 19:34:44 +01:00
Takashi Sakamoto c5fcee0373 ALSA: firewire-digi00x: add MIDI operations for MIDI control port
Digi 002/003 family has two types of MIDI port; one is for physical MIDI
port and another is for MIDI control message. The former is transferred in
isochronous packet, and the latter is transferred by asynchronous
transaction. These transmission mechanisms are completely different, while
current ALSA digi00x driver defines a set of operations for them with
several condition statements. As a result, codes for the operation are
messy.

This commit adds a set of MIDI operation for control MIDI ports. In later
commit, it's applied as an operation for ALSA rawmidi character device.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-30 19:34:32 +01:00
Takashi Sakamoto 5918f96220 ALSA: firewire-digi00x: rename identifiers of MIDI operation for physical ports
In following commit, new functions and variables are added for operations
of MIDI control port.

This commit is a preparation. Current identifiers are renamed so that they
mean physical MIDI ports.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-30 19:34:13 +01:00
Takashi Sakamoto f937b43d48 ALSA: firewire-tascam: clear extra MIDI bytes in an asynchronous transaction
When MIDI buffer stores two or more MIDI messages, TASCAM driver
transfers asynchronous transactions including one MIDI message and
extra bytes from second MIDI message.

This commit fixes this bug by clearing needless bytes in the buffer. The
consumed bytes are already calculated correctly, thus the sequence of
transactions is already correct.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-20 17:49:15 +02:00
Takashi Sakamoto 123990e930 ALSA: firewire-tascam: fix loop condition with some readable variables
In transactions for MIDI messages, the first byte is used for label and
the rest is for MIDI bytes. In current code, these are handled correctly,
while there's a small mistake for loop condition to include meaningless
statement.

This commit adds two local variables for them and improve the loop
condition.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-20 17:49:15 +02:00
Takashi Sakamoto b7ab614f30 ALSA: firewire-tascam: use better name for local variables to describe their intension
In the callback function of asynchronous MIDI port, the intension of some
local variables are not clear.

This commit improves them. The 'len' variable is used to calculate the
number of MIDI bytes including in the transaction. The 'consume' variable
is used to return the actual number of consumed bytes in ALSA MIDI buffer.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-20 17:49:14 +02:00
Takashi Sakamoto 516a306156 ALSA: firewire-tascam: change type of valiables according to function prototype
In the callback function of asynchronous MIDI port, some local variables
are declared 'unsigned int', while they're assigned to int value of return
from snd_rawmidi_transmit_peek().

This commit fixes the type.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-20 17:49:14 +02:00
Takashi Sakamoto 9f9c5617c8 ALSA: firewire-tascam: remove buffer initialization in driver side
The given buffer to callback function is cleared in caller side.

This commit removes buffer initialization in callee side.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-20 17:49:13 +02:00
Dan Carpenter 9a30ae2df2 ALSA: firewire-tascam: off by one in identify_model()
Let's leave space for the NUL char otherwise the static checkers
complain that we go beyond the end of the array.

Fixes: 53b3ffee78 ('ALSA: firewire-tascam: change device probing processing')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-19 14:00:49 +02:00
Takashi Sakamoto 759a2f40c9 ALSA: oxfw: add an entry for TASCAM FireOne
TASCAM FireOne is based on OXFW971 and ALSA OXFW driver can support it.
These are values of identical registers.

$ ./firewire-request /dev/fw1 read 0xfffff0050000
result: 97100105

$ ./firewire-request /dev/fw1 read 0xfffff0090020
result: 39373100

This commit adds an entry for this model. This model has physical controls
and its MIDI control messages are transferred to second MIDI data stream
multiplexed in one MIDI conformant data channel.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-19 12:01:22 +02:00
Takashi Sakamoto bb71da4346 ALSA: oxfw: support more MIDI ports
In IEC 61883-6, sequence multiplexing is applied to MIDI conformant data
channel. As a result, eight MIDI data streams are included in the channel.
Although ALSA AM824 data block processing layer implements this
multiplexing, current OXFW driver doesn't utilize it due to wrong
calculation of MIDI ports.

This commit fixes this bug to add proper calculation. Although this commit
allows to use 8 MIDI data streams, the number of available MIDI ports is
limited by the number of ALSA MIDI ports added by the driver.

Fixes: df075feefbd3('ALSA: firewire-lib: complete AM824 data block processing layer')
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-19 12:01:07 +02:00
Takashi Sakamoto 3205604101 ALSA: oxfw: calculating MIDI ports in stream discover
Current OXFW driver calculates the number of MIDI ports just before adding
ALSA MIDI ports. It's convenient for some devices with quirks to move
these codes before handling quirks.

This commit implements this idea.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-19 12:00:47 +02:00
Takashi Sakamoto 56b1c72a75 ALSA: firewire-lib: avoid NULL pointer dereference after closing MIDI port
When asynchronous MIDI port is closed before callbacked, the callback
function causes NULL pointer dereference to missing MIDI substream.

This commit fixes this bug.

Fixes: e8a40d9bcb23('ALSA: firewire-lib: schedule work again when MIDI substream has rest of MIDI messages')
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-19 11:58:21 +02:00
Takashi Sakamoto bd04809bbe ALSA: firewire-digi00x/firewire-tascam: remove wrong conversion for Config ROM
The contents of Config ROM in firewire device structure are already
aligned to CPU-endianness. Thus, no need to convert it again.

This commit removes needless conversions

Fixes: 9edf723fd858('ALSA: firewire-digi00x: add skeleton for Digi 002/003 family')
Fixes: c0949b278515('ALSA: firewire-tascam: add skeleton for TASCAM FireWire series')
Reported-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-19 11:57:03 +02:00
Takashi Sakamoto fef586d589 ALSA: bebob: use correct type for __be32 data
In former commit, metering is supported for BeBoB based models
customized by M-Audio. The data in transaction is aligned to
big-endianness, while in the driver code u16 typed variable is assigned
to the data. This causes sparse warnings.

bebob_maudio.c:651:31: warning: cast to restricted __be16
bebob_maudio.c:651:31: warning: cast to restricted __be16
bebob_maudio.c:651:31: warning: cast to restricted __be16
bebob_maudio.c:651:31: warning: cast to restricted __be16

This commit fixes this bug by using __be16 variable for the data.

Fixes: 3149ac489ff8('ALSA: bebob: Add support for M-Audio special Firewire series')
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-19 11:57:03 +02:00
Takashi Sakamoto 463543ac2e ALSA: fireworks: use u32 type for be32_to_cpup() macro
In former commit, snd_efw_command_get_phys_meters() was added to handle
metering data. The given buffer is used to save transaction result and to
convert between endianness. But this causes sparse warnings.

fireworks_command.c:269:25: warning: incorrect type in argument 1 (different base types)
fireworks_command.c:269:25:    expected unsigned int [usertype] *p
fireworks_command.c:269:25:    got restricted __be32 [usertype] *

This commit fixes this bug.

Fixes: bde8a8f23bbe('ALSA: fireworks: Add transaction and some commands')
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-19 11:57:02 +02:00
Takashi Sakamoto cbc6f28067 ALSA: dice: assign converted data to the same type of variable
In former commit, u32 data was assigned to __be32 variable instead of an
int variable. This is not enough solution because it still causes sparse
warnings.

dice.c:80:23: warning: incorrect type in assignment (different base types)
dice.c:80:23:    expected restricted __be32 [usertype] value
dice.c:80:23:    got unsigned int
dice.c:81:21: warning: restricted __be32 degrades to integer
dice.c:81:46: warning: restricted __be32 degrades to integer

This commit fixes this bug.

Fixes: 7c2d4c0cf5ba('ALSA: dice: Split transaction functionality into a file')
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-19 11:57:01 +02:00
Takashi Sakamoto 3e93d42a04 ALSA: dice: correct variable types for __be32 data
Some local variables in some functions are typed as unsigned int, while
__be32 value is assigned to them. This causes sparse warnings.

dice-stream.c:50:17: warning: incorrect type in assignment (different base types)
dice-stream.c:50:17:    expected unsigned int [unsigned] channel
dice-stream.c:50:17:    got restricted __be32 [usertype] <noident>
dice-stream.c:74:17: warning: incorrect type in assignment (different base types)
dice-stream.c:74:17:    expected unsigned int [unsigned] channel
dice-stream.c:74:17:    got restricted __be32 [usertype] <noident>

This commit fixes this bug.

Fixes: 288a8d0cb04f('ALSA: dice: Change the way to start stream')
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-19 11:57:01 +02:00
Takashi Sakamoto ad4401e53d ALSA: oxfw: remove a meaningless entry from firewire Makefile
A former commit moves oxfw-related codes to a sub-directory, while it
forgot to remove an entry from Makefile in parent directory.

Fixes: 1a4e39c2e5ca('ALSA: oxfw: Move to its own directory')
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-18 09:10:11 +02:00
Takashi Sakamoto df4833886f ALSA: fireworks/bebob/oxfw/dice: enable to make as built-in
When committed to upstream, these four modules had wrong entries for
Makefile. This forces them to be loadable modules even if they're set
as built-in.

This commit fixes this bug.

Fixes: b5b04336015e('ALSA: fireworks: Add skelton for Fireworks based devices')
Fixes: fd6f4b0dc167('ALSA: bebob: Add skelton for BeBoB based devices')
Fixes: 1a4e39c2e5ca('ALSA: oxfw: Move to its own directory')
Fixes: 14ff6a094815('ALSA: dice: Move file to its own directory')
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-18 09:08:11 +02:00
Dan Carpenter 724097059a ALSA: firewire-tascam: off by one in handle_midi_tx()
My static checker complains because tscm->spec->midi_capture_ports is
either 2 or 4 but the tscm->tx_midi_substreams[] array has 4 elements so
this is possibly off by one.  I have looked at the code and I think it
should be >= instead of > as well.

Fixes: 107cc0129a ('ALSA: firewire-tascam: add support for incoming MIDI messages by asynchronous transaction')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-17 12:06:28 +02:00
Dan Carpenter 69ec98d7e5 ALSA: firewire-tascam: fix an LED bug
We recently tried to add some new code to support turning the LED on and
off but the code in snd_tscm_transaction_reregister() is unreachable.

Fixes: e65e2cb99e ('ALSA: firewire-tascam: Turn on/off FireWire LED')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-17 12:04:16 +02:00
Takashi Sakamoto 53b3ffee78 ALSA: firewire-tascam: change device probing processing
Currently, this driver picks up model name with be32_to_cpu() macro
to align characters. This is wrong operation because the result is
different depending on CPU endiannness.

Additionally, vendor released several versions of firmware for this
series. It's not better to assign model-dependent information to
device entry according to the version field.

This commit fixes these bugs. The name of model is picked up correctly
and used to identify model-dependent information.

Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
Fixes: c0949b2785 ('ALSA: firewire-tascam: add skeleton for TASCAM FireWire series')
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-12 14:17:02 +02:00
Takashi Sakamoto e65e2cb99e ALSA: firewire-tascam: Turn on/off FireWire LED
TASCAM FireWire series has some LEDs on its surface. These LEDs can be
turned on/off by receiving asynchronous transactions to a certain
address. One of the LEDs is labels as 'FireWire'. It's better to light it
up when this driver starts to work. Besides, the LED for 'FireWire' is
turned off at bus reset.

This commit implements this idea.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-12 14:16:19 +02:00
Takashi Sakamoto 0db18e7eec ALSA: firewire-tascam: add support for MIDI functionality
In former commits, this driver got functionalities to transfer/receive
MIDI messages to/from TASCAM FireWire series.

This commit adds some ALSA MIDI ports to enable userspace applications
to use the functionalities.

I note that this commit doesn't support virtual MIDI ports which console
models support. A physical controls can be assigned to a certain MIDI
ports including physical and virtual. But the way is not clear.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-12 14:16:18 +02:00
Takashi Sakamoto 3beab0f844 ALSA: firewire-tascam: add support for outgoing MIDI messages by asynchronous transaction
TASCAM FireWire series use asynchronous transaction to receive MIDI
messages. The transaction should be sent to a certain address.

This commit supports the outgoing MIDI messages. The messages in the
transaction includes some quirks:
 * One MIDI message is transferred in one quadlet transaction, except for
   system exclusives.
 * MIDI running status is not allowed, thus transactions always include
   status byte.
 * The basic data format is the same as transferring MIDI messages
   supported in previous commit.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-12 14:16:18 +02:00
Takashi Sakamoto 107cc0129a ALSA: firewire-tascam: add support for incoming MIDI messages by asynchronous transaction
TASCAM FireWire series use asynchronous transaction to transfer MIDI
messages. The transaction is sent to a registered address.

This commit supports the incoming MIDI messages. The messages in the
transaction include some quirks:
 * Two quadlets are used for one MIDI message and one timestamp.
 * Usually, the first byte of the first quadlet includes MIDI port and MSB
   4 bit of MIDI status. For system exclusive message, the first byte
   includes MIDI port and 0x04, or 0x07 in the end of the message.
 * The rest of the first quadlet includes MIDI bytes up to 3.
 * Several set of MIDI messages and timestamp can be transferred in one
   block transaction, up to 8 sets.

I note that TASCAM FireWire series ignores ID bytes of system exclusive
message. When receiving system exclusive messages with ID bytes on physical
MIDI bus, the series transfers the messages without ID bytes on IEEE 1394
bus, and vice versa.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-12 14:16:17 +02:00
Takashi Sakamoto e8bd577ae6 ALSA: firewire-digi00x: add support for MIDI ports for physical controls
In former commits, asynchronous transactions are supported for physical
controls. This commit adds a pair of MIDI ports for them.

This driver already adds diferrent number of ALSA MIDI ports for physical
MIDI ports, and the number of in/out ports are different. As seeing as
'amidi' program in alsa-utils package, a pair of in/out MIDI ports is
expected with the same name. Therefore, this commit adds a pair of new
ports to the first.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-11 18:26:21 +02:00
Takashi Sakamoto b47f525f76 ALSA: firewire-digi00x: add support of asynchronous transaction for outgoing MIDI messages to physical controls
In previous commit, asynchronous transaction for incoming MIDI messages
from physical controls is supported. The physical controls may be
controlled by receiving MIDI messages at a certain address.

This commit supports asynchronous transaction for this purpose.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-11 18:26:14 +02:00
Takashi Sakamoto 3646a54acd ALSA: firewire-digi00x: add support of asynchronous transaction for incoming MIDI messages from physical controls
Digi 00x series has two types of model; rack and console. The console
models have physical controls. The model can transmit control messages.
These control messages are transferred by asynchronous transactions to
registered address.

This commit supports the asynchronous transaction.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-11 18:26:09 +02:00
Takashi Sakamoto 9fbfd38b20 ALSA: firewire-digi00x: add support for MIDI ports corresponding to isochronous packet streaming
This commit adds MIDI functionality to capture/playback MIDI messages
from/to physical MIDI ports. These messages are transferred in isochronous
packets.

When no substreams request AMDTP streams to run, this driver starts the
streams at current sampling rate. When other substreams start at different
sampling rate, the streams are stopped temporarily, then start again at
requested sampling rate. This operation can generate missing MIDI bytes,
thus it's preferable to start PCM substreams at favorite sampling rate in
advance.

Digi 002/003 console also has a set of MIDI port for physical controls.
These ports are added in later commits.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-11 18:26:04 +02:00
Takashi Sakamoto 9dc5d31cdc ALSA: firewire-digi00x: handle MIDI messages in isochronous packets
In Digi 002/003 protocol, MIDI messages are transferred in the last data
channel of data blocks. Although this data channel has a label of 0x80,
it's not fully MIDI conformant data channel especially because the Counter
field always zero independently of included MIDI bytes. The 4th byte of
the data channel in LSB tells the number of included MIDI bytes. This byte
also includes the number of MIDI port. Therefore, the data format in this
data channel is:
 * 1st: 0x80 as label
 * 2nd: MIDI bytes
 * 3rd: 0 or MIDI bytes
 * 4th: the number of MIDI byte and the number of MIDI port

This commit adds support of MIDI messages in data block processing layer.

Like AM824 data format, this data channel has a capability to transfer
more MIDI messages than the capability of phisical MIDI bus. Therefore, a
throttle for data rate is  required to prevent devices' internal buffer to
overflow.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-11 18:25:57 +02:00
Takashi Sakamoto 17385a386c ALSA: firewire-digi00x: use in-kernel representation for the type of 8 bits
Original code for 'DoubleOhThree' encoding was written with '__u8' type,
while the type is usually used to export something to userspace.

This commit replaces the type with 'u8'.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-11 18:25:46 +02:00
Takashi Sakamoto 2a7e1713cd ALSA: firewire-lib: continue packet processing at detecting wrong CIP headers
In firewire-lib, isochronous packet streaming is stopped when detecting
wrong value for FMT field of CIP headers. Although this is appropriate
to IEC 61883-1 and 6, some BeBoB based devices with vendors' customization
use invalid value to FMT field of CIP headers in the beginning of
streaming.

$ journalctl
  snd-bebob fw1.0: Detect unexpected protocol: 01000000 8000ffff

I got this log with M-Audio FireWire 1814. In this line, the value of FMT
field is 0x00, while it should be 0x10 in usual AMDTP.

Except for the beginning, these devices continue to transfer packets with
valid value for FMT field, except for the beginning. Therefore, in this
case, firewire-lib should continue to process packets. The former
implementation of firewire-lib performs it.

This commit loosens the handling of wrong value, to continue packet
processing in the case.

Fixes: 414ba022a5 ('ALSA: firewire-lib: add support arbitrary value for fmt/fdf fields in CIP header')
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-11 18:14:01 +02:00
Julia Lawall 6b9866c893 ALSA: bebob: constify various snd_bebob structures
The structures of type snd_bebob_clock_spec, snd_bebob_rate_spec,
snd_bebob_meter_spec, and snd_bebob_spec are never modified after they are
initialized.  Make them all const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Tested-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-11 18:12:37 +02:00
Takashi Sakamoto bde3e2880f ALSA: firewire-lib: avoid endless loop to transfer MIDI messages at fatal error
Currently, when asynchronous transactions finish in error state and
retries, work scheduling and work running also continues. This
should be canceled at fatal error because it can cause endless loop.

This commit enables to cancel transferring MIDI messages when transactions
encounter fatal errors. This is achieved by setting error state.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-09 09:57:06 +02:00
Takashi Sakamoto ea848b7b62 ALSA: firewire-lib: add throttle for MIDI data rate
Typically, the target devices have internal buffer to adjust output of
received MIDI messages for MIDI serial bus, while the capacity of the
buffer is limited. IEEE 1394 transactions can transfer more MIDI messages
than MIDI serial bus can. This can cause buffer over flow in device side.

This commit adds throttle to limit MIDI data rate by counting intervals
between two MIDI messages. Usual MIDI messages consists of two or three
bytes. This requires 1.302 to 1.953 mili-seconds interval between these
messages. This commit uses kernel monotonic time service to calculate the
time of next transaction.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-09 09:57:06 +02:00
Takashi Sakamoto e8a40d9bcb ALSA: firewire-lib: schedule work again when MIDI substream has rest of MIDI messages
Currently, when two MIDI trigger callbacks can be called immediately,
transactions for the second MIDI messages can be postpone till next trigger
callback. This is not good for real-time message transmission.

This commit schedules work again at response handling callback if the
MIDI substream still includes untransferred MIDI messages.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-09 09:57:05 +02:00
Takashi Sakamoto d3ef9cb93a ALSA: firewire-lib: add a restriction for a transaction at once
Currently, when waiting for a response, callers can start another
transaction by scheduling another work. This is not good for error
processing of transaction, especially the first response is too late.

This commit serialize request/response transactions, by adding one
boolean member to represent idling state.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-09 09:57:05 +02:00
Takashi Sakamoto 585d7cba5e ALSA: firewire-lib: add helper functions for asynchronous transactions to transfer MIDI messages
Some models receive MIDI messages via IEEE 1394 asynchronous transactions.
In this case, MIDI messages are transferred in fixed-length payload. It's
nice that firewire-lib module has common helper functions.

This commit implements this idea. Each driver adds
'struct snd_fw_async_midi_port' in its instance structure. In probing,
it should call snd_fw_async_midi_port_init() to initialize the
structure with some parameters such as target address, the length
of payload in a transaction and a pointer for callback function
to fill the payload buffer. At 'struct snd_rawmidi_ops.trigger()'
callback, it should call 'snd_fw_async_midi_port_run()' to start
transactions. Each driver should ensure that the lifetime of MIDI
substream continues till calling 'snd_fw_async_midi_port_finish()'.

The helper functions support retries to transferring MIDI messages when
transmission errors occur. When transactions are successful, the helper
functions call 'snd_rawmidi_transmit_ack()' internally to consume MIDI
bytes in the buffer. Therefore, Each driver is expected to use
'snd_rawmidi_transmit_peek()' to tell the number of bytes to transfer to
return value of 'fill' callback.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-09 09:57:04 +02:00
Takashi Sakamoto 425a570e1b ALSA: bebob: support Firewire I/O card of Mackie Onyx 1220/1620/1640
Current ALSA BeBoB drivers has an entry for this model, while the value of
vendor ID seems to be wrong according to an user's report.

The vendor had released no updated firmware, thus we can judge that this
model had not changed the content of its config ROM. It's reasonable to fix
the ID according to the report.

$ ./linux-firewire-utils/src/crpp < /sys/bus/firewire/devices/fw1/config_rom

               ROM header and bus information block
               -----------------------------------------------------------------
400  0425720f  bus_info_length 4, crc_length 37, crc 29199
404  31333934  bus_name "1394"
408  f0646122  irmc 1, cmc 1, isc 1, bmc 1, pmc 0, cyc_clk_acc 100,
               max_rec 6 (128), max_rom 1, gen 2, spd 2 (S400)
40c  00000ff2  company_id 00000f     |
410  00004697  device_id f200004697  | EUI-64 00000ff200004697

               root directory
               -----------------------------------------------------------------
414  000859be  directory_length 8, crc 22974
418  04000082  hardware version
41c  0c0083c0  node capabilities per IEEE 1394
420  03000ff2  vendor
424  8100000a  --> descriptor leaf at 44c
428  17010065  model
42c  8100000d  --> descriptor leaf at 460
430  13000910  version
434  d1000001  --> unit directory at 438

               unit directory at 438
               -----------------------------------------------------------------
438  0004ccec  directory_length 4, crc 52460
43c  1200a02d  specifier id: 1394 TA
440  13010001  version: AV/C
444  17010065  model
448  8100000d  --> descriptor leaf at 47c

               descriptor leaf at 44c
               -----------------------------------------------------------------
44c  0004152a  leaf_length 4, crc 5418
450  00000000  textual descriptor
454  00000000  minimal ASCII
458  4d61636b  "Mack"
45c  69650000  "ie"

               descriptor leaf at 460
               -----------------------------------------------------------------
460  000612b5  leaf_length 6, crc 4789
464  00000000  textual descriptor
468  00000000  minimal ASCII
46c  4f6e7978  "Onyx"
470  20466972  " Fir"
474  65776972  "ewir"
478  65000000  "e"

               descriptor leaf at 47c
               -----------------------------------------------------------------
47c  000612b5  leaf_length 6, crc 4789
480  00000000  textual descriptor
484  00000000  minimal ASCII
488  4f6e7978  "Onyx"
48c  20466972  " Fir"
490  65776972  "ewir"
494  65000000  "e"

$ cat /proc/asound/card3/firewire/firmware
Manufacturer:   bridgeCo
Protocol Ver:   1
Build Ver:      0
GUID:           0x00000FF200004697
Model ID:       0x82
Model Rev:      1
Firmware Date:  20040430
Firmware Time:  131527
Firmware ID:    0x10065
Firmware Ver:   2320
Base Addr:      0x20080000
Max Size:       1572864
Loader Date:    20040430
Loader Time:    112036

Reported-by: Andrzej Gansiniec <andrzej@gansiniec.pl>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-04 17:21:34 +02:00
Takashi Sakamoto e5e0c3dd25 ALSA: firewire-tascam: add hwdep interface
This commit adds hwdep interface so as the other IEEE 1394 sound devices
has.

This interface is designed for mixer/control applications. By using this
interface, an application can get information about firewire node, can
lock/unlock kernel streaming and can get notification at starting/stopping
kernel streaming.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-02 18:17:04 +02:00
Takashi Sakamoto e453df44f0 ALSA: firewire-tascam: add PCM functionality
This commit adds PCM functionality to transmit/receive PCM samples.

When one of PCM substreams are running or external clock source is
selected, current sampling rate is used. Else, the sampling rate is
changed as an userspace application requests.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-02 18:17:03 +02:00
Takashi Sakamoto 35efa5c489 ALSA: firewire-tascam: add streaming functionality
This commit adds streaming functionality for both direction. To utilize
the sequence of the number of data blocks in packets, full duplex with
synchronization is applied.

Besides, TASCAM FireWire series allows drivers to decide which PCM data
channels are enabled. For convenience, this driver always enable whole the
data channels.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-02 18:17:02 +02:00
Takashi Sakamoto 47faeea25e ALSA: firewire-tascam: add data block processing layer
TASCAM FireWire series uses non-blocking transmission for AMDTP packet
streaming, while the format of data blocks is unique.

The CIP headers includes specific value in FMT field and no SYT
information.

In transmitted packets, the first data channel represents event counter,
and the last data channel has status and control information. The rest
has 24bit PCM samples with right padding.

In received packets, all of data channels include 16, 24, 32bit PCM
samples. There's no other kind of information.

This commit adds support for this protocol. For convenience, the size of
PCM samples in outgoing packet is limited by 16 and 24bit. The status and
control information will be supported in future commits.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-02 18:17:01 +02:00
Takashi Sakamoto 96e5fbb0dd ALSA: firewire-tascam: add proc node to show firmware information
TASCAM FireWire series has certain registers for firmware information.

This commit adds proc node to show the information.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-02 18:17:01 +02:00
Takashi Sakamoto 6f81ba19ac ALSA: firewire-tascam: add a structure for model-dependent parameters.
TASCAM FireWire series doesn't tell drivers their capabilities, thus
the drivers should have model-dependent parameters and apply it to
detected devices.

This commit adds a structure to represent such parameters.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-02 18:17:00 +02:00
Takashi Sakamoto c0949b2785 ALSA: firewire-tascam: add skeleton for TASCAM FireWire series
This commit adds a new driver for TASCAM FireWire series. In this commit,
this driver just creates/removes card instance according to bus event.
More functionalities will be added in following commits.

TASCAM FireWire series consists of:
 * PDI 1394P23 for IEEE 1394 PHY layer
 * PDI 1394L40 for IEEE 1394 LINK layer and IEC 61883 interface
 * XILINX XC9536XL
 * XILINX Spartan-II XC2S100
 * ATMEL AT91M42800A

Ilya Zimnovich had investigated TASCAM FireWire series in 2011, and
discover some features of his FW-1804. You can see a part of his research
in FFADO project.
http://subversion.ffado.org/wiki/Tascam

A part of my work are based on Ilya's investigation, while this series
doesn't support the FW-1804, because of a lack of config ROM
information and its protocol detail, especially for PCM channels.

I observed that FW-1884 and FW-1082 don't work properly with 1394 OHCI
controller based on VT6315. The controller can actually communicate packets
to these models, while these models generate no sounds. It may be due to
the PHY/LINK layer issues. Using 1394 OHCI controller produced by the other
vendors such as Texas Instruments may work. Or adding another node on the
bus.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-10-02 18:16:59 +02:00
Takashi Sakamoto 44b7308871 ALSA: firewire-digi00x: add support for asynchronous messaging
Digi 002/003 family uses asynchronous transaction for messaging.
The address to transmit this message is stored on a certain register.

This commit allocates a range of address on OHCI 1394 host controller
to handle the messaging. As long as I know, the purpose of this message
seems to notify lost of synchronization. While, the meaning of content
of the message is not clear.

Actual examples of this messaging:
 * When clock source is set as internal:
 - 0x00007051
 - 0x00007052
 - 0x00007054
 - 0x00007057
 - 0x00007058
 * When clock source is set as somewhat external:
 - 0x00009000
 - 0x00009010
 - 0x00009020
 - 0x00009021
 - 0x00009022

The lost often occurs when using internal clock source. In this case,
users hear sounds with quite short gap every several minutes. In fact,
the lost is recovered temporarily.

When using with external clock source, the lost seems not to occur. The
mechanism is not clear yet.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-09-30 15:37:55 +02:00
Takashi Sakamoto 660dd3d52e ALSA: firewire-digi00x: add hwdep interface
This commit adds hwdep interface so as the other sound drivers for units
on IEEE 1394 bus have.

This interface is designed for mixer/control applications. By using this
interface, an application can get information about firewire node, can
lock/unlock kernel streaming and can get notification at starting/stopping
kernel streaming.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-09-30 15:36:56 +02:00
Takashi Sakamoto 0120d0f1fe ALSA: firewire-digi00x: add PCM functionality
This commit adds PCM functionality to transmit/receive PCM samples.

Any PCM substreams are jointed because incoming/outgoing AMDTP streams
are bound. When one of PCM substream is running or external clock source
is selected, current sampling rate is used. Else, the sampling rate is
changed as an userspace application requests.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-09-30 15:36:40 +02:00
Takashi Sakamoto 927f17dc3a ALSA: firewire-digi00x: add proc node to show clock status
This commit adds proc node to show current clock status for debugging.

As long as testing Digi 002 rack, registers can show local clock rate,
local clock source. When external clock input such as S/PDIF is
connected, the registers show the detection and external clock rate.

Additionally, the registers show the mode of optical digital input
interface. Although, a tester with Digi 003 rack reports this makes no
sense. Further investigation is required for Digi 003 series.

Besides, in Digi 002 rack, the S/PDIF format must be IEC 60958-4,
so-called professional.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-09-30 15:35:31 +02:00
Takashi Sakamoto 3a2a17974e ALSA: firewire-digi00x: add stream functionality
This commit adds a functionality to manage streaming.

The streaming is not controlled by CMP in IEC 61883-6. It's controlled by
IEEE 1394 write transaction to certain addresses.

Several clock sources are available, while there're no differences about
packet transmission. The value of SYT field in transmitted packets is
always zero. Thus, streams in both direction don't build synchronization.

And the device always requires received packets to transmit packets. This
driver keeps to transfer outgoing stream even if they're not required.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-09-30 15:34:55 +02:00
Takashi Sakamoto 163ae6f3f3 ALSA: firewire-digi00x: add data block processing layer
Digi 002/003 family uses its own format for data blocks. The format is
quite similar to AM824 in IEC 61883-6, while there're some differences:

 * The Valid Bit Length (VBL) code is always 0x40 in Multi-bit Linear Audio
   (MBLA) data channel.
 * The first data channel includes MIDI messages, against IEC 61883-6
   recommendation.
 * The Counter field is always zero in MIDI conformant data channel.
 * Sequence multiplexing in IEC 61883-6 is not applied to the MIDI
   conformant data channel.
 * PCM samples are scrambled in received AMDTP packets. We call the way
   as Double-Oh-Three (DOT). The algorithm was discovered by
   Robin Gareus and Damien Zammit in 2012.

This commit adds data processing layer to satisfy these differences.

There's a quirk about transmission mode for received packets. When this
driver applies non-blocking mode to outgoing packets with isochronous
channel 2 or more, after 15 to 20 seconds since playbacking, any PCM
samples causes noisy sound on the device. With isochronous channel 0 or 1,
this doesn't occur. As long as I investigated, this quirk is not observed
when applying blocking mode to the received packets.

This driver applies blocking mode to outgoing packets, while non-blocking
mode to incoming packgets.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-09-30 15:34:25 +02:00
Takashi Sakamoto 9edf723fd8 ALSA: firewire-digi00x: add skeleton for Digi 002/003 family
This commit adds a new driver for Digidesign 002/003 family. This commit
just creates/removes card instance according to bus event. More functions
will be added in following commits.

Digidesign 002/003 family consists of:
 * Agere FW802B for IEEE 1394 PHY layer
 * PDI 1394L40 for IEEE 1394 LINK layer and IEC 61883 interface
 * ALTERA ACEX EP1K50 for IEC 61883 layer and DSP controller
 * ADSP-21065L for signal processing

[minor cleanup using skip_spaces() by tiwai]

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-09-30 15:33:50 +02:00
kbuild test robot 02e6ef9fba ALSA: firewire-lib: process_rx_data_blocks() can be static
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-09-29 16:52:52 +02:00
Takashi Iwai d8dfacf8b5 Merge branch 'topic/firewire-update' into for-next 2015-09-29 12:52:07 +02:00
Takashi Sakamoto df075feefb ALSA: firewire-lib: complete AM824 data block processing layer
This commit moves the codes related to data block processing from packet
streaming layer to AM824 layer.

Each driver initializes amdtp stream structure for AM824 data block by
calling amdtp_am824_init(). Then, a memory block is allocated for AM824
specific structure. This memory block is released by calling
amdtp_stream_destroy().

When setting streaming parameters, it calls amdtp_am824_set_parameters().
When starting packet streaming, it calls amdtp_stream_start(). When
stopping packet streaming, it calls amdtp_stream_stop().

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-09-29 12:51:20 +02:00
Takashi Sakamoto 49c7b3fcd9 ALSA: firewire-lib: rename macros with AM824 prefix
This commit renames some macros just related to AM824 format. In later
commit, they're moved to AM824 layer.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-09-29 12:50:23 +02:00
Takashi Sakamoto 85130cb43e ALSA: firewire-lib: rename PCM format helper function
Setting the format of PCM substream to AMDTP stream structure is important
to set a handler to copy actual PCM samples between buffers. The
processing should be in data block processing layer because essentially
it has no relationship to packet streaming.

This commit renames PCM format setting function to prepare for integrating
AM824 layer.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-09-29 12:49:04 +02:00
Takashi Sakamoto 03e2a67eed ALSA: firewire-lib: move MIDI trigger helper function to AM824 layer
In IEC 61883-6, MIDI messages are transferred in MIDI conformant data
channel. Essentially, packet streaming layer is not responsible for MIDI
functionality.

This commit moves MIDI trigger helper function from the layer to AM824
layer. The rest of codes related to MIDI functionality will be moved in
later commits.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-09-29 12:48:49 +02:00
Takashi Sakamoto f65be911c0 ALSA: firewire-lib: add helper functions to set positions of data channels
In IEC 61883-6, several types of data are available in AM824 format. The
data is transferred in each data channel. The position of data channel in
data block differs depending on model.

Current implementation has an array to map the index of data channel in an
data block to the position of actual data channel. The implementation
allows each driver to access the mapping directly.

In later commit, the mapping is in specific structure pushed into an
opaque pointer. Helper functions are required.

This commit adds the helper functions for this purpose. In IEC 61883-6,
AM824 format supports many data types, while this specification easily
causes over-engineering. Current AM824 implementation is allowed to handle
two types of data, Multi Bit Linear Audio data (=PCM samples) and MIDI
conformant data (=MIDI messages).

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-09-29 12:48:36 +02:00
Takashi Sakamoto bc8500da3e ALSA: firewire-lib: move PCM substream constraint to AM824 layer
In IEC 61883-6, PCM frames are transferred in Multi Bit Linear Audio data
channel. The data channel transfers 16/20/24 bit PCM samples. Thus, PCM
substream has a constrain about it.

This commit moves codes related to the constraint from packet streaming
layer to AM824 data block processing layer.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-09-29 12:48:19 +02:00
Takashi Sakamoto 51c29fd213 ALSA: firewire-lib: rename parameter setting function for AM824 with FDF field
The value of FDF field in CIP header is protocol-dependent. Thus, it's
better to allow data block processing layer to decide the value in any
timing.

In AM824 data format, the value of FDF field in CIP header indicates
N-flag and Nominal Sampling Frequency Code (sfc). The N-flag is for
switching 'Clock-based rate control mode' and 'Command-based rate control
mode'. In our implementation, 'Clock-based rate control mode' is just
supported. Therefore, When sampling transfer frequency is decided, then
the FDF can be set.

This commit replaces 'amdtp_stream_set_parameters' with
'amdtp_am824_set_parameters' to set the FDF. This is the same timing
to decide the ration between the number of data blocks and the number of
PCM frames.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-09-29 12:48:02 +02:00
Takashi Sakamoto 5955815e71 ALSA: firewire-lib: add data block processing layer for AM824 format
This commit adds data block processing layer for AM824 format. The new
layer initializes streaming layer with its value for fmt field.

Currently, most implementation of data block processing still remains
streaming layer. In later commits, these codes will be moved to the layer.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-09-29 12:47:45 +02:00
Takashi Sakamoto d67c46b953 ALSA: firewire-lib: rename 'amdtp' to 'amdtp-stream' to prepare for functional separation
In later commit, data block processing layer will be newly added. This
layer will be named as 'amdtp-am824'.

This commit renames current amdtp file to amdtp-stream, to distinguish it
from the new layer.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-09-29 12:47:11 +02:00
Takashi Sakamoto 414ba022a5 ALSA: firewire-lib: add support arbitrary value for fmt/fdf fields in CIP header
Some vendor specific protocol uses its own value for fmt/fdf fields in
CIP header.

This commit support to set arbitrary values for the fields.

In IEC 61883-6, NO-DATA code is defined for FDF field. A packet with this
code includes no data even if it includes some data blocks. This commit
still leaves a condition to handle this special packet.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-09-29 12:35:48 +02:00
Takashi Sakamoto 20e445771e ALSA: firewire-lib: add helper functions as interfaces between packet streaming layer and data block processing layer
ALSA PCM framework uses PCM buffer with a concept of 'period' to
synchronize userspace operations to hardware for nearly-realtime
processing. Each driver implements snd_pcm_period_elapsed() to tell across
of the period boundary to ALSA PCM middleware. To call the function, some
drivers utilize hardware interrupt handlers, the others count handled PCM
frames.

Drivers for sound units on IEEE 1394 bus are the latter. They use two
buffers; PCM buffer and DMA buffer for IEEE 1394 isochronous packet. PCM
frames are copied between these two buffers and 'amdtp_stream' structure
counts the handled PCM frames. Then, snd_pcm_period_elapsed() is called if
required.

Essentially, packet streaming layer should not be responsible for PCM
frame processing. The PCM frame processing should be handled in each data
block processing layer as a result of handling data blocks. Although, PCM
frame counting is a common work for all of protocols which ALSA firewire
stack is going to support.

This commit adds two new helper functions as interfaces between packet
streaming layer to data block processing layer. In future, each data block
processing layer implements these functions. The packet streaming layer
calls data block processing layer per packet by calling the functions. The
data block processing layer processes data blocks and PCM frames, and
returns the number of processed PCM frames. Then the packet streaming layer
calculates handled PCM frames and calls snd_pcm_period_elapsed().

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-09-29 12:35:47 +02:00
Takashi Sakamoto 6a4e89ff0f ALSA: firewire-lib: add a member of frame_multiplier instead of double_pcm_frames
In future commit, interface between data block processing layer and packet
stream processing layer is defined. These two layers communicate the
number of data blocks and the number of PCM frames.

The data block processing layer has a responsibility for calculating the
number of PCM frames. Therefore, 'dual wire' of Dice quirk should be
handled in data block processing layer.

This commit adds a member of 'frame_multiplier'. This member represents
the ratio of the number of PCM frames against the number of data blocks.
Usually, the value of this member is 1, while it's 2 in Dice's 'dual wire'.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-09-29 12:35:46 +02:00
Takashi Sakamoto 27ec83b5c6 ALSA: firewire-lib: add an argument for Dice's dual wire mode
In IEC 61883-6, one data block represents one event. In ALSA, the event is
one PCM frame. Therefore, when processing one data block, current
implementation counts one PCM frame.

On the other hand, Dice platform has a quirk called as 'dual wire' at
higher sampling rate. In detail, see comment of commit 6eb6c81eee
("ALSA: dice: Split stream functionality into a file").

Currently, to handle this quirk, AMDTP stream structure has a
'double_pcm_frames' member. When this is enabled, two PCM frames are
counted. Each driver set this flag by accessing the structure member
directly.

In future commit, some members related to AM824 data block will be moved
to specific structure, to separate packet streaming layer and data block
processing layer. The access will be limited by opaque pointer.

For this reason, this commit adds an argument into
amdtp_stream_set_parameter() to set the flag.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-09-29 12:35:46 +02:00
Takashi Sakamoto 547e631ce3 ALSA: firewire-lib: return error code when amdtp_stream_set_parameters() detects error
Currently, amdtp_stream_set_parameters() returns no error even if wrong
arguments are given. This is not good for streaming layer because drivers
can continue processing ignoring capability of streaming layer.

This commit changes this function to return error code.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-09-29 12:35:45 +02:00
Takashi Sakamoto 10b2b6dc1a ALSA: firewire-lib: arrange structure for AMDTP stream
In later commit, some members related to AM824 data format will be moved
from AMDTP stream structure to data block structure. This commit is a
preparation for it. Additionally, current layout of AMDTP stream structure
is a bit mess by several extensions. This commit also arranges the layout.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-09-29 12:35:44 +02:00
Takashi Sakamoto 13f3a46d2a ALSA: oxfw: add Mackie Onyx Satellite quirk to inform wrong value in 'dbs' field in tx CIP header
Mackie Onyx Satellite has two usage; standalone and with base station.

These two modes has different stream formats. In standalone mode, rx data
block includes 2 Multi Bit Linear Audio (MBLA) data channels and tx data
block includes 2. With base station, they're 6 and 2.

Although, with base station, the actual tx packet include wrong value in
'dbs' field in its CIP header. This quirk causes packet streaming layer to
detect packet discontinuity and to stop PCM substream.

This is a response of 'single' subfunction 'extended stream format
information' command in AV/C Stream Format Information Specification 1.1.
It means that a data block in tx packets includes 2 MBLA data channels.

$ ./firewire-request /dev/fw1 fcp 0x01ffbfc001000000ffffffff
response: 000: 0c ff bf c0 01 00 00 00 ff 00 90 40 03 02 01 02
response: 010: 06

Current OXFW driver parses the response and detects stream formats
correctly.

$ cat /proc/asound/card1/firewire/formation
...
Output Stream from device:
	Rate	PCM	MIDI
* 	48000	2	0
 	44100	2	0
 	88200	2	0
	96000	2	0

On the other hand, in actual tx CIP, the 'dbs' field has 6. But the number
of quadlets in CIP payload is not multiple of 6. Seeing the subtraction of
two successive payload quadlets, it should be multiple of 2.

payload  CIP      CIP
quadlets header0  header1
      24 00060052 9002ffff
      24 0006005e 9002ffff
      26 0006006a 9002ffff
      24 00060077 9002ffff
      24 00060083 9002ffff
      26 0006008f 9002ffff
      24 0006009c 9002ffff
      24 000600a8 9002ffff
      26 000600b4 9002ffff
      24 000600c1 9002ffff

This commit adds support for this quirk to OXFW driver, by using
CIP_WRONG_DBS flag. When this flag is set, packet streaming layer uses
the value of its 'data_block_quadlets' member instead of the value in CIP
header. This value is already set by OXFW driver and no discontinuity is
detected.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-09-24 11:44:25 +02:00
Takashi Sakamoto 22c103cd3d ALSA: fireworks/bebob/dice/oxfw: fix substreams counting at vmalloc failure
In PCM core, when hw_params() in each driver returns error, the state of
PCM substream is kept as 'open'. In this case, current drivers for sound
units on IEEE 1394 bus doesn't decrement substream counter in hw_free()
correctly. This causes these drivers to keep streams even if not
required.

This commit fixes this bug. When snd_pcm_lib_alloc_vmalloc_buffer()
fails, hw_params function in each driver returns without incrementing the
counter.

Reported-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Acked-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-08-29 09:14:41 +02:00
Takashi Iwai 41450b1b5b Merge branch 'for-linus' into for-next 2015-08-11 09:40:16 +02:00
Andrzej Hajda 96bab82f6b ALSA: firewire: use kmemdup rather than duplicating its implementation
The patch was generated using fixed coccinelle semantic patch
scripts/coccinelle/api/memdup.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2014320

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-08-07 14:52:07 +02:00
Takashi Sakamoto 18f5ed365d ALSA: fireworks/firewire-lib: add support for recent firmware quirk
Fireworks uses TSB43CB43(IceLynx-Micro) as its IEC 61883-1/6 interface.
This chip includes ARM7 core, and loads and runs program. The firmware
is stored in on-board memory and loaded every powering-on from it.

Echo Audio ships several versions of firmwares for each model. These
firmwares have each quirk and the quirk changes a sequence of packets.

As long as I investigated, AudioFire2/AudioFire4/AudioFirePre8 have a
quirk to transfer a first packet with 0x02 in its dbc field. This causes
ALSA Fireworks driver to detect discontinuity. In this case, firmware
version 5.7.0, 5.7.3 and 5.8.0 are used.

Payload  CIP      CIP
quadlets header1  header2
02       00050002 90ffffff <-
42       0005000a 90013000
42       00050012 90014400
42       0005001a 90015800
02       0005001a 90ffffff
42       00050022 90019000
42       0005002a 9001a400
42       00050032 9001b800
02       00050032 90ffffff
42       0005003a 9001d000
42       00050042 9001e400
42       0005004a 9001f800
02       0005004a 90ffffff
(AudioFire2 with firmware version 5.7.)

$ dmesg
snd-fireworks fw1.0: Detect discontinuity of CIP: 00 02

These models, AudioFire8 (since Jul 2009 ) and Gibson Robot Interface
Pack series uses the same ARM binary as their firmware. Thus, this
quirk may be observed among them.

This commit adds a new member for AMDTP structure. This member represents
the value of dbc field in a first AMDTP packet. Drivers can set it with
a preferred value according to model's quirk.

Tested-by: Johannes Oertei <johannes.oertel@uni-due.de>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-08-05 07:52:39 +02:00
Takashi Sakamoto c85523d1d9 Revert "ALSA: fireworks: add support for AudioFire2 quirk"
This reverts commit 9c6893e0be.

The fix is superseded by the next commit as a better implementation
for supporting AudioFire2/AudioFire4/AudioFirePre8 quirks.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-08-05 07:51:53 +02:00
Takashi Sakamoto 9c6893e0be ALSA: fireworks: add support for AudioFire2 quirk
Fireworks uses TSB43CB43(IceLynx-Micro) as its IEC 61883-1/6 interface.
This chip includes ARM7 core, and loads and runs program. The firmware
is stored in on-board memory and loaded every powering-on.

Echo Audio ships several versions of firmwares for each model. These
firmwares have each quirk and the quirk changes a sequence of packets.

AudioFire2 has a quirk to transfer a first packet with non-zero in
its dbc field. This causes ALSA Fireworks driver to detect discontinuity.
As long as I investigated, firmware 5.7, 5.7.6 and 5.8 have this quirk.

This commit adds a support for the quirk to handle AudioFire2 packets.
For safe, CIP_SKIP_INIT_DBC_CHECK is applied to all versions of
AudioFire2's firmwares.

02 00050002 90ffffff <-
42 0005000a 90013000
42 00050012 90014400
42 0005001a 90015800
02 0005001a 90ffffff
42 00050022 90019000
42 0005002a 9001a400
42 00050032 9001b800
02 00050032 90ffffff
42 0005003a 9001d000
42 00050042 9001e400
42 0005004a 9001f800
02 0005004a 90ffffff

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-07-27 10:12:25 +02:00
Takashi Sakamoto cf8a471909 ALSA: bebob: add support for Behringer FCA 610/1616
They're based on DM1500 (ArchWave produced), and BeBoB version 3 is
installed.

$ cat /proc/asound/FCA610/firewire/firmware
Manufacturer:	bridgeCo
Protocol Ver:	3
Build Ver:		0
GUID:		0x001564000002AD73
Model ID:		0x03
Model Rev:		0
Firmware Date:	20121102
Firmware Time:	153431
Firmware ID:	0x610
Firmware Ver:	8348
Base Addr:		0x400C0080
Max Size:		1422624
Loader Date:	20121015
Loader Time:	104710

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-06-15 13:38:47 +02:00
Takashi Sakamoto 8d1c2694e4 ALSA: bebob: keep duplex streams always to keep internal multiplexer properly
Behringer FCA610 transmits packets with periodic noisy PCM samples
when receiving no streams, and generates a bit noisy sound.

ALSA BeBoB driver is programmed to establish both in/out connections
when starting streaming, then transfers packets as userspace applications
requested. This means that there's a case that one of incoming/outgoing
streams is running, to save CPU and bandwidth usage. Although, it's natural
to start transferring packets in both direction.

This commit makes this driver to keeps duplex streams always.

Tested-by: Kim Tore Jensen <kim@incendio.no>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-06-15 13:38:29 +02:00
Takashi Sakamoto c4d860a0d2 ALSA: bebob: loosen up severity of checking continuity for BeBoB v3 quirk
PrismSound Orpheus, Behringer UFX1604 and FCA610 work with BeBoB v3, and
they're confirmed to transmit discontinuous packets in the beginning of
streaming.

payload    CIP headers
  8        0x00070000 0x9002FFFF
  8        0x00070000 0x9002FFFF
  8        0x00070000 0x9002FFFF
  8        0x00070008 0x9002FFFF <-
  8        0x00070008 0x9002FFFF
  8        0x00070008 0x9002FFFF
  8        0x00070008 0x9002FFFF
  8        0x00070008 0x9002FFFF
  8        0x00070008 0x9002FFFF
232        0x00070000 0x9002E798 <-
232        0x00070008 0x9002FB99
232        0x00070010 0x90021398
  8        0x00070018 0x9002FFFF
(This sample was got with Behringer FCA610 and FFADO library.)

This commit sets CIP_EMPTY_HAS_WRONG_DBC and CIP_SKIP_DBC_ZERO_CHECK to
ignore these discontinuities.

Tested-by: Kim Tore Jensen <kim@incendio.no>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-06-15 13:38:14 +02:00
Takashi Sakamoto 9a73195e61 ALSA: bebob: expand timeout for DM1500 quirk
Behringer FCA610 and UFX1604 is confirmed to require more time till
transmitting packets after establishing connections. This seems to
be a quirk of DM1500 ASIC which ArchWave produced.

For this quirk, this commit extends the time to wait up to 2 seconds.
As a result, in worst cases, below userspace functions require 2 seconds
to return.
 - snd_pcm_prepare()
 - snd_pcm_hw_params()
 - snd_pcm_recover()

Tested-by: Kim Tore Jensen <kim@incendio.no>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-06-15 13:38:00 +02:00
Takashi Sakamoto 7b4d7dcfa8 ALSA: bebob: add 'version' member for BeBoB protocol version
BeBoB installed devices have BeBoB register area. This area stores
basic information about its firmware. A register has its protocol
version.

This commit adds 'version' member and store the device's protocol
version to handle v3 quirks in following commits.

Tested-by: Kim Tore Jensen <kim@incendio.no>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-06-15 13:37:26 +02:00
Takashi Sakamoto 0577379271 ALSA: bebob: add SYT-Match support
In previous commits, this driver can detect the source of clock as mush
as possible. SYT-Match mode is also available.

This commit purge the restriction.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-06-15 13:37:07 +02:00
Takashi Sakamoto 554d8983a0 ALSA: bebob: obsolete string literal expression for clock source
The old string literals were completely replaced by new normalized
representation.

This commit obsoletes it.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-06-15 13:36:44 +02:00
Takashi Sakamoto 3e254b16b6 ALSA: bebob: use normalized representation for the type of clock source
This commit changes function prototype and its processing. As a result,
function caller can execute additional processing according to detected
clock source.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-06-15 13:36:00 +02:00
Takashi Sakamoto ba5177131d ALSA: bebob: preparation for replacing string literals by normalized representation for model-dependent structures
Previous commit adds a enumerator as a normalized representation of
clock source, while model-dependent structures still use string literals
for this purpose.

This commit is a preparation for replacement.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-06-15 13:34:47 +02:00
Takashi Sakamoto 13a4f42016 ALSA: bebob: apply new enumerator to normalize the type of clock source
Previous commit allows this driver to detect several types of clock
source, while there's no normalized expression for it.

This commit adds a new enumerator for this purpose.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-06-15 13:34:29 +02:00
Takashi Sakamoto 5a66881270 ALSA: bebob: improve signal mode detection for clock source
With BeBoB version 3, current ALSA BeBoB driver detects the type of
current clock signal source wrongly. This is due to a lack of proper
implementation to parse the information.

This commit renews the parser. As a result, this driver detects
SYT-Match clock signal, thus it can start streams with two modes;
SYT-Match mode and the others. SYT-Match mode will be supported in future
commits.

There's a constrain about detected internal/external clock source.
When detecting external clock source, this driver allows userspace
applications to use current sampling rate only. This is due to consider
abour synchronization to external clock sources such as S/PDIF, ADAT or
word-clock.

According to several information from some devices, I guesss that the
internal clock of most devices synchronize to IEEE 1394 cycle start
packet. In this case, by a usual way, it's detect as 'Sync type
of output Music Sub-Unit' connected to 'Sync type of PCR output Unit
(oPCR)', and this driver judges it as internal clock. Therefore,
userspace applications is allowed to request arbitrary supported sampling
rates.

On the other hand, several devices based on BeBoB version 3 have
additional internal clock. In this case, by a usual way, it's detect as
'Sync/Additional type of External input Unit'. Unfortunately, there's no
way to distinguish this sync type from the other external clock sources
such as word-clock. In this case, this driver handles it as external and
userspace applications is forced to use current sampling rate.

I note that when the source of clock is detected as 'Isochronous stream
type of input PCR[0]', it's under 'SYT-Match' mode. In this mode, the
synchronization clock is generated according to SYT-series in received
packets. In this case, this driver generates the series by myself. I
experienced this mode often make the device silent suddenly during
playbacking. This means that the mode is easy to lost synchronization.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-06-15 13:34:13 +02:00
Takashi Sakamoto 31ea49baa1 ALSA: firewire-lib: fix buffer-over-run when detecting packet discontinuity
When detecting packet discontinuity, handle_in_packet() returns minus value
and this value is assigned to unsigned int variable, then the variable has
huge value. As a result, the variable causes buffer-over-run in
handle_out_packet(). This brings invalid page request and system hangup.

This commit fixes the bug to add a new argument into handle_in_packet()
and the number of handled data blocks is assignd to it. The function
return value is just used to check error.

I also considered to change the type of local variable to 'int' in
in_stream_callback(). This idea is based on type-conversion in C standard,
while it may cause future problems when adding more works. Thus, I dropped
this idea.

Fixes: 6fc6b9ce41c6('ALSA: firewire-lib: pass the number of data blocks in incoming packets to outgoing packets')
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-05-27 17:44:42 +02:00
Takashi Sakamoto 146a5e3c1e ALSA: bebob: add Digidesign Mbox 2 Pro support
This device is based on DM1000E, and BeBoB version 1 firmware is
installed.

$ cat /proc/asound/cards
 0 [Pro            ]: BeBoB - Mbox 2 Pro
                      DIGIDESIGN Mbox 2 Pro (id:1, rev:1),
		      GUID 00a07e0100a90000 at fw1.0, S400

$ cat /proc/asound/Pro/firewire/firmware
Manufacturer:	bridgeCo
Protocol Ver:	1
Build Ver:		0
GUID:		0x00A07E0100A90000
Model ID:		0x01
Model Rev:		1
Firmware Date:	20071031
Firmware Time:	034402
Firmware ID:	0xA9
Firmware Ver:	16777215
Base Addr:		0x20080000
Max Size:		1572864
Loader Date:	20051207
Loader Time:	205554

With this patch, ALSA BeBoB driver can start packet streaming to/from
this model, while as a default, internal multiplexer of this model is
not initialized and generates no sound even if the driver transfers
any packets with PCM samples. To hear any sounds from this model,
userspace applications should be developed to set parameters to the
internal multiplexer. You can see raw information in FFADO website:
http://subversion.ffado.org/wiki/AvcModels/DigiDesignMboxPro2

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-05-24 17:31:11 +02:00
Takashi Sakamoto a900705491 ALSA: firewire-lib: use protocol error when detecting wrong value in CIP header
When detecting zero in 'dbs' field of CIP header, this packet streaming
should be aborted because of avoiding division-by-zero. This is an error
in an aspect of IEC 61883-1, thus protocol error.

This commit use EPROTO instead of EIO. Actually, the returned value is
not used for userspace and this commit has no effect.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Acked-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-05-24 08:23:58 +02:00
Takashi Sakamoto 12e0f438d3 ALSA: firewire-lib: use dev_err() when detecting incoming streaming error
When detecting invalid value in 'dbs' field of CIP header or packet
discontinuity, current implementation reports the status by err_info().
In most cases this state is caused by model-specific issue due to
vendor's customization and should be reported to developers.

This commit use dev_err() instead of dev_info() for this purpose.
In the cases, packet streaming is aborted, thus no message floading
occurs.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Acked-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-05-24 08:23:43 +02:00
Takashi Sakamoto 9a2820c118 ALSA: firewire-lib: macro arrangement for code cleanup
Some macros include my misunderstanding for IEC 61883-1 or -6.
Additionally, some fixed values appear on codes.

This commit replaces these with macros with proper names.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Acked-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-05-24 08:23:36 +02:00
Takashi Sakamoto 29bcae2081 ALSA: firewire-lib: rename local functions for code cleanup
The naming rule for local functions was inconsistent. This commit
rename them with a consistent manner.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Acked-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-05-24 08:23:14 +02:00
Takashi Sakamoto 727d3a0b1f ALSA: firewire-lib: remove restriction for non-blocking mode
Former patches allow non-blocking streams to synchronize with timestamp.
This patch removes the restriction.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-05-23 09:13:21 +02:00
Takashi Sakamoto a4103bd7fd ALSA: firewire-lib: set streaming error outside of packetization
In previous commit, error handling for incoming packet processing is
outside of packetization. This is nice for reading the codes.

This commit applies this idea for outgoing packet processing, too.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-05-23 09:13:20 +02:00
Takashi Sakamoto 6fc6b9ce41 ALSA: firewire-lib: pass the number of data blocks in incoming packets to outgoing packets
Current implementation reuses the value of syt field in incoming packet to
outgoing packet for full duplex timestamp synchronization, while the number
of data blocks in outgoing packets refers to hard-coded table and the
synchronization cannot be applied to non-blocking stream.

This commit passes the number of data blocks from incoming packet
processing to outgoing packet processing for the synchronization. For
normal mode, isochronous callback handler is changed to generate the values
of syt and data blocks.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-05-23 09:13:19 +02:00
Takashi Sakamoto 875be09160 ALSA: firewire-lib: simplify function to calculate the number of data blocks
This function is called according to conditions between the value of
syt and streaming mode(blocking or non-blocking).

To simplify caller's work, this commit push these conditions to the
function.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-05-23 09:13:19 +02:00
Takashi Sakamoto a2064710ba ALSA: firewire-lib: add buffer-over-run protection at receiving more data blocks than expected
In IEC 61883-6, the number of data blocks in a packet is limited up to
the value of SYT_INTERVAL. Current implementation is compliant to the
limitation, while it can cause buffer-over-run when the value of dbs
field in received packet is illegally large.

This commit adds a validator to detect such illegal packets to prevent
the buffer-over-run. Actually, the buffer is aligned to the size of memory
 page, thus this issue hardly causes system errors due to the room to page
alignment, as long as a few packets includes such jumbo payload; i.e.
a packet to several received packets.

Here, Behringer F-Control Audio 202 (based on OXFW 960) has a quirk to
postpone transferring isochronous packet till finish handling any
asynchronous packets. In this case, this model is lazy, transfers no
packets according to several cycle-start packets. After finishing, this
model pushes required data in next isochronous packet. As a result, the
packet include more data blocks than IEC 61883-6 defines.

To continue to support this model, this commit adds a new flag to extend
the length of calculated payload. This flag allows the size of payload
5 times as large as IEC 61883-6 defines. As a result, packets from this
model passed the validator successfully.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-05-23 09:13:18 +02:00
Takashi Iwai 9a4f35865f Merge branch 'for-next' into for-linus 2015-04-13 10:23:18 +02:00
Takashi Sakamoto a053fc318b ALSA: bebob: fix to processing in big-endian machine for sending cue
Some M-Audio devices require to receive bootup command just after
powering on, while codes in BeBoB driver doesn't work properly in
big-endian machine because the command should be aligned by
little-endian.

This commit fixes this bug. This fix should go to stable kernel.

Cc: Takayuki Shiroma <t.shiroma.oki@gmail.com>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-08 18:23:10 +02:00
Takashi Iwai e6826ef145 Merge branch 'for-linus' into for-next 2015-03-12 07:38:46 +01:00
Takashi Sakamoto 59294a01d7 ALSA: firewire-lib: leave unit reference counting completely
With previous commit, this module managed to leave the counting to each
drivers, but the isochronous resources functionality still increment/decrement
the count.

This commit purge such codes to leave the responsibility to each drivers.

Fix: c6f224dc20 ('ALSA: firewire-lib: remove reference counting')
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-10 15:27:19 +01:00
Takashi Sakamoto 5b1274efe2 Revert "ALSA: dice: fix wrong offsets for Dice interface"
This reverts commit 8cdebf7109.

The reverted commit breaks out-stream functionality of Dice driver.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-10 15:26:25 +01:00
Yannick Guerrini ce99198131 ALSA: firewire: Fix trivial typos in comments
Change 'propper' to 'proper'
Change 'paramters' to 'parameters'
Change 'SYT_INTEVAL' to 'SYT_INTERVAL'
Change 'aligh'/'alighed' to 'align'/'aligned'

Signed-off-by: Yannick Guerrini <yguerrini@tomshardware.fr>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-10 12:40:30 +01:00
Takashi Sakamoto 8cdebf7109 ALSA: dice: fix wrong offsets for Dice interface
For received packet stream, the offset of 'RX_SEQ_START' locates after
the offset of 'RX_NUMBER_MIDI', although current macro and proc output
includes wrong offsets.

Fortunately, this bug doesn't affect streaming functionality because
these macro is not used.

This commit fixes these wrong macro and outputs.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-01 10:49:06 +01:00
Takashi Sakamoto f2b14c0bc5 ALSA: oxfw: fix a condition and return code in start_stream()
The amdtp_stream_wait_callback() doesn't return minus value and
the return code is not for error code.

This commit fixes with a propper condition and an error code.

Fixes: f3699e2c77 ('ALSA: oxfw: Change the way to start stream')
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: <stable@vger.kernel.org> # 3.19+
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-02-27 14:42:18 +01:00
Takashi Sakamoto dec84316dd ALSA: fireworks/bebob/dice/oxfw: make it possible to shutdown safely
A part of these drivers, especially BeBoB driver, are programmed to wait
some events. Thus the drivers should not destroy any data in .remove()
context.

This commit moves some destructors from 'struct fw_driver.remove()' to
'struct snd_card.private_free()' to shutdown safely.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: <stable@vger.kernel.org> # 3.19+
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-02-23 09:11:24 +01:00
Takashi Sakamoto d23c2cc448 ALSA: fireworks/bebob/dice/oxfw: allow stream destructor after releasing runtime
Currently stream destructor in each driver has a problem to be called in
a context in which sound card object is released, because the destructors
call amdtp_stream_pcm_abort() and touch PCM runtime data.

The PCM runtime data is destroyed in application's context with
snd_pcm_close(), on the other hand PCM substream data is destroyed after
sound card object is released, in most case after all of ALSA character
devices are released. When PCM runtime is destroyed and PCM substream is
remained, amdtp_stream_pcm_abort() touches PCM runtime data and causes
Null-pointer-dereference.

This commit changes stream destructors and allows each driver to call
it after releasing runtime.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: <stable@vger.kernel.org> # 3.19+
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-02-23 09:11:16 +01:00
Takashi Sakamoto c6f224dc20 ALSA: firewire-lib: remove reference counting
AMDTP helper functions increment/decrement reference counter for an
instance of FireWire unit, while it's complicated for each driver to
process error state.

In previous commit, each driver has the role of reference counting. This
commit removes this role from the helper function.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: <stable@vger.kernel.org> # 3.19+
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-02-23 09:11:08 +01:00
Takashi Sakamoto 12ed719291 ALSA: fireworks/bebob/dice/oxfw: add reference-counting for FireWire unit
Fireworks and Dice drivers try to touch instances of FireWire unit after
sound card object is released, while references to the unit is decremented
in .remove(). When unplugging during streaming, sound card object is
released after .remove(), thus Fireworks and Dice drivers causes GPF or
Null-pointer-dereferencing to application processes because an instance of
FireWire unit was already released.

This commit adds reference-counting for FireWire unit in drivers to allow
them to touch an instance of FireWire unit after .remove(). In most case,
any operations after .remove() may be failed safely.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: <stable@vger.kernel.org> # 3.19+
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-02-23 09:10:38 +01:00
Takashi Sakamoto ca5b50501d ALSA: firewire-lib: fix an unexpected byte sequence for micro sign
The sign for microsecond (U+0085, MICRO SIGN) was encoded to '0x c2 b5'
by UTF-8 character encoding scheme. But the byte sequence was converted
to '0x c3 82 c2 b5' in a previous commit. As a result, the byte
sequence cannot represent microsecond sign in UTF-8 or ASCII. This
may confuse developers.

This commit replaces the sign to string expression with 'microseconds'
to purge superfluous troubles.

Fixes: 5c697e5b46ef("ALSA: firewire-lib: remove rx_blocks_for_midi quirk")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-02-23 08:46:03 +01:00
Clemens Ladisch 25ca917c0f ALSA: firewire-lib: limit the MIDI data rate
Do no send MIDI bytes at the full rate at which FireWire packets happen
to be sent, but restrict them to the actual rate of a real MIDI port.
This is required by the specification, and prevents data loss when the
device's buffer overruns.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Tested-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-01-16 22:51:23 +01:00
Clemens Ladisch 5c697e5b46 ALSA: firewire-lib: remove rx_blocks_for_midi quirk
There are several devices that expect to receive MIDI data only in the
first eight data blocks of a packet.  If the driver restricts the data
rate to the allowed rate (as mandated by the specification, but not yet
implemented by this driver), this happens naturally.  Therefore, there
is no reason to ever try to use more data packets with any device.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Tested-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-01-16 22:50:45 +01:00
Takashi Sakamoto 92cb46584e ALSA: fireworks: fix an endianness bug for transaction length
Although the 't->length' is a big-endian value, it's used without any
conversion. This means that the driver always uses 'length' parameter.

Fixes: 555e8a8f7f14("ALSA: fireworks: Add command/response functionality into hwdep interface")
Reported-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-01-07 16:39:21 +01:00
Dan Carpenter 5580ba7bf6 ALSA: oxfw: some signedness bugs
This code tends to use unsigned variables by default and it causes
signedness bugs when we use negative variables for error handling.
The "i" and "j" variables are used to iterated over small positive
values and so they should be type "int".  The "len" variable doesn't
*need* to be signed but it should be signed to make the code easier to
read and audit.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-12-15 10:03:21 +01:00
Dan Carpenter 0d3aba30b7 ALSA: oxfw: fix detect_loud_models() return value
This code causes a static checker warning:

	sound/firewire/oxfw/oxfw.c:46 detect_loud_models()
	warn: signedness bug returning '(-2)'

The detect_loud_models() function should return false on falure, so that
we don't try to set up the loud code for hardware that doesn't support
it.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-12-14 16:04:50 +01:00
Takashi Sakamoto 8985f4ac1c ALSA: oxfw: Add hwdep interface
This interface is designed for mixer/control application. By using this
interface, an application can get information about firewire node, can
lock/unlock kernel streaming and can get notification at starting/stopping
kernel streaming.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Acked-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-12-10 10:50:00 +01:00
Takashi Sakamoto 05588d340a ALSA: oxfw: Add support for capture/playback MIDI messages
This commit adds MIDI functionality with an assumption of 'if the device
has MIDI comformant data channels in its stream formation, the device has
one MIDI port'.

When no streams have already started, MIDI functionality starts stream
with current sampling rate.

When MIDI functionality has already starts some streams and PCM
functionality is going to start streams at different sampling rate,
this driver stops streams once and changes sampling rate, then restarts
streams for both PCM/MIDI substreams.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Acked-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-12-10 10:49:33 +01:00
Takashi Sakamoto 216e256f7b ALSA: oxfw: add support for capturing PCM samples
In previous commit, a support for transmitted packets is added. This commit
add a support for capturing PCM samples.

When any streams are already started, this driver should not change sampling
rate of the device, thus this commit also adds a restriction of sampling rate
in this situation.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Acked-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-12-10 10:49:17 +01:00
Takashi Sakamoto b0ac00095f ALSA: oxfw: Add support AMDTP in-stream
Previous commit adds support for some devices which can capture PCM samples.
These devices transmit AMDTP stream in non-blocking mode. This commit adds
functionality to handle AMDTP incoming stream.

OXFW seems to have two quirks:
 - Transmits packets with non-zero dbc in its beginning
 - Transmits packets with wrong values in syt field

For the first quirk, this commit adds CIP_SKIP_INIT_DBC_CHECK flag for
incoming stream to skip first check of dbc.

For the second quirk, this commit doesn't add duplex stream which
Fireworks/BeBoB drivers use. So OXFW driver generates syt value for outgoing
stream.

Here are examples of a sequence of packets transmitted by Behringer F-Control
Audio 202. There are differences between sequences of syt value when OXFW
driver transfers outgoing stream or not.

When driver gives no outgoing stream:
Index   Payload CIP_Header_0    CIP_Header_1
38      14      00020092        900103D1
39      12      00020098        900102FF
40      12      0002009D        9001027F
41      14      000200A2        90010396
42      14      000200A8        900102E8
43      12      000200AE        90010219
44      14      000200B3        90010331
45      12      000200B9        9001025F
46      14      000200BE        90010376
47      12      000200C4        900102A1
00      12      000200C9        9001023E
01      14      000200CE        90010358
02      12      000200D4        90010289
03      16      000200D9        900103A3
04      12      000200E0        900102DD
05      14      000200E5        900103F1
06      12      000200EB        90010335
07      12      000200F0        90010263
08      14      000200F5        9001037C
09      12      000200FB        900102AE

When driver gives outgoing stream:
Index   Payload CIP_Header_0    CIP_Header_1
38      12      000200BD        900104A8
39      14      000200C2        900104A8
40      12      000200C8        900104AC
41      14      000200CD        900104A9
42      12      000200D3        900104B1
43      14      000200D8        900104A8
44      12      000200DE        900104AA
45      14      000200E3        900104A9
46      14      000200E9        900104AE
47      12      000200EF        900104A8
00      14      000200F4        900104AD
01      12      000200FA        900104A7
02      14      000200FF        900104A9
03      12      00020005        900104A9
04      14      0002000A        900104B1
05      12      00020010        900104AA
06      14      00020015        900104AD
07      12      0002001B        900104A7
08      14      00020020        900104AC
09      12      00020026        900104A7

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Acked-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-12-10 10:48:59 +01:00
Takashi Sakamoto ec4dba5053 ALSA: oxfw: Add support for Behringer/Mackie devices
Some devices produced by Behringer/Mackie are based on OXFW970/971. This
commit adds support for them. Additionally, this commit changes the way to
name card with some information in config rom.

Ids of some Mackie(Loud) models are not identified, therefore this commit
applies name detection for these models.

The devices support capture/playback of PCM-samples and some of them
supports capture/playback of MIDI messages. These functionalities are
implemented by followed commits.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Acked-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-12-10 10:48:30 +01:00
Takashi Sakamoto f3699e2c77 ALSA: oxfw: Change the way to start stream
In past commit, this driver can keep stream formations for each sampling
rate. So its stream functionality can decide stream formations with given
some parameters.

This commit moves related codes from PCM functionality to stream
functionality. Furthermore, to set stream format correctly, this commit
uses AV/C Stream Format Information command instead of AV/C Input/Output
Plug Signal Format command.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Acked-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-12-10 10:48:12 +01:00
Takashi Sakamoto 3c96101f19 ALSA: oxfw: Add proc interface for debugging purpose
This commit adds proc interface to get information about stream
formation. This commit also adds snd_oxfw_stream_get_current_formation()
to get current stream formation.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Acked-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-12-10 10:47:54 +01:00
Takashi Sakamoto 5cd1d3f47a ALSA: oxfw: Change the way to make PCM rules/constraints
In previous commit, this driver can get to know stream formations at
each supported sampling rates. This commit uses it to make PCM
rules/constraints and obsoletes hard-coded rules/constraints.

For this purpose, this commit adds 'struct snd_oxfw_stream_formation' and
snd_oxfw_stream_parse_format() to parse data channel formation of data
block.

According to datasheet of OXFW970/971, they support 32.0kHz to 196.0kHz.

As long as developers investigate, some devices are confirmed to have
several formats for the same sampling rate.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Acked-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-12-10 10:47:37 +01:00
Takashi Sakamoto 5b59d8098d ALSA: oxfw: Add support for AV/C stream format command to get/set supported stream formation
OXFW970/971 may supports AV/C Stream Format Information Specification 1.1
Working Draft (Apr 2005, 1394TA). By using this command, drivers can get to know
stream formations which device supports.

This commit adds 'EXTENDED STREAM FORMAT INFORMATION' command. This command
has two subfunctions, 'SINGLE' and 'LIST'. Drivers can use 'SINGLE' subfunction
to know/set current formation of AMDTP stream, Drivers can use 'LIST'
subfunction to know an available formation of AMDTP stream in a certain sampling
rate.

But some devices don't implement the 'LIST' subfunction. So this commit uses
an assumption that 'if they don't implement it, they don't change stream
formation depending on current each sampling rate'. With this assumption, this
driver generates formations for such devices by:
 1.getting current formation by SINGLE subfunction
 2.getting supported sampling rates
 3.applying current formation for all of supported sampling rates

Followed commit implements a parser of this format information.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Acked-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-12-10 10:47:09 +01:00
Takashi Sakamoto fec7b75362 ALSA: oxfw: Change the way to name card
This is a preparation for more models. In following commit, members
of 'struct snd_card' related to name becomes to consists of vendor and
model strings in device's config-rom.

Current supported devices also has strings in their config rom, but the
strings are too long to name sound card, thus this driver still keep
hard-coded vendor and model names for them.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Acked-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-12-10 10:46:46 +01:00
Takashi Sakamoto a113ff886b ALSA: dice: Add support for MIDI capture/playback
This commit adds a support for MIDI capture/playback

When MIDI substrams already start streaming and PCM substreams are going to
join at different sampling rate, streams are stopped once. Then sampling rate
is changed and streams are restarted.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Acked-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-12-10 10:46:14 +01:00
Takashi Sakamoto 69dcf3e47a ALSA: dice: Add support for capturing PCM samples
This commit adds a support for capturing PCM samples.

When opposite PCM substream is already running, available sampling rate is
limited at current one.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Acked-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-12-10 10:45:53 +01:00
Takashi Sakamoto 8fc01fc067 ALSA: dice: Support for non SYT-Match sampling clock source mode
This commit allows this driver to handle devices with non SYT-Match
sampling clock source.

When sampling clock source is SYT-Match mode, devices handle
'presentation timestamp' in received packets and generates sampling clock
according to the information. In this case, driver is synchronization master
and must transfer correct value in SYT field of each packets in outgoing
stream, then the outgoing stream is a master stream.

On the other hand, non SYT-Match mode, devices do this. So drivers must pick
up the value in SYT field of incoming packets and use the value for outgoing
stream. Currently firewire-lib module achieve this work.

Furthermore, without SYT-Match and internal clock source, the sampling rate
should be fixed for the other devices connected to the handled device. This
commit add a restriction of sampling rate at this situation.

With these implementations, this driver has no need to set clock source.
This commit remove set function.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Acked-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-12-10 10:45:28 +01:00
Takashi Sakamoto 9a02843cae ALSA: dice: Add support for duplex streams with synchronization
This commit adds support for AMDTP in-stream. As a result, Dice driver
supports full duplex streams with synchronization.

AMDTP can transfer timestamps in its packets. By handling the timestamp,
devices can synchronize to the other devices or drivers on the same bus.

When Dice chipset is 'enabled', it starts streams with correct settings.
This 'enable' register is global, thus, when a stream is started to run,
an opposite stream can't start unless turning off 'enable'. Therefore
a pair of streams must be running. This causes a loss of CPU usage when
single stream is needed for neither playbacking or capturing.

This commit assumes that playback-only models also have a functionality
to transmit stream for delivering timestamps.

Currently, sampling clock source is restricted to SYT-Match mode. This is
improved in followed commit. I note that at SYT-Match mode, Dice can select
from 4 streams for synchronization but this driver uses the 1st stream only
for simplicity.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Acked-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-12-10 10:44:54 +01:00
Takashi Sakamoto 288a8d0cb0 ALSA: dice: Change the way to start stream
Streaming functionality can start streams when rate is given but currently
some codes are in PCM functionality.

This commit changes the way to start stream and add some arrangement
to make it easy to understand the way.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Acked-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-12-10 10:44:37 +01:00
Fengguang Wu ea09dd3b00 ALSA: dice: fix semicolon.cocci warnings
sound/firewire/dice/dice-transaction.c:34:2-3: Unneeded semicolon

 Removes unneeded semicolon.

Generated by: scripts/coccinelle/misc/semicolon.cocci

CC: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-12-01 21:41:07 +01:00
Takashi Sakamoto 31514bfb4a ALSA: oxfw: Split control functionality to a new file
This is a help for works in followed patches.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-11-29 20:22:37 +01:00
Takashi Sakamoto 3713d93a6a ALSA: oxfw: Split PCM functionality to a new file
This is a help for works in followed patches.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-11-29 20:22:22 +01:00
Takashi Sakamoto e2786ca648 ALSA: oxfw: Split stream functionality to a new file and add a header file
This is a help for works in followed patches.

And this commit remove 'fw_unit_get()/fw_unit_put()' because these
are called by helper functions in 'snd-firewire-lib'.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-11-29 20:22:08 +01:00
Takashi Sakamoto 1a4e39c2e5 ALSA: oxfw: Move to its own directory
Followed commits add much codes. To make the work easy, this commit creates
own directory and move current file to it.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-11-29 20:21:43 +01:00
Takashi Sakamoto 8832c5a74b ALSA: speakers: Rename to oxfw and rename some members
This commit renames 'firewire-speakers' to 'oxfw' to enhance support for
devices which based on OXFW970/971. A line for MODULE_ALIAS is added.

Additionally, to help for works in followed paches, some members
in private structure are renamed.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-11-29 20:21:15 +01:00
Takashi Sakamoto 60cea52296 ALSA: dice: remove experimental state
Some developers test this driver, thus it's better to remove its
experimental state.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-11-29 20:20:23 +01:00
Takashi Sakamoto 2c2416c83e ALSA: dice: Add new functions for constraints of PCM parameters
This commit adds a new functions and some arrangement for PCM restriction.
This arrangement is due to the number of channels which each Dice device has.

I note that minimum number for period becomes 2, instead of 1 because its PCM
functionality has SNDRV_PCM_INFO_BATCH, this means that the driver uses double
(or more) buffering so the minimum number for period should be 2.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-11-29 20:17:06 +01:00
Takashi Sakamoto 04d426a039 ALSA: dice: Split proc interface into a file
This commit adds a file and move some codes related to proc output.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-11-29 20:09:47 +01:00
Takashi Sakamoto 19af57b46d ALSA: dice: Split hwdep functionality into a file
This commit adds a file and move some codes related to hwdep functionality.

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.

Additionally, this interface give a way to read Dice notification.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-11-29 20:08:19 +01:00
Takashi Sakamoto c50fb91f53 ALSA: dice: Split PCM functionality into a file
This commit adds a file and move some codes related to PCM functionality.

Currently PCM playback is supported. PCM capture will be supported in followed
commits.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-11-29 20:07:47 +01:00
Takashi Sakamoto 6eb6c81eee ALSA: dice: Split stream functionality into a file
This commit adds a file with some helper functions for streaming, and move some
codes into the file with some arrangements.

Well-known CMP is not used to start/stop streams for Dice chipset. It's
achieved by writing to specific address. We call this way as 'enable'.
When devices are 'enabled', streaming starts in registered isochronous channel.
Some helper functions are already implemented in previous commit.

Basically, the stream is compliant to IEC 61883-6, so-called as AMDTP. But Dice
has a specific quirk, so called-as 'Dual Wire'. This quirk is applied at
176.4/192.0kHz. In this mode, each packet includes double number of events than
number in the specification, and stream runs at a half of sampling rate.

There is another quirk at bus reset. Dice chipset handles drivers' request but
don't re-enable streaming. So stream should be stopped.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-11-29 20:07:33 +01:00
Takashi Sakamoto 7c2d4c0cf5 ALSA: dice: Split transaction functionality into a file
This commit adds a file with some helper functions for transaction, and move
some codes into the file with some arrangements.

For Dice chipset, well-known FCP or AV/C commands are not used to control
devices. It's achieved by read/write transactions into specific addresses.

Dice's address area is split into 5 areas. Each area has its own role. The
offset for each area can be got by reading head of the address area. By
reading these areas, drivers can get to know device status. By writing these
areas, drivers can change device status.

Dice has a specific mechanism called as 'notification'. When device status is
changed, Dice devices tells the event by sending transaction. This notification
is sent to an address which drivers register in advance. But this causes an
issue to drivers.

To handle the notification, drivers need to allocate its own callback function
to the address region in host controller. This region is exclusive. For the
other applications, drivers must give a mechanism to read the received
notification. For this purpose, Dice driver already implements hwdep interface.

Dice chipset doesn't allow drivers to register several addresses. In this
reason, when this driver is applied to a device, the other drivers should
_not_ try to register its own address to the device.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-11-29 20:04:15 +01:00
Takashi Sakamoto 14ff6a0948 ALSA: dice: Move file to its own directory
In followed commits, dice driver is split into several files. For easily
managing these files, this commit adds subdirectory and move file into
the directory.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-11-29 20:03:45 +01:00
Takashi Sakamoto 732d153fbe ALSA: dice: Rename structure and its members
Currently, dice driver supports AMDTP out-stream. In followed commits, AMDTP
in-stream will be supported but current name of members in dice structure
are not propper. This commit renames these members to proper name.

Additionally, for easily distinguishing local symbols from structure tag,
rename dice tag into snd_dice.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-11-29 20:03:17 +01:00
Takashi Sakamoto 81fc5ad515 ALSA: dice: suppress checkpatch.pl warnings
The checkpatch.pl generates some warnings due to:
 - C99 comment
 - a line over 80 characters
 - min() for parameters with different types

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-11-29 20:02:48 +01:00
Takashi Sakamoto 5f217f905b ALSA: firewire-lib: fix kerneldoc errors
Complete missing parameters, correct wrong reference, and add an explaination
about the differences between the latest specification and our implementation.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-11-18 18:10:23 +01:00
Takashi Iwai 1fb8510cdb ALSA: pcm: Add snd_pcm_stop_xrun() helper
Add a new helper function snd_pcm_stop_xrun() to the standard sequnce
lock/snd_pcm_stop(XRUN)/unlock by a single call, and replace the
existing open codes with this helper.

The function checks the PCM running state to prevent setting the wrong
state, too, for more safety.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-11-09 18:20:40 +01:00
Takashi Iwai 85c24cd8d3 Merge branch 'for-linus' into for-next
Merged upstream branch to make further fireworks development easier
(and avoid conflicts earlier).

Conflicts:
	sound/firewire/bebob/bebob_focusrite.c
2014-10-27 14:11:07 +01:00
Christian Vogel d1d0b6b668 ALSA: bebob: Uninitialized id returned by saffirepro_both_clk_src_get
snd_bebob_stream_check_internal_clock() may get an id from
saffirepro_both_clk_src_get (via clk_src->get()) that was uninitialized.

a) make logic in saffirepro_both_clk_src_get explicit
b) test if id used in snd_bebob_stream_check_internal_clock matches array size

[fixed missing signed prefix to *_maps[] by tiwai]

Signed-off-by: Christian Vogel <vogelchr@vogel.cx>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-10-27 14:09:14 +01:00
Takashi Sakamoto 7ce5c9268b ALSA: bebob: fix wrong decoding of clock information for Terratec PHASE 88 Rack FW
Terratec PHASE 88 rack fw has two registers for source of clock, one is
for internal/external, and another is for wordclock/spdif for external.

When clock source is internal, information in another register has no meaning.
Thus it must be ignored, but current implementation decodes it. This causes
over-indexing reference to labels.

Reported-by: András Murányi <muranyia@gmail.com>
Tested-by: András Murányi <muranyia@gmail.com>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Acked-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-10-27 08:39:11 +01:00
Takashi Iwai 41be5164ea ALSA: bebob: Use snd_ctl_enum_info()
... and reduce the open codes.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-10-21 08:26:55 +02:00
Takashi Iwai e7ced4137d ALSA: bebob: More constify text arrays
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-10-21 08:26:10 +02:00
Takashi Sakamoto 3f4032861c ALSA: bebob: Fix failure to detect source of clock for Terratec Phase 88
This patch fixes a failure to open PCM device with -ENOSYS in
Terratec Phase 88.

Terratec Phase 88 has two Selector Function Blocks of AVC Audio subunit
to switch source of clock. One is to switch internal/external for the
source and another is to switch word/spdif for the external clock.

The IDs for these Selector Function Blocks are 9 and 8. But in current
implementation they're 0 and 0.

Reported-by: András Murányi <muranyia@gmail.com>
Tested-by: András Murányi <muranyia@gmail.com>
Cc: <stable@vger.kernel.org> # v3.16+
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-10-10 17:25:30 +02:00
Takashi Sakamoto 65845f29be ALSA: firewire-lib/dice: add arrangements of PCM pointer and interrupts for Dice quirk
In IEC 61883-6, one data block transfers one event. In ALSA, the event equals one PCM frame,
hence one data block transfers one PCM frame. But Dice has a quirk at higher sampling rate
(176.4/192.0 kHz) that one data block transfers two PCM frames.

Commit 10550bea44 ("ALSA: dice/firewire-lib: Keep dualwire mode but obsolete
CIP_HI_DUALWIRE") moved some codes related to this quirk into Dice driver. But the commit
forgot to add arrangements for PCM period interrupts and DMA pointer updates. As a result, Dice
driver cannot work correctly at higher sampling rate.

This commit adds 'double_pcm_frames' parameter to amdtp structure for this quirk. When this
parameter is set, PCM period interrupts and DMA pointer updates occur at double speed than in
IEC 61883-6.

Reported-by: Daniel Robbins <drobbins@funtoo.org>
Fixes: 10550bea44 ("ALSA: dice/firewire-lib: Keep dualwire mode but obsolete CIP_HI_DUALWIRE")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: <stable@vger.kernel.org> # 3.16
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-08-29 09:52:07 +02:00
Takashi Sakamoto 1033eb5b5a ALSA: dice: fix wrong channel mappping at higher sampling rate
The channel mapping is initialized by amdtp_stream_set_parameters(), however
Dice driver set it before calling this function. Furthermore, the setting is
wrong because the index is the value of array, and vice versa.

This commit moves codes for channel mapping after the function and set it correctly.

Reported-by: Daniel Robbins <drobbins@funtoo.org>
Fixes: 10550bea44 ("ALSA: dice/firewire-lib: Keep dualwire mode but obsolete CIP_HI_DUALWIRE")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: <stable@vger.kernel.org> # 3.16
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-08-29 09:51:45 +02:00
Takashi Sakamoto 30225ed5ca ALSA: fireworks: fix specifiers in format strings for propper output
Use %d for loop counter and %X for device capabilities. This is a
supplemental patch for Hans Wennborg's patch.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-08-05 09:15:20 +02:00
Hans Wennborg 04b9906d8c ALSA: fireworks: fix %d confusingly prefixed with 0x in format strings
Signed-off-by: Hans Wennborg <hans@hanshq.net>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-08-04 13:17:23 +02:00
Takashi Iwai 2e65b8916c Merge branch 'for-next' into for-linus 2014-08-04 11:11:22 +02:00
Stefan Richter 27c828816d ALSA: firewire: trivial typo fixes in Kconfig
ESI Quotafire -> QuataFire
TerraTec EWS Mic4 -> Mic8
Firewire -> FireWire

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-07-28 10:26:42 +02:00