1f759f5b5SMaxime Ripard /* SPDX-License-Identifier: GPL-2.0 */
2f759f5b5SMaxime Ripard
3f759f5b5SMaxime Ripard #ifndef VC4_MOCK_H_
4f759f5b5SMaxime Ripard #define VC4_MOCK_H_
5f759f5b5SMaxime Ripard
6f759f5b5SMaxime Ripard #include "../vc4_drv.h"
7f759f5b5SMaxime Ripard
8f759f5b5SMaxime Ripard static inline
vc4_find_crtc_for_encoder(struct kunit * test,struct drm_device * drm,struct drm_encoder * encoder)9f759f5b5SMaxime Ripard struct drm_crtc *vc4_find_crtc_for_encoder(struct kunit *test,
10f759f5b5SMaxime Ripard struct drm_device *drm,
11f759f5b5SMaxime Ripard struct drm_encoder *encoder)
12f759f5b5SMaxime Ripard {
13f759f5b5SMaxime Ripard struct drm_crtc *crtc;
14f759f5b5SMaxime Ripard
15f759f5b5SMaxime Ripard KUNIT_ASSERT_EQ(test, hweight32(encoder->possible_crtcs), 1);
16f759f5b5SMaxime Ripard
17f759f5b5SMaxime Ripard drm_for_each_crtc(crtc, drm)
18f759f5b5SMaxime Ripard if (encoder->possible_crtcs & drm_crtc_mask(crtc))
19f759f5b5SMaxime Ripard return crtc;
20f759f5b5SMaxime Ripard
21f759f5b5SMaxime Ripard return NULL;
22f759f5b5SMaxime Ripard }
23f759f5b5SMaxime Ripard
24f759f5b5SMaxime Ripard struct vc4_dummy_plane {
25f759f5b5SMaxime Ripard struct vc4_plane plane;
26f759f5b5SMaxime Ripard };
27f759f5b5SMaxime Ripard
28f759f5b5SMaxime Ripard struct vc4_dummy_plane *vc4_dummy_plane(struct kunit *test,
29f759f5b5SMaxime Ripard struct drm_device *drm,
30f759f5b5SMaxime Ripard enum drm_plane_type type);
31f759f5b5SMaxime Ripard
32f759f5b5SMaxime Ripard struct vc4_dummy_crtc {
33f759f5b5SMaxime Ripard struct vc4_crtc crtc;
34f759f5b5SMaxime Ripard };
35f759f5b5SMaxime Ripard
36f759f5b5SMaxime Ripard struct vc4_dummy_crtc *vc4_mock_pv(struct kunit *test,
37f759f5b5SMaxime Ripard struct drm_device *drm,
38f759f5b5SMaxime Ripard struct drm_plane *plane,
39f759f5b5SMaxime Ripard const struct vc4_crtc_data *data);
40f759f5b5SMaxime Ripard
41f759f5b5SMaxime Ripard struct vc4_dummy_output {
42f759f5b5SMaxime Ripard struct vc4_encoder encoder;
43f759f5b5SMaxime Ripard struct drm_connector connector;
44f759f5b5SMaxime Ripard };
45f759f5b5SMaxime Ripard
46*5a46e490SMaxime Ripard #define encoder_to_vc4_dummy_output(_enc) \
47*5a46e490SMaxime Ripard container_of_const(_enc, struct vc4_dummy_output, encoder.base)
48*5a46e490SMaxime Ripard
49f759f5b5SMaxime Ripard struct vc4_dummy_output *vc4_dummy_output(struct kunit *test,
50f759f5b5SMaxime Ripard struct drm_device *drm,
51f759f5b5SMaxime Ripard struct drm_crtc *crtc,
52f759f5b5SMaxime Ripard enum vc4_encoder_type vc4_encoder_type,
53f759f5b5SMaxime Ripard unsigned int kms_encoder_type,
54f759f5b5SMaxime Ripard unsigned int connector_type);
55f759f5b5SMaxime Ripard
56f759f5b5SMaxime Ripard struct vc4_dev *vc4_mock_device(struct kunit *test);
57f759f5b5SMaxime Ripard struct vc4_dev *vc5_mock_device(struct kunit *test);
58f759f5b5SMaxime Ripard
5976ec18dcSMaxime Ripard int vc4_mock_atomic_add_output(struct kunit *test,
6076ec18dcSMaxime Ripard struct drm_atomic_state *state,
6176ec18dcSMaxime Ripard enum vc4_encoder_type type);
6276ec18dcSMaxime Ripard int vc4_mock_atomic_del_output(struct kunit *test,
6376ec18dcSMaxime Ripard struct drm_atomic_state *state,
6476ec18dcSMaxime Ripard enum vc4_encoder_type type);
65f759f5b5SMaxime Ripard
66f759f5b5SMaxime Ripard #endif // VC4_MOCK_H_
67