*/
#include <drm.h>
-#include "xf86mm.h"
/*
* This is the interface for modesetting for drm.
* In order to use this interface you must include either <stdint.h> or another
* header defining uint32_t, int32_t and uint16_t.
*
- * It aims to provide a randr compatible interface for modesettings in the
+ * It aims to provide a randr1.2 compatible interface for modesettings in the
* kernel, the interface is also ment to be used by libraries like EGL.
*
* More information can be found in randrproto.txt which can be found here:
* http://gitweb.freedesktop.org/?p=xorg/proto/randrproto.git
*
- * All framebuffer, crtc and output ids start at 1 while 0 is either an invalid
- * parameter or used to indicate that the command should disconnect from the
- * currently bound target, as with drmModeMapOutput.
- *
- * Currently only one framebuffer exist and has a id of 1, which is also the
- * default framebuffer and should allways be avaible to the client, unless
- * it is locked/used or any other limiting state is applied on it.
- *
+ * There are some major diffrences to be noted. Unlike the randr1.2 proto you
+ * need to create the memory object of the framebuffer yourself with the ttm
+ * buffer object interface. This object needs to be pinned.
*/
-typedef struct _drmModeGammaTriple {
- uint16_t r, g, b;
-} drmModeGammaTriple, *drmModeGammaTriplePtr;
-
typedef struct _drmModeRes {
int count_fbs;
int count_crtcs;
uint32_t *crtcs;
- int count_outputs;
- uint32_t *outputs;
+ int count_connectors;
+ uint32_t *connectors;
- int count_modes;
- struct drm_mode_modeinfo *modes;
+ int count_encoders;
+ uint32_t *encoders;
+ uint32_t min_width, max_width;
+ uint32_t min_height, max_height;
} drmModeRes, *drmModeResPtr;
typedef struct drm_mode_fb_cmd drmModeFB, *drmModeFBPtr;
-typedef struct _drmModeCrtc {
+typedef struct _drmModePropertyBlob {
+ uint32_t id;
+ uint32_t length;
+ void *data;
+} drmModePropertyBlobRes, *drmModePropertyBlobPtr;
+
+typedef struct _drmModeProperty {
+ unsigned int prop_id;
+ unsigned int flags;
+ char name[DRM_PROP_NAME_LEN];
+ int count_values;
+ uint64_t *values; // store the blob lengths
+ int count_enums;
+ struct drm_mode_property_enum *enums;
+ int count_blobs;
+ uint32_t *blob_ids; // store the blob IDs
+} drmModePropertyRes, *drmModePropertyPtr;
- unsigned int buffer_id; /**< FB id to connect to 0 = disconnect*/
+typedef struct _drmModeCrtc {
+ unsigned int crtc_id;
+ unsigned int buffer_id; /**< FB id to connect to 0 = disconnect */
- uint32_t x, y; /**< Position on the frameuffer */
+ uint32_t x, y; /**< Position on the framebuffer */
uint32_t width, height;
- uint32_t mode; /**< Current mode used */
-
- int count_outputs;
- uint32_t outputs; /**< Outputs that are connected */
-
- int count_possibles;
- uint32_t possibles; /**< Outputs that can be connected */
+ int mode_valid;
+ struct drm_mode_modeinfo mode;
int gamma_size; /**< Number of gamma stops */
} drmModeCrtc, *drmModeCrtcPtr;
+typedef struct _drmModeEncoder {
+ unsigned int encoder_id;
+ unsigned int encoder_type;
+ unsigned int crtc_id;
+ uint32_t possible_crtcs;
+ uint32_t possible_clones;
+} drmModeEncoder, *drmModeEncoderPtr;
+
typedef enum {
DRM_MODE_CONNECTED = 1,
DRM_MODE_DISCONNECTED = 2,
DRM_MODE_SUBPIXEL_NONE = 6
} drmModeSubPixel;
-typedef struct _drmModeOutput {
-
- unsigned int crtc; /**< Crtc currently connected to */
- unsigned char name[DRM_OUTPUT_NAME_LEN];
+typedef struct _drmModeConnector {
+ unsigned int connector_id;
+ unsigned int encoder_id; /**< Encoder currently connected to */
+ unsigned int connector_type;
+ unsigned int connector_type_id;
drmModeConnection connection;
uint32_t mmWidth, mmHeight; /**< HxW in millimeters */
drmModeSubPixel subpixel;
- int count_crtcs;
- uint32_t crtcs; /**< Possible crtc to connect to */
+ int count_modes;
+ struct drm_mode_modeinfo *modes;
- int count_clones;
- uint32_t clones; /**< Mask of clones */
+ int count_props;
+ uint32_t *props; /**< List of property ids */
+ uint64_t *prop_values; /**< List of property values */
- int count_modes;
- uint32_t *modes; /**< List of modes ids */
+ int count_encoders;
+ uint32_t *encoders; /**< List of encoder ids */
+} drmModeConnector, *drmModeConnectorPtr;
-} drmModeOutput, *drmModeOutputPtr;
-/*
- * RRSetScreenConfig o
- * RRGetScreenInfo o
- *
- * RRGetScreenSizeRange - see frameBuffer info
- * RRSetScreenSize
- * RRGetScreenResources
- *
- * RRGetOutputInfo
- *
- * RRListOutputProperties *
- * RRQueryOutputProperty *
- * RRConfigureOutputProperty *
- * RRChangeOutputProperty *
- * RRDeleteOutputProperty *
- * RRGetOutputProperty *
- *
- * RRCreateMode
- * RRDestroyMode
- * RRAddOutputMode
- * RRDeleteOutputMode
- *
- * RRGetCrtcInfo
- * RRSetCrtcConfig
- *
- * RRGetCrtcGammaSize - see crtc info
- * RRGetCrtcGamma
- * RRSetCrtcGamma
- *
- * drmModeGetResources
- * drmModeForceProbe
- *
- * drmModeGetFrameBufferInfo
- * drmModeSetFrameBufferSize
- *
- * drmModeGetCrtcInfo
- * drmModeSetCrtcConfig
- * drmModeGetCrtcGamma
- * drmModeSetCrtcGamma
- *
- * drmModeGetOutputInfo
- *
- * drmModeAddMode
- * drmModeDestroyMode
- * drmModeAddOutputMode
- * drmModeDeleteOutputMode
- */
extern void drmModeFreeModeInfo( struct drm_mode_modeinfo *ptr );
extern void drmModeFreeResources( drmModeResPtr ptr );
extern void drmModeFreeFB( drmModeFBPtr ptr );
extern void drmModeFreeCrtc( drmModeCrtcPtr ptr );
-extern void drmModeFreeOutput( drmModeOutputPtr ptr );
+extern void drmModeFreeConnector( drmModeConnectorPtr ptr );
+extern void drmModeFreeEncoder( drmModeEncoderPtr ptr );
/**
* Retrives all of the resources associated with a card.
extern drmModeResPtr drmModeGetResources(int fd);
/**
- * Forces a probe of the give output outputId, on 0 all will be probed.
+ * Retrives the hotplug counter
*/
-extern int drmModeForceProbe(int fd, uint32_t outputId);
-
+extern uint32_t drmModeGetHotplug(int fd);
/*
* FrameBuffer manipulation.
* Creates a new framebuffer with an buffer object as its scanout buffer.
*/
extern int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth,
- uint8_t bpp, uint32_t pitch, drmBO *bo,
+ uint8_t bpp, uint32_t pitch, uint32_t bo_handle,
uint32_t *buf_id);
/**
* Destroies the given framebuffer.
extern int drmModeRmFB(int fd, uint32_t bufferId);
/**
- * Changes the scanout buffer to the given buffer object.
+ * Replace a framebuffer object with a new one - for resizing the screen.
*/
-extern int drmModeFlipFrameBuffer(int fd, uint32_t bufferId, drmBO *bo);
+extern int drmModeReplaceFB(int fd, uint32_t buffer_id,
+ uint32_t width, uint32_t height, uint8_t depth,
+ uint8_t bpp, uint32_t pitch, uint32_t bo_handle);
/*
- * Crtc function.
+ * Crtc functions
*/
/**
/**
* Set the mode on a crtc crtcId with the given mode modeId.
*/
-extern int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId,
- uint32_t x, uint32_t y, uint32_t modeId,
- uint32_t *outputs, int count);
+int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId,
+ uint32_t x, uint32_t y, uint32_t *connectors, int count,
+ struct drm_mode_modeinfo *mode);
-/**
- * Gets the gamma from a crtc
+/*
+ * Cursor functions
*/
-extern drmModeGammaTriplePtr drmModeGetCrtcGamma(int fd, uint32_t crtcId,
- int *count);
/**
- * Sets the gamma on a crtc
+ * Set the cursor on crtc
*/
-extern int drmModeSetCrtcGamma(int fd, uint32_t crtcId,
- drmModeGammaTriplePtr ptr, int count);
-
-
+int drmModeSetCursor(int fd, uint32_t crtcId, uint32_t bo_handle, uint32_t width, uint32_t height);
-/*
- * Output manipulation
+/**
+ * Move the cursor on crtc
*/
+int drmModeMoveCursor(int fd, uint32_t crtcId, int x, int y);
/**
- * Retrive information about the output outputId.
+ * Encoder functions
*/
-extern drmModeOutputPtr drmModeGetOutput(int fd,
- uint32_t outputId);
+drmModeEncoderPtr drmModeGetEncoder(int fd, uint32_t encoder_id);
-/**
- * Creates a new mode from the given mode info.
- * Name must be unique.
+/*
+ * Connector manipulation
*/
-extern uint32_t drmModeNewMode(int fd, struct drm_mode_modeinfo *modeInfo);
/**
- * Destroys a mode created with CreateMode, must be unused.
+ * Retrive information about the connector connectorId.
*/
-extern int drmModeDesMode(int fd, uint32_t modeId);
+extern drmModeConnectorPtr drmModeGetConnector(int fd,
+ uint32_t connectorId);
/**
- * Adds the given mode to an output.
+ * Attaches the given mode to an connector.
*/
-extern int drmModeAddMode(int fd, uint32_t outputId, uint32_t modeId);
+extern int drmModeAttachMode(int fd, uint32_t connectorId, struct drm_mode_modeinfo *mode_info);
/**
- * Deletes a mode Added with AddOutputMode from the output,
+ * Detaches a mode from the connector
* must be unused, by the given mode.
*/
-extern int drmModeDelMode(int fd, uint32_t outputId, uint32_t modeId);
+extern int drmModeDetachMode(int fd, uint32_t connectorId, struct drm_mode_modeinfo *mode_info);
+
+extern drmModePropertyPtr drmModeGetProperty(int fd, uint32_t propertyId);
+extern void drmModeFreeProperty(drmModePropertyPtr ptr);
+
+extern drmModePropertyBlobPtr drmModeGetPropertyBlob(int fd, uint32_t blob_id);
+extern void drmModeFreePropertyBlob(drmModePropertyBlobPtr ptr);
+extern int drmModeConnectorSetProperty(int fd, uint32_t connector_id, uint32_t property_id,
+ uint64_t value);
+extern int drmCheckModesettingSupported(const char *busid);
+extern int drmModeCrtcSetGamma(int fd, uint32_t crtc_id, uint32_t size,
+ uint16_t *red, uint16_t *green, uint16_t *blue);
+extern int drmModeCrtcGetGamma(int fd, uint32_t crtc_id, uint32_t size,
+ uint16_t *red, uint16_t *green, uint16_t *blue);