2 .\" Copyright (c) 20002 Sun Microsystems, Inc.
3 .\" All Rights Reserved.
4 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
5 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
6 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
7 .TH PRNIO 7I "Jan 2, 2002"
9 prnio \- generic printer interface
13 \fB#include <sys/prnio.h>\fR
19 The \fBprnio\fR generic printer interface defines ioctl commands and data
20 structures for printer device drivers.
23 \fBprnio\fR defines and provides facilities for five basic phases of the
29 Identification \(em Retrieve device information/attributes
35 Setup \(em Set device attributes
41 Transfer \(em Transfer data to or from the device
47 Cleanup \(em Transfer phase conclusion
53 Abort \(em Transfer phase interruption
57 During the Identification phase, the application retrieves a set of device
58 capabilities and additional information using the \fBPRNIOC_GET_IFCAP\fR,
59 \fBPRNIOC_GET_STATUS\fR, \fBPRNIOC_GET_TIMEOUTS\fR, \fBPRNIOC_GET_IFINFO\fR and
60 \fBPRNIOC_GET_1284_DEVID\fR commands.
63 During the Setup phase the application sets some interface attributes and
64 probably resets the printer as described in the \fBPRNIOC_SET_IFCAP\fR,
65 \fBPRNIOC_SET_TIMEOUTS\fR and \fBPRNIOC_RESET\fR sections.
68 During the Transfer phase, data is transferred in a forward (host to
69 peripheral) or reverse direction (peripheral to host). Transfer is accomplished
70 using \fBwrite\fR(2) and \fBread\fR(2) system calls. For \fBprnio\fR compliant
71 printer drivers, forward transfer support is mandatory, while reverse transfer
72 support is optional. Applications can also use \fBPRNIOC_GET_STATUS\fR and
73 \fBPRNIOC_GET_1284_STATUS\fR commands during the transfer to monitor the device
77 The Cleanup phase is accomplished by closing the device using \fBclose\fR(2).
78 Device drivers supporting \fBprnio\fR may set non-zero error code as
79 appropriate. Applications should explicitly \fBclose\fR(2) a device before
80 exiting and check \fBerrno\fR value.
83 The Abort phase is accomplished by interrupting the \fBwrite\fR(2) and
84 \fBread\fR(2) system calls. The application can perform some additional cleanup
85 during the Abort phase as described in \fBPRNIOC_GET_IFCAP\fR section.
90 \fB\fBPRNIOC_GET_IFCAP\fR\fR
93 Application can retrieve printer interface capabilities using this command. The
94 \fBioctl\fR(2) argument is a pointer to \fBuint_t\fR, a bit field representing
95 a set of properties and services provided by a printer driver. Set bit means
96 supported capability. The following values are defined:
99 \fBPRN_BIDI\fR - When this bit is set, the interface operates in a
100 bidirectional mode, instead of forward-only mode.
104 \fBPRN_HOTPLUG\fR - If this bit is set, the interface allows device
109 \fBPRN_1284_DEVID\fR - If this bit is set, the device is capable of returning
110 \fI1284\fR device ID (see \fBPRNIOC_GET_1284_DEVID\fR.)
114 \fBPRN_1284_STATUS\fR - If this bit is set, the device driver can return device
115 status lines (see \fBPRNIOC_GET_1284_STATUS\fR). Some devices support this
116 ioctl in unidirectional mode only.
120 \fBPRN_TIMEOUTS\fR - If this bit is set the peripheral may stall during the
121 transfer phase and the driver can timeout and return from the \fBwrite\fR(2)
122 and \fBread\fR(2) returning the number of bytes that have been transferred. If
123 \fBPRN_TIMEOUTS\fR is set, the driver supports this functionality and the
124 timeout values can be retrieved and modified via the \fBPRNIOC_GET_TIMEOUTS\fR
125 and \fBPRNIOC_SET_TIMEOUTS\fR ioctls. Otherwise, applications can implement
126 their own timeouts and abort phase.
130 \fBPRN_STREAMS\fR - This bit impacts the application abort phase behaviour. If
131 the device claimed \fBPRN_STREAMS\fR capability, the application must issue an
132 \fBI_FLUSH\fR \fBioctl\fR(2) before \fBclose\fR(2) to dismiss the untransferred
133 data. Only STREAMS drivers can support this capability.
140 \fBPRNIOC_SET_IFCAP\fR
143 This ioctl can be used to change interface capabilities. The argument is a
144 pointer to \fBuint_t\fR bit field that is described in detail in the
145 \fBPRNIOC_GET_IFCAP\fR section. Capabilities should be set one at a time;
146 otherwise the command will return \fBEINVAL\fR. The following capabilities can
147 be changed by this ioctl:
150 \fBPRN_BIDI\fR - When this capability is set, the interface operates in a
151 bidirectional mode, instead of forward-only mode. Devices that support only one
152 mode will not return error; applications should use \fBPRNIOC_GET_IFCAP\fR to
153 check if the mode was successfully changed. Because some capabilities may be
154 altered as a side effect of changing other capabilities, this command should be
155 followed by \fBPRNIOC_GET_IFCAP\fR.
162 \fBPRNIOC_GET_IFINFO\fR
165 This command can be used to retrieve printer interface info string, which is an
166 arbitrary format string usually describing the bus type. The argument is a
167 pointer to \fBstruct prn_interface_info\fR as described below.\f(CW\fR
173 struct prn_interface_info {
174 uint_t if_len; /* length of buffer */
175 uint_t if_rlen; /* actual info length */
176 char *if_data; /* buffer address */
183 The application allocates a buffer and sets \fBif_data\fR and \fBif_len\fR
184 values to its address and length, respectively. The driver returns the string
185 to this buffer and sets \fBif_len\fR to its length. If \fBif_len\fR is less
186 that \fBif_rlen\fR, the driver must return the first \fBif_len\fR bytes of the
187 string. The application may then repeat the command with a bigger buffer.
190 Although \fBprnio\fR does not limit the contents of the interface info string,
191 some values are recommended and defined in <\fBsys/prnio.h\fR> by the following
195 \fBPRN_PARALLEL\fR - Centronics or \fIIEEE 1284\fR compatible devices
199 \fBPRN_SERIAL\fR - EIA-232/EIA-485 serial ports
203 \fBPRN_USB\fR - Universal Serial Bus printers
207 \fBPRN_1394\fR - \fIIEEE 1394\fR peripherals
211 Printer interface info string is for information only: no implications should
212 be made from its value.
220 Some applications may want to reset the printer state during Setup and/or
221 Cleanup phase using \fBPRNIOC_RESET\fR command. Reset semantics are
222 device-specific, and in general, applications using this command should be
223 aware of the printer type.
225 Each \fBprnio\fR compliant driver is required to accept this request, although
226 performed actions are completely driver-dependent. More information on the
227 \fBPRNIOC_RESET\fR implementation for the particular driver is available in the
228 corresponding man page and printer manual.
234 \fBPRNIOC_GET_1284_DEVID\fR
237 This command can be used to retrieve printer device ID as defined by \fIIEEE
238 1284-1994\fR.The \fBioctl\fR(2) argument is a pointer to \fBstruct
239 prn_1284_device_id\fR as described below.
245 struct prn_1284_device_id {
246 uint_t id_len; /* length of buffer */
247 uint_t id_rlen; /* actual ID length */
248 char *id_data; /* buffer address */
255 For convenience, the two-byte length field is not considered part of device ID
256 string and is not returned in the user buffer. Instead, \fBid_rlen\fR value
257 shall be set to (length - 2) by the driver, where length is the ID length field
258 value. If buffer length is less than \fBid_rlen\fR, the driver returns the
259 first \fBid_len\fR bytes of the ID.
262 The printer driver must return the most up-to-date value of the device ID.
266 \fBPRNIOC_GET_STATUS\fR
269 This command can be used by applications to retrieve current device status. The
270 argument is a pointer to \fBuint_t\fR, where the status word is returned.
271 Status is a combination of the following bits:
276 \fBPRN_ONLINE\fR - For devices that support \fBPRN_HOTPLUG\fR capability,
277 this bit is set when the device is online, otherwise the device is offline.
278 Devices without \fBPRN_HOTPLUG\fR support should always have this bit set.
282 \fBPRN_READY\fR - This bit indicates if the device is ready to receive/send
283 data. Applications may use this bit for an outbound flow control
288 \fB\fBPRNIOC_GET_1284_STATUS\fR\fR
291 Devices that support \fBPRN_1284_STATUS\fR capability accept this ioctl to
292 retrieve the device status lines defined in \fIIEEE 1284\fR for use in
293 Compatibility mode. The following bits may be set by the driver:
296 \fBPRN_1284_NOFAULT\fR - Device is not in error state
300 \fBPRN_1284_SELECT\fR - Device is selected
304 \fBPRN_1284_PE\fR - Paper error
308 \fBPRN_1284_BUSY\fR - Device is busy
315 \fB\fBPRNIOC_GET_TIMEOUTS\fR\fR
318 This command retrieves current transfer timeout values for the driver. The
319 argument is a pointer to \fBstruct prn_timeouts\fR as described below.
325 struct prn_timeouts {
326 uint_t tmo_forward; /* forward transfer timeout */
327 uint_t tmo_reverse; /* reverse transfer timeout */
334 \fBtmo_forward\fR and \fBtmo_reverse\fR define forward and reverse transfer
335 timeouts in seconds. This command is only valid for drivers that support
336 \fBPRN_TIMEOUTS\fR capability.
340 \fB\fBPRNIOC_SET_TIMEOUTS\fR\fR
343 This command sets current transfer timeout values for the driver. The
344 argument is a pointer to \fBstruct prn_timeouts\fR. See
345 \fBPRNIOC_GET_TIMEOUTS\fR for description of this structure. This command is
346 only valid for drivers that support \fBPRN_TIMEOUTS\fR capability.
352 See \fBattributes\fR(5) for descriptions of the following attributes:
360 ATTRIBUTE TYPE ATTRIBUTE VALUE
362 Architecture SPARC, IA
364 Interface Stability Evolving
370 \fBclose\fR(2), \fBioctl\fR(2), \fBread\fR(2), \fBwrite\fR(2),
371 \fBattributes\fR(5), \fBecpp\fR(7D), \fBusbprn\fR(7D), \fBlp\fR(7D)
374 \fIIEEE Std 1284-1994\fR