summaryrefslogtreecommitdiff
path: root/linux-core/intel_drv.h
AgeCommit message (Collapse)Author
2008-06-06intelfb: move mode sets into the intel crtcsDave Airlie
better place to store them.
2008-06-05modesetting: initial attempt at debonging fbDave Airlie
2008-06-04drm/modesetting: overhaul the fb create/delete.Dave Airlie
Move TTM code into the driver
2008-06-02drm: add functions to get/set gamma rampsDave Airlie
2008-06-02drm/modesetting: add best encoder finding for modesettingDave Airlie
This asks the driver to suggest the best encoder for the connector during the pick crtcs stage. Need to also do this during mode setting stages
2008-06-02drm/modesetting: another re-org of some internals.Dave Airlie
Move dpms into the helper functions. Move crtc into the encoder. Move disable unused functions into the helper.
2008-05-30modesetting: the great renaming.Dave Airlie
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
2008-05-30drm: attach an encoder.Dave Airlie
Time to do some renaming on the connectors I think
2008-05-30modesetting: reorganise out crtc/outputs are allocated.Dave Airlie
Use subclassing from the drivers to allocate the objects. This saves two objects being allocated for each crtc/output and generally makes exit paths cleaner.
2008-05-29modesetting: reorganise code into core and helper functions.Dave Airlie
This splits a lot of the core modesetting code out into a file of helper functions, that are only called from themselves and/or the driver. The driver gets called into more often or can call these functions from itself if it is a helper using driver. I've broken framebuffer resize doing this but I didn't like the API for that in any case.
2008-05-12fix kernel oops when removing fbHong Liu
drm_crtc->fb may point to NULL, f.e X server will allocate a new fb and assign it to the CRTC at startup, when X server exits, it will destroy the allocated fb, making drm_crtc->fb points to NULL.
2008-05-08i915: Changed intel_fb to use the new drm_crtc_set_config interfaceJakob Bornecrantz
2008-04-17Porting DVO stuffHong Liu
Ported from Xorg intel 2d driver. Changed interfaces definitions, which needed to be changed later if other device wants to use these DVO stuff.
2008-04-09Port pipe reservation code for load detectionJesse Barnes
TV out needs to do load detection, which means we have to find an available pipe to use for the detection. Port over the pipe reservation code for this purpose.
2008-04-08Improved DRM sysfs supportJesse Barnes
This patch ties outputs, output properties and hotplug events into the DRM core. Each output has a corresponding directory under the primary DRM device (usually card0) containing dpms, edid, modes, and connection status files. New hotplug change events occur when outputs are added or hotplug events are detected.
2008-03-11drm: hopefully fix cursors on 965Dave Airlie
2008-02-15i915: initial (and untested) TV out supportJesse Barnes
Ported from xf86-video-intel. Still need to tie in TV modes somehow, though preferably w/o using the properties mechanism.
2008-01-28Added cursor supportJakob Bornecrantz
2007-12-18Modesetting HotplugJakob Bornecrantz
2007-09-24Merge branch 'master' into modesetting-101 - TTM & typedef removalJesse Barnes
Conflicts: linux-core/drmP.h linux-core/drm_bo.c linux-core/drm_drv.c linux-core/drm_objects.h shared-core/drm.h shared-core/i915_dma.c shared-core/i915_drv.h shared-core/i915_irq.c Mostly removing typedefs that snuck into the modesetting code and updating to the latest TTM APIs. As of today, the i915 driver builds, but there are likely to be problems, so debugging and bugfixes will come next.
2007-05-18Move fbo creation to the specified fb driver which givesAlan Hourihane
it a chance to allocate the memory from whichever buffer it wants to.
2007-05-17Merge branch 'modesetting-101' of git+ssh://git.freedesktop.org/git/mesa/drm ↵Jesse Barnes
into origin/modesetting-101 Conflicts: linux-core/drm_crtc.c linux-core/drm_fb.c Lots of changes to merge with alanh's latest stuff: o fix use of fb->pitch now that it has the right value o add new helper for finding the CRTC given an FB o fix new fb_probe/fb_remove functions to take a CRTC o fixup callers of new FB routines o port drm_fb changes to intel_fb o check for errors after creating fb buffer object o go back to using cfb_imageblit since the accel stubs aren't ready
2007-05-17Fix FB pitch value (we had it wrong and were working around it in a fewJesse Barnes
places). Add new FB hooks to the drm driver structure and make i915 use them for an Intel specific FB driver. This will allow acceleration and better handling of the command stream.
2007-05-17Large changes for fbdev support.root
Change from DIRECTCOLOR to TRUECOLOR, and enable support for PSEUDOCOLOR. DIRECTCOLOR support needs more work. Add the ability to change the mode on the fbdev device. Support depth 8, 15, 16 and 24 (and 32). Add a /dev/fbX device per CRTC, but there's some code which doesn't allocate the fbX device unless the output is actually enabled. Read the code on this as it impacts the fbcon map flags. Pick CRTC's based on the available outputs. More work could be done here to match modes, so cloning could be achieved on outputs. This fits more inline with what the X code does.
2007-04-12Use crtc_from_pipe call in intel_lvds.c and add get_mode panel mode ↵Jesse Barnes
detection. Also fix up error case for when LVDS mode can't be determined. Leave placeholder code in place for BIOS mode probing and platform quirks.
2007-04-11export vblank routine for use by intel_display.c and intel_sdvo.c.Jesse Barnes
2007-04-10Finish bringing in LVDS code, re-add to Makefile. Needed other changes too:Jesse Barnes
- move EDID structures to drm_edid.h - add EDID info structure to drm_output - add a few routines to intel_display for getting current mode info - add some prototypes to intel_drv.h and drm_crtc.h
2007-04-05Add copyrights before I forgetJesse Barnes
2007-04-05Initial import of modesetting for intel driver in DRMDave Airlie
Software is furnished to do so, subject to * the following conditions: * * 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 NON-INFRINGEMENT. IN NO EVENT SHALL * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS 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. * * The above copyright notice and this permission notice (including the * next paragraph) shall be included in all copies or substantial portions * of the Software. * * **************************************************************************/ /* * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com> */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include <X11/Xlib.h> #include <X11/Xutil.h> #include <drm/drm.h> #include "xf86dri.h" #include "xf86drm.h" #include "stdio.h" #include "sys/types.h" #include <unistd.h> #include <string.h> #include <errno.h> #include <stdlib.h> #include "sys/mman.h" typedef struct { enum { haveNothing, haveDisplay, haveConnection, haveDriverName, haveDeviceInfo, haveDRM, haveContext } state; Display *display; int screen; drm_handle_t sAreaOffset; char *curBusID; char *driverName; int drmFD; XVisualInfo visualInfo; XID id; drm_context_t hwContext; void *driPriv; int driPrivSize; int fbSize; int fbOrigin; int fbStride; drm_handle_t fbHandle; int ddxDriverMajor; int ddxDriverMinor; int ddxDriverPatch; } TinyDRIContext; #ifndef __x86_64__ static unsigned fastrdtsc(void) { unsigned eax; __asm__ volatile ("\t" "pushl %%ebx\n\t" "cpuid\n\t" ".byte 0x0f, 0x31\n\t" "popl %%ebx\n":"=a" (eax) :"0"(0) :"ecx", "edx", "cc"); return eax; } #else static unsigned fastrdtsc(void) { unsigned eax; __asm__ volatile ("\t" "cpuid\n\t" ".byte 0x0f, 0x31\n\t":"=a" (eax) :"0"(0) :"ecx", "edx", "ebx", "cc"); return eax; } #endif void bmError(int val, const char *file, const char *function, int line) { fprintf(stderr, "Fatal video memory manager error \"%s\".\n" "Check kernel logs or set the LIBGL_DEBUG\n" "environment variable to \"verbose\" for more info.\n" "Detected in file %s, line %d, function %s.\n", strerror(-val), file, line, function); abort(); } #define BM_CKFATAL(val) \ do{ \ int tstVal = (val); \ if (tstVal) \ bmError(tstVal, __FILE__, __FUNCTION__, __LINE__); \ } while(0); static unsigned time_diff(unsigned t, unsigned t2) { return ((t < t2) ? t2 - t : 0xFFFFFFFFU - (t - t2 - 1)); } static int releaseContext(TinyDRIContext * ctx) { switch (ctx->state) { case haveContext: uniDRIDestroyContext(ctx->display, ctx->screen, ctx->id); case haveDRM: drmClose(ctx->drmFD); case haveDeviceInfo: XFree(ctx->driPriv); case haveDriverName: XFree(ctx->driverName); case haveConnection: XFree(ctx->curBusID); uniDRICloseConnection(ctx->display, ctx->screen); case haveDisplay: XCloseDisplay(ctx->display); default: break; } return -1; } static void readBuf(void *buf, unsigned long size) { volatile unsigned *buf32 = (unsigned *)buf; unsigned *end = (unsigned *)buf32 + size / sizeof(*buf32); while (buf32 < end) { (void)*buf32++; } } static int benchmarkBuffer(TinyDRIContext * ctx, unsigned long size, unsigned long *ticks) { unsigned long curTime, oldTime; int ret; drmBO buf; void *virtual; /* * Test system memory objects. */ oldTime = fastrdtsc(); BM_CKFATAL(drmBOCreate(ctx->drmFD, 0, size, 0, NULL, drm_bo_type_dc, DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE | DRM_BO_FLAG_MEM_LOCAL /*| DRM_BO_FLAG_NO_MOVE*/, 0, &buf)); curTime = fastrdtsc(); *ticks++ = time_diff(oldTime, curTime); oldTime = fastrdtsc(); BM_CKFATAL(drmBOMap(ctx->drmFD, &buf, DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0, &virtual)); curTime = fastrdtsc(); *ticks++ = time_diff(oldTime, curTime); oldTime = fastrdtsc(); memset(virtual, 0xF0, buf.size); curTime = fastrdtsc(); *ticks++ = time_diff(oldTime, curTime); oldTime = fastrdtsc(); memset(virtual, 0x0F, buf.size); curTime = fastrdtsc(); *ticks++ = time_diff(oldTime, curTime); oldTime = fastrdtsc(); readBuf(virtual, buf.size); curTime = fastrdtsc(); *ticks++ = time_diff(oldTime, curTime); oldTime = fastrdtsc(); BM_CKFATAL(drmBOUnmap(ctx->drmFD, &buf)); curTime = fastrdtsc(); *ticks++ = time_diff(oldTime, curTime); /* * Test TT bound buffer objects. */ 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)); curTime = fastrdtsc(); BM_CKFATAL(drmUnlock(ctx->drmFD, ctx->hwContext)); *ticks++ = time_diff(oldTime, curTime); oldTime = fastrdtsc(); BM_CKFATAL(drmBOMap(ctx->drmFD, &buf, DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0, &virtual)); curTime = fastrdtsc(); *ticks++ = time_diff(oldTime, curTime); oldTime = fastrdtsc(); memset(virtual, 0xF0, buf.size); curTime = fastrdtsc(); *ticks++ = time_diff(oldTime, curTime); oldTime = fastrdtsc(); memset(virtual, 0x0F, buf.size); curTime = fastrdtsc(); *ticks++ = time_diff(oldTime, curTime); oldTime = fastrdtsc(); readBuf(virtual, buf.size); curTime = fastrdtsc(); *ticks++ = time_diff(oldTime, curTime); BM_CKFATAL(drmBOUnmap(ctx->drmFD, &buf)); BM_CKFATAL(drmGetLock(ctx->drmFD, ctx->hwContext, 0)); oldTime = fastrdtsc(); BM_CKFATAL(drmBOValidate(ctx->drmFD, &buf, DRM_BO_FLAG_MEM_LOCAL, DRM_BO_MASK_MEM, DRM_BO_HINT_DONT_FENCE)); curTime = fastrdtsc(); *ticks++ = time_diff(oldTime, curTime); /* * Test cached buffers objects. */ oldTime = fastrdtsc(); ret = drmBOValidate(ctx->drmFD, &buf, DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_CACHED | DRM_BO_FLAG_FORCE_CACHING, DRM_BO_MASK_MEMTYPE | DRM_BO_FLAG_FORCE_CACHING, DRM_BO_HINT_DONT_FENCE); curTime = fastrdtsc(); drmUnlock(ctx->drmFD, ctx->hwContext); if (ret) { printf("Couldn't bind cached. Probably no support\n"); BM_CKFATAL(drmBODestroy(ctx->drmFD, &buf)); return 1; } *ticks++ = time_diff(oldTime, curTime); oldTime = fastrdtsc(); BM_CKFATAL(drmBOMap(ctx->drmFD, &buf, DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0, &virtual)); curTime = fastrdtsc(); *ticks++ = time_diff(oldTime, curTime); oldTime = fastrdtsc(); memset(virtual, 0xF0, buf.size); curTime = fastrdtsc(); *ticks++ = time_diff(oldTime, curTime); oldTime = fastrdtsc(); memset(virtual, 0x0F, buf.size); curTime = fastrdtsc(); *ticks++ = time_diff(oldTime, curTime); oldTime = fastrdtsc(); readBuf(virtual, buf.size); curTime = fastrdtsc(); *ticks++ = time_diff(oldTime, curTime); BM_CKFATAL(drmBOUnmap(ctx->drmFD, &buf)); BM_CKFATAL(drmBODestroy(ctx->drmFD, &buf)); return 0; } static void testAGP(TinyDRIContext * ctx) { unsigned long ticks[128], *pTicks; unsigned long size = 8 * 1024; int ret; ret = benchmarkBuffer(ctx, size, ticks); if (ret < 0) { fprintf(stderr, "Buffer error %s\n", strerror(-ret)); return; } pTicks = ticks; printf("Buffer size %d bytes\n", size); printf("System memory timings ********************************\n"); printf("Creation took %12lu ticks\n", *pTicks++); printf("Mapping took %12lu ticks\n", *pTicks++); printf("Writing took %12lu ticks\n", *pTicks++); printf("Writing Again took %12lu ticks\n", *pTicks++); printf("Reading took %12lu ticks\n", *pTicks++); printf("Unmapping took %12lu ticks\n", *pTicks++); printf("\nTT Memory timings ************************************\n"); printf("Moving to TT took %12lu ticks\n", *pTicks++); printf("Mapping in TT took %12lu ticks\n", *pTicks++); printf("Writing to TT took %12lu ticks\n", *pTicks++); printf("Writing again to TT took %12lu ticks\n", *pTicks++); printf("Reading from TT took %12lu ticks\n", *pTicks++); printf("Moving to system took %12lu ticks\n", *pTicks++); if (ret == 1) return; printf("\nCached TT Memory timings *****************************\n"); printf("Moving to CTT took %12lu ticks\n", *pTicks++); printf("Mapping in CTT took %12lu ticks\n", *pTicks++); printf("Writing to CTT took %12lu ticks\n", *pTicks++); printf("Re-writing to CTT took %12lu ticks\n", *pTicks++); printf("Reading from CTT took %12lu ticks\n", *pTicks++); printf("\n\n"); } int main() { int ret, screen, isCapable; char *displayName = ":0"; TinyDRIContext ctx; unsigned magic; ctx.screen = 0; ctx.state = haveNothing; ctx.display = XOpenDisplay(displayName); if (!ctx.display) { fprintf(stderr, "Could not open display\n"); return releaseContext(&ctx); } ctx.state = haveDisplay; ret = uniDRIQueryDirectRenderingCapable(ctx.display, ctx.screen, &isCapable); if (!ret || !isCapable) { fprintf(stderr, "No DRI on this display:sceen\n"); return releaseContext(&ctx); } if (!uniDRIOpenConnection(ctx.display, ctx.screen, &ctx.sAreaOffset, &ctx.curBusID)) { fprintf(stderr, "Could not open DRI connection.\n"); return releaseContext(&ctx); } ctx.state = haveConnection; if (!uniDRIGetClientDriverName(ctx.display, ctx.screen, &ctx.ddxDriverMajor, &ctx.ddxDriverMinor, &ctx.ddxDriverPatch, &ctx.driverName)) { fprintf(stderr, "Could not get DRI driver name.\n"); return releaseContext(&ctx); } ctx.state = haveDriverName; if (!uniDRIGetDeviceInfo(ctx.display, ctx.screen, &ctx.fbHandle, &ctx.fbOrigin, &ctx.fbSize, &ctx.fbStride, &ctx.driPrivSize, &ctx.driPriv)) { fprintf(stderr, "Could not get DRI device info.\n"); return releaseContext(&ctx); } ctx.state = haveDriverName; if ((ctx.drmFD = drmOpen(NULL, ctx.curBusID)) < 0) { perror("DRM Device could not be opened"); return releaseContext(&ctx); } ctx.state = haveDRM; drmGetMagic(ctx.drmFD, &magic); if (!uniDRIAuthConnection(ctx.display, ctx.screen, magic)) { fprintf(stderr, "Could not get X server to authenticate us.\n"); return releaseContext(&ctx); } ret = XMatchVisualInfo(ctx.display, ctx.screen, 24, TrueColor, &ctx.visualInfo); if (!ret) { ret = XMatchVisualInfo(ctx.display, ctx.screen, 16, TrueColor, &ctx.visualInfo); if (!ret) { fprintf(stderr, "Could not find a matching visual.\n"); return releaseContext(&ctx); } } if (!uniDRICreateContext(ctx.display, ctx.screen, ctx.visualInfo.visual, &ctx.id, &ctx.hwContext)) { fprintf(stderr, "Could not create DRI context.\n"); return releaseContext(&ctx); } ctx.state = haveContext; testAGP(&ctx); releaseContext(&ctx); printf("Terminating normally\n"); return 0; }