modesetting-101: Make the interface variable names a little more consistent + modeprint changes.

- All things are now called _id when they are id's.
- modeprint now accepts driver name as first argument.
main
Maarten Maathuis 2008-07-05 12:04:07 +02:00
parent be31a0fa73
commit 7cbc5f6145
5 changed files with 48 additions and 47 deletions

View File

@ -284,11 +284,6 @@ int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId,
{ {
struct drm_mode_crtc crtc; struct drm_mode_crtc crtc;
crtc.count_connectors = 0;
crtc.connectors = 0;
crtc.count_possibles = 0;
crtc.possibles = 0;
crtc.x = x; crtc.x = x;
crtc.y = y; crtc.y = y;
crtc.crtc_id = crtcId; crtc.crtc_id = crtcId;
@ -343,8 +338,8 @@ drmModeEncoderPtr drmModeGetEncoder(int fd, uint32_t encoder_id)
enc.encoder_id = encoder_id; enc.encoder_id = encoder_id;
enc.encoder_type = 0; enc.encoder_type = 0;
enc.crtcs = 0; enc.possible_crtcs = 0;
enc.clones = 0; enc.possible_clones = 0;
if (ioctl(fd, DRM_IOCTL_MODE_GETENCODER, &enc)) if (ioctl(fd, DRM_IOCTL_MODE_GETENCODER, &enc))
return 0; return 0;
@ -353,10 +348,10 @@ drmModeEncoderPtr drmModeGetEncoder(int fd, uint32_t encoder_id)
return 0; return 0;
r->encoder_id = enc.encoder_id; r->encoder_id = enc.encoder_id;
r->crtc = enc.crtc; r->crtc_id = enc.crtc_id;
r->encoder_type = enc.encoder_type; r->encoder_type = enc.encoder_type;
r->crtcs = enc.crtcs; r->possible_crtcs = enc.possible_crtcs;
r->clones = enc.clones; r->possible_clones = enc.possible_clones;
return r; return r;
} }
@ -370,7 +365,7 @@ drmModeConnectorPtr drmModeGetConnector(int fd, uint32_t connector_id)
struct drm_mode_get_connector conn; struct drm_mode_get_connector conn;
drmModeConnectorPtr r = NULL; drmModeConnectorPtr r = NULL;
conn.connector = connector_id; conn.connector_id = connector_id;
conn.connector_type_id = 0; conn.connector_type_id = 0;
conn.connector_type = 0; conn.connector_type = 0;
conn.count_modes = 0; conn.count_modes = 0;
@ -402,8 +397,8 @@ drmModeConnectorPtr drmModeGetConnector(int fd, uint32_t connector_id)
goto err_allocs; goto err_allocs;
} }
r->connector_id = conn.connector; r->connector_id = conn.connector_id;
r->encoder = conn.encoder; r->encoder_id = conn.encoder_id;
r->connection = conn.connection; r->connection = conn.connection;
r->mmWidth = conn.mm_width; r->mmWidth = conn.mm_width;
r->mmHeight = conn.mm_height; r->mmHeight = conn.mm_height;

View File

@ -92,7 +92,7 @@ typedef struct _drmModeCrtc {
unsigned int crtc_id; unsigned int crtc_id;
unsigned int buffer_id; /**< FB id to connect to 0 = disconnect */ 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 width, height;
int mode_valid; int mode_valid;
struct drm_mode_modeinfo mode; struct drm_mode_modeinfo mode;
@ -104,9 +104,9 @@ typedef struct _drmModeCrtc {
typedef struct _drmModeEncoder { typedef struct _drmModeEncoder {
unsigned int encoder_id; unsigned int encoder_id;
unsigned int encoder_type; unsigned int encoder_type;
uint32_t crtc; unsigned int crtc_id;
uint32_t crtcs; uint32_t possible_crtcs;
uint32_t clones; uint32_t possible_clones;
} drmModeEncoder, *drmModeEncoderPtr; } drmModeEncoder, *drmModeEncoderPtr;
typedef enum { typedef enum {
@ -126,7 +126,7 @@ typedef enum {
typedef struct _drmModeConnector { typedef struct _drmModeConnector {
unsigned int connector_id; unsigned int connector_id;
unsigned int encoder; /**< Encoder currently connected to */ unsigned int encoder_id; /**< Encoder currently connected to */
unsigned int connector_type; unsigned int connector_type;
unsigned int connector_type_id; unsigned int connector_type_id;
drmModeConnection connection; drmModeConnection connection;

View File

@ -1046,7 +1046,6 @@ int drm_mode_getcrtc(struct drm_device *dev,
else else
crtc_resp->fb_id = 0; crtc_resp->fb_id = 0;
crtc_resp->connectors = 0;
if (crtc->enabled) { if (crtc->enabled) {
drm_crtc_convert_to_umode(&crtc_resp->mode, &crtc->mode); drm_crtc_convert_to_umode(&crtc_resp->mode, &crtc->mode);
@ -1099,11 +1098,11 @@ int drm_mode_getconnector(struct drm_device *dev,
memset(&u_mode, 0, sizeof(struct drm_mode_modeinfo)); memset(&u_mode, 0, sizeof(struct drm_mode_modeinfo));
DRM_DEBUG("connector id %d:\n", out_resp->connector); DRM_DEBUG("connector id %d:\n", out_resp->connector_id);
mutex_lock(&dev->mode_config.mutex); mutex_lock(&dev->mode_config.mutex);
obj = drm_mode_object_find(dev, out_resp->connector, DRM_MODE_OBJECT_CONNECTOR); obj = drm_mode_object_find(dev, out_resp->connector_id, DRM_MODE_OBJECT_CONNECTOR);
if (!obj) { if (!obj) {
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
@ -1130,6 +1129,7 @@ int drm_mode_getconnector(struct drm_device *dev,
list_for_each_entry(mode, &connector->modes, head) list_for_each_entry(mode, &connector->modes, head)
mode_count++; mode_count++;
out_resp->connector_id = connector->base.id;
out_resp->connector_type = connector->connector_type; out_resp->connector_type = connector->connector_type;
out_resp->connector_type_id = connector->connector_type_id; out_resp->connector_type_id = connector->connector_type_id;
out_resp->mm_width = connector->display_info.width_mm; out_resp->mm_width = connector->display_info.width_mm;
@ -1137,9 +1137,9 @@ int drm_mode_getconnector(struct drm_device *dev,
out_resp->subpixel = connector->display_info.subpixel_order; out_resp->subpixel = connector->display_info.subpixel_order;
out_resp->connection = connector->status; out_resp->connection = connector->status;
if (connector->encoder) if (connector->encoder)
out_resp->encoder = connector->encoder->base.id; out_resp->encoder_id = connector->encoder->base.id;
else else
out_resp->encoder = 0; out_resp->encoder_id = 0;
/* this ioctl is called twice, once to determine how much space is needed, and the 2nd time to fill it */ /* this ioctl is called twice, once to determine how much space is needed, and the 2nd time to fill it */
if ((out_resp->count_modes >= mode_count) && mode_count) { if ((out_resp->count_modes >= mode_count) && mode_count) {
@ -1215,13 +1215,13 @@ int drm_mode_getencoder(struct drm_device *dev,
encoder = obj_to_encoder(obj); encoder = obj_to_encoder(obj);
if (encoder->crtc) if (encoder->crtc)
enc_resp->crtc = encoder->crtc->base.id; enc_resp->crtc_id = encoder->crtc->base.id;
else else
enc_resp->crtc = 0; enc_resp->crtc_id = 0;
enc_resp->encoder_type = encoder->encoder_type; enc_resp->encoder_type = encoder->encoder_type;
enc_resp->encoder_id = encoder->base.id; enc_resp->encoder_id = encoder->base.id;
enc_resp->crtcs = encoder->possible_crtcs; enc_resp->possible_crtcs = encoder->possible_crtcs;
enc_resp->clones = encoder->possible_clones; enc_resp->possible_clones = encoder->possible_clones;
out: out:
mutex_unlock(&dev->mode_config.mutex); mutex_unlock(&dev->mode_config.mutex);

View File

@ -1059,17 +1059,13 @@ struct drm_mode_card_res {
struct drm_mode_crtc { struct drm_mode_crtc {
uint64_t set_connectors_ptr; uint64_t set_connectors_ptr;
int count_connectors;
unsigned int crtc_id; /**< Id */ unsigned int crtc_id; /**< Id */
unsigned int fb_id; /**< Id of framebuffer */ unsigned int fb_id; /**< Id of framebuffer */
int x, y; /**< Position on the frameuffer */ int x, y; /**< Position on the frameuffer */
int count_connectors;
unsigned int connectors; /**< Connectors that are connected */
int count_possibles;
unsigned int possibles; /**< Connectors that can be connected */
uint32_t gamma_size; uint32_t gamma_size;
int mode_valid; int mode_valid;
struct drm_mode_modeinfo mode; struct drm_mode_modeinfo mode;
@ -1083,12 +1079,13 @@ struct drm_mode_crtc {
struct drm_mode_get_encoder { struct drm_mode_get_encoder {
uint32_t encoder_type; unsigned int encoder_type;
uint32_t encoder_id; unsigned int encoder_id;
unsigned int crtc; /**< Id of crtc */ unsigned int crtc_id; /**< Id of crtc */
uint32_t crtcs;
uint32_t clones; uint32_t possible_crtcs;
uint32_t possible_clones;
}; };
/* This is for connectors with multiple signal types. */ /* This is for connectors with multiple signal types. */
@ -1126,8 +1123,8 @@ struct drm_mode_get_connector {
int count_props; int count_props;
int count_encoders; int count_encoders;
unsigned int encoder; /**< Current Encoder */ unsigned int encoder_id; /**< Current Encoder */
unsigned int connector; /**< Id */ unsigned int connector_id; /**< Id */
unsigned int connector_type; unsigned int connector_type;
unsigned int connector_type_id; unsigned int connector_type_id;

View File

@ -17,6 +17,7 @@ int full_modes;
int encoders; int encoders;
int crtcs; int crtcs;
int fbs; int fbs;
char *module_name;
const char* getConnectionText(drmModeConnection conn) const char* getConnectionText(drmModeConnection conn)
{ {
@ -115,7 +116,7 @@ int printConnector(int fd, drmModeResPtr res, drmModeConnectorPtr connector, uin
printf("Connector: %d-%d\n", connector->connector_type, connector->connector_type_id); printf("Connector: %d-%d\n", connector->connector_type, connector->connector_type_id);
printf("\tid : %i\n", id); printf("\tid : %i\n", id);
printf("\tencoder id : %i\n", connector->encoder); printf("\tencoder id : %i\n", connector->encoder_id);
printf("\tconn : %s\n", getConnectionText(connector->connection)); printf("\tconn : %s\n", getConnectionText(connector->connection));
printf("\tsize : %ix%i (mm)\n", connector->mmWidth, connector->mmHeight); printf("\tsize : %ix%i (mm)\n", connector->mmWidth, connector->mmHeight);
printf("\tcount_modes : %i\n", connector->count_modes); printf("\tcount_modes : %i\n", connector->count_modes);
@ -159,10 +160,10 @@ int printEncoder(int fd, drmModeResPtr res, drmModeEncoderPtr encoder, uint32_t
{ {
printf("Encoder\n"); printf("Encoder\n");
printf("\tid :%i\n", id); printf("\tid :%i\n", id);
printf("\tcrtc :%d\n", encoder->crtc); printf("\tcrtc_id :%d\n", encoder->crtc_id);
printf("\ttype :%d\n", encoder->encoder_type); printf("\ttype :%d\n", encoder->encoder_type);
printf("\tcrtcs :%d\n", encoder->crtcs); printf("\tpossible_crtcs :%d\n", encoder->possible_crtcs);
printf("\tclones :%d\n", encoder->clones); printf("\tpossible_clones :%d\n", encoder->possible_clones);
return 0; return 0;
} }
@ -283,7 +284,9 @@ void args(int argc, char **argv)
full_props = 0; full_props = 0;
connectors = 0; connectors = 0;
for (i = 1; i < argc; i++) { module_name = argv[1];
for (i = 2; i < argc; i++) {
if (strcmp(argv[i], "-fb") == 0) { if (strcmp(argv[i], "-fb") == 0) {
fbs = 1; fbs = 1;
} else if (strcmp(argv[i], "-crtcs") == 0) { } else if (strcmp(argv[i], "-crtcs") == 0) {
@ -316,9 +319,9 @@ void args(int argc, char **argv)
full_props = 1; full_props = 1;
connectors = 1; connectors = 1;
} }
} }
if (argc == 1) { if (argc == 2) {
fbs = 1; fbs = 1;
edid = 1; edid = 1;
crtcs = 1; crtcs = 1;
@ -329,16 +332,22 @@ void args(int argc, char **argv)
connectors = 1; connectors = 1;
} }
} }
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int fd; int fd;
drmModeResPtr res; drmModeResPtr res;
if (argc == 1) {
printf("Please add modulename as first argument\n");
return 1;
}
args(argc, argv); args(argc, argv);
printf("Starting test\n"); printf("Starting test\n");
fd = drmOpen("i915", NULL); fd = drmOpen(module_name, NULL);
if (fd < 0) { if (fd < 0) {
printf("Failed to open the card fd (%d)\n",fd); printf("Failed to open the card fd (%d)\n",fd);