From 7fe60435bce6595a9c58a9bfd8244d74b5320e96 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Tue, 15 Jan 2013 08:46:13 +0100 Subject: Import DirectFB141_2k11R3_beta5 --- Source/DirectFB/tools/dfbinfo.c | 605 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 605 insertions(+) create mode 100755 Source/DirectFB/tools/dfbinfo.c (limited to 'Source/DirectFB/tools/dfbinfo.c') diff --git a/Source/DirectFB/tools/dfbinfo.c b/Source/DirectFB/tools/dfbinfo.c new file mode 100755 index 0000000..7cc1591 --- /dev/null +++ b/Source/DirectFB/tools/dfbinfo.c @@ -0,0 +1,605 @@ +/* + (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org) + (c) Copyright 2000-2004 Convergence (integrated media) GmbH + + All rights reserved. + + Written by Denis Oliver Kropp , + Andreas Hundt , + Sven Neumann , + Ville Syrjälä and + Claudio Ciccani . + + This file is subject to the terms and conditions of the MIT License: + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the "Software"), to deal in the Software without restriction, + including without limitation the rights to use, copy, modify, merge, + publish, distribute, sublicense, and/or sell copies of the Software, + and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include "config.h" + +#include +#include +#include + +#include +#include + +static const DirectFBInputDeviceTypeFlagsNames(input_types); +static const DirectFBInputDeviceCapabilitiesNames(input_caps); + +static const DirectFBDisplayLayerTypeFlagsNames(layer_types); +static const DirectFBDisplayLayerCapabilitiesNames(layer_caps); + +static const DirectFBScreenCapabilitiesNames(screen_caps); +static const DirectFBScreenEncoderCapabilitiesNames(encoder_caps); +static const DirectFBScreenEncoderTypeNames(encoder_type); +static const DirectFBScreenEncoderTVStandardsNames(tv_standards); +static const DirectFBScreenOutputCapabilitiesNames(output_caps); +static const DirectFBScreenOutputConnectorsNames(connectors); +static const DirectFBScreenOutputResolutionNames(resolutions); +static const DirectFBScreenOutputSignalsNames(signals); +static const DirectFBScreenMixerCapabilitiesNames(mixer_caps); + +/*****************************************************************************/ + +static IDirectFB *dfb = NULL; + +/*****************************************************************************/ + +static DFBBoolean parse_command_line ( int argc, char *argv[] ); +static void enum_input_devices ( void ); +static void enum_screens ( void ); + +/*****************************************************************************/ + +int +main( int argc, char *argv[] ) +{ + DFBResult ret; + + /* Initialize DirectFB including command line parsing. */ + ret = DirectFBInit( &argc, &argv ); + if (ret) { + DirectFBError( "DirectFBInit() failed", ret ); + return -1; + } + + /* Parse the command line. */ + if (!parse_command_line( argc, argv )) + return -2; + + DirectFBSetOption( "bg-none", NULL ); + DirectFBSetOption( "no-cursor", NULL ); + + /* Create the super interface. */ + ret = DirectFBCreate( &dfb ); + if (ret) { + DirectFBError( "DirectFBCreate() failed", ret ); + return -3; + } + + printf( "\n" ); + + enum_screens(); + + while (1) { + printf("\n\n\n\n\n"); + enum_input_devices(); + sleep(10); + } + + /* Release the super interface. */ + dfb->Release( dfb ); + + return EXIT_SUCCESS; +} + +/*****************************************************************************/ + +static DFBBoolean +parse_command_line( int argc, char *argv[] ) +{ + return DFB_TRUE; +} + +/*****************************************************************************/ + +static DFBEnumerationResult +input_device_callback( DFBInputDeviceID id, + DFBInputDeviceDescription desc, + void *arg ) +{ + int i; + + /* Name */ + printf( "Input (%02x) %-30s", id, desc.name ); + + switch (id) { + case DIDID_JOYSTICK: + printf( " (primary joystick)" ); + break; + case DIDID_KEYBOARD: + printf( " (primary keyboard)" ); + break; + case DIDID_MOUSE: + printf( " (primary mouse)" ); + break; + case DIDID_REMOTE: + printf( " (primary remote control)" ); + break; + default: + break; + } + + printf( "\n" ); + + /* Type */ + printf( " Type: " ); + + for (i=0; input_types[i].type; i++) { + if (desc.type & input_types[i].type) + printf( "%s ", input_types[i].name ); + } + + printf( "\n" ); + + /* Caps */ + printf( " Caps: " ); + + for (i=0; input_caps[i].capability; i++) { + if (desc.caps & input_caps[i].capability) + printf( "%s ", input_caps[i].name ); + } + + printf( "\n" ); + + + /* Details */ + if (desc.caps & DICAPS_KEYS) + printf( " Min. Keycode: %d\n", desc.min_keycode ); + if (desc.caps & DICAPS_KEYS) + printf( " Max. Keycode: %d\n", desc.max_keycode ); + if (desc.caps & DICAPS_AXES) + printf( " Max. Axis: %d\n", desc.max_axis ); + if (desc.caps & DICAPS_BUTTONS) + printf( " Max. Button: %d\n", desc.max_button ); + + + DFBResult ret; + IDirectFBInputDevice *device; + + ret = dfb->GetInputDevice( dfb, id, &device ); + if (ret == DFB_OK) { + DFBInputDeviceState state; + + ret = device->GetState( device, &state ); + if (ret) + D_DERROR( ret, "DFBInfo: IDirectFBInputDevice::GetState() failed!\n" ); + else { + if (state.flags & DISTATE_DISCONNECTED) + printf( " - DISCONNECTED -\n" ); + } + + device->Release( device ); + } + + + printf( "\n" ); + + return DFB_OK; +} + +static void +enum_input_devices( void ) +{ + DFBResult ret; + + printf( "\n" ); + + ret = dfb->EnumInputDevices( dfb, input_device_callback, NULL ); + if (ret) + DirectFBError( "IDirectFB::EnumInputDevices", ret ); +} + +/*****************************************************************************/ + +static DFBEnumerationResult +display_layer_callback( DFBDisplayLayerID id, + DFBDisplayLayerDescription desc, + void *arg ) +{ + int i; + + /* Name */ + printf( " Layer (%02x) %-30s", id, desc.name ); + + switch (id) { + case DLID_PRIMARY: + printf( " (primary layer)" ); + break; + default: + break; + } + + printf( "\n" ); + + + /* Type */ + printf( " Type: " ); + + for (i=0; layer_types[i].type; i++) { + if (desc.type & layer_types[i].type) + printf( "%s ", layer_types[i].name ); + } + + printf( "\n" ); + + + /* Caps */ + printf( " Caps: " ); + + for (i=0; layer_caps[i].capability; i++) { + if (desc.caps & layer_caps[i].capability) + printf( "%s ", layer_caps[i].name ); + } + + printf( "\n" ); + + + /* Sources */ + if (desc.caps & DLCAPS_SOURCES) { + DFBResult ret; + IDirectFBDisplayLayer *layer; + DFBDisplayLayerSourceDescription descs[desc.sources]; + + ret = dfb->GetDisplayLayer( dfb, id, &layer ); + if (ret) { + DirectFBError( "DirectFB::GetDisplayLayer() failed", ret ); + } + else { + ret = layer->GetSourceDescriptions( layer, descs ); + if (ret) { + DirectFBError( "DirectFBDisplayLayer::GetSourceDescriptions() failed", ret ); + } + else { + printf( " Sources: " ); + + for (i=0; i 0) + printf( ", %s", descs[i].name ); + else + printf( "%s", descs[i].name ); + } + + printf( "\n" ); + } + + layer->Release( layer ); + } + } + + + printf( "\n" ); + + return DFB_OK; +} + +static void +enum_display_layers( IDirectFBScreen *screen ) +{ + DFBResult ret; + + ret = screen->EnumDisplayLayers( screen, display_layer_callback, NULL ); + if (ret) + DirectFBError( "IDirectFBScreen::EnumDisplayLayers", ret ); +} + +/*****************************************************************************/ + +static void +dump_mixers( IDirectFBScreen *screen, + int num ) +{ + int i, n; + DFBResult ret; + DFBScreenMixerDescription descs[num]; + + ret = screen->GetMixerDescriptions( screen, descs ); + if (ret) { + DirectFBError( "IDirectFBScreen::GetMixerDescriptions", ret ); + return; + } + + for (i=0; iGetEncoderDescriptions( screen, descs ); + if (ret) { + DirectFBError( "IDirectFBScreen::GetEncoderDescriptions", ret ); + return; + } + + for (i=0; iGetOutputDescriptions( screen, descs ); + if (ret) { + DirectFBError( "IDirectFBScreen::GetOutputDescriptions", ret ); + return; + } + + for (i=0; iGetScreen( dfb, id, &screen ); + if (ret) + DirectFBErrorFatal( "IDirectFB::GetScreen", ret ); + + /* Name */ + printf( "Screen (%02x) %-30s", id, desc.name ); + + switch (id) { + case DSCID_PRIMARY: + printf( " (primary screen)" ); + break; + default: + break; + } + + printf( "\n" ); + + /* Caps */ + printf( " Caps: " ); + + for (i=0; screen_caps[i].capability; i++) { + if (desc.caps & screen_caps[i].capability) + printf( "%s ", screen_caps[i].name ); + } + + printf( "\n\n" ); + + + /* Mixers */ + if (desc.mixers) + dump_mixers( screen, desc.mixers ); + + /* Encoders */ + if (desc.encoders) + dump_encoders( screen, desc.encoders ); + + /* Outputs */ + if (desc.outputs) + dump_outputs( screen, desc.outputs ); + + /* Display layers */ + enum_display_layers( screen ); + + screen->Release( screen ); + + return DFB_OK; +} + +static void +enum_screens( void ) +{ + DFBResult ret; + + printf( "\n" ); + + ret = dfb->EnumScreens( dfb, screen_callback, NULL ); + if (ret) + DirectFBError( "IDirectFB::EnumScreens", ret ); +} + -- cgit