From patchwork Sun Apr 16 17:35:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Frank_Sch=C3=A4fer?= X-Patchwork-Id: 9683047 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 339366038A for ; Sun, 16 Apr 2017 17:36:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2588327A98 for ; Sun, 16 Apr 2017 17:36:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A77F279E0; Sun, 16 Apr 2017 17:36:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3CCB27A98 for ; Sun, 16 Apr 2017 17:36:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756545AbdDPRgB (ORCPT ); Sun, 16 Apr 2017 13:36:01 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:32790 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756532AbdDPRf7 (ORCPT ); Sun, 16 Apr 2017 13:35:59 -0400 Received: by mail-wm0-f68.google.com with SMTP id o81so5886409wmb.0 for ; Sun, 16 Apr 2017 10:35:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Zck8FK1i1vBwzmOOCHKroSF5yWxIyLLyDQrCdOyF4gM=; b=gWl0vnPZC0QAtkklO1szK1Iov8Fdps9/Q9fNKuMwWeER7xAAEEZ4lhcitRuB5rMPo5 YxJWDifbrpMdt6OMcEYM5qRJ6E74UsaD2PaxoecOBxj3tBMQolSExxlT1eqQunm0j7dE jzt62KBWHhVyw8bIKY+o8PK6hqX7f7ZiSEOqEEhRvS9cRKrYkzQ+d0nVgFRvomtkepiF wAmW62csls77sJodPfzIVqaOszyuUV82IfM+3zxUbspMrEIhZKl724jkLfol9c9/3KKj 4kiveGdATUyYelnLstDi2S+1mU51LDkoNlGq8NWVC57KKhcRj4YPv3THg3bkVBf8RWNe RB4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Zck8FK1i1vBwzmOOCHKroSF5yWxIyLLyDQrCdOyF4gM=; b=oFmDYxcOVHut9xC0MLFcZTB4HB5ElLZIYzDNzLMuPteB9P1yH53LJFsbjOjDEBxRMM AzabTvFhWws6olgN15omcSYep7gjL4dwZkocW1wwbIjRoMQ5UKKVqg5Ej/7Rngu+r1go otwQ6KTssdsU+GV0sVcP+hDLlW+mPoGRQX6HGhJt9gRCKqfEitohmxdVoaEDzcp2A1E4 cVLh/YEvMbmxisrxW7WCCHKYyQs/K4whJuH/ObKWr79xpiwHetAbXB9wUh2al9d97Or5 /vbVfD8RqcVYTfJE9A92exIcsSPyEZEiU/BHlVkvQUgad+eJkRFas/mOR8yF+G3dV4bM PAZQ== X-Gm-Message-State: AN3rC/4Ca0cxySA8VD0eAyBziygMKGkoLY9S61Wm7EVLoDHbufcwE6v8 +HLgF+IunpcTWw== X-Received: by 10.28.88.2 with SMTP id m2mr6385999wmb.12.1492364158290; Sun, 16 Apr 2017 10:35:58 -0700 (PDT) Received: from Athlon64X2-5000.lan (ip-109-90-213-36.hsi11.unitymediagroup.de. [109.90.213.36]) by smtp.googlemail.com with ESMTPSA id l36sm8491642wrl.59.2017.04.16.10.35.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 16 Apr 2017 10:35:57 -0700 (PDT) From: =?UTF-8?q?Frank=20Sch=C3=A4fer?= To: linux-media@vger.kernel.org Cc: guennadi.liakhovetski@intel.com, hans.verkuil@cisco.com, =?UTF-8?q?Frank=20Sch=C3=A4fer?= Subject: [PATCH 2/7] ov2640: improve banding filter register definitions/documentation Date: Sun, 16 Apr 2017 19:35:41 +0200 Message-Id: <20170416173546.4317-3-fschaefer.oss@googlemail.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170416173546.4317-1-fschaefer.oss@googlemail.com> References: <20170416173546.4317-1-fschaefer.oss@googlemail.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP - add missing initialisation of sensor register COM25 (2 MSBs of banding filter AEC values) - add macros for setting the banding filter AEC values - add definitions for sensor register 0x5a, which is documented in Omnivisions software application notes Signed-off-by: Frank Schäfer --- drivers/media/i2c/ov2640.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/ov2640.c b/drivers/media/i2c/ov2640.c index df9f6c7a929c..fd1b215b6dec 100644 --- a/drivers/media/i2c/ov2640.c +++ b/drivers/media/i2c/ov2640.c @@ -248,8 +248,19 @@ #define ZOOMS 0x49 /* Zoom: Vertical start point */ #define COM22 0x4B /* Flash light control */ #define COM25 0x4E /* For Banding operations */ +#define COM25_50HZ_BANDING_AEC_MSBS_MASK 0xC0 /* 50Hz Bd. AEC 2 MSBs */ +#define COM25_60HZ_BANDING_AEC_MSBS_MASK 0x30 /* 60Hz Bd. AEC 2 MSBs */ +#define COM25_50HZ_BANDING_AEC_MSBS_SET(x) VAL_SET(x, 0x3, 8, 6) +#define COM25_60HZ_BANDING_AEC_MSBS_SET(x) VAL_SET(x, 0x3, 8, 4) #define BD50 0x4F /* 50Hz Banding AEC 8 LSBs */ +#define BD50_50HZ_BANDING_AEC_LSBS_SET(x) VAL_SET(x, 0xFF, 0, 0) #define BD60 0x50 /* 60Hz Banding AEC 8 LSBs */ +#define BD60_60HZ_BANDING_AEC_LSBS_SET(x) VAL_SET(x, 0xFF, 0, 0) +#define REG5A 0x5A /* 50/60Hz Banding Maximum AEC Step */ +#define BD50_MAX_AEC_STEP_MASK 0xF0 /* 50Hz Banding Max. AEC Step */ +#define BD60_MAX_AEC_STEP_MASK 0x0F /* 60Hz Banding Max. AEC Step */ +#define BD50_MAX_AEC_STEP_SET(x) VAL_SET((x - 1), 0x0F, 0, 4) +#define BD60_MAX_AEC_STEP_SET(x) VAL_SET((x - 1), 0x0F, 0, 0) #define REG5D 0x5D /* AVGsel[7:0], 16-zone average weight option */ #define REG5E 0x5E /* AVGsel[15:8], 16-zone average weight option */ #define REG5F 0x5F /* AVGsel[23:16], 16-zone average weight option */ @@ -356,9 +367,12 @@ static const struct regval_list ov2640_init_regs[] = { { 0x73, 0xc1 }, { 0x3d, 0x34 }, { COM7, COM7_RES_UXGA | COM7_ZOOM_EN }, - { 0x5a, 0x57 }, - { BD50, 0xbb }, - { BD60, 0x9c }, + { REG5A, BD50_MAX_AEC_STEP_SET(6) + | BD60_MAX_AEC_STEP_SET(8) }, /* 0x57 */ + { COM25, COM25_50HZ_BANDING_AEC_MSBS_SET(0x0bb) + | COM25_60HZ_BANDING_AEC_MSBS_SET(0x09c) }, /* 0x00 */ + { BD50, BD50_50HZ_BANDING_AEC_LSBS_SET(0x0bb) }, /* 0xbb */ + { BD60, BD60_60HZ_BANDING_AEC_LSBS_SET(0x09c) }, /* 0x9c */ { BANK_SEL, BANK_SEL_DSP }, { 0xe5, 0x7f }, { MC_BIST, MC_BIST_RESET | MC_BIST_BOOT_ROM_SEL },