Tao Bao | 557fa1f | 2017-02-07 12:51:00 -0800 | [diff] [blame] | 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 | |
Tao Bao | 92bdb5a | 2018-10-21 12:12:37 -0700 | [diff] [blame] | 17 | #pragma once |
| 18 | |
| 19 | #include <stdint.h> |
Tao Bao | 557fa1f | 2017-02-07 12:51:00 -0800 | [diff] [blame] | 20 | |
| 21 | #include <adf/adf.h> |
| 22 | |
| 23 | #include "graphics.h" |
Tao Bao | 92bdb5a | 2018-10-21 12:12:37 -0700 | [diff] [blame] | 24 | #include "minui/minui.h" |
Tao Bao | 557fa1f | 2017-02-07 12:51:00 -0800 | [diff] [blame] | 25 | |
| 26 | class GRSurfaceAdf : public GRSurface { |
Tao Bao | 92bdb5a | 2018-10-21 12:12:37 -0700 | [diff] [blame] | 27 | public: |
| 28 | uint8_t* data() override { |
| 29 | return mmapped_buffer_; |
| 30 | } |
| 31 | |
Tao Bao | 557fa1f | 2017-02-07 12:51:00 -0800 | [diff] [blame] | 32 | private: |
Tao Bao | 92bdb5a | 2018-10-21 12:12:37 -0700 | [diff] [blame] | 33 | friend class MinuiBackendAdf; |
| 34 | |
Tao Bao | 557fa1f | 2017-02-07 12:51:00 -0800 | [diff] [blame] | 35 | int fence_fd; |
| 36 | int fd; |
| 37 | __u32 offset; |
| 38 | __u32 pitch; |
| 39 | |
Tao Bao | 92bdb5a | 2018-10-21 12:12:37 -0700 | [diff] [blame] | 40 | uint8_t* mmapped_buffer_{ nullptr }; |
Tao Bao | 557fa1f | 2017-02-07 12:51:00 -0800 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | class 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 | }; |