Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp178742pxb; Fri, 8 Jan 2021 01:53:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJzFk1HU0k2b+LEn4whj6rtC66ZupQa4wojZkPjpPGrSfnSfjApywgV9n3mauAcfMpPaPFcZ X-Received: by 2002:a17:906:4d8d:: with SMTP id s13mr2129300eju.305.1610099636715; Fri, 08 Jan 2021 01:53:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610099636; cv=none; d=google.com; s=arc-20160816; b=Hu3B72bXqMkM7aK3AXGLo4rap68MbnOxgV6hImP69cXpQbPT+p779lkRAXP1JP3gJA 4QEgH3qqRMPn7VUW5VZmaTwrtD5g6O84xOaW0E0UMzq77KemXo6ubxSKSZ3suZpKhnQa 3yWHV/1zfj3Ilzjo1jd/spFLmuN3aNK72013ZeDmVdqpnwqHjWWrlwhi1cKBmzbEAsT3 qalpLWea2fmKMSvapvqcXvWmMSw9Qx7uUMwMwi80+BIIlrSU7CwH1h5W8Anjg/RqrwXM D6+h/1G6SnbEfEZy6tGXVLJPLlTDZxymkz0KLd3wcrXvcuICTwbJ+H/PQHLinFka9Tlt zKHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=6RcYttTMOnXQ/EkpLSa2hP7WyET9NuXOkFaalMdFVgM=; b=P509kHi+4r3QaqBy5u5PrTmUSZlpDJwD/cbQ85NkGIKdzuvZx9eRFvd1QMYY+4g8ae xJfk7M0KTs1Z1vChctpvTuU17e8PSPMCNadpLQan/1U2Qr1l1ruGutD5FRIDKJboZa5/ OE3TK4sKGyTQdb9bM67yYvO7bTb9FETUCvxvlJ1vdPnL/SSAnlYsddqiQH2mLu7quIsd 8yG94rv6AzfF3TW73rfhs7wA0LCIn3I6uzLZjtrHdX74MB3hCt8zJignot8as97ci8VK 3xUyIdjYC/a7OXLnTVXoIS5Bsk/z7iqXx5E5f51gEJkTN6ClftpDq5NDG/zlesZSnuOc h1Dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="upXMSd/I"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j18si3515754edj.99.2021.01.08.01.53.32; Fri, 08 Jan 2021 01:53:56 -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=@google.com header.s=20161025 header.b="upXMSd/I"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728194AbhAHJuC (ORCPT + 99 others); Fri, 8 Jan 2021 04:50:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726683AbhAHJuB (ORCPT ); Fri, 8 Jan 2021 04:50:01 -0500 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 219D0C0612F4 for ; Fri, 8 Jan 2021 01:49:21 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id t16so8383245wra.3 for ; Fri, 08 Jan 2021 01:49:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6RcYttTMOnXQ/EkpLSa2hP7WyET9NuXOkFaalMdFVgM=; b=upXMSd/IWf84zJj2eifJ4ej+Bxpt7HnlTttf4LiN36uw9tvU4eCtR/jUPqxNvZs8As a0eAYW6UlPazIZ1HlYiMsk9te0WbcyZ5wZbU+3Gh34KKqWpbXV6ArAIWaSFVzHXlRGnw z91DEW7/aeQF0F566EvGbEMUnqSo0xkuVmkcL+SFNNHnrUBLsp6N3Za7NZU4CIp+IMFF pTp2B15WVxZSmWpy3ChmdL7+Lvt1qbHrk/JaupVjx+iunmBCr6mQXuxb22F8yixtQrxT RwuvvA6MAk8qlu2lq8jyK82T684YEpZe3pQ/EITjvGQbfCOz8sSxKLXZDi2vunT+xh0B VrqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6RcYttTMOnXQ/EkpLSa2hP7WyET9NuXOkFaalMdFVgM=; b=DMXR63PDOTF/BSCbpOpES1DXCl3UV/q3LpR1jgMIGysucC3ODdW8zHVxaKXQ6IXfYr YljehiQXl/aZKa2gTlBB4Ge/+VJUA+hjEAYYsyfS7sDcL3ed22kxvYiGamBd8ca078qk rIcT8LiueyHEfAV4VNyUSaIX2ME5fa+jSEA59c4pS6BZUfDrA9dy1QAI2fSLrM+aSH13 pv++UxpJ+QTT4U3i/acvtNv/XlfBuuBiMz5Z414e1hJgNb1cNlCRsiebOiOWbnm0SuwY taT/FVJrtKtrIJhBhnXDEjYxHhWRsJF0Za1oDpScZStslNSBz5wrkhS6hYSYT+kgyNlu Nn5w== X-Gm-Message-State: AOAM532XZPvrdGLK8ZindFqn2Lr8BDSJlDje++Db5nZLKSa1IOWli8XY H/u254MqUQhKEm3GiWyPQkf1w+r00cnGHNw73YBsWw== X-Received: by 2002:adf:ef12:: with SMTP id e18mr2779398wro.192.1610099359674; Fri, 08 Jan 2021 01:49:19 -0800 (PST) MIME-Version: 1.0 References: <20210107142123.639477-1-robert.foss@linaro.org> In-Reply-To: <20210107142123.639477-1-robert.foss@linaro.org> From: Tomasz Figa Date: Fri, 8 Jan 2021 18:49:07 +0900 Message-ID: Subject: Re: [PATCH v2] media: ov8856: Fix Bayer format dependance on mode To: Robert Foss Cc: Dongchun Zhu , Mauro Carvalho Chehab , Linux Media Mailing List , Linux Kernel Mailing List , Sakari Ailus , Bingbu Cao Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Best regards, Tomasz