Giulio Camuffo | 1c0e40d | 2016-04-29 15:40:34 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2008-2011 Kristian Høgsberg |
| 3 | * Copyright © 2011 Intel Corporation |
| 4 | * Copyright © 2015 Giulio Camuffo |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining |
| 7 | * a copy of this software and associated documentation files (the |
| 8 | * "Software"), to deal in the Software without restriction, including |
| 9 | * without limitation the rights to use, copy, modify, merge, publish, |
| 10 | * distribute, sublicense, and/or sell copies of the Software, and to |
| 11 | * permit persons to whom the Software is furnished to do so, subject to |
| 12 | * the following conditions: |
| 13 | * |
| 14 | * The above copyright notice and this permission notice (including the |
| 15 | * next paragraph) shall be included in all copies or substantial |
| 16 | * portions of the Software. |
| 17 | * |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 22 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 23 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 24 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 25 | * SOFTWARE. |
| 26 | */ |
| 27 | |
| 28 | #ifndef WESTON_COMPOSITOR_DRM_H |
| 29 | #define WESTON_COMPOSITOR_DRM_H |
| 30 | |
| 31 | #include "compositor.h" |
Armin Krezović | 0836813 | 2016-09-30 14:11:05 +0200 | [diff] [blame] | 32 | #include "plugin-registry.h" |
Giulio Camuffo | 1c0e40d | 2016-04-29 15:40:34 -0700 | [diff] [blame] | 33 | |
| 34 | #ifdef __cplusplus |
| 35 | extern "C" { |
| 36 | #endif |
| 37 | |
Armin Krezović | 0836813 | 2016-09-30 14:11:05 +0200 | [diff] [blame] | 38 | #define WESTON_DRM_BACKEND_CONFIG_VERSION 2 |
Giulio Camuffo | 1c0e40d | 2016-04-29 15:40:34 -0700 | [diff] [blame] | 39 | |
Giulio Camuffo | 8aedf7b | 2016-06-02 21:48:12 +0300 | [diff] [blame] | 40 | struct libinput_device; |
| 41 | |
Giulio Camuffo | 1c0e40d | 2016-04-29 15:40:34 -0700 | [diff] [blame] | 42 | enum weston_drm_backend_output_mode { |
| 43 | /** The output is disabled */ |
| 44 | WESTON_DRM_BACKEND_OUTPUT_OFF, |
| 45 | /** The output will use the current active mode */ |
| 46 | WESTON_DRM_BACKEND_OUTPUT_CURRENT, |
| 47 | /** The output will use the preferred mode. A modeline can be provided |
| 48 | * by setting weston_backend_output_config::modeline in the form of |
| 49 | * "WIDTHxHEIGHT" or in the form of an explicit modeline calculated |
| 50 | * using e.g. the cvt tool. If a valid modeline is supplied it will be |
| 51 | * used, if invalid or NULL the preferred available mode will be used. */ |
| 52 | WESTON_DRM_BACKEND_OUTPUT_PREFERRED, |
| 53 | }; |
| 54 | |
Armin Krezović | 0836813 | 2016-09-30 14:11:05 +0200 | [diff] [blame] | 55 | #define WESTON_DRM_OUTPUT_API_NAME "weston_drm_output_api_v1" |
| 56 | |
| 57 | struct weston_drm_output_api { |
| 58 | /** The mode to be used by the output. Refer to the documentation |
| 59 | * of WESTON_DRM_BACKEND_OUTPUT_PREFERRED for details. |
| 60 | * |
| 61 | * Returns 0 on success, -1 on failure. |
| 62 | */ |
| 63 | int (*set_mode)(struct weston_output *output, |
| 64 | enum weston_drm_backend_output_mode mode, |
| 65 | const char *modeline); |
Giulio Camuffo | 1c0e40d | 2016-04-29 15:40:34 -0700 | [diff] [blame] | 66 | |
| 67 | /** The pixel format to be used by the output. Valid values are: |
| 68 | * - NULL - The format set at backend creation time will be used; |
| 69 | * - "xrgb8888"; |
| 70 | * - "rgb565" |
| 71 | * - "xrgb2101010" |
| 72 | */ |
Armin Krezović | 0836813 | 2016-09-30 14:11:05 +0200 | [diff] [blame] | 73 | void (*set_gbm_format)(struct weston_output *output, |
| 74 | const char *gbm_format); |
| 75 | |
Giulio Camuffo | 1c0e40d | 2016-04-29 15:40:34 -0700 | [diff] [blame] | 76 | /** The seat to be used by the output. Set to NULL to use the |
Armin Krezović | 0836813 | 2016-09-30 14:11:05 +0200 | [diff] [blame] | 77 | * default seat. |
| 78 | */ |
| 79 | void (*set_seat)(struct weston_output *output, |
| 80 | const char *seat); |
Giulio Camuffo | 1c0e40d | 2016-04-29 15:40:34 -0700 | [diff] [blame] | 81 | }; |
| 82 | |
Armin Krezović | 0836813 | 2016-09-30 14:11:05 +0200 | [diff] [blame] | 83 | static inline const struct weston_drm_output_api * |
| 84 | weston_drm_output_get_api(struct weston_compositor *compositor) |
| 85 | { |
| 86 | const void *api; |
| 87 | api = weston_plugin_api_get(compositor, WESTON_DRM_OUTPUT_API_NAME, |
| 88 | sizeof(struct weston_drm_output_api)); |
| 89 | |
| 90 | return (const struct weston_drm_output_api *)api; |
| 91 | } |
| 92 | |
Giulio Camuffo | 1c0e40d | 2016-04-29 15:40:34 -0700 | [diff] [blame] | 93 | /** The backend configuration struct. |
| 94 | * |
| 95 | * weston_drm_backend_config contains the configuration used by a DRM |
| 96 | * backend. |
| 97 | */ |
| 98 | struct weston_drm_backend_config { |
| 99 | struct weston_backend_config base; |
| 100 | |
| 101 | /** The connector id of the output to be initialized. |
| 102 | * |
| 103 | * A value of 0 will enable all available outputs. |
| 104 | */ |
| 105 | int connector; |
| 106 | |
| 107 | /** The tty to be used. Set to 0 to use the current tty. */ |
| 108 | int tty; |
| 109 | |
| 110 | /** Whether to use the pixman renderer instead of the OpenGL ES renderer. */ |
| 111 | bool use_pixman; |
| 112 | |
| 113 | /** The seat to be used for input and output. |
| 114 | * |
| 115 | * If NULL the default "seat0" will be used. The backend will |
| 116 | * take ownership of the seat_id pointer and will free it on |
| 117 | * backend destruction. |
| 118 | */ |
| 119 | char *seat_id; |
| 120 | |
| 121 | /** The pixel format of the framebuffer to be used. |
| 122 | * |
| 123 | * Valid values are: |
| 124 | * - NULL - The default format ("xrgb8888") will be used; |
| 125 | * - "xrgb8888"; |
| 126 | * - "rgb565" |
| 127 | * - "xrgb2101010" |
| 128 | * The backend will take ownership of the format pointer and will free |
| 129 | * it on backend destruction. |
| 130 | */ |
| 131 | char *gbm_format; |
| 132 | |
Giulio Camuffo | 8aedf7b | 2016-06-02 21:48:12 +0300 | [diff] [blame] | 133 | /** Callback used to configure input devices. |
| 134 | * |
| 135 | * This function will be called by the backend when a new input device |
| 136 | * needs to be configured. |
| 137 | * If NULL the device will use the default configuration. |
| 138 | */ |
| 139 | void (*configure_device)(struct weston_compositor *compositor, |
| 140 | struct libinput_device *device); |
Emmanuel Gil Peyrot | 11ae2a3 | 2017-03-07 13:27:54 +0000 | [diff] [blame] | 141 | |
| 142 | /** Maximum duration for a pageflip event to arrive, after which the |
| 143 | * compositor will consider the DRM driver crashed and will try to exit |
| 144 | * cleanly. |
| 145 | * |
| 146 | * It is exprimed in milliseconds, 0 means disabled. */ |
| 147 | uint32_t pageflip_timeout; |
Giulio Camuffo | 1c0e40d | 2016-04-29 15:40:34 -0700 | [diff] [blame] | 148 | }; |
| 149 | |
| 150 | #ifdef __cplusplus |
| 151 | } |
| 152 | #endif |
| 153 | |
| 154 | #endif /* WESTON_COMPOSITOR_DRM_H */ |