summaryrefslogtreecommitdiff
path: root/libdrm
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2008-06-02 12:58:10 +1000
committerDave Airlie <airlied@redhat.com>2008-06-02 12:58:10 +1000
commiteba6cdc936cb33d929997ccb9bade6f75bb40670 (patch)
tree8fc95131e711155fe4e5613e5c0029cf71054e5e /libdrm
parentefb48c6cf7bbb57e7b2ea6ce7671905e84384963 (diff)
parent7fec6c0e2a2457925b88ed3bd70d9defde77b81b (diff)
Merge branch 'modesetting-101-encoders' into modesetting-101
Diffstat (limited to 'libdrm')
-rw-r--r--libdrm/xf86drmMode.c174
-rw-r--r--libdrm/xf86drmMode.h69
2 files changed, 142 insertions, 101 deletions
diff --git a/libdrm/xf86drmMode.c b/libdrm/xf86drmMode.c
index ae15fd65..d11fc12e 100644
--- a/libdrm/xf86drmMode.c
+++ b/libdrm/xf86drmMode.c
@@ -109,7 +109,7 @@ void drmModeFreeCrtc(drmModeCrtcPtr ptr)
}
-void drmModeFreeOutput(drmModeOutputPtr ptr)
+void drmModeFreeConnector(drmModeConnectorPtr ptr)
{
if (!ptr)
return;
@@ -119,6 +119,11 @@ void drmModeFreeOutput(drmModeOutputPtr ptr)
}
+void drmModeFreeEncoder(drmModeEncoderPtr ptr)
+{
+ drmFree(ptr);
+}
+
/*
* ModeSetting functions.
*/
@@ -137,8 +142,10 @@ drmModeResPtr drmModeGetResources(int fd)
res.fb_id_ptr = VOID2U64(drmMalloc(res.count_fbs*sizeof(uint32_t)));
if (res.count_crtcs)
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_connectors)
+ res.connector_id_ptr = VOID2U64(drmMalloc(res.count_connectors*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;
@@ -159,16 +166,19 @@ drmModeResPtr drmModeGetResources(int fd)
r->max_height = res.max_height;
r->count_fbs = res.count_fbs;
r->count_crtcs = res.count_crtcs;
- r->count_outputs = res.count_outputs;
+ r->count_connectors = res.count_connectors;
+ r->count_encoders = res.count_encoders;
/* TODO we realy should test if these allocs fails. */
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->connectors = drmAllocCpy(U642VOID(res.connector_id_ptr), res.count_connectors, 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));
+ drmFree(U642VOID(res.connector_id_ptr));
+ drmFree(U642VOID(res.encoder_id_ptr));
return r;
}
@@ -244,10 +254,6 @@ drmModeCrtcPtr drmModeGetCrtc(int fd, uint32_t crtcId)
struct drm_mode_crtc crtc;
drmModeCrtcPtr r;
- crtc.count_outputs = 0;
- crtc.outputs = 0;
- crtc.count_possibles = 0;
- crtc.possibles = 0;
crtc.crtc_id = crtcId;
if (ioctl(fd, DRM_IOCTL_MODE_GETCRTC, &crtc))
@@ -268,24 +274,18 @@ drmModeCrtcPtr drmModeGetCrtc(int fd, uint32_t crtcId)
memcpy(&r->mode, &crtc.mode, sizeof(struct drm_mode_modeinfo));
r->buffer_id = crtc.fb_id;
r->gamma_size = crtc.gamma_size;
- r->count_outputs = crtc.count_outputs;
- r->count_possibles = crtc.count_possibles;
- /* TODO we realy should test if these alloc & cpy fails. */
- r->outputs = crtc.outputs;
- r->possibles = crtc.possibles;
-
return r;
}
int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId,
- uint32_t x, uint32_t y, uint32_t *outputs, int count,
+ uint32_t x, uint32_t y, uint32_t *connectors, int count,
struct drm_mode_modeinfo *mode)
{
struct drm_mode_crtc crtc;
- crtc.count_outputs = 0;
- crtc.outputs = 0;
+ crtc.count_connectors = 0;
+ crtc.connectors = 0;
crtc.count_possibles = 0;
crtc.possibles = 0;
@@ -293,8 +293,8 @@ int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId,
crtc.y = y;
crtc.crtc_id = crtcId;
crtc.fb_id = bufferId;
- crtc.set_outputs_ptr = VOID2U64(outputs);
- crtc.count_outputs = count;
+ crtc.set_connectors_ptr = VOID2U64(connectors);
+ crtc.count_connectors = count;
if (mode) {
memcpy(&crtc.mode, mode, sizeof(struct drm_mode_modeinfo));
crtc.mode_valid = 1;
@@ -334,88 +334,116 @@ int drmModeMoveCursor(int fd, uint32_t crtcId, int x, int y)
}
/*
- * Output manipulation
+ * 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;
+
+ if (!(r = drmMalloc(sizeof(*r))))
+ return 0;
+
+ r->encoder_id = enc.encoder_id;
+ r->crtc = enc.crtc;
+ r->encoder_type = enc.encoder_type;
+ r->crtcs = enc.crtcs;
+ r->clones = enc.clones;
+
+ return r;
+}
+
+/*
+ * Connector manipulation
*/
-drmModeOutputPtr drmModeGetOutput(int fd, uint32_t output_id)
+drmModeConnectorPtr drmModeGetConnector(int fd, uint32_t connector_id)
{
- struct drm_mode_get_output out;
- drmModeOutputPtr r = NULL;
-
- out.output = output_id;
- out.output_type_id = 0;
- out.output_type = 0;
- out.count_crtcs = 0;
- out.crtcs = 0;
- out.count_clones = 0;
- out.clones = 0;
- out.count_modes = 0;
- out.modes_ptr = 0;
- out.count_props = 0;
- out.props_ptr = 0;
- out.prop_values_ptr = 0;
-
- if (ioctl(fd, DRM_IOCTL_MODE_GETOUTPUT, &out))
+ struct drm_mode_get_connector conn;
+ drmModeConnectorPtr r = NULL;
+
+ conn.connector = connector_id;
+ conn.connector_type_id = 0;
+ conn.connector_type = 0;
+ conn.count_modes = 0;
+ conn.modes_ptr = 0;
+ conn.count_props = 0;
+ conn.props_ptr = 0;
+ conn.prop_values_ptr = 0;
+ conn.count_encoders = 0;
+ conn.encoders_ptr = 0;
+
+ if (ioctl(fd, DRM_IOCTL_MODE_GETCONNECTOR, &conn))
return 0;
- if (out.count_props) {
- out.props_ptr = VOID2U64(drmMalloc(out.count_props*sizeof(uint32_t)));
- out.prop_values_ptr = VOID2U64(drmMalloc(out.count_props*sizeof(uint64_t)));
+ if (conn.count_props) {
+ conn.props_ptr = VOID2U64(drmMalloc(conn.count_props*sizeof(uint32_t)));
+ conn.prop_values_ptr = VOID2U64(drmMalloc(conn.count_props*sizeof(uint64_t)));
}
- if (out.count_modes)
- out.modes_ptr = VOID2U64(drmMalloc(out.count_modes*sizeof(struct drm_mode_modeinfo)));
+ if (conn.count_modes)
+ conn.modes_ptr = VOID2U64(drmMalloc(conn.count_modes*sizeof(struct drm_mode_modeinfo)));
+
+ if (conn.count_encoders)
+ conn.encoders_ptr = VOID2U64(drmMalloc(conn.count_encoders*sizeof(uint32_t)));
- if (ioctl(fd, DRM_IOCTL_MODE_GETOUTPUT, &out))
+ if (ioctl(fd, DRM_IOCTL_MODE_GETCONNECTOR, &conn))
goto err_allocs;
if(!(r = drmMalloc(sizeof(*r)))) {
goto err_allocs;
}
- r->output_id = out.output;
- r->crtc = out.crtc;
- r->connection = out.connection;
- r->mmWidth = out.mm_width;
- r->mmHeight = out.mm_height;
- r->subpixel = out.subpixel;
- r->count_crtcs = out.count_crtcs;
- r->count_clones = out.count_clones;
- r->count_modes = out.count_modes;
+ r->connector_id = conn.connector;
+ r->encoder = conn.encoder;
+ r->connection = conn.connection;
+ r->mmWidth = conn.mm_width;
+ r->mmHeight = conn.mm_height;
+ r->subpixel = conn.subpixel;
+ r->count_modes = conn.count_modes;
/* TODO we should test if these alloc & cpy fails. */
- r->crtcs = out.crtcs;
- r->clones = out.clones;
- r->count_props = out.count_props;
- r->props = drmAllocCpy(U642VOID(out.props_ptr), out.count_props, sizeof(uint32_t));
- r->prop_values = drmAllocCpy(U642VOID(out.prop_values_ptr), out.count_props, sizeof(uint64_t));
- r->modes = drmAllocCpy(U642VOID(out.modes_ptr), out.count_modes, sizeof(struct drm_mode_modeinfo));
- r->output_type = out.output_type;
- r->output_type_id = out.output_type_id;
+ r->count_props = conn.count_props;
+ r->props = drmAllocCpy(U642VOID(conn.props_ptr), conn.count_props, sizeof(uint32_t));
+ r->prop_values = drmAllocCpy(U642VOID(conn.prop_values_ptr), conn.count_props, sizeof(uint64_t));
+ r->modes = drmAllocCpy(U642VOID(conn.modes_ptr), conn.count_modes, sizeof(struct drm_mode_modeinfo));
+ r->count_encoders = conn.count_encoders;
+ r->encoders = drmAllocCpy(U642VOID(conn.encoders_ptr), conn.count_encoders, sizeof(uint32_t));
+ r->connector_type = conn.connector_type;
+ r->connector_type_id = conn.connector_type_id;
err_allocs:
- drmFree(U642VOID(out.prop_values_ptr));
- drmFree(U642VOID(out.props_ptr));
- drmFree(U642VOID(out.modes_ptr));
+ drmFree(U642VOID(conn.prop_values_ptr));
+ drmFree(U642VOID(conn.props_ptr));
+ drmFree(U642VOID(conn.modes_ptr));
+ drmFree(U642VOID(conn.encoders_ptr));
return r;
}
-int drmModeAttachMode(int fd, uint32_t output_id, struct drm_mode_modeinfo *mode_info)
+int drmModeAttachMode(int fd, uint32_t connector_id, struct drm_mode_modeinfo *mode_info)
{
struct drm_mode_mode_cmd res;
memcpy(&res.mode, mode_info, sizeof(struct drm_mode_modeinfo));
- res.output_id = output_id;
+ res.connector_id = connector_id;
return ioctl(fd, DRM_IOCTL_MODE_ATTACHMODE, &res);
}
-int drmModeDetachMode(int fd, uint32_t output_id, struct drm_mode_modeinfo *mode_info)
+int drmModeDetachMode(int fd, uint32_t connector_id, struct drm_mode_modeinfo *mode_info)
{
struct drm_mode_mode_cmd res;
memcpy(&res.mode, mode_info, sizeof(struct drm_mode_modeinfo));
- res.output_id = output_id;
+ res.connector_id = connector_id;
return ioctl(fd, DRM_IOCTL_MODE_DETACHMODE, &res);
}
@@ -530,13 +558,13 @@ void drmModeFreePropertyBlob(drmModePropertyBlobPtr ptr)
drmFree(ptr);
}
-int drmModeOutputSetProperty(int fd, uint32_t output_id, uint32_t property_id,
+int drmModeConnectorSetProperty(int fd, uint32_t connector_id, uint32_t property_id,
uint64_t value)
{
- struct drm_mode_output_set_property osp;
+ struct drm_mode_connector_set_property osp;
int ret;
- osp.output_id = output_id;
+ osp.connector_id = connector_id;
osp.prop_id = property_id;
osp.value = value;
diff --git a/libdrm/xf86drmMode.h b/libdrm/xf86drmMode.h
index 5171b592..2f3a8f74 100644
--- a/libdrm/xf86drmMode.h
+++ b/libdrm/xf86drmMode.h
@@ -60,8 +60,11 @@ typedef struct _drmModeRes {
int count_crtcs;
uint32_t *crtcs;
- int count_outputs;
- uint32_t *outputs;
+ int count_connectors;
+ uint32_t *connectors;
+
+ int count_encoders;
+ uint32_t *encoders;
uint32_t min_width, max_width;
uint32_t min_height, max_height;
@@ -96,16 +99,24 @@ typedef struct _drmModeCrtc {
int mode_valid;
struct drm_mode_modeinfo mode;
- int count_outputs;
- uint32_t outputs; /**< Outputs that are connected */
+ int count_connectors;
+ uint32_t connectors; /**< Connectors that are connected */
int count_possibles;
- uint32_t possibles; /**< Outputs that can be connected */
+ uint32_t possibles; /**< Connectors that can be connected */
int gamma_size; /**< Number of gamma stops */
} drmModeCrtc, *drmModeCrtcPtr;
+typedef struct _drmModeEncoder {
+ unsigned int encoder_id;
+ unsigned int encoder_type;
+ uint32_t crtc;
+ uint32_t crtcs;
+ uint32_t clones;
+} drmModeEncoder, *drmModeEncoderPtr;
+
typedef enum {
DRM_MODE_CONNECTED = 1,
DRM_MODE_DISCONNECTED = 2,
@@ -121,22 +132,16 @@ typedef enum {
DRM_MODE_SUBPIXEL_NONE = 6
} drmModeSubPixel;
-typedef struct _drmModeOutput {
- unsigned int output_id;
+typedef struct _drmModeConnector {
+ unsigned int connector_id;
- unsigned int crtc; /**< Crtc currently connected to */
- unsigned int output_type;
- unsigned int output_type_id;
+ unsigned int encoder; /**< Crtc 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_clones;
- uint32_t clones; /**< Mask of clones */
-
int count_modes;
struct drm_mode_modeinfo *modes;
@@ -144,7 +149,9 @@ typedef struct _drmModeOutput {
uint32_t *props; /**< List of property ids */
uint64_t *prop_values; /**< List of property values */
-} drmModeOutput, *drmModeOutputPtr;
+ int count_encoders;
+ uint32_t *encoders; /**< List of encoder ids */
+} drmModeConnector, *drmModeConnectorPtr;
@@ -152,7 +159,8 @@ 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.
@@ -204,7 +212,7 @@ extern drmModeCrtcPtr drmModeGetCrtc(int fd, uint32_t crtcId);
* Set the mode on a crtc crtcId with the given mode modeId.
*/
int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId,
- uint32_t x, uint32_t y, uint32_t *outputs, int count,
+ uint32_t x, uint32_t y, uint32_t *connectors, int count,
struct drm_mode_modeinfo *mode);
/*
@@ -221,32 +229,37 @@ 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);
+/**
+ * Encoder functions
+ */
+drmModeEncoderPtr drmModeGetEncoder(int fd, uint32_t encoder_id);
+
/*
- * Output manipulation
+ * Connector manipulation
*/
/**
- * Retrive information about the output outputId.
+ * Retrive information about the connector connectorId.
*/
-extern drmModeOutputPtr drmModeGetOutput(int fd,
- uint32_t outputId);
+extern drmModeConnectorPtr drmModeGetConnector(int fd,
+ uint32_t connectorId);
/**
- * Attaches the given mode to an output.
+ * Attaches the given mode to an connector.
*/
-extern int drmModeAttachMode(int fd, uint32_t outputId, struct drm_mode_modeinfo *mode_info);
+extern int drmModeAttachMode(int fd, uint32_t connectorId, struct drm_mode_modeinfo *mode_info);
/**
- * Detaches a mode from the output
+ * Detaches a mode from the connector
* must be unused, by the given mode.
*/
-extern int drmModeDetachMode(int fd, uint32_t outputId, struct drm_mode_modeinfo *mode_info);
+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 drmModeOutputSetProperty(int fd, uint32_t output_id, uint32_t property_id,
+extern int drmModeConnectorSetProperty(int fd, uint32_t connector_id, uint32_t property_id,
uint64_t value);
extern int drmCheckModesettingSupported(const char *busid);