blob: af9655a0b1cf80524002168e7a7f22fad3f46984 [file] [log] [blame]
Lyudec99f8b72016-10-18 14:12:09 -04001/*
2 * Copyright © 2016 Red Hat Inc.
3 *
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:
10 *
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
13 * Software.
14 *
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
21 * IN THE SOFTWARE.
22 *
23 * Authors: Lyude Paul <lyude@redhat.com>
24 */
25
26#ifndef IGT_CHAMELIUM_H
27#define IGT_CHAMELIUM_H
28
29#include "config.h"
Arkadiusz Hilera702b602017-04-12 12:33:12 +020030
Lyudec99f8b72016-10-18 14:12:09 -040031#include <stdbool.h>
Daniel Vetter8c1fcc62017-09-08 11:23:15 +020032#include <xf86drmMode.h>
33
34#include "igt_debugfs.h"
35
36struct igt_fb;
Lyudec99f8b72016-10-18 14:12:09 -040037
38struct chamelium;
39struct chamelium_port;
40struct chamelium_frame_dump;
Paul Kocialkowskie0802ba2017-07-19 16:46:05 +030041struct chamelium_fb_crc_async_data;
Lyudec99f8b72016-10-18 14:12:09 -040042
43struct chamelium *chamelium_init(int drm_fd);
44void chamelium_deinit(struct chamelium *chamelium);
45void chamelium_reset(struct chamelium *chamelium);
46
47struct chamelium_port **chamelium_get_ports(struct chamelium *chamelium,
48 int *count);
49unsigned int chamelium_port_get_type(const struct chamelium_port *port);
50drmModeConnector *chamelium_port_get_connector(struct chamelium *chamelium,
51 struct chamelium_port *port,
52 bool reprobe);
53const char *chamelium_port_get_name(struct chamelium_port *port);
54
55void chamelium_plug(struct chamelium *chamelium, struct chamelium_port *port);
56void chamelium_unplug(struct chamelium *chamelium, struct chamelium_port *port);
57bool chamelium_is_plugged(struct chamelium *chamelium,
58 struct chamelium_port *port);
59bool chamelium_port_wait_video_input_stable(struct chamelium *chamelium,
60 struct chamelium_port *port,
61 int timeout_secs);
62void chamelium_fire_mixed_hpd_pulses(struct chamelium *chamelium,
63 struct chamelium_port *port, ...);
64void chamelium_fire_hpd_pulses(struct chamelium *chamelium,
65 struct chamelium_port *port,
66 int width_msec, int count);
Paul Kocialkowkifa8b6ee2017-06-27 13:53:06 +030067void chamelium_schedule_hpd_toggle(struct chamelium *chamelium,
68 struct chamelium_port *port, int delay_ms,
69 bool rising_edge);
Lyudec99f8b72016-10-18 14:12:09 -040070int chamelium_new_edid(struct chamelium *chamelium, const unsigned char *edid);
71void chamelium_port_set_edid(struct chamelium *chamelium,
72 struct chamelium_port *port, int edid_id);
73bool chamelium_port_get_ddc_state(struct chamelium *chamelium,
74 struct chamelium_port *port);
75void chamelium_port_set_ddc_state(struct chamelium *chamelium,
76 struct chamelium_port *port,
77 bool enabled);
78void chamelium_port_get_resolution(struct chamelium *chamelium,
79 struct chamelium_port *port,
80 int *x, int *y);
81igt_crc_t *chamelium_get_crc_for_area(struct chamelium *chamelium,
82 struct chamelium_port *port,
83 int x, int y, int w, int h);
84void chamelium_start_capture(struct chamelium *chamelium,
85 struct chamelium_port *port,
86 int x, int y, int w, int h);
87void chamelium_stop_capture(struct chamelium *chamelium, int frame_count);
88void chamelium_capture(struct chamelium *chamelium, struct chamelium_port *port,
89 int x, int y, int w, int h, int frame_count);
90igt_crc_t *chamelium_read_captured_crcs(struct chamelium *chamelium,
91 int *frame_count);
92struct chamelium_frame_dump *chamelium_read_captured_frame(struct chamelium *chamelium,
93 unsigned int index);
94struct chamelium_frame_dump *chamelium_port_dump_pixels(struct chamelium *chamelium,
95 struct chamelium_port *port,
96 int x, int y,
97 int w, int h);
Paul Kocialkowskie0802ba2017-07-19 16:46:05 +030098igt_crc_t *chamelium_calculate_fb_crc(int fd, struct igt_fb *fb);
99struct chamelium_fb_crc_async_data *chamelium_calculate_fb_crc_async_start(int fd,
100 struct igt_fb *fb);
101igt_crc_t *chamelium_calculate_fb_crc_async_finish(struct chamelium_fb_crc_async_data *fb_crc);
Lyudec99f8b72016-10-18 14:12:09 -0400102int chamelium_get_captured_frame_count(struct chamelium *chamelium);
103int chamelium_get_frame_limit(struct chamelium *chamelium,
104 struct chamelium_port *port,
105 int w, int h);
Lyudec99f8b72016-10-18 14:12:09 -0400106void chamelium_assert_frame_eq(const struct chamelium *chamelium,
107 const struct chamelium_frame_dump *dump,
108 struct igt_fb *fb);
Paul Kocialkowski5e4e8292017-07-19 16:46:09 +0300109void chamelium_assert_crc_eq_or_dump(struct chamelium *chamelium,
110 igt_crc_t *reference_crc,
111 igt_crc_t *capture_crc, struct igt_fb *fb,
112 int index);
Paul Kocialkowskie246ff02017-07-20 18:13:37 +0300113void chamelium_assert_analog_frame_match_or_dump(struct chamelium *chamelium,
114 struct chamelium_port *port,
115 const struct chamelium_frame_dump *frame,
116 struct igt_fb *fb);
117void chamelium_crop_analog_frame(struct chamelium_frame_dump *dump, int width,
118 int height);
Lyudec99f8b72016-10-18 14:12:09 -0400119void chamelium_destroy_frame_dump(struct chamelium_frame_dump *dump);
120
121#endif /* IGT_CHAMELIUM_H */