File: drm_gpu_util.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (110 lines) | stat: -rw-r--r-- 4,377 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_OZONE_PLATFORM_DRM_GPU_DRM_GPU_UTIL_H_
#define UI_OZONE_PLATFORM_DRM_GPU_DRM_GPU_UTIL_H_

#include "base/containers/flat_map.h"
#include "third_party/perfetto/include/perfetto/tracing/traced_value_forward.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/ozone/platform/drm/common/drm_util.h"
#include "ui/ozone/platform/drm/common/drm_wrapper.h"
#include "ui/ozone/platform/drm/common/scoped_drm_types.h"
#include "ui/ozone/platform/drm/gpu/drm_device.h"

typedef struct _drmModeModeInfo drmModeModeInfo;
struct skcms_Matrix3x3;

namespace ui {

struct ControllerConfigParams {
  ControllerConfigParams(int64_t display_id,
                         scoped_refptr<DrmDevice> drm,
                         uint32_t crtc,
                         uint32_t connector,
                         gfx::Point origin,
                         std::unique_ptr<drmModeModeInfo> pmode,
                         bool enable_vrr = false,
                         uint64_t base_connector_id = 0);
  ControllerConfigParams(const ControllerConfigParams& other);
  ControllerConfigParams(ControllerConfigParams&& other);
  ~ControllerConfigParams();

  const int64_t display_id;
  const scoped_refptr<DrmDevice> drm;
  uint32_t crtc;
  const uint32_t connector;
  const uint64_t base_connector_id;
  const gfx::Point origin;
  std::unique_ptr<drmModeModeInfo> mode;
  const bool enable_vrr;
};

using ConnectorCrtcMap =
    base::flat_map<uint32_t /*connector_id*/, uint32_t /*crtc_id*/>;

// Describes assignment of CRTC with |crtc_id| to a connector with
// |connector_id|.
struct CrtcConnectorPair {
  uint32_t crtc_id;
  uint32_t connector_id;
};
using CrtcConnectorPairs = std::vector<CrtcConnectorPair>;

// Helper function that finds the property with the specified name.
bool GetDrmPropertyForName(DrmWrapper* drm,
                           drmModeObjectProperties* properties,
                           const std::string& name,
                           DrmWrapper::Property* property);

// If the |property| has a valid ID add it to the |property_set| request.
bool AddPropertyIfValid(drmModeAtomicReq* property_set,
                        uint32_t object_id,
                        const DrmWrapper::Property& property);

// Transforms the gamma curve into the drm_color_lut format with `size` entries.
ScopedDrmColorLutPtr CreateLutBlob(const display::GammaCurve& source,
                                   size_t size);

// Parse a Lut blob to retrieve a display::GammaCurve.
bool ParseLutBlob(const void* data, size_t size, display::GammaCurve& result);

// Converts |color_matrix| to a drm_color_ctm in U31.32 format where the most
// significant bit is the sign. If `negative_values_broken` is true, then
// clamp all negative values to 0.
ScopedDrmColorCtmPtr CreateCTMBlob(const skcms_Matrix3x3& color_matrix,
                                   bool negative_values_broken);

// Parse a CTM blob to retrieve a skcms_Matrix3x3.
bool ParseCTMBlob(const void* data, size_t size, skcms_Matrix3x3& result);

// Creates a FB Damage Clip Blob
ScopedDrmModeRectPtr CreateDCBlob(const gfx::Rect& rect);

// Returns the display infos parsed in
// |GetDisplayInfosAndInvalidCrtcs| and disables the invalid CRTCs
// that weren't picked as preferred CRTCs.
std::vector<std::unique_ptr<HardwareDisplayControllerInfo>>
GetDisplayInfosAndUpdateCrtcs(DrmWrapper& drm);

void DrmWriteIntoTraceHelper(const drmModeModeInfo& mode_info,
                             perfetto::TracedValue context);

// Given a list of connectors from |controllers_params|, generate a list of all
// possible CRTC-connector combinations. The returned vector will contain
// permutations that have all the connectors in connectors paired up with each
// of their supported CRTC.
std::vector<CrtcConnectorPairs> GetAllCrtcConnectorPermutations(
    const DrmDevice& drm,
    const std::vector<ControllerConfigParams>& controllers_params);

// Apply the color space conversion of `crtc_id` in-place on the specified RGB
// triple.
void ApplyCrtcColorSpaceConversion(DrmWrapper* drm,
                                   uint32_t crtc_id,
                                   float rgb[3]);

}  // namespace ui

#endif  // UI_OZONE_PLATFORM_DRM_GPU_DRM_GPU_UTIL_H_