Commit 76ec18dc authored by Maxime Ripard's avatar Maxime Ripard

drm/vc4: tests: Add unit test suite for the PV muxing

The HVS to PixelValve muxing code is fairly error prone and has a bunch
of arbitrary constraints due to the hardware setup.

Let's create a test suite that makes sure that the possible combinations
work and the invalid ones don't.
Reviewed-by: default avatarJavier Martinez Canillas <javierm@redhat.com>
Reviewed-by: default avatarMaíra Canal <mcanal@igalia.com>
Link: https://lore.kernel.org/r/20221123-rpi-kunit-tests-v3-19-4615a663a84a@cerno.techSigned-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
parent da43ff04
......@@ -29,7 +29,8 @@ vc4-$(CONFIG_DRM_VC4_KUNIT_TEST) += \
tests/vc4_mock.o \
tests/vc4_mock_crtc.o \
tests/vc4_mock_output.o \
tests/vc4_mock_plane.o
tests/vc4_mock_plane.o \
tests/vc4_test_pv_muxing.o
vc4-$(CONFIG_DEBUG_FS) += vc4_debugfs.o
......
......@@ -53,8 +53,11 @@ struct vc4_dummy_output *vc4_dummy_output(struct kunit *test,
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);
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_
......@@ -61,16 +61,17 @@ static const struct drm_display_mode default_mode = {
DRM_SIMPLE_MODE(640, 480, 64, 48)
};
int vc4_mock_atomic_add_output(struct kunit *test, struct drm_device *drm,
enum vc4_encoder_type type,
struct drm_atomic_state *state)
int vc4_mock_atomic_add_output(struct kunit *test,
struct drm_atomic_state *state,
enum vc4_encoder_type type)
{
struct drm_device *drm = state->dev;
struct drm_connector_state *conn_state;
struct drm_crtc_state *crtc_state;
struct vc4_dummy_output *output;
struct drm_connector *conn;
struct drm_connector_state *conn_state;
struct drm_encoder *encoder;
struct drm_crtc *crtc;
struct drm_crtc_state *crtc_state;
int ret;
encoder = vc4_find_encoder_by_type(drm, type);
......@@ -97,3 +98,41 @@ int vc4_mock_atomic_add_output(struct kunit *test, struct drm_device *drm,
return 0;
}
int vc4_mock_atomic_del_output(struct kunit *test,
struct drm_atomic_state *state,
enum vc4_encoder_type type)
{
struct drm_device *drm = state->dev;
struct drm_connector_state *conn_state;
struct drm_crtc_state *crtc_state;
struct vc4_dummy_output *output;
struct drm_connector *conn;
struct drm_encoder *encoder;
struct drm_crtc *crtc;
int ret;
encoder = vc4_find_encoder_by_type(drm, type);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, encoder);
crtc = vc4_find_crtc_for_encoder(test, drm, encoder);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, crtc);
crtc_state = drm_atomic_get_crtc_state(state, crtc);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, crtc_state);
crtc_state->active = false;
ret = drm_atomic_set_mode_for_crtc(crtc_state, NULL);
KUNIT_ASSERT_EQ(test, ret, 0);
output = container_of(encoder, struct vc4_dummy_output, encoder.base);
conn = &output->connector;
conn_state = drm_atomic_get_connector_state(state, conn);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, conn_state);
ret = drm_atomic_set_crtc_for_connector(conn_state, NULL);
KUNIT_ASSERT_EQ(test, ret, 0);
return 0;
}
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment