Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1929101ybv; Fri, 14 Feb 2020 08:23:49 -0800 (PST) X-Google-Smtp-Source: APXvYqwnOj+r463doy+QQ4fAq4fAjYjBZJjBvbZJK0iEFFlib9XLjXhf6rkr4oxX9Hbnbe1dtUYF X-Received: by 2002:a05:6808:658:: with SMTP id z24mr2458041oih.91.1581697429676; Fri, 14 Feb 2020 08:23:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581697429; cv=none; d=google.com; s=arc-20160816; b=lB2yKjagmB8DCxx5qculcExbz1f+ks0VmIHNpzfQA7KsGYGiIf2C7xgRvj8tRF4rHL Fr+QXu4QdNYUL+8Sd3ZkDhB8Oi+1Z6sFxpvT5vPKirqBgyrpBV7QKBS96jRJbHsNpH6G V4g/ES1s8Y0uqydsE9JtFwHBcbstcPUFtwyneO0laO4r7Eq4jqNz6eApynwHbplUnDKh k7jBBGYmOxRYLUeeypT3bl9fWSnPmDTBpBOFIQpLwdKJihzdrSJRU4xwVEIq7g0x3wDF ozVbXGOxp5xRnle+hUCkpdQxSBh3lq5Tn58l2md3alXH0pVpupeR+VzdyUrOOWw/cRu4 Nrqg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dee2NsGoO6J1sA0WcRh0bLRtNIAzboZqfTWG7y7FVTo=; b=D1MqISL/vTQQvdGUI5eNaPGFoWPljL7FVDdW1j6bLRfFQi738p6/hrUCfnDTsF2mbo YhFrPKAvp9+U389cVRtJRx8pbC6Y+Dy9HN7ThbhkCw1WPdvJFWlnlhNROvFfW55hxfk0 UNNlyfPR6tC85ZXu2svemBn9HyjNR/+oQSQ8CSDGUJZoxf1e3gCMwQmGXzAOYGRyiYVd KM1ck6bSuDptvXhXN2+j56NJN9Xmr8xM9LuSa9llgiq90V2Rrn74j+r/cJJslWJZDxua uWQxJDuNAzMVu14J7ZLcVfzYWAwnbPA4X9+B7AvzBcXANchCyfkEvU19bIU/EOcWgfZU jwtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HOzYGCmp; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l83si2811307oih.58.2020.02.14.08.23.38; Fri, 14 Feb 2020 08:23:49 -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=HOzYGCmp; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393275AbgBNQWy (ORCPT + 99 others); Fri, 14 Feb 2020 11:22:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:56292 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393018AbgBNQVg (ORCPT ); Fri, 14 Feb 2020 11:21:36 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DFE0D246B8; Fri, 14 Feb 2020 16:21:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581697295; bh=rHPaUk6u286XrQ+yGXZ96uDdkynwYvW284M6ai2NP80=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HOzYGCmplFPMlNJmmdYZZF8YIavGxK15Kqlmvw8ikvHbzLGmzZaFi0KYsM23bqcrn tmktTGGST4YNG/2UdyZ86ocw7/PD8Qj4cnOrWcNAIgu8N0NJSHNzg4mMGwKvp0+ZC9 yxUPDsCKzTatgOHuXh0jzllTl95WXPosQkUoV2ZQ= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Eugen Hristev , Wenyou Yang , Laurent Pinchart , Sakari Ailus , Mauro Carvalho Chehab , Sasha Levin , linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 010/141] media: i2c: mt9v032: fix enum mbus codes and frame sizes Date: Fri, 14 Feb 2020 11:19:10 -0500 Message-Id: <20200214162122.19794-10-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200214162122.19794-1-sashal@kernel.org> References: <20200214162122.19794-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 58eb62f1ba214..a018a76662df7 100644 --- a/drivers/media/i2c/mt9v032.c +++ b/drivers/media/i2c/mt9v032.c @@ -423,10 +423,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; } @@ -434,7 +436,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