drm/radeon: Provide ddc symlink in connector sysfs directory
authorAndrzej Pietrasiewicz <andrzej.p@collabora.com>
Mon, 26 Aug 2019 19:25:44 +0000 (21:25 +0200)
committerAndrzej Pietrasiewicz <andrzej.p@collabora.com>
Thu, 7 Nov 2019 14:06:36 +0000 (15:06 +0100)
Use the ddc pointer provided by the generic connector.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/
drivers/gpu/drm/radeon/radeon_connectors.c

index c07427d3c19995f76dbd153a65e6b8283ab111de..0851e6817e57444e7d4f246c368a9984e8edd8ed 100644 (file)
@@ -1861,6 +1861,7 @@ radeon_add_atom_connector(struct drm_device *dev,
        struct radeon_connector_atom_dig *radeon_dig_connector;
        struct drm_encoder *encoder;
        struct radeon_encoder *radeon_encoder;
+       struct i2c_adapter *ddc = NULL;
        uint32_t subpixel_order = SubPixelNone;
        bool shared_ddc = false;
        bool is_dp_bridge = false;
@@ -1938,17 +1939,21 @@ radeon_add_atom_connector(struct drm_device *dev,
                radeon_connector->con_priv = radeon_dig_connector;
                if (i2c_bus->valid) {
                        radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
-                       if (radeon_connector->ddc_bus)
+                       if (radeon_connector->ddc_bus) {
                                has_aux = true;
-                       else
+                               ddc = &radeon_connector->ddc_bus->adapter;
+                       } else {
                                DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
+                       }
                }
                switch (connector_type) {
                case DRM_MODE_CONNECTOR_VGA:
                case DRM_MODE_CONNECTOR_DVIA:
                default:
-                       drm_connector_init(dev, &radeon_connector->base,
-                                          &radeon_dp_connector_funcs, connector_type);
+                       drm_connector_init_with_ddc(dev, &radeon_connector->base,
+                                                   &radeon_dp_connector_funcs,
+                                                   connector_type,
+                                                   ddc);
                        drm_connector_helper_add(&radeon_connector->base,
                                                 &radeon_dp_connector_helper_funcs);
                        connector->interlace_allowed = true;
@@ -1970,8 +1975,10 @@ radeon_add_atom_connector(struct drm_device *dev,
                case DRM_MODE_CONNECTOR_HDMIA:
                case DRM_MODE_CONNECTOR_HDMIB:
                case DRM_MODE_CONNECTOR_DisplayPort:
-                       drm_connector_init(dev, &radeon_connector->base,
-                                          &radeon_dp_connector_funcs, connector_type);
+                       drm_connector_init_with_ddc(dev, &radeon_connector->base,
+                                                   &radeon_dp_connector_funcs,
+                                                   connector_type,
+                                                   ddc);
                        drm_connector_helper_add(&radeon_connector->base,
                                                 &radeon_dp_connector_helper_funcs);
                        drm_object_attach_property(&radeon_connector->base.base,
@@ -2018,8 +2025,10 @@ radeon_add_atom_connector(struct drm_device *dev,
                        break;
                case DRM_MODE_CONNECTOR_LVDS:
                case DRM_MODE_CONNECTOR_eDP:
-                       drm_connector_init(dev, &radeon_connector->base,
-                                          &radeon_lvds_bridge_connector_funcs, connector_type);
+                       drm_connector_init_with_ddc(dev, &radeon_connector->base,
+                                                   &radeon_lvds_bridge_connector_funcs,
+                                                   connector_type,
+                                                   ddc);
                        drm_connector_helper_add(&radeon_connector->base,
                                                 &radeon_dp_connector_helper_funcs);
                        drm_object_attach_property(&radeon_connector->base.base,
@@ -2033,13 +2042,18 @@ radeon_add_atom_connector(struct drm_device *dev,
        } else {
                switch (connector_type) {
                case DRM_MODE_CONNECTOR_VGA:
-                       drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type);
-                       drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs);
                        if (i2c_bus->valid) {
                                radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
                                if (!radeon_connector->ddc_bus)
                                        DRM_ERROR("VGA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
+                               else
+                                       ddc = &radeon_connector->ddc_bus->adapter;
                        }
+                       drm_connector_init_with_ddc(dev, &radeon_connector->base,
+                                                   &radeon_vga_connector_funcs,
+                                                   connector_type,
+                                                   ddc);
+                       drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs);
                        radeon_connector->dac_load_detect = true;
                        drm_object_attach_property(&radeon_connector->base.base,
                                                      rdev->mode_info.load_detect_property,
@@ -2058,13 +2072,18 @@ radeon_add_atom_connector(struct drm_device *dev,
                        connector->doublescan_allowed = true;
                        break;
                case DRM_MODE_CONNECTOR_DVIA:
-                       drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type);
-                       drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs);
                        if (i2c_bus->valid) {
                                radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
                                if (!radeon_connector->ddc_bus)
                                        DRM_ERROR("DVIA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
+                               else
+                                       ddc = &radeon_connector->ddc_bus->adapter;
                        }
+                       drm_connector_init_with_ddc(dev, &radeon_connector->base,
+                                                   &radeon_vga_connector_funcs,
+                                                   connector_type,
+                                                   ddc);
+                       drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs);
                        radeon_connector->dac_load_detect = true;
                        drm_object_attach_property(&radeon_connector->base.base,
                                                      rdev->mode_info.load_detect_property,
@@ -2089,13 +2108,18 @@ radeon_add_atom_connector(struct drm_device *dev,
                                goto failed;
                        radeon_dig_connector->igp_lane_info = igp_lane_info;
                        radeon_connector->con_priv = radeon_dig_connector;
-                       drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type);
-                       drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs);
                        if (i2c_bus->valid) {
                                radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
                                if (!radeon_connector->ddc_bus)
                                        DRM_ERROR("DVI: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
+                               else
+                                       ddc = &radeon_connector->ddc_bus->adapter;
                        }
+                       drm_connector_init_with_ddc(dev, &radeon_connector->base,
+                                                   &radeon_dvi_connector_funcs,
+                                                   connector_type,
+                                                   ddc);
+                       drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs);
                        subpixel_order = SubPixelHorizontalRGB;
                        drm_object_attach_property(&radeon_connector->base.base,
                                                      rdev->mode_info.coherent_mode_property,
@@ -2146,13 +2170,18 @@ radeon_add_atom_connector(struct drm_device *dev,
                                goto failed;
                        radeon_dig_connector->igp_lane_info = igp_lane_info;
                        radeon_connector->con_priv = radeon_dig_connector;
-                       drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type);
-                       drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs);
                        if (i2c_bus->valid) {
                                radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
                                if (!radeon_connector->ddc_bus)
                                        DRM_ERROR("HDMI: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
+                               else
+                                       ddc = &radeon_connector->ddc_bus->adapter;
                        }
+                       drm_connector_init_with_ddc(dev, &radeon_connector->base,
+                                                   &radeon_dvi_connector_funcs,
+                                                   connector_type,
+                                                   ddc);
+                       drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs);
                        drm_object_attach_property(&radeon_connector->base.base,
                                                      rdev->mode_info.coherent_mode_property,
                                                      1);
@@ -2196,15 +2225,20 @@ radeon_add_atom_connector(struct drm_device *dev,
                                goto failed;
                        radeon_dig_connector->igp_lane_info = igp_lane_info;
                        radeon_connector->con_priv = radeon_dig_connector;
-                       drm_connector_init(dev, &radeon_connector->base, &radeon_dp_connector_funcs, connector_type);
-                       drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs);
                        if (i2c_bus->valid) {
                                radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
-                               if (radeon_connector->ddc_bus)
+                               if (radeon_connector->ddc_bus) {
                                        has_aux = true;
-                               else
+                                       ddc = &radeon_connector->ddc_bus->adapter;
+                               } else {
                                        DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
+                               }
                        }
+                       drm_connector_init_with_ddc(dev, &radeon_connector->base,
+                                                   &radeon_dp_connector_funcs,
+                                                   connector_type,
+                                                   ddc);
+                       drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs);
                        subpixel_order = SubPixelHorizontalRGB;
                        drm_object_attach_property(&radeon_connector->base.base,
                                                      rdev->mode_info.coherent_mode_property,
@@ -2246,15 +2280,20 @@ radeon_add_atom_connector(struct drm_device *dev,
                                goto failed;
                        radeon_dig_connector->igp_lane_info = igp_lane_info;
                        radeon_connector->con_priv = radeon_dig_connector;
-                       drm_connector_init(dev, &radeon_connector->base, &radeon_edp_connector_funcs, connector_type);
-                       drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs);
                        if (i2c_bus->valid) {
                                radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
-                               if (radeon_connector->ddc_bus)
+                               if (radeon_connector->ddc_bus) {
                                        has_aux = true;
-                               else
+                                       ddc = &radeon_connector->ddc_bus->adapter;
+                               } else {
                                        DRM_ERROR("DP: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
+                               }
                        }
+                       drm_connector_init_with_ddc(dev, &radeon_connector->base,
+                                                   &radeon_edp_connector_funcs,
+                                                   connector_type,
+                                                   ddc);
+                       drm_connector_helper_add(&radeon_connector->base, &radeon_dp_connector_helper_funcs);
                        drm_object_attach_property(&radeon_connector->base.base,
                                                      dev->mode_config.scaling_mode_property,
                                                      DRM_MODE_SCALE_FULLSCREEN);
@@ -2265,7 +2304,10 @@ radeon_add_atom_connector(struct drm_device *dev,
                case DRM_MODE_CONNECTOR_SVIDEO:
                case DRM_MODE_CONNECTOR_Composite:
                case DRM_MODE_CONNECTOR_9PinDIN:
-                       drm_connector_init(dev, &radeon_connector->base, &radeon_tv_connector_funcs, connector_type);
+                       drm_connector_init_with_ddc(dev, &radeon_connector->base,
+                                                   &radeon_tv_connector_funcs,
+                                                   connector_type,
+                                                   ddc);
                        drm_connector_helper_add(&radeon_connector->base, &radeon_tv_connector_helper_funcs);
                        radeon_connector->dac_load_detect = true;
                        drm_object_attach_property(&radeon_connector->base.base,
@@ -2285,13 +2327,18 @@ radeon_add_atom_connector(struct drm_device *dev,
                                goto failed;
                        radeon_dig_connector->igp_lane_info = igp_lane_info;
                        radeon_connector->con_priv = radeon_dig_connector;
-                       drm_connector_init(dev, &radeon_connector->base, &radeon_lvds_connector_funcs, connector_type);
-                       drm_connector_helper_add(&radeon_connector->base, &radeon_lvds_connector_helper_funcs);
                        if (i2c_bus->valid) {
                                radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
                                if (!radeon_connector->ddc_bus)
                                        DRM_ERROR("LVDS: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
+                               else
+                                       ddc = &radeon_connector->ddc_bus->adapter;
                        }
+                       drm_connector_init_with_ddc(dev, &radeon_connector->base,
+                                                   &radeon_lvds_connector_funcs,
+                                                   connector_type,
+                                                   ddc);
+                       drm_connector_helper_add(&radeon_connector->base, &radeon_lvds_connector_helper_funcs);
                        drm_object_attach_property(&radeon_connector->base.base,
                                                      dev->mode_config.scaling_mode_property,
                                                      DRM_MODE_SCALE_FULLSCREEN);
@@ -2335,6 +2382,7 @@ radeon_add_legacy_connector(struct drm_device *dev,
        struct radeon_device *rdev = dev->dev_private;
        struct drm_connector *connector;
        struct radeon_connector *radeon_connector;
+       struct i2c_adapter *ddc = NULL;
        uint32_t subpixel_order = SubPixelNone;
 
        if (connector_type == DRM_MODE_CONNECTOR_Unknown)
@@ -2369,13 +2417,18 @@ radeon_add_legacy_connector(struct drm_device *dev,
 
        switch (connector_type) {
        case DRM_MODE_CONNECTOR_VGA:
-               drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type);
-               drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs);
                if (i2c_bus->valid) {
                        radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
                        if (!radeon_connector->ddc_bus)
                                DRM_ERROR("VGA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
+                       else
+                               ddc = &radeon_connector->ddc_bus->adapter;
                }
+               drm_connector_init_with_ddc(dev, &radeon_connector->base,
+                                           &radeon_vga_connector_funcs,
+                                           connector_type,
+                                           ddc);
+               drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs);
                radeon_connector->dac_load_detect = true;
                drm_object_attach_property(&radeon_connector->base.base,
                                              rdev->mode_info.load_detect_property,
@@ -2386,13 +2439,18 @@ radeon_add_legacy_connector(struct drm_device *dev,
                connector->doublescan_allowed = true;
                break;
        case DRM_MODE_CONNECTOR_DVIA:
-               drm_connector_init(dev, &radeon_connector->base, &radeon_vga_connector_funcs, connector_type);
-               drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs);
                if (i2c_bus->valid) {
                        radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
                        if (!radeon_connector->ddc_bus)
                                DRM_ERROR("DVIA: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
+                       else
+                               ddc = &radeon_connector->ddc_bus->adapter;
                }
+               drm_connector_init_with_ddc(dev, &radeon_connector->base,
+                                           &radeon_vga_connector_funcs,
+                                           connector_type,
+                                           ddc);
+               drm_connector_helper_add(&radeon_connector->base, &radeon_vga_connector_helper_funcs);
                radeon_connector->dac_load_detect = true;
                drm_object_attach_property(&radeon_connector->base.base,
                                              rdev->mode_info.load_detect_property,
@@ -2404,13 +2462,18 @@ radeon_add_legacy_connector(struct drm_device *dev,
                break;
        case DRM_MODE_CONNECTOR_DVII:
        case DRM_MODE_CONNECTOR_DVID:
-               drm_connector_init(dev, &radeon_connector->base, &radeon_dvi_connector_funcs, connector_type);
-               drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs);
                if (i2c_bus->valid) {
                        radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
                        if (!radeon_connector->ddc_bus)
                                DRM_ERROR("DVI: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
+                       else
+                               ddc = &radeon_connector->ddc_bus->adapter;
                }
+               drm_connector_init_with_ddc(dev, &radeon_connector->base,
+                                           &radeon_dvi_connector_funcs,
+                                           connector_type,
+                                           ddc);
+               drm_connector_helper_add(&radeon_connector->base, &radeon_dvi_connector_helper_funcs);
                if (connector_type == DRM_MODE_CONNECTOR_DVII) {
                        radeon_connector->dac_load_detect = true;
                        drm_object_attach_property(&radeon_connector->base.base,
@@ -2427,7 +2490,10 @@ radeon_add_legacy_connector(struct drm_device *dev,
        case DRM_MODE_CONNECTOR_SVIDEO:
        case DRM_MODE_CONNECTOR_Composite:
        case DRM_MODE_CONNECTOR_9PinDIN:
-               drm_connector_init(dev, &radeon_connector->base, &radeon_tv_connector_funcs, connector_type);
+               drm_connector_init_with_ddc(dev, &radeon_connector->base,
+                                           &radeon_tv_connector_funcs,
+                                           connector_type,
+                                           ddc);
                drm_connector_helper_add(&radeon_connector->base, &radeon_tv_connector_helper_funcs);
                radeon_connector->dac_load_detect = true;
                /* RS400,RC410,RS480 chipset seems to report a lot
@@ -2449,13 +2515,18 @@ radeon_add_legacy_connector(struct drm_device *dev,
                connector->doublescan_allowed = false;
                break;
        case DRM_MODE_CONNECTOR_LVDS:
-               drm_connector_init(dev, &radeon_connector->base, &radeon_lvds_connector_funcs, connector_type);
-               drm_connector_helper_add(&radeon_connector->base, &radeon_lvds_connector_helper_funcs);
                if (i2c_bus->valid) {
                        radeon_connector->ddc_bus = radeon_i2c_lookup(rdev, i2c_bus);
                        if (!radeon_connector->ddc_bus)
                                DRM_ERROR("LVDS: Failed to assign ddc bus! Check dmesg for i2c errors.\n");
+                       else
+                               ddc = &radeon_connector->ddc_bus->adapter;
                }
+               drm_connector_init_with_ddc(dev, &radeon_connector->base,
+                                           &radeon_lvds_connector_funcs,
+                                           connector_type,
+                                           ddc);
+               drm_connector_helper_add(&radeon_connector->base, &radeon_lvds_connector_helper_funcs);
                drm_object_attach_property(&radeon_connector->base.base,
                                              dev->mode_config.scaling_mode_property,
                                              DRM_MODE_SCALE_FULLSCREEN);