2 * digi00x.h - a part of driver for Digidesign Digi 002/003 family
4 * Copyright (c) 2014-2015 Takashi Sakamoto
6 * Licensed under the terms of the GNU General Public License, version 2.
9 #ifndef SOUND_DIGI00X_H_INCLUDED
10 #define SOUND_DIGI00X_H_INCLUDED
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>
20 #include <sound/core.h>
21 #include <sound/initval.h>
22 #include <sound/pcm.h>
23 #include <sound/pcm_params.h>
26 #include "../iso-resources.h"
27 #include "../amdtp-stream.h"
30 struct snd_card
*card
;
35 struct amdtp_stream tx_stream
;
36 struct fw_iso_resources tx_resources
;
38 struct amdtp_stream rx_stream
;
39 struct fw_iso_resources rx_resources
;
41 unsigned int substreams_counter
;
44 #define DG00X_ADDR_BASE 0xffffe0000000ull
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 */
51 #define DG00X_OFFSET_MESSAGE_ADDR 0x0014
52 /* For LSB of the address 0x0018 */
55 /* not used 0x0024--0x00ff */
56 #define DG00X_OFFSET_ISOC_CHANNELS 0x0100
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
65 /* Mixer control on/off 0x0124 */
67 #define DG00X_OFFSET_DETECT_EXTERNAL 0x012c
69 #define DG00X_OFFSET_MMC 0x0400
72 SND_DG00X_RATE_44100
= 0,
79 enum snd_dg00x_clock
{
80 SND_DG00X_CLOCK_INTERNAL
= 0,
81 SND_DG00X_CLOCK_SPDIF
,
84 SND_DG00X_CLOCK_COUNT
,
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
);
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
,
101 int snd_dg00x_stream_get_local_rate(struct snd_dg00x
*dg00x
,
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
,
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
);