* [PATCH libdrm 0/8] Latest properties patches
@ 2012-06-05 18:06 Rob Clark
2012-06-05 18:06 ` [PATCH libdrm 1/8] Add support for generic object properties IOCTLs Rob Clark
` (7 more replies)
0 siblings, 8 replies; 12+ messages in thread
From: Rob Clark @ 2012-06-05 18:06 UTC (permalink / raw)
To: dri-devel; +Cc: Rob Clark, Paulo Zanoni, patches
From: Rob Clark <rob@ti.com>
The first 6 patches are a re-send of what has already been sent by
Paulo and myself, and the last two add bitmask and plane properties
support to proptest as suggested by Paulo.
I can push these to libdrm git tree if ok.
Paulo Zanoni (3):
Add support for generic object properties IOCTLs
modetest: print CRTC properties
tests: add proptest
Rob Clark (5):
Add support for bitmask properties
modetest: support bitmask properties
modetest: support plane properties
proptest: support bitmask properties
proptest: support plane properties
configure.ac | 1 +
include/drm/drm.h | 2 +
include/drm/drm_mode.h | 25 ++++
tests/Makefile.am | 2 +-
tests/modetest/modetest.c | 37 +++++
tests/proptest/Makefile.am | 11 ++
tests/proptest/proptest.c | 357 ++++++++++++++++++++++++++++++++++++++++++++
xf86drmMode.c | 87 ++++++++++-
xf86drmMode.h | 14 ++
9 files changed, 533 insertions(+), 3 deletions(-)
create mode 100644 tests/proptest/Makefile.am
create mode 100644 tests/proptest/proptest.c
--
1.7.9.5
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH libdrm 1/8] Add support for generic object properties IOCTLs
2012-06-05 18:06 [PATCH libdrm 0/8] Latest properties patches Rob Clark
@ 2012-06-05 18:06 ` Rob Clark
2012-06-05 18:06 ` [PATCH libdrm 2/8] modetest: print CRTC properties Rob Clark
` (6 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Rob Clark @ 2012-06-05 18:06 UTC (permalink / raw)
To: dri-devel; +Cc: Paulo Zanoni, patches
From: Paulo Zanoni <paulo.r.zanoni@intel.com>
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>
---
include/drm/drm.h | 2 ++
include/drm/drm_mode.h | 24 ++++++++++++++
xf86drmMode.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++
xf86drmMode.h | 14 ++++++++
4 files changed, 123 insertions(+)
diff --git a/include/drm/drm.h b/include/drm/drm.h
index 753d2fc..5e6cd29 100644
--- a/include/drm/drm.h
+++ b/include/drm/drm.h
@@ -731,6 +731,8 @@ struct drm_prime_handle {
#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_OBJ_GETPROPERTIES DRM_IOWR(0xB9, struct drm_mode_obj_get_properties)
+#define DRM_IOCTL_MODE_OBJ_SETPROPERTY DRM_IOWR(0xBA, struct drm_mode_obj_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 f36c61a..f303d94 100644
--- a/include/drm/drm_mode.h
+++ b/include/drm/drm_mode.h
@@ -250,6 +250,30 @@ struct drm_mode_connector_set_property {
__u32 connector_id;
};
+#define DRM_MODE_OBJECT_CRTC 0xcccccccc
+#define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0
+#define DRM_MODE_OBJECT_ENCODER 0xe0e0e0e0
+#define DRM_MODE_OBJECT_MODE 0xdededede
+#define DRM_MODE_OBJECT_PROPERTY 0xb0b0b0b0
+#define DRM_MODE_OBJECT_FB 0xfbfbfbfb
+#define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb
+#define DRM_MODE_OBJECT_PLANE 0xeeeeeeee
+
+struct drm_mode_obj_get_properties {
+ __u64 props_ptr;
+ __u64 prop_values_ptr;
+ __u32 count_props;
+ __u32 obj_id;
+ __u32 obj_type;
+};
+
+struct drm_mode_obj_set_property {
+ __u64 value;
+ __u32 prop_id;
+ __u32 obj_id;
+ __u32 obj_type;
+};
+
struct drm_mode_get_blob {
__u32 blob_id;
__u32 length;
diff --git a/xf86drmMode.c b/xf86drmMode.c
index c809c44..a60c7cb 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -974,3 +974,86 @@ void drmModeFreePlaneResources(drmModePlaneResPtr ptr)
drmFree(ptr->planes);
drmFree(ptr);
}
+
+drmModeObjectPropertiesPtr drmModeObjectGetProperties(int fd,
+ uint32_t object_id,
+ uint32_t object_type)
+{
+ struct drm_mode_obj_get_properties properties;
+ drmModeObjectPropertiesPtr ret = NULL;
+ uint32_t count;
+
+retry:
+ memset(&properties, 0, sizeof(struct drm_mode_obj_get_properties));
+ properties.obj_id = object_id;
+ properties.obj_type = object_type;
+
+ if (drmIoctl(fd, DRM_IOCTL_MODE_OBJ_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_OBJ_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 drmModeFreeObjectProperties(drmModeObjectPropertiesPtr ptr)
+{
+ if (!ptr)
+ return;
+ drmFree(ptr->props);
+ drmFree(ptr->prop_values);
+ drmFree(ptr);
+}
+
+int drmModeObjectSetProperty(int fd, uint32_t object_id, uint32_t object_type,
+ uint32_t property_id, uint64_t value)
+{
+ struct drm_mode_obj_set_property prop;
+
+ prop.value = value;
+ prop.prop_id = property_id;
+ prop.obj_id = object_id;
+ prop.obj_type = object_type;
+
+ return DRM_IOCTL(fd, DRM_IOCTL_MODE_OBJ_SETPROPERTY, &prop);
+}
diff --git a/xf86drmMode.h b/xf86drmMode.h
index 991e3f9..8e40034 100644
--- a/xf86drmMode.h
+++ b/xf86drmMode.h
@@ -281,6 +281,12 @@ typedef struct _drmModeConnector {
uint32_t *encoders; /**< List of encoder ids */
} drmModeConnector, *drmModeConnectorPtr;
+typedef struct _drmModeObjectProperties {
+ uint32_t count_props;
+ uint32_t *props;
+ uint64_t *prop_values;
+} drmModeObjectProperties, *drmModeObjectPropertiesPtr;
+
typedef struct _drmModePlane {
uint32_t count_formats;
uint32_t *formats;
@@ -428,6 +434,14 @@ 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 drmModeObjectPropertiesPtr drmModeObjectGetProperties(int fd,
+ uint32_t object_id,
+ uint32_t object_type);
+extern void drmModeFreeObjectProperties(drmModeObjectPropertiesPtr ptr);
+extern int drmModeObjectSetProperty(int fd, uint32_t object_id,
+ uint32_t object_type, uint32_t property_id,
+ uint64_t value);
+
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
--
1.7.9.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH libdrm 2/8] modetest: print CRTC properties
2012-06-05 18:06 [PATCH libdrm 0/8] Latest properties patches Rob Clark
2012-06-05 18:06 ` [PATCH libdrm 1/8] Add support for generic object properties IOCTLs Rob Clark
@ 2012-06-05 18:06 ` Rob Clark
2012-06-05 18:06 ` [PATCH libdrm 3/8] tests: add proptest Rob Clark
` (5 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Rob Clark @ 2012-06-05 18:06 UTC (permalink / raw)
To: dri-devel; +Cc: Paulo Zanoni, patches
From: Paulo Zanoni <paulo.r.zanoni@intel.com>
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>
---
tests/modetest/modetest.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index 8012ecc..ce57e65 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -295,7 +295,9 @@ void dump_connectors(void)
void dump_crtcs(void)
{
drmModeCrtc *crtc;
+ drmModeObjectPropertiesPtr props;
int i;
+ uint32_t j;
printf("CRTCs:\n");
printf("id\tfb\tpos\tsize\n");
@@ -314,6 +316,19 @@ void dump_crtcs(void)
crtc->width, crtc->height);
dump_mode(&crtc->mode);
+ printf(" props:\n");
+ props = drmModeObjectGetProperties(fd, crtc->crtc_id,
+ DRM_MODE_OBJECT_CRTC);
+ if (props) {
+ for (j = 0; j < props->count_props; j++)
+ dump_prop(props->props[j],
+ props->prop_values[j]);
+ drmModeFreeObjectProperties(props);
+ } else {
+ printf("\tcould not get crtc properties: %s\n",
+ strerror(errno));
+ }
+
drmModeFreeCrtc(crtc);
}
printf("\n");
--
1.7.9.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH libdrm 3/8] tests: add proptest
2012-06-05 18:06 [PATCH libdrm 0/8] Latest properties patches Rob Clark
2012-06-05 18:06 ` [PATCH libdrm 1/8] Add support for generic object properties IOCTLs Rob Clark
2012-06-05 18:06 ` [PATCH libdrm 2/8] modetest: print CRTC properties Rob Clark
@ 2012-06-05 18:06 ` Rob Clark
2012-06-07 5:03 ` Joonyoung Shim
2012-06-05 18:06 ` [PATCH libdrm 4/8] Add support for bitmask properties Rob Clark
` (4 subsequent siblings)
7 siblings, 1 reply; 12+ messages in thread
From: Rob Clark @ 2012-06-05 18:06 UTC (permalink / raw)
To: dri-devel; +Cc: Paulo Zanoni, patches
From: Paulo Zanoni <paulo.r.zanoni@intel.com>
A small program that allows us to see and modify properties.
Reviewed-by: Rob Clark <rob@ti.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
---
configure.ac | 1 +
tests/Makefile.am | 2 +-
tests/proptest/Makefile.am | 11 ++
tests/proptest/proptest.c | 317 ++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 330 insertions(+), 1 deletion(-)
create mode 100644 tests/proptest/Makefile.am
create mode 100644 tests/proptest/proptest.c
diff --git a/configure.ac b/configure.ac
index e6e9a9f..73558ce 100644
--- a/configure.ac
+++ b/configure.ac
@@ -329,6 +329,7 @@ AC_CONFIG_FILES([
tests/modeprint/Makefile
tests/modetest/Makefile
tests/kmstest/Makefile
+ tests/proptest/Makefile
tests/radeon/Makefile
tests/vbltest/Makefile
include/Makefile
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a3a59bd..1442854 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -10,7 +10,7 @@ check_PROGRAMS = \
dristat \
drmstat
-SUBDIRS = modeprint
+SUBDIRS = modeprint proptest
if HAVE_LIBKMS
SUBDIRS += kmstest modetest
diff --git a/tests/proptest/Makefile.am b/tests/proptest/Makefile.am
new file mode 100644
index 0000000..f81a3c0
--- /dev/null
+++ b/tests/proptest/Makefile.am
@@ -0,0 +1,11 @@
+AM_CFLAGS = \
+ -I$(top_srcdir)/include/drm \
+ -I$(top_srcdir)
+
+noinst_PROGRAMS = \
+ proptest
+
+proptest_SOURCES = \
+ proptest.c
+proptest_LDADD = \
+ $(top_builddir)/libdrm.la
diff --git a/tests/proptest/proptest.c b/tests/proptest/proptest.c
new file mode 100644
index 0000000..52896fe
--- /dev/null
+++ b/tests/proptest/proptest.c
@@ -0,0 +1,317 @@
+/*
+ * Copyright (c) 2012 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ * Paulo Zanoni <paulo.r.zanoni@intel.com>
+ *
+ */
+
+#include <assert.h>
+#include <errno.h>
+#include <inttypes.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "xf86drm.h"
+#include "xf86drmMode.h"
+
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+
+int fd;
+drmModeResPtr res = NULL;
+
+const char *connector_type_str(uint32_t type)
+{
+ switch (type) {
+ case DRM_MODE_CONNECTOR_Unknown:
+ return "Unknown";
+ case DRM_MODE_CONNECTOR_VGA:
+ return "VGA";
+ case DRM_MODE_CONNECTOR_DVII:
+ return "DVI-I";
+ case DRM_MODE_CONNECTOR_DVID:
+ return "DVI-D";
+ case DRM_MODE_CONNECTOR_DVIA:
+ return "DVI-A";
+ case DRM_MODE_CONNECTOR_Composite:
+ return "Composite";
+ case DRM_MODE_CONNECTOR_SVIDEO:
+ return "SVIDEO";
+ case DRM_MODE_CONNECTOR_LVDS:
+ return "LVDS";
+ case DRM_MODE_CONNECTOR_Component:
+ return "Component";
+ case DRM_MODE_CONNECTOR_9PinDIN:
+ return "9PinDin";
+ case DRM_MODE_CONNECTOR_DisplayPort:
+ return "DisplayPort";
+ case DRM_MODE_CONNECTOR_HDMIA:
+ return "HDMI-A";
+ case DRM_MODE_CONNECTOR_HDMIB:
+ return "HDMI-B";
+ case DRM_MODE_CONNECTOR_TV:
+ return "TV";
+ case DRM_MODE_CONNECTOR_eDP:
+ return "eDP";
+ default:
+ return "Invalid";
+ }
+}
+
+/* dump_blob and dump_prop shamelessly copied from ../modetest/modetest.c */
+static void
+dump_blob(uint32_t blob_id)
+{
+ uint32_t i;
+ unsigned char *blob_data;
+ drmModePropertyBlobPtr blob;
+
+ blob = drmModeGetPropertyBlob(fd, blob_id);
+ if (!blob)
+ return;
+
+ blob_data = blob->data;
+
+ for (i = 0; i < blob->length; i++) {
+ if (i % 16 == 0)
+ printf("\n\t\t\t");
+ printf("%.2hhx", blob_data[i]);
+ }
+ printf("\n");
+
+ drmModeFreePropertyBlob(blob);
+}
+
+static void
+dump_prop(uint32_t prop_id, uint64_t value)
+{
+ int i;
+ drmModePropertyPtr prop;
+
+ prop = drmModeGetProperty(fd, prop_id);
+
+ printf("\t%d", prop_id);
+ if (!prop) {
+ printf("\n");
+ return;
+ }
+
+ printf(" %s:\n", prop->name);
+
+ printf("\t\tflags:");
+ if (prop->flags & DRM_MODE_PROP_PENDING)
+ printf(" pending");
+ if (prop->flags & DRM_MODE_PROP_RANGE)
+ printf(" range");
+ if (prop->flags & DRM_MODE_PROP_IMMUTABLE)
+ printf(" immutable");
+ if (prop->flags & DRM_MODE_PROP_ENUM)
+ printf(" enum");
+ if (prop->flags & DRM_MODE_PROP_BLOB)
+ printf(" blob");
+ printf("\n");
+
+ if (prop->flags & DRM_MODE_PROP_RANGE) {
+ printf("\t\tvalues:");
+ for (i = 0; i < prop->count_values; i++)
+ printf(" %"PRIu64, prop->values[i]);
+ printf("\n");
+ }
+
+ if (prop->flags & DRM_MODE_PROP_ENUM) {
+ printf("\t\tenums:");
+ for (i = 0; i < prop->count_enums; i++)
+ printf(" %s=%llu", prop->enums[i].name,
+ prop->enums[i].value);
+ printf("\n");
+ } else {
+ assert(prop->count_enums == 0);
+ }
+
+ if (prop->flags & DRM_MODE_PROP_BLOB) {
+ printf("\t\tblobs:\n");
+ for (i = 0; i < prop->count_blobs; i++)
+ dump_blob(prop->blob_ids[i]);
+ printf("\n");
+ } else {
+ assert(prop->count_blobs == 0);
+ }
+
+ printf("\t\tvalue:");
+ if (prop->flags & DRM_MODE_PROP_BLOB)
+ dump_blob(value);
+ else
+ printf(" %"PRIu64"\n", value);
+
+ drmModeFreeProperty(prop);
+}
+
+static void listObjectProperties(uint32_t id, uint32_t type)
+{
+ unsigned int i;
+ drmModeObjectPropertiesPtr props;
+
+ props = drmModeObjectGetProperties(fd, id, type);
+
+ if (!props) {
+ printf("\tNo properties: %s.\n", strerror(errno));
+ return;
+ }
+
+ for (i = 0; i < props->count_props; i++)
+ dump_prop(props->props[i], props->prop_values[i]);
+
+ drmModeFreeObjectProperties(props);
+}
+
+static void listConnectorProperties(void)
+{
+ int i;
+ drmModeConnectorPtr c;
+
+ for (i = 0; i < res->count_connectors; i++) {
+ c = drmModeGetConnector(fd, res->connectors[i]);
+
+ if (!c) {
+ fprintf(stderr, "Could not get connector %u: %s\n",
+ res->connectors[i], strerror(errno));
+ continue;
+ }
+
+ printf("Connector %u (%s-%u)\n", c->connector_id,
+ connector_type_str(c->connector_type),
+ c->connector_type_id);
+
+ listObjectProperties(c->connector_id,
+ DRM_MODE_OBJECT_CONNECTOR);
+
+ drmModeFreeConnector(c);
+ }
+}
+
+static void listCrtcProperties(void)
+{
+ int i;
+ drmModeCrtcPtr c;
+
+ for (i = 0; i < res->count_crtcs; i++) {
+ c = drmModeGetCrtc(fd, res->crtcs[i]);
+
+ if (!c) {
+ fprintf(stderr, "Could not get crtc %u: %s\n",
+ res->crtcs[i], strerror(errno));
+ continue;
+ }
+
+ printf("CRTC %u\n", c->crtc_id);
+
+ listObjectProperties(c->crtc_id, DRM_MODE_OBJECT_CRTC);
+
+ drmModeFreeCrtc(c);
+ }
+}
+
+static void listAllProperties(void)
+{
+ listConnectorProperties();
+ listCrtcProperties();
+}
+
+static int setProperty(char *argv[])
+{
+ uint32_t obj_id, obj_type, prop_id;
+ uint64_t value;
+
+ obj_id = atoi(argv[1]);
+
+ if (!strcmp(argv[2], "connector")) {
+ obj_type = DRM_MODE_OBJECT_CONNECTOR;
+ } else if (!strcmp(argv[2], "crtc")) {
+ obj_type = DRM_MODE_OBJECT_CRTC;
+ } else {
+ fprintf(stderr, "Invalid object type.\n");
+ return 1;
+ }
+
+ prop_id = atoi(argv[3]);
+ value = atoll(argv[4]);
+
+ return drmModeObjectSetProperty(fd, obj_id, obj_type, prop_id, value);
+}
+
+static void printUsage(void)
+{
+ printf("Usage:\n"
+" proptest\n"
+" proptest [obj id] [obj type] [prop id] [value]\n"
+"\n"
+"The first form just prints all the existing properties. The second one is\n"
+"used to set the value of a specified property. The object type can be one of\n"
+"the following strings:\n"
+" connector crtc\n"
+"\n"
+"Example:\n"
+" proptest 7 connector 2 1\n"
+"will set property 2 of connector 7 to 1\n");
+}
+
+int main(int argc, char *argv[])
+{
+ char *modules[] = { "i915", "radeon", "nouveau", "vmwgfx", "omapdrm" };
+ unsigned int i, ret = 0;
+
+ for (i = 0; i < ARRAY_SIZE(modules); i++){
+ fd = drmOpen(modules[i], NULL);
+ if (fd >= 0) {
+ printf("Module %s loaded.\n", modules[i]);
+ break;
+ }
+ }
+
+ if (i == ARRAY_SIZE(modules)) {
+ fprintf(stderr, "Failed to load drm modules.\n");
+ return 1;
+ }
+
+ res = drmModeGetResources(fd);
+ if (!res) {
+ fprintf(stderr, "Failed to get resources: %s\n",
+ strerror(errno));
+ ret = 1;
+ goto done;
+ }
+
+ if (argc < 2) {
+ listAllProperties();
+ } else if (argc == 5) {
+ ret = setProperty(argv);
+ } else {
+ printUsage();
+ ret = 1;
+ }
+
+ drmModeFreeResources(res);
+done:
+ drmClose(fd);
+ return ret;
+}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH libdrm 4/8] Add support for bitmask properties
2012-06-05 18:06 [PATCH libdrm 0/8] Latest properties patches Rob Clark
` (2 preceding siblings ...)
2012-06-05 18:06 ` [PATCH libdrm 3/8] tests: add proptest Rob Clark
@ 2012-06-05 18:06 ` Rob Clark
2012-06-05 18:06 ` [PATCH libdrm 5/8] modetest: support " Rob Clark
` (3 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Rob Clark @ 2012-06-05 18:06 UTC (permalink / raw)
To: dri-devel; +Cc: Rob Clark, Paulo Zanoni, patches
From: Rob Clark <rob@ti.com>
A bitmask property is similar to an enum. The enum value is a bit
position (0-63), and valid property values consist of a mask of
zero or more of (1 << enum_val[n]).
Signed-off-by: Rob Clark <rob@ti.com>
Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
---
include/drm/drm_mode.h | 1 +
xf86drmMode.c | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/include/drm/drm_mode.h b/include/drm/drm_mode.h
index f303d94..62ba997 100644
--- a/include/drm/drm_mode.h
+++ b/include/drm/drm_mode.h
@@ -226,6 +226,7 @@ struct drm_mode_get_connector {
#define DRM_MODE_PROP_IMMUTABLE (1<<2)
#define DRM_MODE_PROP_ENUM (1<<3) /* enumerated type with text strings */
#define DRM_MODE_PROP_BLOB (1<<4)
+#define DRM_MODE_PROP_BITMASK (1<<5) /* bitmask of enumerated types */
struct drm_mode_property_enum {
__u64 value;
diff --git a/xf86drmMode.c b/xf86drmMode.c
index a60c7cb..04fdf1f 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -575,7 +575,7 @@ drmModePropertyPtr drmModeGetProperty(int fd, uint32_t property_id)
if (prop.count_values)
prop.values_ptr = VOID2U64(drmMalloc(prop.count_values * sizeof(uint64_t)));
- if (prop.count_enum_blobs && (prop.flags & DRM_MODE_PROP_ENUM))
+ if (prop.count_enum_blobs && (prop.flags & (DRM_MODE_PROP_ENUM | DRM_MODE_PROP_BITMASK)))
prop.enum_blob_ptr = VOID2U64(drmMalloc(prop.count_enum_blobs * sizeof(struct drm_mode_property_enum)));
if (prop.count_enum_blobs && (prop.flags & DRM_MODE_PROP_BLOB)) {
@@ -597,7 +597,7 @@ drmModePropertyPtr drmModeGetProperty(int fd, uint32_t property_id)
r->flags = prop.flags;
if (prop.count_values)
r->values = drmAllocCpy(U642VOID(prop.values_ptr), prop.count_values, sizeof(uint64_t));
- if (prop.flags & DRM_MODE_PROP_ENUM) {
+ if (prop.flags & (DRM_MODE_PROP_ENUM | DRM_MODE_PROP_BITMASK)) {
r->count_enums = prop.count_enum_blobs;
r->enums = drmAllocCpy(U642VOID(prop.enum_blob_ptr), prop.count_enum_blobs, sizeof(struct drm_mode_property_enum));
} else if (prop.flags & DRM_MODE_PROP_BLOB) {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH libdrm 5/8] modetest: support bitmask properties
2012-06-05 18:06 [PATCH libdrm 0/8] Latest properties patches Rob Clark
` (3 preceding siblings ...)
2012-06-05 18:06 ` [PATCH libdrm 4/8] Add support for bitmask properties Rob Clark
@ 2012-06-05 18:06 ` Rob Clark
2012-06-05 18:06 ` [PATCH libdrm 6/8] modetest: support plane properties Rob Clark
` (2 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Rob Clark @ 2012-06-05 18:06 UTC (permalink / raw)
To: dri-devel; +Cc: Rob Clark, Paulo Zanoni, patches
From: Rob Clark <rob@ti.com>
Add support to display bitmask properties.
Signed-off-by: Rob Clark <rob@ti.com>
Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
---
tests/modetest/modetest.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index ce57e65..dea271a 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -207,6 +207,8 @@ dump_prop(uint32_t prop_id, uint64_t value)
printf(" immutable");
if (prop->flags & DRM_MODE_PROP_ENUM)
printf(" enum");
+ if (prop->flags & DRM_MODE_PROP_BITMASK)
+ printf(" bitmask");
if (prop->flags & DRM_MODE_PROP_BLOB)
printf(" blob");
printf("\n");
@@ -224,6 +226,12 @@ dump_prop(uint32_t prop_id, uint64_t value)
printf(" %s=%llu", prop->enums[i].name,
prop->enums[i].value);
printf("\n");
+ } else if (prop->flags & DRM_MODE_PROP_BITMASK) {
+ printf("\t\tvalues:");
+ for (i = 0; i < prop->count_enums; i++)
+ printf(" %s=0x%llx", prop->enums[i].name,
+ (1LL << prop->enums[i].value));
+ printf("\n");
} else {
assert(prop->count_enums == 0);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH libdrm 6/8] modetest: support plane properties
2012-06-05 18:06 [PATCH libdrm 0/8] Latest properties patches Rob Clark
` (4 preceding siblings ...)
2012-06-05 18:06 ` [PATCH libdrm 5/8] modetest: support " Rob Clark
@ 2012-06-05 18:06 ` Rob Clark
2012-06-05 18:06 ` [PATCH libdrm 7/8] proptest: support bitmask properties Rob Clark
2012-06-05 18:06 ` [PATCH libdrm 8/8] proptest: support plane properties Rob Clark
7 siblings, 0 replies; 12+ messages in thread
From: Rob Clark @ 2012-06-05 18:06 UTC (permalink / raw)
To: dri-devel; +Cc: Rob Clark, Paulo Zanoni, patches
From: Rob Clark <rob@ti.com>
Add support to display plane properties.
Signed-off-by: Rob Clark <rob@ti.com>
Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
---
tests/modetest/modetest.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index dea271a..dc84cf3 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -369,6 +369,7 @@ void dump_framebuffers(void)
static void dump_planes(void)
{
+ drmModeObjectPropertiesPtr props;
drmModePlaneRes *plane_resources;
drmModePlane *ovr;
unsigned int i, j;
@@ -403,6 +404,19 @@ static void dump_planes(void)
printf(" %4.4s", (char *)&ovr->formats[j]);
printf("\n");
+ printf(" props:\n");
+ props = drmModeObjectGetProperties(fd, ovr->plane_id,
+ DRM_MODE_OBJECT_PLANE);
+ if (props) {
+ for (j = 0; j < props->count_props; j++)
+ dump_prop(props->props[j],
+ props->prop_values[j]);
+ drmModeFreeObjectProperties(props);
+ } else {
+ printf("\tcould not get plane properties: %s\n",
+ strerror(errno));
+ }
+
drmModeFreePlane(ovr);
}
printf("\n");
--
1.7.9.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH libdrm 7/8] proptest: support bitmask properties
2012-06-05 18:06 [PATCH libdrm 0/8] Latest properties patches Rob Clark
` (5 preceding siblings ...)
2012-06-05 18:06 ` [PATCH libdrm 6/8] modetest: support plane properties Rob Clark
@ 2012-06-05 18:06 ` Rob Clark
2012-06-05 18:06 ` [PATCH libdrm 8/8] proptest: support plane properties Rob Clark
7 siblings, 0 replies; 12+ messages in thread
From: Rob Clark @ 2012-06-05 18:06 UTC (permalink / raw)
To: dri-devel; +Cc: Rob Clark, Paulo Zanoni, patches
From: Rob Clark <rob@ti.com>
Add support to display bitmask properties.
Signed-off-by: Rob Clark <rob@ti.com>
---
tests/proptest/proptest.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tests/proptest/proptest.c b/tests/proptest/proptest.c
index 52896fe..fa34a48 100644
--- a/tests/proptest/proptest.c
+++ b/tests/proptest/proptest.c
@@ -127,6 +127,8 @@ dump_prop(uint32_t prop_id, uint64_t value)
printf(" immutable");
if (prop->flags & DRM_MODE_PROP_ENUM)
printf(" enum");
+ if (prop->flags & DRM_MODE_PROP_BITMASK)
+ printf(" bitmask");
if (prop->flags & DRM_MODE_PROP_BLOB)
printf(" blob");
printf("\n");
@@ -144,6 +146,12 @@ dump_prop(uint32_t prop_id, uint64_t value)
printf(" %s=%llu", prop->enums[i].name,
prop->enums[i].value);
printf("\n");
+ } else if (prop->flags & DRM_MODE_PROP_BITMASK) {
+ printf("\t\tvalues:");
+ for (i = 0; i < prop->count_enums; i++)
+ printf(" %s=0x%llx", prop->enums[i].name,
+ (1LL << prop->enums[i].value));
+ printf("\n");
} else {
assert(prop->count_enums == 0);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH libdrm 8/8] proptest: support plane properties
2012-06-05 18:06 [PATCH libdrm 0/8] Latest properties patches Rob Clark
` (6 preceding siblings ...)
2012-06-05 18:06 ` [PATCH libdrm 7/8] proptest: support bitmask properties Rob Clark
@ 2012-06-05 18:06 ` Rob Clark
2012-06-07 5:09 ` Joonyoung Shim
7 siblings, 1 reply; 12+ messages in thread
From: Rob Clark @ 2012-06-05 18:06 UTC (permalink / raw)
To: dri-devel; +Cc: Rob Clark, Paulo Zanoni, patches
From: Rob Clark <rob@ti.com>
Add support to display plane properties.
Signed-off-by: Rob Clark <rob@ti.com>
---
tests/proptest/proptest.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/tests/proptest/proptest.c b/tests/proptest/proptest.c
index fa34a48..aac6b8f 100644
--- a/tests/proptest/proptest.c
+++ b/tests/proptest/proptest.c
@@ -39,6 +39,7 @@
int fd;
drmModeResPtr res = NULL;
+drmModePlaneResPtr plane_res = NULL;
const char *connector_type_str(uint32_t type)
{
@@ -239,10 +240,33 @@ static void listCrtcProperties(void)
}
}
+static void listPlaneProperties(void)
+{
+ int i;
+ drmModePlanePtr p;
+
+ for (i = 0; i < plane_res->count_planes; i++) {
+ p = drmModeGetPlane(fd, plane_res->planes[i]);
+
+ if (!p) {
+ fprintf(stderr, "Could not get plane %u: %s\n",
+ plane_res->planes[i], strerror(errno));
+ continue;
+ }
+
+ printf("Plane %u\n", p->plane_id);
+
+ listObjectProperties(p->plane_id, DRM_MODE_OBJECT_PLANE);
+
+ drmModeFreePlane(p);
+ }
+}
+
static void listAllProperties(void)
{
listConnectorProperties();
listCrtcProperties();
+ listPlaneProperties();
}
static int setProperty(char *argv[])
@@ -309,6 +333,14 @@ int main(int argc, char *argv[])
goto done;
}
+ plane_res = drmModeGetPlaneResources(fd);
+ if (!plane_res) {
+ fprintf(stderr, "Failed to get plane resources: %s\n",
+ strerror(errno));
+ ret = 1;
+ goto done;
+ }
+
if (argc < 2) {
listAllProperties();
} else if (argc == 5) {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH libdrm 3/8] tests: add proptest
2012-06-05 18:06 ` [PATCH libdrm 3/8] tests: add proptest Rob Clark
@ 2012-06-07 5:03 ` Joonyoung Shim
0 siblings, 0 replies; 12+ messages in thread
From: Joonyoung Shim @ 2012-06-07 5:03 UTC (permalink / raw)
To: Rob Clark; +Cc: Paulo Zanoni, dri-devel, patches
Hi, Rob and Paulo.
On 06/06/2012 03:06 AM, Rob Clark wrote:
> From: Paulo Zanoni<paulo.r.zanoni@intel.com>
>
> A small program that allows us to see and modify properties.
>
> Reviewed-by: Rob Clark<rob@ti.com>
> Signed-off-by: Paulo Zanoni<paulo.r.zanoni@intel.com>
> ---
> configure.ac | 1 +
> tests/Makefile.am | 2 +-
> tests/proptest/Makefile.am | 11 ++
> tests/proptest/proptest.c | 317 ++++++++++++++++++++++++++++++++++++++++++++
> 4 files changed, 330 insertions(+), 1 deletion(-)
> create mode 100644 tests/proptest/Makefile.am
> create mode 100644 tests/proptest/proptest.c
>
> diff --git a/configure.ac b/configure.ac
> index e6e9a9f..73558ce 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -329,6 +329,7 @@ AC_CONFIG_FILES([
> tests/modeprint/Makefile
> tests/modetest/Makefile
> tests/kmstest/Makefile
> + tests/proptest/Makefile
> tests/radeon/Makefile
> tests/vbltest/Makefile
> include/Makefile
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index a3a59bd..1442854 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -10,7 +10,7 @@ check_PROGRAMS = \
> dristat \
> drmstat
>
> -SUBDIRS = modeprint
> +SUBDIRS = modeprint proptest
>
> if HAVE_LIBKMS
> SUBDIRS += kmstest modetest
> diff --git a/tests/proptest/Makefile.am b/tests/proptest/Makefile.am
> new file mode 100644
> index 0000000..f81a3c0
> --- /dev/null
> +++ b/tests/proptest/Makefile.am
> @@ -0,0 +1,11 @@
> +AM_CFLAGS = \
> + -I$(top_srcdir)/include/drm \
> + -I$(top_srcdir)
> +
> +noinst_PROGRAMS = \
> + proptest
> +
> +proptest_SOURCES = \
> + proptest.c
> +proptest_LDADD = \
> + $(top_builddir)/libdrm.la
> diff --git a/tests/proptest/proptest.c b/tests/proptest/proptest.c
> new file mode 100644
> index 0000000..52896fe
> --- /dev/null
> +++ b/tests/proptest/proptest.c
> @@ -0,0 +1,317 @@
> +/*
> + * Copyright (c) 2012 Intel Corporation
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> + * IN THE SOFTWARE.
> + *
> + * Authors:
> + * Paulo Zanoni<paulo.r.zanoni@intel.com>
> + *
> + */
> +
> +#include<assert.h>
> +#include<errno.h>
> +#include<inttypes.h>
> +#include<stdlib.h>
> +#include<stdio.h>
> +#include<string.h>
> +
> +#include "xf86drm.h"
> +#include "xf86drmMode.h"
> +
> +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
> +
> +int fd;
> +drmModeResPtr res = NULL;
> +
> +const char *connector_type_str(uint32_t type)
> +{
> + switch (type) {
> + case DRM_MODE_CONNECTOR_Unknown:
> + return "Unknown";
> + case DRM_MODE_CONNECTOR_VGA:
> + return "VGA";
> + case DRM_MODE_CONNECTOR_DVII:
> + return "DVI-I";
> + case DRM_MODE_CONNECTOR_DVID:
> + return "DVI-D";
> + case DRM_MODE_CONNECTOR_DVIA:
> + return "DVI-A";
> + case DRM_MODE_CONNECTOR_Composite:
> + return "Composite";
> + case DRM_MODE_CONNECTOR_SVIDEO:
> + return "SVIDEO";
> + case DRM_MODE_CONNECTOR_LVDS:
> + return "LVDS";
> + case DRM_MODE_CONNECTOR_Component:
> + return "Component";
> + case DRM_MODE_CONNECTOR_9PinDIN:
> + return "9PinDin";
> + case DRM_MODE_CONNECTOR_DisplayPort:
> + return "DisplayPort";
> + case DRM_MODE_CONNECTOR_HDMIA:
> + return "HDMI-A";
> + case DRM_MODE_CONNECTOR_HDMIB:
> + return "HDMI-B";
> + case DRM_MODE_CONNECTOR_TV:
> + return "TV";
> + case DRM_MODE_CONNECTOR_eDP:
> + return "eDP";
> + default:
> + return "Invalid";
> + }
> +}
> +
> +/* dump_blob and dump_prop shamelessly copied from ../modetest/modetest.c */
> +static void
> +dump_blob(uint32_t blob_id)
> +{
> + uint32_t i;
> + unsigned char *blob_data;
> + drmModePropertyBlobPtr blob;
> +
> + blob = drmModeGetPropertyBlob(fd, blob_id);
> + if (!blob)
> + return;
> +
> + blob_data = blob->data;
> +
> + for (i = 0; i< blob->length; i++) {
> + if (i % 16 == 0)
> + printf("\n\t\t\t");
> + printf("%.2hhx", blob_data[i]);
> + }
> + printf("\n");
> +
> + drmModeFreePropertyBlob(blob);
> +}
> +
> +static void
> +dump_prop(uint32_t prop_id, uint64_t value)
> +{
> + int i;
> + drmModePropertyPtr prop;
> +
> + prop = drmModeGetProperty(fd, prop_id);
> +
> + printf("\t%d", prop_id);
> + if (!prop) {
> + printf("\n");
> + return;
> + }
> +
> + printf(" %s:\n", prop->name);
> +
> + printf("\t\tflags:");
> + if (prop->flags& DRM_MODE_PROP_PENDING)
> + printf(" pending");
> + if (prop->flags& DRM_MODE_PROP_RANGE)
> + printf(" range");
> + if (prop->flags& DRM_MODE_PROP_IMMUTABLE)
> + printf(" immutable");
> + if (prop->flags& DRM_MODE_PROP_ENUM)
> + printf(" enum");
> + if (prop->flags& DRM_MODE_PROP_BLOB)
> + printf(" blob");
> + printf("\n");
> +
> + if (prop->flags& DRM_MODE_PROP_RANGE) {
> + printf("\t\tvalues:");
> + for (i = 0; i< prop->count_values; i++)
> + printf(" %"PRIu64, prop->values[i]);
> + printf("\n");
> + }
> +
> + if (prop->flags& DRM_MODE_PROP_ENUM) {
> + printf("\t\tenums:");
> + for (i = 0; i< prop->count_enums; i++)
> + printf(" %s=%llu", prop->enums[i].name,
> + prop->enums[i].value);
> + printf("\n");
> + } else {
> + assert(prop->count_enums == 0);
> + }
> +
> + if (prop->flags& DRM_MODE_PROP_BLOB) {
> + printf("\t\tblobs:\n");
"\n" seems to be unnecessary.
> + for (i = 0; i< prop->count_blobs; i++)
> + dump_blob(prop->blob_ids[i]);
> + printf("\n");
> + } else {
> + assert(prop->count_blobs == 0);
> + }
> +
> + printf("\t\tvalue:");
> + if (prop->flags& DRM_MODE_PROP_BLOB)
> + dump_blob(value);
Here needs printf("\n");
> + else
> + printf(" %"PRIu64"\n", value);
> +
> + drmModeFreeProperty(prop);
> +}
> +
> +static void listObjectProperties(uint32_t id, uint32_t type)
> +{
> + unsigned int i;
> + drmModeObjectPropertiesPtr props;
> +
> + props = drmModeObjectGetProperties(fd, id, type);
> +
> + if (!props) {
> + printf("\tNo properties: %s.\n", strerror(errno));
> + return;
> + }
> +
> + for (i = 0; i< props->count_props; i++)
> + dump_prop(props->props[i], props->prop_values[i]);
> +
> + drmModeFreeObjectProperties(props);
> +}
> +
> +static void listConnectorProperties(void)
> +{
> + int i;
> + drmModeConnectorPtr c;
> +
> + for (i = 0; i< res->count_connectors; i++) {
> + c = drmModeGetConnector(fd, res->connectors[i]);
> +
> + if (!c) {
> + fprintf(stderr, "Could not get connector %u: %s\n",
> + res->connectors[i], strerror(errno));
> + continue;
> + }
> +
> + printf("Connector %u (%s-%u)\n", c->connector_id,
> + connector_type_str(c->connector_type),
> + c->connector_type_id);
> +
> + listObjectProperties(c->connector_id,
> + DRM_MODE_OBJECT_CONNECTOR);
> +
> + drmModeFreeConnector(c);
> + }
> +}
> +
> +static void listCrtcProperties(void)
> +{
> + int i;
> + drmModeCrtcPtr c;
> +
> + for (i = 0; i< res->count_crtcs; i++) {
> + c = drmModeGetCrtc(fd, res->crtcs[i]);
> +
> + if (!c) {
> + fprintf(stderr, "Could not get crtc %u: %s\n",
> + res->crtcs[i], strerror(errno));
> + continue;
> + }
> +
> + printf("CRTC %u\n", c->crtc_id);
> +
> + listObjectProperties(c->crtc_id, DRM_MODE_OBJECT_CRTC);
> +
> + drmModeFreeCrtc(c);
> + }
> +}
> +
> +static void listAllProperties(void)
> +{
> + listConnectorProperties();
> + listCrtcProperties();
> +}
> +
> +static int setProperty(char *argv[])
> +{
> + uint32_t obj_id, obj_type, prop_id;
> + uint64_t value;
> +
> + obj_id = atoi(argv[1]);
> +
> + if (!strcmp(argv[2], "connector")) {
> + obj_type = DRM_MODE_OBJECT_CONNECTOR;
> + } else if (!strcmp(argv[2], "crtc")) {
> + obj_type = DRM_MODE_OBJECT_CRTC;
> + } else {
> + fprintf(stderr, "Invalid object type.\n");
> + return 1;
> + }
> +
> + prop_id = atoi(argv[3]);
> + value = atoll(argv[4]);
> +
> + return drmModeObjectSetProperty(fd, obj_id, obj_type, prop_id, value);
> +}
> +
> +static void printUsage(void)
> +{
> + printf("Usage:\n"
> +" proptest\n"
> +" proptest [obj id] [obj type] [prop id] [value]\n"
> +"\n"
> +"The first form just prints all the existing properties. The second one is\n"
> +"used to set the value of a specified property. The object type can be one of\n"
> +"the following strings:\n"
> +" connector crtc\n"
> +"\n"
> +"Example:\n"
> +" proptest 7 connector 2 1\n"
> +"will set property 2 of connector 7 to 1\n");
> +}
> +
> +int main(int argc, char *argv[])
> +{
> + char *modules[] = { "i915", "radeon", "nouveau", "vmwgfx", "omapdrm" };
Please add "exynos"
> + unsigned int i, ret = 0;
> +
> + for (i = 0; i< ARRAY_SIZE(modules); i++){
> + fd = drmOpen(modules[i], NULL);
> + if (fd>= 0) {
> + printf("Module %s loaded.\n", modules[i]);
> + break;
> + }
> + }
> +
> + if (i == ARRAY_SIZE(modules)) {
> + fprintf(stderr, "Failed to load drm modules.\n");
> + return 1;
> + }
> +
> + res = drmModeGetResources(fd);
> + if (!res) {
> + fprintf(stderr, "Failed to get resources: %s\n",
> + strerror(errno));
> + ret = 1;
> + goto done;
> + }
> +
> + if (argc< 2) {
> + listAllProperties();
> + } else if (argc == 5) {
> + ret = setProperty(argv);
> + } else {
> + printUsage();
> + ret = 1;
> + }
> +
> + drmModeFreeResources(res);
> +done:
> + drmClose(fd);
> + return ret;
> +}
Thanks.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH libdrm 8/8] proptest: support plane properties
2012-06-05 18:06 ` [PATCH libdrm 8/8] proptest: support plane properties Rob Clark
@ 2012-06-07 5:09 ` Joonyoung Shim
2012-06-07 14:45 ` Rob Clark
0 siblings, 1 reply; 12+ messages in thread
From: Joonyoung Shim @ 2012-06-07 5:09 UTC (permalink / raw)
To: Rob Clark; +Cc: Rob Clark, Paulo Zanoni, dri-devel, patches
Hi, Rob.
On 06/06/2012 03:06 AM, Rob Clark wrote:
> From: Rob Clark<rob@ti.com>
>
> Add support to display plane properties.
Do you not support to set property for plane?
>
> Signed-off-by: Rob Clark<rob@ti.com>
> ---
> tests/proptest/proptest.c | 32 ++++++++++++++++++++++++++++++++
> 1 file changed, 32 insertions(+)
>
> diff --git a/tests/proptest/proptest.c b/tests/proptest/proptest.c
> index fa34a48..aac6b8f 100644
> --- a/tests/proptest/proptest.c
> +++ b/tests/proptest/proptest.c
> @@ -39,6 +39,7 @@
>
> int fd;
> drmModeResPtr res = NULL;
> +drmModePlaneResPtr plane_res = NULL;
>
> const char *connector_type_str(uint32_t type)
> {
> @@ -239,10 +240,33 @@ static void listCrtcProperties(void)
> }
> }
>
> +static void listPlaneProperties(void)
> +{
> + int i;
> + drmModePlanePtr p;
> +
> + for (i = 0; i< plane_res->count_planes; i++) {
> + p = drmModeGetPlane(fd, plane_res->planes[i]);
> +
> + if (!p) {
> + fprintf(stderr, "Could not get plane %u: %s\n",
> + plane_res->planes[i], strerror(errno));
> + continue;
> + }
> +
> + printf("Plane %u\n", p->plane_id);
> +
> + listObjectProperties(p->plane_id, DRM_MODE_OBJECT_PLANE);
> +
> + drmModeFreePlane(p);
> + }
> +}
> +
> static void listAllProperties(void)
> {
> listConnectorProperties();
> listCrtcProperties();
> + listPlaneProperties();
> }
>
> static int setProperty(char *argv[])
> @@ -309,6 +333,14 @@ int main(int argc, char *argv[])
> goto done;
> }
>
> + plane_res = drmModeGetPlaneResources(fd);
> + if (!plane_res) {
> + fprintf(stderr, "Failed to get plane resources: %s\n",
> + strerror(errno));
> + ret = 1;
> + goto done;
> + }
> +
> if (argc< 2) {
> listAllProperties();
> } else if (argc == 5) {
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH libdrm 8/8] proptest: support plane properties
2012-06-07 5:09 ` Joonyoung Shim
@ 2012-06-07 14:45 ` Rob Clark
0 siblings, 0 replies; 12+ messages in thread
From: Rob Clark @ 2012-06-07 14:45 UTC (permalink / raw)
To: Joonyoung Shim; +Cc: Paulo Zanoni, dri-devel, patches
On Thu, Jun 7, 2012 at 1:09 PM, Joonyoung Shim <jy0922.shim@samsung.com> wrote:
> Hi, Rob.
>
>
> On 06/06/2012 03:06 AM, Rob Clark wrote:
>>
>> From: Rob Clark<rob@ti.com>
>>
>> Add support to display plane properties.
>
>
> Do you not support to set property for plane?
oh, heh, I missed the fact that proptest actually lets you *set*
properties.. I won't push this particular patch until I update it to
set properties too
BR,
-R
>
>>
>> Signed-off-by: Rob Clark<rob@ti.com>
>> ---
>> tests/proptest/proptest.c | 32 ++++++++++++++++++++++++++++++++
>> 1 file changed, 32 insertions(+)
>>
>> diff --git a/tests/proptest/proptest.c b/tests/proptest/proptest.c
>> index fa34a48..aac6b8f 100644
>> --- a/tests/proptest/proptest.c
>> +++ b/tests/proptest/proptest.c
>> @@ -39,6 +39,7 @@
>>
>> int fd;
>> drmModeResPtr res = NULL;
>> +drmModePlaneResPtr plane_res = NULL;
>>
>> const char *connector_type_str(uint32_t type)
>> {
>> @@ -239,10 +240,33 @@ static void listCrtcProperties(void)
>> }
>> }
>>
>> +static void listPlaneProperties(void)
>> +{
>> + int i;
>> + drmModePlanePtr p;
>> +
>> + for (i = 0; i< plane_res->count_planes; i++) {
>> + p = drmModeGetPlane(fd, plane_res->planes[i]);
>> +
>> + if (!p) {
>> + fprintf(stderr, "Could not get plane %u: %s\n",
>> + plane_res->planes[i], strerror(errno));
>> + continue;
>> + }
>> +
>> + printf("Plane %u\n", p->plane_id);
>> +
>> + listObjectProperties(p->plane_id, DRM_MODE_OBJECT_PLANE);
>> +
>> + drmModeFreePlane(p);
>> + }
>> +}
>> +
>> static void listAllProperties(void)
>> {
>> listConnectorProperties();
>> listCrtcProperties();
>> + listPlaneProperties();
>> }
>>
>> static int setProperty(char *argv[])
>> @@ -309,6 +333,14 @@ int main(int argc, char *argv[])
>> goto done;
>> }
>>
>> + plane_res = drmModeGetPlaneResources(fd);
>> + if (!plane_res) {
>> + fprintf(stderr, "Failed to get plane resources: %s\n",
>> + strerror(errno));
>> + ret = 1;
>> + goto done;
>> + }
>> +
>> if (argc< 2) {
>> listAllProperties();
>> } else if (argc == 5) {
>
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2012-06-07 14:46 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-05 18:06 [PATCH libdrm 0/8] Latest properties patches Rob Clark
2012-06-05 18:06 ` [PATCH libdrm 1/8] Add support for generic object properties IOCTLs Rob Clark
2012-06-05 18:06 ` [PATCH libdrm 2/8] modetest: print CRTC properties Rob Clark
2012-06-05 18:06 ` [PATCH libdrm 3/8] tests: add proptest Rob Clark
2012-06-07 5:03 ` Joonyoung Shim
2012-06-05 18:06 ` [PATCH libdrm 4/8] Add support for bitmask properties Rob Clark
2012-06-05 18:06 ` [PATCH libdrm 5/8] modetest: support " Rob Clark
2012-06-05 18:06 ` [PATCH libdrm 6/8] modetest: support plane properties Rob Clark
2012-06-05 18:06 ` [PATCH libdrm 7/8] proptest: support bitmask properties Rob Clark
2012-06-05 18:06 ` [PATCH libdrm 8/8] proptest: support plane properties Rob Clark
2012-06-07 5:09 ` Joonyoung Shim
2012-06-07 14:45 ` Rob Clark
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.