diff --git a/audio/audio.c b/audio/audio.c index c19973c6985..d3e928a4cad 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 5f9b3e2024a..dea07c01578 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 916d7bc0721..c7a63683fff 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 5d1a2b4df1c..2b450bb103f 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 4188bab3ba9..53b032a993b 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 de73b7afd6b..7f19a56dca6 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 6fa9b982281..bd0089dbd8d 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 2d39fe988a7..0443f4d5009 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 fa25915ee92..f7f7289912e 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 c916618cef2..843aec621c1 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 99387970850..7bac43cc608 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 7a8a117a892..c33e8da8211 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 0b47a93d243..95192effff7 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 dc6a0c1b393..1afc486d3ef 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 975be11f461..4166d82746e 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 9a616044f40..1fe6f267333 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 d94eb2c4fbb..fe5fb1c588e 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 3a364f78a9d..82707bac521 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 24e5bb091ff..d789c8339ce 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 9065478c2d4..9d9fd60aa60 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 5a630d6800d..6cdbf4f12f0 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 10db4d9b379..8fd9f7c4e64 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 b921b7d38e2..fe2608106a1 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 dc1488b85d7..db37e54a413 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.