Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2177392lqo; Mon, 13 May 2024 09:53:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX8r+urEByyS/M28aMYtizsnRyhy71psQa774nye1L9UmTURNu4vaPX9vvL3JZ1xwUg5wAhi/LOB01M4jdtuO0cuxtli4gGLWwoN9OdkA== X-Google-Smtp-Source: AGHT+IHZpMMdL0GrTniODkW75MaiuRh8YJfWXZk+z5OzlbNZFeHHjW2K+3kFDFRXtUe2Ng/e0nJF X-Received: by 2002:a05:6358:7204:b0:192:8935:4067 with SMTP id e5c5f4694b2df-193bb612b4fmr1288606655d.14.1715619199823; Mon, 13 May 2024 09:53:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715619199; cv=pass; d=google.com; s=arc-20160816; b=hbYrtf+HPThIiEDPFN7ATZXQeuQ7Xlr4+YqJqxoyaega2erByoNjecwT5qjmkmsDa3 XUh+GrPGoXfbpwyEcvqOma1Q4eTUH+l4qsAkDhT2nii0isYIedvoBQFk1ibynl/AVDDv IRF7fCxNA4rR8iKBkBGOVGCDopuGLAqnLwHOrE3yFtTE3K4igFdjzd6PZPqd+cUUzrIJ 1yXQnFjGJ997k3JNtDuDTp1CxY23lpQVWuxRqx8EQZpgaSn4wpeXUfrJHp8YqWuGGgka GADL+kwYnTJqrBNN+IxeCeNLEeTV1+9y2Pvul2pcu1WMevAgJdWxi41SkvB9jTnefA/O Ua/A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=Es6jTmjTFhFxEXJqbKsv8hP+lTSCf3yS1oPECWLd7uU=; fh=saStlOxtygyJX8I8OdQzTu92r4en6un8lJXqCHXUTX4=; b=DVsLbu2rkZb3FGuP4NnpfA6qzZK/mTUZLgh8iAsnAQMTUohf8JnVEwRLwdQh0t+HBJ w9Sz1nep18hXr5MO5RtLIiIYgJw+rDGr86W62TdHZrnQwDJx93kHwHXWWiNrBsuZhYrn GHwVsa3fexdh0Vk5S33cU+c/Rh7wLWPNyyq2WazPAK890BbB51QUXhHxcz9dmslaAFqz ywY2QRqJasIfy0DOaPkINajrGzkOPgaHWz4clswP2DG6fZ/7xySBM749lYlr1mwiDM+u kuUqPAsySysM4HN0Z8nwvCSghFD5nkqcLcG0MhSrvy6qhCUWlRMTun7cSThu0T24i08T bchA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=b8bL5T2q; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-177854-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177854-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-6340a06c2d9si9235886a12.4.2024.05.13.09.53.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 09:53:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-177854-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=b8bL5T2q; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-177854-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177854-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id B6E70B23B7C for ; Mon, 13 May 2024 16:52:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E5D171C694; Mon, 13 May 2024 16:52:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="b8bL5T2q" Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5BEFD18C3D; Mon, 13 May 2024 16:52:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715619139; cv=none; b=ulLDR7zAHADkUjwxcTWYCgtyv+2ji0Eq5Q9TpK3hUrkSxlmAAvR5F2atse5CqmeUQ6UV+eUMAiydDVT3lgjZbTL7IQPoaF6877er1VTSN1bKo/a8m5slwaL7ih10Cpidu5VAJqHiEN/IqpbEqrvG0+Y2BG/0PxSTZT1Gv1KeGNw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715619139; c=relaxed/simple; bh=HxxOong3W3gZPaT5eDY3JXpmkoKgzN6SCBTlmXMa5lU=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=L5iHmvFJpjyPp/zrxe6/x/hcOdhPEUHJ9p+gG0SRJATQFOYIYFAlpmO3B/Jde19oZeQDNfx8P+sg1Hy6RSPkquAVJgrG6qyN+M+7UCmH1Bd3MX+jdG2O5Jea6Gd1viVKzaJloxu4+aIeywDiIGvdCbuC/2UD900kJWofhUI6JEc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=b8bL5T2q; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 44DBKFuT028330; Mon, 13 May 2024 16:52:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= message-id:date:mime-version:subject:to:cc:references:from :in-reply-to:content-type:content-transfer-encoding; s= qcppdkim1; bh=Es6jTmjTFhFxEXJqbKsv8hP+lTSCf3yS1oPECWLd7uU=; b=b8 bL5T2qM6w6vWqsveIlmPT6FTE+fEHl/SgiNkv56tjxBXCYVJ0SIg76lJVLQgmOli 17SFFFZc5wP6pDBDj+MvzoH2h0AAhphre+NP+OYqcJ0kcEobhDH1fPi3Bq+TcBw/ QsdEVeBalSbAUGFnGF3hiKyk+HIxqJh+dc3k+zF8Pb0UM0UnyRTJG34OnFNdRbrn KzgjumTmYHZAyXeD743//D3gG6fegklJIgC2ka8Phusi+H2ZyJRYpSUV+Kz6zjVY ttLWSzC/dOm1fPYju+MhZ5juBzoHxUpLxhiR/v8ITbtB8qu8Cc2H5bJ1xhQLVNIA U4liJwWFrg04LepwDmcA== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3y1ymq45qg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 May 2024 16:52:11 +0000 (GMT) Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 44DGq9Uj022330 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 May 2024 16:52:09 GMT Received: from [10.251.44.40] (10.80.80.8) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Mon, 13 May 2024 09:52:04 -0700 Message-ID: Date: Mon, 13 May 2024 19:52:02 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 5/8] media: qcom: camss: Move format related functions Content-Language: en-US To: Vladimir Zapolskiy , , , , , , CC: , , , , , References: <20240411124543.199-1-quic_grosikop@quicinc.com> <20240411124543.199-6-quic_grosikop@quicinc.com> From: "Gjorgji Rosikopulos (Consultant)" In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: w_TBqawH3ZvU1dG_Am_m1ksTWIZOPq5_ X-Proofpoint-ORIG-GUID: w_TBqawH3ZvU1dG_Am_m1ksTWIZOPq5_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-13_11,2024-05-10_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 bulkscore=0 malwarescore=0 mlxlogscore=999 priorityscore=1501 phishscore=0 lowpriorityscore=0 mlxscore=0 impostorscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405010000 definitions=main-2405130109 Hi Vladimir, Thanks for the review, On 5/13/2024 6:39 PM, Vladimir Zapolskiy wrote: > On 4/11/24 15:45, Gjorgji Rosikopulos wrote: >> From: Radoslav Tsvetkov >> >> Move out the format related helper functions from vfe and video in a >> separate file. The goal here is to create a format API. >> >> Signed-off-by: Radoslav Tsvetkov >> Signed-off-by: Gjorgji Rosikopulos >> --- >>   drivers/media/platform/qcom/camss/Makefile    |  1 + >>   .../media/platform/qcom/camss/camss-format.c  | 98 +++++++++++++++++++ >>   .../media/platform/qcom/camss/camss-format.h  |  5 + >>   drivers/media/platform/qcom/camss/camss-vfe.c | 86 +++++----------- >>   .../media/platform/qcom/camss/camss-video.c   | 26 +---- >>   5 files changed, 128 insertions(+), 88 deletions(-) >>   create mode 100644 drivers/media/platform/qcom/camss/camss-format.c >> >> diff --git a/drivers/media/platform/qcom/camss/Makefile >> b/drivers/media/platform/qcom/camss/Makefile >> index 0d4389ab312d..e636968a1126 100644 >> --- a/drivers/media/platform/qcom/camss/Makefile >> +++ b/drivers/media/platform/qcom/camss/Makefile >> @@ -19,5 +19,6 @@ qcom-camss-objs += \ >>           camss-vfe-gen1.o \ >>           camss-vfe.o \ >>           camss-video.o \ >> +        camss-format.o \ >>     obj-$(CONFIG_VIDEO_QCOM_CAMSS) += qcom-camss.o >> diff --git a/drivers/media/platform/qcom/camss/camss-format.c >> b/drivers/media/platform/qcom/camss/camss-format.c >> new file mode 100644 >> index 000000000000..6279cb099625 >> --- /dev/null >> +++ b/drivers/media/platform/qcom/camss/camss-format.c >> @@ -0,0 +1,98 @@ >> +// SPDX-License-Identifier: GPL-2.0-only >> +/* Copyright (c) 2023, The Linux Foundation. All rights reserved. >> + * Copyright (c) 2023 Qualcomm Technologies, Inc. >> + * >> + * This program is free software; you can redistribute it and/or modify >> + * it under the terms of the GNU General Public License version 2 and >> + * only version 2 as published by the Free Software Foundation. >> + * >> + * This program is distributed in the hope that it will be useful, >> + * but WITHOUT ANY WARRANTY; without even the implied warranty of >> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the >> + * GNU General Public License for more details. >> + */ > > SPDX-License-Identifier is fully sufficient, the licence description > shall be removed. I need to check, but as i can see with other files the license description can be removed. > >> + >> +#include >> +#include >> + >> +#include "camss-format.h" >> + >> +/* >> + * camss_format_get_bpp - Map media bus format to bits per pixel >> + * @formats: supported media bus formats array >> + * @nformats: size of @formats array >> + * @code: media bus format code >> + * >> + * Return number of bits per pixel >> + */ >> +u8 camss_format_get_bpp(const struct camss_format_info *formats, >> unsigned int nformats, u32 code) >> +{ >> +    unsigned int i; >> + >> +    for (i = 0; i < nformats; i++) >> +        if (code == formats[i].code) >> +            return formats[i].mbus_bpp; >> + >> +    WARN(1, "Unknown format\n"); >> + >> +    return formats[0].mbus_bpp; >> +} >> + >> +/* >> + * camss_format_find_code - Find a format code in an array >> + * @code: a pointer to media bus format codes array >> + * @n_code: size of @code array >> + * @index: index of code in the array >> + * @req_code: required code >> + * >> + * Return media bus format code >> + */ >> +u32 camss_format_find_code(u32 *code, unsigned int n_code, unsigned >> int index, u32 req_code) >> +{ >> +    int i; >> + >> +    if (!req_code && index >= n_code) >> +        return 0; >> + > > 0 as an error condition indicator is not very common, at least it shall be > documented in the comment. The original function was vfe_find_code. This change moves all format related functions across the sub-device files to camss-format I believe that 0 is default format. > >> +    for (i = 0; i < n_code; i++) { >> +        if (req_code) { >> +            if (req_code == code[i]) >> +                return req_code; >> +        } else { >> +            if (i == index) >> +                return code[i]; >> +        } >> +    } >> + >> +    return code[0]; >> +} >> + >> +/* >> + * camss_format_find_format - Find a format in an array >> + * @code: media bus format code >> + * @pixelformat: V4L2 pixel format FCC identifier >> + * @formats: a pointer to formats array >> + * @nformats: size of @formats array >> + * >> + * Return index of a format or a negative error code otherwise >> + */ >> +int camss_format_find_format(u32 code, u32 pixelformat, const struct >> camss_format_info *formats, >> +                 unsigned int nformats) >> +{ >> +    int i; > > unsigned int i Maybe it makes sense to go to all functions already existing in camss and change int with unsigned int for for loops... > >> + >> +    for (i = 0; i < nformats; i++) { >> +        if (formats[i].code == code && >> +            formats[i].pixelformat == pixelformat) >> +            return i; >> +    } >> + >> +    for (i = 0; i < nformats; i++) { >> +        if (formats[i].code == code) >> +            return i; >> +    } >> + >> +    WARN_ON(1); >> + > > WARN_ON() is not needed here, it has to be removed. Again this is migrated code from camss-video :/. I guess we need bigger consensus to remove this WARN_ON. For me it makes sense to be removed. ~Gjorgji