quirks: add quirks_get_double()

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2018-07-09 16:00:45 +10:00
parent 0021f9e7a8
commit 1cc9f44e93
3 changed files with 34 additions and 0 deletions

View file

@ -54,6 +54,7 @@ enum property_type {
PT_BOOL,
PT_DIMENSION,
PT_RANGE,
PT_DOUBLE,
};
/**
@ -74,6 +75,7 @@ struct property {
char *s;
struct quirk_dimensions dim;
struct quirk_range range;
double d;
} value;
};
@ -1434,6 +1436,24 @@ quirks_get_uint32(struct quirks *q, enum quirk which, uint32_t *val)
return true;
}
bool
quirks_get_double(struct quirks *q, enum quirk which, double *val)
{
struct property *p;
if (!q)
return false;
p = quirk_find_prop(q, which);
if (!p)
return false;
assert(p->type == PT_DOUBLE);
*val = p->value.d;
return true;
}
bool
quirks_get_string(struct quirks *q, enum quirk which, char **val)
{

View file

@ -216,6 +216,19 @@ quirks_get_int32(struct quirks *q,
enum quirk which,
int32_t *val);
/**
* Get the value of the given quirk, as double.
* This function will assert if the quirk type does not match the
* requested type. If the quirk is not set for this device, val is
* unchanged.
*
* @return true if the quirk value is valid, false otherwise.
*/
bool
quirks_get_double(struct quirks *q,
enum quirk which,
double *val);
/**
* Get the value of the given quirk, as string.
* This function will assert if the quirk type does not match the

View file

@ -630,6 +630,7 @@ tools_list_device_quirks(struct quirks_context *ctx,
struct quirk_range r;
uint32_t v;
char *s;
double d;
if (!quirks_has_quirk(quirks, *q))
continue;