* [PATCH libdrm 1/4] modetest: fix some compiler warnings
@ 2012-04-21 20:51 Paulo Zanoni
2012-04-21 20:51 ` [PATCH libdrm 2/4] modetest: fix drmModeGetConnector memory leak Paulo Zanoni
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Paulo Zanoni @ 2012-04-21 20:51 UTC (permalink / raw)
To: dri-devel; +Cc: Paulo Zanoni
From: Paulo Zanoni <paulo.r.zanoni@intel.com>
Use unsigned int instead of int:
- modetest.c:90:1: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
- modetest.c:98:1: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
- modetest.c:118:1: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
- modetest.c:286:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
- modetest.c:303:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
- modetest.c:694:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
- modetest.c:1088:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
The 'fd' variable is global, we don't need to pass it as an argument:
- modetest.c:998:40: warning: unused parameter ‘fd’ [-Wunused-parameter]
We don't use the 'modeset' variable:
- modetest.c:1025:8: warning: variable ‘modeset’ set but not used [-Wunused-but-set-variable]
V2: rebase, clear some more warnings
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
---
tests/modetest/modetest.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
Hi
I'm sending this patch series again. These 4 patches are independent
from the object properties patches, so once reviewed, it would be nice
if someone could push them.
Patch 1 had to be rebased and patch 3 is new.
Thanks,
Paulo
diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index 223adc4..1b9ae18 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -71,7 +71,7 @@ struct type_name {
#define type_name_fn(res) \
char * res##_str(int type) { \
- int i; \
+ unsigned int i; \
for (i = 0; i < ARRAY_SIZE(res##_names); i++) { \
if (res##_names[i].type == type) \
return res##_names[i].name; \
@@ -272,7 +272,7 @@ static void dump_planes(void)
{
drmModePlaneRes *plane_resources;
drmModePlane *ovr;
- int i, j;
+ unsigned int i, j;
plane_resources = drmModeGetPlaneResources(fd);
if (!plane_resources) {
@@ -681,7 +681,8 @@ set_plane(struct kms_driver *kms, struct connector *c, struct plane *p)
uint32_t plane_id = 0;
struct kms_bo *plane_bo;
uint32_t plane_flags = 0, format;
- int i, ret, crtc_x, crtc_y, crtc_w, crtc_h;
+ int ret, crtc_x, crtc_y, crtc_w, crtc_h;
+ unsigned int i;
/* find an unused plane which can be connected to our crtc */
plane_resources = drmModeGetPlaneResources(fd);
@@ -995,7 +996,7 @@ void usage(char *name)
#define dump_resource(res) if (res) dump_##res()
-static int page_flipping_supported(int fd)
+static int page_flipping_supported(void)
{
/*FIXME: generic ioctl needed? */
return 1;
@@ -1022,8 +1023,8 @@ int main(int argc, char **argv)
int encoders = 0, connectors = 0, crtcs = 0, planes = 0, framebuffers = 0;
int test_vsync = 0;
char *modules[] = { "i915", "radeon", "nouveau", "vmwgfx", "omapdrm" };
- char *modeset = NULL;
- int i, count = 0, plane_count = 0;
+ unsigned int i;
+ int count = 0, plane_count = 0;
struct connector con_args[2];
struct plane plane_args[2] = {0};
@@ -1050,7 +1051,6 @@ int main(int argc, char **argv)
test_vsync = 1;
break;
case 's':
- modeset = strdup(optarg);
con_args[count].crtc = -1;
if (sscanf(optarg, "%d:%64s",
&con_args[count].id,
@@ -1096,7 +1096,7 @@ int main(int argc, char **argv)
}
}
- if (test_vsync && !page_flipping_supported(fd)) {
+ if (test_vsync && !page_flipping_supported()) {
fprintf(stderr, "page flipping not supported by drm.\n");
return -1;
}
--
1.7.9.5
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH libdrm 2/4] modetest: fix drmModeGetConnector memory leak
2012-04-21 20:51 [PATCH libdrm 1/4] modetest: fix some compiler warnings Paulo Zanoni
@ 2012-04-21 20:51 ` Paulo Zanoni
2012-04-21 20:51 ` [PATCH libdrm 3/4] modetest: call drmModeFreePlaneResources Paulo Zanoni
2012-04-21 20:51 ` [PATCH libdrm 4/4] modetest: print more about our properties Paulo Zanoni
2 siblings, 0 replies; 5+ messages in thread
From: Paulo Zanoni @ 2012-04-21 20:51 UTC (permalink / raw)
To: dri-devel; +Cc: Paulo Zanoni
From: Paulo Zanoni <paulo.r.zanoni@intel.com>
Don't "continue" without freeing the connector.
192 bytes in 6 blocks are indirectly lost in loss record 6 of 12
at 0x4C2779D: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4E30DD8: drmMalloc (xf86drm.c:147)
by 0x4E35024: drmAllocCpy (xf86drmMode.c:73)
by 0x4E35D69: drmModeGetConnector (xf86drmMode.c:507)
by 0x402F22: dump_connectors (modetest.c:181)
by 0x40261B: main (modetest.c:801)
Reviewed-by: Eugeni Dodonov <eugeni.dodonov@intel.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
---
tests/modetest/modetest.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index 1b9ae18..64809da 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -199,17 +199,16 @@ void dump_connectors(void)
printf("%s%d", j > 0 ? ", " : "", connector->encoders[j]);
printf("\n");
- if (!connector->count_modes)
- continue;
-
- printf(" modes:\n");
- printf(" name refresh (Hz) hdisp hss hse htot vdisp "
- "vss vse vtot)\n");
- for (j = 0; j < connector->count_modes; j++)
- dump_mode(&connector->modes[j]);
-
- printf(" props:\n");
- dump_props(connector);
+ if (connector->count_modes) {
+ printf(" modes:\n");
+ printf(" name refresh (Hz) hdisp hss hse htot vdisp "
+ "vss vse vtot)\n");
+ for (j = 0; j < connector->count_modes; j++)
+ dump_mode(&connector->modes[j]);
+
+ printf(" props:\n");
+ dump_props(connector);
+ }
drmModeFreeConnector(connector);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH libdrm 3/4] modetest: call drmModeFreePlaneResources
2012-04-21 20:51 [PATCH libdrm 1/4] modetest: fix some compiler warnings Paulo Zanoni
2012-04-21 20:51 ` [PATCH libdrm 2/4] modetest: fix drmModeGetConnector memory leak Paulo Zanoni
@ 2012-04-21 20:51 ` Paulo Zanoni
2012-04-21 20:51 ` [PATCH libdrm 4/4] modetest: print more about our properties Paulo Zanoni
2 siblings, 0 replies; 5+ messages in thread
From: Paulo Zanoni @ 2012-04-21 20:51 UTC (permalink / raw)
To: dri-devel; +Cc: Paulo Zanoni
From: Paulo Zanoni <paulo.r.zanoni@intel.com>
24 (16 direct, 8 indirect) bytes in 1 blocks are definitely lost in loss record 2 of 7
at 0x402994D: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4A25950: drmMalloc (xf86drm.c:147)
by 0x4A2E26D: drmModeGetPlaneResources (xf86drmMode.c:951)
by 0x4025FF: dump_planes (modetest.c:276)
by 0x4052AF: main (modetest.c:1120)
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
---
tests/modetest/modetest.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index 64809da..6deed69 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -307,6 +307,7 @@ static void dump_planes(void)
}
printf("\n");
+ drmModeFreePlaneResources(plane_resources);
return;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH libdrm 4/4] modetest: print more about our properties
2012-04-21 20:51 [PATCH libdrm 1/4] modetest: fix some compiler warnings Paulo Zanoni
2012-04-21 20:51 ` [PATCH libdrm 2/4] modetest: fix drmModeGetConnector memory leak Paulo Zanoni
2012-04-21 20:51 ` [PATCH libdrm 3/4] modetest: call drmModeFreePlaneResources Paulo Zanoni
@ 2012-04-21 20:51 ` Paulo Zanoni
2012-05-03 11:33 ` Daniel Vetter
2 siblings, 1 reply; 5+ messages in thread
From: Paulo Zanoni @ 2012-04-21 20:51 UTC (permalink / raw)
To: dri-devel; +Cc: Paulo Zanoni
From: Paulo Zanoni <paulo.r.zanoni@intel.com>
In the future we'll have more than just connector properties, so create
a dump_prop function that can handle any property (instead of the
current dump_props function that only handles connector properties).
Also, make this function print a lot more information about the existing
properties.
Also change the printed indentation of the modes to make the output more
readable.
The previous function dump_props also segfaulted when we didn't have
enought permissions. The new function does not segfault in this case (by
checking for the return value of drmModeGetProperty).
Reviewed-by: Eugeni Dodonov <eugeni.dodonov@intel.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
---
tests/modetest/modetest.c | 95 ++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 86 insertions(+), 9 deletions(-)
diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index 6deed69..5784622 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -43,6 +43,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
+#include <inttypes.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
@@ -145,7 +146,7 @@ void dump_encoders(void)
void dump_mode(drmModeModeInfo *mode)
{
- printf(" %s %d %d %d %d %d %d %d %d %d\n",
+ printf("\t%s %d %d %d %d %d %d %d %d %d\n",
mode->name,
mode->vrefresh,
mode->hdisplay,
@@ -159,16 +160,90 @@ void dump_mode(drmModeModeInfo *mode)
}
static void
-dump_props(drmModeConnector *connector)
+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)
{
- drmModePropertyPtr props;
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");
+ }
- for (i = 0; i < connector->count_props; i++) {
- props = drmModeGetProperty(fd, connector->props[i]);
- printf("\t%s, flags %d\n", props->name, props->flags);
- drmModeFreeProperty(props);
+ 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);
}
void dump_connectors(void)
@@ -201,13 +276,15 @@ void dump_connectors(void)
if (connector->count_modes) {
printf(" modes:\n");
- printf(" name refresh (Hz) hdisp hss hse htot vdisp "
+ printf("\tname refresh (Hz) hdisp hss hse htot vdisp "
"vss vse vtot)\n");
for (j = 0; j < connector->count_modes; j++)
dump_mode(&connector->modes[j]);
printf(" props:\n");
- dump_props(connector);
+ for (j = 0; j < connector->count_props; j++)
+ dump_prop(connector->props[j],
+ connector->prop_values[j]);
}
drmModeFreeConnector(connector);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH libdrm 4/4] modetest: print more about our properties
2012-04-21 20:51 ` [PATCH libdrm 4/4] modetest: print more about our properties Paulo Zanoni
@ 2012-05-03 11:33 ` Daniel Vetter
0 siblings, 0 replies; 5+ messages in thread
From: Daniel Vetter @ 2012-05-03 11:33 UTC (permalink / raw)
To: Paulo Zanoni; +Cc: Paulo Zanoni, dri-devel
On Sat, Apr 21, 2012 at 05:51:53PM -0300, Paulo Zanoni wrote:
> From: Paulo Zanoni <paulo.r.zanoni@intel.com>
>
> In the future we'll have more than just connector properties, so create
> a dump_prop function that can handle any property (instead of the
> current dump_props function that only handles connector properties).
>
> Also, make this function print a lot more information about the existing
> properties.
>
> Also change the printed indentation of the modes to make the output more
> readable.
>
> The previous function dump_props also segfaulted when we didn't have
> enought permissions. The new function does not segfault in this case (by
> checking for the return value of drmModeGetProperty).
>
> Reviewed-by: Eugeni Dodonov <eugeni.dodonov@intel.com>
> Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Looks like this series here has been lost a bit. I've pushed all 4
patches, thanks.
-Daniel
--
Daniel Vetter
Mail: daniel@ffwll.ch
Mobile: +41 (0)79 365 57 48
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-05-03 11:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-21 20:51 [PATCH libdrm 1/4] modetest: fix some compiler warnings Paulo Zanoni
2012-04-21 20:51 ` [PATCH libdrm 2/4] modetest: fix drmModeGetConnector memory leak Paulo Zanoni
2012-04-21 20:51 ` [PATCH libdrm 3/4] modetest: call drmModeFreePlaneResources Paulo Zanoni
2012-04-21 20:51 ` [PATCH libdrm 4/4] modetest: print more about our properties Paulo Zanoni
2012-05-03 11:33 ` Daniel Vetter
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.