ALSA: bebob: obsolete useless member of private structure
[linux-2.6-block.git] / sound / firewire / bebob / bebob.h
CommitLineData
fd6f4b0d
TS
1/*
2 * bebob.h - a part of driver for BeBoB based devices
3 *
4 * Copyright (c) 2013-2014 Takashi Sakamoto
5 *
6 * Licensed under the terms of the GNU General Public License, version 2.
7 */
8
9#ifndef SOUND_BEBOB_H_INCLUDED
10#define SOUND_BEBOB_H_INCLUDED
11
12#include <linux/compat.h>
13#include <linux/device.h>
14#include <linux/firewire.h>
15#include <linux/firewire-constants.h>
16#include <linux/module.h>
17#include <linux/mod_devicetable.h>
18#include <linux/delay.h>
19#include <linux/slab.h>
174cd4b1 20#include <linux/sched/signal.h>
fd6f4b0d
TS
21
22#include <sound/core.h>
23#include <sound/initval.h>
ad9697ba 24#include <sound/info.h>
248b7802 25#include <sound/rawmidi.h>
fbbebd2c
TS
26#include <sound/pcm.h>
27#include <sound/pcm_params.h>
618eabea
TS
28#include <sound/firewire.h>
29#include <sound/hwdep.h>
fd6f4b0d
TS
30
31#include "../lib.h"
32#include "../fcp.h"
eb7b3a05
TS
33#include "../packets-buffer.h"
34#include "../iso-resources.h"
5955815e 35#include "../amdtp-am824.h"
eb7b3a05 36#include "../cmp.h"
fd6f4b0d
TS
37
38/* basic register addresses on DM1000/DM1100/DM1500 */
9b5f0edf
TS
39#define BEBOB_ADDR_REG_INFO 0xffffc8020000ULL
40#define BEBOB_ADDR_REG_REQ 0xffffc8021000ULL
fd6f4b0d 41
eb7b3a05
TS
42struct snd_bebob;
43
44#define SND_BEBOB_STRM_FMT_ENTRIES 7
45struct snd_bebob_stream_formation {
46 unsigned int pcm;
47 unsigned int midi;
48};
49/* this is a lookup table for index of stream formations */
50extern const unsigned int snd_bebob_rate_table[SND_BEBOB_STRM_FMT_ENTRIES];
51
1fc9522a 52/* device specific operations */
13a4f420
TS
53enum snd_bebob_clock_type {
54 SND_BEBOB_CLOCK_TYPE_INTERNAL = 0,
55 SND_BEBOB_CLOCK_TYPE_EXTERNAL,
56 SND_BEBOB_CLOCK_TYPE_SYT,
57};
1fc9522a
TS
58struct snd_bebob_clock_spec {
59 unsigned int num;
e7ced413 60 const char *const *labels;
782fbec7 61 const enum snd_bebob_clock_type *types;
1fc9522a
TS
62 int (*get)(struct snd_bebob *bebob, unsigned int *id);
63};
64struct snd_bebob_rate_spec {
65 int (*get)(struct snd_bebob *bebob, unsigned int *rate);
66 int (*set)(struct snd_bebob *bebob, unsigned int rate);
67};
68struct snd_bebob_meter_spec {
69 unsigned int num;
e7ced413 70 const char *const *labels;
1fc9522a
TS
71 int (*get)(struct snd_bebob *bebob, u32 *target, unsigned int size);
72};
73struct snd_bebob_spec {
6b9866c8
JL
74 const struct snd_bebob_clock_spec *clock;
75 const struct snd_bebob_rate_spec *rate;
76 const struct snd_bebob_meter_spec *meter;
1fc9522a
TS
77};
78
fd6f4b0d
TS
79struct snd_bebob {
80 struct snd_card *card;
81 struct fw_unit *unit;
82 int card_index;
83
84 struct mutex mutex;
85 spinlock_t lock;
eb7b3a05 86
04a2c73c
TS
87 bool registered;
88 struct delayed_work dwork;
89
90 const struct ieee1394_device_id *entry;
1fc9522a
TS
91 const struct snd_bebob_spec *spec;
92
eb7b3a05
TS
93 unsigned int midi_input_ports;
94 unsigned int midi_output_ports;
95
eb7b3a05
TS
96 struct amdtp_stream tx_stream;
97 struct amdtp_stream rx_stream;
98 struct cmp_connection out_conn;
99 struct cmp_connection in_conn;
4fd6c6c7 100 unsigned int substreams_counter;
eb7b3a05
TS
101
102 struct snd_bebob_stream_formation
103 tx_stream_formations[SND_BEBOB_STRM_FMT_ENTRIES];
104 struct snd_bebob_stream_formation
105 rx_stream_formations[SND_BEBOB_STRM_FMT_ENTRIES];
106
107 int sync_input_plug;
618eabea
TS
108
109 /* for uapi */
110 int dev_lock_count;
111 bool dev_lock_changed;
112 wait_queue_head_t hwdep_wait;
3149ac48
TS
113
114 /* for M-Audio special devices */
115 void *maudio_special_quirk;
7b4d7dcf
TS
116
117 /* For BeBoB version quirk. */
118 unsigned int version;
fd6f4b0d
TS
119};
120
121static inline int
122snd_bebob_read_block(struct fw_unit *unit, u64 addr, void *buf, int size)
123{
124 return snd_fw_transaction(unit, TCODE_READ_BLOCK_REQUEST,
125 BEBOB_ADDR_REG_INFO + addr,
126 buf, size, 0);
127}
128
129static inline int
130snd_bebob_read_quad(struct fw_unit *unit, u64 addr, u32 *buf)
131{
132 return snd_fw_transaction(unit, TCODE_READ_QUADLET_REQUEST,
133 BEBOB_ADDR_REG_INFO + addr,
134 (void *)buf, sizeof(u32), 0);
135}
136
1fc9522a
TS
137/* AV/C Audio Subunit Specification 1.0 (Oct 2000, 1394TA) */
138int avc_audio_set_selector(struct fw_unit *unit, unsigned int subunit_id,
139 unsigned int fb_id, unsigned int num);
140int avc_audio_get_selector(struct fw_unit *unit, unsigned int subunit_id,
141 unsigned int fb_id, unsigned int *num);
142
eb7b3a05
TS
143/*
144 * AVC command extensions, AV/C Unit and Subunit, Revision 17
145 * (Nov 2003, BridgeCo)
146 */
147#define AVC_BRIDGECO_ADDR_BYTES 6
148enum avc_bridgeco_plug_dir {
149 AVC_BRIDGECO_PLUG_DIR_IN = 0x00,
150 AVC_BRIDGECO_PLUG_DIR_OUT = 0x01
151};
152enum avc_bridgeco_plug_mode {
153 AVC_BRIDGECO_PLUG_MODE_UNIT = 0x00,
154 AVC_BRIDGECO_PLUG_MODE_SUBUNIT = 0x01,
155 AVC_BRIDGECO_PLUG_MODE_FUNCTION_BLOCK = 0x02
156};
157enum avc_bridgeco_plug_unit {
158 AVC_BRIDGECO_PLUG_UNIT_ISOC = 0x00,
159 AVC_BRIDGECO_PLUG_UNIT_EXT = 0x01,
160 AVC_BRIDGECO_PLUG_UNIT_ASYNC = 0x02
161};
162enum avc_bridgeco_plug_type {
163 AVC_BRIDGECO_PLUG_TYPE_ISOC = 0x00,
164 AVC_BRIDGECO_PLUG_TYPE_ASYNC = 0x01,
165 AVC_BRIDGECO_PLUG_TYPE_MIDI = 0x02,
166 AVC_BRIDGECO_PLUG_TYPE_SYNC = 0x03,
167 AVC_BRIDGECO_PLUG_TYPE_ANA = 0x04,
5a668812
TS
168 AVC_BRIDGECO_PLUG_TYPE_DIG = 0x05,
169 AVC_BRIDGECO_PLUG_TYPE_ADDITION = 0x06
eb7b3a05
TS
170};
171static inline void
172avc_bridgeco_fill_unit_addr(u8 buf[AVC_BRIDGECO_ADDR_BYTES],
173 enum avc_bridgeco_plug_dir dir,
174 enum avc_bridgeco_plug_unit unit,
175 unsigned int pid)
176{
177 buf[0] = 0xff; /* Unit */
178 buf[1] = dir;
179 buf[2] = AVC_BRIDGECO_PLUG_MODE_UNIT;
180 buf[3] = unit;
181 buf[4] = 0xff & pid;
182 buf[5] = 0xff; /* reserved */
183}
184static inline void
185avc_bridgeco_fill_msu_addr(u8 buf[AVC_BRIDGECO_ADDR_BYTES],
186 enum avc_bridgeco_plug_dir dir,
187 unsigned int pid)
188{
189 buf[0] = 0x60; /* Music subunit */
190 buf[1] = dir;
191 buf[2] = AVC_BRIDGECO_PLUG_MODE_SUBUNIT;
192 buf[3] = 0xff & pid;
193 buf[4] = 0xff; /* reserved */
194 buf[5] = 0xff; /* reserved */
195}
196int avc_bridgeco_get_plug_ch_pos(struct fw_unit *unit,
197 u8 addr[AVC_BRIDGECO_ADDR_BYTES],
198 u8 *buf, unsigned int len);
199int avc_bridgeco_get_plug_type(struct fw_unit *unit,
200 u8 addr[AVC_BRIDGECO_ADDR_BYTES],
201 enum avc_bridgeco_plug_type *type);
202int avc_bridgeco_get_plug_section_type(struct fw_unit *unit,
203 u8 addr[AVC_BRIDGECO_ADDR_BYTES],
204 unsigned int id, u8 *type);
205int avc_bridgeco_get_plug_input(struct fw_unit *unit,
206 u8 addr[AVC_BRIDGECO_ADDR_BYTES],
207 u8 input[7]);
208int avc_bridgeco_get_plug_strm_fmt(struct fw_unit *unit,
209 u8 addr[AVC_BRIDGECO_ADDR_BYTES], u8 *buf,
210 unsigned int *len, unsigned int eid);
211
212/* for AMDTP streaming */
213int snd_bebob_stream_get_rate(struct snd_bebob *bebob, unsigned int *rate);
214int snd_bebob_stream_set_rate(struct snd_bebob *bebob, unsigned int rate);
3e254b16
TS
215int snd_bebob_stream_get_clock_src(struct snd_bebob *bebob,
216 enum snd_bebob_clock_type *src);
eb7b3a05 217int snd_bebob_stream_discover(struct snd_bebob *bebob);
eb7b3a05 218int snd_bebob_stream_init_duplex(struct snd_bebob *bebob);
ac2888b9
TS
219int snd_bebob_stream_reserve_duplex(struct snd_bebob *bebob, unsigned int rate);
220int snd_bebob_stream_start_duplex(struct snd_bebob *bebob);
eb7b3a05 221void snd_bebob_stream_stop_duplex(struct snd_bebob *bebob);
eb7b3a05
TS
222void snd_bebob_stream_destroy_duplex(struct snd_bebob *bebob);
223
618eabea
TS
224void snd_bebob_stream_lock_changed(struct snd_bebob *bebob);
225int snd_bebob_stream_lock_try(struct snd_bebob *bebob);
226void snd_bebob_stream_lock_release(struct snd_bebob *bebob);
227
ad9697ba
TS
228void snd_bebob_proc_init(struct snd_bebob *bebob);
229
248b7802
TS
230int snd_bebob_create_midi_devices(struct snd_bebob *bebob);
231
fbbebd2c
TS
232int snd_bebob_create_pcm_devices(struct snd_bebob *bebob);
233
618eabea
TS
234int snd_bebob_create_hwdep_device(struct snd_bebob *bebob);
235
326b9cac 236/* model specific operations */
6b9866c8 237extern const struct snd_bebob_spec phase88_rack_spec;
e15c282e 238extern const struct snd_bebob_spec yamaha_terratec_spec;
6b9866c8
JL
239extern const struct snd_bebob_spec saffirepro_26_spec;
240extern const struct snd_bebob_spec saffirepro_10_spec;
241extern const struct snd_bebob_spec saffire_le_spec;
242extern const struct snd_bebob_spec saffire_spec;
243extern const struct snd_bebob_spec maudio_fw410_spec;
244extern const struct snd_bebob_spec maudio_audiophile_spec;
245extern const struct snd_bebob_spec maudio_solo_spec;
246extern const struct snd_bebob_spec maudio_ozonic_spec;
247extern const struct snd_bebob_spec maudio_nrv10_spec;
248extern const struct snd_bebob_spec maudio_special_spec;
3149ac48 249int snd_bebob_maudio_special_discover(struct snd_bebob *bebob, bool is1814);
a2b2a779 250int snd_bebob_maudio_load_firmware(struct fw_unit *unit);
326b9cac 251
1fc9522a 252#define SND_BEBOB_DEV_ENTRY(vendor, model, data) \
fd6f4b0d
TS
253{ \
254 .match_flags = IEEE1394_MATCH_VENDOR_ID | \
255 IEEE1394_MATCH_MODEL_ID, \
256 .vendor_id = vendor, \
257 .model_id = model, \
1fc9522a 258 .driver_data = (kernel_ulong_t)data \
fd6f4b0d
TS
259}
260
261#endif