Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev add digital capture support



details:   https://anonhg.NetBSD.org/src/rev/1bbeed0dde5c
branches:  trunk
changeset: 767117:1bbeed0dde5c
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sat Jul 09 15:00:43 2011 +0000

description:
add digital capture support

diffstat:

 sys/dev/i2c/au8522.c           |  118 +++++++++++++-
 sys/dev/i2c/au8522mod.h        |   41 ++++
 sys/dev/i2c/au8522mod_8vsb.h   |   57 ++++++
 sys/dev/i2c/au8522mod_qam256.h |  102 ++++++++++++
 sys/dev/i2c/au8522mod_qam64.h  |  102 ++++++++++++
 sys/dev/i2c/au8522var.h        |   12 +-
 sys/dev/i2c/xc5k.c             |  128 ++++++++++++++-
 sys/dev/i2c/xc5kreg.h          |   15 +-
 sys/dev/i2c/xc5kvar.h          |   12 +-
 sys/dev/usb/auvitek.c          |  101 ++++++++++-
 sys/dev/usb/auvitek_board.c    |   13 +-
 sys/dev/usb/auvitek_dtv.c      |  345 +++++++++++++++++++++++++++++++++++++++++
 sys/dev/usb/auvitek_i2c.c      |    8 +-
 sys/dev/usb/auvitek_video.c    |   37 +--
 sys/dev/usb/auvitekvar.h       |   40 ++++-
 15 files changed, 1064 insertions(+), 67 deletions(-)

diffs (truncated from 1696 to 300 lines):

diff -r cf9921808013 -r 1bbeed0dde5c sys/dev/i2c/au8522.c
--- a/sys/dev/i2c/au8522.c      Sat Jul 09 15:00:08 2011 +0000
+++ b/sys/dev/i2c/au8522.c      Sat Jul 09 15:00:43 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: au8522.c,v 1.3 2011/05/26 23:42:05 jmcneill Exp $ */
+/* $NetBSD: au8522.c,v 1.4 2011/07/09 15:00:43 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2010 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: au8522.c,v 1.3 2011/05/26 23:42:05 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: au8522.c,v 1.4 2011/07/09 15:00:43 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -41,10 +41,13 @@
 #include <sys/kmem.h>
 #include <sys/module.h>
 
+#include <dev/dtv/dtvio.h>
+
 #include <dev/i2c/i2cvar.h>
 
 #include <dev/i2c/au8522reg.h>
 #include <dev/i2c/au8522var.h>
+#include <dev/i2c/au8522mod.h>
 
 static int     au8522_reset(struct au8522 *);
 static int     au8522_read_1(struct au8522 *, uint16_t, uint8_t *);
@@ -187,8 +190,31 @@
        return 0;
 }
 
+static int
+au8522_set_if(struct au8522 *au)
+{
+       uint8_t ifinit[3];
+       unsigned int n;
+
+       switch (au->if_freq) {
+       case 6000000:   /* 6MHz */
+               ifinit[0] = 0xfb;
+               ifinit[1] = 0x8e;
+               ifinit[2] = 0x39;
+               break;
+       default:
+               aprint_error_dev(au->parent, "au8522: unsupported if freq %dHz\n", au->if_freq);
+               return EINVAL;
+       }
+
+       for (n = 0; n < __arraycount(ifinit); n++)
+               au8522_write_1(au, 0x80b5 + n, ifinit[n]);
+
+       return 0;
+}
+
 struct au8522 *
-au8522_open(device_t parent, i2c_tag_t i2c, i2c_addr_t addr)
+au8522_open(device_t parent, i2c_tag_t i2c, i2c_addr_t addr, unsigned int if_freq)
 {
        struct au8522 *au;
 
@@ -198,6 +224,8 @@
        au->parent = parent;
        au->i2c = i2c;
        au->i2c_addr = addr;
+       au->current_modulation = -1;
+       au->if_freq = if_freq;
 
        if (au8522_reset(au))
                goto failed;
@@ -271,6 +299,90 @@
        }
 }
 
+int
+au8522_set_modulation(struct au8522 *au, fe_modulation_t modulation)
+{
+       const struct au8522_modulation_table *modtab = NULL;
+       size_t modtablen;
+       unsigned int n;
+
+       switch (modulation) {
+       case VSB_8:
+               modtab = au8522_modulation_8vsb;
+               modtablen = __arraycount(au8522_modulation_8vsb);
+               break;
+       case QAM_64:
+               modtab = au8522_modulation_qam64;
+               modtablen = __arraycount(au8522_modulation_qam64);
+               break;
+       case QAM_256:
+               modtab = au8522_modulation_qam256;
+               modtablen = __arraycount(au8522_modulation_qam256);
+               break;
+       default:
+               return EINVAL;
+       }
+
+       for (n = 0; n < modtablen; n++)
+               au8522_write_1(au, modtab[n].reg, modtab[n].val);
+
+       au8522_set_if(au);
+
+       au->current_modulation = modulation;
+
+       return 0;
+}
+
+void
+au8522_set_gate(struct au8522 *au, bool onoff)
+{
+       au8522_write_1(au, AU8522_REG_TUNERCTL, onoff ? AU8522_TUNERCTL_EN : 0);
+}
+
+fe_status_t
+au8522_get_dtv_status(struct au8522 *au)
+{
+       fe_status_t status = 0;
+       uint8_t val;
+
+       //printf("%s: current_modulation = %d\n", __func__,
+       //    au->current_modulation);
+
+       switch (au->current_modulation) {
+       case VSB_8:
+               if (au8522_read_1(au, 0x4088, &val))
+                       return 0;
+               if ((val & 0x03) == 0x03) {
+                       status |= FE_HAS_SIGNAL;
+                       status |= FE_HAS_CARRIER;
+                       status |= FE_HAS_VITERBI;
+               }
+               break;
+       case QAM_64:
+       case QAM_256:
+               if (au8522_read_1(au, 0x4541, &val))
+                       return 0;
+               if (val & 0x80) {
+                       status |= FE_HAS_VITERBI;
+               }
+               if (val & 0x20) {
+                       status |= FE_HAS_SIGNAL;
+                       status |= FE_HAS_CARRIER;
+               }
+               break;
+       default:
+               break;
+       }
+
+       if (status & FE_HAS_VITERBI) {
+               status |= FE_HAS_SYNC;
+               status |= FE_HAS_LOCK;
+       }
+
+       //printf("%s: status = 0x%x\n", __func__, status);
+       return status;
+}
+
 MODULE(MODULE_CLASS_DRIVER, au8522, NULL);
 
 static int
diff -r cf9921808013 -r 1bbeed0dde5c sys/dev/i2c/au8522mod.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/i2c/au8522mod.h   Sat Jul 09 15:00:43 2011 +0000
@@ -0,0 +1,41 @@
+/* $NetBSD: au8522mod.h,v 1.1 2011/07/09 15:00:43 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _AU8522MOD_H
+#define _AU8522MOD_H
+
+struct au8522_modulation_table {
+       uint16_t        reg;
+       uint8_t         val;
+};
+
+#include <dev/i2c/au8522mod_8vsb.h>
+#include <dev/i2c/au8522mod_qam64.h>
+#include <dev/i2c/au8522mod_qam256.h>
+
+#endif /* !_AU8522MOD_H */
diff -r cf9921808013 -r 1bbeed0dde5c sys/dev/i2c/au8522mod_8vsb.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/i2c/au8522mod_8vsb.h      Sat Jul 09 15:00:43 2011 +0000
@@ -0,0 +1,57 @@
+/* $NetBSD: au8522mod_8vsb.h,v 1.1 2011/07/09 15:00:43 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+static const struct au8522_modulation_table au8522_modulation_8vsb[] = {
+       { 0x8090, 0x84 },
+       { 0x4092, 0x11 },
+       { 0x2005, 0x00 },
+       { 0x8091, 0x80 },
+       { 0x80a3, 0x0c },
+       { 0x80a4, 0xe8 },
+       { 0x8081, 0xc4 },
+       { 0x80a5, 0x40 },
+       { 0x80a7, 0x40 },
+       { 0x80a6, 0x67 },
+       { 0x8262, 0x20 },
+       { 0x821c, 0x30 },
+       { 0x80d8, 0x1a },
+       { 0x8227, 0xa0 },
+       { 0x8121, 0xff },
+       { 0x80a8, 0xf0 },
+       { 0x80a9, 0x05 },
+       { 0x80aa, 0x77 },
+       { 0x80ab, 0xf0 },
+       { 0x80ac, 0x05 },
+       { 0x80ad, 0x77 },
+       { 0x80ae, 0x41 },
+       { 0x80af, 0x66 },
+       { 0x821b, 0xcc },
+       { 0x821d, 0x80 },
+       { 0x80a4, 0xe8 },
+       { 0x8231, 0x13 },
+};
diff -r cf9921808013 -r 1bbeed0dde5c sys/dev/i2c/au8522mod_qam256.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/i2c/au8522mod_qam256.h    Sat Jul 09 15:00:43 2011 +0000
@@ -0,0 +1,102 @@
+/* $NetBSD: au8522mod_qam256.h,v 1.1 2011/07/09 15:00:43 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE



Home | Main Index | Thread Index | Old Index