drm: rcar-du: Replace direct DRM encoder access with cast macro
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Sun, 30 Mar 2014 23:50:16 +0000 (01:50 +0200)
committerLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Wed, 26 Nov 2014 18:09:37 +0000 (20:09 +0200)
Add a new macro to downcast an rcar_du_encoder pointer to a drm_encoder
pointer and use it. This prepares for the replacement of the
rcar_drm_encoder encoder field with a drm_slave_encoder.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
drivers/gpu/drm/rcar-du/rcar_du_encoder.c
drivers/gpu/drm/rcar-du/rcar_du_encoder.h
drivers/gpu/drm/rcar-du/rcar_du_lvdscon.c
drivers/gpu/drm/rcar-du/rcar_du_vgacon.c

index c699100a13593703f37fa17a6957b81a7aaf598f..e88e63b06b0977bc66bf3876a52cf66dcb3c8198 100644 (file)
@@ -33,7 +33,7 @@ rcar_du_connector_best_encoder(struct drm_connector *connector)
 {
        struct rcar_du_connector *rcon = to_rcar_connector(connector);
 
-       return &rcon->encoder->encoder;
+       return rcar_encoder_to_drm_encoder(rcon->encoder);
 }
 
 /* -----------------------------------------------------------------------------
@@ -146,6 +146,7 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu,
                         struct device_node *con_node)
 {
        struct rcar_du_encoder *renc;
+       struct drm_encoder *encoder;
        unsigned int encoder_type;
        int ret;
 
@@ -154,6 +155,7 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu,
                return -ENOMEM;
 
        renc->output = output;
+       encoder = rcar_encoder_to_drm_encoder(renc);
 
        switch (output) {
        case RCAR_DU_OUTPUT_LVDS0:
@@ -182,12 +184,12 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu,
                break;
        }
 
-       ret = drm_encoder_init(rcdu->ddev, &renc->encoder, &encoder_funcs,
+       ret = drm_encoder_init(rcdu->ddev, encoder, &encoder_funcs,
                               encoder_type);
        if (ret < 0)
                return ret;
 
-       drm_encoder_helper_add(&renc->encoder, &encoder_helper_funcs);
+       drm_encoder_helper_add(encoder, &encoder_helper_funcs);
 
        switch (encoder_type) {
        case DRM_MODE_ENCODER_LVDS:
index 4b906b90c204f0c90ed2f061a3cbb64459371638..c6334b4280d96200a2053531e28bed3be86b6b64 100644 (file)
@@ -35,6 +35,8 @@ struct rcar_du_encoder {
 #define to_rcar_encoder(e) \
        container_of(e, struct rcar_du_encoder, encoder)
 
+#define rcar_encoder_to_drm_encoder(e) (&(e)->encoder)
+
 struct rcar_du_connector {
        struct drm_connector connector;
        struct rcar_du_encoder *encoder;
index 80dc02166c885c0b7dde1c83d2f0db095731b94e..6d9811c052c4bce4d41ea61232fd99aaa71d6aa9 100644 (file)
@@ -84,6 +84,7 @@ int rcar_du_lvds_connector_init(struct rcar_du_device *rcdu,
                                struct rcar_du_encoder *renc,
                                /* TODO const */ struct device_node *np)
 {
+       struct drm_encoder *encoder = rcar_encoder_to_drm_encoder(renc);
        struct rcar_du_lvds_connector *lvdscon;
        struct drm_connector *connector;
        struct display_timing timing;
@@ -120,11 +121,11 @@ int rcar_du_lvds_connector_init(struct rcar_du_device *rcdu,
        drm_object_property_set_value(&connector->base,
                rcdu->ddev->mode_config.dpms_property, DRM_MODE_DPMS_OFF);
 
-       ret = drm_mode_connector_attach_encoder(connector, &renc->encoder);
+       ret = drm_mode_connector_attach_encoder(connector, encoder);
        if (ret < 0)
                return ret;
 
-       connector->encoder = &renc->encoder;
+       connector->encoder = encoder;
        lvdscon->connector.encoder = renc;
 
        return 0;
index 564a723ede0374e5def036e085b009bef4b1a954..752747a5e920e847ac689aa78555da1c12716b9e 100644 (file)
@@ -52,6 +52,7 @@ static const struct drm_connector_funcs connector_funcs = {
 int rcar_du_vga_connector_init(struct rcar_du_device *rcdu,
                               struct rcar_du_encoder *renc)
 {
+       struct drm_encoder *encoder = rcar_encoder_to_drm_encoder(renc);
        struct rcar_du_connector *rcon;
        struct drm_connector *connector;
        int ret;
@@ -78,11 +79,11 @@ int rcar_du_vga_connector_init(struct rcar_du_device *rcdu,
        drm_object_property_set_value(&connector->base,
                rcdu->ddev->mode_config.dpms_property, DRM_MODE_DPMS_OFF);
 
-       ret = drm_mode_connector_attach_encoder(connector, &renc->encoder);
+       ret = drm_mode_connector_attach_encoder(connector, encoder);
        if (ret < 0)
                return ret;
 
-       connector->encoder = &renc->encoder;
+       connector->encoder = encoder;
        rcon->encoder = renc;
 
        return 0;