From patchwork Tue May 18 07:30:11 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitri Belimov X-Patchwork-Id: 3416 Return-path: Envelope-to: mchehab@infradead.org Delivery-date: Tue, 18 May 2010 07:29:57 +0000 Received: from bombadil.infradead.org [18.85.46.34] by pedra with IMAP (fetchmail-6.3.6) for (single-drop); Tue, 18 May 2010 04:30:22 -0300 (BRT) Received: from vger.kernel.org ([209.132.180.67]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1OEHFV-0003IN-Jm; Tue, 18 May 2010 07:29:57 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752490Ab0ERH3z (ORCPT + 1 other); Tue, 18 May 2010 03:29:55 -0400 Received: from mail-fx0-f46.google.com ([209.85.161.46]:35873 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752189Ab0ERH3y (ORCPT ); Tue, 18 May 2010 03:29:54 -0400 Received: by fxm10 with SMTP id 10so709270fxm.19 for ; Tue, 18 May 2010 00:29:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:subject :message-id:x-mailer:mime-version:content-type; bh=QJslqBJ2napO/IkNbRu6ir5Gd3XokWG3wRYI+tzBPNA=; b=oz+tGei8+CRyCo7lbrVA2EOEg/LTYYNDaxp8UfmGtUsp5mROKal5R+LZtg+oO3K6q8 Du/JLNasGGkmJKSI3NCxZRU7MlkISR//zg79bJWnj70O4AtSFtN6wZ6v8Ckzu6MRwAGr ZlCXoTOl1rPxiJqbc+4DcnBP4ryzKby7l77gk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:subject:message-id:x-mailer:mime-version:content-type; b=vFtkY5vg2D6Sq1nb/+VBXp3UGdzvPAUrLDaGTlT+tNV1eZK91DVTvPEkGZLMohLiHP ZWatPZUI9ovvm4LhYAb4jK+FMsLfvWaiMjyx+RDl5BL0URYNuRvzu+chMNy5Oo83TK8u 6GOt8xh9smXj+Nm6cyn5w4OtnzPCmflIAXDYY= Received: by 10.87.19.37 with SMTP id w37mr10265379fgi.25.1274167792867; Tue, 18 May 2010 00:29:52 -0700 (PDT) Received: from glory.loctelecom.ru (ns2.openhardware.ru [84.19.183.172]) by mx.google.com with ESMTPS id d6sm10762980fga.13.2010.05.18.00.29.50 (version=SSLv3 cipher=RC4-MD5); Tue, 18 May 2010 00:29:52 -0700 (PDT) Date: Tue, 18 May 2010 17:30:11 +1000 From: Dmitri Belimov To: Linux Media Mailing List , Stefan Ringel , Mauro Carvalho Chehab , Bee Hock Goh , Devin Heitmueller Subject: [PATCH] xc5000, rework xc_write_reg Message-ID: <20100518173011.5d9c7f2c@glory.loctelecom.ru> X-Mailer: Claws Mail 3.5.0 (GTK+ 2.16.1; i486-pc-linux-gnu) Mime-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Hi Rework xc_write_reg function for correct read register of the xc5000. It is very useful for tm6000. Tested for tm6000 and for saa7134 works well. Signed-off-by: Beholder Intl. Ltd. Dmitry Belimov With my best regards, Dmitry. Acked-by: Devin Heitmueller diff -r 8f5129efe974 linux/drivers/media/common/tuners/xc5000.c --- a/linux/drivers/media/common/tuners/xc5000.c Sun May 16 18:48:01 2010 -0300 +++ b/linux/drivers/media/common/tuners/xc5000.c Tue May 18 11:14:55 2010 +1000 @@ -232,6 +232,26 @@ return 0; } +static int xc5000_readreg(struct xc5000_priv *priv, u16 reg, u16 *val) +{ + u8 buf[2] = { reg >> 8, reg & 0xff }; + u8 bval[2] = { 0, 0 }; + struct i2c_msg msg[2] = { + { .addr = priv->i2c_props.addr, + .flags = 0, .buf = &buf[0], .len = 2 }, + { .addr = priv->i2c_props.addr, + .flags = I2C_M_RD, .buf = &bval[0], .len = 2 }, + }; + + if (i2c_transfer(priv->i2c_props.adap, msg, 2) != 2) { + printk(KERN_WARNING "xc5000: I2C read failed\n"); + return -EREMOTEIO; + } + + *val = (bval[0] << 8) | bval[1]; + return XC_RESULT_SUCCESS; +} + static void xc_wait(int wait_ms) { msleep(wait_ms); @@ -275,20 +295,14 @@ if (result == XC_RESULT_SUCCESS) { /* wait for busy flag to clear */ while ((WatchDogTimer > 0) && (result == XC_RESULT_SUCCESS)) { - buf[0] = 0; - buf[1] = XREG_BUSY; - - result = xc_send_i2c_data(priv, buf, 2); + result = xc5000_readreg(priv, XREG_BUSY, buf); if (result == XC_RESULT_SUCCESS) { - result = xc_read_i2c_data(priv, buf, 2); - if (result == XC_RESULT_SUCCESS) { - if ((buf[0] == 0) && (buf[1] == 0)) { - /* busy flag cleared */ + if ((buf[0] == 0) && (buf[1] == 0)) { + /* busy flag cleared */ break; - } else { - xc_wait(5); /* wait 5 ms */ - WatchDogTimer--; - } + } else { + xc_wait(5); /* wait 5 ms */ + WatchDogTimer--; } } } @@ -534,25 +548,6 @@ return found; } -static int xc5000_readreg(struct xc5000_priv *priv, u16 reg, u16 *val) -{ - u8 buf[2] = { reg >> 8, reg & 0xff }; - u8 bval[2] = { 0, 0 }; - struct i2c_msg msg[2] = { - { .addr = priv->i2c_props.addr, - .flags = 0, .buf = &buf[0], .len = 2 }, - { .addr = priv->i2c_props.addr, - .flags = I2C_M_RD, .buf = &bval[0], .len = 2 }, - }; - - if (i2c_transfer(priv->i2c_props.adap, msg, 2) != 2) { - printk(KERN_WARNING "xc5000: I2C read failed\n"); - return -EREMOTEIO; - } - - *val = (bval[0] << 8) | bval[1]; - return XC_RESULT_SUCCESS; -} static int xc5000_fwupload(struct dvb_frontend *fe) { Signed-off-by: Beholder Intl. Ltd. Dmitry Belimov