Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1613689ybv; Fri, 21 Feb 2020 00:18:04 -0800 (PST) X-Google-Smtp-Source: APXvYqxnhfPLdR+oMwZEsWaByOSUrkI1KJLJM8iwQwEzRUIyetG8BPnpo4rjZQH81VCHy9+3pb1D X-Received: by 2002:a9d:51c1:: with SMTP id d1mr25786056oth.136.1582273084298; Fri, 21 Feb 2020 00:18:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582273084; cv=none; d=google.com; s=arc-20160816; b=E+jYmRMv6XNrjSV8Bjr5RvtqTZGOimCCWTfvYGeAdUpdAKD18dgaY+/gzc0MsZT4SD tnYqcmr+1FB1s94bZuypq/rNIvDIkaQF5dCt4y+uD/VCHIuKrmgCiFjnxzITTLD2xs42 iVM5v+11Eu35ZfYCGFp34g1y6qx9Nbz/wkl1sWc/V2C0wemNnAJ3TA1gx5dDICP2Cycg j/OOc7mnN/iMR9aY79KSZaySXH576zipNZ8zPGe2+lk86r8od1WTAyuA/4nGbZLjGJyf DxOUqJr0WxeM5FVZi2Vnq4/LiIeq19hwqhuIh3E0NUwT8SOO13czASxlvGLtFpvlWaIi VOSA== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9P8H8Bvu+UVutmKX1Kg8wDI2zifZnJR9JNxaaJ3me4w=; b=hDS5W+eDuT0CGXyia4AehKuwtOY8totIBNtmcnrOU1uYd4os6oHUBKdVK1+roYBuL+ /ljRzuFqkMnivT+HgrufUjMWXxp24FEm8iNuv8eWd84Ji3tFYJNLE/5FXcrXwswGdpZX p/87T6x2cl3pqxMn+VCCaJGZYLjDSJmabs74sIhlr76aoujaXR6AeYQLWV/f+sZwb8eG 8PK2fE83lAn9ReGvkheRkHKNmUqqv6w/vpWsEKi8CQ3WgSXhY9vERmFJFw9s/CIZUHLj yW+KxPl7jUPgwWcqjN0iP9Jf6lzC6yigdAmpGf9m1Yd6YOVebVceFjzrJVXXfOAzLJYI aIKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Hy+4A5uH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a4si1027411otq.98.2020.02.21.00.17.52; Fri, 21 Feb 2020 00:18:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Hy+4A5uH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387634AbgBUIRL (ORCPT + 99 others); Fri, 21 Feb 2020 03:17:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:54430 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387630AbgBUIRI (ORCPT ); Fri, 21 Feb 2020 03:17:08 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DF3EE24670; Fri, 21 Feb 2020 08:17:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582273028; bh=Vpm/cz36dyRSQNVKx2X+LFRPRQifTpcBfMITrEp7/fw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hy+4A5uHOuo8d4qkbXWqLl0pfcq9GTjyFuRpqF8DL9QfJEMXJ+QeAqVPnbOe3ONlB VKLPjs6torDg6SVtR2/vWsXpvykG7pKyqqciqZ/CPEsF4FCpK5+/yDTcYvKO/Et249 k3KDl49tnzH5vIgXfW3BR2aI4SNgszIx804+B0NE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wenyou Yang , Eugen Hristev , Laurent Pinchart , Sakari Ailus , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 4.19 021/191] media: i2c: mt9v032: fix enum mbus codes and frame sizes Date: Fri, 21 Feb 2020 08:39:54 +0100 Message-Id: <20200221072253.725612874@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200221072250.732482588@linuxfoundation.org> References: <20200221072250.732482588@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eugen Hristev [ Upstream commit 1451d5ae351d938a0ab1677498c893f17b9ee21d ] This driver supports both the mt9v032 (color) and the mt9v022 (mono) sensors. Depending on which sensor is used, the format from the sensor is different. The format.code inside the dev struct holds this information. The enum mbus and enum frame sizes need to take into account both type of sensors, not just the color one. To solve this, use the format.code in these functions instead of the hardcoded bayer color format (which is only used for mt9v032). [Sakari Ailus: rewrapped commit message] Suggested-by: Wenyou Yang Signed-off-by: Eugen Hristev Reviewed-by: Laurent Pinchart Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/i2c/mt9v032.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c index f74730d24d8fe..04788692c9ff4 100644 --- a/drivers/media/i2c/mt9v032.c +++ b/drivers/media/i2c/mt9v032.c @@ -431,10 +431,12 @@ static int mt9v032_enum_mbus_code(struct v4l2_subdev *subdev, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_mbus_code_enum *code) { + struct mt9v032 *mt9v032 = to_mt9v032(subdev); + if (code->index > 0) return -EINVAL; - code->code = MEDIA_BUS_FMT_SGRBG10_1X10; + code->code = mt9v032->format.code; return 0; } @@ -442,7 +444,11 @@ static int mt9v032_enum_frame_size(struct v4l2_subdev *subdev, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_frame_size_enum *fse) { - if (fse->index >= 3 || fse->code != MEDIA_BUS_FMT_SGRBG10_1X10) + struct mt9v032 *mt9v032 = to_mt9v032(subdev); + + if (fse->index >= 3) + return -EINVAL; + if (mt9v032->format.code != fse->code) return -EINVAL; fse->min_width = MT9V032_WINDOW_WIDTH_DEF / (1 << fse->index); -- 2.20.1