selinux: fix overflow and 0 length allocations
[deliverable/linux.git] / sound / firewire / bebob / bebob_yamaha.c
1 /*
2 * bebob_yamaha.c - 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 #include "./bebob.h"
10
11 /*
12 * NOTE:
13 * Yamaha GO44 is not designed to be used as stand-alone mixer. So any streams
14 * must be accompanied. If changing the state, a LED on the device starts to
15 * blink and its sync status is false. In this state, the device sounds nothing
16 * even if streaming. To start streaming at the current sampling rate is only
17 * way to revocer this state. GO46 is better for stand-alone mixer.
18 *
19 * Both of them have a capability to change its sampling rate up to 192.0kHz.
20 * At 192.0kHz, the device reports 4 PCM-in, 1 MIDI-in, 6 PCM-out, 1 MIDI-out.
21 * But Yamaha's driver reduce 2 PCM-in, 1 MIDI-in, 2 PCM-out, 1 MIDI-out to use
22 * 'Extended Stream Format Information Command - Single Request' in 'Additional
23 * AVC commands' defined by BridgeCo.
24 * This ALSA driver don't do this because a bit tiresome. Then isochronous
25 * streaming with many asynchronous transactions brings sounds with noises.
26 * Unfortunately current 'ffado-mixer' generated many asynchronous transaction
27 * to observe device's state, mainly check cmp connection and signal format. I
28 * reccomend users to close ffado-mixer at 192.0kHz if mixer is needless.
29 */
30
31 static enum snd_bebob_clock_type clk_src_types[] = {
32 SND_BEBOB_CLOCK_TYPE_INTERNAL,
33 SND_BEBOB_CLOCK_TYPE_EXTERNAL, /* S/PDIF */
34 };
35 static int
36 clk_src_get(struct snd_bebob *bebob, unsigned int *id)
37 {
38 int err;
39
40 err = avc_audio_get_selector(bebob->unit, 0, 4, id);
41 if (err < 0)
42 return err;
43
44 if (*id >= ARRAY_SIZE(clk_src_types))
45 return -EIO;
46
47 return 0;
48 }
49 static const struct snd_bebob_clock_spec clock_spec = {
50 .num = ARRAY_SIZE(clk_src_types),
51 .types = clk_src_types,
52 .get = &clk_src_get,
53 };
54 static const struct snd_bebob_rate_spec rate_spec = {
55 .get = &snd_bebob_stream_get_rate,
56 .set = &snd_bebob_stream_set_rate,
57 };
58 const struct snd_bebob_spec yamaha_go_spec = {
59 .clock = &clock_spec,
60 .rate = &rate_spec,
61 .meter = NULL
62 };
This page took 0.032511 seconds and 5 git commands to generate.