Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp229623pxb; Fri, 8 Jan 2021 03:30:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJxnsI+4m5Lf0Gjkily+1/ptNE7lidNO3cBXDDsgpq6E4SkQyqb6mc3CQHlK18k57/ULX5IN X-Received: by 2002:aa7:cf85:: with SMTP id z5mr4933833edx.274.1610105453839; Fri, 08 Jan 2021 03:30:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610105453; cv=none; d=google.com; s=arc-20160816; b=oNHvgQNLStqFs0wbUt9JTQPnxAJBzSMDJK8UHA8bC++uyex4MMZWxurF8IMkbAo2HP XSYo6Tx5+RiWIRgt1wCIq6od/ZlwKUAroc7SB2h8nKj0fPN34Cz74uLRSzRghXPRPa/x PRayUNIC3BkB+f8QkIq31S39xHPnV+xr/2YWP3EDCKdDkarXTu6Ho0FRGV7zbAcDCl7d Qf9hBeGkjbLbC+kRxNdzESwnr11owYwhRNvxUM4RFmm9v2IErnpAtMYkN1/xJlbprGLm 3kQv6DPmAgvYktc7DmoJFQPqeYnBVC6L8f/TzU//KhnFHRkSTWr8Qg3Tmt3x/YOeiZJ8 hlUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:references:cc :to:from:subject:dkim-signature; bh=lS76xy/ppY53yeFgRK9lPlVnhMGFdbc36EC1VOjyjcU=; b=na8buFDuiQPQJxKMjaJ8aZn4nxNUkHyLwTKr7fGbe/G+l1ATc99NebzX/7KCjw/dHr Wo7E8+dyOPaOifpC8UI9zI4/C2RGPnbvK23bjQCCynBrgPtzKWnbdwKi7HPCHNlZeklS AAtldN1rbv3+OufyZK4XvrtbY/AzW+bbCmaYFYtIM/ev1q7ouXL1pqfn/5TxVMwfAwx9 PLXdFPP2SJbXM2ZvfQSIU9Uqvq8IYd7A9JPVCmvHuBT3yjJXhySUWIOm/pYXFXCdk97h NobXJ0K7kbuRXXuZlJ4tDMkx0Yon+yZbxak9mM/Cjf36SlYz2vg4Yq5DWyF8OWnaxwGp s7pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=szQ2mLAm; 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 i8si3413503edq.125.2021.01.08.03.30.30; Fri, 08 Jan 2021 03:30:53 -0800 (PST) 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=szQ2mLAm; 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 S1726441AbhAHL2r (ORCPT + 99 others); Fri, 8 Jan 2021 06:28:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725791AbhAHL2r (ORCPT ); Fri, 8 Jan 2021 06:28:47 -0500 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 984DAC0612F4 for ; Fri, 8 Jan 2021 03:28:06 -0800 (PST) Received: by mail-lf1-x134.google.com with SMTP id o13so22188261lfr.3 for ; Fri, 08 Jan 2021 03:28:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=lS76xy/ppY53yeFgRK9lPlVnhMGFdbc36EC1VOjyjcU=; b=szQ2mLAmF/GZrZeond+4zTzdeypaZxGO0ygu4tuMgQxMrbSncWHRDUB9ji909mFCmK LNMsiZ7qk9CS6WMVRWZpC7kIUbZASzSAGtJWEEIIXjwUvpYqua68kCzuULsP4Szjvn2h 9mcG6muO+sxA8uX0yXEwy2TJ5wuVSdvMg2ycULsXO2vMIynV/D/yfyHbCeoJkSrho60W oforQ621ZsoEYxiPY54DAfpxFeMds2Az98kZ8AZdevp+Vg9f8fHBNlQpBGsn44c4ZqRI UAEnulHEl8TrwD1J37PEYGr8o8tlDjjwdRTJFinvkMJC2cusD2iyNat8/v8z2rPTgAb5 QUug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=lS76xy/ppY53yeFgRK9lPlVnhMGFdbc36EC1VOjyjcU=; b=Yzj3L2tqAUgpB+O+03VHxOrbkWv2RVedZXzxqKVOrEQPHMW9ujeRJaBmsrjqak0fcY E4f4aFqeIy39f7Gk2ipZvsSAaxbRl4QxinTLB+SKFwNWjb1TMyRcpRiovf91O2WCWTAp mWjP0g+FLkgpBC8CMX/yHIHwDgt952RR3hT2sIEe0OlQKsvOH6rv0v6RARhpGvjveyeW ANSgXUagbTrjGToF9kOPrvsA2vNvmkn6l2g6blZYYmd0dBuirbyMGYrMBP4M14juzBZs YImkhRRhduMQChW1t8VfLTWzn5EXbPrhydTwkWiw0ERnyht/eR6TYdp/OcFtpU7KkU4Y u5AQ== X-Gm-Message-State: AOAM530JBtrW70/Ht2XoOqsCZhXb7bKaCM6sGuTswLLtZmKogyniRnsG bJq4+sIcvcjDEQ4AFItWJFp1xhyMsU8PGYwN X-Received: by 2002:a2e:58f:: with SMTP id 137mr1309988ljf.469.1610105285085; Fri, 08 Jan 2021 03:28:05 -0800 (PST) Received: from [192.168.118.216] ([85.249.43.69]) by smtp.gmail.com with ESMTPSA id q23sm1906733lfo.278.2021.01.08.03.28.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 08 Jan 2021 03:28:04 -0800 (PST) Subject: Re: [PATCH v2] media: ov8856: Fix Bayer format dependance on mode From: Andrey Konovalov To: Tomasz Figa , Robert Foss Cc: Dongchun Zhu , Mauro Carvalho Chehab , Linux Media Mailing List , Linux Kernel Mailing List , Sakari Ailus , Bingbu Cao References: <20210107142123.639477-1-robert.foss@linaro.org> <6ec75d88-0cd5-79cc-6413-81f169b5e976@linaro.org> Message-ID: Date: Fri, 8 Jan 2021 14:28:03 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <6ec75d88-0cd5-79cc-6413-81f169b5e976@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Robert, On 08.01.2021 13:46, Andrey Konovalov wrote: > Hi Robert and Tomasz, > > On 08.01.2021 12:49, Tomasz Figa wrote: >> Hi Robert, >> >> On Thu, Jan 7, 2021 at 11:21 PM Robert Foss wrote: >>> >>> The Bayer GRBG10 mode used for earlier modes 3280x2460 and >>> 1640x1232 isn't the mode output by the sensor for the >>> 3264x2448 and 1632x1224 modes. >>> >>> Switch from MEDIA_BUS_FMT_SGRBG10_1X10 to MEDIA_BUS_FMT_SBGGR10_1X10 >>> for 3264x2448 & 1632x1224 modes. >>> >>> Signed-off-by: Robert Foss >>> --- >>> >>> Changes since v1: >>>   - Sakari: Added mode information to ov8856_mode struct >>>   - Sakari: enum_mbus_code updated >>> >>>   drivers/media/i2c/ov8856.c | 24 ++++++++++++++++++------ >>>   1 file changed, 18 insertions(+), 6 deletions(-) >>> >>> diff --git a/drivers/media/i2c/ov8856.c b/drivers/media/i2c/ov8856.c >>> index 2f4ceaa80593..7cd83564585c 100644 >>> --- a/drivers/media/i2c/ov8856.c >>> +++ b/drivers/media/i2c/ov8856.c >>> @@ -126,6 +126,9 @@ struct ov8856_mode { >>> >>>          /* Sensor register settings for this resolution */ >>>          const struct ov8856_reg_list reg_list; >>> + >>> +       /* MEDIA_BUS_FMT for this mode */ >>> +       u32 code; >>>   }; >>> >>>   static const struct ov8856_reg mipi_data_rate_720mbps[] = { >>> @@ -942,6 +945,11 @@ static const char * const ov8856_test_pattern_menu[] = { >>>          "Bottom-Top Darker Color Bar" >>>   }; >>> >>> +static const u32 ov8856_formats[] = { >>> +       MEDIA_BUS_FMT_SBGGR10_1X10, >>> +       MEDIA_BUS_FMT_SGRBG10_1X10, >>> +}; >>> + >>>   static const s64 link_freq_menu_items[] = { >>>          OV8856_LINK_FREQ_360MHZ, >>>          OV8856_LINK_FREQ_180MHZ >>> @@ -974,6 +982,7 @@ static const struct ov8856_mode supported_modes[] = { >>>                          .regs = mode_3280x2464_regs, >>>                  }, >>>                  .link_freq_index = OV8856_LINK_FREQ_720MBPS, >>> +               .code = MEDIA_BUS_FMT_SGRBG10_1X10, >>>          }, >>>          { >>>                  .width = 3264, >>> @@ -986,6 +995,7 @@ static const struct ov8856_mode supported_modes[] = { >>>                          .regs = mode_3264x2448_regs, >>>                  }, >>>                  .link_freq_index = OV8856_LINK_FREQ_720MBPS, >>> +               .code = MEDIA_BUS_FMT_SBGGR10_1X10, >>>          }, >>>          { >>>                  .width = 1640, >>> @@ -998,6 +1008,7 @@ static const struct ov8856_mode supported_modes[] = { >>>                          .regs = mode_1640x1232_regs, >>>                  }, >>>                  .link_freq_index = OV8856_LINK_FREQ_360MBPS, >>> +               .code = MEDIA_BUS_FMT_SGRBG10_1X10, >>>          }, >>>          { >>>                  .width = 1632, >>> @@ -1010,6 +1021,7 @@ static const struct ov8856_mode supported_modes[] = { >>>                          .regs = mode_1632x1224_regs, >>>                  }, >>>                  .link_freq_index = OV8856_LINK_FREQ_360MBPS, >>> +               .code = MEDIA_BUS_FMT_SBGGR10_1X10, >>>          } >>>   }; >>> >>> @@ -1281,8 +1293,8 @@ static void ov8856_update_pad_format(const struct ov8856_mode *mode, >>>   { >>>          fmt->width = mode->width; >>>          fmt->height = mode->height; >>> -       fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10; >>>          fmt->field = V4L2_FIELD_NONE; >>> +       fmt->code = mode->code; >>>   } >>> >>>   static int ov8856_start_streaming(struct ov8856 *ov8856) >>> @@ -1519,11 +1531,10 @@ static int ov8856_enum_mbus_code(struct v4l2_subdev *sd, >>>                                   struct v4l2_subdev_pad_config *cfg, >>>                                   struct v4l2_subdev_mbus_code_enum *code) >>>   { >>> -       /* Only one bayer order GRBG is supported */ >>> -       if (code->index > 0) >>> +       if (code->index >= ARRAY_SIZE(ov8856_formats)) >>>                  return -EINVAL; >>> >>> -       code->code = MEDIA_BUS_FMT_SGRBG10_1X10; >>> +       code->code = ov8856_formats[code->index]; >>> >>>          return 0; >>>   } >>> @@ -1532,10 +1543,11 @@ static int ov8856_enum_frame_size(struct v4l2_subdev *sd, >>>                                    struct v4l2_subdev_pad_config *cfg, >>>                                    struct v4l2_subdev_frame_size_enum *fse) >>>   { >>> -       if (fse->index >= ARRAY_SIZE(supported_modes)) >>> +       if ((fse->code != ov8856_formats[0]) && >>> +           (fse->code != ov8856_formats[1])) >> >> Shouldn't this be validated against the current mode? I guess it's the >> question about which part of the state takes precedence - the mbus >> code or the frame size. > > The docs [1] say "enumerate all frame sizes supported by a sub-device on the given pad > for the given media bus format". It doesn't seem to mention the current mode. But the > frame sizes reported should be filtered by the mbus code, and this patch misses that > if I read it correct. > > But this situation when the mbus code depends on the mode (on the resolution in fact)... > Yes, if we read the pixels from a rectangle smaller than the active area, we can change > the bayer order by moving this "read-out" rectangle by one pixel along x, y, or both x > and y axes. But wouldn't it be better if we try to review the register setting for the > current modes so that the bayer order would be the same for all the modes? This untested change should make the 3264x2448 and 1632x1224 modes to use the GRBG bayer order (I would prefer BGGR as this is the "native" order of the pixel array, but GRBG appeared in the driver first): diff --git a/drivers/media/i2c/ov8856.c b/drivers/media/i2c/ov8856.c index d8cefd3d4045..b337f729d5e3 100644 --- a/drivers/media/i2c/ov8856.c +++ b/drivers/media/i2c/ov8856.c @@ -428,7 +428,7 @@ static const struct ov8856_reg mode_3264x2448_regs[] = { {0x3810, 0x00}, {0x3811, 0x04}, {0x3812, 0x00}, - {0x3813, 0x02}, + {0x3813, 0x01}, {0x3814, 0x01}, {0x3815, 0x01}, {0x3816, 0x00}, @@ -821,7 +821,7 @@ static const struct ov8856_reg mode_1632x1224_regs[] = { {0x3810, 0x00}, {0x3811, 0x02}, {0x3812, 0x00}, - {0x3813, 0x02}, + {0x3813, 0x01}, {0x3814, 0x03}, {0x3815, 0x01}, {0x3816, 0x00}, Thanks, Andrey > Thanks, > Andrey > >> Best regards, >> Tomasz >> > > [1] https://linuxtv.org/downloads/v4l-dvb-apis-new/userspace-api/v4l/vidioc-subdev-enum-frame-size.html