Path: blob/master/drivers/media/dvb/dvb-core/demux.h
15112 views
/*1* demux.h2*3* Copyright (c) 2002 Convergence GmbH4*5* based on code:6* Copyright (c) 2000 Nokia Research Center7* Tampere, FINLAND8*9* This program is free software; you can redistribute it and/or10* modify it under the terms of the GNU Lesser General Public License11* as published by the Free Software Foundation; either version 2.112* of the License, or (at your option) any later version.13*14* This program is distributed in the hope that it will be useful,15* but WITHOUT ANY WARRANTY; without even the implied warranty of16* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the17* GNU General Public License for more details.18*19* You should have received a copy of the GNU Lesser General Public License20* along with this program; if not, write to the Free Software21* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.22*23*/2425#ifndef __DEMUX_H26#define __DEMUX_H2728#include <linux/types.h>29#include <linux/errno.h>30#include <linux/list.h>31#include <linux/time.h>32#include <linux/dvb/dmx.h>3334/*--------------------------------------------------------------------------*/35/* Common definitions */36/*--------------------------------------------------------------------------*/3738/*39* DMX_MAX_FILTER_SIZE: Maximum length (in bytes) of a section/PES filter.40*/4142#ifndef DMX_MAX_FILTER_SIZE43#define DMX_MAX_FILTER_SIZE 1844#endif4546/*47* DMX_MAX_SECFEED_SIZE: Maximum length (in bytes) of a private section feed filter.48*/4950#ifndef DMX_MAX_SECTION_SIZE51#define DMX_MAX_SECTION_SIZE 409652#endif53#ifndef DMX_MAX_SECFEED_SIZE54#define DMX_MAX_SECFEED_SIZE (DMX_MAX_SECTION_SIZE + 188)55#endif565758/*59* enum dmx_success: Success codes for the Demux Callback API.60*/6162enum dmx_success {63DMX_OK = 0, /* Received Ok */64DMX_LENGTH_ERROR, /* Incorrect length */65DMX_OVERRUN_ERROR, /* Receiver ring buffer overrun */66DMX_CRC_ERROR, /* Incorrect CRC */67DMX_FRAME_ERROR, /* Frame alignment error */68DMX_FIFO_ERROR, /* Receiver FIFO overrun */69DMX_MISSED_ERROR /* Receiver missed packet */70} ;7172/*--------------------------------------------------------------------------*/73/* TS packet reception */74/*--------------------------------------------------------------------------*/7576/* TS filter type for set() */7778#define TS_PACKET 1 /* send TS packets (188 bytes) to callback (default) */79#define TS_PAYLOAD_ONLY 2 /* in case TS_PACKET is set, only send the TS80payload (<=184 bytes per packet) to callback */81#define TS_DECODER 4 /* send stream to built-in decoder (if present) */82#define TS_DEMUX 8 /* in case TS_PACKET is set, send the TS to83the demux device, not to the dvr device */8485/* PES type for filters which write to built-in decoder */86/* these should be kept identical to the types in dmx.h */8788enum dmx_ts_pes89{ /* also send packets to decoder (if it exists) */90DMX_TS_PES_AUDIO0,91DMX_TS_PES_VIDEO0,92DMX_TS_PES_TELETEXT0,93DMX_TS_PES_SUBTITLE0,94DMX_TS_PES_PCR0,9596DMX_TS_PES_AUDIO1,97DMX_TS_PES_VIDEO1,98DMX_TS_PES_TELETEXT1,99DMX_TS_PES_SUBTITLE1,100DMX_TS_PES_PCR1,101102DMX_TS_PES_AUDIO2,103DMX_TS_PES_VIDEO2,104DMX_TS_PES_TELETEXT2,105DMX_TS_PES_SUBTITLE2,106DMX_TS_PES_PCR2,107108DMX_TS_PES_AUDIO3,109DMX_TS_PES_VIDEO3,110DMX_TS_PES_TELETEXT3,111DMX_TS_PES_SUBTITLE3,112DMX_TS_PES_PCR3,113114DMX_TS_PES_OTHER115};116117#define DMX_TS_PES_AUDIO DMX_TS_PES_AUDIO0118#define DMX_TS_PES_VIDEO DMX_TS_PES_VIDEO0119#define DMX_TS_PES_TELETEXT DMX_TS_PES_TELETEXT0120#define DMX_TS_PES_SUBTITLE DMX_TS_PES_SUBTITLE0121#define DMX_TS_PES_PCR DMX_TS_PES_PCR0122123124struct dmx_ts_feed {125int is_filtering; /* Set to non-zero when filtering in progress */126struct dmx_demux *parent; /* Back-pointer */127void *priv; /* Pointer to private data of the API client */128int (*set) (struct dmx_ts_feed *feed,129u16 pid,130int type,131enum dmx_ts_pes pes_type,132size_t circular_buffer_size,133struct timespec timeout);134int (*start_filtering) (struct dmx_ts_feed* feed);135int (*stop_filtering) (struct dmx_ts_feed* feed);136};137138/*--------------------------------------------------------------------------*/139/* Section reception */140/*--------------------------------------------------------------------------*/141142struct dmx_section_filter {143u8 filter_value [DMX_MAX_FILTER_SIZE];144u8 filter_mask [DMX_MAX_FILTER_SIZE];145u8 filter_mode [DMX_MAX_FILTER_SIZE];146struct dmx_section_feed* parent; /* Back-pointer */147void* priv; /* Pointer to private data of the API client */148};149150struct dmx_section_feed {151int is_filtering; /* Set to non-zero when filtering in progress */152struct dmx_demux* parent; /* Back-pointer */153void* priv; /* Pointer to private data of the API client */154155int check_crc;156u32 crc_val;157158u8 *secbuf;159u8 secbuf_base[DMX_MAX_SECFEED_SIZE];160u16 secbufp, seclen, tsfeedp;161162int (*set) (struct dmx_section_feed* feed,163u16 pid,164size_t circular_buffer_size,165int check_crc);166int (*allocate_filter) (struct dmx_section_feed* feed,167struct dmx_section_filter** filter);168int (*release_filter) (struct dmx_section_feed* feed,169struct dmx_section_filter* filter);170int (*start_filtering) (struct dmx_section_feed* feed);171int (*stop_filtering) (struct dmx_section_feed* feed);172};173174/*--------------------------------------------------------------------------*/175/* Callback functions */176/*--------------------------------------------------------------------------*/177178typedef int (*dmx_ts_cb) ( const u8 * buffer1,179size_t buffer1_length,180const u8 * buffer2,181size_t buffer2_length,182struct dmx_ts_feed* source,183enum dmx_success success);184185typedef int (*dmx_section_cb) ( const u8 * buffer1,186size_t buffer1_len,187const u8 * buffer2,188size_t buffer2_len,189struct dmx_section_filter * source,190enum dmx_success success);191192/*--------------------------------------------------------------------------*/193/* DVB Front-End */194/*--------------------------------------------------------------------------*/195196enum dmx_frontend_source {197DMX_MEMORY_FE,198DMX_FRONTEND_0,199DMX_FRONTEND_1,200DMX_FRONTEND_2,201DMX_FRONTEND_3,202DMX_STREAM_0, /* external stream input, e.g. LVDS */203DMX_STREAM_1,204DMX_STREAM_2,205DMX_STREAM_3206};207208struct dmx_frontend {209struct list_head connectivity_list; /* List of front-ends that can210be connected to a particular211demux */212enum dmx_frontend_source source;213};214215/*--------------------------------------------------------------------------*/216/* MPEG-2 TS Demux */217/*--------------------------------------------------------------------------*/218219/*220* Flags OR'ed in the capabilities field of struct dmx_demux.221*/222223#define DMX_TS_FILTERING 1224#define DMX_PES_FILTERING 2225#define DMX_SECTION_FILTERING 4226#define DMX_MEMORY_BASED_FILTERING 8 /* write() available */227#define DMX_CRC_CHECKING 16228#define DMX_TS_DESCRAMBLING 32229230/*231* Demux resource type identifier.232*/233234/*235* DMX_FE_ENTRY(): Casts elements in the list of registered236* front-ends from the generic type struct list_head237* to the type * struct dmx_frontend238*.239*/240241#define DMX_FE_ENTRY(list) list_entry(list, struct dmx_frontend, connectivity_list)242243struct dmx_demux {244u32 capabilities; /* Bitfield of capability flags */245struct dmx_frontend* frontend; /* Front-end connected to the demux */246void* priv; /* Pointer to private data of the API client */247int (*open) (struct dmx_demux* demux);248int (*close) (struct dmx_demux* demux);249int (*write) (struct dmx_demux* demux, const char __user *buf, size_t count);250int (*allocate_ts_feed) (struct dmx_demux* demux,251struct dmx_ts_feed** feed,252dmx_ts_cb callback);253int (*release_ts_feed) (struct dmx_demux* demux,254struct dmx_ts_feed* feed);255int (*allocate_section_feed) (struct dmx_demux* demux,256struct dmx_section_feed** feed,257dmx_section_cb callback);258int (*release_section_feed) (struct dmx_demux* demux,259struct dmx_section_feed* feed);260int (*add_frontend) (struct dmx_demux* demux,261struct dmx_frontend* frontend);262int (*remove_frontend) (struct dmx_demux* demux,263struct dmx_frontend* frontend);264struct list_head* (*get_frontends) (struct dmx_demux* demux);265int (*connect_frontend) (struct dmx_demux* demux,266struct dmx_frontend* frontend);267int (*disconnect_frontend) (struct dmx_demux* demux);268269int (*get_pes_pids) (struct dmx_demux* demux, u16 *pids);270271int (*get_caps) (struct dmx_demux* demux, struct dmx_caps *caps);272273int (*set_source) (struct dmx_demux* demux, const dmx_source_t *src);274275int (*get_stc) (struct dmx_demux* demux, unsigned int num,276u64 *stc, unsigned int *base);277};278279#endif /* #ifndef __DEMUX_H */280281282