xref: /netbsd/sys/dev/dtv/dtv_ioctl.c (revision 81b7a306)
1*81b7a306Sjmcneill /* $NetBSD: dtv_ioctl.c,v 1.3 2011/07/13 22:43:04 jmcneill 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 #include <sys/cdefs.h>
36*81b7a306Sjmcneill __KERNEL_RCSID(0, "$NetBSD: dtv_ioctl.c,v 1.3 2011/07/13 22:43:04 jmcneill Exp $");
371308e7f6Sjmcneill 
381308e7f6Sjmcneill #include <sys/param.h>
391308e7f6Sjmcneill #include <sys/types.h>
401308e7f6Sjmcneill #include <sys/conf.h>
411308e7f6Sjmcneill #include <sys/kmem.h>
421308e7f6Sjmcneill #include <sys/device.h>
431308e7f6Sjmcneill #include <sys/select.h>
441308e7f6Sjmcneill 
451308e7f6Sjmcneill #include <dev/dtv/dtvvar.h>
461308e7f6Sjmcneill 
471308e7f6Sjmcneill int
dtv_frontend_ioctl(struct dtv_softc * sc,u_long cmd,void * data,int flags)481308e7f6Sjmcneill dtv_frontend_ioctl(struct dtv_softc *sc, u_long cmd, void *data, int flags)
491308e7f6Sjmcneill {
501308e7f6Sjmcneill 	switch (cmd) {
511308e7f6Sjmcneill 	case FE_READ_STATUS:
521308e7f6Sjmcneill 		*(fe_status_t *)data = dtv_device_get_status(sc);
531308e7f6Sjmcneill 		return 0;
541308e7f6Sjmcneill 	case FE_READ_BER:
551308e7f6Sjmcneill 		*(uint32_t *)data = 0;	/* XXX TODO */
561308e7f6Sjmcneill 		return 0;
571308e7f6Sjmcneill 	case FE_READ_SNR:
581308e7f6Sjmcneill 		*(uint16_t *)data = dtv_device_get_snr(sc);
591308e7f6Sjmcneill 		return 0;
601308e7f6Sjmcneill 	case FE_READ_SIGNAL_STRENGTH:
611308e7f6Sjmcneill 		*(uint16_t *)data = dtv_device_get_signal_strength(sc);
621308e7f6Sjmcneill 		return 0;
631308e7f6Sjmcneill 	case FE_SET_FRONTEND:
641308e7f6Sjmcneill 		return dtv_device_set_tuner(sc, data);
651308e7f6Sjmcneill 	case FE_GET_INFO:
661308e7f6Sjmcneill 		dtv_device_get_devinfo(sc, data);
671308e7f6Sjmcneill 		return 0;
681308e7f6Sjmcneill 	default:
691308e7f6Sjmcneill 		return EINVAL;
701308e7f6Sjmcneill 	}
711308e7f6Sjmcneill }
72