mirror of
https://github.com/torvalds/linux.git
synced 2026-04-26 18:42:25 -04:00
drm/vc4: tests: Introduce a mocking infrastructure
In order to test the current atomic_check hooks we need to have a DRM device that has roughly the same capabilities and layout that the actual hardware. We'll also need a bunch of functions to create arbitrary atomic states. Let's create some helpers to create a device that behaves like the real one, and some helpers to maintain the atomic state we want to check. Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Reviewed-by: Maíra Canal <mcanal@igalia.com> Link: https://lore.kernel.org/r/20221123-rpi-kunit-tests-v3-17-4615a663a84a@cerno.tech Signed-off-by: Maxime Ripard <maxime@cerno.tech>
This commit is contained in:
47
drivers/gpu/drm/vc4/tests/vc4_mock_plane.c
Normal file
47
drivers/gpu/drm/vc4/tests/vc4_mock_plane.c
Normal file
@@ -0,0 +1,47 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
#include <drm/drm_atomic_state_helper.h>
|
||||
#include <drm/drm_fourcc.h>
|
||||
#include <drm/drm_modeset_helper_vtables.h>
|
||||
#include <drm/drm_plane.h>
|
||||
|
||||
#include <kunit/test.h>
|
||||
|
||||
#include "vc4_mock.h"
|
||||
|
||||
static const struct drm_plane_helper_funcs vc4_dummy_plane_helper_funcs = {
|
||||
};
|
||||
|
||||
static const struct drm_plane_funcs vc4_dummy_plane_funcs = {
|
||||
.atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
|
||||
.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
|
||||
.reset = drm_atomic_helper_plane_reset,
|
||||
};
|
||||
|
||||
static const uint32_t vc4_dummy_plane_formats[] = {
|
||||
DRM_FORMAT_XRGB8888,
|
||||
};
|
||||
|
||||
struct vc4_dummy_plane *vc4_dummy_plane(struct kunit *test,
|
||||
struct drm_device *drm,
|
||||
enum drm_plane_type type)
|
||||
{
|
||||
struct vc4_dummy_plane *dummy_plane;
|
||||
struct drm_plane *plane;
|
||||
|
||||
dummy_plane = drmm_universal_plane_alloc(drm,
|
||||
struct vc4_dummy_plane, plane.base,
|
||||
0,
|
||||
&vc4_dummy_plane_funcs,
|
||||
vc4_dummy_plane_formats,
|
||||
ARRAY_SIZE(vc4_dummy_plane_formats),
|
||||
NULL,
|
||||
DRM_PLANE_TYPE_PRIMARY,
|
||||
NULL);
|
||||
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dummy_plane);
|
||||
|
||||
plane = &dummy_plane->plane.base;
|
||||
drm_plane_helper_add(plane, &vc4_dummy_plane_helper_funcs);
|
||||
|
||||
return dummy_plane;
|
||||
}
|
||||
Reference in New Issue
Block a user