You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/04/21 23:20:01 UTC

[incubator-nuttx] branch master updated (fc8522c -> 79589ec)

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

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


    from fc8522c  tools/testbuild.sh: check status after make distclean
     new 76c47f6  libc: audio: nxstyle fixes
     new d9d720b  audio: nxstyle fixes for core and drivers
     new 7a83177  cxd56: disable unused audio effects
     new 36e756a  cxd56: add support for pause and resume
     new ecc4939  cxd56: fix volume setting and improve volume range
     new 79589ec  cxd56: replace Sony return values

The 6 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:
 audio/audio.c                    | 117 +++++---
 audio/audio_comp.c               |   8 +-
 audio/pcm_decode.c               |  55 ++--
 drivers/audio/audio_i2s.c        |   4 +-
 drivers/audio/audio_null.c       |  59 ++--
 drivers/audio/cs43l22.c          |  10 +-
 drivers/audio/cs43l22.h          |  57 ++--
 drivers/audio/cs43l22_debug.c    |  78 +++---
 drivers/audio/cxd56.c            | 564 ++++++++++++++++++++++-----------------
 drivers/audio/cxd56.h            |   5 +-
 drivers/audio/tone.c             |  32 ++-
 drivers/audio/vs1053.c           | 307 ++++++++++++---------
 drivers/audio/vs1053.h           |  34 +--
 drivers/audio/wm8776.c           |  10 +-
 drivers/audio/wm8776.h           |   9 +-
 drivers/audio/wm8904.c           |  18 +-
 drivers/audio/wm8904.h           |  90 ++++---
 drivers/audio/wm8904_debug.c     |  12 +-
 include/nuttx/audio/audio.h      | 129 +++++----
 include/nuttx/audio/audio_null.h |   1 +
 include/nuttx/audio/cs43l22.h    |  18 +-
 include/nuttx/audio/i2s.h        |  35 ++-
 include/nuttx/audio/pcm.h        |   5 +-
 include/nuttx/audio/wm8776.h     |   2 -
 include/nuttx/audio/wm8904.h     |   2 +
 libs/libc/audio/lib_buffer.c     |   6 +-
 26 files changed, 989 insertions(+), 678 deletions(-)


[incubator-nuttx] 03/06: cxd56: disable unused audio effects

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

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

commit 7a83177419147d74e812eccc50141cf9ac41ce3b
Author: Tobias Johansson <to...@sony.com>
AuthorDate: Fri Apr 17 15:42:31 2020 +0200

    cxd56: disable unused audio effects
    
    Disables audio effects that are not currently in use.
    Also fixes some minor indentation issues.
---
 drivers/audio/cxd56.c | 72 ++++++++++++++++++++++++++-------------------------
 1 file changed, 37 insertions(+), 35 deletions(-)

diff --git a/drivers/audio/cxd56.c b/drivers/audio/cxd56.c
index f7f7289..579cc24 100644
--- a/drivers/audio/cxd56.c
+++ b/drivers/audio/cxd56.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * drivers/audio/cxd56.h
+ * drivers/audio/cxd56.c
  *
  *   Copyright 2019 Sony Semiconductor Solutions Corporation
  *
@@ -1006,29 +1006,29 @@ static void cxd56_set_volume(enum cxd56_vol_id_e id, int16_t vol, bool fade)
     }
 
   switch (id)
-  {
-    case CXD56_VOL_ID_MIXER_IN1:
-      write_reg(REG_AC_SDIN1_VOL, vol);
-      break;
-    case CXD56_VOL_ID_MIXER_IN2:
-      write_reg(REG_AC_SDIN2_VOL, vol);
-      break;
-    case CXD56_VOL_ID_MIXER_OUT:
-      write_reg(REG_AC_DAC_VOL, vol);
-      break;
-  }
+    {
+      case CXD56_VOL_ID_MIXER_IN1:
+        write_reg(REG_AC_SDIN1_VOL, vol);
+        break;
+      case CXD56_VOL_ID_MIXER_IN2:
+        write_reg(REG_AC_SDIN2_VOL, vol);
+        break;
+      case CXD56_VOL_ID_MIXER_OUT:
+        write_reg(REG_AC_DAC_VOL, vol);
+        break;
+    }
 
   waittime = (fade ? CXD56_VOL_MUTE_TIME(vol, 1) : CXD56_VOL_WAIT_TIME);
 
   nxsig_usleep(waittime);
 
   if (vol == CXD56_VOL_MUTE_REG)
-  {
-    /* Disable analog out */
+    {
+      /* Disable analog out */
 
-    as_aca_control(CXD56_ACA_CTL_SET_OUTPUT_DEVICE,
-                   (uint32_t)CXD56_OUT_DEV_OFF);
-  }
+      as_aca_control(CXD56_ACA_CTL_SET_OUTPUT_DEVICE,
+                     (uint32_t)CXD56_OUT_DEV_OFF);
+    }
 }
 
 static void cxd56_init_i2s1_output(uint8_t bits)
@@ -1321,8 +1321,27 @@ static uint32_t cxd56_power_on(FAR struct cxd56_dev_s *dev)
 
       write_reg(REG_I2S_ENSEL, (dev->samplerate > 48000) ? 1 : 0);
 
-      /* TODO: alc, cstereo, dnc, deq, vol & datapath (reset mic */
+      /* Disable DEQ */
+      write_reg(REG_AC_DEQ_EN, 0);
+
+      /* Disable DNC. */
 
+      write_reg(REG_AC_DNC1_MUTE, 1);
+      write_reg(REG_AC_DNC2_MUTE, 1);
+      write_reg(REG_AC_DNC1_START, 0);
+      write_reg(REG_AC_DNC2_START, 0);
+
+      /* Disable ALC/SPC */
+
+      write_reg(REG_AC_ALC_EN, 0);
+      write_reg(REG_AC_SPC_EN, 0);
+
+      /* Disable Clear Stereo */
+
+      write_reg(REG_AC_CS_SIGN, 0);
+      write_reg(REG_AC_CS_VOL, 0x00);
+
+      /* Attach interrupts */
       cxd56_attach_irq(true);
       cxd56_enable_irq(true);
     }
@@ -1337,25 +1356,10 @@ static uint32_t cxd56_power_off(FAR struct cxd56_dev_s *dev)
 {
   audinfo("cxd56_power_off\n");
 
-  /* Codec block. */
-
   /* Disable AHBMASTER. */
 
   write_reg(REG_AC_MCK_AMBMSTR_EN, 0);
 
-  /* Disable CODEC. */
-
-  write_reg(REG_AC_ALC_EN, 0);
-  write_reg(REG_AC_SPC_EN, 0);
-  write_reg(REG_AC_DEQ_EN, 0);
-
-  /* Disable DNC. */
-
-  write_reg(REG_AC_DNC1_MUTE, 1);
-  write_reg(REG_AC_DNC2_MUTE, 1);
-  write_reg(REG_AC_DNC1_START, 0);
-  write_reg(REG_AC_DNC2_START, 0);
-
   /* Disable SRC. */
 
   write_reg(REG_AC_SDIN1_EN, 0);
@@ -1387,8 +1391,6 @@ static uint32_t cxd56_power_off(FAR struct cxd56_dev_s *dev)
   write_reg(REG_AC_PDN_DNC2, 1);
   write_reg(REG_AC_PDN_ANC, 1);
 
-  /* Analog block. */
-
   /* Disable audio clock */
 
   cxd56_audio_clock_disable();


[incubator-nuttx] 05/06: cxd56: fix volume setting and improve volume range

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

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

commit ecc4939453a196f3d3f5e016d345fc6dbd2fafda
Author: Tobias Johansson <to...@sony.com>
AuthorDate: Sun Apr 19 22:07:21 2020 +0200

    cxd56: fix volume setting and improve volume range
    
    - Setting volume now works except when in paused state
    - Volume range decreased to be a little more sane
---
 drivers/audio/cxd56.c | 85 ++++++++++++++++++++++++++++-----------------------
 1 file changed, 46 insertions(+), 39 deletions(-)

diff --git a/drivers/audio/cxd56.c b/drivers/audio/cxd56.c
index 25d7f7b..871e972 100644
--- a/drivers/audio/cxd56.c
+++ b/drivers/audio/cxd56.c
@@ -68,9 +68,9 @@
 #define CXD56_VOL_MIN            -1020
 #define CXD56_VOL_MAX            120
 #define CXD56_VOL_MUTE           (CXD56_VOL_MIN - 1)
-#define CXD56_VOL_RANGE          (CXD56_VOL_MAX - CXD56_VOL_MIN)
+#define CXD56_VOL_RANGE          ((CXD56_VOL_MAX - CXD56_VOL_MIN) / 2)
 #define CXD56_VOL_NX_TO_CXD56(v) ((int)((float)((v) / 1000.0) * CXD56_VOL_RANGE) \
-                                 + CXD56_VOL_MIN)
+                                 + CXD56_VOL_MIN + CXD56_VOL_RANGE)
 #define CXD56_VOL_WAIT_TIME      20
 #define CXD56_VOL_TO_REG(vol)    (((vol) / 5) & 0xff)
 #define CXD56_VOL_MUTE_REG       0x33
@@ -301,7 +301,7 @@ static int cxd56_start_dma(FAR struct cxd56_dev_s *dev);
 static int cxd56_stop_dma(FAR struct cxd56_dev_s *priv);
 static void cxd56_set_dma_int_en(bool enabled);
 static void cxd56_set_dma_running(cxd56_dmahandle_t handle, bool running);
-static void cxd56_set_volume(enum cxd56_vol_id_e id, int16_t vol, bool fade);
+static int cxd56_set_volume(enum cxd56_vol_id_e id, int16_t vol);
 static void cxd56_swap_buffer_rl(uint32_t addr, uint16_t size);
 static void *cxd56_workerthread(pthread_addr_t pvarg);
 
@@ -986,9 +986,9 @@ static void cxd56_enable_irq(bool enable)
     }
 }
 
-static void cxd56_set_volume(enum cxd56_vol_id_e id, int16_t vol, bool fade)
+static int cxd56_set_volume(enum cxd56_vol_id_e id, int16_t vol)
 {
-  uint32_t waittime = 0;
+  int ret;
 
   if (vol == CXD56_VOL_MUTE)
     {
@@ -996,18 +996,7 @@ static void cxd56_set_volume(enum cxd56_vol_id_e id, int16_t vol, bool fade)
     }
   else
     {
-      CXD56_AUDIO_ECODE ret;
-
       vol = CXD56_VOL_TO_REG(vol);
-
-      /* Enable analog out */
-
-      ret = as_aca_control(CXD56_ACA_CTL_SET_OUTPUT_DEVICE,
-                           (uint32_t)CXD56_OUT_DEV_SP);
-      if (ret != CXD56_AUDIO_ECODE_OK)
-        {
-          auderr("cxd56_set_volume analog out enable failed. (%d)\n", ret);
-        }
     }
 
   switch (id)
@@ -1023,17 +1012,37 @@ static void cxd56_set_volume(enum cxd56_vol_id_e id, int16_t vol, bool fade)
         break;
     }
 
-  waittime = (fade ? CXD56_VOL_MUTE_TIME(vol, 1) : CXD56_VOL_WAIT_TIME);
-
-  nxsig_usleep(waittime);
 
   if (vol == CXD56_VOL_MUTE_REG)
     {
       /* Disable analog out */
 
-      as_aca_control(CXD56_ACA_CTL_SET_OUTPUT_DEVICE,
-                     (uint32_t)CXD56_OUT_DEV_OFF);
+      ret = as_aca_control(CXD56_ACA_CTL_SET_OUTPUT_DEVICE,
+                           (uint32_t)CXD56_OUT_DEV_OFF);
+      if (ret != CXD56_AUDIO_ECODE_OK)
+        {
+          auderr("cxd56_set_volume analog out disable failed. (%d)\n", ret);
+          ret = -EBUSY;
+          goto error;
+        }
     }
+  else
+    {
+      /* Enable analog out */
+
+      ret = as_aca_control(CXD56_ACA_CTL_SET_OUTPUT_DEVICE,
+                           (uint32_t)CXD56_OUT_DEV_SP);
+      if (ret != CXD56_AUDIO_ECODE_OK)
+        {
+          auderr("cxd56_set_volume analog out enable failed. (%d)\n", ret);
+          ret = -EBUSY;
+          goto error;
+        }
+    }
+  ret = OK;
+
+error:
+  return ret;
 }
 
 static void cxd56_init_i2s1_output(uint8_t bits)
@@ -1234,7 +1243,7 @@ static uint32_t cxd56_power_on_analog_output(FAR struct cxd56_dev_s *dev)
   write_reg(REG_INT_M_OVF_SMASR, 0);
   write_reg(REG_AC_NSPMUTE, 0);
 
-  cxd56_set_volume(CXD56_AUDIO_VOLID_MIXER_OUT, dev->volume, true);
+  cxd56_set_volume(CXD56_AUDIO_VOLID_MIXER_OUT, dev->volume);
 
   return CXD56_AUDIO_ECODE_OK;
 }
@@ -1323,6 +1332,7 @@ static uint32_t cxd56_power_on(FAR struct cxd56_dev_s *dev)
       write_reg(REG_I2S_ENSEL, (dev->samplerate > 48000) ? 1 : 0);
 
       /* Disable DEQ */
+
       write_reg(REG_AC_DEQ_EN, 0);
 
       /* Disable DNC. */
@@ -1342,7 +1352,6 @@ static uint32_t cxd56_power_on(FAR struct cxd56_dev_s *dev)
       write_reg(REG_AC_CS_SIGN, 0);
       write_reg(REG_AC_CS_VOL, 0x00);
 
-      /* Attach interrupts */
       cxd56_attach_irq(true);
       cxd56_enable_irq(true);
     }
@@ -1571,14 +1580,10 @@ static int cxd56_configure(FAR struct audio_lowerhalf_s *lower,
                 /* Scale the volume setting to the range {-1020..120} */
 
                 priv->volume = CXD56_VOL_NX_TO_CXD56(volume);
-                audinfo("Volume: %d (priv = %d)\n", volume, priv->volume);
-
-                cxd56_set_volume(CXD56_AUDIO_VOLID_MIXER_OUT,
-                                 priv->volume, false);
-                cxd56_set_volume(CXD56_AUDIO_VOLID_MIXER_IN1,
-                                 priv->volume, false);
-                cxd56_set_volume(CXD56_AUDIO_VOLID_MIXER_IN2,
-                                 priv->volume, false);
+
+                cxd56_set_volume(CXD56_AUDIO_VOLID_MIXER_OUT, priv->volume);
+                cxd56_set_volume(CXD56_AUDIO_VOLID_MIXER_IN1, priv->volume);
+                cxd56_set_volume(CXD56_AUDIO_VOLID_MIXER_IN2, priv->volume);
               }
             else
               {
@@ -1619,6 +1624,8 @@ static int cxd56_configure(FAR struct audio_lowerhalf_s *lower,
         audinfo("  Samplerate:  %d\n", priv->samplerate);
         audinfo("  Bit width:   %d\n", priv->bitwidth);
 
+        /* Get ready to start receiving buffers */
+
         ret = cxd56_power_on(priv);
         if (ret != CXD56_AUDIO_ECODE_OK)
           {
@@ -1633,13 +1640,6 @@ static int cxd56_configure(FAR struct audio_lowerhalf_s *lower,
             goto error;
           }
 
-        ret = cxd56_power_on_analog_output(priv);
-        if (ret != CXD56_AUDIO_ECODE_OK)
-          {
-            auderr("Power on analog output failed- (%d)\n", ret);
-            goto error;
-          }
-
         priv->state = CXD56_DEV_STATE_STOPPED;
       }
       break;
@@ -1668,13 +1668,20 @@ static int cxd56_start(FAR struct audio_lowerhalf_s *lower)
 
   audinfo("cxd56_start\n");
 
-  /* Select audio data path */
+  /* Set audio path and enable output */
 
   if (priv->dma_handle == CXD56_AUDIO_DMA_I2S0_DOWN)
     {
       write_reg(REG_AC_AU_DAT_SEL1, CXD56_AUDAT_SEL_BUSIF1);
     }
 
+  ret = cxd56_power_on_analog_output(priv);
+  if (ret != CXD56_AUDIO_ECODE_OK)
+    {
+      auderr("Power on analog output failed- (%d)\n", ret);
+      goto error;
+    }
+
   ret = cxd56_init_worker(lower);
   if (ret != CXD56_AUDIO_ECODE_OK)
     {


[incubator-nuttx] 02/06: audio: nxstyle fixes for core and drivers

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

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

commit d9d720b296eb54613b28aa0515e1383f698d9f6f
Author: Alin Jerpelea <al...@sony.com>
AuthorDate: Tue Apr 21 09:45:24 2020 +0200

    audio: nxstyle fixes for core and drivers
    
    nxstyle fixes for the audio core and drivers
    
    Signed-off-by: Alin Jerpelea <al...@sony.com>
---
 audio/audio.c                    | 111 ++++++++------
 audio/audio_comp.c               |   6 +-
 audio/pcm_decode.c               |  55 ++++---
 drivers/audio/audio_i2s.c        |   4 +-
 drivers/audio/audio_null.c       |  59 +++++---
 drivers/audio/cs43l22.c          |  10 +-
 drivers/audio/cs43l22.h          |  57 +++++---
 drivers/audio/cs43l22_debug.c    |  78 +++++-----
 drivers/audio/cxd56.c            |  14 +-
 drivers/audio/tone.c             |  32 ++--
 drivers/audio/vs1053.c           | 307 +++++++++++++++++++++++----------------
 drivers/audio/vs1053.h           |  34 ++---
 drivers/audio/wm8776.c           |  10 +-
 drivers/audio/wm8776.h           |   9 +-
 drivers/audio/wm8904.c           |  18 ++-
 drivers/audio/wm8904.h           |  90 ++++++++----
 drivers/audio/wm8904_debug.c     |  12 +-
 include/nuttx/audio/audio.h      | 125 +++++++++-------
 include/nuttx/audio/audio_null.h |   1 +
 include/nuttx/audio/cs43l22.h    |  18 ++-
 include/nuttx/audio/i2s.h        |  35 +++--
 include/nuttx/audio/pcm.h        |   5 +-
 include/nuttx/audio/wm8776.h     |   2 -
 include/nuttx/audio/wm8904.h     |   2 +
 24 files changed, 660 insertions(+), 434 deletions(-)

diff --git a/audio/audio.c b/audio/audio.c
index c19973c..d3e928a 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -68,6 +68,7 @@
  ****************************************************************************/
 
 /* Debug ********************************************************************/
+
 /* Non-standard debug that may be enabled just for testing Audio */
 
 #ifndef AUDIO_MAX_DEVICE_PATH
@@ -86,11 +87,11 @@
 
 struct audio_upperhalf_s
 {
-  uint8_t           crefs;    /* The number of times the device has been opened */
-  volatile bool     started;  /* True: playback is active */
-  sem_t             exclsem;  /* Supports mutual exclusion */
+  uint8_t           crefs;            /* The number of times the device has been opened */
+  volatile bool     started;          /* True: playback is active */
+  sem_t             exclsem;          /* Supports mutual exclusion */
   FAR struct audio_lowerhalf_s *dev;  /* lower-half state */
-  mqd_t             usermq;   /* User mode app's message queue */
+  mqd_t             usermq;           /* User mode app's message queue */
 };
 
 /****************************************************************************
@@ -99,17 +100,29 @@ struct audio_upperhalf_s
 
 static int      audio_open(FAR struct file *filep);
 static int      audio_close(FAR struct file *filep);
-static ssize_t  audio_read(FAR struct file *filep, FAR char *buffer, size_t buflen);
-static ssize_t  audio_write(FAR struct file *filep, FAR const char *buffer, size_t buflen);
-static int      audio_ioctl(FAR struct file *filep, int cmd, unsigned long arg);
+static ssize_t  audio_read(FAR struct file *filep,
+                           FAR char *buffer,
+                           size_t buflen);
+static ssize_t  audio_write(FAR struct file *filep,
+                            FAR const char *buffer,
+                            size_t buflen);
+static int      audio_ioctl(FAR struct file *filep,
+                            int cmd,
+                            unsigned long arg);
 #ifdef CONFIG_AUDIO_MULTI_SESSION
-static int      audio_start(FAR struct audio_upperhalf_s *upper, FAR void *session);
-static void     audio_callback(FAR void *priv, uint16_t reason,
-                    FAR struct ap_buffer_s *apb, uint16_t status, FAR void *session);
+static int      audio_start(FAR struct audio_upperhalf_s *upper,
+                            FAR void *session);
+static void     audio_callback(FAR void *priv,
+                               uint16_t reason,
+                               FAR struct ap_buffer_s *apb,
+                               uint16_t status,
+                               FAR void *session);
 #else
 static int      audio_start(FAR struct audio_upperhalf_s *upper);
-static void     audio_callback(FAR void *priv, uint16_t reason,
-                    FAR struct ap_buffer_s *apb, uint16_t status);
+static void     audio_callback(FAR void *priv,
+                               uint16_t reason,
+                               FAR struct ap_buffer_s *apb,
+                               uint16_t status);
 #endif /* CONFIG_AUDIO_MULTI_SESSION */
 
 /****************************************************************************
@@ -131,13 +144,13 @@ static const struct file_operations g_audioops =
  * Private Functions
  ****************************************************************************/
 
-/************************************************************************************
+/****************************************************************************
  * Name: audio_open
  *
  * Description:
  *   This function is called whenever the Audio device is opened.
  *
- ************************************************************************************/
+ ****************************************************************************/
 
 static int audio_open(FAR struct file *filep)
 {
@@ -184,13 +197,13 @@ errout:
   return ret;
 }
 
-/************************************************************************************
+/****************************************************************************
  * Name: audio_close
  *
  * Description:
  *   This function is called when the Audio device is closed.
  *
- ************************************************************************************/
+ ****************************************************************************/
 
 static int audio_close(FAR struct file *filep)
 {
@@ -241,15 +254,17 @@ errout:
   return ret;
 }
 
-/************************************************************************************
+/****************************************************************************
  * Name: audio_read
  *
  * Description:
  *   A dummy read method.  This is provided only to satsify the VFS layer.
  *
- ************************************************************************************/
+ ****************************************************************************/
 
-static ssize_t audio_read(FAR struct file *filep, FAR char *buffer, size_t buflen)
+static ssize_t audio_read(FAR struct file *filep,
+                          FAR char *buffer,
+                          size_t buflen)
 {
   FAR struct inode *inode = filep->f_inode;
   FAR struct audio_upperhalf_s *upper = inode->i_private;
@@ -267,15 +282,17 @@ static ssize_t audio_read(FAR struct file *filep, FAR char *buffer, size_t bufle
   return 0;
 }
 
-/************************************************************************************
+/****************************************************************************
  * Name: audio_write
  *
  * Description:
  *   A dummy write method.  This is provided only to satsify the VFS layer.
  *
- ************************************************************************************/
+ ****************************************************************************/
 
-static ssize_t audio_write(FAR struct file *filep, FAR const char *buffer, size_t buflen)
+static ssize_t audio_write(FAR struct file *filep,
+                           FAR const char *buffer,
+                           size_t buflen)
 {
   FAR struct inode *inode = filep->f_inode;
   FAR struct audio_upperhalf_s *upper = inode->i_private;
@@ -293,16 +310,17 @@ static ssize_t audio_write(FAR struct file *filep, FAR const char *buffer, size_
   return 0;
 }
 
-/************************************************************************************
+/****************************************************************************
  * Name: audio_start
  *
  * Description:
  *   Handle the AUDIOIOC_START ioctl command
  *
- ************************************************************************************/
+ ****************************************************************************/
 
 #ifdef CONFIG_AUDIO_MULTI_SESSION
-static int audio_start(FAR struct audio_upperhalf_s *upper, FAR void *session)
+static int audio_start(FAR struct audio_upperhalf_s *upper,
+                       FAR void *session)
 #else
 static int audio_start(FAR struct audio_upperhalf_s *upper)
 #endif
@@ -339,13 +357,13 @@ static int audio_start(FAR struct audio_upperhalf_s *upper)
   return ret;
 }
 
-/************************************************************************************
+/****************************************************************************
  * Name: audio_ioctl
  *
  * Description:
  *   The standard ioctl method.  This is where ALL of the Audio work is done.
  *
- ************************************************************************************/
+ ****************************************************************************/
 
 static int audio_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
 {
@@ -379,7 +397,8 @@ static int audio_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
 
       case AUDIOIOC_GETCAPS:
         {
-          FAR struct audio_caps_s *caps = (FAR struct audio_caps_s *)((uintptr_t)arg);
+          FAR struct audio_caps_s *caps =
+                     (FAR struct audio_caps_s *)((uintptr_t)arg);
           DEBUGASSERT(lower->ops->getcaps != NULL);
 
           audinfo("AUDIOIOC_GETCAPS: Device=%d\n", caps->ac_type);
@@ -420,7 +439,8 @@ static int audio_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
         }
         break;
 
-      /* AUDIOIOC_START - Start the audio stream.  The AUDIOIOC_SETCHARACTERISTICS
+      /* AUDIOIOC_START - Start the audio stream.
+       *   The AUDIOIOC_SETCHARACTERISTICS
        *   command must have previously been sent.
        *
        *   ioctl argument:  Audio session
@@ -647,7 +667,9 @@ static int audio_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
         }
         break;
 
-      /* Any unrecognized IOCTL commands might be platform-specific ioctl commands */
+      /* Any unrecognized IOCTL commands might be
+       * platform-specific ioctl commands
+       */
 
       default:
         {
@@ -711,8 +733,8 @@ static inline void audio_dequeuebuffer(FAR struct audio_upperhalf_s *upper,
 
   if (upper->usermq != NULL)
     {
-      msg.msgId = AUDIO_MSG_DEQUEUE;
-      msg.u.pPtr = apb;
+      msg.msg_id = AUDIO_MSG_DEQUEUE;
+      msg.u.ptr = apb;
 #ifdef CONFIG_AUDIO_MULTI_SESSION
       msg.session = session;
 #endif
@@ -750,8 +772,8 @@ static inline void audio_complete(FAR struct audio_upperhalf_s *upper,
   upper->started = false;
   if (upper->usermq != NULL)
     {
-      msg.msgId = AUDIO_MSG_COMPLETE;
-      msg.u.pPtr = NULL;
+      msg.msg_id = AUDIO_MSG_COMPLETE;
+      msg.u.ptr = NULL;
 #ifdef CONFIG_AUDIO_MULTI_SESSION
       msg.session = session;
 #endif
@@ -823,7 +845,8 @@ static void audio_callback(FAR void *handle, uint16_t reason,
         FAR struct ap_buffer_s *apb, uint16_t status)
 #endif
 {
-  FAR struct audio_upperhalf_s *upper = (FAR struct audio_upperhalf_s *)handle;
+  FAR struct audio_upperhalf_s *upper =
+            (FAR struct audio_upperhalf_s *)handle;
 
   audinfo("Entry\n");
 
@@ -854,7 +877,9 @@ static void audio_callback(FAR void *handle, uint16_t reason,
 
       case AUDIO_CALLBACK_COMPLETE:
         {
-          /* Send a complete message to the user if a message queue is registered */
+          /* Send a complete message to the user if a message queue
+           * is registered
+           */
 
 #ifdef CONFIG_AUDIO_MULTI_SESSION
           audio_complete(upper, apb, status, session);
@@ -902,9 +927,9 @@ static void audio_callback(FAR void *handle, uint16_t reason,
  *     filesystem.  The recommended convention is to name Audio drivers
  *     based on the function they provide, such as "/dev/pcm0", "/dev/mp31",
  *     etc.
- *   dev - A pointer to an instance of lower half audio driver.  This instance
- *     is bound to the Audio driver and must persists as long as the driver
- *     persists.
+ *   dev - A pointer to an instance of lower half audio driver.
+ *     This instance is bound to the Audio driver and must persists as long
+ *     as the driver persists.
  *
  * Returned Value:
  *   Zero on success; a negated errno value on failure.
@@ -926,14 +951,17 @@ int audio_register(FAR const char *name, FAR struct audio_lowerhalf_s *dev)
 
   /* Allocate the upper-half data structure */
 
-  upper = (FAR struct audio_upperhalf_s *)kmm_zalloc(sizeof(struct audio_upperhalf_s));
+  upper = (FAR struct audio_upperhalf_s *)kmm_zalloc(
+                                           sizeof(struct audio_upperhalf_s));
   if (!upper)
     {
       auderr("ERROR: Allocation failed\n");
       return -ENOMEM;
     }
 
-  /* Initialize the Audio device structure (it was already zeroed by kmm_zalloc()) */
+  /* Initialize the Audio device structure
+   * (it was already zeroed by kmm_zalloc())
+   */
 
   nxsem_init(&upper->exclsem, 0, 1);
   upper->dev = dev;
@@ -979,6 +1007,7 @@ int audio_register(FAR const char *name, FAR struct audio_lowerhalf_s *dev)
             {
               *pathptr++ = *ptr++;
             }
+
           *pathptr = '\0';
 
           /* Make this level of directory */
diff --git a/audio/audio_comp.c b/audio/audio_comp.c
index 5f9b3e2..dea07c0 100644
--- a/audio/audio_comp.c
+++ b/audio/audio_comp.c
@@ -139,11 +139,13 @@ static int audio_comp_release(FAR struct audio_lowerhalf_s *dev);
 
 #ifdef CONFIG_AUDIO_MULTI_SESSION
 static void audio_comp_callback(FAR void *arg, uint16_t reason,
-                                FAR struct ap_buffer_s *apb, uint16_t status,
+                                FAR struct ap_buffer_s *apb,
+                                uint16_t status,
                                 FAR void *session);
 #else
 static void audio_comp_callback(FAR void *arg, uint16_t reason,
-                                FAR struct ap_buffer_s *apb, uint16_t status);
+                                FAR struct ap_buffer_s *apb,
+                                uint16_t status);
 #endif
 
 /****************************************************************************
diff --git a/audio/pcm_decode.c b/audio/pcm_decode.c
index 916d7bc..c7a6368 100644
--- a/audio/pcm_decode.c
+++ b/audio/pcm_decode.c
@@ -215,13 +215,15 @@ static int  pcm_ioctl(FAR struct audio_lowerhalf_s *dev,
               int cmd, unsigned long arg);
 
 #ifdef CONFIG_AUDIO_MULTI_SESSION
-static int  pcm_reserve(FAR struct audio_lowerhalf_s *dev, FAR void **session);
+static int  pcm_reserve(FAR struct audio_lowerhalf_s *dev,
+                        FAR void **session);
 #else
 static int  pcm_reserve(FAR struct audio_lowerhalf_s *dev);
 #endif
 
 #ifdef CONFIG_AUDIO_MULTI_SESSION
-static int  pcm_release(FAR struct audio_lowerhalf_s *dev, FAR void *session);
+static int  pcm_release(FAR struct audio_lowerhalf_s *dev,
+                        FAR void *session);
 #else
 static int  pcm_release(FAR struct audio_lowerhalf_s *dev);
 #endif
@@ -399,14 +401,14 @@ static bool pcm_parsewav(FAR struct pcm_decode_s *priv, uint8_t *data)
 
       if (priv->bpsamp != 8 && priv->bpsamp != 16)
         {
-          auderr("ERROR: Cannot support bits per sample of %d in this mode\n",
+          auderr("ERROR: %d bits per sample are not suported in this mode\n",
                  priv->bpsamp);
           return -EINVAL;
         }
 
       if (priv->nchannels != 1 && priv->nchannels != 2)
         {
-          auderr("ERROR: Cannot support number of channels of %d in this mode\n",
+          auderr("ERROR: %d channels are not supported in this mode\n",
                  priv->nchannels);
           return -EINVAL;
         }
@@ -637,7 +639,9 @@ static void pcm_subsample(FAR struct pcm_decode_s *priv,
               priv->skip     = skipsize;
             }
 
-          /* Now copy the sample from the end of audio buffer to the beginning. */
+          /* Now copy the sample from the end of audio buffer
+           * to the beginning.
+           */
 
           for (i = 0; i < copysize; i++)
             {
@@ -666,10 +670,11 @@ static void pcm_subsample(FAR struct pcm_decode_s *priv,
  * Description:
  *   This method is called to retrieve the lower-half device capabilities.
  *   It will be called with device type AUDIO_TYPE_QUERY to request the
- *   overall capabilities, such as to determine the types of devices supported
- *   audio formats supported, etc.  Then it may be called once or more with
- *   reported supported device types to determine the specific capabilities
- *   of that device type (such as MP3 encoder, WMA encoder, PCM output, etc.).
+ *   overall capabilities, such as to determine the types of devices
+ *   supported audio formats supported, etc.
+ *   Then it may be called once or more with reported supported device types
+ *   to determine the specific capabilities of that device type
+ *   (such as MP3 encoder, WMA encoder, PCM output, etc.).
  *
  ****************************************************************************/
 
@@ -696,9 +701,9 @@ static int pcm_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
       return ret;
     }
 
-  /* Modify the capabilities reported by the lower driver:  PCM is the only
-   * supported format that we will report, regardless of what the lower driver
-   * reported.
+  /* Modify the capabilities reported by the lower driver:
+   * PCM is the only supported format that we will report,
+   * regardless of what the lower driver  reported.
    */
 
   if (caps->ac_subtype == AUDIO_TYPE_QUERY)
@@ -724,7 +729,8 @@ static int pcm_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
 
 #ifdef CONFIG_AUDIO_MULTI_SESSION
 static int pcm_configure(FAR struct audio_lowerhalf_s *dev,
-                         FAR void *session, FAR const struct audio_caps_s *caps)
+                         FAR void *session,
+                         FAR const struct audio_caps_s *caps)
 #else
 static int pcm_configure(FAR struct audio_lowerhalf_s *dev,
                          FAR const struct audio_caps_s *caps)
@@ -776,8 +782,8 @@ static int pcm_configure(FAR struct audio_lowerhalf_s *dev,
  *   output generation.  It should also disable the audio hardware and put
  *   it into the lowest possible power usage state.
  *
- *   Any enqueued Audio Pipeline Buffers that have not been processed / dequeued
- *   should be dequeued by this function.
+ *   Any enqueued Audio Pipeline Buffers that have not been
+ *   processed / dequeued should be dequeued by this function.
  *
  ****************************************************************************/
 
@@ -805,10 +811,10 @@ static int pcm_shutdown(FAR struct audio_lowerhalf_s *dev)
  * Name: pcm_start
  *
  * Description:
- *   Start audio streaming in the configured mode.  For input and synthesis
- *   devices, this means it should begin sending streaming audio data.  For output
- *   or processing type device, it means it should begin processing of any enqueued
- *   Audio Pipeline Buffers.
+ *   Start audio streaming in the configured mode.
+ *   For input and synthesis devices, this means it should begin sending
+ *   streaming audio data.  For output or processing type device, it means
+ *   it should begin processing of any enqueued Audio Pipeline Buffers.
  *
  ****************************************************************************/
 
@@ -879,8 +885,9 @@ static int pcm_stop(FAR struct audio_lowerhalf_s *dev)
  * Name: pcm_pause
  *
  * Description:
- *   Pause the audio stream.  Should keep current playback context active
- *   in case a resume is issued.  Could be called and then followed by a stop.
+ *   Pause the audio stream.
+ *   Should keep current playback context active in case a resume  is issued.
+ *   Could be called and then followed by a stop.
  *
  ****************************************************************************/
 
@@ -1037,6 +1044,7 @@ static int pcm_enqueuebuffer(FAR struct audio_lowerhalf_s *dev,
   if (priv->streaming)
     {
       /* Yes, we are streaming */
+
       /* Check for the last audio buffer in the stream */
 
       if ((apb->flags & AUDIO_APB_FINAL) != 0)
@@ -1120,8 +1128,9 @@ static int pcm_enqueuebuffer(FAR struct audio_lowerhalf_s *dev,
 
           /* Then give the audio buffer to the lower driver */
 
-          audinfo("Pass to lower enqueuebuffer: apb=%p curbyte=%d nbytes=%d\n",
-                  apb, apb->curbyte, apb->nbytes);
+          audinfo(
+               "Pass to lower enqueuebuffer: apb=%p curbyte=%d nbytes=%d\n",
+                apb, apb->curbyte, apb->nbytes);
 
           ret = lower->ops->enqueuebuffer(lower, apb);
           if (ret == OK)
diff --git a/drivers/audio/audio_i2s.c b/drivers/audio/audio_i2s.c
index 5d1a2b4..2b450bb 100644
--- a/drivers/audio/audio_i2s.c
+++ b/drivers/audio/audio_i2s.c
@@ -232,7 +232,9 @@ static int audio_i2s_configure(FAR struct audio_lowerhalf_s *dev,
 {
   FAR struct audio_i2s_s *audio_i2s = (struct audio_i2s_s *)dev;
   FAR struct i2s_dev_s *i2s;
-  int samprate, nchannels, bpsamp;
+  int samprate;
+  int nchannels;
+  int bpsamp;
   int ret = OK;
 
   DEBUGASSERT(audio_i2s != NULL && caps != NULL);
diff --git a/drivers/audio/audio_null.c b/drivers/audio/audio_null.c
index 4188bab..53b032a 100644
--- a/drivers/audio/audio_null.c
+++ b/drivers/audio/audio_null.c
@@ -211,12 +211,14 @@ static int null_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
 
               /* The types of audio units we implement */
 
-              caps->ac_controls.b[0] = AUDIO_TYPE_OUTPUT | AUDIO_TYPE_FEATURE |
+              caps->ac_controls.b[0] = AUDIO_TYPE_OUTPUT |
+                                       AUDIO_TYPE_FEATURE |
                                        AUDIO_TYPE_PROCESSING;
 
               break;
 
             case AUDIO_FMT_MIDI:
+
               /* We only support Format 0 */
 
               caps->ac_controls.b[0] = AUDIO_SUBFMT_END;
@@ -241,9 +243,12 @@ static int null_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
 
               /* Report the Sample rates we support */
 
-              caps->ac_controls.b[0] = AUDIO_SAMP_RATE_8K | AUDIO_SAMP_RATE_11K |
-                                       AUDIO_SAMP_RATE_16K | AUDIO_SAMP_RATE_22K |
-                                       AUDIO_SAMP_RATE_32K | AUDIO_SAMP_RATE_44K |
+              caps->ac_controls.b[0] = AUDIO_SAMP_RATE_8K |
+                                       AUDIO_SAMP_RATE_11K |
+                                       AUDIO_SAMP_RATE_16K |
+                                       AUDIO_SAMP_RATE_22K |
+                                       AUDIO_SAMP_RATE_32K |
+                                       AUDIO_SAMP_RATE_44K |
                                        AUDIO_SAMP_RATE_48K;
               break;
 
@@ -262,19 +267,25 @@ static int null_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
 
       case AUDIO_TYPE_FEATURE:
 
-        /* If the sub-type is UNDEF, then report the Feature Units we support */
+        /* If the sub-type is UNDEF,
+         * then report the Feature Units we support
+         */
 
         if (caps->ac_subtype == AUDIO_FU_UNDEF)
           {
-            /* Fill in the ac_controls section with the Feature Units we have */
+            /* Fill in the ac_controls section with
+             * the Feature Units we have
+             */
 
-            caps->ac_controls.b[0] = AUDIO_FU_VOLUME | AUDIO_FU_BASS | AUDIO_FU_TREBLE;
+            caps->ac_controls.b[0] = AUDIO_FU_VOLUME |
+                                     AUDIO_FU_BASS |
+                                     AUDIO_FU_TREBLE;
             caps->ac_controls.b[1] = AUDIO_FU_BALANCE >> 8;
           }
         else
           {
-            /* TODO:  Do we need to provide specific info for the Feature Units,
-             * such as volume setting ranges, etc.?
+            /* TODO:  Do we need to provide specific info for the
+             * Feature Units, such as volume setting ranges, etc.?
              */
           }
 
@@ -297,7 +308,8 @@ static int null_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
 
               /* Provide capabilities of our Stereo Extender */
 
-              caps->ac_controls.b[0] = AUDIO_STEXT_ENABLE | AUDIO_STEXT_WIDTH;
+              caps->ac_controls.b[0] = AUDIO_STEXT_ENABLE |
+                                       AUDIO_STEXT_WIDTH;
               break;
 
             default:
@@ -450,7 +462,7 @@ static void *null_workerthread(pthread_addr_t pvarg)
 
       /* Process the message */
 
-      switch (msg.msgId)
+      switch (msg.msg_id)
         {
           case AUDIO_MSG_DATA_REQUEST:
             break;
@@ -468,7 +480,7 @@ static void *null_workerthread(pthread_addr_t pvarg)
             break;
 
           default:
-            auderr("ERROR: Ignoring message ID %d\n", msg.msgId);
+            auderr("ERROR: Ignoring message ID %d\n", msg.msg_id);
             break;
         }
     }
@@ -584,11 +596,12 @@ static int null_stop(FAR struct audio_lowerhalf_s *dev)
   FAR void *value;
 
   /* Send a message to stop all audio streaming */
-  /* REVISIT: There should be a check to see if the worker thread is still
-   * running.
+
+  /* REVISIT:
+   * There should be a check to see if the worker thread is still  running.
    */
 
-  term_msg.msgId = AUDIO_MSG_STOP;
+  term_msg.msg_id = AUDIO_MSG_STOP;
   term_msg.u.data = 0;
   nxmq_send(priv->mq, (FAR const char *)&term_msg, sizeof(term_msg),
             CONFIG_AUDIO_NULL_MSG_PRIO);
@@ -681,9 +694,16 @@ static int null_enqueuebuffer(FAR struct audio_lowerhalf_s *dev,
   if (done)
     {
 #ifdef CONFIG_AUDIO_MULTI_SESSION
-      priv->dev.upper(priv->dev.priv, AUDIO_CALLBACK_COMPLETE, NULL, OK, NULL);
+      priv->dev.upper(priv->dev.priv,
+                      AUDIO_CALLBACK_COMPLETE,
+                      NULL,
+                      OK,
+                      NULL);
 #else
-      priv->dev.upper(priv->dev.priv, AUDIO_CALLBACK_COMPLETE, NULL, OK);
+      priv->dev.upper(priv->dev.priv,
+                      AUDIO_CALLBACK_COMPLETE,
+                      NULL,
+                      OK);
 #endif
     }
 
@@ -834,8 +854,9 @@ FAR struct audio_lowerhalf_s *audio_null_initialize(void)
   priv = (FAR struct null_dev_s *)kmm_zalloc(sizeof(struct null_dev_s));
   if (priv)
     {
-      /* Initialize the null audio device structure.  Since we used kmm_zalloc,
-       * only the non-zero elements of the structure need to be initialized.
+      /* Initialize the null audio device structure.
+       * Since we used kmm_zalloc, only the non-zero elements
+       * of the structure need to be initialized.
        */
 
       priv->dev.ops = &g_audioops;
diff --git a/drivers/audio/cs43l22.c b/drivers/audio/cs43l22.c
index de73b7a..7f19a56 100644
--- a/drivers/audio/cs43l22.c
+++ b/drivers/audio/cs43l22.c
@@ -1014,7 +1014,7 @@ cs43l22_senddone(FAR struct i2s_dev_s *i2s,
    * buffers in the done queue that need to be cleaned up.
    */
 
-  msg.msgId = AUDIO_MSG_COMPLETE;
+  msg.msg_id = AUDIO_MSG_COMPLETE;
   ret = nxmq_send(priv->mq, (FAR const char *)&msg, sizeof(msg),
                   CONFIG_CS43L22_MSG_PRIO);
   if (ret < 0)
@@ -1282,7 +1282,7 @@ static int cs43l22_stop(FAR struct audio_lowerhalf_s *dev)
 
   /* Send a message to stop all audio streaming */
 
-  term_msg.msgId = AUDIO_MSG_STOP;
+  term_msg.msg_id = AUDIO_MSG_STOP;
   term_msg.u.data = 0;
   nxmq_send(priv->mq, (FAR const char *)&term_msg, sizeof(term_msg),
             CONFIG_CS43L22_MSG_PRIO);
@@ -1409,7 +1409,7 @@ static int cs43l22_enqueuebuffer(FAR struct audio_lowerhalf_s *dev,
   ret = OK;
   if (priv->mq != NULL)
     {
-      term_msg.msgId  = AUDIO_MSG_ENQUEUE;
+      term_msg.msg_id  = AUDIO_MSG_ENQUEUE;
       term_msg.u.data = 0;
 
       ret = nxmq_send(priv->mq, (FAR const char *)&term_msg,
@@ -1692,7 +1692,7 @@ static void *cs43l22_workerthread(pthread_addr_t pvarg)
 
       /* Process the message */
 
-      switch (msg.msgId)
+      switch (msg.msg_id)
         {
           /* The ISR has requested more data.  We will catch this case at
            * the top of the loop.
@@ -1730,7 +1730,7 @@ static void *cs43l22_workerthread(pthread_addr_t pvarg)
             break;
 
           default:
-            auderr("ERROR: Ignoring message ID %d\n", msg.msgId);
+            auderr("ERROR: Ignoring message ID %d\n", msg.msg_id);
             break;
         }
     }
diff --git a/drivers/audio/cs43l22.h b/drivers/audio/cs43l22.h
index 6fa9b98..bd0089d 100644
--- a/drivers/audio/cs43l22.h
+++ b/drivers/audio/cs43l22.h
@@ -63,6 +63,7 @@
 /****************************************************************************
  * Pre-Processor Definitions
  ****************************************************************************/
+
 /* So far, I have not been able to get FLL lock interrupts. Worse, I have
  * been able to get the FLL to claim that it is locked at all even when
  * polling.  What am I doing wrong?
@@ -120,8 +121,9 @@
 #define CS43L22_SPKAMUTE           (1 << 4)
 
 /* Register Default Values **************************************************/
-/* Registers have some undocumented bits set on power up.  These probably
- * should be retained on writes (?).
+
+/* Registers have some undocumented bits set on power up.
+ * These probably should be retained on writes (?).
  */
 
 #define CS43L22_ID_REV_DEFAULT             0xe3 /* Chip I.D. and Revision */
@@ -179,33 +181,41 @@
 /* 0x04 Power Control 2 */
 #define CS43L22_PDN_HPB_SHIFT         (6)                          /* Bits 6-7: Headphone channel B Control */
 #define CS43L22_PDN_HPB_ON_HW_PIN_LO  (0 << CS43L22_PDN_HPB_SHIFT) /* PDN_HPx[1:0] 00 Headphone channel is ON when the SPK/HP_SW pin, 6, is LO
-                                                                                      Headphone channel is OFF when the SPK/HP_SW pin, 6, is HI */
+                                                                    *                 Headphone channel is OFF when the SPK/HP_SW pin, 6, is HI
+                                                                    */
 #define CS43L22_PDN_HPB_ON_HW_PIN_HI  (1 << CS43L22_PDN_HPB_SHIFT) /* PDN_HPx[1:0] 01 Headphone channel is ON when the SPK/HP_SW pin, 6, is HI
-                                                                                      Headphone channel is OFF when the SPK/HP_SW pin, 6, is LO */
+                                                                    *                 Headphone channel is OFF when the SPK/HP_SW pin, 6, is LO
+                                                                    */
 #define CS43L22_PDN_HPB_ON            (2 << CS43L22_PDN_HPB_SHIFT) /* PDN_HPx[1:0] 10 Headphone channel is always ON */
 #define CS43L22_PDN_HPB_OFF           (3 << CS43L22_PDN_HPB_SHIFT) /* PDN_HPx[1:0] 11 Headphone channel is always OFF */
 
 #define CS43L22_PDN_HPA_SHIFT         (4)                          /* Bits 4-5: Headphone channel A Control */
 #define CS43L22_PDN_HPA_ON_HW_PIN_LO  (0 << CS43L22_PDN_HPA_SHIFT) /* PDN_HPx[1:0] 00 Headphone channel is ON when the SPK/HP_SW pin, 6, is LO
-                                                                                      Headphone channel is OFF when the SPK/HP_SW pin, 6, is HI */
+                                                                    *                 Headphone channel is OFF when the SPK/HP_SW pin, 6, is HI */
 #define CS43L22_PDN_HPA_ON_HW_PIN_HI  (1 << CS43L22_PDN_HPA_SHIFT) /* PDN_HPx[1:0] 01 Headphone channel is ON when the SPK/HP_SW pin, 6, is HI
-                                                                                      Headphone channel is OFF when the SPK/HP_SW pin, 6, is LO */
+                                                                    *                 Headphone channel is OFF when the SPK/HP_SW pin, 6, is LO
+                                                                    */
 #define CS43L22_PDN_HPA_ON            (2 << CS43L22_PDN_HPA_SHIFT) /* PDN_HPx[1:0] 10 Headphone channel is always ON */
 #define CS43L22_PDN_HPA_OFF           (3 << CS43L22_PDN_HPA_SHIFT) /* PDN_HPx[1:0] 11 Headphone channel is always OFF */
 
 #define CS43L22_PDN_SPKB_SHIFT        (2)                           /* Bits 2-3: Speaker channel B Control */
 #define CS43L22_PDN_SPKB_ON_HW_PIN_LO (0 << CS43L22_PDN_SPKB_SHIFT) /* PDN_HPx[1:0] 00 Speaker channel is ON when the SPK/HP_SW pin, 6, is LO
-                                                                                       Speaker channel is OFF when the SPK/HP_SW pin, 6, is HI */
+                                                                     *                 Speaker channel is OFF when the SPK/HP_SW pin, 6, is HI
+                                                                     */
+
 #define CS43L22_PDN_SPKB_ON_HW_PIN_HI (1 << CS43L22_PDN_SPKB_SHIFT) /* PDN_HPx[1:0] 01 Speaker channel is ON when the SPK/HP_SW pin, 6, is HI
-                                                                                       Speaker channel is OFF when the SPK/HP_SW pin, 6, is LO */
+                                                                     *                 Speaker channel is OFF when the SPK/HP_SW pin, 6, is LO
+                                                                     */
 #define CS43L22_PDN_SPKB_ON           (2 << CS43L22_PDN_SPKB_SHIFT) /* PDN_HPx[1:0] 10 Speaker channel is always ON */
 #define CS43L22_PDN_SPKB_OFF          (3 << CS43L22_PDN_SPKB_SHIFT) /* PDN_HPx[1:0] 11 Speaker channel is always OFF */
 
 #define CS43L22_PDN_SPKA_SHIFT        (0)                           /* Bits 0-1: Speaker channel A Control */
 #define CS43L22_PDN_SPKA_ON_HW_PIN_LO (0 << CS43L22_PDN_SPKA_SHIFT) /* PDN_HPx[1:0] 00 Speaker channel is ON when the SPK/HP_SW pin, 6, is LO
-                                                                                       Speaker channel is OFF when the SPK/HP_SW pin, 6, is HI */
+                                                                     *                 Speaker channel is OFF when the SPK/HP_SW pin, 6, is HI
+                                                                     */
 #define CS43L22_PDN_SPKA_ON_HW_PIN_HI (1 << CS43L22_PDN_SPKA_SHIFT) /* PDN_HPx[1:0] 01 Speaker channel is ON when the SPK/HP_SW pin, 6, is HI
-                                                                                       Speaker channel is OFF when the SPK/HP_SW pin, 6, is LO */
+                                                                     *                 Speaker channel is OFF when the SPK/HP_SW pin, 6, is LO
+                                                                     */
 #define CS43L22_PDN_SPKA_ON           (2 << CS43L22_PDN_SPKA_SHIFT) /* PDN_HPx[1:0] 10 Speaker channel is always ON */
 #define CS43L22_PDN_SPKA_OFF          (3 << CS43L22_PDN_SPKA_SHIFT) /* PDN_HPx[1:0] 11 Speaker channel is always OFF */
 
@@ -223,6 +233,7 @@
 #define CS43L22_VIDEOCLK_ENABLE       (1 << 3)                      /* Bit 3: Specifies whether or not the external MCLK frequency is 27 MHz */
 
 #define CS43L22_MCLK_LRCK_RATIO_SHIFT (1)                           /* Bits 1-2: Internal MCLK/LRCK Ratio */
+
 #define CS43L22_RATIO_128_64          (0 << CS43L22_MCLK_LRCK_RATIO_SHIFT)    /* RATIO[1:0] Internal MCLK Cycles per LRCK=128, SCLK/LRCK=64 Ratio in Master Mode */
 #define CS43L22_RATIO_125_62          (1 << CS43L22_MCLK_LRCK_RATIO_SHIFT)    /* RATIO[1:0] Internal MCLK Cycles per LRCK=125, SCLK/LRCK=62 Ratio in Master Mode */
 #define CS43L22_RATIO_132_66          (2 << CS43L22_MCLK_LRCK_RATIO_SHIFT)    /* RATIO[1:0] Internal MCLK Cycles per LRCK=132, SCLK/LRCK=66 Ratio in Master Mode */
@@ -237,17 +248,17 @@
 
 #define CS43L22_DSP_MODE_ENABLE       (1 << 4)                      /* Configures a data-packed interface format for the DAC */
 
-#define CS43L22_DAC_IF_FORMAT_SHIFT   (2)                           /* Bits 2-3: Configures the digital interface format for data on SDIN */
+#define CS43L22_DAC_IF_FORMAT_SHIFT   (2)                                   /* Bits 2-3: Configures the digital interface format for data on SDIN */
 #define CS43L22_DAC_IF_LEFT_JUSTIFIED (0 << CS43L22_DAC_IF_FORMAT_SHIFT)    /* DACDIF[1:0] Left Justified, up to 24-bit data */
 #define CS43L22_DAC_IF_I2S            (1 << CS43L22_DAC_IF_FORMAT_SHIFT)    /* DACDIF[1:0] I2S, up to 24-bit data */
 #define CS43L22_DAC_IF_RIGHT_JUSTIFIED (2 << CS43L22_DAC_IF_FORMAT_SHIFT)   /* DACDIF[1:0] Right Justified */
 #define CS43L22_DAC_IF_RESERVED       (3 << CS43L22_DAC_IF_FORMAT_SHIFT)    /* DACDIF[1:0] Reserved */
 
-#define CS43L22_AUDIO_WORD_LENGHT_SHIFT (0)                          /* Bits 0-1: Configures the audio sample word length used for the data into SDIN */
-#define CS43L22_AWL_DSP_32_RJ_24      (0 << CS43L22_AUDIO_WORD_LENGHT_SHIFT)/* AWL[1:0] DSP Mode: 32-bit data, Right Justified: 24-bit data */
-#define CS43L22_AWL_DSP_24_RJ_20      (1 << CS43L22_AUDIO_WORD_LENGHT_SHIFT)/* AWL[1:0] DSP Mode: 24-bit data, Right Justified: 20-bit data */
-#define CS43L22_AWL_DSP_20_RJ_18      (2 << CS43L22_AUDIO_WORD_LENGHT_SHIFT)/* AWL[1:0] DSP Mode: 20-bit data, Right Justified: 18-bit data */
-#define CS43L22_AWL_DSP_16_RJ_16      (3 << CS43L22_AUDIO_WORD_LENGHT_SHIFT)/* AWL[1:0] DSP Mode: 16 bit data, Right Justified: 16-bit data */
+#define CS43L22_AUDIO_WORD_LENGHT_SHIFT (0)                                  /* Bits 0-1: Configures the audio sample word length used for the data into SDIN */
+#define CS43L22_AWL_DSP_32_RJ_24      (0 << CS43L22_AUDIO_WORD_LENGHT_SHIFT) /* AWL[1:0] DSP Mode: 32-bit data, Right Justified: 24-bit data */
+#define CS43L22_AWL_DSP_24_RJ_20      (1 << CS43L22_AUDIO_WORD_LENGHT_SHIFT) /* AWL[1:0] DSP Mode: 24-bit data, Right Justified: 20-bit data */
+#define CS43L22_AWL_DSP_20_RJ_18      (2 << CS43L22_AUDIO_WORD_LENGHT_SHIFT) /* AWL[1:0] DSP Mode: 20-bit data, Right Justified: 18-bit data */
+#define CS43L22_AWL_DSP_16_RJ_16      (3 << CS43L22_AUDIO_WORD_LENGHT_SHIFT) /* AWL[1:0] DSP Mode: 16 bit data, Right Justified: 16-bit data */
 
 /* 0x0E Miscellaneous Controls */
 #define CS43L22_FREEZE                (1 << 3)                      /* Configures a hold on all register settings */
@@ -256,7 +267,7 @@
 /* 0x1F Tone Control */
 #define CS43L22_TREB_GAIN_SHIFT       (4)                           /* Sets the gain of the treble shelving filter */
 #define CS43L22_TREB_GAIN(a)          ((a) << CS43L22_TREB_GAIN_SHIFT)
-                                                                    /* TREB[3:0] Gain Setting:*/
+                                                                    /* TREB[3:0] Gain Setting: */
                                                                     /* 0000 +12.0 dB */
                                                                     /* ··· ··· */
                                                                     /* 0111 +1.5 dB */
@@ -267,7 +278,7 @@
 
 #define CS43L22_BASS_GAIN_SHIFT       (0)                           /* Sets the gain of the bass shelving filter */
 #define CS43L22_BASS_GAIN(a)          ((a) << CS43L22_BASS_GAIN_SHIFT)
-                                                                    /* BASS[3:0] Gain Setting:*/
+                                                                    /* BASS[3:0] Gain Setting: */
                                                                     /* 0000 +12.0 dB */
                                                                     /* ··· ··· */
                                                                     /* 0111 +1.5 dB */
@@ -276,7 +287,8 @@
                                                                     /* 1111 -10.5 dB */
                                                                     /* Step Size: 1.5 dB */
 
-/* FLL Configuration *********************************************************/
+/* FLL Configuration ********************************************************/
+
 /* Default FLL configuration */
 
 #define CS43L22_DEFAULT_SAMPRATE      11025     /* Initial sample rate */
@@ -312,8 +324,9 @@ struct cs43l22_dev_s
   /* We are an audio lower half driver (We are also the upper "half" of
    * the CS43L22 driver with respect to the board lower half driver).
    *
-   * Terminology: Our "lower" half audio instances will be called dev for the
-   * publicly visible version and "priv" for the version that only this driver
+   * Terminology:
+   * Our "lower" half audio instances will be called dev for the publicly
+   * visible version and "priv" for the version that only this driver
    * knows.  From the point of view of this driver, it is the board lower
    * "half" that is referred to as "lower".
    */
@@ -363,7 +376,7 @@ struct cs43l22_dev_s
  ****************************************************************************/
 
 #ifdef CONFIG_CS43L22_CLKDEBUG
-extern const uint8_t g_sysclk_scaleb1[CS43L22_BCLK_MAXDIV+1];
+extern const uint8_t g_sysclk_scaleb1[CS43L22_BCLK_MAXDIV + 1];
 extern const uint8_t g_fllratio[CS43L22_NFLLRATIO];
 #endif
 
diff --git a/drivers/audio/cs43l22_debug.c b/drivers/audio/cs43l22_debug.c
index 2d39fe9..0443f4d 100644
--- a/drivers/audio/cs43l22_debug.c
+++ b/drivers/audio/cs43l22_debug.c
@@ -82,47 +82,47 @@ struct cs43l22_regdump_s
 #ifdef CONFIG_CS43L22_REGDUMP
 static const struct cs43l22_regdump_s g_cs43l22_debug[] =
 {
-  {"CHIP_ID_REV",     CS43L22_ID_REV          },
-  {"POWER_CTRL1",     CS43L22_POWER_CTRL1     },
-  {"POWER_CTRL2",     CS43L22_POWER_CTRL2     },
-  {"CLOCK_CTRL",      CS43L22_CLOCK_CTRL      },
-  {"INTERFACE_CTRL1", CS43L22_INTERFACE_CTRL1 },
-  {"INTERFACE_CTRL2", CS43L22_INTERFACE_CTRL2 },
-  {"PASS_SEL_A",      CS43L22_PASS_SEL_A      },
-  {"PASS_SEL_B",      CS43L22_PASS_SEL_B      },
-  {"ANLG_ZC_SR_SEL",  CS43L22_ANLG_ZC_SR_SEL  },
-  {"PASS_GANG_CTRL",  CS43L22_PASS_GANG_CTRL  },
-  {"PLAYBACK_CTRL1",  CS43L22_PLAYBACK_CTRL1  },
-  {"MISCLLNS_CTRL",   CS43L22_MISCLLNS_CTRL   },
-  {"PLAYBACK_CTRL2",  CS43L22_PLAYBACK_CTRL2  },
-  {"PASS_VOL_A",      CS43L22_PASS_VOL_A      },
-  {"PASS_VOL_B",      CS43L22_PASS_VOL_B      },
-  {"PCM_VOL_A",       CS43L22_PCM_VOL_A       },
-  {"PCM_VOL_B",       CS43L22_PCM_VOL_B       },
-  {"BP_FREQ_ON_T",    CS43L22_BP_FREQ_ON_TIME },
-  {"BP_VOL_OFF_T",    CS43L22_BP_VOL_OFF_TIME },
-  {"BP_TONE_CFG",     CS43L22_BP_TONE_CFG     },
-  {"TONE_CTRL",       CS43L22_TONE_CTRL       },
-  {"MS_VOL_CTRL_A",   CS43L22_MS_VOL_CTRL_A   },
-  {"MS_VOL_CTRL_B",   CS43L22_MS_VOL_CTRL_B   },
-  {"HP_VOL_CTRL_A",   CS43L22_HP_VOL_CTRL_A   },
-  {"HP_VOL_CTRL_B",   CS43L22_HP_VOL_CTRL_B   },
-  {"SPK_VOL_CTRL_A",  CS43L22_SPK_VOL_CTRL_A  },
-  {"SPK_VOL_CTRL_B",  CS43L22_SPK_VOL_CTRL_B  },
-  {"PCM_CH_SWAP",     CS43L22_PCM_CH_SWAP     },
-  {"LIM_CTRL1",       CS43L22_LIM_CTRL1       },
-  {"LIM_CTRL2",       CS43L22_LIM_CTRL2       },
-  {"LIM_ATTACK_RATE", CS43L22_LIM_ATTACK_RATE },
-  {"STATUS",          CS43L22_STATUS          },
-  {"BAT_COMP",        CS43L22_BAT_COMP        },
-  {"VP_BAT_LEVEL",    CS43L22_VP_BAT_LEVEL    },
-  {"SPK_STATUS",      CS43L22_SPK_STATUS      },
-  {"TEMP_MON_CTRL",   CS43L22_TEMP_MON_CTRL   },
-  {"THERMAL_FOLDBACK",CS43L22_THERMAL_FOLDBACK},
-  {"CHRG_PUMP_FREQ",  CS43L22_CHRG_PUMP_FREQ  }
+  {"CHIP_ID_REV",      CS43L22_ID_REV          },
+  {"POWER_CTRL1",      CS43L22_POWER_CTRL1     },
+  {"POWER_CTRL2",      CS43L22_POWER_CTRL2     },
+  {"CLOCK_CTRL",       CS43L22_CLOCK_CTRL      },
+  {"INTERFACE_CTRL1",  CS43L22_INTERFACE_CTRL1 },
+  {"INTERFACE_CTRL2",  CS43L22_INTERFACE_CTRL2 },
+  {"PASS_SEL_A",       CS43L22_PASS_SEL_A      },
+  {"PASS_SEL_B",       CS43L22_PASS_SEL_B      },
+  {"ANLG_ZC_SR_SEL",   CS43L22_ANLG_ZC_SR_SEL  },
+  {"PASS_GANG_CTRL",   CS43L22_PASS_GANG_CTRL  },
+  {"PLAYBACK_CTRL1",   CS43L22_PLAYBACK_CTRL1  },
+  {"MISCLLNS_CTRL",    CS43L22_MISCLLNS_CTRL   },
+  {"PLAYBACK_CTRL2",   CS43L22_PLAYBACK_CTRL2  },
+  {"PASS_VOL_A",       CS43L22_PASS_VOL_A      },
+  {"PASS_VOL_B",       CS43L22_PASS_VOL_B      },
+  {"PCM_VOL_A",        CS43L22_PCM_VOL_A       },
+  {"PCM_VOL_B",        CS43L22_PCM_VOL_B       },
+  {"BP_FREQ_ON_T",     CS43L22_BP_FREQ_ON_TIME },
+  {"BP_VOL_OFF_T",     CS43L22_BP_VOL_OFF_TIME },
+  {"BP_TONE_CFG",      CS43L22_BP_TONE_CFG     },
+  {"TONE_CTRL",        CS43L22_TONE_CTRL       },
+  {"MS_VOL_CTRL_A",    CS43L22_MS_VOL_CTRL_A   },
+  {"MS_VOL_CTRL_B",    CS43L22_MS_VOL_CTRL_B   },
+  {"HP_VOL_CTRL_A",    CS43L22_HP_VOL_CTRL_A   },
+  {"HP_VOL_CTRL_B",    CS43L22_HP_VOL_CTRL_B   },
+  {"SPK_VOL_CTRL_A",   CS43L22_SPK_VOL_CTRL_A  },
+  {"SPK_VOL_CTRL_B",   CS43L22_SPK_VOL_CTRL_B  },
+  {"PCM_CH_SWAP",      CS43L22_PCM_CH_SWAP     },
+  {"LIM_CTRL1",        CS43L22_LIM_CTRL1       },
+  {"LIM_CTRL2",        CS43L22_LIM_CTRL2       },
+  {"LIM_ATTACK_RATE",  CS43L22_LIM_ATTACK_RATE },
+  {"STATUS",           CS43L22_STATUS          },
+  {"BAT_COMP",         CS43L22_BAT_COMP        },
+  {"VP_BAT_LEVEL",     CS43L22_VP_BAT_LEVEL    },
+  {"SPK_STATUS",       CS43L22_SPK_STATUS      },
+  {"TEMP_MON_CTRL",    CS43L22_TEMP_MON_CTRL   },
+  {"THERMAL_FOLDBACK", CS43L22_THERMAL_FOLDBACK},
+  {"CHRG_PUMP_FREQ",   CS43L22_CHRG_PUMP_FREQ  },
 };
 
-#  define CS43L22_NREGISTERS (sizeof(g_cs43l22_debug)/sizeof(struct cs43l22_regdump_s))
+#  define CS43L22_NREGISTERS (sizeof(g_cs43l22_debug) / sizeof(struct cs43l22_regdump_s))
 #endif /* CONFIG_CS43L22_REGDUMP */
 
 /****************************************************************************
diff --git a/drivers/audio/cxd56.c b/drivers/audio/cxd56.c
index fa25915..f7f7289 100644
--- a/drivers/audio/cxd56.c
+++ b/drivers/audio/cxd56.c
@@ -929,7 +929,7 @@ static void cxd56_dma_int_handler(void)
 
       if (dev->mq != NULL)
         {
-          msg.msgId = AUDIO_MSG_DATA_REQUEST;
+          msg.msg_id = AUDIO_MSG_DATA_REQUEST;
           msg.u.data = 0;
           (void)nxmq_send(dev->mq, (FAR const char *) &msg,
                           sizeof(msg), CONFIG_CXD56_MSG_PRIO);
@@ -939,7 +939,7 @@ static void cxd56_dma_int_handler(void)
         {
           /* End of data */
 
-          msg.msgId = AUDIO_MSG_STOP;
+          msg.msg_id = AUDIO_MSG_STOP;
           msg.u.data = 0;
           (void)nxmq_send(dev->mq, (FAR const char *)&msg,
                           sizeof(msg), CONFIG_CXD56_MSG_PRIO);
@@ -1743,7 +1743,7 @@ static int cxd56_stop(FAR struct audio_lowerhalf_s *lower)
 
   priv->state = CXD56_DEV_STATE_STOPPING;
 
-  msg.msgId = AUDIO_MSG_STOP;
+  msg.msg_id = AUDIO_MSG_STOP;
   msg.u.data = 0;
   (void)nxmq_send(priv->mq, (FAR const char *)&msg,
                   sizeof(msg), CONFIG_CXD56_MSG_PRIO);
@@ -1804,7 +1804,7 @@ static int cxd56_resume(FAR struct audio_lowerhalf_s *lower)
 
 #ifdef CONFIG_AUDIO_MULTI_SESSION
 static int cxd56_release(FAR struct audio_lowerhalf_s *lower,
-                  FAR void *pContext)
+                  FAR void *session)
 #else
 static int cxd56_release(FAR struct audio_lowerhalf_s *lower)
 #endif
@@ -1822,7 +1822,7 @@ static int cxd56_release(FAR struct audio_lowerhalf_s *lower)
 
 #ifdef CONFIG_AUDIO_MULTI_SESSION
 static int cxd56_reserve(FAR struct audio_lowerhalf_s *lower,
-                  FAR void **ppContext)
+                  FAR void **session)
 #else
 static int cxd56_reserve(FAR struct audio_lowerhalf_s *lower)
 #endif
@@ -2030,7 +2030,7 @@ static int cxd56_enqueuebuffer(FAR struct audio_lowerhalf_s *lower,
 
   if (priv->mq != NULL)
     {
-      msg.msgId = AUDIO_MSG_ENQUEUE;
+      msg.msg_id = AUDIO_MSG_ENQUEUE;
       msg.u.data = 0;
       (void)nxmq_send(priv->mq, (FAR const char *) &msg,
                       sizeof(msg), CONFIG_CXD56_MSG_PRIO);
@@ -2143,7 +2143,7 @@ static void *cxd56_workerthread(pthread_addr_t pvarg)
 
       /* Process the message */
 
-      switch (msg.msgId)
+      switch (msg.msg_id)
         {
           case AUDIO_MSG_STOP:
             cxd56_stop_dma(priv);
diff --git a/drivers/audio/tone.c b/drivers/audio/tone.c
index c916618..843aec6 100644
--- a/drivers/audio/tone.c
+++ b/drivers/audio/tone.c
@@ -8,7 +8,8 @@
  * modified to become a NuttX driver and to use the Oneshot Timer API.
  *
  * The PX4 driver is here:
- * https://github.com/PX4/Firmware/blob/master/src/drivers/stm32/tone_alarm/tone_alarm.cpp
+ * https://github.com/PX4/Firmware/blob/master/ \
+ * src/drivers/stm32/tone_alarm/tone_alarm.cpp
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -80,7 +81,7 @@
 #define MODE_LEGATO   2
 #define MODE_STACCATO 3
 
-/* Max tune string length*/
+/* Max tune string length */
 
 #define MAX_TUNE_LEN (1 * 256)
 
@@ -114,7 +115,10 @@ static char tune_buf[MAX_TUNE_LEN];
 
 /* Semitone offsets from C for the characters 'A'-'G' */
 
-static const uint8_t g_note_tab[] = { 9, 11, 0, 2, 4, 5, 7 };
+static const uint8_t g_note_tab[] =
+{
+  9, 11, 0, 2, 4, 5, 7
+};
 
 /* Notes in Frequency */
 
@@ -169,7 +173,6 @@ static ssize_t tone_read(FAR struct file *filep, FAR char *buffer,
 static ssize_t tone_write(FAR struct file *filep, FAR const char *buffer,
                           size_t buflen);
 
-
 /****************************************************************************
  * Private Data
  ****************************************************************************/
@@ -406,7 +409,8 @@ static void next_note(FAR struct tone_upperhalf_s *upper)
     }
 
   /* Make sure we still have a tune - may be removed by the write / ioctl
-   * handler */
+   * handler
+   */
 
   if ((g_next == NULL) || (g_tune == NULL))
     {
@@ -719,7 +723,7 @@ static uint8_t next_number(void)
   uint8_t number = 0;
   int c;
 
-  for (;;)
+  for (; ; )
     {
       c = next_char();
 
@@ -782,9 +786,10 @@ static int tone_open(FAR struct file *filep)
       goto errout;
     }
 
-  /* Increment the count of references to the device.  If this the first time
-   * that the driver has been opened for this device, then initialize the
-   * device. */
+  /* Increment the count of references to the device.
+   * If this the first time that the driver has been opened for this device,
+   * then initialize the device.
+   */
 
   tmp = upper->crefs + 1;
   if (tmp == 0)
@@ -831,8 +836,10 @@ static int tone_close(FAR struct file *filep)
       goto errout;
     }
 
-  /* Decrement the references to the driver.  If the reference count will
-   * decrement to 0, then uninitialize the driver. */
+  /* Decrement the references to the driver.
+   * If the reference count will decrement to 0,
+   * then uninitialize the driver.
+   */
 
   if (upper->crefs > 1)
     {
@@ -946,7 +953,8 @@ int tone_register(FAR const char *path, FAR struct pwm_lowerhalf_s *tone,
   /* Allocate the upper-half data structure */
 
   upper =
-    (FAR struct tone_upperhalf_s *)kmm_zalloc(sizeof(struct tone_upperhalf_s));
+    (FAR struct tone_upperhalf_s *)kmm_zalloc(
+                              sizeof(struct tone_upperhalf_s));
 
   if (!upper)
     {
diff --git a/drivers/audio/vs1053.c b/drivers/audio/vs1053.c
index 9938797..7bac43c 100644
--- a/drivers/audio/vs1053.c
+++ b/drivers/audio/vs1053.c
@@ -149,11 +149,11 @@ struct vs1053_struct_s
  ****************************************************************************/
 
 static int     vs1053_getcaps(FAR struct audio_lowerhalf_s *lower, int type,
-                 FAR struct audio_caps_s *pCaps);
+                 FAR struct audio_caps_s *caps);
 static int     vs1053_shutdown(FAR struct audio_lowerhalf_s *lower);
 #ifdef CONFIG_AUDIO_MULTI_SESSION
 static int     vs1053_configure(FAR struct audio_lowerhalf_s *lower,
-                 FAR void *session, FAR const struct audio_caps_s *pCaps);
+                 FAR void *session, FAR const struct audio_caps_s *caps);
 static int     vs1053_start(FAR struct audio_lowerhalf_s *lower,
                  FAR void *session);
 #ifndef CONFIG_AUDIO_EXCLUDE_STOP
@@ -167,12 +167,12 @@ static int     vs1053_resume(FAR struct audio_lowerhalf_s *lower,
                  FAR void *session);
 #endif /* CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME */
 static int     vs1053_reserve(FAR struct audio_lowerhalf_s *lower,
-                 FAR void** ppContext);
+                 FAR void** session);
 static int     vs1053_release(FAR struct audio_lowerhalf_s *lower,
-                 FAR void *pContext);
+                 FAR void *session);
 #else
 static int     vs1053_configure(FAR struct audio_lowerhalf_s *lower,
-                 FAR const struct audio_caps_s *pCaps);
+                 FAR const struct audio_caps_s *caps);
 static int     vs1053_start(FAR struct audio_lowerhalf_s *lower);
 #ifndef CONFIG_AUDIO_EXCLUDE_STOP
 static int     vs1053_stop(FAR struct audio_lowerhalf_s *lower);
@@ -236,8 +236,8 @@ static const uint8_t   g_logtable [] =
   22,  21,  19,  18,  17,     /* 60 - 68 */
   15,  14,  13,  12,  11,     /* 70 - 78 */
   10,   9,   8,   7,   6,     /* 80 - 88 */
-   5,   4,   3,   2,   1,     /* 90 - 98 */
-    0                         /* 100     */
+  5,    4,   3,   2,   1,     /* 90 - 98 */
+  0                           /* 100     */
 };
 #endif /* CONFIG_AUDIO_EXCLUDE_VOLUME */
 
@@ -245,26 +245,29 @@ static const uint8_t   g_logtable [] =
  * Private Functions
  ****************************************************************************/
 
-/************************************************************************************
+/****************************************************************************
  * Name: vs1053_spi_lock
- ************************************************************************************/
+ ****************************************************************************/
 
-static void vs1053_spi_lock(FAR struct spi_dev_s *dev, unsigned long freq_mhz)
+static void vs1053_spi_lock(FAR struct spi_dev_s *dev,
+                            unsigned long freq_mhz)
 {
   /* On SPI buses where there are multiple devices, it will be necessary to
    * lock SPI to have exclusive access to the buses for a sequence of
    * transfers.  The bus should be locked before the chip is selected.
    *
-   * This is a blocking call and will not return until we have exclusive access to
-   * the SPI bus.  We will retain that exclusive access until the bus is unlocked.
+   * This is a blocking call and will not return until we have exclusive
+   * access to the SPI bus.
+   * We will retain that exclusive access until the bus is unlocked.
    */
 
   SPI_LOCK(dev, true);
 
-  /* After locking the SPI bus, the we also need call the setfrequency, setbits, and
-   * setmode methods to make sure that the SPI is properly configured for the device.
-   * If the SPI bus is being shared, then it may have been left in an incompatible
-   * state.
+  /* After locking the SPI bus, the we also need call the setfrequency,
+   * setbits, and setmode methods to make sure that the SPI is properly
+   * configured for the device.
+   * If the SPI bus is being shared, then it may have been left in an
+   * incompatible state.
    */
 
   SPI_SETMODE(dev, CONFIG_VS1053_SPIMODE);
@@ -273,19 +276,19 @@ static void vs1053_spi_lock(FAR struct spi_dev_s *dev, unsigned long freq_mhz)
   SPI_SETFREQUENCY(dev, freq_mhz);
 }
 
-/************************************************************************************
+/****************************************************************************
  * Name: vs1053_spi_unlock
- ************************************************************************************/
+ ****************************************************************************/
 
 static inline void vs1053_spi_unlock(FAR struct spi_dev_s *dev)
 {
   SPI_LOCK(dev, false);
 }
 
-/************************************************************************************
+/****************************************************************************
  * Name: vs1053_readreg - Read the specified 16-bit register from the
  *                        VS1053 device.  Caller must hold the SPI lock.
- ************************************************************************************/
+ ****************************************************************************/
 
 static uint16_t vs1053_readreg(FAR struct vs1053_struct_s *dev, uint8_t reg)
 {
@@ -313,12 +316,14 @@ static uint16_t vs1053_readreg(FAR struct vs1053_struct_s *dev, uint8_t reg)
   return ret;
 }
 
-/************************************************************************************
+/****************************************************************************
  * Name: vs1053_writereg - Write the specified 16-bit register to the
  *                         VS1053 device.  Caller must hold the SPI lock.
- ************************************************************************************/
+ ****************************************************************************/
 
-static void vs1053_writereg(FAR struct vs1053_struct_s *dev, uint8_t reg, uint16_t val)
+static void vs1053_writereg(FAR struct vs1053_struct_s *dev,
+                            uint8_t reg,
+                            uint16_t val)
 {
   FAR struct spi_dev_s *spi = dev->spi;
 
@@ -336,7 +341,7 @@ static void vs1053_writereg(FAR struct vs1053_struct_s *dev, uint8_t reg, uint16
   /* Now read the 16-bit value */
 
   SPI_SEND(spi, val >> 8);
-  SPI_SEND(spi, val & 0xFF);
+  SPI_SEND(spi, val & 0xff);
 
   /* Deselect the CODEC */
 
@@ -354,7 +359,8 @@ static void vs1053_writereg(FAR struct vs1053_struct_s *dev, uint8_t reg, uint16
  *
  ****************************************************************************/
 
-static int vs1053_setfrequency(FAR struct vs1053_struct_s *dev, uint32_t freq)
+static int vs1053_setfrequency(FAR struct vs1053_struct_s *dev,
+                               uint32_t freq)
 {
   double    factor;
   uint16_t  reg;
@@ -395,7 +401,7 @@ static int vs1053_setfrequency(FAR struct vs1053_struct_s *dev, uint32_t freq)
    * increase the frequency the maximum amount as needed
    */
 
-  reg |= (VS1053_SC_ADD_XTALIx20 << VS1053_SC_ADD_SHIFT);
+  reg |= (VS1053_SC_ADD_XTALI_X20 << VS1053_SC_ADD_SHIFT);
 
   /* If we aren't running with a 12.228Mhz input crystal, then we
    * must tell the chip what the frequency is
@@ -431,11 +437,12 @@ static int vs1053_setfrequency(FAR struct vs1053_struct_s *dev, uint32_t freq)
   return OK;
 }
 
-/************************************************************************************
- * Name: vs1053_logapprox - Approximate the register value in .5 dB increments
- *                          level based on the percentage using a log table since
- *                          math libraries aren't available.
- ************************************************************************************/
+/****************************************************************************
+ * Name: vs1053_logapprox -
+ *           Approximate the register value in .5 dB increments
+ *           level based on the percentage using a log table since
+ *           math libraries aren't available.
+ ****************************************************************************/
 
 #ifndef CONFIG_AUDIO_EXCLUDE_VOLUME
 uint8_t vs1053_logapprox(int percent)
@@ -447,14 +454,15 @@ uint8_t vs1053_logapprox(int percent)
       return 0;
     }
 
-  return (g_logtable[percent >> 1] + g_logtable[(percent+1) >> 1]) >> 1;
+  return (g_logtable[percent >> 1] + g_logtable[(percent + 1) >> 1]) >> 1;
 }
 #endif /* CONFIG_AUDIO_EXCLUDE_VOLUME */
 
-/************************************************************************************
- * Name: vs1053_setvolume - Set the right and left volume values in the VS1053
- *                          device based on the current volume and balance settings.
- ************************************************************************************/
+/****************************************************************************
+ * Name: vs1053_setvolume -
+ *             Set the right and left volume values in the VS1053
+ *             device based on the current volume and balance settings.
+ ****************************************************************************/
 
 #ifndef CONFIG_AUDIO_EXCLUDE_VOLUME
 static void vs1053_setvolume(FAR struct vs1053_struct_s *dev)
@@ -462,7 +470,8 @@ static void vs1053_setvolume(FAR struct vs1053_struct_s *dev)
   FAR struct spi_dev_s *spi = dev->spi;
   uint32_t              leftlevel;
   uint32_t              rightlevel;
-  uint8_t               leftreg, rightreg;
+  uint8_t               leftreg;
+  uint8_t               rightreg;
 
   /* Constrain balance */
 #ifndef CONFIG_AUDIO_EXCLUDE_BALANCE
@@ -505,6 +514,7 @@ static void vs1053_setvolume(FAR struct vs1053_struct_s *dev)
 #endif
 
   /* Calculate the left and right register values */
+
   /* The register sets the volume in dB which is a logrithmic scale,
    * so we must use log() to calculate the register value.
    */
@@ -520,20 +530,22 @@ static void vs1053_setvolume(FAR struct vs1053_struct_s *dev)
 }
 #endif /* CONFIG_AUDIO_EXCLUDE_VOLUME */
 
-/************************************************************************************
+/****************************************************************************
  * Name: vs1053_setbass - Set the bass and treble level as specified in the
  *                        context's bass and treble variables..
  *
  * The level and range are in whole percentage levels (0-100).
  *
- ************************************************************************************/
+ ****************************************************************************/
 
 #ifndef CONFIG_AUDIO_EXCLUDE_TONE
 static void vs1053_setbass(FAR struct vs1053_struct_s *dev)
 {
   FAR struct spi_dev_s *spi = dev->spi;
-  int       bass_range, bass_boost;
-  int       treble_range, treble_boost;
+  int       bass_range;
+  int       bass_boost;
+  int       treble_range;
+  int       treble_boost;
 
   /* Calculate range and boost based on level */
 
@@ -545,8 +557,9 @@ static void vs1053_setbass(FAR struct vs1053_struct_s *dev)
   /* Lock the SPI bus to get exclsive access to the chip. */
 
   vs1053_spi_lock(spi, dev->spi_freq);
-  vs1053_writereg(dev, VS1053_SCI_BASS, (treble_boost << 12) | (treble_range << 8) |
-      (bass_boost << 4) | bass_range);
+  vs1053_writereg(dev, VS1053_SCI_BASS,
+                 (treble_boost << 12) | (treble_range << 8) |
+                 (bass_boost << 4) | bass_range);
   vs1053_spi_unlock(spi);
 }
 #endif /* CONFIG_AUDIO_EXCLUDE_TONE */
@@ -559,20 +572,20 @@ static void vs1053_setbass(FAR struct vs1053_struct_s *dev)
  ****************************************************************************/
 
 static int vs1053_getcaps(FAR struct audio_lowerhalf_s *lower, int type,
-            FAR struct audio_caps_s *pCaps)
+            FAR struct audio_caps_s *caps)
 {
   audinfo("Entry\n");
 
   /* Validate the structure */
 
-  DEBUGASSERT(pCaps->ac_len >= sizeof(struct audio_caps_s));
+  DEBUGASSERT(caps->ac_len >= sizeof(struct audio_caps_s));
 
   /* Fill in the caller's structure based on requested info */
 
-  pCaps->ac_format.hw  = 0;
-  pCaps->ac_controls.w = 0;
+  caps->ac_format.hw  = 0;
+  caps->ac_controls.w = 0;
 
-  switch (pCaps->ac_type)
+  switch (caps->ac_type)
     {
       /* Caller is querying for the types of units we support */
 
@@ -582,14 +595,15 @@ static int vs1053_getcaps(FAR struct audio_lowerhalf_s *lower, int type,
          * must then call us back for specific info for each capability.
          */
 
-        pCaps->ac_channels = 2;       /* Stereo output */
+        caps->ac_channels = 2;       /* Stereo output */
 
-        switch (pCaps->ac_subtype)
+        switch (caps->ac_subtype)
           {
             case AUDIO_TYPE_QUERY:
+
               /* The input formats we can decode / accept */
 
-              pCaps->ac_format.hw = 0
+              caps->ac_format.hw = 0
 #ifdef CONFIG_AUDIO_FORMAT_AC3
                     | (1 << (AUDIO_FMT_AC3 - 1))
 #endif
@@ -612,8 +626,9 @@ static int vs1053_getcaps(FAR struct audio_lowerhalf_s *lower, int type,
 
               /* The types of audio units we implement */
 
-              pCaps->ac_controls.b[0] = AUDIO_TYPE_OUTPUT | AUDIO_TYPE_FEATURE |
-                                      AUDIO_TYPE_PROCESSING;
+              caps->ac_controls.b[0] = AUDIO_TYPE_OUTPUT |
+                                       AUDIO_TYPE_FEATURE |
+                                       AUDIO_TYPE_PROCESSING;
 
               break;
 
@@ -621,15 +636,16 @@ static int vs1053_getcaps(FAR struct audio_lowerhalf_s *lower, int type,
 
 #ifdef CONFIG_AUDIO_FORMAT_MIDI
             case AUDIO_FMT_MIDI:
+
               /* We only support Format 0 */
 
-              pCaps->ac_controls.b[0] = AUDIO_SUBFMT_MIDI_0;
-              pCaps->ac_controls.b[1] = AUDIO_SUBFMT_END;
+              caps->ac_controls.b[0] = AUDIO_SUBFMT_MIDI_0;
+              caps->ac_controls.b[1] = AUDIO_SUBFMT_END;
               break;
 #endif
 
             default:
-              pCaps->ac_controls.b[0] = AUDIO_SUBFMT_END;
+              caps->ac_controls.b[0] = AUDIO_SUBFMT_END;
               break;
           }
 
@@ -639,28 +655,34 @@ static int vs1053_getcaps(FAR struct audio_lowerhalf_s *lower, int type,
 
       case AUDIO_TYPE_OUTPUT:
 
-        pCaps->ac_channels = 2;
+        caps->ac_channels = 2;
 
-        switch (pCaps->ac_subtype)
+        switch (caps->ac_subtype)
           {
             case AUDIO_TYPE_QUERY:
 
               /* Report the Sample rates we support */
 
-              pCaps->ac_controls.b[0] = AUDIO_SAMP_RATE_8K  | AUDIO_SAMP_RATE_11K |
-                                        AUDIO_SAMP_RATE_16K | AUDIO_SAMP_RATE_22K |
-                                        AUDIO_SAMP_RATE_32K | AUDIO_SAMP_RATE_44K |
-                                        AUDIO_SAMP_RATE_48K;
+              caps->ac_controls.b[0] = AUDIO_SAMP_RATE_8K  |
+                                       AUDIO_SAMP_RATE_11K |
+                                       AUDIO_SAMP_RATE_16K |
+                                       AUDIO_SAMP_RATE_22K |
+                                       AUDIO_SAMP_RATE_32K |
+                                       AUDIO_SAMP_RATE_44K |
+                                       AUDIO_SAMP_RATE_48K;
               break;
 
             case AUDIO_FMT_MP3:
             case AUDIO_FMT_WMA:
             case AUDIO_FMT_PCM:
-              /* Report the Bit rates we support.  The bit rate support is actually a
-               * complex function of the format and selected sample rate, and the datasheet
-               * has multiple tables to indicate the supported bit rate vs sample rate vs
-               * format.  The selected sample rate should be provided in the ac_format
-               * field of the query, and only a single sample rate should be given.
+              /* Report the Bit rates we support.
+               * The bit rate support is actually a complex function of the
+               * format and selected sample rate, and the datasheet has
+               * multiple tables to indicate the supported bit rate vs sample
+               * rate vsformat.
+               * The selected sample rate should be provided in the ac_format
+               * field of the query, and only a single sample rate should be
+               * given.
                */
 
               /* TODO:  Create a table or set of tables to report this! */
@@ -677,18 +699,25 @@ static int vs1053_getcaps(FAR struct audio_lowerhalf_s *lower, int type,
 
       case AUDIO_TYPE_FEATURE:
 
-        /* If the sub-type is UNDEF, then report the Feature Units we support */
+        /* If the sub-type is UNDEF,
+         * then report the Feature Units we support
+         */
 
-        if (pCaps->ac_subtype == AUDIO_FU_UNDEF)
+        if (caps->ac_subtype == AUDIO_FU_UNDEF)
           {
-            /* Fill in the ac_controls section with the Feature Units we have */
+            /* Fill in the ac_controls section with the
+             * Feature Units we have
+             */
 
-            pCaps->ac_controls.b[0] = AUDIO_FU_VOLUME | AUDIO_FU_BASS | AUDIO_FU_TREBLE;
-            pCaps->ac_controls.b[1] = AUDIO_FU_BALANCE >> 8;
+            caps->ac_controls.b[0] = AUDIO_FU_VOLUME |
+                                     AUDIO_FU_BASS |
+                                     AUDIO_FU_TREBLE;
+            caps->ac_controls.b[1] = AUDIO_FU_BALANCE >> 8;
           }
         else
           {
-            /* TODO:  Do we need to provide specific info for the Feature Units,
+            /* TODO:
+             * Do we need to provide specific info for the Feature Units,
              * such as volume setting ranges, etc.?
              */
           }
@@ -699,20 +728,21 @@ static int vs1053_getcaps(FAR struct audio_lowerhalf_s *lower, int type,
 
       case AUDIO_TYPE_PROCESSING:
 
-        switch (pCaps->ac_subtype)
+        switch (caps->ac_subtype)
           {
             case AUDIO_PU_UNDEF:
 
               /* Provide the type of Processing Units we support */
 
-              pCaps->ac_controls.b[0] = AUDIO_PU_STEREO_EXTENDER;
+              caps->ac_controls.b[0] = AUDIO_PU_STEREO_EXTENDER;
               break;
 
             case AUDIO_PU_STEREO_EXTENDER:
 
               /* Proivde capabilities of our Stereo Extender */
 
-              pCaps->ac_controls.b[0] = AUDIO_STEXT_ENABLE | AUDIO_STEXT_WIDTH;
+              caps->ac_controls.b[0] = AUDIO_STEXT_ENABLE |
+                                       AUDIO_STEXT_WIDTH;
               break;
 
             default:
@@ -730,8 +760,8 @@ static int vs1053_getcaps(FAR struct audio_lowerhalf_s *lower, int type,
 
         /* Zero out the fields to indicate no support */
 
-        pCaps->ac_subtype = 0;
-        pCaps->ac_channels = 0;
+        caps->ac_subtype = 0;
+        caps->ac_channels = 0;
 
         break;
     }
@@ -740,7 +770,7 @@ static int vs1053_getcaps(FAR struct audio_lowerhalf_s *lower, int type,
    * proper Audio device type.
    */
 
-  return pCaps->ac_len;
+  return caps->ac_len;
 }
 
 /****************************************************************************
@@ -753,10 +783,10 @@ static int vs1053_getcaps(FAR struct audio_lowerhalf_s *lower, int type,
 
 #ifdef CONFIG_AUDIO_MULTI_SESSION
 static int vs1053_configure(FAR struct audio_lowerhalf_s *lower,
-            FAR void *session, FAR const struct audio_caps_s *pCaps)
+            FAR void *session, FAR const struct audio_caps_s *caps)
 #else
 static int vs1053_configure(FAR struct audio_lowerhalf_s *lower,
-            FAR const struct audio_caps_s *pCaps)
+            FAR const struct audio_caps_s *caps)
 #endif
 {
   int     ret = OK;
@@ -768,19 +798,20 @@ static int vs1053_configure(FAR struct audio_lowerhalf_s *lower,
 
   /* Process the configure operation */
 
-  switch (pCaps->ac_type)
+  switch (caps->ac_type)
     {
       case AUDIO_TYPE_FEATURE:
 
         /* Process based on Feature Unit */
 
-        switch (pCaps->ac_format.hw)
+        switch (caps->ac_format.hw)
           {
 #ifndef CONFIG_AUDIO_EXCLUDE_VOLUME
             case AUDIO_FU_VOLUME:
+
               /* Set the volume */
 
-              dev->volume = pCaps->ac_controls.hw[0];
+              dev->volume = caps->ac_controls.hw[0];
               vs1053_setvolume(dev);
 
               break;
@@ -788,9 +819,10 @@ static int vs1053_configure(FAR struct audio_lowerhalf_s *lower,
 
 #if !defined(CONFIG_AUDIO_EXCLUDE_TONE) && !defined(CONFIG_AUDIO_EXCLUDE_VOLUME)
             case AUDIO_FU_BALANCE:
+
               /* Set the volume */
 
-              dev->balance = pCaps->ac_controls.hw[0];
+              dev->balance = caps->ac_controls.hw[0];
               vs1053_setvolume(dev);
 
               break;
@@ -798,11 +830,12 @@ static int vs1053_configure(FAR struct audio_lowerhalf_s *lower,
 
 #ifndef CONFIG_AUDIO_EXCLUDE_TONE
             case AUDIO_FU_BASS:
+
               /* Set the bass.  The percentage level (0-100) is in the
                * ac_controls[0] parameter.
                */
 
-              dev->bass = pCaps->ac_controls.b[0];
+              dev->bass = caps->ac_controls.b[0];
               if (dev->bass > 100)
                 dev->bass = 100;
               vs1053_setbass(dev);
@@ -814,7 +847,7 @@ static int vs1053_configure(FAR struct audio_lowerhalf_s *lower,
                * ac_controls.b[0] parameter.
                */
 
-              dev->treble = pCaps->ac_controls.b[0];
+              dev->treble = caps->ac_controls.b[0];
               if (dev->treble > 100)
                 dev->treble = 100;
               vs1053_setbass(dev);
@@ -823,6 +856,7 @@ static int vs1053_configure(FAR struct audio_lowerhalf_s *lower,
 #endif /* CONFIG_AUDIO_EXCLUDE_TONE */
 
             default:
+
               /* Others we don't support */
 
               break;
@@ -837,7 +871,7 @@ static int vs1053_configure(FAR struct audio_lowerhalf_s *lower,
 
         /* We only support STEREO_EXTENDER */
 
-        if (pCaps->ac_format.hw == AUDIO_PU_STEREO_EXTENDER)
+        if (caps->ac_format.hw == AUDIO_PU_STEREO_EXTENDER)
           {
           }
 
@@ -922,7 +956,7 @@ static int vs1053_shutdown(FAR struct audio_lowerhalf_s *lower)
   audinfo("Entry\n");
   vs1053_spi_lock(spi, dev->spi_freq);            /* Lock the device */
   vs1053_setfrequency(dev, CONFIG_VS1053_XTALI);  /* Reduce speed to minimum */
-  vs1053_writereg(dev, VS1053_SCI_VOL, 0xFEFE);   /* Power down the DAC outputs */
+  vs1053_writereg(dev, VS1053_SCI_VOL, 0xfefe);   /* Power down the DAC outputs */
   vs1053_spi_unlock(spi);                         /* Unlock the device */
   return OK;
 }
@@ -940,7 +974,7 @@ static void vs1053_feeddata(FAR struct vs1053_struct_s *dev)
 {
   int                   bytecount;
   int                   ret;
-  uint8_t               *pSamp = NULL;
+  uint8_t               *samp = NULL;
   uint16_t              reg;
   struct ap_buffer_s    *apb;
   FAR struct spi_dev_s  *spi = dev->spi;
@@ -957,18 +991,22 @@ static void vs1053_feeddata(FAR struct vs1053_struct_s *dev)
    */
 
   vs1053_spi_lock(spi, VS1053_DATA_FREQ);   /* Lock the SPI bus */
+
   SPI_SELECT(spi, SPIDEV_AUDIO_DATA(0), true); /* Select the VS1053 data bus */
 
   /* Local stack copy of our active buffer */
 
   apb = dev->apb;
-  //audinfo("Entry apb=%p, Bytes left=%d\n", apb, apb->nbytes - apb->curbyte);
+
+  /* audinfo("Entry apb=%p, Bytes left=%d\n",
+   *         apb, apb->nbytes - apb->curbyte);
+   */
 
   /* Setup pointer to the next sample in the buffer */
 
   if (apb)
     {
-      pSamp = &apb->samp[apb->curbyte];
+      samp = &apb->samp[apb->curbyte];
     }
   else if (!dev->endmode)
     {
@@ -1004,7 +1042,7 @@ static void vs1053_feeddata(FAR struct vs1053_struct_s *dev)
            * 32 bytes at a time.
            */
 
-          if (dev->endfillbytes == 32*65)
+          if (dev->endfillbytes == 32 * 65)
             {
               /* After at least 2052 bytes, we send an SM_CANCEL */
 
@@ -1014,7 +1052,7 @@ static void vs1053_feeddata(FAR struct vs1053_struct_s *dev)
               vs1053_writereg(dev, VS1053_SCI_MODE, reg | VS1053_SM_CANCEL);
               dev->hw_lower->enable(dev->hw_lower);   /* Enable the DREQ interrupt */
             }
-          else if (dev->endfillbytes >= 32*130)
+          else if (dev->endfillbytes >= 32 * 130)
             {
               /* Do a hard reset and terminate */
 
@@ -1023,14 +1061,15 @@ static void vs1053_feeddata(FAR struct vs1053_struct_s *dev)
               dev->endmode = false;
               break;
             }
-          else if (dev->endfillbytes > 32*65)
+          else if (dev->endfillbytes > 32 * 65)
             {
               /* After each 32 byte of endfillchar, check the status
                * register to see if SM_CANCEL has been cleared.  If
                * it has been cleared, then we're done.
                */
 
-              if (!(vs1053_readreg(dev, VS1053_SCI_STATUS) & VS1053_SM_CANCEL))
+              if (!(vs1053_readreg(dev, VS1053_SCI_STATUS) &
+                    VS1053_SM_CANCEL))
                 {
                   SPI_SETFREQUENCY(dev->spi, dev->spi_freq);
                   dev->hw_lower->disable(dev->hw_lower);   /* Disable the DREQ interrupt */
@@ -1039,13 +1078,18 @@ static void vs1053_feeddata(FAR struct vs1053_struct_s *dev)
                           vs1053_readreg(dev, VS1053_SCI_HDAT1),
                           vs1053_readreg(dev, VS1053_SCI_HDAT0));
 
-                  vs1053_writereg(dev, VS1053_SCI_WRAMADDR, VS1053_END_FILL_BYTE);
-                  dev->endfillchar = vs1053_readreg(dev, VS1053_SCI_WRAM) >> 8;
+                  vs1053_writereg(dev,
+                                  VS1053_SCI_WRAMADDR,
+                                  VS1053_END_FILL_BYTE);
+                  dev->endfillchar = vs1053_readreg(dev,
+                                                    VS1053_SCI_WRAM) >> 8;
 
                   audinfo("EndFillChar: 0x%0X\n", dev->endfillchar);
 
                   reg = vs1053_readreg(dev, VS1053_SCI_MODE);
-                  vs1053_writereg(dev, VS1053_SCI_MODE, reg | VS1053_SM_RESET);
+                  vs1053_writereg(dev,
+                                  VS1053_SCI_MODE,
+                                  reg | VS1053_SM_RESET);
 
                   dev->running = false;
                   dev->endmode = false;
@@ -1066,18 +1110,20 @@ static void vs1053_feeddata(FAR struct vs1053_struct_s *dev)
             {
               bytecount = 32;
             }
+
 #if 1
-          SPI_SNDBLOCK(spi, pSamp, bytecount);
-          pSamp += bytecount;
+          SPI_SNDBLOCK(spi, samp, bytecount);
+          samp += bytecount;
 #else
           bytecount = bytecount;
           while (bytecount--)
             {
               /* Send next byte from the buffer */
 
-              SPI_SEND(spi, *pSamp);
-              pSamp++;
+              SPI_SEND(spi, *samp);
+              samp++;
             }
+
 #endif
           apb->curbyte += bytecount;
 
@@ -1121,8 +1167,11 @@ static void vs1053_feeddata(FAR struct vs1053_struct_s *dev)
 
                   dev->hw_lower->disable(dev->hw_lower);   /* Disable the DREQ interrupt */
                   SPI_SETFREQUENCY(dev->spi, dev->spi_freq);
-                  vs1053_writereg(dev, VS1053_SCI_WRAMADDR, VS1053_END_FILL_BYTE);
-                  dev->endfillchar = vs1053_readreg(dev, VS1053_SCI_WRAM) >> 8;
+                  vs1053_writereg(dev,
+                                  VS1053_SCI_WRAMADDR,
+                                  VS1053_END_FILL_BYTE);
+                  dev->endfillchar = vs1053_readreg(dev,
+                                                    VS1053_SCI_WRAM) >> 8;
                   SPI_SETFREQUENCY(dev->spi, VS1053_DATA_FREQ);
                   dev->hw_lower->enable(dev->hw_lower);   /* Enable the DREQ interrupt */
 
@@ -1133,12 +1182,12 @@ static void vs1053_feeddata(FAR struct vs1053_struct_s *dev)
 #ifndef CONFIG_AUDIO_EXCLUDE_STOP
                   if (dev->cancelmode)
                     {
-                      /* If we are in cancel mode, then we don't dequeue the buffer
-                       * or need to send another SM_CANCEL, so jump into the middle
-                       * of the stop sequence.
+                      /* If we are in cancel mode, then we don't dequeue the
+                       * buffer or need to send another SM_CANCEL, so jump
+                       * into the middle of the stop sequence.
                        */
 
-                      dev->endfillbytes = 32*65+1;
+                      dev->endfillbytes = 32 * 65 + 1;
                       continue;
                     }
                   else
@@ -1180,14 +1229,17 @@ static void vs1053_feeddata(FAR struct vs1053_struct_s *dev)
               apb = (struct ap_buffer_s *) dq_remfirst(&dev->apbq);
               dev->apb = apb;
 
-              //audinfo("Next Buffer = %p, bytes = %d\n", apb, apb ? apb->nbytes : 0);
+              /* audinfo("Next Buffer = %p, bytes = %d\n",
+               *          apb, apb ? apb->nbytes : 0);
+               */
+
               if (apb == NULL)
                 {
                   nxsem_post(&dev->apbq_sem);
                   break;
                 }
 
-              pSamp = &apb->samp[apb->curbyte];
+              samp = &apb->samp[apb->curbyte];
               apb_reference(apb);                /* Add our buffer reference */
               nxsem_post(&dev->apbq_sem);
             }
@@ -1222,13 +1274,13 @@ static int vs1053_dreq_isr(int irq, FAR void *context, FAR void *arg)
 
   if (dev->running)
     {
-      msg.msgId = AUDIO_MSG_DATA_REQUEST;
+      msg.msg_id = AUDIO_MSG_DATA_REQUEST;
       nxmq_send(dev->mq, (FAR const char *)&msg, sizeof(msg),
                 CONFIG_VS1053_MSG_PRIO);
     }
   else
     {
-      msg.msgId = AUDIO_MSG_DATA_REQUEST;
+      msg.msg_id = AUDIO_MSG_DATA_REQUEST;
     }
 
   return 0;
@@ -1302,7 +1354,7 @@ static void *vs1053_workerthread(pthread_addr_t pvarg)
 
       /* Process the message */
 
-      switch (msg.msgId)
+      switch (msg.msg_id)
         {
           /* The ISR has requested more data */
 
@@ -1356,7 +1408,8 @@ static void *vs1053_workerthread(pthread_addr_t pvarg)
     {
       /* Get the next buffer from the queue */
 
-      while ((apb = (FAR struct ap_buffer_s *) dq_remfirst(&dev->apbq)) != NULL)
+      while ((apb = (FAR struct ap_buffer_s *) dq_remfirst(&dev->apbq))
+               != NULL)
         ;
     }
 
@@ -1397,7 +1450,8 @@ static void *vs1053_workerthread(pthread_addr_t pvarg)
  ****************************************************************************/
 
 #ifdef CONFIG_AUDIO_MULTI_SESSION
-static int vs1053_start(FAR struct audio_lowerhalf_s *lower, FAR void *session)
+static int vs1053_start(FAR struct audio_lowerhalf_s *lower,
+                        FAR void *session)
 #else
 static int vs1053_start(FAR struct audio_lowerhalf_s *lower)
 #endif
@@ -1501,7 +1555,8 @@ static int vs1053_start(FAR struct audio_lowerhalf_s *lower)
 
 #ifndef CONFIG_AUDIO_EXCLUDE_STOP
 #ifdef CONFIG_AUDIO_MULTI_SESSION
-static int vs1053_stop(FAR struct audio_lowerhalf_s *lower, FAR void *session)
+static int vs1053_stop(FAR struct audio_lowerhalf_s *lower,
+                       FAR void *session)
 #else
 static int vs1053_stop(FAR struct audio_lowerhalf_s *lower)
 #endif
@@ -1512,7 +1567,7 @@ static int vs1053_stop(FAR struct audio_lowerhalf_s *lower)
 
   /* Send a message to stop all audio streaming */
 
-  term_msg.msgId = AUDIO_MSG_STOP;
+  term_msg.msg_id = AUDIO_MSG_STOP;
   term_msg.u.data = 0;
   nxmq_send(dev->mq, (FAR const char *)&term_msg, sizeof(term_msg),
             CONFIG_VS1053_MSG_PRIO);
@@ -1545,7 +1600,8 @@ static int vs1053_stop(FAR struct audio_lowerhalf_s *lower)
 
 #ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME
 #ifdef CONFIG_AUDIO_MULTI_SESSION
-static int vs1053_pause(FAR struct audio_lowerhalf_s *lower, FAR void *session)
+static int vs1053_pause(FAR struct audio_lowerhalf_s *lower,
+                        FAR void *session)
 #else
 static int vs1053_pause(FAR struct audio_lowerhalf_s *lower)
 #endif
@@ -1574,7 +1630,8 @@ static int vs1053_pause(FAR struct audio_lowerhalf_s *lower)
 
 #ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME
 #ifdef CONFIG_AUDIO_MULTI_SESSION
-static int vs1053_resume(FAR struct audio_lowerhalf_s *lower, FAR void *session)
+static int vs1053_resume(FAR struct audio_lowerhalf_s *lower,
+                         FAR void *session)
 #else
 static int vs1053_resume(FAR struct audio_lowerhalf_s *lower)
 #endif
@@ -1626,7 +1683,7 @@ static int vs1053_enqueuebuffer(FAR struct audio_lowerhalf_s *lower,
 
       if (dev->mq != NULL)
         {
-          term_msg.msgId = AUDIO_MSG_ENQUEUE;
+          term_msg.msg_id = AUDIO_MSG_ENQUEUE;
           term_msg.u.data = 0;
           nxmq_send(dev->mq, (FAR const char *)&term_msg,
                     sizeof(term_msg), CONFIG_VS1053_MSG_PRIO);
@@ -1660,7 +1717,7 @@ static int vs1053_ioctl(FAR struct audio_lowerhalf_s *lower, int cmd,
                   unsigned long arg)
 {
 #ifdef CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS
-  FAR struct ap_buffer_info_s *pBufInfo;
+  FAR struct ap_buffer_info_s *bufinfo;
 #endif
 
   /* Deal with ioctls passed from the upper-half driver */
@@ -1680,9 +1737,9 @@ static int vs1053_ioctl(FAR struct audio_lowerhalf_s *lower, int cmd,
 #ifdef CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS
       case AUDIOIOC_GETBUFFERINFO:
 
-        pBufInfo = (FAR struct ap_buffer_info_s *) arg;
-        pBufInfo->buffer_size = CONFIG_VS1053_BUFFER_SIZE;
-        pBufInfo->nbuffers = CONFIG_VS1053_NUM_BUFFERS;
+        bufinfo = (FAR struct ap_buffer_info_s *) arg;
+        bufinfo->buffer_size = CONFIG_VS1053_BUFFER_SIZE;
+        bufinfo->nbuffers = CONFIG_VS1053_NUM_BUFFERS;
         break;
 #endif
 
diff --git a/drivers/audio/vs1053.h b/drivers/audio/vs1053.h
index 7a8a117..c33e8da 100644
--- a/drivers/audio/vs1053.h
+++ b/drivers/audio/vs1053.h
@@ -93,7 +93,7 @@
 #define VS1053_SM_LINE1             0x4000
 #define VS1053_SM_CLK_RANGE         0x8000
 
-/* STATUS register bit definitions ****************************************/
+/* STATUS register bit definitions ******************************************/
 
 #define VS1053_SS_DO_NOT_JUMP       0x8000
 #define VS1053_SS_SWING             0x7000
@@ -115,14 +115,14 @@
 #define VS1053_VER_VS1063           6
 #define VS1053_VER_VS1103           7
 
-/* BASS register bit definitions ******************************************/
+/* BASS register bit definitions ********************************************/
 
 #define VS1053_ST_AMPLITUDE         0xF000
 #define VS1053_ST_FREQLIMIT         0x0F00
 #define VS1053_SB_AMPLITUDE         0x00F0
 #define VS1053_SB_FREQLIMIT         0x000F
 
-/* CLOCKF register bit definitions ****************************************/
+/* CLOCKF register bit definitions ******************************************/
 
 #define VS1053_SC_MULT              0xE000
 #define VS1053_SC_MULT_SHIFT        13
@@ -130,21 +130,21 @@
 #define VS1053_SC_ADD_SHIFT         11
 #define VS1053_SC_FREQ              0x07FF
 
-#define VS1053_SC_MULT_XTALIx10     0
-#define VS1053_SC_MULT_XTALIx20     1
-#define VS1053_SC_MULT_XTALIx25     2
-#define VS1053_SC_MULT_XTALIx30     3
-#define VS1053_SC_MULT_XTALIx35     4
-#define VS1053_SC_MULT_XTALIx40     5
-#define VS1053_SC_MULT_XTALIx45     6
-#define VS1053_SC_MULT_XTALIx50     7
+#define VS1053_SC_MULT_XTALI_X10     0
+#define VS1053_SC_MULT_XTALI_X20     1
+#define VS1053_SC_MULT_XTALI_X25     2
+#define VS1053_SC_MULT_XTALI_X30     3
+#define VS1053_SC_MULT_XTALI_X35     4
+#define VS1053_SC_MULT_XTALI_X40     5
+#define VS1053_SC_MULT_XTALI_X45     6
+#define VS1053_SC_MULT_XTALI_X50     7
 
-#define VS1053_SC_ADD_NONE          0
-#define VS1053_SC_ADD_XTALIx10      1
-#define VS1053_SC_ADD_XTALIx15      2
-#define VS1053_SC_ADD_XTALIx20      3
+#define VS1053_SC_ADD_NONE           0
+#define VS1053_SC_ADD_XTALI_X10      1
+#define VS1053_SC_ADD_XTALI_X15      2
+#define VS1053_SC_ADD_XTALI_X20      3
 
-/* WRAM Addresses **********************************************************/
+/* WRAM Addresses ***********************************************************/
 
 #define VS1053_XRAM_BASE            0x1800      /* X data RAM */
 #define VS1053_XRAM_SIZE            256
@@ -158,7 +158,7 @@
 #define VS1053_IO_BASE              0xC000
 #define VS1053_IO_SIZE              0x4000
 
-/* HDAT1 register values *************************************************/
+/* HDAT1 register values ****************************************************/
 
 #define VS1053_HDAT1_WAV            0x7665      /* "ve" (as in Wave) */
 #define VS1053_HDAT1_ADTS           0x4154      /* "AT" */
diff --git a/drivers/audio/wm8776.c b/drivers/audio/wm8776.c
index 0b47a93..95192ef 100644
--- a/drivers/audio/wm8776.c
+++ b/drivers/audio/wm8776.c
@@ -587,7 +587,7 @@ static void  wm8776_senddone(FAR struct i2s_dev_s *i2s,
    * buffers in the done queue that need to be cleaned up.
    */
 
-  msg.msgId = AUDIO_MSG_COMPLETE;
+  msg.msg_id = AUDIO_MSG_COMPLETE;
   ret = mq_send(priv->mq, (FAR const char *)&msg, sizeof(msg),
                 CONFIG_WM8776_MSG_PRIO);
   if (ret < 0)
@@ -832,7 +832,7 @@ static int wm8776_stop(FAR struct audio_lowerhalf_s *dev)
 
   /* Send a message to stop all audio streaming */
 
-  term_msg.msgId = AUDIO_MSG_STOP;
+  term_msg.msg_id = AUDIO_MSG_STOP;
   term_msg.u.data = 0;
   mq_send(priv->mq, (FAR const char *)&term_msg, sizeof(term_msg),
           CONFIG_WM8776_MSG_PRIO);
@@ -946,7 +946,7 @@ static int wm8776_enqueuebuffer(FAR struct audio_lowerhalf_s *dev,
   ret = OK;
   if (priv->mq != NULL)
     {
-      term_msg.msgId  = AUDIO_MSG_ENQUEUE;
+      term_msg.msg_id  = AUDIO_MSG_ENQUEUE;
       term_msg.u.data = 0;
 
       ret = mq_send(priv->mq, (FAR const char *)&term_msg, sizeof(term_msg),
@@ -1250,7 +1250,7 @@ repeat:
 
       /* Process the message */
 
-      switch (msg.msgId)
+      switch (msg.msg_id)
         {
           /* The ISR has requested more data.  We will catch this case at
            * the top of the loop.
@@ -1288,7 +1288,7 @@ repeat:
             break;
 
           default:
-            auderr("ERROR: Ignoring message ID %d\n", msg.msgId);
+            auderr("ERROR: Ignoring message ID %d\n", msg.msg_id);
             break;
         }
 
diff --git a/drivers/audio/wm8776.h b/drivers/audio/wm8776.h
index dc6a0c1..1afc486 100644
--- a/drivers/audio/wm8776.h
+++ b/drivers/audio/wm8776.h
@@ -84,10 +84,11 @@ struct wm8776_dev_s
   /* We are an audio lower half driver (We are also the upper "half" of
    * the WM8776 driver with respect to the board lower half driver).
    *
-   * Terminology: Our "lower" half audio instances will be called dev for the
-   * publicly visible version and "priv" for the version that only this driver
-   * knows.  From the point of view of this driver, it is the board lower
-   * "half" that is referred to as "lower".
+   * Terminology:
+   * Our "lower" half audio instances will be called dev for the publicly
+   * visible version and "priv" for the version that only this driver knows
+   * From the point of view of this driver, it is the board lower "half"
+   * that is referred to as "lower".
    */
 
   struct audio_lowerhalf_s dev;             /* WM8776 audio lower half (this device) */
diff --git a/drivers/audio/wm8904.c b/drivers/audio/wm8904.c
index 975be11..4166d82 100644
--- a/drivers/audio/wm8904.c
+++ b/drivers/audio/wm8904.c
@@ -1099,11 +1099,15 @@ static int wm8904_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
 
       case AUDIO_TYPE_FEATURE:
 
-        /* If the sub-type is UNDEF, then report the Feature Units we support */
+        /* If the sub-type is UNDEF,
+         * then report the Feature Units we support
+         */
 
         if (caps->ac_subtype == AUDIO_FU_UNDEF)
           {
-            /* Fill in the ac_controls section with the Feature Units we have */
+            /* Fill in the ac_controls section with
+             * the Feature Units we have
+             */
 
             caps->ac_controls.b[0] = AUDIO_FU_VOLUME | AUDIO_FU_BASS |
                                      AUDIO_FU_TREBLE;
@@ -1400,7 +1404,7 @@ static void  wm8904_senddone(FAR struct i2s_dev_s *i2s,
    * buffers in the done queue that need to be cleaned up.
    */
 
-  msg.msgId = AUDIO_MSG_COMPLETE;
+  msg.msg_id = AUDIO_MSG_COMPLETE;
   ret = nxmq_send(priv->mq, (FAR const char *)&msg, sizeof(msg),
                   CONFIG_WM8904_MSG_PRIO);
   if (ret < 0)
@@ -1667,7 +1671,7 @@ static int wm8904_stop(FAR struct audio_lowerhalf_s *dev)
 
   /* Send a message to stop all audio streaming */
 
-  term_msg.msgId = AUDIO_MSG_STOP;
+  term_msg.msg_id = AUDIO_MSG_STOP;
   term_msg.u.data = 0;
   nxmq_send(priv->mq, (FAR const char *)&term_msg, sizeof(term_msg),
             CONFIG_WM8904_MSG_PRIO);
@@ -1790,7 +1794,7 @@ static int wm8904_enqueuebuffer(FAR struct audio_lowerhalf_s *dev,
   ret = OK;
   if (priv->mq != NULL)
     {
-      term_msg.msgId  = AUDIO_MSG_ENQUEUE;
+      term_msg.msg_id  = AUDIO_MSG_ENQUEUE;
       term_msg.u.data = 0;
 
       ret = nxmq_send(priv->mq, (FAR const char *)&term_msg,
@@ -2124,7 +2128,7 @@ static void *wm8904_workerthread(pthread_addr_t pvarg)
 
       /* Process the message */
 
-      switch (msg.msgId)
+      switch (msg.msg_id)
         {
           /* The ISR has requested more data.  We will catch this case at
            * the top of the loop.
@@ -2162,7 +2166,7 @@ static void *wm8904_workerthread(pthread_addr_t pvarg)
             break;
 
           default:
-            auderr("ERROR: Ignoring message ID %d\n", msg.msgId);
+            auderr("ERROR: Ignoring message ID %d\n", msg.msg_id);
             break;
         }
     }
diff --git a/drivers/audio/wm8904.h b/drivers/audio/wm8904.h
index 9a61604..1fe6f26 100644
--- a/drivers/audio/wm8904.h
+++ b/drivers/audio/wm8904.h
@@ -58,6 +58,7 @@
 /****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/
+
 /* So far, I have not been able to get FLL lock interrupts. Worse, I have
  * been able to get the FLL to claim that it is locked at all even when
  * polling.  What am I doing wrong?
@@ -175,6 +176,7 @@
 #define WM8904_DUMMY                 0xff /* Dummy register address */
 
 /* Register Default Values **************************************************/
+
 /* Registers have some undocumented bits set on power up.  These probably
  * should be retained on writes (?).
  */
@@ -287,22 +289,22 @@
 
 /* 0x04 Bias Control */
 
-#define WM8904_ISEL_SHIFT            (2)       /* Bits 2-3: Master Bias Control */
+#define WM8904_ISEL_SHIFT            (2)                      /* Bits 2-3: Master Bias Control */
 #define WM8904_ISEL_MASK             (3 << WM8904_ISEL_SHIFT)
 #  define WM8904_ISEL_LOW            (0 << WM8904_ISEL_SHIFT) /* Low power bias */
 #  define WM8904_ISEL_HIGH           (2 << WM8904_ISEL_SHIFT) /* High performance bias */
-#define WM8904_BIAS_ENA              (1 << 0)  /* Bit 0:  Normal bias current generator */
+#define WM8904_BIAS_ENA              (1 << 0)                 /* Bit 0:  Normal bias current generator */
 
 /* 0x05 VMID Control */
 
-#define WM8904_VMID_BUF_ENA          (1 << 6)  /* Bit 6:  Enable VMID buffer to unused I/O */
-#define WM8904_VMID_RES_SHIFT        (1)       /* Bits 1-2: VMID divider enable and select */
+#define WM8904_VMID_BUF_ENA          (1 << 6)                     /* Bit 6:  Enable VMID buffer to unused I/O */
+#define WM8904_VMID_RES_SHIFT        (1)                          /* Bits 1-2: VMID divider enable and select */
 #define WM8904_VMID_RES_MASK         (3 << WM8904_VMID_RES_SHIFT)
 #  define WM8904_VMID_RES_OFF        (0 << WM8904_VMID_RES_SHIFT) /* VMID disabled */
 #  define WM8904_VMID_RES_NORMAL     (1 << WM8904_VMID_RES_SHIFT) /* 2 x 50k divider */
 #  define WM8904_VMID_RES_STANDBY    (2 << WM8904_VMID_RES_SHIFT) /* 2 x 250k divider */
 #  define WM8904_VMID_RES_FASTSTART  (3 << WM8904_VMID_RES_SHIFT) /* 2 x 5k divider */
-#define WM8904_VMID_ENA              (1 << 0)  /* Bit 0:  VMID buffer enable */
+#define WM8904_VMID_ENA              (1 << 0)                     /* Bit 0:  VMID buffer enable */
 
 /* 0x06 Mic Bias Control 0 */
 
@@ -433,29 +435,32 @@
 /* 0x1a Audio Interface 2 */
 
 #define WM8904_OPCLK_DIV_SHIFT       (8)       /* Bits 8-11: GPIO Output Clock Divider */
+
 #define WM8904_OPCLK_DIV_MASK        (15 << WM8904_OPCLK_DIV_SHIFT)
-#  define WM8904_OPCLK_DIV1          (0 << WM8904_OPCLK_DIV_SHIFT) /* SYSCLK */
-#  define WM8904_OPCLK_DIV2          (1 << WM8904_OPCLK_DIV_SHIFT) /* SYSCLK / 2 */
-#  define WM8904_OPCLK_DIV3          (2 << WM8904_OPCLK_DIV_SHIFT) /* SYSCLK / 3 */
-#  define WM8904_OPCLK_DIV4          (3 << WM8904_OPCLK_DIV_SHIFT) /* SYSCLK / 4 */
-#  define WM8904_OPCLK_DIV5p5        (4 << WM8904_OPCLK_DIV_SHIFT) /* SYSCLK / 5.5 */
-#  define WM8904_OPCLK_DIV6          (5 << WM8904_OPCLK_DIV_SHIFT) /* SYSCLK / 6 */
-#  define WM8904_OPCLK_DIV8          (6 << WM8904_OPCLK_DIV_SHIFT) /* SYSCLK / 8 */
-#  define WM8904_OPCLK_DIV12         (7 << WM8904_OPCLK_DIV_SHIFT) /* SYSCLK / 12 */
-#  define WM8904_OPCLK_DIV16         (8 << WM8904_OPCLK_DIV_SHIFT) /* SYSCLK / 16 */
+#  define WM8904_OPCLK_DIV1          (0 << WM8904_OPCLK_DIV_SHIFT)  /* SYSCLK */
+#  define WM8904_OPCLK_DIV2          (1 << WM8904_OPCLK_DIV_SHIFT)  /* SYSCLK / 2 */
+#  define WM8904_OPCLK_DIV3          (2 << WM8904_OPCLK_DIV_SHIFT)  /* SYSCLK / 3 */
+#  define WM8904_OPCLK_DIV4          (3 << WM8904_OPCLK_DIV_SHIFT)  /* SYSCLK / 4 */
+#  define WM8904_OPCLK_DIV5p5        (4 << WM8904_OPCLK_DIV_SHIFT)  /* SYSCLK / 5.5 */
+#  define WM8904_OPCLK_DIV6          (5 << WM8904_OPCLK_DIV_SHIFT)  /* SYSCLK / 6 */
+#  define WM8904_OPCLK_DIV8          (6 << WM8904_OPCLK_DIV_SHIFT)  /* SYSCLK / 8 */
+#  define WM8904_OPCLK_DIV12         (7 << WM8904_OPCLK_DIV_SHIFT)  /* SYSCLK / 12 */
+#  define WM8904_OPCLK_DIV16         (8 << WM8904_OPCLK_DIV_SHIFT)  /* SYSCLK / 16 */
+
 #define WM8904_BCLK_DIV_SHIFT        (0)       /* Bits 0-4: BCLK Frequency (Master Mode) */
+
 #define WM8904_BCLK_DIV_MASK         (31 << WM8904_BCLK_DIV_SHIFT)
 #  define WM8904_BCLK_DIV(n)         ((uint16_t)(n) << WM8904_BCLK_DIV_SHIFT)
-#  define WM8904_BCLK_DIV1           (0 << WM8904_BCLK_DIV_SHIFT) /* SYSCLK */
-#  define WM8904_BCLK_DIV1p5         (1 << WM8904_BCLK_DIV_SHIFT) /* SYSCLK / 1.5 */
-#  define WM8904_BCLK_DIV2           (2 << WM8904_BCLK_DIV_SHIFT) /* SYSCLK / 2 */
-#  define WM8904_BCLK_DIV3           (3 << WM8904_BCLK_DIV_SHIFT) /* SYSCLK / 3 */
-#  define WM8904_BCLK_DIV4           (4 << WM8904_BCLK_DIV_SHIFT) /* SYSCLK / 4 */
-#  define WM8904_BCLK_DIV5           (5 << WM8904_BCLK_DIV_SHIFT) /* SYSCLK / 5 */
-#  define WM8904_BCLK_DIV5p5         (6 << WM8904_BCLK_DIV_SHIFT) /* SYSCLK / 5.5 */
-#  define WM8904_BCLK_DIV6           (7 << WM8904_BCLK_DIV_SHIFT) /* SYSCLK / 6 */
-#  define WM8904_BCLK_DIV8           (8 << WM8904_BCLK_DIV_SHIFT) /* SYSCLK / 8 */
-#  define WM8904_BCLK_DIV10          (9 << WM8904_BCLK_DIV_SHIFT) /* SYSCLK / 10 */
+#  define WM8904_BCLK_DIV1           (0 << WM8904_BCLK_DIV_SHIFT)  /* SYSCLK */
+#  define WM8904_BCLK_DIV1p5         (1 << WM8904_BCLK_DIV_SHIFT)  /* SYSCLK / 1.5 */
+#  define WM8904_BCLK_DIV2           (2 << WM8904_BCLK_DIV_SHIFT)  /* SYSCLK / 2 */
+#  define WM8904_BCLK_DIV3           (3 << WM8904_BCLK_DIV_SHIFT)  /* SYSCLK / 3 */
+#  define WM8904_BCLK_DIV4           (4 << WM8904_BCLK_DIV_SHIFT)  /* SYSCLK / 4 */
+#  define WM8904_BCLK_DIV5           (5 << WM8904_BCLK_DIV_SHIFT)  /* SYSCLK / 5 */
+#  define WM8904_BCLK_DIV5p5         (6 << WM8904_BCLK_DIV_SHIFT)  /* SYSCLK / 5.5 */
+#  define WM8904_BCLK_DIV6           (7 << WM8904_BCLK_DIV_SHIFT)  /* SYSCLK / 6 */
+#  define WM8904_BCLK_DIV8           (8 << WM8904_BCLK_DIV_SHIFT)  /* SYSCLK / 8 */
+#  define WM8904_BCLK_DIV10          (9 << WM8904_BCLK_DIV_SHIFT)  /* SYSCLK / 10 */
 #  define WM8904_BCLK_DIV11          (10 << WM8904_BCLK_DIV_SHIFT) /* SYSCLK / 11 */
 #  define WM8904_BCLK_DIV12          (11 << WM8904_BCLK_DIV_SHIFT) /* SYSCLK / 12 */
 #  define WM8904_BCLK_DIV16          (12 << WM8904_BCLK_DIV_SHIFT) /* SYSCLK / 16 */
@@ -476,6 +481,7 @@
 #  define WM8904_LRCLK_RATE(n)       ((uint16_t)(n) << WM8904_LRCLK_RATE_SHIFT)
 
 /* 0x1e DAC Digital Volume Left */
+
 /* 0x1f DAC Digital Volume Right */
 
 #define WM8904_DAC_VU                (1 << 8)  /* Bit 8:  DAC volume update */
@@ -493,11 +499,14 @@
 #  define WM8904_ADCR_DAC_SVOL(n)    ((uint16_t)(n) << WM8904_ADCR_DAC_SVOL_SHIFT)
 #define WM8904_ADC_TO_DACL_SHIFT     (2)       /* Bits 2-3: Left DAC digital sidetone source */
 #define WM8904_ADC_TO_DACL_MASK      (3 << WM8904_ADC_TO_DACL_SHIFT)
+
 #  define WM8904_ADC_TO_DACL_NONE    (0 << WM8904_ADC_TO_DACL_SHIFT) /* No sidetone */
 #  define WM8904_ADC_TO_DACL_LEFT    (1 << WM8904_ADC_TO_DACL_SHIFT) /* Left ADC */
 #  define WM8904_ADC_TO_DACL_RIGHT   (2 << WM8904_ADC_TO_DACL_SHIFT) /* Right ADC */
+
 #define WM8904_ADC_TO_DACR_SHIFT     (0)       /* Bits 0-1: Right DAC digital sidetone source */
 #define WM8904_ADC_TO_DACR_MASK      (3 << WM8904_ADC_TO_DACR_SHIFT)
+
 #  define WM8904_ADC_TO_DACR_NONE    (0 << WM8904_ADC_TO_DACR_SHIFT) /* No sidetone */
 #  define WM8904_ADC_TO_DACR_LEFT    (1 << WM8904_ADC_TO_DACR_SHIFT) /* Left ADC */
 #  define WM8904_ADC_TO_DACR_RIGHT   (2 << WM8904_ADC_TO_DACR_SHIFT) /* Right ADC */
@@ -518,6 +527,7 @@
 #  define WM8904_DEEMPH_48KHZ        (3 << WM8904_DEEMPH_SHIFT) /* 48kHz sample rate */
 
 /* 0x24 ADC Digital Volume Left */
+
 /* 0x25 ADC Digital Volume Right */
 
 #define WM8904_ADC_VU                (1 << 8)  /* Bit 8:  ADC Volume Update */
@@ -529,10 +539,12 @@
 
 #define WM8904_ADC_HPF_CUT_SHIFT     (5)      /* Bits 5-6: ADC digital high pass filter cut-off */
 #define WM8904_ADC_HPF_CUT_MASK      (3 << WM8904_ADC_HPF_CUT_SHIFT)
+
 #  define WM8904_ADC_HPF_CUT_HIFI    (0 << WM8904_ADC_HPF_CUT_SHIFT) /* Hi-fi mode */
 #  define WM8904_ADC_HPF_CUT_VOICE1  (1 << WM8904_ADC_HPF_CUT_SHIFT) /* Voice mode 1 */
 #  define WM8904_ADC_HPF_CUT_VOICE2  (2 << WM8904_ADC_HPF_CUT_SHIFT) /* Voice mode 2 */
 #  define WM8904_ADC_HPF_CUT_VOICE3  (3 << WM8904_ADC_HPF_CUT_SHIFT) /* Voice mode 3 */
+
 #define WM8904_ADC_HPF               (1 << 4)  /* Bit 4:  ADC digital high pass filter enable */
 #define WM8904_ADCL_DATINV           (1 << 1)  /* Bit 1:  Left ADC invert */
 #define WM8904_ADCR_DATINV           (1 << 0)  /* Bit 0:  Right ADC invert */
@@ -548,10 +560,12 @@
 #define WM8904_DRC_DAC_PATH          (1 << 14) /* Bit 14: DRC path select */
 #define WM8904_DRC_GS_HYST_LVL_SHIFT (11)      /* Bits 11-12: Gain smoothing hysteresis threshold */
 #define WM8904_DRC_GS_HYST_LVL_MASK  (3 << WM8904_DRC_GS_HYST_LVL_SHIFT)
+
 #  define WM8904_DRC_GS_HYST_LVL(n)  ((uint16_t)(n) << WM8904_DRC_GS_HYST_LVL_SHIFT)
 #  define WM8904_DRC_GS_HYST_LOW     (0 << WM8904_DRC_GS_HYST_LVL_SHIFT) /* Low */
 #  define WM8904_DRC_GS_HYST_MEDIUM  (1 << WM8904_DRC_GS_HYST_LVL_SHIFT) /* Medium */
 #  define WM8904_DRC_GS_HYST_HIGH    (2 << WM8904_DRC_GS_HYST_LVL_SHIFT) /* High */
+
 #define WM8904_DRC_STARTUP_GAIN_SHIFT  (6)      /* Bits 6-10: Initial gain at DRC startup */
 #define WM8904_DRC_STARTUP_GAIN_MASK   (31 << WM8904_DRC_STARTUP_GAIN_SHIFT)
 #  define WM8904_DRC_STARTUP_GAIN(n)   ((uint16_t)(n) << WM8904_DRC_STARTUP_GAIN_SHIFT)
@@ -586,14 +600,17 @@
 
 #define WM8904_DRC_HI_COMP_SHIFT     (3)      /* Bits 3-5: Compressor slope (upper region) */
 #define WM8904_DRC_HI_COMP_MASK      (7 << WM8904_DRC_HI_COMP_SHIFT)
+
 #  define WM8904_DRC_HI_COMP_DIV1    (0 << WM8904_DRC_HI_COMP_SHIFT) /* 1 (no compression) */
 #  define WM8904_DRC_HI_COMP_DIV2    (1 << WM8904_DRC_HI_COMP_SHIFT) /* 1/2 */
 #  define WM8904_DRC_HI_COMP_DIV4    (2 << WM8904_DRC_HI_COMP_SHIFT) /* 1/4 */
 #  define WM8904_DRC_HI_COMP_DIV8    (3 << WM8904_DRC_HI_COMP_SHIFT) /* 1/8 */
 #  define WM8904_DRC_HI_COMP_DIV16   (4 << WM8904_DRC_HI_COMP_SHIFT) /* 1/16 */
 #  define WM8904_DRC_HI_COMP_ZERO    (5 << WM8904_DRC_HI_COMP_SHIFT) /* 0 */
+
 #define WM8904_DRC_LO_COMP_SHIFT     (0)      /* Bits 0-2:  Compressor slope (lower region)*/
 #define WM8904_DRC_LO_COMP_MASK      (7 << WM8904_DRC_LO_COMP_SHIFT)
+
 #  define WM8904_DRC_LO_COMP(n)      ((uint16_t)(n) << WM8904_DRC_LO_COMP_SHIFT)
 #  define WM8904_DRC_LO_COMP_DIV1    (0 << WM8904_DRC_HI_COMP_SHIFT) /* 1 (no compression) */
 #  define WM8904_DRC_LO_COMP_DIV2    (1 << WM8904_DRC_HI_COMP_SHIFT) /* 1/2 */
@@ -612,6 +629,7 @@
 #  define WM8904_DRC_KNEE_OP(n)      ((uint16_t)(n) << WM8904_DRC_KNEE_OP_SHIFT)
 
 /* 0x2c Analogue Left Input 0 */
+
 /* 0x2d Analogue Right Input 0 */
 
 #define WM8904_INMUTE                (1 << 7)  /* Bit 7:  Input PGA mute */
@@ -620,6 +638,7 @@
 #  define WM8904_IN_VOL(n)           ((uint16_t)(n) << WM8904_IN_VOL_SHIFT)
 
 /* 0x2e Analogue Left Input 1 */
+
 /* 0x2f Analogue Right Input 1 */
 
 #define WM8904_IN_CM_ENA             (1 << 6)  /* Bit 6: Input PGA common mode rejection enable  */
@@ -642,6 +661,7 @@
 #  define WM8904_MODE_DIFFMIC        (2 << WM8904_MODE_SHIFT) /* Differential MIC */
 
 /* 0x39 Analogue OUT1 Left */
+
 /* 0x3a Analogue OUT1 Right */
 
 #define WM8904_HPOUT_MUTE            (1 << 8)  /* Bit 8:  Headphone output mute */
@@ -652,6 +672,7 @@
 #  define WM8904_HPOUT_VOL(n)        ((uint16_t)(n) << WM8904_HPOUT_VOL_SHIFT)
 
 /* 0x3b Analogue OUT2 Left */
+
 /* 0x3c Analogue OUT2 Right */
 
 #define WM8904_LINEOUT_MUTE          (1 << 8)  /* Bit 8:  Headphone output mute */
@@ -846,6 +867,7 @@
 #  define WM8904_FLL_FRATIO_DIV16    (4 << WM8904_FLL_FRATIO_SHIFT) /* Divide by 16 */
 
 /* 0x76 FLL Control 3, Bits 0-15=Fractional multiply for FREF */
+
 /* 0x77 FLL Control 4 */
 
 #define WM8904_FLL_N_SHIFT           (5)      /* Bits 5-14: Integer multiply for FREF */
@@ -871,6 +893,7 @@
 #  define WM8904_FLL_CLK_REF_DIV2    (1 << WM8904_FLL_CLK_REF_DIV_SHIFT) /* MCLK / 2 */
 #  define WM8904_FLL_CLK_REF_DIV4    (2 << WM8904_FLL_CLK_REF_DIV_SHIFT) /* MCLK / 4 */
 #  define WM8904_FLL_CLK_REF_DIV8    (3 << WM8904_FLL_CLK_REF_DIV_SHIFT) /* MCLK / 8 */
+
 #define WM8904_FLL_CLK_REF_SRC_SHIFT   (0)      /* Bits 0-2: FLL clock source */
 #define WM8904_FLL_CLK_REF_SRC_MASK    (3 << WM8904_FLL_CLK_REF_SRC_SHIFT)
 #  define WM8904_FLL_CLK_REF_SRC_MCLK  (0 << WM8904_FLL_CLK_REF_SRC_SHIFT)
@@ -958,9 +981,13 @@
 #define WM8904_BCLK_PD               (1 << 0)  /* Bit 0:  BCLK pull-down resistor enable */
 
 /* Common interrupt bits */
+
 /* 0x7f Interrupt Status */
+
 /* 0x80 Interrupt Status Mask */
+
 /* 0x81 Interrupt Polarity */
+
 /* 0x82 Interrupt Debounce */
 
 #define WM8904_GPIO_BCLK_INT         (1 << 9)  /* Bit 9:  GPIO4 interrupt */
@@ -985,6 +1012,7 @@
 #define WM8904_EQ_ENA                (1 << 0)  /* Bit 0:  EQ enable */
 
 /* 0x87-0x8b EQ2-EQ6:   5 bit equalizer value */
+
 /* 0x8c-0x9d EQ7-EQ24: 16-bit equalizer value */
 
 /* 0xa1 Control Interface Test 1 */
@@ -1012,7 +1040,8 @@
 #define WM8904FLL_FRC_NCO_MASK       (0x3f << WM8904FLL_FRC_NCO_SHIFT)
 #  define WM8904FLL_FRC_NCO_VAL(n)   ((uint16_t)(n) << WM8904FLL_FRC_NCO_SHIFT)
 
-/* FLL Configuration *********************************************************/
+/* FLL Configuration ********************************************************/
+
 /* Default FLL configuration */
 
 #define WM8904_DEFAULT_SAMPRATE      11025     /* Initial sample rate */
@@ -1056,10 +1085,11 @@ struct wm8904_dev_s
   /* We are an audio lower half driver (We are also the upper "half" of
    * the WM8904 driver with respect to the board lower half driver).
    *
-   * Terminology: Our "lower" half audio instances will be called dev for the
-   * publicly visible version and "priv" for the version that only this driver
-   * knows.  From the point of view of this driver, it is the board lower
-   * "half" that is referred to as "lower".
+   * Terminology:
+   * Our "lower" half audio instances will be called dev for the publicly
+   * visible version and "priv" for the version that only this driver knows.
+   * From the point of view of this driver, it is the board lower "half"
+   * that is referred to as "lower".
    */
 
   struct audio_lowerhalf_s dev;             /* WM8904 audio lower half (this device) */
@@ -1107,7 +1137,7 @@ struct wm8904_dev_s
  ****************************************************************************/
 
 #ifdef CONFIG_WM8904_CLKDEBUG
-extern const uint8_t g_sysclk_scaleb1[WM8904_BCLK_MAXDIV+1];
+extern const uint8_t g_sysclk_scaleb1[WM8904_BCLK_MAXDIV + 1];
 extern const uint8_t g_fllratio[WM8904_NFLLRATIO];
 #endif
 
diff --git a/drivers/audio/wm8904_debug.c b/drivers/audio/wm8904_debug.c
index d94eb2c..fe5fb1c 100644
--- a/drivers/audio/wm8904_debug.c
+++ b/drivers/audio/wm8904_debug.c
@@ -337,9 +337,12 @@ void wm8904_clock_analysis(FAR struct audio_lowerhalf_s *dev,
       syslog(LOG_INFO, "  Fref:            %lu Hz (after divider)\n", fref);
 
       regval = wm8904_readreg(priv, WM8904_FLL_CTRL2);
-      frndx  = (regval & WM8904_FLL_FRATIO_MASK) >> WM8904_FLL_FRATIO_SHIFT;
-      tmp    = (regval & WM8904_FLL_CTRL_RATE_MASK) >> WM8904_FLL_CTRL_RATE_SHIFT;
-      outdiv = ((regval & WM8904_FLL_OUTDIV_MASK) >> WM8904_FLL_OUTDIV_SHIFT) + 1;
+      frndx = (regval & WM8904_FLL_FRATIO_MASK) >>
+                        WM8904_FLL_FRATIO_SHIFT;
+      tmp = (regval & WM8904_FLL_CTRL_RATE_MASK) >>
+                      WM8904_FLL_CTRL_RATE_SHIFT;
+      outdiv = ((regval & WM8904_FLL_OUTDIV_MASK) >>
+                          WM8904_FLL_OUTDIV_SHIFT) + 1;
 
       syslog(LOG_INFO, "  FLL_CTRL_RATE:   Fvco / %u\n", tmp + 1);
 
@@ -397,7 +400,8 @@ void wm8904_clock_analysis(FAR struct audio_lowerhalf_s *dev,
       sysclk >>= 1;
     }
 
-  syslog(LOG_INFO, "  SYSCLK:          %lu (after divider)\n", (unsigned long)sysclk);
+  syslog(LOG_INFO, "  SYSCLK:          %lu (after divider)\n",
+        (unsigned long)sysclk);
 
   regval = wm8904_readreg(priv, WM8904_CLKRATE2);
 
diff --git a/include/nuttx/audio/audio.h b/include/nuttx/audio/audio.h
index 3a364f7..82707ba 100644
--- a/include/nuttx/audio/audio.h
+++ b/include/nuttx/audio/audio.h
@@ -43,10 +43,11 @@
  *
  * The Audio driver is split into two parts:
  *
- * 1) An "upper half", generic driver that provides the common Audio interface
- *    to application level code, and
- * 2) A "lower half", platform-specific driver that implements the low-level
- *    controls to configure and communicate with the audio device(s).
+ * 1) An "upper half", generic driver that provides the common Audio
+ *    interface to application level code, and
+ * 2) A "lower half", platform-specific driver that implements the
+ *    low-level controls to configure and communicate with the audio
+ *    device(s).
  */
 
 /****************************************************************************
@@ -67,14 +68,17 @@
 /****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/
+
 /* Configuration ************************************************************/
+
 /* CONFIG_AUDIO - Enables Audio driver support
- * CONFIG_DEBUG_AUDIO - If enabled (with CONFIG_DEBUG_FEATURES and, optionally,
- *   CONFIG_DEBUG_INFO), this will generate output that can be used to
- *   debug Audio drivers.
+ * CONFIG_DEBUG_AUDIO - If enabled (with CONFIG_DEBUG_FEATURES and,
+ *   optionally, CONFIG_DEBUG_INFO), this will generate output that can
+ *   be used to debug Audio drivers.
  */
 
 /* IOCTL Commands ***********************************************************/
+
 /* The Audio module uses a standard character driver framework.  However, a
  * lot of the Audio driver functionality is configured via a device control
  * interface, such as sampling rate, volume, data format, etc.
@@ -126,6 +130,7 @@
 #define AUDIOIOC_SETBUFFERINFO      _AUDIOIOC(17)
 
 /* Audio Device Types *******************************************************/
+
 /* The NuttX audio interface support different types of audio devices for
  * input, output, synthesis, and manipulation of audio data.  A given driver/
  * device could support a combination of these device type.  The following
@@ -143,6 +148,7 @@
 #define AUDIO_TYPE_EXTENSION        0x80
 
 /* Audio Format Types *******************************************************/
+
 /* The following defines the audio data format types in NuttX.  During a
  * format query, these will be converted to bit positions within the
  * ac_format field, meaning we currently only support up to 16 formats. To
@@ -232,7 +238,7 @@
 #define AUDIO_SUBSAMPLE_MIN         AUDIO_SUBSAMPLE_2X
 #define AUDIO_SUBSAMPLE_MAX         AUDIO_SUBSAMPLE_16X
 
-/* Supported Bit Rates *************************************************/
+/* Supported Bit Rates ******************************************************/
 
 #define AUDIO_BIT_RATE_22K          0x01
 #define AUDIO_BIT_RATE_44K          0x02
@@ -352,15 +358,22 @@ struct audio_caps_s
   uint8_t ac_subtype;       /* Capabilities sub-type, if needed */
   uint8_t ac_channels;      /* Number of channels (1, 2, 5, 7) */
 
-  union                     /* Audio data format(s) for this device */
+  /* Audio data format(s) for this device */
+
+  union
   {
     uint8_t  b[2];
     uint16_t hw;
   } ac_format;
 
-  union                     /* Device specific controls. For AUDIO_DEVICE_QUERY, */
-  {                         /*   this field reports the device type supported */
-    uint8_t  b[4];          /*   by this lower-half driver. */
+  /* Specific controls for AUDIO_DEVICE_QUERY
+   *   this field reports the device type supported
+   *   by this lower-half driver.
+   */
+
+  union
+  {
+    uint8_t  b[4];
     uint16_t hw[2];
     uint32_t w;
 #ifdef CONFIG_HAVE_LONG_LONG
@@ -384,7 +397,9 @@ struct audio_info_s
   uint8_t samplerate;   /* Sample Rate of the audio data */
   uint8_t channels;     /* Number of channels (1, 2, 5, 7) */
   uint8_t format;       /* Audio data format */
-  uint8_t subformat;    /* Audio subformat (maybe should be combined with format? */
+  uint8_t subformat;    /* Audio subformat
+                         * (maybe should be combined with format?
+                         */
 };
 
 /* This structure describes the preferred number and size of
@@ -430,10 +445,10 @@ struct audio_msg_s
 #ifdef CONFIG_AUDIO_MULTI_SESSION
   FAR void           *session;      /* Associated channel */
 #endif
-  uint16_t            msgId;        /* Message ID */
+  uint16_t            msg_id;       /* Message ID */
   union
   {
-    FAR void         *pPtr;         /* Buffer being dequeued */
+    FAR void         *ptr;          /* Buffer being dequeued */
     uint32_t          data;         /* Message data */
   } u;
 };
@@ -490,14 +505,15 @@ struct audio_ops_s
 {
   /* This method is called to retrieve the lower-half device capabilities.
    * It will be called with device type AUDIO_TYPE_QUERY to request the
-   * overall capabilities, such as to determine the types of devices supported
-   * audio formats supported, etc.  Then it may be called once or more with
-   * reported supported device types to determine the specific capabilities
-   * of that device type (such as MP3 encoder, WMA encoder, PCM output, etc.).
+   * overall capabilities, such as to determine the types of devices
+   * supported audio formats supported, etc.
+   * Then it may be called once or more with reported supported device types
+   * to determine the specific capabilities of that device type
+   * (such as MP3 encoder, WMA encoder, PCM output, etc.).
    */
 
   CODE int (*getcaps)(FAR struct audio_lowerhalf_s *dev, int type,
-      FAR struct audio_caps_s *pCaps);
+      FAR struct audio_caps_s *caps);
 
   /* This method is called to bind the lower-level driver to the upper-level
    * driver and to configure the driver for a specific mode of
@@ -509,10 +525,10 @@ struct audio_ops_s
 
 #ifdef CONFIG_AUDIO_MULTI_SESSION
   CODE int (*configure)(FAR struct audio_lowerhalf_s *dev,
-      FAR void *session, FAR const struct audio_caps_s *pCaps);
+      FAR void *session, FAR const struct audio_caps_s *caps);
 #else
   CODE int (*configure)(FAR struct audio_lowerhalf_s *dev,
-      FAR const struct audio_caps_s *pCaps);
+      FAR const struct audio_caps_s *caps);
 #endif
 
   /* This method is called when the driver is closed.  The lower half driver
@@ -520,16 +536,16 @@ struct audio_ops_s
    * output generation.  It should also disable the audio hardware and put
    * it into the lowest possible power usage state.
    *
-   * Any enqueued Audio Pipeline Buffers that have not been processed / dequeued
-   * should be dequeued by this function.
+   * Any enqueued Audio Pipeline Buffers that have not been
+   * processed / dequeued should be dequeued by this function.
    */
 
   CODE int (*shutdown)(FAR struct audio_lowerhalf_s *dev);
 
   /* Start audio streaming in the configured mode.  For input and synthesis
-   * devices, this means it should begin sending streaming audio data.  For output
-   * or processing type device, it means it should begin processing of any enqueued
-   * Audio Pipeline Buffers.
+   * devices, this means it should begin sending streaming audio data.
+   * For output or processing type device, it means it should begin
+   * processing of any enqueued Audio Pipeline Buffers.
    */
 
 #ifdef CONFIG_AUDIO_MULTI_SESSION
@@ -538,7 +554,9 @@ struct audio_ops_s
   CODE int (*start)(FAR struct audio_lowerhalf_s *dev);
 #endif
 
-  /* Stop audio streaming and/or processing of enqueued Audio Pipeline Buffers */
+  /* Stop audio streaming and/or processing of enqueued
+   * Audio Pipeline Buffers
+   */
 
 #ifndef CONFIG_AUDIO_EXCLUDE_STOP
 #ifdef CONFIG_AUDIO_MULTI_SESSION
@@ -548,8 +566,9 @@ struct audio_ops_s
 #endif
 #endif
 
-  /* Pause the audio stream.  Should keep current playback context active
-   * in case a resume is issued.  Could be called and then followed by a stop.
+  /* Pause the audio stream.
+   * Should keep current playback context active in case a resume is issued.
+   * Could be called and then followed by a stop.
    */
 
 #ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME
@@ -587,16 +606,18 @@ struct audio_ops_s
   CODE int (*freebuffer)(FAR struct audio_lowerhalf_s *dev,
          FAR struct audio_buf_desc_s *apb);
 
-  /* Enqueue a buffer for processing.  This is a non-blocking enqueue operation.
-   * If the lower-half driver's buffer queue is full, then it should return an
-   * error code of -ENOMEM, and the upper-half driver can decide to either block
-   * the calling thread or deal with it in a non-blocking manner.
+  /* Enqueue a buffer for processing.
+   * This is a non-blocking enqueue operation.
+   * If the lower-half driver's buffer queue is full, then it should return
+   * an error code of -ENOMEM, and the upper-half driver can decide to either
+   * block the calling thread or deal with it in a non-blocking manner.
 
    * For each call to enqueuebuffer, the lower-half driver must call
-   * audio_dequeuebuffer when it is finished processing the bufferr, passing the
-   * previously enqueued apb and a dequeue status so that the upper-half driver
-   * can decide if a waiting thread needs to be release, if the dequeued buffer
-   * should be passed to the next block in the Audio Pipeline, etc.
+   * audio_dequeuebuffer when it is finished processing the bufferr, passing
+   * the previously enqueued apb and a dequeue status so that the upper-half
+   * driver can decide if a waiting thread needs to be release, if the
+   * dequeued buffer should be passed to the next block in the
+   * Audio Pipeline, etc.
    */
 
   CODE int (*enqueuebuffer)(FAR struct audio_lowerhalf_s *dev,
@@ -630,7 +651,8 @@ struct audio_ops_s
    */
 
 #ifdef CONFIG_AUDIO_MULTI_SESSION
-  CODE int (*reserve)(FAR struct audio_lowerhalf_s *dev, FAR void **psession);
+  CODE int (*reserve)(FAR struct audio_lowerhalf_s *dev,
+                      FAR void **psession);
 #else
   CODE int (*reserve)(FAR struct audio_lowerhalf_s *dev);
 #endif
@@ -638,7 +660,8 @@ struct audio_ops_s
   /* Release a session.  */
 
 #ifdef CONFIG_AUDIO_MULTI_SESSION
-  CODE int (*release)(FAR struct audio_lowerhalf_s *dev, FAR void *session);
+  CODE int (*release)(FAR struct audio_lowerhalf_s *dev,
+                      FAR void *session);
 #else
   CODE int (*release)(FAR struct audio_lowerhalf_s *dev);
 #endif
@@ -670,7 +693,9 @@ struct audio_lowerhalf_s
 
   FAR audio_callback_t  upper;
 
-  /* The private opaque pointer to be passed to upper-layer during callbacks */
+  /* The private opaque pointer to be passed to upper-layer during
+   * callbacks
+   */
 
   FAR void *priv;
 
@@ -698,6 +723,7 @@ extern "C"
 /****************************************************************************
  * "Upper-Half" Audio Driver Interfaces
  ****************************************************************************/
+
 /****************************************************************************
  * Name: audio_register
  *
@@ -711,12 +737,12 @@ extern "C"
  *
  * Input Parameters:
  *   name - The name of the audio device.  This name will be used to generate
- *     a full path to the driver in the format "/dev/audio/[name]" in the NuttX
- *     filesystem (i.e. the path "/dev/audio" will be prepended to the supplied
- *     device name.  The recommended convention is to name Audio drivers
- *     based on the type of functionality they provide, such as "/dev/audio/pcm0",
- *     "/dev/audio/midi0", "/dev/audio/mp30, etc.
- *   dev - A pointer to an instance of lower half audio driver.  This instance
+ *     a full path to the driver in the format "/dev/audio/[name]" in the
+ *     NuttX filesystem (i.e. the path "/dev/audio" will be prepended to the
+ *     supplied device name.  The recommended convention is to name Audio
+ *     drivers based on the type of functionality they provide, such as
+ *     "/dev/audio/pcm0", "/dev/audio/midi0", "/dev/audio/mp30, etc.
+ *   dev - A pointer to an instance of lower half audio driver. This instance
  *     is bound to the Audio driver and must persists as long as the driver
  *     persists.
  *
@@ -731,8 +757,9 @@ int audio_register(FAR const char *name, FAR struct audio_lowerhalf_s *dev);
  * Name: abp_alloc
  *
  * Description:
- *   Allocated an AP Buffer and prepares it for use.  This allocates a dynamically
- *   allocated buffer that has no special DMA capabilities.
+ *   Allocated an AP Buffer and prepares it for use.
+ *   This allocates a dynamically allocated buffer that has no special
+ *    DMA capabilities.
  *
  * Input Parameters:
  *   bufdesc:   Pointer to a buffer descriptor
diff --git a/include/nuttx/audio/audio_null.h b/include/nuttx/audio/audio_null.h
index 24e5bb0..d789c83 100644
--- a/include/nuttx/audio/audio_null.h
+++ b/include/nuttx/audio/audio_null.h
@@ -51,6 +51,7 @@
 /****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/
+
 /* Configuration ************************************************************
  *
  * CONFIG_AUDIO_NULL - Enabled NULL audio device support
diff --git a/include/nuttx/audio/cs43l22.h b/include/nuttx/audio/cs43l22.h
index 9065478..9d9fd60 100644
--- a/include/nuttx/audio/cs43l22.h
+++ b/include/nuttx/audio/cs43l22.h
@@ -54,14 +54,16 @@
 /****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/
+
 /* Configuration ************************************************************
  *
  * CONFIG_AUDIO_CS43L22 - Enables CS43L22 support
- * CONFIG_CS43L22_INITVOLUME - The initial volume level in the range {0..1000}
- * CONFIG_CS43L22_INFLIGHT - Maximum number of buffers that the CS43L22 driver
- *   will send to the I2S driver before any have completed.
- * CONFIG_CS43L22_MSG_PRIO - Priority of messages sent to the CS43L22 worker
- *   thread.
+ * CONFIG_CS43L22_INITVOLUME - The initial volume level
+ *                             in the range {0..1000}
+ * CONFIG_CS43L22_INFLIGHT - Maximum number of buffers that the CS43L22
+ *   driver will send to the I2S driver before any have completed.
+ * CONFIG_CS43L22_MSG_PRIO - Priority of messages sent to the CS43L22
+ *   worker thread.
  * CONFIG_CS43L22_BUFFER_SIZE - Preferred buffer size
  * CONFIG_CS43L22_NUM_BUFFERS - Preferred number of buffers
  * CONFIG_CS43L22_WORKER_STACKSIZE - Stack size to use when creating the the
@@ -130,6 +132,7 @@
 /****************************************************************************
  * Public Types
  ****************************************************************************/
+
 /* This is the type of the CS43L22 interrupt handler.  The lower level code
  * will intercept the interrupt and provide the upper level with the private
  * data that was provided when the interrupt was attached.
@@ -137,8 +140,9 @@
 
 struct cs43l22_lower_s; /* Forward reference.  Defined below */
 
-typedef CODE int (*cs43l22_handler_t)(FAR const struct cs43l22_lower_s *lower,
-                                      FAR void *arg);
+typedef CODE int (*cs43l22_handler_t)
+                 (FAR const struct cs43l22_lower_s *lower,
+                  FAR void *arg);
 
 /* A reference to a structure of this type must be passed to the CS43L22
  * driver.  This structure provides information about the configuration
diff --git a/include/nuttx/audio/i2s.h b/include/nuttx/audio/i2s.h
index 5a630d6..6cdbf4f 100644
--- a/include/nuttx/audio/i2s.h
+++ b/include/nuttx/audio/i2s.h
@@ -53,6 +53,7 @@
 /****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/
+
 /* Access macros ************************************************************/
 
 /****************************************************************************
@@ -261,6 +262,7 @@
 /****************************************************************************
  * Public Types
  ****************************************************************************/
+
 /* Transfer complete callbacks */
 
 struct i2s_dev_s;
@@ -273,27 +275,36 @@ struct i2s_ops_s
 {
   /* Receiver methods */
 
-  CODE int      (*i2s_rxchannels)(FAR struct i2s_dev_s *dev, uint8_t channels);
-  CODE uint32_t (*i2s_rxsamplerate)(FAR struct i2s_dev_s *dev, uint32_t rate);
-  CODE uint32_t (*i2s_rxdatawidth)(FAR struct i2s_dev_s *dev, int bits);
+  CODE int      (*i2s_rxchannels)(FAR struct i2s_dev_s *dev,
+                                  uint8_t channels);
+  CODE uint32_t (*i2s_rxsamplerate)(FAR struct i2s_dev_s *dev,
+                                    uint32_t rate);
+  CODE uint32_t (*i2s_rxdatawidth)(FAR struct i2s_dev_s *dev,
+                                   int bits);
   CODE int      (*i2s_receive)(FAR struct i2s_dev_s *dev,
-                  FAR struct ap_buffer_s *apb, i2s_callback_t callback,
-                  FAR void *arg, uint32_t timeout);
+                               FAR struct ap_buffer_s *apb,
+                               i2s_callback_t callback,
+                               FAR void *arg,
+                               uint32_t timeout);
 
   /* Transmitter methods */
 
-  CODE int      (*i2s_txchannels)(FAR struct i2s_dev_s *dev, uint8_t channels);
-  CODE uint32_t (*i2s_txsamplerate)(FAR struct i2s_dev_s *dev, uint32_t rate);
-  CODE uint32_t (*i2s_txdatawidth)(FAR struct i2s_dev_s *dev, int bits);
+  CODE int      (*i2s_txchannels)(FAR struct i2s_dev_s *dev,
+                                  uint8_t channels);
+  CODE uint32_t (*i2s_txsamplerate)(FAR struct i2s_dev_s *dev,
+                                    uint32_t rate);
+  CODE uint32_t (*i2s_txdatawidth)(FAR struct i2s_dev_s *dev,
+                                   int bits);
   CODE int      (*i2s_send)(FAR struct i2s_dev_s *dev,
-                  FAR struct ap_buffer_s *apb, i2s_callback_t callback,
-                  FAR void *arg, uint32_t timeout);
+                            FAR struct ap_buffer_s *apb,
+                            i2s_callback_t callback,
+                            FAR void *arg,
+                            uint32_t timeout);
 
   /* Ioctl */
 
   CODE int      (*i2s_ioctl)(FAR struct i2s_dev_s *dev,
                              int cmd, unsigned long arg);
-
 };
 
 /* I2S private data.  This structure only defines the initial fields of the
@@ -320,7 +331,7 @@ extern "C"
 #endif
 
 /****************************************************************************
- * Public Functions
+ * Public Functions Prototypes
  ****************************************************************************/
 
 /****************************************************************************
diff --git a/include/nuttx/audio/pcm.h b/include/nuttx/audio/pcm.h
index 10db4d9..8fd9f7c 100644
--- a/include/nuttx/audio/pcm.h
+++ b/include/nuttx/audio/pcm.h
@@ -50,6 +50,7 @@
 /****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/
+
 /* Configuration ************************************************************
  *
  * CONFIG_AUDIO_FORMAT_PCM - Enabled PCM support
@@ -64,6 +65,7 @@
 /* Default configuration values */
 
 /* WAVE Header Definitions **************************************************/
+
 /* All values are little 32-bit or 16-bit endian */
 
 #define WAV_HDR_CHUNKID   0x46464952  /* "RIFF" */
@@ -78,6 +80,7 @@
 /****************************************************************************
  * Public Types
  ****************************************************************************/
+
 /* The standard WAV header consist of three chunks
  *
  * 1. A WAV header chunk,
@@ -119,7 +122,7 @@ struct wav_header_s
   struct wav_datachunk_s   data;
 };
 
- /****************************************************************************
+/****************************************************************************
  * Public Data
  ****************************************************************************/
 
diff --git a/include/nuttx/audio/wm8776.h b/include/nuttx/audio/wm8776.h
index b921b7d..fe26081 100644
--- a/include/nuttx/audio/wm8776.h
+++ b/include/nuttx/audio/wm8776.h
@@ -61,7 +61,6 @@ struct wm8776_lower_s
   uint8_t  address;    /* 7-bit I2C address (only bits 0-6 used) */
 };
 
-
 /****************************************************************************
  * Public Data
  ****************************************************************************/
@@ -87,7 +86,6 @@ FAR struct audio_lowerhalf_s *
                     FAR struct i2s_dev_s *i2s,
                     FAR const struct wm8776_lower_s *lower);
 
-
 #undef EXTERN
 #ifdef __cplusplus
 }
diff --git a/include/nuttx/audio/wm8904.h b/include/nuttx/audio/wm8904.h
index dc1488b..db37e54 100644
--- a/include/nuttx/audio/wm8904.h
+++ b/include/nuttx/audio/wm8904.h
@@ -54,6 +54,7 @@
 /****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/
+
 /* Configuration ************************************************************
  *
  * CONFIG_AUDIO_WM8904 - Enables WM8904 support
@@ -129,6 +130,7 @@
 /****************************************************************************
  * Public Types
  ****************************************************************************/
+
 /* This is the type of the WM8904 interrupt handler.  The lower level code
  * will intercept the interrupt and provide the upper level with the private
  * data that was provided when the interrupt was attached.


[incubator-nuttx] 06/06: cxd56: replace Sony return values

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

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

commit 79589eca1a487f3d851ee937b508784831bf0df1
Author: Tobias Johansson <to...@sony.com>
AuthorDate: Mon Apr 20 07:43:45 2020 +0200

    cxd56: replace Sony return values
    
    - Replace Sony error codes with standard ones where possible
    - Unify error message and remove some unnecessary info prints
---
 drivers/audio/cxd56.c | 382 +++++++++++++++++++++++++++-----------------------
 1 file changed, 210 insertions(+), 172 deletions(-)

diff --git a/drivers/audio/cxd56.c b/drivers/audio/cxd56.c
index 871e972..10a8f5f 100644
--- a/drivers/audio/cxd56.c
+++ b/drivers/audio/cxd56.c
@@ -286,16 +286,16 @@ static int     cxd56_ioctl(FAR struct audio_lowerhalf_s *lower, int cmd,
 
 /* Non-interface functions */
 
-static void cxd56_attach_irq(bool attach);
+static int cxd56_attach_irq(bool attach);
 static void cxd56_enable_irq(bool enable);
 static uint32_t cxd56_get_i2s_rate(uint32_t samplerate);
-static int cxd56_init_dma(FAR struct cxd56_dev_s *dev);
+static void cxd56_init_dma(FAR struct cxd56_dev_s *dev);
 static void cxd56_init_i2s1_output(uint8_t bits);
 static int cxd56_init_worker(FAR struct audio_lowerhalf_s *lower);
-static uint32_t cxd56_power_off(FAR struct cxd56_dev_s *dev);
-static uint32_t cxd56_power_on(FAR struct cxd56_dev_s *dev);
-static uint32_t cxd56_power_on_aca(uint32_t samplerate);
-static uint32_t cxd56_power_on_analog_output(FAR struct cxd56_dev_s *dev);
+static int cxd56_power_off(FAR struct cxd56_dev_s *dev);
+static int cxd56_power_on(FAR struct cxd56_dev_s *dev);
+static int cxd56_power_on_aca(uint32_t samplerate);
+static int cxd56_power_on_analog_output(FAR struct cxd56_dev_s *dev);
 static void cxd56_power_on_i2s1(FAR struct cxd56_dev_s *dev);
 static int cxd56_start_dma(FAR struct cxd56_dev_s *dev);
 static int cxd56_stop_dma(FAR struct cxd56_dev_s *priv);
@@ -771,7 +771,7 @@ static void cxd56_take_sem(sem_t *sem)
       ret = nxsem_wait(sem);
       if (ret != 0 && ret != -EINTR)
         {
-          auderr("cxd56_take_sem failed. (%d)\n", ret);
+          auderr("ERROR: Take semaphore failed (%d)\n", ret);
         }
     }
   while (ret == -EINTR);
@@ -788,7 +788,7 @@ static void cxd56_give_sem(sem_t *sem)
       ret = nxsem_post(sem);
       if (ret != 0 && ret != -EINTR)
         {
-          auderr("cxd56_give_sem failed. (%d)\n", ret);
+          auderr("ERROR: Give semaphore failed (%d)\n", ret);
         }
     }
   while (ret == -EINTR);
@@ -865,11 +865,14 @@ static void cxd56_reset_channel_sel(cxd56_dmahandle_t handle)
 
 static void cxd56_dma_int_handler(void)
 {
-  uint16_t          ecode = CXD56_AUDIO_ECODE_DMA_HANDLE_INV;
+  uint16_t err_code;
+  uint32_t int_irq;
+  uint32_t int_i2s;
   cxd56_dmahandle_t hdl;
 
-  uint32_t int_irq = read_reg32(REG_INT_IRQ1);
-  uint32_t int_i2s = cxd56_int_get_state(CXD56_AUDIO_DMA_I2S0_DOWN);
+  err_code = CXD56_AUDIO_ECODE_DMA_HANDLE_INV;
+  int_irq = read_reg32(REG_INT_IRQ1);
+  int_i2s = cxd56_int_get_state(CXD56_AUDIO_DMA_I2S0_DOWN);
 
   if ((int_irq & CXD56_IRQ1_BIT_I2S1) && (int_i2s != 0))
     {
@@ -879,7 +882,7 @@ static void cxd56_dma_int_handler(void)
 
       if (int_i2s & (1 << REG_I2S1_INT_CTRL_DONE.pos))
         {
-          ecode = CXD56_AUDIO_ECODE_DMA_CMPLT;
+          err_code = CXD56_AUDIO_ECODE_DMA_CMPLT;
         }
 
       if (int_i2s & (1 << REG_I2S1_INT_CTRL_ERR.pos))
@@ -889,7 +892,7 @@ static void cxd56_dma_int_handler(void)
           write_reg(REG_I2S1_INT_MASK_ERR, 1);
           write_reg(REG_I2S1_INT_CTRL_ERR, 1);
 
-          ecode = CXD56_AUDIO_ECODE_DMA_TRANS;
+          err_code = CXD56_AUDIO_ECODE_DMA_TRANS;
         }
 
       if (int_i2s & (1 << REG_I2S1_INT_CTRL_CMB.pos))
@@ -899,19 +902,20 @@ static void cxd56_dma_int_handler(void)
           write_reg(REG_I2S1_INT_MASK_CMB, 1);
           write_reg(REG_I2S1_INT_CTRL_CMB, 1);
 
-          ecode = CXD56_AUDIO_ECODE_DMA_CMB;
+          err_code = CXD56_AUDIO_ECODE_DMA_CMB;
         }
     }
   else
     {
-      _warn("cxd56_dma_int_handler: Unhandled interrupt\n");
+      audinfo("Unhandled interrupt\n");
       return;
     }
 
-  if (ecode != CXD56_AUDIO_ECODE_DMA_HANDLE_INV)
+  if (err_code != CXD56_AUDIO_ECODE_DMA_HANDLE_INV)
     {
       struct audio_msg_s msg;
       struct cxd56_dev_s *dev;
+      int ret;
 
       dev = g_dev[hdl];
 
@@ -921,6 +925,7 @@ static void cxd56_dma_int_handler(void)
       if (dq_count(&dev->runningq) > 0)
         {
           FAR struct ap_buffer_s *apb;
+
           apb = (struct ap_buffer_s *) dq_pop(&dev->runningq);
           dev->dev.upper(dev->dev.priv, AUDIO_CALLBACK_DEQUEUE, apb, OK);
         }
@@ -933,11 +938,15 @@ static void cxd56_dma_int_handler(void)
 
           msg.msg_id = AUDIO_MSG_DATA_REQUEST;
           msg.u.data = 0;
-          (void)nxmq_send(dev->mq, (FAR const char *) &msg,
+          ret = nxmq_send(dev->mq, (FAR const char *) &msg,
                           sizeof(msg), CONFIG_CXD56_MSG_PRIO);
+          if (ret != OK)
+            {
+              auderr("ERROR: nxmq_send to request failed (%d)\n", ret);
+            }
         }
 
-      if (ecode == CXD56_AUDIO_ECODE_DMA_TRANS)
+      if (err_code == CXD56_AUDIO_ECODE_DMA_TRANS)
         {
           /* Notify end of data */
 
@@ -945,29 +954,62 @@ static void cxd56_dma_int_handler(void)
             {
               msg.msg_id = AUDIO_MSG_STOP;
               msg.u.data = 0;
-              (void)nxmq_send(dev->mq, (FAR const char *)&msg,
+              ret = nxmq_send(dev->mq, (FAR const char *)&msg,
                               sizeof(msg), CONFIG_CXD56_MSG_PRIO);
+              if (ret != OK)
+                {
+                  auderr("ERROR: nxmq_send to stop failed (%d)\n", ret);
+                }
             }
         }
     }
 }
 
-static void cxd56_attach_irq(bool attach)
+static int cxd56_attach_irq(bool attach)
 {
+  int ret;
+  int cur_irq;
+  const int audio_irqs[4] = {
+    CXD56_IRQ_AUDIO_0,
+    CXD56_IRQ_AUDIO_1,
+    CXD56_IRQ_AUDIO_2,
+    CXD56_IRQ_AUDIO_3
+  };
+
+  cur_irq = 4;
   if (attach)
     {
-      irq_attach(CXD56_IRQ_AUDIO_0, (xcpt_t)cxd56_dma_int_handler, NULL);
-      irq_attach(CXD56_IRQ_AUDIO_1, (xcpt_t)cxd56_dma_int_handler, NULL);
-      irq_attach(CXD56_IRQ_AUDIO_2, (xcpt_t)cxd56_dma_int_handler, NULL);
-      irq_attach(CXD56_IRQ_AUDIO_3, (xcpt_t)cxd56_dma_int_handler, NULL);
+      do
+        {
+          cur_irq--;
+          ret = irq_attach(audio_irqs[cur_irq],
+                           (xcpt_t)cxd56_dma_int_handler, NULL);
+          if (ret != OK)
+            {
+              auderr("ERROR: Failed to attach handler to irq %d. (%d)\n",
+                     cur_irq, ret);
+              return ret;
+            }
+        }
+      while (cur_irq > 0);
     }
   else
     {
-      irq_detach(CXD56_IRQ_AUDIO_0);
-      irq_detach(CXD56_IRQ_AUDIO_1);
-      irq_detach(CXD56_IRQ_AUDIO_2);
-      irq_detach(CXD56_IRQ_AUDIO_3);
+      do
+        {
+          cur_irq--;
+          ret = irq_detach(audio_irqs[cur_irq]);
+          if (ret != OK)
+            {
+              auderr("ERROR: Failed to detach handler from irq %d. (%d)\n",
+                     cur_irq, ret);
+              return ret;
+            }
+        }
+      while (cur_irq > 0);
     }
+
+  return OK;
 }
 
 static void cxd56_enable_irq(bool enable)
@@ -1012,7 +1054,6 @@ static int cxd56_set_volume(enum cxd56_vol_id_e id, int16_t vol)
         break;
     }
 
-
   if (vol == CXD56_VOL_MUTE_REG)
     {
       /* Disable analog out */
@@ -1021,9 +1062,8 @@ static int cxd56_set_volume(enum cxd56_vol_id_e id, int16_t vol)
                            (uint32_t)CXD56_OUT_DEV_OFF);
       if (ret != CXD56_AUDIO_ECODE_OK)
         {
-          auderr("cxd56_set_volume analog out disable failed. (%d)\n", ret);
-          ret = -EBUSY;
-          goto error;
+          auderr("ERROR: Set output device for mute failed (%d)\n", ret);
+          return -EBUSY;
         }
     }
   else
@@ -1034,15 +1074,12 @@ static int cxd56_set_volume(enum cxd56_vol_id_e id, int16_t vol)
                            (uint32_t)CXD56_OUT_DEV_SP);
       if (ret != CXD56_AUDIO_ECODE_OK)
         {
-          auderr("cxd56_set_volume analog out enable failed. (%d)\n", ret);
-          ret = -EBUSY;
-          goto error;
+          auderr("ERROR: Set output device for volume failed (%d)\n", ret);
+          return -EBUSY;
         }
     }
-  ret = OK;
 
-error:
-  return ret;
+  return OK;
 }
 
 static void cxd56_init_i2s1_output(uint8_t bits)
@@ -1077,11 +1114,9 @@ static void cxd56_set_dma_running(cxd56_dmahandle_t handle, bool running)
     }
 }
 
-static int cxd56_init_dma(FAR struct cxd56_dev_s *dev)
+static void cxd56_init_dma(FAR struct cxd56_dev_s *dev)
 {
-  int ret = CXD56_AUDIO_ECODE_OK;
-  FAR struct cxd56_dev_s *priv = (FAR struct cxd56_dev_s *)dev;
-  uint8_t ints = CXD56_DMA_INT_DONE | CXD56_DMA_INT_ERR | CXD56_DMA_INT_CMB;
+  uint8_t ints;
 
   audinfo("cxd56_init_dma: state = %d, hdl = %d.\n",
           dev->state,
@@ -1090,13 +1125,15 @@ static int cxd56_init_dma(FAR struct cxd56_dev_s *dev)
   dq_clear(&dev->pendingq);
   dq_clear(&dev->runningq);
 
+  ints = CXD56_DMA_INT_DONE | CXD56_DMA_INT_ERR | CXD56_DMA_INT_CMB;
+
   /* Enable DMA */
 
   write_reg(REG_AC_MCK_AMBMSTR_EN, 1);
 
   /* Setup output, bit width etc */
 
-  cxd56_init_i2s1_output(priv->bitwidth);
+  cxd56_init_i2s1_output(dev->bitwidth);
 
   /* Clear interrupt states */
 
@@ -1108,8 +1145,6 @@ static int cxd56_init_dma(FAR struct cxd56_dev_s *dev)
   cxd56_int_unmask_ahb(dev->dma_handle);
 
   cxd56_set_dma_int_en(true);
-
-  return ret;
 }
 
 static uint32_t cxd56_get_i2s_rate(uint32_t samplerate)
@@ -1129,6 +1164,7 @@ static uint32_t cxd56_get_i2s_rate(uint32_t samplerate)
 static void cxd56_power_on_i2s1(FAR struct cxd56_dev_s *dev)
 {
   uint32_t rate;
+
   write_reg(REG_AC_PDN_DSPS1, 0);                     /* Power on SRC1 */
   write_reg(REG_AC_SD1MASTER, CXD56_I2S1_MODE);       /* I2S1 mode */
   write_reg(REG_AC_DIF1, CXD56_I2S1_FORMAT);          /* I2S1 format */
@@ -1139,13 +1175,13 @@ static void cxd56_power_on_i2s1(FAR struct cxd56_dev_s *dev)
   write_reg(REG_AC_SRC1, rate);                       /* I2S1 rate */
 }
 
-static uint32_t cxd56_power_on_aca(uint32_t samplerate)
+static int cxd56_power_on_aca(uint32_t samplerate)
 {
   struct cxd56_aca_pwon_param_s pwon_param;
 
   if (as_aca_control(CXD56_ACA_CTL_CHECK_ID, (uint32_t)NULL) != 0)
     {
-      return CXD56_AUDIO_ECODE_ANA_CHKID;
+      return -ENXIO;
     }
 
   if (samplerate > 48000)
@@ -1163,19 +1199,20 @@ static uint32_t cxd56_power_on_aca(uint32_t samplerate)
 
   pwon_param.dmic_clk_ds = CXD56_DMIC_CLK_DS;
   pwon_param.ad_data_ds = CXD56_DA_DS;
-  pwon_param.mic_dev = CXD56_ACA_MIC_AMIC;  /* TODO: analog/digital mic select */
+  pwon_param.mic_dev = CXD56_ACA_MIC_AMIC;
   pwon_param.mclk_ds = CXD56_MCLKOUT_DS;
   pwon_param.gpo_ds = CXD56_GPO_A_DS;
+
   if (as_aca_control(CXD56_ACA_CTL_POWER_ON_COMMON,
                     (uint32_t)&pwon_param) != 0)
     {
-      return CXD56_AUDIO_ECODE_ANA_PWON;
+      return -EBUSY;
     }
 
-  return CXD56_AUDIO_ECODE_OK;
+  return OK;
 }
 
-static uint32_t cxd56_power_on_analog_output(FAR struct cxd56_dev_s *dev)
+static int cxd56_power_on_analog_output(FAR struct cxd56_dev_s *dev)
 {
   struct cxd56_aca_smaster_param_s smaster_param;
   struct cxd56_aca_pwoutput_param_s pwon_param;
@@ -1209,13 +1246,13 @@ static uint32_t cxd56_power_on_analog_output(FAR struct cxd56_dev_s *dev)
   if (as_aca_control(CXD56_ACA_CTL_SET_SMASTER,
                     (uint32_t)&smaster_param) != 0)
     {
-      return CXD56_AUDIO_ECODE_ANA_SET_SMASTER;
+      return -EBUSY;
     }
 
   if (as_aca_control(CXD56_ACA_CTL_POWER_ON_OUTPUT,
                     (uint32_t)&pwon_param) != 0)
     {
-      return CXD56_AUDIO_ECODE_ANA_PWON_OUTPUT;
+      return -EBUSY;
     }
 
   /* Power on S-Mster. */
@@ -1245,10 +1282,10 @@ static uint32_t cxd56_power_on_analog_output(FAR struct cxd56_dev_s *dev)
 
   cxd56_set_volume(CXD56_AUDIO_VOLID_MIXER_OUT, dev->volume);
 
-  return CXD56_AUDIO_ECODE_OK;
+  return OK;
 }
 
-static uint32_t cxd56_power_on(FAR struct cxd56_dev_s *dev)
+static int cxd56_power_on(FAR struct cxd56_dev_s *dev)
 {
   if (g_codec_start_count == 0)
     {
@@ -1259,12 +1296,12 @@ static uint32_t cxd56_power_on(FAR struct cxd56_dev_s *dev)
 
       if (board_aca_power_control(CXD5247_AVDD | CXD5247_DVDD, true) != 0)
         {
-          return CXD56_AUDIO_ECODE_ANA_PWON;
+          return -EBUSY;
         }
 
       if (!board_aca_power_monitor(CXD5247_AVDD | CXD5247_DVDD))
         {
-          return CXD56_AUDIO_ECODE_ANA_PWON;
+          return -EBUSY;
         }
 
       cxd56_power_on_aca(dev->samplerate);
@@ -1275,16 +1312,16 @@ static uint32_t cxd56_power_on(FAR struct cxd56_dev_s *dev)
 
       if (read_reg(REG_AC_REVID) != CXD56_EXP_REVID)
         {
-          auderr("cxd56_power_on REVID mismatch (%x vs. %x).\n",
+          auderr("ERROR: Power on REVID mismatch (%x vs. %x)\n",
                REG_AC_REVID, CXD56_EXP_REVID);
-          return CXD56_AUDIO_ECODE_ANA_CHKID;
+          return -ENXIO;
         }
 
       if (read_reg(REG_AC_DEVICEID) != CXD56_EXP_DEVICEID)
         {
-          auderr("cxd56_power_on DEVICEID mismatch (%x vs. %x).\n",
+          auderr("ERROR: Power on DEVICEID mismatch (%x vs. %x)\n",
                REG_AC_DEVICEID, CXD56_EXP_DEVICEID);
-          return CXD56_AUDIO_ECODE_ANA_CHKID;
+          return -ENXIO;
         }
 
       /* Power on serializeer */
@@ -1329,7 +1366,7 @@ static uint32_t cxd56_power_on(FAR struct cxd56_dev_s *dev)
 
       /* Set BCA data rate */
 
-      write_reg(REG_I2S_ENSEL, (dev->samplerate > 48000) ? 1 : 0);
+      write_reg(REG_I2S_ENSEL, ((dev->samplerate > 48000) ? 1 : 0));
 
       /* Disable DEQ */
 
@@ -1358,13 +1395,11 @@ static uint32_t cxd56_power_on(FAR struct cxd56_dev_s *dev)
 
   g_codec_start_count++;
 
-  return CXD56_AUDIO_ECODE_OK;
+  return OK;
 }
 
-static uint32_t cxd56_power_off(FAR struct cxd56_dev_s *dev)
+static int cxd56_power_off(FAR struct cxd56_dev_s *dev)
 {
-  audinfo("cxd56_power_off\n");
-
   /* Disable AHBMASTER. */
 
   write_reg(REG_AC_MCK_AMBMSTR_EN, 0);
@@ -1403,9 +1438,10 @@ static uint32_t cxd56_power_off(FAR struct cxd56_dev_s *dev)
   /* Disable audio clock */
 
   cxd56_audio_clock_disable();
+
   if (as_aca_control(CXD56_ACA_CTL_POWER_OFF_COMMON, (uint32_t)NULL) != 0)
     {
-      return CXD56_AUDIO_ECODE_ANA_PWOFF;
+      return -EBUSY;
     }
 
   board_aca_power_control(CXD5247_AVDD | CXD5247_DVDD, false);
@@ -1417,7 +1453,7 @@ static uint32_t cxd56_power_off(FAR struct cxd56_dev_s *dev)
 
   board_audio_finalize();
 
-  return CXD56_AUDIO_ECODE_OK;
+  return OK;
 }
 
 /****************************************************************************
@@ -1523,26 +1559,23 @@ static int cxd56_getcaps(FAR struct audio_lowerhalf_s *lower, int type,
 
 static int cxd56_shutdown(FAR struct audio_lowerhalf_s *lower)
 {
+  int ret;
   FAR struct cxd56_dev_s *priv = (FAR struct cxd56_dev_s *)lower;
-  int ret = OK;
-
-  audinfo("cxd56_shutdown\n");
 
   if (priv->state != CXD56_DEV_STATE_OFF)
     {
       ret = cxd56_power_off(priv);
-      if (ret != CXD56_AUDIO_ECODE_OK)
+      if (ret != OK)
         {
-          auderr("cxd56_audio_poweroff() failed. (%d)\n", ret);
-          goto error;
+          auderr("ERROR: Power off failed (%d)\n", ret);
+          return ret;
         }
 
       g_codec_start_count = 0;
       priv->state = CXD56_DEV_STATE_OFF;
     }
 
-error:
-  return ret;
+  return OK;
 }
 
 /****************************************************************************
@@ -1560,13 +1593,12 @@ static int cxd56_configure(FAR struct audio_lowerhalf_s *lower,
                  FAR const struct audio_caps_s *caps)
 #endif
 {
+  int ret;
   FAR struct cxd56_dev_s *priv = (FAR struct cxd56_dev_s *)lower;
-  int ret = OK;
 
   switch (caps->ac_type)
     {
     case AUDIO_TYPE_FEATURE:
-      audinfo("  AUDIO_TYPE_FEATURE\n");
 
       switch (caps->ac_format.hw)
         {
@@ -1587,16 +1619,15 @@ static int cxd56_configure(FAR struct audio_lowerhalf_s *lower,
               }
             else
               {
-                ret = -EDOM;
+                return -EDOM;
               }
           }
           break;
 #endif /* CONFIG_AUDIO_EXCLUDE_VOLUME */
 
         default:
-          auderr("Unrecognized feature unit\n");
-          ret = -ENOTTY;
-          break;
+          auderr("ERROR: Unknown feature unit: %d\n", caps->ac_format.hw);
+          return -ENOTTY;
         }
       break;
 
@@ -1604,10 +1635,9 @@ static int cxd56_configure(FAR struct audio_lowerhalf_s *lower,
       {
         if (caps->ac_controls.b[2] != 16 && caps->ac_controls.b[2] != 24)
           {
-            auderr("Unsupported bits per sample: %d\n",
+            auderr("ERROR: Unsupported bits per sample: %d\n",
                    caps->ac_controls.b[2]);
-            ret = -ERANGE;
-            break;
+            return -ERANGE;
           }
 
         /* Save the configuration */
@@ -1627,26 +1657,20 @@ static int cxd56_configure(FAR struct audio_lowerhalf_s *lower,
         /* Get ready to start receiving buffers */
 
         ret = cxd56_power_on(priv);
-        if (ret != CXD56_AUDIO_ECODE_OK)
+        if (ret != OK)
           {
-            auderr("Power on error. (%d)\n", ret);
-            goto error;
+            auderr("ERROR: Power on error (%d)\n", ret);
+            return ret;
           }
 
-        ret = cxd56_init_dma(priv);
-        if (ret != CXD56_AUDIO_ECODE_OK)
-          {
-            auderr("DMA init failed. (%d)\n", ret);
-            goto error;
-          }
+        cxd56_init_dma(priv);
 
         priv->state = CXD56_DEV_STATE_STOPPED;
       }
       break;
     }
 
-error:
-  return ret;
+  return OK;
 }
 
 /****************************************************************************
@@ -1666,8 +1690,6 @@ static int cxd56_start(FAR struct audio_lowerhalf_s *lower)
   int ret;
   FAR struct cxd56_dev_s *priv = (FAR struct cxd56_dev_s *)lower;
 
-  audinfo("cxd56_start\n");
-
   /* Set audio path and enable output */
 
   if (priv->dma_handle == CXD56_AUDIO_DMA_I2S0_DOWN)
@@ -1676,21 +1698,20 @@ static int cxd56_start(FAR struct audio_lowerhalf_s *lower)
     }
 
   ret = cxd56_power_on_analog_output(priv);
-  if (ret != CXD56_AUDIO_ECODE_OK)
+  if (ret != OK)
     {
-      auderr("Power on analog output failed- (%d)\n", ret);
-      goto error;
+      auderr("ERROR: Power on analog output failed (%d)\n", ret);
+      return ret;
     }
 
   ret = cxd56_init_worker(lower);
-  if (ret != CXD56_AUDIO_ECODE_OK)
+  if (ret != OK)
     {
-      auderr("Could not feed DMA. (%d)\n", ret);
-      goto error;
+      auderr("ERROR: Could not feed DMA (%d)\n", ret);
+      return ret;
     }
 
-error:
-  return ret;
+  return OK;
 }
 
 /****************************************************************************
@@ -1702,12 +1723,10 @@ error:
 
 static int cxd56_stop_dma(FAR struct cxd56_dev_s *priv)
 {
-  int ret = OK;
+  int ret;
 
   if (priv->state != CXD56_DEV_STATE_STOPPED)
     {
-      audinfo("Stopping DMA for handle %d.\n", priv->dma_handle);
-
       /* Stop DMA */
 
       cxd56_set_dma_running(priv->dma_handle, false);
@@ -1716,17 +1735,28 @@ static int cxd56_stop_dma(FAR struct cxd56_dev_s *priv)
         {
           /* Turn off amplifier */
 
-          board_external_amp_mute_control(true);
+          ret = board_external_amp_mute_control(true);
+          if (ret != CXD56_AUDIO_ECODE_OK)
+            {
+              auderr("ERROR: Couldn't mute amplifier (%d)\n", ret);
+              return -EBUSY;
+            }
 
           /* Mute and disable output */
 
           write_reg(REG_AC_NSPMUTE, 1);
           write_reg(REG_AC_PDN_SMSTR, 1);
+
           as_aca_control(CXD56_ACA_CTL_POWER_OFF_OUTPUT, (uint32_t)NULL);
+          if (ret != CXD56_AUDIO_ECODE_OK)
+            {
+              auderr("ERROR: Analog out power off failed (%d)\n", ret);
+              return -EBUSY;
+            }
         }
     }
 
-  return ret;
+  return OK;
 }
 
 #ifndef CONFIG_AUDIO_EXCLUDE_STOP
@@ -1736,29 +1766,33 @@ static int cxd56_stop(FAR struct audio_lowerhalf_s *lower, FAR void *session)
 static int cxd56_stop(FAR struct audio_lowerhalf_s *lower)
 #endif
 {
-  int ret = OK;
-  FAR void *value;
-  struct audio_msg_s msg;
   FAR struct cxd56_dev_s *priv = (FAR struct cxd56_dev_s *)lower;
 
   audinfo("cxd56_stop\n");
 
-  if (priv->state == CXD56_DEV_STATE_STOPPED)
+  if (priv->state != CXD56_DEV_STATE_STOPPED)
     {
-      goto error;
-    }
+      int ret;
+      FAR void *value;
+      struct audio_msg_s msg;
+
+      msg.msg_id = AUDIO_MSG_STOP;
+      msg.u.data = 0;
+      ret = nxmq_send(priv->mq, (FAR const char *)&msg,
+                      sizeof(msg), CONFIG_CXD56_MSG_PRIO);
+      if (ret != OK)
+        {
+          auderr("ERROR: nxmq_send stop message failed (%d)\n", ret);
+          return ret;
+        }
 
-  msg.msg_id = AUDIO_MSG_STOP;
-  msg.u.data = 0;
-  (void)nxmq_send(priv->mq, (FAR const char *)&msg,
-                  sizeof(msg), CONFIG_CXD56_MSG_PRIO);
+      /* Join the worker thread */
 
-  /* Join the worker thread */
+      pthread_join(priv->threadid, &value);
+      priv->threadid = 0;
+    }
 
-  pthread_join(priv->threadid, &value);
-  priv->threadid = 0;
-error:
-  return ret;
+  return OK;
 }
 #endif /* CONFIG_AUDIO_EXCLUDE_STOP */
 
@@ -1777,22 +1811,22 @@ static int cxd56_pause(FAR struct audio_lowerhalf_s *lower,
 static int cxd56_pause(FAR struct audio_lowerhalf_s *lower)
 #endif
 {
-  int ret = OK;
+  int ret;
   FAR struct cxd56_dev_s *dev = (FAR struct cxd56_dev_s *)lower;
 
-  audinfo("cxd56_pause\n");
-
   if (dev->state == CXD56_DEV_STATE_STARTED)
     {
       dev->state = CXD56_DEV_STATE_PAUSED;
 
       ret = cxd56_stop_dma(dev);
-      if (ret != CXD56_AUDIO_ECODE_OK)
+      if (ret != OK)
         {
-          auderr("Could not stop DMA transfer. (%d)\n", ret);
+          auderr("ERROR: Could not stop DMA transfer (%d)\n", ret);
+          return ret;
         }
     }
-  return ret;
+
+  return OK;
 }
 
 /****************************************************************************
@@ -1809,11 +1843,9 @@ static int cxd56_resume(FAR struct audio_lowerhalf_s *lower,
 static int cxd56_resume(FAR struct audio_lowerhalf_s *lower)
 #endif
 {
-  int ret = OK;
+  int ret;
   FAR struct cxd56_dev_s *dev = (FAR struct cxd56_dev_s *)lower;
 
-  audinfo("cxd56_resume\n");
-
   if (dev->state == CXD56_DEV_STATE_PAUSED)
     {
       dev->state = CXD56_DEV_STATE_STARTED;
@@ -1821,12 +1853,14 @@ static int cxd56_resume(FAR struct audio_lowerhalf_s *lower)
       board_external_amp_mute_control(false);
 
       ret = cxd56_start_dma(dev);
-      if (ret != CXD56_AUDIO_ECODE_OK)
+      if (ret != OK)
         {
-          audinfo("Could not resume DMA transfer. (%d)\n", ret);
+          auderr("ERROR: Could not resume DMA transfer (%d)\n", ret);
+          return ret;
         }
     }
-  return ret;
+
+  return OK;
 }
 #endif /* CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME */
 
@@ -1844,7 +1878,6 @@ static int cxd56_release(FAR struct audio_lowerhalf_s *lower,
 static int cxd56_release(FAR struct audio_lowerhalf_s *lower)
 #endif
 {
-  audinfo("cxd56_release\n");
   return OK;
 }
 
@@ -1862,7 +1895,6 @@ static int cxd56_reserve(FAR struct audio_lowerhalf_s *lower,
 static int cxd56_reserve(FAR struct audio_lowerhalf_s *lower)
 #endif
 {
-  audinfo("cxd56_reserve\n");
   return OK;
 }
 
@@ -1891,7 +1923,7 @@ static int cxd56_start_dma(FAR struct cxd56_dev_s *dev)
   int timeout;
   uint32_t addr;
   uint32_t size;
-  CXD56_AUDIO_ECODE ret = CXD56_AUDIO_ECODE_OK;
+  int ret = OK;
 
   cxd56_take_sem(&dev->pendsem);
   if (dq_count(&dev->pendingq) == 0)
@@ -1902,8 +1934,13 @@ static int cxd56_start_dma(FAR struct cxd56_dev_s *dev)
 
       msg.msg_id = AUDIO_MSG_STOP;
       msg.u.data = 0;
-      (void)nxmq_send(dev->mq, (FAR const char *)&msg,
+      ret = nxmq_send(dev->mq, (FAR const char *)&msg,
                       sizeof(msg), CONFIG_CXD56_MSG_PRIO);
+      if (ret != OK)
+        {
+          auderr("ERROR: nxmq_send start DMA failed (%d)\n", ret);
+          goto exit;
+        }
     }
   else
     {
@@ -1915,7 +1952,7 @@ static int cxd56_start_dma(FAR struct cxd56_dev_s *dev)
             {
               /* DMA busy, will retry next time */
 
-              ret = CXD56_AUDIO_ECODE_OK;
+              ret = OK;
               goto exit;
             }
 
@@ -1968,7 +2005,7 @@ static int cxd56_start_dma(FAR struct cxd56_dev_s *dev)
 
                   if (timeout == CXD56_DMA_TIMEOUT)
                     {
-                      ret = CXD56_AUDIO_ECODE_DMA_SMP_TIMEOUT;
+                      ret = -ETIME;
                       goto exit;
                     }
 
@@ -2061,7 +2098,6 @@ static int cxd56_enqueuebuffer(FAR struct audio_lowerhalf_s *lower,
 {
   FAR struct cxd56_dev_s *priv = (FAR struct cxd56_dev_s *)lower;
   struct audio_msg_s msg;
-  int                ret = OK;
 
   cxd56_take_sem(&priv->pendsem);
   dq_push(&priv->pendingq, &apb->dq_entry);
@@ -2069,13 +2105,21 @@ static int cxd56_enqueuebuffer(FAR struct audio_lowerhalf_s *lower,
 
   if (priv->mq != NULL)
     {
+      int ret;
+
       msg.msg_id = AUDIO_MSG_ENQUEUE;
       msg.u.data = 0;
-      (void)nxmq_send(priv->mq, (FAR const char *) &msg,
+
+      ret = nxmq_send(priv->mq, (FAR const char *) &msg,
                       sizeof(msg), CONFIG_CXD56_MSG_PRIO);
+      if (ret != OK)
+        {
+          auderr("ERROR: nxmq_send to enqueue failed (%d)\n", ret);
+          return ret;
+        }
     }
 
-  return ret;
+  return OK;
 }
 
 /****************************************************************************
@@ -2088,7 +2132,6 @@ static int cxd56_enqueuebuffer(FAR struct audio_lowerhalf_s *lower,
 static int cxd56_cancelbuffer(FAR struct audio_lowerhalf_s *lower,
                  FAR struct ap_buffer_s *apb)
 {
-  audinfo("cxd56_cancelbuffer\n");
   return OK;
 }
 
@@ -2106,8 +2149,6 @@ static int cxd56_ioctl(FAR struct audio_lowerhalf_s *lower, int cmd,
   FAR struct ap_buffer_info_s *bufinfo;
 #endif
 
-  audinfo("cxd56_ioctl\n");
-
   /* Handle ioctl commands from the upper-half driver */
 
   switch (cmd)
@@ -2144,10 +2185,10 @@ static int cxd56_ioctl(FAR struct audio_lowerhalf_s *lower, int cmd,
 static void *cxd56_workerthread(pthread_addr_t pvarg)
 {
   FAR struct cxd56_dev_s *priv = (struct cxd56_dev_s *)pvarg;
-  struct audio_msg_s     msg;
-  unsigned int           prio;
-  int                    ret;
-  int                    size;
+  struct audio_msg_s msg;
+  unsigned int prio;
+  int size;
+  int ret;
 
   audinfo("Workerthread started.\n");
 
@@ -2162,9 +2203,9 @@ static void *cxd56_workerthread(pthread_addr_t pvarg)
   /* Initial buffering */
 
   ret = cxd56_start_dma(priv);
-  if (ret != CXD56_AUDIO_ECODE_OK)
+  if (ret != OK)
     {
-      auderr("Could not start DMA transfer. (%d)\n", ret);
+      auderr("ERROR: Could not start DMA transfer (%d)\n", ret);
       priv->running = false;
     }
 
@@ -2188,9 +2229,10 @@ static void *cxd56_workerthread(pthread_addr_t pvarg)
             ret = cxd56_stop_dma(priv);
             if (ret != CXD56_AUDIO_ECODE_OK)
               {
-                auderr("Could not stop DMA transfer. (%d)\n", ret);
+                auderr("ERROR: Could not stop DMA transfer (%d)\n", ret);
                 priv->running = false;
               }
+
             priv->state = CXD56_DEV_STATE_STOPPED;
             priv->running = false;
             audinfo("Workerthread stopped.\n");
@@ -2230,10 +2272,10 @@ static int cxd56_init_worker(FAR struct audio_lowerhalf_s *dev)
 {
   FAR struct cxd56_dev_s *priv = (FAR struct cxd56_dev_s *)dev;
   struct sched_param sparam;
-  struct mq_attr     m_attr;
-  pthread_attr_t     t_attr;
-  void               *value;
-  int                ret = CXD56_AUDIO_ECODE_OK;
+  struct mq_attr m_attr;
+  pthread_attr_t t_attr;
+  void *value;
+  int ret;
 
   snprintf(priv->mqname, sizeof(priv->mqname), "/tmp/%X", priv);
 
@@ -2245,9 +2287,8 @@ static int cxd56_init_worker(FAR struct audio_lowerhalf_s *dev)
   priv->mq = mq_open(priv->mqname, O_RDWR | O_CREAT, 0644, &m_attr);
   if (priv->mq == NULL)
     {
-      auderr("Could not allocate message queue.\n");
-      ret = -ENOMEM;
-      goto error;
+      auderr("ERROR: Could not allocate message queue.\n");
+      return -ENOMEM;
     }
 
   /* Join any old worker thread we had created to prevent a memory leak */
@@ -2267,16 +2308,13 @@ static int cxd56_init_worker(FAR struct audio_lowerhalf_s *dev)
                        (pthread_addr_t)priv);
   if (ret != OK)
     {
-      auderr("pthread_create failed. (%d)\n", ret);
-      goto error;
-    }
-  else
-    {
-      pthread_setname_np(priv->threadid, "cxd56");
+      auderr("ERROR: pthread_create failed (%d)\n", ret);
+      return ret;
     }
 
-error:
-  return ret;
+  pthread_setname_np(priv->threadid, "cxd56");
+
+  return OK;
 }
 
 /****************************************************************************


[incubator-nuttx] 01/06: libc: audio: nxstyle fixes

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

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

commit 76c47f6b21307ffca3a6110a57d1fde43c07ebb9
Author: Alin Jerpelea <al...@sony.com>
AuthorDate: Tue Apr 21 10:55:41 2020 +0200

    libc: audio: nxstyle fixes
    
    This change is needed to be able to fix the warnings on the audio core
    and includes the propagation of the fix in the audio.
    
    Signed-off-by: Alin Jerpelea <al...@sony.com>
---
 audio/audio.c                | 6 +++---
 audio/audio_comp.c           | 2 +-
 include/nuttx/audio/audio.h  | 4 ++--
 libs/libc/audio/lib_buffer.c | 6 +++---
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/audio/audio.c b/audio/audio.c
index 716a1ac..c19973c 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -556,8 +556,8 @@ static int audio_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
             {
               /* Perform a simple apb_free operation */
 
-              DEBUGASSERT(bufdesc->u.pBuffer != NULL);
-              apb_free(bufdesc->u.pBuffer);
+              DEBUGASSERT(bufdesc->u.buffer != NULL);
+              apb_free(bufdesc->u.buffer);
               ret = sizeof(struct audio_buf_desc_s);
             }
         }
@@ -575,7 +575,7 @@ static int audio_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
           DEBUGASSERT(lower->ops->enqueuebuffer != NULL);
 
           bufdesc = (FAR struct audio_buf_desc_s *) arg;
-          ret = lower->ops->enqueuebuffer(lower, bufdesc->u.pBuffer);
+          ret = lower->ops->enqueuebuffer(lower, bufdesc->u.buffer);
         }
         break;
 
diff --git a/audio/audio_comp.c b/audio/audio_comp.c
index 494de48..5f9b3e2 100644
--- a/audio/audio_comp.c
+++ b/audio/audio_comp.c
@@ -597,7 +597,7 @@ static int audio_comp_freebuffer(FAR struct audio_lowerhalf_s *dev,
 
   if (ret == -ENOTTY)
     {
-      apb_free(bufdesc->u.pBuffer);
+      apb_free(bufdesc->u.buffer);
       ret = sizeof(*bufdesc);
     }
 
diff --git a/include/nuttx/audio/audio.h b/include/nuttx/audio/audio.h
index 5be6431..3a364f7 100644
--- a/include/nuttx/audio/audio.h
+++ b/include/nuttx/audio/audio.h
@@ -465,8 +465,8 @@ struct audio_buf_desc_s
   uint16_t            numbytes;           /* Number of bytes to allocate */
   union
   {
-    FAR struct ap_buffer_s  *pBuffer;     /* Buffer to free / enqueue */
-    FAR struct ap_buffer_s  **ppBuffer;   /* Pointer to receive allocated buffer */
+    FAR struct ap_buffer_s  *buffer;     /* Buffer to free / enqueue */
+    FAR struct ap_buffer_s  **pbuffer;   /* Pointer to receive allocated buffer */
   } u;
 };
 
diff --git a/libs/libc/audio/lib_buffer.c b/libs/libc/audio/lib_buffer.c
index 88fd735..712b321 100644
--- a/libs/libc/audio/lib_buffer.c
+++ b/libs/libc/audio/lib_buffer.c
@@ -104,17 +104,17 @@ int apb_alloc(FAR struct audio_buf_desc_s *bufdesc)
   int                 ret;
   struct ap_buffer_s  *apb;
 
-  DEBUGASSERT(bufdesc->u.ppBuffer != NULL);
+  DEBUGASSERT(bufdesc->u.pbuffer != NULL);
 
   /* Perform a user mode allocation */
 
   bufsize = sizeof(struct ap_buffer_s) + bufdesc->numbytes;
   apb = lib_umalloc(bufsize);
-  *bufdesc->u.ppBuffer = apb;
+  *bufdesc->u.pbuffer = apb;
 
   /* Test if the allocation was successful or not */
 
-  if (*bufdesc->u.ppBuffer == NULL)
+  if (*bufdesc->u.pbuffer == NULL)
     {
       ret = -ENOMEM;
     }


[incubator-nuttx] 04/06: cxd56: add support for pause and resume

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

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

commit 36e756a915aebe1ccb96d44b098710a9c9b89f15
Author: Tobias Johansson <to...@sony.com>
AuthorDate: Fri Apr 17 15:54:24 2020 +0200

    cxd56: add support for pause and resume
    
    Implements pause and resume functionality
---
 drivers/audio/cxd56.c | 87 +++++++++++++++++++++++++++++++++++++--------------
 drivers/audio/cxd56.h |  5 ++-
 2 files changed, 65 insertions(+), 27 deletions(-)

diff --git a/drivers/audio/cxd56.c b/drivers/audio/cxd56.c
index 579cc24..25d7f7b 100644
--- a/drivers/audio/cxd56.c
+++ b/drivers/audio/cxd56.c
@@ -929,6 +929,8 @@ static void cxd56_dma_int_handler(void)
 
       if (dev->mq != NULL)
         {
+          /* Request more data */
+
           msg.msg_id = AUDIO_MSG_DATA_REQUEST;
           msg.u.data = 0;
           (void)nxmq_send(dev->mq, (FAR const char *) &msg,
@@ -937,12 +939,15 @@ static void cxd56_dma_int_handler(void)
 
       if (ecode == CXD56_AUDIO_ECODE_DMA_TRANS)
         {
-          /* End of data */
+          /* Notify end of data */
 
-          msg.msg_id = AUDIO_MSG_STOP;
-          msg.u.data = 0;
-          (void)nxmq_send(dev->mq, (FAR const char *)&msg,
-                          sizeof(msg), CONFIG_CXD56_MSG_PRIO);
+          if (dev->state != CXD56_DEV_STATE_PAUSED)
+            {
+              msg.msg_id = AUDIO_MSG_STOP;
+              msg.u.data = 0;
+              (void)nxmq_send(dev->mq, (FAR const char *)&msg,
+                              sizeof(msg), CONFIG_CXD56_MSG_PRIO);
+            }
         }
     }
 }
@@ -1283,21 +1288,17 @@ static uint32_t cxd56_power_on(FAR struct cxd56_dev_s *dev)
       write_reg(REG_AC_DSR_RATE, 1);
       write_reg(REG_AC_DIGSFT,   1);
 
-#if defined(CONFIG_CXD56_I2S0) || defined(CONFIG_CXD56_I2S1)
       /* Clear interrupt status of bck_err */
 
       write_reg(REG_INT_M_I2S1_BCL_ERR1, 0);
       write_reg(REG_INT_M_I2S1_BCL_ERR2, 0);
 
       cxd56_power_on_i2s1(dev);
-#endif /* defined(CONFIG_CXD56_I2S0) || defined(CONFIG_CXD56_I2S1) */
 
-#ifdef CONFIG_CXD56_I2S0
       /* Enable I2S data input and output of SRC1 */
 
       write_reg(REG_AC_SDIN1_EN, 1);
       write_reg(REG_AC_SDOUT1_EN, 1);
-#endif /* CONFIG_CXD56_I2S0 */
 
       /* Enable BCK, LRCK output if master (1). */
 
@@ -1347,7 +1348,6 @@ static uint32_t cxd56_power_on(FAR struct cxd56_dev_s *dev)
     }
 
   g_codec_start_count++;
-  dev->state = CXD56_DEV_STATE_STOPPED;
 
   return CXD56_AUDIO_ECODE_OK;
 }
@@ -1639,6 +1639,8 @@ static int cxd56_configure(FAR struct audio_lowerhalf_s *lower,
             auderr("Power on analog output failed- (%d)\n", ret);
             goto error;
           }
+
+        priv->state = CXD56_DEV_STATE_STOPPED;
       }
       break;
     }
@@ -1680,8 +1682,6 @@ static int cxd56_start(FAR struct audio_lowerhalf_s *lower)
       goto error;
     }
 
-  priv->state = CXD56_DEV_STATE_STARTING;
-
 error:
   return ret;
 }
@@ -1717,8 +1717,6 @@ static int cxd56_stop_dma(FAR struct cxd56_dev_s *priv)
           write_reg(REG_AC_PDN_SMSTR, 1);
           as_aca_control(CXD56_ACA_CTL_POWER_OFF_OUTPUT, (uint32_t)NULL);
         }
-
-      priv->state = CXD56_DEV_STATE_STOPPED;
     }
 
   return ret;
@@ -1743,8 +1741,6 @@ static int cxd56_stop(FAR struct audio_lowerhalf_s *lower)
       goto error;
     }
 
-  priv->state = CXD56_DEV_STATE_STOPPING;
-
   msg.msg_id = AUDIO_MSG_STOP;
   msg.u.data = 0;
   (void)nxmq_send(priv->mq, (FAR const char *)&msg,
@@ -1774,8 +1770,22 @@ static int cxd56_pause(FAR struct audio_lowerhalf_s *lower,
 static int cxd56_pause(FAR struct audio_lowerhalf_s *lower)
 #endif
 {
+  int ret = OK;
+  FAR struct cxd56_dev_s *dev = (FAR struct cxd56_dev_s *)lower;
+
   audinfo("cxd56_pause\n");
-  return OK;
+
+  if (dev->state == CXD56_DEV_STATE_STARTED)
+    {
+      dev->state = CXD56_DEV_STATE_PAUSED;
+
+      ret = cxd56_stop_dma(dev);
+      if (ret != CXD56_AUDIO_ECODE_OK)
+        {
+          auderr("Could not stop DMA transfer. (%d)\n", ret);
+        }
+    }
+  return ret;
 }
 
 /****************************************************************************
@@ -1792,8 +1802,24 @@ static int cxd56_resume(FAR struct audio_lowerhalf_s *lower,
 static int cxd56_resume(FAR struct audio_lowerhalf_s *lower)
 #endif
 {
+  int ret = OK;
+  FAR struct cxd56_dev_s *dev = (FAR struct cxd56_dev_s *)lower;
+
   audinfo("cxd56_resume\n");
-  return OK;
+
+  if (dev->state == CXD56_DEV_STATE_PAUSED)
+    {
+      dev->state = CXD56_DEV_STATE_STARTED;
+      cxd56_power_on_analog_output(dev);
+      board_external_amp_mute_control(false);
+
+      ret = cxd56_start_dma(dev);
+      if (ret != CXD56_AUDIO_ECODE_OK)
+        {
+          audinfo("Could not resume DMA transfer. (%d)\n", ret);
+        }
+    }
+  return ret;
 }
 #endif /* CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME */
 
@@ -1858,14 +1884,19 @@ static int cxd56_start_dma(FAR struct cxd56_dev_s *dev)
   int timeout;
   uint32_t addr;
   uint32_t size;
-  static int bufcount = 0;
   CXD56_AUDIO_ECODE ret = CXD56_AUDIO_ECODE_OK;
 
   cxd56_take_sem(&dev->pendsem);
   if (dq_count(&dev->pendingq) == 0)
     {
-    audinfo("Pending queue empty! Played %d buffers.\n", bufcount);
-    dev->state = CXD56_DEV_STATE_STOPPING;
+      /* Pending queue empty, nothing to do */
+
+      struct audio_msg_s msg;
+
+      msg.msg_id = AUDIO_MSG_STOP;
+      msg.u.data = 0;
+      (void)nxmq_send(dev->mq, (FAR const char *)&msg,
+                      sizeof(msg), CONFIG_CXD56_MSG_PRIO);
     }
   else
     {
@@ -2003,7 +2034,6 @@ static int cxd56_start_dma(FAR struct cxd56_dev_s *dev)
           dq_pop(&dev->pendingq);
           dq_push(&dev->runningq, &apb->dq_entry);
           dev->state = CXD56_DEV_STATE_STARTED;
-          bufcount++;
         }
     }
 
@@ -2148,13 +2178,22 @@ static void *cxd56_workerthread(pthread_addr_t pvarg)
       switch (msg.msg_id)
         {
           case AUDIO_MSG_STOP:
-            cxd56_stop_dma(priv);
+            ret = cxd56_stop_dma(priv);
+            if (ret != CXD56_AUDIO_ECODE_OK)
+              {
+                auderr("Could not stop DMA transfer. (%d)\n", ret);
+                priv->running = false;
+              }
+            priv->state = CXD56_DEV_STATE_STOPPED;
             priv->running = false;
             audinfo("Workerthread stopped.\n");
             break;
 
           case AUDIO_MSG_DATA_REQUEST:
-            cxd56_start_dma(priv);
+            if (priv->state == CXD56_DEV_STATE_STARTED)
+            {
+                cxd56_start_dma(priv);
+            }
             break;
 
           case AUDIO_MSG_ENQUEUE:
diff --git a/drivers/audio/cxd56.h b/drivers/audio/cxd56.h
index 1012df6..8987efe 100644
--- a/drivers/audio/cxd56.h
+++ b/drivers/audio/cxd56.h
@@ -205,10 +205,9 @@ typedef enum cxd56_dmahandle_e cxd56_dmahandle_t;
 enum cxd56_devstate_e
 {
   CXD56_DEV_STATE_OFF,
-  CXD56_DEV_STATE_STOPPED,
-  CXD56_DEV_STATE_STARTING,
+  CXD56_DEV_STATE_PAUSED,
   CXD56_DEV_STATE_STARTED,
-  CXD56_DEV_STATE_STOPPING,
+  CXD56_DEV_STATE_STOPPED
 };
 
 struct cxd56_dev_s