1 From 369f591ee78af2d53c67f561daeb963cc4aa60aa 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 476/806] Revert "staging: bcm2835-audio: Drop DT dependency"
6 This reverts commit 60a2e557a4f81480216066f22b84c3dda31b3470.
8 .../vc04_services/bcm2835-audio/bcm2835.c | 31 +++++++++++++------
9 1 file changed, 22 insertions(+), 9 deletions(-)
11 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c
12 +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c
14 #include <linux/init.h>
15 #include <linux/slab.h>
16 #include <linux/module.h>
17 +#include <linux/of.h>
21 static bool enable_hdmi;
22 static bool enable_headphones;
23 static bool enable_compat_alsa = true;
24 -static int num_channels = MAX_SUBSTREAMS;
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)");
35 static void bcm2835_devm_free_vchi_ctx(struct device *dev, void *res)
37 @@ -296,19 +294,28 @@ static int snd_add_child_devices(struct
38 static int snd_bcm2835_alsa_probe(struct platform_device *pdev)
40 struct device *dev = &pdev->dev;
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",
48 + err = of_property_read_u32(dev->of_node, "brcm,pwm-channels",
51 + dev_err(dev, "Failed to get DT property 'brcm,pwm-channels'");
55 + if (numchans == 0 || numchans > MAX_SUBSTREAMS) {
56 + numchans = MAX_SUBSTREAMS;
58 + "Illegal 'brcm,pwm-channels' value, will use %u\n",
62 err = bcm2835_devm_add_vchi_ctx(dev);
66 - err = snd_add_child_devices(dev, num_channels);
67 + err = snd_add_child_devices(dev, numchans);
71 @@ -330,6 +337,12 @@ static int snd_bcm2835_alsa_resume(struc
75 +static const struct of_device_id snd_bcm2835_of_match_table[] = {
76 + { .compatible = "brcm,bcm2835-audio",},
79 +MODULE_DEVICE_TABLE(of, snd_bcm2835_of_match_table);
81 static struct platform_driver bcm2835_alsa_driver = {
82 .probe = snd_bcm2835_alsa_probe,
84 @@ -338,6 +351,7 @@ static struct platform_driver bcm2835_al
87 .name = "bcm2835_audio",
88 + .of_match_table = snd_bcm2835_of_match_table,
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");