SDL_Flip hanging on Mobility Radeon HD 3400

I have this piece of code which behaves funny on a Thinkpad T400. First, here is the code:

Code:

#include <stdio.h>
#include <stdlib.h>
#include “SDL/SDL.h”

uint32_t refresh_callback(uint32_t interval, void *param)
{
SDL_Event event = { .type = SDL_USEREVENT };
SDL_PushEvent(&event);
return interval;
}

int main(int argc, char *argv[])
{
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0) {
fprintf(stderr, “Failed to initialize SDL: %s\n”, SDL_GetError());
return EXIT_FAILURE;
}

SDL_AddTimer(20, refresh_callback, NULL);
SDL_Surface *screen = SDL_SetVideoMode(640, 480, 16, SDL_DOUBLEBUF |
                                                     SDL_SWSURFACE);

SDL_Event event;
while (SDL_WaitEvent(&event)) {
    if (event.type == SDL_QUIT) break;
    if (event.type != SDL_USEREVENT) continue;

    uint32_t before = SDL_GetTicks();
    SDL_Flip(screen);
    uint32_t after = SDL_GetTicks();

    printf("%6d Delay: %6dms\n", SDL_GetTicks(), after-before);
}

SDL_Quit();
return EXIT_SUCCESS;

}

This works as expected on my lowend nettop with an ion2.? On the T400, it also works, but it hangs one second every 5. Here is the relevant output:

Code:

5001 Delay: 7ms
6015 Delay: 1004ms
6017 Delay: 2ms

Same thing happens at 10000 ticks, 15000, etc. The laptop has switchable graphics, but it’s running the discrete radeon mobility HD3400 with the ati drivers all the time (locked by BIOS). The distro is Ubuntu 10.10 64 bits. I’ve tried the distro libsdl and a hand compiled one (both are 1.2.14). Here is the lspci -vv output:

Code:

01:00.0 VGA compatible controller: ATI Technologies Inc Mobility Radeon HD 3400 Series (prog-if 00 [VGA controller])
Subsystem: Lenovo Device 210e
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR+ FastB2B- DisINTx+
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- SERR- <PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Interrupt: pin A routed to IRQ 49
Region 0: Memory at d0000000 (32-bit, prefetchable) [size=256M]
Region 1: I/O ports at 2000 [size=256]
Region 2: Memory at cfff0000 (32-bit, non-prefetchable) [size=64K]
[virtual] Expansion ROM at cff00000 [disabled] [size=128K]
Capabilities:
Kernel driver in use: fglrx_pci
Kernel modules: fglrx, radeon

Any hint on how to address this? I’m not sure SDL is to blame here, but maybe you can point in the right direction.

Thanks,
Gerard.

It seems that it only reproduces using multiple display setup. I’m using 2 displays VGA + DVI via dock