From: Depeng Shao <quic_depengs@quicinc.com>
To: Bryan O'Donoghue <bryan.odonoghue@linaro.org>, <rfoss@kernel.org>,
<todor.too@gmail.com>, <mchehab@kernel.org>, <robh@kernel.org>,
<krzk+dt@kernel.org>, <conor+dt@kernel.org>
Cc: <quic_eberman@quicinc.com>, <linux-media@vger.kernel.org>,
<linux-arm-msm@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <kernel@quicinc.com>,
Yongsheng Li <quic_yon@quicinc.com>
Subject: Re: [PATCH 09/13] media: qcom: camss: Add CSID Gen3 support for SM8550
Date: Thu, 11 Jul 2024 23:33:56 +0800 [thread overview]
Message-ID: <eeaf4f4e-5200-4b13-b38f-3f3385fc2a2b@quicinc.com> (raw)
In-Reply-To: <e118f980-e10f-450c-8270-76602cc50b27@linaro.org>
Hi Bryan,
On 7/10/2024 7:28 PM, Bryan O'Donoghue wrote:
> On 09/07/2024 17:06, Depeng Shao wrote:
>> The CSID in SM8550 is gen3, it has new register offset and new
>> functionality. The buf done irq,register update and reset are
>> moved to CSID gen3. And CSID gen3 has a new register block which
>> is named as CSID top, it controls the output of CSID, since the
>> CSID can connect to Sensor Front End (SFE) or original VFE, the
>> register in top block is used to control the HW connection.
>>
>> Co-developed-by: Yongsheng Li <quic_yon@quicinc.com>
>> Signed-off-by: Yongsheng Li <quic_yon@quicinc.com>
>> Signed-off-by: Depeng Shao <quic_depengs@quicinc.com>
>> ---
>> drivers/media/platform/qcom/camss/Makefile | 1 +
>> .../platform/qcom/camss/camss-csid-gen3.c | 445 ++++++++++++++++++
>> .../platform/qcom/camss/camss-csid-gen3.h | 26 +
>> .../media/platform/qcom/camss/camss-csid.h | 2 +
>> 4 files changed, 474 insertions(+)
>> create mode 100644 drivers/media/platform/qcom/camss/camss-csid-gen3.c
>> create mode 100644 drivers/media/platform/qcom/camss/camss-csid-gen3.h
>>
>> +
>> +#define REG_UPDATE_RDI reg_update_rdi
>> +
>> +static void __csid_configure_rx(struct csid_device *csid,
>> + struct csid_phy_config *phy, int vc)
>> +{
>> + int val;
>> +
>> + val = (phy->lane_cnt - 1) << CSI2_RX_CFG0_NUM_ACTIVE_LANES;
>> + val |= phy->lane_assign << CSI2_RX_CFG0_DL0_INPUT_SEL;
>> + val |= (phy->csiphy_id + CSI2_RX_CFG0_PHY_SEL_BASE_IDX) <<
>> CSI2_RX_CFG0_PHY_NUM_SEL;
>> +
>> + writel_relaxed(val, csid->base + CSID_CSI2_RX_CFG0);
>> +
>> + val = 1 << CSI2_RX_CFG1_PACKET_ECC_CORRECTION_EN;
>> + if (vc > 3)
>> + val |= 1 << CSI2_RX_CFG1_VC_MODE;
>
> I realise downstream does these shifts but, I think in upstream we
> should just define a BIT(x)
>
> #define CSI2_RX_CFG1_VC_MODE BIT(2)
>
> val |= CSI2_RX_CFG1_VC_MODE;
>
Here CSI2_RX_CFG1_VC_MODE just means a register bit offset, not a
register configuration.
Some fixed configuration can do this, but some register bits value are
configured based on actual parameter.
e.g.; val = (phy->lane_cnt - 1) << CSI2_RX_CFG0_NUM_ACTIVE_LANES;
If we want to use macro definition, maybe we can do like below.
#define CSI2_RX_CFG1_VC_MODE(n) ((n) << 2)
val |= CSI2_RX_CFG1_VC_MODE(1);
#define CSI2_RX_CFG0_DL0_INPUT_SEL(n) ((n) << 4)
val |= CSI2_RX_CFG0_DL0_INPUT_SEL(phy->lane_assign)
Could you please comment if we really need to do like this?
>> + writel_relaxed(val, csid->base + CSID_CSI2_RX_CFG1);
>> +}
>> +
>> +static void __csid_ctrl_rdi(struct csid_device *csid, int enable, u8
>> rdi)
>> +{
>> + int val;
>> +
>> + if (enable)
>> + val = 1 << RDI_CTRL_START_CMD;
>> + else
>> + val = 0 << RDI_CTRL_START_CMD;
>
> Here is an example of how the bit shifting is weird
>
> (0 << anything) is still zero
>
Understood, the value is same, but we can know the configuration clearly
on this register bit. If we do like above way, then it likes below.
#define RDI_CTRL_START_CMD(n) ((n) << 0) --> it is same with (n), but
we don't know the register bit offset clearly if we use (n).
if (enable)
val = RDI_CTRL_START_CMD(1);
else
val = RDI_CTRL_START_CMD(0);
>> + writel_relaxed(val, csid->base + CSID_RDI_CTRL(rdi));
>> +}
>> +
>> +static void __csid_configure_top(struct csid_device *csid)
>> +{
>> + u32 val;
>> +
>> + /* CSID "top" is a new function in Titan780.
>> + * CSID can connect to VFE & SFE(Sensor Front End).
>> + * This connection is ontrolled by CSID "top".
>> + * Only enable VFE path in current driver.
>> + */
>> + if (csid->top_base) {
>
> When is csid->top_base NULL ?
>
> Its required in your yaml.
>
csid->top_base is NULL when it is csid lite, I will add this info in yaml.
>> +
>> +static void csid_configure_stream(struct csid_device *csid, u8 enable)
>> +{
>> + u8 i;
>> +
>> + /* Loop through all enabled VCs and configure stream for each */
>> + for (i = 0; i < MSM_CSID_MAX_SRC_STREAMS; i++)
>> + if (csid->phy.en_vc & BIT(i)) {
>> + /* Configure CSID "top" */
>> + __csid_configure_top(csid);
>> + __csid_configure_rdi_stream(csid, enable, i);
>> + __csid_configure_rx(csid, &csid->phy, i);
>> + __csid_ctrl_rdi(csid, enable, i);
>> + }
>> +}
>
> I really like this breakdown
Sorry, I don't get it, do you mean you like that configuring the
different block use different functions, and no other meaning?
>> +
>> +static int csid_configure_testgen_pattern(struct csid_device *csid,
>> s32 val)
>> +{
>> + if (val > 0 && val <= csid->testgen.nmodes)
>> + csid->testgen.mode = val;
>
> Surely you should just set the val parameter directly ?
>
> Also why is this a signed integer and how does it get assigned a
> negative value which we need to mitigate against here >
This was copied from csid-gen2 driver, they are same, so we can move to
common file.
And the val comes from ctrl->val, so I guess this is the reason why this
agrument is signed integer.
struct v4l2_ctrl {
...
s32 val;
...
};
>> +
>> +static u32 csid_src_pad_code(struct csid_device *csid, u32 sink_code,
>> + unsigned int match_format_idx, u32 match_code)
>> +{
>> + switch (sink_code) {
>> + case MEDIA_BUS_FMT_SBGGR10_1X10:
>> + {
>> + u32 src_code[] = {
>> + MEDIA_BUS_FMT_SBGGR10_1X10,
>> + MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE,
>> + };
>> +
>> + return csid_find_code(src_code, ARRAY_SIZE(src_code),
>> + match_format_idx, match_code);
>> + }
>> + case MEDIA_BUS_FMT_Y10_1X10:
>> + {
>> + u32 src_code[] = {
>> + MEDIA_BUS_FMT_Y10_1X10,
>> + MEDIA_BUS_FMT_Y10_2X8_PADHI_LE,
>> + };
>> +
>> + return csid_find_code(src_code, ARRAY_SIZE(src_code),
>> + match_format_idx, match_code);
>> + }
>> + default:
>> + if (match_format_idx > 0)
>> + return 0;
>> +
>> + return sink_code;
>> + }
>> +}
>
> Same code as in gen2.
>
> You could move the gen2 version of this into camss-csid.c and just reuse
> in both.
>
Sure, it is same with the comments in vfe driver, I will try to move
same code to camss-csid.c
Thanks,
Depeng
next prev parent reply other threads:[~2024-07-11 15:34 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-09 16:06 [PATCH V3 00/13] media: qcom: camss: Add sm8550 support Depeng Shao
2024-07-09 16:06 ` [PATCH 01/13] media: qcom: camss: csiphy-3ph: Fix trivial indentation fault in defines Depeng Shao
2024-07-31 23:16 ` Vladimir Zapolskiy
2024-07-09 16:06 ` [PATCH 02/13] media: qcom: camss: csiphy-3ph: Remove redundant PHY init sequence control loop Depeng Shao
2024-07-31 23:27 ` Vladimir Zapolskiy
2024-07-09 16:06 ` [PATCH 03/13] media: qcom: camss: csiphy-3ph: Rename struct Depeng Shao
2024-07-31 23:28 ` Vladimir Zapolskiy
2024-07-09 16:06 ` [PATCH 04/13] media: qcom: camss: csiphy: Add an init callback to CSI PHY devices Depeng Shao
2024-07-31 23:43 ` Vladimir Zapolskiy
2024-08-01 8:16 ` Bryan O'Donoghue
2024-08-04 21:26 ` Vladimir Zapolskiy
2024-08-07 13:08 ` Depeng Shao
2024-08-07 14:04 ` Bryan O'Donoghue
2024-08-07 15:03 ` Depeng Shao
2024-08-07 15:37 ` Bryan O'Donoghue
2024-08-08 14:02 ` Depeng Shao
2024-08-12 11:32 ` Bryan O'Donoghue
2024-08-12 12:20 ` Depeng Shao
2024-07-09 16:06 ` [PATCH 05/13] media: qcom: camss: csiphy-3ph: Move CSIPHY variables to data field inside csiphy struct Depeng Shao
2024-07-31 23:55 ` Vladimir Zapolskiy
2024-07-09 16:06 ` [PATCH 06/13] media: qcom: camss: csiphy-3ph: Use an offset variable to find common control regs Depeng Shao
2024-07-09 16:06 ` [PATCH 07/13] dt-bindings: media: camss: Add qcom,sm8550-camss binding Depeng Shao
2024-07-09 20:21 ` Rob Herring (Arm)
2024-07-10 9:37 ` Bryan O'Donoghue
2024-07-10 10:59 ` Depeng Shao
2024-07-10 11:07 ` Krzysztof Kozlowski
2024-07-11 10:43 ` Depeng Shao
2024-08-01 0:05 ` Vladimir Zapolskiy
2024-08-01 2:02 ` Depeng Shao
2024-07-09 16:06 ` [PATCH 08/13] media: qcom: camss: csiphy-3ph: Add Gen2 v1.2 two-phase MIPI CSI-2 DPHY init Depeng Shao
2024-07-10 11:09 ` Krzysztof Kozlowski
2024-07-10 13:14 ` Depeng Shao
2024-07-10 11:13 ` Bryan O'Donoghue
2024-07-10 13:33 ` Depeng Shao
2024-07-09 16:06 ` [PATCH 09/13] media: qcom: camss: Add CSID Gen3 support for SM8550 Depeng Shao
2024-07-10 11:20 ` Krzysztof Kozlowski
2024-07-11 11:08 ` Depeng Shao
2024-07-11 11:12 ` Krzysztof Kozlowski
2024-07-11 11:41 ` Depeng Shao
2024-07-11 12:00 ` Bryan O'Donoghue
2024-07-11 12:14 ` Depeng Shao
2024-07-11 12:17 ` Krzysztof Kozlowski
2024-07-31 15:26 ` Depeng Shao
2024-07-31 16:12 ` Bryan O'Donoghue
2024-08-01 1:53 ` Depeng Shao
2024-08-01 10:59 ` Bryan O'Donoghue
2024-08-01 11:14 ` Bryan O'Donoghue
2024-08-01 13:49 ` Depeng Shao
2024-07-10 11:28 ` Bryan O'Donoghue
2024-07-11 15:33 ` Depeng Shao [this message]
2024-08-07 15:10 ` Depeng Shao
2024-07-09 16:06 ` [PATCH 10/13] media: qcom: camss: Add support for VFE hardware version Titan 780 Depeng Shao
2024-07-10 11:22 ` Krzysztof Kozlowski
2024-07-10 11:47 ` Bryan O'Donoghue
2024-07-11 13:29 ` Depeng Shao
2024-07-09 16:06 ` [PATCH 11/13] media: qcom: camss: Add notify interface in camss driver Depeng Shao
2024-07-10 11:54 ` Bryan O'Donoghue
2024-07-11 11:54 ` Depeng Shao
2024-07-09 16:06 ` [PATCH 12/13] media: qcom: camss: Add sm8550 support Depeng Shao
2024-07-10 12:02 ` Bryan O'Donoghue
2024-07-11 14:36 ` Depeng Shao
2024-07-09 16:06 ` [PATCH 13/13] media: qcom: camss: Add sm8550 resources Depeng Shao
2024-07-10 11:08 ` [PATCH V3 00/13] media: qcom: camss: Add sm8550 support Krzysztof Kozlowski
2024-07-10 11:27 ` Depeng Shao
2024-07-10 12:30 ` Krzysztof Kozlowski
2024-07-11 11:14 ` Depeng Shao
2024-08-24 17:05 ` 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=eeaf4f4e-5200-4b13-b38f-3f3385fc2a2b@quicinc.com \
--to=quic_depengs@quicinc.com \
--cc=bryan.odonoghue@linaro.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=kernel@quicinc.com \
--cc=krzk+dt@kernel.org \
--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_eberman@quicinc.com \
--cc=quic_yon@quicinc.com \
--cc=rfoss@kernel.org \
--cc=robh@kernel.org \
--cc=todor.too@gmail.com \
/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