Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[linux-dvb] Re: info visionplus usb-ter
Hi,
On Wed, Apr 21, 2004 at 02:47:37PM +0200, Andrea Venturi wrote:
> hi,
>
> we bought this usb dvb-t visionplus dvb-t usb-ter
>
> http://www.visionplus.com.tw/visiontv-2.htm
>
> the main business is "load" any firmware available on the linux host to
> the chip. but i have not been able to recognize the "firmware" file in
> the driver directory of the MS OS driver package.. (maybe it's embedded
> in some of the .sys file there)
Try this:
--------------------------------------------------------------------------
vp7041fwload.c
--------------------------------------------------------------------------
/*
* TwinHan Vision Plus USB-Ter firmware loader
*
* Copyright (c) 2004 Peter Schildmann <peter.schildmann@web.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License, as published by the Free Software Foundation. This
* program is distributed WITHOUT ANY WARRANTY; without even the
* implied warranty of merchantability or fitness for a particular
* purpose. You should have received a copy of version 2 of the GNU
* General Public License along with this program; if not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <usb.h>
usb_dev_handle *usb = NULL;
u_int8_t *firmware;
struct stat s;
void die(char* s)
{
perror(s);
exit(1);
}
void close_all (void) {
if(usb != NULL)
usb_close(usb);
if(firmware != MAP_FAILED)
munmap(firmware, s.st_size);
}
int vp7041_write(usb_dev_handle *handle, u_int16_t addr, u_int8_t size, u_int8_t *data)
{
#ifdef DEBUG
int i;
printf("0x%04x %02d ", addr, size);
for(i = 0; i < size; i++)
printf("%02x ", data[i]);
putchar('\n');
#endif
int ret = usb_control_msg(handle, USB_TYPE_VENDOR, 0xa0, addr, 0x0, data, size, 500);
return ret == size;
}
int main(int argc, char *argv[])
{
int i;
int fd;
struct usb_bus *bus;
struct usb_device *dev;
struct usb_device *usb_dev = NULL;
if(argc != 2) {
fprintf(stderr, "Usage: %s filename\n", argv[0]);
fprintf(stderr, "Downloads firmware to the TwinHan USB-Ter DVB-T box\n");
exit(1);
}
fd = open(argv[1], O_RDONLY);
if(fd == -1)
die(argv[1]);
if(fstat(fd, &s) < 0)
die(argv[1]);
firmware = (u_int8_t*) mmap(0, s.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
if(firmware == MAP_FAILED)
die(argv[1]);
usb_init();
usb_find_busses();
usb_find_devices();
for (bus = usb_busses; bus; bus = bus->next)
{
for (dev = bus->devices; dev; dev = dev->next)
{
if(dev->descriptor.idVendor == 0x1822 && dev->descriptor.idProduct == 0x3201)
{
#ifdef DEBUG
printf("TwinHan VP-7041 DVB-T box found.\n");
#endif
if(usb_dev != NULL) {
fprintf(stderr,"Multiple VP-7041 found, bailing out.\n");
exit(1);
}
usb_dev = dev;
}
}
}
if(usb_dev == NULL) {
fprintf(stderr, "VP-7041 not found.\n");
exit(1);
}
if((usb = usb_open(usb_dev)) == NULL) {
fprintf(stderr, "Error opening USB device.\n");
exit(1);
}
atexit(close_all);
if(usb_claim_interface(usb, 0))
die("Can't claim interface");
/* -----------------------------------------------------
* Load firmware
*/
for(i = 0; i < s.st_size; i += 22)
{
u_int16_t addr = ((u_int16_t) firmware[i + 3]) | ((u_int16_t) firmware[i + 4]) << 8;
if(!vp7041_write(usb, addr, firmware[i + 1], firmware + i + 6))
{
fprintf(stderr, "Firmware download failed\n");
exit(1);
}
}
if(usb_release_interface(usb, 0))
die("Can't release interface");
exit(0);
}
--------------------------------------------------------------------------
Makefile
--------------------------------------------------------------------------
CFLAGS += -Wall $(shell libusb-config --cflags)
LDFLAGS += $(shell libusb-config --libs)
SRCS = vp7041fwload.c
vp7041fwload: vp7041fwload.o
depend:
makedepend -- $(CFLAGS) -- $(SRCS)
clean:
rm -f vp7041fwload *.o *~
--------------------------------------------------------------------------
extract-firmware
--------------------------------------------------------------------------
#!/bin/sh
# Extract VP-7041 firmware from Windoze driver (twinload.sys)
DRIVER=twinload.sys
COMMAND="\000\001\000\222\177\000"
PADDING="\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
printf $COMMAND"\001"$PADDING > twinload.bin
printf $COMMAND"\001"$PADDING >> twinload.bin
# block #1
# start = 0x30df
# end = 0x3cbb
dd bs=1 skip=12511 count=3036 if=$DRIVER >> twinload.bin
printf $COMMAND"\000"$PADDING >> twinload.bin
printf $COMMAND"\001"$PADDING >> twinload.bin
# block #2
# start = 0x097f
# end = 0x30c5
dd bs=1 skip=2431 count=10054 if=$DRIVER >> twinload.bin
printf $COMMAND"\001"$PADDING >> twinload.bin
printf $COMMAND"\000"$PADDING >> twinload.bin
--------------------------------------------------------------------------
Peter
--
Info:
To unsubscribe send a mail to ecartis@linuxtv.org with "unsubscribe linux-dvb" as subject.
Home |
Main Index |
Thread Index