aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2022-07-21 12:45:26 +0200
committerMattias Andrée <maandree@kth.se>2022-07-21 12:45:26 +0200
commitd2386fa0e3cc5e80fcfe51f07751d13676655d76 (patch)
tree5bb04bc188f3366fe2e50cca8e05020a8cf3cb6f
parentmissed to set JAVA_HOME (diff)
downloadjlibgamma-d2386fa0e3cc5e80fcfe51f07751d13676655d76.tar.gz
jlibgamma-d2386fa0e3cc5e80fcfe51f07751d13676655d76.tar.bz2
jlibgamma-d2386fa0e3cc5e80fcfe51f07751d13676655d76.tar.xz
Improve makefile, change license to ISC, change code style, remove dist/
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r--.gitignore11
-rw-r--r--COPYING15
-rw-r--r--DEPENDENCIES1
-rw-r--r--LICENSE683
-rw-r--r--Makefile313
-rw-r--r--README1
-rw-r--r--Test.java148
-rw-r--r--config.mk19
-rw-r--r--dist/archlinux/stable/.gitignore6
-rw-r--r--dist/archlinux/stable/PKGBUILD26
-rw-r--r--libgamma/AdjustmentMethod.java228
-rw-r--r--libgamma/AdjustmentMethodCapabilities.java147
-rw-r--r--libgamma/CRTC.java285
-rw-r--r--libgamma/CRTCInformation.java552
-rw-r--r--libgamma/ConnectorType.java148
-rw-r--r--libgamma/GammaRamps.java312
-rw-r--r--libgamma/Libgamma.java30
-rw-r--r--libgamma/LibgammaException.java411
-rw-r--r--libgamma/Partition.java125
-rw-r--r--libgamma/Ramp.java160
-rw-r--r--libgamma/Ramp16.java79
-rw-r--r--libgamma/Ramp32.java57
-rw-r--r--libgamma/Ramp64.java44
-rw-r--r--libgamma/Ramp8.java83
-rw-r--r--libgamma/Rampd.java66
-rw-r--r--libgamma/Rampf.java57
-rw-r--r--libgamma/Site.java133
-rw-r--r--libgamma/SubpixelOrder.java77
-rw-r--r--libgamma_AdjustmentMethod.c151
-rw-r--r--libgamma_CRTC.c414
-rw-r--r--libgamma_GammaRamps.c336
-rw-r--r--libgamma_LibgammaException.c124
-rw-r--r--libgamma_Partition.c103
-rw-r--r--libgamma_Ramp.c210
-rw-r--r--libgamma_Site.c121
-rw-r--r--mk/linux.mk3
-rw-r--r--mk/macos.mk3
-rw-r--r--mk/windows.mk3
-rw-r--r--src/Test.java164
-rw-r--r--src/libgamma/AdjustmentMethod.java254
-rw-r--r--src/libgamma/AdjustmentMethodCapabilities.java167
-rw-r--r--src/libgamma/CRTC.java305
-rw-r--r--src/libgamma/CRTCInformation.java580
-rw-r--r--src/libgamma/ConnectorType.java168
-rw-r--r--src/libgamma/GammaRamps.java332
-rw-r--r--src/libgamma/Libgamma.java50
-rw-r--r--src/libgamma/LibgammaException.java436
-rw-r--r--src/libgamma/Partition.java145
-rw-r--r--src/libgamma/Ramp.java179
-rw-r--r--src/libgamma/Ramp16.java100
-rw-r--r--src/libgamma/Ramp32.java77
-rw-r--r--src/libgamma/Ramp64.java64
-rw-r--r--src/libgamma/Ramp8.java103
-rw-r--r--src/libgamma/Rampd.java88
-rw-r--r--src/libgamma/Rampf.java78
-rw-r--r--src/libgamma/Site.java155
-rw-r--r--src/libgamma/SubpixelOrder.java97
-rw-r--r--src/libgamma_AdjustmentMethod.c173
-rw-r--r--src/libgamma_CRTC.c441
-rw-r--r--src/libgamma_GammaRamps.c359
-rw-r--r--src/libgamma_LibgammaException.c145
-rw-r--r--src/libgamma_Partition.c123
-rw-r--r--src/libgamma_Ramp.c230
-rw-r--r--src/libgamma_Site.c143
64 files changed, 4734 insertions, 6107 deletions
diff --git a/.gitignore b/.gitignore
index 0d0b5cf..a14f509 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,9 +1,5 @@
_/
-bin/
-obj/
-\#*\#
-.*
-!.git*
+*\#*
*~
*.bak
*.swp
@@ -13,6 +9,9 @@ obj/
*.out
*.o
*.so
+*.so.*
+*.dll
+*.dylib
*.class
*.jar
-
+libgamma_*.h
diff --git a/COPYING b/COPYING
deleted file mode 100644
index 8a75e67..0000000
--- a/COPYING
+++ /dev/null
@@ -1,15 +0,0 @@
-jlibgamma -- Display server abstraction layer for gamma ramp and Java
-Copyright (C) 2014 Mattias Andrée (maandree@member.fsf.org)
-
-This library is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this library. If not, see <http://www.gnu.org/licenses/>.
diff --git a/DEPENDENCIES b/DEPENDENCIES
index e800c13..549eb83 100644
--- a/DEPENDENCIES
+++ b/DEPENDENCIES
@@ -20,4 +20,3 @@ INSTALL DEPENDENCIES:
make
coreutils
-
diff --git a/LICENSE b/LICENSE
index 94a9ed0..d3ebfaa 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,674 +1,15 @@
- GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
+ISC License
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
+© 2014, 2022 Mattias Andrée <maandree@kth.se>
- Preamble
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Use with the GNU Affero General Public License.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-Also add information on how to contact you by electronic and paper mail.
-
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
- <program> Copyright (C) <year> <name of author>
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-<http://www.gnu.org/licenses/>.
-
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
-<http://www.gnu.org/philosophy/why-not-lgpl.html>.
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/Makefile b/Makefile
index 9712844..5ec989a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,235 +1,98 @@
-# Copying and distribution of this file, with or without modification,
-# are permitted in any medium without royalty provided the copyright
-# notice and this notice are preserved. This file is offered as-is,
-# without any warranty.
-
-
-# The package path prefix, if you want to install to another root, set DESTDIR to that root
-PREFIX ?= /usr
-# The library path excluding prefix
-LIB ?= /lib
-# The resource path excluding prefix
-DATA ?= /share
-# The library path including prefix
-LIBDIR ?= $(PREFIX)$(LIB)
-# The resource path including prefix
-DATADIR ?= $(PREFIX)$(DATA)
-# Java module path including prefix
-JAVADIR ?= $(DATADIR)/java
-# The generic documentation path including prefix
-DOCDIR ?= $(DATADIR)/doc
-# The info manual documentation path including prefix
-INFODIR ?= $(DATADIR)/info
-# The license base path including prefix
-LICENSEDIR ?= $(DATADIR)/licenses
-
-# The name of the package as it should be installed
-PKGNAME = jlibgamma
-
-
-# The Java compiler
-JAVAC = javac
-# The Java archive creator
-JAR = jar
-# The JNI header generator
-JAVAH = javah
-
-
-# The version of the library.
-LIB_MAJOR = 1
-LIB_MINOR = 0
-LIB_VERSION = $(LIB_MAJOR).$(LIB_MINOR)
-
-# The so in libgammamm.so as the library file is named on Linux
-ifeq ($(PLATFORM),w32)
-SO = dll
-else
-ifeq ($(PLATFORM),osx)
-SO = dylib
-else
-SO = so
-endif
-endif
-
-# Platform dependent flags
-ifeq ($(PLATFORM),w32)
-SHARED = -mdll
-LDSO = -Wl,-soname,libgamma-java.$(SO).$(LIB_MAJOR)
-PIC =
-else
-ifeq ($(PLATFORM),osx)
-SHARED = -dynamiclib
-LDSO =
-PIC = -fPIC
-else
-SHARED = -shared
-LDSO = -Wl,-soname,libgamma-java.$(SO).$(LIB_MAJOR)
-PIC = -fPIC
-endif
-endif
-
-# The C standard for C code compilation
-STD = c99
-# Optimisation settings for C code compilation
-C_OPTIMISE ?= -Og -g
-# Optimisation settings for Java code compilation
-JAVA_OPTIMISE ?= -O
-
-# Warning flags for C code, set to empty if you are not using GCC
-C_WARN = -Wall -Wextra -pedantic -Wdouble-promotion -Wformat=2 -Winit-self -Wmissing-include-dirs \
- -Wtrampolines -Wfloat-equal -Wshadow -Wmissing-prototypes -Wmissing-declarations \
- -Wredundant-decls -Wnested-externs -Winline -Wno-variadic-macros -Wswitch-default \
- -Wsync-nand -Wunsafe-loop-optimizations -Wcast-align -Wstrict-overflow \
- -Wdeclaration-after-statement -Wundef -Wbad-function-cast -Wcast-qual -Wwrite-strings \
- -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wpacked \
- -Wvector-operation-performance -Wunsuffixed-float-constants -Wnormalized=nfkc
-
-# Warning flags for Java code
-JAVA_WARN = -Xlint:all
-
-
-# Addition flags to use when compiling C code with JNI support
-CC_JNI_FLAGS = -I"$(JAVA_HOME)/include" -I"$(shell echo "$(JAVA_HOME)"/include/*/)"
-
-# Addition flags to use when linking native objets with JNI support
-LD_JNI_FLAGS =
-
-# Flags to use when compiling C code
-CC_FLAGS = -std=$(STD) $(C_OPTIMISE) $(PIC) $(C_WARN)
-
-# Flags to use when linking native objects
-LD_FLAGS = -lgamma -std=$(STD) $(C_OPTIMISE) $(C_WARN)
-
-# Flags to use when compiling Java code
-JAVAC_FLAGS = $(JAVACFLAGS) $(JAVA_OPTIMISE) $(JAVA_WARN)
-
-
-# Java classes
-JAVA_OBJ = AdjustmentMethod CRTC CRTCInformation GammaRamps Libgamma Partition Site \
- AdjustmentMethodCapabilities ConnectorType LibgammaException Ramp SubpixelOrder \
- Ramp16 Ramp32 Ramp64 Ramp8 Rampd Rampf
-
-# Java classes with native functions
-JAVA_H = AdjustmentMethod CRTC GammaRamps LibgammaException Partition Ramp Site
-
-# .so files to create
-SO_FILES = bin/libgamma-java.$(SO).$(LIB_VERSION) bin/libgamma-java.$(SO).$(LIB_MAJOR) bin/libgamma-java.$(SO)
-
-
-
-.PHONY: all
-all: lib test
-
-.PHONY: lib
-lib: jar so
-
-.PHONY: so
-so: $(SO_FILES)
-
-.PHONY: jar
-jar: bin/jlibgamma.jar
-
-.PHONY: class
-class: $(foreach O,$(JAVA_OBJ),obj/libgamma/$(O).class)
-
-.PHONY: header
-header: $(foreach H,$(JAVA_H),obj/libgamma_$(H).h)
+.POSIX:
-.PHONY: test
-test: bin/Test.class
+CONFIGFILE = config.mk
+include $(CONFIGFILE)
+OS = linux
+include mk/$(OS).mk
-bin/jlibgamma.jar: $(foreach O,$(JAVA_OBJ),obj/libgamma/$(O).class)
- @mkdir -p bin
- cd obj; $(JAR) cf jlibgamma.jar $(foreach O,$(JAVA_OBJ),libgamma/$(O).class)
- mv obj/jlibgamma.jar $@
-obj/libgamma/%.class: src/libgamma/%.java
- @mkdir -p obj/libgamma
- $(JAVAC) $(JAVAC_FLAGS) -cp src -s src -d obj $<
-
-obj/libgamma_%.h: obj/libgamma/%.class
- $(JAVAH) -classpath obj -jni -d obj \
- $$(echo "$<" | sed -e 's:^obj/::' -e 's:.class$$::' | sed -e 's:/:.:g')
-
-obj/libgamma_%.o: src/libgamma_%.c obj/libgamma_%.h
- $(CC) $(CC_JNI_FLAGS) $(CC_FLAGS) -iquote"obj" -c -o $@ $< $(CFLAGS) $(CPPFLAGS)
-
-bin/libgamma-java.$(SO).$(LIB_VERSION): $(foreach O,$(JAVA_H),obj/libgamma_$(O).o)
- @mkdir -p bin
- $(CC) $(LD_JNI_FLAGS) $(LD_FLAGS) $(SHARED) $(LDSO) -o $@ $^ $(LDFLAGS)
-
-bin/libgamma-java.$(SO).$(LIB_MAJOR):
- @mkdir -p bin
- ln -sf libgamma-java.$(SO).$(LIB_VERSION) $@
-
-bin/libgamma-java.$(SO):
- @mkdir -p bin
- ln -sf libgamma-java.$(SO).$(LIB_VERSION) $@
-
-bin/Test.class: src/Test.java bin/jlibgamma.jar $(SO_FILES)
- @mkdir -p bin
- $(JAVAC) $(JAVAC_FLAGS) -cp 'src:bin/jlibgamma.jar' -s src -d bin $<
-
-
-
-.PHONY: install
-install: install-base
-
-.PHONY: install
-install-all: install-base
-
-.PHONY: install-base
-install-base: install-lib install-jar install-copyright
-
-
-.PHONY: install-lib
-install-lib:
- install -dm755 -- "$(DESTDIR)$(LIBDIR)"
- install -m755 bin/libgamma-java.$(SO).$(LIB_VERSION) -- "$(DESTDIR)$(LIBDIR)/libgamma-java.$(SO).$(LIB_VERSION)"
- ln -sf libgamma-java.$(SO).$(LIB_VERSION) -- "$(DESTDIR)$(LIBDIR)/libgamma-java.$(SO).$(LIB_MAJOR)"
- ln -sf libgamma-java.$(SO).$(LIB_VERSION) -- "$(DESTDIR)$(LIBDIR)/libgamma-java.$(SO)"
-
-.PHONY: install-jar
-install-jar:
- install -dm755 -- "$(DESTDIR)$(JAVADIR)"
- install -m644 bin/jlibgamma.jar -- "$(DESTDIR)$(JAVADIR)/jlibgamma.jar"
-
-
-.PHONY: install-copyright
-install-copyright: install-copying install-license
-
-.PHONY: install-copying
-install-copying:
- install -dm755 -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"
- install -m644 COPYING -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/COPYING"
-
-.PHONY: install-license
-install-license:
- install -dm755 -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"
- install -m644 LICENSE -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/LICENSE"
-
-
-
-.PHONY: uninstall
-uninstall:
- -rm -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/LICENSE"
- -rm -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)/COPYING"
- -rmdir -- "$(DESTDIR)$(LICENSEDIR)/$(PKGNAME)"
- -rm -- "$(DESTDIR)$(JAVADIR)/jlibgamma.jar"
- -rm -- "$(DESTDIR)$(LIBDIR)/libgamma-java.$(SO).$(LIB_VERSION)"
- -rm -- "$(DESTDIR)$(LIBDIR)/libgamma-java.$(SO).$(LIB_MAJOR)"
- -rm -- "$(DESTDIR)$(LIBDIR)/libgamma-java.$(SO)"
+LIB_MAJOR = 1
+LIB_MINOR = 0
+LIB_VERSION = $(LIB_MAJOR).$(LIB_MINOR)
+JPKGDIR = libgamma
+JPKG = libgamma
+
+CLASS =\
+ $(JPKGDIR)/AdjustmentMethod.class\
+ $(JPKGDIR)/AdjustmentMethodCapabilities.class\
+ $(JPKGDIR)/ConnectorType.class\
+ $(JPKGDIR)/CRTC.class\
+ $(JPKGDIR)/CRTCInformation.class\
+ $(JPKGDIR)/GammaRamps.class\
+ $(JPKGDIR)/Libgamma.class\
+ $(JPKGDIR)/LibgammaException.class\
+ $(JPKGDIR)/Partition.class\
+ $(JPKGDIR)/Ramp.class\
+ $(JPKGDIR)/Ramp8.class\
+ $(JPKGDIR)/Ramp16.class\
+ $(JPKGDIR)/Ramp32.class\
+ $(JPKGDIR)/Ramp64.class\
+ $(JPKGDIR)/Rampd.class\
+ $(JPKGDIR)/Rampf.class\
+ $(JPKGDIR)/Site.class\
+ $(JPKGDIR)/SubpixelOrder.class
+
+OBJ =\
+ libgamma_AdjustmentMethod.o\
+ libgamma_CRTC.o\
+ libgamma_GammaRamps.o\
+ libgamma_LibgammaException.o\
+ libgamma_Partition.o\
+ libgamma_Ramp.o\
+ libgamma_Site.o
+
+JAVA_HDR = $(OBJ:.o=.h)
+JAVA_SRC = $(CLASS:.class=.java)
+
+
+all: libgamma.jar libgamma-java.so
+
+$(OBJ): $(JAVA_HDR)
+
+$(CLASS) $(JAVA_HDR): $(JAVA_SRC)
+ @set -e;\
+ if $(JAVAH) -version 2>/dev/null >/dev/null; then\
+ printf '%s\n' "$(JAVAH) -jni -d . -cp . $(JPKG).EQNative";\
+ $(JAVAH) -jni -d . -cp . $(JPKG).EQNative;\
+ printf '%s\n' "$(JAVAC) '-Xlint:all' -O -cp . -d . $(JAVA_SRC)";\
+ $(JAVAC) '-Xlint:all' -O -cp . -d . $(JAVA_SRC);\
+ else\
+ printf '%s\n' "$(JAVAC) '-Xlint:all' -O -h . -cp . -d . $(JAVA_SRC)";\
+ $(JAVAC) '-Xlint:all' -O -h . -cp . -d . $(JAVA_SRC);\
+ fi
+
+Test.class: Test.java
+ $(JAVAC) '-Xlint:all' -cp . -d . Test.java
+
+libgamma.jar: $(CLASS)
+ $(JAR) cf $@ $(CLASS)
+
+libgamma-java.$(LIBEXT): $(OBJ)
+ $(CC) $(LD_FLAGS) $(SHARED) $(LDSO) -o $@ $(OBJ) $(LDFLAGS)
+
+.c.o:
+ $(CC) -c -o $@ $< $(CFLAGS)
+
+install: libgamma.jar libgamma-java.$(LIBEXT)
+ mkdir -p -- "$(DESTDIR)$(PREFIX)/lib"
+ mkdir -p -- "$(DESTDIR)$(JAVADIR)"
+ cp -- libgamma-java.$(LIBEXT) "$(DESTDIR)$(PREFIX)/lib"
+ cp -- libgamma.jar "$(DESTDIR)$(JAVADIR)"
+
+uninstall:
+ -rm -f -- "$(DESTDIR)$(PREFIX)/lib/libgamma-java.so"
+ -rm -f -- "$(DESTDIR)$(JAVADIR)/libgamma.jar"
+
+run-test: Test.class ./libgamma.jar ./libgamma-java.so
+ @env LD_LIBRARY_PATH=. java -cp .:./libgamma.jar Test
-.PHONY: clean
clean:
- -rm -r obj bin
-
-
+ -rm -f -- libgamma_*.h *.o *.class *.so *.so.* *.dll *.dylib *.$(LIBEXT)
-.PHONY: run-test
-run-test: bin/Test.class
- @env LD_LIBRARY_PATH=bin java -cp bin:bin/jlibgamma.jar Test
+.SUFFIXES:
+.SUFFIXES: .o .c
+.PHONY: all install uninstall check run-test clean
diff --git a/README b/README
index 4e96dad..e70b892 100644
--- a/README
+++ b/README
@@ -1,2 +1 @@
Java wrapper for libgamma.
-
diff --git a/Test.java b/Test.java
new file mode 100644
index 0000000..ad8c607
--- /dev/null
+++ b/Test.java
@@ -0,0 +1,148 @@
+/* See LICENSE file for copyright and license details. */
+import libgamma.*;
+
+
+/**
+ * jlibgamma interactive test class
+ */
+public class Test
+{
+ public static void p(boolean text) { System.out.println(text); }
+ public static void p(byte text) { System.out.println(text); }
+ public static void p(short text) { System.out.println(text); }
+ public static void p(int text) { System.out.println(text); }
+ public static void p(long text) { System.out.println(text); }
+ public static void p(char text) { System.out.println(text); }
+ public static void p(String text) { System.out.println(text); }
+ public static void p(Object text) { System.out.println(text); }
+ public static void p() { System.out.println(); }
+
+ public static void P(boolean text) { System.out.print(text + " "); }
+ public static void P(byte text) { System.out.print(text + " "); }
+ public static void P(short text) { System.out.print(text + " "); }
+ public static void P(int text) { System.out.print(text + " "); }
+ public static void P(long text) { System.out.print(text + " "); }
+ public static void P(char text) { System.out.print(text + " "); }
+ public static void P(String text) { System.out.print(text + " "); }
+ public static void P(Object text) { System.out.print(text + " "); }
+
+
+ /**
+ * Main test function
+ *
+ * @param args Command line arguments, excluding $0
+ */
+ public static void main(String[] args) throws LibgammaException
+ {
+ p(LibgammaException.name_of_error(-3));
+ p(LibgammaException.value_of_error("LIBGAMMA_NO_SUCH_SITE"));
+ p();
+
+ LibgammaException err = new LibgammaException(LibgammaException.LIBGAMMA_DEVICE_REQUIRE_GROUP);
+ p(err.error_code);
+ p(err.group_gid);
+ p(err.group_name);
+ p(err.string);
+ err = new LibgammaException(5);
+ p(err.string);
+ p(err);
+ p();
+
+ for (AdjustmentMethod method : AdjustmentMethod.list_methods(0)) P(method.value); p();
+ for (AdjustmentMethod method : AdjustmentMethod.list_methods(1)) P(method.value); p();
+ for (AdjustmentMethod method : AdjustmentMethod.list_methods(2)) P(method.value); p();
+ for (AdjustmentMethod method : AdjustmentMethod.list_methods(3)) P(method.value); p();
+ for (AdjustmentMethod method : AdjustmentMethod.list_methods(4)) P(method.value); p();
+ p();
+
+ AdjustmentMethod method = AdjustmentMethod.list_methods(0)[0];
+ p(method);
+ p(SubpixelOrder.HORIZONTAL_RGB);
+ p(ConnectorType.VGA);
+ p();
+
+ p(AdjustmentMethod.X_RANDR.is_available());
+ p(AdjustmentMethod.X_RANDR.get_default_site());
+ p(AdjustmentMethod.X_RANDR.get_default_site_variable());
+ p();
+
+ for (byte b : CRTCInformation.unhex("0123456789abcdef"))
+ P(b & 255);
+ p();
+ p(CRTCInformation.behex(CRTCInformation.unhex("0123456789abcdef")));
+ p();
+
+ Site site = new Site(method, ":0");
+ p(site.partitions_available);
+ p(site);
+ Partition partition = new Partition(site, 0);
+ p(partition.crtcs_available);
+ p(partition);
+ CRTC crtc = new CRTC(partition, 0);
+ p(crtc);
+ p();
+
+ CRTCInformation info = crtc.get_information(~0);
+ p(info);
+ p();
+
+ AdjustmentMethodCapabilities caps = method.get_capabilities();
+ p(caps);
+ p();
+
+ GammaRamps<Ramp16> ramps = new GammaRamps<Ramp16>(info.red_gamma_size,
+ info.green_gamma_size,
+ info.blue_gamma_size,
+ 16);
+
+ int[] saved_red = new int[ramps.red.size];
+ int[] saved_green = new int[ramps.green.size];
+ int[] saved_blue = new int[ramps.blue.size];
+
+ crtc.get_gamma(ramps);
+
+ for (int i = 0; i < ramps.red.size; i++) {
+ P(ramps.red.get(i));
+ ramps.red.set(i, (saved_red[i] = ramps.red.get(i)) / 2);
+ }
+ p();
+ p();
+ for (int i = 0; i < ramps.green.size; i++) {
+ P(ramps.green.get(i));
+ ramps.green.set(i, (saved_green[i] = ramps.green.get(i)) / 2);
+ }
+ p();
+ p();
+ for (int i = 0; i < ramps.blue.size; i++) {
+ P(ramps.blue.get(i));
+ ramps.blue.set(i, (saved_blue[i] = ramps.blue.get(i)) / 2);
+ }
+ p();
+ p();
+
+ crtc.set_gamma(ramps);
+
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException _error) {
+ /* ignore. */
+ }
+
+ for (int i = 0; i < ramps.red. size; i++) ramps.red. set(i, saved_red[i]);
+ for (int i = 0; i < ramps.green.size; i++) ramps.green.set(i, saved_green[i]);
+ for (int i = 0; i < ramps.blue. size; i++) ramps.blue. set(i, saved_blue[i]);
+
+ crtc.set_gamma(ramps);
+
+ ramps.close();
+ crtc.close();
+ partition.close();
+ site.close();
+
+ try {
+ throw new LibgammaException(0);
+ } catch (LibgammaException error) {
+ p(error);
+ }
+ }
+}
diff --git a/config.mk b/config.mk
new file mode 100644
index 0000000..f8eb955
--- /dev/null
+++ b/config.mk
@@ -0,0 +1,19 @@
+PREFIX = /usr
+JAVADIR = $(PREFIX)/share/java
+
+INSTALLED_JAVAPATH = $$(dirname $$(dirname $$($(REALPATH) $$(which $(JAVAC) || type -p $(JAVAC)))))
+
+REALPATH = readlink -f
+CC = c99
+JAVA = java
+JAVAC = javac
+JAVADOC = javadoc
+JAR = jar
+JAVAH = javah
+# The Makefile will check whether $(JAVAH) exists, otherwise it will use $(JAVAC) with -h
+
+CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_GNU_SOURCE\
+ -isystem "$(INSTALLED_JAVAPATH)/include"\
+ -isystem "$(INSTALLED_JAVAPATH)/include/$$(uname | tr '[A-Z]' '[a-z]')"
+CFLAGS = -Wall -O2 $(OS_CFLAGS) $(CPPFLAGS)
+LDFLAGS = -lgamma $(OS_LDFLAGS)
diff --git a/dist/archlinux/stable/.gitignore b/dist/archlinux/stable/.gitignore
deleted file mode 100644
index 17b52ab..0000000
--- a/dist/archlinux/stable/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-*
-!/.git*
-*~
-!/PKGBUILD
-!/jlibgamma.install
-
diff --git a/dist/archlinux/stable/PKGBUILD b/dist/archlinux/stable/PKGBUILD
deleted file mode 100644
index 45bf517..0000000
--- a/dist/archlinux/stable/PKGBUILD
+++ /dev/null
@@ -1,26 +0,0 @@
-# Maintainer: Mattias Andrée <`base64 -d`(bWFhbmRyZWUK)@member.fsf.org>
-
-pkgname=jlibgamma
-pkgver=1.0.1
-pkgrel=1
-pkgdesc="Display server abstraction layer for gamma ramps and Java"
-arch=(i686 x86_64)
-url="https://github.com/maandree/jlibgamma"
-license=('GPL3')
-depends=('java-runtime-headless>=1.5' 'libgamma>=0.3' glibc)
-makedepends=('java-environment>=1.5' 'libgamma>=0.3' glibc gcc make coreutils sed)
-source=($url/archive/$pkgver.tar.gz)
-sha256sums=(b2b4fff21270162a7faa3cc95f511261acf128a28e35f24c6c24a1b8492bb175)
-
-
-build() {
- cd "$srcdir/$pkgname-$pkgver"
- make PREFIX=/usr JAVA_HOME=/usr/lib/jvm/default
-}
-
-
-package() {
- cd "$srcdir/$pkgname-$pkgver"
- make PREFIX=/usr JAVA_HOME=/usr/lib/jvm/default install DESTDIR="$pkgdir"
-}
-
diff --git a/libgamma/AdjustmentMethod.java b/libgamma/AdjustmentMethod.java
new file mode 100644
index 0000000..7d53090
--- /dev/null
+++ b/libgamma/AdjustmentMethod.java
@@ -0,0 +1,228 @@
+/* See LICENSE file for copyright and license details. */
+package libgamma;
+
+
+/**
+ * Class of adjustment methods
+ */
+public enum AdjustmentMethod
+{
+ /**
+ * The identifier for the dummy adjustment method.
+ * This method can be configured and is useful for
+ * testing your program's ability to handle errors.
+ */
+ DUMMY(0),
+
+ /**
+ * The identifier for the adjustment method with
+ * uses the RandR protocol under the X display server
+ */
+ X_RANDR(1),
+
+ /**
+ * The identifier for the adjustment method with
+ * uses the VidMode protocol under the X display server.
+ * This is an older alternative to RandR that can
+ * work on some drivers that are not supported by RandR,
+ * however it can only control the primary CRTC per
+ * screen (partition).
+ */
+ X_VIDMODE(2),
+
+ /**
+ * The identifier for the Direct Rendering Manager
+ * adjustment method that is available in Linux
+ * (built in to the Linux kernel with a userland
+ * library for access) and is a part of the
+ * Direct Rendering Infrastructure. This adjustment
+ * method all work when you are in non-graphical
+ * mode; however a display server cannnot be
+ * started while this is running, but it can be
+ * started while a display server is running.
+ */
+ LINUX_DRM(3),
+
+ /**
+ * The identifier for the Graphics Device Interface
+ * adjustment method that is available in Windows.
+ * This method is not well tested; it can be compiled
+ * to be available under X.org using a translation layer.
+ */
+ W32_GDI(4),
+
+ /**
+ * The identifier for the CoreGraphics adjustment
+ * method that is available in Mac OS X that can
+ * adjust gamma ramps under the Quartz display server.
+ * This method is not well tested; it can be compiled
+ * to be available under X.org using a translation layer.
+ */
+ QUARTZ_CORE_GRAPHICS(5);
+
+
+ /**
+ * Type initialiser
+ */
+ static
+ {
+ Libgamma.initialise();
+ }
+
+
+ /**
+ * The index of the last gamma method, neither it
+ * nor any index before it may actually be supported
+ * as it could have been disabled at compile-time
+ */
+ public static final int MAX = 5;
+
+ /**
+ * The number adjustment methods provided by this library.
+ * Note however that this includes adjstment methods that
+ * have been removed at compile-time
+ */
+ public static final int COUNT = MAX + 1;
+
+ /**
+ * Adjustment methods by their numerical values
+ */
+ public static AdjustmentMethod[] VALUES =
+ {
+ DUMMY, X_RANDR, X_VIDMODE, LINUX_DRM, W32_GDI, QUARTZ_CORE_GRAPHICS
+ };
+
+
+ /**
+ * Constructor
+ *
+ * @param value The numerical value of the adjustment method
+ */
+ private AdjustmentMethod(int value)
+ {
+ this.value = value;
+ }
+
+
+ /**
+ * The numerical value of the adjustment method
+ */
+ public final int value;
+
+
+ /**
+ * Check whether the adjustment method is available
+ *
+ * @return Whether the adjustment method is available
+ */
+ public boolean is_available()
+ {
+ return libgamma_is_method_available(this.value) != 0;
+ }
+
+ /**
+ * Get the default site for the adjustment method
+ *
+ * @return The default site for the adjustment method
+ */
+ public String get_default_site()
+ {
+ return libgamma_method_default_site(this.value);
+ }
+
+ /**
+ * Get the default variable that determines the default
+ * site for the adjustment method
+ *
+ * @return default variable that determines the default
+ * site for the adjustment method
+ */
+ public String get_default_site_variable()
+ {
+ return libgamma_method_default_site_variable(this.value);
+ }
+
+ /**
+ * Return the capabilities of the adjustment method
+ *
+ * @return The capabilities of the adjustment method
+ */
+ public AdjustmentMethodCapabilities get_capabilities()
+ {
+ return new AdjustmentMethodCapabilities(libgamma_method_capabilities(this.value));
+ }
+
+
+ /**
+ * List available adjustment methods by their order of preference based on the environment
+ *
+ * @param operation Allowed values:<br>
+ * 0: Methods that the environment suggests will work, excluding fake<br>
+ * 1: Methods that the environment suggests will work, including fake<br>
+ * 2: All real non-fake methods<br>
+ * 3: All real methods<br>
+ * 4: All methods<br>
+ * Other values invoke undefined behaviour
+ * @return List available adjustment methods by their order of preference
+ */
+ public static AdjustmentMethod[] list_methods(int operation)
+ {
+ int[] methods = libgamma_list_methods(operation);
+ AdjustmentMethod[] rc = new AdjustmentMethod[methods.length];
+ for (int i = 0; i < methods.length; i++)
+ rc[i] = VALUES[methods[i]];
+ return rc;
+ }
+
+
+ /**
+ * List available adjustment methods by their order of preference based on the environment
+ *
+ * @param operation Allowed values:<br>
+ * 0: Methods that the environment suggests will work, excluding fake<br>
+ * 1: Methods that the environment suggests will work, including fake<br>
+ * 2: All real non-fake methods<br>
+ * 3: All real methods<br>
+ * 4: All methods<br>
+ * Other values invoke undefined behaviour
+ * @return List available adjustment methods by their order of preference
+ */
+ private static native int[] libgamma_list_methods(int operation);
+
+ /**
+ * Check whether an adjustment method is available, non-existing (invalid) methods will
+ * be identified as not available under the rationale that the library may be out of date
+ *
+ * @param method The adjustment method
+ * @return Whether the adjustment method is available
+ */
+ private static native int libgamma_is_method_available(int method);
+
+ /**
+ * Return the capabilities of an adjustment method
+ *
+ * @param method The adjustment method (display server and protocol)
+ * @return Input parameter to the constructor of {@link AdjustmentMethodCapabilities}
+ */
+ private static native long libgamma_method_capabilities(int method);
+
+ /**
+ * Return the default site for an adjustment method
+ *
+ * @param method The adjustment method (display server and protocol)
+ * @return The default site, {@code null} if it cannot be determined or
+ * if multiple sites are not supported by the adjustment method
+ */
+ private static native String libgamma_method_default_site(int method);
+
+ /**
+ * Return the default variable that determines
+ * the default site for an adjustment method
+ *
+ * @param method The adjustment method (display server and protocol)
+ * @return The environ variables that is used to determine the
+ * default site; {@code null} if there is none, that is,
+ * if the method does not support multiple sites
+ */
+ private static native String libgamma_method_default_site_variable(int method);
+}
diff --git a/libgamma/AdjustmentMethodCapabilities.java b/libgamma/AdjustmentMethodCapabilities.java
new file mode 100644
index 0000000..871813f
--- /dev/null
+++ b/libgamma/AdjustmentMethodCapabilities.java
@@ -0,0 +1,147 @@
+/* See LICENSE file for copyright and license details. */
+package libgamma;
+
+
+/**
+ * Capabilities of adjustment methods
+ */
+public class AdjustmentMethodCapabilities
+{
+ /**
+ * Type initialiser
+ */
+ static
+ {
+ Libgamma.initialise();
+ }
+
+
+ /**
+ * Constructor
+ *
+ * @param data Low half: the value of {@link #crtc_information}<br>
+ * High half: the values of the booleanic variables
+ */
+ AdjustmentMethodCapabilities(long data)
+ {
+ this.crtc_information = (int)data;
+
+ this.default_site_known = (data & (1L << 33L)) != 0;
+ this.multiple_sites = (data & (1L << 34L)) != 0;
+ this.multiple_partitions = (data & (1L << 35L)) != 0;
+ this.multiple_crtcs = (data & (1L << 36L)) != 0;
+ this.partitions_are_graphics_cards = (data & (1L << 37L)) != 0;
+ this.site_restore = (data & (1L << 38L)) != 0;
+ this.partition_restore = (data & (1L << 39L)) != 0;
+ this.crtc_restore = (data & (1L << 40L)) != 0;
+ this.identical_gamma_sizes = (data & (1L << 41L)) != 0;
+ this.fixed_gamma_size = (data & (1L << 42L)) != 0;
+ this.fixed_gamma_depth = (data & (1L << 43L)) != 0;
+ this.real = (data & (1L << 44L)) != 0;
+ this.fake = (data & (1L << 45L)) != 0;
+ }
+
+
+ /**
+ * OR of the CRTC information fields in {@link CRTCInformation}
+ * that may (but can fail) be read successfully
+ */
+ public int crtc_information;
+
+ /**
+ * Whether the default site is known, if true the site is integrated
+ * to the system or can be determined using environment variables
+ */
+ public boolean default_site_known;
+
+ /**
+ * Whether the adjustment method supports multiple sites rather
+ * than just the default site
+ */
+ public boolean multiple_sites;
+
+ /**
+ * Whether the adjustment method supports multiple partitions
+ * per site
+ */
+ public boolean multiple_partitions;
+
+ /**
+ * Whether the adjustment method supports multiple CRTC:s
+ * per partition per site
+ */
+ public boolean multiple_crtcs;
+
+ /**
+ * Whether the partition to graphics card is a bijection
+ */
+ public boolean partitions_are_graphics_cards;
+
+ /**
+ * Whether the adjustment method supports {@link Site#restore}
+ */
+ public boolean site_restore;
+
+ /**
+ * Whether the adjustment method supports {@link Partition#restore}
+ */
+ public boolean partition_restore;
+
+ /**
+ * Whether the adjustment method supports {@link CRTC#restore}
+ */
+ public boolean crtc_restore;
+
+ /**
+ * Whether the {@link #red_gamma_size}, {@link #green_gamma_size} and
+ * {@link #blue_gamma_size} fields in {@link CRTCInformation} will
+ * always have the same values as each other for the adjustment method
+ */
+ public boolean identical_gamma_sizes;
+
+ /**
+ * Whether the {@link #red_gamma_size}, {@link #green_gamma_size} and
+ * {@link #blue_gamma_size} fields in {@link CRTCInformation} will
+ * always be filled with the same value for the adjustment method
+ */
+ public boolean fixed_gamma_size;
+
+ /**
+ * Whether the {@link #gamma_depth} field in {@link CRTCInformation}
+ * will always be filled with the same value for the adjustment method
+ */
+ public boolean fixed_gamma_depth;
+
+ /**
+ * Whether the adjustment method will actually perform adjustments
+ */
+ public boolean real;
+
+ /**
+ * Whether the adjustment method is implement using a translation layer
+ */
+ public boolean fake;
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ return "<AdjustmentMethodCapabilities: " +
+ "information = " + Integer.toString(this.crtc_information) + ", " +
+ "default_site_known = " + Boolean.toString(this.default_site_known) + ", " +
+ "multiple_sites = " + Boolean.toString(this.multiple_sites) + ", " +
+ "multiple_partitions = " + Boolean.toString(this.multiple_partitions) + ", " +
+ "multiple_crtcs = " + Boolean.toString(this.multiple_crtcs) + ", " +
+ "partitions_are_graphics_cards = " + Boolean.toString(this.partitions_are_graphics_cards) + ", " +
+ "site_restore = " + Boolean.toString(this.site_restore) + ", " +
+ "partition_restore = " + Boolean.toString(this.partition_restore) + ", " +
+ "crtc_restore = " + Boolean.toString(this.crtc_restore) + ", " +
+ "identical_gamma_sizes = " + Boolean.toString(this.identical_gamma_sizes) + ", " +
+ "fixed_gamma_size = " + Boolean.toString(this.fixed_gamma_size) + ", " +
+ "fixed_gamma_depth = " + Boolean.toString(this.fixed_gamma_depth) + ", " +
+ "real = " + Boolean.toString(this.real) + ", " +
+ "fake = " + Boolean.toString(this.fake) + ">";
+ }
+}
diff --git a/libgamma/CRTC.java b/libgamma/CRTC.java
new file mode 100644
index 0000000..de4abdb
--- /dev/null
+++ b/libgamma/CRTC.java
@@ -0,0 +1,285 @@
+/* See LICENSE file for copyright and license details. */
+package libgamma;
+
+
+/**
+ * Cathode ray tube controller state
+ * <p>
+ * The CRTC controls the gamma ramps for the
+ * monitor that is plugged in to the connector
+ * that the CRTC belongs to
+ */
+public class CRTC
+{
+ /**
+ * Type initialiser
+ */
+ static
+ {
+ Libgamma.initialise();
+ }
+
+
+ /**
+ * Constructor
+ *
+ * @param partition The partition this CRTC belongs to
+ * @param crtc The index of the CRTC within its partition
+ */
+ public CRTC(Partition partition, int crtc) throws LibgammaException
+ {
+ this.partition = partition;
+ this.crtc = crtc;
+ long[] r = libgamma_crtc_create(partition.address, crtc);
+ this.address = r[0];
+ if (r[1] != 0)
+ throw new LibgammaException((int)(r[1]));
+ }
+
+
+ /**
+ * The partition this CRTC belongs to
+ */
+ public final Partition partition;
+
+ /**
+ * The index of the CRTC within its partition
+ */
+ public final int crtc;
+
+ /**
+ * The address of the native object
+ */
+ final long address;
+
+
+ /**
+ * Release resources
+ */
+ public void close()
+ {
+ libgamma_crtc_free(this.address);
+ }
+
+ /**
+ * Restore the gamma ramps for the CRTC to the system settings
+ */
+ public void restore() throws LibgammaException
+ {
+ int r = libgamma_crtc_restore(this.address);
+ if (r != 0)
+ throw new LibgammaException(r);
+ }
+
+ /**
+ * Read information about the CRTC
+ *
+ * @param fields OR:ed identifiers for the information about the CRTC that should be read
+ * @return Information about the CRTC
+ */
+ public CRTCInformation get_information(int fields)
+ {
+ Object[] r = libgamma_get_crtc_information(this.address, fields);
+ byte[] edid = (byte[])(r[0]);
+ String connector_name = (String)(r[1]);
+ float[] gamma = (float[])(r[2]);
+ int[] ints = (int[])(r[3]);
+ return new CRTCInformation(edid, connector_name, gamma, ints);
+ }
+
+ /**
+ * Get the current gamma ramps for the CRTC
+ *
+ * @param output The gamma ramp structure to fill
+ */
+ public <T extends Ramp> void get_gamma(GammaRamps<T> output) throws LibgammaException
+ {
+ int r = 0;
+ if (output.depth == 8) r = libgamma_crtc_get_gamma_ramps8(this.address, output.address);
+ else if (output.depth == 16) r = libgamma_crtc_get_gamma_ramps16(this.address, output.address);
+ else if (output.depth == 32) r = libgamma_crtc_get_gamma_ramps32(this.address, output.address);
+ else if (output.depth == 64) r = libgamma_crtc_get_gamma_ramps64(this.address, output.address);
+ else if (output.depth == -1) r = libgamma_crtc_get_gamma_rampsf(this.address, output.address);
+ else if (output.depth == -2) r = libgamma_crtc_get_gamma_rampsd(this.address, output.address);
+ if (r != 0)
+ throw new LibgammaException(r);
+ }
+
+ /**
+ * Set the gamma ramps for the CRTC
+ *
+ * @param values The gamma ramps to apply
+ */
+ public <T extends Ramp> void set_gamma(GammaRamps<T> values) throws LibgammaException
+ {
+ int r = 0;
+ if (values.depth == 8) r = libgamma_crtc_set_gamma_ramps8(this.address, values.address);
+ else if (values.depth == 16) r = libgamma_crtc_set_gamma_ramps16(this.address, values.address);
+ else if (values.depth == 32) r = libgamma_crtc_set_gamma_ramps32(this.address, values.address);
+ else if (values.depth == 64) r = libgamma_crtc_set_gamma_ramps64(this.address, values.address);
+ else if (values.depth == -1) r = libgamma_crtc_set_gamma_rampsf(this.address, values.address);
+ else if (values.depth == -2) r = libgamma_crtc_set_gamma_rampsd(this.address, values.address);
+ if (r != 0)
+ throw new LibgammaException(r);
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ return "<Site: partition = " + this.partition.toString() + ", " +
+ "crtc = " + Integer.toString(this.crtc) + ">";
+ }
+
+
+ /**
+ * Create a CRTC state
+ *
+ * @param partition The partition state for the partition that the CRTC belongs to
+ * @param crtc The index of the CRTC within the partition
+ * @return Element 0: The value for {@link #address}<br>
+ * Element 1: Error code, zero on success
+ */
+ private static native long[] libgamma_crtc_create(long partition, int crtc);
+
+ /**
+ * Release all resources held by a CRTC state
+ * and free the CRTC state pointer
+ *
+ * @param address The CRTC state
+ */
+ private static native void libgamma_crtc_free(long address);
+
+ /**
+ * Restore the gamma ramps for a CRTC to the system settings for that CRTC
+ *
+ * @param address The CRTC state
+ * @return Zero on success, and error code on failure
+ */
+ private static native int libgamma_crtc_restore(long address);
+
+ /**
+ * Read information about a CRTC
+ *
+ * @param crtc The state of the CRTC whose information should be read
+ * @param fields OR:ed identifiers for the information about the CRTC that should be read
+ * @return Input parameters for the constructor of {@link CRTCInformation}
+ */
+ private static native Object[] libgamma_get_crtc_information(long crtc, int fields);
+
+
+ /**
+ * Get the current gamma ramps for a CRTC, 8-bit gamma-depth version
+ *
+ * @param address The CRTC state
+ * @param ramps The gamma ramps to fill with the current values
+ * @return Zero on success, an error code on failure
+ */
+ private static native int libgamma_crtc_get_gamma_ramps8(long address, long ramps);
+
+ /**
+ * Set the gamma ramps for a CRTC, 8-bit gamma-depth version
+ *
+ * @param address The CRTC state
+ * @param ramps The gamma ramps to apply
+ * @return Zero on success, an error code on failure
+ */
+ private static native int libgamma_crtc_set_gamma_ramps8(long address, long ramps);
+
+
+ /**
+ * Get the current gamma ramps for a CRTC, 16-bit gamma-depth version
+ *
+ * @param address The CRTC state
+ * @param ramps The gamma ramps to fill with the current values
+ * @return Zero on success, an error code on failure
+ */
+ private static native int libgamma_crtc_get_gamma_ramps16(long address, long ramps);
+
+ /**
+ * Set the gamma ramps for a CRTC, 16-bit gamma-depth version
+ *
+ * @param address The CRTC state
+ * @param ramps The gamma ramps to apply
+ * @return Zero on success, an error code on failure
+ */
+ private static native int libgamma_crtc_set_gamma_ramps16(long address, long ramps);
+
+
+ /**
+ * Get the current gamma ramps for a CRTC, 32-bit gamma-depth version
+ *
+ * @param address The CRTC state
+ * @param ramps The gamma ramps to fill with the current values
+ * @return Zero on success, an error code on failure
+ */
+ private static native int libgamma_crtc_get_gamma_ramps32(long address, long ramps);
+
+ /**
+ * Set the gamma ramps for a CRTC, 32-bit gamma-depth version
+ *
+ * @param address The CRTC state
+ * @param ramps The gamma ramps to apply
+ * @return Zero on success, an error code on failure
+ */
+ private static native int libgamma_crtc_set_gamma_ramps32(long address, long ramps);
+
+
+ /**
+ * Get the current gamma ramps for a CRTC, 64-bit gamma-depth version
+ *
+ * @param address The CRTC state
+ * @param ramps The gamma ramps to fill with the current values
+ * @return Zero on success, an error code on failure
+ */
+ private static native int libgamma_crtc_get_gamma_ramps64(long address, long ramps);
+
+ /**
+ * Set the gamma ramps for a CRTC, 64-bit gamma-depth version
+ *
+ * @param address The CRTC state
+ * @param ramps The gamma ramps to apply
+ * @return Zero on success, an error code on failure
+ */
+ private static native int libgamma_crtc_set_gamma_ramps64(long address, long ramps);
+
+
+ /**
+ * Set the gamma ramps for a CRTC, single precision floating point version
+ *
+ * @param address The CRTC state
+ * @param ramps The gamma ramps to apply
+ * @return Zero on success, an error code on failure
+ */
+ private static native int libgamma_crtc_set_gamma_rampsf(long address, long ramps);
+
+ /**
+ * Get the current gamma ramps for a CRTC, single precision floating point version
+ *
+ * @param address The CRTC state
+ * @param ramps The gamma ramps to fill with the current values
+ * @return Zero on success, an error code on failure
+ */
+ private static native int libgamma_crtc_get_gamma_rampsf(long address, long ramps);
+
+
+ /**
+ * Get the current gamma ramps for a CRTC, double precision floating point version
+ *
+ * @param address The CRTC state
+ * @param ramps The gamma ramps to fill with the current values
+ * @return Zero on success, an error code on failure
+ */
+ private static native int libgamma_crtc_get_gamma_rampsd(long address, long ramps);
+
+ /**
+ * Set the gamma ramps for a CRTC, double precision floating point version
+ *
+ * @param address The CRTC state
+ * @param ramps The gamma ramps to apply
+ * @return Zero on success, an error code on failure
+ */
+ private static native int libgamma_crtc_set_gamma_rampsd(long address, long ramps);
+}
diff --git a/libgamma/CRTCInformation.java b/libgamma/CRTCInformation.java
new file mode 100644
index 0000000..dc9b759
--- /dev/null
+++ b/libgamma/CRTCInformation.java
@@ -0,0 +1,552 @@
+/* See LICENSE file for copyright and license details. */
+package libgamma;
+
+
+/**
+ * Cathode ray tube controller information data structure
+ */
+public class CRTCInformation
+{
+ /**
+ * Type initialiser
+ */
+ static
+ {
+ Libgamma.initialise();
+ }
+
+
+ /**
+ * For a {@link CRTCInformation} fill in the values for {@link #edid}
+ * and {@link #edid_length} and report errors to {@link #edid_error}
+ */
+ public static final int EDID = 1 << 0;
+
+ /**
+ * For a {@link CRTCInformation} fill in the value for
+ * {@link #width_mm} and report errors to {@link #width_mm_error}
+ */
+ public static final int WIDTH_MM = 1 << 1;
+
+ /**
+ * For a {@link CRTCInformation} fill in the value for
+ * {@link #height_mm} and report errors to {@link #height_mm_error}
+ */
+ public static final int HEIGHT_MM = 1 << 2;
+
+ /**
+ * For a {@link CRTCInformation} fill in the value for {@link #width_mm_edid}
+ * and report errors to {@link #width_mm_edid_error}
+ */
+ public static final int WIDTH_MM_EDID = 1 << 3;
+
+ /**
+ * For a {@link CRTCInformation} fill in the value for
+ * {@link #height_mm_edid} and report errors to {@link #height_mm_edid_error}
+ */
+ public static final int HEIGHT_MM_EDID = 1 << 4;
+
+ /**
+ * For a {@link CRTCInformation} fill in the values for
+ * {@link #red_gamma_size}, {@link #green_gamma_size} and
+ * {@link #blue_gamma_size}, and report errors to
+ * {@link #gamma_size_error}
+ */
+ public static final int GAMMA_SIZE = 1 << 5;
+
+ /**
+ * For a {@link CRTCInformation} fill in the value for
+ * {@link #gamma_depth} and report errors to {@link #gamma_depth_error}
+ */
+ public static final int GAMMA_DEPTH = 1 << 6;
+
+ /**
+ * For a {@link CRTCInformation} fill in the value for
+ * {@link #gamma_support} and report errors to {@link #gamma_support_error}
+ */
+ public static final int GAMMA_SUPPORT = 1 << 7;
+
+ /**
+ * For a {@link CRTCInformation} fill in the value for
+ * {@link #subpixel_order} and report errors to {@link #subpixel_order_error}
+ */
+ public static final int SUBPIXEL_ORDER = 1 << 8;
+
+ /**
+ * For a {@link CRTCInformation} fill in the value for
+ * {@link #active} and report errors to {@link #active_error}
+ */
+ public static final int ACTIVE = 1 << 9;
+
+ /**
+ * For a {@link CRTCInformation} fill in the value
+ * for {@link #connector_name} and report errors to
+ * {@link #connector_name_error}
+ */
+ public static final int CONNECTOR_NAME = 1 << 10;
+
+ /**
+ * For a {@link CRTCInformation} fill in the
+ * value for {@link #connector_type} and report
+ * errors to {@link #connector_type_error}
+ */
+ public static final int CONNECTOR_TYPE = 1 << 11;
+
+ /**
+ * For a {@link CRTCInformation} fill in the values for
+ * {@link #gamma_red}, {@link #gamma_green} and
+ * {@link #gamma_blue} and report errors to {@link #gamma_error}
+ */
+ public static final int GAMMA = 1 << 12;
+
+
+ /**
+ * The number of {@link #*} values defined
+ */
+ public static final int COUNT = 13;
+
+
+ /**
+ * Macro for both {@link CRTCInformation} fields
+ * that can specify the size of the monitor's viewport
+ * as specified in the monitor's Extended Display
+ * Information Data
+ */
+ public static final int MACRO_EDID_VIEWPORT = WIDTH_MM_EDID | HEIGHT_MM_EDID;
+
+ /**
+ * Macro for all {@link CRTCInformation} fields
+ * that can be filled if the adjustment method have
+ * support for reading the monitors' Extended Display
+ * Information Data
+ */
+ public static final int MACRO_EDID = EDID | MACRO_EDID_VIEWPORT | GAMMA;
+
+ /**
+ * Macro for both {@link CRTCInformation} fields
+ * that can specify the size of the monitor's viewport
+ * as provided by the adjustment method without this
+ * library having to parse the monitor's Extended Display
+ * Information Data
+ */
+ public static final int MACRO_VIEWPORT = WIDTH_MM | HEIGHT_MM;
+
+ /**
+ * Macro for the {@link CRTCInformation} fields
+ * that specifies the CRTC's gamma ramp sizes and gamma
+ * ramp depth
+ */
+ public static final int MACRO_RAMP = GAMMA_SIZE | GAMMA_DEPTH;
+
+ /**
+ * Macro for the {@link CRTCInformation} fields
+ * that specifies the CRTC's connector type and the
+ * partition unique name of the connector
+ */
+ public static final int MACRO_CONNECTOR = CONNECTOR_NAME | CONNECTOR_TYPE;
+
+ /**
+ * Macro for the {@link CRTCInformation} fields
+ * that required there is a monitor attached to
+ * the connector, and that status itself
+ */
+ public static final int MACRO_ACTIVE = MACRO_EDID | MACRO_VIEWPORT | SUBPIXEL_ORDER | ACTIVE;
+
+
+ /**
+ * Constructor
+ *
+ * @param edid The value for {@link edid}
+ * @param connector_name The value for {@link connector_name}
+ * @param gamma The values for {@link gamma_red},
+ * {@link gamma_green} and {@link gamma_blue}
+ * @param ints Values for the rest of the variables
+ */
+ public CRTCInformation(byte[] edid, String connector_name, float[] gamma, int[] ints)
+ {
+ this.edid = edid;
+ this.connector_name = connector_name;
+ this.gamma_red = gamma[0];
+ this.gamma_green = gamma[1];
+ this.gamma_blue = gamma[2];
+
+ this.edid_error = make_error(ints[0]);
+ this.width_mm = ints[1];
+ this.width_mm_error = make_error(ints[2]);
+ this.height_mm = ints[3];
+ this.height_mm_error = make_error(ints[4]);
+ this.width_mm_edid = ints[5];
+ this.width_mm_edid_error = make_error(ints[6]);
+ this.height_mm_edid = ints[7];
+ this.height_mm_edid_error = make_error(ints[8]);
+ this.red_gamma_size = ints[9];
+ this.green_gamma_size = ints[10];
+ this.blue_gamma_size = ints[11];
+ this.gamma_size_error = make_error(ints[12]);
+ this.gamma_depth = (short)(ints[13]);
+ this.gamma_depth_error = make_error(ints[14]);
+ this.gamma_support = ints[15] != 0;
+ this.gamma_support_error = make_error(ints[16]);
+ this.subpixel_order = SubpixelOrder.VALUES[ints[17]];
+ this.subpixel_order_error = make_error(ints[18]);
+ this.active = ints[19] != 0;
+ this.active_error = make_error(ints[20]);
+ this.connector_name_error = make_error(ints[21]);
+ this.connector_type = ConnectorType.VALUES[ints[22]];
+ this.connector_type_error = make_error(ints[23]);
+ this.gamma_error = make_error(ints[24]);
+
+ this.has_error = (this.edid_error != null)
+ || (this.width_mm_error != null)
+ || (this.height_mm_error != null)
+ || (this.width_mm_edid_error != null)
+ || (this.height_mm_edid_error != null)
+ || (this.gamma_size_error != null)
+ || (this.gamma_depth_error != null)
+ || (this.gamma_support_error != null)
+ || (this.subpixel_order_error != null)
+ || (this.connector_name_error != null)
+ || (this.connector_type_error != null);
+ }
+
+
+ /**
+ * Create an {@link LibgammaException} from an error code
+ *
+ * @param error_code The error code
+ * @return An {@link LibgammaException} for the error,
+ * {@code null} if <tt>error_code</tt> is zero
+ */
+ private static LibgammaException make_error(int error_code)
+ {
+ return error_code == 0 ? null : new LibgammaException(error_code);
+ }
+
+
+ /**
+ * The Extended Display Identification Data associated with
+ * the attached monitor. This is raw byte array that is usually
+ * 128 bytes long.
+ */
+ public final byte[] edid;
+
+ /**
+ * Error that occurred when fetching the value for
+ * {@link #edid}, {@code null} on success
+ */
+ public final LibgammaException edid_error;
+
+
+ /**
+ * The phyical width, in millimetres, of the viewport of the
+ * attached monitor, as reported by the adjustment method. This
+ * value may be incorrect, which is a known issue with the X
+ * server where it is the result of the X server attempting
+ * the estimate the size on its own.
+ * Zero means that its is not applicable, which is the case
+ * for projectors.
+ */
+ public final int width_mm;
+
+ /**
+ * Error that occurred when fetching the value for
+ * {@link #width_mm}, {@code null} on success
+ */
+ public final LibgammaException width_mm_error;
+
+
+ /**
+ * The phyical height, in millimetres, of the viewport of the
+ * attached monitor, as reported by the adjustment method. This
+ * value may be incorrect, which is a known issue with the X
+ * server where it is the result of the X server attempting
+ * the estimate the size on its own.
+ * Zero means that its is not applicable, which is the case
+ * for projectors.
+ */
+ public final int height_mm;
+
+ /**
+ * Error that occurred when fetching the value for
+ * {@link #height_mm}, {@code null} on success
+ */
+ public final LibgammaException height_mm_error;
+
+
+ /**
+ * The phyical width, in millimetres, of the viewport of the
+ * attached monitor, as reported by it the monitor's Extended
+ * Display Information Data. This value can only contain whole
+ * centimetres, which means that the result is always zero
+ * modulus ten. However, this could change with revisions of
+ * the EDID structure.
+ * Zero means that its is not applicable, which is the case
+ * for projectors.
+ */
+ public final int width_mm_edid;
+
+ /**
+ * Error that occurred when fetching the value for
+ * {@link #width_mm_edid}, {@code null} on success
+ */
+ public final LibgammaException width_mm_edid_error;
+
+
+ /**
+ * The phyical height, in millimetres, of the viewport of the
+ * attached monitor, as reported by it the monitor's Extended
+ * Display Information Data. This value can only contain whole
+ * centimetres, which means that the result is always zero
+ * modulus ten. However, this could change with revisions of
+ * the EDID structure.
+ * Zero means that its is not applicable, which is the case
+ * for projectors.
+ */
+ public final int height_mm_edid;
+
+ /**
+ * Error that occurred when fetching the value for
+ * {@link #height_mm_edid}, {@code null} on success
+ */
+ public final LibgammaException height_mm_edid_error;
+
+
+ /**
+ * The size of the encoding axis of the red gamma ramp
+ */
+ public final int red_gamma_size;
+
+ /**
+ * The size of the encoding axis of the green gamma ramp
+ */
+ public final int green_gamma_size;
+
+ /**
+ * The size of the encoding axis of the blue gamma ramp
+ */
+ public final int blue_gamma_size;
+
+ /**
+ * Error that occurred when fetching the values for
+ * {@link #red_gamma_size}, {@link #green_gamma_size}
+ * and {@link #blue_gamma_size}, {@code null} on success
+ */
+ public final LibgammaException gamma_size_error;
+
+
+ /**
+ * The bit-depth of the value axes of gamma ramps,
+ * -1 for single precision floating point, and -2 for
+ * double precision floating point
+ */
+ public final short gamma_depth;
+
+ /**
+ * Error that occurred when fetching the value for
+ * {@link #gamma_depth}, {@code null} on success
+ */
+ public final LibgammaException gamma_depth_error;
+
+
+ /**
+ * Whether gamma ramp adjustments are supported
+ */
+ public final boolean gamma_support;
+
+ /**
+ * Error that occurred when fetching the value for
+ * {@link #gamma_support}, {@code null} on success
+ */
+ public final LibgammaException gamma_support_error;
+
+
+ /**
+ * The layout of the subpixels
+ * <p>
+ * You cannot count on this value — especially for CRT:s —
+ * but it is provided anyway as a means of distinguishing monitors
+ */
+ public final SubpixelOrder subpixel_order;
+
+ /**
+ * Error that occurred when fetching the value for
+ * {@link #subpixel_order}, {@code null} on success
+ */
+ public final LibgammaException subpixel_order_error;
+
+
+ /**
+ * Whether there is a monitors connected to the CRTC
+ */
+ public final boolean active;
+
+ /**
+ * Error that occurred when fetching the value for
+ * {@link #active}, {@code null} on success
+ */
+ public final LibgammaException active_error;
+
+
+ /**
+ * The name of the connector as designated by the display
+ * server or as give by this library in case the display
+ * server lacks this feature
+ */
+ public final String connector_name;
+
+ /**
+ * Error that occurred when fetching the value for
+ * {@link #connector_name}, {@code null} on success
+ */
+ public final LibgammaException connector_name_error;
+
+
+ /**
+ * The type of the connector that is associated with the CRTC
+ */
+ public final ConnectorType connector_type;
+
+ /**
+ * Error that occurred when fetching the value for
+ * {@link #connector_type}, {@code null} on success
+ */
+ public final LibgammaException connector_type_error;
+
+
+ /**
+ * The gamma characteristics of the monitor as reported
+ * in its Extended Display Information Data. The value
+ * holds the value for the red channel. If you do not have
+ * and more accurate measurement of the gamma for the
+ * monitor this could be used to give a rought gamma
+ * correction; simply divide the value with 2.2 and use
+ * the result for the red channel in the gamma correction.
+ */
+ public final float gamma_red;
+
+ /**
+ * The gamma characteristics of the monitor as reported
+ * in its Extended Display Information Data. The value
+ * holds the value for the green channel. If you do not have
+ * and more accurate measurement of the gamma for the
+ * monitor this could be used to give a rought gamma
+ * correction; simply divide the value with 2.2 and use
+ * the result for the green channel in the gamma correction.
+ */
+ public final float gamma_green;
+
+ /**
+ * The gamma characteristics of the monitor as reported
+ * in its Extended Display Information Data. The value
+ * holds the value for the blue channel. If you do not have
+ * and more accurate measurement of the gamma for the
+ * monitor this could be used to give a rought gamma
+ * correction; simply divide the value with 2.2 and use
+ * the result for the blue channel in the gamma correction.
+ */
+ public final float gamma_blue;
+
+ /**
+ * Error that occurred when fetching the values for
+ * {@link #red_gamma}, {@link #green_gamma} and
+ * {@link #blue_gamma}, {@code null} on success
+ */
+ public final LibgammaException gamma_error;
+
+
+ /**
+ * Whether any of the error fields are non-{@code null}
+ */
+ public final boolean has_error;
+
+
+ /**
+ * Helper function for {@link #toString}
+ *
+ * @param error An error, may be {@code null}
+ * @return A textual representation of <tt>error</tt>
+ */
+ private static String errorToString(LibgammaException error)
+ {
+ return error == null ? "<null>" : error.toString();
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ String depth_str = Integer.toString(this.gamma_depth);
+ if (this.gamma_depth == -1) depth_str = "float";
+ if (this.gamma_depth == -2) depth_str = "double";
+
+ return "<CRTCInformation: " +
+ "edid = " + behex(this.edid) + ", " +
+ "edid_error = " + errorToString(this.edid_error) + ", " +
+ "width_mm = " + Integer.toString(this.width_mm) + ", " +
+ "width_mm_error = " + errorToString(this.width_mm_error) + ", " +
+ "height_mm = " + Integer.toString(this.height_mm) + ", " +
+ "height_mm_error = " + errorToString(this.height_mm_error) + ", " +
+ "width_mm_edid = " + Integer.toString(this.width_mm_edid) + ", " +
+ "width_mm_edid_error = " + errorToString(this.width_mm_edid_error) + ", " +
+ "height_mm_edid = " + Integer.toString(this.height_mm_edid) + ", " +
+ "height_mm_edid_error = " + errorToString(this.height_mm_edid_error) + ", " +
+ "red_gamma_size = " + Integer.toString(this.red_gamma_size) + ", " +
+ "green_gamma_size = " + Integer.toString(this.green_gamma_size) + ", " +
+ "blue_gamma_size = " + Integer.toString(this.blue_gamma_size) + ", " +
+ "gamma_size_error = " + errorToString(this.gamma_size_error) + ", " +
+ "gamma_depth = " + depth_str + ", " +
+ "gamma_depth_error = " + errorToString(this.gamma_depth_error) + ", " +
+ "gamma_support = " + Boolean.toString(this.gamma_support) + ", " +
+ "gamma_support_error = " + errorToString(this.gamma_support_error) + ", " +
+ "subpixel_order = " + this.subpixel_order.toString() + ", " +
+ "subpixel_order_error = " + errorToString(this.subpixel_order_error) + ", " +
+ "active = " + Boolean.toString(this.active) + ", " +
+ "active_error = " + errorToString(this.active_error) + ", " +
+ "connector_name = " + (this.connector_name == null ? "<null>" : this.connector_name) + ", " +
+ "connector_name_error = " + errorToString(this.connector_name_error) + ", " +
+ "connector_type = " + this.connector_type.toString() + ", " +
+ "connector_type_error = " + errorToString(this.connector_type_error) + ", " +
+ "gamma_red = " + Float.toString(this.gamma_red) + ", " +
+ "gamma_green = " + Float.toString(this.gamma_green) + ", " +
+ "gamma_blue = " + Float.toString(this.gamma_blue) + ", " +
+ "gamma_error = " + errorToString(this.gamma_error) + ", " +
+ "has_error = " + Boolean.toString(this.has_error) + ">";
+ }
+
+
+ /**
+ * Convert a raw representation of an EDID to a lowercase hexadecimal representation
+ *
+ * @param edid The EDID in raw representation
+ * @return The EDID in lowercase hexadecimal representation
+ */
+ public static String behex(byte[] edid)
+ {
+ char[] rc = new char[edid.length * 2];
+ for (int i = 0; i < edid.length; i++) {
+ rc[i * 2 + 0] = "0123456789abcdef".charAt((edid[i] >> 4) & 15);
+ rc[i * 2 + 1] = "0123456789abcdef".charAt((edid[i] >> 0) & 15);
+ }
+ return new String(rc);
+ }
+
+ /**
+ * Convert an hexadecimal representation of an EDID to a raw representation
+ *
+ * @param edid The EDID in hexadecimal representation
+ * @return The EDID in raw representation, it will be half the length
+ * of <tt>edid</tt> (the input value)
+ */
+ public static byte[] unhex(String edid)
+ {
+ byte[] rc = new byte[edid.length() / 2];
+ edid = edid.toLowerCase();
+ for (int i = 0; i < rc.length; i++) {
+ rc[i] = (byte)("0123456789abcdef".indexOf(edid.charAt(i * 2 + 0)) << 4);
+ rc[i] |= (byte)("0123456789abcdef".indexOf(edid.charAt(i * 2 + 1)) << 0);
+ }
+ return rc;
+ }
+}
diff --git a/libgamma/ConnectorType.java b/libgamma/ConnectorType.java
new file mode 100644
index 0000000..3f3aed1
--- /dev/null
+++ b/libgamma/ConnectorType.java
@@ -0,0 +1,148 @@
+/* See LICENSE file for copyright and license details. */
+package libgamma;
+
+
+/**
+ * Types for connectors
+ */
+public enum ConnectorType
+{
+ /**
+ * The adjustment method does not know the connector's type
+ * <p>
+ * (This could be considered an error)
+ */
+ Unknown(0),
+
+ /**
+ * Video Graphics Array (VGA)
+ */
+ VGA(1),
+
+ /**
+ * Digital Visual Interface, unknown type
+ */
+ DVI(2),
+
+ /**
+ * Digital Visual Interface, integrated (DVI-I)
+ */
+ DVII(3),
+
+ /**
+ * Digital Visual Interface, digital only (DVI-D)
+ */
+ DVID(4),
+
+ /**
+ * Digital Visual Interface, analogue only (DVI-A)
+ */
+ DVIA(5),
+
+ /**
+ * Composite video
+ */
+ Composite(6),
+
+ /**
+ * Separate Video (S-video)
+ */
+ SVIDEO(7),
+
+ /**
+ * Low-voltage differential signaling (LVDS)
+ */
+ LVDS(8),
+
+ /**
+ * Component video, usually separate cables for each channel
+ */
+ Component(9),
+
+ /**
+ * 9 pin DIN (Deutsches Institut für Normung) connector
+ */
+ NinePinDIN(10),
+
+ /**
+ * DisplayPort
+ */
+ DisplayPort(11),
+
+ /**
+ * High-Definition Multimedia Interface (HDMI), unknown type
+ */
+ HDMI(12),
+
+ /**
+ * High-Definition Multimedia Interface, type A (HDMI-A)
+ */
+ HDMIA(13),
+
+ /**
+ * High-Definition Multimedia Interface, type B (HDMI-B)
+ */
+ HDMIB(14),
+
+ /**
+ * Television, unknown connector
+ */
+ TV(15),
+
+ /**
+ * Embedded DisplayPort (eDP)
+ */
+ eDP(16),
+
+ /**
+ * A virtual connector
+ */
+ VIRTUAL(17),
+
+ /**
+ * Display Serial Interface (DSI)
+ */
+ DSI(18),
+
+ /**
+ * LFP connector
+ * <p>
+ * (If you know what this is add it to Wikipedia)
+ */
+ LFP(19);
+
+
+ /**
+ * Type initialiser
+ */
+ static
+ {
+ Libgamma.initialise();
+ }
+
+
+
+ /**
+ * Subpixel orders by their numerical values
+ */
+ public static ConnectorType[] VALUES =
+ {
+ Unknown, VGA, DVI, DVII, DVID, DVIA, Composite, SVIDEO, LVDS, Component,
+ NinePinDIN, DisplayPort, HDMI, HDMIA, HDMIB, TV, eDP, VIRTUAL, DSI, LFP
+ };
+
+ /**
+ * Constructor
+ *
+ * @param value The numerical value of the connector type
+ */
+ private ConnectorType(int value)
+ {
+ this.value = value;
+ }
+
+ /**
+ * The numerical value of the connector type
+ */
+ public int value;
+}
diff --git a/libgamma/GammaRamps.java b/libgamma/GammaRamps.java
new file mode 100644
index 0000000..8ea5d57
--- /dev/null
+++ b/libgamma/GammaRamps.java
@@ -0,0 +1,312 @@
+/* See LICENSE file for copyright and license details. */
+package libgamma;
+
+
+/**
+ * Gamma ramp structure
+ *
+ * @param <T> The ramp class, should be select in accordance
+ * with the <tt>depth</tt> parameter of the constructor:
+ * <p>
+ * 8: Ramp8<br>
+ * 16: Ramp16<br>
+ * 32: Ramp32<br>
+ * 64: Ramp64<br>
+ * -1: Rampf<br>
+ * -2: Rampd<br>
+ */
+public class GammaRamps<T extends Ramp>
+{
+ /**
+ * Type initialiser
+ */
+ static
+ {
+ Libgamma.initialise();
+ }
+
+
+ /**
+ * Constructor
+ *
+ * @param red_size The size of the encoding axis of the red gamma ramp
+ * @param green_size The size of the encoding axis of the green gamma ramp
+ * @param blue_size The size of the encoding axis of the blue gamma ramp
+ * @param depth The bit-depth of the value axes of gamma ramps,
+ * -1 for single precision floating point, and -2 for
+ * double precision floating point
+ */
+ public GammaRamps(int red_size, int green_size, int blue_size, int depth) throws LibgammaException
+ {
+ this(red_size, green_size, blue_size, (short)depth);
+ }
+
+ /**
+ * Constructor
+ *
+ * @param red_size The size of the encoding axis of the red gamma ramp
+ * @param green_size The size of the encoding axis of the green gamma ramp
+ * @param blue_size The size of the encoding axis of the blue gamma ramp
+ * @param depth The bit-depth of the value axes of gamma ramps,
+ * -1 for single precision floating point, and -2 for
+ * double precision floating point
+ */
+ @SuppressWarnings("unchecked")
+ public GammaRamps(int red_size, int green_size, int blue_size, short depth) throws LibgammaException
+ {
+ long[] r;
+ if (depth == 8) r = libgamma_gamma_ramps8_create (red_size, green_size, blue_size);
+ else if (depth == 16) r = libgamma_gamma_ramps16_create(red_size, green_size, blue_size);
+ else if (depth == 32) r = libgamma_gamma_ramps32_create(red_size, green_size, blue_size);
+ else if (depth == 64) r = libgamma_gamma_ramps64_create(red_size, green_size, blue_size);
+ else if (depth == -1) r = libgamma_gamma_rampsf_create (red_size, green_size, blue_size);
+ else if (depth == -2) r = libgamma_gamma_rampsd_create (red_size, green_size, blue_size);
+ else
+ throw new IllegalArgumentException("depth must be either of: 8, 16, 32, 64, -1, -2.");
+
+ if (r[4] != 0)
+ throw new LibgammaException((int)(r[4]));
+
+ this.address = r[0];
+ this.depth = depth;
+
+ Ramp red = null;
+ Ramp green = null;
+ Ramp blue = null;
+
+ if (depth == 8) red = (Ramp)(new Ramp8 (r[1], red_size));
+ else if (depth == 16) red = (Ramp)(new Ramp16(r[1], red_size));
+ else if (depth == 32) red = (Ramp)(new Ramp32(r[1], red_size));
+ else if (depth == 64) red = (Ramp)(new Ramp64(r[1], red_size));
+ else if (depth == -1) red = (Ramp)(new Rampf (r[1], red_size));
+ else if (depth == -2) red = (Ramp)(new Rampd (r[1], red_size));
+
+ if (depth == 8) green = (Ramp)(new Ramp8 (r[2], green_size));
+ else if (depth == 16) green = (Ramp)(new Ramp16(r[2], green_size));
+ else if (depth == 32) green = (Ramp)(new Ramp32(r[2], green_size));
+ else if (depth == 64) green = (Ramp)(new Ramp64(r[2], green_size));
+ else if (depth == -1) green = (Ramp)(new Rampf (r[2], green_size));
+ else if (depth == -2) green = (Ramp)(new Rampd (r[2], green_size));
+
+ if (depth == 8) blue = (Ramp)(new Ramp8 (r[3], blue_size));
+ else if (depth == 16) blue = (Ramp)(new Ramp16(r[3], blue_size));
+ else if (depth == 32) blue = (Ramp)(new Ramp32(r[3], blue_size));
+ else if (depth == 64) blue = (Ramp)(new Ramp64(r[3], blue_size));
+ else if (depth == -1) blue = (Ramp)(new Rampf (r[3], blue_size));
+ else if (depth == -2) blue = (Ramp)(new Rampd (r[3], blue_size));
+
+ this.red = (T)red;
+ this.green = (T)green;
+ this.blue = (T)blue;
+ }
+
+
+ /**
+ * The gamma ramp for the red channel
+ */
+ public final T red;
+
+ /**
+ * The gamma ramp for the green channel
+ */
+ public final T green;
+
+ /**
+ * The gamma ramp for the blue channel
+ */
+ public final T blue;
+
+ /**
+ * The bit-depth of the value axes of gamma ramps,
+ * -1 for single precision floating point, and -2 for
+ * double precision floating point
+ */
+ public final short depth;
+
+ /**
+ * The address of the native object
+ */
+ final long address;
+
+
+ /**
+ * Release resources
+ */
+ public void close()
+ {
+ if (this.depth == 8) libgamma_gamma_ramps8_free(this.address);
+ else if (this.depth == 16) libgamma_gamma_ramps16_free(this.address);
+ else if (this.depth == 32) libgamma_gamma_ramps32_free(this.address);
+ else if (this.depth == 64) libgamma_gamma_ramps64_free(this.address);
+ else if (this.depth == -1) libgamma_gamma_rampsf_free(this.address);
+ else if (this.depth == -2) libgamma_gamma_rampsd_free(this.address);
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ String depth_str = Integer.toString(this.depth);
+ if (this.depth == -1) depth_str = "float";
+ if (this.depth == -1) depth_str = "double";
+
+ return "<GammaRamps: depth = " + depth_str + ", " +
+ "red = " + this.red.toString() +
+ "green = " + this.green.toString() +
+ "blue = " + this.blue.toString() + ">";
+ }
+
+
+ /**
+ * Create and initialise a gamma ramp in the proper way that allows all adjustment
+ * methods to read from and write to it without causing segmentation violation
+ *
+ * @param red_size The size of the encoding axis of the red gamma ramp
+ * @param green_size The size of the encoding axis of the green gamma ramp
+ * @param blue_size The size of the encoding axis of the blue gamma ramp
+ * @return Element 0: The address of the native object<br>
+ * Element 1: The address of the red gamma ramp<br>
+ * Element 2: The address of the green gamma ramp<br>
+ * Element 3: The address of the blue gamma ramp<br>
+ * Element 4: Zero on success, an error code on error
+ */
+ private static native long[] libgamma_gamma_ramps8_create(int red_size, int green_size, int blue_size);
+
+ /**
+ * Create and initialise a gamma ramp in the proper way that allows all adjustment
+ * methods to read from and write to it without causing segmentation violation
+ *
+ * @param red_size The size of the encoding axis of the red gamma ramp
+ * @param green_size The size of the encoding axis of the green gamma ramp
+ * @param blue_size The size of the encoding axis of the blue gamma ramp
+ * @return Element 0: The address of the native object<br>
+ * Element 1: The address of the red gamma ramp<br>
+ * Element 2: The address of the green gamma ramp<br>
+ * Element 3: The address of the blue gamma ramp<br>
+ * Element 4: Zero on success, an error code on error
+ */
+ private static native long[] libgamma_gamma_ramps16_create(int red_size, int green_size, int blue_size);
+
+ /**
+ * Create and initialise a gamma ramp in the proper way that allows all adjustment
+ * methods to read from and write to it without causing segmentation violation
+ *
+ * @param red_size The size of the encoding axis of the red gamma ramp
+ * @param green_size The size of the encoding axis of the green gamma ramp
+ * @param blue_size The size of the encoding axis of the blue gamma ramp
+ * @return Element 0: The address of the native object<br>
+ * Element 1: The address of the red gamma ramp<br>
+ * Element 2: The address of the green gamma ramp<br>
+ * Element 3: The address of the blue gamma ramp<br>
+ * Element 4: Zero on success, an error code on error
+ */
+ private static native long[] libgamma_gamma_ramps32_create(int red_size, int green_size, int blue_size);
+
+ /**
+ * Create and initialise a gamma ramp in the proper way that allows all adjustment
+ * methods to read from and write to it without causing segmentation violation
+ *
+ * @param red_size The size of the encoding axis of the red gamma ramp
+ * @param green_size The size of the encoding axis of the green gamma ramp
+ * @param blue_size The size of the encoding axis of the blue gamma ramp
+ * @return Element 0: The address of the native object<br>
+ * Element 1: The address of the red gamma ramp<br>
+ * Element 2: The address of the green gamma ramp<br>
+ * Element 3: The address of the blue gamma ramp<br>
+ * Element 4: Zero on success, an error code on error
+ */
+ private static native long[] libgamma_gamma_ramps64_create(int red_size, int green_size, int blue_size);
+
+ /**
+ * Create and initialise a gamma ramp in the proper way that allows all adjustment
+ * methods to read from and write to it without causing segmentation violation
+ *
+ * @param red_size The size of the encoding axis of the red gamma ramp
+ * @param green_size The size of the encoding axis of the green gamma ramp
+ * @param blue_size The size of the encoding axis of the blue gamma ramp
+ * @return Element 0: The address of the native object<br>
+ * Element 1: The address of the red gamma ramp<br>
+ * Element 2: The address of the green gamma ramp<br>
+ * Element 3: The address of the blue gamma ramp<br>
+ * Element 4: Zero on success, an error code on error
+ */
+ private static native long[] libgamma_gamma_rampsf_create(int red_size, int green_size, int blue_size);
+
+ /**
+ * Create and initialise a gamma ramp in the proper way that allows all adjustment
+ * methods to read from and write to it without causing segmentation violation
+ *
+ * @param red_size The size of the encoding axis of the red gamma ramp
+ * @param green_size The size of the encoding axis of the green gamma ramp
+ * @param blue_size The size of the encoding axis of the blue gamma ramp
+ * @return Element 0: The address of the native object<br>
+ * Element 1: The address of the red gamma ramp<br>
+ * Element 2: The address of the green gamma ramp<br>
+ * Element 3: The address of the blue gamma ramp<br>
+ * Element 4: Zero on success, an error code on error
+ */
+ private static native long[] libgamma_gamma_rampsd_create(int red_size, int green_size, int blue_size);
+
+
+ /**
+ * Release resources that are held by a gamma ramp strcuture that
+ * has been allocated by {@link #libgamma_gamma_ramps8_create} or
+ * otherwise initialised in the proper manner, as well as release
+ * the pointer to the structure
+ *
+ * @param address The gamma ramps
+ */
+ private static native void libgamma_gamma_ramps8_free(long address);
+
+ /**
+ * Release resources that are held by a gamma ramp strcuture that
+ * has been allocated by {@link #libgamma_gamma_ramps16_create} or
+ * otherwise initialised in the proper manner, as well as release
+ * the pointer to the structure
+ *
+ * @param address The gamma ramps
+ */
+ private static native void libgamma_gamma_ramps16_free(long address);
+
+ /**
+ * Release resources that are held by a gamma ramp strcuture that
+ * has been allocated by {@link #libgamma_gamma_ramps32_create} or
+ * otherwise initialised in the proper manner, as well as release
+ * the pointer to the structure
+ *
+ * @param address The gamma ramps
+ */
+ private static native void libgamma_gamma_ramps32_free(long address);
+
+ /**
+ * Release resources that are held by a gamma ramp strcuture that
+ * has been allocated by {@link #libgamma_gamma_ramps64_create} or
+ * otherwise initialised in the proper manner, as well as release
+ * the pointer to the structure
+ *
+ * @param address The gamma ramps
+ */
+ private static native void libgamma_gamma_ramps64_free(long address);
+
+ /**
+ * Release resources that are held by a gamma ramp strcuture that
+ * has been allocated by {@link #libgamma_gamma_rampsf_create} or
+ * otherwise initialised in the proper manner, as well as release
+ * the pointer to the structure
+ *
+ * @param address The gamma ramps
+ */
+ private static native void libgamma_gamma_rampsf_free(long address);
+
+ /**
+ * Release resources that are held by a gamma ramp strcuture that
+ * has been allocated by {@link #libgamma_gamma_rampsd_create} or
+ * otherwise initialised in the proper manner, as well as release
+ * the pointer to the structure
+ *
+ * @param address The gamma ramps
+ */
+ private static native void libgamma_gamma_rampsd_free(long address);
+}
diff --git a/libgamma/Libgamma.java b/libgamma/Libgamma.java
new file mode 100644
index 0000000..98e086c
--- /dev/null
+++ b/libgamma/Libgamma.java
@@ -0,0 +1,30 @@
+/* See LICENSE file for copyright and license details. */
+package libgamma;
+
+
+/**
+ * Library initialisation class
+ */
+class Libgamma
+{
+ /**
+ * Initialise the library
+ */
+ static void initialise()
+ {
+ if (Libgamma.initialised)
+ return;
+ Libgamma.initialised = true;
+
+ try {
+ System.loadLibrary("gamma-java");
+ } catch (Throwable err) {
+ throw new Error(err);
+ }
+ }
+
+ /**
+ * Whether {@link #initialise} has been invoked
+ */
+ private static boolean initialised = false;
+}
diff --git a/libgamma/LibgammaException.java b/libgamma/LibgammaException.java
new file mode 100644
index 0000000..63d8b09
--- /dev/null
+++ b/libgamma/LibgammaException.java
@@ -0,0 +1,411 @@
+/* See LICENSE file for copyright and license details. */
+package libgamma;
+
+
+/**
+ * Class of <tt>libgamma</tt> exceptions including
+ * native system exceptions
+ * <p>
+ * The class contains constants with <tt>libgamma</tt> error
+ * codes. It does however not contain system error codes.
+ */
+@SuppressWarnings("serial")
+public class LibgammaException extends Exception
+{
+ /**
+ * Type initialiser
+ */
+ static
+ {
+ Libgamma.initialise();
+ }
+
+
+ /**
+ * This error code is never used. It is only provided
+ * so you know its error code if you plan to iterate
+ * over all <tt>libgamma</tt> error codes.
+ */
+ public static final int LIBGAMMA_ERRNO_SET = -1;
+
+ /**
+ * The selected adjustment method does not exist
+ * or has been excluded at compile-time
+ */
+ public static final int LIBGAMMA_NO_SUCH_ADJUSTMENT_METHOD = -2;
+
+ /**
+ * The selected site does not exist
+ */
+ public static final int LIBGAMMA_NO_SUCH_SITE = -3;
+
+ /**
+ * The selected partition does not exist
+ */
+ public static final int LIBGAMMA_NO_SUCH_PARTITION = -4;
+
+ /**
+ * The selected CRTC does not exist
+ */
+ public static final int LIBGAMMA_NO_SUCH_CRTC = -5;
+
+ /**
+ * Counter overflowed when counting the number
+ * of available items
+ */
+ public static final int LIBGAMMA_IMPOSSIBLE_AMOUNT = -6;
+
+ /**
+ * The selected connector is disabled, it does
+ * not have a CRTC
+ */
+ public static final int LIBGAMMA_CONNECTOR_DISABLED = -7;
+
+ /**
+ * The selected CRTC could not be opened,
+ * reason unknown
+ */
+ public static final int LIBGAMMA_OPEN_CRTC_FAILED = -8;
+
+ /**
+ * The CRTC information field is not supported
+ * by the adjustment method
+ */
+ public static final int LIBGAMMA_CRTC_INFO_NOT_SUPPORTED = -9;
+
+ /**
+ * Failed to read the current gamma ramps for
+ * the selected CRTC, reason unknown
+ */
+ public static final int LIBGAMMA_GAMMA_RAMP_READ_FAILED = -10;
+
+ /**
+ * Failed to write the current gamma ramps for
+ * the selected CRTC, reason unknown
+ */
+ public static final int LIBGAMMA_GAMMA_RAMP_WRITE_FAILED = -11;
+
+ /**
+ * The specified ramp sizes does not match the
+ * ramps sizes returned by the adjustment methods
+ * in response to the query/command
+ */
+ public static final int LIBGAMMA_GAMMA_RAMP_SIZE_CHANGED = -12;
+
+ /**
+ * The specified ramp sizes are not identical
+ * which is required by the adjustment method
+ * <p>
+ * (Only returned in debug mode)
+ */
+ public static final int LIBGAMMA_MIXED_GAMMA_RAMP_SIZE = -13;
+
+ /**
+ * The specified ramp sizes are not supported
+ * by the adjustment method
+ * <p>
+ * (Only returned in debug mode)
+ */
+ public static final int LIBGAMMA_WRONG_GAMMA_RAMP_SIZE = -14;
+
+ /**
+ * The adjustment method reported that the gamma
+ * ramps size is 1, or perhaps even zero or negative
+ */
+ public static final int LIBGAMMA_SINGLETON_GAMMA_RAMP = -15;
+
+ /**
+ * The adjustment method failed to list
+ * available CRTC:s, reason unknown
+ */
+ public static final int LIBGAMMA_LIST_CRTCS_FAILED = -16;
+
+ /**
+ * Failed to acquire mode resources from the
+ * adjustment method
+ */
+ public static final int LIBGAMMA_ACQUIRING_MODE_RESOURCES_FAILED = -17;
+
+ /**
+ * The adjustment method reported that a negative
+ * number of partitions exists in the site
+ */
+ public static final int LIBGAMMA_NEGATIVE_PARTITION_COUNT = -18;
+
+ /**
+ * The adjustment method reported that a negative
+ * number of CRTC:s exists in the partition
+ */
+ public static final int LIBGAMMA_NEGATIVE_CRTC_COUNT = -19;
+
+ /**
+ * Device cannot be access becauses of
+ * insufficient permissions
+ */
+ public static final int LIBGAMMA_DEVICE_RESTRICTED = -20;
+
+ /**
+ * Device cannot be access, reason unknown
+ */
+ public static final int LIBGAMMA_DEVICE_ACCESS_FAILED = -21;
+
+ /**
+ * Device cannot be access, membership of the
+ * {@link #group_gid} (named by {@link #group_name}
+ * (can be {@code null}, if so <tt>errno</tt> may have
+ * been set to tell why)) is required
+ */
+ public static final int LIBGAMMA_DEVICE_REQUIRE_GROUP = -22;
+
+ /**
+ * The graphics card appear to have been removed
+ */
+ public static final int LIBGAMMA_GRAPHICS_CARD_REMOVED = -23;
+
+ /**
+ * The state of the requested information is unknown
+ */
+ public static final int LIBGAMMA_STATE_UNKNOWN = -24;
+
+ /**
+ * Failed to determine which connector the
+ * CRTC belongs to
+ */
+ public static final int LIBGAMMA_CONNECTOR_UNKNOWN = -25;
+
+ /**
+ * The detected connector type is not listed
+ * in this library and has to be updated
+ */
+ public static final int LIBGAMMA_CONNECTOR_TYPE_NOT_RECOGNISED = -26;
+
+ /**
+ * The detected subpixel order is not listed
+ * in this library and has to be updated
+ */
+ public static final int LIBGAMMA_SUBPIXEL_ORDER_NOT_RECOGNISED = -27;
+
+ /**
+ * The length of the EDID does not match that
+ * of any supported EDID structure revision
+ */
+ public static final int LIBGAMMA_EDID_LENGTH_UNSUPPORTED = -28;
+
+ /**
+ * The magic number in the EDID does not match
+ * that of any supported EDID structure revision
+ */
+ public static final int LIBGAMMA_EDID_WRONG_MAGIC_NUMBER = -29;
+
+ /**
+ * The EDID structure revision used by the
+ * mointor is not supported
+ */
+ public static final int LIBGAMMA_EDID_REVISION_UNSUPPORTED = -30;
+
+ /**
+ * The gamma characteristics field in the EDID
+ * is left unspecified
+ * <p>
+ * (This could be considered a non-error)
+ */
+ public static final int LIBGAMMA_GAMMA_NOT_SPECIFIED = -31;
+
+ /**
+ * The checksum in the EDID is incorrect, all
+ * request information has been provided
+ * by you cannot count on it
+ */
+ public static final int LIBGAMMA_EDID_CHECKSUM_ERROR = -32;
+
+ /**
+ * Both of the errors {@link #LIBGAMMA_GAMMA_NOT_SPECIFIED}
+ * and {@link #LIBGAMMA_EDID_CHECKSUM_ERROR} have occurred
+ */
+ public static final int LIBGAMMA_GAMMA_NOT_SPECIFIED_AND_EDID_CHECKSUM_ERROR = -33;
+
+ /**
+ * Failed to query the gamma ramps size from the
+ * adjustment method, reason unknown
+ */
+ public static final int LIBGAMMA_GAMMA_RAMPS_SIZE_QUERY_FAILED = -34;
+
+ /**
+ * The selected partition could not be opened,
+ * reason unknown
+ */
+ public static final int LIBGAMMA_OPEN_PARTITION_FAILED = -35;
+
+ /**
+ * The selected site could not be opened,
+ * reason unknown
+ */
+ public static final int LIBGAMMA_OPEN_SITE_FAILED = -36;
+
+ /**
+ * Failed to query the adjustment method for
+ * its protocol version, reason unknown
+ */
+ public static final int LIBGAMMA_PROTOCOL_VERSION_QUERY_FAILED = -37;
+
+ /**
+ * The adjustment method's version of its
+ * protocol is not supported
+ */
+ public static final int LIBGAMMA_PROTOCOL_VERSION_NOT_SUPPORTED = -38;
+
+ /**
+ * The adjustment method failed to list
+ * available partitions, reason unknown
+ */
+ public static final int LIBGAMMA_LIST_PARTITIONS_FAILED = -39;
+
+ /**
+ * Partition exists by index, but the partition
+ * at that index does not exist
+ */
+ public static final int LIBGAMMA_NULL_PARTITION = -40;
+
+ /**
+ * There is not mointor connected to the
+ * connector of the selected CRTC
+ */
+ public static final int LIBGAMMA_NOT_CONNECTED = -41;
+
+ /**
+ * Data extraction from a reply from the
+ * adjustment method failed, reason unknown
+ */
+ public static final int LIBGAMMA_REPLY_VALUE_EXTRACTION_FAILED = -42;
+
+ /**
+ * No EDID property was found on the output
+ */
+ public static final int LIBGAMMA_EDID_NOT_FOUND = -43;
+
+ /**
+ * Failed to list properties on the output,
+ * reason unknown
+ */
+ public static final int LIBGAMMA_LIST_PROPERTIES_FAILED = -44;
+
+ /**
+ * Failed to query a property's value from
+ * the output, reason unknown
+ */
+ public static final int LIBGAMMA_PROPERTY_VALUE_QUERY_FAILED = -45;
+
+ /**
+ * A request for information on an output
+ * failed, reason unknown
+ */
+ public static final int LIBGAMMA_OUTPUT_INFORMATION_QUERY_FAILED = -46;
+
+
+ /**
+ * The number of the libgamma error with the
+ * lowest number. If this is lower than the
+ * number your program thinks it should be sould
+ * update your program for new errors.
+ */
+ public static final int LIBGAMMA_ERROR_MIN = -46;
+
+
+ /**
+ * Constructor
+ *
+ * @param error_code The error code
+ */
+ public LibgammaException(int error_code)
+ {
+ this.error_code = error_code;
+ if (error_code == LIBGAMMA_DEVICE_REQUIRE_GROUP) {
+ this.group_gid = libgamma_group_gid();
+ this.group_name = libgamma_group_name();
+ } else {
+ this.group_gid = 0;
+ this.group_name = null;
+ }
+ this.string = error_code < 0 ? name_of_error(error_code) : strerror(error_code);
+ }
+
+
+ /**
+ * The error code
+ * <p>
+ * Cannot be {@link #LIBGAMMA_ERRNO_SET}
+ */
+ public final int error_code;
+
+ /**
+ * Group that the user needs to be a member of if
+ * {@link #error_code} is {@link #LIBGAMMA_DEVICE_REQUIRE_GROUP}
+ */
+ public final int group_gid;
+
+ /**
+ * Group that the user needs to be a member of if
+ * {@link #error_code} is {@link #LIBGAMMA_DEVICE_REQUIRE_GROUP},
+ * {@code null} if the name of the group {@link #group_gid}
+ * cannot be determined
+ */
+ public final String group_name;
+
+ /**
+ * Name of textual description of the error
+ */
+ public final String string;
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString()
+ {
+ return this.string;
+ }
+
+
+ /**
+ * Returns the name of the definition associated with
+ * a <tt>libgamma</tt> error code
+ *
+ * @param value The error code
+ * @return The name of the definition associated with the error code,
+ * {@code null} if the error code does not exist
+ */
+ public static native String name_of_error(int value);
+
+ /**
+ * Return the value of a <tt>libgamma</tt> error definition
+ * refered to by name
+ *
+ * @param name The name of the definition associated with the error code
+ * @return The error code, zero if the name is {@code null}
+ * or does not refer to a <tt>libgamma</tt> error
+ */
+ public static native int value_of_error(String name);
+
+ /**
+ * Acquire the value that should go to {@link #group_gid}
+ *
+ * @return The value that should go to {@link #group_gid}
+ */
+ private static native int libgamma_group_gid();
+
+ /**
+ * Acquire the value that should go to {@link #group_name}
+ *
+ * @return The value that should go to {@link #group_name}
+ */
+ private static native String libgamma_group_name();
+
+ /**
+ * Get a textual description of a system error code
+ *
+ * @param error_code The error code
+ * @return A textual description of the error code
+ */
+ private static native String strerror(int error_code);
+}
diff --git a/libgamma/Partition.java b/libgamma/Partition.java
new file mode 100644
index 0000000..cb480d3
--- /dev/null
+++ b/libgamma/Partition.java
@@ -0,0 +1,125 @@
+/* See LICENSE file for copyright and license details. */
+package libgamma;
+
+
+/**
+ * Partition state
+ * <p>
+ * Probably the majority of display server only one partition
+ * per site. However, X.org can, and traditional used to have
+ * on multi-headed environments, multiple partitions per site.
+ * In X.org partitions are called 'screens'. It is not to be
+ * confused with monitor. A screen is a collection of monitors,
+ * and the mapping from monitors to screens is a surjection.
+ * On hardware-level adjustment methods, such as Direct
+ * Rendering Manager, a partition is a graphics card.
+ */
+public class Partition
+{
+ /**
+ * Type initialiser
+ */
+ static
+ {
+ Libgamma.initialise();
+ }
+
+
+ /**
+ * Constructor
+ *
+ * @param site The site this partition belongs to
+ * @param partition The index of the partition
+ */
+ public Partition(Site site, int partition) throws LibgammaException
+ {
+ this.site = site;
+ this.partition = partition;
+ long[] r = libgamma_partition_create(site.address, partition);
+ this.address = r[0];
+ this.crtcs_available = (int)(r[1]);
+ if (r[2] != 0)
+ throw new LibgammaException((int)(r[2]));
+ }
+
+
+ /**
+ * The site this partition belongs to
+ */
+ public final Site site;
+
+ /**
+ * The index of the partition
+ */
+ public final int partition;
+
+ /**
+ * The number of CRTC:s that are available under this
+ * partition. Note that the CRTC:s are not necessarily
+ * online.
+ */
+ public final int crtcs_available;
+
+ /**
+ * The address of the native object
+ */
+ final long address;
+
+
+ /**
+ * Release resources
+ */
+ public void close()
+ {
+ libgamma_partition_free(this.address);
+ }
+
+ /**
+ * Restore the gamma ramps all CRTC:s within the partition to the system settings
+ */
+ public void restore() throws LibgammaException
+ {
+ int r = libgamma_partition_restore(this.address);
+ if (r != 0)
+ throw new LibgammaException(r);
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ return "<Partition: site = " + this.site.toString() + ", " +
+ "partition = " + Integer.toString(this.partition) + ", " +
+ "crtcs_available = " + Integer.toString(this.crtcs_available) + ">";
+ }
+
+
+ /**
+ * Create a partition state
+ *
+ * @param site The site state for the site that the partition belongs to
+ * @param partition The index of the partition within the site
+ * @return Element 0: The value for {@link #address}<br>
+ * Element 1: The value for {@link #crtcs_available}<br>
+ * Element 2: Error code, zero on success
+ */
+ private static native long[] libgamma_partition_create(long site, int partition);
+
+ /**
+ * Release all resources held by a partition state
+ * and free the partition state pointer
+ *
+ * @param address The partition state
+ */
+ private static native void libgamma_partition_free(long address);
+
+ /**
+ * Restore the gamma ramps all CRTC:s within a partition to the system settings
+ *
+ * @param address The partition state
+ * @return Zero on success, and error code on failure
+ */
+ private static native int libgamma_partition_restore(long address);
+}
diff --git a/libgamma/Ramp.java b/libgamma/Ramp.java
new file mode 100644
index 0000000..6f66683
--- /dev/null
+++ b/libgamma/Ramp.java
@@ -0,0 +1,160 @@
+/* See LICENSE file for copyright and license details. */
+package libgamma;
+
+
+/**
+ * A single gamma ramp
+ */
+public abstract class Ramp
+{
+ /**
+ * Type initialiser
+ */
+ static
+ {
+ Libgamma.initialise();
+ }
+
+
+ /**
+ * Constructor
+ *
+ * @param address The address of the native object
+ * @param size The size of the encoding axis of the gamma ramp
+ */
+ Ramp(long address, int size)
+ {
+ this.size = size;
+ this.address = address;
+ }
+
+
+ /**
+ * The size of the encoding axis of the gamma ramp
+ */
+ public final int size;
+
+ /**
+ * The address of the native object
+ */
+ protected final long address;
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ return "<Ramp: size = " + Integer.toString(size) + ">";
+ }
+
+
+ /**
+ * Read the value of a stop in an 8-bit ramp
+ *
+ * @param address The address of the ramp
+ * @param stop The index of the stop
+ * @return The value of the stop
+ */
+ protected static native short libgamma_gamma_ramps8_get(long address, int stop);
+
+ /**
+ * Read the value of a stop in a 16-bit ramp
+ *
+ * @param address The address of the ramp
+ * @param stop The index of the stop
+ * @return The value of the stop
+ */
+ protected static native int libgamma_gamma_ramps16_get(long address, int stop);
+
+ /**
+ * Read the value of a stop in a 32-bit ramp
+ *
+ * @param address The address of the ramp
+ * @param stop The index of the stop
+ * @return The value of the stop
+ */
+ protected static native long libgamma_gamma_ramps32_get(long address, int stop);
+
+ /**
+ * Read the value of a stop in a 64-bit ramp
+ *
+ * @param address The address of the ramp
+ * @param stop The index of the stop
+ * @return The value of the stop
+ */
+ protected static native long libgamma_gamma_ramps64_get(long address, int stop);
+
+ /**
+ * Read the value of a stop in a single precision floating point ramp
+ *
+ * @param address The address of the ramp
+ * @param stop The index of the stop
+ * @return The value of the stop
+ */
+ protected static native float libgamma_gamma_rampsf_get(long address, int stop);
+
+ /**
+ * Read the value of a stop in a double precision floating point ramp
+ *
+ * @param address The address of the ramp
+ * @param stop The index of the stop
+ * @return The value of the stop
+ */
+ protected static native double libgamma_gamma_rampsd_get(long address, int stop);
+
+
+ /**
+ * Set the value of a stop in an 8-bit ramp
+ *
+ * @param address The address of the ramp
+ * @param stop The index of the stop
+ * @param value The value of the stop
+ */
+ protected static native void libgamma_gamma_ramps8_set(long address, int stop, short value);
+
+ /**
+ * Set the value of a stop in a 16-bit ramp
+ *
+ * @param address The address of the ramp
+ * @param stop The index of the stop
+ * @param value The value of the stop
+ */
+ protected static native void libgamma_gamma_ramps16_set(long address, int stop, int value);
+
+ /**
+ * Set the value of a stop in a 32-bit ramp
+ *
+ * @param address The address of the ramp
+ * @param stop The index of the stop
+ * @param value The value of the stop
+ */
+ protected static native void libgamma_gamma_ramps32_set(long address, int stop, long value);
+
+ /**
+ * Set the value of a stop in a 64-bit ramp
+ *
+ * @param address The address of the ramp
+ * @param stop The index of the stop
+ * @param value The value of the stop
+ */
+ protected static native void libgamma_gamma_ramps64_set(long address, int stop, long value);
+
+ /**
+ * Set the value of a stop in a single precision floating point ramp
+ *
+ * @param address The address of the ramp
+ * @param stop The index of the stop
+ * @param value The value of the stop
+ */
+ protected static native void libgamma_gamma_rampsf_set(long address, int stop, float value);
+
+ /**
+ * Set the value of a stop in a double precision floating point ramp
+ *
+ * @param address The address of the ramp
+ * @param stop The index of the stop
+ * @param value The value of the stop
+ */
+ protected static native void libgamma_gamma_rampsd_set(long address, int stop, double value);
+}
diff --git a/libgamma/Ramp16.java b/libgamma/Ramp16.java
new file mode 100644
index 0000000..a78bf2e
--- /dev/null
+++ b/libgamma/Ramp16.java
@@ -0,0 +1,79 @@
+/* See LICENSE file for copyright and license details. */
+package libgamma;
+
+
+/**
+ * A single 16-bit gamma ramp
+ */
+public class Ramp16 extends Ramp
+{
+ /**
+ * Type initialiser
+ */
+ static
+ {
+ Libgamma.initialise();
+ }
+
+
+ /**
+ * Constructor
+ *
+ * @param address The address of the native object
+ * @param size The size of the encoding axis of the gamma ramp
+ */
+ Ramp16(long address, int size)
+ {
+ super(address, size);
+ }
+
+ /**
+ * Read the value of a stop
+ *
+ * @param stop The index of the stop
+ * @return The value of the stop
+ */
+ public int get(int stop)
+ {
+ return libgamma_gamma_ramps16_get(this.address, stop);
+ }
+
+ /**
+ * Read the value of a stop
+ *
+ * @param stop The index of the stop
+ * @param value The new value of the stop
+ * @return The new value of the stop
+ */
+ public long set(int stop, long value)
+ {
+ libgamma_gamma_ramps16_set(this.address, stop, (int)value);
+ return value;
+ }
+
+ /**
+ * Read the value of a stop
+ *
+ * @param stop The index of the stop
+ * @param value The new value of the stop
+ * @return The new value of the stop
+ */
+ public int set(int stop, int value)
+ {
+ libgamma_gamma_ramps16_set(this.address, stop, value);
+ return value;
+ }
+
+ /**
+ * Read the value of a stop
+ *
+ * @param stop The index of the stop
+ * @param value The new value of the stop
+ * @return The new value of the stop
+ */
+ public short set(int stop, short value)
+ {
+ libgamma_gamma_ramps16_set(this.address, stop, value);
+ return value;
+ }
+}
diff --git a/libgamma/Ramp32.java b/libgamma/Ramp32.java
new file mode 100644
index 0000000..27e3ebc
--- /dev/null
+++ b/libgamma/Ramp32.java
@@ -0,0 +1,57 @@
+/* See LICENSE file for copyright and license details. */
+package libgamma;
+
+
+/**
+ * A single 32-bit gamma ramp
+ */
+public class Ramp32 extends Ramp
+{
+ /**
+ * Constructor
+ *
+ * @param address The address of the native object
+ * @param size The size of the encoding axis of the gamma ramp
+ */
+ Ramp32(long address, int size)
+ {
+ super(address, size);
+ }
+
+ /**
+ * Read the value of a stop
+ *
+ * @param stop The index of the stop
+ * @return The value of the stop
+ */
+ public long get(int stop)
+ {
+ return libgamma_gamma_ramps32_get(this.address, stop);
+ }
+
+ /**
+ * Read the value of a stop
+ *
+ * @param stop The index of the stop
+ * @param value The new value of the stop
+ * @return The new value of the stop
+ */
+ public long set(int stop, long value)
+ {
+ libgamma_gamma_ramps32_set(this.address, stop, value);
+ return value;
+ }
+
+ /**
+ * Read the value of a stop
+ *
+ * @param stop The index of the stop
+ * @param value The new value of the stop
+ * @return The new value of the stop
+ */
+ public int set(int stop, int value)
+ {
+ libgamma_gamma_ramps32_set(this.address, stop, value);
+ return value;
+ }
+}
diff --git a/libgamma/Ramp64.java b/libgamma/Ramp64.java
new file mode 100644
index 0000000..8a5db0a
--- /dev/null
+++ b/libgamma/Ramp64.java
@@ -0,0 +1,44 @@
+/* See LICENSE file for copyright and license details. */
+package libgamma;
+
+
+/**
+ * A single 64-bit gamma ramp
+ */
+public class Ramp64 extends Ramp
+{
+ /**
+ * Constructor
+ *
+ * @param address The address of the native object
+ * @param size The size of the encoding axis of the gamma ramp
+ */
+ Ramp64(long address, int size)
+ {
+ super(address, size);
+ }
+
+ /**
+ * Read the value of a stop
+ *
+ * @param stop The index of the stop
+ * @return The value of the stop
+ */
+ public long get(int stop)
+ {
+ return libgamma_gamma_ramps64_get(this.address, stop);
+ }
+
+ /**
+ * Read the value of a stop
+ *
+ * @param stop The index of the stop
+ * @param value The new value of the stop
+ * @return The new value of the stop
+ */
+ public long set(int stop, long value)
+ {
+ libgamma_gamma_ramps64_set(this.address, stop, value);
+ return value;
+ }
+}
diff --git a/libgamma/Ramp8.java b/libgamma/Ramp8.java
new file mode 100644
index 0000000..ff7d36e
--- /dev/null
+++ b/libgamma/Ramp8.java
@@ -0,0 +1,83 @@
+/* See LICENSE file for copyright and license details. */
+package libgamma;
+
+
+/**
+ * A single 8-bit gamma ramp
+ */
+public class Ramp8 extends Ramp
+{
+ /**
+ * Constructor
+ *
+ * @param address The address of the native object
+ * @param size The size of the encoding axis of the gamma ramp
+ */
+ Ramp8(long address, int size)
+ {
+ super(address, size);
+ }
+
+ /**
+ * Read the value of a stop
+ *
+ * @param stop The index of the stop
+ * @return The value of the stop
+ */
+ public short get(short stop)
+ {
+ return libgamma_gamma_ramps8_get(this.address, stop);
+ }
+
+ /**
+ * Read the value of a stop
+ *
+ * @param stop The index of the stop
+ * @param value The new value of the stop
+ * @return The new value of the stop
+ */
+ public long set(int stop, long value)
+ {
+ libgamma_gamma_ramps8_set(this.address, stop, (short)value);
+ return value;
+ }
+
+ /**
+ * Read the value of a stop
+ *
+ * @param stop The index of the stop
+ * @param value The new value of the stop
+ * @return The new value of the stop
+ */
+ public int set(int stop, int value)
+ {
+ libgamma_gamma_ramps8_set(this.address, stop, (short)value);
+ return value;
+ }
+
+ /**
+ * Read the value of a stop
+ *
+ * @param stop The index of the stop
+ * @param value The new value of the stop
+ * @return The new value of the stop
+ */
+ public short set(int stop, short value)
+ {
+ libgamma_gamma_ramps8_set(this.address, stop, value);
+ return value;
+ }
+
+ /**
+ * Read the value of a stop
+ *
+ * @param stop The index of the stop
+ * @param value The new value of the stop
+ * @return The new value of the stop
+ */
+ public byte set(int stop, byte value)
+ {
+ libgamma_gamma_ramps8_set(this.address, stop, value);
+ return value;
+ }
+}
diff --git a/libgamma/Rampd.java b/libgamma/Rampd.java
new file mode 100644
index 0000000..e1a3ad8
--- /dev/null
+++ b/libgamma/Rampd.java
@@ -0,0 +1,66 @@
+/* See LICENSE file for copyright and license details. */
+package libgamma;
+
+
+/**
+ * A single double percision floating point gamma ramp
+ */
+public class Rampd extends Ramp
+{
+ /**
+ * Type initialiser
+ */
+ static
+ {
+ Libgamma.initialise();
+ }
+
+
+ /**
+ * Constructor
+ *
+ * @param address The address of the native object
+ * @param size The size of the encoding axis of the gamma ramp
+ */
+ Rampd(long address, int size)
+ {
+ super(address, size);
+ }
+
+ /**
+ * Read the value of a stop
+ *
+ * @param stop The index of the stop
+ * @return The value of the stop
+ */
+ public double get(int stop)
+ {
+ return libgamma_gamma_rampsd_get(this.address, stop);
+ }
+
+ /**
+ * Read the value of a stop
+ *
+ * @param stop The index of the stop
+ * @param value The new value of the stop
+ * @return The new value of the stop
+ */
+ public float set(int stop, float value)
+ {
+ libgamma_gamma_rampsd_set(this.address, stop, value);
+ return value;
+ }
+
+ /**
+ * Read the value of a stop
+ *
+ * @param stop The index of the stop
+ * @param value The new value of the stop
+ * @return The new value of the stop
+ */
+ public double set(int stop, double value)
+ {
+ libgamma_gamma_rampsd_set(this.address, stop, value);
+ return value;
+ }
+}
diff --git a/libgamma/Rampf.java b/libgamma/Rampf.java
new file mode 100644
index 0000000..fcfa7b5
--- /dev/null
+++ b/libgamma/Rampf.java
@@ -0,0 +1,57 @@
+/* See LICENSE file for copyright and license details. */
+package libgamma;
+
+
+/**
+ * A single single percision floating point gamma ramp
+ */
+public class Rampf extends Ramp
+{
+ /**
+ * Constructor
+ *
+ * @param address The address of the native object
+ * @param size The size of the encoding axis of the gamma ramp
+ */
+ Rampf(long address, int size)
+ {
+ super(address, size);
+ }
+
+ /**
+ * Read the value of a stop
+ *
+ * @param stop The index of the stop
+ * @return The value of the stop
+ */
+ public float get(int stop)
+ {
+ return libgamma_gamma_rampsf_get(this.address, stop);
+ }
+
+ /**
+ * Read the value of a stop
+ *
+ * @param stop The index of the stop
+ * @param value The new value of the stop
+ * @return The new value of the stop
+ */
+ public float set(int stop, float value)
+ {
+ libgamma_gamma_rampsf_set(this.address, stop, value);
+ return value;
+ }
+
+ /**
+ * Read the value of a stop
+ *
+ * @param stop The index of the stop
+ * @param value The new value of the stop
+ * @return The new value of the stop
+ */
+ public double set(int stop, double value)
+ {
+ libgamma_gamma_rampsf_set(this.address, stop, (float)value);
+ return value;
+ }
+}
diff --git a/libgamma/Site.java b/libgamma/Site.java
new file mode 100644
index 0000000..6ce2ad4
--- /dev/null
+++ b/libgamma/Site.java
@@ -0,0 +1,133 @@
+/* See LICENSE file for copyright and license details. */
+package libgamma;
+
+
+/**
+ * Site state
+ * <p>
+ * On operating systems that integrate a graphical environment
+ * there is usually just one site. However, one systems with
+ * pluggable graphics, like Unix-like systems such as GNU/Linux
+ * and the BSD:s, there can usually be any (feasible) number of
+ * sites. In X.org parlance they are called displays.
+ */
+public class Site
+{
+ /**
+ * Type initialiser
+ */
+ static
+ {
+ Libgamma.initialise();
+ }
+
+
+ /**
+ * Constructor
+ *
+ * @param method The adjustmet method
+ * @param site The site identifier
+ */
+ public Site(AdjustmentMethod method, String site) throws LibgammaException
+ {
+ this.method = method;
+ this.site = site;
+ long[] r = libgamma_site_create(method.value, site);
+ this.address = r[0];
+ this.partitions_available = (int)(r[1]);
+ if (r[2] != 0)
+ throw new LibgammaException((int)(r[2]));
+ }
+
+
+ /**
+ * This field specifies, for the methods if this library,
+ * which adjustment method (display server and protocol)
+ * is used to adjust the gamma ramps
+ */
+ public final AdjustmentMethod method;
+
+ /**
+ * The site identifier. It can either be {@code null} or
+ * a string. {@code null} indicates the default site. On
+ * systems like the Unix-like systems, where the graphics
+ * are pluggable, this is usually resolved by an environment
+ * variable, such as "DISPLAY" for X.org.
+ */
+ public final String site;
+
+ /**
+ * The number of partitions that is available on this site.
+ * Probably the majority of display server only one partition
+ * per site. However, X.org can, and traditional used to have
+ * on multi-headed environments, multiple partitions per site.
+ * In X.org partitions are called 'screens'. It is not to be
+ * confused with monitor. A screen is a collection of monitors,
+ * and the mapping from monitors to screens is a surjection.
+ * On hardware-level adjustment methods, such as Direct
+ * Rendering Manager, a partition is a graphics card.
+ */
+ public final int partitions_available;
+
+ /**
+ * The address of the native object
+ */
+ final long address;
+
+
+ /**
+ * Release resources
+ */
+ public void close()
+ {
+ libgamma_site_free(this.address);
+ }
+
+ /**
+ * Restore the gamma ramps all CRTC:s within the site to the system settings
+ */
+ public void restore() throws LibgammaException
+ {
+ int r = libgamma_site_restore(this.address);
+ if (r != 0)
+ throw new LibgammaException(r);
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ return "<Site: method = " + this.method.toString() + ", " +
+ "site = " + (this.site == null ? "(null)" : this.site) + ", " +
+ "partitions_available = " + Integer.toString(this.partitions_available) + ">";
+ }
+
+ /**
+ * Create a site state
+ *
+ * @param method The adjustment method (display server and protocol)
+ * @param site The site identifier
+ * @return Element 0: The value for {@link #address}<br>
+ * Element 1: The value for {@link #partitions_available}<br>
+ * Element 2: Error code, zero on success
+ */
+ private static native long[] libgamma_site_create(int method, String site);
+
+ /**
+ * Release all resources held by a site state
+ * and free the site state pointer
+ *
+ * @param address The site state
+ */
+ private static native void libgamma_site_free(long address);
+
+ /**
+ * Restore the gamma ramps all CRTC:s within a site to the system settings
+ *
+ * @param address The site state
+ * @return Zero on success, and error code on failure
+ */
+ private static native int libgamma_site_restore(long address);
+}
diff --git a/libgamma/SubpixelOrder.java b/libgamma/SubpixelOrder.java
new file mode 100644
index 0000000..4db2ff9
--- /dev/null
+++ b/libgamma/SubpixelOrder.java
@@ -0,0 +1,77 @@
+/* See LICENSE file for copyright and license details. */
+package libgamma;
+
+
+/**
+ * Orders for subpixels. Currently the possible values are
+ * very biased to LCD, Plasma and monochrome monitors
+ */
+public enum SubpixelOrder
+{
+ /**
+ * The adjustment method does not know the order of the subpixels
+ * <p>
+ * (This could be considered an error)
+ */
+ UNKNOWN(0),
+
+ /**
+ * There are no subpixels in the monitor
+ */
+ NONE(1),
+
+ /**
+ * The subpixels are ordered red, green and then blue, from left to right
+ */
+ HORIZONTAL_RGB(2),
+
+ /**
+ * The subpixels are ordered blue, green and then red, from left to right
+ */
+ HORIZONTAL_BGR(3),
+
+ /**
+ * The subpixels are ordered red, green and then blue, from the top down
+ */
+ VERTICAL_RGB(4),
+
+ /**
+ * The subpixels are ordered blue, green and then red, from the top down
+ */
+ VERTICAL_BGR(5);
+
+
+ /**
+ * Type initialiser
+ */
+ static
+ {
+ Libgamma.initialise();
+ }
+
+
+ /**
+ * Subpixel orders by their numerical values
+ */
+ public static SubpixelOrder[] VALUES =
+ {
+ UNKNOWN, NONE, HORIZONTAL_RGB, HORIZONTAL_BGR, VERTICAL_RGB, VERTICAL_BGR
+ };
+
+
+ /**
+ * Constructor
+ *
+ * @param value The numerical value of the subpixel order
+ */
+ private SubpixelOrder(int value)
+ {
+ this.value = value;
+ }
+
+
+ /**
+ * The numerical value of the subpixel order
+ */
+ public int value;
+}
diff --git a/libgamma_AdjustmentMethod.c b/libgamma_AdjustmentMethod.c
new file mode 100644
index 0000000..b5f9fe1
--- /dev/null
+++ b/libgamma_AdjustmentMethod.c
@@ -0,0 +1,151 @@
+/* See LICENSE file for copyright and license details. */
+#include "libgamma_AdjustmentMethod.h"
+#include <stdlib.h>
+#include <string.h>
+
+#include <libgamma.h>
+
+
+#if LIBGAMMA_METHOD_COUNT > 6
+# error LIBGAMMA_METHOD_COUNT has been updated
+#endif
+
+
+/**
+ * List available adjustment methods by their order of preference based on the environment
+ *
+ * @param operation Allowed values:
+ * 0: Methods that the environment suggests will work, excluding fake
+ * 1: Methods that the environment suggests will work, including fake
+ * 2: All real non-fake methods
+ * 3: All real methods
+ * 4: All methods
+ * Other values invoke undefined behaviour
+ * @return List available adjustment methods by their order of preference
+ */
+jintArray
+Java_libgamma_AdjustmentMethod_libgamma_1list_1methods(JNIEnv *env, jclass class, jint operation)
+{
+ int methods[LIBGAMMA_METHOD_COUNT];
+ size_t i, n;
+ jintArray rc;
+
+ n = libgamma_list_methods(methods, LIBGAMMA_METHOD_COUNT, operation);
+ if (n > LIBGAMMA_METHOD_COUNT)
+ abort(); /* Prevented by the #if above and package maintenance */
+
+ rc = (*env)->NewIntArray(env, n);
+
+ /* Remember, jint is 32 bits, int is 16+ bits. */
+ for (i = 0; i < n; i++)
+ (*env)->SetIntArrayRegion(env, rc, i, 1, methods + i);
+
+ return rc;
+ (void) class;
+}
+
+/**
+ * Check whether an adjustment method is available, non-existing (invalid) methods will be
+ * identified as not available under the rationale that the library may be out of date
+ *
+ * @param method The adjustment method
+ * @return Whether the adjustment method is available
+ */
+jint
+Java_libgamma_AdjustmentMethod_libgamma_1is_1method_1available(JNIEnv *env, jclass class, jint method)
+{
+ return libgamma_is_method_available(method);
+ (void) env;
+ (void) class;
+}
+
+/**
+ * Return the capabilities of an adjustment method
+ *
+ * @param method The adjustment method (display server and protocol)
+ * @return Input parameter to the constructor of {@link AdjustmentMethodCapabilities}
+ */
+jlong
+Java_libgamma_AdjustmentMethod_libgamma_1method_1capabilities(JNIEnv *env, jclass class, jint method)
+{
+ libgamma_method_capabilities_t caps;
+ jlong rc;
+
+ libgamma_method_capabilities(&caps, method);
+ rc = (jlong)(caps.crtc_information);
+ rc &= 0xFFFFFFFFLL;
+ rc |= caps.default_site_known ? (1LL < 33) : 0;
+ rc |= caps.multiple_sites ? (1LL < 34) : 0;
+ rc |= caps.multiple_partitions ? (1LL < 35) : 0;
+ rc |= caps.multiple_crtcs ? (1LL < 36) : 0;
+ rc |= caps.partitions_are_graphics_cards ? (1LL < 37) : 0;
+ rc |= caps.site_restore ? (1LL < 38) : 0;
+ rc |= caps.partition_restore ? (1LL < 39) : 0;
+ rc |= caps.crtc_restore ? (1LL < 40) : 0;
+ rc |= caps.identical_gamma_sizes ? (1LL < 41) : 0;
+ rc |= caps.fixed_gamma_size ? (1LL < 42) : 0;
+ rc |= caps.fixed_gamma_depth ? (1LL < 43) : 0;
+ rc |= caps.real ? (1LL < 44) : 0;
+ rc |= caps.fake ? (1LL < 45) : 0;
+ return rc;
+ (void) env;
+ (void) class;
+}
+
+/**
+ * Return the default site for an adjustment method
+ *
+ * @param method The adjustment method (display server and protocol)
+ * @return The default site, {@code null} if it cannot be determined or
+ * if multiple sites are not supported by the adjustment method
+ */
+jstring
+Java_libgamma_AdjustmentMethod_libgamma_1method_1default_1site(JNIEnv *env, jclass class, jint method)
+{
+ /* It is really unlikely that `malloc` returns `NULL` here
+ * and error handing makes this unnecessarily comples,
+ * therefore we will simply skip it */
+
+ char *do_not_free_this = libgamma_method_default_site(method);
+ char *this_will_be_freed;
+ size_t n;
+ if (!do_not_free_this)
+ return NULL;
+
+ n = strlen(do_not_free_this) + 1;
+ this_will_be_freed = malloc(n * sizeof(char));
+ memcpy(this_will_be_freed, do_not_free_this, n * sizeof(char));
+
+ return (*env)->NewStringUTF(env, this_will_be_freed);
+ (void) class;
+}
+
+/**
+ * Return the default variable that determines
+ * the default site for an adjustment method
+ *
+ * @param method The adjustment method (display server and protocol)
+ * @return The environ variables that is used to determine the
+ * default site; {@code null} if there is none, that is,
+ * if the method does not support multiple sites
+ */
+jstring
+Java_libgamma_AdjustmentMethod_libgamma_1method_1default_1site_1variable(JNIEnv *env, jclass class, jint method)
+{
+ /* It is really unlikely that `malloc` returns `NULL` here
+ * and error handing makes this unnecessarily comples,
+ * therefore we will simply skip it */
+
+ const char *do_not_free_this = libgamma_method_default_site_variable(method);
+ char *this_will_be_freed;
+ size_t n;
+ if (!do_not_free_this)
+ return NULL;
+
+ n = strlen(do_not_free_this) + 1;
+ this_will_be_freed = malloc(n * sizeof(char));
+ memcpy(this_will_be_freed, do_not_free_this, n * sizeof(char));
+
+ return (*env)->NewStringUTF(env, this_will_be_freed);
+ (void) class;
+}
diff --git a/libgamma_CRTC.c b/libgamma_CRTC.c
new file mode 100644
index 0000000..284beee
--- /dev/null
+++ b/libgamma_CRTC.c
@@ -0,0 +1,414 @@
+/* See LICENSE file for copyright and license details. */
+#include "libgamma_CRTC.h"
+#include <errno.h>
+#include <stdlib.h>
+
+#include <libgamma.h>
+
+
+/**
+ * Make a failure-return
+ *
+ * @param error_code The error code returned from the failing function or zero to read `errno`
+ * @return The object to return
+ */
+static jlongArray
+fail(JNIEnv *env, int error_code)
+{
+ jlongArray rc = (*env)->NewLongArray(env, 2);
+ jlong e, z = 0;
+ if ((error_code == LIBGAMMA_ERRNO_SET) || !error_code)
+ error_code = errno;
+ e = (jlong)error_code;
+ (*env)->SetLongArrayRegion(env, rc, 0, 1, &z);
+ (*env)->SetLongArrayRegion(env, rc, 1, 1, &e);
+ return rc;
+}
+
+/**
+ * Make a success-return
+ *
+ * @param state The native object
+ * @return The object to return
+ */
+static jlongArray
+ok(JNIEnv *env, void *state)
+{
+ jlong a = (jlong)(size_t)state, z = 0;
+ jlongArray rc = (*env)->NewLongArray(env, 2);
+ (*env)->SetLongArrayRegion(env, rc, 0, 1, &a);
+ (*env)->SetLongArrayRegion(env, rc, 1, 1, &z);
+ return rc;
+}
+
+/**
+ * Create a CRTC state
+ *
+ * @param partition The partition state for the partition that the CRTC belongs to
+ * @param crtc The index of the CRTC within the partition
+ * @return Element 0: The value for {@link #address}
+ * Element 1: Error code, zero on success
+ */
+jlongArray
+Java_libgamma_CRTC_libgamma_1crtc_1create(JNIEnv *env, jclass class, jlong partition, jint crtc)
+{
+ libgamma_crtc_state_t *state = malloc(sizeof(libgamma_crtc_state_t));
+ void *super = (void *)(size_t)partition;
+ int r;
+ if (!state)
+ return fail(env, 0);
+ r = libgamma_crtc_initialise(state, super, crtc);
+ if (r)
+ return fail(env, r);
+ return ok(env, state);
+ (void) class;
+}
+
+/**
+ * Release all resources held by a CRTC state
+ * and free the CRTC state pointer
+ *
+ * @param address The CRTC state
+ */
+void
+Java_libgamma_CRTC_libgamma_1crtc_1free(JNIEnv *env, jclass class, jlong address)
+{
+ void *this = (void *)(size_t)address;
+ libgamma_crtc_free(this);
+ (void) env;
+ (void) class;
+}
+
+/**
+ * Restore the gamma ramps for a CRTC to the system settings for that CRTC
+ *
+ * @param address The CRTC state
+ * @return Zero on success, and error code on failure
+ */
+jint
+Java_libgamma_CRTC_libgamma_1crtc_1restore(JNIEnv *env, jclass class, jlong address)
+{
+ void *this = (void *)(size_t)address;
+ int r = libgamma_crtc_restore(this);
+ if (r)
+ return r == LIBGAMMA_ERRNO_SET ? errno : r;
+ return 0;
+ (void) env;
+ (void) class;
+}
+
+
+/**
+ * Read information about a CRTC
+ *
+ * @param crtc The state of the CRTC whose information should be read
+ * @param fields OR:ed identifiers for the information about the CRTC that should be read
+ * @return Input parameters for the constructor of {@link CRTCInformation}
+ */
+jobjectArray
+Java_libgamma_CRTC_libgamma_1get_1crtc_1information(JNIEnv *env, jclass class, jlong crtc, jint fields)
+{
+ void *this_voidp = (void *)(size_t)crtc;
+ libgamma_crtc_state_t *this = this_voidp;
+ jbyteArray edid = NULL;
+ jstring connector_name = NULL;
+ jclass class_of_jobject = (*env)->FindClass(env, "java/lang/Object");
+ jintArray ints_ = (*env)->NewIntArray(env, 25);
+ jfloatArray gamma_ = (*env)->NewFloatArray(env, 3);
+ jobjectArray rc = (*env)->NewObjectArray(env, 4, class_of_jobject, NULL);
+ libgamma_crtc_information_t info;
+ jint ints[25];
+ jfloat gamma[3];
+
+ libgamma_get_crtc_information(&info, this, fields);
+
+ if (info.edid) {
+ edid = (*env)->NewByteArray(env, info.edid_length);
+ (*env)->SetByteArrayRegion(env, edid, 0, info.edid_length, (const jbyte*)(info.edid));
+ free(info.edid);
+ }
+
+ if (connector_name)
+ connector_name = (*env)->NewStringUTF(env, info.connector_name);
+
+ gamma[0] = (jfloat)info.gamma_red;
+ gamma[1] = (jfloat)info.gamma_green;
+ gamma[2] = (jfloat)info.gamma_blue;
+
+ ints[0] = (jint)info.edid_error;
+ ints[1] = (jint)info.width_mm;
+ ints[2] = (jint)info.width_mm_error;
+ ints[3] = (jint)info.height_mm;
+ ints[4] = (jint)info.height_mm_error;
+ ints[5] = (jint)info.width_mm_edid;
+ ints[6] = (jint)info.width_mm_edid_error;
+ ints[7] = (jint)info.height_mm_edid;
+ ints[8] = (jint)info.height_mm_edid_error;
+ ints[9] = (jint)info.red_gamma_size;
+ ints[10] = (jint)info.green_gamma_size;
+ ints[11] = (jint)info.blue_gamma_size;
+ ints[12] = (jint)info.gamma_size_error;
+ ints[13] = (jint)info.gamma_depth;
+ ints[14] = (jint)info.gamma_depth_error;
+ ints[15] = (jint)info.gamma_support;
+ ints[16] = (jint)info.gamma_support_error;
+ ints[17] = (jint)info.subpixel_order;
+ ints[18] = (jint)info.subpixel_order_error;
+ ints[19] = (jint)info.active;
+ ints[20] = (jint)info.active_error;
+ ints[21] = (jint)info.connector_name_error;
+ ints[22] = (jint)info.connector_type;
+ ints[23] = (jint)info.connector_type_error;
+ ints[24] = (jint)info.gamma_error;
+
+ (*env)->SetIntArrayRegion(env, ints_, 0, 25, ints);
+ (*env)->SetFloatArrayRegion(env, gamma_, 0, 3, gamma);
+
+ (*env)->SetObjectArrayElement(env, rc, 0, edid);
+ (*env)->SetObjectArrayElement(env, rc, 1, connector_name);
+ (*env)->SetObjectArrayElement(env, rc, 2, gamma_);
+ (*env)->SetObjectArrayElement(env, rc, 3, ints_);
+
+ return rc;
+ (void) class;
+}
+
+/**
+ * Get the current gamma ramps for a CRTC, 8-bit gamma-depth version
+ *
+ * @param address The CRTC state
+ * @param ramps The gamma ramps to fill with the current values
+ * @return Zero on success, an error code on failure
+ */
+jint
+Java_libgamma_CRTC_libgamma_1crtc_1get_1gamma_1ramps8(JNIEnv *env, jclass class, jlong address, jlong ramps)
+{
+ void *crtc_voidp = (void *)(size_t)address;
+ libgamma_crtc_state_t *crtc = crtc_voidp;
+ void *output_voidp = (void *)(size_t)ramps;
+ libgamma_gamma_ramps8_t *output = output_voidp;
+ int r = libgamma_crtc_get_gamma_ramps8(crtc, output);
+ return r == LIBGAMMA_ERRNO_SET ? errno : r;
+ (void) env;
+ (void) class;
+}
+
+/**
+ * Set the gamma ramps for a CRTC, 8-bit gamma-depth version
+ *
+ * @param address The CRTC state
+ * @param ramps The gamma ramps to apply
+ * @return Zero on success, an error code on failure
+ */
+jint
+Java_libgamma_CRTC_libgamma_1crtc_1set_1gamma_1ramps8(JNIEnv *env, jclass class, jlong address, jlong ramps)
+{
+ void *crtc_voidp = (void *)(size_t)address;
+ libgamma_crtc_state_t *crtc = crtc_voidp;
+ void *values_voidp = (void *)(size_t)ramps;
+ libgamma_gamma_ramps8_t *values = values_voidp;
+ int r = libgamma_crtc_set_gamma_ramps8(crtc, *values);
+ return r == LIBGAMMA_ERRNO_SET ? errno : r;
+ (void) env;
+ (void) class;
+}
+
+/**
+ * Get the current gamma ramps for a CRTC, 16-bit gamma-depth version
+ *
+ * @param address The CRTC state
+ * @param ramps The gamma ramps to fill with the current values
+ * @return Zero on success, an error code on failure
+ */
+jint
+Java_libgamma_CRTC_libgamma_1crtc_1get_1gamma_1ramps16(JNIEnv *env, jclass class, jlong address, jlong ramps)
+{
+ void *crtc_voidp = (void *)(size_t)address;
+ libgamma_crtc_state_t *crtc = crtc_voidp;
+ void *output_voidp = (void *)(size_t)ramps;
+ libgamma_gamma_ramps16_t *output = output_voidp;
+ int r = libgamma_crtc_get_gamma_ramps16(crtc, output);
+ return r == LIBGAMMA_ERRNO_SET ? errno : r;
+ (void) env;
+ (void) class;
+}
+
+/**
+ * Set the gamma ramps for a CRTC, 16-bit gamma-depth version
+ *
+ * @param address The CRTC state
+ * @param ramps The gamma ramps to apply
+ * @return Zero on success, an error code on failure
+ */
+jint
+Java_libgamma_CRTC_libgamma_1crtc_1set_1gamma_1ramps16(JNIEnv *env, jclass class, jlong address, jlong ramps)
+{
+ void *crtc_voidp = (void *)(size_t)address;
+ libgamma_crtc_state_t *crtc = crtc_voidp;
+ void *values_voidp = (void *)(size_t)ramps;
+ libgamma_gamma_ramps16_t *values = values_voidp;
+ int r = libgamma_crtc_set_gamma_ramps16(crtc, *values);
+ return r == LIBGAMMA_ERRNO_SET ? errno : r;
+ (void) env;
+ (void) class;
+}
+
+/**
+ * Get the current gamma ramps for a CRTC, 32-bit gamma-depth version
+ *
+ * @param address The CRTC state
+ * @param ramps The gamma ramps to fill with the current values
+ * @return Zero on success, an error code on failure
+ */
+jint
+Java_libgamma_CRTC_libgamma_1crtc_1get_1gamma_1ramps32(JNIEnv *env, jclass class, jlong address, jlong ramps)
+{
+ void *crtc_voidp = (void *)(size_t)address;
+ libgamma_crtc_state_t *crtc = crtc_voidp;
+ void *output_voidp = (void *)(size_t)ramps;
+ libgamma_gamma_ramps32_t *output = output_voidp;
+ int r = libgamma_crtc_get_gamma_ramps32(crtc, output);
+ return r == LIBGAMMA_ERRNO_SET ? errno : r;
+ (void) env;
+ (void) class;
+}
+
+/**
+ * Set the gamma ramps for a CRTC, 32-bit gamma-depth version
+ *
+ * @param address The CRTC state
+ * @param ramps The gamma ramps to apply
+ * @return Zero on success, an error code on failure
+ */
+jint
+Java_libgamma_CRTC_libgamma_1crtc_1set_1gamma_1ramps32(JNIEnv *env, jclass class, jlong address, jlong ramps)
+{
+ void *crtc_voidp = (void *)(size_t)address;
+ libgamma_crtc_state_t *crtc = crtc_voidp;
+ void *values_voidp = (void *)(size_t)ramps;
+ libgamma_gamma_ramps32_t *values = values_voidp;
+ int r = libgamma_crtc_set_gamma_ramps32(crtc, *values);
+ return r == LIBGAMMA_ERRNO_SET ? errno : r;
+ (void) env;
+ (void) class;
+}
+
+/**
+ * Get the current gamma ramps for a CRTC, 64-bit gamma-depth version
+ *
+ * @param address The CRTC state
+ * @param ramps The gamma ramps to fill with the current values
+ * @return Zero on success, an error code on failure
+ */
+jint
+Java_libgamma_CRTC_libgamma_1crtc_1get_1gamma_1ramps64(JNIEnv *env, jclass class, jlong address, jlong ramps)
+{
+ void *crtc_voidp = (void *)(size_t)address;
+ libgamma_crtc_state_t *crtc = crtc_voidp;
+ void *output_voidp = (void *)(size_t)ramps;
+ libgamma_gamma_ramps64_t *output = output_voidp;
+ int r = libgamma_crtc_get_gamma_ramps64(crtc, output);
+ return r == LIBGAMMA_ERRNO_SET ? errno : r;
+ (void) env;
+ (void) class;
+}
+
+/**
+ * Set the gamma ramps for a CRTC, 64-bit gamma-depth version
+ *
+ * @param address The CRTC state
+ * @param ramps The gamma ramps to apply
+ * @return Zero on success, an error code on failure
+ */
+jint
+Java_libgamma_CRTC_libgamma_1crtc_1set_1gamma_1ramps64(JNIEnv *env, jclass class, jlong address, jlong ramps)
+{
+ void *crtc_voidp = (void *)(size_t)address;
+ libgamma_crtc_state_t *crtc = crtc_voidp;
+ void *values_voidp = (void *)(size_t)ramps;
+ libgamma_gamma_ramps64_t *values = values_voidp;
+ int r = libgamma_crtc_set_gamma_ramps64(crtc, *values);
+ return r == LIBGAMMA_ERRNO_SET ? errno : r;
+ (void) env;
+ (void) class;
+}
+
+/**
+ * Set the gamma ramps for a CRTC, single precision floating point version
+ *
+ * @param address The CRTC state
+ * @param ramps The gamma ramps to apply
+ * @return Zero on success, an error code on failure
+ */
+jint
+Java_libgamma_CRTC_libgamma_1crtc_1set_1gamma_1rampsf(JNIEnv *env, jclass class, jlong address, jlong ramps)
+{
+ void *crtc_voidp = (void *)(size_t)address;
+ libgamma_crtc_state_t *crtc = crtc_voidp;
+ void *output_voidp = (void *)(size_t)ramps;
+ libgamma_gamma_rampsf_t *output = output_voidp;
+ int r = libgamma_crtc_get_gamma_rampsf(crtc, output);
+ return r == LIBGAMMA_ERRNO_SET ? errno : r;
+ (void) env;
+ (void) class;
+}
+
+/**
+ * Get the current gamma ramps for a CRTC, single precision floating point version
+ *
+ * @param address The CRTC state
+ * @param ramps The gamma ramps to fill with the current values
+ * @return Zero on success, an error code on failure
+ */
+jint
+Java_libgamma_CRTC_libgamma_1crtc_1get_1gamma_1rampsf(JNIEnv *env, jclass class, jlong address, jlong ramps)
+{
+ void *crtc_voidp = (void *)(size_t)address;
+ libgamma_crtc_state_t * crtc = crtc_voidp;
+ void *values_voidp = (void *)(size_t)ramps;
+ libgamma_gamma_rampsf_t * values = values_voidp;
+ int r = libgamma_crtc_set_gamma_rampsf(crtc, *values);
+ return r == LIBGAMMA_ERRNO_SET ? errno : r;
+ (void) env;
+ (void) class;
+}
+
+/**
+ * Get the current gamma ramps for a CRTC, double precision floating point version
+ *
+ * @param address The CRTC state
+ * @param ramps The gamma ramps to fill with the current values
+ * @return Zero on success, an error code on failure
+ */
+jint
+Java_libgamma_CRTC_libgamma_1crtc_1get_1gamma_1rampsd(JNIEnv *env, jclass class, jlong address, jlong ramps)
+{
+ void *crtc_voidp = (void *)(size_t)address;
+ libgamma_crtc_state_t *crtc = crtc_voidp;
+ void *output_voidp = (void *)(size_t)ramps;
+ libgamma_gamma_rampsd_t *output = output_voidp;
+ int r = libgamma_crtc_get_gamma_rampsd(crtc, output);
+ return r == LIBGAMMA_ERRNO_SET ? errno : r;
+ (void) env;
+ (void) class;
+}
+
+/**
+ * Set the gamma ramps for a CRTC, double precision floating point version
+ *
+ * @param address The CRTC state
+ * @param ramps The gamma ramps to apply
+ * @return Zero on success, an error code on failure
+ */
+jint
+Java_libgamma_CRTC_libgamma_1crtc_1set_1gamma_1rampsd(JNIEnv *env, jclass class, jlong address, jlong ramps)
+{
+ void *crtc_voidp = (void *)(size_t)address;
+ libgamma_crtc_state_t *crtc = crtc_voidp;
+ void *values_voidp = (void *)(size_t)ramps;
+ libgamma_gamma_rampsd_t *values = values_voidp;
+ int r = libgamma_crtc_set_gamma_rampsd(crtc, *values);
+ return r == LIBGAMMA_ERRNO_SET ? errno : r;
+ (void) env;
+ (void) class;
+}
diff --git a/libgamma_GammaRamps.c b/libgamma_GammaRamps.c
new file mode 100644
index 0000000..eb233b7
--- /dev/null
+++ b/libgamma_GammaRamps.c
@@ -0,0 +1,336 @@
+/* See LICENSE file for copyright and license details. */
+#include "libgamma_GammaRamps.h"
+#include <errno.h>
+#include <stdlib.h>
+
+#include <libgamma.h>
+
+
+/**
+ * Make a failure-return
+ *
+ * @param error_code The error code returned from the failing function or zero to read `errno`
+ * @return The object to return
+ */
+static jlongArray
+fail(JNIEnv *env, int error_code)
+{
+ jlongArray rc = (*env)->NewLongArray(env, 5);
+ jlong e, z = 0;
+ if ((error_code == LIBGAMMA_ERRNO_SET) || !error_code)
+ error_code = errno;
+ e = (jlong)error_code;
+ (*env)->SetLongArrayRegion(env, rc, 0, 1, &z);
+ (*env)->SetLongArrayRegion(env, rc, 1, 1, &z);
+ (*env)->SetLongArrayRegion(env, rc, 2, 1, &z);
+ (*env)->SetLongArrayRegion(env, rc, 3, 1, &z);
+ (*env)->SetLongArrayRegion(env, rc, 4, 1, &e);
+ return rc;
+}
+
+/**
+ * Make a success-return
+ *
+ * @param ramps The native object
+ * @param red The red gamma ramp
+ * @param green The green gamma ramp
+ * @param blue The blue gamma ramp
+ * @return The object to return
+ */
+static jlongArray
+ok(JNIEnv *env, void *ramps, void *red, void *green, void *blue)
+{
+ jlong a = (jlong)(size_t)ramps;
+ jlong b = (jlong)(size_t)red;
+ jlong c = (jlong)(size_t)green;
+ jlong d = (jlong)(size_t)blue, z = 0;
+ jlongArray rc = (*env)->NewLongArray(env, 5);
+ (*env)->SetLongArrayRegion(env, rc, 0, 1, &a);
+ (*env)->SetLongArrayRegion(env, rc, 1, 1, &b);
+ (*env)->SetLongArrayRegion(env, rc, 2, 1, &c);
+ (*env)->SetLongArrayRegion(env, rc, 3, 1, &d);
+ (*env)->SetLongArrayRegion(env, rc, 4, 1, &z);
+ return rc;
+}
+
+/**
+ * Create and initialise a gamma ramp in the proper way that allows all adjustment
+ * methods to read from and write to it without causing segmentation violation
+ *
+ * @param red_size The size of the encoding axis of the red gamma ramp
+ * @param green_size The size of the encoding axis of the green gamma ramp
+ * @param blue_size The size of the encoding axis of the blue gamma ramp
+ * @return Element 0: The address of the native object
+ * Element 1: The address of the red gamma ramp
+ * Element 2: The address of the green gamma ramp
+ * Element 3: The address of the blue gamma ramp
+ * Element 4: Zero on success, an error code on error
+ */
+jlongArray
+Java_libgamma_GammaRamps_libgamma_1gamma_1ramps8_1create(JNIEnv *env, jclass class, jint red_size, jint green_size, jint blue_size)
+{
+ libgamma_gamma_ramps8_t *ramps = malloc(sizeof(libgamma_gamma_ramps8_t));
+ int r;
+ if (!ramps)
+ return fail(env, 0);
+ ramps->red_size = red_size;
+ ramps->green_size = green_size;
+ ramps->blue_size = blue_size;
+ r = libgamma_gamma_ramps8_initialise(ramps);
+ if (r)
+ return fail(env, r);
+ return ok(env, ramps, ramps->red, ramps->green, ramps->blue);
+ (void) class;
+}
+
+/**
+ * Create and initialise a gamma ramp in the proper way that allows all adjustment
+ * methods to read from and write to it without causing segmentation violation
+ *
+ * @param red_size The size of the encoding axis of the red gamma ramp
+ * @param green_size The size of the encoding axis of the green gamma ramp
+ * @param blue_size The size of the encoding axis of the blue gamma ramp
+ * @return Element 0: The address of the native object
+ * Element 1: The address of the red gamma ramp
+ * Element 2: The address of the green gamma ramp
+ * Element 3: The address of the blue gamma ramp
+ * Element 4: Zero on success, an error code on error
+ */
+jlongArray
+Java_libgamma_GammaRamps_libgamma_1gamma_1ramps16_1create(JNIEnv *env, jclass class, jint red_size, jint green_size, jint blue_size)
+{
+ libgamma_gamma_ramps16_t *ramps = malloc(sizeof(libgamma_gamma_ramps16_t));
+ int r;
+ if (!ramps)
+ return fail(env, 0);
+ ramps->red_size = red_size;
+ ramps->green_size = green_size;
+ ramps->blue_size = blue_size;
+ r = libgamma_gamma_ramps16_initialise(ramps);
+ if (r)
+ return fail(env, r);
+ return ok(env, ramps, ramps->red, ramps->green, ramps->blue);
+ (void) class;
+}
+
+/**
+ * Create and initialise a gamma ramp in the proper way that allows all adjustment
+ * methods to read from and write to it without causing segmentation violation
+ *
+ * @param red_size The size of the encoding axis of the red gamma ramp
+ * @param green_size The size of the encoding axis of the green gamma ramp
+ * @param blue_size The size of the encoding axis of the blue gamma ramp
+ * @return Element 0: The address of the native object
+ * Element 1: The address of the red gamma ramp
+ * Element 2: The address of the green gamma ramp
+ * Element 3: The address of the blue gamma ramp
+ * Element 4: Zero on success, an error code on error
+ */
+jlongArray
+Java_libgamma_GammaRamps_libgamma_1gamma_1ramps32_1create(JNIEnv *env, jclass class, jint red_size, jint green_size, jint blue_size)
+{
+ libgamma_gamma_ramps32_t *ramps = malloc(sizeof(libgamma_gamma_ramps32_t));
+ int r;
+ if (!ramps)
+ return fail(env, 0);
+ ramps->red_size = red_size;
+ ramps->green_size = green_size;
+ ramps->blue_size = blue_size;
+ r = libgamma_gamma_ramps32_initialise(ramps);
+ if (r)
+ return fail(env, r);
+ return ok(env, ramps, ramps->red, ramps->green, ramps->blue);
+ (void) class;
+}
+
+/**
+ * Create and initialise a gamma ramp in the proper way that allows all adjustment
+ * methods to read from and write to it without causing segmentation violation
+ *
+ * @param red_size The size of the encoding axis of the red gamma ramp
+ * @param green_size The size of the encoding axis of the green gamma ramp
+ * @param blue_size The size of the encoding axis of the blue gamma ramp
+ * @return Element 0: The address of the native object
+ * Element 1: The address of the red gamma ramp
+ * Element 2: The address of the green gamma ramp
+ * Element 3: The address of the blue gamma ramp
+ * Element 4: Zero on success, an error code on error
+ */
+jlongArray
+Java_libgamma_GammaRamps_libgamma_1gamma_1ramps64_1create(JNIEnv *env, jclass class, jint red_size, jint green_size, jint blue_size)
+{
+ libgamma_gamma_ramps64_t *ramps = malloc(sizeof(libgamma_gamma_ramps64_t));
+ int r;
+ if (!ramps)
+ return fail(env, 0);
+ ramps->red_size = red_size;
+ ramps->green_size = green_size;
+ ramps->blue_size = blue_size;
+ r = libgamma_gamma_ramps64_initialise(ramps);
+ if (r)
+ return fail(env, r);
+ return ok(env, ramps, ramps->red, ramps->green, ramps->blue);
+ (void) class;
+}
+
+/**
+ * Create and initialise a gamma ramp in the proper way that allows all adjustment
+ * methods to read from and write to it without causing segmentation violation
+ *
+ * @param red_size The size of the encoding axis of the red gamma ramp
+ * @param green_size The size of the encoding axis of the green gamma ramp
+ * @param blue_size The size of the encoding axis of the blue gamma ramp
+ * @return Element 0: The address of the native object
+ * Element 1: The address of the red gamma ramp
+ * Element 2: The address of the green gamma ramp
+ * Element 3: The address of the blue gamma ramp
+ * Element 4: Zero on success, an error code on error
+ */
+jlongArray
+Java_libgamma_GammaRamps_libgamma_1gamma_1rampsf_1create(JNIEnv *env, jclass class, jint red_size, jint green_size, jint blue_size)
+{
+ libgamma_gamma_rampsf_t *ramps = malloc(sizeof(libgamma_gamma_rampsf_t));
+ int r;
+ if (!ramps)
+ return fail(env, 0);
+ ramps->red_size = red_size;
+ ramps->green_size = green_size;
+ ramps->blue_size = blue_size;
+ r = libgamma_gamma_rampsf_initialise(ramps);
+ if (r)
+ return fail(env, r);
+ return ok(env, ramps, ramps->red, ramps->green, ramps->blue);
+ (void) class;
+}
+
+/**
+ * Create and initialise a gamma ramp in the proper way that allows all adjustment
+ * methods to read from and write to it without causing segmentation violation
+ *
+ * @param red_size The size of the encoding axis of the red gamma ramp
+ * @param green_size The size of the encoding axis of the green gamma ramp
+ * @param blue_size The size of the encoding axis of the blue gamma ramp
+ * @return Element 0: The address of the native object
+ * Element 1: The address of the red gamma ramp
+ * Element 2: The address of the green gamma ramp
+ * Element 3: The address of the blue gamma ramp
+ * Element 4: Zero on success, an error code on error
+ */
+jlongArray
+Java_libgamma_GammaRamps_libgamma_1gamma_1rampsd_1create(JNIEnv *env, jclass class, jint red_size, jint green_size, jint blue_size)
+{
+ libgamma_gamma_rampsd_t *ramps = malloc(sizeof(libgamma_gamma_rampsd_t));
+ int r;
+ if (!ramps)
+ return fail(env, 0);
+ ramps->red_size = red_size;
+ ramps->green_size = green_size;
+ ramps->blue_size = blue_size;
+ r = libgamma_gamma_rampsd_initialise(ramps);
+ if (r)
+ return fail(env, r);
+ return ok(env, ramps, ramps->red, ramps->green, ramps->blue);
+ (void) class;
+}
+
+/**
+ * Release resources that are held by a gamma ramp strcuture that
+ * has been allocated by {@link #libgamma_gamma_ramps8_create} or
+ * otherwise initialised in the proper manner, as well as release
+ * the pointer to the structure
+ *
+ * @param address The gamma ramps
+ */
+void
+Java_libgamma_GammaRamps_libgamma_1gamma_1ramps8_1free(JNIEnv *env, jclass class, jlong address)
+{
+ void *this = (void *)(size_t)address;
+ libgamma_gamma_ramps8_free(this);
+ (void) env;
+ (void) class;
+}
+
+/**
+ * Release resources that are held by a gamma ramp strcuture that
+ * has been allocated by {@link #libgamma_gamma_ramps16_create} or
+ * otherwise initialised in the proper manner, as well as release
+ * the pointer to the structure
+ *
+ * @param address The gamma ramps
+ */
+void
+Java_libgamma_GammaRamps_libgamma_1gamma_1ramps16_1free(JNIEnv *env, jclass class, jlong address)
+{
+ void *this = (void *)(size_t)address;
+ libgamma_gamma_ramps16_free(this);
+ (void) env;
+ (void) class;
+}
+
+/**
+ * Release resources that are held by a gamma ramp strcuture that
+ * has been allocated by {@link #libgamma_gamma_ramps32_create} or
+ * otherwise initialised in the proper manner, as well as release
+ * the pointer to the structure
+ *
+ * @param address The gamma ramps
+ */
+void
+Java_libgamma_GammaRamps_libgamma_1gamma_1ramps32_1free(JNIEnv *env, jclass class, jlong address)
+{
+ void *this = (void *)(size_t)address;
+ libgamma_gamma_ramps32_free(this);
+ (void) env;
+ (void) class;
+}
+
+/**
+ * Release resources that are held by a gamma ramp strcuture that
+ * has been allocated by {@link #libgamma_gamma_ramps64_create} or
+ * otherwise initialised in the proper manner, as well as release
+ * the pointer to the structure
+ *
+ * @param address The gamma ramps
+ */
+void
+Java_libgamma_GammaRamps_libgamma_1gamma_1ramps64_1free(JNIEnv *env, jclass class, jlong address)
+{
+ void *this = (void *)(size_t)address;
+ libgamma_gamma_ramps64_free(this);
+ (void) env;
+ (void) class;
+}
+
+/**
+ * Release resources that are held by a gamma ramp strcuture that
+ * has been allocated by {@link #libgamma_gamma_rampsf_create} or
+ * otherwise initialised in the proper manner, as well as release
+ * the pointer to the structure
+ *
+ * @param address The gamma ramps
+ */
+void
+Java_libgamma_GammaRamps_libgamma_1gamma_1rampsf_1free(JNIEnv *env, jclass class, jlong address)
+{
+ void *this = (void *)(size_t)address;
+ libgamma_gamma_rampsf_free(this);
+ (void) env;
+ (void) class;
+}
+
+/**
+ * Release resources that are held by a gamma ramp strcuture that
+ * has been allocated by {@link #libgamma_gamma_rampsd_create} or
+ * otherwise initialised in the proper manner, as well as release
+ * the pointer to the structure
+ *
+ * @param address The gamma ramps
+ */
+void
+Java_libgamma_GammaRamps_libgamma_1gamma_1rampsd_1free(JNIEnv *env, jclass class, jlong address)
+{
+ void *this = (void *)(size_t)address;
+ libgamma_gamma_rampsd_free(this);
+ (void) env;
+ (void) class;
+}
diff --git a/libgamma_LibgammaException.c b/libgamma_LibgammaException.c
new file mode 100644
index 0000000..52d19d7
--- /dev/null
+++ b/libgamma_LibgammaException.c
@@ -0,0 +1,124 @@
+/* See LICENSE file for copyright and license details. */
+#include "libgamma_LibgammaException.h"
+#include <stdlib.h>
+#include <string.h>
+
+#include <libgamma.h>
+
+
+/**
+ * Returns the name of the definition associated with
+ * a <tt>libgamma</tt> error code
+ *
+ * @param value The error code
+ * @return The name of the definition associated with the error code,
+ * {@code null} if the error code does not exist
+ */
+jstring
+Java_libgamma_LibgammaException_name_1of_1error(JNIEnv *env, jclass class, jint value)
+{
+ /* It is really unlikely that `malloc` returns `NULL` here
+ * and error handing makes this unnecessarily comples,
+ * therefore we will simply skip it */
+
+ const char *do_not_free_this = libgamma_name_of_error(value);
+ char *this_will_be_freed;
+ size_t n;
+ if (!do_not_free_this)
+ return NULL;
+
+ n = strlen(do_not_free_this) + 1;
+ this_will_be_freed = malloc(n * sizeof(char));
+ memcpy(this_will_be_freed, do_not_free_this, n * sizeof(char));
+
+ return (*env)->NewStringUTF(env, this_will_be_freed);
+ (void) class;
+}
+
+/**
+ * Return the value of a <tt>libgamma</tt> error definition
+ * refered to by name
+ *
+ * @param name The name of the definition associated with the error code
+ * @return The error code, zero if the name is {@code null}
+ * or does not refer to a <tt>libgamma</tt> error
+ */
+jint
+Java_libgamma_LibgammaException_value_1of_1error(JNIEnv *env, jclass class, jstring name)
+{
+ const char *name_chars;
+ int rc;
+ if (!name)
+ return 0;
+ name_chars = (*env)->GetStringUTFChars(env, name, NULL);
+ rc = libgamma_value_of_error(name_chars);
+ (*env)->ReleaseStringUTFChars(env, name, name_chars);
+ return rc;
+ (void) class;
+}
+
+/**
+ * Acquire the value that should go to {@link #group_gid}
+ *
+ * @return The value that should go to {@link #group_gid}
+ */
+jint
+Java_libgamma_LibgammaException_libgamma_1group_1gid(JNIEnv *env, jclass class)
+{
+ return libgamma_group_gid;
+ (void) env;
+ (void) class;
+}
+
+/**
+ * Acquire the value that should go to {@link #group_name}
+ *
+ * @return The value that should go to {@link #group_name}
+ */
+jstring
+Java_libgamma_LibgammaException_libgamma_1group_1name(JNIEnv *env, jclass class)
+{
+ /* It is really unlikely that `malloc` returns `NULL` here
+ * and error handing makes this unnecessarily comples,
+ * therefore we will simply skip it */
+
+ const char *do_not_free_this = libgamma_group_name;
+ char *this_will_be_freed;
+ size_t n;
+ if (!do_not_free_this)
+ return NULL;
+
+ n = strlen(do_not_free_this) + 1;
+ this_will_be_freed = malloc(n * sizeof(char));
+ memcpy(this_will_be_freed, do_not_free_this, n * sizeof(char));
+
+ return (*env)->NewStringUTF(env, this_will_be_freed);
+ (void) class;
+}
+
+/**
+ * Get a textual description of a system error code
+ *
+ * @param error_code The error code
+ * @return A textual description of the error code
+ */
+jstring
+Java_libgamma_LibgammaException_strerror(JNIEnv *env, jclass class, jint error_code)
+{
+ /* It is really unlikely that `malloc` returns `NULL` here
+ * and error handing makes this unnecessarily comples,
+ * therefore we will simply skip it */
+
+ const char *do_not_free_this = strerror(error_code);
+ char *this_will_be_freed;
+ size_t n;
+ if (!do_not_free_this)
+ return NULL;
+
+ n = strlen(do_not_free_this) + 1;
+ this_will_be_freed = malloc(n * sizeof(char));
+ memcpy(this_will_be_freed, do_not_free_this, n * sizeof(char));
+
+ return (*env)->NewStringUTF(env, this_will_be_freed);
+ (void) class;
+}
diff --git a/libgamma_Partition.c b/libgamma_Partition.c
new file mode 100644
index 0000000..baea208
--- /dev/null
+++ b/libgamma_Partition.c
@@ -0,0 +1,103 @@
+/* See LICENSE file for copyright and license details. */
+#include "libgamma_Partition.h"
+#include <errno.h>
+#include <stdlib.h>
+
+#include <libgamma.h>
+
+
+/**
+ * Make a failure-return
+ *
+ * @param error_code The error code returned from the failing function or zero to read `errno`
+ * @return The object to return
+ */
+static jlongArray
+fail(JNIEnv *env, int error_code)
+{
+ jlongArray rc = (*env)->NewLongArray(env, 3);
+ jlong e, z = 0;
+ if ((error_code == LIBGAMMA_ERRNO_SET) || !error_code)
+ error_code = errno;
+ e = (jlong)error_code;
+ (*env)->SetLongArrayRegion(env, rc, 0, 1, &z);
+ (*env)->SetLongArrayRegion(env, rc, 1, 1, &z);
+ (*env)->SetLongArrayRegion(env, rc, 2, 1, &e);
+ return rc;
+}
+
+/**
+ * Make a success-return
+ *
+ * @param state The native object
+ * @param count The subelement count
+ * @return The object to return
+ */
+static jlongArray
+ok(JNIEnv *env, void *state, size_t count)
+{
+ jlong a = (jlong)(size_t)state;
+ jlong b = (jlong)count, z = 0;
+ jlongArray rc = (*env)->NewLongArray(env, 3);
+ (*env)->SetLongArrayRegion(env, rc, 0, 1, &a);
+ (*env)->SetLongArrayRegion(env, rc, 1, 1, &b);
+ (*env)->SetLongArrayRegion(env, rc, 2, 1, &z);
+ return rc;
+}
+
+/**
+ * Create a partition state
+ *
+ * @param site The site state for the site that the partition belongs to
+ * @param partition The index of the partition within the site
+ * @return Element 0: The value for {@link #address}
+ * Element 1: The value for {@link #crtcs_available}
+ * Element 2: Error code, zero on success
+ */
+jlongArray
+Java_libgamma_Partition_libgamma_1partition_1create(JNIEnv *env, jclass class, jlong site, jint partition)
+{
+ libgamma_partition_state_t *state = malloc(sizeof(libgamma_partition_state_t));
+ void *super = (void *)(size_t)site;
+ int r;
+ if (state == NULL)
+ return fail(env, 0);
+ r = libgamma_partition_initialise(state, super, partition);
+ if (r)
+ return fail(env, r);
+ return ok(env, state, state->crtcs_available);
+ (void) class;
+}
+
+/**
+ * Release all resources held by a partition state
+ * and free the partition state pointer
+ *
+ * @param address The partition state
+ */
+void
+Java_libgamma_Partition_libgamma_1partition_1free(JNIEnv *env, jclass class, jlong address)
+{
+ void *this = (void *)(size_t)address;
+ libgamma_partition_free(this);
+ (void) env;
+ (void) class;
+}
+
+/**
+ * Restore the gamma ramps all CRTC:s within a partition to the system settings
+ *
+ * @param address The partition state
+ * @return Zero on success, and error code on failure
+ */
+jint
+Java_libgamma_Partition_libgamma_1partition_1restore(JNIEnv *env, jclass class, jlong address)
+{
+ void *this = (void *)(size_t)address;
+ int r = libgamma_partition_restore(this);
+ if (r)
+ return r == LIBGAMMA_ERRNO_SET ? errno : r;
+ return 0;
+ (void) env;
+ (void) class;
+}
diff --git a/libgamma_Ramp.c b/libgamma_Ramp.c
new file mode 100644
index 0000000..9202dc7
--- /dev/null
+++ b/libgamma_Ramp.c
@@ -0,0 +1,210 @@
+/* See LICENSE file for copyright and license details. */
+#include "libgamma_Ramp.h"
+#include <libgamma.h>
+
+
+/**
+ * Read the value of a stop in an 8-bit ramp
+ *
+ * @param address The address of the ramp
+ * @param stop The index of the stop
+ * @return The value of the stop
+ */
+jshort
+Java_libgamma_Ramp_libgamma_1gamma_1ramps8_1get(JNIEnv *env, jclass class, jlong address, jint stop)
+{
+ void *this_voidp = (void *)(size_t)address;
+ uint8_t *this = this_voidp;
+ return (jshort)(this[stop]);
+ (void) env;
+ (void) class;
+}
+
+/**
+ * Read the value of a stop in a 16-bit ramp
+ *
+ * @param address The address of the ramp
+ * @param stop The index of the stop
+ * @return The value of the stop
+ */
+jint
+Java_libgamma_Ramp_libgamma_1gamma_1ramps16_1get(JNIEnv *env, jclass class, jlong address, jint stop)
+{
+ void *this_voidp = (void *)(size_t)address;
+ uint16_t *this = this_voidp;
+ return (jint)(this[stop]);
+ (void) env;
+ (void) class;
+}
+
+/**
+ * Read the value of a stop in a 32-bit ramp
+ *
+ * @param address The address of the ramp
+ * @param stop The index of the stop
+ * @return The value of the stop
+ */
+jlong
+Java_libgamma_Ramp_libgamma_1gamma_1ramps32_1get(JNIEnv *env, jclass class, jlong address, jint stop)
+{
+ void *this_voidp = (void *)(size_t)address;
+ uint32_t *this = this_voidp;
+ return (jlong)(this[stop]);
+ (void) env;
+ (void) class;
+}
+
+/**
+ * Read the value of a stop in a 64-bit ramp
+ *
+ * @param address The address of the ramp
+ * @param stop The index of the stop
+ * @return The value of the stop
+ */
+jlong
+Java_libgamma_Ramp_libgamma_1gamma_1ramps64_1get(JNIEnv *env, jclass class, jlong address, jint stop)
+{
+ void *this_voidp = (void *)(size_t)address;
+ uint64_t *this = this_voidp;
+ return (jlong)(this[stop]);
+ (void) env;
+ (void) class;
+}
+
+/**
+ * Read the value of a stop in a single precision floating point ramp
+ *
+ * @param address The address of the ramp
+ * @param stop The index of the stop
+ * @return The value of the stop
+ */
+jfloat
+Java_libgamma_Ramp_libgamma_1gamma_1rampsf_1get(JNIEnv *env, jclass class, jlong address, jint stop)
+{
+ void *this_voidp = (void *)(size_t)address;
+ float *this = this_voidp;
+ return (jfloat)(this[stop]);
+ (void) env;
+ (void) class;
+}
+
+/**
+ * Read the value of a stop in a double precision floating point ramp
+ *
+ * @param address The address of the ramp
+ * @param stop The index of the stop
+ * @return The value of the stop
+ */
+jdouble
+Java_libgamma_Ramp_libgamma_1gamma_1rampsd_1get(JNIEnv *env, jclass class, jlong address, jint stop)
+{
+ void *this_voidp = (void *)(size_t)address;
+ double *this = this_voidp;
+ return (jdouble)(this[stop]);
+ (void) env;
+ (void) class;
+}
+
+/**
+ * Set the value of a stop in an 8-bit ramp
+ *
+ * @param address The address of the ramp
+ * @param stop The index of the stop
+ * @param value The value of the stop
+ */
+void
+Java_libgamma_Ramp_libgamma_1gamma_1ramps8_1set(JNIEnv *env, jclass class, jlong address, jint stop, jshort value)
+{
+ void *this_voidp = (void *)(size_t)address;
+ uint8_t *this = this_voidp;
+ this[stop] = (uint8_t)value;
+ (void) env;
+ (void) class;
+}
+
+/**
+ * Set the value of a stop in a 16-bit ramp
+ *
+ * @param address The address of the ramp
+ * @param stop The index of the stop
+ * @param value The value of the stop
+ */
+void
+Java_libgamma_Ramp_libgamma_1gamma_1ramps16_1set(JNIEnv *env, jclass class, jlong address, jint stop, jint value)
+{
+ void *this_voidp = (void *)(size_t)address;
+ uint16_t *this = this_voidp;
+ this[stop] = (uint16_t)value;
+ (void) env;
+ (void) class;
+}
+
+/**
+ * Set the value of a stop in a 32-bit ramp
+ *
+ * @param address The address of the ramp
+ * @param stop The index of the stop
+ * @param value The value of the stop
+ */
+void
+Java_libgamma_Ramp_libgamma_1gamma_1ramps32_1set(JNIEnv *env, jclass class, jlong address, jint stop, jlong value)
+{
+ void *this_voidp = (void *)(size_t)address;
+ uint32_t *this = this_voidp;
+ this[stop] = (uint32_t)value;
+ (void) env;
+ (void) class;
+}
+
+/**
+ * Set the value of a stop in a 64-bit ramp
+ *
+ * @param address The address of the ramp
+ * @param stop The index of the stop
+ * @param value The value of the stop
+ */
+void
+Java_libgamma_Ramp_libgamma_1gamma_1ramps64_1set(JNIEnv *env, jclass class, jlong address, jint stop, jlong value)
+{
+ void *this_voidp = (void *)(size_t)address;
+ uint64_t *this = this_voidp;
+ this[stop] = (uint64_t)value;
+ (void) env;
+ (void) class;
+}
+
+
+/**
+ * Set the value of a stop in a single precision floating point ramp
+ *
+ * @param address The address of the ramp
+ * @param stop The index of the stop
+ * @param value The value of the stop
+ */
+void
+Java_libgamma_Ramp_libgamma_1gamma_1rampsf_1set(JNIEnv *env, jclass class, jlong address, jint stop, jfloat value)
+{
+ void *this_voidp = (void *)(size_t)address;
+ float *this = this_voidp;
+ this[stop] = (float)value;
+ (void) env;
+ (void) class;
+}
+
+
+/**
+ * Set the value of a stop in a double precision floating point ramp
+ *
+ * @param address The address of the ramp
+ * @param stop The index of the stop
+ * @param value The value of the stop
+ */
+void
+Java_libgamma_Ramp_libgamma_1gamma_1rampsd_1set(JNIEnv *env, jclass class, jlong address, jint stop, jdouble value)
+{
+ void *this_voidp = (void *)(size_t)address;
+ double *this = this_voidp;
+ this[stop] = (double)value;
+ (void) env;
+ (void) class;
+}
diff --git a/libgamma_Site.c b/libgamma_Site.c
new file mode 100644
index 0000000..b28244a
--- /dev/null
+++ b/libgamma_Site.c
@@ -0,0 +1,121 @@
+/* See LICENSE file for copyright and license details. */
+#include "libgamma_Site.h"
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <libgamma.h>
+
+
+/**
+ * Make a failure-return
+ *
+ * @param error_code The error code returned from the failing function or zero to read `errno`
+ * @return The object to return
+ */
+static jlongArray
+fail(JNIEnv *env, int error_code)
+{
+ jlongArray rc = (*env)->NewLongArray(env, 3);
+ jlong e, z = 0;
+ if ((error_code == LIBGAMMA_ERRNO_SET) || !error_code)
+ error_code = errno;
+ e = (jlong)error_code;
+ (*env)->SetLongArrayRegion(env, rc, 0, 1, &z);
+ (*env)->SetLongArrayRegion(env, rc, 1, 1, &z);
+ (*env)->SetLongArrayRegion(env, rc, 2, 1, &e);
+ return rc;
+}
+
+/**
+ * Make a success-return
+ *
+ * @param state The native object
+ * @param count The subelement count
+ * @return The object to return
+ */
+static jlongArray
+ok(JNIEnv *env, void *state, size_t count)
+{
+ jlong a = (jlong)(size_t)state;
+ jlong b = (jlong)count, z = 0;
+ jlongArray rc = (*env)->NewLongArray(env, 3);
+ (*env)->SetLongArrayRegion(env, rc, 0, 1, &a);
+ (*env)->SetLongArrayRegion(env, rc, 1, 1, &b);
+ (*env)->SetLongArrayRegion(env, rc, 2, 1, &z);
+ return rc;
+}
+
+/**
+ * Create a site state
+ *
+ * @param method The adjustment method (display server and protocol)
+ * @param site The site identifier
+ * @return Element 0: The value for {@link #address}
+ * Element 1: The value for {@link #partitions_available}
+ * Element 2: Error code, zero on success
+ */
+jlongArray
+Java_libgamma_Site_libgamma_1site_1create(JNIEnv *env, jclass class, jint method, jstring site)
+{
+ libgamma_site_state_t *state = malloc(sizeof(libgamma_site_state_t));
+ const char *site_chars;
+ char *site_;
+ int r;
+ int saved_errno = 0;
+ size_t n;
+ if (site) {
+ site_chars = (*env)->GetStringUTFChars(env, site, NULL);
+ n = strlen(site_chars) + 1;
+ site_ = malloc(n * sizeof(char));
+ if (!site_)
+ saved_errno = errno;
+ else
+ memcpy(site_, site_chars, n * sizeof(char));
+ (*env)->ReleaseStringUTFChars(env, site, site_chars);
+ if (saved_errno)
+ return fail(env, errno);
+ } else {
+ site_ = NULL;
+ }
+ if (!state)
+ return fail(env, 0);
+ r = libgamma_site_initialise(state, method, site_);
+ if (r)
+ return fail(env, r);
+ return ok(env, state, state->partitions_available);
+ (void) class;
+}
+
+/**
+ * Release all resources held by a site state
+ * and free the site state pointer
+ *
+ * @param address The site state
+ */
+void
+Java_libgamma_Site_libgamma_1site_1free(JNIEnv *env, jclass class, jlong address)
+{
+ void *this = (void *)(size_t)address;
+ libgamma_site_free(this);
+ (void) env;
+ (void) class;
+}
+
+/**
+ * Restore the gamma ramps all CRTC:s within a site to the system settings
+ *
+ * @param address The site state
+ * @return Zero on success, and error code on failure
+ */
+jint
+Java_libgamma_Site_libgamma_1site_1restore(JNIEnv *env, jclass class, jlong address)
+{
+ void *this = (void *)(size_t)address;
+ int r = libgamma_site_restore(this);
+ if (r)
+ return r == LIBGAMMA_ERRNO_SET ? errno : r;
+ return 0;
+ (void) env;
+ (void) class;
+}
diff --git a/mk/linux.mk b/mk/linux.mk
new file mode 100644
index 0000000..9de2d8d
--- /dev/null
+++ b/mk/linux.mk
@@ -0,0 +1,3 @@
+LIBEXT = so
+OS_CFLAGS = -fPIC
+OS_LDFLAGS = -shared -Wl,-soname,libgamma-java.so.$(LIB_MAJOR)
diff --git a/mk/macos.mk b/mk/macos.mk
new file mode 100644
index 0000000..aa8b17b
--- /dev/null
+++ b/mk/macos.mk
@@ -0,0 +1,3 @@
+LIBEXT = dylib
+OS_CFLAGS = -fPIC
+OS_LDFLAGS = -dynamiclib
diff --git a/mk/windows.mk b/mk/windows.mk
new file mode 100644
index 0000000..5f83afc
--- /dev/null
+++ b/mk/windows.mk
@@ -0,0 +1,3 @@
+LIBEXT = dll
+OS_CFLAGS =
+OS_LDFLAGS = -mdll -Wl,-soname,libgamma-java.dll.$(LIB_MAJOR)
diff --git a/src/Test.java b/src/Test.java
deleted file mode 100644
index e42971f..0000000
--- a/src/Test.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/**
- * jlibgamma — Display server abstraction layer for gamma ramp and Java
- * Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
- *
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-import libgamma.*;
-
-
-/**
- * jlibgamma test class.
- */
-public class Test
-{
- public static void p(boolean text) { System.out.println(text); }
- public static void p(byte text) { System.out.println(text); }
- public static void p(short text) { System.out.println(text); }
- public static void p(int text) { System.out.println(text); }
- public static void p(long text) { System.out.println(text); }
- public static void p(char text) { System.out.println(text); }
- public static void p(String text) { System.out.println(text); }
- public static void p(Object text) { System.out.println(text); }
- public static void p() { System.out.println(); }
-
- public static void P(boolean text) { System.out.print(text + " "); }
- public static void P(byte text) { System.out.print(text + " "); }
- public static void P(short text) { System.out.print(text + " "); }
- public static void P(int text) { System.out.print(text + " "); }
- public static void P(long text) { System.out.print(text + " "); }
- public static void P(char text) { System.out.print(text + " "); }
- public static void P(String text) { System.out.print(text + " "); }
- public static void P(Object text) { System.out.print(text + " "); }
-
-
- /**
- * Main test function.
- *
- * @param args Command line arguments, excluding $0.
- */
- public static void main(String[] args) throws LibgammaException
- {
- p(LibgammaException.name_of_error(-3));
- p(LibgammaException.value_of_error("LIBGAMMA_NO_SUCH_SITE"));
- p();
-
- LibgammaException err = new LibgammaException(LibgammaException.LIBGAMMA_DEVICE_REQUIRE_GROUP);
- p(err.error_code);
- p(err.group_gid);
- p(err.group_name);
- p(err.string);
- err = new LibgammaException(5);
- p(err.string);
- p(err);
- p();
-
- for (AdjustmentMethod method : AdjustmentMethod.list_methods(0)) P(method.value); p();
- for (AdjustmentMethod method : AdjustmentMethod.list_methods(1)) P(method.value); p();
- for (AdjustmentMethod method : AdjustmentMethod.list_methods(2)) P(method.value); p();
- for (AdjustmentMethod method : AdjustmentMethod.list_methods(3)) P(method.value); p();
- for (AdjustmentMethod method : AdjustmentMethod.list_methods(4)) P(method.value); p();
- p();
-
- AdjustmentMethod method = AdjustmentMethod.list_methods(0)[0];
- p(method);
- p(SubpixelOrder.HORIZONTAL_RGB);
- p(ConnectorType.VGA);
- p();
-
- p(AdjustmentMethod.X_RANDR.is_available());
- p(AdjustmentMethod.X_RANDR.get_default_site());
- p(AdjustmentMethod.X_RANDR.get_default_site_variable());
- p();
-
- for (byte b : CRTCInformation.unhex("0123456789abcdef")) P(b & 255); p();
- p(CRTCInformation.behex(CRTCInformation.unhex("0123456789abcdef")));
- p();
-
- Site site = new Site(method, ":0");
- p(site.partitions_available);
- p(site);
- Partition partition = new Partition(site, 0);
- p(partition.crtcs_available);
- p(partition);
- CRTC crtc = new CRTC(partition, 0);
- p(crtc);
- p();
-
- CRTCInformation info = crtc.get_information(~0);
- p(info);
- p();
-
- AdjustmentMethodCapabilities caps = method.get_capabilities();
- p(caps);
- p();
-
- GammaRamps<Ramp16> ramps = new GammaRamps<Ramp16>(info.red_gamma_size, info.green_gamma_size,
- info.blue_gamma_size, 16);
-
- int[] saved_red = new int[ramps.red.size];
- int[] saved_green = new int[ramps.green.size];
- int[] saved_blue = new int[ramps.blue.size];
-
- crtc.get_gamma(ramps);
-
- for (int i = 0; i < ramps.red.size; i++)
- { P(ramps.red.get(i));
- ramps.red.set(i, (saved_red[i] = ramps.red.get(i)) / 2);
- }
- p();
- p();
- for (int i = 0; i < ramps.green.size; i++)
- { P(ramps.green.get(i));
- ramps.green.set(i, (saved_green[i] = ramps.green.get(i)) / 2);
- }
- p();
- p();
- for (int i = 0; i < ramps.blue.size; i++)
- { P(ramps.blue.get(i));
- ramps.blue.set(i, (saved_blue[i] = ramps.blue.get(i)) / 2);
- }
- p();
- p();
-
- crtc.set_gamma(ramps);
-
- try
- { Thread.sleep(1000);
- }
- catch (InterruptedException _error)
- { /* ignore. */
- }
-
- for (int i = 0; i < ramps.red. size; i++) ramps.red. set(i, saved_red[i]);
- for (int i = 0; i < ramps.green.size; i++) ramps.green.set(i, saved_green[i]);
- for (int i = 0; i < ramps.blue. size; i++) ramps.blue. set(i, saved_blue[i]);
-
- crtc.set_gamma(ramps);
-
- ramps.close();
- crtc.close();
- partition.close();
- site.close();
-
- try
- { throw new LibgammaException(0);
- }
- catch (LibgammaException error)
- { p(error);
- }
- }
-
-}
-
diff --git a/src/libgamma/AdjustmentMethod.java b/src/libgamma/AdjustmentMethod.java
deleted file mode 100644
index 7805533..0000000
--- a/src/libgamma/AdjustmentMethod.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/**
- * jlibgamma — Display server abstraction layer for gamma ramp and Java
- * Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
- *
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-package libgamma;
-
-
-/**
- * Class of adjustment methods.
- */
-public enum AdjustmentMethod
-{
- /**
- * The identifier for the dummy adjustment method.
- * This method can be configured and is useful for
- * testing your program's ability to handle errors.
- */
- DUMMY(0),
-
- /**
- * The identifier for the adjustment method with
- * uses the RandR protocol under the X display server.
- */
- X_RANDR(1),
-
- /**
- * The identifier for the adjustment method with
- * uses the VidMode protocol under the X display server.
- * This is an older alternative to RandR that can
- * work on some drivers that are not supported by RandR,
- * however it can only control the primary CRTC per
- * screen (partition).
- */
- X_VIDMODE(2),
-
- /**
- * The identifier for the Direct Rendering Manager
- * adjustment method that is available in Linux
- * (built in to the Linux kernel with a userland
- * library for access) and is a part of the
- * Direct Rendering Infrastructure. This adjustment
- * method all work when you are in non-graphical
- * mode; however a display server cannnot be
- * started while this is running, but it can be
- * started while a display server is running.
- */
- LINUX_DRM(3),
-
- /**
- * The identifier for the Graphics Device Interface
- * adjustment method that is available in Windows.
- * This method is not well tested; it can be compiled
- * to be available under X.org using a translation layer.
- */
- W32_GDI(4),
-
- /**
- * The identifier for the CoreGraphics adjustment
- * method that is available in Mac OS X that can
- * adjust gamma ramps under the Quartz display server.
- * This method is not well tested; it can be compiled
- * to be available under X.org using a translation layer.
- */
- QUARTZ_CORE_GRAPHICS(5)
-
- ;
-
-
- /**
- * Type initialiser.
- */
- static
- {
- Libgamma.initialise();
- }
-
-
-
- /**
- * The index of the last gamma method, neither it
- * nor any index before it may actually be supported
- * as it could have been disabled at compile-time
- */
- public static final int MAX = 5;
-
- /**
- * The number adjustment methods provided by this library.
- * Note however that this includes adjstment methods that
- * have been removed at compile-time.
- */
- public static final int COUNT = MAX + 1;
-
- /**
- * Adjustment methods by their numerical values.
- */
- public static AdjustmentMethod[] VALUES =
- {
- DUMMY, X_RANDR, X_VIDMODE, LINUX_DRM, W32_GDI, QUARTZ_CORE_GRAPHICS
- };
-
-
-
- /**
- * Constructor.
- *
- * @param value The numerical value of the adjustment method.
- */
- private AdjustmentMethod(int value)
- {
- this.value = value;
- }
-
-
- /**
- * The numerical value of the adjustment method.
- */
- public final int value;
-
-
-
- /**
- * Check whether the adjustment method is available.
- *
- * @return Whether the adjustment method is available.
- */
- public boolean is_available()
- {
- return libgamma_is_method_available(this.value) != 0;
- }
-
- /**
- * Get the default site for the adjustment method.
- *
- * @return The default site for the adjustment method.
- */
- public String get_default_site()
- {
- return libgamma_method_default_site(this.value);
- }
-
- /**
- * Get the default variable that determines the default
- * site for the adjustment method.
- *
- * @return default variable that determines the default
- * site for the adjustment method.
- */
- public String get_default_site_variable()
- {
- return libgamma_method_default_site_variable(this.value);
- }
-
- /**
- * Return the capabilities of the adjustment method.
- *
- * @return The capabilities of the adjustment method.
- */
- public AdjustmentMethodCapabilities get_capabilities()
- {
- return new AdjustmentMethodCapabilities(libgamma_method_capabilities(this.value));
- }
-
-
-
- /**
- * List available adjustment methods by their order of preference based on the environment.
- *
- * @param operation Allowed values:
- * 0: Methods that the environment suggests will work, excluding fake.
- * 1: Methods that the environment suggests will work, including fake.
- * 2: All real non-fake methods.
- * 3: All real methods.
- * 4: All methods.
- * Other values invoke undefined behaviour.
- * @return List available adjustment methods by their order of preference.
- */
- public static AdjustmentMethod[] list_methods(int operation)
- {
- int[] methods = libgamma_list_methods(operation);
- AdjustmentMethod[] rc = new AdjustmentMethod[methods.length];
- for (int i = 0; i < methods.length; i++)
- rc[i] = VALUES[methods[i]];
- return rc;
- }
-
-
-
- /**
- * List available adjustment methods by their order of preference based on the environment.
- *
- * @param operation Allowed values:
- * 0: Methods that the environment suggests will work, excluding fake.
- * 1: Methods that the environment suggests will work, including fake.
- * 2: All real non-fake methods.
- * 3: All real methods.
- * 4: All methods.
- * Other values invoke undefined behaviour.
- * @return List available adjustment methods by their order of preference.
- */
- private static native int[] libgamma_list_methods(int operation);
-
- /**
- * Check whether an adjustment method is available, non-existing (invalid) methods will be
- * identified as not available under the rationale that the library may be out of date.
- *
- * @param method The adjustment method.
- * @return Whether the adjustment method is available.
- */
- private static native int libgamma_is_method_available(int method);
-
- /**
- * Return the capabilities of an adjustment method.
- *
- * @param method The adjustment method (display server and protocol).
- * @return Input parameter to the constructor of {@link AdjustmentMethodCapabilities}.
- */
- private static native long libgamma_method_capabilities(int method);
-
-
- /**
- * Return the default site for an adjustment method.
- *
- * @param method The adjustment method (display server and protocol.)
- * @return The default site, {@code null} if it cannot be determined or
- * if multiple sites are not supported by the adjustment method.
- */
- private static native String libgamma_method_default_site(int method);
-
- /**
- * Return the default variable that determines
- * the default site for an adjustment method.
- *
- * @param method The adjustment method (display server and protocol.)
- * @return The environ variables that is used to determine the
- * default site. {@code null} if there is none, that is,
- * if the method does not support multiple sites.
- */
- private static native String libgamma_method_default_site_variable(int method);
-
-}
-
diff --git a/src/libgamma/AdjustmentMethodCapabilities.java b/src/libgamma/AdjustmentMethodCapabilities.java
deleted file mode 100644
index 36cfbb9..0000000
--- a/src/libgamma/AdjustmentMethodCapabilities.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/**
- * jlibgamma — Display server abstraction layer for gamma ramp and Java
- * Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
- *
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-package libgamma;
-
-
-/**
- * Capabilities of adjustment methods.
- */
-public class AdjustmentMethodCapabilities
-{
- /**
- * Type initialiser.
- */
- static
- {
- Libgamma.initialise();
- }
-
-
-
- /**
- * Constructor.
- *
- * @param data Low half: the value of {@link #crtc_information}.
- * High half: the values of the booleanic variables.
- */
- AdjustmentMethodCapabilities(long data)
- {
- this.crtc_information = (int)data;
-
- this.default_site_known = (data & (1L << 33L)) != 0;
- this.multiple_sites = (data & (1L << 34L)) != 0;
- this.multiple_partitions = (data & (1L << 35L)) != 0;
- this.multiple_crtcs = (data & (1L << 36L)) != 0;
- this.partitions_are_graphics_cards = (data & (1L << 37L)) != 0;
- this.site_restore = (data & (1L << 38L)) != 0;
- this.partition_restore = (data & (1L << 39L)) != 0;
- this.crtc_restore = (data & (1L << 40L)) != 0;
- this.identical_gamma_sizes = (data & (1L << 41L)) != 0;
- this.fixed_gamma_size = (data & (1L << 42L)) != 0;
- this.fixed_gamma_depth = (data & (1L << 43L)) != 0;
- this.real = (data & (1L << 44L)) != 0;
- this.fake = (data & (1L << 45L)) != 0;
- }
-
-
-
- /**
- * OR of the CRTC information fields in {@link CRTCInformation}
- * that may (but can fail) be read successfully.
- */
- public int crtc_information;
-
- /**
- * Whether the default site is known, if true the site is integrated
- * to the system or can be determined using environment variables.
- */
- public boolean default_site_known;
-
- /**
- * Whether the adjustment method supports multiple sites rather
- * than just the default site.
- */
- public boolean multiple_sites;
-
- /**
- * Whether the adjustment method supports multiple partitions
- * per site.
- */
- public boolean multiple_partitions;
-
- /**
- * Whether the adjustment method supports multiple CRTC:s
- * per partition per site.
- */
- public boolean multiple_crtcs;
-
- /**
- * Whether the partition to graphics card is a bijection.
- */
- public boolean partitions_are_graphics_cards;
-
- /**
- * Whether the adjustment method supports {@link Site#restore}.
- */
- public boolean site_restore;
-
- /**
- * Whether the adjustment method supports {@link Partition#restore}.
- */
- public boolean partition_restore;
-
- /**
- * Whether the adjustment method supports {@link CRTC#restore}.
- */
- public boolean crtc_restore;
-
- /**
- * Whether the {@link #red_gamma_size}, {@link #green_gamma_size} and
- * {@link #blue_gamma_size} fields in {@link CRTCInformation} will
- * always have the same values as each other for the adjustment method.
- */
- public boolean identical_gamma_sizes;
-
- /**
- * Whether the {@link #red_gamma_size}, {@link #green_gamma_size} and
- * {@link #blue_gamma_size} fields in {@link CRTCInformation} will
- * always be filled with the same value for the adjustment method.
- */
- public boolean fixed_gamma_size;
-
- /**
- * Whether the {@link #gamma_depth} field in {@link CRTCInformation}
- * will always be filled with the same value for the adjustment method.
- */
- public boolean fixed_gamma_depth;
-
- /**
- * Whether the adjustment method will actually perform adjustments.
- */
- public boolean real;
-
- /**
- * Whether the adjustment method is implement using a translation layer.
- */
- public boolean fake;
-
-
- /**
- * {@inheritDoc}
- */
- public String toString()
- {
- return "<AdjustmentMethodCapabilities: " +
- "information = " + Integer.toString(this.crtc_information) + ", " +
- "default_site_known = " + Boolean.toString(this.default_site_known) + ", " +
- "multiple_sites = " + Boolean.toString(this.multiple_sites) + ", " +
- "multiple_partitions = " + Boolean.toString(this.multiple_partitions) + ", " +
- "multiple_crtcs = " + Boolean.toString(this.multiple_crtcs) + ", " +
- "partitions_are_graphics_cards = " + Boolean.toString(this.partitions_are_graphics_cards) + ", " +
- "site_restore = " + Boolean.toString(this.site_restore) + ", " +
- "partition_restore = " + Boolean.toString(this.partition_restore) + ", " +
- "crtc_restore = " + Boolean.toString(this.crtc_restore) + ", " +
- "identical_gamma_sizes = " + Boolean.toString(this.identical_gamma_sizes) + ", " +
- "fixed_gamma_size = " + Boolean.toString(this.fixed_gamma_size) + ", " +
- "fixed_gamma_depth = " + Boolean.toString(this.fixed_gamma_depth) + ", " +
- "real = " + Boolean.toString(this.real) + ", " +
- "fake = " + Boolean.toString(this.fake) + ">";
- }
-
-}
-
diff --git a/src/libgamma/CRTC.java b/src/libgamma/CRTC.java
deleted file mode 100644
index 5bbb445..0000000
--- a/src/libgamma/CRTC.java
+++ /dev/null
@@ -1,305 +0,0 @@
-/**
- * jlibgamma — Display server abstraction layer for gamma ramp and Java
- * Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
- *
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-package libgamma;
-
-
-/**
- * Cathode ray tube controller state.
- *
- * The CRTC controls the gamma ramps for the
- * monitor that is plugged in to the connector
- * that the CRTC belongs to.
- */
-public class CRTC
-{
- /**
- * Type initialiser.
- */
- static
- {
- Libgamma.initialise();
- }
-
-
-
- /**
- * Constructor.
- *
- * @param partition The partition this CRTC belongs to.
- * @param crtc The index of the CRTC within its partition.
- */
- public CRTC(Partition partition, int crtc) throws LibgammaException
- {
- this.partition = partition;
- this.crtc = crtc;
- long[] r = libgamma_crtc_create(partition.address, crtc);
- this.address = r[0];
- if (r[1] != 0)
- throw new LibgammaException((int)(r[1]));
- }
-
-
- /**
- * The partition this CRTC belongs to.
- */
- public final Partition partition;
-
- /**
- * The index of the CRTC within its partition.
- */
- public final int crtc;
-
- /**
- * The address of the native object.
- */
- final long address;
-
-
- /**
- * Release resources.
- */
- public void close()
- {
- libgamma_crtc_free(this.address);
- }
-
- /**
- * Restore the gamma ramps for the CRTC to the system settings.
- */
- public void restore() throws LibgammaException
- {
- int r = libgamma_crtc_restore(this.address);
- if (r != 0)
- throw new LibgammaException(r);
- }
-
- /**
- * Read information about the CRTC.
- *
- * @param fields OR:ed identifiers for the information about the CRTC that should be read.
- * @return Information about the CRTC.
- */
- public CRTCInformation get_information(int fields)
- {
- Object[] r = libgamma_get_crtc_information(this.address, fields);
- byte[] edid = (byte[])(r[0]);
- String connector_name = (String)(r[1]);
- float[] gamma = (float[])(r[2]);
- int[] ints = (int[])(r[3]);
- return new CRTCInformation(edid, connector_name, gamma, ints);
- }
-
- /**
- * Get the current gamma ramps for the CRTC.
- *
- * @param output The gamma ramp structure to fill.
- */
- public <T extends Ramp> void get_gamma(GammaRamps<T> output) throws LibgammaException
- {
- int r = 0;
- if (output.depth == 8) r = libgamma_crtc_get_gamma_ramps8(this.address, output.address);
- else if (output.depth == 16) r = libgamma_crtc_get_gamma_ramps16(this.address, output.address);
- else if (output.depth == 32) r = libgamma_crtc_get_gamma_ramps32(this.address, output.address);
- else if (output.depth == 64) r = libgamma_crtc_get_gamma_ramps64(this.address, output.address);
- else if (output.depth == -1) r = libgamma_crtc_get_gamma_rampsf(this.address, output.address);
- else if (output.depth == -2) r = libgamma_crtc_get_gamma_rampsd(this.address, output.address);
- if (r != 0)
- throw new LibgammaException(r);
- }
-
- /**
- * Set the gamma ramps for the CRTC.
- *
- * @param values The gamma ramps to apply.
- */
- public <T extends Ramp> void set_gamma(GammaRamps<T> values) throws LibgammaException
- {
- int r = 0;
- if (values.depth == 8) r = libgamma_crtc_set_gamma_ramps8(this.address, values.address);
- else if (values.depth == 16) r = libgamma_crtc_set_gamma_ramps16(this.address, values.address);
- else if (values.depth == 32) r = libgamma_crtc_set_gamma_ramps32(this.address, values.address);
- else if (values.depth == 64) r = libgamma_crtc_set_gamma_ramps64(this.address, values.address);
- else if (values.depth == -1) r = libgamma_crtc_set_gamma_rampsf(this.address, values.address);
- else if (values.depth == -2) r = libgamma_crtc_set_gamma_rampsd(this.address, values.address);
- if (r != 0)
- throw new LibgammaException(r);
- }
-
-
- /**
- * {@inheritDoc}
- */
- public String toString()
- {
- return "<Site: partition = " + this.partition.toString() + ", " +
- "crtc = " + Integer.toString(this.crtc) + ">";
- }
-
-
-
- /**
- * Create a CRTC state.
- *
- * @param partition The partition state for the partition that the CRTC belongs to.
- * @param crtc The index of the CRTC within the partition.
- * @return Element 0: The value for {@link #address}.
- * Element 1: Error code, zero on success.
- */
- private static native long[] libgamma_crtc_create(long partition, int crtc);
-
- /**
- * Release all resources held by a CRTC state
- * and free the CRTC state pointer.
- *
- * @param address The CRTC state.
- */
- private static native void libgamma_crtc_free(long address);
-
- /**
- * Restore the gamma ramps for a CRTC to the system settings for that CRTC.
- *
- * @param address The CRTC state.
- * @return Zero on success, and error code on failure.
- */
- private static native int libgamma_crtc_restore(long address);
-
- /**
- * Read information about a CRTC.
- *
- * @param crtc The state of the CRTC whose information should be read.
- * @param fields OR:ed identifiers for the information about the CRTC that should be read.
- * @return Input parameters for the constructor of {@link CRTCInformation}
- */
- private static native Object[] libgamma_get_crtc_information(long crtc, int fields);
-
-
- /**
- * Get the current gamma ramps for a CRTC, 8-bit gamma-depth version.
- *
- * @param address The CRTC state.
- * @param ramps The gamma ramps to fill with the current values
- * @return Zero on success, an error code on failure.
- */
- private static native int libgamma_crtc_get_gamma_ramps8(long address, long ramps);
-
- /**
- * Set the gamma ramps for a CRTC, 8-bit gamma-depth version.
- *
- * @param address The CRTC state.
- * @param ramps The gamma ramps to apply.
- * @return Zero on success, an error code on failure.
- */
- private static native int libgamma_crtc_set_gamma_ramps8(long address, long ramps);
-
-
- /**
- * Get the current gamma ramps for a CRTC, 16-bit gamma-depth version.
- *
- * @param address The CRTC state.
- * @param ramps The gamma ramps to fill with the current values
- * @return Zero on success, an error code on failure.
- */
- private static native int libgamma_crtc_get_gamma_ramps16(long address, long ramps);
-
- /**
- * Set the gamma ramps for a CRTC, 16-bit gamma-depth version.
- *
- * @param address The CRTC state.
- * @param ramps The gamma ramps to apply.
- * @return Zero on success, an error code on failure.
- */
- private static native int libgamma_crtc_set_gamma_ramps16(long address, long ramps);
-
-
- /**
- * Get the current gamma ramps for a CRTC, 32-bit gamma-depth version.
- *
- * @param address The CRTC state.
- * @param ramps The gamma ramps to fill with the current values.
- * @return Zero on success, an error code on failure.
- */
- private static native int libgamma_crtc_get_gamma_ramps32(long address, long ramps);
-
- /**
- * Set the gamma ramps for a CRTC, 32-bit gamma-depth version.
- *
- * @param address The CRTC state.
- * @param ramps The gamma ramps to apply.
- * @return Zero on success, an error code on failure.
- */
- private static native int libgamma_crtc_set_gamma_ramps32(long address, long ramps);
-
-
- /**
- * Get the current gamma ramps for a CRTC, 64-bit gamma-depth version.
- *
- * @param address The CRTC state.
- * @param ramps The gamma ramps to fill with the current values.
- * @return Zero on success, an error code on failure.
- */
- private static native int libgamma_crtc_get_gamma_ramps64(long address, long ramps);
-
- /**
- * Set the gamma ramps for a CRTC, 64-bit gamma-depth version.
- *
- * @param address The CRTC state.
- * @param ramps The gamma ramps to apply.
- * @return Zero on success, an error code on failure.
- */
- private static native int libgamma_crtc_set_gamma_ramps64(long address, long ramps);
-
-
- /**
- * Set the gamma ramps for a CRTC, single precision floating point version.
- *
- * @param address The CRTC state.
- * @param ramps The gamma ramps to apply.
- * @return Zero on success, an error code on failure.
- */
- private static native int libgamma_crtc_set_gamma_rampsf(long address, long ramps);
-
- /**
- * Get the current gamma ramps for a CRTC, single precision floating point version.
- *
- * @param address The CRTC state.
- * @param ramps The gamma ramps to fill with the current values.
- * @return Zero on success, an error code on failure.
- */
- private static native int libgamma_crtc_get_gamma_rampsf(long address, long ramps);
-
-
- /**
- * Get the current gamma ramps for a CRTC, double precision floating point version.
- *
- * @param address The CRTC state.
- * @param ramps The gamma ramps to fill with the current values.
- * @return Zero on success, an error code on failure.
- */
- private static native int libgamma_crtc_get_gamma_rampsd(long address, long ramps);
-
- /**
- * Set the gamma ramps for a CRTC, double precision floating point version.
- *
- * @param address The CRTC state.
- * @param ramps The gamma ramps to apply.
- * @return Zero on success, an error code on failure.
- */
- private static native int libgamma_crtc_set_gamma_rampsd(long address, long ramps);
-
-}
-
diff --git a/src/libgamma/CRTCInformation.java b/src/libgamma/CRTCInformation.java
deleted file mode 100644
index a54a0c0..0000000
--- a/src/libgamma/CRTCInformation.java
+++ /dev/null
@@ -1,580 +0,0 @@
-/**
- * jlibgamma — Display server abstraction layer for gamma ramp and Java
- * Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
- *
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-package libgamma;
-
-
-/**
- * Cathode ray tube controller information data structure.
- */
-public class CRTCInformation
-{
- /**
- * Type initialiser.
- */
- static
- {
- Libgamma.initialise();
- }
-
-
-
- /**
- * For a {@link CRTCInformation} fill in the values for {@link #edid}
- * and {@link #edid_length} and report errors to {@link #edid_error}.
- */
- public static final int EDID = 1 << 0;
-
- /**
- * For a {@link CRTCInformation} fill in the value for
- * {@link #width_mm} and report errors to {@link #width_mm_error}.
- */
- public static final int WIDTH_MM = 1 << 1;
-
- /**
- * For a {@link CRTCInformation} fill in the value for
- * {@link #height_mm} and report errors to {@link #height_mm_error}.
- */
- public static final int HEIGHT_MM = 1 << 2;
-
- /**
- * For a {@link CRTCInformation} fill in the value for {@link #width_mm_edid}
- * and report errors to {@link #width_mm_edid_error}.
- */
- public static final int WIDTH_MM_EDID = 1 << 3;
-
- /**
- * For a {@link CRTCInformation} fill in the value for
- * {@link #height_mm_edid} and report errors to {@link #height_mm_edid_error}.
- */
- public static final int HEIGHT_MM_EDID = 1 << 4;
-
- /**
- * For a {@link CRTCInformation} fill in the values for
- * {@link #red_gamma_size}, {@link #green_gamma_size} and
- * {@link #blue_gamma_size}. and report errors to
- * {@link #gamma_size_error}.
- */
- public static final int GAMMA_SIZE = 1 << 5;
-
- /**
- * For a {@link CRTCInformation} fill in the value for
- * {@link #gamma_depth} and report errors to {@link #gamma_depth_error}.
- */
- public static final int GAMMA_DEPTH = 1 << 6;
-
- /**
- * For a {@link CRTCInformation} fill in the value for
- * {@link #gamma_support} and report errors to {@link #gamma_support_error}.
- */
- public static final int GAMMA_SUPPORT = 1 << 7;
-
- /**
- * For a {@link CRTCInformation} fill in the value for
- * {@link #subpixel_order} and report errors to {@link #subpixel_order_error}.
- */
- public static final int SUBPIXEL_ORDER = 1 << 8;
-
- /**
- * For a {@link CRTCInformation} fill in the value for
- * {@link #active} and report errors to {@link #active_error}.
- */
- public static final int ACTIVE = 1 << 9;
-
- /**
- * For a {@link CRTCInformation} fill in the value
- * for {@link #connector_name} and report errors to
- * {@link #connector_name_error}.
- */
- public static final int CONNECTOR_NAME = 1 << 10;
-
- /**
- * For a {@link CRTCInformation} fill in the
- * value for {@link #connector_type} and report
- * errors to {@link #connector_type_error}.
- */
- public static final int CONNECTOR_TYPE = 1 << 11;
-
- /**
- * For a {@link CRTCInformation} fill in the values for
- * {@link #gamma_red}, {@link #gamma_green} and
- * {@link #gamma_blue} and report errors to {@link #gamma_error}.
- */
- public static final int GAMMA = 1 << 12;
-
-
- /**
- * The number of {@link #*} values defined.
- */
- public static final int COUNT = 13;
-
-
- /**
- * Macro for both {@link CRTCInformation} fields
- * that can specify the size of the monitor's viewport
- * as specified in the monitor's Extended Display
- * Information Data.
- */
- public static final int MACRO_EDID_VIEWPORT = WIDTH_MM_EDID | HEIGHT_MM_EDID;
-
- /**
- * Macro for all {@link CRTCInformation} fields
- * that can be filled if the adjustment method have
- * support for reading the monitors' Extended Display
- * Information Data.
- */
- public static final int MACRO_EDID = EDID | MACRO_EDID_VIEWPORT | GAMMA;
-
- /**
- * Macro for both {@link CRTCInformation} fields
- * that can specify the size of the monitor's viewport
- * as provided by the adjustment method without this
- * library having to parse the monitor's Extended Display
- * Information Data.
- */
- public static final int MACRO_VIEWPORT = WIDTH_MM | HEIGHT_MM;
-
- /**
- * Macro for the {@link CRTCInformation} fields
- * that specifies the CRTC's gamma ramp sizes and gamma
- * ramp depth.
- */
- public static final int MACRO_RAMP = GAMMA_SIZE | GAMMA_DEPTH;
-
- /**
- * Macro for the {@link CRTCInformation} fields
- * that specifies the CRTC's connector type and the
- * partition unique name of the connector.
- */
- public static final int MACRO_CONNECTOR = CONNECTOR_NAME | CONNECTOR_TYPE;
-
- /**
- * Macro for the {@link CRTCInformation} fields
- * that required there is a monitor attached to
- * the connector, and that status itself.
- */
- public static final int MACRO_ACTIVE = MACRO_EDID | MACRO_VIEWPORT | SUBPIXEL_ORDER | ACTIVE;
-
-
-
- /**
- * Constructor.
- *
- * @param edid The value for {@link edid}.
- * @param connector_name The value for {@link connector_name}.
- * @param gamma The values for {@link gamma_red},
- * {@link gamma_green} and {@link gamma_blue}.
- * @param ints Values for the rest of the variables.
- */
- public CRTCInformation(byte[] edid, String connector_name, float[] gamma, int[] ints)
- {
- this.edid = edid;
- this.connector_name = connector_name;
- this.gamma_red = gamma[0];
- this.gamma_green = gamma[1];
- this.gamma_blue = gamma[2];
-
- this.edid_error = make_error(ints[0]);
- this.width_mm = ints[1];
- this.width_mm_error = make_error(ints[2]);
- this.height_mm = ints[3];
- this.height_mm_error = make_error(ints[4]);
- this.width_mm_edid = ints[5];
- this.width_mm_edid_error = make_error(ints[6]);
- this.height_mm_edid = ints[7];
- this.height_mm_edid_error = make_error(ints[8]);
- this.red_gamma_size = ints[9];
- this.green_gamma_size = ints[10];
- this.blue_gamma_size = ints[11];
- this.gamma_size_error = make_error(ints[12]);
- this.gamma_depth = (short)(ints[13]);
- this.gamma_depth_error = make_error(ints[14]);
- this.gamma_support = ints[15] != 0;
- this.gamma_support_error = make_error(ints[16]);
- this.subpixel_order = SubpixelOrder.VALUES[ints[17]];
- this.subpixel_order_error = make_error(ints[18]);
- this.active = ints[19] != 0;
- this.active_error = make_error(ints[20]);
- this.connector_name_error = make_error(ints[21]);
- this.connector_type = ConnectorType.VALUES[ints[22]];
- this.connector_type_error = make_error(ints[23]);
- this.gamma_error = make_error(ints[24]);
-
- this.has_error = (this.edid_error != null)
- || (this.width_mm_error != null)
- || (this.height_mm_error != null)
- || (this.width_mm_edid_error != null)
- || (this.height_mm_edid_error != null)
- || (this.gamma_size_error != null)
- || (this.gamma_depth_error != null)
- || (this.gamma_support_error != null)
- || (this.subpixel_order_error != null)
- || (this.connector_name_error != null)
- || (this.connector_type_error != null);
- }
-
-
- /**
- * Create an {@link LibgammaException} from an error code.
- *
- * @param error_code The error code.
- * @return An {@link LibgammaException} for the error,
- * {@code null} if <tt>error_code</tt> is zero.
- */
- private static LibgammaException make_error(int error_code)
- {
- if (error_code == 0)
- return null;
- else
- return new LibgammaException(error_code);
- }
-
-
-
- /**
- * The Extended Display Identification Data associated with
- * the attached monitor. This is raw byte array that is usually
- * 128 bytes long.
- */
- public final byte[] edid;
-
- /**
- * Error that occurred when fetching the value for
- * {@link #edid}, {@code null} on success.
- */
- public final LibgammaException edid_error;
-
-
- /**
- * The phyical width, in millimetres, of the viewport of the
- * attached monitor, as reported by the adjustment method. This
- * value may be incorrect, which is a known issue with the X
- * server where it is the result of the X server attempting
- * the estimate the size on its own.
- * Zero means that its is not applicable, which is the case
- * for projectors.
- */
- public final int width_mm;
-
- /**
- * Error that occurred when fetching the value for
- * {@link #width_mm}, {@code null} on success.
- */
- public final LibgammaException width_mm_error;
-
-
- /**
- * The phyical height, in millimetres, of the viewport of the
- * attached monitor, as reported by the adjustment method. This
- * value may be incorrect, which is a known issue with the X
- * server where it is the result of the X server attempting
- * the estimate the size on its own.
- * Zero means that its is not applicable, which is the case
- * for projectors.
- */
- public final int height_mm;
-
- /**
- * Error that occurred when fetching the value for
- * {@link #height_mm}, {@code null} on success.
- */
- public final LibgammaException height_mm_error;
-
-
- /**
- * The phyical width, in millimetres, of the viewport of the
- * attached monitor, as reported by it the monitor's Extended
- * Display Information Data. This value can only contain whole
- * centimetres, which means that the result is always zero
- * modulus ten. However, this could change with revisions of
- * the EDID structure.
- * Zero means that its is not applicable, which is the case
- * for projectors.
- */
- public final int width_mm_edid;
-
- /**
- * Error that occurred when fetching the value for
- * {@link #width_mm_edid}, {@code null} on success.
- */
- public final LibgammaException width_mm_edid_error;
-
-
- /**
- * The phyical height, in millimetres, of the viewport of the
- * attached monitor, as reported by it the monitor's Extended
- * Display Information Data. This value can only contain whole
- * centimetres, which means that the result is always zero
- * modulus ten. However, this could change with revisions of
- * the EDID structure.
- * Zero means that its is not applicable, which is the case
- * for projectors.
- */
- public final int height_mm_edid;
-
- /**
- * Error that occurred when fetching the value for
- * {@link #height_mm_edid}, {@code null} on success.
- */
- public final LibgammaException height_mm_edid_error;
-
-
- /**
- * The size of the encoding axis of the red gamma ramp.
- */
- public final int red_gamma_size;
-
- /**
- * The size of the encoding axis of the green gamma ramp.
- */
- public final int green_gamma_size;
-
- /**
- * The size of the encoding axis of the blue gamma ramp.
- */
- public final int blue_gamma_size;
-
- /**
- * Error that occurred when fetching the values for
- * {@link #red_gamma_size}, {@link #green_gamma_size}
- * and {@link #blue_gamma_size}, {@code null} on success.
- */
- public final LibgammaException gamma_size_error;
-
-
- /**
- * The bit-depth of the value axes of gamma ramps,
- * -1 for single precision floating point, and -2 for
- * double precision floating point.
- */
- public final short gamma_depth;
-
- /**
- * Error that occurred when fetching the value for
- * {@link #gamma_depth}, {@code null} on success.
- */
- public final LibgammaException gamma_depth_error;
-
-
- /**
- * Whether gamma ramp adjustments are supported.
- */
- public final boolean gamma_support;
-
- /**
- * Error that occurred when fetching the value for
- * {@link #gamma_support}, {@code null} on success.
- */
- public final LibgammaException gamma_support_error;
-
-
- /**
- * The layout of the subpixels.
- * You cannot count on this value --- especially for CRT:s ---
- * but it is provided anyway as a means of distinguishing monitors.
- */
- public final SubpixelOrder subpixel_order;
-
- /**
- * Error that occurred when fetching the value for
- * {@link #subpixel_order}, {@code null} on success.
- */
- public final LibgammaException subpixel_order_error;
-
-
- /**
- * Whether there is a monitors connected to the CRTC.
- */
- public final boolean active;
-
- /**
- * Error that occurred when fetching the value for
- * {@link #active}, {@code null} on success.
- */
- public final LibgammaException active_error;
-
-
- /**
- * The name of the connector as designated by the display
- * server or as give by this library in case the display
- * server lacks this feature.
- */
- public final String connector_name;
-
- /**
- * Error that occurred when fetching the value for
- * {@link #connector_name}, {@code null} on success.
- */
- public final LibgammaException connector_name_error;
-
-
- /**
- * The type of the connector that is associated with the CRTC.
- */
- public final ConnectorType connector_type;
-
- /**
- * Error that occurred when fetching the value for
- * {@link #connector_type}, {@code null} on success.
- */
- public final LibgammaException connector_type_error;
-
-
- /**
- * The gamma characteristics of the monitor as reported
- * in its Extended Display Information Data. The value
- * holds the value for the red channel. If you do not have
- * and more accurate measurement of the gamma for the
- * monitor this could be used to give a rought gamma
- * correction; simply divide the value with 2.2 and use
- * the result for the red channel in the gamma correction.
- */
- public final float gamma_red;
-
- /**
- * The gamma characteristics of the monitor as reported
- * in its Extended Display Information Data. The value
- * holds the value for the green channel. If you do not have
- * and more accurate measurement of the gamma for the
- * monitor this could be used to give a rought gamma
- * correction; simply divide the value with 2.2 and use
- * the result for the green channel in the gamma correction.
- */
- public final float gamma_green;
-
- /**
- * The gamma characteristics of the monitor as reported
- * in its Extended Display Information Data. The value
- * holds the value for the blue channel. If you do not have
- * and more accurate measurement of the gamma for the
- * monitor this could be used to give a rought gamma
- * correction; simply divide the value with 2.2 and use
- * the result for the blue channel in the gamma correction.
- */
- public final float gamma_blue;
-
- /**
- * Error that occurred when fetching the values for
- * {@link #red_gamma}, {@link #green_gamma} and
- * {@link #blue_gamma}, {@code null} on success.
- */
- public final LibgammaException gamma_error;
-
-
- /**
- * Whether any of the error fields are non-{@code null}.
- */
- public final boolean has_error;
-
-
-
- /**
- * Helper function for {@link #toString}.
- *
- * @param error An error, may be {@code null}.
- * @return A textual representation of <tt>error</tt>
- */
- private static String errorToString(LibgammaException error)
- {
- if (error == null)
- return "<null>";
- else
- return error.toString();
- }
-
-
- /**
- * {@inheritDoc}
- */
- public String toString()
- {
- String depth_str = Integer.toString(this.gamma_depth);
- if (this.gamma_depth == -1) depth_str = "float";
- if (this.gamma_depth == -1) depth_str = "double";
-
- return "<CRTCInformation: " +
- "edid = " + behex(this.edid) + ", " +
- "edid_error = " + errorToString(this.edid_error) + ", " +
- "width_mm = " + Integer.toString(this.width_mm) + ", " +
- "width_mm_error = " + errorToString(this.width_mm_error) + ", " +
- "height_mm = " + Integer.toString(this.height_mm) + ", " +
- "height_mm_error = " + errorToString(this.height_mm_error) + ", " +
- "width_mm_edid = " + Integer.toString(this.width_mm_edid) + ", " +
- "width_mm_edid_error = " + errorToString(this.width_mm_edid_error) + ", " +
- "height_mm_edid = " + Integer.toString(this.height_mm_edid) + ", " +
- "height_mm_edid_error = " + errorToString(this.height_mm_edid_error) + ", " +
- "red_gamma_size = " + Integer.toString(this.red_gamma_size) + ", " +
- "green_gamma_size = " + Integer.toString(this.green_gamma_size) + ", " +
- "blue_gamma_size = " + Integer.toString(this.blue_gamma_size) + ", " +
- "gamma_size_error = " + errorToString(this.gamma_size_error) + ", " +
- "gamma_depth = " + depth_str + ", " +
- "gamma_depth_error = " + errorToString(this.gamma_depth_error) + ", " +
- "gamma_support = " + Boolean.toString(this.gamma_support) + ", " +
- "gamma_support_error = " + errorToString(this.gamma_support_error) + ", " +
- "subpixel_order = " + this.subpixel_order.toString() + ", " +
- "subpixel_order_error = " + errorToString(this.subpixel_order_error) + ", " +
- "active = " + Boolean.toString(this.active) + ", " +
- "active_error = " + errorToString(this.active_error) + ", " +
- "connector_name = " + (this.connector_name == null ? "<null>" : this.connector_name) + ", " +
- "connector_name_error = " + errorToString(this.connector_name_error) + ", " +
- "connector_type = " + this.connector_type.toString() + ", " +
- "connector_type_error = " + errorToString(this.connector_type_error) + ", " +
- "gamma_red = " + Float.toString(this.gamma_red) + ", " +
- "gamma_green = " + Float.toString(this.gamma_green) + ", " +
- "gamma_blue = " + Float.toString(this.gamma_blue) + ", " +
- "gamma_error = " + errorToString(this.gamma_error) + ", " +
- "has_error = " + Boolean.toString(this.has_error) + ">";
- }
-
-
-
- /**
- * Convert a raw representation of an EDID to a lowercase hexadecimal representation.
- *
- * @param edid The EDID in raw representation.
- * @return The EDID in lowercase hexadecimal representation,
- */
- public static String behex(byte[] edid)
- {
- char[] rc = new char[edid.length * 2];
- for (int i = 0; i < edid.length; i++)
- { rc[i * 2 + 0] = "0123456789abcdef".charAt((edid[i] >> 4) & 15);
- rc[i * 2 + 1] = "0123456789abcdef".charAt((edid[i] >> 0) & 15);
- }
- return new String(rc);
- }
-
- /**
- * Convert an hexadecimal representation of an EDID to a raw representation.
- *
- * @param edid The EDID in hexadecimal representation.
- * @return The EDID in raw representation, it will be half the length
- * of <tt>edid</tt> (the input value).
- */
- public static byte[] unhex(String edid)
- {
- byte[] rc = new byte[edid.length() / 2];
- edid = edid.toLowerCase();
- for (int i = 0; i < rc.length; i++)
- { rc[i] = (byte)("0123456789abcdef".indexOf(edid.charAt(i * 2 + 0)) << 4);
- rc[i] |= (byte)("0123456789abcdef".indexOf(edid.charAt(i * 2 + 1)) << 0);
- }
- return rc;
- }
-
-}
-
diff --git a/src/libgamma/ConnectorType.java b/src/libgamma/ConnectorType.java
deleted file mode 100644
index cdb737c..0000000
--- a/src/libgamma/ConnectorType.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/**
- * jlibgamma — Display server abstraction layer for gamma ramp and Java
- * Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
- *
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-package libgamma;
-
-
-/**
- * Types for connectors.
- */
-public enum ConnectorType
-{
- /**
- * The adjustment method does not know the connector's type
- * (This could be considered an error).
- */
- Unknown(0),
-
- /**
- * Video Graphics Array (VGA).
- */
- VGA(1),
-
- /**
- * Digital Visual Interface, unknown type.
- */
- DVI(2),
-
- /**
- * Digital Visual Interface, integrated (DVI-I).
- */
- DVII(3),
-
- /**
- * Digital Visual Interface, digital only (DVI-D).
- */
- DVID(4),
-
- /**
- * Digital Visual Interface, analogue only (DVI-A).
- */
- DVIA(5),
-
- /**
- * Composite video.
- */
- Composite(6),
-
- /**
- * Separate Video (S-video).
- */
- SVIDEO(7),
-
- /**
- * Low-voltage differential signaling (LVDS).
- */
- LVDS(8),
-
- /**
- * Component video, usually separate cables for each channel.
- */
- Component(9),
-
- /**
- * 9 pin DIN (Deutsches Institut für Normung) connector.
- */
- NinePinDIN(10),
-
- /**
- * DisplayPort.
- */
- DisplayPort(11),
-
- /**
- * High-Definition Multimedia Interface (HDMI), unknown type.
- */
- HDMI(12),
-
- /**
- * High-Definition Multimedia Interface, type A (HDMI-A).
- */
- HDMIA(13),
-
- /**
- * High-Definition Multimedia Interface, type B (HDMI-B).
- */
- HDMIB(14),
-
- /**
- * Television, unknown connector.
- */
- TV(15),
-
- /**
- * Embedded DisplayPort (eDP).
- */
- eDP(16),
-
- /**
- * A virtual connector.
- */
- VIRTUAL(17),
-
- /**
- * Display Serial Interface (DSI).
- */
- DSI(18),
-
- /**
- * LFP connector.
- * (If you know what this is add it to Wikipedia.)
- */
- LFP(19)
-
- ;
-
-
- /**
- * Type initialiser.
- */
- static
- {
- Libgamma.initialise();
- }
-
-
-
- /**
- * Subpixel orders by their numerical values.
- */
- public static ConnectorType[] VALUES =
- {
- Unknown, VGA, DVI, DVII, DVID, DVIA, Composite, SVIDEO, LVDS, Component,
- NinePinDIN, DisplayPort, HDMI, HDMIA, HDMIB, TV, eDP, VIRTUAL, DSI, LFP
- };
-
-
- /**
- * Constructor.
- *
- * @param value The numerical value of the connector type.
- */
- private ConnectorType(int value)
- {
- this.value = value;
- }
-
-
- /**
- * The numerical value of the connector type.
- */
- public int value;
-
-}
-
diff --git a/src/libgamma/GammaRamps.java b/src/libgamma/GammaRamps.java
deleted file mode 100644
index 61352e2..0000000
--- a/src/libgamma/GammaRamps.java
+++ /dev/null
@@ -1,332 +0,0 @@
-/**
- * jlibgamma — Display server abstraction layer for gamma ramp and Java
- * Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
- *
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-package libgamma;
-
-
-/**
- * Gamma ramp structure.
- *
- * @param <T> The ramp class, should be select in accordance
- * with the <tt>depth</tt> parameter of the constructor:
- * <p>
- * 8: Ramp8<br/>
- * 16: Ramp16<br/>
- * 32: Ramp32<br/>
- * 64: Ramp64<br/>
- * -1: Rampf<br/>
- * -2: Rampd<br/>
- * </p>
- */
-public class GammaRamps<T extends Ramp>
-{
- /**
- * Type initialiser.
- */
- static
- {
- Libgamma.initialise();
- }
-
-
-
- /**
- * Constructor.
- *
- * @param red_size The size of the encoding axis of the red gamma ramp.
- * @param green_size The size of the encoding axis of the green gamma ramp.
- * @param blue_size The size of the encoding axis of the blue gamma ramp.
- * @param depth The bit-depth of the value axes of gamma ramps,
- * -1 for single precision floating point, and -2 for
- * double precision floating point.
- */
- public GammaRamps(int red_size, int green_size, int blue_size, int depth) throws LibgammaException
- {
- this(red_size, green_size, blue_size, (short)depth);
- }
-
- /**
- * Constructor.
- *
- * @param red_size The size of the encoding axis of the red gamma ramp.
- * @param green_size The size of the encoding axis of the green gamma ramp.
- * @param blue_size The size of the encoding axis of the blue gamma ramp.
- * @param depth The bit-depth of the value axes of gamma ramps,
- * -1 for single precision floating point, and -2 for
- * double precision floating point.
- */
- @SuppressWarnings("unchecked")
- public GammaRamps(int red_size, int green_size, int blue_size, short depth) throws LibgammaException
- {
- long[] r;
- if (depth == 8) r = libgamma_gamma_ramps8_create (red_size, green_size, blue_size);
- else if (depth == 16) r = libgamma_gamma_ramps16_create(red_size, green_size, blue_size);
- else if (depth == 32) r = libgamma_gamma_ramps32_create(red_size, green_size, blue_size);
- else if (depth == 64) r = libgamma_gamma_ramps64_create(red_size, green_size, blue_size);
- else if (depth == -1) r = libgamma_gamma_rampsf_create (red_size, green_size, blue_size);
- else if (depth == -2) r = libgamma_gamma_rampsd_create (red_size, green_size, blue_size);
- else
- throw new IllegalArgumentException("depth must be either of: 8, 16, 32, 64, -1, -2.");
-
- if (r[4] != 0)
- throw new LibgammaException((int)(r[4]));
-
- this.address = r[0];
- this.depth = depth;
-
- Ramp red = null;
- Ramp green = null;
- Ramp blue = null;
-
- if (depth == 8) red = (Ramp)(new Ramp8 (r[1], red_size));
- else if (depth == 16) red = (Ramp)(new Ramp16(r[1], red_size));
- else if (depth == 32) red = (Ramp)(new Ramp32(r[1], red_size));
- else if (depth == 64) red = (Ramp)(new Ramp64(r[1], red_size));
- else if (depth == -1) red = (Ramp)(new Rampf (r[1], red_size));
- else if (depth == -2) red = (Ramp)(new Rampd (r[1], red_size));
-
- if (depth == 8) green = (Ramp)(new Ramp8 (r[2], green_size));
- else if (depth == 16) green = (Ramp)(new Ramp16(r[2], green_size));
- else if (depth == 32) green = (Ramp)(new Ramp32(r[2], green_size));
- else if (depth == 64) green = (Ramp)(new Ramp64(r[2], green_size));
- else if (depth == -1) green = (Ramp)(new Rampf (r[2], green_size));
- else if (depth == -2) green = (Ramp)(new Rampd (r[2], green_size));
-
- if (depth == 8) blue = (Ramp)(new Ramp8 (r[3], blue_size));
- else if (depth == 16) blue = (Ramp)(new Ramp16(r[3], blue_size));
- else if (depth == 32) blue = (Ramp)(new Ramp32(r[3], blue_size));
- else if (depth == 64) blue = (Ramp)(new Ramp64(r[3], blue_size));
- else if (depth == -1) blue = (Ramp)(new Rampf (r[3], blue_size));
- else if (depth == -2) blue = (Ramp)(new Rampd (r[3], blue_size));
-
- this.red = (T)red;
- this.green = (T)green;
- this.blue = (T)blue;
- }
-
-
- /**
- * The gamma ramp for the red channel.
- */
- public final T red;
-
- /**
- * The gamma ramp for the green channel.
- */
- public final T green;
-
- /**
- * The gamma ramp for the blue channel.
- */
- public final T blue;
-
- /**
- * The bit-depth of the value axes of gamma ramps,
- * -1 for single precision floating point, and -2 for
- * double precision floating point.
- */
- public final short depth;
-
- /**
- * The address of the native object.
- */
- final long address;
-
-
- /**
- * Release resources.
- */
- public void close()
- {
- if (this.depth == 8) libgamma_gamma_ramps8_free(this.address);
- else if (this.depth == 16) libgamma_gamma_ramps16_free(this.address);
- else if (this.depth == 32) libgamma_gamma_ramps32_free(this.address);
- else if (this.depth == 64) libgamma_gamma_ramps64_free(this.address);
- else if (this.depth == -1) libgamma_gamma_rampsf_free(this.address);
- else if (this.depth == -2) libgamma_gamma_rampsd_free(this.address);
- }
-
-
- /**
- * {@inheritDoc}
- */
- public String toString()
- {
- String depth_str = Integer.toString(this.depth);
- if (this.depth == -1) depth_str = "float";
- if (this.depth == -1) depth_str = "double";
-
- return "<GammaRamps: depth = " + depth_str + ", " +
- "red = " + this.red.toString() +
- "green = " + this.green.toString() +
- "blue = " + this.blue.toString() + ">";
- }
-
-
- /**
- * Create and initialise a gamma ramp in the proper way that allows all adjustment
- * methods to read from and write to it without causing segmentation violation.
- *
- * @param red_size The size of the encoding axis of the red gamma ramp.
- * @param green_size The size of the encoding axis of the green gamma ramp.
- * @param blue_size The size of the encoding axis of the blue gamma ramp.
- * @return Element 0: The address of the native object.
- * Element 1: The address of the red gamma ramp.
- * Element 2: The address of the green gamma ramp.
- * Element 3: The address of the blue gamma ramp.
- * Element 4: Zero on success, an error code on error.
- */
- private static native long[] libgamma_gamma_ramps8_create(int red_size, int green_size, int blue_size);
-
- /**
- * Create and initialise a gamma ramp in the proper way that allows all adjustment
- * methods to read from and write to it without causing segmentation violation.
- *
- * @param red_size The size of the encoding axis of the red gamma ramp.
- * @param green_size The size of the encoding axis of the green gamma ramp.
- * @param blue_size The size of the encoding axis of the blue gamma ramp.
- * @return Element 0: The address of the native object.
- * Element 1: The address of the red gamma ramp.
- * Element 2: The address of the green gamma ramp.
- * Element 3: The address of the blue gamma ramp.
- * Element 4: Zero on success, an error code on error.
- */
- private static native long[] libgamma_gamma_ramps16_create(int red_size, int green_size, int blue_size);
-
- /**
- * Create and initialise a gamma ramp in the proper way that allows all adjustment
- * methods to read from and write to it without causing segmentation violation.
- *
- * @param red_size The size of the encoding axis of the red gamma ramp.
- * @param green_size The size of the encoding axis of the green gamma ramp.
- * @param blue_size The size of the encoding axis of the blue gamma ramp.
- * @return Element 0: The address of the native object.
- * Element 1: The address of the red gamma ramp.
- * Element 2: The address of the green gamma ramp.
- * Element 3: The address of the blue gamma ramp.
- * Element 4: Zero on success, an error code on error.
- */
- private static native long[] libgamma_gamma_ramps32_create(int red_size, int green_size, int blue_size);
-
- /**
- * Create and initialise a gamma ramp in the proper way that allows all adjustment
- * methods to read from and write to it without causing segmentation violation.
- *
- * @param red_size The size of the encoding axis of the red gamma ramp.
- * @param green_size The size of the encoding axis of the green gamma ramp.
- * @param blue_size The size of the encoding axis of the blue gamma ramp.
- * @return Element 0: The address of the native object.
- * Element 1: The address of the red gamma ramp.
- * Element 2: The address of the green gamma ramp.
- * Element 3: The address of the blue gamma ramp.
- * Element 4: Zero on success, an error code on error.
- */
- private static native long[] libgamma_gamma_ramps64_create(int red_size, int green_size, int blue_size);
-
- /**
- * Create and initialise a gamma ramp in the proper way that allows all adjustment
- * methods to read from and write to it without causing segmentation violation.
- *
- * @param red_size The size of the encoding axis of the red gamma ramp.
- * @param green_size The size of the encoding axis of the green gamma ramp.
- * @param blue_size The size of the encoding axis of the blue gamma ramp.
- * @return Element 0: The address of the native object.
- * Element 1: The address of the red gamma ramp.
- * Element 2: The address of the green gamma ramp.
- * Element 3: The address of the blue gamma ramp.
- * Element 4: Zero on success, an error code on error.
- */
- private static native long[] libgamma_gamma_rampsf_create(int red_size, int green_size, int blue_size);
-
- /**
- * Create and initialise a gamma ramp in the proper way that allows all adjustment
- * methods to read from and write to it without causing segmentation violation.
- *
- * @param red_size The size of the encoding axis of the red gamma ramp.
- * @param green_size The size of the encoding axis of the green gamma ramp.
- * @param blue_size The size of the encoding axis of the blue gamma ramp.
- * @return Element 0: The address of the native object.
- * Element 1: The address of the red gamma ramp.
- * Element 2: The address of the green gamma ramp.
- * Element 3: The address of the blue gamma ramp.
- * Element 4: Zero on success, an error code on error.
- */
- private static native long[] libgamma_gamma_rampsd_create(int red_size, int green_size, int blue_size);
-
-
- /**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by {@link #libgamma_gamma_ramps8_create} or
- * otherwise initialised in the proper manner, as well as release
- * the pointer to the structure.
- *
- * @param address The gamma ramps.
- */
- private static native void libgamma_gamma_ramps8_free(long address);
-
- /**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by {@link #libgamma_gamma_ramps16_create} or
- * otherwise initialised in the proper manner, as well as release
- * the pointer to the structure.
- *
- * @param address The gamma ramps.
- */
- private static native void libgamma_gamma_ramps16_free(long address);
-
- /**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by {@link #libgamma_gamma_ramps32_create} or
- * otherwise initialised in the proper manner, as well as release
- * the pointer to the structure.
- *
- * @param address The gamma ramps.
- */
- private static native void libgamma_gamma_ramps32_free(long address);
-
- /**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by {@link #libgamma_gamma_ramps64_create} or
- * otherwise initialised in the proper manner, as well as release
- * the pointer to the structure.
- *
- * @param address The gamma ramps.
- */
- private static native void libgamma_gamma_ramps64_free(long address);
-
- /**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by {@link #libgamma_gamma_rampsf_create} or
- * otherwise initialised in the proper manner, as well as release
- * the pointer to the structure.
- *
- * @param address The gamma ramps.
- */
- private static native void libgamma_gamma_rampsf_free(long address);
-
- /**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by {@link #libgamma_gamma_rampsd_create} or
- * otherwise initialised in the proper manner, as well as release
- * the pointer to the structure.
- *
- * @param address The gamma ramps.
- */
- private static native void libgamma_gamma_rampsd_free(long address);
-
-}
-
diff --git a/src/libgamma/Libgamma.java b/src/libgamma/Libgamma.java
deleted file mode 100644
index dbb9d1c..0000000
--- a/src/libgamma/Libgamma.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * jlibgamma — Display server abstraction layer for gamma ramp and Java
- * Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
- *
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-package libgamma;
-
-
-/**
- * Library initialisation class.
- */
-class Libgamma
-{
- /**
- * Initialise the library.
- */
- static void initialise()
- {
- if (Libgamma.initialised)
- return;
- Libgamma.initialised = true;
-
- try
- { System.loadLibrary("gamma-java");
- }
- catch (Throwable err)
- { throw new Error(err);
- }
- }
-
-
- /**
- * Whether {@link #initialise} has been invoked.
- */
- private static boolean initialised = false;
-
-}
-
diff --git a/src/libgamma/LibgammaException.java b/src/libgamma/LibgammaException.java
deleted file mode 100644
index bc8611e..0000000
--- a/src/libgamma/LibgammaException.java
+++ /dev/null
@@ -1,436 +0,0 @@
-/**
- * jlibgamma — Display server abstraction layer for gamma ramp and Java
- * Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
- *
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-package libgamma;
-
-
-/**
- * <p>
- * Class of <tt>libgamma</tt> exceptions including
- * native system exceptions.
- * </p>
- * <p>
- * The class contains constants with <tt>libgamma</tt> error
- * codes. It does however not contain system error codes.
- * </p>
- */
-@SuppressWarnings("serial")
-public class LibgammaException extends Exception
-{
- /**
- * Type initialiser.
- */
- static
- {
- Libgamma.initialise();
- }
-
-
-
- /**
- * This error code is never used. It is only provided
- * so you know its error code if you plan to iterate
- * over all <tt>libgamma</tt> error codes.
- */
- public static final int LIBGAMMA_ERRNO_SET = -1;
-
- /**
- * The selected adjustment method does not exist
- * or has been excluded at compile-time.
- */
- public static final int LIBGAMMA_NO_SUCH_ADJUSTMENT_METHOD = -2;
-
- /**
- * The selected site does not exist.
- */
- public static final int LIBGAMMA_NO_SUCH_SITE = -3;
-
- /**
- * The selected partition does not exist.
- */
- public static final int LIBGAMMA_NO_SUCH_PARTITION = -4;
-
- /**
- * The selected CRTC does not exist.
- */
- public static final int LIBGAMMA_NO_SUCH_CRTC = -5;
-
- /**
- * Counter overflowed when counting the number
- * of available items.
- */
- public static final int LIBGAMMA_IMPOSSIBLE_AMOUNT = -6;
-
- /**
- * The selected connector is disabled, it does
- * not have a CRTC.
- */
- public static final int LIBGAMMA_CONNECTOR_DISABLED = -7;
-
- /**
- * The selected CRTC could not be opened,
- * reason unknown.
- */
- public static final int LIBGAMMA_OPEN_CRTC_FAILED = -8;
-
- /**
- * The CRTC information field is not supported
- * by the adjustment method.
- */
- public static final int LIBGAMMA_CRTC_INFO_NOT_SUPPORTED = -9;
-
- /**
- * Failed to read the current gamma ramps for
- * the selected CRTC, reason unknown.
- */
- public static final int LIBGAMMA_GAMMA_RAMP_READ_FAILED = -10;
-
- /**
- * Failed to write the current gamma ramps for
- * the selected CRTC, reason unknown.
- */
- public static final int LIBGAMMA_GAMMA_RAMP_WRITE_FAILED = -11;
-
- /**
- * The specified ramp sizes does not match the
- * ramps sizes returned by the adjustment methods
- * in response to the query/command.
- */
- public static final int LIBGAMMA_GAMMA_RAMP_SIZE_CHANGED = -12;
-
- /**
- * The specified ramp sizes are not identical
- * which is required by the adjustment method.
- * (Only returned in debug mode.)
- */
- public static final int LIBGAMMA_MIXED_GAMMA_RAMP_SIZE = -13;
-
- /**
- * The specified ramp sizes are not supported
- * by the adjustment method.
- * (Only returned in debug mode.)
- */
- public static final int LIBGAMMA_WRONG_GAMMA_RAMP_SIZE = -14;
-
- /**
- * The adjustment method reported that the gamma
- * ramps size is 1, or perhaps even zero or negative.
- */
- public static final int LIBGAMMA_SINGLETON_GAMMA_RAMP = -15;
-
- /**
- * The adjustment method failed to list
- * available CRTC:s, reason unknown.
- */
- public static final int LIBGAMMA_LIST_CRTCS_FAILED = -16;
-
- /**
- * Failed to acquire mode resources from the
- * adjustment method.
- */
- public static final int LIBGAMMA_ACQUIRING_MODE_RESOURCES_FAILED = -17;
-
- /**
- * The adjustment method reported that a negative
- * number of partitions exists in the site.
- */
- public static final int LIBGAMMA_NEGATIVE_PARTITION_COUNT = -18;
-
- /**
- * The adjustment method reported that a negative
- * number of CRTC:s exists in the partition.
- */
- public static final int LIBGAMMA_NEGATIVE_CRTC_COUNT = -19;
-
- /**
- * Device cannot be access becauses of
- * insufficient permissions.
- */
- public static final int LIBGAMMA_DEVICE_RESTRICTED = -20;
-
- /**
- * Device cannot be access, reason unknown.
- */
- public static final int LIBGAMMA_DEVICE_ACCESS_FAILED = -21;
-
- /**
- * Device cannot be access, membership of the
- * {@link #group_gid} (named by {@link #group_name}
- * (can be {@code null}, if so <tt>errno</tt> may have
- * been set to tell why)) is required.
- */
- public static final int LIBGAMMA_DEVICE_REQUIRE_GROUP = -22;
-
- /**
- * The graphics card appear to have been removed.
- */
- public static final int LIBGAMMA_GRAPHICS_CARD_REMOVED = -23;
-
- /**
- * The state of the requested information is unknown.
- */
- public static final int LIBGAMMA_STATE_UNKNOWN = -24;
-
- /**
- * Failed to determine which connector the
- * CRTC belongs to.
- */
- public static final int LIBGAMMA_CONNECTOR_UNKNOWN = -25;
-
- /**
- * The detected connector type is not listed
- * in this library and has to be updated.
- */
- public static final int LIBGAMMA_CONNECTOR_TYPE_NOT_RECOGNISED = -26;
-
- /**
- * The detected subpixel order is not listed
- * in this library and has to be updated.
- */
- public static final int LIBGAMMA_SUBPIXEL_ORDER_NOT_RECOGNISED = -27;
-
- /**
- * The length of the EDID does not match that
- * of any supported EDID structure revision.
- */
- public static final int LIBGAMMA_EDID_LENGTH_UNSUPPORTED = -28;
-
- /**
- * The magic number in the EDID does not match
- * that of any supported EDID structure revision.
- */
- public static final int LIBGAMMA_EDID_WRONG_MAGIC_NUMBER = -29;
-
- /**
- * The EDID structure revision used by the
- * mointor is not supported.
- */
- public static final int LIBGAMMA_EDID_REVISION_UNSUPPORTED = -30;
-
- /**
- * The gamma characteristics field in the EDID
- * is left unspecified.
- * (This could be considered a non-error.)
- */
- public static final int LIBGAMMA_GAMMA_NOT_SPECIFIED = -31;
-
- /**
- * The checksum in the EDID is incorrect, all
- * request information has been provided
- * by you cannot count on it.
- */
- public static final int LIBGAMMA_EDID_CHECKSUM_ERROR = -32;
-
- /**
- * Both of the errors {@link #LIBGAMMA_GAMMA_NOT_SPECIFIED}
- * and {@link #LIBGAMMA_EDID_CHECKSUM_ERROR} have occurred.
- */
- public static final int LIBGAMMA_GAMMA_NOT_SPECIFIED_AND_EDID_CHECKSUM_ERROR = -33;
-
- /**
- * Failed to query the gamma ramps size from the
- * adjustment method, reason unknown.
- */
- public static final int LIBGAMMA_GAMMA_RAMPS_SIZE_QUERY_FAILED = -34;
-
- /**
- * The selected partition could not be opened,
- * reason unknown.
- */
- public static final int LIBGAMMA_OPEN_PARTITION_FAILED = -35;
-
- /**
- * The selected site could not be opened,
- * reason unknown.
- */
- public static final int LIBGAMMA_OPEN_SITE_FAILED = -36;
-
- /**
- * Failed to query the adjustment method for
- * its protocol version, reason unknown.
- */
- public static final int LIBGAMMA_PROTOCOL_VERSION_QUERY_FAILED = -37;
-
- /**
- * The adjustment method's version of its
- * protocol is not supported.
- */
- public static final int LIBGAMMA_PROTOCOL_VERSION_NOT_SUPPORTED = -38;
-
- /**
- * The adjustment method failed to list
- * available partitions, reason unknown.
- */
- public static final int LIBGAMMA_LIST_PARTITIONS_FAILED = -39;
-
- /**
- * Partition exists by index, but the partition
- * at that index does not exist.
- */
- public static final int LIBGAMMA_NULL_PARTITION = -40;
-
- /**
- * There is not mointor connected to the
- * connector of the selected CRTC.
- */
- public static final int LIBGAMMA_NOT_CONNECTED = -41;
-
- /**
- * Data extraction from a reply from the
- * adjustment method failed, reason unknown.
- */
- public static final int LIBGAMMA_REPLY_VALUE_EXTRACTION_FAILED = -42;
-
- /**
- * No EDID property was found on the output.
- */
- public static final int LIBGAMMA_EDID_NOT_FOUND = -43;
-
- /**
- * Failed to list properties on the output,
- * reason unknown.
- */
- public static final int LIBGAMMA_LIST_PROPERTIES_FAILED = -44;
-
- /**
- * Failed to query a property's value from
- * the output, reason unknown.
- */
- public static final int LIBGAMMA_PROPERTY_VALUE_QUERY_FAILED = -45;
-
- /**
- * A request for information on an output
- * failed, reason unknown.
- */
- public static final int LIBGAMMA_OUTPUT_INFORMATION_QUERY_FAILED = -46;
-
-
- /**
- * The number of the libgamma error with the
- * lowest number. If this is lower than the
- * number your program thinks it should be sould
- * update your program for new errors.
- */
- public static final int LIBGAMMA_ERROR_MIN = -46;
-
-
-
- /**
- * Constructor.
- *
- * @param error_code The error code.
- */
- public LibgammaException(int error_code)
- {
- this.error_code = error_code;
- if (error_code == LIBGAMMA_DEVICE_REQUIRE_GROUP)
- { this.group_gid = libgamma_group_gid();
- this.group_name = libgamma_group_name();
- }
- else
- { this.group_gid = 0;
- this.group_name = null;
- }
- if (error_code < 0)
- this.string = name_of_error(error_code);
- else
- this.string = strerror(error_code);
- }
-
-
- /**
- * The error code.
- * Cannot be {@link #LIBGAMMA_ERRNO_SET}.
- */
- public final int error_code;
-
- /**
- * Group that the user needs to be a member of if
- * {@link #error_code} is {@link #LIBGAMMA_DEVICE_REQUIRE_GROUP}.
- */
- public final int group_gid;
-
- /**
- * Group that the user needs to be a member of if
- * {@link #error_code} is {@link #LIBGAMMA_DEVICE_REQUIRE_GROUP},
- * {@code null} if the name of the group {@link #group_gid}
- * cannot be determined.
- */
- public final String group_name;
-
- /**
- * Name of textual description of the error.
- */
- public final String string;
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString()
- {
- return this.string;
- }
-
-
-
- /**
- * Returns the name of the definition associated with
- * a <tt>libgamma</tt> error code.
- *
- * @param value The error code.
- * @return The name of the definition associated with the error code,
- * {@code null} if the error code does not exist.
- */
- public static native String name_of_error(int value);
-
- /**
- * Return the value of a <tt>libgamma</tt> error definition
- * refered to by name.
- *
- * @param name The name of the definition associated with the error code.
- * @return The error code, zero if the name is {@code null}
- * or does not refer to a <tt>libgamma</tt> error.
- */
- public static native int value_of_error(String name);
-
-
- /**
- * Acquire the value that should go to {@link #group_gid}.
- *
- * @return The value that should go to {@link #group_gid}.
- */
- private static native int libgamma_group_gid();
-
- /**
- * Acquire the value that should go to {@link #group_name}.
- *
- * @return The value that should go to {@link #group_name}.
- */
- private static native String libgamma_group_name();
-
- /**
- * Get a textual description of a system error code.
- *
- * @param error_code The error code.
- * @return A textual description of the error code.
- */
- private static native String strerror(int error_code);
-
-}
-
diff --git a/src/libgamma/Partition.java b/src/libgamma/Partition.java
deleted file mode 100644
index 740bc11..0000000
--- a/src/libgamma/Partition.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/**
- * jlibgamma — Display server abstraction layer for gamma ramp and Java
- * Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
- *
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-package libgamma;
-
-
-/**
- * Partition state.
- *
- * Probably the majority of display server only one partition
- * per site. However, X.org can, and traditional used to have
- * on multi-headed environments, multiple partitions per site.
- * In X.org partitions are called 'screens'. It is not to be
- * confused with monitor. A screen is a collection of monitors,
- * and the mapping from monitors to screens is a surjection.
- * On hardware-level adjustment methods, such as Direct
- * Rendering Manager, a partition is a graphics card.
- */
-public class Partition
-{
- /**
- * Type initialiser.
- */
- static
- {
- Libgamma.initialise();
- }
-
-
-
- /**
- * Constructor.
- *
- * @param site The site this partition belongs to.
- * @param partition The index of the partition.
- */
- public Partition(Site site, int partition) throws LibgammaException
- {
- this.site = site;
- this.partition = partition;
- long[] r = libgamma_partition_create(site.address, partition);
- this.address = r[0];
- this.crtcs_available = (int)(r[1]);
- if (r[2] != 0)
- throw new LibgammaException((int)(r[2]));
- }
-
-
- /**
- * The site this partition belongs to.
- */
- public final Site site;
-
- /**
- * The index of the partition.
- */
- public final int partition;
-
- /**
- * The number of CRTC:s that are available under this
- * partition. Note that the CRTC:s are not necessarily
- * online.
- */
- public final int crtcs_available;
-
- /**
- * The address of the native object.
- */
- final long address;
-
-
- /**
- * Release resources.
- */
- public void close()
- {
- libgamma_partition_free(this.address);
- }
-
- /**
- * Restore the gamma ramps all CRTC:s within the partition to the system settings.
- */
- public void restore() throws LibgammaException
- {
- int r = libgamma_partition_restore(this.address);
- if (r != 0)
- throw new LibgammaException(r);
- }
-
-
- /**
- * {@inheritDoc}
- */
- public String toString()
- {
- return "<Partition: site = " + this.site.toString() + ", " +
- "partition = " + Integer.toString(this.partition) + ", " +
- "crtcs_available = " + Integer.toString(this.crtcs_available) + ">";
- }
-
-
-
- /**
- * Create a partition state.
- *
- * @param site The site state for the site that the partition belongs to.
- * @param partition The index of the partition within the site.
- * @return Element 0: The value for {@link #address}.
- * Element 1: The value for {@link #crtcs_available}
- * Element 2: Error code, zero on success.
- */
- private static native long[] libgamma_partition_create(long site, int partition);
-
- /**
- * Release all resources held by a partition state
- * and free the partition state pointer.
- *
- * @param address The partition state.
- */
- private static native void libgamma_partition_free(long address);
-
- /**
- * Restore the gamma ramps all CRTC:s within a partition to the system settings.
- *
- * @param address The partition state.
- * @return Zero on success, and error code on failure.
- */
- private static native int libgamma_partition_restore(long address);
-
-}
-
diff --git a/src/libgamma/Ramp.java b/src/libgamma/Ramp.java
deleted file mode 100644
index ef55f9d..0000000
--- a/src/libgamma/Ramp.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/**
- * jlibgamma — Display server abstraction layer for gamma ramp and Java
- * Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
- *
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-package libgamma;
-
-
-/**
- * A single gamma ramp.
- */
-public abstract class Ramp
-{
- /**
- * Type initialiser.
- */
- static
- {
- Libgamma.initialise();
- }
-
-
-
- /**
- * Constructor.
- *
- * @param address The address of the native object.
- * @param size The size of the encoding axis of the gamma ramp.
- */
- Ramp(long address, int size)
- {
- this.size = size;
- this.address = address;
- }
-
-
- /**
- * The size of the encoding axis of the gamma ramp.
- */
- public final int size;
-
- /**
- * The address of the native object.
- */
- protected final long address;
-
-
- /**
- * {@inheritDoc}
- */
- public String toString()
- {
- return "<Ramp: size = " + Integer.toString(size) + ">";
- }
-
-
- /**
- * Read the value of a stop in an 8-bit ramp.
- *
- * @param address The address of the ramp.
- * @param stop The index of the stop.
- * @return The value of the stop.
- */
- protected static native short libgamma_gamma_ramps8_get(long address, int stop);
-
- /**
- * Read the value of a stop in a 16-bit ramp.
- *
- * @param address The address of the ramp.
- * @param stop The index of the stop.
- * @return The value of the stop.
- */
- protected static native int libgamma_gamma_ramps16_get(long address, int stop);
-
- /**
- * Read the value of a stop in a 32-bit ramp.
- *
- * @param address The address of the ramp.
- * @param stop The index of the stop.
- * @return The value of the stop.
- */
- protected static native long libgamma_gamma_ramps32_get(long address, int stop);
-
- /**
- * Read the value of a stop in a 64-bit ramp.
- *
- * @param address The address of the ramp.
- * @param stop The index of the stop.
- * @return The value of the stop.
- */
- protected static native long libgamma_gamma_ramps64_get(long address, int stop);
-
- /**
- * Read the value of a stop in a single precision floating point ramp.
- *
- * @param address The address of the ramp.
- * @param stop The index of the stop.
- * @return The value of the stop.
- */
- protected static native float libgamma_gamma_rampsf_get(long address, int stop);
-
- /**
- * Read the value of a stop in a double precision floating point ramp.
- *
- * @param address The address of the ramp.
- * @param stop The index of the stop.
- * @return The value of the stop.
- */
- protected static native double libgamma_gamma_rampsd_get(long address, int stop);
-
-
- /**
- * Set the value of a stop in an 8-bit ramp.
- *
- * @param address The address of the ramp.
- * @param stop The index of the stop.
- * @param value The value of the stop.
- */
- protected static native void libgamma_gamma_ramps8_set(long address, int stop, short value);
-
- /**
- * Set the value of a stop in a 16-bit ramp.
- *
- * @param address The address of the ramp.
- * @param stop The index of the stop.
- * @param value The value of the stop.
- */
- protected static native void libgamma_gamma_ramps16_set(long address, int stop, int value);
-
- /**
- * Set the value of a stop in a 32-bit ramp.
- *
- * @param address The address of the ramp.
- * @param stop The index of the stop.
- * @param value The value of the stop.
- */
- protected static native void libgamma_gamma_ramps32_set(long address, int stop, long value);
-
- /**
- * Set the value of a stop in a 64-bit ramp.
- *
- * @param address The address of the ramp.
- * @param stop The index of the stop.
- * @param value The value of the stop.
- */
- protected static native void libgamma_gamma_ramps64_set(long address, int stop, long value);
-
- /**
- * Set the value of a stop in a single precision floating point ramp.
- *
- * @param address The address of the ramp.
- * @param stop The index of the stop.
- * @param value The value of the stop.
- */
- protected static native void libgamma_gamma_rampsf_set(long address, int stop, float value);
-
- /**
- * Set the value of a stop in a double precision floating point ramp.
- *
- * @param address The address of the ramp.
- * @param stop The index of the stop.
- * @param value The value of the stop.
- */
- protected static native void libgamma_gamma_rampsd_set(long address, int stop, double value);
-
-}
-
diff --git a/src/libgamma/Ramp16.java b/src/libgamma/Ramp16.java
deleted file mode 100644
index cbf7ff0..0000000
--- a/src/libgamma/Ramp16.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
- * jlibgamma — Display server abstraction layer for gamma ramp and Java
- * Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
- *
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-package libgamma;
-
-
-/**
- * A single 16-bit gamma ramp.
- */
-public class Ramp16 extends Ramp
-{
- /**
- * Type initialiser.
- */
- static
- {
- Libgamma.initialise();
- }
-
-
-
- /**
- * Constructor.
- *
- * @param address The address of the native object.
- * @param size The size of the encoding axis of the gamma ramp.
- */
- Ramp16(long address, int size)
- {
- super(address, size);
- }
-
-
- /**
- * Read the value of a stop.
- *
- * @param stop The index of the stop.
- * @return The value of the stop.
- */
- public int get(int stop)
- {
- return libgamma_gamma_ramps16_get(this.address, stop);
- }
-
-
- /**
- * Read the value of a stop.
- *
- * @param stop The index of the stop.
- * @param value The new value of the stop.
- * @return The new value of the stop.
- */
- public long set(int stop, long value)
- {
- libgamma_gamma_ramps16_set(this.address, stop, (int)value);
- return value;
- }
-
- /**
- * Read the value of a stop.
- *
- * @param stop The index of the stop.
- * @param value The new value of the stop.
- * @return The new value of the stop.
- */
- public int set(int stop, int value)
- {
- libgamma_gamma_ramps16_set(this.address, stop, value);
- return value;
- }
-
- /**
- * Read the value of a stop.
- *
- * @param stop The index of the stop.
- * @param value The new value of the stop.
- * @return The new value of the stop.
- */
- public short set(int stop, short value)
- {
- libgamma_gamma_ramps16_set(this.address, stop, value);
- return value;
- }
-
-}
-
diff --git a/src/libgamma/Ramp32.java b/src/libgamma/Ramp32.java
deleted file mode 100644
index 563a77f..0000000
--- a/src/libgamma/Ramp32.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- * jlibgamma — Display server abstraction layer for gamma ramp and Java
- * Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
- *
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-package libgamma;
-
-
-/**
- * A single 32-bit gamma ramp.
- */
-public class Ramp32 extends Ramp
-{
- /**
- * Constructor.
- *
- * @param address The address of the native object.
- * @param size The size of the encoding axis of the gamma ramp.
- */
- Ramp32(long address, int size)
- {
- super(address, size);
- }
-
-
- /**
- * Read the value of a stop.
- *
- * @param stop The index of the stop.
- * @return The value of the stop.
- */
- public long get(int stop)
- {
- return libgamma_gamma_ramps32_get(this.address, stop);
- }
-
-
- /**
- * Read the value of a stop.
- *
- * @param stop The index of the stop.
- * @param value The new value of the stop.
- * @return The new value of the stop.
- */
- public long set(int stop, long value)
- {
- libgamma_gamma_ramps32_set(this.address, stop, value);
- return value;
- }
-
- /**
- * Read the value of a stop.
- *
- * @param stop The index of the stop.
- * @param value The new value of the stop.
- * @return The new value of the stop.
- */
- public int set(int stop, int value)
- {
- libgamma_gamma_ramps32_set(this.address, stop, value);
- return value;
- }
-
-}
-
diff --git a/src/libgamma/Ramp64.java b/src/libgamma/Ramp64.java
deleted file mode 100644
index d772e96..0000000
--- a/src/libgamma/Ramp64.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * jlibgamma — Display server abstraction layer for gamma ramp and Java
- * Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
- *
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-package libgamma;
-
-
-/**
- * A single 64-bit gamma ramp.
- */
-public class Ramp64 extends Ramp
-{
- /**
- * Constructor.
- *
- * @param address The address of the native object.
- * @param size The size of the encoding axis of the gamma ramp.
- */
- Ramp64(long address, int size)
- {
- super(address, size);
- }
-
-
- /**
- * Read the value of a stop.
- *
- * @param stop The index of the stop.
- * @return The value of the stop.
- */
- public long get(int stop)
- {
- return libgamma_gamma_ramps64_get(this.address, stop);
- }
-
-
- /**
- * Read the value of a stop.
- *
- * @param stop The index of the stop.
- * @param value The new value of the stop.
- * @return The new value of the stop.
- */
- public long set(int stop, long value)
- {
- libgamma_gamma_ramps64_set(this.address, stop, value);
- return value;
- }
-
-}
-
diff --git a/src/libgamma/Ramp8.java b/src/libgamma/Ramp8.java
deleted file mode 100644
index ca0150a..0000000
--- a/src/libgamma/Ramp8.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/**
- * jlibgamma — Display server abstraction layer for gamma ramp and Java
- * Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
- *
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-package libgamma;
-
-
-/**
- * A single 8-bit gamma ramp.
- */
-public class Ramp8 extends Ramp
-{
- /**
- * Constructor.
- *
- * @param address The address of the native object.
- * @param size The size of the encoding axis of the gamma ramp.
- */
- Ramp8(long address, int size)
- {
- super(address, size);
- }
-
-
- /**
- * Read the value of a stop.
- *
- * @param stop The index of the stop.
- * @return The value of the stop.
- */
- public short get(short stop)
- {
- return libgamma_gamma_ramps8_get(this.address, stop);
- }
-
-
- /**
- * Read the value of a stop.
- *
- * @param stop The index of the stop.
- * @param value The new value of the stop.
- * @return The new value of the stop.
- */
- public long set(int stop, long value)
- {
- libgamma_gamma_ramps8_set(this.address, stop, (short)value);
- return value;
- }
-
- /**
- * Read the value of a stop.
- *
- * @param stop The index of the stop.
- * @param value The new value of the stop.
- * @return The new value of the stop.
- */
- public int set(int stop, int value)
- {
- libgamma_gamma_ramps8_set(this.address, stop, (short)value);
- return value;
- }
-
- /**
- * Read the value of a stop.
- *
- * @param stop The index of the stop.
- * @param value The new value of the stop.
- * @return The new value of the stop.
- */
- public short set(int stop, short value)
- {
- libgamma_gamma_ramps8_set(this.address, stop, value);
- return value;
- }
-
- /**
- * Read the value of a stop.
- *
- * @param stop The index of the stop.
- * @param value The new value of the stop.
- * @return The new value of the stop.
- */
- public byte set(int stop, byte value)
- {
- libgamma_gamma_ramps8_set(this.address, stop, value);
- return value;
- }
-
-}
-
diff --git a/src/libgamma/Rampd.java b/src/libgamma/Rampd.java
deleted file mode 100644
index 7f34eb4..0000000
--- a/src/libgamma/Rampd.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- * jlibgamma — Display server abstraction layer for gamma ramp and Java
- * Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
- *
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-package libgamma;
-
-
-/**
- * A single double percision floating point gamma ramp.
- */
-public class Rampd extends Ramp
-{
- /**
- * Type initialiser.
- */
- static
- {
- Libgamma.initialise();
- }
-
-
-
- /**
- * Constructor.
- *
- * @param address The address of the native object.
- * @param size The size of the encoding axis of the gamma ramp.
- */
- Rampd(long address, int size)
- {
- super(address, size);
- }
-
-
- /**
- * Read the value of a stop.
- *
- * @param stop The index of the stop.
- * @return The value of the stop.
- */
- public double get(int stop)
- {
- return libgamma_gamma_rampsd_get(this.address, stop);
- }
-
-
- /**
- * Read the value of a stop.
- *
- * @param stop The index of the stop.
- * @param value The new value of the stop.
- * @return The new value of the stop.
- */
- public float set(int stop, float value)
- {
- libgamma_gamma_rampsd_set(this.address, stop, value);
- return value;
- }
-
-
- /**
- * Read the value of a stop.
- *
- * @param stop The index of the stop.
- * @param value The new value of the stop.
- * @return The new value of the stop.
- */
- public double set(int stop, double value)
- {
- libgamma_gamma_rampsd_set(this.address, stop, value);
- return value;
- }
-
-}
-
diff --git a/src/libgamma/Rampf.java b/src/libgamma/Rampf.java
deleted file mode 100644
index 31fd55b..0000000
--- a/src/libgamma/Rampf.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/**
- * jlibgamma — Display server abstraction layer for gamma ramp and Java
- * Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
- *
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-package libgamma;
-
-
-/**
- * A single single percision floating point gamma ramp.
- */
-public class Rampf extends Ramp
-{
- /**
- * Constructor.
- *
- * @param address The address of the native object.
- * @param size The size of the encoding axis of the gamma ramp.
- */
- Rampf(long address, int size)
- {
- super(address, size);
- }
-
-
- /**
- * Read the value of a stop.
- *
- * @param stop The index of the stop.
- * @return The value of the stop.
- */
- public float get(int stop)
- {
- return libgamma_gamma_rampsf_get(this.address, stop);
- }
-
-
- /**
- * Read the value of a stop.
- *
- * @param stop The index of the stop.
- * @param value The new value of the stop.
- * @return The new value of the stop.
- */
- public float set(int stop, float value)
- {
- libgamma_gamma_rampsf_set(this.address, stop, value);
- return value;
- }
-
-
- /**
- * Read the value of a stop.
- *
- * @param stop The index of the stop.
- * @param value The new value of the stop.
- * @return The new value of the stop.
- */
- public double set(int stop, double value)
- {
- libgamma_gamma_rampsf_set(this.address, stop, (float)value);
- return value;
- }
-
-}
-
diff --git a/src/libgamma/Site.java b/src/libgamma/Site.java
deleted file mode 100644
index 2dbe2b3..0000000
--- a/src/libgamma/Site.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/**
- * jlibgamma — Display server abstraction layer for gamma ramp and Java
- * Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
- *
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-package libgamma;
-
-
-/**
- * Site state.
- *
- * On operating systems that integrate a graphical environment
- * there is usually just one site. However, one systems with
- * pluggable graphics, like Unix-like systems such as GNU/Linux
- * and the BSD:s, there can usually be any (feasible) number of
- * sites. In X.org parlance they are called displays.
- */
-public class Site
-{
- /**
- * Type initialiser.
- */
- static
- {
- Libgamma.initialise();
- }
-
-
-
- /**
- * Constructor.
- *
- * @param method The adjustmet method.
- * @param site The site identifier.
- */
- public Site(AdjustmentMethod method, String site) throws LibgammaException
- {
- this.method = method;
- this.site = site;
- long[] r = libgamma_site_create(method.value, site);
- this.address = r[0];
- this.partitions_available = (int)(r[1]);
- if (r[2] != 0)
- throw new LibgammaException((int)(r[2]));
- }
-
-
- /**
- * This field specifies, for the methods if this library,
- * which adjustment method (display server and protocol)
- * is used to adjust the gamma ramps.
- */
- public final AdjustmentMethod method;
-
- /**
- * The site identifier. It can either be {@code null} or
- * a string. {@code null} indicates the default site. On
- * systems like the Unix-like systems, where the graphics
- * are pluggable, this is usually resolved by an environment
- * variable, such as "DISPLAY" for X.org.
- */
- public final String site;
-
- /**
- * The number of partitions that is available on this site.
- * Probably the majority of display server only one partition
- * per site. However, X.org can, and traditional used to have
- * on multi-headed environments, multiple partitions per site.
- * In X.org partitions are called 'screens'. It is not to be
- * confused with monitor. A screen is a collection of monitors,
- * and the mapping from monitors to screens is a surjection.
- * On hardware-level adjustment methods, such as Direct
- * Rendering Manager, a partition is a graphics card.
- */
- public final int partitions_available;
-
- /**
- * The address of the native object.
- */
- final long address;
-
-
- /**
- * Release resources.
- */
- public void close()
- {
- libgamma_site_free(this.address);
- }
-
- /**
- * Restore the gamma ramps all CRTC:s within the site to the system settings.
- */
- public void restore() throws LibgammaException
- {
- int r = libgamma_site_restore(this.address);
- if (r != 0)
- throw new LibgammaException(r);
- }
-
-
- /**
- * {@inheritDoc}
- */
- public String toString()
- {
- return "<Site: method = " + this.method.toString() + ", " +
- "site = " + (this.site == null ? "(null)" : this.site) + ", " +
- "partitions_available = " + Integer.toString(this.partitions_available) + ">";
- }
-
-
-
-
- /**
- * Create a site state.
- *
- * @param method The adjustment method (display server and protocol.)
- * @param site The site identifier.
- * @return Element 0: The value for {@link #address}.
- * Element 1: The value for {@link #partitions_available}
- * Element 2: Error code, zero on success.
- */
- private static native long[] libgamma_site_create(int method, String site);
-
- /**
- * Release all resources held by a site state
- * and free the site state pointer.
- *
- * @param address The site state.
- */
- private static native void libgamma_site_free(long address);
-
- /**
- * Restore the gamma ramps all CRTC:s within a site to the system settings.
- *
- * @param address The site state.
- * @return Zero on success, and error code on failure.
- */
- private static native int libgamma_site_restore(long address);
-
-}
-
diff --git a/src/libgamma/SubpixelOrder.java b/src/libgamma/SubpixelOrder.java
deleted file mode 100644
index 9cc9efd..0000000
--- a/src/libgamma/SubpixelOrder.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * jlibgamma — Display server abstraction layer for gamma ramp and Java
- * Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
- *
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-package libgamma;
-
-
-/**
- * Orders for subpixels. Currently the possible values are
- * very biased to LCD, Plasma and monochrome monitors.
- */
-public enum SubpixelOrder
-{
- /**
- * The adjustment method does not know the order of the subpixels.
- * (This could be considered an error.)
- */
- UNKNOWN(0),
-
- /**
- * There are no subpixels in the monitor.
- */
- NONE(1),
-
- /**
- * The subpixels are ordered red, green and then blue, from left to right.
- */
- HORIZONTAL_RGB(2),
-
- /**
- * The subpixels are ordered blue, green and then red, from left to right.
- */
- HORIZONTAL_BGR(3),
-
- /**
- * The subpixels are ordered red, green and then blue, from the top down.
- */
- VERTICAL_RGB(4),
-
- /**
- * The subpixels are ordered blue, green and then red, from the top down.
- */
- VERTICAL_BGR(5)
-
- ;
-
-
- /**
- * Type initialiser.
- */
- static
- {
- Libgamma.initialise();
- }
-
-
-
- /**
- * Subpixel orders by their numerical values.
- */
- public static SubpixelOrder[] VALUES =
- {
- UNKNOWN, NONE, HORIZONTAL_RGB, HORIZONTAL_BGR, VERTICAL_RGB, VERTICAL_BGR
- };
-
-
- /**
- * Constructor.
- *
- * @param value The numerical value of the subpixel order.
- */
- private SubpixelOrder(int value)
- {
- this.value = value;
- }
-
-
- /**
- * The numerical value of the subpixel order.
- */
- public int value;
-
-}
-
diff --git a/src/libgamma_AdjustmentMethod.c b/src/libgamma_AdjustmentMethod.c
deleted file mode 100644
index 76c4877..0000000
--- a/src/libgamma_AdjustmentMethod.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/**
- * jlibgamma -- Display server abstraction layer for gamma ramp and Java
- * Copyright (C) 2014 Mattias Andrée (maandree@member.fsf.org)
- *
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-#include "libgamma_AdjustmentMethod.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-#include <libgamma.h>
-
-
-#define J JNIEnv* env, jclass class
-
-
-#if LIBGAMMA_METHOD_COUNT > 6
-# error LIBGAMMA_METHOD_COUNT has been updated
-#endif
-
-
-
-/**
- * List available adjustment methods by their order of preference based on the environment.
- *
- * @param operation Allowed values:
- * 0: Methods that the environment suggests will work, excluding fake.
- * 1: Methods that the environment suggests will work, including fake.
- * 2: All real non-fake methods.
- * 3: All real methods.
- * 4: All methods.
- * Other values invoke undefined behaviour.
- * @return List available adjustment methods by their order of preference.
- */
-jintArray Java_libgamma_AdjustmentMethod_libgamma_1list_1methods(J, jint operation)
-{
- int methods[LIBGAMMA_METHOD_COUNT];
- size_t i, n;
- jintArray rc;
-
- n = libgamma_list_methods(methods, LIBGAMMA_METHOD_COUNT, operation);
- if (n > LIBGAMMA_METHOD_COUNT)
- abort(); /* Prevented by the #if above and package maintenance. */
-
- rc = (*env)->NewIntArray(env, n);
-
- /* Remember, jint is 32 bits, int is 16+ bits. */
- for (i = 0; i < n; i++)
- (*env)->SetIntArrayRegion(env, rc, i, 1, methods + i);
-
- return rc;
- (void) class;
-}
-
-
-/**
- * Check whether an adjustment method is available, non-existing (invalid) methods will be
- * identified as not available under the rationale that the library may be out of date.
- *
- * @param method The adjustment method.
- * @return Whether the adjustment method is available.
- */
-jint Java_libgamma_AdjustmentMethod_libgamma_1is_1method_1available(J, jint method)
-{
- return libgamma_is_method_available(method);
- (void) env;
- (void) class;
-}
-
-
-
-/**
- * Return the capabilities of an adjustment method.
- *
- * @param method The adjustment method (display server and protocol).
- * @return Input parameter to the constructor of {@link AdjustmentMethodCapabilities}.
- */
-jlong Java_libgamma_AdjustmentMethod_libgamma_1method_1capabilities(J, jint method)
-{
- libgamma_method_capabilities_t caps;
- jlong rc;
-
- libgamma_method_capabilities(&caps, method);
- rc = (jlong)(caps.crtc_information);
- rc &= 0xFFFFFFFFLL;
- rc |= caps.default_site_known ? (1LL < 33) : 0;
- rc |= caps.multiple_sites ? (1LL < 34) : 0;
- rc |= caps.multiple_partitions ? (1LL < 35) : 0;
- rc |= caps.multiple_crtcs ? (1LL < 36) : 0;
- rc |= caps.partitions_are_graphics_cards ? (1LL < 37) : 0;
- rc |= caps.site_restore ? (1LL < 38) : 0;
- rc |= caps.partition_restore ? (1LL < 39) : 0;
- rc |= caps.crtc_restore ? (1LL < 40) : 0;
- rc |= caps.identical_gamma_sizes ? (1LL < 41) : 0;
- rc |= caps.fixed_gamma_size ? (1LL < 42) : 0;
- rc |= caps.fixed_gamma_depth ? (1LL < 43) : 0;
- rc |= caps.real ? (1LL < 44) : 0;
- rc |= caps.fake ? (1LL < 45) : 0;
- return rc;
- (void) env;
- (void) class;
-}
-
-
-/**
- * Return the default site for an adjustment method.
- *
- * @param method The adjustment method (display server and protocol.)
- * @return The default site, {@code null} if it cannot be determined or
- * if multiple sites are not supported by the adjustment method.
- */
-jstring Java_libgamma_AdjustmentMethod_libgamma_1method_1default_1site(J, jint method)
-{
- /* It is really unlikely that `malloc` returns `NULL` here
- * and error handing makes this unnecessarily comples,
- * therefore we will simply skip it. */
-
- char* do_not_free_this = libgamma_method_default_site(method);
- char* this_will_be_freed;
- size_t n;
- if (do_not_free_this == NULL)
- return NULL;
-
- n = strlen(do_not_free_this) + 1;
- this_will_be_freed = malloc(n * sizeof(char));
- memcpy(this_will_be_freed, do_not_free_this, n * sizeof(char));
-
- return (*env)->NewStringUTF(env, this_will_be_freed);
- (void) class;
-}
-
-
-/**
- * Return the default variable that determines
- * the default site for an adjustment method.
- *
- * @param method The adjustment method (display server and protocol.)
- * @return The environ variables that is used to determine the
- * default site. {@code null} if there is none, that is,
- * if the method does not support multiple sites.
- */
-jstring Java_libgamma_AdjustmentMethod_libgamma_1method_1default_1site_1variable(J, jint method)
-{
- /* It is really unlikely that `malloc` returns `NULL` here
- * and error handing makes this unnecessarily comples,
- * therefore we will simply skip it. */
-
- const char* do_not_free_this = libgamma_method_default_site_variable(method);
- char* this_will_be_freed;
- size_t n;
- if (do_not_free_this == NULL)
- return NULL;
-
- n = strlen(do_not_free_this) + 1;
- this_will_be_freed = malloc(n * sizeof(char));
- memcpy(this_will_be_freed, do_not_free_this, n * sizeof(char));
-
- return (*env)->NewStringUTF(env, this_will_be_freed);
- (void) class;
-}
-
diff --git a/src/libgamma_CRTC.c b/src/libgamma_CRTC.c
deleted file mode 100644
index 4146de6..0000000
--- a/src/libgamma_CRTC.c
+++ /dev/null
@@ -1,441 +0,0 @@
-/**
- * jlibgamma -- Display server abstraction layer for gamma ramp and Java
- * Copyright (C) 2014 Mattias Andrée (maandree@member.fsf.org)
- *
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-#include "libgamma_CRTC.h"
-
-#include <errno.h>
-#include <stdlib.h>
-
-#include <libgamma.h>
-
-
-#define J JNIEnv* env, jclass class
-
-
-
-/**
- * Make a failure-return.
- *
- * @param error_code The error code returned from the failing function or zero to read `errno`.
- * @return The object to return.
- */
-static jlongArray fail(JNIEnv* env, int error_code)
-{
- jlongArray rc = (*env)->NewLongArray(env, 2);
- jlong e, z = 0;
- if ((error_code == LIBGAMMA_ERRNO_SET) || !error_code)
- error_code = errno;
- e = (jlong)error_code;
- (*env)->SetLongArrayRegion(env, rc, 0, 1, &z);
- (*env)->SetLongArrayRegion(env, rc, 1, 1, &e);
- return rc;
-}
-
-
-/**
- * Make a success-return.
- *
- * @param state The native object.
- * @return The object to return.
- */
-static jlongArray ok(JNIEnv* env, void* state)
-{
- jlong a = (jlong)(size_t)state, z = 0;
- jlongArray rc = (*env)->NewLongArray(env, 2);
- (*env)->SetLongArrayRegion(env, rc, 0, 1, &a);
- (*env)->SetLongArrayRegion(env, rc, 1, 1, &z);
- return rc;
-}
-
-
-/**
- * Create a CRTC state.
- *
- * @param partition The partition state for the partition that the CRTC belongs to.
- * @param crtc The index of the CRTC within the partition.
- * @return Element 0: The value for {@link #address}.
- * Element 1: Error code, zero on success.
- */
-jlongArray Java_libgamma_CRTC_libgamma_1crtc_1create(J, jlong partition, jint crtc)
-{
- libgamma_crtc_state_t* state = malloc(sizeof(libgamma_crtc_state_t));
- void* super = (void*)(size_t)partition;
- int r;
- if (state == NULL)
- return fail(env, 0);
- r = libgamma_crtc_initialise(state, super, crtc);
- if (r != 0)
- return fail(env, r);
- return ok(env, state);
- (void) class;
-}
-
-
-/**
- * Release all resources held by a CRTC state
- * and free the CRTC state pointer.
- *
- * @param address The CRTC state.
- */
-void Java_libgamma_CRTC_libgamma_1crtc_1free(J, jlong address)
-{
- void* this = (void*)(size_t)address;
- libgamma_crtc_free(this);
- (void) env;
- (void) class;
-}
-
-
-/**
- * Restore the gamma ramps for a CRTC to the system settings for that CRTC.
- *
- * @param address The CRTC state.
- * @return Zero on success, and error code on failure.
- */
-jint Java_libgamma_CRTC_libgamma_1crtc_1restore(J, jlong address)
-{
- void* this = (void*)(size_t)address;
- int r = libgamma_crtc_restore(this);
- if (r != 0)
- return r == LIBGAMMA_ERRNO_SET ? errno : r;
- return 0;
- (void) env;
- (void) class;
-}
-
-
-/**
- * Read information about a CRTC.
- *
- * @param crtc The state of the CRTC whose information should be read.
- * @param fields OR:ed identifiers for the information about the CRTC that should be read.
- * @return Input parameters for the constructor of {@link CRTCInformation}
- */
-jobjectArray Java_libgamma_CRTC_libgamma_1get_1crtc_1information(J, jlong crtc, jint fields)
-{
- void* this_voidp = (void*)(size_t)crtc;
- libgamma_crtc_state_t* this = this_voidp;
- jbyteArray edid = NULL;
- jstring connector_name = NULL;
- jclass class_of_jobject = (*env)->FindClass(env, "java/lang/Object");
- jintArray ints_ = (*env)->NewIntArray(env, 25);
- jfloatArray gamma_ = (*env)->NewFloatArray(env, 3);
- jobjectArray rc = (*env)->NewObjectArray(env, 4, class_of_jobject, NULL);
- libgamma_crtc_information_t info;
- jint ints[25];
- jfloat gamma[3];
-
- libgamma_get_crtc_information(&info, this, fields);
-
- if (info.edid != NULL)
- {
- edid = (*env)->NewByteArray(env, info.edid_length);
- (*env)->SetByteArrayRegion(env, edid, 0, info.edid_length, (const jbyte*)(info.edid));
- free(info.edid);
- }
-
- if (connector_name != NULL)
- connector_name = (*env)->NewStringUTF(env, info.connector_name);
-
- gamma[0] = (jfloat)info.gamma_red;
- gamma[1] = (jfloat)info.gamma_green;
- gamma[2] = (jfloat)info.gamma_blue;
-
- ints[0] = (jint)info.edid_error;
- ints[1] = (jint)info.width_mm;
- ints[2] = (jint)info.width_mm_error;
- ints[3] = (jint)info.height_mm;
- ints[4] = (jint)info.height_mm_error;
- ints[5] = (jint)info.width_mm_edid;
- ints[6] = (jint)info.width_mm_edid_error;
- ints[7] = (jint)info.height_mm_edid;
- ints[8] = (jint)info.height_mm_edid_error;
- ints[9] = (jint)info.red_gamma_size;
- ints[10] = (jint)info.green_gamma_size;
- ints[11] = (jint)info.blue_gamma_size;
- ints[12] = (jint)info.gamma_size_error;
- ints[13] = (jint)info.gamma_depth;
- ints[14] = (jint)info.gamma_depth_error;
- ints[15] = (jint)info.gamma_support;
- ints[16] = (jint)info.gamma_support_error;
- ints[17] = (jint)info.subpixel_order;
- ints[18] = (jint)info.subpixel_order_error;
- ints[19] = (jint)info.active;
- ints[20] = (jint)info.active_error;
- ints[21] = (jint)info.connector_name_error;
- ints[22] = (jint)info.connector_type;
- ints[23] = (jint)info.connector_type_error;
- ints[24] = (jint)info.gamma_error;
-
- (*env)->SetIntArrayRegion(env, ints_, 0, 25, ints);
- (*env)->SetFloatArrayRegion(env, gamma_, 0, 3, gamma);
-
- (*env)->SetObjectArrayElement(env, rc, 0, edid);
- (*env)->SetObjectArrayElement(env, rc, 1, connector_name);
- (*env)->SetObjectArrayElement(env, rc, 2, gamma_);
- (*env)->SetObjectArrayElement(env, rc, 3, ints_);
-
- return rc;
- (void) class;
-}
-
-
-
-/**
- * Get the current gamma ramps for a CRTC, 8-bit gamma-depth version.
- *
- * @param address The CRTC state.
- * @param ramps The gamma ramps to fill with the current values
- * @return Zero on success, an error code on failure.
- */
-jint Java_libgamma_CRTC_libgamma_1crtc_1get_1gamma_1ramps8(J, jlong address, jlong ramps)
-{
- void* crtc_voidp = (void*)(size_t)address;
- libgamma_crtc_state_t* crtc = crtc_voidp;
- void* output_voidp = (void*)(size_t)ramps;
- libgamma_gamma_ramps8_t* output = output_voidp;
- int r = libgamma_crtc_get_gamma_ramps8(crtc, output);
- return r == LIBGAMMA_ERRNO_SET ? errno : r;
- (void) env;
- (void) class;
-}
-
-
-/**
- * Set the gamma ramps for a CRTC, 8-bit gamma-depth version.
- *
- * @param address The CRTC state.
- * @param ramps The gamma ramps to apply.
- * @return Zero on success, an error code on failure.
- */
-jint Java_libgamma_CRTC_libgamma_1crtc_1set_1gamma_1ramps8(J, jlong address, jlong ramps)
-{
- void* crtc_voidp = (void*)(size_t)address;
- libgamma_crtc_state_t* crtc = crtc_voidp;
- void* values_voidp = (void*)(size_t)ramps;
- libgamma_gamma_ramps8_t* values = values_voidp;
- int r = libgamma_crtc_set_gamma_ramps8(crtc, *values);
- return r == LIBGAMMA_ERRNO_SET ? errno : r;
- (void) env;
- (void) class;
-}
-
-
-
-/**
- * Get the current gamma ramps for a CRTC, 16-bit gamma-depth version.
- *
- * @param address The CRTC state.
- * @param ramps The gamma ramps to fill with the current values
- * @return Zero on success, an error code on failure.
- */
-jint Java_libgamma_CRTC_libgamma_1crtc_1get_1gamma_1ramps16(J, jlong address, jlong ramps)
-{
- void* crtc_voidp = (void*)(size_t)address;
- libgamma_crtc_state_t* crtc = crtc_voidp;
- void* output_voidp = (void*)(size_t)ramps;
- libgamma_gamma_ramps16_t* output = output_voidp;
- int r = libgamma_crtc_get_gamma_ramps16(crtc, output);
- return r == LIBGAMMA_ERRNO_SET ? errno : r;
- (void) env;
- (void) class;
-}
-
-
-/**
- * Set the gamma ramps for a CRTC, 16-bit gamma-depth version.
- *
- * @param address The CRTC state.
- * @param ramps The gamma ramps to apply.
- * @return Zero on success, an error code on failure.
- */
-jint Java_libgamma_CRTC_libgamma_1crtc_1set_1gamma_1ramps16(J, jlong address, jlong ramps)
-{
- void* crtc_voidp = (void*)(size_t)address;
- libgamma_crtc_state_t* crtc = crtc_voidp;
- void* values_voidp = (void*)(size_t)ramps;
- libgamma_gamma_ramps16_t* values = values_voidp;
- int r = libgamma_crtc_set_gamma_ramps16(crtc, *values);
- return r == LIBGAMMA_ERRNO_SET ? errno : r;
- (void) env;
- (void) class;
-}
-
-
-
-/**
- * Get the current gamma ramps for a CRTC, 32-bit gamma-depth version.
- *
- * @param address The CRTC state.
- * @param ramps The gamma ramps to fill with the current values.
- * @return Zero on success, an error code on failure.
- */
-jint Java_libgamma_CRTC_libgamma_1crtc_1get_1gamma_1ramps32(J, jlong address, jlong ramps)
-{
- void* crtc_voidp = (void*)(size_t)address;
- libgamma_crtc_state_t* crtc = crtc_voidp;
- void* output_voidp = (void*)(size_t)ramps;
- libgamma_gamma_ramps32_t* output = output_voidp;
- int r = libgamma_crtc_get_gamma_ramps32(crtc, output);
- return r == LIBGAMMA_ERRNO_SET ? errno : r;
- (void) env;
- (void) class;
-}
-
-
-/**
- * Set the gamma ramps for a CRTC, 32-bit gamma-depth version.
- *
- * @param address The CRTC state.
- * @param ramps The gamma ramps to apply.
- * @return Zero on success, an error code on failure.
- */
-jint Java_libgamma_CRTC_libgamma_1crtc_1set_1gamma_1ramps32(J, jlong address, jlong ramps)
-{
- void* crtc_voidp = (void*)(size_t)address;
- libgamma_crtc_state_t* crtc = crtc_voidp;
- void* values_voidp = (void*)(size_t)ramps;
- libgamma_gamma_ramps32_t* values = values_voidp;
- int r = libgamma_crtc_set_gamma_ramps32(crtc, *values);
- return r == LIBGAMMA_ERRNO_SET ? errno : r;
- (void) env;
- (void) class;
-}
-
-
-
-/**
- * Get the current gamma ramps for a CRTC, 64-bit gamma-depth version.
- *
- * @param address The CRTC state.
- * @param ramps The gamma ramps to fill with the current values.
- * @return Zero on success, an error code on failure.
- */
-jint Java_libgamma_CRTC_libgamma_1crtc_1get_1gamma_1ramps64(J, jlong address, jlong ramps)
-{
- void* crtc_voidp = (void*)(size_t)address;
- libgamma_crtc_state_t* crtc = crtc_voidp;
- void* output_voidp = (void*)(size_t)ramps;
- libgamma_gamma_ramps64_t* output = output_voidp;
- int r = libgamma_crtc_get_gamma_ramps64(crtc, output);
- return r == LIBGAMMA_ERRNO_SET ? errno : r;
- (void) env;
- (void) class;
-}
-
-
-/**
- * Set the gamma ramps for a CRTC, 64-bit gamma-depth version.
- *
- * @param address The CRTC state.
- * @param ramps The gamma ramps to apply.
- * @return Zero on success, an error code on failure.
- */
-jint Java_libgamma_CRTC_libgamma_1crtc_1set_1gamma_1ramps64(J, jlong address, jlong ramps)
-{
- void* crtc_voidp = (void*)(size_t)address;
- libgamma_crtc_state_t* crtc = crtc_voidp;
- void* values_voidp = (void*)(size_t)ramps;
- libgamma_gamma_ramps64_t* values = values_voidp;
- int r = libgamma_crtc_set_gamma_ramps64(crtc, *values);
- return r == LIBGAMMA_ERRNO_SET ? errno : r;
- (void) env;
- (void) class;
-}
-
-
-
-/**
- * Set the gamma ramps for a CRTC, single precision floating point version.
- *
- * @param address The CRTC state.
- * @param ramps The gamma ramps to apply.
- * @return Zero on success, an error code on failure.
- */
-jint Java_libgamma_CRTC_libgamma_1crtc_1set_1gamma_1rampsf(J, jlong address, jlong ramps)
-{
- void* crtc_voidp = (void*)(size_t)address;
- libgamma_crtc_state_t* crtc = crtc_voidp;
- void* output_voidp = (void*)(size_t)ramps;
- libgamma_gamma_rampsf_t* output = output_voidp;
- int r = libgamma_crtc_get_gamma_rampsf(crtc, output);
- return r == LIBGAMMA_ERRNO_SET ? errno : r;
- (void) env;
- (void) class;
-}
-
-
-/**
- * Get the current gamma ramps for a CRTC, single precision floating point version.
- *
- * @param address The CRTC state.
- * @param ramps The gamma ramps to fill with the current values.
- * @return Zero on success, an error code on failure.
- */
-jint Java_libgamma_CRTC_libgamma_1crtc_1get_1gamma_1rampsf(J, jlong address, jlong ramps)
-{
- void* crtc_voidp = (void*)(size_t)address;
- libgamma_crtc_state_t* crtc = crtc_voidp;
- void* values_voidp = (void*)(size_t)ramps;
- libgamma_gamma_rampsf_t* values = values_voidp;
- int r = libgamma_crtc_set_gamma_rampsf(crtc, *values);
- return r == LIBGAMMA_ERRNO_SET ? errno : r;
- (void) env;
- (void) class;
-}
-
-
-
-/**
- * Get the current gamma ramps for a CRTC, double precision floating point version.
- *
- * @param address The CRTC state.
- * @param ramps The gamma ramps to fill with the current values.
- * @return Zero on success, an error code on failure.
- */
-jint Java_libgamma_CRTC_libgamma_1crtc_1get_1gamma_1rampsd(J, jlong address, jlong ramps)
-{
- void* crtc_voidp = (void*)(size_t)address;
- libgamma_crtc_state_t* crtc = crtc_voidp;
- void* output_voidp = (void*)(size_t)ramps;
- libgamma_gamma_rampsd_t* output = output_voidp;
- int r = libgamma_crtc_get_gamma_rampsd(crtc, output);
- return r == LIBGAMMA_ERRNO_SET ? errno : r;
- (void) env;
- (void) class;
-}
-
-
-/**
- * Set the gamma ramps for a CRTC, double precision floating point version.
- *
- * @param address The CRTC state.
- * @param ramps The gamma ramps to apply.
- * @return Zero on success, an error code on failure.
- */
-jint Java_libgamma_CRTC_libgamma_1crtc_1set_1gamma_1rampsd(J, jlong address, jlong ramps)
-{
- void* crtc_voidp = (void*)(size_t)address;
- libgamma_crtc_state_t* crtc = crtc_voidp;
- void* values_voidp = (void*)(size_t)ramps;
- libgamma_gamma_rampsd_t* values = values_voidp;
- int r = libgamma_crtc_set_gamma_rampsd(crtc, *values);
- return r == LIBGAMMA_ERRNO_SET ? errno : r;
- (void) env;
- (void) class;
-}
-
diff --git a/src/libgamma_GammaRamps.c b/src/libgamma_GammaRamps.c
deleted file mode 100644
index aa91a0f..0000000
--- a/src/libgamma_GammaRamps.c
+++ /dev/null
@@ -1,359 +0,0 @@
-/**
- * jlibgamma -- Display server abstraction layer for gamma ramp and Java
- * Copyright (C) 2014 Mattias Andrée (maandree@member.fsf.org)
- *
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-#include "libgamma_GammaRamps.h"
-
-#include <stdlib.h>
-#include <errno.h>
-
-#include <libgamma.h>
-
-
-#define J JNIEnv* env, jclass class
-
-
-
-/**
- * Make a failure-return.
- *
- * @param error_code The error code returned from the failing function or zero to read `errno`.
- * @return The object to return.
- */
-static jlongArray fail(JNIEnv* env, int error_code)
-{
- jlongArray rc = (*env)->NewLongArray(env, 5);
- jlong e, z = 0;
- if ((error_code == LIBGAMMA_ERRNO_SET) || !error_code)
- error_code = errno;
- e = (jlong)error_code;
- (*env)->SetLongArrayRegion(env, rc, 0, 1, &z);
- (*env)->SetLongArrayRegion(env, rc, 1, 1, &z);
- (*env)->SetLongArrayRegion(env, rc, 2, 1, &z);
- (*env)->SetLongArrayRegion(env, rc, 3, 1, &z);
- (*env)->SetLongArrayRegion(env, rc, 4, 1, &e);
- return rc;
-}
-
-
-/**
- * Make a success-return.
- *
- * @param ramps The native object.
- * @param red The red gamma ramp.
- * @param green The green gamma ramp.
- * @param blue The blue gamma ramp.
- * @return The object to return.
- */
-static jlongArray ok(JNIEnv* env, void* ramps, void* red, void* green, void* blue)
-{
- jlong a = (jlong)(size_t)ramps;
- jlong b = (jlong)(size_t)red;
- jlong c = (jlong)(size_t)green;
- jlong d = (jlong)(size_t)blue, z = 0;
- jlongArray rc = (*env)->NewLongArray(env, 5);
- (*env)->SetLongArrayRegion(env, rc, 0, 1, &a);
- (*env)->SetLongArrayRegion(env, rc, 1, 1, &b);
- (*env)->SetLongArrayRegion(env, rc, 2, 1, &c);
- (*env)->SetLongArrayRegion(env, rc, 3, 1, &d);
- (*env)->SetLongArrayRegion(env, rc, 4, 1, &z);
- return rc;
-}
-
-
-
-/**
- * Create and initialise a gamma ramp in the proper way that allows all adjustment
- * methods to read from and write to it without causing segmentation violation.
- *
- * @param red_size The size of the encoding axis of the red gamma ramp.
- * @param green_size The size of the encoding axis of the green gamma ramp.
- * @param blue_size The size of the encoding axis of the blue gamma ramp.
- * @return Element 0: The address of the native object.
- * Element 1: The address of the red gamma ramp.
- * Element 2: The address of the green gamma ramp.
- * Element 3: The address of the blue gamma ramp.
- * Element 4: Zero on success, an error code on error.
- */
-jlongArray Java_libgamma_GammaRamps_libgamma_1gamma_1ramps8_1create(J, jint red_size, jint green_size, jint blue_size)
-{
- libgamma_gamma_ramps8_t* ramps = malloc(sizeof(libgamma_gamma_ramps8_t));
- int r;
- if (ramps == NULL)
- return fail(env, 0);
- ramps->red_size = red_size;
- ramps->green_size = green_size;
- ramps->blue_size = blue_size;
- r = libgamma_gamma_ramps8_initialise(ramps);
- if (r != 0)
- return fail(env, r);
- return ok(env, ramps, ramps->red, ramps->green, ramps->blue);
- (void) class;
-}
-
-
-/**
- * Create and initialise a gamma ramp in the proper way that allows all adjustment
- * methods to read from and write to it without causing segmentation violation.
- *
- * @param red_size The size of the encoding axis of the red gamma ramp.
- * @param green_size The size of the encoding axis of the green gamma ramp.
- * @param blue_size The size of the encoding axis of the blue gamma ramp.
- * @return Element 0: The address of the native object.
- * Element 1: The address of the red gamma ramp.
- * Element 2: The address of the green gamma ramp.
- * Element 3: The address of the blue gamma ramp.
- * Element 4: Zero on success, an error code on error.
- */
-jlongArray Java_libgamma_GammaRamps_libgamma_1gamma_1ramps16_1create(J, jint red_size, jint green_size, jint blue_size)
-{
- libgamma_gamma_ramps16_t* ramps = malloc(sizeof(libgamma_gamma_ramps16_t));
- int r;
- if (ramps == NULL)
- return fail(env, 0);
- ramps->red_size = red_size;
- ramps->green_size = green_size;
- ramps->blue_size = blue_size;
- r = libgamma_gamma_ramps16_initialise(ramps);
- if (r != 0)
- return fail(env, r);
- return ok(env, ramps, ramps->red, ramps->green, ramps->blue);
- (void) class;
-}
-
-
-/**
- * Create and initialise a gamma ramp in the proper way that allows all adjustment
- * methods to read from and write to it without causing segmentation violation.
- *
- * @param red_size The size of the encoding axis of the red gamma ramp.
- * @param green_size The size of the encoding axis of the green gamma ramp.
- * @param blue_size The size of the encoding axis of the blue gamma ramp.
- * @return Element 0: The address of the native object.
- * Element 1: The address of the red gamma ramp.
- * Element 2: The address of the green gamma ramp.
- * Element 3: The address of the blue gamma ramp.
- * Element 4: Zero on success, an error code on error.
- */
-jlongArray Java_libgamma_GammaRamps_libgamma_1gamma_1ramps32_1create(J, jint red_size, jint green_size, jint blue_size)
-{
- libgamma_gamma_ramps32_t* ramps = malloc(sizeof(libgamma_gamma_ramps32_t));
- int r;
- if (ramps == NULL)
- return fail(env, 0);
- ramps->red_size = red_size;
- ramps->green_size = green_size;
- ramps->blue_size = blue_size;
- r = libgamma_gamma_ramps32_initialise(ramps);
- if (r != 0)
- return fail(env, r);
- return ok(env, ramps, ramps->red, ramps->green, ramps->blue);
- (void) class;
-}
-
-
-/**
- * Create and initialise a gamma ramp in the proper way that allows all adjustment
- * methods to read from and write to it without causing segmentation violation.
- *
- * @param red_size The size of the encoding axis of the red gamma ramp.
- * @param green_size The size of the encoding axis of the green gamma ramp.
- * @param blue_size The size of the encoding axis of the blue gamma ramp.
- * @return Element 0: The address of the native object.
- * Element 1: The address of the red gamma ramp.
- * Element 2: The address of the green gamma ramp.
- * Element 3: The address of the blue gamma ramp.
- * Element 4: Zero on success, an error code on error.
- */
-jlongArray Java_libgamma_GammaRamps_libgamma_1gamma_1ramps64_1create(J, jint red_size, jint green_size, jint blue_size)
-{
- libgamma_gamma_ramps64_t* ramps = malloc(sizeof(libgamma_gamma_ramps64_t));
- int r;
- if (ramps == NULL)
- return fail(env, 0);
- ramps->red_size = red_size;
- ramps->green_size = green_size;
- ramps->blue_size = blue_size;
- r = libgamma_gamma_ramps64_initialise(ramps);
- if (r != 0)
- return fail(env, r);
- return ok(env, ramps, ramps->red, ramps->green, ramps->blue);
- (void) class;
-}
-
-
-/**
- * Create and initialise a gamma ramp in the proper way that allows all adjustment
- * methods to read from and write to it without causing segmentation violation.
- *
- * @param red_size The size of the encoding axis of the red gamma ramp.
- * @param green_size The size of the encoding axis of the green gamma ramp.
- * @param blue_size The size of the encoding axis of the blue gamma ramp.
- * @return Element 0: The address of the native object.
- * Element 1: The address of the red gamma ramp.
- * Element 2: The address of the green gamma ramp.
- * Element 3: The address of the blue gamma ramp.
- * Element 4: Zero on success, an error code on error.
- */
-jlongArray Java_libgamma_GammaRamps_libgamma_1gamma_1rampsf_1create(J, jint red_size, jint green_size, jint blue_size)
-{
- libgamma_gamma_rampsf_t* ramps = malloc(sizeof(libgamma_gamma_rampsf_t));
- int r;
- if (ramps == NULL)
- return fail(env, 0);
- ramps->red_size = red_size;
- ramps->green_size = green_size;
- ramps->blue_size = blue_size;
- r = libgamma_gamma_rampsf_initialise(ramps);
- if (r != 0)
- return fail(env, r);
- return ok(env, ramps, ramps->red, ramps->green, ramps->blue);
- (void) class;
-}
-
-
-/**
- * Create and initialise a gamma ramp in the proper way that allows all adjustment
- * methods to read from and write to it without causing segmentation violation.
- *
- * @param red_size The size of the encoding axis of the red gamma ramp.
- * @param green_size The size of the encoding axis of the green gamma ramp.
- * @param blue_size The size of the encoding axis of the blue gamma ramp.
- * @return Element 0: The address of the native object.
- * Element 1: The address of the red gamma ramp.
- * Element 2: The address of the green gamma ramp.
- * Element 3: The address of the blue gamma ramp.
- * Element 4: Zero on success, an error code on error.
- */
-jlongArray Java_libgamma_GammaRamps_libgamma_1gamma_1rampsd_1create(J, jint red_size, jint green_size, jint blue_size)
-{
- libgamma_gamma_rampsd_t* ramps = malloc(sizeof(libgamma_gamma_rampsd_t));
- int r;
- if (ramps == NULL)
- return fail(env, 0);
- ramps->red_size = red_size;
- ramps->green_size = green_size;
- ramps->blue_size = blue_size;
- r = libgamma_gamma_rampsd_initialise(ramps);
- if (r != 0)
- return fail(env, r);
- return ok(env, ramps, ramps->red, ramps->green, ramps->blue);
- (void) class;
-}
-
-
-
-/**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by {@link #libgamma_gamma_ramps8_create} or
- * otherwise initialised in the proper manner, as well as release
- * the pointer to the structure.
- *
- * @param address The gamma ramps.
- */
-void Java_libgamma_GammaRamps_libgamma_1gamma_1ramps8_1free(J, jlong address)
-{
- void* this = (void*)(size_t)address;
- libgamma_gamma_ramps8_free(this);
- (void) env;
- (void) class;
-}
-
-
-/**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by {@link #libgamma_gamma_ramps16_create} or
- * otherwise initialised in the proper manner, as well as release
- * the pointer to the structure.
- *
- * @param address The gamma ramps.
- */
-void Java_libgamma_GammaRamps_libgamma_1gamma_1ramps16_1free(J, jlong address)
-{
- void* this = (void*)(size_t)address;
- libgamma_gamma_ramps16_free(this);
- (void) env;
- (void) class;
-}
-
-
-/**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by {@link #libgamma_gamma_ramps32_create} or
- * otherwise initialised in the proper manner, as well as release
- * the pointer to the structure.
- *
- * @param address The gamma ramps.
- */
-void Java_libgamma_GammaRamps_libgamma_1gamma_1ramps32_1free(J, jlong address)
-{
- void* this = (void*)(size_t)address;
- libgamma_gamma_ramps32_free(this);
- (void) env;
- (void) class;
-}
-
-
-/**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by {@link #libgamma_gamma_ramps64_create} or
- * otherwise initialised in the proper manner, as well as release
- * the pointer to the structure.
- *
- * @param address The gamma ramps.
- */
-void Java_libgamma_GammaRamps_libgamma_1gamma_1ramps64_1free(J, jlong address)
-{
- void* this = (void*)(size_t)address;
- libgamma_gamma_ramps64_free(this);
- (void) env;
- (void) class;
-}
-
-
-/**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by {@link #libgamma_gamma_rampsf_create} or
- * otherwise initialised in the proper manner, as well as release
- * the pointer to the structure.
- *
- * @param address The gamma ramps.
- */
-void Java_libgamma_GammaRamps_libgamma_1gamma_1rampsf_1free(J, jlong address)
-{
- void* this = (void*)(size_t)address;
- libgamma_gamma_rampsf_free(this);
- (void) env;
- (void) class;
-}
-
-
-/**
- * Release resources that are held by a gamma ramp strcuture that
- * has been allocated by {@link #libgamma_gamma_rampsd_create} or
- * otherwise initialised in the proper manner, as well as release
- * the pointer to the structure.
- *
- * @param address The gamma ramps.
- */
-void Java_libgamma_GammaRamps_libgamma_1gamma_1rampsd_1free(J, jlong address)
-{
- void* this = (void*)(size_t)address;
- libgamma_gamma_rampsd_free(this);
- (void) env;
- (void) class;
-}
-
diff --git a/src/libgamma_LibgammaException.c b/src/libgamma_LibgammaException.c
deleted file mode 100644
index 5621a58..0000000
--- a/src/libgamma_LibgammaException.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/**
- * jlibgamma -- Display server abstraction layer for gamma ramp and Java
- * Copyright (C) 2014 Mattias Andrée (maandree@member.fsf.org)
- *
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-#include "libgamma_LibgammaException.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-#include <libgamma.h>
-
-
-#define J JNIEnv* env, jclass class
-
-
-
-/**
- * Returns the name of the definition associated with
- * a <tt>libgamma</tt> error code.
- *
- * @param value The error code.
- * @return The name of the definition associated with the error code,
- * {@code null} if the error code does not exist.
- */
-jstring Java_libgamma_LibgammaException_name_1of_1error(J, jint value)
-{
- /* It is really unlikely that `malloc` returns `NULL` here
- * and error handing makes this unnecessarily comples,
- * therefore we will simply skip it. */
-
- const char* do_not_free_this = libgamma_name_of_error(value);
- char* this_will_be_freed;
- size_t n;
- if (do_not_free_this == NULL)
- return NULL;
-
- n = strlen(do_not_free_this) + 1;
- this_will_be_freed = malloc(n * sizeof(char));
- memcpy(this_will_be_freed, do_not_free_this, n * sizeof(char));
-
- return (*env)->NewStringUTF(env, this_will_be_freed);
- (void) class;
-}
-
-
-/**
- * Return the value of a <tt>libgamma</tt> error definition
- * refered to by name.
- *
- * @param name The name of the definition associated with the error code.
- * @return The error code, zero if the name is {@code null}
- * or does not refer to a <tt>libgamma</tt> error.
- */
-jint Java_libgamma_LibgammaException_value_1of_1error(J, jstring name)
-{
- const char* name_chars;
- int rc;
- if (name == NULL)
- return 0;
- name_chars = (*env)->GetStringUTFChars(env, name, NULL);
- rc = libgamma_value_of_error(name_chars);
- (*env)->ReleaseStringUTFChars(env, name, name_chars);
- return rc;
- (void) class;
-}
-
-
-/**
- * Acquire the value that should go to {@link #group_gid}.
- *
- * @return The value that should go to {@link #group_gid}.
- */
-jint Java_libgamma_LibgammaException_libgamma_1group_1gid(J)
-{
- return libgamma_group_gid;
- (void) env;
- (void) class;
-}
-
-
-/**
- * Acquire the value that should go to {@link #group_name}.
- *
- * @return The value that should go to {@link #group_name}.
- */
-jstring Java_libgamma_LibgammaException_libgamma_1group_1name(J)
-{
- /* It is really unlikely that `malloc` returns `NULL` here
- * and error handing makes this unnecessarily comples,
- * therefore we will simply skip it. */
-
- const char* do_not_free_this = libgamma_group_name;
- char* this_will_be_freed;
- size_t n;
- if (do_not_free_this == NULL)
- return NULL;
-
- n = strlen(do_not_free_this) + 1;
- this_will_be_freed = malloc(n * sizeof(char));
- memcpy(this_will_be_freed, do_not_free_this, n * sizeof(char));
-
- return (*env)->NewStringUTF(env, this_will_be_freed);
- (void) class;
-}
-
-
-/**
- * Get a textual description of a system error code.
- *
- * @param error_code The error code.
- * @return A textual description of the error code.
- */
-jstring Java_libgamma_LibgammaException_strerror(J, jint error_code)
-{
- /* It is really unlikely that `malloc` returns `NULL` here
- * and error handing makes this unnecessarily comples,
- * therefore we will simply skip it. */
-
- const char* do_not_free_this = strerror(error_code);
- char* this_will_be_freed;
- size_t n;
- if (do_not_free_this == NULL)
- return NULL;
-
- n = strlen(do_not_free_this) + 1;
- this_will_be_freed = malloc(n * sizeof(char));
- memcpy(this_will_be_freed, do_not_free_this, n * sizeof(char));
-
- return (*env)->NewStringUTF(env, this_will_be_freed);
- (void) class;
-}
-
diff --git a/src/libgamma_Partition.c b/src/libgamma_Partition.c
deleted file mode 100644
index 65bf2e0..0000000
--- a/src/libgamma_Partition.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/**
- * jlibgamma -- Display server abstraction layer for gamma ramp and Java
- * Copyright (C) 2014 Mattias Andrée (maandree@member.fsf.org)
- *
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-#include "libgamma_Partition.h"
-
-#include <errno.h>
-#include <stdlib.h>
-
-#include <libgamma.h>
-
-
-#define J JNIEnv* env, jclass class
-
-
-/**
- * Make a failure-return.
- *
- * @param error_code The error code returned from the failing function or zero to read `errno`.
- * @return The object to return.
- */
-static jlongArray fail(JNIEnv* env, int error_code)
-{
- jlongArray rc = (*env)->NewLongArray(env, 3);
- jlong e, z = 0;
- if ((error_code == LIBGAMMA_ERRNO_SET) || !error_code)
- error_code = errno;
- e = (jlong)error_code;
- (*env)->SetLongArrayRegion(env, rc, 0, 1, &z);
- (*env)->SetLongArrayRegion(env, rc, 1, 1, &z);
- (*env)->SetLongArrayRegion(env, rc, 2, 1, &e);
- return rc;
-}
-
-
-/**
- * Make a success-return.
- *
- * @param state The native object.
- * @param count The subelement count.
- * @return The object to return.
- */
-static jlongArray ok(JNIEnv* env, void* state, size_t count)
-{
- jlong a = (jlong)(size_t)state;
- jlong b = (jlong)count, z = 0;
- jlongArray rc = (*env)->NewLongArray(env, 3);
- (*env)->SetLongArrayRegion(env, rc, 0, 1, &a);
- (*env)->SetLongArrayRegion(env, rc, 1, 1, &b);
- (*env)->SetLongArrayRegion(env, rc, 2, 1, &z);
- return rc;
-}
-
-
-/**
- * Create a partition state.
- *
- * @param site The site state for the site that the partition belongs to.
- * @param partition The index of the partition within the site.
- * @return Element 0: The value for {@link #address}.
- * Element 1: The value for {@link #crtcs_available}
- * Element 2: Error code, zero on success.
- */
-jlongArray Java_libgamma_Partition_libgamma_1partition_1create(J, jlong site, jint partition)
-{
- libgamma_partition_state_t* state = malloc(sizeof(libgamma_partition_state_t));
- void* super = (void*)(size_t)site;
- int r;
- if (state == NULL)
- return fail(env, 0);
- r = libgamma_partition_initialise(state, super, partition);
- if (r != 0)
- return fail(env, r);
- return ok(env, state, state->crtcs_available);
- (void) class;
-}
-
-
-/**
- * Release all resources held by a partition state
- * and free the partition state pointer.
- *
- * @param address The partition state.
- */
-void Java_libgamma_Partition_libgamma_1partition_1free(J, jlong address)
-{
- void* this = (void*)(size_t)address;
- libgamma_partition_free(this);
- (void) env;
- (void) class;
-}
-
-
-/**
- * Restore the gamma ramps all CRTC:s within a partition to the system settings.
- *
- * @param address The partition state.
- * @return Zero on success, and error code on failure.
- */
-jint Java_libgamma_Partition_libgamma_1partition_1restore(J, jlong address)
-{
- void* this = (void*)(size_t)address;
- int r = libgamma_partition_restore(this);
- if (r != 0)
- return r == LIBGAMMA_ERRNO_SET ? errno : r;
- return 0;
- (void) env;
- (void) class;
-}
-
diff --git a/src/libgamma_Ramp.c b/src/libgamma_Ramp.c
deleted file mode 100644
index cdbbc03..0000000
--- a/src/libgamma_Ramp.c
+++ /dev/null
@@ -1,230 +0,0 @@
-/**
- * jlibgamma -- Display server abstraction layer for gamma ramp and Java
- * Copyright (C) 2014 Mattias Andrée (maandree@member.fsf.org)
- *
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-#include "libgamma_Ramp.h"
-
-#include <libgamma.h>
-
-
-#define J JNIEnv* env, jclass class
-
-
-
-/**
- * Read the value of a stop in an 8-bit ramp.
- *
- * @param address The address of the ramp.
- * @param stop The index of the stop.
- * @return The value of the stop.
- */
-jshort Java_libgamma_Ramp_libgamma_1gamma_1ramps8_1get(J, jlong address, jint stop)
-{
- void* this_voidp = (void*)(size_t)address;
- uint8_t* this = this_voidp;
- return (jshort)(this[stop]);
- (void) env;
- (void) class;
-}
-
-
-/**
- * Read the value of a stop in a 16-bit ramp.
- *
- * @param address The address of the ramp.
- * @param stop The index of the stop.
- * @return The value of the stop.
- */
-jint Java_libgamma_Ramp_libgamma_1gamma_1ramps16_1get(J, jlong address, jint stop)
-{
- void* this_voidp = (void*)(size_t)address;
- uint16_t* this = this_voidp;
- return (jint)(this[stop]);
- (void) env;
- (void) class;
-}
-
-
-/**
- * Read the value of a stop in a 32-bit ramp.
- *
- * @param address The address of the ramp.
- * @param stop The index of the stop.
- * @return The value of the stop.
- */
-jlong Java_libgamma_Ramp_libgamma_1gamma_1ramps32_1get(J, jlong address, jint stop)
-{
- void* this_voidp = (void*)(size_t)address;
- uint32_t* this = this_voidp;
- return (jlong)(this[stop]);
- (void) env;
- (void) class;
-}
-
-
-/**
- * Read the value of a stop in a 64-bit ramp.
- *
- * @param address The address of the ramp.
- * @param stop The index of the stop.
- * @return The value of the stop.
- */
-jlong Java_libgamma_Ramp_libgamma_1gamma_1ramps64_1get(J, jlong address, jint stop)
-{
- void* this_voidp = (void*)(size_t)address;
- uint64_t* this = this_voidp;
- return (jlong)(this[stop]);
- (void) env;
- (void) class;
-}
-
-
-/**
- * Read the value of a stop in a single precision floating point ramp.
- *
- * @param address The address of the ramp.
- * @param stop The index of the stop.
- * @return The value of the stop.
- */
-jfloat Java_libgamma_Ramp_libgamma_1gamma_1rampsf_1get(J, jlong address, jint stop)
-{
- void* this_voidp = (void*)(size_t)address;
- float* this = this_voidp;
- return (jfloat)(this[stop]);
- (void) env;
- (void) class;
-}
-
-
-/**
- * Read the value of a stop in a double precision floating point ramp.
- *
- * @param address The address of the ramp.
- * @param stop The index of the stop.
- * @return The value of the stop.
- */
-jdouble Java_libgamma_Ramp_libgamma_1gamma_1rampsd_1get(J, jlong address, jint stop)
-{
- void* this_voidp = (void*)(size_t)address;
- double* this = this_voidp;
- return (jdouble)(this[stop]);
- (void) env;
- (void) class;
-}
-
-
-
-/**
- * Set the value of a stop in an 8-bit ramp.
- *
- * @param address The address of the ramp.
- * @param stop The index of the stop.
- * @param value The value of the stop.
- */
-void Java_libgamma_Ramp_libgamma_1gamma_1ramps8_1set(J, jlong address, jint stop, jshort value)
-{
- void* this_voidp = (void*)(size_t)address;
- uint8_t* this = this_voidp;
- this[stop] = (uint8_t)value;
- (void) env;
- (void) class;
-}
-
-
-/**
- * Set the value of a stop in a 16-bit ramp.
- *
- * @param address The address of the ramp.
- * @param stop The index of the stop.
- * @param value The value of the stop.
- */
-void Java_libgamma_Ramp_libgamma_1gamma_1ramps16_1set(J, jlong address, jint stop, jint value)
-{
- void* this_voidp = (void*)(size_t)address;
- uint16_t* this = this_voidp;
- this[stop] = (uint16_t)value;
- (void) env;
- (void) class;
-}
-
-
-/**
- * Set the value of a stop in a 32-bit ramp.
- *
- * @param address The address of the ramp.
- * @param stop The index of the stop.
- * @param value The value of the stop.
- */
-void Java_libgamma_Ramp_libgamma_1gamma_1ramps32_1set(J, jlong address, jint stop, jlong value)
-{
- void* this_voidp = (void*)(size_t)address;
- uint32_t* this = this_voidp;
- this[stop] = (uint32_t)value;
- (void) env;
- (void) class;
-}
-
-
-/**
- * Set the value of a stop in a 64-bit ramp.
- *
- * @param address The address of the ramp.
- * @param stop The index of the stop.
- * @param value The value of the stop.
- */
-void Java_libgamma_Ramp_libgamma_1gamma_1ramps64_1set(J, jlong address, jint stop, jlong value)
-{
- void* this_voidp = (void*)(size_t)address;
- uint64_t* this = this_voidp;
- this[stop] = (uint64_t)value;
- (void) env;
- (void) class;
-}
-
-
-/**
- * Set the value of a stop in a single precision floating point ramp.
- *
- * @param address The address of the ramp.
- * @param stop The index of the stop.
- * @param value The value of the stop.
- */
-void Java_libgamma_Ramp_libgamma_1gamma_1rampsf_1set(J, jlong address, jint stop, jfloat value)
-{
- void* this_voidp = (void*)(size_t)address;
- float* this = this_voidp;
- this[stop] = (float)value;
- (void) env;
- (void) class;
-}
-
-
-/**
- * Set the value of a stop in a double precision floating point ramp.
- *
- * @param address The address of the ramp.
- * @param stop The index of the stop.
- * @param value The value of the stop.
- */
-void Java_libgamma_Ramp_libgamma_1gamma_1rampsd_1set(J, jlong address, jint stop, jdouble value)
-{
- void* this_voidp = (void*)(size_t)address;
- double* this = this_voidp;
- this[stop] = (double)value;
- (void) env;
- (void) class;
-}
-
diff --git a/src/libgamma_Site.c b/src/libgamma_Site.c
deleted file mode 100644
index 2b227d9..0000000
--- a/src/libgamma_Site.c
+++ /dev/null
@@ -1,143 +0,0 @@
-/**
- * jlibgamma -- Display server abstraction layer for gamma ramp and Java
- * Copyright (C) 2014 Mattias Andrée (maandree@member.fsf.org)
- *
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-#include "libgamma_Site.h"
-
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-
-#include <libgamma.h>
-
-
-#define J JNIEnv* env, jclass class
-
-
-
-/**
- * Make a failure-return.
- *
- * @param error_code The error code returned from the failing function or zero to read `errno`.
- * @return The object to return.
- */
-static jlongArray fail(JNIEnv* env, int error_code)
-{
- jlongArray rc = (*env)->NewLongArray(env, 3);
- jlong e, z = 0;
- if ((error_code == LIBGAMMA_ERRNO_SET) || !error_code)
- error_code = errno;
- e = (jlong)error_code;
- (*env)->SetLongArrayRegion(env, rc, 0, 1, &z);
- (*env)->SetLongArrayRegion(env, rc, 1, 1, &z);
- (*env)->SetLongArrayRegion(env, rc, 2, 1, &e);
- return rc;
-}
-
-
-/**
- * Make a success-return.
- *
- * @param state The native object.
- * @param count The subelement count.
- * @return The object to return.
- */
-static jlongArray ok(JNIEnv* env, void* state, size_t count)
-{
- jlong a = (jlong)(size_t)state;
- jlong b = (jlong)count, z = 0;
- jlongArray rc = (*env)->NewLongArray(env, 3);
- (*env)->SetLongArrayRegion(env, rc, 0, 1, &a);
- (*env)->SetLongArrayRegion(env, rc, 1, 1, &b);
- (*env)->SetLongArrayRegion(env, rc, 2, 1, &z);
- return rc;
-}
-
-
-/**
- * Create a site state.
- *
- * @param method The adjustment method (display server and protocol.)
- * @param site The site identifier.
- * @return Element 0: The value for {@link #address}.
- * Element 1: The value for {@link #partitions_available}
- * Element 2: Error code, zero on success.
- */
-jlongArray Java_libgamma_Site_libgamma_1site_1create(J, jint method, jstring site)
-{
- libgamma_site_state_t* state = malloc(sizeof(libgamma_site_state_t));
- const char* site_chars;
- char* site_;
- int r;
- if (site != NULL)
- {
- int saved_errno = 0;
- size_t n;
- site_chars = (*env)->GetStringUTFChars(env, site, NULL);
- n = strlen(site_chars) + 1;
- site_ = malloc(n * sizeof(char));
- if (site_ == NULL)
- saved_errno = errno;
- else
- memcpy(site_, site_chars, n * sizeof(char));
- (*env)->ReleaseStringUTFChars(env, site, site_chars);
- if (saved_errno)
- return fail(env, errno);
- }
- else
- site_ = NULL;
- if (state == NULL)
- return fail(env, 0);
- r = libgamma_site_initialise(state, method, site_);
- if (r != 0)
- return fail(env, r);
- return ok(env, state, state->partitions_available);
- (void) class;
-}
-
-
-/**
- * Release all resources held by a site state
- * and free the site state pointer.
- *
- * @param address The site state.
- */
-void Java_libgamma_Site_libgamma_1site_1free(J, jlong address)
-{
- void* this = (void*)(size_t)address;
- libgamma_site_free(this);
- (void) env;
- (void) class;
-}
-
-
-/**
- * Restore the gamma ramps all CRTC:s within a site to the system settings.
- *
- * @param address The site state.
- * @return Zero on success, and error code on failure.
- */
-jint Java_libgamma_Site_libgamma_1site_1restore(J, jlong address)
-{
- void* this = (void*)(size_t)address;
- int r = libgamma_site_restore(this);
- if (r != 0)
- return r == LIBGAMMA_ERRNO_SET ? errno : r;
- return 0;
- (void) env;
- (void) class;
-}
-