drm/amd/display: get_atomic_property missing for drm_connector_funcs
authorPratik Vishwakarma <Pratik.Vishwakarma@amd.com>
Thu, 6 Apr 2017 07:48:20 +0000 (13:18 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 26 Sep 2017 21:22:51 +0000 (17:22 -0400)
DRM_IOCTL_MODE_GETCONNECTOR fails with EINVAL on enabling DRIVER_ATOMIC
With this DRM_IOCTL_MODE_GETCONNECTOR returns all the connector properties.
freesync_property and freesync_capable_property return 0 currently.

TESTS(On Chromium OS on Stoney Only)
* Builds without compilation errors.
* 'atomictest' proceeds after applying patch and fails with vblank event
timed out.
* Chromium OS ui comes up.

Signed-off-by: Pratik Vishwakarma <Pratik.Vishwakarma@amd.com>
Reviewed-by: Tony Cheng <Tony.Cheng@amd.com>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.h

index 2c48408849d8883e3b8feb4f9bb9326462b4cb94..ba1f3d40771afba90f7b6b56e607a412f98fa360 100644 (file)
@@ -1184,6 +1184,48 @@ int amdgpu_dm_connector_atomic_set_property(
        return ret;
 }
 
+int amdgpu_dm_connector_atomic_get_property(
+       struct drm_connector *connector,
+       const struct drm_connector_state *state,
+       struct drm_property *property,
+       uint64_t *val)
+{
+       struct drm_device *dev = connector->dev;
+       struct amdgpu_device *adev = dev->dev_private;
+       struct dm_connector_state *dm_state =
+               to_dm_connector_state(state);
+       int ret = -EINVAL;
+
+       if (property == dev->mode_config.scaling_mode_property) {
+               switch (dm_state->scaling) {
+               case RMX_CENTER:
+                       *val = DRM_MODE_SCALE_CENTER;
+                       break;
+               case RMX_ASPECT:
+                       *val = DRM_MODE_SCALE_ASPECT;
+                       break;
+               case RMX_FULL:
+                       *val = DRM_MODE_SCALE_FULLSCREEN;
+                       break;
+               case RMX_OFF:
+               default:
+                       *val = DRM_MODE_SCALE_NONE;
+                       break;
+               }
+               ret = 0;
+       } else if (property == adev->mode_info.underscan_hborder_property) {
+               *val = dm_state->underscan_hborder;
+               ret = 0;
+       } else if (property == adev->mode_info.underscan_vborder_property) {
+               *val = dm_state->underscan_vborder;
+               ret = 0;
+       } else if (property == adev->mode_info.underscan_property) {
+               *val = dm_state->underscan_enable;
+               ret = 0;
+       }
+       return ret;
+}
+
 void amdgpu_dm_connector_destroy(struct drm_connector *connector)
 {
        struct amdgpu_connector *aconnector = to_amdgpu_connector(connector);
@@ -1246,43 +1288,6 @@ struct drm_connector_state *amdgpu_dm_connector_atomic_duplicate_state(
        return NULL;
 }
 
-
-/**
- * amdgpu_dm_atomic_get_property - fetch connector property value
- * @connector: connector to fetch property for
- * @state: state containing the property value
- * @property: property to look up
- * @val: pointer to write property value into
- *
- * The DRM core does not store shadow copies of properties for
- * atomic-capable drivers.  This entrypoint is used to fetch
- * the current value of a driver-specific connector property.
- */
-int amdgpu_dm_connector_atomic_get_property(struct drm_connector *connector,
-                                                         const struct drm_connector_state *state,
-                                                         struct drm_property *property,
-                                                         uint64_t *val)
-{
-       int i;
-
-       /*
-        * TODO: Get properties from atomic state or objs.  Until it's ready,
-        * continue to look up all property values in the DRM's shadow copy
-        * in obj->properties->values[].
-        *
-        * When the crtc/connector state work matures, this function should
-        * be updated to read the values out of the state structure instead.
-        */
-       for (i = 0; i < connector->base.properties->count; i++) {
-               if (connector->base.properties->properties[i] == property) {
-                       *val = connector->base.properties->values[i];
-                       return 0;
-               }
-       }
-
-       return -EINVAL;
-}
-
 static const struct drm_connector_funcs amdgpu_dm_connector_funcs = {
        .reset = amdgpu_dm_connector_funcs_reset,
        .detect = amdgpu_dm_connector_detect,
@@ -1291,7 +1296,7 @@ static const struct drm_connector_funcs amdgpu_dm_connector_funcs = {
        .atomic_duplicate_state = amdgpu_dm_connector_atomic_duplicate_state,
        .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
        .atomic_set_property = amdgpu_dm_connector_atomic_set_property,
-       .atomic_get_property = amdgpu_dm_connector_atomic_get_property,
+       .atomic_get_property = amdgpu_dm_connector_atomic_get_property
 };
 
 static struct drm_encoder *best_encoder(struct drm_connector *connector)
index ab6d51dbbf4bb913c4ef0dcd157aaed90d8c02be..b69c86826b1ad554002d4d4a77c7914cbfd6bb77 100644 (file)
@@ -71,6 +71,12 @@ int amdgpu_dm_connector_atomic_set_property(
        struct drm_property *property,
        uint64_t val);
 
+int amdgpu_dm_connector_atomic_get_property(
+       struct drm_connector *connector,
+       const struct drm_connector_state *state,
+       struct drm_property *property,
+       uint64_t *val);
+
 int amdgpu_dm_get_encoder_crtc_mask(struct amdgpu_device *adev);
 
 void amdgpu_dm_connector_init_helper(