xref: /rockchip-linux_mpp/mpp/vproc/inc/iep_common.h (revision 437bfbeb9567cca9cd9080e3f6954aa9d6a94f18)
1 /*
2  * Copyright 2020 Rockchip Electronics Co. LTD
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 __IEP_COMMON_H__
18 #define __IEP_COMMON_H__
19 
20 #include "mpp_debug.h"
21 
22 #define IEP_DBG_FUNCTION            (0x00000001)
23 #define IEP_DBG_TRACE               (0x00000002)
24 #define IEP_DBG_IMAGE               (0x00000010)
25 
26 #define iep_dbg(flag, fmt, ...)     _mpp_dbg(iep_debug, flag, "iep:" fmt, ## __VA_ARGS__)
27 #define iep_dbg_f(flag, fmt, ...)   _mpp_dbg_f(iep_debug, flag, fmt, ## __VA_ARGS__)
28 #define iep_dbg_func(fmt, ...)      iep_dbg(IEP_DBG_FUNCTION, fmt, ## __VA_ARGS__)
29 #define iep_dbg_trace(fmt, ...)     iep_dbg(IEP_DBG_TRACE, fmt, ## __VA_ARGS__)
30 
31 typedef enum IepCmd_e {
32     IEP_CMD_INIT,                           // reset msg to all zero
33     IEP_CMD_SET_SRC,                        // config source image info
34     IEP_CMD_SET_DST,                        // config destination image info
35 
36     // deinterlace command
37     IEP_CMD_SET_DEI_CFG         = 0x0100,   // config deinterlace configure
38     IEP_CMD_SET_DEI_SRC1,                   // config deinterlace extra source
39     IEP_CMD_SET_DEI_DST1,                   // config deinterlace extra destination
40     IEP_CMD_SET_DEI_SRC2,                   // in case of iep2 deinterlacing
41 
42     // color enhancement command
43     IEP_CMD_SET_YUV_ENHANCE     = 0x0200,   // config YUV enhancement parameter
44     IEP_CMD_SET_RGB_ENHANCE,                // config RGB enhancement parameter
45 
46     // scale algorithm command
47     IEP_CMD_SET_SCALE           = 0x0300,   // config scale algorithm
48 
49     // color convert command
50     IEP_CMD_SET_COLOR_CONVERT   = 0x0400,   // config color convert parameter
51 
52     // hardware trigger command
53     IEP_CMD_RUN_SYNC            = 0x1000,   // start sync mode process
54     IEP_CMD_RUN_ASYNC,                      // start async mode process
55 
56     // hardware capability query command
57     IEP_CMD_QUERY_CAP           = 0x8000,   // query iep capability
58 } IepCmd;
59 
60 typedef enum IepFormat_e {
61     IEP_FORMAT_RGB_BASE     = 0x0,
62     IEP_FORMAT_ARGB_8888    = IEP_FORMAT_RGB_BASE,
63     IEP_FORMAT_ABGR_8888    = 0x1,
64     IEP_FORMAT_RGBA_8888    = 0x2,
65     IEP_FORMAT_BGRA_8888    = 0x3,
66     IEP_FORMAT_RGB_565      = 0x4,
67     IEP_FORMAT_BGR_565      = 0x5,
68     IEP_FORMAT_RGB_BUTT,
69 
70     IEP_FORMAT_YUV_BASE     = 0x10,
71     IEP_FORMAT_YCbCr_422_SP = IEP_FORMAT_YUV_BASE,
72     IEP_FORMAT_YCbCr_422_P  = 0x11,
73     IEP_FORMAT_YCbCr_420_SP = 0x12,
74     IEP_FORMAT_YCbCr_420_P  = 0x13,
75     IEP_FORMAT_YCrCb_422_SP = 0x14,
76     IEP_FORMAT_YCrCb_422_P  = 0x15, // same as IEP_FORMAT_YCbCr_422_P
77     IEP_FORMAT_YCrCb_420_SP = 0x16,
78     IEP_FORMAT_YCrCb_420_P  = 0x17, // same as IEP_FORMAT_YCbCr_420_P
79     IEP_FORMAT_YUV_BUTT,
80 } IepFormat;
81 
82 // iep image for external user
83 typedef struct IegImg_t {
84     RK_U16  act_w;          // act_width
85     RK_U16  act_h;          // act_height
86     RK_S16  x_off;          // x offset for the vir,word unit
87     RK_S16  y_off;          // y offset for the vir,word unit
88 
89     RK_U16  vir_w;          // unit in byte
90     RK_U16  vir_h;          // unit in byte
91     RK_U32  format;         // IepFormat
92     RK_U32  mem_addr;       // base address fd
93     RK_U32  uv_addr;        // chroma address fd + (offset << 10)
94     RK_U32  v_addr;
95 } IepImg;
96 
97 typedef void* IepCtx;
98 
99 #ifdef __cplusplus
100 extern "C" {
101 #endif
102 
103 typedef struct iep_com_ctx_t iep_com_ctx;
104 
105 typedef struct iep_com_ops_t {
106     MPP_RET (*init)(IepCtx *ctx);
107     MPP_RET (*deinit)(IepCtx ctx);
108     MPP_RET (*control)(IepCtx ctx, IepCmd cmd, void *param);
109     MPP_RET (*reset)(IepCtx ctx);
110     void (*release)(iep_com_ctx *ctx);
111 } iep_com_ops;
112 
113 typedef struct iep_com_ctx_t {
114     iep_com_ops *ops;
115     IepCtx priv;
116     int ver;
117 } iep_com_ctx;
118 
119 struct dev_compatible {
120     const char *compatible;
121     iep_com_ctx* (*get)(void);
122     void (*put)(iep_com_ctx *ctx);
123     int ver;
124 };
125 
126 iep_com_ctx* get_iep_ctx();
127 void put_iep_ctx(iep_com_ctx *ictx);
128 extern RK_U32 iep_debug;
129 
130 #ifdef __cplusplus
131 }
132 #endif
133 
134 #endif /* __IEP_API_H__ */
135