summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPaul Kocialkowski <paul.kocialkowski@bootlin.com>2019-01-10 15:50:20 +0100
committerPaul Kocialkowski <paul.kocialkowski@bootlin.com>2019-02-26 09:45:54 +0100
commitcc28478682e35ced5cf45e9ef2ea8edd1d7cccb9 (patch)
tree2cf9e9415f98fbaea123162e5fae9accbb8ba23c /lib
parentc6f3707d3c5c7f61283ef643106db8e5f7e309e9 (diff)
lib/igt_chamelium: Generalize the frame match helper with check type
In prevision of adding support for another type of frame matching, rename chamelium_assert_analog_frame_match_or_dump to drop the analog part and feed it the check type. This way, the bulk of the helper can apply to other frame matching types. This requires moving the chamelium_check enum from the test to the common chamelium header. Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com> Reviewed-by: Lyude Paul <lyude@redhat.com> Reviewed-by: Maxime Ripard <maxime.ripard@bootlin.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/igt_chamelium.c21
-rw-r--r--lib/igt_chamelium.h21
2 files changed, 32 insertions, 10 deletions
diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
index dcf8e2f1..62f7e40c 100644
--- a/lib/igt_chamelium.c
+++ b/lib/igt_chamelium.c
@@ -1095,19 +1095,21 @@ void chamelium_assert_crc_eq_or_dump(struct chamelium *chamelium,
}
/**
- * chamelium_assert_analog_frame_match_or_dump:
+ * chamelium_assert_frame_match_or_dump:
* @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
*
* 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.
*/
-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)
+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)
{
cairo_surface_t *reference;
cairo_surface_t *capture;
@@ -1121,7 +1123,14 @@ void chamelium_assert_analog_frame_match_or_dump(struct chamelium *chamelium,
/* Grab the captured frame from chamelium */
capture = convert_frame_dump_argb32(frame);
- match = igt_check_analog_frame_match(reference, capture);
+ switch (check) {
+ case CHAMELIUM_CHECK_ANALOG:
+ match = igt_check_analog_frame_match(reference, capture);
+ break;
+ default:
+ igt_assert(false);
+ }
+
if (!match && igt_frame_dump_is_enabled()) {
reference_crc = malloc(sizeof(igt_crc_t));
igt_assert(reference_crc);
diff --git a/lib/igt_chamelium.h b/lib/igt_chamelium.h
index af9655a0..2f8e31db 100644
--- a/lib/igt_chamelium.h
+++ b/lib/igt_chamelium.h
@@ -40,6 +40,18 @@ struct chamelium_port;
struct chamelium_frame_dump;
struct chamelium_fb_crc_async_data;
+/**
+ * chamelium_check:
+ * @CHAMELIUM_CHECK_ANALOG: Fuzzy checking method for analog interfaces
+ * @CHAMELIUM_CHECK_CRC: CRC-based checking method for pixel-perfect interfaces
+ *
+ * Checking method for comparing between reference and captured frames.
+ */
+enum chamelium_check {
+ CHAMELIUM_CHECK_ANALOG,
+ CHAMELIUM_CHECK_CRC,
+};
+
struct chamelium *chamelium_init(int drm_fd);
void chamelium_deinit(struct chamelium *chamelium);
void chamelium_reset(struct chamelium *chamelium);
@@ -110,10 +122,11 @@ 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);
-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);
+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);
void chamelium_crop_analog_frame(struct chamelium_frame_dump *dump, int width,
int height);
void chamelium_destroy_frame_dump(struct chamelium_frame_dump *dump);