brcm2708: add linux 4.19 support
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-4.19 / 950-0482-Revert-staging-bcm2835-audio-Drop-DT-dependency.patch
1 From 5a957250fdb0f0b45bd41569c754a676fa556225 Mon Sep 17 00:00:00 2001
2 From: popcornmix <popcornmix@gmail.com>
3 Date: Wed, 1 May 2019 14:23:39 +0100
4 Subject: [PATCH 482/703] Revert "staging: bcm2835-audio: Drop DT dependency"
5
6 This reverts commit 60a2e557a4f81480216066f22b84c3dda31b3470.
7 ---
8 .../vc04_services/bcm2835-audio/bcm2835.c | 31 +++++++++++++------
9 1 file changed, 22 insertions(+), 9 deletions(-)
10
11 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c
12 +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c
13 @@ -6,13 +6,13 @@
14 #include <linux/init.h>
15 #include <linux/slab.h>
16 #include <linux/module.h>
17 +#include <linux/of.h>
18
19 #include "bcm2835.h"
20
21 static bool enable_hdmi;
22 static bool enable_headphones;
23 static bool enable_compat_alsa = true;
24 -static int num_channels = MAX_SUBSTREAMS;
25
26 module_param(enable_hdmi, bool, 0444);
27 MODULE_PARM_DESC(enable_hdmi, "Enables HDMI virtual audio device");
28 @@ -21,8 +21,6 @@ MODULE_PARM_DESC(enable_headphones, "Ena
29 module_param(enable_compat_alsa, bool, 0444);
30 MODULE_PARM_DESC(enable_compat_alsa,
31 "Enables ALSA compatibility virtual audio device");
32 -module_param(num_channels, int, 0644);
33 -MODULE_PARM_DESC(num_channels, "Number of audio channels (default: 8)");
34
35 static void bcm2835_devm_free_vchi_ctx(struct device *dev, void *res)
36 {
37 @@ -296,19 +294,28 @@ static int snd_add_child_devices(struct
38 static int snd_bcm2835_alsa_probe(struct platform_device *pdev)
39 {
40 struct device *dev = &pdev->dev;
41 + u32 numchans;
42 int err;
43
44 - if (num_channels <= 0 || num_channels > MAX_SUBSTREAMS) {
45 - num_channels = MAX_SUBSTREAMS;
46 - dev_warn(dev, "Illegal num_channels value, will use %u\n",
47 - num_channels);
48 + err = of_property_read_u32(dev->of_node, "brcm,pwm-channels",
49 + &numchans);
50 + if (err) {
51 + dev_err(dev, "Failed to get DT property 'brcm,pwm-channels'");
52 + return err;
53 + }
54 +
55 + if (numchans == 0 || numchans > MAX_SUBSTREAMS) {
56 + numchans = MAX_SUBSTREAMS;
57 + dev_warn(dev,
58 + "Illegal 'brcm,pwm-channels' value, will use %u\n",
59 + numchans);
60 }
61
62 err = bcm2835_devm_add_vchi_ctx(dev);
63 if (err)
64 return err;
65
66 - err = snd_add_child_devices(dev, num_channels);
67 + err = snd_add_child_devices(dev, numchans);
68 if (err)
69 return err;
70
71 @@ -330,6 +337,12 @@ static int snd_bcm2835_alsa_resume(struc
72
73 #endif
74
75 +static const struct of_device_id snd_bcm2835_of_match_table[] = {
76 + { .compatible = "brcm,bcm2835-audio",},
77 + {},
78 +};
79 +MODULE_DEVICE_TABLE(of, snd_bcm2835_of_match_table);
80 +
81 static struct platform_driver bcm2835_alsa_driver = {
82 .probe = snd_bcm2835_alsa_probe,
83 #ifdef CONFIG_PM
84 @@ -338,6 +351,7 @@ static struct platform_driver bcm2835_al
85 #endif
86 .driver = {
87 .name = "bcm2835_audio",
88 + .of_match_table = snd_bcm2835_of_match_table,
89 },
90 };
91 module_platform_driver(bcm2835_alsa_driver);
92 @@ -345,4 +359,3 @@ module_platform_driver(bcm2835_alsa_driv
93 MODULE_AUTHOR("Dom Cobley");
94 MODULE_DESCRIPTION("Alsa driver for BCM2835 chip");
95 MODULE_LICENSE("GPL");
96 -MODULE_ALIAS("platform:bcm2835_audio");