[igt-dev] [PATCH i-g-t v3 17/21] lib/igt_chamelium: Generalize the frame match helper with check type
Lyude Paul
lyude at redhat.com
Tue Jan 15 22:07:23 UTC 2019
On Fri, 2019-01-11 at 10:05 +0100, Paul Kocialkowski wrote:
> 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 at bootlin.com>
> ---
> lib/igt_chamelium.c | 21 +++++++++++++++------
> lib/igt_chamelium.h | 14 ++++++++++----
> tests/kms_chamelium.c | 9 ++-------
> 3 files changed, 27 insertions(+), 17 deletions(-)
>
> diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
> index 5966b5ce0743..17321a2cef89 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));
>
> diff --git a/lib/igt_chamelium.h b/lib/igt_chamelium.h
> index af9655a0b1cf..042ac019ccdb 100644
> --- a/lib/igt_chamelium.h
> +++ b/lib/igt_chamelium.h
> @@ -40,6 +40,11 @@ struct chamelium_port;
> struct chamelium_frame_dump;
> struct chamelium_fb_crc_async_data;
>
> +enum chamelium_check {
> + CHAMELIUM_CHECK_ANALOG,
> + CHAMELIUM_CHECK_CRC,
> +};
> +
We should add some docs to this while we're at it. With that fixed:
Reviewed-by: Lyude Paul <lyude at redhat.com>
> struct chamelium *chamelium_init(int drm_fd);
> void chamelium_deinit(struct chamelium *chamelium);
> void chamelium_reset(struct chamelium *chamelium);
> @@ -110,10 +115,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);
> diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
> index 64f87d3ae474..fa6fee7d9e3e 100644
> --- a/tests/kms_chamelium.c
> +++ b/tests/kms_chamelium.c
> @@ -527,11 +527,6 @@ static int chamelium_get_pattern_fb(data_t *data,
> size_t width, size_t height,
> return fb_id;
> }
>
> -enum chamelium_check {
> - CHAMELIUM_CHECK_ANALOG,
> - CHAMELIUM_CHECK_CRC,
> -};
> -
> static void do_test_display(data_t *data, struct chamelium_port *port,
> igt_output_t *output, drmModeModeInfo *mode,
> uint32_t fourcc, enum chamelium_check check,
> @@ -589,8 +584,8 @@ static void do_test_display(data_t *data, struct
> chamelium_port *port,
> 0, 0);
> chamelium_crop_analog_frame(dump, mode->hdisplay,
> mode->vdisplay);
> - chamelium_assert_analog_frame_match_or_dump(data->chamelium,
> - port, dump, &fb);
> + chamelium_assert_frame_match_or_dump(data->chamelium, port,
> + dump, &fb, check);
> chamelium_destroy_frame_dump(dump);
> }
>
--
Cheers,
Lyude Paul
More information about the igt-dev
mailing list