Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: ui/ozone/platform/drm/gpu/drm_device.h

Issue 1124063003: drm: GPU process manages VGEM fd. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase to ToT Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/ozone/common/gpu/ozone_gpu_messages.h ('k') | ui/ozone/platform/drm/gpu/drm_device.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_OZONE_PLATFORM_DRM_GPU_DRM_DEVICE_H_ 5 #ifndef UI_OZONE_PLATFORM_DRM_GPU_DRM_DEVICE_H_
6 #define UI_OZONE_PLATFORM_DRM_GPU_DRM_DEVICE_H_ 6 #define UI_OZONE_PLATFORM_DRM_GPU_DRM_DEVICE_H_
7 7
8 #include <stdint.h>
9
10 #include <vector>
11
12 #include "base/callback.h" 8 #include "base/callback.h"
13 #include "base/files/file.h" 9 #include "base/files/file.h"
14 #include "base/files/file_path.h"
15 #include "base/macros.h"
16 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
17 #include "base/memory/scoped_vector.h" 11 #include "base/memory/scoped_vector.h"
18 #include "ui/gfx/geometry/rect.h" 12 #include "ui/gfx/geometry/rect.h"
19 #include "ui/gfx/geometry/rect_f.h" 13 #include "ui/gfx/geometry/rect_f.h"
20 #include "ui/gfx/overlay_transform.h" 14 #include "ui/gfx/overlay_transform.h"
21 #include "ui/ozone/ozone_export.h" 15 #include "ui/ozone/ozone_export.h"
22 #include "ui/ozone/platform/drm/common/scoped_drm_types.h" 16 #include "ui/ozone/platform/drm/common/scoped_drm_types.h"
23 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager.h" 17 #include "ui/ozone/platform/drm/gpu/hardware_display_plane_manager.h"
24 18
25 typedef struct _drmEventContext drmEventContext; 19 typedef struct _drmEventContext drmEventContext;
26 typedef struct _drmModeModeInfo drmModeModeInfo; 20 typedef struct _drmModeModeInfo drmModeModeInfo;
27 21
28 struct SkImageInfo; 22 struct SkImageInfo;
29 23
30 namespace base { 24 namespace base {
31 class SingleThreadTaskRunner; 25 class SingleThreadTaskRunner;
32 } // namespace base 26 } // namespace base
33 27
34 namespace ui { 28 namespace ui {
35 29
36 class HardwareDisplayPlaneManager; 30 class HardwareDisplayPlaneManager;
37 struct GammaRampRGBEntry; 31 struct GammaRampRGBEntry;
38 32
33 // Wraps /dev/dri/cardX device.
34 class OZONE_EXPORT DrmDeviceBase
35 : public base::RefCountedThreadSafe<DrmDeviceBase> {
36 public:
37 // |task_runner| will be used to asynchronously page flip.
38 virtual void InitializeTaskRunner(
39 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) = 0;
40
41 enum Type { DRM, VGEM };
42 virtual Type GetType() const = 0;
43
44 int get_fd() const { return file_.GetPlatformFile(); }
45 base::FilePath device_path() const { return device_path_; }
46
47 protected:
48 friend class base::RefCountedThreadSafe<DrmDeviceBase>;
49 DrmDeviceBase(const base::FilePath& device_path, base::File file);
50 virtual ~DrmDeviceBase();
51
52 // Path to GEM device.
53 const base::FilePath device_path_;
54
55 // GEM device.
56 base::File file_;
57
58 private:
59 DISALLOW_COPY_AND_ASSIGN(DrmDeviceBase);
60 };
61
39 // Wraps DRM calls into a nice interface. Used to provide different 62 // Wraps DRM calls into a nice interface. Used to provide different
40 // implementations of the DRM calls. For the actual implementation the DRM API 63 // implementations of the DRM calls. For the actual implementation the DRM API
41 // would be called. In unit tests this interface would be stubbed. 64 // would be called. In unit tests this interface would be stubbed.
42 class OZONE_EXPORT DrmDevice : public base::RefCountedThreadSafe<DrmDevice> { 65 class OZONE_EXPORT DrmDevice : public DrmDeviceBase {
43 public: 66 public:
44 typedef base::Callback<void(unsigned int /* frame */, 67 typedef base::Callback<void(unsigned int /* frame */,
45 unsigned int /* seconds */, 68 unsigned int /* seconds */,
46 unsigned int /* useconds */)> PageFlipCallback; 69 unsigned int /* useconds */)> PageFlipCallback;
47 70
48 DrmDevice(const base::FilePath& device_path);
49 DrmDevice(const base::FilePath& device_path, base::File file); 71 DrmDevice(const base::FilePath& device_path, base::File file);
50 72
73 // GemDevice implementation:
74 void InitializeTaskRunner(
75 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) override;
76 Type GetType() const override;
77
51 // Open device. 78 // Open device.
52 virtual bool Initialize(); 79 virtual bool Initialize();
53 80
54 // |task_runner| will be used to asynchronously page flip.
55 virtual void InitializeTaskRunner(
56 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
57
58 // Get the CRTC state. This is generally used to save state before using the 81 // Get the CRTC state. This is generally used to save state before using the
59 // CRTC. When the user finishes using the CRTC, the user should restore the 82 // CRTC. When the user finishes using the CRTC, the user should restore the
60 // CRTC to it's initial state. Use |SetCrtc| to restore the state. 83 // CRTC to it's initial state. Use |SetCrtc| to restore the state.
61 virtual ScopedDrmCrtcPtr GetCrtc(uint32_t crtc_id); 84 virtual ScopedDrmCrtcPtr GetCrtc(uint32_t crtc_id);
62 85
63 // Used to configure CRTC with ID |crtc_id| to use the connector in 86 // Used to configure CRTC with ID |crtc_id| to use the connector in
64 // |connectors|. The CRTC will be configured with mode |mode| and will display 87 // |connectors|. The CRTC will be configured with mode |mode| and will display
65 // the framebuffer with ID |framebuffer|. Before being able to display the 88 // the framebuffer with ID |framebuffer|. Before being able to display the
66 // framebuffer, it should be registered with the CRTC using |AddFramebuffer|. 89 // framebuffer, it should be registered with the CRTC using |AddFramebuffer|.
67 virtual bool SetCrtc(uint32_t crtc_id, 90 virtual bool SetCrtc(uint32_t crtc_id,
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // Set the gamma ramp for |crtc_id| to reflect the ramps in |lut|. 188 // Set the gamma ramp for |crtc_id| to reflect the ramps in |lut|.
166 virtual bool SetGammaRamp(uint32_t crtc_id, 189 virtual bool SetGammaRamp(uint32_t crtc_id,
167 const std::vector<GammaRampRGBEntry>& lut); 190 const std::vector<GammaRampRGBEntry>& lut);
168 191
169 virtual bool SetCapability(uint64_t capability, uint64_t value); 192 virtual bool SetCapability(uint64_t capability, uint64_t value);
170 193
171 // Drm master related 194 // Drm master related
172 virtual bool SetMaster(); 195 virtual bool SetMaster();
173 virtual bool DropMaster(); 196 virtual bool DropMaster();
174 197
175 int get_fd() const { return file_.GetPlatformFile(); }
176
177 base::FilePath device_path() const { return device_path_; }
178
179 HardwareDisplayPlaneManager* plane_manager() { return plane_manager_.get(); } 198 HardwareDisplayPlaneManager* plane_manager() { return plane_manager_.get(); }
180 199
181 protected: 200 protected:
182 friend class base::RefCountedThreadSafe<DrmDevice>; 201 ~DrmDevice() override;
183
184 virtual ~DrmDevice();
185 202
186 scoped_ptr<HardwareDisplayPlaneManager> plane_manager_; 203 scoped_ptr<HardwareDisplayPlaneManager> plane_manager_;
187 204
188 private: 205 private:
189 class IOWatcher; 206 class IOWatcher;
190 class PageFlipManager; 207 class PageFlipManager;
191 208
192 // Path to DRM device.
193 const base::FilePath device_path_;
194
195 // DRM device.
196 base::File file_;
197
198 // Helper thread to perform IO listener operations. 209 // Helper thread to perform IO listener operations.
199 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 210 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
200 211
201 // Watcher for |fd_| listening for page flip events. 212 // Watcher for |fd_| listening for page flip events.
202 scoped_refptr<IOWatcher> watcher_; 213 scoped_refptr<IOWatcher> watcher_;
203 214
204 scoped_refptr<PageFlipManager> page_flip_manager_; 215 scoped_refptr<PageFlipManager> page_flip_manager_;
205 216
206 DISALLOW_COPY_AND_ASSIGN(DrmDevice); 217 DISALLOW_COPY_AND_ASSIGN(DrmDevice);
207 }; 218 };
208 219
209 } // namespace ui 220 } // namespace ui
210 221
211 #endif // UI_OZONE_PLATFORM_DRM_GPU_DRM_DEVICE_H_ 222 #endif // UI_OZONE_PLATFORM_DRM_GPU_DRM_DEVICE_H_
OLDNEW
« no previous file with comments | « ui/ozone/common/gpu/ozone_gpu_messages.h ('k') | ui/ozone/platform/drm/gpu/drm_device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698