0N/A/*
2362N/A * Copyright (c) 1998, 2000, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A#ifndef _JDGADEVICE_H_
0N/A#define _JDGADEVICE_H_
0N/A
0N/A/*
0N/A * Interface for Supporting DGA to Framebuffers under Java
0N/A * -------------------------------------------------------
0N/A *
0N/A * This interface will allow third party (and Sun) framebuffers which
0N/A * support the Direct Graphics Access (DGA) interface to be accessed with
0N/A * DGA in Java applications.
0N/A *
0N/A * It coexists with the existing device-independent interfaces provided in
0N/A * libsunwjdga.so.
0N/A *
0N/A * Framebuffers desiring access to Java DGA must supply a dynamically
0N/A * loaded library named "libjdga<fbname>.so", where <fbname> is the name
0N/A * returned by the VIS_GETIDENTIFIER ioctl as defined in the Solaris
0N/A * VISUAL environment (visual_io(7i)). For example, the Java DGA library
0N/A * for Sun's cg6 framebuffer will be named libjdgaSUNWcg6.so.
0N/A *
0N/A * Because multiple instances of a framebuffer type may exist on a system,
0N/A * the device-dependent library must avoid the use of static or global
0N/A * variables for any framebuffer-related variables. In other words it
0N/A * must be reentrant.
0N/A *
0N/A * The device-independent function Solaris_JDga_LibInit() is called in the
0N/A * static initializer for X11Graphics.java. Solaris_JDga_LibInit() will be
0N/A * modified to seek out a device-dependent DGA library as follows.
0N/A *
0N/A * - DGA grab the DefaultRootWindow to get a Dga_drawable.
0N/A *
0N/A * - Use the Dga_drawable ID to get the device file descriptor
0N/A * fd = dga_win_devfd(dga_draw_id)
0N/A *
0N/A * - Use the VIS_GETIDENTIFIER ioctl to get the device name string.
0N/A *
0N/A * - Construct the library path name using the device name string.
0N/A * The device-dependent library must be located in a location specified
0N/A * in the LD_LIBRARY_PATH.
0N/A *
0N/A * - The device-dependent library will be dlopen'ed and then a dlsym will
0N/A * be performed for the function "SolarisJDgaDevOpen", which must
0N/A * be implemented by the device-dependent library writer.
0N/A *
0N/A * - The function SolarisJDgaDevOpen() will then be called with a
0N/A * pointer to a SolarisJDgaDevInfo structure. This structure will
0N/A * have its major and minor version numbers filled in with their
0N/A * current values by the device-independent calling code. The
0N/A * device-dependent library must examine these version numbers and
0N/A * act as follows:
0N/A *
0N/A * - In all cases, the device-dependent code should reset the
0N/A * supplied major and minor version numbers to those of the
0N/A * device-dependent library.
0N/A *
0N/A * - If the supplied major version number is not the same as that
0N/A * of the device library, the open must fail and return JDGA_FAILED.
0N/A *
0N/A * - If the supplied minor version number is less than or equal to
0N/A * the device minor version number, then backward compatibility
0N/A * is assumed and the open should return JDGA_SUCCESS.
0N/A *
0N/A * - If the supplied minor version number is greater than the
0N/A * device minor version number, the open should also return
0N/A * JDGA_SUCCESS. The returned device minor version number will
0N/A * indicate to the device-independent code what features are
0N/A * supported in the device library.
0N/A *
0N/A * - The function SolarisJDgaDevOpen() must also return a structure
0N/A * containing function pointers as given in the SolarisJDgaDevFunc
0N/A * structure below. The winlock and winunlock functions are
0N/A * required only if there is some device-specific locking to be done
0N/A * in addition to the DGA lock. If this is not required for the device
0N/A * these function pointers may be specified as NULL pointers.
0N/A *
0N/A */
0N/A
0N/A#include <dga/dga.h>
0N/A#include <unistd.h> /* ioctl */
0N/A#include <stdlib.h>
0N/A#include <sys/mman.h> /* mmap */
0N/A#include <sys/visual_io.h>
0N/A#include <X11/Xlib.h>
0N/A
0N/A/*
0N/A * Status return codes
0N/A */
0N/A#ifndef _DEFINE_JDGASTATUS_
0N/A#define _DEFINE_JDGASTATUS_
0N/Atypedef enum {
0N/A JDGA_SUCCESS = 0, /* operation succeeded */
0N/A JDGA_FAILED = 1 /* unable to complete operation */
0N/A} JDgaStatus;
0N/A#endif
0N/A
0N/A/*
0N/A * Structure to be filled in by device-dependent library's
0N/A * SolarisJDgaDevOpen() function
0N/A */
0N/Atypedef struct {
0N/A char * visidName; /* device name from ioctl */
0N/A int majorVersion;
0N/A int minorVersion;
0N/A struct _SolarisJDgaDevFuncList* function; /* Device function pointers */
0N/A} SolarisJDgaDevInfo;
0N/A
0N/A/*
0N/A * Structure returned by device-dependent library for a window
0N/A */
0N/Atypedef struct {
0N/A SolarisJDgaDevInfo* devInfo; /* Supplied by caller */
0N/A Dga_drawable dgaDraw; /* Supplied by caller */
0N/A caddr_t mapAddr; /* FB mapping for this window */
0N/A int mapDepth; /* Depth in bits */
0N/A int mapWidth; /* Width in pixels */
0N/A int mapHeight; /* Height in lines */
0N/A int mapLineStride; /* Byte stride line-to-line */
0N/A int mapPixelStride; /* Byte stride pixel-to-pixel */
0N/A void* privateData; /* Handle for device-dependent library */
0N/A} SolarisJDgaWinInfo;
0N/A
0N/Atypedef JDgaStatus (*SolarisJDgaDevFunction)(SolarisJDgaDevInfo*);
0N/Atypedef JDgaStatus (*SolarisJDgaWinFunction)(SolarisJDgaWinInfo*);
0N/A
0N/A/*
0N/A * Structure for device-dependent functions
0N/A */
0N/Atypedef struct _SolarisJDgaDevFuncList {
0N/A SolarisJDgaDevFunction devclose;
0N/A SolarisJDgaWinFunction winopen;
0N/A SolarisJDgaWinFunction winclose;
0N/A SolarisJDgaWinFunction winlock;
0N/A SolarisJDgaWinFunction winunlock;
0N/A} SolarisJDgaDevFuncList;
0N/A
0N/A/*
0N/A * Function to be supplied by the device-dependent library implementor.
0N/A * It will accept a SolarisJDgaDevInfo structure with a filled-in
0N/A * major and minor version number and will return updated version
0N/A * numbers and the function pointers described below.
0N/A */
0N/Atypedef JDgaStatus SolarisJDgaDevOpenFunc(SolarisJDgaDevInfo* devInfo);
0N/A
0N/AJDgaStatus SolarisJDgaDevOpen(SolarisJDgaDevInfo* devInfo);
0N/A
0N/A/*
0N/A * Functions supplied by the device-dependent library.
0N/A * These function pointers will be returned to the
0N/A * device-independent code in the SolarisJDgaDevFunc structure.
0N/A */
0N/A
0N/AJDgaStatus (*winopen)(SolarisJDgaWinInfo* info);
0N/A
0N/A/*
0N/A * Fills in window-specific information in the supplied SolarisJDgaWinInfo
0N/A * structure. Because multiple windows may be open concurrently,
0N/A * implementations should avoid the use of static structures.
0N/A */
0N/A
0N/AJDgaStatus (*winclose)(SolarisJDgaWinInfo* info);
0N/A
0N/A/*
0N/A * Frees any resources allocated by the device-dependent library for
0N/A * this window. It may also perform an unmap if this is the last
0N/A * window using this particular memory map. Devices, such as the FFB,
0N/A * which support multiple depths, can have different device memory
0N/A * mappings for different depths.
0N/A */
0N/A
0N/AJDgaStatus (*winlock)(SolarisJDgaWinInfo* info);
0N/A
0N/A/*
0N/A * Performs any device-specific locking needed for the framebuffer.
0N/A * In most cases it will be unnecessary. In those cases, the
0N/A * device-dependent library can supply NULL for this function pointer.
0N/A */
0N/A
0N/AJDgaStatus (*winunlock)(SolarisJDgaWinInfo* info);
0N/A
0N/A/*
0N/A * Performs any device-specific unlocking needed for the framebuffer.
0N/A * In most cases it will be unnecessary. In those cases, the
0N/A * device-dependent library can supply NULL for this function pointer.
0N/A */
0N/A
0N/AJDgaStatus (*devclose)(SolarisJDgaDevInfo* info);
0N/A
0N/A/*
0N/A * This function will be called at the last usage of the framebuffer
0N/A * device to allow the library to clean up any remaining resources.
0N/A */
0N/A
0N/A#endif /* _JDGADEVICE_H_ */