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:
60
drivers/gpu/drm/vc4/tests/vc4_mock.h
Normal file
60
drivers/gpu/drm/vc4/tests/vc4_mock.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
|
||||
#ifndef VC4_MOCK_H_
|
||||
#define VC4_MOCK_H_
|
||||
|
||||
#include "../vc4_drv.h"
|
||||
|
||||
static inline
|
||||
struct drm_crtc *vc4_find_crtc_for_encoder(struct kunit *test,
|
||||
struct drm_device *drm,
|
||||
struct drm_encoder *encoder)
|
||||
{
|
||||
struct drm_crtc *crtc;
|
||||
|
||||
KUNIT_ASSERT_EQ(test, hweight32(encoder->possible_crtcs), 1);
|
||||
|
||||
drm_for_each_crtc(crtc, drm)
|
||||
if (encoder->possible_crtcs & drm_crtc_mask(crtc))
|
||||
return crtc;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct vc4_dummy_plane {
|
||||
struct vc4_plane plane;
|
||||
};
|
||||
|
||||
struct vc4_dummy_plane *vc4_dummy_plane(struct kunit *test,
|
||||
struct drm_device *drm,
|
||||
enum drm_plane_type type);
|
||||
|
||||
struct vc4_dummy_crtc {
|
||||
struct vc4_crtc crtc;
|
||||
};
|
||||
|
||||
struct vc4_dummy_crtc *vc4_mock_pv(struct kunit *test,
|
||||
struct drm_device *drm,
|
||||
struct drm_plane *plane,
|
||||
const struct vc4_crtc_data *data);
|
||||
|
||||
struct vc4_dummy_output {
|
||||
struct vc4_encoder encoder;
|
||||
struct drm_connector connector;
|
||||
};
|
||||
|
||||
struct vc4_dummy_output *vc4_dummy_output(struct kunit *test,
|
||||
struct drm_device *drm,
|
||||
struct drm_crtc *crtc,
|
||||
enum vc4_encoder_type vc4_encoder_type,
|
||||
unsigned int kms_encoder_type,
|
||||
unsigned int connector_type);
|
||||
|
||||
struct vc4_dev *vc4_mock_device(struct kunit *test);
|
||||
struct vc4_dev *vc5_mock_device(struct kunit *test);
|
||||
|
||||
int vc4_mock_atomic_add_output(struct kunit *test, struct drm_device *drm,
|
||||
enum vc4_encoder_type type,
|
||||
struct drm_atomic_state *state);
|
||||
|
||||
#endif // VC4_MOCK_H_
|
||||
Reference in New Issue
Block a user