13d0407baSopenharmony_ci/*
23d0407baSopenharmony_ci * Copyright (C) 2016 Rockchip Electronics Co., Ltd.
33d0407baSopenharmony_ci * Authors:
43d0407baSopenharmony_ci *  Zhiqin Wei <wzq@rock-chips.com>
53d0407baSopenharmony_ci *
63d0407baSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
73d0407baSopenharmony_ci * you may not use this file except in compliance with the License.
83d0407baSopenharmony_ci * You may obtain a copy of the License at
93d0407baSopenharmony_ci *
103d0407baSopenharmony_ci *      http://www.apache.org/licenses/LICENSE-2.0
113d0407baSopenharmony_ci *
123d0407baSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
133d0407baSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
143d0407baSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
153d0407baSopenharmony_ci * See the License for the specific language governing permissions and
163d0407baSopenharmony_ci * limitations under the License.
173d0407baSopenharmony_ci */
183d0407baSopenharmony_ci
193d0407baSopenharmony_ci#ifndef _rockchip_rga_h_
203d0407baSopenharmony_ci#define _rockchip_rga_h_
213d0407baSopenharmony_ci
223d0407baSopenharmony_ci#include <stdint.h>
233d0407baSopenharmony_ci#include <sys/types.h>
243d0407baSopenharmony_ci#include <stdlib.h>
253d0407baSopenharmony_ci#include <stdio.h>
263d0407baSopenharmony_ci#include <string.h>
273d0407baSopenharmony_ci#include <errno.h>
283d0407baSopenharmony_ci#include <time.h>
293d0407baSopenharmony_ci#include <unistd.h>
303d0407baSopenharmony_ci#include <sys/mman.h>
313d0407baSopenharmony_ci#include <linux/stddef.h>
323d0407baSopenharmony_ci
333d0407baSopenharmony_ci#include "drmrga.h"
343d0407baSopenharmony_ci#include "GrallocOps.h"
353d0407baSopenharmony_ci#include "RgaUtils.h"
363d0407baSopenharmony_ci#include "rga.h"
373d0407baSopenharmony_ci
383d0407baSopenharmony_ci//////////////////////////////////////////////////////////////////////////////////
393d0407baSopenharmony_ci#ifndef ANDROID
403d0407baSopenharmony_ci#include "RgaSingleton.h"
413d0407baSopenharmony_ci#endif
423d0407baSopenharmony_ci
433d0407baSopenharmony_ci#ifdef ANDROID
443d0407baSopenharmony_ci#include <utils/Singleton.h>
453d0407baSopenharmony_ci#include <utils/Thread.h>
463d0407baSopenharmony_ci#include <hardware/hardware.h>
473d0407baSopenharmony_ci
483d0407baSopenharmony_cinamespace android {
493d0407baSopenharmony_ci#endif
503d0407baSopenharmony_ci
513d0407baSopenharmony_ci    class RockchipRga :public Singleton<RockchipRga> {
523d0407baSopenharmony_ci      public:
533d0407baSopenharmony_ci
543d0407baSopenharmony_ci        static inline RockchipRga& get() {
553d0407baSopenharmony_ci            return getInstance();
563d0407baSopenharmony_ci        }
573d0407baSopenharmony_ci
583d0407baSopenharmony_ci        int         RkRgaInit();
593d0407baSopenharmony_ci        void        RkRgaDeInit();
603d0407baSopenharmony_ci        void        RkRgaGetContext(void **ctx);
613d0407baSopenharmony_ci#ifndef ANDROID /* LINUX */
623d0407baSopenharmony_ci        int         RkRgaAllocBuffer(int drm_fd /* input */, bo_t *bo_info,
633d0407baSopenharmony_ci                                     int width, int height, int bpp, int flags);
643d0407baSopenharmony_ci        int         RkRgaFreeBuffer(int drm_fd /* input */, bo_t *bo_info);
653d0407baSopenharmony_ci        int         RkRgaGetAllocBuffer(bo_t *bo_info, int width, int height, int bpp);
663d0407baSopenharmony_ci        int         RkRgaGetAllocBufferExt(bo_t *bo_info, int width, int height, int bpp, int flags);
673d0407baSopenharmony_ci        int         RkRgaGetAllocBufferCache(bo_t *bo_info, int width, int height, int bpp);
683d0407baSopenharmony_ci        int         RkRgaGetMmap(bo_t *bo_info);
693d0407baSopenharmony_ci        int         RkRgaUnmap(bo_t *bo_info);
703d0407baSopenharmony_ci        int         RkRgaFree(bo_t *bo_info);
713d0407baSopenharmony_ci        int         RkRgaGetBufferFd(bo_t *bo_info, int *fd);
723d0407baSopenharmony_ci#else
733d0407baSopenharmony_ci        int         RkRgaGetBufferFd(buffer_handle_t handle, int *fd);
743d0407baSopenharmony_ci        int         RkRgaGetHandleMapCpuAddress(buffer_handle_t handle, void **buf);
753d0407baSopenharmony_ci#endif
763d0407baSopenharmony_ci        int         RkRgaBlit(rga_info *src, rga_info *dst, rga_info *src1);
773d0407baSopenharmony_ci        int         RkRgaCollorFill(rga_info *dst);
783d0407baSopenharmony_ci        int         RkRgaCollorPalette(rga_info *src, rga_info *dst, rga_info *lut);
793d0407baSopenharmony_ci        int         RkRgaFlush();
803d0407baSopenharmony_ci
813d0407baSopenharmony_ci
823d0407baSopenharmony_ci        void        RkRgaSetLogOnceFlag(int log) {
833d0407baSopenharmony_ci            mLogOnce = log;
843d0407baSopenharmony_ci        }
853d0407baSopenharmony_ci        void        RkRgaSetAlwaysLogFlag(bool log) {
863d0407baSopenharmony_ci            mLogAlways = log;
873d0407baSopenharmony_ci        }
883d0407baSopenharmony_ci        void        RkRgaLogOutRgaReq(struct rga_req rgaReg);
893d0407baSopenharmony_ci        int         RkRgaLogOutUserPara(rga_info *rgaInfo);
903d0407baSopenharmony_ci        inline bool RkRgaIsReady() {
913d0407baSopenharmony_ci            return mSupportRga;
923d0407baSopenharmony_ci        }
933d0407baSopenharmony_ci
943d0407baSopenharmony_ci        RockchipRga();
953d0407baSopenharmony_ci        ~RockchipRga();
963d0407baSopenharmony_ci      private:
973d0407baSopenharmony_ci        bool                            mSupportRga;
983d0407baSopenharmony_ci        int                             mLogOnce;
993d0407baSopenharmony_ci        int                             mLogAlways;
1003d0407baSopenharmony_ci        void *                          mContext;
1013d0407baSopenharmony_ci
1023d0407baSopenharmony_ci        friend class Singleton<RockchipRga>;
1033d0407baSopenharmony_ci    };
1043d0407baSopenharmony_ci
1053d0407baSopenharmony_ci#ifdef ANDROID
1063d0407baSopenharmony_ci}; // namespace android
1073d0407baSopenharmony_ci#endif
1083d0407baSopenharmony_ci
1093d0407baSopenharmony_ci#endif
1103d0407baSopenharmony_ci
111