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 __MPP_SERVICE_H__ 18 #define __MPP_SERVICE_H__ 19 20 #include "rk_type.h" 21 #include <asm/ioctl.h> 22 23 /* Use 'v' as magic number */ 24 #define MPP_IOC_MAGIC 'v' 25 #define MPP_IOC_CFG_V1 _IOW(MPP_IOC_MAGIC, 1, unsigned int) 26 #define MAX_REQ_NUM 16 27 28 #if __SIZEOF_POINTER__ == 4 29 #define REQ_DATA_PTR(ptr) ((RK_U32)ptr) 30 #elif __SIZEOF_POINTER__ == 8 31 #define REQ_DATA_PTR(ptr) ((RK_U64)ptr) 32 #endif 33 34 /* define flags for mpp_request */ 35 #define MPP_FLAGS_MULTI_MSG (0x00000001) 36 #define MPP_FLAGS_LAST_MSG (0x00000002) 37 #define MPP_FLAGS_REG_FD_NO_TRANS (0x00000004) 38 #define MPP_FLAGS_SCL_FD_NO_TRANS (0x00000008) 39 #define MPP_FLAGS_REG_OFFSET_ALONE (0x00000010) 40 #define MPP_FLAGS_POLL_NON_BLOCK (0x00000020) 41 #define MPP_FLAGS_SECURE_MODE (0x00010000) 42 43 /* mpp service capability description */ 44 typedef enum MppDevCmd_e { 45 MPP_DEV_GET_START = 0, 46 MPP_DEV_GET_MAX_WIDTH, 47 MPP_DEV_GET_MAX_HEIGHT, 48 MPP_DEV_GET_MIN_WIDTH, 49 MPP_DEV_GET_MIN_HEIGHT, 50 MPP_DEV_GET_MMU_STATUS, 51 52 MPP_DEV_SET_START = 0x01000000, 53 MPP_DEV_SET_HARD_PLATFORM, // set paltform by user 54 MPP_DEV_ENABLE_POSTPROCCESS, 55 56 MPP_DEV_PROP_BUTT, 57 } MppDevCmd; 58 59 typedef enum MppServiceCmdType_e { 60 MPP_CMD_QUERY_BASE = 0, 61 MPP_CMD_PROBE_HW_SUPPORT = MPP_CMD_QUERY_BASE + 0, 62 MPP_CMD_QUERY_HW_ID = MPP_CMD_QUERY_BASE + 1, 63 MPP_CMD_QUERY_CMD_SUPPORT = MPP_CMD_QUERY_BASE + 2, 64 MPP_CMD_QUERY_BUTT, 65 66 MPP_CMD_INIT_BASE = 0x100, 67 MPP_CMD_INIT_CLIENT_TYPE = MPP_CMD_INIT_BASE + 0, 68 MPP_CMD_INIT_DRIVER_DATA = MPP_CMD_INIT_BASE + 1, 69 MPP_CMD_INIT_TRANS_TABLE = MPP_CMD_INIT_BASE + 2, 70 MPP_CMD_INIT_BUTT, 71 72 MPP_CMD_SEND_BASE = 0x200, 73 MPP_CMD_SET_REG_WRITE = MPP_CMD_SEND_BASE + 0, 74 MPP_CMD_SET_REG_READ = MPP_CMD_SEND_BASE + 1, 75 MPP_CMD_SET_REG_ADDR_OFFSET = MPP_CMD_SEND_BASE + 2, 76 MPP_CMD_SET_RCB_INFO = MPP_CMD_SEND_BASE + 3, 77 /* for batch process start a task of one session */ 78 MPP_CMD_SET_SESSION_FD = MPP_CMD_SEND_BASE + 4, 79 MPP_CMD_SEND_BUTT, 80 81 MPP_CMD_POLL_BASE = 0x300, 82 MPP_CMD_POLL_HW_FINISH = MPP_CMD_POLL_BASE + 0, 83 MPP_CMD_POLL_HW_IRQ = MPP_CMD_POLL_BASE + 1, 84 MPP_CMD_POLL_BUTT, 85 86 MPP_CMD_CONTROL_BASE = 0x400, 87 MPP_CMD_RESET_SESSION = MPP_CMD_CONTROL_BASE + 0, 88 MPP_CMD_TRANS_FD_TO_IOVA = MPP_CMD_CONTROL_BASE + 1, 89 MPP_CMD_RELEASE_FD = MPP_CMD_CONTROL_BASE + 2, 90 MPP_CMD_SEND_CODEC_INFO = MPP_CMD_CONTROL_BASE + 3, 91 MPP_CMD_BAT_CMD = MPP_CMD_CONTROL_BASE + 4, 92 MPP_CMD_CONTROL_BUTT, 93 94 MPP_CMD_BUTT, 95 } MppServiceCmdType; 96 97 typedef struct mppReqV1_t { 98 RK_U32 cmd; 99 RK_U32 flag; 100 RK_U32 size; 101 RK_U32 offset; 102 RK_U64 data_ptr; 103 } MppReqV1; 104 105 typedef struct MppServiceCmdCap_t { 106 RK_U32 support_cmd; 107 RK_U32 query_cmd; 108 RK_U32 init_cmd; 109 RK_U32 send_cmd; 110 RK_U32 poll_cmd; 111 RK_U32 ctrl_cmd; 112 } MppServiceCmdCap; 113 114 typedef struct MppDevBatCmd_t { 115 RK_U64 flag; 116 RK_S32 client; 117 RK_S32 ret; 118 } MppDevBatCmd; 119 120 #ifdef __cplusplus 121 extern "C" { 122 #endif 123 124 void check_mpp_service_cap(RK_U32 *codec_type, RK_U32 *hw_ids, MppServiceCmdCap *cap); 125 const MppServiceCmdCap *mpp_get_mpp_service_cmd_cap(void); 126 const char *mpp_get_mpp_service_name(void); 127 128 #ifdef __cplusplus 129 } 130 #endif 131 132 #endif /* __MPP_SERVICE_H__ */ 133