nuttx/audio: add channels range

use the upper 4bits in ac_channels to indicate the minimum channels.

Signed-off-by: jinxiuxu <jinxiuxu@xiaomi.com>
This commit is contained in:
jinxiuxu
2023-05-19 15:12:55 +08:00
committed by Xiang Xiao
parent ff6f280b95
commit 653ea69927
2 changed files with 13 additions and 3 deletions
+11 -2
View File
@@ -176,6 +176,8 @@ static int audio_comp_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
FAR struct audio_comp_priv_s *priv = (FAR struct audio_comp_priv_s *)dev; FAR struct audio_comp_priv_s *priv = (FAR struct audio_comp_priv_s *)dev;
FAR struct audio_lowerhalf_s **lower = priv->lower; FAR struct audio_lowerhalf_s **lower = priv->lower;
int ret = -ENOTTY; int ret = -ENOTTY;
int max = UINT8_MAX;
int min = 0;
int i; int i;
caps->ac_channels = UINT8_MAX; caps->ac_channels = UINT8_MAX;
@@ -200,9 +202,14 @@ static int audio_comp_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
break; break;
} }
if (caps->ac_channels > dup.ac_channels) if (max > (dup.ac_channels & 0x0f))
{ {
caps->ac_channels = dup.ac_channels; max = dup.ac_channels & 0x0f;
}
if (min < (dup.ac_channels & 0xf0))
{
min = dup.ac_channels & 0xf0;
} }
caps->ac_format.hw &= dup.ac_format.hw; caps->ac_format.hw &= dup.ac_format.hw;
@@ -210,6 +217,8 @@ static int audio_comp_getcaps(FAR struct audio_lowerhalf_s *dev, int type,
} }
} }
caps->ac_channels = max | min;
return ret; return ret;
} }
+2 -1
View File
@@ -362,7 +362,8 @@ struct audio_caps_s
uint8_t ac_len; /* Length of the structure */ uint8_t ac_len; /* Length of the structure */
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, 3, ... 8) */ uint8_t ac_channels; /* Number of channels (1, 2, 3, ... 15) upper 4 bits for minimum channels,
* lower 4 bits for maximum channels */
uint8_t ac_chmap; /* Channel map, each ch for each bit, uint8_t ac_chmap; /* Channel map, each ch for each bit,
* zero means don't care */ * zero means don't care */
uint8_t reserved; /* Reserved for future use */ uint8_t reserved; /* Reserved for future use */