Skip to content

Commit 40275dc

Browse files
committed
drm: simple_kms_helper: Add mode_valid() callback support
The PL111 needs to filter valid modes based on memory bandwidth. I guess it is a pretty simple operation, so we can still claim the DRM KMS helper pipeline is simple after adding this (optional) vtable callback. Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> Signed-off-by: Linus Walleij <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 1aecabb commit 40275dc

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

drivers/gpu/drm/drm_simple_kms_helper.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,20 @@ static const struct drm_encoder_funcs drm_simple_kms_encoder_funcs = {
3434
.destroy = drm_encoder_cleanup,
3535
};
3636

37+
static enum drm_mode_status
38+
drm_simple_kms_crtc_mode_valid(struct drm_crtc *crtc,
39+
const struct drm_display_mode *mode)
40+
{
41+
struct drm_simple_display_pipe *pipe;
42+
43+
pipe = container_of(crtc, struct drm_simple_display_pipe, crtc);
44+
if (!pipe->funcs || !pipe->funcs->mode_valid)
45+
/* Anything goes */
46+
return MODE_OK;
47+
48+
return pipe->funcs->mode_valid(crtc, mode);
49+
}
50+
3751
static int drm_simple_kms_crtc_check(struct drm_crtc *crtc,
3852
struct drm_crtc_state *state)
3953
{
@@ -72,6 +86,7 @@ static void drm_simple_kms_crtc_disable(struct drm_crtc *crtc,
7286
}
7387

7488
static const struct drm_crtc_helper_funcs drm_simple_kms_crtc_helper_funcs = {
89+
.mode_valid = drm_simple_kms_crtc_mode_valid,
7590
.atomic_check = drm_simple_kms_crtc_check,
7691
.atomic_enable = drm_simple_kms_crtc_enable,
7792
.atomic_disable = drm_simple_kms_crtc_disable,

include/drm/drm_simple_kms_helper.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,20 @@ struct drm_simple_display_pipe;
2121
* display pipeline
2222
*/
2323
struct drm_simple_display_pipe_funcs {
24+
/**
25+
* @mode_valid:
26+
*
27+
* This function is called to filter out valid modes from the
28+
* suggestions suggested by the bridge or display. This optional
29+
* hook is passed in when initializing the pipeline.
30+
*
31+
* RETURNS:
32+
*
33+
* drm_mode_status Enum
34+
*/
35+
enum drm_mode_status (*mode_valid)(struct drm_crtc *crtc,
36+
const struct drm_display_mode *mode);
37+
2438
/**
2539
* @enable:
2640
*

0 commit comments

Comments
 (0)