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

Maxime Ripard mripard at kernel.org
Wed Jan 31 05:23:46 PST 2024


On Wed, Jan 31, 2024 at 09:33:06AM +0000, Keith Zhao wrote:
> 
> 
> > -----邮件原件-----
> > 发件人: Maxime Ripard <mripard at kernel.org>
> > 发送时间: 2023年12月6日 16:56
> > 收件人: Keith Zhao <keith.zhao at starfivetech.com>
> > 抄送: 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;
> > 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?

> The idea is to avoid a whole dance I don't know if I understand
> correctly about whole dance. Is it means I create 2 ctrc and 8 plane
> in the dc_bind?

Yeah, you should strive to make it two separate devices.

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/20240131/9096167e/attachment.sig>


More information about the linux-riscv mailing list