summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/vc4/tests/vc4_mock.h
blob: db8e9a141ef844aadc364888800e6dd038a497b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* 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_atomic_state *state,
			       enum vc4_encoder_type type);
int vc4_mock_atomic_del_output(struct kunit *test,
			       struct drm_atomic_state *state,
			       enum vc4_encoder_type type);

#endif // VC4_MOCK_H_