diff options
| author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2014-04-25 09:45:26 -0400 |
|---|---|---|
| committer | Takashi Iwai <tiwai@suse.de> | 2014-05-26 08:32:21 -0400 |
| commit | 3149ac489ff8dea0c305c7f97ac2a1b4ad54f5be (patch) | |
| tree | ad5ead9df75157589593cd7985aad418cc1aad17 /sound/firewire/bebob | |
| parent | 9076c22ddd9d29a30426f0367dec2b40e12536de (diff) | |
ALSA: bebob: Add support for M-Audio special Firewire series
This commit allows this driver to support some models which M-Audio produces
with DM1000 but its firmware is special. They are:
- Firewire 1814
- ProjectMix I/O
They have heavily customized firmware. The usual operations can't be applied to
them. For this reason, this commit adds a model specific member to 'struct
snd_bebob' and some model specific functions. Some parameters are write-only so
this commit also adds control interface for applications to set them.
M-Audio special firmware quirks:
- Just after powering on, they wait to download firmware. This state is
changed when receiving cue. Then bus reset is generated and the device is
recognized as a different model with the uploaded firmware.
- They don't respond against BridgeCo AV/C extension commands. So drivers
can't get their stream formations and so on.
- They do not start to transmit packets only by establishing connection but
also by receiving SIGNAL FORMAT command.
- After booting up, they often fail to send response against driver's request
due to mismatch of gap_count.
This module don't support to upload firmware.
Tested-by: Darren Anderson <darrena092@gmail.com> (ProjectMix I/O)
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/firewire/bebob')
| -rw-r--r-- | sound/firewire/bebob/bebob.c | 19 | ||||
| -rw-r--r-- | sound/firewire/bebob/bebob.h | 5 | ||||
| -rw-r--r-- | sound/firewire/bebob/bebob_maudio.c | 550 | ||||
| -rw-r--r-- | sound/firewire/bebob/bebob_stream.c | 45 |
4 files changed, 608 insertions, 11 deletions
diff --git a/sound/firewire/bebob/bebob.c b/sound/firewire/bebob/bebob.c index 9bf9149194df..ffb042b1f19f 100644 --- a/sound/firewire/bebob/bebob.c +++ b/sound/firewire/bebob/bebob.c | |||
| @@ -60,6 +60,8 @@ static DECLARE_BITMAP(devices_used, SNDRV_CARDS); | |||
| 60 | 60 | ||
| 61 | #define MODEL_FOCUSRITE_SAFFIRE_BOTH 0x00000000 | 61 | #define MODEL_FOCUSRITE_SAFFIRE_BOTH 0x00000000 |
| 62 | #define MODEL_MAUDIO_AUDIOPHILE_BOTH 0x00010060 | 62 | #define MODEL_MAUDIO_AUDIOPHILE_BOTH 0x00010060 |
| 63 | #define MODEL_MAUDIO_FW1814 0x00010071 | ||
| 64 | #define MODEL_MAUDIO_PROJECTMIX 0x00010091 | ||
| 63 | 65 | ||
| 64 | static int | 66 | static int |
| 65 | name_device(struct snd_bebob *bebob, unsigned int vendor_id) | 67 | name_device(struct snd_bebob *bebob, unsigned int vendor_id) |
| @@ -210,7 +212,14 @@ bebob_probe(struct fw_unit *unit, | |||
| 210 | if (err < 0) | 212 | if (err < 0) |
| 211 | goto error; | 213 | goto error; |
| 212 | 214 | ||
| 213 | err = snd_bebob_stream_discover(bebob); | 215 | if ((entry->vendor_id == VEN_MAUDIO1) && |
| 216 | (entry->model_id == MODEL_MAUDIO_FW1814)) | ||
| 217 | err = snd_bebob_maudio_special_discover(bebob, true); | ||
| 218 | else if ((entry->vendor_id == VEN_MAUDIO1) && | ||
| 219 | (entry->model_id == MODEL_MAUDIO_PROJECTMIX)) | ||
| 220 | err = snd_bebob_maudio_special_discover(bebob, false); | ||
| 221 | else | ||
| 222 | err = snd_bebob_stream_discover(bebob); | ||
| 214 | if (err < 0) | 223 | if (err < 0) |
| 215 | goto error; | 224 | goto error; |
| 216 | 225 | ||
| @@ -270,6 +279,8 @@ static void bebob_remove(struct fw_unit *unit) | |||
| 270 | if (bebob == NULL) | 279 | if (bebob == NULL) |
| 271 | return; | 280 | return; |
| 272 | 281 | ||
| 282 | kfree(bebob->maudio_special_quirk); | ||
| 283 | |||
| 273 | snd_bebob_stream_destroy_duplex(bebob); | 284 | snd_bebob_stream_destroy_duplex(bebob); |
| 274 | snd_card_disconnect(bebob->card); | 285 | snd_card_disconnect(bebob->card); |
| 275 | snd_card_free_when_closed(bebob->card); | 286 | snd_card_free_when_closed(bebob->card); |
| @@ -375,6 +386,12 @@ static const struct ieee1394_device_id bebob_id_table[] = { | |||
| 375 | SND_BEBOB_DEV_ENTRY(VEN_MAUDIO1, 0x00010081, &maudio_nrv10_spec), | 386 | SND_BEBOB_DEV_ENTRY(VEN_MAUDIO1, 0x00010081, &maudio_nrv10_spec), |
| 376 | /* M-Audio, ProFireLightbridge */ | 387 | /* M-Audio, ProFireLightbridge */ |
| 377 | SND_BEBOB_DEV_ENTRY(VEN_MAUDIO1, 0x000100a1, &spec_normal), | 388 | SND_BEBOB_DEV_ENTRY(VEN_MAUDIO1, 0x000100a1, &spec_normal), |
| 389 | /* Firewire 1814 */ | ||
| 390 | SND_BEBOB_DEV_ENTRY(VEN_MAUDIO1, MODEL_MAUDIO_FW1814, | ||
| 391 | &maudio_special_spec), | ||
| 392 | /* M-Audio ProjectMix */ | ||
| 393 | SND_BEBOB_DEV_ENTRY(VEN_MAUDIO1, MODEL_MAUDIO_PROJECTMIX, | ||
| 394 | &maudio_special_spec), | ||
| 378 | /* IDs are unknown but able to be supported */ | 395 | /* IDs are unknown but able to be supported */ |
| 379 | /* Apogee, Mini-ME Firewire */ | 396 | /* Apogee, Mini-ME Firewire */ |
| 380 | /* Apogee, Mini-DAC Firewire */ | 397 | /* Apogee, Mini-DAC Firewire */ |
diff --git a/sound/firewire/bebob/bebob.h b/sound/firewire/bebob/bebob.h index a851639ead45..eba012958b5c 100644 --- a/sound/firewire/bebob/bebob.h +++ b/sound/firewire/bebob/bebob.h | |||
| @@ -106,6 +106,9 @@ struct snd_bebob { | |||
| 106 | int dev_lock_count; | 106 | int dev_lock_count; |
| 107 | bool dev_lock_changed; | 107 | bool dev_lock_changed; |
| 108 | wait_queue_head_t hwdep_wait; | 108 | wait_queue_head_t hwdep_wait; |
| 109 | |||
| 110 | /* for M-Audio special devices */ | ||
| 111 | void *maudio_special_quirk; | ||
| 109 | }; | 112 | }; |
| 110 | 113 | ||
| 111 | static inline int | 114 | static inline int |
| @@ -237,6 +240,8 @@ extern struct snd_bebob_spec maudio_audiophile_spec; | |||
| 237 | extern struct snd_bebob_spec maudio_solo_spec; | 240 | extern struct snd_bebob_spec maudio_solo_spec; |
| 238 | extern struct snd_bebob_spec maudio_ozonic_spec; | 241 | extern struct snd_bebob_spec maudio_ozonic_spec; |
| 239 | extern struct snd_bebob_spec maudio_nrv10_spec; | 242 | extern struct snd_bebob_spec maudio_nrv10_spec; |
| 243 | extern struct snd_bebob_spec maudio_special_spec; | ||
| 244 | int snd_bebob_maudio_special_discover(struct snd_bebob *bebob, bool is1814); | ||
| 240 | 245 | ||
| 241 | #define SND_BEBOB_DEV_ENTRY(vendor, model, data) \ | 246 | #define SND_BEBOB_DEV_ENTRY(vendor, model, data) \ |
| 242 | { \ | 247 | { \ |
diff --git a/sound/firewire/bebob/bebob_maudio.c b/sound/firewire/bebob/bebob_maudio.c index dededb35fbd7..544094b22c6d 100644 --- a/sound/firewire/bebob/bebob_maudio.c +++ b/sound/firewire/bebob/bebob_maudio.c | |||
| @@ -7,9 +7,10 @@ | |||
| 7 | */ | 7 | */ |
| 8 | 8 | ||
| 9 | #include "./bebob.h" | 9 | #include "./bebob.h" |
| 10 | #include <sound/control.h> | ||
| 10 | 11 | ||
| 11 | /* | 12 | /* |
| 12 | * Just powering on, Firewire 410/Audiophile wait to | 13 | * Just powering on, Firewire 410/Audiophile/1814 and ProjectMix I/O wait to |
| 13 | * download firmware blob. To enable these devices, drivers should upload | 14 | * download firmware blob. To enable these devices, drivers should upload |
| 14 | * firmware blob and send a command to initialize configuration to factory | 15 | * firmware blob and send a command to initialize configuration to factory |
| 15 | * settings when completing uploading. Then these devices generate bus reset | 16 | * settings when completing uploading. Then these devices generate bus reset |
| @@ -22,6 +23,12 @@ | |||
| 22 | * Without streaming, the devices except for Firewire Audiophile can mix any | 23 | * Without streaming, the devices except for Firewire Audiophile can mix any |
| 23 | * input and output. For this reason, Audiophile cannot be used as standalone | 24 | * input and output. For this reason, Audiophile cannot be used as standalone |
| 24 | * mixer. | 25 | * mixer. |
| 26 | * | ||
| 27 | * Firewire 1814 and ProjectMix I/O uses special firmware. It will be freezed | ||
| 28 | * when receiving any commands which the firmware can't understand. These | ||
| 29 | * devices utilize completely different system to control. It is some | ||
| 30 | * write-transaction directly into a certain address. All of addresses for mixer | ||
| 31 | * functionality is between 0xffc700700000 to 0xffc70070009c. | ||
| 25 | */ | 32 | */ |
| 26 | 33 | ||
| 27 | #define MAUDIO_SPECIFIC_ADDRESS 0xffc700000000 | 34 | #define MAUDIO_SPECIFIC_ADDRESS 0xffc700000000 |
| @@ -29,6 +36,7 @@ | |||
| 29 | #define METER_OFFSET 0x00600000 | 36 | #define METER_OFFSET 0x00600000 |
| 30 | 37 | ||
| 31 | /* some device has sync info after metering data */ | 38 | /* some device has sync info after metering data */ |
| 39 | #define METER_SIZE_SPECIAL 84 /* with sync info */ | ||
| 32 | #define METER_SIZE_FW410 76 /* with sync info */ | 40 | #define METER_SIZE_FW410 76 /* with sync info */ |
| 33 | #define METER_SIZE_AUDIOPHILE 60 /* with sync info */ | 41 | #define METER_SIZE_AUDIOPHILE 60 /* with sync info */ |
| 34 | #define METER_SIZE_SOLO 52 /* with sync info */ | 42 | #define METER_SIZE_SOLO 52 /* with sync info */ |
| @@ -50,6 +58,15 @@ | |||
| 50 | /* for NRV */ | 58 | /* for NRV */ |
| 51 | #define UNKNOWN_METER "Unknown" | 59 | #define UNKNOWN_METER "Unknown" |
| 52 | 60 | ||
| 61 | struct special_params { | ||
| 62 | bool is1814; | ||
| 63 | unsigned int clk_src; | ||
| 64 | unsigned int dig_in_fmt; | ||
| 65 | unsigned int dig_out_fmt; | ||
| 66 | unsigned int clk_lock; | ||
| 67 | struct snd_ctl_elem_id *ctl_id_sync; | ||
| 68 | }; | ||
| 69 | |||
| 53 | static inline int | 70 | static inline int |
| 54 | get_meter(struct snd_bebob *bebob, void *buf, unsigned int size) | 71 | get_meter(struct snd_bebob *bebob, void *buf, unsigned int size) |
| 55 | { | 72 | { |
| @@ -58,6 +75,516 @@ get_meter(struct snd_bebob *bebob, void *buf, unsigned int size) | |||
| 58 | buf, size, 0); | 75 | buf, size, 0); |
| 59 | } | 76 | } |
| 60 | 77 | ||
| 78 | static int | ||
| 79 | check_clk_sync(struct snd_bebob *bebob, unsigned int size, bool *sync) | ||
| 80 | { | ||
| 81 | int err; | ||
| 82 | u8 *buf; | ||
| 83 | |||
| 84 | buf = kmalloc(size, GFP_KERNEL); | ||
| 85 | if (buf == NULL) | ||
| 86 | return -ENOMEM; | ||
| 87 | |||
| 88 | err = get_meter(bebob, buf, size); | ||
| 89 | if (err < 0) | ||
| 90 | goto end; | ||
| 91 | |||
| 92 | /* if synced, this value is the same as SFC of FDF in CIP header */ | ||
| 93 | *sync = (buf[size - 2] != 0xff); | ||
| 94 | end: | ||
| 95 | kfree(buf); | ||
| 96 | return err; | ||
| 97 | } | ||
| 98 | |||
| 99 | /* | ||
| 100 | * dig_fmt: 0x00:S/PDIF, 0x01:ADAT | ||
| 101 | * clk_lock: 0x00:unlock, 0x01:lock | ||
| 102 | */ | ||
| 103 | static int | ||
| 104 | avc_maudio_set_special_clk(struct snd_bebob *bebob, unsigned int clk_src, | ||
| 105 | unsigned int dig_in_fmt, unsigned int dig_out_fmt, | ||
| 106 | unsigned int clk_lock) | ||
| 107 | { | ||
| 108 | struct special_params *params = bebob->maudio_special_quirk; | ||
| 109 | int err; | ||
| 110 | u8 *buf; | ||
| 111 | |||
| 112 | if (amdtp_stream_running(&bebob->rx_stream) || | ||
| 113 | amdtp_stream_running(&bebob->tx_stream)) | ||
| 114 | return -EBUSY; | ||
| 115 | |||
| 116 | buf = kmalloc(12, GFP_KERNEL); | ||
| 117 | if (buf == NULL) | ||
| 118 | return -ENOMEM; | ||
| 119 | |||
| 120 | buf[0] = 0x00; /* CONTROL */ | ||
| 121 | buf[1] = 0xff; /* UNIT */ | ||
| 122 | buf[2] = 0x00; /* vendor dependent */ | ||
| 123 | buf[3] = 0x04; /* company ID high */ | ||
| 124 | buf[4] = 0x00; /* company ID middle */ | ||
| 125 | buf[5] = 0x04; /* company ID low */ | ||
| 126 | buf[6] = 0xff & clk_src; /* clock source */ | ||
| 127 | buf[7] = 0xff & dig_in_fmt; /* input digital format */ | ||
| 128 | buf[8] = 0xff & dig_out_fmt; /* output digital format */ | ||
| 129 | buf[9] = 0xff & clk_lock; /* lock these settings */ | ||
| 130 | buf[10] = 0x00; /* padding */ | ||
| 131 | buf[11] = 0x00; /* padding */ | ||
| 132 | |||
| 133 | err = fcp_avc_transaction(bebob->unit, buf, 12, buf, 12, | ||
| 134 | BIT(1) | BIT(2) | BIT(3) | BIT(4) | | ||
| 135 | BIT(5) | BIT(6) | BIT(7) | BIT(8) | | ||
| 136 | BIT(9)); | ||
| 137 | if ((err > 0) && (err < 10)) | ||
| 138 | err = -EIO; | ||
| 139 | else if (buf[0] == 0x08) /* NOT IMPLEMENTED */ | ||
| 140 | err = -ENOSYS; | ||
| 141 | else if (buf[0] == 0x0a) /* REJECTED */ | ||
| 142 | err = -EINVAL; | ||
| 143 | if (err < 0) | ||
| 144 | goto end; | ||
| 145 | |||
| 146 | params->clk_src = buf[6]; | ||
| 147 | params->dig_in_fmt = buf[7]; | ||
| 148 | params->dig_out_fmt = buf[8]; | ||
| 149 | params->clk_lock = buf[9]; | ||
| 150 | |||
| 151 | if (params->ctl_id_sync) | ||
| 152 | snd_ctl_notify(bebob->card, SNDRV_CTL_EVENT_MASK_VALUE, | ||
| 153 | params->ctl_id_sync); | ||
| 154 | |||
| 155 | err = 0; | ||
| 156 | end: | ||
| 157 | kfree(buf); | ||
| 158 | return err; | ||
| 159 | } | ||
| 160 | static void | ||
| 161 | special_stream_formation_set(struct snd_bebob *bebob) | ||
| 162 | { | ||
| 163 | static const unsigned int ch_table[2][2][3] = { | ||
| 164 | /* AMDTP_OUT_STREAM */ | ||
| 165 | { { 6, 6, 4 }, /* SPDIF */ | ||
| 166 | { 12, 8, 4 } }, /* ADAT */ | ||
| 167 | /* AMDTP_IN_STREAM */ | ||
| 168 | { { 10, 10, 2 }, /* SPDIF */ | ||
| 169 | { 16, 12, 2 } } /* ADAT */ | ||
| 170 | }; | ||
| 171 | struct special_params *params = bebob->maudio_special_quirk; | ||
| 172 | unsigned int i, max; | ||
| 173 | |||
| 174 | max = SND_BEBOB_STRM_FMT_ENTRIES - 1; | ||
| 175 | if (!params->is1814) | ||
| 176 | max -= 2; | ||
| 177 | |||
| 178 | for (i = 0; i < max; i++) { | ||
| 179 | bebob->tx_stream_formations[i + 1].pcm = | ||
| 180 | ch_table[AMDTP_IN_STREAM][params->dig_in_fmt][i / 2]; | ||
| 181 | bebob->tx_stream_formations[i + 1].midi = 1; | ||
| 182 | |||
| 183 | bebob->rx_stream_formations[i + 1].pcm = | ||
| 184 | ch_table[AMDTP_OUT_STREAM][params->dig_out_fmt][i / 2]; | ||
| 185 | bebob->rx_stream_formations[i + 1].midi = 1; | ||
| 186 | } | ||
| 187 | } | ||
| 188 | |||
| 189 | static int add_special_controls(struct snd_bebob *bebob); | ||
| 190 | int | ||
| 191 | snd_bebob_maudio_special_discover(struct snd_bebob *bebob, bool is1814) | ||
| 192 | { | ||
| 193 | struct special_params *params; | ||
| 194 | int err; | ||
| 195 | |||
| 196 | params = kzalloc(sizeof(struct special_params), GFP_KERNEL); | ||
| 197 | if (params == NULL) | ||
| 198 | return -ENOMEM; | ||
| 199 | |||
| 200 | mutex_lock(&bebob->mutex); | ||
| 201 | |||
| 202 | bebob->maudio_special_quirk = (void *)params; | ||
| 203 | params->is1814 = is1814; | ||
| 204 | |||
| 205 | /* initialize these parameters because driver is not allowed to ask */ | ||
| 206 | bebob->rx_stream.context = ERR_PTR(-1); | ||
| 207 | bebob->tx_stream.context = ERR_PTR(-1); | ||
| 208 | err = avc_maudio_set_special_clk(bebob, 0x03, 0x00, 0x00, 0x00); | ||
| 209 | if (err < 0) { | ||
| 210 | dev_err(&bebob->unit->device, | ||
| 211 | "fail to initialize clock params: %d\n", err); | ||
| 212 | goto end; | ||
| 213 | } | ||
| 214 | |||
| 215 | err = add_special_controls(bebob); | ||
| 216 | if (err < 0) | ||
| 217 | goto end; | ||
| 218 | |||
| 219 | special_stream_formation_set(bebob); | ||
| 220 | |||
| 221 | if (params->is1814) { | ||
| 222 | bebob->midi_input_ports = 1; | ||
| 223 | bebob->midi_output_ports = 1; | ||
| 224 | } else { | ||
| 225 | bebob->midi_input_ports = 2; | ||
| 226 | bebob->midi_output_ports = 2; | ||
| 227 | } | ||
| 228 | end: | ||
| 229 | if (err < 0) { | ||
| 230 | kfree(params); | ||
| 231 | bebob->maudio_special_quirk = NULL; | ||
| 232 | } | ||
| 233 | mutex_unlock(&bebob->mutex); | ||
| 234 | return err; | ||
| 235 | } | ||
| 236 | |||
| 237 | /* Input plug shows actual rate. Output plug is needless for this purpose. */ | ||
| 238 | static int special_get_rate(struct snd_bebob *bebob, unsigned int *rate) | ||
| 239 | { | ||
| 240 | int err, trials; | ||
| 241 | |||
| 242 | trials = 0; | ||
| 243 | do { | ||
| 244 | err = avc_general_get_sig_fmt(bebob->unit, rate, | ||
| 245 | AVC_GENERAL_PLUG_DIR_IN, 0); | ||
| 246 | } while (err == -EAGAIN && ++trials < 3); | ||
| 247 | |||
| 248 | return err; | ||
| 249 | } | ||
| 250 | static int special_set_rate(struct snd_bebob *bebob, unsigned int rate) | ||
| 251 | { | ||
| 252 | struct special_params *params = bebob->maudio_special_quirk; | ||
| 253 | int err; | ||
| 254 | |||
| 255 | err = avc_general_set_sig_fmt(bebob->unit, rate, | ||
| 256 | AVC_GENERAL_PLUG_DIR_OUT, 0); | ||
| 257 | if (err < 0) | ||
| 258 | goto end; | ||
| 259 | |||
| 260 | /* | ||
| 261 | * Just after changing sampling rate for output, a followed command | ||
| 262 | * for input is easy to fail. This is a workaround fot this issue. | ||
| 263 | */ | ||
| 264 | msleep(100); | ||
| 265 | |||
| 266 | err = avc_general_set_sig_fmt(bebob->unit, rate, | ||
| 267 | AVC_GENERAL_PLUG_DIR_IN, 0); | ||
| 268 | if (err < 0) | ||
| 269 | goto end; | ||
| 270 | |||
| 271 | if (params->ctl_id_sync) | ||
| 272 | snd_ctl_notify(bebob->card, SNDRV_CTL_EVENT_MASK_VALUE, | ||
| 273 | params->ctl_id_sync); | ||
| 274 | end: | ||
| 275 | return err; | ||
| 276 | } | ||
| 277 | |||
| 278 | /* Clock source control for special firmware */ | ||
| 279 | static char *const special_clk_labels[] = { | ||
| 280 | SND_BEBOB_CLOCK_INTERNAL " with Digital Mute", "Digital", | ||
| 281 | "Word Clock", SND_BEBOB_CLOCK_INTERNAL}; | ||
| 282 | static int special_clk_get(struct snd_bebob *bebob, unsigned int *id) | ||
| 283 | { | ||
| 284 | struct special_params *params = bebob->maudio_special_quirk; | ||
| 285 | *id = params->clk_src; | ||
| 286 | return 0; | ||
| 287 | } | ||
| 288 | static int special_clk_ctl_info(struct snd_kcontrol *kctl, | ||
| 289 | struct snd_ctl_elem_info *einf) | ||
| 290 | { | ||
| 291 | einf->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
| 292 | einf->count = 1; | ||
| 293 | einf->value.enumerated.items = ARRAY_SIZE(special_clk_labels); | ||
| 294 | |||
| 295 | if (einf->value.enumerated.item >= einf->value.enumerated.items) | ||
| 296 | einf->value.enumerated.item = einf->value.enumerated.items - 1; | ||
| 297 | |||
| 298 | strcpy(einf->value.enumerated.name, | ||
| 299 | special_clk_labels[einf->value.enumerated.item]); | ||
| 300 | |||
| 301 | return 0; | ||
| 302 | } | ||
| 303 | static int special_clk_ctl_get(struct snd_kcontrol *kctl, | ||
| 304 | struct snd_ctl_elem_value *uval) | ||
| 305 | { | ||
| 306 | struct snd_bebob *bebob = snd_kcontrol_chip(kctl); | ||
| 307 | struct special_params *params = bebob->maudio_special_quirk; | ||
| 308 | uval->value.enumerated.item[0] = params->clk_src; | ||
| 309 | return 0; | ||
| 310 | } | ||
| 311 | static int special_clk_ctl_put(struct snd_kcontrol *kctl, | ||
| 312 | struct snd_ctl_elem_value *uval) | ||
| 313 | { | ||
| 314 | struct snd_bebob *bebob = snd_kcontrol_chip(kctl); | ||
| 315 | struct special_params *params = bebob->maudio_special_quirk; | ||
| 316 | int err, id; | ||
| 317 | |||
| 318 | mutex_lock(&bebob->mutex); | ||
| 319 | |||
| 320 | id = uval->value.enumerated.item[0]; | ||
| 321 | if (id >= ARRAY_SIZE(special_clk_labels)) | ||
| 322 | return 0; | ||
| 323 | |||
| 324 | err = avc_maudio_set_special_clk(bebob, id, | ||
| 325 | params->dig_in_fmt, | ||
| 326 | params->dig_out_fmt, | ||
| 327 | params->clk_lock); | ||
| 328 | mutex_unlock(&bebob->mutex); | ||
| 329 | |||
| 330 | return err >= 0; | ||
| 331 | } | ||
| 332 | static struct snd_kcontrol_new special_clk_ctl = { | ||
| 333 | .name = "Clock Source", | ||
| 334 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
| 335 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, | ||
| 336 | .info = special_clk_ctl_info, | ||
| 337 | .get = special_clk_ctl_get, | ||
| 338 | .put = special_clk_ctl_put | ||
| 339 | }; | ||
| 340 | |||
| 341 | /* Clock synchronization control for special firmware */ | ||
| 342 | static int special_sync_ctl_info(struct snd_kcontrol *kctl, | ||
| 343 | struct snd_ctl_elem_info *einf) | ||
| 344 | { | ||
| 345 | einf->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; | ||
| 346 | einf->count = 1; | ||
| 347 | einf->value.integer.min = 0; | ||
| 348 | einf->value.integer.max = 1; | ||
| 349 | |||
| 350 | return 0; | ||
| 351 | } | ||
| 352 | static int special_sync_ctl_get(struct snd_kcontrol *kctl, | ||
| 353 | struct snd_ctl_elem_value *uval) | ||
| 354 | { | ||
| 355 | struct snd_bebob *bebob = snd_kcontrol_chip(kctl); | ||
| 356 | int err; | ||
| 357 | bool synced = 0; | ||
| 358 | |||
| 359 | err = check_clk_sync(bebob, METER_SIZE_SPECIAL, &synced); | ||
| 360 | if (err >= 0) | ||
| 361 | uval->value.integer.value[0] = synced; | ||
| 362 | |||
| 363 | return 0; | ||
| 364 | } | ||
| 365 | static struct snd_kcontrol_new special_sync_ctl = { | ||
| 366 | .name = "Sync Status", | ||
| 367 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
| 368 | .access = SNDRV_CTL_ELEM_ACCESS_READ, | ||
| 369 | .info = special_sync_ctl_info, | ||
| 370 | .get = special_sync_ctl_get, | ||
| 371 | }; | ||
| 372 | |||
| 373 | /* Digital interface control for special firmware */ | ||
| 374 | static char *const special_dig_iface_labels[] = { | ||
| 375 | "S/PDIF Optical", "S/PDIF Coaxial", "ADAT Optical" | ||
| 376 | }; | ||
| 377 | static int special_dig_in_iface_ctl_info(struct snd_kcontrol *kctl, | ||
| 378 | struct snd_ctl_elem_info *einf) | ||
| 379 | { | ||
| 380 | einf->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
| 381 | einf->count = 1; | ||
| 382 | einf->value.enumerated.items = ARRAY_SIZE(special_dig_iface_labels); | ||
| 383 | |||
| 384 | if (einf->value.enumerated.item >= einf->value.enumerated.items) | ||
| 385 | einf->value.enumerated.item = einf->value.enumerated.items - 1; | ||
| 386 | |||
| 387 | strcpy(einf->value.enumerated.name, | ||
| 388 | special_dig_iface_labels[einf->value.enumerated.item]); | ||
| 389 | |||
| 390 | return 0; | ||
| 391 | } | ||
| 392 | static int special_dig_in_iface_ctl_get(struct snd_kcontrol *kctl, | ||
| 393 | struct snd_ctl_elem_value *uval) | ||
| 394 | { | ||
| 395 | struct snd_bebob *bebob = snd_kcontrol_chip(kctl); | ||
| 396 | struct special_params *params = bebob->maudio_special_quirk; | ||
| 397 | unsigned int dig_in_iface; | ||
| 398 | int err, val; | ||
| 399 | |||
| 400 | mutex_lock(&bebob->mutex); | ||
| 401 | |||
| 402 | err = avc_audio_get_selector(bebob->unit, 0x00, 0x04, | ||
| 403 | &dig_in_iface); | ||
| 404 | if (err < 0) { | ||
| 405 | dev_err(&bebob->unit->device, | ||
| 406 | "fail to get digital input interface: %d\n", err); | ||
| 407 | goto end; | ||
| 408 | } | ||
| 409 | |||
| 410 | /* encoded id for user value */ | ||
| 411 | val = (params->dig_in_fmt << 1) | (dig_in_iface & 0x01); | ||
| 412 | |||
| 413 | /* for ADAT Optical */ | ||
| 414 | if (val > 2) | ||
| 415 | val = 2; | ||
| 416 | |||
| 417 | uval->value.enumerated.item[0] = val; | ||
| 418 | end: | ||
| 419 | mutex_unlock(&bebob->mutex); | ||
| 420 | return err; | ||
| 421 | } | ||
| 422 | static int special_dig_in_iface_ctl_set(struct snd_kcontrol *kctl, | ||
| 423 | struct snd_ctl_elem_value *uval) | ||
| 424 | { | ||
| 425 | struct snd_bebob *bebob = snd_kcontrol_chip(kctl); | ||
| 426 | struct special_params *params = bebob->maudio_special_quirk; | ||
| 427 | unsigned int id, dig_in_fmt, dig_in_iface; | ||
| 428 | int err; | ||
| 429 | |||
| 430 | mutex_lock(&bebob->mutex); | ||
| 431 | |||
| 432 | id = uval->value.enumerated.item[0]; | ||
| 433 | |||
| 434 | /* decode user value */ | ||
| 435 | dig_in_fmt = (id >> 1) & 0x01; | ||
| 436 | dig_in_iface = id & 0x01; | ||
| 437 | |||
| 438 | err = avc_maudio_set_special_clk(bebob, | ||
| 439 | params->clk_src, | ||
| 440 | dig_in_fmt, | ||
| 441 | params->dig_out_fmt, | ||
| 442 | params->clk_lock); | ||
| 443 | if ((err < 0) || (params->dig_in_fmt > 0)) /* ADAT */ | ||
| 444 | goto end; | ||
| 445 | |||
| 446 | err = avc_audio_set_selector(bebob->unit, 0x00, 0x04, dig_in_iface); | ||
| 447 | if (err < 0) | ||
| 448 | dev_err(&bebob->unit->device, | ||
| 449 | "fail to set digital input interface: %d\n", err); | ||
| 450 | end: | ||
| 451 | special_stream_formation_set(bebob); | ||
| 452 | mutex_unlock(&bebob->mutex); | ||
| 453 | return err; | ||
| 454 | } | ||
| 455 | static struct snd_kcontrol_new special_dig_in_iface_ctl = { | ||
| 456 | .name = "Digital Input Interface", | ||
| 457 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
| 458 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, | ||
| 459 | .info = special_dig_in_iface_ctl_info, | ||
| 460 | .get = special_dig_in_iface_ctl_get, | ||
| 461 | .put = special_dig_in_iface_ctl_set | ||
| 462 | }; | ||
| 463 | |||
| 464 | static int special_dig_out_iface_ctl_info(struct snd_kcontrol *kctl, | ||
| 465 | struct snd_ctl_elem_info *einf) | ||
| 466 | { | ||
| 467 | einf->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | ||
| 468 | einf->count = 1; | ||
| 469 | einf->value.enumerated.items = ARRAY_SIZE(special_dig_iface_labels) - 1; | ||
| 470 | |||
| 471 | if (einf->value.enumerated.item >= einf->value.enumerated.items) | ||
| 472 | einf->value.enumerated.item = einf->value.enumerated.items - 1; | ||
| 473 | |||
| 474 | strcpy(einf->value.enumerated.name, | ||
| 475 | special_dig_iface_labels[einf->value.enumerated.item + 1]); | ||
| 476 | |||
| 477 | return 0; | ||
| 478 | } | ||
| 479 | static int special_dig_out_iface_ctl_get(struct snd_kcontrol *kctl, | ||
| 480 | struct snd_ctl_elem_value *uval) | ||
| 481 | { | ||
| 482 | struct snd_bebob *bebob = snd_kcontrol_chip(kctl); | ||
| 483 | struct special_params *params = bebob->maudio_special_quirk; | ||
| 484 | mutex_lock(&bebob->mutex); | ||
| 485 | uval->value.enumerated.item[0] = params->dig_out_fmt; | ||
| 486 | mutex_unlock(&bebob->mutex); | ||
| 487 | return 0; | ||
| 488 | } | ||
| 489 | static int special_dig_out_iface_ctl_set(struct snd_kcontrol *kctl, | ||
| 490 | struct snd_ctl_elem_value *uval) | ||
| 491 | { | ||
| 492 | struct snd_bebob *bebob = snd_kcontrol_chip(kctl); | ||
| 493 | struct special_params *params = bebob->maudio_special_quirk; | ||
| 494 | unsigned int id; | ||
| 495 | int err; | ||
| 496 | |||
| 497 | mutex_lock(&bebob->mutex); | ||
| 498 | |||
| 499 | id = uval->value.enumerated.item[0]; | ||
| 500 | |||
| 501 | err = avc_maudio_set_special_clk(bebob, | ||
| 502 | params->clk_src, | ||
| 503 | params->dig_in_fmt, | ||
| 504 | id, params->clk_lock); | ||
| 505 | if (err >= 0) | ||
| 506 | special_stream_formation_set(bebob); | ||
| 507 | |||
| 508 | mutex_unlock(&bebob->mutex); | ||
| 509 | return err; | ||
| 510 | } | ||
| 511 | static struct snd_kcontrol_new special_dig_out_iface_ctl = { | ||
| 512 | .name = "Digital Output Interface", | ||
| 513 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
| 514 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, | ||
| 515 | .info = special_dig_out_iface_ctl_info, | ||
| 516 | .get = special_dig_out_iface_ctl_get, | ||
| 517 | .put = special_dig_out_iface_ctl_set | ||
| 518 | }; | ||
| 519 | |||
| 520 | static int add_special_controls(struct snd_bebob *bebob) | ||
| 521 | { | ||
| 522 | struct snd_kcontrol *kctl; | ||
| 523 | struct special_params *params = bebob->maudio_special_quirk; | ||
| 524 | int err; | ||
| 525 | |||
| 526 | kctl = snd_ctl_new1(&special_clk_ctl, bebob); | ||
| 527 | err = snd_ctl_add(bebob->card, kctl); | ||
| 528 | if (err < 0) | ||
| 529 | goto end; | ||
| 530 | |||
| 531 | kctl = snd_ctl_new1(&special_sync_ctl, bebob); | ||
| 532 | err = snd_ctl_add(bebob->card, kctl); | ||
| 533 | if (err < 0) | ||
| 534 | goto end; | ||
| 535 | params->ctl_id_sync = &kctl->id; | ||
| 536 | |||
| 537 | kctl = snd_ctl_new1(&special_dig_in_iface_ctl, bebob); | ||
| 538 | err = snd_ctl_add(bebob->card, kctl); | ||
| 539 | if (err < 0) | ||
| 540 | goto end; | ||
| 541 | |||
| 542 | kctl = snd_ctl_new1(&special_dig_out_iface_ctl, bebob); | ||
| 543 | err = snd_ctl_add(bebob->card, kctl); | ||
| 544 | end: | ||
| 545 | return err; | ||
| 546 | } | ||
| 547 | |||
| 548 | /* Hardware metering for special firmware */ | ||
| 549 | static char *const special_meter_labels[] = { | ||
| 550 | ANA_IN, ANA_IN, ANA_IN, ANA_IN, | ||
| 551 | SPDIF_IN, | ||
| 552 | ADAT_IN, ADAT_IN, ADAT_IN, ADAT_IN, | ||
| 553 | ANA_OUT, ANA_OUT, | ||
| 554 | SPDIF_OUT, | ||
| 555 | ADAT_OUT, ADAT_OUT, ADAT_OUT, ADAT_OUT, | ||
| 556 | HP_OUT, HP_OUT, | ||
| 557 | AUX_OUT | ||
| 558 | }; | ||
| 559 | static int | ||
| 560 | special_meter_get(struct snd_bebob *bebob, u32 *target, unsigned int size) | ||
| 561 | { | ||
| 562 | u16 *buf; | ||
| 563 | unsigned int i, c, channels; | ||
| 564 | int err; | ||
| 565 | |||
| 566 | channels = ARRAY_SIZE(special_meter_labels) * 2; | ||
| 567 | if (size < channels * sizeof(u32)) | ||
| 568 | return -EINVAL; | ||
| 569 | |||
| 570 | /* omit last 4 bytes because it's clock info. */ | ||
| 571 | buf = kmalloc(METER_SIZE_SPECIAL - 4, GFP_KERNEL); | ||
| 572 | if (buf == NULL) | ||
| 573 | return -ENOMEM; | ||
| 574 | |||
| 575 | err = get_meter(bebob, (void *)buf, METER_SIZE_SPECIAL - 4); | ||
| 576 | if (err < 0) | ||
| 577 | goto end; | ||
| 578 | |||
| 579 | /* Its format is u16 and some channels are unknown. */ | ||
| 580 | i = 0; | ||
| 581 | for (c = 2; c < channels + 2; c++) | ||
| 582 | target[i++] = be16_to_cpu(buf[c]) << 16; | ||
| 583 | end: | ||
| 584 | kfree(buf); | ||
| 585 | return err; | ||
| 586 | } | ||
| 587 | |||
| 61 | /* last 4 bytes are omitted because it's clock info. */ | 588 | /* last 4 bytes are omitted because it's clock info. */ |
| 62 | static char *const fw410_meter_labels[] = { | 589 | static char *const fw410_meter_labels[] = { |
| 63 | ANA_IN, DIG_IN, | 590 | ANA_IN, DIG_IN, |
| @@ -115,6 +642,27 @@ end: | |||
| 115 | return err; | 642 | return err; |
| 116 | } | 643 | } |
| 117 | 644 | ||
| 645 | /* for special customized devices */ | ||
| 646 | static struct snd_bebob_rate_spec special_rate_spec = { | ||
| 647 | .get = &special_get_rate, | ||
| 648 | .set = &special_set_rate, | ||
| 649 | }; | ||
| 650 | static struct snd_bebob_clock_spec special_clk_spec = { | ||
| 651 | .num = ARRAY_SIZE(special_clk_labels), | ||
| 652 | .labels = special_clk_labels, | ||
| 653 | .get = &special_clk_get, | ||
| 654 | }; | ||
| 655 | static struct snd_bebob_meter_spec special_meter_spec = { | ||
| 656 | .num = ARRAY_SIZE(special_meter_labels), | ||
| 657 | .labels = special_meter_labels, | ||
| 658 | .get = &special_meter_get | ||
| 659 | }; | ||
| 660 | struct snd_bebob_spec maudio_special_spec = { | ||
| 661 | .clock = &special_clk_spec, | ||
| 662 | .rate = &special_rate_spec, | ||
| 663 | .meter = &special_meter_spec | ||
| 664 | }; | ||
| 665 | |||
| 118 | /* Firewire 410 specification */ | 666 | /* Firewire 410 specification */ |
| 119 | static struct snd_bebob_rate_spec usual_rate_spec = { | 667 | static struct snd_bebob_rate_spec usual_rate_spec = { |
| 120 | .get = &snd_bebob_stream_get_rate, | 668 | .get = &snd_bebob_stream_get_rate, |
diff --git a/sound/firewire/bebob/bebob_stream.c b/sound/firewire/bebob/bebob_stream.c index 5fc52706f7c5..2695b7899410 100644 --- a/sound/firewire/bebob/bebob_stream.c +++ b/sound/firewire/bebob/bebob_stream.c | |||
| @@ -389,6 +389,10 @@ break_both_connections(struct snd_bebob *bebob) | |||
| 389 | cmp_connection_break(&bebob->out_conn); | 389 | cmp_connection_break(&bebob->out_conn); |
| 390 | 390 | ||
| 391 | bebob->connected = false; | 391 | bebob->connected = false; |
| 392 | |||
| 393 | /* These models seems to be in transition state for a longer time. */ | ||
| 394 | if (bebob->maudio_special_quirk != NULL) | ||
| 395 | msleep(200); | ||
| 392 | } | 396 | } |
| 393 | 397 | ||
| 394 | static void | 398 | static void |
| @@ -421,9 +425,11 @@ start_stream(struct snd_bebob *bebob, struct amdtp_stream *stream, | |||
| 421 | conn = &bebob->out_conn; | 425 | conn = &bebob->out_conn; |
| 422 | 426 | ||
| 423 | /* channel mapping */ | 427 | /* channel mapping */ |
| 424 | err = map_data_channels(bebob, stream); | 428 | if (bebob->maudio_special_quirk == NULL) { |
| 425 | if (err < 0) | 429 | err = map_data_channels(bebob, stream); |
| 426 | goto end; | 430 | if (err < 0) |
| 431 | goto end; | ||
| 432 | } | ||
| 427 | 433 | ||
| 428 | /* start amdtp stream */ | 434 | /* start amdtp stream */ |
| 429 | err = amdtp_stream_start(stream, | 435 | err = amdtp_stream_start(stream, |
| @@ -555,13 +561,17 @@ int snd_bebob_stream_start_duplex(struct snd_bebob *bebob, int rate) | |||
| 555 | * NOTE: | 561 | * NOTE: |
| 556 | * If establishing connections at first, Yamaha GO46 | 562 | * If establishing connections at first, Yamaha GO46 |
| 557 | * (and maybe Terratec X24) don't generate sound. | 563 | * (and maybe Terratec X24) don't generate sound. |
| 564 | * | ||
| 565 | * For firmware customized by M-Audio, refer to next NOTE. | ||
| 558 | */ | 566 | */ |
| 559 | err = rate_spec->set(bebob, rate); | 567 | if (bebob->maudio_special_quirk == NULL) { |
| 560 | if (err < 0) { | 568 | err = rate_spec->set(bebob, rate); |
| 561 | dev_err(&bebob->unit->device, | 569 | if (err < 0) { |
| 562 | "fail to set sampling rate: %d\n", | 570 | dev_err(&bebob->unit->device, |
| 563 | err); | 571 | "fail to set sampling rate: %d\n", |
| 564 | goto end; | 572 | err); |
| 573 | goto end; | ||
| 574 | } | ||
| 565 | } | 575 | } |
| 566 | 576 | ||
| 567 | err = make_both_connections(bebob, rate); | 577 | err = make_both_connections(bebob, rate); |
| @@ -576,6 +586,23 @@ int snd_bebob_stream_start_duplex(struct snd_bebob *bebob, int rate) | |||
| 576 | goto end; | 586 | goto end; |
| 577 | } | 587 | } |
| 578 | 588 | ||
| 589 | /* | ||
| 590 | * NOTE: | ||
| 591 | * The firmware customized by M-Audio uses these commands to | ||
| 592 | * start transmitting stream. This is not usual way. | ||
| 593 | */ | ||
| 594 | if (bebob->maudio_special_quirk != NULL) { | ||
| 595 | err = rate_spec->set(bebob, rate); | ||
| 596 | if (err < 0) { | ||
| 597 | dev_err(&bebob->unit->device, | ||
| 598 | "fail to ensure sampling rate: %d\n", | ||
| 599 | err); | ||
| 600 | amdtp_stream_stop(master); | ||
| 601 | break_both_connections(bebob); | ||
| 602 | goto end; | ||
| 603 | } | ||
| 604 | } | ||
| 605 | |||
| 579 | /* wait first callback */ | 606 | /* wait first callback */ |
| 580 | if (!amdtp_stream_wait_callback(master, CALLBACK_TIMEOUT)) { | 607 | if (!amdtp_stream_wait_callback(master, CALLBACK_TIMEOUT)) { |
| 581 | amdtp_stream_stop(master); | 608 | amdtp_stream_stop(master); |
