Commit bb8a3560 authored by Zhenyu Wang's avatar Zhenyu Wang Committed by Eric Anholt

drm/i915: convert LVDS driver to new encoder/connector structure

Signed-off-by: default avatarZhenyu Wang <zhenyuw@linux.intel.com>
Signed-off-by: default avatarEric Anholt <eric@anholt.net>
parent 454c1ca8
...@@ -565,7 +565,8 @@ static enum drm_connector_status intel_lvds_detect(struct drm_connector *connect ...@@ -565,7 +565,8 @@ static enum drm_connector_status intel_lvds_detect(struct drm_connector *connect
static int intel_lvds_get_modes(struct drm_connector *connector) static int intel_lvds_get_modes(struct drm_connector *connector)
{ {
struct drm_device *dev = connector->dev; struct drm_device *dev = connector->dev;
struct intel_encoder *intel_encoder = to_intel_encoder(connector); struct drm_encoder *encoder = intel_attached_encoder(connector);
struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder);
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
int ret = 0; int ret = 0;
...@@ -647,11 +648,8 @@ static int intel_lid_notify(struct notifier_block *nb, unsigned long val, ...@@ -647,11 +648,8 @@ static int intel_lid_notify(struct notifier_block *nb, unsigned long val,
static void intel_lvds_destroy(struct drm_connector *connector) static void intel_lvds_destroy(struct drm_connector *connector)
{ {
struct drm_device *dev = connector->dev; struct drm_device *dev = connector->dev;
struct intel_encoder *intel_encoder = to_intel_encoder(connector);
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
if (intel_encoder->ddc_bus)
intel_i2c_destroy(intel_encoder->ddc_bus);
if (dev_priv->lid_notifier.notifier_call) if (dev_priv->lid_notifier.notifier_call)
acpi_lid_notifier_unregister(&dev_priv->lid_notifier); acpi_lid_notifier_unregister(&dev_priv->lid_notifier);
drm_sysfs_connector_remove(connector); drm_sysfs_connector_remove(connector);
...@@ -664,13 +662,14 @@ static int intel_lvds_set_property(struct drm_connector *connector, ...@@ -664,13 +662,14 @@ static int intel_lvds_set_property(struct drm_connector *connector,
uint64_t value) uint64_t value)
{ {
struct drm_device *dev = connector->dev; struct drm_device *dev = connector->dev;
struct intel_encoder *intel_encoder =
to_intel_encoder(connector);
if (property == dev->mode_config.scaling_mode_property && if (property == dev->mode_config.scaling_mode_property &&
connector->encoder) { connector->encoder) {
struct drm_crtc *crtc = connector->encoder->crtc; struct drm_crtc *crtc = connector->encoder->crtc;
struct drm_encoder *encoder = connector->encoder;
struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder);
struct intel_lvds_priv *lvds_priv = intel_encoder->dev_priv; struct intel_lvds_priv *lvds_priv = intel_encoder->dev_priv;
if (value == DRM_MODE_SCALE_NONE) { if (value == DRM_MODE_SCALE_NONE) {
DRM_DEBUG_KMS("no scaling not supported\n"); DRM_DEBUG_KMS("no scaling not supported\n");
return 0; return 0;
...@@ -704,7 +703,7 @@ static const struct drm_encoder_helper_funcs intel_lvds_helper_funcs = { ...@@ -704,7 +703,7 @@ static const struct drm_encoder_helper_funcs intel_lvds_helper_funcs = {
static const struct drm_connector_helper_funcs intel_lvds_connector_helper_funcs = { static const struct drm_connector_helper_funcs intel_lvds_connector_helper_funcs = {
.get_modes = intel_lvds_get_modes, .get_modes = intel_lvds_get_modes,
.mode_valid = intel_lvds_mode_valid, .mode_valid = intel_lvds_mode_valid,
.best_encoder = intel_best_encoder, .best_encoder = intel_attached_encoder,
}; };
static const struct drm_connector_funcs intel_lvds_connector_funcs = { static const struct drm_connector_funcs intel_lvds_connector_funcs = {
...@@ -718,7 +717,12 @@ static const struct drm_connector_funcs intel_lvds_connector_funcs = { ...@@ -718,7 +717,12 @@ static const struct drm_connector_funcs intel_lvds_connector_funcs = {
static void intel_lvds_enc_destroy(struct drm_encoder *encoder) static void intel_lvds_enc_destroy(struct drm_encoder *encoder)
{ {
struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder);
if (intel_encoder->ddc_bus)
intel_i2c_destroy(intel_encoder->ddc_bus);
drm_encoder_cleanup(encoder); drm_encoder_cleanup(encoder);
kfree(intel_encoder);
} }
static const struct drm_encoder_funcs intel_lvds_enc_funcs = { static const struct drm_encoder_funcs intel_lvds_enc_funcs = {
...@@ -907,6 +911,7 @@ void intel_lvds_init(struct drm_device *dev) ...@@ -907,6 +911,7 @@ void intel_lvds_init(struct drm_device *dev)
{ {
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_encoder *intel_encoder; struct intel_encoder *intel_encoder;
struct intel_connector *intel_connector;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_encoder *encoder; struct drm_encoder *encoder;
struct drm_display_mode *scan; /* *modes, *bios_mode; */ struct drm_display_mode *scan; /* *modes, *bios_mode; */
...@@ -940,15 +945,21 @@ void intel_lvds_init(struct drm_device *dev) ...@@ -940,15 +945,21 @@ void intel_lvds_init(struct drm_device *dev)
return; return;
} }
connector = &intel_encoder->base; intel_connector = kzalloc(sizeof(struct intel_connector), GFP_KERNEL);
if (!intel_connector) {
kfree(intel_encoder);
return;
}
connector = &intel_connector->base;
encoder = &intel_encoder->enc; encoder = &intel_encoder->enc;
drm_connector_init(dev, &intel_encoder->base, &intel_lvds_connector_funcs, drm_connector_init(dev, &intel_connector->base, &intel_lvds_connector_funcs,
DRM_MODE_CONNECTOR_LVDS); DRM_MODE_CONNECTOR_LVDS);
drm_encoder_init(dev, &intel_encoder->enc, &intel_lvds_enc_funcs, drm_encoder_init(dev, &intel_encoder->enc, &intel_lvds_enc_funcs,
DRM_MODE_ENCODER_LVDS); DRM_MODE_ENCODER_LVDS);
drm_mode_connector_attach_encoder(&intel_encoder->base, &intel_encoder->enc); drm_mode_connector_attach_encoder(&intel_connector->base, &intel_encoder->enc);
intel_encoder->type = INTEL_OUTPUT_LVDS; intel_encoder->type = INTEL_OUTPUT_LVDS;
intel_encoder->clone_mask = (1 << INTEL_LVDS_CLONE_BIT); intel_encoder->clone_mask = (1 << INTEL_LVDS_CLONE_BIT);
...@@ -969,7 +980,7 @@ void intel_lvds_init(struct drm_device *dev) ...@@ -969,7 +980,7 @@ void intel_lvds_init(struct drm_device *dev)
* the initial panel fitting mode will be FULL_SCREEN. * the initial panel fitting mode will be FULL_SCREEN.
*/ */
drm_connector_attach_property(&intel_encoder->base, drm_connector_attach_property(&intel_connector->base,
dev->mode_config.scaling_mode_property, dev->mode_config.scaling_mode_property,
DRM_MODE_SCALE_FULLSCREEN); DRM_MODE_SCALE_FULLSCREEN);
lvds_priv->fitting_mode = DRM_MODE_SCALE_FULLSCREEN; lvds_priv->fitting_mode = DRM_MODE_SCALE_FULLSCREEN;
...@@ -1081,4 +1092,5 @@ void intel_lvds_init(struct drm_device *dev) ...@@ -1081,4 +1092,5 @@ void intel_lvds_init(struct drm_device *dev)
drm_connector_cleanup(connector); drm_connector_cleanup(connector);
drm_encoder_cleanup(encoder); drm_encoder_cleanup(encoder);
kfree(intel_encoder); kfree(intel_encoder);
kfree(intel_connector);
} }
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