]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blame - include/drm/drm_simple_kms_helper.h
drm: fix drm_get_max_iomem type mismatch
[mirror_ubuntu-eoan-kernel.git] / include / drm / drm_simple_kms_helper.h
CommitLineData
5b809074
NT
1/*
2 * Copyright (C) 2016 Noralf Trønnes
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 */
9
10#ifndef __LINUX_DRM_SIMPLE_KMS_HELPER_H
11#define __LINUX_DRM_SIMPLE_KMS_HELPER_H
12
a6a9534c
NT
13#include <drm/drm_crtc.h>
14#include <drm/drm_encoder.h>
15#include <drm/drm_plane.h>
16
5b809074
NT
17struct drm_simple_display_pipe;
18
19/**
20 * struct drm_simple_display_pipe_funcs - helper operations for a simple
21 * display pipeline
22 */
23struct drm_simple_display_pipe_funcs {
40275dc4
LW
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
5b809074
NT
38 /**
39 * @enable:
40 *
41 * This function should be used to enable the pipeline.
42 * It is called when the underlying crtc is enabled.
43 * This hook is optional.
44 */
45 void (*enable)(struct drm_simple_display_pipe *pipe,
46 struct drm_crtc_state *crtc_state);
47 /**
48 * @disable:
49 *
50 * This function should be used to disable the pipeline.
51 * It is called when the underlying crtc is disabled.
52 * This hook is optional.
53 */
54 void (*disable)(struct drm_simple_display_pipe *pipe);
55
56 /**
57 * @check:
58 *
59 * This function is called in the check phase of an atomic update,
60 * specifically when the underlying plane is checked.
61 * The simple display pipeline helpers already check that the plane is
62 * not scaled, fills the entire visible area and is always enabled
63 * when the crtc is also enabled.
64 * This hook is optional.
65 *
66 * RETURNS:
67 *
68 * 0 on success, -EINVAL if the state or the transition can't be
69 * supported, -ENOMEM on memory allocation failure and -EDEADLK if an
70 * attempt to obtain another state object ran into a &drm_modeset_lock
71 * deadlock.
72 */
73 int (*check)(struct drm_simple_display_pipe *pipe,
74 struct drm_plane_state *plane_state,
75 struct drm_crtc_state *crtc_state);
76 /**
77 * @update:
78 *
79 * This function is called when the underlying plane state is updated.
80 * This hook is optional.
6dcf0de7
DV
81 *
82 * This is the function drivers should submit the
83 * &drm_pending_vblank_event from. Using either
84 * drm_crtc_arm_vblank_event(), when the driver supports vblank
85 * interrupt handling, or drm_crtc_send_vblank_event() directly in case
86 * the hardware lacks vblank support entirely.
5b809074
NT
87 */
88 void (*update)(struct drm_simple_display_pipe *pipe,
bcd2ba02 89 struct drm_plane_state *old_plane_state);
7d83a155
MV
90
91 /**
92 * @prepare_fb:
93 *
6806cdf9
DV
94 * Optional, called by &drm_plane_helper_funcs.prepare_fb. Please read
95 * the documentation for the &drm_plane_helper_funcs.prepare_fb hook for
96 * more details.
7d83a155
MV
97 */
98 int (*prepare_fb)(struct drm_simple_display_pipe *pipe,
99 struct drm_plane_state *plane_state);
100
101 /**
102 * @cleanup_fb:
103 *
6806cdf9
DV
104 * Optional, called by &drm_plane_helper_funcs.cleanup_fb. Please read
105 * the documentation for the &drm_plane_helper_funcs.cleanup_fb hook for
106 * more details.
7d83a155
MV
107 */
108 void (*cleanup_fb)(struct drm_simple_display_pipe *pipe,
109 struct drm_plane_state *plane_state);
5b809074
NT
110};
111
112/**
113 * struct drm_simple_display_pipe - simple display pipeline
114 * @crtc: CRTC control structure
115 * @plane: Plane control structure
116 * @encoder: Encoder control structure
117 * @connector: Connector control structure
118 * @funcs: Pipeline control functions (optional)
119 *
120 * Simple display pipeline with plane, crtc and encoder collapsed into one
121 * entity. It should be initialized by calling drm_simple_display_pipe_init().
122 */
123struct drm_simple_display_pipe {
124 struct drm_crtc crtc;
125 struct drm_plane plane;
126 struct drm_encoder encoder;
127 struct drm_connector *connector;
128
129 const struct drm_simple_display_pipe_funcs *funcs;
130};
131
315486c6
AM
132int drm_simple_display_pipe_attach_bridge(struct drm_simple_display_pipe *pipe,
133 struct drm_bridge *bridge);
134
5b809074
NT
135int drm_simple_display_pipe_init(struct drm_device *dev,
136 struct drm_simple_display_pipe *pipe,
137 const struct drm_simple_display_pipe_funcs *funcs,
138 const uint32_t *formats, unsigned int format_count,
e6fc3b68 139 const uint64_t *format_modifiers,
5b809074
NT
140 struct drm_connector *connector);
141
142#endif /* __LINUX_DRM_SIMPLE_KMS_HELPER_H */