Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2662067pxb; Fri, 5 Nov 2021 02:29:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzi98m8uHw4oid4+8XXqq0BPrA324SD7kEEpM3XwxU4vyjhenD94HTbmtn8Yw+UWPtGvvXm X-Received: by 2002:a17:906:368c:: with SMTP id a12mr69528256ejc.143.1636104589727; Fri, 05 Nov 2021 02:29:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636104589; cv=none; d=google.com; s=arc-20160816; b=x7oWIP4ZVCw5s9RVVNtmaCnod2NsrGbHE4hBSV7CTvhqYmjzJiyuDusHYNCk0gYcFs YM+xMhbT2ZaNE61V1Nd4kkSAy1jCRUFqHbGzTM9AsL4vNm7ALBZFJ9EY6dR/0Abb6i9Z 9quBUqqTbjVRmezqkF9O3yq2k1yneEH4DWCtQdDd7VQld79wAU9uDrA7PEgcs3gh8Uqy RnR9tyiPVlo9uGWIS5LGvN2llOZq6Jb2Xart7Tq6gJtrC9GVPF4hwm9fIIE93lkPwgnk 20gZ470zJED9ud5s275DixyDjJeV+dkgLcV5rfVhgaOqNxobFQjeT5be5iCqS6uRHKul 7Reg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=3t6JCTnqJoNiEhA87RMZZd30oy8WHAsTf+fAVvXTXxY=; b=QXFIi3GgHxYhnCqOKjtJvlSAqe/RYomwrvdRmwyMnffDME1lnxAlzfFex57UxxjH/c izbLdnazdguB13FbRZOPLKzq57l8T+MBDMuKgWfnf8zj1QB3gmwpbThAqbl64NXZ9hJb TMtB6RmeNUx/dRZBec0GGP4ja8YTYfBaXWl504PU1uMdZFuPzZ4btrnmsNHoBxpA3HOK pW6SFeDpGwJFAw14bp2cK33NYjYUDNX1qQRFLGeT468P6k04oYGLybrs8H1TT7H9Om7c xf7lXK/eTD1zKTwszSncuPq0jdhGEMvHbz6Ef9IBZQddbM6B0t9UF4jqmWYdZSd871Nh uv5w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d8si15747903edm.486.2021.11.05.02.29.24; Fri, 05 Nov 2021 02:29:49 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232719AbhKEJ1w (ORCPT + 99 others); Fri, 5 Nov 2021 05:27:52 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:38089 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232716AbhKEJ1v (ORCPT ); Fri, 5 Nov 2021 05:27:51 -0400 Received: (Authenticated sender: jacopo@jmondi.org) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 521BA24000C; Fri, 5 Nov 2021 09:25:06 +0000 (UTC) Date: Fri, 5 Nov 2021 10:25:59 +0100 From: Jacopo Mondi To: Eugen Hristev Cc: linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, laurent.pinchart@ideasonboard.com, sakari.ailus@iki.fi, robh+dt@kernel.org, nicolas.ferre@microchip.com Subject: Re: [PATCH 11/21] media: atmel: atmel-isc-base: implement mbus_code support in enumfmt Message-ID: <20211105092559.ce6pdm4hwvxkmutd@uno.localdomain> References: <20211022075247.518880-1-eugen.hristev@microchip.com> <20211022075247.518880-12-eugen.hristev@microchip.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20211022075247.518880-12-eugen.hristev@microchip.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Eugen, On Fri, Oct 22, 2021 at 10:52:37AM +0300, Eugen Hristev wrote: > If enumfmt is called with an mbus_code, the enumfmt handler should only > return the formats that are supported for this mbus_code. > To make it more easy to understand the formats, changed the report order > to report first the native formats, and after that the formats that the ISC > can convert to. > > Signed-off-by: Eugen Hristev Reviewed-by: Jacopo Mondi Thanks j > --- > drivers/media/platform/atmel/atmel-isc-base.c | 51 ++++++++++++++++--- > 1 file changed, 43 insertions(+), 8 deletions(-) > > diff --git a/drivers/media/platform/atmel/atmel-isc-base.c b/drivers/media/platform/atmel/atmel-isc-base.c > index 2dd2511c7be1..1f7fbe5e4d79 100644 > --- a/drivers/media/platform/atmel/atmel-isc-base.c > +++ b/drivers/media/platform/atmel/atmel-isc-base.c > @@ -499,21 +499,56 @@ static int isc_enum_fmt_vid_cap(struct file *file, void *priv, > u32 index = f->index; > u32 i, supported_index; > > - if (index < isc->controller_formats_size) { > - f->pixelformat = isc->controller_formats[index].fourcc; > - return 0; > + supported_index = 0; > + > + for (i = 0; i < isc->formats_list_size; i++) { > + if (!isc->formats_list[i].sd_support) > + continue; > + /* > + * If specific mbus_code is requested, provide only > + * supported formats with this mbus code > + */ > + if (f->mbus_code && f->mbus_code != > + isc->formats_list[i].mbus_code) > + continue; > + if (supported_index == index) { > + f->pixelformat = isc->formats_list[i].fourcc; > + return 0; > + } > + supported_index++; > } > > - index -= isc->controller_formats_size; > + /* > + * If the sensor does not support this mbus_code whatsoever, > + * there is no reason to advertise any of our output formats > + */ > + if (supported_index == 0) > + return -EINVAL; > + > + /* > + * If the sensor uses a format that is not raw, then we cannot > + * convert it to any of the formats that we usually can with a > + * RAW sensor. Thus, do not advertise them. > + */ > + if (!isc->config.sd_format || > + !ISC_IS_FORMAT_RAW(isc->config.sd_format->mbus_code)) > + return -EINVAL; > > + /* > + * Iterate again through the formats that we can convert to. > + * However, to avoid duplicates, skip the formats that > + * the sensor already supports directly > + */ > + index -= supported_index; > supported_index = 0; > > - for (i = 0; i < isc->formats_list_size; i++) { > - if (!ISC_IS_FORMAT_RAW(isc->formats_list[i].mbus_code) || > - !isc->formats_list[i].sd_support) > + for (i = 0; i < isc->controller_formats_size; i++) { > + /* if this format is already supported by sensor, skip it */ > + if (find_format_by_fourcc(isc, isc->controller_formats[i].fourcc)) > continue; > if (supported_index == index) { > - f->pixelformat = isc->formats_list[i].fourcc; > + f->pixelformat = > + isc->controller_formats[i].fourcc; > return 0; > } > supported_index++; > -- > 2.25.1 >