brcm2708: update linux 4.4 patches to latest version
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-4.4 / 0250-bcm2835-add-fallback-channel-layouts-if-channel-map-.patch
1 From f3e1f2d9d34ab1cfafc4df7d67b7c65619b69ce0 Mon Sep 17 00:00:00 2001
2 From: wm4 <wm4@nowhere>
3 Date: Tue, 19 Apr 2016 16:29:41 +0200
4 Subject: [PATCH] bcm2835: add fallback channel layouts if channel map API is
5 not used
6
7 Should be more useful than just forcing stereo.
8
9 We can't match the exact legacy ALSA channel layouts, so this is a
10 "best effort" hack.
11
12 I'm not sure what happens if the application requests channel counts
13 that are not power-of-2s. The channel map API hopefully forces
14 applications which use the channel map API to request the correct
15 count by adding padding channels, but the bare API enforces
16 nothing. Possibly this could be added to rate_hw_constraint_channels
17 at a later point.
18 ---
19 sound/arm/bcm2835-vchiq.c | 11 ++++++++++-
20 1 file changed, 10 insertions(+), 1 deletion(-)
21
22 --- a/sound/arm/bcm2835-vchiq.c
23 +++ b/sound/arm/bcm2835-vchiq.c
24 @@ -598,7 +598,16 @@ int bcm2835_audio_set_params(bcm2835_als
25 if (alsa_stream->chip->cea_chmap >= 0) {
26 chmap_value = (unsigned)alsa_stream->chip->cea_chmap << 24;
27 } else {
28 - chmap_value = 0; /* force stereo */
29 + /* fallback layouts for applications which do not use chmap API */
30 + chmap_value = 0x00;
31 + switch (channels) {
32 + case 3: chmap_value = 0x01; break;
33 + case 4: chmap_value = 0x03; break;
34 + case 5: chmap_value = 0x07; break;
35 + case 6: chmap_value = 0x0b; break;
36 + case 7: chmap_value = 0x0f; break;
37 + case 8: chmap_value = 0x13; break;
38 + }
39 for (i = 0; i < 8; i++)
40 alsa_stream->chip->map_channels[i] = i;
41 }