a7b790694b6066c9c88ab1ad0ad72b9ad961afaa
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-4.4 / 0132-bcm2835-only-allow-stereo-if-analogue-jack-is-select.patch
1 From 5f7049894f47b3836838cd68e29ee883179c80b3 Mon Sep 17 00:00:00 2001
2 From: wm4 <wm4@nowhere>
3 Date: Wed, 13 Jan 2016 19:44:24 +0100
4 Subject: [PATCH 132/232] bcm2835: only allow stereo if analogue jack is
5 selected
6
7 Sending more than 2 channels to videocore while outputting to analogue
8 mysteriously outputs heavy artifacts. So just paint it over with a
9 hack: if analogue is explicitly selected as destination, do not
10 reporting support for anything other than stereo.
11
12 I'm not sure how to deal with the auto case (destination 0). There's
13 probably way to retrieve this and even to listen to plug events, but
14 I didn't find one yet, and it's probably not worth the trouble. Just
15 don't use this setting, I guess. Unless you like noise.
16
17 Changing the setting while an audio stream is active also doesn't
18 work properly. We could probably interrupt running streams by
19 returning ENODEV or using kernel hotplug stuff (maybe), but that
20 also doesn't seem worth the trouble.
21 ---
22 sound/arm/bcm2835-ctl.c | 12 ++++++++++++
23 1 file changed, 12 insertions(+)
24
25 --- a/sound/arm/bcm2835-ctl.c
26 +++ b/sound/arm/bcm2835-ctl.c
27 @@ -423,9 +423,16 @@ static struct cea_channel_speaker_alloca
28 { .ca_index = 0x31, .speakers = { FRW, FLW, RR, RL, FC, LFE, FR, FL } },
29 };
30
31 +static int uses_analogue(bcm2835_chip_t *chip)
32 +{
33 + return chip->dest == 1;
34 +}
35 +
36 static int snd_bcm2835_chmap_ctl_tlv(struct snd_kcontrol *kcontrol, int op_flag,
37 unsigned int size, unsigned int __user *tlv)
38 {
39 + struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol);
40 + bcm2835_chip_t *chip = info->private_data;
41 unsigned int __user *dst;
42 int count = 0;
43 int i;
44 @@ -442,6 +449,9 @@ static int snd_bcm2835_chmap_ctl_tlv(str
45 int chs_bytes;
46 int c;
47
48 + if (i > 0 && uses_analogue(chip))
49 + break;
50 +
51 for (c = 0; c < 8; c++) {
52 if (ch->speakers[c])
53 num_chs++;
54 @@ -552,6 +562,8 @@ static int snd_bcm2835_chmap_ctl_put(str
55 int matches = 1;
56 int cur = 0;
57 int x;
58 + if (i > 0 && uses_analogue(chip))
59 + break;
60 memset(remap, 0, sizeof(remap));
61 for (x = 0; x < substream->runtime->channels; x++) {
62 int sp = ucontrol->value.integer.value[x];