Add ioctls so that PCM decoder can configure the driver bitrate, num channels, and sample width

This commit is contained in:
Gregory Nutt 2014-07-23 12:21:04 -06:00
parent 516b343666
commit 72133f5d95
4 changed files with 100 additions and 11 deletions

View File

@ -695,12 +695,13 @@ static int pcm_enqueuebuffer(FAR struct audio_lowerhalf_s *dev,
FAR struct pcm_decode_s *priv = (FAR struct pcm_decode_s *)dev;
FAR struct audio_lowerhalf_s *lower;
apb_samp_t bytesleft;
int ret;
DEBUGASSERT(priv);
audvdbg("Received buffer %p, streaming=%d\n", apb, priv->streaming);
lower = priv->lower;
DEBUGASSERT(lower && lower->ops->enqueuebuffer);
DEBUGASSERT(lower && lower->ops->enqueuebuffer && lower->ops->ioctl);
/* Are we streaming yet? */
@ -734,8 +735,33 @@ static int pcm_enqueuebuffer(FAR struct audio_lowerhalf_s *dev,
priv->streaming = true;
/* Configure the lower level for the number of channels and bitrate */
#warning Missing logic
/* Configure the lower level for the number of channels, bitrate,
* and sample bitwidth.
*/
ret = lower->ops->ioctl(lower, AUDIOIOC_BITRATE,
(unsigned long)priv->samprate);
if (ret < 0)
{
auddbg("ERROR: Failed to set bit rate: %d\n", ret);
return ret;
}
ret = lower->ops->ioctl(lower, AUDIOIOC_NCHANNELS,
(unsigned long)priv->nchannels);
if (ret < 0)
{
auddbg("ERROR: Failed to set number of channels: %d\n", ret);
return ret;
}
ret = lower->ops->ioctl(lower, AUDIOIOC_SAMPWIDTH,
(unsigned long)priv->bpsamp);
if (ret < 0)
{
auddbg("ERROR: Failed to set sample width: %d\n", ret);
return ret;
}
/* Bump up the data offset and pass the buffer to the lower level */

View File

@ -661,18 +661,44 @@ static int null_ioctl(FAR struct audio_lowerhalf_s *dev, int cmd,
*/
case AUDIOIOC_HWRESET:
{
audvdbg("AUDIOIOC_HWRESET:\n");
}
break;
/* Report our preferred buffer size and quantity */
#ifdef CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS
case AUDIOIOC_GETBUFFERINFO:
bufinfo = (FAR struct ap_buffer_info_s *) arg;
bufinfo->buffer_size = CONFIG_AUDIO_NULL_BUFFER_SIZE;
bufinfo->nbuffers = CONFIG_AUDIO_NULL_NUM_BUFFERS;
{
audvdbg("AUDIOIOC_GETBUFFERINFO:\n");
bufinfo = (FAR struct ap_buffer_info_s *) arg;
bufinfo->buffer_size = CONFIG_AUDIO_NULL_BUFFER_SIZE;
bufinfo->nbuffers = CONFIG_AUDIO_NULL_NUM_BUFFERS;
}
break;
#endif
/* Data stream configuration */
case AUDIOIOC_BITRATE:
{
audvdbg("AUDIOIOC_BITRATE: Set bit rate: %lu\n", arg);
}
break;
case AUDIOIOC_NCHANNELS:
{
audvdbg("AUDIOIOC_NCHANNELS: Set number of channels: %lu\n", arg);
}
break;
case AUDIOIOC_SAMPWIDTH:
{
audvdbg("AUDIOIOC_SAMPWIDTH: Set sample width: %lu\n", arg);
}
break;
default:
break;
}

View File

@ -1448,20 +1448,47 @@ static int wm8904_ioctl(FAR struct audio_lowerhalf_s *dev, int cmd,
*/
case AUDIOIOC_HWRESET:
wm8904_reset((FAR struct wm8904_dev_s *)dev);
{
audvdbg("AUDIOIOC_HWRESET:\n");
wm8904_reset((FAR struct wm8904_dev_s *)dev);
}
break;
/* Report our preferred buffer size and quantity */
#ifdef CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS
case AUDIOIOC_GETBUFFERINFO:
bufinfo = (FAR struct ap_buffer_info_s *) arg;
bufinfo->buffer_size = CONFIG_WM8904_BUFFER_SIZE;
bufinfo->nbuffers = CONFIG_WM8904_NUM_BUFFERS;
{
audvdbg("AUDIOIOC_GETBUFFERINFO:\n");
bufinfo = (FAR struct ap_buffer_info_s *) arg;
bufinfo->buffer_size = CONFIG_WM8904_BUFFER_SIZE;
bufinfo->nbuffers = CONFIG_WM8904_NUM_BUFFERS;
}
break;
#endif
/* Data stream configuration */
case AUDIOIOC_BITRATE:
{
audvdbg("AUDIOIOC_BITRATE: Set bit rate: %lu\n", arg);
#warning Missing logic
}
break;
case AUDIOIOC_NCHANNELS:
{
audvdbg("AUDIOIOC_NCHANNELS: Set number of channels: %lu\n", arg);
#warning Missing logic
}
break;
case AUDIOIOC_SAMPWIDTH:
{
audvdbg("AUDIOIOC_SAMPWIDTH: Set sample width: %lu\n", arg);
#warning Missing logic
}
break;
default:
break;
}

View File

@ -122,6 +122,16 @@
#define AUDIOIOC_UNREGISTERMQ _AUDIOIOC(15)
#define AUDIOIOC_HWRESET _AUDIOIOC(16)
/* Additional ioctl commands support operations between audio decoders
* and low-level audio drivers. This ioctls are not used by the higher
* level audio logic and need be implemented only in low-level audio
* drivers that are driven by a decoder.
*/
#define AUDIOIOC_BITRATE _AUDIOIOC(17)
#define AUDIOIOC_NCHANNELS _AUDIOIOC(18)
#define AUDIOIOC_SAMPWIDTH _AUDIOIOC(19)
/* Audio Device Types *******************************************************/
/* The NuttX audio interface support different types of audio devices for
* input, output, synthesis, and manupulation of audio data. A given driver/