From: "Gjorgji Rosikopulos (Consultant)" <quic_grosikop@quicinc.com>
To: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>,
<rfoss@kernel.org>, <todor.too@gmail.com>,
<bryan.odonoghue@linaro.org>, <andersson@kernel.org>,
<konrad.dybcio@linaro.org>, <mchehab@kernel.org>
Cc: <linux-media@vger.kernel.org>, <linux-arm-msm@vger.kernel.org>,
<linux-kernel@vger.kernel.org>,
<laurent.pinchart@ideasonboard.com>, <hverkuil-cisco@xs4all.nl>,
<quic_hariramp@quicinc.com>
Subject: Re: [PATCH v3 5/8] media: qcom: camss: Move format related functions
Date: Mon, 13 May 2024 19:52:02 +0300 [thread overview]
Message-ID: <d53fec3e-e46c-4185-abcd-e621818057a5@quicinc.com> (raw)
In-Reply-To: <c6797921-2c2b-4dc1-866e-011d10c9d3c2@linaro.org>
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 <quic_rtsvetko@quicinc.com>
>>
>> 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 <quic_rtsvetko@quicinc.com>
>> Signed-off-by: Gjorgji Rosikopulos <quic_grosikop@quicinc.com>
>> ---
>> 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 <linux/bug.h>
>> +#include <linux/errno.h>
>> +
>> +#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
next prev parent reply other threads:[~2024-05-13 16:52 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-11 12:45 [PATCH v3 0/8] Move camss version related defs in to resources Gjorgji Rosikopulos
2024-04-11 12:45 ` [PATCH v3 1/8] media: qcom: camss: Add per sub-device type resources Gjorgji Rosikopulos
2024-05-10 18:26 ` Bryan O'Donoghue
2024-05-10 22:18 ` Bryan O'Donoghue
2024-05-13 9:55 ` Gjorgji Rosikopulos (Consultant)
2024-05-10 23:09 ` [PATCH v3.1] " Bryan O'Donoghue
2024-04-11 12:45 ` [PATCH v3 2/8] media: qcom: camss: Attach formats to VFE resources Gjorgji Rosikopulos
2024-05-10 18:27 ` Bryan O'Donoghue
2024-05-13 15:15 ` Vladimir Zapolskiy
2024-05-13 15:35 ` Gjorgji Rosikopulos (Consultant)
2024-05-13 17:36 ` Bryan O'Donoghue
2024-05-14 8:39 ` Gjorgji Rosikopulos (Consultant)
2024-04-11 12:45 ` [PATCH v3 3/8] media: qcom: camss: Attach formats to CSID resources Gjorgji Rosikopulos
2024-05-10 18:27 ` Bryan O'Donoghue
2024-04-11 12:45 ` [PATCH v3 4/8] media: qcom: camss: Attach formats to CSIPHY resources Gjorgji Rosikopulos
2024-05-10 18:28 ` Bryan O'Donoghue
2024-04-11 12:45 ` [PATCH v3 5/8] media: qcom: camss: Move format related functions Gjorgji Rosikopulos
2024-05-10 18:28 ` Bryan O'Donoghue
2024-05-13 15:39 ` Vladimir Zapolskiy
2024-05-13 16:52 ` Gjorgji Rosikopulos (Consultant) [this message]
2024-05-13 17:43 ` Bryan O'Donoghue
2024-04-11 12:45 ` [PATCH v3 6/8] media: qcom: camss: Split testgen, RDI and RX for CSID 170 Gjorgji Rosikopulos
2024-05-10 18:28 ` Bryan O'Donoghue
2024-04-11 12:45 ` [PATCH v3 7/8] media: qcom: camss: Decompose register and link operations Gjorgji Rosikopulos
2024-05-10 18:29 ` Bryan O'Donoghue
2024-04-11 12:45 ` [PATCH v3 8/8] media: qcom: camss: Decouple VFE from CSID Gjorgji Rosikopulos
2024-05-10 18:29 ` Bryan O'Donoghue
2024-05-13 15:58 ` Vladimir Zapolskiy
2024-05-13 16:26 ` Gjorgji Rosikopulos (Consultant)
2024-05-13 17:48 ` Bryan O'Donoghue
2024-05-10 18:33 ` [PATCH v3 0/8] Move camss version related defs in to resources Bryan O'Donoghue
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d53fec3e-e46c-4185-abcd-e621818057a5@quicinc.com \
--to=quic_grosikop@quicinc.com \
--cc=andersson@kernel.org \
--cc=bryan.odonoghue@linaro.org \
--cc=hverkuil-cisco@xs4all.nl \
--cc=konrad.dybcio@linaro.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=quic_hariramp@quicinc.com \
--cc=rfoss@kernel.org \
--cc=todor.too@gmail.com \
--cc=vladimir.zapolskiy@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox