//----------------------------------------------------------------------------
//
//  Test:           test_tuner
//
//  Description:    Iterates through each of the known local channels,
//                  and attempts to save an image from each of them.
//
//  Setup:          - Source is TV tuner
//                  - Tunes to each local channel sequentially
//                  - Uses standard window sizing
//                  - Saves in RGB24 format
//
//----------------------------------------------------------------------------
int test_tuner( FRAMEGRABBER* fg )
{
    FRAME* frame = NULL;
    char fname[32];
    int i;

    _T( fg_set_format( fg, VIDEO_PALETTE_RGB32 ) );
    _T( fg_set_capture_window( fg, 0, 0, 320, 240 ) );
    _N( frame = fg_new_compatible_frame( fg ) );

    for ( i = 0; i < sizeof(local)/sizeof(CHANNEL); i++ )
    {
        printf( "%u. Saving %s @ %fMHz\n", i, local[i].name, local[i].freq );

        _T( fg_set_channel( fg, local[i].freq ) );

        // Catch up to the new tuning
        _N( fg_grab_frame( fg, frame ) );
        _N( fg_grab_frame( fg, frame ) );

        snprintf( fname, sizeof(fname), "test_%s.ppm", local[i].name );

        _T( frame_save( frame, fname ) );
    }
    frame_release( frame );

    return 0;
}
//----------------------------------------------------------------------------
//
//  Test:           test_simple_grab
//
//  Description:    Grabs a single frame and saves it to a file.
//
//  Setup:          - Source is TV tuner
//                  - Uses standard window sizing
//                  - Tunes to first local channel
//
//----------------------------------------------------------------------------
int test_simple_grab( FRAMEGRABBER* fg )
{
    FRAME* frame = NULL;

    _T( fg_set_source( fg, FG_SOURCE_TV ) );

    _T( fg_set_capture_window( fg, 0, 0,
                               fg->caps.maxwidth,
                               fg->caps.maxheight ) );

    _T( fg_set_channel( fg, local[0].freq ) );

    _T( fg_set_brightness( fg, 75 ) );

    _T( fg_set_colour( fg, 80 ) );

    _N( frame = fg_grab( fg ) );

    printf( "Saving test frame...\n" );

    _T( frame_save( frame, "test_frame.ppm" ) );

    frame_release( frame );

    return 0;
}
Beispiel #3
0
static inline void __page_unmap(vaddr_t vaddr)
{
    if (vaddr & PAGE_MASK)
        return;

    __virtaddr_t virtaddr = {.raw = vaddr};
    size_t pml4      = virtaddr.pml4;
    size_t dirtbl    = virtaddr.dirtbl;
    size_t directory = virtaddr.directory;
    size_t table     = virtaddr.table;

    if (LVL4[pml4].present &&
        LVL3(pml4)[dirtbl].present &&
        LVL2(pml4, dirtbl)[directory].present) {

        /* Dereference page */
        LVL1(pml4, dirtbl, directory)[table].raw = 0;

#if 0
        /* Decrement references */
        paddr_t table_phy = GET_PHYS_ADDR(&LVL2(pml4, dirtbl)[directory]);
        pages[table_phy/PAGE_SIZE].refs--;
        if (!pages[table_phy/PAGE_SIZE].refs) {
            frame_release(table_phy);
            LVL2(pml4, dirtbl)[directory].present = 0;
        }

        paddr_t directory_phy = GET_PHYS_ADDR(&LVL3(pml4)[dirtbl]);
        pages[directory_phy/PAGE_SIZE].refs--;
        if (!pages[directory_phy/PAGE_SIZE].refs) {
            frame_release(directory_phy);
            LVL3(pml4)[dirtbl].present = 0;
        }

        paddr_t dirtbl_phy = GET_PHYS_ADDR(&LVL4[pml4]);
        pages[directory_phy/PAGE_SIZE].refs--;
        if (!pages[directory_phy/PAGE_SIZE].refs) {
            frame_release(directory_phy);
            LVL4[pml4].present = 0;
        }
#endif

        tlb_invalidate_page(vaddr);
    }
}
//----------------------------------------------------------------------------
//
//  Test:           test_formats
//
//  Description:    Iterates through each of the supported frame formats,
//                  and attempts to save an image in each of them.
//
//  Setup:          - Source is default
//                  - Channel tuning is default 
//                  - Window sizing is default
//
//----------------------------------------------------------------------------
int test_formats( FRAMEGRABBER* fg )
{
    FRAME* frame = NULL;
    char fname[32];
    int i;

    for ( i = 0; i < sizeof(fmts)/sizeof(FMT); i++ )
    {
        printf( "Saving in %s...\n", fmts[i].name );

        _T( fg_set_format( fg, fmts[i].format ) );
        _N( frame = fg_grab( fg ) );

        snprintf( fname, sizeof(fname), "test_%s.ppm", fmts[i].name );

        _T( frame_save( frame, fname ) );
        frame_release( frame );
    }

    return 0;
}