/* SPDX-License-Identifier: Apache-2.0 OR MIT */
/*
 * Copyright (c) 2021 Rockchip Electronics Co., Ltd.
 */

#ifndef __MPP_SERVICE_IMPL_H__
#define __MPP_SERVICE_IMPL_H__

#include "mpp_list.h"

#include "mpp_device.h"
#include "mpp_service.h"

#define MAX_REG_OFFSET          64
#define MAX_RCB_OFFSET          32
#define MAX_INFO_COUNT          16

typedef struct FdTransInfo_t {
    RK_U32          reg_idx;
    RK_U32          offset;
} RegOffsetInfo;

typedef struct RcbInfo_t {
    RK_U32          reg_idx;
    RK_U32          size;
} RcbInfo;

typedef struct MppDevMppService_t {
    RK_S32          client_type;
    RK_S32          client;
    RK_S32          server;
    void            *serv_ctx;
    RK_S32          batch_io;
    MppCbCtx        *dev_cb;

    MppReqV1        *reqs;
    RK_S32          req_max;
    RK_S32          req_cnt;

    RegOffsetInfo   *reg_offset_info;
    RK_S32          reg_offset_max;
    RK_S32          reg_offset_count;
    RK_S32          reg_offset_pos;

    RcbInfo         *rcb_info;
    RK_S32          rcb_max;
    RK_S32          rcb_count;
    RK_S32          rcb_pos;

    MppDevBatCmd    bat_cmd;

    RK_S32          info_count;
    MppDevInfoCfg   info[MAX_INFO_COUNT];

    /* support max cmd buttom  */
    const MppServiceCmdCap *cap;
    RK_U32          support_set_info;
    RK_U32          support_set_rcb_info;
    RK_U32          support_hw_irq;

    pthread_mutex_t     lock_bufs;
    struct list_head    list_bufs;
} MppDevMppService;

#ifdef  __cplusplus
extern "C" {
#endif

RK_S32 mpp_service_ioctl(RK_S32 fd, RK_U32 cmd, RK_U32 size, void *param);
RK_S32 mpp_service_ioctl_request(RK_S32 fd, MppReqV1 *req);
MPP_RET mpp_service_check_cmd_valid(RK_U32 cmd, const MppServiceCmdCap *cap);

#ifdef  __cplusplus
}
#endif

#endif /* __MPP_SERVICE_IMPL_H__ */
