Browse Source

更新语音板驱动程序,适配最新系统

corvin 3 years ago
parent
commit
90d1ad639b
3 changed files with 31 additions and 59 deletions
  1. 2 2
      install.sh
  2. 17 20
      wm8960-soundcard
  3. 12 37
      wm8960-soundcard.c

+ 2 - 2
install.sh

@@ -69,8 +69,8 @@ grep -q "dtoverlay=i2s-mmap" /boot/config.txt || \
 grep -q "dtparam=i2s=on" /boot/config.txt || \
   echo "dtparam=i2s=on" >> /boot/config.txt
 
-grep -q "dtoverlay=wm8960-soundcard" /boot/config.txt || \
-  echo "dtoverlay=wm8960-soundcard" >> /boot/config.txt
+#grep -q "dtoverlay=wm8960-soundcard" /boot/config.txt || \
+#  echo "dtoverlay=wm8960-soundcard" >> /boot/config.txt
   
 #install config files
 mkdir /etc/wm8960-soundcard || true

+ 17 - 20
wm8960-soundcard

@@ -7,29 +7,26 @@ dtparam i2c_arm=on
 modprobe i2c-dev
 
 sleep 1
+for loop in 1 2 3 4 5
+do
+    is_1a=$(i2cdetect -y  1 0x1a 0x1a | egrep "(1a|UU)" | awk '{print $2}')
 
-is_1a=$(i2cdetect -y  1 0x1a 0x1a | egrep "(1a|UU)" | awk '{print $2}')
+    if [ "x${is_1a}" != "x" ] ; then
+        echo "install wm8960-soundcard"
+        dtoverlay wm8960-soundcard
+        sleep 1
 
+        rm /etc/asound.conf
+        rm /var/lib/alsa/asound.state
 
+        echo "create wm8960-soundcard configure file"
+        ln -s /etc/wm8960-soundcard/asound.conf /etc/asound.conf
 
-if [ "x${is_1a}" != "x" ] ; then
-    echo "install wm8960-soundcard"
-    dtoverlay wm8960-soundcard
-    sleep 1
-    
-    rm /etc/asound.conf
-    rm /var/lib/alsa/asound.state
-    
-    echo "create wm8960-soundcard configure file"
-    ln -s /etc/wm8960-soundcard/asound.conf /etc/asound.conf
-    
-    echo "create wm8960-soundcard status file"
-    ln -s /etc/wm8960-soundcard/wm8960_asound.state /var/lib/alsa/asound.state
-fi
+        echo "create wm8960-soundcard status file"
+        ln -s /etc/wm8960-soundcard/wm8960_asound.state /var/lib/alsa/asound.state
+        break
+    fi
+    sleep 3
+done
 
 alsactl restore
-
-#Fore 3.5mm ('headphone') jack
-amixer cset numid=3 1 
-
-

+ 12 - 37
wm8960-soundcard.c

@@ -149,7 +149,7 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv,
 	if (li->cpu) {
 		int is_single_links = 0;
 
-		/* BE is dummy */
+		/* Codec is dummy */
 		codecs->of_node		= NULL;
 		codecs->dai_name	= "snd-soc-dummy-dai";
 		codecs->name		= "snd-soc-dummy";
@@ -179,7 +179,7 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv,
 	} else {
 		struct snd_soc_codec_conf *cconf;
 
-		/* FE is dummy */
+		/* CPU is dummy */
 		cpus->of_node		= NULL;
 		cpus->dai_name		= "snd-soc-dummy-dai";
 		cpus->name		= "snd-soc-dummy";
@@ -231,8 +231,8 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv,
 	if (ret < 0)
 		goto out_put_node;
 
-	dai_link->dpcm_playback		= 1;
-	dai_link->dpcm_capture		= 1;
+	snd_soc_dai_link_set_capabilities(dai_link);
+
 	dai_link->ops			= &simple_ops;
 	dai_link->init			= asoc_simple_dai_init;
 
@@ -258,7 +258,7 @@ static int simple_dai_link_of(struct asoc_simple_priv *priv,
 	struct device_node *plat = NULL;
 	char prop[128];
 	char *prefix = "";
-	int ret, single_cpu;
+	int ret, single_cpu = 0;
 
 	/*
 	 *	 |CPU   |Codec   : turn
@@ -371,6 +371,7 @@ static int simple_for_each_link(struct asoc_simple_priv *priv,
 	do {
 		struct asoc_simple_data adata;
 		struct device_node *codec;
+		struct device_node *plat;
 		struct device_node *np;
 		int num = of_get_child_count(node);
 
@@ -381,6 +382,9 @@ static int simple_for_each_link(struct asoc_simple_priv *priv,
 			ret = -ENODEV;
 			goto error;
 		}
+		/* get platform */
+		plat = of_get_child_by_name(node, is_top ?
+					    PREFIX "plat" : "plat");
 
 		/* get convert-xxx property */
 		memset(&adata, 0, sizeof(adata));
@@ -389,6 +393,8 @@ static int simple_for_each_link(struct asoc_simple_priv *priv,
 
 		/* loop for all CPU/Codec node */
 		for_each_child_of_node(node, np) {
+			if (plat == np)
+				continue;
 			/*
 			 * It is DPCM
 			 * if it has many CPUs,
@@ -418,37 +424,6 @@ static int simple_for_each_link(struct asoc_simple_priv *priv,
 	return ret;
 }
 
-static int simple_parse_aux_devs(struct device_node *node,
-				 struct asoc_simple_priv *priv)
-{
-	struct device *dev = simple_priv_to_dev(priv);
-	struct device_node *aux_node;
-	struct snd_soc_card *card = simple_priv_to_card(priv);
-	int i, n, len;
-
-	if (!of_find_property(node, PREFIX "aux-devs", &len))
-		return 0;		/* Ok to have no aux-devs */
-
-	n = len / sizeof(__be32);
-	if (n <= 0)
-		return -EINVAL;
-
-	card->aux_dev = devm_kcalloc(dev,
-			n, sizeof(*card->aux_dev), GFP_KERNEL);
-	if (!card->aux_dev)
-		return -ENOMEM;
-
-	for (i = 0; i < n; i++) {
-		aux_node = of_parse_phandle(node, PREFIX "aux-devs", i);
-		if (!aux_node)
-			return -EINVAL;
-		card->aux_dev[i].dlc.of_node = aux_node;
-	}
-
-	card->num_aux_devs = n;
-	return 0;
-}
-
 static int simple_parse_of(struct asoc_simple_priv *priv)
 {
 	struct device *dev = simple_priv_to_dev(priv);
@@ -498,7 +473,7 @@ static int simple_parse_of(struct asoc_simple_priv *priv)
 	if (ret < 0)
 		return ret;
 
-	ret = simple_parse_aux_devs(top, priv);
+	ret = snd_soc_of_parse_aux_devs(card, PREFIX "aux-devs");
 
 	return ret;
 }