/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
/*
 * Copyright (c) 2021 MediaTek Inc.
 */

#ifndef MTK_DMX_ISDB3_H
#define MTK_DMX_ISDB3_H

#include "mtk_dmx_drv.h"
#include "mtk_dmx_dvrdrv.h"

#define cast_to_isdb3_filter(filter)	\
	((struct mtk_isdb3_filter *)filter)

#define cast_to_isdb3_feed(feed)	\
	((struct mtk_isdb3_feed *)feed)

#define cast_to_isdb3_dvr_private(priv)	\
	((struct mtk_isdb3_dvr_private*)priv)

enum dvr_isdb_filein_state {
	DVR_ISDB_FILEINE_INIT_STATE,
	DVR_ISDB_FILEINE_FIRST_BLOCK_STATE,
	DVR_ISDB_FILEINE_NORMAL_STATE,
};

struct mtk_isdb3_filter {
	struct dmx2_filter base;

	/* derived part */
};

struct mtk_isdb3_feed {
	struct dmx2_feed base;

	/* derived part */
};

struct mtk_isdb3_dmx_private {
	u32 stc_cw;
	u32 stc_bypass_3_2;
};

struct mtk_isdb3_dvr_private {
	enum dvr_isdb_filein_state dvr_isdb_filein_state;
	ssize_t prev_src_startoffset;
	ssize_t prev_dest_startoffset;
	ssize_t prev_decrypt_size;
	bool status;
};

int mtk_dmx_isdb3_init(struct mtk_demux2 *demux);
int mtk_dmx_isdb3_exit(struct mtk_demux2 *demux);

int mtk_dvr_isdb3_init(struct mtk_dvr2 *dvr);
int mtk_dvr_isdb3_exit(struct mtk_dvr2 *dvr);

void isdb3_handle_section_transfer(struct dmx2_feed *feed);


#endif /* MTK_DMX_ISDB3_H */
