Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add Zarlink ZL10353 DVB demodulator (or as it is now know, I...
details: https://anonhg.NetBSD.org/src/rev/f53ad13470b5
branches: trunk
changeset: 768926:f53ad13470b5
user: jruoho <jruoho%NetBSD.org@localhost>
date: Mon Aug 29 11:14:15 2011 +0000
description:
Add Zarlink ZL10353 DVB demodulator (or as it is now know, Intel CE623x).
diffstat:
distrib/sets/lists/modules/md.amd64 | 4 +-
distrib/sets/lists/modules/md.i386 | 4 +-
sys/dev/i2c/zl10353.c | 663 ++++++++++++++++++++++++++++++++++++
sys/dev/i2c/zl10353reg.h | 124 ++++++
sys/dev/i2c/zl10353var.h | 56 +++
sys/modules/Makefile | 3 +-
sys/modules/zl10353/Makefile | 12 +
7 files changed, 863 insertions(+), 3 deletions(-)
diffs (truncated from 918 to 300 lines):
diff -r 85f54d153d58 -r f53ad13470b5 distrib/sets/lists/modules/md.amd64
--- a/distrib/sets/lists/modules/md.amd64 Mon Aug 29 11:07:38 2011 +0000
+++ b/distrib/sets/lists/modules/md.amd64 Mon Aug 29 11:14:15 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: md.amd64,v 1.29 2011/08/11 12:03:58 mbalmer Exp $
+# $NetBSD: md.amd64,v 1.30 2011/08/29 11:14:15 jruoho Exp $
./@MODULEDIR@/acpiacad base-kernel-modules kmod
./@MODULEDIR@/acpiacad/acpiacad.kmod base-kernel-modules kmod
./@MODULEDIR@/acpibat base-kernel-modules kmod
@@ -113,3 +113,5 @@
./@MODULEDIR@/xc3028/xc3028.kmod base-kernel-modules kmod
./@MODULEDIR@/xc5k base-kernel-modules kmod
./@MODULEDIR@/xc5k/xc5k.kmod base-kernel-modules kmod
+./@MODULEDIR@/zl10353 base-kernel-modules kmod
+./@MODULEDIR@/zl10353/zl10353.kmod base-kernel-modules kmod
diff -r 85f54d153d58 -r f53ad13470b5 distrib/sets/lists/modules/md.i386
--- a/distrib/sets/lists/modules/md.i386 Mon Aug 29 11:07:38 2011 +0000
+++ b/distrib/sets/lists/modules/md.i386 Mon Aug 29 11:14:15 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: md.i386,v 1.35 2011/08/28 16:19:08 jmcneill Exp $
+# $NetBSD: md.i386,v 1.36 2011/08/29 11:14:15 jruoho Exp $
./@MODULEDIR@/acpiacad base-kernel-modules kmod
./@MODULEDIR@/acpiacad/acpiacad.kmod base-kernel-modules kmod
./@MODULEDIR@/acpibat base-kernel-modules kmod
@@ -139,3 +139,5 @@
./@MODULEDIR@/xc3028/xc3028.kmod base-kernel-modules kmod
./@MODULEDIR@/xc5k base-kernel-modules kmod
./@MODULEDIR@/xc5k/xc5k.kmod base-kernel-modules kmod
+./@MODULEDIR@/zl10353 base-kernel-modules kmod
+./@MODULEDIR@/zl10353/zl10353.kmod base-kernel-modules kmod
diff -r 85f54d153d58 -r f53ad13470b5 sys/dev/i2c/zl10353.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/i2c/zl10353.c Mon Aug 29 11:14:15 2011 +0000
@@ -0,0 +1,663 @@
+/* $NetBSD */
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jukka Ruohonen.
+ *
+ * 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 AUTHOR 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 AUTHOR 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.
+ */
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: zl10353.c,v 1.1 2011/08/29 11:14:15 jruoho Exp $");
+
+#include <sys/param.h>
+#include <sys/kmem.h>
+#include <sys/module.h>
+
+#include <dev/dtv/dtvif.h>
+
+#include <dev/i2c/i2cvar.h>
+#include <dev/i2c/zl10353reg.h>
+#include <dev/i2c/zl10353var.h>
+
+/*
+ * Zarlink ZL10353 demodulator (now known as Intel CE623x).
+ *
+ * An incomplete datasheet:
+ *
+ * Intel Corporation: CE6230 - COFDM demodulator with
+ * USB interface for PC-TV. Data Sheet, Revision 1.1.
+ * March 29, 2007.
+ */
+
+static int zl10353_probe(struct zl10353 *);
+static int zl10353_read(struct zl10353 *, uint8_t, uint8_t *);
+static int zl10353_write(struct zl10353 *, uint8_t, uint8_t);
+static int zl10353_reset(struct zl10353 *, bool);
+static int zl10353_set_agc(struct zl10353 *,
+ const struct dvb_frontend_parameters *);
+static int zl10353_set_bw(struct zl10353 *, fe_bandwidth_t);
+static int zl10353_set_rate(struct zl10353 *);
+static int zl10353_set_freq(struct zl10353 *);
+static int zl10353_set_tps(struct zl10353 *,
+ const struct dvb_frontend_parameters *);
+static int zl10353_get_guard(fe_guard_interval_t, uint16_t *);
+static int zl10353_get_mode(fe_transmit_mode_t, uint16_t *);
+static int zl10353_get_fec(fe_code_rate_t, bool, uint16_t *);
+static int zl10353_get_modulation(fe_modulation_t, uint16_t *);
+static int zl10353_get_hier(fe_hierarchy_t, uint16_t *);
+
+struct zl10353 *
+zl10353_open(device_t parent, i2c_tag_t i2c, i2c_addr_t addr)
+{
+ struct zl10353 *zl;
+
+ zl = kmem_zalloc(sizeof(*zl), KM_SLEEP);
+
+ if (zl == NULL)
+ return NULL;
+
+ zl->zl_i2c = i2c;
+ zl->zl_i2c_addr = addr;
+ zl->zl_parent = parent;
+
+ zl->zl_freq = ZL10353_DEFAULT_INPUT_FREQ;
+ zl->zl_clock = ZL10353_DEFAULT_CLOCK_MHZ;
+
+ if (zl10353_reset(zl, true) != 0) {
+ zl10353_close(zl);
+ return NULL;
+ }
+
+ if (zl10353_probe(zl) != 0) {
+ zl10353_close(zl);
+ return NULL;
+ }
+
+ return zl;
+}
+
+void
+zl10353_close(struct zl10353 *zl)
+{
+ kmem_free(zl, sizeof(*zl));
+}
+
+static int
+zl10353_probe(struct zl10353 *zl)
+{
+ uint8_t val;
+ int rv;
+
+ if ((rv = zl10353_read(zl, ZL10353_REG_ID, &val)) != 0)
+ return rv;
+
+ switch (val) {
+
+ case ZL10353_ID_CE6230:
+ zl->zl_name = "Intel CE6230";
+ break;
+
+ case ZL10353_ID_CE6231:
+ zl->zl_name = "Intel CE6231";
+ break;
+
+ case ZL10353_ID_ZL10353:
+ zl->zl_name = "Zarlink ZL10353";
+ break;
+
+ default:
+ aprint_error_dev(zl->zl_parent, "unknown chip 0x%02x\n", val);
+ return ENOTSUP;
+ }
+
+ aprint_verbose_dev(zl->zl_parent, "found %s at i2c "
+ "addr 0x%02x\n", zl->zl_name, zl->zl_i2c_addr);
+
+ return 0;
+}
+
+static int
+zl10353_read(struct zl10353 *zl, uint8_t reg, uint8_t *valp)
+{
+ static const i2c_op_t op = I2C_OP_READ;
+ int rv;
+
+ if ((rv = iic_acquire_bus(zl->zl_i2c, 0)) != 0)
+ return rv;
+
+ rv = iic_exec(zl->zl_i2c, op, zl->zl_i2c_addr, ®, 1, valp, 1, 0);
+ iic_release_bus(zl->zl_i2c, 0);
+
+ return rv;
+}
+
+static int
+zl10353_write(struct zl10353 *zl, uint8_t reg, uint8_t val)
+{
+ static const i2c_op_t op = I2C_OP_WRITE;
+ const uint8_t cmd[2] = { reg, val };
+ int rv;
+
+ if ((rv = iic_acquire_bus(zl->zl_i2c, 0)) != 0)
+ return rv;
+
+ rv = iic_exec(zl->zl_i2c, op, zl->zl_i2c_addr, cmd, 2, NULL, 0, 0);
+ iic_release_bus(zl->zl_i2c, 0);
+
+ return rv;
+}
+
+static int
+zl10353_reset(struct zl10353 *zl, bool hard)
+{
+ size_t i = 0, len = 5;
+ int rv;
+
+ static const struct {
+ uint8_t reg;
+ uint8_t val;
+ } reset[] = {
+ { 0x50, 0x03 }, /* Hard */
+ { 0x03, 0x44 },
+ { 0x44, 0x46 },
+ { 0x46, 0x15 },
+ { 0x15, 0x0f },
+ { 0x55, 0x80 }, /* Soft */
+ { 0xea, 0x01 },
+ { 0xea, 0x00 },
+ };
+
+ if (hard != true) {
+ len = __arraycount(reset);
+ i = 5;
+ }
+
+ while (i < len) {
+
+ if ((rv = zl10353_write(zl, reset[i].reg, reset[i].val)) != 0)
+ return rv;
+ else {
+ delay(100);
+ }
+
+ i++;
+
+ }
+
+ return 0;
+}
+
+void
+zl10353_get_devinfo(struct dvb_frontend_info *fi)
+{
+
+ fi->type = FE_OFDM;
+
+ fi->frequency_min = 174000000;
+ fi->frequency_max = 862000000;
+
+ fi->frequency_tolerance = 0;
+ fi->frequency_stepsize = 166667;
+
+ fi->caps |= FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
+ FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_QPSK |
+ FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_RECOVER |
+ FE_CAN_MUTE_TS;
+
+ fi->caps |= FE_CAN_FEC_AUTO | FE_CAN_TRANSMISSION_MODE_AUTO |
+ FE_CAN_QAM_AUTO | FE_CAN_GUARD_INTERVAL_AUTO |
+ FE_CAN_HIERARCHY_AUTO;
+}
+
+int
+zl10353_set_params(struct zl10353 *zl,const struct dvb_frontend_parameters *fp)
+{
+ int rv;
+
+ /* 1. Soft reset. */
+ if ((rv = zl10353_reset(zl, false)) != 0)
+ return rv;
+
+ /* 2. Set AGC. */
+ if ((rv = zl10353_set_agc(zl, fp)) != 0)
+ return rv;
+
+ /* 3. Set bandwidth. */
+ if ((rv = zl10353_set_bw(zl, fp->u.ofdm.bandwidth)) != 0)
+ return rv;
+
+ /* 4. Set nominal rate. */
+ if ((rv = zl10353_set_rate(zl)) != 0)
+ return rv;
+
+ /* 5. Set input frequency. */
+ if ((rv = zl10353_set_freq(zl)) != 0)
+ return rv;
+
+ /* 6. Set TPS parameters. */
+ if ((rv = zl10353_set_tps(zl, fp)) != 0)
+ return rv;
+
+ return 0;
+}
+
Home |
Main Index |
Thread Index |
Old Index