xref: /netbsd/sys/dev/dtv/dtvif.h (revision 30296cb2)
1*30296cb2Schristos /* $NetBSD: dtvif.h,v 1.4 2018/04/19 21:50:08 christos Exp $ */
21308e7f6Sjmcneill 
31308e7f6Sjmcneill /*-
41308e7f6Sjmcneill  * Copyright (c) 2011 Jared D. McNeill <jmcneill@invisible.ca>
51308e7f6Sjmcneill  * All rights reserved.
61308e7f6Sjmcneill  *
71308e7f6Sjmcneill  * Redistribution and use in source and binary forms, with or without
81308e7f6Sjmcneill  * modification, are permitted provided that the following conditions
91308e7f6Sjmcneill  * are met:
101308e7f6Sjmcneill  * 1. Redistributions of source code must retain the above copyright
111308e7f6Sjmcneill  *    notice, this list of conditions and the following disclaimer.
121308e7f6Sjmcneill  * 2. Redistributions in binary form must reproduce the above copyright
131308e7f6Sjmcneill  *    notice, this list of conditions and the following disclaimer in the
141308e7f6Sjmcneill  *    documentation and/or other materials provided with the distribution.
151308e7f6Sjmcneill  * 3. All advertising materials mentioning features or use of this software
161308e7f6Sjmcneill  *    must display the following acknowledgement:
171308e7f6Sjmcneill  *        This product includes software developed by Jared D. McNeill.
181308e7f6Sjmcneill  * 4. Neither the name of The NetBSD Foundation nor the names of its
191308e7f6Sjmcneill  *    contributors may be used to endorse or promote products derived
201308e7f6Sjmcneill  *    from this software without specific prior written permission.
211308e7f6Sjmcneill  *
221308e7f6Sjmcneill  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
231308e7f6Sjmcneill  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
241308e7f6Sjmcneill  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
251308e7f6Sjmcneill  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
261308e7f6Sjmcneill  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
271308e7f6Sjmcneill  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
281308e7f6Sjmcneill  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
291308e7f6Sjmcneill  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
301308e7f6Sjmcneill  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
311308e7f6Sjmcneill  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
321308e7f6Sjmcneill  * POSSIBILITY OF SUCH DAMAGE.
331308e7f6Sjmcneill  */
341308e7f6Sjmcneill 
351308e7f6Sjmcneill #ifndef _DEV_DTV_DTVIF_H
361308e7f6Sjmcneill #define _DEV_DTV_DTVIF_H
371308e7f6Sjmcneill 
380f21fd12Sjmcneill #include <sys/device.h>
390f21fd12Sjmcneill 
401308e7f6Sjmcneill #include <dev/dtv/dtvio.h>
411308e7f6Sjmcneill 
421308e7f6Sjmcneill #define	DTV_DEVICE_FRONTEND	0
431308e7f6Sjmcneill #define	DTV_DEVICE_DEMUX	1
441308e7f6Sjmcneill #define	DTV_DEVICE_DVR		2
451308e7f6Sjmcneill 
461308e7f6Sjmcneill #define	DTV_NUM_DEVICES		3
471308e7f6Sjmcneill 
481308e7f6Sjmcneill #define	DTVUNIT(x)		(minor(x) & 0x0f)
491308e7f6Sjmcneill #define	DTVDEV(x)		((minor(x) & 0xf0) >> 4)
501308e7f6Sjmcneill 
511308e7f6Sjmcneill #define	ISDTVFRONTEND(x)	(DTVDEV((x)) == DTV_DEVICE_FRONTEND)
521308e7f6Sjmcneill #define	ISDTVDEMUX(x)		(DTVDEV((x)) == DTV_DEVICE_DEMUX)
531308e7f6Sjmcneill #define	ISDTVDVR(x)		(DTVDEV((x)) == DTV_DEVICE_DVR)
541308e7f6Sjmcneill 
558f316c9dSjmcneill struct dtv_payload;
568f316c9dSjmcneill 
571308e7f6Sjmcneill struct dtv_hw_if {
581308e7f6Sjmcneill 	void		(*get_devinfo)(void *, struct dvb_frontend_info *);
591308e7f6Sjmcneill 
601308e7f6Sjmcneill 	int		(*open)(void *, int);
611308e7f6Sjmcneill 	void		(*close)(void *);
621308e7f6Sjmcneill 	int		(*set_tuner)(void *, const struct dvb_frontend_parameters *);
631308e7f6Sjmcneill 	fe_status_t	(*get_status)(void *);
641308e7f6Sjmcneill 	uint16_t	(*get_signal_strength)(void *);
651308e7f6Sjmcneill 	uint16_t	(*get_snr)(void *);
668f316c9dSjmcneill 	int		(*start_transfer)(void *,
678f316c9dSjmcneill 			    void (*)(void *, const struct dtv_payload *),
688f316c9dSjmcneill 			    void *);
691308e7f6Sjmcneill 	int		(*stop_transfer)(void *);
701308e7f6Sjmcneill };
711308e7f6Sjmcneill 
721308e7f6Sjmcneill struct dtv_attach_args {
731308e7f6Sjmcneill 	const struct dtv_hw_if *hw;
741308e7f6Sjmcneill 	void *priv;
751308e7f6Sjmcneill };
761308e7f6Sjmcneill 
771308e7f6Sjmcneill struct dtv_payload {
781308e7f6Sjmcneill 	const uint8_t	*data;
791308e7f6Sjmcneill 	size_t		size;
801308e7f6Sjmcneill };
811308e7f6Sjmcneill 
82*30296cb2Schristos static __inline int
dtv_print(void * priv,const char * pnp)838f316c9dSjmcneill dtv_print(void *priv, const char *pnp)
848f316c9dSjmcneill {
858f316c9dSjmcneill 	if (pnp)
868f316c9dSjmcneill 		aprint_normal("dtv at %s", pnp);
878f316c9dSjmcneill 	return UNCONF;
888f316c9dSjmcneill }
890f21fd12Sjmcneill 
901308e7f6Sjmcneill #endif /* !_DEV_DTV_DTVIF_H */
91