I have an issue with the r128 driver on my Dell Inspiron 8000 laptop with an ATI
Mobility M4 video card. When playing movies using Xv, the vertical width is
incorrect, leading to vertically squashed output and a black band at the bottom.
I have identified the problem in the source and made a fix which works; at the
moment is should be considered a crude hack that only works in 1024x768, but I
am reporting my findings here so someone can hopefully come up with a definitive
My modification changes both occurances of "v_inc = (src_h << 20) / drw_h;" in
r128_video.c to "v_inc = (src_h << 20) / (drw_h + 128);", which will result in
proper Xv scaling *only* when using a resolution of 1024x768.
With the stock driver, Xv output with a resolution of 800x600 results in a much
larger black band, and using 1280x1024, the band is smaller (and hence Xv output
is closest to normal out of all possible resolutions), but still present. Based
on this observation, drw_h is being calculated incorrectly on the vertical axis,
but horizontal width is fine under all resolutions.
Someone else may need to fix this properly, I'm afraid my programming experience
is virtually non-existant, but I will try.. :)
Created attachment 5191 [details]
Hack to fix r128 Xv output using resolution of 1024x768 *only*
Created attachment 5192 [details] [review]
Hack to fix r128 Xv output using resolution of 1024x768 *only*
Unfortunately, the problem is more complicated than I thought. Adding 128 gave
almost perfect results for a 480x360 video, but trying a different video at
512x384 produces a more pronounced black band at the bottom. No matter how I
manually adjust the lines as mentioned above, it seems that the result will vary
from video to video, depending on the Xv output resolution. Can someone shed
some light on this?
Created attachment 5193 [details] [review]
r128_video.c radeon patches try1
This patch works much better. I borrowed code from radeon_video.c and modified
it slightly. I replaced v_inc_shift with 20, simply to remove the need to
incorporate the interlace/doublescan checks - but the next time I will try to
add this part too. Also, I made a slight adjustment, (drw_h + 1).
This patch gives better scaling under all resolutions, but the quality is not
good, meaning that the vertical scale is still imperfect (but only by a few
pixels). I changed the end of the line to (drw_h + 1) for testing purposes, and
with this modification under 640x480, the scaling quality goes from bad to very
good. Under 800x600 onwards, though, the quality is bad again, but it differs
from the previous patch considerably, there is *no* black border noticeable. I
imagine that tweaking this using low values such as (drw_h + 2), 3, 4 will
produce good results under higher resolutions, but what is really needed is to
incorporate more changes from the radeon driver (probably y_mult, x_off and
y_off variables), which I will try tomorrow. If someone can provide feedback to
help me in the meantime, I would appreciate it.
Created attachment 5197 [details] [review]
r128_video.c with radeon patches try2
This patch appears to solve my problem under all resolutions and video sizes,
however, I am not satisfied with the results. I have also incorporated a
doublescan/interlace fix by Marc La France, see
Vertical scaling appears to be correct, but on closer inspection, the quality
of Xv output is bad compared to output from X11 video (using eg., mplayer).
Can someone have a look and see if anything else needs to be changed?
Nice work. I'll take a look at it as soon as I get through my current patch queue.
I've made a few observations. My laptop LCD screen's native resolution is
1400x1050. Using the default driver (without my patch), here's my observations:
1. X running at 1400x1050: Xv output is perfect. Image quality is great (almost
identical to X11 output from mplayer), scaling seems perfect (no black border at
the bottom of the video).
2. X running at 1280x1024: Xv output bad. Image is squashed vertically, but only
by a few dozen pixels, as a slight black border is noticeable at the bottom.
The resolutions 1024x768, 800x600 and 640x480 follow this pattern too, with Xv's
vertical output becoming progressively more squashed as the resolution is lowered.
Using a patched driver with my latest patch, here's my observations:
1. X running at 1400x1050 - Xv output perfect, same as with default driver
2. X running at 1280x1024 - Xv output very good. The vertical scale *seems*
perfect, there is no black border any more, and hence the image no longer
appears distorted. However, close visual inspection shows some inperfections
with the scaling, but hardly noticeable at all.
3. X running at 1024x768 - Xv output is good. Again, the vertical scale seems
fine, but the image quality has taken a hit. It's tough to explain, but looks as
though the picture is slightly interlaced. Watching a cartoon (Family Guy), the
black outline of characters looks jagged or pixellated, whereas using x11
output, the characters have solid looking outlines with no hint of jaggedness.
Both 800x600 and 640x480 exhibit the same problem, but it seems to my eyes that
1024x768 has the worst image quality of all resolutions with my patched driver.
Vertical scaling seems fine under all resolutions, as there are no longer any
black borders under any resolution.
I've been looking through radeon_video.c and tried substituting more code from
there, but I've had no luck. Although my patch is "adequate", I would prefer to
have the best possible image quality at all resolutions (especially 1024x768),
due to my card not having enough videoram to work at 1400x1050, as DRI would be
I've figured out the problem in more depth, but not the solution.
My Dell Inspiron 8000 has a special function key that scales the screen from the
native resolution. The laptop panel's native size is 1400x1050, under lower
resolutions you can have the display unscaled (with borders around the picture)
or scaled (filling the entire panel) - you can toggle this with the key combo Fn+F7.
If the panel is unscaled, the default driver plays videos perfectly, but when
it's scaled (which is the default and most favourable setting) then Xv output's
vertical height is incorrect.
The patch I posted solves the problem at the expense of "dirty" Xv output; the
default driver works perfectly with clear Xv output when the panel is unscaled.
I'd like for it to work as intended with the panel scaled. Is there any logs I
can post to help solve this?
(In reply to comment #8)
> If the panel is unscaled, the default driver plays videos perfectly, but when
> it's scaled (which is the default and most favourable setting) then Xv output's
> vertical height is incorrect.
> The patch I posted solves the problem at the expense of "dirty" Xv output; the
> default driver works perfectly with clear Xv output when the panel is unscaled.
> I'd like for it to work as intended with the panel scaled. Is there any logs I
> can post to help solve this?
Take a look at the radeon code. there is code there to deal with the overlay
when RMX enabled. RMX is the ati scaling cell.
Sorry about the phenomenal bug spam, guys. Adding xorg-team@ to the QA contact so bugs don't get lost in future.
Tagging to avoid patch lossage; will triage later.
Can you please email your patch to xorg-devel for review.
You mention slight imperfections that show up in the video once you scale it properly. Has another change solved this by now? I tried your patch and video still looks fine. I guess it's possible that my eyesight isn't good enough or that it only happens with certain cards.
Anyway, I committed this with xf86-video-r128 commit 4ecd6e67fbbfd52e0ac77a6c48bd3c6a6d5598e7 which should be easy to undo if another dev thinks this is premature. Thanks!