1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// SPDX-FileCopyrightText: (c) 2026 Joel Winarske
// SPDX-License-Identifier: MIT
//! How big the cursor buffer is.
//!
//! Two decisions. What size to ask for, which depends on the path and what the
//! driver advertises; and what size to settle on, which depends on what the
//! kernel will actually accept. The second needs a device, so it takes the
//! probe as a parameter and everything here stays testable.
use cratePlanePath;
/// What every driver hard-codes for `drmModeSetCursor`, and the floor
/// everywhere else.
///
/// The legacy call has no capability query, so there is nothing to ask.
const LEGACY_SIZE: u32 = 64;
/// Sizes worth probing, largest first.
///
/// Not a range: these are the sizes real hardware implements. i915 does 64,
/// amdgpu 256, and asking for anything between them gets rounded or refused
/// depending on the driver, so there is no point walking one pixel at a time.
const LADDER: = ;
/// The size to ask for, before finding out what is accepted.
///
/// A caller who names a size gets it considered as-is. Otherwise the atomic
/// paths take what the driver advertises through `DRM_CAP_CURSOR_WIDTH`, so a
/// plane that wants 256 gets 256; legacy takes 64, because that is what the
/// call means.
/// Settle on a buffer size, asking `accepts` what the kernel will take.
///
/// Walks the ladder downward from `preferred`, and never above it: a caller
/// who asked for a small cursor does not get a large one because the driver
/// could manage it.
///
/// When nothing is accepted the answer is `preferred`, floored at 64 — there
/// has to be a buffer either way, and the first real commit will surface the
/// kernel's objection if there is one. That case is usually not about size at
/// all: with no mode set yet, every `TEST_ONLY` fails for unrelated reasons.