From patchwork Wed Oct 5 15:27:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 612705 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1B2DC433FE for ; Wed, 5 Oct 2022 15:28:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230451AbiJEP2v (ORCPT ); Wed, 5 Oct 2022 11:28:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230435AbiJEP2u (ORCPT ); Wed, 5 Oct 2022 11:28:50 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25E0D1EEE3 for ; Wed, 5 Oct 2022 08:28:49 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 130-20020a1c0288000000b003b494ffc00bso1244105wmc.0 for ; Wed, 05 Oct 2022 08:28:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=u9Nk/5KWVZuhK9fPLbCCMVzm/c2ZpA/A5nbN8kga8jI=; b=G6IagFV61ktaTOX3dqVIxo90pmDTlxiZOnCbaxq23g5nk6frso3gsxRlQ58IQIgLoE ngUUPoI/nktXyf/8IqZ26mETfUbZVpfC9hT5nlJ1fZlWgKokOtUpZuzbNVpF+pZ+vU1w NJsgzj2pZiMutiRIM5rUrVxy/GvDh99iKC5Yne5fkfOQpmhtQv4eMyYprn559/JuOQTf S7VjgDWz7uJnOOr71QRLhI4lA/ECIvCEnKuKsnCrqzrlelztlKLpKMDOvn3LUUdikWhI +J67W8al4ffhvDPnGupUfK40h/rU05ROZzy7XbHs6K1ET7iZ1dr938wdtjjIANhV1YBm 3CPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=u9Nk/5KWVZuhK9fPLbCCMVzm/c2ZpA/A5nbN8kga8jI=; b=UQx1h8rHKV+neUs0tSa7CbeSETlNPcDbGhgy1z/xWGXWjJJKzhym+qlIJNi39aRYzl yV6uLD+GlZZsXAVy4ounWea6m1kl4A8f2s5JVBAxaX8B+ky2uaIkzp7fqn39U+sgE0yP b+iDFOe+zSU0nv+qClsKM2jjKazeqomRNCGG8DsHhxSlyHc9BdNEhaotM7FZDj2587uB j16B7sY5glIWJnSb0gfEBT0A+B+V9t8/igVUS1hc+5NxuZlNYJGDR9aww81Sm6F49vZg D3ixGhJwECYhvZHB7APgDdws2i/pdBKCdaxHxjiBsQSni2xB7DXD5z3Ugb23fMDa8ot6 K3pA== X-Gm-Message-State: ACrzQf2KqqY8E3PK7EDlKMwZMJ6NEkVGHKzr3POD1cBHu6b9VqDKMykz qKxZSKwXmcKTB44kYrCBxZRGtQ== X-Google-Smtp-Source: AMsMyM48VqAhvqEa0Opb/N7ou1XWBtZNvb78zByVq6kI6azMXc/C6F0TWwojA4U7+DmN0zuWCO1oZQ== X-Received: by 2002:a05:600c:1909:b0:3b4:aa30:40df with SMTP id j9-20020a05600c190900b003b4aa3040dfmr3730969wmq.205.1664983727755; Wed, 05 Oct 2022 08:28:47 -0700 (PDT) Received: from dave-Ubuntu2204.pitowers.org ([93.93.133.154]) by smtp.googlemail.com with ESMTPSA id y14-20020adfe6ce000000b0022c96d3b6f2sm19747237wrm.54.2022.10.05.08.28.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 08:28:46 -0700 (PDT) From: Dave Stevenson To: paul.j.murphy@intel.com, daniele.alessandrelli@intel.com, linux-media@vger.kernel.org Cc: Dave Stevenson Subject: [PATCH 02/16] media: i2c: ov9282: Split registers into common and mode specific Date: Wed, 5 Oct 2022 16:27:55 +0100 Message-Id: <20221005152809.3785786-3-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221005152809.3785786-1-dave.stevenson@raspberrypi.com> References: <20221005152809.3785786-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Currently only one mode is supported, so all registers were dropped in one list. In preparation for adding more modes, split out the common registers from those which configure the mode. Signed-off-by: Dave Stevenson --- drivers/media/i2c/ov9282.c | 77 +++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 30 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index 2c13bcd59c2a..9842080cf66f 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -157,8 +157,8 @@ static const s64 link_freq[] = { OV9282_LINK_FREQ, }; -/* Sensor mode registers */ -static const struct ov9282_reg mode_1280x720_regs[] = { +/* Common registers */ +static const struct ov9282_reg common_regs[] = { {0x0302, 0x32}, {0x030d, 0x50}, {0x030e, 0x02}, @@ -189,13 +189,49 @@ static const struct ov9282_reg mode_1280x720_regs[] = { {0x372d, 0x22}, {0x3731, 0x80}, {0x3732, 0x30}, - {0x3778, 0x00}, {0x377d, 0x22}, {0x3788, 0x02}, {0x3789, 0xa4}, {0x378a, 0x00}, {0x378b, 0x4a}, {0x3799, 0x20}, + {0x3881, 0x42}, + {0x38a8, 0x02}, + {0x38a9, 0x80}, + {0x38b1, 0x00}, + {0x38c4, 0x00}, + {0x38c5, 0xc0}, + {0x38c6, 0x04}, + {0x38c7, 0x80}, + {0x3920, 0xff}, + {0x4010, 0x40}, + {0x4043, 0x40}, + {0x4307, 0x30}, + {0x4317, 0x00}, + {0x4501, 0x00}, + {0x450a, 0x08}, + {0x4601, 0x04}, + {0x470f, 0x00}, + {0x4f07, 0x00}, + {0x4800, 0x20}, + {0x5000, 0x9f}, + {0x5001, 0x00}, + {0x5e00, 0x00}, + {0x5d00, 0x07}, + {0x5d01, 0x00}, + {0x0101, 0x01}, + {0x1000, 0x03}, + {0x5a08, 0x84}, +}; + +struct ov9282_reg_list common_regs_list = { + .num_of_regs = ARRAY_SIZE(common_regs), + .regs = common_regs, +}; + +/* Sensor mode registers */ +static const struct ov9282_reg mode_1280x720_regs[] = { + {0x3778, 0x00}, {0x3800, 0x00}, {0x3801, 0x00}, {0x3802, 0x00}, @@ -218,40 +254,13 @@ static const struct ov9282_reg mode_1280x720_regs[] = { {0x3815, 0x11}, {0x3820, 0x3c}, {0x3821, 0x84}, - {0x3881, 0x42}, - {0x38a8, 0x02}, - {0x38a9, 0x80}, - {0x38b1, 0x00}, - {0x38c4, 0x00}, - {0x38c5, 0xc0}, - {0x38c6, 0x04}, - {0x38c7, 0x80}, - {0x3920, 0xff}, {0x4003, 0x40}, {0x4008, 0x02}, {0x4009, 0x05}, {0x400c, 0x00}, {0x400d, 0x03}, - {0x4010, 0x40}, - {0x4043, 0x40}, - {0x4307, 0x30}, - {0x4317, 0x00}, - {0x4501, 0x00}, {0x4507, 0x00}, {0x4509, 0x80}, - {0x450a, 0x08}, - {0x4601, 0x04}, - {0x470f, 0x00}, - {0x4f07, 0x00}, - {0x4800, 0x20}, - {0x5000, 0x9f}, - {0x5001, 0x00}, - {0x5e00, 0x00}, - {0x5d00, 0x07}, - {0x5d01, 0x00}, - {0x0101, 0x01}, - {0x1000, 0x03}, - {0x5a08, 0x84}, }; /* Supported sensor mode configurations */ @@ -663,6 +672,14 @@ static int ov9282_start_streaming(struct ov9282 *ov9282) const struct ov9282_reg_list *reg_list; int ret; + /* Write common registers */ + ret = ov9282_write_regs(ov9282, common_regs_list.regs, + common_regs_list.num_of_regs); + if (ret) { + dev_err(ov9282->dev, "fail to write common registers"); + return ret; + } + /* Write sensor mode registers */ reg_list = &ov9282->cur_mode->reg_list; ret = ov9282_write_regs(ov9282, reg_list->regs, reg_list->num_of_regs); From patchwork Wed Oct 5 15:27:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 612704 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FD74C433FE for ; Wed, 5 Oct 2022 15:28:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230457AbiJEP2y (ORCPT ); Wed, 5 Oct 2022 11:28:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229888AbiJEP2x (ORCPT ); Wed, 5 Oct 2022 11:28:53 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3074057899 for ; Wed, 5 Oct 2022 08:28:51 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id u10so26366396wrq.2 for ; Wed, 05 Oct 2022 08:28:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=y3WPiNu5a72VVLHY7+nk24MwdU+a1fkv2slymEUonvs=; b=DXPMptmXpBWr0T81d2qzoVjWfLmgIAFeiVvzM8QWu7GBXBPLCz5Z/hx1/oujyHssbc 9GCSR4Ne0EvkqNWBwUJWskkC5kaMk7EqZtjkS5vqrHJ6bmqYrl5FNBQX/h3nu/TLiTgF jMKsTBZWhN9UuRbd3lmrlwUwSBBwDGOr6PUTcnGibSEMvMiehfIJ5Pdi0LsNiZAJmaN7 RaE87Ek6+DwIHlbA+Y/F4o6haE9cIFCkXDJw0i5NgXryhGtkGWZqH9eKho8IG6J2cEAk 9fdifi4rYc96gsFKR+kHhbfSu7apUYp5JZI+wgC1XzeO9ZOupHlgEn//7SbCQqWGPE7E KGyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=y3WPiNu5a72VVLHY7+nk24MwdU+a1fkv2slymEUonvs=; b=raCb7Es3FCJEg9soQU0RMmIEboA5LEoNkMCiqQkZtCt9Ud4ACMjbGx9RobzQIlnyEA Y1h+DF/NHR13SNreMucvjZhKln8H7M6/5cWmMdK80utg07RVV+oOd+ikaIBvkz7hB7A3 fvcRniufYpHw5isw5oa3l7agMtZo8MSmBGXmTqhStzSOwHIb78qnDgRp4TGVJl0TyxT6 5Vsi3KrCZFYshPwaTfPvqSoLxFlWGQEbLckoWb/qkW09S+AiCZsOK97HnOcrr/s1D1GM vNOpX0ScIEa/P5qCdfA2nVvejday+xPdUMxF9uGiJ3C521vNkXFdzszWmAOf6NJ3XHag BK9g== X-Gm-Message-State: ACrzQf15Pw0oDSQ3sRZraO/2MXTJUV9/jrTynxA+rPgNBv9g4SlTVg8l RRdYnpSZI6DOmR0G4O6S2zpqN2O8YFdbkw== X-Google-Smtp-Source: AMsMyM7owYbO/RjyLRLlfG4LVO395pk7axHDBWaN4CpThSj0uFk+OXhfgqGuRy5mReqnE7nkqBZ7VQ== X-Received: by 2002:a5d:5010:0:b0:22a:cb71:9493 with SMTP id e16-20020a5d5010000000b0022acb719493mr207089wrt.514.1664983729727; Wed, 05 Oct 2022 08:28:49 -0700 (PDT) Received: from dave-Ubuntu2204.pitowers.org ([93.93.133.154]) by smtp.googlemail.com with ESMTPSA id y14-20020adfe6ce000000b0022c96d3b6f2sm19747237wrm.54.2022.10.05.08.28.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 08:28:48 -0700 (PDT) From: Dave Stevenson To: paul.j.murphy@intel.com, daniele.alessandrelli@intel.com, linux-media@vger.kernel.org Cc: Dave Stevenson Subject: [PATCH 04/16] media: i2c: ov9282: Remove pixel rate from mode definition Date: Wed, 5 Oct 2022 16:27:57 +0100 Message-Id: <20221005152809.3785786-5-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221005152809.3785786-1-dave.stevenson@raspberrypi.com> References: <20221005152809.3785786-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The pixel rate is determined by the PLL setup in the common registers, not by the mode specific registers, therefore remove it from the mode definition and define it for all modes. Signed-off-by: Dave Stevenson --- drivers/media/i2c/ov9282.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index 1c77b77427f0..798ff8ba50bd 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -53,6 +53,10 @@ #define OV9282_LINK_FREQ 400000000 #define OV9282_NUM_DATA_LANES 2 +/* Pixel rate */ +#define OV9282_PIXEL_RATE (OV9282_LINK_FREQ * 2 * \ + OV9282_NUM_DATA_LANES / 10) + #define OV9282_REG_MIN 0x00 #define OV9282_REG_MAX 0xfffff @@ -92,7 +96,6 @@ struct ov9282_reg_list { * @vblank: Vertical blanking in lines * @vblank_min: Minimum vertical blanking in lines * @vblank_max: Maximum vertical blanking in lines - * @pclk: Sensor pixel clock * @link_freq_idx: Link frequency index * @reg_list: Register list for sensor mode */ @@ -103,7 +106,6 @@ struct ov9282_mode { u32 vblank; u32 vblank_min; u32 vblank_max; - u64 pclk; u32 link_freq_idx; struct ov9282_reg_list reg_list; }; @@ -118,7 +120,6 @@ struct ov9282_mode { * @inclk: Sensor input clock * @ctrl_handler: V4L2 control handler * @link_freq_ctrl: Pointer to link frequency control - * @pclk_ctrl: Pointer to pixel clock control * @hblank_ctrl: Pointer to horizontal blanking control * @vblank_ctrl: Pointer to vertical blanking control * @exp_ctrl: Pointer to exposure control @@ -138,7 +139,6 @@ struct ov9282 { struct regulator_bulk_data supplies[OV9282_NUM_SUPPLIES]; struct v4l2_ctrl_handler ctrl_handler; struct v4l2_ctrl *link_freq_ctrl; - struct v4l2_ctrl *pclk_ctrl; struct v4l2_ctrl *hblank_ctrl; struct v4l2_ctrl *vblank_ctrl; struct { @@ -269,7 +269,6 @@ static const struct ov9282_mode supported_mode = { .vblank = 1022, .vblank_min = 151, .vblank_max = 51540, - .pclk = 160000000, .link_freq_idx = 0, .reg_list = { .num_of_regs = ARRAY_SIZE(mode_1280x720_regs), @@ -1006,11 +1005,9 @@ static int ov9282_init_controls(struct ov9282 *ov9282) 1, mode->vblank); /* Read only controls */ - ov9282->pclk_ctrl = v4l2_ctrl_new_std(ctrl_hdlr, - &ov9282_ctrl_ops, - V4L2_CID_PIXEL_RATE, - mode->pclk, mode->pclk, - 1, mode->pclk); + v4l2_ctrl_new_std(ctrl_hdlr, &ov9282_ctrl_ops, V4L2_CID_PIXEL_RATE, + OV9282_PIXEL_RATE, OV9282_PIXEL_RATE, 1, + OV9282_PIXEL_RATE); ov9282->link_freq_ctrl = v4l2_ctrl_new_int_menu(ctrl_hdlr, &ov9282_ctrl_ops, From patchwork Wed Oct 5 15:27:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 612703 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10861C43217 for ; Wed, 5 Oct 2022 15:28:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230455AbiJEP25 (ORCPT ); Wed, 5 Oct 2022 11:28:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230434AbiJEP2y (ORCPT ); Wed, 5 Oct 2022 11:28:54 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 507205247F for ; Wed, 5 Oct 2022 08:28:52 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id n12so6902766wrp.10 for ; Wed, 05 Oct 2022 08:28:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=9XLxy8qWLotes+30GGmVyXT6iU1B7jM466UQuPj2CMY=; b=cGk73AXwcKo8TtqNQzrtLwjkdEe+B4xu4EQQfsFqbR3XyYIJqjpOM0TDDVlHf2ZIxo Gge7xDEZP7tgW5AhaePMyqgFP+JOwCvEDTefMwgmIcDK9deKtoRQDV4yPlWvckxyo/pB K9TMl+UvrAu1AGEwWS2PAqkqq3O1p5YsaLu00b6D9aQNCheRXOCdAbr7Ol/M91l41bEK 14Tecbq1sEf37S1L+EtzLpIN2YkCLgnpIZ12f60ukj2sYboJdesCjD7JIAtI0+trdYuT ygWLUvt0lgc+mBEepkh4G0A619Eta2Tj5BxnXnrx9pAFoTmeNV0EhT7kavXulJEdvfSX sh+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=9XLxy8qWLotes+30GGmVyXT6iU1B7jM466UQuPj2CMY=; b=rfHvaf50QZTdTzhsQ8ypHRfBpryM0Geyw/fB+DRd4HiV+QVdxhDiIU1qSlHSDh0nNu kOBt/zChFjc8Fd/SSdM75GnJbxuG3gjs9xvn6m65O7znGDUHTNTky1yR6D9TBuDCjLAx z9SG4FBoM8s4VJpZkBmcJAadLJgj9fq/Af3+tG+rgkvfaUhYmlVfFiFpK0Lgj6PpxDkF AiEkjfsxsZgzpI4m5Lnqf5zjBFQRW3P2mfq+KwhYnnTSE04X/SlCxRd/GmL3/O91fnNK DYATALheSrAsmY/iQ1GzV92iWdCvzoZrbtoR5DIL62sPnhDxetXfBfmbEQW8dG5HEDJK Q7dg== X-Gm-Message-State: ACrzQf2zqx6luPbI+Whzer6qlJeBzUgngaTywiProNsZZep+vAoVT+rf 0/4nnJKLhjTCI/KbGtY3IFRzfKAiOyCn7A== X-Google-Smtp-Source: AMsMyM4Rn1apvRkeXE7iUqiA/osVcSUWOI41jiD2hwl5+pDbZVu2oRMp/AwrBhSjx6Y14HLLUWAqbQ== X-Received: by 2002:adf:efce:0:b0:22e:38b8:fe41 with SMTP id i14-20020adfefce000000b0022e38b8fe41mr178427wrp.391.1664983731620; Wed, 05 Oct 2022 08:28:51 -0700 (PDT) Received: from dave-Ubuntu2204.pitowers.org ([93.93.133.154]) by smtp.googlemail.com with ESMTPSA id y14-20020adfe6ce000000b0022c96d3b6f2sm19747237wrm.54.2022.10.05.08.28.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 08:28:50 -0700 (PDT) From: Dave Stevenson To: paul.j.murphy@intel.com, daniele.alessandrelli@intel.com, linux-media@vger.kernel.org Cc: Dave Stevenson Subject: [PATCH 06/16] media: i2c: ov9282: Correct HTS register for configured pixel rate Date: Wed, 5 Oct 2022 16:27:59 +0100 Message-Id: <20221005152809.3785786-7-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221005152809.3785786-1-dave.stevenson@raspberrypi.com> References: <20221005152809.3785786-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The calculations from pixel rate, width+hblank, and height+vblank do not give the correct framerate - it's half the speed it should be. Whilst not documented as such, the TIMING_HTS register (0x380c/d) appears to be in units of 2 pixels. The default is 0x2d8 (728) which can not be valid as-is when the frame is 1280 active pixels wide. Doubling to 0x5b0 (1456) results in the correct timings. This driver isn't using the default frame width + hblank, so use 0x02fd which is half of the width of 1280 and hblank of 250 which is reported to userspace. With this the frame rate calculations work correctly. Signed-off-by: Dave Stevenson --- drivers/media/i2c/ov9282.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index f7823d584522..1cd6cb4addfb 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -242,8 +242,8 @@ static const struct ov9282_reg mode_1280x720_regs[] = { {0x3809, 0x00}, {0x380a, 0x02}, {0x380b, 0xd0}, - {0x380c, 0x05}, - {0x380d, 0xfa}, + {0x380c, 0x02}, + {0x380d, 0xfd}, {0x3810, 0x00}, {0x3811, 0x08}, {0x3812, 0x00}, From patchwork Wed Oct 5 15:28:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 612702 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66033C4332F for ; Wed, 5 Oct 2022 15:29:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230466AbiJEP27 (ORCPT ); Wed, 5 Oct 2022 11:28:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230454AbiJEP24 (ORCPT ); Wed, 5 Oct 2022 11:28:56 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEFFD726AC for ; Wed, 5 Oct 2022 08:28:54 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id bu30so6600520wrb.8 for ; Wed, 05 Oct 2022 08:28:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=XxqpkwTUgbj02jaJPTOUGxI3NiIufCRVkxD/M+na3eo=; b=lanMOQAuze+cNBEAFpqsWqUFCxMWTRd1+/s6a/kds8eWz9yfCHliRlXxusxHlBBBiA F2GNdhBVwXFlfz/1+nwQlrmRXteOhz7VKrJ8IY/LNpRHH21IKOWYMkvrL4KQ0FOiHFUF MFNUX8Xvw0n3Pwxdt0GiaMyoB1G9MpxRUVFt6HBmTwZ/LyVsfiIrGuAARi3vXg7XQfzq jSdrh/zNUIqU0O9Zgni23njcBRvx8SVGcuri3aPJTYYOpdeNwmqtheRXzwqsJ5ITwldy TS/wcl1tZJa5M/HI/UgZERg9sm7s2z20Uh02aGm39XKBV9p5vQWzLVTrlHubfIdadkAh guPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=XxqpkwTUgbj02jaJPTOUGxI3NiIufCRVkxD/M+na3eo=; b=usVoNoh6+YO6WOBplkg5rAcKIWnO23FWup37a17wnV8S6IPZLdMThg+7Py41XfO2uk So5QS67iLoB4DBjpcrde/kRd3GA6KyrkL2TdL5y8CJKfwS3cCjjKR+owiX5m8rHcl7X5 fGjsI/UuGqGkM7RzmeHruS5vDTzuR95rk0l+FquC6CDXi0g+Cdir6HnyMdr5wkRjqHdu Z15+92dN+5SCfvkYRw2kiMDnzBOzBS1IExNVFc7DNSP81/hDERhaeHys1qurBY0BmR/B 3YROAQCtpuhpVMn8wRFJsoBGvqf2mPAh588lTKTOn909tedQsLIbtXj3VjlWSaCRHMup nBUw== X-Gm-Message-State: ACrzQf1tyyCYFBMwDuDz7OQ/LRMVPlxmZD1qpWpi+NStlmI9wMfxLFMa dTM/rOSlYzerAQqleMIoX1hDQ9/ufmuPSw== X-Google-Smtp-Source: AMsMyM6VWNqUBXnnKFEtWsO2KAX13Jo+UWYpDChQvPjTEpSyYln5r9eTRB5kcy0emEwkUkZTeJUypA== X-Received: by 2002:a5d:4c44:0:b0:22e:3503:41bf with SMTP id n4-20020a5d4c44000000b0022e350341bfmr228867wrt.0.1664983734533; Wed, 05 Oct 2022 08:28:54 -0700 (PDT) Received: from dave-Ubuntu2204.pitowers.org ([93.93.133.154]) by smtp.googlemail.com with ESMTPSA id y14-20020adfe6ce000000b0022c96d3b6f2sm19747237wrm.54.2022.10.05.08.28.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 08:28:53 -0700 (PDT) From: Dave Stevenson To: paul.j.murphy@intel.com, daniele.alessandrelli@intel.com, linux-media@vger.kernel.org Cc: Dave Stevenson Subject: [PATCH 09/16] media: i2c: ov9282: Add the properties from fwnode Date: Wed, 5 Oct 2022 16:28:02 +0100 Message-Id: <20221005152809.3785786-10-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221005152809.3785786-1-dave.stevenson@raspberrypi.com> References: <20221005152809.3785786-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Use v4l2_ctrl_new_fwnode_properties to add V4L2_CID_CAMERA_ORIENTATION and V4L2_CID_CAMERA_SENSOR_ROTATION. Signed-off-by: Dave Stevenson --- drivers/media/i2c/ov9282.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index 334b31af34a4..183283d191b1 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -989,10 +989,11 @@ static int ov9282_init_controls(struct ov9282 *ov9282) { struct v4l2_ctrl_handler *ctrl_hdlr = &ov9282->ctrl_handler; const struct ov9282_mode *mode = ov9282->cur_mode; + struct v4l2_fwnode_device_properties props; u32 lpfr; int ret; - ret = v4l2_ctrl_handler_init(ctrl_hdlr, 6); + ret = v4l2_ctrl_handler_init(ctrl_hdlr, 8); if (ret) return ret; @@ -1050,7 +1051,14 @@ static int ov9282_init_controls(struct ov9282 *ov9282) if (ov9282->hblank_ctrl) ov9282->hblank_ctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY; - if (ctrl_hdlr->error) { + ret = v4l2_fwnode_device_parse(ov9282->dev, &props); + if (!ret) { + /* Failure sets ctrl_hdlr->error, which we check afterwards anyway */ + v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &ov9282_ctrl_ops, + &props); + } + + if (ctrl_hdlr->error || ret) { dev_err(ov9282->dev, "control init failed: %d", ctrl_hdlr->error); v4l2_ctrl_handler_free(ctrl_hdlr); From patchwork Wed Oct 5 15:28:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 612701 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8006BC4332F for ; Wed, 5 Oct 2022 15:29:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230472AbiJEP3B (ORCPT ); Wed, 5 Oct 2022 11:29:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230462AbiJEP25 (ORCPT ); Wed, 5 Oct 2022 11:28:57 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA7B561709 for ; Wed, 5 Oct 2022 08:28:56 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id bk15so26470242wrb.13 for ; Wed, 05 Oct 2022 08:28:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Z1L47Ikas8tepO08CaLIg/K6uhTqS3MA2OXErSnZo7c=; b=ce92HrKZzS3fclGQgdYYfIjUKrvVx6Yi+oWGJi3i0OmrzyvhSED06DK/jp9JagYRFc fmsAbHZqLJtmA3RtzmkXxPoQbGp44LlSjFD8bbr9fqD1rQbouPissDgo3DwAAS+lBdkx /xqtDF4yGtofPb/uzJcT79q/+8mElH7MIHjTDrk42cxjpxiNA9qtrDrVJus9P/gunXkk RqnGz2ANUGIemuPVCmNF7O4TEnCWk5Won740i7SXhzwIz/84sCqONsAZJWPxSV3Glu/z 56LxIsTPhjhpw5g9Q1mlB+vK9Eb2bYs/2n1yLaK3jnSQkkqmsN7pknhfHRS5TAow/eVX KKgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Z1L47Ikas8tepO08CaLIg/K6uhTqS3MA2OXErSnZo7c=; b=XDaTXmpnYZ5FQ7QTWW2hA+5ndm9SBr7RcFI1mtJiDRLtxx84AOs8IGccExYJaOyTnM +HS9lhAQwEp6XaG2IC9p85HJzUabSiPaih7sC5OTwFU/vaepZ5wpt4PUkN08QgSJk638 tBhfW5Wna+JQV4qO3gUVOJBmTwpXp+WGL+Ea25cZ5UBCigjTzvc1BEErvsmnW1iXJZQ6 MxFHp3YE4K50kqpsFhvgoLmzKbL0JX8g/wGKO+opBt3AnsocNgrAB+6HhKufCxhqWaEq kQ65JE992fQYLI/DRxrn6qCW2Q2XfatWPKQKqgMd3St86zJO/qfOdQJVJDRO2byALcXu WmeQ== X-Gm-Message-State: ACrzQf2AuZWGEtjYWrOknWy2ojhoSHQqWvUpY6WR8ds2F/WNXC6crYk0 boeTh35ojRIk7UI2+zFwOIz7UA== X-Google-Smtp-Source: AMsMyM4bZ96PTs7OV0cXtPy5VTsjWLpyCxnsdJStjVx6a2AT7xpNbJ/M5DW/r9RFIswJPBQnj6a9QA== X-Received: by 2002:a5d:59af:0:b0:22e:32be:60f1 with SMTP id p15-20020a5d59af000000b0022e32be60f1mr188454wrr.81.1664983735413; Wed, 05 Oct 2022 08:28:55 -0700 (PDT) Received: from dave-Ubuntu2204.pitowers.org ([93.93.133.154]) by smtp.googlemail.com with ESMTPSA id y14-20020adfe6ce000000b0022c96d3b6f2sm19747237wrm.54.2022.10.05.08.28.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 08:28:54 -0700 (PDT) From: Dave Stevenson To: paul.j.murphy@intel.com, daniele.alessandrelli@intel.com, linux-media@vger.kernel.org Cc: Dave Stevenson Subject: [PATCH 10/16] media: i2c: ov9282: Action CID_VBLANK when set. Date: Wed, 5 Oct 2022 16:28:03 +0100 Message-Id: <20221005152809.3785786-11-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221005152809.3785786-1-dave.stevenson@raspberrypi.com> References: <20221005152809.3785786-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Programming the sensor with TIMING_VTS (aka LPFR) was done when triggered by a change in exposure or gain, but not when V4L2_CID_VBLANK was changed. Dynamic frame rate changes could therefore not be achieved. Separate out programming TIMING_VTS so that it is triggered by set_ctrl(V4L2_CID_VBLANK) Signed-off-by: Dave Stevenson --- drivers/media/i2c/ov9282.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index 183283d191b1..5ddef6e2b3ac 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -419,22 +419,15 @@ static int ov9282_update_controls(struct ov9282 *ov9282, */ static int ov9282_update_exp_gain(struct ov9282 *ov9282, u32 exposure, u32 gain) { - u32 lpfr; int ret; - lpfr = ov9282->vblank + ov9282->cur_mode->height; - - dev_dbg(ov9282->dev, "Set exp %u, analog gain %u, lpfr %u", - exposure, gain, lpfr); + dev_dbg(ov9282->dev, "Set exp %u, analog gain %u", + exposure, gain); ret = ov9282_write_reg(ov9282, OV9282_REG_HOLD, 1, 1); if (ret) return ret; - ret = ov9282_write_reg(ov9282, OV9282_REG_LPFR, 2, lpfr); - if (ret) - goto error_release_group_hold; - ret = ov9282_write_reg(ov9282, OV9282_REG_EXPOSURE, 3, exposure << 4); if (ret) goto error_release_group_hold; @@ -465,6 +458,7 @@ static int ov9282_set_ctrl(struct v4l2_ctrl *ctrl) container_of(ctrl->handler, struct ov9282, ctrl_handler); u32 analog_gain; u32 exposure; + u32 lpfr; int ret; switch (ctrl->id) { @@ -482,10 +476,14 @@ static int ov9282_set_ctrl(struct v4l2_ctrl *ctrl) OV9282_EXPOSURE_OFFSET, 1, OV9282_EXPOSURE_DEFAULT); break; + } + + /* Set controls only if sensor is in power on state */ + if (!pm_runtime_get_if_in_use(ov9282->dev)) + return 0; + + switch (ctrl->id) { case V4L2_CID_EXPOSURE: - /* Set controls only if sensor is in power on state */ - if (!pm_runtime_get_if_in_use(ov9282->dev)) - return 0; exposure = ctrl->val; analog_gain = ov9282->again_ctrl->val; @@ -495,14 +493,19 @@ static int ov9282_set_ctrl(struct v4l2_ctrl *ctrl) ret = ov9282_update_exp_gain(ov9282, exposure, analog_gain); - pm_runtime_put(ov9282->dev); + break; + case V4L2_CID_VBLANK: + lpfr = ov9282->vblank + ov9282->cur_mode->height; + ret = ov9282_write_reg(ov9282, OV9282_REG_LPFR, 2, lpfr); break; default: dev_err(ov9282->dev, "Invalid control %d", ctrl->id); ret = -EINVAL; } + pm_runtime_put(ov9282->dev); + return ret; } From patchwork Wed Oct 5 15:28:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 612700 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6CEEAC433F5 for ; Wed, 5 Oct 2022 15:29:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230188AbiJEP3F (ORCPT ); Wed, 5 Oct 2022 11:29:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230467AbiJEP27 (ORCPT ); Wed, 5 Oct 2022 11:28:59 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EF0D61709 for ; Wed, 5 Oct 2022 08:28:58 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id b4so19544863wrs.1 for ; Wed, 05 Oct 2022 08:28:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=XKiMujn/UlWa10V840tKoy+9zQnGra0wz3xwbR/Baao=; b=Zgrzdk9nuZpYHSJ62FGqdj+gRi+9OBjD8i2fK5WT+Q6n189fd1V9TgM8FCRwKv9xfh /6ALTt8/V5pjD/Kd8xPV8irHSPZqnaU2bHCKzArcTIOyfid7jJRtInWn1Pqllp5EHr1+ kPD/MmCKcvyCh/ZI5gdAAHUhgUnMADx5LSwfah7xLWXR8h3Sg8pkbVK+Gpa2nO1D9V61 b5LsRXCpt64y++KQ3j43YRETAKJ8LqfrakTlTdw3vpZsHrNIojGPleCMnJOjFqi97yKO zbrP6GWWbfaik+Wc/Y8z5A9jtaVSzJPhp20oyTEzEusGYv2z7mRAmw1MPj8AP8ve5w0k 2dew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=XKiMujn/UlWa10V840tKoy+9zQnGra0wz3xwbR/Baao=; b=BhFVafdmHlfSBOtDN694cz16tjSI8BRm6EqpLlNIuHT9PwePZzoSYl/dFCKaMDkLNJ PYjlLf/lDqTD8G681j0W4dez38yRIGZOoI7F9O+Z19m5Fghj6OqnZpklCp2Vaar78ShB tTrFuGVyA2p3wQ1U5VN4l3U683kGoEWc3I4fELD6+0CM7rGk7t6D6LHFLBWtJ7FtI+RY +zBQjw+x4OxlOlwUoDG4t7rTkdHNFJHx9+ptuOwLP45izijpz69BbM51YFpNwKX/hTbP TsHonkw6S/jNsOu+n0ABD8Tvpnm9Q+JdxmI8RWsWhDbh5vukl9G2pVikflkIgdn79+IJ Rayg== X-Gm-Message-State: ACrzQf2xg80suhR6rT6J1O5DoQ66HUnCtM1BTLq4EsEkYxAuX3PXCPZx I3avB1iNjiD9GyrvG4/SrIyL+A== X-Google-Smtp-Source: AMsMyM4bwJZY3ACG771Q/zNuT+gfx7b0IBOgPAVimtMEV3L3ImiN8IrXh8D0CVpV99W6SpXL2eb7bw== X-Received: by 2002:a05:6000:10d1:b0:22e:3bc5:c91c with SMTP id b17-20020a05600010d100b0022e3bc5c91cmr203914wrx.368.1664983737726; Wed, 05 Oct 2022 08:28:57 -0700 (PDT) Received: from dave-Ubuntu2204.pitowers.org ([93.93.133.154]) by smtp.googlemail.com with ESMTPSA id y14-20020adfe6ce000000b0022c96d3b6f2sm19747237wrm.54.2022.10.05.08.28.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 08:28:57 -0700 (PDT) From: Dave Stevenson To: paul.j.murphy@intel.com, daniele.alessandrelli@intel.com, linux-media@vger.kernel.org Cc: Dave Stevenson Subject: [PATCH 12/16] media: i2c: ov9282: Make V4L2_CID_HBLANK r/w Date: Wed, 5 Oct 2022 16:28:05 +0100 Message-Id: <20221005152809.3785786-13-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221005152809.3785786-1-dave.stevenson@raspberrypi.com> References: <20221005152809.3785786-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org There's no reason why HBLANK has to be read-only as it only changes the TIMING_HTS register in the sensor. Remove the READ_ONLY flag, and add the relevant handling for it. The minimum value also varies based on whether continuous clock mode is being used or not, so allow hblank_min to depend on that. Signed-off-by: Dave Stevenson --- drivers/media/i2c/ov9282.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index 12cbe401fd78..8e86aa7e4b2a 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -22,6 +22,9 @@ #define OV9282_MODE_STANDBY 0x00 #define OV9282_MODE_STREAMING 0x01 +#define OV9282_REG_TIMING_HTS 0x380c +#define OV9282_TIMING_HTS_MAX 0x7fff + /* Lines per frame */ #define OV9282_REG_LPFR 0x380e @@ -99,7 +102,8 @@ struct ov9282_reg_list { * struct ov9282_mode - ov9282 sensor mode structure * @width: Frame width * @height: Frame height - * @hblank: Horizontal blanking in lines + * @hblank_min: Minimum horizontal blanking in lines for non-continuous[0] and + * continuous[1] clock modes * @vblank: Vertical blanking in lines * @vblank_min: Minimum vertical blanking in lines * @vblank_max: Maximum vertical blanking in lines @@ -109,7 +113,7 @@ struct ov9282_reg_list { struct ov9282_mode { u32 width; u32 height; - u32 hblank; + u32 hblank_min[2]; u32 vblank; u32 vblank_min; u32 vblank_max; @@ -249,8 +253,6 @@ static const struct ov9282_reg mode_1280x720_regs[] = { {0x3809, 0x00}, {0x380a, 0x02}, {0x380b, 0xd0}, - {0x380c, 0x02}, - {0x380d, 0xfd}, {0x3810, 0x00}, {0x3811, 0x08}, {0x3812, 0x00}, @@ -273,7 +275,7 @@ static const struct ov9282_mode supported_modes[] = { { .width = 1280, .height = 720, - .hblank = 250, + .hblank_min = { 250, 176 }, .vblank = 1022, .vblank_min = 41, .vblank_max = 51540, @@ -399,15 +401,17 @@ static int ov9282_write_regs(struct ov9282 *ov9282, static int ov9282_update_controls(struct ov9282 *ov9282, const struct ov9282_mode *mode) { + u32 hblank_min; int ret; ret = __v4l2_ctrl_s_ctrl(ov9282->link_freq_ctrl, mode->link_freq_idx); if (ret) return ret; - ret = __v4l2_ctrl_s_ctrl(ov9282->hblank_ctrl, mode->hblank); - if (ret) - return ret; + hblank_min = mode->hblank_min[ov9282->noncontinuous_clock ? 0 : 1]; + ret = __v4l2_ctrl_modify_range(ov9282->hblank_ctrl, hblank_min, + OV9282_TIMING_HTS_MAX - mode->width, 1, + hblank_min); return __v4l2_ctrl_modify_range(ov9282->vblank_ctrl, mode->vblank_min, mode->vblank_max, 1, mode->vblank); @@ -539,6 +543,10 @@ static int ov9282_set_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_VFLIP: ret = ov9282_set_ctrl_vflip(ov9282, ctrl->val); break; + case V4L2_CID_HBLANK: + ret = ov9282_write_reg(ov9282, OV9282_REG_TIMING_HTS, 2, + (ctrl->val + ov9282->cur_mode->width) >> 1); + break; default: dev_err(ov9282->dev, "Invalid control %d", ctrl->id); ret = -EINVAL; @@ -1033,6 +1041,7 @@ static int ov9282_init_controls(struct ov9282 *ov9282) struct v4l2_ctrl_handler *ctrl_hdlr = &ov9282->ctrl_handler; const struct ov9282_mode *mode = ov9282->cur_mode; struct v4l2_fwnode_device_properties props; + u32 hblank_min; u32 lpfr; int ret; @@ -1091,14 +1100,13 @@ static int ov9282_init_controls(struct ov9282 *ov9282) if (ov9282->link_freq_ctrl) ov9282->link_freq_ctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY; + hblank_min = mode->hblank_min[ov9282->noncontinuous_clock ? 0 : 1]; ov9282->hblank_ctrl = v4l2_ctrl_new_std(ctrl_hdlr, &ov9282_ctrl_ops, V4L2_CID_HBLANK, - OV9282_REG_MIN, - OV9282_REG_MAX, - 1, mode->hblank); - if (ov9282->hblank_ctrl) - ov9282->hblank_ctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY; + hblank_min, + OV9282_TIMING_HTS_MAX - mode->width, + 1, hblank_min); ret = v4l2_fwnode_device_parse(ov9282->dev, &props); if (!ret) { From patchwork Wed Oct 5 15:28:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 612699 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78B49C43217 for ; Wed, 5 Oct 2022 15:29:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230470AbiJEP3H (ORCPT ); Wed, 5 Oct 2022 11:29:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230462AbiJEP3D (ORCPT ); Wed, 5 Oct 2022 11:29:03 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFD2057899 for ; Wed, 5 Oct 2022 08:29:01 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id y23-20020a1c4b17000000b003bd336914f9so1233253wma.4 for ; Wed, 05 Oct 2022 08:29:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Tcapm+tKjFrTXlUvq1XzREivNboKqkjM4qRciK0bi88=; b=CMv8HFLqZLNdzzT4dWXVod6tv+fU2thk0KI1UJwxskqO7Djz1XKrI/q9lwTtK6EQ+h K9rRjpQetfHy3YfyekRPZ34y7YDbBuRGrDANbE9KEP2y0WEx6qFEG/09dhAe82/a5q0W YfCxNICva+FJdd06Z7OZOE//RnVUo24HdpRRfNW+2ACmG0ilPeHcNQEGA7KCnaMneYTC H+d5+DUPFX99w8ZHn0fZTpUCfc4EyaVlctnO8Ixy/W7ks1euFgEco1xxQvNLFIuy5V3L lytSAecMmuLIL9+X02sGJo1xKH6PGCMu9csyu02HEun8PnrgGAanmhZY6F/C9xo1A8Ha K9NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Tcapm+tKjFrTXlUvq1XzREivNboKqkjM4qRciK0bi88=; b=az6YcKGChie9fJXfG2WvJdSM4UsM5vO76/7iN13A7XaF2oAJLUcc3/H9n1tvuz6Xja EXqtMMnM8QoYYGeZOUYkRFwxnYlp6ZIu2T7PIXEwu6NFxKWlyulCi+mbyb1InO3RwsH3 JKle1k8VhoBcKg8LuqM37FDtVY4dhGx6UQbTGBCd21tuLN21z1pqTVDdEZn2sR3eNhMd 1wwNo8rm3XiZRVoHJteLZmgRYLol7F75LuWYl39jipBAYmPQRCx5EoqrlIknz0XfomNd VrdNGL8pKMdmDfYEmxVPgOBZbCPraQ3IWci1xXQdC7if6NY2hkQUIZhRuu5UosABmbnk Fbww== X-Gm-Message-State: ACrzQf0zp2w/gJu7bw89ZbYHUYnaLZD5R/gZkh2qQ5aIBRtHMb2uwy46 eJd/y3A9UIqQeerf1JniUHxV6g== X-Google-Smtp-Source: AMsMyM6vH2QWPcAz/OP44Jid1PHKLNB+ABqx5BLMEt9eKyQ0HKPVtKukYuBgoF3TcUvi5DD96623tw== X-Received: by 2002:a05:600c:3106:b0:3b9:578a:c151 with SMTP id g6-20020a05600c310600b003b9578ac151mr3753930wmo.29.1664983740152; Wed, 05 Oct 2022 08:29:00 -0700 (PDT) Received: from dave-Ubuntu2204.pitowers.org ([93.93.133.154]) by smtp.googlemail.com with ESMTPSA id y14-20020adfe6ce000000b0022c96d3b6f2sm19747237wrm.54.2022.10.05.08.28.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 08:28:59 -0700 (PDT) From: Dave Stevenson To: paul.j.murphy@intel.com, daniele.alessandrelli@intel.com, linux-media@vger.kernel.org Cc: Dave Stevenson Subject: [PATCH 14/16] media: i2c: ov9282: Add support for 1280x800 and 640x400 modes Date: Wed, 5 Oct 2022 16:28:07 +0100 Message-Id: <20221005152809.3785786-15-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221005152809.3785786-1-dave.stevenson@raspberrypi.com> References: <20221005152809.3785786-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Adds register settings for additional modes. Signed-off-by: Dave Stevenson --- drivers/media/i2c/ov9282.c | 97 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index d892f53fb1ea..ec1599488f21 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -251,6 +251,37 @@ struct ov9282_reg_list common_regs_list = { }; /* Sensor mode registers */ +static const struct ov9282_reg mode_1280x800_regs[] = { + {0x3778, 0x00}, + {0x3800, 0x00}, + {0x3801, 0x00}, + {0x3802, 0x00}, + {0x3803, 0x00}, + {0x3804, 0x05}, + {0x3805, 0x0f}, + {0x3806, 0x03}, + {0x3807, 0x2f}, + {0x3808, 0x05}, + {0x3809, 0x00}, + {0x380a, 0x03}, + {0x380b, 0x20}, + {0x3810, 0x00}, + {0x3811, 0x08}, + {0x3812, 0x00}, + {0x3813, 0x08}, + {0x3814, 0x11}, + {0x3815, 0x11}, + {0x3820, 0x40}, + {0x3821, 0x00}, + {0x4003, 0x40}, + {0x4008, 0x04}, + {0x4009, 0x0b}, + {0x400c, 0x00}, + {0x400d, 0x07}, + {0x4507, 0x00}, + {0x4509, 0x00}, +}; + static const struct ov9282_reg mode_1280x720_regs[] = { {0x3778, 0x00}, {0x3800, 0x00}, @@ -282,6 +313,36 @@ static const struct ov9282_reg mode_1280x720_regs[] = { {0x4509, 0x80}, }; +static const struct ov9282_reg mode_640x400_regs[] = { + {0x3778, 0x10}, + {0x3800, 0x00}, + {0x3801, 0x00}, + {0x3802, 0x00}, + {0x3803, 0x00}, + {0x3804, 0x05}, + {0x3805, 0x0f}, + {0x3806, 0x03}, + {0x3807, 0x2f}, + {0x3808, 0x02}, + {0x3809, 0x80}, + {0x380a, 0x01}, + {0x380b, 0x90}, + {0x3810, 0x00}, + {0x3811, 0x04}, + {0x3812, 0x00}, + {0x3813, 0x04}, + {0x3814, 0x31}, + {0x3815, 0x22}, + {0x3820, 0x60}, + {0x3821, 0x01}, + {0x4008, 0x02}, + {0x4009, 0x05}, + {0x400c, 0x00}, + {0x400d, 0x03}, + {0x4507, 0x03}, + {0x4509, 0x80}, +}; + /* Supported sensor mode configurations */ static const struct ov9282_mode supported_modes[] = { { @@ -306,6 +367,42 @@ static const struct ov9282_mode supported_modes[] = { .num_of_regs = ARRAY_SIZE(mode_1280x720_regs), .regs = mode_1280x720_regs, }, + }, { + .width = 1280, + .height = 800, + .hblank_min = { 250, 176 }, + .vblank = 1022, + .vblank_min = 110, + .vblank_max = 51540, + .link_freq_idx = 0, + .crop = { + .left = OV9282_PIXEL_ARRAY_LEFT, + .top = OV9282_PIXEL_ARRAY_TOP, + .width = 1280, + .height = 800 + }, + .reg_list = { + .num_of_regs = ARRAY_SIZE(mode_1280x800_regs), + .regs = mode_1280x800_regs, + }, + }, { + .width = 640, + .height = 400, + .hblank_min = { 890, 816 }, + .vblank = 1022, + .vblank_min = 22, + .vblank_max = 51540, + .link_freq_idx = 0, + .crop = { + .left = OV9282_PIXEL_ARRAY_LEFT, + .top = OV9282_PIXEL_ARRAY_TOP, + .width = 1280, + .height = 800 + }, + .reg_list = { + .num_of_regs = ARRAY_SIZE(mode_640x400_regs), + .regs = mode_640x400_regs, + }, }, }; From patchwork Wed Oct 5 15:28:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 612698 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8081AC4332F for ; Wed, 5 Oct 2022 15:29:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230462AbiJEP3J (ORCPT ); Wed, 5 Oct 2022 11:29:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230236AbiJEP3F (ORCPT ); Wed, 5 Oct 2022 11:29:05 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C1335247F for ; Wed, 5 Oct 2022 08:29:03 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id iv17so11003011wmb.4 for ; Wed, 05 Oct 2022 08:29:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=6z3eOipP9uSMzPeU3wBGzwLbTfap33BpuIjU1zg0tEk=; b=qQzZRbGT2wTwhRLH83pIdLCNg8GKK5mI8Py7DLK0afe6y02JwMwZcVmfzn44zDkeaO 4nJ38tSXc9JvikrKB1IT62mbZm9Z8n7KaURxABhAgmnDJASzWM1KrlI6MDIXKuhroJTu /+hMocPK3vfC7kNJ4XOl1tTN1WOSQ22vS5B7vqzDdoL4NcYaWP06ZUBT3+RFAa8Q7Hju e0kSLkH1Z6Q+raSQrTVKMhJC1TSIKaoOp/ZHiqx0JRBB6yaCXknnoKQkrVy0WkPUL7yH Km44bAh5MJ6IVxtJOCyYKAzPUerqwCHDmeFsP6Dkj/a0aASQ7LGbOYakQe+ohvi2nP22 XIqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=6z3eOipP9uSMzPeU3wBGzwLbTfap33BpuIjU1zg0tEk=; b=Xz77JBpBBtmYy+DaC5ChUoqeSoUWx4jYCsefivjnGU8B4OlW86nRQmW8r6W19eFfXT +YQMnryyXgO7he+CJLq97kpD4g3iwiu71vbN7yj0WiC8VQoP22Fz0x9DcyrBwZ7WFMZ7 c757em0cwfj5o3IgrpP0XaRQYro73L7BqpnxpUMyw0sEIGHzRq5z7XvlV0tPQtIeGA01 1NMgwhpGxvZTePMZLgG6lMHktBcc2eDs1wgcDuhzTNHBRy0QU6r95NyQTt1IN+byQyGt S9KD6Bbrw6bDRovp3vpzQ91iaaU/Ok9NzAacagxWVJVXLo7WjYd/cYYWipTlZh8kJLTb CqfA== X-Gm-Message-State: ACrzQf2hd/DgkvmDQgohPyVJf4eer/k4FEfJ1r5bda4KsmxygnixBITY 3cT2XkCP2XMcx8SrZoLXpQzxw+EmO+wipw== X-Google-Smtp-Source: AMsMyM4R7vCfmdzS3F312wf/F0RNQlnMxcY1A91cTiRl9ZV0cTTTp4t5QdZQ8kxlIzecRtH2q9KU1A== X-Received: by 2002:a05:600c:1c89:b0:3b4:a612:c3e0 with SMTP id k9-20020a05600c1c8900b003b4a612c3e0mr113983wms.20.1664983742070; Wed, 05 Oct 2022 08:29:02 -0700 (PDT) Received: from dave-Ubuntu2204.pitowers.org ([93.93.133.154]) by smtp.googlemail.com with ESMTPSA id y14-20020adfe6ce000000b0022c96d3b6f2sm19747237wrm.54.2022.10.05.08.29.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 08:29:01 -0700 (PDT) From: Dave Stevenson To: paul.j.murphy@intel.com, daniele.alessandrelli@intel.com, linux-media@vger.kernel.org Cc: Dave Stevenson Subject: [PATCH 16/16] media: i2c: ov9282: Support event handlers Date: Wed, 5 Oct 2022 16:28:09 +0100 Message-Id: <20221005152809.3785786-17-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221005152809.3785786-1-dave.stevenson@raspberrypi.com> References: <20221005152809.3785786-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org As noted in the headers for V4L2_SUBDEV_FL_HAS_EVENTS, "controls can send events, thus drivers exposing controls should set this flag". This driver exposes controls, but didn't reflect that it could generate events. Correct this, and add the default event handler functions. Signed-off-by: Dave Stevenson --- drivers/media/i2c/ov9282.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index bc429455421e..416c9656e3ac 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -1189,6 +1190,11 @@ static int ov9282_parse_hw_config(struct ov9282 *ov9282) } /* V4l2 subdevice ops */ +static const struct v4l2_subdev_core_ops ov9282_core_ops = { + .subscribe_event = v4l2_ctrl_subdev_subscribe_event, + .unsubscribe_event = v4l2_event_subdev_unsubscribe, +}; + static const struct v4l2_subdev_video_ops ov9282_video_ops = { .s_stream = ov9282_set_stream, }; @@ -1203,6 +1209,7 @@ static const struct v4l2_subdev_pad_ops ov9282_pad_ops = { }; static const struct v4l2_subdev_ops ov9282_subdev_ops = { + .core = &ov9282_core_ops, .video = &ov9282_video_ops, .pad = &ov9282_pad_ops, }; @@ -1419,7 +1426,8 @@ static int ov9282_probe(struct i2c_client *client) } /* Initialize subdev */ - ov9282->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; + ov9282->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | + V4L2_SUBDEV_FL_HAS_EVENTS; ov9282->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR; /* Initialize source pad */