diff mbox series

[6/8] drm/ast: Initialize encoder and connector for VGA in helper function

Message ID 20220111120058.10510-7-tzimmermann@suse.de (mailing list archive)
State New, archived
Headers show
Series drm/ast: Untangle connector helpers | expand

Commit Message

Thomas Zimmermann Jan. 11, 2022, noon UTC
Move encoder and connector initialization into a single helper and
put all related mode-setting structures into a single place. Done in
preparation of moving transmitter code into separate helpers. No
functional changes.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/ast/ast_drv.h  |  8 +++--
 drivers/gpu/drm/ast/ast_mode.c | 62 ++++++++++++++++++++--------------
 2 files changed, 42 insertions(+), 28 deletions(-)

Comments

Javier Martinez Canillas Feb. 3, 2022, 5:43 p.m. UTC | #1
On 1/11/22 13:00, Thomas Zimmermann wrote:
> Move encoder and connector initialization into a single helper and
> put all related mode-setting structures into a single place. Done in
> preparation of moving transmitter code into separate helpers. No
> functional changes.
> 
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

[snip]

> -	encoder->possible_crtcs = 1;

[snip]

> +	encoder->possible_crtcs = drm_crtc_mask(crtc);

This is a somewhat unrelated change. It's OK because is fairly simple
but I would probably still do the cleanups as separate patches.

Best regards,
Thomas Zimmermann Feb. 7, 2022, 1:04 p.m. UTC | #2
Hi

Am 03.02.22 um 18:43 schrieb Javier Martinez Canillas:
> On 1/11/22 13:00, Thomas Zimmermann wrote:
>> Move encoder and connector initialization into a single helper and
>> put all related mode-setting structures into a single place. Done in
>> preparation of moving transmitter code into separate helpers. No
>> functional changes.
>>
>> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> 
> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
> 
> [snip]
> 
>> -	encoder->possible_crtcs = 1;
> 
> [snip]
> 
>> +	encoder->possible_crtcs = drm_crtc_mask(crtc);
> 
> This is a somewhat unrelated change. It's OK because is fairly simple
> but I would probably still do the cleanups as separate patches.

I'll put this change into a separate patch.

Best regards
Thomas

> 
> Best regards,
diff mbox series

Patch

diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h
index e1cb31acdaac..cda50fb887ed 100644
--- a/drivers/gpu/drm/ast/ast_drv.h
+++ b/drivers/gpu/drm/ast/ast_drv.h
@@ -160,8 +160,12 @@  struct ast_private {
 	struct drm_plane primary_plane;
 	struct ast_cursor_plane cursor_plane;
 	struct drm_crtc crtc;
-	struct drm_encoder encoder;
-	struct ast_vga_connector connector;
+	union {
+		struct {
+			struct drm_encoder encoder;
+			struct ast_vga_connector vga_connector;
+		} vga;
+	} output;
 
 	bool support_wide_screen;
 	enum {
diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index f7f4034cc91e..17e4e038a3ed 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -1249,25 +1249,6 @@  static int ast_crtc_init(struct drm_device *dev)
 	return 0;
 }
 
-/*
- * Encoder
- */
-
-static int ast_encoder_init(struct drm_device *dev)
-{
-	struct ast_private *ast = to_ast_private(dev);
-	struct drm_encoder *encoder = &ast->encoder;
-	int ret;
-
-	ret = drm_simple_encoder_init(dev, encoder, DRM_MODE_ENCODER_DAC);
-	if (ret)
-		return ret;
-
-	encoder->possible_crtcs = 1;
-
-	return 0;
-}
-
 /*
  * VGA Connector
  */
@@ -1315,12 +1296,10 @@  static const struct drm_connector_funcs ast_vga_connector_funcs = {
 	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
 };
 
-static int ast_vga_connector_init(struct drm_device *dev)
+static int ast_vga_connector_init(struct drm_device *dev,
+				  struct ast_vga_connector *ast_vga_connector)
 {
-	struct ast_private *ast = to_ast_private(dev);
-	struct ast_vga_connector *ast_vga_connector = &ast->connector;
 	struct drm_connector *connector = &ast_vga_connector->base;
-	struct drm_encoder *encoder = &ast->encoder;
 	int ret;
 
 	ast_vga_connector->i2c = ast_i2c_create(dev);
@@ -1344,7 +1323,30 @@  static int ast_vga_connector_init(struct drm_device *dev)
 
 	connector->polled = DRM_CONNECTOR_POLL_CONNECT;
 
-	drm_connector_attach_encoder(connector, encoder);
+	return 0;
+}
+
+static int ast_vga_output_init(struct ast_private *ast)
+{
+	struct drm_device *dev = &ast->base;
+	struct drm_crtc *crtc = &ast->crtc;
+	struct drm_encoder *encoder = &ast->output.vga.encoder;
+	struct ast_vga_connector *ast_vga_connector = &ast->output.vga.vga_connector;
+	struct drm_connector *connector = &ast_vga_connector->base;
+	int ret;
+
+	ret = drm_simple_encoder_init(dev, encoder, DRM_MODE_ENCODER_DAC);
+	if (ret)
+		return ret;
+	encoder->possible_crtcs = drm_crtc_mask(crtc);
+
+	ret = ast_vga_connector_init(dev, ast_vga_connector);
+	if (ret)
+		return ret;
+
+	ret = drm_connector_attach_encoder(connector, encoder);
+	if (ret)
+		return ret;
 
 	return 0;
 }
@@ -1405,8 +1407,16 @@  int ast_mode_config_init(struct ast_private *ast)
 		return ret;
 
 	ast_crtc_init(dev);
-	ast_encoder_init(dev);
-	ast_vga_connector_init(dev);
+
+	switch (ast->tx_chip_type) {
+	case AST_TX_NONE:
+	case AST_TX_SIL164:
+	case AST_TX_DP501:
+		ret = ast_vga_output_init(ast);
+		break;
+	}
+	if (ret)
+		return ret;
 
 	drm_mode_config_reset(dev);