libdrm: add encoder retrival
authorDave Airlie <airlied@redhat.com>
Fri, 30 May 2008 02:10:01 +0000 (12:10 +1000)
committerDave Airlie <airlied@redhat.com>
Fri, 30 May 2008 02:10:01 +0000 (12:10 +1000)
libdrm/xf86drmMode.c
libdrm/xf86drmMode.h

index ae15fd6..e5798f9 100644 (file)
@@ -139,6 +139,8 @@ drmModeResPtr drmModeGetResources(int fd)
                res.crtc_id_ptr = VOID2U64(drmMalloc(res.count_crtcs*sizeof(uint32_t)));
        if (res.count_outputs)
                res.output_id_ptr = VOID2U64(drmMalloc(res.count_outputs*sizeof(uint32_t)));
                res.crtc_id_ptr = VOID2U64(drmMalloc(res.count_crtcs*sizeof(uint32_t)));
        if (res.count_outputs)
                res.output_id_ptr = VOID2U64(drmMalloc(res.count_outputs*sizeof(uint32_t)));
+       if (res.count_encoders)
+               res.encoder_id_ptr = VOID2U64(drmMalloc(res.count_encoders*sizeof(uint32_t)));
 
        if (ioctl(fd, DRM_IOCTL_MODE_GETRESOURCES, &res)) {
                r = NULL;
 
        if (ioctl(fd, DRM_IOCTL_MODE_GETRESOURCES, &res)) {
                r = NULL;
@@ -164,11 +166,13 @@ drmModeResPtr drmModeGetResources(int fd)
        r->fbs           = drmAllocCpy(U642VOID(res.fb_id_ptr), res.count_fbs, sizeof(uint32_t));
        r->crtcs         = drmAllocCpy(U642VOID(res.crtc_id_ptr), res.count_crtcs, sizeof(uint32_t));
        r->outputs       = drmAllocCpy(U642VOID(res.output_id_ptr), res.count_outputs, sizeof(uint32_t));
        r->fbs           = drmAllocCpy(U642VOID(res.fb_id_ptr), res.count_fbs, sizeof(uint32_t));
        r->crtcs         = drmAllocCpy(U642VOID(res.crtc_id_ptr), res.count_crtcs, sizeof(uint32_t));
        r->outputs       = drmAllocCpy(U642VOID(res.output_id_ptr), res.count_outputs, sizeof(uint32_t));
+       r->encoders      = drmAllocCpy(U642VOID(res.encoder_id_ptr), res.count_encoders, sizeof(uint32_t));
 
 err_allocs:
        drmFree(U642VOID(res.fb_id_ptr));
        drmFree(U642VOID(res.crtc_id_ptr));
        drmFree(U642VOID(res.output_id_ptr));
 
 err_allocs:
        drmFree(U642VOID(res.fb_id_ptr));
        drmFree(U642VOID(res.crtc_id_ptr));
        drmFree(U642VOID(res.output_id_ptr));
+       drmFree(U642VOID(res.encoder_id_ptr));
 
        return r;
 }
 
        return r;
 }
@@ -334,6 +338,29 @@ int drmModeMoveCursor(int fd, uint32_t crtcId, int x, int y)
 }
 
 /*
 }
 
 /*
+ * Encoder get 
+ */
+drmModeEncoderPtr drmModeGetEncoder(int fd, uint32_t encoder_id)
+{
+       struct drm_mode_get_encoder enc;
+       drmModeEncoderPtr r = NULL;
+
+       enc.encoder_id = encoder_id;
+       enc.encoder_type = 0;
+       enc.crtcs = 0;
+       enc.clones = 0;
+
+       if (ioctl(fd, DRM_IOCTL_MODE_GETENCODER, &enc))
+               return 0;
+
+       r->encoder_type = enc.encoder_type;
+       r->crtcs = enc.crtcs;
+       r->clones = enc.clones;
+
+       return r;
+}
+
+/*
  * Output manipulation
  */
 
  * Output manipulation
  */
 
index 5171b59..a5ecd09 100644 (file)
@@ -63,6 +63,9 @@ typedef struct _drmModeRes {
        int count_outputs;
        uint32_t *outputs;
 
        int count_outputs;
        uint32_t *outputs;
 
+       int count_encoders;
+       uint32_t *encoders;
+
        uint32_t min_width, max_width;
        uint32_t min_height, max_height;
 } drmModeRes, *drmModeResPtr;
        uint32_t min_width, max_width;
        uint32_t min_height, max_height;
 } drmModeRes, *drmModeResPtr;
@@ -106,6 +109,13 @@ typedef struct _drmModeCrtc {
 
 } drmModeCrtc, *drmModeCrtcPtr;
 
 
 } drmModeCrtc, *drmModeCrtcPtr;
 
+typedef struct _drmModeEncoder {
+       unsigned int encoder_id;
+       unsigned int encoder_type;
+       uint32_t crtcs;
+       uint32_t clones;
+} drmModeEncoder, *drmModeEncoderPtr;
+
 typedef enum {
        DRM_MODE_CONNECTED         = 1,
        DRM_MODE_DISCONNECTED      = 2,
 typedef enum {
        DRM_MODE_CONNECTED         = 1,
        DRM_MODE_DISCONNECTED      = 2,
@@ -221,6 +231,11 @@ int drmModeSetCursor(int fd, uint32_t crtcId, uint32_t bo_handle, uint32_t width
  */
 int drmModeMoveCursor(int fd, uint32_t crtcId, int x, int y);
 
  */
 int drmModeMoveCursor(int fd, uint32_t crtcId, int x, int y);
 
+/**
+ * Encoder functions
+ */
+drmModeEncoderPtr drmModeGetEncoder(int fd, uint32_t encoder_id);
+
 /*
  * Output manipulation
  */
 /*
  * Output manipulation
  */