• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 #ifndef ANDROID_PLATFORM_DRM_GENERIC_H_
18 #define ANDROID_PLATFORM_DRM_GENERIC_H_
19 
20 #include "drmdevice.h"
21 #include "platform.h"
22 
23 #include <hardware/gralloc.h>
24 #include <map>
25 
26 #include <drm/drm_fourcc.h>
27 
28 #ifndef DRM_FORMAT_INVALID
29 #define DRM_FORMAT_INVALID 0
30 #endif
31 
32 namespace android {
33 
34 class DrmGenericImporter : public Importer {
35  public:
36   DrmGenericImporter(DrmDevice *drm);
37   ~DrmGenericImporter() override;
38 
39   int Init();
40 
41   int ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) override;
42   int ReleaseBuffer(hwc_drm_bo_t *bo) override;
43   bool CanImportBuffer(buffer_handle_t handle) override;
44   int ImportHandle(uint32_t gem_handle);
45   int ReleaseHandle(uint32_t gem_handle);
46 
47   int ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) override;
48 
49   uint32_t ConvertHalFormatToDrm(uint32_t hal_format);
50   uint32_t DrmFormatToBitsPerPixel(uint32_t drm_format);
51 
52  protected:
53   DrmDevice *drm_;
54 
55  private:
56   const gralloc_module_t *gralloc_;
57   bool exclude_non_hwfb_;
58 
59   int CloseHandle(uint32_t gem_handle);
60   std::map<uint32_t, int> gem_refcount_;
61 };
62 }  // namespace android
63 
64 #endif
65