/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (c) 2019-2020 MediaTek Inc.
 * Author: Elle.ko <elle.ko@mediatek.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
#ifndef _MAD_TEE_INTERFACE_H_
#define _MAD_TEE_INTERFACE_H_
#include <linux/types.h>
#define INVALID_TEE_PARSER_ID (0xFFFFFFFF)
#define VDEC_IF 0
typedef enum {
	E_VES_PARSER_CODEC_AVC = 0,
	E_VES_PARSER_CODEC_AVC_DV,
	E_VES_PARSER_CODEC_HEVC,
	E_VES_PARSER_CODEC_HEVC_DV,
	E_VES_PARSER_CODEC_MPEG2,
	E_VES_PARSER_CODEC_AVS,
	E_VES_PARSER_CODEC_AVS2,
	E_VES_PARSER_CODEC_VC1,
	E_VES_PARSER_CODEC_BY_PASS,
	E_VES_PARSER_CODEC_VP9,
	E_VES_PARSER_CODEC_MPEG4,
	E_VES_PARSER_CODEC_VP8,
	E_VES_PARSER_CODEC_H263,
	E_VES_PARSER_CODEC_S263,
	E_VES_PARSER_CODEC_VVC,
	E_VES_PARSER_CODEC_AVS3,
	E_VES_PARSER_CODEC_NUM,
} EN_VES_PARSER_CODEC_TYPE;
/*struct tee_framing_param {
	uint64_t es_start;
	uint64_t es_end;
	uint8_t update_parser;	// update parser with ES data info or not
	uint32_t es_data_offset;
	uint32_t es_data_size;
	uint32_t find_ret;
	uint64_t unit_base;
	void *unit_table;
	uint32_t unit_table_size;
	uint32_t unit_entity_size;
	uint32_t unit_found_num;
	uint8_t find_last_unit;
};*/
struct ST_AUDIO_PARSER_FRAMING_PARAM {
// TLV param
uint16_t u16ParserId;
uint32_t u32SequenceNum;

uint32_t u32SequenceLng;
// Input buf info
uint32_t u32InSecureEsDataOffset;
uint32_t u32InSecureEsDataSize;
uint32_t u32InNonSecureEsDataOffset;
uint32_t u32InNonSecureEsDataSize;
// Output buf info
uint32_t u32OutSecureEsDataOffset;
uint32_t u32OutSecureEsDataSize;
uint32_t u32OutNonSecureEsDataOffset;
uint32_t u32OutNonSecureEsDataSize;
// Padding
uint16_t u16Reserved;
};

struct _ST_AUDIO_SECURE_INFO {
uint8_t  u8SvpEnableFlag;
uint32_t u32pipelineID;
uint16_t u16ParserId;
uint8_t  u8Version;
uint8_t  u8Reserved;
uint32_t u32Reserved[2];
};
struct tee_pre_parse_param {
	uint32_t u32CodecType;
	uint64_t u64EsDataStart;
	uint64_t u64EsDataEnd;
	uint32_t u32Width;
	uint32_t u32Height;
	uint32_t u32FrameRate;
	uint32_t u32BitDepth;
	uint32_t u32DpbSize;
};
struct tee_vcu_svp_call_arg {
	uint64_t u64Data;
	uint32_t u32Size;
};
struct parser_create_param {
	uint64_t u64SecureEsStartAddr;
	uint64_t u64SecureEsEndAddr;
	uint64_t u64NonSecureEsStartAddr;
	uint64_t u64NonSecureEsEndAddr;
	uint8_t u8IncompleteBs;
	uint16_t u16ParserId;
};
int mad_parser_tee_create(u16 parser_id, 
	struct parser_create_param *param);
int mad_parser_tee_destroy(u16 parser_id);
int mad_parser_tee_framing(u16 parser_id,
	struct ST_AUDIO_PARSER_FRAMING_PARAM *framing_param);
int mad_parser_tee_setmode(u16 parser_id,
	struct _ST_AUDIO_SECURE_INFO *param);
#endif
