Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37866235
en ru br
Репозитории ALT

Группа :: Графика
Пакет: somagic-easycap-tools

 Главная   Изменения   Спек   Патчи   Исходники   Загрузить   Gear   Bugs and FR  Repocop 

somagic-easycap-tools-1.0/000075500000000000000000000000001204427231000155465ustar00rootroot00000000000000somagic-easycap-tools-1.0/Makefile000064400000000000000000000032161204427231000172100ustar00rootroot00000000000000################################################################################
# Makefile #
# #
# Makefile for somagic-extract-firmware program #
# ##############################################################################
#
# Copyright 2011, 2012 Jeffry Johnston
#
# This file is part of somagic_easycap
# http://code.google.com/p/easycap-somagic-linux/
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.

SHELL = /bin/sh
PREFIX = /usr/local
BINDIR = $(PREFIX)/bin
MANDIR = $(PREFIX)/share/man
PROGRAMS = somagic-extract-firmware
MANUALS = man/somagic-extract-firmware.1
CFLAGS = -s -W -Wall
LFLAGS = -lgcrypt

.SUFFIXES:
.SUFFIXES: .c

.PHONY: all
all: $(PROGRAMS)

.c:
$(CC) $(CFLAGS) $< -o $@ $(LFLAGS)

.PHONY: install
install: $(PROGRAMS) $(MANUALS)
mkdir -p $(BINDIR)
install $(PROGRAMS) $(BINDIR)/
mkdir -p $(MANDIR)/man1
install $(MANUALS) $(MANDIR)/man1/

.PHONY: clean
clean:
-rm -f $(PROGRAMS)
somagic-easycap-tools-1.0/README000064400000000000000000000022411204427231000164250ustar00rootroot00000000000000Description
-----------
somagic-extract-firmware is a small tool to extract the EasyCAP Somagic
firmware from a Windows driver file. It searches the driver file for the
firmware and verifies its CRC32 signature before writing it to a file.


Preliminaries
-------------
Before using this program, a file must be obtained. Using Wine or
Windows, run "Setup.exe", which should be found in the "Drivers"
directory of the EasyCAP installation CD. This should create a driver
file named "SmiUsbGrabber3C.sys" or "SmiUsbGrabber3E.sys", located in
the "Program Files/Common Files/Somagic/SmiUsbGrabber3C/xp/" or
"Program Files/Common Files/Somagic/SmiUsbGrabber3E/xp/" directory.


Dependencies
------------
make, gcc, libgcrypt11 (and development headers)


Example
-------
sudo somagic-extract-firmware ~/.wine/drive_c/Program\ Files/Common\ Files/Somagic/SmiUsbGrabber3C/xp/SmiUsbGrabber3C.sys


To build from sources
---------------------
make && sudo make install


To build Debian source and binary packages
------------------------------------------
apt-get install devscripts debhelper
debuild -us -uc


To clean debian directory
-------------------------
fakeroot debian/rules clean
somagic-easycap-tools-1.0/debian/000075500000000000000000000000001204427231000167705ustar00rootroot00000000000000somagic-easycap-tools-1.0/debian/changelog000064400000000000000000000002251204427231000206410ustar00rootroot00000000000000somagic-easycap-tools (1.0) unstable; urgency=low

* Initial Release.

-- Jeffry Johnston <somagic@kidsquid.com> Fri, 24 Feb 2012 16:13:23 -0700
somagic-easycap-tools-1.0/debian/compat000064400000000000000000000000021204427231000201660ustar00rootroot000000000000008
somagic-easycap-tools-1.0/debian/control000064400000000000000000000021211204427231000203670ustar00rootroot00000000000000Source: somagic-easycap-tools
Section: graphics
Priority: extra
Maintainer: Jeffry Johnston <somagic@kidsquid.com>
Build-Depends: debhelper (>= 8.0.0), libgcrypt11-dev
Standards-Version: 3.9.2
Homepage: http://code.google.com/p/easycap-somagic-linux/

Package: somagic-easycap-tools
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Suggests: somagic-easycap, wine
Description: Somagic EasyCAP tools
Linux capture program for the Somagic variants of the EasyCAP:
* EasyCAP Model DC60, with CVBS, S-VIDEO, AUDIO(L), and AUDIO(R)
inputs. The uninitialized device shows in lsusb as
"1c88:0007 Somagic, Inc.". Once initialized, it shows as
"1c88:003c Somagic, Inc".
* EasyCAP Model 002 (or EasyCAP002), with 1, 2, 3, 4, and
unlabeled microphone inputs. The uninitialized device shows in
lsusb as "1c88:0007 Somagic, Inc.". Once initialized, it shows
as either "1c88:003e Somagic, Inc" or
"1c88:003f Somagic, Inc".
.
This package provides somagic-extract-firmware (to extract
firmware from a Windows driver).

somagic-easycap-tools-1.0/debian/copyright000064400000000000000000000020601204427231000207210ustar00rootroot00000000000000Format: http://dep.debian.net/deps/dep5
Upstream-Name: somagic-easycap-tools
Source: http://code.google.com/p/easycap-somagic-linux/

Files: *
Copyright: 2011, 2012 Jeffry Johnston
License: GPL-2.0+

Files: debian/*
Copyright: 2012 Jeffry Johnston <somagic@kidsquid.com>
License: GPL-2.0+

License: GPL-2.0+
This package is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
.
This package is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
.
On Debian systems, the complete text of the GNU General
Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".


somagic-easycap-tools-1.0/debian/docs000064400000000000000000000000001204427231000176310ustar00rootroot00000000000000somagic-easycap-tools-1.0/debian/rules000075500000000000000000000013671204427231000200570ustar00rootroot00000000000000#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
#
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
#
# Modified to make a template file for a multi-binary package with separated
# build-arch and build-indep targets by Bill Allombert 2001

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# This has to be exported to make some magic below work.
export DH_OPTIONS

%:
dh $@

override_dh_auto_install:
dh_auto_install -- PREFIX=$(CURDIR)/debian/somagic-easycap-tools/usr


somagic-easycap-tools-1.0/debian/source/000075500000000000000000000000001204427231000202705ustar00rootroot00000000000000somagic-easycap-tools-1.0/debian/source/format000064400000000000000000000000151204427231000214770ustar00rootroot000000000000003.0 (native)
somagic-easycap-tools-1.0/man/000075500000000000000000000000001204427231000163215ustar00rootroot00000000000000somagic-easycap-tools-1.0/man/somagic-extract-firmware.1000064400000000000000000000036011204427231000233070ustar00rootroot00000000000000.TH somagic-extract-firmware "1" "February 2012" "somagic-extract-firmware 1.0" "Somagic EasyCAP"
.SH NAME
somagic-extract-firmware \- Extract the Somagic EasyCAP DC60 or Somagic EasyCAP002 firmware from a Windows driver file
.SH SYNOPSIS
.B somagic-init
[\fIOPTION\fR]... [\fIDRIVER_FILENAME\fR]
.SH DESCRIPTION
.PP
Extracts the firmware for the Somagic EasyCAP from the Windows driver file named \fIDRIVER_FILENAME\fR, verifies its CRC32 signature, and writes it to a file.

Before running this program, use Wine or Windows to run "Setup.exe", which should be found in the "Drivers" directory of the EasyCAP installation CD.
This should create a driver file named either "SmiUsbGrabber3C.sys" or "SmiUsbGrabber3C.sys", located in either the "Program Files/Common Files/Somagic/SmiUsbGrabber3C/xp/" or "Program Files/Common Files/Somagic/SmiUsbGrabber3E/xp/" directory.
.SH OPTIONS
.TP
\fB\-f\fR, \fB\-\-firmware\fR=\fIFILENAME\fR
Write to firmware file \fIFILENAME\fR.
The default filename is "/lib/firmware/somagic_firmware.bin".
.TP
\fB\-\-help\fR
Print program usage and example.
.TP
\fB\-\-version\fR
Print the program version, the program copyright, a list of authors, and a notice that there is no warranty.
.SH "EXIT STATUS"
The program exits with a status of zero on success.
A status of one will be returned if any errors were encountered.
.SH "SEE ALSO"
\fBsomagic-init\fR(1), \fBsomagic-capture\fR(1)
.SH "REPORTING BUGS"
Report bugs to the easycap-somagic-linux project on Google Project Hosting:
<http://code.google.com/p/easycap\-somagic\-linux/issues/list>
.SH AUTHOR
This manual page was written by Jeffry Johnston <somagic@kidsquid.com>.
.SH "COPYRIGHT"
Copyright \(co 2011, 2012 Jeffry Johnston.
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.
.br
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

somagic-easycap-tools-1.0/somagic-extract-firmware.c000064400000000000000000000201711204427231000226170ustar00rootroot00000000000000/*******************************************************************************
* somagic-extract-firmware.c *
* *
* Extract the EasyCAP Somagic firmware from a Windows driver file. *
* *****************************************************************************
*
* Copyright 2011, 2012 Jeffry Johnston
*
* This file is part of somagic_easycap
* http://code.google.com/p/easycap-somagic-linux/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
*/

#include <errno.h>
#include <gcrypt.h>
#include <getopt.h>
#include <stdio.h>
#include <string.h>

/* Constants */
#define PROGRAM_NAME "somagic-extract-firmware"
#define VERSION "1.1"
#define SOMAGIC_FIRMWARE_PATH "/lib/firmware/somagic_firmware.bin"

/*
* Index Firmware
* ----- --------
* 0 SmiUsbGrabber3C.sys, EasyCAP DC60
* 1 SmiUsbGrabber3E.sys, EasyCAP002
* 2 SmiUsbGrabber3F.sys, EasyCAP002
*/

/*
* File Initialized 62-byte Firmware Offset
* Firmware Filename Size Device blocks Length Firmware Offsets Difference
* ---------------------------- ------ ----------- ------- -------- ------------------------------- ----------
* vista/SmiUsbGrabber3C.sys 805888 1c88:003c 121 7502 0xbb0d8 0xbce28 0xbeb78 0xc08c8 7504
* vista64/SmiUsbGrabber3C.sys 821888 1c88:003c 121 7502 0x12aa0 0x147f0 0x16540 0x18290 7504
* wind7_32/SmiUsbGrabber3C.sys 805888 1c88:003c 121 7502 0xbb0d8 0xbce28 0xbeb78 0xc08c8 7504
* wind7_64/SmiUsbGrabber3C.sys 821888 1c88:003c 121 7502 0x12aa0 0x147f0 0x16540 0x18290 7504
* xp/SmiUsbGrabber3C.sys 805632 1c88:003c 121 7502 0xbafd8 0xbcd28 0xbea78 0xc07c8 7504
* xp/SmiUsbGrabber3E.sys 805376 1c88:003e 107 6634 0xbac48 0xbc628 0xbe008 0xbf9e8 6624
* vista/SmiUsbGrabber3F.sys 109568 1c88:003f 107 6634 0x10b28 0x12508 0x13ee8 0x158c8 6624
* vista64/SmiUsbGrabber3F.sys 127872 1c88:003f 107 6634 0x14270 0x15c50 0x17630 0x19010 6624
* wind7_32/SmiUsbGrabber3F.sys 109568 1c88:003f 107 6634 0x10b28 0x12508 0x13ee8 0x158c8 6624
* wind7_64/SmiUsbGrabber3F.sys 127872 1c88:003f 107 6634 0x14270 0x15c50 0x17630 0x19010 6624
* xp/SmiUsbGrabber3F.sys 109568 1c88:003f 107 6634 0x10b28 0x12508 0x13ee8 0x158c8 6624
* xp/SmiUsbGrabber3F.sys 147328 1c88:003f 107 6634 0x18570 0x19f50 0x1b930 0x1d310 6624
*/
#define PRODUCT_COUNT 3
static const int SOMAGIC_FIRMWARE_LENGTH[PRODUCT_COUNT] = {
7502,
6634,
6634
};
static const unsigned char SOMAGIC_FIRMWARE_MAGIC[PRODUCT_COUNT][4] = {
{'\x0c', '\x94', '\xce', '\x00'},
{'\x0c', '\x94', '\xcc', '\x00'},
{'\x0c', '\x94', '\xcc', '\x00'}
};
static const unsigned char SOMAGIC_FIRMWARE_CRC32[PRODUCT_COUNT][4] = {
{'\x34', '\x89', '\xf7', '\x7b'},
{'\x1f', '\xfe', '\xde', '\xbb'},
{'\x60', '\x1d', '\x37', '\x5f'}
};

static void version()
{
fprintf(stderr, PROGRAM_NAME" "VERSION"\n");
fprintf(stderr, "Copyright 2011, 2012 Jeffry Johnston\n");
fprintf(stderr, "License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.\n");
fprintf(stderr, "This is free software: you are free to change and redistribute it.\n");
fprintf(stderr, "There is NO WARRANTY, to the extent permitted by law.\n");
}

static void usage()
{
fprintf(stderr, "Usage: "PROGRAM_NAME" [options] DRIVER_FILENAME\n");
fprintf(stderr, " -f, --firmware=FILENAME Write to firmware file FILENAME\n");
fprintf(stderr, " (default: "SOMAGIC_FIRMWARE_PATH")\n");
fprintf(stderr, " --help Display usage\n");
fprintf(stderr, " --version Display version information\n");
fprintf(stderr, "\n");
fprintf(stderr, "Example (run as root):\n");
fprintf(stderr, PROGRAM_NAME" SmiUsbGrabber3C.sys\n");
}

int main(int argc, char **argv)
{
FILE *infile;
int ret;
char *firmware_path = SOMAGIC_FIRMWARE_PATH;
unsigned char last4[4] = {'\0', '\0', '\0', '\0'};
int firmware_found = 0;
long pos;
char firmware[SOMAGIC_FIRMWARE_LENGTH[0]];
unsigned char digest[4];
FILE *outfile;
int i;

/* Parsing */
int c;
int option_index = 0;
static struct option long_options[] = {
{"help", 0, 0, 0}, /* index 0 */
{"version", 0, 0, 0}, /* index 1 */
{"firmware", 1, 0, 'f'},
{0, 0, 0, 0}
};

/* Parse command line arguments */
while (1) {
c = getopt_long(argc, argv, "f:", long_options, &option_index);
if (c == -1) {
break;
}
switch (c) {
case 0:
switch (option_index) {
case 0: /* --help */
usage();
return 0;
case 1: /* --version */
version();
return 0;
default:
usage();
return 1;
}
break;
case 'f':
firmware_path = optarg;
break;
default:
usage();
return 1;
}
}
if (optind + 1 != argc) {
usage();
return 1;
}

infile = fopen(argv[optind], "r");
if (infile == NULL) {
fprintf(stderr, "%s: Failed to open driver file '%s': %s\n", argv[0], argv[optind], strerror(errno));
return 1;
}

/* Search for the firmware magic */
while (!firmware_found) {
/* Read next byte from file */
c = fgetc(infile);
if (c == EOF) {
/* Either at EOF or a read error occurred */
if (!feof(infile)) {
perror("Failed to read driver file");
return 1;
}
break;
}

/* Roll new character into array */
memmove(last4, last4 + 1, 3);
last4[3] = c;

/* Check firmware magic */
for (i = 0; i < PRODUCT_COUNT; i++) {
if (memcmp(last4, SOMAGIC_FIRMWARE_MAGIC[i], 4) == 0) {
/* Found, save file position */
pos = ftell(infile);

/* Read rest of firmware */
memcpy(firmware, last4, 4);
ret = fread(firmware + 4, 1, SOMAGIC_FIRMWARE_LENGTH[i] - 4, infile);
if (ret != SOMAGIC_FIRMWARE_LENGTH[i] - 4) {
perror("Failed to read driver file");
return 1;
}

/* Check CRC32 */
gcry_md_hash_buffer(GCRY_MD_CRC32, digest, firmware, SOMAGIC_FIRMWARE_LENGTH[i]);
#ifdef DEBUG
fprintf(stderr, "Product: %i, Expected: %02x %02x %02x %02x, Found: %02x %02x %02x %02x, Offset: %lx\n", i, SOMAGIC_FIRMWARE_CRC32[i][0], SOMAGIC_FIRMWARE_CRC32[i][1], SOMAGIC_FIRMWARE_CRC32[i][2], SOMAGIC_FIRMWARE_CRC32[i][3], digest[0], digest[1], digest[2], digest[3], (pos - 4));
#endif
if (memcmp(digest, SOMAGIC_FIRMWARE_CRC32[i], 4) == 0) {
/* CRC32 matched */
firmware_found = 1;

/* Write firmware file */
outfile = fopen(firmware_path, "w+");
if (outfile == NULL) {
fprintf(stderr, "%s: Failed to open firmware file '%s': %s\n", argv[0], firmware_path, strerror(errno));
return 1;
}
ret = fwrite(firmware, 1, SOMAGIC_FIRMWARE_LENGTH[i], outfile);
if (ret != SOMAGIC_FIRMWARE_LENGTH[i]) {
perror("Failed to write firmware file");
return 1;
}
ret = fclose(outfile);
if (ret) {
perror("Failed to close firmware file");
return 1;
}
fprintf(stderr, "Firmware written to '%s'.\n", firmware_path);
break;
} else {
/* False positive, return to previous file position and keep looking */
ret = fseek(infile, pos, SEEK_SET);
if (ret) {
perror("Failed to seek in driver file");
return 1;
}
}
}
}
}

ret = fclose(infile);
if (ret) {
perror("Failed to close driver file");
return 1;
}

if (!firmware_found) {
fprintf(stderr, "Somagic firmware was not found in driver file.\n");
return 1;
}

return 0;
}

 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin