Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp633499ybm; Wed, 27 May 2020 04:22:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbLyQYERC2TaCl/0SVkn7DhqyMetzQWHW8ov0sTxA9npIMBTp9LdekFbSU02oZ94G6rijX X-Received: by 2002:a17:906:2503:: with SMTP id i3mr5758222ejb.293.1590578560912; Wed, 27 May 2020 04:22:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590578560; cv=none; d=google.com; s=arc-20160816; b=PCBhY8yRHnz34lF+EgbJaa4bylsL7nLkmK/SJQDFJyGj197kEWEJyLKZxNqOxtaxst lqzl6XRD9mH7Ghk80bcMO/ozzRllqx9kHRw8l9cEZgWdYOMMCujkKJLSIluLcj/BX15a LMf0FTgo+PY7zeYsGEL/IYKimqqETp81V5cu1pj5NZ4Z3zobS3FGLLe/102mq4vDW7zV A9PcBp8l0KxDQNTuKAFBLty1DFC05bwQBtVo7up1SA/1ez7m02coybybOiuvs6agJka0 f7XaTmHFurCVgSa4/9qr2VjA7vR8JPeeOXLTcA/X2BOOdsLSMZd2F2lOdVJiKcpwlj1F 3yMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=0cVbaBKHPFRHFgLj7eTRo1bAadVyagSGQGQWcN/OrRE=; b=hqTQbeFKumZuGBvzS8GLXdnnshUl4XykyzP2L0IoT7doSKKq8yF3wxWl9EwhQUfWh6 CuUE4CUtwzwOMt8KaF9Db3BzKMCUWBZ0qrCMuiOGs3hiAqvgho2MsLCCAtJkRpRGDpQp ug2dJGlz3KdCmxvdLwd0F3bfwmMyL6lkSlFkuMzC3YNDTYS8vpPgiavESpARv/f5X0Dd s2d1PFkiDbOTLijRiMyyxG5IQAon3M0mq8wiyZv9PUxQDkBJfb+JOf77QwdDFEHsw8NS 0t7sTtBRgJMowvEY1+tViknDOnBE7UqXZEs0mxXIYW/SW8wP2twf/npc1stAPeD+Fj/I MTVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oJxUyzIV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 r27si1685019ejb.750.2020.05.27.04.22.18; Wed, 27 May 2020 04:22:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=oJxUyzIV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S2388168AbgE0Im0 (ORCPT + 99 others); Wed, 27 May 2020 04:42:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388161AbgE0ImZ (ORCPT ); Wed, 27 May 2020 04:42:25 -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 6411BC03E97C for ; Wed, 27 May 2020 01:42:25 -0700 (PDT) Received: by mail-lf1-x143.google.com with SMTP id 82so13987339lfh.2 for ; Wed, 27 May 2020 01:42:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=0cVbaBKHPFRHFgLj7eTRo1bAadVyagSGQGQWcN/OrRE=; b=oJxUyzIVgZq7u4vhV2WTxYtWXGyQmwh7FnwZ8aW0G3ACHvkdtdA5Vg8o7/V1sOarON yNJdUef2IB0O73wQevzC4PCIMlKH3IWiY6zcax+lX2CmWdkv8j2+pjwlJkLtYIpsWFgp SuQ5IhYNHlfCZxc8AijCOMtBvTka3/7rbhfY3Nc6zRHthYsIW9Ia5YXmDFUO15q7K9hn gv0TJ0vBP1RCF2fErFoKvNPuVJOLNxLkd0zU42psapjDni5JhYPlHuSrQgTT1TsaksnW bLzX4DiKNHL6Hr18kFZRWSRt4TTWKotEOD6xkTw9O+WJMFFWo3KHfgwwU34C3KRgL8N2 oZ1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=0cVbaBKHPFRHFgLj7eTRo1bAadVyagSGQGQWcN/OrRE=; b=hk1j+r/qnQKmfKORuyPHtFycbIkNAhIOQRB7LJ/Sh3IJNdgE8WmC9sSjfEkv2wjv3W pDoJJwdxrHaBXApaAkkGvK5EE2v2twOQyprkYC/Nv6fpoq/hq+jfw1MwS08CZ4wFrcFT 3sZhtuB21+WvSNfqHuj+TlmhpYj6u+HodGDX6xOIZ8wPfxmd/0grOIziy6wDkNhsHVHD I1wbFMMl2Bz/KsUmcsG8vYG9UZF8rbaRZ/+dYvSuATum30DTv8Y3xEhSVK8odwDPc8lz 6AHBMXObKH3W9KVwPQwDTWEL0himl5ebDYvec5Q1ZGMKYDRJpVNllHhMbFZY4SQXaGP6 IR5w== X-Gm-Message-State: AOAM530vGQ3Itkw2aazuPDPFnkdqvZVDTyRECTU7ulnLesnR5LakCYqH iIHkWgp5JyI4CvPgsHViCW9z+nAF5QZM0w== X-Received: by 2002:a19:550e:: with SMTP id n14mr2628879lfe.81.1590568943796; Wed, 27 May 2020 01:42:23 -0700 (PDT) Received: from [192.168.118.216] (37-144-159-139.broadband.corbina.ru. [37.144.159.139]) by smtp.gmail.com with ESMTPSA id f2sm543541ljf.113.2020.05.27.01.42.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 May 2020 01:42:23 -0700 (PDT) Subject: Re: [PATCH v3 07/10] media: i2c: imx290: Add RAW12 mode support To: Dave Stevenson Cc: Mauro Carvalho Chehab , Sakari Ailus , manivannan.sadhasivam@linaro.org, Linux Media Mailing List , LKML , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, c.barrett@framos.com, a.brela@framos.com, Peter Griffin References: <20200524192505.20682-1-andrey.konovalov@linaro.org> <20200524192505.20682-8-andrey.konovalov@linaro.org> From: Andrey Konovalov Message-ID: <3597b850-5ce6-0e88-8f1f-e16bad5f75ef@linaro.org> Date: Wed, 27 May 2020 11:42:22 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Dave, On 26.05.2020 19:05, Dave Stevenson wrote: > Hi Andrey > > Thanks for the patch. > > On Sun, 24 May 2020 at 20:26, Andrey Konovalov > wrote: >> >> From: Manivannan Sadhasivam >> >> IMX290 is capable of outputting frames in both Raw Bayer (packed) 10 and >> 12 bit formats. Since the driver already supports RAW10 mode, let's add >> the missing RAW12 mode as well. >> >> Signed-off-by: Manivannan Sadhasivam >> Signed-off-by: Andrey Konovalov >> --- >> drivers/media/i2c/imx290.c | 36 +++++++++++++++++++++++++++++++++--- >> 1 file changed, 33 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c >> index 162c345fffac..6e70ff22bc5f 100644 >> --- a/drivers/media/i2c/imx290.c >> +++ b/drivers/media/i2c/imx290.c >> @@ -71,6 +71,7 @@ struct imx290 { >> struct clk *xclk; >> struct regmap *regmap; >> u8 nlanes; >> + u8 bpp; >> >> struct v4l2_subdev sd; >> struct v4l2_fwnode_endpoint ep; >> @@ -90,10 +91,12 @@ struct imx290 { >> >> struct imx290_pixfmt { >> u32 code; >> + u8 bpp; >> }; >> >> static const struct imx290_pixfmt imx290_formats[] = { >> - { MEDIA_BUS_FMT_SRGGB10_1X10 }, >> + { MEDIA_BUS_FMT_SRGGB10_1X10, 10 }, >> + { MEDIA_BUS_FMT_SRGGB12_1X12, 12 }, >> }; >> >> static const struct regmap_config imx290_regmap_config = { >> @@ -261,6 +264,18 @@ static const struct imx290_regval imx290_10bit_settings[] = { >> { 0x300b, 0x00}, >> }; >> >> +static const struct imx290_regval imx290_12bit_settings[] = { >> + { 0x3005, 0x01 }, >> + { 0x3046, 0x01 }, >> + { 0x3129, 0x00 }, >> + { 0x317c, 0x00 }, >> + { 0x31ec, 0x0e }, >> + { 0x3441, 0x0c }, >> + { 0x3442, 0x0c }, >> + { 0x300a, 0xf0 }, >> + { 0x300b, 0x00 }, >> +}; >> + >> /* supported link frequencies */ >> static const s64 imx290_link_freq_2lanes[] = { >> 891000000, /* 1920x1080 - 2 lane */ >> @@ -421,7 +436,12 @@ static int imx290_set_ctrl(struct v4l2_ctrl *ctrl) >> } else { >> imx290_write_reg(imx290, IMX290_PGCTRL, 0x00); >> msleep(10); >> - imx290_write_reg(imx290, IMX290_BLKLEVEL_LOW, 0x3c); >> + if (imx290->bpp == 10) >> + imx290_write_reg(imx290, IMX290_BLKLEVEL_LOW, >> + 0x3c); >> + else /* 12 bits per pixel */ >> + imx290_write_reg(imx290, IMX290_BLKLEVEL_LOW, >> + 0xf0); >> imx290_write_reg(imx290, IMX290_BLKLEVEL_HIGH, 0x00); >> } >> break; >> @@ -496,7 +516,7 @@ static u64 imx290_calc_pixel_rate(struct imx290 *imx290) >> u8 nlanes = imx290->nlanes; >> >> /* pixel rate = link_freq * 2 * nr_of_lanes / bits_per_sample */ >> - return (link_freq * 2 * nlanes / 10); >> + return (link_freq * 2 * nlanes / imx290->bpp); > > This doesn't link on a 32bit system as it's a 64bit divide: > ERROR: "__aeabi_ldivmod" [drivers/media/i2c/imx290.ko] undefined! > It ought to be using do_div(). Nice catch, thanks! I'll fix this in the next version of the patchset. Thanks, Andrey > Admittedly it didn't compile before as you still had a s64 divide by > 10, but I hadn't tried that :-) > > Dave > >> } >> >> static int imx290_set_fmt(struct v4l2_subdev *sd, >> @@ -533,6 +553,7 @@ static int imx290_set_fmt(struct v4l2_subdev *sd, >> } else { >> format = &imx290->current_format; >> imx290->current_mode = mode; >> + imx290->bpp = imx290_formats[i].bpp; >> >> if (imx290->link_freq) >> __v4l2_ctrl_s_ctrl(imx290->link_freq, >> @@ -577,6 +598,15 @@ static int imx290_write_current_format(struct imx290 *imx290) >> return ret; >> } >> break; >> + case MEDIA_BUS_FMT_SRGGB12_1X12: >> + ret = imx290_set_register_array(imx290, imx290_12bit_settings, >> + ARRAY_SIZE( >> + imx290_12bit_settings)); >> + if (ret < 0) { >> + dev_err(imx290->dev, "Could not set format registers\n"); >> + return ret; >> + } >> + break; >> default: >> dev_err(imx290->dev, "Unknown pixel format\n"); >> return -EINVAL; >> -- >> 2.17.1 >>