exynos: fix coordinate computation in g2d_copy
[platform/upstream/libdrm.git] / tests / dristat.c
index 47193ab..900a3e6 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include "../../../xf86drm.h"
-#include "../xf86drmRandom.c"
-#include "../xf86drmHash.c"
-#include "../xf86drm.c"
+#include "xf86drm.h"
+#include "xf86drmRandom.c"
+#include "xf86drmHash.c"
+#include "xf86drm.c"
 
 #define DRM_VERSION 0x00000001
 #define DRM_MEMORY  0x00000002
@@ -69,32 +69,21 @@ static void getbusid(int fd)
     drmFreeBusid(busid);
 }
 
-#if 0
-typedef struct {
-    unsigned long      offset;  /* Requested physical address (0 for SAREA)*/
-    unsigned long      size;    /* Requested physical size (bytes)         */
-    drm_map_type_t     type;    /* Type of memory to map                   */
-    drm_map_flags_t flags;      /* Flags                                   */
-    void               *handle; /* User-space: "Handle" to pass to mmap    */
-    /* Kernel-space: kernel-virtual address    */
-    int                mtrr;    /* MTRR slot used                          */
-                                /* Private data                            */
-} drmVmRec, *drmVmPtr;
-#endif
 
 static void getvm(int fd)
 {
     int             i;
     const char      *typename;
     char            flagname[33];
-    drmHandle       offset;
+    drm_handle_t    offset;
     drmSize         size;
     drmMapType      type;
     drmMapFlags     flags;
-    drmHandle       handle;
+    drm_handle_t    handle;
     int             mtrr;
 
-    printf("  VM map information (Restricted locked kernel WC Lock):\n");
+    printf("  VM map information:\n");
+    printf("  flags: (R)estricted (r)ead/(w)rite (l)ocked (k)ernel (W)rite-combine (L)ock:\n");
     printf("    slot     offset       size type flags    address mtrr\n");
 
     for (i = 0;
@@ -102,11 +91,12 @@ static void getvm(int fd)
         i++) {
        
        switch (type) {
-       case DRM_FRAME_BUFFER: typename = "FB";  break;
-       case DRM_REGISTERS:    typename = "REG"; break;
-       case DRM_SHM:          typename = "SHM"; break;
-       case DRM_AGP:          typename = "AGP"; break;
-       default:               typename = "???"; break;
+       case DRM_FRAME_BUFFER:   typename = "FB";  break;
+       case DRM_REGISTERS:      typename = "REG"; break;
+       case DRM_SHM:            typename = "SHM"; break;
+       case DRM_AGP:            typename = "AGP"; break;
+       case DRM_SCATTER_GATHER: typename = "SG";  break;
+       default:                 typename = "???"; break;
        }
 
        flagname[0] = (flags & DRM_RESTRICTED)      ? 'R' : ' ';
@@ -118,7 +108,8 @@ static void getvm(int fd)
        flagname[6] = '\0';
        
        printf("    %4d 0x%08lx 0x%08lx %3.3s %6.6s 0x%08lx ",
-              i, offset, (unsigned long)size, typename, flagname, handle);
+              i, (unsigned long)offset, (unsigned long)size,
+              typename, flagname, (unsigned long)handle);
        if (mtrr < 0) printf("none\n");
        else          printf("%4d\n", mtrr);
     }
@@ -141,7 +132,7 @@ static void getclients(int fd)
 
     for (i = 0; !drmGetClient(fd, i, &auth, &pid, &uid, &magic, &iocs); i++) {
        sprintf(buf, "/proc/%d/cmdline", pid);
-       memset(cmd, sizeof(cmd), 0);
+       memset(cmd, 0, sizeof(cmd));
        if ((procfd = open(buf, O_RDONLY, 0)) >= 0) {
            read(procfd, cmd, sizeof(cmd)-1);
            close(procfd);
@@ -258,13 +249,22 @@ int main(int argc, char **argv)
        case 'i': interval = strtol(optarg, NULL, 0); break;
        case 'M': minor = strtol(optarg, NULL, 0);    break;
        default:
-           fprintf( stderr, "Usage: dristat [options]\n" );
+           fprintf( stderr, "Usage: dristat [options]\n\n" );
+           fprintf( stderr, "Displays DRM information. Use with no arguments to display available cards.\n\n" );
+           fprintf( stderr, "  -a            Show all available information\n" );
+           fprintf( stderr, "  -b            Show DRM bus ID's\n" );
+           fprintf( stderr, "  -c            Display information about DRM clients\n" );
+           fprintf( stderr, "  -i [interval] Continuously display statistics every [interval] seconds\n" );
+           fprintf( stderr, "  -v            Display DRM module and card version information\n" );
+           fprintf( stderr, "  -m            Display memory use information\n" );
+           fprintf( stderr, "  -s            Display DRM statistics\n" );
+           fprintf( stderr, "  -M [minor]    Select card by minor number\n" );
            return 1;
        }
 
     for (i = 0; i < 16; i++) if (!minor || i == minor) {
        sprintf(buf, DRM_DEV_NAME, DRM_DIR_NAME, i);
-       fd = drmOpenMinor(i, 1);
+       fd = drmOpenMinor(i, 1, DRM_NODE_RENDER);
        if (fd >= 0) {
            printf("%s\n", buf);
            if (mask & DRM_BUSID)   getbusid(fd);