diff options
author | Paulo Zanoni <paulo.r.zanoni@intel.com> | 2012-05-15 17:09:03 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2012-05-17 06:11:28 -0400 |
commit | 0057d8dd8d378bf88f75736496d779f3c9454b5f (patch) | |
tree | d17d5069afebfb6116c469c4bda58cc634fb503b | |
parent | c543188afb7a83e66161c026dc6fd5eb38dc0b63 (diff) |
drm: make the connector properties code use the object properties code
In the future, we may want to kill the internal functions:
- drm_connector_attach_property
- drm_connector_property_set_value
- drm_connector_property_get_value
It seems the IOCTL drm_mode_connector_property_set_ioctl will have to live, but
we may change libdrm to not use it anymore, if we want.
Reviewed-by: Eugeni Dodonov <eugeni.dodonov@intel.com>
Reviewed-by: Rob Clark <rob.clark@linaro.org>
Tested-by: Rob Clark <rob.clark@linaro.org>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r-- | drivers/gpu/drm/drm_crtc.c | 98 |
1 files changed, 12 insertions, 86 deletions
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index b6783f914246..793f51b0f7a4 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c | |||
@@ -2823,55 +2823,21 @@ EXPORT_SYMBOL(drm_property_destroy); | |||
2823 | void drm_connector_attach_property(struct drm_connector *connector, | 2823 | void drm_connector_attach_property(struct drm_connector *connector, |
2824 | struct drm_property *property, uint64_t init_val) | 2824 | struct drm_property *property, uint64_t init_val) |
2825 | { | 2825 | { |
2826 | int i; | 2826 | drm_object_attach_property(&connector->base, property, init_val); |
2827 | |||
2828 | for (i = 0; i < DRM_OBJECT_MAX_PROPERTY; i++) { | ||
2829 | if (connector->properties.ids[i] == 0) { | ||
2830 | connector->properties.ids[i] = property->base.id; | ||
2831 | connector->properties.values[i] = init_val; | ||
2832 | return; | ||
2833 | } | ||
2834 | } | ||
2835 | |||
2836 | WARN(1, "Failed to attach connector property. Please increase " | ||
2837 | "DRM_OBJECT_MAX_PROPERTY by 1 for each time you see this " | ||
2838 | "message\n"); | ||
2839 | } | 2827 | } |
2840 | EXPORT_SYMBOL(drm_connector_attach_property); | 2828 | EXPORT_SYMBOL(drm_connector_attach_property); |
2841 | 2829 | ||
2842 | int drm_connector_property_set_value(struct drm_connector *connector, | 2830 | int drm_connector_property_set_value(struct drm_connector *connector, |
2843 | struct drm_property *property, uint64_t value) | 2831 | struct drm_property *property, uint64_t value) |
2844 | { | 2832 | { |
2845 | int i; | 2833 | return drm_object_property_set_value(&connector->base, property, value); |
2846 | |||
2847 | for (i = 0; i < DRM_OBJECT_MAX_PROPERTY; i++) { | ||
2848 | if (connector->properties.ids[i] == property->base.id) { | ||
2849 | connector->properties.values[i] = value; | ||
2850 | break; | ||
2851 | } | ||
2852 | } | ||
2853 | |||
2854 | if (i == DRM_OBJECT_MAX_PROPERTY) | ||
2855 | return -EINVAL; | ||
2856 | return 0; | ||
2857 | } | 2834 | } |
2858 | EXPORT_SYMBOL(drm_connector_property_set_value); | 2835 | EXPORT_SYMBOL(drm_connector_property_set_value); |
2859 | 2836 | ||
2860 | int drm_connector_property_get_value(struct drm_connector *connector, | 2837 | int drm_connector_property_get_value(struct drm_connector *connector, |
2861 | struct drm_property *property, uint64_t *val) | 2838 | struct drm_property *property, uint64_t *val) |
2862 | { | 2839 | { |
2863 | int i; | 2840 | return drm_object_property_get_value(&connector->base, property, val); |
2864 | |||
2865 | for (i = 0; i < DRM_OBJECT_MAX_PROPERTY; i++) { | ||
2866 | if (connector->properties.ids[i] == property->base.id) { | ||
2867 | *val = connector->properties.values[i]; | ||
2868 | break; | ||
2869 | } | ||
2870 | } | ||
2871 | |||
2872 | if (i == DRM_OBJECT_MAX_PROPERTY) | ||
2873 | return -EINVAL; | ||
2874 | return 0; | ||
2875 | } | 2841 | } |
2876 | EXPORT_SYMBOL(drm_connector_property_get_value); | 2842 | EXPORT_SYMBOL(drm_connector_property_get_value); |
2877 | 2843 | ||
@@ -3148,56 +3114,16 @@ static bool drm_property_change_is_valid(struct drm_property *property, | |||
3148 | int drm_mode_connector_property_set_ioctl(struct drm_device *dev, | 3114 | int drm_mode_connector_property_set_ioctl(struct drm_device *dev, |
3149 | void *data, struct drm_file *file_priv) | 3115 | void *data, struct drm_file *file_priv) |
3150 | { | 3116 | { |
3151 | struct drm_mode_connector_set_property *out_resp = data; | 3117 | struct drm_mode_connector_set_property *conn_set_prop = data; |
3152 | struct drm_mode_object *obj; | 3118 | struct drm_mode_obj_set_property obj_set_prop = { |
3153 | struct drm_property *property; | 3119 | .value = conn_set_prop->value, |
3154 | struct drm_connector *connector; | 3120 | .prop_id = conn_set_prop->prop_id, |
3155 | int ret = -EINVAL; | 3121 | .obj_id = conn_set_prop->connector_id, |
3156 | int i; | 3122 | .obj_type = DRM_MODE_OBJECT_CONNECTOR |
3157 | 3123 | }; | |
3158 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) | ||
3159 | return -EINVAL; | ||
3160 | |||
3161 | mutex_lock(&dev->mode_config.mutex); | ||
3162 | |||
3163 | obj = drm_mode_object_find(dev, out_resp->connector_id, DRM_MODE_OBJECT_CONNECTOR); | ||
3164 | if (!obj) { | ||
3165 | goto out; | ||
3166 | } | ||
3167 | connector = obj_to_connector(obj); | ||
3168 | |||
3169 | for (i = 0; i < DRM_OBJECT_MAX_PROPERTY; i++) { | ||
3170 | if (connector->properties.ids[i] == out_resp->prop_id) | ||
3171 | break; | ||
3172 | } | ||
3173 | |||
3174 | if (i == DRM_OBJECT_MAX_PROPERTY) { | ||
3175 | goto out; | ||
3176 | } | ||
3177 | |||
3178 | obj = drm_mode_object_find(dev, out_resp->prop_id, DRM_MODE_OBJECT_PROPERTY); | ||
3179 | if (!obj) { | ||
3180 | goto out; | ||
3181 | } | ||
3182 | property = obj_to_property(obj); | ||
3183 | 3124 | ||
3184 | if (!drm_property_change_is_valid(property, out_resp->value)) | 3125 | /* It does all the locking and checking we need */ |
3185 | goto out; | 3126 | return drm_mode_obj_set_property_ioctl(dev, &obj_set_prop, file_priv); |
3186 | |||
3187 | /* Do DPMS ourselves */ | ||
3188 | if (property == connector->dev->mode_config.dpms_property) { | ||
3189 | if (connector->funcs->dpms) | ||
3190 | (*connector->funcs->dpms)(connector, (int) out_resp->value); | ||
3191 | ret = 0; | ||
3192 | } else if (connector->funcs->set_property) | ||
3193 | ret = connector->funcs->set_property(connector, property, out_resp->value); | ||
3194 | |||
3195 | /* store the property value if successful */ | ||
3196 | if (!ret) | ||
3197 | drm_connector_property_set_value(connector, property, out_resp->value); | ||
3198 | out: | ||
3199 | mutex_unlock(&dev->mode_config.mutex); | ||
3200 | return ret; | ||
3201 | } | 3127 | } |
3202 | 3128 | ||
3203 | static int drm_mode_connector_set_obj_prop(struct drm_mode_object *obj, | 3129 | static int drm_mode_connector_set_obj_prop(struct drm_mode_object *obj, |