blob: f9d923ff840e1b2d19d2cb7d5ad43659c95e5f8f [file] [log] [blame]
Sean Paulda6270d2015-06-01 14:11:52 -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
Sean Paul5d8acfc2016-04-21 16:26:27 -040017#ifndef ANDROID_PLATFORM_DRM_GENERIC_H_
18#define ANDROID_PLATFORM_DRM_GENERIC_H_
Sean Paulda6270d2015-06-01 14:11:52 -040019
Alexandru Gheorghe0f5abd72018-05-01 14:37:10 +010020#include "drmdevice.h"
Sean Paul63769962016-04-21 16:25:06 -040021#include "platform.h"
Sean Paulda6270d2015-06-01 14:11:52 -040022
23#include <hardware/gralloc.h>
Vincent Donnefortf67c3652019-08-02 11:18:35 +010024#include <map>
Sean Paulda6270d2015-06-01 14:11:52 -040025
Roman Stratiienko6f5e4502019-11-27 19:23:03 +020026#include <drm/drm_fourcc.h>
27
28#ifndef DRM_FORMAT_INVALID
29#define DRM_FORMAT_INVALID 0
30#endif
31
Sean Paulda6270d2015-06-01 14:11:52 -040032namespace android {
33
34class DrmGenericImporter : public Importer {
35 public:
Alexandru Gheorghe0f5abd72018-05-01 14:37:10 +010036 DrmGenericImporter(DrmDevice *drm);
Haixia Shi479412c2015-10-27 10:40:48 -070037 ~DrmGenericImporter() override;
Sean Paulda6270d2015-06-01 14:11:52 -040038
39 int Init();
40
Haixia Shi479412c2015-10-27 10:40:48 -070041 int ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) override;
42 int ReleaseBuffer(hwc_drm_bo_t *bo) override;
Alexey Firago18ec6882018-11-21 23:47:05 +030043 bool CanImportBuffer(buffer_handle_t handle) override;
Vincent Donnefortf67c3652019-08-02 11:18:35 +010044 int ImportHandle(uint32_t gem_handle);
45 int ReleaseHandle(uint32_t gem_handle);
Sean Paulda6270d2015-06-01 14:11:52 -040046
Roman Stratiienko4163efc2019-12-06 12:30:28 +020047 int ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) override;
48
Sean Paulda6270d2015-06-01 14:11:52 -040049 uint32_t ConvertHalFormatToDrm(uint32_t hal_format);
John Stultza4514832018-08-24 16:27:36 -070050 uint32_t DrmFormatToBitsPerPixel(uint32_t drm_format);
Sean Paulf72cccd2018-08-27 13:59:08 -040051
Mykhailo Sopihaad438862019-06-06 14:45:27 +030052 protected:
Alexandru Gheorghe0f5abd72018-05-01 14:37:10 +010053 DrmDevice *drm_;
Sean Paulda6270d2015-06-01 14:11:52 -040054
Mykhailo Sopihaad438862019-06-06 14:45:27 +030055 private:
Sean Paulda6270d2015-06-01 14:11:52 -040056 const gralloc_module_t *gralloc_;
Mykhailo Sopiha1693bc32019-07-08 18:28:56 +030057 bool exclude_non_hwfb_;
Vincent Donnefortf67c3652019-08-02 11:18:35 +010058
59 int CloseHandle(uint32_t gem_handle);
60 std::map<uint32_t, int> gem_refcount_;
Sean Paulda6270d2015-06-01 14:11:52 -040061};
Sean Paulf72cccd2018-08-27 13:59:08 -040062} // namespace android
Sean Paulda6270d2015-06-01 14:11:52 -040063
64#endif