mirror of
https://github.com/apache/nuttx.git
synced 2026-05-23 23:28:29 +08:00
audio: nxstyle fixes for core and drivers
nxstyle fixes for the audio core and drivers Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
This commit is contained in:
+70
-41
@@ -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 */
|
||||
|
||||
+4
-2
@@ -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
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
+32
-23
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
+40
-19
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+35
-22
@@ -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
|
||||
|
||||
|
||||
@@ -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 */
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -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);
|
||||
|
||||
+20
-12
@@ -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)
|
||||
{
|
||||
|
||||
+182
-125
File diff suppressed because it is too large
Load Diff
+17
-17
@@ -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" */
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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) */
|
||||
|
||||
+11
-7
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+60
-30
@@ -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
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
+76
-49
@@ -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
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Configuration ************************************************************
|
||||
*
|
||||
* CONFIG_AUDIO_NULL - Enabled NULL audio device support
|
||||
|
||||
@@ -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
|
||||
|
||||
+23
-12
@@ -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
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -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
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user