/* * Copyright (c) 2021-2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef HI_GBM_H #define HI_GBM_H #include namespace OHOS { namespace HDI { namespace DISPLAY { struct gbm_device; struct gbm_bo; enum gbm_bo_flags { /* * * Buffer is going to be presented to the screen using an API such as KMS */ GBM_BO_USE_SCANOUT = (1 << 0), /* * * Buffer is going to be used as cursor */ GBM_BO_USE_CURSOR = (1 << 1), /* * * Deprecated */ GBM_BO_USE_CURSOR_64X64 = GBM_BO_USE_CURSOR, /* * * Buffer is to be used for rendering - for example it is going to be used * as the storage for a color buffer */ GBM_BO_USE_RENDERING = (1 << 2), /* * * Deprecated */ GBM_BO_USE_WRITE = (1 << 3), /* * * Buffer is guaranteed to be laid out linearly in memory. That is, the * buffer is laid out as an array with 'height' blocks, each block with * length 'stride'. Each stride is in the same order as the rows of the * buffer. This is intended to be used with buffers that will be accessed * via dma-buf mmap(). */ GBM_BO_USE_LINEAR = (1 << 4), /* * * The buffer will be used as a texture that will be sampled from. */ GBM_BO_USE_TEXTURING = (1 << 5), /* * * The buffer will be written to by a camera subsystem. */ GBM_BO_USE_CAMERA_WRITE = (1 << 6), /* * * The buffer will be read from by a camera subsystem. */ GBM_BO_USE_CAMERA_READ = (1 << 7), /* * * Buffer inaccessible to unprivileged users. */ GBM_BO_USE_PROTECTED = (1 << 8), /* * * These flags specify the frequency of software access. These flags do not * guarantee the buffer is linear, but do guarantee gbm_bo_map(..) will * present a linear view. */ GBM_BO_USE_SW_READ_OFTEN = (1 << 9), GBM_BO_USE_SW_READ_RARELY = (1 << 10), GBM_BO_USE_SW_WRITE_OFTEN = (1 << 11), GBM_BO_USE_SW_WRITE_RARELY = (1 << 12), /* * * The buffer will be written by a video decode accelerator. */ GBM_BO_USE_HW_VIDEO_DECODER = (1 << 13), }; struct gbm_device *HdiGbmCreateDevice(int fd); void HdiGbmDeviceDestroy(struct gbm_device *gbm); struct gbm_bo *HdiGbmBoCreate(struct gbm_device *gbm, uint32_t width, uint32_t height, uint32_t format, uint32_t usage); uint32_t HdiGbmBoGetStride(struct gbm_bo *bo); uint32_t HdiGbmBoGetWidth(struct gbm_bo *bo); uint32_t HdiGbmBoGetHeight(struct gbm_bo *bo); uint32_t HdiGbmBoGetSize(struct gbm_bo *bo); void HdiGbmBoDestroy(struct gbm_bo *bo); int HdiGbmBoGetFd(struct gbm_bo *bo); } // namespace DISPLAY } // namespace HDI } // namespace OHOS #endif // HI_GBM_H