mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-10 03:35:42 +01:00
nhlt: use stdint.h types
u_int_* aren't standard, but uint* are. Use those instead for musl compat. Closes: https://github.com/alsa-project/alsa-utils/pull/234 Bug: https://bugs.gentoo.org/913758 Signed-off-by: Sam James <sam@gentoo.org> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
d272c5d935
commit
c08d580b28
1 changed files with 14 additions and 14 deletions
|
@ -46,7 +46,7 @@ int debug = 0;
|
||||||
#define NHLT_EP_HDR_SIZE (4 + 1 + 1 + 2 + 2 + 2 + 4 + 1 + 1 + 1)
|
#define NHLT_EP_HDR_SIZE (4 + 1 + 1 + 2 + 2 + 2 + 4 + 1 + 1 + 1)
|
||||||
#define VENDOR_MIC_CFG_SIZE (1 + 1 + 2 + 2 + 2 + 1 + 1 + 2 + 2 + 2 + 2 + 2 + 2)
|
#define VENDOR_MIC_CFG_SIZE (1 + 1 + 2 + 2 + 2 + 1 + 1 + 2 + 2 + 2 + 2 + 2 + 2)
|
||||||
|
|
||||||
static const char *microphone_type(u_int8_t type)
|
static const char *microphone_type(uint8_t type)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 0: return "omnidirectional";
|
case 0: return "omnidirectional";
|
||||||
|
@ -60,7 +60,7 @@ static const char *microphone_type(u_int8_t type)
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *microphone_location(u_int8_t location)
|
static const char *microphone_location(uint8_t location)
|
||||||
{
|
{
|
||||||
switch (location) {
|
switch (location) {
|
||||||
case 0: return "laptop-top-panel";
|
case 0: return "laptop-top-panel";
|
||||||
|
@ -74,21 +74,21 @@ static const char *microphone_location(u_int8_t location)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline u_int8_t get_u8(u_int8_t *base, u_int32_t off)
|
static inline uint8_t get_u8(uint8_t *base, uint32_t off)
|
||||||
{
|
{
|
||||||
return *(base + off);
|
return *(base + off);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int32_t get_s16le(u_int8_t *base, u_int32_t off)
|
static inline int32_t get_s16le(uint8_t *base, uint32_t off)
|
||||||
{
|
{
|
||||||
u_int32_t v = *(base + off + 0) |
|
uint32_t v = *(base + off + 0) |
|
||||||
(*(base + off + 1) << 8);
|
(*(base + off + 1) << 8);
|
||||||
if (v & 0x8000)
|
if (v & 0x8000)
|
||||||
return -((int32_t)0x10000 - (int32_t)v);
|
return -((int32_t)0x10000 - (int32_t)v);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u_int32_t get_u32le(u_int8_t *base, u_int32_t off)
|
static inline uint32_t get_u32le(uint8_t *base, uint32_t off)
|
||||||
{
|
{
|
||||||
return *(base + off + 0) |
|
return *(base + off + 0) |
|
||||||
(*(base + off + 1) << 8) |
|
(*(base + off + 1) << 8) |
|
||||||
|
@ -138,10 +138,10 @@ static int nhlt_dmic_config(FILE *out, uint8_t *dmic, uint8_t mic)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nhlt_dmic_ep_to_json(FILE *out, uint8_t *ep, u_int32_t ep_size)
|
static int nhlt_dmic_ep_to_json(FILE *out, uint8_t *ep, uint32_t ep_size)
|
||||||
{
|
{
|
||||||
u_int32_t off, specific_cfg_size;
|
uint32_t off, specific_cfg_size;
|
||||||
u_int8_t config_type, array_type, mic, num_mics;
|
uint8_t config_type, array_type, mic, num_mics;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
off = NHLT_EP_HDR_SIZE;
|
off = NHLT_EP_HDR_SIZE;
|
||||||
|
@ -182,15 +182,15 @@ oob:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nhlt_table_to_json(FILE *out, u_int8_t *nhlt, u_int32_t size)
|
static int nhlt_table_to_json(FILE *out, uint8_t *nhlt, uint32_t size)
|
||||||
{
|
{
|
||||||
u_int32_t _size, off, ep_size;
|
uint32_t _size, off, ep_size;
|
||||||
u_int8_t sum = 0, ep, ep_count, link_type, dmics = 0;
|
uint8_t sum = 0, ep, ep_count, link_type, dmics = 0;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
_size = get_u32le(nhlt, 4);
|
_size = get_u32le(nhlt, 4);
|
||||||
if (_size != size) {
|
if (_size != size) {
|
||||||
fprintf(stderr, "Table size mismatch (%08x != %08x)\n", _size, (u_int32_t)size);
|
fprintf(stderr, "Table size mismatch (%08x != %08x)\n", _size, (uint32_t)size);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
for (off = 0; off < size; off++)
|
for (off = 0; off < size; off++)
|
||||||
|
@ -232,7 +232,7 @@ oob:
|
||||||
static int nhlt_to_json(FILE *out, const char *nhlt_file)
|
static int nhlt_to_json(FILE *out, const char *nhlt_file)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
u_int8_t *buf;
|
uint8_t *buf;
|
||||||
int _errno, fd, res;
|
int _errno, fd, res;
|
||||||
size_t pos, size;
|
size_t pos, size;
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
|
|
Loading…
Reference in a new issue