Add ioctls so that PCM decoder can configure the driver bitrate, num channels, and sample width
This commit is contained in:
parent
516b343666
commit
72133f5d95
@ -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 pcm_decode_s *priv = (FAR struct pcm_decode_s *)dev;
|
||||||
FAR struct audio_lowerhalf_s *lower;
|
FAR struct audio_lowerhalf_s *lower;
|
||||||
apb_samp_t bytesleft;
|
apb_samp_t bytesleft;
|
||||||
|
int ret;
|
||||||
|
|
||||||
DEBUGASSERT(priv);
|
DEBUGASSERT(priv);
|
||||||
audvdbg("Received buffer %p, streaming=%d\n", apb, priv->streaming);
|
audvdbg("Received buffer %p, streaming=%d\n", apb, priv->streaming);
|
||||||
|
|
||||||
lower = priv->lower;
|
lower = priv->lower;
|
||||||
DEBUGASSERT(lower && lower->ops->enqueuebuffer);
|
DEBUGASSERT(lower && lower->ops->enqueuebuffer && lower->ops->ioctl);
|
||||||
|
|
||||||
/* Are we streaming yet? */
|
/* Are we streaming yet? */
|
||||||
|
|
||||||
@ -734,8 +735,33 @@ static int pcm_enqueuebuffer(FAR struct audio_lowerhalf_s *dev,
|
|||||||
|
|
||||||
priv->streaming = true;
|
priv->streaming = true;
|
||||||
|
|
||||||
/* Configure the lower level for the number of channels and bitrate */
|
/* Configure the lower level for the number of channels, bitrate,
|
||||||
#warning Missing logic
|
* 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 */
|
/* Bump up the data offset and pass the buffer to the lower level */
|
||||||
|
|
||||||
|
@ -661,18 +661,44 @@ static int null_ioctl(FAR struct audio_lowerhalf_s *dev, int cmd,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
case AUDIOIOC_HWRESET:
|
case AUDIOIOC_HWRESET:
|
||||||
|
{
|
||||||
|
audvdbg("AUDIOIOC_HWRESET:\n");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Report our preferred buffer size and quantity */
|
/* Report our preferred buffer size and quantity */
|
||||||
|
|
||||||
#ifdef CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS
|
#ifdef CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS
|
||||||
case AUDIOIOC_GETBUFFERINFO:
|
case AUDIOIOC_GETBUFFERINFO:
|
||||||
bufinfo = (FAR struct ap_buffer_info_s *) arg;
|
{
|
||||||
bufinfo->buffer_size = CONFIG_AUDIO_NULL_BUFFER_SIZE;
|
audvdbg("AUDIOIOC_GETBUFFERINFO:\n");
|
||||||
bufinfo->nbuffers = CONFIG_AUDIO_NULL_NUM_BUFFERS;
|
bufinfo = (FAR struct ap_buffer_info_s *) arg;
|
||||||
|
bufinfo->buffer_size = CONFIG_AUDIO_NULL_BUFFER_SIZE;
|
||||||
|
bufinfo->nbuffers = CONFIG_AUDIO_NULL_NUM_BUFFERS;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#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:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1448,20 +1448,47 @@ static int wm8904_ioctl(FAR struct audio_lowerhalf_s *dev, int cmd,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
case AUDIOIOC_HWRESET:
|
case AUDIOIOC_HWRESET:
|
||||||
wm8904_reset((FAR struct wm8904_dev_s *)dev);
|
{
|
||||||
|
audvdbg("AUDIOIOC_HWRESET:\n");
|
||||||
|
wm8904_reset((FAR struct wm8904_dev_s *)dev);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Report our preferred buffer size and quantity */
|
/* Report our preferred buffer size and quantity */
|
||||||
|
|
||||||
#ifdef CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS
|
#ifdef CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS
|
||||||
case AUDIOIOC_GETBUFFERINFO:
|
case AUDIOIOC_GETBUFFERINFO:
|
||||||
|
{
|
||||||
bufinfo = (FAR struct ap_buffer_info_s *) arg;
|
audvdbg("AUDIOIOC_GETBUFFERINFO:\n");
|
||||||
bufinfo->buffer_size = CONFIG_WM8904_BUFFER_SIZE;
|
bufinfo = (FAR struct ap_buffer_info_s *) arg;
|
||||||
bufinfo->nbuffers = CONFIG_WM8904_NUM_BUFFERS;
|
bufinfo->buffer_size = CONFIG_WM8904_BUFFER_SIZE;
|
||||||
|
bufinfo->nbuffers = CONFIG_WM8904_NUM_BUFFERS;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#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:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -122,6 +122,16 @@
|
|||||||
#define AUDIOIOC_UNREGISTERMQ _AUDIOIOC(15)
|
#define AUDIOIOC_UNREGISTERMQ _AUDIOIOC(15)
|
||||||
#define AUDIOIOC_HWRESET _AUDIOIOC(16)
|
#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 *******************************************************/
|
/* Audio Device Types *******************************************************/
|
||||||
/* The NuttX audio interface support different types of audio devices for
|
/* The NuttX audio interface support different types of audio devices for
|
||||||
* input, output, synthesis, and manupulation of audio data. A given driver/
|
* input, output, synthesis, and manupulation of audio data. A given driver/
|
||||||
|
Loading…
Reference in New Issue
Block a user