Commit 557d1a2e authored by Ilia Mirkin's avatar Ilia Mirkin

modetest: add an add_property_optional variant that does not print errors

As new features are added and others are declared to be legacy, it's
nice to be able to implement fallbacks. As such, create a
property-setting variant that does not generate errors which can very
well be entirely expected.

Will be used for gamma control in a future change.
Signed-off-by: default avatarIlia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: default avatarEmil Velikov <emil.velikov@collabora.com>
parent 78ea9334
......@@ -948,9 +948,10 @@ struct property_arg {
char name[DRM_PROP_NAME_LEN+1];
uint32_t prop_id;
uint64_t value;
bool optional;
};
static void set_property(struct device *dev, struct property_arg *p)
static bool set_property(struct device *dev, struct property_arg *p)
{
drmModeObjectProperties *props = NULL;
drmModePropertyRes **props_info = NULL;
......@@ -982,13 +983,13 @@ static void set_property(struct device *dev, struct property_arg *p)
if (p->obj_type == 0) {
fprintf(stderr, "Object %i not found, can't set property\n",
p->obj_id);
return;
return false;
}
if (!props) {
fprintf(stderr, "%s %i has no properties\n",
obj_type, p->obj_id);
return;
return false;
}
for (i = 0; i < (int)props->count_props; ++i) {
......@@ -999,9 +1000,10 @@ static void set_property(struct device *dev, struct property_arg *p)
}
if (i == (int)props->count_props) {
fprintf(stderr, "%s %i has no %s property\n",
obj_type, p->obj_id, p->name);
return;
if (!p->optional)
fprintf(stderr, "%s %i has no %s property\n",
obj_type, p->obj_id, p->name);
return false;
}
p->prop_id = props->props[i];
......@@ -1015,6 +1017,8 @@ static void set_property(struct device *dev, struct property_arg *p)
if (ret < 0)
fprintf(stderr, "failed to set %s %i property %s to %" PRIu64 ": %s\n",
obj_type, p->obj_id, p->name, p->value, strerror(errno));
return true;
}
/* -------------------------------------------------------------------------- */
......@@ -1072,6 +1076,19 @@ static void add_property(struct device *dev, uint32_t obj_id,
set_property(dev, &p);
}
static bool add_property_optional(struct device *dev, uint32_t obj_id,
const char *name, uint64_t value)
{
struct property_arg p;
p.obj_id = obj_id;
strcpy(p.name, name);
p.value = value;
p.optional = true;
return set_property(dev, &p);
}
static int atomic_set_plane(struct device *dev, struct plane_arg *p,
int pattern, bool update)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment