From patchwork Fri Jun 12 13:53:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 199171 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1423DC433E0 for ; Fri, 12 Jun 2020 13:56:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E79AD206A4 for ; Fri, 12 Jun 2020 13:56:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="hiiHVTh1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726639AbgFLN4j (ORCPT ); Fri, 12 Jun 2020 09:56:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726306AbgFLNyT (ORCPT ); Fri, 12 Jun 2020 09:54:19 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BAC6C08C5C2 for ; Fri, 12 Jun 2020 06:54:18 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id s1so11189022ljo.0 for ; Fri, 12 Jun 2020 06:54:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xeJmQRJvkh8fRKHXAH/W536lRiSffIGCx+R099ed5PQ=; b=hiiHVTh1koKECwgkQFOYluvaR28/5xxQvqOjadxCulwyJAffd2ZpYXFjRWW1GzXVU0 nomzxfGeylZ5u440WHBdRkGLZgok5eypFL+YQPilPO3CGrehGubk6rraAt64TSwIsJSe yoXR8k2FXymqMEqV+1cz4eaNbor9pimWSgDqjiRhRi8sHXkx+0HQezDhVNe4TygLUJQ0 ftjs0JrFoSH+fnIq/YijvScx0OXsSbgEIYGNKa97Ei5JeWJNg9gIh4QEs9y9H6sOQ9Rp irk26liCEIf59CE2Ly8HkxSzVUgwP7NRijj7rokcaQu/kuCGVOP9smOd7pMii0QvDRpo hBhg== 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; bh=xeJmQRJvkh8fRKHXAH/W536lRiSffIGCx+R099ed5PQ=; b=HRJaAxMX5YsXmIDhSCAPDFA94xMNZOP7J44r/fr9DQPgqVrICWiMUiV0qNNfjSZp8G FRAns2mcoWlBQFHKE8/1u8wlLQ5fTNN6n85S/S2sLYQXMYgI/3wnVdTqfmQnwxPE9HNx llyZDaxx6CSGPya9wE9Mtxc08izAiNBl5NCScSApJi8zp31qqJ4fTrO2qrYkmeQRT4c7 sEjfx8VpULUP6t2ocjWuCCKsqnGN+tBlXRAt+8IAVvmPQXkYRmUvOUi2+31jWxmKs6iI X/gbIai2rLfQ2bcl9Vy2ng9vjmet/P7xPFMed4y8MdwLEFI5Am1x8mRek3MUw4YPW7lJ 1k9Q== X-Gm-Message-State: AOAM533vqpoSF5+thOnuCdJMgYIbU1TaPPeWZR+dGmVsVegHk5TLxnv0 DDCYLlxxjI/MRcNurcIf3U8PSQ== X-Google-Smtp-Source: ABdhPJxAs/p3JqvNSzkzmTG4KRwjrgYR0Zzdjszn5nAVDBlQ8woXvA/n+G+5ZPWyQVX+lnXJxldUWw== X-Received: by 2002:a05:651c:108:: with SMTP id a8mr7069531ljb.326.1591970056778; Fri, 12 Jun 2020 06:54:16 -0700 (PDT) Received: from localhost.localdomain (37-144-159-139.broadband.corbina.ru. [37.144.159.139]) by smtp.googlemail.com with ESMTPSA id a1sm2414415lfi.36.2020.06.12.06.54.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jun 2020 06:54:16 -0700 (PDT) From: Andrey Konovalov To: mchehab@kernel.org, sakari.ailus@iki.fi, manivannan.sadhasivam@linaro.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, c.barrett@framos.com, a.brela@framos.com, peter.griffin@linaro.org, Andrey Konovalov Subject: [PATCH v5 01/10] media: i2c: imx290: set the format before VIDIOC_SUBDEV_G_FMT is called Date: Fri, 12 Jun 2020 16:53:46 +0300 Message-Id: <20200612135355.30286-2-andrey.konovalov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200612135355.30286-1-andrey.konovalov@linaro.org> References: <20200612135355.30286-1-andrey.konovalov@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org With the current driver 'media-ctl -p' issued right after the imx290 driver is loaded prints: pad0: Source [fmt:unknown/0x0] The format value of zero is due to the current_format field of the imx290 struct not being initialized yet. As imx290_entity_init_cfg() calls imx290_set_fmt(), the current_mode field is also initialized, so the line which set current_mode to a default value in driver's probe() function is no longer needed. Signed-off-by: Andrey Konovalov Reviewed-by: Manivannan Sadhasivam --- drivers/media/i2c/imx290.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c index f7678e5a5d87..2d8c38ffe2f0 100644 --- a/drivers/media/i2c/imx290.c +++ b/drivers/media/i2c/imx290.c @@ -722,9 +722,6 @@ static int imx290_probe(struct i2c_client *client) goto free_err; } - /* Set default mode to max resolution */ - imx290->current_mode = &imx290_modes[0]; - /* get system clock (xclk) */ imx290->xclk = devm_clk_get(dev, "xclk"); if (IS_ERR(imx290->xclk)) { @@ -809,6 +806,9 @@ static int imx290_probe(struct i2c_client *client) goto free_ctrl; } + /* Initialize the frame format (this also sets imx290->current_mode) */ + imx290_entity_init_cfg(&imx290->sd, NULL); + ret = v4l2_async_register_subdev(&imx290->sd); if (ret < 0) { dev_err(dev, "Could not register v4l2 device\n"); From patchwork Fri Jun 12 13:53:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 187845 Delivered-To: patch@linaro.org Received: by 2002:a54:30ca:0:0:0:0:0 with SMTP id e10csp519313ecs; Fri, 12 Jun 2020 06:56:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXjrY5SgUwkYuhBUbaMMVRMkqw3noatkn6dbEsOpZNs7U/T7vsaj8Edib3Mm48KNFsoiSz X-Received: by 2002:a17:907:429b:: with SMTP id ny19mr13495480ejb.498.1591970197336; Fri, 12 Jun 2020 06:56:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591970197; cv=none; d=google.com; s=arc-20160816; b=FpkiR7w2iNK2AWrnTXp5+KGXDJplldYrJs5OmENhrsO1EV8RZ6OmhJdq6y9Yq2Z2Z9 sZdCqpjZoUyBZ8PLoNxBpFxMTduefXmIOdpqCMb5wdIN4Lq4BlL/u9v80iJp8YztgjNT 5GGjwemnHUnvRtyND5KxUR5hPxWkg3ffkUD+lGFcZwJ1ESUWsbPr0b5fC/kYKB/KNQHR eWGnql15l+FPKlLO3NcSXuIlYNtov9C+yYJdWpT7nU8V4w0FCT5l52MweMHYca/R71mH v+n21+r7U6GanoqWH/oBBLzcuj/RhsJtaC47RuViuf9tZyz+HJn0iw7K3ZonK3WBq4au hkCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=i8QHZ+71uR5r8C2iVrz+FnYiMnJAkGWgVhEcbxpdOK0=; b=0EZbSDdnSyDlH6fjQ1cCVGUaZRU5Uin7sXIuiBWqG+C60JaEj7GgYIZS8sjlB5y0n3 s89xfOvYWOkmKI32ba2auzdhtFJ/yMaLoVnee9bK5xP9uhJenUQwsSFxKNAiWcGhluQk QAahv4mO+QYfqvJg54vhhkshK9WsrJa4Y2IkH2vfYna4zAjDTFo9XOc7nvOmdsauXL7P Iv4sBMqRz6oOFIQzPGM1DlC2UHRxkwen8vabrAr52tr3K2tRE5xhOhcEBpnhxmBcDI15 3oIbKB9enS4VvPYA+UVDtg5ZhpyIJgeQIpyGiSKhwuskQLx0iVUgqjW9IMoG4HQuo1u9 tMhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XLWy5sO0; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w17si3611700edt.490.2020.06.12.06.56.37; Fri, 12 Jun 2020 06:56:37 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XLWy5sO0; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726451AbgFLNyc (ORCPT + 6 others); Fri, 12 Jun 2020 09:54:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726366AbgFLNyY (ORCPT ); Fri, 12 Jun 2020 09:54:24 -0400 Received: from mail-lf1-x143.google.com (mail-lf1-x143.google.com [IPv6:2a00:1450:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2579C08C5C3 for ; Fri, 12 Jun 2020 06:54:22 -0700 (PDT) Received: by mail-lf1-x143.google.com with SMTP id z206so5530783lfc.6 for ; Fri, 12 Jun 2020 06:54:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=i8QHZ+71uR5r8C2iVrz+FnYiMnJAkGWgVhEcbxpdOK0=; b=XLWy5sO0x6NyMihD9u77RPeoTa4IN3p4476KrhEB3C21R7zGrViSArupp8vODWeY08 MZAA3SwN3S2SA6wiLKAnZTnaJ+tnvDIHdd39DowB98xoNi9Z2TOoma4aoiU4O4Mc8mgG SL95B7uIT4Lv994CBMH+AHawfTt3QilccsXJTsPxr1d2BgD2APHJ2Ea0FappE9lUlgbx oP4EKJSze9ktQAMIfGqxnt/MEijNdd0DgnDnaSSi00JB79vNii1CxJVUdcAFn2d9MAPg goz06Sx8j18T6Dbu7MOOnB1zls/Ow3l8Ceedxl5NwZEHsZo1HCQnTsc1Q0BgLt3746aB swMw== 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; bh=i8QHZ+71uR5r8C2iVrz+FnYiMnJAkGWgVhEcbxpdOK0=; b=KE2SouzC1RjfQlNxPEskDRagp+Vpfj5s/t13UEUVeWLsd5c0Vzm/EgJv23+u2E0I5Y wC7q5DOpG4Jn2k9ETTodi2/jIvJSdqZr3zYuGTHp6K5t7naOYaz1S/h4LJabZxxW2T8V Trz23j4jVQ05szfqoeObNjPCyX7kMozBaI8tCxWkmvtWVC5XgmwYAC/qjOsG74tLi9Ce Q59NrDXpd1vUhAqImAaiWnbuGdEB2iqNrTPh/k//7Yu6woytuAVegaQoHgCRGteKbid5 qrHPuMMNytnFKWWKdg5wlewBTP9CgyYSBR8FeUikq8bSu7RsNooBT+0AbRwqIgJURRFI iadg== X-Gm-Message-State: AOAM5307LCC3wigc4xFvJeRNUKFvJOZ1MElWAXFP+idl2+JpXvnISti8 UQcAOzMiXasJQZVySuN7I/KMHA== X-Received: by 2002:a19:cbd7:: with SMTP id b206mr6991562lfg.163.1591970061110; Fri, 12 Jun 2020 06:54:21 -0700 (PDT) Received: from localhost.localdomain (37-144-159-139.broadband.corbina.ru. [37.144.159.139]) by smtp.googlemail.com with ESMTPSA id a1sm2414415lfi.36.2020.06.12.06.54.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jun 2020 06:54:20 -0700 (PDT) From: Andrey Konovalov To: mchehab@kernel.org, sakari.ailus@iki.fi, manivannan.sadhasivam@linaro.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, c.barrett@framos.com, a.brela@framos.com, peter.griffin@linaro.org, Andrey Konovalov Subject: [PATCH v5 02/10] media: i2c: imx290: fix the order of the args in SET_RUNTIME_PM_OPS() Date: Fri, 12 Jun 2020 16:53:47 +0300 Message-Id: <20200612135355.30286-3-andrey.konovalov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200612135355.30286-1-andrey.konovalov@linaro.org> References: <20200612135355.30286-1-andrey.konovalov@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The macro is defined as SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn), so imx290_power_off must be the 1st arg, and imx290_power_on the 2nd. Signed-off-by: Andrey Konovalov Reviewed-by: Manivannan Sadhasivam --- drivers/media/i2c/imx290.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c index 2d8c38ffe2f0..d0322f9a8856 100644 --- a/drivers/media/i2c/imx290.c +++ b/drivers/media/i2c/imx290.c @@ -648,7 +648,7 @@ static int imx290_power_off(struct device *dev) } static const struct dev_pm_ops imx290_pm_ops = { - SET_RUNTIME_PM_OPS(imx290_power_on, imx290_power_off, NULL) + SET_RUNTIME_PM_OPS(imx290_power_off, imx290_power_on, NULL) }; static const struct v4l2_subdev_video_ops imx290_video_ops = { From patchwork Fri Jun 12 13:53:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 199170 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 664F5C433DF for ; Fri, 12 Jun 2020 13:56:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4577F20792 for ; Fri, 12 Jun 2020 13:56:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ddFsPwMK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726444AbgFLN4i (ORCPT ); Fri, 12 Jun 2020 09:56:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726396AbgFLNyb (ORCPT ); Fri, 12 Jun 2020 09:54:31 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BB74C08C5CA for ; Fri, 12 Jun 2020 06:54:28 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id n24so11119569lji.10 for ; Fri, 12 Jun 2020 06:54:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7kqfMUc+k2k/CiQ8rg2p7L02Gn6NnHmpWC1JYpqHUwA=; b=ddFsPwMKjSzo2EQi1Zqx3EnOMCVYa3kNjaMMi/H4r2p3LatbMak66e7dd6IwSU10X+ zPdd5mxI01/xadY9BLBoJMSN3iV9Vi3mA8vB7fL3ZXKo8dZRHncOiaIQulWBR5h02U1W NToR+Blffkx4NO7rgHKYCdYnO8L6JZceghBlinU7dshVfNdpSv9+Mdfy1hCZ27z9yYkj rGBN9IA+iSxqoZ6snZvKGzF9+9xAcdTF/kPeGeumUI7nvhBPUbeDqlqbEFjMHHa1m5sn JPiB7FgrrVnefgFDsOB2pZcUOOcnG/3p9RSwn427aP3vR7k6kvbmRBwsdYQigy23Q+7J fXwA== 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; bh=7kqfMUc+k2k/CiQ8rg2p7L02Gn6NnHmpWC1JYpqHUwA=; b=f0xNG2+szXwqVew0INMszUN41XyvxfVsLKcCNKISrmvmXJBZ6jPH12exIx5thVsE1n nGSgbieCOKLcc78oe876ml3qNEqzdrV8BlsVQkLy6fW4QUkF+ucebuQw1YLZbR02y1tM NmfQxhdKe3nQQ3pWU2J7hNugx8RYkivhQNa69LSvjZSEPhzD26FzKDq6fFs3vPym70Wn NTyqiDc9Rna27c8qiugtSV0M980Kpuct7kKWs6oBZ2K1HpaTSiZzhPx1urUE/D1Lgh2P PAUcmQwtVdpbFwmggNEiep9cNSGKhmJ6gETrA55sAgK2igQOEYfTLT3YiKt8BTKRCw2P 1mqQ== X-Gm-Message-State: AOAM533cEuC8dydb3mcLYfIKNxctYDAD7mhs+YSERHLK4wCxxInJrRqX bh0jP5mmm+mfmEZll2BefYI/yA== X-Google-Smtp-Source: ABdhPJyDBnrD3DlLh7dSvnCrLclg55A+bSStipj3gqqSMeNA7e1fZAY83WXzWV6h0RqFYcGfLoT59g== X-Received: by 2002:a2e:818f:: with SMTP id e15mr6754881ljg.376.1591970066440; Fri, 12 Jun 2020 06:54:26 -0700 (PDT) Received: from localhost.localdomain (37-144-159-139.broadband.corbina.ru. [37.144.159.139]) by smtp.googlemail.com with ESMTPSA id a1sm2414415lfi.36.2020.06.12.06.54.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jun 2020 06:54:25 -0700 (PDT) From: Andrey Konovalov To: mchehab@kernel.org, sakari.ailus@iki.fi, manivannan.sadhasivam@linaro.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, c.barrett@framos.com, a.brela@framos.com, peter.griffin@linaro.org, Andrey Konovalov Subject: [PATCH v5 04/10] media: i2c: imx290: Add support for 2 data lanes Date: Fri, 12 Jun 2020 16:53:49 +0300 Message-Id: <20200612135355.30286-5-andrey.konovalov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200612135355.30286-1-andrey.konovalov@linaro.org> References: <20200612135355.30286-1-andrey.konovalov@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Manivannan Sadhasivam The IMX290 sensor can output frames with 2/4 CSI2 data lanes. This commit adds support for 2 lane mode in addition to the 4 lane and also configuring the data lane settings in the driver based on system configuration. Signed-off-by: Manivannan Sadhasivam Signed-off-by: Andrey Konovalov --- drivers/media/i2c/imx290.c | 147 +++++++++++++++++++++++++++++++++---- 1 file changed, 133 insertions(+), 14 deletions(-) diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c index 7b1de1f0c8b7..ffb393962ffc 100644 --- a/drivers/media/i2c/imx290.c +++ b/drivers/media/i2c/imx290.c @@ -25,7 +25,12 @@ #define IMX290_STANDBY 0x3000 #define IMX290_REGHOLD 0x3001 #define IMX290_XMSTA 0x3002 +#define IMX290_FR_FDG_SEL 0x3009 #define IMX290_GAIN 0x3014 +#define IMX290_HMAX_LOW 0x301c +#define IMX290_HMAX_HIGH 0x301d +#define IMX290_PHY_LANE_NUM 0x3407 +#define IMX290_CSI_LANE_MODE 0x3443 #define IMX290_DEFAULT_LINK_FREQ 445500000 @@ -45,6 +50,7 @@ struct imx290_regval { struct imx290_mode { u32 width; u32 height; + u32 hmax; u32 pixel_rate; u32 link_freq_index; @@ -56,6 +62,7 @@ struct imx290 { struct device *dev; struct clk *xclk; struct regmap *regmap; + u8 nlanes; struct v4l2_subdev sd; struct v4l2_fwnode_endpoint ep; @@ -89,14 +96,11 @@ static const struct regmap_config imx290_regmap_config = { static const struct imx290_regval imx290_global_init_settings[] = { { 0x3007, 0x00 }, - { 0x3009, 0x00 }, { 0x3018, 0x65 }, { 0x3019, 0x04 }, { 0x301a, 0x00 }, - { 0x3443, 0x03 }, { 0x3444, 0x20 }, { 0x3445, 0x25 }, - { 0x3407, 0x03 }, { 0x303a, 0x0c }, { 0x3040, 0x00 }, { 0x3041, 0x00 }, @@ -169,7 +173,6 @@ static const struct imx290_regval imx290_1080p_settings[] = { { 0x3164, 0x1a }, { 0x3480, 0x49 }, /* data rate settings */ - { 0x3009, 0x01 }, { 0x3405, 0x10 }, { 0x3446, 0x57 }, { 0x3447, 0x00 }, @@ -187,8 +190,6 @@ static const struct imx290_regval imx290_1080p_settings[] = { { 0x3453, 0x00 }, { 0x3454, 0x17 }, { 0x3455, 0x00 }, - { 0x301c, 0x98 }, - { 0x301d, 0x08 }, }; static const struct imx290_regval imx290_720p_settings[] = { @@ -210,7 +211,6 @@ static const struct imx290_regval imx290_720p_settings[] = { { 0x3164, 0x1a }, { 0x3480, 0x49 }, /* data rate settings */ - { 0x3009, 0x01 }, { 0x3405, 0x10 }, { 0x3446, 0x4f }, { 0x3447, 0x00 }, @@ -228,8 +228,6 @@ static const struct imx290_regval imx290_720p_settings[] = { { 0x3453, 0x00 }, { 0x3454, 0x17 }, { 0x3455, 0x00 }, - { 0x301c, 0xe4 }, - { 0x301d, 0x0c }, }; static const struct imx290_regval imx290_10bit_settings[] = { @@ -250,10 +248,11 @@ static const s64 imx290_link_freq[] = { }; /* Mode configs */ -static const struct imx290_mode imx290_modes[] = { +static const struct imx290_mode imx290_modes_2lanes[] = { { .width = 1920, .height = 1080, + .hmax = 0x1130, .data = imx290_1080p_settings, .data_size = ARRAY_SIZE(imx290_1080p_settings), .pixel_rate = 178200000, @@ -262,6 +261,7 @@ static const struct imx290_mode imx290_modes[] = { { .width = 1280, .height = 720, + .hmax = 0x19c8, .data = imx290_720p_settings, .data_size = ARRAY_SIZE(imx290_720p_settings), .pixel_rate = 178200000, @@ -269,6 +269,44 @@ static const struct imx290_mode imx290_modes[] = { }, }; +static const struct imx290_mode imx290_modes_4lanes[] = { + { + .width = 1920, + .height = 1080, + .hmax = 0x0898, + .data = imx290_1080p_settings, + .data_size = ARRAY_SIZE(imx290_1080p_settings), + .pixel_rate = 178200000, + .link_freq_index = 0, + }, + { + .width = 1280, + .height = 720, + .hmax = 0x0ce4, + .data = imx290_720p_settings, + .data_size = ARRAY_SIZE(imx290_720p_settings), + .pixel_rate = 178200000, + .link_freq_index = 0, + }, +}; + +static inline const struct imx290_mode *imx290_modes_ptr(const struct imx290 *imx290) +{ + /* We rely on imx290_probe() to ensure that nlanes is either 2 or 4 */ + if (imx290->nlanes == 2) + return imx290_modes_2lanes; + else + return imx290_modes_4lanes; +} + +static inline int imx290_modes_num(const struct imx290 *imx290) +{ + if (imx290->nlanes == 2) + return ARRAY_SIZE(imx290_modes_2lanes); + else + return ARRAY_SIZE(imx290_modes_4lanes); +} + static inline struct imx290 *to_imx290(struct v4l2_subdev *_sd) { return container_of(_sd, struct imx290, sd); @@ -450,9 +488,8 @@ static int imx290_set_fmt(struct v4l2_subdev *sd, mutex_lock(&imx290->lock); - mode = v4l2_find_nearest_size(imx290_modes, - ARRAY_SIZE(imx290_modes), - width, height, + mode = v4l2_find_nearest_size(imx290_modes_ptr(imx290), + imx290_modes_num(imx290), width, height, fmt->format.width, fmt->format.height); fmt->format.width = mode->width; @@ -522,6 +559,25 @@ static int imx290_write_current_format(struct imx290 *imx290, return 0; } +static int imx290_set_hmax(struct imx290 *imx290, u32 val) +{ + int ret; + + ret = imx290_write_reg(imx290, IMX290_HMAX_LOW, (val & 0xff)); + if (ret) { + dev_err(imx290->dev, "Error setting HMAX register\n"); + return ret; + } + + ret = imx290_write_reg(imx290, IMX290_HMAX_HIGH, ((val >> 8) & 0xff)); + if (ret) { + dev_err(imx290->dev, "Error setting HMAX register\n"); + return ret; + } + + return 0; +} + /* Start streaming */ static int imx290_start_streaming(struct imx290 *imx290) { @@ -550,6 +606,9 @@ static int imx290_start_streaming(struct imx290 *imx290) dev_err(imx290->dev, "Could not set current mode\n"); return ret; } + ret = imx290_set_hmax(imx290, imx290->current_mode->hmax); + if (ret < 0) + return ret; /* Apply customized values from user */ ret = v4l2_ctrl_handler_setup(imx290->sd.ctrl_handler); @@ -607,6 +666,49 @@ static int imx290_get_regulators(struct device *dev, struct imx290 *imx290) imx290->supplies); } +static int imx290_set_data_lanes(struct imx290 *imx290) +{ + int ret = 0, laneval, frsel; + + switch (imx290->nlanes) { + case 2: + laneval = 0x01; + frsel = 0x02; + break; + case 4: + laneval = 0x03; + frsel = 0x01; + break; + default: + /* + * We should never hit this since the data lane count is + * validated in probe itself + */ + dev_err(imx290->dev, "Lane configuration not supported\n"); + ret = -EINVAL; + goto exit; + } + + ret = imx290_write_reg(imx290, IMX290_PHY_LANE_NUM, laneval); + if (ret) { + dev_err(imx290->dev, "Error setting Physical Lane number register\n"); + goto exit; + } + + ret = imx290_write_reg(imx290, IMX290_CSI_LANE_MODE, laneval); + if (ret) { + dev_err(imx290->dev, "Error setting CSI Lane mode register\n"); + goto exit; + } + + ret = imx290_write_reg(imx290, IMX290_FR_FDG_SEL, frsel); + if (ret) + dev_err(imx290->dev, "Error setting FR/FDG SEL register\n"); + +exit: + return ret; +} + static int imx290_power_on(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); @@ -631,6 +733,9 @@ static int imx290_power_on(struct device *dev) gpiod_set_value_cansleep(imx290->rst_gpio, 0); usleep_range(30000, 31000); + /* Set data lane count */ + imx290_set_data_lanes(imx290); + return 0; } @@ -677,6 +782,7 @@ static int imx290_probe(struct i2c_client *client) struct fwnode_handle *endpoint; struct imx290 *imx290; u32 xclk_freq; + u32 default_pixel_rate; int ret; imx290 = devm_kzalloc(dev, sizeof(*imx290), GFP_KERNEL); @@ -703,6 +809,16 @@ static int imx290_probe(struct i2c_client *client) goto free_err; } + /* Get number of data lanes */ + imx290->nlanes = imx290->ep.bus.mipi_csi2.num_data_lanes; + if (imx290->nlanes != 2 && imx290->nlanes != 4) { + dev_err(dev, "Invalid data lanes: %d\n", imx290->nlanes); + ret = -EINVAL; + goto free_err; + } + + dev_dbg(dev, "Using %u data lanes\n", imx290->nlanes); + if (!imx290->ep.nr_of_link_frequencies) { dev_err(dev, "link-frequency property not found in DT\n"); ret = -EINVAL; @@ -780,10 +896,13 @@ static int imx290_probe(struct i2c_client *client) if (imx290->link_freq) imx290->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY; + default_pixel_rate = imx290->nlanes == 2 ? + imx290_modes_2lanes[0].pixel_rate : + imx290_modes_4lanes[0].pixel_rate; imx290->pixel_rate = v4l2_ctrl_new_std(&imx290->ctrls, &imx290_ctrl_ops, V4L2_CID_PIXEL_RATE, 1, INT_MAX, 1, - imx290_modes[0].pixel_rate); + default_pixel_rate); imx290->sd.ctrl_handler = &imx290->ctrls; From patchwork Fri Jun 12 13:53:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 199173 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC658C433E0 for ; Fri, 12 Jun 2020 13:56:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8959F20835 for ; Fri, 12 Jun 2020 13:56:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="tTPvo9D/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726576AbgFLNzo (ORCPT ); Fri, 12 Jun 2020 09:55:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726513AbgFLNyo (ORCPT ); Fri, 12 Jun 2020 09:54:44 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69980C08C5C4 for ; Fri, 12 Jun 2020 06:54:43 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id c17so11141637lji.11 for ; Fri, 12 Jun 2020 06:54:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZN8pb1DxbDLuAa3GwJ440N0/6Zk96TU9nPo+rlxSNXs=; b=tTPvo9D/MvRXBYX/MuHpkfqpCLq6atXifgP7LV4e3/6UtF3iJJK1XIhlokPt2be/6X rw06kE/rT6je/Hm8AxKVhHSpwcD+crQqHu6WtC9W7UQF6Ct8K8ketGlK08BDO8RJN6Hj IvQgKQDZG+OK05stM197t5SLomRYn6ffu/eNGlE19PdVcXVDW1LXmeX7EmruPAx49R7l Nyz88Fqrv44x2YQC55PAOcnj54GBa9z/VouaaLk4m6Ek0tPFwMoeqebHz1NxqFI4JA5m oI+x8tjGs4Afg7PiQMsAj4KTf/VfwO7cMmc2fojYCf0abdsoKvQ4+N+QlrcJ4khYofCr Opyw== 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; bh=ZN8pb1DxbDLuAa3GwJ440N0/6Zk96TU9nPo+rlxSNXs=; b=sUkcGI+9KjrMjCIB5rwmcWr7K8HZjJzOm7cE7TVHO//tWusXNNWj7s/HHqwzPBjTbf u52/fmsJKqqvEnZBswPPIMFaSLXIVi7ZXv3QlrF8/DuFcTUgi0/9vfz/cXNhcPW1lRRF 3vY0wVdcAuJC0MOB914jDqYo5zGVMU+rNbxjztdzgxRWW5PGygaLKMt6DrX0KM0DJzxz T1hmkaaOeMjMCkaqRpdrkix1xMVNjgWyaBe0ySaFxr6izXA3yiWOIKf5pbRnnm1GYznz lmTPFtfyRvEjiQmT/DHSqCyU+2kvgnV7Pn6MCWKdw2G596erINV+4yCjGGrwxGs3TCXX lRgg== X-Gm-Message-State: AOAM5339p3xvYID1KTWqpD4Dngw8XloZRw6aT6qOg1bOmonoSMe7Wm+2 wMCEeRTNx6CpWVhiMEz+r4oKTg== X-Google-Smtp-Source: ABdhPJyd0K77IMACgsooS/25EwC76SwVSTRSStSbsi4StlxM/eYk+QNKB3QOHNFROB4+6VQH2CxZbw== X-Received: by 2002:a05:651c:50d:: with SMTP id o13mr7303244ljp.181.1591970081900; Fri, 12 Jun 2020 06:54:41 -0700 (PDT) Received: from localhost.localdomain (37-144-159-139.broadband.corbina.ru. [37.144.159.139]) by smtp.googlemail.com with ESMTPSA id a1sm2414415lfi.36.2020.06.12.06.54.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jun 2020 06:54:41 -0700 (PDT) From: Andrey Konovalov To: mchehab@kernel.org, sakari.ailus@iki.fi, manivannan.sadhasivam@linaro.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, c.barrett@framos.com, a.brela@framos.com, peter.griffin@linaro.org, Andrey Konovalov Subject: [PATCH v5 08/10] media: i2c: imx290: Add support to enumerate all frame sizes Date: Fri, 12 Jun 2020 16:53:53 +0300 Message-Id: <20200612135355.30286-9-andrey.konovalov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200612135355.30286-1-andrey.konovalov@linaro.org> References: <20200612135355.30286-1-andrey.konovalov@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Manivannan Sadhasivam Add support to enumerate all frame sizes supported by IMX290. This is required for using with userspace tools such as libcamera. Signed-off-by: Manivannan Sadhasivam Signed-off-by: Andrey Konovalov --- drivers/media/i2c/imx290.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c index c654a9a8fb08..fd147fac5ef2 100644 --- a/drivers/media/i2c/imx290.c +++ b/drivers/media/i2c/imx290.c @@ -528,6 +528,28 @@ static int imx290_enum_mbus_code(struct v4l2_subdev *sd, return 0; } +static int imx290_enum_frame_size(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_frame_size_enum *fse) +{ + const struct imx290 *imx290 = to_imx290(sd); + const struct imx290_mode *imx290_modes = imx290_modes_ptr(imx290); + + if ((fse->code != imx290_formats[0].code) && + (fse->code != imx290_formats[1].code)) + return -EINVAL; + + if (fse->index >= imx290_modes_num(imx290)) + return -EINVAL; + + fse->min_width = imx290_modes[fse->index].width; + fse->max_width = imx290_modes[fse->index].width; + fse->min_height = imx290_modes[fse->index].height; + fse->max_height = imx290_modes[fse->index].height; + + return 0; +} + static int imx290_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_format *fmt) @@ -873,6 +895,7 @@ static const struct v4l2_subdev_video_ops imx290_video_ops = { static const struct v4l2_subdev_pad_ops imx290_pad_ops = { .init_cfg = imx290_entity_init_cfg, .enum_mbus_code = imx290_enum_mbus_code, + .enum_frame_size = imx290_enum_frame_size, .get_fmt = imx290_get_fmt, .set_fmt = imx290_set_fmt, }; From patchwork Fri Jun 12 13:53:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 187841 Delivered-To: patch@linaro.org Received: by 2002:a54:30ca:0:0:0:0:0 with SMTP id e10csp518766ecs; Fri, 12 Jun 2020 06:55:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdywf65D+exnMxKDnTKwVav2xNqn1n6JYWH81ZAgXx8SqrFeHhNOOE6x0LYzIY8eGcW1j7 X-Received: by 2002:a17:906:cd05:: with SMTP id oz5mr14250583ejb.335.1591970140961; Fri, 12 Jun 2020 06:55:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591970140; cv=none; d=google.com; s=arc-20160816; b=ArdcaK18E/LNbQV75Pg76fOVFqkakgriMq6ZIPdQbkS4VNmew93hBT1FyCnfy0EAza Sj3gm3BAkI9EKvYWXQc0dvYP7Kylc+Fs7HxQ5mYDSMMEd89j/sr7t+A3ISV03oqvx62f fsOKeplp324KsQVH0UyVvALL9ajLIBHSXnw+8XPy2ZFI4ph9K6+Y2XHojnHlG3ceA/69 qe3/v2BKjxXB1wiTuFBzTBQF9Wkg7eFF2Xnh5gq44E73IHmcfjDK+HtsBIzIxRkn7s22 fHB6kwYUbJhviOyH1r7IfWXimfjRx3Ridn7O0PgbZBAKPyT+v12OQ09SYCSUQY1CsuOv +Eug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=Rt6ATyUj+kngO18ntOXAOOJDegUILp5okUOOJZj7u30=; b=yFBQkdDgFFZOYT+sn5SqEeJwh2v4SA1bnhT2/eMmbeXYsOIOuuxK9b1rDAqFDNsIZl gxWi+ayGmYkXFCY84cxpG59HUGGYzgh/t8Tqp4uO/+FTOLzf3xHg+Dl/04Nm9qVSrbQX 4pwWv1GrNLNj2eWFQyA6/Wc/0eS4zMs1SjFxAS/btADItRj6Vrgk8DYdqWmkgP9tynXQ SSiWnsmJFg5LkRTj89wRKpVgGuPub6vcpb+h+KJsall13a6F1QJOsEsPFT1LKX/+aTpx 3T0GL+x10MSaCbDIzSM6hxvQHQDvCwlmn0baiuZe4MshGVkqYYWN4jiWegTFSv9qmXl9 sUtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wO7KwHdt; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i11si4046337ejv.272.2020.06.12.06.55.40; Fri, 12 Jun 2020 06:55:40 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wO7KwHdt; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726570AbgFLNzh (ORCPT + 6 others); Fri, 12 Jun 2020 09:55:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726517AbgFLNyq (ORCPT ); Fri, 12 Jun 2020 09:54:46 -0400 Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E920C03E96F for ; Fri, 12 Jun 2020 06:54:45 -0700 (PDT) Received: by mail-lf1-x142.google.com with SMTP id 126so905324lfn.1 for ; Fri, 12 Jun 2020 06:54:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Rt6ATyUj+kngO18ntOXAOOJDegUILp5okUOOJZj7u30=; b=wO7KwHdto8wlA0AV82uro7r1mK8DBbXdgWCWNK/MHmIEZNZswGO4HSzn48aJdHLwZo 4FzLRbwhsBUHqDFgtuTSNvdAopkP1kXPR+tNGagHOodO2CH/OX2VB5P7t78pzMNaba2l 2lvPmRYZ+er5+r7VhVBhp9YYNQuuUZfLmedjZWePBXNM/U7o23C0oYHsLdS0dG2rbGgA 0pkFdjWn4K8I4Tp9zZGgXDov0m97rJ24qVbVgJIxdYQ23STL5mCFH0uN1cZ7c42GB7pK c5OsfvVDrRMsrf216jVMdXeqlb8U3vtsT9ZC1P1QvU9lnF0YT1AQyoxT5PAE9w9C6+p6 AY0A== 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; bh=Rt6ATyUj+kngO18ntOXAOOJDegUILp5okUOOJZj7u30=; b=M/1FYXm7HDfMYpY7/Hk2oQqlLs+BsG8kvEpUXYIDoatk3fkSNBC9dojQwa4j6lGRLk xQvVkxAO5qjiHM2UL1U0gKd3MCpWLNKjNPtnhgW+P/1DO/yKc5rP1PBoUFTrFDSrtea/ oMT1yvHr7A09Re2sOTaSE7Kplfirj1MaDg7R+QS+KkYbO9szjTdl8v4LN717R/AJZiJ4 CwU7pbyqB8P/Y8ttgFvrqgHCTh4IPjmd4eebvApsbQ2Hf/eF+pm1lxdBxtoScvo77BVZ pplYQipjlUO9/rmVsqKCM/E4tN1GlM5itDM/U0cgOrbU8rxdT7lWhUXPZY+jkOuTfRgF Hk3g== X-Gm-Message-State: AOAM532nsks/NkYWb4TSgxD4DN2ReMR3QXEm28GpJePFtAGPpL0iek2S 1gnaaQwZ5A5f3DtgzwdIre9reC5mMWF4fg== X-Received: by 2002:a05:6512:488:: with SMTP id v8mr7079139lfq.205.1591970083855; Fri, 12 Jun 2020 06:54:43 -0700 (PDT) Received: from localhost.localdomain (37-144-159-139.broadband.corbina.ru. [37.144.159.139]) by smtp.googlemail.com with ESMTPSA id a1sm2414415lfi.36.2020.06.12.06.54.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jun 2020 06:54:43 -0700 (PDT) From: Andrey Konovalov To: mchehab@kernel.org, sakari.ailus@iki.fi, manivannan.sadhasivam@linaro.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, c.barrett@framos.com, a.brela@framos.com, peter.griffin@linaro.org, Andrey Konovalov Subject: [PATCH v5 09/10] media: i2c: imx290: Move the settle time delay out of loop Date: Fri, 12 Jun 2020 16:53:54 +0300 Message-Id: <20200612135355.30286-10-andrey.konovalov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200612135355.30286-1-andrey.konovalov@linaro.org> References: <20200612135355.30286-1-andrey.konovalov@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Manivannan Sadhasivam The 10ms settle time is needed only at the end of all consecutive register writes. So move the delay to outside of the for loop of imx290_set_register_array(). Signed-off-by: Manivannan Sadhasivam Signed-off-by: Andrey Konovalov --- drivers/media/i2c/imx290.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c index fd147fac5ef2..02001c1b0dfc 100644 --- a/drivers/media/i2c/imx290.c +++ b/drivers/media/i2c/imx290.c @@ -404,11 +404,11 @@ static int imx290_set_register_array(struct imx290 *imx290, ret = imx290_write_reg(imx290, settings->reg, settings->val); if (ret < 0) return ret; - - /* Settle time is 10ms for all registers */ - msleep(10); } + /* Provide 10ms settle time */ + msleep(10); + return 0; } From patchwork Fri Jun 12 13:53:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 187840 Delivered-To: patch@linaro.org Received: by 2002:a54:30ca:0:0:0:0:0 with SMTP id e10csp518528ecs; Fri, 12 Jun 2020 06:55:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz11lZRw/+8DT4QLJwgLHbEJo+yqTd4RL+3HfiA6EIukzonBOxo5MGxwBiU4ZTKQ7IqWlS4 X-Received: by 2002:a50:f1d9:: with SMTP id y25mr11434970edl.292.1591970114416; Fri, 12 Jun 2020 06:55:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591970114; cv=none; d=google.com; s=arc-20160816; b=0+w3Fygk1M09i2nYobW8SXJDVz644rAOWQ8TS2tn0FChQqomyR9jnQ5qIclrYpGKNl KiQe3VnmaSkgpB1jRXpdCxmy2yDdM4m8jXs/c5RUqIbhwOmmV+MXvSYwAHe4TmLwHwZ0 AIMnZIVq9LUR8nutorP/t8n2lS/26WZsDOs92Ahs0nHcxC8YgIzNvbzH5wvsSUYhKEtX dQQNITv4mjt3/4xbccFVCbR2sBlLVOXDipr/TR2u0rk03H3co7NQWKcXi28TwWL6TN2s EE9ZjDCIddif3uaWnj7Ckqq/S2CY00zh1ya4gEtdteWcm08pzKndyG8cHc+fU5cQic9R 0l4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=dfWTJRln/wUkUezGYMWTWyc7bZ4R2M6yJEVL+/18MoU=; b=ArLXmoyTF9DzgfRiSnitiWoHcy02dVpbZRhPDWH/XvJMrsPAsGcvJlZipgiwNvp0Rv +W6uVdWf1WHoEpyalnNe/UqbIXtIcIIDs92S78LwNVq/mqdPT+76tqeBZ1NimXroXfFW fnmEKXFpN1oRMVK6ps/g745St8x8y8azYOSqWcNK1Nk4gWhJU5dzRGxys1/94DTdH0tD U0rZ00bG3mo0q+2maxxVw11IgPyqAm317UDHw557oOsucBJ7sgHk/262LI8RbS7BB0ig mzu1wIS+JCo2c08xyPKsxSKFE0cTUQs7QTu8gjf9+fOZr2PZm0QFtNAws26b7sVRDfNv BS6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YKUm5+MX; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i11si4046337ejv.272.2020.06.12.06.55.14; Fri, 12 Jun 2020 06:55:14 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YKUm5+MX; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726283AbgFLNzH (ORCPT + 6 others); Fri, 12 Jun 2020 09:55:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726536AbgFLNyv (ORCPT ); Fri, 12 Jun 2020 09:54:51 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40968C03E96F for ; Fri, 12 Jun 2020 06:54:49 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id c17so11141985lji.11 for ; Fri, 12 Jun 2020 06:54:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dfWTJRln/wUkUezGYMWTWyc7bZ4R2M6yJEVL+/18MoU=; b=YKUm5+MXtyoghi4Yx87JKWrhK8cqKD7Pbsn3qttgdfSTtHv9XJDTFN6NgT4uvktIZ4 uoW5GEgLbTnrIKjiPQH6wahznKsDQ5arq9tYg0nV3URIhCV9lEdy9f9oGwW4Y1W1y9u9 w9/5i2Een1oXqRDGaVhEBRV7FFxMTbNX43qg0J+qjrXwn2xDKJ/ytgQrOnogGLijj0/T 9Jlw5TytVFnb97n2RZU8Et8Hf57kDLGSF0BPJ8W4BWtNgD3Z+dTD755+KLZnXI2WcLwl IqqKciv1se3OjH7IzAN57JRVq66HbgvpNjVFwb1TDU5vjEHitTUcjc1F7oeh2JdCwLLz xlyw== 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; bh=dfWTJRln/wUkUezGYMWTWyc7bZ4R2M6yJEVL+/18MoU=; b=BnvIRbbti0N84exZpd7rbx78t/QADVzDBUunDW0T3gCd2VYV4FsytyxAaCZDlgpt5H IfGz+OT1AfQswd/n/sY55UDvRn3Qj1Fvn01Di07yUeANuJg+fIWXwNfo5bfdcTpxzYG4 Z+281zCuvY+MLiU6yB4enmta7dXQGf4Dhhj2/BnaptlNaXHEOsx3LARTBzKvXaa2WCkL G4u2NrPhLWSoz8m/06ehi7fg+ab2/JvvA7puJXski16CxK8HuXdd04hvtDf0n21uJBCt s6uW9gZILry+83EbWmHYR1S8X52TgqVwus5sxkuZhQpYHchj2X1tCB4R7kVJL1+xyqQn wadQ== X-Gm-Message-State: AOAM532sSpMfj8x3eo7mO5+Grfk4GZF1/3lGK/iYBVU50Gemhfl9bouu G2+P5v3toMY9LuzcZdr5u0VR5g== X-Received: by 2002:a2e:81c5:: with SMTP id s5mr6643701ljg.372.1591970087696; Fri, 12 Jun 2020 06:54:47 -0700 (PDT) Received: from localhost.localdomain (37-144-159-139.broadband.corbina.ru. [37.144.159.139]) by smtp.googlemail.com with ESMTPSA id a1sm2414415lfi.36.2020.06.12.06.54.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jun 2020 06:54:47 -0700 (PDT) From: Andrey Konovalov To: mchehab@kernel.org, sakari.ailus@iki.fi, manivannan.sadhasivam@linaro.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, c.barrett@framos.com, a.brela@framos.com, peter.griffin@linaro.org, Andrey Konovalov Subject: [PATCH v5 10/10] media: i2c: imx290: set bus_type before calling v4l2_fwnode_endpoint_alloc_parse() Date: Fri, 12 Jun 2020 16:53:55 +0300 Message-Id: <20200612135355.30286-11-andrey.konovalov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200612135355.30286-1-andrey.konovalov@linaro.org> References: <20200612135355.30286-1-andrey.konovalov@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The bus_type field of v4l2_fwnode_endpoint structure passed as the argument to v4l2_fwnode_endpoint_alloc_parse() function must be initiaized. Set it to V4L2_MBUS_CSI2_DPHY, and check for -ENXIO which is returned when the requested media bus type doesn't match the fwnode. Also remove v4l2_fwnode_endpoint field from struct imx290 as it is only needed in the probe function: use the local variable for this purpose. Signed-off-by: Andrey Konovalov --- drivers/media/i2c/imx290.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) -- 2.17.1 diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c index 02001c1b0dfc..9c97830164e9 100644 --- a/drivers/media/i2c/imx290.c +++ b/drivers/media/i2c/imx290.c @@ -70,7 +70,6 @@ struct imx290 { u8 bpp; struct v4l2_subdev sd; - struct v4l2_fwnode_endpoint ep; struct media_pad pad; struct v4l2_mbus_framefmt current_format; const struct imx290_mode *current_mode; @@ -914,17 +913,18 @@ static const struct media_entity_operations imx290_subdev_entity_ops = { * of MIPI data lanes are mentioned in the device tree, or the value of the * first missing frequency otherwise. */ -static s64 imx290_check_link_freqs(const struct imx290 *imx290) +static s64 imx290_check_link_freqs(const struct imx290 *imx290, + const struct v4l2_fwnode_endpoint *ep) { int i, j; const s64 *freqs = imx290_link_freqs_ptr(imx290); int freqs_count = imx290_link_freqs_num(imx290); for (i = 0; i < freqs_count; i++) { - for (j = 0; j < imx290->ep.nr_of_link_frequencies; j++) - if (freqs[i] == imx290->ep.link_frequencies[j]) + for (j = 0; j < ep->nr_of_link_frequencies; j++) + if (freqs[i] == ep->link_frequencies[j]) break; - if (j == imx290->ep.nr_of_link_frequencies) + if (j == ep->nr_of_link_frequencies) return freqs[i]; } return 0; @@ -934,6 +934,10 @@ static int imx290_probe(struct i2c_client *client) { struct device *dev = &client->dev; struct fwnode_handle *endpoint; + /* Only CSI2 is supported for now: */ + struct v4l2_fwnode_endpoint ep = { + .bus_type = V4L2_MBUS_CSI2_DPHY + }; struct imx290 *imx290; u32 xclk_freq; s64 fq; @@ -956,15 +960,18 @@ static int imx290_probe(struct i2c_client *client) return -EINVAL; } - ret = v4l2_fwnode_endpoint_alloc_parse(endpoint, &imx290->ep); + ret = v4l2_fwnode_endpoint_alloc_parse(endpoint, &ep); fwnode_handle_put(endpoint); - if (ret) { + if (ret == -ENXIO) { + dev_err(dev, "Unsupported bus type, should be CSI2\n"); + goto free_err; + } else if (ret) { dev_err(dev, "Parsing endpoint node failed\n"); goto free_err; } /* Get number of data lanes */ - imx290->nlanes = imx290->ep.bus.mipi_csi2.num_data_lanes; + imx290->nlanes = ep.bus.mipi_csi2.num_data_lanes; if (imx290->nlanes != 2 && imx290->nlanes != 4) { dev_err(dev, "Invalid data lanes: %d\n", imx290->nlanes); ret = -EINVAL; @@ -973,27 +980,20 @@ static int imx290_probe(struct i2c_client *client) dev_dbg(dev, "Using %u data lanes\n", imx290->nlanes); - if (!imx290->ep.nr_of_link_frequencies) { + if (!ep.nr_of_link_frequencies) { dev_err(dev, "link-frequency property not found in DT\n"); ret = -EINVAL; goto free_err; } /* Check that link frequences for all the modes are in device tree */ - fq = imx290_check_link_freqs(imx290); + fq = imx290_check_link_freqs(imx290, &ep); if (fq) { dev_err(dev, "Link frequency of %lld is not supported\n", fq); ret = -EINVAL; goto free_err; } - /* Only CSI2 is supported for now */ - if (imx290->ep.bus_type != V4L2_MBUS_CSI2_DPHY) { - dev_err(dev, "Unsupported bus type, should be CSI2\n"); - ret = -EINVAL; - goto free_err; - } - /* get system clock (xclk) */ imx290->xclk = devm_clk_get(dev, "xclk"); if (IS_ERR(imx290->xclk)) { @@ -1108,7 +1108,7 @@ static int imx290_probe(struct i2c_client *client) pm_runtime_enable(dev); pm_runtime_idle(dev); - v4l2_fwnode_endpoint_free(&imx290->ep); + v4l2_fwnode_endpoint_free(&ep); return 0; @@ -1118,7 +1118,7 @@ static int imx290_probe(struct i2c_client *client) v4l2_ctrl_handler_free(&imx290->ctrls); mutex_destroy(&imx290->lock); free_err: - v4l2_fwnode_endpoint_free(&imx290->ep); + v4l2_fwnode_endpoint_free(&ep); return ret; }