1428d7b3dSmrg/* 2428d7b3dSmrg * Copyright © 2000, 2008 Keith Packard 3428d7b3dSmrg * 2004 Eric Anholt 4428d7b3dSmrg * 2005 Zack Rusin 5428d7b3dSmrg * 6428d7b3dSmrg * Permission to use, copy, modify, distribute, and sell this software and its 7428d7b3dSmrg * documentation for any purpose is hereby granted without fee, provided that 8428d7b3dSmrg * the above copyright notice appear in all copies and that both that 9428d7b3dSmrg * copyright notice and this permission notice appear in supporting 10428d7b3dSmrg * documentation, and that the name of copyright holders not be used in 11428d7b3dSmrg * advertising or publicity pertaining to distribution of the software without 12428d7b3dSmrg * specific, written prior permission. Copyright holders make no 13428d7b3dSmrg * representations about the suitability of this software for any purpose. It 14428d7b3dSmrg * is provided "as is" without express or implied warranty. 15428d7b3dSmrg * 16428d7b3dSmrg * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 17428d7b3dSmrg * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 18428d7b3dSmrg * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 19428d7b3dSmrg * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 20428d7b3dSmrg * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 21428d7b3dSmrg * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 22428d7b3dSmrg * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 23428d7b3dSmrg * SOFTWARE. 24428d7b3dSmrg */ 25428d7b3dSmrg 26428d7b3dSmrg/** @file 27428d7b3dSmrg * UXA - the unified memory acceleration architecture. 28428d7b3dSmrg * 29428d7b3dSmrg * This is the header containing the public API of UXA for uxa drivers. 30428d7b3dSmrg */ 31428d7b3dSmrg 32428d7b3dSmrg#ifndef UXA_H 33428d7b3dSmrg#define UXA_H 34428d7b3dSmrg 35428d7b3dSmrg#include "scrnintstr.h" 36428d7b3dSmrg#include "pixmapstr.h" 37428d7b3dSmrg#include "windowstr.h" 38428d7b3dSmrg#include "gcstruct.h" 39428d7b3dSmrg#include "picturestr.h" 40428d7b3dSmrg#include "fb.h" 41428d7b3dSmrg 42428d7b3dSmrg#define UXA_VERSION_MAJOR 1 43428d7b3dSmrg#define UXA_VERSION_MINOR 0 44428d7b3dSmrg#define UXA_VERSION_RELEASE 0 45428d7b3dSmrg 46428d7b3dSmrgtypedef enum { 47428d7b3dSmrg UXA_ACCESS_RO, 48428d7b3dSmrg UXA_ACCESS_RW, 49428d7b3dSmrg} uxa_access_t; 50428d7b3dSmrg 51428d7b3dSmrg/** 52428d7b3dSmrg * The UxaDriver structure is allocated through uxa_driver_alloc(), and then 53428d7b3dSmrg * fllled in by drivers. 54428d7b3dSmrg */ 55428d7b3dSmrgtypedef struct _UxaDriver { 56428d7b3dSmrg /** 57428d7b3dSmrg * uxa_major and uxa_minor should be set by the driver to the version of 58428d7b3dSmrg * UXA which the driver was compiled for (or configures itself at 59428d7b3dSmrg * runtime to support). This allows UXA to extend the structure for 60428d7b3dSmrg * new features without breaking ABI for drivers compiled against 61428d7b3dSmrg * older versions. 62428d7b3dSmrg */ 63428d7b3dSmrg int uxa_major, uxa_minor; 64428d7b3dSmrg 65428d7b3dSmrg /** 66428d7b3dSmrg * The flags field is bitfield of boolean values controlling UXA's 67428d7b3dSmrg * behavior. 68428d7b3dSmrg * 69428d7b3dSmrg * The flags include UXA_TWO_BITBLT_DIRECTIONS. 70428d7b3dSmrg */ 71428d7b3dSmrg int flags; 72428d7b3dSmrg 73428d7b3dSmrg /** @name solid 74428d7b3dSmrg * @{ 75428d7b3dSmrg */ 76428d7b3dSmrg /** 77428d7b3dSmrg * check_solid() checks whether the driver can do a solid fill to this drawable. 78428d7b3dSmrg * @param pDrawable Destination drawable 79428d7b3dSmrg * @param alu raster operation 80428d7b3dSmrg * @param planemask write mask for the fill 81428d7b3dSmrg * 82428d7b3dSmrg * The check_solid() call is recommended if prepare_solid() is 83428d7b3dSmrg * implemented, but is not required. 84428d7b3dSmrg */ 85428d7b3dSmrg Bool(*check_solid) (DrawablePtr pDrawable, int alu, Pixel planemask); 86428d7b3dSmrg 87428d7b3dSmrg /** 88428d7b3dSmrg * prepare_solid() sets up the driver for doing a solid fill. 89428d7b3dSmrg * @param pPixmap Destination pixmap 90428d7b3dSmrg * @param alu raster operation 91428d7b3dSmrg * @param planemask write mask for the fill 92428d7b3dSmrg * @param fg "foreground" color for the fill 93428d7b3dSmrg * 94428d7b3dSmrg * This call should set up the driver for doing a series of solid fills 95428d7b3dSmrg * through the solid() call. The alu raster op is one of the GX* 96428d7b3dSmrg * graphics functions listed in X.h, and typically maps to a similar 97428d7b3dSmrg * single-byte "ROP" setting in all hardware. The planemask controls 98428d7b3dSmrg * which bits of the destination should be affected, and will only 99428d7b3dSmrg * represent the bits up to the depth of pPixmap. The fg is the pixel 100428d7b3dSmrg * value of the foreground color referred to in ROP descriptions. 101428d7b3dSmrg * 102428d7b3dSmrg * Note that many drivers will need to store some of the data in the 103428d7b3dSmrg * driver private record, for sending to the hardware with each 104428d7b3dSmrg * drawing command. 105428d7b3dSmrg * 106428d7b3dSmrg * The prepare_solid() call is required of all drivers, but it may fail 107428d7b3dSmrg * for any reason. Failure results in a fallback to software rendering. 108428d7b3dSmrg */ 109428d7b3dSmrg Bool(*prepare_solid) (PixmapPtr pPixmap, 110428d7b3dSmrg int alu, Pixel planemask, Pixel fg); 111428d7b3dSmrg 112428d7b3dSmrg /** 113428d7b3dSmrg * solid() performs a solid fill set up in the last prepare_solid() 114428d7b3dSmrg * call. 115428d7b3dSmrg * 116428d7b3dSmrg * @param pPixmap destination pixmap 117428d7b3dSmrg * @param x1 left coordinate 118428d7b3dSmrg * @param y1 top coordinate 119428d7b3dSmrg * @param x2 right coordinate 120428d7b3dSmrg * @param y2 bottom coordinate 121428d7b3dSmrg * 122428d7b3dSmrg * Performs the fill set up by the last prepare_solid() call, 123428d7b3dSmrg * covering the area from (x1,y1) to (x2,y2) in pPixmap. Note that 124428d7b3dSmrg * the coordinates are in the coordinate space of the destination 125428d7b3dSmrg * pixmap, so the driver will need to set up the hardware's offset 126428d7b3dSmrg * and pitch for the destination coordinates according to the pixmap's 127428d7b3dSmrg * offset and pitch within framebuffer. 128428d7b3dSmrg * 129428d7b3dSmrg * This call is required if prepare_solid() ever succeeds. 130428d7b3dSmrg */ 131428d7b3dSmrg void (*solid) (PixmapPtr pPixmap, int x1, int y1, int x2, int y2); 132428d7b3dSmrg 133428d7b3dSmrg /** 134428d7b3dSmrg * done_solid() finishes a set of solid fills. 135428d7b3dSmrg * 136428d7b3dSmrg * @param pPixmap destination pixmap. 137428d7b3dSmrg * 138428d7b3dSmrg * The done_solid() call is called at the end of a series of consecutive 139428d7b3dSmrg * solid() calls following a successful prepare_solid(). This allows 140428d7b3dSmrg * drivers to finish up emitting drawing commands that were buffered, or 141428d7b3dSmrg * clean up state from prepare_solid(). 142428d7b3dSmrg * 143428d7b3dSmrg * This call is required if prepare_solid() ever succeeds. 144428d7b3dSmrg */ 145428d7b3dSmrg void (*done_solid) (PixmapPtr pPixmap); 146428d7b3dSmrg /** @} */ 147428d7b3dSmrg 148428d7b3dSmrg /** @name copy 149428d7b3dSmrg * @{ 150428d7b3dSmrg */ 151428d7b3dSmrg /** 152428d7b3dSmrg * check_copy() checks whether the driver can blit between the two Pictures 153428d7b3dSmrg */ 154428d7b3dSmrg Bool(*check_copy) (PixmapPtr pSrc, PixmapPtr pDst, int alu, Pixel planemask); 155428d7b3dSmrg /** 156428d7b3dSmrg * prepare_copy() sets up the driver for doing a copy within video 157428d7b3dSmrg * memory. 158428d7b3dSmrg - * 159428d7b3dSmrg * @param pSrcPixmap source pixmap 160428d7b3dSmrg * @param pDstPixmap destination pixmap 161428d7b3dSmrg * @param dx X copy direction 162428d7b3dSmrg * @param dy Y copy direction 163428d7b3dSmrg * @param alu raster operation 164428d7b3dSmrg * @param planemask write mask for the fill 165428d7b3dSmrg * 166428d7b3dSmrg * This call should set up the driver for doing a series of copies 167428d7b3dSmrg * from the pSrcPixmap to the pDstPixmap. The dx flag will be 168428d7b3dSmrg * positive if the 169428d7b3dSmrg * hardware should do the copy from the left to the right, and dy will 170428d7b3dSmrg * be positive if the copy should be done from the top to the bottom. 171428d7b3dSmrg * This is to deal with self-overlapping copies when 172428d7b3dSmrg * pSrcPixmap == pDstPixmap. 173428d7b3dSmrg * 174428d7b3dSmrg * If your hardware can only support blits that are (left to right, 175428d7b3dSmrg * top to bottom) or (right to left, bottom to top), then you should 176428d7b3dSmrg * set #UXA_TWO_BITBLT_DIRECTIONS, and UXA will break down copy 177428d7b3dSmrg * operations to ones that meet those requirements. The alu raster 178428d7b3dSmrg * op is one of the GX* graphics functions listed in X.h, and 179428d7b3dSmrg * typically maps to a similar single-byte "ROP" setting in all 180428d7b3dSmrg * hardware. The planemask controls which bits of the destination 181428d7b3dSmrg * should be affected, and will only represent the bits up to the 182428d7b3dSmrg * depth of pPixmap. 183428d7b3dSmrg * 184428d7b3dSmrg * Note that many drivers will need to store some of the data in the 185428d7b3dSmrg * driver private record, for sending to the hardware with each 186428d7b3dSmrg * drawing command. 187428d7b3dSmrg * 188428d7b3dSmrg * The prepare_copy() call is required of all drivers, but it may fail 189428d7b3dSmrg * for any reason. Failure results in a fallback to software rendering. 190428d7b3dSmrg */ 191428d7b3dSmrg Bool(*prepare_copy) (PixmapPtr pSrcPixmap, 192428d7b3dSmrg PixmapPtr pDstPixmap, 193428d7b3dSmrg int dx, int dy, int alu, Pixel planemask); 194428d7b3dSmrg 195428d7b3dSmrg /** 196428d7b3dSmrg * copy() performs a copy set up in the last prepare_copy call. 197428d7b3dSmrg * 198428d7b3dSmrg * @param pDstPixmap destination pixmap 199428d7b3dSmrg * @param srcX source X coordinate 200428d7b3dSmrg * @param srcY source Y coordinate 201428d7b3dSmrg * @param dstX destination X coordinate 202428d7b3dSmrg * @param dstY destination Y coordinate 203428d7b3dSmrg * @param width width of the rectangle to be copied 204428d7b3dSmrg * @param height height of the rectangle to be copied. 205428d7b3dSmrg * 206428d7b3dSmrg * Performs the copy set up by the last prepare_copy() call, copying the 207428d7b3dSmrg * rectangle from (srcX, srcY) to (srcX + width, srcY + width) in the 208428d7b3dSmrg * source pixmap to the same-sized rectangle at (dstX, dstY) in the 209428d7b3dSmrg * destination pixmap. Those rectangles may overlap in memory, if 210428d7b3dSmrg * pSrcPixmap == pDstPixmap. Note that this call does not receive the 211428d7b3dSmrg * pSrcPixmap as an argument -- if it's needed in this function, it 212428d7b3dSmrg * should be stored in the driver private during prepare_copy(). As 213428d7b3dSmrg * with solid(), the coordinates are in the coordinate space of each 214428d7b3dSmrg * pixmap, so the driver will need to set up source and destination 215428d7b3dSmrg * pitches and offsets from those pixmaps, probably using 216428d7b3dSmrg * uxaGetPixmapOffset() and uxa_get_pixmap_pitch(). 217428d7b3dSmrg * 218428d7b3dSmrg * This call is required if prepare_copy ever succeeds. 219428d7b3dSmrg */ 220428d7b3dSmrg void (*copy) (PixmapPtr pDstPixmap, 221428d7b3dSmrg int srcX, 222428d7b3dSmrg int srcY, int dstX, int dstY, int width, int height); 223428d7b3dSmrg 224428d7b3dSmrg /** 225428d7b3dSmrg * done_copy() finishes a set of copies. 226428d7b3dSmrg * 227428d7b3dSmrg * @param pPixmap destination pixmap. 228428d7b3dSmrg * 229428d7b3dSmrg * The done_copy() call is called at the end of a series of consecutive 230428d7b3dSmrg * copy() calls following a successful prepare_copy(). This allows 231428d7b3dSmrg * drivers to finish up emitting drawing commands that were buffered, 232428d7b3dSmrg * or clean up state from prepare_copy(). 233428d7b3dSmrg * 234428d7b3dSmrg * This call is required if prepare_copy() ever succeeds. 235428d7b3dSmrg */ 236428d7b3dSmrg void (*done_copy) (PixmapPtr pDstPixmap); 237428d7b3dSmrg /** @} */ 238428d7b3dSmrg 239428d7b3dSmrg /** @name composite 240428d7b3dSmrg * @{ 241428d7b3dSmrg */ 242428d7b3dSmrg /** 243428d7b3dSmrg * check_composite() checks to see if a composite operation could be 244428d7b3dSmrg * accelerated. 245428d7b3dSmrg * 246428d7b3dSmrg * @param op Render operation 247428d7b3dSmrg * @param pSrcPicture source Picture 248428d7b3dSmrg * @param pMaskPicture mask picture 249428d7b3dSmrg * @param pDstPicture destination Picture 250428d7b3dSmrg * @param width The width of the composite operation 251428d7b3dSmrg * @param height The height of the composite operation 252428d7b3dSmrg * 253428d7b3dSmrg * The check_composite() call checks if the driver could handle 254428d7b3dSmrg * acceleration of op with the given source, mask, and destination 255428d7b3dSmrg * pictures. This allows drivers to check source and destination 256428d7b3dSmrg * formats, supported operations, transformations, and component 257428d7b3dSmrg * alpha state, and send operations it can't support to software 258428d7b3dSmrg * rendering early on. 259428d7b3dSmrg * 260428d7b3dSmrg * See prepare_composite() for more details on likely issues that 261428d7b3dSmrg * drivers will have in accelerating composite operations. 262428d7b3dSmrg * 263428d7b3dSmrg * The check_composite() call is recommended if prepare_composite() is 264428d7b3dSmrg * implemented, but is not required. 265428d7b3dSmrg */ 266428d7b3dSmrg Bool(*check_composite) (int op, 267428d7b3dSmrg PicturePtr pSrcPicture, 268428d7b3dSmrg PicturePtr pMaskPicture, 269428d7b3dSmrg PicturePtr pDstPicture, 270428d7b3dSmrg int width, int height); 271428d7b3dSmrg 272428d7b3dSmrg /** 273428d7b3dSmrg * check_composite_target() checks to see if the destination of the composite 274428d7b3dSmrg * operation can be used without midification. 275428d7b3dSmrg * 276428d7b3dSmrg * @param pixmap Destination Pixmap 277428d7b3dSmrg * 278428d7b3dSmrg * The check_composite_target() call is recommended if prepare_composite() is 279428d7b3dSmrg * implemented, but is not required. 280428d7b3dSmrg */ 281428d7b3dSmrg Bool(*check_composite_target) (PixmapPtr pixmap); 282428d7b3dSmrg 283428d7b3dSmrg /** 284428d7b3dSmrg * check_composite_texture() checks to see if a source to the composite 285428d7b3dSmrg * operation can be used without midification. 286428d7b3dSmrg * 287428d7b3dSmrg * @param pScreen Screen 288428d7b3dSmrg * @param pPicture Picture 289428d7b3dSmrg * 290428d7b3dSmrg * The check_composite_texture() call is recommended if prepare_composite() is 291428d7b3dSmrg * implemented, but is not required. 292428d7b3dSmrg */ 293428d7b3dSmrg Bool(*check_composite_texture) (ScreenPtr pScreen, 294428d7b3dSmrg PicturePtr pPicture); 295428d7b3dSmrg 296428d7b3dSmrg /** 297428d7b3dSmrg * prepare_composite() sets up the driver for doing a composite 298428d7b3dSmrg * operation described in the Render extension protocol spec. 299428d7b3dSmrg * 300428d7b3dSmrg * @param op Render operation 301428d7b3dSmrg * @param pSrcPicture source Picture 302428d7b3dSmrg * @param pMaskPicture mask picture 303428d7b3dSmrg * @param pDstPicture destination Picture 304428d7b3dSmrg * @param pSrc source pixmap 305428d7b3dSmrg * @param pMask mask pixmap 306428d7b3dSmrg * @param pDst destination pixmap 307428d7b3dSmrg * 308428d7b3dSmrg * This call should set up the driver for doing a series of composite 309428d7b3dSmrg * operations, as described in the Render protocol spec, with the given 310428d7b3dSmrg * pSrcPicture, pMaskPicture, and pDstPicture. The pSrc, pMask, and 311428d7b3dSmrg * pDst are the pixmaps containing the pixel data, and should be used 312428d7b3dSmrg * for setting the offset and pitch used for the coordinate spaces for 313428d7b3dSmrg * each of the Pictures. 314428d7b3dSmrg * 315428d7b3dSmrg * Notes on interpreting Picture structures: 316428d7b3dSmrg * - The Picture structures will always have a valid pDrawable. 317428d7b3dSmrg * - The Picture structures will never have alphaMap set. 318428d7b3dSmrg * - The mask Picture (and therefore pMask) may be NULL, in which case 319428d7b3dSmrg * the operation is simply src OP dst instead of src IN mask OP dst, 320428d7b3dSmrg * and mask coordinates should be ignored. 321428d7b3dSmrg * - pMarkPicture may have componentAlpha set, which greatly changes 322428d7b3dSmrg * the behavior of the composite operation. componentAlpha has no 323428d7b3dSmrg * effect when set on pSrcPicture or pDstPicture. 324428d7b3dSmrg * - The source and mask Pictures may have a transformation set 325428d7b3dSmrg * (Picture->transform != NULL), which means that the source 326428d7b3dSmrg * coordinates should be transformed by that transformation, 327428d7b3dSmrg * resulting in scaling, rotation, etc. The PictureTransformPoint() 328428d7b3dSmrg * call can transform coordinates for you. Transforms have no 329428d7b3dSmrg * effect on Pictures when used as a destination. 330428d7b3dSmrg * - The source and mask pictures may have a filter set. 331428d7b3dSmrg * PictFilterNearest and PictFilterBilinear are defined in the 332428d7b3dSmrg * Render protocol, but others may be encountered, and must be 333428d7b3dSmrg * handled correctly (usually by prepare_composite failing, and 334428d7b3dSmrg * falling back to software). Filters have 335428d7b3dSmrg * no effect on Pictures when used as a destination. 336428d7b3dSmrg * - The source and mask Pictures may have repeating set, which must be 337428d7b3dSmrg * respected. Many chipsets will be unable to support repeating on 338428d7b3dSmrg * pixmaps that have a width or height that is not a power of two. 339428d7b3dSmrg * 340428d7b3dSmrg * If your hardware can't support source pictures (textures) with 341428d7b3dSmrg * non-power-of-two pitches, you should set #UXA_OFFSCREEN_ALIGN_POT. 342428d7b3dSmrg * 343428d7b3dSmrg * Note that many drivers will need to store some of the data in the 344428d7b3dSmrg * driver private record, for sending to the hardware with each 345428d7b3dSmrg * drawing command. 346428d7b3dSmrg * 347428d7b3dSmrg * The prepare_composite() call is not required. However, it is highly 348428d7b3dSmrg * recommended for performance of antialiased font rendering and 349428d7b3dSmrg * performance of cairo applications. Failure results in a fallback 350428d7b3dSmrg * to software rendering. 351428d7b3dSmrg */ 352428d7b3dSmrg Bool(*prepare_composite) (int op, 353428d7b3dSmrg PicturePtr pSrcPicture, 354428d7b3dSmrg PicturePtr pMaskPicture, 355428d7b3dSmrg PicturePtr pDstPicture, 356428d7b3dSmrg PixmapPtr pSrc, 357428d7b3dSmrg PixmapPtr pMask, PixmapPtr pDst); 358428d7b3dSmrg 359428d7b3dSmrg /** 360428d7b3dSmrg * composite() performs a composite operation set up in the last 361428d7b3dSmrg * prepare_composite() call. 362428d7b3dSmrg * 363428d7b3dSmrg * @param pDstPixmap destination pixmap 364428d7b3dSmrg * @param srcX source X coordinate 365428d7b3dSmrg * @param srcY source Y coordinate 366428d7b3dSmrg * @param maskX source X coordinate 367428d7b3dSmrg * @param maskY source Y coordinate 368428d7b3dSmrg * @param dstX destination X coordinate 369428d7b3dSmrg * @param dstY destination Y coordinate 370428d7b3dSmrg * @param width destination rectangle width 371428d7b3dSmrg * @param height destination rectangle height 372428d7b3dSmrg * 373428d7b3dSmrg * Performs the composite operation set up by the last 374428d7b3dSmrg * prepare_composite() call, to the rectangle from (dstX, dstY) to 375428d7b3dSmrg * (dstX + width, dstY + height) in the destination Pixmap. Note that 376428d7b3dSmrg * if a transformation was set on the source or mask Pictures, the 377428d7b3dSmrg * source rectangles may not be the same size as the destination 378428d7b3dSmrg * rectangles and filtering. Getting the coordinate transformation 379428d7b3dSmrg * right at the subpixel level can be tricky, and rendercheck 380428d7b3dSmrg * can test this for you. 381428d7b3dSmrg * 382428d7b3dSmrg * This call is required if prepare_composite() ever succeeds. 383428d7b3dSmrg */ 384428d7b3dSmrg void (*composite) (PixmapPtr pDst, 385428d7b3dSmrg int srcX, 386428d7b3dSmrg int srcY, 387428d7b3dSmrg int maskX, 388428d7b3dSmrg int maskY, 389428d7b3dSmrg int dstX, int dstY, int width, int height); 390428d7b3dSmrg 391428d7b3dSmrg /** 392428d7b3dSmrg * done_composite() finishes a set of composite operations. 393428d7b3dSmrg * 394428d7b3dSmrg * @param pPixmap destination pixmap. 395428d7b3dSmrg * 396428d7b3dSmrg * The done_composite() call is called at the end of a series of 397428d7b3dSmrg * consecutive composite() calls following a successful 398428d7b3dSmrg * prepare_composite(). This allows drivers to finish up emitting 399428d7b3dSmrg * drawing commands that were buffered, or clean up state from 400428d7b3dSmrg * prepare_composite(). 401428d7b3dSmrg * 402428d7b3dSmrg * This call is required if prepare_composite() ever succeeds. 403428d7b3dSmrg */ 404428d7b3dSmrg void (*done_composite) (PixmapPtr pDst); 405428d7b3dSmrg /** @} */ 406428d7b3dSmrg 407428d7b3dSmrg /** 408428d7b3dSmrg * put_image() loads a rectangle of data from src into pDst. 409428d7b3dSmrg * 410428d7b3dSmrg * @param pDst destination pixmap 411428d7b3dSmrg * @param x destination X coordinate. 412428d7b3dSmrg * @param y destination Y coordinate 413428d7b3dSmrg * @param width width of the rectangle to be copied 414428d7b3dSmrg * @param height height of the rectangle to be copied 415428d7b3dSmrg * @param src pointer to the beginning of the source data 416428d7b3dSmrg * @param src_pitch pitch (in bytes) of the lines of source data. 417428d7b3dSmrg * 418428d7b3dSmrg * put_image() copies data in system memory beginning at src (with 419428d7b3dSmrg * pitch src_pitch) into the destination pixmap from (x, y) to 420428d7b3dSmrg * (x + width, y + height). This is typically done with hostdata 421428d7b3dSmrg * uploads, where the CPU sets up a blit command on the hardware with 422428d7b3dSmrg * instructions that the blit data will be fed through some sort of 423428d7b3dSmrg * aperture on the card. 424428d7b3dSmrg * 425428d7b3dSmrg * put_image() is most important for the performance of uxa_glyphs() 426428d7b3dSmrg * (antialiased font drawing) by allowing pipelining of data uploads, 427428d7b3dSmrg * avoiding a sync of the card after each glyph. 428428d7b3dSmrg * 429428d7b3dSmrg * @return TRUE if the driver successfully uploaded the data. FALSE 430428d7b3dSmrg * indicates that UXA should fall back to doing the upload in software. 431428d7b3dSmrg * 432428d7b3dSmrg * put_image() is not required, but is recommended if composite 433428d7b3dSmrg * acceleration is supported. 434428d7b3dSmrg */ 435428d7b3dSmrg Bool(*put_image) (PixmapPtr pDst, 436428d7b3dSmrg int x, 437428d7b3dSmrg int y, int w, int h, char *src, int src_pitch); 438428d7b3dSmrg 439428d7b3dSmrg /** 440428d7b3dSmrg * get_image() loads a rectangle of data from pSrc into dst 441428d7b3dSmrg * 442428d7b3dSmrg * @param pSrc source pixmap 443428d7b3dSmrg * @param x source X coordinate. 444428d7b3dSmrg * @param y source Y coordinate 445428d7b3dSmrg * @param width width of the rectangle to be copied 446428d7b3dSmrg * @param height height of the rectangle to be copied 447428d7b3dSmrg * @param dst pointer to the beginning of the destination data 448428d7b3dSmrg * @param dst_pitch pitch (in bytes) of the lines of destination data. 449428d7b3dSmrg * 450428d7b3dSmrg * get_image() copies data from offscreen memory in pSrc from 451428d7b3dSmrg * (x, y) to (x + width, y + height), to system memory starting at 452428d7b3dSmrg * dst (with pitch dst_pitch). This would usually be done 453428d7b3dSmrg * using scatter-gather DMA, supported by a DRM call, or by blitting 454428d7b3dSmrg * to AGP and then synchronously reading from AGP. 455428d7b3dSmrg * 456428d7b3dSmrg * @return TRUE if the driver successfully downloaded the data. FALSE 457428d7b3dSmrg * indicates that UXA should fall back to doing the download in 458428d7b3dSmrg * software. 459428d7b3dSmrg * 460428d7b3dSmrg * get_image() is not required, but is highly recommended. 461428d7b3dSmrg */ 462428d7b3dSmrg Bool(*get_image) (PixmapPtr pSrc, 463428d7b3dSmrg int x, int y, 464428d7b3dSmrg int w, int h, char *dst, int dst_pitch); 465428d7b3dSmrg 466428d7b3dSmrg /** @{ */ 467428d7b3dSmrg /** 468428d7b3dSmrg * prepare_access() is called before CPU access to an offscreen pixmap. 469428d7b3dSmrg * 470428d7b3dSmrg * @param pPix the pixmap being accessed 471428d7b3dSmrg * @param index the index of the pixmap being accessed. 472428d7b3dSmrg * 473428d7b3dSmrg * prepare_access() will be called before CPU access to an offscreen 474428d7b3dSmrg * pixmap. 475428d7b3dSmrg * 476428d7b3dSmrg * This can be used to set up hardware surfaces for byteswapping or 477428d7b3dSmrg * untiling, or to adjust the pixmap's devPrivate.ptr for the purpose of 478428d7b3dSmrg * making CPU access use a different aperture. 479428d7b3dSmrg * 480428d7b3dSmrg * The index is one of #UXA_PREPARE_DEST, #UXA_PREPARE_SRC, or 481428d7b3dSmrg * #UXA_PREPARE_MASK, indicating which pixmap is in question. Since 482428d7b3dSmrg * only up to three pixmaps will have prepare_access() called on them 483428d7b3dSmrg * per operation, drivers can have a small, statically-allocated space 484428d7b3dSmrg * to maintain state for prepare_access() and finish_access() in. 485428d7b3dSmrg * Note that the same pixmap may have prepare_access() called on it 486428d7b3dSmrg * more than once, for uxample when doing a copy within the same 487428d7b3dSmrg * pixmap (so it gets prepare_access as 488428d7b3dSmrg * #UXA_PREPARE_DEST and then as #UXA_PREPARE_SRC). 489428d7b3dSmrg * 490428d7b3dSmrg * prepare_access() may fail. An example might be the case of 491428d7b3dSmrg * hardware that can set up 1 or 2 surfaces for CPU access, but not 492428d7b3dSmrg * 3. If prepare_access() 493428d7b3dSmrg * fails, UXA will migrate the pixmap to system memory. 494428d7b3dSmrg * get_image() must be implemented and must not fail if a driver 495428d7b3dSmrg * wishes to fail in prepare_access(). prepare_access() must not 496428d7b3dSmrg * fail when pPix is the visible screen, because the visible screen 497428d7b3dSmrg * can not be migrated. 498428d7b3dSmrg * 499428d7b3dSmrg * @return TRUE if prepare_access() successfully prepared the pixmap 500428d7b3dSmrg * for CPU drawing. 501428d7b3dSmrg * @return FALSE if prepare_access() is unsuccessful and UXA should use 502428d7b3dSmrg * get_image() to migate the pixmap out. 503428d7b3dSmrg */ 504428d7b3dSmrg Bool(*prepare_access) (PixmapPtr pPix, uxa_access_t access); 505428d7b3dSmrg 506428d7b3dSmrg /** 507428d7b3dSmrg * finish_access() is called after CPU access to an offscreen pixmap. 508428d7b3dSmrg * 509428d7b3dSmrg * @param pPix the pixmap being accessed 510428d7b3dSmrg * @param index the index of the pixmap being accessed. 511428d7b3dSmrg * 512428d7b3dSmrg * finish_access() will be called after finishing CPU access of an 513428d7b3dSmrg * offscreen pixmap set up by prepare_access(). Note that the 514428d7b3dSmrg * finish_access() will not be called if prepare_access() failed. 515428d7b3dSmrg */ 516428d7b3dSmrg void (*finish_access) (PixmapPtr pPix, uxa_access_t access); 517428d7b3dSmrg 518428d7b3dSmrg /** 519428d7b3dSmrg * PixmapIsOffscreen() is an optional driver replacement to 520428d7b3dSmrg * uxa_pixmap_is_offscreen(). Set to NULL if you want the standard 521428d7b3dSmrg * behaviour of uxa_pixmap_is_offscreen(). 522428d7b3dSmrg * 523428d7b3dSmrg * @param pPix the pixmap 524428d7b3dSmrg * @return TRUE if the given drawable is in framebuffer memory. 525428d7b3dSmrg * 526428d7b3dSmrg * uxa_pixmap_is_offscreen() is used to determine if a pixmap is in 527428d7b3dSmrg * offscreen memory, meaning that acceleration could probably be done 528428d7b3dSmrg * to it, and that it will need to be wrapped by 529428d7b3dSmrg * prepare_access()/finish_access() when accessing it with the CPU. 530428d7b3dSmrg */ 531428d7b3dSmrg Bool(*pixmap_is_offscreen) (PixmapPtr pPix); 532428d7b3dSmrg 533428d7b3dSmrg /** @} */ 534428d7b3dSmrg} uxa_driver_t; 535428d7b3dSmrg 536428d7b3dSmrg/** @name UXA driver flags 537428d7b3dSmrg * @{ 538428d7b3dSmrg */ 539428d7b3dSmrg/** 540428d7b3dSmrg * UXA_TWO_BITBLT_DIRECTIONS indicates to UXA that the driver can only 541428d7b3dSmrg * support copies that are (left-to-right, top-to-bottom) or 542428d7b3dSmrg * (right-to-left, bottom-to-top). 543428d7b3dSmrg */ 544428d7b3dSmrg#define UXA_TWO_BITBLT_DIRECTIONS (1 << 2) 545428d7b3dSmrg 546428d7b3dSmrg/** @} */ 547428d7b3dSmrg/** @name UXA CreatePixmap hint flags 548428d7b3dSmrg * @{ 549428d7b3dSmrg */ 550428d7b3dSmrg/** 551428d7b3dSmrg * Flag to hint that the first operation on the pixmap will be a 552428d7b3dSmrg * prepare_access. 553428d7b3dSmrg */ 554428d7b3dSmrg#define UXA_CREATE_PIXMAP_FOR_MAP 0x20000000 555428d7b3dSmrg/** @} */ 556428d7b3dSmrg 557428d7b3dSmrguxa_driver_t *uxa_driver_alloc(void); 558428d7b3dSmrg 559428d7b3dSmrgBool uxa_driver_init(ScreenPtr screen, uxa_driver_t * uxa_driver); 560428d7b3dSmrgBool uxa_resources_init(ScreenPtr screen); 561428d7b3dSmrg 562428d7b3dSmrgvoid uxa_driver_fini(ScreenPtr pScreen); 563428d7b3dSmrg 564428d7b3dSmrgCARD32 uxa_get_pixmap_first_pixel(PixmapPtr pPixmap); 565428d7b3dSmrg 566428d7b3dSmrgBool 567428d7b3dSmrguxa_get_color_for_pixmap (PixmapPtr pixmap, 568428d7b3dSmrg CARD32 src_format, 569428d7b3dSmrg CARD32 dst_format, 570428d7b3dSmrg CARD32 *pixel); 571428d7b3dSmrg 572428d7b3dSmrgvoid uxa_set_fallback_debug(ScreenPtr screen, Bool enable); 573428d7b3dSmrgvoid uxa_set_force_fallback(ScreenPtr screen, Bool enable); 574428d7b3dSmrg 575428d7b3dSmrg/** 576428d7b3dSmrg * Returns TRUE if the given planemask covers all the significant bits in the 577428d7b3dSmrg * pixel values for pDrawable. 578428d7b3dSmrg */ 579428d7b3dSmrg#define UXA_PM_IS_SOLID(_pDrawable, _pm) \ 580428d7b3dSmrg (((_pm) & FbFullMask((_pDrawable)->depth)) == \ 581428d7b3dSmrg FbFullMask((_pDrawable)->depth)) 582428d7b3dSmrg 583428d7b3dSmrg#endif /* UXA_H */ 584