~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/firewire/bebob/bebob.h

Version: ~ [ linux-5.8 ] ~ [ linux-5.7.14 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.57 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.138 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.193 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.232 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.232 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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>
 20 
 21 #include <sound/core.h>
 22 #include <sound/initval.h>
 23 #include <sound/info.h>
 24 #include <sound/rawmidi.h>
 25 #include <sound/pcm.h>
 26 #include <sound/pcm_params.h>
 27 #include <sound/firewire.h>
 28 #include <sound/hwdep.h>
 29 
 30 #include "../lib.h"
 31 #include "../fcp.h"
 32 #include "../packets-buffer.h"
 33 #include "../iso-resources.h"
 34 #include "../amdtp.h"
 35 #include "../cmp.h"
 36 
 37 /* basic register addresses on DM1000/DM1100/DM1500 */
 38 #define BEBOB_ADDR_REG_INFO     0xffffc8020000ULL
 39 #define BEBOB_ADDR_REG_REQ      0xffffc8021000ULL
 40 
 41 struct snd_bebob;
 42 
 43 #define SND_BEBOB_STRM_FMT_ENTRIES      7
 44 struct snd_bebob_stream_formation {
 45         unsigned int pcm;
 46         unsigned int midi;
 47 };
 48 /* this is a lookup table for index of stream formations */
 49 extern const unsigned int snd_bebob_rate_table[SND_BEBOB_STRM_FMT_ENTRIES];
 50 
 51 /* device specific operations */
 52 #define SND_BEBOB_CLOCK_INTERNAL        "Internal"
 53 struct snd_bebob_clock_spec {
 54         unsigned int num;
 55         char *const *labels;
 56         int (*get)(struct snd_bebob *bebob, unsigned int *id);
 57 };
 58 struct snd_bebob_rate_spec {
 59         int (*get)(struct snd_bebob *bebob, unsigned int *rate);
 60         int (*set)(struct snd_bebob *bebob, unsigned int rate);
 61 };
 62 struct snd_bebob_meter_spec {
 63         unsigned int num;
 64         char *const *labels;
 65         int (*get)(struct snd_bebob *bebob, u32 *target, unsigned int size);
 66 };
 67 struct snd_bebob_spec {
 68         struct snd_bebob_clock_spec *clock;
 69         struct snd_bebob_rate_spec *rate;
 70         struct snd_bebob_meter_spec *meter;
 71 };
 72 
 73 struct snd_bebob {
 74         struct snd_card *card;
 75         struct fw_unit *unit;
 76         int card_index;
 77 
 78         struct mutex mutex;
 79         spinlock_t lock;
 80 
 81         const struct snd_bebob_spec *spec;
 82 
 83         unsigned int midi_input_ports;
 84         unsigned int midi_output_ports;
 85 
 86         /* for bus reset quirk */
 87         struct completion bus_reset;
 88         bool connected;
 89 
 90         struct amdtp_stream *master;
 91         struct amdtp_stream tx_stream;
 92         struct amdtp_stream rx_stream;
 93         struct cmp_connection out_conn;
 94         struct cmp_connection in_conn;
 95         atomic_t capture_substreams;
 96         atomic_t playback_substreams;
 97 
 98         struct snd_bebob_stream_formation
 99                 tx_stream_formations[SND_BEBOB_STRM_FMT_ENTRIES];
100         struct snd_bebob_stream_formation
101                 rx_stream_formations[SND_BEBOB_STRM_FMT_ENTRIES];
102 
103         int sync_input_plug;
104 
105         /* for uapi */
106         int dev_lock_count;
107         bool dev_lock_changed;
108         wait_queue_head_t hwdep_wait;
109 
110         /* for M-Audio special devices */
111         void *maudio_special_quirk;
112         bool deferred_registration;
113 };
114 
115 static inline int
116 snd_bebob_read_block(struct fw_unit *unit, u64 addr, void *buf, int size)
117 {
118         return snd_fw_transaction(unit, TCODE_READ_BLOCK_REQUEST,
119                                   BEBOB_ADDR_REG_INFO + addr,
120                                   buf, size, 0);
121 }
122 
123 static inline int
124 snd_bebob_read_quad(struct fw_unit *unit, u64 addr, u32 *buf)
125 {
126         return snd_fw_transaction(unit, TCODE_READ_QUADLET_REQUEST,
127                                   BEBOB_ADDR_REG_INFO + addr,
128                                   (void *)buf, sizeof(u32), 0);
129 }
130 
131 /* AV/C Audio Subunit Specification 1.0 (Oct 2000, 1394TA) */
132 int avc_audio_set_selector(struct fw_unit *unit, unsigned int subunit_id,
133                            unsigned int fb_id, unsigned int num);
134 int avc_audio_get_selector(struct fw_unit *unit, unsigned  int subunit_id,
135                            unsigned int fb_id, unsigned int *num);
136 
137 /*
138  * AVC command extensions, AV/C Unit and Subunit, Revision 17
139  * (Nov 2003, BridgeCo)
140  */
141 #define AVC_BRIDGECO_ADDR_BYTES 6
142 enum avc_bridgeco_plug_dir {
143         AVC_BRIDGECO_PLUG_DIR_IN        = 0x00,
144         AVC_BRIDGECO_PLUG_DIR_OUT       = 0x01
145 };
146 enum avc_bridgeco_plug_mode {
147         AVC_BRIDGECO_PLUG_MODE_UNIT             = 0x00,
148         AVC_BRIDGECO_PLUG_MODE_SUBUNIT          = 0x01,
149         AVC_BRIDGECO_PLUG_MODE_FUNCTION_BLOCK   = 0x02
150 };
151 enum avc_bridgeco_plug_unit {
152         AVC_BRIDGECO_PLUG_UNIT_ISOC     = 0x00,
153         AVC_BRIDGECO_PLUG_UNIT_EXT      = 0x01,
154         AVC_BRIDGECO_PLUG_UNIT_ASYNC    = 0x02
155 };
156 enum avc_bridgeco_plug_type {
157         AVC_BRIDGECO_PLUG_TYPE_ISOC     = 0x00,
158         AVC_BRIDGECO_PLUG_TYPE_ASYNC    = 0x01,
159         AVC_BRIDGECO_PLUG_TYPE_MIDI     = 0x02,
160         AVC_BRIDGECO_PLUG_TYPE_SYNC     = 0x03,
161         AVC_BRIDGECO_PLUG_TYPE_ANA      = 0x04,
162         AVC_BRIDGECO_PLUG_TYPE_DIG      = 0x05
163 };
164 static inline void
165 avc_bridgeco_fill_unit_addr(u8 buf[AVC_BRIDGECO_ADDR_BYTES],
166                             enum avc_bridgeco_plug_dir dir,
167                             enum avc_bridgeco_plug_unit unit,
168                             unsigned int pid)
169 {
170         buf[0] = 0xff;  /* Unit */
171         buf[1] = dir;
172         buf[2] = AVC_BRIDGECO_PLUG_MODE_UNIT;
173         buf[3] = unit;
174         buf[4] = 0xff & pid;
175         buf[5] = 0xff;  /* reserved */
176 }
177 static inline void
178 avc_bridgeco_fill_msu_addr(u8 buf[AVC_BRIDGECO_ADDR_BYTES],
179                            enum avc_bridgeco_plug_dir dir,
180                            unsigned int pid)
181 {
182         buf[0] = 0x60;  /* Music subunit */
183         buf[1] = dir;
184         buf[2] = AVC_BRIDGECO_PLUG_MODE_SUBUNIT;
185         buf[3] = 0xff & pid;
186         buf[4] = 0xff;  /* reserved */
187         buf[5] = 0xff;  /* reserved */
188 }
189 int avc_bridgeco_get_plug_ch_pos(struct fw_unit *unit,
190                                  u8 addr[AVC_BRIDGECO_ADDR_BYTES],
191                                  u8 *buf, unsigned int len);
192 int avc_bridgeco_get_plug_type(struct fw_unit *unit,
193                                u8 addr[AVC_BRIDGECO_ADDR_BYTES],
194                                enum avc_bridgeco_plug_type *type);
195 int avc_bridgeco_get_plug_section_type(struct fw_unit *unit,
196                                        u8 addr[AVC_BRIDGECO_ADDR_BYTES],
197                                        unsigned int id, u8 *type);
198 int avc_bridgeco_get_plug_input(struct fw_unit *unit,
199                                 u8 addr[AVC_BRIDGECO_ADDR_BYTES],
200                                 u8 input[7]);
201 int avc_bridgeco_get_plug_strm_fmt(struct fw_unit *unit,
202                                    u8 addr[AVC_BRIDGECO_ADDR_BYTES], u8 *buf,
203                                    unsigned int *len, unsigned int eid);
204 
205 /* for AMDTP streaming */
206 int snd_bebob_stream_get_rate(struct snd_bebob *bebob, unsigned int *rate);
207 int snd_bebob_stream_set_rate(struct snd_bebob *bebob, unsigned int rate);
208 int snd_bebob_stream_check_internal_clock(struct snd_bebob *bebob,
209                                           bool *internal);
210 int snd_bebob_stream_discover(struct snd_bebob *bebob);
211 int snd_bebob_stream_init_duplex(struct snd_bebob *bebob);
212 int snd_bebob_stream_start_duplex(struct snd_bebob *bebob, unsigned int rate);
213 void snd_bebob_stream_stop_duplex(struct snd_bebob *bebob);
214 void snd_bebob_stream_update_duplex(struct snd_bebob *bebob);
215 void snd_bebob_stream_destroy_duplex(struct snd_bebob *bebob);
216 
217 void snd_bebob_stream_lock_changed(struct snd_bebob *bebob);
218 int snd_bebob_stream_lock_try(struct snd_bebob *bebob);
219 void snd_bebob_stream_lock_release(struct snd_bebob *bebob);
220 
221 void snd_bebob_proc_init(struct snd_bebob *bebob);
222 
223 int snd_bebob_create_midi_devices(struct snd_bebob *bebob);
224 
225 int snd_bebob_create_pcm_devices(struct snd_bebob *bebob);
226 
227 int snd_bebob_create_hwdep_device(struct snd_bebob *bebob);
228 
229 /* model specific operations */
230 extern struct snd_bebob_spec phase88_rack_spec;
231 extern struct snd_bebob_spec phase24_series_spec;
232 extern struct snd_bebob_spec yamaha_go_spec;
233 extern struct snd_bebob_spec saffirepro_26_spec;
234 extern struct snd_bebob_spec saffirepro_10_spec;
235 extern struct snd_bebob_spec saffire_le_spec;
236 extern struct snd_bebob_spec saffire_spec;
237 extern struct snd_bebob_spec maudio_fw410_spec;
238 extern struct snd_bebob_spec maudio_audiophile_spec;
239 extern struct snd_bebob_spec maudio_solo_spec;
240 extern struct snd_bebob_spec maudio_ozonic_spec;
241 extern struct snd_bebob_spec maudio_nrv10_spec;
242 extern struct snd_bebob_spec maudio_special_spec;
243 int snd_bebob_maudio_special_discover(struct snd_bebob *bebob, bool is1814);
244 int snd_bebob_maudio_load_firmware(struct fw_unit *unit);
245 
246 #define SND_BEBOB_DEV_ENTRY(vendor, model, data) \
247 { \
248         .match_flags    = IEEE1394_MATCH_VENDOR_ID | \
249                           IEEE1394_MATCH_MODEL_ID, \
250         .vendor_id      = vendor, \
251         .model_id       = model, \
252         .driver_data    = (kernel_ulong_t)data \
253 }
254 
255 #endif
256 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp