Oyranos Colour Management System API
Functions
Device API
Alpha API's
Collaboration diagram for Device API:

Functions

OYAPI int OYEXPORT oyDevicesGet (const char *device_type, const char *device_class, oyOptions_s *options, oyConfigs_s **devices)
 get all devices matching to a device class and type
OYAPI int OYEXPORT oyDeviceGet (const char *device_type, const char *device_class, const char *device_name, oyOptions_s *options, oyConfig_s **device)
 ask a module for device informations or other direct calls
OYAPI int OYEXPORT oyDeviceBackendCall (oyConfig_s *device, oyOptions_s *options)
 get device answere from options
OYAPI int OYEXPORT oyDeviceSetup (oyConfig_s *device)
 activate the device using the stored configuration
int oyDeviceUnset (oyConfig_s *device)
 unset the device profile
OYAPI int OYEXPORT oyDeviceGetInfo (oyConfig_s *device, oyNAME_e type, oyOptions_s *options, char **info_text, oyAlloc_f allocateFunc)
 get all devices matching to a device class and type
OYAPI int OYEXPORT oyDeviceGetProfile (oyConfig_s *device, oyOptions_s *options, oyProfile_s **profile)
 order a device profile
OYAPI int OYEXPORT oyDeviceAskProfile2 (oyConfig_s *device, oyOptions_s *options, oyProfile_s **profile)
 ask for the device profile
int oyDeviceSetProfile (oyConfig_s *device, const char *profile_name)
 set the device profile
OYAPI int OYEXPORT oyDeviceProfileFromDB (oyConfig_s *device, char **profile_name, oyAlloc_f allocateFunc)
 look up a profile of a device from DB
OYAPI int OYEXPORT oyDeviceSelectSimiliar (oyConfig_s *pattern, oyConfigs_s *heap, uint32_t flags, oyConfigs_s **matched_devices)
 get similiar devices by a pattern from a list
OYAPI int OYEXPORT oyDeviceFromJSON (const char *json_text, oyOptions_s *options, oyConfig_s **device)
 generate a device from a JSON device calibration
OYAPI int OYEXPORT oyDeviceToJSON (oyConfig_s *device, oyOptions_s *options, char **json_text, oyAlloc_f allocateFunc)
 get JSON format device calibration text from a device

Detailed Description

Devices are a special form of configurations. Their access is grouped for effective performance. Known devices are queried with oyDevicesGet(). oyConfigDomainList() provides a list of known device modules. A single device can be obtained by oyDeviceGet(). The device_type argument defaults to OY_TYPE_STD and can be omitted for this group. The device_class argument specifies a subgroup, e.g. "monitor".

All other functions return a handle to the device. With this handle it is possible to get informations (oyDeviceGetInfo()), query it's current, possibly remote profile (oyDeviceAskProfile2()) or typical used get a profile with fallbacks including the DB through (oyDeviceGetProfile()), set the profile persistent (oyDeviceSetProfile()) or query the persistent stored profile (oyDeviceProfileFromDB()).


Function Documentation

OYAPI int OYEXPORT oyDeviceAskProfile2 ( oyConfig_s device,
oyOptions_s *  options,
oyProfile_s **  profile 
)

ask for the device profile

Function oyDeviceAskProfile2 Ask for a profile associated with the device. A device capable to hold a profile. Only the held profile will be checked and returned. In case this profile is not found a "icc_profile" of oyVAL_STRUCT should be included.

The device might not be able to hold a profile, then just the DB profile will be returned from here without an issue. For interessted users, the source of the profile keeps transparent, as it can be checked if the device contains a "icc_profile" option which contains a oyProfile_s object.

Parameters:
[in]devicethe device
[in]optionsadditional options
[out]profilethe device's ICC profile
Returns:
0 - good, 1 >= error, -1 <= issue(s)
Version:
Oyranos: 0.1.10
Since:
2009/02/10 (Oyranos: 0.1.10)
Date:
2009/12/10

References oyConfig_s::oyConfig_Find(), oyDeviceBackendCall(), oyDeviceProfileFromDB(), oyProfile_s::oyProfile_FromFile(), oyProfile_s::oyProfile_GetSignature(), oySIGNATURE_MAGIC, and oyConfig_s::registration.

Referenced by oyDeviceGetProfile(), and oyDeviceSetup().

OYAPI int OYEXPORT oyDeviceBackendCall ( oyConfig_s device,
oyOptions_s *  options 
)

get device answere from options

Function oyDeviceBackendCall

Parameters:
[in]devicethe device
[in]optionsoptions for the device
Returns:
error
Version:
Oyranos: 0.1.10
Since:
2009/02/02 (Oyranos: 0.1.10)
Date:
2009/08/25

1. obtain detailed and expensive device informations for a zero options argument through the "properties" command.

1.1 add "properties" call to module arguments

3. talk to the module

References oyConfig_s::oyConfig_Copy(), oyConfigs_s::oyConfigs_Modify(), oyConfigs_s::oyConfigs_MoveIn(), oyConfigs_s::oyConfigs_New(), oyConfigs_s::oyConfigs_Release(), and oyConfig_s::registration.

Referenced by oyDeviceAskProfile2(), oyDeviceGetInfo(), oyDeviceProfileFromDB(), oyDeviceSelectSimiliar(), oyDeviceSetProfile(), oyDeviceSetup(), and oyDeviceUnset().

OYAPI int OYEXPORT oyDeviceFromJSON ( const char *  json_text,
oyOptions_s *  options,
oyConfig_s **  device 
)

generate a device from a JSON device calibration

Function oyDeviceGetJSON

Parameters:
[in]json_textthe device calibration
[in]optionsunused
[out]configthe device
Returns:
error
Version:
Oyranos: 0.3.2
Since:
2011/08/21 (Oyranos: 0.3.2)
Date:
2011/08/21

References oyConfig_s::oyConfig_AddDBData(), and oyConfig_s::oyConfig_New().

OYAPI int OYEXPORT oyDeviceGet ( const char *  device_type,
const char *  device_class,
const char *  device_name,
oyOptions_s *  options,
oyConfig_s **  device 
)

ask a module for device informations or other direct calls

Function oyDeviceGet

    oyConfig_s * device = 0;
    int error = oyDeviceGet( 0, "monitor", ":0.0", 0, &device );
    oyConfig_Release( &device );
    
    // pass empty options to the module to get a usage message
    oyOptions_s * options = oyOptions_New( 0 );
    oyDeviceGet( OY_TYPE_STD, "monitor", ":0.0", options, 0 );
    
Parameters:
[in]device_typethe device type, e.g. OY_TYPE_STD, defaults to OY_TYPE_STD (optional)
[in]device_classregistration ::oyFILTER_REG_APPLICATION part, e.g. "monitor", mandatory
[in]device_namethe device name as returned by oyConfigs_FromPattern_f, mandatory, ::oyFILTER_REG_OPTION
[in]optionsoptions to pass to the module, for zero the verbose and expensive "properties" call is assumed
[out]devicethe returned device
Returns:
error
Version:
Oyranos: 0.1.10
Since:
2009/01/28 (Oyranos: 0.1.10)
Date:
2009/02/09

1. obtain basic device informations

1.1 add "list" call to module arguments

1.1.2 set device filter

2. get the device

3. check for success of device detection

References oyConfig_s::oyConfig_Release(), oyConfigs_s::oyConfigs_FromDeviceClass(), oyConfigs_s::oyConfigs_Get(), and oyConfigs_s::oyConfigs_Release().

OYAPI int OYEXPORT oyDeviceGetInfo ( oyConfig_s device,
oyNAME_e  type,
oyOptions_s *  options,
char **  info_text,
oyAlloc_f  allocateFunc 
)

get all devices matching to a device class and type

Function oyDeviceGetInfo

    // print all properties
    int error = oyDeviceGetInfo( device, oyNAME_DESCRIPTION, 0, &text,
                                     malloc );
    char * list = text, * tmp = 0, * line = malloc(128);
    int even = 1;

        tmp = list;
        while(list && list[0])
        {
          snprintf( line, 128, "%s", list );
          if(strchr( line, '\n' ))
          {
            tmp = strchr( line, '\n' );
            tmp[0] = 0;
          }
          if(even)
            printf( "%s\n", line );
          else
            printf( "  %s\n", line );
          list = strchr( list, '\n' );
          if(list) ++list;
          even = !even;
        }

    if(line) free(line);
    if(text) free(text);
    

To obtain a certain single pice of information you do not need oyDeviceGetInfo. See the following example:

    char * device_name = ":0.0"; // a typical device
    char * text = 0;
    oyConfig_s * device = 0;
    oyOptions_s * options = 0;
    int error = 0;

    // tell the module with the "properties" call to add all informations
    error = oyOptions_SetFromText( &options, "//" OY_TYPE_STD
                                   "/config/command",
                                   "properties", OY_CREATE_NEW );

    oyDeviceGet( OY_TYPE_STD, "monitor", device_name, options, &device );
    text = oyConfig_FindString( device, "manufacturer", 0 );
    
Parameters:
[in]devicethe device
[in]typeinfluences the info_text output
  • oyNAME_NAME - a short one line text,
  • oyNAME_NICK - one word,
  • oyNAME_DESCRIPTION - expensive text, even lines contain the property key name, odd lines contain the value, lines are separated by newline '\n'
[in]optionsdefaults to command=properties
[out]info_textthe text
[in]allocateFuncthe user allocator for info_text
Returns:
0 - good, 1 >= error, -1 <= issue(s)
Version:
Oyranos: 0.1.10
Since:
2009/02/02 (Oyranos: 0.1.10)
Date:
2009/03/27

1.2 ask each module

1.2.1 add device_name to the string list

References oyConfig_s::backend_core, oyConfig_s::data, oyConfig_s::oyConfig_Release(), oyDeviceBackendCall(), and oyConfig_s::registration.

OYAPI int OYEXPORT oyDeviceGetProfile ( oyConfig_s device,
oyOptions_s *  options,
oyProfile_s **  profile 
)

order a device profile

Function oyDeviceGetProfile This function is designed to satisfy most users as it tries to deliver a profile all the time. Following code can almost allways expect some profile to go with. It tries hard to get a current profile or set the system up and retry or get at least one basic profile.

For a basic and thus weaker call to the device use oyDeviceAskProfile2() instead.

Parameters:
devicethe device
optionsoptions passed to the backend
profilethe device's ICC profile
Returns:
error
Version:
Oyranos: 0.1.10
Since:
2009/02/08 (Oyranos: 0.1.10)
Date:
2009/02/09

This function does a device setup in case no profile is delivered by the according module.

As a last means oyASSUMED_WEB is delivered.

References oyASSUMED_WEB, oyDeviceAskProfile2(), oyDeviceSetup(), and oyProfile_s::oyProfile_FromStd().

OYAPI int OYEXPORT oyDeviceProfileFromDB ( oyConfig_s device,
char **  profile_name,
oyAlloc_f  allocateFunc 
)

look up a profile of a device from DB

Function oyDeviceProfileFromDB The function asks the module for a detailed and possible expensive list of device information and tries to find a matching configuration in the DB. The device informations are the same as for saving to DB.

Parameters:
[in]devicea device
[in]profile_nameprofile's name in DB
[in]allocateFuncuser allocator
Returns:
error
Version:
Oyranos: 0.1.10
Since:
2009/01/21 (Oyranos: 0.1.10)
Date:
2009/02/09

References oyConfig_s::db, oyConfig_s::oyConfig_Find(), oyConfig_s::oyConfig_FindString(), oyConfig_s::oyConfig_GetDB(), and oyDeviceBackendCall().

Referenced by oyDeviceAskProfile2(), oyDeviceSetup(), and oyDeviceUnset().

OYAPI int OYEXPORT oyDeviceSelectSimiliar ( oyConfig_s pattern,
oyConfigs_s heap,
uint32_t  flags,
oyConfigs_s **  matched_devices 
)

get similiar devices by a pattern from a list

Function oyDeviceSelectSimiliar The function takes a device and tries to find exact matches, which can be considered as belonging to the same device. The comparision can be influenced by the flags. The option "profile_name" is ignored during the comparision.

Parameters:
[in]patternPass a device used as reference. String options of this object are compared to the objects in the heap argument depending on the flags argument. "profile_name" and other options from heap objects are ignored.
[in]heapa list of device objects
[in]flags- 0 yields exact match
  • 1 compare manufacturer model and serial
  • 2 compare only manufacturer and model
  • 4 compare only device_name
[out]matched_devicesthe devices selected from heap
Returns:
error
Version:
Oyranos: 0.1.10
Since:
2009/08/27 (Oyranos: 0.1.10)
Date:
2009/08/27

References oyConfig_s::oyConfig_Count(), oyConfig_s::oyConfig_FindString(), oyConfig_s::oyConfig_Get(), oyConfig_s::oyConfig_Release(), oyConfigs_s::oyConfigs_Count(), oyConfigs_s::oyConfigs_Get(), oyConfigs_s::oyConfigs_MoveIn(), oyConfigs_s::oyConfigs_New(), oyConfigs_s::oyConfigs_Release(), oyDeviceBackendCall(), and oyFilterRegistrationToText().

int oyDeviceSetProfile ( oyConfig_s device,
const char *  profile_name 
)

set the device profile

Function oyDeviceSetProfile The function will lookup the monitor in the Oyranos device database and stores the given profile there.

To set a new profile und update the device please call the following sequence:

    // store new settings in the Oyranos data base
    oyDeviceSetProfile( device, profile );
    // remove any device entries
    oyDeviceUnset( device );
    // update the device from the newly added Oyranos data base settings
    oyDeviceSetup( device );
    
Parameters:
devicethe device
profile_namethe device's ICC profile or zero to unset
Returns:
error
Version:
Oyranos: 0.1.10
Since:
2009/02/07 (Oyranos: 0.1.10)
Date:
2009/02/12

1. obtain detailed and expensive device informations

1.1 add "properties" call to module arguments

1.2 get monitor device

2. check for success of device detection

3 load profile from file name argument

3.1 check for success of profile loading

4. Now remove all those DB configurations fully matching the selected device.

4.1 get stored DB's configurations

4.1.1 compare if each device key matches to one configuration key

4.1.2 if the 4.1.1 condition is true remove the configuration

5. save the new configuration with a associated profile
5.1 add the profile simply to the device configuration

5.2 save the configuration to DB (Elektra)

5.3 reload the DB part

References oyConfig_s::backend_core, oyConfig_s::oyConfig_AddDBData(), oyConfig_s::oyConfig_ClearDBData(), oyConfig_s::oyConfig_EraseFromDB(), oyConfig_s::oyConfig_FindString(), oyConfig_s::oyConfig_GetDB(), oyConfig_s::oyConfig_Release(), oyConfig_s::oyConfig_SaveToDB(), oyConfigs_s::oyConfigs_Count(), oyConfigs_s::oyConfigs_FromDB(), oyConfigs_s::oyConfigs_Get(), oyConfigs_s::oyConfigs_Release(), oyDeviceBackendCall(), oyFilterRegistrationToText(), oyProfile_s::oyProfile_FromFile(), and oyConfig_s::registration.

OYAPI int OYEXPORT oyDeviceSetup ( oyConfig_s device)
OYAPI int OYEXPORT oyDevicesGet ( const char *  device_type,
const char *  device_class,
oyOptions_s *  options,
oyConfigs_s **  devices 
)

get all devices matching to a device class and type

Function oyDevicesGet

    // "list" all monitors
    oyConfig_s * monitors = 0;
    int error = oyDevicesGet( 0, "monitor", 0, &monitors );
    // see how many are included
    int n = oyConfigs_Count( monitors );
    // release them
    oyConfigs_Release( &monitors );
    

For obtaining expensive "properties" informations at once, add the according option.

    // get all monitors the expensive way
    oyConfig_s * monitors = 0;
    oyOptions_s * options = oyOptions_New( 0 );
    int error = 0;

    error = oyOptions_SetFromText( &options, "//" OY_TYPE_STD "/config/command",
                                   "properties", OY_CREATE_NEW );
    error = oyDevicesGet( 0, "monitor", 0, &monitors );
    oyOptions_Release( &options );

    // see how many are included
    int n = oyConfigs_Count( monitors );

    // release them
    oyConfigs_Release( &monitors );
    
Parameters:
[in]device_typethe device type ::oyFILTER_REG_TYPE, defaults to OY_TYPE_STD (optional)
[in]device_classthe device class, e.g. "monitor", ::oyFILTER_REG_APPLICATION
[in]optionsoptions for the device
[out]devicesthe found devices
Returns:
0 - good, >= 1 - error, <= -1 unknown
Version:
Oyranos: 0.1.10
Since:
2009/02/02 (Oyranos: 0.1.10)
Date:
2009/02/02

1. obtain detailed and expensive device informations

1.1 add "list" call to module arguments

1.2 ask each module

References oyConfigs_s::oyConfigs_FromDeviceClass().

OYAPI int OYEXPORT oyDeviceToJSON ( oyConfig_s device,
oyOptions_s *  options,
char **  json_text,
oyAlloc_f  allocateFunc 
)

get JSON format device calibration text from a device

Function oyDeviceToJSON

Parameters:
[in]configthe device
[in]optionsunused
[out]json_textthe device calibration
[in]allocateFuncuser allocator
Returns:
error
Version:
Oyranos: 0.3.2
Since:
2011/08/21 (Oyranos: 0.3.2)
Date:
2011/08/21

References oyConfDomain_s::oyConfDomain_FromReg(), oyConfDomain_s::oyConfDomain_GetText(), oyConfDomain_s::oyConfDomain_Release(), oyConfig_s::oyConfig_Count(), oyConfig_s::oyConfig_Get(), and oyFilterRegistrationToText().

int oyDeviceUnset ( oyConfig_s device)

unset the device profile

Function oyDeviceUnset The function solely calls unset in the module, e.g. unset graphic card luts and server stored profile. So pretty all device/server side informatin should go away.

Parameters:
devicethe device
Returns:
error
Version:
Oyranos: 0.1.10
Since:
2009/02/12 (Oyranos: 0.1.10)
Date:
2009/02/12

2.1 set a general request

2.2 send the query to a module

References oyConfig_s::oyConfig_FindString(), oyConfigs_s::oyConfigs_FromDomain(), oyDeviceBackendCall(), oyDeviceProfileFromDB(), and oyConfig_s::registration.