]> git.karo-electronics.de Git - linux-beck.git/blob - sound/firewire/digi00x/digi00x.h
685d5f01ee0dc54faf87527ffd7b4ebbf237431e
[linux-beck.git] / sound / firewire / digi00x / digi00x.h
1 /*
2  * digi00x.h - a part of driver for Digidesign Digi 002/003 family
3  *
4  * Copyright (c) 2014-2015 Takashi Sakamoto
5  *
6  * Licensed under the terms of the GNU General Public License, version 2.
7  */
8
9 #ifndef SOUND_DIGI00X_H_INCLUDED
10 #define SOUND_DIGI00X_H_INCLUDED
11
12 #include <linux/compat.h>
13 #include <linux/device.h>
14 #include <linux/firewire.h>
15 #include <linux/module.h>
16 #include <linux/mod_devicetable.h>
17 #include <linux/delay.h>
18 #include <linux/slab.h>
19
20 #include <sound/core.h>
21 #include <sound/initval.h>
22 #include <sound/pcm.h>
23 #include <sound/pcm_params.h>
24
25 #include "../lib.h"
26 #include "../iso-resources.h"
27 #include "../amdtp-stream.h"
28
29 struct snd_dg00x {
30         struct snd_card *card;
31         struct fw_unit *unit;
32
33         struct mutex mutex;
34
35         struct amdtp_stream tx_stream;
36         struct fw_iso_resources tx_resources;
37
38         struct amdtp_stream rx_stream;
39         struct fw_iso_resources rx_resources;
40
41         unsigned int substreams_counter;
42 };
43
44 #define DG00X_ADDR_BASE         0xffffe0000000ull
45
46 #define DG00X_OFFSET_STREAMING_STATE    0x0000
47 #define DG00X_OFFSET_STREAMING_SET      0x0004
48 #define DG00X_OFFSET_MIDI_CTL_ADDR      0x0008
49 /* For LSB of the address               0x000c */
50 /* unknown                              0x0010 */
51 #define DG00X_OFFSET_MESSAGE_ADDR       0x0014
52 /* For LSB of the address               0x0018 */
53 /* unknown                              0x001c */
54 /* unknown                              0x0020 */
55 /* not used                     0x0024--0x00ff */
56 #define DG00X_OFFSET_ISOC_CHANNELS      0x0100
57 /* unknown                              0x0104 */
58 /* unknown                              0x0108 */
59 /* unknown                              0x010c */
60 #define DG00X_OFFSET_LOCAL_RATE         0x0110
61 #define DG00X_OFFSET_EXTERNAL_RATE      0x0114
62 #define DG00X_OFFSET_CLOCK_SOURCE       0x0118
63 #define DG00X_OFFSET_OPT_IFACE_MODE     0x011c
64 /* unknown                              0x0120 */
65 /* Mixer control on/off                 0x0124 */
66 /* unknown                              0x0128 */
67 #define DG00X_OFFSET_DETECT_EXTERNAL    0x012c
68 /* unknown                              0x0138 */
69 #define DG00X_OFFSET_MMC                0x0400
70
71 enum snd_dg00x_rate {
72         SND_DG00X_RATE_44100 = 0,
73         SND_DG00X_RATE_48000,
74         SND_DG00X_RATE_88200,
75         SND_DG00X_RATE_96000,
76         SND_DG00X_RATE_COUNT,
77 };
78
79 enum snd_dg00x_clock {
80         SND_DG00X_CLOCK_INTERNAL = 0,
81         SND_DG00X_CLOCK_SPDIF,
82         SND_DG00X_CLOCK_ADAT,
83         SND_DG00X_CLOCK_WORD,
84         SND_DG00X_CLOCK_COUNT,
85 };
86
87 int amdtp_dot_init(struct amdtp_stream *s, struct fw_unit *unit,
88                    enum amdtp_stream_direction dir);
89 int amdtp_dot_set_parameters(struct amdtp_stream *s, unsigned int rate,
90                              unsigned int pcm_channels,
91                              unsigned int midi_ports);
92 void amdtp_dot_reset(struct amdtp_stream *s);
93 int amdtp_dot_add_pcm_hw_constraints(struct amdtp_stream *s,
94                                      struct snd_pcm_runtime *runtime);
95 void amdtp_dot_set_pcm_format(struct amdtp_stream *s, snd_pcm_format_t format);
96
97 extern const unsigned int snd_dg00x_stream_rates[SND_DG00X_RATE_COUNT];
98 extern const unsigned int snd_dg00x_stream_pcm_channels[SND_DG00X_RATE_COUNT];
99 int snd_dg00x_stream_get_external_rate(struct snd_dg00x *dg00x,
100                                        unsigned int *rate);
101 int snd_dg00x_stream_get_local_rate(struct snd_dg00x *dg00x,
102                                     unsigned int *rate);
103 int snd_dg00x_stream_set_local_rate(struct snd_dg00x *dg00x, unsigned int rate);
104 int snd_dg00x_stream_get_clock(struct snd_dg00x *dg00x,
105                                enum snd_dg00x_clock *clock);
106 int snd_dg00x_stream_check_external_clock(struct snd_dg00x *dg00x,
107                                           bool *detect);
108 int snd_dg00x_stream_init_duplex(struct snd_dg00x *dg00x);
109 int snd_dg00x_stream_start_duplex(struct snd_dg00x *dg00x, unsigned int rate);
110 void snd_dg00x_stream_stop_duplex(struct snd_dg00x *dg00x);
111 void snd_dg00x_stream_update_duplex(struct snd_dg00x *dg00x);
112 void snd_dg00x_stream_destroy_duplex(struct snd_dg00x *dg00x);
113
114 #endif