From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6E6C5C433F5 for ; Mon, 13 Dec 2021 14:00:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FGmvY3GjW7Qtkm69hA8R3wmNqWF9y3h/m6XFxnQdjtY=; b=2BHc5jo1xMn/79 mwJsn8JjHsgrOM9S3nWTSuALsuRCwvw8XLwFw8x+kLk9U1FqdUH02MiCALeeYzzub1aqhtzraTbYo bLR9c/6IDFYg90bo7l8UOKMyKicQ65rTP0EW1/Cr5EhI03lwN8kvavoxDs3kDAJg6DS/onGtkDjmW EsV/OiRWARIu4lDnJJCVaIE0ontlXx3VolB3YHl4+g74bTLofrvCAgZS05Cr7knhM5diKcNLFy0GB MlfKEYhCBd81KmqDgWqn6uCB6QGkhgqFvIyjX51KDmtuY5LgYpzfMDo/miQMcF3mkzw4e10zamIqn gT3OoXCpcpCIiAMV1JhQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mwlqs-009rP4-Q9; Mon, 13 Dec 2021 13:58:53 +0000 Received: from esa.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mwlkl-009oYL-Qq for linux-arm-kernel@lists.infradead.org; Mon, 13 Dec 2021 13:52:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1639403551; x=1670939551; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wAej8zbZ2Z8QMflPY6dkTpKKqPVWmjJ48/bava7RNWY=; b=zVi9oAmEA6Bn1uYv4ebBcbyuKZs+3UnIfdvUO6fZhQj1JxGu7vii2z8+ n1gKpn/c2kkLtWBOp32B6X1HxkuVUEHPVxiLw+Jph+xZukzHlmRpxMs8M 1xrB/8Of59288UdT2Ym6d91Yjt/QHQGm3WtJruEqWtq0S0LbHq8DTV+Oi Bem1xwXrdowlMadj86kBk4yEx1zY/3gpeIPs6WnIMXN3JDw/IBbEQjPCo Max80RZAs4JXfDZvyZy+aHF+g6tVqpn0Y900Dz4PjhxKaOV8ms24l7a96 JHr0WOTW3VerIt42Sb6/8CIbDSYN7KpsuNeT9Z11n5wrf1uc5AqmRrIOz w==; IronPort-SDR: 599aJWp803J+oMAyfn+chvLvjzlwg9oh+44yXjG1eiGl0w3Bv5y2H4xXRkyZ7u/uzbljoR3gYJ f1u3HibW+CQiSajjpmFJyM6xqNlzuK7CEqtGguSOEZIEjTw4sAhCgO2uXa2itFYAPHraM4gNdv ASPD3yr21BGzSAdg2qGgLXwfIsAI1UsREXOmi+IaZf/OsxhsnglpGt51phXeoQlxlB4qT2HyBz dduFS36DUvmQDUonqyDsXZlpR79JbPljTJz8UTR3mmhk/ZbGe50MYv8+CE84LXE/NlAST41RN/ ssQ5zOemL8fTv/K5bEh3iKT8 X-IronPort-AV: E=Sophos;i="5.88,202,1635231600"; d="scan'208";a="79361735" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 13 Dec 2021 06:52:30 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Mon, 13 Dec 2021 06:52:30 -0700 Received: from ROB-ULT-M18282.microchip.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Mon, 13 Dec 2021 06:52:20 -0700 From: Eugen Hristev To: , , , , Subject: [PATCH v3 10/23] media: atmel: atmel-isc-base: implement mbus_code support in enumfmt Date: Mon, 13 Dec 2021 15:49:27 +0200 Message-ID: <20211213134940.324266-11-eugen.hristev@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211213134940.324266-1-eugen.hristev@microchip.com> References: <20211213134940.324266-1-eugen.hristev@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211213_055231_969597_9993824C X-CRM114-Status: GOOD ( 17.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Eugen Hristev , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 --- 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 bf638d201b29..2cb8446ff90c 100644 --- a/drivers/media/platform/atmel/atmel-isc-base.c +++ b/drivers/media/platform/atmel/atmel-isc-base.c @@ -498,21 +498,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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel