Commit 0cc3ae93 authored by Patrik Jakobsson's avatar Patrik Jakobsson

drm/gma500: Make cdv crt use ddc adapter from drm_connector

We're moving all uses of ddc_bus to drm_connector where they belong.
Also cleanup the error handling in cdv_intel_crt_init().
Signed-off-by: default avatarPatrik Jakobsson <patrik.r.jakobsson@gmail.com>
Acked-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20220601092311.22648-7-patrik.r.jakobsson@gmail.com
parent 147a0907
......@@ -192,18 +192,16 @@ static enum drm_connector_status cdv_intel_crt_detect(
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,
......@@ -245,8 +243,10 @@ void cdv_intel_crt_init(struct drm_device *dev,
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)
......@@ -254,25 +254,31 @@ void cdv_intel_crt_init(struct drm_device *dev,
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;
......@@ -282,11 +288,14 @@ void cdv_intel_crt_init(struct drm_device *dev,
&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;
}
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