drivers/gpu/drm/tests/drm_damage_helper_test.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/tests/drm_damage_helper_test.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/tests/drm_damage_helper_test.c- Extension
.c- Size
- 22468 bytes
- Lines
- 641
- 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.
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
kunit/test.hdrm/drm_damage_helper.hdrm/drm_framebuffer.hdrm/drm_plane.hdrm/drm_drv.h
Detected Declarations
struct drm_damage_mockfunction drm_damage_helper_initfunction set_plane_srcfunction set_damage_clipfunction set_damage_blobfunction set_plane_damagefunction check_damage_clipfunction drm_test_damage_iter_no_damagefunction drm_test_damage_iter_no_damage_fractional_srcfunction drm_test_damage_iter_no_damage_src_movedfunction drm_test_damage_iter_no_damage_fractional_src_movedfunction drm_test_damage_iter_no_damage_not_visiblefunction drm_test_damage_iter_no_damage_no_crtcfunction drm_test_damage_iter_no_damage_no_fbfunction drm_test_damage_iter_simple_damagefunction drm_test_damage_iter_single_damagefunction drm_test_damage_iter_single_damage_intersect_srcfunction drm_test_damage_iter_single_damage_outside_srcfunction drm_test_damage_iter_single_damage_fractional_srcfunction drm_test_damage_iter_single_damage_intersect_fractional_srcfunction drm_test_damage_iter_single_damage_outside_fractional_srcfunction drm_test_damage_iter_single_damage_src_movedfunction drm_test_damage_iter_single_damage_fractional_src_movedfunction drm_test_damage_iter_damagefunction drm_test_damage_iter_damage_one_intersectfunction drm_test_damage_iter_damage_one_outsidefunction drm_test_damage_iter_damage_src_movedfunction drm_test_damage_iter_damage_not_visible
Annotated Snippet
struct drm_damage_mock {
struct drm_driver driver;
struct drm_device device;
struct drm_object_properties obj_props;
struct drm_plane plane;
struct drm_property prop;
struct drm_framebuffer fb;
struct drm_plane_state state;
struct drm_plane_state old_state;
};
static int drm_damage_helper_init(struct kunit *test)
{
struct drm_damage_mock *mock;
mock = kunit_kzalloc(test, sizeof(*mock), GFP_KERNEL);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, mock);
mock->fb.width = 2048;
mock->fb.height = 2048;
mock->state.crtc = ZERO_SIZE_PTR;
mock->state.fb = &mock->fb;
mock->state.visible = true;
mock->old_state.plane = &mock->plane;
mock->state.plane = &mock->plane;
/* just enough so that drm_plane_enable_fb_damage_clips() works */
mock->device.driver = &mock->driver;
mock->device.mode_config.prop_fb_damage_clips = &mock->prop;
mock->plane.dev = &mock->device;
mock->obj_props.count = 0;
mock->plane.base.properties = &mock->obj_props;
mock->prop.base.id = 1; /* 0 is an invalid id */
mock->prop.dev = &mock->device;
drm_plane_enable_fb_damage_clips(&mock->plane);
test->priv = mock;
return 0;
}
static void set_plane_src(struct drm_plane_state *state, int x1, int y1, int x2,
int y2)
{
state->src_x = x1;
state->src_y = y1;
state->src_w = x2 - x1;
state->src_h = y2 - y1;
state->src.x1 = x1;
state->src.y1 = y1;
state->src.x2 = x2;
state->src.y2 = y2;
}
static void set_damage_clip(struct drm_mode_rect *r, int x1, int y1, int x2,
int y2)
{
r->x1 = x1;
r->y1 = y1;
r->x2 = x2;
r->y2 = y2;
}
static void set_damage_blob(struct drm_property_blob *damage_blob,
struct drm_mode_rect *r, u32 size)
{
damage_blob->length = size;
damage_blob->data = r;
}
static void set_plane_damage(struct drm_plane_state *state,
struct drm_property_blob *damage_blob)
{
state->fb_damage_clips = damage_blob;
}
static void check_damage_clip(struct kunit *test, struct drm_rect *r,
int x1, int y1, int x2, int y2)
{
struct drm_damage_mock *mock = test->priv;
struct drm_plane_state state = mock->state;
/*
* Round down x1/y1 and round up x2/y2. This is because damage is not in
* 16.16 fixed point so to catch all pixels.
*/
Annotation
- Immediate include surface: `kunit/test.h`, `drm/drm_damage_helper.h`, `drm/drm_framebuffer.h`, `drm/drm_plane.h`, `drm/drm_drv.h`.
- Detected declarations: `struct drm_damage_mock`, `function drm_damage_helper_init`, `function set_plane_src`, `function set_damage_clip`, `function set_damage_blob`, `function set_plane_damage`, `function check_damage_clip`, `function drm_test_damage_iter_no_damage`, `function drm_test_damage_iter_no_damage_fractional_src`, `function drm_test_damage_iter_no_damage_src_moved`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.