2 * Copyright © 2013 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
32 #include <igt_display.h>
34 struct kmstest_connector_config {
36 drmModeConnector *connector;
37 drmModeEncoder *encoder;
38 drmModeModeInfo default_mode;
43 int kmstest_get_connector_default_mode(int drm_fd, drmModeConnector *connector,
44 drmModeModeInfo *mode);
45 int kmstest_get_connector_config(int drm_fd, uint32_t connector_id,
46 unsigned long crtc_idx_mask,
47 struct kmstest_connector_config *config);
48 void kmstest_free_connector_config(struct kmstest_connector_config *config);
50 /* helpers to create nice-looking framebuffers */
61 cairo_surface_t *cairo_surface;
64 enum kmstest_text_align {
66 align_bottom = align_left,
73 int kmstest_cairo_printf_line(cairo_t *cr, enum kmstest_text_align align,
74 double yspacing, const char *fmt, ...)
75 __attribute__((format (printf, 4, 5)));
77 unsigned int kmstest_create_fb(int fd, int width, int height, int bpp,
78 int depth, bool tiled,
79 struct kmstest_fb *fb_info);
80 unsigned int kmstest_create_fb2(int fd, int width, int height, uint32_t format,
81 bool tiled, struct kmstest_fb *fb);
82 void kmstest_remove_fb(int fd, struct kmstest_fb *fb_info);
83 cairo_t *kmstest_get_cairo_ctx(int fd, struct kmstest_fb *fb);
84 cairo_surface_t *kmstest_get_cairo_surface(int fd, struct kmstest_fb *fb);
85 void kmstest_paint_color(cairo_t *cr, int x, int y, int w, int h,
86 double r, double g, double b);
87 void kmstest_paint_color_alpha(cairo_t *cr, int x, int y, int w, int h,
88 double r, double g, double b, double a);
89 void kmstest_paint_color_gradient(cairo_t *cr, int x, int y, int w, int h,
91 void kmstest_paint_test_pattern(cairo_t *cr, int width, int height);
92 void kmstest_paint_image(cairo_t *cr, const char *filename,
93 int dst_x, int dst_y, int dst_width, int dst_height);
94 void kmstest_write_fb(int fd, struct kmstest_fb *fb, const char *filename);
95 void kmstest_dump_mode(drmModeModeInfo *mode);
96 int kmstest_get_pipe_from_crtc_id(int fd, int crtc_id);
97 const char *kmstest_format_str(uint32_t drm_format);
98 const char *kmstest_pipe_str(int pipe);
99 void kmstest_get_all_formats(const uint32_t **formats, int *format_count);
100 const char *kmstest_encoder_type_str(int type);
101 const char *kmstest_connector_status_str(int type);
102 const char *kmstest_connector_type_str(int type);
104 uint32_t drm_format_to_bpp(uint32_t drm_format);
107 * A small modeset API
110 typedef struct igt_display igt_display_t;
111 typedef struct igt_pipe igt_pipe_t;
112 typedef uint32_t igt_fixed_t; /* 16.16 fixed point */
117 unsigned int is_primary : 1;
118 unsigned int is_cursor : 1;
119 unsigned int position_changed : 1;
120 struct kmstest_fb *fb;
121 /* position within pipe_src_w x pipe_src_h */
126 igt_display_t *display;
128 unsigned int need_set_crtc : 1;
129 unsigned int need_set_cursor : 1;
130 #define IGT_MAX_PLANES 4
132 igt_plane_t planes[IGT_MAX_PLANES];
136 igt_display_t *display;
137 uint32_t id; /* KMS id */
138 struct kmstest_connector_config config;
141 unsigned long pending_crtc_idx_mask;
146 unsigned int verbose : 1;
150 unsigned long pipes_in_use;
151 igt_output_t *outputs;
152 igt_pipe_t pipes[I915_MAX_PIPES];
155 void igt_display_init(igt_display_t *display, int drm_fd);
156 void igt_display_fini(igt_display_t *display);
157 int igt_display_commit(igt_display_t *display);
158 void igt_display_set_verbose(igt_display_t *display, bool verbose);
159 int igt_display_get_n_pipes(igt_display_t *display);
161 const char *igt_output_name(igt_output_t *output);
162 drmModeModeInfo *igt_output_get_mode(igt_output_t *output);
163 void igt_output_set_pipe(igt_output_t *output, enum pipe pipe);
164 igt_plane_t *igt_ouput_get_plane(igt_output_t *output, enum igt_plane plane);
166 void igt_plane_set_fb(igt_plane_t *plane, struct kmstest_fb *fb);
167 void igt_plane_set_position(igt_plane_t *plane, int x, int y);
169 #define for_each_connected_output(display, output) \
170 for (int i__ = 0; i__ < (display)->n_outputs; i__++) \
171 if ((output = &(display)->outputs[i__]), output->valid)
173 #define IGT_FIXED(i,f) ((i) << 16 | (f))
175 #endif /* __IGT_KMS_H__ */