Commit | Line | Data |
---|---|---|
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> | |
20 | ||
21 | #include <sound/core.h> | |
22 | #include <sound/initval.h> | |
96e5fbb0 | 23 | #include <sound/info.h> |
47faeea2 TS |
24 | #include <sound/pcm.h> |
25 | #include <sound/pcm_params.h> | |
c0949b27 TS |
26 | |
27 | #include "../lib.h" | |
47faeea2 | 28 | #include "../amdtp-stream.h" |
35efa5c4 | 29 | #include "../iso-resources.h" |
c0949b27 | 30 | |
6f81ba19 TS |
31 | struct snd_tscm_spec { |
32 | const char *const name; | |
33 | bool has_adat; | |
34 | bool has_spdif; | |
35 | unsigned int pcm_capture_analog_channels; | |
36 | unsigned int pcm_playback_analog_channels; | |
37 | unsigned int midi_capture_ports; | |
38 | unsigned int midi_playback_ports; | |
39 | bool is_controller; | |
40 | }; | |
41 | ||
c0949b27 TS |
42 | struct snd_tscm { |
43 | struct snd_card *card; | |
44 | struct fw_unit *unit; | |
45 | ||
46 | struct mutex mutex; | |
6f81ba19 TS |
47 | |
48 | const struct snd_tscm_spec *spec; | |
35efa5c4 TS |
49 | |
50 | struct fw_iso_resources tx_resources; | |
51 | struct fw_iso_resources rx_resources; | |
52 | struct amdtp_stream tx_stream; | |
53 | struct amdtp_stream rx_stream; | |
54 | unsigned int substreams_counter; | |
c0949b27 TS |
55 | }; |
56 | ||
96e5fbb0 TS |
57 | #define TSCM_ADDR_BASE 0xffff00000000ull |
58 | ||
59 | #define TSCM_OFFSET_FIRMWARE_REGISTER 0x0000 | |
60 | #define TSCM_OFFSET_FIRMWARE_FPGA 0x0004 | |
61 | #define TSCM_OFFSET_FIRMWARE_ARM 0x0008 | |
62 | #define TSCM_OFFSET_FIRMWARE_HW 0x000c | |
63 | ||
35efa5c4 TS |
64 | #define TSCM_OFFSET_ISOC_TX_CH 0x0200 |
65 | #define TSCM_OFFSET_UNKNOWN 0x0204 | |
66 | #define TSCM_OFFSET_START_STREAMING 0x0208 | |
67 | #define TSCM_OFFSET_ISOC_RX_CH 0x020c | |
68 | #define TSCM_OFFSET_ISOC_RX_ON 0x0210 /* Little conviction. */ | |
69 | #define TSCM_OFFSET_TX_PCM_CHANNELS 0x0214 | |
70 | #define TSCM_OFFSET_RX_PCM_CHANNELS 0x0218 | |
71 | #define TSCM_OFFSET_MULTIPLEX_MODE 0x021c | |
72 | #define TSCM_OFFSET_ISOC_TX_ON 0x0220 | |
73 | /* Unknown 0x0224 */ | |
74 | #define TSCM_OFFSET_CLOCK_STATUS 0x0228 | |
75 | #define TSCM_OFFSET_SET_OPTION 0x022c | |
76 | ||
77 | enum snd_tscm_clock { | |
78 | SND_TSCM_CLOCK_INTERNAL = 0, | |
79 | SND_TSCM_CLOCK_WORD = 1, | |
80 | SND_TSCM_CLOCK_SPDIF = 2, | |
81 | SND_TSCM_CLOCK_ADAT = 3, | |
82 | }; | |
83 | ||
47faeea2 TS |
84 | int amdtp_tscm_init(struct amdtp_stream *s, struct fw_unit *unit, |
85 | enum amdtp_stream_direction dir, unsigned int pcm_channels); | |
86 | int amdtp_tscm_set_parameters(struct amdtp_stream *s, unsigned int rate); | |
87 | int amdtp_tscm_add_pcm_hw_constraints(struct amdtp_stream *s, | |
88 | struct snd_pcm_runtime *runtime); | |
89 | void amdtp_tscm_set_pcm_format(struct amdtp_stream *s, snd_pcm_format_t format); | |
90 | ||
35efa5c4 TS |
91 | int snd_tscm_stream_get_rate(struct snd_tscm *tscm, unsigned int *rate); |
92 | int snd_tscm_stream_get_clock(struct snd_tscm *tscm, | |
93 | enum snd_tscm_clock *clock); | |
94 | int snd_tscm_stream_init_duplex(struct snd_tscm *tscm); | |
95 | void snd_tscm_stream_update_duplex(struct snd_tscm *tscm); | |
96 | void snd_tscm_stream_destroy_duplex(struct snd_tscm *tscm); | |
97 | int snd_tscm_stream_start_duplex(struct snd_tscm *tscm, unsigned int rate); | |
98 | void snd_tscm_stream_stop_duplex(struct snd_tscm *tscm); | |
99 | ||
96e5fbb0 TS |
100 | void snd_tscm_proc_init(struct snd_tscm *tscm); |
101 | ||
e453df44 TS |
102 | int snd_tscm_create_pcm_devices(struct snd_tscm *tscm); |
103 | ||
c0949b27 | 104 | #endif |