All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: clemens@ladisch.de, tiwai@suse.de
Cc: alsa-devel@alsa-project.org, ffado-devel@lists.sf.net
Subject: [PATCH 17/25] ALSA: firewire-tascam: add skeleton for TASCAM FireWire series
Date: Sat, 22 Aug 2015 18:19:33 +0900	[thread overview]
Message-ID: <1440235181-18181-18-git-send-email-o-takashi@sakamocchi.jp> (raw)
In-Reply-To: <1440235181-18181-1-git-send-email-o-takashi@sakamocchi.jp>

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 is 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 enable to work. Or adding another
node on the bus.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 sound/firewire/Kconfig         |  11 +++
 sound/firewire/Makefile        |   1 +
 sound/firewire/tascam/Makefile |   2 +
 sound/firewire/tascam/tascam.c | 155 +++++++++++++++++++++++++++++++++++++++++
 sound/firewire/tascam/tascam.h |  28 ++++++++
 5 files changed, 197 insertions(+)
 create mode 100644 sound/firewire/tascam/Makefile
 create mode 100644 sound/firewire/tascam/tascam.c
 create mode 100644 sound/firewire/tascam/tascam.h

diff --git a/sound/firewire/Kconfig b/sound/firewire/Kconfig
index 80f3b57..605cb91 100644
--- a/sound/firewire/Kconfig
+++ b/sound/firewire/Kconfig
@@ -135,4 +135,15 @@ config SND_FIREWIRE_DIGI00X
 	 To compile this driver as a module, choose M here: the module
 	 will be called snd-firewire-digi00x.
 
+config SND_FIREWIRE_TASCAM
+	tristate "TASCAM FireWire series support"
+	select SND_FIREWIRE_LIB
+	help
+	 Say Y here to include support for TASCAM.
+	  * FW-1884
+	  * FW-1082
+
+	 To compile this driver as a module, choose M here: the module
+	 will be called snd-firewire-tascam.
+
 endif # SND_FIREWIRE
diff --git a/sound/firewire/Makefile b/sound/firewire/Makefile
index 5325d15..6ae50f5 100644
--- a/sound/firewire/Makefile
+++ b/sound/firewire/Makefile
@@ -12,3 +12,4 @@ obj-$(CONFIG_SND_SCS1X) += snd-scs1x.o
 obj-$(CONFIG_SND_FIREWORKS) += fireworks/
 obj-$(CONFIG_SND_BEBOB) += bebob/
 obj-$(CONFIG_SND_FIREWIRE_DIGI00X) += digi00x/
+obj-$(CONFIG_SND_FIREWIRE_TASCAM) += tascam/
diff --git a/sound/firewire/tascam/Makefile b/sound/firewire/tascam/Makefile
new file mode 100644
index 0000000..627129b
--- /dev/null
+++ b/sound/firewire/tascam/Makefile
@@ -0,0 +1,2 @@
+snd-firewire-tascam-objs := tascam.o
+obj-$(CONFIG_SND_FIREWIRE_TASCAM) += snd-firewire-tascam.o
diff --git a/sound/firewire/tascam/tascam.c b/sound/firewire/tascam/tascam.c
new file mode 100644
index 0000000..9f2d2a3
--- /dev/null
+++ b/sound/firewire/tascam/tascam.c
@@ -0,0 +1,155 @@
+/*
+ * 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 int check_name(struct snd_tscm *tscm)
+{
+	struct fw_device *fw_dev = fw_parent_device(tscm->unit);
+	char vendor[8];
+	char model[8];
+	__u32 data;
+
+	/* Retrieve model name. */
+	data = be32_to_cpu(fw_dev->config_rom[28]);
+	memcpy(model, &data, 4);
+	data = be32_to_cpu(fw_dev->config_rom[29]);
+	memcpy(model + 4, &data, 4);
+	model[7] = '\0';
+
+	/* Retrieve vendor name. */
+	data = be32_to_cpu(fw_dev->config_rom[23]);
+	memcpy(vendor, &data, 4);
+	data = be32_to_cpu(fw_dev->config_rom[24]);
+	memcpy(vendor + 4, &data, 4);
+	vendor[7] = '\0';
+
+	strcpy(tscm->card->driver, "FW-TASCAM");
+	strcpy(tscm->card->shortname, model);
+	strcpy(tscm->card->mixername, model);
+	snprintf(tscm->card->longname, sizeof(tscm->card->longname),
+		 "%s %s, GUID %08x%08x at %s, S%d", vendor, model,
+		 cpu_to_be32(fw_dev->config_rom[3]),
+		 cpu_to_be32(fw_dev->config_rom[4]),
+		 dev_name(&tscm->unit->device), 100 << fw_dev->max_speed);
+
+	return 0;
+}
+
+static void tscm_card_free(struct snd_card *card)
+{
+	struct snd_tscm *tscm = card->private_data;
+
+	fw_unit_put(tscm->unit);
+
+	mutex_destroy(&tscm->mutex);
+}
+
+static int snd_tscm_probe(struct fw_unit *unit,
+			   const struct ieee1394_device_id *entry)
+{
+	struct snd_card *card;
+	struct snd_tscm *tscm;
+	int err;
+
+	/* create card */
+	err = snd_card_new(&unit->device, -1, NULL, THIS_MODULE,
+			   sizeof(struct snd_tscm), &card);
+	if (err < 0)
+		return err;
+	card->private_free = tscm_card_free;
+
+	/* initialize myself */
+	tscm = card->private_data;
+	tscm->card = card;
+	tscm->unit = fw_unit_get(unit);
+
+	mutex_init(&tscm->mutex);
+
+	err = check_name(tscm);
+	if (err < 0)
+		goto error;
+
+	err = snd_card_register(card);
+	if (err < 0)
+		goto error;
+
+	dev_set_drvdata(&unit->device, tscm);
+
+	return err;
+error:
+	snd_card_free(card);
+	return err;
+}
+
+static void snd_tscm_update(struct fw_unit *unit)
+{
+	return;
+}
+
+static void snd_tscm_remove(struct fw_unit *unit)
+{
+	struct snd_tscm *tscm = dev_get_drvdata(&unit->device);
+
+	/* No need to wait for releasing card object in this context. */
+	snd_card_free_when_closed(tscm->card);
+}
+
+static const struct ieee1394_device_id snd_tscm_id_table[] = {
+	/* FW-1082 */
+	{
+		.match_flags = IEEE1394_MATCH_VENDOR_ID |
+			       IEEE1394_MATCH_SPECIFIER_ID |
+			       IEEE1394_MATCH_VERSION,
+		.vendor_id = 0x00022e,
+		.specifier_id = 0x00022e,
+		.version = 0x800003,
+	},
+	/* FW-1884 */
+	{
+		.match_flags = IEEE1394_MATCH_VENDOR_ID |
+			       IEEE1394_MATCH_SPECIFIER_ID |
+			       IEEE1394_MATCH_VERSION,
+		.vendor_id = 0x00022e,
+		.specifier_id = 0x00022e,
+		.version = 0x800000,
+	},
+	/* FW-1804 mey be supported if IDs are clear. */
+	/* 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);
diff --git a/sound/firewire/tascam/tascam.h b/sound/firewire/tascam/tascam.h
new file mode 100644
index 0000000..ca6b6b1
--- /dev/null
+++ b/sound/firewire/tascam/tascam.h
@@ -0,0 +1,28 @@
+/*
+ * tascam.h - 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 <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>
+#include <linux/compat.h>
+
+#include <sound/core.h>
+#include <sound/initval.h>
+
+#include "../lib.h"
+
+struct snd_tscm {
+	struct snd_card *card;
+	struct fw_unit *unit;
+
+	struct mutex mutex;
+};
-- 
2.1.4

  parent reply	other threads:[~2015-08-22  9:19 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-22  9:19 [PATCH 00/25 v2] ALSA: support AMDTP variants Takashi Sakamoto
2015-08-22  9:19 ` [PATCH 01/25] ALSA: firewire-lib: rename 'amdtp' to 'amdtp-stream' for functional separation Takashi Sakamoto
2015-08-22  9:19 ` [PATCH 02/25] ALSA: firewire-lib: functional separation for packet transmission layer and data processing layer Takashi Sakamoto
2015-08-22  9:19 ` [PATCH 03/25] ALSA: firewire-lib: add helper functions for asynchronous MIDI port Takashi Sakamoto
2015-08-22  9:19 ` [PATCH 04/25] ALSA: firewire-lib: add a restriction for a transaction at once Takashi Sakamoto
2015-08-22  9:19 ` [PATCH 05/25] ALSA: firewire-lib: schedule tasklet again when MIDI substream has rest of MIDI messages Takashi Sakamoto
2015-08-22  9:19 ` [PATCH 06/25] ALSA: firewire-lib: add throttle for MIDI data rate Takashi Sakamoto
2015-08-22  9:19 ` [PATCH 07/25] ALSA: firewire-lib: avoid endless loop to transfer MIDI messages at fatal error Takashi Sakamoto
2015-08-22  9:19 ` [PATCH 08/25] ALSA: firewire-digi00x: add skeleton for Digi 002/003 family Takashi Sakamoto
2015-08-22  9:19 ` [PATCH 09/25] ALSA: firewire-digi00x: add data processing layer Takashi Sakamoto
2015-08-22  9:19 ` [PATCH 10/25] ALSA: firewire-digi00x: add stream functionality Takashi Sakamoto
2015-08-22  9:19 ` [PATCH 11/25] ALSA: firewire-digi00x: add proc node to show clock status Takashi Sakamoto
2015-08-22  9:19 ` [PATCH 12/25] ALSA: firewire-digi00x: add PCM functionality Takashi Sakamoto
2015-08-22  9:19 ` [PATCH 13/25] ALSA: firewire-digi00x: add MIDI functionality Takashi Sakamoto
2015-08-22  9:19 ` [PATCH 14/25] ALSA: firewire-digi00x: add hwdep interface Takashi Sakamoto
2015-08-22  9:19 ` [PATCH 15/25] ALSA: firewire-digi00x: add support for asynchronous messaging Takashi Sakamoto
2015-08-22  9:19 ` [PATCH 16/25] ALSA: firewire-digi00x: add support for MIDI ports for machine control Takashi Sakamoto
2015-08-22  9:19 ` Takashi Sakamoto [this message]
2015-08-22  9:19 ` [PATCH 18/25] ALSA: firewire-tascam: add a structure for model-dependent parameters Takashi Sakamoto
2015-08-22  9:19 ` [PATCH 19/25] ALSA: firewire-tascam: add proc node to show firmware information Takashi Sakamoto
2015-08-22  9:19 ` [PATCH 20/25] ALSA: firewire-tascam: add data processing layer Takashi Sakamoto
2015-08-22  9:19 ` [PATCH 21/25] ALSA: firewire-tascam: add streaming functionality Takashi Sakamoto
2015-08-22  9:19 ` [PATCH 22/25] ALSA: firewire-tascam: add PCM functionality Takashi Sakamoto
2015-08-24 21:12   ` Takashi Iwai
2015-08-25 11:56     ` Takashi Sakamoto
2015-08-22  9:19 ` [PATCH 23/25] ALSA: firewire-tascam: add transaction functionality Takashi Sakamoto
2015-08-22  9:19 ` [PATCH 24/25] ALSA: firewire-tascam: add MIDI functionality Takashi Sakamoto
2015-08-24 20:59   ` Takashi Iwai
2015-08-22  9:19 ` [PATCH 25/25] ALSA: firewire-tascam: add hwdep interface Takashi Sakamoto
2015-08-23  8:04 ` [PATCH 00/25 v2] ALSA: support AMDTP variants Takashi Iwai
2015-08-23 14:58   ` Takashi Sakamoto
2015-08-24  6:26     ` Takashi Iwai
2015-08-25  5:24       ` Takashi Iwai
2015-08-25 11:47         ` Takashi Sakamoto
2015-08-25 12:03           ` Takashi Iwai
2015-08-29  6:00             ` Takashi Sakamoto
  -- strict thread matches above, loose matches on Subject: below --
2015-08-13  0:19 [PATCH 00/25] " Takashi Sakamoto
2015-08-13  0:20 ` [PATCH 17/25] ALSA: firewire-tascam: add skeleton for TASCAM FireWire series Takashi Sakamoto
2015-08-13  6:24   ` Takashi Iwai
2015-08-13  7:18     ` Takashi Sakamoto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1440235181-18181-18-git-send-email-o-takashi@sakamocchi.jp \
    --to=o-takashi@sakamocchi.jp \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    --cc=ffado-devel@lists.sf.net \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.