Commit a59b0264 authored by Thomas Zimmermann's avatar Thomas Zimmermann

drm/ast: Initialize encoder and connector for VGA in helper function

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.

v2:
	* move encoder CRTC bitmask fix into separate patch (Javier)
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarJavier Martinez Canillas <javierm@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220207141544.30015-7-tzimmermann@suse.de
parent b20384d9
...@@ -160,8 +160,12 @@ struct ast_private { ...@@ -160,8 +160,12 @@ struct ast_private {
struct drm_plane primary_plane; struct drm_plane primary_plane;
struct ast_cursor_plane cursor_plane; struct ast_cursor_plane cursor_plane;
struct drm_crtc crtc; struct drm_crtc crtc;
struct drm_encoder encoder; union {
struct ast_vga_connector connector; struct {
struct drm_encoder encoder;
struct ast_vga_connector vga_connector;
} vga;
} output;
bool support_wide_screen; bool support_wide_screen;
enum { enum {
......
...@@ -1252,25 +1252,6 @@ static int ast_crtc_init(struct drm_device *dev) ...@@ -1252,25 +1252,6 @@ static int ast_crtc_init(struct drm_device *dev)
return 0; 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 * VGA Connector
*/ */
...@@ -1318,12 +1299,10 @@ static const struct drm_connector_funcs ast_vga_connector_funcs = { ...@@ -1318,12 +1299,10 @@ static const struct drm_connector_funcs ast_vga_connector_funcs = {
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state, .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_connector *connector = &ast_vga_connector->base;
struct drm_encoder *encoder = &ast->encoder;
int ret; int ret;
ast_vga_connector->i2c = ast_i2c_create(dev); ast_vga_connector->i2c = ast_i2c_create(dev);
...@@ -1347,7 +1326,30 @@ static int ast_vga_connector_init(struct drm_device *dev) ...@@ -1347,7 +1326,30 @@ static int ast_vga_connector_init(struct drm_device *dev)
connector->polled = DRM_CONNECTOR_POLL_CONNECT; 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 = 1;
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; return 0;
} }
...@@ -1408,8 +1410,16 @@ int ast_mode_config_init(struct ast_private *ast) ...@@ -1408,8 +1410,16 @@ int ast_mode_config_init(struct ast_private *ast)
return ret; return ret;
ast_crtc_init(dev); 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); drm_mode_config_reset(dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment