drivers/gpu/drm/tests/drm_panic_test.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/tests/drm_panic_test.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/tests/drm_panic_test.c
Extension
.c
Size
5921 bytes
Lines
222
Domain
Driver Families
Bucket
drivers/gpu
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct drm_test_mode {
	const int width;
	const int height;
	const u32 format;
	void (*draw_screen)(struct drm_scanout_buffer *sb);
	const char *fname;
};

/*
 * Run all tests for the 3 panic screens: user, kmsg and qr_code
 */
#define DRM_TEST_MODE_LIST(func) \
	DRM_PANIC_TEST_MODE(1024, 768, DRM_FORMAT_XRGB8888, func) \
	DRM_PANIC_TEST_MODE(300, 200, DRM_FORMAT_XRGB8888, func) \
	DRM_PANIC_TEST_MODE(1920, 1080, DRM_FORMAT_XRGB8888, func) \
	DRM_PANIC_TEST_MODE(1024, 768, DRM_FORMAT_RGB565, func) \
	DRM_PANIC_TEST_MODE(1024, 768, DRM_FORMAT_RGB888, func) \

#define DRM_PANIC_TEST_MODE(w, h, f, name) { \
	.width = w, \
	.height = h, \
	.format = f, \
	.draw_screen = draw_panic_screen_##name, \
	.fname = #name, \
	}, \

static const struct drm_test_mode drm_test_modes_cases[] = {
	DRM_TEST_MODE_LIST(user)
	DRM_TEST_MODE_LIST(kmsg)
#if IS_ENABLED(CONFIG_DRM_PANIC_SCREEN_QR_CODE)
	DRM_TEST_MODE_LIST(qr_code)
#endif
};

#undef DRM_PANIC_TEST_MODE

static int drm_test_panic_init(struct kunit *test)
{
	struct drm_scanout_buffer *priv;

	priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL);
	KUNIT_ASSERT_NOT_NULL(test, priv);

	test->priv = priv;

	drm_panic_set_description("Kunit testing");

	return 0;
}

/*
 * Test drawing the panic screen, using a memory mapped framebuffer
 * Set the whole buffer to 0xa5, and then check that all pixels have been
 * written.
 */
static void drm_test_panic_screen_user_map(struct kunit *test)
{
	struct drm_scanout_buffer *sb = test->priv;
	const struct drm_test_mode *params = test->param_value;
	char *fb;
	int fb_size;
	int i;

	sb->format = drm_format_info(params->format);
	fb_size = params->width * params->height * sb->format->cpp[0];

	fb = vmalloc(fb_size);
	KUNIT_ASSERT_NOT_NULL(test, fb);

	memset(fb, 0xa5, fb_size);

	iosys_map_set_vaddr(&sb->map[0], fb);
	sb->width = params->width;
	sb->height = params->height;
	sb->pitch[0] = params->width * sb->format->cpp[0];

	params->draw_screen(sb);

	for (i = 0; i < fb_size; i++)
		drm_panic_check_color_byte(test, fb[i]);

	vfree(fb);
}

/*
 * Test drawing the panic screen, using a list of pages framebuffer
 * Set the whole buffer to 0xa5, and then check that all pixels have been
 * written.
 */
static void drm_test_panic_screen_user_page(struct kunit *test)

Annotation

Implementation Notes