Changes in 4.9.236 HID: core: Correctly handle ReportSize being zero HID: core: Sanitize event code and type when mapping input perf record/stat: Explicitly call out event modifiers in the documentation hwmon: (applesmc) check status earlier. nvmet: Disable keep-alive timer when kato is cleared to 0h ceph: don't allow setlease on cephfs s390: don't trace preemption in percpu macros xen/xenbus: Fix granting of vmalloc'd memory dmaengine: of-dma: Fix of_dma_router_xlate's of_dma_xlate handling batman-adv: Avoid uninitialized chaddr when handling DHCP batman-adv: bla: use netif_rx_ni when not in interrupt context dmaengine: at_hdmac: check return value of of_find_device_by_node() in at_dma_xlate() MIPS: mm: BMIPS5000 has inclusive physical caches MIPS: BMIPS: Also call bmips_cpu_setup() for secondary cores netfilter: nf_tables: add NFTA_SET_USERDATA if not null netfilter: nf_tables: incorrect enum nft_list_attributes definition netfilter: nf_tables: fix destination register zeroing net: hns: Fix memleak in hns_nic_dev_probe ravb: Fixed to be able to unload modules net: arc_emac: Fix memleak in arc_mdio_probe dmaengine: pl330: Fix burst length if burst size is smaller than bus width bnxt_en: Check for zero dir entries in NVRAM. bnxt_en: Fix PCI AER error recovery flow fix regression in "epoll: Keep a reference on files added to the check list" tg3: Fix soft lockup when tg3_reset_task() fails. iommu/vt-d: Serialize IOMMU GCMD register modifications thermal: ti-soc-thermal: Fix bogus thermal shutdowns for omap4430 include/linux/log2.h: add missing () around n in roundup_pow_of_two() btrfs: drop path before adding new uuid tree entry btrfs: Remove redundant extent_buffer_get in get_old_root btrfs: Remove extraneous extent_buffer_get from tree_mod_log_rewind btrfs: set the lockdep class for log tree extent buffers uaccess: Add non-pagefault user-space read functions uaccess: Add non-pagefault user-space write function btrfs: fix potential deadlock in the search ioctl net: usb: qmi_wwan: add Telit 0x1050 composition drivers: net: usb: qmi_wwan: add QMI_QUIRK_SET_DTR for Telit PID 0x1201 qmi_wwan: new Telewell and Sierra device IDs usb: qmi_wwan: add D-Link DWM-222 A2 device ID ALSA: ca0106: fix error code handling ALSA: pcm: oss: Remove superfluous WARN_ON() for mulaw sanity check ALSA: firewire-digi00x: exclude Avid Adrenaline from detection block: allow for_each_bvec to support zero len bvec block: Move SECTOR_SIZE and SECTOR_SHIFT definitions into <linux/blkdev.h> libata: implement ATA_HORKAGE_MAX_TRIM_128M and apply to Sandisks dm cache metadata: Avoid returning cmd->bm wild pointer on error dm thin metadata: Avoid returning cmd->bm wild pointer on error mm: slub: fix conversion of freelist_corrupted() vfio/type1: Support faulting PFNMAP vmas vfio-pci: Fault mmaps to enable vma tracking vfio-pci: Invalidate mmaps and block MMIO access on disabled memory KVM: arm64: Add kvm_extable for vaxorcism code KVM: arm64: Defer guest entry when an asynchronous exception is pending KVM: arm64: Survive synchronous exceptions caused by AT instructions KVM: arm64: Set HCR_EL2.PTW to prevent AT taking synchronous exception net: refactor bind_bucket fastreuse into helper net: initialize fastreuse on inet_inherit_port vfio/pci: Fix SR-IOV VF handling with MMIO blocking checkpatch: fix the usage of capture group ( ... ) mm/hugetlb: fix a race between hugetlb sysctl handlers cfg80211: regulatory: reject invalid hints net: usb: Fix uninit-was-stored issue in asix_read_phy_addr() ALSA; firewire-tascam: exclude Tascam FE-8 from detection fs/affs: use octal for permissions affs: fix basic permission bits to actually work net: ethernet: mlx4: Fix memory allocation in mlx4_buddy_init() bnxt: don't enable NAPI until rings are ready netlabel: fix problems with mapping removal sctp: not disable bh in the whole sctp_get_port_local() net: disable netpoll on fresh napis Linux 4.9.236 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: I707909fadc45a09f6ecdacb81a294421af163664
291 lines
6.7 KiB
C
291 lines
6.7 KiB
C
/*
|
|
* tascam.c - a part of driver for TASCAM FireWire series
|
|
*
|
|
* Copyright (c) 2015 Takashi Sakamoto
|
|
*
|
|
* Licensed under the terms of the GNU General Public License, version 2.
|
|
*/
|
|
|
|
#include "tascam.h"
|
|
|
|
MODULE_DESCRIPTION("TASCAM FireWire series Driver");
|
|
MODULE_AUTHOR("Takashi Sakamoto <o-takashi@sakamocchi.jp>");
|
|
MODULE_LICENSE("GPL v2");
|
|
|
|
static struct snd_tscm_spec model_specs[] = {
|
|
{
|
|
.name = "FW-1884",
|
|
.has_adat = true,
|
|
.has_spdif = true,
|
|
.pcm_capture_analog_channels = 8,
|
|
.pcm_playback_analog_channels = 8,
|
|
.midi_capture_ports = 4,
|
|
.midi_playback_ports = 4,
|
|
},
|
|
{
|
|
.name = "FW-1082",
|
|
.has_adat = false,
|
|
.has_spdif = true,
|
|
.pcm_capture_analog_channels = 8,
|
|
.pcm_playback_analog_channels = 2,
|
|
.midi_capture_ports = 2,
|
|
.midi_playback_ports = 2,
|
|
},
|
|
{
|
|
.name = "FW-1804",
|
|
.has_adat = true,
|
|
.has_spdif = true,
|
|
.pcm_capture_analog_channels = 8,
|
|
.pcm_playback_analog_channels = 2,
|
|
.midi_capture_ports = 2,
|
|
.midi_playback_ports = 4,
|
|
},
|
|
};
|
|
|
|
static int identify_model(struct snd_tscm *tscm)
|
|
{
|
|
struct fw_device *fw_dev = fw_parent_device(tscm->unit);
|
|
const u32 *config_rom = fw_dev->config_rom;
|
|
char model[9];
|
|
unsigned int i;
|
|
u8 c;
|
|
|
|
if (fw_dev->config_rom_length < 30) {
|
|
dev_err(&tscm->unit->device,
|
|
"Configuration ROM is too short.\n");
|
|
return -ENODEV;
|
|
}
|
|
|
|
/* Pick up model name from certain addresses. */
|
|
for (i = 0; i < 8; i++) {
|
|
c = config_rom[28 + i / 4] >> (24 - 8 * (i % 4));
|
|
if (c == '\0')
|
|
break;
|
|
model[i] = c;
|
|
}
|
|
model[i] = '\0';
|
|
|
|
for (i = 0; i < ARRAY_SIZE(model_specs); i++) {
|
|
if (strcmp(model, model_specs[i].name) == 0) {
|
|
tscm->spec = &model_specs[i];
|
|
break;
|
|
}
|
|
}
|
|
if (tscm->spec == NULL)
|
|
return -ENODEV;
|
|
|
|
strcpy(tscm->card->driver, "FW-TASCAM");
|
|
strcpy(tscm->card->shortname, model);
|
|
strcpy(tscm->card->mixername, model);
|
|
snprintf(tscm->card->longname, sizeof(tscm->card->longname),
|
|
"TASCAM %s, GUID %08x%08x at %s, S%d", model,
|
|
fw_dev->config_rom[3], fw_dev->config_rom[4],
|
|
dev_name(&tscm->unit->device), 100 << fw_dev->max_speed);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void tscm_free(struct snd_tscm *tscm)
|
|
{
|
|
snd_tscm_transaction_unregister(tscm);
|
|
snd_tscm_stream_destroy_duplex(tscm);
|
|
|
|
fw_unit_put(tscm->unit);
|
|
|
|
mutex_destroy(&tscm->mutex);
|
|
kfree(tscm);
|
|
}
|
|
|
|
static void tscm_card_free(struct snd_card *card)
|
|
{
|
|
tscm_free(card->private_data);
|
|
}
|
|
|
|
static void do_registration(struct work_struct *work)
|
|
{
|
|
struct snd_tscm *tscm = container_of(work, struct snd_tscm, dwork.work);
|
|
int err;
|
|
|
|
err = snd_card_new(&tscm->unit->device, -1, NULL, THIS_MODULE, 0,
|
|
&tscm->card);
|
|
if (err < 0)
|
|
return;
|
|
|
|
err = identify_model(tscm);
|
|
if (err < 0)
|
|
goto error;
|
|
|
|
err = snd_tscm_transaction_register(tscm);
|
|
if (err < 0)
|
|
goto error;
|
|
|
|
err = snd_tscm_stream_init_duplex(tscm);
|
|
if (err < 0)
|
|
goto error;
|
|
|
|
snd_tscm_proc_init(tscm);
|
|
|
|
err = snd_tscm_create_pcm_devices(tscm);
|
|
if (err < 0)
|
|
goto error;
|
|
|
|
err = snd_tscm_create_midi_devices(tscm);
|
|
if (err < 0)
|
|
goto error;
|
|
|
|
err = snd_tscm_create_hwdep_device(tscm);
|
|
if (err < 0)
|
|
goto error;
|
|
|
|
err = snd_card_register(tscm->card);
|
|
if (err < 0)
|
|
goto error;
|
|
|
|
/*
|
|
* After registered, tscm instance can be released corresponding to
|
|
* releasing the sound card instance.
|
|
*/
|
|
tscm->card->private_free = tscm_card_free;
|
|
tscm->card->private_data = tscm;
|
|
tscm->registered = true;
|
|
|
|
return;
|
|
error:
|
|
snd_tscm_transaction_unregister(tscm);
|
|
snd_tscm_stream_destroy_duplex(tscm);
|
|
snd_card_free(tscm->card);
|
|
dev_info(&tscm->unit->device,
|
|
"Sound card registration failed: %d\n", err);
|
|
}
|
|
|
|
static int snd_tscm_probe(struct fw_unit *unit,
|
|
const struct ieee1394_device_id *entry)
|
|
{
|
|
struct snd_tscm *tscm;
|
|
|
|
/* Allocate this independent of sound card instance. */
|
|
tscm = kzalloc(sizeof(struct snd_tscm), GFP_KERNEL);
|
|
if (tscm == NULL)
|
|
return -ENOMEM;
|
|
|
|
/* initialize myself */
|
|
tscm->unit = fw_unit_get(unit);
|
|
dev_set_drvdata(&unit->device, tscm);
|
|
|
|
mutex_init(&tscm->mutex);
|
|
spin_lock_init(&tscm->lock);
|
|
init_waitqueue_head(&tscm->hwdep_wait);
|
|
|
|
/* Allocate and register this sound card later. */
|
|
INIT_DEFERRABLE_WORK(&tscm->dwork, do_registration);
|
|
snd_fw_schedule_registration(unit, &tscm->dwork);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void snd_tscm_update(struct fw_unit *unit)
|
|
{
|
|
struct snd_tscm *tscm = dev_get_drvdata(&unit->device);
|
|
|
|
/* Postpone a workqueue for deferred registration. */
|
|
if (!tscm->registered)
|
|
snd_fw_schedule_registration(unit, &tscm->dwork);
|
|
|
|
snd_tscm_transaction_reregister(tscm);
|
|
|
|
/*
|
|
* After registration, userspace can start packet streaming, then this
|
|
* code block works fine.
|
|
*/
|
|
if (tscm->registered) {
|
|
mutex_lock(&tscm->mutex);
|
|
snd_tscm_stream_update_duplex(tscm);
|
|
mutex_unlock(&tscm->mutex);
|
|
}
|
|
}
|
|
|
|
static void snd_tscm_remove(struct fw_unit *unit)
|
|
{
|
|
struct snd_tscm *tscm = dev_get_drvdata(&unit->device);
|
|
|
|
/*
|
|
* Confirm to stop the work for registration before the sound card is
|
|
* going to be released. The work is not scheduled again because bus
|
|
* reset handler is not called anymore.
|
|
*/
|
|
cancel_delayed_work_sync(&tscm->dwork);
|
|
|
|
if (tscm->registered) {
|
|
/* No need to wait for releasing card object in this context. */
|
|
snd_card_free_when_closed(tscm->card);
|
|
} else {
|
|
/* Don't forget this case. */
|
|
tscm_free(tscm);
|
|
}
|
|
}
|
|
|
|
static const struct ieee1394_device_id snd_tscm_id_table[] = {
|
|
// Tascam, FW-1884.
|
|
{
|
|
.match_flags = IEEE1394_MATCH_VENDOR_ID |
|
|
IEEE1394_MATCH_SPECIFIER_ID |
|
|
IEEE1394_MATCH_VERSION,
|
|
.vendor_id = 0x00022e,
|
|
.specifier_id = 0x00022e,
|
|
.version = 0x800000,
|
|
},
|
|
// Tascam, FE-8 (.version = 0x800001)
|
|
// This kernel module doesn't support FE-8 because the most of features
|
|
// can be implemented in userspace without any specific support of this
|
|
// module.
|
|
//
|
|
// .version = 0x800002 is unknown.
|
|
//
|
|
// Tascam, FW-1082.
|
|
{
|
|
.match_flags = IEEE1394_MATCH_VENDOR_ID |
|
|
IEEE1394_MATCH_SPECIFIER_ID |
|
|
IEEE1394_MATCH_VERSION,
|
|
.vendor_id = 0x00022e,
|
|
.specifier_id = 0x00022e,
|
|
.version = 0x800003,
|
|
},
|
|
// Tascam, FW-1804.
|
|
{
|
|
.match_flags = IEEE1394_MATCH_VENDOR_ID |
|
|
IEEE1394_MATCH_SPECIFIER_ID |
|
|
IEEE1394_MATCH_VERSION,
|
|
.vendor_id = 0x00022e,
|
|
.specifier_id = 0x00022e,
|
|
.version = 0x800004,
|
|
},
|
|
/* FE-08 requires reverse-engineering because it just has faders. */
|
|
{}
|
|
};
|
|
MODULE_DEVICE_TABLE(ieee1394, snd_tscm_id_table);
|
|
|
|
static struct fw_driver tscm_driver = {
|
|
.driver = {
|
|
.owner = THIS_MODULE,
|
|
.name = "snd-firewire-tascam",
|
|
.bus = &fw_bus_type,
|
|
},
|
|
.probe = snd_tscm_probe,
|
|
.update = snd_tscm_update,
|
|
.remove = snd_tscm_remove,
|
|
.id_table = snd_tscm_id_table,
|
|
};
|
|
|
|
static int __init snd_tscm_init(void)
|
|
{
|
|
return driver_register(&tscm_driver.driver);
|
|
}
|
|
|
|
static void __exit snd_tscm_exit(void)
|
|
{
|
|
driver_unregister(&tscm_driver.driver);
|
|
}
|
|
|
|
module_init(snd_tscm_init);
|
|
module_exit(snd_tscm_exit);
|