Sean Paul | da6270d | 2015-06-01 14:11:52 -0400 | [diff] [blame] | 1 | /* |
| 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 | |
Sean Paul | 5d8acfc | 2016-04-21 16:26:27 -0400 | [diff] [blame] | 17 | #ifndef ANDROID_PLATFORM_DRM_GENERIC_H_ |
| 18 | #define ANDROID_PLATFORM_DRM_GENERIC_H_ |
Sean Paul | da6270d | 2015-06-01 14:11:52 -0400 | [diff] [blame] | 19 | |
Alexandru Gheorghe | 0f5abd7 | 2018-05-01 14:37:10 +0100 | [diff] [blame] | 20 | #include "drmdevice.h" |
Sean Paul | 6376996 | 2016-04-21 16:25:06 -0400 | [diff] [blame] | 21 | #include "platform.h" |
Sean Paul | da6270d | 2015-06-01 14:11:52 -0400 | [diff] [blame] | 22 | |
| 23 | #include <hardware/gralloc.h> |
Vincent Donnefort | f67c365 | 2019-08-02 11:18:35 +0100 | [diff] [blame] | 24 | #include <map> |
Sean Paul | da6270d | 2015-06-01 14:11:52 -0400 | [diff] [blame] | 25 | |
Roman Stratiienko | 6f5e450 | 2019-11-27 19:23:03 +0200 | [diff] [blame] | 26 | #include <drm/drm_fourcc.h> |
| 27 | |
| 28 | #ifndef DRM_FORMAT_INVALID |
| 29 | #define DRM_FORMAT_INVALID 0 |
| 30 | #endif |
| 31 | |
Sean Paul | da6270d | 2015-06-01 14:11:52 -0400 | [diff] [blame] | 32 | namespace android { |
| 33 | |
| 34 | class DrmGenericImporter : public Importer { |
| 35 | public: |
Alexandru Gheorghe | 0f5abd7 | 2018-05-01 14:37:10 +0100 | [diff] [blame] | 36 | DrmGenericImporter(DrmDevice *drm); |
Haixia Shi | 479412c | 2015-10-27 10:40:48 -0700 | [diff] [blame] | 37 | ~DrmGenericImporter() override; |
Sean Paul | da6270d | 2015-06-01 14:11:52 -0400 | [diff] [blame] | 38 | |
| 39 | int Init(); |
| 40 | |
Haixia Shi | 479412c | 2015-10-27 10:40:48 -0700 | [diff] [blame] | 41 | int ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) override; |
| 42 | int ReleaseBuffer(hwc_drm_bo_t *bo) override; |
Alexey Firago | 18ec688 | 2018-11-21 23:47:05 +0300 | [diff] [blame] | 43 | bool CanImportBuffer(buffer_handle_t handle) override; |
Vincent Donnefort | f67c365 | 2019-08-02 11:18:35 +0100 | [diff] [blame] | 44 | int ImportHandle(uint32_t gem_handle); |
| 45 | int ReleaseHandle(uint32_t gem_handle); |
Sean Paul | da6270d | 2015-06-01 14:11:52 -0400 | [diff] [blame] | 46 | |
Roman Stratiienko | 4163efc | 2019-12-06 12:30:28 +0200 | [diff] [blame] | 47 | int ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) override; |
| 48 | |
Sean Paul | da6270d | 2015-06-01 14:11:52 -0400 | [diff] [blame] | 49 | uint32_t ConvertHalFormatToDrm(uint32_t hal_format); |
John Stultz | a451483 | 2018-08-24 16:27:36 -0700 | [diff] [blame] | 50 | uint32_t DrmFormatToBitsPerPixel(uint32_t drm_format); |
Sean Paul | f72cccd | 2018-08-27 13:59:08 -0400 | [diff] [blame] | 51 | |
Mykhailo Sopiha | ad43886 | 2019-06-06 14:45:27 +0300 | [diff] [blame] | 52 | protected: |
Alexandru Gheorghe | 0f5abd7 | 2018-05-01 14:37:10 +0100 | [diff] [blame] | 53 | DrmDevice *drm_; |
Sean Paul | da6270d | 2015-06-01 14:11:52 -0400 | [diff] [blame] | 54 | |
Mykhailo Sopiha | ad43886 | 2019-06-06 14:45:27 +0300 | [diff] [blame] | 55 | private: |
Sean Paul | da6270d | 2015-06-01 14:11:52 -0400 | [diff] [blame] | 56 | const gralloc_module_t *gralloc_; |
Mykhailo Sopiha | 1693bc3 | 2019-07-08 18:28:56 +0300 | [diff] [blame] | 57 | bool exclude_non_hwfb_; |
Vincent Donnefort | f67c365 | 2019-08-02 11:18:35 +0100 | [diff] [blame] | 58 | |
| 59 | int CloseHandle(uint32_t gem_handle); |
| 60 | std::map<uint32_t, int> gem_refcount_; |
Sean Paul | da6270d | 2015-06-01 14:11:52 -0400 | [diff] [blame] | 61 | }; |
Sean Paul | f72cccd | 2018-08-27 13:59:08 -0400 | [diff] [blame] | 62 | } // namespace android |
Sean Paul | da6270d | 2015-06-01 14:11:52 -0400 | [diff] [blame] | 63 | |
| 64 | #endif |