return I915_READ(reg);
 }
 
-static bool g4x_pipe_in_vblank(struct drm_device *dev, enum pipe pipe)
+static bool intel_pipe_in_vblank(struct drm_device *dev, enum pipe pipe)
 {
        struct drm_i915_private *dev_priv = dev->dev_private;
        uint32_t status;
                        I915_DISPLAY_PIPE_B_VBLANK_INTERRUPT;
 
                return I915_READ(VLV_ISR) & status;
-       } else if (IS_G4X(dev)) {
+       } else if (IS_GEN2(dev)) {
+               status = pipe == PIPE_A ?
+                       I915_DISPLAY_PIPE_A_VBLANK_INTERRUPT :
+                       I915_DISPLAY_PIPE_B_VBLANK_INTERRUPT;
+
+               return I915_READ16(ISR) & status;
+       } else if (INTEL_INFO(dev)->gen < 5) {
                status = pipe == PIPE_A ?
                        I915_DISPLAY_PIPE_A_VBLANK_INTERRUPT :
                        I915_DISPLAY_PIPE_B_VBLANK_INTERRUPT;
 
        ret |= DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_ACCURATE;
 
-       if (IS_G4X(dev) || INTEL_INFO(dev)->gen >= 5) {
+       if (IS_GEN2(dev) || IS_G4X(dev) || INTEL_INFO(dev)->gen >= 5) {
                /* No obvious pixelcount register. Only query vertical
                 * scanout position from Display scan line register.
                 */
-               position = I915_READ(PIPEDSL(pipe)) & 0x1fff;
+               if (IS_GEN2(dev))
+                       position = I915_READ(PIPEDSL(pipe)) & DSL_LINEMASK_GEN2;
+               else
+                       position = I915_READ(PIPEDSL(pipe)) & DSL_LINEMASK_GEN3;
 
                /*
                 * The scanline counter increments at the leading edge
                 * to get a more accurate picture whether we're in vblank
                 * or not.
                 */
-               in_vbl = g4x_pipe_in_vblank(dev, pipe);
+               in_vbl = intel_pipe_in_vblank(dev, pipe);
                if ((in_vbl && position == vbl_start - 1) ||
                    (!in_vbl && position == vbl_end - 1))
                        position = (position + 1) % vtotal;
        else
                position += vtotal - vbl_end;
 
-       if (IS_G4X(dev) || INTEL_INFO(dev)->gen >= 5) {
+       if (IS_GEN2(dev) || IS_G4X(dev) || INTEL_INFO(dev)->gen >= 5) {
                *vpos = position;
                *hpos = 0;
        } else {