aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaulo Zanoni2012-05-15 16:38:28 -0500
committerRob Clark2012-06-08 09:27:20 -0500
commit8c75703df0fdf65b3851f8eb5822705638decff3 (patch)
treef546773f66a8ca7d723c318c46f81b0b08d19d8c /xf86drmMode.c
parent247521a8909f4ca889a4bc09755cda9ff200061d (diff)
downloadexternal-libdrm-8c75703df0fdf65b3851f8eb5822705638decff3.tar.gz
external-libdrm-8c75703df0fdf65b3851f8eb5822705638decff3.tar.xz
external-libdrm-8c75703df0fdf65b3851f8eb5822705638decff3.zip
Add support for generic object properties IOCTLs
New library calls: - drmModeObjectGetProperties - drmModeFreeObjectProperties - drmModeObjectSetProperties Reviewed-by: Eugeni Dodonov <eugeni.dodonov@intel.com> Reviewed-by: Rob Clark <rob@ti.com> Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Diffstat (limited to 'xf86drmMode.c')
-rw-r--r--xf86drmMode.c83
1 files changed, 83 insertions, 0 deletions
diff --git a/xf86drmMode.c b/xf86drmMode.c
index c809c44a..a60c7cb1 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -974,3 +974,86 @@ void drmModeFreePlaneResources(drmModePlaneResPtr ptr)
974 drmFree(ptr->planes); 974 drmFree(ptr->planes);
975 drmFree(ptr); 975 drmFree(ptr);
976} 976}
977
978drmModeObjectPropertiesPtr drmModeObjectGetProperties(int fd,
979 uint32_t object_id,
980 uint32_t object_type)
981{
982 struct drm_mode_obj_get_properties properties;
983 drmModeObjectPropertiesPtr ret = NULL;
984 uint32_t count;
985
986retry:
987 memset(&properties, 0, sizeof(struct drm_mode_obj_get_properties));
988 properties.obj_id = object_id;
989 properties.obj_type = object_type;
990
991 if (drmIoctl(fd, DRM_IOCTL_MODE_OBJ_GETPROPERTIES, &properties))
992 return 0;
993
994 count = properties.count_props;
995
996 if (count) {
997 properties.props_ptr = VOID2U64(drmMalloc(count *
998 sizeof(uint32_t)));
999 if (!properties.props_ptr)
1000 goto err_allocs;
1001 properties.prop_values_ptr = VOID2U64(drmMalloc(count *
1002 sizeof(uint64_t)));
1003 if (!properties.prop_values_ptr)
1004 goto err_allocs;
1005 }
1006
1007 if (drmIoctl(fd, DRM_IOCTL_MODE_OBJ_GETPROPERTIES, &properties))
1008 goto err_allocs;
1009
1010 if (count < properties.count_props) {
1011 drmFree(U642VOID(properties.props_ptr));
1012 drmFree(U642VOID(properties.prop_values_ptr));
1013 goto retry;
1014 }
1015 count = properties.count_props;
1016
1017 ret = drmMalloc(sizeof(*ret));
1018 if (!ret)
1019 goto err_allocs;
1020
1021 ret->count_props = count;
1022 ret->props = drmAllocCpy(U642VOID(properties.props_ptr),
1023 count, sizeof(uint32_t));
1024 ret->prop_values = drmAllocCpy(U642VOID(properties.prop_values_ptr),
1025 count, sizeof(uint64_t));
1026 if (ret->count_props && (!ret->props || !ret->prop_values)) {
1027 drmFree(ret->props);
1028 drmFree(ret->prop_values);
1029 drmFree(ret);
1030 ret = NULL;
1031 }
1032
1033err_allocs:
1034 drmFree(U642VOID(properties.props_ptr));
1035 drmFree(U642VOID(properties.prop_values_ptr));
1036 return ret;
1037}
1038
1039void drmModeFreeObjectProperties(drmModeObjectPropertiesPtr ptr)
1040{
1041 if (!ptr)
1042 return;
1043 drmFree(ptr->props);
1044 drmFree(ptr->prop_values);
1045 drmFree(ptr);
1046}
1047
1048int drmModeObjectSetProperty(int fd, uint32_t object_id, uint32_t object_type,
1049 uint32_t property_id, uint64_t value)
1050{
1051 struct drm_mode_obj_set_property prop;
1052
1053 prop.value = value;
1054 prop.prop_id = property_id;
1055 prop.obj_id = object_id;
1056 prop.obj_type = object_type;
1057
1058 return DRM_IOCTL(fd, DRM_IOCTL_MODE_OBJ_SETPROPERTY, &prop);
1059}