xref: /illumos-gate/usr/src/man/man4i/prnio.4i (revision bbf215553c7233fbab8a0afdf1fac74c44781867)
1*bbf21555SRichard Lowe.\"  Copyright (c) 20002 Sun Microsystems, Inc.
2*bbf21555SRichard Lowe.\"  All Rights Reserved.
3*bbf21555SRichard Lowe.\"  Copyright 2018, Joyent, Inc.
4*bbf21555SRichard Lowe.\" The contents of this file are subject to the terms of the
5*bbf21555SRichard Lowe.\" Common Development and Distribution License (the "License").
6*bbf21555SRichard Lowe.\" You may not use this file except in compliance with the License.
7*bbf21555SRichard Lowe.\"
8*bbf21555SRichard Lowe.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*bbf21555SRichard Lowe.\" or http://www.opensolaris.org/os/licensing.
10*bbf21555SRichard Lowe.\" See the License for the specific language governing permissions
11*bbf21555SRichard Lowe.\" and limitations under the License.
12*bbf21555SRichard Lowe.\"
13*bbf21555SRichard Lowe.\" When distributing Covered Code, include this CDDL HEADER in each
14*bbf21555SRichard Lowe.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*bbf21555SRichard Lowe.\" If applicable, add the following below this CDDL HEADER, with the
16*bbf21555SRichard Lowe.\" fields enclosed by brackets "[]" replaced with your own identifying
17*bbf21555SRichard Lowe.\" information: Portions Copyright [yyyy] [name of copyright owner]
18*bbf21555SRichard Lowe.Dd August 31, 2018
19*bbf21555SRichard Lowe.Dt PRNIO 4I
20*bbf21555SRichard Lowe.Os
21*bbf21555SRichard Lowe.Sh NAME
22*bbf21555SRichard Lowe.Nm prnio
23*bbf21555SRichard Lowe.Nd generic printer interface
24*bbf21555SRichard Lowe.Sh SYNOPSIS
25*bbf21555SRichard Lowe.In sys/prnio.h
26*bbf21555SRichard Lowe.Sh DESCRIPTION
27*bbf21555SRichard LoweThe
28*bbf21555SRichard Lowe.Nm
29*bbf21555SRichard Lowegeneric printer interface defines ioctl commands and data
30*bbf21555SRichard Lowestructures for printer device drivers.
31*bbf21555SRichard Lowe.Pp
32*bbf21555SRichard Lowe.Nm
33*bbf21555SRichard Lowedefines and provides facilities for five basic phases of the printing process:
34*bbf21555SRichard Lowe.Bl -bullet -offset indent
35*bbf21555SRichard Lowe.It
36*bbf21555SRichard LoweIdentification \(em Retrieve device information/attributes
37*bbf21555SRichard Lowe.It
38*bbf21555SRichard LoweSetup \(em Set device attributes
39*bbf21555SRichard Lowe.It
40*bbf21555SRichard LoweTransfer \(em Transfer data to or from the device
41*bbf21555SRichard Lowe.It
42*bbf21555SRichard LoweCleanup \(em Transfer phase conclusion
43*bbf21555SRichard Lowe.It
44*bbf21555SRichard LoweAbort \(em Transfer phase interruption
45*bbf21555SRichard Lowe.El
46*bbf21555SRichard Lowe.Pp
47*bbf21555SRichard LoweDuring the Identification phase, the application retrieves a set of device
48*bbf21555SRichard Lowecapabilities and additional information using the
49*bbf21555SRichard Lowe.Dv PRNIOC_GET_IFCAP ,
50*bbf21555SRichard Lowe.Dv PRNIOC_GET_STATUS ,
51*bbf21555SRichard Lowe.Dv PRNIOC_GET_TIMEOUTS ,
52*bbf21555SRichard Lowe.Dv PRNIOC_GET_IFINFO ,
53*bbf21555SRichard Loweand
54*bbf21555SRichard Lowe.Dv PRNIOC_GET_1284_DEVID
55*bbf21555SRichard Lowecommands.
56*bbf21555SRichard Lowe.Pp
57*bbf21555SRichard LoweDuring the Setup phase the application sets some interface attributes and
58*bbf21555SRichard Loweprobably resets the printer as described in the
59*bbf21555SRichard Lowe.Dv PRNIOC_SET_IFCAP ,
60*bbf21555SRichard Lowe.Dv PRNIOC_SET_TIMEOUTS ,
61*bbf21555SRichard Loweand
62*bbf21555SRichard Lowe.Dv PRNIOC_RESET
63*bbf21555SRichard Lowesections.
64*bbf21555SRichard Lowe.Pp
65*bbf21555SRichard LoweDuring the Transfer phase, data is transferred in a forward (host to
66*bbf21555SRichard Loweperipheral) or reverse direction (peripheral to host).
67*bbf21555SRichard LoweTransfer is accomplished
68*bbf21555SRichard Loweusing
69*bbf21555SRichard Lowe.Xr write 2
70*bbf21555SRichard Loweand
71*bbf21555SRichard Lowe.Xr read 2
72*bbf21555SRichard Lowesystem calls.
73*bbf21555SRichard LoweFor
74*bbf21555SRichard Lowe.Nm
75*bbf21555SRichard Lowecompliant
76*bbf21555SRichard Loweprinter drivers, forward transfer support is mandatory, while reverse transfer
77*bbf21555SRichard Lowesupport is optional.
78*bbf21555SRichard LoweApplications can also use
79*bbf21555SRichard Lowe.Dv PRNIOC_GET_STATUS
80*bbf21555SRichard Loweand
81*bbf21555SRichard Lowe.Dv PRNIOC_GET_1284_STATUS
82*bbf21555SRichard Lowecommands during the transfer to monitor the device state.
83*bbf21555SRichard Lowe.Pp
84*bbf21555SRichard LoweThe Cleanup phase is accomplished by closing the device using
85*bbf21555SRichard Lowe.Xr close 2 .
86*bbf21555SRichard LoweDevice drivers supporting
87*bbf21555SRichard Lowe.Nm
88*bbf21555SRichard Lowemay set non-zero error code as appropriate.
89*bbf21555SRichard LoweApplications should explicitly
90*bbf21555SRichard Lowe.Xr close 2
91*bbf21555SRichard Lowea device before
92*bbf21555SRichard Loweexiting and check
93*bbf21555SRichard Lowe.Va errno
94*bbf21555SRichard Lowevalue.
95*bbf21555SRichard Lowe.Pp
96*bbf21555SRichard LoweThe Abort phase is accomplished by interrupting the
97*bbf21555SRichard Lowe.Xr write 2
98*bbf21555SRichard Loweand
99*bbf21555SRichard Lowe.Xr read 2
100*bbf21555SRichard Lowesystem calls.
101*bbf21555SRichard LoweThe application can perform some additional cleanup
102*bbf21555SRichard Loweduring the Abort phase as described in
103*bbf21555SRichard Lowe.Dv PRNIOC_GET_IFCAP
104*bbf21555SRichard Lowesection.
105*bbf21555SRichard Lowe.Sh IOCTLS
106*bbf21555SRichard Lowe.Bl -tag -width PRNIOC_GET_IFINFO
107*bbf21555SRichard Lowe.It Dv PRNIOC_GET_IFCAP
108*bbf21555SRichard LoweApplication can retrieve printer interface capabilities using this command.
109*bbf21555SRichard LoweThe
110*bbf21555SRichard Lowe.Xr ioctl 2
111*bbf21555SRichard Loweargument is a pointer to
112*bbf21555SRichard Lowe.Vt uint_t ,
113*bbf21555SRichard Lowea bit field representing
114*bbf21555SRichard Lowea set of properties and services provided by a printer driver.
115*bbf21555SRichard LoweSet bit means supported capability.
116*bbf21555SRichard LoweThe following values are defined:
117*bbf21555SRichard Lowe.Bl -tag -width PRN_1284_STATUS
118*bbf21555SRichard Lowe.It Dv PRN_BIDI
119*bbf21555SRichard LoweWhen this bit is set, the interface operates in a
120*bbf21555SRichard Lowebidirectional mode, instead of forward-only mode.
121*bbf21555SRichard Lowe.It Dv PRN_HOTPLUG
122*bbf21555SRichard LoweIf this bit is set, the interface allows device hot-plugging.
123*bbf21555SRichard Lowe.It Dv PRN_1284_DEVID
124*bbf21555SRichard LoweIf this bit is set, the device is capable of returning
125*bbf21555SRichard Lowe.Em 1284
126*bbf21555SRichard Lowedevice ID (see
127*bbf21555SRichard Lowe.Dv PRNIOC_GET_1284_DEVID ) .
128*bbf21555SRichard Lowe.It Dv PRN_1284_STATUS
129*bbf21555SRichard LoweIf this bit is set, the device driver can return device
130*bbf21555SRichard Lowestatus lines (see
131*bbf21555SRichard Lowe.Dv PRNIOC_GET_1284_STATUS ) .
132*bbf21555SRichard LoweSome devices support this
133*bbf21555SRichard Loweioctl in unidirectional mode only.
134*bbf21555SRichard Lowe.It Dv PRN_TIMEOUTS
135*bbf21555SRichard LoweIf this bit is set the peripheral may stall during the
136*bbf21555SRichard Lowetransfer phase and the driver can timeout and return from the
137*bbf21555SRichard Lowe.Xr write 2
138*bbf21555SRichard Loweand
139*bbf21555SRichard Lowe.Xr read 2
140*bbf21555SRichard Lowereturning the number of bytes that have been transferred.
141*bbf21555SRichard LoweIf
142*bbf21555SRichard Lowe.Dv PRN_TIMEOUTS
143*bbf21555SRichard Loweis set, the driver supports this functionality and the
144*bbf21555SRichard Lowetimeout values can be retrieved and modified via the
145*bbf21555SRichard Lowe.Dv PRNIOC_GET_TIMEOUTS
146*bbf21555SRichard Loweand
147*bbf21555SRichard Lowe.Dv PRNIOC_SET_TIMEOUTS
148*bbf21555SRichard Loweioctls.
149*bbf21555SRichard LoweOtherwise, applications can implement
150*bbf21555SRichard Lowetheir own timeouts and abort phase.
151*bbf21555SRichard Lowe.It Dv PRN_STREAMS
152*bbf21555SRichard LoweThis bit impacts the application abort phase behaviour.
153*bbf21555SRichard LoweIf the device claimed
154*bbf21555SRichard Lowe.Dv PRN_STREAMS
155*bbf21555SRichard Lowecapability, the application must issue an
156*bbf21555SRichard Lowe.Dv I_FLUSH
157*bbf21555SRichard Lowe.Xr ioctl 2
158*bbf21555SRichard Lowebefore
159*bbf21555SRichard Lowe.Xr close 2
160*bbf21555SRichard Loweto dismiss the untransferred
161*bbf21555SRichard Lowedata.
162*bbf21555SRichard LoweOnly STREAMS drivers can support this capability.
163*bbf21555SRichard Lowe.El
164*bbf21555SRichard Lowe.It Dv PRNIOC_SET_IFCAP
165*bbf21555SRichard LoweThis ioctl can be used to change interface capabilities.
166*bbf21555SRichard LoweThe argument is a pointer to
167*bbf21555SRichard Lowe.Vt uint_t
168*bbf21555SRichard Lowebit field that is described in detail in the
169*bbf21555SRichard Lowe.Dv PRNIOC_GET_IFCAP
170*bbf21555SRichard Lowesection.
171*bbf21555SRichard LoweCapabilities should be set one at a time;
172*bbf21555SRichard Loweotherwise the command will return
173*bbf21555SRichard Lowe.Er EINVAL .
174*bbf21555SRichard LoweThe following capabilities can be changed by this ioctl:
175*bbf21555SRichard Lowe.Bl -tag -width PRN_BIDI
176*bbf21555SRichard Lowe.It Dv PRN_BIDI
177*bbf21555SRichard LoweWhen this capability is set, the interface operates in a
178*bbf21555SRichard Lowebidirectional mode, instead of forward-only mode.
179*bbf21555SRichard LoweDevices that support only one
180*bbf21555SRichard Lowemode will not return error; applications should use
181*bbf21555SRichard Lowe.Dv PRNIOC_GET_IFCAP
182*bbf21555SRichard Loweto check if the mode was successfully changed.
183*bbf21555SRichard LoweBecause some capabilities may be
184*bbf21555SRichard Lowealtered as a side effect of changing other capabilities, this command should be
185*bbf21555SRichard Lowefollowed by
186*bbf21555SRichard Lowe.Dv PRNIOC_GET_IFCAP .
187*bbf21555SRichard Lowe.El
188*bbf21555SRichard Lowe.It Dv PRNIOC_GET_IFINFO
189*bbf21555SRichard LoweThis command can be used to retrieve printer interface info string, which is an
190*bbf21555SRichard Lowearbitrary format string usually describing the bus type.
191*bbf21555SRichard LoweThe argument is a
192*bbf21555SRichard Lowepointer to
193*bbf21555SRichard Lowe.Vt struct prn_interface_info
194*bbf21555SRichard Loweas described below.
195*bbf21555SRichard Lowe.Bd -literal -offset 2n
196*bbf21555SRichard Lowestruct prn_interface_info {
197*bbf21555SRichard Lowe  uint_t	  if_len;   /* length of buffer */
198*bbf21555SRichard Lowe  uint_t	  if_rlen;  /* actual info length */
199*bbf21555SRichard Lowe  char   *if_data;          /* buffer address */
200*bbf21555SRichard Lowe};
201*bbf21555SRichard Lowe.Ed
202*bbf21555SRichard Lowe.Pp
203*bbf21555SRichard LoweThe application allocates a buffer and sets
204*bbf21555SRichard Lowe.Fa if_data
205*bbf21555SRichard Loweand
206*bbf21555SRichard Lowe.Fa if_len
207*bbf21555SRichard Lowevalues to its address and length, respectively.
208*bbf21555SRichard LoweThe driver returns the string
209*bbf21555SRichard Loweto this buffer and sets
210*bbf21555SRichard Lowe.Fa if_len
211*bbf21555SRichard Loweto its length.
212*bbf21555SRichard LoweIf
213*bbf21555SRichard Lowe.Fa if_len
214*bbf21555SRichard Loweis less
215*bbf21555SRichard Lowethan
216*bbf21555SRichard Lowe.Fa if_rlen ,
217*bbf21555SRichard Lowethe driver must return the first
218*bbf21555SRichard Lowe.Fa if_len
219*bbf21555SRichard Lowebytes of the string.
220*bbf21555SRichard LoweThe application may then repeat the command with a bigger buffer.
221*bbf21555SRichard Lowe.Pp
222*bbf21555SRichard LoweAlthough
223*bbf21555SRichard Lowe.Nm
224*bbf21555SRichard Lowedoes not limit the contents of the interface info string,
225*bbf21555SRichard Lowesome values are recommended and defined in
226*bbf21555SRichard Lowe.In sys/prnio.h
227*bbf21555SRichard Loweby the following macros:
228*bbf21555SRichard Lowe.Pp
229*bbf21555SRichard Lowe.Bl -tag -width PRN_PARALLEL -compact
230*bbf21555SRichard Lowe.It Dv PRN_PARALLEL
231*bbf21555SRichard LoweCentronics or
232*bbf21555SRichard Lowe.Em IEEE 1284
233*bbf21555SRichard Lowecompatible devices
234*bbf21555SRichard Lowe.It Dv PRN_SERIAL
235*bbf21555SRichard LoweEIA-232/EIA-485 serial ports
236*bbf21555SRichard Lowe.It Dv PRN_USB
237*bbf21555SRichard LoweUniversal Serial Bus printers
238*bbf21555SRichard Lowe.It Dv PRN_1394
239*bbf21555SRichard Lowe.Em IEEE 1394
240*bbf21555SRichard Loweperipherals
241*bbf21555SRichard Lowe.El
242*bbf21555SRichard Lowe.Pp
243*bbf21555SRichard LowePrinter interface info string is for information only: no implications should
244*bbf21555SRichard Lowebe made from its value.
245*bbf21555SRichard Lowe.It Dv PRNIOC_RESET
246*bbf21555SRichard LoweSome applications may want to reset the printer state during Setup and/or
247*bbf21555SRichard LoweCleanup phase using
248*bbf21555SRichard Lowe.Dv PRNIOC_RESET
249*bbf21555SRichard Lowecommand.
250*bbf21555SRichard LoweReset semantics are
251*bbf21555SRichard Lowedevice-specific, and in general, applications using this command should be
252*bbf21555SRichard Loweaware of the printer type.
253*bbf21555SRichard Lowe.Pp
254*bbf21555SRichard LoweEach
255*bbf21555SRichard Lowe.Nm
256*bbf21555SRichard Lowecompliant driver is required to accept this request, although
257*bbf21555SRichard Loweperformed actions are completely driver-dependent.
258*bbf21555SRichard LoweMore information on the
259*bbf21555SRichard Lowe.Dv PRNIOC_RESET
260*bbf21555SRichard Loweimplementation for the particular driver is available in the
261*bbf21555SRichard Lowecorresponding man page and printer manual.
262*bbf21555SRichard Lowe.It Dv PRNIOC_GET_1284_DEVID
263*bbf21555SRichard LoweThis command can be used to retrieve printer device ID as defined by
264*bbf21555SRichard Lowe.Em IEEE 1284-1994 .
265*bbf21555SRichard LoweThe
266*bbf21555SRichard Lowe.Xr ioctl 2
267*bbf21555SRichard Loweargument is a pointer to
268*bbf21555SRichard Lowe.Vt struct prn_1284_device_id
269*bbf21555SRichard Loweas described below.
270*bbf21555SRichard Lowe.Bd -literal -offset 2n
271*bbf21555SRichard Lowestruct prn_1284_device_id {
272*bbf21555SRichard Lowe   uint_t	  id_len;   /* length of buffer */
273*bbf21555SRichard Lowe   uint_t	  id_rlen;  /* actual ID length */
274*bbf21555SRichard Lowe   char           *id_data; /* buffer address */
275*bbf21555SRichard Lowe};
276*bbf21555SRichard Lowe.Ed
277*bbf21555SRichard Lowe.Pp
278*bbf21555SRichard LoweFor convenience, the two-byte length field is not considered part of device ID
279*bbf21555SRichard Lowestring and is not returned in the user buffer.
280*bbf21555SRichard LoweInstead,
281*bbf21555SRichard Lowe.Fa id_rlen
282*bbf21555SRichard Lowevalue shall be set to (length - 2) by the driver, where length is the ID
283*bbf21555SRichard Lowelength field value.
284*bbf21555SRichard LoweIf buffer length is less than
285*bbf21555SRichard Lowe.Fa id_rlen ,
286*bbf21555SRichard Lowethe driver returns the first
287*bbf21555SRichard Lowe.Fa id_len
288*bbf21555SRichard Lowebytes of the ID.
289*bbf21555SRichard Lowe.Pp
290*bbf21555SRichard LoweThe printer driver must return the most up-to-date value of the device ID.
291*bbf21555SRichard Lowe.It Dv PRNIOC_GET_STATUS
292*bbf21555SRichard LoweThis command can be used by applications to retrieve current device status.
293*bbf21555SRichard LoweThe argument is a pointer to
294*bbf21555SRichard Lowe.Vt uint_t ,
295*bbf21555SRichard Lowewhere the status word is returned.
296*bbf21555SRichard LoweStatus is a combination of the following bits:
297*bbf21555SRichard Lowe.Bl -tag -width PRN_ONLINE
298*bbf21555SRichard Lowe.It Dv PRN_ONLINE
299*bbf21555SRichard LoweFor devices that support
300*bbf21555SRichard Lowe.Dv PRN_HOTPLUG
301*bbf21555SRichard Lowecapability, this bit is set when the device is online, otherwise the device is
302*bbf21555SRichard Loweoffline.
303*bbf21555SRichard LoweDevices without
304*bbf21555SRichard Lowe.Dv PRN_HOTPLUG
305*bbf21555SRichard Lowesupport should always have this bit set.
306*bbf21555SRichard Lowe.It Dv PRN_READY
307*bbf21555SRichard LoweThis bit indicates if the device is ready to receive/send data.
308*bbf21555SRichard LoweApplications may use this bit for an outbound flow control.
309*bbf21555SRichard Lowe.El
310*bbf21555SRichard Lowe.It Dv PRNIOC_GET_1284_STATUS
311*bbf21555SRichard LoweDevices that support
312*bbf21555SRichard Lowe.Dv PRN_1284_STATUS
313*bbf21555SRichard Lowecapability accept this ioctl to
314*bbf21555SRichard Loweretrieve the device status lines defined in
315*bbf21555SRichard Lowe.Em IEEE 1284
316*bbf21555SRichard Lowefor use in Compatibility mode.
317*bbf21555SRichard LoweThe following bits may be set by the driver:
318*bbf21555SRichard Lowe.Pp
319*bbf21555SRichard Lowe.Bl -tag -width PRN_1284_NOFAULT -compact
320*bbf21555SRichard Lowe.It Dv PRN_1284_NOFAULT
321*bbf21555SRichard LoweDevice is not in error state
322*bbf21555SRichard Lowe.It Dv PRN_1284_SELECT
323*bbf21555SRichard LoweDevice is selected
324*bbf21555SRichard Lowe.It Dv PRN_1284_PE
325*bbf21555SRichard LowePaper error
326*bbf21555SRichard Lowe.It Dv PRN_1284_BUSY
327*bbf21555SRichard LoweDevice is busy
328*bbf21555SRichard Lowe.El
329*bbf21555SRichard Lowe.It Dv PRNIOC_GET_TIMEOUTS
330*bbf21555SRichard LoweThis command retrieves current transfer timeout values for the driver.
331*bbf21555SRichard LoweThe argument is a pointer to
332*bbf21555SRichard Lowe.Vt struct prn_timeouts
333*bbf21555SRichard Loweas described below.
334*bbf21555SRichard Lowe.Bd -literal -offset 2n
335*bbf21555SRichard Lowestruct prn_timeouts {
336*bbf21555SRichard Lowe    uint_t tmo_forward; /* forward transfer timeout */
337*bbf21555SRichard Lowe    uint_t tmo_reverse; /* reverse transfer timeout */
338*bbf21555SRichard Lowe};
339*bbf21555SRichard Lowe.Ed
340*bbf21555SRichard Lowe.Pp
341*bbf21555SRichard Lowe.Fa tmo_forward
342*bbf21555SRichard Loweand
343*bbf21555SRichard Lowe.Fa tmo_reverse
344*bbf21555SRichard Lowedefine forward and reverse transfer timeouts in seconds.
345*bbf21555SRichard LoweThis command is only valid for drivers that support
346*bbf21555SRichard Lowe.Dv PRN_TIMEOUTS
347*bbf21555SRichard Lowecapability.
348*bbf21555SRichard Lowe.It Dv PRNIOC_SET_TIMEOUTS
349*bbf21555SRichard LoweThis command sets current transfer timeout values for the driver.
350*bbf21555SRichard LoweThe argument is a pointer to
351*bbf21555SRichard Lowe.Vt struct prn_timeouts .
352*bbf21555SRichard LoweSee
353*bbf21555SRichard Lowe.Sx PRNIOC_GET_TIMEOUTS
354*bbf21555SRichard Lowefor description of this structure.
355*bbf21555SRichard LoweThis command is only valid for drivers that support
356*bbf21555SRichard Lowe.Dv PRN_TIMEOUTS
357*bbf21555SRichard Lowecapability.
358*bbf21555SRichard Lowe.El
359*bbf21555SRichard Lowe.Sh SEE ALSO
360*bbf21555SRichard Lowe.Xr close 2 ,
361*bbf21555SRichard Lowe.Xr ioctl 2 ,
362*bbf21555SRichard Lowe.Xr read 2 ,
363*bbf21555SRichard Lowe.Xr write 2 ,
364*bbf21555SRichard Lowe.Xr ecpp 4D ,
365*bbf21555SRichard Lowe.Xr lp 4D ,
366*bbf21555SRichard Lowe.Xr usbprn 4D ,
367*bbf21555SRichard Lowe.Xr attributes 7
368*bbf21555SRichard Lowe.Rs
369*bbf21555SRichard Lowe.%T IEEE Std 1284-1994
370*bbf21555SRichard Lowe.Re
371