mirror of
https://github.com/libratbag/libratbag.git
synced 2026-11-07 23:23:52 +01:00
Sanity-check the list of dpi values and report rates
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
committed by
Benjamin Tissoires
parent
ec7bb2f63a
commit
bacdab2596
@@ -64,7 +64,9 @@ static const struct ratbag_test_device ratbagd_test_device_descr = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
.resolutions = {
|
.resolutions = {
|
||||||
{ .xres = 100, .yres = 200, .hz = 1000, .dpi_min = 50, .dpi_max = 5000 },
|
{ .xres = 100, .yres = 200, .hz = 1000,
|
||||||
|
.dpi_min = 50, .dpi_max = 5000,
|
||||||
|
.report_rates = { 500, 1000 } },
|
||||||
{ .xres = 200, .yres = 300, .hz = 1000, .active = true, .dflt = true },
|
{ .xres = 200, .yres = 300, .hz = 1000, .active = true, .dflt = true },
|
||||||
{ .xres = 300, .yres = 400, .hz = 1000 },
|
{ .xres = 300, .yres = 400, .hz = 1000 },
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -247,6 +247,8 @@ ratbag_sanity_check_device(struct ratbag_device *device)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ratbag_device_for_each_profile(device, profile) {
|
ratbag_device_for_each_profile(device, profile) {
|
||||||
|
struct ratbag_resolution *resolution;
|
||||||
|
|
||||||
/* Allow max 1 active profile */
|
/* Allow max 1 active profile */
|
||||||
if (profile->is_active) {
|
if (profile->is_active) {
|
||||||
if (has_active) {
|
if (has_active) {
|
||||||
@@ -266,6 +268,30 @@ ratbag_sanity_check_device(struct ratbag_device *device)
|
|||||||
nres);
|
nres);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ratbag_profile_for_each_resolution(profile, resolution) {
|
||||||
|
unsigned int vals[300];
|
||||||
|
unsigned int nvals = ARRAY_LENGTH(vals);
|
||||||
|
|
||||||
|
if (!ratbag_device_has_capability(device, RATBAG_DEVICE_CAP_RESOLUTION))
|
||||||
|
break;
|
||||||
|
|
||||||
|
nvals = ratbag_resolution_get_dpi_list(resolution, vals, nvals);
|
||||||
|
if (nvals == 0) {
|
||||||
|
log_bug_libratbag(ratbag,
|
||||||
|
"%s: invalid dpi list\n",
|
||||||
|
device->name);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
nvals = ratbag_resolution_get_report_rate_list(resolution, vals, nvals);
|
||||||
|
if (nvals == 0) {
|
||||||
|
log_bug_libratbag(ratbag,
|
||||||
|
"%s: invalid report rate list\n",
|
||||||
|
device->name);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Require 1 active profile */
|
/* Require 1 active profile */
|
||||||
|
|||||||
@@ -59,7 +59,9 @@ const struct ratbag_test_device sane_device = {
|
|||||||
.profiles = {
|
.profiles = {
|
||||||
{
|
{
|
||||||
.resolutions = {
|
.resolutions = {
|
||||||
{ .xres = 100, .yres = 200, .hz = 1000 },
|
{ .xres = 100, .yres = 200, .hz = 1000,
|
||||||
|
.dpi_min = 100, .dpi_max = 5000,
|
||||||
|
.report_rates = { 500, 1000 } },
|
||||||
{ .xres = 200, .yres = 300, .hz = 1000 },
|
{ .xres = 200, .yres = 300, .hz = 1000 },
|
||||||
{ .xres = 300, .yres = 400, .hz = 1000 },
|
{ .xres = 300, .yres = 400, .hz = 1000 },
|
||||||
},
|
},
|
||||||
@@ -354,7 +356,9 @@ START_TEST(device_resolutions)
|
|||||||
.profiles = {
|
.profiles = {
|
||||||
{
|
{
|
||||||
.resolutions = {
|
.resolutions = {
|
||||||
{ .xres = 100, .yres = 200, .hz = 1000, .dpi_min = 50, .dpi_max = 5000},
|
{ .xres = 100, .yres = 200, .hz = 1000,
|
||||||
|
.dpi_min = 50, .dpi_max = 5000,
|
||||||
|
.report_rates = { 500, 1000 } },
|
||||||
{ .xres = 200, .yres = 300, .hz = 1000, .active = true },
|
{ .xres = 200, .yres = 300, .hz = 1000, .active = true },
|
||||||
{ .xres = 300, .yres = 400, .hz = 1000 },
|
{ .xres = 300, .yres = 400, .hz = 1000 },
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user