From patchwork Mon Jun 10 14:06:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13692107 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8C4E0C27C65 for ; Mon, 10 Jun 2024 14:11:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 097EC10E489; Mon, 10 Jun 2024 14:11:58 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.b="SqS1KnXm"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="9cLl9pTz"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="SqS1KnXm"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="9cLl9pTz"; dkim-atps=neutral Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7256810E0DA for ; Mon, 10 Jun 2024 14:11:46 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id B5D4521B79; Mon, 10 Jun 2024 14:11:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718028704; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=faOVVCAtSFL3eid7snezf7lxueDjdiLA5+KimEDN/As=; b=SqS1KnXmQcH/mvmBAAMfDbyycuiKLg1MQO6QI1J40h951/TfL1FDtLvmPhObJgih39pwMq TkVPYOlfbQDN3X5mm4r74RE+Vtg9UlbHJQ5DUQ43LIiZkTC/uTDVXVtjEmM4J0xNS1DDIm TU4YvcoqufiWzhT1Kxyf5m7gfkkvO3c= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718028704; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=faOVVCAtSFL3eid7snezf7lxueDjdiLA5+KimEDN/As=; b=9cLl9pTzi4YLAbVwhHaOUMt1NSTcC76NzVnd66L+N0xb+WEm1I0DwoDYFf47X3pfnlMtHJ XUEzSeKgmL+UPLBg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718028704; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=faOVVCAtSFL3eid7snezf7lxueDjdiLA5+KimEDN/As=; b=SqS1KnXmQcH/mvmBAAMfDbyycuiKLg1MQO6QI1J40h951/TfL1FDtLvmPhObJgih39pwMq TkVPYOlfbQDN3X5mm4r74RE+Vtg9UlbHJQ5DUQ43LIiZkTC/uTDVXVtjEmM4J0xNS1DDIm TU4YvcoqufiWzhT1Kxyf5m7gfkkvO3c= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718028704; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=faOVVCAtSFL3eid7snezf7lxueDjdiLA5+KimEDN/As=; b=9cLl9pTzi4YLAbVwhHaOUMt1NSTcC76NzVnd66L+N0xb+WEm1I0DwoDYFf47X3pfnlMtHJ XUEzSeKgmL+UPLBg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 7721B13AA0; Mon, 10 Jun 2024 14:11:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id iH3tG6AJZ2Z7QQAAD6G6ig (envelope-from ); Mon, 10 Jun 2024 14:11:44 +0000 From: Thomas Zimmermann To: airlied@redhat.com, jfalempe@redhat.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, airlied@gmail.com, daniel@ffwll.ch Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH v2 1/3] drm/mgag200: Consolidate VGA output Date: Mon, 10 Jun 2024 16:06:04 +0200 Message-ID: <20240610141141.29527-2-tzimmermann@suse.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240610141141.29527-1-tzimmermann@suse.de> References: <20240610141141.29527-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_SEVEN(0.00)[8]; FUZZY_BLOCKED(0.00)[rspamd.com]; FREEMAIL_TO(0.00)[redhat.com,linux.intel.com,kernel.org,gmail.com,ffwll.ch]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The various models have common code for the VGA output's encoder and connector. Move everything into a single shared source file. Remove some obsolete initializer macros. No functional changes. Signed-off-by: Thomas Zimmermann Reviewed-by: Jocelyn Falempe --- drivers/gpu/drm/mgag200/Makefile | 3 +- drivers/gpu/drm/mgag200/mgag200_drv.h | 24 +++----- drivers/gpu/drm/mgag200/mgag200_g200.c | 46 +-------------- drivers/gpu/drm/mgag200/mgag200_g200eh.c | 46 +-------------- drivers/gpu/drm/mgag200/mgag200_g200eh3.c | 46 +-------------- drivers/gpu/drm/mgag200/mgag200_g200er.c | 46 +-------------- drivers/gpu/drm/mgag200/mgag200_g200ev.c | 46 +-------------- drivers/gpu/drm/mgag200/mgag200_g200ew3.c | 46 +-------------- drivers/gpu/drm/mgag200/mgag200_g200se.c | 46 +-------------- drivers/gpu/drm/mgag200/mgag200_g200wb.c | 46 +-------------- drivers/gpu/drm/mgag200/mgag200_vga.c | 68 +++++++++++++++++++++++ 11 files changed, 95 insertions(+), 368 deletions(-) create mode 100644 drivers/gpu/drm/mgag200/mgag200_vga.c diff --git a/drivers/gpu/drm/mgag200/Makefile b/drivers/gpu/drm/mgag200/Makefile index 0b919352046eb..d1b25f9f6586e 100644 --- a/drivers/gpu/drm/mgag200/Makefile +++ b/drivers/gpu/drm/mgag200/Makefile @@ -11,6 +11,7 @@ mgag200-y := \ mgag200_g200ew3.o \ mgag200_g200se.o \ mgag200_g200wb.o \ - mgag200_mode.o + mgag200_mode.o \ + mgag200_vga.o obj-$(CONFIG_DRM_MGAG200) += mgag200.o diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h b/drivers/gpu/drm/mgag200/mgag200_drv.h index 20e3710e056b3..db89fddc26dcb 100644 --- a/drivers/gpu/drm/mgag200/mgag200_drv.h +++ b/drivers/gpu/drm/mgag200/mgag200_drv.h @@ -283,8 +283,12 @@ struct mga_device { struct drm_plane primary_plane; struct drm_crtc crtc; - struct drm_encoder encoder; - struct drm_connector connector; + struct { + struct { + struct drm_encoder encoder; + struct drm_connector connector; + } vga; + } output; }; static inline struct mga_device *to_mga_device(struct drm_device *dev) @@ -417,25 +421,15 @@ void mgag200_crtc_atomic_destroy_state(struct drm_crtc *crtc, struct drm_crtc_st .atomic_duplicate_state = mgag200_crtc_atomic_duplicate_state, \ .atomic_destroy_state = mgag200_crtc_atomic_destroy_state -#define MGAG200_DAC_ENCODER_FUNCS \ - .destroy = drm_encoder_cleanup - -#define MGAG200_VGA_CONNECTOR_HELPER_FUNCS \ - .get_modes = drm_connector_helper_get_modes - -#define MGAG200_VGA_CONNECTOR_FUNCS \ - .reset = drm_atomic_helper_connector_reset, \ - .fill_modes = drm_helper_probe_single_connector_modes, \ - .destroy = drm_connector_cleanup, \ - .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, \ - .atomic_destroy_state = drm_atomic_helper_connector_destroy_state - void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mode *mode); void mgag200_set_format_regs(struct mga_device *mdev, const struct drm_format_info *format); void mgag200_enable_display(struct mga_device *mdev); void mgag200_init_registers(struct mga_device *mdev); int mgag200_mode_config_init(struct mga_device *mdev, resource_size_t vram_available); +/* mgag200_vga.c */ +int mgag200_vga_output_init(struct mga_device *mdev); + /* mgag200_bmc.c */ void mgag200_bmc_disable_vidrst(struct mga_device *mdev); void mgag200_bmc_enable_vidrst(struct mga_device *mdev); diff --git a/drivers/gpu/drm/mgag200/mgag200_g200.c b/drivers/gpu/drm/mgag200/mgag200_g200.c index 39a29d8ffca6e..ff467b0f9cbf3 100644 --- a/drivers/gpu/drm/mgag200/mgag200_g200.c +++ b/drivers/gpu/drm/mgag200/mgag200_g200.c @@ -9,7 +9,6 @@ #include #include -#include "mgag200_ddc.h" #include "mgag200_drv.h" static int mgag200_g200_init_pci_options(struct pci_dev *pdev) @@ -184,26 +183,11 @@ static const struct drm_crtc_funcs mgag200_g200_crtc_funcs = { MGAG200_CRTC_FUNCS, }; -static const struct drm_encoder_funcs mgag200_g200_dac_encoder_funcs = { - MGAG200_DAC_ENCODER_FUNCS, -}; - -static const struct drm_connector_helper_funcs mgag200_g200_vga_connector_helper_funcs = { - MGAG200_VGA_CONNECTOR_HELPER_FUNCS, -}; - -static const struct drm_connector_funcs mgag200_g200_vga_connector_funcs = { - MGAG200_VGA_CONNECTOR_FUNCS, -}; - static int mgag200_g200_pipeline_init(struct mga_device *mdev) { struct drm_device *dev = &mdev->base; struct drm_plane *primary_plane = &mdev->primary_plane; struct drm_crtc *crtc = &mdev->crtc; - struct drm_encoder *encoder = &mdev->encoder; - struct drm_connector *connector = &mdev->connector; - struct i2c_adapter *ddc; int ret; ret = drm_universal_plane_init(dev, primary_plane, 0, @@ -231,35 +215,9 @@ static int mgag200_g200_pipeline_init(struct mga_device *mdev) drm_mode_crtc_set_gamma_size(crtc, MGAG200_LUT_SIZE); drm_crtc_enable_color_mgmt(crtc, 0, false, MGAG200_LUT_SIZE); - encoder->possible_crtcs = drm_crtc_mask(crtc); - ret = drm_encoder_init(dev, encoder, &mgag200_g200_dac_encoder_funcs, - DRM_MODE_ENCODER_DAC, NULL); - if (ret) { - drm_err(dev, "drm_encoder_init() failed: %d\n", ret); - return ret; - } - - ddc = mgag200_ddc_create(mdev); - if (IS_ERR(ddc)) { - ret = PTR_ERR(ddc); - drm_err(dev, "failed to add DDC bus: %d\n", ret); - return ret; - } - - ret = drm_connector_init_with_ddc(dev, connector, - &mgag200_g200_vga_connector_funcs, - DRM_MODE_CONNECTOR_VGA, ddc); - if (ret) { - drm_err(dev, "drm_connector_init_with_ddc() failed: %d\n", ret); - return ret; - } - drm_connector_helper_add(connector, &mgag200_g200_vga_connector_helper_funcs); - - ret = drm_connector_attach_encoder(connector, encoder); - if (ret) { - drm_err(dev, "drm_connector_attach_encoder() failed: %d\n", ret); + ret = mgag200_vga_output_init(mdev); + if (ret) return ret; - } return 0; } diff --git a/drivers/gpu/drm/mgag200/mgag200_g200eh.c b/drivers/gpu/drm/mgag200/mgag200_g200eh.c index 619fee7ffdf5e..df00b25efb895 100644 --- a/drivers/gpu/drm/mgag200/mgag200_g200eh.c +++ b/drivers/gpu/drm/mgag200/mgag200_g200eh.c @@ -9,7 +9,6 @@ #include #include -#include "mgag200_ddc.h" #include "mgag200_drv.h" void mgag200_g200eh_init_registers(struct mga_device *mdev) @@ -183,26 +182,11 @@ static const struct drm_crtc_funcs mgag200_g200eh_crtc_funcs = { MGAG200_CRTC_FUNCS, }; -static const struct drm_encoder_funcs mgag200_g200eh_dac_encoder_funcs = { - MGAG200_DAC_ENCODER_FUNCS, -}; - -static const struct drm_connector_helper_funcs mgag200_g200eh_vga_connector_helper_funcs = { - MGAG200_VGA_CONNECTOR_HELPER_FUNCS, -}; - -static const struct drm_connector_funcs mgag200_g200eh_vga_connector_funcs = { - MGAG200_VGA_CONNECTOR_FUNCS, -}; - static int mgag200_g200eh_pipeline_init(struct mga_device *mdev) { struct drm_device *dev = &mdev->base; struct drm_plane *primary_plane = &mdev->primary_plane; struct drm_crtc *crtc = &mdev->crtc; - struct drm_encoder *encoder = &mdev->encoder; - struct drm_connector *connector = &mdev->connector; - struct i2c_adapter *ddc; int ret; ret = drm_universal_plane_init(dev, primary_plane, 0, @@ -230,35 +214,9 @@ static int mgag200_g200eh_pipeline_init(struct mga_device *mdev) drm_mode_crtc_set_gamma_size(crtc, MGAG200_LUT_SIZE); drm_crtc_enable_color_mgmt(crtc, 0, false, MGAG200_LUT_SIZE); - encoder->possible_crtcs = drm_crtc_mask(crtc); - ret = drm_encoder_init(dev, encoder, &mgag200_g200eh_dac_encoder_funcs, - DRM_MODE_ENCODER_DAC, NULL); - if (ret) { - drm_err(dev, "drm_encoder_init() failed: %d\n", ret); - return ret; - } - - ddc = mgag200_ddc_create(mdev); - if (IS_ERR(ddc)) { - ret = PTR_ERR(ddc); - drm_err(dev, "failed to add DDC bus: %d\n", ret); - return ret; - } - - ret = drm_connector_init_with_ddc(dev, connector, - &mgag200_g200eh_vga_connector_funcs, - DRM_MODE_CONNECTOR_VGA, ddc); - if (ret) { - drm_err(dev, "drm_connector_init_with_ddc() failed: %d\n", ret); - return ret; - } - drm_connector_helper_add(connector, &mgag200_g200eh_vga_connector_helper_funcs); - - ret = drm_connector_attach_encoder(connector, encoder); - if (ret) { - drm_err(dev, "drm_connector_attach_encoder() failed: %d\n", ret); + ret = mgag200_vga_output_init(mdev); + if (ret) return ret; - } return 0; } diff --git a/drivers/gpu/drm/mgag200/mgag200_g200eh3.c b/drivers/gpu/drm/mgag200/mgag200_g200eh3.c index a172b8a4500a0..be42b1291e357 100644 --- a/drivers/gpu/drm/mgag200/mgag200_g200eh3.c +++ b/drivers/gpu/drm/mgag200/mgag200_g200eh3.c @@ -8,7 +8,6 @@ #include #include -#include "mgag200_ddc.h" #include "mgag200_drv.h" /* @@ -87,26 +86,11 @@ static const struct drm_crtc_funcs mgag200_g200eh3_crtc_funcs = { MGAG200_CRTC_FUNCS, }; -static const struct drm_encoder_funcs mgag200_g200eh3_dac_encoder_funcs = { - MGAG200_DAC_ENCODER_FUNCS, -}; - -static const struct drm_connector_helper_funcs mgag200_g200eh3_vga_connector_helper_funcs = { - MGAG200_VGA_CONNECTOR_HELPER_FUNCS, -}; - -static const struct drm_connector_funcs mgag200_g200eh3_vga_connector_funcs = { - MGAG200_VGA_CONNECTOR_FUNCS, -}; - static int mgag200_g200eh3_pipeline_init(struct mga_device *mdev) { struct drm_device *dev = &mdev->base; struct drm_plane *primary_plane = &mdev->primary_plane; struct drm_crtc *crtc = &mdev->crtc; - struct drm_encoder *encoder = &mdev->encoder; - struct drm_connector *connector = &mdev->connector; - struct i2c_adapter *ddc; int ret; ret = drm_universal_plane_init(dev, primary_plane, 0, @@ -134,35 +118,9 @@ static int mgag200_g200eh3_pipeline_init(struct mga_device *mdev) drm_mode_crtc_set_gamma_size(crtc, MGAG200_LUT_SIZE); drm_crtc_enable_color_mgmt(crtc, 0, false, MGAG200_LUT_SIZE); - encoder->possible_crtcs = drm_crtc_mask(crtc); - ret = drm_encoder_init(dev, encoder, &mgag200_g200eh3_dac_encoder_funcs, - DRM_MODE_ENCODER_DAC, NULL); - if (ret) { - drm_err(dev, "drm_encoder_init() failed: %d\n", ret); - return ret; - } - - ddc = mgag200_ddc_create(mdev); - if (IS_ERR(ddc)) { - ret = PTR_ERR(ddc); - drm_err(dev, "failed to add DDC bus: %d\n", ret); - return ret; - } - - ret = drm_connector_init_with_ddc(dev, connector, - &mgag200_g200eh3_vga_connector_funcs, - DRM_MODE_CONNECTOR_VGA, ddc); - if (ret) { - drm_err(dev, "drm_connector_init_with_ddc() failed: %d\n", ret); - return ret; - } - drm_connector_helper_add(connector, &mgag200_g200eh3_vga_connector_helper_funcs); - - ret = drm_connector_attach_encoder(connector, encoder); - if (ret) { - drm_err(dev, "drm_connector_attach_encoder() failed: %d\n", ret); + ret = mgag200_vga_output_init(mdev); + if (ret) return ret; - } return 0; } diff --git a/drivers/gpu/drm/mgag200/mgag200_g200er.c b/drivers/gpu/drm/mgag200/mgag200_g200er.c index a11c91331e43e..6f2c07af38c4f 100644 --- a/drivers/gpu/drm/mgag200/mgag200_g200er.c +++ b/drivers/gpu/drm/mgag200/mgag200_g200er.c @@ -9,7 +9,6 @@ #include #include -#include "mgag200_ddc.h" #include "mgag200_drv.h" static void mgag200_g200er_init_registers(struct mga_device *mdev) @@ -226,26 +225,11 @@ static const struct drm_crtc_funcs mgag200_g200er_crtc_funcs = { MGAG200_CRTC_FUNCS, }; -static const struct drm_encoder_funcs mgag200_g200er_dac_encoder_funcs = { - MGAG200_DAC_ENCODER_FUNCS, -}; - -static const struct drm_connector_helper_funcs mgag200_g200er_vga_connector_helper_funcs = { - MGAG200_VGA_CONNECTOR_HELPER_FUNCS, -}; - -static const struct drm_connector_funcs mgag200_g200er_vga_connector_funcs = { - MGAG200_VGA_CONNECTOR_FUNCS, -}; - static int mgag200_g200er_pipeline_init(struct mga_device *mdev) { struct drm_device *dev = &mdev->base; struct drm_plane *primary_plane = &mdev->primary_plane; struct drm_crtc *crtc = &mdev->crtc; - struct drm_encoder *encoder = &mdev->encoder; - struct drm_connector *connector = &mdev->connector; - struct i2c_adapter *ddc; int ret; ret = drm_universal_plane_init(dev, primary_plane, 0, @@ -273,35 +257,9 @@ static int mgag200_g200er_pipeline_init(struct mga_device *mdev) drm_mode_crtc_set_gamma_size(crtc, MGAG200_LUT_SIZE); drm_crtc_enable_color_mgmt(crtc, 0, false, MGAG200_LUT_SIZE); - encoder->possible_crtcs = drm_crtc_mask(crtc); - ret = drm_encoder_init(dev, encoder, &mgag200_g200er_dac_encoder_funcs, - DRM_MODE_ENCODER_DAC, NULL); - if (ret) { - drm_err(dev, "drm_encoder_init() failed: %d\n", ret); - return ret; - } - - ddc = mgag200_ddc_create(mdev); - if (IS_ERR(ddc)) { - ret = PTR_ERR(ddc); - drm_err(dev, "failed to add DDC bus: %d\n", ret); - return ret; - } - - ret = drm_connector_init_with_ddc(dev, connector, - &mgag200_g200er_vga_connector_funcs, - DRM_MODE_CONNECTOR_VGA, ddc); - if (ret) { - drm_err(dev, "drm_connector_init_with_ddc() failed: %d\n", ret); - return ret; - } - drm_connector_helper_add(connector, &mgag200_g200er_vga_connector_helper_funcs); - - ret = drm_connector_attach_encoder(connector, encoder); - if (ret) { - drm_err(dev, "drm_connector_attach_encoder() failed: %d\n", ret); + ret = mgag200_vga_output_init(mdev); + if (ret) return ret; - } return 0; } diff --git a/drivers/gpu/drm/mgag200/mgag200_g200ev.c b/drivers/gpu/drm/mgag200/mgag200_g200ev.c index dfb641b83842a..908d04d4c862c 100644 --- a/drivers/gpu/drm/mgag200/mgag200_g200ev.c +++ b/drivers/gpu/drm/mgag200/mgag200_g200ev.c @@ -9,7 +9,6 @@ #include #include -#include "mgag200_ddc.h" #include "mgag200_drv.h" static void mgag200_g200ev_init_registers(struct mga_device *mdev) @@ -227,26 +226,11 @@ static const struct drm_crtc_funcs mgag200_g200ev_crtc_funcs = { MGAG200_CRTC_FUNCS, }; -static const struct drm_encoder_funcs mgag200_g200ev_dac_encoder_funcs = { - MGAG200_DAC_ENCODER_FUNCS, -}; - -static const struct drm_connector_helper_funcs mgag200_g200ev_vga_connector_helper_funcs = { - MGAG200_VGA_CONNECTOR_HELPER_FUNCS, -}; - -static const struct drm_connector_funcs mgag200_g200ev_vga_connector_funcs = { - MGAG200_VGA_CONNECTOR_FUNCS, -}; - static int mgag200_g200ev_pipeline_init(struct mga_device *mdev) { struct drm_device *dev = &mdev->base; struct drm_plane *primary_plane = &mdev->primary_plane; struct drm_crtc *crtc = &mdev->crtc; - struct drm_encoder *encoder = &mdev->encoder; - struct drm_connector *connector = &mdev->connector; - struct i2c_adapter *ddc; int ret; ret = drm_universal_plane_init(dev, primary_plane, 0, @@ -274,35 +258,9 @@ static int mgag200_g200ev_pipeline_init(struct mga_device *mdev) drm_mode_crtc_set_gamma_size(crtc, MGAG200_LUT_SIZE); drm_crtc_enable_color_mgmt(crtc, 0, false, MGAG200_LUT_SIZE); - encoder->possible_crtcs = drm_crtc_mask(crtc); - ret = drm_encoder_init(dev, encoder, &mgag200_g200ev_dac_encoder_funcs, - DRM_MODE_ENCODER_DAC, NULL); - if (ret) { - drm_err(dev, "drm_encoder_init() failed: %d\n", ret); - return ret; - } - - ddc = mgag200_ddc_create(mdev); - if (IS_ERR(ddc)) { - ret = PTR_ERR(ddc); - drm_err(dev, "failed to add DDC bus: %d\n", ret); - return ret; - } - - ret = drm_connector_init_with_ddc(dev, connector, - &mgag200_g200ev_vga_connector_funcs, - DRM_MODE_CONNECTOR_VGA, ddc); - if (ret) { - drm_err(dev, "drm_connector_init_with_ddc() failed: %d\n", ret); - return ret; - } - drm_connector_helper_add(connector, &mgag200_g200ev_vga_connector_helper_funcs); - - ret = drm_connector_attach_encoder(connector, encoder); - if (ret) { - drm_err(dev, "drm_connector_attach_encoder() failed: %d\n", ret); + ret = mgag200_vga_output_init(mdev); + if (ret) return ret; - } return 0; } diff --git a/drivers/gpu/drm/mgag200/mgag200_g200ew3.c b/drivers/gpu/drm/mgag200/mgag200_g200ew3.c index 525b7f75e6228..8b69af543e2be 100644 --- a/drivers/gpu/drm/mgag200/mgag200_g200ew3.c +++ b/drivers/gpu/drm/mgag200/mgag200_g200ew3.c @@ -8,7 +8,6 @@ #include #include -#include "mgag200_ddc.h" #include "mgag200_drv.h" static void mgag200_g200ew3_init_registers(struct mga_device *mdev) @@ -96,26 +95,11 @@ static const struct drm_crtc_funcs mgag200_g200ew3_crtc_funcs = { MGAG200_CRTC_FUNCS, }; -static const struct drm_encoder_funcs mgag200_g200ew3_dac_encoder_funcs = { - MGAG200_DAC_ENCODER_FUNCS, -}; - -static const struct drm_connector_helper_funcs mgag200_g200ew3_vga_connector_helper_funcs = { - MGAG200_VGA_CONNECTOR_HELPER_FUNCS, -}; - -static const struct drm_connector_funcs mgag200_g200ew3_vga_connector_funcs = { - MGAG200_VGA_CONNECTOR_FUNCS, -}; - static int mgag200_g200ew3_pipeline_init(struct mga_device *mdev) { struct drm_device *dev = &mdev->base; struct drm_plane *primary_plane = &mdev->primary_plane; struct drm_crtc *crtc = &mdev->crtc; - struct drm_encoder *encoder = &mdev->encoder; - struct drm_connector *connector = &mdev->connector; - struct i2c_adapter *ddc; int ret; ret = drm_universal_plane_init(dev, primary_plane, 0, @@ -143,35 +127,9 @@ static int mgag200_g200ew3_pipeline_init(struct mga_device *mdev) drm_mode_crtc_set_gamma_size(crtc, MGAG200_LUT_SIZE); drm_crtc_enable_color_mgmt(crtc, 0, false, MGAG200_LUT_SIZE); - encoder->possible_crtcs = drm_crtc_mask(crtc); - ret = drm_encoder_init(dev, encoder, &mgag200_g200ew3_dac_encoder_funcs, - DRM_MODE_ENCODER_DAC, NULL); - if (ret) { - drm_err(dev, "drm_encoder_init() failed: %d\n", ret); - return ret; - } - - ddc = mgag200_ddc_create(mdev); - if (IS_ERR(ddc)) { - ret = PTR_ERR(ddc); - drm_err(dev, "failed to add DDC bus: %d\n", ret); - return ret; - } - - ret = drm_connector_init_with_ddc(dev, connector, - &mgag200_g200ew3_vga_connector_funcs, - DRM_MODE_CONNECTOR_VGA, ddc); - if (ret) { - drm_err(dev, "drm_connector_init_with_ddc() failed: %d\n", ret); - return ret; - } - drm_connector_helper_add(connector, &mgag200_g200ew3_vga_connector_helper_funcs); - - ret = drm_connector_attach_encoder(connector, encoder); - if (ret) { - drm_err(dev, "drm_connector_attach_encoder() failed: %d\n", ret); + ret = mgag200_vga_output_init(mdev); + if (ret) return ret; - } return 0; } diff --git a/drivers/gpu/drm/mgag200/mgag200_g200se.c b/drivers/gpu/drm/mgag200/mgag200_g200se.c index ef7606b529ea1..6d7fbdf62b97a 100644 --- a/drivers/gpu/drm/mgag200/mgag200_g200se.c +++ b/drivers/gpu/drm/mgag200/mgag200_g200se.c @@ -9,7 +9,6 @@ #include #include -#include "mgag200_ddc.h" #include "mgag200_drv.h" static int mgag200_g200se_init_pci_options(struct pci_dev *pdev) @@ -358,26 +357,11 @@ static const struct drm_crtc_funcs mgag200_g200se_crtc_funcs = { MGAG200_CRTC_FUNCS, }; -static const struct drm_encoder_funcs mgag200_g200se_dac_encoder_funcs = { - MGAG200_DAC_ENCODER_FUNCS, -}; - -static const struct drm_connector_helper_funcs mgag200_g200se_vga_connector_helper_funcs = { - MGAG200_VGA_CONNECTOR_HELPER_FUNCS, -}; - -static const struct drm_connector_funcs mgag200_g200se_vga_connector_funcs = { - MGAG200_VGA_CONNECTOR_FUNCS, -}; - static int mgag200_g200se_pipeline_init(struct mga_device *mdev) { struct drm_device *dev = &mdev->base; struct drm_plane *primary_plane = &mdev->primary_plane; struct drm_crtc *crtc = &mdev->crtc; - struct drm_encoder *encoder = &mdev->encoder; - struct drm_connector *connector = &mdev->connector; - struct i2c_adapter *ddc; int ret; ret = drm_universal_plane_init(dev, primary_plane, 0, @@ -405,35 +389,9 @@ static int mgag200_g200se_pipeline_init(struct mga_device *mdev) drm_mode_crtc_set_gamma_size(crtc, MGAG200_LUT_SIZE); drm_crtc_enable_color_mgmt(crtc, 0, false, MGAG200_LUT_SIZE); - encoder->possible_crtcs = drm_crtc_mask(crtc); - ret = drm_encoder_init(dev, encoder, &mgag200_g200se_dac_encoder_funcs, - DRM_MODE_ENCODER_DAC, NULL); - if (ret) { - drm_err(dev, "drm_encoder_init() failed: %d\n", ret); - return ret; - } - - ddc = mgag200_ddc_create(mdev); - if (IS_ERR(ddc)) { - ret = PTR_ERR(ddc); - drm_err(dev, "failed to add DDC bus: %d\n", ret); - return ret; - } - - ret = drm_connector_init_with_ddc(dev, connector, - &mgag200_g200se_vga_connector_funcs, - DRM_MODE_CONNECTOR_VGA, ddc); - if (ret) { - drm_err(dev, "drm_connector_init_with_ddc() failed: %d\n", ret); - return ret; - } - drm_connector_helper_add(connector, &mgag200_g200se_vga_connector_helper_funcs); - - ret = drm_connector_attach_encoder(connector, encoder); - if (ret) { - drm_err(dev, "drm_connector_attach_encoder() failed: %d\n", ret); + ret = mgag200_vga_output_init(mdev); + if (ret) return ret; - } return 0; } diff --git a/drivers/gpu/drm/mgag200/mgag200_g200wb.c b/drivers/gpu/drm/mgag200/mgag200_g200wb.c index e4def62b1e575..564d1f3ecc108 100644 --- a/drivers/gpu/drm/mgag200/mgag200_g200wb.c +++ b/drivers/gpu/drm/mgag200/mgag200_g200wb.c @@ -9,7 +9,6 @@ #include #include -#include "mgag200_ddc.h" #include "mgag200_drv.h" void mgag200_g200wb_init_registers(struct mga_device *mdev) @@ -230,26 +229,11 @@ static const struct drm_crtc_funcs mgag200_g200wb_crtc_funcs = { MGAG200_CRTC_FUNCS, }; -static const struct drm_encoder_funcs mgag200_g200wb_dac_encoder_funcs = { - MGAG200_DAC_ENCODER_FUNCS, -}; - -static const struct drm_connector_helper_funcs mgag200_g200wb_vga_connector_helper_funcs = { - MGAG200_VGA_CONNECTOR_HELPER_FUNCS, -}; - -static const struct drm_connector_funcs mgag200_g200wb_vga_connector_funcs = { - MGAG200_VGA_CONNECTOR_FUNCS, -}; - static int mgag200_g200wb_pipeline_init(struct mga_device *mdev) { struct drm_device *dev = &mdev->base; struct drm_plane *primary_plane = &mdev->primary_plane; struct drm_crtc *crtc = &mdev->crtc; - struct drm_encoder *encoder = &mdev->encoder; - struct drm_connector *connector = &mdev->connector; - struct i2c_adapter *ddc; int ret; ret = drm_universal_plane_init(dev, primary_plane, 0, @@ -277,35 +261,9 @@ static int mgag200_g200wb_pipeline_init(struct mga_device *mdev) drm_mode_crtc_set_gamma_size(crtc, MGAG200_LUT_SIZE); drm_crtc_enable_color_mgmt(crtc, 0, false, MGAG200_LUT_SIZE); - encoder->possible_crtcs = drm_crtc_mask(crtc); - ret = drm_encoder_init(dev, encoder, &mgag200_g200wb_dac_encoder_funcs, - DRM_MODE_ENCODER_DAC, NULL); - if (ret) { - drm_err(dev, "drm_encoder_init() failed: %d\n", ret); - return ret; - } - - ddc = mgag200_ddc_create(mdev); - if (IS_ERR(ddc)) { - ret = PTR_ERR(ddc); - drm_err(dev, "failed to add DDC bus: %d\n", ret); - return ret; - } - - ret = drm_connector_init_with_ddc(dev, connector, - &mgag200_g200wb_vga_connector_funcs, - DRM_MODE_CONNECTOR_VGA, ddc); - if (ret) { - drm_err(dev, "drm_connector_init_with_ddc() failed: %d\n", ret); - return ret; - } - drm_connector_helper_add(connector, &mgag200_g200wb_vga_connector_helper_funcs); - - ret = drm_connector_attach_encoder(connector, encoder); - if (ret) { - drm_err(dev, "drm_connector_attach_encoder() failed: %d\n", ret); + ret = mgag200_vga_output_init(mdev); + if (ret) return ret; - } return 0; } diff --git a/drivers/gpu/drm/mgag200/mgag200_vga.c b/drivers/gpu/drm/mgag200/mgag200_vga.c new file mode 100644 index 0000000000000..6d8982990c2c3 --- /dev/null +++ b/drivers/gpu/drm/mgag200/mgag200_vga.c @@ -0,0 +1,68 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include +#include + +#include "mgag200_ddc.h" +#include "mgag200_drv.h" + +static const struct drm_encoder_funcs mgag200_dac_encoder_funcs = { + .destroy = drm_encoder_cleanup +}; + +static const struct drm_connector_helper_funcs mgag200_vga_connector_helper_funcs = { + .get_modes = drm_connector_helper_get_modes +}; + +static const struct drm_connector_funcs mgag200_vga_connector_funcs = { + .reset = drm_atomic_helper_connector_reset, + .fill_modes = drm_helper_probe_single_connector_modes, + .destroy = drm_connector_cleanup, + .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_connector_destroy_state +}; + +int mgag200_vga_output_init(struct mga_device *mdev) +{ + struct drm_device *dev = &mdev->base; + struct drm_crtc *crtc = &mdev->crtc; + struct drm_encoder *encoder; + struct drm_connector *connector; + struct i2c_adapter *ddc; + int ret; + + encoder = &mdev->output.vga.encoder; + ret = drm_encoder_init(dev, encoder, &mgag200_dac_encoder_funcs, + DRM_MODE_ENCODER_DAC, NULL); + if (ret) { + drm_err(dev, "drm_encoder_init() failed: %d\n", ret); + return ret; + } + encoder->possible_crtcs = drm_crtc_mask(crtc); + + ddc = mgag200_ddc_create(mdev); + if (IS_ERR(ddc)) { + ret = PTR_ERR(ddc); + drm_err(dev, "failed to add DDC bus: %d\n", ret); + return ret; + } + + connector = &mdev->output.vga.connector; + ret = drm_connector_init_with_ddc(dev, connector, + &mgag200_vga_connector_funcs, + DRM_MODE_CONNECTOR_VGA, ddc); + if (ret) { + drm_err(dev, "drm_connector_init_with_ddc() failed: %d\n", ret); + return ret; + } + drm_connector_helper_add(connector, &mgag200_vga_connector_helper_funcs); + + ret = drm_connector_attach_encoder(connector, encoder); + if (ret) { + drm_err(dev, "drm_connector_attach_encoder() failed: %d\n", ret); + return ret; + } + + return 0; +} From patchwork Mon Jun 10 14:06:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13692106 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 474A6C27C55 for ; Mon, 10 Jun 2024 14:11:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8799910E14C; Mon, 10 Jun 2024 14:11:50 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.b="RTNtsqxV"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="rgTkfL8T"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="RTNtsqxV"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="rgTkfL8T"; dkim-atps=neutral Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1D04C10E14C for ; Mon, 10 Jun 2024 14:11:47 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id F22251F7F3; Mon, 10 Jun 2024 14:11:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718028705; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oGyd8CfN0KaRVsIP5hHdem1X7CgzVXavcoX3UOAHsVI=; b=RTNtsqxVU9Y0BfCX3rKborLB1ez6tNYSFSYK74jYkGiCTgXWJIkQL3EwuvbbtRyq+rWX8J 2aO/zD6200LTqDYMMNf/wl/v/X65u23sPK5P3oqBfnw92rgJ341lJL3OIui6LHK4T3cbcr VhdzUqf2c0b2fhfpwSu+eR7AXZttddk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718028705; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oGyd8CfN0KaRVsIP5hHdem1X7CgzVXavcoX3UOAHsVI=; b=rgTkfL8TCPMT0XZdWYmUCXPNDFVr61MtcZ+0Y53av//e7SmqJSvkTRqZgV9IdexHpyhd4M iIcRgqpLcKdRD3Ag== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718028705; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oGyd8CfN0KaRVsIP5hHdem1X7CgzVXavcoX3UOAHsVI=; b=RTNtsqxVU9Y0BfCX3rKborLB1ez6tNYSFSYK74jYkGiCTgXWJIkQL3EwuvbbtRyq+rWX8J 2aO/zD6200LTqDYMMNf/wl/v/X65u23sPK5P3oqBfnw92rgJ341lJL3OIui6LHK4T3cbcr VhdzUqf2c0b2fhfpwSu+eR7AXZttddk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718028705; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oGyd8CfN0KaRVsIP5hHdem1X7CgzVXavcoX3UOAHsVI=; b=rgTkfL8TCPMT0XZdWYmUCXPNDFVr61MtcZ+0Y53av//e7SmqJSvkTRqZgV9IdexHpyhd4M iIcRgqpLcKdRD3Ag== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id BC30813A7F; Mon, 10 Jun 2024 14:11:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id uMejLKAJZ2Z7QQAAD6G6ig (envelope-from ); Mon, 10 Jun 2024 14:11:44 +0000 From: Thomas Zimmermann To: airlied@redhat.com, jfalempe@redhat.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, airlied@gmail.com, daniel@ffwll.ch Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH v2 2/3] drm/mgag200: Add BMC output Date: Mon, 10 Jun 2024 16:06:05 +0200 Message-ID: <20240610141141.29527-3-tzimmermann@suse.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240610141141.29527-1-tzimmermann@suse.de> References: <20240610141141.29527-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_SEVEN(0.00)[8]; FUZZY_BLOCKED(0.00)[rspamd.com]; FREEMAIL_TO(0.00)[redhat.com,linux.intel.com,kernel.org,gmail.com,ffwll.ch]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The BMC output can be viewed via the BMC's web interface or a similar client. Represent it as virtual encoder and connector. It's attached to the same CRTC as the VGA connector. The connector's status depends on the physical connector's status. The BMC is only connected if the physical connector is not. This is necessary to support userspace clients that can only handle a single output per CRTC. The BMC is a server feature. Add a BMC output for all server chips, but not the desktop models. Signed-off-by: Thomas Zimmermann Reviewed-by: Jocelyn Falempe --- drivers/gpu/drm/mgag200/mgag200_bmc.c | 107 ++++++++++++++++++++++ drivers/gpu/drm/mgag200/mgag200_drv.h | 10 ++ drivers/gpu/drm/mgag200/mgag200_g200eh.c | 4 + drivers/gpu/drm/mgag200/mgag200_g200eh3.c | 4 + drivers/gpu/drm/mgag200/mgag200_g200er.c | 4 + drivers/gpu/drm/mgag200/mgag200_g200ev.c | 4 + drivers/gpu/drm/mgag200/mgag200_g200ew3.c | 4 + drivers/gpu/drm/mgag200/mgag200_g200se.c | 4 + drivers/gpu/drm/mgag200/mgag200_g200wb.c | 4 + 9 files changed, 145 insertions(+) diff --git a/drivers/gpu/drm/mgag200/mgag200_bmc.c b/drivers/gpu/drm/mgag200/mgag200_bmc.c index 2ba2e3c5086a5..23ef85aa7e378 100644 --- a/drivers/gpu/drm/mgag200/mgag200_bmc.c +++ b/drivers/gpu/drm/mgag200/mgag200_bmc.c @@ -2,8 +2,18 @@ #include +#include +#include +#include +#include + #include "mgag200_drv.h" +static struct mgag200_bmc_connector *to_mgag200_bmc_connector(struct drm_connector *connector) +{ + return container_of(connector, struct mgag200_bmc_connector, base); +} + void mgag200_bmc_disable_vidrst(struct mga_device *mdev) { u8 tmp; @@ -97,3 +107,100 @@ void mgag200_bmc_enable_vidrst(struct mga_device *mdev) tmp &= ~0x10; WREG_DAC(MGA1064_GEN_IO_DATA, tmp); } + +static const struct drm_encoder_funcs mgag200_bmc_encoder_funcs = { + .destroy = drm_encoder_cleanup, +}; + +static int mgag200_bmc_connector_helper_detect_ctx(struct drm_connector *connector, + struct drm_modeset_acquire_ctx *ctx, + bool force) +{ + struct mgag200_bmc_connector *bmc_connector = to_mgag200_bmc_connector(connector); + struct drm_connector *physical_connector = bmc_connector->physical_connector; + + /* + * Most user-space compositors cannot handle more than one connected + * connector per CRTC. Hence, we only mark the BMC as connected if the + * physical connector is disconnected. If the physical connector's status + * is connected or unknown, the BMC remains disconnected. This has no + * effect on the output of the BMC. + * + * FIXME: Remove this logic once user-space compositors can handle more + * than one connector per CRTC. The BMC should always be connected. + */ + + if (physical_connector && physical_connector->status == connector_status_disconnected) + return connector_status_connected; + + return connector_status_disconnected; +} + +static int mgag200_bmc_connector_helper_get_modes(struct drm_connector *connector) +{ + struct drm_device *dev = connector->dev; + struct mga_device *mdev = to_mga_device(dev); + const struct mgag200_device_info *minfo = mdev->info; + + return drm_add_modes_noedid(connector, minfo->max_hdisplay, minfo->max_vdisplay); +} + +static const struct drm_connector_helper_funcs mgag200_bmc_connector_helper_funcs = { + .get_modes = mgag200_bmc_connector_helper_get_modes, + .detect_ctx = mgag200_bmc_connector_helper_detect_ctx, +}; + +static const struct drm_connector_funcs mgag200_bmc_connector_funcs = { + .reset = drm_atomic_helper_connector_reset, + .fill_modes = drm_helper_probe_single_connector_modes, + .destroy = drm_connector_cleanup, + .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, +}; + +static int mgag200_bmc_connector_init(struct drm_device *dev, + struct mgag200_bmc_connector *bmc_connector, + struct drm_connector *physical_connector) +{ + struct drm_connector *connector = &bmc_connector->base; + int ret; + + ret = drm_connector_init(dev, connector, &mgag200_bmc_connector_funcs, + DRM_MODE_CONNECTOR_VIRTUAL); + if (ret) + return ret; + drm_connector_helper_add(connector, &mgag200_bmc_connector_helper_funcs); + + bmc_connector->physical_connector = physical_connector; + + return 0; +} + +int mgag200_bmc_output_init(struct mga_device *mdev, struct drm_connector *physical_connector) +{ + struct drm_device *dev = &mdev->base; + struct drm_crtc *crtc = &mdev->crtc; + struct drm_encoder *encoder; + struct mgag200_bmc_connector *bmc_connector; + struct drm_connector *connector; + int ret; + + encoder = &mdev->output.bmc.encoder; + ret = drm_encoder_init(dev, encoder, &mgag200_bmc_encoder_funcs, + DRM_MODE_ENCODER_VIRTUAL, NULL); + if (ret) + return ret; + encoder->possible_crtcs = drm_crtc_mask(crtc); + + bmc_connector = &mdev->output.bmc.bmc_connector; + ret = mgag200_bmc_connector_init(dev, bmc_connector, physical_connector); + if (ret) + return ret; + connector = &bmc_connector->base; + + ret = drm_connector_attach_encoder(connector, encoder); + if (ret) + return ret; + + return 0; +} diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.h b/drivers/gpu/drm/mgag200/mgag200_drv.h index db89fddc26dcb..7f7dfbd0f0134 100644 --- a/drivers/gpu/drm/mgag200/mgag200_drv.h +++ b/drivers/gpu/drm/mgag200/mgag200_drv.h @@ -186,6 +186,11 @@ static inline struct mgag200_crtc_state *to_mgag200_crtc_state(struct drm_crtc_s return container_of(base, struct mgag200_crtc_state, base); } +struct mgag200_bmc_connector { + struct drm_connector base; + struct drm_connector *physical_connector; +}; + enum mga_type { G200_PCI, G200_AGP, @@ -288,6 +293,10 @@ struct mga_device { struct drm_encoder encoder; struct drm_connector connector; } vga; + struct { + struct drm_encoder encoder; + struct mgag200_bmc_connector bmc_connector; + } bmc; } output; }; @@ -433,5 +442,6 @@ int mgag200_vga_output_init(struct mga_device *mdev); /* mgag200_bmc.c */ void mgag200_bmc_disable_vidrst(struct mga_device *mdev); void mgag200_bmc_enable_vidrst(struct mga_device *mdev); +int mgag200_bmc_output_init(struct mga_device *mdev, struct drm_connector *physical_connector); #endif /* __MGAG200_DRV_H__ */ diff --git a/drivers/gpu/drm/mgag200/mgag200_g200eh.c b/drivers/gpu/drm/mgag200/mgag200_g200eh.c index df00b25efb895..6f31c5249f0b1 100644 --- a/drivers/gpu/drm/mgag200/mgag200_g200eh.c +++ b/drivers/gpu/drm/mgag200/mgag200_g200eh.c @@ -218,6 +218,10 @@ static int mgag200_g200eh_pipeline_init(struct mga_device *mdev) if (ret) return ret; + ret = mgag200_bmc_output_init(mdev, &mdev->output.vga.connector); + if (ret) + return ret; + return 0; } diff --git a/drivers/gpu/drm/mgag200/mgag200_g200eh3.c b/drivers/gpu/drm/mgag200/mgag200_g200eh3.c index be42b1291e357..5befe8da4beb2 100644 --- a/drivers/gpu/drm/mgag200/mgag200_g200eh3.c +++ b/drivers/gpu/drm/mgag200/mgag200_g200eh3.c @@ -122,6 +122,10 @@ static int mgag200_g200eh3_pipeline_init(struct mga_device *mdev) if (ret) return ret; + ret = mgag200_bmc_output_init(mdev, &mdev->output.vga.connector); + if (ret) + return ret; + return 0; } diff --git a/drivers/gpu/drm/mgag200/mgag200_g200er.c b/drivers/gpu/drm/mgag200/mgag200_g200er.c index 6f2c07af38c4f..55c275180cde2 100644 --- a/drivers/gpu/drm/mgag200/mgag200_g200er.c +++ b/drivers/gpu/drm/mgag200/mgag200_g200er.c @@ -261,6 +261,10 @@ static int mgag200_g200er_pipeline_init(struct mga_device *mdev) if (ret) return ret; + ret = mgag200_bmc_output_init(mdev, &mdev->output.vga.connector); + if (ret) + return ret; + return 0; } diff --git a/drivers/gpu/drm/mgag200/mgag200_g200ev.c b/drivers/gpu/drm/mgag200/mgag200_g200ev.c index 908d04d4c862c..2466126140db6 100644 --- a/drivers/gpu/drm/mgag200/mgag200_g200ev.c +++ b/drivers/gpu/drm/mgag200/mgag200_g200ev.c @@ -262,6 +262,10 @@ static int mgag200_g200ev_pipeline_init(struct mga_device *mdev) if (ret) return ret; + ret = mgag200_bmc_output_init(mdev, &mdev->output.vga.connector); + if (ret) + return ret; + return 0; } diff --git a/drivers/gpu/drm/mgag200/mgag200_g200ew3.c b/drivers/gpu/drm/mgag200/mgag200_g200ew3.c index 8b69af543e2be..a52e60609c3de 100644 --- a/drivers/gpu/drm/mgag200/mgag200_g200ew3.c +++ b/drivers/gpu/drm/mgag200/mgag200_g200ew3.c @@ -131,6 +131,10 @@ static int mgag200_g200ew3_pipeline_init(struct mga_device *mdev) if (ret) return ret; + ret = mgag200_bmc_output_init(mdev, &mdev->output.vga.connector); + if (ret) + return ret; + return 0; } diff --git a/drivers/gpu/drm/mgag200/mgag200_g200se.c b/drivers/gpu/drm/mgag200/mgag200_g200se.c index 6d7fbdf62b97a..212770acdd477 100644 --- a/drivers/gpu/drm/mgag200/mgag200_g200se.c +++ b/drivers/gpu/drm/mgag200/mgag200_g200se.c @@ -393,6 +393,10 @@ static int mgag200_g200se_pipeline_init(struct mga_device *mdev) if (ret) return ret; + ret = mgag200_bmc_output_init(mdev, &mdev->output.vga.connector); + if (ret) + return ret; + return 0; } diff --git a/drivers/gpu/drm/mgag200/mgag200_g200wb.c b/drivers/gpu/drm/mgag200/mgag200_g200wb.c index 564d1f3ecc108..cb6daa0426fbc 100644 --- a/drivers/gpu/drm/mgag200/mgag200_g200wb.c +++ b/drivers/gpu/drm/mgag200/mgag200_g200wb.c @@ -265,6 +265,10 @@ static int mgag200_g200wb_pipeline_init(struct mga_device *mdev) if (ret) return ret; + ret = mgag200_bmc_output_init(mdev, &mdev->output.vga.connector); + if (ret) + return ret; + return 0; } From patchwork Mon Jun 10 14:06:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13692105 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 40888C27C55 for ; Mon, 10 Jun 2024 14:11:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3B6F810E12F; Mon, 10 Jun 2024 14:11:49 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2130710E189 for ; Mon, 10 Jun 2024 14:11:46 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 3912E1F7F4; Mon, 10 Jun 2024 14:11:45 +0000 (UTC) Authentication-Results: smtp-out2.suse.de; none Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 042D313AA0; Mon, 10 Jun 2024 14:11:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id +HNxO6AJZ2Z7QQAAD6G6ig (envelope-from ); Mon, 10 Jun 2024 14:11:44 +0000 From: Thomas Zimmermann To: airlied@redhat.com, jfalempe@redhat.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, airlied@gmail.com, daniel@ffwll.ch Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: [PATCH v2 3/3] drm/mgag200: Set .detect_ctx() and enable connector polling Date: Mon, 10 Jun 2024 16:06:06 +0200 Message-ID: <20240610141141.29527-4-tzimmermann@suse.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240610141141.29527-1-tzimmermann@suse.de> References: <20240610141141.29527-1-tzimmermann@suse.de> MIME-Version: 1.0 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Queue-Id: 3912E1F7F4 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Set .detect_ctx() in struct drm_connector_helper_funcs to the common helper drm_connector_helper_detect_from_ddc() and enable polling for the connector. Mgag200 will now test for the monitor's presence by probing the DDC in regular intervals. Signed-off-by: Thomas Zimmermann Reviewed-by: Jocelyn Falempe --- drivers/gpu/drm/mgag200/mgag200_g200.c | 1 + drivers/gpu/drm/mgag200/mgag200_g200eh.c | 1 + drivers/gpu/drm/mgag200/mgag200_g200eh3.c | 1 + drivers/gpu/drm/mgag200/mgag200_g200er.c | 1 + drivers/gpu/drm/mgag200/mgag200_g200ev.c | 1 + drivers/gpu/drm/mgag200/mgag200_g200ew3.c | 1 + drivers/gpu/drm/mgag200/mgag200_g200se.c | 1 + drivers/gpu/drm/mgag200/mgag200_g200wb.c | 1 + drivers/gpu/drm/mgag200/mgag200_vga.c | 6 +++++- 9 files changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_g200.c b/drivers/gpu/drm/mgag200/mgag200_g200.c index ff467b0f9cbf3..f874e29498409 100644 --- a/drivers/gpu/drm/mgag200/mgag200_g200.c +++ b/drivers/gpu/drm/mgag200/mgag200_g200.c @@ -401,6 +401,7 @@ struct mga_device *mgag200_g200_device_create(struct pci_dev *pdev, const struct return ERR_PTR(ret); drm_mode_config_reset(dev); + drm_kms_helper_poll_init(dev); return mdev; } diff --git a/drivers/gpu/drm/mgag200/mgag200_g200eh.c b/drivers/gpu/drm/mgag200/mgag200_g200eh.c index 6f31c5249f0b1..52bf49ead5c50 100644 --- a/drivers/gpu/drm/mgag200/mgag200_g200eh.c +++ b/drivers/gpu/drm/mgag200/mgag200_g200eh.c @@ -277,6 +277,7 @@ struct mga_device *mgag200_g200eh_device_create(struct pci_dev *pdev, const stru return ERR_PTR(ret); drm_mode_config_reset(dev); + drm_kms_helper_poll_init(dev); return mdev; } diff --git a/drivers/gpu/drm/mgag200/mgag200_g200eh3.c b/drivers/gpu/drm/mgag200/mgag200_g200eh3.c index 5befe8da4beb2..e7f89b2a59fd0 100644 --- a/drivers/gpu/drm/mgag200/mgag200_g200eh3.c +++ b/drivers/gpu/drm/mgag200/mgag200_g200eh3.c @@ -182,6 +182,7 @@ struct mga_device *mgag200_g200eh3_device_create(struct pci_dev *pdev, return ERR_PTR(ret); drm_mode_config_reset(dev); + drm_kms_helper_poll_init(dev); return mdev; } diff --git a/drivers/gpu/drm/mgag200/mgag200_g200er.c b/drivers/gpu/drm/mgag200/mgag200_g200er.c index 55c275180cde2..4e8a1756138d7 100644 --- a/drivers/gpu/drm/mgag200/mgag200_g200er.c +++ b/drivers/gpu/drm/mgag200/mgag200_g200er.c @@ -316,6 +316,7 @@ struct mga_device *mgag200_g200er_device_create(struct pci_dev *pdev, const stru return ERR_PTR(ret); drm_mode_config_reset(dev); + drm_kms_helper_poll_init(dev); return mdev; } diff --git a/drivers/gpu/drm/mgag200/mgag200_g200ev.c b/drivers/gpu/drm/mgag200/mgag200_g200ev.c index 2466126140db6..d884f3cb0ec79 100644 --- a/drivers/gpu/drm/mgag200/mgag200_g200ev.c +++ b/drivers/gpu/drm/mgag200/mgag200_g200ev.c @@ -321,6 +321,7 @@ struct mga_device *mgag200_g200ev_device_create(struct pci_dev *pdev, const stru return ERR_PTR(ret); drm_mode_config_reset(dev); + drm_kms_helper_poll_init(dev); return mdev; } diff --git a/drivers/gpu/drm/mgag200/mgag200_g200ew3.c b/drivers/gpu/drm/mgag200/mgag200_g200ew3.c index a52e60609c3de..839401e8b4654 100644 --- a/drivers/gpu/drm/mgag200/mgag200_g200ew3.c +++ b/drivers/gpu/drm/mgag200/mgag200_g200ew3.c @@ -202,6 +202,7 @@ struct mga_device *mgag200_g200ew3_device_create(struct pci_dev *pdev, return ERR_PTR(ret); drm_mode_config_reset(dev); + drm_kms_helper_poll_init(dev); return mdev; } diff --git a/drivers/gpu/drm/mgag200/mgag200_g200se.c b/drivers/gpu/drm/mgag200/mgag200_g200se.c index 212770acdd477..a824bb8ad5791 100644 --- a/drivers/gpu/drm/mgag200/mgag200_g200se.c +++ b/drivers/gpu/drm/mgag200/mgag200_g200se.c @@ -521,6 +521,7 @@ struct mga_device *mgag200_g200se_device_create(struct pci_dev *pdev, const stru return ERR_PTR(ret); drm_mode_config_reset(dev); + drm_kms_helper_poll_init(dev); return mdev; } diff --git a/drivers/gpu/drm/mgag200/mgag200_g200wb.c b/drivers/gpu/drm/mgag200/mgag200_g200wb.c index cb6daa0426fbc..835df0f4fc13d 100644 --- a/drivers/gpu/drm/mgag200/mgag200_g200wb.c +++ b/drivers/gpu/drm/mgag200/mgag200_g200wb.c @@ -326,6 +326,7 @@ struct mga_device *mgag200_g200wb_device_create(struct pci_dev *pdev, const stru return ERR_PTR(ret); drm_mode_config_reset(dev); + drm_kms_helper_poll_init(dev); return mdev; } diff --git a/drivers/gpu/drm/mgag200/mgag200_vga.c b/drivers/gpu/drm/mgag200/mgag200_vga.c index 6d8982990c2c3..60568f32736dd 100644 --- a/drivers/gpu/drm/mgag200/mgag200_vga.c +++ b/drivers/gpu/drm/mgag200/mgag200_vga.c @@ -12,7 +12,8 @@ static const struct drm_encoder_funcs mgag200_dac_encoder_funcs = { }; static const struct drm_connector_helper_funcs mgag200_vga_connector_helper_funcs = { - .get_modes = drm_connector_helper_get_modes + .get_modes = drm_connector_helper_get_modes, + .detect_ctx = drm_connector_helper_detect_from_ddc }; static const struct drm_connector_funcs mgag200_vga_connector_funcs = { @@ -58,6 +59,9 @@ int mgag200_vga_output_init(struct mga_device *mdev) } drm_connector_helper_add(connector, &mgag200_vga_connector_helper_funcs); + connector->polled = DRM_CONNECTOR_POLL_CONNECT | + DRM_CONNECTOR_POLL_DISCONNECT; + ret = drm_connector_attach_encoder(connector, encoder); if (ret) { drm_err(dev, "drm_connector_attach_encoder() failed: %d\n", ret);