Skip to content
2 changes: 2 additions & 0 deletions audio/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,7 @@ static int audio_ioctl(FAR struct file *filep, int cmd, unsigned long 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);
Expand Down Expand Up @@ -1342,6 +1343,7 @@ static int audio_poll(FAR struct file *filep,
/* This is a request to tear down the poll. */

FAR struct pollfd **slot = (FAR struct pollfd **)fds->priv;

*slot = NULL;
fds->priv = NULL;
}
Expand Down
3 changes: 3 additions & 0 deletions audio/audio_comp.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ static int audio_comp_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
FAR struct audio_caps_s dup = *caps;

int tmp = lower[i]->ops->getcaps(lower[i], type, &dup);

if (tmp == -ENOTTY)
{
continue;
Expand Down Expand Up @@ -294,6 +295,7 @@ static int audio_comp_shutdown(FAR struct audio_lowerhalf_s *dev)
if (lower[i]->ops->shutdown)
{
int tmp = lower[i]->ops->shutdown(lower[i]);

if (tmp == -ENOTTY)
{
continue;
Expand Down Expand Up @@ -680,6 +682,7 @@ static int audio_comp_ioctl(FAR struct audio_lowerhalf_s *dev, int cmd,
if (lower[i]->ops->ioctl)
{
int tmp = lower[i]->ops->ioctl(lower[i], cmd, arg);

if (tmp == -ENOTTY)
{
continue;
Expand Down
4 changes: 3 additions & 1 deletion audio/pcm_decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ static void pcm_subsample_configure(FAR struct pcm_decode_s *priv,
* next audio buffer that we receive.
*/

priv->subsample = subsample;
priv->subsample = subsample;
}
}
#endif
Expand Down Expand Up @@ -1089,9 +1089,11 @@ static int pcm_enqueuebuffer(FAR struct audio_lowerhalf_s *dev,
#ifndef CONFIG_AUDIO_FORMAT_RAW
ssize_t headersize = pcm_parsewav(priv, &apb->samp[apb->curbyte],
bytesleft);

if (headersize > 0)
{
struct audio_caps_s caps;

memset(&caps, 0, sizeof(caps));

/* Configure the lower level for the number of channels, bitrate,
Expand Down
76 changes: 50 additions & 26 deletions drivers/audio/audio_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,22 +162,22 @@ static int audio_dma_getcaps(struct audio_lowerhalf_s *dev, int type,

if (caps->ac_subtype == AUDIO_TYPE_QUERY)
{
/* We don't decode any formats! Only something above us in
* the audio stream can perform decoding on our behalf.
*/
/* We don't decode any formats! Only something above us in
* the audio stream can perform decoding on our behalf.
*/

/* The types of audio units we implement */
/* The types of audio units we implement */

if (audio_dma->playback)
if (audio_dma->playback)
{
caps->ac_controls.b[0] = AUDIO_TYPE_OUTPUT;
}
else
else
{
caps->ac_controls.b[0] = AUDIO_TYPE_INPUT;
}

caps->ac_format.hw = 1 << (AUDIO_FMT_PCM - 1);
caps->ac_format.hw = 1 << (AUDIO_FMT_PCM - 1);
}

caps->ac_controls.b[0] = AUDIO_SUBFMT_END;
Expand All @@ -194,11 +194,11 @@ static int audio_dma_getcaps(struct audio_lowerhalf_s *dev, int type,
{
/* Report the Sample rates we support */

caps->ac_controls.hw[0] = AUDIO_SAMP_RATE_DEF_ALL;
caps->ac_controls.hw[0] = AUDIO_SAMP_RATE_DEF_ALL;
}

break;
}
}

/* Return the length of the audio_caps_s struct for validation of
* proper Audio device type.
Expand Down Expand Up @@ -233,9 +233,14 @@ static int audio_dma_configure(struct audio_lowerhalf_s *dev,
memset(&cfg, 0, sizeof(struct dma_config_s));
cfg.direction = DMA_MEM_TO_DEV;
if (audio_dma->fifo_width)
cfg.dst_width = audio_dma->fifo_width;
{
cfg.dst_width = audio_dma->fifo_width;
}
else
cfg.dst_width = caps->ac_controls.b[2] / 8;
{
cfg.dst_width = caps->ac_controls.b[2] / 8;
}

ret = DMA_CONFIG(audio_dma->chan, &cfg);
}
break;
Expand All @@ -245,9 +250,14 @@ static int audio_dma_configure(struct audio_lowerhalf_s *dev,
memset(&cfg, 0, sizeof(struct dma_config_s));
cfg.direction = DMA_DEV_TO_MEM;
if (audio_dma->fifo_width)
cfg.src_width = audio_dma->fifo_width;
{
cfg.src_width = audio_dma->fifo_width;
}
else
cfg.src_width = caps->ac_controls.b[2] / 8;
{
cfg.src_width = caps->ac_controls.b[2] / 8;
}

ret = DMA_CONFIG(audio_dma->chan, &cfg);
}
break;
Expand Down Expand Up @@ -382,9 +392,13 @@ static int audio_dma_allocbuffer(struct audio_lowerhalf_s *dev,
}

if (audio_dma->playback)
audio_dma->src_addr = up_addrenv_va_to_pa(audio_dma->alloc_addr);
{
audio_dma->src_addr = up_addrenv_va_to_pa(audio_dma->alloc_addr);
}
else
audio_dma->dst_addr = up_addrenv_va_to_pa(audio_dma->alloc_addr);
{
audio_dma->dst_addr = up_addrenv_va_to_pa(audio_dma->alloc_addr);
}
}

apb = kumm_zalloc(sizeof(struct ap_buffer_s));
Expand Down Expand Up @@ -438,8 +452,10 @@ static int audio_dma_enqueuebuffer(struct audio_lowerhalf_s *dev,
irqstate_t flags;

if (audio_dma->playback)
up_clean_dcache((uintptr_t)apb->samp,
(uintptr_t)apb->samp + apb->nbytes);
{
up_clean_dcache((uintptr_t)apb->samp,
(uintptr_t)apb->samp + apb->nbytes);
}

apb->flags |= AUDIO_APB_OUTPUT_ENQUEUED;

Expand Down Expand Up @@ -525,18 +541,22 @@ static void audio_dma_callback(struct dma_chan_s *chan,
}

if (!audio_dma->playback)
up_invalidate_dcache((uintptr_t)apb->samp,
(uintptr_t)apb->samp + apb->nbytes);
{
up_invalidate_dcache((uintptr_t)apb->samp,
(uintptr_t)apb->samp + apb->nbytes);
}

if ((apb->flags & AUDIO_APB_FINAL) != 0)
final = true;
{
final = true;
}

#ifdef CONFIG_AUDIO_MULTI_SESSION
audio_dma->dev.upper(audio_dma->dev.priv, AUDIO_CALLBACK_DEQUEUE,
apb, OK, NULL);
audio_dma->dev.upper(audio_dma->dev.priv, AUDIO_CALLBACK_DEQUEUE,
apb, OK, NULL);
#else
audio_dma->dev.upper(audio_dma->dev.priv, AUDIO_CALLBACK_DEQUEUE,
apb, OK);
audio_dma->dev.upper(audio_dma->dev.priv, AUDIO_CALLBACK_DEQUEUE,
apb, OK);
#endif
if (final)
{
Expand Down Expand Up @@ -589,9 +609,13 @@ struct audio_lowerhalf_s *audio_dma_initialize(struct dma_dev_s *dma_dev,
audio_dma->fifo_width = fifo_width;

if (audio_dma->playback)
audio_dma->dst_addr = up_addrenv_va_to_pa((FAR void *)fifo_addr);
{
audio_dma->dst_addr = up_addrenv_va_to_pa((FAR void *)fifo_addr);
}
else
audio_dma->src_addr = up_addrenv_va_to_pa((FAR void *)fifo_addr);
{
audio_dma->src_addr = up_addrenv_va_to_pa((FAR void *)fifo_addr);
}

audio_dma->buffer_size = CONFIG_AUDIO_BUFFER_NUMBYTES;
audio_dma->buffer_num = CONFIG_AUDIO_NUM_BUFFERS;
Expand Down
4 changes: 4 additions & 0 deletions drivers/audio/audio_fake.c
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,7 @@ static int audio_fake_configure(FAR struct audio_lowerhalf_s *dev,
{
FAR struct audio_fake_s *priv = (FAR struct audio_fake_s *)dev;
int ret;

audinfo("ac_type: %d\n", caps->ac_type);

if (priv->mqname[0] == '\0')
Expand Down Expand Up @@ -901,6 +902,7 @@ static int audio_fake_pause(FAR struct audio_lowerhalf_s *dev)
#endif
{
FAR struct audio_fake_s *priv = (FAR struct audio_fake_s *)dev;

audinfo("%s pause\n", priv->dev_params->dev_name);
return OK;
}
Expand All @@ -922,6 +924,7 @@ static int audio_fake_resume(FAR struct audio_lowerhalf_s *dev)
#endif
{
FAR struct audio_fake_s *priv = (FAR struct audio_fake_s *)dev;

audinfo("%s resume\n", priv->dev_params->dev_name);
return OK;
}
Expand Down Expand Up @@ -1048,6 +1051,7 @@ static int audio_fake_reserve(FAR struct audio_lowerhalf_s *dev)
#endif
{
FAR struct audio_fake_s *priv = (FAR struct audio_fake_s *)dev;

priv->terminate = false;
audinfo("%s reserve\n", priv->dev_params->dev_name);
return OK;
Expand Down
44 changes: 22 additions & 22 deletions drivers/audio/audio_i2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,27 +155,27 @@ static int audio_i2s_getcaps(FAR struct audio_lowerhalf_s *dev, int type,

if (caps->ac_subtype == AUDIO_TYPE_QUERY)
{
/* We don't decode any formats! Only something above us in
* the audio stream can perform decoding on our behalf.
*/

/* The types of audio units we implement */

if (audio_i2s->playback)
{
caps->ac_controls.b[0] = AUDIO_TYPE_OUTPUT;
}
else
{
caps->ac_controls.b[0] = AUDIO_TYPE_INPUT;
}

caps->ac_format.hw = 1 << (AUDIO_FMT_PCM - 1);
break;
/* We don't decode any formats! Only something above us in
* the audio stream can perform decoding on our behalf.
*/

/* The types of audio units we implement */

if (audio_i2s->playback)
{
caps->ac_controls.b[0] = AUDIO_TYPE_OUTPUT;
}
else
{
caps->ac_controls.b[0] = AUDIO_TYPE_INPUT;
}

caps->ac_format.hw = 1 << (AUDIO_FMT_PCM - 1);
break;
}

caps->ac_controls.b[0] = AUDIO_SUBFMT_END;
break;
caps->ac_controls.b[0] = AUDIO_SUBFMT_END;
break;

/* Provide capabilities of our OUTPUT unit */

Expand All @@ -186,11 +186,11 @@ static int audio_i2s_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
{
/* Report the Sample rates we support */

caps->ac_controls.hw[0] = AUDIO_SAMP_RATE_DEF_ALL;
caps->ac_controls.hw[0] = AUDIO_SAMP_RATE_DEF_ALL;

caps->ac_channels = 2;
caps->ac_channels = 2;

break;
break;
}

default:
Expand Down
Loading
Loading