Logo Search packages:      
Sourcecode: libdc1394-22 version File versions  Download package

dc1394error_t dc1394_feature_get ( dc1394camera_t camera,
dc1394feature_info_t feature 
)

Stores the bounds and options associated with the feature described by feature->feature_id

Definition at line 203 of file control.c.

References __dc1394feature_info_t_struct::abs_control, __dc1394feature_info_t_struct::abs_max, __dc1394feature_info_t_struct::abs_min, __dc1394feature_info_t_struct::abs_value, __dc1394feature_info_t_struct::absolute_capable, __dc1394feature_info_t_struct::available, __dc1394feature_info_t_struct::B_value, __dc1394feature_info_t_struct::BU_value, __dc1394feature_info_t_struct::current_mode, dc1394_get_control_register(), __dc1394feature_info_t_struct::G_value, __dc1394feature_info_t_struct::id, __dc1394feature_info_t_struct::is_on, __dc1394feature_info_t_struct::max, __dc1394feature_info_t_struct::min, dc1394trigger_modes_t::modes, __dc1394feature_info_t_struct::modes, dc1394trigger_modes_t::num, __dc1394feature_info_t_struct::on_off_capable, __dc1394feature_info_t_struct::polarity_capable, __dc1394feature_info_t_struct::R_value, __dc1394feature_info_t_struct::readout_capable, __dc1394feature_info_t_struct::RV_value, __dc1394feature_info_t_struct::target_value, __dc1394feature_info_t_struct::trigger_mode, __dc1394feature_info_t_struct::trigger_modes, __dc1394feature_info_t_struct::trigger_polarity, __dc1394feature_info_t_struct::trigger_source, __dc1394feature_info_t_struct::trigger_sources, and __dc1394feature_info_t_struct::value.

{
    uint64_t offset;
    uint32_t value;
    dc1394error_t err;

    if ( (feature->id < DC1394_FEATURE_MIN) || (feature->id > DC1394_FEATURE_MAX) ) {
        return DC1394_INVALID_FEATURE;
    }

    // check presence
    err=dc1394_feature_is_present(camera, feature->id, &(feature->available));
    DC1394_ERR_RTN(err, "Could not check feature presence");

    if (feature->available == DC1394_FALSE) {
        return DC1394_SUCCESS;
    }

    // get capabilities
    FEATURE_TO_INQUIRY_OFFSET(feature->id, offset);
    err=dc1394_get_control_register(camera, offset, &value);
    DC1394_ERR_RTN(err, "Could not check feature characteristics");

    dc1394_feature_get_modes(camera, feature->id, &feature->modes);
    dc1394_feature_get_mode(camera, feature->id, &feature->current_mode);

    switch (feature->id) {
    case DC1394_FEATURE_TRIGGER:
        feature->polarity_capable= (value & 0x02000000UL) ? DC1394_TRUE : DC1394_FALSE;
        int i, j;
        uint32_t value_tmp;

        feature->trigger_modes.num=0;
        value_tmp= (value & (0xFFFF));

        for (i=DC1394_TRIGGER_MODE_MIN;i<=DC1394_TRIGGER_MODE_MAX;i++) {
            j = i - DC1394_TRIGGER_MODE_MIN;
            if (value_tmp & (0x1 << (15-j-(j>5)*8))) { // (i>5)*8 to take the mode gap into account
                feature->trigger_modes.modes[feature->trigger_modes.num]=i;
                feature->trigger_modes.num++;
            }
        }

        err=dc1394_external_trigger_get_supported_sources(camera,&feature->trigger_sources);
        DC1394_ERR_RTN(err, "Could not get supported trigger sources");

        break;
    default:
        feature->polarity_capable = 0;
        feature->trigger_mode     = 0;

        feature->min= (value & 0xFFF000UL) >> 12;
        feature->max= (value & 0xFFFUL);
        break;
    }

    feature->absolute_capable = (value & 0x40000000UL) ? DC1394_TRUE : DC1394_FALSE;
    feature->readout_capable  = (value & 0x08000000UL) ? DC1394_TRUE : DC1394_FALSE;
    feature->on_off_capable   = (value & 0x04000000UL) ? DC1394_TRUE : DC1394_FALSE;

    // get current values
    FEATURE_TO_VALUE_OFFSET(feature->id, offset);

    err=dc1394_get_control_register(camera, offset, &value);
    DC1394_ERR_RTN(err, "Could not get feature register");

    switch (feature->id) {
    case DC1394_FEATURE_TRIGGER:
        feature->trigger_polarity= (value & 0x01000000UL) ? DC1394_TRUE : DC1394_FALSE;
        feature->trigger_mode= (uint32_t)((value >> 16) & 0xF);
        if (feature->trigger_mode >= 14)
            feature->trigger_mode += DC1394_TRIGGER_MODE_MIN - 8;
        else
            feature->trigger_mode += DC1394_TRIGGER_MODE_MIN;
        feature->trigger_source = (uint32_t)((value >> 21) & 0x7UL);
        if (feature->trigger_source > 3)
            feature->trigger_source -= 3;
        feature->trigger_source += DC1394_TRIGGER_SOURCE_MIN;
        break;
    default:
        break;
    }

    feature->is_on= (value & 0x02000000UL) ? DC1394_TRUE : DC1394_FALSE;

    switch (feature->id) {
    case DC1394_FEATURE_WHITE_BALANCE:
        feature->RV_value= value & 0xFFFUL;
        feature->BU_value= (value & 0xFFF000UL) >> 12;
        break;
    case DC1394_FEATURE_WHITE_SHADING:
        feature->R_value=value & 0xFFUL;
        feature->G_value=(value & 0xFF00UL)>>8;
        feature->B_value=(value & 0xFF0000UL)>>16;
        break;
    case DC1394_FEATURE_TEMPERATURE:
        feature->value= value & 0xFFFUL;
        feature->target_value= value & 0xFFF000UL;
        break;
    default:
        feature->value= value & 0xFFFUL;
        break;
    }

    if (feature->absolute_capable>0) {
        err=dc1394_feature_get_absolute_boundaries(camera, feature->id, &feature->abs_min, &feature->abs_max);
        DC1394_ERR_RTN(err, "Could not get feature absolute min/max");
        err=dc1394_feature_get_absolute_value(camera, feature->id, &feature->abs_value);
        DC1394_ERR_RTN(err, "Could not get feature absolute value");
        err=dc1394_feature_get_absolute_control(camera, feature->id, &feature->abs_control);
        DC1394_ERR_RTN(err, "Could not get feature absolute control");
    }

    return err;
}


Generated by  Doxygen 1.6.0   Back to index