diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-07-23 12:21:04 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-07-23 12:21:04 -0600 |
commit | 6d699ac12bf501de4585b3c9220c6d2118515320 (patch) | |
tree | f5457ece0c693eddac5e639d215a6e87deaad861 | |
parent | 3ba884fbe77421aa372827a31034f00c42407989 (diff) | |
download | nuttx-6d699ac12bf501de4585b3c9220c6d2118515320.tar.gz nuttx-6d699ac12bf501de4585b3c9220c6d2118515320.tar.bz2 nuttx-6d699ac12bf501de4585b3c9220c6d2118515320.zip |
Add ioctls so that PCM decoder can configure the driver bitrate, num channels, and sample width
-rw-r--r-- | nuttx/audio/pcm_decode.c | 32 | ||||
-rw-r--r-- | nuttx/drivers/audio/audio_null.c | 32 | ||||
-rw-r--r-- | nuttx/drivers/audio/wm8904.c | 37 | ||||
-rw-r--r-- | nuttx/include/nuttx/audio/audio.h | 10 |
4 files changed, 100 insertions, 11 deletions
diff --git a/nuttx/audio/pcm_decode.c b/nuttx/audio/pcm_decode.c index d50fab198..83c623c02 100644 --- a/nuttx/audio/pcm_decode.c +++ b/nuttx/audio/pcm_decode.c @@ -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 */ diff --git a/nuttx/drivers/audio/audio_null.c b/nuttx/drivers/audio/audio_null.c index 92caccc1b..b9495d4f1 100644 --- a/nuttx/drivers/audio/audio_null.c +++ b/nuttx/drivers/audio/audio_null.c @@ -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; } diff --git a/nuttx/drivers/audio/wm8904.c b/nuttx/drivers/audio/wm8904.c index 2a85505d8..6b496844c 100644 --- a/nuttx/drivers/audio/wm8904.c +++ b/nuttx/drivers/audio/wm8904.c @@ -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; } diff --git a/nuttx/include/nuttx/audio/audio.h b/nuttx/include/nuttx/audio/audio.h index 162db9ad3..4e813f1f9 100644 --- a/nuttx/include/nuttx/audio/audio.h +++ b/nuttx/include/nuttx/audio/audio.h @@ -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/ |