blob: 099d329628c2517f1e3f0b6e9009fb4725b64544 [file] [log] [blame]
Tao Bao557fa1f2017-02-07 12:51:00 -08001/*
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
Tao Bao92bdb5a2018-10-21 12:12:37 -070017#pragma once
18
19#include <stdint.h>
Tao Bao557fa1f2017-02-07 12:51:00 -080020
21#include <adf/adf.h>
22
23#include "graphics.h"
Tao Bao92bdb5a2018-10-21 12:12:37 -070024#include "minui/minui.h"
Tao Bao557fa1f2017-02-07 12:51:00 -080025
26class GRSurfaceAdf : public GRSurface {
Tao Bao92bdb5a2018-10-21 12:12:37 -070027 public:
28 uint8_t* data() override {
29 return mmapped_buffer_;
30 }
31
Tao Bao557fa1f2017-02-07 12:51:00 -080032 private:
Tao Bao92bdb5a2018-10-21 12:12:37 -070033 friend class MinuiBackendAdf;
34
Tao Bao557fa1f2017-02-07 12:51:00 -080035 int fence_fd;
36 int fd;
37 __u32 offset;
38 __u32 pitch;
39
Tao Bao92bdb5a2018-10-21 12:12:37 -070040 uint8_t* mmapped_buffer_{ nullptr };
Tao Bao557fa1f2017-02-07 12:51:00 -080041};
42
43class MinuiBackendAdf : public MinuiBackend {
44 public:
45 GRSurface* Init() override;
46 GRSurface* Flip() override;
47 void Blank(bool) override;
48 ~MinuiBackendAdf() override;
49 MinuiBackendAdf();
50
51 private:
52 int SurfaceInit(const drm_mode_modeinfo* mode, GRSurfaceAdf* surf);
53 int InterfaceInit();
54 int DeviceInit(adf_device* dev);
55 void SurfaceDestroy(GRSurfaceAdf* surf);
56 void Sync(GRSurfaceAdf* surf);
57
58 int intf_fd;
59 adf_id_t eng_id;
60 __u32 format;
61 adf_device dev;
62 unsigned int current_surface;
63 unsigned int n_surfaces;
64 GRSurfaceAdf surfaces[2];
65};