blob: 6d9adbb46293310cb09780ec509f048b94642a41 [file] [log] [blame]
Noralf Trønnes5b809072016-06-10 16:55:59 +02001/*
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
Noralf Trønnesa6a95342017-01-22 19:11:11 +010013#include <drm/drm_crtc.h>
14#include <drm/drm_encoder.h>
15#include <drm/drm_plane.h>
16
Noralf Trønnes5b809072016-06-10 16:55:59 +020017struct 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 {
24 /**
25 * @enable:
26 *
27 * This function should be used to enable the pipeline.
28 * It is called when the underlying crtc is enabled.
29 * This hook is optional.
30 */
31 void (*enable)(struct drm_simple_display_pipe *pipe,
32 struct drm_crtc_state *crtc_state);
33 /**
34 * @disable:
35 *
36 * This function should be used to disable the pipeline.
37 * It is called when the underlying crtc is disabled.
38 * This hook is optional.
39 */
40 void (*disable)(struct drm_simple_display_pipe *pipe);
41
42 /**
43 * @check:
44 *
45 * This function is called in the check phase of an atomic update,
46 * specifically when the underlying plane is checked.
47 * The simple display pipeline helpers already check that the plane is
48 * not scaled, fills the entire visible area and is always enabled
49 * when the crtc is also enabled.
50 * This hook is optional.
51 *
52 * RETURNS:
53 *
54 * 0 on success, -EINVAL if the state or the transition can't be
55 * supported, -ENOMEM on memory allocation failure and -EDEADLK if an
56 * attempt to obtain another state object ran into a &drm_modeset_lock
57 * deadlock.
58 */
59 int (*check)(struct drm_simple_display_pipe *pipe,
60 struct drm_plane_state *plane_state,
61 struct drm_crtc_state *crtc_state);
62 /**
63 * @update:
64 *
65 * This function is called when the underlying plane state is updated.
66 * This hook is optional.
Daniel Vetter6dcf0de2016-08-23 08:25:40 +020067 *
68 * This is the function drivers should submit the
69 * &drm_pending_vblank_event from. Using either
70 * drm_crtc_arm_vblank_event(), when the driver supports vblank
71 * interrupt handling, or drm_crtc_send_vblank_event() directly in case
72 * the hardware lacks vblank support entirely.
Noralf Trønnes5b809072016-06-10 16:55:59 +020073 */
74 void (*update)(struct drm_simple_display_pipe *pipe,
Eric Anholtbcd2ba02017-03-20 16:36:15 -070075 struct drm_plane_state *old_plane_state);
Marek Vasut7d83a152016-10-02 19:01:24 +020076
77 /**
78 * @prepare_fb:
79 *
Daniel Vetter6806cdf2017-01-25 07:26:43 +010080 * Optional, called by &drm_plane_helper_funcs.prepare_fb. Please read
81 * the documentation for the &drm_plane_helper_funcs.prepare_fb hook for
82 * more details.
Marek Vasut7d83a152016-10-02 19:01:24 +020083 */
84 int (*prepare_fb)(struct drm_simple_display_pipe *pipe,
85 struct drm_plane_state *plane_state);
86
87 /**
88 * @cleanup_fb:
89 *
Daniel Vetter6806cdf2017-01-25 07:26:43 +010090 * Optional, called by &drm_plane_helper_funcs.cleanup_fb. Please read
91 * the documentation for the &drm_plane_helper_funcs.cleanup_fb hook for
92 * more details.
Marek Vasut7d83a152016-10-02 19:01:24 +020093 */
94 void (*cleanup_fb)(struct drm_simple_display_pipe *pipe,
95 struct drm_plane_state *plane_state);
Noralf Trønnes5b809072016-06-10 16:55:59 +020096};
97
98/**
99 * struct drm_simple_display_pipe - simple display pipeline
100 * @crtc: CRTC control structure
101 * @plane: Plane control structure
102 * @encoder: Encoder control structure
103 * @connector: Connector control structure
104 * @funcs: Pipeline control functions (optional)
105 *
106 * Simple display pipeline with plane, crtc and encoder collapsed into one
107 * entity. It should be initialized by calling drm_simple_display_pipe_init().
108 */
109struct drm_simple_display_pipe {
110 struct drm_crtc crtc;
111 struct drm_plane plane;
112 struct drm_encoder encoder;
113 struct drm_connector *connector;
114
115 const struct drm_simple_display_pipe_funcs *funcs;
116};
117
Andrea Merello315486c2016-08-25 11:04:34 +0200118int drm_simple_display_pipe_attach_bridge(struct drm_simple_display_pipe *pipe,
119 struct drm_bridge *bridge);
120
Noralf Trønnes5b809072016-06-10 16:55:59 +0200121int drm_simple_display_pipe_init(struct drm_device *dev,
122 struct drm_simple_display_pipe *pipe,
123 const struct drm_simple_display_pipe_funcs *funcs,
124 const uint32_t *formats, unsigned int format_count,
Ben Widawskye6fc3b62017-07-23 20:46:38 -0700125 const uint64_t *format_modifiers,
Noralf Trønnes5b809072016-06-10 16:55:59 +0200126 struct drm_connector *connector);
127
128#endif /* __LINUX_DRM_SIMPLE_KMS_HELPER_H */