^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * dvb_demux.h: DVB kernel demux API
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (C) 2000-2001 Marcus Metzler & Ralph Metzler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * for convergence integrated media GmbH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * This program is free software; you can redistribute it and/or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * modify it under the terms of the GNU Lesser General Public License
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * as published by the Free Software Foundation; either version 2.1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * of the License, or (at your option) any later version.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * This program is distributed in the hope that it will be useful,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * but WITHOUT ANY WARRANTY; without even the implied warranty of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * GNU General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #ifndef _DVB_DEMUX_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #define _DVB_DEMUX_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/time.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/timer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <media/demux.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * enum dvb_dmx_filter_type - type of demux feed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * @DMX_TYPE_TS: feed is in TS mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * @DMX_TYPE_SEC: feed is in Section mode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) enum dvb_dmx_filter_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) DMX_TYPE_TS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) DMX_TYPE_SEC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * enum dvb_dmx_state - state machine for a demux filter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * @DMX_STATE_FREE: indicates that the filter is freed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * @DMX_STATE_ALLOCATED: indicates that the filter was allocated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * to be used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * @DMX_STATE_READY: indicates that the filter is ready
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * to be used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * @DMX_STATE_GO: indicates that the filter is running.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) enum dvb_dmx_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) DMX_STATE_FREE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) DMX_STATE_ALLOCATED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) DMX_STATE_READY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) DMX_STATE_GO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #define DVB_DEMUX_MASK_MAX 18
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #define MAX_PID 0x1fff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #define SPEED_PKTS_INTERVAL 50000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * struct dvb_demux_filter - Describes a DVB demux section filter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) * @filter: Section filter as defined by &struct dmx_section_filter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) * @maskandmode: logical ``and`` bit mask.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * @maskandnotmode: logical ``and not`` bit mask.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) * @doneq: flag that indicates when a filter is ready.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) * @next: pointer to the next section filter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) * @feed: &struct dvb_demux_feed pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) * @index: index of the used demux filter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) * @state: state of the filter as described by &enum dvb_dmx_state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) * @type: type of the filter as described
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * by &enum dvb_dmx_filter_type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) struct dvb_demux_filter {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) struct dmx_section_filter filter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) u8 maskandmode[DMX_MAX_FILTER_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) u8 maskandnotmode[DMX_MAX_FILTER_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) bool doneq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) struct dvb_demux_filter *next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) struct dvb_demux_feed *feed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) int index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) enum dvb_dmx_state state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) enum dvb_dmx_filter_type type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) /* private: used only by av7110 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) u16 hw_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) * struct dvb_demux_feed - describes a DVB field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) * @feed: a union describing a digital TV feed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) * Depending on the feed type, it can be either
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) * @feed.ts or @feed.sec.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) * @feed.ts: a &struct dmx_ts_feed pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) * For TS feed only.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) * @feed.sec: a &struct dmx_section_feed pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) * For section feed only.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) * @cb: a union describing digital TV callbacks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) * Depending on the feed type, it can be either
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) * @cb.ts or @cb.sec.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * @cb.ts: a dmx_ts_cb() calback function pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) * For TS feed only.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) * @cb.sec: a dmx_section_cb() callback function pointer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) * For section feed only.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) * @demux: pointer to &struct dvb_demux.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) * @priv: private data that can optionally be used by a DVB driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) * @type: type of the filter, as defined by &enum dvb_dmx_filter_type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) * @state: state of the filter as defined by &enum dvb_dmx_state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) * @pid: PID to be filtered.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) * @timeout: feed timeout.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) * @filter: pointer to &struct dvb_demux_filter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) * @buffer_flags: Buffer flags used to report discontinuity users via DVB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) * memory mapped API, as defined by &enum dmx_buffer_flags.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) * @ts_type: type of TS, as defined by &enum ts_filter_type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) * @pes_type: type of PES, as defined by &enum dmx_ts_pes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) * @cc: MPEG-TS packet continuity counter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) * @pusi_seen: if true, indicates that a discontinuity was detected.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) * it is used to prevent feeding of garbage from previous section.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) * @peslen: length of the PES (Packet Elementary Stream).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) * @list_head: head for the list of digital TV demux feeds.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) * @index: a unique index for each feed. Can be used as hardware
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) * pid filter index.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) struct dvb_demux_feed {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) struct dmx_ts_feed ts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) struct dmx_section_feed sec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) } feed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) dmx_ts_cb ts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) dmx_section_cb sec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) } cb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) struct dvb_demux *demux;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) void *priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) enum dvb_dmx_filter_type type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) enum dvb_dmx_state state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) u16 pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) ktime_t timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) struct dvb_demux_filter *filter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) u32 buffer_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) enum ts_filter_type ts_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) enum dmx_ts_pes pes_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) int cc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) bool pusi_seen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) u16 peslen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) struct list_head list_head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) unsigned int index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) * struct dvb_demux - represents a digital TV demux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) * @dmx: embedded &struct dmx_demux with demux capabilities
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) * and callbacks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) * @priv: private data that can optionally be used by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) * a DVB driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) * @filternum: maximum amount of DVB filters.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) * @feednum: maximum amount of DVB feeds.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) * @start_feed: callback routine to be called in order to start
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) * a DVB feed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) * @stop_feed: callback routine to be called in order to stop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) * a DVB feed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) * @write_to_decoder: callback routine to be called if the feed is TS and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) * it is routed to an A/V decoder, when a new TS packet
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) * is received.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) * Used only on av7110-av.c.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) * @check_crc32: callback routine to check CRC. If not initialized,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) * dvb_demux will use an internal one.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) * @memcopy: callback routine to memcopy received data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) * If not initialized, dvb_demux will default to memcpy().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) * @users: counter for the number of demux opened file descriptors.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) * Currently, it is limited to 10 users.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) * @filter: pointer to &struct dvb_demux_filter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) * @feed: pointer to &struct dvb_demux_feed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) * @frontend_list: &struct list_head with frontends used by the demux.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) * @pesfilter: array of &struct dvb_demux_feed with the PES types
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) * that will be filtered.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) * @pids: list of filtered program IDs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) * @feed_list: &struct list_head with feeds.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) * @tsbuf: temporary buffer used internally to store TS packets.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) * @tsbufp: temporary buffer index used internally.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) * @mutex: pointer to &struct mutex used to protect feed set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) * logic.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) * @lock: pointer to &spinlock_t, used to protect buffer handling.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) * @cnt_storage: buffer used for TS/TEI continuity check.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) * @speed_last_time: &ktime_t used for TS speed check.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) * @speed_pkts_cnt: packets count used for TS speed check.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) struct dvb_demux {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) struct dmx_demux dmx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) void *priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) int filternum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) int feednum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) int (*start_feed)(struct dvb_demux_feed *feed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) int (*stop_feed)(struct dvb_demux_feed *feed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) int (*write_to_decoder)(struct dvb_demux_feed *feed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) const u8 *buf, size_t len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) u32 (*check_crc32)(struct dvb_demux_feed *feed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) const u8 *buf, size_t len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) void (*memcopy)(struct dvb_demux_feed *feed, u8 *dst,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) const u8 *src, size_t len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) int users;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) #define MAX_DVB_DEMUX_USERS 10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) struct dvb_demux_filter *filter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) struct dvb_demux_feed *feed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) struct list_head frontend_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) struct dvb_demux_feed *pesfilter[DMX_PES_OTHER];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) u16 pids[DMX_PES_OTHER];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) #define DMX_MAX_PID 0x2000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) struct list_head feed_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) u8 tsbuf[204];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) int tsbufp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) struct mutex mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) spinlock_t lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) uint8_t *cnt_storage; /* for TS continuity check */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) ktime_t speed_last_time; /* for TS speed check */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) uint32_t speed_pkts_cnt; /* for TS speed check */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) /* private: used only on av7110 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) int playing;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) int recording;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) * dvb_dmx_init - initialize a digital TV demux struct.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) * @demux: &struct dvb_demux to be initialized.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) * Before being able to register a digital TV demux struct, drivers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) * should call this routine. On its typical usage, some fields should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) * be initialized at the driver before calling it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) * A typical usecase is::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) * dvb->demux.dmx.capabilities =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) * DMX_TS_FILTERING | DMX_SECTION_FILTERING |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) * DMX_MEMORY_BASED_FILTERING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) * dvb->demux.priv = dvb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) * dvb->demux.filternum = 256;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) * dvb->demux.feednum = 256;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) * dvb->demux.start_feed = driver_start_feed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) * dvb->demux.stop_feed = driver_stop_feed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) * ret = dvb_dmx_init(&dvb->demux);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) * if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) * return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) int dvb_dmx_init(struct dvb_demux *demux);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) * dvb_dmx_release - releases a digital TV demux internal buffers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) * @demux: &struct dvb_demux to be released.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) * The DVB core internally allocates data at @demux. This routine
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) * releases those data. Please notice that the struct itelf is not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) * released, as it can be embedded on other structs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) void dvb_dmx_release(struct dvb_demux *demux);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) * dvb_dmx_swfilter_packets - use dvb software filter for a buffer with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) * multiple MPEG-TS packets with 188 bytes each.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) * @demux: pointer to &struct dvb_demux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) * @buf: buffer with data to be filtered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) * @count: number of MPEG-TS packets with size of 188.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) * The routine will discard a DVB packet that don't start with 0x47.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) * Use this routine if the DVB demux fills MPEG-TS buffers that are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) * already aligned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) * NOTE: The @buf size should have size equal to ``count * 188``.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) void dvb_dmx_swfilter_packets(struct dvb_demux *demux, const u8 *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) size_t count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) * dvb_dmx_swfilter - use dvb software filter for a buffer with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) * multiple MPEG-TS packets with 188 bytes each.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) * @demux: pointer to &struct dvb_demux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) * @buf: buffer with data to be filtered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) * @count: number of MPEG-TS packets with size of 188.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) * If a DVB packet doesn't start with 0x47, it will seek for the first
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) * byte that starts with 0x47.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) * Use this routine if the DVB demux fill buffers that may not start with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) * a packet start mark (0x47).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) * NOTE: The @buf size should have size equal to ``count * 188``.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) * dvb_dmx_swfilter_204 - use dvb software filter for a buffer with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) * multiple MPEG-TS packets with 204 bytes each.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) * @demux: pointer to &struct dvb_demux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) * @buf: buffer with data to be filtered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) * @count: number of MPEG-TS packets with size of 204.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) * If a DVB packet doesn't start with 0x47, it will seek for the first
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) * byte that starts with 0x47.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) * Use this routine if the DVB demux fill buffers that may not start with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) * a packet start mark (0x47).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) * NOTE: The @buf size should have size equal to ``count * 204``.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) size_t count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) * dvb_dmx_swfilter_raw - make the raw data available to userspace without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) * filtering
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) * @demux: pointer to &struct dvb_demux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) * @buf: buffer with data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) * @count: number of packets to be passed. The actual size of each packet
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) * depends on the &dvb_demux->feed->cb.ts logic.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) * Use it if the driver needs to deliver the raw payload to userspace without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) * passing through the kernel demux. That is meant to support some
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) * delivery systems that aren't based on MPEG-TS.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) * This function relies on &dvb_demux->feed->cb.ts to actually handle the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) * buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) void dvb_dmx_swfilter_raw(struct dvb_demux *demux, const u8 *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) size_t count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) #endif /* _DVB_DEMUX_H_ */