dtvvar.h revision 1.3 1 1.3 jmcneill /* $NetBSD: dtvvar.h,v 1.3 2011/07/12 00:57:19 jmcneill Exp $ */
2 1.1 jmcneill
3 1.1 jmcneill /*-
4 1.1 jmcneill * Copyright (c) 2011 Jared D. McNeill <jmcneill (at) invisible.ca>
5 1.1 jmcneill * All rights reserved.
6 1.1 jmcneill *
7 1.1 jmcneill * Redistribution and use in source and binary forms, with or without
8 1.1 jmcneill * modification, are permitted provided that the following conditions
9 1.1 jmcneill * are met:
10 1.1 jmcneill * 1. Redistributions of source code must retain the above copyright
11 1.1 jmcneill * notice, this list of conditions and the following disclaimer.
12 1.1 jmcneill * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 jmcneill * notice, this list of conditions and the following disclaimer in the
14 1.1 jmcneill * documentation and/or other materials provided with the distribution.
15 1.1 jmcneill * 3. All advertising materials mentioning features or use of this software
16 1.1 jmcneill * must display the following acknowledgement:
17 1.1 jmcneill * This product includes software developed by Jared D. McNeill.
18 1.1 jmcneill * 4. Neither the name of The NetBSD Foundation nor the names of its
19 1.1 jmcneill * contributors may be used to endorse or promote products derived
20 1.1 jmcneill * from this software without specific prior written permission.
21 1.1 jmcneill *
22 1.1 jmcneill * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
23 1.1 jmcneill * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24 1.1 jmcneill * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 1.1 jmcneill * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
26 1.1 jmcneill * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 1.1 jmcneill * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 1.1 jmcneill * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 1.1 jmcneill * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 1.1 jmcneill * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 1.1 jmcneill * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 1.1 jmcneill * POSSIBILITY OF SUCH DAMAGE.
33 1.1 jmcneill */
34 1.1 jmcneill
35 1.1 jmcneill #ifndef _DEV_DTV_DTVVAR_H
36 1.1 jmcneill #define _DEV_DTV_DTVVAR_H
37 1.1 jmcneill
38 1.1 jmcneill #include <dev/dtv/dtvif.h>
39 1.1 jmcneill #include <dev/dtv/dtv_scatter.h>
40 1.1 jmcneill
41 1.3 jmcneill #define DTV_DEFAULT_BLOCKSIZE (32 * PAGE_SIZE)
42 1.3 jmcneill #define DTV_DEFAULT_BUFSIZE (32 * DTV_DEFAULT_BLOCKSIZE)
43 1.1 jmcneill
44 1.1 jmcneill #define TS_PKTLEN 188
45 1.1 jmcneill #define TS_HAS_SYNC(_tspkt) ((_tspkt)[0] == 0x47)
46 1.1 jmcneill #define TS_PID(_tspkt) ((((_tspkt)[1] & 0x1f) << 8) | (_tspkt)[2])
47 1.1 jmcneill
48 1.1 jmcneill struct dtv_buffer {
49 1.1 jmcneill uint32_t db_offset;
50 1.1 jmcneill uint32_t db_bytesused;
51 1.1 jmcneill size_t db_length;
52 1.1 jmcneill SIMPLEQ_ENTRY(dtv_buffer) db_entries;
53 1.1 jmcneill };
54 1.1 jmcneill
55 1.1 jmcneill SIMPLEQ_HEAD(dtv_sample_queue, dtv_buffer);
56 1.1 jmcneill
57 1.1 jmcneill struct dtv_stream {
58 1.1 jmcneill unsigned int ds_nbufs;
59 1.1 jmcneill struct dtv_buffer **ds_buf;
60 1.1 jmcneill struct dtv_scatter_buf ds_data;
61 1.1 jmcneill struct dtv_sample_queue ds_ingress, ds_egress;
62 1.3 jmcneill kmutex_t ds_ingress_lock, ds_egress_lock;
63 1.1 jmcneill kcondvar_t ds_sample_cv;
64 1.1 jmcneill struct selinfo ds_sel;
65 1.1 jmcneill uint32_t ds_bytesread;
66 1.1 jmcneill };
67 1.1 jmcneill
68 1.1 jmcneill struct dtv_ts {
69 1.1 jmcneill uint8_t ts_pidfilter[0x2000];
70 1.1 jmcneill kmutex_t ts_lock;
71 1.1 jmcneill };
72 1.1 jmcneill
73 1.1 jmcneill struct dtv_softc {
74 1.1 jmcneill device_t sc_dev;
75 1.1 jmcneill const struct dtv_hw_if *sc_hw;
76 1.1 jmcneill void *sc_priv;
77 1.1 jmcneill
78 1.1 jmcneill bool sc_dying;
79 1.1 jmcneill
80 1.1 jmcneill unsigned int sc_open;
81 1.1 jmcneill
82 1.1 jmcneill size_t sc_bufsize;
83 1.1 jmcneill bool sc_bufsize_chg;
84 1.1 jmcneill
85 1.1 jmcneill struct dtv_stream sc_stream;
86 1.1 jmcneill struct dtv_ts sc_ts;
87 1.1 jmcneill };
88 1.1 jmcneill
89 1.1 jmcneill #define dtv_device_get_devinfo(sc, info) \
90 1.1 jmcneill ((sc)->sc_hw->get_devinfo((sc)->sc_priv, (info)))
91 1.1 jmcneill #define dtv_device_open(sc, flags) \
92 1.1 jmcneill ((sc)->sc_hw->open((sc)->sc_priv, (flags)))
93 1.1 jmcneill #define dtv_device_close(sc) \
94 1.1 jmcneill ((sc)->sc_hw->close((sc)->sc_priv))
95 1.1 jmcneill #define dtv_device_set_tuner(sc, params) \
96 1.1 jmcneill ((sc)->sc_hw->set_tuner((sc)->sc_priv, (params)))
97 1.1 jmcneill #define dtv_device_get_status(sc) \
98 1.1 jmcneill ((sc)->sc_hw->get_status((sc)->sc_priv))
99 1.1 jmcneill #define dtv_device_get_signal_strength(sc) \
100 1.1 jmcneill ((sc)->sc_hw->get_signal_strength((sc)->sc_priv))
101 1.1 jmcneill #define dtv_device_get_snr(sc) \
102 1.1 jmcneill ((sc)->sc_hw->get_snr((sc)->sc_priv))
103 1.1 jmcneill #define dtv_device_start_transfer(sc) \
104 1.1 jmcneill ((sc)->sc_hw->start_transfer((sc)->sc_priv))
105 1.1 jmcneill #define dtv_device_stop_transfer(sc) \
106 1.1 jmcneill ((sc)->sc_hw->stop_transfer((sc)->sc_priv))
107 1.1 jmcneill
108 1.1 jmcneill int dtv_frontend_ioctl(struct dtv_softc *, u_long, void *, int);
109 1.1 jmcneill int dtv_demux_ioctl(struct dtv_softc *, u_long, void *, int);
110 1.1 jmcneill
111 1.2 jmcneill int dtv_buffer_realloc(struct dtv_softc *, size_t);
112 1.2 jmcneill int dtv_buffer_setup(struct dtv_softc *);
113 1.1 jmcneill int dtv_buffer_destroy(struct dtv_softc *);
114 1.1 jmcneill int dtv_buffer_read(struct dtv_softc *, struct uio *, int);
115 1.1 jmcneill int dtv_buffer_poll(struct dtv_softc *, int, lwp_t *);
116 1.1 jmcneill
117 1.1 jmcneill #endif /* !_DEV_DTV_DTVVAR_H */
118