1 /* 2 * Copyright (c) 2021 Rockchip Electronics Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef __MPP_SERVICE_H__ 17 #define __MPP_SERVICE_H__ 18 19 #include <asm/ioctl.h> 20 #include "rk_type.h" 21 22 /* Use 'v' as magic number */ 23 #define MPP_IOC_MAGIC 'v' 24 #define MPP_IOC_CFG_V1 _IOW(MPP_IOC_MAGIC, 1, unsigned int) 25 #define MAX_REQ_NUM 16 26 27 #if __SIZEOF_POINTER__ == 4 28 #define REQ_DATA_PTR(ptr) ((RK_U32)(ptr)) 29 #elif __SIZEOF_POINTER__ == 8 30 #define REQ_DATA_PTR(ptr) ((RK_U64)(ptr)) 31 #endif 32 33 /* define flags for mpp_request */ 34 #define MPP_FLAGS_MULTI_MSG (0x00000001) 35 #define MPP_FLAGS_LAST_MSG (0x00000002) 36 #define MPP_FLAGS_REG_FD_NO_TRANS (0x00000004) 37 #define MPP_FLAGS_SCL_FD_NO_TRANS (0x00000008) 38 #define MPP_FLAGS_REG_OFFSET_ALONE (0x00000010) 39 #define MPP_FLAGS_POLL_NON_BLOCK (0x00000020) 40 #define MPP_FLAGS_SECURE_MODE (0x00010000) 41 42 /* mpp service capability description */ 43 typedef enum MppDevCmd_e { 44 MPP_DEV_GET_START = 0, 45 MPP_DEV_GET_MAX_WIDTH, 46 MPP_DEV_GET_MAX_HEIGHT, 47 MPP_DEV_GET_MIN_WIDTH, 48 MPP_DEV_GET_MIN_HEIGHT, 49 MPP_DEV_GET_MMU_STATUS, 50 51 MPP_DEV_SET_START = 0x01000000, 52 MPP_DEV_SET_HARD_PLATFORM, // set paltform by user 53 MPP_DEV_ENABLE_POSTPROCCESS, 54 55 MPP_DEV_PROP_BUTT, 56 } MppDevCmd; 57 58 typedef enum MppServiceCmdType_e { 59 MPP_CMD_QUERY_BASE = 0, 60 MPP_CMD_PROBE_HW_SUPPORT = MPP_CMD_QUERY_BASE + 0, 61 MPP_CMD_QUERY_HW_ID = MPP_CMD_QUERY_BASE + 1, 62 MPP_CMD_QUERY_CMD_SUPPORT = MPP_CMD_QUERY_BASE + 2, 63 MPP_CMD_QUERY_BUTT, 64 65 MPP_CMD_INIT_BASE = 0x100, 66 MPP_CMD_INIT_CLIENT_TYPE = MPP_CMD_INIT_BASE + 0, 67 MPP_CMD_INIT_DRIVER_DATA = MPP_CMD_INIT_BASE + 1, 68 MPP_CMD_INIT_TRANS_TABLE = MPP_CMD_INIT_BASE + 2, 69 MPP_CMD_INIT_BUTT, 70 71 MPP_CMD_SEND_BASE = 0x200, 72 MPP_CMD_SET_REG_WRITE = MPP_CMD_SEND_BASE + 0, 73 MPP_CMD_SET_REG_READ = MPP_CMD_SEND_BASE + 1, 74 MPP_CMD_SET_REG_ADDR_OFFSET = MPP_CMD_SEND_BASE + 2, 75 MPP_CMD_SET_RCB_INFO = MPP_CMD_SEND_BASE + 3, 76 /* for batch process start a task of one session */ 77 MPP_CMD_SET_SESSION_FD = MPP_CMD_SEND_BASE + 4, 78 MPP_CMD_SEND_BUTT, 79 80 MPP_CMD_POLL_BASE = 0x300, 81 MPP_CMD_POLL_HW_FINISH = MPP_CMD_POLL_BASE + 0, 82 MPP_CMD_POLL_BUTT, 83 84 MPP_CMD_CONTROL_BASE = 0x400, 85 MPP_CMD_RESET_SESSION = MPP_CMD_CONTROL_BASE + 0, 86 MPP_CMD_TRANS_FD_TO_IOVA = MPP_CMD_CONTROL_BASE + 1, 87 MPP_CMD_RELEASE_FD = MPP_CMD_CONTROL_BASE + 2, 88 MPP_CMD_SEND_CODEC_INFO = MPP_CMD_CONTROL_BASE + 3, 89 MPP_CMD_BAT_CMD = MPP_CMD_CONTROL_BASE + 4, 90 MPP_CMD_CONTROL_BUTT, 91 92 MPP_CMD_BUTT, 93 } MppServiceCmdType; 94 95 typedef struct mppReqV1_t { 96 RK_U32 cmd; 97 RK_U32 flag; 98 RK_U32 size; 99 RK_U32 offset; 100 RK_U64 data_ptr; 101 } MppReqV1; 102 103 typedef struct MppServiceCmdCap_t { 104 RK_U32 support_cmd; 105 RK_U32 query_cmd; 106 RK_U32 init_cmd; 107 RK_U32 send_cmd; 108 RK_U32 poll_cmd; 109 RK_U32 ctrl_cmd; 110 } MppServiceCmdCap; 111 112 #ifdef __cplusplus 113 extern "C" { 114 #endif 115 116 void check_mpp_service_cap(RK_U32 *codec_type, RK_U32 *hw_ids, MppServiceCmdCap *cap); 117 const MppServiceCmdCap *mpp_get_mpp_service_cmd_cap(void); 118 const char *mpp_get_mpp_service_name(void); 119 120 #ifdef __cplusplus 121 } 122 #endif 123 124 #endif /* __MPP_SERVICE_H__ */