Exemplo n.º 1
0
static int info_cmd(int argc, char *argv[])
{
    image_t *image;
    uint64_t image_offset;
    uint64_t image_size = 0;
    fip_toc_header_t toc_header;
    int i;

    if (argc != 2)
        info_usage();
    argc--, argv++;

    parse_fip(argv[0], &toc_header);

    if (verbose) {
        log_dbgx("toc_header[name]: 0x%llX",
                 (unsigned long long)toc_header.name);
        log_dbgx("toc_header[serial_number]: 0x%llX",
                 (unsigned long long)toc_header.serial_number);
        log_dbgx("toc_header[flags]: 0x%llX",
                 (unsigned long long)toc_header.flags);
    }

    image_offset = sizeof(fip_toc_header_t) +
                   (sizeof(fip_toc_entry_t) * (nr_images + 1));

    for (i = 0; i < nr_images; i++) {
        toc_entry_t *toc_entry;

        image = images[i];
        toc_entry = lookup_entry_from_uuid(&image->uuid);
        if (toc_entry != NULL)
            printf("%s: ", toc_entry->name);
        else
            printf("Unknown entry: ");
        image_size = image->size;
        printf("offset=0x%llX, size=0x%llX",
               (unsigned long long)image_offset,
               (unsigned long long)image_size);
        if (toc_entry != NULL)
            printf(", cmdline=\"--%s\"",
                   toc_entry->cmdline_name);
        if (verbose) {
            unsigned char md[SHA256_DIGEST_LENGTH];

            SHA256(image->buffer, image_size, md);
            printf(", sha256=");
            md_print(md, sizeof(md));
        }
        putchar('\n');
        image_offset += image_size;
    }

    free_images();
    return 0;
}
Exemplo n.º 2
0
static int create_cmd(int argc, char *argv[])
{
    struct option opts[toc_entries_len + 1];
    unsigned long long toc_flags = 0;
    int i;

    if (argc < 2)
        usage();

    i = fill_common_opts(opts, required_argument);
    add_opt(opts, i, "plat-toc-flags", required_argument,
            OPT_PLAT_TOC_FLAGS);
    add_opt(opts, ++i, NULL, 0, 0);

    while (1) {
        int c, opt_index;

        c = getopt_long(argc, argv, "o:", opts, &opt_index);
        if (c == -1)
            break;

        switch (c) {
        case OPT_TOC_ENTRY: {
            toc_entry_t *toc_entry;

            toc_entry = &toc_entries[opt_index];
            toc_entry->action = DO_PACK;
            toc_entry->action_arg = strdup(optarg);
            if (toc_entry->action_arg == NULL)
                log_err("strdup");
            break;
        }
        case OPT_PLAT_TOC_FLAGS:
            parse_plat_toc_flags(optarg, &toc_flags);
            break;
        default:
            usage();
        }
    }
    argc -= optind;
    argv += optind;

    if (argc == 0)
        usage();

    update_fip();

    pack_images(argv[0], toc_flags);
    free_images();
    return 0;
}
Exemplo n.º 3
0
static int info_cmd(int argc, char *argv[])
{
    image_t *image;
    uint64_t image_offset;
    uint64_t image_size = 0;
    fip_toc_header_t toc_header;
    int i;

    if (argc != 2)
        usage();
    argc--, argv++;

    parse_fip(argv[0], &toc_header);

    if (verbose) {
        log_dbgx("toc_header[name]: 0x%llX",
                 (unsigned long long)toc_header.name);
        log_dbgx("toc_header[serial_number]: 0x%llX",
                 (unsigned long long)toc_header.serial_number);
        log_dbgx("toc_header[flags]: 0x%llX",
                 (unsigned long long)toc_header.flags);
    }

    image_offset = sizeof(fip_toc_header_t) +
                   (sizeof(fip_toc_entry_t) * (nr_images + 1));

    for (i = 0; i < nr_images; i++) {
        image = images[i];
        if (image->toc_entry != NULL)
            printf("%s: ", image->toc_entry->name);
        else
            printf("Unknown entry: ");
        image_size = image->size;
        printf("offset=0x%llX, size=0x%llX",
               (unsigned long long)image_offset,
               (unsigned long long)image_size);
        if (image->toc_entry != NULL)
            printf(", cmdline=\"--%s\"\n",
                   image->toc_entry->cmdline_name);
        else
            putchar('\n');
        image_offset += image_size;
    }

    free_images();
    return 0;
}
Exemplo n.º 4
0
static int remove_cmd(int argc, char *argv[])
{
    struct option opts[toc_entries_len + 2];
    char outfile[FILENAME_MAX] = { 0 };
    fip_toc_header_t toc_header;
    toc_entry_t *toc_entry;
    int fflag = 0;
    int i;

    if (argc < 2)
        usage();

    i = fill_common_opts(opts, no_argument);
    add_opt(opts, i, "force", no_argument, 'f');
    add_opt(opts, ++i, "out", required_argument, 'o');
    add_opt(opts, ++i, NULL, 0, 0);

    while (1) {
        int c, opt_index;

        c = getopt_long(argc, argv, "fo:", opts, &opt_index);
        if (c == -1)
            break;

        switch (c) {
        case OPT_TOC_ENTRY:
            toc_entry = &toc_entries[opt_index];
            toc_entry->action = DO_REMOVE;
            break;
        case 'f':
            fflag = 1;
            break;
        case 'o':
            snprintf(outfile, sizeof(outfile), "%s", optarg);
            break;
        default:
            usage();
        }
    }
    argc -= optind;
    argv += optind;

    if (argc == 0)
        usage();

    if (outfile[0] != '\0' && access(outfile, F_OK) == 0 && !fflag)
        log_errx("File %s already exists, use --force to overwrite it",
                 outfile);

    if (outfile[0] == '\0')
        snprintf(outfile, sizeof(outfile), "%s", argv[0]);

    parse_fip(argv[0], &toc_header);

    for (toc_entry = toc_entries;
            toc_entry->cmdline_name != NULL;
            toc_entry++) {
        if (toc_entry->action != DO_REMOVE)
            continue;
        if (toc_entry->image != NULL) {
            if (verbose)
                log_dbgx("Removing %s.bin",
                         toc_entry->cmdline_name);
            remove_image(toc_entry->image);
        } else {
            log_warnx("Requested image %s.bin is not in %s",
                      toc_entry->cmdline_name, argv[0]);
        }
    }

    pack_images(outfile, toc_header.flags);
    free_images();
    return 0;
}
Exemplo n.º 5
0
static int unpack_cmd(int argc, char *argv[])
{
    struct option opts[toc_entries_len + 3];
    char file[FILENAME_MAX], outdir[PATH_MAX] = { 0 };
    toc_entry_t *toc_entry;
    int fflag = 0;
    int unpack_all = 1;
    int i;

    if (argc < 2)
        usage();

    i = fill_common_opts(opts, required_argument);
    add_opt(opts, i, "force", no_argument, 'f');
    add_opt(opts, ++i, "out", required_argument, 'o');
    add_opt(opts, ++i, NULL, 0, 0);

    while (1) {
        int c, opt_index;

        c = getopt_long(argc, argv, "fo:", opts, &opt_index);
        if (c == -1)
            break;

        switch (c) {
        case OPT_TOC_ENTRY:
            unpack_all = 0;
            toc_entry = &toc_entries[opt_index];
            toc_entry->action = DO_UNPACK;
            toc_entry->action_arg = strdup(optarg);
            if (toc_entry->action_arg == NULL)
                log_err("strdup");
            break;
        case 'f':
            fflag = 1;
            break;
        case 'o':
            snprintf(outdir, sizeof(outdir), "%s", optarg);
            break;
        default:
            usage();
        }
    }
    argc -= optind;
    argv += optind;

    if (argc == 0)
        usage();

    parse_fip(argv[0], NULL);

    if (outdir[0] != '\0')
        if (chdir(outdir) == -1)
            log_err("chdir %s", outdir);

    /* Mark all images to be unpacked. */
    if (unpack_all) {
        for (toc_entry = toc_entries;
                toc_entry->cmdline_name != NULL;
                toc_entry++) {
            if (toc_entry->image != NULL) {
                toc_entry->action = DO_UNPACK;
                toc_entry->action_arg = NULL;
            }
        }
    }

    /* Unpack all specified images. */
    for (toc_entry = toc_entries;
            toc_entry->cmdline_name != NULL;
            toc_entry++) {
        if (toc_entry->action != DO_UNPACK)
            continue;

        /* Build filename. */
        if (toc_entry->action_arg == NULL)
            snprintf(file, sizeof(file), "%s.bin",
                     toc_entry->cmdline_name);
        else
            snprintf(file, sizeof(file), "%s",
                     toc_entry->action_arg);

        if (toc_entry->image == NULL) {
            log_warnx("Requested image %s is not in %s",
                      file, argv[0]);
            free(toc_entry->action_arg);
            toc_entry->action_arg = NULL;
            continue;
        }

        if (access(file, F_OK) != 0 || fflag) {
            if (verbose)
                log_dbgx("Unpacking %s", file);
            write_image_to_file(toc_entry->image, file);
        } else {
            log_warnx("File %s already exists, use --force to overwrite it",
                      file);
        }

        free(toc_entry->action_arg);
        toc_entry->action_arg = NULL;
    }

    free_images();
    return 0;
}
Exemplo n.º 6
0
static int update_cmd(int argc, char *argv[])
{
    struct option opts[toc_entries_len + 2];
    char outfile[FILENAME_MAX] = { 0 };
    fip_toc_header_t toc_header = { 0 };
    unsigned long long toc_flags = 0;
    int pflag = 0;
    int i;

    if (argc < 2)
        usage();

    i = fill_common_opts(opts, required_argument);
    add_opt(opts, i, "out", required_argument, 'o');
    add_opt(opts, ++i, "plat-toc-flags", required_argument,
            OPT_PLAT_TOC_FLAGS);
    add_opt(opts, ++i, NULL, 0, 0);

    while (1) {
        int c, opt_index;

        c = getopt_long(argc, argv, "o:", opts, &opt_index);
        if (c == -1)
            break;

        switch (c) {
        case OPT_TOC_ENTRY: {
            toc_entry_t *toc_entry;

            toc_entry = &toc_entries[opt_index];
            toc_entry->action = DO_PACK;
            toc_entry->action_arg = strdup(optarg);
            if (toc_entry->action_arg == NULL)
                log_err("strdup");
            break;
        }
        case OPT_PLAT_TOC_FLAGS: {
            parse_plat_toc_flags(optarg, &toc_flags);
            pflag = 1;
            break;
        }
        case 'o':
            snprintf(outfile, sizeof(outfile), "%s", optarg);
            break;
        default:
            usage();
        }
    }
    argc -= optind;
    argv += optind;

    if (argc == 0)
        usage();

    if (outfile[0] == '\0')
        snprintf(outfile, sizeof(outfile), "%s", argv[0]);

    if (access(outfile, F_OK) == 0)
        parse_fip(argv[0], &toc_header);

    if (pflag)
        toc_header.flags &= ~(0xffffULL << 32);
    toc_flags = (toc_header.flags |= toc_flags);

    update_fip();

    pack_images(outfile, toc_flags);
    free_images();
    return 0;
}
Exemplo n.º 7
0
int main ( int argc, char** argv )
{
/// initialisation son & image
    /// initialisation FMOD
    FMOD_SYSTEM * system;
    FMOD_System_Create(&system);
    /// initialisation image & son
    initialisation(system);

/// verification de la date
    struct tm Today;
	time_t maintenant;

	time(&maintenant);
	Today = *localtime(&maintenant);

	Today.tm_year += 1900;
	Today.tm_mon += 1;
	Today.tm_mday;

/// username
    DWORD StrLen = 256;
    TCHAR SysInfoStr[256];
    GetComputerName(SysInfoStr, &StrLen);
    std::string nameComputeur = SysInfoStr;
    GetUserName(SysInfoStr, &StrLen);
    std::string nameUser = SysInfoStr;


/// déclaration et chargements des ressources
    /// create a new window
    putenv("SDL_VIDEO_WINDOW_POS=center"); /// pour centrer la fenêtre
    SDL_Surface* screen = SDL_SetVideoMode(LARGEUR_ECRAN, HAUTEUR_ECRAN, 32, SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_RESIZABLE|SDL_FULLSCREEN);
    if ( !screen )
    {
        printf("Unable to set 640x480 video: %s\n", SDL_GetError());
        return 1;
    }
    /// images
    SDL_Surface** images = NULL;
    images = (SDL_Surface **) malloc (sizeof(SDL_Surface*)*NOMBRE_IMAGE);
    load_images(images);
    /// sons
    FMOD_SOUND ** musiques = NULL;
    musiques = (FMOD_SOUND **) malloc (sizeof(FMOD_SOUND*)*NOMBRE_MUSIQUE);
    load_musiques(system, musiques);
    /// polices
    TTF_Font ** polices = NULL;
    polices = (TTF_Font **) malloc(sizeof(TTF_Font*) * NOMBRE_POLICE);
    load_polices(polices);


/// Icone
    SDL_WM_SetIcon(images[0], NULL);

/// titre
    SDL_WM_SetCaption("Julie", NULL);

/// program main loop
    Input * in = new Input;
    int tempsPrecedent = 0, tempsActuel = 0;

    int ghost = 255;
    bool devient_ghost = true;

    int * menu = new int;
    *menu = -1;

    SDL_Rect place = {LARGEUR_ECRAN/2 - images[0]->w/2,HAUTEUR_ECRAN/2 - images[0]->h/2,0,0};

/// musiques
    FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, musiques[0], 0, NULL);

/// affichage du logo
    int i = 0;
    while(i<256)
    {
        SDL_FillRect(SDL_GetVideoSurface(), 0, SDL_MapRGB(SDL_GetVideoSurface()->format, 0, 0, 0));
        place = {LARGEUR_ECRAN/2 - images[0]->w/2,HAUTEUR_ECRAN/2 - images[0]->h/2,0,0};
        SDL_SetAlpha(images[0], SDL_SRCALPHA, i);
        SDL_BlitSurface(images[0], NULL, SDL_GetVideoSurface(), &place);
        i++;
        SDL_Flip(SDL_GetVideoSurface());
    }

    while(i>=0)
    {
        SDL_FillRect(SDL_GetVideoSurface(), 0, SDL_MapRGB(SDL_GetVideoSurface()->format, 0, 0, 0));
        place = {LARGEUR_ECRAN/2 - images[0]->w/2,HAUTEUR_ECRAN/2 - images[0]->h/2,0,0};
        SDL_SetAlpha(images[0], SDL_SRCALPHA, i);
        SDL_BlitSurface(images[0], NULL, SDL_GetVideoSurface(), &place);
        i--;
        SDL_Flip(SDL_GetVideoSurface());
    }


    place = {LARGEUR_ECRAN/2 - images[1]->w/2,HAUTEUR_ECRAN/2 - images[1]->h/2,0,0};


    while(!in->get_touche(SDLK_ESCAPE) && !in->get_exit())  /// boucle principale
    {
        /// mise à jour des events
        in->update();

        /// gestion du frame
        fps(&tempsPrecedent, &tempsActuel, SCREEN_REFRESH);

        /// resize taille écran
        resize_screen(*in);

        if(*menu == 1 || in->get_touche(SDLK_1) || in->get_touche(SDLK_KP1)) /// jouer
        {
            in->set_touche(SDLK_1, 0);
            in->set_touche(SDLK_KP1, 0);
            Jeu * party = new Jeu(images);
            party->game();
            delete party;
            in->set_touche(SDLK_ESCAPE, 0);
        }

        if(*menu == 2 || in->get_touche(SDLK_2) || in->get_touche(SDLK_KP2)) /// jouer
        {
            in->set_touche(SDLK_2, 0);
            in->set_touche(SDLK_KP2, 0);
            Jeu * party = new Jeu(images);
            party->conjugaison();
            delete party;
            in->set_touche(SDLK_ESCAPE, 0);
        }

        if(*menu == -9) /// quitter le jeu
        {
            in->set_exit(1);
        }

        if(*menu == -1)
        {
            SDL_FillRect(SDL_GetVideoSurface(), 0, SDL_MapRGB(SDL_GetVideoSurface()->format, 0, 0, 0));
            place = {LARGEUR_ECRAN/2 - images[1]->w/2,HAUTEUR_ECRAN/2 - images[1]->h/2,0,0};
            SDL_BlitSurface(images[1], NULL, SDL_GetVideoSurface(), &place);
/*
            if(devient_ghost)
            {
                ghost -= 8;
            }
            else
            {
                ghost += 8;
            }
            if(ghost >= 255 || ghost <= 88)
            {
                devient_ghost = !devient_ghost;
            }
            place = {LARGEUR_ECRAN/2 - images[2]->w/2,3*HAUTEUR_ECRAN/4 - images[2]->h/2,0,0};
            SDL_SetAlpha(images[2], SDL_SRCALPHA, ghost);
            SDL_BlitSurface(images[2], NULL, SDL_GetVideoSurface(), &place);
*/
            Texte menu1;
            Texte menu2;
            menu1.print("1 - Mathématiques", "arial", 60, {255,255,255}, SDL_GetVideoSurface()->w/3, 3*SDL_GetVideoSurface()->h/4);
            menu2.print("2 - Conjugaison", "arial", 60, {255,255,255}, SDL_GetVideoSurface()->w/3, 3*SDL_GetVideoSurface()->h/4+100);
        }

        SDL_Flip(screen);
    }/// end main loop


/// nettoyage
    /// free pointeurs
    delete menu;
    delete in;
    /// free loaded bitmap and created surface
    SDL_FreeSurface(screen);
    free_images(images);
    free_polices(polices);
    /// libération des sons
    free_musiques(musiques);
    /// fermeture propre de ce qui est ouvert dans initialisation()
    fermeture(system);


/// all is well ;)
    printf("Exited cleanly\n");
    return 0;
}
Exemplo n.º 8
0
int main(int argc, char *argv[])
{
	int i, iRet = 0;
	struct pwcmech * pwcmech;

	//
	// Signal Handling
	//
	sigset_t block_no_signals;
	sigemptyset(&block_no_signals);


	struct sigaction pwc_sig_handler;
	struct sigaction standard_sig_handler;
	struct sigaction video_io_sig_handler;

	pwc_sig_handler.sa_flags = 0;
	pwc_sig_handler.sa_handler = &sig_handler;

	sigaction(SIGINT, &pwc_sig_handler, &standard_sig_handler);
	sigaction(SIGTERM, &pwc_sig_handler, &standard_sig_handler);

	video_io_sig_handler.sa_flags = 0;
	video_io_sig_handler.sa_handler = &ioctl_callback;
	sigaction(SIGIO, &video_io_sig_handler, &standard_sig_handler);


	//
	// Userspace Driver Interfaces
	//
	struct devClass * video_dev;
	struct images * p_img;


	//
	// Buffering Initialization
	//
	printf("Allocating buffers...");
	frames = alloc_buffers();
	if ( frames == NULL )
	{
		printf("failed?!\n");
		goto finish;
	}
	init_data_buffer(frames);
	printf("done!\n");


	//
	// Device Initialization
	//
	printf("Create camera device...");
	pwcmech = pwc_devmech_start();
	if ( pwcmech_register_driver(pwcmech) )
	{
		printf("failed?!\n");
		goto release_buffers;
	}
	printf("done!\n");

	printf("Initialize camera device...");
	if ( pwcmech_register_handler(pwcmech) )
	{
		perror("Failed opening camera device");
		printf("failed?!\n");
		goto stop_usb;
	}
	printf("done!\n");

	printf("Set camera's video mode...");
	//if_claim should work seamslessly somehow
	iRet = usb_if_claim(pwcmech->com, pwcmech->com->standard_descriptors.highspeed.cameraStream.cameraStreamConf);
	if ( iRet )
	{
		perror("Failed setting camera's video mode");
		printf("failed?!\n");
		goto close_camera;
	}
	iRet = setVideoMode(pwcmech, 9);	//still old way, pre-setting instead of from V4L
	if ( iRet )
	{
		perror("Failed setting camera's video mode");
		printf("failed?!\n");
		goto close_camera;
	}
	set_ctrl0_timeout(pwcmech->com, 1000);
	setLeds(pwcmech, 0,0);	//don't bother with the light
	iRet = sendVideoCommand(pwcmech, video_mode_string, VIDEO_MODE_STRING_LEN);
	if ( iRet )
	{
		perror("Failed setting camera's video mode");
		printf("failed?!\n");
		goto close_camera;
	}
	printf("done!\n");


	//
	// Decompression
	//
	printf("Initializing decompression system...");
	p_img = alloc_images();
	if ( p_img == NULL )
	{
		printf("failed?!\n");
		goto close_camera;
	}
	if ( ( iRet = init_images(p_img) ) )
	{
		printf("failed?!\n");
		goto free_p_img;
	}
	printf("done!\n");

#ifndef NO_IMG
	//
	// Open video pipe
	//
	printf("Opening the video pipe (vl4 device emulation)...");
	video_dev = alloc_devClass();
	if ( video_dev == NULL )
	{
		printf("failed?!\n");
		goto free_p_img;
	}
	p_img->img_buf = init_devClass(video_dev, argv[1], p_img);
	if ( p_img->img_buf == NULL )
	{
		perror("Initializing device class failed");
		printf("failed?!\n");
		printf("Did you input the device path, \"/dev/video0\"?\"\n\n\n");
		goto free_video_dev;
	}
	printf("done!\n");
#endif

	//
	//	ISO transfers
	//
	printf("Create USB isochronous transfers...");
	for (i = 0; i < ISO_BUFFERS_NR; i++)
	{
		iRet = assignVideoBuffer(pwcmech, frames->iso_buffer[i], ISO_BUFFER_SIZE);
		if (iRet)
		{
			perror("Failed creating image transfer");
			printf("failed?!\n");
			goto unregister_buffers;
		}
	}
	printf("done!\n");


	//
	// Threads
	//
	printf("Set-up threads...");
	int active_threads = 0;
	pthread_t threads[NUM_THREADS];

	pthread_attr_t attr;
	pthread_attr_init(&attr);
	pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);

	struct acqArg * acq_arg;
	acq_arg = malloc(sizeof(struct acqArg));
	if ( acq_arg == NULL )
	{
		printf("failed?!\n");
		goto close_threads;
	}
	acq_arg->abort = &thread_abort;
	acq_arg->pwcmech = pwcmech;

	struct imgArg * img_arg;
	img_arg = malloc(sizeof(struct imgArg));
	if ( img_arg == NULL )
	{
		printf("failed?!\n");
		goto close_threads;
	}
	img_arg->frames = frames;
	img_arg->p_img = p_img;
	img_arg->video_pipe = video_dev;
	img_arg->capture = 0;
	img_arg->abort = &thread_abort;
	printf("done!\n");


	//
	//	MAIN
	//
	printf("Registering callback function for Isochronous transfer...");
	setPower(pwcmech, 0);		//enable camera (our state machine discovered that this was missing)
	registerVideoCallback(pwcmech, acquire_frame, pwcmech);
	if ( acknowledgeVideoCallback(pwcmech) )
		goto close_threads;
	printf("done!\n");

#ifndef NO_COM
	printf("Creating the data acquisition thread...");
	if ( ( iRet = pthread_create(&threads[active_threads], &attr, process_usb, (void *)acq_arg) ) )
	{
		printf("failed?!\n");
		goto stop_camera;
	}
	active_threads++;
	printf("done!\n");
#endif

#ifndef NO_IMG
	printf("Creating the image fill thread...");
	if ( ( iRet = pthread_create(&threads[active_threads], &attr, fillImageData, (void *)img_arg) ) )
	{
		printf("failed?!\n");
		goto stop_camera;
	}
	active_threads++;
	printf("done!\n");
#endif

	while (!op_abort)
	{
//		sigsuspend(&block_no_signals);
		if ( ioctl_call )
		{
			devClass_ioctl(video_dev, &img_arg->capture);
			ioctl_call = 0;
		}
	}


	//
	//	~MAIN
	//

stop_camera:
	printf("Releasing video callback...");
	releaseVideoCallback(pwcmech);
	printf("done!\n");
	printf("Unregistering buffers...");
	unassignVideoBuffers(pwcmech);
	printf("done!\n");

close_threads:
	printf("Closing all threads...");
	thread_abort = 1;
	for ( i = 0; i < active_threads; i++)
		pthread_join(threads[i], NULL);

	free(acq_arg);
	free(img_arg);

	pthread_attr_destroy(&attr);
	printf("done!\n");

unregister_buffers:
	printf("Unregistering buffers if not done before...");
	unassignVideoBuffers(pwcmech);
	printf("done!\n");

free_video_dev:
#ifndef NO_IMG
	printf("Closing video pipe...");
	close_devClass(video_dev);
	free_devClass(video_dev);
	printf("done!\n");
#endif

free_p_img:
	printf("Releasing decompression system...");
	free_images(p_img);
	printf("done!\n");
	usb_release_interface(pwcmech->com, pwcmech->com->standard_descriptors.highspeed.cameraStream.cameraStreamConf);

close_camera:
	printf("Close camera device...");
	pwcmech_deregister_handler(pwcmech);
	printf("done!\n");

stop_usb:
	printf("Stopping USB interface...");
	pwcmech_deregister_driver(pwcmech);
	printf("done!\n");

release_buffers:
	pwc_devmech_stop(pwcmech);
	//release buffers, they are linked to the camera device
	//so only release them after releasing the camera
	printf("Releasing buffers...");
	free_buffers(frames);
	printf("done!\n");

finish:
	return 0;
}