2019-05-29 16:57:59 -07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2014-11-28 08:59:27 -07:00
|
|
|
/*
|
|
|
|
* oxfw.h - a part of driver for OXFW970/971 based devices
|
|
|
|
*
|
|
|
|
* Copyright (c) Clemens Ladisch <clemens@ladisch.de>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/firewire.h>
|
|
|
|
#include <linux/firewire-constants.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/mod_devicetable.h>
|
|
|
|
#include <linux/mutex.h>
|
|
|
|
#include <linux/slab.h>
|
2014-12-08 08:10:49 -07:00
|
|
|
#include <linux/compat.h>
|
2017-02-02 11:15:33 -07:00
|
|
|
#include <linux/sched/signal.h>
|
2014-11-28 08:59:27 -07:00
|
|
|
|
|
|
|
#include <sound/control.h>
|
|
|
|
#include <sound/core.h>
|
|
|
|
#include <sound/initval.h>
|
|
|
|
#include <sound/pcm.h>
|
|
|
|
#include <sound/pcm_params.h>
|
2014-12-08 08:10:43 -07:00
|
|
|
#include <sound/info.h>
|
2014-12-08 08:10:48 -07:00
|
|
|
#include <sound/rawmidi.h>
|
2014-12-08 08:10:49 -07:00
|
|
|
#include <sound/firewire.h>
|
|
|
|
#include <sound/hwdep.h>
|
2014-11-28 08:59:27 -07:00
|
|
|
|
|
|
|
#include "../lib.h"
|
|
|
|
#include "../fcp.h"
|
|
|
|
#include "../packets-buffer.h"
|
|
|
|
#include "../iso-resources.h"
|
2015-09-18 19:21:55 -07:00
|
|
|
#include "../amdtp-am824.h"
|
2014-11-28 08:59:27 -07:00
|
|
|
#include "../cmp.h"
|
|
|
|
|
2021-05-18 01:45:54 -07:00
|
|
|
enum snd_oxfw_quirk {
|
|
|
|
// Postpone transferring packets during handling asynchronous transaction. As a result,
|
|
|
|
// next isochronous packet includes more events than one packet can include.
|
|
|
|
SND_OXFW_QUIRK_JUMBO_PAYLOAD = 0x01,
|
2021-05-18 01:45:56 -07:00
|
|
|
// The dbs field of CIP header in tx packet is wrong.
|
|
|
|
SND_OXFW_QUIRK_WRONG_DBS = 0x02,
|
2021-05-18 01:45:57 -07:00
|
|
|
// Blocking transmission mode is used.
|
|
|
|
SND_OXFW_QUIRK_BLOCKING_TRANSMISSION = 0x04,
|
2021-06-07 01:12:44 -07:00
|
|
|
// Stanton SCS1.d and SCS1.m support unique transaction.
|
|
|
|
SND_OXFW_QUIRK_SCS_TRANSACTION = 0x08,
|
2021-08-11 19:28:39 -07:00
|
|
|
// Apogee Duet FireWire ignores data blocks in packet with NO_INFO for audio data
|
|
|
|
// processing, while output level meter moves. Any value in syt field of packet takes
|
|
|
|
// the device to process audio data even if the value is invalid in a point of
|
|
|
|
// IEC 61883-1/6.
|
|
|
|
SND_OXFW_QUIRK_IGNORE_NO_INFO_PACKET = 0x10,
|
2021-10-28 06:03:25 -07:00
|
|
|
// Loud Technologies Mackie Onyx 1640i seems to configure OXFW971 ASIC so that it decides
|
|
|
|
// event frequency according to events in received isochronous packets. The device looks to
|
|
|
|
// performs media clock recovery voluntarily. In the recovery, the packets with NO_INFO
|
|
|
|
// are ignored, thus driver should transfer packets with timestamp.
|
|
|
|
SND_OXFW_QUIRK_VOLUNTARY_RECOVERY = 0x20,
|
2024-02-18 00:41:26 -07:00
|
|
|
// Miglia Harmony Audio does not support AV/C Stream Format Information command.
|
|
|
|
SND_OXFW_QUIRK_STREAM_FORMAT_INFO_UNSUPPORTED = 0x40,
|
ALSA: oxfw: add support for Miglia Harmony Audio
Miglia Technology ships Harmony Audio 2004. It uses Oxford Semiconductor
OXFW970 for communication function in IEEE 1394 bus. This commit adds
support for the model.
In my opinion, the firmware of ASIC is really the initial stage, since
it has the following quirks.
* It skips several isochronous cycles to transmit isochronous packets
when receiving any asynchronous transaction.
* The value of dbc field in the transmitted packet is the number of
accumulated quadlets in CIP payload, instead of the accumulated data
blocks. Furthermore, the value includes the quadlets of CIP payload in
the packet.
* It neither supports AV/C Stream Format Information command nor AV/C
Extended Stream Format Information command.
* The vendor and model information in root directory of configuration
ROM includes some mistakes.
Additionally, when operating at 96.0 kHz, it often skips much isochronous
cycles to transmit the isochronous packets. The issue is detected as cycle
discontinuity and ALSA PCM application receives -EIO at any operation for
PCM substream. I have never found any workaround yet.
$ config-rom-pretty-printer < /sys/bus/firewire/devices/fw1/config_rom
ROM header and bus information block
-----------------------------------------------------------------
1024 04249e04 bus_info_length 4, crc_length 36, crc 40452
1028 31333934 bus_name "1394"
1032 20ff5003 irmc 0, cmc 0, isc 1, bmc 0, cyc_clk_acc 255, max_rec 5 (64)
1036 0030e002 company_id 0030e0 |
1040 00454647 device_id 8594474567 | EUI-64 13757098081207879
root directory
-----------------------------------------------------------------
1044 00062d69 directory_length 6, crc 11625
1048 030030e0 vendor
1052 8100000a --> descriptor leaf at 1092
1056 1700f970 model
1060 81000011 --> descriptor leaf at 1128
1064 0c0083c0 node capabilities: per IEEE 1394
1068 d1000001 --> unit directory at 1072
unit directory at 1072
-----------------------------------------------------------------
1072 00046ff9 directory_length 4, crc 28665 (should be 43676)
1076 1200a02d specifier id
1080 13010001 version
1084 1700f970 model
1088 8100000f --> descriptor leaf at 1148
descriptor leaf at 1092
-----------------------------------------------------------------
1092 00085f8a leaf_length 8, crc 24458
1096 00000000 textual descriptor
1100 00000000 minimal ASCII
1104 4d69676c "Migl"
1108 69612054 "ia T"
1112 6563686e "echn"
1116 6f6c6f67 "olog"
1120 79204c74 "y Lt"
1124 642e0000 "d."
descriptor leaf at 1128
-----------------------------------------------------------------
1128 00040514 leaf_length 4, crc 1300
1132 00000000 textual descriptor
1136 00000000 minimal ASCII
1140 4f584657 "OXFW"
1144 20393730 " 970"
descriptor leaf at 1148
-----------------------------------------------------------------
1148 0005a1dc leaf_length 5, crc 41436
1152 00000000 textual descriptor
1156 00000000 minimal ASCII
1160 4861726d "Harm"
1164 6f6e7941 "onyA"
1168 7564696f "udio"
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20240218074128.95210-5-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2024-02-18 00:41:28 -07:00
|
|
|
// Miglia Harmony Audio transmits CIP in which the value of dbc field expresses the number
|
|
|
|
// of accumulated payload quadlets including the packet.
|
|
|
|
SND_OXFW_QUIRK_DBC_IS_TOTAL_PAYLOAD_QUADLETS = 0x80,
|
2021-05-18 01:45:54 -07:00
|
|
|
};
|
|
|
|
|
2014-12-08 08:10:42 -07:00
|
|
|
/* This is an arbitrary number for convinience. */
|
|
|
|
#define SND_OXFW_STREAM_FORMAT_ENTRIES 10
|
2014-11-28 08:59:27 -07:00
|
|
|
struct snd_oxfw {
|
|
|
|
struct snd_card *card;
|
|
|
|
struct fw_unit *unit;
|
|
|
|
struct mutex mutex;
|
2014-12-08 08:10:48 -07:00
|
|
|
spinlock_t lock;
|
2014-12-08 08:10:42 -07:00
|
|
|
|
2021-05-18 01:45:54 -07:00
|
|
|
// The combination of snd_oxfw_quirk enumeration-constants.
|
|
|
|
unsigned int quirks;
|
2014-12-08 08:10:46 -07:00
|
|
|
bool has_output;
|
2020-01-13 00:34:17 -07:00
|
|
|
bool has_input;
|
2014-12-08 08:10:46 -07:00
|
|
|
u8 *tx_stream_formats[SND_OXFW_STREAM_FORMAT_ENTRIES];
|
2014-12-08 08:10:42 -07:00
|
|
|
u8 *rx_stream_formats[SND_OXFW_STREAM_FORMAT_ENTRIES];
|
|
|
|
bool assumed;
|
2014-12-08 08:10:46 -07:00
|
|
|
struct cmp_connection out_conn;
|
2014-11-28 08:59:27 -07:00
|
|
|
struct cmp_connection in_conn;
|
2014-12-08 08:10:46 -07:00
|
|
|
struct amdtp_stream tx_stream;
|
2014-11-28 08:59:27 -07:00
|
|
|
struct amdtp_stream rx_stream;
|
2019-06-12 01:44:20 -07:00
|
|
|
unsigned int substreams_count;
|
2014-12-08 08:10:42 -07:00
|
|
|
|
2014-12-08 08:10:48 -07:00
|
|
|
unsigned int midi_input_ports;
|
|
|
|
unsigned int midi_output_ports;
|
|
|
|
|
2014-12-08 08:10:49 -07:00
|
|
|
int dev_lock_count;
|
|
|
|
bool dev_lock_changed;
|
|
|
|
wait_queue_head_t hwdep_wait;
|
2015-12-15 07:56:20 -07:00
|
|
|
|
2015-12-16 04:37:54 -07:00
|
|
|
void *spec;
|
2019-08-03 23:21:32 -07:00
|
|
|
|
|
|
|
struct amdtp_domain domain;
|
2014-11-28 08:59:27 -07:00
|
|
|
};
|
|
|
|
|
2014-12-08 08:10:41 -07:00
|
|
|
/*
|
|
|
|
* AV/C Stream Format Information Specification 1.1 Working Draft
|
|
|
|
* (Apr 2005, 1394TA)
|
|
|
|
*/
|
|
|
|
int avc_stream_set_format(struct fw_unit *unit, enum avc_general_plug_dir dir,
|
|
|
|
unsigned int pid, u8 *format, unsigned int len);
|
|
|
|
int avc_stream_get_format(struct fw_unit *unit,
|
|
|
|
enum avc_general_plug_dir dir, unsigned int pid,
|
|
|
|
u8 *buf, unsigned int *len, unsigned int eid);
|
|
|
|
static inline int
|
|
|
|
avc_stream_get_format_single(struct fw_unit *unit,
|
|
|
|
enum avc_general_plug_dir dir, unsigned int pid,
|
|
|
|
u8 *buf, unsigned int *len)
|
|
|
|
{
|
|
|
|
return avc_stream_get_format(unit, dir, pid, buf, len, 0xff);
|
|
|
|
}
|
|
|
|
static inline int
|
|
|
|
avc_stream_get_format_list(struct fw_unit *unit,
|
|
|
|
enum avc_general_plug_dir dir, unsigned int pid,
|
|
|
|
u8 *buf, unsigned int *len,
|
|
|
|
unsigned int eid)
|
|
|
|
{
|
|
|
|
return avc_stream_get_format(unit, dir, pid, buf, len, eid);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* AV/C Digital Interface Command Set General Specification 4.2
|
|
|
|
* (Sep 2004, 1394TA)
|
|
|
|
*/
|
|
|
|
int avc_general_inquiry_sig_fmt(struct fw_unit *unit, unsigned int rate,
|
|
|
|
enum avc_general_plug_dir dir,
|
|
|
|
unsigned short pid);
|
|
|
|
|
2019-06-12 01:44:19 -07:00
|
|
|
int snd_oxfw_stream_init_duplex(struct snd_oxfw *oxfw);
|
2019-06-12 01:44:21 -07:00
|
|
|
int snd_oxfw_stream_reserve_duplex(struct snd_oxfw *oxfw,
|
|
|
|
struct amdtp_stream *stream,
|
2019-10-07 04:05:19 -07:00
|
|
|
unsigned int rate, unsigned int pcm_channels,
|
2019-10-17 08:54:16 -07:00
|
|
|
unsigned int frames_per_period,
|
|
|
|
unsigned int frames_per_buffer);
|
2019-06-12 01:44:21 -07:00
|
|
|
int snd_oxfw_stream_start_duplex(struct snd_oxfw *oxfw);
|
2019-06-12 01:44:19 -07:00
|
|
|
void snd_oxfw_stream_stop_duplex(struct snd_oxfw *oxfw);
|
|
|
|
void snd_oxfw_stream_destroy_duplex(struct snd_oxfw *oxfw);
|
|
|
|
void snd_oxfw_stream_update_duplex(struct snd_oxfw *oxfw);
|
2014-11-28 08:59:28 -07:00
|
|
|
|
2014-12-08 08:10:42 -07:00
|
|
|
struct snd_oxfw_stream_formation {
|
|
|
|
unsigned int rate;
|
|
|
|
unsigned int pcm;
|
|
|
|
unsigned int midi;
|
|
|
|
};
|
2024-02-18 00:41:25 -07:00
|
|
|
int snd_oxfw_stream_parse_format(const u8 *format,
|
2014-12-08 08:10:42 -07:00
|
|
|
struct snd_oxfw_stream_formation *formation);
|
|
|
|
int snd_oxfw_stream_get_current_formation(struct snd_oxfw *oxfw,
|
|
|
|
enum avc_general_plug_dir dir,
|
|
|
|
struct snd_oxfw_stream_formation *formation);
|
2014-12-08 08:10:46 -07:00
|
|
|
|
2014-12-08 08:10:42 -07:00
|
|
|
int snd_oxfw_stream_discover(struct snd_oxfw *oxfw);
|
|
|
|
|
2014-12-08 08:10:49 -07:00
|
|
|
void snd_oxfw_stream_lock_changed(struct snd_oxfw *oxfw);
|
|
|
|
int snd_oxfw_stream_lock_try(struct snd_oxfw *oxfw);
|
|
|
|
void snd_oxfw_stream_lock_release(struct snd_oxfw *oxfw);
|
|
|
|
|
2014-11-28 08:59:28 -07:00
|
|
|
int snd_oxfw_create_pcm(struct snd_oxfw *oxfw);
|
2014-11-28 08:59:29 -07:00
|
|
|
|
2014-12-08 08:10:43 -07:00
|
|
|
void snd_oxfw_proc_init(struct snd_oxfw *oxfw);
|
2014-12-08 08:10:48 -07:00
|
|
|
|
|
|
|
int snd_oxfw_create_midi(struct snd_oxfw *oxfw);
|
2014-12-08 08:10:49 -07:00
|
|
|
|
|
|
|
int snd_oxfw_create_hwdep(struct snd_oxfw *oxfw);
|
2015-12-15 07:56:18 -07:00
|
|
|
|
2015-12-16 04:37:56 -07:00
|
|
|
int snd_oxfw_add_spkr(struct snd_oxfw *oxfw, bool is_lacie);
|
2015-12-21 17:15:39 -07:00
|
|
|
int snd_oxfw_scs1x_add(struct snd_oxfw *oxfw);
|
2015-12-21 17:15:40 -07:00
|
|
|
void snd_oxfw_scs1x_update(struct snd_oxfw *oxfw);
|