drm/ast: Embed CRTC and connector in struct ast_private
Only single instances of CRTC and connector are supported per device. Embed both in ast's structure and remove the individual memory allocations. DRM's CRTC cleanup helpers replace the rsp. destroy function in ast. While at it, also convert to_ast_connector() to a function. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Acked-by: Sam Ravnborg <sam@ravnborg.org> Link: https://patchwork.freedesktop.org/patch/msgid/20200730135206.30239-2-tzimmermann@suse.de
This commit is contained in:
parent
70eca5d5d3
commit
6a470dc2a1
|
@ -98,6 +98,22 @@ enum ast_tx_chip {
|
|||
#define AST_HWC_SIGNATURE_HOTSPOTX 0x14
|
||||
#define AST_HWC_SIGNATURE_HOTSPOTY 0x18
|
||||
|
||||
struct ast_i2c_chan {
|
||||
struct i2c_adapter adapter;
|
||||
struct drm_device *dev;
|
||||
struct i2c_algo_bit_data bit;
|
||||
};
|
||||
|
||||
struct ast_connector {
|
||||
struct drm_connector base;
|
||||
struct ast_i2c_chan *i2c;
|
||||
};
|
||||
|
||||
static inline struct ast_connector *
|
||||
to_ast_connector(struct drm_connector *connector)
|
||||
{
|
||||
return container_of(connector, struct ast_connector, base);
|
||||
}
|
||||
|
||||
struct ast_private {
|
||||
struct drm_device *dev;
|
||||
|
@ -119,9 +135,11 @@ struct ast_private {
|
|||
unsigned int next_index;
|
||||
} cursor;
|
||||
|
||||
struct drm_encoder encoder;
|
||||
struct drm_plane primary_plane;
|
||||
struct drm_plane cursor_plane;
|
||||
struct drm_crtc crtc;
|
||||
struct drm_encoder encoder;
|
||||
struct ast_connector connector;
|
||||
|
||||
bool support_wide_screen;
|
||||
enum {
|
||||
|
@ -226,19 +244,6 @@ static inline void ast_open_key(struct ast_private *ast)
|
|||
|
||||
#define AST_VIDMEM_DEFAULT_SIZE AST_VIDMEM_SIZE_8M
|
||||
|
||||
struct ast_i2c_chan {
|
||||
struct i2c_adapter adapter;
|
||||
struct drm_device *dev;
|
||||
struct i2c_algo_bit_data bit;
|
||||
};
|
||||
|
||||
struct ast_connector {
|
||||
struct drm_connector base;
|
||||
struct ast_i2c_chan *i2c;
|
||||
};
|
||||
|
||||
#define to_ast_connector(x) container_of(x, struct ast_connector, base)
|
||||
|
||||
struct ast_vbios_stdtable {
|
||||
u8 misc;
|
||||
u8 seq[4];
|
||||
|
|
|
@ -831,12 +831,6 @@ static void ast_crtc_reset(struct drm_crtc *crtc)
|
|||
__drm_atomic_helper_crtc_reset(crtc, &ast_state->base);
|
||||
}
|
||||
|
||||
static void ast_crtc_destroy(struct drm_crtc *crtc)
|
||||
{
|
||||
drm_crtc_cleanup(crtc);
|
||||
kfree(crtc);
|
||||
}
|
||||
|
||||
static struct drm_crtc_state *
|
||||
ast_crtc_atomic_duplicate_state(struct drm_crtc *crtc)
|
||||
{
|
||||
|
@ -872,7 +866,7 @@ static void ast_crtc_atomic_destroy_state(struct drm_crtc *crtc,
|
|||
static const struct drm_crtc_funcs ast_crtc_funcs = {
|
||||
.reset = ast_crtc_reset,
|
||||
.gamma_set = drm_atomic_helper_legacy_gamma_set,
|
||||
.destroy = ast_crtc_destroy,
|
||||
.destroy = drm_crtc_cleanup,
|
||||
.set_config = drm_atomic_helper_set_config,
|
||||
.page_flip = drm_atomic_helper_page_flip,
|
||||
.atomic_duplicate_state = ast_crtc_atomic_duplicate_state,
|
||||
|
@ -882,27 +876,19 @@ static const struct drm_crtc_funcs ast_crtc_funcs = {
|
|||
static int ast_crtc_init(struct drm_device *dev)
|
||||
{
|
||||
struct ast_private *ast = to_ast_private(dev);
|
||||
struct drm_crtc *crtc;
|
||||
struct drm_crtc *crtc = &ast->crtc;
|
||||
int ret;
|
||||
|
||||
crtc = kzalloc(sizeof(*crtc), GFP_KERNEL);
|
||||
if (!crtc)
|
||||
return -ENOMEM;
|
||||
|
||||
ret = drm_crtc_init_with_planes(dev, crtc, &ast->primary_plane,
|
||||
&ast->cursor_plane, &ast_crtc_funcs,
|
||||
NULL);
|
||||
if (ret)
|
||||
goto err_kfree;
|
||||
return ret;
|
||||
|
||||
drm_mode_crtc_set_gamma_size(crtc, 256);
|
||||
drm_crtc_helper_add(crtc, &ast_crtc_helper_funcs);
|
||||
|
||||
return 0;
|
||||
|
||||
err_kfree:
|
||||
kfree(crtc);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1021,7 +1007,6 @@ static void ast_connector_destroy(struct drm_connector *connector)
|
|||
struct ast_connector *ast_connector = to_ast_connector(connector);
|
||||
ast_i2c_destroy(ast_connector->i2c);
|
||||
drm_connector_cleanup(connector);
|
||||
kfree(connector);
|
||||
}
|
||||
|
||||
static const struct drm_connector_helper_funcs ast_connector_helper_funcs = {
|
||||
|
@ -1039,15 +1024,11 @@ static const struct drm_connector_funcs ast_connector_funcs = {
|
|||
|
||||
static int ast_connector_init(struct drm_device *dev)
|
||||
{
|
||||
struct ast_connector *ast_connector;
|
||||
struct drm_connector *connector;
|
||||
struct drm_encoder *encoder;
|
||||
struct ast_private *ast = to_ast_private(dev);
|
||||
struct ast_connector *ast_connector = &ast->connector;
|
||||
struct drm_connector *connector = &ast_connector->base;
|
||||
struct drm_encoder *encoder = &ast->encoder;
|
||||
|
||||
ast_connector = kzalloc(sizeof(struct ast_connector), GFP_KERNEL);
|
||||
if (!ast_connector)
|
||||
return -ENOMEM;
|
||||
|
||||
connector = &ast_connector->base;
|
||||
ast_connector->i2c = ast_i2c_create(dev);
|
||||
if (!ast_connector->i2c)
|
||||
drm_err(dev, "failed to add ddc bus for connector\n");
|
||||
|
@ -1064,7 +1045,6 @@ static int ast_connector_init(struct drm_device *dev)
|
|||
|
||||
connector->polled = DRM_CONNECTOR_POLL_CONNECT;
|
||||
|
||||
encoder = list_first_entry(&dev->mode_config.encoder_list, struct drm_encoder, head);
|
||||
drm_connector_attach_encoder(connector, encoder);
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue