Noralf Trønnes | 5b80907 | 2016-06-10 16:55:59 +0200 | [diff] [blame] | 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 | |
Noralf Trønnes | a6a9534 | 2017-01-22 19:11:11 +0100 | [diff] [blame] | 13 | #include <drm/drm_crtc.h> |
| 14 | #include <drm/drm_encoder.h> |
| 15 | #include <drm/drm_plane.h> |
| 16 | |
Noralf Trønnes | 5b80907 | 2016-06-10 16:55:59 +0200 | [diff] [blame] | 17 | struct drm_simple_display_pipe; |
| 18 | |
| 19 | /** |
| 20 | * struct drm_simple_display_pipe_funcs - helper operations for a simple |
| 21 | * display pipeline |
| 22 | */ |
| 23 | struct drm_simple_display_pipe_funcs { |
| 24 | /** |
Linus Walleij | 40275dc | 2018-02-20 08:28:59 +0100 | [diff] [blame] | 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 | |
| 38 | /** |
Noralf Trønnes | 5b80907 | 2016-06-10 16:55:59 +0200 | [diff] [blame] | 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. |
Daniel Vetter | 6dcf0de | 2016-08-23 08:25:40 +0200 | [diff] [blame] | 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. |
Noralf Trønnes | 5b80907 | 2016-06-10 16:55:59 +0200 | [diff] [blame] | 87 | */ |
| 88 | void (*update)(struct drm_simple_display_pipe *pipe, |
Eric Anholt | bcd2ba0 | 2017-03-20 16:36:15 -0700 | [diff] [blame] | 89 | struct drm_plane_state *old_plane_state); |
Marek Vasut | 7d83a15 | 2016-10-02 19:01:24 +0200 | [diff] [blame] | 90 | |
| 91 | /** |
| 92 | * @prepare_fb: |
| 93 | * |
Daniel Vetter | 6806cdf | 2017-01-25 07:26:43 +0100 | [diff] [blame] | 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. |
Marek Vasut | 7d83a15 | 2016-10-02 19:01:24 +0200 | [diff] [blame] | 97 | */ |
| 98 | int (*prepare_fb)(struct drm_simple_display_pipe *pipe, |
| 99 | struct drm_plane_state *plane_state); |
| 100 | |
| 101 | /** |
| 102 | * @cleanup_fb: |
| 103 | * |
Daniel Vetter | 6806cdf | 2017-01-25 07:26:43 +0100 | [diff] [blame] | 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. |
Marek Vasut | 7d83a15 | 2016-10-02 19:01:24 +0200 | [diff] [blame] | 107 | */ |
| 108 | void (*cleanup_fb)(struct drm_simple_display_pipe *pipe, |
| 109 | struct drm_plane_state *plane_state); |
Oleksandr Andrushchenko | ac86cba | 2018-02-12 10:52:51 +0200 | [diff] [blame] | 110 | |
| 111 | /** |
| 112 | * @enable_vblank: |
| 113 | * |
| 114 | * Optional, called by &drm_crtc_funcs.enable_vblank. Please read |
| 115 | * the documentation for the &drm_crtc_funcs.enable_vblank hook for |
| 116 | * more details. |
| 117 | */ |
| 118 | int (*enable_vblank)(struct drm_simple_display_pipe *pipe); |
| 119 | |
| 120 | /** |
| 121 | * @disable_vblank: |
| 122 | * |
| 123 | * Optional, called by &drm_crtc_funcs.disable_vblank. Please read |
| 124 | * the documentation for the &drm_crtc_funcs.disable_vblank hook for |
| 125 | * more details. |
| 126 | */ |
| 127 | void (*disable_vblank)(struct drm_simple_display_pipe *pipe); |
Noralf Trønnes | 5b80907 | 2016-06-10 16:55:59 +0200 | [diff] [blame] | 128 | }; |
| 129 | |
| 130 | /** |
| 131 | * struct drm_simple_display_pipe - simple display pipeline |
| 132 | * @crtc: CRTC control structure |
| 133 | * @plane: Plane control structure |
| 134 | * @encoder: Encoder control structure |
| 135 | * @connector: Connector control structure |
| 136 | * @funcs: Pipeline control functions (optional) |
| 137 | * |
| 138 | * Simple display pipeline with plane, crtc and encoder collapsed into one |
| 139 | * entity. It should be initialized by calling drm_simple_display_pipe_init(). |
| 140 | */ |
| 141 | struct drm_simple_display_pipe { |
| 142 | struct drm_crtc crtc; |
| 143 | struct drm_plane plane; |
| 144 | struct drm_encoder encoder; |
| 145 | struct drm_connector *connector; |
| 146 | |
| 147 | const struct drm_simple_display_pipe_funcs *funcs; |
| 148 | }; |
| 149 | |
Andrea Merello | 315486c | 2016-08-25 11:04:34 +0200 | [diff] [blame] | 150 | int drm_simple_display_pipe_attach_bridge(struct drm_simple_display_pipe *pipe, |
| 151 | struct drm_bridge *bridge); |
| 152 | |
Noralf Trønnes | 5b80907 | 2016-06-10 16:55:59 +0200 | [diff] [blame] | 153 | int drm_simple_display_pipe_init(struct drm_device *dev, |
| 154 | struct drm_simple_display_pipe *pipe, |
| 155 | const struct drm_simple_display_pipe_funcs *funcs, |
| 156 | const uint32_t *formats, unsigned int format_count, |
Ben Widawsky | e6fc3b6 | 2017-07-23 20:46:38 -0700 | [diff] [blame] | 157 | const uint64_t *format_modifiers, |
Noralf Trønnes | 5b80907 | 2016-06-10 16:55:59 +0200 | [diff] [blame] | 158 | struct drm_connector *connector); |
| 159 | |
| 160 | #endif /* __LINUX_DRM_SIMPLE_KMS_HELPER_H */ |