.\" $NetBSD: utoppy.4,v 1.7 2017/07/03 21:30:58 wiz Exp $ .\" .\" Copyright (c) 2006 The NetBSD Foundation, Inc. .\" All rights reserved. .\" .\" This code is derived from software contributed to The NetBSD Foundation .\" by Steve C. Woodford. .\" .\" 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. .\" .Dd April 3, 2006 .Dt UTOPPY 4 .Os .Sh NAME .Nm utoppy .Nd USB driver for the Topfield TF5000PVR range of digital video recorders .Sh SYNOPSIS .Cd "utoppy* at uhub? port ?" .Pp .In dev/usb/utoppy.h .Sh DESCRIPTION The .Nm driver provides support for the Topfield TF5000PVR range of DVB recorders (nicknamed .Ql Toppy ) which are popular in Europe and Australia. These recorders have a .Tn USB device interface which can be used to transfer recordings to and from the unit's hard disk. The .Tn USB interface can also be used to upload binary images for execution on the Toppy's MIPS cpu. .Pp The Toppy's .Tn USB protocol has not been officially documented by Topfield, but the basic features have been reverse engineered by others in order to write replacements for the official .Ql Altair download/upload program from Topfield. .Pp Existing replacements for Altair suffer from the fact that they are ultimately built on top of .Xr ugen 4 . This has a number of detrimental side-effects: .Bl -enum .It Performance suffers since all Toppy command packets have to cross the user-kernel interface. .It The userland programs are full of clutter to deal with interpreting the command/status packets, not to mention byte-swapping and host endian issues. .It Signals can interrupt a data transfer at a critical point, leaving the Toppy in an undefined state. For example, interrupting a download with .Ql Turbo mode enabled will leave the Toppy completely unresponsive to the remote control, and prevent timer-based recordings from starting. .El .Pp The .Nm driver provides a clean and stable interface to the Toppy protocol, and ensures that an interrupt caused by a signal does not leave the Toppy in an undefined state. .Sh UTOPPY INTERFACE Use the following header file to get access to the .Tn utoppy specific structures and defines. .Bd -literal #include .Ed .Pp The .Nm driver can be accessed through the .Pa /dev/utoppyN character device. The primary means of controlling the driver is by issuing a series of .Xr ioctl 2 system calls followed by .Xr read 2 or .Xr write 2 system calls as appropriate. .Pp The following .Xr ioctl 2 commands are supported by the .Nm driver: .Bl -tag -width xxxxxx .It Dv UTOPPYIOTURBO Fa "int *mode" This command can be used to enable or disable .Ql Turbo mode for subsequent .Dv UTOPPYIOREADFILE or .Dv UTOPPYIOWRITEFILE commands (see below). If .Fa num is non-zero, Turbo mode will be enabled. Otherwise Turbo mode will be disabled. In non-Turbo mode, the Toppy's .Tn USB interface is capable of sustaining around 5.6 Mbit/s during a file transfer. With Turbo mode enabled, it can sustain just over 16 Mbit/s. Of course, these figures are valid only if the Toppy is connected via a .Tn USB 2.0 interface. Performance using an older .Tn USB 1 interface will be significantly lower. .It Dv UTOPPYIOCANCEL Fa void This command can be used to abort an in-progress .Dv UTOPPYIOREADDIR , .Dv UTOPPYIOREADFILE , or .Dv UTOPPYIOWRITEFILE command. .It Dv UTOPPYIOREBOOT Fa void This command will cause the Toppy to reboot cleanly. .It Dv UTOPPYIOSTATS Fa "struct utoppy_stats *stats" This command retrieves statistics for the Toppy's hard disk. .Bd -literal struct utoppy_stats { uint64_t us_hdd_size; /* Size of the disk, in bytes */ uint64_t us_hdd_free; /* Free space, in bytes */ }; .Ed .It UTOPPYIORENAME Fa "struct utoppy_rename *rename" This command is used to rename a file or directory on the Toppy's hard disk. The full pathname to each file must be provided. .Bd -literal struct utoppy_rename { char *ur_old_path; /* Path to existing file */ char *ur_new_path; /* Path to new file */ }; .Ed .It UTOPPYIOMKDIR Fa "char *path" This command creates the directory specified by .Fa path . .It UTOPPYIODELETE Fa "char *path" This command deletes the file or directory specified by .Fa path . .It UTOPPYIOREADDIR Fa "char *path" This command initiates a read of the contents of the directory specified by .Fa path . After issuing this command, the directory contents must be read using consecutive .Xr read 2 system calls. Each .Xr read 2 will transfer one or more directory entries into the user-supplied buffer. The buffer must be large enough to receive at least one directory entry. When .Xr read 2 returns zero, all directory entries have been read. .Pp A directory entry is described using the following data structure: .Bd -literal struct utoppy_dirent { char ud_path[UTOPPY_MAX_FILENAME_LEN + 1]; enum { UTOPPY_DIRENT_UNKNOWN, UTOPPY_DIRENT_DIRECTORY, UTOPPY_DIRENT_FILE } ud_type; off_t ud_size; time_t ud_mtime; uint32_t ud_attributes; }; .Ed .Pp The .Va ud_path field contains the name of the directory entry. .Pp The .Va ud_type field specifies whether the entry corresponds to a file or a sub-directory. .Pp The .Va ud_size field is valid for files only, and specifies the file's size in bytes. .Pp The .Va ud_mtime field describes the file or directory's modification time, specified as seconds from the Unix epoch. The timestamp is relative to the current timezone, so .Xr localtime 3 can be used to convert it into human readable form. Note that the Toppy sets directory timestamps to a predefined value so they are not particularly useful. .Pp The .Va ud_attributes field is not used at this time. .It UTOPPYIOREADFILE Fa "struct utoppy_readfile *" This command is used to initiate reading a file from the Toppy's hard disk. The full pathname, together with the file offset at which to start reading, is specified using the following data structure: .Bd -literal struct utoppy_readfile { char *ur_path; off_t ur_offset; }; .Ed .Pp After issuing this command, the file must be read using consecutive .Xr read 2 system calls. When .Xr read 2 returns zero, the entire file has been read. .It UTOPPYIOWRITEFILE Fa "struct utoppy_writefile *" This command is used to initiate writing to a file on the Toppy's hard disk. The file to be written is described using the following data structure: .Bd -literal struct utoppy_writefile { char *uw_path; off_t uw_offset; off_t uw_size; time_t uw_mtime; }; .Ed .Pp The .Va uw_path field specifies the full pathname of the file to be written. .Pp The .Va uw_offset field specifies the file offset at which to start writing, assuming the file already exists. Otherwise, .Va uw_offset must be zero. .Pp The protocol requires that the Toppy must be informed of a file's size in advance of the file being written. This is accomplished using the .Va uw_size field. It may be possible to work around this limitation in a future version of the driver. .Pp The .Va uw_mtime field specifies the file's timestamp expressed as seconds from the Unix epoch in the local timezone. .El .Pp Due to limitations with the protocol, a .Nm device can be opened by only one application at a time. Also, only a single .Dv UTOPPYIOREADDIR , .Dv UTOPPYIOREADFILE , or .Dv UTOPPYIOWRITEFILE command can be in progress at any given time. .Sh FILES .Bl -tag -width /dev/utoppy0 -compact .It Pa /dev/utoppy0 device node .El .Sh SEE ALSO .Xr utoppya 1 , .Xr usb 4 .Sh HISTORY The .Nm driver appeared in .Nx 4.0 . .Sh AUTHORS .An Steve C. Woodford Aq Mt scw@netbsd.org