You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2022/04/10 22:12:16 UTC

[incubator-nuttx] branch master updated (1a6ee1b908 -> 218cbb470a)

This is an automated email from the ASF dual-hosted git repository.

acassis pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


    from 1a6ee1b908 audio: Don't register audio device if name isn't given in audio_comp_initialize
     new eb3e8175de Fixes some issues with the implementation of the balance functionality. In function "wm8904_hw_reset" the priv->balance is initialized with b16HALF, indicating a range from 0 to b16ONE. In function "wm8904_setvolume" the assumed range for priv->balance is between 0 and 1000. The changes now make this consistent for 0 to b16ONE-1. Furthermore, in wm8904_configure the change of balance was not implemented.
     new 56f0d72465 Minor fix, function name was wm8994_setvolume instead of wm8904_setvolume.
     new 218cbb470a Fixed source code format errors.

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 drivers/audio/wm8904.c | 47 +++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 41 insertions(+), 6 deletions(-)


[incubator-nuttx] 02/03: Minor fix, function name was wm8994_setvolume instead of wm8904_setvolume.

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 56f0d7246510cff2fb848fc9bc4fee3329a623db
Author: okayserh <o....@gmail.com>
AuthorDate: Sun Apr 10 19:04:16 2022 +0200

    Minor fix, function name was wm8994_setvolume instead of
    wm8904_setvolume.
---
 drivers/audio/wm8904.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/audio/wm8904.c b/drivers/audio/wm8904.c
index 2a056cb8b9..26f05e7f94 100644
--- a/drivers/audio/wm8904.c
+++ b/drivers/audio/wm8904.c
@@ -1228,7 +1228,7 @@ static int wm8904_configure(FAR struct audio_lowerhalf_s *dev,
               {
                 /* Scale the balance setting to the range {0..(b16ONE - 1)} */
 		priv->balance = (balance * (b16ONE - 1)) / 1000;
-                wm8994_setvolume(priv, priv->volume, priv->mute);
+                wm8904_setvolume(priv, priv->volume, priv->mute);
               }
             else
               {


[incubator-nuttx] 03/03: Fixed source code format errors.

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 218cbb470a24222c4356e5fa8f04d306db974350
Author: okayserh <o....@gmail.com>
AuthorDate: Sun Apr 10 19:11:15 2022 +0200

    Fixed source code format errors.
---
 drivers/audio/wm8904.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/audio/wm8904.c b/drivers/audio/wm8904.c
index 26f05e7f94..0f974c7f3c 100644
--- a/drivers/audio/wm8904.c
+++ b/drivers/audio/wm8904.c
@@ -490,9 +490,12 @@ static void wm8904_setvolume(FAR struct wm8904_dev_s *priv, uint16_t volume,
     }
   else
     {
-      /* Note: b16ONE - balance goes from 0 to 0.5. Hence need to multiply volume by 2! */
+      /* Note: b16ONE - balance goes from 0 to 0.5.
+       * Hence need to multiply volume by 2!
+       */
 
-      leftlevel = wm8904_scalevolume(2 * volume, b16ONE - (b16_t)priv->balance);
+      leftlevel = wm8904_scalevolume(2 * volume,
+                                     b16ONE - (b16_t)priv->balance);
     }
 
   /* Calculate the right channel volume level {0..1000} */
@@ -507,9 +510,12 @@ static void wm8904_setvolume(FAR struct wm8904_dev_s *priv, uint16_t volume,
     }
   else
     {
-      /* Note: b16ONE - balance goes from 0 to 0.5. Hence need to multiply volume by 2! */
+      /* Note: b16ONE - balance goes from 0 to 0.5.
+       * Hence need to multiply volume by 2!
+       */
 
-      rightlevel = wm8904_scalevolume(2 * volume, (b16_t)priv->balance);
+      rightlevel = wm8904_scalevolume(2 * volume,
+                                      (b16_t)priv->balance);
     }
 #else
   leftlevel  = priv->volume;
@@ -1227,7 +1233,8 @@ static int wm8904_configure(FAR struct audio_lowerhalf_s *dev,
             if (balance >= 0 && balance <= 1000)
               {
                 /* Scale the balance setting to the range {0..(b16ONE - 1)} */
-		priv->balance = (balance * (b16ONE - 1)) / 1000;
+
+                priv->balance = (balance * (b16ONE - 1)) / 1000;
                 wm8904_setvolume(priv, priv->volume, priv->mute);
               }
             else


[incubator-nuttx] 01/03: Fixes some issues with the implementation of the balance functionality. In function "wm8904_hw_reset" the priv->balance is initialized with b16HALF, indicating a range from 0 to b16ONE. In function "wm8904_setvolume" the assumed range for priv->balance is between 0 and 1000. The changes now make this consistent for 0 to b16ONE-1. Furthermore, in wm8904_configure the change of balance was not implemented.

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit eb3e8175de4cf7d5d7ec73c7e0abe86cf72cf09f
Author: okayserh <o....@gmail.com>
AuthorDate: Sun Apr 10 19:00:22 2022 +0200

    Fixes some issues with the implementation of the balance
    functionality. In function "wm8904_hw_reset" the priv->balance
    is initialized with b16HALF, indicating a range from
    0 to b16ONE. In function "wm8904_setvolume" the assumed
    range for priv->balance is between 0 and 1000. The changes
    now make this consistent for 0 to b16ONE-1. Furthermore,
    in wm8904_configure the change of balance was not implemented.
---
 drivers/audio/wm8904.c | 40 ++++++++++++++++++++++++++++++++++------
 1 file changed, 34 insertions(+), 6 deletions(-)

diff --git a/drivers/audio/wm8904.c b/drivers/audio/wm8904.c
index baec14523c..2a056cb8b9 100644
--- a/drivers/audio/wm8904.c
+++ b/drivers/audio/wm8904.c
@@ -480,22 +480,24 @@ static void wm8904_setvolume(FAR struct wm8904_dev_s *priv, uint16_t volume,
 #ifndef CONFIG_AUDIO_EXCLUDE_BALANCE
   /* Calculate the left channel volume level {0..1000} */
 
-  if (priv->balance <= 500)
+  if (priv->balance <= (b16HALF - 1))
     {
       leftlevel = volume;
     }
-  else if (priv->balance == 1000)
+  else if (priv->balance == (b16ONE - 1))
     {
       leftlevel = 0;
     }
   else
     {
-      leftlevel = wm8904_scalevolume(volume, b16ONE - (b16_t)priv->balance);
+      /* Note: b16ONE - balance goes from 0 to 0.5. Hence need to multiply volume by 2! */
+
+      leftlevel = wm8904_scalevolume(2 * volume, b16ONE - (b16_t)priv->balance);
     }
 
   /* Calculate the right channel volume level {0..1000} */
 
-  if (priv->balance >= 500)
+  if (priv->balance >= (b16HALF - 1))
     {
       rightlevel = volume;
     }
@@ -505,7 +507,9 @@ static void wm8904_setvolume(FAR struct wm8904_dev_s *priv, uint16_t volume,
     }
   else
     {
-      rightlevel = wm8904_scalevolume(volume, (b16_t)priv->balance);
+      /* Note: b16ONE - balance goes from 0 to 0.5. Hence need to multiply volume by 2! */
+
+      rightlevel = wm8904_scalevolume(2 * volume, (b16_t)priv->balance);
     }
 #else
   leftlevel  = priv->volume;
@@ -1210,6 +1214,30 @@ static int wm8904_configure(FAR struct audio_lowerhalf_s *dev,
           break;
 #endif /* CONFIG_AUDIO_EXCLUDE_VOLUME */
 
+#ifndef CONFIG_AUDIO_EXCLUDE_BALANCE
+        case AUDIO_FU_BALANCE:
+          {
+            /* Set the balance.  The percentage level * 10 (0-1000) is in the
+             * ac_controls.b[0] parameter.
+             */
+
+            uint16_t balance = caps->ac_controls.hw[0];
+            audinfo("    Balance: %d\n", balance);
+
+            if (balance >= 0 && balance <= 1000)
+              {
+                /* Scale the balance setting to the range {0..(b16ONE - 1)} */
+		priv->balance = (balance * (b16ONE - 1)) / 1000;
+                wm8994_setvolume(priv, priv->volume, priv->mute);
+              }
+            else
+              {
+                ret = -EDOM;
+              }
+           }
+          break;
+#endif /* CONFIG_AUDIO_EXCLUDE_BALANCE */
+
 #ifndef CONFIG_AUDIO_EXCLUDE_TONE
         case AUDIO_FU_BASS:
           {
@@ -2492,7 +2520,7 @@ static void wm8904_hw_reset(FAR struct wm8904_dev_s *priv)
   priv->nchannels  = WM8904_DEFAULT_NCHANNELS;
   priv->bpsamp     = WM8904_DEFAULT_BPSAMP;
 #if !defined(CONFIG_AUDIO_EXCLUDE_VOLUME) && !defined(CONFIG_AUDIO_EXCLUDE_BALANCE)
-  priv->balance    = b16HALF;            /* Center balance */
+  priv->balance    = b16HALF - 1;            /* Center balance */
 #endif
 
   /* Software reset.  This puts all WM8904 registers back in their