Top |
struct | chamelium |
struct | chamelium_fb_crc_async_data |
struct | chamelium_frame_dump |
struct | chamelium_port |
struct | igt_fb |
This library contains helpers for using Chameliums in IGT tests. This allows for tests to simulate more difficult tasks to automate such as display hotplugging, faulty display behaviors, etc.
More information on the Chamelium can be found on the ChromeOS project page.
In order to run tests using the Chamelium, a valid configuration file must be present. It must contain Chamelium-specific keys as shown with the following example:
[Chamelium] URL=http://chameleon:9992 # The URL used for connecting to the Chamelium's RPC server # The rest of the sections are used for defining connector mappings. # This is required so any tests using the Chamelium know which connector # on the test machine should be connected to each Chamelium port. # # In the event that any of these mappings are specified incorrectly, # any hotplugging tests for the incorrect connector mapping will fail. [Chamelium:DP-1] # The name of the DRM connector ChameliumPortID=1 # The ID of the port on the Chamelium this connector is attached to [Chamelium:HDMI-A-1] ChameliumPortID=3
struct chamelium *
chamelium_init (int drm_fd
);
Sets up a connection with a chamelium, using the URL specified in the Chamelium configuration. This must be called first before trying to use the chamelium.
If we fail to establish a connection with the chamelium, fail to find a configured connector, etc. we fail the current test.
chamelium |
The Chamelium instance to use |
|
drm_fd |
a display initialized with igt_display_init |
void
chamelium_deinit (struct chamelium *chamelium
);
Frees the resources used by a connection to the chamelium that was set up with chamelium_init. As well, this function restores the state of the chamelium like it was before calling chamelium_init. This function is also called as an exit handler, so users only need to call manually if they don't want the chamelium interfering with other tests in the same file.
void
chamelium_reset (struct chamelium *chamelium
);
Resets the chamelium's IO board. As well, this also has the effect of causing all of the chamelium ports to get set to unplugged
struct chamelium_port ** chamelium_get_ports (struct chamelium *chamelium
,int *count
);
Retrieves all of the ports currently configured for use with this chamelium
drmModeConnector * chamelium_port_get_connector (struct chamelium *chamelium
,struct chamelium_port *port
,bool reprobe
);
Get a drmModeConnector object for the given Chamelium port, and optionally reprobe the port in the process
const char *
chamelium_port_get_name (struct chamelium_port *port
);
Gets the name of the DRM connector corresponding to the given Chamelium port.
void chamelium_plug (struct chamelium *chamelium
,struct chamelium_port *port
);
Simulate a display connector being plugged into the system using the chamelium.
void chamelium_unplug (struct chamelium *chamelium
,struct chamelium_port *port
);
Simulate a display connector being unplugged from the system using the chamelium.
bool chamelium_is_plugged (struct chamelium *chamelium
,struct chamelium_port *port
);
Check whether or not the given port has been plugged into the system using chamelium_plug.
bool chamelium_port_wait_video_input_stable (struct chamelium *chamelium
,struct chamelium_port *port
,int timeout_secs
);
Waits for a video signal to appear on the given port. This is useful for checking whether or not we've setup a monitor correctly.
void chamelium_fire_mixed_hpd_pulses (struct chamelium *chamelium
,struct chamelium_port *port
,...
);
Does the same thing as chamelium_fire_hpd_pulses, but allows the caller to specify the length of each individual pulse.
void chamelium_fire_hpd_pulses (struct chamelium *chamelium
,struct chamelium_port *port
,int width_msec
,int count
);
A convienence function for sending multiple hotplug pulses to the system.
The pulses start at low (e.g. connector is disconnected), and then alternate
from high (e.g. connector is plugged in) to low. This is the equivalent of
repeatedly calling chamelium_plug and chamelium_unplug, waiting
width_msec
between each call.
If count
is even, the last pulse sent will be high, and if it's odd then it
will be low. Resetting the HPD line back to it's previous state, if desired,
is the responsibility of the caller.
void chamelium_schedule_hpd_toggle (struct chamelium *chamelium
,struct chamelium_port *port
,int delay_ms
,bool rising_edge
);
Instructs the chamelium to schedule an hpd toggle (either a rising edge or
a falling edge, depending on rising_edg
) after delay_ms
have passed.
This is useful for testing things such as hpd after a suspend/resume cycle.
int chamelium_new_edid (struct chamelium *chamelium
,const unsigned char *edid
);
Uploads and registers a new EDID with the chamelium. The EDID will be destroyed automatically when chamelium_deinit is called.
void chamelium_port_set_edid (struct chamelium *chamelium
,struct chamelium_port *port
,int edid_id
);
Sets a port on the chamelium to use the specified EDID. This does not fire a hotplug pulse on it's own, and merely changes what EDID the chamelium port will report to us the next time we probe it. Users will need to reprobe the connectors themselves if they want to see the EDID reported by the port change.
chamelium |
The Chamelium instance to use |
|
port |
The port on the Chamelium to set the EDID on |
|
edid_id |
The ID of an EDID on the chamelium created with chamelium_new_edid, or 0 to disable the EDID on the port |
bool chamelium_port_get_ddc_state (struct chamelium *chamelium
,struct chamelium_port *port
);
Check whether or not the DDC bus on the specified chamelium port is enabled or not.
void chamelium_port_set_ddc_state (struct chamelium *chamelium
,struct chamelium_port *port
,bool enabled
);
This disables the DDC bus (e.g. the i2c line on the connector that gives us an EDID) of the specified port on the chamelium. This is useful for testing behavior on legacy connectors such as VGA, where the presence of a DDC bus is not always guaranteed.
void chamelium_port_get_resolution (struct chamelium *chamelium
,struct chamelium_port *port
,int *x
,int *y
);
Check the current reported display resolution of the specified port on the chamelium. This information is provided by the chamelium itself, not DRM. Useful for verifying that we really are scanning out at the resolution we think we are.
igt_crc_t * chamelium_get_crc_for_area (struct chamelium *chamelium
,struct chamelium_port *port
,int x
,int y
,int w
,int h
);
Reads back the pixel CRC for an area on the specified chamelium port. This is the same as using the CRC readback from a GPU, the main difference being the data is provided by the chamelium and also allows us to specify a region of the screen to use as opposed to the entire thing.
As an important note: some of the EDIDs provided by the Chamelium cause certain GPU drivers to default to using limited color ranges. This can cause video captures from the Chamelium to provide different images then expected due to the difference in color ranges (framebuffer uses full color range, but the video output doesn't), and as a result lead to CRC mismatches. To workaround this, the caller should force the connector to use full color ranges by using kmstest_set_connector_broadcast_rgb before setting up the display.
After the caller is finished with the EDID returned by this function, the caller should manually free the resources associated with it.
chamelium |
The Chamelium instance to use |
|
port |
The port to perform the CRC checking on |
|
x |
The X coordinate on the emulated display to start calculating the CRC from |
|
y |
The Y coordinate on the emulated display to start calculating the CRC from |
|
w |
The width of the area to fetch the CRC from, or |
|
h |
The height of the area to fetch the CRC from, or |
void chamelium_start_capture (struct chamelium *chamelium
,struct chamelium_port *port
,int x
,int y
,int w
,int h
);
Starts capturing video frames on the given Chamelium port. Once the user is finished capturing frames, they should call chamelium_stop_capture.
A blocking, one-shot version of this function is available: see chamelium_capture
As an important note: some of the EDIDs provided by the Chamelium cause certain GPU drivers to default to using limited color ranges. This can cause video captures from the Chamelium to provide different images then expected due to the difference in color ranges (framebuffer uses full color range, but the video output doesn't), and as a result lead to CRC and frame dump comparison mismatches. To workaround this, the caller should force the connector to use full color ranges by using kmstest_set_connector_broadcast_rgb before setting up the display.
void chamelium_stop_capture (struct chamelium *chamelium
,int frame_count
);
Finishes capturing video frames on the given Chamelium port. If frame_count
is specified, this call will block until the given number of frames have been
captured.
void chamelium_capture (struct chamelium *chamelium
,struct chamelium_port *port
,int x
,int y
,int w
,int h
,int frame_count
);
Captures the given number of frames on the chamelium. This is equivalent to calling chamelium_start_capture immediately followed by chamelium_stop_capture. The caller is blocked until all of the frames have been captured.
As an important note: some of the EDIDs provided by the Chamelium cause certain GPU drivers to default to using limited color ranges. This can cause video captures from the Chamelium to provide different images then expected due to the difference in color ranges (framebuffer uses full color range, but the video output doesn't), and as a result lead to CRC and frame dump comparison mismatches. To workaround this, the caller should force the connector to use full color ranges by using kmstest_set_connector_broadcast_rgb before setting up the display.
chamelium |
The Chamelium instance to use |
|
port |
The port to perform the video capture on |
|
x |
The X coordinate to crop the video to |
|
y |
The Y coordinate to crop the video to |
|
w |
The width of the cropped video, or |
|
h |
The height of the cropped video, or |
|
frame_count |
The number of frames to capture |
igt_crc_t * chamelium_read_captured_crcs (struct chamelium *chamelium
,int *frame_count
);
Reads all of the CRCs that have been captured thus far from the Chamelium.
struct chamelium_frame_dump * chamelium_read_captured_frame (struct chamelium *chamelium
,unsigned int index
);
struct chamelium_frame_dump * chamelium_port_dump_pixels (struct chamelium *chamelium
,struct chamelium_port *port
,int x
,int y
,int w
,int h
);
Captures the currently displayed image on the given chamelium port, optionally cropped to a given region. In situations where pre-calculating CRCs may not be reliable, this can be used as an alternative for figuring out whether or not the correct images are being displayed on the screen.
The frame dump data returned by this function should be freed when the caller is done with it using chamelium_destroy_frame_dump.
As an important note: some of the EDIDs provided by the Chamelium cause certain GPU drivers to default to using limited color ranges. This can cause video captures from the Chamelium to provide different images then expected due to the difference in color ranges (framebuffer uses full color range, but the video output doesn't), and as a result lead to CRC mismatches. To workaround this, the caller should force the connector to use full color ranges by using kmstest_set_connector_broadcast_rgb before setting up the display.
chamelium |
The Chamelium instance to use |
|
port |
The port to perform the video capture on |
|
x |
The X coordinate to crop the screen capture to |
|
y |
The Y coordinate to crop the screen capture to |
|
w |
The width of the area to crop the screen capture to, or 0 for the whole screen |
|
h |
The height of the area to crop the screen capture to, or 0 for the whole screen |
igt_crc_t * chamelium_calculate_fb_crc (int fd
,struct igt_fb *fb
);
Calculates the CRC for the provided framebuffer, using the Chamelium's CRC algorithm. This calculates the CRC in a synchronous fashion.
struct chamelium_fb_crc_async_data * chamelium_calculate_fb_crc_async_start (int fd
,struct igt_fb *fb
);
igt_crc_t *
chamelium_calculate_fb_crc_async_finish
(struct chamelium_fb_crc_async_data *fb_crc
);
int
chamelium_get_captured_frame_count (struct chamelium *chamelium
);
Gets the number of frames that were captured during the last video capture.
int chamelium_get_frame_limit (struct chamelium *chamelium
,struct chamelium_port *port
,int w
,int h
);
Gets the max number of frames we can capture with the Chamelium for the given resolution.
void chamelium_assert_frame_eq (const struct chamelium *chamelium
,const struct chamelium_frame_dump *dump
,struct igt_fb *fb
);
Asserts that the image contained in the chamelium frame dump is identical to the given framebuffer. Useful for scenarios where pre-calculating CRCs might not be ideal.
void chamelium_assert_crc_eq_or_dump (struct chamelium *chamelium
,igt_crc_t *reference_crc
,igt_crc_t *capture_crc
,struct igt_fb *fb
,int index
);
Asserts that the CRC provided for both the reference and the captured frame are identical. If they are not, this grabs the captured frame and saves it along with the reference to a png file.
chamelium |
The chamelium instance the frame dump belongs to |
|
reference_crc |
The CRC for the reference frame |
|
capture_crc |
The CRC for the captured frame |
|
fb |
pointer to an igt_fb structure |
void chamelium_assert_analog_frame_match_or_dump (struct chamelium *chamelium
,struct chamelium_port *port
,const struct chamelium_frame_dump *frame
,struct igt_fb *fb
);
Asserts that the provided captured frame matches the reference frame from the framebuffer. If they do not, this saves the reference and captured frames to a png file.
chamelium |
The chamelium instance the frame dump belongs to |
|
frame |
The chamelium frame dump to match |
|
fb |
pointer to an igt_fb structure |
void chamelium_crop_analog_frame (struct chamelium_frame_dump *dump
,int width
,int height
);