mirror of
git://nv-tegra.nvidia.com/tegra/gfx-src/nv-xconfig.git
synced 2025-12-22 09:22:53 +03:00
913b088cb559f31e09a1baf89d85d75cb43079b4 - nvidia-xconfig-35.2.1/nvidia-xconfig.h 1e39095238886dfc6a69f7ec750e10c05a93e7d1 - nvidia-xconfig-35.2.1/nvidia-xconfig.1.m4 f14e9577e537037d4778d490ef70f13b0e94a70a - nvidia-xconfig-35.2.1/option_table.h 4cc77b90af91e615a64ae04893fdffa7939db84c - nvidia-xconfig-35.2.1/COPYING 41bcac41393c9a465c30c07cf1ab386647a16687 - nvidia-xconfig-35.2.1/util.c 647e7896275a1113ec99352d573823a05001f57e - nvidia-xconfig-35.2.1/lscf.c 22a5c807291792a264b5acca7ff6d199468890b8 - nvidia-xconfig-35.2.1/Makefile bfa37f78ba458f14a1865bbf3f67eb84987a7e1c - nvidia-xconfig-35.2.1/extract_edids.c c946eefad99cec9366d8abbd4e45c5d138d3b7be - nvidia-xconfig-35.2.1/make_usable.c 46f2ea329459b0b16cb36cc14cec0de737d0963e - nvidia-xconfig-35.2.1/options.c b3d0f9f27c4d9cb7940d04e1dd387d357a16024c - nvidia-xconfig-35.2.1/nvidia-xconfig.c 6f6f68f976250f2646450e571f9ab2d7eee1ac80 - nvidia-xconfig-35.2.1/nvidia-cfg.h 9b0c02164398be2795fea7cb13c9e1b062d24bfb - nvidia-xconfig-35.2.1/query_gpu_info.c 10edc2c301fd331439b38d001c0df41669c238b2 - nvidia-xconfig-35.2.1/multiple_screens.c d37da5a118e0418b267a48d05fd144611316b42c - nvidia-xconfig-35.2.1/gen-manpage-opts.c a5ad539267b73169480e7898b284823639c4db3a - nvidia-xconfig-35.2.1/tree.c 5d55b94375c2055cfa1578e4c7f34c90e63a33f7 - nvidia-xconfig-35.2.1/common-utils/gen-manpage-opts-helper.c 8259a24058c714629f9819cc8c830ea9b202bb27 - nvidia-xconfig-35.2.1/common-utils/gen-manpage-opts-helper.h 8a346196b052cfb1e06dd83d2ad1fe71e928d2b3 - nvidia-xconfig-35.2.1/common-utils/common-utils.c aac5cbf0e68e1da4e646c316a7c0e620304ee16b - nvidia-xconfig-35.2.1/common-utils/msg.c e572cac43202f6c2af1c80b9e3901215126093ed - nvidia-xconfig-35.2.1/common-utils/nvgetopt.h 384e36102dcd08ed4c5de05b5e3b8a7cdb2e257d - nvidia-xconfig-35.2.1/common-utils/nvgetopt.c 1654638c567bc7f2bd70b54d807b498ab14c1061 - nvidia-xconfig-35.2.1/common-utils/nvpci-utils.h 524990f5497f9bbeb3d148b5e7dc8d2267c3163d - nvidia-xconfig-35.2.1/common-utils/nvpci-utils.c abb5c1b445d9353f2d2840bda848cd16109710a4 - nvidia-xconfig-35.2.1/common-utils/msg.h dc2678d8a9d794a4b2b2718fce57ec087f21f54b - nvidia-xconfig-35.2.1/common-utils/common-utils.h 4d9b03ea3badceb6bdfdf6589e6731140ec44079 - nvidia-xconfig-35.2.1/XF86Config-parser/Generate.c 0a274c4bc54b6ae0f6d009e443bda0cb033d66b5 - nvidia-xconfig-35.2.1/XF86Config-parser/Pointer.c 6c210ad0eaee1db3fec48ff01746cb054b4f9aaa - nvidia-xconfig-35.2.1/XF86Config-parser/Video.c 3f2238c88d737bd329a9bca1ac4b0bcf77bb9ac2 - nvidia-xconfig-35.2.1/XF86Config-parser/xf86tokens.h 33211ca0a10f50e2c87b9e8feef6c1ab381b57a1 - nvidia-xconfig-35.2.1/XF86Config-parser/DRI.c 2022a4a3c2a1b23a67ae74f50a3849f5f3a45e4b - nvidia-xconfig-35.2.1/XF86Config-parser/Keyboard.c 45ceb0129668346ae3e52d81bb6e2f97efadf9d0 - nvidia-xconfig-35.2.1/XF86Config-parser/Input.c e67d630ef396ab7d34524c333f3a77fc42ba8fc6 - nvidia-xconfig-35.2.1/XF86Config-parser/configProcs.h 953b945f3b117d6fb44f1f738af17b6380a9ec72 - nvidia-xconfig-35.2.1/XF86Config-parser/Monitor.c c7b8d8ca0f7c9dcc2cdca4f8e77d1122c71892ef - nvidia-xconfig-35.2.1/XF86Config-parser/Read.c de1c758e29f217e1a99e4c076d54ac84bce98b18 - nvidia-xconfig-35.2.1/XF86Config-parser/Screen.c 7344be997921dec57959691e986763ee686888d5 - nvidia-xconfig-35.2.1/XF86Config-parser/Device.c 4407207cf890539dc604cff5b834c994b307729a - nvidia-xconfig-35.2.1/XF86Config-parser/Write.c 18711ff932af2202869a30f3b32d6d7fe7811c84 - nvidia-xconfig-35.2.1/XF86Config-parser/Layout.c ac878b26ded86a3c502a6a81fc4c4a96162afefb - nvidia-xconfig-35.2.1/XF86Config-parser/Merge.c 83b0a8efd6a508db54995688ab353591bdb242a2 - nvidia-xconfig-35.2.1/XF86Config-parser/Flags.c 04efe162cf6d97882f2bb87f3712d9a65c2320f3 - nvidia-xconfig-35.2.1/XF86Config-parser/Scan.c f3d611bdbddfa64675a0810ef81dada57e224bcd - nvidia-xconfig-35.2.1/XF86Config-parser/Extensions.c a9bc06f33bf525c2b08be2dc3cd64a59c4c7946d - nvidia-xconfig-35.2.1/XF86Config-parser/Configint.h ec19d673a6a7d1d8f855f2d32d3e8f63046c3625 - nvidia-xconfig-35.2.1/XF86Config-parser/Files.c cda3a4ab05bf48ba28af35b5c4c632e968afc7fa - nvidia-xconfig-35.2.1/XF86Config-parser/Util.c c66a0a141e25e31b568fb9df41f17d7fb9e6d3b9 - nvidia-xconfig-35.2.1/XF86Config-parser/xf86Parser.h 9cbc29da282aa957f28b7fc83caf1e3b19ee2a52 - nvidia-xconfig-35.2.1/XF86Config-parser/Vendor.c 5ffb2caa5077a2e6ec1c5ece807e71503fb2fbce - nvidia-xconfig-35.2.1/XF86Config-parser/Module.c Change-Id: I95f040ed93f9532cc6977e9284d2be1256f1b734
417 lines
12 KiB
C
417 lines
12 KiB
C
#include <stdio.h>
|
|
#include "nvidia-xconfig.h"
|
|
#if defined(NV_SUNOS)
|
|
|
|
/* Interface to the Solaris Service Management Facility.
|
|
* This facility is responsible for running programs and services
|
|
* and store their configuration information (named properties)
|
|
* The configuration information for the X server is managed by
|
|
* this facility. The functions in this source file use the library
|
|
* libscf (Service Configuration Facility) to access and modify
|
|
* the properties for the X server, more specifically the default depth.
|
|
* On Solaris, changing the default depth in the xorg.conf file is not
|
|
* enough. The session manager overrides the xorg.conf default depth:
|
|
* it passes the option -defdepth to the X server with the value
|
|
* retrieved from the Service Management Facility.
|
|
*
|
|
* For more information refer to the manpages of fmf(5), libsfc(3LIB),
|
|
* and to the source code of svccfg(1M) available on cvs.opensolaris.org.
|
|
*/
|
|
|
|
|
|
#include <libscf.h>
|
|
#include "msg.h"
|
|
|
|
static int lscf_init_handle(scf_handle_t **scf_handle,
|
|
scf_scope_t **scf_scope);
|
|
static int lscf_select(scf_handle_t *scf_handle,
|
|
scf_scope_t *scf_scope,
|
|
const char *selection,
|
|
scf_service_t **current_svc);
|
|
static int lscf_setprop_int(scf_handle_t *scf_handle,
|
|
scf_scope_t *scf_scope,
|
|
scf_service_t *current_svc,
|
|
const char *group,
|
|
const char *name, int value);
|
|
static int lscf_getprop_int(scf_handle_t *scf_handle,
|
|
scf_scope_t *scf_scope,
|
|
scf_service_t *current_svc,
|
|
const char *group,
|
|
const char *name, int *value);
|
|
|
|
/* UPDATE THE DEFAULT DEPTH PROPERTY IN SMF WITH THE LIBSCF FUNCTIONS */
|
|
int update_scf_depth(int depth)
|
|
{
|
|
static scf_handle_t *scf_handle = NULL;
|
|
static scf_scope_t *scf_scope = NULL;
|
|
scf_service_t *curren_svc = NULL;
|
|
int status = 1;
|
|
|
|
// Initialization of the handles
|
|
lscf_init_handle(&scf_handle, &scf_scope);
|
|
if (scf_handle == NULL) {
|
|
status =0;
|
|
goto done;
|
|
}
|
|
|
|
// Set the current selection
|
|
if(!lscf_select(scf_handle, scf_scope, "application/x11/x11-server",
|
|
¤_svc)) {
|
|
status =0;
|
|
goto done;
|
|
}
|
|
|
|
// Set the depth property of the current selection
|
|
if(!lscf_setprop_int(scf_handle, scf_scope, curren_svc,
|
|
"options", "default_depth", depth)) {
|
|
status =0;
|
|
goto done;
|
|
}
|
|
|
|
done:
|
|
if(curren_svc) scf_service_destroy(curren_svc);
|
|
if(scf_scope) scf_scope_destroy(scf_scope);
|
|
if(scf_handle) {
|
|
scf_handle_unbind(scf_handle);
|
|
scf_handle_destroy(scf_handle);
|
|
}
|
|
if (!status) {
|
|
nv_error_msg("Unable to set X server default depth through "
|
|
"Solaris Service Management Facility");
|
|
}
|
|
return status;
|
|
}
|
|
|
|
/* READ THE DEFAULT DEPTH PROPERTY FROM SMF WITH THE LIBSCF FUNCTIONS */
|
|
int read_scf_depth(int *depth)
|
|
{
|
|
static scf_handle_t *scf_handle = NULL;
|
|
static scf_scope_t *scf_scope = NULL;
|
|
scf_service_t *curren_svc = NULL;
|
|
int status = 1;
|
|
|
|
// Initialization of the handles
|
|
lscf_init_handle(&scf_handle, &scf_scope);
|
|
if (scf_handle == NULL) {
|
|
status =0;
|
|
goto done;
|
|
}
|
|
|
|
// Set the current selection
|
|
if(!lscf_select(scf_handle, scf_scope, "application/x11/x11-server",
|
|
¤_svc)) {
|
|
status =0;
|
|
goto done;
|
|
}
|
|
|
|
// Get the depth property of the current selection
|
|
if(!lscf_getprop_int(scf_handle, scf_scope, curren_svc,
|
|
"options", "default_depth", depth)) {
|
|
status =0;
|
|
goto done;
|
|
}
|
|
|
|
done:
|
|
if(curren_svc) scf_service_destroy(curren_svc);
|
|
if(scf_scope) scf_scope_destroy(scf_scope);
|
|
if(scf_handle) {
|
|
scf_handle_unbind(scf_handle);
|
|
scf_handle_destroy(scf_handle);
|
|
}
|
|
if (!status) {
|
|
nv_error_msg("Unable to get X server default depth from "
|
|
"Solaris Service Management Facility");
|
|
}
|
|
return status;
|
|
}
|
|
|
|
|
|
/* INITIALIZATION OF THE HANDLES */
|
|
static int lscf_init_handle(scf_handle_t **scf_handle,
|
|
scf_scope_t **scf_scope)
|
|
{
|
|
scf_handle_t *handle = NULL;
|
|
scf_scope_t *scope = NULL;;
|
|
|
|
*scf_handle = NULL;
|
|
*scf_scope = NULL;
|
|
|
|
// Create a new Service Configuration Facility
|
|
// handle, needed for the communication with the
|
|
// configuration repository.
|
|
handle = scf_handle_create(SCF_VERSION);
|
|
if (handle == NULL) {
|
|
return 0;
|
|
}
|
|
|
|
// Bind the handle to the running svc.config daemon
|
|
if (scf_handle_bind(handle) != 0) {
|
|
scf_handle_destroy(handle);
|
|
return 0;
|
|
}
|
|
|
|
|
|
// Allocate a new scope. A scope is a top level of the
|
|
// SCF repository tree.
|
|
scope = scf_scope_create(handle);
|
|
if (scope == NULL) {
|
|
scf_handle_unbind(handle);
|
|
scf_handle_destroy(handle);
|
|
return 0;
|
|
}
|
|
|
|
// Set the scope to the root of the local SCF repository tree.
|
|
if (scf_handle_get_scope(handle, SCF_SCOPE_LOCAL, scope) !=0) {
|
|
scf_scope_destroy(scope);
|
|
scf_handle_unbind(handle);
|
|
scf_handle_destroy(handle);
|
|
return 0;
|
|
}
|
|
|
|
*scf_handle = handle;
|
|
*scf_scope = scope;
|
|
|
|
return 1;
|
|
}
|
|
|
|
|
|
/* EQUIVALENT TO THE SVCCFG SELECT COMMAND */
|
|
static int lscf_select(scf_handle_t *scf_handle,
|
|
scf_scope_t *scf_scope,
|
|
const char *selection,
|
|
scf_service_t **current_svc)
|
|
{
|
|
scf_service_t *svc;
|
|
|
|
// Services are children of a scope, and
|
|
// contain configuration information for
|
|
// the service.
|
|
svc = scf_service_create(scf_handle);
|
|
if (svc == NULL) {
|
|
return 0;
|
|
}
|
|
|
|
// Set the service 'svc' to the service specified
|
|
// by 'selection', in the scope 'scf_scope'.
|
|
if (scf_scope_get_service(scf_scope, selection, svc) == SCF_SUCCESS) {
|
|
*current_svc = svc;
|
|
return 1;
|
|
}
|
|
|
|
scf_service_destroy(svc);
|
|
return 0;
|
|
}
|
|
|
|
/* EQUIVALENT TO THE SVCCFG SETPROP COMMAND FOR AN INTEGER TYPED VALUE */
|
|
static int lscf_setprop_int(scf_handle_t *scf_handle,
|
|
scf_scope_t *scf_scope,
|
|
scf_service_t *current_svc,
|
|
const char *group,
|
|
const char *name, int value)
|
|
{
|
|
scf_transaction_entry_t *entry=NULL;
|
|
scf_propertygroup_t *pg = NULL;
|
|
scf_property_t *prop = NULL;
|
|
scf_transaction_t *transax = NULL;
|
|
scf_value_t *v = NULL;
|
|
int status = 1;
|
|
|
|
// Allocate a new transaction entry handle
|
|
entry = scf_entry_create(scf_handle);
|
|
if (entry == NULL) {
|
|
status=0;
|
|
goto done;
|
|
}
|
|
|
|
// Allocate a property group.
|
|
pg = scf_pg_create(scf_handle);
|
|
if (pg == NULL) {
|
|
status=0;
|
|
goto done;
|
|
}
|
|
|
|
// Allocate a property. A property is a named set
|
|
// of values.
|
|
prop = scf_property_create(scf_handle);
|
|
if (prop == NULL) {
|
|
status=0;
|
|
goto done;
|
|
}
|
|
|
|
// Allocate a transaction, used to change
|
|
// property groups.
|
|
transax = scf_transaction_create(scf_handle);
|
|
if (transax == NULL) {
|
|
status=0;
|
|
goto done;
|
|
}
|
|
|
|
// Allocate a value.
|
|
v = scf_value_create(scf_handle);
|
|
if (v == NULL) {
|
|
status=0;
|
|
goto done;
|
|
}
|
|
|
|
// Set the the property group 'pg' to the
|
|
// groups specified by 'group' in the service
|
|
// specified by 'current_svc'
|
|
if (scf_service_get_pg(current_svc, group, pg) != SCF_SUCCESS) {
|
|
status=0;
|
|
goto done;
|
|
}
|
|
|
|
// Update the property group.
|
|
if (scf_pg_update(pg) == -1) {
|
|
status=0;
|
|
goto done;
|
|
}
|
|
|
|
// Set up the transaction to modify the property group.
|
|
if (scf_transaction_start(transax, pg) != SCF_SUCCESS) {
|
|
status=0;
|
|
goto done;
|
|
}
|
|
|
|
// Set the property 'prop' to the property
|
|
// specified ny 'name' in the property group 'pg'
|
|
if (scf_pg_get_property(pg, name, prop) == SCF_SUCCESS) {
|
|
// Found
|
|
// It should be already of integer type.
|
|
// To be secure, reset the property type to integer.
|
|
if (scf_transaction_property_change_type(transax, entry,
|
|
name, SCF_TYPE_INTEGER) == -1) {
|
|
status=0;
|
|
goto done;
|
|
}
|
|
} else {
|
|
// Not found
|
|
// Add a new property to the property group.
|
|
if (scf_transaction_property_new(transax, entry,
|
|
name, SCF_TYPE_INTEGER)
|
|
== -1) {
|
|
status=0;
|
|
goto done;
|
|
}
|
|
}
|
|
|
|
// Set the integer value
|
|
scf_value_set_integer(v, value);
|
|
|
|
// Set up the value to the property.
|
|
if (scf_entry_add_value(entry, v) != SCF_SUCCESS) {
|
|
status=0;
|
|
goto done;
|
|
}
|
|
|
|
// Commit the transaction
|
|
if (scf_transaction_commit(transax) < 0) {
|
|
status=0;
|
|
}
|
|
|
|
done:
|
|
if (entry) scf_entry_destroy(entry);
|
|
if (pg) scf_pg_destroy(pg);
|
|
if (prop) scf_property_destroy(prop);
|
|
if (transax) scf_transaction_destroy(transax);
|
|
if (v) scf_value_destroy(v);
|
|
return status;
|
|
}
|
|
|
|
/* EQUIVALENT TO THE SVCCFG SETPROP COMMAND FOR AN INTEGER TYPED VALUE */
|
|
static int lscf_getprop_int(scf_handle_t *scf_handle,
|
|
scf_scope_t *scf_scope,
|
|
scf_service_t *current_svc,
|
|
const char *group,
|
|
const char *name, int *value)
|
|
{
|
|
scf_transaction_entry_t *entry=NULL;
|
|
scf_propertygroup_t *pg = NULL;
|
|
scf_property_t *prop = NULL;
|
|
scf_value_t *v = NULL;
|
|
int status = 1;
|
|
int64_t t;
|
|
|
|
// Allocate a new transaction entry handle
|
|
entry = scf_entry_create(scf_handle);
|
|
if (entry == NULL) {
|
|
status=0;
|
|
goto done;
|
|
}
|
|
|
|
// Allocate a property group.
|
|
pg = scf_pg_create(scf_handle);
|
|
if (pg == NULL) {
|
|
status=0;
|
|
goto done;
|
|
}
|
|
|
|
// Allocate a property. A property is a named set
|
|
// of values.
|
|
prop = scf_property_create(scf_handle);
|
|
if (prop == NULL) {
|
|
status=0;
|
|
goto done;
|
|
}
|
|
|
|
// Set the the property group 'pg' to the
|
|
// groups specified by 'group' in the service
|
|
// specified by 'current_svc'
|
|
if (scf_service_get_pg(current_svc, group, pg) != SCF_SUCCESS) {
|
|
status=0;
|
|
goto done;
|
|
}
|
|
|
|
// Update the property group.
|
|
if (scf_pg_update(pg) == -1) {
|
|
status=0;
|
|
goto done;
|
|
}
|
|
|
|
// Set the property 'prop' to the property
|
|
// specified ny 'name' in the property group 'pg'
|
|
if (scf_pg_get_property(pg, name, prop) != SCF_SUCCESS) {
|
|
status=0;
|
|
goto done;
|
|
}
|
|
|
|
// Allocate a value.
|
|
v = scf_value_create(scf_handle);
|
|
if (v == NULL) {
|
|
status=0;
|
|
goto done;
|
|
}
|
|
|
|
// Get the value
|
|
if (scf_property_get_value(prop, v) != SCF_SUCCESS) {
|
|
status=0;
|
|
goto done;
|
|
}
|
|
|
|
// Get the integer value
|
|
if (scf_value_get_integer(v, &t) != SCF_SUCCESS) {
|
|
status=0;
|
|
goto done;
|
|
}
|
|
|
|
*value = (int)t;
|
|
|
|
done:
|
|
if (entry) scf_entry_destroy(entry);
|
|
if (pg) scf_pg_destroy(pg);
|
|
if (prop) scf_property_destroy(prop);
|
|
if (v) scf_value_destroy(v);
|
|
return status;
|
|
}
|
|
#else // NOT SOLARIS
|
|
int update_scf_depth(int depth)
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
int read_scf_depth(int *depth)
|
|
{
|
|
return 0;
|
|
}
|
|
#endif
|