summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaulo Zanoni <paulo.r.zanoni@intel.com>2012-01-12 14:35:42 -0200
committerPaulo Zanoni <paulo.r.zanoni@intel.com>2012-01-12 14:35:42 -0200
commit649916cafe285f62c814a989373653344e2b85f3 (patch)
treea70228191e7f04529b23ca598071eb0e039fa1fe
parent9477cda5fa48cd82f5fa24a7ec5b0c7ff9b34ec0 (diff)
Add support for CRTC properties
New library calls: - drmModeCrtcGetProperties - drmModeFreeCrtcProperties - drmModeCrtcSetProperties Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
-rw-r--r--include/drm/drm.h2
-rw-r--r--include/drm/drm_mode.h13
-rw-r--r--xf86drmMode.c80
-rw-r--r--xf86drmMode.h12
4 files changed, 107 insertions, 0 deletions
diff --git a/include/drm/drm.h b/include/drm/drm.h
index 8adb9d59..45eef57b 100644
--- a/include/drm/drm.h
+++ b/include/drm/drm.h
@@ -717,6 +717,8 @@ struct drm_get_cap {
#define DRM_IOCTL_MODE_GETPLANE DRM_IOWR(0xB6, struct drm_mode_get_plane)
#define DRM_IOCTL_MODE_SETPLANE DRM_IOWR(0xB7, struct drm_mode_set_plane)
#define DRM_IOCTL_MODE_ADDFB2 DRM_IOWR(0xB8, struct drm_mode_fb_cmd2)
+#define DRM_IOCTL_MODE_CRTC_GETPROPERTIES DRM_IOWR(0xB9, struct drm_mode_crtc_get_properties)
+#define DRM_IOCTL_MODE_CRTC_SETPROPERTY DRM_IOWR(0xBA, struct drm_mode_crtc_set_property)
/**
* Device specific ioctls should only be in their respective headers
diff --git a/include/drm/drm_mode.h b/include/drm/drm_mode.h
index f36c61a5..2bc6b83f 100644
--- a/include/drm/drm_mode.h
+++ b/include/drm/drm_mode.h
@@ -250,6 +250,19 @@ struct drm_mode_connector_set_property {
__u32 connector_id;
};
+struct drm_mode_crtc_get_properties {
+ __u64 props_ptr;
+ __u64 prop_values_ptr;
+ __u32 count_props;
+ __u32 crtc_id;
+};
+
+struct drm_mode_crtc_set_property {
+ __u64 value;
+ __u32 prop_id;
+ __u32 crtc_id;
+};
+
struct drm_mode_get_blob {
__u32 blob_id;
__u32 length;
diff --git a/xf86drmMode.c b/xf86drmMode.c
index 712eff12..70d470cf 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -962,3 +962,83 @@ err_allocs:
return r;
}
+
+drmModeCrtcPropertiesPtr drmModeCrtcGetProperties(int fd, uint32_t crtc_id)
+{
+ struct drm_mode_crtc_get_properties properties;
+ drmModeCrtcPropertiesPtr ret = NULL;
+ uint32_t count;
+
+retry:
+ memset(&properties, 0, sizeof(struct drm_mode_crtc_get_properties));
+ properties.crtc_id = crtc_id;
+
+ if (drmIoctl(fd, DRM_IOCTL_MODE_CRTC_GETPROPERTIES, &properties))
+ return 0;
+
+ count = properties.count_props;
+
+ if (count) {
+ properties.props_ptr = VOID2U64(drmMalloc(count *
+ sizeof(uint32_t)));
+ if (!properties.props_ptr)
+ goto err_allocs;
+ properties.prop_values_ptr = VOID2U64(drmMalloc(count *
+ sizeof(uint64_t)));
+ if (!properties.prop_values_ptr)
+ goto err_allocs;
+ }
+
+ if (drmIoctl(fd, DRM_IOCTL_MODE_CRTC_GETPROPERTIES, &properties))
+ goto err_allocs;
+
+ if (count < properties.count_props) {
+ drmFree(U642VOID(properties.props_ptr));
+ drmFree(U642VOID(properties.prop_values_ptr));
+ goto retry;
+ }
+ count = properties.count_props;
+
+ ret = drmMalloc(sizeof(*ret));
+ if (!ret)
+ goto err_allocs;
+
+ ret->count_props = count;
+ ret->props = drmAllocCpy(U642VOID(properties.props_ptr),
+ count, sizeof(uint32_t));
+ ret->prop_values = drmAllocCpy(U642VOID(properties.prop_values_ptr),
+ count, sizeof(uint64_t));
+ if (ret->count_props && (!ret->props || !ret->prop_values)) {
+ drmFree(ret->props);
+ drmFree(ret->prop_values);
+ drmFree(ret);
+ ret = NULL;
+ }
+
+err_allocs:
+ drmFree(U642VOID(properties.props_ptr));
+ drmFree(U642VOID(properties.prop_values_ptr));
+ return ret;
+}
+
+void drmModeFreeCrtcProperties(drmModeCrtcPropertiesPtr ptr)
+{
+ if (!ptr)
+ return;
+ drmFree(ptr->props);
+ drmFree(ptr->prop_values);
+ drmFree(ptr);
+}
+
+int drmModeCrtcSetProperty(int fd, uint32_t crtc_id, uint32_t property_id,
+ uint64_t value)
+{
+ struct drm_mode_crtc_set_property prop;
+
+ prop.value = value;
+ prop.prop_id = property_id;
+ prop.crtc_id = crtc_id;
+
+ return DRM_IOCTL(fd, DRM_IOCTL_MODE_CRTC_SETPROPERTY, &prop);
+}
+
diff --git a/xf86drmMode.h b/xf86drmMode.h
index c0fc2efa..fbb9d15e 100644
--- a/xf86drmMode.h
+++ b/xf86drmMode.h
@@ -278,6 +278,12 @@ typedef struct _drmModeConnector {
uint32_t *encoders; /**< List of encoder ids */
} drmModeConnector, *drmModeConnectorPtr;
+typedef struct _drmModeCrtcProperties {
+ uint32_t count_props;
+ uint32_t *props;
+ uint64_t *prop_values;
+} drmModeCrtcProperties, *drmModeCrtcPropertiesPtr;
+
typedef struct _drmModePlane {
uint32_t count_formats;
uint32_t *formats;
@@ -424,6 +430,12 @@ extern int drmModeSetPlane(int fd, uint32_t plane_id, uint32_t crtc_id,
uint32_t src_x, uint32_t src_y,
uint32_t src_w, uint32_t src_h);
+extern drmModeCrtcPropertiesPtr drmModeCrtcGetProperties(int fd,
+ uint32_t crtc_id);
+extern void drmModeFreeCrtcProperties(drmModeCrtcPropertiesPtr ptr);
+extern int drmModeCrtcSetProperty(int fd, uint32_t crtc_id,
+ uint32_t property_id, uint64_t value);
+
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif