1 '\" te
   2 .\" Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved
   3 .\" 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.
   4 .\" 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.
   5 .\" 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]
   6 .TH USBPRN 7D "May 17, 2020"
   7 .SH NAME
   8 usbprn \- USB printer class driver
   9 .SH SYNOPSIS
  10 .nf
  11 #include <sys/usb/clients/printer/usb_printer.h>
  12 .fi
  13 
  14 .LP
  15 .nf
  16 #include <sys/ecppio.h>
  17 .fi
  18 
  19 .LP
  20 .nf
  21 usbprn@unit-address
  22 .fi
  23 
  24 .SH DESCRIPTION
  25 The \fBusbprn\fR driver is a USBA (Solaris USB Architecture) compliant client
  26 driver that supports the \fIUSB Printer Class 1.0\fR specification. The
  27 \fBusbprn\fR driver supports a subset of the \fBecpp\fR(7D) parallel port
  28 driver functionality. However, unlike the STREAMS-based \fBecpp\fR driver,
  29 \fBusbprn\fR is a character driver.
  30 .sp
  31 .LP
  32 The \fBusbprn\fR driver supports all USB printer-class compliant printers.
  33 .sp
  34 .LP
  35 The \fBusbrpn\fR driver includes support for communicating with many different
  36 printers. To use these printers, it may be necessary to install and configure
  37 additional format conversion packages available in the Solaris distribution.
  38 Configuration of these conversion packages under the Solaris printing system
  39 can be simplified through the use of the \fBprintmgr\fR(1M). This tool allows
  40 selection of printer manufacturer/model information while creating a print
  41 queue. For USB connected printers, it attempts to pre-select the
  42 manufacturer and model information based on the 1284 device id supplied by the
  43 printer.
  44 .SS "UGEN (Generic USB)"
  45 The \fBusbprn\fR driver also supports a \fBugen\fR(7D) interface allowing raw
  46 access to the device, for example by libusb applications, by
  47 passing the drivers bound to each interface. Because a libusb application might
  48 change the state of the device, you should not access the device through the
  49 child interface drivers.
  50 .SH DEFAULT OPERATION
  51 With certain minor exceptions (outlined in the Notes sections below), the
  52 \fBusbprn\fR driver supports a subset of the \fBecpp\fR(7D) ioctl interfaces:
  53 .sp
  54 .LP
  55 Configuration variables are set to their default values each time the USB
  56 printer device is attached. The \fBwrite_timeout\fR period (defined in the
  57 ECPPIOC_SETPARMS ioctl description below) is set to 90 seconds. The mode is set
  58 to centronics mode (ECPP_CENTRONICS). Parameters can be changed through the
  59 ECPPIOC_SETPARMS ioctl and read through the ECPPIOC_GETPARMS ioctl. Each time
  60 the USB printer device is opened, the device is marked as busy and all further
  61 opens will return EBUSY. Once the device is open, applications can write to the
  62 device and the driver can send data and obtain device id and status.
  63 .LP
  64 Note -
  65 .sp
  66 .RS 2
  67 Unlike the \fBecpp\fR(7D) driver, \fBusbprn\fR resets configuration variables
  68 to their default values with each \fBattach\fR(9E). (The \fBecpp\fR(7D) driver
  69 resets configuration variables with each \fBopen\fR(2).)
  70 .RE
  71 .SH WRITE OPERATION
  72 A \fBwrite\fR(2) operation returns the number of bytes successfully written to
  73 the device. If a failure occurs while a driver is transferring data to printer,
  74 the contents of the status bits are captured at the time of the error and can
  75 be retrieved by the application program using the ECPPIOC_GETERR \fBioctl\fR(2)
  76 call. The captured status information is overwritten each time an
  77 ECPPIOC_TESTIO \fBioctl\fR(2) occurs.
  78 .SH IOCTLS
  79 The \fBusbprn\fR driver supports \fBprnio\fR(7I) interfaces. Note that the
  80 \fBPRNIOC_RESET\fR command has no effect on USB printers.
  81 .sp
  82 .LP
  83 The following \fBioctl\fR(2) calls are supported for backward compatibility and
  84 are not recommended for new applications.
  85 .sp
  86 .ne 2
  87 .na
  88 \fB\fBECPPIOC_GETPARMS\fR\fR
  89 .ad
  90 .RS 20n
  91 Gets current transfer parameters. The argument is a pointer to \fBstruct
  92 ecpp_transfer_parms\fR. If parameters are not configured after the device is
  93 opened, the structure will be set to its default configuration.
  94 .LP
  95 Note -
  96 .sp
  97 .RS 2
  98 Unlike the \fBecpp\fR(7D) driver, only the ECPP_CENTRONICS mode is currently
  99 supported in \fBusbprn\fR.
 100 .RE
 101 .RE
 102 
 103 .sp
 104 .ne 2
 105 .na
 106 \fB\fBECPPIOC_SETPARMS\fR\fR
 107 .ad
 108 .RS 20n
 109 Sets transfer parameters. The argument is a pointer to a \fBstruct
 110 ecpp_transfer_parms\fR. If a parameter is out of range, \fBEINVAL\fR is
 111 returned. If the peripheral or host device cannot support the requested mode,
 112 \fBEPROTONOSUPPORT\fR is returned.
 113 .sp
 114 The transfer parameters structure is defined in <\fBsys/ecppio.h\fR>:
 115 .sp
 116 .in +2
 117 .nf
 118 struct ecpp_transfer_parms {
 119     int  write_timeout;
 120     int  mode;
 121 };
 122 .fi
 123 .in -2
 124 
 125 The \fBwrite_timeout\fR field, which specifies how long the driver will take to
 126 transfer 8192 bytes of data to the device, is set to a default value of 90
 127 seconds. The \fBwrite_timeout\fR field must be greater than one second and less
 128 than 300 seconds (five minutes.)
 129 .LP
 130 Note -
 131 .sp
 132 .RS 2
 133 Unlike the \fBecpp\fR(7D) driver, only the ECPP_CENTRONICS mode is currently
 134 supported in \fBusbprn\fR. Also, the semantics of \fBwrite_timeout\fR in
 135 \fBusbprn\fR differ from \fBecpp\fR(7D). Refer to \fBecpp\fR(7D) for
 136 information.
 137 .RE
 138 .RE
 139 
 140 .sp
 141 .ne 2
 142 .na
 143 \fB\fBBPPIOC_TESTIO\fR\fR
 144 .ad
 145 .RS 20n
 146 Tests the transfer readiness of a print device and checks status bits to
 147 determine if a \fBwrite\fR(2) will succeed. If status bits are set, a transfer
 148 will fail. If a transfer will succeed, zero is returned. If a transfer fails,
 149 the driver returns \fBEIO\fR and the state of the status bits are captured. The
 150 captured status can be retrieved using the BPPIOC_GETERR \fBioctl\fR(2) call.
 151 .LP
 152 Note -
 153 .sp
 154 .RS 2
 155 Unlike the \fBecpp\fR(7D) driver, only the ECPP_CENTRONICS mode is currently
 156 supported in \fBusbprn\fR. Additionally, \fBbus_error\fR and
 157 \fBtimeout_occurred\fR fields are not used in the \fBusbprn\fR interface. (In
 158 \fBecpp\fR(7D), \fBtimeout_occurred\fR is used.)
 159 .RE
 160 .RE
 161 
 162 .sp
 163 .ne 2
 164 .na
 165 \fB\fBBPPIOC_GETERR\fR\fR
 166 .ad
 167 .RS 20n
 168 Get last error status. The argument is a pointer to a \fBstruct
 169 bpp_error_status\fR. This structure indicates the status of all the appropriate
 170 status bits at the time of the most recent error condition during a
 171 \fBwrite\fR(2) call, or the status of the bits at the most recent BPPIOC_TESTIO
 172 \fBioctl\fR(2) call.
 173 .sp
 174 .in +2
 175 .nf
 176 struct bpp_error_status {
 177    char    timeout_occurred; /* not used */
 178    char    bus_error;        /* not used */
 179    uchar_t pin_status;       /* status of pins which
 180                              /* could cause error */
 181 };
 182 .fi
 183 .in -2
 184 
 185 The pin_status field indicates possible error conditions. The error status
 186 structure \fBbpp_error_status\fR is defined in the include file
 187 \fB<sys/bpp_io.h>\fR\&. The valid bits for \fBpin_status\fR can be
 188 \fBBPP_ERR_ERR\fR, \fBBPP_SLCT_ERR\fR, and \fBBPP_PE_ERR\fR. A set bit
 189 indicates that the associated pin is asserted.
 190 .LP
 191 Note -
 192 .sp
 193 .RS 2
 194 Unlike the \fBecpp\fR(7D) driver, only the ECPP_CENTRONICS mode is currently
 195 supported in \fBusbprn\fR. Additionally, the \fBbus_error\fR and
 196 \fBtimeout_occurred\fR fields are not used in the \fBusbprn\fR interface. (In
 197 \fBecpp\fR(7D), \fBtimeout_occurred\fR is used.) Unlike \fBecpp\fR(7D), the
 198 BPP_BUSY_ERR status bit is not supported by USB printers.
 199 .RE
 200 .RE
 201 
 202 .sp
 203 .ne 2
 204 .na
 205 \fB\fBECPPIOC_GETDEVID\fR\fR
 206 .ad
 207 .RS 20n
 208 Gets the IEEE 1284 device ID from the peripheral. The argument is a pointer to
 209 a \fBstruct ecpp_device_id\fR. Applications should set mode to ECPP_CENTRONICS.
 210 If another mode is used, the driver will return \fBEPROTONOSUPPORT\fR.
 211 \fBlen\fR is the length of the buffer pointed to by \fBaddr\fR. \fBrlen\fR is
 212 the actual length of the device ID string returned from the peripheral. If the
 213 returned \fBrlen\fR is greater than \fBlen\fR, the application should call
 214 ECPPIOC_GETDEVID a second time with a buffer length equal to \fBrlen\fR.
 215 .sp
 216 The 1284 device ID structure:
 217 .sp
 218 .in +2
 219 .nf
 220 struct ecpp_device_id {
 221   int  mode; /* mode to use for reading device id */
 222   int  len;  /* length of buffer */
 223   int  rlen;  /* actual length of device id string */
 224   char *addr; /* buffer address */
 225 .fi
 226 .in -2
 227 
 228 .LP
 229 Note -
 230 .sp
 231 .RS 2
 232 Unlike \fBecpp\fR(7D), only the ECPP_CENTRONICS mode is currently supported in
 233 \fBusbprn\fR.
 234 .RE
 235 .RE
 236 
 237 .SH READ OPERATION
 238 The \fBread\fR operation is not supported and returns \fBEIO\fR.
 239 .SH ERRORS
 240 .ne 2
 241 .na
 242 \fB\fBEBUSY\fR\fR
 243 .ad
 244 .RS 19n
 245 The device has been opened and another open is attempted. An attempt has been
 246 made to unload the driver while one of the units is open.
 247 .RE
 248 
 249 .sp
 250 .ne 2
 251 .na
 252 \fB\fBEINVAL\fR\fR
 253 .ad
 254 .RS 19n
 255 An unsupported IOCTL has been received. A ECPPIOC_SETPARMS \fBioctl\fR(2) is
 256 attempted with an out of range value in the \fBecpp_transfer_parms\fR
 257 structure.
 258 .RE
 259 
 260 .sp
 261 .ne 2
 262 .na
 263 \fB\fBEIO\fR\fR
 264 .ad
 265 .RS 19n
 266 The driver has received an unrecoverable device error, or the device is not
 267 responding, or the device has stalled when attempting an access. A
 268 \fBwrite\fR(2) or \fBioctl\fR(2) did not complete due to a peripheral access. A
 269 \fBread\fR(2) system call has been issued.
 270 .RE
 271 
 272 .sp
 273 .ne 2
 274 .na
 275 \fB\fBENXIO\fR\fR
 276 .ad
 277 .RS 19n
 278 The driver has received an \fBopen\fR(2) request for a unit for which the
 279 attach failed.
 280 .RE
 281 
 282 .sp
 283 .ne 2
 284 .na
 285 \fB\fBENODEV\fR\fR
 286 .ad
 287 .RS 19n
 288 The driver has received an \fBopen\fR(2) request for a device that has been
 289 disconnected.
 290 .RE
 291 
 292 .sp
 293 .ne 2
 294 .na
 295 \fB\fBEPROTONOSUPPORT\fR\fR
 296 .ad
 297 .RS 19n
 298 The driver has received a ECPPIOC_SETPARMS \fBioctl\fR(2) for a mode argument
 299 other than ECPP_CENTRONICS in the \fBecpp_transfer_parms\fR structure.
 300 .RE
 301 
 302 .SH FILES
 303 .ne 2
 304 .na
 305 \fB\fB/kernel/drv/usbprn\fR\fR
 306 .ad
 307 .RS 30n
 308 32-bit x86 ELF kernel module
 309 .RE
 310 
 311 .sp
 312 .ne 2
 313 .na
 314 \fB\fB/kernel/drv/amd64/usbprn\fR\fR
 315 .ad
 316 .RS 30n
 317 64-bit x86 ELF kernel module
 318 .RE
 319 
 320 .sp
 321 .ne 2
 322 .na
 323 \fB\fB/kernel/drv/sparcv9/usbprn\fR\fR
 324 .ad
 325 .RS 30n
 326 64-bit SPARC ELF kernel module
 327 .RE
 328 
 329 .sp
 330 .ne 2
 331 .na
 332 \fB/dev/usb/*/*/* \fR
 333 .ad
 334 .RS 30n
 335 ugen(7D) nodes.
 336 .RE
 337 
 338 .sp
 339 .ne 2
 340 .na
 341 \fB\fB/dev/printers/\fIn\fR\fR\fR
 342 .ad
 343 .RS 30n
 344 Character special files
 345 .RE
 346 
 347 .SH ATTRIBUTES
 348 See \fBattributes\fR(5) for descriptions of the following attributes:
 349 .sp
 350 
 351 .sp
 352 .TS
 353 box;
 354 c | c
 355 l | l .
 356 ATTRIBUTE TYPE  ATTRIBUTE VALUE
 357 _
 358 Architecture    SPARC, x86, PCI-based systems
 359 .TE
 360 
 361 .SH SEE ALSO
 362 \fBcfgadm_usb\fR(1M), \fBprintmgr\fR(1M), \fBioctl\fR(2), \fBopen\fR(2),
 363 \fBread\fR(2), \fBwrite\fR(2), \fBattributes\fR(5),
 364 \fBecpp\fR(7D), \fBugen\fR(7D), \fBusba\fR(7D), \fBprnio\fR(7I),
 365 \fBattach\fR(9E)
 366 .sp
 367 .LP
 368 \fIWriting Device Drivers\fR
 369 .sp
 370 .LP
 371 \fIUniversal Serial Bus Specification 1.0 and 1.1\fR
 372 .sp
 373 .LP
 374 \fIUSB Device Class Definition for Printing Devices 1.0\fR
 375 .sp
 376 .LP
 377 \fISystem Administration Guide: Basic Administration\fR
 378 .SH DIAGNOSTICS
 379 In addition to being logged, the following messages may appear on the system
 380 console. All messages are formatted in the following manner:
 381 .sp
 382 .in +2
 383 .nf
 384 Warning: <device path> (usbprn<instance num>): Error Message...
 385 .fi
 386 .in -2
 387 .sp
 388 
 389 .sp
 390 .ne 2
 391 .na
 392 \fBDevice was disconnected while open. Data may have been lost.\fR
 393 .ad
 394 .sp .6
 395 .RS 4n
 396 The device has been hot-removed or powered off while it was open and a possible
 397 data transfer was in progress. The job may be aborted.
 398 .RE
 399 
 400 .sp
 401 .ne 2
 402 .na
 403 \fBCannot access <device>. Please reconnect.\fR
 404 .ad
 405 .sp .6
 406 .RS 4n
 407 There was an error in accessing the printer during reconnect. Please reconnect
 408 the device.
 409 .RE
 410 
 411 .sp
 412 .ne 2
 413 .na
 414 \fBDevice is not identical to the previous one on this port. Please disconnect
 415 and reconnect.\fR
 416 .ad
 417 .sp .6
 418 .RS 4n
 419 A USB printer was hot-removed while open. A new device was hot-inserted which
 420 is not identical to the original USB printer. Please disconnect the USB device
 421 and reconnect the printer to the same port.
 422 .RE
 423 
 424 .sp
 425 .ne 2
 426 .na
 427 \fBPrinter has been reconnected but data may have been lost.\fR
 428 .ad
 429 .sp .6
 430 .RS 4n
 431 The printer that was hot-removed from its USB port has been re-inserted again
 432 to the same port. It is available for access but the job that was running prior
 433 to the hot-removal may be lost.
 434 .RE
 435 
 436 .SH NOTES
 437 The USB printer will be power managed if the device is closed.
 438 .sp
 439 .LP
 440 If a printer is hot-removed before a job completes, the job is terminated and
 441 the driver will return EIO. All subsequent opens will return \fBENODEV\fR. If a
 442 printer is hot-removed, an LP reconfiguration may not be needed if a printer is
 443 re-inserted on the same port. If re-inserted on a different port, an LP
 444 reconfiguration may be required.
 445 .sp
 446 .LP
 447 The USB Parallel Printer Adapter is not hotpluggable. The printer should be
 448 connected to USB Parallel Printer Adapter before plugging the USB cable into
 449 host or hub port and should be removed only after disconnecting the USB cable
 450 of USB Parallel Printer Adapter from the host or hub port.