summaryrefslogtreecommitdiff
path: root/static/netbsd/man4/utoppy.4
blob: 979357b75066a2a5e87ffb0b0b9e8b3b1952c06d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
.\" $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 <dev/usb/utoppy.h>
.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