| 1 | /* |
| 2 | * Shinko/Sinfonia CHC-S6145 CUPS backend |
| 3 | * |
| 4 | * (c) 2015-2024 Solomon Peachy <[email protected]> |
| 5 | * |
| 6 | * Low-level documentation was provided by Sinfonia. Thank you! |
| 7 | * |
| 8 | * The latest version of this program can be found at: |
| 9 | * |
| 10 | * https://git.shaftnet.org/gitea/slp/selphy_print.git |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify it |
| 13 | * under the terms of the GNU General Public License as published by the Free |
| 14 | * Software Foundation; either version 2 of the License, or (at your option) |
| 15 | * any later version. |
| 16 | * |
| 17 | * This program is distributed in the hope that it will be useful, but |
| 18 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 19 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 20 | * for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License |
| 23 | * along with this program; if not, see <https://www.gnu.org/licenses/>. |
| 24 | * |
| 25 | * An additional permission is granted, under the GPLv3 section 7, to combine |
| 26 | * and/or redistribute this program with the proprietary libS6145ImageProcess |
| 27 | * and S2245IP libraries, providing you have *written permission* from Sinfonia |
| 28 | * Technology Co. LTD to use and/or redistribute that library. |
| 29 | * |
| 30 | * You must still adhere to all other terms of the license to this program |
| 31 | * (ie GPLv3) and the license of the libS6145ImageProcess/S2245IP libraries. |
| 32 | * |
| 33 | * SPDX-License-Identifier: GPL-2.0+ with special exception |
| 34 | * |
| 35 | */ |
| 36 | |
| 37 | #define BACKEND shinkos6145_backend |
| 38 | |
| 39 | #include "backend_common.h" |
| 40 | #include "backend_sinfonia.h" |
| 41 | |
| 42 | #include <time.h> |
| 43 | #include <stdbool.h> |
| 44 | |
| 45 | #ifndef WITH_DYNAMIC |
| 46 | #warning "No dynamic loading support!" |
| 47 | #endif |
| 48 | |
| 49 | /* Image processing library function prototypes */ |
| 50 | typedef void (*dump_announceFN)(FILE *fp); |
| 51 | |
| 52 | typedef int (*ImageProcessingFN)(unsigned char *, unsigned short *, void *); |
| 53 | typedef int (*ImageAvrCalcFN)(const unsigned char *, unsigned short, unsigned short, unsigned char *); |
| 54 | |
| 55 | #define LIB6145_NAME "libS6145ImageProcess" DLL_SUFFIX // Official library |
| 56 | #define LIB6145_NAME_RE "libS6145ImageReProcess" DLL_SUFFIX // Reimplemented library |
| 57 | |
| 58 | #define S6145_CORRDATA_HEADDOTS_OFFSET 8834 |
| 59 | #define S6145_CORRDATA_WIDTH_OFFSET 12432 |
| 60 | #define S6145_CORRDATA_HEIGHT_OFFSET 12434 |
| 61 | #define S6145_CORRDATA_EXTRA_LEN 4 |
| 62 | |
| 63 | #define S2245_CORRDATA_HEADER_MODE_OFFSET (64+7) |
| 64 | |
| 65 | typedef bool (*ip_imageProcFN)(uint16_t *destData, uint8_t *srcInRgb, |
| 66 | uint16_t width, uint16_t height, void *srcIpp); |
| 67 | typedef bool (*ip_checkIppFN)(uint16_t width, uint16_t height, void *srcIpp); |
| 68 | typedef bool (*ip_getMemorySizeFN)(uint32_t *szMemory, |
| 69 | uint16_t width, uint16_t height, |
| 70 | void *srcIpp); |
| 71 | |
| 72 | #define LIB2245_NAME "libS2245ImageProcess" DLL_SUFFIX // Official library |
| 73 | #define LIB2245_NAME_RE "libS2245ImageReProcess" DLL_SUFFIX // Reimplemented library |
| 74 | |
| 75 | enum { |
| 76 | S_IDLE = 0, |
| 77 | S_PRINTER_READY_CMD, |
| 78 | S_PRINTER_SENT_DATA, |
| 79 | S_FINISHED, |
| 80 | }; |
| 81 | |
| 82 | /* Structs for printer */ |
| 83 | struct s6145_print_cmd { |
| 84 | struct sinfonia_cmd_hdr hdr; |
| 85 | uint8_t id; |
| 86 | uint16_t count; |
| 87 | uint16_t columns; |
| 88 | uint16_t rows; |
| 89 | uint8_t media; /* reserved in docs, but brava21 uses this */ |
| 90 | uint8_t combo_wait; |
| 91 | uint8_t reserved[6]; |
| 92 | uint8_t unk_1; /* Brava 21 sets this to 1 */ |
| 93 | uint8_t method; |
| 94 | uint8_t image_avg; |
| 95 | } __attribute__((packed)); |
| 96 | |
| 97 | |
| 98 | struct s6245_errorlog_resp { |
| 99 | struct sinfonia_status_hdr hdr; |
| 100 | uint16_t error_count; // @10 |
| 101 | uint8_t reserved_12; // @12 |
| 102 | uint8_t error_major; // @13 |
| 103 | uint8_t error_minor; // @14 |
| 104 | uint8_t reserved_15; // @15 |
| 105 | uint16_t ribbon_remain; // @16 /* 4x6 */ |
| 106 | uint8_t reserved_18[2];// @18 |
| 107 | uint16_t boot_fw_ver; // @20 |
| 108 | uint16_t main_fw_ver; // @22 |
| 109 | uint16_t dsp_fw_ver; // @24 |
| 110 | uint16_t tables_ver; // @26 |
| 111 | uint32_t print_counter; // @28 |
| 112 | uint8_t unkb[42]; // @32 |
| 113 | |
| 114 | /* on 6245 series, these additional fields: |
| 115 | uint8_t ribbon_takeup_diameter; |
| 116 | uint8_t ribbon_supply_diameter; |
| 117 | uint8_t time_sec; |
| 118 | uint8_t time_min; |
| 119 | uint8_t time_hour; |
| 120 | uint8_t time_day; |
| 121 | uint8_t time_month; |
| 122 | uint8_t time_year; |
| 123 | uint8_t printer_thermistor; |
| 124 | uint8_t head_thermistor; |
| 125 | uint8_t printer_humidity; |
| 126 | uint8_t status; |
| 127 | uint16_t image_cols; |
| 128 | uint16_t image_rows; |
| 129 | */ |
| 130 | } __attribute__((packed)); |
| 131 | |
| 132 | STATIC_ASSERT(sizeof(struct s6245_errorlog_resp) == 74); |
| 133 | |
| 134 | static const struct sinfonia_param s6145_params[] = |
| 135 | { |
| 136 | { PARAM_OC_PRINT, "Overcoat Mode" }, |
| 137 | { PARAM_PAPER_PRESV, "Paper Preserve Mode" }, |
| 138 | { PARAM_DRIVER_MODE, "Driver Mode/Wizard" }, |
| 139 | { PARAM_PAPER_MODE, "Paper Load Mode" }, |
| 140 | { PARAM_SLEEP_TIME, "Sleep Time" }, |
| 141 | { PARAM_REGION_CODE, "Region Code" }, |
| 142 | }; |
| 143 | #define s6145_params_num (sizeof(s6145_params) / sizeof(struct sinfonia_param)) |
| 144 | |
| 145 | static const struct sinfonia_param s2245_params[] = |
| 146 | { |
| 147 | { PARAM_DRIVER_MODE, "Driver Mode/Wizard" }, |
| 148 | { PARAM_PAPER_MODE, "Paper Load Mode" }, |
| 149 | }; |
| 150 | #define s2245_params_num (sizeof(s2245_params) / sizeof(struct sinfonia_param)) |
| 151 | |
| 152 | // CHC-S6145 |
| 153 | #define PARAM_OC_PRINT_OFF 0x00000001 |
| 154 | #define PARAM_OC_PRINT_GLOSS 0x00000002 |
| 155 | #define PARAM_OC_PRINT_MATTE 0x00000003 |
| 156 | |
| 157 | // CHC-S6145-5A |
| 158 | #define PARAM_PRINTM_OC_OFF 0x00000001 |
| 159 | #define PARAM_PRINTM_OC_GLOSS 0x00000002 |
| 160 | #define PARAM_PRINTM_OC_MATTE 0x00000012 |
| 161 | #define PARAM_PRINTM_STD 0x00000000 |
| 162 | #define PARAM_PRINTM_FINE 0x00000004 |
| 163 | #define PARAM_PRINTM_FAST 0x00000008 |
| 164 | |
| 165 | // S6145 |
| 166 | #define PARAM_PAPER_PRESV_OFF 0x00000000 |
| 167 | #define PARAM_PAPER_PRESV_ON 0x00000001 |
| 168 | |
| 169 | static const char *s6145_error_codes(uint8_t major, uint8_t minor) |
| 170 | { |
| 171 | switch(major) { |
| 172 | case 0x01: /* "Controller Error" */ |
| 173 | switch(minor) { |
| 174 | case 0x01: |
| 175 | return "Controller: EEPROM Write Timeout"; |
| 176 | case 0x0A: |
| 177 | return "Controller: Invalid Print Parameter Table"; |
| 178 | case 0x0C: |
| 179 | return "Controller: Print Parameter Table Mismatch"; |
| 180 | case 0x0F: |
| 181 | return "Controller: Main FW Checksum"; |
| 182 | case 0x10: |
| 183 | return "Controller: Flash Write Failed"; |
| 184 | case 0x13: |
| 185 | return "Controller: Print Parameter Table Checksum"; |
| 186 | case 0x14: |
| 187 | return "Controller: Print Parameter Table Write Failed"; |
| 188 | case 0x15: |
| 189 | return "Controller: User Tone Curve Write Failed"; |
| 190 | case 0x16: |
| 191 | return "Controller: MSP Communication"; |
| 192 | case 0x17: |
| 193 | return "Controller: THV Autotuning"; |
| 194 | case 0x18: |
| 195 | return "Controller: THV Value Out of Range"; |
| 196 | case 0x19: |
| 197 | return "Controller: Thermal Head"; |
| 198 | case 0x1A: |
| 199 | return "Controller: Wake from Power Save Failed"; |
| 200 | default: |
| 201 | return "Controller: Unknown"; |
| 202 | } |
| 203 | case 0x02: /* "Mechanical Error" */ |
| 204 | switch (minor) { |
| 205 | case 0x01: |
| 206 | return "Mechanical: Pinch Head Home"; |
| 207 | case 0x02: |
| 208 | return "Mechanical: Pinch Head (position 1)"; |
| 209 | case 0x03: |
| 210 | return "Mechanical: Pinch Head (position 2)"; |
| 211 | case 0x04: |
| 212 | return "Mechanical: Pinch Head (position 3)"; |
| 213 | case 0x0B: |
| 214 | return "Mechanical: Cutter (Right)"; |
| 215 | case 0x0C: |
| 216 | return "Mechanical: Cutter (Left)"; |
| 217 | default: |
| 218 | return "Mechanical: Unknown"; |
| 219 | } |
| 220 | case 0x03: /* "Sensor Error" */ |
| 221 | switch (minor) { |
| 222 | case 0x01: |
| 223 | return "Sensor: Head Up"; |
| 224 | case 0x02: |
| 225 | return "Sensor: Head Down"; |
| 226 | case 0x0B: |
| 227 | return "Sensor: Cutter Left"; |
| 228 | case 0x0C: |
| 229 | return "Sensor: Cutter Right"; |
| 230 | case 0x0D: |
| 231 | return "Sensor: Cutter Left+Right"; |
| 232 | case 0x15: |
| 233 | return "Sensor: Head Up Unstable"; |
| 234 | case 0x16: |
| 235 | return "Sensor: Head Down Unstable"; |
| 236 | case 0x17: |
| 237 | return "Sensor: Cutter Left Unstable"; |
| 238 | case 0x18: |
| 239 | return "Sensor: Cutter Right Unstable"; |
| 240 | case 0x19: |
| 241 | return "Sensor: Cover Open Unstable"; |
| 242 | case 0x1E: |
| 243 | return "Sensor: Ribbon Mark (Cyan)"; |
| 244 | case 0x1F: |
| 245 | return "Sensor: Ribbon Mark (OC)"; |
| 246 | default: |
| 247 | return "Sensor: Unknown"; |
| 248 | } |
| 249 | case 0x04: /* "Temperature Sensor Error" */ |
| 250 | switch (minor) { |
| 251 | case 0x01: |
| 252 | return "Temp Sensor: Thermal Head Low"; |
| 253 | case 0x02: |
| 254 | return "Temp Sensor: Thermal Head High"; |
| 255 | case 0x05: |
| 256 | return "Temp Sensor: Environment Low"; |
| 257 | case 0x06: |
| 258 | return "Temp Sensor: Environment High"; |
| 259 | case 0x07: |
| 260 | return "Temp Sensor: Preheat"; |
| 261 | case 0x08: |
| 262 | return "Temp Sensor: Thermal Protect"; |
| 263 | default: |
| 264 | return "Temp Sensor: Unknown"; |
| 265 | } |
| 266 | case 0x5: /* "Paper Jam" */ |
| 267 | switch (minor) { |
| 268 | case 0x01: |
| 269 | return "Paper Jam: Loading Paper Top On"; |
| 270 | case 0x02: |
| 271 | return "Paper Jam: Loading Print Position On"; |
| 272 | case 0x03: |
| 273 | return "Paper Jam: Loading Print Position Off"; |
| 274 | case 0x04: |
| 275 | return "Paper Jam: Loading Paper Top Off"; |
| 276 | case 0x05: |
| 277 | return "Paper Jam: Loading Cut Print Position Off"; |
| 278 | case 0x0C: |
| 279 | return "Paper Jam: Initializing Print Position Off"; |
| 280 | case 0x0D: |
| 281 | return "Paper Jam: Initializing Print Position On"; |
| 282 | case 0x15: |
| 283 | return "Paper Jam: Printing Print Position Off"; |
| 284 | case 0x16: |
| 285 | return "Paper Jam: Printing Paper Top On"; |
| 286 | case 0x17: |
| 287 | return "Paper Jam: Printing Paper Top Off"; |
| 288 | case 0x1F: |
| 289 | return "Paper Jam: Precut Print Position Off"; |
| 290 | case 0x20: |
| 291 | return "Paper Jam: Precut Print Position On"; |
| 292 | |
| 293 | case 0x29: |
| 294 | return "Paper Jam: Printing Paper Top On"; |
| 295 | case 0x2A: |
| 296 | return "Paper Jam: Printing Pre-Yellow Print Position Off"; |
| 297 | case 0x2B: |
| 298 | return "Paper Jam: Printing Yellow Print Position Off"; |
| 299 | case 0x2C: |
| 300 | return "Paper Jam: Printing Yellow Print Position On"; |
| 301 | case 0x2D: |
| 302 | return "Paper Jam: Printing Pre-Magenta Print Position Off"; |
| 303 | case 0x2E: |
| 304 | return "Paper Jam: Printing Magenta Print Position On"; |
| 305 | case 0x2F: |
| 306 | return "Paper Jam: Printing Magenta Print Position Off"; |
| 307 | case 0x30: |
| 308 | return "Paper Jam: Printing Pre-Cyan Print Position Off"; |
| 309 | case 0x31: |
| 310 | return "Paper Jam: Printing Cyan Print Position On"; |
| 311 | case 0x32: |
| 312 | return "Paper Jam: Printing Cyan Print Position Off"; |
| 313 | case 0x33: |
| 314 | return "Paper Jam: Printing Pre-OC Print Position Off"; |
| 315 | case 0x34: |
| 316 | return "Paper Jam: Printing OC Print Position On"; |
| 317 | case 0x35: |
| 318 | return "Paper Jam: Printing OC Print Position Off"; |
| 319 | case 0x36: |
| 320 | return "Paper Jam: Cut Print Position Off"; |
| 321 | case 0x37: |
| 322 | return "Paper Jam: Home Position Off"; |
| 323 | case 0x38: |
| 324 | return "Paper Jam: Paper Top Off"; |
| 325 | case 0x39: |
| 326 | return "Paper Jam: Print Position On"; |
| 327 | |
| 328 | case 0x51: |
| 329 | return "Paper Jam: Paper Empty On, Top On, Position On"; |
| 330 | case 0x52: |
| 331 | return "Paper Jam: Paper Empty On, Top On, Position Off"; |
| 332 | case 0x54: |
| 333 | return "Paper Jam: Paper Empty On, Top Off, Position Off"; |
| 334 | case 0x60: |
| 335 | return "Paper Jam: Cutter Right"; |
| 336 | case 0x61: |
| 337 | return "Paper Jam: Cutter Left"; |
| 338 | |
| 339 | default: |
| 340 | return "Paper Jam: Unknown"; |
| 341 | } |
| 342 | case 0x06: /* User Error */ |
| 343 | switch (minor) { |
| 344 | case 0x01: |
| 345 | return "Drawer Unit Open"; |
| 346 | case 0x02: |
| 347 | return "Incorrect Ribbon"; |
| 348 | case 0x04: |
| 349 | return "Ribbon Empty"; |
| 350 | case 0x08: |
| 351 | return "No Paper"; |
| 352 | case 0x0C: |
| 353 | return "Paper End"; |
| 354 | default: |
| 355 | return "Unknown"; |
| 356 | } |
| 357 | default: |
| 358 | return "Unknown"; |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | static const char *s2245_error_codes(uint8_t major, uint8_t minor) |
| 363 | { |
| 364 | switch(major) { |
| 365 | case 0x01: /* "Controller Error" */ |
| 366 | switch(minor) { |
| 367 | case 0x01: |
| 368 | return "Controller: EEPROM Write Timeout"; |
| 369 | case 0x0A: |
| 370 | return "Controller: Invalid Print Parameter Table"; |
| 371 | case 0x0C: |
| 372 | return "Controller: Print Parameter Table Mismatch"; |
| 373 | case 0x0F: |
| 374 | return "Controller: Main FW Data Error"; |
| 375 | case 0x10: |
| 376 | return "Controller: Main FW Write Failed"; |
| 377 | case 0x13: |
| 378 | return "Controller: Print Parameter Table Checksum"; |
| 379 | case 0x14: |
| 380 | return "Controller: Print Parameter Table Write Failed"; |
| 381 | case 0x15: |
| 382 | return "Controller: User Tone Curve Write Failed"; |
| 383 | case 0x16: |
| 384 | return "Controller: MSP Communication"; |
| 385 | case 0x19: |
| 386 | return "Controller: Thermal Head"; |
| 387 | default: |
| 388 | return "Controller: Unknown"; |
| 389 | } |
| 390 | case 0x02: /* "Mechanical Error" */ |
| 391 | switch (minor) { |
| 392 | case 0x01: |
| 393 | return "Mechanical: Pinch Head Home"; |
| 394 | case 0x02: |
| 395 | return "Mechanical: Pinch Head (position 1)"; |
| 396 | case 0x03: |
| 397 | return "Mechanical: Pinch Head (position 2)"; |
| 398 | case 0x04: |
| 399 | return "Mechanical: Pinch Head (position 3)"; |
| 400 | case 0x05: |
| 401 | return "Mechanical: Pinch Head (position 4)"; |
| 402 | case 0x14: |
| 403 | return "Mechanical: Cutter (Left-Right)"; |
| 404 | case 0x15: |
| 405 | return "Mechanical: Cutter (Right-Left)"; |
| 406 | default: |
| 407 | return "Mechanical: Unknown"; |
| 408 | } |
| 409 | case 0x03: /* "Sensor Error" */ |
| 410 | switch (minor) { |
| 411 | case 0x01: |
| 412 | return "Sensor: Cutter Left+Right"; |
| 413 | case 0x02: |
| 414 | return "Sensor: Cutter Left drove"; |
| 415 | case 0x03: |
| 416 | return "Sensor: Cutter Right drove"; |
| 417 | case 0x1E: |
| 418 | return "Sensor: Left Front Lock"; |
| 419 | case 0x1F: |
| 420 | return "Sensor: Right Front Lock"; |
| 421 | case 0x20: |
| 422 | return "Sensor: Cutter Left"; |
| 423 | case 0x21: |
| 424 | return "Sensor: Cutter Right"; |
| 425 | case 0x22: |
| 426 | return "Sensor: Left Head/Pinch"; |
| 427 | case 0x23: |
| 428 | return "Sensor: Right Head/Pinch"; |
| 429 | case 0x24: |
| 430 | return "Sensor: Head/Pinch Encoder"; |
| 431 | case 0x25: |
| 432 | return "Sensor: Supply Ribbon Encoder"; |
| 433 | default: |
| 434 | return "Sensor: Unknown"; |
| 435 | } |
| 436 | case 0x04: /* "Temperature Sensor Error" */ |
| 437 | switch (minor) { |
| 438 | case 0x01: |
| 439 | return "Temp Sensor: Thermal Head Low"; |
| 440 | case 0x02: |
| 441 | return "Temp Sensor: Thermal Head High"; |
| 442 | case 0x05: |
| 443 | return "Temp Sensor: Environment Low"; |
| 444 | case 0x06: |
| 445 | return "Temp Sensor: Environment High"; |
| 446 | case 0x07: |
| 447 | return "Temp Sensor: Preheat"; |
| 448 | case 0x08: |
| 449 | return "Temp Sensor: Thermal Protect"; |
| 450 | default: |
| 451 | return "Temp Sensor: Unknown"; |
| 452 | } |
| 453 | case 0x5: /* "Paper Jam" */ |
| 454 | switch (minor) { |
| 455 | case 0x01: |
| 456 | return "Paper Jam: Paper Not Detected"; |
| 457 | case 0x02: |
| 458 | return "Paper Jam: Pinch Roller Fail"; |
| 459 | case 0x10: |
| 460 | return "Paper Jam: Print Position Sensor on"; |
| 461 | case 0x11: |
| 462 | return "Paper Jam: Print Position Sensor off"; |
| 463 | case 0x12: |
| 464 | return "Paper Jam: Paper End Sensor on"; |
| 465 | case 0x13: |
| 466 | return "Paper Jam: Paper Cut"; |
| 467 | case 0x30: |
| 468 | return "Paper Jam: Print Position Sensor early"; |
| 469 | case 0x31: |
| 470 | return "Paper Jam: Print Position Sensor on"; |
| 471 | case 0x32: |
| 472 | return "Paper Jam: Print Position Sensor off"; |
| 473 | case 0x40: |
| 474 | return "Paper Jam: Cutter Left-Right"; |
| 475 | case 0x41: |
| 476 | return "Paper Jam: Cutter Right-Left"; |
| 477 | case 0x51: |
| 478 | return "Paper Jam: Paper End On, Position Off"; |
| 479 | case 0x52: |
| 480 | return "Paper Jam: Paper End Off, Position On"; |
| 481 | case 0x53: |
| 482 | return "Paper Jam: Paper End On, Position On"; |
| 483 | default: |
| 484 | return "Paper Jam: Unknown"; |
| 485 | } |
| 486 | case 0x06: /* User Error */ |
| 487 | switch (minor) { |
| 488 | case 0x01: |
| 489 | return "Cover Open"; |
| 490 | case 0x02: |
| 491 | return "Cover Not Closed"; |
| 492 | case 0x03: |
| 493 | return "Incorrect Ribbon"; |
| 494 | case 0x04: |
| 495 | return "Ribbon End"; |
| 496 | case 0x07: |
| 497 | return "No Paper"; |
| 498 | case 0x08: |
| 499 | return "Paper End"; |
| 500 | case 0x0D: |
| 501 | return "No Ribbon"; |
| 502 | case 0x0E: |
| 503 | return "Ribbon Rewind Failure"; |
| 504 | case 0x0F: |
| 505 | return "Ribbon Sense Failure"; |
| 506 | case 0x20: |
| 507 | return "THV Tuning"; |
| 508 | case 0x21: |
| 509 | return "THV Not Tuned"; |
| 510 | default: |
| 511 | return "Unknown"; |
| 512 | } |
| 513 | default: |
| 514 | return "Unknown"; |
| 515 | } |
| 516 | } |
| 517 | |
| 518 | #define RIBBON_NONE 0x00 |
| 519 | #define RIBBON_4x6 0x01 |
| 520 | #define RIBBON_3_5x5 0x02 |
| 521 | #define RIBBON_5x7 0x03 |
| 522 | #define RIBBON_6x8 0x04 |
| 523 | #define RIBBON_6x9 0x05 |
| 524 | |
| 525 | #define RIBBON_89x60mm 0x01 |
| 526 | |
| 527 | static int ribbon_sizes (uint8_t v, uint8_t is_card, uint8_t is_2245) { |
| 528 | if (is_card) { |
| 529 | return 450; |
| 530 | } |
| 531 | |
| 532 | switch (v) { |
| 533 | case RIBBON_4x6: |
| 534 | if (is_2245) |
| 535 | return 900; |
| 536 | else |
| 537 | return 300; |
| 538 | case RIBBON_3_5x5: |
| 539 | return 340; |
| 540 | case RIBBON_5x7: |
| 541 | return 170; |
| 542 | case RIBBON_6x8: |
| 543 | if (is_2245) |
| 544 | return 450; |
| 545 | else |
| 546 | return 150; |
| 547 | case RIBBON_6x9: |
| 548 | return 130; // XXX guessed |
| 549 | default: |
| 550 | if (is_2245) |
| 551 | return 450; |
| 552 | else |
| 553 | return 300; |
| 554 | } |
| 555 | } |
| 556 | |
| 557 | static const char *print_ribbons (uint8_t v, uint8_t is_card) { |
| 558 | if (is_card) { |
| 559 | if (v == RIBBON_89x60mm) |
| 560 | return "89x60mm"; |
| 561 | else if (v == RIBBON_NONE) |
| 562 | return "None"; |
| 563 | else |
| 564 | return "Unknown"; |
| 565 | } |
| 566 | |
| 567 | switch (v) { |
| 568 | case RIBBON_NONE: |
| 569 | return "None"; |
| 570 | case RIBBON_4x6: |
| 571 | return "4x6"; |
| 572 | case RIBBON_3_5x5: |
| 573 | return "3.5x5"; |
| 574 | case RIBBON_5x7: |
| 575 | return "5x7"; |
| 576 | case RIBBON_6x8: |
| 577 | return "6x8"; |
| 578 | case RIBBON_6x9: |
| 579 | return "6x9"; |
| 580 | default: |
| 581 | return "Unknown"; |
| 582 | } |
| 583 | } |
| 584 | |
| 585 | struct s6145_imagecorr_resp { |
| 586 | struct sinfonia_status_hdr hdr; |
| 587 | uint16_t total_size; |
| 588 | } __attribute__((packed)); |
| 589 | |
| 590 | struct s2245_imagecorr_req { |
| 591 | struct sinfonia_cmd_hdr hdr; |
| 592 | uint8_t options; |
| 593 | uint8_t flags; |
| 594 | uint8_t null[10]; |
| 595 | } __attribute__((packed)); |
| 596 | |
| 597 | #define S2245_IMAGECORR_FLAG_CONTOUR_ENH 0x01 |
| 598 | |
| 599 | struct s2245_imagecorr_resp { |
| 600 | struct sinfonia_status_hdr hdr; |
| 601 | uint32_t total_size; |
| 602 | } __attribute__((packed)); |
| 603 | |
| 604 | struct s6145_imagecorr_data { |
| 605 | uint8_t remain_pkt; |
| 606 | uint8_t return_size; /* Always 0x10 */ |
| 607 | uint8_t data[16]; |
| 608 | } __attribute__((packed)); |
| 609 | |
| 610 | /* Private data structure */ |
| 611 | struct shinkos6145_ctx { |
| 612 | struct sinfonia_usbdev dev; |
| 613 | |
| 614 | uint8_t jobid; |
| 615 | |
| 616 | uint8_t image_avg[3]; /* YMC */ |
| 617 | |
| 618 | char serial[32]; |
| 619 | char fwver[32]; |
| 620 | |
| 621 | int is_card; /* card printer model */ |
| 622 | int is_2245; /* 2245 or its variants */ |
| 623 | |
| 624 | struct marker marker; |
| 625 | |
| 626 | struct sinfonia_6x45_mediainfo_resp media; |
| 627 | |
| 628 | uint8_t *eeprom; |
| 629 | size_t eepromlen; |
| 630 | |
| 631 | void *dl_handle; |
| 632 | |
| 633 | dump_announceFN DumpAnnounce; |
| 634 | ImageProcessingFN ImageProcessing; |
| 635 | ImageAvrCalcFN ImageAvrCalc; |
| 636 | |
| 637 | ip_imageProcFN ip_imageProc; |
| 638 | ip_checkIppFN ip_checkIpp; |
| 639 | ip_getMemorySizeFN ip_getMemorySize; |
| 640 | |
| 641 | void *corrdata; /* Correction table */ |
| 642 | uint16_t corrdatalen; |
| 643 | }; |
| 644 | |
| 645 | static const char *s2245_drivermodes(uint8_t val); |
| 646 | static int shinkos2245_get_imagecorr(struct shinkos6145_ctx *ctx, uint8_t options); |
| 647 | static int shinkos6145_get_imagecorr(struct shinkos6145_ctx *ctx); |
| 648 | static int shinkos6145_get_eeprom(struct shinkos6145_ctx *ctx); |
| 649 | |
| 650 | static int get_status(struct shinkos6145_ctx *ctx) |
| 651 | { |
| 652 | struct sinfonia_cmd_hdr cmd; |
| 653 | struct sinfonia_status_resp resp; |
| 654 | struct sinfonia_getextcounter_resp resp2; |
| 655 | int ret, num = 0; |
| 656 | uint32_t val; |
| 657 | |
| 658 | cmd.cmd = cpu_to_le16(SINFONIA_CMD_GETSTATUS); |
| 659 | cmd.len = cpu_to_le16(0); |
| 660 | |
| 661 | if ((ret = sinfonia_docmd(&ctx->dev, |
| 662 | (uint8_t*)&cmd, sizeof(cmd), |
| 663 | (uint8_t*)&resp, sizeof(resp), &num)) < 0) { |
| 664 | return ret; |
| 665 | } |
| 666 | |
| 667 | INFO("Printer Status: 0x%02x (%s)\n", resp.hdr.status, |
| 668 | sinfonia_status_str(resp.hdr.status)); |
| 669 | if (resp.hdr.status == ERROR_PRINTER) { |
| 670 | if(resp.hdr.error == ERROR_NONE) |
| 671 | resp.hdr.error = resp.hdr.status; |
| 672 | INFO(" Error 0x%02x (%s) 0x%02x/0x%02x (%s)\n", |
| 673 | resp.hdr.error, |
| 674 | sinfonia_error_str(resp.hdr.error), |
| 675 | resp.hdr.printer_major, |
| 676 | resp.hdr.printer_minor, ctx->dev.error_codes(resp.hdr.printer_major, resp.hdr.printer_minor)); |
| 677 | } |
| 678 | if (le16_to_cpu(resp.hdr.payload_len) != (sizeof(struct sinfonia_status_resp) - sizeof(struct sinfonia_status_hdr))) |
| 679 | return -1; |
| 680 | |
| 681 | INFO(" Print Counts:\n"); |
| 682 | INFO("\tSince Paper Changed:\t%08u\n", le32_to_cpu(resp.count_paper)); |
| 683 | INFO("\tLifetime:\t\t%08u\n", le32_to_cpu(resp.count_lifetime)); |
| 684 | INFO("\tMaintenance:\t\t%08u\n", le32_to_cpu(resp.count_maint)); |
| 685 | INFO("\tPrint Head:\t\t%08u\n", le32_to_cpu(resp.count_head)); |
| 686 | INFO(" Cutter Actuations:\t%08u\n", le32_to_cpu(resp.count_cutter)); |
| 687 | INFO(" Ribbon Remaining:\t%08u\n", le32_to_cpu(resp.count_ribbon_left)); |
| 688 | INFO("Bank 1: 0x%02x (%s) Job %03u @ %03u/%03u (%03u remaining)\n", |
| 689 | resp.bank1_status, sinfonia_bank_statuses(resp.bank1_status), |
| 690 | resp.bank1_printid, |
| 691 | le16_to_cpu(resp.bank1_finished), |
| 692 | le16_to_cpu(resp.bank1_specified), |
| 693 | le16_to_cpu(resp.bank1_remaining)); |
| 694 | |
| 695 | INFO("Bank 2: 0x%02x (%s) Job %03u @ %03u/%03u (%03u remaining)\n", |
| 696 | resp.bank2_status, sinfonia_bank_statuses(resp.bank1_status), |
| 697 | resp.bank2_printid, |
| 698 | le16_to_cpu(resp.bank2_finished), |
| 699 | le16_to_cpu(resp.bank2_specified), |
| 700 | le16_to_cpu(resp.bank2_remaining)); |
| 701 | |
| 702 | INFO("Tonecurve Status: 0x%02x (%s)\n", resp.tonecurve_status, sinfonia_tonecurve_statuses(resp.tonecurve_status)); |
| 703 | |
| 704 | /* Query Extended counters */ |
| 705 | cmd.cmd = cpu_to_le16(SINFONIA_CMD_EXTCOUNTER); |
| 706 | cmd.len = cpu_to_le16(0); |
| 707 | |
| 708 | if ((ret = sinfonia_docmd(&ctx->dev, |
| 709 | (uint8_t*)&cmd, sizeof(cmd), |
| 710 | (uint8_t*)&resp2, sizeof(resp2), |
| 711 | &num))) { |
| 712 | return ret; |
| 713 | } |
| 714 | if (le16_to_cpu(resp2.hdr.payload_len) != (sizeof(struct sinfonia_getextcounter_resp) - sizeof(struct sinfonia_status_hdr))) |
| 715 | return -1; |
| 716 | |
| 717 | INFO("Lifetime Distance: %08u inches\n", le32_to_cpu(resp2.lifetime_distance)); |
| 718 | INFO("Maintenance Distance: %08u inches\n", le32_to_cpu(resp2.maint_distance)); |
| 719 | INFO("Head Distance: %08u inches\n", le32_to_cpu(resp2.head_distance)); |
| 720 | |
| 721 | /* Query various params */ |
| 722 | if (ctx->dev.conn->type == P_SHINKO_S6145D) { |
| 723 | if ((ret = sinfonia_getparam(&ctx->dev, PARAM_REGION_CODE, &val))) { |
| 724 | ERROR("Failed to execute command\n"); |
| 725 | return ret; |
| 726 | } |
| 727 | INFO("Region Code: %#x\n", val); |
| 728 | |
| 729 | } |
| 730 | if (!ctx->is_2245) { |
| 731 | if ((ret = sinfonia_getparam(&ctx->dev, PARAM_PAPER_PRESV, &val))) { |
| 732 | ERROR("Failed to execute command\n"); |
| 733 | return ret; |
| 734 | } |
| 735 | INFO("Paper Preserve mode: %s\n", (val ? "On" : "Off")); |
| 736 | } |
| 737 | if ((ret = sinfonia_getparam(&ctx->dev, PARAM_DRIVER_MODE, &val))) { |
| 738 | ERROR("Failed to execute command\n"); |
| 739 | return ret; |
| 740 | } |
| 741 | if (ctx->is_2245) { |
| 742 | INFO("Driver mode: %s\n", s2245_drivermodes(val)); |
| 743 | } else { |
| 744 | INFO("Driver mode: %s\n", (val ? "On" : "Off")); |
| 745 | } |
| 746 | |
| 747 | if ((ret = sinfonia_getparam(&ctx->dev, PARAM_PAPER_MODE, &val))) { |
| 748 | ERROR("Failed to execute command\n"); |
| 749 | return ret; |
| 750 | } |
| 751 | INFO("Paper load mode: %s\n", (val ? "Cut" : "No Cut")); |
| 752 | |
| 753 | if (!ctx->is_2245) { |
| 754 | if ((ret = sinfonia_getparam(&ctx->dev, PARAM_SLEEP_TIME, &val))) { |
| 755 | ERROR("Failed to execute command\n"); |
| 756 | return ret; |
| 757 | } |
| 758 | if (val == 0) |
| 759 | val = 5; |
| 760 | else if (val == 1) |
| 761 | val = 15; |
| 762 | else if (val == 2) |
| 763 | val = 30; |
| 764 | else if (val == 3) |
| 765 | val = 60; |
| 766 | else if (val == 4) |
| 767 | val = 120; |
| 768 | else |
| 769 | val = 240; // default? |
| 770 | |
| 771 | INFO("Sleep delay: %u minutes\n", val); |
| 772 | } |
| 773 | |
| 774 | return CUPS_BACKEND_OK; |
| 775 | } |
| 776 | |
| 777 | static void dump_mediainfo(struct sinfonia_6x45_mediainfo_resp *resp, int is_card) |
| 778 | { |
| 779 | int i; |
| 780 | |
| 781 | INFO("Loaded Media Type: %s\n", print_ribbons(resp->ribbon_code, is_card)); |
| 782 | INFO("Supported Print Sizes: %u entries:\n", resp->count); |
| 783 | for (i = 0 ; i < resp->count ; i++) { |
| 784 | INFO(" %02d: C 0x%02x (%s), %04ux%04u, P 0x%02x (%s)\n", i, |
| 785 | resp->items[i].code, |
| 786 | sinfonia_print_codes(resp->items[i].code, 0), |
| 787 | resp->items[i].columns, |
| 788 | resp->items[i].rows, |
| 789 | resp->items[i].method, |
| 790 | sinfonia_print_methods(resp->items[i].method)); |
| 791 | } |
| 792 | } |
| 793 | |
| 794 | static int shinkos6145_dump_corrdata(struct shinkos6145_ctx *ctx, const char *fname) |
| 795 | { |
| 796 | int ret; |
| 797 | |
| 798 | if (ctx->is_2245) { |
| 799 | ret = shinkos2245_get_imagecorr(ctx, 0x0a); // XXX have to supply something.. this is HQ matte. |
| 800 | } else { |
| 801 | ret = shinkos6145_get_imagecorr(ctx); |
| 802 | } |
| 803 | if (ret) { |
| 804 | ERROR("Failed to execute command\n"); |
| 805 | return ret; |
| 806 | } |
| 807 | |
| 808 | /* Open file and write it out */ |
| 809 | { |
| 810 | int fd = open(fname, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR); |
| 811 | if (fd < 0) { |
| 812 | ERROR("Unable to open filename\n"); |
| 813 | return fd; |
| 814 | } |
| 815 | |
| 816 | ret = write(fd, ctx->corrdata, ctx->corrdatalen); |
| 817 | close(fd); |
| 818 | } |
| 819 | |
| 820 | /* Free the buffers */ |
| 821 | free(ctx->corrdata); |
| 822 | ctx->corrdata = NULL; |
| 823 | ctx->corrdatalen = 0; |
| 824 | |
| 825 | return ret; |
| 826 | } |
| 827 | |
| 828 | static int shinkos6145_dump_eeprom(struct shinkos6145_ctx *ctx, const char *fname) |
| 829 | { |
| 830 | int ret; |
| 831 | |
| 832 | ret = shinkos6145_get_eeprom(ctx); |
| 833 | if (ret) { |
| 834 | ERROR("Failed to execute command\n"); |
| 835 | return ret; |
| 836 | } |
| 837 | |
| 838 | /* Open file and write it out */ |
| 839 | { |
| 840 | int fd = open(fname, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR); |
| 841 | if (fd < 0) { |
| 842 | ERROR("Unable to open filename\n"); |
| 843 | return fd; |
| 844 | } |
| 845 | |
| 846 | ret = write(fd, ctx->eeprom, ctx->eepromlen); |
| 847 | close(fd); |
| 848 | } |
| 849 | |
| 850 | /* Free the buffers */ |
| 851 | free(ctx->eeprom); |
| 852 | ctx->eeprom = NULL; |
| 853 | ctx->eepromlen = 0; |
| 854 | |
| 855 | return ret; |
| 856 | } |
| 857 | |
| 858 | static int shinkos6145_get_imagecorr(struct shinkos6145_ctx *ctx) |
| 859 | { |
| 860 | struct sinfonia_cmd_hdr cmd; |
| 861 | struct s6145_imagecorr_resp resp; |
| 862 | |
| 863 | uint16_t total = 0; |
| 864 | int ret, num; |
| 865 | cmd.cmd = cpu_to_le16(SINFONIA_CMD_GETCORR); |
| 866 | cmd.len = 0; |
| 867 | |
| 868 | if (ctx->corrdata) { |
| 869 | free(ctx->corrdata); |
| 870 | ctx->corrdata = NULL; |
| 871 | } |
| 872 | |
| 873 | if ((ret = sinfonia_docmd(&ctx->dev, |
| 874 | (uint8_t*)&cmd, sizeof(cmd), |
| 875 | (uint8_t*)&resp, sizeof(resp), |
| 876 | &num))) { |
| 877 | goto done; |
| 878 | } |
| 879 | |
| 880 | ctx->corrdatalen = le16_to_cpu(resp.total_size); |
| 881 | INFO("Fetching %u bytes of image correction data\n", ctx->corrdatalen); |
| 882 | |
| 883 | /* We need a little extra to pass arguments to the library */ |
| 884 | ctx->corrdata = malloc(ctx->corrdatalen + S6145_CORRDATA_EXTRA_LEN); |
| 885 | if (!ctx->corrdata) { |
| 886 | ERROR("Memory allocation failure\n"); |
| 887 | ret = CUPS_BACKEND_FAILED; |
| 888 | goto done; |
| 889 | } |
| 890 | memset(ctx->corrdata, 0, ctx->corrdatalen); |
| 891 | total = 0; |
| 892 | |
| 893 | while (total < ctx->corrdatalen) { |
| 894 | struct s6145_imagecorr_data data; |
| 895 | |
| 896 | ret = read_data(ctx->dev.conn, (uint8_t *) &data, |
| 897 | sizeof(data), |
| 898 | &num); |
| 899 | if (ret < 0) |
| 900 | goto done; |
| 901 | |
| 902 | memcpy(((uint8_t*)ctx->corrdata) + total, data.data, sizeof(data.data)); |
| 903 | total += sizeof(data.data); |
| 904 | |
| 905 | if (data.remain_pkt == 0) |
| 906 | DEBUG("correction block transferred (%u/%u total)\n", total, ctx->corrdatalen); |
| 907 | |
| 908 | } |
| 909 | |
| 910 | done: |
| 911 | return ret; |
| 912 | } |
| 913 | |
| 914 | static int shinkos2245_get_imagecorr(struct shinkos6145_ctx *ctx, uint8_t options) |
| 915 | { |
| 916 | struct s2245_imagecorr_req cmd; |
| 917 | struct s2245_imagecorr_resp resp; |
| 918 | |
| 919 | uint16_t total = 0; |
| 920 | int ret, num; |
| 921 | cmd.hdr.cmd = cpu_to_le16(SINFONIA_CMD_GETCORR); |
| 922 | cmd.hdr.len = sizeof(cmd) - sizeof(cmd.hdr); |
| 923 | cmd.options = options; |
| 924 | cmd.flags = S2245_IMAGECORR_FLAG_CONTOUR_ENH; // XXX make configurable? or key off a flag in the job? |
| 925 | memset(cmd.null, 0, sizeof(cmd.null)); |
| 926 | |
| 927 | if (ctx->corrdata) { |
| 928 | free(ctx->corrdata); |
| 929 | ctx->corrdata = NULL; |
| 930 | } |
| 931 | |
| 932 | if ((ret = sinfonia_docmd(&ctx->dev, |
| 933 | (uint8_t*)&cmd, sizeof(cmd), |
| 934 | (uint8_t*)&resp, sizeof(resp), |
| 935 | &num))) { |
| 936 | goto done; |
| 937 | } |
| 938 | |
| 939 | ctx->corrdatalen = le16_to_cpu(resp.total_size); |
| 940 | INFO("Fetching %u bytes of image correction data\n", ctx->corrdatalen); |
| 941 | |
| 942 | ctx->corrdata = malloc(ctx->corrdatalen); |
| 943 | if (!ctx->corrdata) { |
| 944 | ERROR("Memory allocation failure\n"); |
| 945 | ret = CUPS_BACKEND_FAILED; |
| 946 | goto done; |
| 947 | } |
| 948 | memset(ctx->corrdata, 0, ctx->corrdatalen); |
| 949 | total = 0; |
| 950 | |
| 951 | while (total < ctx->corrdatalen) { |
| 952 | struct s6145_imagecorr_data data; |
| 953 | |
| 954 | ret = read_data(ctx->dev.conn, (uint8_t *) &data, |
| 955 | sizeof(data), |
| 956 | &num); |
| 957 | if (ret < 0) |
| 958 | goto done; |
| 959 | |
| 960 | memcpy(((uint8_t*)ctx->corrdata) + total, data.data, sizeof(data.data)); |
| 961 | total += sizeof(data.data); |
| 962 | |
| 963 | if (data.remain_pkt == 0) |
| 964 | DEBUG("correction block transferred (%u/%u total)\n", total, ctx->corrdatalen); |
| 965 | |
| 966 | } |
| 967 | |
| 968 | done: |
| 969 | return ret; |
| 970 | } |
| 971 | |
| 972 | static int shinkos6145_get_eeprom(struct shinkos6145_ctx *ctx) |
| 973 | { |
| 974 | struct sinfonia_cmd_hdr cmd; |
| 975 | struct sinfonia_geteeprom_resp resp; |
| 976 | |
| 977 | int ret, num; |
| 978 | cmd.cmd = cpu_to_le16(SINFONIA_CMD_GETEEPROM); |
| 979 | cmd.len = 0; |
| 980 | |
| 981 | if (ctx->eeprom) { |
| 982 | free(ctx->eeprom); |
| 983 | ctx->eeprom = NULL; |
| 984 | } |
| 985 | |
| 986 | if ((ret = sinfonia_docmd(&ctx->dev, |
| 987 | (uint8_t*)&cmd, sizeof(cmd), |
| 988 | (uint8_t*)&resp, sizeof(resp), |
| 989 | &num))) { |
| 990 | goto done; |
| 991 | } |
| 992 | |
| 993 | ctx->eepromlen = le16_to_cpu(resp.hdr.payload_len); |
| 994 | ctx->eeprom = malloc(ctx->eepromlen); |
| 995 | if (!ctx->eeprom) { |
| 996 | ERROR("Memory allocation failure\n"); |
| 997 | ret = CUPS_BACKEND_FAILED; |
| 998 | goto done; |
| 999 | } |
| 1000 | memcpy(ctx->eeprom, resp.data, ctx->eepromlen); |
| 1001 | |
| 1002 | done: |
| 1003 | return ret; |
| 1004 | } |
| 1005 | |
| 1006 | static const char *s2245_drivermodes(uint8_t val) |
| 1007 | { |
| 1008 | switch(val) { |
| 1009 | case 0x00: |
| 1010 | return "-Class/-iSerial"; |
| 1011 | case 0x01: |
| 1012 | return "-Class/+iSerial"; |
| 1013 | case 0x02: |
| 1014 | return "+Class/-iSerial"; |
| 1015 | case 0x03: |
| 1016 | return "+Class/+iSerial"; |
| 1017 | } |
| 1018 | return "Unknown"; |
| 1019 | } |
| 1020 | |
| 1021 | static int s2245_get_errorlog(struct sinfonia_usbdev *usbh) |
| 1022 | { |
| 1023 | struct sinfonia_errorlog2_cmd cmd; |
| 1024 | struct s6245_errorlog_resp resp; |
| 1025 | int num = 0; |
| 1026 | int i = 0; |
| 1027 | |
| 1028 | cmd.hdr.cmd = cpu_to_le16(SINFONIA_CMD_ERRORLOG); |
| 1029 | cmd.hdr.len = cpu_to_le16(2); |
| 1030 | |
| 1031 | do { |
| 1032 | int ret; |
| 1033 | cmd.index = i; |
| 1034 | |
| 1035 | if ((ret = sinfonia_docmd(usbh, |
| 1036 | (uint8_t*)&cmd, sizeof(cmd), |
| 1037 | (uint8_t*)&resp, sizeof(resp), |
| 1038 | &num))) { |
| 1039 | return ret; |
| 1040 | } |
| 1041 | |
| 1042 | if (le16_to_cpu(resp.hdr.payload_len) != (sizeof(struct s6245_errorlog_resp) - sizeof(struct sinfonia_status_hdr))) |
| 1043 | return -2; |
| 1044 | |
| 1045 | INFO("Stored Error ID %d:\n", i); |
| 1046 | INFO("%08u prints : 0x%02x/0x%02x (%s)\n", |
| 1047 | le32_to_cpu(resp.print_counter), |
| 1048 | resp.error_major, resp.error_minor, |
| 1049 | usbh->error_codes(resp.error_major, resp.error_minor)); |
| 1050 | /* |
| 1051 | INFO(" %04d-%02u-%02u %02u:%02u:%02u @ %08u prints : 0x%02x/0x%02x (%s)\n", |
| 1052 | resp.time_year + 2000, resp.time_month, resp.time_day, |
| 1053 | resp.time_hour, resp.time_min, resp.time_sec, |
| 1054 | le32_to_cpu(resp.print_counter), |
| 1055 | resp.error_major, resp.error_minor, |
| 1056 | usbh->error_codes(resp.error_major, resp.error_minor)); |
| 1057 | INFO(" Temp: %02u/%02u Hum: %02u\n", |
| 1058 | resp.printer_thermistor, resp.head_thermistor, resp.printer_humidity); |
| 1059 | */ |
| 1060 | } while (++i < le16_to_cpu(resp.error_count)); |
| 1061 | |
| 1062 | return CUPS_BACKEND_OK; |
| 1063 | } |
| 1064 | |
| 1065 | static void shinkos6145_cmdline(void) |
| 1066 | { |
| 1067 | DEBUG("\t\t[ -c filename ] # Get user/NV tone curve\n"); |
| 1068 | DEBUG("\t\t[ -C filename ] # Set user/NV tone curve\n"); |
| 1069 | DEBUG("\t\t[ -e ] # Query error log\n"); |
| 1070 | DEBUG("\t\t[ -F ] # Flash Printer LED\n"); |
| 1071 | DEBUG("\t\t[ -i ] # Query printer info\n"); |
| 1072 | DEBUG("\t\t[ -k num ] # Set sleep time (5-240 minutes)\n"); |
| 1073 | DEBUG("\t\t[ -l filename ] # Get current tone curve\n"); |
| 1074 | DEBUG("\t\t[ -L filename ] # Set current tone curve\n"); |
| 1075 | DEBUG("\t\t[ -m ] # Query media\n"); |
| 1076 | DEBUG("\t\t[ -q filename ] # Extract eeprom data\n"); |
| 1077 | DEBUG("\t\t[ -Q filename ] # Extract image correction params\n"); |
| 1078 | DEBUG("\t\t[ -r ] # Reset user/NV tone curve\n"); |
| 1079 | DEBUG("\t\t[ -R ] # Reset printer to factory defaults\n"); |
| 1080 | DEBUG("\t\t[ -s ] # Query status\n"); |
| 1081 | DEBUG("\t\t[ -X jobid ] # Abort a printjob\n"); |
| 1082 | // DEBUG("\t\t[ -Z 0 | 1 ] # Dump all parameters\n"); |
| 1083 | } |
| 1084 | |
| 1085 | static int shinkos6145_cmdline_arg(void *vctx, int argc, char **argv) |
| 1086 | { |
| 1087 | struct shinkos6145_ctx *ctx = vctx; |
| 1088 | int i, j = 0; |
| 1089 | |
| 1090 | if (!ctx) |
| 1091 | return -1; |
| 1092 | |
| 1093 | while ((i = getopt(argc, argv, GETOPT_LIST_GLOBAL "c:C:eFik:l:L:mr:Q:q:rR:sX:Z:")) >= 0) { |
| 1094 | switch(i) { |
| 1095 | GETOPT_PROCESS_GLOBAL |
| 1096 | case 'c': |
| 1097 | j = sinfonia_gettonecurve(&ctx->dev, TONECURVE_USER, optarg); |
| 1098 | break; |
| 1099 | case 'C': |
| 1100 | j = sinfonia_settonecurve(&ctx->dev, UPDATE_TARGET_TONE_USER, optarg); |
| 1101 | break; |
| 1102 | case 'e': |
| 1103 | if (ctx->is_2245) { |
| 1104 | j = s2245_get_errorlog(&ctx->dev); |
| 1105 | } else { |
| 1106 | j = sinfonia_geterrorlog(&ctx->dev); |
| 1107 | } |
| 1108 | break; |
| 1109 | case 'F': |
| 1110 | j = sinfonia_flashled(&ctx->dev); |
| 1111 | break; |
| 1112 | case 'i': |
| 1113 | j = sinfonia_getfwinfo(&ctx->dev); |
| 1114 | break; |
| 1115 | case 'k': { |
| 1116 | i = atoi(optarg); |
| 1117 | if (i <= 5) |
| 1118 | i = 0; |
| 1119 | else if (i <= 15) |
| 1120 | i = 1; |
| 1121 | else if (i <= 30) |
| 1122 | i = 2; |
| 1123 | else if (i <= 60) |
| 1124 | i = 3; |
| 1125 | else if (i <= 120) |
| 1126 | i = 4; |
| 1127 | else if (i <= 240) |
| 1128 | i = 5; |
| 1129 | else |
| 1130 | i = 5; |
| 1131 | |
| 1132 | j = sinfonia_setparam(&ctx->dev, PARAM_SLEEP_TIME, i); |
| 1133 | break; |
| 1134 | } |
| 1135 | case 'l': |
| 1136 | j = sinfonia_gettonecurve(&ctx->dev, TONECURVE_CURRENT, optarg); |
| 1137 | break; |
| 1138 | case 'L': |
| 1139 | j = sinfonia_settonecurve(&ctx->dev, UPDATE_TARGET_TONE_CURRENT, optarg); |
| 1140 | break; |
| 1141 | case 'm': |
| 1142 | dump_mediainfo(&ctx->media, ctx->is_card); |
| 1143 | break; |
| 1144 | case 'q': |
| 1145 | j = shinkos6145_dump_eeprom(ctx, optarg); |
| 1146 | break; |
| 1147 | case 'Q': |
| 1148 | j = shinkos6145_dump_corrdata(ctx, optarg); |
| 1149 | break; |
| 1150 | case 'r': |
| 1151 | j = sinfonia_resetcurve(&ctx->dev, RESET_TONE_CURVE, TONE_CURVE_ID); |
| 1152 | break; |
| 1153 | case 'R': |
| 1154 | j = sinfonia_resetcurve(&ctx->dev, RESET_PRINTER, 0); |
| 1155 | break; |
| 1156 | case 's': |
| 1157 | j = get_status(ctx); |
| 1158 | break; |
| 1159 | case 'X': |
| 1160 | j = sinfonia_canceljob(&ctx->dev, atoi(optarg)); |
| 1161 | break; |
| 1162 | case 'Z': |
| 1163 | j = sinfonia_dumpallparams(&ctx->dev, atoi(optarg)); |
| 1164 | break; |
| 1165 | default: |
| 1166 | break; /* Ignore completely */ |
| 1167 | } |
| 1168 | |
| 1169 | if (j) return j; |
| 1170 | } |
| 1171 | |
| 1172 | return CUPS_BACKEND_OK; |
| 1173 | } |
| 1174 | |
| 1175 | static void *shinkos6145_init(void) |
| 1176 | { |
| 1177 | struct shinkos6145_ctx *ctx = malloc(sizeof(struct shinkos6145_ctx)); |
| 1178 | if (!ctx) { |
| 1179 | ERROR("Memory Allocation Failure!\n"); |
| 1180 | return NULL; |
| 1181 | } |
| 1182 | memset(ctx, 0, sizeof(struct shinkos6145_ctx)); |
| 1183 | |
| 1184 | DL_INIT(); |
| 1185 | |
| 1186 | return ctx; |
| 1187 | } |
| 1188 | |
| 1189 | static int shinkos6145_attach(void *vctx, struct dyesub_connection *conn, uint8_t jobid) |
| 1190 | { |
| 1191 | struct shinkos6145_ctx *ctx = vctx; |
| 1192 | |
| 1193 | ctx->dev.conn = conn; |
| 1194 | |
| 1195 | /* Mark 2245-class */ |
| 1196 | if (conn->type == P_SHINKO_S2245 || |
| 1197 | conn->type == P_KODAK_6900) { |
| 1198 | ctx->is_2245 = 1; |
| 1199 | } |
| 1200 | |
| 1201 | if (ctx->is_2245) { |
| 1202 | ctx->dev.params = s2245_params; |
| 1203 | ctx->dev.params_count = s2245_params_num; |
| 1204 | ctx->dev.error_codes = &s2245_error_codes; |
| 1205 | |
| 1206 | #if defined(WITH_DYNAMIC) |
| 1207 | DEBUG("Attempting to load S2245 image processing library\n"); |
| 1208 | ctx->dl_handle = DL_OPEN(LIB2245_NAME); /* Try the Sinfonia one first */ |
| 1209 | if (!ctx->dl_handle) |
| 1210 | ctx->dl_handle = DL_OPEN(LIB2245_NAME_RE); /* Then the RE one */ |
| 1211 | if (ctx->dl_handle) { |
| 1212 | ctx->DumpAnnounce = DL_SYM(ctx->dl_handle, "dump_announce"); |
| 1213 | ctx->ip_imageProc = DL_SYM(ctx->dl_handle, "ip_imageProc"); |
| 1214 | ctx->ip_checkIpp = DL_SYM(ctx->dl_handle, "ip_checkIpp"); |
| 1215 | ctx->ip_getMemorySize = DL_SYM(ctx->dl_handle, "ip_getMemorySize"); |
| 1216 | if (!ctx->ip_imageProc || !ctx->ip_checkIpp || !ctx->ip_getMemorySize) { |
| 1217 | WARNING("Problem resolving symbols in imaging processing library\n"); |
| 1218 | DL_CLOSE(ctx->dl_handle); |
| 1219 | ctx->dl_handle = NULL; |
| 1220 | } else { |
| 1221 | DEBUG("Image processing library successfully loaded\n"); |
| 1222 | if (!stats_only && ctx->DumpAnnounce) |
| 1223 | ctx->DumpAnnounce(logger); |
| 1224 | } |
| 1225 | } |
| 1226 | #endif |
| 1227 | } else if (conn->type == P_SHINKO_S6145 || |
| 1228 | conn->type == P_SHINKO_S6145D) { |
| 1229 | ctx->dev.params = s6145_params; |
| 1230 | ctx->dev.params_count = s6145_params_num; |
| 1231 | ctx->dev.error_codes = &s6145_error_codes; |
| 1232 | |
| 1233 | #if defined(WITH_DYNAMIC) |
| 1234 | DEBUG("Attempting to load S6145 image processing library\n"); |
| 1235 | ctx->dl_handle = DL_OPEN(LIB6145_NAME); /* Try the Sinfonia one first */ |
| 1236 | if (!ctx->dl_handle) |
| 1237 | ctx->dl_handle = DL_OPEN(LIB6145_NAME_RE); /* Then the RE one */ |
| 1238 | if (ctx->dl_handle) { |
| 1239 | ctx->DumpAnnounce = DL_SYM(ctx->dl_handle, "dump_announce"); |
| 1240 | ctx->ImageProcessing = DL_SYM(ctx->dl_handle, "ImageProcessing"); |
| 1241 | ctx->ImageAvrCalc = DL_SYM(ctx->dl_handle, "ImageAvrCalc"); |
| 1242 | if (!ctx->ImageProcessing || !ctx->ImageAvrCalc) { |
| 1243 | WARNING("Problem resolving symbols in imaging processing library\n"); |
| 1244 | DL_CLOSE(ctx->dl_handle); |
| 1245 | ctx->dl_handle = NULL; |
| 1246 | } else { |
| 1247 | DEBUG("Image processing library successfully loaded\n"); |
| 1248 | if (!stats_only && ctx->DumpAnnounce) |
| 1249 | ctx->DumpAnnounce(logger); |
| 1250 | } |
| 1251 | } |
| 1252 | #endif |
| 1253 | } |
| 1254 | |
| 1255 | #if defined(WITH_DYNAMIC) |
| 1256 | if (!ctx->dl_handle) |
| 1257 | WARNING("Image processing library not found; will NOT be able to print!\n"); |
| 1258 | #else |
| 1259 | WARNING("Image processing library cannot be loaded; will NOT be able to print!e\n"); |
| 1260 | #endif |
| 1261 | |
| 1262 | /* Ensure jobid is sane */ |
| 1263 | ctx->jobid = (jobid & 0x7f); |
| 1264 | if (!ctx->jobid) |
| 1265 | ctx->jobid++; |
| 1266 | |
| 1267 | /* Query Media */ |
| 1268 | if (test_mode < TEST_MODE_NOATTACH) { |
| 1269 | int ret = sinfonia_query_media(&ctx->dev, |
| 1270 | &ctx->media); |
| 1271 | if (ret) |
| 1272 | return ret; |
| 1273 | } else { |
| 1274 | int media_code = RIBBON_6x8; |
| 1275 | if (getenv("MEDIA_CODE")) |
| 1276 | media_code = strtol(getenv("MEDIA_CODE"), NULL, 16); |
| 1277 | |
| 1278 | ctx->media.ribbon_code = media_code; |
| 1279 | } |
| 1280 | |
| 1281 | ctx->marker.color = "#00FFFF#FF00FF#FFFF00"; |
| 1282 | ctx->marker.name = print_ribbons(ctx->media.ribbon_code, ctx->is_card); |
| 1283 | ctx->marker.numtype = ctx->media.ribbon_code; |
| 1284 | ctx->marker.levelmax = ribbon_sizes(ctx->media.ribbon_code, ctx->is_card, ctx->is_2245); |
| 1285 | ctx->marker.levelnow = CUPS_MARKER_UNKNOWN; |
| 1286 | |
| 1287 | return CUPS_BACKEND_OK; |
| 1288 | } |
| 1289 | |
| 1290 | static void shinkos6145_teardown(void *vctx) { |
| 1291 | struct shinkos6145_ctx *ctx = vctx; |
| 1292 | |
| 1293 | if (!ctx) |
| 1294 | return; |
| 1295 | |
| 1296 | if (ctx->eeprom) |
| 1297 | free(ctx->eeprom); |
| 1298 | if (ctx->corrdata) |
| 1299 | free(ctx->corrdata); |
| 1300 | if (ctx->dl_handle) |
| 1301 | DL_CLOSE(ctx->dl_handle); |
| 1302 | |
| 1303 | DL_EXIT(); |
| 1304 | |
| 1305 | free(ctx); |
| 1306 | } |
| 1307 | |
| 1308 | static int shinkos6145_read_parse(void *vctx, const void **vjob, int data_fd, int copies) { |
| 1309 | struct shinkos6145_ctx *ctx = vctx; |
| 1310 | struct sinfonia_printjob *job = NULL; |
| 1311 | int ret; |
| 1312 | int model; |
| 1313 | uint8_t input_ymc; |
| 1314 | |
| 1315 | if (!ctx) |
| 1316 | return CUPS_BACKEND_FAILED; |
| 1317 | |
| 1318 | if (ctx->dev.conn->type == P_SHINKO_S6145 || |
| 1319 | ctx->dev.conn->type == P_SHINKO_S6145D) |
| 1320 | model = 6145; |
| 1321 | else |
| 1322 | model = 2245; |
| 1323 | |
| 1324 | job = malloc(sizeof(*job)); |
| 1325 | if (!job) { |
| 1326 | ERROR("Memory allocation failure!\n"); |
| 1327 | return CUPS_BACKEND_RETRY_CURRENT; |
| 1328 | } |
| 1329 | memset(job, 0, sizeof(*job)); |
| 1330 | |
| 1331 | /* Common read/parse code */ |
| 1332 | if (ctx->dev.conn->type == P_KODAK_6900) { |
| 1333 | ret = sinfonia_raw28_read_parse(data_fd, job); |
| 1334 | } else { |
| 1335 | ret = sinfonia_read_parse(data_fd, model, job); |
| 1336 | } |
| 1337 | if (ret) { |
| 1338 | free(job); |
| 1339 | return ret; |
| 1340 | } |
| 1341 | |
| 1342 | /* Use whicever copy count is larger */ |
| 1343 | if (job->common.copies < copies) |
| 1344 | job->common.copies = copies; |
| 1345 | |
| 1346 | /* S6145 can only combine 2* 4x6 -> 8x6. |
| 1347 | 2x6 strips and 3.5x5 -> 5x7 can't. |
| 1348 | S2245 can combine 2x6 strips too! |
| 1349 | */ |
| 1350 | if (job->jp.columns == 1844 && |
| 1351 | job->jp.rows == 1240 && |
| 1352 | (ctx->media.ribbon_code == RIBBON_6x8 || |
| 1353 | ctx->media.ribbon_code == RIBBON_6x9)) { |
| 1354 | |
| 1355 | if (model == 6145 && job->jp.method == PRINT_METHOD_STD) |
| 1356 | job->common.can_combine = 1; |
| 1357 | else if (model == 2245) |
| 1358 | job->common.can_combine = 1; |
| 1359 | } |
| 1360 | |
| 1361 | /* Extended spool format to re-purpose an unused header field. |
| 1362 | When bit 0 is set, this tells the backend that the data is |
| 1363 | already in planar YMC format (vs packed RGB) so we don't need |
| 1364 | to do the conversion ourselves. Saves some processing overhead */ |
| 1365 | input_ymc = job->jp.ext_flags & EXT_FLAG_PLANARYMC; |
| 1366 | |
| 1367 | /* Convert packed RGB to planar YMC if necessary */ |
| 1368 | if (!ctx->is_2245 && !input_ymc) { |
| 1369 | INFO("Converting Packed RGB to Planar YMC\n"); |
| 1370 | int planelen = job->jp.columns * job->jp.rows; |
| 1371 | uint8_t *databuf3 = malloc(job->datalen); |
| 1372 | int i; |
| 1373 | if (!databuf3) { |
| 1374 | ERROR("Memory allocation failure!\n"); |
| 1375 | sinfonia_cleanup_job(job); |
| 1376 | return CUPS_BACKEND_RETRY_CURRENT; |
| 1377 | } |
| 1378 | for (i = 0 ; i < planelen ; i++) { |
| 1379 | uint8_t r, g, b; |
| 1380 | r = job->databuf[3*i]; |
| 1381 | g = job->databuf[3*i+1]; |
| 1382 | b = job->databuf[3*i+2]; |
| 1383 | databuf3[i] = 255 - b; |
| 1384 | databuf3[planelen + i] = 255 - g; |
| 1385 | databuf3[planelen + planelen + i] = 255 - r; |
| 1386 | } |
| 1387 | free(job->databuf); |
| 1388 | job->databuf = databuf3; |
| 1389 | } |
| 1390 | |
| 1391 | *vjob = job; |
| 1392 | |
| 1393 | return CUPS_BACKEND_OK; |
| 1394 | } |
| 1395 | |
| 1396 | #define JOB_EQUIV(__x) if (job1->__x != job2->__x) goto done |
| 1397 | |
| 1398 | static void *shinkos6145_combine_jobs(const void *vjob1, |
| 1399 | const void *vjob2) |
| 1400 | { |
| 1401 | const struct sinfonia_printjob *job1 = vjob1; |
| 1402 | const struct sinfonia_printjob *job2 = vjob2; |
| 1403 | struct sinfonia_printjob *newjob = NULL; |
| 1404 | |
| 1405 | uint16_t newrows; |
| 1406 | uint16_t newpad; |
| 1407 | |
| 1408 | if (!job1 || !job2) |
| 1409 | goto done; |
| 1410 | |
| 1411 | /* Make sure we're okay to proceed */ |
| 1412 | JOB_EQUIV(jp.columns); |
| 1413 | JOB_EQUIV(jp.rows); |
| 1414 | JOB_EQUIV(jp.oc_mode); |
| 1415 | JOB_EQUIV(jp.method); |
| 1416 | JOB_EQUIV(jp.media); |
| 1417 | JOB_EQUIV(jp.quality); |
| 1418 | |
| 1419 | switch (job1->jp.rows) { |
| 1420 | case 1240: /* 4x6 */ |
| 1421 | newrows = 2492; |
| 1422 | newpad = 12; |
| 1423 | break; |
| 1424 | default: |
| 1425 | /* All other sizes, we can't combine */ |
| 1426 | goto done; |
| 1427 | } |
| 1428 | |
| 1429 | newjob = malloc(sizeof(*newjob)); |
| 1430 | if (!newjob) { |
| 1431 | ERROR("Memory allocation failure!\n"); |
| 1432 | goto done; |
| 1433 | } |
| 1434 | memcpy(newjob, job1, sizeof(*newjob)); |
| 1435 | |
| 1436 | newjob->jp.rows = newrows; |
| 1437 | newjob->jp.media = CODE_6x8; |
| 1438 | |
| 1439 | if (job1->jp.method == PRINT_METHOD_SPLIT) /* 4x6-div2 -> 8x6-div4 */ |
| 1440 | newjob->jp.method = PRINT_METHOD_COMBO_4; |
| 1441 | else /* 4x6 -> 8x6-div2 */ |
| 1442 | newjob->jp.method = PRINT_METHOD_SPLIT; |
| 1443 | |
| 1444 | /* Allocate new buffer */ |
| 1445 | newjob->databuf = malloc(newjob->jp.rows * newjob->jp.columns * 3); |
| 1446 | newjob->datalen = 0; |
| 1447 | if (!newjob->databuf) { |
| 1448 | sinfonia_cleanup_job(newjob); |
| 1449 | newjob = NULL; |
| 1450 | goto done; |
| 1451 | } |
| 1452 | |
| 1453 | /* Copy Planar YMC payload into new buffer! */ |
| 1454 | memcpy(newjob->databuf + newjob->datalen, |
| 1455 | job1->databuf, |
| 1456 | job1->jp.rows * job1->jp.columns); |
| 1457 | newjob->datalen += job1->jp.rows * job1->jp.columns; |
| 1458 | memset(newjob->databuf + newjob->datalen, 0xff, newpad * newjob->jp.columns); |
| 1459 | memcpy(newjob->databuf + newjob->datalen, |
| 1460 | job2->databuf, |
| 1461 | job2->jp.rows * job2->jp.columns); |
| 1462 | newjob->datalen += job2->jp.rows * job2->jp.columns; |
| 1463 | |
| 1464 | memcpy(newjob->databuf + newjob->datalen, |
| 1465 | job1->databuf + (job1->jp.rows * job1->jp.columns), |
| 1466 | job1->jp.rows * job1->jp.columns); |
| 1467 | newjob->datalen += job1->jp.rows * job1->jp.columns; |
| 1468 | memset(newjob->databuf + newjob->datalen, 0xff, newpad * newjob->jp.columns); |
| 1469 | memcpy(newjob->databuf + newjob->datalen, |
| 1470 | job2->databuf + (job2->jp.rows * job2->jp.columns), |
| 1471 | job2->jp.rows * job2->jp.columns); |
| 1472 | newjob->datalen += job2->jp.rows * job2->jp.columns; |
| 1473 | |
| 1474 | memcpy(newjob->databuf + newjob->datalen, |
| 1475 | job1->databuf + 2*(job1->jp.rows * job1->jp.columns), |
| 1476 | job1->jp.rows * job1->jp.columns); |
| 1477 | newjob->datalen += job1->jp.rows * job1->jp.columns; |
| 1478 | memset(newjob->databuf + newjob->datalen, 0xff, newpad * newjob->jp.columns); |
| 1479 | memcpy(newjob->databuf + newjob->datalen, |
| 1480 | job2->databuf + 2*(job2->jp.rows * job2->jp.columns), |
| 1481 | job2->jp.rows * job2->jp.columns); |
| 1482 | newjob->datalen += job2->jp.rows * job2->jp.columns; |
| 1483 | |
| 1484 | done: |
| 1485 | return newjob; |
| 1486 | } |
| 1487 | |
| 1488 | static int shinkos6145_main_loop(void *vctx, const void *vjob, int wait_for_return) { |
| 1489 | struct shinkos6145_ctx *ctx = vctx; |
| 1490 | |
| 1491 | int ret, num; |
| 1492 | |
| 1493 | int i, last_state = -1, state = S_IDLE; |
| 1494 | |
| 1495 | struct sinfonia_cmd_hdr cmd; |
| 1496 | struct sinfonia_status_resp sts, sts2; |
| 1497 | |
| 1498 | uint32_t cur_mode; |
| 1499 | |
| 1500 | struct sinfonia_printjob *job = (struct sinfonia_printjob*) vjob; |
| 1501 | |
| 1502 | if (!job) |
| 1503 | return CUPS_BACKEND_FAILED; |
| 1504 | |
| 1505 | /* Validate print sizes */ |
| 1506 | for (i = 0; i < ctx->media.count ; i++) { |
| 1507 | /* Look for matching media */ |
| 1508 | if (ctx->media.items[i].columns == job->jp.columns && |
| 1509 | ctx->media.items[i].rows == job->jp.rows && |
| 1510 | ctx->media.items[i].method == job->jp.method && |
| 1511 | ctx->media.items[i].code == job->jp.media) |
| 1512 | break; |
| 1513 | } |
| 1514 | if (i == ctx->media.count) { |
| 1515 | ERROR("Incorrect media loaded for print!\n"); |
| 1516 | return CUPS_BACKEND_HOLD; |
| 1517 | } |
| 1518 | |
| 1519 | // XXX check copies against remaining media? |
| 1520 | |
| 1521 | if (!ctx->is_2245) { |
| 1522 | /* Query printer mode */ |
| 1523 | ret = sinfonia_getparam(&ctx->dev, PARAM_OC_PRINT, &cur_mode); |
| 1524 | if (ret) { |
| 1525 | ERROR("Failed to execute command\n"); |
| 1526 | return ret; |
| 1527 | } |
| 1528 | } |
| 1529 | |
| 1530 | /* Send Set Time */ |
| 1531 | if (ctx->is_2245) { |
| 1532 | struct sinfonia_settime_cmd settime; |
| 1533 | time_t now = time(NULL); |
| 1534 | const struct tm *cur = localtime(&now); |
| 1535 | |
| 1536 | memset(&settime, 0, sizeof(settime)); |
| 1537 | settime.hdr.cmd = cpu_to_le16(SINFONIA_CMD_SETTIME); |
| 1538 | settime.hdr.len = cpu_to_le16(sizeof(settime)-sizeof(settime.hdr)); |
| 1539 | settime.enable = 1; |
| 1540 | settime.second = cur->tm_sec; |
| 1541 | settime.minute = cur->tm_min; |
| 1542 | settime.hour = cur->tm_hour; |
| 1543 | settime.day = cur->tm_mday; |
| 1544 | settime.month = cur->tm_mon; |
| 1545 | settime.year = cur->tm_year + 1900 - 2000; |
| 1546 | |
| 1547 | if ((ret = sinfonia_docmd(&ctx->dev, |
| 1548 | (uint8_t*)&settime, sizeof(settime), |
| 1549 | (uint8_t*)&sts, sizeof(sts), |
| 1550 | &num))) { |
| 1551 | return CUPS_BACKEND_FAILED; |
| 1552 | } |
| 1553 | if (sts.hdr.result != RESULT_SUCCESS) |
| 1554 | return CUPS_BACKEND_FAILED; |
| 1555 | } |
| 1556 | |
| 1557 | |
| 1558 | top: |
| 1559 | if (state != last_state) { |
| 1560 | if (dyesub_debug) |
| 1561 | DEBUG("last_state %d new %d\n", last_state, state); |
| 1562 | } |
| 1563 | |
| 1564 | /* Send Status Query */ |
| 1565 | cmd.cmd = cpu_to_le16(SINFONIA_CMD_GETSTATUS); |
| 1566 | cmd.len = cpu_to_le16(0); |
| 1567 | |
| 1568 | if ((ret = sinfonia_docmd(&ctx->dev, |
| 1569 | (uint8_t*)&cmd, sizeof(cmd), |
| 1570 | (uint8_t*)&sts, sizeof(sts), |
| 1571 | &num))) { |
| 1572 | return CUPS_BACKEND_FAILED; |
| 1573 | } |
| 1574 | |
| 1575 | if (memcmp(&sts, &sts2, sizeof(sts))) { |
| 1576 | memcpy(&sts2, &sts, sizeof(sts)); |
| 1577 | |
| 1578 | INFO("Printer Status: 0x%02x (%s)\n", |
| 1579 | sts.hdr.status, sinfonia_status_str(sts.hdr.status)); |
| 1580 | |
| 1581 | if (ctx->marker.levelnow != (int)sts.count_ribbon_left) { |
| 1582 | ctx->marker.levelnow = sts.count_ribbon_left; |
| 1583 | dump_markers(&ctx->marker, 1, 0); |
| 1584 | } |
| 1585 | |
| 1586 | if (sts.hdr.result != RESULT_SUCCESS) |
| 1587 | goto printer_error; |
| 1588 | if (sts.hdr.status == ERROR_PRINTER) |
| 1589 | goto printer_error; |
| 1590 | } else if (state == last_state) { |
| 1591 | sleep(1); |
| 1592 | goto top; |
| 1593 | } |
| 1594 | last_state = state; |
| 1595 | |
| 1596 | fflush(logger); |
| 1597 | |
| 1598 | switch (state) { |
| 1599 | case S_IDLE: |
| 1600 | INFO("Waiting for printer idle\n"); |
| 1601 | /* If either bank is free, continue */ |
| 1602 | if (sts.bank1_status == BANK_STATUS_FREE || |
| 1603 | sts.bank2_status == BANK_STATUS_FREE) |
| 1604 | state = S_PRINTER_READY_CMD; |
| 1605 | |
| 1606 | break; |
| 1607 | case S_PRINTER_READY_CMD: { |
| 1608 | /* Set matte/etc */ |
| 1609 | uint32_t oc_mode = job->jp.oc_mode; |
| 1610 | uint32_t updated = 0; |
| 1611 | |
| 1612 | if (ctx->is_2245) { |
| 1613 | oc_mode = (job->jp.oc_mode & SINFONIA_PRINT28_OC_MASK) | (job->jp.quality ? SINFONIA_PRINT28_OPTIONS_HQ : 0); |
| 1614 | if (!ctx->corrdata || |
| 1615 | ctx->corrdatalen <= S2245_CORRDATA_HEADER_MODE_OFFSET || |
| 1616 | ((uint8_t*)ctx->corrdata)[S2245_CORRDATA_HEADER_MODE_OFFSET] != oc_mode) |
| 1617 | updated = 1; |
| 1618 | } else { |
| 1619 | if (!oc_mode) /* if nothing set, default to glossy */ |
| 1620 | oc_mode = PARAM_OC_PRINT_GLOSS; |
| 1621 | |
| 1622 | if (cur_mode != oc_mode) { |
| 1623 | /* If cur_mode is not the same as desired oc_mode, |
| 1624 | change it -- but we have to wait until the printer |
| 1625 | is COMPLETELY idle */ |
| 1626 | if (sts.bank1_status != BANK_STATUS_FREE || |
| 1627 | sts.bank2_status != BANK_STATUS_FREE) { |
| 1628 | INFO("Need to switch overcoat mode, waiting for printer idle\n"); |
| 1629 | sleep(1); |
| 1630 | goto top; |
| 1631 | } |
| 1632 | |
| 1633 | ret = sinfonia_setparam(&ctx->dev, PARAM_OC_PRINT, oc_mode); |
| 1634 | if (ret) { |
| 1635 | ERROR("Failed to execute command\n"); |
| 1636 | return ret; |
| 1637 | } |
| 1638 | updated = 1; |
| 1639 | } |
| 1640 | } |
| 1641 | |
| 1642 | ret = shinkos6145_get_eeprom(ctx); |
| 1643 | if (ret) { |
| 1644 | ERROR("Failed to execute command\n"); |
| 1645 | return ret; |
| 1646 | } |
| 1647 | |
| 1648 | /* Get image correction parameters if necessary */ |
| 1649 | if (updated || !ctx->corrdata || !ctx->corrdatalen) { |
| 1650 | if (ctx->is_2245) { |
| 1651 | ret = shinkos2245_get_imagecorr(ctx, oc_mode); |
| 1652 | } else { |
| 1653 | ret = shinkos6145_get_imagecorr(ctx); |
| 1654 | } |
| 1655 | } |
| 1656 | if (ret) { |
| 1657 | ERROR("Failed to execute command\n"); |
| 1658 | return ret; |
| 1659 | } |
| 1660 | |
| 1661 | if (ctx->dl_handle) { |
| 1662 | INFO("Calling image processing library...\n"); |
| 1663 | } else { |
| 1664 | ERROR("Image processing library not found! Cannot print!\n"); |
| 1665 | return CUPS_BACKEND_FAILED; |
| 1666 | } |
| 1667 | |
| 1668 | if (ctx->is_2245) { |
| 1669 | uint32_t bufSize = 0; |
| 1670 | uint16_t *newbuf; |
| 1671 | |
| 1672 | if (!ctx->ip_checkIpp(job->jp.columns, job->jp.rows, ctx->corrdata)) { |
| 1673 | ERROR("ip_checkIPP Failed!\n"); |
| 1674 | return CUPS_BACKEND_FAILED; |
| 1675 | } |
| 1676 | if (!ctx->ip_getMemorySize(&bufSize, job->jp.columns, job->jp.rows, ctx->corrdata)) { |
| 1677 | ERROR("ip_getMemorySize Failed!\n"); |
| 1678 | return CUPS_BACKEND_FAILED; |
| 1679 | } |
| 1680 | newbuf = malloc(bufSize); |
| 1681 | if (!newbuf) { |
| 1682 | ERROR("Memory Allocation failure!\n"); |
| 1683 | return CUPS_BACKEND_RETRY; |
| 1684 | } |
| 1685 | if (!ctx->ip_imageProc(newbuf, job->databuf, job->jp.columns, job->jp.rows, ctx->corrdata)) { |
| 1686 | ERROR("ip_imageProc Failed!\n"); |
| 1687 | free(newbuf); |
| 1688 | return CUPS_BACKEND_FAILED; |
| 1689 | } |
| 1690 | free(job->databuf); |
| 1691 | job->databuf = (uint8_t*)newbuf; |
| 1692 | job->datalen = bufSize; |
| 1693 | } else { |
| 1694 | uint16_t tmp; |
| 1695 | memcpy(&tmp, (uint8_t*)ctx->corrdata + S6145_CORRDATA_HEADDOTS_OFFSET, sizeof(tmp)); |
| 1696 | tmp = le16_to_cpu(tmp); |
| 1697 | |
| 1698 | /* Set up library transform... */ |
| 1699 | uint32_t newlen = tmp * job->jp.rows * sizeof(uint16_t) * 4; |
| 1700 | uint16_t *databuf2 = malloc(newlen); |
| 1701 | if (!databuf2) { |
| 1702 | ERROR("Memory Allocation failure!\n"); |
| 1703 | return CUPS_BACKEND_RETRY; |
| 1704 | } |
| 1705 | /* Set the size in the correctiondata */ |
| 1706 | tmp = cpu_to_le16(job->jp.columns); |
| 1707 | memcpy((uint8_t*)ctx->corrdata + S6145_CORRDATA_WIDTH_OFFSET, &tmp, sizeof(tmp)); |
| 1708 | tmp = cpu_to_le16(job->jp.rows); |
| 1709 | memcpy((uint8_t*)ctx->corrdata + S6145_CORRDATA_HEIGHT_OFFSET, &tmp, sizeof(tmp)); |
| 1710 | |
| 1711 | /* Perform the actual library transform */ |
| 1712 | if (ctx->ImageAvrCalc(job->databuf, job->jp.columns, job->jp.rows, ctx->image_avg)) { |
| 1713 | free(databuf2); |
| 1714 | ERROR("Library returned error!\n"); |
| 1715 | return CUPS_BACKEND_FAILED; |
| 1716 | } |
| 1717 | ctx->ImageProcessing(job->databuf, databuf2, ctx->corrdata); |
| 1718 | |
| 1719 | free(job->databuf); |
| 1720 | job->databuf = (uint8_t*) databuf2; |
| 1721 | job->datalen = newlen; |
| 1722 | } |
| 1723 | |
| 1724 | INFO("Sending print job (internal id %u)\n", ctx->jobid); |
| 1725 | |
| 1726 | if (!ctx->is_2245) { |
| 1727 | struct s6145_print_cmd print; |
| 1728 | memset(&print, 0, sizeof(print)); |
| 1729 | print.hdr.cmd = cpu_to_le16(SINFONIA_CMD_PRINTJOB); |
| 1730 | print.hdr.len = cpu_to_le16(sizeof (print) - sizeof(cmd)); |
| 1731 | |
| 1732 | print.id = ctx->jobid; |
| 1733 | print.count = cpu_to_le16(job->common.copies); |
| 1734 | print.columns = cpu_to_le16(job->jp.columns); |
| 1735 | print.rows = cpu_to_le16(job->jp.rows); |
| 1736 | print.image_avg = ctx->image_avg[2]; /* Cyan level */ |
| 1737 | print.method = cpu_to_le32(job->jp.method); |
| 1738 | print.combo_wait = 0; |
| 1739 | |
| 1740 | /* Brava21 header has a few quirks */ |
| 1741 | if(ctx->dev.conn->type == P_SHINKO_S6145D) { |
| 1742 | print.media = job->jp.media; |
| 1743 | print.unk_1 = 0x01; |
| 1744 | } |
| 1745 | if ((ret = sinfonia_docmd(&ctx->dev, |
| 1746 | (uint8_t*)&print, sizeof(print), |
| 1747 | (uint8_t*)&sts, sizeof(sts), |
| 1748 | &num))) { |
| 1749 | return ret; |
| 1750 | } |
| 1751 | } else { |
| 1752 | struct sinfonia_printcmd28_hdr print; |
| 1753 | memset(&print, 0, sizeof(print)); |
| 1754 | print.hdr.cmd = cpu_to_le16(SINFONIA_CMD_PRINTJOB); |
| 1755 | print.hdr.len = cpu_to_le16(sizeof (print) - sizeof(cmd)); |
| 1756 | print.jobid = ctx->jobid; |
| 1757 | print.copies = cpu_to_le16(job->common.copies); |
| 1758 | print.columns = cpu_to_le16(job->jp.columns); |
| 1759 | print.rows = cpu_to_le16(job->jp.rows); |
| 1760 | print.options = job->jp.oc_mode & 0x3; |
| 1761 | if (job->jp.quality) |
| 1762 | print.options |= 0x08; |
| 1763 | print.media = 0; /* ignore job->jp.media! */ |
| 1764 | print.ipp = 0; /* Not used */ |
| 1765 | print.method = cpu_to_le32(job->jp.method | SINFONIA_PRINT28_METHOD_ERR_RECOVERY | SINFONIA_PRINT28_METHOD_PREHEAT); |
| 1766 | |
| 1767 | if ((ret = sinfonia_docmd(&ctx->dev, |
| 1768 | (uint8_t*)&print, sizeof(print), |
| 1769 | (uint8_t*)&sts, sizeof(sts), |
| 1770 | &num))) { |
| 1771 | return ret; |
| 1772 | } |
| 1773 | } |
| 1774 | |
| 1775 | if (sts.hdr.result != RESULT_SUCCESS) { |
| 1776 | if (sts.hdr.error == ERROR_BUFFER_FULL) { |
| 1777 | INFO("Printer Buffers full, retrying\n"); |
| 1778 | break; |
| 1779 | } else if ((sts.hdr.status & 0xf0) == 0x30 || sts.hdr.status == 0x21) { |
| 1780 | INFO("Printer busy (%s), retrying\n", sinfonia_status_str(sts.hdr.status)); |
| 1781 | break; |
| 1782 | } else if (sts.hdr.status != ERROR_NONE) |
| 1783 | goto printer_error; |
| 1784 | } |
| 1785 | |
| 1786 | INFO("Sending image data to printer\n"); |
| 1787 | // XXX we shouldn't send the lamination layer over if |
| 1788 | // it's not needed. hdr->oc_mode == PRINT_MODE_NO_OC |
| 1789 | if ((ret = send_data(ctx->dev.conn, |
| 1790 | job->databuf, job->datalen))) |
| 1791 | return CUPS_BACKEND_FAILED; |
| 1792 | |
| 1793 | INFO("Waiting for printer to acknowledge completion\n"); |
| 1794 | sleep(1); |
| 1795 | state = S_PRINTER_SENT_DATA; |
| 1796 | break; |
| 1797 | } |
| 1798 | case S_PRINTER_SENT_DATA: |
| 1799 | if (!wait_for_return) { |
| 1800 | INFO("Fast return mode enabled.\n"); |
| 1801 | state = S_FINISHED; |
| 1802 | } else if (sts.hdr.status == STATUS_READY) { |
| 1803 | state = S_FINISHED; |
| 1804 | } |
| 1805 | break; |
| 1806 | default: |
| 1807 | break; |
| 1808 | }; |
| 1809 | |
| 1810 | if (state != S_FINISHED) |
| 1811 | goto top; |
| 1812 | |
| 1813 | INFO("Print complete\n"); |
| 1814 | |
| 1815 | return CUPS_BACKEND_OK; |
| 1816 | |
| 1817 | printer_error: |
| 1818 | ERROR("Printer reported error: %#x (%s) status: %#x (%s) -> %#x.%#x (%s)\n", |
| 1819 | sts.hdr.error, |
| 1820 | sinfonia_error_str(sts.hdr.error), |
| 1821 | sts.hdr.status, |
| 1822 | sinfonia_status_str(sts.hdr.status), |
| 1823 | sts.hdr.printer_major, sts.hdr.printer_minor, |
| 1824 | ctx->dev.error_codes(sts.hdr.printer_major, sts.hdr.printer_minor)); |
| 1825 | return CUPS_BACKEND_FAILED; |
| 1826 | } |
| 1827 | |
| 1828 | static int shinkos6145_query_markers(void *vctx, struct marker **markers, int *count) |
| 1829 | { |
| 1830 | struct shinkos6145_ctx *ctx = vctx; |
| 1831 | struct sinfonia_cmd_hdr cmd; |
| 1832 | struct sinfonia_status_resp sts; |
| 1833 | int num; |
| 1834 | |
| 1835 | /* Query Status */ |
| 1836 | cmd.cmd = cpu_to_le16(SINFONIA_CMD_GETSTATUS); |
| 1837 | cmd.len = cpu_to_le16(0); |
| 1838 | |
| 1839 | if (sinfonia_docmd(&ctx->dev, |
| 1840 | (uint8_t*)&cmd, sizeof(cmd), |
| 1841 | (uint8_t*)&sts, sizeof(sts), |
| 1842 | &num)) { |
| 1843 | return CUPS_BACKEND_FAILED; |
| 1844 | } |
| 1845 | |
| 1846 | ctx->marker.levelnow = le32_to_cpu(sts.count_ribbon_left); |
| 1847 | |
| 1848 | if (markers) *markers = &ctx->marker; |
| 1849 | if (count) *count = 1; |
| 1850 | |
| 1851 | return CUPS_BACKEND_OK; |
| 1852 | } |
| 1853 | |
| 1854 | static int shinkos6145_query_stats(void *vctx, struct printerstats *stats) |
| 1855 | { |
| 1856 | struct shinkos6145_ctx *ctx = vctx; |
| 1857 | struct sinfonia_cmd_hdr cmd; |
| 1858 | struct sinfonia_status_resp status; |
| 1859 | int num; |
| 1860 | |
| 1861 | if (shinkos6145_query_markers(ctx, NULL, NULL)) |
| 1862 | return CUPS_BACKEND_FAILED; |
| 1863 | |
| 1864 | /* Query Status */ |
| 1865 | cmd.cmd = cpu_to_le16(SINFONIA_CMD_GETSTATUS); |
| 1866 | cmd.len = cpu_to_le16(0); |
| 1867 | |
| 1868 | if (sinfonia_docmd(&ctx->dev, |
| 1869 | (uint8_t*)&cmd, sizeof(cmd), |
| 1870 | (uint8_t*)&status, sizeof(status), |
| 1871 | &num)) { |
| 1872 | return CUPS_BACKEND_FAILED; |
| 1873 | } |
| 1874 | |
| 1875 | switch (ctx->dev.conn->type) { |
| 1876 | case P_SHINKO_S6145: |
| 1877 | stats->mfg = "Sinfonia"; |
| 1878 | stats->model = "CS2 / S6145"; |
| 1879 | break; |
| 1880 | case P_SHINKO_S6145D: |
| 1881 | stats->mfg = "Ciaat"; |
| 1882 | stats->model = "Brava 21"; |
| 1883 | break; |
| 1884 | case P_KODAK_6900: |
| 1885 | stats->mfg = "Kodak"; |
| 1886 | if (ctx->dev.conn->usb_pid == 0x0003) { |
| 1887 | stats->model = "6900"; |
| 1888 | } else if (ctx->dev.conn->usb_pid == 0x0004) { |
| 1889 | stats->model = "6950"; |
| 1890 | } |
| 1891 | break; |
| 1892 | case P_SHINKO_S2245: |
| 1893 | if (ctx->dev.conn->usb_pid == 0x0010) { |
| 1894 | stats->mfg = "HiTi"; |
| 1895 | stats->model = "M610"; |
| 1896 | } else if (ctx->dev.conn->usb_pid == 0x0039) { |
| 1897 | stats->mfg = "Sinfonia"; |
| 1898 | stats->model = "S3 / S2245"; |
| 1899 | } else { |
| 1900 | stats->mfg = "Unknown"; |
| 1901 | stats->model = "Unknown"; |
| 1902 | } |
| 1903 | break; |
| 1904 | default: |
| 1905 | stats->mfg = "Unknown"; |
| 1906 | stats->model = "Unknown"; |
| 1907 | break; |
| 1908 | } |
| 1909 | |
| 1910 | if (sinfonia_query_serno(ctx->dev.conn, |
| 1911 | ctx->serial, sizeof(ctx->serial))) |
| 1912 | return CUPS_BACKEND_FAILED; |
| 1913 | |
| 1914 | stats->serial = ctx->serial; |
| 1915 | |
| 1916 | { |
| 1917 | struct sinfonia_fwinfo_cmd fcmd; |
| 1918 | struct sinfonia_fwinfo_resp resp; |
| 1919 | |
| 1920 | num = 0; |
| 1921 | fcmd.hdr.cmd = cpu_to_le16(SINFONIA_CMD_FWINFO); |
| 1922 | fcmd.hdr.len = cpu_to_le16(1); |
| 1923 | fcmd.target = FWINFO_TARGET_MAIN_APP; |
| 1924 | |
| 1925 | if (sinfonia_docmd(&ctx->dev, |
| 1926 | (uint8_t*)&fcmd, sizeof(fcmd), |
| 1927 | (uint8_t*)&resp, sizeof(resp), |
| 1928 | &num)) |
| 1929 | return CUPS_BACKEND_FAILED; |
| 1930 | snprintf(ctx->fwver, sizeof(ctx->fwver)-1, |
| 1931 | "%d.%d", resp.major, resp.minor); |
| 1932 | stats->fwver = ctx->fwver; |
| 1933 | } |
| 1934 | |
| 1935 | stats->decks = 1; |
| 1936 | stats->mediatype[0] = ctx->marker.name; |
| 1937 | stats->levelmax[0] = ctx->marker.levelmax; |
| 1938 | stats->levelnow[0] = ctx->marker.levelnow; |
| 1939 | stats->name[0] = "Roll"; |
| 1940 | if (status.hdr.status == ERROR_PRINTER) { |
| 1941 | if(status.hdr.error == ERROR_NONE) |
| 1942 | status.hdr.error = status.hdr.status; |
| 1943 | stats->status[0] = strdup(sinfonia_error_str(status.hdr.error)); |
| 1944 | } else { |
| 1945 | stats->status[0] = strdup(sinfonia_status_str(status.hdr.status)); |
| 1946 | } |
| 1947 | stats->cnt_life[0] = le32_to_cpu(status.count_lifetime); |
| 1948 | |
| 1949 | return CUPS_BACKEND_OK; |
| 1950 | } |
| 1951 | |
| 1952 | static const char *shinkos6145_prefixes[] = { |
| 1953 | "shinkos6145", /* Family Name */ |
| 1954 | // backwards-compatiblity |
| 1955 | "brava21", |
| 1956 | NULL |
| 1957 | }; |
| 1958 | |
| 1959 | static const struct device_id shinkos6145_devices[] = { |
| 1960 | { 0x10ce, 0x0019, P_SHINKO_S6145, NULL, "sinfonia-chcs6145"}, |
| 1961 | { 0x10ce, 0x0019, P_SHINKO_S6145, NULL, "shinko-chcs6145"}, /* Duplicate */ |
| 1962 | { 0x10ce, 0x001e, P_SHINKO_S6145D, NULL, "ciaat-brava-21"}, |
| 1963 | { 0x10ce, 0x0039, P_SHINKO_S2245, NULL, "sinfonia-chcs2245"}, |
| 1964 | { 0x29cc, 0x0003, P_KODAK_6900, NULL, "kodak-6900"}, /* aka CHC-S2245-6A */ |
| 1965 | { 0x29cc, 0x0004, P_KODAK_6900, NULL, "kodak-6950"}, /* aka CHC-S2245-6C */ |
| 1966 | { 0x0d16, 0x0010, P_SHINKO_S2245, NULL, "hiti-m610"}, /* aka CHC-S2245-5F */ |
| 1967 | { 0, 0, 0, NULL, NULL} |
| 1968 | }; |
| 1969 | |
| 1970 | const struct dyesub_backend shinkos6145_backend = { |
| 1971 | .name = "Shinko/Sinfonia CHC-S6145/CS2/S2245/S3", |
| 1972 | .version = "0.50" " (lib " LIBSINFONIA_VER ")", |
| 1973 | .uri_prefixes = shinkos6145_prefixes, |
| 1974 | .devices = shinkos6145_devices, |
| 1975 | .cmdline_usage = shinkos6145_cmdline, |
| 1976 | .cmdline_arg = shinkos6145_cmdline_arg, |
| 1977 | .init = shinkos6145_init, |
| 1978 | .attach = shinkos6145_attach, |
| 1979 | .teardown = shinkos6145_teardown, |
| 1980 | .cleanup_job = sinfonia_cleanup_job, |
| 1981 | .read_parse = shinkos6145_read_parse, |
| 1982 | .main_loop = shinkos6145_main_loop, |
| 1983 | .query_serno = sinfonia_query_serno, |
| 1984 | .query_markers = shinkos6145_query_markers, |
| 1985 | .query_stats = shinkos6145_query_stats, |
| 1986 | .combine_jobs = shinkos6145_combine_jobs, |
| 1987 | }; |
| 1988 | |
| 1989 | /* CHC-S6145 spool file format |
| 1990 | |
| 1991 | Spool file consists of an 116-byte header, followed by RGB-packed data, |
| 1992 | followed by a 4-byte footer. Header appears to consist of a series of |
| 1993 | 4-byte Little Endian words. |
| 1994 | |
| 1995 | 10 00 00 00 MM MM 00 00 HH 00 00 00 01 00 00 00 MM == Model (ie 6145d), HH == 0x02 (5" media), 0x03 (6" media) |
| 1996 | 64 00 00 00 00 00 00 00 TT 00 00 00 00 00 00 00 TT == 0x08 5x5, 0x03 5x7, 0x07 2x6, 0x00 4x6, 0x06 6x6/6x6+6x2/6x8 |
| 1997 | UU 00 00 00 ZZ 00 00 00 XX 00 00 00 00 00 00 00 XX == 0x00 default, 0x02 glossy, 0x03 matte, ZZ == 0x00 default, 0x01 == std qual; UU == 0x00 normal, 0x04 2x6*2, 0x05 6x6+2x6 |
| 1998 | 00 00 00 00 WW WW 00 00 HH HH 00 00 NN 00 00 00 WW/HH Width, Height (LE), NN == Copies |
| 1999 | 00 00 00 00 00 00 00 00 00 00 00 00 ce ff ff ff |
| 2000 | 00 00 00 00 ce ff ff ff QQ QQ 00 00 ce ff ff ff QQ == DPI (300) |
| 2001 | 00 00 00 00 ce ff ff ff 00 00 00 00 00 00 00 00 |
| 2002 | 00 00 00 00 |
| 2003 | |
| 2004 | [[Packed RGB payload of WW*HH*3 bytes]] |
| 2005 | |
| 2006 | 04 03 02 01 [[ footer ]] |
| 2007 | |
| 2008 | * CHC-S2245 spool file format |
| 2009 | |
| 2010 | 10 00 00 00 c5 08 00 00 MM MM MM MM 01 00 00 00 [ hdr len 16 ] |
| 2011 | 64 00 00 00 00 00 00 00 ZZ ZZ ZZ ZZ 00 00 00 00 [ hdr len 100 ] |
| 2012 | XX XX XX XX QQ QQ QQ QQ GG GG GG GG 00 00 00 00 |
| 2013 | 00 00 00 00 CC CC CC CC RR RR RR RR NN NN NN NN |
| 2014 | 00 00 00 00 00 00 00 00 00 00 00 00 ce ff ff ff |
| 2015 | 00 00 00 00 ce ff ff ff DD DD DD DD ce ff ff ff |
| 2016 | 00 00 00 00 ce ff ff ff 00 00 00 00 00 00 00 00 |
| 2017 | 00 00 00 00 |
| 2018 | |
| 2019 | [[Packed RGB payload of WW*HH*3 bytes]] |
| 2020 | |
| 2021 | 04 03 02 01 [[ footer ]] |
| 2022 | |
| 2023 | CC == columns (1844) |
| 2024 | RR == rows (1240 = 4x6, 2434 = 8x6, 1824 = 6x6, 634 = 2x6) |
| 2025 | DD == dpi (300 fixed) |
| 2026 | NN == copies (1-900) |
| 2027 | GG == overcoat (1 = gloss, 2 = matte) |
| 2028 | QQ == quality (0 = standard, 1 = high) |
| 2029 | MM == media? (1 = 8x6, 0 = 4x6) |
| 2030 | XX == cut? (04 = 4x6-div2, 05 = 8x6-div2, 00 = normal) |
| 2031 | ZZ == method (00 = 4x6, 08 = 6x6, 07 = 2x6, 06 = 8x6) |
| 2032 | |
| 2033 | */ |