DFBResult dfb_layer_region_disable( CoreLayerRegion *region ) { DFBResult ret; D_ASSERT( region != NULL ); /* Lock the region. */ if (dfb_layer_region_lock( region )) return DFB_FUSION; D_ASSUME( D_FLAGS_IS_SET( region->state, CLRSF_ENABLED ) ); if (! D_FLAGS_IS_SET( region->state, CLRSF_ENABLED )) { dfb_layer_region_unlock( region ); return DFB_OK; } /* Unrealize the region if it's active. */ if (D_FLAGS_IS_SET( region->state, CLRSF_ACTIVE )) { ret = unrealize_region( region ); if (ret) return ret; } /* Update the region's state. */ D_FLAGS_CLEAR( region->state, CLRSF_ENABLED ); /* Unlock the region. */ dfb_layer_region_unlock( region ); return DFB_OK; }
DFBResult dfb_state_set_source2( CardState *state, CoreSurface *source2 ) { D_MAGIC_ASSERT( state, CardState ); dfb_state_lock( state ); if (state->source2 != source2) { if (source2 && dfb_surface_ref( source2 )) { D_WARN( "could not ref() source2" ); dfb_state_unlock( state ); return DFB_DEAD; } if (state->source2) { D_ASSERT( D_FLAGS_IS_SET( state->flags, CSF_SOURCE2 ) ); dfb_surface_unref( state->source2 ); } state->source2 = source2; state->modified |= SMF_SOURCE2; if (source2) { direct_serial_copy( &state->src2_serial, &source2->serial ); D_FLAGS_SET( state->flags, CSF_SOURCE2 ); } else D_FLAGS_CLEAR( state->flags, CSF_SOURCE2 ); } dfb_state_unlock( state ); return DFB_OK; }
DFBResult dfb_state_set_source_mask( CardState *state, CoreSurface *source_mask ) { D_MAGIC_ASSERT( state, CardState ); dfb_state_lock( state ); if (state->source_mask != source_mask) { if (source_mask && dfb_surface_ref( source_mask )) { D_WARN( "could not ref() source mask" ); dfb_state_unlock( state ); return DFB_DEAD; } if (state->source_mask) { D_ASSERT( D_FLAGS_IS_SET( state->flags, CSF_SOURCE_MASK ) ); dfb_surface_unref( state->source_mask ); } state->source_mask = source_mask; state->modified |= SMF_SOURCE_MASK; if (source_mask) { direct_serial_copy( &state->src_mask_serial, &source_mask->serial ); D_FLAGS_SET( state->flags, CSF_SOURCE_MASK ); } else D_FLAGS_CLEAR( state->flags, CSF_SOURCE_MASK ); } dfb_state_unlock( state ); return DFB_OK; }
static DFBResult unrealize_region( CoreLayerRegion *region ) { DFBResult ret; int index; CoreLayer *layer; CoreLayerShared *shared; const DisplayLayerFuncs *funcs; D_ASSERT( region != NULL ); D_ASSERT( region->context != NULL ); D_ASSERT( D_FLAGS_IS_SET( region->state, CLRSF_REALIZED ) ); layer = dfb_layer_at( region->context->layer_id ); D_ASSERT( layer != NULL ); D_ASSERT( layer->shared != NULL ); D_ASSERT( layer->funcs != NULL ); shared = layer->shared; funcs = layer->funcs; D_ASSERT( fusion_vector_contains( &shared->added_regions, region ) ); index = fusion_vector_index_of( &shared->added_regions, region ); D_DEBUG_AT( Core_Layers, "Removing region (%d, %d - %dx%d) from '%s'.\n", DFB_RECTANGLE_VALS( ®ion->config.dest ), shared->description.name ); /* Remove the region from hardware and driver. */ if (funcs->RemoveRegion) { ret = funcs->RemoveRegion( layer, layer->driver_data, layer->layer_data, region->region_data ); if (ret) { D_DERROR( ret, "Core/Layers: Could not remove region!\n" ); return ret; } } /* Remove the region from the 'added' list. */ fusion_vector_remove( &shared->added_regions, index ); /* Deallocate the driver's region data. */ if (region->region_data) { SHFREE( shared->shmpool, region->region_data ); region->region_data = NULL; } /* Update the region's state. */ D_FLAGS_CLEAR( region->state, CLRSF_REALIZED ); D_FLAGS_SET( region->state, CLRSF_FROZEN ); if (region->surface && region->surface_lock.buffer) { dfb_surface_unlock_buffer( region->surface, ®ion->surface_lock ); dfb_surface_destroy_buffers( region->surface ); } return DFB_OK; }
DFBResult dfb_state_set_source_2( CardState *state, CoreSurface *source, u32 flip_count ) { D_MAGIC_ASSERT( state, CardState ); dfb_state_lock( state ); if (state->source != source || state->source_flip_count != flip_count || !state->source_flip_count_used) { bool ref = true;//!fusion_config->secure_fusion || dfb_core_is_master( core_dfb ); if (source && ref && dfb_surface_ref( source )) { D_WARN( "could not ref() source" ); dfb_state_unlock( state ); return DFB_DEAD; } if (state->source) { D_ASSERT( D_FLAGS_IS_SET( state->flags, CSF_SOURCE ) ); if (ref) dfb_surface_unref( state->source ); } state->source = source; state->modified |= SMF_SOURCE; state->source_flip_count = flip_count; state->source_flip_count_used = true; if (source) { direct_serial_copy( &state->src_serial, &source->serial ); D_FLAGS_SET( state->flags, CSF_SOURCE ); } else D_FLAGS_CLEAR( state->flags, CSF_SOURCE ); } dfb_state_unlock( state ); return DFB_OK; }
DFBResult dfb_state_set_destination( CardState *state, CoreSurface *destination ) { D_MAGIC_ASSERT( state, CardState ); dfb_state_lock( state ); D_ASSUME( !(state->flags & CSF_DRAWING) ); if (state->destination != destination) { if (destination) { if (dfb_surface_ref( destination )) { D_WARN( "could not ref() destination" ); dfb_state_unlock( state ); return DFB_DEAD; } validate_clip( state, destination->config.size.w - 1, destination->config.size.h - 1, false ); } if (state->destination) { D_ASSERT( D_FLAGS_IS_SET( state->flags, CSF_DESTINATION ) ); dfb_surface_unref( state->destination ); } state->destination = destination; state->modified |= SMF_DESTINATION; if (destination) { direct_serial_copy( &state->dst_serial, &destination->serial ); D_FLAGS_SET( state->flags, CSF_DESTINATION ); } else D_FLAGS_CLEAR( state->flags, CSF_DESTINATION ); } dfb_state_unlock( state ); return DFB_OK; }
DFBResult dfb_state_set_source2( CardState *state, CoreSurface *source2 ) { D_MAGIC_ASSERT( state, CardState ); dfb_state_lock( state ); if (state->source2 != source2) { bool ref = true;//!fusion_config->secure_fusion || dfb_core_is_master( core_dfb ); if (source2 && ref && dfb_surface_ref( source2 )) { D_WARN( "could not ref() source2" ); dfb_state_unlock( state ); return DFB_DEAD; } if (state->source2) { D_ASSERT( D_FLAGS_IS_SET( state->flags, CSF_SOURCE2 ) ); if (ref) dfb_surface_unref( state->source2 ); } state->source2 = source2; state->modified |= SMF_SOURCE2; if (source2) { direct_serial_copy( &state->src2_serial, &source2->serial ); D_FLAGS_SET( state->flags, CSF_SOURCE2 ); } else D_FLAGS_CLEAR( state->flags, CSF_SOURCE2 ); } dfb_state_unlock( state ); return DFB_OK; }
static DFBResult sh_du_set_region( CoreLayer *layer, void *driver_data, void *layer_data, void *region_data, CoreLayerRegionConfig *config, CoreLayerRegionConfigFlags updated, CoreSurface *surface, CorePalette *palette, CoreSurfaceBufferLock *left_lock, CoreSurfaceBufferLock *right_lock ) { DFBResult ret; SHGfxDriverData *drv; SHDuLayerData *lyr; u32 *pal, dirty; D_DEBUG_AT( SH_DU_LAYER, "%s( %u, 0x%x, 0x%lx )\n", __FUNCTION__, dfb_layer_id( layer ), updated, D_FLAGS_IS_SET( updated, CLRCF_SURFACE ) ? left_lock->phys : 0 ); D_UNUSED_P( region_data ); D_UNUSED_P( surface ); D_UNUSED_P( right_lock ); drv = (SHGfxDriverData *)driver_data; lyr = (SHDuLayerData *)layer_data; pal = NULL; dirty = 0u; /* color palette */ if (D_FLAGS_IS_SET( updated, CLRCF_PALETTE ) && palette) { unsigned int i; if (palette->num_entries > 256) return DFB_UNSUPPORTED; pal = malloc(256 * sizeof(u32)); if (!pal) return DFB_NOSYSTEMMEMORY; for (i = 0; i < palette->num_entries; i++) pal[i] = SH_DU_COLOR_TO_PALETTE(palette->entries[i]); while (i < 256) pal[i++] = 0u; } /* buffer address and stride */ if (D_FLAGS_IS_SET( updated, CLRCF_SURFACE )) { u32 stride; stride = (u32)(left_lock->pitch * 8); stride /= DFB_BITS_PER_PIXEL( left_lock->buffer->format ); if (lyr->plane.stride != stride) { lyr->plane.stride = stride; SH_DU_PLANE_SET_DIRTY( dirty, STRIDE ); } if (lyr->plane.pa0 != left_lock->phys) { lyr->plane.pa0 = left_lock->phys; SH_DU_PLANE_SET_DIRTY( dirty, PA0 ); } } /* area */ if (D_FLAGS_IS_SET( updated, CLRCF_WIDTH | CLRCF_HEIGHT | CLRCF_SOURCE | CLRCF_DEST )) { u32 sx, sy, dx, dy, w, h; if (D_FLAGS_IS_SET( updated, CLRCF_WIDTH )) { D_ASSERT( config->width > 0 ); lyr->width = config->width; } if (D_FLAGS_IS_SET( updated, CLRCF_HEIGHT )) { D_ASSERT( config->height > 0 ); lyr->height = config->height; } if (D_FLAGS_IS_SET( updated, CLRCF_SOURCE )) { D_ASSERT( config->source.x >= 0 ); D_ASSERT( config->source.y >= 0 ); lyr->sx = config->source.x; lyr->sy = config->source.y; } if (D_FLAGS_IS_SET( updated, CLRCF_DEST )) { lyr->dx = config->dest.x; lyr->dy = config->dest.y; } if (lyr->dx >= 0) { w = (u32)lyr->width; sx = (u32)lyr->sx; dx = (u32)lyr->dx; } else { w = (lyr->width + lyr->dx) <= 0 ? 0u : (u32)(lyr->width + lyr->dx); sx = (u32)(lyr->sx - lyr->dx); dx = 0u; } if (lyr->dy >= 0) { h = (u32)lyr->height; sy = (u32)lyr->sy; dy = (u32)lyr->dy; } else { h = (lyr->height + lyr->dy) <= 0 ? 0u : (u32)(lyr->height + lyr->dy); sy = (u32)(lyr->sy - lyr->dy); dy = 0u; } if (lyr->plane.width != w) { lyr->plane.width = w; SH_DU_PLANE_SET_DIRTY( dirty, WIDTH ); } if (lyr->plane.height != h) { lyr->plane.height = h; SH_DU_PLANE_SET_DIRTY( dirty, HEIGHT ); } if (lyr->plane.sx != sx) { lyr->plane.sx = sx; SH_DU_PLANE_SET_DIRTY( dirty, SX ); } if (lyr->plane.sy != sy) { lyr->plane.sy = sy; SH_DU_PLANE_SET_DIRTY( dirty, SY ); } if (lyr->plane.dx != dx) { lyr->plane.dx = dx; SH_DU_PLANE_SET_DIRTY( dirty, DX ); } if (lyr->plane.dy != dy) { lyr->plane.dy = dy; SH_DU_PLANE_SET_DIRTY( dirty, DY ); } } /* mode and opacity */ if (D_FLAGS_IS_SET( updated, CLRCF_FORMAT | CLRCF_OPTIONS | CLRCF_OPACITY )) { u32 mode, opacity; mode = lyr->plane.mode; opacity = lyr->plane.opacity; if (D_FLAGS_IS_SET( updated, CLRCF_OPACITY )) lyr->opacity = config->opacity; if (D_FLAGS_IS_SET( updated, CLRCF_OPTIONS )) { if (D_FLAGS_IS_SET( config->options, DLOP_ALPHACHANNEL )) { D_FLAGS_SET( mode, SH_DU_PMR_BLEND ); D_FLAGS_CLEAR( opacity, SH_DU_PALPHAR_ABIT_IGNORE ); D_FLAGS_SET( opacity, SH_DU_PALPHAR_PALETTE ); } else if (D_FLAGS_IS_SET( config->options, DLOP_OPACITY )) { D_FLAGS_SET( mode, SH_DU_PMR_BLEND ); D_FLAGS_SET( opacity, SH_DU_PALPHAR_ABIT_IGNORE ); D_FLAGS_CLEAR( opacity, SH_DU_PALPHAR_PALETTE ); } else { D_FLAGS_CLEAR( mode, SH_DU_PMR_BLEND ); } if (D_FLAGS_IS_SET( config->options, DLOP_SRC_COLORKEY )) D_FLAGS_CLEAR( mode, SH_DU_PMR_NOSRCKEY ); else D_FLAGS_SET( mode, SH_DU_PMR_NOSRCKEY ); } if (D_FLAGS_IS_SET( updated, CLRCF_FORMAT )) { mode &= ~SH_DU_PMR_DDF_MASK; switch (config->format) { case DSPF_RGB16: mode |= SH_DU_PMR_DDF565; break; case DSPF_ARGB1555: mode |= SH_DU_PMR_DDF1555; break; default: D_ASSERT( config->format == DSPF_LUT8 ); mode |= SH_DU_PMR_DDF8; break; } } if (D_FLAGS_IS_SET( mode, SH_DU_PMR_BLEND )) { if (D_FLAGS_IS_SET( opacity, SH_DU_PALPHAR_PALETTE )) /* pixel alpha blending */ opacity |= SH_DU_PALPHAR_ALPHA_MASK; else /* const alpha blending */ opacity = (opacity & ~SH_DU_PALPHAR_ALPHA_MASK) | (u32)lyr->opacity; } if (lyr->plane.opacity != opacity) { lyr->plane.opacity = opacity; SH_DU_PLANE_SET_DIRTY( dirty, OPACITY ); } if (lyr->plane.mode != mode) { lyr->plane.mode = mode; SH_DU_PLANE_SET_DIRTY( dirty, MODE ); } } /* src color key */ if (D_FLAGS_IS_SET( updated, CLRCF_SRCKEY )) lyr->ckey = config->src_key; if (D_FLAGS_IS_SET( updated, CLRCF_SRCKEY | CLRCF_FORMAT )) { u32 ddf, ckey; ddf = lyr->plane.mode & SH_DU_PMR_DDF_MASK; if (ddf == SH_DU_PMR_DDF8) { ckey = (u32)lyr->ckey.index; if (lyr->plane.ckey8 != ckey) { lyr->plane.ckey8 = ckey; SH_DU_PLANE_SET_DIRTY( dirty, CKEY8 ); } } else { ckey = (ddf == SH_DU_PMR_DDF565) ? SH_DU_COLORKEY_TO_RGB565( lyr->ckey ) : SH_DU_COLORKEY_TO_ARGB1555( lyr->ckey ); if (lyr->plane.ckey16 != ckey) { lyr->plane.ckey16 = ckey; SH_DU_PLANE_SET_DIRTY( dirty, CKEY16 ); } } } ret = (dirty || pal) ? update_layer( drv, lyr, dirty, pal ) : DFB_OK; if (pal) free( pal ); return ret; }
DFBResult dfb_layer_region_flip_update( CoreLayerRegion *region, const DFBRegion *update, DFBSurfaceFlipFlags flags ) { DFBResult ret = DFB_OK; DFBRegion rotated; CoreLayer *layer; CoreLayerContext *context; CoreSurface *surface; const DisplayLayerFuncs *funcs; if (update) D_DEBUG_AT( Core_Layers, "dfb_layer_region_flip_update( %p, %p, 0x%08x ) <- [%d, %d - %dx%d]\n", region, update, flags, DFB_RECTANGLE_VALS_FROM_REGION( update ) ); else D_DEBUG_AT( Core_Layers, "dfb_layer_region_flip_update( %p, %p, 0x%08x )\n", region, update, flags ); D_ASSERT( region != NULL ); D_ASSERT( region->context != NULL ); /* Lock the region. */ if (dfb_layer_region_lock( region )) return DFB_FUSION; D_ASSUME( region->surface != NULL ); /* Check for NULL surface. */ if (!region->surface) { D_DEBUG_AT( Core_Layers, " -> No surface => no update!\n" ); dfb_layer_region_unlock( region ); return DFB_UNSUPPORTED; } context = region->context; surface = region->surface; layer = dfb_layer_at( context->layer_id ); D_ASSERT( layer->funcs != NULL ); funcs = layer->funcs; /* Unfreeze region? */ if (D_FLAGS_IS_SET( region->state, CLRSF_FROZEN )) { D_FLAGS_CLEAR( region->state, CLRSF_FROZEN ); if (D_FLAGS_IS_SET( region->state, CLRSF_REALIZED )) { ret = set_region( region, ®ion->config, CLRCF_ALL, surface ); if (ret) D_DERROR( ret, "Core/LayerRegion: set_region() in dfb_layer_region_flip_update() failed!\n" ); } else if (D_FLAGS_ARE_SET( region->state, CLRSF_ENABLED | CLRSF_ACTIVE )) { ret = realize_region( region ); if (ret) D_DERROR( ret, "Core/LayerRegion: realize_region() in dfb_layer_region_flip_update() failed!\n" ); } if (ret) { dfb_layer_region_unlock( region ); return ret; } } /* Depending on the buffer mode... */ switch (region->config.buffermode) { case DLBM_TRIPLE: case DLBM_BACKVIDEO: /* Check if simply swapping the buffers is possible... */ if (!(flags & DSFLIP_BLIT) && !surface->rotation && (!update || (update->x1 == 0 && update->y1 == 0 && update->x2 == surface->config.size.w - 1 && update->y2 == surface->config.size.h - 1))) { D_DEBUG_AT( Core_Layers, " -> Going to swap buffers...\n" ); /* Use the driver's routine if the region is realized. */ if (D_FLAGS_IS_SET( region->state, CLRSF_REALIZED )) { D_ASSUME( funcs->FlipRegion != NULL ); ret = region_buffer_lock( region, surface, CSBR_BACK ); if (ret) { dfb_layer_region_unlock( region ); return ret; } D_DEBUG_AT( Core_Layers, " -> Flipping region using driver...\n" ); if (funcs->FlipRegion) ret = funcs->FlipRegion( layer, layer->driver_data, layer->layer_data, region->region_data, surface, flags, ®ion->surface_lock ); dfb_surface_unlock( surface ); } else { D_DEBUG_AT( Core_Layers, " -> Flipping region not using driver...\n" ); /* Just do the hardware independent work. */ dfb_surface_lock( surface ); dfb_surface_flip( surface, false ); dfb_surface_unlock( surface ); } break; } /* fall through */ case DLBM_BACKSYSTEM: D_DEBUG_AT( Core_Layers, " -> Going to copy portion...\n" ); if ((flags & DSFLIP_WAITFORSYNC) == DSFLIP_WAITFORSYNC) { D_DEBUG_AT( Core_Layers, " -> Waiting for VSync...\n" ); dfb_layer_wait_vsync( layer ); } D_DEBUG_AT( Core_Layers, " -> Copying content from back to front buffer...\n" ); /* ...or copy updated contents from back to front buffer. */ dfb_back_to_front_copy_rotation( surface, update, surface->rotation ); if ((flags & DSFLIP_WAITFORSYNC) == DSFLIP_WAIT) { D_DEBUG_AT( Core_Layers, " -> Waiting for VSync...\n" ); dfb_layer_wait_vsync( layer ); } /* fall through */ case DLBM_FRONTONLY: /* Tell the driver about the update if the region is realized. */ if (funcs->UpdateRegion && D_FLAGS_IS_SET( region->state, CLRSF_REALIZED )) { if (surface) { CoreSurfaceAllocation *allocation; allocation = region->surface_lock.allocation; D_ASSERT( allocation != NULL ); /* If hardware has written or is writing... */ if (allocation->accessed[CSAID_GPU] & CSAF_WRITE) { D_DEBUG_AT( Core_Layers, " -> Waiting for pending writes...\n" ); /* ...wait for the operation to finish. */ if (!(flags & DSFLIP_PIPELINE)) dfb_gfxcard_sync(); /* TODO: wait for serial instead */ allocation->accessed[CSAID_GPU] &= ~CSAF_WRITE; } dfb_surface_lock( surface ); dfb_surface_allocation_update( allocation, CSAF_READ ); dfb_surface_unlock( surface ); } D_DEBUG_AT( Core_Layers, " -> Notifying driver about updated content...\n" ); dfb_region_from_rotated( &rotated, update, &surface->config.size, surface->rotation ); ret = funcs->UpdateRegion( layer, layer->driver_data, layer->layer_data, region->region_data, surface, &rotated, ®ion->surface_lock ); } break; default: D_BUG("unknown buffer mode"); ret = DFB_BUG; } D_DEBUG_AT( Core_Layers, " -> done.\n" ); /* Unlock the region. */ dfb_layer_region_unlock( region ); return ret; }
DirectResult direct_config_set( const char *name, const char *value ) { if (direct_strcmp (name, "disable-module" ) == 0) { if (value) { int n = 0; while (direct_config->disable_module && direct_config->disable_module[n]) n++; direct_config->disable_module = (char**) D_REALLOC( direct_config->disable_module, sizeof(char*) * (n + 2) ); direct_config->disable_module[n] = D_STRDUP( value ); direct_config->disable_module[n+1] = NULL; } else { D_ERROR("Direct/Config '%s': No module name specified!\n", name); return DR_INVARG; } } else if (direct_strcmp (name, "module-dir" ) == 0) { if (value) { if (direct_config->module_dir) D_FREE( direct_config->module_dir ); direct_config->module_dir = D_STRDUP( value ); } else { D_ERROR("Direct/Config 'module-dir': No directory name specified!\n"); return DR_INVARG; } } else if (direct_strcmp (name, "memcpy" ) == 0) { if (value) { if (direct_config->memcpy) D_FREE( direct_config->memcpy ); direct_config->memcpy = D_STRDUP( value ); } else { D_ERROR("Direct/Config '%s': No method specified!\n", name); return DR_INVARG; } } else if (direct_strcmp (name, "quiet" ) == 0 || strcmp (name, "no-quiet" ) == 0) { /* Enable/disable all at once by default. */ DirectMessageType type = DMT_ALL; /* Find out the specific message type being configured. */ if (value) { if (!strcmp( value, "info" )) type = DMT_INFO; else if (!strcmp( value, "warning" )) type = DMT_WARNING; else if (!strcmp( value, "error" )) type = DMT_ERROR; else if (!strcmp( value, "once" )) type = DMT_ONCE; else if (!strcmp( value, "untested" )) type = DMT_UNTESTED; else if (!strcmp( value, "unimplemented" )) type = DMT_UNIMPLEMENTED; else { D_ERROR( "DirectFB/Config '%s': Unknown message type '%s'!\n", name, value ); return DR_INVARG; } } /* Set/clear the corresponding flag in the configuration. */ if (name[0] == 'q') D_FLAGS_SET( direct_config->quiet, type ); else D_FLAGS_CLEAR( direct_config->quiet, type ); } else if (direct_strcmp (name, "no-quiet" ) == 0) { direct_config->quiet = DMT_NONE; } else if (direct_strcmp (name, "debug" ) == 0) { if (value) { DirectLogDomainConfig config = {0}; if (value[0] && value[1] == ':') { config.level = value[0] - '0' + DIRECT_LOG_DEBUG_0; value += 2; } else config.level = DIRECT_LOG_DEBUG; direct_log_domain_configure( value, &config ); } else if (direct_config->log_level < DIRECT_LOG_DEBUG) direct_config->log_level = DIRECT_LOG_DEBUG; } else if (direct_strcmp (name, "no-debug" ) == 0) { if (value) { DirectLogDomainConfig config = {0}; config.level = DIRECT_LOG_DEBUG_0; direct_log_domain_configure( value, &config ); } else if (direct_config->log_level > DIRECT_LOG_DEBUG_0) direct_config->log_level = DIRECT_LOG_DEBUG_0; } else if (direct_strcmp (name, "log-all" ) == 0) { direct_config->log_all = true; } else if (direct_strcmp (name, "log-none" ) == 0) { direct_config->log_none = true; } else if (direct_strcmp (name, "debugmem" ) == 0) { direct_config->debugmem = true; } else if (direct_strcmp (name, "no-debugmem" ) == 0) { direct_config->debugmem = false; } else if (direct_strcmp (name, "trace" ) == 0) { direct_config->trace = true; } else if (direct_strcmp (name, "no-trace" ) == 0) { direct_config->trace = false; } else if (direct_strcmp (name, "log-file" ) == 0 || strcmp (name, "log-udp" ) == 0) { if (value) { DirectResult ret; DirectLog *log; ret = direct_log_create( strcmp(name,"log-udp") ? DLT_FILE : DLT_UDP, value, &log ); if (ret) return ret; if (direct_config->log) direct_log_destroy( direct_config->log ); direct_config->log = log; direct_log_set_default( log ); } else { if (direct_strcmp(name,"log-udp")) D_ERROR("Direct/Config '%s': No file name specified!\n", name); else D_ERROR("Direct/Config '%s': No host and port specified!\n", name); return DR_INVARG; } } else if (direct_strcmp (name, "fatal-level" ) == 0) { if (direct_strcasecmp (value, "none" ) == 0) { direct_config->fatal = DCFL_NONE; } else if (direct_strcasecmp (value, "assert" ) == 0) { direct_config->fatal = DCFL_ASSERT; } else if (direct_strcasecmp (value, "assume" ) == 0) { direct_config->fatal = DCFL_ASSUME; } else { D_ERROR("Direct/Config '%s': Unknown level specified (use 'none', 'assert', 'assume')!\n", name); return DR_INVARG; } } else if (direct_strcmp (name, "fatal-break" ) == 0) { direct_config->fatal_break = true; } else if (direct_strcmp (name, "no-fatal-break" ) == 0) { direct_config->fatal_break = false; } else if (direct_strcmp (name, "sighandler" ) == 0) { direct_config->sighandler = true; } else if (direct_strcmp (name, "no-sighandler" ) == 0) { direct_config->sighandler = false; } else if (direct_strcmp (name, "dont-catch" ) == 0) { if (value) { char *signals = D_STRDUP( value ); char *p = NULL, *r, *s = signals; while ((r = direct_strtok_r( s, ",", &p ))) { char *error; unsigned long signum; direct_trim( &r ); signum = direct_strtoul( r, &error, 10 ); if (*error) { D_ERROR( "Direct/Config '%s': Error in number at '%s'!\n", name, error ); D_FREE( signals ); return DR_INVARG; } sigaddset( &direct_config->dont_catch, signum ); s = NULL; } D_FREE( signals ); } else { D_ERROR("Direct/Config '%s': No signals specified!\n", name); return DR_INVARG; } } else if (direct_strcmp (name, "thread_block_signals") == 0) { direct_config->thread_block_signals = true; } else if (direct_strcmp (name, "no-thread_block_signals") == 0) { direct_config->thread_block_signals = false; } else if (direct_strcmp (name, "thread-priority-scale" ) == 0) { if (value) { int scale; if (direct_sscanf( value, "%d", &scale ) < 1) { D_ERROR("Direct/Config '%s': Could not parse value!\n", name); return DR_INVARG; } direct_config->thread_priority_scale = scale; } else { D_ERROR("Direct/Config '%s': No value specified!\n", name); return DR_INVARG; } } else if (direct_strcmp (name, "thread-priority" ) == 0) { /* Must be moved to lib/direct/conf.c in trunk! */ if (value) { int priority; if (direct_sscanf( value, "%d", &priority ) < 1) { D_ERROR("Direct/Config '%s': Could not parse value!\n", name); return DR_INVARG; } direct_config->thread_priority = priority; } else { D_ERROR("Direct/Config '%s': No value specified!\n", name); return DR_INVARG; } } else if (direct_strcmp (name, "thread-scheduler" ) == 0) { /* Must be moved to lib/direct/conf.c in trunk! */ if (value) { if (direct_strcmp( value, "other" ) == 0) { direct_config->thread_scheduler = DCTS_OTHER; } else if (direct_strcmp( value, "fifo" ) == 0) { direct_config->thread_scheduler = DCTS_FIFO; } else if (direct_strcmp( value, "rr" ) == 0) { direct_config->thread_scheduler = DCTS_RR; } else { D_ERROR( "Direct/Config '%s': Unknown scheduler '%s'!\n", name, value ); return DR_INVARG; } } else { D_ERROR( "Direct/Config '%s': No value specified!\n", name ); return DR_INVARG; } } else if (direct_strcmp (name, "thread-stacksize" ) == 0) { /* Must be moved to lib/direct/conf.c in trunk! */ if (value) { int size; if (direct_sscanf( value, "%d", &size ) < 1) { D_ERROR( "Direct/Config '%s': Could not parse value!\n", name ); return DR_INVARG; } direct_config->thread_stack_size = size; } else { D_ERROR( "Direct/Config '%s': No value specified!\n", name ); return DR_INVARG; } } else return DR_UNSUPPORTED; return DR_OK; }