Top |
typedef | igt_crc_t |
enum | chamelium_check |
struct | chamelium_video_params |
struct | chamelium_audio_file |
enum | chamelium_infoframe_type |
struct | chamelium_infoframe |
#define | CHAMELIUM_MAX_PORTS |
#define | CHAMELIUM_DEFAULT_EDID |
#define | CHAMELIUM_MAX_AUDIO_CHANNELS |
extern bool | igt_chamelium_allow_fsm_handling |
#define | CHAMELIUM_HOTPLUG_TIMEOUT |
struct | chamelium_edid |
struct | chamelium |
struct | chamelium_fb_crc_async_data |
struct | chamelium_frame_dump |
struct | chamelium_port |
struct | edid |
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
void
chamelium_deinit_rpc_only (struct chamelium *chamelium
);
Frees the resources used by a connection to the chamelium that was set up with chamelium_init_rpc_only.
struct chamelium *
chamelium_init_rpc_only (void
);
Sets up a connection with a chamelium, using the URL specified in the Chamelium configuration. The function initializes only the RPC - no port autodiscovery happens, which means only the functions that do not require struct chamelium_port can be called with an instance produced by this function.
chamelium_init is almost always a better choice.
struct chamelium * chamelium_init (int drm_fd
,igt_display_t *display
);
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.
Needs to happen *after* igt_display_require()
as otherwise the board will
get reset.
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_require |
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_require_connector_present (struct chamelium_port **ports
,unsigned int type
,int port_count
,int count
);
Check there are required ports connected of given type
drmModeConnection chamelium_reprobe_connector (igt_display_t *display
,struct chamelium *chamelium
,struct chamelium_port *port
);
Reprobe the given connector and fetch current status
display |
A pointer to an igt_display_t structure |
|
chamelium |
The Chamelium instance to use |
|
port |
Chamelium port to reprobe |
void chamelium_wait_for_conn_status_change (igt_display_t *display
,struct chamelium *chamelium
,struct chamelium_port *port
,drmModeConnection status
);
Wait for the connector to change the status
display |
A pointer to an igt_display_t structure |
|
chamelium |
The Chamelium instance to use |
|
port |
Chamelium port to check connector status update |
|
status |
Enum which describes connector states |
void chamelium_reset_state (igt_display_t *display
,struct chamelium *chamelium
,struct chamelium_port *port
,struct chamelium_port **ports
,int port_count
);
chamelium
: The Chamelium instance to use
port
: Chamelium port to reset
ports
: All connected ports
port_count
: Count of connected ports
Reset chamelium ports
bool chamelium_wait_reachable (struct chamelium *chamelium
,int timeout
);
void chamelium_assert_reachable (struct chamelium *chamelium
,int timeout
);
Asserts that the chamelium is reachable.
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.
struct chamelium_edid * chamelium_new_edid (struct chamelium *chamelium
,const struct edid *edid
);
Uploads and registers a new EDID with the chamelium. The EDID will be destroyed automatically when chamelium_deinit is called.
Callers shouldn't assume that the raw EDID they provide is uploaded as-is to the Chamelium. The EDID may be mutated (e.g. a serial number can be appended to be able to uniquely identify the EDID). To retrieve the exact EDID that will be applied to a particular port, use chamelium_edid_get_raw.
const struct edid * chamelium_edid_get_raw (struct chamelium_edid *edid
,struct chamelium_port *port
);
struct edid * chamelium_edid_get_editable_raw (struct chamelium_edid *edid
,struct chamelium_port *port
);
void chamelium_port_set_edid (struct chamelium *chamelium
,struct chamelium_port *port
,struct chamelium_edid *edid
);
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.
To create an EDID, see chamelium_new_edid.
void chamelium_port_set_tiled_edid (struct chamelium *chamelium
,struct chamelium_port *port
,struct chamelium_edid *edid
);
Sets unique serial for tiled edid. 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.
To create an EDID, see chamelium_new_edid.
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.
bool
chamelium_supports_get_video_params (struct chamelium *chamelium
);
void chamelium_port_get_video_params (struct chamelium *chamelium
,struct chamelium_port *port
,struct chamelium_video_params *params
);
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 |
bool
chamelium_supports_get_last_infoframe (struct chamelium *chamelium
);
struct chamelium_infoframe * chamelium_get_last_infoframe (struct chamelium *chamelium
,struct chamelium_port *port
,enum chamelium_infoframe_type type
);
bool chamelium_has_audio_support (struct chamelium *chamelium
,struct chamelium_port *port
);
void chamelium_get_audio_channel_mapping (struct chamelium *chamelium
,struct chamelium_port *port
);
Obtains the channel mapping for an audio port.
Audio channels are not guaranteed not to be swapped. Users can use the channel mapping to match an input channel to a capture channel.
The mapping contains one element per capture channel. Each element indicates which input channel the capture channel is mapped to. As a special case, -1 means that the channel isn't mapped.
void chamelium_get_audio_format (struct chamelium *chamelium
,struct chamelium_port *port
,int *rate
,int *channels
);
Obtains the audio format of the captured data. Users should start sending an audio signal to the Chamelium device prior to calling this function.
The captured data is guaranteed to be in the S32_LE format.
void chamelium_start_capturing_audio (struct chamelium *chamelium
,struct chamelium_port *port
,bool save_to_file
);
Starts capturing audio from a Chamelium port. To stop the capture, use
chamelium_stop_capturing_audio. To retrieve the audio data, either use the
stream server or enable save_to_file
(the latter is mainly useful for
debugging purposes).
It isn't possible to capture audio from multiple ports at the same time.
struct chamelium_audio_file * chamelium_stop_capturing_audio (struct chamelium *chamelium
,struct chamelium_port *port
);
Stops capturing audio from a Chamelium port. If
chamelium_start_capturing_audio has been called with save_to_file
enabled,
this function will return a chamelium_audio_file struct containing details
about the audio file. Once the caller is done with the struct, they should
release it with chamelium_destroy_audio_file.
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_frame_match_or_dump (struct chamelium *chamelium
,struct chamelium_port *port
,const struct chamelium_frame_dump *frame
,struct igt_fb *fb
,enum chamelium_check check
);
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 |
|
check |
the type of frame matching check to use |
bool chamelium_frame_match_or_dump (struct chamelium *chamelium
,struct chamelium_port *port
,const struct chamelium_frame_dump *frame
,struct igt_fb *fb
,enum chamelium_check check
);
Returns bool 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 |
|
check |
the type of frame matching check to use |
void chamelium_crop_analog_frame (struct chamelium_frame_dump *dump
,int width
,int height
);
void
chamelium_destroy_frame_dump (struct chamelium_frame_dump *dump
);
Destroys the given frame dump and frees all of the resources associated with it.
void
chamelium_destroy_audio_file (struct chamelium_audio_file *audio_file
);
void
chamelium_infoframe_destroy (struct chamelium_infoframe *infoframe
);
bool chamelium_wait_all_configured_ports_connected (struct chamelium *chamelium
,int drm_fd
);
Pipe CRC value. All other members than frame
are private and should not be
inspected by testcases.
struct chamelium_video_params { double clock; int htotal, hactive, hsync_offset, hsync_width, hsync_polarity; int vtotal, vactive, vsync_offset, vsync_width, vsync_polarity; };
struct chamelium_audio_file { char *path; int rate; /* Hz */ int channels; };
struct chamelium_infoframe { int version; size_t payload_size; uint8_t *payload; };
struct chamelium_edid { struct chamelium *chamelium; struct edid *base; struct edid *raw[CHAMELIUM_MAX_PORTS]; int ids[CHAMELIUM_MAX_PORTS]; struct igt_list_head link; };
struct chamelium * |
instance of the chamelium where the EDID will be applied |
|
struct edid * |
Unaltered EDID that would be used for all ports. Matches what you would get from a real monitor. |
|
struct edid * |
EDID to be applied for each port. |
|
int |
The ID received from Chamelium after it's created for specific ports. |
|
struct igt_list_head |