Bug 20790

Summary: XvMC disabled with DRI2
Product: xorg Reporter: Matt Turner <mattst88>
Component: Driver/intelAssignee: haihao <haihao.xiang>
Status: RESOLVED FIXED QA Contact: Xorg Project Team <xorg-team>
Severity: major    
Priority: medium CC: charles.bovy, ckane, freedesktop-bugzilla, nanhai.zou, pluescho
Version: git   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
enable XvMC on DRI2
none
enable XvMC on DRI2 (new) none

Description Matt Turner 2009-03-21 15:59:52 UTC
I'm trying to enable XvMC with xf86-video-intel-2.6.99.902 on my GM965.

In /var/log/Xorg.0.log, I see

(==) intel(0): Intel XvMC decoder disabled

I tried adding Options XvMC and XvMCSurfaces to xorg.conf, but neither
changes anything. The log even reports that '(WW) intel(0): Option
"XvMCSurfaces" is not used'.

During the configure stage, it prints "checking whether to include
XvMC support... yes" so I cannot understand why I cannot enable it. I
have libXvMC-1.0.4 installed.
Comment 1 Matt Turner 2009-03-23 12:43:45 UTC
Evidently XvMC is explicitly disabled on DRI2. See commit 32e7d47925b445a85847d77651b258e117aaaffe

This is fine and well, but _why_ wasn't it documented? Why wasn't a bug report filed?

This is really just an irrelevant rant, but why are the man pages _never_ in-sync with the driver?

o Option XvMC isn't even mentioned in the man page
o Option XvMCSurfaces appears to be used only on i810 -- not documented in the man page
o Option PageFlip default on i830+ according to the man page is disabled, but it actually doesn't even exist
o Same for Option TripleBuffer

I'm sure I could go on.
Comment 2 haihao 2009-03-27 01:07:48 UTC
Created attachment 24304 [details] [review]
enable XvMC on DRI2

This patch enables XvMC on DRI2. To use XvMC, you should set option 'XvMC' to 'on' in your xorg.conf (See intel manual)
Comment 3 Matt Turner 2009-03-28 12:51:17 UTC
I tested the patch. It appears to work correctly, thanks!
Comment 4 Charles Bovy 2009-04-05 12:34:43 UTC
I tried your patch as well, but didn't get it to work. Here are the results:

Test with:
(II) intel(0): Integrated Graphics Chipset: Intel(R) G45/G43

Tested with mplayer with command: 
mplayer -vo xvmc -vc ffmpeg12mc VTS_01_1.VOB

Error of mplayer:

Playing VTS_01_1.VOB.
MPEG-PS file format detected.
VIDEO:  MPEG2  720x576  (aspect 3)  25.000 fps  8572.0 kbps (1071.5 kbyte/s)
xscreensaver_disable: Could not find XScreenSaver window.
GNOME screensaver disabled
vo_xvmc: X-Video extension 2.2
vo_xvmc: X-Video MotionCompensation Extension version 1.1
==========================================================================
Forced video codec: ffmpeg12mc
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
[VD_FFMPEG] XVMC accelerated codec.
Selected video codec: [ffmpeg12mc] vfm: ffmpeg (FFmpeg MPEG-1/2 (XvMC))
==========================================================================
==========================================================================
Forced audio codec: mad
Opening audio decoder: [libmad] libmad mpeg audio decoder
AUDIO: 48000 Hz, 2 ch, s16le, 224.0 kbit/14.58% (ratio: 28000->192000)
Selected audio codec: [mad] afm: libmad (libMAD MPEG layer 1-2-3)
==========================================================================
AO: [alsa] 48000Hz 2ch s16le (2 bytes per sample)
Starting playback...
[VD_FFMPEG] XVMC-accelerated MPEG-2.
[VD_FFMPEG] Trying pixfmt=0.
VDec: vo config request - 720 x 576 (preferred colorspace: MPEG1/2 Motion Compensation and IDCT)
VDec: using MPEG1/2 Motion Compensation as output csp (no 1)
Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.
VO: [xvmc] 720x576 => 1024x576 MPEG1/2 Motion Compensation 
vo_xvmc: Port 69 grabed
vo_xvmc: Found matching surface with id=32315659 on 69 port at 0 adapter
[intel_xvmc] info: decoder type is i965 MPEG2 MC decoder
vo_xvmc: Allocated Direct Context
vo_xvmc: data_blocks allocated
vo_xvmc: mv_blocks allocated
vo_xvmc: Motion Compensation context allocated - 8 surfaces
vo_xvmc: idct=0 unsigned_intra=1
vo_xvmc: looking for OSD support
vo_xvmc: No OSD support for this mode
DRM_I830_BATCHBUFFER: -22


dmesg:
[drm:i915_batchbuffer] *ERROR* Batchbuffer ioctl disabled

I'm using drm-intel
Comment 5 haihao 2009-04-06 19:54:12 UTC
(In reply to comment #4)
> VDec: vo config request - 720 x 576 (preferred colorspace: MPEG1/2 Motion
> Compensation and IDCT)
> VDec: using MPEG1/2 Motion Compensation as output csp (no 1)
> Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.
> VO: [xvmc] 720x576 => 1024x576 MPEG1/2 Motion Compensation 
> vo_xvmc: Port 69 grabed
> vo_xvmc: Found matching surface with id=32315659 on 69 port at 0 adapter
> [intel_xvmc] info: decoder type is i965 MPEG2 MC decoder
> vo_xvmc: Allocated Direct Context
> vo_xvmc: data_blocks allocated
> vo_xvmc: mv_blocks allocated
> vo_xvmc: Motion Compensation context allocated - 8 surfaces
> vo_xvmc: idct=0 unsigned_intra=1
> vo_xvmc: looking for OSD support
> vo_xvmc: No OSD support for this mode
> DRM_I830_BATCHBUFFER: -22
> 
> 
> dmesg:
> [drm:i915_batchbuffer] *ERROR* Batchbuffer ioctl disabled

Does it work for you with DRI?
Comment 6 Charles Bovy 2009-04-07 09:32:48 UTC
I have tried the following:

* Changing back from UXA to EXA and disable DRI2. XvMC is working. Comparing CPU usage between XvMC and Xv at a working situation, shows that the XvMC option uses a bit more CPU (mplayer: 13% compared to 9%). I should say it should be less.

* Changing back from UXA to EXA, and leaving DRI2 active. XvMC is working. CPU is at 26% with XvMC and 11% with Xv.

UXA in combination with DRI2 is causing XvMC to fail.

Any other things to try?
Comment 7 Charles Bovy 2009-04-07 13:02:30 UTC
Just worth to mention, but no time at the moment to confirm: running kernel with KMS enabled, UXA and DRI2, XvMC works correctly. Give me another day to confirm this behaviour.
Previous attemps were done with KMS disabled.
Comment 8 Charles Bovy 2009-04-07 13:24:44 UTC
Confirmed: With KMS, UXA and DRI2, XvMC is working correctly. Without KMS, no XvMC with the BATCHBUFFER error.
One side effect: with KMS I don't have any HDMI audio anymore....
Comment 9 haihao 2009-04-07 18:31:16 UTC
(In reply to comment #4)
> dmesg:
> [drm:i915_batchbuffer] *ERROR* Batchbuffer ioctl disabled
> 
> I'm using drm-intel
Oh, the batchbuffer ioctl is disabled.

        if (!dev_priv->allow_batchbuffer) {
                DRM_ERROR("Batchbuffer ioctl disabled\n");
                return -EINVAL;
        }


The default of dev_priv->allow_batchbuffer should be 1 and I don't find any component (2D/3D/xvmc)try to change it.  Does direct rendering work fine for you?
Comment 10 Charles Bovy 2009-04-08 09:35:11 UTC
I think direct rendering is working:
glxinfo:
name of display: :0.0
display: :0  screen: 0
direct rendering: Yes
server glx vendor string: SGI
server glx version string: 1.2

There are only two locations where "dev_priv->allow_batchbuffer = 1" is set:
* i915_initializei915_initialize
* i915_load_modeset_init

Is i915_initialize() being called in a non-KMS case?
Comment 11 haihao 2009-04-08 19:25:48 UTC
Created attachment 24679 [details] [review]
enable XvMC on DRI2 (new)

Currently XvMC uses batchbuffer to pass commands
Comment 12 Charles Bovy 2009-04-09 12:53:30 UTC
Perfect! Latest patch works for me.
Both MPlayer and MythTV are able to use XvMC at this moment.

Is Chromakey supported?

2009-04-09 19:30:45.130 VideoOutputXv: XvMC Adaptor Name: 'Intel(R) Textured Video'
2009-04-09 19:30:45.136 VideoOutputXv: Ack! Disabling ChromaKey OSD
                        We can't use ChromaKey OSD if chromakeying is not supported!
2009-04-09 19:30:45.138 VideoOutputXv: XvMC Adaptor Name: 'Intel(R) Textured Video'
2009-04-09 19:30:45.143 XvMCOSD::CreateBuffer() failed because no subpicture is available
2009-04-09 19:30:45.266 VideoOutputXv: ProcessFrameXvMC: Tried to reuse frame but failed
2009-04-09 19:30:45.266 VideoOutputXv: ProcessFrameXvMC: Called without frame
2009-04-09 19:30:45.268 AFD: Opened codec 0x7f39f7964c50, id(MPEG2VIDEO_XVMC) type(Video)
Comment 13 Coleman Kane 2009-05-01 08:43:32 UTC
I applied the new patch to version 2.7.99.1 of the driver, so that I can use UXA and KMS, and I currently get the following error, and the X server hangs (but the HW cursor can still move). I modified the driver slightly to remove the DRI1 references which were being used to assign the sarea stuff (and also un-commented the section in configure.ac), otherwise 2.7.99.1 would not compile with --enable-xvmc.

intelWaitIrq: drmI830IrqWait: -16

This is from running 'mplayer -vo xvmc -vc ffmpeg12mc file.mpg' on an Intel Atom platform w/ a 945GME chip.

I see the following output from mplayer:
Starting playback...
[VD_FFMPEG] Trying pixfmt=0.
[VD_FFMPEG] XVMC-accelerated MPEG-2.
VDec: vo config request - 640 x 480 (preferred colorspace: MPEG1/2 Motion Compensation and IDCT)
vo_xvmc: Found matching surface with id=434D5658 on 73 port at 0 adapter
VDec: using MPEG1/2 Motion Compensation as output csp (no 1)
Movie-Aspect is 1.33:1 - prescaling to correct movie aspect.
VO: [xvmc] 640x480 => 640x480 MPEG1/2 Motion Compensation 
vo_xvmc: Found matching surface with id=434D5658 on 73 port at 0 adapter
vo_xvmc: Using Xv Adaptor #0 (Intel(R) Textured Video)
vo_xvmc: Port 73 grabed
[intel_xvmc] info: decoder type is i915/945 MPEG2 MC decoder
vo_xvmc: Allocated Direct Context
vo_xvmc: data_blocks allocated
vo_xvmc: mv_blocks allocated
vo_xvmc: Motion Compensation context allocated - 8 surfaces
vo_xvmc: idct=0 unsigned_intra=0
vo_xvmc: looking for OSD support
vo_xvmc: No OSD support for this mode
[VD_FFMPEG] XVMC-accelerated MPEG-2.

And the following output is visible in the Xorg.0.log:
(II) intel(0): i915_mc: Fixed memory allocation layout:
(II) intel(0): i915_mc: 0x00000000-0xffff4fff: DRI memory manager (4194260 kB)
(II) intel(0): i915_mc: 0x00000000:            end of aperture
(II) intel(0): i915_mc: BO memory allocation layout:
(II) intel(0): i915_mc: 0x00000000:            start of memory manager
(II) intel(0): i915_mc: 0x02300000-0x0237ffff: [XvMC]Correction Data Buffer (512 kB)
(II) intel(0): i915_mc: 0x02200000-0x02200fff: [XvMC]Pixel Shader Constants (4 kB)
(II) intel(0): i915_mc: 0x02100000-0x02100fff: [XvMC]Pixel Shader Program (4 kB)
(II) intel(0): i915_mc: 0x02000000-0x02000fff: [XvMC]Map State (4 kB)
(II) intel(0): i915_mc: 0x01300000-0x01300fff: [XvMC]Sampler State (4 kB)
(II) intel(0): i915_mc: 0x01200000-0x01200fff: [XvMC]Static Indirect State (4 kB)
(II) intel(0): i915_mc: 0x01800000-0x01cfffff: front buffer (5120 kB)
(II) intel(0): i915_mc: 0x01100000-0x0110ffff: [XvMC] batch buffer (64 kB)
(II) intel(0): i915_mc: 0x01000000-0x01009fff: HW cursors (40 kB)
(II) intel(0): i915_mc: 0xffff5000:            end of memory manager
Comment 14 Coleman Kane 2009-05-01 08:46:08 UTC
FYI: OpenGL+DRI rendering does work fine on this chip using the intel driver. I did make the xorg.conf adjustment to turn off Tiling though.
Comment 15 Coleman Kane 2009-05-01 11:18:12 UTC
Also, the kernel (2.6.29.2) states the following on the matter:

[drm:i915_wait_irq] *ERROR* EBUSY -- rec: 2 emitted: 5
Comment 16 haihao 2009-05-04 00:15:59 UTC
XvMC on 915 is broken since Xv uses BOs.  I sent out a new patch  to intel-gfx for review, could you try with it?
Comment 17 Coleman Kane 2009-05-04 08:36:40 UTC
(In reply to comment #16)
> XvMC on 915 is broken since Xv uses BOs.  I sent out a new patch  to intel-gfx
> for review, could you try with it?
> 

Thank you! This seems to work now. "mplayer -vo xvmc -vc ffmpeg12mc video.mpg" works for me and mplayer does output information indicating the use of xvmc.
Comment 18 Coleman Kane 2009-05-04 10:43:50 UTC
I read that there was a surface size limit on XvMC. Is this restriction a limit of the hardware, or of the implementation of XvMC in the driver/libraries?
Comment 19 Coleman Kane 2009-05-04 11:20:37 UTC
Scratch that... it stopped working again. I can't reproduce the success I had this morning. More to come.
Comment 20 Coleman Kane 2009-05-04 12:23:15 UTC
Okay, I figured out how to reproduce it. I have to first run an OpenGL/DRI application that sets up an OpenGL context, then exit it. This seems to leave the system in a state which permits me to use XvMC.

If I just boot the system, start up X.org, and run mplayer with xvmc, I get the IRQ timeout errors. I must run an OpenGL app first, close it, and then I may use mplayer w/ XvMC.
Comment 21 haihao 2009-05-04 23:32:40 UTC
It works for me on 945GM with 
X:1.6.1
xf86-video-intel: master(8255cca2c9092f7ecb798944aa8f03fa3efcfa6c) + xvmc patch
kernel: 2.6.30-rc4 (KMS enabled).

Comment 22 Coleman Kane 2009-05-05 08:16:51 UTC
(In reply to comment #21)
> It works for me on 945GM with 
> X:1.6.1
> xf86-video-intel: master(8255cca2c9092f7ecb798944aa8f03fa3efcfa6c) + xvmc patch
> kernel: 2.6.30-rc4 (KMS enabled).
> 

Are you using an AIGLX-enabled window manager? This would normally initialize any DRI state to my report's "working state" as soon as your X session starts.

I am basically doing the following (on a home-rolled embedded Linux base):

1) Boot up to a console
2) Start X by running: "xinit /bin/twm -- -config xorg.conf"
3) Start up mplayer via "mplayer -vc ffmpeg12mc -vo xvmc movie.mpg" and it gives the IRQ timeouts

But, it seems to work if I do the following (where MyProgram is the software I have that is using OpenGL):
1) Boot up to a console
2) Start X by running: "xinit /bin/twm -- -config xorg.conf"
3) Run MyProgram (see that the OpenGL/DRI is working fine)
4) Stop MyProgram (Ctrl-C from the owning console)
5) Start up mplayer via "mplayer -vc ffmpeg12mc -vo xvmc movie.mpg" and it gives the IRQ timeouts

I am using xorg-server v1.6.1, same git master as you are, but I am using kernel 2.6.29.2 w/ KMS enabled. I am probably also using more aggressive compile optimizations than you are. I will attempt to recompile with -O0 and then report if that changes anything.

I'd like for you (if you can) to attempt my test using a bare X session (twm or no window manager) and cold reboot, and see if you can reproduce my behavior.
Comment 23 haihao 2009-05-05 18:22:12 UTC
Please attach your xorg.conf and Xorg.0.log
Comment 24 Gordon Jin 2009-05-13 23:02:12 UTC
*** Bug 21721 has been marked as a duplicate of this bug. ***
Comment 25 Coleman Kane 2009-05-14 11:46:37 UTC
Testing in the case where I was able to trampoline the card into a state where it wouldn't fail in XvMC ops, I was able to test XvMC performance compared to the native system performance. 

In the end, it seems that the XvMC work in the GPU takes longer than simply doing the same work on the Intel Atom CPU I am using. Since I don't dedicate the CPU to anything else substantial, and since XvMC doesn't support greater than PAL/NTSC frame sizes, I decided to drop the experiment, and focus my time elsewhere.

My research came across a new problem when using Xv and OpenGL together. I have this info posted in Bug #21738. You will find the xorg.conf, dmesg, etc... in that issue.... however, I didn't apply the XvMC-enable-on-DRI2 patch to the code I tested for that issue, so you won't see the XvMC output there.

Anyhow, I'd prefer to pursue that bug rather than this one. It's easier for me to just use the CPU to perform the MC step on small SDTV frame sizes and below, so I don't care about XvMC at this point any more, unless it gets larger frame size support.
Comment 26 Charles Bovy 2009-06-07 12:08:48 UTC
I had XvMC working with a previous release with the provided patch.
Today I tried the newest GIT where xvmc-vld is included in master, but now I'm unable to get XvMC working (bot KMS and non-KMS, running 2.6.30-rc8).

Here is the output from Xorg:

(**) intel(0): Option "XvMC" "true"
(II) intel(0): Integrated Graphics Chipset: Intel(R) G45/G43
(--) intel(0): Chipset: "G45/G43"
(**) intel(0): Intel XvMC decoder enabled
(II) intel(0): Set up textured video
(II) intel(0): [XvMC] xvmc_vld driver initialized.
(II) intel(0): direct rendering: DRI2 Enabled

Here is the output of xvmcinfo:

Xv version 2.2
XvMC version 1.1

screen number 0
   info for adaptor 0 [Intel(R) Textured Video]
      number of XvMC surface types: 1

      info about surface 0:
         max_width=1936
         max_height=1096
         subpicture_max_width=1920
         subpicture_max_height=1080
         chroma_format:
            XVMC_CHROMA_FORMAT_420 
         mc_type:
            format                   : MPEG2
            accelaration start from  : MOCOMP 
         flags:
            XVMC_INTRA_UNSIGNED 



And here is the output of mplayer:

Playing VTS_01_1.VOB.
MPEG-PS file format detected.
VIDEO:  MPEG2  720x576  (aspect 3)  25.000 fps  9360.0 kbps (1170.0 kbyte/s)
xscreensaver_disable: Could not find XScreenSaver window.
vo_xvmc: X-Video extension 2.2
vo_xvmc: X-Video MotionCompensation Extension version 1.1
==========================================================================
Forced video codec: ffmpeg12mc
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
[VD_FFMPEG] XVMC accelerated codec.
Selected video codec: [ffmpeg12mc] vfm: ffmpeg (FFmpeg MPEG-1/2 (XvMC))
==========================================================================
==========================================================================
Forced audio codec: mad
Opening audio decoder: [liba52] AC3 decoding with liba52
Using SSE optimized IMDCT transform
Using MMX optimized resampler
AUDIO: 48000 Hz, 2 ch, s16le, 448.0 kbit/29.17% (ratio: 56000->192000)
Selected audio codec: [a52] afm: liba52 (AC3-liba52)
==========================================================================
AO: [alsa] 48000Hz 2ch s16le (2 bytes per sample)
Starting playback...
[VD_FFMPEG] XVMC-accelerated MPEG-2.
[VD_FFMPEG] Trying pixfmt=0.
VDec: vo config request - 720 x 576 (preferred colorspace: MPEG1/2 Motion Compensation and IDCT)
Could not find matching colorspace - retrying with -vf scale...
Opening video filter: [scale]
The selected video_out device is incompatible with this codec.
Try appending the scale filter to your filter list,
e.g. -vf spp,scale instead of -vf spp.
[VD_FFMPEG] Trying pixfmt=1.
VDec: vo config request - 720 x 576 (preferred colorspace: MPEG1/2 Motion Compensation)
Could not find matching colorspace - retrying with -vf scale...
Opening video filter: [scale]
The selected video_out device is incompatible with this codec.
Try appending the scale filter to your filter list,
e.g. -vf spp,scale instead of -vf spp.
VDec: vo config request - 720 x 576 (preferred colorspace: MPEG1/2 Motion Compensation and IDCT)
Could not find matching colorspace - retrying with -vf scale...
Opening video filter: [scale]
The selected video_out device is incompatible with this codec.
Try appending the scale filter to your filter list,
e.g. -vf spp,scale instead of -vf spp.
[VD_FFMPEG] Unexpected init_vo error.


Comment 27 Gordon Jin 2009-06-08 15:20:30 UTC
(In reply to comment #26)
> I had XvMC working with a previous release with the provided patch.
> Today I tried the newest GIT where xvmc-vld is included in master, but now I'm
> unable to get XvMC working (bot KMS and non-KMS, running 2.6.30-rc8).

This seems bug#22103.
Comment 28 haihao 2009-06-08 18:03:59 UTC
It is a different issue. A vld supported mplayer works here.
Comment 29 haihao 2009-06-08 19:28:02 UTC
DRI2 for XvMC is on git master, so I mark it as fixed, and please file a new bug to track the new issue that mplayer without vld support doesn't work on G45/GM45.
Comment 30 Charles Bovy 2009-06-10 09:11:04 UTC
Thanks, problem fixed with latest git. XvMC+G45 working with non-vld mplayer.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.