#include <sys/ioctl.h>
#include <stdio.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include "xf86drmMode.h"
#include "xf86drm.h"
#include <drm.h>
#include <unistd.h>
#include <errno.h>
+#ifdef HAVE_VALGRIND
+#include <valgrind.h>
+#include <memcheck.h>
+#define VG(x) x
+#else
+#define VG(x)
+#endif
+
+#define VG_CLEAR(s) VG(memset(&s, 0, sizeof(s)))
+
#define U642VOID(x) ((void *)(unsigned long)(x))
#define VOID2U64(x) ((uint64_t)(unsigned long)(x))
struct drm_mode_fb_cmd f;
int ret;
+ VG_CLEAR(f);
f.width = width;
f.height = height;
f.pitch = pitch;
struct drm_mode_crtc crtc;
drmModeCrtcPtr r;
+ VG_CLEAR(crtc);
crtc.crtc_id = crtcId;
if (drmIoctl(fd, DRM_IOCTL_MODE_GETCRTC, &crtc))
{
struct drm_mode_crtc crtc;
+ VG_CLEAR(crtc);
crtc.x = x;
crtc.y = y;
crtc.crtc_id = crtcId;
drmModeEncoderPtr r = NULL;
enc.encoder_id = encoder_id;
+ enc.crtc_id = 0;
enc.encoder_type = 0;
enc.possible_crtcs = 0;
enc.possible_clones = 0;
struct drm_mode_get_property prop;
drmModePropertyPtr r;
+ VG_CLEAR(prop);
prop.prop_id = property_id;
prop.count_enum_blobs = 0;
prop.count_values = 0;
*/
int drmCheckModesettingSupported(const char *busid)
{
-#ifdef __linux__
+#if defined (__linux__)
char pci_dev_dir[1024];
int domain, bus, dev, func;
DIR *sysdir;
closedir(sysdir);
if (found)
return 0;
+#elif defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
+ char kbusid[1024], sbusid[1024];
+ char oid[128];
+ int domain, bus, dev, func;
+ int i, modesetting, ret;
+ size_t len;
+
+ ret = sscanf(busid, "pci:%04x:%02x:%02x.%d", &domain, &bus, &dev,
+ &func);
+ if (ret != 4)
+ return -EINVAL;
+ snprintf(kbusid, sizeof(kbusid), "pci:%04x:%02x:%02x.%d", domain, bus,
+ dev, func);
+
+ /* How many GPUs do we expect in the machine ? */
+ for (i = 0; i < 16; i++) {
+ snprintf(oid, sizeof(oid), "hw.dri.%d.busid", i);
+ len = sizeof(sbusid);
+ ret = sysctlbyname(oid, sbusid, &len, NULL, 0);
+ if (ret == -1) {
+ if (errno == ENOENT)
+ continue;
+ return -EINVAL;
+ }
+ if (strcmp(sbusid, kbusid) != 0)
+ continue;
+ snprintf(oid, sizeof(oid), "hw.dri.%d.modesetting", i);
+ len = sizeof(modesetting);
+ ret = sysctlbyname(oid, &modesetting, &len, NULL, 0);
+ if (ret == -1 || len != sizeof(modesetting))
+ return -EINVAL;
+ return (modesetting ? 0 : -ENOSYS);
+ }
#endif
return -ENOSYS;
int drmModeSetPlane(int fd, uint32_t plane_id, uint32_t crtc_id,
uint32_t fb_id, uint32_t flags,
- uint32_t crtc_x, uint32_t crtc_y,
+ int32_t crtc_x, int32_t crtc_y,
uint32_t crtc_w, uint32_t crtc_h,
uint32_t src_x, uint32_t src_y,
uint32_t src_w, uint32_t src_h)