/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
/*
 * MediaTek	Inc. (C) 2020. All rights	reserved.
 */

#ifndef _DEMOD_CORE_H_
#define _DEMOD_CORE_H_

#include "../cfm/cfm.h"
#include <linux/dvb/frontend.h>
#include <linux/i2c.h>
#include <linux/math64.h>
#include <linux/version.h>
#include <media/dvb_frontend.h>

/*-------------------------------------------------------------------*/
#define YAMATO_DRV_NAME "mediatek, mtk-yamato-demod"
/*---------------------------------------------------------------------------*/

static int _demod_i2c_write(
		struct i2c_client *client, u16 u16AddrCnt, u8 *pu8Addr, u16 u16Len, u8 *buf);
static int _demod_i2c_read(
		struct i2c_client *client, u16 u16AddrCnt, u8 *pu8Addr, u16 u16Len, u8 *buf);

u8 mtk_demod_write_register(
		u16 u16BusNumSlaveID, u8 u8addrcount, u8 *pu8addr, u16 u16size, u8 *pu8data);
u8 mtk_demod_read_register(
		u16 u16BusNumSlaveID, u8 u8addrcount, u8 *pu8addr, u16 u16size, u8 *pu8data);

typedef u8 (*demod_i2c_read)(
		u16 u16BusNumSlaveID, u8 u8addrcount, u8 *pu8addr, u16 u16size, u8 *pu8data);
typedef u8 (*demod_i2c_write)(
		u16 u16BusNumSlaveID, u8 u8addrcount, u8 *pu8addr, u16 u16size, u8 *pu8data);

struct mtk_extern_demod_dev {
	struct cdev cdev;
	struct dvb_adapter *adapter;
	struct dvb_frontend fe;
	struct i2c_client *client;
	struct mutex i2c_mutex;
	demod_i2c_read fpRead;
	demod_i2c_write fpWrite;
	u8 spectrum_inversion;
	u8 agc_polarity;
	u8 rf_strength;
	u16 ip_version;
	u8 if_gain;
	u8 model_info;
	int previous_system;
	bool fw_downloaded;
	unsigned int start_time;
	struct cfm_demod_ops dmd_ops;
	const char *pinctrl_ts;
	int lock_ever_flag;
	bool open_done_flag;
};

#endif
