-
Notifications
You must be signed in to change notification settings - Fork 0
/
drm-display-test.c
83 lines (61 loc) · 1.53 KB
/
drm-display-test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
* Copyright (C) 2019-2021 Paul Kocialkowski <contact@paulk.fr>
* Copyright (C) 2020 Bootlin
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <drm-display.h>
static int test_color(struct drm_display *display)
{
struct drm_display_buffer *buffer;
int ret;
display->primary_setup.buffer_format = DRM_FORMAT_XRGB8888;
ret = drm_display_probe(display);
if (ret)
return 1;
ret = drm_display_setup(display);
if (ret)
return ret;
buffer = drm_display_primary_buffer_cycle(display);
if (!buffer)
return 1;
memset(buffer->data[0], 0x33, buffer->strides[0] * buffer->height);
ret = drm_display_configure(display, &display->primary_setup, buffer);
if (ret)
return ret;
buffer = drm_display_primary_buffer_cycle(display);
if (!buffer)
return 1;
printf("Press enter to continue ");
getchar();
memset(buffer->data[0], 0x99, buffer->strides[0] * buffer->height);
ret = drm_display_page_flip(display, &display->primary_setup, buffer);
if (ret)
return ret;
printf("Press enter to continue ");
getchar();
buffer = drm_display_primary_buffer_cycle(display);
if (!buffer)
return 1;
ret = drm_display_page_flip(display, &display->primary_setup, buffer);
if (ret)
return ret;
}
int main(int argc, char *argv[])
{
struct drm_display display = { 0 };
int ret;
ret = drm_display_open(&display);
if (ret)
return 1;
ret = test_color(&display);
if (ret)
return 1;
printf("Press enter to continue ");
getchar();
drm_display_close(&display);
return 0;
}