• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1  /*
2   * Copyright (C) 2017 The Android Open Source Project
3   *
4   * Licensed under the Apache License, Version 2.0 (the "License");
5   * you may not use this file except in compliance with the License.
6   * You may obtain a copy of the License at
7   *
8   *      http://www.apache.org/licenses/LICENSE-2.0
9   *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  #ifndef _GRAPHICS_DRM_H_
18  #define _GRAPHICS_DRM_H_
19  
20  #include <stdint.h>
21  
22  #include <xf86drmMode.h>
23  
24  #include "graphics.h"
25  #include "minui/minui.h"
26  
27  class GRSurfaceDrm : public GRSurface {
28   private:
29    uint32_t fb_id;
30    uint32_t handle;
31  
32    friend class MinuiBackendDrm;
33  };
34  
35  class MinuiBackendDrm : public MinuiBackend {
36   public:
37    GRSurface* Init() override;
38    GRSurface* Flip() override;
39    void Blank(bool) override;
40    ~MinuiBackendDrm() override;
41    MinuiBackendDrm();
42  
43   private:
44    void DrmDisableCrtc(int drm_fd, drmModeCrtc* crtc);
45    void DrmEnableCrtc(int drm_fd, drmModeCrtc* crtc, GRSurfaceDrm* surface);
46    GRSurfaceDrm* DrmCreateSurface(int width, int height);
47    void DrmDestroySurface(GRSurfaceDrm* surface);
48    void DisableNonMainCrtcs(int fd, drmModeRes* resources, drmModeCrtc* main_crtc);
49    drmModeConnector* FindMainMonitor(int fd, drmModeRes* resources, uint32_t* mode_index);
50  
51    GRSurfaceDrm* GRSurfaceDrms[2];
52    int current_buffer;
53    drmModeCrtc* main_monitor_crtc;
54    drmModeConnector* main_monitor_connector;
55    int drm_fd;
56  };
57  
58  #endif  // _GRAPHICS_DRM_H_
59