1 /* $NetBSD: dtvio_demux.h,v 1.3 2017/10/28 06:27:32 riastradh Exp $ */
2 
3 /*-
4  * Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca>
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. All advertising materials mentioning features or use of this software
16  *    must display the following acknowledgement:
17  *        This product includes software developed by Jared D. McNeill.
18  * 4. Neither the name of The NetBSD Foundation nor the names of its
19  *    contributors may be used to endorse or promote products derived
20  *    from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
23  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
26  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 #ifndef _DEV_DTV_DTVIO_DEMUX_H
36 #define _DEV_DTV_DTVIO_DEMUX_H
37 
38 #include <sys/types.h>
39 #include <sys/ioccom.h>
40 
41 /*
42  * DVB Demux API
43  */
44 
45 typedef enum {
46           DMX_OUT_DECODER,
47           DMX_OUT_TAP,
48           DMX_OUT_TS_TAP,
49           DMX_OUT_TSDEMUX_TAP,
50 } dmx_output_t;
51 
52 typedef enum {
53           DMX_IN_FRONTEND,
54           DMX_IN_DVR,
55 } dmx_input_t;
56 
57 typedef enum {
58           DMX_PES_AUDIO0,
59           DMX_PES_VIDEO0,
60           DMX_PES_TELETEXT0,
61           DMX_PES_SUBTITLE0,
62           DMX_PES_PCR0,
63 
64           DMX_PES_AUDIO1,
65           DMX_PES_VIDEO1,
66           DMX_PES_TELETEXT1,
67           DMX_PES_SUBTITLE1,
68           DMX_PES_PCR1,
69 
70           DMX_PES_AUDIO2,
71           DMX_PES_VIDEO2,
72           DMX_PES_TELETEXT2,
73           DMX_PES_SUBTITLE2,
74           DMX_PES_PCR2,
75 
76           DMX_PES_AUDIO3,
77           DMX_PES_VIDEO3,
78           DMX_PES_TELETEXT3,
79           DMX_PES_SUBTITLE3,
80           DMX_PES_PCR3,
81 
82           DMX_PES_OTHER,
83 } dmx_pes_type_t;
84 
85 #define   DMX_PES_AUDIO                 DMX_PES_AUDIO0
86 #define   DMX_PES_VIDEO                 DMX_PES_VIDEO0
87 #define   DMX_PES_TELETEXT    DMX_PES_TELETEXT0
88 #define   DMX_PES_SUBTITLE    DMX_PES_SUBTITLE0
89 #define   DMX_PES_PCR                   DMX_PES_PCR0
90 
91 #define   DMX_FILTER_SIZE     16
92 
93 typedef struct dmx_filter {
94           uint8_t             filter[DMX_FILTER_SIZE];
95           uint8_t             mask[DMX_FILTER_SIZE];
96           uint8_t             mode[DMX_FILTER_SIZE];
97 } dmx_filter_t;
98 
99 struct dmx_sct_filter_params {
100           uint16_t  pid;
101           dmx_filter_t        filter;
102           uint32_t  timeout;
103           uint32_t  flags;
104 #define   DMX_CHECK_CRC                 0x0001
105 #define   DMX_ONESHOT                   0x0002
106 #define   DMX_IMMEDIATE_START 0x0004
107 #define   DMX_KERNEL_CLIENT   0x8000
108 };
109 
110 struct dmx_pes_filter_params {
111           uint16_t  pid;
112           dmx_input_t         input;
113           dmx_output_t        output;
114           dmx_pes_type_t      pes_type;
115           uint32_t  flags;
116 };
117 
118 struct dmx_stc {
119           unsigned int        num;
120           unsigned int        base;
121           uint64_t  stc;
122 };
123 
124 typedef struct dmx_caps {
125           uint32_t  caps;
126           int                 num_decoders;
127 } dmx_caps_t;
128 
129 typedef enum {
130           DMX_SOURCE_FRONT0 = 0,
131           DMX_SOURCE_FRONT1,
132           DMX_SOURCE_FRONT2,
133           DMX_SOURCE_FRONT3,
134           DMX_SOURCE_DVR0 = 16,
135           DMX_SOURCE_DVR1,
136           DMX_SOURCE_DVR2,
137           DMX_SOURCE_DVR3,
138 } dmx_source_t;
139 
140 #define   DMX_START              _IO('D', 100)
141 #define   DMX_STOP               _IO('D', 101)
142 #define   DMX_SET_FILTER                   _IOW('D', 102, struct dmx_sct_filter_params)
143 #define   DMX_SET_PES_FILTER     _IOW('D', 103, struct dmx_pes_filter_params)
144 #define   DMX_SET_BUFFER_SIZE    _IO('D', 104)
145 #define   DMX_GET_STC                      _IOWR('D', 105, struct dmx_stc)
146 #define   DMX_ADD_PID                      _IOW('D', 106, uint16_t)
147 #define   DMX_REMOVE_PID                   _IOW('D', 107, uint16_t)
148 #define   DMX_GET_CAPS                     _IOR('D', 108, dmx_caps_t)
149 #define   DMX_SET_SOURCE                   _IOW('D', 109, dmx_source_t)
150 
151 #endif /* !_DEV_DTV_DTVIO_DEMUX_H */
152