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