diff mbox

[02/10] drm/i915/lvds: Introduce intel_lvds_connector

Message ID 1303463958-17128-3-git-send-email-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson April 22, 2011, 9:19 a.m. UTC
Introduce a local structure to move LVDS specific information away from
the drm_i915_private and onto the LVDS connector.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/intel_lvds.c |   31 +++++++++++++++++++++----------
 1 files changed, 21 insertions(+), 10 deletions(-)

Comments

Jesse Barnes April 22, 2011, 4:18 p.m. UTC | #1
On Fri, 22 Apr 2011 10:19:10 +0100
Chris Wilson <chris@chris-wilson.co.uk> wrote:

> Introduce a local structure to move LVDS specific information away from
> the drm_i915_private and onto the LVDS connector.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---

Nice to split this out.

Acked-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Ben Widawsky April 22, 2011, 5:50 p.m. UTC | #2
On Fri, Apr 22, 2011 at 10:19:10AM +0100, Chris Wilson wrote:
> Introduce a local structure to move LVDS specific information away from
> the drm_i915_private and onto the LVDS connector.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>  drivers/gpu/drm/i915/intel_lvds.c |   31 +++++++++++++++++++++----------
>  1 files changed, 21 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
> index 0882e4c..d82c8da 100644
> --- a/drivers/gpu/drm/i915/intel_lvds.c
> +++ b/drivers/gpu/drm/i915/intel_lvds.c
> @@ -54,11 +54,20 @@ struct intel_lvds_encoder {
>  	struct drm_display_mode *fixed_mode;
>  };
>  
> +struct intel_lvds_connector {
> +	struct intel_connector base;
> +};

How about to save some eyestrain, using some macro helpers?

struct intel_lvds_connector {
	struct intel_connector base;
#define drm_base \
	base.base
#define drm_dev \
	drm_base.dev
#define drm_funcs \
	drm_base.funcs
};

Similarly with lvds_encoder, and intel_dp structures if you so desire.

Ben
Chris Wilson April 22, 2011, 6:07 p.m. UTC | #3
On Fri, 22 Apr 2011 10:50:47 -0700, Ben Widawsky <ben@bwidawsk.net> wrote:
> How about to save some eyestrain, using some macro helpers?
> 
> struct intel_lvds_connector {
> 	struct intel_connector base;
> #define drm_base \
> 	base.base
> #define drm_dev \
> 	drm_base.dev
> #define drm_funcs \
> 	drm_base.funcs
> };
> 
> Similarly with lvds_encoder, and intel_dp structures if you so desire.

I'm always a little wary about macros to hide details of the structure,
they make the relationships less discoverable.

Fortunately, by the end of the series most of the eye sores have gone.
-Chris
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index 0882e4c..d82c8da 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -54,11 +54,20 @@  struct intel_lvds_encoder {
 	struct drm_display_mode *fixed_mode;
 };
 
+struct intel_lvds_connector {
+	struct intel_connector base;
+};
+
 static struct intel_lvds_encoder *to_lvds_encoder(struct drm_encoder *encoder)
 {
 	return container_of(encoder, struct intel_lvds_encoder, base.base);
 }
 
+static struct intel_lvds_connector *to_lvds_connector(struct drm_connector *connector)
+{
+	return container_of(connector, struct intel_lvds_connector, base.base);
+}
+
 static struct intel_lvds_encoder *intel_attached_lvds(struct drm_connector *connector)
 {
 	return container_of(intel_attached_encoder(connector),
@@ -836,11 +845,11 @@  static bool lvds_is_present_in_vbt(struct drm_device *dev,
  * Create the connector, register the LVDS DDC bus, and try to figure out what
  * modes we can display on the LVDS panel (if present).
  */
-bool intel_lvds_encoder_init(struct drm_device *dev)
+bool intel_lvds_init(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_lvds_encoder *lvds_encoder;
-	struct intel_connector *intel_connector;
+	struct intel_lvds_connector *lvds_connector;
 	struct drm_connector *connector;
 	struct drm_encoder *encoder;
 	struct drm_display_mode *scan; /* *modes, *bios_mode; */
@@ -873,8 +882,8 @@  bool intel_lvds_encoder_init(struct drm_device *dev)
 		return false;
 	}
 
-	intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL);
-	if (!intel_connector) {
+	lvds_connector = kzalloc(sizeof(struct intel_lvds_connector), GFP_KERNEL);
+	if (!lvds_connector) {
 		kfree(lvds_encoder);
 		return false;
 	}
@@ -884,17 +893,19 @@  bool intel_lvds_encoder_init(struct drm_device *dev)
 	}
 
 	encoder = &lvds_encoder->base.base;
-	connector = &intel_connector->base;
+	connector = &lvds_connector->base.base;
 	drm_connector_init(dev,
-			   &intel_connector->base,
+			   &lvds_connector->base.base,
 			   &intel_lvds_connector_funcs,
 			   DRM_MODE_CONNECTOR_LVDS);
 
-	drm_encoder_init(dev, &lvds_encoder->base.base,
+	drm_encoder_init(dev,
+			 &lvds_encoder->base.base,
 			 &intel_lvds_encoder_enc_funcs,
 			 DRM_MODE_ENCODER_LVDS);
 
-	intel_connector_attach_encoder(intel_connector, &lvds_encoder->base);
+	intel_connector_attach_encoder(&lvds_connector->base,
+				       &lvds_encoder->base);
 	lvds_encoder->base.type = INTEL_OUTPUT_LVDS;
 
 	lvds_encoder->base.clone_mask = (1 << INTEL_LVDS_CLONE_BIT);
@@ -913,7 +924,7 @@  bool intel_lvds_encoder_init(struct drm_device *dev)
 	 * the initial panel fitting mode will be FULL_SCREEN.
 	 */
 
-	drm_connector_attach_property(&intel_connector->base,
+	drm_connector_attach_property(&lvds_connector->base.base,
 				      dev->mode_config.scaling_mode_property,
 				      DRM_MODE_SCALE_ASPECT);
 	lvds_encoder->fitting_mode = DRM_MODE_SCALE_ASPECT;
@@ -1065,6 +1076,6 @@  failed:
 	drm_connector_cleanup(connector);
 	drm_encoder_cleanup(encoder);
 	kfree(lvds_encoder);
-	kfree(intel_connector);
+	kfree(lvds_connector);
 	return false;
 }