Convert ac_format and ac_controls to unions to make access a little cleaner
This commit is contained in:
parent
dba43a9c75
commit
22f8503d0a
@ -407,7 +407,7 @@ static int pcm_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
|
|||||||
|
|
||||||
if (caps->ac_subtype == AUDIO_TYPE_QUERY)
|
if (caps->ac_subtype == AUDIO_TYPE_QUERY)
|
||||||
{
|
{
|
||||||
*((uint16_t *)&caps->ac_format[0]) = (1 << (AUDIO_FMT_PCM - 1));
|
caps->ac_format.hw = (1 << (AUDIO_FMT_PCM - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
return caps->ac_len;
|
return caps->ac_len;
|
||||||
@ -749,12 +749,12 @@ static int pcm_enqueuebuffer(FAR struct audio_lowerhalf_s *dev,
|
|||||||
|
|
||||||
DEBUGASSERT(priv->samprate < 65535);
|
DEBUGASSERT(priv->samprate < 65535);
|
||||||
|
|
||||||
caps.ac_len = sizeof(struct audio_caps_s);
|
caps.ac_len = sizeof(struct audio_caps_s);
|
||||||
caps.ac_type = AUDIO_TYPE_OUTPUT;
|
caps.ac_type = AUDIO_TYPE_OUTPUT;
|
||||||
caps.ac_channels = priv->nchannels;
|
caps.ac_channels = priv->nchannels;
|
||||||
|
|
||||||
*((uint16_t *)&caps.ac_controls[0]) = (uint16_t)priv->samprate;
|
caps.ac_controls.hw[0] = (uint16_t)priv->samprate;
|
||||||
caps.ac_controls[2] = priv->bpsamp;
|
caps.ac_controls.b[2] = priv->bpsamp;
|
||||||
|
|
||||||
#ifdef CONFIG_AUDIO_MULTI_SESSION
|
#ifdef CONFIG_AUDIO_MULTI_SESSION
|
||||||
ret = lower->ops->configure(lower, priv->session, &caps);
|
ret = lower->ops->configure(lower, priv->session, &caps);
|
||||||
|
@ -186,12 +186,8 @@ static int null_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
|
|||||||
|
|
||||||
/* Fill in the caller's structure based on requested info */
|
/* Fill in the caller's structure based on requested info */
|
||||||
|
|
||||||
caps->ac_format[0] = 0;
|
caps->ac_format.hw = 0;
|
||||||
caps->ac_format[1] = 0;
|
caps->ac_controls.w = 0;
|
||||||
caps->ac_controls[0] = 0;
|
|
||||||
caps->ac_controls[1] = 0;
|
|
||||||
caps->ac_controls[2] = 0;
|
|
||||||
caps->ac_controls[3] = 0;
|
|
||||||
|
|
||||||
switch (caps->ac_type)
|
switch (caps->ac_type)
|
||||||
{
|
{
|
||||||
@ -214,19 +210,19 @@ static int null_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
|
|||||||
|
|
||||||
/* The types of audio units we implement */
|
/* The types of audio units we implement */
|
||||||
|
|
||||||
caps->ac_controls[0] = AUDIO_TYPE_OUTPUT | AUDIO_TYPE_FEATURE |
|
caps->ac_controls.b[0] = AUDIO_TYPE_OUTPUT | AUDIO_TYPE_FEATURE |
|
||||||
AUDIO_TYPE_PROCESSING;
|
AUDIO_TYPE_PROCESSING;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AUDIO_FMT_MIDI:
|
case AUDIO_FMT_MIDI:
|
||||||
/* We only support Format 0 */
|
/* We only support Format 0 */
|
||||||
|
|
||||||
caps->ac_controls[0] = AUDIO_SUBFMT_END;
|
caps->ac_controls.b[0] = AUDIO_SUBFMT_END;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
caps->ac_controls[0] = AUDIO_SUBFMT_END;
|
caps->ac_controls.b[0] = AUDIO_SUBFMT_END;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,10 +240,10 @@ static int null_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
|
|||||||
|
|
||||||
/* Report the Sample rates we support */
|
/* Report the Sample rates we support */
|
||||||
|
|
||||||
caps->ac_controls[0] = AUDIO_SAMP_RATE_8K | AUDIO_SAMP_RATE_11K |
|
caps->ac_controls.b[0] = AUDIO_SAMP_RATE_8K | AUDIO_SAMP_RATE_11K |
|
||||||
AUDIO_SAMP_RATE_16K | AUDIO_SAMP_RATE_22K |
|
AUDIO_SAMP_RATE_16K | AUDIO_SAMP_RATE_22K |
|
||||||
AUDIO_SAMP_RATE_32K | AUDIO_SAMP_RATE_44K |
|
AUDIO_SAMP_RATE_32K | AUDIO_SAMP_RATE_44K |
|
||||||
AUDIO_SAMP_RATE_48K;
|
AUDIO_SAMP_RATE_48K;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AUDIO_FMT_MP3:
|
case AUDIO_FMT_MP3:
|
||||||
@ -271,8 +267,8 @@ static int null_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
|
|||||||
{
|
{
|
||||||
/* 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[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[1] = AUDIO_FU_BALANCE >> 8;
|
caps->ac_controls.b[1] = AUDIO_FU_BALANCE >> 8;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -293,14 +289,14 @@ static int null_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
|
|||||||
|
|
||||||
/* Provide the type of Processing Units we support */
|
/* Provide the type of Processing Units we support */
|
||||||
|
|
||||||
caps->ac_controls[0] = AUDIO_PU_STEREO_EXTENDER;
|
caps->ac_controls.b[0] = AUDIO_PU_STEREO_EXTENDER;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AUDIO_PU_STEREO_EXTENDER:
|
case AUDIO_PU_STEREO_EXTENDER:
|
||||||
|
|
||||||
/* Provide capabilities of our Stereo Extender */
|
/* Provide capabilities of our Stereo Extender */
|
||||||
|
|
||||||
caps->ac_controls[0] = AUDIO_STEXT_ENABLE | AUDIO_STEXT_WIDTH;
|
caps->ac_controls.b[0] = AUDIO_STEXT_ENABLE | AUDIO_STEXT_WIDTH;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -360,21 +356,21 @@ static int null_configure(FAR struct audio_lowerhalf_s *dev,
|
|||||||
|
|
||||||
/* Process based on Feature Unit */
|
/* Process based on Feature Unit */
|
||||||
|
|
||||||
switch (*((uint16_t *)caps->ac_format))
|
switch (caps->ac_format.hw)
|
||||||
{
|
{
|
||||||
#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME
|
#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME
|
||||||
case AUDIO_FU_VOLUME:
|
case AUDIO_FU_VOLUME:
|
||||||
audvdbg(" Volume: %d\n", *(uint16_t *)caps->ac_controls);
|
audvdbg(" Volume: %d\n", caps->ac_controls.hw[0]);
|
||||||
break;
|
break;
|
||||||
#endif /* CONFIG_AUDIO_EXCLUDE_VOLUME */
|
#endif /* CONFIG_AUDIO_EXCLUDE_VOLUME */
|
||||||
|
|
||||||
#ifndef CONFIG_AUDIO_EXCLUDE_TONE
|
#ifndef CONFIG_AUDIO_EXCLUDE_TONE
|
||||||
case AUDIO_FU_BASS:
|
case AUDIO_FU_BASS:
|
||||||
audvdbg(" Bass: %d\n", caps->ac_controls[0]);
|
audvdbg(" Bass: %d\n", caps->ac_controls.b[0]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AUDIO_FU_TREBLE:
|
case AUDIO_FU_TREBLE:
|
||||||
audvdbg(" Treble: %d\n", caps->ac_controls[0]);
|
audvdbg(" Treble: %d\n", caps->ac_controls.b[0]);
|
||||||
break;
|
break;
|
||||||
#endif /* CONFIG_AUDIO_EXCLUDE_TONE */
|
#endif /* CONFIG_AUDIO_EXCLUDE_TONE */
|
||||||
|
|
||||||
@ -387,8 +383,8 @@ static int null_configure(FAR struct audio_lowerhalf_s *dev,
|
|||||||
case AUDIO_TYPE_OUTPUT:
|
case AUDIO_TYPE_OUTPUT:
|
||||||
audvdbg(" AUDIO_TYPE_OUTPUT:\n");
|
audvdbg(" AUDIO_TYPE_OUTPUT:\n");
|
||||||
audvdbg(" Number of channels: %u\n", caps->ac_channels);
|
audvdbg(" Number of channels: %u\n", caps->ac_channels);
|
||||||
audvdbg(" Sample rate: %u\n", *(uint16_t*)&ac_controls[0]);
|
audvdbg(" Sample rate: %u\n", ac_controls.hw[0]);
|
||||||
audvdbg(" Sample width: %u\n", ac_controls[2]);
|
audvdbg(" Sample width: %u\n", ac_controls.b[2]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AUDIO_TYPE_PROCESSING:
|
case AUDIO_TYPE_PROCESSING:
|
||||||
|
@ -568,12 +568,8 @@ static int vs1053_getcaps(FAR struct audio_lowerhalf_s *lower, int type,
|
|||||||
|
|
||||||
/* Fill in the caller's structure based on requested info */
|
/* Fill in the caller's structure based on requested info */
|
||||||
|
|
||||||
pCaps->ac_format[0] = 0;
|
pCaps->ac_format.hw = 0;
|
||||||
pCaps->ac_format[1] = 0;
|
pCaps->ac_controls.w = 0;
|
||||||
pCaps->ac_controls[0] = 0;
|
|
||||||
pCaps->ac_controls[1] = 0;
|
|
||||||
pCaps->ac_controls[2] = 0;
|
|
||||||
pCaps->ac_controls[3] = 0;
|
|
||||||
|
|
||||||
switch (pCaps->ac_type)
|
switch (pCaps->ac_type)
|
||||||
{
|
{
|
||||||
@ -592,7 +588,7 @@ static int vs1053_getcaps(FAR struct audio_lowerhalf_s *lower, int type,
|
|||||||
case AUDIO_TYPE_QUERY:
|
case AUDIO_TYPE_QUERY:
|
||||||
/* The input formats we can decode / accept */
|
/* The input formats we can decode / accept */
|
||||||
|
|
||||||
*((uint16_t *) &pCaps->ac_format[0]) = 0
|
pCaps->ac_format.hw = 0
|
||||||
#ifdef CONFIG_AUDIO_FORMAT_AC3
|
#ifdef CONFIG_AUDIO_FORMAT_AC3
|
||||||
| (1 << (AUDIO_FMT_AC3 - 1))
|
| (1 << (AUDIO_FMT_AC3 - 1))
|
||||||
#endif
|
#endif
|
||||||
@ -615,7 +611,7 @@ static int vs1053_getcaps(FAR struct audio_lowerhalf_s *lower, int type,
|
|||||||
|
|
||||||
/* The types of audio units we implement */
|
/* The types of audio units we implement */
|
||||||
|
|
||||||
pCaps->ac_controls[0] = AUDIO_TYPE_OUTPUT | AUDIO_TYPE_FEATURE |
|
pCaps->ac_controls.b[0] = AUDIO_TYPE_OUTPUT | AUDIO_TYPE_FEATURE |
|
||||||
AUDIO_TYPE_PROCESSING;
|
AUDIO_TYPE_PROCESSING;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -626,13 +622,13 @@ static int vs1053_getcaps(FAR struct audio_lowerhalf_s *lower, int type,
|
|||||||
case AUDIO_FMT_MIDI:
|
case AUDIO_FMT_MIDI:
|
||||||
/* We only support Format 0 */
|
/* We only support Format 0 */
|
||||||
|
|
||||||
pCaps->ac_controls[0] = AUDIO_SUBFMT_MIDI_0;
|
pCaps->ac_controls.b[0] = AUDIO_SUBFMT_MIDI_0;
|
||||||
pCaps->ac_controls[1] = AUDIO_SUBFMT_END;
|
pCaps->ac_controls.b[1] = AUDIO_SUBFMT_END;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
pCaps->ac_controls[0] = AUDIO_SUBFMT_END;
|
pCaps->ac_controls.b[0] = AUDIO_SUBFMT_END;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -650,7 +646,7 @@ static int vs1053_getcaps(FAR struct audio_lowerhalf_s *lower, int type,
|
|||||||
|
|
||||||
/* Report the Sample rates we support */
|
/* Report the Sample rates we support */
|
||||||
|
|
||||||
pCaps->ac_controls[0] = AUDIO_SAMP_RATE_8K | AUDIO_SAMP_RATE_11K |
|
pCaps->ac_controls.b[0] = AUDIO_SAMP_RATE_8K | AUDIO_SAMP_RATE_11K |
|
||||||
AUDIO_SAMP_RATE_16K | AUDIO_SAMP_RATE_22K |
|
AUDIO_SAMP_RATE_16K | AUDIO_SAMP_RATE_22K |
|
||||||
AUDIO_SAMP_RATE_32K | AUDIO_SAMP_RATE_44K |
|
AUDIO_SAMP_RATE_32K | AUDIO_SAMP_RATE_44K |
|
||||||
AUDIO_SAMP_RATE_48K;
|
AUDIO_SAMP_RATE_48K;
|
||||||
@ -686,8 +682,8 @@ static int vs1053_getcaps(FAR struct audio_lowerhalf_s *lower, int type,
|
|||||||
{
|
{
|
||||||
/* Fill in the ac_controls section with the Feature Units we have */
|
/* Fill in the ac_controls section with the Feature Units we have */
|
||||||
|
|
||||||
pCaps->ac_controls[0] = AUDIO_FU_VOLUME | AUDIO_FU_BASS | AUDIO_FU_TREBLE;
|
pCaps->ac_controls.b[0] = AUDIO_FU_VOLUME | AUDIO_FU_BASS | AUDIO_FU_TREBLE;
|
||||||
pCaps->ac_controls[1] = AUDIO_FU_BALANCE >> 8;
|
pCaps->ac_controls.b[1] = AUDIO_FU_BALANCE >> 8;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -708,14 +704,14 @@ static int vs1053_getcaps(FAR struct audio_lowerhalf_s *lower, int type,
|
|||||||
|
|
||||||
/* Provide the type of Processing Units we support */
|
/* Provide the type of Processing Units we support */
|
||||||
|
|
||||||
pCaps->ac_controls[0] = AUDIO_PU_STEREO_EXTENDER;
|
pCaps->ac_controls.b[0] = AUDIO_PU_STEREO_EXTENDER;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AUDIO_PU_STEREO_EXTENDER:
|
case AUDIO_PU_STEREO_EXTENDER:
|
||||||
|
|
||||||
/* Proivde capabilities of our Stereo Extender */
|
/* Proivde capabilities of our Stereo Extender */
|
||||||
|
|
||||||
pCaps->ac_controls[0] = AUDIO_STEXT_ENABLE | AUDIO_STEXT_WIDTH;
|
pCaps->ac_controls.b[0] = AUDIO_STEXT_ENABLE | AUDIO_STEXT_WIDTH;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -777,13 +773,13 @@ static int vs1053_configure(FAR struct audio_lowerhalf_s *lower,
|
|||||||
|
|
||||||
/* Process based on Feature Unit */
|
/* Process based on Feature Unit */
|
||||||
|
|
||||||
switch (*((uint16_t *) pCaps->ac_format))
|
switch (pCaps->ac_format.hw)
|
||||||
{
|
{
|
||||||
#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME
|
#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME
|
||||||
case AUDIO_FU_VOLUME:
|
case AUDIO_FU_VOLUME:
|
||||||
/* Set the volume */
|
/* Set the volume */
|
||||||
|
|
||||||
dev->volume = *((uint16_t *) pCaps->ac_controls);
|
dev->volume = pCaps->ac_controls.hw[0]);
|
||||||
vs1053_setvolume(dev);
|
vs1053_setvolume(dev);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -793,7 +789,7 @@ static int vs1053_configure(FAR struct audio_lowerhalf_s *lower,
|
|||||||
case AUDIO_FU_BALANCE:
|
case AUDIO_FU_BALANCE:
|
||||||
/* Set the volume */
|
/* Set the volume */
|
||||||
|
|
||||||
dev->balance = *((uint16_t *) pCaps->ac_controls);
|
dev->balance = pCaps->ac_controls.hw[0]);
|
||||||
vs1053_setvolume(dev);
|
vs1053_setvolume(dev);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -805,7 +801,7 @@ static int vs1053_configure(FAR struct audio_lowerhalf_s *lower,
|
|||||||
* ac_controls[0] parameter.
|
* ac_controls[0] parameter.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
dev->bass = pCaps->ac_controls[0];
|
dev->bass = pCaps->ac_controls.b[0];
|
||||||
if (dev->bass > 100)
|
if (dev->bass > 100)
|
||||||
dev->bass = 100;
|
dev->bass = 100;
|
||||||
vs1053_setbass(dev);
|
vs1053_setbass(dev);
|
||||||
@ -814,10 +810,10 @@ static int vs1053_configure(FAR struct audio_lowerhalf_s *lower,
|
|||||||
|
|
||||||
case AUDIO_FU_TREBLE:
|
case AUDIO_FU_TREBLE:
|
||||||
/* Set the treble. The percentage level (0-100) is in the
|
/* Set the treble. The percentage level (0-100) is in the
|
||||||
* ac_controls[0] parameter.
|
* ac_controls.b[0] parameter.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
dev->treble = pCaps->ac_controls[0];
|
dev->treble = pCaps->ac_controls.b[0];
|
||||||
if (dev->treble > 100)
|
if (dev->treble > 100)
|
||||||
dev->treble = 100;
|
dev->treble = 100;
|
||||||
vs1053_setbass(dev);
|
vs1053_setbass(dev);
|
||||||
@ -840,7 +836,7 @@ static int vs1053_configure(FAR struct audio_lowerhalf_s *lower,
|
|||||||
|
|
||||||
/* We only support STEREO_EXTENDER */
|
/* We only support STEREO_EXTENDER */
|
||||||
|
|
||||||
if (*((uint16_t *) pCaps->ac_format) == AUDIO_PU_STEREO_EXTENDER)
|
if (pCaps->ac_format.hw == AUDIO_PU_STEREO_EXTENDER)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -563,12 +563,9 @@ static int wm8904_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
|
|||||||
|
|
||||||
/* Fill in the caller's structure based on requested info */
|
/* Fill in the caller's structure based on requested info */
|
||||||
|
|
||||||
caps->ac_format[0] = 0;
|
caps->ac_format[0] = 0;
|
||||||
caps->ac_format[1] = 0;
|
caps->ac_format[1] = 0;
|
||||||
caps->ac_controls[0] = 0;
|
caps->ac_controls.w = 0;
|
||||||
caps->ac_controls[1] = 0;
|
|
||||||
caps->ac_controls[2] = 0;
|
|
||||||
caps->ac_controls[3] = 0;
|
|
||||||
|
|
||||||
switch (caps->ac_type)
|
switch (caps->ac_type)
|
||||||
{
|
{
|
||||||
@ -591,7 +588,7 @@ static int wm8904_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
|
|||||||
|
|
||||||
/* The types of audio units we implement */
|
/* The types of audio units we implement */
|
||||||
|
|
||||||
caps->ac_controls[0] = AUDIO_TYPE_OUTPUT | AUDIO_TYPE_FEATURE |
|
caps->ac_controls.b[0] = AUDIO_TYPE_OUTPUT | AUDIO_TYPE_FEATURE |
|
||||||
AUDIO_TYPE_PROCESSING;
|
AUDIO_TYPE_PROCESSING;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -599,11 +596,11 @@ static int wm8904_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
|
|||||||
case AUDIO_FMT_MIDI:
|
case AUDIO_FMT_MIDI:
|
||||||
/* We only support Format 0 */
|
/* We only support Format 0 */
|
||||||
|
|
||||||
caps->ac_controls[0] = AUDIO_SUBFMT_END;
|
caps->ac_controls.b[0] = AUDIO_SUBFMT_END;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
caps->ac_controls[0] = AUDIO_SUBFMT_END;
|
caps->ac_controls.b[0] = AUDIO_SUBFMT_END;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -621,7 +618,7 @@ static int wm8904_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
|
|||||||
|
|
||||||
/* Report the Sample rates we support */
|
/* Report the Sample rates we support */
|
||||||
|
|
||||||
caps->ac_controls[0] = AUDIO_SAMP_RATE_8K | AUDIO_SAMP_RATE_11K |
|
caps->ac_controls.b[0] = AUDIO_SAMP_RATE_8K | AUDIO_SAMP_RATE_11K |
|
||||||
AUDIO_SAMP_RATE_16K | AUDIO_SAMP_RATE_22K |
|
AUDIO_SAMP_RATE_16K | AUDIO_SAMP_RATE_22K |
|
||||||
AUDIO_SAMP_RATE_32K | AUDIO_SAMP_RATE_44K |
|
AUDIO_SAMP_RATE_32K | AUDIO_SAMP_RATE_44K |
|
||||||
AUDIO_SAMP_RATE_48K;
|
AUDIO_SAMP_RATE_48K;
|
||||||
@ -648,8 +645,8 @@ static int wm8904_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
|
|||||||
{
|
{
|
||||||
/* 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[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[1] = AUDIO_FU_BALANCE >> 8;
|
caps->ac_controls.b[1] = AUDIO_FU_BALANCE >> 8;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -670,14 +667,14 @@ static int wm8904_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
|
|||||||
|
|
||||||
/* Provide the type of Processing Units we support */
|
/* Provide the type of Processing Units we support */
|
||||||
|
|
||||||
caps->ac_controls[0] = AUDIO_PU_STEREO_EXTENDER;
|
caps->ac_controls.b[0] = AUDIO_PU_STEREO_EXTENDER;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AUDIO_PU_STEREO_EXTENDER:
|
case AUDIO_PU_STEREO_EXTENDER:
|
||||||
|
|
||||||
/* Provide capabilities of our Stereo Extender */
|
/* Provide capabilities of our Stereo Extender */
|
||||||
|
|
||||||
caps->ac_controls[0] = AUDIO_STEXT_ENABLE | AUDIO_STEXT_WIDTH;
|
caps->ac_controls.b[0] = AUDIO_STEXT_ENABLE | AUDIO_STEXT_WIDTH;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -748,7 +745,7 @@ static int wm8904_configure(FAR struct audio_lowerhalf_s *dev,
|
|||||||
{
|
{
|
||||||
/* Set the volume */
|
/* Set the volume */
|
||||||
|
|
||||||
uint16_t volume = *(uint16_t *)caps->ac_controls;
|
uint16_t volume = caps->ac_controls.hw[0];
|
||||||
audvdbg(" Volume: %d\n", volume);
|
audvdbg(" Volume: %d\n", volume);
|
||||||
|
|
||||||
if (volume >= 0 && volume <= 1000)
|
if (volume >= 0 && volume <= 1000)
|
||||||
@ -769,10 +766,10 @@ static int wm8904_configure(FAR struct audio_lowerhalf_s *dev,
|
|||||||
case AUDIO_FU_BASS:
|
case AUDIO_FU_BASS:
|
||||||
{
|
{
|
||||||
/* Set the bass. The percentage level (0-100) is in the
|
/* Set the bass. The percentage level (0-100) is in the
|
||||||
* ac_controls[0] parameter.
|
* ac_controls.b[0] parameter.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uint8_t bass = caps->ac_controls[0];
|
uint8_t bass = caps->ac_controls.b[0];
|
||||||
audvdbg(" Bass: %d\n", bass);
|
audvdbg(" Bass: %d\n", bass);
|
||||||
|
|
||||||
if (bass <= 100)
|
if (bass <= 100)
|
||||||
@ -789,10 +786,10 @@ static int wm8904_configure(FAR struct audio_lowerhalf_s *dev,
|
|||||||
case AUDIO_FU_TREBLE:
|
case AUDIO_FU_TREBLE:
|
||||||
{
|
{
|
||||||
/* Set the treble. The percentage level (0-100) is in the
|
/* Set the treble. The percentage level (0-100) is in the
|
||||||
* ac_controls[0] parameter.
|
* ac_controls.b[0] parameter.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uint8_t treble = caps->ac_controls[0];
|
uint8_t treble = caps->ac_controls.b[0];
|
||||||
audvdbg(" Treble: %d\n", treble);
|
audvdbg(" Treble: %d\n", treble);
|
||||||
|
|
||||||
if (treble <= 100)
|
if (treble <= 100)
|
||||||
@ -817,8 +814,8 @@ static int wm8904_configure(FAR struct audio_lowerhalf_s *dev,
|
|||||||
case AUDIO_TYPE_OUTPUT:
|
case AUDIO_TYPE_OUTPUT:
|
||||||
audvdbg(" AUDIO_TYPE_OUTPUT:\n");
|
audvdbg(" AUDIO_TYPE_OUTPUT:\n");
|
||||||
audvdbg(" Number of channels: %u\n", caps->ac_channels);
|
audvdbg(" Number of channels: %u\n", caps->ac_channels);
|
||||||
audvdbg(" Sample rate: %u\n", *(uint16_t*)&ac_controls[0]);
|
audvdbg(" Sample rate: %u\n", ac_controls.hw[0]);
|
||||||
audvdbg(" Sample width: %u\n", ac_controls[2]);
|
audvdbg(" Sample width: %u\n", ac_controls.b[2]);
|
||||||
#warning Missing logic
|
#warning Missing logic
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -300,10 +300,19 @@ struct audio_caps_s
|
|||||||
uint8_t ac_type; /* Capabilities (device) type */
|
uint8_t ac_type; /* Capabilities (device) type */
|
||||||
uint8_t ac_subtype; /* Capabilities sub-type, if needed */
|
uint8_t ac_subtype; /* Capabilities sub-type, if needed */
|
||||||
uint8_t ac_channels; /* Number of channels (1, 2, 5, 7) */
|
uint8_t ac_channels; /* Number of channels (1, 2, 5, 7) */
|
||||||
uint8_t ac_format[2]; /* Audio data format(s) for this device */
|
|
||||||
uint8_t ac_controls[4]; /* Device specific controls. For AUDIO_DEVICE_QUERY,
|
union /* Audio data format(s) for this device */
|
||||||
* this field reports the device type supported
|
{
|
||||||
* by this lower-half driver. */
|
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. */
|
||||||
|
uint16_t hw[2];
|
||||||
|
uint32_t w;
|
||||||
|
} ac_controls;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct audio_caps_desc_s
|
struct audio_caps_desc_s
|
||||||
|
Loading…
Reference in New Issue
Block a user