From patchwork Tue Nov 3 23:10:17 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: HoP X-Patchwork-Id: 57399 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nA3NAM1s022652 for ; Tue, 3 Nov 2009 23:10:22 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751714AbZKCXKP (ORCPT ); Tue, 3 Nov 2009 18:10:15 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751655AbZKCXKP (ORCPT ); Tue, 3 Nov 2009 18:10:15 -0500 Received: from mail-bw0-f227.google.com ([209.85.218.227]:59980 "EHLO mail-bw0-f227.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751165AbZKCXKN (ORCPT ); Tue, 3 Nov 2009 18:10:13 -0500 Received: by bwz27 with SMTP id 27so8209181bwz.21 for ; Tue, 03 Nov 2009 15:10:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=fBoKOh7+O8rA1nUN7//b8NHYO48dbpPWL3JGdgp0O2M=; b=a0MXOeHYCBxah5v0mWlQyzWmR84zbHEIauyETG8cDgoBlUrRJ2gsYDZFz4YDL5T3YY wIY/oeb9UCeBDNgaFvHVLQSW+K27MhxAJHqu2/UVQsGAfafP/nk5jDU1+dnsXHsibW8v yPvnCA9ip3IZlHG21P48V8VJ+fnx6j/lGerE8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=rMPWiJXjIGbuxVAwOlTfLZhcgi5HRJxafL5n4dp4cjVq+dqq1PPXNDTUAN3gVWzqRp r5pvt2kUd3ogbJ0YyLhq39mHBoSiLd11q0ZhxlHan0bCH9Ab2AxzZG4DJOeG0Wu/O+tA Mjx7h4ASXqBn47aBnmekZEhCBoplpGId+bQZE= MIME-Version: 1.0 Received: by 10.239.181.161 with SMTP id m33mr84204hbg.18.1257289817141; Tue, 03 Nov 2009 15:10:17 -0800 (PST) In-Reply-To: <4AEC08F0.70205@redhat.com> References: <846899810910241711s6fb5939fq3a693a92a2a76310@mail.gmail.com> <4AEC08F0.70205@redhat.com> Date: Wed, 4 Nov 2009 00:10:17 +0100 Message-ID: <846899810911031510p252dadfeu3fa058c7b8733270@mail.gmail.com> Subject: Re: [PATCH] isl6421.c - added optional features: tone control and temporary diseqc overcurrent From: HoP To: Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, Ales Jurik Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org diff -r 9d9bc92d7c33 drivers/media/dvb/frontends/isl6421.c --- a/drivers/media/dvb/frontends/isl6421.c Sat Sep 19 12:48:44 2009 +0200 +++ b/drivers/media/dvb/frontends/isl6421.c Tue Nov 03 23:23:05 2009 +0100 @@ -3,6 +3,9 @@ * * Copyright (C) 2006 Andrew de Quincey * Copyright (C) 2006 Oliver Endriss + * Copyright (C) 2009 Ales Jurik and Jan Petrous (added optional 22k tone + * support and temporary diseqc overcurrent enable until + * next command - set voltage or tone) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -35,12 +38,23 @@ #include "dvb_frontend.h" #include "isl6421.h" +static int tone_control; +module_param(tone_control, int, S_IRUGO); +MODULE_PARM_DESC(tone_control, "Set ISL6421 to control 22kHz tone"); + +static int overcurrent_enable; +module_param(overcurrent_enable, int, S_IRUGO); +MODULE_PARM_DESC(overcurrent_enable, "Set ISL6421 to temporary enable " + "overcurrent when diseqc command is active"); + struct isl6421 { u8 config; u8 override_or; u8 override_and; struct i2c_adapter *i2c; u8 i2c_addr; + int (*diseqc_send_master_cmd_orig)(struct dvb_frontend *fe, + struct dvb_diseqc_master_cmd *cmd); }; static int isl6421_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) @@ -60,6 +74,55 @@ static int isl6421_set_voltage(struct dv break; case SEC_VOLTAGE_18: isl6421->config |= (ISL6421_EN1 | ISL6421_VSEL1); + break; + default: + return -EINVAL; + }; + + isl6421->config |= isl6421->override_or; + isl6421->config &= isl6421->override_and; + + return (i2c_transfer(isl6421->i2c, &msg, 1) == 1) ? 0 : -EIO; +} + +static int isl6421_send_diseqc(struct dvb_frontend *fe, + struct dvb_diseqc_master_cmd *cmd) +{ + struct isl6421 *isl6421 = (struct isl6421 *) fe->sec_priv; + struct i2c_msg msg = { .addr = isl6421->i2c_addr, .flags = 0, + .buf = &isl6421->config, + .len = sizeof(isl6421->config) }; + + isl6421->config |= ISL6421_DCL; + + isl6421->config |= isl6421->override_or; + isl6421->config &= isl6421->override_and; + + if (i2c_transfer(isl6421->i2c, &msg, 1) != 1) + return -EIO; + + isl6421->config &= ~ISL6421_DCL; + + return isl6421->diseqc_send_master_cmd_orig(fe, cmd); +} + +static int isl6421_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone) +{ + struct isl6421 *isl6421 = (struct isl6421 *) fe->sec_priv; + struct i2c_msg msg = { .addr = isl6421->i2c_addr, .flags = 0, + .buf = &isl6421->config, + .len = sizeof(isl6421->config) }; + + isl6421->config &= ~(ISL6421_ENT1); + + printk(KERN_INFO "%s: %s\n", __func__, ((tone == SEC_TONE_OFF) ? + "Off" : "On")); + + switch (tone) { + case SEC_TONE_ON: + isl6421->config |= ISL6421_ENT1; + break; + case SEC_TONE_OFF: break; default: return -EINVAL; @@ -91,18 +154,26 @@ static int isl6421_enable_high_lnb_volta static void isl6421_release(struct dvb_frontend *fe) { + struct isl6421 *isl6421 = (struct isl6421 *) fe->sec_priv; + /* power off */ isl6421_set_voltage(fe, SEC_VOLTAGE_OFF); + + if (overcurrent_enable) + fe->ops.diseqc_send_master_cmd = + isl6421->diseqc_send_master_cmd_orig; /* free */ kfree(fe->sec_priv); fe->sec_priv = NULL; } -struct dvb_frontend *isl6421_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 i2c_addr, - u8 override_set, u8 override_clear) +struct dvb_frontend *isl6421_attach(struct dvb_frontend *fe, + struct i2c_adapter *i2c, u8 i2c_addr, u8 override_set, + u8 override_clear) { struct isl6421 *isl6421 = kmalloc(sizeof(struct isl6421), GFP_KERNEL); + if (!isl6421) return NULL; @@ -131,6 +202,33 @@ struct dvb_frontend *isl6421_attach(stru /* override frontend ops */ fe->ops.set_voltage = isl6421_set_voltage; fe->ops.enable_high_lnb_voltage = isl6421_enable_high_lnb_voltage; + if (tone_control) + fe->ops.set_tone = isl6421_set_tone; + + printk(KERN_INFO "ISL6421 attached on addr=%x\n", i2c_addr); + + if (overcurrent_enable) { + if ((override_set & ISL6421_DCL) || + (override_clear & ISL6421_DCL)) { + /* there is no sense to use overcurrent_enable + * with DCL bit set in any override byte */ + if (override_set & ISL6421_DCL) + printk(KERN_WARNING "ISL6421 overcurrent_enable" + " with DCL bit in override_set," + " overcurrent_enable ignored\n"); + if (override_clear & ISL6421_DCL) + printk(KERN_WARNING "ISL6421 overcurrent_enable" + " with DCL bit in override_clear," + " overcurrent_enable ignored\n"); + } else { + printk(KERN_WARNING "ISL6421 overcurrent_enable " + " activated. WARNING: it can be " + " dangerous for your hardware!"); + isl6421->diseqc_send_master_cmd_orig = + fe->ops.diseqc_send_master_cmd; + fe->ops.diseqc_send_master_cmd = isl6421_send_diseqc; + } + } return fe; }