Home | History | Annotate | Line # | Download | only in dtv
dtvif.h revision 1.1
      1 /* $NetBSD: dtvif.h,v 1.1 2011/07/09 14:46:56 jmcneill Exp $ */
      2 
      3 /*-
      4  * Copyright (c) 2011 Jared D. McNeill <jmcneill (at) 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_DTVIF_H
     36 #define _DEV_DTV_DTVIF_H
     37 
     38 #include <dev/dtv/dtvio.h>
     39 
     40 #define	DTV_DEVICE_FRONTEND	0
     41 #define	DTV_DEVICE_DEMUX	1
     42 #define	DTV_DEVICE_DVR		2
     43 
     44 #define	DTV_NUM_DEVICES		3
     45 
     46 #define	DTVUNIT(x)		(minor(x) & 0x0f)
     47 #define	DTVDEV(x)		((minor(x) & 0xf0) >> 4)
     48 
     49 #define	ISDTVFRONTEND(x)	(DTVDEV((x)) == DTV_DEVICE_FRONTEND)
     50 #define	ISDTVDEMUX(x)		(DTVDEV((x)) == DTV_DEVICE_DEMUX)
     51 #define	ISDTVDVR(x)		(DTVDEV((x)) == DTV_DEVICE_DVR)
     52 
     53 struct dtv_hw_if {
     54 	void		(*get_devinfo)(void *, struct dvb_frontend_info *);
     55 
     56 	int		(*open)(void *, int);
     57 	void		(*close)(void *);
     58 	int		(*set_tuner)(void *, const struct dvb_frontend_parameters *);
     59 	fe_status_t	(*get_status)(void *);
     60 	uint16_t	(*get_signal_strength)(void *);
     61 	uint16_t	(*get_snr)(void *);
     62 	int		(*start_transfer)(void *);
     63 	int		(*stop_transfer)(void *);
     64 };
     65 
     66 struct dtv_attach_args {
     67 	const struct dtv_hw_if *hw;
     68 	void *priv;
     69 };
     70 
     71 struct dtv_payload {
     72 	const uint8_t	*data;
     73 	size_t		size;
     74 };
     75 
     76 int	dtv_print(void *, const char *);
     77 
     78 void	dtv_submit_payload(device_t, const struct dtv_payload *);
     79 
     80 #endif /* !_DEV_DTV_DTVIF_H */
     81