Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 14 Mar 2000 23:01:08 -0500
From:      Randall Hopper <aa8vb@ipass.net>
To:        Steve Reid <sreid@sea-to-sky.net>
Cc:        freebsd-multimedia@FreeBSD.ORG
Subject:   Re: fxtv newbie questions
Message-ID:  <20000314230108.A4692@ipass.net>
In-Reply-To: <20000311000826.A2673@grok.localnet>; from sreid@sea-to-sky.net on Sat, Mar 11, 2000 at 12:08:26AM -0800
References:  <20000311000826.A2673@grok.localnet>

next in thread | previous in thread | raw e-mail | index | archive | help

--IS0zKkzwUGydFO0o
Content-Type: text/plain; charset=us-ascii

Steve Reid:
 |I just purchased a Hauppauge WinTV (Bt878) and have Fxtv working "alright".
 |I have a few questions/annoyances though...
 |
 |When I press the "full screen" button on the remote the image goes
 |full-screen like it should. But when I press the button a second time
 |the screen goes black.

Sounds like a bug in the X server for your card.
To remove fxtv from the loop, try the attached program.  

1. run "xsetvmode -q" to display your current resolution.
2. run "xsetvmode 640 480" to switch to 640x480
3. run "xsetvmode # #" to switch back to your original resolution (plug
   in the numbers you saw from xsetvmode -q originally)

Did you see a black screen after step #3?  

If so, upgrade to the latest released version of XFree86.  If you
already have, report this to the XFree86 team (see www.xfree86.org 
for the web bug report form.

 |Is there any way to bind a remote button to flip back and forth between
 |two channels like most regular TV remotes have? This seems like such a
 |basic thing but I can't find any way to do it.

There's currently no "last channel viewed" feature.

 |This device should be able to play cable radio... Can it be done with
 |Fxtv or is there some other program I should be using?

See xmradio in the ports collection.  Also:

     http://www.egd.igd.fhg.de/~runge/xmradio.html

 |What do you folks do to stop xscreensaver from kicking in while you're
 |watching TV? I guess a script to kill the xscreensaver server, run fxtv,
 |then restart the xscreensaver server would work but I'm wondering if
 |there's a better way.

There may be a way for an X app to disable the screen saver, but I'm
not familiar with it.  Anyone?

Randall

--IS0zKkzwUGydFO0o
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="xsetvmode.c"

/*
 * xsetvmode.c
 *
 * Simple utility to change video modes under XFree86.  The version of XFree86
 *   being run must support the vidmode extension.  Also note that only
 *   the video mode will be changed.  The desktop size will remain the
 *   same.
 *
 * COMPILE USING:
 *     cc -o xsetvmode xsetvmode.c -I/usr/X11R6/include -L/usr/X11R6/lib \
 *     -lX11 -lXext -lXxf86vm
 *
 * (C) 1999 Randall Hopper
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met: 1. Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer. 2.
 * Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 */

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/extensions/xf86vmode.h>

/*  Older XFree86 versions need this with some cards  */
/*#define VMODE_SWITCHTOMODE_API_IS_BUSTED ...Unfortunately*/

#define ERRPRINT(str) fprintf( stderr, str )

/**@BEGINFUNC**************************************************************

    Prototype  : static INT32 SGetCurVidMode(
                      Display              *display,
                      int                   screen,
                      XF86VidModeModeInfo **vm_list,
                      int                   vm_list_len )

    Purpose    : Returns the index of the current video mode in the 
                 vm_list video mode list.

                 NOTE:  Assumes the vidmode extension is supported.

    Programmer : 13-Apr-97  Randall Hopper

    Parameters : display     - I: X display to query
                 screen      - I: screen on X display to query
                 vm_list     - I: list of video mode structs
                 vm_list_len - I: length of vm_list

    Returns    : index of current mode in list

    Globals    : None.

 **@ENDFUNC*****************************************************************/

static INT32 SGetCurVidMode( Display              *display,
                             int                   screen,
                             XF86VidModeModeInfo **vm_list,
                             int                   vm_list_len )
{
    int                  dot_clock,
                         vm;
    XF86VidModeModeLine  vm_info;

    if ( !XF86VidModeGetModeLine( display, screen, &dot_clock, &vm_info ) ) {
        ERRPRINT( "XF86VidModeGetModeLine() failed\n" );
        exit(1);
    }

    for ( vm = 0; vm < vm_list_len; vm++ )
        if (( vm_info.hdisplay   == vm_list[vm]->hdisplay   ) &&
            ( vm_info.hsyncstart == vm_list[vm]->hsyncstart ) &&
            ( vm_info.hsyncend   == vm_list[vm]->hsyncend   ) &&
            ( vm_info.htotal     == vm_list[vm]->htotal     ) &&
            ( vm_info.vdisplay   == vm_list[vm]->vdisplay   ) &&
            ( vm_info.vsyncstart == vm_list[vm]->vsyncstart ) &&
            ( vm_info.vsyncend   == vm_list[vm]->vsyncend   ) &&
            ( vm_info.vtotal     == vm_list[vm]->vtotal     ))
            break;

    if ( vm >= vm_list_len ) {
        ERRPRINT( "SGetCurVidMode: Couldn't find cur mode in list\n" );
        exit(1);
    }

    return vm;
}

          
int main( int argc, char *argv[] )
{
    Display              *display;
    int                   screen,
                          vmode_majv,
                          vmode_minv,
                          vm_list_len,
                          vm_startup;
    XF86VidModeModeInfo **vm_list;

    /*  Connect to the default XServer ($DISPLAY)  */
    if ( (display = XOpenDisplay( NULL )) == NULL ) {
        ERRPRINT( "Can't open X display\n" );
        exit(1);
    }
    screen = DefaultScreen( display );

    /*  First determine if the vidmode extension is supported on this server */
    if ( !XF86VidModeQueryVersion( display, &vmode_majv, &vmode_minv ) ) {
        ERRPRINT( "XF86VidModeQueryVersion() failed\n" );
        exit(1);
    }
    
    /*  Get a list of all video modes supported by the server  */
    if ( !XF86VidModeGetAllModeLines( display, screen, &vm_list_len, 
                                      &vm_list ) ) {
        ERRPRINT( "XF86VidModeGetAllModeLines() failed\n" );
        exit(1);
    }
        
    /*  Get the current video mode  */
    vm_startup = SGetCurVidMode( display, screen, vm_list, vm_list_len );

    /*  Now, deal with user request.  */

    /*  If user just wanted to know res of current mode, print it  */
    if (( argc == 2 ) && ( strcmp( argv[1], "-q" ) == 0 ))
        printf( "%d %d\n", vm_list[ vm_startup ]->hdisplay,
                           vm_list[ vm_startup ]->vdisplay );

    /*  If user just wanted to see all available modes, print it  */
    else if (( argc == 2 ) && ( strcmp( argv[1], "-v" ) == 0 )) {
        int i;
        for ( i = 0; i < vm_list_len; i++ )
	    printf( "%4d %4d\n", vm_list[i]->hdisplay, vm_list[i]->vdisplay);
    }

    /*  Or if user wanted to change res to that specified, try to do that  */
    else if (( argc == 3 ) && 
             ( strspn( argv[1], "0123456789" ) == strlen( argv[1] ) ) &&
             ( strspn( argv[2], "0123456789" ) == strlen( argv[2] ) )) {
        int xres = atoi( argv[1] ),
            yres = atoi( argv[2] ),
            i;

        for ( i = 0; i < vm_list_len; i++ )
            if (( xres == vm_list[i]->hdisplay ) &&
                ( yres == vm_list[i]->vdisplay ))
                break;

        if ( i >= vm_list_len ) {
            fprintf( stderr, "Resolution %dx%d not supported by XServer\n",
                     xres, yres );
            exit(1);
        }

#ifdef VMODE_SWITCHTOMODE_API_IS_BUSTED
        {
            int j;

            for ( j = vm_startup; j != i; j += (i-vm_startup>0) ? 1 : -1 ) 
            if ( !XF86VidModeSwitchMode( display, screen, 
                                         (i-j) > 0 ? 1 : 0 ) ) {
                ERRPRINT( "XF86VidModeSwitchMode() failed\n" );
                exit(1);
            }
        }
#else
        if ( !XF86VidModeSwitchToMode( display, screen, vm_list[i] ) ) {
            ERRPRINT( "XF86VidModeSwitchToMode() failed\n" );
            exit(1);
        }
#endif
        XSync( display, False );
    }
    
    /*  Bad options.  Print help  */
    else {
        char *p = strrchr( argv[0], '/' );

        if ( p == NULL )
            p = argv[0];

        printf( "%s  --  XFree86 Video Mode Query/Switch Utility\n\n"
                "\tParameters: [ -q | -v | <xres> <yres> ]\n\n"
                "\tUse '%s -q' to query the current video mode\n"
                "\tUse '%s -v' to show all available video modes\n"
                "\tUse '%s <xres> <yres>' to switch to a video mode\n",
                p,p,p,p );
        exit(1);
    }

    XCloseDisplay( display );

    return 0;
}

--IS0zKkzwUGydFO0o
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=Makefile

all : xsetvmode

CFLAGS  = -Wall -I/usr/X11R6/include
LDFLAGS = -L/usr/X11R6/lib

xsetvmode : xsetvmode.c
	$(CC) $(CFLAGS) $(LDFLAGS) -o xsetvmode xsetvmode.c -lX11 -lXext -lXxf86vm

--IS0zKkzwUGydFO0o--


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-multimedia" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000314230108.A4692>