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

#ifndef MDRV_DEMUX_EVENT_H
#define MDRV_DEMUX_EVENT_H

#include <linux/types.h>
#include <linux/dvb/dmx_mtk.h>

#define DMX_DEFAULT_EVENTQ_NUM	(300)

struct dmx_kevent {
	struct list_head list;
	struct dmx_subscribed_event *sev;
	struct dmx_event event;
};

struct dmx_subscribed_event {
	struct list_head	list;
	u32					type;
	u32					mask;
	u32					flags;
	struct dmx_fh		*fh;
	unsigned int		elems;
	unsigned int		first;
	unsigned int		in_use;
	struct dmx_kevent	events[];
};

int mdrv_demux_event_queue(struct dmx_fh_mgr *mgr, const struct dmx_event *ev);
int mdrv_demux_event_dequeue(struct dmx_fh *fh, struct dmx_event *ev, int nonblocking);

int mdrv_demux_event_subscribe(struct dmx_fh *fh,
		const struct dmx_event_subscription *sub, u32 elems);
int mdrv_demux_event_unsubscribe(struct dmx_fh *fh,
		const struct dmx_event_subscription *sub);
int mdrv_demux_event_unsubscribe_all(struct dmx_fh *fh);

#endif	/* MDRV_DEMUX_EVENT_H */
