Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * dmxdev.h
0003  *
0004  * Copyright (C) 2000 Ralph Metzler & Marcus Metzler
0005  *                    for convergence integrated media GmbH
0006  *
0007  * This program is free software; you can redistribute it and/or
0008  * modify it under the terms of the GNU Lesser General Public License
0009  * as published by the Free Software Foundation; either version 2.1
0010  * of the License, or (at your option) any later version.
0011  *
0012  * This program is distributed in the hope that it will be useful,
0013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0015  * GNU General Public License for more details.
0016  *
0017  */
0018 
0019 #ifndef _DMXDEV_H_
0020 #define _DMXDEV_H_
0021 
0022 #include <linux/types.h>
0023 #include <linux/spinlock.h>
0024 #include <linux/time.h>
0025 #include <linux/timer.h>
0026 #include <linux/wait.h>
0027 #include <linux/fs.h>
0028 #include <linux/string.h>
0029 #include <linux/mutex.h>
0030 #include <linux/slab.h>
0031 
0032 #include <linux/dvb/dmx.h>
0033 
0034 #include <media/dvbdev.h>
0035 #include <media/demux.h>
0036 #include <media/dvb_ringbuffer.h>
0037 #include <media/dvb_vb2.h>
0038 
0039 /**
0040  * enum dmxdev_type - type of demux filter type.
0041  *
0042  * @DMXDEV_TYPE_NONE:   no filter set.
0043  * @DMXDEV_TYPE_SEC:    section filter.
0044  * @DMXDEV_TYPE_PES:    Program Elementary Stream (PES) filter.
0045  */
0046 enum dmxdev_type {
0047     DMXDEV_TYPE_NONE,
0048     DMXDEV_TYPE_SEC,
0049     DMXDEV_TYPE_PES,
0050 };
0051 
0052 /**
0053  * enum dmxdev_state - state machine for the dmxdev.
0054  *
0055  * @DMXDEV_STATE_FREE:      indicates that the filter is freed.
0056  * @DMXDEV_STATE_ALLOCATED: indicates that the filter was allocated
0057  *              to be used.
0058  * @DMXDEV_STATE_SET:       indicates that the filter parameters are set.
0059  * @DMXDEV_STATE_GO:        indicates that the filter is running.
0060  * @DMXDEV_STATE_DONE:      indicates that a packet was already filtered
0061  *              and the filter is now disabled.
0062  *              Set only if %DMX_ONESHOT. See
0063  *              &dmx_sct_filter_params.
0064  * @DMXDEV_STATE_TIMEDOUT:  Indicates a timeout condition.
0065  */
0066 enum dmxdev_state {
0067     DMXDEV_STATE_FREE,
0068     DMXDEV_STATE_ALLOCATED,
0069     DMXDEV_STATE_SET,
0070     DMXDEV_STATE_GO,
0071     DMXDEV_STATE_DONE,
0072     DMXDEV_STATE_TIMEDOUT
0073 };
0074 
0075 /**
0076  * struct dmxdev_feed - digital TV dmxdev feed
0077  *
0078  * @pid:    Program ID to be filtered
0079  * @ts:     pointer to &struct dmx_ts_feed
0080  * @next:   &struct list_head pointing to the next feed.
0081  */
0082 
0083 struct dmxdev_feed {
0084     u16 pid;
0085     struct dmx_ts_feed *ts;
0086     struct list_head next;
0087 };
0088 
0089 /**
0090  * struct dmxdev_filter - digital TV dmxdev filter
0091  *
0092  * @filter: a union describing a dmxdev filter.
0093  *      Currently used only for section filters.
0094  * @filter.sec: a &struct dmx_section_filter pointer.
0095  *      For section filter only.
0096  * @feed:   a union describing a dmxdev feed.
0097  *      Depending on the filter type, it can be either
0098  *      @feed.ts or @feed.sec.
0099  * @feed.ts:    a &struct list_head list.
0100  *      For TS and PES feeds.
0101  * @feed.sec:   a &struct dmx_section_feed pointer.
0102  *      For section feed only.
0103  * @params: a union describing dmxdev filter parameters.
0104  *      Depending on the filter type, it can be either
0105  *      @params.sec or @params.pes.
0106  * @params.sec: a &struct dmx_sct_filter_params embedded struct.
0107  *      For section filter only.
0108  * @params.pes: a &struct dmx_pes_filter_params embedded struct.
0109  *      For PES filter only.
0110  * @type:   type of the dmxdev filter, as defined by &enum dmxdev_type.
0111  * @state:  state of the dmxdev filter, as defined by &enum dmxdev_state.
0112  * @dev:    pointer to &struct dmxdev.
0113  * @buffer: an embedded &struct dvb_ringbuffer buffer.
0114  * @vb2_ctx:    control struct for VB2 handler
0115  * @mutex:  protects the access to &struct dmxdev_filter.
0116  * @timer:  &struct timer_list embedded timer, used to check for
0117  *      feed timeouts.
0118  *      Only for section filter.
0119  * @todo:   index for the @secheader.
0120  *      Only for section filter.
0121  * @secheader:  buffer cache to parse the section header.
0122  *      Only for section filter.
0123  */
0124 struct dmxdev_filter {
0125     union {
0126         struct dmx_section_filter *sec;
0127     } filter;
0128 
0129     union {
0130         /* list of TS and PES feeds (struct dmxdev_feed) */
0131         struct list_head ts;
0132         struct dmx_section_feed *sec;
0133     } feed;
0134 
0135     union {
0136         struct dmx_sct_filter_params sec;
0137         struct dmx_pes_filter_params pes;
0138     } params;
0139 
0140     enum dmxdev_type type;
0141     enum dmxdev_state state;
0142     struct dmxdev *dev;
0143     struct dvb_ringbuffer buffer;
0144     struct dvb_vb2_ctx vb2_ctx;
0145 
0146     struct mutex mutex;
0147 
0148     /* only for sections */
0149     struct timer_list timer;
0150     int todo;
0151     u8 secheader[3];
0152 };
0153 
0154 /**
0155  * struct dmxdev - Describes a digital TV demux device.
0156  *
0157  * @dvbdev:     pointer to &struct dvb_device associated with
0158  *          the demux device node.
0159  * @dvr_dvbdev:     pointer to &struct dvb_device associated with
0160  *          the dvr device node.
0161  * @filter:     pointer to &struct dmxdev_filter.
0162  * @demux:      pointer to &struct dmx_demux.
0163  * @filternum:      number of filters.
0164  * @capabilities:   demux capabilities as defined by &enum dmx_demux_caps.
0165  * @may_do_mmap:    flag used to indicate if the device may do mmap.
0166  * @exit:       flag to indicate that the demux is being released.
0167  * @dvr_orig_fe:    pointer to &struct dmx_frontend.
0168  * @dvr_buffer:     embedded &struct dvb_ringbuffer for DVB output.
0169  * @dvr_vb2_ctx:    control struct for VB2 handler
0170  * @mutex:      protects the usage of this structure.
0171  * @lock:       protects access to &dmxdev->filter->data.
0172  */
0173 struct dmxdev {
0174     struct dvb_device *dvbdev;
0175     struct dvb_device *dvr_dvbdev;
0176 
0177     struct dmxdev_filter *filter;
0178     struct dmx_demux *demux;
0179 
0180     int filternum;
0181     int capabilities;
0182 
0183     unsigned int may_do_mmap:1;
0184     unsigned int exit:1;
0185 #define DMXDEV_CAP_DUPLEX 1
0186     struct dmx_frontend *dvr_orig_fe;
0187 
0188     struct dvb_ringbuffer dvr_buffer;
0189 #define DVR_BUFFER_SIZE (10*188*1024)
0190 
0191     struct dvb_vb2_ctx dvr_vb2_ctx;
0192 
0193     struct mutex mutex;
0194     spinlock_t lock;
0195 };
0196 
0197 /**
0198  * dvb_dmxdev_init - initializes a digital TV demux and registers both demux
0199  *  and DVR devices.
0200  *
0201  * @dmxdev: pointer to &struct dmxdev.
0202  * @adap: pointer to &struct dvb_adapter.
0203  */
0204 int dvb_dmxdev_init(struct dmxdev *dmxdev, struct dvb_adapter *adap);
0205 
0206 /**
0207  * dvb_dmxdev_release - releases a digital TV demux and unregisters it.
0208  *
0209  * @dmxdev: pointer to &struct dmxdev.
0210  */
0211 void dvb_dmxdev_release(struct dmxdev *dmxdev);
0212 
0213 #endif /* _DMXDEV_H_ */