summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorjmcneill <jmcneill@NetBSD.org>2011-08-09 01:42:24 +0000
committerjmcneill <jmcneill@NetBSD.org>2011-08-09 01:42:24 +0000
commit8f316c9d31c5699dff3348944bc0b3cecdabfcd2 (patch)
tree2b732df3b8492af263d754510fe79ad6cbf4144b /sys
parent10629df4c0ed8af8e573cddc477f70616fc35d33 (diff)
modify the dtv device api so hardware drivers can be loaded independently
of the dtv module
Diffstat (limited to 'sys')
-rw-r--r--sys/conf/files11
-rw-r--r--sys/dev/dtv/dtv_buffer.c8
-rw-r--r--sys/dev/dtv/dtv_device.c13
-rw-r--r--sys/dev/dtv/dtv_math.c19
-rw-r--r--sys/dev/dtv/dtvif.h21
-rw-r--r--sys/dev/dtv/dtvvar.h7
-rw-r--r--sys/dev/dtv/files.dtv6
-rw-r--r--sys/dev/i2c/files.i2c4
-rw-r--r--sys/dev/i2c/xc3028.c6
-rw-r--r--sys/dev/pci/coram.c51
-rw-r--r--sys/dev/pci/coramvar.h6
-rw-r--r--sys/dev/pci/cxdtv.c101
-rw-r--r--sys/dev/pci/cxdtvvar.h6
-rw-r--r--sys/dev/usb/auvitek.c20
-rw-r--r--sys/dev/usb/auvitek_dtv.c40
-rw-r--r--sys/dev/usb/auvitek_video.c16
-rw-r--r--sys/dev/usb/auvitekvar.h7
-rw-r--r--sys/dev/usb/emdtv.c19
-rw-r--r--sys/dev/usb/emdtv_dtv.c38
-rw-r--r--sys/dev/usb/emdtvvar.h6
-rw-r--r--sys/modules/Makefile3
-rw-r--r--sys/modules/dtv/Makefile3
-rw-r--r--sys/modules/dtv_math/Makefile12
23 files changed, 292 insertions, 131 deletions
diff --git a/sys/conf/files b/sys/conf/files
index a94ab55ebca..43914fbeec7 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -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 @@ define audiobell
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 @@ include "dev/nand/files.nand"
# NOR subsytem
#
include "dev/nor/files.nor"
-
-#
-# DTV subsystem
-#
-include "dev/dtv/files.dtv"
diff --git a/sys/dev/dtv/dtv_buffer.c b/sys/dev/dtv/dtv_buffer.c
index a43a297d8c2..78e03416d37 100644
--- a/sys/dev/dtv/dtv_buffer.c
+++ b/sys/dev/dtv/dtv_buffer.c
@@ -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 <jmcneill@invisible.ca>
@@ -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 @@ dtv_buffer_write(struct dtv_softc *sc, const uint8_t *buf, size_t buflen)
}
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;
diff --git a/sys/dev/dtv/dtv_device.c b/sys/dev/dtv/dtv_device.c
index 89fd36a835c..8c8ce70a369 100644
--- a/sys/dev/dtv/dtv_device.c
+++ b/sys/dev/dtv/dtv_device.c
@@ -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 <jmcneill@invisible.ca>
@@ -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 @@ dtv_common_close(struct dtv_softc *sc)
}
mutex_exit(&sc->sc_lock);
}
-
-int
-dtv_print(void *arg, const char *pnp)
-{
- if (pnp)
- aprint_normal("dtv at %s", pnp);
-
- return UNCONF;
-}
diff --git a/sys/dev/dtv/dtv_math.c b/sys/dev/dtv/dtv_math.c
index 267be710df9..45a715f30b1 100644
--- a/sys/dev/dtv/dtv_math.c
+++ b/sys/dev/dtv/dtv_math.c
@@ -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 <apb@NetBSD.org>
@@ -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 @@ dtv_intlog10(uint32_t x)
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:
diff --git a/sys/dev/dtv/dtvif.h b/sys/dev/dtv/dtvif.h
index 993cfc63ce5..d0b997c5649 100644
--- a/sys/dev/dtv/dtvif.h
+++ b/sys/dev/dtv/dtvif.h
@@ -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 <jmcneill@invisible.ca>
@@ -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 @@ struct dtv_hw_if {
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 @@ struct dtv_payload {
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 */
diff --git a/sys/dev/dtv/dtvvar.h b/sys/dev/dtv/dtvvar.h
index a99cbd537f6..adccefc6741 100644
--- a/sys/dev/dtv/dtvvar.h
+++ b/sys/dev/dtv/dtvvar.h
@@ -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 <jmcneill@invisible.ca>
@@ -141,8 +141,8 @@ struct dtv_softc {
((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_setup(struct dtv_softc *);
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 *);
diff --git a/sys/dev/dtv/files.dtv b/sys/dev/dtv/files.dtv
index 0893b12d1c2..40fbaa64e6f 100644
--- a/sys/dev/dtv/files.dtv
+++ b/sys/dev/dtv/files.dtv
@@ -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_buffer.c dtv
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
diff --git a/sys/dev/i2c/files.i2c b/sys/dev/i2c/files.i2c
index 52754a013f6..738c28ceca4 100644
--- a/sys/dev/i2c/files.i2c
+++ b/sys/dev/i2c/files.i2c
@@ -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 @@ define lg3303: i2cexec
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
diff --git a/sys/dev/i2c/xc3028.c b/sys/dev/i2c/xc3028.c
index 809ff5d06ab..be5fc6ef63a 100644
--- a/sys/dev/i2c/xc3028.c
+++ b/sys/dev/i2c/xc3028.c
@@ -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 <jmcneill@invisible.ca>
@@ -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 @@ xc3028_tune_dtv(struct xc3028 *xc, const struct dvb_frontend_parameters *params)
return 0;
}
-MODULE(MODULE_CLASS_DRIVER, xc3028, NULL);
+MODULE(MODULE_CLASS_DRIVER, xc3028, "dtv_math");
static int
xc3028_modcmd(modcmd_t cmd, void *opaque)
diff --git a/sys/dev/pci/coram.c b/sys/dev/pci/coram.c
index a680c44ca5e..45f071d3c44 100644
--- a/sys/dev/pci/coram.c
+++ b/sys/dev/pci/coram.c
@@ -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 const struct coram_board coram_boards[] = {
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 int coram_dtv_set_tuner(void *, const struct dvb_frontend_parameters *);
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_sram_ch_setup(struct coram_softc *, struct coram_sram_ch *, uin
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 @@ coram_detach(device_t self, int flags)
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 @@ coram_mpeg_intr(struct coram_softc *sc)
}
}
+ 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 @@ coram_mpeg_intr(struct coram_softc *sc)
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 @@ coram_iic_write(struct coram_iic_softc *cic, i2c_op_t op, i2c_addr_t addr,
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_attach(struct coram_softc *sc)
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 @@ coram_dtv_get_snr(void *cookie)
}
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 @@ coram_dtv_start_transfer(void *cookie)
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_dtv_stop_transfer(void *cookie)
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 @@ coram_sram_ch_setup(struct coram_softc *sc, struct coram_sram_ch *csc,
return 0;
}
-MODULE(MODULE_CLASS_DRIVER, coram, "dtv,cx24227,mt2131");
+MODULE(MODULE_CLASS_DRIVER, coram, "cx24227,mt2131");
#ifdef _MODULE
#include "ioconf.c"
diff --git a/sys/dev/pci/coramvar.h b/sys/dev/pci/coramvar.h
index e5bb7a9bdeb..b739a876d6c 100644
--- a/sys/dev/pci/coramvar.h
+++ b/sys/dev/pci/coramvar.h
@@ -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 @@ struct coram_softc {
void *sc_tuner;
void *sc_demod;
+ void (*sc_dtvsubmitcb)(void *,
+ const struct dtv_payload *);
+ void *sc_dtvsubmitarg;
+
const struct coram_board *sc_board;
};
diff --git a/sys/dev/pci/cxdtv.c b/sys/dev/pci/cxdtv.c
index 52b0277b698..fa7b57ce1ff 100644
--- a/sys/dev/pci/cxdtv.c
+++ b/sys/dev/pci/cxdtv.c
@@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: cxdtv.c,v 1.6 2011/07/25 04:31:26 jakllsch Exp $");
#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 @@ __KERNEL_RCSID(0, "$NetBSD: cxdtv.c,v 1.6 2011/07/25 04:31:26 jakllsch Exp $");
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_mpeg_free(struct cxdtv_softc *, void *);
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 @@ static struct cxdtv_sram_ch cxdtv_sram_chs[] = {
};
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 @@ cxdtv_detach(device_t self, int flags)
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 @@ cxdtv_iic_write_byte(void *cookie, uint8_t data, int flags)
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 @@ cxdtv_mpeg_attach(struct cxdtv_softc *sc)
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 @@ cxdtv_dtv_get_snr(void *priv)
}
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_dtv_stop_transfer(void *priv)
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 @@ cxdtv_mpeg_intr(struct cxdtv_softc *sc)
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 @@ cxdtv_mpeg_intr(struct cxdtv_softc *sc)
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 @@ cxdtv_card_init_hd5500(struct cxdtv_softc *sc)
delay(200000);
}
-MODULE(MODULE_CLASS_DRIVER, cxdtv, "dtv,tvpll,nxt2k,lg3303");
+MODULE(MODULE_CLASS_DRIVER, cxdtv, "tvpll,nxt2k,lg3303");
#ifdef _MODULE
#include "ioconf.c"
diff --git a/sys/dev/pci/cxdtvvar.h b/sys/dev/pci/cxdtvvar.h
index 4ea0c9e0e07..ba5116d7cb6 100644
--- a/sys/dev/pci/cxdtvvar.h
+++ b/sys/dev/pci/cxdtvvar.h
@@ -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 @@ struct cxdtv_softc {
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;
diff --git a/sys/dev/usb/auvitek.c b/sys/dev/usb/auvitek.c
index 61c44aa4738..cd592dd52fc 100644
--- a/sys/dev/usb/auvitek.c
+++ b/sys/dev/usb/auvitek.c
@@ -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 <jmcneill@invisible.ca>
@@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: auvitek.c,v 1.4 2011/07/09 15:00:44 jmcneill Exp $")
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 @@ auvitek_activate(device_t self, enum devact act)
}
}
+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 @@ auvitek_write_1(struct auvitek_softc *sc, uint16_t reg, uint8_t data)
usbd_errstr(err));
}
-MODULE(MODULE_CLASS_DRIVER, auvitek, "au8522,xc5k,dtv");
+MODULE(MODULE_CLASS_DRIVER, auvitek, "au8522,xc5k");
#ifdef _MODULE
#include "ioconf.c"
diff --git a/sys/dev/usb/auvitek_dtv.c b/sys/dev/usb/auvitek_dtv.c
index 6aeccce4791..f8e67c3e59a 100644
--- a/sys/dev/usb/auvitek_dtv.c
+++ b/sys/dev/usb/auvitek_dtv.c
@@ -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 <jmcneill@invisible.ca>
@@ -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 int auvitek_dtv_set_tuner(void *,
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 @@ static const struct dtv_hw_if auvitek_dtv_if = {
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 @@ auvitek_dtv_detach(struct auvitek_softc *sc, int flags)
}
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_close(void *priv)
auvitek_dtv_stop_transfer(sc);
auvitek_dtv_close_pipes(sc);
+
+ sc->sc_dtvsubmitcb = NULL;
+ sc->sc_dtvsubmitarg = NULL;
}
static int
@@ -202,7 +218,8 @@ auvitek_dtv_get_snr(void *priv)
}
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 @@ auvitek_dtv_start_transfer(void *priv)
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 @@ auvitek_dtv_bulk_cb(usbd_xfer_handle xfer, usbd_private_handle priv,
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 @@ auvitek_dtv_bulk_cb(usbd_xfer_handle xfer, usbd_private_handle priv,
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);
diff --git a/sys/dev/usb/auvitek_video.c b/sys/dev/usb/auvitek_video.c
index bc0fcae59a6..f569740b972 100644
--- a/sys/dev/usb/auvitek_video.c
+++ b/sys/dev/usb/auvitek_video.c
@@ -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 <jmcneill@invisible.ca>
@@ -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 @@ auvitek_video_attach(struct auvitek_softc *sc)
{
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 @@ auvitek_video_detach(struct auvitek_softc *sc, int flags)
}
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)
diff --git a/sys/dev/usb/auvitekvar.h b/sys/dev/usb/auvitekvar.h
index 6674cc112b4..bc8601452fd 100644
--- a/sys/dev/usb/auvitekvar.h
+++ b/sys/dev/usb/auvitekvar.h
@@ -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 <jmcneill@invisible.ca>
@@ -121,6 +121,9 @@ struct auvitek_softc {
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 @@ int auvitek_i2c_detach(struct auvitek_softc *, int);
/* 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 */
diff --git a/sys/dev/usb/emdtv.c b/sys/dev/usb/emdtv.c
index 4272d9420ce..62a7f4b6662 100644
--- a/sys/dev/usb/emdtv.c
+++ b/sys/dev/usb/emdtv.c
@@ -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 <jmcneill@invisible.ca>
@@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: emdtv.c,v 1.3 2011/07/15 10:48:30 jmcneill Exp $");
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 @@ static void emdtv_default_board_init(struct emdtv_softc *);
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 @@ emdtv_activate(device_t self, enum devact act)
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 @@ emdtv_default_board_init(struct emdtv_softc *sc)
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"
diff --git a/sys/dev/usb/emdtv_dtv.c b/sys/dev/usb/emdtv_dtv.c
index f72bfda6471..dba5f42c092 100644
--- a/sys/dev/usb/emdtv_dtv.c
+++ b/sys/dev/usb/emdtv_dtv.c
@@ -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 <jmcneill@invisible.ca>
@@ -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 int emdtv_dtv_set_tuner(void *,
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 @@ emdtv_dtv_attach(struct emdtv_softc *sc)
{
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_dtv_attach(struct emdtv_softc *sc)
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 @@ emdtv_dtv_detach(struct emdtv_softc *sc, int flags)
}
}
+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 @@ emdtv_dtv_get_snr(void *priv)
}
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 @@ emdtv_dtv_start_transfer(void *priv)
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 @@ emdtv_dtv_stop_transfer(void *priv)
sc->sc_ix[i].ix_buf = NULL;
}
+ sc->sc_dtvsubmitcb = NULL;
+ sc->sc_dtvsubmitarg = NULL;
+
return 0;
}
@@ -379,7 +397,7 @@ emdtv_dtv_isoc(usbd_xfer_handle xfer, usbd_private_handle priv,
KASSERT(xfer == ix->ix_xfer);
- if (sc->sc_dying)
+ if (sc->sc_dying || sc->sc_dtvsubmitcb == NULL)
return;
if (err) {
@@ -404,7 +422,7 @@ emdtv_dtv_isoc(usbd_xfer_handle xfer, usbd_private_handle priv,
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:
diff --git a/sys/dev/usb/emdtvvar.h b/sys/dev/usb/emdtvvar.h
index 4ef91033fd1..9ff3af98540 100644
--- a/sys/dev/usb/emdtvvar.h
+++ b/sys/dev/usb/emdtvvar.h
@@ -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 <jmcneill@invisible.ca>
@@ -102,12 +102,16 @@ struct emdtv_softc {
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 *);
diff --git a/sys/modules/Makefile b/sys/modules/Makefile
index 7b7511b0aaf..cdf07992872 100644
--- a/sys/modules/Makefile
+++ b/sys/modules/Makefile
@@ -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
SUBDIR+= compat_ossaudio
SUBDIR+= coredump
SUBDIR+= dtv
+SUBDIR+= dtv_math
SUBDIR+= efs
SUBDIR+= ext2fs
SUBDIR+= exec_script
diff --git a/sys/modules/dtv/Makefile b/sys/modules/dtv/Makefile
index 03381055144..e74dea7e688 100644
--- a/sys/modules/dtv/Makefile
+++ b/sys/modules/dtv/Makefile
@@ -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 @@ SRCS= dtv_buffer.c \
dtv_demux.c \
dtv_device.c \
dtv_ioctl.c \
- dtv_math.c \
dtv_scatter.c
WARNS= 4
diff --git a/sys/modules/dtv_math/Makefile b/sys/modules/dtv_math/Makefile
new file mode 100644
index 00000000000..e316559ea41
--- /dev/null
+++ b/sys/modules/dtv_math/Makefile
@@ -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>