Commit 7e3bdf4a authored by Paulo Zanoni's avatar Paulo Zanoni Committed by Dave Airlie

drm: create struct drm_object_properties and use it

For now, only connectors have it. In the future, all objects that need
properties should use it. Since the structure is referenced inside
struct drm_mode_object, we will be able to deal with object properties
without knowing the real type of the object.
Reviewed-by: default avatarEugeni Dodonov <eugeni.dodonov@intel.com>
Reviewed-by: default avatarRob Clark <rob.clark@linaro.org>
Tested-by: default avatarRob Clark <rob.clark@linaro.org>
Signed-off-by: default avatarPaulo Zanoni <paulo.r.zanoni@intel.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent afea2ad5
...@@ -483,6 +483,7 @@ int drm_connector_init(struct drm_device *dev, ...@@ -483,6 +483,7 @@ int drm_connector_init(struct drm_device *dev,
if (ret) if (ret)
goto out; goto out;
connector->base.properties = &connector->properties;
connector->dev = dev; connector->dev = dev;
connector->funcs = funcs; connector->funcs = funcs;
connector->connector_type = connector_type; connector->connector_type = connector_type;
...@@ -1424,8 +1425,8 @@ int drm_mode_getconnector(struct drm_device *dev, void *data, ...@@ -1424,8 +1425,8 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
} }
connector = obj_to_connector(obj); connector = obj_to_connector(obj);
for (i = 0; i < DRM_CONNECTOR_MAX_PROPERTY; i++) { for (i = 0; i < DRM_OBJECT_MAX_PROPERTY; i++) {
if (connector->property_ids[i] != 0) { if (connector->properties.ids[i] != 0) {
props_count++; props_count++;
} }
} }
...@@ -1481,15 +1482,15 @@ int drm_mode_getconnector(struct drm_device *dev, void *data, ...@@ -1481,15 +1482,15 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
copied = 0; copied = 0;
prop_ptr = (uint32_t __user *)(unsigned long)(out_resp->props_ptr); prop_ptr = (uint32_t __user *)(unsigned long)(out_resp->props_ptr);
prop_values = (uint64_t __user *)(unsigned long)(out_resp->prop_values_ptr); prop_values = (uint64_t __user *)(unsigned long)(out_resp->prop_values_ptr);
for (i = 0; i < DRM_CONNECTOR_MAX_PROPERTY; i++) { for (i = 0; i < DRM_OBJECT_MAX_PROPERTY; i++) {
if (connector->property_ids[i] != 0) { if (connector->properties.ids[i] != 0) {
if (put_user(connector->property_ids[i], if (put_user(connector->properties.ids[i],
prop_ptr + copied)) { prop_ptr + copied)) {
ret = -EFAULT; ret = -EFAULT;
goto out; goto out;
} }
if (put_user(connector->property_values[i], if (put_user(connector->properties.values[i],
prop_values + copied)) { prop_values + copied)) {
ret = -EFAULT; ret = -EFAULT;
goto out; goto out;
...@@ -2824,16 +2825,16 @@ void drm_connector_attach_property(struct drm_connector *connector, ...@@ -2824,16 +2825,16 @@ void drm_connector_attach_property(struct drm_connector *connector,
{ {
int i; int i;
for (i = 0; i < DRM_CONNECTOR_MAX_PROPERTY; i++) { for (i = 0; i < DRM_OBJECT_MAX_PROPERTY; i++) {
if (connector->property_ids[i] == 0) { if (connector->properties.ids[i] == 0) {
connector->property_ids[i] = property->base.id; connector->properties.ids[i] = property->base.id;
connector->property_values[i] = init_val; connector->properties.values[i] = init_val;
return; return;
} }
} }
WARN(1, "Failed to attach connector property. Please increase " WARN(1, "Failed to attach connector property. Please increase "
"DRM_CONNECTOR_MAX_PROPERTY by 1 for each time you see this " "DRM_OBJECT_MAX_PROPERTY by 1 for each time you see this "
"message\n"); "message\n");
} }
EXPORT_SYMBOL(drm_connector_attach_property); EXPORT_SYMBOL(drm_connector_attach_property);
...@@ -2843,14 +2844,14 @@ int drm_connector_property_set_value(struct drm_connector *connector, ...@@ -2843,14 +2844,14 @@ int drm_connector_property_set_value(struct drm_connector *connector,
{ {
int i; int i;
for (i = 0; i < DRM_CONNECTOR_MAX_PROPERTY; i++) { for (i = 0; i < DRM_OBJECT_MAX_PROPERTY; i++) {
if (connector->property_ids[i] == property->base.id) { if (connector->properties.ids[i] == property->base.id) {
connector->property_values[i] = value; connector->properties.values[i] = value;
break; break;
} }
} }
if (i == DRM_CONNECTOR_MAX_PROPERTY) if (i == DRM_OBJECT_MAX_PROPERTY)
return -EINVAL; return -EINVAL;
return 0; return 0;
} }
...@@ -2861,14 +2862,14 @@ int drm_connector_property_get_value(struct drm_connector *connector, ...@@ -2861,14 +2862,14 @@ int drm_connector_property_get_value(struct drm_connector *connector,
{ {
int i; int i;
for (i = 0; i < DRM_CONNECTOR_MAX_PROPERTY; i++) { for (i = 0; i < DRM_OBJECT_MAX_PROPERTY; i++) {
if (connector->property_ids[i] == property->base.id) { if (connector->properties.ids[i] == property->base.id) {
*val = connector->property_values[i]; *val = connector->properties.values[i];
break; break;
} }
} }
if (i == DRM_CONNECTOR_MAX_PROPERTY) if (i == DRM_OBJECT_MAX_PROPERTY)
return -EINVAL; return -EINVAL;
return 0; return 0;
} }
...@@ -3113,12 +3114,12 @@ int drm_mode_connector_property_set_ioctl(struct drm_device *dev, ...@@ -3113,12 +3114,12 @@ int drm_mode_connector_property_set_ioctl(struct drm_device *dev,
} }
connector = obj_to_connector(obj); connector = obj_to_connector(obj);
for (i = 0; i < DRM_CONNECTOR_MAX_PROPERTY; i++) { for (i = 0; i < DRM_OBJECT_MAX_PROPERTY; i++) {
if (connector->property_ids[i] == out_resp->prop_id) if (connector->properties.ids[i] == out_resp->prop_id)
break; break;
} }
if (i == DRM_CONNECTOR_MAX_PROPERTY) { if (i == DRM_OBJECT_MAX_PROPERTY) {
goto out; goto out;
} }
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
struct drm_device; struct drm_device;
struct drm_mode_set; struct drm_mode_set;
struct drm_framebuffer; struct drm_framebuffer;
struct drm_object_properties;
#define DRM_MODE_OBJECT_CRTC 0xcccccccc #define DRM_MODE_OBJECT_CRTC 0xcccccccc
...@@ -50,6 +51,13 @@ struct drm_framebuffer; ...@@ -50,6 +51,13 @@ struct drm_framebuffer;
struct drm_mode_object { struct drm_mode_object {
uint32_t id; uint32_t id;
uint32_t type; uint32_t type;
struct drm_object_properties *properties;
};
#define DRM_OBJECT_MAX_PROPERTY 16
struct drm_object_properties {
uint32_t ids[DRM_OBJECT_MAX_PROPERTY];
uint64_t values[DRM_OBJECT_MAX_PROPERTY];
}; };
/* /*
...@@ -451,7 +459,6 @@ struct drm_encoder_funcs { ...@@ -451,7 +459,6 @@ struct drm_encoder_funcs {
}; };
#define DRM_CONNECTOR_MAX_UMODES 16 #define DRM_CONNECTOR_MAX_UMODES 16
#define DRM_CONNECTOR_MAX_PROPERTY 16
#define DRM_CONNECTOR_LEN 32 #define DRM_CONNECTOR_LEN 32
#define DRM_CONNECTOR_MAX_ENCODER 3 #define DRM_CONNECTOR_MAX_ENCODER 3
...@@ -520,8 +527,7 @@ enum drm_connector_force { ...@@ -520,8 +527,7 @@ enum drm_connector_force {
* @funcs: connector control functions * @funcs: connector control functions
* @user_modes: user added mode list * @user_modes: user added mode list
* @edid_blob_ptr: DRM property containing EDID if present * @edid_blob_ptr: DRM property containing EDID if present
* @property_ids: property tracking for this connector * @properties: property tracking for this connector
* @property_values: value pointers or data for properties
* @polled: a %DRM_CONNECTOR_POLL_<foo> value for core driven polling * @polled: a %DRM_CONNECTOR_POLL_<foo> value for core driven polling
* @dpms: current dpms state * @dpms: current dpms state
* @helper_private: mid-layer private data * @helper_private: mid-layer private data
...@@ -565,8 +571,7 @@ struct drm_connector { ...@@ -565,8 +571,7 @@ struct drm_connector {
struct list_head user_modes; struct list_head user_modes;
struct drm_property_blob *edid_blob_ptr; struct drm_property_blob *edid_blob_ptr;
u32 property_ids[DRM_CONNECTOR_MAX_PROPERTY]; struct drm_object_properties properties;
uint64_t property_values[DRM_CONNECTOR_MAX_PROPERTY];
uint8_t polled; /* DRM_CONNECTOR_POLL_* */ uint8_t polled; /* DRM_CONNECTOR_POLL_* */
......
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