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