Module Name:    src
Committed By:   jmcneill
Date:           Tue Aug  9 01:42:25 UTC 2011

Modified Files:
        src/sys/conf: files
        src/sys/dev/dtv: dtv_buffer.c dtv_device.c dtv_math.c dtvif.h dtvvar.h
            files.dtv
        src/sys/dev/i2c: files.i2c xc3028.c
        src/sys/dev/pci: coram.c coramvar.h cxdtv.c cxdtvvar.h
        src/sys/dev/usb: auvitek.c auvitek_dtv.c auvitek_video.c auvitekvar.h
            emdtv.c emdtv_dtv.c emdtvvar.h
        src/sys/modules: Makefile
        src/sys/modules/dtv: Makefile
Added Files:
        src/sys/modules/dtv_math: Makefile

Log Message:
modify the dtv device api so hardware drivers can be loaded independently
of the dtv module


To generate a diff of this commit:
cvs rdiff -u -r1.1023 -r1.1024 src/sys/conf/files
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/dtv/dtv_buffer.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/dtv/dtv_device.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/dtv/dtv_math.c
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/dtv/dtvif.h
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/dtv/dtvvar.h
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/dtv/files.dtv
cvs rdiff -u -r1.40 -r1.41 src/sys/dev/i2c/files.i2c
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/i2c/xc3028.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/pci/coram.c
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/pci/coramvar.h \
    src/sys/dev/pci/cxdtvvar.h
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/pci/cxdtv.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/usb/auvitek.c \
    src/sys/dev/usb/auvitek_video.c src/sys/dev/usb/emdtv_dtv.c
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/usb/auvitek_dtv.c \
    src/sys/dev/usb/emdtvvar.h
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/usb/auvitekvar.h src/sys/dev/usb/emdtv.c
cvs rdiff -u -r1.81 -r1.82 src/sys/modules/Makefile
cvs rdiff -u -r1.3 -r1.4 src/sys/modules/dtv/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/modules/dtv_math/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/conf/files
diff -u src/sys/conf/files:1.1023 src/sys/conf/files:1.1024
--- src/sys/conf/files:1.1023	Sun Aug  7 13:33:01 2011
+++ src/sys/conf/files	Tue Aug  9 01:42:24 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: files,v 1.1023 2011/08/07 13:33:01 rmind Exp $
+#	$NetBSD: files,v 1.1024 2011/08/09 01:42:24 jmcneill Exp $
 #	@(#)files.newconf	7.5 (Berkeley) 5/10/93
 
 version 	20100430
@@ -327,6 +327,10 @@
 device	video
 attach	video at videobus
 
+# DTV subsystem
+#
+include "dev/dtv/files.dtv"
+
 # National Semiconductor LM7[89]
 #
 # (included here so files.i2c can define an attachment)
@@ -1729,8 +1733,3 @@
 # NOR subsytem
 #
 include "dev/nor/files.nor"
-
-#
-# DTV subsystem
-#
-include "dev/dtv/files.dtv"

Index: src/sys/dev/dtv/dtv_buffer.c
diff -u src/sys/dev/dtv/dtv_buffer.c:1.6 src/sys/dev/dtv/dtv_buffer.c:1.7
--- src/sys/dev/dtv/dtv_buffer.c:1.6	Sat Jul 16 12:20:01 2011
+++ src/sys/dev/dtv/dtv_buffer.c	Tue Aug  9 01:42:24 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: dtv_buffer.c,v 1.6 2011/07/16 12:20:01 jmcneill Exp $ */
+/* $NetBSD: dtv_buffer.c,v 1.7 2011/08/09 01:42:24 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <[email protected]>
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dtv_buffer.c,v 1.6 2011/07/16 12:20:01 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dtv_buffer.c,v 1.7 2011/08/09 01:42:24 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -96,9 +96,9 @@
 }
 
 void
-dtv_submit_payload(device_t self, const struct dtv_payload *payload)
+dtv_buffer_submit(void *priv, const struct dtv_payload *payload)
 {
-	struct dtv_softc *sc = device_private(self);
+	struct dtv_softc *sc = priv;
 	struct dtv_ts *ts = &sc->sc_ts;
 	const uint8_t *tspkt;
 	unsigned int npkts, i;

Index: src/sys/dev/dtv/dtv_device.c
diff -u src/sys/dev/dtv/dtv_device.c:1.7 src/sys/dev/dtv/dtv_device.c:1.8
--- src/sys/dev/dtv/dtv_device.c:1.7	Sat Jul 16 12:20:01 2011
+++ src/sys/dev/dtv/dtv_device.c	Tue Aug  9 01:42:24 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: dtv_device.c,v 1.7 2011/07/16 12:20:01 jmcneill Exp $ */
+/* $NetBSD: dtv_device.c,v 1.8 2011/08/09 01:42:24 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <[email protected]>
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dtv_device.c,v 1.7 2011/07/16 12:20:01 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dtv_device.c,v 1.8 2011/08/09 01:42:24 jmcneill Exp $");
 
 #include <sys/types.h>
 #include <sys/conf.h>
@@ -301,12 +301,3 @@
 	}
 	mutex_exit(&sc->sc_lock);
 }
-
-int
-dtv_print(void *arg, const char *pnp)
-{
-	if (pnp)
-		aprint_normal("dtv at %s", pnp);
-
-	return UNCONF;
-}

Index: src/sys/dev/dtv/dtv_math.c
diff -u src/sys/dev/dtv/dtv_math.c:1.4 src/sys/dev/dtv/dtv_math.c:1.5
--- src/sys/dev/dtv/dtv_math.c:1.4	Sat Jul 16 22:41:59 2011
+++ src/sys/dev/dtv/dtv_math.c	Tue Aug  9 01:42:24 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: dtv_math.c,v 1.4 2011/07/16 22:41:59 apb Exp $ */
+/* $NetBSD: dtv_math.c,v 1.5 2011/08/09 01:42:24 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Alan Barrett <[email protected]>
@@ -27,12 +27,13 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dtv_math.c,v 1.4 2011/07/16 22:41:59 apb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dtv_math.c,v 1.5 2011/08/09 01:42:24 jmcneill Exp $");
 
 #include <sys/types.h>
 #include <sys/bitops.h>
+#include <sys/module.h>
 
-#include <dev/dtv/dtvif.h>
+#include <dev/dtv/dtv_math.h>
 
 /*
  * dtv_intlog10 -- return an approximation to log10(x) * 1<<24,
@@ -148,6 +149,18 @@
 	return t / 2136 * 643;
 }
 
+#ifdef _KERNEL
+MODULE(MODULE_CLASS_MISC, dtv_math, NULL);
+
+static int
+dtv_math_modcmd(modcmd_t cmd, void *opaque)
+{
+	if (cmd == MODULE_CMD_INIT || cmd == MODULE_CMD_FINI)
+		return 0;
+	return ENOTTY;
+}
+#endif
+
 #ifdef TEST_DTV_MATH
 /*
  * To test:

Index: src/sys/dev/dtv/dtvif.h
diff -u src/sys/dev/dtv/dtvif.h:1.2 src/sys/dev/dtv/dtvif.h:1.3
--- src/sys/dev/dtv/dtvif.h:1.2	Fri Jul 15 20:27:42 2011
+++ src/sys/dev/dtv/dtvif.h	Tue Aug  9 01:42:24 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: dtvif.h,v 1.2 2011/07/15 20:27:42 jmcneill Exp $ */
+/* $NetBSD: dtvif.h,v 1.3 2011/08/09 01:42:24 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <[email protected]>
@@ -52,6 +52,8 @@
 #define	ISDTVDEMUX(x)		(DTVDEV((x)) == DTV_DEVICE_DEMUX)
 #define	ISDTVDVR(x)		(DTVDEV((x)) == DTV_DEVICE_DVR)
 
+struct dtv_payload;
+
 struct dtv_hw_if {
 	void		(*get_devinfo)(void *, struct dvb_frontend_info *);
 
@@ -61,7 +63,9 @@
 	fe_status_t	(*get_status)(void *);
 	uint16_t	(*get_signal_strength)(void *);
 	uint16_t	(*get_snr)(void *);
-	int		(*start_transfer)(void *);
+	int		(*start_transfer)(void *,
+			    void (*)(void *, const struct dtv_payload *),
+			    void *);
 	int		(*stop_transfer)(void *);
 };
 
@@ -75,11 +79,12 @@
 	size_t		size;
 };
 
-int	dtv_print(void *, const char *);
-
-void	dtv_submit_payload(device_t, const struct dtv_payload *);
-
-/* dtv_math.c */
-uint32_t	dtv_intlog10(uint32_t);
+static inline int
+dtv_print(void *priv, const char *pnp)
+{
+	if (pnp)
+		aprint_normal("dtv at %s", pnp);
+	return UNCONF;
+}
 
 #endif /* !_DEV_DTV_DTVIF_H */

Index: src/sys/dev/dtv/dtvvar.h
diff -u src/sys/dev/dtv/dtvvar.h:1.5 src/sys/dev/dtv/dtvvar.h:1.6
--- src/sys/dev/dtv/dtvvar.h:1.5	Sat Jul 16 12:20:01 2011
+++ src/sys/dev/dtv/dtvvar.h	Tue Aug  9 01:42:24 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: dtvvar.h,v 1.5 2011/07/16 12:20:01 jmcneill Exp $ */
+/* $NetBSD: dtvvar.h,v 1.6 2011/08/09 01:42:24 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <[email protected]>
@@ -141,8 +141,8 @@
 	((sc)->sc_hw->get_signal_strength((sc)->sc_priv))
 #define	dtv_device_get_snr(sc)			\
 	((sc)->sc_hw->get_snr((sc)->sc_priv))
-#define	dtv_device_start_transfer(sc)		\
-	((sc)->sc_hw->start_transfer((sc)->sc_priv))
+#define	dtv_device_start_transfer(sc)	\
+	((sc)->sc_hw->start_transfer((sc)->sc_priv, dtv_buffer_submit, (sc)))
 #define	dtv_device_stop_transfer(sc)		\
 	((sc)->sc_hw->stop_transfer((sc)->sc_priv))
 
@@ -156,6 +156,7 @@
 int	dtv_buffer_destroy(struct dtv_softc *);
 int	dtv_buffer_read(struct dtv_softc *, struct uio *, int);
 int	dtv_buffer_poll(struct dtv_softc *, int, lwp_t *);
+void	dtv_buffer_submit(void *, const struct dtv_payload *);
 
 void	dtv_common_close(struct dtv_softc *);
 

Index: src/sys/dev/dtv/files.dtv
diff -u src/sys/dev/dtv/files.dtv:1.3 src/sys/dev/dtv/files.dtv:1.4
--- src/sys/dev/dtv/files.dtv:1.3	Fri Jul 15 20:27:42 2011
+++ src/sys/dev/dtv/files.dtv	Tue Aug  9 01:42:24 2011
@@ -1,4 +1,4 @@
-# $NetBSD: files.dtv,v 1.3 2011/07/15 20:27:42 jmcneill Exp $
+# $NetBSD: files.dtv,v 1.4 2011/08/09 01:42:24 jmcneill Exp $
 
 define	dtvbus { }
 
@@ -8,5 +8,7 @@
 file	dev/dtv/dtv_demux.c	dtv
 file	dev/dtv/dtv_device.c	dtv
 file	dev/dtv/dtv_ioctl.c	dtv
-file	dev/dtv/dtv_math.c	dtv
 file	dev/dtv/dtv_scatter.c	dtv
+
+define	dtv_math
+file	dev/dtv/dtv_math.c	dtv_math

Index: src/sys/dev/i2c/files.i2c
diff -u src/sys/dev/i2c/files.i2c:1.40 src/sys/dev/i2c/files.i2c:1.41
--- src/sys/dev/i2c/files.i2c:1.40	Thu Aug  4 01:48:34 2011
+++ src/sys/dev/i2c/files.i2c	Tue Aug  9 01:42:24 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: files.i2c,v 1.40 2011/08/04 01:48:34 jakllsch Exp $
+#	$NetBSD: files.i2c,v 1.41 2011/08/09 01:42:24 jmcneill Exp $
 
 defflag	opt_i2cbus.h				I2C_SCAN
 define	i2cbus { }
@@ -22,7 +22,7 @@
 file	dev/i2c/lg3303.c			lg3303
 
 # Xceive XC3028 tuner
-define	xc3028: i2cexec, firmload
+define	xc3028: i2cexec, firmload, dtv_math
 file	dev/i2c/xc3028.c			xc3028
 
 # Xceive XC5000 tuner

Index: src/sys/dev/i2c/xc3028.c
diff -u src/sys/dev/i2c/xc3028.c:1.2 src/sys/dev/i2c/xc3028.c:1.3
--- src/sys/dev/i2c/xc3028.c:1.2	Fri Jul 22 18:21:10 2011
+++ src/sys/dev/i2c/xc3028.c	Tue Aug  9 01:42:24 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: xc3028.c,v 1.2 2011/07/22 18:21:10 njoly Exp $ */
+/* $NetBSD: xc3028.c,v 1.3 2011/08/09 01:42:24 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <[email protected]>
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xc3028.c,v 1.2 2011/07/22 18:21:10 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xc3028.c,v 1.3 2011/08/09 01:42:24 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -564,7 +564,7 @@
 	return 0;
 }
 
-MODULE(MODULE_CLASS_DRIVER, xc3028, NULL);
+MODULE(MODULE_CLASS_DRIVER, xc3028, "dtv_math");
 
 static int
 xc3028_modcmd(modcmd_t cmd, void *opaque)

Index: src/sys/dev/pci/coram.c
diff -u src/sys/dev/pci/coram.c:1.7 src/sys/dev/pci/coram.c:1.8
--- src/sys/dev/pci/coram.c:1.7	Sat Aug  6 19:21:27 2011
+++ src/sys/dev/pci/coram.c	Tue Aug  9 01:42:24 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: coram.c,v 1.7 2011/08/06 19:21:27 jmcneill Exp $ */
+/* $NetBSD: coram.c,v 1.8 2011/08/09 01:42:24 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2008, 2011 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: coram.c,v 1.7 2011/08/06 19:21:27 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: coram.c,v 1.8 2011/08/09 01:42:24 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -61,6 +61,7 @@
 static int coram_match(device_t, cfdata_t, void *);
 static void coram_attach(device_t, device_t, void *);
 static int coram_detach(device_t, int);
+static int coram_rescan(device_t, const char *, const int *);
 static void coram_childdet(device_t, device_t);
 static bool coram_resume(device_t, const pmf_qual_t *);
 static int coram_intr(void *);
@@ -82,7 +83,7 @@
 static fe_status_t coram_dtv_get_status(void *);
 static uint16_t coram_dtv_get_signal_strength(void *);
 static uint16_t coram_dtv_get_snr(void *);
-static int coram_dtv_start_transfer(void *);
+static int coram_dtv_start_transfer(void *, void (*)(void *, const struct dtv_payload *), void *);
 static int coram_dtv_stop_transfer(void *);
 
 static int coram_mpeg_attach(struct coram_softc *);
@@ -100,7 +101,8 @@
 static int coram_mpeg_intr(struct coram_softc *);
 
 CFATTACH_DECL2_NEW(coram, sizeof(struct coram_softc),
-    coram_match, coram_attach, coram_detach, NULL, NULL, coram_childdet);
+    coram_match, coram_attach, coram_detach, NULL,
+    coram_rescan, coram_childdet);
 
 #define CORAM_SRAM_CH6 0
 
@@ -317,6 +319,22 @@
 	return 0;
 }
 
+static int
+coram_rescan(device_t self, const char *ifattr, const int *locs)
+{
+	struct coram_softc *sc = device_private(self);
+	struct dtv_attach_args daa;
+
+	daa.hw = &coram_dtv_if;
+	daa.priv = sc;
+
+	if (ifattr_match(ifattr, "dtvbus") && sc->sc_dtvdev == NULL)
+		sc->sc_dtvdev = config_found_ia(sc->sc_dev, "dtvbus",
+		    &daa, dtv_print);
+
+	return 0;
+}
+ 
 static void
 coram_childdet(device_t self, device_t child)
 {
@@ -404,13 +422,16 @@
 		}
 	}
 
+	if (sc->sc_dtvsubmitcb == NULL)
+		goto done;
+
 	if ((s & CXDTV_TS_RISCI1) == CXDTV_TS_RISCI1) {
 		bus_dmamap_sync(sc->sc_dmat, sc->sc_dma->map,
 		    0, CORAM_TS_PKTSIZE,
 		    BUS_DMASYNC_POSTREAD);
 		payload.data = KERNADDR(sc->sc_dma);
 		payload.size = CORAM_TS_PKTSIZE;
-		dtv_submit_payload(sc->sc_dtvdev, &payload);
+		sc->sc_dtvsubmitcb(sc->sc_dtvsubmitarg, &payload);
 	}
 
 	if ((s & CXDTV_TS_RISCI2) == CXDTV_TS_RISCI2) {
@@ -419,9 +440,10 @@
 		    BUS_DMASYNC_POSTREAD);
 		payload.data = (char *)(KERNADDR(sc->sc_dma)) + (uintptr_t)CORAM_TS_PKTSIZE;
 		payload.size = CORAM_TS_PKTSIZE;
-		dtv_submit_payload(sc->sc_dtvdev, &payload);
+		sc->sc_dtvsubmitcb(sc->sc_dtvsubmitarg, &payload);
 	}
 
+done:
 	bus_space_write_4(sc->sc_memt, sc->sc_memh, VID_C_INT_STAT, s);
 
 	return 1;
@@ -587,7 +609,6 @@
 static int
 coram_mpeg_attach(struct coram_softc *sc)
 {
-	struct dtv_attach_args daa;
 	struct coram_sram_ch *ch;
 
 	ch = &coram_sram_chs[CORAM_SRAM_CH6];
@@ -600,12 +621,9 @@
 
 	coram_mpeg_reset(sc);
 
-	daa.hw = &coram_dtv_if;
-	daa.priv = sc;
-
 	sc->sc_tsbuf = NULL;
 
-	sc->sc_dtvdev = config_found_ia(sc->sc_dev, "dtvbus", &daa, dtv_print);
+	coram_rescan(sc->sc_dev, NULL, NULL);
 
 	return (sc->sc_dtvdev != NULL);
 }
@@ -719,7 +737,8 @@
 }
 
 static int
-coram_dtv_start_transfer(void *cookie)
+coram_dtv_start_transfer(void *cookie,
+    void (*cb)(void *, const struct dtv_payload *), void *arg)
 {
 	struct coram_softc *sc = cookie;
 
@@ -727,6 +746,9 @@
 	device_printf(sc->sc_dev, "%s\n", __func__);
 #endif
 
+	sc->sc_dtvsubmitcb = cb;
+	sc->sc_dtvsubmitarg = arg;
+
 	coram_mpeg_trigger(sc, sc->sc_tsbuf);
 
 	return 0;
@@ -744,6 +766,9 @@
 	coram_mpeg_halt(sc);
 	bus_space_write_4(sc->sc_memt, sc->sc_memh, PCI_INT_MSK, 0);
 
+	sc->sc_dtvsubmitcb = NULL;
+	sc->sc_dtvsubmitarg = NULL;
+
 	return 0;
 }
 
@@ -1075,7 +1100,7 @@
 	return 0;
 }
 
-MODULE(MODULE_CLASS_DRIVER, coram, "dtv,cx24227,mt2131");
+MODULE(MODULE_CLASS_DRIVER, coram, "cx24227,mt2131");
 
 #ifdef _MODULE
 #include "ioconf.c"

Index: src/sys/dev/pci/coramvar.h
diff -u src/sys/dev/pci/coramvar.h:1.3 src/sys/dev/pci/coramvar.h:1.4
--- src/sys/dev/pci/coramvar.h:1.3	Sat Aug  6 19:21:27 2011
+++ src/sys/dev/pci/coramvar.h	Tue Aug  9 01:42:24 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: coramvar.h,v 1.3 2011/08/06 19:21:27 jmcneill Exp $ */
+/* $NetBSD: coramvar.h,v 1.4 2011/08/09 01:42:24 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2008, 2011 Jonathan A. Kollasch
@@ -100,6 +100,10 @@
 	void			*sc_tuner;
 	void			*sc_demod;
 
+	void			(*sc_dtvsubmitcb)(void *,
+				    const struct dtv_payload *);
+	void			*sc_dtvsubmitarg;
+
 	const struct coram_board *sc_board;
 };
 
Index: src/sys/dev/pci/cxdtvvar.h
diff -u src/sys/dev/pci/cxdtvvar.h:1.3 src/sys/dev/pci/cxdtvvar.h:1.4
--- src/sys/dev/pci/cxdtvvar.h:1.3	Mon Jul 25 04:31:26 2011
+++ src/sys/dev/pci/cxdtvvar.h	Tue Aug  9 01:42:24 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: cxdtvvar.h,v 1.3 2011/07/25 04:31:26 jakllsch Exp $ */
+/* $NetBSD: cxdtvvar.h,v 1.4 2011/08/09 01:42:24 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2008, 2011 Jonathan A. Kollasch
@@ -95,6 +95,10 @@
 	void			*sc_tuner;
 	void 			*sc_demod;
 
+	void			(*sc_dtvsubmitcb)(void *,
+				    const struct dtv_payload *);
+	void			*sc_dtvsubmitarg;
+
 	const struct cxdtv_board *sc_board;
 	pci_vendor_id_t		sc_vendor;
 	pci_product_id_t	sc_product;

Index: src/sys/dev/pci/cxdtv.c
diff -u src/sys/dev/pci/cxdtv.c:1.6 src/sys/dev/pci/cxdtv.c:1.7
--- src/sys/dev/pci/cxdtv.c:1.6	Mon Jul 25 04:31:26 2011
+++ src/sys/dev/pci/cxdtv.c	Tue Aug  9 01:42:24 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: cxdtv.c,v 1.6 2011/07/25 04:31:26 jakllsch Exp $ */
+/* $NetBSD: cxdtv.c,v 1.7 2011/08/09 01:42:24 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2008, 2011 Jonathan A. Kollasch
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cxdtv.c,v 1.6 2011/07/25 04:31:26 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cxdtv.c,v 1.7 2011/08/09 01:42:24 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -50,12 +50,12 @@
 #include <dev/i2c/nxt2kvar.h>
 #include <dev/i2c/lg3303var.h>
 
+#include <dev/dtv/dtvif.h>
+
 #include <dev/pci/cxdtvreg.h>
 #include <dev/pci/cxdtvvar.h>
 #include <dev/pci/cxdtv_boards.h>
 
-#include <dev/dtv/dtvif.h>
-
 #define CXDTV_MMBASE		0x10
 
 #define CXDTV_SRAM_CH_MPEG	0
@@ -64,6 +64,7 @@
 static int cxdtv_match(struct device *, struct cfdata *, void *);
 static void cxdtv_attach(struct device *, struct device *, void *);
 static int cxdtv_detach(struct device *, int);
+static int cxdtv_rescan(struct device *, const char *, const int *);
 static void cxdtv_childdet(struct device *, struct device *);
 static int cxdtv_intr(void *);
 
@@ -102,6 +103,30 @@
 static void cxdtv_card_init_hd5500(struct cxdtv_softc *);
 static void cxdtv_card_init_hdtvwonder(struct cxdtv_softc *);
 
+/* MPEG TS Port */
+static void cxdtv_dtv_get_devinfo(void *, struct dvb_frontend_info *);
+static int cxdtv_dtv_open(void *, int);
+static void cxdtv_dtv_close(void *);
+static int cxdtv_dtv_set_tuner(void *, const struct dvb_frontend_parameters *);
+static fe_status_t cxdtv_dtv_get_status(void *);
+static uint16_t cxdtv_dtv_get_signal_strength(void *);
+static uint16_t cxdtv_dtv_get_snr(void *);
+static int cxdtv_dtv_start_transfer(void *,
+    void (*)(void *, const struct dtv_payload *), void *);
+static int cxdtv_dtv_stop_transfer(void *);
+
+static const struct dtv_hw_if cxdtv_dtv_if = {
+	.get_devinfo = cxdtv_dtv_get_devinfo,
+	.open = cxdtv_dtv_open,
+	.close = cxdtv_dtv_close,
+	.set_tuner = cxdtv_dtv_set_tuner,
+	.get_status = cxdtv_dtv_get_status,
+	.get_signal_strength = cxdtv_dtv_get_signal_strength,
+	.get_snr = cxdtv_dtv_get_snr,
+	.start_transfer = cxdtv_dtv_start_transfer,
+	.stop_transfer = cxdtv_dtv_stop_transfer,
+};
+
 const struct i2c_bitbang_ops cxdtv_i2cbb_ops = {
 	cxdtv_i2cbb_set_bits,
 	cxdtv_i2cbb_set_dir,
@@ -129,7 +154,8 @@
 };
 
 CFATTACH_DECL2_NEW(cxdtv, sizeof(struct cxdtv_softc),
-    cxdtv_match, cxdtv_attach, cxdtv_detach, NULL, NULL, cxdtv_childdet);
+    cxdtv_match, cxdtv_attach, cxdtv_detach, NULL,
+    cxdtv_rescan, cxdtv_childdet);
 
 static int
 cxdtv_match(device_t parent, cfdata_t match, void *aux)
@@ -266,6 +292,22 @@
 	return 0;
 }
 
+static int
+cxdtv_rescan(device_t self, const char *ifattr, const int *locs)
+{
+	struct cxdtv_softc *sc = device_private(self);
+	struct dtv_attach_args daa;
+
+	daa.hw = &cxdtv_dtv_if;
+	daa.priv = sc;
+
+	if (ifattr_match(ifattr, "dtvbus") && sc->sc_dtvdev == NULL)
+		sc->sc_dtvdev = config_found_ia(sc->sc_dev, "dtvbus",
+		    &daa, dtv_print);
+
+	return 0;
+}
+
 static void
 cxdtv_childdet(device_t self, device_t child)
 {
@@ -396,34 +438,9 @@
 	return i2c_bitbang_write_byte(cookie, data, flags, &cxdtv_i2cbb_ops);
 }
 
-/* MPEG TS Port */
-
-static void cxdtv_dtv_get_devinfo(void *, struct dvb_frontend_info *);
-static int cxdtv_dtv_open(void *, int);
-static void cxdtv_dtv_close(void *);
-static int cxdtv_dtv_set_tuner(void *, const struct dvb_frontend_parameters *);
-static fe_status_t cxdtv_dtv_get_status(void *);
-static uint16_t cxdtv_dtv_get_signal_strength(void *);
-static uint16_t cxdtv_dtv_get_snr(void *);
-static int cxdtv_dtv_start_transfer(void *);
-static int cxdtv_dtv_stop_transfer(void *);
-
-static const struct dtv_hw_if cxdtv_dtv_if = {
-	.get_devinfo = cxdtv_dtv_get_devinfo,
-	.open = cxdtv_dtv_open,
-	.close = cxdtv_dtv_close,
-	.set_tuner = cxdtv_dtv_set_tuner,
-	.get_status = cxdtv_dtv_get_status,
-	.get_signal_strength = cxdtv_dtv_get_signal_strength,
-	.get_snr = cxdtv_dtv_get_snr,
-	.start_transfer = cxdtv_dtv_start_transfer,
-	.stop_transfer = cxdtv_dtv_stop_transfer,
-};
-
 int
 cxdtv_mpeg_attach(struct cxdtv_softc *sc)
 {
-	struct dtv_attach_args daa;
 	struct cxdtv_sram_ch *ch;
 
 	CX_DPRINTF(("cxdtv_mpeg_attach\n"));
@@ -478,10 +495,7 @@
 	KASSERT(sc->sc_tuner != NULL);
 	KASSERT(sc->sc_demod != NULL);
 
-	daa.hw = &cxdtv_dtv_if;
-	daa.priv = sc;
-
-	sc->sc_dtvdev = config_found_ia(sc->sc_dev, "dtvbus", &daa, dtv_print);
+	cxdtv_rescan(sc->sc_dev, NULL, NULL);
 
 	return (sc->sc_dtvdev != NULL);
 }
@@ -647,10 +661,14 @@
 }
 
 static int
-cxdtv_dtv_start_transfer(void *priv)
+cxdtv_dtv_start_transfer(void *priv,
+    void (*cb)(void *, const struct dtv_payload *), void *arg)
 {
 	struct cxdtv_softc *sc = priv;
 	
+	sc->sc_dtvsubmitcb = cb;
+	sc->sc_dtvsubmitarg = arg;
+
 	/* allocate two alternating DMA areas for MPEG TS packets */
 	sc->sc_tsbuf = cxdtv_mpeg_malloc(sc, CXDTV_TS_PKTSIZE * 2);
 
@@ -667,6 +685,9 @@
 	cxdtv_mpeg_halt(sc);
 	bus_space_write_4(sc->sc_memt, sc->sc_memh, CXDTV_PCI_INT_MASK, 0);
 
+	sc->sc_dtvsubmitcb = NULL;
+	sc->sc_dtvsubmitarg = NULL;
+
 	return 0;
 }
 
@@ -970,13 +991,16 @@
 	if ( (s & ~CXDTV_TS_RISCI) != 0 )
 		device_printf(sc->sc_dev, "unexpected TS IS %08x\n", s);
 
+	if (sc->sc_dtvsubmitcb == NULL)
+		goto done;
+
 	if ((s & CXDTV_TS_RISCI1) == CXDTV_TS_RISCI1) {
 		bus_dmamap_sync(sc->sc_dmat, sc->sc_dma->map,
 			0, CXDTV_TS_PKTSIZE,
 			BUS_DMASYNC_POSTREAD);
 		payload.data = KERNADDR(sc->sc_dma);
 		payload.size = CXDTV_TS_PKTSIZE;
-		dtv_submit_payload(sc->sc_dtvdev, &payload);
+		sc->sc_dtvsubmitcb(sc->sc_dtvsubmitarg, &payload);
 	}
 
 	if ((s & CXDTV_TS_RISCI2) == CXDTV_TS_RISCI2) {
@@ -985,9 +1009,10 @@
 			BUS_DMASYNC_POSTREAD);
 		payload.data = (char *)(KERNADDR(sc->sc_dma)) + (uintptr_t)CXDTV_TS_PKTSIZE;
 		payload.size = CXDTV_TS_PKTSIZE;
-		dtv_submit_payload(sc->sc_dtvdev, &payload);
+		sc->sc_dtvsubmitcb(sc->sc_dtvsubmitarg, &payload);
 	}
 
+done:
 	bus_space_write_4(sc->sc_memt, sc->sc_memh, CXDTV_TS_INT_STAT, s);
 
 	return 1;
@@ -1139,7 +1164,7 @@
 	delay(200000);
 }
 
-MODULE(MODULE_CLASS_DRIVER, cxdtv, "dtv,tvpll,nxt2k,lg3303");
+MODULE(MODULE_CLASS_DRIVER, cxdtv, "tvpll,nxt2k,lg3303");
 
 #ifdef _MODULE
 #include "ioconf.c"

Index: src/sys/dev/usb/auvitek.c
diff -u src/sys/dev/usb/auvitek.c:1.4 src/sys/dev/usb/auvitek.c:1.5
--- src/sys/dev/usb/auvitek.c:1.4	Sat Jul  9 15:00:44 2011
+++ src/sys/dev/usb/auvitek.c	Tue Aug  9 01:42:24 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: auvitek.c,v 1.4 2011/07/09 15:00:44 jmcneill Exp $ */
+/* $NetBSD: auvitek.c,v 1.5 2011/08/09 01:42:24 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2010 Jared D. McNeill <[email protected]>
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: auvitek.c,v 1.4 2011/07/09 15:00:44 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auvitek.c,v 1.5 2011/08/09 01:42:24 jmcneill Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -52,12 +52,13 @@
 static int	auvitek_match(device_t, cfdata_t, void *);
 static void	auvitek_attach(device_t, device_t, void *);
 static int	auvitek_detach(device_t, int);
+static int	auvitek_rescan(device_t, const char *, const int *);
 static void	auvitek_childdet(device_t, device_t);
 static int	auvitek_activate(device_t, enum devact);
 
 CFATTACH_DECL2_NEW(auvitek, sizeof(struct auvitek_softc),
     auvitek_match, auvitek_attach, auvitek_detach, auvitek_activate,
-    NULL, auvitek_childdet);
+    auvitek_rescan, auvitek_childdet);
 
 static const struct {
 	uint16_t		vendor;
@@ -305,6 +306,17 @@
 	}
 }
 
+static int
+auvitek_rescan(device_t self, const char *ifattr, const int *locs)
+{
+	struct auvitek_softc *sc = device_private(self);
+
+	auvitek_video_rescan(sc, ifattr, locs);
+	auvitek_dtv_rescan(sc, ifattr, locs);
+
+	return 0;
+}
+
 static void
 auvitek_childdet(device_t self, device_t child)
 {
@@ -358,7 +370,7 @@
 		    usbd_errstr(err));
 }
 
-MODULE(MODULE_CLASS_DRIVER, auvitek, "au8522,xc5k,dtv");
+MODULE(MODULE_CLASS_DRIVER, auvitek, "au8522,xc5k");
 
 #ifdef _MODULE
 #include "ioconf.c"
Index: src/sys/dev/usb/auvitek_video.c
diff -u src/sys/dev/usb/auvitek_video.c:1.4 src/sys/dev/usb/auvitek_video.c:1.5
--- src/sys/dev/usb/auvitek_video.c:1.4	Sat Jul  9 15:00:45 2011
+++ src/sys/dev/usb/auvitek_video.c	Tue Aug  9 01:42:24 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: auvitek_video.c,v 1.4 2011/07/09 15:00:45 jmcneill Exp $ */
+/* $NetBSD: auvitek_video.c,v 1.5 2011/08/09 01:42:24 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2010 Jared D. McNeill <[email protected]>
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: auvitek_video.c,v 1.4 2011/07/09 15:00:45 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auvitek_video.c,v 1.5 2011/08/09 01:42:24 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -132,7 +132,8 @@
 {
 	snprintf(sc->sc_businfo, sizeof(sc->sc_businfo), "usb:%08x",
 	    sc->sc_udev->cookie.cookie);
-	sc->sc_videodev = video_attach_mi(&auvitek_video_if, sc->sc_dev);
+
+	auvitek_video_rescan(sc, NULL, NULL);
 
 	return (sc->sc_videodev != NULL);
 }
@@ -149,6 +150,15 @@
 }
 
 void
+auvitek_video_rescan(struct auvitek_softc *sc, const char *ifattr,
+    const int *locs)
+{
+	if (ifattr_match(ifattr, "videobus") && sc->sc_videodev == NULL)
+		sc->sc_videodev = video_attach_mi(&auvitek_video_if,
+		    sc->sc_dev);
+}
+
+void
 auvitek_video_childdet(struct auvitek_softc *sc, device_t child)
 {
 	if (sc->sc_videodev == child)
Index: src/sys/dev/usb/emdtv_dtv.c
diff -u src/sys/dev/usb/emdtv_dtv.c:1.4 src/sys/dev/usb/emdtv_dtv.c:1.5
--- src/sys/dev/usb/emdtv_dtv.c:1.4	Fri Jul 15 20:32:24 2011
+++ src/sys/dev/usb/emdtv_dtv.c	Tue Aug  9 01:42:24 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: emdtv_dtv.c,v 1.4 2011/07/15 20:32:24 jmcneill Exp $ */
+/* $NetBSD: emdtv_dtv.c,v 1.5 2011/08/09 01:42:24 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2008, 2011 Jared D. McNeill <[email protected]>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: emdtv_dtv.c,v 1.4 2011/07/15 20:32:24 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: emdtv_dtv.c,v 1.5 2011/08/09 01:42:24 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -53,7 +53,9 @@
 static fe_status_t	emdtv_dtv_get_status(void *);
 static uint16_t		emdtv_dtv_get_signal_strength(void *);
 static uint16_t		emdtv_dtv_get_snr(void *);
-static int		emdtv_dtv_start_transfer(void *);
+static int		emdtv_dtv_start_transfer(void *,
+			    void (*)(void *, const struct dtv_payload *),
+			    void *);
 static int		emdtv_dtv_stop_transfer(void *);
 
 static int		emdtv_dtv_tuner_reset(void *);
@@ -81,7 +83,6 @@
 {
 	usb_endpoint_descriptor_t *ed;
 	usbd_status status;
-	struct dtv_attach_args daa;
 	int i;
 
 	for (i = 0; i < EMDTV_NXFERS; i++) {
@@ -119,9 +120,7 @@
 	emdtv_gpio_ctl(sc, EMDTV_GPIO_DEMOD1_RESET, true);
 	usbd_delay_ms(sc->sc_udev, 100);
 
-	daa.hw = &emdtv_dtv_if;
-	daa.priv = sc;
-	sc->sc_dtvdev = config_found_ia(sc->sc_dev, "dtvbus", &daa, dtv_print);
+	emdtv_dtv_rescan(sc, NULL, NULL);
 }
 
 void
@@ -146,6 +145,19 @@
 	}
 }
 
+void
+emdtv_dtv_rescan(struct emdtv_softc *sc, const char *ifattr, const int *locs)
+{
+	struct dtv_attach_args daa;
+
+	daa.hw = &emdtv_dtv_if;
+	daa.priv = sc;
+
+	if (ifattr_match(ifattr, "dtvbus") && sc->sc_dtvdev == NULL)
+		sc->sc_dtvdev = config_found_ia(sc->sc_dev, "dtvbus",
+		    &daa, dtv_print);
+}
+
 static void
 emdtv_dtv_get_devinfo(void *priv, struct dvb_frontend_info *info)
 {
@@ -279,7 +291,8 @@
 }
 
 static int
-emdtv_dtv_start_transfer(void *priv)
+emdtv_dtv_start_transfer(void *priv,
+    void (*cb)(void *, const struct dtv_payload *), void *arg)
 {
 	struct emdtv_softc *sc = priv;
 	int i, s;
@@ -287,6 +300,8 @@
 	s = splusb();
 
 	sc->sc_streaming = true;
+	sc->sc_dtvsubmitcb = cb;
+	sc->sc_dtvsubmitarg = arg;
 
 	aprint_debug_dev(sc->sc_dev, "allocating isoc xfers (pktsz %d)\n",
 	    sc->sc_isoc_maxpacketsize);
@@ -327,6 +342,9 @@
 			sc->sc_ix[i].ix_buf = NULL;
 		}
 
+	sc->sc_dtvsubmitcb = NULL;
+	sc->sc_dtvsubmitarg = NULL;
+
 	return 0;
 }
 
@@ -379,7 +397,7 @@
 
 	KASSERT(xfer == ix->ix_xfer);
 
-	if (sc->sc_dying)
+	if (sc->sc_dying || sc->sc_dtvsubmitcb == NULL)
 		return;
 
 	if (err) {
@@ -404,7 +422,7 @@
 			continue;
 		payload.data = buf;
 		payload.size = ix->ix_frlengths[i];
-		dtv_submit_payload(sc->sc_dtvdev, &payload);
+		sc->sc_dtvsubmitcb(sc->sc_dtvsubmitarg, &payload);
 	}
 
 resched:

Index: src/sys/dev/usb/auvitek_dtv.c
diff -u src/sys/dev/usb/auvitek_dtv.c:1.2 src/sys/dev/usb/auvitek_dtv.c:1.3
--- src/sys/dev/usb/auvitek_dtv.c:1.2	Sun Jul 10 00:47:34 2011
+++ src/sys/dev/usb/auvitek_dtv.c	Tue Aug  9 01:42:24 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: auvitek_dtv.c,v 1.2 2011/07/10 00:47:34 jmcneill Exp $ */
+/* $NetBSD: auvitek_dtv.c,v 1.3 2011/08/09 01:42:24 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <[email protected]>
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: auvitek_dtv.c,v 1.2 2011/07/10 00:47:34 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: auvitek_dtv.c,v 1.3 2011/08/09 01:42:24 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -60,7 +60,9 @@
 static fe_status_t	auvitek_dtv_get_status(void *);
 static uint16_t		auvitek_dtv_get_signal_strength(void *);
 static uint16_t		auvitek_dtv_get_snr(void *);
-static int		auvitek_dtv_start_transfer(void *);
+static int		auvitek_dtv_start_transfer(void *,
+			    void (*)(void *, const struct dtv_payload *),
+			    void *);
 static int		auvitek_dtv_stop_transfer(void *);
 
 static int		auvitek_dtv_init_pipes(struct auvitek_softc *);
@@ -87,11 +89,8 @@
 int
 auvitek_dtv_attach(struct auvitek_softc *sc)
 {
-	struct dtv_attach_args daa;
 
-	daa.hw = &auvitek_dtv_if;
-	daa.priv = sc;
-	sc->sc_dtvdev = config_found_ia(sc->sc_dev, "dtvbus", &daa, dtv_print);
+	auvitek_dtv_rescan(sc, NULL, NULL);
 
 	return (sc->sc_dtvdev != NULL);
 }
@@ -108,6 +107,20 @@
 }
 
 void
+auvitek_dtv_rescan(struct auvitek_softc *sc, const char *ifattr,
+    const int *locs)
+{
+	struct dtv_attach_args daa;
+
+	daa.hw = &auvitek_dtv_if;
+	daa.priv = sc;
+
+	if (ifattr_match(ifattr, "dtvbus") && sc->sc_dtvdev == NULL)
+		sc->sc_dtvdev = config_found_ia(sc->sc_dev, "dtvbus",
+		    &daa, dtv_print);
+}
+
+void
 auvitek_dtv_childdet(struct auvitek_softc *sc, device_t child)
 {
 	if (sc->sc_dtvdev == child)
@@ -158,6 +171,9 @@
 
 	auvitek_dtv_stop_transfer(sc);
 	auvitek_dtv_close_pipes(sc);
+
+	sc->sc_dtvsubmitcb = NULL;
+	sc->sc_dtvsubmitarg = NULL;
 }
 
 static int
@@ -202,7 +218,8 @@
 }
 
 static int
-auvitek_dtv_start_transfer(void *priv)
+auvitek_dtv_start_transfer(void *priv,
+    void (*cb)(void *, const struct dtv_payload *), void *arg)
 {
 	struct auvitek_softc *sc = priv;
 	int s;
@@ -211,6 +228,9 @@
 		return 0;
 	}
 
+	sc->sc_dtvsubmitcb = cb;
+	sc->sc_dtvsubmitarg = arg;
+
 	auvitek_write_1(sc, 0x608, 0x90);
 	auvitek_write_1(sc, 0x609, 0x72);
 	auvitek_write_1(sc, 0x60a, 0x71);
@@ -278,7 +298,7 @@
 	struct dtv_payload payload;
 	uint32_t xferlen;
 
-	if (ab->ab_running == false)
+	if (ab->ab_running == false || sc->sc_dtvsubmitcb == NULL)
 		return;
 
 	usbd_get_xfer_status(xfer, NULL, NULL, &xferlen, NULL);
@@ -304,7 +324,7 @@
 
 	payload.data = bx->bx_buffer;
 	payload.size = xferlen;
-	dtv_submit_payload(sc->sc_dtvdev, &payload);
+	sc->sc_dtvsubmitcb(sc->sc_dtvsubmitarg, &payload);
 
 next:
 	auvitek_dtv_bulk_start1(bx);
Index: src/sys/dev/usb/emdtvvar.h
diff -u src/sys/dev/usb/emdtvvar.h:1.2 src/sys/dev/usb/emdtvvar.h:1.3
--- src/sys/dev/usb/emdtvvar.h:1.2	Mon Jul 11 18:30:31 2011
+++ src/sys/dev/usb/emdtvvar.h	Tue Aug  9 01:42:24 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: emdtvvar.h,v 1.2 2011/07/11 18:30:31 jmcneill Exp $ */
+/* $NetBSD: emdtvvar.h,v 1.3 2011/08/09 01:42:24 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2008 Jared D. McNeill <[email protected]>
@@ -102,12 +102,16 @@
 	uint32_t		sc_frequency;
 
 	bool			sc_streaming;
+	void			(*sc_dtvsubmitcb)(void *,
+				    const struct dtv_payload *);
+	void			*sc_dtvsubmitarg;
 
 	bool			sc_dying;
 };
 
 void	emdtv_dtv_attach(struct emdtv_softc *);
 void	emdtv_dtv_detach(struct emdtv_softc *, int);
+void	emdtv_dtv_rescan(struct emdtv_softc *, const char *, const int *);
 void	emdtv_ir_attach(struct emdtv_softc *);
 void	emdtv_ir_detach(struct emdtv_softc *, int);
 int	emdtv_i2c_attach(struct emdtv_softc *);

Index: src/sys/dev/usb/auvitekvar.h
diff -u src/sys/dev/usb/auvitekvar.h:1.3 src/sys/dev/usb/auvitekvar.h:1.4
--- src/sys/dev/usb/auvitekvar.h:1.3	Sat Jul  9 15:00:45 2011
+++ src/sys/dev/usb/auvitekvar.h	Tue Aug  9 01:42:24 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: auvitekvar.h,v 1.3 2011/07/09 15:00:45 jmcneill Exp $ */
+/* $NetBSD: auvitekvar.h,v 1.4 2011/08/09 01:42:24 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2010 Jared D. McNeill <[email protected]>
@@ -121,6 +121,9 @@
 
 	unsigned int		sc_ainput, sc_vinput;
 	uint32_t		sc_curfreq;
+	void			(*sc_dtvsubmitcb)(void *,
+				    const struct dtv_payload *);
+	void			*sc_dtvsubmitarg;
 
 	struct auvitek_xfer	sc_ax;
 	struct auvitek_bulk	sc_ab;
@@ -149,11 +152,13 @@
 /* auvitek_video.c */
 int	auvitek_video_attach(struct auvitek_softc *);
 int	auvitek_video_detach(struct auvitek_softc *, int);
+void	auvitek_video_rescan(struct auvitek_softc *, const char *, const int *);
 void	auvitek_video_childdet(struct auvitek_softc *, device_t);
 
 /* auvitek_dtv.c */
 int	auvitek_dtv_attach(struct auvitek_softc *);
 int	auvitek_dtv_detach(struct auvitek_softc *, int);
+void	auvitek_dtv_rescan(struct auvitek_softc *, const char *, const int *);
 void	auvitek_dtv_childdet(struct auvitek_softc *, device_t);
 
 #endif /* !_AUVITEKVAR_H */
Index: src/sys/dev/usb/emdtv.c
diff -u src/sys/dev/usb/emdtv.c:1.3 src/sys/dev/usb/emdtv.c:1.4
--- src/sys/dev/usb/emdtv.c:1.3	Fri Jul 15 10:48:30 2011
+++ src/sys/dev/usb/emdtv.c	Tue Aug  9 01:42:24 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: emdtv.c,v 1.3 2011/07/15 10:48:30 jmcneill Exp $ */
+/* $NetBSD: emdtv.c,v 1.4 2011/08/09 01:42:24 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2008, 2011 Jared D. McNeill <[email protected]>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: emdtv.c,v 1.3 2011/07/15 10:48:30 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: emdtv.c,v 1.4 2011/08/09 01:42:24 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -46,6 +46,7 @@
 static int	emdtv_match(device_t, cfdata_t, void *);
 static void	emdtv_attach(device_t, device_t, void *);
 static int	emdtv_detach(device_t, int);
+static int	emdtv_rescan(device_t, const char *, const int *);
 static void	emdtv_childdet(device_t, device_t);
 static int	emdtv_activate(device_t, enum devact);
 
@@ -56,7 +57,7 @@
 
 CFATTACH_DECL2_NEW(emdtv, sizeof(struct emdtv_softc),
     emdtv_match, emdtv_attach, emdtv_detach, emdtv_activate,
-    NULL, emdtv_childdet);
+    emdtv_rescan, emdtv_childdet);
 
 static const struct usb_devno emdtv_devices[] = {
 	{ USB_VENDOR_AMD,	USB_PRODUCT_AMD_TV_WONDER_600_USB },
@@ -183,6 +184,16 @@
 	return 0;
 }
 
+static int
+emdtv_rescan(device_t self, const char *ifattr, const int *locs)
+{
+	struct emdtv_softc *sc = device_private(self);
+
+	emdtv_dtv_rescan(sc, ifattr, locs);
+
+	return 0;
+}
+
 static void
 emdtv_childdet(device_t self, device_t child)
 {
@@ -442,7 +453,7 @@
 	usbd_delay_ms(sc->sc_udev, 10);
 }
 
-MODULE(MODULE_CLASS_DRIVER, emdtv, "cir,dtv,lg3303,xc3028");
+MODULE(MODULE_CLASS_DRIVER, emdtv, "cir,lg3303,xc3028");
 
 #ifdef _MODULE
 #include "ioconf.c"

Index: src/sys/modules/Makefile
diff -u src/sys/modules/Makefile:1.81 src/sys/modules/Makefile:1.82
--- src/sys/modules/Makefile:1.81	Mon Aug  1 03:51:05 2011
+++ src/sys/modules/Makefile	Tue Aug  9 01:42:24 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.81 2011/08/01 03:51:05 pgoyette Exp $
+#	$NetBSD: Makefile,v 1.82 2011/08/09 01:42:24 jmcneill Exp $
 
 .include <bsd.own.mk>
 
@@ -16,6 +16,7 @@
 SUBDIR+=	compat_ossaudio
 SUBDIR+=	coredump
 SUBDIR+=	dtv
+SUBDIR+=	dtv_math
 SUBDIR+=	efs
 SUBDIR+=	ext2fs
 SUBDIR+=	exec_script

Index: src/sys/modules/dtv/Makefile
diff -u src/sys/modules/dtv/Makefile:1.3 src/sys/modules/dtv/Makefile:1.4
--- src/sys/modules/dtv/Makefile:1.3	Fri Jul 15 20:27:41 2011
+++ src/sys/modules/dtv/Makefile	Tue Aug  9 01:42:25 2011
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.3 2011/07/15 20:27:41 jmcneill Exp $
+# $NetBSD: Makefile,v 1.4 2011/08/09 01:42:25 jmcneill Exp $
 
 .include "../Makefile.inc"
 
@@ -10,7 +10,6 @@
 	dtv_demux.c \
 	dtv_device.c \
 	dtv_ioctl.c \
-	dtv_math.c \
 	dtv_scatter.c
 
 WARNS=	4

Added files:

Index: src/sys/modules/dtv_math/Makefile
diff -u /dev/null src/sys/modules/dtv_math/Makefile:1.1
--- /dev/null	Tue Aug  9 01:42:25 2011
+++ src/sys/modules/dtv_math/Makefile	Tue Aug  9 01:42:25 2011
@@ -0,0 +1,12 @@
+# $NetBSD: Makefile,v 1.1 2011/08/09 01:42:25 jmcneill Exp $
+
+.include "../Makefile.inc"
+
+.PATH:	${S}/dev/dtv
+
+KMOD=	dtv_math
+SRCS=	dtv_math.c
+
+WARNS=	4
+
+.include <bsd.kmodule.mk>

Reply via email to