1d514b0f3Smrg/* 2d514b0f3Smrg * Copyright © 2000, 2008 Keith Packard 3d514b0f3Smrg * 2004 Eric Anholt 4d514b0f3Smrg * 2005 Zack Rusin 5d514b0f3Smrg * 6d514b0f3Smrg * Permission to use, copy, modify, distribute, and sell this software and its 7d514b0f3Smrg * documentation for any purpose is hereby granted without fee, provided that 8d514b0f3Smrg * the above copyright notice appear in all copies and that both that 9d514b0f3Smrg * copyright notice and this permission notice appear in supporting 10d514b0f3Smrg * documentation, and that the name of copyright holders not be used in 11d514b0f3Smrg * advertising or publicity pertaining to distribution of the software without 12d514b0f3Smrg * specific, written prior permission. Copyright holders make no 13d514b0f3Smrg * representations about the suitability of this software for any purpose. It 14d514b0f3Smrg * is provided "as is" without express or implied warranty. 15d514b0f3Smrg * 16d514b0f3Smrg * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 17d514b0f3Smrg * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 18d514b0f3Smrg * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY 19d514b0f3Smrg * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 20d514b0f3Smrg * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 21d514b0f3Smrg * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 22d514b0f3Smrg * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 23d514b0f3Smrg * SOFTWARE. 24d514b0f3Smrg */ 25d514b0f3Smrg 26d514b0f3Smrg/** @file 27d514b0f3Smrg * UXA - the unified memory acceleration architecture. 28d514b0f3Smrg * 29d514b0f3Smrg * This is the header containing the public API of UXA for uxa drivers. 30d514b0f3Smrg */ 31d514b0f3Smrg 32d514b0f3Smrg#ifndef UXA_H 33d514b0f3Smrg#define UXA_H 34d514b0f3Smrg 35d514b0f3Smrg#include "scrnintstr.h" 36d514b0f3Smrg#include "pixmapstr.h" 37d514b0f3Smrg#include "windowstr.h" 38d514b0f3Smrg#include "gcstruct.h" 39d514b0f3Smrg#include "picturestr.h" 40d514b0f3Smrg#include "fb.h" 41d514b0f3Smrg 42d514b0f3Smrg#define UXA_VERSION_MAJOR 1 43d514b0f3Smrg#define UXA_VERSION_MINOR 0 44d514b0f3Smrg#define UXA_VERSION_RELEASE 0 45d514b0f3Smrg 46d514b0f3Smrgtypedef enum { 47d514b0f3Smrg UXA_ACCESS_RO, 48d514b0f3Smrg UXA_ACCESS_RW 49d514b0f3Smrg} uxa_access_t; 50d514b0f3Smrg 51d514b0f3Smrg/** 52d514b0f3Smrg * The UxaDriver structure is allocated through uxa_driver_alloc(), and then 53d514b0f3Smrg * fllled in by drivers. 54d514b0f3Smrg */ 55d514b0f3Smrgtypedef struct _UxaDriver { 56d514b0f3Smrg /** 57d514b0f3Smrg * uxa_major and uxa_minor should be set by the driver to the version of 58d514b0f3Smrg * UXA which the driver was compiled for (or configures itself at 59d514b0f3Smrg * runtime to support). This allows UXA to extend the structure for 60d514b0f3Smrg * new features without breaking ABI for drivers compiled against 61d514b0f3Smrg * older versions. 62d514b0f3Smrg */ 63d514b0f3Smrg int uxa_major, uxa_minor; 64d514b0f3Smrg 65d514b0f3Smrg /** 66d514b0f3Smrg * The flags field is bitfield of boolean values controlling UXA's 67d514b0f3Smrg * behavior. 68d514b0f3Smrg * 69d514b0f3Smrg * The flags include UXA_TWO_BITBLT_DIRECTIONS. 70d514b0f3Smrg */ 71d514b0f3Smrg int flags; 72d514b0f3Smrg 73d514b0f3Smrg /** @name solid 74d514b0f3Smrg * @{ 75d514b0f3Smrg */ 76d514b0f3Smrg /** 77d514b0f3Smrg * check_solid() checks whether the driver can do a solid fill to this drawable. 78d514b0f3Smrg * @param pDrawable Destination drawable 79d514b0f3Smrg * @param alu raster operation 80d514b0f3Smrg * @param planemask write mask for the fill 81d514b0f3Smrg * 82d514b0f3Smrg * The check_solid() call is recommended if prepare_solid() is 83d514b0f3Smrg * implemented, but is not required. 84d514b0f3Smrg */ 85d514b0f3Smrg Bool(*check_solid) (DrawablePtr pDrawable, int alu, Pixel planemask); 86d514b0f3Smrg 87d514b0f3Smrg /** 88d514b0f3Smrg * prepare_solid() sets up the driver for doing a solid fill. 89d514b0f3Smrg * @param pPixmap Destination pixmap 90d514b0f3Smrg * @param alu raster operation 91d514b0f3Smrg * @param planemask write mask for the fill 92d514b0f3Smrg * @param fg "foreground" color for the fill 93d514b0f3Smrg * 94d514b0f3Smrg * This call should set up the driver for doing a series of solid fills 95d514b0f3Smrg * through the solid() call. The alu raster op is one of the GX* 96d514b0f3Smrg * graphics functions listed in X.h, and typically maps to a similar 97d514b0f3Smrg * single-byte "ROP" setting in all hardware. The planemask controls 98d514b0f3Smrg * which bits of the destination should be affected, and will only 99d514b0f3Smrg * represent the bits up to the depth of pPixmap. The fg is the pixel 100d514b0f3Smrg * value of the foreground color referred to in ROP descriptions. 101d514b0f3Smrg * 102d514b0f3Smrg * Note that many drivers will need to store some of the data in the 103d514b0f3Smrg * driver private record, for sending to the hardware with each 104d514b0f3Smrg * drawing command. 105d514b0f3Smrg * 106d514b0f3Smrg * The prepare_solid() call is required of all drivers, but it may fail 107d514b0f3Smrg * for any reason. Failure results in a fallback to software rendering. 108d514b0f3Smrg */ 109d514b0f3Smrg Bool(*prepare_solid) (PixmapPtr pPixmap, 110d514b0f3Smrg int alu, Pixel planemask, Pixel fg); 111d514b0f3Smrg 112d514b0f3Smrg /** 113d514b0f3Smrg * solid() performs a solid fill set up in the last prepare_solid() 114d514b0f3Smrg * call. 115d514b0f3Smrg * 116d514b0f3Smrg * @param pPixmap destination pixmap 117d514b0f3Smrg * @param x1 left coordinate 118d514b0f3Smrg * @param y1 top coordinate 119d514b0f3Smrg * @param x2 right coordinate 120d514b0f3Smrg * @param y2 bottom coordinate 121d514b0f3Smrg * 122d514b0f3Smrg * Performs the fill set up by the last prepare_solid() call, 123d514b0f3Smrg * covering the area from (x1,y1) to (x2,y2) in pPixmap. Note that 124d514b0f3Smrg * the coordinates are in the coordinate space of the destination 125d514b0f3Smrg * pixmap, so the driver will need to set up the hardware's offset 126d514b0f3Smrg * and pitch for the destination coordinates according to the pixmap's 127d514b0f3Smrg * offset and pitch within framebuffer. 128d514b0f3Smrg * 129d514b0f3Smrg * This call is required if prepare_solid() ever succeeds. 130d514b0f3Smrg */ 131d514b0f3Smrg void (*solid) (PixmapPtr pPixmap, int x1, int y1, int x2, int y2); 132d514b0f3Smrg 133d514b0f3Smrg /** 134d514b0f3Smrg * done_solid() finishes a set of solid fills. 135d514b0f3Smrg * 136d514b0f3Smrg * @param pPixmap destination pixmap. 137d514b0f3Smrg * 138d514b0f3Smrg * The done_solid() call is called at the end of a series of consecutive 139d514b0f3Smrg * solid() calls following a successful prepare_solid(). This allows 140d514b0f3Smrg * drivers to finish up emitting drawing commands that were buffered, or 141d514b0f3Smrg * clean up state from prepare_solid(). 142d514b0f3Smrg * 143d514b0f3Smrg * This call is required if prepare_solid() ever succeeds. 144d514b0f3Smrg */ 145d514b0f3Smrg void (*done_solid) (PixmapPtr pPixmap); 146d514b0f3Smrg /** @} */ 147d514b0f3Smrg 148d514b0f3Smrg /** @name copy 149d514b0f3Smrg * @{ 150d514b0f3Smrg */ 151d514b0f3Smrg /** 152d514b0f3Smrg * check_copy() checks whether the driver can blit between the two Pictures 153d514b0f3Smrg */ 154d514b0f3Smrg Bool(*check_copy) (PixmapPtr pSrc, PixmapPtr pDst, int alu, Pixel planemask); 155d514b0f3Smrg /** 156d514b0f3Smrg * prepare_copy() sets up the driver for doing a copy within video 157d514b0f3Smrg * memory. 158d514b0f3Smrg - * 159d514b0f3Smrg * @param pSrcPixmap source pixmap 160d514b0f3Smrg * @param pDstPixmap destination pixmap 161d514b0f3Smrg * @param dx X copy direction 162d514b0f3Smrg * @param dy Y copy direction 163d514b0f3Smrg * @param alu raster operation 164d514b0f3Smrg * @param planemask write mask for the fill 165d514b0f3Smrg * 166d514b0f3Smrg * This call should set up the driver for doing a series of copies 167d514b0f3Smrg * from the pSrcPixmap to the pDstPixmap. The dx flag will be 168d514b0f3Smrg * positive if the 169d514b0f3Smrg * hardware should do the copy from the left to the right, and dy will 170d514b0f3Smrg * be positive if the copy should be done from the top to the bottom. 171d514b0f3Smrg * This is to deal with self-overlapping copies when 172d514b0f3Smrg * pSrcPixmap == pDstPixmap. 173d514b0f3Smrg * 174d514b0f3Smrg * If your hardware can only support blits that are (left to right, 175d514b0f3Smrg * top to bottom) or (right to left, bottom to top), then you should 176d514b0f3Smrg * set #UXA_TWO_BITBLT_DIRECTIONS, and UXA will break down copy 177d514b0f3Smrg * operations to ones that meet those requirements. The alu raster 178d514b0f3Smrg * op is one of the GX* graphics functions listed in X.h, and 179d514b0f3Smrg * typically maps to a similar single-byte "ROP" setting in all 180d514b0f3Smrg * hardware. The planemask controls which bits of the destination 181d514b0f3Smrg * should be affected, and will only represent the bits up to the 182d514b0f3Smrg * depth of pPixmap. 183d514b0f3Smrg * 184d514b0f3Smrg * Note that many drivers will need to store some of the data in the 185d514b0f3Smrg * driver private record, for sending to the hardware with each 186d514b0f3Smrg * drawing command. 187d514b0f3Smrg * 188d514b0f3Smrg * The prepare_copy() call is required of all drivers, but it may fail 189d514b0f3Smrg * for any reason. Failure results in a fallback to software rendering. 190d514b0f3Smrg */ 191d514b0f3Smrg Bool(*prepare_copy) (PixmapPtr pSrcPixmap, 192d514b0f3Smrg PixmapPtr pDstPixmap, 193d514b0f3Smrg int dx, int dy, int alu, Pixel planemask); 194d514b0f3Smrg 195d514b0f3Smrg /** 196d514b0f3Smrg * copy() performs a copy set up in the last prepare_copy call. 197d514b0f3Smrg * 198d514b0f3Smrg * @param pDstPixmap destination pixmap 199d514b0f3Smrg * @param srcX source X coordinate 200d514b0f3Smrg * @param srcY source Y coordinate 201d514b0f3Smrg * @param dstX destination X coordinate 202d514b0f3Smrg * @param dstY destination Y coordinate 203d514b0f3Smrg * @param width width of the rectangle to be copied 204d514b0f3Smrg * @param height height of the rectangle to be copied. 205d514b0f3Smrg * 206d514b0f3Smrg * Performs the copy set up by the last prepare_copy() call, copying the 207d514b0f3Smrg * rectangle from (srcX, srcY) to (srcX + width, srcY + width) in the 208d514b0f3Smrg * source pixmap to the same-sized rectangle at (dstX, dstY) in the 209d514b0f3Smrg * destination pixmap. Those rectangles may overlap in memory, if 210d514b0f3Smrg * pSrcPixmap == pDstPixmap. Note that this call does not receive the 211d514b0f3Smrg * pSrcPixmap as an argument -- if it's needed in this function, it 212d514b0f3Smrg * should be stored in the driver private during prepare_copy(). As 213d514b0f3Smrg * with solid(), the coordinates are in the coordinate space of each 214d514b0f3Smrg * pixmap, so the driver will need to set up source and destination 215d514b0f3Smrg * pitches and offsets from those pixmaps, probably using 216d514b0f3Smrg * uxaGetPixmapOffset() and uxa_get_pixmap_pitch(). 217d514b0f3Smrg * 218d514b0f3Smrg * This call is required if prepare_copy ever succeeds. 219d514b0f3Smrg */ 220d514b0f3Smrg void (*copy) (PixmapPtr pDstPixmap, 221d514b0f3Smrg int srcX, 222d514b0f3Smrg int srcY, int dstX, int dstY, int width, int height); 223d514b0f3Smrg 224d514b0f3Smrg /** 225d514b0f3Smrg * done_copy() finishes a set of copies. 226d514b0f3Smrg * 227d514b0f3Smrg * @param pPixmap destination pixmap. 228d514b0f3Smrg * 229d514b0f3Smrg * The done_copy() call is called at the end of a series of consecutive 230d514b0f3Smrg * copy() calls following a successful prepare_copy(). This allows 231d514b0f3Smrg * drivers to finish up emitting drawing commands that were buffered, 232d514b0f3Smrg * or clean up state from prepare_copy(). 233d514b0f3Smrg * 234d514b0f3Smrg * This call is required if prepare_copy() ever succeeds. 235d514b0f3Smrg */ 236d514b0f3Smrg void (*done_copy) (PixmapPtr pDstPixmap); 237d514b0f3Smrg /** @} */ 238d514b0f3Smrg 239d514b0f3Smrg /** @name composite 240d514b0f3Smrg * @{ 241d514b0f3Smrg */ 242d514b0f3Smrg /** 243d514b0f3Smrg * check_composite() checks to see if a composite operation could be 244d514b0f3Smrg * accelerated. 245d514b0f3Smrg * 246d514b0f3Smrg * @param op Render operation 247d514b0f3Smrg * @param pSrcPicture source Picture 248d514b0f3Smrg * @param pMaskPicture mask picture 249d514b0f3Smrg * @param pDstPicture destination Picture 250d514b0f3Smrg * @param width The width of the composite operation 251d514b0f3Smrg * @param height The height of the composite operation 252d514b0f3Smrg * 253d514b0f3Smrg * The check_composite() call checks if the driver could handle 254d514b0f3Smrg * acceleration of op with the given source, mask, and destination 255d514b0f3Smrg * pictures. This allows drivers to check source and destination 256d514b0f3Smrg * formats, supported operations, transformations, and component 257d514b0f3Smrg * alpha state, and send operations it can't support to software 258d514b0f3Smrg * rendering early on. 259d514b0f3Smrg * 260d514b0f3Smrg * See prepare_composite() for more details on likely issues that 261d514b0f3Smrg * drivers will have in accelerating composite operations. 262d514b0f3Smrg * 263d514b0f3Smrg * The check_composite() call is recommended if prepare_composite() is 264d514b0f3Smrg * implemented, but is not required. 265d514b0f3Smrg */ 266d514b0f3Smrg Bool(*check_composite) (int op, 267d514b0f3Smrg PicturePtr pSrcPicture, 268d514b0f3Smrg PicturePtr pMaskPicture, 269d514b0f3Smrg PicturePtr pDstPicture, 270d514b0f3Smrg int width, int height); 271d514b0f3Smrg 272d514b0f3Smrg /** 273d514b0f3Smrg * check_composite_target() checks to see if the destination of the composite 274d514b0f3Smrg * operation can be used without midification. 275d514b0f3Smrg * 276d514b0f3Smrg * @param pixmap Destination Pixmap 277d514b0f3Smrg * 278d514b0f3Smrg * The check_composite_target() call is recommended if prepare_composite() is 279d514b0f3Smrg * implemented, but is not required. 280d514b0f3Smrg */ 281d514b0f3Smrg Bool(*check_composite_target) (PixmapPtr pixmap); 282d514b0f3Smrg 283d514b0f3Smrg /** 284d514b0f3Smrg * check_composite_texture() checks to see if a source to the composite 285d514b0f3Smrg * operation can be used without midification. 286d514b0f3Smrg * 287d514b0f3Smrg * @param pScreen Screen 288d514b0f3Smrg * @param pPicture Picture 289d514b0f3Smrg * 290d514b0f3Smrg * The check_composite_texture() call is recommended if prepare_composite() is 291d514b0f3Smrg * implemented, but is not required. 292d514b0f3Smrg */ 293d514b0f3Smrg Bool(*check_composite_texture) (ScreenPtr pScreen, 294d514b0f3Smrg PicturePtr pPicture); 295d514b0f3Smrg 296d514b0f3Smrg /** 297d514b0f3Smrg * prepare_composite() sets up the driver for doing a composite 298d514b0f3Smrg * operation described in the Render extension protocol spec. 299d514b0f3Smrg * 300d514b0f3Smrg * @param op Render operation 301d514b0f3Smrg * @param pSrcPicture source Picture 302d514b0f3Smrg * @param pMaskPicture mask picture 303d514b0f3Smrg * @param pDstPicture destination Picture 304d514b0f3Smrg * @param pSrc source pixmap 305d514b0f3Smrg * @param pMask mask pixmap 306d514b0f3Smrg * @param pDst destination pixmap 307d514b0f3Smrg * 308d514b0f3Smrg * This call should set up the driver for doing a series of composite 309d514b0f3Smrg * operations, as described in the Render protocol spec, with the given 310d514b0f3Smrg * pSrcPicture, pMaskPicture, and pDstPicture. The pSrc, pMask, and 311d514b0f3Smrg * pDst are the pixmaps containing the pixel data, and should be used 312d514b0f3Smrg * for setting the offset and pitch used for the coordinate spaces for 313d514b0f3Smrg * each of the Pictures. 314d514b0f3Smrg * 315d514b0f3Smrg * Notes on interpreting Picture structures: 316d514b0f3Smrg * - The Picture structures will always have a valid pDrawable. 317d514b0f3Smrg * - The Picture structures will never have alphaMap set. 318d514b0f3Smrg * - The mask Picture (and therefore pMask) may be NULL, in which case 319d514b0f3Smrg * the operation is simply src OP dst instead of src IN mask OP dst, 320d514b0f3Smrg * and mask coordinates should be ignored. 321d514b0f3Smrg * - pMarkPicture may have componentAlpha set, which greatly changes 322d514b0f3Smrg * the behavior of the composite operation. componentAlpha has no 323d514b0f3Smrg * effect when set on pSrcPicture or pDstPicture. 324d514b0f3Smrg * - The source and mask Pictures may have a transformation set 325d514b0f3Smrg * (Picture->transform != NULL), which means that the source 326d514b0f3Smrg * coordinates should be transformed by that transformation, 327d514b0f3Smrg * resulting in scaling, rotation, etc. The PictureTransformPoint() 328d514b0f3Smrg * call can transform coordinates for you. Transforms have no 329d514b0f3Smrg * effect on Pictures when used as a destination. 330d514b0f3Smrg * - The source and mask pictures may have a filter set. 331d514b0f3Smrg * PictFilterNearest and PictFilterBilinear are defined in the 332d514b0f3Smrg * Render protocol, but others may be encountered, and must be 333d514b0f3Smrg * handled correctly (usually by prepare_composite failing, and 334d514b0f3Smrg * falling back to software). Filters have 335d514b0f3Smrg * no effect on Pictures when used as a destination. 336d514b0f3Smrg * - The source and mask Pictures may have repeating set, which must be 337d514b0f3Smrg * respected. Many chipsets will be unable to support repeating on 338d514b0f3Smrg * pixmaps that have a width or height that is not a power of two. 339d514b0f3Smrg * 340d514b0f3Smrg * If your hardware can't support source pictures (textures) with 341d514b0f3Smrg * non-power-of-two pitches, you should set #UXA_OFFSCREEN_ALIGN_POT. 342d514b0f3Smrg * 343d514b0f3Smrg * Note that many drivers will need to store some of the data in the 344d514b0f3Smrg * driver private record, for sending to the hardware with each 345d514b0f3Smrg * drawing command. 346d514b0f3Smrg * 347d514b0f3Smrg * The prepare_composite() call is not required. However, it is highly 348d514b0f3Smrg * recommended for performance of antialiased font rendering and 349d514b0f3Smrg * performance of cairo applications. Failure results in a fallback 350d514b0f3Smrg * to software rendering. 351d514b0f3Smrg */ 352d514b0f3Smrg Bool(*prepare_composite) (int op, 353d514b0f3Smrg PicturePtr pSrcPicture, 354d514b0f3Smrg PicturePtr pMaskPicture, 355d514b0f3Smrg PicturePtr pDstPicture, 356d514b0f3Smrg PixmapPtr pSrc, 357d514b0f3Smrg PixmapPtr pMask, PixmapPtr pDst); 358d514b0f3Smrg 359d514b0f3Smrg /** 360d514b0f3Smrg * composite() performs a composite operation set up in the last 361d514b0f3Smrg * prepare_composite() call. 362d514b0f3Smrg * 363d514b0f3Smrg * @param pDstPixmap destination pixmap 364d514b0f3Smrg * @param srcX source X coordinate 365d514b0f3Smrg * @param srcY source Y coordinate 366d514b0f3Smrg * @param maskX source X coordinate 367d514b0f3Smrg * @param maskY source Y coordinate 368d514b0f3Smrg * @param dstX destination X coordinate 369d514b0f3Smrg * @param dstY destination Y coordinate 370d514b0f3Smrg * @param width destination rectangle width 371d514b0f3Smrg * @param height destination rectangle height 372d514b0f3Smrg * 373d514b0f3Smrg * Performs the composite operation set up by the last 374d514b0f3Smrg * prepare_composite() call, to the rectangle from (dstX, dstY) to 375d514b0f3Smrg * (dstX + width, dstY + height) in the destination Pixmap. Note that 376d514b0f3Smrg * if a transformation was set on the source or mask Pictures, the 377d514b0f3Smrg * source rectangles may not be the same size as the destination 378d514b0f3Smrg * rectangles and filtering. Getting the coordinate transformation 379d514b0f3Smrg * right at the subpixel level can be tricky, and rendercheck 380d514b0f3Smrg * can test this for you. 381d514b0f3Smrg * 382d514b0f3Smrg * This call is required if prepare_composite() ever succeeds. 383d514b0f3Smrg */ 384d514b0f3Smrg void (*composite) (PixmapPtr pDst, 385d514b0f3Smrg int srcX, 386d514b0f3Smrg int srcY, 387d514b0f3Smrg int maskX, 388d514b0f3Smrg int maskY, 389d514b0f3Smrg int dstX, int dstY, int width, int height); 390d514b0f3Smrg 391d514b0f3Smrg /** 392d514b0f3Smrg * done_composite() finishes a set of composite operations. 393d514b0f3Smrg * 394d514b0f3Smrg * @param pPixmap destination pixmap. 395d514b0f3Smrg * 396d514b0f3Smrg * The done_composite() call is called at the end of a series of 397d514b0f3Smrg * consecutive composite() calls following a successful 398d514b0f3Smrg * prepare_composite(). This allows drivers to finish up emitting 399d514b0f3Smrg * drawing commands that were buffered, or clean up state from 400d514b0f3Smrg * prepare_composite(). 401d514b0f3Smrg * 402d514b0f3Smrg * This call is required if prepare_composite() ever succeeds. 403d514b0f3Smrg */ 404d514b0f3Smrg void (*done_composite) (PixmapPtr pDst); 405d514b0f3Smrg /** @} */ 406d514b0f3Smrg 407d514b0f3Smrg /** 408d514b0f3Smrg * put_image() loads a rectangle of data from src into pDst. 409d514b0f3Smrg * 410d514b0f3Smrg * @param pDst destination pixmap 411d514b0f3Smrg * @param x destination X coordinate. 412d514b0f3Smrg * @param y destination Y coordinate 413d514b0f3Smrg * @param width width of the rectangle to be copied 414d514b0f3Smrg * @param height height of the rectangle to be copied 415d514b0f3Smrg * @param src pointer to the beginning of the source data 416d514b0f3Smrg * @param src_pitch pitch (in bytes) of the lines of source data. 417d514b0f3Smrg * 418d514b0f3Smrg * put_image() copies data in system memory beginning at src (with 419d514b0f3Smrg * pitch src_pitch) into the destination pixmap from (x, y) to 420d514b0f3Smrg * (x + width, y + height). This is typically done with hostdata 421d514b0f3Smrg * uploads, where the CPU sets up a blit command on the hardware with 422d514b0f3Smrg * instructions that the blit data will be fed through some sort of 423d514b0f3Smrg * aperture on the card. 424d514b0f3Smrg * 425d514b0f3Smrg * put_image() is most important for the performance of uxa_glyphs() 426d514b0f3Smrg * (antialiased font drawing) by allowing pipelining of data uploads, 427d514b0f3Smrg * avoiding a sync of the card after each glyph. 428d514b0f3Smrg * 429d514b0f3Smrg * @return TRUE if the driver successfully uploaded the data. FALSE 430d514b0f3Smrg * indicates that UXA should fall back to doing the upload in software. 431d514b0f3Smrg * 432d514b0f3Smrg * put_image() is not required, but is recommended if composite 433d514b0f3Smrg * acceleration is supported. 434d514b0f3Smrg */ 435d514b0f3Smrg Bool(*put_image) (PixmapPtr pDst, 436d514b0f3Smrg int x, 437d514b0f3Smrg int y, int w, int h, char *src, int src_pitch); 438d514b0f3Smrg 439d514b0f3Smrg /** 440d514b0f3Smrg * get_image() loads a rectangle of data from pSrc into dst 441d514b0f3Smrg * 442d514b0f3Smrg * @param pSrc source pixmap 443d514b0f3Smrg * @param x source X coordinate. 444d514b0f3Smrg * @param y source Y coordinate 445d514b0f3Smrg * @param width width of the rectangle to be copied 446d514b0f3Smrg * @param height height of the rectangle to be copied 447d514b0f3Smrg * @param dst pointer to the beginning of the destination data 448d514b0f3Smrg * @param dst_pitch pitch (in bytes) of the lines of destination data. 449d514b0f3Smrg * 450d514b0f3Smrg * get_image() copies data from offscreen memory in pSrc from 451d514b0f3Smrg * (x, y) to (x + width, y + height), to system memory starting at 452d514b0f3Smrg * dst (with pitch dst_pitch). This would usually be done 453d514b0f3Smrg * using scatter-gather DMA, supported by a DRM call, or by blitting 454d514b0f3Smrg * to AGP and then synchronously reading from AGP. 455d514b0f3Smrg * 456d514b0f3Smrg * @return TRUE if the driver successfully downloaded the data. FALSE 457d514b0f3Smrg * indicates that UXA should fall back to doing the download in 458d514b0f3Smrg * software. 459d514b0f3Smrg * 460d514b0f3Smrg * get_image() is not required, but is highly recommended. 461d514b0f3Smrg */ 462d514b0f3Smrg Bool(*get_image) (PixmapPtr pSrc, 463d514b0f3Smrg int x, int y, 464d514b0f3Smrg int w, int h, char *dst, int dst_pitch); 465d514b0f3Smrg 466d514b0f3Smrg /** @{ */ 467d514b0f3Smrg /** 468d514b0f3Smrg * prepare_access() is called before CPU access to an offscreen pixmap. 469d514b0f3Smrg * 470d514b0f3Smrg * @param pPix the pixmap being accessed 471d514b0f3Smrg * @param index the index of the pixmap being accessed. 472d514b0f3Smrg * 473d514b0f3Smrg * prepare_access() will be called before CPU access to an offscreen 474d514b0f3Smrg * pixmap. 475d514b0f3Smrg * 476d514b0f3Smrg * This can be used to set up hardware surfaces for byteswapping or 477d514b0f3Smrg * untiling, or to adjust the pixmap's devPrivate.ptr for the purpose of 478d514b0f3Smrg * making CPU access use a different aperture. 479d514b0f3Smrg * 480d514b0f3Smrg * The index is one of #UXA_PREPARE_DEST, #UXA_PREPARE_SRC, or 481d514b0f3Smrg * #UXA_PREPARE_MASK, indicating which pixmap is in question. Since 482d514b0f3Smrg * only up to three pixmaps will have prepare_access() called on them 483d514b0f3Smrg * per operation, drivers can have a small, statically-allocated space 484d514b0f3Smrg * to maintain state for prepare_access() and finish_access() in. 485d514b0f3Smrg * Note that the same pixmap may have prepare_access() called on it 486d514b0f3Smrg * more than once, for uxample when doing a copy within the same 487d514b0f3Smrg * pixmap (so it gets prepare_access as 488d514b0f3Smrg * #UXA_PREPARE_DEST and then as #UXA_PREPARE_SRC). 489d514b0f3Smrg * 490d514b0f3Smrg * prepare_access() may fail. An example might be the case of 491d514b0f3Smrg * hardware that can set up 1 or 2 surfaces for CPU access, but not 492d514b0f3Smrg * 3. If prepare_access() 493d514b0f3Smrg * fails, UXA will migrate the pixmap to system memory. 494d514b0f3Smrg * get_image() must be implemented and must not fail if a driver 495d514b0f3Smrg * wishes to fail in prepare_access(). prepare_access() must not 496d514b0f3Smrg * fail when pPix is the visible screen, because the visible screen 497d514b0f3Smrg * cannot be migrated. 498d514b0f3Smrg * 499d514b0f3Smrg * @return TRUE if prepare_access() successfully prepared the pixmap 500d514b0f3Smrg * for CPU drawing. 501d514b0f3Smrg * @return FALSE if prepare_access() is unsuccessful and UXA should use 502d514b0f3Smrg * get_image() to migate the pixmap out. 503d514b0f3Smrg */ 504d514b0f3Smrg Bool(*prepare_access) (PixmapPtr pPix, RegionPtr region, uxa_access_t access); 505d514b0f3Smrg 506d514b0f3Smrg /** 507d514b0f3Smrg * finish_access() is called after CPU access to an offscreen pixmap. 508d514b0f3Smrg * 509d514b0f3Smrg * @param pPix the pixmap being accessed 510d514b0f3Smrg * @param index the index of the pixmap being accessed. 511d514b0f3Smrg * 512d514b0f3Smrg * finish_access() will be called after finishing CPU access of an 513d514b0f3Smrg * offscreen pixmap set up by prepare_access(). Note that the 514d514b0f3Smrg * finish_access() will not be called if prepare_access() failed. 515d514b0f3Smrg */ 516d514b0f3Smrg void (*finish_access) (PixmapPtr pPix); 517d514b0f3Smrg 518d514b0f3Smrg /** 519d514b0f3Smrg * PixmapIsOffscreen() is an optional driver replacement to 520d514b0f3Smrg * uxa_pixmap_is_offscreen(). Set to NULL if you want the standard 521d514b0f3Smrg * behaviour of uxa_pixmap_is_offscreen(). 522d514b0f3Smrg * 523d514b0f3Smrg * @param pPix the pixmap 524d514b0f3Smrg * @return TRUE if the given drawable is in framebuffer memory. 525d514b0f3Smrg * 526d514b0f3Smrg * uxa_pixmap_is_offscreen() is used to determine if a pixmap is in 527d514b0f3Smrg * offscreen memory, meaning that acceleration could probably be done 528d514b0f3Smrg * to it, and that it will need to be wrapped by 529d514b0f3Smrg * prepare_access()/finish_access() when accessing it with the CPU. 530d514b0f3Smrg */ 531d514b0f3Smrg Bool(*pixmap_is_offscreen) (PixmapPtr pPix); 532d514b0f3Smrg 533d514b0f3Smrg /** @} */ 534d514b0f3Smrg} uxa_driver_t; 535d514b0f3Smrg 536d514b0f3Smrg/** @name UXA driver flags 537d514b0f3Smrg * @{ 538d514b0f3Smrg */ 539d514b0f3Smrg/** 540d514b0f3Smrg * UXA_TWO_BITBLT_DIRECTIONS indicates to UXA that the driver can only 541d514b0f3Smrg * support copies that are (left-to-right, top-to-bottom) or 542d514b0f3Smrg * (right-to-left, bottom-to-top). 543d514b0f3Smrg */ 544d514b0f3Smrg#define UXA_TWO_BITBLT_DIRECTIONS (1 << 2) 545d514b0f3Smrg 546d514b0f3Smrg/** @} */ 547d514b0f3Smrg 548d514b0f3Smrg/** @name UXA CreatePixmap hint flags 549d514b0f3Smrg * @{ 550d514b0f3Smrg */ 551d514b0f3Smrg/** 552d514b0f3Smrg * Flag to hint that the first operation on the pixmap will be a 553d514b0f3Smrg * prepare_access. 554d514b0f3Smrg */ 555d514b0f3Smrg#define UXA_CREATE_PIXMAP_FOR_MAP 0x20000000 556d514b0f3Smrg/** @} */ 557d514b0f3Smrg 558d514b0f3Smrguxa_driver_t *uxa_driver_alloc(void); 559d514b0f3Smrg 560d514b0f3SmrgBool uxa_driver_init(ScreenPtr screen, uxa_driver_t * uxa_driver); 561d514b0f3SmrgBool uxa_resources_init(ScreenPtr screen); 562d514b0f3Smrg 563d514b0f3Smrgvoid uxa_driver_fini(ScreenPtr pScreen); 564d514b0f3Smrg 565d514b0f3SmrgCARD32 uxa_get_pixmap_first_pixel(PixmapPtr pPixmap); 566d514b0f3Smrg 567d514b0f3SmrgBool 568d514b0f3Smrguxa_get_color_for_pixmap (PixmapPtr pixmap, 569d514b0f3Smrg CARD32 src_format, 570d514b0f3Smrg CARD32 dst_format, 571d514b0f3Smrg CARD32 *pixel); 572d514b0f3Smrg 573d514b0f3Smrgvoid uxa_set_fallback_debug(ScreenPtr screen, Bool enable); 574d514b0f3Smrgvoid uxa_set_force_fallback(ScreenPtr screen, Bool enable); 575d514b0f3SmrgBool uxa_swapped_out (ScreenPtr screen); 576d514b0f3Smrg 577d514b0f3Smrg/** 578d514b0f3Smrg * Returns TRUE if the given planemask covers all the significant bits in the 579d514b0f3Smrg * pixel values for pDrawable. 580d514b0f3Smrg */ 581d514b0f3Smrg#define UXA_PM_IS_SOLID(_pDrawable, _pm) \ 582d514b0f3Smrg (((_pm) & FbFullMask((_pDrawable)->depth)) == \ 583d514b0f3Smrg FbFullMask((_pDrawable)->depth)) 584d514b0f3Smrg 585d514b0f3Smrg#endif /* UXA_H */ 586