blob: 428409347f235c7b98324e8b3de502669cc92a8f [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
Roman Stratiienkoaa3cd542020-08-29 11:26:16 +030020#include <drm/drm_fourcc.h>
Sean Paulda6270d2015-06-01 14:11:52 -040021#include <hardware/gralloc.h>
Roman Stratiienkoaa3cd542020-08-29 11:26:16 +030022
Vincent Donnefortf67c3652019-08-02 11:18:35 +010023#include <map>
Sean Paulda6270d2015-06-01 14:11:52 -040024
Roman Stratiienkoaa3cd542020-08-29 11:26:16 +030025#include "drm/drmdevice.h"
26#include "platform.h"
Roman Stratiienko6f5e4502019-11-27 19:23:03 +020027
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);
Roman Stratiienkofbf5c0c2020-08-24 11:27:48 +030051 bool GetYuvPlaneInfo(int num_fds, buffer_handle_t handle, hwc_drm_bo_t *bo);
Sean Paulf72cccd2018-08-27 13:59:08 -040052
Mykhailo Sopihaad438862019-06-06 14:45:27 +030053 protected:
Alexandru Gheorghe0f5abd72018-05-01 14:37:10 +010054 DrmDevice *drm_;
Sean Paulda6270d2015-06-01 14:11:52 -040055
Mykhailo Sopihaad438862019-06-06 14:45:27 +030056 private:
Sean Paulda6270d2015-06-01 14:11:52 -040057 const gralloc_module_t *gralloc_;
Mykhailo Sopiha1693bc32019-07-08 18:28:56 +030058 bool exclude_non_hwfb_;
Vincent Donnefortf67c3652019-08-02 11:18:35 +010059
60 int CloseHandle(uint32_t gem_handle);
61 std::map<uint32_t, int> gem_refcount_;
Sean Paulda6270d2015-06-01 14:11:52 -040062};
Sean Paulf72cccd2018-08-27 13:59:08 -040063} // namespace android
Sean Paulda6270d2015-06-01 14:11:52 -040064
65#endif