From patchwork Wed Oct 5 15:27:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 12999386 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 3785FC4332F for ; Wed, 5 Oct 2022 15:28:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230448AbiJEP2u (ORCPT ); Wed, 5 Oct 2022 11:28:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229991AbiJEP2t (ORCPT ); Wed, 5 Oct 2022 11:28:49 -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 2BD0E21818 for ; Wed, 5 Oct 2022 08:28:48 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id bg9-20020a05600c3c8900b003bf249616b0so1064224wmb.3 for ; Wed, 05 Oct 2022 08:28:48 -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=5F9oOTt1h7E4ugwjY0SVsurm2rLl+26D5GFYpF/eY4k=; b=KB4A72mxoRK3U+lYiEihWXQFWqQcjzjyX1SUX4ZdLH6d0YF8IYBxQPcIetUeiBLYxD 5U1lgrO9U5JeiZaLK8iTNjXB8Us5ITgtCm399NqGonAoMpRPB+7WApksDQlDGpHR+OaV ZxhUHig+xDIgV+uF3dmzjU4QZr1X2zJCa7q+/WlV/mZDHS4Ef18BHVMOQ4HkuvBO9I/8 1NC4blKEdCTUcB2dTb0yVNuANSFxr70lH96zw4WuKohPHuNoOreLCyqhMF1ZL2dPLupf ZlsskCL40r+e9DyJEbLw4TJtSaCG6T6C6ZnlDa3juCGggLDtCh9YaTXIykmnwjcqFLo9 NPlA== 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=5F9oOTt1h7E4ugwjY0SVsurm2rLl+26D5GFYpF/eY4k=; b=KMzC71KtHlBQbvGKMA32pkPkpxJeITzykWLZowffbDJRaEkg2xcIa0zZRIDJEC1EdL 0yMG2Kl5HGflguuqmhQqMVysAJ7MTynYBdmNDr84sWiDbtoAzhYCmY7tmfgqyWreqDeW aW7dNlZv46sGDUea0Sro0eW5iTDFN2Fd8aK5yNLSQSEeprUSsHaKIBklhBgd4AOPKa4F Y95nl2NSWeeKckDapw72AsiZGiE5qMh5dTnaIvYsVDUkYcrwR73J/3Kgke8JkBTcdi4I UsejNLhUanggzVuWilv3GVd8wfd4RCUecFHyp4YDAq77PD31sNGbdNUUVE1ocFjPUy1b f3Cw== X-Gm-Message-State: ACrzQf2M+qMrefzkXoFtUumdlRH1bJ5aCZSTFC4po0WiEyezjQdBheZG EPXkUjwq1+bezeaZrx21Pibrmn+LcP763g== X-Google-Smtp-Source: AMsMyM7V7JE0fmkHdDNrKIXj9DR6+AlnFN6R3wFRVvLsrGpSLqD5e4uQKs9hG5UzKzeYQSKEcdXJLA== X-Received: by 2002:a7b:ca46:0:b0:3b4:7ff1:4fcc with SMTP id m6-20020a7bca46000000b003b47ff14fccmr3844755wml.47.1664983726671; Wed, 05 Oct 2022 08:28:46 -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 01/16] media: i2c: ov9282: Remove duplication of registers Date: Wed, 5 Oct 2022 16:27:54 +0100 Message-Id: <20221005152809.3785786-2-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 TIMING_VTS (registers 0x380e/f), EXPOSURE (registers 0x3500/1/2), and GAIN (0x3509) are all set from ov9282_update_exp_gain as part of the control handler, therefore they do not need to be in the main list of registers. Remove them. Signed-off-by: Dave Stevenson Reviewed-by: Jacopo Mondi --- drivers/media/i2c/ov9282.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index 699fc5b753b4..2c13bcd59c2a 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -173,14 +173,10 @@ static const struct ov9282_reg mode_1280x720_regs[] = { {0x3030, 0x10}, {0x3039, 0x32}, {0x303a, 0x00}, - {0x3500, 0x00}, - {0x3501, 0x5f}, - {0x3502, 0x1e}, {0x3503, 0x08}, {0x3505, 0x8c}, {0x3507, 0x03}, {0x3508, 0x00}, - {0x3509, 0x10}, {0x3610, 0x80}, {0x3611, 0xa0}, {0x3620, 0x6e}, @@ -214,8 +210,6 @@ static const struct ov9282_reg mode_1280x720_regs[] = { {0x380b, 0xd0}, {0x380c, 0x05}, {0x380d, 0xfa}, - {0x380e, 0x06}, - {0x380f, 0xce}, {0x3810, 0x00}, {0x3811, 0x08}, {0x3812, 0x00}, 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: 12999387 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 Reviewed-by: Jacopo Mondi --- 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:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 12999388 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 DDD77C433F5 for ; Wed, 5 Oct 2022 15:28:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230453AbiJEP2x (ORCPT ); Wed, 5 Oct 2022 11:28:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230434AbiJEP2v (ORCPT ); Wed, 5 Oct 2022 11:28:51 -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 2742521818 for ; Wed, 5 Oct 2022 08:28:50 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id bu30so6600137wrb.8 for ; Wed, 05 Oct 2022 08:28:50 -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=JN+WKzTlGg4Dfuw/XYIvcSEzDC2bO8y0dBB3JqIqBHU=; b=lepSQfSZ76iMoeV0TPRdks2npZUjxeCENNWRxYdnuF1pqkwoES7O14oboWKaal2btf TMbhWbEVm3CfwpDxGTM/1JQWmgUZFSE9sD4OjbawbVUMIAS2A9ZGMBLRXlW/Du8x5mLj gkpPxkU2xUOisCNmnOX+4nFrfzwM2MJD21b6SLChCU2pPgnL3wMaJDxFtm8XSFSr9Hjd JQkeHXE0BWxFvLMMN7nV6wgqxyw3S+DuWlK84JqaeGz8vlcvCLWOHwtZKJxTI6p5vAnt 0sn2NSzKkxp5VOEk9tmlfJiX87NcrWqkEnYz5g7fZAbMKaIjAOLO6R4SOAuBGDSzpo6J mlPQ== 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=JN+WKzTlGg4Dfuw/XYIvcSEzDC2bO8y0dBB3JqIqBHU=; b=SZIW1CJGm99eLvXTENi6/xwoWm7riueVzxj9dVr2imzNDBarPY/5wz+cJPHvnlzGVJ cg2yVCO0G5R+KdM+NptxL6+vwuGVveMcJLsc6CDUKVhsEGtNTk3/+REUXuEpTIhQX+0H NejO4KSmyKPxT9kJqEvltoe/BCA5otFCjDeNXBdkd9Cmgr8Ol1eEsSG53hSGg+gXJmc0 3tjTOmfyx7GL4ZyoEYRvOuJh0ZmlwPy7fY2rHVCSqPo07Dr1Ut6wEfsyRGc5ACkDn9HH jaT5YLVAW472uClTxIhJqkgZB0iLn7D5o44kWl0pgUSPE93vn7fINAejXHOuV8eEH3+U BuFg== X-Gm-Message-State: ACrzQf2zLhyyEoJ2B13PmT6m7GysibDyxUvZWZy4V/iPqjZek+dfIt50 uBbFzM6kc7GgQ8ajCaG+FyxXr5tMy0YR8w== X-Google-Smtp-Source: AMsMyM66VifbHLZVLV4D6L/LyWJKEj5KpjQzQ39Y0P7iXQi0vkJ2Vlph2NLMFzge0zb+qxt6vl80vA== X-Received: by 2002:a05:6000:108a:b0:22e:5610:7987 with SMTP id y10-20020a056000108a00b0022e56107987mr161729wrw.527.1664983728707; Wed, 05 Oct 2022 08:28:48 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 08:28:47 -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 03/16] media: i2c: ov9282: Remove format code from the mode Date: Wed, 5 Oct 2022 16:27:56 +0100 Message-Id: <20221005152809.3785786-4-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 format code is independent of mode, and each mode could support both Y10 and Y8, so disassociate the code from the mode. Signed-off-by: Dave Stevenson Reviewed-by: Jacopo Mondi --- drivers/media/i2c/ov9282.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index 9842080cf66f..1c77b77427f0 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -88,7 +88,6 @@ struct ov9282_reg_list { * struct ov9282_mode - ov9282 sensor mode structure * @width: Frame width * @height: Frame height - * @code: Format code * @hblank: Horizontal blanking in lines * @vblank: Vertical blanking in lines * @vblank_min: Minimum vertical blanking in lines @@ -100,7 +99,6 @@ struct ov9282_reg_list { struct ov9282_mode { u32 width; u32 height; - u32 code; u32 hblank; u32 vblank; u32 vblank_min; @@ -273,7 +271,6 @@ static const struct ov9282_mode supported_mode = { .vblank_max = 51540, .pclk = 160000000, .link_freq_idx = 0, - .code = MEDIA_BUS_FMT_Y10_1X10, .reg_list = { .num_of_regs = ARRAY_SIZE(mode_1280x720_regs), .regs = mode_1280x720_regs, @@ -523,7 +520,7 @@ static int ov9282_enum_mbus_code(struct v4l2_subdev *sd, if (code->index > 0) return -EINVAL; - code->code = supported_mode.code; + code->code = MEDIA_BUS_FMT_Y10_1X10; return 0; } @@ -543,7 +540,7 @@ static int ov9282_enum_frame_size(struct v4l2_subdev *sd, if (fsize->index > 0) return -EINVAL; - if (fsize->code != supported_mode.code) + if (fsize->code != MEDIA_BUS_FMT_Y10_1X10) return -EINVAL; fsize->min_width = supported_mode.width; @@ -567,7 +564,7 @@ static void ov9282_fill_pad_format(struct ov9282 *ov9282, { fmt->format.width = mode->width; fmt->format.height = mode->height; - fmt->format.code = mode->code; + fmt->format.code = MEDIA_BUS_FMT_Y10_1X10; fmt->format.field = V4L2_FIELD_NONE; fmt->format.colorspace = V4L2_COLORSPACE_RAW; fmt->format.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; 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: 12999389 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 Reviewed-by: Jacopo Mondi --- 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:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 12999390 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 E9561C4332F for ; Wed, 5 Oct 2022 15:28:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230461AbiJEP24 (ORCPT ); Wed, 5 Oct 2022 11:28:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229991AbiJEP2x (ORCPT ); Wed, 5 Oct 2022 11:28:53 -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 716344B9BE for ; Wed, 5 Oct 2022 08:28:52 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id f11so23837793wrm.6 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=u48U+IK6M8Tybj3w4BxGG2Sv9mA9uX0DERliKfCIBNY=; b=NHg9TtYaq0rrPvOlmB5+4d+h4ZDpNoaTGGFElByWHEp1c2K8FFybHy9gNOvkyEFxyD LY191gTj0NdsWYL83BiQ/dqe/2GAvR//yWX94nBWcIVzexoUtASa9qAHgH6a/06+3t29 CLW2JnuRKQFvwJK43FlcJyTCSBWe7xcNDYM45cQDEbMRVQCwFYsvsUsGuIPP6ob5zopb jp5EkCqult6plA8P7civb3ny0LgSnfZVwHyPHVyfNcbVdVq8EX+Cu6BV5rr+GHSSrhEi tNX8wfOymbmTHCg2tI93aozl7iKfj7wuUgHlM7pRnGCIWaPVspgPfFrINcPs3RgD6s4V tMrQ== 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=u48U+IK6M8Tybj3w4BxGG2Sv9mA9uX0DERliKfCIBNY=; b=SiXH7UQFgQGMNvPWCQaPmCpNErkZeYKpBa6lS9xNgYK6Lr7oGuVS4M2pbe/TxfbGca sJ4gyAEz0TeGkYmWgo9WQfRwu6DzQMFKzcnWVnHyNDYeDr8PrGoa1eLEY0uo+aNjpQhx in8DWA/57ntxesyRO2aLHaFGzvB/isgvlGqDy8P9YskgE4/kmBc3YrHc17lICsGv6SO/ pjPWY85mdaPGJ8dvp+kCiKiVwrny6cixljnmmKpQp50VWJ8NRJjzd0A6D5qfiRke9ZZx HzMBSylk3IbiFwJLgXEtXL6T62hKvsB9PxrDp2zRs0PvQRMTSD2FCBh7iRrSqdQ+epLl TaqA== X-Gm-Message-State: ACrzQf3vGyZ7bzisCnRAMYEfXRWZAvqueSbQx5FK8/ig6F1qRqiJwmrr H75U0qRxYcAF8VJhIXj1C8Iaqg== X-Google-Smtp-Source: AMsMyM5j+kvw+TCPZZzqCe4vQUe9r0j7FrqZ4Livtql+ttRsCgz0kvoeo4XdIaLd3u/6rkk50ke8JQ== X-Received: by 2002:a5d:4f81:0:b0:21e:2cd7:25df with SMTP id d1-20020a5d4f81000000b0021e2cd725dfmr180206wru.439.1664983730710; Wed, 05 Oct 2022 08:28:50 -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.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 08:28:49 -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 05/16] media: i2c: ov9281: Support more than 1 mode. Date: Wed, 5 Oct 2022 16:27:58 +0100 Message-Id: <20221005152809.3785786-6-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 driver currently has multiple assumptions that there is only one supported mode. Convert supported_mode to an array, and fix up all references to correctly look at that array. Signed-off-by: Dave Stevenson Reviewed-by: Jacopo Mondi --- drivers/media/i2c/ov9282.c | 44 ++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index 798ff8ba50bd..f7823d584522 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -262,20 +262,24 @@ static const struct ov9282_reg mode_1280x720_regs[] = { }; /* Supported sensor mode configurations */ -static const struct ov9282_mode supported_mode = { - .width = 1280, - .height = 720, - .hblank = 250, - .vblank = 1022, - .vblank_min = 151, - .vblank_max = 51540, - .link_freq_idx = 0, - .reg_list = { - .num_of_regs = ARRAY_SIZE(mode_1280x720_regs), - .regs = mode_1280x720_regs, +static const struct ov9282_mode supported_modes[] = { + { + .width = 1280, + .height = 720, + .hblank = 250, + .vblank = 1022, + .vblank_min = 151, + .vblank_max = 51540, + .link_freq_idx = 0, + .reg_list = { + .num_of_regs = ARRAY_SIZE(mode_1280x720_regs), + .regs = mode_1280x720_regs, + }, }, }; +#define OV9282_NUM_MODES ARRAY_SIZE(supported_modes) + /** * to_ov9282() - ov9282 V4L2 sub-device to ov9282 device. * @subdev: pointer to ov9282 V4L2 sub-device @@ -536,15 +540,15 @@ static int ov9282_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_frame_size_enum *fsize) { - if (fsize->index > 0) + if (fsize->index >= OV9282_NUM_MODES) return -EINVAL; if (fsize->code != MEDIA_BUS_FMT_Y10_1X10) return -EINVAL; - fsize->min_width = supported_mode.width; + fsize->min_width = supported_modes[fsize->index].width; fsize->max_width = fsize->min_width; - fsize->min_height = supported_mode.height; + fsize->min_height = supported_modes[fsize->index].height; fsize->max_height = fsize->min_height; return 0; @@ -619,7 +623,11 @@ static int ov9282_set_pad_format(struct v4l2_subdev *sd, mutex_lock(&ov9282->mutex); - mode = &supported_mode; + mode = v4l2_find_nearest_size(supported_modes, + OV9282_NUM_MODES, + width, height, + fmt->format.width, + fmt->format.height); ov9282_fill_pad_format(ov9282, mode, fmt); if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { @@ -652,7 +660,7 @@ static int ov9282_init_pad_cfg(struct v4l2_subdev *sd, struct v4l2_subdev_format fmt = { 0 }; fmt.which = sd_state ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; - ov9282_fill_pad_format(ov9282, &supported_mode, &fmt); + ov9282_fill_pad_format(ov9282, &supported_modes[0], &fmt); return ov9282_set_pad_format(sd, sd_state, &fmt); } @@ -1081,8 +1089,8 @@ static int ov9282_probe(struct i2c_client *client) goto error_power_off; } - /* Set default mode to max resolution */ - ov9282->cur_mode = &supported_mode; + /* Set default mode to first mode */ + ov9282->cur_mode = &supported_modes[0]; ov9282->vblank = ov9282->cur_mode->vblank; ret = ov9282_init_controls(ov9282); 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: 12999391 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:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 12999392 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 40A33C433FE for ; Wed, 5 Oct 2022 15:28:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230463AbiJEP26 (ORCPT ); Wed, 5 Oct 2022 11:28:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230456AbiJEP2y (ORCPT ); Wed, 5 Oct 2022 11:28:54 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18F0061709 for ; Wed, 5 Oct 2022 08:28:54 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id w18so17743246wro.7 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=4bnTMT1ECV0+8G4nsiyDVtLIQnvHl+1RKBB8Wab7ZcY=; b=FyUdamdk3HzAB2BYCnovcQMN9KkjneLq8UMM8Rp/naKb83EEEXuLiQ0+/nfmVc4m8a 2R4VG7G+m+0Gihv3wdhjxKxIi10Epib3AWhksEFeT1CVYee9EOhY5Z2KM/qNSMunvJau xcN1RFvEJfBr0WumpzbCGGJRBHARzRYT48Qo8pzgHYoWkV5i3GLIcaCnsCVrNJHw2R1n c35NwmlBobHhUXI8NYmq26F/8tQAZ9gqv8ZM1X9RRwrqfbNmzKh4r+fyFrcg24w6lm5L 7h0JOj8Lt/0LJdPhdWV+3mtZuCvTbjYXRIzELbvhsEh0ylTzVw//uEhs9sQs+CS2LykY EfyA== 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=4bnTMT1ECV0+8G4nsiyDVtLIQnvHl+1RKBB8Wab7ZcY=; b=dFRoDa8qmY50p7sXsVtwXdoH9jTQmnb2RDZWeSPvib2axJZbrUBZFg5xUjD5YQ457q qGMtj6Elwi9UfYnz0axHlD95AFHW+1oaOjKoxcJPX9NnIDD0YhnqIscTDttuyWF34rvg MFXI1Wi34maiZATaOVPBN89m4zTpYrcQGVeBJwAkZxUHmrsXrd0Z5usCoBTKQ4Pzm/G+ uzUMa0XKueIDE4A2toOqCwEki+waqhYksW3mS11QfuTsyfSzE2MTW00eZOFpt1sg09NW cpPSW3MaOalLz3BpVxRYo1jjszJJqEM/bQo/IQR0DnuBNrdyR9y5+J2Wy//J5c90ve0i VjvQ== X-Gm-Message-State: ACrzQf0XNGir1io6Fcttva5SLIvnGXqPdsGcaZ9pquz+jZp3VZEvyssZ WKMxrwfeo2rc7ROYSj5HkD/yWQ== X-Google-Smtp-Source: AMsMyM4+tawjfy6Ygi3zczOpsm8XteN23JR+jbkkDDCM6CxWFc2T3tM1AjA5umtZ0paHWKyQXNYUSw== X-Received: by 2002:a5d:65c4:0:b0:22c:dbdd:7177 with SMTP id e4-20020a5d65c4000000b0022cdbdd7177mr200489wrw.470.1664983732729; Wed, 05 Oct 2022 08:28:52 -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.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 08:28:52 -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 07/16] media: i2c: ov9282: Reduce vblank_min values based on testing Date: Wed, 5 Oct 2022 16:28:00 +0100 Message-Id: <20221005152809.3785786-8-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 configured vblank_min setting of 250 (meaning VTS of 720 + 250 = 970) is far higher than the setting that works on the sensor, and there are no obvious restrictions stated in the datasheet. Reduce the vblank_min to allow for faster frame rates. Signed-off-by: Dave Stevenson --- drivers/media/i2c/ov9282.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index 1cd6cb4addfb..abb1223c0260 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -268,7 +268,7 @@ static const struct ov9282_mode supported_modes[] = { .height = 720, .hblank = 250, .vblank = 1022, - .vblank_min = 151, + .vblank_min = 41, .vblank_max = 51540, .link_freq_idx = 0, .reg_list = { From patchwork Wed Oct 5 15:28:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 12999394 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 84F70C433F5 for ; Wed, 5 Oct 2022 15:29:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230456AbiJEP3A (ORCPT ); Wed, 5 Oct 2022 11:29:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230460AbiJEP24 (ORCPT ); Wed, 5 Oct 2022 11:28:56 -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 1C6FD61709 for ; Wed, 5 Oct 2022 08:28:55 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id b4so19544597wrs.1 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=zlo94kx4d/0h4pXbHO90YkVJN9vv7NJ7f1xqV+w4aSk=; b=KFWC/4eYIFbRKVqKYeSpjXdMxe8bbzsgmkCvNXOTZxlaHJRhNtAmg025qHpy01gUxY LshgslbbW7zoGivy+zhuZs0YSKsY7hAGVbFmSbhVjKYOZ6mkDniwkFC33dx1ONTIqSbk 1ELDv5tkLMDi1kiYlht7+THObyTOLl2fhkUberKKWkqFv8z9fniR/FBv/zxyHUrQUZIu 2OWWAPeL7L/xzwezBQVeOahgG1oThXs7eQzPLzw+UozG4p3BYfiFYBs3l/y7WELKdQwd 0SUr/B6rQKa2KebKqCChJNs0mnyelGhdYWY4gQ42gk5p100qPvAxGham5CEfdxexqExh dCFQ== 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=zlo94kx4d/0h4pXbHO90YkVJN9vv7NJ7f1xqV+w4aSk=; b=NAC4GyUtu/j+4TWXqus0mSIFL3lROyViF5gQclcUaE1M2rAPDpmO1C8s1lOmdtfGLe YTA9Z+8ZypJKnBLI3agzzCYS+s6enDoXxWW8LmnHJ1b09iFksGsYR+33Bz+JzIe8sTv6 r0YNOb7EwXndiA0190YFLsZwlPbY+MezWorJYj7XdZdPGFEEPMbbzKOkcIhPp4Vka7Nw Zde4oCFF0s+Brwf0GBt3EIaBxi0sES6CcO14BvaQWAjRf81mY0UwhLHPQosat2eZe03i my+ampLmdT8QRQIW40F7m0PtEPhzyKKT7PB7w0/4QSJEF4XNDPyMkG/CwgKoJAYWhd7n vUFg== X-Gm-Message-State: ACrzQf1ioTBpmMNRoJik+Uagy/88fyz+5ux0JzWE+2GlwmfxIcM3b9Cr EgUb8nnp7JvtQXaGM1vH12Y6mA== X-Google-Smtp-Source: AMsMyM7L809sxZHq+IW2V016tulXRpQFYEM1C3I6vpQFyGdZm2spAMBAFEQT4BwhBYu4yfLMA35x+w== X-Received: by 2002:a05:6000:1f81:b0:22c:c692:5c49 with SMTP id bw1-20020a0560001f8100b0022cc6925c49mr194276wrb.630.1664983733614; Wed, 05 Oct 2022 08:28:53 -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.52 (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 08/16] media: i2c: ov9282: Add selection for CSI2 clock mode Date: Wed, 5 Oct 2022 16:28:01 +0100 Message-Id: <20221005152809.3785786-9-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 sensor supports either having the CSI2 clock lane free running, or gated when there is no packet to transmit. The driver only selected gated (non-continuous) clock mode. Add code to allow fwnode to configure whether the clock is gated or free running. Signed-off-by: Dave Stevenson Reviewed-by: Jacopo Mondi --- drivers/media/i2c/ov9282.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index abb1223c0260..334b31af34a4 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -46,6 +46,9 @@ /* Group hold register */ #define OV9282_REG_HOLD 0x3308 +#define OV9282_REG_MIPI_CTRL00 0x4800 +#define OV9282_GATED_CLOCK BIT(5) + /* Input clock rate */ #define OV9282_INCLK_RATE 24000000 @@ -138,6 +141,7 @@ struct ov9282 { struct clk *inclk; struct regulator_bulk_data supplies[OV9282_NUM_SUPPLIES]; struct v4l2_ctrl_handler ctrl_handler; + bool noncontinuous_clock; struct v4l2_ctrl *link_freq_ctrl; struct v4l2_ctrl *hblank_ctrl; struct v4l2_ctrl *vblank_ctrl; @@ -211,7 +215,6 @@ static const struct ov9282_reg common_regs[] = { {0x4601, 0x04}, {0x470f, 0x00}, {0x4f07, 0x00}, - {0x4800, 0x20}, {0x5000, 0x9f}, {0x5001, 0x00}, {0x5e00, 0x00}, @@ -684,6 +687,14 @@ static int ov9282_start_streaming(struct ov9282 *ov9282) return ret; } + ret = ov9282_write_reg(ov9282, OV9282_REG_MIPI_CTRL00, 1, + ov9282->noncontinuous_clock ? + OV9282_GATED_CLOCK : 0); + if (ret) { + dev_err(ov9282->dev, "fail to write MIPI_CTRL00"); + 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); @@ -861,6 +872,9 @@ static int ov9282_parse_hw_config(struct ov9282 *ov9282) if (ret) return ret; + ov9282->noncontinuous_clock = + bus_cfg.bus.mipi_csi2.flags & V4L2_MBUS_CSI2_NONCONTINUOUS_CLOCK; + if (bus_cfg.bus.mipi_csi2.num_data_lanes != OV9282_NUM_DATA_LANES) { dev_err(ov9282->dev, "number of CSI2 data lanes %d is not supported", 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: 12999393 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 Reviewed-by: Jacopo Mondi --- 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: 12999395 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 Reviewed-by: Jacopo Mondi --- 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:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 12999396 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 562A2C433FE for ; Wed, 5 Oct 2022 15:29:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230473AbiJEP3E (ORCPT ); Wed, 5 Oct 2022 11:29:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230465AbiJEP26 (ORCPT ); Wed, 5 Oct 2022 11:28:58 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF25072B42 for ; Wed, 5 Oct 2022 08:28:57 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id a10so14146004wrm.12 for ; Wed, 05 Oct 2022 08:28:57 -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=SJoBZQnUO4yW4+5QLRqRFjHqllPrldbqWp5Kd5yEpHE=; b=iWxKTQHDSFybHr2tnwpzYrfaein13S2bTn/0ol9UEMzoMEbcz+mwztpw+DJNcAPdLi agrWuiWrh7AIuOuE6OjPZiCnGkbwmnZcfY/dcHq43qGkuv1uj9MdVjcdX3cTtbrHULHS OPlKTfywmi3ypTMBWoMGP4oZHPw1AbEjXRi3N4CaL02Vwj6kOzgX2cpjDoUrqZnay/PA CO8Z1iCwEeT+ojH+r5Ch+axdPEGZm4iAvlTIym98O8qDld5gQJAG8SSVaOnJLg6urZdc 4pPAaTE1ut3uhHrY5Uc6r7b6bPqzqbWoGLFV721MJ5vvNzd2wR9HcLK5nN7+z17TWgOA FGIw== 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=SJoBZQnUO4yW4+5QLRqRFjHqllPrldbqWp5Kd5yEpHE=; b=nu+8KPcF42+Oxfl2EkXhLdWxHk08WdPJCifRpHDI6I9xqS0V76UKSgg8pNrLIIgb4j tJ22IKkNjmstcyEjjGgun8m+YIGmNsNIWv8vcY7uLk6EdorpZ90N0KB8qx0aElFaX4ef T0G9OdLjJhhrAu3B59viuXxl1UhMCZUohIFmJbHL+aRLAi9g3mck1FyEmug4eqEXx5BS 4ypOtYU2lsaC6liwLPlyTd+0mFNl2RSCWLP1QFAqqMyhhoiovrvvjaNIR1AlU7eNprnE uhs4o5ZZhYYBh+kdYWEvuyI7MlyLfTRZqTpZERUCql1ud5aHWeYs7DPwsHK77w9xAloC Dh6A== X-Gm-Message-State: ACrzQf2klLMTUPmh1g6PjwdV5GCH2WUPqxUf/b9INLJsZCLFvCCPfa4j 3kXwx3TJ0xgt1D9eVbqqL5jaqw== X-Google-Smtp-Source: AMsMyM6V29OVrQiBqb3PO1tfdFHAO0F+r2w3ZWSDpYQPyp+CPwn9p0jcI/VMPxilVHwjX71fEwslqA== X-Received: by 2002:a5d:5148:0:b0:22e:53bd:31c5 with SMTP id u8-20020a5d5148000000b0022e53bd31c5mr180625wrt.241.1664983736529; Wed, 05 Oct 2022 08:28:56 -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.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 08:28:55 -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 11/16] media: i2c: ov9282: Add HFLIP and VFLIP support Date: Wed, 5 Oct 2022 16:28:04 +0100 Message-Id: <20221005152809.3785786-12-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 support for V4L2_CID_HFLIP and V4L2_CID_VFLIP to allow flipping the image. The driver previously enabled H & V flips in the register table, therefore the controls default to the same settings to avoid changing the behaviour. Signed-off-by: Dave Stevenson --- drivers/media/i2c/ov9282.c | 52 +++++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index 5ddef6e2b3ac..12cbe401fd78 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -46,6 +46,10 @@ /* Group hold register */ #define OV9282_REG_HOLD 0x3308 +#define OV9282_REG_TIMING_FORMAT_1 0x3820 +#define OV9282_REG_TIMING_FORMAT_2 0x3821 +#define OV9282_FLIP_BIT BIT(2) + #define OV9282_REG_MIPI_CTRL00 0x4800 #define OV9282_GATED_CLOCK BIT(5) @@ -440,6 +444,38 @@ static int ov9282_update_exp_gain(struct ov9282 *ov9282, u32 exposure, u32 gain) return ret; } +static int ov9282_set_ctrl_hflip(struct ov9282 *ov9282, int value) +{ + u32 current_val; + int ret = ov9282_read_reg(ov9282, OV9282_REG_TIMING_FORMAT_2, 1, + ¤t_val); + if (!ret) { + if (value) + current_val |= OV9282_FLIP_BIT; + else + current_val &= ~OV9282_FLIP_BIT; + return ov9282_write_reg(ov9282, OV9282_REG_TIMING_FORMAT_2, 1, + current_val); + } + return ret; +} + +static int ov9282_set_ctrl_vflip(struct ov9282 *ov9282, int value) +{ + u32 current_val; + int ret = ov9282_read_reg(ov9282, OV9282_REG_TIMING_FORMAT_1, 1, + ¤t_val); + if (!ret) { + if (value) + current_val |= OV9282_FLIP_BIT; + else + current_val &= ~OV9282_FLIP_BIT; + return ov9282_write_reg(ov9282, OV9282_REG_TIMING_FORMAT_1, 1, + current_val); + } + return ret; +} + /** * ov9282_set_ctrl() - Set subdevice control * @ctrl: pointer to v4l2_ctrl structure @@ -484,7 +520,6 @@ static int ov9282_set_ctrl(struct v4l2_ctrl *ctrl) switch (ctrl->id) { case V4L2_CID_EXPOSURE: - exposure = ctrl->val; analog_gain = ov9282->again_ctrl->val; @@ -493,12 +528,17 @@ static int ov9282_set_ctrl(struct v4l2_ctrl *ctrl) ret = ov9282_update_exp_gain(ov9282, exposure, analog_gain); - break; case V4L2_CID_VBLANK: lpfr = ov9282->vblank + ov9282->cur_mode->height; ret = ov9282_write_reg(ov9282, OV9282_REG_LPFR, 2, lpfr); break; + case V4L2_CID_HFLIP: + ret = ov9282_set_ctrl_hflip(ov9282, ctrl->val); + break; + case V4L2_CID_VFLIP: + ret = ov9282_set_ctrl_vflip(ov9282, ctrl->val); + break; default: dev_err(ov9282->dev, "Invalid control %d", ctrl->id); ret = -EINVAL; @@ -996,7 +1036,7 @@ static int ov9282_init_controls(struct ov9282 *ov9282) u32 lpfr; int ret; - ret = v4l2_ctrl_handler_init(ctrl_hdlr, 8); + ret = v4l2_ctrl_handler_init(ctrl_hdlr, 10); if (ret) return ret; @@ -1030,6 +1070,12 @@ static int ov9282_init_controls(struct ov9282 *ov9282) mode->vblank_max, 1, mode->vblank); + v4l2_ctrl_new_std(ctrl_hdlr, &ov9282_ctrl_ops, V4L2_CID_VFLIP, + 0, 1, 1, 1); + + v4l2_ctrl_new_std(ctrl_hdlr, &ov9282_ctrl_ops, V4L2_CID_HFLIP, + 0, 1, 1, 1); + /* Read only controls */ v4l2_ctrl_new_std(ctrl_hdlr, &ov9282_ctrl_ops, V4L2_CID_PIXEL_RATE, OV9282_PIXEL_RATE, OV9282_PIXEL_RATE, 1, 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: 12999397 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 Reviewed-by: Jacopo Mondi --- 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:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 12999398 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 2E942C4332F for ; Wed, 5 Oct 2022 15:29:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230469AbiJEP3G (ORCPT ); Wed, 5 Oct 2022 11:29:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230470AbiJEP3A (ORCPT ); Wed, 5 Oct 2022 11:29:00 -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 8A7F6760C0 for ; Wed, 5 Oct 2022 08:28:59 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id bg9-20020a05600c3c8900b003bf249616b0so1064587wmb.3 for ; Wed, 05 Oct 2022 08:28:59 -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=01a+eYyocqSQT4oHgnQCSByq5FcmY7rLPJBSaZ0ZxC4=; b=DWI+ZDqo1zDs5557wPIGc8ZMPjyXgb4UDc1q1n8R9i9uVE9Zo3LfigQ0vp9Z76lOV/ e0SFCedkQBRcaSKLzUZBMDG7Mtj4VY0I9ZIoiyLnkI2a6puB+yriOfg+9cCMfBqbx5wS qij0BKNPW6lY8IK2RmMSeu1Hs7ebhAgnD/ygMXMLQAdTArrAGT28VOBETP/wNjkwMCqM Sf8XALKPAhTfgCW0S4Jj4GF2uF+SC06NHKi3jCYFCyDa+DWApN3oH6KOTfglhKGQUttY oiHH4fSOvKWBASgFgiFFnpzskfLA7ddpLZeqlJAfoosZqONI+bbnxNPoEt4fjXooDxjb wCQQ== 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=01a+eYyocqSQT4oHgnQCSByq5FcmY7rLPJBSaZ0ZxC4=; b=4IklzJUMBO7/nWEWJ1a/oMWSzDysQukx98JLFThM4drS4F8mdc4Yk7WtZunwb+1NS4 fFePPTbWwa5uAoPNstgO2+u3lsIC0jft+maff76LH7Rp4+Q+ByUKJCvjkI9qYuqzOx0g 5QmcCcaVVWEwLHizOZ6Jh7VZtYpkDyN03HP556tSJnXqTEIwhUzCZQmB9/AiOljAcBqy JwHJNbrszVsPZfyKAcke7nyW6rMPXvGYsjQQ96Oic40g9sfqSM2+wAsaQdaJhvbbUQhB R57zSgApcTLbG3YttN6idjlFWy+UJE3moxYitc8RN8klQ5TCyXA6aGtJC/g91XwrbBy1 bDoQ== X-Gm-Message-State: ACrzQf26Adnr/h4ZMkXN8GyR/zUnKjLmmBDPdCpUt/iHOSLrbR/9/Mmy yPFLCMqx/EQjoHztBtcKV2gygQ== X-Google-Smtp-Source: AMsMyM6rdai+9U/8/oJ+TOFEHGJAfIoSaQ6PWI82A1OYE+WeHdlbjVWh/utGgNAHCOxyIl1XzJUWIQ== X-Received: by 2002:a05:600c:3b1f:b0:3b4:b1fc:4797 with SMTP id m31-20020a05600c3b1f00b003b4b1fc4797mr3745647wms.129.1664983739104; Wed, 05 Oct 2022 08:28:59 -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.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 08:28:58 -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 13/16] media: i2c: ov9282: Add selection API calls for cropping info Date: Wed, 5 Oct 2022 16:28:06 +0100 Message-Id: <20221005152809.3785786-14-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 required by libcamera, add the relevant cropping targets to report which portion of the sensor is being read out in any mode. Signed-off-by: Dave Stevenson Reviewed-by: Jacopo Mondi --- drivers/media/i2c/ov9282.c | 75 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index 8e86aa7e4b2a..d892f53fb1ea 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -67,6 +67,17 @@ #define OV9282_PIXEL_RATE (OV9282_LINK_FREQ * 2 * \ OV9282_NUM_DATA_LANES / 10) +/* + * OV9282 native and active pixel array size. + * 8 dummy rows/columns on each edge of a 1280x800 active array + */ +#define OV9282_NATIVE_WIDTH 1296U +#define OV9282_NATIVE_HEIGHT 816U +#define OV9282_PIXEL_ARRAY_LEFT 8U +#define OV9282_PIXEL_ARRAY_TOP 8U +#define OV9282_PIXEL_ARRAY_WIDTH 1280U +#define OV9282_PIXEL_ARRAY_HEIGHT 800U + #define OV9282_REG_MIN 0x00 #define OV9282_REG_MAX 0xfffff @@ -118,6 +129,7 @@ struct ov9282_mode { u32 vblank_min; u32 vblank_max; u32 link_freq_idx; + struct v4l2_rect crop; struct ov9282_reg_list reg_list; }; @@ -280,6 +292,16 @@ static const struct ov9282_mode supported_modes[] = { .vblank_min = 41, .vblank_max = 51540, .link_freq_idx = 0, + .crop = { + /* + * Note that this mode takes the top 720 lines from the + * 800 of the sensor. It does not take a middle crop. + */ + .left = OV9282_PIXEL_ARRAY_LEFT, + .top = OV9282_PIXEL_ARRAY_TOP, + .width = 1280, + .height = 720 + }, .reg_list = { .num_of_regs = ARRAY_SIZE(mode_1280x720_regs), .regs = mode_1280x720_regs, @@ -719,6 +741,58 @@ static int ov9282_init_pad_cfg(struct v4l2_subdev *sd, return ov9282_set_pad_format(sd, sd_state, &fmt); } +static const struct v4l2_rect * +__ov9282_get_pad_crop(struct ov9282 *ov9282, + struct v4l2_subdev_state *sd_state, + unsigned int pad, enum v4l2_subdev_format_whence which) +{ + switch (which) { + case V4L2_SUBDEV_FORMAT_TRY: + return v4l2_subdev_get_try_crop(&ov9282->sd, sd_state, pad); + case V4L2_SUBDEV_FORMAT_ACTIVE: + return &ov9282->cur_mode->crop; + } + + return NULL; +} + +static int ov9282_get_selection(struct v4l2_subdev *sd, + struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_selection *sel) +{ + switch (sel->target) { + case V4L2_SEL_TGT_CROP: { + struct ov9282 *ov9282 = to_ov9282(sd); + + mutex_lock(&ov9282->mutex); + sel->r = *__ov9282_get_pad_crop(ov9282, sd_state, sel->pad, + sel->which); + mutex_unlock(&ov9282->mutex); + + return 0; + } + + case V4L2_SEL_TGT_NATIVE_SIZE: + sel->r.top = 0; + sel->r.left = 0; + sel->r.width = OV9282_NATIVE_WIDTH; + sel->r.height = OV9282_NATIVE_HEIGHT; + + return 0; + + case V4L2_SEL_TGT_CROP_DEFAULT: + case V4L2_SEL_TGT_CROP_BOUNDS: + sel->r.top = OV9282_PIXEL_ARRAY_TOP; + sel->r.left = OV9282_PIXEL_ARRAY_LEFT; + sel->r.width = OV9282_PIXEL_ARRAY_WIDTH; + sel->r.height = OV9282_PIXEL_ARRAY_HEIGHT; + + return 0; + } + + return -EINVAL; +} + /** * ov9282_start_streaming() - Start sensor stream * @ov9282: pointer to ov9282 device @@ -963,6 +1037,7 @@ static const struct v4l2_subdev_pad_ops ov9282_pad_ops = { .enum_frame_size = ov9282_enum_frame_size, .get_fmt = ov9282_get_pad_format, .set_fmt = ov9282_set_pad_format, + .get_selection = ov9282_get_selection, }; static const struct v4l2_subdev_ops ov9282_subdev_ops = { 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: 12999399 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 Reviewed-by: Jacopo Mondi --- 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:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 12999400 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 4BE4DC433FE for ; Wed, 5 Oct 2022 15:29:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230474AbiJEP3I (ORCPT ); Wed, 5 Oct 2022 11:29:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230460AbiJEP3D (ORCPT ); Wed, 5 Oct 2022 11:29:03 -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 777D972B56 for ; Wed, 5 Oct 2022 08:29:01 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id b4so19545085wrs.1 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=6tqbfMZn/qKVxwCmKqdYTLrxuNh178oqQVD9Dfpa8v0=; b=IESiIupHZats4CI1DF3eXC5VoqaHJ01oWzhRRdeaf26TPGSUdg4+uVGhxlnz9Bf/gO 3PAmpgDsHrMNqMDg1UNEPGqQ/G3roRfOF1+au5iBhqVCAiqzh9+1c0iBSX+4kYQEAccn T5UgbALHJNPz3QzOSM++WgurajCCe6h3ugh3WeUxWSI33aImhhlOpmt4Zdu5gtWehxxp IvxIfM4RZXwMHZGG3IwctsjLsgAwMYliJ+qJcWVunCzs8yEZhMjsggOCFkgK78iWr0HD 5C86cTu0ylT0POSxEdt7dohf7Y2bpeXnizwAuS2LlPxFZYX0gyx8dm0evUjJieKwHrDE zCUw== 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=6tqbfMZn/qKVxwCmKqdYTLrxuNh178oqQVD9Dfpa8v0=; b=otIBn36P2xXiNx+Pvpc0iNxPLthqn3V5VRMJwVnIuXzNaLuoirW/hZ0Z/IuzIt2zXQ g0VK6WET7K1tOXi7jetz2LQUhWIqop+bTsS85L7hBr0X9Wlx35Q31KSvE2hUQ3eh7JUu M5NxaDWkNmM0XdyVYKF6CdOgMQQ5OYL7BjEhTv3KLugRzrkqsgpdyenVHosptSG+YY1X SDq4e+/++VJXqlxsq9kcMqjTxMx49LzqkUl0GF+Y0xFl4gtyAgeqEuLrMq0nnj82MYnG +a32eXdDhW+EwGq8vWuen46wP2kMGTon+2OxEN6tdPFmzFFyT7tJ+LfGGPDSmv+v+AjB E1rA== X-Gm-Message-State: ACrzQf3OXN9Ky9ZXlL0K/1hQYu2tg7BJ98sJYPYBJQoIirtrSgvrztap 2FtR8RUn7A5xcRvc5UkQ3Zz7QQ== X-Google-Smtp-Source: AMsMyM406+NESq22e2cBPEsS7IPsBqWgOjW6UDxknIzDY4wPxkz9T+Dkw1PZjpC9TqlSVeHWG9jFmA== X-Received: by 2002:a5d:5010:0:b0:22a:cb71:9493 with SMTP id e16-20020a5d5010000000b0022acb719493mr207652wrt.514.1664983740980; 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.29.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 08:29:00 -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 15/16] media: i2c: ov9282: Add support for 8bit readout Date: Wed, 5 Oct 2022 16:28:08 +0100 Message-Id: <20221005152809.3785786-16-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 sensor supports 8 or 10 bit readout modes, but the driver only supported 10 bit. Add 8 bit readout. Signed-off-by: Dave Stevenson --- drivers/media/i2c/ov9282.c | 110 ++++++++++++++++++++++++++++++------- 1 file changed, 89 insertions(+), 21 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index ec1599488f21..bc429455421e 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -22,6 +22,10 @@ #define OV9282_MODE_STANDBY 0x00 #define OV9282_MODE_STREAMING 0x01 +#define OV9282_REG_PLL_CTRL_0D 0x030d +#define OV9282_PLL_CTRL_0D_RAW8 0x60 +#define OV9282_PLL_CTRL_0D_RAW10 0x50 + #define OV9282_REG_TIMING_HTS 0x380c #define OV9282_TIMING_HTS_MAX 0x7fff @@ -49,6 +53,10 @@ /* Group hold register */ #define OV9282_REG_HOLD 0x3308 +#define OV9282_REG_ANA_CORE_2 0x3662 +#define OV9282_ANA_CORE2_RAW8 0x07 +#define OV9282_ANA_CORE2_RAW10 0x05 + #define OV9282_REG_TIMING_FORMAT_1 0x3820 #define OV9282_REG_TIMING_FORMAT_2 0x3821 #define OV9282_FLIP_BIT BIT(2) @@ -64,8 +72,10 @@ #define OV9282_NUM_DATA_LANES 2 /* Pixel rate */ -#define OV9282_PIXEL_RATE (OV9282_LINK_FREQ * 2 * \ - OV9282_NUM_DATA_LANES / 10) +#define OV9282_PIXEL_RATE_10BIT (OV9282_LINK_FREQ * 2 * \ + OV9282_NUM_DATA_LANES / 10) +#define OV9282_PIXEL_RATE_8BIT (OV9282_LINK_FREQ * 2 * \ + OV9282_NUM_DATA_LANES / 8) /* * OV9282 native and active pixel array size. @@ -149,6 +159,7 @@ struct ov9282_mode { * @again_ctrl: Pointer to analog gain control * @vblank: Vertical blanking in lines * @cur_mode: Pointer to current selected sensor mode + * @code: Mbus code currently selected * @mutex: Mutex for serializing sensor controls * @streaming: Flag indicating streaming state */ @@ -169,8 +180,10 @@ struct ov9282 { struct v4l2_ctrl *exp_ctrl; struct v4l2_ctrl *again_ctrl; }; + struct v4l2_ctrl *pixel_rate; u32 vblank; const struct ov9282_mode *cur_mode; + u32 code; struct mutex mutex; bool streaming; }; @@ -182,7 +195,6 @@ static const s64 link_freq[] = { /* Common registers */ static const struct ov9282_reg common_regs[] = { {0x0302, 0x32}, - {0x030d, 0x50}, {0x030e, 0x02}, {0x3001, 0x00}, {0x3004, 0x00}, @@ -514,23 +526,41 @@ static int ov9282_write_regs(struct ov9282 *ov9282, * ov9282_update_controls() - Update control ranges based on streaming mode * @ov9282: pointer to ov9282 device * @mode: pointer to ov9282_mode sensor mode + * @fmt: pointer to the requested mode * * Return: 0 if successful, error code otherwise. */ static int ov9282_update_controls(struct ov9282 *ov9282, - const struct ov9282_mode *mode) + const struct ov9282_mode *mode, + const struct v4l2_subdev_format *fmt) { u32 hblank_min; + s64 pixel_rate; int ret; ret = __v4l2_ctrl_s_ctrl(ov9282->link_freq_ctrl, mode->link_freq_idx); 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); + pixel_rate = (fmt->format.code == MEDIA_BUS_FMT_Y10_1X10) ? + OV9282_PIXEL_RATE_10BIT : OV9282_PIXEL_RATE_8BIT; + ret = __v4l2_ctrl_modify_range(ov9282->pixel_rate, pixel_rate, + pixel_rate, 1, pixel_rate); + if (ret) + return ret; + + if (ov9282->cur_mode != mode) { + 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); + if (ret) + return ret; + + ret = __v4l2_ctrl_s_ctrl(ov9282->hblank_ctrl, hblank_min); + if (ret) + return ret; + } return __v4l2_ctrl_modify_range(ov9282->vblank_ctrl, mode->vblank_min, mode->vblank_max, 1, mode->vblank); @@ -693,10 +723,16 @@ static int ov9282_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_mbus_code_enum *code) { - if (code->index > 0) + switch (code->index) { + default: return -EINVAL; - - code->code = MEDIA_BUS_FMT_Y10_1X10; + case 0: + code->code = MEDIA_BUS_FMT_Y10_1X10; + break; + case 1: + code->code = MEDIA_BUS_FMT_Y8_1X8; + break; + } return 0; } @@ -716,7 +752,8 @@ static int ov9282_enum_frame_size(struct v4l2_subdev *sd, if (fsize->index >= OV9282_NUM_MODES) return -EINVAL; - if (fsize->code != MEDIA_BUS_FMT_Y10_1X10) + if (fsize->code != MEDIA_BUS_FMT_Y10_1X10 && + fsize->code != MEDIA_BUS_FMT_Y8_1X8) return -EINVAL; fsize->min_width = supported_modes[fsize->index].width; @@ -732,15 +769,17 @@ static int ov9282_enum_frame_size(struct v4l2_subdev *sd, * from selected sensor mode * @ov9282: pointer to ov9282 device * @mode: pointer to ov9282_mode sensor mode + * @code: mbus code to be stored * @fmt: V4L2 sub-device format need to be filled */ static void ov9282_fill_pad_format(struct ov9282 *ov9282, const struct ov9282_mode *mode, + u32 code, struct v4l2_subdev_format *fmt) { fmt->format.width = mode->width; fmt->format.height = mode->height; - fmt->format.code = MEDIA_BUS_FMT_Y10_1X10; + fmt->format.code = code; fmt->format.field = V4L2_FIELD_NONE; fmt->format.colorspace = V4L2_COLORSPACE_RAW; fmt->format.ycbcr_enc = V4L2_YCBCR_ENC_DEFAULT; @@ -770,7 +809,8 @@ static int ov9282_get_pad_format(struct v4l2_subdev *sd, framefmt = v4l2_subdev_get_try_format(sd, sd_state, fmt->pad); fmt->format = *framefmt; } else { - ov9282_fill_pad_format(ov9282, ov9282->cur_mode, fmt); + ov9282_fill_pad_format(ov9282, ov9282->cur_mode, ov9282->code, + fmt); } mutex_unlock(&ov9282->mutex); @@ -792,6 +832,7 @@ static int ov9282_set_pad_format(struct v4l2_subdev *sd, { struct ov9282 *ov9282 = to_ov9282(sd); const struct ov9282_mode *mode; + u32 code; int ret = 0; mutex_lock(&ov9282->mutex); @@ -801,7 +842,12 @@ static int ov9282_set_pad_format(struct v4l2_subdev *sd, width, height, fmt->format.width, fmt->format.height); - ov9282_fill_pad_format(ov9282, mode, fmt); + if (fmt->format.code == MEDIA_BUS_FMT_Y8_1X8) + code = MEDIA_BUS_FMT_Y8_1X8; + else + code = MEDIA_BUS_FMT_Y10_1X10; + + ov9282_fill_pad_format(ov9282, mode, code, fmt); if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { struct v4l2_mbus_framefmt *framefmt; @@ -809,9 +855,11 @@ static int ov9282_set_pad_format(struct v4l2_subdev *sd, framefmt = v4l2_subdev_get_try_format(sd, sd_state, fmt->pad); *framefmt = fmt->format; } else { - ret = ov9282_update_controls(ov9282, mode); - if (!ret) + ret = ov9282_update_controls(ov9282, mode, fmt); + if (!ret) { ov9282->cur_mode = mode; + ov9282->code = code; + } } mutex_unlock(&ov9282->mutex); @@ -833,7 +881,7 @@ static int ov9282_init_pad_cfg(struct v4l2_subdev *sd, struct v4l2_subdev_format fmt = { 0 }; fmt.which = sd_state ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE; - ov9282_fill_pad_format(ov9282, &supported_modes[0], &fmt); + ov9282_fill_pad_format(ov9282, &supported_modes[0], ov9282->code, &fmt); return ov9282_set_pad_format(sd, sd_state, &fmt); } @@ -898,7 +946,17 @@ static int ov9282_get_selection(struct v4l2_subdev *sd, */ static int ov9282_start_streaming(struct ov9282 *ov9282) { + const struct ov9282_reg bitdepth_regs[2][2] = { + { + {OV9282_REG_PLL_CTRL_0D, OV9282_PLL_CTRL_0D_RAW10}, + {OV9282_REG_ANA_CORE_2, OV9282_ANA_CORE2_RAW10}, + }, { + {OV9282_REG_PLL_CTRL_0D, OV9282_PLL_CTRL_0D_RAW8}, + {OV9282_REG_ANA_CORE_2, OV9282_ANA_CORE2_RAW8}, + } + }; const struct ov9282_reg_list *reg_list; + int bitdepth_index; int ret; /* Write common registers */ @@ -917,6 +975,13 @@ static int ov9282_start_streaming(struct ov9282 *ov9282) return ret; } + bitdepth_index = ov9282->code == MEDIA_BUS_FMT_Y10_1X10 ? 0 : 1; + ret = ov9282_write_regs(ov9282, bitdepth_regs[bitdepth_index], 2); + if (ret) { + dev_err(ov9282->dev, "fail to write bitdepth regs"); + 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); @@ -1258,9 +1323,11 @@ static int ov9282_init_controls(struct ov9282 *ov9282) 0, 1, 1, 1); /* Read only controls */ - v4l2_ctrl_new_std(ctrl_hdlr, &ov9282_ctrl_ops, V4L2_CID_PIXEL_RATE, - OV9282_PIXEL_RATE, OV9282_PIXEL_RATE, 1, - OV9282_PIXEL_RATE); + ov9282->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, &ov9282_ctrl_ops, + V4L2_CID_PIXEL_RATE, + OV9282_PIXEL_RATE_10BIT, + OV9282_PIXEL_RATE_10BIT, 1, + OV9282_PIXEL_RATE_10BIT); ov9282->link_freq_ctrl = v4l2_ctrl_new_int_menu(ctrl_hdlr, &ov9282_ctrl_ops, @@ -1342,6 +1409,7 @@ static int ov9282_probe(struct i2c_client *client) /* Set default mode to first mode */ ov9282->cur_mode = &supported_modes[0]; + ov9282->code = MEDIA_BUS_FMT_Y10_1X10; ov9282->vblank = ov9282->cur_mode->vblank; ret = ov9282_init_controls(ov9282); 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: 12999401 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 */