From patchwork Sun Oct 13 12:50:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 11187399 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 50F68112B for ; Sun, 13 Oct 2019 12:52:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 311E12082F for ; Sun, 13 Oct 2019 12:52:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VV1QMnkZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729294AbfJMMwF (ORCPT ); Sun, 13 Oct 2019 08:52:05 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:43117 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729187AbfJMMvw (ORCPT ); Sun, 13 Oct 2019 08:51:52 -0400 Received: by mail-lj1-f195.google.com with SMTP id n14so13949444ljj.10; Sun, 13 Oct 2019 05:51:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=N5xwppzxLfD235nBWm/2lMus5/8Z/i+yMzV4wj9LsE4=; b=VV1QMnkZm/jSR163JgojCsqmbsoTL0r+24dV0TYzmuH85a/7PzgVyXdS+WGMo8S3rI zxl9zUy2vFcWgYSoX8j7nk51PSSUGZ4f1xM4FTP+OuBKtu3Rc8yGcGbhX0nK+LITod+m I4hy8cBdfQSLF4lqpq7mMHeekhc7b+WHRmWNJJGq9o4BmioWQFCWjOYQ07n47wEdHD9n NULXj71kKHVwCw6jmURC8ooqBH6dOgUCOgNVL1hWugH1McsLd14owdWwgfE89cNZ5ZUK FnW3KE2IUyXI3b4oIB1xEE+G8oeWluzjMMreMAeLObhytzgtFbcYw99/GKcK9652h7Ft 3ofA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=N5xwppzxLfD235nBWm/2lMus5/8Z/i+yMzV4wj9LsE4=; b=gnCgX57tJKSmiZhxlZc3vIuzxmOb5mh5/WbLXMC/BwKogFLF/TVr2CVk8COTpnE4Uh bI4Dbf7k/ZI4W70q3DAIGYz4cCJyVpo3tEf2FQL8RKq++D5SIe0LtQtkJagYP1rVZbBN mMNHqc3ybnQ7W9gB+cdGuH7H2swh98Juqu33bK/Koxkah5B5rOlQzYLHjpDzP0I07Pl8 lD973zRvxbdK4W3J2l/q1pro4OJfr26XMERONMVA1HYoC2UQjQqjUakwV5MSPyW/N0tW ZxQMEt0Z9E4FPKTPL+FuCDXx9cLAAtkWWu4vb3Y8aD9s0Qnt69AW6z1ja5pbHHvEUXGs FITA== X-Gm-Message-State: APjAAAVjq5ZsUJr0nla56XdIVrEyBqUmRBjzngVzZq99olQRg4zyZZIG AOwSIb/Ccot/ibaV3o0fvxQ= X-Google-Smtp-Source: APXvYqzXMz8SnBPIqokeFzd8nC9MNXRRuEHd2i6zONnC9nXuFWMjoh43nA50NaOh/HPRUev76wvT2A== X-Received: by 2002:a2e:207:: with SMTP id 7mr15412581ljc.248.1570971109117; Sun, 13 Oct 2019 05:51:49 -0700 (PDT) Received: from z50.gdansk-morena.vectranet.pl (109241207190.gdansk.vectranet.pl. [109.241.207.190]) by smtp.gmail.com with ESMTPSA id m18sm3327243lfb.73.2019.10.13.05.51.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 13 Oct 2019 05:51:48 -0700 (PDT) From: Janusz Krzysztofik To: Sakari Ailus Cc: Mauro Carvalho Chehab , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH 4/6] media: ov6650: Don't reapply pixel clock divisor on format change Date: Sun, 13 Oct 2019 14:50:48 +0200 Message-Id: <20191013125050.4153-5-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191013125050.4153-1-jmkrzyszt@gmail.com> References: <20191013125050.4153-1-jmkrzyszt@gmail.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org As calculation of pixel clock hardware divisor no longer depends on mbus format specific maximum pixel clock, there is no need to reapply the divisor on format change. Drop related code from ov6650_s_fmt() helper. Since a master clock hardware divisor, so far applied only together with the pixel clock divisor in a single operation, will no longer be applied from ov6650_s_fmt(), apply it, still using a hardcoded value for now, from ov6650_prog_dflt() helper so hardware is still initialised correctly on device probe. Signed-off-by: Janusz Krzysztofik --- drivers/media/i2c/ov6650.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c index 61ddd4ea4c26..e95ea132ef06 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -564,8 +564,7 @@ static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) .r.height = mf->height << half_scale, }; u32 code = mf->code; - unsigned long mclk, pclk; - u8 coma_set = 0, coma_mask = 0, coml_set, coml_mask, clkrc; + u8 coma_set = 0, coma_mask = 0, coml_set, coml_mask; int ret; /* select color matrix configuration for given color encoding */ @@ -635,21 +634,9 @@ static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) coma_mask |= COMA_QCIF; } - clkrc = CLKRC_12MHz; - mclk = 12000000; - dev_dbg(&client->dev, "using 12MHz input clock\n"); - - clkrc |= to_clkrc(priv->tpf.numerator); - - pclk = priv->pclk_max / GET_CLKRC_DIV(clkrc); - dev_dbg(&client->dev, "pixel clock divider: %ld.%ld\n", - mclk / pclk, 10 * mclk % pclk / pclk); - ret = ov6650_set_selection(sd, NULL, &sel); if (!ret) ret = ov6650_reg_rmw(client, REG_COMA, coma_set, coma_mask); - if (!ret) - ret = ov6650_reg_write(client, REG_CLKRC, clkrc); if (!ret) { priv->half_scale = half_scale; @@ -798,6 +785,8 @@ static int ov6650_prog_dflt(struct i2c_client *client) dev_dbg(&client->dev, "initializing\n"); ret = ov6650_reg_write(client, REG_COMA, 0); /* ~COMA_RESET */ + if (!ret) + ret = ov6650_reg_write(client, REG_CLKRC, CLKRC_12MHz); if (!ret) ret = ov6650_reg_rmw(client, REG_COMB, 0, COMB_BAND_FILTER);