Add support for the Chamelium
v4 cover Add support for the Chamelium
Resending because I forgot to stage some files before sending this out…
This adds basic support for using the Chamelium in hotplugging tests, along with checking video outputs.
So far there's still definitely some bugs with video capturing, however they seem to mostly be the Chamelium's fault. Since we really need to try to at least get basic support for this into igt, we're going to have to fix those later. Currently the issues I've observed are:
- Quick and successive resolution changes make the HDMI rx on the Chamelium barf pretty badly, and the WaitForVideoInputStable RPC call doesn't do it's job properly and immediately fails as a result of the video input not being stable.
- DisplayPort video capturing is not reliable, and occasionally results in single pixel mismatches between the fb and the actual video output.
Lyude (5):
igt_aux: Add igt_set_autoresume_delay()
igt_kms: Add helpers for watching for sysfs hotplug events
igt_kms: Add igt_output_from_connector
igt_kms: Add kmstest_set_connector_broadcast_rgb() Add support for hotplug testing with the Chamelium
configure.ac | 4 + .../intel-gpu-tools/intel-gpu-tools-docs.xml | 1 + lib/Makefile.am | 6 + lib/Makefile.sources | 2 + lib/igt.h | 1 + lib/igt_aux.c | 46 + lib/igt_aux.h | 1 + lib/igt_chamelium.c | 1346 ++++++++++++++++++++ lib/igt_chamelium.h | 103 ++ lib/igt_kms.c | 171 +++ lib/igt_kms.h | 25 + tests/Makefile.am | 5 +- tests/Makefile.sources | 1 + tests/chamelium.c | 689 ++++++++++ 14 files changed, 2400 insertions(+), 1 deletion(-) create mode 100644 lib/igt_chamelium.c create mode 100644 lib/igt_chamelium.h create mode 100644 tests/chamelium.c
Signature · 6 lines
2.9.3 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH RESEND v2 1/5 igt_aux: Add igt_set_autoresume_delay()
The default autoresume delay is about 5 seconds. It's possible on a system that's not very fast this might not be a long enough time, since an asynchronous hotplug event we scheduled on the chamelium that was intended to happen during suspend could happen before we actually manage to suspend. So, add a function that allows us to increase the autoresume time to ensure this never happens during suspend/resume tests with the chamelium.
Changes since v1:
- Use igt_require, not assert
--- lib/igt_aux.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_aux.h | 1 + 2 files changed, 47 insertions(+)
lib/igt_aux.c +46 -0
@@ -786,6 +786,52 @@ void igt_system_suspend_autoresume(enum igt_suspend_state state,close (power_dir); } +static int original_autoresume_delay; + +static void igt_restore_autoresume_delay (int sig) +{ +int delay_fd; +char delay_str[10 ]; + +igt_require ((delay_fd =open ("/sys/module/suspend/parameters/pm_test_delay" , +O_WRONLY )) >=0 ); + +snprintf (delay_str,sizeof (delay_str),"%d" , original_autoresume_delay); +igt_require (write (delay_fd, delay_str,strlen (delay_str))); + +close (delay_fd); +} + +/** +* igt_set_autoresume_delay: +* @delay_secs: The delay in seconds before resuming the system +* +* Sets how long we wait to resume the system after suspending it, using the +* suspend.pm_test_delay variable. On exit, the original delay value is +* restored. +*/ +void igt_set_autoresume_delay (int delay_secs) +{ +int delay_fd; +char delay_str[10 ]; + +igt_skip_on_simulation (); + +igt_require ((delay_fd =open ("/sys/module/suspend/parameters/pm_test_delay" , +O_RDWR )) >=0 ); + +if (!original_autoresume_delay) { +igt_require (read (delay_fd, delay_str,sizeof (delay_str))); + original_autoresume_delay =atoi (delay_str); +igt_install_exit_handler (igt_restore_autoresume_delay); + } + +snprintf (delay_str,sizeof (delay_str),"%d" , delay_secs); +igt_require (write (delay_fd, delay_str,strlen (delay_str))); + +close (delay_fd); +} +/** * igt_drop_root: *
lib/igt_aux.h +1 -0
@@ -183,6 +183,7 @@ enum igt_suspend_test {void igt_system_suspend_autoresume (enum igt_suspend_state state,enum igt_suspend_test test); +void igt_set_autoresume_delay (int delay_secs);/* dropping priviledges */ void igt_drop_root (void );
Signature · 6 lines
2.9.3 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH RESEND v3 2/5 igt_kms: Add helpers for watching for sysfs hotplug events
In reply to LyudeThis adds some basic helpers for connecting to udev and watching for sysfs hotplug events.
Changes since v1:
- Remove unused arg from documentation
Changes since v2:
- Make udev_monitor explicit so that we can use this for detecting FSMs from the Chamelium in rpc calls
--- lib/igt_kms.c | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_kms.h | 7 ++++ 2 files changed, 118 insertions(+)
lib/igt_kms.c +111 -0
@@ -38,6 +38,10 @@#elif HAVE_SYS_KD_H #include <sys/kd.h> #endif +#ifdef HAVE_UDEV +#include <libudev.h> +#include <poll.h> +#endif #include <errno.h> #include <time.h>
@@ -2921,6 +2925,113 @@ void igt_reset_connectors(void) "detect"); } +#ifdef HAVE_UDEV + +/** +* igt_watch_hotplug: +* +* Begin monitoring udev for sysfs hotplug events. +* +* Returns: a udev monitor for detecting hotplugs on +*/ +struct udev_monitor *igt_watch_hotplug (void ) +{ +struct udev *udev; +struct udev_monitor *mon; +int ret, flags, fd; + + udev =udev_new (); +igt_assert (udev !=NULL ); + + mon =udev_monitor_new_from_netlink (udev,"udev" ); +igt_assert (mon !=NULL ); + + ret =udev_monitor_filter_add_match_subsystem_devtype (mon, +"drm" , +"drm_minor" ); +igt_assert_eq (ret,0 ); + ret =udev_monitor_filter_update (mon); +igt_assert_eq (ret,0 ); + ret =udev_monitor_enable_receiving (mon); +igt_assert_eq (ret,0 ); + +/* Set the fd for udev as non blocking */ + fd =udev_monitor_get_fd (mon); + flags =fcntl (fd,F_GETFL ,0 ); +igt_assert (flags); + + flags |=O_NONBLOCK ; +igt_assert_neq (fcntl (fd,F_SETFL , flags),-1 ); + +return mon; +} + +/** +* igt_hotplug_detected: +* @mon: A udev monitor initialized with #igt_watch_hotplug +* @timeout_secs: How long to wait for a hotplug event to occur. +* +* Assert that a hotplug event was received since we last checked the monitor. +* +* Returns: true if a sysfs hotplug event was received, false if we timed out +*/ +bool igt_hotplug_detected (struct udev_monitor *mon,int timeout_secs) +{ +struct udev_device *dev; +const char *hotplug_val; +struct pollfd fd = { + .fd =udev_monitor_get_fd (mon), + .events =POLLIN + }; +bool hotplug_received = false; + +/* Go through all of the events pending on the udev monitor. Once we +* receive a hotplug, we continue going through the rest of the events +* so that redundant hotplug events don't change the results of future +* checks +*/ +while (!hotplug_received &&poll (&fd,1 , timeout_secs *1000 )) { + dev =udev_monitor_receive_device (mon); + + hotplug_val =udev_device_get_property_value (dev,"HOTPLUG" ); +if (hotplug_val &&atoi (hotplug_val) ==1 ) + hotplug_received = true; + +udev_device_unref (dev); + } + +return hotplug_received; +} + +/** +* igt_flush_hotplugs: +* @mon: A udev monitor initialized with #igt_watch_hotplug +* +* Get rid of any pending hotplug events +*/ +void igt_flush_hotplugs (struct udev_monitor *mon) +{ +struct udev_device *dev; + +while ((dev =udev_monitor_receive_device (mon))) +udev_device_unref (dev); +} + +/** +* igt_cleanup_hotplug: +* +* Cleanup the resources allocated by #igt_watch_hotplug +*/ +void igt_cleanup_hotplug (struct udev_monitor *mon) +{ +struct udev *udev =udev_monitor_get_udev (mon); + +udev_monitor_unref (mon); + mon =NULL ; +udev_unref (udev); +} +#endif +/** * kmstest_get_vbl_flag: * @pipe_id: Pipe to convert to flag representation.
lib/igt_kms.h +7 -0
@@ -503,5 +503,12 @@ uint32_t kmstest_get_vbl_flag(uint32_t pipe_id);const unsigned char *igt_kms_get_base_edid (void );const unsigned char *igt_kms_get_alt_edid (void ); +#ifdef HAVE_UDEV +struct udev_monitor *igt_watch_hotplug (void ); +bool igt_hotplug_detected (struct udev_monitor *mon, +int timeout_secs); +void igt_flush_hotplugs (struct udev_monitor *mon); +void igt_cleanup_hotplug (struct udev_monitor *mon); +#endif #endif /* __IGT_KMS_H__ */
Signature · 6 lines
2.9.3 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH RESEND v4 3/5 igt_kms: Add igt_output_from_connector
In reply to LyudeA simple helper for getting the igt_output_t struct corresponding to the given DRM connector id.
--- lib/igt_kms.c | 26 ++++++++++++++++++++++++++ lib/igt_kms.h | 2 ++ 2 files changed, 28 insertions(+)
lib/igt_kms.c +26 -0
@@ -1686,6 +1686,32 @@ int igt_display_get_n_pipes(igt_display_t *display)return display->n_pipes; } +/** +* igt_output_from_connector: +* @display: a pointer to an #igt_display_t structure +* @connector: a pointer to a drmModeConnector +* +* Finds the output corresponding to the given connector +* +* Returns: A #igt_output_t structure configured to use the connector, or NULL +* if none was found +*/ +igt_output_t *igt_output_from_connector (igt_display_t *display, +drmModeConnector *connector) +{ +igt_output_t *output, *found =NULL ; + +for_each_connected_output (display, output) { +if (output->config.connector->connector_id == + connector->connector_id) { + found = output; +break ; + } + } + +return found; +} +static void igt_pipe_fini (igt_pipe_t *pipe) {int i;
lib/igt_kms.h +2 -0
@@ -354,6 +354,8 @@ void igt_output_override_mode(igt_output_t *output, drmModeModeInfo *mode);void igt_output_set_pipe (igt_output_t *output,enum pipe pipe);void igt_output_set_scaling_mode (igt_output_t *output,uint64_t scaling_mode);igt_plane_t *igt_output_get_plane (igt_output_t *output,enum igt_plane plane); +igt_output_t *igt_output_from_connector (igt_display_t *display, +drmModeConnector *connector);bool igt_pipe_get_property (igt_pipe_t *pipe,const char *name,uint32_t *prop_id,uint64_t *value,drmModePropertyPtr *prop);
Signature · 6 lines
2.9.3 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH RESEND v4 4/5 igt_kms: Add kmstest_set_connector_broadcast_rgb()
In reply to LyudeA simple helper that checks whether or not the given connector has the "Broadcast RGB" prop, and if so sets it to the given mode. Required for working with the Chamelium since the Chamelium EDIDs enable limited color ranges by default on i915 and break frame dump comparisons/CRCs.
--- lib/igt_kms.c | 34 ++++++++++++++++++++++++++++++++++ lib/igt_kms.h | 16 ++++++++++++++++ 2 files changed, 50 insertions(+)
lib/igt_kms.c +34 -0
@@ -1035,6 +1035,40 @@ void kmstest_set_connector_dpms(int fd, drmModeConnector *connector, int mode) }/** +* kmstest_set_connector_broadcast_rgb: +* @fd: DRM fd +* @connector: libdrm connector +* @mode: Broadcast RGB mode +* +* This function sets the Broadcast RGB prop of @connector to @mode, if there +* is one. +* +* Returns: true if we found and set the Broadcast RGB prop, false otherwise +*/ +bool kmstest_set_connector_broadcast_rgb (int fd,drmModeConnector *connector, +enum kmstest_broadcast_rgb_mode mode) +{ +uint32_t prop_id; +int ret; + + ret =kmstest_get_property (fd, connector->connector_id, +DRM_MODE_OBJECT_CONNECTOR ,"Broadcast RGB" , + &prop_id,NULL ,NULL ); +if (!ret) { +igt_debug ("Broadcast RGB property not found on %d\n" , + connector->connector_id); +return false; + } + +igt_debug ("Setting Broadcast RGB mode on connector %d to %d\n" , + connector->connector_id, mode); + ret =drmModeConnectorSetProperty (fd, connector->connector_id, prop_id, + mode); + +return ret ==0 ; +} + +/** * kmstest_get_property: * @drm_fd: drm file descriptor * @object_id: object whose properties we're going to get
lib/igt_kms.h +16 -0
@@ -166,6 +166,20 @@ enum kmstest_force_connector_state { FORCE_CONNECTOR_OFF }; +/** +* kmstest_broadcast_rgb_mode: +* @BROADCAST_RGB_AUTO: Choose the color range to use automatically +* @BROADCAST_RGB_FULL: Force the connector to use full color range +* @BROADCAST_RGB_16_235: Force the connector to use a limited 16:235 color +* range +*/ +enum kmstest_broadcast_rgb_mode { +BROADCAST_RGB_AUTO =0 , +BROADCAST_RGB_FULL , +BROADCAST_RGB_16_235 +}; + +bool kmstest_force_connector (int fd,drmModeConnector *connector,enum kmstest_force_connector_state state);void kmstest_edid_add_3d (const unsigned char *edid,size_t length,unsigned char *new_edid_ptr[],size_t *new_length);
@@ -184,6 +198,8 @@ int kmstest_pipe_to_index(char pipe);void kmstest_free_connector_config (struct kmstest_connector_config *config);void kmstest_set_connector_dpms (int fd,drmModeConnector *connector,int mode); +bool kmstest_set_connector_broadcast_rgb (int fd,drmModeConnector *connector, +enum kmstest_broadcast_rgb_mode mode);bool kmstest_get_property (int drm_fd,uint32_t object_id,uint32_t object_type,const char *name,uint32_t *prop_id,uint64_t *value,drmModePropertyPtr *prop);
Signature · 6 lines
2.9.3 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH RESEND v4 5/5 Add support for hotplug testing with the Chamelium
In reply to LyudeFor the purpose of testing things such as hotplugging and bad monitors, the ChromeOS team ended up designing a neat little device known as the Chamelium. More information on this can be found here:
https://www.chromium.org/chromium-os/testing/chamelium
This adds support for a couple of things to intel-gpu-tools:
- igt library functions for connecting to udev and monitoring it for hotplug events, loosely based off of the unfinished hotplugging implementation in testdisplay
- Library functions for controlling the chamelium in tests using xmlrpc. A couple of RPC calls were ommitted here, mainly because they didn't seem very useful for our needs (yet)
- A set of functions for doing CRC checks and frame comparisons in tests
- A set of basic tests using the Chamelium library.
Changes since v1:
- Don't try to guess connector mappings, have the user specify them manually using a configuration file
- Open DRM fd using DRIVER_ANY, not DRIVER_INTEL
- Lower the hotplug timeout a little bit, since 30 seconds was leftover from debugging these tests anyway
- Don't try to keep track of the original state of the chamelium ports, and just leave them plugged in after each run. This makes more sense to me, since I'd imagine in automated testing setups using chameliums that all of the extra monitors will probably be provided by the Chamelium to begin with, so keeping them plugged in would make sure tests running afterwards that require >1 monitor don't get skipped.
- Add wait_for_connector() to the chamelium tests. After some more testing, I found that depending on the system some tests would throw false negatives due to us not waiting long enough for the system to detect that we connected something to it. This mainly happened with VGA connectors, since their lack of HPD makes them take significantly longer for the hardware to notice. wait_for_connector() fixes this by continually reprobing the status of the desired connector (without relying on a hpd event happening, since that might never come) until we get what we want, or we time out and fail.
- Use kmstest_get_property() for retrieving EDIDs instead of doing it by hand
- Don't hardcode PIPE_A for bringing up the display, use kmstest to find an appropriate CRTC to use.
Changes since v2:
- Fix incorrect usage of the list helpers when recording new EDIDs
- Add missing documentation
- Make sure documentation actually appears
- Since we finally got video capture working, add CRC functions and fix the ones we couldn't actually test before
- In the exit handler, reset the xmlrpc env so we can properly reset the Chamelium even after an RPC error
- Make sure compiling without Chamelium support still works Changes since v3:
- Change the config file name from .igt_chamelium_rc to .igtrc
- Remove chamelium global context
- Get rid of define_common_connector_tests()
- Get rid of connector list, expose connectors as opaque objects and provide helpers for accessing their attributes
- Get rid of configure.ac option for Chamelium
- Add tests for CRC functions
- Add frame dumping functions + tests
- Add FSM handling to chamelium_rpc()
- Use LIBUDEV_LIBS in automake, not UDEV_LIBS
- Documentation fixes
- Improve debugging output some more
- Remove skip_without_suspend_support, we no longer need to check for suspend support before calling things
- Remove unnessecary malloc() checks with igt_assert()
- Don't use igt_require in chamelium_init, leave it up to the caller whether or not to abort when failing to initialize the chamelium
- Use igt_assert_eq for making assertions about connector's statuses
- Define suspend/resume delay for tests as constant
--- configure.ac | 4 + .../intel-gpu-tools/intel-gpu-tools-docs.xml | 1 + lib/Makefile.am | 6 + lib/Makefile.sources | 2 + lib/igt.h | 1 + lib/igt_chamelium.c | 1346 ++++++++++++++++++++ lib/igt_chamelium.h | 103 ++ tests/Makefile.am | 5 +- tests/Makefile.sources | 1 + tests/chamelium.c | 689 ++++++++++ 10 files changed, 2157 insertions(+), 1 deletion(-) create mode 100644 lib/igt_chamelium.c create mode 100644 lib/igt_chamelium.h create mode 100644 tests/chamelium.c
configure.ac +4 -0
@@ -169,6 +169,10 @@ if test x"$udev" = xyes; then fi PKG_CHECK_MODULES(GLIB, glib-2.0) +# for chamelium +PKG_CHECK_MODULES(XMLRPC, xmlrpc_client) +PKG_CHECK_MODULES(PIXMAN, pixman-1) + # ----------------------------------------------------------------------------- # Configuration options # -----------------------------------------------------------------------------
docs/reference/intel-gpu-tools/intel-gpu-tools-docs.xml +1 -0
@@ -34,6 +34,7 @@ <xi:include href="xml/igt_vc4.xml"/> <xi:include href="xml/igt_vgem.xml"/> <xi:include href="xml/igt_dummyload.xml"/> + <xi:include href="xml/igt_chamelium.xml"/> </chapter> <xi:include href="xml/igt_test_programs.xml"/>
lib/Makefile.am +6 -0
@@ -31,6 +31,9 @@ AM_CFLAGS = \ $(KMOD_CFLAGS) \ $(PROCPS_CFLAGS) \ $(DEBUG_CFLAGS) \ + $(XMLRPC_CFLAGS) \ + $(LIBUDEV_CFLAGS) \ + $(PIXMAN_CFLAGS) \ -DIGT_SRCDIR=\""$(abs_top_srcdir)/tests"\" \ -DIGT_DATADIR=\""$(pkgdatadir)"\" \ -DIGT_LOG_DOMAIN=\""$(subst _,-,$*)"\" \
@@ -47,5 +50,8 @@ libintel_tools_la_LIBADD = \ $(LIBUDEV_LIBS) \ $(LIBUNWIND_LIBS) \ $(TIMER_LIBS) \ + $(XMLRPC_LIBS) \ + $(LIBUDEV_LIBS) \ + $(PIXMAN_LIBS) \ -lm
lib/Makefile.sources +2 -0
@@ -83,6 +83,8 @@ lib_source_list = \ uwildmat/uwildmat.c \ igt_kmod.c \ igt_kmod.h \ + igt_chamelium.h \ + igt_chamelium.c \ $(NULL) .PHONY: version.h.tmp
lib/igt.h +1 -0
@@ -38,6 +38,7 @@#include "igt_kms.h" #include "igt_pm.h" #include "igt_stats.h" +#include "igt_chamelium.h" #include "instdone.h" #include "intel_batchbuffer.h" #include "intel_chipset.h"
lib/igt_chamelium.c new file +1346 -0
1,346 lines not on this page · raw message
lib/igt_chamelium.h new file +103 -0
103 lines not on this page · raw message
tests/Makefile.am +4 -1
@@ -62,7 +62,7 @@ AM_CFLAGS = $(DRM_CFLAGS) $(CWARNFLAGS) -Wno-unused-result $(DEBUG_CFLAGS)\ $(LIBUNWIND_CFLAGS) $(WERROR_CFLAGS) \ $(NULL) -LDADD = ../lib/libintel_tools.la $(GLIB_LIBS) +LDADD = ../lib/libintel_tools.la $(GLIB_LIBS) $(XMLRPC_LIBS) AM_CFLAGS += $(CAIRO_CFLAGS) $(LIBUDEV_CFLAGS) $(GLIB_CFLAGS) AM_LDFLAGS = -Wl,--as-needed
@@ -118,5 +118,8 @@ vc4_wait_bo_CFLAGS = $(AM_CFLAGS) $(DRM_VC4_CFLAGS) vc4_wait_bo_LDADD = $(LDADD) $(DRM_VC4_LIBS) vc4_wait_seqno_CFLAGS = $(AM_CFLAGS) $(DRM_VC4_CFLAGS) vc4_wait_seqno_LDADD = $(LDADD) $(DRM_VC4_LIBS) + +chamelium_CFLAGS = $(AM_CFLAGS) $(XMLRPC_CFLAGS) $(LIBUDEV_CFLAGS) +chamelium_LDADD = $(LDADD) $(XMLRPC_LIBS) $(LIBUDEV_LIBS) endif
tests/Makefile.sources +1 -0
@@ -142,6 +142,7 @@ TESTS_progs_M = \ template \ vgem_basic \ vgem_slow \ + chamelium \ $(NULL) TESTS_progs_XM = \
tests/chamelium.c new file +689 -0
689 lines not on this page · raw message
Signature · 6 lines
2.9.3 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx