[v3 4/6] drm/vs: Add KMS crtc&plane

Maxime Ripard mripard at kernel.org
Fri Feb 9 07:37:09 PST 2024


On Thu, Feb 01, 2024 at 02:22:16AM +0000, Keith Zhao wrote:
> 
> 
> 
> 
> > -----Original Message-----
> 
> > From: Maxime Ripard <mripard at kernel.org>
> 
> > Sent: 2024年1月31日 21:24
> 
> > To: Keith Zhao <keith.zhao at starfivetech.com>
> 
> > Cc: devicetree at vger.kernel.org; dri-devel at lists.freedesktop.org;
> 
> > linux-kernel at vger.kernel.org; linux-riscv at lists.infradead.org;
> 
> > tzimmermann at suse.de; airlied at gmail.com; krzysztof.kozlowski+dt at linaro.org;
> 
> > William Qiu <william.qiu at starfivetech.com>; Xingyu Wu
> 
> > <xingyu.wu at starfivetech.com>; paul.walmsley at sifive.com;
> 
> > aou at eecs.berkeley.edu; palmer at dabbelt.com; p.zabel at pengutronix.de;
> 
> > Shengyang Chen <shengyang.chen at starfivetech.com>; Jack Zhu
> 
> > <jack.zhu at starfivetech.com>; Changhuang Liang
> 
> > <changhuang.liang at starfivetech.com>; maarten.lankhorst at linux.intel.com
> 
> > Subject: Re: [v3 4/6] drm/vs: Add KMS crtc&plane
> 
> >
> 
> > On Wed, Jan 31, 2024 at 09:33:06AM +0000, Keith Zhao wrote:
> 
> > >
> 
> > >
> 
> > > > -----邮件原件-----
> 
> > > > 发件人: Maxime Ripard <mripard at kernel.org<mailto:mripard at kernel.org>>
> 
> > > > 发送时间: 2023年12月6日 16:56
> 
> > > > 收件人: Keith Zhao <keith.zhao at starfivetech.com<mailto:keith.zhao at starfivetech.com>>
> 
> > > > 抄送: devicetree at vger.kernel.org<mailto:devicetree at vger.kernel.org>; dri-devel at lists.freedesktop.org<mailto:dri-devel at lists.freedesktop.org>;
> 
> > > > linux-kernel at vger.kernel.org<mailto:linux-kernel at vger.kernel.org>; linux-riscv at lists.infradead.org<mailto:linux-riscv at lists.infradead.org>;
> 
> > > > tzimmermann at suse.de<mailto:tzimmermann at suse.de>; airlied at gmail.com<mailto:airlied at gmail.com>;
> 
> > > > krzysztof.kozlowski+dt at linaro.org<mailto:krzysztof.kozlowski+dt at linaro.org>;
> 
> > > > William Qiu <william.qiu at starfivetech.com<mailto:william.qiu at starfivetech.com>>; Xingyu Wu
> 
> > > > <xingyu.wu at starfivetech.com<mailto:xingyu.wu at starfivetech.com>>; paul.walmsley at sifive.com<mailto:paul.walmsley at sifive.com>;
> 
> > > > aou at eecs.berkeley.edu<mailto:aou at eecs.berkeley.edu>; palmer at dabbelt.com<mailto:palmer at dabbelt.com>; p.zabel at pengutronix.de<mailto:p.zabel at pengutronix.de>;
> 
> > > > Shengyang Chen <shengyang.chen at starfivetech.com<mailto:shengyang.chen at starfivetech.com>>; Jack Zhu
> 
> > > > <jack.zhu at starfivetech.com<mailto:jack.zhu at starfivetech.com>>; Changhuang Liang
> 
> > > > <changhuang.liang at starfivetech.com<mailto:changhuang.liang at starfivetech.com>>;
> 
> > > > maarten.lankhorst at linux.intel.com<mailto:maarten.lankhorst at linux.intel.com>;
> 
> > > > suijingfeng at loongson.cn<mailto:suijingfeng at loongson.cn>
> 
> > > > 主题: Re: [v3 4/6] drm/vs: Add KMS crtc&plane
> 
> > > >
> 
> > > > On Mon, Dec 04, 2023 at 08:33:13PM +0800, Keith Zhao wrote:
> 
> > > > > +static const struct vs_plane_info dc_hw_planes_rev0[PLANE_NUM] = {
> 
> > > > > +   {
> 
> > > > > +            .name                         = "Primary",
> 
> > > > > +            .id                       = PRIMARY_PLANE_0,
> 
> > > > > +            .type                            = DRM_PLANE_TYPE_PRIMARY,
> 
> > > > > +            .num_formats           = ARRAY_SIZE(primary_overlay_format0),
> 
> > > > > +            .formats            = primary_overlay_format0,
> 
> > > > > +            .num_modifiers                 = ARRAY_SIZE(format_modifier0),
> 
> > > > > +            .modifiers                   = format_modifier0,
> 
> > > > > +            .min_width                = 0,
> 
> > > > > +            .min_height               = 0,
> 
> > > > > +            .max_width               = 4096,
> 
> > > > > +            .max_height              = 4096,
> 
> > > > > +            .rotation           = DRM_MODE_ROTATE_0 |
> 
> > > > > +                                          DRM_MODE_ROTATE_90 |
> 
> > > > > +                                          DRM_MODE_ROTATE_180 |
> 
> > > > > +                                          DRM_MODE_ROTATE_270 |
> 
> > > > > +                                          DRM_MODE_REFLECT_X |
> 
> > > > > +                                          DRM_MODE_REFLECT_Y,
> 
> > > > > +            .blend_mode             = BIT(DRM_MODE_BLEND_PIXEL_NONE) |
> 
> > > > > +                                          BIT(DRM_MODE_BLEND_PREMULTI) |
> 
> > > > > +                                          BIT(DRM_MODE_BLEND_COVERAGE),
> 
> > > > > +            .color_encoding                 = BIT(DRM_COLOR_YCBCR_BT709) |
> 
> > > > > +                                          BIT(DRM_COLOR_YCBCR_BT2020),
> 
> > > > > +            .degamma_size                  = DEGAMMA_SIZE,
> 
> > > > > +            .min_scale                 = FRAC_16_16(1, 3),
> 
> > > > > +            .max_scale                = FRAC_16_16(10, 1),
> 
> > > > > +            .zpos                            = 0,
> 
> > > > > +            .watermark               = true,
> 
> > > > > +            .color_mgmt             = true,
> 
> > > > > +            .roi                      = true,
> 
> > > > > +   },
> 
> > > > > +   {
> 
> > > > > +            .name                         = "Overlay",
> 
> > > > > +            .id                       = OVERLAY_PLANE_0,
> 
> > > > > +            .type                            = DRM_PLANE_TYPE_OVERLAY,
> 
> > > > > +            .num_formats           = ARRAY_SIZE(primary_overlay_format0),
> 
> > > > > +            .formats            = primary_overlay_format0,
> 
> > > > > +            .num_modifiers                 = ARRAY_SIZE(format_modifier0),
> 
> > > > > +            .modifiers                   = format_modifier0,
> 
> > > > > +            .min_width                = 0,
> 
> > > > > +            .min_height               = 0,
> 
> > > > > +            .max_width               = 4096,
> 
> > > > > +            .max_height              = 4096,
> 
> > > > > +            .rotation           = DRM_MODE_ROTATE_0 |
> 
> > > > > +                                          DRM_MODE_ROTATE_90 |
> 
> > > > > +                                          DRM_MODE_ROTATE_180 |
> 
> > > > > +                                          DRM_MODE_ROTATE_270 |
> 
> > > > > +                                          DRM_MODE_REFLECT_X |
> 
> > > > > +                                          DRM_MODE_REFLECT_Y,
> 
> > > > > +            .blend_mode             = BIT(DRM_MODE_BLEND_PIXEL_NONE) |
> 
> > > > > +                                          BIT(DRM_MODE_BLEND_PREMULTI) |
> 
> > > > > +                                          BIT(DRM_MODE_BLEND_COVERAGE),
> 
> > > > > +            .color_encoding                 = BIT(DRM_COLOR_YCBCR_BT709) |
> 
> > > > > +                                          BIT(DRM_COLOR_YCBCR_BT2020),
> 
> > > > > +            .degamma_size                  = DEGAMMA_SIZE,
> 
> > > > > +            .min_scale                 = FRAC_16_16(1, 3),
> 
> > > > > +            .max_scale                = FRAC_16_16(10, 1),
> 
> > > > > +            .zpos                            = 1,
> 
> > > > > +            .watermark               = true,
> 
> > > > > +            .color_mgmt             = true,
> 
> > > > > +            .roi                      = true,
> 
> > > > > +   },
> 
> > > > > +   {
> 
> > > > > +            .name                         = "Overlay_1",
> 
> > > > > +            .id                       = OVERLAY_PLANE_1,
> 
> > > > > +            .type                            = DRM_PLANE_TYPE_OVERLAY,
> 
> > > > > +            .num_formats           = ARRAY_SIZE(primary_overlay_format0),
> 
> > > > > +            .formats            = primary_overlay_format0,
> 
> > > > > +            .num_modifiers                 =
> 
> > ARRAY_SIZE(secondary_format_modifiers),
> 
> > > > > +            .modifiers                   = secondary_format_modifiers,
> 
> > > > > +            .min_width                = 0,
> 
> > > > > +            .min_height               = 0,
> 
> > > > > +            .max_width               = 4096,
> 
> > > > > +            .max_height              = 4096,
> 
> > > > > +            .rotation           = 0,
> 
> > > > > +            .blend_mode             = BIT(DRM_MODE_BLEND_PIXEL_NONE) |
> 
> > > > > +                                          BIT(DRM_MODE_BLEND_PREMULTI) |
> 
> > > > > +                                          BIT(DRM_MODE_BLEND_COVERAGE),
> 
> > > > > +            .color_encoding                 = BIT(DRM_COLOR_YCBCR_BT709) |
> 
> > > > > +                                          BIT(DRM_COLOR_YCBCR_BT2020),
> 
> > > > > +            .degamma_size                  = DEGAMMA_SIZE,
> 
> > > > > +            .min_scale                 = DRM_PLANE_NO_SCALING,
> 
> > > > > +            .max_scale                = DRM_PLANE_NO_SCALING,
> 
> > > > > +            .zpos                            = 2,
> 
> > > > > +            .watermark               = true,
> 
> > > > > +            .color_mgmt             = true,
> 
> > > > > +            .roi                      = true,
> 
> > > > > +   },
> 
> > > > > +   {
> 
> > > > > +            .name                         = "Primary_1",
> 
> > > > > +            .id                       = PRIMARY_PLANE_1,
> 
> > > > > +            .type                            = DRM_PLANE_TYPE_PRIMARY,
> 
> > > > > +            .num_formats           = ARRAY_SIZE(primary_overlay_format0),
> 
> > > > > +            .formats            = primary_overlay_format0,
> 
> > > > > +            .num_modifiers                 = ARRAY_SIZE(format_modifier0),
> 
> > > > > +            .modifiers                   = format_modifier0,
> 
> > > > > +            .min_width                = 0,
> 
> > > > > +            .min_height               = 0,
> 
> > > > > +            .max_width               = 4096,
> 
> > > > > +            .max_height              = 4096,
> 
> > > > > +            .rotation           = DRM_MODE_ROTATE_0 |
> 
> > > > > +                                          DRM_MODE_ROTATE_90 |
> 
> > > > > +                                          DRM_MODE_ROTATE_180 |
> 
> > > > > +                                          DRM_MODE_ROTATE_270 |
> 
> > > > > +                                          DRM_MODE_REFLECT_X |
> 
> > > > > +                                          DRM_MODE_REFLECT_Y,
> 
> > > > > +            .blend_mode             = BIT(DRM_MODE_BLEND_PIXEL_NONE) |
> 
> > > > > +                                          BIT(DRM_MODE_BLEND_PREMULTI) |
> 
> > > > > +                                          BIT(DRM_MODE_BLEND_COVERAGE),
> 
> > > > > +            .color_encoding                 = BIT(DRM_COLOR_YCBCR_BT709) |
> 
> > > > > +                                          BIT(DRM_COLOR_YCBCR_BT2020),
> 
> > > > > +            .degamma_size                  = DEGAMMA_SIZE,
> 
> > > > > +            .min_scale                 = FRAC_16_16(1, 3),
> 
> > > > > +            .max_scale                = FRAC_16_16(10, 1),
> 
> > > > > +            .zpos                            = 3,
> 
> > > > > +            .watermark               = true,
> 
> > > > > +            .color_mgmt             = true,
> 
> > > > > +            .roi                      = true,
> 
> > > > > +   },
> 
> > > > > +   {
> 
> > > > > +            .name                         = "Overlay_2",
> 
> > > > > +            .id                       = OVERLAY_PLANE_2,
> 
> > > > > +            .type                            = DRM_PLANE_TYPE_OVERLAY,
> 
> > > > > +            .num_formats           = ARRAY_SIZE(primary_overlay_format0),
> 
> > > > > +            .formats            = primary_overlay_format0,
> 
> > > > > +            .num_modifiers                 = ARRAY_SIZE(format_modifier0),
> 
> > > > > +            .modifiers                   = format_modifier0,
> 
> > > > > +            .min_width                = 0,
> 
> > > > > +            .min_height               = 0,
> 
> > > > > +            .max_width               = 4096,
> 
> > > > > +            .max_height              = 4096,
> 
> > > > > +            .rotation           = DRM_MODE_ROTATE_0 |
> 
> > > > > +                                          DRM_MODE_ROTATE_90 |
> 
> > > > > +                                          DRM_MODE_ROTATE_180 |
> 
> > > > > +                                          DRM_MODE_ROTATE_270 |
> 
> > > > > +                                          DRM_MODE_REFLECT_X |
> 
> > > > > +                                          DRM_MODE_REFLECT_Y,
> 
> > > > > +            .blend_mode             = BIT(DRM_MODE_BLEND_PIXEL_NONE) |
> 
> > > > > +                                          BIT(DRM_MODE_BLEND_PREMULTI) |
> 
> > > > > +                                          BIT(DRM_MODE_BLEND_COVERAGE),
> 
> > > > > +            .color_encoding                 = BIT(DRM_COLOR_YCBCR_BT709) |
> 
> > > > > +                                          BIT(DRM_COLOR_YCBCR_BT2020),
> 
> > > > > +            .degamma_size                  = DEGAMMA_SIZE,
> 
> > > > > +            .min_scale                 = FRAC_16_16(1, 3),
> 
> > > > > +            .max_scale                = FRAC_16_16(10, 1),
> 
> > > > > +            .zpos                            = 4,
> 
> > > > > +            .watermark               = true,
> 
> > > > > +            .color_mgmt             = true,
> 
> > > > > +            .roi                      = true,
> 
> > > > > +   },
> 
> > > > > +   {
> 
> > > > > +            .name                         = "Overlay_3",
> 
> > > > > +            .id                       = OVERLAY_PLANE_3,
> 
> > > > > +            .type                            = DRM_PLANE_TYPE_OVERLAY,
> 
> > > > > +            .num_formats           = ARRAY_SIZE(primary_overlay_format0),
> 
> > > > > +            .formats            = primary_overlay_format0,
> 
> > > > > +            .num_modifiers                 =
> 
> > ARRAY_SIZE(secondary_format_modifiers),
> 
> > > > > +            .modifiers                   = secondary_format_modifiers,
> 
> > > > > +            .min_width                = 0,
> 
> > > > > +            .min_height               = 0,
> 
> > > > > +            .max_width               = 4096,
> 
> > > > > +            .max_height              = 4096,
> 
> > > > > +            .rotation           = 0,
> 
> > > > > +            .blend_mode             = BIT(DRM_MODE_BLEND_PIXEL_NONE) |
> 
> > > > > +                                          BIT(DRM_MODE_BLEND_PREMULTI) |
> 
> > > > > +                                          BIT(DRM_MODE_BLEND_COVERAGE),
> 
> > > > > +            .color_encoding                 = BIT(DRM_COLOR_YCBCR_BT709) |
> 
> > > > > +                                          BIT(DRM_COLOR_YCBCR_BT2020),
> 
> > > > > +            .degamma_size                  = DEGAMMA_SIZE,
> 
> > > > > +            .min_scale                 = DRM_PLANE_NO_SCALING,
> 
> > > > > +            .max_scale                = DRM_PLANE_NO_SCALING,
> 
> > > > > +            .zpos                            = 5,
> 
> > > > > +            .watermark               = true,
> 
> > > > > +            .color_mgmt             = true,
> 
> > > > > +            .roi                      = true,
> 
> > > > > +   },
> 
> > > > > +   {
> 
> > > > > +            .name                         = "Cursor",
> 
> > > > > +            .id                       = CURSOR_PLANE_0,
> 
> > > > > +            .type                            = DRM_PLANE_TYPE_CURSOR,
> 
> > > > > +            .num_formats           = ARRAY_SIZE(cursor_formats),
> 
> > > > > +            .formats            = cursor_formats,
> 
> > > > > +            .num_modifiers                 = 0,
> 
> > > > > +            .modifiers                   = NULL,
> 
> > > > > +            .min_width                = 32,
> 
> > > > > +            .min_height               = 32,
> 
> > > > > +            .max_width               = 64,
> 
> > > > > +            .max_height              = 64,
> 
> > > > > +            .rotation           = 0,
> 
> > > > > +            .degamma_size                  = 0,
> 
> > > > > +            .min_scale                 = DRM_PLANE_NO_SCALING,
> 
> > > > > +            .max_scale                = DRM_PLANE_NO_SCALING,
> 
> > > > > +            .zpos                            = 255,
> 
> > > > > +            .watermark               = false,
> 
> > > > > +            .color_mgmt             = false,
> 
> > > > > +            .roi                      = false,
> 
> > > > > +   },
> 
> > > > > +   {
> 
> > > > > +            .name                         = "Cursor_1",
> 
> > > > > +            .id                       = CURSOR_PLANE_1,
> 
> > > > > +            .type                            = DRM_PLANE_TYPE_CURSOR,
> 
> > > > > +            .num_formats           = ARRAY_SIZE(cursor_formats),
> 
> > > > > +            .formats            = cursor_formats,
> 
> > > > > +            .num_modifiers                 = 0,
> 
> > > > > +            .modifiers                   = NULL,
> 
> > > > > +            .min_width                = 32,
> 
> > > > > +            .min_height               = 32,
> 
> > > > > +            .max_width               = 64,
> 
> > > > > +            .max_height              = 64,
> 
> > > > > +            .rotation           = 0,
> 
> > > > > +            .degamma_size                  = 0,
> 
> > > > > +            .min_scale                 = DRM_PLANE_NO_SCALING,
> 
> > > > > +            .max_scale                = DRM_PLANE_NO_SCALING,
> 
> > > > > +            .zpos                            = 255,
> 
> > > > > +            .watermark               = false,
> 
> > > > > +            .color_mgmt             = false,
> 
> > > > > +            .roi                      = false,
> 
> > > > > +   },
> 
> > > > > +};
> 
> > > > > +
> 
> > > > > +static const struct vs_dc_info dc8200_info = {
> 
> > > > > +   .name                         = "DC8200",
> 
> > > > > +   .panel_num               = 2,
> 
> > > > > +   .plane_num               = 8,
> 
> > > > > +   .planes                        = dc_hw_planes_rev0,
> 
> > > > > +   .layer_num                = 6,
> 
> > > > > +   .max_bpc          = 10,
> 
> > > > > +   .color_formats          = DRM_COLOR_FORMAT_RGB444 |
> 
> > > > > +                                 DRM_COLOR_FORMAT_YCBCR444 |
> 
> > > > > +                                 DRM_COLOR_FORMAT_YCBCR422 |
> 
> > > > > +                                 DRM_COLOR_FORMAT_YCBCR420,
> 
> > > > > +   .gamma_size             = GAMMA_EX_SIZE,
> 
> > > > > +   .gamma_bits             = 12,
> 
> > > > > +   .pitch_alignment     = 128,
> 
> > > > > +   .pipe_sync                  = false,
> 
> > > > > +   .background              = true,
> 
> > > > > +   .panel_sync               = true,
> 
> > > > > +   .cap_dec           = true,
> 
> > > > > +};
> 
> > > >
> 
> > > > I really think that entire thing is to workaround a suboptimal device tree
> 
> > binding.
> 
> > > > You should have two CRTCs in the device tree, you'll probe twice,
> 
> > > > and you won't get to do that whole dance.
> 
> > > >
> 
> >
> 
> > > I tried to modify it according to this idea Found it too difficult In
> 
> > > terms of hardware, the two crtc designs are too close to separate, and
> 
> > > they are even designed into the same reg with different bits
> 
> > > representing crtc0 and crtc1. It seems not easy to described the 2
> 
> > > ctrc hardware by 2 device nodes
> 
> >
> 
> > What are these bits doing?
> 
> 
> 
> [cid:image001.png at 01DA54F5.ECEA9C10]
> 
> For example:
> 
> like this , bit0 and bit1 match ctrc0 and crtc1 , it is used to start crtc
> 
> A similar situation exists for other register definitions.
> 
> 
> 
> Another case is that ctrc0 and crtc1 have the same function and their offset is continuous,
> 
> instead of crtc0 being a continuous area, crtc1 being a continuous area
> 
> reg:
> 
> crtc0 X
> 
> crtc1 X+4
> 
> crtc0 X+8
> 
> crtc1 X+12
> 
> if to make it two separate devices, the device node dts reg attribute would be complex

Yeah, ok, that makes sense then.

In which case, if we're going to have one big device in the DT with all
the planes and CRTCs, why do we need the display-subsystem device? Just
make your driver probe on the dc8200 device.

Maxime
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-riscv/attachments/20240209/7ebce235/attachment.sig>


More information about the linux-riscv mailing list