mirror of
				https://github.com/torvalds/linux.git
				synced 2025-10-31 16:48:26 +02:00 
			
		
		
		
	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: 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-19-4615a663a84a@cerno.tech Signed-off-by: Maxime Ripard <maxime@cerno.tech>
This commit is contained in:
		
							parent
							
								
									da43ff045c
								
							
						
					
					
						commit
						76ec18dc5a
					
				
					 4 changed files with 1091 additions and 9 deletions
				
			
		|  | @ -29,7 +29,8 @@ vc4-$(CONFIG_DRM_VC4_KUNIT_TEST) += \ | ||||||
| 	tests/vc4_mock.o \
 | 	tests/vc4_mock.o \
 | ||||||
| 	tests/vc4_mock_crtc.o \
 | 	tests/vc4_mock_crtc.o \
 | ||||||
| 	tests/vc4_mock_output.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 | 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 *vc4_mock_device(struct kunit *test); | ||||||
| struct vc4_dev *vc5_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, | int vc4_mock_atomic_add_output(struct kunit *test, | ||||||
| 			       enum vc4_encoder_type type, | 			       struct drm_atomic_state *state, | ||||||
| 			       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_
 | #endif // VC4_MOCK_H_
 | ||||||
|  |  | ||||||
|  | @ -61,16 +61,17 @@ static const struct drm_display_mode default_mode = { | ||||||
| 	DRM_SIMPLE_MODE(640, 480, 64, 48) | 	DRM_SIMPLE_MODE(640, 480, 64, 48) | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| int vc4_mock_atomic_add_output(struct kunit *test, struct drm_device *drm, | int vc4_mock_atomic_add_output(struct kunit *test, | ||||||
| 			       enum vc4_encoder_type type, | 			       struct drm_atomic_state *state, | ||||||
| 			       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 vc4_dummy_output *output; | ||||||
| 	struct drm_connector *conn; | 	struct drm_connector *conn; | ||||||
| 	struct drm_connector_state *conn_state; |  | ||||||
| 	struct drm_encoder *encoder; | 	struct drm_encoder *encoder; | ||||||
| 	struct drm_crtc *crtc; | 	struct drm_crtc *crtc; | ||||||
| 	struct drm_crtc_state *crtc_state; |  | ||||||
| 	int ret; | 	int ret; | ||||||
| 
 | 
 | ||||||
| 	encoder = vc4_find_encoder_by_type(drm, type); | 	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; | 	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; | ||||||
|  | } | ||||||
|  |  | ||||||
							
								
								
									
										1039
									
								
								drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1039
									
								
								drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
		Loading…
	
		Reference in a new issue
	
	 Maxime Ripard
						Maxime Ripard