/*
 * Copyright (C) 2018 MediaTek Inc.
 *
 * 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 __INTERFACE_H__
#define __INTERFACE_H__

#include <linux/fs.h>

#ifdef MET_USER_EVENT_SUPPORT
extern int tag_reg(struct file_operations *const fops, struct kobject *kobj);
extern int tag_unreg(void);
#include "met_drv.h"
#include "met_tag.h"
extern struct bltable_t bltab;
#endif

extern struct metdevice met_stat;
extern struct metdevice met_cpupmu;
extern struct metdevice met_cookie;
extern struct metdevice met_memstat;
extern struct metdevice met_switch;
extern struct metdevice met_trace_event;
extern struct metdevice met_dummy_header;
extern struct metdevice met_backlight;

/* This variable will decide which method to access the CPU PMU counter */
/*     0: access registers directly */
/*     others: via Linux perf driver */
extern unsigned int met_cpu_pmu_method;

/*
 * controls whether re-configuring pmu events after leaving cpu off state
 */
extern unsigned int met_cpu_pm_pmu_reconfig;

extern int met_parse_num(const char *str, unsigned int *value, int len);
extern void met_set_suspend_notify(int flag);

#define	PR_CPU_NOTIFY
#if	defined(PR_CPU_NOTIFY)
extern int met_cpu_notify;
#endif

//#undef	MET_BOOT_MSG
#define	MET_BOOT_MSG
#if	defined(MET_BOOT_MSG)
extern char met_boot_msg_tmp[256];
extern int pr_bootmsg(int str_len, char *str);
#define	PR_BOOTMSG(fmt, args...) { \
	int str_len = snprintf(met_boot_msg_tmp, sizeof(met_boot_msg_tmp), \
			       fmt, ##args); \
	pr_bootmsg(str_len, met_boot_msg_tmp); }
#define	PR_BOOTMSG_ONCE(fmt, args...) { \
	static int once; \
	if (!once) { \
		int str_len = snprintf(met_boot_msg_tmp, \
				       sizeof(met_boot_msg_tmp), \
				       fmt, ##args); \
		pr_bootmsg(str_len, met_boot_msg_tmp); \
		once = 1; \
	} }
#else
#define	pr_bootmsg(str_len, str)
#define PR_BOOTMSG(fmt, args...)
#define	PR_BOOTMSG_ONCE(fmt, args...)
#endif

#endif	/* __INTERFACE_H__ */
