1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0-only
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun * bebob_yamaha.c - a part of driver for BeBoB based devices
4*4882a593Smuzhiyun *
5*4882a593Smuzhiyun * Copyright (c) 2013-2014 Takashi Sakamoto
6*4882a593Smuzhiyun */
7*4882a593Smuzhiyun
8*4882a593Smuzhiyun #include "./bebob.h"
9*4882a593Smuzhiyun
10*4882a593Smuzhiyun /*
11*4882a593Smuzhiyun * NOTE:
12*4882a593Smuzhiyun * Yamaha GO44 is not designed to be used as stand-alone mixer. So any streams
13*4882a593Smuzhiyun * must be accompanied. If changing the state, a LED on the device starts to
14*4882a593Smuzhiyun * blink and its sync status is false. In this state, the device sounds nothing
15*4882a593Smuzhiyun * even if streaming. To start streaming at the current sampling rate is only
16*4882a593Smuzhiyun * way to recover this state. GO46 is better for stand-alone mixer.
17*4882a593Smuzhiyun *
18*4882a593Smuzhiyun * Both of them have a capability to change its sampling rate up to 192.0kHz.
19*4882a593Smuzhiyun * At 192.0kHz, the device reports 4 PCM-in, 1 MIDI-in, 6 PCM-out, 1 MIDI-out.
20*4882a593Smuzhiyun * But Yamaha's driver reduce 2 PCM-in, 1 MIDI-in, 2 PCM-out, 1 MIDI-out to use
21*4882a593Smuzhiyun * 'Extended Stream Format Information Command - Single Request' in 'Additional
22*4882a593Smuzhiyun * AVC commands' defined by BridgeCo.
23*4882a593Smuzhiyun * This ALSA driver don't do this because a bit tiresome. Then isochronous
24*4882a593Smuzhiyun * streaming with many asynchronous transactions brings sounds with noises.
25*4882a593Smuzhiyun * Unfortunately current 'ffado-mixer' generated many asynchronous transaction
26*4882a593Smuzhiyun * to observe device's state, mainly check cmp connection and signal format. I
27*4882a593Smuzhiyun * recommend users to close ffado-mixer at 192.0kHz if mixer is needless.
28*4882a593Smuzhiyun *
29*4882a593Smuzhiyun * Terratec PHASE 24 FW and PHASE X24 FW are internally the same as
30*4882a593Smuzhiyun * Yamaha GO 44 and GO 46. Yamaha and Terratec had cooperated for these models.
31*4882a593Smuzhiyun */
32*4882a593Smuzhiyun
33*4882a593Smuzhiyun static const enum snd_bebob_clock_type clk_src_types[] = {
34*4882a593Smuzhiyun SND_BEBOB_CLOCK_TYPE_INTERNAL,
35*4882a593Smuzhiyun SND_BEBOB_CLOCK_TYPE_EXTERNAL, /* S/PDIF */
36*4882a593Smuzhiyun };
37*4882a593Smuzhiyun static int
clk_src_get(struct snd_bebob * bebob,unsigned int * id)38*4882a593Smuzhiyun clk_src_get(struct snd_bebob *bebob, unsigned int *id)
39*4882a593Smuzhiyun {
40*4882a593Smuzhiyun int err;
41*4882a593Smuzhiyun
42*4882a593Smuzhiyun err = avc_audio_get_selector(bebob->unit, 0, 4, id);
43*4882a593Smuzhiyun if (err < 0)
44*4882a593Smuzhiyun return err;
45*4882a593Smuzhiyun
46*4882a593Smuzhiyun if (*id >= ARRAY_SIZE(clk_src_types))
47*4882a593Smuzhiyun return -EIO;
48*4882a593Smuzhiyun
49*4882a593Smuzhiyun return 0;
50*4882a593Smuzhiyun }
51*4882a593Smuzhiyun static const struct snd_bebob_clock_spec clock_spec = {
52*4882a593Smuzhiyun .num = ARRAY_SIZE(clk_src_types),
53*4882a593Smuzhiyun .types = clk_src_types,
54*4882a593Smuzhiyun .get = &clk_src_get,
55*4882a593Smuzhiyun };
56*4882a593Smuzhiyun static const struct snd_bebob_rate_spec rate_spec = {
57*4882a593Smuzhiyun .get = &snd_bebob_stream_get_rate,
58*4882a593Smuzhiyun .set = &snd_bebob_stream_set_rate,
59*4882a593Smuzhiyun };
60*4882a593Smuzhiyun const struct snd_bebob_spec yamaha_terratec_spec = {
61*4882a593Smuzhiyun .clock = &clock_spec,
62*4882a593Smuzhiyun .rate = &rate_spec,
63*4882a593Smuzhiyun .meter = NULL
64*4882a593Smuzhiyun };
65