[Openchrome-devel] drm-openchrome: drivers/gpu/drm
James Simmons
jsimmons at kemper.freedesktop.org
Tue Mar 26 11:03:39 PDT 2013
drivers/gpu/drm/via/via_analog.c | 10 ++++------
drivers/gpu/drm/via/via_display.c | 26 +++++++++++++++++++++++---
drivers/gpu/drm/via/via_display.h | 2 ++
drivers/gpu/drm/via/via_hdmi.c | 10 ++++------
drivers/gpu/drm/via/via_lvds.c | 12 +++++-------
5 files changed, 38 insertions(+), 22 deletions(-)
New commits:
commit 89d94daaf0c587181a91a77bbbf904fa01c19a9f
Author: James Simmons <jsimmons at infradead.org>
Date: Tue Mar 26 14:03:31 2013 -0400
Update the way encoder and connectors are memory allocated to handle multiple connectors being mapped to a encoder
diff --git a/drivers/gpu/drm/via/via_analog.c b/drivers/gpu/drm/via/via_analog.c
index e7e18ce..8fabeac 100644
--- a/drivers/gpu/drm/via/via_analog.c
+++ b/drivers/gpu/drm/via/via_analog.c
@@ -29,7 +29,7 @@
* Routines for controlling stuff on the analog port
*/
static const struct drm_encoder_funcs via_dac_enc_funcs = {
- .destroy = drm_encoder_cleanup,
+ .destroy = via_encoder_cleanup,
};
/* Manage the power state of the DAC */
@@ -116,15 +116,13 @@ via_analog_init(struct drm_device *dev)
{
struct via_connector *con;
struct via_encoder *enc;
- void *par;
- par = kzalloc(sizeof(*enc) + sizeof(*con), GFP_KERNEL);
- if (!par) {
+ enc = kzalloc(sizeof(*enc) + sizeof(*con), GFP_KERNEL);
+ if (!enc) {
DRM_ERROR("Failed to allocate connector and encoder\n");
return;
}
- con = par + sizeof(*enc);
- enc = par;
+ con = &enc->cons[0];
/* Piece together our connector */
drm_connector_init(dev, &con->base, &via_analog_connector_funcs,
diff --git a/drivers/gpu/drm/via/via_display.c b/drivers/gpu/drm/via/via_display.c
index 99046d9..2533698 100644
--- a/drivers/gpu/drm/via/via_display.c
+++ b/drivers/gpu/drm/via/via_display.c
@@ -281,6 +281,14 @@ via_best_encoder(struct drm_connector *connector)
return encoder;
}
+void via_encoder_cleanup(struct drm_encoder *encoder)
+{
+ struct via_encoder *enc = container_of(encoder, struct via_encoder, base);
+
+ drm_encoder_cleanup(encoder);
+ kfree(enc);
+}
+
/*
* Shared connector routines.
*/
@@ -335,12 +343,9 @@ via_connector_set_property(struct drm_connector *connector,
void
via_connector_destroy(struct drm_connector *connector)
{
- struct via_connector *con = container_of(connector, struct via_connector, base);
-
drm_mode_connector_update_edid_property(connector, NULL);
drm_sysfs_connector_remove(connector);
drm_connector_cleanup(connector);
- kfree(con);
}
/* Power sequence relations */
@@ -546,7 +551,22 @@ via_modeset_init(struct drm_device *dev)
void via_modeset_fini(struct drm_device *dev)
{
+ struct drm_connector *connector, *ot;
+ struct drm_encoder *encoder, *enct;
+
via_framebuffer_fini(dev);
+
+ /* We need to cleanup the connectors before the encoders */
+ list_for_each_entry_safe(connector, ot,
+ &dev->mode_config.connector_list, head) {
+ connector->funcs->destroy(connector);
+ }
+
+ list_for_each_entry_safe(encoder, enct, &dev->mode_config.encoder_list,
+ head) {
+ encoder->funcs->destroy(encoder);
+ }
+
drm_mode_config_cleanup(dev);
via_i2c_exit();
diff --git a/drivers/gpu/drm/via/via_display.h b/drivers/gpu/drm/via/via_display.h
index 02408a5..a54a3fb 100644
--- a/drivers/gpu/drm/via/via_display.h
+++ b/drivers/gpu/drm/via/via_display.h
@@ -89,6 +89,7 @@ struct via_encoder {
struct drm_encoder base;
uint32_t flags;
int diPort;
+ struct via_connector cons[];
};
static inline void
@@ -148,6 +149,7 @@ extern void via_set_sync_polarity(struct drm_encoder *encoder,
struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode);
extern struct drm_encoder* via_best_encoder(struct drm_connector *connector);
+extern void via_encoder_cleanup(struct drm_encoder *encoder);
extern void via_encoder_prepare(struct drm_encoder *encoder);
extern void via_encoder_disable(struct drm_encoder *encoder);
extern void via_encoder_commit(struct drm_encoder *encoder);
diff --git a/drivers/gpu/drm/via/via_hdmi.c b/drivers/gpu/drm/via/via_hdmi.c
index 77e648f..dffc503 100644
--- a/drivers/gpu/drm/via/via_hdmi.c
+++ b/drivers/gpu/drm/via/via_hdmi.c
@@ -33,7 +33,7 @@
* Routines for controlling stuff on the HDMI port
*/
static const struct drm_encoder_funcs via_hdmi_enc_funcs = {
- .destroy = drm_encoder_cleanup,
+ .destroy = via_encoder_cleanup,
};
static void
@@ -653,15 +653,13 @@ via_hdmi_init(struct drm_device *dev, int diport)
{
struct via_connector *con;
struct via_encoder *enc;
- void *par;
- par = kzalloc(sizeof(*enc) + sizeof(*con), GFP_KERNEL);
- if (!par) {
+ enc = kzalloc(sizeof(*enc) + sizeof(*con), GFP_KERNEL);
+ if (!enc) {
DRM_ERROR("Failed to allocate connector and encoder\n");
return;
}
- con = par + sizeof(*enc);
- enc = par;
+ con = &enc->cons[0];
/* Piece together our connector */
drm_connector_init(dev, &con->base, &via_hdmi_connector_funcs,
diff --git a/drivers/gpu/drm/via/via_lvds.c b/drivers/gpu/drm/via/via_lvds.c
index 30ebad5..d8ed81c 100644
--- a/drivers/gpu/drm/via/via_lvds.c
+++ b/drivers/gpu/drm/via/via_lvds.c
@@ -336,7 +336,7 @@ const struct drm_encoder_helper_funcs via_lvds_helper_funcs = {
};
const struct drm_encoder_funcs via_lvds_enc_funcs = {
- .destroy = drm_encoder_cleanup,
+ .destroy = via_encoder_cleanup,
};
/* detect this connector connect status */
@@ -643,15 +643,13 @@ via_lvds_init(struct drm_device *dev)
struct via_encoder *enc;
struct edid *edid;
u8 reg_value;
- void *par;
- par = kzalloc(sizeof(*enc) + sizeof(*con), GFP_KERNEL);
- if (!par) {
+ enc = kzalloc(sizeof(*enc) + sizeof(*con), GFP_KERNEL);
+ if (!enc) {
DRM_INFO("Failed to allocate LVDS output\n");
return;
}
- con = par + sizeof(*enc);
- enc = par;
+ con = &enc->cons[0];
drm_connector_init(dev, &con->base, &via_lcd_connector_funcs,
DRM_MODE_CONNECTOR_LVDS);
@@ -776,5 +774,5 @@ via_lvds_init(struct drm_device *dev)
no_device:
drm_sysfs_connector_remove(&con->base);
drm_connector_cleanup(&con->base);
- kfree(par);
+ kfree(enc);
}
More information about the Openchrome-devel
mailing list