Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/tests: Add output bpc tests

Now that we're tracking the output bpc count in the connector state,
let's add a few tests to make sure it works as expected.

Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Tested-by: Sui Jingfeng <sui.jingfeng@linux.dev>
Link: https://patchwork.freedesktop.org/patch/msgid/20240527-kms-hdmi-connector-state-v15-6-c5af16c3aae2@kernel.org
Signed-off-by: Maxime Ripard <mripard@kernel.org>

+703
+1
drivers/gpu/drm/Kconfig
··· 79 79 depends on DRM && KUNIT && MMU 80 80 select DRM_BUDDY 81 81 select DRM_DISPLAY_DP_HELPER 82 + select DRM_DISPLAY_HDMI_STATE_HELPER 82 83 select DRM_DISPLAY_HELPER 83 84 select DRM_EXEC 84 85 select DRM_EXPORT_FOR_TESTS if m
+1
drivers/gpu/drm/tests/Makefile
··· 14 14 drm_format_test.o \ 15 15 drm_framebuffer_test.o \ 16 16 drm_gem_shmem_test.o \ 17 + drm_hdmi_state_helper_test.o \ 17 18 drm_managed_test.o \ 18 19 drm_mm_test.o \ 19 20 drm_modes_test.o \
+155
drivers/gpu/drm/tests/drm_connector_test.c
··· 12 12 13 13 #include <kunit/test.h> 14 14 15 + #include "../drm_crtc_internal.h" 16 + 15 17 struct drm_connector_init_priv { 16 18 struct drm_device drm; 17 19 struct drm_connector connector; ··· 209 207 } 210 208 211 209 /* 210 + * Test that the registration of a connector with an invalid maximum bpc 211 + * count fails. 212 + */ 213 + static void drm_test_connector_hdmi_init_bpc_invalid(struct kunit *test) 214 + { 215 + struct drm_connector_init_priv *priv = test->priv; 216 + int ret; 217 + 218 + ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector, 219 + &dummy_funcs, 220 + DRM_MODE_CONNECTOR_HDMIA, 221 + &priv->ddc, 222 + 9); 223 + KUNIT_EXPECT_LT(test, ret, 0); 224 + } 225 + 226 + /* 227 + * Test that the registration of a connector with a null maximum bpc 228 + * count fails. 229 + */ 230 + static void drm_test_connector_hdmi_init_bpc_null(struct kunit *test) 231 + { 232 + struct drm_connector_init_priv *priv = test->priv; 233 + int ret; 234 + 235 + ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector, 236 + &dummy_funcs, 237 + DRM_MODE_CONNECTOR_HDMIA, 238 + &priv->ddc, 239 + 0); 240 + KUNIT_EXPECT_LT(test, ret, 0); 241 + } 242 + 243 + /* 244 + * Test that the registration of a connector with a maximum bpc count of 245 + * 8 succeeds, registers the max bpc property, but doesn't register the 246 + * HDR output metadata one. 247 + */ 248 + static void drm_test_connector_hdmi_init_bpc_8(struct kunit *test) 249 + { 250 + struct drm_connector_init_priv *priv = test->priv; 251 + struct drm_connector_state *state; 252 + struct drm_connector *connector = &priv->connector; 253 + struct drm_property *prop; 254 + uint64_t val; 255 + int ret; 256 + 257 + ret = drmm_connector_hdmi_init(&priv->drm, connector, 258 + &dummy_funcs, 259 + DRM_MODE_CONNECTOR_HDMIA, 260 + &priv->ddc, 261 + 8); 262 + KUNIT_EXPECT_EQ(test, ret, 0); 263 + 264 + prop = connector->max_bpc_property; 265 + KUNIT_ASSERT_NOT_NULL(test, prop); 266 + KUNIT_EXPECT_NOT_NULL(test, drm_mode_obj_find_prop_id(&connector->base, prop->base.id)); 267 + 268 + ret = drm_object_property_get_default_value(&connector->base, prop, &val); 269 + KUNIT_EXPECT_EQ(test, ret, 0); 270 + KUNIT_EXPECT_EQ(test, val, 8); 271 + 272 + state = connector->state; 273 + KUNIT_EXPECT_EQ(test, state->max_bpc, 8); 274 + KUNIT_EXPECT_EQ(test, state->max_requested_bpc, 8); 275 + 276 + prop = priv->drm.mode_config.hdr_output_metadata_property; 277 + KUNIT_ASSERT_NOT_NULL(test, prop); 278 + KUNIT_EXPECT_NULL(test, drm_mode_obj_find_prop_id(&connector->base, prop->base.id)); 279 + } 280 + 281 + /* 282 + * Test that the registration of a connector with a maximum bpc count of 283 + * 10 succeeds and registers the max bpc and HDR output metadata 284 + * properties. 285 + */ 286 + static void drm_test_connector_hdmi_init_bpc_10(struct kunit *test) 287 + { 288 + struct drm_connector_init_priv *priv = test->priv; 289 + struct drm_connector_state *state; 290 + struct drm_connector *connector = &priv->connector; 291 + struct drm_property *prop; 292 + uint64_t val; 293 + int ret; 294 + 295 + ret = drmm_connector_hdmi_init(&priv->drm, connector, 296 + &dummy_funcs, 297 + DRM_MODE_CONNECTOR_HDMIA, 298 + &priv->ddc, 299 + 10); 300 + KUNIT_EXPECT_EQ(test, ret, 0); 301 + 302 + prop = connector->max_bpc_property; 303 + KUNIT_ASSERT_NOT_NULL(test, prop); 304 + KUNIT_EXPECT_NOT_NULL(test, drm_mode_obj_find_prop_id(&connector->base, prop->base.id)); 305 + 306 + ret = drm_object_property_get_default_value(&connector->base, prop, &val); 307 + KUNIT_EXPECT_EQ(test, ret, 0); 308 + KUNIT_EXPECT_EQ(test, val, 10); 309 + 310 + state = connector->state; 311 + KUNIT_EXPECT_EQ(test, state->max_bpc, 10); 312 + KUNIT_EXPECT_EQ(test, state->max_requested_bpc, 10); 313 + 314 + prop = priv->drm.mode_config.hdr_output_metadata_property; 315 + KUNIT_ASSERT_NOT_NULL(test, prop); 316 + KUNIT_EXPECT_NOT_NULL(test, drm_mode_obj_find_prop_id(&connector->base, prop->base.id)); 317 + } 318 + 319 + /* 320 + * Test that the registration of a connector with a maximum bpc count of 321 + * 12 succeeds and registers the max bpc and HDR output metadata 322 + * properties. 323 + */ 324 + static void drm_test_connector_hdmi_init_bpc_12(struct kunit *test) 325 + { 326 + struct drm_connector_init_priv *priv = test->priv; 327 + struct drm_connector_state *state; 328 + struct drm_connector *connector = &priv->connector; 329 + struct drm_property *prop; 330 + uint64_t val; 331 + int ret; 332 + 333 + ret = drmm_connector_hdmi_init(&priv->drm, connector, 334 + &dummy_funcs, 335 + DRM_MODE_CONNECTOR_HDMIA, 336 + &priv->ddc, 337 + 12); 338 + KUNIT_EXPECT_EQ(test, ret, 0); 339 + 340 + prop = connector->max_bpc_property; 341 + KUNIT_ASSERT_NOT_NULL(test, prop); 342 + KUNIT_EXPECT_NOT_NULL(test, drm_mode_obj_find_prop_id(&connector->base, prop->base.id)); 343 + 344 + ret = drm_object_property_get_default_value(&connector->base, prop, &val); 345 + KUNIT_EXPECT_EQ(test, ret, 0); 346 + KUNIT_EXPECT_EQ(test, val, 12); 347 + 348 + state = connector->state; 349 + KUNIT_EXPECT_EQ(test, state->max_bpc, 12); 350 + KUNIT_EXPECT_EQ(test, state->max_requested_bpc, 12); 351 + 352 + prop = priv->drm.mode_config.hdr_output_metadata_property; 353 + KUNIT_ASSERT_NOT_NULL(test, prop); 354 + KUNIT_EXPECT_NOT_NULL(test, drm_mode_obj_find_prop_id(&connector->base, prop->base.id)); 355 + } 356 + 357 + /* 212 358 * Test that the registration of an HDMI connector with an HDMI 213 359 * connector type succeeds. 214 360 */ ··· 434 284 435 285 static struct kunit_case drmm_connector_hdmi_init_tests[] = { 436 286 KUNIT_CASE(drm_test_connector_hdmi_init_valid), 287 + KUNIT_CASE(drm_test_connector_hdmi_init_bpc_8), 288 + KUNIT_CASE(drm_test_connector_hdmi_init_bpc_10), 289 + KUNIT_CASE(drm_test_connector_hdmi_init_bpc_12), 290 + KUNIT_CASE(drm_test_connector_hdmi_init_bpc_invalid), 291 + KUNIT_CASE(drm_test_connector_hdmi_init_bpc_null), 437 292 KUNIT_CASE(drm_test_connector_hdmi_init_null_ddc), 438 293 KUNIT_CASE_PARAM(drm_test_connector_hdmi_init_type_valid, 439 294 drm_connector_hdmi_init_type_valid_gen_params),
+438
drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 3 + /* 4 + * Kunit test for drm_hdmi_state_helper functions 5 + */ 6 + 7 + #include <drm/drm_atomic.h> 8 + #include <drm/drm_atomic_state_helper.h> 9 + #include <drm/drm_atomic_uapi.h> 10 + #include <drm/drm_drv.h> 11 + #include <drm/drm_edid.h> 12 + #include <drm/drm_connector.h> 13 + #include <drm/drm_fourcc.h> 14 + #include <drm/drm_kunit_helpers.h> 15 + #include <drm/drm_managed.h> 16 + #include <drm/drm_modeset_helper_vtables.h> 17 + #include <drm/drm_print.h> 18 + #include <drm/drm_probe_helper.h> 19 + 20 + #include <drm/display/drm_hdmi_state_helper.h> 21 + 22 + #include "../drm_crtc_internal.h" 23 + 24 + #include <kunit/test.h> 25 + 26 + #include "drm_kunit_edid.h" 27 + 28 + struct drm_atomic_helper_connector_hdmi_priv { 29 + struct drm_device drm; 30 + struct drm_plane *plane; 31 + struct drm_crtc *crtc; 32 + struct drm_encoder encoder; 33 + struct drm_connector connector; 34 + 35 + const char *current_edid; 36 + size_t current_edid_len; 37 + }; 38 + 39 + #define connector_to_priv(c) \ 40 + container_of_const(c, struct drm_atomic_helper_connector_hdmi_priv, connector) 41 + 42 + static struct drm_display_mode *find_preferred_mode(struct drm_connector *connector) 43 + { 44 + struct drm_device *drm = connector->dev; 45 + struct drm_display_mode *mode, *preferred; 46 + 47 + mutex_lock(&drm->mode_config.mutex); 48 + preferred = list_first_entry(&connector->modes, struct drm_display_mode, head); 49 + list_for_each_entry(mode, &connector->modes, head) 50 + if (mode->type & DRM_MODE_TYPE_PREFERRED) 51 + preferred = mode; 52 + mutex_unlock(&drm->mode_config.mutex); 53 + 54 + return preferred; 55 + } 56 + 57 + static int light_up_connector(struct kunit *test, 58 + struct drm_device *drm, 59 + struct drm_crtc *crtc, 60 + struct drm_connector *connector, 61 + struct drm_display_mode *mode, 62 + struct drm_modeset_acquire_ctx *ctx) 63 + { 64 + struct drm_atomic_state *state; 65 + struct drm_connector_state *conn_state; 66 + struct drm_crtc_state *crtc_state; 67 + int ret; 68 + 69 + state = drm_kunit_helper_atomic_state_alloc(test, drm, ctx); 70 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); 71 + 72 + conn_state = drm_atomic_get_connector_state(state, connector); 73 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, conn_state); 74 + 75 + ret = drm_atomic_set_crtc_for_connector(conn_state, crtc); 76 + KUNIT_EXPECT_EQ(test, ret, 0); 77 + 78 + crtc_state = drm_atomic_get_crtc_state(state, crtc); 79 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, crtc_state); 80 + 81 + ret = drm_atomic_set_mode_for_crtc(crtc_state, mode); 82 + KUNIT_EXPECT_EQ(test, ret, 0); 83 + 84 + crtc_state->enable = true; 85 + crtc_state->active = true; 86 + 87 + ret = drm_atomic_commit(state); 88 + KUNIT_ASSERT_EQ(test, ret, 0); 89 + 90 + return 0; 91 + } 92 + 93 + static int set_connector_edid(struct kunit *test, struct drm_connector *connector, 94 + const char *edid, size_t edid_len) 95 + { 96 + struct drm_atomic_helper_connector_hdmi_priv *priv = 97 + connector_to_priv(connector); 98 + struct drm_device *drm = connector->dev; 99 + int ret; 100 + 101 + priv->current_edid = edid; 102 + priv->current_edid_len = edid_len; 103 + 104 + mutex_lock(&drm->mode_config.mutex); 105 + ret = connector->funcs->fill_modes(connector, 4096, 4096); 106 + mutex_unlock(&drm->mode_config.mutex); 107 + KUNIT_ASSERT_GT(test, ret, 0); 108 + 109 + return 0; 110 + } 111 + 112 + static int dummy_connector_get_modes(struct drm_connector *connector) 113 + { 114 + struct drm_atomic_helper_connector_hdmi_priv *priv = 115 + connector_to_priv(connector); 116 + const struct drm_edid *edid; 117 + unsigned int num_modes; 118 + 119 + edid = drm_edid_alloc(priv->current_edid, priv->current_edid_len); 120 + if (!edid) 121 + return -EINVAL; 122 + 123 + drm_edid_connector_update(connector, edid); 124 + num_modes = drm_edid_connector_add_modes(connector); 125 + 126 + drm_edid_free(edid); 127 + 128 + return num_modes; 129 + } 130 + 131 + static const struct drm_connector_helper_funcs dummy_connector_helper_funcs = { 132 + .atomic_check = drm_atomic_helper_connector_hdmi_check, 133 + .get_modes = dummy_connector_get_modes, 134 + }; 135 + 136 + static void dummy_hdmi_connector_reset(struct drm_connector *connector) 137 + { 138 + drm_atomic_helper_connector_reset(connector); 139 + __drm_atomic_helper_connector_hdmi_reset(connector, connector->state); 140 + } 141 + 142 + static const struct drm_connector_funcs dummy_connector_funcs = { 143 + .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, 144 + .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, 145 + .fill_modes = drm_helper_probe_single_connector_modes, 146 + .reset = dummy_hdmi_connector_reset, 147 + }; 148 + 149 + static 150 + struct drm_atomic_helper_connector_hdmi_priv * 151 + drm_atomic_helper_connector_hdmi_init(struct kunit *test, 152 + unsigned int max_bpc) 153 + { 154 + struct drm_atomic_helper_connector_hdmi_priv *priv; 155 + struct drm_connector *conn; 156 + struct drm_encoder *enc; 157 + struct drm_device *drm; 158 + struct device *dev; 159 + int ret; 160 + 161 + dev = drm_kunit_helper_alloc_device(test); 162 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev); 163 + 164 + priv = drm_kunit_helper_alloc_drm_device(test, dev, 165 + struct drm_atomic_helper_connector_hdmi_priv, drm, 166 + DRIVER_MODESET | DRIVER_ATOMIC); 167 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv); 168 + test->priv = priv; 169 + 170 + drm = &priv->drm; 171 + priv->plane = drm_kunit_helper_create_primary_plane(test, drm, 172 + NULL, 173 + NULL, 174 + NULL, 0, 175 + NULL); 176 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv->plane); 177 + 178 + priv->crtc = drm_kunit_helper_create_crtc(test, drm, 179 + priv->plane, NULL, 180 + NULL, 181 + NULL); 182 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv->crtc); 183 + 184 + enc = &priv->encoder; 185 + ret = drmm_encoder_init(drm, enc, NULL, DRM_MODE_ENCODER_TMDS, NULL); 186 + KUNIT_ASSERT_EQ(test, ret, 0); 187 + 188 + enc->possible_crtcs = drm_crtc_mask(priv->crtc); 189 + 190 + conn = &priv->connector; 191 + ret = drmm_connector_hdmi_init(drm, conn, 192 + &dummy_connector_funcs, 193 + DRM_MODE_CONNECTOR_HDMIA, 194 + NULL, 195 + max_bpc); 196 + KUNIT_ASSERT_EQ(test, ret, 0); 197 + 198 + drm_connector_helper_add(conn, &dummy_connector_helper_funcs); 199 + drm_connector_attach_encoder(conn, enc); 200 + 201 + drm_mode_config_reset(drm); 202 + 203 + ret = set_connector_edid(test, conn, 204 + test_edid_hdmi_1080p_rgb_max_200mhz, 205 + ARRAY_SIZE(test_edid_hdmi_1080p_rgb_max_200mhz)); 206 + KUNIT_ASSERT_EQ(test, ret, 0); 207 + 208 + return priv; 209 + } 210 + 211 + /* 212 + * Test that if we change the maximum bpc property to a different value, 213 + * we trigger a mode change on the connector's CRTC, which will in turn 214 + * disable/enable the connector. 215 + */ 216 + static void drm_test_check_output_bpc_crtc_mode_changed(struct kunit *test) 217 + { 218 + struct drm_atomic_helper_connector_hdmi_priv *priv; 219 + struct drm_modeset_acquire_ctx *ctx; 220 + struct drm_connector_state *old_conn_state; 221 + struct drm_connector_state *new_conn_state; 222 + struct drm_crtc_state *crtc_state; 223 + struct drm_atomic_state *state; 224 + struct drm_display_mode *preferred; 225 + struct drm_connector *conn; 226 + struct drm_device *drm; 227 + struct drm_crtc *crtc; 228 + int ret; 229 + 230 + priv = drm_atomic_helper_connector_hdmi_init(test, 10); 231 + KUNIT_ASSERT_NOT_NULL(test, priv); 232 + 233 + ctx = drm_kunit_helper_acquire_ctx_alloc(test); 234 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 235 + 236 + conn = &priv->connector; 237 + preferred = find_preferred_mode(conn); 238 + KUNIT_ASSERT_NOT_NULL(test, preferred); 239 + 240 + drm = &priv->drm; 241 + crtc = priv->crtc; 242 + ret = light_up_connector(test, drm, crtc, conn, preferred, ctx); 243 + KUNIT_ASSERT_EQ(test, ret, 0); 244 + 245 + state = drm_kunit_helper_atomic_state_alloc(test, drm, ctx); 246 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); 247 + 248 + new_conn_state = drm_atomic_get_connector_state(state, conn); 249 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, new_conn_state); 250 + 251 + old_conn_state = drm_atomic_get_old_connector_state(state, conn); 252 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, old_conn_state); 253 + 254 + new_conn_state->hdmi.output_bpc = 8; 255 + 256 + KUNIT_ASSERT_NE(test, 257 + old_conn_state->hdmi.output_bpc, 258 + new_conn_state->hdmi.output_bpc); 259 + 260 + ret = drm_atomic_check_only(state); 261 + KUNIT_ASSERT_EQ(test, ret, 0); 262 + 263 + old_conn_state = drm_atomic_get_old_connector_state(state, conn); 264 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, old_conn_state); 265 + 266 + new_conn_state = drm_atomic_get_new_connector_state(state, conn); 267 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, new_conn_state); 268 + 269 + KUNIT_ASSERT_NE(test, 270 + old_conn_state->hdmi.output_bpc, 271 + new_conn_state->hdmi.output_bpc); 272 + 273 + crtc_state = drm_atomic_get_new_crtc_state(state, crtc); 274 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, crtc_state); 275 + KUNIT_EXPECT_TRUE(test, crtc_state->mode_changed); 276 + } 277 + 278 + /* 279 + * Test that if we set the output bpc property to the same value, we 280 + * don't trigger a mode change on the connector's CRTC and leave the 281 + * connector unaffected. 282 + */ 283 + static void drm_test_check_output_bpc_crtc_mode_not_changed(struct kunit *test) 284 + { 285 + struct drm_atomic_helper_connector_hdmi_priv *priv; 286 + struct drm_modeset_acquire_ctx *ctx; 287 + struct drm_connector_state *old_conn_state; 288 + struct drm_connector_state *new_conn_state; 289 + struct drm_crtc_state *crtc_state; 290 + struct drm_atomic_state *state; 291 + struct drm_display_mode *preferred; 292 + struct drm_connector *conn; 293 + struct drm_device *drm; 294 + struct drm_crtc *crtc; 295 + int ret; 296 + 297 + priv = drm_atomic_helper_connector_hdmi_init(test, 10); 298 + KUNIT_ASSERT_NOT_NULL(test, priv); 299 + 300 + ctx = drm_kunit_helper_acquire_ctx_alloc(test); 301 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); 302 + 303 + conn = &priv->connector; 304 + preferred = find_preferred_mode(conn); 305 + KUNIT_ASSERT_NOT_NULL(test, preferred); 306 + 307 + drm = &priv->drm; 308 + crtc = priv->crtc; 309 + ret = light_up_connector(test, drm, crtc, conn, preferred, ctx); 310 + KUNIT_ASSERT_EQ(test, ret, 0); 311 + 312 + state = drm_kunit_helper_atomic_state_alloc(test, drm, ctx); 313 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); 314 + 315 + new_conn_state = drm_atomic_get_connector_state(state, conn); 316 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, new_conn_state); 317 + 318 + old_conn_state = drm_atomic_get_old_connector_state(state, conn); 319 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, old_conn_state); 320 + 321 + KUNIT_ASSERT_EQ(test, 322 + new_conn_state->hdmi.output_bpc, 323 + old_conn_state->hdmi.output_bpc); 324 + 325 + ret = drm_atomic_check_only(state); 326 + KUNIT_ASSERT_EQ(test, ret, 0); 327 + 328 + old_conn_state = drm_atomic_get_old_connector_state(state, conn); 329 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, old_conn_state); 330 + 331 + new_conn_state = drm_atomic_get_new_connector_state(state, conn); 332 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, new_conn_state); 333 + 334 + KUNIT_EXPECT_EQ(test, 335 + old_conn_state->hdmi.output_bpc, 336 + new_conn_state->hdmi.output_bpc); 337 + 338 + crtc_state = drm_atomic_get_new_crtc_state(state, crtc); 339 + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, crtc_state); 340 + KUNIT_EXPECT_FALSE(test, crtc_state->mode_changed); 341 + } 342 + 343 + static struct kunit_case drm_atomic_helper_connector_hdmi_check_tests[] = { 344 + KUNIT_CASE(drm_test_check_output_bpc_crtc_mode_changed), 345 + KUNIT_CASE(drm_test_check_output_bpc_crtc_mode_not_changed), 346 + { } 347 + }; 348 + 349 + static struct kunit_suite drm_atomic_helper_connector_hdmi_check_test_suite = { 350 + .name = "drm_atomic_helper_connector_hdmi_check", 351 + .test_cases = drm_atomic_helper_connector_hdmi_check_tests, 352 + }; 353 + 354 + /* 355 + * Test that if the connector was initialised with a maximum bpc of 8, 356 + * the value of the max_bpc and max_requested_bpc properties out of 357 + * reset are also set to 8, and output_bpc is set to 0 and will be 358 + * filled at atomic_check time. 359 + */ 360 + static void drm_test_check_bpc_8_value(struct kunit *test) 361 + { 362 + struct drm_atomic_helper_connector_hdmi_priv *priv; 363 + struct drm_connector_state *conn_state; 364 + struct drm_connector *conn; 365 + 366 + priv = drm_atomic_helper_connector_hdmi_init(test, 8); 367 + KUNIT_ASSERT_NOT_NULL(test, priv); 368 + 369 + conn = &priv->connector; 370 + conn_state = conn->state; 371 + KUNIT_EXPECT_EQ(test, conn_state->max_bpc, 8); 372 + KUNIT_EXPECT_EQ(test, conn_state->max_requested_bpc, 8); 373 + KUNIT_EXPECT_EQ(test, conn_state->hdmi.output_bpc, 0); 374 + } 375 + 376 + /* 377 + * Test that if the connector was initialised with a maximum bpc of 10, 378 + * the value of the max_bpc and max_requested_bpc properties out of 379 + * reset are also set to 10, and output_bpc is set to 0 and will be 380 + * filled at atomic_check time. 381 + */ 382 + static void drm_test_check_bpc_10_value(struct kunit *test) 383 + { 384 + struct drm_atomic_helper_connector_hdmi_priv *priv; 385 + struct drm_connector_state *conn_state; 386 + struct drm_connector *conn; 387 + 388 + priv = drm_atomic_helper_connector_hdmi_init(test, 10); 389 + KUNIT_ASSERT_NOT_NULL(test, priv); 390 + 391 + conn = &priv->connector; 392 + conn_state = conn->state; 393 + KUNIT_EXPECT_EQ(test, conn_state->max_bpc, 10); 394 + KUNIT_EXPECT_EQ(test, conn_state->max_requested_bpc, 10); 395 + KUNIT_EXPECT_EQ(test, conn_state->hdmi.output_bpc, 0); 396 + } 397 + 398 + /* 399 + * Test that if the connector was initialised with a maximum bpc of 12, 400 + * the value of the max_bpc and max_requested_bpc properties out of 401 + * reset are also set to 12, and output_bpc is set to 0 and will be 402 + * filled at atomic_check time. 403 + */ 404 + static void drm_test_check_bpc_12_value(struct kunit *test) 405 + { 406 + struct drm_atomic_helper_connector_hdmi_priv *priv; 407 + struct drm_connector_state *conn_state; 408 + struct drm_connector *conn; 409 + 410 + priv = drm_atomic_helper_connector_hdmi_init(test, 12); 411 + KUNIT_ASSERT_NOT_NULL(test, priv); 412 + 413 + conn = &priv->connector; 414 + conn_state = conn->state; 415 + KUNIT_EXPECT_EQ(test, conn_state->max_bpc, 12); 416 + KUNIT_EXPECT_EQ(test, conn_state->max_requested_bpc, 12); 417 + KUNIT_EXPECT_EQ(test, conn_state->hdmi.output_bpc, 0); 418 + } 419 + 420 + static struct kunit_case drm_atomic_helper_connector_hdmi_reset_tests[] = { 421 + KUNIT_CASE(drm_test_check_bpc_8_value), 422 + KUNIT_CASE(drm_test_check_bpc_10_value), 423 + KUNIT_CASE(drm_test_check_bpc_12_value), 424 + { } 425 + }; 426 + 427 + static struct kunit_suite drm_atomic_helper_connector_hdmi_reset_test_suite = { 428 + .name = "drm_atomic_helper_connector_hdmi_reset", 429 + .test_cases = drm_atomic_helper_connector_hdmi_reset_tests, 430 + }; 431 + 432 + kunit_test_suites( 433 + &drm_atomic_helper_connector_hdmi_check_test_suite, 434 + &drm_atomic_helper_connector_hdmi_reset_test_suite, 435 + ); 436 + 437 + MODULE_AUTHOR("Maxime Ripard <mripard@kernel.org>"); 438 + MODULE_LICENSE("GPL");
+108
drivers/gpu/drm/tests/drm_kunit_edid.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + 3 + #ifndef DRM_KUNIT_EDID_H_ 4 + #define DRM_KUNIT_EDID_H_ 5 + 6 + /* 7 + * edid-decode (hex): 8 + * 9 + * 00 ff ff ff ff ff ff 00 31 d8 2a 00 00 00 00 00 10 + * 00 21 01 03 81 a0 5a 78 02 00 00 00 00 00 00 00 11 + * 00 00 00 20 00 00 01 01 01 01 01 01 01 01 01 01 12 + * 01 01 01 01 01 01 02 3a 80 18 71 38 2d 40 58 2c 13 + * 45 00 40 84 63 00 00 1e 00 00 00 fc 00 54 65 73 14 + * 74 20 45 44 49 44 0a 20 20 20 00 00 00 fd 00 32 15 + * 46 1e 46 0f 00 0a 20 20 20 20 20 20 00 00 00 10 16 + * 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 92 17 + * 18 + * 02 03 1b 81 e3 05 00 20 41 10 e2 00 4a 6d 03 0c 19 + * 00 12 34 00 28 20 00 00 00 00 00 00 00 00 00 00 20 + * 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 21 + * 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 22 + * 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 23 + * 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 24 + * 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 25 + * 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 d0 26 + * 27 + * ---------------- 28 + * 29 + * Block 0, Base EDID: 30 + * EDID Structure Version & Revision: 1.3 31 + * Vendor & Product Identification: 32 + * Manufacturer: LNX 33 + * Model: 42 34 + * Made in: 2023 35 + * Basic Display Parameters & Features: 36 + * Digital display 37 + * DFP 1.x compatible TMDS 38 + * Maximum image size: 160 cm x 90 cm 39 + * Gamma: 2.20 40 + * Monochrome or grayscale display 41 + * First detailed timing is the preferred timing 42 + * Color Characteristics: 43 + * Red : 0.0000, 0.0000 44 + * Green: 0.0000, 0.0000 45 + * Blue : 0.0000, 0.0000 46 + * White: 0.0000, 0.0000 47 + * Established Timings I & II: 48 + * DMT 0x04: 640x480 59.940476 Hz 4:3 31.469 kHz 25.175000 MHz 49 + * Standard Timings: none 50 + * Detailed Timing Descriptors: 51 + * DTD 1: 1920x1080 60.000000 Hz 16:9 67.500 kHz 148.500000 MHz (1600 mm x 900 mm) 52 + * Hfront 88 Hsync 44 Hback 148 Hpol P 53 + * Vfront 4 Vsync 5 Vback 36 Vpol P 54 + * Display Product Name: 'Test EDID' 55 + * Display Range Limits: 56 + * Monitor ranges (GTF): 50-70 Hz V, 30-70 kHz H, max dotclock 150 MHz 57 + * Dummy Descriptor: 58 + * Extension blocks: 1 59 + * Checksum: 0x92 60 + * 61 + * ---------------- 62 + * 63 + * Block 1, CTA-861 Extension Block: 64 + * Revision: 3 65 + * Underscans IT Video Formats by default 66 + * Native detailed modes: 1 67 + * Colorimetry Data Block: 68 + * sRGB 69 + * Video Data Block: 70 + * VIC 16: 1920x1080 60.000000 Hz 16:9 67.500 kHz 148.500000 MHz 71 + * Video Capability Data Block: 72 + * YCbCr quantization: No Data 73 + * RGB quantization: Selectable (via AVI Q) 74 + * PT scan behavior: No Data 75 + * IT scan behavior: Always Underscanned 76 + * CE scan behavior: Always Underscanned 77 + * Vendor-Specific Data Block (HDMI), OUI 00-0C-03: 78 + * Source physical address: 1.2.3.4 79 + * Maximum TMDS clock: 200 MHz 80 + * Extended HDMI video details: 81 + * Checksum: 0xd0 Unused space in Extension Block: 100 bytes 82 + */ 83 + static const unsigned char test_edid_hdmi_1080p_rgb_max_200mhz[] = { 84 + 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x31, 0xd8, 0x2a, 0x00, 85 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x01, 0x03, 0x81, 0xa0, 0x5a, 0x78, 86 + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 87 + 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 88 + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x3a, 0x80, 0x18, 0x71, 0x38, 89 + 0x2d, 0x40, 0x58, 0x2c, 0x45, 0x00, 0x40, 0x84, 0x63, 0x00, 0x00, 0x1e, 90 + 0x00, 0x00, 0x00, 0xfc, 0x00, 0x54, 0x65, 0x73, 0x74, 0x20, 0x45, 0x44, 91 + 0x49, 0x44, 0x0a, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x32, 92 + 0x46, 0x00, 0x00, 0xc4, 0x00, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 93 + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 94 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x41, 0x02, 0x03, 0x1b, 0x81, 95 + 0xe3, 0x05, 0x00, 0x20, 0x41, 0x10, 0xe2, 0x00, 0x4a, 0x6d, 0x03, 0x0c, 96 + 0x00, 0x12, 0x34, 0x00, 0x28, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 97 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 98 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 99 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 100 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 101 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 102 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 103 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 104 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 105 + 0x00, 0x00, 0x00, 0xd0 106 + }; 107 + 108 + #endif // DRM_KUNIT_EDID_H_