Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3617945pxf; Mon, 5 Apr 2021 17:38:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJziAG4/nwzFbETknimHU/qN/Cj2MkDEFP90U+r7FpJ5XlreJlEN2fcMvnCJcsEzS72+XXBP X-Received: by 2002:a17:906:5d12:: with SMTP id g18mr30676690ejt.246.1617669486891; Mon, 05 Apr 2021 17:38:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617669486; cv=none; d=google.com; s=arc-20160816; b=xP4xm25vvSQ7WQLDfcZjD9/uim8ZrT1fQ1czxMgj8sf7PXn4bxKdhxdygtoXFVvZmP 5qcvln3JuVbE5gbBuslzDsvU7OJMnyTlNRsfeAid/aJBlDJTAxQTGqTGUaovqPuReWOT 0ATPJi3wbsUIVT2AslcLBWbP+wLslanvm5dNPUDvAaoovD/H3Xpk551CA0/Vg01273DM MYonvASTGJxuOeVY2aOcDi6z61PsoDlCi0IT7NBYBQkD1rn/au0PCUESulOFJ3DIssw9 OSX3gvG6WlYclOe+LdYSXDaH+q4Q77TwdpxNIXuHBU4BqRcfUh6ABut8Uk4GZ3NlIdVp kJqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:dkim-signature; bh=w5M5tT7Gv/O63WU61RlVQ76HyqBstHqyW8E2+xPPx+Q=; b=el7y746yJ9gBRPMd1JYFwMGa9WT+1WBVWn0rdbEJr7qruo9KnVIGo9LcqEePApPBTc lbemV0IRh4v0k21nSrde4gefC2/OSWg+DaPBcUKJiMjD917hMwlW1s1lqZLMKYWvM1jC JbeWb08O2Ch5JSrQmCZpGslg4xs4mtBgFu8+SHAVqRFpUZr+gHVYye0BlNPbbk1tc1dN vdp3tp4FNyGi+xSQgJ72+c692EeskyTvypg7OgA+08ITuNsSLVs0B2BEU6qcQnvmK2Le ygn9YXIXbgl0VGH0M0XX8YndZgxU/7ITuPcBmJPVp7LF/7jVzrxLfahAx4IaIagfQ3jD PZLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@microchip.com header.s=mchp header.b=gCpE7MTB; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n9si8556222edc.437.2021.04.05.17.37.44; Mon, 05 Apr 2021 17:38:06 -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=fail header.i=@microchip.com header.s=mchp header.b=gCpE7MTB; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241704AbhDEPw4 (ORCPT + 99 others); Mon, 5 Apr 2021 11:52:56 -0400 Received: from esa.microchip.iphmx.com ([68.232.154.123]:36224 "EHLO esa.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232798AbhDEPwz (ORCPT ); Mon, 5 Apr 2021 11:52:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1617637969; x=1649173969; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=W9RTc4XTqmuga+DzPKp51siwwTSJHh6dtg9LlNk0M14=; b=gCpE7MTBzZBjzJlePCpiqRdP1NZq8ZBxbGb+6N8KYj1/a+uScoQTQfvd mX+wB7mcfHEGGKVJPPglQ+pPhn8qxErylb+E/XfkyaTHzQcEsccU/lSoK 6k3qP89ArNa7KzePMbJjTEfPYHTAHE8zEV4rVxxBtg3IhndxfIutw0OJf TJ4tMZySYV1P7y2zQezzEvIVCeJ8WlPU1qqejFInOiL+P939GaGGIZTTQ QnFDfmIrwxOoZtwiOZ3+5OCkA1K4kL7ivJ9Vy3O3QMFEv0KImFrT57i2B ll3uk+U+A3EsCBVKENbs96mTyGPvOfXyM4a/ssfzMHaM2fW037eEPBj3Q Q==; IronPort-SDR: US6DGm0iWxEyeoAwyPGNZAmbVvGtLhLaF8tBGQdxb51J65oG7yjBU/W0R+kP0HI43xoqOnVTbj Hck3klKSv5UqIXu0UW6YLMKpLWHWgZaHnxEg/uXLPbgw9Azde1b2eohuEwu8Hp47CVeZnf1/6E 7r751EgMZkQUn+RTs67ceUE0tYc5mjD5JdWQaf+5IafUw1MOG3INHu0z85W0A2k4q8ZrLITeqZ 4nvy3jUERHrNqlddH7b6TPi8GnrB8xUeDUczcjUjFLwfK0wM3YVWSMnDvV9aLw0q1LQLI8Q7R7 Jh4= X-IronPort-AV: E=Sophos;i="5.81,307,1610434800"; d="scan'208";a="112481602" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 05 Apr 2021 08:52:49 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 5 Apr 2021 08:52:49 -0700 Received: from ROB-ULT-M18282.microchip.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2176.2 via Frontend Transport; Mon, 5 Apr 2021 08:52:23 -0700 From: Eugen Hristev To: , CC: , , Eugen Hristev Subject: [PATCH v2 03/30] media: atmel: atmel-isc: add checks for limiting frame sizes Date: Mon, 5 Apr 2021 18:50:38 +0300 Message-ID: <20210405155105.162529-4-eugen.hristev@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210405155105.162529-1-eugen.hristev@microchip.com> References: <20210405155105.162529-1-eugen.hristev@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When calling the subdev, certain subdev drivers will overwrite the frame size and adding sizes which are beyond the ISC's capabilities. Thus we need to ensure the frame size is cropped to the maximum caps. Signed-off-by: Eugen Hristev --- drivers/media/platform/atmel/atmel-isc-base.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/media/platform/atmel/atmel-isc-base.c b/drivers/media/platform/atmel/atmel-isc-base.c index 277a8fd8b83d..45fc8dbb7943 100644 --- a/drivers/media/platform/atmel/atmel-isc-base.c +++ b/drivers/media/platform/atmel/atmel-isc-base.c @@ -1326,6 +1326,12 @@ static int isc_try_fmt(struct isc_device *isc, struct v4l2_format *f, v4l2_fill_pix_format(pixfmt, &format.format); + /* Limit to Atmel ISC hardware capabilities */ + if (pixfmt->width > ISC_MAX_SUPPORT_WIDTH) + pixfmt->width = ISC_MAX_SUPPORT_WIDTH; + if (pixfmt->height > ISC_MAX_SUPPORT_HEIGHT) + pixfmt->height = ISC_MAX_SUPPORT_HEIGHT; + pixfmt->field = V4L2_FIELD_NONE; pixfmt->bytesperline = (pixfmt->width * isc->try_config.bpp) >> 3; pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height; @@ -1361,6 +1367,12 @@ static int isc_set_fmt(struct isc_device *isc, struct v4l2_format *f) if (ret < 0) return ret; + /* Limit to Atmel ISC hardware capabilities */ + if (pixfmt->width > ISC_MAX_SUPPORT_WIDTH) + pixfmt->width = ISC_MAX_SUPPORT_WIDTH; + if (pixfmt->height > ISC_MAX_SUPPORT_HEIGHT) + pixfmt->height = ISC_MAX_SUPPORT_HEIGHT; + isc->fmt = *f; if (isc->try_config.sd_format && isc->config.sd_format && -- 2.25.1