From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
To: Fei Shao <fshao@chromium.org>
Cc: chunkuang.hu@kernel.org, p.zabel@pengutronix.de,
airlied@gmail.com, daniel@ffwll.ch, matthias.bgg@gmail.com,
dri-devel@lists.freedesktop.org,
linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, kernel@collabora.com
Subject: Re: [PATCH v2 1/4] drm/mediatek: dsi: Use GENMASK() for register mask definitions
Date: Wed, 31 Jan 2024 11:56:42 +0100 [thread overview]
Message-ID: <d8c364a6-932d-4669-af70-5b113556121d@collabora.com> (raw)
In-Reply-To: <CAC=S1ng+kkJS-g3FHe4SC-r1a6hegj3=Any07TCdvTU_apvZNg@mail.gmail.com>
Il 26/12/23 11:46, Fei Shao ha scritto:
> Hi Angelo,
>
> On Wed, Dec 20, 2023 at 9:57 PM AngeloGioacchino Del Regno
> <angelogioacchino.delregno@collabora.com> wrote:
>>
>> Change magic numerical masks with usage of the GENMASK() macro
>> to improve readability.
>>
>> This commit brings no functional changes.
>>
>> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
>> ---
>> drivers/gpu/drm/mediatek/mtk_dsi.c | 46 ++++++++++++++++--------------
>> 1 file changed, 24 insertions(+), 22 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c
>> index a2fdfc8ddb15..23d2c5be8dbb 100644
>> --- a/drivers/gpu/drm/mediatek/mtk_dsi.c
>> +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
>> @@ -58,18 +58,18 @@
>>
>> #define DSI_TXRX_CTRL 0x18
>> #define VC_NUM BIT(1)
>> -#define LANE_NUM (0xf << 2)
>> +#define LANE_NUM GENMASK(5, 2)
>> #define DIS_EOT BIT(6)
>> #define NULL_EN BIT(7)
>> #define TE_FREERUN BIT(8)
>> #define EXT_TE_EN BIT(9)
>> #define EXT_TE_EDGE BIT(10)
>> -#define MAX_RTN_SIZE (0xf << 12)
>> +#define MAX_RTN_SIZE GENMASK(15, 12)
>> #define HSTX_CKLP_EN BIT(16)
>>
>> #define DSI_PSCTRL 0x1c
>> -#define DSI_PS_WC 0x3fff
>> -#define DSI_PS_SEL (3 << 16)
>> +#define DSI_PS_WC GENMASK(14, 0)
>> +#define DSI_PS_SEL GENMASK(19, 16)
>
> GENMASK(17, 16)
That was intended, and depends on the SoC - I should effectively advertise that
in the commit description and I will.
As per the datasheets:
MT8192 - DSI_PS_SEL[18:16]
MT8195 - DSI_PS_SEL[19:16]
...on SoCs that don't have those additional bits, the higher ones are reserved
(unused), so it is safe to have this as 19, 16.
>>
>> #define PACKED_PS_16BIT_RGB565 (0 << 16)
>> #define LOOSELY_PS_18BIT_RGB666 (1 << 16)
>> #define PACKED_PS_18BIT_RGB666 (2 << 16)
>> @@ -109,26 +109,27 @@
>> #define LD0_WAKEUP_EN BIT(2)
>>
>> #define DSI_PHY_TIMECON0 0x110
>> -#define LPX (0xff << 0)
>> -#define HS_PREP (0xff << 8)
>> -#define HS_ZERO (0xff << 16)
>> -#define HS_TRAIL (0xff << 24)
>> +#define LPX GENMASK(7, 0)
>> +#define HS_PREP GENMASK(15, 8)
>> +#define HS_ZERO GENMASK(23, 16)
>> +#define HS_TRAIL GENMASK(31, 24)
>>
>> #define DSI_PHY_TIMECON1 0x114
>> -#define TA_GO (0xff << 0)
>> -#define TA_SURE (0xff << 8)
>> -#define TA_GET (0xff << 16)
>> -#define DA_HS_EXIT (0xff << 24)
>> +#define TA_GO GENMASK(7, 0)
>> +#define TA_SURE GENMASK(15, 8)
>> +#define TA_GET GENMASK(23, 16)
>> +#define DA_HS_EXIT GENMASK(31, 24)
>>
>> #define DSI_PHY_TIMECON2 0x118
>> -#define CONT_DET (0xff << 0)
>> -#define CLK_ZERO (0xff << 16)
>> -#define CLK_TRAIL (0xff << 24)
>> +#define CONT_DET GENMASK(7, 0)
>> +#define DA_HS_SYNC GENMASK(15, 8)
>
> This is new, so please introduce it in a separate patch if intended.
>
I wouldn't really be comfortable doing so: this would mean that I'd
have to first write a constant and then fix that in a later patch...
P.S.: Sorry for working again on this one whole month after .... :-)
Regards,
Angelo
> The rest looks good to me.
>
> Regards,
> Fei
>
>
>>
>> +#define CLK_ZERO GENMASK(23, 16)
>> +#define CLK_TRAIL GENMASK(31, 24)
>>
>> #define DSI_PHY_TIMECON3 0x11c
>> -#define CLK_HS_PREP (0xff << 0)
>> -#define CLK_HS_POST (0xff << 8)
>> -#define CLK_HS_EXIT (0xff << 16)
>> +#define CLK_HS_PREP GENMASK(7, 0)
>> +#define CLK_HS_POST GENMASK(15, 8)
>> +#define CLK_HS_EXIT GENMASK(23, 16)
>>
>> #define DSI_VM_CMD_CON 0x130
>> #define VM_CMD_EN BIT(0)
>> @@ -138,13 +139,14 @@
>> #define FORCE_COMMIT BIT(0)
>> #define BYPASS_SHADOW BIT(1)
>>
>> -#define CONFIG (0xff << 0)
>> +/* CMDQ related bits */
>> +#define CONFIG GENMASK(7, 0)
>> #define SHORT_PACKET 0
>> #define LONG_PACKET 2
>> #define BTA BIT(2)
>> -#define DATA_ID (0xff << 8)
>> -#define DATA_0 (0xff << 16)
>> -#define DATA_1 (0xff << 24)
>> +#define DATA_ID GENMASK(15, 8)
>> +#define DATA_0 GENMASK(23, 16)
>> +#define DATA_1 GENMASK(31, 24)
>>
>> #define NS_TO_CYCLE(n, c) ((n) / (c) + (((n) % (c)) ? 1 : 0))
>>
>> --
>> 2.43.0
>>
>>
next prev parent reply other threads:[~2024-01-31 10:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-20 13:57 [PATCH v2 0/4] MediaTek DRM - DSI driver cleanups AngeloGioacchino Del Regno
2023-12-20 13:57 ` [PATCH v2 1/4] drm/mediatek: dsi: Use GENMASK() for register mask definitions AngeloGioacchino Del Regno
2023-12-26 10:46 ` Fei Shao
2024-01-31 10:56 ` AngeloGioacchino Del Regno [this message]
2023-12-20 13:57 ` [PATCH v2 2/4] drm/mediatek: dsi: Cleanup functions mtk_dsi_ps_control{_vact}() AngeloGioacchino Del Regno
2023-12-26 10:48 ` Fei Shao
2024-01-31 10:57 ` AngeloGioacchino Del Regno
2023-12-20 13:57 ` [PATCH v2 3/4] drm/mediatek: dsi: Use bitfield macros where useful AngeloGioacchino Del Regno
2023-12-23 7:36 ` kernel test robot
2023-12-20 13:57 ` [PATCH v2 4/4] drm/mediatek: dsi: Replace open-coded instance of HZ_PER_MHZ AngeloGioacchino Del Regno
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=d8c364a6-932d-4669-af70-5b113556121d@collabora.com \
--to=angelogioacchino.delregno@collabora.com \
--cc=airlied@gmail.com \
--cc=chunkuang.hu@kernel.org \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=fshao@chromium.org \
--cc=kernel@collabora.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=p.zabel@pengutronix.de \
/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
all inboxes | Powered by JetHome®