2016-04-30 01:40:34 +03:00
|
|
|
/*
|
|
|
|
* Copyright © 2008-2011 Kristian Høgsberg
|
|
|
|
* Copyright © 2011 Intel Corporation
|
|
|
|
* Copyright © 2015 Giulio Camuffo
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
* a copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
* the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the
|
|
|
|
* next paragraph) shall be included in all copies or substantial
|
|
|
|
* portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef WESTON_COMPOSITOR_DRM_H
|
|
|
|
#define WESTON_COMPOSITOR_DRM_H
|
|
|
|
|
2019-03-28 17:28:47 +03:00
|
|
|
#include <libweston/libweston.h>
|
2019-03-29 18:07:34 +03:00
|
|
|
#include <libweston/plugin-registry.h>
|
2016-04-30 01:40:34 +03:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2022-12-29 21:14:52 +03:00
|
|
|
#define WESTON_DRM_BACKEND_CONFIG_VERSION 6
|
2016-04-30 01:40:34 +03:00
|
|
|
|
2016-06-02 21:48:12 +03:00
|
|
|
struct libinput_device;
|
|
|
|
|
2016-04-30 01:40:34 +03:00
|
|
|
enum weston_drm_backend_output_mode {
|
|
|
|
/** The output is disabled */
|
|
|
|
WESTON_DRM_BACKEND_OUTPUT_OFF,
|
|
|
|
/** The output will use the current active mode */
|
|
|
|
WESTON_DRM_BACKEND_OUTPUT_CURRENT,
|
|
|
|
/** The output will use the preferred mode. A modeline can be provided
|
|
|
|
* by setting weston_backend_output_config::modeline in the form of
|
|
|
|
* "WIDTHxHEIGHT" or in the form of an explicit modeline calculated
|
|
|
|
* using e.g. the cvt tool. If a valid modeline is supplied it will be
|
|
|
|
* used, if invalid or NULL the preferred available mode will be used. */
|
|
|
|
WESTON_DRM_BACKEND_OUTPUT_PREFERRED,
|
|
|
|
};
|
|
|
|
|
2016-09-30 15:11:05 +03:00
|
|
|
#define WESTON_DRM_OUTPUT_API_NAME "weston_drm_output_api_v1"
|
|
|
|
|
|
|
|
struct weston_drm_output_api {
|
|
|
|
/** The mode to be used by the output. Refer to the documentation
|
|
|
|
* of WESTON_DRM_BACKEND_OUTPUT_PREFERRED for details.
|
|
|
|
*
|
|
|
|
* Returns 0 on success, -1 on failure.
|
|
|
|
*/
|
|
|
|
int (*set_mode)(struct weston_output *output,
|
|
|
|
enum weston_drm_backend_output_mode mode,
|
|
|
|
const char *modeline);
|
2016-04-30 01:40:34 +03:00
|
|
|
|
|
|
|
/** The pixel format to be used by the output. Valid values are:
|
|
|
|
* - NULL - The format set at backend creation time will be used;
|
|
|
|
* - "xrgb8888";
|
|
|
|
* - "rgb565"
|
|
|
|
* - "xrgb2101010"
|
|
|
|
*/
|
2016-09-30 15:11:05 +03:00
|
|
|
void (*set_gbm_format)(struct weston_output *output,
|
|
|
|
const char *gbm_format);
|
|
|
|
|
2016-04-30 01:40:34 +03:00
|
|
|
/** The seat to be used by the output. Set to NULL to use the
|
2016-09-30 15:11:05 +03:00
|
|
|
* default seat.
|
|
|
|
*/
|
|
|
|
void (*set_seat)(struct weston_output *output,
|
|
|
|
const char *seat);
|
2021-07-21 17:45:14 +03:00
|
|
|
|
|
|
|
/** Set the "max bpc" KMS connector property
|
|
|
|
*
|
|
|
|
* The property is used for working around faulty sink hardware like
|
|
|
|
* monitors or media converters that mishandle the kernel driver
|
|
|
|
* chosen bits-per-channel on the physical link. When having trouble,
|
2022-09-07 18:34:17 +03:00
|
|
|
* try a lower value like 8. A value of 0 means that the current max
|
|
|
|
* bpc will be reprogrammed.
|
2021-07-21 17:45:14 +03:00
|
|
|
*
|
|
|
|
* The value actually used in KMS is silently clamped to the range the
|
|
|
|
* KMS driver claims to support. The default value is 16.
|
|
|
|
*
|
|
|
|
* This can be set only while the output is disabled.
|
|
|
|
*/
|
|
|
|
void (*set_max_bpc)(struct weston_output *output, unsigned max_bpc);
|
2021-10-02 18:10:37 +03:00
|
|
|
|
|
|
|
/** The content type primarily used on the output. Valid values are:
|
|
|
|
* - NULL or "no data" - No information is provided about the usage of the
|
|
|
|
* output
|
|
|
|
* - "graphics"
|
|
|
|
* - "photo"
|
|
|
|
* - "cinema"
|
|
|
|
* - "game"
|
|
|
|
*/
|
|
|
|
int (*set_content_type)(struct weston_output *output,
|
|
|
|
const char *content_type);
|
2016-04-30 01:40:34 +03:00
|
|
|
};
|
|
|
|
|
2016-09-30 15:11:05 +03:00
|
|
|
static inline const struct weston_drm_output_api *
|
|
|
|
weston_drm_output_get_api(struct weston_compositor *compositor)
|
|
|
|
{
|
|
|
|
const void *api;
|
|
|
|
api = weston_plugin_api_get(compositor, WESTON_DRM_OUTPUT_API_NAME,
|
|
|
|
sizeof(struct weston_drm_output_api));
|
|
|
|
|
|
|
|
return (const struct weston_drm_output_api *)api;
|
|
|
|
}
|
|
|
|
|
2021-05-11 18:22:50 +03:00
|
|
|
#define WESTON_DRM_VIRTUAL_OUTPUT_API_NAME "weston_drm_virtual_output_api_v2"
|
2018-01-31 11:50:48 +03:00
|
|
|
|
|
|
|
struct drm_fb;
|
|
|
|
typedef int (*submit_frame_cb)(struct weston_output *output, int fd,
|
|
|
|
int stride, struct drm_fb *buffer);
|
|
|
|
|
|
|
|
struct weston_drm_virtual_output_api {
|
|
|
|
/** Create virtual output.
|
|
|
|
* This is a low-level function, where the caller is expected to wrap
|
|
|
|
* the weston_output function pointers as necessary to make the virtual
|
|
|
|
* output useful. The caller must set up output make, model, serial,
|
2021-05-11 18:22:50 +03:00
|
|
|
* physical size, the mode list and current mode. The destroy function
|
|
|
|
* pointer must not be overwritten, as it is used by the DRM backend to
|
|
|
|
* recognize its outputs. Instead, an auxiliary destroy callback has to
|
|
|
|
* be provided as a parameter.
|
2018-01-31 11:50:48 +03:00
|
|
|
*
|
|
|
|
* Returns output on success, NULL on failure.
|
|
|
|
*/
|
|
|
|
struct weston_output* (*create_output)(struct weston_compositor *c,
|
2021-05-11 18:22:50 +03:00
|
|
|
char *name,
|
|
|
|
void (*destroy_func)(struct weston_output *base));
|
2018-01-31 11:50:48 +03:00
|
|
|
|
|
|
|
/** Set pixel format same as drm_output set_gbm_format().
|
|
|
|
*
|
|
|
|
* Returns the set format.
|
|
|
|
*/
|
|
|
|
uint32_t (*set_gbm_format)(struct weston_output *output,
|
|
|
|
const char *gbm_format);
|
|
|
|
|
|
|
|
/** Set a callback to be called when the DRM-backend has drawn a new
|
|
|
|
* frame and submits it for display.
|
|
|
|
* The callback will deliver a buffer to the virtual output's the
|
|
|
|
* owner and assumes the buffer is now reserved for the owner. The
|
|
|
|
* callback is called in virtual output repaint function.
|
|
|
|
* The caller must call buffer_released() and finish_frame().
|
|
|
|
*
|
|
|
|
* The callback parameters are output, FD and stride (bytes) of dmabuf,
|
|
|
|
* and buffer (drm_fb) pointer.
|
|
|
|
* The callback returns 0 on success, -1 on failure.
|
|
|
|
*
|
|
|
|
* The submit_frame_cb callback hook is responsible for closing the fd
|
|
|
|
* if it returns success. One needs to call the buffer release and
|
|
|
|
* finish frame functions if and only if this hook returns success.
|
|
|
|
*/
|
|
|
|
void (*set_submit_frame_cb)(struct weston_output *output,
|
|
|
|
submit_frame_cb cb);
|
|
|
|
|
|
|
|
/** Get fd for renderer fence.
|
|
|
|
* The returned fence signals when the renderer job has completed and
|
|
|
|
* the buffer is fully drawn.
|
|
|
|
*
|
|
|
|
* Returns fd on success, -1 on failure.
|
|
|
|
*/
|
|
|
|
int (*get_fence_sync_fd)(struct weston_output *output);
|
|
|
|
|
|
|
|
/** Notify that the caller has finished using buffer */
|
|
|
|
void (*buffer_released)(struct drm_fb *fb);
|
|
|
|
|
|
|
|
/** Notify finish frame
|
|
|
|
* This function allows the output repainting mechanism to advance to
|
|
|
|
* the next frame.
|
|
|
|
*/
|
|
|
|
void (*finish_frame)(struct weston_output *output,
|
|
|
|
struct timespec *stamp,
|
|
|
|
uint32_t presented_flags);
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline const struct weston_drm_virtual_output_api *
|
|
|
|
weston_drm_virtual_output_get_api(struct weston_compositor *compositor)
|
|
|
|
{
|
|
|
|
const void *api;
|
|
|
|
api = weston_plugin_api_get(compositor,
|
|
|
|
WESTON_DRM_VIRTUAL_OUTPUT_API_NAME,
|
|
|
|
sizeof(struct weston_drm_virtual_output_api));
|
|
|
|
return (const struct weston_drm_virtual_output_api *)api;
|
|
|
|
}
|
|
|
|
|
2016-04-30 01:40:34 +03:00
|
|
|
/** The backend configuration struct.
|
|
|
|
*
|
|
|
|
* weston_drm_backend_config contains the configuration used by a DRM
|
|
|
|
* backend.
|
|
|
|
*/
|
|
|
|
struct weston_drm_backend_config {
|
|
|
|
struct weston_backend_config base;
|
|
|
|
|
2022-12-29 21:14:52 +03:00
|
|
|
/** Select the renderer type to use */
|
|
|
|
enum weston_renderer_type renderer;
|
2016-04-30 01:40:34 +03:00
|
|
|
|
|
|
|
/** The seat to be used for input and output.
|
|
|
|
*
|
2018-06-29 15:17:46 +03:00
|
|
|
* If seat_id is NULL, the seat is taken from XDG_SEAT environment
|
|
|
|
* variable. If neither is set, "seat0" is used. The backend will
|
2016-04-30 01:40:34 +03:00
|
|
|
* take ownership of the seat_id pointer and will free it on
|
|
|
|
* backend destruction.
|
|
|
|
*/
|
|
|
|
char *seat_id;
|
|
|
|
|
|
|
|
/** The pixel format of the framebuffer to be used.
|
|
|
|
*
|
|
|
|
* Valid values are:
|
|
|
|
* - NULL - The default format ("xrgb8888") will be used;
|
|
|
|
* - "xrgb8888";
|
|
|
|
* - "rgb565"
|
|
|
|
* - "xrgb2101010"
|
|
|
|
* The backend will take ownership of the format pointer and will free
|
|
|
|
* it on backend destruction.
|
|
|
|
*/
|
|
|
|
char *gbm_format;
|
|
|
|
|
2016-06-02 21:48:12 +03:00
|
|
|
/** Callback used to configure input devices.
|
|
|
|
*
|
|
|
|
* This function will be called by the backend when a new input device
|
|
|
|
* needs to be configured.
|
|
|
|
* If NULL the device will use the default configuration.
|
|
|
|
*/
|
|
|
|
void (*configure_device)(struct weston_compositor *compositor,
|
|
|
|
struct libinput_device *device);
|
2017-03-07 16:27:54 +03:00
|
|
|
|
|
|
|
/** Maximum duration for a pageflip event to arrive, after which the
|
|
|
|
* compositor will consider the DRM driver crashed and will try to exit
|
|
|
|
* cleanly.
|
|
|
|
*
|
|
|
|
* It is exprimed in milliseconds, 0 means disabled. */
|
|
|
|
uint32_t pageflip_timeout;
|
2017-03-28 18:04:27 +03:00
|
|
|
|
|
|
|
/** Specific DRM device to open
|
|
|
|
*
|
|
|
|
* A DRM device name, like "card0", to open. If NULL, use heuristics
|
|
|
|
* based on seat names and boot_vga to find the right device.
|
|
|
|
*/
|
|
|
|
char *specific_device;
|
2018-04-23 12:44:58 +03:00
|
|
|
|
|
|
|
/** Use shadow buffer if using Pixman-renderer. */
|
|
|
|
bool use_pixman_shadow;
|
2021-11-11 19:40:54 +03:00
|
|
|
|
|
|
|
/** Additional DRM devices to open
|
|
|
|
*
|
|
|
|
* A comma-separated list of DRM devices names, like "card1", to open.
|
|
|
|
* The devices will be used as additional scanout devices, but not as a
|
|
|
|
* rendering device.
|
|
|
|
*/
|
|
|
|
char *additional_devices;
|
2016-04-30 01:40:34 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* WESTON_COMPOSITOR_DRM_H */
|