]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - sound/firewire/tascam/tascam.h
sched/headers: Prepare to move signal wakeup & sigpending methods from <linux/sched...
[mirror_ubuntu-artful-kernel.git] / sound / firewire / tascam / tascam.h
CommitLineData
c0949b27
TS
1/*
2 * tascam.h - a part of driver for TASCAM FireWire series
3 *
4 * Copyright (c) 2015 Takashi Sakamoto
5 *
6 * Licensed under the terms of the GNU General Public License, version 2.
7 */
8
9#ifndef SOUND_TASCAM_H_INCLUDED
10#define SOUND_TASCAM_H_INCLUDED
11
12#include <linux/device.h>
13#include <linux/firewire.h>
14#include <linux/firewire-constants.h>
15#include <linux/module.h>
16#include <linux/mod_devicetable.h>
17#include <linux/mutex.h>
18#include <linux/slab.h>
19#include <linux/compat.h>
174cd4b1 20#include <linux/sched/signal.h>
c0949b27
TS
21
22#include <sound/core.h>
23#include <sound/initval.h>
96e5fbb0 24#include <sound/info.h>
47faeea2
TS
25#include <sound/pcm.h>
26#include <sound/pcm_params.h>
e5e0c3dd
TS
27#include <sound/firewire.h>
28#include <sound/hwdep.h>
107cc012 29#include <sound/rawmidi.h>
c0949b27
TS
30
31#include "../lib.h"
47faeea2 32#include "../amdtp-stream.h"
35efa5c4 33#include "../iso-resources.h"
c0949b27 34
6f81ba19
TS
35struct snd_tscm_spec {
36 const char *const name;
37 bool has_adat;
38 bool has_spdif;
39 unsigned int pcm_capture_analog_channels;
40 unsigned int pcm_playback_analog_channels;
41 unsigned int midi_capture_ports;
42 unsigned int midi_playback_ports;
6f81ba19
TS
43};
44
107cc012
TS
45#define TSCM_MIDI_IN_PORT_MAX 4
46#define TSCM_MIDI_OUT_PORT_MAX 4
47
c0949b27
TS
48struct snd_tscm {
49 struct snd_card *card;
50 struct fw_unit *unit;
51
52 struct mutex mutex;
e5e0c3dd 53 spinlock_t lock;
6f81ba19 54
b610386c
TS
55 bool registered;
56 struct delayed_work dwork;
6f81ba19 57 const struct snd_tscm_spec *spec;
35efa5c4
TS
58
59 struct fw_iso_resources tx_resources;
60 struct fw_iso_resources rx_resources;
61 struct amdtp_stream tx_stream;
62 struct amdtp_stream rx_stream;
63 unsigned int substreams_counter;
e5e0c3dd
TS
64
65 int dev_lock_count;
66 bool dev_lock_changed;
67 wait_queue_head_t hwdep_wait;
107cc012
TS
68
69 /* For MIDI message incoming transactions. */
70 struct fw_address_handler async_handler;
71 struct snd_rawmidi_substream *tx_midi_substreams[TSCM_MIDI_IN_PORT_MAX];
3beab0f8
TS
72
73 /* For MIDI message outgoing transactions. */
74 struct snd_fw_async_midi_port out_ports[TSCM_MIDI_OUT_PORT_MAX];
75 u8 running_status[TSCM_MIDI_OUT_PORT_MAX];
76 bool on_sysex[TSCM_MIDI_OUT_PORT_MAX];
c0949b27
TS
77};
78
96e5fbb0
TS
79#define TSCM_ADDR_BASE 0xffff00000000ull
80
81#define TSCM_OFFSET_FIRMWARE_REGISTER 0x0000
82#define TSCM_OFFSET_FIRMWARE_FPGA 0x0004
83#define TSCM_OFFSET_FIRMWARE_ARM 0x0008
84#define TSCM_OFFSET_FIRMWARE_HW 0x000c
85
35efa5c4
TS
86#define TSCM_OFFSET_ISOC_TX_CH 0x0200
87#define TSCM_OFFSET_UNKNOWN 0x0204
88#define TSCM_OFFSET_START_STREAMING 0x0208
89#define TSCM_OFFSET_ISOC_RX_CH 0x020c
90#define TSCM_OFFSET_ISOC_RX_ON 0x0210 /* Little conviction. */
91#define TSCM_OFFSET_TX_PCM_CHANNELS 0x0214
92#define TSCM_OFFSET_RX_PCM_CHANNELS 0x0218
93#define TSCM_OFFSET_MULTIPLEX_MODE 0x021c
94#define TSCM_OFFSET_ISOC_TX_ON 0x0220
95/* Unknown 0x0224 */
96#define TSCM_OFFSET_CLOCK_STATUS 0x0228
97#define TSCM_OFFSET_SET_OPTION 0x022c
98
107cc012
TS
99#define TSCM_OFFSET_MIDI_TX_ON 0x0300
100#define TSCM_OFFSET_MIDI_TX_ADDR_HI 0x0304
101#define TSCM_OFFSET_MIDI_TX_ADDR_LO 0x0308
102
e65e2cb9
TS
103#define TSCM_OFFSET_LED_POWER 0x0404
104
107cc012
TS
105#define TSCM_OFFSET_MIDI_RX_QUAD 0x4000
106
35efa5c4
TS
107enum snd_tscm_clock {
108 SND_TSCM_CLOCK_INTERNAL = 0,
109 SND_TSCM_CLOCK_WORD = 1,
110 SND_TSCM_CLOCK_SPDIF = 2,
111 SND_TSCM_CLOCK_ADAT = 3,
112};
113
47faeea2
TS
114int amdtp_tscm_init(struct amdtp_stream *s, struct fw_unit *unit,
115 enum amdtp_stream_direction dir, unsigned int pcm_channels);
116int amdtp_tscm_set_parameters(struct amdtp_stream *s, unsigned int rate);
117int amdtp_tscm_add_pcm_hw_constraints(struct amdtp_stream *s,
118 struct snd_pcm_runtime *runtime);
119void amdtp_tscm_set_pcm_format(struct amdtp_stream *s, snd_pcm_format_t format);
120
35efa5c4
TS
121int snd_tscm_stream_get_rate(struct snd_tscm *tscm, unsigned int *rate);
122int snd_tscm_stream_get_clock(struct snd_tscm *tscm,
123 enum snd_tscm_clock *clock);
124int snd_tscm_stream_init_duplex(struct snd_tscm *tscm);
125void snd_tscm_stream_update_duplex(struct snd_tscm *tscm);
126void snd_tscm_stream_destroy_duplex(struct snd_tscm *tscm);
127int snd_tscm_stream_start_duplex(struct snd_tscm *tscm, unsigned int rate);
128void snd_tscm_stream_stop_duplex(struct snd_tscm *tscm);
129
e5e0c3dd
TS
130void snd_tscm_stream_lock_changed(struct snd_tscm *tscm);
131int snd_tscm_stream_lock_try(struct snd_tscm *tscm);
132void snd_tscm_stream_lock_release(struct snd_tscm *tscm);
133
107cc012
TS
134int snd_tscm_transaction_register(struct snd_tscm *tscm);
135int snd_tscm_transaction_reregister(struct snd_tscm *tscm);
136void snd_tscm_transaction_unregister(struct snd_tscm *tscm);
137
96e5fbb0
TS
138void snd_tscm_proc_init(struct snd_tscm *tscm);
139
e453df44
TS
140int snd_tscm_create_pcm_devices(struct snd_tscm *tscm);
141
0db18e7e
TS
142int snd_tscm_create_midi_devices(struct snd_tscm *tscm);
143
e5e0c3dd
TS
144int snd_tscm_create_hwdep_device(struct snd_tscm *tscm);
145
c0949b27 146#endif