@@ -104,10 +104,11 @@ static int backlight_write_brightness(int value)
return 0;
}
-static void set_abm_level(data_t *data, igt_output_t *output, int level)
+static int set_abm_level(data_t *data, igt_output_t *output, int level)
{
char buf[PATH_MAX];
int fd;
+ int ret;
igt_assert(snprintf(buf, PATH_MAX, PANEL_POWER_SAVINGS_PATH,
output->name) < PATH_MAX);
@@ -116,8 +117,12 @@ static void set_abm_level(data_t *data, igt_output_t *output, int level)
igt_assert(fd != -1);
- igt_assert_eq(snprintf(buf, sizeof(buf), "%d", level),
- write(fd, buf, 1));
+ snprintf(buf, sizeof(buf), "%d", level);
+ ret = write(fd, buf, 1);
+ if (ret < 0) {
+ close(fd);
+ return ret;
+ }
igt_assert_eq(close(fd), 0);
@@ -129,6 +134,7 @@ static void set_abm_level(data_t *data, igt_output_t *output, int level)
DRM_MODE_DPMS_OFF);
kmstest_set_connector_dpms(data->drm_fd, output->config.connector,
DRM_MODE_DPMS_ON);
+ return 0;
}
static int backlight_read_max_brightness(int *result)
@@ -192,7 +198,8 @@ static void backlight_dpms_cycle(data_t *data)
ret = backlight_read_max_brightness(&max_brightness);
igt_assert_eq(ret, 0);
- set_abm_level(data, output, 0);
+ ret = set_abm_level(data, output, 0);
+ igt_assert_eq(ret, 0);
backlight_write_brightness(max_brightness / 2);
usleep(100000);
pwm_1 = read_target_backlight_pwm(data->drm_fd, output->name);
@@ -223,7 +230,8 @@ static void backlight_monotonic_basic(data_t *data)
brightness_step = max_brightness / 10;
- set_abm_level(data, output, 0);
+ ret = set_abm_level(data, output, 0);
+ igt_assert_eq(ret, 0);
backlight_write_brightness(max_brightness);
usleep(100000);
prev_pwm = read_target_backlight_pwm(data->drm_fd, output->name);
@@ -257,7 +265,8 @@ static void backlight_monotonic_abm(data_t *data)
brightness_step = max_brightness / 10;
for (i = 1; i < 5; i++) {
- set_abm_level(data, output, 0);
+ ret = set_abm_level(data, output, 0);
+ igt_assert_eq(ret, 0);
backlight_write_brightness(max_brightness);
usleep(100000);
prev_pwm = read_target_backlight_pwm(data->drm_fd, output->name);
@@ -289,14 +298,16 @@ static void abm_enabled(data_t *data)
ret = backlight_read_max_brightness(&max_brightness);
igt_assert_eq(ret, 0);
- set_abm_level(data, output, 0);
+ ret = set_abm_level(data, output, 0);
+ igt_assert_eq(ret, 0);
backlight_write_brightness(max_brightness);
usleep(100000);
prev_pwm = read_target_backlight_pwm(data->drm_fd, output->name);
pwm_without_abm = prev_pwm;
for (i = 1; i < 5; i++) {
- set_abm_level(data, output, i);
+ ret = set_abm_level(data, output, i);
+ igt_assert_eq(ret, 0);
usleep(100000);
pwm = read_target_backlight_pwm(data->drm_fd, output->name);
igt_assert(pwm <= prev_pwm);
@@ -323,7 +334,8 @@ static void abm_gradual(data_t *data)
igt_assert_eq(ret, 0);
- set_abm_level(data, output, 0);
+ ret = set_abm_level(data, output, 0);
+ igt_assert_eq(ret, 0);
backlight_write_brightness(max_brightness);
sleep(convergence_delay);
@@ -331,7 +343,8 @@ static void abm_gradual(data_t *data)
curr = read_current_backlight_pwm(data->drm_fd, output->name);
igt_assert_eq(prev_pwm, curr);
- set_abm_level(data, output, 4);
+ ret = set_abm_level(data, output, 4);
+ igt_assert_eq(ret, 0);
for (i = 0; i < 10; i++) {
usleep(100000);
pwm = read_current_backlight_pwm(data->drm_fd, output->name);