Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Mesa 3-D graphics library
  3.  *
  4.  * Copyright (C) 2010 Chia-I Wu <olv@0xlab.org>
  5.  *
  6.  * Permission is hereby granted, free of charge, to any person obtaining a
  7.  * copy of this software and associated documentation files (the "Software"),
  8.  * to deal in the Software without restriction, including without limitation
  9.  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10.  * and/or sell copies of the Software, and to permit persons to whom the
  11.  * Software is furnished to do so, subject to the following conditions:
  12.  *
  13.  * The above copyright notice and this permission notice shall be included
  14.  * in all copies or substantial portions of the Software.
  15.  *
  16.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17.  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18.  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  19.  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20.  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  21.  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  22.  * DEALINGS IN THE SOFTWARE.
  23.  */
  24.  
  25. #ifndef _NATIVE_DRM_H_
  26. #define _NATIVE_DRM_H_
  27.  
  28. #include <xf86drm.h>
  29. #include <xf86drmMode.h>
  30.  
  31. #include "pipe/p_compiler.h"
  32. #include "util/u_format.h"
  33. #include "pipe/p_state.h"
  34. #include "state_tracker/drm_driver.h"
  35.  
  36. #include "common/native.h"
  37. #include "common/native_helper.h"
  38.  
  39. #ifdef HAVE_WAYLAND_BACKEND
  40. #include "common/native_wayland_drm_bufmgr_helper.h"
  41. #endif
  42.  
  43. #include "gbm_gallium_drmint.h"
  44.  
  45. struct drm_config;
  46. struct drm_crtc;
  47. struct drm_connector;
  48. struct drm_mode;
  49. struct drm_surface;
  50.  
  51. struct drm_display {
  52.    struct native_display base;
  53.  
  54.    const struct native_event_handler *event_handler;
  55.  
  56.    struct gbm_gallium_drm_device *gbmdrm;
  57.    int own_gbm;
  58.    int fd;
  59.    char *device_name;
  60.    struct drm_config *config;
  61.  
  62.    /* for modesetting */
  63.    drmModeResPtr resources;
  64.    struct drm_connector *connectors;
  65.    int num_connectors;
  66.  
  67.    struct drm_surface **shown_surfaces;
  68.    /* save the original settings of the CRTCs */
  69.    struct drm_crtc *saved_crtcs;
  70.  
  71. #ifdef HAVE_WAYLAND_BACKEND
  72.    struct wl_drm *wl_server_drm; /* for EGL_WL_bind_wayland_display */
  73. #endif
  74. };
  75.  
  76. struct drm_config {
  77.    struct native_config base;
  78. };
  79.  
  80. struct drm_crtc {
  81.    drmModeCrtcPtr crtc;
  82.    uint32_t connectors[32];
  83.    int num_connectors;
  84. };
  85.  
  86. struct drm_framebuffer {
  87.    struct pipe_resource *texture;
  88.    boolean is_passive;
  89.  
  90.    uint32_t buffer_id;
  91. };
  92.  
  93. struct drm_surface {
  94.    struct native_surface base;
  95.    struct drm_display *drmdpy;
  96.  
  97.    struct resource_surface *rsurf;
  98.    enum pipe_format color_format;
  99.    int width, height;
  100.  
  101.    unsigned int sequence_number;
  102.    struct drm_framebuffer front_fb, back_fb;
  103.  
  104.    boolean is_shown;
  105.    struct drm_crtc current_crtc;
  106.  
  107.    boolean have_pageflip;
  108. };
  109.  
  110. struct drm_connector {
  111.    struct native_connector base;
  112.  
  113.    uint32_t connector_id;
  114.    drmModeConnectorPtr connector;
  115.    struct drm_mode *drm_modes;
  116.    int num_modes;
  117. };
  118.  
  119. struct drm_mode {
  120.    struct native_mode base;
  121.    drmModeModeInfo mode;
  122. };
  123.  
  124. static INLINE struct drm_display *
  125. drm_display(const struct native_display *ndpy)
  126. {
  127.    return (struct drm_display *) ndpy;
  128. }
  129.  
  130. static INLINE struct drm_config *
  131. drm_config(const struct native_config *nconf)
  132. {
  133.    return (struct drm_config *) nconf;
  134. }
  135.  
  136. static INLINE struct drm_surface *
  137. drm_surface(const struct native_surface *nsurf)
  138. {
  139.    return (struct drm_surface *) nsurf;
  140. }
  141.  
  142. static INLINE struct drm_connector *
  143. drm_connector(const struct native_connector *nconn)
  144. {
  145.    return (struct drm_connector *) nconn;
  146. }
  147.  
  148. static INLINE struct drm_mode *
  149. drm_mode(const struct native_mode *nmode)
  150. {
  151.    return (struct drm_mode *) nmode;
  152. }
  153.  
  154. boolean
  155. drm_display_init_modeset(struct native_display *ndpy);
  156.  
  157. void
  158. drm_display_fini_modeset(struct native_display *ndpy);
  159.  
  160. struct native_surface *
  161. drm_display_create_surface_from_resource(struct native_display *ndpy,
  162.                                          struct pipe_resource *resource);
  163.  
  164. #endif /* _NATIVE_DRM_H_ */
  165.