blob: 7cbea443b6f2327daf15534220eb734c3b78bdc4 [file] [log] [blame]
Sean Paul6a55e9f2015-04-30 15:31:06 -04001/*
2 * Copyright (C) 2015 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
Roman Stratiienko13cc3662020-08-29 21:35:39 +030017#include "DrmMode.h"
18
Roman Stratiienkod518a052021-02-25 19:15:14 +020019#include <cstring>
20
Roman Stratiienko13cc3662020-08-29 21:35:39 +030021#include "DrmDevice.h"
Sean Paul6a55e9f2015-04-30 15:31:06 -040022
Sean Paul6a55e9f2015-04-30 15:31:06 -040023namespace android {
24
Roman Stratiienkodf3120f2022-12-07 23:10:55 +020025DrmMode::DrmMode(drmModeModeInfoPtr m) : mode_(*m){};
Sean Paul6a55e9f2015-04-30 15:31:06 -040026
Sean Paul6a55e9f2015-04-30 15:31:06 -040027bool DrmMode::operator==(const drmModeModeInfo &m) const {
Roman Stratiienkodf3120f2022-12-07 23:10:55 +020028 return memcmp(&m, &mode_, offsetof(drmModeModeInfo, name)) == 0;
Sean Paul6a55e9f2015-04-30 15:31:06 -040029}
Roman Stratiienko40b374b2021-10-22 18:13:09 +030030
31auto DrmMode::CreateModeBlob(const DrmDevice &drm)
32 -> DrmModeUserPropertyBlobUnique {
Roman Stratiienkodf3120f2022-12-07 23:10:55 +020033 struct drm_mode_modeinfo drm_mode = {};
34 /* drm_mode_modeinfo and drmModeModeInfo should be identical
35 * At least libdrm does the same memcpy in drmModeAttachMode();
36 */
37 memcpy(&drm_mode, &mode_, sizeof(struct drm_mode_modeinfo));
Roman Stratiienko40b374b2021-10-22 18:13:09 +030038
39 return drm.RegisterUserPropertyBlob(&drm_mode,
Roman Stratiienkodf3120f2022-12-07 23:10:55 +020040 sizeof(struct drm_mode_modeinfo));
Roman Stratiienko40b374b2021-10-22 18:13:09 +030041}
42
Sean Paulf72cccd2018-08-27 13:59:08 -040043} // namespace android