From patchwork Wed Sep 26 09:47:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martin X-Patchwork-Id: 1508731 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 23D1C3FC71 for ; Wed, 26 Sep 2012 09:48:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754324Ab2IZJsU (ORCPT ); Wed, 26 Sep 2012 05:48:20 -0400 Received: from mail-wi0-f178.google.com ([209.85.212.178]:47851 "EHLO mail-wi0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753358Ab2IZJsT (ORCPT ); Wed, 26 Sep 2012 05:48:19 -0400 Received: by mail-wi0-f178.google.com with SMTP id hr7so481354wib.1 for ; Wed, 26 Sep 2012 02:48:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=/UQnnDuZs1qX33vaqjOvpwRcoPdJ7VCJh9cnMMsiCHw=; b=OGTuMcvpS0FG9q4cx+wPtv77SSCG/tEgT5xYqM5r9Z9mzHqMPbSUBMr9L87Hrn7ZHi DNKi9A5ubBZl8KA0kTlj4QP5X9rBjaPVPmSo1DwGmJHWbtviuhfbjhmTQ9IIOQUJT75F KvwiBlhxTZ2Fgcjm3pW/pxWWiSMnboB0/ebRBlK6E7GQ+CeJTjZzm4YaAX/UDkW3mlsP 6NmqJ+n23YoRJXUg+0PYf1do6IqlqGI+4cewErSNVaXn8AdHFsvsXJtsM35T1bOOGopX +F2uFezFYpmReiRMyaTh5s7RqKChQlr44y6OduCqB08Cn8sP/0oH0z3T4EkfFmBN04va 5cgw== Received: by 10.180.79.2 with SMTP id f2mr28338963wix.2.1348652898944; Wed, 26 Sep 2012 02:48:18 -0700 (PDT) Received: from piscis.vsilicon.net (122.251.106.212.dynamic.jazztel.es. [212.106.251.122]) by mx.google.com with ESMTPS id bn7sm5826230wib.8.2012.09.26.02.48.17 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 26 Sep 2012 02:48:18 -0700 (PDT) From: Javier Martin To: linux-media@vger.kernel.org Cc: corbet@lwn.net, mchehab@infradead.org, hverkuil@xs4all.nl, Javier Martin Subject: [PATCH 4/5] media: ov7670: add possibility to bypass pll for ov7675. Date: Wed, 26 Sep 2012 11:47:56 +0200 Message-Id: <1348652877-25816-5-git-send-email-javier.martin@vista-silicon.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1348652877-25816-1-git-send-email-javier.martin@vista-silicon.com> References: <1348652877-25816-1-git-send-email-javier.martin@vista-silicon.com> X-Gm-Message-State: ALoCoQlJ7AHTwzuGbIgPngtNWq52yE2+/43a8IAXuB2LWIfdn04B8DQfZXEUwX8DbN9SUiQ/G9W/ Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Signed-off-by: Javier Martin Acked-by: Jonathan Corbet --- drivers/media/i2c/ov7670.c | 24 ++++++++++++++++++++++-- include/media/ov7670.h | 1 + 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c index 175fbfc..54fb535 100644 --- a/drivers/media/i2c/ov7670.c +++ b/drivers/media/i2c/ov7670.c @@ -210,6 +210,7 @@ struct ov7670_info { int clock_speed; /* External clock speed (MHz) */ u8 clkrc; /* Clock divider value */ bool use_smbus; /* Use smbus I/O instead of I2C */ + bool pll_bypass; enum ov7670_model model; }; @@ -778,7 +779,12 @@ static void ov7670_get_framerate(struct v4l2_subdev *sd, { struct ov7670_info *info = to_state(sd); u32 clkrc = info->clkrc; - u32 pll_factor = PLL_FACTOR; + int pll_factor; + + if (info->pll_bypass) + pll_factor = 1; + else + pll_factor = PLL_FACTOR; clkrc++; if (info->fmt->mbus_code == V4L2_MBUS_FMT_SBGGR8_1X8) @@ -794,7 +800,7 @@ static int ov7670_set_framerate(struct v4l2_subdev *sd, { struct ov7670_info *info = to_state(sd); u32 clkrc; - u32 pll_factor = PLL_FACTOR; + int pll_factor; int ret; /* @@ -804,6 +810,16 @@ static int ov7670_set_framerate(struct v4l2_subdev *sd, * pixclk = clock_speed / (clkrc + 1) * PLLfactor * */ + if (info->pll_bypass) { + pll_factor = 1; + ret = ov7670_write(sd, REG_DBLV, DBLV_BYPASS); + } else { + pll_factor = PLL_FACTOR; + ret = ov7670_write(sd, REG_DBLV, DBLV_X4); + } + if (ret < 0) + return ret; + if (tpf->numerator == 0 || tpf->denominator == 0) { clkrc = 0; } else { @@ -831,6 +847,7 @@ static int ov7670_set_framerate(struct v4l2_subdev *sd, ret = ov7670_write(sd, REG_CLKRC, info->clkrc); if (ret < 0) return ret; + return ov7670_write(sd, REG_DBLV, DBLV_X4); } @@ -1689,6 +1706,9 @@ static int ov7670_probe(struct i2c_client *client, if (config->clock_speed) info->clock_speed = config->clock_speed; + + if (config->pll_bypass && id->driver_data != MODEL_OV7670) + info->pll_bypass = true; } /* Make sure it's an ov7670 */ diff --git a/include/media/ov7670.h b/include/media/ov7670.h index b133bc1..a68c8bb 100644 --- a/include/media/ov7670.h +++ b/include/media/ov7670.h @@ -15,6 +15,7 @@ struct ov7670_config { int min_height; /* Filter out smaller sizes */ int clock_speed; /* External clock speed (MHz) */ bool use_smbus; /* Use smbus I/O instead of I2C */ + bool pll_bypass; /* Choose whether to bypass the PLL */ }; #endif