From f6e8023e03278731db38dcc0c429025f36817c65 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 5 Jun 2007 12:26:18 +1000 Subject: take the lock earlier in ttmtest --- tests/ttmtest/src/ttmtest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/ttmtest/src/ttmtest.c b/tests/ttmtest/src/ttmtest.c index 606fb0cb..052947b1 100644 --- a/tests/ttmtest/src/ttmtest.c +++ b/tests/ttmtest/src/ttmtest.c @@ -176,7 +176,7 @@ benchmarkBuffer(TinyDRIContext * ctx, unsigned long size, /* * Test system memory objects. */ - + BM_CKFATAL(drmGetLock(ctx->drmFD, ctx->hwContext, 0)); oldTime = fastrdtsc(); BM_CKFATAL(drmBOCreate(ctx->drmFD, 0, size, 0, NULL, drm_bo_type_dc, @@ -216,7 +216,7 @@ benchmarkBuffer(TinyDRIContext * ctx, unsigned long size, * Test TT bound buffer objects. */ - BM_CKFATAL(drmGetLock(ctx->drmFD, ctx->hwContext, 0)); + // BM_CKFATAL(drmGetLock(ctx->drmFD, ctx->hwContext, 0)); oldTime = fastrdtsc(); BM_CKFATAL(drmBOValidate(ctx->drmFD, &buf, DRM_BO_FLAG_MEM_TT, DRM_BO_MASK_MEM, DRM_BO_HINT_DONT_FENCE)); -- cgit v1.2.3 From 2a2d02bbc500140a861380df52ce66abcac39312 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Mon, 24 Sep 2007 14:53:10 +0200 Subject: Added small modesetting test --- tests/mode/Makefile | 11 ++ tests/mode/modetest.c | 337 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/mode/test | 1 + 3 files changed, 349 insertions(+) create mode 100644 tests/mode/Makefile create mode 100644 tests/mode/modetest.c create mode 100755 tests/mode/test (limited to 'tests') diff --git a/tests/mode/Makefile b/tests/mode/Makefile new file mode 100644 index 00000000..205c2ba1 --- /dev/null +++ b/tests/mode/Makefile @@ -0,0 +1,11 @@ + +all: modetest + +#CFLAGS = -g -ansi -pedantic -DPOSIX_C_SOURCE=199309L \ +# -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE \ + +modetest: modetest.c + @gcc -o modetest -Wall -I../../libdrm -I../../shared-core -L../../libdrm/.libs -ldrm modetest.c + +clean: + @rm -f modetest diff --git a/tests/mode/modetest.c b/tests/mode/modetest.c new file mode 100644 index 00000000..bf1a5169 --- /dev/null +++ b/tests/mode/modetest.c @@ -0,0 +1,337 @@ + +#include +#include +#include +#include + +#include "xf86drm.h" +#include "xf86drmMode.h" + +const char* getConnectionText(drmModeConnection conn) +{ + switch (conn) { + case DRM_MODE_CONNECTED: + return "connected"; + case DRM_MODE_DISCONNECTED: + return "disconnected"; + default: + return "unknown"; + } + +} + +struct drm_mode_modeinfo* findMode(drmModeResPtr res, uint32_t id) +{ + int i; + for (i = 0; i < res->count_modes; i++) { + if (res->modes[i].id == id) + return &res->modes[i]; + } + + return 0; +} + +int printMode(struct drm_mode_modeinfo *mode) +{ +#if 0 + printf("Mode: %s\n", mode->name); + printf("\tclock : %i\n", mode->clock); + printf("\thdisplay : %i\n", mode->hdisplay); + printf("\thsync_start : %i\n", mode->hsync_start); + printf("\thsync_end : %i\n", mode->hsync_end); + printf("\thtotal : %i\n", mode->htotal); + printf("\thskew : %i\n", mode->hskew); + printf("\tvdisplay : %i\n", mode->vdisplay); + printf("\tvsync_start : %i\n", mode->vsync_start); + printf("\tvsync_end : %i\n", mode->vsync_end); + printf("\tvtotal : %i\n", mode->vtotal); + printf("\tvscan : %i\n", mode->vscan); + printf("\tvrefresh : %i\n", mode->vrefresh); + printf("\tflags : %i\n", mode->flags); +#else + printf("Mode: %i \"%s\" %ix%i %.0f\n", mode->id, mode->name, + mode->hdisplay, mode->vdisplay, mode->vrefresh / 1000.0); +#endif + return 0; +} + +int printOutput(int fd, drmModeResPtr res, drmModeOutputPtr output, uint32_t id) +{ + int i = 0; + struct drm_mode_modeinfo *mode = NULL; + + printf("Output: %s\n", output->name); + printf("\tid : %i\n", id); + printf("\tcrtc id : %i\n", output->crtc); + printf("\tconn : %s\n", getConnectionText(output->connection)); + printf("\tsize : %ix%i (mm)\n", output->mmWidth, output->mmHeight); + printf("\tcount_crtcs : %i\n", output->count_crtcs); + printf("\tcrtcs : %i\n", output->crtcs); + printf("\tcount_clones : %i\n", output->count_clones); + printf("\tclones : %i\n", output->clones); + printf("\tcount_modes : %i\n", output->count_modes); + + for (i = 0; i < output->count_modes; i++) { + mode = findMode(res, output->modes[i]); + + if (mode) + printf("\t\tmode: %i \"%s\" %ix%i %.0f\n", mode->id, mode->name, + mode->hdisplay, mode->vdisplay, mode->vrefresh / 1000.0); + else + printf("\t\tmode: Invalid mode %i\n", output->modes[i]); + } + + return 0; +} + +int printCrtc(int fd, drmModeResPtr res, drmModeCrtcPtr crtc, uint32_t id) +{ + printf("Crtc\n"); + printf("\tid : %i\n", id); + printf("\tx : %i\n", crtc->x); + printf("\ty : %i\n", crtc->y); + printf("\twidth : %i\n", crtc->width); + printf("\theight : %i\n", crtc->height); + printf("\tmode : %i\n", crtc->mode); + printf("\tnum outputs : %i\n", crtc->count_outputs); + printf("\toutputs : %i\n", crtc->outputs); + printf("\tnum possible : %i\n", crtc->count_possibles); + printf("\tpossibles : %i\n", crtc->possibles); + + return 0; +} + +int printFrameBuffer(int fd, drmModeResPtr res, drmModeFBPtr fb) +{ + printf("Framebuffer\n"); + printf("\thandle : %i\n", fb->handle); + printf("\twidth : %i\n", fb->width); + printf("\theight : %i\n", fb->height); + printf("\tpitch : %i\n", fb->pitch);; + printf("\tbpp : %i\n", fb->bpp); + printf("\tdepth : %i\n", fb->depth); + printf("\tbuffer_id : %i\n", fb->buffer_id); + + return 0; +} + +int printRes(int fd, drmModeResPtr res) +{ + int i; + drmModeOutputPtr output; + drmModeCrtcPtr crtc; + drmModeFBPtr fb; + + for (i = 0; i < res->count_modes; i++) { + printMode(&res->modes[i]); + } + + for (i = 0; i < res->count_outputs; i++) { + output = drmModeGetOutput(fd, res->outputs[i]); + + if (!output) + printf("Could not get output %i\n", i); + else { + printOutput(fd, res, output, res->outputs[i]); + drmModeFreeOutput(output); + } + } + + for (i = 0; i < res->count_crtcs; i++) { + crtc = drmModeGetCrtc(fd, res->crtcs[i]); + + if (!crtc) + printf("Could not get crtc %i\n", i); + else { + printCrtc(fd, res, crtc, res->crtcs[i]); + drmModeFreeCrtc(crtc); + } + } + + for (i = 0; i < res->count_fbs; i++) { + fb = drmModeGetFB(fd, res->fbs[i]); + + if (!fb) + printf("Could not get fb %i\n", res->fbs[i]); + else { + printFrameBuffer(fd, res, fb); + drmModeFreeFB(fb); + } + } + + return 0; +} + +static struct drm_mode_modeinfo mode = { + .name = "Test mode", + .clock = 25200, + .hdisplay = 640, + .hsync_start = 656, + .hsync_end = 752, + .htotal = 800, + .hskew = 0, + .vdisplay = 480, + .vsync_start = 490, + .vsync_end = 492, + .vtotal = 525, + .vscan = 0, + .vrefresh = 60000, /* vertical refresh * 1000 */ + .flags = 10, +}; + +int testMode(int fd, drmModeResPtr res) +{ + uint32_t output = res->outputs[0]; + uint32_t newMode = 0; + int ret = 0; + int error = 0; + + printf("Test: adding mode to output %i\n", output); + + /* printMode(&mode); */ + + printf("\tAdding mode\n"); + newMode = drmModeAddMode(fd, &mode); + if (!newMode) + goto err; + + printf("\tAttaching mode %i to output %i\n", newMode, output); + + ret = drmModeAttachMode(fd, output, newMode); + + if (ret) + goto err_mode; + + printf("\tDetaching mode %i from output %i\n", newMode, output); + ret = drmModeDetachMode(fd, output, newMode); + + if (ret) + goto err_mode; + + printf("\tRemoveing new mode %i\n", newMode); + ret = drmModeRmMode(fd, newMode); + if (ret) + goto err; + + return 0; + +err_mode: + error = drmModeRmMode(fd, newMode); + +err: + printf("\tFailed\n"); + + if (error) + printf("\tFailed to delete mode %i\n", newMode); + + return 1; +} + +/* +int testFrameBufferGet(int fd, uint32_t fb) +{ + drmModeFBPtr frame; + + printf("Test: get framebuffer %i\n", fb); + + frame = drmModeGetFB(fd, fb); + + if (!frame) { + printf("\tFailed\n"); + } else { + printFrameBuffer(fd, frame); + drmModeFreeFB(frame); + } + + return 0; +} +*/ + +int testFrameBufferAdd(int fd, drmModeResPtr res) +{ + uint32_t fb = 0; + int ret = 0; + drmModeFBPtr frame = 0; + drmBO bo; + + printf("Test: adding framebuffer\n"); + + printf("\tCreating BO\n"); + + /* TODO */ + ret = 1; + if (ret) + goto err; + + printf("\tAdding FB\n"); + ret = drmModeAddFB(fd, 640, 480, 32, 8, 0, &bo, &fb); + if (ret) + goto err_bo; + + frame = drmModeGetFB(fd, fb); + + if (!frame) { + printf("Couldn't retrive created framebuffer\n"); + } else { + printFrameBuffer(fd, res, frame); + drmModeFreeFB(frame); + } + + printf("\tRemoveing FB\n"); + + ret = drmModeRmFB(fd, fb); + + if (ret) { + printf("\tFailed this shouldn't happen!\n"); + goto err_bo; + } + + printf("\tRemoveing BO\n"); + + ret = drmBODestroy(fb, &bo); + + return 0; + +err_bo: + drmBODestroy(fd, &bo); + +err: + printf("\tFailed\n"); + + return 1; +} + + +int main(int argc, char **argv) +{ + int fd; + const char *driver = "i915"; /* hardcoded for now */ + drmModeResPtr res; + + printf("Starting test\n"); + + fd = drmOpen(driver, NULL); + + if (fd < 0) { + printf("Failed to open the card fb\n"); + return 1; + } + + res = drmModeGetResources(fd); + if (res == 0) { + printf("Failed to get resources from card\n"); + drmClose(fd); + return 1; + } + + printRes(fd, res); + + testMode(fd, res); + + testFrameBufferAdd(fd, res); + + drmModeFreeResources(res); + printf("Ok\n"); + + return 0; +} diff --git a/tests/mode/test b/tests/mode/test new file mode 100755 index 00000000..fa155f4e --- /dev/null +++ b/tests/mode/test @@ -0,0 +1 @@ +LD_PRELOAD=../../libdrm/.libs/libdrm.so ./modetest -- cgit v1.2.3 From d275bb8fb87d8dc23e9a62c5f82627e36c8dc589 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 15 Nov 2007 16:51:15 +1100 Subject: tests: update for new drm interface --- tests/mode/modetest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/mode/modetest.c b/tests/mode/modetest.c index bf1a5169..8f151758 100644 --- a/tests/mode/modetest.c +++ b/tests/mode/modetest.c @@ -288,12 +288,12 @@ int testFrameBufferAdd(int fd, drmModeResPtr res) printf("\tRemoveing BO\n"); - ret = drmBODestroy(fb, &bo); + ret = drmBOUnreference(fb, &bo); return 0; err_bo: - drmBODestroy(fd, &bo); + drmBOUnreference(fd, &bo); err: printf("\tFailed\n"); -- cgit v1.2.3 From b3af2b59a77a6916ea7151236d3da9bde6a537fc Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 27 Nov 2007 14:31:02 +1000 Subject: drm/modesetting: add initial gettable properites code. This allow the user to retrieve a list of properties for an output. Properties can either be 32-bit values or an enum with an associated name. Range properties are to be supported. This API is probably not all correct, I may make properties part of the general resource get when I think about it some more. So basically you can create properties and attached them to whatever outputs you want, so it should be possible to create some generics and just attach them to every output. --- libdrm/xf86drmMode.c | 77 +++++++++++++++++-- libdrm/xf86drmMode.h | 17 +++++ linux-core/drm_crtc.c | 207 ++++++++++++++++++++++++++++++++++++++++++++++++-- linux-core/drm_crtc.h | 34 +++++++++ linux-core/drm_drv.c | 1 + shared-core/drm.h | 29 +++++++ tests/mode/modetest.c | 34 ++++++++- 7 files changed, 387 insertions(+), 12 deletions(-) (limited to 'tests') diff --git a/libdrm/xf86drmMode.c b/libdrm/xf86drmMode.c index e400f219..f697232d 100644 --- a/libdrm/xf86drmMode.c +++ b/libdrm/xf86drmMode.c @@ -316,7 +316,7 @@ int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId, drmModeOutputPtr drmModeGetOutput(int fd, uint32_t output_id) { struct drm_mode_get_output out; - drmModeOutputPtr r = 0; + drmModeOutputPtr r = NULL; out.output = output_id; out.count_crtcs = 0; @@ -325,18 +325,27 @@ drmModeOutputPtr drmModeGetOutput(int fd, uint32_t output_id) out.clones = 0; out.count_modes = 0; out.modes = 0; + out.count_props = 0; + out.props = NULL; + out.prop_values = NULL; if (ioctl(fd, DRM_IOCTL_MODE_GETOUTPUT, &out)) return 0; + if (out.count_props) { + out.props = drmMalloc(out.count_props*sizeof(uint32_t)); + out.prop_values = drmMalloc(out.count_props*sizeof(uint32_t)); + } + if (out.count_modes) out.modes = drmMalloc(out.count_modes*sizeof(uint32_t)); if (ioctl(fd, DRM_IOCTL_MODE_GETOUTPUT, &out)) goto err_allocs; - if(!(r = drmMalloc(sizeof(*r)))) - return 0; + if(!(r = drmMalloc(sizeof(*r)))) { + goto err_allocs; + } r->output_id = out.output; r->crtc = out.crtc; @@ -350,15 +359,19 @@ drmModeOutputPtr drmModeGetOutput(int fd, uint32_t output_id) /* 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(out.props, out.count_props, sizeof(uint32_t)); + r->prop_values = drmAllocCpy(out.prop_values, out.count_props, sizeof(uint32_t)); r->modes = drmAllocCpy(out.modes, out.count_modes, sizeof(uint32_t)); strncpy(r->name, out.name, DRM_OUTPUT_NAME_LEN); r->name[DRM_OUTPUT_NAME_LEN-1] = 0; - return r; err_allocs: + drmFree(out.prop_values); + drmFree(out.props); drmFree(out.modes); - return 0; + return r; } uint32_t drmModeAddMode(int fd, struct drm_mode_modeinfo *mode_info) @@ -396,3 +409,57 @@ int drmModeDetachMode(int fd, uint32_t output_id, uint32_t mode_id) } +drmModePropertyPtr drmModeGetProperty(int fd, uint32_t property_id) +{ + struct drm_mode_get_property prop; + drmModePropertyPtr r; + + prop.prop_id = property_id; + prop.count_enums = 0; + prop.count_values = 0; + prop.flags = 0; + prop.enums = NULL; + prop.values = NULL; + + if (ioctl(fd, DRM_IOCTL_MODE_GETPROPERTY, &prop)) + return 0; + + if (prop.count_values) + prop.values = drmMalloc(prop.count_values * sizeof(uint32_t)); + + if (prop.count_enums) + prop.enums = drmMalloc(prop.count_enums * sizeof(struct drm_mode_property_enum)); + + if (ioctl(fd, DRM_IOCTL_MODE_GETPROPERTY, &prop)) { + r = NULL; + goto err_allocs; + } + + if (!(r = drmMalloc(sizeof(*r)))) + return NULL; + + r->prop_id = prop.prop_id; + r->count_values = prop.count_values; + r->count_enums = prop.count_enums; + + r->values = drmAllocCpy(prop.values, prop.count_values, sizeof(uint32_t)); + r->enums = drmAllocCpy(prop.enums, prop.count_enums, sizeof(struct drm_mode_property_enum)); + strncpy(r->name, prop.name, DRM_PROP_NAME_LEN); + r->name[DRM_PROP_NAME_LEN-1] = 0; + +err_allocs: + drmFree(prop.values); + drmFree(prop.enums); + + return r; +} + +void drmModeFreeProperty(drmModePropertyPtr ptr) +{ + if (!ptr) + return; + + drmFree(ptr->values); + drmFree(ptr->enums); + drmFree(ptr); +} diff --git a/libdrm/xf86drmMode.h b/libdrm/xf86drmMode.h index be9d84af..5e966e95 100644 --- a/libdrm/xf86drmMode.h +++ b/libdrm/xf86drmMode.h @@ -70,6 +70,17 @@ typedef struct _drmModeRes { typedef struct drm_mode_fb_cmd drmModeFB, *drmModeFBPtr; +typedef struct _drmModeProperty { + unsigned int prop_id; + unsigned int flags; + unsigned char name[DRM_PROP_NAME_LEN]; + int count_values; + uint32_t *values; + int count_enums; + struct drm_mode_property_enum *enums; + +} drmModePropertyRes, *drmModePropertyPtr; + typedef struct _drmModeCrtc { unsigned int crtc_id; unsigned int buffer_id; /**< FB id to connect to 0 = disconnect*/ @@ -121,6 +132,10 @@ typedef struct _drmModeOutput { int count_modes; uint32_t *modes; /**< List of modes ids */ + int count_props; + uint32_t *props; /**< List of property ids */ + uint32_t *prop_values; /**< List of property values */ + } drmModeOutput, *drmModeOutputPtr; @@ -207,3 +222,5 @@ extern int drmModeAttachMode(int fd, uint32_t outputId, uint32_t modeId); */ extern int drmModeDetachMode(int fd, uint32_t outputId, uint32_t modeId); +extern drmModePropertyPtr drmModeGetProperty(int fd, uint32_t propertyId); +extern void drmModeFreeProperty(drmModePropertyPtr ptr); diff --git a/linux-core/drm_crtc.c b/linux-core/drm_crtc.c index bc292703..cd60f522 100644 --- a/linux-core/drm_crtc.c +++ b/linux-core/drm_crtc.c @@ -711,6 +711,7 @@ void drm_mode_config_init(struct drm_device *dev) INIT_LIST_HEAD(&dev->mode_config.fb_list); INIT_LIST_HEAD(&dev->mode_config.crtc_list); INIT_LIST_HEAD(&dev->mode_config.output_list); + INIT_LIST_HEAD(&dev->mode_config.property_list); INIT_LIST_HEAD(&dev->mode_config.usermode_list); idr_init(&dev->mode_config.crtc_idr); } @@ -944,14 +945,20 @@ void drm_mode_config_cleanup(struct drm_device *dev) struct drm_crtc *crtc, *ct; struct drm_framebuffer *fb, *fbt; struct drm_display_mode *mode, *mt; + struct drm_property *property, *pt; + list_for_each_entry_safe(output, ot, &dev->mode_config.output_list, head) { drm_output_destroy(output); } + list_for_each_entry_safe(property, pt, &dev->mode_config.property_list, head) { + drm_property_destroy(dev, property); + } + list_for_each_entry_safe(mode, mt, &dev->mode_config.usermode_list, head) { drm_mode_destroy(dev, mode); } - + list_for_each_entry_safe(fb, fbt, &dev->mode_config.fb_list, head) { if (fb->bo->type != drm_bo_type_kernel) drm_framebuffer_destroy(fb); @@ -1331,6 +1338,7 @@ int drm_mode_getoutput(struct drm_device *dev, struct drm_output *output; struct drm_display_mode *mode; int mode_count = 0; + int props_count = 0; int ret = 0; int copied = 0; int i; @@ -1341,7 +1349,7 @@ int drm_mode_getoutput(struct drm_device *dev, output= idr_find(&dev->mode_config.crtc_idr, out_resp->output); if (!output || (output->id != out_resp->output)) { ret = -EINVAL; - goto done; + goto out; } list_for_each_entry(mode, &output->modes, head) @@ -1351,6 +1359,12 @@ int drm_mode_getoutput(struct drm_device *dev, if (output->user_mode_ids[i] != 0) mode_count++; + for (i = 0; i < DRM_OUTPUT_MAX_PROPERTY; i++) { + if (output->property_ids[i] != 0) { + props_count++; + } + } + strncpy(out_resp->name, output->name, DRM_OUTPUT_NAME_LEN); out_resp->name[DRM_OUTPUT_NAME_LEN-1] = 0; @@ -1365,20 +1379,42 @@ int drm_mode_getoutput(struct drm_device *dev, out_resp->crtcs = output->possible_crtcs; out_resp->clones = output->possible_clones; + if ((out_resp->count_modes >= mode_count) && mode_count) { copied = 0; list_for_each_entry(mode, &output->modes, head) { out_resp->modes[copied++] = mode->mode_id; } for (i = 0; i < DRM_OUTPUT_MAX_UMODES; i++) { - if (output->user_mode_ids[i] != 0) - out_resp->modes[copied++] = output->user_mode_ids[i]; + if (output->user_mode_ids[i] != 0) { + if (put_user(output->user_mode_ids[i], out_resp->modes + copied)) + return -EFAULT; + copied++; + } } - } out_resp->count_modes = mode_count; -done: + if ((out_resp->count_props >= props_count) && props_count) { + copied = 0; + for (i = 0; i < DRM_OUTPUT_MAX_PROPERTY; i++) { + if (output->property_ids[i] != 0) { + if (put_user(output->property_ids[i], out_resp->props + copied)) { + ret = -EFAULT; + goto out; + } + + if (put_user(output->property_values[i], out_resp->prop_values + copied)) { + ret = -EFAULT; + goto out; + } + copied++; + } + } + } + out_resp->count_props = props_count; + +out: mutex_unlock(&dev->mode_config.mutex); return ret; } @@ -1783,6 +1819,7 @@ int drm_mode_detachmode_crtc(struct drm_device *dev, struct drm_display_mode *mo list_for_each_entry(output, &dev->mode_config.output_list, head) { drm_mode_detachmode(dev, output, mode); } + return 0; } EXPORT_SYMBOL(drm_mode_detachmode_crtc); @@ -1949,3 +1986,161 @@ out: mutex_unlock(&dev->mode_config.mutex); return ret; } + +struct drm_property *drm_property_create(struct drm_device *dev, int flags, + const char *name, int num_values) +{ + struct drm_property *property = NULL; + + property = kzalloc(sizeof(struct drm_output), GFP_KERNEL); + if (!property) + return NULL; + + property->values = kzalloc(sizeof(uint32_t)*num_values, GFP_KERNEL); + if (!property->values) + goto fail; + + property->id = drm_idr_get(dev, property); + property->flags = flags; + property->num_values = num_values; + INIT_LIST_HEAD(&property->enum_list); + + if (name) + strncpy(property->name, name, DRM_PROP_NAME_LEN); + + list_add_tail(&property->head, &dev->mode_config.property_list); + return property; +fail: + kfree(property); + return NULL; +} +EXPORT_SYMBOL(drm_property_create); + +int drm_property_add_enum(struct drm_property *property, int index, + uint32_t value, const char *name) +{ + struct drm_property_enum *prop_enum; + + if (!(property->flags & DRM_MODE_PROP_ENUM)) + return -EINVAL; + + if (!list_empty(&property->enum_list)) { + list_for_each_entry(prop_enum, &property->enum_list, head) { + if (prop_enum->value == value) { + strncpy(prop_enum->name, name, DRM_PROP_NAME_LEN); + prop_enum->name[DRM_PROP_NAME_LEN-1] = '\0'; + return 0; + } + } + } + + prop_enum = kzalloc(sizeof(struct drm_property_enum), GFP_KERNEL); + if (!prop_enum) + return -ENOMEM; + + strncpy(prop_enum->name, name, DRM_PROP_NAME_LEN); + prop_enum->name[DRM_PROP_NAME_LEN-1] = '\0'; + prop_enum->value = value; + + property->values[index] = value; + list_add_tail(&prop_enum->head, &property->enum_list); + return 0; +} +EXPORT_SYMBOL(drm_property_add_enum); + +void drm_property_destroy(struct drm_device *dev, struct drm_property *property) +{ + struct drm_property_enum *prop_enum, *pt; + + list_for_each_entry_safe(prop_enum, pt, &property->enum_list, head) { + list_del(&prop_enum->head); + kfree(prop_enum); + } + + kfree(property->values); + drm_idr_put(dev, property->id); + list_del(&property->head); + kfree(property); +} +EXPORT_SYMBOL(drm_property_destroy); + + +int drm_output_attach_property(struct drm_output *output, + struct drm_property *property, int init_val) +{ + int i; + + for (i = 0; i < DRM_OUTPUT_MAX_PROPERTY; i++) { + if (output->property_ids[i] == 0) { + output->property_ids[i] = property->id; + output->property_values[i] = init_val; + break; + } + } + + if (i == DRM_OUTPUT_MAX_PROPERTY) + return -EINVAL; + return 0; +} +EXPORT_SYMBOL(drm_output_attach_property); + +int drm_mode_getproperty_ioctl(struct drm_device *dev, + void *data, struct drm_file *file_priv) +{ + struct drm_mode_get_property *out_resp = data; + struct drm_property *property; + int enum_count = 0; + int value_count = 0; + int ret = 0, i; + int copied; + struct drm_property_enum *prop_enum; + + mutex_lock(&dev->mode_config.mutex); + property = idr_find(&dev->mode_config.crtc_idr, out_resp->prop_id); + if (!property || (property->id != out_resp->prop_id)) { + ret = -EINVAL; + goto done; + } + + + list_for_each_entry(prop_enum, &property->enum_list, head) + enum_count++; + + value_count = property->num_values; + + strncpy(out_resp->name, property->name, DRM_PROP_NAME_LEN); + out_resp->name[DRM_PROP_NAME_LEN-1] = 0; + out_resp->flags = property->flags; + + if ((out_resp->count_values >= value_count) && value_count) { + for (i = 0; i < value_count; i++) { + if (put_user(property->values[i], out_resp->values + i)) { + ret = -EFAULT; + goto done; + } + } + } + out_resp->count_values = value_count; + + if ((out_resp->count_enums >= enum_count) && enum_count) { + copied = 0; + list_for_each_entry(prop_enum, &property->enum_list, head) { + if (put_user(prop_enum->value, &out_resp->enums[copied].value)) { + ret = -EFAULT; + goto done; + } + + if (copy_to_user(&out_resp->enums[copied].name, + prop_enum->name, DRM_PROP_NAME_LEN)) { + ret = -EFAULT; + goto done; + } + copied++; + } + } + out_resp->count_enums = enum_count; + +done: + mutex_unlock(&dev->mode_config.mutex); + return ret; +} diff --git a/linux-core/drm_crtc.h b/linux-core/drm_crtc.h index fc97525d..011903ce 100644 --- a/linux-core/drm_crtc.h +++ b/linux-core/drm_crtc.h @@ -233,6 +233,24 @@ struct drm_framebuffer { void *virtual_base; struct list_head filp_head; }; + +struct drm_property_enum { + struct list_head head; + uint32_t value; + unsigned char name[DRM_PROP_NAME_LEN]; +}; + +struct drm_property { + struct list_head head; + int id; /* idr assigned */ + uint32_t flags; + char name[DRM_PROP_NAME_LEN]; + uint32_t num_values; + uint32_t *values; + + struct list_head enum_list; +}; + struct drm_crtc; struct drm_output; @@ -376,6 +394,7 @@ struct drm_output_funcs { }; #define DRM_OUTPUT_MAX_UMODES 16 +#define DRM_OUTPUT_MAX_PROPERTY 16 #define DRM_OUTPUT_LEN 32 /** * drm_output - central DRM output control structure @@ -431,6 +450,8 @@ struct drm_output { u32 user_mode_ids[DRM_OUTPUT_MAX_UMODES]; + u32 property_ids[DRM_OUTPUT_MAX_PROPERTY]; + u32 property_values[DRM_OUTPUT_MAX_PROPERTY]; }; /** @@ -464,6 +485,9 @@ struct drm_mode_config { struct list_head crtc_list; struct list_head usermode_list; + + struct list_head property_list; + int min_width, min_height; int max_width, max_height; /* DamagePtr rotationDamage? */ @@ -529,6 +553,14 @@ extern int drmfb_remove(struct drm_device *dev, struct drm_framebuffer *fb); extern bool drm_crtc_set_mode(struct drm_crtc *crtc, struct drm_display_mode *mode, int x, int y); +extern int drm_output_attach_property(struct drm_output *output, + struct drm_property *property, int init_val); +extern struct drm_property *drm_property_create(struct drm_device *dev, int flags, + const char *name, int num_values); +extern void drm_property_destroy(struct drm_device *dev, struct drm_property *property); +extern int drm_property_add_enum(struct drm_property *property, int index, + uint32_t value, const char *name); + /* IOCTLs */ extern int drm_mode_getresources(struct drm_device *dev, void *data, struct drm_file *file_priv); @@ -554,5 +586,7 @@ extern int drm_mode_attachmode_ioctl(struct drm_device *dev, extern int drm_mode_detachmode_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv); +extern int drm_mode_getproperty_ioctl(struct drm_device *dev, + void *data, struct drm_file *file_priv); #endif /* __DRM_CRTC_H__ */ diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c index e606bc6a..b3e00e84 100644 --- a/linux-core/drm_drv.c +++ b/linux-core/drm_drv.c @@ -128,6 +128,7 @@ static struct drm_ioctl_desc drm_ioctls[] = { DRM_IOCTL_DEF(DRM_IOCTL_MODE_RMMODE, drm_mode_rmmode_ioctl, DRM_MASTER|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_IOCTL_MODE_ATTACHMODE, drm_mode_attachmode_ioctl, DRM_MASTER|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_IOCTL_MODE_DETACHMODE, drm_mode_detachmode_ioctl, DRM_MASTER|DRM_ROOT_ONLY), + DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETPROPERTY, drm_mode_getproperty_ioctl, DRM_MASTER | DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_IOCTL_MM_INIT, drm_mm_init_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), diff --git a/shared-core/drm.h b/shared-core/drm.h index 55675d2f..9219b456 100644 --- a/shared-core/drm.h +++ b/shared-core/drm.h @@ -897,6 +897,7 @@ struct drm_mm_init_arg { #define DRM_DISPLAY_INFO_LEN 32 #define DRM_OUTPUT_NAME_LEN 32 #define DRM_DISPLAY_MODE_LEN 32 +#define DRM_PROP_NAME_LEN 32 #define DRM_MODE_TYPE_BUILTIN (1<<0) #define DRM_MODE_TYPE_CLOCK_C ((1<<1) | DRM_MODE_TYPE_BUILTIN) @@ -976,6 +977,32 @@ struct drm_mode_get_output { int count_modes; unsigned int __user *modes; /**< list of modes it supports */ + int count_props; + unsigned int __user *props; + unsigned int __user *prop_values; +}; + +#define DRM_MODE_PROP_PENDING (1<<0) +#define DRM_MODE_PROP_RANGE (1<<1) +#define DRM_MODE_PROP_IMMUTABLE (1<<2) +#define DRM_MODE_PROP_ENUM (1<<3) // enumerated type with text strings + +struct drm_mode_property_enum { + uint32_t value; + unsigned char name[DRM_PROP_NAME_LEN]; +}; + +struct drm_mode_get_property { + + unsigned int prop_id; + unsigned int flags; + unsigned char name[DRM_PROP_NAME_LEN]; + + int count_values; + uint32_t __user *values; + + int count_enums; + struct drm_mode_property_enum *enums; }; struct drm_mode_fb_cmd { @@ -1096,6 +1123,8 @@ struct drm_mode_mode_cmd { #define DRM_IOCTL_MODE_RMMODE DRM_IOWR(0xA8, unsigned int) #define DRM_IOCTL_MODE_ATTACHMODE DRM_IOWR(0xA9, struct drm_mode_mode_cmd) #define DRM_IOCTL_MODE_DETACHMODE DRM_IOWR(0xAA, struct drm_mode_mode_cmd) + +#define DRM_IOCTL_MODE_GETPROPERTY DRM_IOWR(0xAB, struct drm_mode_get_property) /*@}*/ /** diff --git a/tests/mode/modetest.c b/tests/mode/modetest.c index 8f151758..50271af9 100644 --- a/tests/mode/modetest.c +++ b/tests/mode/modetest.c @@ -57,8 +57,10 @@ int printMode(struct drm_mode_modeinfo *mode) int printOutput(int fd, drmModeResPtr res, drmModeOutputPtr output, uint32_t id) { - int i = 0; + int i = 0, j; struct drm_mode_modeinfo *mode = NULL; + drmModePropertyPtr props; + unsigned char *name = NULL; printf("Output: %s\n", output->name); printf("\tid : %i\n", id); @@ -70,6 +72,36 @@ int printOutput(int fd, drmModeResPtr res, drmModeOutputPtr output, uint32_t id) printf("\tcount_clones : %i\n", output->count_clones); printf("\tclones : %i\n", output->clones); printf("\tcount_modes : %i\n", output->count_modes); + printf("\tcount_props : %i\n", output->count_props); + + for (i = 0; i < output->count_props; i++) { + props = drmModeGetProperty(fd, output->props[i]); + name = NULL; + if (props) { + printf("Property: %s\n", props->name); + printf("\tid: %i\n", props->prop_id); + printf("\tflags: %i\n", props->flags); + printf("\tvalues %d: ", props->count_values); + for (j = 0; j < props->count_values; j++) + printf("%d ", props->values[j]); + + printf("\n\tenums %d: \n", props->count_enums); + + for (j = 0; j < props->count_enums; j++) { + if (output->prop_values[i] == props->enums[j].value) + name = props->enums[j].name; + printf("\t\t%d = %s\n", props->enums[j].value, props->enums[j].name); + } + + if (props->count_enums && name) { + printf("\toutput property name %s %s\n", props->name, name); + } else { + printf("\toutput property id %s %i\n", props->name, output->prop_values[i]); + } + + drmModeFreeProperty(props); + } + } for (i = 0; i < output->count_modes; i++) { mode = findMode(res, output->modes[i]); -- cgit v1.2.3 From 91cd3e3c097d581ea75ec4bcbc1ba8d23b471a2e Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 28 Nov 2007 15:18:25 +1000 Subject: modesetting API change for removing mode ids and making modes per output. so really want to get a list of modes per output not the global hammer list. also we remove the mode ids and let the user pass back the full mode description need to fix up add/remove mode for user modes now --- libdrm/xf86drmMode.c | 22 ++-- libdrm/xf86drmMode.h | 14 ++- linux-core/drm_crtc.c | 270 +++++++++++++++++++++++--------------------------- shared-core/drm.h | 14 +-- tests/mode/modetest.c | 28 ++---- 5 files changed, 149 insertions(+), 199 deletions(-) (limited to 'tests') diff --git a/libdrm/xf86drmMode.c b/libdrm/xf86drmMode.c index f697232d..8b701381 100644 --- a/libdrm/xf86drmMode.c +++ b/libdrm/xf86drmMode.c @@ -101,7 +101,6 @@ void drmModeFreeResources(drmModeResPtr ptr) if (!ptr) return; - drmFree(ptr->modes); drmFree(ptr); } @@ -155,8 +154,6 @@ drmModeResPtr drmModeGetResources(int fd) res.crtc_id = drmMalloc(res.count_crtcs*sizeof(uint32_t)); if (res.count_outputs) res.output_id = drmMalloc(res.count_outputs*sizeof(uint32_t)); - if (res.count_modes) - res.modes = drmMalloc(res.count_modes*sizeof(*res.modes)); if (ioctl(fd, DRM_IOCTL_MODE_GETRESOURCES, &res)) { r = NULL; @@ -174,18 +171,15 @@ drmModeResPtr drmModeGetResources(int fd) r->count_fbs = res.count_fbs; r->count_crtcs = res.count_crtcs; r->count_outputs = res.count_outputs; - r->count_modes = res.count_modes; /* TODO we realy should test if these allocs fails. */ r->fbs = drmAllocCpy(res.fb_id, res.count_fbs, sizeof(uint32_t)); r->crtcs = drmAllocCpy(res.crtc_id, res.count_crtcs, sizeof(uint32_t)); r->outputs = drmAllocCpy(res.output_id, res.count_outputs, sizeof(uint32_t)); - r->modes = drmAllocCpy(res.modes, res.count_modes, sizeof(struct drm_mode_modeinfo)); err_allocs: drmFree(res.fb_id); drmFree(res.crtc_id); drmFree(res.output_id); - drmFree(res.modes); return r; } @@ -287,8 +281,8 @@ err_allocs: int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId, - uint32_t x, uint32_t y, uint32_t modeId, - uint32_t *outputs, int count) + uint32_t x, uint32_t y, uint32_t *outputs, int count, + struct drm_mode_modeinfo *mode) { struct drm_mode_crtc crtc; @@ -303,7 +297,11 @@ int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId, crtc.fb_id = bufferId; crtc.set_outputs = outputs; crtc.count_outputs = count; - crtc.mode = modeId; + if (mode) { + memcpy(&crtc.mode, mode, sizeof(struct drm_mode_modeinfo)); + crtc.mode_valid = 1; + } else + crtc.mode_valid = 0; return ioctl(fd, DRM_IOCTL_MODE_SETCRTC, &crtc); } @@ -338,7 +336,7 @@ drmModeOutputPtr drmModeGetOutput(int fd, uint32_t output_id) } if (out.count_modes) - out.modes = drmMalloc(out.count_modes*sizeof(uint32_t)); + out.modes = drmMalloc(out.count_modes*sizeof(struct drm_mode_modeinfo)); if (ioctl(fd, DRM_IOCTL_MODE_GETOUTPUT, &out)) goto err_allocs; @@ -362,7 +360,7 @@ drmModeOutputPtr drmModeGetOutput(int fd, uint32_t output_id) r->count_props = out.count_props; r->props = drmAllocCpy(out.props, out.count_props, sizeof(uint32_t)); r->prop_values = drmAllocCpy(out.prop_values, out.count_props, sizeof(uint32_t)); - r->modes = drmAllocCpy(out.modes, out.count_modes, sizeof(uint32_t)); + r->modes = drmAllocCpy(out.modes, out.count_modes, sizeof(struct drm_mode_modeinfo)); strncpy(r->name, out.name, DRM_OUTPUT_NAME_LEN); r->name[DRM_OUTPUT_NAME_LEN-1] = 0; @@ -374,6 +372,7 @@ err_allocs: return r; } +#if 0 uint32_t drmModeAddMode(int fd, struct drm_mode_modeinfo *mode_info) { if (ioctl(fd, DRM_IOCTL_MODE_ADDMODE, mode_info)) @@ -386,6 +385,7 @@ int drmModeRmMode(int fd, uint32_t mode_id) { return ioctl(fd, DRM_IOCTL_MODE_RMMODE, &mode_id); } +#endif int drmModeAttachMode(int fd, uint32_t output_id, uint32_t mode_id) { diff --git a/libdrm/xf86drmMode.h b/libdrm/xf86drmMode.h index 5e966e95..0777c596 100644 --- a/libdrm/xf86drmMode.h +++ b/libdrm/xf86drmMode.h @@ -63,9 +63,6 @@ typedef struct _drmModeRes { int count_outputs; uint32_t *outputs; - int count_modes; - struct drm_mode_modeinfo *modes; - } drmModeRes, *drmModeResPtr; typedef struct drm_mode_fb_cmd drmModeFB, *drmModeFBPtr; @@ -87,7 +84,8 @@ typedef struct _drmModeCrtc { uint32_t x, y; /**< Position on the frameuffer */ uint32_t width, height; - uint32_t mode; /**< Current mode used */ + int mode_valid; + struct drm_mode_modeinfo mode; int count_outputs; uint32_t outputs; /**< Outputs that are connected */ @@ -130,7 +128,7 @@ typedef struct _drmModeOutput { uint32_t clones; /**< Mask of clones */ int count_modes; - uint32_t *modes; /**< List of modes ids */ + struct drm_mode_modeinfo *modes; int count_props; uint32_t *props; /**< List of property ids */ @@ -185,9 +183,9 @@ extern drmModeCrtcPtr drmModeGetCrtc(int fd, uint32_t crtcId); /** * 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 *outputs, int count, + struct drm_mode_modeinfo *mode); /* diff --git a/linux-core/drm_crtc.c b/linux-core/drm_crtc.c index cd60f522..44268337 100644 --- a/linux-core/drm_crtc.c +++ b/linux-core/drm_crtc.c @@ -280,73 +280,79 @@ static struct drm_display_mode std_mode[] = { * * FIXME: take into account monitor limits */ -void drm_crtc_probe_output_modes(struct drm_device *dev, int maxX, int maxY) +void drm_crtc_probe_single_output_modes(struct drm_output *output, int maxX, int maxY) { - struct drm_output *output; + struct drm_device *dev = output->dev; struct drm_display_mode *mode, *t; int ret; //if (maxX == 0 || maxY == 0) // TODO - list_for_each_entry(output, &dev->mode_config.output_list, head) { - - /* set all modes to the unverified state */ - list_for_each_entry_safe(mode, t, &output->modes, head) - mode->status = MODE_UNVERIFIED; + /* set all modes to the unverified state */ + list_for_each_entry_safe(mode, t, &output->modes, head) + mode->status = MODE_UNVERIFIED; - output->status = (*output->funcs->detect)(output); - - if (output->status == output_status_disconnected) { - DRM_DEBUG("%s is disconnected\n", output->name); - /* TODO set EDID to NULL */ - continue; - } - - ret = (*output->funcs->get_modes)(output); - - if (ret) { - drm_mode_output_list_update(output); - } - - if (maxX && maxY) - drm_mode_validate_size(dev, &output->modes, maxX, - maxY, 0); - list_for_each_entry_safe(mode, t, &output->modes, head) { - if (mode->status == MODE_OK) - mode->status = (*output->funcs->mode_valid)(output,mode); - } + output->status = (*output->funcs->detect)(output); + + if (output->status == output_status_disconnected) { + DRM_DEBUG("%s is disconnected\n", output->name); + /* TODO set EDID to NULL */ + return; + } + + ret = (*output->funcs->get_modes)(output); + + if (ret) { + drm_mode_output_list_update(output); + } + + if (maxX && maxY) + drm_mode_validate_size(dev, &output->modes, maxX, + maxY, 0); + list_for_each_entry_safe(mode, t, &output->modes, head) { + if (mode->status == MODE_OK) + mode->status = (*output->funcs->mode_valid)(output,mode); + } + + + drm_mode_prune_invalid(dev, &output->modes, TRUE); + + if (list_empty(&output->modes)) { + struct drm_display_mode *stdmode; + DRM_DEBUG("No valid modes on %s\n", output->name); + + /* Should we do this here ??? + * When no valid EDID modes are available we end up + * here and bailed in the past, now we add a standard + * 640x480@60Hz mode and carry on. + */ + stdmode = drm_mode_duplicate(dev, &std_mode[0]); + drm_mode_probed_add(output, stdmode); + drm_mode_list_concat(&output->probed_modes, + &output->modes); + + DRM_DEBUG("Adding standard 640x480 @ 60Hz to %s\n", + output->name); + } + + drm_mode_sort(&output->modes); + + DRM_DEBUG("Probed modes for %s\n", output->name); + list_for_each_entry_safe(mode, t, &output->modes, head) { + mode->vrefresh = drm_mode_vrefresh(mode); + + drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V); + drm_mode_debug_printmodeline(dev, mode); + } +} - drm_mode_prune_invalid(dev, &output->modes, TRUE); - - if (list_empty(&output->modes)) { - struct drm_display_mode *stdmode; - - DRM_DEBUG("No valid modes on %s\n", output->name); - - /* Should we do this here ??? - * When no valid EDID modes are available we end up - * here and bailed in the past, now we add a standard - * 640x480@60Hz mode and carry on. - */ - stdmode = drm_mode_duplicate(dev, &std_mode[0]); - drm_mode_probed_add(output, stdmode); - drm_mode_list_concat(&output->probed_modes, - &output->modes); - - DRM_DEBUG("Adding standard 640x480 @ 60Hz to %s\n", - output->name); - } - - drm_mode_sort(&output->modes); - - DRM_DEBUG("Probed modes for %s\n", output->name); - list_for_each_entry_safe(mode, t, &output->modes, head) { - mode->vrefresh = drm_mode_vrefresh(mode); +void drm_crtc_probe_output_modes(struct drm_device *dev, int maxX, int maxY) +{ + struct drm_output *output; - drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V); - drm_mode_debug_printmodeline(dev, mode); - } + list_for_each_entry(output, &dev->mode_config.output_list, head) { + drm_crtc_probe_single_output_modes(output, maxX, maxY); } } @@ -1068,8 +1074,6 @@ int drm_crtc_set_config(struct drm_crtc *crtc, struct drm_mode_crtc *crtc_info, */ void drm_crtc_convert_to_umode(struct drm_mode_modeinfo *out, struct drm_display_mode *in) { - - out->id = in->mode_id; out->clock = in->clock; out->hdisplay = in->hdisplay; out->hsync_start = in->hsync_start; @@ -1145,17 +1149,12 @@ int drm_mode_getresources(struct drm_device *dev, struct drm_framebuffer *fb; struct drm_output *output; struct drm_crtc *crtc; - struct drm_mode_modeinfo u_mode; - struct drm_display_mode *mode; int ret = 0; - int mode_count= 0; int output_count = 0; int crtc_count = 0; int fb_count = 0; int copied = 0; - memset(&u_mode, 0, sizeof(struct drm_mode_modeinfo)); - mutex_lock(&dev->mode_config.mutex); list_for_each(lh, &dev->mode_config.fb_list) @@ -1164,34 +1163,18 @@ int drm_mode_getresources(struct drm_device *dev, list_for_each(lh, &dev->mode_config.crtc_list) crtc_count++; - list_for_each_entry(output, &dev->mode_config.output_list, - head) { + list_for_each(lh, &dev->mode_config.output_list) output_count++; - list_for_each(lh, &output->modes) - mode_count++; - } - list_for_each(lh, &dev->mode_config.usermode_list) - mode_count++; - - if (card_res->count_modes == 0) { - DRM_DEBUG("probing modes %dx%d\n", dev->mode_config.max_width, dev->mode_config.max_height); - drm_crtc_probe_output_modes(dev, dev->mode_config.max_width, dev->mode_config.max_height); - mode_count = 0; - list_for_each_entry(output, &dev->mode_config.output_list, head) { - list_for_each(lh, &output->modes) - mode_count++; - } - list_for_each(lh, &dev->mode_config.usermode_list) - mode_count++; - } /* handle this in 4 parts */ /* FBs */ if (card_res->count_fbs >= fb_count) { copied = 0; list_for_each_entry(fb, &dev->mode_config.fb_list, head) { - if (put_user(fb->id, card_res->fb_id + copied)) - return -EFAULT; + if (put_user(fb->id, card_res->fb_id + copied)) { + ret = -EFAULT; + goto out; + } copied++; } } @@ -1202,8 +1185,10 @@ int drm_mode_getresources(struct drm_device *dev, copied = 0; list_for_each_entry(crtc, &dev->mode_config.crtc_list, head){ DRM_DEBUG("CRTC ID is %d\n", crtc->id); - if (put_user(crtc->id, card_res->crtc_id + copied)) - return -EFAULT; + if (put_user(crtc->id, card_res->crtc_id + copied)) { + ret = -EFAULT; + goto out; + } copied++; } } @@ -1216,41 +1201,20 @@ int drm_mode_getresources(struct drm_device *dev, list_for_each_entry(output, &dev->mode_config.output_list, head) { DRM_DEBUG("OUTPUT ID is %d\n", output->id); - if (put_user(output->id, card_res->output_id + copied)) - return -EFAULT; + if (put_user(output->id, card_res->output_id + copied)) { + ret = -EFAULT; + goto out; + } copied++; } } card_res->count_outputs = output_count; - /* Modes */ - if (card_res->count_modes >= mode_count) { - copied = 0; - list_for_each_entry(output, &dev->mode_config.output_list, - head) { - list_for_each_entry(mode, &output->modes, head) { - drm_crtc_convert_to_umode(&u_mode, mode); - if (copy_to_user(card_res->modes + copied, - &u_mode, sizeof(u_mode))) - return -EFAULT; - copied++; - } - } - /* add in user modes */ - list_for_each_entry(mode, &dev->mode_config.usermode_list, head) { - drm_crtc_convert_to_umode(&u_mode, mode); - if (copy_to_user(card_res->modes + copied, &u_mode, - sizeof(u_mode))) - return -EFAULT; - copied++; - } - } - card_res->count_modes = mode_count; + DRM_DEBUG("Counted %d %d\n", card_res->count_crtcs, + card_res->count_outputs); - DRM_DEBUG("Counted %d %d %d\n", card_res->count_crtcs, - card_res->count_outputs, - card_res->count_modes); - + +out: mutex_unlock(&dev->mode_config.mutex); return ret; } @@ -1299,14 +1263,16 @@ int drm_mode_getcrtc(struct drm_device *dev, crtc_resp->outputs = 0; if (crtc->enabled) { - crtc_resp->mode = crtc->mode.mode_id; + drm_crtc_convert_to_umode(&crtc_resp->mode, &crtc->mode); + crtc_resp->mode_valid = 1; ocount = 0; list_for_each_entry(output, &dev->mode_config.output_list, head) { if (output->crtc == crtc) crtc_resp->outputs |= 1 << (ocount++); } + } else { - crtc_resp->mode = 0; + crtc_resp->mode_valid = 0; } out: @@ -1342,6 +1308,9 @@ int drm_mode_getoutput(struct drm_device *dev, int ret = 0; int copied = 0; int i; + struct drm_mode_modeinfo u_mode; + + memset(&u_mode, 0, sizeof(struct drm_mode_modeinfo)); DRM_DEBUG("output id %d:\n", out_resp->output); @@ -1365,6 +1334,10 @@ int drm_mode_getoutput(struct drm_device *dev, } } + if (out_resp->count_modes == 0) { + drm_crtc_probe_single_output_modes(output, dev->mode_config.max_width, dev->mode_config.max_height); + } + strncpy(out_resp->name, output->name, DRM_OUTPUT_NAME_LEN); out_resp->name[DRM_OUTPUT_NAME_LEN-1] = 0; @@ -1383,12 +1356,26 @@ int drm_mode_getoutput(struct drm_device *dev, if ((out_resp->count_modes >= mode_count) && mode_count) { copied = 0; list_for_each_entry(mode, &output->modes, head) { - out_resp->modes[copied++] = mode->mode_id; + drm_crtc_convert_to_umode(&u_mode, mode); + if (copy_to_user(out_resp->modes + copied, + &u_mode, sizeof(u_mode))) { + ret = -EFAULT; + goto out; + } + copied++; + } for (i = 0; i < DRM_OUTPUT_MAX_UMODES; i++) { - if (output->user_mode_ids[i] != 0) { - if (put_user(output->user_mode_ids[i], out_resp->modes + copied)) - return -EFAULT; + if (!output->user_mode_ids[i]) + continue; + mode = idr_find(&dev->mode_config.crtc_idr, output->user_mode_ids[i]); + if (mode && (mode->mode_id == output->user_mode_ids[i])) { + drm_crtc_convert_to_umode(&u_mode, mode); + if (copy_to_user(out_resp->modes + copied, + &u_mode, sizeof(u_mode))) { + ret = -EFAULT; + goto out; + } copied++; } } @@ -1442,8 +1429,9 @@ int drm_mode_setcrtc(struct drm_device *dev, struct drm_mode_crtc *crtc_req = data; struct drm_crtc *crtc; struct drm_output **output_set = NULL, *output; - struct drm_display_mode *mode; struct drm_framebuffer *fb = NULL; + struct drm_display_mode mode; + int mode_valid = 0; int ret = 0; int i; @@ -1455,7 +1443,7 @@ int drm_mode_setcrtc(struct drm_device *dev, goto out; } - if (crtc_req->mode) { + if (crtc_req->mode_valid) { /* if we have a mode we need a framebuffer */ if (crtc_req->fb_id) { fb = idr_find(&dev->mode_config.crtc_idr, crtc_req->fb_id); @@ -1465,34 +1453,19 @@ int drm_mode_setcrtc(struct drm_device *dev, goto out; } } - mode = idr_find(&dev->mode_config.crtc_idr, crtc_req->mode); - if (!mode || (mode->mode_id != crtc_req->mode)) { - struct drm_output *output; - - list_for_each_entry(output, - &dev->mode_config.output_list, - head) { - list_for_each_entry(mode, &output->modes, - head) { - drm_mode_debug_printmodeline(dev, - mode); - } - } - DRM_DEBUG("Unknown mode id %d, %p\n", crtc_req->mode, mode); - ret = -EINVAL; - goto out; - } + mode_valid = 1; + drm_crtc_convert_umode(&mode, &crtc_req->mode); } else - mode = NULL; + mode_valid = 0; - if (crtc_req->count_outputs == 0 && mode) { + if (crtc_req->count_outputs == 0 && mode_valid) { DRM_DEBUG("Count outputs is 0 but mode set\n"); ret = -EINVAL; goto out; } - if (crtc_req->count_outputs > 0 && !mode && !fb) { + if (crtc_req->count_outputs > 0 && !mode_valid && !fb) { DRM_DEBUG("Count outputs is %d but no mode or fb set\n", crtc_req->count_outputs); ret = -EINVAL; goto out; @@ -1523,8 +1496,12 @@ int drm_mode_setcrtc(struct drm_device *dev, output_set[i] = output; } } - - ret = drm_crtc_set_config(crtc, crtc_req, mode, output_set, fb); + + if (mode_valid) { + ret = drm_crtc_set_config(crtc, crtc_req, &mode, output_set, fb); + } else { + ret = drm_crtc_set_config(crtc, crtc_req, NULL, output_set, fb); + } out: mutex_unlock(&dev->mode_config.mutex); @@ -1855,7 +1832,6 @@ int drm_mode_addmode_ioctl(struct drm_device *dev, drm_crtc_convert_umode(user_mode, new_mode); drm_mode_addmode(dev, user_mode); - new_mode->id = user_mode->mode_id; out: mutex_unlock(&dev->mode_config.mutex); diff --git a/shared-core/drm.h b/shared-core/drm.h index 9219b456..5c24e0af 100644 --- a/shared-core/drm.h +++ b/shared-core/drm.h @@ -908,9 +908,6 @@ struct drm_mm_init_arg { #define DRM_MODE_TYPE_DRIVER (1<<6) struct drm_mode_modeinfo { - - unsigned int id; - unsigned int clock; unsigned short hdisplay, hsync_start, hsync_end, htotal, hskew; unsigned short vdisplay, vsync_start, vsync_end, vtotal, vscan; @@ -932,10 +929,6 @@ struct drm_mode_card_res { int count_outputs; unsigned int __user *output_id; - - int count_modes; - struct drm_mode_modeinfo __user *modes; - }; struct drm_mode_crtc { @@ -944,8 +937,6 @@ struct drm_mode_crtc { int x, y; /**< Position on the frameuffer */ - unsigned int mode; /**< Current mode used */ - int count_outputs; unsigned int outputs; /**< Outputs that are connected */ @@ -955,7 +946,8 @@ struct drm_mode_crtc { unsigned int __user *set_outputs; /**< Outputs to be connected */ int gamma_size; - + int mode_valid; + struct drm_mode_modeinfo mode; }; struct drm_mode_get_output { @@ -975,7 +967,7 @@ struct drm_mode_get_output { unsigned int clones; /**< list of clones */ int count_modes; - unsigned int __user *modes; /**< list of modes it supports */ + struct drm_mode_modeinfo *modes; int count_props; unsigned int __user *props; diff --git a/tests/mode/modetest.c b/tests/mode/modetest.c index 50271af9..2871fde4 100644 --- a/tests/mode/modetest.c +++ b/tests/mode/modetest.c @@ -20,20 +20,9 @@ const char* getConnectionText(drmModeConnection conn) } -struct drm_mode_modeinfo* findMode(drmModeResPtr res, uint32_t id) -{ - int i; - for (i = 0; i < res->count_modes; i++) { - if (res->modes[i].id == id) - return &res->modes[i]; - } - - return 0; -} - int printMode(struct drm_mode_modeinfo *mode) { -#if 0 +#if 1 printf("Mode: %s\n", mode->name); printf("\tclock : %i\n", mode->clock); printf("\thdisplay : %i\n", mode->hdisplay); @@ -49,7 +38,7 @@ int printMode(struct drm_mode_modeinfo *mode) printf("\tvrefresh : %i\n", mode->vrefresh); printf("\tflags : %i\n", mode->flags); #else - printf("Mode: %i \"%s\" %ix%i %.0f\n", mode->id, mode->name, + printf("Mode: \"%s\" %ix%i %.0f\n", mode->name, mode->hdisplay, mode->vdisplay, mode->vrefresh / 1000.0); #endif return 0; @@ -104,11 +93,9 @@ int printOutput(int fd, drmModeResPtr res, drmModeOutputPtr output, uint32_t id) } for (i = 0; i < output->count_modes; i++) { - mode = findMode(res, output->modes[i]); - + mode = &output->modes[i]; if (mode) - printf("\t\tmode: %i \"%s\" %ix%i %.0f\n", mode->id, mode->name, - mode->hdisplay, mode->vdisplay, mode->vrefresh / 1000.0); + printMode(mode); else printf("\t\tmode: Invalid mode %i\n", output->modes[i]); } @@ -154,10 +141,6 @@ int printRes(int fd, drmModeResPtr res) drmModeCrtcPtr crtc; drmModeFBPtr fb; - for (i = 0; i < res->count_modes; i++) { - printMode(&res->modes[i]); - } - for (i = 0; i < res->count_outputs; i++) { output = drmModeGetOutput(fd, res->outputs[i]); @@ -218,6 +201,7 @@ int testMode(int fd, drmModeResPtr res) int ret = 0; int error = 0; +#if 0 printf("Test: adding mode to output %i\n", output); /* printMode(&mode); */ @@ -255,7 +239,7 @@ err: if (error) printf("\tFailed to delete mode %i\n", newMode); - +#endif return 1; } -- cgit v1.2.3 From 96df9b11ad8974d7a2a0a589114cbbb04a584f18 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 3 Dec 2007 13:42:32 +1000 Subject: finish of mode add/remove, just have attach/detach modes --- libdrm/xf86drmMode.c | 24 +----- libdrm/xf86drmMode.h | 15 +--- linux-core/drm_crtc.c | 202 ++++++++++---------------------------------------- linux-core/drm_crtc.h | 7 +- linux-core/drm_drv.c | 3 +- linux-core/intel_fb.c | 2 - shared-core/drm.h | 4 +- tests/mode/modetest.c | 19 +---- 8 files changed, 50 insertions(+), 226 deletions(-) (limited to 'tests') diff --git a/libdrm/xf86drmMode.c b/libdrm/xf86drmMode.c index 8b701381..cf596730 100644 --- a/libdrm/xf86drmMode.c +++ b/libdrm/xf86drmMode.c @@ -372,38 +372,22 @@ err_allocs: return r; } -#if 0 -uint32_t drmModeAddMode(int fd, struct drm_mode_modeinfo *mode_info) +int drmModeAttachMode(int fd, uint32_t output_id, struct drm_mode_modeinfo *mode_info) { - if (ioctl(fd, DRM_IOCTL_MODE_ADDMODE, mode_info)) - return 0; - - return mode_info->id; -} - -int drmModeRmMode(int fd, uint32_t mode_id) -{ - return ioctl(fd, DRM_IOCTL_MODE_RMMODE, &mode_id); -} -#endif - -int drmModeAttachMode(int fd, uint32_t output_id, uint32_t mode_id) -{ - struct drm_mode_mode_cmd res; + memcpy(&res.mode, mode_info, sizeof(struct drm_mode_modeinfo)); res.output_id = output_id; - res.mode_id = mode_id; return ioctl(fd, DRM_IOCTL_MODE_ATTACHMODE, &res); } -int drmModeDetachMode(int fd, uint32_t output_id, uint32_t mode_id) +int drmModeDetachMode(int fd, uint32_t output_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.mode_id = mode_id; return ioctl(fd, DRM_IOCTL_MODE_DETACHMODE, &res); } diff --git a/libdrm/xf86drmMode.h b/libdrm/xf86drmMode.h index 0777c596..a1d717f9 100644 --- a/libdrm/xf86drmMode.h +++ b/libdrm/xf86drmMode.h @@ -198,27 +198,16 @@ int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId, extern drmModeOutputPtr drmModeGetOutput(int fd, uint32_t outputId); -/** - * Adds a new mode from the given mode info. - * Name must be unique. - */ -extern uint32_t drmModeAddMode(int fd, struct drm_mode_modeinfo *modeInfo); - -/** - * Removes a mode created with AddMode, must be unused. - */ -extern int drmModeRmMode(int fd, uint32_t modeId); - /** * Attaches the given mode to an output. */ -extern int drmModeAttachMode(int fd, uint32_t outputId, uint32_t modeId); +extern int drmModeAttachMode(int fd, uint32_t outputId, struct drm_mode_modeinfo *mode_info); /** * Detaches a mode from the output * must be unused, by the given mode. */ -extern int drmModeDetachMode(int fd, uint32_t outputId, uint32_t modeId); +extern int drmModeDetachMode(int fd, uint32_t outputId, struct drm_mode_modeinfo *mode_info); extern drmModePropertyPtr drmModeGetProperty(int fd, uint32_t propertyId); extern void drmModeFreeProperty(drmModePropertyPtr ptr); diff --git a/linux-core/drm_crtc.c b/linux-core/drm_crtc.c index 44268337..26aa5206 100644 --- a/linux-core/drm_crtc.c +++ b/linux-core/drm_crtc.c @@ -579,6 +579,7 @@ struct drm_output *drm_output_create(struct drm_device *dev, strncpy(output->name, name, DRM_OUTPUT_LEN); output->name[DRM_OUTPUT_LEN - 1] = 0; output->subpixel_order = SubPixelUnknown; + INIT_LIST_HEAD(&output->user_modes); INIT_LIST_HEAD(&output->probed_modes); INIT_LIST_HEAD(&output->modes); /* randr_output? */ @@ -620,6 +621,9 @@ void drm_output_destroy(struct drm_output *output) list_for_each_entry_safe(mode, t, &output->modes, head) drm_mode_remove(output, mode); + list_for_each_entry_safe(mode, t, &output->user_modes, head) + drm_mode_remove(output, mode); + mutex_lock(&dev->mode_config.mutex); drm_idr_put(dev, output->id); list_del(&output->head); @@ -718,7 +722,6 @@ void drm_mode_config_init(struct drm_device *dev) INIT_LIST_HEAD(&dev->mode_config.crtc_list); INIT_LIST_HEAD(&dev->mode_config.output_list); INIT_LIST_HEAD(&dev->mode_config.property_list); - INIT_LIST_HEAD(&dev->mode_config.usermode_list); idr_init(&dev->mode_config.crtc_idr); } EXPORT_SYMBOL(drm_mode_config_init); @@ -950,7 +953,6 @@ void drm_mode_config_cleanup(struct drm_device *dev) struct drm_output *output, *ot; struct drm_crtc *crtc, *ct; struct drm_framebuffer *fb, *fbt; - struct drm_display_mode *mode, *mt; struct drm_property *property, *pt; list_for_each_entry_safe(output, ot, &dev->mode_config.output_list, head) { @@ -961,10 +963,6 @@ void drm_mode_config_cleanup(struct drm_device *dev) drm_property_destroy(dev, property); } - list_for_each_entry_safe(mode, mt, &dev->mode_config.usermode_list, head) { - drm_mode_destroy(dev, mode); - } - list_for_each_entry_safe(fb, fbt, &dev->mode_config.fb_list, head) { if (fb->bo->type != drm_bo_type_kernel) drm_framebuffer_destroy(fb); @@ -1324,10 +1322,6 @@ int drm_mode_getoutput(struct drm_device *dev, list_for_each_entry(mode, &output->modes, head) mode_count++; - for (i = 0; i < DRM_OUTPUT_MAX_UMODES; i++) - if (output->user_mode_ids[i] != 0) - mode_count++; - for (i = 0; i < DRM_OUTPUT_MAX_PROPERTY; i++) { if (output->property_ids[i] != 0) { props_count++; @@ -1365,20 +1359,6 @@ int drm_mode_getoutput(struct drm_device *dev, copied++; } - for (i = 0; i < DRM_OUTPUT_MAX_UMODES; i++) { - if (!output->user_mode_ids[i]) - continue; - mode = idr_find(&dev->mode_config.crtc_idr, output->user_mode_ids[i]); - if (mode && (mode->mode_id == output->user_mode_ids[i])) { - drm_crtc_convert_to_umode(&u_mode, mode); - if (copy_to_user(out_resp->modes + copied, - &u_mode, sizeof(u_mode))) { - ret = -EFAULT; - goto out; - } - copied++; - } - } } out_resp->count_modes = mode_count; @@ -1710,49 +1690,14 @@ void drm_fb_release(struct file *filp) /* * */ -void drm_mode_addmode(struct drm_device *dev, struct drm_display_mode *user_mode) -{ - user_mode->type |= DRM_MODE_TYPE_USERDEF; - - user_mode->output_count = 0; - list_add(&user_mode->head, &dev->mode_config.usermode_list); -} -EXPORT_SYMBOL(drm_mode_addmode); - -int drm_mode_rmmode(struct drm_device *dev, struct drm_display_mode *mode) -{ - struct drm_display_mode *t; - int ret = -EINVAL; - list_for_each_entry(t, &dev->mode_config.usermode_list, head) { - if (t == mode) { - list_del(&mode->head); - drm_mode_destroy(dev, mode); - ret = 0; - break; - } - } - return ret; -} -EXPORT_SYMBOL(drm_mode_rmmode); static int drm_mode_attachmode(struct drm_device *dev, struct drm_output *output, struct drm_display_mode *mode) { int ret = 0; - int i; - - for (i = 0; i < DRM_OUTPUT_MAX_UMODES; i++) { - if (output->user_mode_ids[i] == 0) { - output->user_mode_ids[i] = mode->mode_id; - mode->output_count++; - break; - } - } - - if (i == DRM_OUTPUT_MAX_UMODES) - ret = -ENOSPC; + list_add_tail(&mode->head, &output->user_modes); return ret; } @@ -1760,11 +1705,22 @@ int drm_mode_attachmode_crtc(struct drm_device *dev, struct drm_crtc *crtc, struct drm_display_mode *mode) { struct drm_output *output; - + int ret = 0; + struct drm_display_mode *dup_mode; + int need_dup = 0; list_for_each_entry(output, &dev->mode_config.output_list, head) { - if (output->crtc == crtc) - drm_mode_attachmode(dev, output, mode); + if (output->crtc == crtc) { + if (need_dup) + dup_mode = drm_mode_duplicate(dev, mode); + else + dup_mode = mode; + ret = drm_mode_attachmode(dev, output, dup_mode); + if (ret) + return ret; + need_dup = 1; + } } + return 0; } EXPORT_SYMBOL(drm_mode_attachmode_crtc); @@ -1773,13 +1729,15 @@ static int drm_mode_detachmode(struct drm_device *dev, struct drm_display_mode *mode) { int found = 0; - int ret = 0, i; + int ret = 0; + struct drm_display_mode *match_mode, *t; - for (i = 0; i < DRM_OUTPUT_MAX_UMODES; i++) { - if (output->user_mode_ids[i] == mode->mode_id) { - output->user_mode_ids[i] = 0; - mode->output_count--; + list_for_each_entry_safe(match_mode, t, &output->user_modes, head) { + if (drm_mode_equal(match_mode, mode)) { + list_del(&match_mode->head); + drm_mode_destroy(dev, match_mode); found = 1; + break; } } @@ -1800,86 +1758,6 @@ int drm_mode_detachmode_crtc(struct drm_device *dev, struct drm_display_mode *mo } EXPORT_SYMBOL(drm_mode_detachmode_crtc); -/** - * drm_fb_addmode - adds a user defined mode - * @inode: inode from the ioctl - * @filp: file * from the ioctl - * @cmd: cmd from ioctl - * @arg: arg from ioctl - * - * Adds a user specified mode to the kernel. - * - * Called by the user via ioctl. - * - * RETURNS: - * writes new mode id into arg. - * Zero on success, errno on failure. - */ -int drm_mode_addmode_ioctl(struct drm_device *dev, - void *data, struct drm_file *file_priv) -{ - struct drm_mode_modeinfo *new_mode = data; - struct drm_display_mode *user_mode; - int ret = 0; - - mutex_lock(&dev->mode_config.mutex); - user_mode = drm_mode_create(dev); - if (!user_mode) { - ret = -ENOMEM; - goto out; - } - - drm_crtc_convert_umode(user_mode, new_mode); - - drm_mode_addmode(dev, user_mode); - -out: - mutex_unlock(&dev->mode_config.mutex); - return ret; -} - -/** - * drm_fb_rmmode - removes a user defined mode - * @inode: inode from the ioctl - * @filp: file * from the ioctl - * @cmd: cmd from ioctl - * @arg: arg from ioctl - * - * Remove the user defined mode specified by the user. - * - * Called by the user via ioctl - * - * RETURNS: - * Zero on success, errno on failure. - */ -int drm_mode_rmmode_ioctl(struct drm_device *dev, - void *data, struct drm_file *file_priv) -{ - uint32_t *id = data; - struct drm_display_mode *mode; - int ret = -EINVAL; - - mutex_lock(&dev->mode_config.mutex); - mode = idr_find(&dev->mode_config.crtc_idr, *id); - if (!mode || (*id != mode->mode_id)) { - goto out; - } - - if (!(mode->type & DRM_MODE_TYPE_USERDEF)) { - goto out; - } - - if (mode->output_count) { - goto out; - } - - ret = drm_mode_rmmode(dev, mode); - -out: - mutex_unlock(&dev->mode_config.mutex); - return ret; -} - /** * drm_fb_attachmode - Attach a user mode to an output * @inode: inode from the ioctl @@ -1899,21 +1777,24 @@ int drm_mode_attachmode_ioctl(struct drm_device *dev, struct drm_mode_mode_cmd *mode_cmd = data; struct drm_output *output; struct drm_display_mode *mode; + struct drm_mode_modeinfo *umode = &mode_cmd->mode; int ret = 0; mutex_lock(&dev->mode_config.mutex); - mode = idr_find(&dev->mode_config.crtc_idr, mode_cmd->mode_id); - if (!mode || (mode->mode_id != mode_cmd->mode_id)) { + output = idr_find(&dev->mode_config.crtc_idr, mode_cmd->output_id); + if (!output || (output->id != mode_cmd->output_id)) { ret = -EINVAL; goto out; } - output = idr_find(&dev->mode_config.crtc_idr, mode_cmd->output_id); - if (!output || (output->id != mode_cmd->output_id)) { - ret = -EINVAL; + mode = drm_mode_create(dev); + if (!mode) { + ret = -ENOMEM; goto out; } + + drm_crtc_convert_umode(mode, umode); ret = drm_mode_attachmode(dev, output, mode); out: @@ -1939,25 +1820,20 @@ int drm_mode_detachmode_ioctl(struct drm_device *dev, { struct drm_mode_mode_cmd *mode_cmd = data; struct drm_output *output; - struct drm_display_mode *mode; + struct drm_display_mode mode; + struct drm_mode_modeinfo *umode = &mode_cmd->mode; int ret = 0; mutex_lock(&dev->mode_config.mutex); - mode = idr_find(&dev->mode_config.crtc_idr, mode_cmd->mode_id); - if (!mode || (mode->mode_id != mode_cmd->mode_id)) { - ret = -EINVAL; - goto out; - } - output = idr_find(&dev->mode_config.crtc_idr, mode_cmd->output_id); if (!output || (output->id != mode_cmd->output_id)) { ret = -EINVAL; goto out; } - - - ret = drm_mode_detachmode(dev, output, mode); + + drm_crtc_convert_umode(&mode, umode); + ret = drm_mode_detachmode(dev, output, &mode); out: mutex_unlock(&dev->mode_config.mutex); return ret; diff --git a/linux-core/drm_crtc.h b/linux-core/drm_crtc.h index 011903ce..90d6104f 100644 --- a/linux-core/drm_crtc.h +++ b/linux-core/drm_crtc.h @@ -448,7 +448,7 @@ struct drm_output { const struct drm_output_funcs *funcs; void *driver_private; - u32 user_mode_ids[DRM_OUTPUT_MAX_UMODES]; + struct list_head user_modes; u32 property_ids[DRM_OUTPUT_MAX_PROPERTY]; u32 property_values[DRM_OUTPUT_MAX_PROPERTY]; @@ -484,8 +484,6 @@ struct drm_mode_config { int num_crtc; struct list_head crtc_list; - struct list_head usermode_list; - struct list_head property_list; int min_width, min_height; @@ -518,9 +516,6 @@ extern void drm_mode_set_name(struct drm_display_mode *mode); extern bool drm_mode_equal(struct drm_display_mode *mode1, struct drm_display_mode *mode2); extern void drm_disable_unused_functions(struct drm_device *dev); -extern void drm_mode_addmode(struct drm_device *dev, struct drm_display_mode *user_mode); -extern int drm_mode_rmmode(struct drm_device *dev, struct drm_display_mode *mode); - /* for us by fb module */ extern int drm_mode_attachmode_crtc(struct drm_device *dev, struct drm_crtc *crtc, diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c index b3e00e84..6a3e7041 100644 --- a/linux-core/drm_drv.c +++ b/linux-core/drm_drv.c @@ -124,8 +124,7 @@ static struct drm_ioctl_desc drm_ioctls[] = { DRM_IOCTL_DEF(DRM_IOCTL_MODE_ADDFB, drm_mode_addfb, DRM_MASTER|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_IOCTL_MODE_RMFB, drm_mode_rmfb, DRM_MASTER|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETFB, drm_mode_getfb, DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_IOCTL_MODE_ADDMODE, drm_mode_addmode_ioctl, DRM_MASTER|DRM_ROOT_ONLY), - DRM_IOCTL_DEF(DRM_IOCTL_MODE_RMMODE, drm_mode_rmmode_ioctl, DRM_MASTER|DRM_ROOT_ONLY), + DRM_IOCTL_DEF(DRM_IOCTL_MODE_ATTACHMODE, drm_mode_attachmode_ioctl, DRM_MASTER|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_IOCTL_MODE_DETACHMODE, drm_mode_detachmode_ioctl, DRM_MASTER|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETPROPERTY, drm_mode_getproperty_ioctl, DRM_MASTER | DRM_ROOT_ONLY), diff --git a/linux-core/intel_fb.c b/linux-core/intel_fb.c index 5f43f291..a8c9188d 100644 --- a/linux-core/intel_fb.c +++ b/linux-core/intel_fb.c @@ -281,10 +281,8 @@ static int intelfb_set_par(struct fb_info *info) } if (!found) { - drm_mode_addmode(dev, drm_mode); if (par->fb_mode) { drm_mode_detachmode_crtc(dev, par->fb_mode); - drm_mode_rmmode(dev, par->fb_mode); } par->fb_mode = drm_mode; diff --git a/shared-core/drm.h b/shared-core/drm.h index 5c24e0af..f4f75cf5 100644 --- a/shared-core/drm.h +++ b/shared-core/drm.h @@ -1008,7 +1008,7 @@ struct drm_mode_fb_cmd { struct drm_mode_mode_cmd { unsigned int output_id; - unsigned int mode_id; + struct drm_mode_modeinfo mode; }; /** @@ -1111,8 +1111,6 @@ struct drm_mode_mode_cmd { #define DRM_IOCTL_MODE_RMFB DRM_IOWR(0xA5, unsigned int) #define DRM_IOCTL_MODE_GETFB DRM_IOWR(0xA6, struct drm_mode_fb_cmd) -#define DRM_IOCTL_MODE_ADDMODE DRM_IOWR(0xA7, struct drm_mode_modeinfo) -#define DRM_IOCTL_MODE_RMMODE DRM_IOWR(0xA8, unsigned int) #define DRM_IOCTL_MODE_ATTACHMODE DRM_IOWR(0xA9, struct drm_mode_mode_cmd) #define DRM_IOCTL_MODE_DETACHMODE DRM_IOWR(0xAA, struct drm_mode_mode_cmd) diff --git a/tests/mode/modetest.c b/tests/mode/modetest.c index 2871fde4..1d5002b0 100644 --- a/tests/mode/modetest.c +++ b/tests/mode/modetest.c @@ -201,45 +201,30 @@ int testMode(int fd, drmModeResPtr res) int ret = 0; int error = 0; -#if 0 printf("Test: adding mode to output %i\n", output); /* printMode(&mode); */ - printf("\tAdding mode\n"); - newMode = drmModeAddMode(fd, &mode); - if (!newMode) - goto err; - printf("\tAttaching mode %i to output %i\n", newMode, output); - ret = drmModeAttachMode(fd, output, newMode); + ret = drmModeAttachMode(fd, output, &mode); if (ret) goto err_mode; printf("\tDetaching mode %i from output %i\n", newMode, output); - ret = drmModeDetachMode(fd, output, newMode); + ret = drmModeDetachMode(fd, output, &mode); if (ret) goto err_mode; - - printf("\tRemoveing new mode %i\n", newMode); - ret = drmModeRmMode(fd, newMode); - if (ret) - goto err; - return 0; err_mode: - error = drmModeRmMode(fd, newMode); -err: printf("\tFailed\n"); if (error) printf("\tFailed to delete mode %i\n", newMode); -#endif return 1; } -- cgit v1.2.3 From 1a6c95ef711fce807659ab5e4fe480d65ac233b6 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 5 Dec 2007 16:03:05 +1000 Subject: arrgggh.. make all ioctl structs 32/64-bit compatible hopefully. This also starts to add blob property support. someone needs to check this work for other things like ppc/x86 alignment diffs --- libdrm/xf86drmMode.c | 75 ++++++++++++----------- libdrm/xf86drmMode.h | 6 +- linux-core/drm_crtc.c | 163 ++++++++++++++++++++++++++++++++++++------------- linux-core/drm_crtc.h | 23 +++++-- linux-core/intel_crt.c | 2 + shared-core/drm.h | 48 +++++++-------- tests/mode/modetest.c | 21 ++++--- 7 files changed, 222 insertions(+), 116 deletions(-) (limited to 'tests') diff --git a/libdrm/xf86drmMode.c b/libdrm/xf86drmMode.c index bb7be13c..e5191d8c 100644 --- a/libdrm/xf86drmMode.c +++ b/libdrm/xf86drmMode.c @@ -42,6 +42,9 @@ #include #include +#define U642VOID(x) ((void *)(unsigned long)(x)) +#define VOID2U64(x) ((uint64_t)(unsigned long)(x)) + /* * Util functions */ @@ -149,11 +152,11 @@ drmModeResPtr drmModeGetResources(int fd) return 0; if (res.count_fbs) - res.fb_id = drmMalloc(res.count_fbs*sizeof(uint32_t)); + res.fb_id_ptr = VOID2U64(drmMalloc(res.count_fbs*sizeof(uint32_t))); if (res.count_crtcs) - res.crtc_id = drmMalloc(res.count_crtcs*sizeof(uint32_t)); + res.crtc_id_ptr = VOID2U64(drmMalloc(res.count_crtcs*sizeof(uint32_t))); if (res.count_outputs) - res.output_id = drmMalloc(res.count_outputs*sizeof(uint32_t)); + res.output_id_ptr = VOID2U64(drmMalloc(res.count_outputs*sizeof(uint32_t))); if (ioctl(fd, DRM_IOCTL_MODE_GETRESOURCES, &res)) { r = NULL; @@ -168,18 +171,22 @@ drmModeResPtr drmModeGetResources(int fd) if (!(r = drmMalloc(sizeof(*r)))) return 0; + r->min_width = res.min_width; + r->max_width = res.max_width; + r->min_height = res.min_height; + r->max_height = res.max_height; r->count_fbs = res.count_fbs; r->count_crtcs = res.count_crtcs; r->count_outputs = res.count_outputs; /* TODO we realy should test if these allocs fails. */ - r->fbs = drmAllocCpy(res.fb_id, res.count_fbs, sizeof(uint32_t)); - r->crtcs = drmAllocCpy(res.crtc_id, res.count_crtcs, sizeof(uint32_t)); - r->outputs = drmAllocCpy(res.output_id, 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)); err_allocs: - drmFree(res.fb_id); - drmFree(res.crtc_id); - drmFree(res.output_id); + drmFree(U642VOID(res.fb_id_ptr)); + drmFree(U642VOID(res.crtc_id_ptr)); + drmFree(U642VOID(res.output_id_ptr)); return r; } @@ -297,7 +304,7 @@ int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId, crtc.y = y; crtc.crtc_id = crtcId; crtc.fb_id = bufferId; - crtc.set_outputs = outputs; + crtc.set_outputs_ptr = VOID2U64(outputs); crtc.count_outputs = count; if (mode) { memcpy(&crtc.mode, mode, sizeof(struct drm_mode_modeinfo)); @@ -324,21 +331,21 @@ drmModeOutputPtr drmModeGetOutput(int fd, uint32_t output_id) out.count_clones = 0; out.clones = 0; out.count_modes = 0; - out.modes = 0; + out.modes_ptr = 0; out.count_props = 0; - out.props = NULL; - out.prop_values = NULL; + out.props_ptr = 0; + out.prop_values_ptr = 0; if (ioctl(fd, DRM_IOCTL_MODE_GETOUTPUT, &out)) return 0; if (out.count_props) { - out.props = drmMalloc(out.count_props*sizeof(uint32_t)); - out.prop_values = drmMalloc(out.count_props*sizeof(uint32_t)); + out.props_ptr = VOID2U64(drmMalloc(out.count_props*sizeof(uint32_t))); + out.prop_values_ptr = VOID2U64(drmMalloc(out.count_props*sizeof(uint64_t))); } if (out.count_modes) - out.modes = drmMalloc(out.count_modes*sizeof(struct drm_mode_modeinfo)); + out.modes_ptr = VOID2U64(drmMalloc(out.count_modes*sizeof(struct drm_mode_modeinfo))); if (ioctl(fd, DRM_IOCTL_MODE_GETOUTPUT, &out)) goto err_allocs; @@ -360,16 +367,16 @@ drmModeOutputPtr drmModeGetOutput(int fd, uint32_t output_id) r->crtcs = out.crtcs; r->clones = out.clones; r->count_props = out.count_props; - r->props = drmAllocCpy(out.props, out.count_props, sizeof(uint32_t)); - r->prop_values = drmAllocCpy(out.prop_values, out.count_props, sizeof(uint32_t)); - r->modes = drmAllocCpy(out.modes, out.count_modes, sizeof(struct drm_mode_modeinfo)); + 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)); strncpy(r->name, out.name, DRM_OUTPUT_NAME_LEN); r->name[DRM_OUTPUT_NAME_LEN-1] = 0; err_allocs: - drmFree(out.prop_values); - drmFree(out.props); - drmFree(out.modes); + drmFree(U642VOID(out.prop_values_ptr)); + drmFree(U642VOID(out.props_ptr)); + drmFree(U642VOID(out.modes_ptr)); return r; } @@ -401,20 +408,20 @@ drmModePropertyPtr drmModeGetProperty(int fd, uint32_t property_id) drmModePropertyPtr r; prop.prop_id = property_id; - prop.count_enums = 0; + prop.count_enum_blobs = 0; prop.count_values = 0; prop.flags = 0; - prop.enums = NULL; - prop.values = NULL; + prop.enum_blob_ptr = 0; + prop.values_ptr = 0; if (ioctl(fd, DRM_IOCTL_MODE_GETPROPERTY, &prop)) return 0; if (prop.count_values) - prop.values = drmMalloc(prop.count_values * sizeof(uint32_t)); + prop.values_ptr = VOID2U64(drmMalloc(prop.count_values * sizeof(uint64_t))); - if (prop.count_enums) - prop.enums = drmMalloc(prop.count_enums * sizeof(struct drm_mode_property_enum)); + if (prop.count_enum_blobs) + prop.enum_blob_ptr = VOID2U64(drmMalloc(prop.count_enum_blobs * sizeof(struct drm_mode_property_enum))); if (ioctl(fd, DRM_IOCTL_MODE_GETPROPERTY, &prop)) { r = NULL; @@ -426,16 +433,16 @@ drmModePropertyPtr drmModeGetProperty(int fd, uint32_t property_id) r->prop_id = prop.prop_id; r->count_values = prop.count_values; - r->count_enums = prop.count_enums; - - r->values = drmAllocCpy(prop.values, prop.count_values, sizeof(uint32_t)); - r->enums = drmAllocCpy(prop.enums, prop.count_enums, sizeof(struct drm_mode_property_enum)); + r->count_enums = prop.count_enum_blobs; + r->flags = prop.flags; + r->values = drmAllocCpy(U642VOID(prop.values_ptr), prop.count_values, sizeof(uint64_t)); + r->enums = drmAllocCpy(U642VOID(prop.enum_blob_ptr), prop.count_enum_blobs, sizeof(struct drm_mode_property_enum)); strncpy(r->name, prop.name, DRM_PROP_NAME_LEN); r->name[DRM_PROP_NAME_LEN-1] = 0; err_allocs: - drmFree(prop.values); - drmFree(prop.enums); + drmFree(U642VOID(prop.values_ptr)); + drmFree(U642VOID(prop.enum_blob_ptr)); return r; } diff --git a/libdrm/xf86drmMode.h b/libdrm/xf86drmMode.h index a1d717f9..ec77174b 100644 --- a/libdrm/xf86drmMode.h +++ b/libdrm/xf86drmMode.h @@ -63,6 +63,8 @@ typedef struct _drmModeRes { int count_outputs; uint32_t *outputs; + uint32_t min_width, max_width; + uint32_t min_height, max_height; } drmModeRes, *drmModeResPtr; typedef struct drm_mode_fb_cmd drmModeFB, *drmModeFBPtr; @@ -72,7 +74,7 @@ typedef struct _drmModeProperty { unsigned int flags; unsigned char name[DRM_PROP_NAME_LEN]; int count_values; - uint32_t *values; + uint64_t *values; int count_enums; struct drm_mode_property_enum *enums; @@ -132,7 +134,7 @@ typedef struct _drmModeOutput { int count_props; uint32_t *props; /**< List of property ids */ - uint32_t *prop_values; /**< List of property values */ + uint64_t *prop_values; /**< List of property values */ } drmModeOutput, *drmModeOutputPtr; diff --git a/linux-core/drm_crtc.c b/linux-core/drm_crtc.c index 26aa5206..c2680319 100644 --- a/linux-core/drm_crtc.c +++ b/linux-core/drm_crtc.c @@ -722,7 +722,11 @@ void drm_mode_config_init(struct drm_device *dev) INIT_LIST_HEAD(&dev->mode_config.crtc_list); INIT_LIST_HEAD(&dev->mode_config.output_list); INIT_LIST_HEAD(&dev->mode_config.property_list); + INIT_LIST_HEAD(&dev->mode_config.property_blob_list); idr_init(&dev->mode_config.crtc_idr); + dev->mode_config.edid_property = drm_property_create(dev, + DRM_MODE_PROP_BLOB | DRM_MODE_PROP_IMMUTABLE, + "EDID", 0); } EXPORT_SYMBOL(drm_mode_config_init); @@ -1013,7 +1017,7 @@ int drm_crtc_set_config(struct drm_crtc *crtc, struct drm_mode_crtc *crtc_info, if (crtc_info->x != crtc->x || crtc_info->y != crtc->y) changed = true; - if (new_mode && (crtc->mode.mode_id != new_mode->mode_id)) + if (new_mode && !drm_mode_equal(new_mode, &crtc->mode)) changed = true; list_for_each_entry(output, &dev->mode_config.output_list, head) { @@ -1152,6 +1156,9 @@ int drm_mode_getresources(struct drm_device *dev, int crtc_count = 0; int fb_count = 0; int copied = 0; + uint32_t __user *fb_id; + uint32_t __user *crtc_id; + uint32_t __user *output_id; mutex_lock(&dev->mode_config.mutex); @@ -1164,12 +1171,18 @@ int drm_mode_getresources(struct drm_device *dev, list_for_each(lh, &dev->mode_config.output_list) output_count++; + card_res->max_height = dev->mode_config.max_height; + card_res->min_height = dev->mode_config.min_height; + card_res->max_width = dev->mode_config.max_width; + card_res->min_width = dev->mode_config.min_width; + /* handle this in 4 parts */ /* FBs */ if (card_res->count_fbs >= fb_count) { copied = 0; + fb_id = (uint32_t *)(unsigned long)card_res->fb_id_ptr; list_for_each_entry(fb, &dev->mode_config.fb_list, head) { - if (put_user(fb->id, card_res->fb_id + copied)) { + if (put_user(fb->id, fb_id + copied)) { ret = -EFAULT; goto out; } @@ -1181,9 +1194,10 @@ int drm_mode_getresources(struct drm_device *dev, /* CRTCs */ if (card_res->count_crtcs >= crtc_count) { copied = 0; + crtc_id = (uint32_t *)(unsigned long)card_res->crtc_id_ptr; list_for_each_entry(crtc, &dev->mode_config.crtc_list, head){ DRM_DEBUG("CRTC ID is %d\n", crtc->id); - if (put_user(crtc->id, card_res->crtc_id + copied)) { + if (put_user(crtc->id, crtc_id + copied)) { ret = -EFAULT; goto out; } @@ -1196,10 +1210,11 @@ int drm_mode_getresources(struct drm_device *dev, /* Outputs */ if (card_res->count_outputs >= output_count) { copied = 0; + output_id = (uint32_t *)(unsigned long)card_res->output_id_ptr; list_for_each_entry(output, &dev->mode_config.output_list, head) { DRM_DEBUG("OUTPUT ID is %d\n", output->id); - if (put_user(output->id, card_res->output_id + copied)) { + if (put_user(output->id, output_id + copied)) { ret = -EFAULT; goto out; } @@ -1211,7 +1226,6 @@ int drm_mode_getresources(struct drm_device *dev, DRM_DEBUG("Counted %d %d\n", card_res->count_crtcs, card_res->count_outputs); - out: mutex_unlock(&dev->mode_config.mutex); return ret; @@ -1307,6 +1321,9 @@ int drm_mode_getoutput(struct drm_device *dev, int copied = 0; int i; struct drm_mode_modeinfo u_mode; + struct drm_mode_modeinfo __user *mode_ptr; + uint32_t __user *prop_ptr; + uint64_t __user *prop_values; memset(&u_mode, 0, sizeof(struct drm_mode_modeinfo)); @@ -1349,9 +1366,10 @@ int drm_mode_getoutput(struct drm_device *dev, if ((out_resp->count_modes >= mode_count) && mode_count) { copied = 0; + mode_ptr = (struct drm_mode_modeinfo *)(unsigned long)out_resp->modes_ptr; list_for_each_entry(mode, &output->modes, head) { drm_crtc_convert_to_umode(&u_mode, mode); - if (copy_to_user(out_resp->modes + copied, + if (copy_to_user(mode_ptr + copied, &u_mode, sizeof(u_mode))) { ret = -EFAULT; goto out; @@ -1364,14 +1382,16 @@ int drm_mode_getoutput(struct drm_device *dev, if ((out_resp->count_props >= props_count) && props_count) { copied = 0; + prop_ptr = (uint32_t *)(unsigned long)(out_resp->props_ptr); + prop_values = (uint64_t *)(unsigned long)(out_resp->prop_values_ptr); for (i = 0; i < DRM_OUTPUT_MAX_PROPERTY; i++) { if (output->property_ids[i] != 0) { - if (put_user(output->property_ids[i], out_resp->props + copied)) { + if (put_user(output->property_ids[i], prop_ptr + copied)) { ret = -EFAULT; goto out; } - if (put_user(output->property_values[i], out_resp->prop_values + copied)) { + if (put_user(output->property_values[i], prop_values + copied)) { ret = -EFAULT; goto out; } @@ -1410,10 +1430,10 @@ int drm_mode_setcrtc(struct drm_device *dev, struct drm_crtc *crtc; struct drm_output **output_set = NULL, *output; struct drm_framebuffer *fb = NULL; - struct drm_display_mode mode; - int mode_valid = 0; + struct drm_display_mode *mode = NULL; int ret = 0; int i; + uint32_t __user *set_outputs_ptr; mutex_lock(&dev->mode_config.mutex); crtc = idr_find(&dev->mode_config.crtc_idr, crtc_req->crtc_id); @@ -1434,18 +1454,17 @@ int drm_mode_setcrtc(struct drm_device *dev, } } - mode_valid = 1; - drm_crtc_convert_umode(&mode, &crtc_req->mode); - } else - mode_valid = 0; + mode = drm_mode_create(dev); + drm_crtc_convert_umode(mode, &crtc_req->mode); + } - if (crtc_req->count_outputs == 0 && mode_valid) { + if (crtc_req->count_outputs == 0 && mode) { DRM_DEBUG("Count outputs is 0 but mode set\n"); ret = -EINVAL; goto out; } - if (crtc_req->count_outputs > 0 && !mode_valid && !fb) { + if (crtc_req->count_outputs > 0 && !mode && !fb) { DRM_DEBUG("Count outputs is %d but no mode or fb set\n", crtc_req->count_outputs); ret = -EINVAL; goto out; @@ -1461,7 +1480,8 @@ int drm_mode_setcrtc(struct drm_device *dev, } for (i = 0; i < crtc_req->count_outputs; i++) { - if (get_user(out_id, &crtc_req->set_outputs[i])) { + set_outputs_ptr = (uint32_t *)(unsigned long)crtc_req->set_outputs_ptr; + if (get_user(out_id, &set_outputs_ptr[i])) { ret = -EFAULT; goto out; } @@ -1477,11 +1497,7 @@ int drm_mode_setcrtc(struct drm_device *dev, } } - if (mode_valid) { - ret = drm_crtc_set_config(crtc, crtc_req, &mode, output_set, fb); - } else { - ret = drm_crtc_set_config(crtc, crtc_req, NULL, output_set, fb); - } + ret = drm_crtc_set_config(crtc, crtc_req, mode, output_set, fb); out: mutex_unlock(&dev->mode_config.mutex); @@ -1847,15 +1863,17 @@ struct drm_property *drm_property_create(struct drm_device *dev, int flags, property = kzalloc(sizeof(struct drm_output), GFP_KERNEL); if (!property) return NULL; - - property->values = kzalloc(sizeof(uint32_t)*num_values, GFP_KERNEL); - if (!property->values) - goto fail; + + if (num_values) { + property->values = kzalloc(sizeof(uint64_t)*num_values, GFP_KERNEL); + if (!property->values) + goto fail; + } property->id = drm_idr_get(dev, property); property->flags = flags; property->num_values = num_values; - INIT_LIST_HEAD(&property->enum_list); + INIT_LIST_HEAD(&property->enum_blob_list); if (name) strncpy(property->name, name, DRM_PROP_NAME_LEN); @@ -1869,15 +1887,15 @@ fail: EXPORT_SYMBOL(drm_property_create); int drm_property_add_enum(struct drm_property *property, int index, - uint32_t value, const char *name) + uint64_t value, const char *name) { struct drm_property_enum *prop_enum; if (!(property->flags & DRM_MODE_PROP_ENUM)) return -EINVAL; - if (!list_empty(&property->enum_list)) { - list_for_each_entry(prop_enum, &property->enum_list, head) { + if (!list_empty(&property->enum_blob_list)) { + list_for_each_entry(prop_enum, &property->enum_blob_list, head) { if (prop_enum->value == value) { strncpy(prop_enum->name, name, DRM_PROP_NAME_LEN); prop_enum->name[DRM_PROP_NAME_LEN-1] = '\0'; @@ -1895,7 +1913,7 @@ int drm_property_add_enum(struct drm_property *property, int index, prop_enum->value = value; property->values[index] = value; - list_add_tail(&prop_enum->head, &property->enum_list); + list_add_tail(&prop_enum->head, &property->enum_blob_list); return 0; } EXPORT_SYMBOL(drm_property_add_enum); @@ -1904,12 +1922,13 @@ void drm_property_destroy(struct drm_device *dev, struct drm_property *property) { struct drm_property_enum *prop_enum, *pt; - list_for_each_entry_safe(prop_enum, pt, &property->enum_list, head) { + list_for_each_entry_safe(prop_enum, pt, &property->enum_blob_list, head) { list_del(&prop_enum->head); kfree(prop_enum); } - kfree(property->values); + if (property->num_values) + kfree(property->values); drm_idr_put(dev, property->id); list_del(&property->head); kfree(property); @@ -1918,7 +1937,7 @@ EXPORT_SYMBOL(drm_property_destroy); int drm_output_attach_property(struct drm_output *output, - struct drm_property *property, int init_val) + struct drm_property *property, uint64_t init_val) { int i; @@ -1942,10 +1961,14 @@ int drm_mode_getproperty_ioctl(struct drm_device *dev, struct drm_mode_get_property *out_resp = data; struct drm_property *property; int enum_count = 0; + int blob_count = 0; int value_count = 0; int ret = 0, i; int copied; struct drm_property_enum *prop_enum; + struct drm_property_enum __user *enum_ptr; + struct drm_property_blob *prop_blob; + uint64_t __user *values_ptr; mutex_lock(&dev->mode_config.mutex); property = idr_find(&dev->mode_config.crtc_idr, out_resp->prop_id); @@ -1954,9 +1977,13 @@ int drm_mode_getproperty_ioctl(struct drm_device *dev, goto done; } - - list_for_each_entry(prop_enum, &property->enum_list, head) - enum_count++; + if (property->flags & DRM_MODE_PROP_ENUM) { + list_for_each_entry(prop_enum, &property->enum_blob_list, head) + enum_count++; + } else if (property->flags & DRM_MODE_PROP_BLOB) { + list_for_each_entry(prop_blob, &property->enum_blob_list, head) + blob_count++; + } value_count = property->num_values; @@ -1965,8 +1992,9 @@ int drm_mode_getproperty_ioctl(struct drm_device *dev, out_resp->flags = property->flags; if ((out_resp->count_values >= value_count) && value_count) { + values_ptr = (uint64_t *)(unsigned long)out_resp->values_ptr; for (i = 0; i < value_count; i++) { - if (put_user(property->values[i], out_resp->values + i)) { + if (put_user(property->values[i], values_ptr + i)) { ret = -EFAULT; goto done; } @@ -1974,10 +2002,30 @@ int drm_mode_getproperty_ioctl(struct drm_device *dev, } out_resp->count_values = value_count; - if ((out_resp->count_enums >= enum_count) && enum_count) { + if ((out_resp->count_enum_blobs >= enum_count) && enum_count && (property->flags & DRM_MODE_PROP_ENUM)) { + copied = 0; + enum_ptr = (struct drm_property_enum *)(unsigned long)out_resp->enum_blob_ptr; + list_for_each_entry(prop_enum, &property->enum_blob_list, head) { + if (put_user(prop_enum->value, &enum_ptr[copied].value)) { + ret = -EFAULT; + goto done; + } + + if (copy_to_user(&enum_ptr[copied].name, + prop_enum->name, DRM_PROP_NAME_LEN)) { + ret = -EFAULT; + goto done; + } + copied++; + } + } + out_resp->count_enum_blobs = enum_count; + +#if 0 + if ((out_resp->count_blobs >= enum_count) && blob_count && (property->flags & DRM_MODE_PROP_BLOB)) { copied = 0; - list_for_each_entry(prop_enum, &property->enum_list, head) { - if (put_user(prop_enum->value, &out_resp->enums[copied].value)) { + list_for_each_entry(prop_blob, &property->enum_list, head) { + if (put_user(prop_enum->value, &out_resp->blobs[copied].value)) { ret = -EFAULT; goto done; } @@ -1991,8 +2039,39 @@ int drm_mode_getproperty_ioctl(struct drm_device *dev, } } out_resp->count_enums = enum_count; - +#endif done: mutex_unlock(&dev->mode_config.mutex); return ret; } + +static int drm_property_create_blob(struct drm_device *dev, int length, + void *data) +{ + struct drm_property_blob *blob; + + if (!length || !data) + return -EINVAL; + + blob = kzalloc(sizeof(struct drm_property_blob)+length, GFP_KERNEL); + if (!blob) + return -EINVAL; + + blob->data = (void *)((char *)blob + sizeof(struct drm_property_blob)); + blob->length = length; + + memcpy(blob->data, data, length); + + blob->id = drm_idr_get(dev, blob); + + list_add_tail(&blob->head, &dev->mode_config.property_blob_list); + return blob->id; +} + +static void drm_property_destroy_blob(struct drm_device *dev, + struct drm_property_blob *blob) +{ + drm_idr_put(dev, blob->id); + list_del(&blob->head); + kfree(blob); +} diff --git a/linux-core/drm_crtc.h b/linux-core/drm_crtc.h index 90d6104f..d028f75f 100644 --- a/linux-core/drm_crtc.h +++ b/linux-core/drm_crtc.h @@ -234,9 +234,16 @@ struct drm_framebuffer { struct list_head filp_head; }; +struct drm_property_blob { + struct list_head head; + unsigned int id; + unsigned int length; + void *data; +}; + struct drm_property_enum { struct list_head head; - uint32_t value; + uint64_t value; unsigned char name[DRM_PROP_NAME_LEN]; }; @@ -246,9 +253,9 @@ struct drm_property { uint32_t flags; char name[DRM_PROP_NAME_LEN]; uint32_t num_values; - uint32_t *values; + uint64_t *values; - struct list_head enum_list; + struct list_head enum_blob_list; }; struct drm_crtc; @@ -451,7 +458,7 @@ struct drm_output { struct list_head user_modes; u32 property_ids[DRM_OUTPUT_MAX_PROPERTY]; - u32 property_values[DRM_OUTPUT_MAX_PROPERTY]; + uint64_t property_values[DRM_OUTPUT_MAX_PROPERTY]; }; /** @@ -492,6 +499,10 @@ struct drm_mode_config { /* DGA stuff? */ struct drm_mode_config_funcs *funcs; unsigned long fb_base; + + /* pointers to standard properties */ + struct list_head property_blob_list; + struct drm_property *edid_property; }; struct drm_output *drm_output_create(struct drm_device *dev, @@ -549,12 +560,12 @@ extern bool drm_crtc_set_mode(struct drm_crtc *crtc, struct drm_display_mode *mo int x, int y); extern int drm_output_attach_property(struct drm_output *output, - struct drm_property *property, int init_val); + struct drm_property *property, uint64_t init_val); extern struct drm_property *drm_property_create(struct drm_device *dev, int flags, const char *name, int num_values); extern void drm_property_destroy(struct drm_device *dev, struct drm_property *property); extern int drm_property_add_enum(struct drm_property *property, int index, - uint32_t value, const char *name); + uint64_t value, const char *name); /* IOCTLs */ extern int drm_mode_getresources(struct drm_device *dev, diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index 29c2e611..d3ad4654 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -245,4 +245,6 @@ void intel_crt_init(struct drm_device *dev) output->driver_private = intel_output; output->interlace_allowed = 0; output->doublescan_allowed = 0; + + drm_output_attach_property(output, dev->mode_config.edid_property, 0); } diff --git a/shared-core/drm.h b/shared-core/drm.h index f4f75cf5..6317f142 100644 --- a/shared-core/drm.h +++ b/shared-core/drm.h @@ -920,18 +920,19 @@ struct drm_mode_modeinfo { }; struct drm_mode_card_res { - + uint64_t fb_id_ptr; + uint64_t crtc_id_ptr; + uint64_t output_id_ptr; int count_fbs; - unsigned int __user *fb_id; - int count_crtcs; - unsigned int __user *crtc_id; - int count_outputs; - unsigned int __user *output_id; + int min_width, max_width; + int min_height, max_height; }; struct drm_mode_crtc { + uint64_t set_outputs_ptr; + unsigned int crtc_id; /**< Id */ unsigned int fb_id; /**< Id of framebuffer */ @@ -942,9 +943,6 @@ struct drm_mode_crtc { int count_possibles; unsigned int possibles; /**< Outputs that can be connected */ - - unsigned int __user *set_outputs; /**< Outputs to be connected */ - int gamma_size; int mode_valid; struct drm_mode_modeinfo mode; @@ -952,6 +950,12 @@ struct drm_mode_crtc { struct drm_mode_get_output { + uint64_t modes_ptr; + uint64_t props_ptr; + uint64_t prop_values_ptr; + + int count_modes; + int count_props; unsigned int output; /**< Id */ unsigned int crtc; /**< Id of crtc */ unsigned char name[DRM_OUTPUT_NAME_LEN]; @@ -959,42 +963,37 @@ struct drm_mode_get_output { unsigned int connection; unsigned int mm_width, mm_height; /**< HxW in millimeters */ unsigned int subpixel; - int count_crtcs; - unsigned int crtcs; /**< possible crtc to connect to */ - int count_clones; + unsigned int crtcs; /**< possible crtc to connect to */ unsigned int clones; /**< list of clones */ - - int count_modes; - struct drm_mode_modeinfo *modes; - - int count_props; - unsigned int __user *props; - unsigned int __user *prop_values; }; #define DRM_MODE_PROP_PENDING (1<<0) #define DRM_MODE_PROP_RANGE (1<<1) #define DRM_MODE_PROP_IMMUTABLE (1<<2) #define DRM_MODE_PROP_ENUM (1<<3) // enumerated type with text strings +#define DRM_MODE_PROP_BLOB (1<<4) struct drm_mode_property_enum { - uint32_t value; + uint64_t value; unsigned char name[DRM_PROP_NAME_LEN]; }; + +struct drm_mode_property_blob { + uint32_t length; +}; struct drm_mode_get_property { + uint64_t values_ptr; + uint64_t enum_blob_ptr; unsigned int prop_id; unsigned int flags; unsigned char name[DRM_PROP_NAME_LEN]; int count_values; - uint32_t __user *values; - - int count_enums; - struct drm_mode_property_enum *enums; + int count_enum_blobs; }; struct drm_mode_fb_cmd { @@ -1111,6 +1110,7 @@ struct drm_mode_mode_cmd { #define DRM_IOCTL_MODE_RMFB DRM_IOWR(0xA5, unsigned int) #define DRM_IOCTL_MODE_GETFB DRM_IOWR(0xA6, struct drm_mode_fb_cmd) +#define DRM_IOCTL_MODE_GETPROPBLOB DRM_IOWR(0xA8, struct drm_mode_get_propblob) #define DRM_IOCTL_MODE_ATTACHMODE DRM_IOWR(0xA9, struct drm_mode_mode_cmd) #define DRM_IOCTL_MODE_DETACHMODE DRM_IOWR(0xAA, struct drm_mode_mode_cmd) diff --git a/tests/mode/modetest.c b/tests/mode/modetest.c index 1d5002b0..46f88d82 100644 --- a/tests/mode/modetest.c +++ b/tests/mode/modetest.c @@ -76,16 +76,21 @@ int printOutput(int fd, drmModeResPtr res, drmModeOutputPtr output, uint32_t id) printf("\n\tenums %d: \n", props->count_enums); - for (j = 0; j < props->count_enums; j++) { - if (output->prop_values[i] == props->enums[j].value) - name = props->enums[j].name; - printf("\t\t%d = %s\n", props->enums[j].value, props->enums[j].name); - } + if (prop->flags & DRM_MODE_PROP_BLOB) { + - if (props->count_enums && name) { - printf("\toutput property name %s %s\n", props->name, name); } else { - printf("\toutput property id %s %i\n", props->name, output->prop_values[i]); + for (j = 0; j < props->count_enums; j++) { + if (output->prop_values[i] == props->enums[j].value) + name = props->enums[j].name; + printf("\t\t%d = %s\n", props->enums[j].value, props->enums[j].name); + } + + if (props->count_enums && name) { + printf("\toutput property name %s %s\n", props->name, name); + } else { + printf("\toutput property id %s %i\n", props->name, output->prop_values[i]); + } } drmModeFreeProperty(props); -- cgit v1.2.3 From 67f6eb1eb8d3dc5bb5fdb097655d3da326f637c1 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 6 Dec 2007 10:44:51 +1000 Subject: add property blobs and edid reporting support --- libdrm/xf86drmMode.c | 41 ++++++++++++++++++++++++++ libdrm/xf86drmMode.h | 3 ++ linux-core/drm_crtc.c | 75 ++++++++++++++++++++++++++++++++++++++++++++---- linux-core/drm_crtc.h | 8 ++++-- linux-core/drm_drv.c | 1 + linux-core/intel_crt.c | 1 - linux-core/intel_modes.c | 1 + shared-core/drm.h | 13 +++++---- tests/mode/modetest.c | 9 ++++-- 9 files changed, 134 insertions(+), 18 deletions(-) (limited to 'tests') diff --git a/libdrm/xf86drmMode.c b/libdrm/xf86drmMode.c index f4ec004c..03bd15f1 100644 --- a/libdrm/xf86drmMode.c +++ b/libdrm/xf86drmMode.c @@ -470,3 +470,44 @@ void drmModeFreeProperty(drmModePropertyPtr ptr) drmFree(ptr->enums); drmFree(ptr); } + +drmModePropertyBlobPtr drmModeGetPropertyBlob(int fd, uint32_t blob_id) +{ + struct drm_mode_get_blob blob; + drmModePropertyBlobPtr r; + + blob.length = 0; + blob.data = 0; + blob.blob_id = blob_id; + + if (ioctl(fd, DRM_IOCTL_MODE_GETPROPBLOB, &blob)) + return NULL; + + if (blob.length) + blob.data = VOID2U64(drmMalloc(blob.length)); + + if (ioctl(fd, DRM_IOCTL_MODE_GETPROPBLOB, &blob)) { + r = NULL; + goto err_allocs; + } + + if (!(r = drmMalloc(sizeof(*r)))) + return NULL; + + r->id = blob.blob_id; + r->length = blob.length; + r->data = drmAllocCpy(U642VOID(blob.data), 1, blob.length); + +err_allocs: + drmFree(U642VOID(blob.data)); + return r; +} + +void drmModeFreePropertyBlob(drmModePropertyBlobPtr ptr) +{ + if (!ptr) + return; + + drmFree(ptr->data); + drmFree(ptr); +} diff --git a/libdrm/xf86drmMode.h b/libdrm/xf86drmMode.h index e936044b..6fcf6a19 100644 --- a/libdrm/xf86drmMode.h +++ b/libdrm/xf86drmMode.h @@ -220,3 +220,6 @@ extern int drmModeDetachMode(int fd, uint32_t outputId, struct drm_mode_modeinfo 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); diff --git a/linux-core/drm_crtc.c b/linux-core/drm_crtc.c index a3aa783b..70844237 100644 --- a/linux-core/drm_crtc.c +++ b/linux-core/drm_crtc.c @@ -590,6 +590,8 @@ struct drm_output *drm_output_create(struct drm_device *dev, list_add_tail(&output->head, &dev->mode_config.output_list); dev->mode_config.num_output++; + drm_output_attach_property(output, dev->mode_config.edid_property, 0); + mutex_unlock(&dev->mode_config.mutex); return output; @@ -1935,7 +1937,6 @@ void drm_property_destroy(struct drm_device *dev, struct drm_property *property) } EXPORT_SYMBOL(drm_property_destroy); - int drm_output_attach_property(struct drm_output *output, struct drm_property *property, uint64_t init_val) { @@ -1955,6 +1956,24 @@ int drm_output_attach_property(struct drm_output *output, } EXPORT_SYMBOL(drm_output_attach_property); +int drm_output_property_set_value(struct drm_output *output, + struct drm_property *property, uint64_t value) +{ + int i; + + for (i = 0; i < DRM_OUTPUT_MAX_PROPERTY; i++) { + if (output->property_ids[i] == property->id) { + output->property_values[i] = value; + break; + } + } + + if (i == DRM_OUTPUT_MAX_PROPERTY) + return -EINVAL; + return 0; +} +EXPORT_SYMBOL(drm_output_property_set_value); + int drm_mode_getproperty_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) { @@ -2052,17 +2071,17 @@ done: return ret; } -static int drm_property_create_blob(struct drm_device *dev, int length, - void *data) +static struct drm_property_blob *drm_property_create_blob(struct drm_device *dev, int length, + void *data) { struct drm_property_blob *blob; if (!length || !data) - return -EINVAL; + return NULL; blob = kzalloc(sizeof(struct drm_property_blob)+length, GFP_KERNEL); if (!blob) - return -EINVAL; + return NULL; blob->data = (void *)((char *)blob + sizeof(struct drm_property_blob)); blob->length = length; @@ -2072,7 +2091,7 @@ static int drm_property_create_blob(struct drm_device *dev, int length, blob->id = drm_idr_get(dev, blob); list_add_tail(&blob->head, &dev->mode_config.property_blob_list); - return blob->id; + return blob; } static void drm_property_destroy_blob(struct drm_device *dev, @@ -2082,3 +2101,47 @@ static void drm_property_destroy_blob(struct drm_device *dev, list_del(&blob->head); kfree(blob); } + +int drm_mode_getblob_ioctl(struct drm_device *dev, + void *data, struct drm_file *file_priv) +{ + struct drm_mode_get_blob *out_resp = data; + struct drm_property_blob *blob; + int ret = 0; + void *blob_ptr; + + mutex_lock(&dev->mode_config.mutex); + + blob = idr_find(&dev->mode_config.crtc_idr, out_resp->blob_id); + if (!blob || (blob->id != out_resp->blob_id)) { + ret = -EINVAL; + goto done; + } + + if (out_resp->length == blob->length) { + blob_ptr = (void *)(unsigned long)out_resp->data; + if (copy_to_user(blob_ptr, blob->data, blob->length)){ + ret = -EFAULT; + goto done; + } + } + out_resp->length = blob->length; + +done: + mutex_unlock(&dev->mode_config.mutex); + return ret; +} + +int drm_mode_output_update_edid_property(struct drm_output *output, unsigned char *edid) +{ + struct drm_device *dev = output->dev; + int ret = 0; + if (output->edid_blob_ptr) + drm_property_destroy_blob(dev, output->edid_blob_ptr); + + output->edid_blob_ptr = drm_property_create_blob(output->dev, 128, edid); + + ret = drm_output_property_set_value(output, dev->mode_config.edid_property, output->edid_blob_ptr->id); + return ret; +} +EXPORT_SYMBOL(drm_mode_output_update_edid_property); diff --git a/linux-core/drm_crtc.h b/linux-core/drm_crtc.h index d028f75f..2c77d9d7 100644 --- a/linux-core/drm_crtc.h +++ b/linux-core/drm_crtc.h @@ -236,8 +236,8 @@ struct drm_framebuffer { struct drm_property_blob { struct list_head head; - unsigned int id; unsigned int length; + unsigned int id; void *data; }; @@ -456,7 +456,7 @@ struct drm_output { void *driver_private; struct list_head user_modes; - + struct drm_property_blob *edid_blob_ptr; u32 property_ids[DRM_OUTPUT_MAX_PROPERTY]; uint64_t property_values[DRM_OUTPUT_MAX_PROPERTY]; }; @@ -547,7 +547,7 @@ extern int drm_mode_vrefresh(struct drm_display_mode *mode); extern void drm_mode_set_crtcinfo(struct drm_display_mode *p, int adjust_flags); extern void drm_mode_output_list_update(struct drm_output *output); - +extern int drm_mode_output_update_edid_property(struct drm_output *output, unsigned char *edid); extern struct drm_display_mode *drm_crtc_mode_create(struct drm_device *dev); extern bool drm_initial_config(struct drm_device *dev, bool cangrow); extern void drm_framebuffer_set_object(struct drm_device *dev, @@ -594,5 +594,7 @@ extern int drm_mode_detachmode_ioctl(struct drm_device *dev, extern int drm_mode_getproperty_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv); +extern int drm_mode_getblob_ioctl(struct drm_device *dev, + void *data, struct drm_file *file_priv); #endif /* __DRM_CRTC_H__ */ diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c index a88ae8b5..f8665be7 100644 --- a/linux-core/drm_drv.c +++ b/linux-core/drm_drv.c @@ -125,6 +125,7 @@ static struct drm_ioctl_desc drm_ioctls[] = { DRM_IOCTL_DEF(DRM_IOCTL_MODE_RMFB, drm_mode_rmfb, DRM_MASTER|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETFB, drm_mode_getfb, DRM_MASTER|DRM_ROOT_ONLY), + DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETPROPBLOB, drm_mode_getblob_ioctl, DRM_MASTER|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_IOCTL_MODE_ATTACHMODE, drm_mode_attachmode_ioctl, DRM_MASTER|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_IOCTL_MODE_DETACHMODE, drm_mode_detachmode_ioctl, DRM_MASTER|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETPROPERTY, drm_mode_getproperty_ioctl, DRM_MASTER | DRM_ROOT_ONLY), diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index d3ad4654..2ab6a27b 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -246,5 +246,4 @@ void intel_crt_init(struct drm_device *dev) output->interlace_allowed = 0; output->doublescan_allowed = 0; - drm_output_attach_property(output, dev->mode_config.edid_property, 0); } diff --git a/linux-core/intel_modes.c b/linux-core/intel_modes.c index 346cf1ac..f8bf496c 100644 --- a/linux-core/intel_modes.c +++ b/linux-core/intel_modes.c @@ -55,6 +55,7 @@ int intel_ddc_get_modes(struct drm_output *output) edid = drm_get_edid(output, &intel_output->ddc_bus->adapter); if (edid) { + drm_mode_output_update_edid_property(output, edid); ret = drm_add_edid_modes(output, edid); kfree(edid); } diff --git a/shared-core/drm.h b/shared-core/drm.h index 7649abd6..0c66f85c 100644 --- a/shared-core/drm.h +++ b/shared-core/drm.h @@ -980,11 +980,6 @@ struct drm_mode_property_enum { unsigned char name[DRM_PROP_NAME_LEN]; }; -struct drm_mode_property_blob { - uint64_t data_ptr; - uint32_t length; -}; - struct drm_mode_get_property { uint64_t values_ptr; /* values and blob lengths */ uint64_t enum_blob_ptr; /* enum and blob id ptrs */ @@ -997,6 +992,12 @@ struct drm_mode_get_property { int count_enum_blobs; }; +struct drm_mode_get_blob { + uint32_t blob_id; + uint32_t length; + uint64_t data; +}; + struct drm_mode_fb_cmd { unsigned int buffer_id; unsigned int width, height; @@ -1111,7 +1112,7 @@ struct drm_mode_mode_cmd { #define DRM_IOCTL_MODE_RMFB DRM_IOWR(0xA5, unsigned int) #define DRM_IOCTL_MODE_GETFB DRM_IOWR(0xA6, struct drm_mode_fb_cmd) -#define DRM_IOCTL_MODE_GETPROPBLOB DRM_IOWR(0xA8, struct drm_mode_get_propblob) +#define DRM_IOCTL_MODE_GETPROPBLOB DRM_IOWR(0xA8, struct drm_mode_get_blob) #define DRM_IOCTL_MODE_ATTACHMODE DRM_IOWR(0xA9, struct drm_mode_mode_cmd) #define DRM_IOCTL_MODE_DETACHMODE DRM_IOWR(0xAA, struct drm_mode_mode_cmd) diff --git a/tests/mode/modetest.c b/tests/mode/modetest.c index 46f88d82..c396da41 100644 --- a/tests/mode/modetest.c +++ b/tests/mode/modetest.c @@ -75,9 +75,14 @@ int printOutput(int fd, drmModeResPtr res, drmModeOutputPtr output, uint32_t id) printf("%d ", props->values[j]); printf("\n\tenums %d: \n", props->count_enums); + + if (props->flags & DRM_MODE_PROP_BLOB) { + drmModePropertyBlobPtr blob; - if (prop->flags & DRM_MODE_PROP_BLOB) { - + blob = drmModeGetPropertyBlob(fd, output->prop_values[i]); + + printf("blob is %d length, %08X\n", blob->length, *(uint32_t *)blob->data); + drmModeFreePropertyBlob(blob); } else { for (j = 0; j < props->count_enums; j++) { -- cgit v1.2.3 From 3b6786e3e6523b1ceca3645ea4c6081f170d2134 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 11 Dec 2007 14:46:51 +1000 Subject: modesetting: add dpms property and initial settable property ioctl --- libdrm/xf86drmMode.c | 4 ++-- linux-core/drm_crtc.c | 59 +++++++++++++++++++++++++++++++++++++++++++++------ linux-core/drm_crtc.h | 5 +++-- shared-core/drm.h | 7 ++++++ tests/mode/Makefile | 2 +- tests/mode/modetest.c | 10 +++++---- 6 files changed, 71 insertions(+), 16 deletions(-) (limited to 'tests') diff --git a/libdrm/xf86drmMode.c b/libdrm/xf86drmMode.c index 03bd15f1..7e2683ea 100644 --- a/libdrm/xf86drmMode.c +++ b/libdrm/xf86drmMode.c @@ -421,10 +421,10 @@ drmModePropertyPtr drmModeGetProperty(int fd, uint32_t property_id) if (prop.count_values) prop.values_ptr = VOID2U64(drmMalloc(prop.count_values * sizeof(uint64_t))); - if (prop.count_enum_blobs & (prop.flags & DRM_MODE_PROP_ENUM)) + if (prop.count_enum_blobs && (prop.flags & DRM_MODE_PROP_ENUM)) prop.enum_blob_ptr = VOID2U64(drmMalloc(prop.count_enum_blobs * sizeof(struct drm_mode_property_enum))); - if (prop.count_enum_blobs & (prop.flags & DRM_MODE_PROP_BLOB)) { + if (prop.count_enum_blobs && (prop.flags & DRM_MODE_PROP_BLOB)) { prop.values_ptr = VOID2U64(drmMalloc(prop.count_enum_blobs * sizeof(uint32_t))); prop.enum_blob_ptr = VOID2U64(drmMalloc(prop.count_enum_blobs * sizeof(uint32_t))); } diff --git a/linux-core/drm_crtc.c b/linux-core/drm_crtc.c index fba275b7..871f8994 100644 --- a/linux-core/drm_crtc.c +++ b/linux-core/drm_crtc.c @@ -592,6 +592,8 @@ struct drm_output *drm_output_create(struct drm_device *dev, drm_output_attach_property(output, dev->mode_config.edid_property, 0); + drm_output_attach_property(output, dev->mode_config.dpms_property, 0); + mutex_unlock(&dev->mode_config.mutex); return output; @@ -729,6 +731,15 @@ void drm_mode_config_init(struct drm_device *dev) dev->mode_config.edid_property = drm_property_create(dev, DRM_MODE_PROP_BLOB | DRM_MODE_PROP_IMMUTABLE, "EDID", 0); + + dev->mode_config.dpms_property = drm_property_create(dev, + DRM_MODE_PROP_ENUM, + "DPMS", 4); + drm_property_add_enum(dev->mode_config.dpms_property, 0, DPMSModeOn, "On"); + drm_property_add_enum(dev->mode_config.dpms_property, 1, DPMSModeStandby, "Standby"); + drm_property_add_enum(dev->mode_config.dpms_property, 2, DPMSModeSuspend, "Suspend"); + drm_property_add_enum(dev->mode_config.dpms_property, 3, DPMSModeOff, "Off"); + } EXPORT_SYMBOL(drm_mode_config_init); @@ -1985,7 +1996,7 @@ int drm_mode_getproperty_ioctl(struct drm_device *dev, int ret = 0, i; int copied; struct drm_property_enum *prop_enum; - struct drm_property_enum __user *enum_ptr; + struct drm_mode_property_enum __user *enum_ptr; struct drm_property_blob *prop_blob; uint32_t *blob_id_ptr; uint64_t __user *values_ptr; @@ -2015,7 +2026,7 @@ int drm_mode_getproperty_ioctl(struct drm_device *dev, if ((out_resp->count_values >= value_count) && value_count) { values_ptr = (uint64_t *)(unsigned long)out_resp->values_ptr; for (i = 0; i < value_count; i++) { - if (put_user(property->values[i], values_ptr + i)) { + if (copy_to_user(values_ptr + i, &property->values[i], sizeof(uint64_t))) { ret = -EFAULT; goto done; } @@ -2024,19 +2035,21 @@ int drm_mode_getproperty_ioctl(struct drm_device *dev, out_resp->count_values = value_count; if (property->flags & DRM_MODE_PROP_ENUM) { + if ((out_resp->count_enum_blobs >= enum_count) && enum_count) { copied = 0; - enum_ptr = (struct drm_property_enum *)(unsigned long)out_resp->enum_blob_ptr; + enum_ptr = (struct drm_mode_property_enum *)(unsigned long)out_resp->enum_blob_ptr; list_for_each_entry(prop_enum, &property->enum_blob_list, head) { - if (put_user(prop_enum->value, &enum_ptr[copied].value)) { + + if (copy_to_user(&enum_ptr[copied].value, &prop_enum->value, sizeof(uint64_t))) { ret = -EFAULT; goto done; } if (copy_to_user(&enum_ptr[copied].name, - prop_enum->name, DRM_PROP_NAME_LEN)) { - ret = -EFAULT; - goto done; + &prop_enum->name, DRM_PROP_NAME_LEN)) { + ret = -EFAULT; + goto done; } copied++; } @@ -2145,3 +2158,35 @@ int drm_mode_output_update_edid_property(struct drm_output *output, unsigned cha return ret; } EXPORT_SYMBOL(drm_mode_output_update_edid_property); + +int drm_mode_output_property_set_ioctl(struct drm_device *dev, + void *data, struct drm_file *file_priv) +{ + struct drm_mode_output_set_property *out_resp = data; + struct drm_output *output; + int ret = -EINVAL; + int i; + + mutex_lock(&dev->mode_config.mutex); + output= idr_find(&dev->mode_config.crtc_idr, out_resp->output_id); + if (!output || (output->id != out_resp->output_id)) { + goto out; + } + + for (i = 0; i < DRM_OUTPUT_MAX_PROPERTY; i++) { + if (output->property_ids[i] == out_resp->prop_id) + break; + } + + if (i == DRM_OUTPUT_MAX_PROPERTY) { + goto out; + } + + if (output->funcs->set_property) + ret = output->funcs->set_property(output, out_resp->prop_id, out_resp->value); + +out: + mutex_unlock(&dev->mode_config.mutex); + return ret; +} + diff --git a/linux-core/drm_crtc.h b/linux-core/drm_crtc.h index 2c77d9d7..ad5ecc5d 100644 --- a/linux-core/drm_crtc.h +++ b/linux-core/drm_crtc.h @@ -242,8 +242,8 @@ struct drm_property_blob { }; struct drm_property_enum { - struct list_head head; uint64_t value; + struct list_head head; unsigned char name[DRM_PROP_NAME_LEN]; }; @@ -396,7 +396,7 @@ struct drm_output_funcs { enum drm_output_status (*detect)(struct drm_output *output); int (*get_modes)(struct drm_output *output); /* JJJ: type checking for properties via property value type */ - bool (*set_property)(struct drm_output *output, int prop, void *val); + bool (*set_property)(struct drm_output *output, int prop, uint64_t val); void (*cleanup)(struct drm_output *output); }; @@ -503,6 +503,7 @@ struct drm_mode_config { /* pointers to standard properties */ struct list_head property_blob_list; struct drm_property *edid_property; + struct drm_property *dpms_property; }; struct drm_output *drm_output_create(struct drm_device *dev, diff --git a/shared-core/drm.h b/shared-core/drm.h index 0c66f85c..df43802f 100644 --- a/shared-core/drm.h +++ b/shared-core/drm.h @@ -992,6 +992,12 @@ struct drm_mode_get_property { int count_enum_blobs; }; +struct drm_mode_output_set_property { + uint64_t value; + unsigned int prop_id; + unsigned int output_id; +}; + struct drm_mode_get_blob { uint32_t blob_id; uint32_t length; @@ -1112,6 +1118,7 @@ struct drm_mode_mode_cmd { #define DRM_IOCTL_MODE_RMFB DRM_IOWR(0xA5, unsigned int) #define DRM_IOCTL_MODE_GETFB DRM_IOWR(0xA6, struct drm_mode_fb_cmd) +#define DRM_IOCTL_MODE_SETPROPERTY DRM_IOWR(0xAB, struct drm_mode_set_output_property) #define DRM_IOCTL_MODE_GETPROPBLOB DRM_IOWR(0xA8, struct drm_mode_get_blob) #define DRM_IOCTL_MODE_ATTACHMODE DRM_IOWR(0xA9, struct drm_mode_mode_cmd) #define DRM_IOCTL_MODE_DETACHMODE DRM_IOWR(0xAA, struct drm_mode_mode_cmd) diff --git a/tests/mode/Makefile b/tests/mode/Makefile index 205c2ba1..a3d3b49a 100644 --- a/tests/mode/Makefile +++ b/tests/mode/Makefile @@ -5,7 +5,7 @@ all: modetest # -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE \ modetest: modetest.c - @gcc -o modetest -Wall -I../../libdrm -I../../shared-core -L../../libdrm/.libs -ldrm modetest.c + @gcc $(CFLAGS) -o modetest -Wall -I../../libdrm -I../../shared-core -L../../libdrm/.libs -ldrm modetest.c clean: @rm -f modetest diff --git a/tests/mode/modetest.c b/tests/mode/modetest.c index c396da41..4a8c6a17 100644 --- a/tests/mode/modetest.c +++ b/tests/mode/modetest.c @@ -80,15 +80,17 @@ int printOutput(int fd, drmModeResPtr res, drmModeOutputPtr output, uint32_t id) drmModePropertyBlobPtr blob; blob = drmModeGetPropertyBlob(fd, output->prop_values[i]); - - printf("blob is %d length, %08X\n", blob->length, *(uint32_t *)blob->data); - drmModeFreePropertyBlob(blob); + if (blob) { + printf("blob is %d length, %08X\n", blob->length, *(uint32_t *)blob->data); + drmModeFreePropertyBlob(blob); + } } else { for (j = 0; j < props->count_enums; j++) { + printf("\t\t%lld = %s\n", props->enums[j].value, props->enums[j].name); if (output->prop_values[i] == props->enums[j].value) name = props->enums[j].name; - printf("\t\t%d = %s\n", props->enums[j].value, props->enums[j].name); + } if (props->count_enums && name) { -- cgit v1.2.3 From f99dea7db00dd46aa96eaed3a61dff9c956fd86f Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 11 Dec 2007 15:56:48 +1000 Subject: modesetting: fixup property setting and add connector property --- libdrm/xf86drmMode.c | 18 +++++++++ libdrm/xf86drmMode.h | 2 + linux-core/drm_crtc.c | 102 +++++++++++++++++++++++++++++++++++++++++------- linux-core/drm_crtc.h | 22 ++++++++++- linux-core/drm_drv.c | 1 + linux-core/intel_crt.c | 15 +++++++ linux-core/intel_lvds.c | 1 + linux-core/intel_sdvo.c | 7 ++++ shared-core/drm.h | 2 +- tests/mode/modetest.c | 31 +++++++++++++-- 10 files changed, 181 insertions(+), 20 deletions(-) (limited to 'tests') diff --git a/libdrm/xf86drmMode.c b/libdrm/xf86drmMode.c index 7e2683ea..726c55ab 100644 --- a/libdrm/xf86drmMode.c +++ b/libdrm/xf86drmMode.c @@ -214,6 +214,8 @@ int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth, int drmModeRmFB(int fd, uint32_t bufferId) { return ioctl(fd, DRM_IOCTL_MODE_RMFB, &bufferId); + + } drmModeFBPtr drmModeGetFB(int fd, uint32_t buf) @@ -511,3 +513,19 @@ void drmModeFreePropertyBlob(drmModePropertyBlobPtr ptr) drmFree(ptr->data); drmFree(ptr); } + +int drmModeOutputSetProperty(int fd, uint32_t output_id, uint32_t property_id, + uint64_t value) +{ + struct drm_mode_output_set_property osp; + int ret; + + osp.output_id = output_id; + osp.prop_id = property_id; + osp.value = value; + + if (ret = ioctl(fd, DRM_IOCTL_MODE_SETPROPERTY, &osp)) + return ret; + + return 0; +} diff --git a/libdrm/xf86drmMode.h b/libdrm/xf86drmMode.h index 6fcf6a19..05b61bc8 100644 --- a/libdrm/xf86drmMode.h +++ b/libdrm/xf86drmMode.h @@ -223,3 +223,5 @@ 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, + uint64_t value); diff --git a/linux-core/drm_crtc.c b/linux-core/drm_crtc.c index 871f8994..e1b37c0b 100644 --- a/linux-core/drm_crtc.c +++ b/linux-core/drm_crtc.c @@ -33,6 +33,33 @@ #include "drmP.h" #include "drm_crtc.h" +struct drm_prop_enum_list { + int type; + char *name; +}; + +static struct drm_prop_enum_list drm_dpms_enum_list[] = +{ { DPMSModeOn, "On" }, + { DPMSModeStandby, "Standby" }, + { DPMSModeSuspend, "Suspend" }, + { DPMSModeOff, "Off" } +}; +static struct drm_prop_enum_list drm_conn_enum_list[] = +{ { ConnectorVGA, "VGA" }, + { ConnectorDVII, "DVI-I" }, + { ConnectorDVID, "DVI-D" }, + { ConnectorDVIA, "DVI-A" }, + { ConnectorComposite, "Composite" }, + { ConnectorSVIDEO, "SVIDEO" }, + { ConnectorLVDS, "LVDS" }, + { ConnectorComponent, "Component" }, + { Connector9PinDIN, "9-pin DIN" }, + { ConnectorDisplayPort, "DisplayPort" }, + { ConnectorHDMIA, "HDMI Type A" }, + { ConnectorHDMIB, "HDMI Type B" }, +}; + + /** * drm_idr_get - allocate a new identifier * @dev: DRM device @@ -709,6 +736,34 @@ void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode) } EXPORT_SYMBOL(drm_mode_destroy); +static int drm_mode_create_standard_output_properties(struct drm_device *dev) +{ + int i; + + dev->mode_config.edid_property = + drm_property_create(dev, DRM_MODE_PROP_BLOB | DRM_MODE_PROP_IMMUTABLE, + "EDID", 0); + + dev->mode_config.dpms_property = + drm_property_create(dev, DRM_MODE_PROP_ENUM, "DPMS", 4); + + for (i = 0; i < ARRAY_SIZE(drm_dpms_enum_list); i++) + drm_property_add_enum(dev->mode_config.dpms_property, i, drm_dpms_enum_list[i].type, drm_dpms_enum_list[i].name); + + dev->mode_config.connector_type_property = + drm_property_create(dev, DRM_MODE_PROP_ENUM | DRM_MODE_PROP_IMMUTABLE, + "Connector Type", 10); + for (i = 0; i < ARRAY_SIZE(drm_conn_enum_list); i++) + drm_property_add_enum(dev->mode_config.connector_type_property, i, drm_conn_enum_list[i].type, drm_conn_enum_list[i].name); + + dev->mode_config.connector_num_property = + drm_property_create(dev, DRM_MODE_PROP_RANGE | DRM_MODE_PROP_IMMUTABLE, + "Connector ID", 2); + dev->mode_config.connector_num_property->values[0] = 0; + dev->mode_config.connector_num_property->values[1] = 20; + return 0; +} + /** * drm_mode_config_init - initialize DRM mode_configuration structure * @dev: DRM device @@ -728,17 +783,8 @@ void drm_mode_config_init(struct drm_device *dev) INIT_LIST_HEAD(&dev->mode_config.property_list); INIT_LIST_HEAD(&dev->mode_config.property_blob_list); idr_init(&dev->mode_config.crtc_idr); - dev->mode_config.edid_property = drm_property_create(dev, - DRM_MODE_PROP_BLOB | DRM_MODE_PROP_IMMUTABLE, - "EDID", 0); - - dev->mode_config.dpms_property = drm_property_create(dev, - DRM_MODE_PROP_ENUM, - "DPMS", 4); - drm_property_add_enum(dev->mode_config.dpms_property, 0, DPMSModeOn, "On"); - drm_property_add_enum(dev->mode_config.dpms_property, 1, DPMSModeStandby, "Standby"); - drm_property_add_enum(dev->mode_config.dpms_property, 2, DPMSModeSuspend, "Suspend"); - drm_property_add_enum(dev->mode_config.dpms_property, 3, DPMSModeOff, "Off"); + + drm_mode_create_standard_output_properties(dev); } EXPORT_SYMBOL(drm_mode_config_init); @@ -2160,15 +2206,16 @@ int drm_mode_output_update_edid_property(struct drm_output *output, unsigned cha EXPORT_SYMBOL(drm_mode_output_update_edid_property); int drm_mode_output_property_set_ioctl(struct drm_device *dev, - void *data, struct drm_file *file_priv) + void *data, struct drm_file *file_priv) { struct drm_mode_output_set_property *out_resp = data; + struct drm_property *property; struct drm_output *output; int ret = -EINVAL; int i; mutex_lock(&dev->mode_config.mutex); - output= idr_find(&dev->mode_config.crtc_idr, out_resp->output_id); + output = idr_find(&dev->mode_config.crtc_idr, out_resp->output_id); if (!output || (output->id != out_resp->output_id)) { goto out; } @@ -2182,8 +2229,35 @@ int drm_mode_output_property_set_ioctl(struct drm_device *dev, goto out; } + property = idr_find(&dev->mode_config.crtc_idr, out_resp->prop_id); + if (!property || (property->id != out_resp->prop_id)) { + goto out; + } + + if (property->flags & DRM_MODE_PROP_IMMUTABLE) + goto out; + + if (property->flags & DRM_MODE_PROP_RANGE) { + if (out_resp->value < property->values[0]) + goto out; + + if (out_resp->value > property->values[1]) + goto out; + } else { + int found = 0; + for (i = 0; i < property->num_values; i++) { + if (property->values[i] == out_resp->value) { + found = 1; + break; + } + } + if (!found) { + goto out; + } + } + if (output->funcs->set_property) - ret = output->funcs->set_property(output, out_resp->prop_id, out_resp->value); + ret = output->funcs->set_property(output, property, out_resp->value); out: mutex_unlock(&dev->mode_config.mutex); diff --git a/linux-core/drm_crtc.h b/linux-core/drm_crtc.h index ad5ecc5d..6b6e1dbf 100644 --- a/linux-core/drm_crtc.h +++ b/linux-core/drm_crtc.h @@ -142,11 +142,26 @@ struct drm_display_mode { #define V_CLKDIV2 (1<<13) #define CRTC_INTERLACE_HALVE_V 0x1 /* halve V values for interlacing */ + #define DPMSModeOn 0 #define DPMSModeStandby 1 #define DPMSModeSuspend 2 #define DPMSModeOff 3 +#define ConnectorUnknown 0 +#define ConnectorVGA 1 +#define ConnectorDVII 2 +#define ConnectorDVID 3 +#define ConnectorDVIA 4 +#define ConnectorComposite 5 +#define ConnectorSVIDEO 6 +#define ConnectorLVDS 7 +#define ConnectorComponent 8 +#define Connector9PinDIN 9 +#define ConnectorDisplayPort 10 +#define ConnectorHDMIA 11 +#define ConnectorHDMIB 12 + enum drm_output_status { output_status_connected = 1, output_status_disconnected = 2, @@ -396,7 +411,8 @@ struct drm_output_funcs { enum drm_output_status (*detect)(struct drm_output *output); int (*get_modes)(struct drm_output *output); /* JJJ: type checking for properties via property value type */ - bool (*set_property)(struct drm_output *output, int prop, uint64_t val); + bool (*set_property)(struct drm_output *output, struct drm_property *property, + uint64_t val); void (*cleanup)(struct drm_output *output); }; @@ -504,6 +520,8 @@ struct drm_mode_config { struct list_head property_blob_list; struct drm_property *edid_property; struct drm_property *dpms_property; + struct drm_property *connector_type_property; + struct drm_property *connector_num_property; }; struct drm_output *drm_output_create(struct drm_device *dev, @@ -597,5 +615,7 @@ extern int drm_mode_getproperty_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv); extern int drm_mode_getblob_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv); +extern int drm_mode_output_property_set_ioctl(struct drm_device *dev, + void *data, struct drm_file *file_priv); #endif /* __DRM_CRTC_H__ */ diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c index f8665be7..98fb9ac8 100644 --- a/linux-core/drm_drv.c +++ b/linux-core/drm_drv.c @@ -125,6 +125,7 @@ static struct drm_ioctl_desc drm_ioctls[] = { DRM_IOCTL_DEF(DRM_IOCTL_MODE_RMFB, drm_mode_rmfb, DRM_MASTER|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETFB, drm_mode_getfb, DRM_MASTER|DRM_ROOT_ONLY), + DRM_IOCTL_DEF(DRM_IOCTL_MODE_SETPROPERTY, drm_mode_output_property_set_ioctl, DRM_MASTER|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETPROPBLOB, drm_mode_getblob_ioctl, DRM_MASTER|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_IOCTL_MODE_ATTACHMODE, drm_mode_attachmode_ioctl, DRM_MASTER|DRM_ROOT_ONLY), DRM_IOCTL_DEF(DRM_IOCTL_MODE_DETACHMODE, drm_mode_detachmode_ioctl, DRM_MASTER|DRM_ROOT_ONLY), diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index 2ab6a27b..722a62c8 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -204,6 +204,19 @@ static int intel_crt_get_modes(struct drm_output *output) return intel_ddc_get_modes(output); } +static bool intel_crt_set_property(struct drm_output *output, + struct drm_property *property, + uint64_t value) +{ + struct drm_device *dev = output->dev; + int i; + + if (property == dev->mode_config.dpms_property) { + intel_crt_dpms(output, (uint32_t)(value & 0xf)); + } + return true; +} + /* * Routines for controlling stuff on the analog port */ @@ -219,6 +232,7 @@ static const struct drm_output_funcs intel_crt_output_funcs = { .detect = intel_crt_detect, .get_modes = intel_crt_get_modes, .cleanup = intel_crt_destroy, + .set_property = intel_crt_set_property, }; void intel_crt_init(struct drm_device *dev) @@ -246,4 +260,5 @@ void intel_crt_init(struct drm_device *dev) output->interlace_allowed = 0; output->doublescan_allowed = 0; + drm_output_attach_property(output, dev->mode_config.connector_type_property, ConnectorVGA); } diff --git a/linux-core/intel_lvds.c b/linux-core/intel_lvds.c index e3e4b38a..94232b94 100644 --- a/linux-core/intel_lvds.c +++ b/linux-core/intel_lvds.c @@ -499,6 +499,7 @@ void intel_lvds_init(struct drm_device *dev) #endif out: + drm_output_attach_property(output, dev->mode_config.connector_type_property, ConnectorLVDS); return; failed: diff --git a/linux-core/intel_sdvo.c b/linux-core/intel_sdvo.c index 51fe43cb..0da57faa 100644 --- a/linux-core/intel_sdvo.c +++ b/linux-core/intel_sdvo.c @@ -950,6 +950,7 @@ void intel_sdvo_init(struct drm_device *dev, int output_device) struct intel_output *intel_output; struct intel_sdvo_priv *sdvo_priv; struct intel_i2c_chan *i2cbus = NULL; + int connector_type; u8 ch[0x40]; int i; char name[DRM_OUTPUT_LEN]; @@ -1019,24 +1020,28 @@ void intel_sdvo_init(struct drm_device *dev, int output_device) sdvo_priv->active_outputs = SDVO_OUTPUT_RGB0; output->subpixel_order = SubPixelHorizontalRGB; name_prefix="RGB"; + connector_type = ConnectorVGA; } else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_RGB1) { sdvo_priv->active_outputs = SDVO_OUTPUT_RGB1; output->subpixel_order = SubPixelHorizontalRGB; name_prefix="RGB"; + connector_type = ConnectorVGA; } else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_TMDS0) { sdvo_priv->active_outputs = SDVO_OUTPUT_TMDS0; output->subpixel_order = SubPixelHorizontalRGB; name_prefix="TMDS"; + connector_type = ConnectorDVID; } else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_TMDS1) { sdvo_priv->active_outputs = SDVO_OUTPUT_TMDS1; output->subpixel_order = SubPixelHorizontalRGB; name_prefix="TMDS"; + connector_type = ConnectorDVID; } else { @@ -1084,4 +1089,6 @@ void intel_sdvo_init(struct drm_device *dev, int output_device) (SDVO_OUTPUT_TMDS1 | SDVO_OUTPUT_RGB1) ? 'Y' : 'N'); intel_output->ddc_bus = i2cbus; + + drm_output_attach_property(output, dev->mode_config.connector_type_property, connector_type); } diff --git a/shared-core/drm.h b/shared-core/drm.h index df43802f..f13e36c9 100644 --- a/shared-core/drm.h +++ b/shared-core/drm.h @@ -1118,7 +1118,7 @@ struct drm_mode_mode_cmd { #define DRM_IOCTL_MODE_RMFB DRM_IOWR(0xA5, unsigned int) #define DRM_IOCTL_MODE_GETFB DRM_IOWR(0xA6, struct drm_mode_fb_cmd) -#define DRM_IOCTL_MODE_SETPROPERTY DRM_IOWR(0xAB, struct drm_mode_set_output_property) +#define DRM_IOCTL_MODE_SETPROPERTY DRM_IOWR(0xA7, struct drm_mode_output_set_property) #define DRM_IOCTL_MODE_GETPROPBLOB DRM_IOWR(0xA8, struct drm_mode_get_blob) #define DRM_IOCTL_MODE_ATTACHMODE DRM_IOWR(0xA9, struct drm_mode_mode_cmd) #define DRM_IOCTL_MODE_DETACHMODE DRM_IOWR(0xAA, struct drm_mode_mode_cmd) diff --git a/tests/mode/modetest.c b/tests/mode/modetest.c index 4a8c6a17..f1fe64df 100644 --- a/tests/mode/modetest.c +++ b/tests/mode/modetest.c @@ -3,10 +3,13 @@ #include #include #include +#include +#include #include "xf86drm.h" #include "xf86drmMode.h" +int dpms_prop_id = 0; const char* getConnectionText(drmModeConnection conn) { switch (conn) { @@ -72,7 +75,7 @@ int printOutput(int fd, drmModeResPtr res, drmModeOutputPtr output, uint32_t id) printf("\tflags: %i\n", props->flags); printf("\tvalues %d: ", props->count_values); for (j = 0; j < props->count_values; j++) - printf("%d ", props->values[j]); + printf("%lld ", props->values[j]); printf("\n\tenums %d: \n", props->count_enums); @@ -86,6 +89,9 @@ int printOutput(int fd, drmModeResPtr res, drmModeOutputPtr output, uint32_t id) } } else { + if (!strncmp(props->name, "DPMS", 4)) + dpms_prop_id = props->prop_id; + for (j = 0; j < props->count_enums; j++) { printf("\t\t%lld = %s\n", props->enums[j].value, props->enums[j].name); if (output->prop_values[i] == props->enums[j].value) @@ -96,7 +102,7 @@ int printOutput(int fd, drmModeResPtr res, drmModeOutputPtr output, uint32_t id) if (props->count_enums && name) { printf("\toutput property name %s %s\n", props->name, name); } else { - printf("\toutput property id %s %i\n", props->name, output->prop_values[i]); + printf("\toutput property id %s %lli\n", props->name, output->prop_values[i]); } } @@ -109,7 +115,7 @@ int printOutput(int fd, drmModeResPtr res, drmModeOutputPtr output, uint32_t id) if (mode) printMode(mode); else - printf("\t\tmode: Invalid mode %i\n", output->modes[i]); + printf("\t\tmode: Invalid mode %p\n", &output->modes[i]); } return 0; @@ -123,7 +129,7 @@ int printCrtc(int fd, drmModeResPtr res, drmModeCrtcPtr crtc, uint32_t id) printf("\ty : %i\n", crtc->y); printf("\twidth : %i\n", crtc->width); printf("\theight : %i\n", crtc->height); - printf("\tmode : %i\n", crtc->mode); + printf("\tmode : %p\n", &crtc->mode); printf("\tnum outputs : %i\n", crtc->count_outputs); printf("\toutputs : %i\n", crtc->outputs); printf("\tnum possible : %i\n", crtc->count_possibles); @@ -314,6 +320,21 @@ err: return 1; } +int testDPMS(int fd, drmModeResPtr res) +{ + int output_id; + int i; + + for (i = 0; i < res->count_outputs; i++) { + output_id = res->outputs[i]; + /* turn output off */ + drmModeOutputSetProperty(fd, output_id, dpms_prop_id, 3); + sleep(2); + drmModeOutputSetProperty(fd, output_id, dpms_prop_id, 0); + } + return 1; + +} int main(int argc, char **argv) { @@ -343,6 +364,8 @@ int main(int argc, char **argv) testFrameBufferAdd(fd, res); + /* try dpms test */ + testDPMS(fd, res); drmModeFreeResources(res); printf("Ok\n"); -- cgit v1.2.3 From b13dc383df85d75cb1ea422f4d13efc2a4a8a732 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 18 Dec 2007 17:41:20 +1100 Subject: remove output names --- libdrm/xf86drmMode.c | 6 +++-- libdrm/xf86drmMode.h | 3 ++- linux-core/drm_bo.c | 2 +- linux-core/drm_crtc.c | 68 +++++++++++++++++++------------------------------ linux-core/drm_crtc.h | 12 +++++---- linux-core/drm_edid.c | 6 ++--- linux-core/intel_crt.c | 3 ++- linux-core/intel_lvds.c | 3 ++- linux-core/intel_sdvo.c | 31 +++++++++------------- shared-core/drm.h | 9 ++++++- shared-core/i915_init.c | 4 +-- tests/mode/modetest.c | 2 +- 12 files changed, 70 insertions(+), 79 deletions(-) (limited to 'tests') diff --git a/libdrm/xf86drmMode.c b/libdrm/xf86drmMode.c index 726c55ab..0edb1d7d 100644 --- a/libdrm/xf86drmMode.c +++ b/libdrm/xf86drmMode.c @@ -328,6 +328,8 @@ drmModeOutputPtr drmModeGetOutput(int fd, uint32_t output_id) 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; @@ -372,8 +374,8 @@ drmModeOutputPtr drmModeGetOutput(int fd, uint32_t output_id) 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)); - strncpy(r->name, out.name, DRM_OUTPUT_NAME_LEN); - r->name[DRM_OUTPUT_NAME_LEN-1] = 0; + r->output_type = out.output_type; + r->output_type_id = out.output_type_id; err_allocs: drmFree(U642VOID(out.prop_values_ptr)); diff --git a/libdrm/xf86drmMode.h b/libdrm/xf86drmMode.h index 05b61bc8..e2dda8ac 100644 --- a/libdrm/xf86drmMode.h +++ b/libdrm/xf86drmMode.h @@ -125,7 +125,8 @@ typedef struct _drmModeOutput { unsigned int output_id; unsigned int crtc; /**< Crtc currently connected to */ - unsigned char name[DRM_OUTPUT_NAME_LEN]; + unsigned int output_type; + unsigned int output_type_id; drmModeConnection connection; uint32_t mmWidth, mmHeight; /**< HxW in millimeters */ drmModeSubPixel subpixel; diff --git a/linux-core/drm_bo.c b/linux-core/drm_bo.c index 7a123dad..c89d6608 100644 --- a/linux-core/drm_bo.c +++ b/linux-core/drm_bo.c @@ -1650,7 +1650,7 @@ int drm_buffer_object_create(struct drm_device *dev, size += buffer_start & ~PAGE_MASK; num_pages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT; if (num_pages == 0) { - DRM_ERROR("Illegal buffer object size.\n"); + DRM_ERROR("Illegal buffer object size %d.\n", size); return -EINVAL; } diff --git a/linux-core/drm_crtc.c b/linux-core/drm_crtc.c index e1b37c0b..9a840ea1 100644 --- a/linux-core/drm_crtc.c +++ b/linux-core/drm_crtc.c @@ -58,7 +58,22 @@ static struct drm_prop_enum_list drm_conn_enum_list[] = { ConnectorHDMIA, "HDMI Type A" }, { ConnectorHDMIB, "HDMI Type B" }, }; +static struct drm_prop_enum_list drm_output_enum_list[] = +{ { DRM_MODE_OUTPUT_NONE, "None" }, + { DRM_MODE_OUTPUT_DAC, "DAC" }, + { DRM_MODE_OUTPUT_TMDS, "TMDS" }, + { DRM_MODE_OUTPUT_LVDS, "LVDS" }, + { DRM_MODE_OUTPUT_TVDAC, "TV" }, +}; +char *drm_get_output_name(struct drm_output *output) +{ + static char buf[32]; + + snprintf(buf, 32, "%s-%d", drm_output_enum_list[output->output_type].name, + output->output_type_id); + return buf; +} /** * drm_idr_get - allocate a new identifier @@ -322,7 +337,7 @@ void drm_crtc_probe_single_output_modes(struct drm_output *output, int maxX, int output->status = (*output->funcs->detect)(output); if (output->status == output_status_disconnected) { - DRM_DEBUG("%s is disconnected\n", output->name); + DRM_DEBUG("%s is disconnected\n", drm_get_output_name(output)); /* TODO set EDID to NULL */ return; } @@ -347,7 +362,7 @@ void drm_crtc_probe_single_output_modes(struct drm_output *output, int maxX, int if (list_empty(&output->modes)) { struct drm_display_mode *stdmode; - DRM_DEBUG("No valid modes on %s\n", output->name); + DRM_DEBUG("No valid modes on %s\n", drm_get_output_name(output)); /* Should we do this here ??? * When no valid EDID modes are available we end up @@ -360,12 +375,12 @@ void drm_crtc_probe_single_output_modes(struct drm_output *output, int maxX, int &output->modes); DRM_DEBUG("Adding standard 640x480 @ 60Hz to %s\n", - output->name); + drm_get_output_name(output)); } drm_mode_sort(&output->modes); - DRM_DEBUG("Probed modes for %s\n", output->name); + DRM_DEBUG("Probed modes for %s\n", drm_get_output_name(output)); list_for_each_entry_safe(mode, t, &output->modes, head) { mode->vrefresh = drm_mode_vrefresh(mode); @@ -472,7 +487,7 @@ bool drm_crtc_set_mode(struct drm_crtc *crtc, struct drm_display_mode *mode, if (output->crtc != crtc) continue; - DRM_INFO("%s: set mode %s %x\n", output->name, mode->name, mode->mode_id); + DRM_INFO("%s: set mode %s %x\n", drm_get_output_name(output), mode->name, mode->mode_id); output->funcs->mode_set(output, mode, adjusted_mode); } @@ -591,7 +606,7 @@ EXPORT_SYMBOL(drm_mode_remove); */ struct drm_output *drm_output_create(struct drm_device *dev, const struct drm_output_funcs *funcs, - const char *name) + int output_type) { struct drm_output *output = NULL; @@ -602,9 +617,8 @@ struct drm_output *drm_output_create(struct drm_device *dev, output->dev = dev; output->funcs = funcs; output->id = drm_idr_get(dev, output); - if (name) - strncpy(output->name, name, DRM_OUTPUT_LEN); - output->name[DRM_OUTPUT_LEN - 1] = 0; + output->output_type = output_type; + output->output_type_id = 1; /* TODO */ output->subpixel_order = SubPixelUnknown; INIT_LIST_HEAD(&output->user_modes); INIT_LIST_HEAD(&output->probed_modes); @@ -663,35 +677,6 @@ void drm_output_destroy(struct drm_output *output) } EXPORT_SYMBOL(drm_output_destroy); -/** - * drm_output_rename - rename an output - * @output: output to rename - * @name: new user visible name - * - * LOCKING: - * None. - * - * Simply stuff a new name into @output's name field, based on @name. - * - * RETURNS: - * True if the name was changed, false otherwise. - */ -bool drm_output_rename(struct drm_output *output, const char *name) -{ - if (!name) - return false; - - strncpy(output->name, name, DRM_OUTPUT_LEN); - output->name[DRM_OUTPUT_LEN - 1] = 0; - - DRM_DEBUG("Changed name to %s\n", output->name); -// drm_output_set_monitor(output); -// if (drm_output_ignored(output)) -// return FALSE; - - return TRUE; -} -EXPORT_SYMBOL(drm_output_rename); /** * drm_mode_create - create a new display mode @@ -912,7 +897,7 @@ static void drm_pick_crtcs (struct drm_device *dev) list_for_each_entry(modes_equal, &output_equal->modes, head) { if (drm_mode_equal (modes, modes_equal)) { if ((output->possible_clones & output_equal->possible_clones) && (output_equal->crtc == crtc)) { - printk("Cloning %s (0x%lx) to %s (0x%lx)\n",output->name,output->possible_clones,output_equal->name,output_equal->possible_clones); + printk("Cloning %s (0x%lx) to %s (0x%lx)\n",drm_get_output_name(output),output->possible_clones,drm_get_output_name(output_equal),output_equal->possible_clones); assigned = 0; goto clone; } @@ -1408,9 +1393,8 @@ int drm_mode_getoutput(struct drm_device *dev, drm_crtc_probe_single_output_modes(output, dev->mode_config.max_width, dev->mode_config.max_height); } - strncpy(out_resp->name, output->name, DRM_OUTPUT_NAME_LEN); - out_resp->name[DRM_OUTPUT_NAME_LEN-1] = 0; - + out_resp->output_type = output->output_type; + out_resp->output_type_id = output->output_type_id; out_resp->mm_width = output->mm_width; out_resp->mm_height = output->mm_height; out_resp->subpixel = output->subpixel_order; diff --git a/linux-core/drm_crtc.h b/linux-core/drm_crtc.h index 6b6e1dbf..dbb41867 100644 --- a/linux-core/drm_crtc.h +++ b/linux-core/drm_crtc.h @@ -433,7 +433,6 @@ struct drm_output_funcs { * @subpixel_order: for this output * @mm_width: displayable width of output in mm * @mm_height: displayable height of output in mm - * @name: name of output (should be one of a few standard names) * @funcs: output control functions * @driver_private: private driver data * @@ -447,6 +446,9 @@ struct drm_output { struct list_head head; struct drm_crtc *crtc; int id; /* idr assigned */ + + int output_type; + int output_type_id; unsigned long possible_crtcs; unsigned long possible_clones; bool interlace_allowed; @@ -467,8 +469,7 @@ struct drm_output { enum subpixel_order subpixel_order; int mm_width, mm_height; struct drm_display_info *monitor_info; /* if any */ - char name[DRM_OUTPUT_LEN]; - const struct drm_output_funcs *funcs; + const struct drm_output_funcs *funcs; void *driver_private; struct list_head user_modes; @@ -526,9 +527,10 @@ struct drm_mode_config { struct drm_output *drm_output_create(struct drm_device *dev, const struct drm_output_funcs *funcs, - const char *name); + int type); + +extern char *drm_get_output_name(struct drm_output *output); extern void drm_output_destroy(struct drm_output *output); -extern bool drm_output_rename(struct drm_output *output, const char *name); extern void drm_fb_release(struct file *filp); extern struct edid *drm_get_edid(struct drm_output *output, diff --git a/linux-core/drm_edid.c b/linux-core/drm_edid.c index 7068cef3..41aa8f5e 100644 --- a/linux-core/drm_edid.c +++ b/linux-core/drm_edid.c @@ -443,12 +443,12 @@ struct edid *drm_get_edid(struct drm_output *output, edid = (struct edid *)drm_ddc_read(adapter); if (!edid) { dev_warn(&output->dev->pdev->dev, "%s: no EDID data\n", - output->name); + drm_get_output_name(output)); return NULL; } if (!edid_valid(edid)) { dev_warn(&output->dev->pdev->dev, "%s: EDID invalid.\n", - output->name); + drm_get_output_name(output)); kfree(edid); return NULL; } @@ -474,7 +474,7 @@ int drm_add_edid_modes(struct drm_output *output, struct edid *edid) } if (!edid_valid(edid)) { dev_warn(&output->dev->pdev->dev, "%s: EDID invalid.\n", - output->name); + drm_get_output_name(output)); return 0; } num_modes += add_established_modes(output, edid); diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index 722a62c8..74e3dcd6 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -240,7 +240,8 @@ void intel_crt_init(struct drm_device *dev) struct drm_output *output; struct intel_output *intel_output; - output = drm_output_create(dev, &intel_crt_output_funcs, "VGA"); + output = drm_output_create(dev, &intel_crt_output_funcs, + DRM_MODE_OUTPUT_DAC); intel_output = kmalloc(sizeof(struct intel_output), GFP_KERNEL); if (!intel_output) { diff --git a/linux-core/intel_lvds.c b/linux-core/intel_lvds.c index 94232b94..80f77af6 100644 --- a/linux-core/intel_lvds.c +++ b/linux-core/intel_lvds.c @@ -372,7 +372,8 @@ void intel_lvds_init(struct drm_device *dev) u32 lvds; int pipe; - output = drm_output_create(dev, &intel_lvds_output_funcs, "LVDS"); + output = drm_output_create(dev, &intel_lvds_output_funcs, + DRM_MODE_OUTPUT_LVDS); if (!output) return; diff --git a/linux-core/intel_sdvo.c b/linux-core/intel_sdvo.c index 0da57faa..7f55829b 100644 --- a/linux-core/intel_sdvo.c +++ b/linux-core/intel_sdvo.c @@ -953,12 +953,10 @@ void intel_sdvo_init(struct drm_device *dev, int output_device) int connector_type; u8 ch[0x40]; int i; - char name[DRM_OUTPUT_LEN]; - char *name_prefix; - char *name_suffix; - + int output_type, output_id; - output = drm_output_create(dev, &intel_sdvo_output_funcs, NULL); + output = drm_output_create(dev, &intel_sdvo_output_funcs, + DRM_MODE_OUTPUT_NONE); if (!output) return; @@ -988,10 +986,10 @@ void intel_sdvo_init(struct drm_device *dev, int output_device) sdvo_priv->i2c_bus = i2cbus; if (output_device == SDVOB) { - name_suffix = "-1"; + output_id = 1; sdvo_priv->i2c_bus->slave_addr = 0x38; } else { - name_suffix = "-2"; + output_id = 2; sdvo_priv->i2c_bus->slave_addr = 0x39; } @@ -1019,28 +1017,28 @@ void intel_sdvo_init(struct drm_device *dev, int output_device) { sdvo_priv->active_outputs = SDVO_OUTPUT_RGB0; output->subpixel_order = SubPixelHorizontalRGB; - name_prefix="RGB"; + output_type = DRM_MODE_OUTPUT_DAC; connector_type = ConnectorVGA; } else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_RGB1) { sdvo_priv->active_outputs = SDVO_OUTPUT_RGB1; output->subpixel_order = SubPixelHorizontalRGB; - name_prefix="RGB"; + output_type = DRM_MODE_OUTPUT_DAC; connector_type = ConnectorVGA; } else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_TMDS0) { sdvo_priv->active_outputs = SDVO_OUTPUT_TMDS0; output->subpixel_order = SubPixelHorizontalRGB; - name_prefix="TMDS"; + output_type = DRM_MODE_OUTPUT_TMDS; connector_type = ConnectorDVID; } else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_TMDS1) { sdvo_priv->active_outputs = SDVO_OUTPUT_TMDS1; output->subpixel_order = SubPixelHorizontalRGB; - name_prefix="TMDS"; + output_type = DRM_MODE_OUTPUT_TMDS; connector_type = ConnectorDVID; } else @@ -1054,14 +1052,9 @@ void intel_sdvo_init(struct drm_device *dev, int output_device) drm_output_destroy(output); return; } - strcpy (name, name_prefix); - strcat (name, name_suffix); - if (!drm_output_rename(output, name)) - { - drm_output_destroy(output); - return; - } - + + output->output_type = output_type; + output->output_type_id = output_id; /* Set the input timing to the screen. Assume always input 0. */ intel_sdvo_set_target_input(output, true, false); diff --git a/shared-core/drm.h b/shared-core/drm.h index 9a8dc1d2..f8d44048 100644 --- a/shared-core/drm.h +++ b/shared-core/drm.h @@ -950,6 +950,12 @@ struct drm_mode_crtc { struct drm_mode_modeinfo mode; }; +#define DRM_MODE_OUTPUT_NONE 0 +#define DRM_MODE_OUTPUT_DAC 1 +#define DRM_MODE_OUTPUT_TMDS 2 +#define DRM_MODE_OUTPUT_LVDS 3 +#define DRM_MODE_OUTPUT_TVDAC 4 + struct drm_mode_get_output { uint64_t modes_ptr; @@ -960,7 +966,8 @@ struct drm_mode_get_output { int count_props; unsigned int output; /**< Id */ unsigned int crtc; /**< Id of crtc */ - unsigned char name[DRM_OUTPUT_NAME_LEN]; + unsigned int output_type; + unsigned int output_type_id; unsigned int connection; unsigned int mm_width, mm_height; /**< HxW in millimeters */ diff --git a/shared-core/i915_init.c b/shared-core/i915_init.c index 3b43c722..e44cb930 100644 --- a/shared-core/i915_init.c +++ b/shared-core/i915_init.c @@ -188,8 +188,8 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) ret = drm_buffer_object_create(dev, size, drm_bo_type_kernel, DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE | DRM_BO_FLAG_MEM_VRAM | - DRM_BO_FLAG_NO_EVICT | - DRM_BO_HINT_DONT_FENCE, 0, 0x1, 0, + DRM_BO_FLAG_NO_EVICT, + DRM_BO_HINT_DONT_FENCE, 0x1, 0, &dev_priv->ring_buffer); if (ret < 0) { DRM_ERROR("Unable to allocate or pin ring buffer\n"); diff --git a/tests/mode/modetest.c b/tests/mode/modetest.c index f1fe64df..bd8372dc 100644 --- a/tests/mode/modetest.c +++ b/tests/mode/modetest.c @@ -54,7 +54,7 @@ int printOutput(int fd, drmModeResPtr res, drmModeOutputPtr output, uint32_t id) drmModePropertyPtr props; unsigned char *name = NULL; - printf("Output: %s\n", output->name); + printf("Output: %d-%d\n", output->output_type, output->output_type_id); printf("\tid : %i\n", id); printf("\tcrtc id : %i\n", output->crtc); printf("\tconn : %s\n", getConnectionText(output->connection)); -- cgit v1.2.3 From 73bf5e867089b58b2c4baaa833d15a2b1fb268a4 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 9 Jan 2008 16:44:31 +1100 Subject: add internals for opening a control node --- libdrm/xf86drm.c | 21 ++++++++++++--------- libdrm/xf86drm.h | 1 + tests/dristat.c | 2 +- 3 files changed, 14 insertions(+), 10 deletions(-) (limited to 'tests') diff --git a/libdrm/xf86drm.c b/libdrm/xf86drm.c index 4265c320..2d7d85c1 100644 --- a/libdrm/xf86drm.c +++ b/libdrm/xf86drm.c @@ -87,6 +87,9 @@ #define DRM_MSG_VERBOSITY 3 +#define DRM_NODE_CONTROL 0 +#define DRM_NODE_RENDER 1 + static drmServerInfoPtr drm_server_info; void drmSetServerInfo(drmServerInfoPtr info) @@ -264,7 +267,7 @@ static int drmMatchBusID(const char *id1, const char *id2) * special file node with the major and minor numbers specified by \p dev and * parent directory if necessary and was called by root. */ -static int drmOpenDevice(long dev, int minor) +static int drmOpenDevice(long dev, int minor, int type) { stat_t st; char buf[64]; @@ -274,7 +277,7 @@ static int drmOpenDevice(long dev, int minor) uid_t user = DRM_DEV_UID; gid_t group = DRM_DEV_GID, serv_group; - sprintf(buf, DRM_DEV_NAME, DRM_DIR_NAME, minor); + sprintf(buf, type ? DRM_DEV_NAME : DRM_CONTROL_DEV_NAME, DRM_DIR_NAME, minor); drmMsg("drmOpenDevice: node name is %s\n", buf); if (drm_server_info) { @@ -348,15 +351,15 @@ static int drmOpenDevice(long dev, int minor) * Calls drmOpenDevice() if \p create is set, otherwise assembles the device * name from \p minor and opens it. */ -static int drmOpenMinor(int minor, int create) +static int drmOpenMinor(int minor, int create, int type) { int fd; char buf[64]; if (create) - return drmOpenDevice(makedev(DRM_MAJOR, minor), minor); + return drmOpenDevice(makedev(DRM_MAJOR, minor), minor, type); - sprintf(buf, DRM_DEV_NAME, DRM_DIR_NAME, minor); + sprintf(buf, type ? DRM_DEV_NAME : DRM_CONTROL_DEV_NAME, DRM_DIR_NAME, minor); if ((fd = open(buf, O_RDWR, 0)) >= 0) return fd; return -errno; @@ -379,7 +382,7 @@ int drmAvailable(void) int retval = 0; int fd; - if ((fd = drmOpenMinor(0, 1)) < 0) { + if ((fd = drmOpenMinor(0, 1, DRM_NODE_RENDER)) < 0) { #ifdef __linux__ /* Try proc for backward Linux compatibility */ if (!access("/proc/dri/0", R_OK)) @@ -420,7 +423,7 @@ static int drmOpenByBusid(const char *busid) drmMsg("drmOpenByBusid: Searching for BusID %s\n", busid); for (i = 0; i < DRM_MAX_MINOR; i++) { - fd = drmOpenMinor(i, 1); + fd = drmOpenMinor(i, 1, DRM_NODE_RENDER); drmMsg("drmOpenByBusid: drmOpenMinor returns %d\n", fd); if (fd >= 0) { sv.drm_di_major = 1; @@ -482,7 +485,7 @@ static int drmOpenByName(const char *name) * already in use. If it's in use it will have a busid assigned already. */ for (i = 0; i < DRM_MAX_MINOR; i++) { - if ((fd = drmOpenMinor(i, 1)) >= 0) { + if ((fd = drmOpenMinor(i, 1, DRM_NODE_RENDER)) >= 0) { if ((version = drmGetVersion(fd))) { if (!strcmp(version->name, name)) { drmFreeVersion(version); @@ -526,7 +529,7 @@ static int drmOpenByName(const char *name) if (*pt) { /* Found busid */ return drmOpenByBusid(++pt); } else { /* No busid */ - return drmOpenDevice(strtol(devstring, NULL, 0),i); + return drmOpenDevice(strtol(devstring, NULL, 0),i, DRM_NODE_RENDER); } } } diff --git a/libdrm/xf86drm.h b/libdrm/xf86drm.h index 230f54ce..d6e98825 100644 --- a/libdrm/xf86drm.h +++ b/libdrm/xf86drm.h @@ -49,6 +49,7 @@ #define DRM_DIR_NAME "/dev/dri" #define DRM_DEV_NAME "%s/card%d" +#define DRM_CONTROL_DEV_NAME "%s/controlD%d" #define DRM_PROC_NAME "/proc/dri/" /* For backward Linux compatibility */ #define DRM_ERR_NO_DEVICE (-1001) diff --git a/tests/dristat.c b/tests/dristat.c index 89853164..48c3b51b 100644 --- a/tests/dristat.c +++ b/tests/dristat.c @@ -263,7 +263,7 @@ int main(int argc, char **argv) for (i = 0; i < 16; i++) if (!minor || i == minor) { sprintf(buf, DRM_DEV_NAME, DRM_DIR_NAME, i); - fd = drmOpenMinor(i, 1); + fd = drmOpenMinor(i, 1, DRM_NODE_RENDER); if (fd >= 0) { printf("%s\n", buf); if (mask & DRM_BUSID) getbusid(fd); -- cgit v1.2.3 From 0a4df3372aec219298e3787f6f377941bc51bfcb Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 10 Jan 2008 05:03:13 +0100 Subject: Updated test mode and added modedemo --- tests/mode/Makefile | 11 +++-- tests/mode/modetest.c | 10 +++- tests/mode/test | 2 +- tests/modedemo/Makefile | 14 ++++++ tests/modedemo/demo.c | 119 ++++++++++++++++++++++++++++++++++++++++++++++++ tests/modedemo/test | 1 + 6 files changed, 151 insertions(+), 6 deletions(-) create mode 100644 tests/modedemo/Makefile create mode 100644 tests/modedemo/demo.c create mode 100755 tests/modedemo/test (limited to 'tests') diff --git a/tests/mode/Makefile b/tests/mode/Makefile index a3d3b49a..7a9c3c24 100644 --- a/tests/mode/Makefile +++ b/tests/mode/Makefile @@ -1,11 +1,14 @@ -all: modetest +all: app #CFLAGS = -g -ansi -pedantic -DPOSIX_C_SOURCE=199309L \ # -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE \ -modetest: modetest.c - @gcc $(CFLAGS) -o modetest -Wall -I../../libdrm -I../../shared-core -L../../libdrm/.libs -ldrm modetest.c +app: modetest.c + @gcc $(CFLAGS) -o app -Wall -I../../libdrm -I../../shared-core -L../../libdrm/.libs -ldrm modetest.c clean: - @rm -f modetest + @rm -f app + +run: app + @sudo ./test diff --git a/tests/mode/modetest.c b/tests/mode/modetest.c index bd8372dc..c1f291b2 100644 --- a/tests/mode/modetest.c +++ b/tests/mode/modetest.c @@ -278,7 +278,15 @@ int testFrameBufferAdd(int fd, drmModeResPtr res) printf("\tCreating BO\n"); /* TODO */ - ret = 1; + ret = drmBOCreate(fd, 800 * 600 * 4, 0, 0, + DRM_BO_FLAG_READ | + DRM_BO_FLAG_WRITE | + DRM_BO_FLAG_MEM_TT | + DRM_BO_FLAG_MEM_VRAM | + DRM_BO_FLAG_NO_EVICT, + DRM_BO_HINT_DONT_FENCE, &bo); + + printf("\tgot %i\n", ret); if (ret) goto err; diff --git a/tests/mode/test b/tests/mode/test index fa155f4e..f98e3708 100755 --- a/tests/mode/test +++ b/tests/mode/test @@ -1 +1 @@ -LD_PRELOAD=../../libdrm/.libs/libdrm.so ./modetest +LD_PRELOAD=../../libdrm/.libs/libdrm.so ./app diff --git a/tests/modedemo/Makefile b/tests/modedemo/Makefile new file mode 100644 index 00000000..467fb11a --- /dev/null +++ b/tests/modedemo/Makefile @@ -0,0 +1,14 @@ + +all: app + +#CFLAGS = -g -ansi -pedantic -DPOSIX_C_SOURCE=199309L \ +# -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE \ + +app: demo.c + @gcc $(CFLAGS) -o app -Wall -I../../libdrm -I../../shared-core -L../../libdrm/.libs -ldrm demo.c + +clean: + @rm -f app + +run: app + sudo ./test diff --git a/tests/modedemo/demo.c b/tests/modedemo/demo.c new file mode 100644 index 00000000..ea71fd1d --- /dev/null +++ b/tests/modedemo/demo.c @@ -0,0 +1,119 @@ + +#include +#include +#include +#include +#include +#include + +#include "xf86drm.h" +#include "xf86drmMode.h" +static struct drm_mode_modeinfo mode = { + .name = "Test mode", + .clock = 25200, + .hdisplay = 640, + .hsync_start = 656, + .hsync_end = 752, + .htotal = 800, + .hskew = 0, + .vdisplay = 480, + .vsync_start = 490, + .vsync_end = 492, + .vtotal = 525, + .vscan = 0, + .vrefresh = 60000, /* vertical refresh * 1000 */ + .flags = 10, +}; + +drmModeFBPtr createFB(int fd, drmModeResPtr res); +int findConnectedOutputs(int fd, drmModeResPtr res, drmModeOutputPtr *out); +drmModeCrtcPtr findFreeCrtc(int fd, drmModeResPtr res); + +int main(int argc, char **argv) +{ + int fd; + const char *driver = "i915"; /* hardcoded for now */ + drmModeResPtr res; + drmModeFBPtr framebuffer; + int numOutputs; + drmModeOutputPtr out[8]; + drmModeCrtcPtr crtc; + + printf("Starting test\n"); + + fd = drmOpen(driver, NULL); + + if (fd < 0) { + printf("Failed to open the card fb\n"); + return 1; + } + + res = drmModeGetResources(fd); + if (res == 0) { + printf("Failed to get resources from card\n"); + drmClose(fd); + return 1; + } + + framebuffer = createFB(fd, res); + if (framebuffer == NULL) { + printf("Failed to create framebuffer\n"); + return 1; + } + + numOutputs = findConnectedOutputs(fd, res, out); + if (numOutputs < 1) { + printf("Failed to find connected outputs\n"); + return 1; + } + + crtc = findFreeCrtc(fd, res); + if (numOutputs < 1) { + printf("Couldn't find a free crtc\n"); + return 1; + } + + + drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 0, 0, &out[0]->output_id, 1, &mode); + sleep(2); + drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 0, 500, &out[0]->output_id, 1, &mode); + sleep(2); + drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 500, 0, &out[0]->output_id, 1, &mode); + sleep(2); + drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 500, 500, &out[0]->output_id, 1, &mode); + + drmModeFreeResources(res); + printf("Ok\n"); + + return 0; +} + +drmModeFBPtr createFB(int fd, drmModeResPtr res) +{ + /* Haveing problems getting drmBOCreate to work with me. */ + return drmModeGetFB(fd, res->fbs[1]); +} + +int findConnectedOutputs(int fd, drmModeResPtr res, drmModeOutputPtr *out) +{ + int count = 0; + int i; + + drmModeOutputPtr output; + + for (i = 0; i < res->count_outputs; i++) { + output = drmModeGetOutput(fd, res->outputs[i]); + + if (!output || output->connection != DRM_MODE_CONNECTED) + continue; + + out[count++] = output; + } + + return count; +} + +drmModeCrtcPtr findFreeCrtc(int fd, drmModeResPtr res) +{ + return drmModeGetCrtc(fd, res->crtcs[0]); +} diff --git a/tests/modedemo/test b/tests/modedemo/test new file mode 100755 index 00000000..f98e3708 --- /dev/null +++ b/tests/modedemo/test @@ -0,0 +1 @@ +LD_PRELOAD=../../libdrm/.libs/libdrm.so ./app -- cgit v1.2.3 From 0b69c1d1d6a09d55d3367296dfdf23269f2721ea Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 11 Jan 2008 02:55:00 +0100 Subject: Added fixed misc framebuffer problems --- linux-core/drm_crtc.c | 53 ++++++++++++++++++++++++++++----------------------- tests/mode/modetest.c | 2 +- 2 files changed, 30 insertions(+), 25 deletions(-) (limited to 'tests') diff --git a/linux-core/drm_crtc.c b/linux-core/drm_crtc.c index 0b71b134..fdf4c70e 100644 --- a/linux-core/drm_crtc.c +++ b/linux-core/drm_crtc.c @@ -163,12 +163,6 @@ struct drm_framebuffer *drm_framebuffer_create(struct drm_device *dev) { struct drm_framebuffer *fb; - /* Limit to single framebuffer for now */ - if (dev->mode_config.num_fb > 1) { - DRM_ERROR("Attempt to add multiple framebuffers failed\n"); - return NULL; - } - fb = kzalloc(sizeof(struct drm_framebuffer), GFP_KERNEL); if (!fb) return NULL; @@ -771,7 +765,11 @@ void drm_mode_config_init(struct drm_device *dev) idr_init(&dev->mode_config.crtc_idr); drm_mode_create_standard_output_properties(dev); - + + /* Just to be sure */ + dev->mode_config.num_fb = 0; + dev->mode_config.num_output = 0; + dev->mode_config.num_crtc = 0; } EXPORT_SYMBOL(drm_mode_config_init); @@ -1013,6 +1011,7 @@ void drm_mode_config_cleanup(struct drm_device *dev) } list_for_each_entry_safe(fb, fbt, &dev->mode_config.fb_list, head) { + /* there should only be bo of kernel type left */ if (fb->bo->type != drm_bo_type_kernel) drm_framebuffer_destroy(fb); else @@ -1621,7 +1620,6 @@ int drm_mode_addfb(struct drm_device *dev, struct drm_mode_config *config = &dev->mode_config; struct drm_framebuffer *fb; struct drm_buffer_object *bo; - struct drm_crtc *crtc; int ret = 0; if ((config->min_width > r->width) || (r->width > config->max_width)) { @@ -1637,6 +1635,7 @@ int drm_mode_addfb(struct drm_device *dev, /* TODO check limits are okay */ ret = drm_get_buffer_object(dev, &bo, r->handle); if (ret || !bo) { + DRM_ERROR("BO handle not valid\n"); ret = -EINVAL; goto out; } @@ -1646,6 +1645,7 @@ int drm_mode_addfb(struct drm_device *dev, fb = drm_framebuffer_create(dev); if (!fb) { + DRM_ERROR("could not create framebuffer\n"); ret = -EINVAL; goto out; } @@ -1662,12 +1662,6 @@ int drm_mode_addfb(struct drm_device *dev, list_add(&fb->filp_head, &file_priv->fbs); - /* FIXME: bind the fb to the right crtc */ - list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { - crtc->fb = fb; - dev->driver->fb_probe(dev, crtc); - } - out: mutex_unlock(&dev->mode_config.mutex); return ret; @@ -1694,8 +1688,10 @@ int drm_mode_rmfb(struct drm_device *dev, void *data, struct drm_file *file_priv) { struct drm_framebuffer *fb = 0; + struct drm_framebuffer *fbl = 0; uint32_t *id = data; int ret = 0; + int found = 0; mutex_lock(&dev->mode_config.mutex); fb = idr_find(&dev->mode_config.crtc_idr, *id); @@ -1706,15 +1702,24 @@ int drm_mode_rmfb(struct drm_device *dev, goto out; } - /* TODO check if we own the buffer */ + list_for_each_entry(fbl, &file_priv->fbs, filp_head) + if (fb == fbl) + found = 1; + + if (!found) { + DRM_ERROR("tried to remove a fb that we didn't own\n"); + ret = -EINVAL; + goto out; + } + /* TODO release all crtc connected to the framebuffer */ - /* bind the fb to the crtc for now */ /* TODO unhock the destructor from the buffer object */ - if (fb->bo->type != drm_bo_type_kernel) - drm_framebuffer_destroy(fb); - else - dev->driver->fb_remove(dev, drm_crtc_from_fb(dev, fb)); + if (fb->bo->type == drm_bo_type_kernel) + DRM_ERROR("the bo type should not be of kernel type\n"); + + list_del(&fb->filp_head); + drm_framebuffer_destroy(fb); out: mutex_unlock(&dev->mode_config.mutex); @@ -1788,10 +1793,10 @@ void drm_fb_release(struct file *filp) mutex_lock(&dev->mode_config.mutex); list_for_each_entry_safe(fb, tfb, &priv->fbs, filp_head) { list_del(&fb->filp_head); - if (fb->bo->type != drm_bo_type_kernel) - drm_framebuffer_destroy(fb); - else - dev->driver->fb_remove(dev, drm_crtc_from_fb(dev, fb)); + if (fb->bo->type == drm_bo_type_kernel) + DRM_ERROR("the bo type should not be of kernel_type, the kernel will probably explode, why Dave\n"); + + drm_framebuffer_destroy(fb); } mutex_unlock(&dev->mode_config.mutex); } diff --git a/tests/mode/modetest.c b/tests/mode/modetest.c index c1f291b2..eeb4b258 100644 --- a/tests/mode/modetest.c +++ b/tests/mode/modetest.c @@ -291,7 +291,7 @@ int testFrameBufferAdd(int fd, drmModeResPtr res) goto err; printf("\tAdding FB\n"); - ret = drmModeAddFB(fd, 640, 480, 32, 8, 0, &bo, &fb); + ret = drmModeAddFB(fd, 800, 600, 32, 8, 0, &bo, &fb); if (ret) goto err_bo; -- cgit v1.2.3 From 12a47cd136803883231c9763f2007216236ec3b2 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 11 Jan 2008 04:23:32 +0100 Subject: Updated the modedemo test --- tests/modedemo/demo.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 89 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/modedemo/demo.c b/tests/modedemo/demo.c index ea71fd1d..44ebacd3 100644 --- a/tests/modedemo/demo.c +++ b/tests/modedemo/demo.c @@ -8,6 +8,11 @@ #include "xf86drm.h" #include "xf86drmMode.h" + +/* setting this to 2024 gets the pitch wrong check it */ +#define SIZE_X 2048 +#define SIZE_Y 2048 + static struct drm_mode_modeinfo mode = { .name = "Test mode", .clock = 25200, @@ -28,6 +33,7 @@ static struct drm_mode_modeinfo mode = { drmModeFBPtr createFB(int fd, drmModeResPtr res); int findConnectedOutputs(int fd, drmModeResPtr res, drmModeOutputPtr *out); drmModeCrtcPtr findFreeCrtc(int fd, drmModeResPtr res); +void prettyColors(int fd, unsigned int handle); int main(int argc, char **argv) { @@ -73,14 +79,26 @@ int main(int argc, char **argv) return 1; } + prettyColors(fd, framebuffer->handle); + + printf("0 0\n"); + drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 0, 0, &out[1]->output_id, 1, &mode); + sleep(2); - drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 0, 0, &out[0]->output_id, 1, &mode); + printf("0 100\n"); + drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 0, 100, &out[1]->output_id, 1, &mode); sleep(2); - drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 0, 500, &out[0]->output_id, 1, &mode); + + printf("100 0\n"); + drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 100, 0, &out[1]->output_id, 1, &mode); sleep(2); - drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 500, 0, &out[0]->output_id, 1, &mode); + + printf("100 100\n"); + drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 100, 100, &out[1]->output_id, 1, &mode); sleep(2); - drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 500, 500, &out[0]->output_id, 1, &mode); + + /* turn the crtc off just in case */ + drmModeSetCrtc(fd, crtc->crtc_id, 0, 0, 0, 0, 0, 0); drmModeFreeResources(res); printf("Ok\n"); @@ -90,8 +108,40 @@ int main(int argc, char **argv) drmModeFBPtr createFB(int fd, drmModeResPtr res) { - /* Haveing problems getting drmBOCreate to work with me. */ - return drmModeGetFB(fd, res->fbs[1]); + drmModeFBPtr frame; + unsigned int fb = 0; + int ret = 0; + drmBO bo; + + ret = drmBOCreate(fd, SIZE_X * SIZE_Y * 4, 0, 0, + DRM_BO_FLAG_READ | + DRM_BO_FLAG_WRITE | + DRM_BO_FLAG_MEM_TT | + DRM_BO_FLAG_MEM_VRAM | + DRM_BO_FLAG_NO_EVICT, + DRM_BO_HINT_DONT_FENCE, &bo); + + if (ret) + goto err; + + ret = drmModeAddFB(fd, SIZE_X, SIZE_Y, 32, 32, SIZE_X*4, &bo, &fb); + + if (ret) + goto err_bo; + + frame = drmModeGetFB(fd, fb); + + if (!frame) + goto err_bo; + + return frame; + +err_bo: + drmBOUnreference(fd, &bo); +err: + printf("Something went wrong when creating a fb, using one of the predefined ones\n"); + + return drmModeGetFB(fd, res->fbs[0]); } int findConnectedOutputs(int fd, drmModeResPtr res, drmModeOutputPtr *out) @@ -115,5 +165,37 @@ int findConnectedOutputs(int fd, drmModeResPtr res, drmModeOutputPtr *out) drmModeCrtcPtr findFreeCrtc(int fd, drmModeResPtr res) { - return drmModeGetCrtc(fd, res->crtcs[0]); + return drmModeGetCrtc(fd, res->crtcs[1]); +} + +void draw(unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned int v, unsigned int *ptr) +{ + int i, j; + + for (i = x; i < x + w; i++) + for(j = y; j < y + h; j++) + ptr[(i * SIZE_X) + j] = v; + +} + +void prettyColors(int fd, unsigned int handle) +{ + drmBO bo; + unsigned int *ptr; + int i, j; + + drmBOReference(fd, handle, &bo); + drmBOMap(fd, &bo, DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0, (void**)&ptr); + + for (i = 0; i < (SIZE_X*SIZE_Y); i++) + ptr[i] = 0xFFFFFFFF; + + for (i = 0; i < 8; i++) + draw(i*40, i*40, 40, 40, 0, ptr); + + + draw(200, 100, 40, 40, 0xff00ff, ptr); + draw(100, 200, 40, 40, 0xff00ff, ptr); + + drmBOUnmap(fd, &bo); } -- cgit v1.2.3 From f07942f74a08e4c65e3b5e5c46f543686ae30c2b Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 11 Jan 2008 17:13:48 +0100 Subject: Panning now works without modeset --- linux-core/drm_crtc.c | 14 +++++++++++++- linux-core/drm_crtc.h | 4 ++++ linux-core/intel_display.c | 1 + tests/modedemo/demo.c | 21 +++++++++++---------- 4 files changed, 29 insertions(+), 11 deletions(-) (limited to 'tests') diff --git a/linux-core/drm_crtc.c b/linux-core/drm_crtc.c index fdf4c70e..1e69eca3 100644 --- a/linux-core/drm_crtc.c +++ b/linux-core/drm_crtc.c @@ -1048,6 +1048,7 @@ int drm_crtc_set_config(struct drm_crtc *crtc, struct drm_mode_crtc *crtc_info, struct drm_crtc **save_crtcs, *new_crtc; bool save_enabled = crtc->enabled; bool changed = false; + bool flip_or_move = false; struct drm_output *output; int count = 0, ro; @@ -1055,11 +1056,13 @@ int drm_crtc_set_config(struct drm_crtc *crtc, struct drm_mode_crtc *crtc_info, if (!save_crtcs) return -ENOMEM; + /* We should be able to check here if the fb has the same properties + * and then just flip_or_move it */ if (crtc->fb != fb) changed = true; if (crtc_info->x != crtc->x || crtc_info->y != crtc->y) - changed = true; + flip_or_move = true; if (new_mode && !drm_mode_equal(new_mode, &crtc->mode)) changed = true; @@ -1082,6 +1085,10 @@ int drm_crtc_set_config(struct drm_crtc *crtc, struct drm_mode_crtc *crtc_info, } } + /* mode_set_base is not a required function */ + if (flip_or_move && !crtc->funcs->mode_set_base) + changed = true; + if (changed) { crtc->fb = fb; crtc->enabled = (new_mode != NULL); @@ -1102,7 +1109,10 @@ int drm_crtc_set_config(struct drm_crtc *crtc, struct drm_mode_crtc *crtc_info, crtc->desired_mode = new_mode; } drm_disable_unused_functions(dev); + } else if (flip_or_move) { + crtc->funcs->mode_set_base(crtc, crtc_info->x, crtc_info->y); } + kfree(save_crtcs); return 0; } @@ -1564,6 +1574,7 @@ int drm_mode_setcrtc(struct drm_device *dev, if (crtc_req->count_outputs > 0) { u32 out_id; + /* Maybe we should check that count_outputs is a sensible value. */ output_set = kmalloc(crtc_req->count_outputs * sizeof(struct drm_output *), GFP_KERNEL); if (!output_set) { @@ -1589,6 +1600,7 @@ int drm_mode_setcrtc(struct drm_device *dev, } } + /* What happens to output_set, leak? */ ret = drm_crtc_set_config(crtc, crtc_req, mode, output_set, fb); out: diff --git a/linux-core/drm_crtc.h b/linux-core/drm_crtc.h index 54e0c000..65c3704a 100644 --- a/linux-core/drm_crtc.h +++ b/linux-core/drm_crtc.h @@ -325,6 +325,10 @@ struct drm_crtc_funcs { /* Actually set the mode */ void (*mode_set)(struct drm_crtc *crtc, struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode, int x, int y); + + /* Move the crtc on the current fb to the given position *optional* */ + void (*mode_set_base)(struct drm_crtc *crtc, int x, int y); + /* Set gamma on the CRTC */ void (*gamma_set)(struct drm_crtc *crtc, u16 r, u16 g, u16 b, int regno); diff --git a/linux-core/intel_display.c b/linux-core/intel_display.c index a81cfe69..e75d3c07 100644 --- a/linux-core/intel_display.c +++ b/linux-core/intel_display.c @@ -1083,6 +1083,7 @@ static const struct drm_crtc_funcs intel_crtc_funcs = { .unlock = intel_crtc_unlock, .mode_fixup = intel_crtc_mode_fixup, .mode_set = intel_crtc_mode_set, + .mode_set_base = intel_pipe_set_base, .gamma_set = intel_crtc_gamma_set, .prepare = intel_crtc_prepare, .commit = intel_crtc_commit, diff --git a/tests/modedemo/demo.c b/tests/modedemo/demo.c index 44ebacd3..594d60db 100644 --- a/tests/modedemo/demo.c +++ b/tests/modedemo/demo.c @@ -9,9 +9,10 @@ #include "xf86drm.h" #include "xf86drmMode.h" -/* setting this to 2024 gets the pitch wrong check it */ #define SIZE_X 2048 #define SIZE_Y 2048 +/* Pitch needs to be power of two */ +#define PITCH 2048 static struct drm_mode_modeinfo mode = { .name = "Test mode", @@ -82,19 +83,19 @@ int main(int argc, char **argv) prettyColors(fd, framebuffer->handle); printf("0 0\n"); - drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 0, 0, &out[1]->output_id, 1, &mode); + drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 0, 0, &out[0]->output_id, 1, &mode); sleep(2); printf("0 100\n"); - drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 0, 100, &out[1]->output_id, 1, &mode); + drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 0, 100, &out[0]->output_id, 1, &mode); sleep(2); printf("100 0\n"); - drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 100, 0, &out[1]->output_id, 1, &mode); + drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 100, 0, &out[0]->output_id, 1, &mode); sleep(2); printf("100 100\n"); - drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 100, 100, &out[1]->output_id, 1, &mode); + drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 100, 100, &out[0]->output_id, 1, &mode); sleep(2); /* turn the crtc off just in case */ @@ -124,7 +125,7 @@ drmModeFBPtr createFB(int fd, drmModeResPtr res) if (ret) goto err; - ret = drmModeAddFB(fd, SIZE_X, SIZE_Y, 32, 32, SIZE_X*4, &bo, &fb); + ret = drmModeAddFB(fd, SIZE_X, SIZE_Y, 32, 32, PITCH * 4, &bo, &fb); if (ret) goto err_bo; @@ -165,7 +166,7 @@ int findConnectedOutputs(int fd, drmModeResPtr res, drmModeOutputPtr *out) drmModeCrtcPtr findFreeCrtc(int fd, drmModeResPtr res) { - return drmModeGetCrtc(fd, res->crtcs[1]); + return drmModeGetCrtc(fd, res->crtcs[0]); } void draw(unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned int v, unsigned int *ptr) @@ -174,7 +175,7 @@ void draw(unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsign for (i = x; i < x + w; i++) for(j = y; j < y + h; j++) - ptr[(i * SIZE_X) + j] = v; + ptr[(i * PITCH) + j] = v; } @@ -182,7 +183,7 @@ void prettyColors(int fd, unsigned int handle) { drmBO bo; unsigned int *ptr; - int i, j; + int i; drmBOReference(fd, handle, &bo); drmBOMap(fd, &bo, DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0, (void**)&ptr); @@ -191,7 +192,7 @@ void prettyColors(int fd, unsigned int handle) ptr[i] = 0xFFFFFFFF; for (i = 0; i < 8; i++) - draw(i*40, i*40, 40, 40, 0, ptr); + draw(i * 40, i * 40, 40, 40, 0, ptr); draw(200, 100, 40, 40, 0xff00ff, ptr); -- cgit v1.2.3 From a2254c5a9670a3e865f0eb5acd46e905c9b146ce Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Mon, 28 Jan 2008 03:12:29 +0100 Subject: Added cursor support --- libdrm/xf86drmMode.c | 28 +++++++++ libdrm/xf86drmMode.h | 13 ++++ linux-core/drm_crtc.c | 57 +++++++++++++++++ linux-core/drm_crtc.h | 22 +++++++ linux-core/drm_drv.c | 1 + linux-core/intel_display.c | 108 ++++++++++++++++++++++++++++++++ linux-core/intel_drv.h | 1 + linux-core/intel_fb.c | 26 +++++--- shared-core/drm.h | 28 +++++++++ shared-core/i915_drv.h | 1 + shared-core/i915_init.c | 5 ++ tests/modedemo/demo.c | 47 +++++++++++++- tests/modefb/Makefile | 14 +++++ tests/modefb/demo.c | 150 +++++++++++++++++++++++++++++++++++++++++++++ tests/modefb/test | 1 + 15 files changed, 494 insertions(+), 8 deletions(-) create mode 100644 tests/modefb/Makefile create mode 100644 tests/modefb/demo.c create mode 100755 tests/modefb/test (limited to 'tests') diff --git a/libdrm/xf86drmMode.c b/libdrm/xf86drmMode.c index 0edb1d7d..86572872 100644 --- a/libdrm/xf86drmMode.c +++ b/libdrm/xf86drmMode.c @@ -317,6 +317,34 @@ int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId, return ioctl(fd, DRM_IOCTL_MODE_SETCRTC, &crtc); } +/* + * Cursor manipulation + */ + +int drmModeSetCursor(int fd, uint32_t crtcId, drmBO *bo, uint32_t width, uint32_t height) +{ + struct drm_mode_cursor arg; + + arg.flags = DRM_MODE_CURSOR_BO; + arg.crtc = crtcId; + arg.width = width; + arg.height = height; + arg.handle = bo->handle; + + return ioctl(fd, DRM_IOCTL_MODE_CURSOR, &arg); +} + +int drmModeMoveCursor(int fd, uint32_t crtcId, int x, int y) +{ + struct drm_mode_cursor arg; + + arg.flags = DRM_MODE_CURSOR_MOVE; + arg.crtc = crtcId; + arg.x = x; + arg.y = y; + + return ioctl(fd, DRM_IOCTL_MODE_CURSOR, &arg); +} /* * Output manipulation diff --git a/libdrm/xf86drmMode.h b/libdrm/xf86drmMode.h index e2dda8ac..f5b3337c 100644 --- a/libdrm/xf86drmMode.h +++ b/libdrm/xf86drmMode.h @@ -197,6 +197,19 @@ int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId, uint32_t x, uint32_t y, uint32_t *outputs, int count, struct drm_mode_modeinfo *mode); +/* + * Cursor functions + */ + +/** + * Set the cursor on crtc + */ +int drmModeSetCursor(int fd, uint32_t crtcId, drmBO *bo, uint32_t width, uint32_t height); + +/** + * Move the cursor on crtc + */ +int drmModeMoveCursor(int fd, uint32_t crtcId, int x, int y); /* * Output manipulation diff --git a/linux-core/drm_crtc.c b/linux-core/drm_crtc.c index 1e69eca3..18fa02ce 100644 --- a/linux-core/drm_crtc.c +++ b/linux-core/drm_crtc.c @@ -1608,6 +1608,63 @@ out: return ret; } +int drm_mode_cursor_ioctl(struct drm_device *dev, + void *data, struct drm_file *file_priv) +{ + struct drm_mode_cursor *req = data; + struct drm_crtc *crtc; + struct drm_buffer_object *bo = NULL; /* must be set */ + int ret = 0; + + DRM_DEBUG("\n"); + + if (!req->flags) { + DRM_ERROR("no operation set\n"); + return -EINVAL; + } + + mutex_lock(&dev->mode_config.mutex); + crtc = idr_find(&dev->mode_config.crtc_idr, req->crtc); + if (!crtc || (crtc->id != req->crtc)) { + DRM_DEBUG("Unknown CRTC ID %d\n", req->crtc); + ret = -EINVAL; + goto out; + } + + if (req->flags & DRM_MODE_CURSOR_BO) { + /* Turn of the cursor if handle is 0 */ + if (req->handle) + ret = drm_get_buffer_object(dev, &bo, req->handle); + + if (ret) { + DRM_ERROR("invalid buffer id\n"); + ret = -EINVAL; + goto out; + } + + if (crtc->funcs->cursor_set) { + ret = crtc->funcs->cursor_set(crtc, bo, req->width, req->height); + } else { + DRM_ERROR("crtc does not support cursor\n"); + ret = -EFAULT; + goto out; + } + } + + if (req->flags & DRM_MODE_CURSOR_MOVE) { + if (crtc->funcs->cursor_move) { + ret = crtc->funcs->cursor_move(crtc, req->x, req->y); + } else { + DRM_ERROR("crtc does not support cursor\n"); + ret = -EFAULT; + goto out; + } + } +out: + mutex_unlock(&dev->mode_config.mutex); + return ret; +} + /** * drm_mode_addfb - add an FB to the graphics configuration * @inode: inode from the ioctl diff --git a/linux-core/drm_crtc.h b/linux-core/drm_crtc.h index 65c3704a..8f6a8938 100644 --- a/linux-core/drm_crtc.h +++ b/linux-core/drm_crtc.h @@ -329,6 +329,11 @@ struct drm_crtc_funcs { /* Move the crtc on the current fb to the given position *optional* */ void (*mode_set_base)(struct drm_crtc *crtc, int x, int y); + /* cursor controls */ + int (*cursor_set)(struct drm_crtc *crtc, struct drm_buffer_object *bo, + uint32_t width, uint32_t height); + int (*cursor_move)(struct drm_crtc *crtc, int x, int y); + /* Set gamma on the CRTC */ void (*gamma_set)(struct drm_crtc *crtc, u16 r, u16 g, u16 b, int regno); @@ -482,6 +487,21 @@ struct drm_output { uint64_t property_values[DRM_OUTPUT_MAX_PROPERTY]; }; +/** + * struct drm_mode_set + * + * Represents a single crtc the outputs that it drives with what mode + * and from which framebuffer it scans out from. + */ +struct drm_mode_set +{ + struct drm_framebuffer *fb; + struct drm_crtc *crtc; + + struct drm_output **outputs; + size_t num_outputs; +}; + /** * struct drm_mode_config_funcs - configure CRTCs for a given screen layout * @resize: adjust CRTCs as necessary for the proposed layout @@ -603,6 +623,8 @@ extern int drm_mode_getoutput(struct drm_device *dev, void *data, struct drm_file *file_priv); extern int drm_mode_setcrtc(struct drm_device *dev, void *data, struct drm_file *file_priv); +extern int drm_mode_cursor_ioctl(struct drm_device *dev, + void *data, struct drm_file *file_priv); extern int drm_mode_addfb(struct drm_device *dev, void *data, struct drm_file *file_priv); extern int drm_mode_rmfb(struct drm_device *dev, diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c index ab047ca3..b0b44c90 100644 --- a/linux-core/drm_drv.c +++ b/linux-core/drm_drv.c @@ -125,6 +125,7 @@ static struct drm_ioctl_desc drm_ioctls[] = { DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETCRTC, drm_mode_getcrtc, DRM_MASTER|DRM_ROOT_ONLY|DRM_CONTROL_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETOUTPUT, drm_mode_getoutput, DRM_MASTER|DRM_ROOT_ONLY|DRM_CONTROL_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_MODE_SETCRTC, drm_mode_setcrtc, DRM_MASTER|DRM_ROOT_ONLY|DRM_CONTROL_ALLOW), + DRM_IOCTL_DEF(DRM_IOCTL_MODE_CURSOR, drm_mode_cursor_ioctl, DRM_MASTER|DRM_ROOT_ONLY|DRM_CONTROL_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_MODE_ADDFB, drm_mode_addfb, DRM_MASTER|DRM_ROOT_ONLY|DRM_CONTROL_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_MODE_RMFB, drm_mode_rmfb, DRM_MASTER|DRM_ROOT_ONLY|DRM_CONTROL_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETFB, drm_mode_getfb, DRM_MASTER|DRM_ROOT_ONLY|DRM_CONTROL_ALLOW), diff --git a/linux-core/intel_display.c b/linux-core/intel_display.c index 1498a51c..88cf653c 100644 --- a/linux-core/intel_display.c +++ b/linux-core/intel_display.c @@ -402,6 +402,8 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y) } } + + /** * Sets the power management mode of the pipe and plane. * @@ -956,6 +958,108 @@ void intel_crtc_load_lut(struct drm_crtc *crtc) } } +#define CURSOR_A_CONTROL 0x70080 +#define CURSOR_A_BASE 0x70084 +#define CURSOR_A_POSITION 0x70088 + +#define CURSOR_B_CONTROL 0x700C0 +#define CURSOR_B_BASE 0x700C4 +#define CURSOR_B_POSITION 0x700C8 + +#define CURSOR_MODE_DISABLE 0x00 +#define CURSOR_MODE_64_32B_AX 0x07 +#define CURSOR_MODE_64_ARGB_AX ((1 << 5) | CURSOR_MODE_64_32B_AX) +#define MCURSOR_GAMMA_ENABLE (1 << 26) + +#define CURSOR_POS_MASK 0x007FF +#define CURSOR_POS_SIGN 0x8000 +#define CURSOR_X_SHIFT 0 +#define CURSOR_Y_SHIFT 16 + +static int intel_crtc_cursor_set(struct drm_crtc *crtc, + struct drm_buffer_object *bo, + uint32_t width, uint32_t height) +{ + struct drm_device *dev = crtc->dev; + struct drm_i915_private *dev_priv = dev->dev_private; + struct intel_crtc *intel_crtc = crtc->driver_private; + int pipe = intel_crtc->pipe; + uint32_t control = (pipe == 0) ? CURSOR_A_CONTROL : CURSOR_B_CONTROL; + uint32_t temp; + size_t adder; + + DRM_DEBUG("\n"); + + /* if we want to turn of the cursor ignore width and height */ + if (!bo) { + DRM_DEBUG("cursor off\n"); + /* turn of the cursor */ + temp = 0; + temp |= CURSOR_MODE_DISABLE; + + I915_WRITE(control, temp); + return 0; + } + + /* Currently we only support 64x64 cursors */ + if (width != 64 || height != 64) { + DRM_ERROR("we currently only support 64x64 cursors\n"); + return -EINVAL; + } + + if ((bo->mem.flags & DRM_BO_MASK_MEM) != DRM_BO_FLAG_MEM_VRAM) { + DRM_ERROR("buffer needs to be in VRAM\n"); + return -ENOMEM; + } + + if (bo->mem.size < width * height * 4) { + DRM_ERROR("buffer is to small\n"); + return -ENOMEM; + } + + adder = dev_priv->stolen_base + bo->offset; + intel_crtc->cursor_adder = adder; + temp = 0; + /* set the pipe for the cursor */ + temp |= (pipe << 28); + temp |= CURSOR_MODE_64_ARGB_AX | MCURSOR_GAMMA_ENABLE; + + DRM_DEBUG("cusror base %x\n", adder); + + I915_WRITE((pipe == 0) ? CURSOR_A_CONTROL : CURSOR_B_CONTROL, temp); + I915_WRITE((pipe == 0) ? CURSOR_A_BASE : CURSOR_B_BASE, adder); + + return 0; +} + +static int intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y) +{ + struct drm_device *dev = crtc->dev; + struct drm_i915_private *dev_priv = dev->dev_private; + struct intel_crtc *intel_crtc = crtc->driver_private; + int pipe = intel_crtc->pipe; + uint32_t temp = 0; + uint32_t adder; + + if (x < 0) { + temp |= (CURSOR_POS_SIGN << CURSOR_X_SHIFT); + x = -x; + } + if (y < 0) { + temp |= (CURSOR_POS_SIGN << CURSOR_Y_SHIFT); + y = -y; + } + + temp |= ((x & CURSOR_POS_MASK) << CURSOR_X_SHIFT); + temp |= ((y & CURSOR_POS_MASK) << CURSOR_Y_SHIFT); + + adder = intel_crtc->cursor_adder; + I915_WRITE((pipe == 0) ? CURSOR_A_POSITION : CURSOR_B_POSITION, temp); + I915_WRITE((pipe == 0) ? CURSOR_A_BASE : CURSOR_B_BASE, adder); + + return 0; +} + /** Sets the color ramps on behalf of RandR */ static void intel_crtc_gamma_set(struct drm_crtc *crtc, u16 red, u16 green, u16 blue, int regno) @@ -1084,6 +1188,8 @@ static const struct drm_crtc_funcs intel_crtc_funcs = { .mode_fixup = intel_crtc_mode_fixup, .mode_set = intel_crtc_mode_set, .mode_set_base = intel_pipe_set_base, + .cursor_set = intel_crtc_cursor_set, + .cursor_move = intel_crtc_cursor_move, .gamma_set = intel_crtc_gamma_set, .prepare = intel_crtc_prepare, .commit = intel_crtc_commit, @@ -1113,6 +1219,8 @@ void intel_crtc_init(struct drm_device *dev, int pipe) intel_crtc->lut_b[i] = i; } + intel_crtc->cursor_adder = 0; + crtc->driver_private = intel_crtc; } diff --git a/linux-core/intel_drv.h b/linux-core/intel_drv.h index 06335b18..25c3a978 100644 --- a/linux-core/intel_drv.h +++ b/linux-core/intel_drv.h @@ -55,6 +55,7 @@ struct intel_output { struct intel_crtc { int pipe; + uint32_t cursor_adder; u8 lut_r[256], lut_g[256], lut_b[256]; }; diff --git a/linux-core/intel_fb.c b/linux-core/intel_fb.c index b67c0fcc..bb42bc69 100644 --- a/linux-core/intel_fb.c +++ b/linux-core/intel_fb.c @@ -49,7 +49,7 @@ struct intelfb_par { struct drm_crtc *crtc; struct drm_display_mode *fb_mode; }; - +/* static int var_to_refresh(const struct fb_var_screeninfo *var) { @@ -59,7 +59,7 @@ var_to_refresh(const struct fb_var_screeninfo *var) var->vsync_len; return (1000000000 / var->pixclock * 1000 + 500) / xtot / ytot; -} +}*/ static int intelfb_setcolreg(unsigned regno, unsigned red, unsigned green, unsigned blue, unsigned transp, @@ -106,10 +106,10 @@ static int intelfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) { struct intelfb_par *par = info->par; - struct drm_device *dev = par->dev; + /*struct drm_device *dev = par->dev;*/ struct drm_framebuffer *fb = par->crtc->fb; - struct drm_output *output; - int depth, found = 0; + /*struct drm_output *output;*/ + int depth/*, found = 0*/; if (!var->pixclock) return -EINVAL; @@ -254,6 +254,8 @@ static int intelfb_set_par(struct fb_info *info) struct fb_var_screeninfo *var = &info->var; int found = 0; + DRM_DEBUG("\n"); + switch (var->bits_per_pixel) { case 16: fb->depth = (var->green.length == 6) ? 16 : 15; @@ -321,9 +323,19 @@ static int intelfb_set_par(struct fb_info *info) } if (par->crtc->enabled) { - if (!drm_mode_equal(&par->crtc->mode, drm_mode)) - if (!drm_crtc_set_mode(par->crtc, drm_mode, 0, 0)) + if (!drm_mode_equal(&par->crtc->mode, drm_mode)) { + if (!drm_crtc_set_mode(par->crtc, drm_mode, var->xoffset, var->yoffset)) return -EINVAL; + } else if (par->crtc->x != var->xoffset || par->crtc->x != var->xoffset) { + if (!par->crtc->funcs->mode_set_base) { + if (!drm_crtc_set_mode(par->crtc, drm_mode, var->xoffset, var->yoffset)) + return -EINVAL; + } else { + par->crtc->funcs->mode_set_base(par->crtc, var->xoffset, var->yoffset); + par->crtc->x = var->xoffset; + par->crtc->y = var->yoffset; + } + } } return 0; } diff --git a/shared-core/drm.h b/shared-core/drm.h index 7aea3033..209a8db0 100644 --- a/shared-core/drm.h +++ b/shared-core/drm.h @@ -1084,6 +1084,33 @@ struct drm_mode_mode_cmd { struct drm_mode_modeinfo mode; }; +#define DRM_MODE_CURSOR_BO 0x01 +#define DRM_MODE_CURSOR_MOVE 0x02 + +/* + * depending on the value in flags diffrent members are used. + * + * CURSOR_BO uses + * crtc + * width + * height + * handle - if 0 turns the cursor of + * + * CURSOR_MOVE uses + * crtc + * x + * y + */ +struct drm_mode_cursor { + unsigned int flags; + unsigned int crtc; + int x; + int y; + uint32_t width; + uint32_t height; + unsigned int handle; +}; + /** * \name Ioctls Definitions */ @@ -1190,6 +1217,7 @@ struct drm_mode_mode_cmd { #define DRM_IOCTL_MODE_DETACHMODE DRM_IOWR(0xAA, struct drm_mode_mode_cmd) #define DRM_IOCTL_MODE_GETPROPERTY DRM_IOWR(0xAB, struct drm_mode_get_property) +#define DRM_IOCTL_MODE_CURSOR DRM_IOWR(0xAC, struct drm_mode_cursor) /*@}*/ diff --git a/shared-core/i915_drv.h b/shared-core/i915_drv.h index 49e23ac3..ea89bc4c 100644 --- a/shared-core/i915_drv.h +++ b/shared-core/i915_drv.h @@ -147,6 +147,7 @@ struct drm_i915_private { void *agp_iomap; unsigned int max_validate_buffers; struct mutex cmdbuf_mutex; + size_t stolen_base; #endif DRM_SPINTYPE swaps_lock; diff --git a/shared-core/i915_init.c b/shared-core/i915_init.c index 3b271b17..792c40bb 100644 --- a/shared-core/i915_init.c +++ b/shared-core/i915_init.c @@ -131,6 +131,11 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) dev->types[8] = _DRM_STAT_SECONDARY; dev->types[9] = _DRM_STAT_DMA; + if (IS_I9XX(dev)) { + pci_read_config_dword(dev->pdev, 0x5C, &dev_priv->stolen_base); + DRM_DEBUG("stolen base %p\n", (void*)dev_priv->stolen_base); + } + if (IS_I9XX(dev)) { dev_priv->mmiobase = drm_get_resource_start(dev, 0); dev_priv->mmiolen = drm_get_resource_len(dev, 0); diff --git a/tests/modedemo/demo.c b/tests/modedemo/demo.c index 594d60db..1efeb272 100644 --- a/tests/modedemo/demo.c +++ b/tests/modedemo/demo.c @@ -34,7 +34,9 @@ static struct drm_mode_modeinfo mode = { drmModeFBPtr createFB(int fd, drmModeResPtr res); int findConnectedOutputs(int fd, drmModeResPtr res, drmModeOutputPtr *out); drmModeCrtcPtr findFreeCrtc(int fd, drmModeResPtr res); +void testCursor(int fd, uint32_t crtc); void prettyColors(int fd, unsigned int handle); +void prettyCursor(int fd, unsigned int handle); int main(int argc, char **argv) { @@ -98,6 +100,11 @@ int main(int argc, char **argv) drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 100, 100, &out[0]->output_id, 1, &mode); sleep(2); + printf("0 0\n"); + drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 1, 1, &out[0]->output_id, 1, &mode); + + testCursor(fd, crtc->crtc_id); + /* turn the crtc off just in case */ drmModeSetCrtc(fd, crtc->crtc_id, 0, 0, 0, 0, 0, 0); @@ -166,7 +173,7 @@ int findConnectedOutputs(int fd, drmModeResPtr res, drmModeOutputPtr *out) drmModeCrtcPtr findFreeCrtc(int fd, drmModeResPtr res) { - return drmModeGetCrtc(fd, res->crtcs[0]); + return drmModeGetCrtc(fd, res->crtcs[1]); } void draw(unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned int v, unsigned int *ptr) @@ -200,3 +207,41 @@ void prettyColors(int fd, unsigned int handle) drmBOUnmap(fd, &bo); } + +void testCursor(int fd, uint32_t crtc) +{ + drmBO bo; + int ret; + ret = drmBOCreate(fd, 64 * 64 * 4, 0, 0, + DRM_BO_FLAG_READ | + DRM_BO_FLAG_WRITE | + DRM_BO_FLAG_MEM_VRAM | + DRM_BO_FLAG_NO_EVICT, + DRM_BO_HINT_DONT_FENCE, &bo); + + prettyCursor(fd, bo.handle); + + printf("set cursor\n"); + drmModeSetCursor(fd, crtc, &bo, 64, 64); + printf("move cursor 0, 0\n"); + drmModeMoveCursor(fd, crtc, 0, 0); + sleep(2); + printf("move cursor 40, 40\n"); + drmModeMoveCursor(fd, crtc, 40, 40); + sleep(2); +} + +void prettyCursor(int fd, unsigned int handle) +{ + drmBO bo; + unsigned int *ptr; + int i; + + drmBOReference(fd, handle, &bo); + drmBOMap(fd, &bo, DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0, (void**)&ptr); + + for (i = 0; i < (64 * 64); i++) + ptr[i] = 0xFFFF00FF; + + drmBOUnmap(fd, &bo); +} diff --git a/tests/modefb/Makefile b/tests/modefb/Makefile new file mode 100644 index 00000000..84c6c86a --- /dev/null +++ b/tests/modefb/Makefile @@ -0,0 +1,14 @@ + +all: app + +#CFLAGS = -g -ansi -pedantic -DPOSIX_C_SOURCE=199309L \ +# -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE \ + +app: demo.c + @gcc $(CFLAGS) -o app -Wall demo.c + +clean: + @rm -f app + +run: app + sudo ./test diff --git a/tests/modefb/demo.c b/tests/modefb/demo.c new file mode 100644 index 00000000..0dbf01c7 --- /dev/null +++ b/tests/modefb/demo.c @@ -0,0 +1,150 @@ +#include +#include +#include +#include +#include +#include "linux/fb.h" +#include "sys/ioctl.h" + + +void setMode(struct fb_var_screeninfo *var); +void pan(int fd, struct fb_var_screeninfo *var, int x, int y); +void cursor(int fd); + +int main(int argc, char **argv) +{ + struct fb_var_screeninfo var; + struct fb_fix_screeninfo fix; + const char* name = "/dev/fb0"; + + int fd = open(name, O_RDONLY); + + if (fd == -1) { + printf("open %s : %s\n", name, strerror(errno)); + return 1; + } + + memset(&var, 0, sizeof(struct fb_var_screeninfo)); + memset(&fix, 0, sizeof(struct fb_fix_screeninfo)); + + if (ioctl(fd, FBIOGET_VSCREENINFO, &var)) + printf("var %s\n", strerror(errno)); + if (ioctl(fd, FBIOGET_FSCREENINFO, &fix)) + printf("fix %s\n", strerror(errno)); + + setMode(&var); + printf("pan: 0, 0\n"); + pan(fd, &var, 0, 0); + sleep(2); + printf("pan: 100, 0\n"); + pan(fd, &var, 100, 0); + sleep(2); + printf("pan: 0, 100\n"); + pan(fd, &var, 0, 100); + sleep(2); + printf("pan: 100, 100\n"); + pan(fd, &var, 100, 100); + sleep(2); + printf("pan: 0, 0\n"); + pan(fd, &var, 0, 0); + sleep(2); + + printf("cursor\n"); + cursor(fd); + return 0; +} + +void pan(int fd, struct fb_var_screeninfo *var, int x, int y) +{ + var->xoffset = x; + var->yoffset = y; + + var->activate = FB_ACTIVATE_NOW; + + if (ioctl(fd, FBIOPUT_VSCREENINFO, var)) + printf("pan error: %s\n", strerror(errno)); +} + +/* + * Currently isn't supported in the driver + */ +void cursor(int fd) +{ + struct fb_cursor cur; + void *data = malloc(64 * 64 * 4); + memset(&cur, 0, sizeof(cur)); + + cur.set = FB_CUR_SETIMAGE | FB_CUR_SETPOS | FB_CUR_SETSIZE; + cur.enable = 1; + cur.image.dx = 1; + cur.image.dy = 1; + cur.image.width = 2; + cur.image.height = 2; + cur.image.depth = 32; + cur.image.data = data; + + if (ioctl(fd, FBIO_CURSOR, &cur)) + printf("cursor error: %s\n", strerror(errno)); + + sleep(2); + + memset(&cur, 0, sizeof(cur)); + cur.set = FB_CUR_SETPOS; + cur.enable = 0; + cur.image.dx = 100; + cur.image.dy = 100; + + if (ioctl(fd, FBIO_CURSOR, &cur)) + printf("cursor error: %s\n", strerror(errno)); + + free(data); +} + +struct drm_mode +{ + int clock; + int hdisplay; + int hsync_start; + int hsync_end; + int htotal; + int hskew; + int vdisplay; + int vsync_start; + int vsync_end; + int vtotal; + int vscan; + int vrefresh; + int flags; +}; + +struct drm_mode mode = +{ + .clock = 25200, + .hdisplay = 640, + .hsync_start = 656, + .hsync_end = 752, + .htotal = 800, + .hskew = 0, + .vdisplay = 480, + .vsync_start = 490, + .vsync_end = 492, + .vtotal = 525, + .vscan = 0, + .vrefresh = 60000, /* vertical refresh * 1000 */ + .flags = 10, +}; + +void setMode(struct fb_var_screeninfo *var) { + var->activate = FB_ACTIVATE_NOW; + var->xres = mode.hdisplay; + var->right_margin = mode.hsync_start - mode.hdisplay; + var->hsync_len = mode.hsync_end - mode.hsync_start; + var->left_margin = mode.htotal - mode.hsync_end; + var->yres = mode.vdisplay; + var->lower_margin = mode.vsync_start - mode.vdisplay; + var->vsync_len = mode.vsync_end - mode.vsync_start; + var->upper_margin = mode.vtotal - mode.vsync_end; + var->pixclock = 10000000 / mode.htotal * 1000 / mode.vtotal * 100; + /* avoid overflow */ + var->pixclock = var->pixclock * 1000 / mode.vrefresh; +} diff --git a/tests/modefb/test b/tests/modefb/test new file mode 100755 index 00000000..f98e3708 --- /dev/null +++ b/tests/modefb/test @@ -0,0 +1 @@ +LD_PRELOAD=../../libdrm/.libs/libdrm.so ./app -- cgit v1.2.3 From 841ef9eb8da8058d6495e9f8e1b14af2709dfaa1 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Wed, 30 Jan 2008 15:47:26 +0100 Subject: ModeFB demo now display cursor --- libdrm/xf86drmMode.c | 5 +++- tests/modedemo/demo.c | 1 + tests/modefb/Makefile | 2 +- tests/modefb/demo.c | 82 +++++++++++++++++++++++++++++++++------------------ 4 files changed, 60 insertions(+), 30 deletions(-) (limited to 'tests') diff --git a/libdrm/xf86drmMode.c b/libdrm/xf86drmMode.c index 86572872..681ad417 100644 --- a/libdrm/xf86drmMode.c +++ b/libdrm/xf86drmMode.c @@ -329,7 +329,10 @@ int drmModeSetCursor(int fd, uint32_t crtcId, drmBO *bo, uint32_t width, uint32_ arg.crtc = crtcId; arg.width = width; arg.height = height; - arg.handle = bo->handle; + if (bo) + arg.handle = bo->handle; + else + arg.handle = 0; return ioctl(fd, DRM_IOCTL_MODE_CURSOR, &arg); } diff --git a/tests/modedemo/demo.c b/tests/modedemo/demo.c index 1efeb272..b399aec1 100644 --- a/tests/modedemo/demo.c +++ b/tests/modedemo/demo.c @@ -244,4 +244,5 @@ void prettyCursor(int fd, unsigned int handle) ptr[i] = 0xFFFF00FF; drmBOUnmap(fd, &bo); + drmBOUnreference(fd, &bo); } diff --git a/tests/modefb/Makefile b/tests/modefb/Makefile index 84c6c86a..467fb11a 100644 --- a/tests/modefb/Makefile +++ b/tests/modefb/Makefile @@ -5,7 +5,7 @@ all: app # -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE \ app: demo.c - @gcc $(CFLAGS) -o app -Wall demo.c + @gcc $(CFLAGS) -o app -Wall -I../../libdrm -I../../shared-core -L../../libdrm/.libs -ldrm demo.c clean: @rm -f app diff --git a/tests/modefb/demo.c b/tests/modefb/demo.c index 0dbf01c7..9af369c2 100644 --- a/tests/modefb/demo.c +++ b/tests/modefb/demo.c @@ -5,25 +5,37 @@ #include #include "linux/fb.h" #include "sys/ioctl.h" +#include "xf86drm.h" +#include "xf86drmMode.h" - +void pretty(int fd); void setMode(struct fb_var_screeninfo *var); void pan(int fd, struct fb_var_screeninfo *var, int x, int y); -void cursor(int fd); +void cursor(int fd, int drmfd); +void prettyCursor(int fd, unsigned int handle, unsigned int color); + +extern void sleep(int); int main(int argc, char **argv) { struct fb_var_screeninfo var; struct fb_fix_screeninfo fix; + const char* driver = "i915"; const char* name = "/dev/fb0"; int fd = open(name, O_RDONLY); + int drmfd = drmOpen(driver, NULL); if (fd == -1) { printf("open %s : %s\n", name, strerror(errno)); return 1; } + if (drmfd < 0) { + printf("drmOpen failed\n"); + return 1; + } + memset(&var, 0, sizeof(struct fb_var_screeninfo)); memset(&fix, 0, sizeof(struct fb_fix_screeninfo)); @@ -50,7 +62,7 @@ int main(int argc, char **argv) sleep(2); printf("cursor\n"); - cursor(fd); + cursor(fd, drmfd); return 0; } @@ -66,38 +78,52 @@ void pan(int fd, struct fb_var_screeninfo *var, int x, int y) } /* - * Currently isn't supported in the driver + * Cursor support removed from the fb kernel interface + * using drm instead. */ -void cursor(int fd) +void cursor(int fd, int drmfd) { - struct fb_cursor cur; - void *data = malloc(64 * 64 * 4); - memset(&cur, 0, sizeof(cur)); - - cur.set = FB_CUR_SETIMAGE | FB_CUR_SETPOS | FB_CUR_SETSIZE; - cur.enable = 1; - cur.image.dx = 1; - cur.image.dy = 1; - cur.image.width = 2; - cur.image.height = 2; - cur.image.depth = 32; - cur.image.data = data; - - if (ioctl(fd, FBIO_CURSOR, &cur)) - printf("cursor error: %s\n", strerror(errno)); + drmModeResPtr res = drmModeGetResources(drmfd); + uint32_t crtc = res->crtcs[1]; /* select crtc here */ + drmBO bo; + int ret; + ret = drmBOCreate(drmfd, 64 * 64 * 4, 0, 0, + DRM_BO_FLAG_READ | + DRM_BO_FLAG_WRITE | + DRM_BO_FLAG_MEM_VRAM | + DRM_BO_FLAG_NO_EVICT, + DRM_BO_HINT_DONT_FENCE, &bo); + + if (ret) { + printf("failed to create buffer: %s\n", strerror(ret)); + return; + } + prettyCursor(drmfd, bo.handle, 0xFFFF00FF); + drmModeSetCursor(drmfd, crtc, &bo, 64, 64); + drmModeMoveCursor(drmfd, crtc, 0, 0); + sleep(2); + drmModeMoveCursor(drmfd, crtc, 40, 40); + prettyCursor(drmfd, bo.handle, 0xFFFF0000); sleep(2); + drmModeSetCursor(drmfd, crtc, 0, 0, 0); + drmBOUnreference(drmfd, &bo); +} + +void prettyCursor(int drmfd, unsigned int handle, unsigned int color) +{ + drmBO bo; + unsigned int *ptr; + int i; - memset(&cur, 0, sizeof(cur)); - cur.set = FB_CUR_SETPOS; - cur.enable = 0; - cur.image.dx = 100; - cur.image.dy = 100; + drmBOReference(drmfd, handle, &bo); + drmBOMap(drmfd, &bo, DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0, (void**)&ptr); - if (ioctl(fd, FBIO_CURSOR, &cur)) - printf("cursor error: %s\n", strerror(errno)); + for (i = 0; i < (64 * 64); i++) + ptr[i] = color; - free(data); + drmBOUnmap(drmfd, &bo); + drmBOUnreference(drmfd, &bo); } struct drm_mode -- cgit v1.2.3 From d8bbd02a6086ebe302859cec22c503d32ed77dc6 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Mon, 4 Feb 2008 20:51:59 +0100 Subject: Modedemo now uses two crtc and output pairs --- tests/modedemo/demo.c | 345 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 261 insertions(+), 84 deletions(-) (limited to 'tests') diff --git a/tests/modedemo/demo.c b/tests/modedemo/demo.c index b399aec1..de31e7a6 100644 --- a/tests/modedemo/demo.c +++ b/tests/modedemo/demo.c @@ -14,6 +14,60 @@ /* Pitch needs to be power of two */ #define PITCH 2048 +/* old functions to be replaced */ +drmModeFBPtr createFB(int fd, drmModeResPtr res); +void testCursor(int fd, uint32_t crtc); +void prettyColors(int fd, unsigned int handle); +void prettyCursor(int fd, unsigned int handle); + +/* structs for the demo_driver */ + +struct demo_driver; + +struct demo_screen +{ + /* drm stuff */ + drmBO buffer; + drmModeFBPtr fb; + drmModeCrtcPtr crtc; + drmModeOutputPtr output; + + struct drm_mode_modeinfo *mode; + + /* virtual buffer */ + uint32_t virt_x; + uint32_t virt_y; + uint32_t pitch; + + /* parent */ + struct demo_driver *driver; +}; + +#define DEMO_MAX_SCREENS 4 +#define MAX_FIND_OUTPUTS 8 + +struct demo_driver +{ + /* drm stuff */ + int fd; + drmModeResPtr res; + + /* screens */ + size_t numScreens; + struct demo_screen screens[DEMO_MAX_SCREENS]; +}; + +struct demo_driver* demoCreateDriver(const char *name); +void demoUpdateRes(struct demo_driver *driver); +int demoCreateScreens(struct demo_driver *driver); +void demoTakeDownScreen(struct demo_screen *screen); +int demoFindConnectedOutputs(struct demo_driver *driver, drmModeOutputPtr *out, size_t max_out); +drmModeCrtcPtr demoFindFreeCrtc(struct demo_driver *driver, drmModeOutputPtr output); +void demoPanScreen(struct demo_screen *screen, uint16_t x, uint16_t y); +/* yet to be implemented */ +void demoMouseActivate(struct demo_screen *screen); +void demoMouseMove(struct demo_screen *screen, uint16_t x, uint16_t y); + static struct drm_mode_modeinfo mode = { .name = "Test mode", .clock = 25200, @@ -31,87 +85,232 @@ static struct drm_mode_modeinfo mode = { .flags = 10, }; -drmModeFBPtr createFB(int fd, drmModeResPtr res); -int findConnectedOutputs(int fd, drmModeResPtr res, drmModeOutputPtr *out); -drmModeCrtcPtr findFreeCrtc(int fd, drmModeResPtr res); -void testCursor(int fd, uint32_t crtc); -void prettyColors(int fd, unsigned int handle); -void prettyCursor(int fd, unsigned int handle); - int main(int argc, char **argv) { - int fd; - const char *driver = "i915"; /* hardcoded for now */ - drmModeResPtr res; - drmModeFBPtr framebuffer; - int numOutputs; - drmModeOutputPtr out[8]; - drmModeCrtcPtr crtc; + const char *driver_name = "i915"; /* hardcoded for now */ + struct demo_driver *driver; + int num; + int i; - printf("Starting test\n"); + printf("starting demo\n"); - fd = drmOpen(driver, NULL); + driver = demoCreateDriver(driver_name); - if (fd < 0) { - printf("Failed to open the card fb\n"); + if (!driver) { + printf("failed to create driver\n"); return 1; } - res = drmModeGetResources(fd); - if (res == 0) { - printf("Failed to get resources from card\n"); - drmClose(fd); + num = demoCreateScreens(driver); + if (num < 1) { + printf("no screens attached or an error occured\n"); return 1; } + printf("created %i screens\n", num); - framebuffer = createFB(fd, res); - if (framebuffer == NULL) { - printf("Failed to create framebuffer\n"); - return 1; + for (i = 0; i < num; i++) { + prettyColors(driver->fd, driver->screens[i].fb->handle); } + sleep(1); - numOutputs = findConnectedOutputs(fd, res, out); - if (numOutputs < 1) { - printf("Failed to find connected outputs\n"); - return 1; + for (i = 0; i < num; i++) { + printf("%i: 100 0\n", i); + demoPanScreen(&driver->screens[i], 100, 0); + sleep(1); + + printf("%i: 0 100\n", i); + demoPanScreen(&driver->screens[i], 0, 100); + sleep(1); + + printf("%i: 100 100\n", i); + demoPanScreen(&driver->screens[i], 100, 100); + sleep(1); + + printf("%i: 0 0\n", i); + demoPanScreen(&driver->screens[i], 0, 1); + sleep(1); + testCursor(driver->fd, driver->screens[i].crtc->crtc_id); } - crtc = findFreeCrtc(fd, res); - if (numOutputs < 1) { - printf("Couldn't find a free crtc\n"); - return 1; + sleep(2); + printf("ok\n"); + return 0; +} + +int demoCreateScreens(struct demo_driver *driver) +{ + drmModeOutputPtr out[MAX_FIND_OUTPUTS]; + int num; + int num_screens = 0; + struct demo_screen *screen; + int ret = 0; + int i; + + num = demoFindConnectedOutputs(driver, out, MAX_FIND_OUTPUTS); + if (num < 0) + return 0; + + printf("found %i connected outputs\n", num); + + for (i = 0; i < num; i++) { + screen = &driver->screens[i]; + + screen->crtc = demoFindFreeCrtc(driver, out[i]); + if (!screen->crtc) { + printf("found no free crtc for output\n"); + drmModeFreeOutput(out[i]); + continue; + } + + screen->fb = createFB(driver->fd, driver->res); + if (!screen->fb) { + drmModeFreeOutput(out[i]); + drmModeFreeCrtc(screen->crtc); + screen->crtc = 0; + printf("could not create framebuffer\n"); + continue; + } + + screen->virt_x = SIZE_X; + screen->virt_y = SIZE_Y; + screen->pitch = PITCH; + + screen->output = out[i]; + screen->mode = &mode; + screen->driver = driver; + + ret = drmModeSetCrtc( + driver->fd, + screen->crtc->crtc_id, + screen->fb->buffer_id, + 0, 0, + &screen->output->output_id, 1, + screen->mode); + + if (ret) { + printf("failed to set mode\n"); + demoTakeDownScreen(screen); + } else { + num_screens++; + } + + demoUpdateRes(driver); } - prettyColors(fd, framebuffer->handle); + return num_screens; +} - printf("0 0\n"); - drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 0, 0, &out[0]->output_id, 1, &mode); - sleep(2); +void demoTakeDownScreen(struct demo_screen *screen) +{ + /* TODO Unrefence the BO */ + /* TODO Destroy FB */ + /* TODO take down the mode */ - printf("0 100\n"); - drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 0, 100, &out[0]->output_id, 1, &mode); - sleep(2); + drmModeFreeOutput(screen->output); + drmModeFreeCrtc(screen->crtc); +} - printf("100 0\n"); - drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 100, 0, &out[0]->output_id, 1, &mode); - sleep(2); +drmModeCrtcPtr demoFindFreeCrtc(struct demo_driver *driver, drmModeOutputPtr output) +{ + drmModeCrtcPtr crtc; + int i, j, used = 0; + drmModeResPtr res = driver->res; - printf("100 100\n"); - drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 100, 100, &out[0]->output_id, 1, &mode); - sleep(2); - printf("0 0\n"); - drmModeSetCrtc(fd, crtc->crtc_id, framebuffer->buffer_id, 1, 1, &out[0]->output_id, 1, &mode); + for (i = 0; i < res->count_crtcs; i++) { + used = 0; + for (j = 0; j < DEMO_MAX_SCREENS; j++) { + crtc = driver->screens[j].crtc; - testCursor(fd, crtc->crtc_id); + if (crtc && crtc->crtc_id == res->crtcs[i]) + used = 1; + } - /* turn the crtc off just in case */ - drmModeSetCrtc(fd, crtc->crtc_id, 0, 0, 0, 0, 0, 0); + if (!used) { + crtc = drmModeGetCrtc(driver->fd, res->crtcs[i]); + break; + } else { + crtc = 0; + } + } - drmModeFreeResources(res); - printf("Ok\n"); + return crtc; +} - return 0; +struct demo_driver* demoCreateDriver(const char *name) +{ + struct demo_driver* driver = malloc(sizeof(struct demo_driver)); + + memset(driver, 0, sizeof(struct demo_driver)); + + driver->fd = drmOpen(name, NULL); + + if (driver->fd < 0) { + printf("Failed to open the card fb\n"); + goto err_driver; + } + + demoUpdateRes(driver); + if (!driver->res) { + printf("could not retrive resources\n"); + goto err_res; + } + + return driver; + +err_res: + drmClose(driver->fd); +err_driver: + free(driver); + return NULL; +} + +void demoUpdateRes(struct demo_driver *driver) +{ + if (driver->res) + drmModeFreeResources(driver->res); + + driver->res = drmModeGetResources(driver->fd); + + if (!driver->res) + printf("failed to get resources from kernel\n"); +} + +int demoFindConnectedOutputs(struct demo_driver *driver, drmModeOutputPtr *out, size_t max_out) +{ + int count = 0; + int i; + int fd = driver->fd; + drmModeResPtr res = driver->res; + + drmModeOutputPtr output; + + for (i = 0; i < res->count_outputs && count < max_out; i++) { + output = drmModeGetOutput(fd, res->outputs[i]); + + if (!output) + continue; + + if (output->connection != DRM_MODE_CONNECTED) { + drmModeFreeOutput(output); + continue; + } + + out[count++] = output; + } + + return count; +} + +void demoPanScreen(struct demo_screen *screen, uint16_t x, uint16_t y) +{ + drmModeSetCrtc( + screen->driver->fd, + screen->crtc->crtc_id, + screen->fb->buffer_id, + x, y, + &screen->output->output_id, 1, + screen->mode); } drmModeFBPtr createFB(int fd, drmModeResPtr res) @@ -147,33 +346,7 @@ drmModeFBPtr createFB(int fd, drmModeResPtr res) err_bo: drmBOUnreference(fd, &bo); err: - printf("Something went wrong when creating a fb, using one of the predefined ones\n"); - - return drmModeGetFB(fd, res->fbs[0]); -} - -int findConnectedOutputs(int fd, drmModeResPtr res, drmModeOutputPtr *out) -{ - int count = 0; - int i; - - drmModeOutputPtr output; - - for (i = 0; i < res->count_outputs; i++) { - output = drmModeGetOutput(fd, res->outputs[i]); - - if (!output || output->connection != DRM_MODE_CONNECTED) - continue; - - out[count++] = output; - } - - return count; -} - -drmModeCrtcPtr findFreeCrtc(int fd, drmModeResPtr res) -{ - return drmModeGetCrtc(fd, res->crtcs[1]); + return 0; } void draw(unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned int v, unsigned int *ptr) @@ -225,10 +398,14 @@ void testCursor(int fd, uint32_t crtc) drmModeSetCursor(fd, crtc, &bo, 64, 64); printf("move cursor 0, 0\n"); drmModeMoveCursor(fd, crtc, 0, 0); - sleep(2); + sleep(1); printf("move cursor 40, 40\n"); drmModeMoveCursor(fd, crtc, 40, 40); - sleep(2); + sleep(1); + printf("move cursor 100, 100\n"); + drmModeMoveCursor(fd, crtc, 100, 100); + sleep(1); + drmModeSetCursor(fd, crtc, NULL, 0, 0); } void prettyCursor(int fd, unsigned int handle) -- cgit v1.2.3 From 936e32b08c05c9658cc51cd8fe118e0342733a79 Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Tue, 5 Feb 2008 15:18:05 +0000 Subject: make modefb/modedemo match each others test output. --- tests/mode/modetest.c | 5 ++-- tests/modedemo/demo.c | 23 +++++++------- tests/modefb/demo.c | 83 +++++++++++++++++++++++++++++++++++++++++---------- 3 files changed, 82 insertions(+), 29 deletions(-) (limited to 'tests') diff --git a/tests/mode/modetest.c b/tests/mode/modetest.c index eeb4b258..ab0cdc9c 100644 --- a/tests/mode/modetest.c +++ b/tests/mode/modetest.c @@ -347,15 +347,14 @@ int testDPMS(int fd, drmModeResPtr res) int main(int argc, char **argv) { int fd; - const char *driver = "i915"; /* hardcoded for now */ drmModeResPtr res; printf("Starting test\n"); - fd = drmOpen(driver, NULL); + fd = drmOpenControl(0); if (fd < 0) { - printf("Failed to open the card fb\n"); + printf("Failed to open the card fb (%d)\n",fd); return 1; } diff --git a/tests/modedemo/demo.c b/tests/modedemo/demo.c index de31e7a6..48a4f1f1 100644 --- a/tests/modedemo/demo.c +++ b/tests/modedemo/demo.c @@ -18,7 +18,7 @@ drmModeFBPtr createFB(int fd, drmModeResPtr res); void testCursor(int fd, uint32_t crtc); void prettyColors(int fd, unsigned int handle); -void prettyCursor(int fd, unsigned int handle); +void prettyCursor(int fd, unsigned int handle, unsigned int color); /* structs for the demo_driver */ @@ -57,7 +57,7 @@ struct demo_driver struct demo_screen screens[DEMO_MAX_SCREENS]; }; -struct demo_driver* demoCreateDriver(const char *name); +struct demo_driver* demoCreateDriver(void); void demoUpdateRes(struct demo_driver *driver); int demoCreateScreens(struct demo_driver *driver); void demoTakeDownScreen(struct demo_screen *screen); @@ -87,14 +87,13 @@ static struct drm_mode_modeinfo mode = { int main(int argc, char **argv) { - const char *driver_name = "i915"; /* hardcoded for now */ struct demo_driver *driver; int num; int i; printf("starting demo\n"); - driver = demoCreateDriver(driver_name); + driver = demoCreateDriver(); if (!driver) { printf("failed to create driver\n"); @@ -237,13 +236,13 @@ drmModeCrtcPtr demoFindFreeCrtc(struct demo_driver *driver, drmModeOutputPtr out return crtc; } -struct demo_driver* demoCreateDriver(const char *name) +struct demo_driver* demoCreateDriver(void) { struct demo_driver* driver = malloc(sizeof(struct demo_driver)); memset(driver, 0, sizeof(struct demo_driver)); - driver->fd = drmOpen(name, NULL); + driver->fd = drmOpenControl(0); if (driver->fd < 0) { printf("Failed to open the card fb\n"); @@ -328,8 +327,10 @@ drmModeFBPtr createFB(int fd, drmModeResPtr res) DRM_BO_FLAG_NO_EVICT, DRM_BO_HINT_DONT_FENCE, &bo); - if (ret) + if (ret) { + printf("failed to create framebuffer (ret %d)\n",ret); goto err; + } ret = drmModeAddFB(fd, SIZE_X, SIZE_Y, 32, 32, PITCH * 4, &bo, &fb); @@ -392,13 +393,13 @@ void testCursor(int fd, uint32_t crtc) DRM_BO_FLAG_NO_EVICT, DRM_BO_HINT_DONT_FENCE, &bo); - prettyCursor(fd, bo.handle); - + prettyCursor(fd, bo.handle, 0xFFFF00FF); printf("set cursor\n"); drmModeSetCursor(fd, crtc, &bo, 64, 64); printf("move cursor 0, 0\n"); drmModeMoveCursor(fd, crtc, 0, 0); sleep(1); + prettyCursor(fd, bo.handle, 0xFFFF0000); printf("move cursor 40, 40\n"); drmModeMoveCursor(fd, crtc, 40, 40); sleep(1); @@ -408,7 +409,7 @@ void testCursor(int fd, uint32_t crtc) drmModeSetCursor(fd, crtc, NULL, 0, 0); } -void prettyCursor(int fd, unsigned int handle) +void prettyCursor(int fd, unsigned int handle, unsigned int color) { drmBO bo; unsigned int *ptr; @@ -418,7 +419,7 @@ void prettyCursor(int fd, unsigned int handle) drmBOMap(fd, &bo, DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0, (void**)&ptr); for (i = 0; i < (64 * 64); i++) - ptr[i] = 0xFFFF00FF; + ptr[i] = color; drmBOUnmap(fd, &bo); drmBOUnreference(fd, &bo); diff --git a/tests/modefb/demo.c b/tests/modefb/demo.c index 9af369c2..f80753cf 100644 --- a/tests/modefb/demo.c +++ b/tests/modefb/demo.c @@ -4,6 +4,7 @@ #include #include #include "linux/fb.h" +#include #include "sys/ioctl.h" #include "xf86drm.h" #include "xf86drmMode.h" @@ -12,19 +13,20 @@ void pretty(int fd); void setMode(struct fb_var_screeninfo *var); void pan(int fd, struct fb_var_screeninfo *var, int x, int y); void cursor(int fd, int drmfd); +void prettyColors(int fd); void prettyCursor(int fd, unsigned int handle, unsigned int color); extern void sleep(int); +struct fb_var_screeninfo var; +struct fb_fix_screeninfo fix; + int main(int argc, char **argv) { - struct fb_var_screeninfo var; - struct fb_fix_screeninfo fix; - const char* driver = "i915"; - const char* name = "/dev/fb0"; - - int fd = open(name, O_RDONLY); - int drmfd = drmOpen(driver, NULL); + const char* name = "/dev/fb1"; + int i; + int fd = open(name, O_RDWR); + int drmfd = drmOpenControl(0); if (fd == -1) { printf("open %s : %s\n", name, strerror(errno)); @@ -32,7 +34,7 @@ int main(int argc, char **argv) } if (drmfd < 0) { - printf("drmOpen failed\n"); + printf("drmOpenControl failed\n"); return 1; } @@ -45,6 +47,15 @@ int main(int argc, char **argv) printf("fix %s\n", strerror(errno)); setMode(&var); + + if (ioctl(fd, FBIOPUT_VSCREENINFO, &var)) + printf("var %s\n", strerror(errno)); + + for (i = 0; i < 1; i++) { + prettyColors(fd); + } + sleep(1); + printf("pan: 0, 0\n"); pan(fd, &var, 0, 0); sleep(2); @@ -71,12 +82,51 @@ void pan(int fd, struct fb_var_screeninfo *var, int x, int y) var->xoffset = x; var->yoffset = y; - var->activate = FB_ACTIVATE_NOW; - - if (ioctl(fd, FBIOPUT_VSCREENINFO, var)) + if (ioctl(fd, FBIOPAN_DISPLAY, var)) printf("pan error: %s\n", strerror(errno)); } +void draw(unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned int v, unsigned int *ptr) +{ + int i, j; + + for (i = x; i < x + w; i++) + for(j = y; j < y + h; j++) + ptr[(i * var.xres_virtual) + j] = v; +} + +void prettyColors(int fd) +{ + unsigned int *ptr, *newptr; + int i,w,h; + int size = var.xres * var.yres * var.bits_per_pixel; + + ptr = (unsigned int *)mmap(NULL, size, + PROT_READ|PROT_WRITE, MAP_SHARED, fd, + 0); + if (ptr < 0) { + printf("FAILED MMAP %d\n",errno); + exit(1); + } + + newptr = ptr; + for (h = 0; h < var.yres; h++) { + for (w = 0; w < var.xres; w++) { + newptr[w] = 0xFFFFFFFF; + } + newptr += var.xres_virtual; + } + + for (i = 0; i < 8; i++) + draw(i * 40, i * 40, 40, 40, 0, ptr); + + + draw(200, 100, 40, 40, 0xff00ff, ptr); + draw(100, 200, 40, 40, 0xff00ff, ptr); + + munmap(ptr, size); +} + /* * Cursor support removed from the fb kernel interface * using drm instead. @@ -102,11 +152,13 @@ void cursor(int fd, int drmfd) prettyCursor(drmfd, bo.handle, 0xFFFF00FF); drmModeSetCursor(drmfd, crtc, &bo, 64, 64); drmModeMoveCursor(drmfd, crtc, 0, 0); - sleep(2); - drmModeMoveCursor(drmfd, crtc, 40, 40); + sleep(1); prettyCursor(drmfd, bo.handle, 0xFFFF0000); - sleep(2); - drmModeSetCursor(drmfd, crtc, 0, 0, 0); + drmModeMoveCursor(drmfd, crtc, 40, 40); + sleep(1); + drmModeMoveCursor(drmfd, crtc, 100, 100); + sleep(1); + drmModeSetCursor(drmfd, crtc, NULL, 0, 0); drmBOUnreference(drmfd, &bo); } @@ -173,4 +225,5 @@ void setMode(struct fb_var_screeninfo *var) { var->pixclock = 10000000 / mode.htotal * 1000 / mode.vtotal * 100; /* avoid overflow */ var->pixclock = var->pixclock * 1000 / mode.vrefresh; + var->bits_per_pixel = 32; } -- cgit v1.2.3 From 127cb1ff9a7bbb7af73cc418a7adc30d68c454d2 Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Tue, 5 Feb 2008 15:24:29 +0000 Subject: tweak it --- tests/modefb/demo.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'tests') diff --git a/tests/modefb/demo.c b/tests/modefb/demo.c index f80753cf..ef2b6585 100644 --- a/tests/modefb/demo.c +++ b/tests/modefb/demo.c @@ -97,8 +97,8 @@ void draw(unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsign void prettyColors(int fd) { - unsigned int *ptr, *newptr; - int i,w,h; + unsigned int *ptr; + int i; int size = var.xres * var.yres * var.bits_per_pixel; ptr = (unsigned int *)mmap(NULL, size, @@ -109,13 +109,7 @@ void prettyColors(int fd) exit(1); } - newptr = ptr; - for (h = 0; h < var.yres; h++) { - for (w = 0; w < var.xres; w++) { - newptr[w] = 0xFFFFFFFF; - } - newptr += var.xres_virtual; - } + memset(ptr, 0xFF, size); for (i = 0; i < 8; i++) draw(i * 40, i * 40, 40, 40, 0, ptr); -- cgit v1.2.3 From 516c7a7b28ebf4bba797eaa718450b51aa772c6e Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Tue, 5 Feb 2008 15:30:28 +0000 Subject: update app to cycle through 4 fbdev's --- tests/modefb/demo.c | 102 +++++++++++++++++++++++++++------------------------- 1 file changed, 54 insertions(+), 48 deletions(-) (limited to 'tests') diff --git a/tests/modefb/demo.c b/tests/modefb/demo.c index ef2b6585..7fa3b93f 100644 --- a/tests/modefb/demo.c +++ b/tests/modefb/demo.c @@ -23,57 +23,63 @@ struct fb_fix_screeninfo fix; int main(int argc, char **argv) { - const char* name = "/dev/fb1"; - int i; - int fd = open(name, O_RDWR); + char name[100]; + int i,d; + int fd; int drmfd = drmOpenControl(0); - if (fd == -1) { - printf("open %s : %s\n", name, strerror(errno)); - return 1; - } - - if (drmfd < 0) { - printf("drmOpenControl failed\n"); - return 1; + /* try four devices */ + for (d = 0; d < 4; d++) { + snprintf(name, 100, "/dev/fb%d", d); + fd = open(name, O_RDWR); + + if (fd == -1) { + printf("open %s : %s\n", name, strerror(errno)); + return 1; + } + + if (drmfd < 0) { + printf("drmOpenControl failed\n"); + return 1; + } + + memset(&var, 0, sizeof(struct fb_var_screeninfo)); + memset(&fix, 0, sizeof(struct fb_fix_screeninfo)); + + if (ioctl(fd, FBIOGET_VSCREENINFO, &var)) + printf("var %s\n", strerror(errno)); + if (ioctl(fd, FBIOGET_FSCREENINFO, &fix)) + printf("fix %s\n", strerror(errno)); + + setMode(&var); + + if (ioctl(fd, FBIOPUT_VSCREENINFO, &var)) + printf("var %s\n", strerror(errno)); + + for (i = 0; i < 1; i++) { + prettyColors(fd); + } + sleep(1); + + printf("pan: 0, 0\n"); + pan(fd, &var, 0, 0); + sleep(2); + printf("pan: 100, 0\n"); + pan(fd, &var, 100, 0); + sleep(2); + printf("pan: 0, 100\n"); + pan(fd, &var, 0, 100); + sleep(2); + printf("pan: 100, 100\n"); + pan(fd, &var, 100, 100); + sleep(2); + printf("pan: 0, 0\n"); + pan(fd, &var, 0, 0); + sleep(2); + + printf("cursor (may show up on wrong CRTC - fixme)\n"); + cursor(fd, drmfd); } - - memset(&var, 0, sizeof(struct fb_var_screeninfo)); - memset(&fix, 0, sizeof(struct fb_fix_screeninfo)); - - if (ioctl(fd, FBIOGET_VSCREENINFO, &var)) - printf("var %s\n", strerror(errno)); - if (ioctl(fd, FBIOGET_FSCREENINFO, &fix)) - printf("fix %s\n", strerror(errno)); - - setMode(&var); - - if (ioctl(fd, FBIOPUT_VSCREENINFO, &var)) - printf("var %s\n", strerror(errno)); - - for (i = 0; i < 1; i++) { - prettyColors(fd); - } - sleep(1); - - printf("pan: 0, 0\n"); - pan(fd, &var, 0, 0); - sleep(2); - printf("pan: 100, 0\n"); - pan(fd, &var, 100, 0); - sleep(2); - printf("pan: 0, 100\n"); - pan(fd, &var, 0, 100); - sleep(2); - printf("pan: 100, 100\n"); - pan(fd, &var, 100, 100); - sleep(2); - printf("pan: 0, 0\n"); - pan(fd, &var, 0, 0); - sleep(2); - - printf("cursor\n"); - cursor(fd, drmfd); return 0; } -- cgit v1.2.3 From 87d5f9cb2d2812c1da726e38965f0eb78c2b8dfa Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 7 Feb 2008 19:22:38 +0100 Subject: Small update to modedemo --- tests/modedemo/demo.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/modedemo/demo.c b/tests/modedemo/demo.c index 48a4f1f1..0882fc91 100644 --- a/tests/modedemo/demo.c +++ b/tests/modedemo/demo.c @@ -201,12 +201,30 @@ int demoCreateScreens(struct demo_driver *driver) void demoTakeDownScreen(struct demo_screen *screen) { - /* TODO Unrefence the BO */ - /* TODO Destroy FB */ - /* TODO take down the mode */ + int fd = screen->driver->fd; + drmBO bo; + + if (screen->crtc) + drmModeSetCrtc(fd, screen->crtc->crtc_id, 0, 0, 0, 0, 0, 0); + + if (screen->fb) + drmModeRmFB(fd, screen->fb->buffer_id); + + /* maybe we should keep a pointer to the bo on the screen */ + if (screen->fb && !drmBOReference(fd, screen->fb->handle, &bo)) { + drmBOUnreference(fd, &bo); + drmBOUnreference(fd, &bo); + } else { + printf("bo error\n"); + } drmModeFreeOutput(screen->output); drmModeFreeCrtc(screen->crtc); + drmModeFreeFB(screen->fb); + + screen->output = NULL; + screen->crtc = NULL; + screen->fb = NULL; } drmModeCrtcPtr demoFindFreeCrtc(struct demo_driver *driver, drmModeOutputPtr output) -- cgit v1.2.3 From c8b45e9362aa16fed08540996af6d0b1e2e730d0 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 7 Feb 2008 19:25:52 +0100 Subject: Added userspace part of hotplug ioctl and demo --- libdrm/xf86drmMode.c | 9 +++ libdrm/xf86drmMode.h | 4 ++ tests/modehotplug/Makefile | 14 ++++ tests/modehotplug/demo.c | 157 +++++++++++++++++++++++++++++++++++++++++++++ tests/modehotplug/test | 1 + 5 files changed, 185 insertions(+) create mode 100644 tests/modehotplug/Makefile create mode 100644 tests/modehotplug/demo.c create mode 100755 tests/modehotplug/test (limited to 'tests') diff --git a/libdrm/xf86drmMode.c b/libdrm/xf86drmMode.c index 681ad417..52fef81b 100644 --- a/libdrm/xf86drmMode.c +++ b/libdrm/xf86drmMode.c @@ -191,6 +191,15 @@ err_allocs: return r; } +uint32_t drmModeGetHotplug(int fd) +{ + struct drm_mode_hotplug arg; + arg.counter = 0; + + ioctl(fd, DRM_IOCTL_MODE_HOTPLUG, &arg); + return arg.counter; +} + int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth, uint8_t bpp, uint32_t pitch, drmBO *bo, uint32_t *buf_id) { diff --git a/libdrm/xf86drmMode.h b/libdrm/xf86drmMode.h index e878c40a..7cc3ceca 100644 --- a/libdrm/xf86drmMode.h +++ b/libdrm/xf86drmMode.h @@ -159,6 +159,10 @@ extern void drmModeFreeOutput( drmModeOutputPtr ptr ); */ extern drmModeResPtr drmModeGetResources(int fd); +/** + * Retrives the hotplug counter + */ +extern uint32_t drmModeGetHotplug(int fd); /* * FrameBuffer manipulation. diff --git a/tests/modehotplug/Makefile b/tests/modehotplug/Makefile new file mode 100644 index 00000000..467fb11a --- /dev/null +++ b/tests/modehotplug/Makefile @@ -0,0 +1,14 @@ + +all: app + +#CFLAGS = -g -ansi -pedantic -DPOSIX_C_SOURCE=199309L \ +# -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE \ + +app: demo.c + @gcc $(CFLAGS) -o app -Wall -I../../libdrm -I../../shared-core -L../../libdrm/.libs -ldrm demo.c + +clean: + @rm -f app + +run: app + sudo ./test diff --git a/tests/modehotplug/demo.c b/tests/modehotplug/demo.c new file mode 100644 index 00000000..4ef2e386 --- /dev/null +++ b/tests/modehotplug/demo.c @@ -0,0 +1,157 @@ + +#include +#include +#include +#include +#include +#include + +#include "xf86drm.h" +#include "xf86drmMode.h" + +/* structs for the demo_driver */ + +#define DEMO_MAX_OUTPUTS 8 + +struct demo_driver +{ + /* drm stuff */ + int fd; + drmModeResPtr res; + uint32_t counter; + + drmModeOutputPtr outputs[DEMO_MAX_OUTPUTS]; +}; + +struct demo_driver* demoCreateDriver(void); +void demoUpdateRes(struct demo_driver *driver); + +void demoPopulateOutputs(struct demo_driver *driver); +void demoHotplug(struct demo_driver *driver); + +const char* demoGetStatus(drmModeOutputPtr out); + +int main(int argc, char **argv) +{ + struct demo_driver *driver; + uint32_t temp; + int i; + + printf("starting demo\n"); + + driver = demoCreateDriver(); + + if (!driver) { + printf("failed to create driver\n"); + return 1; + } + + driver->counter = drmModeGetHotplug(driver->fd); + demoPopulateOutputs(driver); + while (driver->counter != (temp = drmModeGetHotplug(driver->fd))) { + demoPopulateOutputs(driver); + driver->counter = temp; + } + + for (i = 0; i < driver->res->count_outputs && i < DEMO_MAX_OUTPUTS; i++) { + printf("Output %u is %s\n", + driver->outputs[i]->output_id, + demoGetStatus(driver->outputs[i])); + } + + while(1) { + usleep(100000); + temp = drmModeGetHotplug(driver->fd); + if (temp == driver->counter) + continue; + + demoHotplug(driver); + driver->counter = temp; + } + + return 0; +} + +const char* demoGetStatus(drmModeOutputPtr output) +{ + switch (output->connection) { + case DRM_MODE_CONNECTED: + return "connected"; + case DRM_MODE_DISCONNECTED: + return "disconnected"; + default: + return "unknown"; + } +} + +void demoHotplug(struct demo_driver *driver) +{ + drmModeResPtr res = driver->res; + int i; + drmModeOutputPtr temp, current; + + for (i = 0; i < res->count_outputs && i < DEMO_MAX_OUTPUTS; i++) { + temp = drmModeGetOutput(driver->fd, res->outputs[i]); + current = driver->outputs[i]; + + if (temp->connection != current->connection) { + printf("Output %u became %s was %s\n", + temp->output_id, + demoGetStatus(temp), + demoGetStatus(current)); + } + + drmModeFreeOutput(current); + driver->outputs[i] = temp; + } +} + +void demoPopulateOutputs(struct demo_driver *driver) +{ + drmModeResPtr res = driver->res; + int i; + + for (i = 0; i < res->count_outputs && i < DEMO_MAX_OUTPUTS; i++) { + drmModeFreeOutput(driver->outputs[i]); + driver->outputs[i] = drmModeGetOutput(driver->fd, res->outputs[i]); + } +} + +struct demo_driver* demoCreateDriver(void) +{ + struct demo_driver* driver = malloc(sizeof(struct demo_driver)); + + memset(driver, 0, sizeof(struct demo_driver)); + + driver->fd = drmOpen("i915", NULL); + + if (driver->fd < 0) { + printf("Failed to open the card fb\n"); + goto err_driver; + } + + demoUpdateRes(driver); + if (!driver->res) { + printf("could not retrive resources\n"); + goto err_res; + } + + return driver; + +err_res: + drmClose(driver->fd); +err_driver: + free(driver); + return NULL; +} + +void demoUpdateRes(struct demo_driver *driver) +{ + if (driver->res) + drmModeFreeResources(driver->res); + + driver->res = drmModeGetResources(driver->fd); + + if (!driver->res) + printf("failed to get resources from kernel\n"); +} diff --git a/tests/modehotplug/test b/tests/modehotplug/test new file mode 100755 index 00000000..f98e3708 --- /dev/null +++ b/tests/modehotplug/test @@ -0,0 +1 @@ +LD_PRELOAD=../../libdrm/.libs/libdrm.so ./app -- cgit v1.2.3 From 2ceafcccb77723a464abd51d07e664933e117b6e Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 7 Feb 2008 19:32:20 +0100 Subject: Wrong open call --- tests/modehotplug/demo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/modehotplug/demo.c b/tests/modehotplug/demo.c index 4ef2e386..1518e84c 100644 --- a/tests/modehotplug/demo.c +++ b/tests/modehotplug/demo.c @@ -123,7 +123,7 @@ struct demo_driver* demoCreateDriver(void) memset(driver, 0, sizeof(struct demo_driver)); - driver->fd = drmOpen("i915", NULL); + driver->fd = drmOpenControl(0); if (driver->fd < 0) { printf("Failed to open the card fb\n"); -- cgit v1.2.3 From f51dc37d75b0b1b8e5636f8f2c201e29986517ea Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Thu, 7 Feb 2008 22:21:50 +0000 Subject: After the previous revert fix libdrm to start at minor 1 and fixup the demos --- libdrm/xf86drm.c | 29 +++++++++++++---------------- tests/mode/modetest.c | 2 +- tests/modedemo/demo.c | 39 +++++++++++++++++++++++++++++++++------ tests/modefb/demo.c | 2 +- 4 files changed, 48 insertions(+), 24 deletions(-) (limited to 'tests') diff --git a/libdrm/xf86drm.c b/libdrm/xf86drm.c index 39a849c6..8849f8bc 100644 --- a/libdrm/xf86drm.c +++ b/libdrm/xf86drm.c @@ -355,7 +355,7 @@ static int drmOpenMinor(int minor, int create, int type) { int fd; char buf[64]; - + if (create) return drmOpenDevice(makedev(DRM_MAJOR, minor), minor, type); @@ -421,8 +421,15 @@ static int drmOpenByBusid(const char *busid) const char *buf; drmSetVersion sv; + /* + * Open the first minor number that matches the driver name and isn't + * already in use. If it's in use it will have a busid assigned already. + * + * start at 1, as 0 is the control node, and we should use drmOpenControl + * for that. + */ drmMsg("drmOpenByBusid: Searching for BusID %s\n", busid); - for (i = 0; i < DRM_MAX_MINOR; i++) { + for (i = 1; i < DRM_MAX_MINOR; i++) { fd = drmOpenMinor(i, 1, DRM_NODE_RENDER); drmMsg("drmOpenByBusid: drmOpenMinor returns %d\n", fd); if (fd >= 0) { @@ -467,24 +474,14 @@ static int drmOpenByName(const char *name) drmVersionPtr version; char * id; - if (!drmAvailable()) { - if (!drm_server_info) { - return -1; - } - else { - /* try to load the kernel module now */ - if (!drm_server_info->load_module(name)) { - drmMsg("[drm] failed to load kernel module \"%s\"\n", name); - return -1; - } - } - } - /* * Open the first minor number that matches the driver name and isn't * already in use. If it's in use it will have a busid assigned already. + * + * start at 1, as 0 is the control node, and we should use drmOpenControl + * for that. */ - for (i = 0; i < DRM_MAX_MINOR; i++) { + for (i = 1; i < DRM_MAX_MINOR; i++) { if ((fd = drmOpenMinor(i, 1, DRM_NODE_RENDER)) >= 0) { if ((version = drmGetVersion(fd))) { if (!strcmp(version->name, name)) { diff --git a/tests/mode/modetest.c b/tests/mode/modetest.c index ab0cdc9c..caa3d970 100644 --- a/tests/mode/modetest.c +++ b/tests/mode/modetest.c @@ -351,7 +351,7 @@ int main(int argc, char **argv) printf("Starting test\n"); - fd = drmOpenControl(0); + fd = drmOpen("i915", NULL); if (fd < 0) { printf("Failed to open the card fb (%d)\n",fd); diff --git a/tests/modedemo/demo.c b/tests/modedemo/demo.c index 0882fc91..6b6997ad 100644 --- a/tests/modedemo/demo.c +++ b/tests/modedemo/demo.c @@ -1,11 +1,16 @@ - +#define CLEAN_FBDEV #include #include #include #include #include #include - +#ifdef CLEAN_FBDEV +#include +#include +#include +#include +#endif #include "xf86drm.h" #include "xf86drmMode.h" @@ -20,6 +25,11 @@ void testCursor(int fd, uint32_t crtc); void prettyColors(int fd, unsigned int handle); void prettyCursor(int fd, unsigned int handle, unsigned int color); +#ifdef CLEAN_FBDEV +struct fb_var_screeninfo var; +struct fb_fix_screeninfo fix; +#endif + /* structs for the demo_driver */ struct demo_driver; @@ -90,6 +100,19 @@ int main(int argc, char **argv) struct demo_driver *driver; int num; int i; +#ifdef CLEAN_FBDEV + int fbdev_fd; + + fbdev_fd = open("/dev/fb0", O_RDWR); + + memset(&var, 0, sizeof(struct fb_var_screeninfo)); + memset(&fix, 0, sizeof(struct fb_fix_screeninfo)); + + if (ioctl(fbdev_fd, FBIOGET_VSCREENINFO, &var)) + printf("var %s\n", strerror(errno)); + if (ioctl(fbdev_fd, FBIOGET_FSCREENINFO, &fix)) + printf("fix %s\n", strerror(errno)); +#endif printf("starting demo\n"); @@ -131,9 +154,13 @@ int main(int argc, char **argv) testCursor(driver->fd, driver->screens[i].crtc->crtc_id); } - sleep(2); - printf("ok\n"); - return 0; +#ifdef CLEAN_FBDEV + if (ioctl(fbdev_fd, FBIOPUT_VSCREENINFO, &var)) + printf("var %s\n", strerror(errno)); +#endif + + printf("ok\n"); + return 0; } int demoCreateScreens(struct demo_driver *driver) @@ -260,7 +287,7 @@ struct demo_driver* demoCreateDriver(void) memset(driver, 0, sizeof(struct demo_driver)); - driver->fd = drmOpenControl(0); + driver->fd = drmOpen("i915", NULL); if (driver->fd < 0) { printf("Failed to open the card fb\n"); diff --git a/tests/modefb/demo.c b/tests/modefb/demo.c index 7fa3b93f..4d81e511 100644 --- a/tests/modefb/demo.c +++ b/tests/modefb/demo.c @@ -26,7 +26,7 @@ int main(int argc, char **argv) char name[100]; int i,d; int fd; - int drmfd = drmOpenControl(0); + int drmfd = drmOpen("i915", NULL); /* try four devices */ for (d = 0; d < 4; d++) { -- cgit v1.2.3 From db2a1a223b94a5da9c5483b7963660c70052f025 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 7 Feb 2008 23:32:59 +0100 Subject: Added you can now clone displays in modedemo --- tests/modedemo/demo.c | 119 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 105 insertions(+), 14 deletions(-) (limited to 'tests') diff --git a/tests/modedemo/demo.c b/tests/modedemo/demo.c index 6b6997ad..9eef9022 100644 --- a/tests/modedemo/demo.c +++ b/tests/modedemo/demo.c @@ -1,4 +1,16 @@ +/* + * Some defines to define the behavior of the program + */ + #define CLEAN_FBDEV +#undef DEMO_CLONE + +#define SIZE_X 2048 +#define SIZE_Y 2048 +/* Pitch needs to be power of two */ +#define PITCH 2048 + + #include #include #include @@ -14,11 +26,6 @@ #include "xf86drm.h" #include "xf86drmMode.h" -#define SIZE_X 2048 -#define SIZE_Y 2048 -/* Pitch needs to be power of two */ -#define PITCH 2048 - /* old functions to be replaced */ drmModeFBPtr createFB(int fd, drmModeResPtr res); void testCursor(int fd, uint32_t crtc); @@ -40,7 +47,10 @@ struct demo_screen drmBO buffer; drmModeFBPtr fb; drmModeCrtcPtr crtc; - drmModeOutputPtr output; + + size_t num_outputs; + uint32_t outputs_id[8]; + drmModeOutputPtr outputs[8]; struct drm_mode_modeinfo *mode; @@ -70,6 +80,7 @@ struct demo_driver struct demo_driver* demoCreateDriver(void); void demoUpdateRes(struct demo_driver *driver); int demoCreateScreens(struct demo_driver *driver); +int demoCreateScreenCloned(struct demo_driver *driver); void demoTakeDownScreen(struct demo_screen *screen); int demoFindConnectedOutputs(struct demo_driver *driver, drmModeOutputPtr *out, size_t max_out); drmModeCrtcPtr demoFindFreeCrtc(struct demo_driver *driver, drmModeOutputPtr output); @@ -123,7 +134,12 @@ int main(int argc, char **argv) return 1; } +#ifndef DEMO_CLONE num = demoCreateScreens(driver); +#else + num = demoCreateScreenCloned(driver); +#endif + if (num < 1) { printf("no screens attached or an error occured\n"); return 1; @@ -154,13 +170,19 @@ int main(int argc, char **argv) testCursor(driver->fd, driver->screens[i].crtc->crtc_id); } + sleep(2); + printf("taking down screens\n"); + for (i = 0; i < num; i++) { + demoTakeDownScreen(&driver->screens[i]); + } + #ifdef CLEAN_FBDEV if (ioctl(fbdev_fd, FBIOPUT_VSCREENINFO, &var)) printf("var %s\n", strerror(errno)); #endif - printf("ok\n"); - return 0; + printf("ok\n"); + return 0; } int demoCreateScreens(struct demo_driver *driver) @@ -201,7 +223,10 @@ int demoCreateScreens(struct demo_driver *driver) screen->virt_y = SIZE_Y; screen->pitch = PITCH; - screen->output = out[i]; + screen->outputs[0] = out[i]; + screen->outputs_id[0] = out[i]->output_id; + screen->num_outputs = 1; + screen->mode = &mode; screen->driver = driver; @@ -210,7 +235,7 @@ int demoCreateScreens(struct demo_driver *driver) screen->crtc->crtc_id, screen->fb->buffer_id, 0, 0, - &screen->output->output_id, 1, + screen->outputs_id, screen->num_outputs, screen->mode); if (ret) { @@ -226,9 +251,73 @@ int demoCreateScreens(struct demo_driver *driver) return num_screens; } +int demoCreateScreenCloned(struct demo_driver *driver) +{ + drmModeOutputPtr out[MAX_FIND_OUTPUTS]; + int num; + struct demo_screen *screen; + int ret = 0; + int i; + + num = demoFindConnectedOutputs(driver, out, MAX_FIND_OUTPUTS); + if (num < 0) + return 0; + + printf("found %i connected outputs\n", num); + + screen = &driver->screens[0]; + + screen->fb = createFB(driver->fd, driver->res); + if (!screen->fb) { + printf("could not create framebuffer\n"); + return 0; + } + + screen->mode = &mode; + screen->driver = driver; + + screen->virt_x = SIZE_X; + screen->virt_y = SIZE_Y; + screen->pitch = PITCH; + + screen->num_outputs = 0; + for (i = 0; i < num; i++) { + screen->crtc = demoFindFreeCrtc(driver, out[i]); + if (!screen->crtc) { + printf("found no free crtc for output\n"); + drmModeFreeOutput(out[i]); + continue; + } + + screen->outputs[screen->num_outputs] = out[i]; + screen->outputs_id[screen->num_outputs] = out[i]->output_id; + screen->num_outputs++; + printf("%u, %u\n", out[i]->output_id, screen->num_outputs); + } + + ret = drmModeSetCrtc( + driver->fd, + screen->crtc->crtc_id, + screen->fb->buffer_id, + 0, 0, + screen->outputs_id, screen->num_outputs, + screen->mode); + + if (ret) { + printf("failed to set mode\n"); + demoTakeDownScreen(screen); + return 0; + } + + demoUpdateRes(driver); + + return 1; +} + void demoTakeDownScreen(struct demo_screen *screen) { int fd = screen->driver->fd; + int i; drmBO bo; if (screen->crtc) @@ -245,11 +334,14 @@ void demoTakeDownScreen(struct demo_screen *screen) printf("bo error\n"); } - drmModeFreeOutput(screen->output); + for (i = 0; i < screen->num_outputs; i++) { + drmModeFreeOutput(screen->outputs[i]); + screen->outputs[i] = NULL; + } + drmModeFreeCrtc(screen->crtc); drmModeFreeFB(screen->fb); - screen->output = NULL; screen->crtc = NULL; screen->fb = NULL; } @@ -260,7 +352,6 @@ drmModeCrtcPtr demoFindFreeCrtc(struct demo_driver *driver, drmModeOutputPtr out int i, j, used = 0; drmModeResPtr res = driver->res; - for (i = 0; i < res->count_crtcs; i++) { used = 0; for (j = 0; j < DEMO_MAX_SCREENS; j++) { @@ -353,7 +444,7 @@ void demoPanScreen(struct demo_screen *screen, uint16_t x, uint16_t y) screen->crtc->crtc_id, screen->fb->buffer_id, x, y, - &screen->output->output_id, 1, + screen->outputs_id, screen->num_outputs, screen->mode); } -- cgit v1.2.3 From db85ed25afc616acfaadb21facf6066354f9d490 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 13 Feb 2008 12:20:02 +1000 Subject: Revert "After the previous revert fix libdrm to start at minor 1" This reverts commit f51dc37d75b0b1b8e5636f8f2c201e29986517ea. Conflicts: tests/modedemo/demo.c --- libdrm/xf86drm.c | 29 ++++++++++++++++------------- tests/mode/modetest.c | 2 +- tests/modedemo/demo.c | 28 ++-------------------------- tests/modefb/demo.c | 2 +- 4 files changed, 20 insertions(+), 41 deletions(-) (limited to 'tests') diff --git a/libdrm/xf86drm.c b/libdrm/xf86drm.c index 8849f8bc..39a849c6 100644 --- a/libdrm/xf86drm.c +++ b/libdrm/xf86drm.c @@ -355,7 +355,7 @@ static int drmOpenMinor(int minor, int create, int type) { int fd; char buf[64]; - + if (create) return drmOpenDevice(makedev(DRM_MAJOR, minor), minor, type); @@ -421,15 +421,8 @@ static int drmOpenByBusid(const char *busid) const char *buf; drmSetVersion sv; - /* - * Open the first minor number that matches the driver name and isn't - * already in use. If it's in use it will have a busid assigned already. - * - * start at 1, as 0 is the control node, and we should use drmOpenControl - * for that. - */ drmMsg("drmOpenByBusid: Searching for BusID %s\n", busid); - for (i = 1; i < DRM_MAX_MINOR; i++) { + for (i = 0; i < DRM_MAX_MINOR; i++) { fd = drmOpenMinor(i, 1, DRM_NODE_RENDER); drmMsg("drmOpenByBusid: drmOpenMinor returns %d\n", fd); if (fd >= 0) { @@ -474,14 +467,24 @@ static int drmOpenByName(const char *name) drmVersionPtr version; char * id; + if (!drmAvailable()) { + if (!drm_server_info) { + return -1; + } + else { + /* try to load the kernel module now */ + if (!drm_server_info->load_module(name)) { + drmMsg("[drm] failed to load kernel module \"%s\"\n", name); + return -1; + } + } + } + /* * Open the first minor number that matches the driver name and isn't * already in use. If it's in use it will have a busid assigned already. - * - * start at 1, as 0 is the control node, and we should use drmOpenControl - * for that. */ - for (i = 1; i < DRM_MAX_MINOR; i++) { + for (i = 0; i < DRM_MAX_MINOR; i++) { if ((fd = drmOpenMinor(i, 1, DRM_NODE_RENDER)) >= 0) { if ((version = drmGetVersion(fd))) { if (!strcmp(version->name, name)) { diff --git a/tests/mode/modetest.c b/tests/mode/modetest.c index caa3d970..ab0cdc9c 100644 --- a/tests/mode/modetest.c +++ b/tests/mode/modetest.c @@ -351,7 +351,7 @@ int main(int argc, char **argv) printf("Starting test\n"); - fd = drmOpen("i915", NULL); + fd = drmOpenControl(0); if (fd < 0) { printf("Failed to open the card fb (%d)\n",fd); diff --git a/tests/modedemo/demo.c b/tests/modedemo/demo.c index 9eef9022..474f04a5 100644 --- a/tests/modedemo/demo.c +++ b/tests/modedemo/demo.c @@ -10,19 +10,13 @@ /* Pitch needs to be power of two */ #define PITCH 2048 - #include #include #include #include #include #include -#ifdef CLEAN_FBDEV -#include -#include -#include -#include -#endif + #include "xf86drm.h" #include "xf86drmMode.h" @@ -32,11 +26,6 @@ void testCursor(int fd, uint32_t crtc); void prettyColors(int fd, unsigned int handle); void prettyCursor(int fd, unsigned int handle, unsigned int color); -#ifdef CLEAN_FBDEV -struct fb_var_screeninfo var; -struct fb_fix_screeninfo fix; -#endif - /* structs for the demo_driver */ struct demo_driver; @@ -111,19 +100,6 @@ int main(int argc, char **argv) struct demo_driver *driver; int num; int i; -#ifdef CLEAN_FBDEV - int fbdev_fd; - - fbdev_fd = open("/dev/fb0", O_RDWR); - - memset(&var, 0, sizeof(struct fb_var_screeninfo)); - memset(&fix, 0, sizeof(struct fb_fix_screeninfo)); - - if (ioctl(fbdev_fd, FBIOGET_VSCREENINFO, &var)) - printf("var %s\n", strerror(errno)); - if (ioctl(fbdev_fd, FBIOGET_FSCREENINFO, &fix)) - printf("fix %s\n", strerror(errno)); -#endif printf("starting demo\n"); @@ -378,7 +354,7 @@ struct demo_driver* demoCreateDriver(void) memset(driver, 0, sizeof(struct demo_driver)); - driver->fd = drmOpen("i915", NULL); + driver->fd = drmOpenControl(0); if (driver->fd < 0) { printf("Failed to open the card fb\n"); diff --git a/tests/modefb/demo.c b/tests/modefb/demo.c index 4d81e511..7fa3b93f 100644 --- a/tests/modefb/demo.c +++ b/tests/modefb/demo.c @@ -26,7 +26,7 @@ int main(int argc, char **argv) char name[100]; int i,d; int fd; - int drmfd = drmOpen("i915", NULL); + int drmfd = drmOpenControl(0); /* try four devices */ for (d = 0; d < 4; d++) { -- cgit v1.2.3 From 88cb873045b76bf947f45fb127baa96f055ad32c Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Wed, 20 Feb 2008 19:54:36 +0000 Subject: minor test fixes --- tests/modedemo/demo.c | 45 ++++++++++++++++++++++++++++++++++++++++++--- tests/modefb/demo.c | 14 ++++++++------ tests/modehotplug/demo.c | 2 +- 3 files changed, 51 insertions(+), 10 deletions(-) (limited to 'tests') diff --git a/tests/modedemo/demo.c b/tests/modedemo/demo.c index 474f04a5..db51cd66 100644 --- a/tests/modedemo/demo.c +++ b/tests/modedemo/demo.c @@ -16,6 +16,12 @@ #include #include #include +#ifdef CLEAN_FBDEV +#include +#include +#include +#include +#endif #include "xf86drm.h" #include "xf86drmMode.h" @@ -26,6 +32,11 @@ void testCursor(int fd, uint32_t crtc); void prettyColors(int fd, unsigned int handle); void prettyCursor(int fd, unsigned int handle, unsigned int color); +#ifdef CLEAN_FBDEV +struct fb_var_screeninfo var; +struct fb_fix_screeninfo fix; +#endif + /* structs for the demo_driver */ struct demo_driver; @@ -101,6 +112,20 @@ int main(int argc, char **argv) int num; int i; +#ifdef CLEAN_FBDEV + int fbdev_fd; + + fbdev_fd = open("/dev/fb0", O_RDWR); + + memset(&var, 0, sizeof(struct fb_var_screeninfo)); + memset(&fix, 0, sizeof(struct fb_fix_screeninfo)); + + if (ioctl(fbdev_fd, FBIOGET_VSCREENINFO, &var)) + printf("var %s\n", strerror(errno)); + if (ioctl(fbdev_fd, FBIOGET_FSCREENINFO, &fix)) + printf("fix %s\n", strerror(errno)); +#endif + printf("starting demo\n"); driver = demoCreateDriver(); @@ -155,10 +180,12 @@ int main(int argc, char **argv) #ifdef CLEAN_FBDEV if (ioctl(fbdev_fd, FBIOPUT_VSCREENINFO, &var)) printf("var %s\n", strerror(errno)); + + close(fbdev_fd); #endif - printf("ok\n"); - return 0; + printf("ok\n"); + return 0; } int demoCreateScreens(struct demo_driver *driver) @@ -296,8 +323,20 @@ void demoTakeDownScreen(struct demo_screen *screen) int i; drmBO bo; +#if 0 + /* This can bust the fbdev arrangement as it basically unhooks + * the outputs and the fbdev backend doesn't know how to put things + * back on track. Realistically, it's up to the crtc owner to restore + * things..... + * + * So if you are mixing API's make sure the modesetting owner puts + * back the original CRTC arrangement so fbdev can continue... + * + * Ho-hum.. + */ if (screen->crtc) drmModeSetCrtc(fd, screen->crtc->crtc_id, 0, 0, 0, 0, 0, 0); +#endif if (screen->fb) drmModeRmFB(fd, screen->fb->buffer_id); @@ -354,7 +393,7 @@ struct demo_driver* demoCreateDriver(void) memset(driver, 0, sizeof(struct demo_driver)); - driver->fd = drmOpenControl(0); + driver->fd = drmOpen("i915",NULL); if (driver->fd < 0) { printf("Failed to open the card fb\n"); diff --git a/tests/modefb/demo.c b/tests/modefb/demo.c index 7fa3b93f..b6d1f65b 100644 --- a/tests/modefb/demo.c +++ b/tests/modefb/demo.c @@ -26,7 +26,12 @@ int main(int argc, char **argv) char name[100]; int i,d; int fd; - int drmfd = drmOpenControl(0); + int drmfd = drmOpen("i915", NULL); + + if (drmfd < 0) { + printf("drmOpenControl failed\n"); + return 1; + } /* try four devices */ for (d = 0; d < 4; d++) { @@ -38,11 +43,6 @@ int main(int argc, char **argv) return 1; } - if (drmfd < 0) { - printf("drmOpenControl failed\n"); - return 1; - } - memset(&var, 0, sizeof(struct fb_var_screeninfo)); memset(&fix, 0, sizeof(struct fb_fix_screeninfo)); @@ -79,6 +79,8 @@ int main(int argc, char **argv) printf("cursor (may show up on wrong CRTC - fixme)\n"); cursor(fd, drmfd); + + close(fd); } return 0; } diff --git a/tests/modehotplug/demo.c b/tests/modehotplug/demo.c index 1518e84c..4ef2e386 100644 --- a/tests/modehotplug/demo.c +++ b/tests/modehotplug/demo.c @@ -123,7 +123,7 @@ struct demo_driver* demoCreateDriver(void) memset(driver, 0, sizeof(struct demo_driver)); - driver->fd = drmOpenControl(0); + driver->fd = drmOpen("i915", NULL); if (driver->fd < 0) { printf("Failed to open the card fb\n"); -- cgit v1.2.3 From 0e72819629741339af46d0e303f33482acdf0972 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Fri, 29 Feb 2008 14:07:29 +1000 Subject: drm: change fb api to take a bo handle not the bo pointer. --- libdrm/xf86drmMode.c | 5 +++-- libdrm/xf86drmMode.h | 2 +- tests/mode/modetest.c | 2 +- tests/modedemo/demo.c | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/libdrm/xf86drmMode.c b/libdrm/xf86drmMode.c index 717e1fe2..dd1a6ca9 100644 --- a/libdrm/xf86drmMode.c +++ b/libdrm/xf86drmMode.c @@ -203,7 +203,8 @@ uint32_t drmModeGetHotplug(int fd) } int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth, - uint8_t bpp, uint32_t pitch, drmBO *bo, uint32_t *buf_id) + uint8_t bpp, uint32_t pitch, uint32_t bo_handle, + uint32_t *buf_id) { struct drm_mode_fb_cmd f; int ret; @@ -213,7 +214,7 @@ int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth, f.pitch = pitch; f.bpp = bpp; f.depth = depth; - f.handle = bo->handle; + f.handle = bo_handle; if (ret = ioctl(fd, DRM_IOCTL_MODE_ADDFB, &f)) return ret; diff --git a/libdrm/xf86drmMode.h b/libdrm/xf86drmMode.h index 71e779d4..edf9efee 100644 --- a/libdrm/xf86drmMode.h +++ b/libdrm/xf86drmMode.h @@ -177,7 +177,7 @@ extern drmModeFBPtr drmModeGetFB(int fd, uint32_t bufferId); * 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. diff --git a/tests/mode/modetest.c b/tests/mode/modetest.c index ab0cdc9c..a50b0cc5 100644 --- a/tests/mode/modetest.c +++ b/tests/mode/modetest.c @@ -291,7 +291,7 @@ int testFrameBufferAdd(int fd, drmModeResPtr res) goto err; printf("\tAdding FB\n"); - ret = drmModeAddFB(fd, 800, 600, 32, 8, 0, &bo, &fb); + ret = drmModeAddFB(fd, 800, 600, 32, 8, 0, bo->handle, &fb); if (ret) goto err_bo; diff --git a/tests/modedemo/demo.c b/tests/modedemo/demo.c index db51cd66..00020bde 100644 --- a/tests/modedemo/demo.c +++ b/tests/modedemo/demo.c @@ -483,7 +483,7 @@ drmModeFBPtr createFB(int fd, drmModeResPtr res) goto err; } - ret = drmModeAddFB(fd, SIZE_X, SIZE_Y, 32, 32, PITCH * 4, &bo, &fb); + ret = drmModeAddFB(fd, SIZE_X, SIZE_Y, 32, 32, PITCH * 4, bo->handle, &fb); if (ret) goto err_bo; -- cgit v1.2.3 From b87c7ff79ee88ec39a285bc17bd2996252b9fd48 Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Wed, 5 Mar 2008 10:33:16 +0000 Subject: Add property info. fix bo handle --- tests/modedemo/demo.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/modedemo/demo.c b/tests/modedemo/demo.c index 00020bde..83a33aa6 100644 --- a/tests/modedemo/demo.c +++ b/tests/modedemo/demo.c @@ -429,7 +429,7 @@ void demoUpdateRes(struct demo_driver *driver) int demoFindConnectedOutputs(struct demo_driver *driver, drmModeOutputPtr *out, size_t max_out) { int count = 0; - int i; + int i,j; int fd = driver->fd; drmModeResPtr res = driver->res; @@ -441,10 +441,20 @@ int demoFindConnectedOutputs(struct demo_driver *driver, drmModeOutputPtr *out, if (!output) continue; - if (output->connection != DRM_MODE_CONNECTED) { + if (output->connection == DRM_MODE_DISCONNECTED) { drmModeFreeOutput(output); continue; } + + for (j = 0; j < output->count_props; j++) { + drmModePropertyPtr prop; + + prop = drmModeGetProperty(fd, output->props[j]); + + printf("Property: %s\n",prop->name); + if (prop->count_enums) + printf("%s\n",prop->enums[output->prop_values[j]].name); + } out[count++] = output; } @@ -483,7 +493,7 @@ drmModeFBPtr createFB(int fd, drmModeResPtr res) goto err; } - ret = drmModeAddFB(fd, SIZE_X, SIZE_Y, 32, 32, PITCH * 4, bo->handle, &fb); + ret = drmModeAddFB(fd, SIZE_X, SIZE_Y, 32, 32, PITCH * 4, bo.handle, &fb); if (ret) goto err_bo; -- cgit v1.2.3 From 7f04dd06e6003dd492ae5ddc876121a686f49157 Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Wed, 12 Mar 2008 09:47:52 +0000 Subject: Add sample code to test hotplug events --- tests/modedemo/demo.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'tests') diff --git a/tests/modedemo/demo.c b/tests/modedemo/demo.c index 83a33aa6..3fad984d 100644 --- a/tests/modedemo/demo.c +++ b/tests/modedemo/demo.c @@ -22,6 +22,7 @@ #include #include #endif +#include #include "xf86drm.h" #include "xf86drmMode.h" @@ -387,9 +388,28 @@ drmModeCrtcPtr demoFindFreeCrtc(struct demo_driver *driver, drmModeOutputPtr out return crtc; } +static int driverfd; + +static void +hotplugSIGNAL(int sig, siginfo_t *si, void *d) +{ + union drm_wait_hotplug hw; + int ret; + + printf("GOT HOTPLUG EVENT!\n"); + + /* ask for another hotplug event ! */ + memset(&hw, 0, sizeof(hw)); + hw.request.type = _DRM_HOTPLUG_SIGNAL; + hw.request.signal = SIGUSR1; + ret = ioctl(driverfd, DRM_IOCTL_WAIT_HOTPLUG, &hw); +} + struct demo_driver* demoCreateDriver(void) { struct demo_driver* driver = malloc(sizeof(struct demo_driver)); + union drm_wait_hotplug hw; + int ret = 0; memset(driver, 0, sizeof(struct demo_driver)); @@ -400,6 +420,33 @@ struct demo_driver* demoCreateDriver(void) goto err_driver; } +#if 0 + /* ioctl wait for hotplug */ + do { + memset(&hw, 0, sizeof(hw)); + ret = ioctl(driver->fd, DRM_IOCTL_WAIT_HOTPLUG, &hw); + printf("HOTPLUG %d %d %d\n",ret,errno,hw.reply.counter); + } while (ret && errno == EBUSY); +#else + /* signal for hotplug */ + { + struct sigaction sa; + struct sigaction osa; + + sigemptyset(&sa.sa_mask); + sa.sa_flags = SA_SIGINFO; + sa.sa_sigaction = hotplugSIGNAL; + sigaction(SIGUSR1, &sa, &osa); + + driverfd = driver->fd; + + memset(&hw, 0, sizeof(hw)); + hw.request.type = _DRM_HOTPLUG_SIGNAL; + hw.request.signal = SIGUSR1; + ret = ioctl(driver->fd, DRM_IOCTL_WAIT_HOTPLUG, &hw); + } +#endif + demoUpdateRes(driver); if (!driver->res) { printf("could not retrive resources\n"); -- cgit v1.2.3 From 7317e774b5cddb7218c1416fa4d9ee98756e4890 Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Fri, 9 May 2008 09:26:17 +0100 Subject: Fix test applications for recent DRM changes --- tests/mode/modetest.c | 2 +- tests/modedemo/demo.c | 4 ++-- tests/modefb/demo.c | 7 +++---- 3 files changed, 6 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/mode/modetest.c b/tests/mode/modetest.c index a50b0cc5..1fab0406 100644 --- a/tests/mode/modetest.c +++ b/tests/mode/modetest.c @@ -291,7 +291,7 @@ int testFrameBufferAdd(int fd, drmModeResPtr res) goto err; printf("\tAdding FB\n"); - ret = drmModeAddFB(fd, 800, 600, 32, 8, 0, bo->handle, &fb); + ret = drmModeAddFB(fd, 800, 600, 32, 8, 0, bo.handle, &fb); if (ret) goto err_bo; diff --git a/tests/modedemo/demo.c b/tests/modedemo/demo.c index 3fad984d..72d69405 100644 --- a/tests/modedemo/demo.c +++ b/tests/modedemo/demo.c @@ -603,7 +603,7 @@ void testCursor(int fd, uint32_t crtc) prettyCursor(fd, bo.handle, 0xFFFF00FF); printf("set cursor\n"); - drmModeSetCursor(fd, crtc, &bo, 64, 64); + drmModeSetCursor(fd, crtc, bo.handle, 64, 64); printf("move cursor 0, 0\n"); drmModeMoveCursor(fd, crtc, 0, 0); sleep(1); @@ -614,7 +614,7 @@ void testCursor(int fd, uint32_t crtc) printf("move cursor 100, 100\n"); drmModeMoveCursor(fd, crtc, 100, 100); sleep(1); - drmModeSetCursor(fd, crtc, NULL, 0, 0); + drmModeSetCursor(fd, crtc, 0, 0, 0); } void prettyCursor(int fd, unsigned int handle, unsigned int color) diff --git a/tests/modefb/demo.c b/tests/modefb/demo.c index b6d1f65b..ead53334 100644 --- a/tests/modefb/demo.c +++ b/tests/modefb/demo.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -16,8 +17,6 @@ void cursor(int fd, int drmfd); void prettyColors(int fd); void prettyCursor(int fd, unsigned int handle, unsigned int color); -extern void sleep(int); - struct fb_var_screeninfo var; struct fb_fix_screeninfo fix; @@ -152,7 +151,7 @@ void cursor(int fd, int drmfd) } prettyCursor(drmfd, bo.handle, 0xFFFF00FF); - drmModeSetCursor(drmfd, crtc, &bo, 64, 64); + drmModeSetCursor(drmfd, crtc, bo.handle, 64, 64); drmModeMoveCursor(drmfd, crtc, 0, 0); sleep(1); prettyCursor(drmfd, bo.handle, 0xFFFF0000); @@ -160,7 +159,7 @@ void cursor(int fd, int drmfd) sleep(1); drmModeMoveCursor(drmfd, crtc, 100, 100); sleep(1); - drmModeSetCursor(drmfd, crtc, NULL, 0, 0); + drmModeSetCursor(drmfd, crtc, 0, 0, 0); drmBOUnreference(drmfd, &bo); } -- cgit v1.2.3 From eeff906aa0f64da12a0154c66d99e8492dd95107 Mon Sep 17 00:00:00 2001 From: Alan Hourihane Date: Fri, 9 May 2008 16:36:28 +0100 Subject: Fix build problems --- linux-core/drm_compat.c | 2 +- tests/mode/modetest.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/linux-core/drm_compat.c b/linux-core/drm_compat.c index 2a761963..dbb31578 100644 --- a/linux-core/drm_compat.c +++ b/linux-core/drm_compat.c @@ -217,7 +217,7 @@ static struct page *drm_bo_vm_fault(struct vm_area_struct *vma, mutex_lock(&bo->mutex); - err = drm_bo_wait(bo, 0, 1, 0); + err = drm_bo_wait(bo, 0, 1, 0, 1); if (err) { data->type = (err == -EAGAIN) ? VM_FAULT_MINOR : VM_FAULT_SIGBUS; diff --git a/tests/mode/modetest.c b/tests/mode/modetest.c index 1fab0406..99238d5a 100644 --- a/tests/mode/modetest.c +++ b/tests/mode/modetest.c @@ -351,7 +351,7 @@ int main(int argc, char **argv) printf("Starting test\n"); - fd = drmOpenControl(0); + fd = drmOpen("i915", NULL); if (fd < 0) { printf("Failed to open the card fb (%d)\n",fd); -- cgit v1.2.3 From 4403c59b76c55c9c430decac8bc76e4230a253ab Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Fri, 30 May 2008 13:22:51 +1000 Subject: tests: add basic encoder reading to test --- tests/mode/modetest.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'tests') diff --git a/tests/mode/modetest.c b/tests/mode/modetest.c index 99238d5a..eba072ee 100644 --- a/tests/mode/modetest.c +++ b/tests/mode/modetest.c @@ -52,6 +52,7 @@ int printOutput(int fd, drmModeResPtr res, drmModeOutputPtr output, uint32_t id) int i = 0, j; struct drm_mode_modeinfo *mode = NULL; drmModePropertyPtr props; + drmModeEncoderPtr enc; unsigned char *name = NULL; printf("Output: %d-%d\n", output->output_type, output->output_type_id); @@ -65,6 +66,14 @@ int printOutput(int fd, drmModeResPtr res, drmModeOutputPtr output, uint32_t id) printf("\tclones : %i\n", output->clones); printf("\tcount_modes : %i\n", output->count_modes); printf("\tcount_props : %i\n", output->count_props); + printf("\tcount_encs : %i\n", output->count_encoders); + + for (i = 0; i < output->count_encoders; i++) { + enc = drmModeGetEncoder(fd, output->encoders[i]); + if (enc) { + printf("Encoder: %d %d %d %d\n", enc->encoder_id, enc->encoder_type, enc->crtcs, enc->clones); + } + } for (i = 0; i < output->count_props; i++) { props = drmModeGetProperty(fd, output->props[i]); @@ -121,6 +130,16 @@ int printOutput(int fd, drmModeResPtr res, drmModeOutputPtr output, uint32_t id) return 0; } +int printEncoder(int fd, drmModeResPtr res, drmModeEncoderPtr encoder, uint32_t id) +{ + printf("Encoder\n"); + printf("\tid :%i\n", id); + printf("\ttype :%d\n", encoder->encoder_type); + printf("\tcrtcs :%d\n", encoder->crtcs); + printf("\tclones :%d\n", encoder->clones); + return 0; +} + int printCrtc(int fd, drmModeResPtr res, drmModeCrtcPtr crtc, uint32_t id) { printf("Crtc\n"); @@ -158,6 +177,7 @@ int printRes(int fd, drmModeResPtr res) drmModeOutputPtr output; drmModeCrtcPtr crtc; drmModeFBPtr fb; + drmModeEncoderPtr encoder; for (i = 0; i < res->count_outputs; i++) { output = drmModeGetOutput(fd, res->outputs[i]); @@ -170,6 +190,18 @@ int printRes(int fd, drmModeResPtr res) } } + for (i = 0; i < res->count_encoders; i++) { + encoder = drmModeGetEncoder(fd, res->encoders[i]); + + if (!encoder) + printf("Could not get encoder %i\n", i); + else { + printEncoder(fd, res, encoder, res->encoders[i]); + drmModeFreeEncoder(encoder); + } + } + + for (i = 0; i < res->count_crtcs; i++) { crtc = drmModeGetCrtc(fd, res->crtcs[i]); -- cgit v1.2.3 From 9d38448ed33aaff324cc4bbe1e0878593e97d07d Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Fri, 30 May 2008 15:03:12 +1000 Subject: modesetting: the great renaming. Okay we have crtc, encoder and connectors. No more outputs exposed beyond driver internals I've broken intel tv connector stuff. Really for TV we should have one TV connector, with a sub property for the type of signal been driven over it --- libdrm/xf86drmMode.c | 148 ++++++------ libdrm/xf86drmMode.h | 42 ++-- linux-core/drmP.h | 8 +- linux-core/drm_crtc.c | 540 +++++++++++++++++++++---------------------- linux-core/drm_crtc.h | 200 ++++++++-------- linux-core/drm_crtc_helper.c | 186 +++++++-------- linux-core/drm_crtc_helper.h | 22 +- linux-core/drm_drv.c | 4 +- linux-core/drm_edid.c | 94 ++++---- linux-core/drm_modes.c | 14 +- linux-core/drm_sysfs.c | 92 ++++---- linux-core/dvo.h | 2 +- linux-core/dvo_ch7017.c | 4 +- linux-core/dvo_ch7xxx.c | 6 +- linux-core/dvo_ivch.c | 4 +- linux-core/dvo_sil164.c | 6 +- linux-core/dvo_tfp410.c | 8 +- linux-core/intel_crt.c | 91 ++++---- linux-core/intel_display.c | 98 ++++---- linux-core/intel_drv.h | 22 +- linux-core/intel_dvo.c | 123 +++++----- linux-core/intel_fb.c | 34 +-- linux-core/intel_lvds.c | 127 +++++----- linux-core/intel_modes.c | 16 +- linux-core/intel_sdvo.c | 399 ++++++++++++++++---------------- linux-core/intel_tv.c | 173 +++++++------- shared-core/drm.h | 40 ++-- shared-core/i915_irq.c | 46 ++-- tests/mode/modetest.c | 90 ++++---- 29 files changed, 1326 insertions(+), 1313 deletions(-) (limited to 'tests') diff --git a/libdrm/xf86drmMode.c b/libdrm/xf86drmMode.c index 0824ec3f..a18c4290 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; @@ -142,8 +142,8 @@ 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))); @@ -166,18 +166,18 @@ 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; @@ -254,8 +254,8 @@ drmModeCrtcPtr drmModeGetCrtc(int fd, uint32_t crtcId) struct drm_mode_crtc crtc; drmModeCrtcPtr r; - crtc.count_outputs = 0; - crtc.outputs = 0; + crtc.count_connectors = 0; + crtc.connectors = 0; crtc.count_possibles = 0; crtc.possibles = 0; crtc.crtc_id = crtcId; @@ -278,10 +278,10 @@ 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_connectors = crtc.count_connectors; r->count_possibles = crtc.count_possibles; /* TODO we realy should test if these alloc & cpy fails. */ - r->outputs = crtc.outputs; + r->connectors = crtc.connectors; r->possibles = crtc.possibles; return r; @@ -289,13 +289,13 @@ drmModeCrtcPtr drmModeGetCrtc(int fd, uint32_t crtcId) 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; @@ -303,8 +303,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; @@ -370,96 +370,96 @@ drmModeEncoderPtr drmModeGetEncoder(int fd, uint32_t encoder_id) } /* - * Output manipulation + * 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; - out.count_encoders = 0; - out.encoders_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_crtcs = 0; + conn.crtcs = 0; + conn.count_clones = 0; + conn.clones = 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 (out.count_encoders) - out.encoders_ptr = VOID2U64(drmMalloc(out.count_encoders*sizeof(uint32_t))); + 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->crtc = conn.crtc; + r->connection = conn.connection; + r->mmWidth = conn.mm_width; + r->mmHeight = conn.mm_height; + r->subpixel = conn.subpixel; + r->count_crtcs = conn.count_crtcs; + r->count_clones = conn.count_clones; + 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->count_encoders = out.count_encoders; - r->encoders = drmAllocCpy(U642VOID(out.encoders_ptr), out.count_encoders, sizeof(uint32_t)); - r->output_type = out.output_type; - r->output_type_id = out.output_type_id; + r->crtcs = conn.crtcs; + r->clones = conn.clones; + 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(out.encoders_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); } @@ -574,13 +574,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 85e3d912..03268b10 100644 --- a/libdrm/xf86drmMode.h +++ b/libdrm/xf86drmMode.h @@ -60,8 +60,8 @@ 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; @@ -99,11 +99,11 @@ 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 */ @@ -131,12 +131,12 @@ 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 connector_type; + unsigned int connector_type_id; drmModeConnection connection; uint32_t mmWidth, mmHeight; /**< HxW in millimeters */ drmModeSubPixel subpixel; @@ -156,7 +156,7 @@ typedef struct _drmModeOutput { int count_encoders; uint32_t *encoders; /**< List of encoder ids */ -} drmModeOutput, *drmModeOutputPtr; +} drmModeConnector, *drmModeConnectorPtr; @@ -164,7 +164,7 @@ 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 ); /** @@ -217,7 +217,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); /* @@ -240,31 +240,31 @@ int drmModeMoveCursor(int fd, uint32_t crtcId, int x, int y); 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); diff --git a/linux-core/drmP.h b/linux-core/drmP.h index 60ae018e..7c7e201a 100644 --- a/linux-core/drmP.h +++ b/linux-core/drmP.h @@ -743,7 +743,7 @@ struct drm_driver { struct drm_set_version *sv); /* FB routines, if present */ - int (*fb_probe)(struct drm_device *dev, struct drm_crtc *crtc, struct drm_output *output); + int (*fb_probe)(struct drm_device *dev, struct drm_crtc *crtc, struct drm_connector *connector); int (*fb_remove)(struct drm_device *dev, struct drm_framebuffer *fb); int (*fb_resize)(struct drm_device *dev, struct drm_crtc *crtc); @@ -1317,9 +1317,9 @@ extern void drm_sysfs_destroy(void); extern int drm_sysfs_device_add(struct drm_minor *minor); extern void drm_sysfs_hotplug_event(struct drm_device *dev); extern void drm_sysfs_device_remove(struct drm_minor *minor); -extern char *drm_get_output_status_name(enum drm_output_status status); -extern int drm_sysfs_output_add(struct drm_output *output); -extern void drm_sysfs_output_remove(struct drm_output *output); +extern char *drm_get_connector_status_name(enum drm_connector_status status); +extern int drm_sysfs_connector_add(struct drm_connector *connector); +extern void drm_sysfs_connector_remove(struct drm_connector *connector); /* * Basic memory manager support (drm_mm.c) diff --git a/linux-core/drm_crtc.c b/linux-core/drm_crtc.c index bb527413..c60476a4 100644 --- a/linux-core/drm_crtc.c +++ b/linux-core/drm_crtc.c @@ -60,43 +60,43 @@ char *drm_get_dpms_name(int val) return "unknown"; } -static struct drm_prop_enum_list drm_conn_enum_list[] = -{ { ConnectorUnknown, "Unknown" }, - { ConnectorVGA, "VGA" }, - { ConnectorDVII, "DVI-I" }, - { ConnectorDVID, "DVI-D" }, - { ConnectorDVIA, "DVI-A" }, - { ConnectorComposite, "Composite" }, - { ConnectorSVIDEO, "SVIDEO" }, - { ConnectorLVDS, "LVDS" }, - { ConnectorComponent, "Component" }, - { Connector9PinDIN, "9-pin DIN" }, - { ConnectorDisplayPort, "DisplayPort" }, - { ConnectorHDMIA, "HDMI Type A" }, - { ConnectorHDMIB, "HDMI Type B" }, +static struct drm_prop_enum_list drm_connector_enum_list[] = +{ { DRM_MODE_CONNECTOR_Unknown, "Unknown" }, + { DRM_MODE_CONNECTOR_VGA, "VGA" }, + { DRM_MODE_CONNECTOR_DVII, "DVI-I" }, + { DRM_MODE_CONNECTOR_DVID, "DVI-D" }, + { DRM_MODE_CONNECTOR_DVIA, "DVI-A" }, + { DRM_MODE_CONNECTOR_Composite, "Composite" }, + { DRM_MODE_CONNECTOR_SVIDEO, "SVIDEO" }, + { DRM_MODE_CONNECTOR_LVDS, "LVDS" }, + { DRM_MODE_CONNECTOR_Component, "Component" }, + { DRM_MODE_CONNECTOR_9PinDIN, "9-pin DIN" }, + { DRM_MODE_CONNECTOR_DisplayPort, "DisplayPort" }, + { DRM_MODE_CONNECTOR_HDMIA, "HDMI Type A" }, + { DRM_MODE_CONNECTOR_HDMIB, "HDMI Type B" }, }; -static struct drm_prop_enum_list drm_output_enum_list[] = -{ { DRM_MODE_OUTPUT_NONE, "None" }, - { DRM_MODE_OUTPUT_VGA, "VGA" }, - { DRM_MODE_OUTPUT_TMDS, "TMDS" }, - { DRM_MODE_OUTPUT_LVDS, "LVDS" }, - { DRM_MODE_OUTPUT_TVDAC, "TV" }, +static struct drm_prop_enum_list drm_encoder_enum_list[] = +{ { DRM_MODE_ENCODER_NONE, "None" }, + { DRM_MODE_ENCODER_DAC, "DAC" }, + { DRM_MODE_ENCODER_TMDS, "TMDS" }, + { DRM_MODE_ENCODER_LVDS, "LVDS" }, + { DRM_MODE_ENCODER_TVDAC, "TV" }, }; -char *drm_get_output_name(struct drm_output *output) +char *drm_get_connector_name(struct drm_connector *connector) { static char buf[32]; - snprintf(buf, 32, "%s-%d", drm_output_enum_list[output->output_type].name, - output->output_type_id); + snprintf(buf, 32, "%s-%d", drm_connector_enum_list[connector->connector_type].name, + connector->connector_type_id); return buf; } -char *drm_get_output_status_name(enum drm_output_status status) +char *drm_get_connector_status_name(enum drm_connector_status status) { - if (status == output_status_connected) + if (status == connector_status_connected) return "connected"; - else if (status == output_status_disconnected) + else if (status == connector_status_disconnected) return "disconnected"; else return "unknown"; @@ -111,7 +111,7 @@ char *drm_get_output_status_name(enum drm_output_status status) * Caller must hold DRM mode_config lock. * * Create a unique identifier based on @ptr in @dev's identifier space. Used - * for tracking modes, CRTCs and outputs. + * for tracking modes, CRTCs and connectors. * * RETURNS: * New unique (relative to other objects in @dev) integer identifier for the @@ -290,11 +290,11 @@ EXPORT_SYMBOL(drm_crtc_cleanup); */ bool drm_crtc_in_use(struct drm_crtc *crtc) { - struct drm_output *output; + struct drm_connector *connector; struct drm_device *dev = crtc->dev; /* FIXME: Locking around list access? */ - list_for_each_entry(output, &dev->mode_config.output_list, head) - if (output->crtc == crtc) + list_for_each_entry(connector, &dev->mode_config.connector_list, head) + if (connector->crtc == crtc) return true; return false; } @@ -310,7 +310,7 @@ static struct drm_display_mode std_mode[] = { }; /** - * drm_crtc_probe_output_modes - get complete set of display modes + * drm_crtc_probe_connector_modes - get complete set of display modes * @dev: DRM device * @maxX: max width for modes * @maxY: max height for modes @@ -318,8 +318,8 @@ static struct drm_display_mode std_mode[] = { * LOCKING: * Caller must hold mode config lock. * - * Based on @dev's mode_config layout, scan all the outputs and try to detect - * modes on them. Modes will first be added to the output's probed_modes + * Based on @dev's mode_config layout, scan all the connectors and try to detect + * modes on them. Modes will first be added to the connector's probed_modes * list, then culled (based on validity and the @maxX, @maxY parameters) and * put into the normal modes list. * @@ -328,47 +328,47 @@ static struct drm_display_mode std_mode[] = { * * FIXME: take into account monitor limits */ -void drm_crtc_probe_single_output_modes(struct drm_output *output, int maxX, int maxY) +void drm_crtc_probe_single_connector_modes(struct drm_connector *connector, int maxX, int maxY) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; struct drm_display_mode *mode, *t; int ret; //if (maxX == 0 || maxY == 0) // TODO /* set all modes to the unverified state */ - list_for_each_entry_safe(mode, t, &output->modes, head) + list_for_each_entry_safe(mode, t, &connector->modes, head) mode->status = MODE_UNVERIFIED; - output->status = (*output->funcs->detect)(output); + connector->status = (*connector->funcs->detect)(connector); - if (output->status == output_status_disconnected) { - DRM_DEBUG("%s is disconnected\n", drm_get_output_name(output)); + if (connector->status == connector_status_disconnected) { + DRM_DEBUG("%s is disconnected\n", drm_get_connector_name(connector)); /* TODO set EDID to NULL */ return; } - ret = (*output->funcs->get_modes)(output); + ret = (*connector->funcs->get_modes)(connector); if (ret) { - drm_mode_output_list_update(output); + drm_mode_connector_list_update(connector); } if (maxX && maxY) - drm_mode_validate_size(dev, &output->modes, maxX, + drm_mode_validate_size(dev, &connector->modes, maxX, maxY, 0); - list_for_each_entry_safe(mode, t, &output->modes, head) { + list_for_each_entry_safe(mode, t, &connector->modes, head) { if (mode->status == MODE_OK) - mode->status = (*output->funcs->mode_valid)(output,mode); + mode->status = (*connector->funcs->mode_valid)(connector,mode); } - drm_mode_prune_invalid(dev, &output->modes, TRUE); + drm_mode_prune_invalid(dev, &connector->modes, TRUE); - if (list_empty(&output->modes)) { + if (list_empty(&connector->modes)) { struct drm_display_mode *stdmode; - DRM_DEBUG("No valid modes on %s\n", drm_get_output_name(output)); + DRM_DEBUG("No valid modes on %s\n", drm_get_connector_name(connector)); /* Should we do this here ??? * When no valid EDID modes are available we end up @@ -376,18 +376,18 @@ void drm_crtc_probe_single_output_modes(struct drm_output *output, int maxX, int * 640x480@60Hz mode and carry on. */ stdmode = drm_mode_duplicate(dev, &std_mode[0]); - drm_mode_probed_add(output, stdmode); - drm_mode_list_concat(&output->probed_modes, - &output->modes); + drm_mode_probed_add(connector, stdmode); + drm_mode_list_concat(&connector->probed_modes, + &connector->modes); DRM_DEBUG("Adding standard 640x480 @ 60Hz to %s\n", - drm_get_output_name(output)); + drm_get_connector_name(connector)); } - drm_mode_sort(&output->modes); + drm_mode_sort(&connector->modes); - DRM_DEBUG("Probed modes for %s\n", drm_get_output_name(output)); - list_for_each_entry_safe(mode, t, &output->modes, head) { + DRM_DEBUG("Probed modes for %s\n", drm_get_connector_name(connector)); + list_for_each_entry_safe(mode, t, &connector->modes, head) { mode->vrefresh = drm_mode_vrefresh(mode); drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V); @@ -395,15 +395,15 @@ void drm_crtc_probe_single_output_modes(struct drm_output *output, int maxX, int } } -void drm_crtc_probe_output_modes(struct drm_device *dev, int maxX, int maxY) +void drm_crtc_probe_connector_modes(struct drm_device *dev, int maxX, int maxY) { - struct drm_output *output; + struct drm_connector *connector; - list_for_each_entry(output, &dev->mode_config.output_list, head) { - drm_crtc_probe_single_output_modes(output, maxX, maxY); + list_for_each_entry(connector, &dev->mode_config.connector_list, head) { + drm_crtc_probe_single_connector_modes(connector, maxX, maxY); } } -EXPORT_SYMBOL(drm_crtc_probe_output_modes); +EXPORT_SYMBOL(drm_crtc_probe_connector_modes); /** @@ -413,17 +413,17 @@ EXPORT_SYMBOL(drm_crtc_probe_output_modes); * LOCKING: * Caller must hold mode config lock. * - * If an output or CRTC isn't part of @dev's mode_config, it can be disabled + * If an connector or CRTC isn't part of @dev's mode_config, it can be disabled * by calling its dpms function, which should power it off. */ void drm_disable_unused_functions(struct drm_device *dev) { - struct drm_output *output; + struct drm_connector *connector; struct drm_crtc *crtc; - list_for_each_entry(output, &dev->mode_config.output_list, head) { - if (!output->crtc) - (*output->funcs->dpms)(output, DPMSModeOff); + list_for_each_entry(connector, &dev->mode_config.connector_list, head) { + if (!connector->crtc) + (*connector->funcs->dpms)(connector, DPMSModeOff); } list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { @@ -434,33 +434,33 @@ void drm_disable_unused_functions(struct drm_device *dev) EXPORT_SYMBOL(drm_disable_unused_functions); /** - * drm_mode_probed_add - add a mode to the specified output's probed mode list - * @output: output the new mode + * drm_mode_probed_add - add a mode to the specified connector's probed mode list + * @connector: connector the new mode * @mode: mode data * * LOCKING: * Caller must hold mode config lock. * - * Add @mode to @output's mode list for later use. + * Add @mode to @connector's mode list for later use. */ -void drm_mode_probed_add(struct drm_output *output, +void drm_mode_probed_add(struct drm_connector *connector, struct drm_display_mode *mode) { - list_add(&mode->head, &output->probed_modes); + list_add(&mode->head, &connector->probed_modes); } EXPORT_SYMBOL(drm_mode_probed_add); /** * drm_mode_remove - remove and free a mode - * @output: output list to modify + * @connector: connector list to modify * @mode: mode to remove * * LOCKING: * Caller must hold mode config lock. * - * Remove @mode from @output's mode list, then free it. + * Remove @mode from @connector's mode list, then free it. */ -void drm_mode_remove(struct drm_output *output, struct drm_display_mode *mode) +void drm_mode_remove(struct drm_connector *connector, struct drm_display_mode *mode) { list_del(&mode->head); kfree(mode); @@ -468,76 +468,76 @@ void drm_mode_remove(struct drm_output *output, struct drm_display_mode *mode) EXPORT_SYMBOL(drm_mode_remove); /** - * drm_output_init - Init a preallocated output + * drm_connector_init - Init a preallocated connector * @dev: DRM device - * @output: the output to init - * @funcs: callbacks for this output - * @name: user visible name of the output + * @connector: the connector to init + * @funcs: callbacks for this connector + * @name: user visible name of the connector * * LOCKING: * Caller must hold @dev's mode_config lock. * - * Initialises a preallocated output. Outputs should be - * subclassed as part of driver output objects. + * Initialises a preallocated connector. Connectors should be + * subclassed as part of driver connector objects. */ -void drm_output_init(struct drm_device *dev, - struct drm_output *output, - const struct drm_output_funcs *funcs, - int output_type) +void drm_connector_init(struct drm_device *dev, + struct drm_connector *connector, + const struct drm_connector_funcs *funcs, + int connector_type) { - output->dev = dev; - output->funcs = funcs; - output->id = drm_idr_get(dev, output); - output->output_type = output_type; - output->output_type_id = 1; /* TODO */ - INIT_LIST_HEAD(&output->user_modes); - INIT_LIST_HEAD(&output->probed_modes); - INIT_LIST_HEAD(&output->modes); - /* randr_output? */ - /* output_set_monitor(output)? */ - /* check for output_ignored(output)? */ + connector->dev = dev; + connector->funcs = funcs; + connector->id = drm_idr_get(dev, connector); + connector->connector_type = connector_type; + connector->connector_type_id = 1; /* TODO */ + INIT_LIST_HEAD(&connector->user_modes); + INIT_LIST_HEAD(&connector->probed_modes); + INIT_LIST_HEAD(&connector->modes); + /* randr_connector? */ + /* connector_set_monitor(connector)? */ + /* check for connector_ignored(connector)? */ mutex_lock(&dev->mode_config.mutex); - list_add_tail(&output->head, &dev->mode_config.output_list); - dev->mode_config.num_output++; + list_add_tail(&connector->head, &dev->mode_config.connector_list); + dev->mode_config.num_connector++; - drm_output_attach_property(output, dev->mode_config.edid_property, 0); + drm_connector_attach_property(connector, dev->mode_config.edid_property, 0); - drm_output_attach_property(output, dev->mode_config.dpms_property, 0); + drm_connector_attach_property(connector, dev->mode_config.dpms_property, 0); mutex_unlock(&dev->mode_config.mutex); } -EXPORT_SYMBOL(drm_output_init); +EXPORT_SYMBOL(drm_connector_init); /** - * drm_output_cleanup - cleans up an initialised output - * @output: output to cleanup + * drm_connector_cleanup - cleans up an initialised connector + * @connector: connector to cleanup * * LOCKING: * Caller must hold @dev's mode_config lock. * - * Cleans up the output but doesn't free the object. + * Cleans up the connector but doesn't free the object. */ -void drm_output_cleanup(struct drm_output *output) +void drm_connector_cleanup(struct drm_connector *connector) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; struct drm_display_mode *mode, *t; - list_for_each_entry_safe(mode, t, &output->probed_modes, head) - drm_mode_remove(output, mode); + list_for_each_entry_safe(mode, t, &connector->probed_modes, head) + drm_mode_remove(connector, mode); - list_for_each_entry_safe(mode, t, &output->modes, head) - drm_mode_remove(output, mode); + list_for_each_entry_safe(mode, t, &connector->modes, head) + drm_mode_remove(connector, mode); - list_for_each_entry_safe(mode, t, &output->user_modes, head) - drm_mode_remove(output, mode); + list_for_each_entry_safe(mode, t, &connector->user_modes, head) + drm_mode_remove(connector, mode); mutex_lock(&dev->mode_config.mutex); - drm_idr_put(dev, output->id); - list_del(&output->head); + drm_idr_put(dev, connector->id); + list_del(&connector->head); mutex_unlock(&dev->mode_config.mutex); } -EXPORT_SYMBOL(drm_output_cleanup); +EXPORT_SYMBOL(drm_connector_cleanup); void drm_encoder_init(struct drm_device *dev, struct drm_encoder *encoder, @@ -610,12 +610,12 @@ void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode) } EXPORT_SYMBOL(drm_mode_destroy); -static int drm_mode_create_standard_output_properties(struct drm_device *dev) +static int drm_mode_create_standard_connector_properties(struct drm_device *dev) { int i; /* - * Standard properties (apply to all outputs) + * Standard properties (apply to all connectors) */ dev->mode_config.edid_property = drm_property_create(dev, DRM_MODE_PROP_BLOB | DRM_MODE_PROP_IMMUTABLE, @@ -627,29 +627,17 @@ static int drm_mode_create_standard_output_properties(struct drm_device *dev) for (i = 0; i < ARRAY_SIZE(drm_dpms_enum_list); i++) drm_property_add_enum(dev->mode_config.dpms_property, i, drm_dpms_enum_list[i].type, drm_dpms_enum_list[i].name); - dev->mode_config.connector_type_property = - drm_property_create(dev, DRM_MODE_PROP_ENUM | DRM_MODE_PROP_IMMUTABLE, - "Connector Type", ARRAY_SIZE(drm_conn_enum_list)); - for (i = 0; i < ARRAY_SIZE(drm_conn_enum_list); i++) - drm_property_add_enum(dev->mode_config.connector_type_property, i, drm_conn_enum_list[i].type, drm_conn_enum_list[i].name); - - dev->mode_config.connector_num_property = - drm_property_create(dev, DRM_MODE_PROP_RANGE | DRM_MODE_PROP_IMMUTABLE, - "Connector ID", 2); - dev->mode_config.connector_num_property->values[0] = 0; - dev->mode_config.connector_num_property->values[1] = 20; - return 0; } /** - * drm_create_tv_properties - create TV specific output properties + * drm_create_tv_properties - create TV specific connector properties * @dev: DRM device * @num_modes: number of different TV formats (modes) supported * @modes: array of pointers to strings containing name of each format * * Called by a driver's TV initialization routine, this function creates - * the TV specific output properties for a given device. Caller is + * the TV specific connector properties for a given device. Caller is * responsible for allocating a list of format names and passing them to * this routine. */ @@ -709,17 +697,17 @@ void drm_mode_config_init(struct drm_device *dev) mutex_init(&dev->mode_config.mutex); INIT_LIST_HEAD(&dev->mode_config.fb_list); INIT_LIST_HEAD(&dev->mode_config.crtc_list); - INIT_LIST_HEAD(&dev->mode_config.output_list); + INIT_LIST_HEAD(&dev->mode_config.connector_list); INIT_LIST_HEAD(&dev->mode_config.encoder_list); INIT_LIST_HEAD(&dev->mode_config.property_list); INIT_LIST_HEAD(&dev->mode_config.property_blob_list); idr_init(&dev->mode_config.crtc_idr); - drm_mode_create_standard_output_properties(dev); + drm_mode_create_standard_connector_properties(dev); /* Just to be sure */ dev->mode_config.num_fb = 0; - dev->mode_config.num_output = 0; + dev->mode_config.num_connector = 0; dev->mode_config.num_crtc = 0; dev->mode_config.num_encoder = 0; dev->mode_config.hotplug_counter = 0; @@ -780,14 +768,14 @@ out_err: * LOCKING: * Caller must hold mode config lock. * - * Free up all the outputs and CRTCs associated with this DRM device, then + * Free up all the connectors and CRTCs associated with this DRM device, then * free up the framebuffers and associated buffer objects. * * FIXME: cleanup any dangling user buffer objects too */ void drm_mode_config_cleanup(struct drm_device *dev) { - struct drm_output *output, *ot; + struct drm_connector *connector, *ot; struct drm_crtc *crtc, *ct; struct drm_encoder *encoder, *enct; struct drm_framebuffer *fb, *fbt; @@ -797,9 +785,9 @@ void drm_mode_config_cleanup(struct drm_device *dev) encoder->funcs->destroy(encoder); } - list_for_each_entry_safe(output, ot, &dev->mode_config.output_list, head) { - drm_sysfs_output_remove(output); - output->funcs->destroy(output); + list_for_each_entry_safe(connector, ot, &dev->mode_config.connector_list, head) { + drm_sysfs_connector_remove(connector); + connector->funcs->destroy(connector); } list_for_each_entry_safe(property, pt, &dev->mode_config.property_list, head) { @@ -906,7 +894,7 @@ void drm_crtc_convert_umode(struct drm_display_mode *out, struct drm_mode_modein * Takes mode config lock. * * Construct a set of configuration description structures and return - * them to the user, including CRTC, output and framebuffer configuration. + * them to the user, including CRTC, connector and framebuffer configuration. * * Called by the user via ioctl. * @@ -919,18 +907,18 @@ int drm_mode_getresources(struct drm_device *dev, struct drm_mode_card_res *card_res = data; struct list_head *lh; struct drm_framebuffer *fb; - struct drm_output *output; + struct drm_connector *connector; struct drm_crtc *crtc; struct drm_encoder *encoder; int ret = 0; - int output_count = 0; + int connector_count = 0; int crtc_count = 0; int fb_count = 0; int encoder_count = 0; int copied = 0; uint32_t __user *fb_id; uint32_t __user *crtc_id; - uint32_t __user *output_id; + uint32_t __user *connector_id; uint32_t __user *encoder_id; mutex_lock(&dev->mode_config.mutex); @@ -941,8 +929,8 @@ int drm_mode_getresources(struct drm_device *dev, list_for_each(lh, &dev->mode_config.crtc_list) crtc_count++; - list_for_each(lh, &dev->mode_config.output_list) - output_count++; + list_for_each(lh, &dev->mode_config.connector_list) + connector_count++; list_for_each(lh, &dev->mode_config.encoder_list) encoder_count++; @@ -983,21 +971,21 @@ int drm_mode_getresources(struct drm_device *dev, card_res->count_crtcs = crtc_count; - /* Outputs */ - if (card_res->count_outputs >= output_count) { + /* Connectors */ + if (card_res->count_connectors >= connector_count) { copied = 0; - output_id = (uint32_t *)(unsigned long)card_res->output_id_ptr; - list_for_each_entry(output, &dev->mode_config.output_list, + connector_id = (uint32_t *)(unsigned long)card_res->connector_id_ptr; + list_for_each_entry(connector, &dev->mode_config.connector_list, head) { - DRM_DEBUG("OUTPUT ID is %d\n", output->id); - if (put_user(output->id, output_id + copied)) { + DRM_DEBUG("CONNECTOR ID is %d\n", connector->id); + if (put_user(connector->id, connector_id + copied)) { ret = -EFAULT; goto out; } copied++; } } - card_res->count_outputs = output_count; + card_res->count_connectors = connector_count; /* Encoders */ if (card_res->count_encoders >= encoder_count) { @@ -1016,7 +1004,7 @@ int drm_mode_getresources(struct drm_device *dev, card_res->count_encoders = encoder_count; DRM_DEBUG("Counted %d %d %d\n", card_res->count_crtcs, - card_res->count_outputs, card_res->count_encoders); + card_res->count_connectors, card_res->count_encoders); out: mutex_unlock(&dev->mode_config.mutex); @@ -1045,7 +1033,7 @@ int drm_mode_getcrtc(struct drm_device *dev, { struct drm_mode_crtc *crtc_resp = data; struct drm_crtc *crtc; - struct drm_output *output; + struct drm_connector *connector; int ocount; int ret = 0; @@ -1064,15 +1052,15 @@ int drm_mode_getcrtc(struct drm_device *dev, else crtc_resp->fb_id = 0; - crtc_resp->outputs = 0; + crtc_resp->connectors = 0; if (crtc->enabled) { drm_crtc_convert_to_umode(&crtc_resp->mode, &crtc->mode); crtc_resp->mode_valid = 1; ocount = 0; - list_for_each_entry(output, &dev->mode_config.output_list, head) { - if (output->crtc == crtc) - crtc_resp->outputs |= 1 << (ocount++); + list_for_each_entry(connector, &dev->mode_config.connector_list, head) { + if (connector->crtc == crtc) + crtc_resp->connectors |= 1 << (ocount++); } } else { @@ -1085,7 +1073,7 @@ out: } /** - * drm_mode_getoutput - get output configuration + * drm_mode_getconnector - get connector configuration * @inode: inode from the ioctl * @filp: file * from the ioctl * @cmd: cmd from ioctl @@ -1094,18 +1082,18 @@ out: * LOCKING: * Caller? (FIXME) * - * Construct a output configuration structure to return to the user. + * Construct a connector configuration structure to return to the user. * * Called by the user via ioctl. * * RETURNS: * Zero on success, errno on failure. */ -int drm_mode_getoutput(struct drm_device *dev, +int drm_mode_getconnector(struct drm_device *dev, void *data, struct drm_file *file_priv) { - struct drm_mode_get_output *out_resp = data; - struct drm_output *output; + struct drm_mode_get_connector *out_resp = data; + struct drm_connector *connector; struct drm_display_mode *mode; int mode_count = 0; int props_count = 0; @@ -1121,52 +1109,52 @@ int drm_mode_getoutput(struct drm_device *dev, memset(&u_mode, 0, sizeof(struct drm_mode_modeinfo)); - DRM_DEBUG("output id %d:\n", out_resp->output); + DRM_DEBUG("connector id %d:\n", out_resp->connector); mutex_lock(&dev->mode_config.mutex); - output= idr_find(&dev->mode_config.crtc_idr, out_resp->output); - if (!output || (output->id != out_resp->output)) { + connector= idr_find(&dev->mode_config.crtc_idr, out_resp->connector); + if (!connector || (connector->id != out_resp->connector)) { ret = -EINVAL; goto out; } - list_for_each_entry(mode, &output->modes, head) + list_for_each_entry(mode, &connector->modes, head) mode_count++; - for (i = 0; i < DRM_OUTPUT_MAX_PROPERTY; i++) { - if (output->property_ids[i] != 0) { + for (i = 0; i < DRM_CONNECTOR_MAX_PROPERTY; i++) { + if (connector->property_ids[i] != 0) { props_count++; } } - for (i = 0; i < DRM_OUTPUT_MAX_ENCODER; i++) { - if (output->encoder_ids[i] != 0) { + for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { + if (connector->encoder_ids[i] != 0) { encoders_count++; } } if (out_resp->count_modes == 0) { - drm_crtc_probe_single_output_modes(output, dev->mode_config.max_width, dev->mode_config.max_height); + drm_crtc_probe_single_connector_modes(connector, dev->mode_config.max_width, dev->mode_config.max_height); } - out_resp->output_type = output->output_type; - out_resp->output_type_id = output->output_type_id; - out_resp->mm_width = output->display_info.width_mm; - out_resp->mm_height = output->display_info.height_mm; - out_resp->subpixel = output->display_info.subpixel_order; - out_resp->connection = output->status; - if (output->crtc) - out_resp->crtc = output->crtc->id; + out_resp->connector_type = connector->connector_type; + out_resp->connector_type_id = connector->connector_type_id; + out_resp->mm_width = connector->display_info.width_mm; + out_resp->mm_height = connector->display_info.height_mm; + out_resp->subpixel = connector->display_info.subpixel_order; + out_resp->connection = connector->status; + if (connector->crtc) + out_resp->crtc = connector->crtc->id; else out_resp->crtc = 0; - out_resp->crtcs = output->possible_crtcs; - out_resp->clones = output->possible_clones; + out_resp->crtcs = connector->possible_crtcs; + out_resp->clones = connector->possible_clones; if ((out_resp->count_modes >= mode_count) && mode_count) { copied = 0; mode_ptr = (struct drm_mode_modeinfo *)(unsigned long)out_resp->modes_ptr; - list_for_each_entry(mode, &output->modes, head) { + list_for_each_entry(mode, &connector->modes, head) { drm_crtc_convert_to_umode(&u_mode, mode); if (copy_to_user(mode_ptr + copied, &u_mode, sizeof(u_mode))) { @@ -1183,14 +1171,14 @@ int drm_mode_getoutput(struct drm_device *dev, copied = 0; prop_ptr = (uint32_t *)(unsigned long)(out_resp->props_ptr); prop_values = (uint64_t *)(unsigned long)(out_resp->prop_values_ptr); - for (i = 0; i < DRM_OUTPUT_MAX_PROPERTY; i++) { - if (output->property_ids[i] != 0) { - if (put_user(output->property_ids[i], prop_ptr + copied)) { + for (i = 0; i < DRM_CONNECTOR_MAX_PROPERTY; i++) { + if (connector->property_ids[i] != 0) { + if (put_user(connector->property_ids[i], prop_ptr + copied)) { ret = -EFAULT; goto out; } - if (put_user(output->property_values[i], prop_values + copied)) { + if (put_user(connector->property_values[i], prop_values + copied)) { ret = -EFAULT; goto out; } @@ -1203,9 +1191,9 @@ int drm_mode_getoutput(struct drm_device *dev, if ((out_resp->count_encoders >= encoders_count) && encoders_count) { copied = 0; encoder_ptr = (uint32_t *)(unsigned long)(out_resp->encoders_ptr); - for (i = 0; i < DRM_OUTPUT_MAX_ENCODER; i++) { - if (output->encoder_ids[i] != 0) { - if (put_user(output->encoder_ids[i], encoder_ptr + copied)) { + for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { + if (connector->encoder_ids[i] != 0) { + if (put_user(connector->encoder_ids[i], encoder_ptr + copied)) { ret = -EFAULT; goto out; } @@ -1267,11 +1255,11 @@ int drm_mode_setcrtc(struct drm_device *dev, { struct drm_mode_crtc *crtc_req = data; struct drm_crtc *crtc, *crtcfb; - struct drm_output **output_set = NULL, *output; + struct drm_connector **connector_set = NULL, *connector; struct drm_framebuffer *fb = NULL; struct drm_display_mode *mode = NULL; struct drm_mode_set set; - uint32_t __user *set_outputs_ptr; + uint32_t __user *set_connectors_ptr; int ret = 0; int i; @@ -1307,43 +1295,43 @@ int drm_mode_setcrtc(struct drm_device *dev, drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V); } - if (crtc_req->count_outputs == 0 && mode) { - DRM_DEBUG("Count outputs is 0 but mode set\n"); + if (crtc_req->count_connectors == 0 && mode) { + DRM_DEBUG("Count connectors is 0 but mode set\n"); ret = -EINVAL; goto out; } - if (crtc_req->count_outputs > 0 && !mode && !fb) { - DRM_DEBUG("Count outputs is %d but no mode or fb set\n", crtc_req->count_outputs); + if (crtc_req->count_connectors > 0 && !mode && !fb) { + DRM_DEBUG("Count connectors is %d but no mode or fb set\n", crtc_req->count_connectors); ret = -EINVAL; goto out; } - if (crtc_req->count_outputs > 0) { + if (crtc_req->count_connectors > 0) { u32 out_id; - /* Maybe we should check that count_outputs is a sensible value. */ - output_set = kmalloc(crtc_req->count_outputs * - sizeof(struct drm_output *), GFP_KERNEL); - if (!output_set) { + /* Maybe we should check that count_connectors is a sensible value. */ + connector_set = kmalloc(crtc_req->count_connectors * + sizeof(struct drm_connector *), GFP_KERNEL); + if (!connector_set) { ret = -ENOMEM; goto out; } - for (i = 0; i < crtc_req->count_outputs; i++) { - set_outputs_ptr = (uint32_t *)(unsigned long)crtc_req->set_outputs_ptr; - if (get_user(out_id, &set_outputs_ptr[i])) { + for (i = 0; i < crtc_req->count_connectors; i++) { + set_connectors_ptr = (uint32_t *)(unsigned long)crtc_req->set_connectors_ptr; + if (get_user(out_id, &set_connectors_ptr[i])) { ret = -EFAULT; goto out; } - output = idr_find(&dev->mode_config.crtc_idr, out_id); - if (!output || (out_id != output->id)) { - DRM_DEBUG("Output id %d unknown\n", out_id); + connector = idr_find(&dev->mode_config.crtc_idr, out_id); + if (!connector || (out_id != connector->id)) { + DRM_DEBUG("Connector id %d unknown\n", out_id); ret = -EINVAL; goto out; } - output_set[i] = output; + connector_set[i] = connector; } } @@ -1351,13 +1339,13 @@ int drm_mode_setcrtc(struct drm_device *dev, set.x = crtc_req->x; set.y = crtc_req->y; set.mode = mode; - set.outputs = output_set; - set.num_outputs = crtc_req->count_outputs; + set.connectors = connector_set; + set.num_connectors = crtc_req->count_connectors; set.fb =fb; ret = crtc->funcs->set_config(&set); out: - kfree(output_set); + kfree(connector_set); mutex_unlock(&dev->mode_config.mutex); return ret; } @@ -1628,29 +1616,29 @@ void drm_fb_release(struct file *filp) */ static int drm_mode_attachmode(struct drm_device *dev, - struct drm_output *output, + struct drm_connector *connector, struct drm_display_mode *mode) { int ret = 0; - list_add_tail(&mode->head, &output->user_modes); + list_add_tail(&mode->head, &connector->user_modes); return ret; } int drm_mode_attachmode_crtc(struct drm_device *dev, struct drm_crtc *crtc, struct drm_display_mode *mode) { - struct drm_output *output; + struct drm_connector *connector; int ret = 0; struct drm_display_mode *dup_mode; int need_dup = 0; - list_for_each_entry(output, &dev->mode_config.output_list, head) { - if (output->crtc == crtc) { + list_for_each_entry(connector, &dev->mode_config.connector_list, head) { + if (connector->crtc == crtc) { if (need_dup) dup_mode = drm_mode_duplicate(dev, mode); else dup_mode = mode; - ret = drm_mode_attachmode(dev, output, dup_mode); + ret = drm_mode_attachmode(dev, connector, dup_mode); if (ret) return ret; need_dup = 1; @@ -1661,14 +1649,14 @@ int drm_mode_attachmode_crtc(struct drm_device *dev, struct drm_crtc *crtc, EXPORT_SYMBOL(drm_mode_attachmode_crtc); static int drm_mode_detachmode(struct drm_device *dev, - struct drm_output *output, + struct drm_connector *connector, struct drm_display_mode *mode) { int found = 0; int ret = 0; struct drm_display_mode *match_mode, *t; - list_for_each_entry_safe(match_mode, t, &output->user_modes, head) { + list_for_each_entry_safe(match_mode, t, &connector->user_modes, head) { if (drm_mode_equal(match_mode, mode)) { list_del(&match_mode->head); drm_mode_destroy(dev, match_mode); @@ -1685,23 +1673,23 @@ static int drm_mode_detachmode(struct drm_device *dev, int drm_mode_detachmode_crtc(struct drm_device *dev, struct drm_display_mode *mode) { - struct drm_output *output; + struct drm_connector *connector; - list_for_each_entry(output, &dev->mode_config.output_list, head) { - drm_mode_detachmode(dev, output, mode); + list_for_each_entry(connector, &dev->mode_config.connector_list, head) { + drm_mode_detachmode(dev, connector, mode); } return 0; } EXPORT_SYMBOL(drm_mode_detachmode_crtc); /** - * drm_fb_attachmode - Attach a user mode to an output + * drm_fb_attachmode - Attach a user mode to an connector * @inode: inode from the ioctl * @filp: file * from the ioctl * @cmd: cmd from ioctl * @arg: arg from ioctl * - * This attaches a user specified mode to an output. + * This attaches a user specified mode to an connector. * Called by the user via ioctl. * * RETURNS: @@ -1711,15 +1699,15 @@ int drm_mode_attachmode_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) { struct drm_mode_mode_cmd *mode_cmd = data; - struct drm_output *output; + struct drm_connector *connector; struct drm_display_mode *mode; struct drm_mode_modeinfo *umode = &mode_cmd->mode; int ret = 0; mutex_lock(&dev->mode_config.mutex); - output = idr_find(&dev->mode_config.crtc_idr, mode_cmd->output_id); - if (!output || (output->id != mode_cmd->output_id)) { + connector = idr_find(&dev->mode_config.crtc_idr, mode_cmd->connector_id); + if (!connector || (connector->id != mode_cmd->connector_id)) { ret = -EINVAL; goto out; } @@ -1732,7 +1720,7 @@ int drm_mode_attachmode_ioctl(struct drm_device *dev, drm_crtc_convert_umode(mode, umode); - ret = drm_mode_attachmode(dev, output, mode); + ret = drm_mode_attachmode(dev, connector, mode); out: mutex_unlock(&dev->mode_config.mutex); return ret; @@ -1740,7 +1728,7 @@ out: /** - * drm_fb_detachmode - Detach a user specified mode from an output + * drm_fb_detachmode - Detach a user specified mode from an connector * @inode: inode from the ioctl * @filp: file * from the ioctl * @cmd: cmd from ioctl @@ -1755,21 +1743,21 @@ int drm_mode_detachmode_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) { struct drm_mode_mode_cmd *mode_cmd = data; - struct drm_output *output; + struct drm_connector *connector; struct drm_display_mode mode; struct drm_mode_modeinfo *umode = &mode_cmd->mode; int ret = 0; mutex_lock(&dev->mode_config.mutex); - output = idr_find(&dev->mode_config.crtc_idr, mode_cmd->output_id); - if (!output || (output->id != mode_cmd->output_id)) { + connector = idr_find(&dev->mode_config.crtc_idr, mode_cmd->connector_id); + if (!connector || (connector->id != mode_cmd->connector_id)) { ret = -EINVAL; goto out; } drm_crtc_convert_umode(&mode, umode); - ret = drm_mode_detachmode(dev, output, &mode); + ret = drm_mode_detachmode(dev, connector, &mode); out: mutex_unlock(&dev->mode_config.mutex); return ret; @@ -1855,60 +1843,60 @@ void drm_property_destroy(struct drm_device *dev, struct drm_property *property) } EXPORT_SYMBOL(drm_property_destroy); -int drm_output_attach_property(struct drm_output *output, +int drm_connector_attach_property(struct drm_connector *connector, struct drm_property *property, uint64_t init_val) { int i; - for (i = 0; i < DRM_OUTPUT_MAX_PROPERTY; i++) { - if (output->property_ids[i] == 0) { - output->property_ids[i] = property->id; - output->property_values[i] = init_val; + for (i = 0; i < DRM_CONNECTOR_MAX_PROPERTY; i++) { + if (connector->property_ids[i] == 0) { + connector->property_ids[i] = property->id; + connector->property_values[i] = init_val; break; } } - if (i == DRM_OUTPUT_MAX_PROPERTY) + if (i == DRM_CONNECTOR_MAX_PROPERTY) return -EINVAL; return 0; } -EXPORT_SYMBOL(drm_output_attach_property); +EXPORT_SYMBOL(drm_connector_attach_property); -int drm_output_property_set_value(struct drm_output *output, +int drm_connector_property_set_value(struct drm_connector *connector, struct drm_property *property, uint64_t value) { int i; - for (i = 0; i < DRM_OUTPUT_MAX_PROPERTY; i++) { - if (output->property_ids[i] == property->id) { - output->property_values[i] = value; + for (i = 0; i < DRM_CONNECTOR_MAX_PROPERTY; i++) { + if (connector->property_ids[i] == property->id) { + connector->property_values[i] = value; break; } } - if (i == DRM_OUTPUT_MAX_PROPERTY) + if (i == DRM_CONNECTOR_MAX_PROPERTY) return -EINVAL; return 0; } -EXPORT_SYMBOL(drm_output_property_set_value); +EXPORT_SYMBOL(drm_connector_property_set_value); -int drm_output_property_get_value(struct drm_output *output, +int drm_connector_property_get_value(struct drm_connector *connector, struct drm_property *property, uint64_t *val) { int i; - for (i = 0; i < DRM_OUTPUT_MAX_PROPERTY; i++) { - if (output->property_ids[i] == property->id) { - *val = output->property_values[i]; + for (i = 0; i < DRM_CONNECTOR_MAX_PROPERTY; i++) { + if (connector->property_ids[i] == property->id) { + *val = connector->property_values[i]; break; } } - if (i == DRM_OUTPUT_MAX_PROPERTY) + if (i == DRM_CONNECTOR_MAX_PROPERTY) return -EINVAL; return 0; } -EXPORT_SYMBOL(drm_output_property_get_value); +EXPORT_SYMBOL(drm_connector_property_get_value); int drm_mode_getproperty_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) @@ -2070,41 +2058,41 @@ done: return ret; } -int drm_mode_output_update_edid_property(struct drm_output *output, struct edid *edid) +int drm_mode_connector_update_edid_property(struct drm_connector *connector, struct edid *edid) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; int ret = 0; - if (output->edid_blob_ptr) - drm_property_destroy_blob(dev, output->edid_blob_ptr); + if (connector->edid_blob_ptr) + drm_property_destroy_blob(dev, connector->edid_blob_ptr); - output->edid_blob_ptr = drm_property_create_blob(output->dev, 128, edid); + connector->edid_blob_ptr = drm_property_create_blob(connector->dev, 128, edid); - ret = drm_output_property_set_value(output, dev->mode_config.edid_property, output->edid_blob_ptr->id); + ret = drm_connector_property_set_value(connector, dev->mode_config.edid_property, connector->edid_blob_ptr->id); return ret; } -EXPORT_SYMBOL(drm_mode_output_update_edid_property); +EXPORT_SYMBOL(drm_mode_connector_update_edid_property); -int drm_mode_output_property_set_ioctl(struct drm_device *dev, +int drm_mode_connector_property_set_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) { - struct drm_mode_output_set_property *out_resp = data; + struct drm_mode_connector_set_property *out_resp = data; struct drm_property *property; - struct drm_output *output; + struct drm_connector *connector; int ret = -EINVAL; int i; mutex_lock(&dev->mode_config.mutex); - output = idr_find(&dev->mode_config.crtc_idr, out_resp->output_id); - if (!output || (output->id != out_resp->output_id)) { + connector = idr_find(&dev->mode_config.crtc_idr, out_resp->connector_id); + if (!connector || (connector->id != out_resp->connector_id)) { goto out; } - for (i = 0; i < DRM_OUTPUT_MAX_PROPERTY; i++) { - if (output->property_ids[i] == out_resp->prop_id) + for (i = 0; i < DRM_CONNECTOR_MAX_PROPERTY; i++) { + if (connector->property_ids[i] == out_resp->prop_id) break; } - if (i == DRM_OUTPUT_MAX_PROPERTY) { + if (i == DRM_CONNECTOR_MAX_PROPERTY) { goto out; } @@ -2135,8 +2123,8 @@ int drm_mode_output_property_set_ioctl(struct drm_device *dev, } } - if (output->funcs->set_property) - ret = output->funcs->set_property(output, property, out_resp->value); + if (connector->funcs->set_property) + ret = connector->funcs->set_property(connector, property, out_resp->value); out: mutex_unlock(&dev->mode_config.mutex); @@ -2205,30 +2193,30 @@ out: } -int drm_mode_output_attach_encoder(struct drm_output *output, +int drm_mode_connector_attach_encoder(struct drm_connector *connector, struct drm_encoder *encoder) { int i; - for (i = 0; i < DRM_OUTPUT_MAX_ENCODER; i++) { - if (output->encoder_ids[i] == 0) { - output->encoder_ids[i] = encoder->id; + for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { + if (connector->encoder_ids[i] == 0) { + connector->encoder_ids[i] = encoder->id; return 0; } } return -ENOMEM; } -EXPORT_SYMBOL(drm_mode_output_attach_encoder); +EXPORT_SYMBOL(drm_mode_connector_attach_encoder); -void drm_mode_output_detach_encoder(struct drm_output *output, +void drm_mode_connector_detach_encoder(struct drm_connector *connector, struct drm_encoder *encoder) { int i; - for (i = 0; i < DRM_OUTPUT_MAX_ENCODER; i++) { - if (output->encoder_ids[i] == encoder->id) { - output->encoder_ids[i] = 0; + for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) { + if (connector->encoder_ids[i] == encoder->id) { + connector->encoder_ids[i] = 0; break; } } } -EXPORT_SYMBOL(drm_mode_output_detach_encoder); +EXPORT_SYMBOL(drm_mode_connector_detach_encoder); diff --git a/linux-core/drm_crtc.h b/linux-core/drm_crtc.h index 03c336e2..568b6b31 100644 --- a/linux-core/drm_crtc.h +++ b/linux-core/drm_crtc.h @@ -17,10 +17,10 @@ struct drm_device; struct drm_mode_set; /* - * Note on terminology: here, for brevity and convenience, we refer to output - * control chips as 'CRTCs'. They can control any type of output, VGA, LVDS, + * Note on terminology: here, for brevity and convenience, we refer to connector + * control chips as 'CRTCs'. They can control any type of connector, VGA, LVDS, * DVI, etc. And 'screen' refers to the whole of the visible display, which - * may span multiple monitors (and therefore multiple CRTC and output + * may span multiple monitors (and therefore multiple CRTC and connector * structures). */ @@ -80,7 +80,7 @@ struct drm_display_mode { struct list_head head; char name[DRM_DISPLAY_MODE_LEN]; int mode_id; - int output_count; + int connector_count; enum drm_mode_status status; int type; @@ -149,24 +149,24 @@ struct drm_display_mode { #define DPMSModeSuspend 2 #define DPMSModeOff 3 -#define ConnectorUnknown 0 -#define ConnectorVGA 1 -#define ConnectorDVII 2 -#define ConnectorDVID 3 -#define ConnectorDVIA 4 -#define ConnectorComposite 5 -#define ConnectorSVIDEO 6 -#define ConnectorLVDS 7 -#define ConnectorComponent 8 -#define Connector9PinDIN 9 -#define ConnectorDisplayPort 10 -#define ConnectorHDMIA 11 -#define ConnectorHDMIB 12 - -enum drm_output_status { - output_status_connected = 1, - output_status_disconnected = 2, - output_status_unknown = 3, +#define DRM_MODE_CONNECTOR_Unknown 0 +#define DRM_MODE_CONNECTOR_VGA 1 +#define DRM_MODE_CONNECTOR_DVII 2 +#define DRM_MODE_CONNECTOR_DVID 3 +#define DRM_MODE_CONNECTOR_DVIA 4 +#define DRM_MODE_CONNECTOR_Composite 5 +#define DRM_MODE_CONNECTOR_SVIDEO 6 +#define DRM_MODE_CONNECTOR_LVDS 7 +#define DRM_MODE_CONNECTOR_Component 8 +#define DRM_MODE_CONNECTOR_9PinDIN 9 +#define DRM_MODE_CONNECTOR_DisplayPort 10 +#define DRM_MODE_CONNECTOR_HDMIA 11 +#define DRM_MODE_CONNECTOR_HDMIB 12 + +enum drm_connector_status { + connector_status_connected = 1, + connector_status_disconnected = 2, + connector_status_unknown = 3, }; enum subpixel_order { @@ -276,7 +276,7 @@ struct drm_property { }; struct drm_crtc; -struct drm_output; +struct drm_connector; struct drm_encoder; /** @@ -295,9 +295,9 @@ struct drm_encoder; * @destroy: deinit and free object. * * The drm_crtc_funcs structure is the central CRTC management structure - * in the DRM. Each CRTC controls one or more outputs (note that the name + * in the DRM. Each CRTC controls one or more connectors (note that the name * CRTC is simply historical, a CRTC may control LVDS, VGA, DVI, TV out, etc. - * outputs, not just CRTs). + * connectors, not just CRTs). * * Each driver is responsible for filling out this structure at startup time, * in addition to providing other modesetting features, like i2c and DDC @@ -339,7 +339,7 @@ struct drm_crtc_funcs { * @desired_y: desired y for desired_mode * @funcs: CRTC control functions * - * Each CRTC may have one or more outputs associated with it. This structure + * Each CRTC may have one or more connectors associated with it. This structure * allows the CRTC to be controlled. */ struct drm_crtc { @@ -348,7 +348,7 @@ struct drm_crtc { int id; /* idr assigned */ - /* framebuffer the output is currently bound to */ + /* framebuffer the connector is currently bound to */ struct drm_framebuffer *fb; bool enabled; @@ -365,32 +365,32 @@ struct drm_crtc { }; /** - * drm_output_funcs - control outputs on a given device + * drm_connector_funcs - control connectors on a given device * @dpms: set power state (see drm_crtc_funcs above) - * @save: save output state - * @restore: restore output state - * @mode_valid: is this mode valid on the given output? - * @mode_fixup: try to fixup proposed mode for this output + * @save: save connector state + * @restore: restore connector state + * @mode_valid: is this mode valid on the given connector? + * @mode_fixup: try to fixup proposed mode for this connector * @mode_set: set this mode - * @detect: is this output active? - * @get_modes: get mode list for this output - * @set_property: property for this output may need update + * @detect: is this connector active? + * @get_modes: get mode list for this connector + * @set_property: property for this connector may need update * @destroy: make object go away * - * Each CRTC may have one or more outputs attached to it. The functions - * below allow the core DRM code to control outputs, enumerate available modes, + * Each CRTC may have one or more connectors attached to it. The functions + * below allow the core DRM code to control connectors, enumerate available modes, * etc. */ -struct drm_output_funcs { - void (*dpms)(struct drm_output *output, int mode); - void (*save)(struct drm_output *output); - void (*restore)(struct drm_output *output); - enum drm_output_status (*detect)(struct drm_output *output); - int (*get_modes)(struct drm_output *output); - bool (*set_property)(struct drm_output *output, struct drm_property *property, +struct drm_connector_funcs { + void (*dpms)(struct drm_connector *connector, int mode); + void (*save)(struct drm_connector *connector); + void (*restore)(struct drm_connector *connector); + enum drm_connector_status (*detect)(struct drm_connector *connector); + int (*get_modes)(struct drm_connector *connector); + bool (*set_property)(struct drm_connector *connector, struct drm_property *property, uint64_t val); - void (*destroy)(struct drm_output *output); - int (*mode_valid)(struct drm_output *output, + void (*destroy)(struct drm_connector *connector); + int (*mode_valid)(struct drm_connector *connector, struct drm_display_mode *mode); }; @@ -399,10 +399,10 @@ struct drm_encoder_funcs { void (*destroy)(struct drm_encoder *encoder); }; -#define DRM_OUTPUT_MAX_UMODES 16 -#define DRM_OUTPUT_MAX_PROPERTY 16 -#define DRM_OUTPUT_LEN 32 -#define DRM_OUTPUT_MAX_ENCODER 2 +#define DRM_CONNECTOR_MAX_UMODES 16 +#define DRM_CONNECTOR_MAX_PROPERTY 16 +#define DRM_CONNECTOR_LEN 32 +#define DRM_CONNECTOR_MAX_ENCODER 2 /** * drm_encoder - central DRM encoder structure @@ -421,24 +421,24 @@ struct drm_encoder { }; /** - * drm_output - central DRM output control structure - * @crtc: CRTC this output is currently connected to, NULL if none - * @possible_crtcs: bitmap of CRTCS this output could be attached to - * @possible_clones: bitmap of possible outputs this output could clone - * @interlace_allowed: can this output handle interlaced modes? - * @doublescan_allowed: can this output handle doublescan? - * @available_modes: modes available on this output (from get_modes() + user) - * @initial_x: initial x position for this output - * @initial_y: initial y position for this output - * @status: output connected? - * @funcs: output control functions + * drm_connector - central DRM connector control structure + * @crtc: CRTC this connector is currently connected to, NULL if none + * @possible_crtcs: bitmap of CRTCS this connector could be attached to + * @possible_clones: bitmap of possible connectors this connector could clone + * @interlace_allowed: can this connector handle interlaced modes? + * @doublescan_allowed: can this connector handle doublescan? + * @available_modes: modes available on this connector (from get_modes() + user) + * @initial_x: initial x position for this connector + * @initial_y: initial y position for this connector + * @status: connector connected? + * @funcs: connector control functions * - * Each output may be connected to one or more CRTCs, or may be clonable by - * another output if they can share a CRTC. Each output also has a specific + * Each connector may be connected to one or more CRTCs, or may be clonable by + * another connector if they can share a CRTC. Each connector also has a specific * position in the broader display (referred to as a 'screen' though it could * span multiple monitors). */ -struct drm_output { +struct drm_connector { struct drm_device *dev; struct device kdev; struct device_attribute *attr; @@ -446,37 +446,37 @@ struct drm_output { struct drm_crtc *crtc; int id; /* idr assigned */ - int output_type; - int output_type_id; + int connector_type; + int connector_type_id; unsigned long possible_crtcs; unsigned long possible_clones; bool interlace_allowed; bool doublescan_allowed; - struct list_head modes; /* list of modes on this output */ + struct list_head modes; /* list of modes on this connector */ int initial_x, initial_y; - enum drm_output_status status; + enum drm_connector_status status; /* these are modes added by probing with DDC or the BIOS */ struct list_head probed_modes; struct drm_display_info display_info; - const struct drm_output_funcs *funcs; + const struct drm_connector_funcs *funcs; struct list_head user_modes; struct drm_property_blob *edid_blob_ptr; - u32 property_ids[DRM_OUTPUT_MAX_PROPERTY]; - uint64_t property_values[DRM_OUTPUT_MAX_PROPERTY]; + u32 property_ids[DRM_CONNECTOR_MAX_PROPERTY]; + uint64_t property_values[DRM_CONNECTOR_MAX_PROPERTY]; void *helper_private; - u32 encoder_ids[DRM_OUTPUT_MAX_ENCODER]; + u32 encoder_ids[DRM_CONNECTOR_MAX_ENCODER]; }; /** * struct drm_mode_set * - * Represents a single crtc the outputs that it drives with what mode + * Represents a single crtc the connectors that it drives with what mode * and from which framebuffer it scans out from. * * This is used to set modes. @@ -490,8 +490,8 @@ struct drm_mode_set uint32_t x; uint32_t y; - struct drm_output **outputs; - size_t num_outputs; + struct drm_connector **connectors; + size_t num_connectors; }; /** @@ -501,7 +501,7 @@ struct drm_mode_set * Currently only a resize hook is available. DRM will call back into the * driver with a new screen width and height. If the driver can't support * the proposed size, it can return false. Otherwise it should adjust - * the CRTC<->output mappings as needed and update its view of the screen. + * the CRTC<->connector mappings as needed and update its view of the screen. */ struct drm_mode_config_funcs { bool (*resize_fb)(struct drm_device *dev, struct drm_framebuffer *fb); @@ -513,12 +513,12 @@ struct drm_mode_config_funcs { */ struct drm_mode_config { struct mutex mutex; /* protects configuration and IDR */ - struct idr crtc_idr; /* use this idr for all IDs, fb, crtc, output, modes - just makes life easier */ + struct idr crtc_idr; /* use this idr for all IDs, fb, crtc, connector, modes - just makes life easier */ /* this is limited to one for now */ int num_fb; struct list_head fb_list; - int num_output; - struct list_head output_list; + int num_connector; + struct list_head connector_list; int num_encoder; struct list_head encoder_list; @@ -536,8 +536,6 @@ struct drm_mode_config { struct list_head property_blob_list; struct drm_property *edid_property; struct drm_property *dpms_property; - struct drm_property *connector_type_property; - struct drm_property *connector_num_property; /* TV properties */ struct drm_property *tv_mode_property; @@ -556,12 +554,12 @@ extern void drm_crtc_init(struct drm_device *dev, const struct drm_crtc_funcs *funcs); extern void drm_crtc_cleanup(struct drm_crtc *crtc); -extern void drm_output_init(struct drm_device *dev, - struct drm_output *output, - const struct drm_output_funcs *funcs, - int output_type); +extern void drm_connector_init(struct drm_device *dev, + struct drm_connector *connector, + const struct drm_connector_funcs *funcs, + int connector_type); -extern void drm_output_cleanup(struct drm_output *output); +extern void drm_connector_cleanup(struct drm_connector *connector); extern void drm_encoder_init(struct drm_device *dev, struct drm_encoder *encoder, @@ -570,15 +568,15 @@ extern void drm_encoder_init(struct drm_device *dev, extern void drm_encoder_cleanup(struct drm_encoder *encoder); -extern char *drm_get_output_name(struct drm_output *output); +extern char *drm_get_connector_name(struct drm_connector *connector); extern char *drm_get_dpms_name(int val); extern void drm_fb_release(struct file *filp); -extern struct edid *drm_get_edid(struct drm_output *output, +extern struct edid *drm_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter); -extern int drm_add_edid_modes(struct drm_output *output, struct edid *edid); -extern void drm_mode_probed_add(struct drm_output *output, struct drm_display_mode *mode); -extern void drm_mode_remove(struct drm_output *output, struct drm_display_mode *mode); +extern int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid); +extern void drm_mode_probed_add(struct drm_connector *connector, struct drm_display_mode *mode); +extern void drm_mode_remove(struct drm_connector *connector, struct drm_display_mode *mode); extern struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev, struct drm_display_mode *mode); extern void drm_mode_debug_printmodeline(struct drm_display_mode *mode); @@ -607,13 +605,13 @@ extern void drm_mode_sort(struct list_head *mode_list); extern int drm_mode_vrefresh(struct drm_display_mode *mode); extern void drm_mode_set_crtcinfo(struct drm_display_mode *p, int adjust_flags); -extern void drm_mode_output_list_update(struct drm_output *output); -extern int drm_mode_output_update_edid_property(struct drm_output *output, +extern void drm_mode_connector_list_update(struct drm_connector *connector); +extern int drm_mode_connector_update_edid_property(struct drm_connector *connector, struct edid *edid); -extern int drm_output_property_set_value(struct drm_output *output, +extern int drm_connector_property_set_value(struct drm_connector *connector, struct drm_property *property, uint64_t value); -extern int drm_output_property_get_value(struct drm_output *output, +extern int drm_connector_property_get_value(struct drm_connector *connector, struct drm_property *property, uint64_t *value); extern struct drm_display_mode *drm_crtc_mode_create(struct drm_device *dev); @@ -623,10 +621,10 @@ extern struct drm_framebuffer *drm_framebuffer_create(struct drm_device *dev); extern void drm_framebuffer_destroy(struct drm_framebuffer *fb); extern int drmfb_probe(struct drm_device *dev, struct drm_crtc *crtc); extern int drmfb_remove(struct drm_device *dev, struct drm_framebuffer *fb); -extern void drm_crtc_probe_output_modes(struct drm_device *dev, int maxX, int maxY); +extern void drm_crtc_probe_connector_modes(struct drm_device *dev, int maxX, int maxY); extern bool drm_crtc_in_use(struct drm_crtc *crtc); -extern int drm_output_attach_property(struct drm_output *output, +extern int drm_connector_attach_property(struct drm_connector *connector, struct drm_property *property, uint64_t init_val); extern struct drm_property *drm_property_create(struct drm_device *dev, int flags, const char *name, int num_values); @@ -636,9 +634,9 @@ extern int drm_property_add_enum(struct drm_property *property, int index, extern bool drm_create_tv_properties(struct drm_device *dev, int num_formats, char *formats[]); -extern int drm_mode_output_attach_encoder(struct drm_output *output, +extern int drm_mode_connector_attach_encoder(struct drm_connector *connector, struct drm_encoder *encoder); -extern void drm_mode_output_detach_encoder(struct drm_output *output, +extern void drm_mode_connector_detach_encoder(struct drm_connector *connector, struct drm_encoder *encoder); /* IOCTLs */ @@ -647,7 +645,7 @@ extern int drm_mode_getresources(struct drm_device *dev, extern int drm_mode_getcrtc(struct drm_device *dev, void *data, struct drm_file *file_priv); -extern int drm_mode_getoutput(struct drm_device *dev, +extern int drm_mode_getconnector(struct drm_device *dev, void *data, struct drm_file *file_priv); extern int drm_mode_setcrtc(struct drm_device *dev, void *data, struct drm_file *file_priv); @@ -672,7 +670,7 @@ extern int drm_mode_getproperty_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv); extern int drm_mode_getblob_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv); -extern int drm_mode_output_property_set_ioctl(struct drm_device *dev, +extern int drm_mode_connector_property_set_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv); extern int drm_mode_hotplug_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv); diff --git a/linux-core/drm_crtc_helper.c b/linux-core/drm_crtc_helper.c index f776dbed..98b112ed 100644 --- a/linux-core/drm_crtc_helper.c +++ b/linux-core/drm_crtc_helper.c @@ -36,7 +36,7 @@ /** - * drm_pick_crtcs - pick crtcs for output devices + * drm_pick_crtcs - pick crtcs for connector devices * @dev: DRM device * * LOCKING: @@ -45,36 +45,36 @@ static void drm_pick_crtcs (struct drm_device *dev) { int c, o, assigned; - struct drm_output *output, *output_equal; + struct drm_connector *connector, *connector_equal; struct drm_crtc *crtc; struct drm_display_mode *des_mode = NULL, *modes, *modes_equal; int found; - list_for_each_entry(output, &dev->mode_config.output_list, head) { - output->crtc = NULL; + list_for_each_entry(connector, &dev->mode_config.connector_list, head) { + connector->crtc = NULL; - /* Don't hook up outputs that are disconnected ?? + /* Don't hook up connectors that are disconnected ?? * * This is debateable. Do we want fixed /dev/fbX or * dynamic on hotplug (need mode code for that though) ? * - * If we don't hook up outputs now, then we only create - * /dev/fbX for the output that's enabled, that's good as - * the users console will be on that output. + * If we don't hook up connectors now, then we only create + * /dev/fbX for the connector that's enabled, that's good as + * the users console will be on that connector. * - * If we do hook up outputs that are disconnected now, then + * If we do hook up connectors that are disconnected now, then * the user may end up having to muck about with the fbcon - * map flags to assign his console to the enabled output. Ugh. + * map flags to assign his console to the enabled connector. Ugh. */ - if (output->status != output_status_connected) + if (connector->status != connector_status_connected) continue; - if (list_empty(&output->modes)) + if (list_empty(&connector->modes)) continue; des_mode = NULL; found = 0; - list_for_each_entry(des_mode, &output->modes, head) { + list_for_each_entry(des_mode, &connector->modes, head) { if (des_mode->type & DRM_MODE_TYPE_PREFERRED) { found = 1; break; @@ -84,7 +84,7 @@ static void drm_pick_crtcs (struct drm_device *dev) /* No preferred mode, let's just select the first available */ if (!found) { des_mode = NULL; - list_for_each_entry(des_mode, &output->modes, head) { + list_for_each_entry(des_mode, &connector->modes, head) { break; } } @@ -94,15 +94,15 @@ static void drm_pick_crtcs (struct drm_device *dev) assigned = 0; c++; - if ((output->possible_crtcs & (1 << c)) == 0) + if ((connector->possible_crtcs & (1 << c)) == 0) continue; - list_for_each_entry(output_equal, &dev->mode_config.output_list, head) { - if (output->id == output_equal->id) + list_for_each_entry(connector_equal, &dev->mode_config.connector_list, head) { + if (connector->id == connector_equal->id) continue; /* Find out if crtc has been assigned before */ - if (output_equal->crtc == crtc) + if (connector_equal->crtc == crtc) assigned = 1; } @@ -112,16 +112,16 @@ static void drm_pick_crtcs (struct drm_device *dev) #endif o = -1; - list_for_each_entry(output_equal, &dev->mode_config.output_list, head) { + list_for_each_entry(connector_equal, &dev->mode_config.connector_list, head) { o++; - if (output->id == output_equal->id) + if (connector->id == connector_equal->id) continue; - list_for_each_entry(modes, &output->modes, head) { - list_for_each_entry(modes_equal, &output_equal->modes, head) { + list_for_each_entry(modes, &connector->modes, head) { + list_for_each_entry(modes_equal, &connector_equal->modes, head) { if (drm_mode_equal (modes, modes_equal)) { - if ((output->possible_clones & output_equal->possible_clones) && (output_equal->crtc == crtc)) { - printk("Cloning %s (0x%lx) to %s (0x%lx)\n",drm_get_output_name(output),output->possible_clones,drm_get_output_name(output_equal),output_equal->possible_clones); + if ((connector->possible_clones & connector_equal->possible_clones) && (connector_equal->crtc == crtc)) { + printk("Cloning %s (0x%lx) to %s (0x%lx)\n",drm_get_connector_name(connector),connector->possible_clones,drm_get_connector_name(connector_equal),connector_equal->possible_clones); des_mode = modes; assigned = 0; goto clone; @@ -137,10 +137,10 @@ clone: continue; /* Found a CRTC to attach to, do it ! */ - output->crtc = crtc; - output->crtc->desired_mode = des_mode; - output->initial_x = 0; - output->initial_y = 0; + connector->crtc = crtc; + connector->crtc->desired_mode = des_mode; + connector->initial_x = 0; + connector->initial_y = 0; DRM_DEBUG("Desired mode for CRTC %d is 0x%x:%s\n",c,des_mode->mode_id, des_mode->name); break; } @@ -158,7 +158,7 @@ EXPORT_SYMBOL(drm_pick_crtcs); * LOCKING: * Caller must hold mode config lock. * - * Try to set @mode on @crtc. Give @crtc and its associated outputs a chance + * Try to set @mode on @crtc. Give @crtc and its associated connectors a chance * to fixup or reject the mode prior to trying to set it. * * RETURNS: @@ -170,9 +170,9 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc, struct drm_display_mode *mo struct drm_device *dev = crtc->dev; struct drm_display_mode *adjusted_mode, saved_mode; struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; - struct drm_output_helper_funcs *output_funcs; + struct drm_connector_helper_funcs *connector_funcs; int saved_x, saved_y; - struct drm_output *output; + struct drm_connector *connector; bool ret = true; adjusted_mode = drm_mode_duplicate(dev, mode); @@ -200,16 +200,16 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc, struct drm_display_mode *mo } } - /* Pass our mode to the outputs and the CRTC to give them a chance to - * adjust it according to limitations or output properties, and also + /* Pass our mode to the connectors and the CRTC to give them a chance to + * adjust it according to limitations or connector properties, and also * a chance to reject the mode entirely. */ - list_for_each_entry(output, &dev->mode_config.output_list, head) { + list_for_each_entry(connector, &dev->mode_config.connector_list, head) { - if (output->crtc != crtc) + if (connector->crtc != crtc) continue; - output_funcs = output->helper_private; - if (!(ret = output_funcs->mode_fixup(output, mode, adjusted_mode))) { + connector_funcs = connector->helper_private; + if (!(ret = connector_funcs->mode_fixup(connector, mode, adjusted_mode))) { goto done; } } @@ -218,47 +218,47 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc, struct drm_display_mode *mo goto done; } - /* Prepare the outputs and CRTCs before setting the mode. */ - list_for_each_entry(output, &dev->mode_config.output_list, head) { + /* Prepare the connectors and CRTCs before setting the mode. */ + list_for_each_entry(connector, &dev->mode_config.connector_list, head) { - if (output->crtc != crtc) + if (connector->crtc != crtc) continue; - output_funcs = output->helper_private; - /* Disable the output as the first thing we do. */ - output_funcs->prepare(output); + connector_funcs = connector->helper_private; + /* Disable the connector as the first thing we do. */ + connector_funcs->prepare(connector); } crtc_funcs->prepare(crtc); - /* Set up the DPLL and any output state that needs to adjust or depend + /* Set up the DPLL and any connector state that needs to adjust or depend * on the DPLL. */ crtc_funcs->mode_set(crtc, mode, adjusted_mode, x, y); - list_for_each_entry(output, &dev->mode_config.output_list, head) { + list_for_each_entry(connector, &dev->mode_config.connector_list, head) { - if (output->crtc != crtc) + if (connector->crtc != crtc) continue; - DRM_INFO("%s: set mode %s %x\n", drm_get_output_name(output), mode->name, mode->mode_id); - output_funcs = output->helper_private; - output_funcs->mode_set(output, mode, adjusted_mode); + DRM_INFO("%s: set mode %s %x\n", drm_get_connector_name(connector), mode->name, mode->mode_id); + connector_funcs = connector->helper_private; + connector_funcs->mode_set(connector, mode, adjusted_mode); } - /* Now, enable the clocks, plane, pipe, and outputs that we set up. */ + /* Now, enable the clocks, plane, pipe, and connectors that we set up. */ crtc_funcs->commit(crtc); - list_for_each_entry(output, &dev->mode_config.output_list, head) { + list_for_each_entry(connector, &dev->mode_config.connector_list, head) { - if (output->crtc != crtc) + if (connector->crtc != crtc) continue; - output_funcs = output->helper_private; - output_funcs->commit(output); + connector_funcs = connector->helper_private; + connector_funcs->commit(connector); #if 0 // TODO def RANDR_12_INTERFACE - if (output->randr_output) - RRPostPendingProperties (output->randr_output); + if (connector->randr_connector) + RRPostPendingProperties (connector->randr_connector); #endif } @@ -285,7 +285,7 @@ EXPORT_SYMBOL(drm_crtc_helper_set_mode); * @crtc: CRTC to setup * @crtc_info: user provided configuration * @new_mode: new mode to set - * @output_set: set of outputs for the new config + * @connector_set: set of connectors for the new config * @fb: new framebuffer * * LOCKING: @@ -304,7 +304,7 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set) bool save_enabled; bool changed = false; bool flip_or_move = false; - struct drm_output *output; + struct drm_connector *connector; int count = 0, ro; struct drm_crtc_helper_funcs *crtc_funcs; @@ -321,14 +321,14 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set) crtc_funcs = set->crtc->helper_private; - DRM_DEBUG("crtc: %p fb: %p outputs: %p num_outputs: %i (x, y) (%i, %i)\n", set->crtc, set->fb, set->outputs, set->num_outputs, set->x, set->y); + DRM_DEBUG("crtc: %p fb: %p connectors: %p num_connectors: %i (x, y) (%i, %i)\n", set->crtc, set->fb, set->connectors, set->num_connectors, set->x, set->y); dev = set->crtc->dev; /* save previous config */ save_enabled = set->crtc->enabled; - /* this is meant to be num_output not num_crtc */ - save_crtcs = kzalloc(dev->mode_config.num_output * sizeof(struct drm_crtc *), GFP_KERNEL); + /* this is meant to be num_connector not num_crtc */ + save_crtcs = kzalloc(dev->mode_config.num_connector * sizeof(struct drm_crtc *), GFP_KERNEL); if (!save_crtcs) return -ENOMEM; @@ -347,21 +347,21 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set) changed = true; } - list_for_each_entry(output, &dev->mode_config.output_list, head) { - save_crtcs[count++] = output->crtc; + list_for_each_entry(connector, &dev->mode_config.connector_list, head) { + save_crtcs[count++] = connector->crtc; - if (output->crtc == set->crtc) + if (connector->crtc == set->crtc) new_crtc = NULL; else - new_crtc = output->crtc; + new_crtc = connector->crtc; - for (ro = 0; ro < set->num_outputs; ro++) { - if (set->outputs[ro] == output) + for (ro = 0; ro < set->num_connectors; ro++) { + if (set->connectors[ro] == connector) new_crtc = set->crtc; } - if (new_crtc != output->crtc) { + if (new_crtc != connector->crtc) { changed = true; - output->crtc = new_crtc; + connector->crtc = new_crtc; } } @@ -379,8 +379,8 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set) set->y)) { set->crtc->enabled = save_enabled; count = 0; - list_for_each_entry(output, &dev->mode_config.output_list, head) - output->crtc = save_crtcs[count++]; + list_for_each_entry(connector, &dev->mode_config.connector_list, head) + connector->crtc = save_crtcs[count++]; kfree(save_crtcs); return -EINVAL; } @@ -402,14 +402,14 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set) EXPORT_SYMBOL(drm_crtc_helper_set_config); /** - * drm_initial_config - setup a sane initial output configuration + * drm_initial_config - setup a sane initial connector configuration * @dev: DRM device * @can_grow: this configuration is growable * * LOCKING: * Called at init time, must take mode config lock. * - * Scan the CRTCs and outputs and try to put together an initial setup. + * Scan the CRTCs and connectors and try to put together an initial setup. * At the moment, this is a cloned configuration across all heads with * a new framebuffer object as the backing store. * @@ -418,32 +418,32 @@ EXPORT_SYMBOL(drm_crtc_helper_set_config); */ bool drm_helper_initial_config(struct drm_device *dev, bool can_grow) { - struct drm_output *output; + struct drm_connector *connector; int ret = false; mutex_lock(&dev->mode_config.mutex); - drm_crtc_probe_output_modes(dev, 2048, 2048); + drm_crtc_probe_connector_modes(dev, 2048, 2048); drm_pick_crtcs(dev); - /* This is a little screwy, as we've already walked the outputs + /* This is a little screwy, as we've already walked the connectors * above, but it's a little bit of magic too. There's the potential * for things not to get setup above if an existing device gets - * re-assigned thus confusing the hardware. By walking the outputs + * re-assigned thus confusing the hardware. By walking the connectors * this fixes up their crtc's. */ - list_for_each_entry(output, &dev->mode_config.output_list, head) { + list_for_each_entry(connector, &dev->mode_config.connector_list, head) { - /* can't setup the output if there's no assigned mode */ - if (!output->crtc || !output->crtc->desired_mode) + /* can't setup the connector if there's no assigned mode */ + if (!connector->crtc || !connector->crtc->desired_mode) continue; - dev->driver->fb_probe(dev, output->crtc, output); + dev->driver->fb_probe(dev, connector->crtc, connector); /* and needs an attached fb */ - if (output->crtc->fb) - drm_crtc_helper_set_mode(output->crtc, output->crtc->desired_mode, 0, 0); + if (connector->crtc->fb) + drm_crtc_helper_set_mode(connector->crtc, connector->crtc->desired_mode, 0, 0); } drm_disable_unused_functions(dev); @@ -456,7 +456,7 @@ EXPORT_SYMBOL(drm_helper_initial_config); /** * drm_hotplug_stage_two * @dev DRM device - * @output hotpluged output + * @connector hotpluged connector * * LOCKING. * Caller must hold mode config lock, function might grab struct lock. @@ -466,7 +466,7 @@ EXPORT_SYMBOL(drm_helper_initial_config); * RETURNS: * Zero on success, errno on failure. */ -int drm_helper_hotplug_stage_two(struct drm_device *dev, struct drm_output *output, +int drm_helper_hotplug_stage_two(struct drm_device *dev, struct drm_connector *connector, bool connected) { int has_config = 0; @@ -479,29 +479,29 @@ int drm_helper_hotplug_stage_two(struct drm_device *dev, struct drm_output *outp return 0; } - if (output->crtc && output->crtc->desired_mode) { - DRM_DEBUG("drm thinks that the output already has a config\n"); + if (connector->crtc && connector->crtc->desired_mode) { + DRM_DEBUG("drm thinks that the connector already has a config\n"); has_config = 1; } - drm_crtc_probe_output_modes(dev, 2048, 2048); + drm_crtc_probe_connector_modes(dev, 2048, 2048); if (!has_config) drm_pick_crtcs(dev); - if (!output->crtc || !output->crtc->desired_mode) { - DRM_DEBUG("could not find a desired mode or crtc for output\n"); + if (!connector->crtc || !connector->crtc->desired_mode) { + DRM_DEBUG("could not find a desired mode or crtc for connector\n"); return 1; } /* We should really check if there is a fb using this crtc */ if (!has_config) - dev->driver->fb_probe(dev, output->crtc, output); + dev->driver->fb_probe(dev, connector->crtc, connector); else { - dev->driver->fb_resize(dev, output->crtc); + dev->driver->fb_resize(dev, connector->crtc); #if 0 - if (!drm_crtc_set_mode(output->crtc, output->crtc->desired_mode, 0, 0)) + if (!drm_crtc_set_mode(connector->crtc, connector->crtc->desired_mode, 0, 0)) DRM_ERROR("failed to set mode after hotplug\n"); #endif } diff --git a/linux-core/drm_crtc_helper.h b/linux-core/drm_crtc_helper.h index 9e16861d..10420065 100644 --- a/linux-core/drm_crtc_helper.h +++ b/linux-core/drm_crtc_helper.h @@ -36,27 +36,27 @@ struct drm_crtc_helper_funcs { void (*mode_set_base)(struct drm_crtc *crtc, int x, int y); }; -struct drm_output_helper_funcs { - bool (*mode_fixup)(struct drm_output *output, +struct drm_connector_helper_funcs { + bool (*mode_fixup)(struct drm_connector *connector, struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode); - void (*prepare)(struct drm_output *output); - void (*commit)(struct drm_output *output); - void (*mode_set)(struct drm_output *output, + void (*prepare)(struct drm_connector *connector); + void (*commit)(struct drm_connector *connector); + void (*mode_set)(struct drm_connector *connector, struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode); }; struct drm_encoder_helper_funcs { - void (*prepare)(struct drm_output *output); - void (*commit)(struct drm_output *output); - void (*mode_set)(struct drm_output *output, + void (*prepare)(struct drm_connector *connector); + void (*commit)(struct drm_connector *connector); + void (*mode_set)(struct drm_connector *connector, struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode); }; -extern int drm_helper_hotplug_stage_two(struct drm_device *dev, struct drm_output *output, +extern int drm_helper_hotplug_stage_two(struct drm_device *dev, struct drm_connector *connector, bool connected); extern bool drm_helper_initial_config(struct drm_device *dev, bool can_grow); extern int drm_crtc_helper_set_config(struct drm_mode_set *set); @@ -68,9 +68,9 @@ static inline void drm_crtc_helper_add(struct drm_crtc *crtc, const struct drm_c crtc->helper_private = (void *)funcs; } -static inline void drm_output_helper_add(struct drm_output *output, const struct drm_output_helper_funcs *funcs) +static inline void drm_connector_helper_add(struct drm_connector *connector, const struct drm_connector_helper_funcs *funcs) { - output->helper_private = (void *)funcs; + connector->helper_private = (void *)funcs; } diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c index 6111c850..5a16fe8d 100644 --- a/linux-core/drm_drv.c +++ b/linux-core/drm_drv.c @@ -126,14 +126,14 @@ static struct drm_ioctl_desc drm_ioctls[] = { DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETRESOURCES, drm_mode_getresources, DRM_MASTER|DRM_CONTROL_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETCRTC, drm_mode_getcrtc, DRM_MASTER|DRM_CONTROL_ALLOW), - DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETOUTPUT, drm_mode_getoutput, DRM_MASTER|DRM_CONTROL_ALLOW), + DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETCONNECTOR, drm_mode_getconnector, DRM_MASTER|DRM_CONTROL_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_MODE_SETCRTC, drm_mode_setcrtc, DRM_MASTER|DRM_CONTROL_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_MODE_CURSOR, drm_mode_cursor_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_MODE_ADDFB, drm_mode_addfb, DRM_MASTER|DRM_CONTROL_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_MODE_RMFB, drm_mode_rmfb, DRM_MASTER|DRM_CONTROL_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETFB, drm_mode_getfb, DRM_MASTER|DRM_CONTROL_ALLOW), - DRM_IOCTL_DEF(DRM_IOCTL_MODE_SETPROPERTY, drm_mode_output_property_set_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW), + DRM_IOCTL_DEF(DRM_IOCTL_MODE_SETPROPERTY, drm_mode_connector_property_set_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETPROPBLOB, drm_mode_getblob_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_MODE_ATTACHMODE, drm_mode_attachmode_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_MODE_DETACHMODE, drm_mode_detachmode_ioctl, DRM_MASTER|DRM_CONTROL_ALLOW), diff --git a/linux-core/drm_edid.c b/linux-core/drm_edid.c index e033abdf..69906ed9 100644 --- a/linux-core/drm_edid.c +++ b/linux-core/drm_edid.c @@ -211,9 +211,9 @@ static struct drm_display_mode edid_est_modes[] = { * Each EDID block contains a bitmap of the supported "established modes" list * (defined above). Tease them out and add them to the global modes list. */ -static int add_established_modes(struct drm_output *output, struct edid *edid) +static int add_established_modes(struct drm_connector *connector, struct edid *edid) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; unsigned long est_bits = edid->established_timings.t1 | (edid->established_timings.t2 << 8) | ((edid->established_timings.mfg_rsvd & 0x80) << 9); @@ -224,7 +224,7 @@ static int add_established_modes(struct drm_output *output, struct edid *edid) struct drm_display_mode *newmode; newmode = drm_mode_duplicate(dev, &edid_est_modes[i]); if (newmode) { - drm_mode_probed_add(output, newmode); + drm_mode_probed_add(connector, newmode); modes++; } } @@ -239,9 +239,9 @@ static int add_established_modes(struct drm_output *output, struct edid *edid) * Standard modes can be calculated using the CVT standard. Grab them from * @edid, calculate them, and add them to the list. */ -static int add_standard_modes(struct drm_output *output, struct edid *edid) +static int add_standard_modes(struct drm_connector *connector, struct edid *edid) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; int i, modes = 0; for (i = 0; i < EDID_STD_TIMINGS; i++) { @@ -254,7 +254,7 @@ static int add_standard_modes(struct drm_output *output, struct edid *edid) newmode = drm_mode_std(dev, &edid->standard_timings[i]); if (newmode) { - drm_mode_probed_add(output, newmode); + drm_mode_probed_add(connector, newmode); modes++; } } @@ -269,9 +269,9 @@ static int add_standard_modes(struct drm_output *output, struct edid *edid) * Some of the detailed timing sections may contain mode information. Grab * it and add it to the list. */ -static int add_detailed_info(struct drm_output *output, struct edid *edid) +static int add_detailed_info(struct drm_connector *connector, struct edid *edid) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; int i, j, modes = 0; for (i = 0; i < EDID_DETAILED_TIMINGS; i++) { @@ -290,11 +290,11 @@ static int add_detailed_info(struct drm_output *output, struct edid *edid) if (newmode) { if (i == 0 && edid->preferred_timing) newmode->type |= DRM_MODE_TYPE_PREFERRED; - drm_mode_probed_add(output, newmode); + drm_mode_probed_add(connector, newmode); - /* Use first one for output's preferred mode */ - if (!output->display_info.preferred_mode) - output->display_info.preferred_mode = + /* Use first one for connector's preferred mode */ + if (!connector->display_info.preferred_mode) + connector->display_info.preferred_mode = newmode; modes++; } @@ -323,7 +323,7 @@ static int add_detailed_info(struct drm_output *output, struct edid *edid) std = &data->data.timings[j]; newmode = drm_mode_std(dev, std); if (newmode) { - drm_mode_probed_add(output, newmode); + drm_mode_probed_add(connector, newmode); modes++; } } @@ -440,32 +440,32 @@ static unsigned char *drm_ddc_read(struct i2c_adapter *adapter) /** * drm_get_edid - get EDID data, if available - * @output: output we're probing + * @connector: connector we're probing * @adapter: i2c adapter to use for DDC * - * Poke the given output's i2c channel to grab EDID data if possible. + * Poke the given connector's i2c channel to grab EDID data if possible. * * Return edid data or NULL if we couldn't find any. */ -struct edid *drm_get_edid(struct drm_output *output, +struct edid *drm_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter) { struct edid *edid; edid = (struct edid *)drm_ddc_read(adapter); if (!edid) { - dev_warn(&output->dev->pdev->dev, "%s: no EDID data\n", - drm_get_output_name(output)); + dev_warn(&connector->dev->pdev->dev, "%s: no EDID data\n", + drm_get_connector_name(connector)); return NULL; } if (!edid_valid(edid)) { - dev_warn(&output->dev->pdev->dev, "%s: EDID invalid.\n", - drm_get_output_name(output)); + dev_warn(&connector->dev->pdev->dev, "%s: EDID invalid.\n", + drm_get_connector_name(connector)); kfree(edid); return NULL; } - output->display_info.raw_edid = (char *)edid; + connector->display_info.raw_edid = (char *)edid; return edid; } @@ -473,14 +473,14 @@ EXPORT_SYMBOL(drm_get_edid); /** * drm_add_edid_modes - add modes from EDID data, if available - * @output: output we're probing + * @connector: connector we're probing * @edid: edid data * - * Add the specified modes to the output's mode list. + * Add the specified modes to the connector's mode list. * * Return number of modes added or 0 if we couldn't find any. */ -int drm_add_edid_modes(struct drm_output *output, struct edid *edid) +int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid) { int num_modes = 0; @@ -488,31 +488,31 @@ int drm_add_edid_modes(struct drm_output *output, struct edid *edid) return 0; } if (!edid_valid(edid)) { - dev_warn(&output->dev->pdev->dev, "%s: EDID invalid.\n", - drm_get_output_name(output)); + dev_warn(&connector->dev->pdev->dev, "%s: EDID invalid.\n", + drm_get_connector_name(connector)); return 0; } - num_modes += add_established_modes(output, edid); - num_modes += add_standard_modes(output, edid); - num_modes += add_detailed_info(output, edid); - - output->display_info.serration_vsync = edid->serration_vsync; - output->display_info.sync_on_green = edid->sync_on_green; - output->display_info.composite_sync = edid->composite_sync; - output->display_info.separate_syncs = edid->separate_syncs; - output->display_info.blank_to_black = edid->blank_to_black; - output->display_info.video_level = edid->video_level; - output->display_info.digital = edid->digital; - output->display_info.width_mm = edid->width_cm * 10; - output->display_info.height_mm = edid->height_cm * 10; - output->display_info.gamma = edid->gamma; - output->display_info.gtf_supported = edid->default_gtf; - output->display_info.standard_color = edid->standard_color; - output->display_info.display_type = edid->display_type; - output->display_info.active_off_supported = edid->pm_active_off; - output->display_info.suspend_supported = edid->pm_suspend; - output->display_info.standby_supported = edid->pm_standby; - output->display_info.gamma = edid->gamma; + num_modes += add_established_modes(connector, edid); + num_modes += add_standard_modes(connector, edid); + num_modes += add_detailed_info(connector, edid); + + connector->display_info.serration_vsync = edid->serration_vsync; + connector->display_info.sync_on_green = edid->sync_on_green; + connector->display_info.composite_sync = edid->composite_sync; + connector->display_info.separate_syncs = edid->separate_syncs; + connector->display_info.blank_to_black = edid->blank_to_black; + connector->display_info.video_level = edid->video_level; + connector->display_info.digital = edid->digital; + connector->display_info.width_mm = edid->width_cm * 10; + connector->display_info.height_mm = edid->height_cm * 10; + connector->display_info.gamma = edid->gamma; + connector->display_info.gtf_supported = edid->default_gtf; + connector->display_info.standard_color = edid->standard_color; + connector->display_info.display_type = edid->display_type; + connector->display_info.active_off_supported = edid->pm_active_off; + connector->display_info.suspend_supported = edid->pm_suspend; + connector->display_info.standby_supported = edid->pm_standby; + connector->display_info.gamma = edid->gamma; return num_modes; } diff --git a/linux-core/drm_modes.c b/linux-core/drm_modes.c index 897777d0..26b96e73 100644 --- a/linux-core/drm_modes.c +++ b/linux-core/drm_modes.c @@ -521,27 +521,27 @@ void drm_mode_sort(struct list_head *mode_list) /** - * drm_mode_output_list_update - update the mode list for the output - * @output: the output to update + * drm_mode_connector_list_update - update the mode list for the connector + * @connector: the connector to update * * LOCKING: * Caller must hold a lock protecting @mode_list. * - * This moves the modes from the @output probed_modes list + * This moves the modes from the @connector probed_modes list * to the actual mode list. It compares the probed mode against the current * list and only adds different modes. All modes unverified after this point * will be removed by the prune invalid modes. */ -void drm_mode_output_list_update(struct drm_output *output) +void drm_mode_connector_list_update(struct drm_connector *connector) { struct drm_display_mode *mode; struct drm_display_mode *pmode, *pt; int found_it; - list_for_each_entry_safe(pmode, pt, &output->probed_modes, + list_for_each_entry_safe(pmode, pt, &connector->probed_modes, head) { found_it = 0; /* go through current modes checking for the new probed mode */ - list_for_each_entry(mode, &output->modes, head) { + list_for_each_entry(mode, &connector->modes, head) { if (drm_mode_equal(pmode, mode)) { found_it = 1; /* if equal delete the probed mode */ @@ -553,7 +553,7 @@ void drm_mode_output_list_update(struct drm_output *output) } if (!found_it) { - list_move_tail(&pmode->head, &output->modes); + list_move_tail(&pmode->head, &connector->modes); } } } diff --git a/linux-core/drm_sysfs.c b/linux-core/drm_sysfs.c index 8691d156..01a3c047 100644 --- a/linux-core/drm_sysfs.c +++ b/linux-core/drm_sysfs.c @@ -147,27 +147,27 @@ static void drm_sysfs_device_release(struct device *dev) } /* - * Output properties + * Connector properties */ static ssize_t status_show(struct device *device, struct device_attribute *attr, char *buf) { - struct drm_output *output = container_of(device, struct drm_output, kdev); + struct drm_connector *connector = container_of(device, struct drm_connector, kdev); return snprintf(buf, PAGE_SIZE, "%s", - drm_get_output_status_name(output->funcs->detect(output))); + drm_get_connector_status_name(connector->funcs->detect(connector))); } static ssize_t dpms_show(struct device *device, struct device_attribute *attr, char *buf) { - struct drm_output *output = container_of(device, struct drm_output, kdev); - struct drm_device *dev = output->dev; + struct drm_connector *connector = container_of(device, struct drm_connector, kdev); + struct drm_device *dev = connector->dev; uint64_t dpms_status; int ret; - ret = drm_output_property_get_value(output, + ret = drm_connector_property_get_value(connector, dev->mode_config.dpms_property, &dpms_status); if (ret) @@ -179,17 +179,17 @@ static ssize_t dpms_show(struct device *device, static ssize_t edid_show(struct kobject *kobj, struct bin_attribute *attr, char *buf, loff_t off, size_t count) { - struct device *output_dev = container_of(kobj, struct device, kobj); - struct drm_output *output = container_of(output_dev, struct drm_output, + struct device *connector_dev = container_of(kobj, struct device, kobj); + struct drm_connector *connector = container_of(connector_dev, struct drm_connector, kdev); unsigned char *edid; size_t size; - if (!output->edid_blob_ptr) + if (!connector->edid_blob_ptr) return 0; - edid = output->edid_blob_ptr->data; - size = output->edid_blob_ptr->length; + edid = connector->edid_blob_ptr->data; + size = connector->edid_blob_ptr->length; if (!edid) return 0; @@ -207,11 +207,11 @@ static ssize_t modes_show(struct device *device, struct device_attribute *attr, char *buf) { - struct drm_output *output = container_of(device, struct drm_output, kdev); + struct drm_connector *connector = container_of(device, struct drm_connector, kdev); struct drm_display_mode *mode; int written = 0; - list_for_each_entry(mode, &output->modes, head) { + list_for_each_entry(mode, &connector->modes, head) { written += snprintf(buf + written, PAGE_SIZE - written, "%s\n", mode->name); } @@ -219,7 +219,7 @@ static ssize_t modes_show(struct device *device, return written; } -static struct device_attribute output_attrs[] = { +static struct device_attribute connector_attrs[] = { __ATTR_RO(status), __ATTR_RO(dpms), __ATTR_RO(modes), @@ -232,48 +232,48 @@ static struct bin_attribute edid_attr = { }; /** - * drm_sysfs_output_add - add an output to sysfs - * @output: output to add + * drm_sysfs_connector_add - add an connector to sysfs + * @connector: connector to add * - * Create an output device in sysfs, along with its associated output + * Create an connector device in sysfs, along with its associated connector * properties (so far, connection status, dpms, mode list & edid) and - * generate a hotplug event so userspace knows there's a new output + * generate a hotplug event so userspace knows there's a new connector * available. */ -int drm_sysfs_output_add(struct drm_output *output) +int drm_sysfs_connector_add(struct drm_connector *connector) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; int ret = 0, i, j; - if (device_is_registered(&output->kdev)) + if (device_is_registered(&connector->kdev)) return 0; - output->kdev.parent = &dev->primary->kdev; - output->kdev.class = drm_class; - output->kdev.release = drm_sysfs_device_release; + connector->kdev.parent = &dev->primary->kdev; + connector->kdev.class = drm_class; + connector->kdev.release = drm_sysfs_device_release; - DRM_DEBUG("adding \"%s\" to sysfs\n", drm_get_output_name(output)); + DRM_DEBUG("adding \"%s\" to sysfs\n", drm_get_connector_name(connector)); - snprintf(output->kdev.bus_id, BUS_ID_SIZE, "card%d-%s", - dev->primary->index, drm_get_output_name(output)); - ret = device_register(&output->kdev); + snprintf(connector->kdev.bus_id, BUS_ID_SIZE, "card%d-%s", + dev->primary->index, drm_get_connector_name(connector)); + ret = device_register(&connector->kdev); if (ret) { - DRM_ERROR("failed to register output device: %d\n", ret); + DRM_ERROR("failed to register connector device: %d\n", ret); goto out; } - for (i = 0; i < ARRAY_SIZE(output_attrs); i++) { - ret = device_create_file(&output->kdev, &output_attrs[i]); + for (i = 0; i < ARRAY_SIZE(connector_attrs); i++) { + ret = device_create_file(&connector->kdev, &connector_attrs[i]); if (ret) goto err_out_files; } - ret = sysfs_create_bin_file(&output->kdev.kobj, &edid_attr); + ret = sysfs_create_bin_file(&connector->kdev.kobj, &edid_attr); if (ret) goto err_out_files; - /* Let userspace know we have a new output */ + /* Let userspace know we have a new connector */ drm_sysfs_hotplug_event(dev); return 0; @@ -281,33 +281,33 @@ int drm_sysfs_output_add(struct drm_output *output) err_out_files: if (i > 0) for (j = 0; j < i; j++) - device_remove_file(&output->kdev, &output_attrs[i]); - device_unregister(&output->kdev); + device_remove_file(&connector->kdev, &connector_attrs[i]); + device_unregister(&connector->kdev); out: return ret; } -EXPORT_SYMBOL(drm_sysfs_output_add); +EXPORT_SYMBOL(drm_sysfs_connector_add); /** - * drm_sysfs_output_remove - remove an output device from sysfs - * @output: output to remove + * drm_sysfs_connector_remove - remove an connector device from sysfs + * @connector: connector to remove * - * Remove @output and its associated attributes from sysfs. Note that + * Remove @connector and its associated attributes from sysfs. Note that * the device model core will take care of sending the "remove" uevent * at this time, so we don't need to do it. */ -void drm_sysfs_output_remove(struct drm_output *output) +void drm_sysfs_connector_remove(struct drm_connector *connector) { int i; - DRM_DEBUG("removing \"%s\" from sysfs\n", drm_get_output_name(output)); - for (i = 0; i < ARRAY_SIZE(output_attrs); i++) - device_remove_file(&output->kdev, &output_attrs[i]); - sysfs_remove_bin_file(&output->kdev.kobj, &edid_attr); - device_unregister(&output->kdev); + DRM_DEBUG("removing \"%s\" from sysfs\n", drm_get_connector_name(connector)); + for (i = 0; i < ARRAY_SIZE(connector_attrs); i++) + device_remove_file(&connector->kdev, &connector_attrs[i]); + sysfs_remove_bin_file(&connector->kdev.kobj, &edid_attr); + device_unregister(&connector->kdev); } -EXPORT_SYMBOL(drm_sysfs_output_remove); +EXPORT_SYMBOL(drm_sysfs_connector_remove); /** * drm_sysfs_hotplug_event - generate a DRM uevent diff --git a/linux-core/dvo.h b/linux-core/dvo.h index c6c1dbdb..b122ea1f 100644 --- a/linux-core/dvo.h +++ b/linux-core/dvo.h @@ -126,7 +126,7 @@ struct intel_dvo_dev_ops { /* * Probe for a connected output, and return detect_status. */ - enum drm_output_status (*detect)(struct intel_dvo_device *dvo); + enum drm_connector_status (*detect)(struct intel_dvo_device *dvo); /** * Query the device for the modes it provides. diff --git a/linux-core/dvo_ch7017.c b/linux-core/dvo_ch7017.c index 8349da1b..194a7af1 100644 --- a/linux-core/dvo_ch7017.c +++ b/linux-core/dvo_ch7017.c @@ -258,9 +258,9 @@ fail: return false; } -static enum drm_output_status ch7017_detect(struct intel_dvo_device *dvo) +static enum drm_connector_status ch7017_detect(struct intel_dvo_device *dvo) { - return output_status_unknown; + return connector_status_unknown; } static enum drm_mode_status ch7017_mode_valid(struct intel_dvo_device *dvo, diff --git a/linux-core/dvo_ch7xxx.c b/linux-core/dvo_ch7xxx.c index 69827a7d..18922556 100644 --- a/linux-core/dvo_ch7xxx.c +++ b/linux-core/dvo_ch7xxx.c @@ -230,7 +230,7 @@ out: return false; } -static enum drm_output_status ch7xxx_detect(struct intel_dvo_device *dvo) +static enum drm_connector_status ch7xxx_detect(struct intel_dvo_device *dvo) { uint8_t cdet, orig_pm, pm; @@ -247,8 +247,8 @@ static enum drm_output_status ch7xxx_detect(struct intel_dvo_device *dvo) ch7xxx_writeb(dvo, CH7xxx_PM, orig_pm); if (cdet & CH7xxx_CDET_DVI) - return output_status_connected; - return output_status_disconnected; + return connector_status_connected; + return connector_status_disconnected; } static enum drm_mode_status ch7xxx_mode_valid(struct intel_dvo_device *dvo, diff --git a/linux-core/dvo_ivch.c b/linux-core/dvo_ivch.c index 5fce2462..80b85c89 100644 --- a/linux-core/dvo_ivch.c +++ b/linux-core/dvo_ivch.c @@ -293,9 +293,9 @@ out: return false; } -static enum drm_output_status ivch_detect(struct intel_dvo_device *dvo) +static enum drm_connector_status ivch_detect(struct intel_dvo_device *dvo) { - return output_status_connected; + return connector_status_connected; } static enum drm_mode_status ivch_mode_valid(struct intel_dvo_device *dvo, diff --git a/linux-core/dvo_sil164.c b/linux-core/dvo_sil164.c index 0cee59b1..d0fa4913 100644 --- a/linux-core/dvo_sil164.c +++ b/linux-core/dvo_sil164.c @@ -180,16 +180,16 @@ out: return false; } -static enum drm_output_status sil164_detect(struct intel_dvo_device *dvo) +static enum drm_connector_status sil164_detect(struct intel_dvo_device *dvo) { uint8_t reg9; sil164_readb(dvo, SIL164_REG9, ®9); if (reg9 & SIL164_9_HTPLG) - return output_status_connected; + return connector_status_connected; else - return output_status_disconnected; + return connector_status_disconnected; } static enum drm_mode_status sil164_mode_valid(struct intel_dvo_device *dvo, diff --git a/linux-core/dvo_tfp410.c b/linux-core/dvo_tfp410.c index 64448509..c1d1aa96 100644 --- a/linux-core/dvo_tfp410.c +++ b/linux-core/dvo_tfp410.c @@ -207,16 +207,16 @@ out: return false; } -static enum drm_output_status tfp410_detect(struct intel_dvo_device *dvo) +static enum drm_connector_status tfp410_detect(struct intel_dvo_device *dvo) { - enum drm_output_status ret = output_status_disconnected; + enum drm_connector_status ret = connector_status_disconnected; uint8_t ctl2; if (tfp410_readb(dvo, TFP410_CTL_2, &ctl2)) { if (ctl2 & TFP410_CTL_2_HTPLG) - ret = output_status_connected; + ret = connector_status_connected; else - ret = output_status_disconnected; + ret = connector_status_disconnected; } return ret; diff --git a/linux-core/intel_crt.c b/linux-core/intel_crt.c index 44035783..a98f7000 100644 --- a/linux-core/intel_crt.c +++ b/linux-core/intel_crt.c @@ -33,9 +33,9 @@ #include "i915_drm.h" #include "i915_drv.h" -static void intel_crt_dpms(struct drm_output *output, int mode) +static void intel_crt_dpms(struct drm_connector *connector, int mode) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; struct drm_i915_private *dev_priv = dev->dev_private; u32 temp; @@ -61,17 +61,17 @@ static void intel_crt_dpms(struct drm_output *output, int mode) I915_WRITE(ADPA, temp); } -static void intel_crt_save(struct drm_output *output) +static void intel_crt_save(struct drm_connector *connector) { } -static void intel_crt_restore(struct drm_output *output) +static void intel_crt_restore(struct drm_connector *connector) { } -static int intel_crt_mode_valid(struct drm_output *output, +static int intel_crt_mode_valid(struct drm_connector *connector, struct drm_display_mode *mode) { if (mode->flags & V_DBLSCAN) @@ -83,19 +83,19 @@ static int intel_crt_mode_valid(struct drm_output *output, return MODE_OK; } -static bool intel_crt_mode_fixup(struct drm_output *output, +static bool intel_crt_mode_fixup(struct drm_connector *connector, struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode) { return true; } -static void intel_crt_mode_set(struct drm_output *output, +static void intel_crt_mode_set(struct drm_connector *connector, struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode) { - struct drm_device *dev = output->dev; - struct drm_crtc *crtc = output->crtc; + struct drm_device *dev = connector->dev; + struct drm_crtc *crtc = connector->crtc; struct intel_crtc *intel_crtc = to_intel_crtc(crtc); struct drm_i915_private *dev_priv = dev->dev_private; int dpll_md_reg; @@ -138,9 +138,9 @@ static void intel_crt_mode_set(struct drm_output *output, * \return TRUE if CRT is connected. * \return FALSE if CRT is disconnected. */ -static bool intel_crt_detect_hotplug(struct drm_output *output) +static bool intel_crt_detect_hotplug(struct drm_connector *connector) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; struct drm_i915_private *dev_priv = dev->dev_private; u32 temp; @@ -164,57 +164,58 @@ static bool intel_crt_detect_hotplug(struct drm_output *output) return false; } -static bool intel_crt_detect_ddc(struct drm_output *output) +static bool intel_crt_detect_ddc(struct drm_connector *connector) { - struct intel_output *intel_output = to_intel_output(output); + struct intel_output *intel_output = to_intel_output(connector); /* CRT should always be at 0, but check anyway */ if (intel_output->type != INTEL_OUTPUT_ANALOG) return false; - return intel_ddc_probe(output); + return intel_ddc_probe(intel_output); } -static enum drm_output_status intel_crt_detect(struct drm_output *output) +static enum drm_connector_status intel_crt_detect(struct drm_connector *connector) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; if (IS_I9XX(dev) && !IS_I915G(dev) && !IS_I915GM(dev)) { - if (intel_crt_detect_hotplug(output)) - return output_status_connected; + if (intel_crt_detect_hotplug(connector)) + return connector_status_connected; else - return output_status_disconnected; + return connector_status_disconnected; } - if (intel_crt_detect_ddc(output)) - return output_status_connected; + if (intel_crt_detect_ddc(connector)) + return connector_status_connected; /* TODO use load detect */ - return output_status_unknown; + return connector_status_unknown; } -static void intel_crt_destroy(struct drm_output *output) +static void intel_crt_destroy(struct drm_connector *connector) { - struct intel_output *intel_output = to_intel_output(output); + struct intel_output *intel_output = to_intel_output(connector); intel_i2c_destroy(intel_output->ddc_bus); - drm_output_cleanup(output); - kfree(output); + drm_connector_cleanup(connector); + kfree(connector); } -static int intel_crt_get_modes(struct drm_output *output) +static int intel_crt_get_modes(struct drm_connector *connector) { - return intel_ddc_get_modes(output); + struct intel_output *intel_output = to_intel_output(connector); + return intel_ddc_get_modes(intel_output); } -static bool intel_crt_set_property(struct drm_output *output, +static bool intel_crt_set_property(struct drm_connector *connector, struct drm_property *property, uint64_t value) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; if (property == dev->mode_config.dpms_property) - intel_crt_dpms(output, (uint32_t)(value & 0xf)); + intel_crt_dpms(connector, (uint32_t)(value & 0xf)); return true; } @@ -223,14 +224,14 @@ static bool intel_crt_set_property(struct drm_output *output, * Routines for controlling stuff on the analog port */ -static const struct drm_output_helper_funcs intel_crt_helper_funcs = { +static const struct drm_connector_helper_funcs intel_crt_helper_funcs = { .mode_fixup = intel_crt_mode_fixup, - .prepare = intel_output_prepare, - .commit = intel_output_commit, + .prepare = intel_connector_prepare, + .commit = intel_connector_commit, .mode_set = intel_crt_mode_set, }; -static const struct drm_output_funcs intel_crt_output_funcs = { +static const struct drm_connector_funcs intel_crt_connector_funcs = { .dpms = intel_crt_dpms, .save = intel_crt_save, .restore = intel_crt_restore, @@ -253,34 +254,36 @@ static const struct drm_encoder_funcs intel_crt_enc_funcs = { void intel_crt_init(struct drm_device *dev) { - struct drm_output *output; + struct drm_connector *connector; struct intel_output *intel_output; intel_output = kzalloc(sizeof(struct intel_output), GFP_KERNEL); if (!intel_output) return; - output = &intel_output->base; - drm_output_init(dev, &intel_output->base, &intel_crt_output_funcs, DRM_MODE_OUTPUT_VGA); + connector = &intel_output->base; + drm_connector_init(dev, &intel_output->base, &intel_crt_connector_funcs, DRM_MODE_CONNECTOR_VGA); drm_encoder_init(dev, &intel_output->enc, &intel_crt_enc_funcs, DRM_MODE_ENCODER_DAC); - drm_mode_output_attach_encoder(&intel_output->base, &intel_output->enc); + drm_mode_connector_attach_encoder(&intel_output->base, &intel_output->enc); /* Set up the DDC bus. */ intel_output->ddc_bus = intel_i2c_create(dev, GPIOA, "CRTDDC_A"); if (!intel_output->ddc_bus) { dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration " "failed.\n"); - intel_crt_destroy(output); + intel_crt_destroy(connector); return; } intel_output->type = INTEL_OUTPUT_ANALOG; - output->interlace_allowed = 0; - output->doublescan_allowed = 0; + connector->interlace_allowed = 0; + connector->doublescan_allowed = 0; + + drm_connector_helper_add(connector, &intel_crt_helper_funcs); + + drm_sysfs_connector_add(connector); - drm_output_helper_add(output, &intel_crt_helper_funcs); - drm_sysfs_output_add(output); } diff --git a/linux-core/intel_display.c b/linux-core/intel_display.c index abcf5f5e..7fb1ea5f 100644 --- a/linux-core/intel_display.c +++ b/linux-core/intel_display.c @@ -225,9 +225,9 @@ bool intel_pipe_has_type (struct drm_crtc *crtc, int type) { struct drm_device *dev = crtc->dev; struct drm_mode_config *mode_config = &dev->mode_config; - struct drm_output *l_entry; + struct drm_connector *l_entry; - list_for_each_entry(l_entry, &mode_config->output_list, head) { + list_for_each_entry(l_entry, &mode_config->connector_list, head) { if (l_entry->crtc == crtc) { struct intel_output *intel_output = to_intel_output(l_entry); if (intel_output->type == type) @@ -240,7 +240,7 @@ bool intel_pipe_has_type (struct drm_crtc *crtc, int type) #define INTELPllInvalid(s) { /* ErrorF (s) */; return false; } /** * Returns whether the given set of divisors are valid for a given refclk with - * the given outputs. + * the given connectors. */ static bool intel_PLL_is_valid(struct drm_crtc *crtc, intel_clock_t *clock) @@ -264,7 +264,7 @@ static bool intel_PLL_is_valid(struct drm_crtc *crtc, intel_clock_t *clock) if (clock->vco < limit->vco.min || limit->vco.max < clock->vco) INTELPllInvalid ("vco out of range\n"); /* XXX: We may need to be checking "Dot clock" depending on the multiplier, - * output, etc., rather than just a single range. + * connector, etc., rather than just a single range. */ if (clock->dot < limit->dot.min || limit->dot.max < clock->dot) INTELPllInvalid ("dot out of range\n"); @@ -583,16 +583,16 @@ static void intel_crtc_commit (struct drm_crtc *crtc) crtc->funcs->dpms(crtc, DPMSModeOn); } -void intel_output_prepare (struct drm_output *output) +void intel_connector_prepare (struct drm_connector *connector) { /* lvds has its own version of prepare see intel_lvds_prepare */ - output->funcs->dpms(output, DPMSModeOff); + connector->funcs->dpms(connector, DPMSModeOff); } -void intel_output_commit (struct drm_output *output) +void intel_connector_commit (struct drm_connector *connector) { /* lvds has its own version of commit see intel_lvds_commit */ - output->funcs->dpms(output, DPMSModeOn); + connector->funcs->dpms(connector, DPMSModeOn); } static bool intel_crtc_mode_fixup(struct drm_crtc *crtc, @@ -716,12 +716,12 @@ static void intel_crtc_mode_set(struct drm_crtc *crtc, bool ok, is_sdvo = false, is_dvo = false; bool is_crt = false, is_lvds = false, is_tv = false; struct drm_mode_config *mode_config = &dev->mode_config; - struct drm_output *output; + struct drm_connector *connector; - list_for_each_entry(output, &mode_config->output_list, head) { - struct intel_output *intel_output = to_intel_output(output); + list_for_each_entry(connector, &mode_config->connector_list, head) { + struct intel_output *intel_output = to_intel_output(connector); - if (output->crtc != crtc) + if (connector->crtc != crtc) continue; switch (intel_output->type) { @@ -1082,38 +1082,38 @@ static struct drm_display_mode load_detect_mode = { 704, 832, 0, 480, 489, 491, 520, 0, V_NHSYNC | V_NVSYNC), }; -struct drm_crtc *intel_get_load_detect_pipe(struct drm_output *output, +struct drm_crtc *intel_get_load_detect_pipe(struct drm_connector *connector, struct drm_display_mode *mode, int *dpms_mode) { - struct drm_device *dev = output->dev; - struct intel_output *intel_output = to_intel_output(output); + struct drm_device *dev = connector->dev; + struct intel_output *intel_output = to_intel_output(connector); struct intel_crtc *intel_crtc; struct drm_crtc *possible_crtc; struct drm_crtc *supported_crtc =NULL; struct drm_crtc *crtc = NULL; - struct drm_output_helper_funcs *output_funcs; + struct drm_connector_helper_funcs *connector_funcs; int i = -1; /* * Algorithm gets a little messy: - * - if the output already has an assigned crtc, use it (but make + * - if the connector already has an assigned crtc, use it (but make * sure it's on first) - * - try to find the first unused crtc that can drive this output, + * - try to find the first unused crtc that can drive this connector, * and use that if we find one * - if there are no unused crtcs available, try to use the first - * one we found that supports the output + * one we found that supports the connector */ - /* See if we already have a CRTC for this output */ - if (output->crtc) { - crtc = output->crtc; - /* Make sure the crtc and output are running */ + /* See if we already have a CRTC for this connector */ + if (connector->crtc) { + crtc = connector->crtc; + /* Make sure the crtc and connector are running */ intel_crtc = to_intel_crtc(crtc); *dpms_mode = intel_crtc->dpms_mode; if (intel_crtc->dpms_mode != DPMSModeOn) { crtc->funcs->dpms(crtc, DPMSModeOn); - output->funcs->dpms(output, DPMSModeOn); + connector->funcs->dpms(connector, DPMSModeOn); } return crtc; } @@ -1121,7 +1121,7 @@ struct drm_crtc *intel_get_load_detect_pipe(struct drm_output *output, /* Find an unused one (if possible) */ list_for_each_entry(possible_crtc, &dev->mode_config.crtc_list, head) { i++; - if (!(output->possible_crtcs & (1 << i))) + if (!(connector->possible_crtcs & (1 << i))) continue; if (!possible_crtc->enabled) { crtc = possible_crtc; @@ -1133,7 +1133,7 @@ struct drm_crtc *intel_get_load_detect_pipe(struct drm_output *output, /* * If we didn't find an unused CRTC, use the first available one - * that can drive this output. + * that can drive this connector. */ if (!crtc) { crtc = supported_crtc; @@ -1141,7 +1141,7 @@ struct drm_crtc *intel_get_load_detect_pipe(struct drm_output *output, return NULL; } - output->crtc = crtc; + connector->crtc = crtc; intel_output->load_detect_temp = TRUE; intel_crtc = to_intel_crtc(crtc); @@ -1155,25 +1155,25 @@ struct drm_crtc *intel_get_load_detect_pipe(struct drm_output *output, if (intel_crtc->dpms_mode != DPMSModeOn) crtc->funcs->dpms(crtc, DPMSModeOn); - output_funcs = output->helper_private; - /* Add this output to the crtc */ - output_funcs->mode_set(output, &crtc->mode, &crtc->mode); - output_funcs->commit(output); + connector_funcs = connector->helper_private; + /* Add this connector to the crtc */ + connector_funcs->mode_set(connector, &crtc->mode, &crtc->mode); + connector_funcs->commit(connector); } - /* let the output get through one full cycle before testing */ + /* let the connector get through one full cycle before testing */ intel_wait_for_vblank(dev); return crtc; } -void intel_release_load_detect_pipe(struct drm_output *output, int dpms_mode) +void intel_release_load_detect_pipe(struct drm_connector *connector, int dpms_mode) { - struct drm_device *dev = output->dev; - struct intel_output *intel_output = to_intel_output(output); - struct drm_crtc *crtc = output->crtc; + struct drm_device *dev = connector->dev; + struct intel_output *intel_output = to_intel_output(connector); + struct drm_crtc *crtc = connector->crtc; if (intel_output->load_detect_temp) { - output->crtc = NULL; + connector->crtc = NULL; intel_output->load_detect_temp = FALSE; crtc->enabled = drm_crtc_in_use(crtc); drm_disable_unused_functions(dev); @@ -1181,8 +1181,8 @@ void intel_release_load_detect_pipe(struct drm_output *output, int dpms_mode) /* Switch crtc and output back off if necessary */ if (crtc->enabled && dpms_mode != DPMSModeOn) { - if (output->crtc == crtc) - output->funcs->dpms(output, dpms_mode); + if (connector->crtc == crtc) + connector->funcs->dpms(connector, dpms_mode); crtc->funcs->dpms(crtc, dpms_mode); } } @@ -1257,7 +1257,7 @@ static int intel_crtc_clock_get(struct drm_device *dev, struct drm_crtc *crtc) } /* XXX: It would be nice to validate the clocks, but we can't reuse - * i830PllIsValid() because it relies on the xf86_config output + * i830PllIsValid() because it relies on the xf86_config connector * configuration being accurate, which it isn't necessarily. */ @@ -1358,14 +1358,14 @@ struct drm_crtc *intel_get_crtc_from_pipe(struct drm_device *dev, int pipe) return crtc; } -int intel_output_clones(struct drm_device *dev, int type_mask) +int intel_connector_clones(struct drm_device *dev, int type_mask) { int index_mask = 0; - struct drm_output *output; + struct drm_connector *connector; int entry = 0; - list_for_each_entry(output, &dev->mode_config.output_list, head) { - struct intel_output *intel_output = to_intel_output(output); + list_for_each_entry(connector, &dev->mode_config.connector_list, head) { + struct intel_output *intel_output = to_intel_output(connector); if (type_mask & (1 << intel_output->type)) index_mask |= (1 << entry); entry++; @@ -1376,7 +1376,7 @@ int intel_output_clones(struct drm_device *dev, int type_mask) static void intel_setup_outputs(struct drm_device *dev) { - struct drm_output *output; + struct drm_connector *connector; intel_crt_init(dev); @@ -1393,8 +1393,8 @@ static void intel_setup_outputs(struct drm_device *dev) if (IS_I9XX(dev) && !IS_I915G(dev)) intel_tv_init(dev); - list_for_each_entry(output, &dev->mode_config.output_list, head) { - struct intel_output *intel_output = to_intel_output(output); + list_for_each_entry(connector, &dev->mode_config.connector_list, head) { + struct intel_output *intel_output = to_intel_output(connector); int crtc_mask = 0, clone_mask = 0; /* valid crtcs */ @@ -1424,8 +1424,8 @@ static void intel_setup_outputs(struct drm_device *dev) clone_mask = (1 << INTEL_OUTPUT_TVOUT); break; } - output->possible_crtcs = crtc_mask; - output->possible_clones = intel_output_clones(dev, clone_mask); + connector->possible_crtcs = crtc_mask; + connector->possible_clones = intel_connector_clones(dev, clone_mask); } } diff --git a/linux-core/intel_drv.h b/linux-core/intel_drv.h index 3f0c1664..44639525 100644 --- a/linux-core/intel_drv.h +++ b/linux-core/intel_drv.h @@ -47,7 +47,7 @@ struct intel_i2c_chan { }; struct intel_output { - struct drm_output base; + struct drm_connector base; struct drm_encoder enc; int type; @@ -72,8 +72,8 @@ struct intel_crtc { struct intel_i2c_chan *intel_i2c_create(struct drm_device *dev, const u32 reg, const char *name); void intel_i2c_destroy(struct intel_i2c_chan *chan); -int intel_ddc_get_modes(struct drm_output *output); -extern bool intel_ddc_probe(struct drm_output *output); +int intel_ddc_get_modes(struct intel_output *intel_output); +extern bool intel_ddc_probe(struct intel_output *intel_output); extern void intel_crt_init(struct drm_device *dev); extern void intel_sdvo_init(struct drm_device *dev, int output_device); @@ -82,23 +82,23 @@ extern void intel_tv_init(struct drm_device *dev); extern void intel_lvds_init(struct drm_device *dev); extern void intel_crtc_load_lut(struct drm_crtc *crtc); -extern void intel_output_prepare (struct drm_output *output); -extern void intel_output_commit (struct drm_output *output); +extern void intel_connector_prepare (struct drm_connector *connector); +extern void intel_connector_commit (struct drm_connector *connector); extern struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev, struct drm_crtc *crtc); extern void intel_wait_for_vblank(struct drm_device *dev); extern struct drm_crtc *intel_get_crtc_from_pipe(struct drm_device *dev, int pipe); -extern struct drm_crtc *intel_get_load_detect_pipe(struct drm_output *output, +extern struct drm_crtc *intel_get_load_detect_pipe(struct drm_connector *connector, struct drm_display_mode *mode, int *dpms_mode); -extern void intel_release_load_detect_pipe(struct drm_output *output, +extern void intel_release_load_detect_pipe(struct drm_connector *connector, int dpms_mode); -extern struct drm_output* intel_sdvo_find(struct drm_device *dev, int sdvoB); -extern int intel_sdvo_supports_hotplug(struct drm_output *output); -extern void intel_sdvo_set_hotplug(struct drm_output *output, int enable); +extern struct drm_connector* intel_sdvo_find(struct drm_device *dev, int sdvoB); +extern int intel_sdvo_supports_hotplug(struct drm_connector *connector); +extern void intel_sdvo_set_hotplug(struct drm_connector *connector, int enable); -extern int intelfb_probe(struct drm_device *dev, struct drm_crtc *crtc, struct drm_output *output); +extern int intelfb_probe(struct drm_device *dev, struct drm_crtc *crtc, struct drm_connector *connector); extern int intelfb_remove(struct drm_device *dev, struct drm_framebuffer *fb); extern int intelfb_resize(struct drm_device *dev, struct drm_crtc *crtc); diff --git a/linux-core/intel_dvo.c b/linux-core/intel_dvo.c index d9f39af6..7fc5ccea 100644 --- a/linux-core/intel_dvo.c +++ b/linux-core/intel_dvo.c @@ -85,10 +85,10 @@ struct intel_dvo_device intel_dvo_devices[] = { } }; -static void intel_dvo_dpms(struct drm_output *output, int mode) +static void intel_dvo_dpms(struct drm_connector *connector, int mode) { - struct drm_i915_private *dev_priv = output->dev->dev_private; - struct intel_output *intel_output = to_intel_output(output); + struct drm_i915_private *dev_priv = connector->dev->dev_private; + struct intel_output *intel_output = to_intel_output(connector); struct intel_dvo_device *dvo = intel_output->dev_priv; u32 dvo_reg = dvo->dvo_reg; u32 temp = I915_READ(dvo_reg); @@ -104,10 +104,10 @@ static void intel_dvo_dpms(struct drm_output *output, int mode) } } -static void intel_dvo_save(struct drm_output *output) +static void intel_dvo_save(struct drm_connector *connector) { - struct drm_i915_private *dev_priv = output->dev->dev_private; - struct intel_output *intel_output = to_intel_output(output); + struct drm_i915_private *dev_priv = connector->dev->dev_private; + struct intel_output *intel_output = to_intel_output(connector); struct intel_dvo_device *dvo = intel_output->dev_priv; /* Each output should probably just save the registers it touches, @@ -120,10 +120,10 @@ static void intel_dvo_save(struct drm_output *output) dvo->dev_ops->save(dvo); } -static void intel_dvo_restore(struct drm_output *output) +static void intel_dvo_restore(struct drm_connector *connector) { - struct drm_i915_private *dev_priv = output->dev->dev_private; - struct intel_output *intel_output = to_intel_output(output); + struct drm_i915_private *dev_priv = connector->dev->dev_private; + struct intel_output *intel_output = to_intel_output(connector); struct intel_dvo_device *dvo = intel_output->dev_priv; dvo->dev_ops->restore(dvo); @@ -133,10 +133,10 @@ static void intel_dvo_restore(struct drm_output *output) I915_WRITE(DVOC, dev_priv->saveDVOC); } -static int intel_dvo_mode_valid(struct drm_output *output, +static int intel_dvo_mode_valid(struct drm_connector *connector, struct drm_display_mode *mode) { - struct intel_output *intel_output = to_intel_output(output); + struct intel_output *intel_output = to_intel_output(connector); struct intel_dvo_device *dvo = intel_output->dev_priv; if (mode->flags & V_DBLSCAN) @@ -154,11 +154,11 @@ static int intel_dvo_mode_valid(struct drm_output *output, return dvo->dev_ops->mode_valid(dvo, mode); } -static bool intel_dvo_mode_fixup(struct drm_output *output, +static bool intel_dvo_mode_fixup(struct drm_connector *connector, struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode) { - struct intel_output *intel_output = to_intel_output(output); + struct intel_output *intel_output = to_intel_output(connector); struct intel_dvo_device *dvo = intel_output->dev_priv; /* If we have timings from the BIOS for the panel, put them in @@ -187,14 +187,14 @@ static bool intel_dvo_mode_fixup(struct drm_output *output, return true; } -static void intel_dvo_mode_set(struct drm_output *output, +static void intel_dvo_mode_set(struct drm_connector *connector, struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; struct drm_i915_private *dev_priv = dev->dev_private; - struct intel_crtc *intel_crtc = to_intel_crtc(output->crtc); - struct intel_output *intel_output = to_intel_output(output); + struct intel_crtc *intel_crtc = to_intel_crtc(connector->crtc); + struct intel_output *intel_output = to_intel_output(connector); struct intel_dvo_device *dvo = intel_output->dev_priv; int pipe = intel_crtc->pipe; u32 dvo_val; @@ -247,17 +247,17 @@ static void intel_dvo_mode_set(struct drm_output *output, * * Unimplemented. */ -static enum drm_output_status intel_dvo_detect(struct drm_output *output) +static enum drm_connector_status intel_dvo_detect(struct drm_connector *connector) { - struct intel_output *intel_output = to_intel_output(output); + struct intel_output *intel_output = to_intel_output(connector); struct intel_dvo_device *dvo = intel_output->dev_priv; return dvo->dev_ops->detect(dvo); } -static int intel_dvo_get_modes(struct drm_output *output) +static int intel_dvo_get_modes(struct drm_connector *connector) { - struct intel_output *intel_output = to_intel_output(output); + struct intel_output *intel_output = to_intel_output(connector); struct intel_dvo_device *dvo = intel_output->dev_priv; /* We should probably have an i2c driver get_modes function for those @@ -265,8 +265,8 @@ static int intel_dvo_get_modes(struct drm_output *output) * (TV-out, for example), but for now with just TMDS and LVDS, * that's not the case. */ - intel_ddc_get_modes(output); - if (!list_empty(&output->probed_modes)) + intel_ddc_get_modes(intel_output); + if (!list_empty(&connector->probed_modes)) return 1; #if 0 @@ -280,18 +280,18 @@ static int intel_dvo_get_modes(struct drm_output *output) if (dvo->panel_fixed_mode != NULL) { struct drm_display_mode *mode; - mode = drm_mode_duplicate(output->dev, dvo->panel_fixed_mode); + mode = drm_mode_duplicate(connector->dev, dvo->panel_fixed_mode); if (mode) { - drm_mode_probed_add(output, mode); + drm_mode_probed_add(connector, mode); return 1; } } return 0; } -static void intel_dvo_destroy (struct drm_output *output) +static void intel_dvo_destroy (struct drm_connector *connector) { - struct intel_output *intel_output = to_intel_output(output); + struct intel_output *intel_output = to_intel_output(connector); struct intel_dvo_device *dvo = intel_output->dev_priv; if (dvo) { @@ -306,16 +306,16 @@ static void intel_dvo_destroy (struct drm_output *output) intel_i2c_destroy(intel_output->i2c_bus); if (intel_output->ddc_bus) intel_i2c_destroy(intel_output->ddc_bus); - drm_output_cleanup(output); - kfree(output); + drm_connector_cleanup(connector); + kfree(intel_output); } #ifdef RANDR_GET_CRTC_INTERFACE -static struct drm_crtc *intel_dvo_get_crtc(struct drm_output *output) +static struct drm_crtc *intel_dvo_get_crtc(struct drm_connector *connector) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; struct drm_i915_private *dev_priv = dev->dev_private; - struct intel_output *intel_output = to_intel_output(output); + struct intel_output *intel_output = to_intel_output(connector); struct intel_dvo_device *dvo = intel_output->dev_priv; int pipe = !!(I915_READ(dvo->dvo_reg) & SDVO_PIPE_B_SELECT); @@ -323,14 +323,14 @@ static struct drm_crtc *intel_dvo_get_crtc(struct drm_output *output) } #endif -static const struct drm_output_helper_funcs intel_dvo_helper_funcs = { +static const struct drm_connector_helper_funcs intel_dvo_helper_funcs = { .mode_fixup = intel_dvo_mode_fixup, - .prepare = intel_output_prepare, + .prepare = intel_connector_prepare, .mode_set = intel_dvo_mode_set, - .commit = intel_output_commit, + .commit = intel_connector_commit, }; -static const struct drm_output_funcs intel_dvo_output_funcs = { +static const struct drm_connector_funcs intel_dvo_connector_funcs = { .dpms = intel_dvo_dpms, .save = intel_dvo_save, .restore = intel_dvo_restore, @@ -340,6 +340,16 @@ static const struct drm_output_funcs intel_dvo_output_funcs = { .mode_valid = intel_dvo_mode_valid, }; +void intel_dvo_enc_destroy(struct drm_encoder *encoder) +{ + drm_encoder_cleanup(encoder); +} + +static const struct drm_encoder_funcs intel_dvo_enc_funcs = { + .destroy = intel_dvo_enc_destroy, +}; + + /** * Attempts to get a fixed panel timing for LVDS (currently only the i830). * @@ -347,11 +357,11 @@ static const struct drm_output_funcs intel_dvo_output_funcs = { * chip being on DVOB/C and having multiple pipes. */ static struct drm_display_mode * -intel_dvo_get_current_mode (struct drm_output *output) +intel_dvo_get_current_mode (struct drm_connector *connector) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; struct drm_i915_private *dev_priv = dev->dev_private; - struct intel_output *intel_output = to_intel_output(output); + struct intel_output *intel_output = to_intel_output(connector); struct intel_dvo_device *dvo = intel_output->dev_priv; uint32_t dvo_reg = dvo->dvo_reg; uint32_t dvo_val = I915_READ(dvo_reg); @@ -388,8 +398,7 @@ void intel_dvo_init(struct drm_device *dev) int ret = 0; int i; int gpio_inited = 0; - int connector = ConnectorUnknown; - + int encoder_type = DRM_MODE_ENCODER_NONE; intel_output = kzalloc (sizeof(struct intel_output), GFP_KERNEL); if (!intel_output) return; @@ -401,7 +410,7 @@ void intel_dvo_init(struct drm_device *dev) /* Now, try to find a controller */ for (i = 0; i < ARRAY_SIZE(intel_dvo_devices); i++) { - struct drm_output *output = &intel_output->base; + struct drm_connector *connector = &intel_output->base; int gpio; dvo = &intel_dvo_devices[i]; @@ -442,25 +451,28 @@ void intel_dvo_init(struct drm_device *dev) intel_output->type = INTEL_OUTPUT_DVO; switch (dvo->type) { case INTEL_DVO_CHIP_TMDS: - connector = ConnectorDVID; - drm_output_init(dev, output, &intel_dvo_output_funcs, - DRM_MODE_OUTPUT_TMDS); + // connector = DRM_MODE_CONNECTOR_DVID; + drm_connector_init(dev, connector, &intel_dvo_connector_funcs, + DRM_MODE_CONNECTOR_DVII); + encoder_type = DRM_MODE_ENCODER_TMDS; break; case INTEL_DVO_CHIP_LVDS: - connector = ConnectorLVDS; - drm_output_init(dev, output, &intel_dvo_output_funcs, - DRM_MODE_OUTPUT_LVDS); + // connector = DRM_MODE_CONNECTOR_LVDS; + drm_connector_init(dev, connector, &intel_dvo_connector_funcs, + DRM_MODE_CONNECTOR_LVDS); + encoder_type = DRM_MODE_ENCODER_LVDS; break; } - drm_output_helper_add(output, &intel_dvo_helper_funcs); - output->display_info.subpixel_order = SubPixelHorizontalRGB; - output->interlace_allowed = false; - output->doublescan_allowed = false; + drm_connector_helper_add(connector, &intel_dvo_helper_funcs); + connector->display_info.subpixel_order = SubPixelHorizontalRGB; + connector->interlace_allowed = false; + connector->doublescan_allowed = false; intel_output->dev_priv = dvo; intel_output->i2c_bus = i2cbus; + drm_encoder_init(dev, &intel_output->enc, &intel_dvo_enc_funcs, encoder_type); if (dvo->type == INTEL_DVO_CHIP_LVDS) { /* For our LVDS chipsets, we should hopefully be able * to dig the fixed panel mode out of the BIOS data. @@ -469,14 +481,11 @@ void intel_dvo_init(struct drm_device *dev) * headers, likely), so for now, just get the current * mode being output through DVO. */ - dvo->panel_fixed_mode = intel_dvo_get_current_mode(output); + dvo->panel_fixed_mode = intel_dvo_get_current_mode(connector); dvo->panel_wants_dither = true; } - drm_sysfs_output_add(output); - drm_output_attach_property(output, - dev->mode_config.connector_type_property, - connector); + drm_sysfs_connector_add(connector); return; } diff --git a/linux-core/intel_fb.c b/linux-core/intel_fb.c index 05fc3b29..394d2344 100644 --- a/linux-core/intel_fb.c +++ b/linux-core/intel_fb.c @@ -53,7 +53,7 @@ struct intelfb_par { */ struct drm_display_mode *our_mode; struct drm_mode_set set; - struct drm_output *hack; + struct drm_connector *hack; }; /* static int @@ -114,7 +114,7 @@ static int intelfb_check_var(struct fb_var_screeninfo *var, struct intelfb_par *par = info->par; /*struct drm_device *dev = par->dev;*/ struct drm_framebuffer *fb = par->set.fb; - /*struct drm_output *output;*/ + /*struct drm_connector *connector;*/ int depth/*, found = 0*/; if (!var->pixclock) @@ -195,17 +195,17 @@ static int intelfb_check_var(struct fb_var_screeninfo *var, } #if 0 - /* Here we walk the output mode list and look for modes. If we haven't + /* Here we walk the connector mode list and look for modes. If we haven't * got it, then bail. Not very nice, so this is disabled. * In the set_par code, we create our mode based on the incoming * parameters. Nicer, but may not be desired by some. */ - list_for_each_entry(output, &dev->mode_config.output_list, head) { - if (output->crtc == par->crtc) + list_for_each_entry(connector, &dev->mode_config.connector_list, head) { + if (connector->crtc == par->crtc) break; } - list_for_each_entry(drm_mode, &output->modes, head) { + list_for_each_entry(drm_mode, &connector->modes, head) { if (drm_mode->hdisplay == var->xres && drm_mode->vdisplay == var->yres && (((PICOS2KHZ(var->pixclock))/1000) >= ((drm_mode->clock/1000)-1)) && @@ -230,7 +230,7 @@ static int intelfb_set_par(struct fb_info *info) struct drm_framebuffer *fb = par->set.fb; struct drm_device *dev = par->dev; struct drm_display_mode *drm_mode, *search_mode; - struct drm_output *output = NULL; + struct drm_connector *connector = NULL; struct fb_var_screeninfo *var = &info->var; int found = 0; @@ -276,20 +276,20 @@ static int intelfb_set_par(struct fb_info *info) drm_mode_set_crtcinfo(drm_mode, CRTC_INTERLACE_HALVE_V); found = 0; - list_for_each_entry(output, &dev->mode_config.output_list, head) { - if (output->crtc == par->set.crtc){ + list_for_each_entry(connector, &dev->mode_config.connector_list, head) { + if (connector->crtc == par->set.crtc){ found = 1; break; } } - /* no output bound, bail */ + /* no connector bound, bail */ if (!found) return -EINVAL; found = 0; drm_mode_debug_printmodeline(drm_mode); - list_for_each_entry(search_mode, &output->modes, head) { + list_for_each_entry(search_mode, &connector->modes, head) { drm_mode_debug_printmodeline(search_mode); if (drm_mode_equal(drm_mode, search_mode)) { drm_mode_destroy(dev, drm_mode); @@ -299,7 +299,7 @@ static int intelfb_set_par(struct fb_info *info) } } - /* If we didn't find a matching mode that exists on our output, + /* If we didn't find a matching mode that exists on our connector, * create a new attachment for the incoming user specified mode */ if (!found) { @@ -566,7 +566,7 @@ int intelfb_resize(struct drm_device *dev, struct drm_crtc *crtc) } EXPORT_SYMBOL(intelfb_resize); -int intelfb_probe(struct drm_device *dev, struct drm_crtc *crtc, struct drm_output *output) +int intelfb_probe(struct drm_device *dev, struct drm_crtc *crtc, struct drm_connector *connector) { struct fb_info *info; struct intelfb_par *par; @@ -581,7 +581,7 @@ int intelfb_probe(struct drm_device *dev, struct drm_crtc *crtc, struct drm_outp return -EINVAL; } - if (!output) + if (!connector) return -EINVAL; fb = drm_framebuffer_create(dev); @@ -627,9 +627,9 @@ int intelfb_probe(struct drm_device *dev, struct drm_crtc *crtc, struct drm_outp par->dev = dev; par->set.crtc = crtc; par->set.fb = fb; - par->hack = output; - par->set.outputs = &par->hack; - par->set.num_outputs = 1; + par->hack = connector; + par->set.connectors = &par->hack; + par->set.num_connectors = 1; info->fbops = &intelfb_ops; diff --git a/linux-core/intel_lvds.c b/linux-core/intel_lvds.c index 6781a47c..019c45fe 100644 --- a/linux-core/intel_lvds.c +++ b/linux-core/intel_lvds.c @@ -89,9 +89,9 @@ static void intel_lvds_set_power(struct drm_device *dev, bool on) } } -static void intel_lvds_dpms(struct drm_output *output, int mode) +static void intel_lvds_dpms(struct drm_connector *connector, int mode) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; if (mode == DPMSModeOn) intel_lvds_set_power(dev, true); @@ -101,9 +101,9 @@ static void intel_lvds_dpms(struct drm_output *output, int mode) /* XXX: We never power down the LVDS pairs. */ } -static void intel_lvds_save(struct drm_output *output) +static void intel_lvds_save(struct drm_connector *connector) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; struct drm_i915_private *dev_priv = dev->dev_private; dev_priv->savePP_ON = I915_READ(PP_ON_DELAYS); @@ -122,9 +122,9 @@ static void intel_lvds_save(struct drm_output *output) intel_lvds_get_max_backlight(dev); } -static void intel_lvds_restore(struct drm_output *output) +static void intel_lvds_restore(struct drm_connector *connector) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; struct drm_i915_private *dev_priv = dev->dev_private; I915_WRITE(BLC_PWM_CTL, dev_priv->saveBLC_PWM_CTL); @@ -138,10 +138,10 @@ static void intel_lvds_restore(struct drm_output *output) intel_lvds_set_power(dev, false); } -static int intel_lvds_mode_valid(struct drm_output *output, +static int intel_lvds_mode_valid(struct drm_connector *connector, struct drm_display_mode *mode) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; struct drm_i915_private *dev_priv = dev->dev_private; struct drm_display_mode *fixed_mode = dev_priv->panel_fixed_mode; @@ -155,14 +155,14 @@ static int intel_lvds_mode_valid(struct drm_output *output, return MODE_OK; } -static bool intel_lvds_mode_fixup(struct drm_output *output, +static bool intel_lvds_mode_fixup(struct drm_connector *connector, struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; struct drm_i915_private *dev_priv = dev->dev_private; - struct intel_crtc *intel_crtc = to_intel_crtc(output->crtc); - struct drm_output *tmp_output; + struct intel_crtc *intel_crtc = to_intel_crtc(connector->crtc); + struct drm_connector *tmp_connector; /* Should never happen!! */ if (!IS_I965G(dev) && intel_crtc->pipe == 0) { @@ -171,10 +171,10 @@ static bool intel_lvds_mode_fixup(struct drm_output *output, } /* Should never happen!! */ - list_for_each_entry(tmp_output, &dev->mode_config.output_list, head) { - if (tmp_output != output && tmp_output->crtc == output->crtc) { + list_for_each_entry(tmp_connector, &dev->mode_config.connector_list, head) { + if (tmp_connector != connector && tmp_connector->crtc == connector->crtc) { printk(KERN_ERR "Can't enable LVDS and another " - "output on the same pipe\n"); + "connector on the same pipe\n"); return false; } } @@ -211,9 +211,9 @@ static bool intel_lvds_mode_fixup(struct drm_output *output, return true; } -static void intel_lvds_prepare(struct drm_output *output) +static void intel_lvds_prepare(struct drm_connector *connector) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; struct drm_i915_private *dev_priv = dev->dev_private; dev_priv->saveBLC_PWM_CTL = I915_READ(BLC_PWM_CTL); @@ -223,9 +223,9 @@ static void intel_lvds_prepare(struct drm_output *output) intel_lvds_set_power(dev, false); } -static void intel_lvds_commit( struct drm_output *output) +static void intel_lvds_commit( struct drm_connector *connector) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; struct drm_i915_private *dev_priv = dev->dev_private; if (dev_priv->backlight_duty_cycle == 0) @@ -235,13 +235,13 @@ static void intel_lvds_commit( struct drm_output *output) intel_lvds_set_power(dev, true); } -static void intel_lvds_mode_set(struct drm_output *output, +static void intel_lvds_mode_set(struct drm_connector *connector, struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; struct drm_i915_private *dev_priv = dev->dev_private; - struct intel_crtc *intel_crtc = to_intel_crtc(output->crtc); + struct intel_crtc *intel_crtc = to_intel_crtc(connector->crtc); u32 pfit_control; /* @@ -276,24 +276,25 @@ static void intel_lvds_mode_set(struct drm_output *output, /** * Detect the LVDS connection. * - * This always returns OUTPUT_STATUS_CONNECTED. This output should only have + * This always returns CONNECTOR_STATUS_CONNECTED. This connector should only have * been set up if the LVDS was actually connected anyway. */ -static enum drm_output_status intel_lvds_detect(struct drm_output *output) +static enum drm_connector_status intel_lvds_detect(struct drm_connector *connector) { - return output_status_connected; + return connector_status_connected; } /** * Return the list of DDC modes if available, or the BIOS fixed mode otherwise. */ -static int intel_lvds_get_modes(struct drm_output *output) +static int intel_lvds_get_modes(struct drm_connector *connector) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; + struct intel_output *intel_output = to_intel_output(connector); struct drm_i915_private *dev_priv = dev->dev_private; int ret = 0; - ret = intel_ddc_get_modes(output); + ret = intel_ddc_get_modes(intel_output); if (ret) return ret; @@ -302,15 +303,15 @@ static int intel_lvds_get_modes(struct drm_output *output) * Set wide sync ranges so we get all modes * handed to valid_mode for checking */ - output->display_info.min_vfreq = 0; - output->display_info.max_vfreq = 200; - output->display_info.min_hfreq = 0; - output->display_info.max_hfreq = 200; + connector->display_info.min_vfreq = 0; + connector->display_info.max_vfreq = 200; + connector->display_info.min_hfreq = 0; + connector->display_info.max_hfreq = 200; if (dev_priv->panel_fixed_mode != NULL) { struct drm_display_mode *mode = drm_mode_duplicate(dev, dev_priv->panel_fixed_mode); - drm_mode_probed_add(output, mode); + drm_mode_probed_add(connector, mode); return 1; } @@ -319,28 +320,28 @@ static int intel_lvds_get_modes(struct drm_output *output) /** * intel_lvds_destroy - unregister and free LVDS structures - * @output: output to free + * @connector: connector to free * - * Unregister the DDC bus for this output then free the driver private + * Unregister the DDC bus for this connector then free the driver private * structure. */ -static void intel_lvds_destroy(struct drm_output *output) +static void intel_lvds_destroy(struct drm_connector *connector) { - struct intel_output *intel_output = to_intel_output(output); + struct intel_output *intel_output = to_intel_output(connector); intel_i2c_destroy(intel_output->ddc_bus); - drm_output_cleanup(output); - kfree(output); + drm_connector_cleanup(connector); + kfree(connector); } -static const struct drm_output_helper_funcs intel_lvds_helper_funcs = { +static const struct drm_connector_helper_funcs intel_lvds_helper_funcs = { .mode_fixup = intel_lvds_mode_fixup, .prepare = intel_lvds_prepare, .mode_set = intel_lvds_mode_set, .commit = intel_lvds_commit, }; -static const struct drm_output_funcs intel_lvds_output_funcs = { +static const struct drm_connector_funcs intel_lvds_connector_funcs = { .dpms = intel_lvds_dpms, .save = intel_lvds_save, .restore = intel_lvds_restore, @@ -350,18 +351,28 @@ static const struct drm_output_funcs intel_lvds_output_funcs = { .mode_valid = intel_lvds_mode_valid, }; + +static void intel_lvds_enc_destroy(struct drm_encoder *encoder) +{ + drm_encoder_cleanup(encoder); +} + +static const struct drm_encoder_funcs intel_lvds_enc_funcs = { + .destroy = intel_lvds_enc_destroy, +}; + /** - * intel_lvds_init - setup LVDS outputs on this device + * intel_lvds_init - setup LVDS connectors on this device * @dev: drm device * - * Create the output, register the LVDS DDC bus, and try to figure out what + * Create the connector, register the LVDS DDC bus, and try to figure out what * modes we can display on the LVDS panel (if present). */ void intel_lvds_init(struct drm_device *dev) { struct drm_i915_private *dev_priv = dev->dev_private; struct intel_output *intel_output; - struct drm_output *output; + struct drm_connector *connector; struct drm_display_mode *scan; /* *modes, *bios_mode; */ struct drm_crtc *crtc; u32 lvds; @@ -372,16 +383,19 @@ void intel_lvds_init(struct drm_device *dev) return; } - output = &intel_output->base; - drm_output_init(dev, &intel_output->base, &intel_lvds_output_funcs, - DRM_MODE_OUTPUT_LVDS); + connector = &intel_output->base; + drm_connector_init(dev, &intel_output->base, &intel_lvds_connector_funcs, + DRM_MODE_CONNECTOR_LVDS); + + drm_encoder_init(dev, &intel_output->enc, &intel_lvds_enc_funcs, + DRM_MODE_ENCODER_LVDS); intel_output->type = INTEL_OUTPUT_LVDS; - drm_output_helper_add(output, &intel_lvds_helper_funcs); - output->display_info.subpixel_order = SubPixelHorizontalRGB; - output->interlace_allowed = FALSE; - output->doublescan_allowed = FALSE; + drm_connector_helper_add(connector, &intel_lvds_helper_funcs); + connector->display_info.subpixel_order = SubPixelHorizontalRGB; + connector->interlace_allowed = FALSE; + connector->doublescan_allowed = FALSE; /* @@ -399,7 +413,7 @@ void intel_lvds_init(struct drm_device *dev) if (!intel_output->ddc_bus) { dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration " "failed.\n"); - intel_lvds_destroy(output); + intel_lvds_destroy(connector); return; } @@ -407,9 +421,9 @@ void intel_lvds_init(struct drm_device *dev) * Attempt to get the fixed panel mode from DDC. Assume that the * preferred mode is the right one. */ - intel_ddc_get_modes(output); + intel_ddc_get_modes(intel_output); - list_for_each_entry(scan, &output->probed_modes, head) { + list_for_each_entry(scan, &connector->probed_modes, head) { if (scan->type & DRM_MODE_TYPE_PREFERRED) { dev_priv->panel_fixed_mode = drm_mode_duplicate(dev, scan); @@ -481,11 +495,10 @@ void intel_lvds_init(struct drm_device *dev) #endif out: - drm_sysfs_output_add(output); - drm_output_attach_property(output, dev->mode_config.connector_type_property, ConnectorLVDS); + drm_sysfs_connector_add(connector); return; failed: DRM_DEBUG("No LVDS modes found, disabling.\n"); - intel_lvds_destroy(output); + intel_lvds_destroy(connector); } diff --git a/linux-core/intel_modes.c b/linux-core/intel_modes.c index 8e9a506a..79be3575 100644 --- a/linux-core/intel_modes.c +++ b/linux-core/intel_modes.c @@ -13,9 +13,8 @@ * intel_ddc_probe * */ -bool intel_ddc_probe(struct drm_output *output) +bool intel_ddc_probe(struct intel_output *intel_output) { - struct intel_output *intel_output = to_intel_output(output); u8 out_buf[] = { 0x0, 0x0}; u8 buf[2]; int ret; @@ -43,20 +42,19 @@ bool intel_ddc_probe(struct drm_output *output) /** * intel_ddc_get_modes - get modelist from monitor - * @output: DRM output device to use + * @connector: DRM connector device to use * - * Fetch the EDID information from @output using the DDC bus. + * Fetch the EDID information from @connector using the DDC bus. */ -int intel_ddc_get_modes(struct drm_output *output) +int intel_ddc_get_modes(struct intel_output *intel_output) { - struct intel_output *intel_output = to_intel_output(output); struct edid *edid; int ret = 0; - edid = drm_get_edid(output, &intel_output->ddc_bus->adapter); + edid = drm_get_edid(&intel_output->base, &intel_output->ddc_bus->adapter); if (edid) { - drm_mode_output_update_edid_property(output, edid); - ret = drm_add_edid_modes(output, edid); + drm_mode_connector_update_edid_property(&intel_output->base, edid); + ret = drm_add_edid_modes(&intel_output->base, edid); kfree(edid); } return ret; diff --git a/linux-core/intel_sdvo.c b/linux-core/intel_sdvo.c index 2b232e9a..85bee96b 100644 --- a/linux-core/intel_sdvo.c +++ b/linux-core/intel_sdvo.c @@ -60,11 +60,10 @@ struct intel_sdvo_priv { * SDVOB and SDVOC to work around apparent hardware issues (according to * comments in the BIOS). */ -void intel_sdvo_write_sdvox(struct drm_output *output, u32 val) +void intel_sdvo_write_sdvox(struct intel_output *intel_output, u32 val) { - struct drm_device *dev = output->dev; + struct drm_device *dev = intel_output->base.dev; struct drm_i915_private *dev_priv = dev->dev_private; - struct intel_output *intel_output = to_intel_output(output); struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; u32 bval = val, cval = val; int i; @@ -88,10 +87,9 @@ void intel_sdvo_write_sdvox(struct drm_output *output, u32 val) } } -static bool intel_sdvo_read_byte(struct drm_output *output, u8 addr, +static bool intel_sdvo_read_byte(struct intel_output *intel_output, u8 addr, u8 *ch) { - struct intel_output *intel_output = to_intel_output(output); struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; u8 out_buf[2]; u8 buf[2]; @@ -126,10 +124,9 @@ static bool intel_sdvo_read_byte(struct drm_output *output, u8 addr, return false; } -static bool intel_sdvo_write_byte(struct drm_output *output, int addr, +static bool intel_sdvo_write_byte(struct intel_output *intel_output, int addr, u8 ch) { - struct intel_output *intel_output = to_intel_output(output); u8 out_buf[2]; struct i2c_msg msgs[] = { { @@ -198,10 +195,9 @@ const static struct _sdvo_cmd_name { #define SDVO_NAME(dev_priv) ((dev_priv)->output_device == SDVOB ? "SDVOB" : "SDVOC") #define SDVO_PRIV(output) ((struct intel_sdvo_priv *) (output)->dev_priv) -static void intel_sdvo_write_cmd(struct drm_output *output, u8 cmd, +static void intel_sdvo_write_cmd(struct intel_output *intel_output, u8 cmd, void *args, int args_len) { - struct intel_output *intel_output = to_intel_output(output); struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; int i; @@ -223,10 +219,10 @@ static void intel_sdvo_write_cmd(struct drm_output *output, u8 cmd, } for (i = 0; i < args_len; i++) { - intel_sdvo_write_byte(output, SDVO_I2C_ARG_0 - i, ((u8*)args)[i]); + intel_sdvo_write_byte(intel_output, SDVO_I2C_ARG_0 - i, ((u8*)args)[i]); } - intel_sdvo_write_byte(output, SDVO_I2C_OPCODE, cmd); + intel_sdvo_write_byte(intel_output, SDVO_I2C_OPCODE, cmd); } static const char *cmd_status_names[] = { @@ -239,10 +235,9 @@ static const char *cmd_status_names[] = { "Scaling not supported" }; -static u8 intel_sdvo_read_response(struct drm_output *output, void *response, +static u8 intel_sdvo_read_response(struct intel_output *intel_output, void *response, int response_len) { - struct intel_output *intel_output = to_intel_output(output); struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; int i; u8 status; @@ -251,12 +246,12 @@ static u8 intel_sdvo_read_response(struct drm_output *output, void *response, while (retry--) { /* Read the command response */ for (i = 0; i < response_len; i++) { - intel_sdvo_read_byte(output, SDVO_I2C_RETURN_0 + i, + intel_sdvo_read_byte(intel_output, SDVO_I2C_RETURN_0 + i, &((u8 *)response)[i]); } /* read the return status */ - intel_sdvo_read_byte(output, SDVO_I2C_CMD_STATUS, &status); + intel_sdvo_read_byte(intel_output, SDVO_I2C_CMD_STATUS, &status); if (1) { DRM_DEBUG("%s: R: ", SDVO_NAME(sdvo_priv)); @@ -295,12 +290,12 @@ int intel_sdvo_get_pixel_multiplier(struct drm_display_mode *mode) * SDVO chips which defeats the purpose of doing a bus switch in the first * place. */ -void intel_sdvo_set_control_bus_switch(struct drm_output *output, u8 target) +void intel_sdvo_set_control_bus_switch(struct intel_output *intel_output, u8 target) { - intel_sdvo_write_cmd(output, SDVO_CMD_SET_CONTROL_BUS_SWITCH, &target, 1); + intel_sdvo_write_cmd(intel_output, SDVO_CMD_SET_CONTROL_BUS_SWITCH, &target, 1); } -static bool intel_sdvo_set_target_input(struct drm_output *output, bool target_0, bool target_1) +static bool intel_sdvo_set_target_input(struct intel_output *intel_output, bool target_0, bool target_1) { struct intel_sdvo_set_target_input_args targets = {0}; u8 status; @@ -311,10 +306,10 @@ static bool intel_sdvo_set_target_input(struct drm_output *output, bool target_0 if (target_1) targets.target_1 = 1; - intel_sdvo_write_cmd(output, SDVO_CMD_SET_TARGET_INPUT, &targets, + intel_sdvo_write_cmd(intel_output, SDVO_CMD_SET_TARGET_INPUT, &targets, sizeof(targets)); - status = intel_sdvo_read_response(output, NULL, 0); + status = intel_sdvo_read_response(intel_output, NULL, 0); return (status == SDVO_CMD_STATUS_SUCCESS); } @@ -325,13 +320,13 @@ static bool intel_sdvo_set_target_input(struct drm_output *output, bool target_0 * This function is making an assumption about the layout of the response, * which should be checked against the docs. */ -static bool intel_sdvo_get_trained_inputs(struct drm_output *output, bool *input_1, bool *input_2) +static bool intel_sdvo_get_trained_inputs(struct intel_output *intel_output, bool *input_1, bool *input_2) { struct intel_sdvo_get_trained_inputs_response response; u8 status; - intel_sdvo_write_cmd(output, SDVO_CMD_GET_TRAINED_INPUTS, NULL, 0); - status = intel_sdvo_read_response(output, &response, sizeof(response)); + intel_sdvo_write_cmd(intel_output, SDVO_CMD_GET_TRAINED_INPUTS, NULL, 0); + status = intel_sdvo_read_response(intel_output, &response, sizeof(response)); if (status != SDVO_CMD_STATUS_SUCCESS) return false; @@ -340,29 +335,29 @@ static bool intel_sdvo_get_trained_inputs(struct drm_output *output, bool *input return true; } -static bool intel_sdvo_get_active_outputs(struct drm_output *output, +static bool intel_sdvo_get_active_outputs(struct intel_output *intel_output, u16 *outputs) { u8 status; - intel_sdvo_write_cmd(output, SDVO_CMD_GET_ACTIVE_OUTPUTS, NULL, 0); - status = intel_sdvo_read_response(output, outputs, sizeof(*outputs)); + intel_sdvo_write_cmd(intel_output, SDVO_CMD_GET_ACTIVE_OUTPUTS, NULL, 0); + status = intel_sdvo_read_response(intel_output, outputs, sizeof(*outputs)); return (status == SDVO_CMD_STATUS_SUCCESS); } -static bool intel_sdvo_set_active_outputs(struct drm_output *output, +static bool intel_sdvo_set_active_outputs(struct intel_output *intel_output, u16 outputs) { u8 status; - intel_sdvo_write_cmd(output, SDVO_CMD_SET_ACTIVE_OUTPUTS, &outputs, + intel_sdvo_write_cmd(intel_output, SDVO_CMD_SET_ACTIVE_OUTPUTS, &outputs, sizeof(outputs)); - status = intel_sdvo_read_response(output, NULL, 0); + status = intel_sdvo_read_response(intel_output, NULL, 0); return (status == SDVO_CMD_STATUS_SUCCESS); } -static bool intel_sdvo_set_encoder_power_state(struct drm_output *output, +static bool intel_sdvo_set_encoder_power_state(struct intel_output *intel_output, int mode) { u8 status, state = SDVO_ENCODER_STATE_ON; @@ -382,24 +377,24 @@ static bool intel_sdvo_set_encoder_power_state(struct drm_output *output, break; } - intel_sdvo_write_cmd(output, SDVO_CMD_SET_ENCODER_POWER_STATE, &state, + intel_sdvo_write_cmd(intel_output, SDVO_CMD_SET_ENCODER_POWER_STATE, &state, sizeof(state)); - status = intel_sdvo_read_response(output, NULL, 0); + status = intel_sdvo_read_response(intel_output, NULL, 0); return (status == SDVO_CMD_STATUS_SUCCESS); } -static bool intel_sdvo_get_input_pixel_clock_range(struct drm_output *output, +static bool intel_sdvo_get_input_pixel_clock_range(struct intel_output *intel_output, int *clock_min, int *clock_max) { struct intel_sdvo_pixel_clock_range clocks; u8 status; - intel_sdvo_write_cmd(output, SDVO_CMD_GET_INPUT_PIXEL_CLOCK_RANGE, + intel_sdvo_write_cmd(intel_output, SDVO_CMD_GET_INPUT_PIXEL_CLOCK_RANGE, NULL, 0); - status = intel_sdvo_read_response(output, &clocks, sizeof(clocks)); + status = intel_sdvo_read_response(intel_output, &clocks, sizeof(clocks)); if (status != SDVO_CMD_STATUS_SUCCESS) return false; @@ -411,31 +406,31 @@ static bool intel_sdvo_get_input_pixel_clock_range(struct drm_output *output, return true; } -static bool intel_sdvo_set_target_output(struct drm_output *output, +static bool intel_sdvo_set_target_output(struct intel_output *intel_output, u16 outputs) { u8 status; - intel_sdvo_write_cmd(output, SDVO_CMD_SET_TARGET_OUTPUT, &outputs, + intel_sdvo_write_cmd(intel_output, SDVO_CMD_SET_TARGET_OUTPUT, &outputs, sizeof(outputs)); - status = intel_sdvo_read_response(output, NULL, 0); + status = intel_sdvo_read_response(intel_output, NULL, 0); return (status == SDVO_CMD_STATUS_SUCCESS); } -static bool intel_sdvo_get_timing(struct drm_output *output, u8 cmd, +static bool intel_sdvo_get_timing(struct intel_output *intel_output, u8 cmd, struct intel_sdvo_dtd *dtd) { u8 status; - intel_sdvo_write_cmd(output, cmd, NULL, 0); - status = intel_sdvo_read_response(output, &dtd->part1, + intel_sdvo_write_cmd(intel_output, cmd, NULL, 0); + status = intel_sdvo_read_response(intel_output, &dtd->part1, sizeof(dtd->part1)); if (status != SDVO_CMD_STATUS_SUCCESS) return false; - intel_sdvo_write_cmd(output, cmd + 1, NULL, 0); - status = intel_sdvo_read_response(output, &dtd->part2, + intel_sdvo_write_cmd(intel_output, cmd + 1, NULL, 0); + status = intel_sdvo_read_response(intel_output, &dtd->part2, sizeof(dtd->part2)); if (status != SDVO_CMD_STATUS_SUCCESS) return false; @@ -443,71 +438,70 @@ static bool intel_sdvo_get_timing(struct drm_output *output, u8 cmd, return true; } -static bool intel_sdvo_get_input_timing(struct drm_output *output, +static bool intel_sdvo_get_input_timing(struct intel_output *intel_output, struct intel_sdvo_dtd *dtd) { - return intel_sdvo_get_timing(output, + return intel_sdvo_get_timing(intel_output, SDVO_CMD_GET_INPUT_TIMINGS_PART1, dtd); } -static bool intel_sdvo_get_output_timing(struct drm_output *output, +static bool intel_sdvo_get_output_timing(struct intel_output *intel_output, struct intel_sdvo_dtd *dtd) { - return intel_sdvo_get_timing(output, + return intel_sdvo_get_timing(intel_output, SDVO_CMD_GET_OUTPUT_TIMINGS_PART1, dtd); } -static bool intel_sdvo_set_timing(struct drm_output *output, u8 cmd, +static bool intel_sdvo_set_timing(struct intel_output *intel_output, u8 cmd, struct intel_sdvo_dtd *dtd) { u8 status; - intel_sdvo_write_cmd(output, cmd, &dtd->part1, sizeof(dtd->part1)); - status = intel_sdvo_read_response(output, NULL, 0); + intel_sdvo_write_cmd(intel_output, cmd, &dtd->part1, sizeof(dtd->part1)); + status = intel_sdvo_read_response(intel_output, NULL, 0); if (status != SDVO_CMD_STATUS_SUCCESS) return false; - intel_sdvo_write_cmd(output, cmd + 1, &dtd->part2, sizeof(dtd->part2)); - status = intel_sdvo_read_response(output, NULL, 0); + intel_sdvo_write_cmd(intel_output, cmd + 1, &dtd->part2, sizeof(dtd->part2)); + status = intel_sdvo_read_response(intel_output, NULL, 0); if (status != SDVO_CMD_STATUS_SUCCESS) return false; return true; } -static bool intel_sdvo_set_input_timing(struct drm_output *output, +static bool intel_sdvo_set_input_timing(struct intel_output *intel_output, struct intel_sdvo_dtd *dtd) { - return intel_sdvo_set_timing(output, + return intel_sdvo_set_timing(intel_output, SDVO_CMD_SET_INPUT_TIMINGS_PART1, dtd); } -static bool intel_sdvo_set_output_timing(struct drm_output *output, +static bool intel_sdvo_set_output_timing(struct intel_output *intel_output, struct intel_sdvo_dtd *dtd) { - return intel_sdvo_set_timing(output, + return intel_sdvo_set_timing(intel_output, SDVO_CMD_SET_OUTPUT_TIMINGS_PART1, dtd); } #if 0 -static bool intel_sdvo_get_preferred_input_timing(struct drm_output *output, +static bool intel_sdvo_get_preferred_input_timing(struct intel_output *intel_output, struct intel_sdvo_dtd *dtd) { - struct intel_output *intel_output = to_intel_output(output); struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; u8 status; - intel_sdvo_write_cmd(output, SDVO_CMD_GET_PREFERRED_INPUT_TIMING_PART1, + intel_sdvo_write_cmd(intel_output, SDVO_CMD_GET_PREFERRED_INPUT_TIMING_PART1, NULL, 0); - status = intel_sdvo_read_response(output, &dtd->part1, + status = intel_sdvo_read_response(intel_output, &dtd->part1, sizeof(dtd->part1)); if (status != SDVO_CMD_STATUS_SUCCESS) return false; - intel_sdvo_write_cmd(output, SDVO_CMD_GET_PREFERRED_INPUT_TIMING_PART2, + intel_sdvo_write_cmd(intel_output, SDVO_CMD_GET_PREFERRED_INPUT_TIMING_PART2, NULL, 0); - status = intel_sdvo_read_response(output, &dtd->part2, + status = intel_sdvo_read_response(intel_output, &dtd->part2, sizeof(dtd->part2)); if (status != SDVO_CMD_STATUS_SUCCESS) return false; @@ -516,12 +510,12 @@ static bool intel_sdvo_get_preferred_input_timing(struct drm_output *output, } #endif -static int intel_sdvo_get_clock_rate_mult(struct drm_output *output) +static int intel_sdvo_get_clock_rate_mult(struct intel_output *intel_output) { u8 response, status; - intel_sdvo_write_cmd(output, SDVO_CMD_GET_CLOCK_RATE_MULT, NULL, 0); - status = intel_sdvo_read_response(output, &response, 1); + intel_sdvo_write_cmd(intel_output, SDVO_CMD_GET_CLOCK_RATE_MULT, NULL, 0); + status = intel_sdvo_read_response(intel_output, &response, 1); if (status != SDVO_CMD_STATUS_SUCCESS) { DRM_DEBUG("Couldn't get SDVO clock rate multiplier\n"); @@ -533,19 +527,19 @@ static int intel_sdvo_get_clock_rate_mult(struct drm_output *output) return response; } -static bool intel_sdvo_set_clock_rate_mult(struct drm_output *output, u8 val) +static bool intel_sdvo_set_clock_rate_mult(struct intel_output *intel_output, u8 val) { u8 status; - intel_sdvo_write_cmd(output, SDVO_CMD_SET_CLOCK_RATE_MULT, &val, 1); - status = intel_sdvo_read_response(output, NULL, 0); + intel_sdvo_write_cmd(intel_output, SDVO_CMD_SET_CLOCK_RATE_MULT, &val, 1); + status = intel_sdvo_read_response(intel_output, NULL, 0); if (status != SDVO_CMD_STATUS_SUCCESS) return false; return true; } -static bool intel_sdvo_mode_fixup(struct drm_output *output, +static bool intel_sdvo_mode_fixup(struct drm_connector *connector, struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode) { @@ -556,15 +550,15 @@ static bool intel_sdvo_mode_fixup(struct drm_output *output, return true; } -static void intel_sdvo_mode_set(struct drm_output *output, +static void intel_sdvo_mode_set(struct drm_connector *connector, struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; struct drm_i915_private *dev_priv = dev->dev_private; - struct drm_crtc *crtc = output->crtc; + struct drm_crtc *crtc = connector->crtc; struct intel_crtc *intel_crtc = to_intel_crtc(crtc); - struct intel_output *intel_output = to_intel_output(output); + struct intel_output *intel_output = to_intel_output(connector); struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; u16 width, height; u16 h_blank_len, h_sync_len, v_blank_len, v_sync_len; @@ -618,11 +612,11 @@ static void intel_sdvo_mode_set(struct drm_output *output, output_dtd.part2.reserved = 0; /* Set the output timing to the screen */ - intel_sdvo_set_target_output(output, sdvo_priv->active_outputs); - intel_sdvo_set_output_timing(output, &output_dtd); + intel_sdvo_set_target_output(intel_output, sdvo_priv->active_outputs); + intel_sdvo_set_output_timing(intel_output, &output_dtd); /* Set the input timing to the screen. Assume always input 0. */ - intel_sdvo_set_target_input(output, true, false); + intel_sdvo_set_target_input(intel_output, true, false); /* We would like to use i830_sdvo_create_preferred_input_timing() to * provide the device with a timing it can support, if it supports that @@ -630,29 +624,29 @@ static void intel_sdvo_mode_set(struct drm_output *output, * output the preferred timing, and we don't support that currently. */ #if 0 - success = intel_sdvo_create_preferred_input_timing(output, clock, + success = intel_sdvo_create_preferred_input_timing(connector, clock, width, height); if (success) { struct intel_sdvo_dtd *input_dtd; - intel_sdvo_get_preferred_input_timing(output, &input_dtd); - intel_sdvo_set_input_timing(output, &input_dtd); + intel_sdvo_get_preferred_input_timing(connector, &input_dtd); + intel_sdvo_set_input_timing(connector, &input_dtd); } #else - intel_sdvo_set_input_timing(output, &output_dtd); + intel_sdvo_set_input_timing(intel_output, &output_dtd); #endif switch (intel_sdvo_get_pixel_multiplier(mode)) { case 1: - intel_sdvo_set_clock_rate_mult(output, + intel_sdvo_set_clock_rate_mult(intel_output, SDVO_CLOCK_RATE_MULT_1X); break; case 2: - intel_sdvo_set_clock_rate_mult(output, + intel_sdvo_set_clock_rate_mult(intel_output, SDVO_CLOCK_RATE_MULT_2X); break; case 4: - intel_sdvo_set_clock_rate_mult(output, + intel_sdvo_set_clock_rate_mult(intel_output, SDVO_CLOCK_RATE_MULT_4X); break; } @@ -686,26 +680,26 @@ static void intel_sdvo_mode_set(struct drm_output *output, sdvox |= (sdvo_pixel_multiply - 1) << SDVO_PORT_MULTIPLY_SHIFT; } - intel_sdvo_write_sdvox(output, sdvox); + intel_sdvo_write_sdvox(intel_output, sdvox); } -static void intel_sdvo_dpms(struct drm_output *output, int mode) +static void intel_sdvo_dpms(struct drm_connector *connector, int mode) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; struct drm_i915_private *dev_priv = dev->dev_private; - struct intel_output *intel_output = to_intel_output(output); + struct intel_output *intel_output = to_intel_output(connector); struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; u32 temp; if (mode != DPMSModeOn) { - intel_sdvo_set_active_outputs(output, 0); + intel_sdvo_set_active_outputs(intel_output, 0); if (0) - intel_sdvo_set_encoder_power_state(output, mode); + intel_sdvo_set_encoder_power_state(intel_output, mode); if (mode == DPMSModeOff) { temp = I915_READ(sdvo_priv->output_device); if ((temp & SDVO_ENABLE) != 0) { - intel_sdvo_write_sdvox(output, temp & ~SDVO_ENABLE); + intel_sdvo_write_sdvox(intel_output, temp & ~SDVO_ENABLE); } } } else { @@ -715,11 +709,11 @@ static void intel_sdvo_dpms(struct drm_output *output, int mode) temp = I915_READ(sdvo_priv->output_device); if ((temp & SDVO_ENABLE) == 0) - intel_sdvo_write_sdvox(output, temp | SDVO_ENABLE); + intel_sdvo_write_sdvox(intel_output, temp | SDVO_ENABLE); for (i = 0; i < 2; i++) intel_wait_for_vblank(dev); - status = intel_sdvo_get_trained_inputs(output, &input1, + status = intel_sdvo_get_trained_inputs(intel_output, &input1, &input2); @@ -733,32 +727,32 @@ static void intel_sdvo_dpms(struct drm_output *output, int mode) } if (0) - intel_sdvo_set_encoder_power_state(output, mode); - intel_sdvo_set_active_outputs(output, sdvo_priv->active_outputs); + intel_sdvo_set_encoder_power_state(intel_output, mode); + intel_sdvo_set_active_outputs(intel_output, sdvo_priv->active_outputs); } return; } -static void intel_sdvo_save(struct drm_output *output) +static void intel_sdvo_save(struct drm_connector *connector) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; struct drm_i915_private *dev_priv = dev->dev_private; - struct intel_output *intel_output = to_intel_output(output); + struct intel_output *intel_output = to_intel_output(connector); struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; int o; - sdvo_priv->save_sdvo_mult = intel_sdvo_get_clock_rate_mult(output); - intel_sdvo_get_active_outputs(output, &sdvo_priv->save_active_outputs); + sdvo_priv->save_sdvo_mult = intel_sdvo_get_clock_rate_mult(intel_output); + intel_sdvo_get_active_outputs(intel_output, &sdvo_priv->save_active_outputs); if (sdvo_priv->caps.sdvo_inputs_mask & 0x1) { - intel_sdvo_set_target_input(output, true, false); - intel_sdvo_get_input_timing(output, + intel_sdvo_set_target_input(intel_output, true, false); + intel_sdvo_get_input_timing(intel_output, &sdvo_priv->save_input_dtd_1); } if (sdvo_priv->caps.sdvo_inputs_mask & 0x2) { - intel_sdvo_set_target_input(output, false, true); - intel_sdvo_get_input_timing(output, + intel_sdvo_set_target_input(intel_output, false, true); + intel_sdvo_get_input_timing(intel_output, &sdvo_priv->save_input_dtd_2); } @@ -767,8 +761,8 @@ static void intel_sdvo_save(struct drm_output *output) u16 this_output = (1 << o); if (sdvo_priv->caps.output_flags & this_output) { - intel_sdvo_set_target_output(output, this_output); - intel_sdvo_get_output_timing(output, + intel_sdvo_set_target_output(intel_output, this_output); + intel_sdvo_get_output_timing(intel_output, &sdvo_priv->save_output_dtd[o]); } } @@ -776,39 +770,39 @@ static void intel_sdvo_save(struct drm_output *output) sdvo_priv->save_SDVOX = I915_READ(sdvo_priv->output_device); } -static void intel_sdvo_restore(struct drm_output *output) +static void intel_sdvo_restore(struct drm_connector *connector) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; struct drm_i915_private *dev_priv = dev->dev_private; - struct intel_output *intel_output = to_intel_output(output); + struct intel_output *intel_output = to_intel_output(connector); struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; int o; int i; bool input1, input2; u8 status; - intel_sdvo_set_active_outputs(output, 0); + intel_sdvo_set_active_outputs(intel_output, 0); for (o = SDVO_OUTPUT_FIRST; o <= SDVO_OUTPUT_LAST; o++) { u16 this_output = (1 << o); if (sdvo_priv->caps.output_flags & this_output) { - intel_sdvo_set_target_output(output, this_output); - intel_sdvo_set_output_timing(output, &sdvo_priv->save_output_dtd[o]); + intel_sdvo_set_target_output(intel_output, this_output); + intel_sdvo_set_output_timing(intel_output, &sdvo_priv->save_output_dtd[o]); } } if (sdvo_priv->caps.sdvo_inputs_mask & 0x1) { - intel_sdvo_set_target_input(output, true, false); - intel_sdvo_set_input_timing(output, &sdvo_priv->save_input_dtd_1); + intel_sdvo_set_target_input(intel_output, true, false); + intel_sdvo_set_input_timing(intel_output, &sdvo_priv->save_input_dtd_1); } if (sdvo_priv->caps.sdvo_inputs_mask & 0x2) { - intel_sdvo_set_target_input(output, false, true); - intel_sdvo_set_input_timing(output, &sdvo_priv->save_input_dtd_2); + intel_sdvo_set_target_input(intel_output, false, true); + intel_sdvo_set_input_timing(intel_output, &sdvo_priv->save_input_dtd_2); } - intel_sdvo_set_clock_rate_mult(output, sdvo_priv->save_sdvo_mult); + intel_sdvo_set_clock_rate_mult(intel_output, sdvo_priv->save_sdvo_mult); I915_WRITE(sdvo_priv->output_device, sdvo_priv->save_SDVOX); @@ -816,19 +810,19 @@ static void intel_sdvo_restore(struct drm_output *output) { for (i = 0; i < 2; i++) intel_wait_for_vblank(dev); - status = intel_sdvo_get_trained_inputs(output, &input1, &input2); + status = intel_sdvo_get_trained_inputs(intel_output, &input1, &input2); if (status == SDVO_CMD_STATUS_SUCCESS && !input1) DRM_DEBUG("First %s output reported failure to sync\n", SDVO_NAME(sdvo_priv)); } - intel_sdvo_set_active_outputs(output, sdvo_priv->save_active_outputs); + intel_sdvo_set_active_outputs(intel_output, sdvo_priv->save_active_outputs); } -static int intel_sdvo_mode_valid(struct drm_output *output, +static int intel_sdvo_mode_valid(struct drm_connector *connector, struct drm_display_mode *mode) { - struct intel_output *intel_output = to_intel_output(output); + struct intel_output *intel_output = to_intel_output(connector); struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; if (mode->flags & V_DBLSCAN) @@ -843,27 +837,27 @@ static int intel_sdvo_mode_valid(struct drm_output *output, return MODE_OK; } -static bool intel_sdvo_get_capabilities(struct drm_output *output, struct intel_sdvo_caps *caps) +static bool intel_sdvo_get_capabilities(struct intel_output *intel_output, struct intel_sdvo_caps *caps) { u8 status; - intel_sdvo_write_cmd(output, SDVO_CMD_GET_DEVICE_CAPS, NULL, 0); - status = intel_sdvo_read_response(output, caps, sizeof(*caps)); + intel_sdvo_write_cmd(intel_output, SDVO_CMD_GET_DEVICE_CAPS, NULL, 0); + status = intel_sdvo_read_response(intel_output, caps, sizeof(*caps)); if (status != SDVO_CMD_STATUS_SUCCESS) return false; return true; } -struct drm_output* intel_sdvo_find(struct drm_device *dev, int sdvoB) +struct drm_connector* intel_sdvo_find(struct drm_device *dev, int sdvoB) { - struct drm_output *output = 0; - struct intel_output *iout = 0; + struct drm_connector *connector = NULL; + struct intel_output *iout = NULL; struct intel_sdvo_priv *sdvo; - /* find the sdvo output */ - list_for_each_entry(output, &dev->mode_config.output_list, head) { - iout = to_intel_output(output); + /* find the sdvo connector */ + list_for_each_entry(connector, &dev->mode_config.connector_list, head) { + iout = to_intel_output(connector); if (iout->type != INTEL_OUTPUT_SDVO) continue; @@ -871,27 +865,30 @@ struct drm_output* intel_sdvo_find(struct drm_device *dev, int sdvoB) sdvo = iout->dev_priv; if (sdvo->output_device == SDVOB && sdvoB) - return output; + return connector; if (sdvo->output_device == SDVOC && !sdvoB) - return output; + return connector; - } - - return 0; + } + + return NULL; } -int intel_sdvo_supports_hotplug(struct drm_output *output) +int intel_sdvo_supports_hotplug(struct drm_connector *connector) { u8 response[2]; u8 status; + struct intel_output *intel_output; DRM_DEBUG("\n"); - if (!output) + if (!connector) return 0; - intel_sdvo_write_cmd(output, SDVO_CMD_GET_HOT_PLUG_SUPPORT, NULL, 0); - status = intel_sdvo_read_response(output, &response, 2); + intel_output = to_intel_output(connector); + + intel_sdvo_write_cmd(intel_output, SDVO_CMD_GET_HOT_PLUG_SUPPORT, NULL, 0); + status = intel_sdvo_read_response(intel_output, &response, 2); if (response[0] !=0) return 1; @@ -899,51 +896,55 @@ int intel_sdvo_supports_hotplug(struct drm_output *output) return 0; } -void intel_sdvo_set_hotplug(struct drm_output *output, int on) +void intel_sdvo_set_hotplug(struct drm_connector *connector, int on) { u8 response[2]; u8 status; + struct intel_output *intel_output = to_intel_output(connector); - intel_sdvo_write_cmd(output, SDVO_CMD_GET_ACTIVE_HOT_PLUG, NULL, 0); - intel_sdvo_read_response(output, &response, 2); + intel_sdvo_write_cmd(intel_output, SDVO_CMD_GET_ACTIVE_HOT_PLUG, NULL, 0); + intel_sdvo_read_response(intel_output, &response, 2); if (on) { - intel_sdvo_write_cmd(output, SDVO_CMD_GET_HOT_PLUG_SUPPORT, NULL, 0); - status = intel_sdvo_read_response(output, &response, 2); + intel_sdvo_write_cmd(intel_output, SDVO_CMD_GET_HOT_PLUG_SUPPORT, NULL, 0); + status = intel_sdvo_read_response(intel_output, &response, 2); - intel_sdvo_write_cmd(output, SDVO_CMD_SET_ACTIVE_HOT_PLUG, &response, 2); + intel_sdvo_write_cmd(intel_output, SDVO_CMD_SET_ACTIVE_HOT_PLUG, &response, 2); } else { response[0] = 0; response[1] = 0; - intel_sdvo_write_cmd(output, SDVO_CMD_SET_ACTIVE_HOT_PLUG, &response, 2); + intel_sdvo_write_cmd(intel_output, SDVO_CMD_SET_ACTIVE_HOT_PLUG, &response, 2); } - intel_sdvo_write_cmd(output, SDVO_CMD_GET_ACTIVE_HOT_PLUG, NULL, 0); - intel_sdvo_read_response(output, &response, 2); + intel_sdvo_write_cmd(intel_output, SDVO_CMD_GET_ACTIVE_HOT_PLUG, NULL, 0); + intel_sdvo_read_response(intel_output, &response, 2); } -static enum drm_output_status intel_sdvo_detect(struct drm_output *output) +static enum drm_connector_status intel_sdvo_detect(struct drm_connector *connector) { u8 response[2]; u8 status; + struct intel_output *intel_output = to_intel_output(connector); - intel_sdvo_write_cmd(output, SDVO_CMD_GET_ATTACHED_DISPLAYS, NULL, 0); - status = intel_sdvo_read_response(output, &response, 2); + intel_sdvo_write_cmd(intel_output, SDVO_CMD_GET_ATTACHED_DISPLAYS, NULL, 0); + status = intel_sdvo_read_response(intel_output, &response, 2); DRM_DEBUG("SDVO response %d %d\n", response[0], response[1]); if ((response[0] != 0) || (response[1] != 0)) - return output_status_connected; + return connector_status_connected; else - return output_status_disconnected; + return connector_status_disconnected; } -static int intel_sdvo_get_modes(struct drm_output *output) +static int intel_sdvo_get_modes(struct drm_connector *connector) { + struct intel_output *intel_output = to_intel_output(connector); + /* set the bus switch and get the modes */ - intel_sdvo_set_control_bus_switch(output, SDVO_CONTROL_BUS_DDC2); - intel_ddc_get_modes(output); + intel_sdvo_set_control_bus_switch(intel_output, SDVO_CONTROL_BUS_DDC2); + intel_ddc_get_modes(intel_output); - if (list_empty(&output->probed_modes)) + if (list_empty(&connector->probed_modes)) return 0; return 1; #if 0 @@ -959,25 +960,25 @@ static int intel_sdvo_get_modes(struct drm_output *output) #endif } -static void intel_sdvo_destroy(struct drm_output *output) +static void intel_sdvo_destroy(struct drm_connector *connector) { - struct intel_output *intel_output = to_intel_output(output); + struct intel_output *intel_output = to_intel_output(connector); if (intel_output->i2c_bus) intel_i2c_destroy(intel_output->i2c_bus); - drm_output_cleanup(output); + drm_connector_cleanup(connector); kfree(intel_output); } -static const struct drm_output_helper_funcs intel_sdvo_helper_funcs = { +static const struct drm_connector_helper_funcs intel_sdvo_helper_funcs = { .mode_fixup = intel_sdvo_mode_fixup, - .prepare = intel_output_prepare, + .prepare = intel_connector_prepare, .mode_set = intel_sdvo_mode_set, - .commit = intel_output_commit, + .commit = intel_connector_commit, }; -static const struct drm_output_funcs intel_sdvo_output_funcs = { +static const struct drm_connector_funcs intel_sdvo_connector_funcs = { .dpms = intel_sdvo_dpms, .save = intel_sdvo_save, .restore = intel_sdvo_restore, @@ -987,32 +988,43 @@ static const struct drm_output_funcs intel_sdvo_output_funcs = { .mode_valid = intel_sdvo_mode_valid, }; + +void intel_sdvo_enc_destroy(struct drm_encoder *encoder) +{ + drm_encoder_cleanup(encoder); +} + +static const struct drm_encoder_funcs intel_sdvo_enc_funcs = { + .destroy = intel_sdvo_enc_destroy, +}; + + void intel_sdvo_init(struct drm_device *dev, int output_device) { - struct drm_output *output; + struct drm_connector *connector; struct intel_output *intel_output; struct intel_sdvo_priv *sdvo_priv; struct intel_i2c_chan *i2cbus = NULL; int connector_type; u8 ch[0x40]; int i; - int output_type, output_id; + int encoder_type, output_id; intel_output = kcalloc(sizeof(struct intel_output)+sizeof(struct intel_sdvo_priv), 1, GFP_KERNEL); if (!intel_output) { return; } - output = &intel_output->base; + connector = &intel_output->base; - drm_output_init(dev, output, &intel_sdvo_output_funcs, - DRM_MODE_OUTPUT_NONE); + drm_connector_init(dev, connector, &intel_sdvo_connector_funcs, + DRM_MODE_CONNECTOR_Unknown); sdvo_priv = (struct intel_sdvo_priv *)(intel_output + 1); intel_output->type = INTEL_OUTPUT_SDVO; - drm_output_helper_add(output, &intel_sdvo_helper_funcs); - output->interlace_allowed = 0; - output->doublescan_allowed = 0; + drm_connector_helper_add(connector, &intel_sdvo_helper_funcs); + connector->interlace_allowed = 0; + connector->doublescan_allowed = 0; /* setup the DDC bus. */ if (output_device == SDVOB) @@ -1021,7 +1033,7 @@ void intel_sdvo_init(struct drm_device *dev, int output_device) i2cbus = intel_i2c_create(dev, GPIOE, "SDVOCTRL_E for SDVOC"); if (i2cbus == NULL) { - intel_sdvo_destroy(output); + intel_sdvo_destroy(connector); return; } @@ -1042,15 +1054,15 @@ void intel_sdvo_init(struct drm_device *dev, int output_device) /* Read the regs to test if we can talk to the device */ for (i = 0; i < 0x40; i++) { - if (!intel_sdvo_read_byte(output, i, &ch[i])) { + if (!intel_sdvo_read_byte(intel_output, i, &ch[i])) { DRM_DEBUG("No SDVO device found on SDVO%c\n", output_device == SDVOB ? 'B' : 'C'); - intel_sdvo_destroy(output); + intel_sdvo_destroy(connector); return; } } - intel_sdvo_get_capabilities(output, &sdvo_priv->caps); + intel_sdvo_get_capabilities(intel_output, &sdvo_priv->caps); memset(&sdvo_priv->active_outputs, 0, sizeof(sdvo_priv->active_outputs)); @@ -1058,30 +1070,30 @@ void intel_sdvo_init(struct drm_device *dev, int output_device) if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_RGB0) { sdvo_priv->active_outputs = SDVO_OUTPUT_RGB0; - output->display_info.subpixel_order = SubPixelHorizontalRGB; - output_type = DRM_MODE_OUTPUT_VGA; - connector_type = ConnectorVGA; + connector->display_info.subpixel_order = SubPixelHorizontalRGB; + encoder_type = DRM_MODE_ENCODER_DAC; + connector_type = DRM_MODE_CONNECTOR_VGA; } else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_RGB1) { sdvo_priv->active_outputs = SDVO_OUTPUT_RGB1; - output->display_info.subpixel_order = SubPixelHorizontalRGB; - output_type = DRM_MODE_OUTPUT_VGA; - connector_type = ConnectorVGA; + connector->display_info.subpixel_order = SubPixelHorizontalRGB; + encoder_type = DRM_MODE_ENCODER_DAC; + connector_type = DRM_MODE_CONNECTOR_VGA; } else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_TMDS0) { sdvo_priv->active_outputs = SDVO_OUTPUT_TMDS0; - output->display_info.subpixel_order = SubPixelHorizontalRGB; - output_type = DRM_MODE_OUTPUT_TMDS; - connector_type = ConnectorDVID; + connector->display_info.subpixel_order = SubPixelHorizontalRGB; + encoder_type = DRM_MODE_ENCODER_TMDS; + connector_type = DRM_MODE_CONNECTOR_DVID; } else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_TMDS1) { sdvo_priv->active_outputs = SDVO_OUTPUT_TMDS1; - output->display_info.subpixel_order = SubPixelHorizontalRGB; - output_type = DRM_MODE_OUTPUT_TMDS; - connector_type = ConnectorDVID; + connector->display_info.subpixel_order = SubPixelHorizontalRGB; + encoder_type = DRM_MODE_ENCODER_TMDS; + connector_type = DRM_MODE_CONNECTOR_DVID; } else { @@ -1091,19 +1103,19 @@ void intel_sdvo_init(struct drm_device *dev, int output_device) DRM_DEBUG("%s: No active RGB or TMDS outputs (0x%02x%02x)\n", SDVO_NAME(sdvo_priv), bytes[0], bytes[1]); - intel_sdvo_destroy(output); + intel_sdvo_destroy(connector); return; } - output->output_type = output_type; - output->output_type_id = output_id; + drm_encoder_init(dev, &intel_output->enc, &intel_sdvo_enc_funcs, encoder_type); + connector->connector_type = connector_type; - drm_sysfs_output_add(output); + drm_sysfs_connector_add(connector); /* Set the input timing to the screen. Assume always input 0. */ - intel_sdvo_set_target_input(output, true, false); + intel_sdvo_set_target_input(intel_output, true, false); - intel_sdvo_get_input_pixel_clock_range(output, + intel_sdvo_get_input_pixel_clock_range(intel_output, &sdvo_priv->pixel_clock_min, &sdvo_priv->pixel_clock_max); @@ -1127,5 +1139,4 @@ void intel_sdvo_init(struct drm_device *dev, int output_device) intel_output->ddc_bus = i2cbus; - drm_output_attach_property(output, dev->mode_config.connector_type_property, connector_type); } diff --git a/linux-core/intel_tv.c b/linux-core/intel_tv.c index e3e78a9f..330c204a 100644 --- a/linux-core/intel_tv.c +++ b/linux-core/intel_tv.c @@ -898,9 +898,9 @@ const static struct tv_mode tv_modes[] = { #define NUM_TV_MODES sizeof(tv_modes) / sizeof (tv_modes[0]) static void -intel_tv_dpms(struct drm_output *output, int mode) +intel_tv_dpms(struct drm_connector *connector, int mode) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; struct drm_i915_private *dev_priv = dev->dev_private; switch(mode) { @@ -916,11 +916,11 @@ intel_tv_dpms(struct drm_output *output, int mode) } static void -intel_tv_save(struct drm_output *output) +intel_tv_save(struct drm_connector *connector) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; struct drm_i915_private *dev_priv = dev->dev_private; - struct intel_output *intel_output = to_intel_output(output); + struct intel_output *intel_output = to_intel_output(connector); struct intel_tv_priv *tv_priv = intel_output->dev_priv; int i; @@ -966,13 +966,13 @@ intel_tv_save(struct drm_output *output) } static void -intel_tv_restore(struct drm_output *output) +intel_tv_restore(struct drm_connector *connector) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; struct drm_i915_private *dev_priv = dev->dev_private; - struct intel_output *intel_output = to_intel_output(output); + struct intel_output *intel_output = to_intel_output(connector); struct intel_tv_priv *tv_priv = intel_output->dev_priv; - struct drm_crtc *crtc = output->crtc; + struct drm_crtc *crtc = connector->crtc; struct intel_crtc *intel_crtc; int i; @@ -1067,18 +1067,18 @@ intel_tv_mode_lookup (char *tv_format) } static const struct tv_mode * -intel_tv_mode_find (struct drm_output *output) +intel_tv_mode_find (struct intel_output *intel_output) { - struct intel_output *intel_output = to_intel_output(output); struct intel_tv_priv *tv_priv = intel_output->dev_priv; return intel_tv_mode_lookup(tv_priv->tv_format); } static enum drm_mode_status -intel_tv_mode_valid(struct drm_output *output, struct drm_display_mode *mode) +intel_tv_mode_valid(struct drm_connector *connector, struct drm_display_mode *mode) { - const struct tv_mode *tv_mode = intel_tv_mode_find(output); + struct intel_output *intel_output = to_intel_output(connector); + const struct tv_mode *tv_mode = intel_tv_mode_find(intel_output); /* Ensure TV refresh is close to desired refresh */ if (tv_mode && abs(tv_mode->refresh - drm_mode_vrefresh(mode)) < 1) @@ -1088,21 +1088,22 @@ intel_tv_mode_valid(struct drm_output *output, struct drm_display_mode *mode) static bool -intel_tv_mode_fixup(struct drm_output *output, struct drm_display_mode *mode, +intel_tv_mode_fixup(struct drm_connector *connector, struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; struct drm_mode_config *drm_config = &dev->mode_config; - const struct tv_mode *tv_mode = intel_tv_mode_find (output); - struct drm_output *other_output; + struct intel_output *intel_output = to_intel_output(connector); + const struct tv_mode *tv_mode = intel_tv_mode_find (intel_output); + struct drm_connector *other_connector; if (!tv_mode) return FALSE; - /* FIXME: lock output list */ - list_for_each_entry(other_output, &drm_config->output_list, head) { - if (other_output != output && - other_output->crtc == output->crtc) + /* FIXME: lock connector list */ + list_for_each_entry(other_connector, &drm_config->connector_list, head) { + if (other_connector != connector && + other_connector->crtc == connector->crtc) return FALSE; } @@ -1111,16 +1112,16 @@ intel_tv_mode_fixup(struct drm_output *output, struct drm_display_mode *mode, } static void -intel_tv_mode_set(struct drm_output *output, struct drm_display_mode *mode, +intel_tv_mode_set(struct drm_connector *connector, struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; struct drm_i915_private *dev_priv = dev->dev_private; - struct drm_crtc *crtc = output->crtc; + struct drm_crtc *crtc = connector->crtc; struct intel_crtc *intel_crtc = to_intel_crtc(crtc); - struct intel_output *intel_output = to_intel_output(output); + struct intel_output *intel_output = to_intel_output(connector); struct intel_tv_priv *tv_priv = intel_output->dev_priv; - const struct tv_mode *tv_mode = intel_tv_mode_find(output); + const struct tv_mode *tv_mode = intel_tv_mode_find(intel_output); u32 tv_ctl; u32 hctl1, hctl2, hctl3; u32 vctl1, vctl2, vctl3, vctl4, vctl5, vctl6, vctl7; @@ -1137,14 +1138,14 @@ intel_tv_mode_set(struct drm_output *output, struct drm_display_mode *mode, switch (tv_priv->type) { default: - case ConnectorUnknown: - case ConnectorComposite: + case DRM_MODE_CONNECTOR_Unknown: + case DRM_MODE_CONNECTOR_Composite: tv_ctl |= TV_ENC_OUTPUT_COMPOSITE; video_levels = tv_mode->composite_levels; color_conversion = tv_mode->composite_color; burst_ena = tv_mode->burst_ena; break; - case ConnectorComponent: + case DRM_MODE_CONNECTOR_Component: tv_ctl |= TV_ENC_OUTPUT_COMPONENT; video_levels = &component_levels; if (tv_mode->burst_ena) @@ -1153,7 +1154,7 @@ intel_tv_mode_set(struct drm_output *output, struct drm_display_mode *mode, color_conversion = &hdtv_csc_yprpb; burst_ena = FALSE; break; - case ConnectorSVIDEO: + case DRM_MODE_CONNECTOR_SVIDEO: tv_ctl |= TV_ENC_OUTPUT_SVIDEO; video_levels = tv_mode->svideo_levels; color_conversion = tv_mode->svideo_color; @@ -1355,15 +1356,15 @@ static const struct drm_display_mode reported_modes[] = { * \return FALSE if TV is disconnected. */ static int -intel_tv_detect_type (struct drm_crtc *crtc, struct drm_output *output) +intel_tv_detect_type (struct drm_crtc *crtc, struct drm_connector *connector) { - struct drm_device *dev = output->dev; + struct drm_device *dev = connector->dev; struct drm_i915_private *dev_priv = dev->dev_private; - struct intel_output *intel_output = to_intel_output(output); + struct intel_output *intel_output = to_intel_output(connector); u32 pipeastat, pipeastat_save; u32 tv_ctl, save_tv_ctl; u32 tv_dac, save_tv_dac; - int type = ConnectorUnknown; + int type = DRM_MODE_CONNECTOR_Unknown; tv_dac = I915_READ(TV_DAC); @@ -1410,13 +1411,13 @@ intel_tv_detect_type (struct drm_crtc *crtc, struct drm_output *output) */ if ((tv_dac & TVDAC_SENSE_MASK) == (TVDAC_B_SENSE | TVDAC_C_SENSE)) { DRM_DEBUG("Detected Composite TV connection\n"); - type = ConnectorComposite; + type = DRM_MODE_CONNECTOR_Composite; } else if ((tv_dac & (TVDAC_A_SENSE|TVDAC_B_SENSE)) == TVDAC_A_SENSE) { DRM_DEBUG("Detected S-Video TV connection\n"); - type = ConnectorSVIDEO; + type = DRM_MODE_CONNECTOR_SVIDEO; } else if ((tv_dac & TVDAC_SENSE_MASK) == 0) { DRM_DEBUG("Detected Component TV connection\n"); - type = ConnectorComponent; + type = DRM_MODE_CONNECTOR_Component; } else { DRM_DEBUG("No TV connection detected\n"); type = -1; @@ -1432,15 +1433,15 @@ intel_tv_detect_type (struct drm_crtc *crtc, struct drm_output *output) /** * Detect the TV connection. * - * Currently this always returns OUTPUT_STATUS_UNKNOWN, as we need to be sure + * Currently this always returns CONNECTOR_STATUS_UNKNOWN, as we need to be sure * we have a pipe programmed in order to probe the TV. */ -static enum drm_output_status -intel_tv_detect(struct drm_output *output) +static enum drm_connector_status +intel_tv_detect(struct drm_connector *connector) { struct drm_crtc *crtc; struct drm_display_mode mode; - struct intel_output *intel_output = to_intel_output(output); + struct intel_output *intel_output = to_intel_output(connector); struct intel_tv_priv *tv_priv = intel_output->dev_priv; int dpms_mode; int type = tv_priv->type; @@ -1448,30 +1449,31 @@ intel_tv_detect(struct drm_output *output) mode = reported_modes[0]; drm_mode_set_crtcinfo(&mode, CRTC_INTERLACE_HALVE_V); - if (output->crtc) { - type = intel_tv_detect_type(output->crtc, output); + if (connector->crtc) { + type = intel_tv_detect_type(connector->crtc, connector); } else { - crtc = intel_get_load_detect_pipe(output, &mode, &dpms_mode); + crtc = intel_get_load_detect_pipe(connector, &mode, &dpms_mode); if (crtc) { - type = intel_tv_detect_type(crtc, output); - intel_release_load_detect_pipe(output, dpms_mode); + type = intel_tv_detect_type(crtc, connector); + intel_release_load_detect_pipe(connector, dpms_mode); } else type = -1; } +#if 0 if (type != tv_priv->type) { struct drm_property *connector_property = - output->dev->mode_config.connector_type_property; + connector->dev->mode_config.connector_type_property; tv_priv->type = type; - drm_output_property_set_value(output, connector_property, + drm_connector_property_set_value(connector, connector_property, type); } - +#endif if (type < 0) - return output_status_disconnected; + return connector_status_disconnected; - return output_status_connected; + return connector_status_connected; } static struct input_res { @@ -1496,10 +1498,11 @@ static struct input_res { */ static int -intel_tv_get_modes(struct drm_output *output) +intel_tv_get_modes(struct drm_connector *connector) { struct drm_display_mode *mode_ptr; - const struct tv_mode *tv_mode = intel_tv_mode_find(output); + struct intel_output *intel_output = to_intel_output(connector); + const struct tv_mode *tv_mode = intel_tv_mode_find(intel_output); int j; for (j = 0; j < sizeof(input_res_table) / sizeof(input_res_table[0]); @@ -1538,33 +1541,33 @@ intel_tv_get_modes(struct drm_output *output) mode_ptr->htotal / 1000) / 1000; mode_ptr->type = DRM_MODE_TYPE_DRIVER; - drm_mode_probed_add(output, mode_ptr); + drm_mode_probed_add(connector, mode_ptr); } return 0; } static void -intel_tv_destroy (struct drm_output *output) +intel_tv_destroy (struct drm_connector *connector) { - struct intel_output *intel_output = to_intel_output(output); + struct intel_output *intel_output = to_intel_output(connector); - drm_output_cleanup(output); + drm_connector_cleanup(connector); drm_free(intel_output, sizeof(struct intel_output) + sizeof(struct intel_tv_priv), DRM_MEM_DRIVER); } static bool -intel_tv_set_property(struct drm_output *output, struct drm_property *property, +intel_tv_set_property(struct drm_connector *connector, struct drm_property *property, uint64_t val) { - struct drm_device *dev = output->dev; - struct intel_output *intel_output = to_intel_output(output); + struct drm_device *dev = connector->dev; + struct intel_output *intel_output = to_intel_output(connector); struct intel_tv_priv *tv_priv = intel_output->dev_priv; int ret = 0; - ret = drm_output_property_set_value(output, property, val); + ret = drm_connector_property_set_value(connector, property, val); if (ret < 0) goto out; @@ -1582,25 +1585,25 @@ intel_tv_set_property(struct drm_output *output, struct drm_property *property, goto out; } tv_priv->tv_format = tv_modes[val].name; - intel_tv_mode_set(output, NULL, NULL); + intel_tv_mode_set(connector, NULL, NULL); } else { ret = -EINVAL; goto out; } - intel_tv_mode_set(output, NULL, NULL); + intel_tv_mode_set(connector, NULL, NULL); out: return ret; } -static const struct drm_output_helper_funcs intel_tv_helper_funcs = { +static const struct drm_connector_helper_funcs intel_tv_helper_funcs = { .mode_fixup = intel_tv_mode_fixup, - .prepare = intel_output_prepare, + .prepare = intel_connector_prepare, .mode_set = intel_tv_mode_set, - .commit = intel_output_commit, + .commit = intel_connector_commit, }; -static const struct drm_output_funcs intel_tv_output_funcs = { +static const struct drm_connector_funcs intel_tv_connector_funcs = { .dpms = intel_tv_dpms, .save = intel_tv_save, .restore = intel_tv_restore, @@ -1615,7 +1618,7 @@ void intel_tv_init(struct drm_device *dev) { struct drm_i915_private *dev_priv = dev->dev_private; - struct drm_output *output; + struct drm_connector *connector; struct intel_output *intel_output; struct intel_tv_priv *tv_priv; u32 tv_dac_on, tv_dac_off, save_tv_dac; @@ -1657,17 +1660,17 @@ intel_tv_init(struct drm_device *dev) if (!intel_output) { return; } - output = &intel_output->base; + connector = &intel_output->base; - drm_output_init(dev, output, &intel_tv_output_funcs, - DRM_MODE_OUTPUT_TVDAC); + drm_connector_init(dev, connector, &intel_tv_connector_funcs, + DRM_MODE_CONNECTOR_Unknown); tv_priv = (struct intel_tv_priv *)(intel_output + 1); intel_output->type = INTEL_OUTPUT_TVOUT; - output->possible_crtcs = ((1 << 0) | (1 << 1)); - output->possible_clones = (1 << INTEL_OUTPUT_TVOUT); + connector->possible_crtcs = ((1 << 0) | (1 << 1)); + connector->possible_clones = (1 << INTEL_OUTPUT_TVOUT); intel_output->dev_priv = tv_priv; - tv_priv->type = ConnectorUnknown; + tv_priv->type = DRM_MODE_CONNECTOR_Unknown; /* BIOS margin values */ tv_priv->margin[TV_MARGIN_LEFT] = 54; @@ -1677,13 +1680,9 @@ intel_tv_init(struct drm_device *dev) tv_priv->tv_format = kstrdup(tv_modes[initial_mode].name, GFP_KERNEL); - drm_output_helper_add(output, &intel_tv_helper_funcs); - output->interlace_allowed = FALSE; - output->doublescan_allowed = FALSE; - - drm_output_attach_property(output, - dev->mode_config.connector_type_property, - ConnectorUnknown); + drm_connector_helper_add(connector, &intel_tv_helper_funcs); + connector->interlace_allowed = FALSE; + connector->doublescan_allowed = FALSE; /* Create TV properties then attach current values */ tv_format_names = drm_alloc(sizeof(char *) * NUM_TV_MODES, @@ -1694,20 +1693,20 @@ intel_tv_init(struct drm_device *dev) tv_format_names[i] = tv_modes[i].name; drm_create_tv_properties(dev, NUM_TV_MODES, tv_format_names); - drm_output_attach_property(output, dev->mode_config.tv_mode_property, + drm_connector_attach_property(connector, dev->mode_config.tv_mode_property, initial_mode); - drm_output_attach_property(output, + drm_connector_attach_property(connector, dev->mode_config.tv_left_margin_property, tv_priv->margin[TV_MARGIN_LEFT]); - drm_output_attach_property(output, + drm_connector_attach_property(connector, dev->mode_config.tv_top_margin_property, tv_priv->margin[TV_MARGIN_TOP]); - drm_output_attach_property(output, + drm_connector_attach_property(connector, dev->mode_config.tv_right_margin_property, tv_priv->margin[TV_MARGIN_RIGHT]); - drm_output_attach_property(output, + drm_connector_attach_property(connector, dev->mode_config.tv_bottom_margin_property, tv_priv->margin[TV_MARGIN_BOTTOM]); out: - drm_sysfs_output_add(output); + drm_sysfs_connector_add(connector); } diff --git a/shared-core/drm.h b/shared-core/drm.h index 0005bb0b..a7f590dc 100644 --- a/shared-core/drm.h +++ b/shared-core/drm.h @@ -558,7 +558,7 @@ union drm_wait_vblank { /* Handle monitor hotplug. * * May want to extend this later to pass reply information which - * details the outputs which generated the hotplug event. + * details the connectors which generated the hotplug event. * Some chipsets can't determine that though, and we'd need to leave * it to the higher levels to determine exactly what changed. */ @@ -998,7 +998,7 @@ struct drm_mm_info_arg { * Drm mode setting */ #define DRM_DISPLAY_INFO_LEN 32 -#define DRM_OUTPUT_NAME_LEN 32 +#define DRM_CONNECTOR_NAME_LEN 32 #define DRM_DISPLAY_MODE_LEN 32 #define DRM_PROP_NAME_LEN 32 @@ -1025,29 +1025,29 @@ struct drm_mode_modeinfo { struct drm_mode_card_res { uint64_t fb_id_ptr; uint64_t crtc_id_ptr; - uint64_t output_id_ptr; + uint64_t connector_id_ptr; uint64_t encoder_id_ptr; int count_fbs; int count_crtcs; - int count_outputs; + int count_connectors; int count_encoders; int min_width, max_width; int min_height, max_height; }; struct drm_mode_crtc { - uint64_t set_outputs_ptr; + uint64_t set_connectors_ptr; unsigned int crtc_id; /**< Id */ unsigned int fb_id; /**< Id of framebuffer */ int x, y; /**< Position on the frameuffer */ - int count_outputs; - unsigned int outputs; /**< Outputs that are connected */ + int count_connectors; + unsigned int connectors; /**< Connectors that are connected */ int count_possibles; - unsigned int possibles; /**< Outputs that can be connected */ + unsigned int possibles; /**< Connectors that can be connected */ int gamma_size; int mode_valid; struct drm_mode_modeinfo mode; @@ -1068,13 +1068,7 @@ struct drm_mode_get_encoder { #define DRM_MODE_ENCODER_LVDS 3 #define DRM_MODE_ENCODER_TVDAC 4 -#define DRM_MODE_OUTPUT_NONE 0 -#define DRM_MODE_OUTPUT_VGA 1 -#define DRM_MODE_OUTPUT_TMDS 2 -#define DRM_MODE_OUTPUT_LVDS 3 -#define DRM_MODE_OUTPUT_TVDAC 4 - -struct drm_mode_get_output { +struct drm_mode_get_connector { uint64_t encoders_ptr; uint64_t modes_ptr; @@ -1085,10 +1079,10 @@ struct drm_mode_get_output { int count_props; int count_encoders; - unsigned int output; /**< Id */ + unsigned int connector; /**< Id */ unsigned int crtc; /**< Id of crtc */ - unsigned int output_type; - unsigned int output_type_id; + unsigned int connector_type; + unsigned int connector_type_id; unsigned int connection; unsigned int mm_width, mm_height; /**< HxW in millimeters */ @@ -1122,10 +1116,10 @@ struct drm_mode_get_property { int count_enum_blobs; }; -struct drm_mode_output_set_property { +struct drm_mode_connector_set_property { uint64_t value; unsigned int prop_id; - unsigned int output_id; + unsigned int connector_id; }; struct drm_mode_get_blob { @@ -1144,7 +1138,7 @@ struct drm_mode_fb_cmd { }; struct drm_mode_mode_cmd { - unsigned int output_id; + unsigned int connector_id; struct drm_mode_modeinfo mode; }; @@ -1280,13 +1274,13 @@ struct drm_mode_hotplug { #define DRM_IOCTL_MODE_GETRESOURCES DRM_IOWR(0xA0, struct drm_mode_card_res) #define DRM_IOCTL_MODE_GETCRTC DRM_IOWR(0xA1, struct drm_mode_crtc) -#define DRM_IOCTL_MODE_GETOUTPUT DRM_IOWR(0xA2, struct drm_mode_get_output) +#define DRM_IOCTL_MODE_GETCONNECTOR DRM_IOWR(0xA2, struct drm_mode_get_connector) #define DRM_IOCTL_MODE_SETCRTC DRM_IOWR(0xA3, struct drm_mode_crtc) #define DRM_IOCTL_MODE_ADDFB DRM_IOWR(0xA4, struct drm_mode_fb_cmd) #define DRM_IOCTL_MODE_RMFB DRM_IOWR(0xA5, unsigned int) #define DRM_IOCTL_MODE_GETFB DRM_IOWR(0xA6, struct drm_mode_fb_cmd) -#define DRM_IOCTL_MODE_SETPROPERTY DRM_IOWR(0xA7, struct drm_mode_output_set_property) +#define DRM_IOCTL_MODE_SETPROPERTY DRM_IOWR(0xA7, struct drm_mode_connector_set_property) #define DRM_IOCTL_MODE_GETPROPBLOB DRM_IOWR(0xA8, struct drm_mode_get_blob) #define DRM_IOCTL_MODE_ATTACHMODE DRM_IOWR(0xA9, struct drm_mode_mode_cmd) #define DRM_IOCTL_MODE_DETACHMODE DRM_IOWR(0xAA, struct drm_mode_mode_cmd) diff --git a/shared-core/i915_irq.c b/shared-core/i915_irq.c index abf916ed..4c147a08 100644 --- a/shared-core/i915_irq.c +++ b/shared-core/i915_irq.c @@ -453,15 +453,15 @@ static spinlock_t hotplug_lock = SPIN_LOCK_UNLOCKED; static void i915_hotplug_tv(struct drm_device *dev) { - struct drm_output *output; + struct drm_connector *connector; struct intel_output *iout; - enum drm_output_status status; + enum drm_connector_status status; mutex_lock(&dev->mode_config.mutex); /* find the crt output */ - list_for_each_entry(output, &dev->mode_config.output_list, head) { - iout = to_intel_output(output); + list_for_each_entry(connector, &dev->mode_config.connector_list, head) { + iout = to_intel_output(connector); if (iout->type == INTEL_OUTPUT_TVOUT) break; else @@ -471,9 +471,9 @@ static void i915_hotplug_tv(struct drm_device *dev) if (iout == 0) goto unlock; - status = output->funcs->detect(output); - drm_helper_hotplug_stage_two(dev, output, - status == output_status_connected ? 1 : 0); + status = connector->funcs->detect(connector); + drm_helper_hotplug_stage_two(dev, connector, + status == connector_status_connected ? 1 : 0); unlock: mutex_unlock(&dev->mode_config.mutex); @@ -481,14 +481,14 @@ unlock: static void i915_hotplug_crt(struct drm_device *dev, bool isconnected) { - struct drm_output *output; + struct drm_connector *connector; struct intel_output *iout; mutex_lock(&dev->mode_config.mutex); /* find the crt output */ - list_for_each_entry(output, &dev->mode_config.output_list, head) { - iout = to_intel_output(output); + list_for_each_entry(connector, &dev->mode_config.connector_list, head) { + iout = to_intel_output(connector); if (iout->type == INTEL_OUTPUT_ANALOG) break; else @@ -498,7 +498,7 @@ static void i915_hotplug_crt(struct drm_device *dev, bool isconnected) if (iout == 0) goto unlock; - drm_helper_hotplug_stage_two(dev, output, isconnected); + drm_helper_hotplug_stage_two(dev, connector, isconnected); unlock: mutex_unlock(&dev->mode_config.mutex); @@ -506,24 +506,24 @@ unlock: static void i915_hotplug_sdvo(struct drm_device *dev, int sdvoB) { - struct drm_output *output = 0; - enum drm_output_status status; + struct drm_connector *connector = 0; + enum drm_connector_status status; mutex_lock(&dev->mode_config.mutex); - output = intel_sdvo_find(dev, sdvoB); + connector = intel_sdvo_find(dev, sdvoB); - if (!output) + if (!connector) goto unlock; - status = output->funcs->detect(output); + status = connector->funcs->detect(connector); - if (status != output_status_connected) - drm_helper_hotplug_stage_two(dev, output, false); + if (status != connector_status_connected) + drm_helper_hotplug_stage_two(dev, connector, false); else - drm_helper_hotplug_stage_two(dev, output, true); + drm_helper_hotplug_stage_two(dev, connector, true); - intel_sdvo_set_hotplug(output, 1); + intel_sdvo_set_hotplug(connector, 1); unlock: mutex_unlock(&dev->mode_config.mutex); @@ -961,15 +961,15 @@ void i915_disable_vblank(struct drm_device *dev, int plane) void i915_enable_interrupt (struct drm_device *dev) { struct drm_i915_private *dev_priv = (struct drm_i915_private *) dev->dev_private; - struct drm_output *o; + struct drm_connector *o; dev_priv->irq_enable_reg |= I915_USER_INTERRUPT; if (IS_I9XX(dev) && !IS_I915G(dev) && !IS_I915GM(dev)) { - if (dev->mode_config.num_output) + if (dev->mode_config.num_connector) dev_priv->irq_enable_reg |= I915_DISPLAY_PORT_INTERRUPT; } else { - if (dev->mode_config.num_output) + if (dev->mode_config.num_connector) dev_priv->irq_enable_reg |= I915_DISPLAY_PIPE_A_EVENT_INTERRUPT; /* Enable global interrupts for hotplug - not a pipeA event */ diff --git a/tests/mode/modetest.c b/tests/mode/modetest.c index eba072ee..3ff78f96 100644 --- a/tests/mode/modetest.c +++ b/tests/mode/modetest.c @@ -47,7 +47,7 @@ int printMode(struct drm_mode_modeinfo *mode) return 0; } -int printOutput(int fd, drmModeResPtr res, drmModeOutputPtr output, uint32_t id) +int printConnector(int fd, drmModeResPtr res, drmModeConnectorPtr connector, uint32_t id) { int i = 0, j; struct drm_mode_modeinfo *mode = NULL; @@ -55,28 +55,28 @@ int printOutput(int fd, drmModeResPtr res, drmModeOutputPtr output, uint32_t id) drmModeEncoderPtr enc; unsigned char *name = NULL; - printf("Output: %d-%d\n", output->output_type, output->output_type_id); + printf("Connector: %d-%d\n", connector->connector_type, connector->connector_type_id); printf("\tid : %i\n", id); - printf("\tcrtc id : %i\n", output->crtc); - printf("\tconn : %s\n", getConnectionText(output->connection)); - printf("\tsize : %ix%i (mm)\n", output->mmWidth, output->mmHeight); - printf("\tcount_crtcs : %i\n", output->count_crtcs); - printf("\tcrtcs : %i\n", output->crtcs); - printf("\tcount_clones : %i\n", output->count_clones); - printf("\tclones : %i\n", output->clones); - printf("\tcount_modes : %i\n", output->count_modes); - printf("\tcount_props : %i\n", output->count_props); - printf("\tcount_encs : %i\n", output->count_encoders); - - for (i = 0; i < output->count_encoders; i++) { - enc = drmModeGetEncoder(fd, output->encoders[i]); + printf("\tcrtc id : %i\n", connector->crtc); + printf("\tconn : %s\n", getConnectionText(connector->connection)); + printf("\tsize : %ix%i (mm)\n", connector->mmWidth, connector->mmHeight); + printf("\tcount_crtcs : %i\n", connector->count_crtcs); + printf("\tcrtcs : %i\n", connector->crtcs); + printf("\tcount_clones : %i\n", connector->count_clones); + printf("\tclones : %i\n", connector->clones); + printf("\tcount_modes : %i\n", connector->count_modes); + printf("\tcount_props : %i\n", connector->count_props); + printf("\tcount_encs : %i\n", connector->count_encoders); + + for (i = 0; i < connector->count_encoders; i++) { + enc = drmModeGetEncoder(fd, connector->encoders[i]); if (enc) { printf("Encoder: %d %d %d %d\n", enc->encoder_id, enc->encoder_type, enc->crtcs, enc->clones); } } - for (i = 0; i < output->count_props; i++) { - props = drmModeGetProperty(fd, output->props[i]); + for (i = 0; i < connector->count_props; i++) { + props = drmModeGetProperty(fd, connector->props[i]); name = NULL; if (props) { printf("Property: %s\n", props->name); @@ -91,7 +91,7 @@ int printOutput(int fd, drmModeResPtr res, drmModeOutputPtr output, uint32_t id) if (props->flags & DRM_MODE_PROP_BLOB) { drmModePropertyBlobPtr blob; - blob = drmModeGetPropertyBlob(fd, output->prop_values[i]); + blob = drmModeGetPropertyBlob(fd, connector->prop_values[i]); if (blob) { printf("blob is %d length, %08X\n", blob->length, *(uint32_t *)blob->data); drmModeFreePropertyBlob(blob); @@ -103,15 +103,15 @@ int printOutput(int fd, drmModeResPtr res, drmModeOutputPtr output, uint32_t id) for (j = 0; j < props->count_enums; j++) { printf("\t\t%lld = %s\n", props->enums[j].value, props->enums[j].name); - if (output->prop_values[i] == props->enums[j].value) + if (connector->prop_values[i] == props->enums[j].value) name = props->enums[j].name; } if (props->count_enums && name) { - printf("\toutput property name %s %s\n", props->name, name); + printf("\tconnector property name %s %s\n", props->name, name); } else { - printf("\toutput property id %s %lli\n", props->name, output->prop_values[i]); + printf("\tconnector property id %s %lli\n", props->name, connector->prop_values[i]); } } @@ -119,12 +119,12 @@ int printOutput(int fd, drmModeResPtr res, drmModeOutputPtr output, uint32_t id) } } - for (i = 0; i < output->count_modes; i++) { - mode = &output->modes[i]; + for (i = 0; i < connector->count_modes; i++) { + mode = &connector->modes[i]; if (mode) printMode(mode); else - printf("\t\tmode: Invalid mode %p\n", &output->modes[i]); + printf("\t\tmode: Invalid mode %p\n", &connector->modes[i]); } return 0; @@ -149,8 +149,8 @@ int printCrtc(int fd, drmModeResPtr res, drmModeCrtcPtr crtc, uint32_t id) printf("\twidth : %i\n", crtc->width); printf("\theight : %i\n", crtc->height); printf("\tmode : %p\n", &crtc->mode); - printf("\tnum outputs : %i\n", crtc->count_outputs); - printf("\toutputs : %i\n", crtc->outputs); + printf("\tnum connectors : %i\n", crtc->count_connectors); + printf("\tconnectors : %i\n", crtc->connectors); printf("\tnum possible : %i\n", crtc->count_possibles); printf("\tpossibles : %i\n", crtc->possibles); @@ -174,19 +174,19 @@ int printFrameBuffer(int fd, drmModeResPtr res, drmModeFBPtr fb) int printRes(int fd, drmModeResPtr res) { int i; - drmModeOutputPtr output; + drmModeConnectorPtr connector; drmModeCrtcPtr crtc; drmModeFBPtr fb; drmModeEncoderPtr encoder; - for (i = 0; i < res->count_outputs; i++) { - output = drmModeGetOutput(fd, res->outputs[i]); + for (i = 0; i < res->count_connectors; i++) { + connector = drmModeGetConnector(fd, res->connectors[i]); - if (!output) - printf("Could not get output %i\n", i); + if (!connector) + printf("Could not get connector %i\n", i); else { - printOutput(fd, res, output, res->outputs[i]); - drmModeFreeOutput(output); + printConnector(fd, res, connector, res->connectors[i]); + drmModeFreeConnector(connector); } } @@ -246,24 +246,24 @@ static struct drm_mode_modeinfo mode = { int testMode(int fd, drmModeResPtr res) { - uint32_t output = res->outputs[0]; + uint32_t connector = res->connectors[0]; uint32_t newMode = 0; int ret = 0; int error = 0; - printf("Test: adding mode to output %i\n", output); + printf("Test: adding mode to connector %i\n", connector); /* printMode(&mode); */ - printf("\tAttaching mode %i to output %i\n", newMode, output); + printf("\tAttaching mode %i to connector %i\n", newMode, connector); - ret = drmModeAttachMode(fd, output, &mode); + ret = drmModeAttachMode(fd, connector, &mode); if (ret) goto err_mode; - printf("\tDetaching mode %i from output %i\n", newMode, output); - ret = drmModeDetachMode(fd, output, &mode); + printf("\tDetaching mode %i from connector %i\n", newMode, connector); + ret = drmModeDetachMode(fd, connector, &mode); if (ret) goto err_mode; @@ -362,15 +362,15 @@ err: int testDPMS(int fd, drmModeResPtr res) { - int output_id; + int connector_id; int i; - for (i = 0; i < res->count_outputs; i++) { - output_id = res->outputs[i]; - /* turn output off */ - drmModeOutputSetProperty(fd, output_id, dpms_prop_id, 3); + for (i = 0; i < res->count_connectors; i++) { + connector_id = res->connectors[i]; + /* turn connector off */ + drmModeConnectorSetProperty(fd, connector_id, dpms_prop_id, 3); sleep(2); - drmModeOutputSetProperty(fd, output_id, dpms_prop_id, 0); + drmModeConnectorSetProperty(fd, connector_id, dpms_prop_id, 0); } return 1; -- cgit v1.2.3 From 30fc88fdf9084ffcb9e76acbdee95d9691ac4ba4 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Fri, 30 May 2008 15:18:07 +1000 Subject: modesetting: drop crtcs/clones from the connectors --- tests/mode/modetest.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'tests') diff --git a/tests/mode/modetest.c b/tests/mode/modetest.c index 3ff78f96..382cba65 100644 --- a/tests/mode/modetest.c +++ b/tests/mode/modetest.c @@ -60,10 +60,6 @@ int printConnector(int fd, drmModeResPtr res, drmModeConnectorPtr connector, uin printf("\tcrtc id : %i\n", connector->crtc); printf("\tconn : %s\n", getConnectionText(connector->connection)); printf("\tsize : %ix%i (mm)\n", connector->mmWidth, connector->mmHeight); - printf("\tcount_crtcs : %i\n", connector->count_crtcs); - printf("\tcrtcs : %i\n", connector->crtcs); - printf("\tcount_clones : %i\n", connector->count_clones); - printf("\tclones : %i\n", connector->clones); printf("\tcount_modes : %i\n", connector->count_modes); printf("\tcount_props : %i\n", connector->count_props); printf("\tcount_encs : %i\n", connector->count_encoders); -- cgit v1.2.3 From dba95ec34315d62934ff0e493e085aa6a03cde7c Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 2 Jun 2008 10:41:12 +1000 Subject: drm: fixup some interfaces so test code works again --- libdrm/xf86drmMode.c | 14 +++----------- libdrm/xf86drmMode.h | 3 ++- linux-core/drm_crtc.c | 7 ------- tests/mode/modetest.c | 4 ++-- 4 files changed, 7 insertions(+), 21 deletions(-) (limited to 'tests') diff --git a/libdrm/xf86drmMode.c b/libdrm/xf86drmMode.c index 8b7f2bcf..d11fc12e 100644 --- a/libdrm/xf86drmMode.c +++ b/libdrm/xf86drmMode.c @@ -254,10 +254,6 @@ drmModeCrtcPtr drmModeGetCrtc(int fd, uint32_t crtcId) struct drm_mode_crtc crtc; drmModeCrtcPtr r; - crtc.count_connectors = 0; - crtc.connectors = 0; - crtc.count_possibles = 0; - crtc.possibles = 0; crtc.crtc_id = crtcId; if (ioctl(fd, DRM_IOCTL_MODE_GETCRTC, &crtc)) @@ -278,12 +274,6 @@ 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_connectors = crtc.count_connectors; - r->count_possibles = crtc.count_possibles; - /* TODO we realy should test if these alloc & cpy fails. */ - r->connectors = crtc.connectors; - r->possibles = crtc.possibles; - return r; } @@ -362,6 +352,8 @@ drmModeEncoderPtr drmModeGetEncoder(int fd, uint32_t encoder_id) 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; @@ -411,7 +403,7 @@ drmModeConnectorPtr drmModeGetConnector(int fd, uint32_t connector_id) } r->connector_id = conn.connector; - r->crtc = conn.crtc; + r->encoder = conn.encoder; r->connection = conn.connection; r->mmWidth = conn.mm_width; r->mmHeight = conn.mm_height; diff --git a/libdrm/xf86drmMode.h b/libdrm/xf86drmMode.h index ceaa9abc..2f3a8f74 100644 --- a/libdrm/xf86drmMode.h +++ b/libdrm/xf86drmMode.h @@ -112,6 +112,7 @@ typedef struct _drmModeCrtc { typedef struct _drmModeEncoder { unsigned int encoder_id; unsigned int encoder_type; + uint32_t crtc; uint32_t crtcs; uint32_t clones; } drmModeEncoder, *drmModeEncoderPtr; @@ -134,7 +135,7 @@ typedef enum { typedef struct _drmModeConnector { unsigned int connector_id; - unsigned int crtc; /**< Crtc currently connected to */ + unsigned int encoder; /**< Crtc currently connected to */ unsigned int connector_type; unsigned int connector_type_id; drmModeConnection connection; diff --git a/linux-core/drm_crtc.c b/linux-core/drm_crtc.c index 27bf7c27..c4210fd4 100644 --- a/linux-core/drm_crtc.c +++ b/linux-core/drm_crtc.c @@ -1015,8 +1015,6 @@ int drm_mode_getcrtc(struct drm_device *dev, { struct drm_mode_crtc *crtc_resp = data; struct drm_crtc *crtc; - struct drm_connector *connector; - int ocount; int ret = 0; mutex_lock(&dev->mode_config.mutex); @@ -1039,11 +1037,6 @@ int drm_mode_getcrtc(struct drm_device *dev, drm_crtc_convert_to_umode(&crtc_resp->mode, &crtc->mode); crtc_resp->mode_valid = 1; - ocount = 0; - list_for_each_entry(connector, &dev->mode_config.connector_list, head) { - if (connector->encoder->crtc == crtc) - crtc_resp->connectors |= 1 << (ocount++); - } } else { crtc_resp->mode_valid = 0; diff --git a/tests/mode/modetest.c b/tests/mode/modetest.c index 382cba65..bd1e8000 100644 --- a/tests/mode/modetest.c +++ b/tests/mode/modetest.c @@ -57,7 +57,7 @@ int printConnector(int fd, drmModeResPtr res, drmModeConnectorPtr connector, uin printf("Connector: %d-%d\n", connector->connector_type, connector->connector_type_id); printf("\tid : %i\n", id); - printf("\tcrtc id : %i\n", connector->crtc); + printf("\tencoder id : %i\n", connector->encoder); printf("\tconn : %s\n", getConnectionText(connector->connection)); printf("\tsize : %ix%i (mm)\n", connector->mmWidth, connector->mmHeight); printf("\tcount_modes : %i\n", connector->count_modes); @@ -67,7 +67,7 @@ int printConnector(int fd, drmModeResPtr res, drmModeConnectorPtr connector, uin for (i = 0; i < connector->count_encoders; i++) { enc = drmModeGetEncoder(fd, connector->encoders[i]); if (enc) { - printf("Encoder: %d %d %d %d\n", enc->encoder_id, enc->encoder_type, enc->crtcs, enc->clones); + printf("Encoder: %d %d %d %d %d\n", enc->crtc, enc->encoder_id, enc->encoder_type, enc->crtcs, enc->clones); } } -- cgit v1.2.3 From 4e7b24639808e5e1e2c05143028db1a3bc2812e9 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 2 Jun 2008 14:04:41 +1000 Subject: drm: add functions to get/set gamma ramps --- libdrm/xf86drmMode.c | 36 ++++++++++++++ libdrm/xf86drmMode.h | 5 ++ linux-core/drm_crtc.c | 115 +++++++++++++++++++++++++++++++++++++++++++++ linux-core/drm_crtc.h | 19 ++++++-- linux-core/drm_drv.c | 2 + linux-core/drm_fb.c | 3 -- linux-core/intel_display.c | 21 ++++++++- linux-core/intel_drv.h | 3 +- linux-core/intel_fb.c | 4 +- linux-core/radeon_ms_fb.c | 6 +-- shared-core/drm.h | 15 +++++- tests/mode/modetest.c | 1 + 12 files changed, 214 insertions(+), 16 deletions(-) (limited to 'tests') diff --git a/libdrm/xf86drmMode.c b/libdrm/xf86drmMode.c index d11fc12e..a393f965 100644 --- a/libdrm/xf86drmMode.c +++ b/libdrm/xf86drmMode.c @@ -657,3 +657,39 @@ int drmModeReplaceFB(int fd, uint32_t buffer_id, return 0; } + +int drmModeCrtcGetGamma(int fd, uint32_t crtc_id, uint32_t size, + uint16_t *red, uint16_t *green, uint16_t *blue) +{ + int ret; + struct drm_mode_crtc_lut l; + + l.crtc_id = crtc_id; + l.gamma_size = size; + l.red = VOID2U64(red); + l.green = VOID2U64(green); + l.blue = VOID2U64(blue); + + if ((ret = ioctl(fd, DRM_IOCTL_MODE_GETGAMMA, &l))) + return ret; + + return 0; +} + +int drmModeCrtcSetGamma(int fd, uint32_t crtc_id, uint32_t size, + uint16_t *red, uint16_t *green, uint16_t *blue) +{ + int ret; + struct drm_mode_crtc_lut l; + + l.crtc_id = crtc_id; + l.gamma_size = size; + l.red = VOID2U64(red); + l.green = VOID2U64(green); + l.blue = VOID2U64(blue); + + if ((ret = ioctl(fd, DRM_IOCTL_MODE_SETGAMMA, &l))) + return ret; + + return 0; +} diff --git a/libdrm/xf86drmMode.h b/libdrm/xf86drmMode.h index 2f3a8f74..56908d8f 100644 --- a/libdrm/xf86drmMode.h +++ b/libdrm/xf86drmMode.h @@ -263,3 +263,8 @@ 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); diff --git a/linux-core/drm_crtc.c b/linux-core/drm_crtc.c index 73c7f2a3..7746fd50 100644 --- a/linux-core/drm_crtc.c +++ b/linux-core/drm_crtc.c @@ -279,6 +279,11 @@ void drm_crtc_cleanup(struct drm_crtc *crtc) { struct drm_device *dev = crtc->dev; + if (crtc->gamma_store) { + kfree(crtc->gamma_store); + crtc->gamma_store = NULL; + } + drm_idr_put(dev, crtc->id); list_del(&crtc->head); dev->mode_config.num_crtc--; @@ -896,6 +901,7 @@ int drm_mode_getcrtc(struct drm_device *dev, crtc_resp->x = crtc->x; crtc_resp->y = crtc->y; + crtc_resp->gamma_size = crtc->gamma_size; if (crtc->fb) crtc_resp->fb_id = crtc->fb->id; @@ -2070,3 +2076,112 @@ void drm_mode_connector_detach_encoder(struct drm_connector *connector, } } EXPORT_SYMBOL(drm_mode_connector_detach_encoder); + +bool drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, + int gamma_size) +{ + crtc->gamma_size = gamma_size; + + crtc->gamma_store = kzalloc(gamma_size * sizeof(uint16_t) * 3, GFP_KERNEL); + if (!crtc->gamma_store) { + crtc->gamma_size = 0; + return false; + } + + return true; +} +EXPORT_SYMBOL(drm_mode_crtc_set_gamma_size); + +int drm_mode_gamma_set_ioctl(struct drm_device *dev, + void *data, struct drm_file *file_priv) +{ + struct drm_mode_crtc_lut *crtc_lut = data; + struct drm_crtc *crtc; + void *r_base, *g_base, *b_base; + int size; + int ret = 0; + + mutex_lock(&dev->mode_config.mutex); + crtc = idr_find(&dev->mode_config.crtc_idr, crtc_lut->crtc_id); + if (!crtc || (crtc->id != crtc_lut->crtc_id)) { + ret = -EINVAL; + goto out; + } + + /* memcpy into gamma store */ + if (crtc_lut->gamma_size != crtc->gamma_size) { + ret = -EINVAL; + goto out; + } + + size = crtc_lut->gamma_size * (sizeof(uint16_t)); + r_base = crtc->gamma_store; + if (copy_from_user(r_base, (void __user *)(unsigned long)crtc_lut->red, size)) { + ret = -EFAULT; + goto out; + } + + g_base = r_base + size; + if (copy_from_user(g_base, (void __user *)(unsigned long)crtc_lut->green, size)) { + ret = -EFAULT; + goto out; + } + + b_base = g_base + size; + if (copy_from_user(b_base, (void __user *)(unsigned long)crtc_lut->blue, size)) { + ret = -EFAULT; + goto out; + } + + crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, crtc->gamma_size); + +out: + mutex_unlock(&dev->mode_config.mutex); + return ret; + +} + +int drm_mode_gamma_get_ioctl(struct drm_device *dev, + void *data, struct drm_file *file_priv) +{ + struct drm_mode_crtc_lut *crtc_lut = data; + struct drm_crtc *crtc; + void *r_base, *g_base, *b_base; + int size; + int ret = 0; + + mutex_lock(&dev->mode_config.mutex); + crtc = idr_find(&dev->mode_config.crtc_idr, crtc_lut->crtc_id); + if (!crtc || (crtc->id != crtc_lut->crtc_id)) { + ret = -EINVAL; + goto out; + } + + /* memcpy into gamma store */ + if (crtc_lut->gamma_size != crtc->gamma_size) { + ret = -EINVAL; + goto out; + } + + size = crtc_lut->gamma_size * (sizeof(uint16_t)); + r_base = crtc->gamma_store; + if (copy_to_user((void __user *)(unsigned long)crtc_lut->red, r_base, size)) { + ret = -EFAULT; + goto out; + } + + g_base = r_base + size; + if (copy_to_user((void __user *)(unsigned long)crtc_lut->green, g_base, size)) { + ret = -EFAULT; + goto out; + } + + b_base = g_base + size; + if (copy_to_user((void __user *)(unsigned long)crtc_lut->blue, b_base, size)) { + ret = -EFAULT; + goto out; + } +out: + mutex_unlock(&dev->mode_config.mutex); + return ret; +} diff --git a/linux-core/drm_crtc.h b/linux-core/drm_crtc.h index 390ab2d3..151d1732 100644 --- a/linux-core/drm_crtc.h +++ b/linux-core/drm_crtc.h @@ -315,8 +315,8 @@ struct drm_crtc_funcs { int (*cursor_move)(struct drm_crtc *crtc, int x, int y); /* Set gamma on the CRTC */ - void (*gamma_set)(struct drm_crtc *crtc, u16 r, u16 g, u16 b, - int regno); + void (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, + uint32_t size); /* Object destroy routine */ void (*destroy)(struct drm_crtc *crtc); @@ -354,6 +354,10 @@ struct drm_crtc { int desired_x, desired_y; const struct drm_crtc_funcs *funcs; + /* CRTC gamma size for reporting to userspace */ + uint32_t gamma_size; + uint16_t *gamma_store; + /* if you are using the helper */ void *helper_private; }; @@ -627,7 +631,8 @@ extern int drm_mode_connector_attach_encoder(struct drm_connector *connector, struct drm_encoder *encoder); extern void drm_mode_connector_detach_encoder(struct drm_connector *connector, struct drm_encoder *encoder); - +extern bool drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, + int gamma_size); /* IOCTLs */ extern int drm_mode_getresources(struct drm_device *dev, void *data, struct drm_file *file_priv); @@ -665,7 +670,11 @@ extern int drm_mode_hotplug_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv); extern int drm_mode_replacefb(struct drm_device *dev, void *data, struct drm_file *file_priv); -int drm_mode_getencoder(struct drm_device *dev, - void *data, struct drm_file *file_priv); +extern int drm_mode_getencoder(struct drm_device *dev, + void *data, struct drm_file *file_priv); +extern int drm_mode_gamma_get_ioctl(struct drm_device *dev, + void *data, struct drm_file *file_priv); +extern int drm_mode_gamma_set_ioctl(struct drm_device *dev, + void *data, struct drm_file *file_priv); #endif /* __DRM_CRTC_H__ */ diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c index 5a16fe8d..82e5af57 100644 --- a/linux-core/drm_drv.c +++ b/linux-core/drm_drv.c @@ -143,6 +143,8 @@ static struct drm_ioctl_desc drm_ioctls[] = { DRM_IOCTL_DEF(DRM_IOCTL_MODE_REPLACEFB, drm_mode_replacefb, DRM_MASTER|DRM_ROOT_ONLY|DRM_CONTROL_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETENCODER, drm_mode_getencoder, DRM_MASTER|DRM_ROOT_ONLY|DRM_CONTROL_ALLOW), + DRM_IOCTL_DEF(DRM_IOCTL_MODE_GETGAMMA, drm_mode_gamma_get_ioctl, DRM_MASTER), + DRM_IOCTL_DEF(DRM_IOCTL_MODE_SETGAMMA, drm_mode_gamma_set_ioctl, DRM_MASTER), DRM_IOCTL_DEF(DRM_IOCTL_MM_INIT, drm_mm_init_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), diff --git a/linux-core/drm_fb.c b/linux-core/drm_fb.c index 775fd180..74a4394a 100644 --- a/linux-core/drm_fb.c +++ b/linux-core/drm_fb.c @@ -58,9 +58,6 @@ static int drmfb_setcolreg(unsigned regno, unsigned red, unsigned green, return 1; if (fb->depth == 8) { - if (crtc->funcs->gamma_set) { - crtc->funcs->gamma_set(crtc, red, green, blue, regno); - } return 0; } diff --git a/linux-core/intel_display.c b/linux-core/intel_display.c index e23b3973..ba9441d6 100644 --- a/linux-core/intel_display.c +++ b/linux-core/intel_display.c @@ -1056,7 +1056,7 @@ static int intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y) } /** Sets the color ramps on behalf of RandR */ -static void intel_crtc_gamma_set(struct drm_crtc *crtc, u16 red, u16 green, +void intel_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green, u16 blue, int regno) { struct intel_crtc *intel_crtc = to_intel_crtc(crtc); @@ -1066,6 +1066,24 @@ static void intel_crtc_gamma_set(struct drm_crtc *crtc, u16 red, u16 green, intel_crtc->lut_b[regno] = blue >> 8; } +static void intel_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, + u16 *blue, uint32_t size) +{ + struct intel_crtc *intel_crtc = to_intel_crtc(crtc); + int i; + + if (size != 256) + return; + + for (i = 0; i < 256; i++) { + intel_crtc->lut_r[i] = red[i] >> 8; + intel_crtc->lut_g[i] = green[i] >> 8; + intel_crtc->lut_b[i] = blue[i] >> 8; + } + + intel_crtc_load_lut(crtc); +} + /** * Get a pipe with a simple mode set on it for doing load-based monitor * detection. @@ -1343,6 +1361,7 @@ void intel_crtc_init(struct drm_device *dev, int pipe) drm_crtc_init(dev, &intel_crtc->base, &intel_crtc_funcs); + drm_mode_crtc_set_gamma_size(&intel_crtc->base, 256); intel_crtc->pipe = pipe; for (i = 0; i < 256; i++) { intel_crtc->lut_r[i] = i; diff --git a/linux-core/intel_drv.h b/linux-core/intel_drv.h index 24287e37..210ed990 100644 --- a/linux-core/intel_drv.h +++ b/linux-core/intel_drv.h @@ -104,5 +104,6 @@ extern void intel_sdvo_set_hotplug(struct drm_connector *connector, int enable); extern int intelfb_probe(struct drm_device *dev, struct drm_crtc *crtc, struct drm_connector *connector); extern int intelfb_remove(struct drm_device *dev, struct drm_framebuffer *fb); extern int intelfb_resize(struct drm_device *dev, struct drm_crtc *crtc); - +extern void intel_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green, + u16 blue, int regno); #endif /* __INTEL_DRV_H__ */ diff --git a/linux-core/intel_fb.c b/linux-core/intel_fb.c index 138d189e..268e95c5 100644 --- a/linux-core/intel_fb.c +++ b/linux-core/intel_fb.c @@ -41,6 +41,7 @@ #include "drmP.h" #include "drm.h" #include "drm_crtc.h" +#include "intel_drv.h" #include "i915_drm.h" #include "i915_drv.h" @@ -79,8 +80,7 @@ static int intelfb_setcolreg(unsigned regno, unsigned red, unsigned green, return 1; if (fb->depth == 8) { - if (crtc->funcs->gamma_set) - crtc->funcs->gamma_set(crtc, red, green, blue, regno); + intel_crtc_fb_gamma_set(crtc, red, green, blue, regno); return 0; } diff --git a/linux-core/radeon_ms_fb.c b/linux-core/radeon_ms_fb.c index e320144e..0ac9207c 100644 --- a/linux-core/radeon_ms_fb.c +++ b/linux-core/radeon_ms_fb.c @@ -54,9 +54,9 @@ static int radeonfb_setcolreg(unsigned regno, unsigned red, if (regno > 255) { return 1; } - if (crtc->funcs->gamma_set) { - crtc->funcs->gamma_set(crtc, red, green, blue, regno); - } + // if (crtc->funcs->gamma_set) { + // crtc->funcs->gamma_set(crtc, red, green, blue, regno); + // } if (regno < 16) { switch (fb->depth) { case 15: diff --git a/shared-core/drm.h b/shared-core/drm.h index 7e94fb82..132c7746 100644 --- a/shared-core/drm.h +++ b/shared-core/drm.h @@ -1048,7 +1048,7 @@ struct drm_mode_crtc { int count_possibles; unsigned int possibles; /**< Connectors that can be connected */ - int gamma_size; + uint32_t gamma_size; int mode_valid; struct drm_mode_modeinfo mode; }; @@ -1173,6 +1173,16 @@ struct drm_mode_hotplug { uint32_t counter; }; +struct drm_mode_crtc_lut { + + uint32_t crtc_id; + uint32_t gamma_size; + + uint64_t red; + uint64_t green; + uint64_t blue; +}; + /** * \name Ioctls Definitions */ @@ -1289,6 +1299,9 @@ struct drm_mode_hotplug { #define DRM_IOCTL_MODE_REPLACEFB DRM_IOWR(0xAF, struct drm_mode_fb_cmd) #define DRM_IOCTL_MODE_GETENCODER DRM_IOWR(0xB0, struct drm_mode_get_encoder) +#define DRM_IOCTL_MODE_GETGAMMA DRM_IOWR(0xB1, struct drm_mode_crtc_lut) +#define DRM_IOCTL_MODE_SETGAMMA DRM_IOWR(0xB2, struct drm_mode_crtc_lut) + /*@}*/ /** diff --git a/tests/mode/modetest.c b/tests/mode/modetest.c index bd1e8000..bb91e832 100644 --- a/tests/mode/modetest.c +++ b/tests/mode/modetest.c @@ -145,6 +145,7 @@ int printCrtc(int fd, drmModeResPtr res, drmModeCrtcPtr crtc, uint32_t id) printf("\twidth : %i\n", crtc->width); printf("\theight : %i\n", crtc->height); printf("\tmode : %p\n", &crtc->mode); + printf("\tgamma size : %d\n", crtc->gamma_size); printf("\tnum connectors : %i\n", crtc->count_connectors); printf("\tconnectors : %i\n", crtc->connectors); printf("\tnum possible : %i\n", crtc->count_possibles); -- cgit v1.2.3 From b28d309210475b6f671af7617c779bd1d7a6810a Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Wed, 2 Jul 2008 13:59:19 +0200 Subject: tests: Improved and renamed the mode app to modeprint --- tests/mode/Makefile | 14 -- tests/mode/modetest.c | 409 --------------------------------------------- tests/mode/test | 1 - tests/modeprint/Makefile | 14 ++ tests/modeprint/modetest.c | 352 ++++++++++++++++++++++++++++++++++++++ tests/modeprint/test | 1 + 6 files changed, 367 insertions(+), 424 deletions(-) delete mode 100644 tests/mode/Makefile delete mode 100644 tests/mode/modetest.c delete mode 100755 tests/mode/test create mode 100644 tests/modeprint/Makefile create mode 100644 tests/modeprint/modetest.c create mode 100755 tests/modeprint/test (limited to 'tests') diff --git a/tests/mode/Makefile b/tests/mode/Makefile deleted file mode 100644 index 7a9c3c24..00000000 --- a/tests/mode/Makefile +++ /dev/null @@ -1,14 +0,0 @@ - -all: app - -#CFLAGS = -g -ansi -pedantic -DPOSIX_C_SOURCE=199309L \ -# -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE \ - -app: modetest.c - @gcc $(CFLAGS) -o app -Wall -I../../libdrm -I../../shared-core -L../../libdrm/.libs -ldrm modetest.c - -clean: - @rm -f app - -run: app - @sudo ./test diff --git a/tests/mode/modetest.c b/tests/mode/modetest.c deleted file mode 100644 index bb91e832..00000000 --- a/tests/mode/modetest.c +++ /dev/null @@ -1,409 +0,0 @@ - -#include -#include -#include -#include -#include -#include - -#include "xf86drm.h" -#include "xf86drmMode.h" - -int dpms_prop_id = 0; -const char* getConnectionText(drmModeConnection conn) -{ - switch (conn) { - case DRM_MODE_CONNECTED: - return "connected"; - case DRM_MODE_DISCONNECTED: - return "disconnected"; - default: - return "unknown"; - } - -} - -int printMode(struct drm_mode_modeinfo *mode) -{ -#if 1 - printf("Mode: %s\n", mode->name); - printf("\tclock : %i\n", mode->clock); - printf("\thdisplay : %i\n", mode->hdisplay); - printf("\thsync_start : %i\n", mode->hsync_start); - printf("\thsync_end : %i\n", mode->hsync_end); - printf("\thtotal : %i\n", mode->htotal); - printf("\thskew : %i\n", mode->hskew); - printf("\tvdisplay : %i\n", mode->vdisplay); - printf("\tvsync_start : %i\n", mode->vsync_start); - printf("\tvsync_end : %i\n", mode->vsync_end); - printf("\tvtotal : %i\n", mode->vtotal); - printf("\tvscan : %i\n", mode->vscan); - printf("\tvrefresh : %i\n", mode->vrefresh); - printf("\tflags : %i\n", mode->flags); -#else - printf("Mode: \"%s\" %ix%i %.0f\n", mode->name, - mode->hdisplay, mode->vdisplay, mode->vrefresh / 1000.0); -#endif - return 0; -} - -int printConnector(int fd, drmModeResPtr res, drmModeConnectorPtr connector, uint32_t id) -{ - int i = 0, j; - struct drm_mode_modeinfo *mode = NULL; - drmModePropertyPtr props; - drmModeEncoderPtr enc; - unsigned char *name = NULL; - - printf("Connector: %d-%d\n", connector->connector_type, connector->connector_type_id); - printf("\tid : %i\n", id); - printf("\tencoder id : %i\n", connector->encoder); - printf("\tconn : %s\n", getConnectionText(connector->connection)); - printf("\tsize : %ix%i (mm)\n", connector->mmWidth, connector->mmHeight); - printf("\tcount_modes : %i\n", connector->count_modes); - printf("\tcount_props : %i\n", connector->count_props); - printf("\tcount_encs : %i\n", connector->count_encoders); - - for (i = 0; i < connector->count_encoders; i++) { - enc = drmModeGetEncoder(fd, connector->encoders[i]); - if (enc) { - printf("Encoder: %d %d %d %d %d\n", enc->crtc, enc->encoder_id, enc->encoder_type, enc->crtcs, enc->clones); - } - } - - for (i = 0; i < connector->count_props; i++) { - props = drmModeGetProperty(fd, connector->props[i]); - name = NULL; - if (props) { - printf("Property: %s\n", props->name); - printf("\tid: %i\n", props->prop_id); - printf("\tflags: %i\n", props->flags); - printf("\tvalues %d: ", props->count_values); - for (j = 0; j < props->count_values; j++) - printf("%lld ", props->values[j]); - - printf("\n\tenums %d: \n", props->count_enums); - - if (props->flags & DRM_MODE_PROP_BLOB) { - drmModePropertyBlobPtr blob; - - blob = drmModeGetPropertyBlob(fd, connector->prop_values[i]); - if (blob) { - printf("blob is %d length, %08X\n", blob->length, *(uint32_t *)blob->data); - drmModeFreePropertyBlob(blob); - } - - } else { - if (!strncmp(props->name, "DPMS", 4)) - dpms_prop_id = props->prop_id; - - for (j = 0; j < props->count_enums; j++) { - printf("\t\t%lld = %s\n", props->enums[j].value, props->enums[j].name); - if (connector->prop_values[i] == props->enums[j].value) - name = props->enums[j].name; - - } - - if (props->count_enums && name) { - printf("\tconnector property name %s %s\n", props->name, name); - } else { - printf("\tconnector property id %s %lli\n", props->name, connector->prop_values[i]); - } - } - - drmModeFreeProperty(props); - } - } - - for (i = 0; i < connector->count_modes; i++) { - mode = &connector->modes[i]; - if (mode) - printMode(mode); - else - printf("\t\tmode: Invalid mode %p\n", &connector->modes[i]); - } - - return 0; -} - -int printEncoder(int fd, drmModeResPtr res, drmModeEncoderPtr encoder, uint32_t id) -{ - printf("Encoder\n"); - printf("\tid :%i\n", id); - printf("\ttype :%d\n", encoder->encoder_type); - printf("\tcrtcs :%d\n", encoder->crtcs); - printf("\tclones :%d\n", encoder->clones); - return 0; -} - -int printCrtc(int fd, drmModeResPtr res, drmModeCrtcPtr crtc, uint32_t id) -{ - printf("Crtc\n"); - printf("\tid : %i\n", id); - printf("\tx : %i\n", crtc->x); - printf("\ty : %i\n", crtc->y); - printf("\twidth : %i\n", crtc->width); - printf("\theight : %i\n", crtc->height); - printf("\tmode : %p\n", &crtc->mode); - printf("\tgamma size : %d\n", crtc->gamma_size); - printf("\tnum connectors : %i\n", crtc->count_connectors); - printf("\tconnectors : %i\n", crtc->connectors); - printf("\tnum possible : %i\n", crtc->count_possibles); - printf("\tpossibles : %i\n", crtc->possibles); - - return 0; -} - -int printFrameBuffer(int fd, drmModeResPtr res, drmModeFBPtr fb) -{ - printf("Framebuffer\n"); - printf("\thandle : %i\n", fb->handle); - printf("\twidth : %i\n", fb->width); - printf("\theight : %i\n", fb->height); - printf("\tpitch : %i\n", fb->pitch);; - printf("\tbpp : %i\n", fb->bpp); - printf("\tdepth : %i\n", fb->depth); - printf("\tbuffer_id : %i\n", fb->buffer_id); - - return 0; -} - -int printRes(int fd, drmModeResPtr res) -{ - int i; - drmModeConnectorPtr connector; - drmModeCrtcPtr crtc; - drmModeFBPtr fb; - drmModeEncoderPtr encoder; - - for (i = 0; i < res->count_connectors; i++) { - connector = drmModeGetConnector(fd, res->connectors[i]); - - if (!connector) - printf("Could not get connector %i\n", i); - else { - printConnector(fd, res, connector, res->connectors[i]); - drmModeFreeConnector(connector); - } - } - - for (i = 0; i < res->count_encoders; i++) { - encoder = drmModeGetEncoder(fd, res->encoders[i]); - - if (!encoder) - printf("Could not get encoder %i\n", i); - else { - printEncoder(fd, res, encoder, res->encoders[i]); - drmModeFreeEncoder(encoder); - } - } - - - for (i = 0; i < res->count_crtcs; i++) { - crtc = drmModeGetCrtc(fd, res->crtcs[i]); - - if (!crtc) - printf("Could not get crtc %i\n", i); - else { - printCrtc(fd, res, crtc, res->crtcs[i]); - drmModeFreeCrtc(crtc); - } - } - - for (i = 0; i < res->count_fbs; i++) { - fb = drmModeGetFB(fd, res->fbs[i]); - - if (!fb) - printf("Could not get fb %i\n", res->fbs[i]); - else { - printFrameBuffer(fd, res, fb); - drmModeFreeFB(fb); - } - } - - return 0; -} - -static struct drm_mode_modeinfo mode = { - .name = "Test mode", - .clock = 25200, - .hdisplay = 640, - .hsync_start = 656, - .hsync_end = 752, - .htotal = 800, - .hskew = 0, - .vdisplay = 480, - .vsync_start = 490, - .vsync_end = 492, - .vtotal = 525, - .vscan = 0, - .vrefresh = 60000, /* vertical refresh * 1000 */ - .flags = 10, -}; - -int testMode(int fd, drmModeResPtr res) -{ - uint32_t connector = res->connectors[0]; - uint32_t newMode = 0; - int ret = 0; - int error = 0; - - printf("Test: adding mode to connector %i\n", connector); - - /* printMode(&mode); */ - - printf("\tAttaching mode %i to connector %i\n", newMode, connector); - - ret = drmModeAttachMode(fd, connector, &mode); - - if (ret) - goto err_mode; - - printf("\tDetaching mode %i from connector %i\n", newMode, connector); - ret = drmModeDetachMode(fd, connector, &mode); - - if (ret) - goto err_mode; - return 0; - -err_mode: - - printf("\tFailed\n"); - - if (error) - printf("\tFailed to delete mode %i\n", newMode); - return 1; -} - -/* -int testFrameBufferGet(int fd, uint32_t fb) -{ - drmModeFBPtr frame; - - printf("Test: get framebuffer %i\n", fb); - - frame = drmModeGetFB(fd, fb); - - if (!frame) { - printf("\tFailed\n"); - } else { - printFrameBuffer(fd, frame); - drmModeFreeFB(frame); - } - - return 0; -} -*/ - -int testFrameBufferAdd(int fd, drmModeResPtr res) -{ - uint32_t fb = 0; - int ret = 0; - drmModeFBPtr frame = 0; - drmBO bo; - - printf("Test: adding framebuffer\n"); - - printf("\tCreating BO\n"); - - /* TODO */ - ret = drmBOCreate(fd, 800 * 600 * 4, 0, 0, - DRM_BO_FLAG_READ | - DRM_BO_FLAG_WRITE | - DRM_BO_FLAG_MEM_TT | - DRM_BO_FLAG_MEM_VRAM | - DRM_BO_FLAG_NO_EVICT, - DRM_BO_HINT_DONT_FENCE, &bo); - - printf("\tgot %i\n", ret); - if (ret) - goto err; - - printf("\tAdding FB\n"); - ret = drmModeAddFB(fd, 800, 600, 32, 8, 0, bo.handle, &fb); - if (ret) - goto err_bo; - - frame = drmModeGetFB(fd, fb); - - if (!frame) { - printf("Couldn't retrive created framebuffer\n"); - } else { - printFrameBuffer(fd, res, frame); - drmModeFreeFB(frame); - } - - printf("\tRemoveing FB\n"); - - ret = drmModeRmFB(fd, fb); - - if (ret) { - printf("\tFailed this shouldn't happen!\n"); - goto err_bo; - } - - printf("\tRemoveing BO\n"); - - ret = drmBOUnreference(fb, &bo); - - return 0; - -err_bo: - drmBOUnreference(fd, &bo); - -err: - printf("\tFailed\n"); - - return 1; -} - -int testDPMS(int fd, drmModeResPtr res) -{ - int connector_id; - int i; - - for (i = 0; i < res->count_connectors; i++) { - connector_id = res->connectors[i]; - /* turn connector off */ - drmModeConnectorSetProperty(fd, connector_id, dpms_prop_id, 3); - sleep(2); - drmModeConnectorSetProperty(fd, connector_id, dpms_prop_id, 0); - } - return 1; - -} - -int main(int argc, char **argv) -{ - int fd; - drmModeResPtr res; - - printf("Starting test\n"); - - fd = drmOpen("i915", NULL); - - if (fd < 0) { - printf("Failed to open the card fb (%d)\n",fd); - return 1; - } - - res = drmModeGetResources(fd); - if (res == 0) { - printf("Failed to get resources from card\n"); - drmClose(fd); - return 1; - } - - printRes(fd, res); - - testMode(fd, res); - - testFrameBufferAdd(fd, res); - - /* try dpms test */ - testDPMS(fd, res); - drmModeFreeResources(res); - printf("Ok\n"); - - return 0; -} diff --git a/tests/mode/test b/tests/mode/test deleted file mode 100755 index f98e3708..00000000 --- a/tests/mode/test +++ /dev/null @@ -1 +0,0 @@ -LD_PRELOAD=../../libdrm/.libs/libdrm.so ./app diff --git a/tests/modeprint/Makefile b/tests/modeprint/Makefile new file mode 100644 index 00000000..7a9c3c24 --- /dev/null +++ b/tests/modeprint/Makefile @@ -0,0 +1,14 @@ + +all: app + +#CFLAGS = -g -ansi -pedantic -DPOSIX_C_SOURCE=199309L \ +# -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE \ + +app: modetest.c + @gcc $(CFLAGS) -o app -Wall -I../../libdrm -I../../shared-core -L../../libdrm/.libs -ldrm modetest.c + +clean: + @rm -f app + +run: app + @sudo ./test diff --git a/tests/modeprint/modetest.c b/tests/modeprint/modetest.c new file mode 100644 index 00000000..36925a0b --- /dev/null +++ b/tests/modeprint/modetest.c @@ -0,0 +1,352 @@ + +#include +#include +#include +#include +#include +#include + +#include "xf86drm.h" +#include "xf86drmMode.h" + +int connectors; +int full_props; +int edid; +int modes; +int full_modes; +int encoders; +int crtcs; +int fbs; + +const char* getConnectionText(drmModeConnection conn) +{ + switch (conn) { + case DRM_MODE_CONNECTED: + return "connected"; + case DRM_MODE_DISCONNECTED: + return "disconnected"; + default: + return "unknown"; + } + +} + +int printMode(struct drm_mode_modeinfo *mode) +{ + if (full_modes) { + printf("Mode: %s\n", mode->name); + printf("\tclock : %i\n", mode->clock); + printf("\thdisplay : %i\n", mode->hdisplay); + printf("\thsync_start : %i\n", mode->hsync_start); + printf("\thsync_end : %i\n", mode->hsync_end); + printf("\thtotal : %i\n", mode->htotal); + printf("\thskew : %i\n", mode->hskew); + printf("\tvdisplay : %i\n", mode->vdisplay); + printf("\tvsync_start : %i\n", mode->vsync_start); + printf("\tvsync_end : %i\n", mode->vsync_end); + printf("\tvtotal : %i\n", mode->vtotal); + printf("\tvscan : %i\n", mode->vscan); + printf("\tvrefresh : %i\n", mode->vrefresh); + printf("\tflags : %i\n", mode->flags); + } else { + printf("Mode: \"%s\" %ix%i %.0f\n", mode->name, + mode->hdisplay, mode->vdisplay, mode->vrefresh / 1000.0); + } + return 0; +} + +int printConnector(int fd, drmModeResPtr res, drmModeConnectorPtr connector, uint32_t id) +{ + int i = 0, j; + struct drm_mode_modeinfo *mode = NULL; + drmModePropertyPtr props; + unsigned char *name = NULL; + + printf("Connector: %d-%d\n", connector->connector_type, connector->connector_type_id); + printf("\tid : %i\n", id); + printf("\tencoder id : %i\n", connector->encoder); + printf("\tconn : %s\n", getConnectionText(connector->connection)); + printf("\tsize : %ix%i (mm)\n", connector->mmWidth, connector->mmHeight); + printf("\tcount_modes : %i\n", connector->count_modes); + printf("\tcount_props : %i\n", connector->count_props); + printf("\tcount_encoders : %i\n", connector->count_encoders); + + if (connector->count_encoders) { + printf("\t\tencoders"); + for (i = 0; i < connector->count_encoders; i++) + printf(" %i", connector->encoders[i]); + printf("\n"); + } + + if (full_props) { + for (i = 0; i < connector->count_props; i++) { + props = drmModeGetProperty(fd, connector->props[i]); + name = NULL; + if (props) { + printf("Property: %s\n", props->name); + printf("\tid: %i\n", props->prop_id); + printf("\tflags: %i\n", props->flags); + printf("\tvalues %d: ", props->count_values); + for (j = 0; j < props->count_values; j++) + printf("%lld ", props->values[j]); + + printf("\n\tenums %d: \n", props->count_enums); + + if (props->flags & DRM_MODE_PROP_BLOB) { + drmModePropertyBlobPtr blob; + + blob = drmModeGetPropertyBlob(fd, connector->prop_values[i]); + if (blob) { + printf("blob is %d length, %08X\n", blob->length, *(uint32_t *)blob->data); + drmModeFreePropertyBlob(blob); + } + + } else { + if (!strncmp(props->name, "DPMS", 4)) + ; + + for (j = 0; j < props->count_enums; j++) { + printf("\t\t%lld = %s\n", props->enums[j].value, props->enums[j].name); + if (connector->prop_values[i] == props->enums[j].value) + name = props->enums[j].name; + + } + + if (props->count_enums && name) { + printf("\tconnector property name %s %s\n", props->name, name); + } else { + printf("\tconnector property id %s %lli\n", props->name, connector->prop_values[i]); + } + } + + drmModeFreeProperty(props); + } + } + } else { + if (connector->count_props) { + printf("\t\tprops"); + for (i = 0; i < connector->count_props; i++) + printf(" %i", connector->props[i]); + printf("\n"); + } + } + + if (modes) { + for (i = 0; i < connector->count_modes; i++) { + mode = &connector->modes[i]; + printMode(mode); + } + } + + return 0; +} + +int printEncoder(int fd, drmModeResPtr res, drmModeEncoderPtr encoder, uint32_t id) +{ + printf("Encoder\n"); + printf("\tid :%i\n", id); + printf("\tcrtc :%d\n", encoder->crtc); + printf("\ttype :%d\n", encoder->encoder_type); + printf("\tcrtcs :%d\n", encoder->crtcs); + printf("\tclones :%d\n", encoder->clones); + return 0; +} + +int printCrtc(int fd, drmModeResPtr res, drmModeCrtcPtr crtc, uint32_t id) +{ + printf("Crtc\n"); + printf("\tid : %i\n", id); + printf("\tx : %i\n", crtc->x); + printf("\ty : %i\n", crtc->y); + printf("\twidth : %i\n", crtc->width); + printf("\theight : %i\n", crtc->height); + printf("\tmode : %p\n", &crtc->mode); + printf("\tgamma size : %d\n", crtc->gamma_size); + printf("\tnum connectors : %i\n", crtc->count_connectors); + printf("\tconnectors : %i\n", crtc->connectors); + printf("\tnum possible : %i\n", crtc->count_possibles); + printf("\tpossibles : %i\n", crtc->possibles); + + return 0; +} + +int printFrameBuffer(int fd, drmModeResPtr res, drmModeFBPtr fb) +{ + printf("Framebuffer\n"); + printf("\thandle : %i\n", fb->handle); + printf("\twidth : %i\n", fb->width); + printf("\theight : %i\n", fb->height); + printf("\tpitch : %i\n", fb->pitch);; + printf("\tbpp : %i\n", fb->bpp); + printf("\tdepth : %i\n", fb->depth); + printf("\tbuffer_id : %i\n", fb->buffer_id); + + return 0; +} + +int printRes(int fd, drmModeResPtr res) +{ + int i; + drmModeFBPtr fb; + drmModeCrtcPtr crtc; + drmModeEncoderPtr encoder; + drmModeConnectorPtr connector; + + printf("Resources\n\n"); + + printf("count_connectors : %i\n", res->count_connectors); + printf("count_encoders : %i\n", res->count_encoders); + printf("count_crtcs : %i\n", res->count_crtcs); + printf("count_fbs : %i\n", res->count_fbs); + + printf("\n"); + + if (connectors) { + for (i = 0; i < res->count_connectors; i++) { + connector = drmModeGetConnector(fd, res->connectors[i]); + + if (!connector) + printf("Could not get connector %i\n", i); + else { + printConnector(fd, res, connector, res->connectors[i]); + drmModeFreeConnector(connector); + } + } + printf("\n"); + } + + + if (encoders) { + for (i = 0; i < res->count_encoders; i++) { + encoder = drmModeGetEncoder(fd, res->encoders[i]); + + if (!encoder) + printf("Could not get encoder %i\n", i); + else { + printEncoder(fd, res, encoder, res->encoders[i]); + drmModeFreeEncoder(encoder); + } + } + printf("\n"); + } + + if (crtcs) { + for (i = 0; i < res->count_crtcs; i++) { + crtc = drmModeGetCrtc(fd, res->crtcs[i]); + + if (!crtc) + printf("Could not get crtc %i\n", i); + else { + printCrtc(fd, res, crtc, res->crtcs[i]); + drmModeFreeCrtc(crtc); + } + } + printf("\n"); + } + + if (fbs) { + for (i = 0; i < res->count_fbs; i++) { + fb = drmModeGetFB(fd, res->fbs[i]); + + if (!fb) + printf("Could not get fb %i\n", res->fbs[i]); + else { + printFrameBuffer(fd, res, fb); + drmModeFreeFB(fb); + } + } + } + + return 0; +} + +void args(int argc, char **argv) +{ + int i; + + fbs = 0; + edid = 0; + crtcs = 0; + modes = 0; + encoders = 0; + full_modes = 0; + full_props = 0; + connectors = 0; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-fb") == 0) { + fbs = 1; + } else if (strcmp(argv[i], "-crtcs") == 0) { + crtcs = 1; + } else if (strcmp(argv[i], "-cons") == 0) { + connectors = 1; + modes = 1; + } else if (strcmp(argv[i], "-modes") == 0) { + connectors = 1; + modes = 1; + } else if (strcmp(argv[i], "-full") == 0) { + connectors = 1; + modes = 1; + full_modes = 1; + } else if (strcmp(argv[i], "-props") == 0) { + connectors = 1; + full_props = 1; + } else if (strcmp(argv[i], "-edids") == 0) { + connectors = 1; + edid = 1; + } else if (strcmp(argv[i], "-encoders") == 0) { + encoders = 1; + } else if (strcmp(argv[i], "-v") == 0) { + fbs = 1; + edid = 1; + crtcs = 1; + modes = 1; + encoders = 1; + full_modes = 1; + full_props = 1; + connectors = 1; + } + } + + if (argc == 1) { + fbs = 1; + modes = 1; + full_modes = 0; + encoders = 1; + connectors = 1; + crtcs = 1; + full_props = 0; + edid = 1; + } +} +int main(int argc, char **argv) +{ + int fd; + drmModeResPtr res; + + args(argc, argv); + + printf("Starting test\n"); + + fd = drmOpen("i915", NULL); + + if (fd < 0) { + printf("Failed to open the card fb (%d)\n",fd); + return 1; + } + + res = drmModeGetResources(fd); + if (res == 0) { + printf("Failed to get resources from card\n"); + drmClose(fd); + return 1; + } + + printRes(fd, res); + + drmModeFreeResources(res); + + printf("Ok\n"); + + return 0; +} diff --git a/tests/modeprint/test b/tests/modeprint/test new file mode 100755 index 00000000..bd1952cc --- /dev/null +++ b/tests/modeprint/test @@ -0,0 +1 @@ +LD_PRELOAD=../../libdrm/.libs/libdrm.so ./app $@ -- cgit v1.2.3 From 4f233ce61858b94e0c1bd36e331b36d1b59512e5 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Wed, 2 Jul 2008 22:46:44 +0200 Subject: tests: Updated modeprint --- tests/modeprint/modetest.c | 132 +++++++++++++++++++++++++-------------------- 1 file changed, 73 insertions(+), 59 deletions(-) (limited to 'tests') diff --git a/tests/modeprint/modetest.c b/tests/modeprint/modetest.c index 36925a0b..3f00922f 100644 --- a/tests/modeprint/modetest.c +++ b/tests/modeprint/modetest.c @@ -55,12 +55,63 @@ int printMode(struct drm_mode_modeinfo *mode) return 0; } +int printProperty(int fd, drmModeResPtr res, drmModePropertyPtr props, uint64_t value) +{ + const unsigned char *name = NULL; + int j; + + printf("Property: %s\n", props->name); + printf("\tid : %i\n", props->prop_id); + printf("\tflags : %i\n", props->flags); + printf("\tcount_values : %d\n", props->count_values); + + + if (props->count_values) { + printf("\tvalues :"); + for (j = 0; j < props->count_values; j++) + printf(" %lld", props->values[j]); + printf("\n"); + } + + + printf("\tcount_enums : %d\n", props->count_enums); + + if (props->flags & DRM_MODE_PROP_BLOB) { + drmModePropertyBlobPtr blob; + + blob = drmModeGetPropertyBlob(fd, value); + if (blob) { + printf("blob is %d length, %08X\n", blob->length, *(uint32_t *)blob->data); + drmModeFreePropertyBlob(blob); + } else { + printf("error getting blob %lld\n", value); + } + + } else { + if (!strncmp(props->name, "DPMS", 4)) + ; + + for (j = 0; j < props->count_enums; j++) { + printf("\t\t%lld = %s\n", props->enums[j].value, props->enums[j].name); + if (props->enums[j].value == value) + name = props->enums[j].name; + } + + if (props->count_enums && name) { + printf("\tcon_value : %s\n", name); + } else { + printf("\tcon_value : %lld\n", value); + } + } + + return 0; +} + int printConnector(int fd, drmModeResPtr res, drmModeConnectorPtr connector, uint32_t id) { - int i = 0, j; + int i = 0; struct drm_mode_modeinfo *mode = NULL; drmModePropertyPtr props; - unsigned char *name = NULL; printf("Connector: %d-%d\n", connector->connector_type, connector->connector_type_id); printf("\tid : %i\n", id); @@ -69,73 +120,36 @@ int printConnector(int fd, drmModeResPtr res, drmModeConnectorPtr connector, uin printf("\tsize : %ix%i (mm)\n", connector->mmWidth, connector->mmHeight); printf("\tcount_modes : %i\n", connector->count_modes); printf("\tcount_props : %i\n", connector->count_props); - printf("\tcount_encoders : %i\n", connector->count_encoders); + if (connector->count_props) { + printf("\tprops :"); + for (i = 0; i < connector->count_props; i++) + printf(" %i", connector->props[i]); + printf("\n"); + } + printf("\tcount_encoders : %i\n", connector->count_encoders); if (connector->count_encoders) { - printf("\t\tencoders"); + printf("\tencoders :"); for (i = 0; i < connector->count_encoders; i++) printf(" %i", connector->encoders[i]); printf("\n"); } + if (modes) { + for (i = 0; i < connector->count_modes; i++) { + mode = &connector->modes[i]; + printMode(mode); + } + } + if (full_props) { for (i = 0; i < connector->count_props; i++) { props = drmModeGetProperty(fd, connector->props[i]); - name = NULL; if (props) { - printf("Property: %s\n", props->name); - printf("\tid: %i\n", props->prop_id); - printf("\tflags: %i\n", props->flags); - printf("\tvalues %d: ", props->count_values); - for (j = 0; j < props->count_values; j++) - printf("%lld ", props->values[j]); - - printf("\n\tenums %d: \n", props->count_enums); - - if (props->flags & DRM_MODE_PROP_BLOB) { - drmModePropertyBlobPtr blob; - - blob = drmModeGetPropertyBlob(fd, connector->prop_values[i]); - if (blob) { - printf("blob is %d length, %08X\n", blob->length, *(uint32_t *)blob->data); - drmModeFreePropertyBlob(blob); - } - - } else { - if (!strncmp(props->name, "DPMS", 4)) - ; - - for (j = 0; j < props->count_enums; j++) { - printf("\t\t%lld = %s\n", props->enums[j].value, props->enums[j].name); - if (connector->prop_values[i] == props->enums[j].value) - name = props->enums[j].name; - - } - - if (props->count_enums && name) { - printf("\tconnector property name %s %s\n", props->name, name); - } else { - printf("\tconnector property id %s %lli\n", props->name, connector->prop_values[i]); - } - } - + printProperty(fd, res, props, connector->prop_values[i]); drmModeFreeProperty(props); } } - } else { - if (connector->count_props) { - printf("\t\tprops"); - for (i = 0; i < connector->count_props; i++) - printf(" %i", connector->props[i]); - printf("\n"); - } - } - - if (modes) { - for (i = 0; i < connector->count_modes; i++) { - mode = &connector->modes[i]; - printMode(mode); - } } return 0; @@ -310,13 +324,13 @@ void args(int argc, char **argv) if (argc == 1) { fbs = 1; + edid = 1; + crtcs = 1; modes = 1; - full_modes = 0; encoders = 1; - connectors = 1; - crtcs = 1; + full_modes = 0; full_props = 0; - edid = 1; + connectors = 1; } } int main(int argc, char **argv) -- cgit v1.2.3 From 49e1fa1d503bb66949d825c41c1d97c83cf86361 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Wed, 2 Jul 2008 23:12:33 +0200 Subject: tests: modeprint s/fb/fd/ --- tests/modeprint/modetest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/modeprint/modetest.c b/tests/modeprint/modetest.c index 3f00922f..d8a94709 100644 --- a/tests/modeprint/modetest.c +++ b/tests/modeprint/modetest.c @@ -345,7 +345,7 @@ int main(int argc, char **argv) fd = drmOpen("i915", NULL); if (fd < 0) { - printf("Failed to open the card fb (%d)\n",fd); + printf("Failed to open the card fd (%d)\n",fd); return 1; } -- cgit v1.2.3 From aa2d3cfc168481b7637d935af990ce447012ebfe Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 3 Jul 2008 00:03:48 +0200 Subject: tests: Fix faulty error messages in modeprint --- tests/modeprint/modetest.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/modeprint/modetest.c b/tests/modeprint/modetest.c index d8a94709..f0f8abd4 100644 --- a/tests/modeprint/modetest.c +++ b/tests/modeprint/modetest.c @@ -220,7 +220,7 @@ int printRes(int fd, drmModeResPtr res) connector = drmModeGetConnector(fd, res->connectors[i]); if (!connector) - printf("Could not get connector %i\n", i); + printf("Could not get connector %i\n", res->connectors[i]); else { printConnector(fd, res, connector, res->connectors[i]); drmModeFreeConnector(connector); @@ -235,7 +235,7 @@ int printRes(int fd, drmModeResPtr res) encoder = drmModeGetEncoder(fd, res->encoders[i]); if (!encoder) - printf("Could not get encoder %i\n", i); + printf("Could not get encoder %i\n", res->encoders[i]); else { printEncoder(fd, res, encoder, res->encoders[i]); drmModeFreeEncoder(encoder); @@ -249,7 +249,7 @@ int printRes(int fd, drmModeResPtr res) crtc = drmModeGetCrtc(fd, res->crtcs[i]); if (!crtc) - printf("Could not get crtc %i\n", i); + printf("Could not get crtc %i\n", res->crtcs[i]); else { printCrtc(fd, res, crtc, res->crtcs[i]); drmModeFreeCrtc(crtc); -- cgit v1.2.3 From 94cf07bff1bf9a42ba6360f8feaa441b763b337f Mon Sep 17 00:00:00 2001 From: Maarten Maathuis Date: Thu, 3 Jul 2008 00:30:00 +0200 Subject: Forgot to fix the modeprint test. --- tests/modeprint/modetest.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'tests') diff --git a/tests/modeprint/modetest.c b/tests/modeprint/modetest.c index f0f8abd4..d5cbbc56 100644 --- a/tests/modeprint/modetest.c +++ b/tests/modeprint/modetest.c @@ -176,10 +176,6 @@ int printCrtc(int fd, drmModeResPtr res, drmModeCrtcPtr crtc, uint32_t id) printf("\theight : %i\n", crtc->height); printf("\tmode : %p\n", &crtc->mode); printf("\tgamma size : %d\n", crtc->gamma_size); - printf("\tnum connectors : %i\n", crtc->count_connectors); - printf("\tconnectors : %i\n", crtc->connectors); - printf("\tnum possible : %i\n", crtc->count_possibles); - printf("\tpossibles : %i\n", crtc->possibles); return 0; } -- cgit v1.2.3 From 7cbc5f6145046f3775e3b3ca2862bfb71831ec44 Mon Sep 17 00:00:00 2001 From: Maarten Maathuis Date: Sat, 5 Jul 2008 12:04:07 +0200 Subject: 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. --- libdrm/xf86drmMode.c | 21 ++++++++------------- libdrm/xf86drmMode.h | 10 +++++----- linux-core/drm_crtc.c | 18 +++++++++--------- shared-core/drm.h | 21 +++++++++------------ tests/modeprint/modetest.c | 25 +++++++++++++++++-------- 5 files changed, 48 insertions(+), 47 deletions(-) (limited to 'tests') diff --git a/libdrm/xf86drmMode.c b/libdrm/xf86drmMode.c index ca21a961..c3921ee9 100644 --- a/libdrm/xf86drmMode.c +++ b/libdrm/xf86drmMode.c @@ -284,11 +284,6 @@ int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId, { struct drm_mode_crtc crtc; - crtc.count_connectors = 0; - crtc.connectors = 0; - crtc.count_possibles = 0; - crtc.possibles = 0; - crtc.x = x; crtc.y = y; crtc.crtc_id = crtcId; @@ -343,8 +338,8 @@ drmModeEncoderPtr drmModeGetEncoder(int fd, uint32_t encoder_id) enc.encoder_id = encoder_id; enc.encoder_type = 0; - enc.crtcs = 0; - enc.clones = 0; + enc.possible_crtcs = 0; + enc.possible_clones = 0; if (ioctl(fd, DRM_IOCTL_MODE_GETENCODER, &enc)) return 0; @@ -353,10 +348,10 @@ drmModeEncoderPtr drmModeGetEncoder(int fd, uint32_t encoder_id) return 0; r->encoder_id = enc.encoder_id; - r->crtc = enc.crtc; + r->crtc_id = enc.crtc_id; r->encoder_type = enc.encoder_type; - r->crtcs = enc.crtcs; - r->clones = enc.clones; + r->possible_crtcs = enc.possible_crtcs; + r->possible_clones = enc.possible_clones; return r; } @@ -370,7 +365,7 @@ drmModeConnectorPtr drmModeGetConnector(int fd, uint32_t connector_id) struct drm_mode_get_connector conn; drmModeConnectorPtr r = NULL; - conn.connector = connector_id; + conn.connector_id = connector_id; conn.connector_type_id = 0; conn.connector_type = 0; conn.count_modes = 0; @@ -402,8 +397,8 @@ drmModeConnectorPtr drmModeGetConnector(int fd, uint32_t connector_id) goto err_allocs; } - r->connector_id = conn.connector; - r->encoder = conn.encoder; + r->connector_id = conn.connector_id; + r->encoder_id = conn.encoder_id; r->connection = conn.connection; r->mmWidth = conn.mm_width; r->mmHeight = conn.mm_height; diff --git a/libdrm/xf86drmMode.h b/libdrm/xf86drmMode.h index 3e2f5c0e..59612a94 100644 --- a/libdrm/xf86drmMode.h +++ b/libdrm/xf86drmMode.h @@ -92,7 +92,7 @@ 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; int mode_valid; struct drm_mode_modeinfo mode; @@ -104,9 +104,9 @@ typedef struct _drmModeCrtc { typedef struct _drmModeEncoder { unsigned int encoder_id; unsigned int encoder_type; - uint32_t crtc; - uint32_t crtcs; - uint32_t clones; + unsigned int crtc_id; + uint32_t possible_crtcs; + uint32_t possible_clones; } drmModeEncoder, *drmModeEncoderPtr; typedef enum { @@ -126,7 +126,7 @@ typedef enum { typedef struct _drmModeConnector { 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_id; drmModeConnection connection; diff --git a/linux-core/drm_crtc.c b/linux-core/drm_crtc.c index 3ee0f86c..f8e09a8c 100644 --- a/linux-core/drm_crtc.c +++ b/linux-core/drm_crtc.c @@ -1046,7 +1046,6 @@ int drm_mode_getcrtc(struct drm_device *dev, else crtc_resp->fb_id = 0; - crtc_resp->connectors = 0; if (crtc->enabled) { 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)); - 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); - 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) { ret = -EINVAL; goto out; @@ -1130,6 +1129,7 @@ int drm_mode_getconnector(struct drm_device *dev, list_for_each_entry(mode, &connector->modes, head) mode_count++; + out_resp->connector_id = connector->base.id; out_resp->connector_type = connector->connector_type; out_resp->connector_type_id = connector->connector_type_id; 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->connection = connector->status; if (connector->encoder) - out_resp->encoder = connector->encoder->base.id; + out_resp->encoder_id = connector->encoder->base.id; 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 */ 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); if (encoder->crtc) - enc_resp->crtc = encoder->crtc->base.id; + enc_resp->crtc_id = encoder->crtc->base.id; else - enc_resp->crtc = 0; + enc_resp->crtc_id = 0; enc_resp->encoder_type = encoder->encoder_type; enc_resp->encoder_id = encoder->base.id; - enc_resp->crtcs = encoder->possible_crtcs; - enc_resp->clones = encoder->possible_clones; + enc_resp->possible_crtcs = encoder->possible_crtcs; + enc_resp->possible_clones = encoder->possible_clones; out: mutex_unlock(&dev->mode_config.mutex); diff --git a/shared-core/drm.h b/shared-core/drm.h index c9b40e78..b64e265d 100644 --- a/shared-core/drm.h +++ b/shared-core/drm.h @@ -1059,17 +1059,13 @@ struct drm_mode_card_res { struct drm_mode_crtc { uint64_t set_connectors_ptr; + int count_connectors; unsigned int crtc_id; /**< Id */ unsigned int fb_id; /**< Id of framebuffer */ 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; int mode_valid; struct drm_mode_modeinfo mode; @@ -1083,12 +1079,13 @@ struct drm_mode_crtc { struct drm_mode_get_encoder { - uint32_t encoder_type; - uint32_t encoder_id; + unsigned int encoder_type; + unsigned int encoder_id; + + unsigned int crtc_id; /**< Id of crtc */ - unsigned int crtc; /**< 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. */ @@ -1126,8 +1123,8 @@ struct drm_mode_get_connector { int count_props; int count_encoders; - unsigned int encoder; /**< Current Encoder */ - unsigned int connector; /**< Id */ + unsigned int encoder_id; /**< Current Encoder */ + unsigned int connector_id; /**< Id */ unsigned int connector_type; unsigned int connector_type_id; diff --git a/tests/modeprint/modetest.c b/tests/modeprint/modetest.c index d5cbbc56..cefa5262 100644 --- a/tests/modeprint/modetest.c +++ b/tests/modeprint/modetest.c @@ -17,6 +17,7 @@ int full_modes; int encoders; int crtcs; int fbs; +char *module_name; 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("\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("\tsize : %ix%i (mm)\n", connector->mmWidth, connector->mmHeight); 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("\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("\tcrtcs :%d\n", encoder->crtcs); - printf("\tclones :%d\n", encoder->clones); + printf("\tpossible_crtcs :%d\n", encoder->possible_crtcs); + printf("\tpossible_clones :%d\n", encoder->possible_clones); return 0; } @@ -283,7 +284,9 @@ void args(int argc, char **argv) full_props = 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) { fbs = 1; } else if (strcmp(argv[i], "-crtcs") == 0) { @@ -316,9 +319,9 @@ void args(int argc, char **argv) full_props = 1; connectors = 1; } - } + } - if (argc == 1) { + if (argc == 2) { fbs = 1; edid = 1; crtcs = 1; @@ -329,16 +332,22 @@ void args(int argc, char **argv) connectors = 1; } } + int main(int argc, char **argv) { int fd; drmModeResPtr res; + if (argc == 1) { + printf("Please add modulename as first argument\n"); + return 1; + } + args(argc, argv); printf("Starting test\n"); - fd = drmOpen("i915", NULL); + fd = drmOpen(module_name, NULL); if (fd < 0) { printf("Failed to open the card fd (%d)\n",fd); -- cgit v1.2.3 From 0443d2a32ab791867cb0ce361a3905357d6a87d9 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sat, 26 Jul 2008 08:56:43 +1000 Subject: tests: add some basic radeon gem tests --- tests/Makefile.am | 4 +- tests/radeon_gem_basic.c | 114 ++++++++++++++++++++++++++++++++++++++++ tests/radeon_gem_mmap.c | 132 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 249 insertions(+), 1 deletion(-) create mode 100644 tests/radeon_gem_basic.c create mode 100644 tests/radeon_gem_mmap.c (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index 718cc436..a5f9967b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -25,7 +25,9 @@ TESTS = auth \ updatedraw \ gem_basic \ gem_readwrite \ - gem_mmap + gem_mmap \ + radeon_gem_mmap \ + radeon_gem_basic EXTRA_PROGRAMS = $(TESTS) CLEANFILES = $(EXTRA_PROGRAMS) $(EXTRA_LTLIBRARIES) diff --git a/tests/radeon_gem_basic.c b/tests/radeon_gem_basic.c new file mode 100644 index 00000000..d8231879 --- /dev/null +++ b/tests/radeon_gem_basic.c @@ -0,0 +1,114 @@ +/* + * Copyright © 2008 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + * Authors: + * Eric Anholt + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "drm.h" +#include "radeon_drm.h" + +static void +test_bad_close(int fd) +{ + struct drm_gem_close close; + int ret; + + printf("Testing error return on bad close ioctl.\n"); + + close.handle = 0x10101010; + ret = ioctl(fd, DRM_IOCTL_GEM_CLOSE, &close); + + assert(ret == -1 && errno == EINVAL); +} + +static void +test_create_close(int fd) +{ + struct drm_radeon_gem_create create; + struct drm_gem_close close; + int ret; + + printf("Testing creating and closing an object.\n"); + + memset(&create, 0, sizeof(create)); + create.size = 16 * 1024; + ret = ioctl(fd, DRM_IOCTL_RADEON_GEM_CREATE, &create); + assert(ret == 0); + + close.handle = create.handle; + ret = ioctl(fd, DRM_IOCTL_GEM_CLOSE, &close); +} + +static void +test_create_fd_close(int fd) +{ + struct drm_radeon_gem_create create; + int ret; + + printf("Testing closing with an object allocated.\n"); + + memset(&create, 0, sizeof(create)); + create.size = 16 * 1024; + ret = ioctl(fd, DRM_IOCTL_RADEON_GEM_CREATE, &create); + assert(ret == 0); + + close(fd); +} + +int test_gem_info(int fd) +{ + struct drm_radeon_gem_info info; + int ret; + + ret = ioctl(fd, DRM_IOCTL_RADEON_GEM_INFO, &info); + assert(ret == 0); + + fprintf(stderr,"%lld %lld %lld %lld %lld\n", + info.gtt_start, info.gtt_size, + info.vram_start, info.vram_size, + info.vram_visible); + +} + +int main(int argc, char **argv) +{ + int fd; + + fd = drm_open_any(); + + test_gem_info(fd); + test_bad_close(fd); + test_create_close(fd); + test_create_fd_close(fd); + + return 0; +} diff --git a/tests/radeon_gem_mmap.c b/tests/radeon_gem_mmap.c new file mode 100644 index 00000000..aa7b0196 --- /dev/null +++ b/tests/radeon_gem_mmap.c @@ -0,0 +1,132 @@ +/* + * Copyright © 2008 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + * Authors: + * Eric Anholt + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "drm.h" +#include "radeon_drm.h" + +#define OBJECT_SIZE 16384 + +int do_read(int fd, int handle, void *buf, int offset, int size) +{ + struct drm_radeon_gem_pread read; + + /* Ensure that we don't have any convenient data in buf in case + * we fail. + */ + memset(buf, 0xd0, size); + + memset(&read, 0, sizeof(read)); + read.handle = handle; + read.data_ptr = (uintptr_t)buf; + read.size = size; + read.offset = offset; + + return ioctl(fd, DRM_IOCTL_RADEON_GEM_PREAD, &read); +} + +int do_write(int fd, int handle, void *buf, int offset, int size) +{ + struct drm_radeon_gem_pwrite write; + + memset(&write, 0, sizeof(write)); + write.handle = handle; + write.data_ptr = (uintptr_t)buf; + write.size = size; + write.offset = offset; + + return ioctl(fd, DRM_IOCTL_RADEON_GEM_PWRITE, &write); +} + +int main(int argc, char **argv) +{ + int fd; + struct drm_radeon_gem_create create; + struct drm_radeon_gem_mmap mmap; + struct drm_gem_close unref; + uint8_t expected[OBJECT_SIZE]; + uint8_t buf[OBJECT_SIZE]; + uint8_t *addr; + int ret; + int handle; + + fd = drm_open_any(); + + memset(&mmap, 0, sizeof(mmap)); + mmap.handle = 0x10101010; + mmap.offset = 0; + mmap.size = 4096; + printf("Testing mmaping of bad object.\n"); + ret = ioctl(fd, DRM_IOCTL_RADEON_GEM_MMAP, &mmap); + assert(ret == -1 && errno == EINVAL); + + memset(&create, 0, sizeof(create)); + create.size = OBJECT_SIZE; + ret = ioctl(fd, DRM_IOCTL_RADEON_GEM_CREATE, &create); + assert(ret == 0); + handle = create.handle; + + printf("Testing mmaping of newly created object.\n"); + mmap.handle = handle; + mmap.offset = 0; + mmap.size = OBJECT_SIZE; + ret = ioctl(fd, DRM_IOCTL_RADEON_GEM_MMAP, &mmap); + assert(ret == 0); + addr = (uint8_t *)(uintptr_t)mmap.addr_ptr; + + printf("Testing contents of newly created object.\n"); + memset(expected, 0, sizeof(expected)); + assert(memcmp(addr, expected, sizeof(expected)) == 0); + + printf("Testing coherency of writes and mmap reads.\n"); + memset(buf, 0, sizeof(buf)); + memset(buf + 1024, 0x01, 1024); + memset(expected + 1024, 0x01, 1024); + ret = do_write(fd, handle, buf, 0, OBJECT_SIZE); + assert(ret == 0); + assert(memcmp(buf, addr, sizeof(buf)) == 0); + + printf("Testing that mapping stays after close\n"); + unref.handle = handle; + ret = ioctl(fd, DRM_IOCTL_GEM_CLOSE, &unref); + assert(ret == 0); + assert(memcmp(buf, addr, sizeof(buf)) == 0); + + printf("Testing unmapping\n"); + munmap(addr, OBJECT_SIZE); + + close(fd); + + return 0; +} -- cgit v1.2.3 From 8f5d8ba97e82072b2403bff0bf836a09640108a6 Mon Sep 17 00:00:00 2001 From: Jesse Barnes Date: Wed, 19 Nov 2008 10:54:11 -0800 Subject: Update modetest --- tests/modetest/Makefile | 14 ++ tests/modetest/modetest.c | 410 ++++++++++++++++++++++++++++++++++++++++++++++ tests/modetest/test | 2 + 3 files changed, 426 insertions(+) create mode 100644 tests/modetest/Makefile create mode 100644 tests/modetest/modetest.c create mode 100755 tests/modetest/test (limited to 'tests') diff --git a/tests/modetest/Makefile b/tests/modetest/Makefile new file mode 100644 index 00000000..8583ae82 --- /dev/null +++ b/tests/modetest/Makefile @@ -0,0 +1,14 @@ + +all: app + +#CFLAGS = -g -ansi -pedantic -DPOSIX_C_SOURCE=199309L \ +# -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE \ + +app: modetest.c + gcc $(CFLAGS) -o app -Wall -I../../libdrm -I../../libdrm/intel -I../../shared-core -L../../libdrm/.libs -L../../libdrm/intel/.libs -ldrm -ldrm_intel modetest.c + +clean: + @rm -f app + +run: app + sudo ./test diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c new file mode 100644 index 00000000..66c7f9cd --- /dev/null +++ b/tests/modetest/modetest.c @@ -0,0 +1,410 @@ +/* + * DRM based mode setting test program + * Copyright 2008 Tungsten Graphics + * Jakob Bornecrantz + * Copyright 2008 Intel Corporation + * Jesse Barnes + */ +#include +#include +#include +#include +#include +#include +#include + +#include "xf86drm.h" +#include "xf86drmMode.h" +#include "intel_bufmgr.h" + +drmModeRes *resources; +int fd, modes; + +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) + +struct type_name { + int type; + char *name; +}; + +#define type_name_fn(res) \ +char * res##_str(int type) { \ + int i; \ + for (i = 0; i < ARRAY_SIZE(res##_names); i++) { \ + if (res##_names[i].type == type) \ + return res##_names[i].name; \ + } \ + return "(invalid)"; \ +} + +struct type_name encoder_type_names[] = { + { DRM_MODE_ENCODER_NONE, "none" }, + { DRM_MODE_ENCODER_DAC, "DAC" }, + { DRM_MODE_ENCODER_TMDS, "TMDS" }, + { DRM_MODE_ENCODER_LVDS, "LVDS" }, + { DRM_MODE_ENCODER_TVDAC, "TVDAC" }, +}; + +type_name_fn(encoder_type) + +struct type_name connector_status_names[] = { + { DRM_MODE_CONNECTED, "connected" }, + { DRM_MODE_DISCONNECTED, "disconnected" }, + { DRM_MODE_UNKNOWNCONNECTION, "unknown" }, +}; + +type_name_fn(connector_status) + +struct type_name connector_type_names[] = { + { DRM_MODE_CONNECTOR_Unknown, "unknown" }, + { DRM_MODE_CONNECTOR_VGA, "VGA" }, + { DRM_MODE_CONNECTOR_DVII, "DVI-I" }, + { DRM_MODE_CONNECTOR_DVID, "DVI-D" }, + { DRM_MODE_CONNECTOR_DVIA, "DVI-A" }, + { DRM_MODE_CONNECTOR_Composite, "composite" }, + { DRM_MODE_CONNECTOR_SVIDEO, "s-video" }, + { DRM_MODE_CONNECTOR_LVDS, "LVDS" }, + { DRM_MODE_CONNECTOR_Component, "component" }, + { DRM_MODE_CONNECTOR_9PinDIN, "9-pin DIN" }, + { DRM_MODE_CONNECTOR_DisplayPort, "displayport" }, + { DRM_MODE_CONNECTOR_HDMIA, "HDMI-A" }, + { DRM_MODE_CONNECTOR_HDMIB, "HDMI-B" }, +}; + +type_name_fn(connector_type) + +void dump_encoders(void) +{ + drmModeEncoder *encoder; + int i; + + printf("Encoders:\n"); + printf("id\tcrtc\ttype\tpossible crtcs\tpossible clones\t\n"); + for (i = 0; i < resources->count_encoders; i++) { + encoder = drmModeGetEncoder(fd, resources->encoders[i]); + + if (!encoder) { + fprintf(stderr, "could not get encoder %i: %s\n", + resources->encoders[i], strerror(errno)); + continue; + } + printf("%d\t%d\t%s\t0x%08x\t0x%08x\n", + encoder->encoder_id, + encoder->crtc_id, + encoder_type_str(encoder->encoder_type), + encoder->possible_crtcs, + encoder->possible_clones); + drmModeFreeEncoder(encoder); + } +} + +void dump_connectors(void) +{ + drmModeConnector *connector; + int i, j; + + printf("Connectors:\n"); + printf("id\tencoder\tstatus\t\ttype\tsize (mm)\tmodes\n"); + for (i = 0; i < resources->count_connectors; i++) { + connector = drmModeGetConnector(fd, resources->connectors[i]); + + if (!connector) { + fprintf(stderr, "could not get connector %i: %s\n", + resources->connectors[i], strerror(errno)); + continue; + } + + printf("%d\t%d\t%s\t%s\t%dx%d\t\t%d\n", + connector->connector_id, + connector->encoder_id, + connector_status_str(connector->connection), + connector_type_str(connector->connector_type), + connector->mmWidth, connector->mmHeight, + connector->count_modes); + + if (!connector->count_modes) + continue; + + printf(" modes:\n"); + printf(" name refresh (Hz) hdisp hss hse htot vdisp " + "vss vse vtot)\n"); + for (j = 0; j < connector->count_modes; j++) { + struct drm_mode_modeinfo *mode; + + mode = &connector->modes[j]; + printf(" %s %.02f %d %d %d %d %d %d %d %d\n", + mode->name, + (float)mode->vrefresh / 1000, + mode->hdisplay, + mode->hsync_start, + mode->hsync_end, + mode->htotal, + mode->vdisplay, + mode->vsync_start, + mode->vsync_end, + mode->vtotal); + } + drmModeFreeConnector(connector); + } +} + +void dump_crtcs(void) +{ + drmModeCrtc *crtc; + int i; + + for (i = 0; i < resources->count_crtcs; i++) { + crtc = drmModeGetCrtc(fd, resources->crtcs[i]); + + if (!crtc) { + fprintf(stderr, "could not get crtc %i: %s\n", + resources->crtcs[i], strerror(errno)); + continue; + } + drmModeFreeCrtc(crtc); + } +} + +void dump_framebuffers(void) +{ + drmModeFB *fb; + int i; + + for (i = 0; i < resources->count_fbs; i++) { + fb = drmModeGetFB(fd, resources->fbs[i]); + + if (!fb) { + fprintf(stderr, "could not get fb %i: %s\n", + resources->fbs[i], strerror(errno)); + continue; + } + drmModeFreeFB(fb); + } +} + +void set_mode(int connector_id, char *mode_str) +{ + drmModeConnector *connector; + drmModeEncoder *encoder = NULL; + struct drm_mode_modeinfo *mode = NULL; + drm_intel_bufmgr *bufmgr; + drm_intel_bo *bo; + unsigned int fb_id, *fb_ptr; + int i, j, size, ret, width, height; + + /* First, find the connector & mode */ + for (i = 0; i < resources->count_connectors; i++) { + connector = drmModeGetConnector(fd, resources->connectors[i]); + + if (!connector) { + fprintf(stderr, "could not get connector %i: %s\n", + resources->connectors[i], strerror(errno)); + drmModeFreeConnector(connector); + continue; + } + + if (!connector->count_modes) { + drmModeFreeConnector(connector); + continue; + } + + if (connector->connector_id != connector_id) { + drmModeFreeConnector(connector); + continue; + } + + for (j = 0; j < connector->count_modes; j++) { + mode = &connector->modes[j]; + if (!strcmp(mode->name, mode_str)) + break; + } + + /* Found it, break out */ + if (mode) + break; + + drmModeFreeConnector(connector); + } + + if (!mode) { + fprintf(stderr, "failed to find mode \"%s\"\n", mode_str); + return; + } + + width = mode->hdisplay; + height = mode->vdisplay; + + /* Now get the encoder */ + for (i = 0; i < resources->count_encoders; i++) { + encoder = drmModeGetEncoder(fd, resources->encoders[i]); + + if (!encoder) { + fprintf(stderr, "could not get encoder %i: %s\n", + resources->encoders[i], strerror(errno)); + drmModeFreeEncoder(encoder); + continue; + } + + if (encoder->encoder_id == connector->encoder_id) + break; + + drmModeFreeEncoder(encoder); + } + + bufmgr = drm_intel_bufmgr_gem_init(fd, 2<<20); + if (!bufmgr) { + fprintf(stderr, "failed to init bufmgr: %s\n", strerror(errno)); + return; + } + + /* Mode size at 32 bpp */ + size = width * height * 4; + + bo = drm_intel_bo_alloc(bufmgr, "frontbuffer", size, 4096); + if (!bo) { + fprintf(stderr, "failed to alloc buffer: %s\n", + strerror(errno)); + return; + } + + ret = drm_intel_bo_pin(bo, 4096); + if (ret) { + fprintf(stderr, "failed to pin buffer: %s\n", strerror(errno)); + return; + } + + ret = drm_intel_gem_bo_map_gtt(bo); + if (ret) { + fprintf(stderr, "failed to GTT map buffer: %s\n", + strerror(errno)); + return; + } + + fb_ptr = bo->virtual; + + /* paint the buffer blue */ + for (i = 0; i < width * height; i++) + fb_ptr[i] = 0xff; + + ret = drmModeAddFB(fd, width, height, 32, 32, width * 4, bo->handle, + &fb_id); + if (ret) { + fprintf(stderr, "failed to add fb: %s\n", strerror(errno)); + return; + } + + ret = drmModeSetCrtc(fd, encoder->crtc_id, fb_id, 0, 0, + &connector->connector_id, 1, mode); + if (ret) { + fprintf(stderr, "failed to set mode: %s\n", strerror(errno)); + return; + } +} + +extern char *optarg; +extern int optind, opterr, optopt; +static char optstr[] = "ecpmfs:"; + +void usage(char *name) +{ + fprintf(stderr, "usage: %s [-ecpmf]\n", name); + fprintf(stderr, "\t-e\tlist encoders\n"); + fprintf(stderr, "\t-c\tlist connectors\n"); + fprintf(stderr, "\t-p\tlist CRTCs (pipes)\n"); + fprintf(stderr, "\t-m\tlist modes\n"); + fprintf(stderr, "\t-f\tlist framebuffers\n"); + fprintf(stderr, "\t-s :\tset a mode\n"); + fprintf(stderr, "\n\tDefault is to dump all info.\n"); + exit(0); +} + +#define dump_resource(res) if (res) dump_##res() + +int main(int argc, char **argv) +{ + int c; + int encoders = 0, connectors = 0, crtcs = 0, framebuffers = 0; + char *modules[] = { "i915", "radeon" }; + char *modeset = NULL, *mode, *connector; + int i, connector_id; + + opterr = 0; + while ((c = getopt(argc, argv, optstr)) != -1) { + switch (c) { + case 'e': + encoders = 1; + break; + case 'c': + connectors = 1; + break; + case 'p': + crtcs = 1; + break; + case 'm': + modes = 1; + break; + case 'f': + framebuffers = 1; + break; + case 's': + modeset = strdup(optarg); + break; + default: + usage(argv[0]); + break; + } + } + + if (argc == 1) + encoders = connectors = crtcs = modes = framebuffers = 1; + + for (i = 0; i < ARRAY_SIZE(modules); i++) { + printf("trying to load module %s...", modules[i]); + fd = drmOpen(modules[i], NULL); + if (fd < 0) { + printf("failed.\n"); + } else { + printf("success.\n"); + break; + } + } + + if (i == ARRAY_SIZE(modules)) { + fprintf(stderr, "failed to load any modules, aborting.\n"); + return -1; + } + + resources = drmModeGetResources(fd); + if (!resources) { + fprintf(stderr, "drmModeGetResources failed: %s\n", + strerror(errno)); + drmClose(fd); + return 1; + } + + dump_resource(encoders); + dump_resource(connectors); + dump_resource(crtcs); + dump_resource(framebuffers); + + if (modeset) { + connector = strtok(modeset, ":"); + if (!connector) + usage(argv[0]); + connector_id = atoi(connector); + + mode = strtok(NULL, ":"); + if (!mode) + usage(argv[0]); + printf("setting connector %d to mode %s\n", connector_id, + mode); + set_mode(connector_id, mode); + sleep(3); + } + + sleep(3); + + drmModeFreeResources(resources); + + return 0; +} diff --git a/tests/modetest/test b/tests/modetest/test new file mode 100755 index 00000000..5bb552ef --- /dev/null +++ b/tests/modetest/test @@ -0,0 +1,2 @@ +export LD_LIBRARY_PATH=../../libdrm/.libs:../../libdrm/intel/.libs +LD_PRELOAD=../../libdrm/.libs/libdrm.so ./app $@ -- cgit v1.2.3