summaryrefslogtreecommitdiff
path: root/src/xvmc/radeon_xvmc.c
blob: 1874133275bf861bcb9224391eff6143c2acdb1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
/*
 * Copyright 2008 Advanced Micro Devices, Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *
 * Author: Cooper Yuan  <cooper.yuan@amd.com>
 *
 */

#include "radeon_xvmc.h"

struct radeon_xvmc_driver *xvmc_driver_ptr = NULL;

static radeon_xvmc_context_ptr radeon_xvmc_new_context(Display *dpy)
{
    radeon_xvmc_context_ptr ret;

    ret = (radeon_xvmc_context_ptr)calloc(1, sizeof(radeon_xvmc_context_t));
    if (!ret)
        return NULL;

    ret->next = xvmc_driver_ptr->ctx_list;
    xvmc_driver_ptr->ctx_list = ret;
    xvmc_driver_ptr->num_ctx++;

    return ret;

}

static void radeon_xvmc_free_context(XID id)
{
    radeon_xvmc_context_ptr p = xvmc_driver_ptr->ctx_list;
    radeon_xvmc_context_ptr pre = p;

    while(p) 
    {
        if (p->context && p->context->context_id == id) 
        {
            if (p == xvmc_driver_ptr->ctx_list)
                xvmc_driver_ptr->ctx_list = p->next;
            else
                pre->next = p->next;
            break;
        }
        pre = p;
        p = p->next;
    }

    if (p) 
    {
        free(p);
        xvmc_driver_ptr->num_ctx--;
    }
}

radeon_xvmc_context_ptr radeon_xvmc_find_context(XID id)
{
    radeon_xvmc_context_ptr p = xvmc_driver_ptr->ctx_list;

    while(p)
    {
        if (p->context && p->context->context_id == id)
            return p;
        p = p->next;
    }
    return NULL;
}

static radeon_xvmc_surface_ptr radeon_xvmc_new_surface(Display *dpy)
{
    radeon_xvmc_surface_ptr ret;

    ret = (radeon_xvmc_surface_ptr)calloc(1, sizeof(radeon_xvmc_surface_t));
    if (!ret)
        return NULL;

    ret->next = xvmc_driver_ptr->surf_list;
    xvmc_driver_ptr->surf_list = ret;
    xvmc_driver_ptr->num_surf++;

    ret->image = NULL;
    ret->gc_init = FALSE;

    return ret;
}

static void radeon_xvmc_free_surface(XID id)
{
    radeon_xvmc_surface_ptr p = xvmc_driver_ptr->surf_list;
    radeon_xvmc_surface_ptr pre = p;

    while(p) 
    {
        if (p->surface && p->surface->surface_id == id) 
        {
            if (p == xvmc_driver_ptr->surf_list)
                xvmc_driver_ptr->surf_list = p->next;
            else
                pre->next = p->next;
            break;
        }
        pre = p;
        p = p->next;
    }

    if (p) 
    {
        free(p);
        xvmc_driver_ptr->num_surf--;
    }
}

radeon_xvmc_surface_ptr radeon_xvmc_find_surface(XID id)
{
    radeon_xvmc_surface_ptr p = xvmc_driver_ptr->surf_list;

    while(p) 
    {
        if (p->surface && p->surface->surface_id == id)
            return p;
        p = p->next;
    }
    return NULL;
}

/*
* Function: XvMCCreateContext
* Description: Create a XvMC context for the given surface parameters.
* Arguments:
*   display - Connection to the X server.
*   port - XvPortID to use as avertised by the X connection.
*   surface_type_id - Unique identifier for the Surface type.
*   width - Width of the surfaces.
*   height - Height of the surfaces.
*   flags - one or more of the following
*      XVMC_DIRECT - A direct rendered context is requested.
*
* Notes: surface_type_id and width/height parameters must match those
*        returned by XvMCListSurfaceTypes.
* Returns: Status
*/
_X_EXPORT Status XvMCCreateContext(Display *display, XvPortID port,
                         int surface_type_id, int width, int height,
                         int flags, XvMCContext *context)
{
    Status ret;
    drm_sarea_t *pSAREA;
    char *curBusID;
    CARD32 *priv_data = NULL;
    struct radeon_xvmc_common *comm;
    drm_magic_t magic;
    int major, minor;
    int priv_count;
    int isCapable;
    int event_base, error_base;
    int screen = DefaultScreen(display);
    radeon_xvmc_context_ptr radeon_ctx;
    int fd;

    /* Verify Obvious things first */
    if (!display || !context)
        return BadValue;

    if (!(flags & XVMC_DIRECT)) 
    {
        ErrorF("[XvMC]: Radeon: Indirect Rendering not supported! Using Direct.");
        return BadValue;
    }

    context->surface_type_id = surface_type_id;
    context->width           = (unsigned short)((width + 15) & ~15);
    context->height          = (unsigned short)((height + 15) & ~15);
    context->flags           = flags;
    context->port            = port;

    if (!XvMCQueryExtension(display, &event_base, &error_base)) 
    {
        ErrorF("[XvMC]: Radeon: XvMCExtension is not available!");
        return BadValue;
    }
    
    ret = XvMCQueryVersion(display, &major, &minor);
    if (ret) 
    {
        ErrorF("[XvMC]: Radeon: XvMCQueryVersion Failed, unable to determine protocol version.");
        return ret;
    }

    /*
     * Pass control to the X server to create a drm_context_t for us and
     * validate the with/height and flags.
     */
    if ((ret = _xvmc_create_context(display, context, &priv_count, &priv_data))) 
    {
        ErrorF("[XvMC]: Radeon: Unable to create XvMC Context.");
        return ret;
    }

    comm = (struct radeon_xvmc_common *)priv_data;

    if (xvmc_driver_ptr == NULL || xvmc_driver_ptr->type != comm->type) 
    {
        switch (comm->type) 
        {
          case XVMC_R500_MPEG2_MC:
            xvmc_driver_ptr = &r500_xvmc_driver;
            break;
          default:
            ErrorF("[XvMC]: Radeon: unimplemented xvmc type %d", comm->type);
            XFree(priv_data);
            priv_data = NULL;
            return BadValue;
        }
    }

    if (xvmc_driver_ptr == NULL || xvmc_driver_ptr->type != comm->type) 
    {
        ErrorF("[XvMC]: Radeon: fail to load xvmc driver for type %d\n", comm->type);
        return BadValue;
    }

    xvmc_driver_ptr->sarea_size         = comm->sarea_size;
    xvmc_driver_ptr->batchbuffer.handle = comm->batchbuffer.handle;
    xvmc_driver_ptr->batchbuffer.offset = comm->batchbuffer.offset;
    xvmc_driver_ptr->batchbuffer.size   = comm->batchbuffer.size;

    /* assign local ctx info */
    radeon_ctx = radeon_xvmc_new_context(display);
    if (!radeon_ctx) 
    {
        ErrorF("[XvMC]: Radeon XvMC context create failed\n");
        return BadAlloc;
    }
    radeon_ctx->context = context;

    ret = uniDRIQueryDirectRenderingCapable(display, screen, &isCapable);
    if (!ret || !isCapable) 
    {
        ErrorF("[XvMC]: Direct Rendering is not available on this system!");
        XFree(priv_data);
        return BadValue;
    }

    if (!uniDRIOpenConnection(display, screen, &xvmc_driver_ptr->hsarea, &curBusID)) 
    {
        ErrorF("[XvMC]: Could not open DRI connection to X server!");
        XFree(priv_data);
        return BadValue;
    }

    /* Open DRI Device */
    if((fd = drmOpen("radeon", curBusID)) < 0) 
    {
        ErrorF("[XvMC]: DRM Device could not be opened.");
        XFree(priv_data);
        XFree(curBusID);
        return BadValue;
    }

    xvmc_driver_ptr->fd = fd;

    strncpy(xvmc_driver_ptr->busID, curBusID, 20);
    xvmc_driver_ptr->busID[20] = '\0';
    XFree(curBusID);

    /* Get magic number */
    drmGetMagic(xvmc_driver_ptr->fd, &magic);

    if (!uniDRIAuthConnection(display, screen, magic)) 
    {
        ErrorF("[XvMC]: X server did not allow DRI. Check permissions.");
        xvmc_driver_ptr = NULL;
        XFree(priv_data);
        return BadAlloc;
    }

    /*
     * Map DRI Sarea. we always want it right?
     */
    if (drmMap(xvmc_driver_ptr->fd, xvmc_driver_ptr->hsarea,
               xvmc_driver_ptr->sarea_size, &xvmc_driver_ptr->sarea_address) < 0) 
    {
        XVMC_ERR("[XvMC]: Unable to map DRI SAREA.\n");
        xvmc_driver_ptr = NULL;
        XFree(priv_data);
        return BadAlloc;
    }
    pSAREA = (drm_sarea_t *)xvmc_driver_ptr->sarea_address;
    xvmc_driver_ptr->driHwLock = (drmLock *)&pSAREA->lock;
    pthread_mutex_init(&xvmc_driver_ptr->ctxmutex, NULL);

    /* context_id is alloc in _xvmc_create_context */
    if (!uniDRICreateContext(display, screen, DefaultVisual(display, screen),
                             context->context_id,
                             &radeon_ctx->hw_context)) 
    {
        XVMC_ERR("[XvMC]: Could not create DRI context for xvmc ctx %d.",
                 (int)context->context_id);
        XFree(priv_data);
        context->privData = NULL;
        drmUnmap(xvmc_driver_ptr->sarea_address, xvmc_driver_ptr->sarea_size);
        return BadAlloc;
    }
    
    /* 
     * call driver hook.
     * driver hook should free priv_data after return if success.
     */
    ret = (xvmc_driver_ptr->create_context)(display, context, priv_count, priv_data);
    if (ret) 
    {
        ErrorF("[XvMC]: driver create context failed\n");
        XFree(priv_data);
        drmUnmap(xvmc_driver_ptr->sarea_address, xvmc_driver_ptr->sarea_size);
        return ret;
    }

    return Success;
}

/*
 * Function: XvMCDestroyContext
 * Description: Destorys the specified context.
 *
 * Arguments:
 *   display - Specifies the connection to the server.
 *   context - The context to be destroyed.
 *
 */
_X_EXPORT Status XvMCDestroyContext(Display *display, XvMCContext *context)
{
    Status ret;
    int screen;

    if (!display || !context)
        return XvMCBadContext;
    screen = DefaultScreen(display);
    ret = (xvmc_driver_ptr->destroy_context)(display, context);
    if (ret) 
    {
        ErrorF("[XvMC]: destroy context fail\n");
        return ret;
    }

    uniDRIDestroyContext(display, screen, context->context_id);
    radeon_xvmc_free_context(context->context_id);
    
    ret = _xvmc_destroy_context(display, context);
    if (ret != Success) 
    {
        ErrorF("[XvMC]: _xvmc_destroy_context fail\n");
        return ret;
    }

    if (xvmc_driver_ptr->num_ctx == 0) 
    {
        uniDRICloseConnection(display, screen);
        pthread_mutex_destroy(&xvmc_driver_ptr->ctxmutex);

        drmUnmap(xvmc_driver_ptr->sarea_address, xvmc_driver_ptr->sarea_size);

        if (xvmc_driver_ptr->fd >= 0)
            drmClose(xvmc_driver_ptr->fd);
        xvmc_driver_ptr->fd = -1;
    }
    return Success;    
}

/*
 * Function: XvMCCreateSurface
 */
_X_EXPORT Status XvMCCreateSurface(Display *display, XvMCContext *context, XvMCSurface *surface)
{
}

/*
 * Function: XvMCDestroySurface
 */
_X_EXPORT Status XvMCDestroySurface(Display *display, XvMCSurface *surface)
{
}

/*
 * Function: XvMCCreateBlocks
 */
_X_EXPORT Status XvMCCreateBlocks(Display *display, XvMCContext *context,
                        unsigned int num_blocks,
                        XvMCBlockArray *block)
{
}

/*
 * Function: XvMCDestroyBlocks
 */
_X_EXPORT Status XvMCDestroyBlocks(Display *display, XvMCBlockArray *block)
{
}

/*
 * Function: XvMCCreateMacroBlocks
 */
_X_EXPORT Status XvMCCreateMacroBlocks(Display *display, XvMCContext *context,
                             unsigned int num_blocks,
                             XvMCMacroBlockArray *blocks)
{
}

/*
 * Function: XvMCDestroyMacroBlocks
 */
_X_EXPORT Status XvMCDestroyMacroBlocks(Display *display, XvMCMacroBlockArray *block)
{
}

/*
 * Function: XvMCRenderSurface
 *
 * Description: This function does the actual HWMC. Given a list of
 *  macroblock structures it dispatched the hardware commands to execute
 *  them.
 */
_X_EXPORT Status XvMCRenderSurface(Display *display, XvMCContext *context,
                         unsigned int picture_structure,
                         XvMCSurface *target_surface,
                         XvMCSurface *past_surface,
                         XvMCSurface *future_surface,
                         unsigned int flags,
                         unsigned int num_macroblocks,
                         unsigned int first_macroblock,
                         XvMCMacroBlockArray *macroblock_array,
                         XvMCBlockArray *blocks)
{
}

/*
 * Function: XvMCPutSurface
 *
 * Description:
 * Arguments:
 *  display: Connection to X server
 *  surface: Surface to be displayed
 *  draw: X Drawable on which to display the surface
 *  srcx: X coordinate of the top left corner of the region to be
 *          displayed within the surface.
 *  srcy: Y coordinate of the top left corner of the region to be
 *          displayed within the surface.
 *  srcw: Width of the region to be displayed.
 *  srch: Height of the region to be displayed.
 *  destx: X cordinate of the top left corner of the destination region
 *         in the drawable coordinates.
 *  desty: Y cordinate of the top left corner of the destination region
 *         in the drawable coordinates.
 *  destw: Width of the destination region.
 *  desth: Height of the destination region.
 *  flags: One or more of the following.
 *	XVMC_TOP_FIELD - Display only the Top field of the surface.
 *	XVMC_BOTTOM_FIELD - Display only the Bottom Field of the surface.
 *	XVMC_FRAME_PICTURE - Display both fields or frame.
 */
_X_EXPORT Status XvMCPutSurface(Display *display,XvMCSurface *surface,
                      Drawable draw, short srcx, short srcy,
                      unsigned short srcw, unsigned short srch,
                      short destx, short desty,
                      unsigned short destw, unsigned short desth,
                      int flags)
{
}

/*
 * Function: XvMCSyncSurface
 * Arguments:
 *   display - Connection to the X server
 *   surface - The surface to synchronize
 */
_X_EXPORT Status XvMCSyncSurface(Display *display, XvMCSurface *surface)
{
}

/*
 * Function: XvMCFlushSurface
 * Description:
 *   This function commits pending rendering requests to ensure that they
 *   wll be completed in a finite amount of time.
 * Arguments:
 *   display - Connection to X server
 *   surface - Surface to flush
 * Returns: Status
 */
_X_EXPORT Status XvMCFlushSurface(Display * display, XvMCSurface *surface)
{
}

/*
 * Function: XvMCGetSurfaceStatus
 * Description:
 * Arguments:
 *  display: connection to X server
 *  surface: The surface to query
 *  stat: One of the Following
 *    XVMC_RENDERING - The last XvMCRenderSurface command has not
 *                     completed.
 *    XVMC_DISPLAYING - The surface is currently being displayed or a
 *                     display is pending.
 */
_X_EXPORT Status XvMCGetSurfaceStatus(Display *display, XvMCSurface *surface, int *stat)
{
}

/*
 * Function: XvMCHideSurface
 * Description: Stops the display of a surface.
 * Arguments:
 *   display - Connection to the X server.
 *   surface - surface to be hidden.
 *
 * Returns: Status
 */
_X_EXPORT Status XvMCHideSurface(Display *display, XvMCSurface *surface)
{
}

/*
 * Function: XvMCCreateSubpicture
 * Description: This creates a subpicture by filling out the XvMCSubpicture
 *              structure passed to it and returning Success.
 * Arguments:
 *   display - Connection to the X server.
 *   context - The context to create the subpicture for.
 *   subpicture - Pre-allocated XvMCSubpicture structure to be filled in.
 *   width - of subpicture
 *   height - of subpicture
 *   xvimage_id - The id describing the XvImage format.
 *
 * Returns: Status
 */
_X_EXPORT Status XvMCCreateSubpicture(Display *display, XvMCContext *context,
                            XvMCSubpicture *subpicture,
                            unsigned short width, unsigned short height,
                            int xvimage_id)
{
}

/*
 * Function: XvMCClearSubpicture
 * Description: Clear the area of the given subpicture to "color".
 *              structure passed to it and returning Success.
 * Arguments:
 *   display - Connection to the X server.
 *   subpicture - Subpicture to clear.
 *   x, y, width, height - rectangle in the subpicture to clear.
 *   color - The data to file the rectangle with.
 *
 * Returns: Status
 */
_X_EXPORT Status XvMCClearSubpicture(Display *display, XvMCSubpicture *subpicture,
                           short x, short y,
                           unsigned short width, unsigned short height,
                           unsigned int color)
{
}

/*
 * Function: XvMCCompositeSubpicture
 * Description: Composite the XvImae on the subpicture. This composit uses
 *              non-premultiplied alpha. Destination alpha is utilized
 *              except for with indexed subpictures. Indexed subpictures
 *              use a simple "replace".
 * Arguments:
 *   display - Connection to the X server.
 *   subpicture - Subpicture to clear.
 *   image - the XvImage to be used as the source of the composite.
 *   srcx, srcy, width, height - The rectangle from the image to be used.
 *   dstx, dsty - location in the subpicture to composite the source.
 *
 * Returns: Status
 */
_X_EXPORT Status XvMCCompositeSubpicture(Display *display, XvMCSubpicture *subpicture,
                               XvImage *image,
                               short srcx, short srcy,
                               unsigned short width, unsigned short height,
                               short dstx, short dsty)
{
}

/*
 * Function: XvMCDestroySubpicture
 * Description: Destroys the specified subpicture.
 * Arguments:
 *   display - Connection to the X server.
 *   subpicture - Subpicture to be destroyed.
 *
 * Returns: Status
 */
_X_EXPORT Status XvMCDestroySubpicture(Display *display, XvMCSubpicture *subpicture)
{
    return BadValue;
}

/*
 * Function: XvMCSetSubpicturePalette
 * Description: Set the subpictures palette
 * Arguments:
 *   display - Connection to the X server.
 *   subpicture - Subpiture to set palette for.
 *   palette - A pointer to an array holding the palette data. The array
 *     is num_palette_entries * entry_bytes in size.
 * Returns: Status
 */
_X_EXPORT Status XvMCSetSubpicturePalette(Display *display, XvMCSubpicture *subpicture,
                                unsigned char *palette)
{
    return BadValue;
}

/*
 * Function: XvMCBlendSubpicture
 * Description:
 *    The behavior of this function is different depending on whether
 *    or not the XVMC_BACKEND_SUBPICTURE flag is set in the XvMCSurfaceInfo.
 *    i915 only support frontend behavior.
 *
 *    XVMC_BACKEND_SUBPICTURE not set ("frontend" behavior):
 *
 *    XvMCBlendSubpicture is a no-op in this case.
 *
 * Arguments:
 *   display - Connection to the X server.
 *   subpicture - The subpicture to be blended into the video.
 *   target_surface - The surface to be displayed with the blended subpic.
 *   source_surface - Source surface prior to blending.
 *   subx, suby, subw, subh - The rectangle from the subpicture to use.
 *   surfx, surfy, surfw, surfh - The rectangle in the surface to blend
 *      blend the subpicture rectangle into. Scaling can ocure if
 *      XVMC_SUBPICTURE_INDEPENDENT_SCALING is set.
 *
 * Returns: Status
 */
_X_EXPORT Status XvMCBlendSubpicture(Display *display, XvMCSurface *target_surface,
                           XvMCSubpicture *subpicture,
                           short subx, short suby,
                           unsigned short subw, unsigned short subh,
                           short surfx, short surfy,
                           unsigned short surfw, unsigned short surfh)
{
    return BadValue;
}

/*
 * Function: XvMCBlendSubpicture2
 * Description:
 *    The behavior of this function is different depending on whether
 *    or not the XVMC_BACKEND_SUBPICTURE flag is set in the XvMCSurfaceInfo.
 *    i915 only supports frontend blending.
 *
 *    XVMC_BACKEND_SUBPICTURE not set ("frontend" behavior):
 *
 *    XvMCBlendSubpicture2 blends the source_surface and subpicture and
 *    puts it in the target_surface.  This does not effect the status of
 *    the source surface but will cause the target_surface to query
 *    XVMC_RENDERING until the blend is completed.
 *
 * Arguments:
 *   display - Connection to the X server.
 *   subpicture - The subpicture to be blended into the video.
 *   target_surface - The surface to be displayed with the blended subpic.
 *   source_surface - Source surface prior to blending.
 *   subx, suby, subw, subh - The rectangle from the subpicture to use.
 *   surfx, surfy, surfw, surfh - The rectangle in the surface to blend
 *      blend the subpicture rectangle into. Scaling can ocure if
 *      XVMC_SUBPICTURE_INDEPENDENT_SCALING is set.
 *
 * Returns: Status
 */
_X_EXPORT Status XvMCBlendSubpicture2(Display *display,
                            XvMCSurface *source_surface,
                            XvMCSurface *target_surface,
                            XvMCSubpicture *subpicture,
                            short subx, short suby,
                            unsigned short subw, unsigned short subh,
                            short surfx, short surfy,
                            unsigned short surfw, unsigned short surfh)
{
    return BadValue;
}

/*
 * Function: XvMCSyncSubpicture
 * Description: This function blocks until all composite/clear requests on
 *              the subpicture have been complete.
 * Arguments:
 *   display - Connection to the X server.
 *   subpicture - The subpicture to synchronize
 *
 * Returns: Status
 */
_X_EXPORT Status XvMCSyncSubpicture(Display *display, XvMCSubpicture *subpicture)
{
    return BadValue;
}

/*
 * Function: XvMCFlushSubpicture
 * Description: This function commits pending composite/clear requests to
 *              ensure that they will be completed in a finite amount of
 *              time.
 * Arguments:
 *   display - Connection to the X server.
 *   subpicture - The subpicture whos compsiting should be flushed
 *
 * Returns: Status
 */
_X_EXPORT Status XvMCFlushSubpicture(Display *display, XvMCSubpicture *subpicture)
{
    return BadValue;
}

/*
 * Function: XvMCGetSubpictureStatus
 * Description: This function gets the current status of a subpicture
 *
 * Arguments:
 *   display - Connection to the X server.
 *   subpicture - The subpicture whos status is being queried
 *   stat - The status of the subpicture. It can be any of the following
 *          OR'd together:
 *          XVMC_RENDERING  - Last composite or clear request not completed
 *          XVMC_DISPLAYING - Suppicture currently being displayed.
 *
 * Returns: Status
 */
_X_EXPORT Status XvMCGetSubpictureStatus(Display *display, XvMCSubpicture *subpicture,
                               int *stat)
{
    return BadValue;
}

/*
 * Function: XvMCQueryAttributes
 * Description: An array of XvAttributes of size "number" is returned by
 *   this function. If there are no attributes, NULL is returned and number
 *   is set to 0. The array may be freed with xfree().
 *
 * Arguments:
 *   display - Connection to the X server.
 *   context - The context whos attributes we are querying.
 *   number - The returned number of recognized atoms
 *
 * Returns:
 *  An array of XvAttributes.
 */
_X_EXPORT XvAttribute *XvMCQueryAttributes(Display *display, XvMCContext *context,
                                 int *number)
{
    /* now XvMC has no extra attribs than Xv */
    *number = 0;
    return NULL;
}

/*
 * Function: XvMCSetAttribute
 * Description: This function sets a context-specific attribute.
 *
 * Arguments:
 *   display - Connection to the X server.
 *   context - The context whos attributes we are querying.
 *   attribute - The X atom of the attribute to be changed.
 *   value - The new value for the attribute.
 *
 * Returns:
 *  Status
 */
_X_EXPORT Status XvMCSetAttribute(Display *display, XvMCContext *context,
                        Atom attribute, int value)
{
    return Success;
}

/*
 * Function: XvMCGetAttribute
 * Description: This function queries a context-specific attribute and
 *   returns the value.
 *
 * Arguments:
 *   display - Connection to the X server.
 *   context - The context whos attributes we are querying.
 *   attribute - The X atom of the attribute to be queried
 *   value - The returned attribute value
 *
 * Returns:
 *  Status
 */
_X_EXPORT Status XvMCGetAttribute(Display *display, XvMCContext *context,
                        Atom attribute, int *value)
{
    return Success;
}