dtvvar.h revision 1.1 1 1.1 jmcneill /* $NetBSD: dtvvar.h,v 1.1 2011/07/09 14:46:56 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.1 jmcneill #define DTV_DEFAULT_BUFSIZE (64 * 4096)
42 1.1 jmcneill
43 1.1 jmcneill #define TS_PKTLEN 188
44 1.1 jmcneill #define TS_HAS_SYNC(_tspkt) ((_tspkt)[0] == 0x47)
45 1.1 jmcneill #define TS_PID(_tspkt) ((((_tspkt)[1] & 0x1f) << 8) | (_tspkt)[2])
46 1.1 jmcneill
47 1.1 jmcneill struct dtv_buffer {
48 1.1 jmcneill uint32_t db_offset;
49 1.1 jmcneill uint32_t db_bytesused;
50 1.1 jmcneill size_t db_length;
51 1.1 jmcneill SIMPLEQ_ENTRY(dtv_buffer) db_entries;
52 1.1 jmcneill };
53 1.1 jmcneill
54 1.1 jmcneill SIMPLEQ_HEAD(dtv_sample_queue, dtv_buffer);
55 1.1 jmcneill
56 1.1 jmcneill struct dtv_stream {
57 1.1 jmcneill unsigned int ds_nbufs;
58 1.1 jmcneill struct dtv_buffer **ds_buf;
59 1.1 jmcneill struct dtv_scatter_buf ds_data;
60 1.1 jmcneill struct dtv_sample_queue ds_ingress, ds_egress;
61 1.1 jmcneill kmutex_t ds_lock;
62 1.1 jmcneill kcondvar_t ds_sample_cv;
63 1.1 jmcneill struct selinfo ds_sel;
64 1.1 jmcneill uint32_t ds_bytesread;
65 1.1 jmcneill };
66 1.1 jmcneill
67 1.1 jmcneill struct dtv_ts {
68 1.1 jmcneill uint8_t ts_pidfilter[0x2000];
69 1.1 jmcneill kmutex_t ts_lock;
70 1.1 jmcneill };
71 1.1 jmcneill
72 1.1 jmcneill struct dtv_softc {
73 1.1 jmcneill device_t sc_dev;
74 1.1 jmcneill const struct dtv_hw_if *sc_hw;
75 1.1 jmcneill void *sc_priv;
76 1.1 jmcneill
77 1.1 jmcneill bool sc_dying;
78 1.1 jmcneill
79 1.1 jmcneill unsigned int sc_open;
80 1.1 jmcneill
81 1.1 jmcneill size_t sc_bufsize;
82 1.1 jmcneill bool sc_bufsize_chg;
83 1.1 jmcneill
84 1.1 jmcneill struct dtv_stream sc_stream;
85 1.1 jmcneill struct dtv_ts sc_ts;
86 1.1 jmcneill };
87 1.1 jmcneill
88 1.1 jmcneill #define dtv_device_get_devinfo(sc, info) \
89 1.1 jmcneill ((sc)->sc_hw->get_devinfo((sc)->sc_priv, (info)))
90 1.1 jmcneill #define dtv_device_open(sc, flags) \
91 1.1 jmcneill ((sc)->sc_hw->open((sc)->sc_priv, (flags)))
92 1.1 jmcneill #define dtv_device_close(sc) \
93 1.1 jmcneill ((sc)->sc_hw->close((sc)->sc_priv))
94 1.1 jmcneill #define dtv_device_set_tuner(sc, params) \
95 1.1 jmcneill ((sc)->sc_hw->set_tuner((sc)->sc_priv, (params)))
96 1.1 jmcneill #define dtv_device_get_status(sc) \
97 1.1 jmcneill ((sc)->sc_hw->get_status((sc)->sc_priv))
98 1.1 jmcneill #define dtv_device_get_signal_strength(sc) \
99 1.1 jmcneill ((sc)->sc_hw->get_signal_strength((sc)->sc_priv))
100 1.1 jmcneill #define dtv_device_get_snr(sc) \
101 1.1 jmcneill ((sc)->sc_hw->get_snr((sc)->sc_priv))
102 1.1 jmcneill #define dtv_device_start_transfer(sc) \
103 1.1 jmcneill ((sc)->sc_hw->start_transfer((sc)->sc_priv))
104 1.1 jmcneill #define dtv_device_stop_transfer(sc) \
105 1.1 jmcneill ((sc)->sc_hw->stop_transfer((sc)->sc_priv))
106 1.1 jmcneill
107 1.1 jmcneill int dtv_frontend_ioctl(struct dtv_softc *, u_long, void *, int);
108 1.1 jmcneill int dtv_demux_ioctl(struct dtv_softc *, u_long, void *, int);
109 1.1 jmcneill
110 1.1 jmcneill int dtv_buffer_setup(struct dtv_softc *, size_t);
111 1.1 jmcneill int dtv_buffer_destroy(struct dtv_softc *);
112 1.1 jmcneill int dtv_buffer_read(struct dtv_softc *, struct uio *, int);
113 1.1 jmcneill int dtv_buffer_poll(struct dtv_softc *, int, lwp_t *);
114 1.1 jmcneill
115 1.1 jmcneill #endif /* !_DEV_DTV_DTVVAR_H */
116