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