/*1* dmxdev.h2*3* Copyright (C) 2000 Ralph Metzler & Marcus Metzler4* for convergence integrated media GmbH5*6* This program is free software; you can redistribute it and/or7* modify it under the terms of the GNU Lesser General Public License8* as published by the Free Software Foundation; either version 2.19* of the License, or (at your option) any later version.10*11* This program is distributed in the hope that it will be useful,12* but WITHOUT ANY WARRANTY; without even the implied warranty of13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14* GNU General Public License for more details.15*16*/1718#ifndef _DMXDEV_H_19#define _DMXDEV_H_2021#include <linux/types.h>22#include <linux/spinlock.h>23#include <linux/time.h>24#include <linux/timer.h>25#include <linux/wait.h>26#include <linux/fs.h>27#include <linux/string.h>28#include <linux/mutex.h>29#include <linux/slab.h>3031#include <linux/dvb/dmx.h>3233#include <media/dvbdev.h>34#include <media/demux.h>35#include <media/dvb_ringbuffer.h>36#include <media/dvb_vb2.h>3738/**39* enum dmxdev_type - type of demux filter type.40*41* @DMXDEV_TYPE_NONE: no filter set.42* @DMXDEV_TYPE_SEC: section filter.43* @DMXDEV_TYPE_PES: Program Elementary Stream (PES) filter.44*/45enum dmxdev_type {46DMXDEV_TYPE_NONE,47DMXDEV_TYPE_SEC,48DMXDEV_TYPE_PES,49};5051/**52* enum dmxdev_state - state machine for the dmxdev.53*54* @DMXDEV_STATE_FREE: indicates that the filter is freed.55* @DMXDEV_STATE_ALLOCATED: indicates that the filter was allocated56* to be used.57* @DMXDEV_STATE_SET: indicates that the filter parameters are set.58* @DMXDEV_STATE_GO: indicates that the filter is running.59* @DMXDEV_STATE_DONE: indicates that a packet was already filtered60* and the filter is now disabled.61* Set only if %DMX_ONESHOT. See62* &dmx_sct_filter_params.63* @DMXDEV_STATE_TIMEDOUT: Indicates a timeout condition.64*/65enum dmxdev_state {66DMXDEV_STATE_FREE,67DMXDEV_STATE_ALLOCATED,68DMXDEV_STATE_SET,69DMXDEV_STATE_GO,70DMXDEV_STATE_DONE,71DMXDEV_STATE_TIMEDOUT72};7374/**75* struct dmxdev_feed - digital TV dmxdev feed76*77* @pid: Program ID to be filtered78* @ts: pointer to &struct dmx_ts_feed79* @next: &struct list_head pointing to the next feed.80*/8182struct dmxdev_feed {83u16 pid;84struct dmx_ts_feed *ts;85struct list_head next;86};8788/**89* struct dmxdev_filter - digital TV dmxdev filter90*91* @filter: a union describing a dmxdev filter.92* Currently used only for section filters.93* @filter.sec: a &struct dmx_section_filter pointer.94* For section filter only.95* @feed: a union describing a dmxdev feed.96* Depending on the filter type, it can be either97* @feed.ts or @feed.sec.98* @feed.ts: a &struct list_head list.99* For TS and PES feeds.100* @feed.sec: a &struct dmx_section_feed pointer.101* For section feed only.102* @params: a union describing dmxdev filter parameters.103* Depending on the filter type, it can be either104* @params.sec or @params.pes.105* @params.sec: a &struct dmx_sct_filter_params embedded struct.106* For section filter only.107* @params.pes: a &struct dmx_pes_filter_params embedded struct.108* For PES filter only.109* @type: type of the dmxdev filter, as defined by &enum dmxdev_type.110* @state: state of the dmxdev filter, as defined by &enum dmxdev_state.111* @dev: pointer to &struct dmxdev.112* @buffer: an embedded &struct dvb_ringbuffer buffer.113* @vb2_ctx: control struct for VB2 handler114* @mutex: protects the access to &struct dmxdev_filter.115* @timer: &struct timer_list embedded timer, used to check for116* feed timeouts.117* Only for section filter.118* @todo: index for the @secheader.119* Only for section filter.120* @secheader: buffer cache to parse the section header.121* Only for section filter.122*/123struct dmxdev_filter {124union {125struct dmx_section_filter *sec;126} filter;127128union {129/* list of TS and PES feeds (struct dmxdev_feed) */130struct list_head ts;131struct dmx_section_feed *sec;132} feed;133134union {135struct dmx_sct_filter_params sec;136struct dmx_pes_filter_params pes;137} params;138139enum dmxdev_type type;140enum dmxdev_state state;141struct dmxdev *dev;142struct dvb_ringbuffer buffer;143struct dvb_vb2_ctx vb2_ctx;144145struct mutex mutex;146147/* only for sections */148struct timer_list timer;149int todo;150u8 secheader[3];151};152153/**154* struct dmxdev - Describes a digital TV demux device.155*156* @dvbdev: pointer to &struct dvb_device associated with157* the demux device node.158* @dvr_dvbdev: pointer to &struct dvb_device associated with159* the dvr device node.160* @filter: pointer to &struct dmxdev_filter.161* @demux: pointer to &struct dmx_demux.162* @filternum: number of filters.163* @capabilities: demux capabilities as defined by &enum dmx_demux_caps.164* @may_do_mmap: flag used to indicate if the device may do mmap.165* @exit: flag to indicate that the demux is being released.166* @dvr_orig_fe: pointer to &struct dmx_frontend.167* @dvr_buffer: embedded &struct dvb_ringbuffer for DVB output.168* @dvr_vb2_ctx: control struct for VB2 handler169* @mutex: protects the usage of this structure.170* @lock: protects access to &dmxdev->filter->data.171*/172struct dmxdev {173struct dvb_device *dvbdev;174struct dvb_device *dvr_dvbdev;175176struct dmxdev_filter *filter;177struct dmx_demux *demux;178179int filternum;180int capabilities;181182unsigned int may_do_mmap:1;183unsigned int exit:1;184#define DMXDEV_CAP_DUPLEX 1185struct dmx_frontend *dvr_orig_fe;186187struct dvb_ringbuffer dvr_buffer;188#define DVR_BUFFER_SIZE (10*188*1024)189190struct dvb_vb2_ctx dvr_vb2_ctx;191192struct mutex mutex;193spinlock_t lock;194};195196/**197* dvb_dmxdev_init - initializes a digital TV demux and registers both demux198* and DVR devices.199*200* @dmxdev: pointer to &struct dmxdev.201* @adap: pointer to &struct dvb_adapter.202*/203int dvb_dmxdev_init(struct dmxdev *dmxdev, struct dvb_adapter *adap);204205/**206* dvb_dmxdev_release - releases a digital TV demux and unregisters it.207*208* @dmxdev: pointer to &struct dmxdev.209*/210void dvb_dmxdev_release(struct dmxdev *dmxdev);211212#endif /* _DMXDEV_H_ */213214215