Files
mpp/osal/inc/mpp_device.h
Herman Chen 16ce9d1f6b [mpp_server]: Add mpp_server module for batch mode
Batch mode will send multiple task to kernel at one time. And its
non-block poll is triggered by timer and looper.

This mode will reduce the ioctl overhead on ultra multi-instance case.

Main features and some notes:
1. Each client type has independence batch server.
2. Each mpp_device can attach or not attach to server independently.
3. When a device is attached to server all its tasks will be sent to
kernel through the server session not original client session.
4. The tasks are sent non-block and wait in block or non-block.
5. The batch mode can only be switch on/off when hardware is not
working.

Change-Id: I07462d852cb002259d2873e13c12f6f8a489ba8e
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
2021-06-04 09:02:30 +08:00

117 lines
2.9 KiB
C

/*
* Copyright 2020 Rockchip Electronics Co. LTD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __MPP_DEVICE_H__
#define __MPP_DEVICE_H__
#include "mpp_err.h"
#include "mpp_dev_defs.h"
typedef enum MppDevIoctlCmd_e {
/* device batch mode config */
MPP_DEV_BATCH_ON,
MPP_DEV_BATCH_OFF,
/* hardware operation setup config */
MPP_DEV_REG_WR,
MPP_DEV_REG_RD,
MPP_DEV_REG_OFFSET,
MPP_DEV_RCB_INFO,
MPP_DEV_SET_INFO,
MPP_DEV_CMD_SEND,
MPP_DEV_CMD_POLL,
MPP_DEV_IOCTL_CMD_BUTT,
} MppDevIoctlCmd;
/* for MPP_DEV_REG_WR */
typedef struct MppDevRegWrCfg_t {
void *reg;
RK_U32 size;
RK_U32 offset;
} MppDevRegWrCfg;
/* for MPP_DEV_REG_RD */
typedef struct MppDevRegRdCfg_t {
void *reg;
RK_U32 size;
RK_U32 offset;
} MppDevRegRdCfg;
/* for MPP_DEV_REG_OFFSET */
typedef struct MppDevRegOffsetCfg_t {
RK_U32 reg_idx;
RK_U32 offset;
} MppDevRegOffsetCfg;
/* for MPP_DEV_RCB_INFO */
typedef struct MppDevRcbInfoCfg_t {
RK_U32 reg_idx;
RK_U32 size;
} MppDevRcbInfoCfg;
/* for MPP_DEV_SET_INFO */
typedef struct MppDevSetInfoCfg_t {
RK_U32 type;
RK_U32 flag;
RK_U64 data;
} MppDevInfoCfg;
typedef struct MppDevApi_t {
const char *name;
RK_U32 ctx_size;
MPP_RET (*init)(void *ctx, MppClientType type);
MPP_RET (*deinit)(void *ctx);
/* bat mode function */
MPP_RET (*attach)(void *ctx);
MPP_RET (*detach)(void *ctx);
/* config the cmd on preparing */
MPP_RET (*reg_wr)(void *ctx, MppDevRegWrCfg *cfg);
MPP_RET (*reg_rd)(void *ctx, MppDevRegRdCfg *cfg);
MPP_RET (*reg_offset)(void *ctx, MppDevRegOffsetCfg *cfg);
MPP_RET (*rcb_info)(void *ctx, MppDevRcbInfoCfg *cfg);
MPP_RET (*set_info)(void *ctx, MppDevInfoCfg *cfg);
/* send cmd to hardware */
MPP_RET (*cmd_send)(void *ctx);
/* poll cmd from hardware */
MPP_RET (*cmd_poll)(void *ctx);
} MppDevApi;
typedef void* MppDev;
#ifdef __cplusplus
extern "C" {
#endif
MPP_RET mpp_dev_init(MppDev *ctx, MppClientType type);
MPP_RET mpp_dev_deinit(MppDev ctx);
MPP_RET mpp_dev_ioctl(MppDev ctx, RK_S32 cmd, void *param);
/* special helper function for large address offset config */
MPP_RET mpp_dev_set_reg_offset(MppDev dev, RK_S32 index, RK_U32 offset);
#ifdef __cplusplus
}
#endif
#endif /* __MPP_DEVICE_H__ */