static void cdv_intel_crt_destroy(struct drm_connector *connector)
{
struct gma_connector *gma_connector = to_gma_connector(connector);
- struct gma_encoder *gma_encoder = gma_attached_encoder(connector);
+ struct gma_i2c_chan *ddc_bus = to_gma_i2c_chan(connector->ddc);
- gma_i2c_destroy(gma_encoder->ddc_bus);
+ gma_i2c_destroy(ddc_bus);
drm_connector_cleanup(connector);
kfree(gma_connector);
}
static int cdv_intel_crt_get_modes(struct drm_connector *connector)
{
- struct gma_encoder *gma_encoder = gma_attached_encoder(connector);
- return psb_intel_ddc_get_modes(connector,
- &gma_encoder->ddc_bus->base);
+ return psb_intel_ddc_get_modes(connector, connector->ddc);
}
static int cdv_intel_crt_set_property(struct drm_connector *connector,
struct gma_connector *gma_connector;
struct gma_encoder *gma_encoder;
+ struct gma_i2c_chan *ddc_bus;
struct drm_connector *connector;
struct drm_encoder *encoder;
+ int ret;
gma_encoder = kzalloc(sizeof(struct gma_encoder), GFP_KERNEL);
if (!gma_encoder)
gma_connector = kzalloc(sizeof(struct gma_connector), GFP_KERNEL);
if (!gma_connector)
- goto failed_connector;
+ goto err_free_encoder;
+
+ /* Set up the DDC bus. */
+ ddc_bus = gma_i2c_create(dev, GPIOA, "CRTDDC_A");
+ if (!ddc_bus) {
+ dev_printk(KERN_ERR, dev->dev, "DDC bus registration failed.\n");
+ goto err_free_connector;
+ }
connector = &gma_connector->base;
connector->polled = DRM_CONNECTOR_POLL_HPD;
- drm_connector_init(dev, connector,
- &cdv_intel_crt_connector_funcs, DRM_MODE_CONNECTOR_VGA);
+ ret = drm_connector_init_with_ddc(dev, connector,
+ &cdv_intel_crt_connector_funcs,
+ DRM_MODE_CONNECTOR_VGA,
+ &ddc_bus->base);
+ if (ret)
+ goto err_ddc_destroy;
encoder = &gma_encoder->base;
- drm_simple_encoder_init(dev, encoder, DRM_MODE_ENCODER_DAC);
+ ret = drm_simple_encoder_init(dev, encoder, DRM_MODE_ENCODER_DAC);
+ if (ret)
+ goto err_connector_cleanup;
gma_connector_attach_encoder(gma_connector, gma_encoder);
- /* Set up the DDC bus. */
- gma_encoder->ddc_bus = gma_i2c_create(dev, GPIOA, "CRTDDC_A");
- if (!gma_encoder->ddc_bus) {
- dev_printk(KERN_ERR, dev->dev, "DDC bus registration failed.\n");
- goto failed_ddc;
- }
-
gma_encoder->type = INTEL_OUTPUT_ANALOG;
connector->interlace_allowed = 0;
connector->doublescan_allowed = 0;
&cdv_intel_crt_connector_helper_funcs);
return;
-failed_ddc:
- drm_encoder_cleanup(&gma_encoder->base);
+
+err_connector_cleanup:
drm_connector_cleanup(&gma_connector->base);
+err_ddc_destroy:
+ gma_i2c_destroy(ddc_bus);
+err_free_connector:
kfree(gma_connector);
-failed_connector:
+err_free_encoder:
kfree(gma_encoder);
return;
}