include/avivo.h | 37 ++++-- xorg/Makefile.am | 2 xorg/avivo.c | 156 ++++++++++++++++++++++++--- xorg/avivo_bios.c | 75 +++++++++++++ xorg/avivo_crtc.c | 200 ++++++++++++++++++++++++----------- xorg/avivo_cursor.c | 2 xorg/avivo_output.c | 296 ++++++++++++++++++++++++++++++++++++++++++++++++++++ xorg/avivo_state.c | 4 8 files changed, 683 insertions(+), 89 deletions(-)
New commits: commit 52e78cf2d65b33ab23a6bea22caf6da68fa77768 Author: Jerome Glisse <[EMAIL PROTECTED]> Date: Thu Jun 14 21:07:14 2007 +0200 avivo: randr1.2: initial support, not working enable with AVIVO_RR12 For some reason the server is not calling in driver crtc function to set video mode thus launching with it will end up in a broken display. This why this is disabled by default. Also randr 1.2 still need work on rotation, allocating framebuffer, shadow buffer for rotation, ... diff --git a/include/avivo.h b/include/avivo.h index ac136c0..e83e2b8 100644 --- a/include/avivo.h +++ b/include/avivo.h @@ -139,6 +139,7 @@ struct avivo_output_private { I2CBusPtr i2c; unsigned long output_offset; int number; + char *name; }; /** diff --git a/xorg/Makefile.am b/xorg/Makefile.am index 89c8dad..1a59543 100644 --- a/xorg/Makefile.am +++ b/xorg/Makefile.am @@ -33,5 +33,7 @@ avivo_drv_la_SOURCES = \ avivo_state.c \ avivo_bios.c \ avivo_cursor.c \ + avivo_crtc.c \ + avivo_output.c \ avivo_i2c.c \ avivo.c diff --git a/xorg/avivo.c b/xorg/avivo.c index 9986ee9..4672ea4 100644 --- a/xorg/avivo.c +++ b/xorg/avivo.c @@ -409,6 +409,7 @@ avivo_get_chipset(struct avivo_info *avivo) static Bool avivo_preinit(ScrnInfoPtr screen_info, int flags) { + xf86CrtcConfigPtr config; struct avivo_info *avivo; DisplayModePtr mode; ClockRangePtr clock_ranges; @@ -461,7 +462,7 @@ avivo_preinit(ScrnInfoPtr screen_info, int flags) avivo_get_chipset(avivo); screen_info->chipset = "avivo"; screen_info->monitor = screen_info->confScreen->monitor; - /* setup depth */ + if (!xf86SetDepthBpp(screen_info, 0, 0, 0, Support32bppFb)) return FALSE; xf86PrintDepthBpp(screen_info); @@ -476,10 +477,73 @@ avivo_preinit(ScrnInfoPtr screen_info, int flags) default: FatalError("Unsupported screen depth: %d\n", xf86GetDepth()); } - - +#if AVIVO_RR12 + if (!avivo_crtc_create(screen_info)) + return FALSE; +#if 0 + if (!avivo_output_setup(screen_info)) + return FALSE; +#else + avivo_output_setup(screen_info); +#endif + /* color weight */ + if (!xf86SetWeight(screen_info, rzeros, rzeros)) + return FALSE; + /* visual init */ + if (!xf86SetDefaultVisual(screen_info, -1)) + return FALSE; + /* TODO: gamma correction */ + xf86SetGamma(screen_info, gzeros); + /* Set display resolution */ + xf86SetDpi(screen_info, 100, 100); + /* probe monitor found */ + monitor = NULL; + config = XF86_CRTC_CONFIG_PTR(screen_info); + for (i = 0; i < config->num_output; i++) { + xf86OutputPtr output = config->output[i]; + struct avivo_output_private *avivo_output = output->driver_private; + if (output->funcs->detect(output) == XF86OutputStatusConnected) { + output->funcs->get_modes(output); + monitor = output->MonInfo; + xf86PrintEDID(monitor); + } + } + if (monitor == NULL) { + xf86DrvMsg(screen_info->scrnIndex, X_ERROR, + "No monitor found.\n"); + return FALSE; + } + xf86SetDDCproperties(screen_info, monitor); + /* validates mode */ + clock_ranges = xcalloc(sizeof(ClockRange), 1); + if (clock_ranges == NULL) { + xf86DrvMsg(screen_info->scrnIndex, X_ERROR, + "Failed to allocate memory for clock range\n"); + return FALSE; + } + clock_ranges->minClock = 12000; + clock_ranges->maxClock = 165000; + clock_ranges->clockIndex = -1; + clock_ranges->interlaceAllowed = FALSE; + clock_ranges->doubleScanAllowed = FALSE; + screen_info->progClock = TRUE; + xf86ValidateModes(screen_info, screen_info->monitor->Modes, + screen_info->display->modes, clock_ranges, 0, 320, 2048, + 16 * screen_info->bitsPerPixel, 200, 2047, + screen_info->display->virtualX, + screen_info->display->virtualY, + screen_info->videoRam, LOOKUP_BEST_REFRESH); + xf86PruneDriverModes(screen_info); + /* check if there modes available */ + if (screen_info->modes == NULL) { + xf86DrvMsg(screen_info->scrnIndex, X_ERROR, "No modes available\n"); + return FALSE; + } + screen_info->currentMode = screen_info->modes; +#else /* probe BIOS information */ avivo_probe_info(screen_info); + /* color weight */ if (!xf86SetWeight(screen_info, rzeros, rzeros)) return FALSE; @@ -533,8 +597,8 @@ avivo_preinit(ScrnInfoPtr screen_info, int flags) xf86DrvMsg(screen_info->scrnIndex, X_ERROR, "No modes available\n"); return FALSE; } - screen_info->currentMode = screen_info->modes; +#endif /* options */ xf86CollectOptions(screen_info, NULL); @@ -555,6 +619,7 @@ avivo_preinit(ScrnInfoPtr screen_info, int flags) #endif + xf86DrvMsg(screen_info->scrnIndex, X_INFO, "[ScreenPreInit OK]\n"); return TRUE; } @@ -575,8 +640,9 @@ avivo_screen_init(int index, ScreenPtr screen, int argc, char **argv) { ScrnInfoPtr screen_info = xf86Screens[index]; struct avivo_info *avivo = avivo_get_info(screen_info); + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(screen_info); VisualPtr visual; - int flags; + int flags, i; unsigned int mc_memory_map; unsigned int mc_memory_map_end; @@ -592,13 +658,6 @@ avivo_screen_init(int index, ScreenPtr screen, int argc, char **argv) (avivo->fb_addr >> 16) & AVIVO_MC_MEMORY_MAP_BASE_MASK); OUTREG(AVIVO_VGA_FB_START, avivo->fb_addr); - /* set first video mode */ - if (!avivo_set_mode(screen_info, screen_info->currentMode)) - return FALSE; - - /* set the viewport */ - avivo_adjust_frame(index, screen_info->frameX0, screen_info->frameY0, 0); - /* mi layer */ miClearVisualTypes(); @@ -630,18 +689,43 @@ avivo_screen_init(int index, ScreenPtr screen, int argc, char **argv) visual->blueMask = screen_info->mask.blue; } } - /* must be after RGB ordering fixed */ fbPictureInit(screen, 0, 0); xf86SetBlackWhitePixels(screen); +#if AVIVO_RR12 + for (i = 0; i < xf86_config->num_crtc; i++) { + xf86CrtcPtr crtc = xf86_config->crtc[i]; + /* Mark that we'll need to re-set the mode for sure */ + memset(&crtc->mode, 0, sizeof(crtc->mode)); + if (!crtc->desiredMode.CrtcHDisplay) { + memcpy(&crtc->desiredMode, screen_info->currentMode, + sizeof(crtc->desiredMode)); + crtc->desiredRotation = RR_Rotate_0; + crtc->desiredX = 0; + crtc->desiredY = 0; + } - xf86DPMSInit(screen, avivo_dpms, 0); + if (!xf86CrtcSetMode (crtc, &crtc->desiredMode, crtc->desiredRotation, + crtc->desiredX, crtc->desiredY)) + return FALSE; + } +#else + /* set first video mode */ + if (!avivo_set_mode(screen_info, screen_info->currentMode)) + return FALSE; +#endif + /* set the viewport */ + avivo_adjust_frame(index, screen_info->frameX0, screen_info->frameY0, 0); miDCInitialize(screen, xf86GetPointerScreenFuncs()); +#if 1 /* FIXME enormous hack ... */ avivo->cursor_offset = screen_info->virtualX * screen_info->virtualY * 4; avivo_cursor_init(screen); +#endif + + xf86DPMSInit(screen, avivo_dpms, 0); if (!miCreateDefColormap(screen)) return FALSE; @@ -654,6 +738,12 @@ avivo_screen_init(int index, ScreenPtr screen, int argc, char **argv) avivo->close_screen = screen->CloseScreen; screen->CloseScreen = avivo_close_screen; +#if AVIVO_RR12 + if (!xf86CrtcScreenInit(screen)) + return FALSE; +#endif + + xf86DrvMsg(screen_info->scrnIndex, X_INFO, "[ScreenInit OK]\n"); return TRUE; } @@ -913,7 +1003,31 @@ avivo_setup_crtc(struct avivo_info *avivo, struct avivo_crtc *crtc, avivo_crtc_enable(avivo, crtc, 1); } +#if AVIVO_RR12 +static Bool +avivo_switch_mode(int index, DisplayModePtr mode, int flags) +{ + ScrnInfoPtr screen_info = xf86Screens[index]; + Bool ok; + xf86DrvMsg(screen_info->scrnIndex, X_INFO, + "set mode: hdisp %d, htotal %d, hss %d, hse %d, hsk %d\n", + mode->HDisplay, mode->HTotal, mode->HSyncStart, mode->HSyncEnd, + mode->HSkew); + xf86DrvMsg(screen_info->scrnIndex, X_INFO, + " vdisp %d, vtotal %d, vss %d, vse %d, vsc %d\n", + mode->VDisplay, mode->VTotal, mode->VSyncStart, mode->VSyncEnd, + mode->VScan); + + ok = xf86SetSingleMode(screen_info, mode, RR_Rotate_0); + if (!ok) { + xf86DrvMsg(screen_info->scrnIndex, X_INFO, "Failed to set mode\n"); + } else { + xf86DrvMsg(screen_info->scrnIndex, X_INFO, "Setting mode succeed\n"); + } + return ok; +} +#else static Bool avivo_switch_mode(int index, DisplayModePtr mode, int flags) { @@ -947,6 +1061,7 @@ avivo_switch_mode(int index, DisplayModePtr mode, int flags) return TRUE; } +#endif /* Set a graphics mode */ static Bool diff --git a/xorg/avivo_bios.c b/xorg/avivo_bios.c index e8d612c..e030602 100644 --- a/xorg/avivo_bios.c +++ b/xorg/avivo_bios.c @@ -328,3 +328,78 @@ avivo_probe_info(ScrnInfoPtr screen_info) connector = connector->next; } } + + +int +avivo_output_clones(ScrnInfoPtr screen_info) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR (screen_info); + int o, index_mask; + + for (o = 0; o < config->num_output; o++) { + index_mask |= (1 << o); + } + return index_mask; +} + +Bool +avivo_output_setup(ScrnInfoPtr screen_info) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(screen_info); + struct avivo_info *avivo = avivo_get_info(screen_info); + int offset = 0; + int tmp, i; + + if (RADEONGetBIOSInfo(screen_info)) + return FALSE; + + offset = RADEON_BIOS16(avivo->master_data + 22); + if (offset == 0) { + xf86DrvMsg(screen_info->scrnIndex, X_INFO, + "No connector table in BIOS"); + return 1; + } + + tmp = RADEON_BIOS16(offset + 4); + for (i = 0; i < 8; i++) { + if (tmp & (1 << i)) { + int portinfo, number, connector_type, tmp0; + unsigned int ddc_reg; + xf86ConnectorType type; + + portinfo = RADEON_BIOS16(offset + 6 + i * 2); + number = (portinfo >> 8) & 0xf; + connector_type = (portinfo >> 4) & 0xf; + tmp0 = RADEON_BIOS16(avivo->master_data + 24); + ddc_reg = RADEON_BIOS16(tmp0 + 4 + 27 * number) * 4; + switch (connector_type) { + case 0: type = XF86ConnectorNone; break; + case 1: type = XF86ConnectorVGA; break; + case 2: type = XF86ConnectorDVI_I; break; + case 3: type = XF86ConnectorDVI_D; break; + case 4: type = XF86ConnectorDVI_A; break; + case 5: type = XF86ConnectorSvideo; break; + case 6: type = XF86ConnectorComponent; break; + case 7: type = XF86ConnectorLFP; break; + case 8: type = XF86ConnectorNone; break; + default: type = XF86ConnectorNone; break; + } + + switch (type) { + case XF86ConnectorVGA: + case XF86ConnectorLFP: + case XF86ConnectorDVI_I: + avivo_output_init(screen_info, type, number, ddc_reg); + break; + } + } + } + + + for (i = 0; i < config->num_output; i++) { + xf86OutputPtr output = config->output[i]; + output->possible_crtcs = (1 << 0) | (1 << 1); + output->possible_clones = avivo_output_clones(screen_info); + } + return TRUE; +} diff --git a/xorg/avivo_crtc.c b/xorg/avivo_crtc.c index 90375be..6233717 100644 --- a/xorg/avivo_crtc.c +++ b/xorg/avivo_crtc.c @@ -194,7 +194,16 @@ avivo_crtc_mode_set(xf86CrtcPtr crtc, default: FatalError("Unsupported screen depth: %d\n", xf86GetDepth()); } - + xf86DrvMsg(crtc->scrn->scrnIndex, X_INFO, + "crtc(%d) hdisp %d, htotal %d, hss %d, hse %d, hsk %d\n", + avivo_crtc->crtc_number, adjusted_mode->CrtcHDisplay, + adjusted_mode->CrtcHTotal, adjusted_mode->CrtcHSyncStart, + adjusted_mode->CrtcHSyncEnd, adjusted_mode->CrtcHSkew); + xf86DrvMsg(crtc->scrn->scrnIndex, X_INFO, + "crtc(%d) vdisp %d, vtotal %d, vss %d, vse %d, vsc %d\n", + avivo_crtc->crtc_number, adjusted_mode->CrtcVDisplay, + adjusted_mode->CrtcVTotal, adjusted_mode->CrtcVSyncStart, + adjusted_mode->CrtcVSyncEnd, adjusted_mode->VScan); /* TODO: find out what this regs truely are for. * last guess: Switch from text to graphics mode. */ @@ -317,10 +326,10 @@ avivo_crtc_cursor_load_argb(xf86CrtcPtr crtc, CARD32 *image) } static void -avivo_crtc_destroy(xf86OutputPtr output) +avivo_crtc_destroy(xf86CrtcPtr crtc) { - if (output->driver_private) - xfree(output->driver_private); + if (crtc->driver_private) + xfree(crtc->driver_private); } static const xf86CrtcFuncsRec avivo_crtc_funcs = { @@ -358,6 +367,8 @@ avivo_crtc_init(ScrnInfoPtr screen_info, int crtc_number) if (avivo_crtc == NULL) return FALSE; avivo_crtc->crtc_number = crtc_number; + avivo_crtc->fb_offset = 0; + avivo_crtc->cursor_offset = 0; avivo_crtc->crtc_offset = 0; if (avivo_crtc->crtc_number == 1) avivo_crtc->crtc_offset = AVIVO_CRTC2_H_TOTAL - AVIVO_CRTC1_H_TOTAL; @@ -370,6 +381,8 @@ avivo_crtc_init(ScrnInfoPtr screen_info, int crtc_number) } crtc->driver_private = avivo_crtc; + xf86DrvMsg(screen_info->scrnIndex, X_INFO, + "added CRTC %d\n", crtc_number); return TRUE; } diff --git a/xorg/avivo_state.c b/xorg/avivo_state.c index f7a21bf..a1e65f6 100644 --- a/xorg/avivo_state.c +++ b/xorg/avivo_state.c @@ -32,7 +32,7 @@ #include "avivo.h" #include "radeon_reg.h" -static void +void avivo_save_cursor(ScrnInfoPtr screen_info) { struct avivo_info *avivo = avivo_get_info(screen_info); commit 61f20371eb3af031767776300587eb9dacd453ef Author: Jerome Glisse <[EMAIL PROTECTED]> Date: Thu Jun 14 18:19:49 2007 +0200 avivo: fix bugs introduced by randr change. diff --git a/xorg/avivo.c b/xorg/avivo.c index 040cee0..9986ee9 100644 --- a/xorg/avivo.c +++ b/xorg/avivo.c @@ -461,8 +461,11 @@ avivo_preinit(ScrnInfoPtr screen_info, int flags) avivo_get_chipset(avivo); screen_info->chipset = "avivo"; screen_info->monitor = screen_info->confScreen->monitor; - - switch (xf86GetDepth()) { + /* setup depth */ + if (!xf86SetDepthBpp(screen_info, 0, 0, 0, Support32bppFb)) + return FALSE; + xf86PrintDepthBpp(screen_info); + switch (screen_info->depth) { case 16: avivo->bpp = 2; break; @@ -477,11 +480,6 @@ avivo_preinit(ScrnInfoPtr screen_info, int flags) /* probe BIOS information */ avivo_probe_info(screen_info); - - if (!xf86SetDepthBpp(screen_info, 0, 0, 0, Support32bppFb)) - return FALSE; - xf86PrintDepthBpp(screen_info); - /* color weight */ if (!xf86SetWeight(screen_info, rzeros, rzeros)) return FALSE; diff --git a/xorg/avivo_cursor.c b/xorg/avivo_cursor.c index b5588b8..5398438 100644 --- a/xorg/avivo_cursor.c +++ b/xorg/avivo_cursor.c @@ -65,7 +65,7 @@ avivo_cursor_set_position(ScrnInfoPtr screen_info, int x, int y) avivo->cursor_y = y; } -static void +void avivo_setup_cursor(struct avivo_info *avivo, int id, int enable) { if (id == 1) { commit ef115f143e6197aae9c2ed59c5759a095467eb28 Author: Jerome Glisse <[EMAIL PROTECTED]> Date: Thu Jun 14 14:58:24 2007 +0200 avivo: crtc & output handling fixes. diff --git a/xorg/avivo_crtc.c b/xorg/avivo_crtc.c index 84a8a90..90375be 100644 --- a/xorg/avivo_crtc.c +++ b/xorg/avivo_crtc.c @@ -183,7 +183,7 @@ avivo_crtc_mode_set(xf86CrtcPtr crtc, avivo_crtc->fb_pitch = adjusted_mode->CrtcHDisplay; avivo_crtc->fb_offset = 0; avivo_crtc->fb_length = avivo_crtc->fb_pitch * avivo_crtc->fb_height * 4; - switch (xf86GetDepth()) { + switch (crtc->scrn->depth) { case 16: avivo_crtc->fb_format = AVIVO_CRTC_FORMAT_ARGB16; break; @@ -359,7 +359,7 @@ avivo_crtc_init(ScrnInfoPtr screen_info, int crtc_number) return FALSE; avivo_crtc->crtc_number = crtc_number; avivo_crtc->crtc_offset = 0; - if (avivo_crtc->crtc_number == 2) + if (avivo_crtc->crtc_number == 1) avivo_crtc->crtc_offset = AVIVO_CRTC2_H_TOTAL - AVIVO_CRTC1_H_TOTAL; /* allocate & initialize xf86Crtc */ @@ -390,6 +390,9 @@ avivo_crtc_create(ScrnInfoPtr screen_info) /* * add both crtc i think all r5xx chipset got two crtc */ - + if (!avivo_crtc_init(screen_info, 0)) + return FALSE; + if (!avivo_crtc_init(screen_info, 1)) + return FALSE; return TRUE; } diff --git a/xorg/avivo_output.c b/xorg/avivo_output.c index 8bbd335..805d653 100644 --- a/xorg/avivo_output.c +++ b/xorg/avivo_output.c @@ -202,6 +202,7 @@ avivo_output_destroy(xf86OutputPtr output) if (avivo_output == NULL) return; xf86DestroyI2CBusRec(avivo_output->i2c, TRUE, TRUE); + xfree(avivo_output->name); xfree(avivo_output); } @@ -225,21 +226,32 @@ avivo_output_init(ScrnInfoPtr screen_info, xf86ConnectorType type, { xf86OutputPtr output; struct avivo_output_private *avivo_output; + int name_size; /* allocate & initialize private crtc structure */ avivo_output = xcalloc(sizeof(struct avivo_output_private), 1); if (avivo_output == NULL) return FALSE; + name_size = snprintf(NULL, 0, "%s connector %d", + xf86ConnectorGetName(type), number); + avivo_output->name = xcalloc(name_size + 1, 1); + if (avivo_output->name == NULL) { + xfree(avivo_output); + xf86DrvMsg(screen_info->scrnIndex, X_ERROR, + "Failed to allocate memory for I2C bus name\n"); + return FALSE; + } + snprintf(avivo_output->name, name_size + 1, "%s connector %d", + xf86ConnectorGetName(type), number); + avivo_output->i2c = xf86CreateI2CBusRec(); if (!avivo_output->i2c) { - avivo_output->i2c = xf86CreateI2CBusRec(); - if (!avivo_output->i2c) { - xfree(avivo_output); - xf86DrvMsg(screen_info->scrnIndex, X_ERROR, - "Couldn't create I2C bus\n"); - return FALSE; - } + xfree(avivo_output); + xf86DrvMsg(screen_info->scrnIndex, X_ERROR, + "Couldn't create I2C bus for %s connector %d\n", + xf86ConnectorGetName(type), number); + return FALSE; } - avivo_output->i2c->BusName = "DDC"; + avivo_output->i2c->BusName = avivo_output->name; avivo_output->i2c->scrnIndex = screen_info->scrnIndex; avivo_output->i2c->I2CPutBits = avivo_i2c_put_bits; avivo_output->i2c->I2CGetBits = avivo_i2c_get_bits; @@ -247,7 +259,8 @@ avivo_output_init(ScrnInfoPtr screen_info, xf86ConnectorType type, avivo_output->i2c->DriverPrivate.uval = ddc_reg; if (!xf86I2CBusInit(avivo_output->i2c)) { xf86DrvMsg(screen_info->scrnIndex, X_ERROR, - "Couldn't initialise I2C bus\n"); + "Couldn't initialise I2C bus for %s connector %d\n", + xf86ConnectorGetName(type), number); return; } avivo_output->type = type; @@ -278,4 +291,6 @@ avivo_output_init(ScrnInfoPtr screen_info, xf86ConnectorType type, output->driver_private = avivo_output; output->interlaceAllowed = FALSE; output->doubleScanAllowed = FALSE; + xf86DrvMsg(screen_info->scrnIndex, X_INFO, + "added %s connector %d\n", xf86ConnectorGetName(type), number); } commit e9e9a0b35a31840a4b1bff14efd506d2c9e5ac13 Author: Jerome Glisse <[EMAIL PROTECTED]> Date: Thu Jun 14 14:14:15 2007 +0200 avivo: randr 1.2: fix crtc & output handling (not activated yet) diff --git a/xorg/avivo_crtc.c b/xorg/avivo_crtc.c index 1e5cebc..84a8a90 100644 --- a/xorg/avivo_crtc.c +++ b/xorg/avivo_crtc.c @@ -25,6 +25,9 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif +/* DPMS */ +#define DPMS_SERVER +#include <X11/extensions/dpms.h> #include "avivo.h" #include "radeon_reg.h" @@ -179,7 +182,7 @@ avivo_crtc_mode_set(xf86CrtcPtr crtc, avivo_crtc->fb_height = adjusted_mode->CrtcVDisplay; avivo_crtc->fb_pitch = adjusted_mode->CrtcHDisplay; avivo_crtc->fb_offset = 0; - avivo_crtc->fb_length = avivo_crtc->fb_pitch * crtc->fb_height * 4; + avivo_crtc->fb_length = avivo_crtc->fb_pitch * avivo_crtc->fb_height * 4; switch (xf86GetDepth()) { case 16: avivo_crtc->fb_format = AVIVO_CRTC_FORMAT_ARGB16; @@ -189,6 +192,7 @@ avivo_crtc_mode_set(xf86CrtcPtr crtc, avivo_crtc->fb_format = AVIVO_CRTC_FORMAT_ARGB32; break; default: + FatalError("Unsupported screen depth: %d\n", xf86GetDepth()); } /* TODO: find out what this regs truely are for. @@ -210,7 +214,7 @@ avivo_crtc_mode_set(xf86CrtcPtr crtc, /* set PLL TODO: there is likely PLL registers we miss for having * different PLL for each CRTC for instance. */ - avivo_crtc_set_pll(avivo, avivo_crtc, adjusted_mode); + avivo_crtc_set_pll(crtc, adjusted_mode); /* finaly set the mode */ @@ -259,13 +263,13 @@ avivo_crtc_commit(xf86CrtcPtr crtc) } static void -avivo_crtc_cursor_set_colors(xf86CrtcPtr crtc, int bg, int fg) +avivo_crtc_set_cursor_colors(xf86CrtcPtr crtc, int bg, int fg) { /* TODO: implement */ } static void -avivo_crtc_cursor_set_position(xf86CrtcPtr crtc, int x, int y) +avivo_crtc_set_cursor_position(xf86CrtcPtr crtc, int x, int y) { struct avivo_crtc_private *avivo_crtc = crtc->driver_private; struct avivo_info *avivo = avivo_get_info(crtc->scrn); @@ -281,7 +285,7 @@ avivo_crtc_cursor_set_position(xf86CrtcPtr crtc, int x, int y) } static void -avivo_crtc_cursor_show(xf86CrtcPtr crtc) +avivo_crtc_show_cursor(xf86CrtcPtr crtc) { struct avivo_crtc_private *avivo_crtc = crtc->driver_private; struct avivo_info *avivo = avivo_get_info(crtc->scrn); @@ -292,7 +296,7 @@ avivo_crtc_cursor_show(xf86CrtcPtr crtc) } static void -avivo_crtc_cursor_hide(xf86CrtcPtr crtc) +avivo_crtc_hide_cursor(xf86CrtcPtr crtc) { struct avivo_crtc_private *avivo_crtc = crtc->driver_private; struct avivo_info *avivo = avivo_get_info(crtc->scrn); @@ -338,7 +342,7 @@ static const xf86CrtcFuncsRec avivo_crtc_funcs = { .show_cursor = avivo_crtc_show_cursor, .hide_cursor = avivo_crtc_hide_cursor, .load_cursor_image = NULL, - .load_cursor_argb = avivo_crtc_load_cursor_argb, + .load_cursor_argb = avivo_crtc_cursor_load_argb, .destroy = avivo_crtc_destroy, }; diff --git a/xorg/avivo_output.c b/xorg/avivo_output.c index ba4a4f7..8bbd335 100644 --- a/xorg/avivo_output.c +++ b/xorg/avivo_output.c @@ -25,6 +25,9 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif +/* DPMS */ +#define DPMS_SERVER +#include <X11/extensions/dpms.h> #include "avivo.h" #include "radeon_reg.h" @@ -167,7 +170,7 @@ avivo_output_detect_ddc(xf86OutputPtr output) { struct avivo_output_private *avivo_output = output->driver_private; -o return xf86I2CProbeAddress(avivo_output->i2c, 0x00A0); + return xf86I2CProbeAddress(avivo_output->i2c, 0x00A0); } static xf86OutputStatus @@ -202,10 +205,10 @@ avivo_output_destroy(xf86OutputPtr output) xfree(avivo_output); } -static const xf86OutputFuncsRec avivo_output_output_funcs = { +static const xf86OutputFuncsRec avivo_output_funcs = { .dpms = avivo_output_dpms, - .save = avivo_output_save, - .restore = avivo_output_restore, + .save = NULL, + .restore = NULL, .mode_valid = avivo_output_mode_valid, .mode_fixup = avivo_output_mode_fixup, .prepare = avivo_output_prepare, @@ -221,10 +224,10 @@ avivo_output_init(ScrnInfoPtr screen_info, xf86ConnectorType type, int number, unsigned long ddc_reg) { xf86OutputPtr output; - struct avivo_output_private avivo_output; + struct avivo_output_private *avivo_output; /* allocate & initialize private crtc structure */ - avivo_output = xcalloc (sizeof(struct avivo_output_private), 1); + avivo_output = xcalloc(sizeof(struct avivo_output_private), 1); if (avivo_output == NULL) return FALSE; if (!avivo_output->i2c) { commit c5caf1e26baf2c90d514f9a331626c43d099e555 Author: Jerome Glisse <[EMAIL PROTECTED]> Date: Thu Jun 14 13:16:11 2007 +0200 avivo: randr 1.2 output (not compiled yet, work in progress) diff --git a/include/avivo.h b/include/avivo.h index e4815e6..ac136c0 100644 --- a/include/avivo.h +++ b/include/avivo.h @@ -24,22 +24,18 @@ /* All drivers should typically include these */ #include "xf86.h" #include "xf86str.h" +#include "xf86i2c.h" +#include "xf86DDC.h" +#include "xf86Crtc.h" #include "xf86_OSproc.h" #include "xf86Resources.h" +#include "xf86RAC.h" #include "compiler.h" - /* Drivers for PCI hardware need this */ #include "xf86PciInfo.h" - /* Drivers that need to access the PCI config space directly need this */ #include "xf86Pci.h" -#include "xf86Resources.h" -#include "xf86RAC.h" - -#include "xf86i2c.h" -#include "xf86DDC.h" - #include "fb.h" #ifdef PCIACCESS @@ -137,6 +133,14 @@ struct avivo_output { struct avivo_output *next; }; + +struct avivo_output_private { + xf86ConnectorType type; + I2CBusPtr i2c; + unsigned long output_offset; + int number; +}; + /** * struct avivo_connector - avivo output connector information structure * @is_connected: is output connected @@ -310,6 +314,16 @@ struct avivo_info *avivo_get_info(ScrnInfoPtr screen_info); void avivo_restore_state(ScrnInfoPtr screen_info); void avivo_save_state(ScrnInfoPtr screen_info); +/* + * avivo crtc handling + */ +Bool avivo_crtc_create(ScrnInfoPtr screen_info); + +/* + * avivo output handling + */ +Bool avivo_output_init(ScrnInfoPtr screen_info, xf86ConnectorType type, + int number, unsigned long ddc_reg); /* * avivo cursor handling diff --git a/xorg/avivo_crtc.c b/xorg/avivo_crtc.c index 57d2063..1e5cebc 100644 --- a/xorg/avivo_crtc.c +++ b/xorg/avivo_crtc.c @@ -312,6 +312,13 @@ avivo_crtc_cursor_load_argb(xf86CrtcPtr crtc, CARD32 *image) memcpy(dst, image, 64 * 64 * 4); } +static void +avivo_crtc_destroy(xf86OutputPtr output) +{ + if (output->driver_private) + xfree(output->driver_private); +} + static const xf86CrtcFuncsRec avivo_crtc_funcs = { .dpms = avivo_crtc_dpms, .save = NULL, /* this got saved elsewhere */ diff --git a/xorg/avivo_output.c b/xorg/avivo_output.c new file mode 100644 index 0000000..ba4a4f7 --- /dev/null +++ b/xorg/avivo_output.c @@ -0,0 +1,278 @@ +/* + * Copyright © 2007 Daniel Stone + * Copyright © 2007 Matthew Garrett + * Copyright © 2007 Jerome Glisse + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * A copy of the General Public License is included with the source + * distribution of this driver, as COPYING. + * + * Authors: Daniel Stone <[EMAIL PROTECTED]> + * Matthew Garrett <[EMAIL PROTECTED]> + * Jerome Glisse <[EMAIL PROTECTED]> + */ +/* + * avivo output handling functions. + */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "avivo.h" +#include "radeon_reg.h" + +static void +avivo_i2c_get_bits(I2CBusPtr b, int *Clock, int *data) +{ + ScrnInfoPtr screen_info = xf86Screens[b->scrnIndex]; + struct avivo_info *avivo = avivo_get_info(screen_info); + unsigned long val; + + /* Get the result */ + val = INREG(b->DriverPrivate.uval + 0xC); + *Clock = (val & (1<<0)) != 0; + *data = (val & (1<<8)) != 0; +} + +static void +avivo_i2c_put_bits(I2CBusPtr b, int Clock, int data) +{ + ScrnInfoPtr screen_info = xf86Screens[b->scrnIndex]; + struct avivo_info *avivo = avivo_get_info(screen_info); + unsigned long val; + + val = 0; + val |= (Clock ? 0:(1<<0)); + val |= (data ? 0:(1<<8)); + OUTREG(b->DriverPrivate.uval + 0x8, val); + /* read back to improve reliability on some cards. */ + val = INREG(b->DriverPrivate.uval + 0x8); +} + +static void +avivo_output_dpms(xf86OutputPtr output, int mode) +{ + struct avivo_output_private *avivo_output = output->driver_private; + struct avivo_info *avivo = avivo_get_info(output->scrn); + + switch (avivo_output->type) { + case XF86ConnectorVGA: + { + int value1, value2, value3; + + switch(mode) { + case DPMSModeOn: + value1 = 0; + value2 = 0; + value3 = AVIVO_DAC_EN; + break; + case DPMSModeStandby: + case DPMSModeSuspend: + case DPMSModeOff: + value1 = AVIVO_DAC_MYSTERY1_DIS; + value2 = AVIVO_DAC_MYSTERY2_DIS; + value3 = 0; + break; + } + OUTREG(AVIVO_DAC1_MYSTERY1 + avivo_output->output_offset, value1); + OUTREG(AVIVO_DAC1_MYSTERY2 + avivo_output->output_offset, value2); + OUTREG(AVIVO_DAC1_CNTL + avivo_output->output_offset, value3); + break; + } + case XF86ConnectorDVI_I: + case XF86ConnectorDVI_D: + case XF86ConnectorDVI_A: + { + int value1, value2, value3, value4, value5; + + value3 = 0x10000011; + value5 = 0x00001010; + switch(mode) { + case DPMSModeOn: + value1 = AVIVO_TMDS_MYSTERY1_EN; + value2 = AVIVO_TMDS_MYSTERY2_EN; + value4 = 0x00001f1f; + if (avivo_output->number == 2) + value4 |= 0x00000020; + value5 |= AVIVO_TMDS_EN; + break; + case DPMSModeStandby: + case DPMSModeSuspend: + case DPMSModeOff: + value1 = 0x04000000; + value2 = 0; + value4 = 0x00060000; + break; + } + OUTREG(AVIVO_TMDS1_MYSTERY1 + avivo_output->output_offset, value1); + OUTREG(AVIVO_TMDS1_MYSTERY2 + avivo_output->output_offset, value2); + OUTREG(AVIVO_TMDS1_MYSTERY3 + avivo_output->output_offset, value3); + OUTREG(AVIVO_TMDS1_CLOCK_CNTL + avivo_output->output_offset, value4); + OUTREG(AVIVO_TMDS1_CNTL + avivo_output->output_offset, value5); + break; + } + } +} + +static int +avivo_output_mode_valid(xf86OutputPtr output, DisplayModePtr pMode) +{ + if (pMode->Flags & V_DBLSCAN) + return MODE_NO_DBLESCAN; + + if (pMode->Clock > 400000 || pMode->Clock < 25000) + return MODE_CLOCK_RANGE; + + return MODE_OK; +} + +static Bool +avivo_output_mode_fixup(xf86OutputPtr output, + DisplayModePtr mode, + DisplayModePtr adjusted_mode) +{ + return TRUE; +} + +static void +avivo_output_prepare(xf86OutputPtr output) +{ + output->funcs->dpms(output, DPMSModeOff); +} + +static void +avivo_output_mode_set(xf86OutputPtr output, + DisplayModePtr mode, + DisplayModePtr adjusted_mode) +{ +} + +static void +avivo_output_commit(xf86OutputPtr output) +{ + output->funcs->dpms(output, DPMSModeOn); +} + + +static Bool +avivo_output_detect_ddc(xf86OutputPtr output) +{ + struct avivo_output_private *avivo_output = output->driver_private; + +o return xf86I2CProbeAddress(avivo_output->i2c, 0x00A0); -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]