| 1 | /* |
| 2 | * |
| 3 | * Print plug-in Lexmark driver for the GIMP. |
| 4 | * |
| 5 | * Copyright 2000 Richard Wisenoecker ([email protected]) and |
| 6 | * Alwin Stolk ([email protected]) |
| 7 | * |
| 8 | * The plug-in is based on the code of the CANON BJL plugin for the GIMP |
| 9 | * of Michael Sweet ([email protected]) and Robert Krawitz ([email protected]). |
| 10 | * |
| 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 | |
| 26 | /* |
| 27 | * This file must include only standard C header files. The core code must |
| 28 | * compile on generic platforms that don't support glib, gimp, gtk, etc. |
| 29 | */ |
| 30 | |
| 31 | /* |
| 32 | * !!! IMPORTANT !!! Some short information: Border and page offsets |
| 33 | * are defined in 1/72 DPI. This mean, that the parameter defined at |
| 34 | * lexmark_cap_t which defines positions are in 1/72 DPI. At |
| 35 | * lexmark_print the unit will be changed dependent on the printer, |
| 36 | * according to the value defined at lexmark_cap_t.x_raster_res and |
| 37 | * lexmark_cap_t.y_raster_res. These two parameters are specifying the |
| 38 | * resolution used for positioning the printer head (it is not the |
| 39 | * resolution used for printing!). |
| 40 | */ |
| 41 | |
| 42 | /* TODO-LIST |
| 43 | * |
| 44 | * * implement the left border |
| 45 | * |
| 46 | */ |
| 47 | |
| 48 | /*#define DEBUG 1*/ |
| 49 | #define USEEPSEWAVE 1 |
| 50 | |
| 51 | #ifdef __GNUC__ |
| 52 | #define inline __inline__ |
| 53 | #endif |
| 54 | |
| 55 | #ifdef HAVE_CONFIG_H |
| 56 | #include <config.h> |
| 57 | #endif |
| 58 | #include <gutenprint/gutenprint.h> |
| 59 | #include <gutenprint/gutenprint-intl-internal.h> |
| 60 | #include "gutenprint-internal.h" |
| 61 | #include <string.h> |
| 62 | #ifdef DEBUG |
| 63 | #include <stdio.h> |
| 64 | #endif |
| 65 | |
| 66 | #define STP_ECOLOR_LC 4 |
| 67 | #define STP_ECOLOR_LM 5 |
| 68 | #define STP_ECOLOR_LY 6 |
| 69 | |
| 70 | #define false 0 |
| 71 | #define true 1 |
| 72 | |
| 73 | #define max(a, b) ((a > b) ? (a) : (b)) |
| 74 | #define INCH(x) (72 * x) |
| 75 | |
| 76 | static const stp_dotsize_t single_dotsize[] = |
| 77 | { |
| 78 | { 0x1, 1.0 } |
| 79 | }; |
| 80 | |
| 81 | static const stp_shade_t photo_dither_shades[] = |
| 82 | { |
| 83 | { 1.0000, 1, single_dotsize }, |
| 84 | { 0.3333, 1, single_dotsize }, |
| 85 | }; |
| 86 | |
| 87 | |
| 88 | typedef enum Lex_model { m_lex7500, m_z52=10052, m_z42=10042, m_3200=3200 } Lex_model; |
| 89 | |
| 90 | #define NCHANNELS (7) |
| 91 | |
| 92 | typedef union { /* Offsets from the start of each line */ |
| 93 | unsigned long v[NCHANNELS]; /* (really pass) */ |
| 94 | struct { /* IMPORTANT: order corresponds to STP_ECOLOR_* */ |
| 95 | unsigned long k; |
| 96 | unsigned long c; |
| 97 | unsigned long m; |
| 98 | unsigned long y; |
| 99 | unsigned long C; |
| 100 | unsigned long M; |
| 101 | unsigned long Y; |
| 102 | } p; |
| 103 | } lexmark_lineoff_t; |
| 104 | |
| 105 | typedef union { /* Base pointers for each pass */ |
| 106 | unsigned char *v[NCHANNELS]; |
| 107 | struct { /* IMPORTANT: order corresponds to STP_ECOLOR_* */ |
| 108 | unsigned char *k; |
| 109 | unsigned char *c; |
| 110 | unsigned char *m; |
| 111 | unsigned char *y; |
| 112 | unsigned char *C; |
| 113 | unsigned char *M; |
| 114 | unsigned char *Y; |
| 115 | } p; |
| 116 | } lexmark_linebufs_t; |
| 117 | |
| 118 | |
| 119 | |
| 120 | #ifdef DEBUG |
| 121 | typedef struct testdata { |
| 122 | FILE *ifile; |
| 123 | int x, y, cols, deep; |
| 124 | char colchar[16]; |
| 125 | char *input_line; |
| 126 | } testdata; |
| 127 | |
| 128 | const stp_vars_t **dbgfileprn; |
| 129 | int lex_show_lcount, lex_show_length; |
| 130 | |
| 131 | const stp_vars_t *lex_open_tmp_file(); |
| 132 | const stp_vars_t *lex_write_tmp_file(const stp_vars_t *ofile, void *data,int length); |
| 133 | static void testprint(testdata *td); |
| 134 | static void readtestprintline(testdata *td, lexmark_linebufs_t *linebufs); |
| 135 | #endif |
| 136 | |
| 137 | static void |
| 138 | flush_pass(stp_vars_t *v, int passno, int vertical_subpass); |
| 139 | |
| 140 | /*** resolution specific parameters */ |
| 141 | #define DPI300 0 |
| 142 | #define DPI600 1 |
| 143 | #define DPI1200 2 |
| 144 | #define DPI2400 3 |
| 145 | #define DPItest 4 |
| 146 | |
| 147 | #define V_NOZZLE_MASK 0x3 |
| 148 | #define H_NOZZLE_MASK 0xc |
| 149 | #define NOZZLE_MASK 0xf |
| 150 | |
| 151 | #define PRINT_MODE_300 0x100 |
| 152 | #define PRINT_MODE_600 0x200 |
| 153 | #define PRINT_MODE_1200 0x300 |
| 154 | #define PRINT_MODE_2400 0x400 |
| 155 | |
| 156 | #define COLOR_MODE_K 0x1000 |
| 157 | #define COLOR_MODE_C 0x2000 |
| 158 | #define COLOR_MODE_Y 0x4000 |
| 159 | #define COLOR_MODE_M 0x8000 |
| 160 | #define COLOR_MODE_LC 0x10000 |
| 161 | #define COLOR_MODE_LY 0x20000 |
| 162 | #define COLOR_MODE_LM 0x40000 |
| 163 | #define COLOR_MODE_CMYK (COLOR_MODE_C | COLOR_MODE_M | COLOR_MODE_Y | COLOR_MODE_K) |
| 164 | #define COLOR_MODE_CMY (COLOR_MODE_C | COLOR_MODE_M | COLOR_MODE_Y) |
| 165 | #define COLOR_MODE_CcMcYK (COLOR_MODE_C | COLOR_MODE_LC | COLOR_MODE_M | COLOR_MODE_LM | COLOR_MODE_Y | COLOR_MODE_K) |
| 166 | #define COLOR_MODE_CcMcY (COLOR_MODE_C | COLOR_MODE_LC | COLOR_MODE_M | COLOR_MODE_LM | COLOR_MODE_Y) |
| 167 | |
| 168 | #define COLOR_MODE_MASK 0x7f000 |
| 169 | #define PRINT_MODE_MASK 0xf00 |
| 170 | #define COLOR_MODE_PHOTO (COLOR_MODE_LC | COLOR_MODE_LM) |
| 171 | |
| 172 | #define BWR 0 |
| 173 | #define BWL 1 |
| 174 | #define CR 2 |
| 175 | #define CL 3 |
| 176 | |
| 177 | |
| 178 | static const char standard_sat_adjustment[] = |
| 179 | "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" |
| 180 | "<gutenprint>\n" |
| 181 | "<curve wrap=\"wrap\" type=\"linear\" gamma=\"0\">\n" |
| 182 | "<sequence count=\"48\" lower-bound=\"0\" upper-bound=\"4\">\n" |
| 183 | /* C */ "1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 " /* B */ |
| 184 | /* B */ "1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 " /* M */ |
| 185 | /* M */ "1.00 0.95 0.90 0.90 0.90 0.90 0.90 0.90 " /* R */ |
| 186 | /* R */ "0.90 0.95 0.95 1.00 1.00 1.00 1.00 1.00 " /* Y */ |
| 187 | /* Y */ "1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 " /* G */ |
| 188 | /* G */ "1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 " /* C */ |
| 189 | "</sequence>\n" |
| 190 | "</curve>\n" |
| 191 | "</gutenprint>\n"; |
| 192 | |
| 193 | static const char standard_lum_adjustment[] = |
| 194 | "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" |
| 195 | "<gutenprint>\n" |
| 196 | "<curve wrap=\"wrap\" type=\"linear\" gamma=\"0\">\n" |
| 197 | "<sequence count=\"48\" lower-bound=\"0\" upper-bound=\"4\">\n" |
| 198 | /* C */ "0.65 0.67 0.70 0.72 0.77 0.80 0.82 0.85 " /* B */ |
| 199 | /* B */ "0.87 0.86 0.82 0.79 0.79 0.82 0.85 0.88 " /* M */ |
| 200 | /* M */ "0.92 0.95 0.96 0.97 0.97 0.97 0.96 0.96 " /* R */ |
| 201 | /* R */ "0.96 0.97 0.97 0.98 0.99 1.00 1.00 1.00 " /* Y */ |
| 202 | /* Y */ "1.00 0.97 0.95 0.94 0.93 0.92 0.90 0.86 " /* G */ |
| 203 | /* G */ "0.79 0.76 0.71 0.68 0.68 0.68 0.68 0.66 " /* C */ |
| 204 | "</sequence>\n" |
| 205 | "</curve>\n" |
| 206 | "</gutenprint>\n"; |
| 207 | |
| 208 | static const char standard_hue_adjustment[] = |
| 209 | "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" |
| 210 | "<gutenprint>\n" |
| 211 | "<curve wrap=\"wrap\" type=\"linear\" gamma=\"0\">\n" |
| 212 | "<sequence count=\"48\" lower-bound=\"-6\" upper-bound=\"6\">\n" |
| 213 | /* C */ "0.00 0.06 0.10 0.10 0.06 -.01 -.09 -.17 " /* B */ |
| 214 | /* B */ "-.25 -.33 -.38 -.38 -.36 -.34 -.34 -.34 " /* M */ |
| 215 | /* M */ "-.34 -.34 -.36 -.40 -.50 -.40 -.30 -.20 " /* R */ |
| 216 | /* R */ "-.12 -.07 -.04 -.02 0.00 0.00 0.00 0.00 " /* Y */ |
| 217 | /* Y */ "0.00 0.00 0.00 -.05 -.10 -.15 -.22 -.24 " /* G */ |
| 218 | /* G */ "-.26 -.30 -.33 -.28 -.25 -.20 -.13 -.06 " /* C */ |
| 219 | "</sequence>\n" |
| 220 | "</curve>\n" |
| 221 | "</gutenprint>\n"; |
| 222 | |
| 223 | |
| 224 | /* Codes for possible ink-tank combinations. |
| 225 | * Each combo is represented by the colors that can be used with |
| 226 | * the installed ink-tank(s) |
| 227 | * Combinations of the codes represent the combinations allowed for a model |
| 228 | */ |
| 229 | #define LEXMARK_INK_K 1 |
| 230 | #define LEXMARK_INK_CMY 2 |
| 231 | #define LEXMARK_INK_CMYK 4 |
| 232 | #define LEXMARK_INK_CcMmYK 8 |
| 233 | #define LEXMARK_INK_CcMmYy 16 |
| 234 | #define LEXMARK_INK_CcMmYyK 32 |
| 235 | |
| 236 | #define LEXMARK_INK_BLACK_MASK (LEXMARK_INK_K|LEXMARK_INK_CMYK|\ |
| 237 | LEXMARK_INK_CcMmYK|LEXMARK_INK_CcMmYyK) |
| 238 | |
| 239 | #define LEXMARK_INK_PHOTO_MASK (LEXMARK_INK_CcMmYy|LEXMARK_INK_CcMmYK|\ |
| 240 | LEXMARK_INK_CcMmYyK) |
| 241 | |
| 242 | /* document feeding */ |
| 243 | #define LEXMARK_SLOT_ASF1 1 |
| 244 | #define LEXMARK_SLOT_ASF2 2 |
| 245 | #define LEXMARK_SLOT_MAN1 4 |
| 246 | #define LEXMARK_SLOT_MAN2 8 |
| 247 | |
| 248 | /* model peculiarities */ |
| 249 | #define LEXMARK_CAP_DMT 1<<0 /* Drop Modulation Technology */ |
| 250 | #define LEXMARK_CAP_MSB_FIRST 1<<1 /* how to send data */ |
| 251 | #define LEXMARK_CAP_CMD61 1<<2 /* uses command #0x61 */ |
| 252 | #define LEXMARK_CAP_CMD6d 1<<3 /* uses command #0x6d */ |
| 253 | #define LEXMARK_CAP_CMD70 1<<4 /* uses command #0x70 */ |
| 254 | #define LEXMARK_CAP_CMD72 1<<5 /* uses command #0x72 */ |
| 255 | |
| 256 | |
| 257 | static const int lr_shift_color[10] = { 9, 18, 2*18 }; /* vertical distance between ever 2nd inkjet (related to resolution) */ |
| 258 | static const int lr_shift_black[10] = { 9, 18, 2*18 }; /* vertical distance between ever 2nd inkjet (related to resolution) */ |
| 259 | |
| 260 | static const stp_parameter_t the_parameters[] = |
| 261 | { |
| 262 | { |
| 263 | "PageSize", N_("Page Size"), "Color=No,Category=Basic Printer Setup", |
| 264 | N_("Size of the paper being printed to"), |
| 265 | STP_PARAMETER_TYPE_STRING_LIST, STP_PARAMETER_CLASS_CORE, |
| 266 | STP_PARAMETER_LEVEL_BASIC, 1, 1, STP_CHANNEL_NONE, 1, 0 |
| 267 | }, |
| 268 | { |
| 269 | "MediaType", N_("Media Type"), "Color=Yes,Category=Basic Printer Setup", |
| 270 | N_("Type of media (plain paper, photo paper, etc.)"), |
| 271 | STP_PARAMETER_TYPE_STRING_LIST, STP_PARAMETER_CLASS_FEATURE, |
| 272 | STP_PARAMETER_LEVEL_BASIC, 1, 1, STP_CHANNEL_NONE, 1, 0 |
| 273 | }, |
| 274 | { |
| 275 | "InputSlot", N_("Media Source"), "Color=No,Category=Basic Printer Setup", |
| 276 | N_("Source (input slot) of the media"), |
| 277 | STP_PARAMETER_TYPE_STRING_LIST, STP_PARAMETER_CLASS_FEATURE, |
| 278 | STP_PARAMETER_LEVEL_BASIC, 1, 1, STP_CHANNEL_NONE, 1, 0 |
| 279 | }, |
| 280 | { |
| 281 | "Resolution", N_("Resolution"), "Color=Yes,Category=Basic Printer Setup", |
| 282 | N_("Resolution and quality of the print"), |
| 283 | STP_PARAMETER_TYPE_STRING_LIST, STP_PARAMETER_CLASS_FEATURE, |
| 284 | STP_PARAMETER_LEVEL_BASIC, 1, 1, STP_CHANNEL_NONE, 1, 0 |
| 285 | }, |
| 286 | { |
| 287 | "InkType", N_("Ink Type"), "Color=Yes,Category=Advanced Printer Setup", |
| 288 | N_("Type of ink in the printer"), |
| 289 | STP_PARAMETER_TYPE_STRING_LIST, STP_PARAMETER_CLASS_FEATURE, |
| 290 | STP_PARAMETER_LEVEL_BASIC, 1, 1, STP_CHANNEL_NONE, 1, 0 |
| 291 | }, |
| 292 | { |
| 293 | "InkChannels", N_("Ink Channels"), "Color=Yes,Category=Advanced Printer Functionality", |
| 294 | N_("Ink Channels"), |
| 295 | STP_PARAMETER_TYPE_INT, STP_PARAMETER_CLASS_FEATURE, |
| 296 | STP_PARAMETER_LEVEL_INTERNAL, 0, 0, STP_CHANNEL_NONE, 0, 0 |
| 297 | }, |
| 298 | { |
| 299 | "PrintingMode", N_("Printing Mode"), "Color=Yes,Category=Core Parameter", |
| 300 | N_("Printing Output Mode"), |
| 301 | STP_PARAMETER_TYPE_STRING_LIST, STP_PARAMETER_CLASS_CORE, |
| 302 | STP_PARAMETER_LEVEL_BASIC, 1, 1, STP_CHANNEL_NONE, 1, 0 |
| 303 | }, |
| 304 | }; |
| 305 | |
| 306 | static const int the_parameter_count = |
| 307 | sizeof(the_parameters) / sizeof(const stp_parameter_t); |
| 308 | |
| 309 | typedef struct |
| 310 | { |
| 311 | const stp_parameter_t param; |
| 312 | double min; |
| 313 | double max; |
| 314 | double defval; |
| 315 | int color_only; |
| 316 | } float_param_t; |
| 317 | |
| 318 | static const float_param_t float_parameters[] = |
| 319 | { |
| 320 | { |
| 321 | { |
| 322 | "CyanDensity", N_("Cyan Density"), "Color=Yes,Category=Output Level Adjustment", |
| 323 | N_("Adjust the cyan density"), |
| 324 | STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT, |
| 325 | STP_PARAMETER_LEVEL_ADVANCED, 0, 1, 1, 1, 0 |
| 326 | }, 0.0, 2.0, 1.0, 1 |
| 327 | }, |
| 328 | { |
| 329 | { |
| 330 | "MagentaDensity", N_("Magenta Density"), "Color=Yes,Category=Output Level Adjustment", |
| 331 | N_("Adjust the magenta density"), |
| 332 | STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT, |
| 333 | STP_PARAMETER_LEVEL_ADVANCED, 0, 1, 2, 1, 0 |
| 334 | }, 0.0, 2.0, 1.0, 1 |
| 335 | }, |
| 336 | { |
| 337 | { |
| 338 | "YellowDensity", N_("Yellow Density"), "Color=Yes,Category=Output Level Adjustment", |
| 339 | N_("Adjust the yellow density"), |
| 340 | STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT, |
| 341 | STP_PARAMETER_LEVEL_ADVANCED, 0, 1, 3, 1, 0 |
| 342 | }, 0.0, 2.0, 1.0, 1 |
| 343 | }, |
| 344 | { |
| 345 | { |
| 346 | "BlackDensity", N_("Black Density"), "Color=Yes,Category=Output Level Adjustment", |
| 347 | N_("Adjust the black density"), |
| 348 | STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT, |
| 349 | STP_PARAMETER_LEVEL_ADVANCED, 0, 1, 0, 1, 0 |
| 350 | }, 0.0, 2.0, 1.0, 1 |
| 351 | }, |
| 352 | { |
| 353 | { |
| 354 | "LightCyanTrans", N_("Light Cyan Transition"), "Color=Yes,Category=Advanced Ink Adjustment", |
| 355 | N_("Light Cyan Transition"), |
| 356 | STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT, |
| 357 | STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0 |
| 358 | }, 0.0, 5.0, 1.0, 1 |
| 359 | }, |
| 360 | { |
| 361 | { |
| 362 | "LightMagentaTrans", N_("Light Magenta Transition"), "Color=Yes,Category=Advanced Ink Adjustment", |
| 363 | N_("Light Magenta Transition"), |
| 364 | STP_PARAMETER_TYPE_DOUBLE, STP_PARAMETER_CLASS_OUTPUT, |
| 365 | STP_PARAMETER_LEVEL_ADVANCED4, 0, 1, STP_CHANNEL_NONE, 1, 0 |
| 366 | }, 0.0, 5.0, 1.0, 1 |
| 367 | }, |
| 368 | }; |
| 369 | |
| 370 | static const int float_parameter_count = |
| 371 | sizeof(float_parameters) / sizeof(const float_param_t); |
| 372 | |
| 373 | /* returns the offset of the first jet when printing in the other direction */ |
| 374 | static int get_lr_shift(int mode) |
| 375 | { |
| 376 | |
| 377 | const int *ptr_lr_shift; |
| 378 | |
| 379 | /* K could only be present if black is printed only. */ |
| 380 | if((mode & COLOR_MODE_K) == (mode & COLOR_MODE_MASK)) { |
| 381 | ptr_lr_shift = lr_shift_black; |
| 382 | } else { |
| 383 | ptr_lr_shift = lr_shift_color; |
| 384 | } |
| 385 | |
| 386 | switch(mode & PRINT_MODE_MASK) { |
| 387 | case PRINT_MODE_300: |
| 388 | return ptr_lr_shift[0]; |
| 389 | break; |
| 390 | case PRINT_MODE_600: |
| 391 | return ptr_lr_shift[1]; |
| 392 | break; |
| 393 | case PRINT_MODE_1200: |
| 394 | return ptr_lr_shift[2]; |
| 395 | break; |
| 396 | case PRINT_MODE_2400: |
| 397 | return ptr_lr_shift[2]; |
| 398 | break; |
| 399 | } |
| 400 | return 0; |
| 401 | } |
| 402 | |
| 403 | |
| 404 | /* |
| 405 | * head offsets for z52: |
| 406 | * |
| 407 | * black black color photo |
| 408 | * cartridge cartridge cartridge cartridge |
| 409 | * mode I mode II |
| 410 | * |
| 411 | * v +-----+ -- +-----+ --- |
| 412 | * --- +-----+ --- v | | ^ | | ^ |
| 413 | * ^ | | --- +-----+ --- -- | C | 64 | LC | | |
| 414 | * | | | ^ | | ^ 40 | | v v | | | |
| 415 | * | | | | | | -- +-----+ -- -- +-----+ | |
| 416 | * | | | | | | ^ 28 | |
| 417 | * | | | | | | +-----+ -- -- +-----+ | |
| 418 | * | | | | | | | ^ ^ | | | |
| 419 | * 208 | K | | K | 192 | M | 64 | LM | 240 |
| 420 | * | | | | | | | v v | | | |
| 421 | * | | | | | | +-----+ -- -- +-----+ | |
| 422 | * | | | | | | v 28 | |
| 423 | * | | | | | | -- +-----+ -- -- +-----+ | |
| 424 | * | | | | | v 40 | | ^ ^ | | | |
| 425 | * v | | +-----+ --- -- | Y | 64 | K | | |
| 426 | * --- +-----+ ^ | | v | | v |
| 427 | * +-----+ -- +-----+ --- |
| 428 | * |
| 429 | */ |
| 430 | |
| 431 | static const int head_offset_cmyk[] = |
| 432 | {70, 368, 184, 0, 368, 184, 0}; /* k, m, c, y, M, C, Y */ |
| 433 | /* the head_offset_cmy is needed because the dithering code is going into troubles if there is an offset different from 0 for the unused black color */ |
| 434 | static const int head_offset_cmy[] = |
| 435 | {0, 368, 184, 0, 368, 184, 0}; /* k, m, c, y, M, C, Y */ |
| 436 | static const int head_offset_cCmMyk[] = |
| 437 | {0, 368, 184, 0, 368, 184, 0}; /* k, m, c, y, M, C, Y */ |
| 438 | |
| 439 | |
| 440 | |
| 441 | |
| 442 | /**************************************************************************/ |
| 443 | /**** Data structures which are describing printer specific parameters ****/ |
| 444 | |
| 445 | /* resolution specific parameters (substructure of lexmark_cap_t) */ |
| 446 | typedef struct { |
| 447 | const char *name; |
| 448 | const char *text; |
| 449 | int hres; |
| 450 | int vres; |
| 451 | int softweave; |
| 452 | int vertical_passes; |
| 453 | int vertical_oversample; |
| 454 | int unidirectional; /* print bi/unidirectional */ |
| 455 | int resid; /* resolution id */ |
| 456 | } lexmark_res_t; |
| 457 | |
| 458 | #define LEXM_RES_COUNT 30 |
| 459 | typedef lexmark_res_t lexmark_res_t_array[LEXM_RES_COUNT]; |
| 460 | |
| 461 | |
| 462 | /* ink type parameters (substructure of lexmark_cap_t) */ |
| 463 | typedef struct { |
| 464 | int ncolors; |
| 465 | unsigned int used_colors; /* specifies the head colors to be used (e.g. COLOR_MODE_K */ |
| 466 | unsigned int pass_length; /* available jets for one color */ |
| 467 | int v_top_head_offset; /* offset from top, where the first jet will be found */ |
| 468 | int h_catridge_offset; /* horizontal offset of cartridges */ |
| 469 | int h_direction_offset; /* Offset when printing in the other direction */ |
| 470 | const int *head_offset; /* specifies the offset of head colors */ |
| 471 | } lexmark_inkparam_t; |
| 472 | |
| 473 | typedef struct |
| 474 | { |
| 475 | const char *name; |
| 476 | const char *text; |
| 477 | lexmark_inkparam_t ink_parameter[2]; |
| 478 | } lexmark_inkname_t; |
| 479 | |
| 480 | |
| 481 | /* main structure which describes all printer specific parameters */ |
| 482 | typedef struct { |
| 483 | Lex_model model; /* printer model */ |
| 484 | int max_paper_width; /* maximum printable paper size in 1/72 inch */ |
| 485 | int max_paper_height; |
| 486 | int min_paper_width; /* Maximum paper width, in points */ |
| 487 | int min_paper_height; /* Maximum paper height, in points */ |
| 488 | int max_xdpi; |
| 489 | int max_ydpi; |
| 490 | int max_quality; |
| 491 | int border_left; /* unit is 72 DPI */ |
| 492 | int border_right; |
| 493 | int border_top; |
| 494 | int border_bottom; |
| 495 | int inks; /* installable cartridges (LEXMARK_INK_*) */ |
| 496 | int slots; /* available paperslots */ |
| 497 | int features; /* special bjl settings */ |
| 498 | /*** printer internal parameters ***/ |
| 499 | /* the unit of the following parameters is identical with max phys unit of the printer */ |
| 500 | int offset_left_border; /* Offset to the left paper border (== border_left=0) */ |
| 501 | int offset_top_border; /* Offset to the top paper border (== border_top=0) */ |
| 502 | int x_raster_res; /* horizontal resolution for positioning of the printer head in DPI */ |
| 503 | int y_raster_res; /* vertical resolution for positioning of the printer head in DPI */ |
| 504 | const lexmark_res_t_array *res_parameters; /* resolution specific parameters; last entry has resid = -1 */ |
| 505 | const lexmark_inkname_t *ink_types; /* type of supported inks */ |
| 506 | const char *lum_adjustment; |
| 507 | const char *hue_adjustment; |
| 508 | const char *sat_adjustment; |
| 509 | } lexmark_cap_t; |
| 510 | |
| 511 | |
| 512 | /*****************************************************************/ |
| 513 | /**** initialize printer specific data structures ****/ |
| 514 | |
| 515 | /* |
| 516 | * z52 specific parameters |
| 517 | */ |
| 518 | #define LX_Z52_300_DPI 1 |
| 519 | #define LX_Z52_600_DPI 3 |
| 520 | #define LX_Z52_1200_DPI 4 |
| 521 | #define LX_Z52_2400_DPI 5 |
| 522 | |
| 523 | #define LX_Z52_COLOR_PRINT 0 |
| 524 | #define LX_Z52_BLACK_PRINT 1 |
| 525 | |
| 526 | #define LX_PSHIFT 0x13 |
| 527 | #define LX_Z52_COLOR_MODE_POS 0x9 |
| 528 | #define LX_Z52_RESOLUTION_POS 0x7 |
| 529 | #define LX_Z52_PRINT_DIRECTION_POS 0x8 |
| 530 | |
| 531 | /*static const int IDX_Z52ID =2;*/ |
| 532 | static const int IDX_SEQLEN=3; |
| 533 | |
| 534 | /* |
| 535 | head: |
| 536 | 1 .. black, |
| 537 | 0 .. color |
| 538 | |
| 539 | resolution: |
| 540 | 1 .. 300 dpi (for black ?) |
| 541 | 2 .. like 1 |
| 542 | 3 .. 600 dpi (color&black) |
| 543 | 4 .. 1200 dpi |
| 544 | 5 .. ? like 1 |
| 545 | */ |
| 546 | |
| 547 | #define LXM_Z52_HEADERSIZE 34 |
| 548 | static const unsigned char outbufHeader_z52[LXM_Z52_HEADERSIZE]= |
| 549 | { |
| 550 | 0x1B,0x2A,0x24,0x00,0x00,0xFF,0xFF, /* number of packets ---- vvvvvvvvv */ |
| 551 | 0x01,0x01,0x01,0x1a,0x03,0x01, /* 0x7-0xc: resolution, direction, head */ |
| 552 | 0x03,0x60, /* 0xd-0xe HE */ |
| 553 | 0x04,0xe0, /* 0xf-0x10 HS vertical pos */ |
| 554 | 0x19,0x5c, /* 0x11-0x12 */ |
| 555 | 0x0,0x0, /* 0x13-0x14 VO between packages*/ |
| 556 | 0x0,0x80, /* 0x15-0x16 */ |
| 557 | 0x0,0x0,0x0,0x0,0x1,0x2,0x0,0x0,0x0,0x0,0x0 /* 0x17-0x21 */ |
| 558 | }; |
| 559 | |
| 560 | #define LXM_Z42_HEADERSIZE 34 |
| 561 | static const unsigned char outbufHeader_z42[LXM_Z42_HEADERSIZE]= |
| 562 | { |
| 563 | 0x1B,0x2A,0x24,0x00,0x00,0x00,0x00, |
| 564 | 0x01,0x01,0x01,0x18,0x00,0x01,0x00, |
| 565 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 566 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00, |
| 567 | 0x00,0x00,0x00,0x00,0x00,0x00 |
| 568 | }; |
| 569 | |
| 570 | |
| 571 | static const lexmark_res_t_array lexmark_reslist_z52 = /* LEXM_RES_COUNT entries are allowed !! */ |
| 572 | { |
| 573 | /* name hres vres softw v_pass overs unidir resid */ |
| 574 | { "300x600dpi", N_ ("300 DPI x 600 DPI"), 300, 600, 0, 1, 1, 0, DPI300 }, |
| 575 | { "600dpi", N_ ("600 DPI"), 600, 600, 0, 1, 1, 0, DPI600 }, |
| 576 | { "600hq", N_ ("600 DPI high quality"), 600, 600, 1, 4, 1, 0, DPI600 }, |
| 577 | { "600uni", N_ ("600 DPI Unidirectional"), 600, 600, 0, 1, 1, 1, DPI600 }, |
| 578 | { "1200dpi", N_ ("1200 DPI"), 1200, 1200, 1, 1, 1, 0, DPI1200}, |
| 579 | { "1200hq", N_ ("1200 DPI high quality"), 1200, 1200, 1, 1, 1, 0, DPI300 }, |
| 580 | { "1200hq2", N_ ("1200 DPI highest quality"), 1200, 1200, 1, 1, 1, 0, DPI600 }, |
| 581 | { "1200uni", N_ ("1200 DPI Unidirectional"), 1200, 1200, 0, 1, 1, 1, DPI1200}, |
| 582 | { "2400x1200dpi", N_ ("2400 DPI x 1200 DPI"), 2400, 1200, 1, 1, 1, 0, DPI1200}, |
| 583 | { "2400x1200hq", N_ ("2400 DPI x 1200 DPI high quality"), 2400, 1200, 1, 1, 1, 0, DPI600 }, |
| 584 | { "2400x1200hq2", N_ ("2400 DPI x 1200 DPI highest quality"),2400, 1200, 1, 1, 1, 0, DPI300}, |
| 585 | #ifdef DEBUG |
| 586 | { "testprint", N_ ("test print"), 1200, 1200, 1, 1, 1, 0, DPItest}, |
| 587 | #endif |
| 588 | { "", "", 0, 0, 0, 0, 0, -1 } |
| 589 | }; |
| 590 | |
| 591 | |
| 592 | static const lexmark_inkname_t ink_types_z52[] = |
| 593 | { |
| 594 | /* output_type ncolors used_colors pass_length v_top_head_offset |
| 595 | * h_cartridge_offset |
| 596 | * h_direction_offset |
| 597 | * head_offset */ |
| 598 | { "CMYK", N_("Four Color Standard"), |
| 599 | {{ 1, COLOR_MODE_K, 208, 324, 0, 10, head_offset_cmyk }, |
| 600 | { 4, COLOR_MODE_CMYK, 192/3, 0, 0, 10, head_offset_cmyk }}}, |
| 601 | { "RGB", N_("Three Color Composite"), |
| 602 | {{ 1, COLOR_MODE_K, 208, 324, 0, 10, head_offset_cmyk }, /* we ignore CMY, use black */ |
| 603 | { 4, COLOR_MODE_CMY, 192/3, 0, 0, 10, head_offset_cmy }}}, |
| 604 | { "PhotoCMYK", N_("Six Color Photo"), |
| 605 | {{ 1, COLOR_MODE_K, 192/3, 0, 0, 10, head_offset_cCmMyk }, |
| 606 | { 6, COLOR_MODE_CcMcYK, 192/3, 0, 0, 10, head_offset_cCmMyk }}}, |
| 607 | { "PhotoCMY", N_("Five Color Photo Composite"), |
| 608 | {{ 1, COLOR_MODE_K, 208, 324, 0, 10, head_offset_cCmMyk }, |
| 609 | { 5, COLOR_MODE_CcMcY, 192/3, 0, 0, 10, head_offset_cCmMyk }}}, /* we ignore CMY, use black */ |
| 610 | { "Gray", N_("Black"), |
| 611 | {{ 1, COLOR_MODE_K, 208, 324, 0, 10, head_offset_cmyk }, |
| 612 | { 1, COLOR_MODE_K, 208, 324, 0, 10, head_offset_cmyk }}}, |
| 613 | { NULL, NULL } |
| 614 | }; |
| 615 | |
| 616 | |
| 617 | |
| 618 | /* |
| 619 | * 3200 specific stuff |
| 620 | */ |
| 621 | #define LXM3200_LEFTOFFS 6254 |
| 622 | #define LXM3200_RIGHTOFFS (LXM3200_LEFTOFFS-2120) |
| 623 | |
| 624 | static int lxm3200_headpos = 0; |
| 625 | static int lxm3200_linetoeject = 0; |
| 626 | |
| 627 | #define LXM_3200_HEADERSIZE 24 |
| 628 | static const char outbufHeader_3200[LXM_3200_HEADERSIZE] = |
| 629 | { |
| 630 | 0x1b, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 631 | 0x1b, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 632 | 0x1b, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 |
| 633 | }; |
| 634 | |
| 635 | static inline int |
| 636 | lexmark_calc_3200_checksum(unsigned char *data) |
| 637 | { |
| 638 | int ck, i; |
| 639 | |
| 640 | ck = 0; |
| 641 | for(i=1; i<7; i++)ck += data[i]; |
| 642 | |
| 643 | return(ck & 255); |
| 644 | } |
| 645 | |
| 646 | |
| 647 | static const lexmark_res_t_array lexmark_reslist_3200 = /* LEXM_RES_COUNT entries are allowed !! */ |
| 648 | { |
| 649 | /* name hres vres softw v_pass overs unidir resid */ |
| 650 | { "300x600dpi", N_ ("300 DPI x 600 DPI"), 300, 600, 0, 1, 1, 0, DPI300 }, |
| 651 | { "600dpi", N_ ("600 DPI"), 600, 600, 0, 1, 1, 0, DPI600 }, |
| 652 | { "600hq", N_ ("600 DPI high quality"), 600, 600, 1, 4, 1, 0, DPI600 }, |
| 653 | { "600uni", N_ ("600 DPI Unidirectional"), 600, 600, 0, 1, 1, 1, DPI600 }, |
| 654 | { "1200dpi", N_ ("1200 DPI"), 1200, 1200, 1, 1, 1, 0, DPI1200}, |
| 655 | { "1200hq", N_ ("1200 DPI high quality"), 1200, 1200, 1, 1, 1, 0, DPI300 }, |
| 656 | { "1200hq2", N_ ("1200 DPI highest quality"), 1200, 1200, 1, 1, 1, 0, DPI600 }, |
| 657 | { "1200uni", N_ ("1200 DPI Unidirectional"), 1200, 1200, 0, 1, 1, 1, DPI1200}, |
| 658 | { "", "", 0, 0, 0, 0, 0, -1 } |
| 659 | }; |
| 660 | |
| 661 | |
| 662 | static const lexmark_inkname_t ink_types_3200[] = |
| 663 | { |
| 664 | /* output_type ncolors used_colors pass_length v_top_head_offset |
| 665 | * h_cartridge_offset |
| 666 | * h_direction_offset |
| 667 | * head_offset */ |
| 668 | { "CMYK", N_("Four Color Standard"), |
| 669 | {{ 1, COLOR_MODE_K, 208, 20, 0, 12, head_offset_cmyk }, |
| 670 | { 4, COLOR_MODE_CMYK, 192/3, 0, 0, 12, head_offset_cmyk }}}, |
| 671 | { "RGB", N_("Three Color Composite"), |
| 672 | {{ 1, COLOR_MODE_K, 208, 20, 0, 12, head_offset_cmyk }, /* we ignore CMY, use black */ |
| 673 | { 4, COLOR_MODE_CMY, 192/3, 0, 0, 12, head_offset_cmy }}}, |
| 674 | { "PhotoCMYK", N_("Six Color Photo"), |
| 675 | {{ 1, COLOR_MODE_K, 192/3, 0, 0, 12, head_offset_cCmMyk }, |
| 676 | { 6, COLOR_MODE_CcMcYK, 192/3, 0, 0, 12, head_offset_cCmMyk }}}, |
| 677 | { "PhotoCMY", N_("Five Color Photo Composite"), |
| 678 | {{ 1, COLOR_MODE_K, 208, 20, 0, 12, head_offset_cCmMyk }, /* we ignore CMY, use black */ |
| 679 | { 5, COLOR_MODE_CcMcY, 192/3, 0, 0, 12, head_offset_cCmMyk }}}, |
| 680 | { NULL, NULL } |
| 681 | }; |
| 682 | |
| 683 | |
| 684 | |
| 685 | |
| 686 | |
| 687 | /* main structure */ |
| 688 | static const lexmark_cap_t lexmark_model_capabilities[] = |
| 689 | { |
| 690 | /* default settings for unknown models */ |
| 691 | |
| 692 | { (Lex_model)-1, 8*72,11*72,180,180,20,20,20,20, LEXMARK_INK_K, LEXMARK_SLOT_ASF1, 0 }, |
| 693 | |
| 694 | /* tested models */ |
| 695 | |
| 696 | { /* Lexmark z52 */ |
| 697 | m_z52, |
| 698 | 618, 936, /* max paper size *//* 8.58" x 13 " */ |
| 699 | INCH(2), INCH(4), /* min paper size */ |
| 700 | 2400, 1200, 2, /* max resolution */ |
| 701 | 0, 0, 5, 15, /* 15 36 border l,r,t,b unit is 1/72 DPI */ |
| 702 | LEXMARK_INK_CMY | LEXMARK_INK_CMYK | LEXMARK_INK_CcMmYK, |
| 703 | LEXMARK_SLOT_ASF1 | LEXMARK_SLOT_MAN1, |
| 704 | LEXMARK_CAP_DMT, |
| 705 | /*** printer internal parameters ***/ |
| 706 | 20, /* real left paper border */ |
| 707 | 123, /* real top paper border */ |
| 708 | 2400, /* horizontal resolution of 2400 dpi for positioning */ |
| 709 | 1200, /* use a vertical resolution of 1200 dpi for positioning */ |
| 710 | &lexmark_reslist_z52, /* resolution specific parameters of z52 */ |
| 711 | ink_types_z52, /* supported inks */ |
| 712 | standard_lum_adjustment, standard_hue_adjustment, standard_sat_adjustment |
| 713 | }, |
| 714 | { /* Lexmark z42 */ |
| 715 | m_z42, |
| 716 | 618, 936, /* max paper size *//* 8.58" x 13 " */ |
| 717 | INCH(2), INCH(4), /* min paper size */ |
| 718 | 2400, 1200, 2, /* max resolution */ |
| 719 | 0, 0, 5, 41, /* border l,r,t,b unit is 1/72 DPI */ |
| 720 | LEXMARK_INK_CMY | LEXMARK_INK_CMYK | LEXMARK_INK_CcMmYK, |
| 721 | LEXMARK_SLOT_ASF1 | LEXMARK_SLOT_MAN1, |
| 722 | LEXMARK_CAP_DMT, |
| 723 | /*** printer internal parameters ***/ |
| 724 | 20, /* real left paper border */ |
| 725 | 123, /* real top paper border */ |
| 726 | 2400, /* horizontal resolution of 2400 dpi for positioning */ |
| 727 | 1200, /* use a vertical resolution of 1200 dpi for positioning */ |
| 728 | &lexmark_reslist_z52, /* resolution specific parameters of z52 */ |
| 729 | ink_types_z52, /* supported inks */ |
| 730 | standard_lum_adjustment, standard_hue_adjustment, standard_sat_adjustment |
| 731 | }, |
| 732 | { /* Lexmark 3200 */ |
| 733 | m_3200, |
| 734 | 618, 936, /* 8.58" x 13 " */ |
| 735 | INCH(2), INCH(4), /* min paper size */ |
| 736 | 1200, 1200, 2, |
| 737 | 11, 9, 10, 18, |
| 738 | LEXMARK_INK_CMYK | LEXMARK_INK_CcMmYK, |
| 739 | LEXMARK_SLOT_ASF1 | LEXMARK_SLOT_MAN1, |
| 740 | LEXMARK_CAP_DMT, |
| 741 | /*** printer internal parameters ***/ |
| 742 | 0, /* real left paper border */ |
| 743 | 300, /* real top paper border */ |
| 744 | 1200, /* horizontal resolution of ?? dpi for positioning */ |
| 745 | 1200, /* use a vertical resolution of 1200 dpi for positioning */ |
| 746 | &lexmark_reslist_3200, /* resolution specific parameters of 3200 */ |
| 747 | ink_types_3200, /* supported inks */ |
| 748 | standard_lum_adjustment, standard_hue_adjustment, standard_sat_adjustment |
| 749 | }, |
| 750 | { /* */ |
| 751 | m_lex7500, |
| 752 | 618, 936, /* 8.58" x 13 " */ |
| 753 | INCH(2), INCH(4), /* min paper size */ |
| 754 | 2400, 1200, 2, |
| 755 | 11, 9, 10, 18, |
| 756 | LEXMARK_INK_CMY | LEXMARK_INK_CMYK | LEXMARK_INK_CcMmYK, |
| 757 | LEXMARK_SLOT_ASF1 | LEXMARK_SLOT_MAN1, |
| 758 | LEXMARK_CAP_DMT, |
| 759 | /*** printer internal parameters ***/ |
| 760 | 0, /* real left paper border */ |
| 761 | 300, /* real top paper border */ |
| 762 | 1200, /* horizontal resolution of ??? dpi for positioning */ |
| 763 | 1200, /* use a vertical resolution of 1200 dpi for positioning */ |
| 764 | &lexmark_reslist_3200, /* resolution specific parameters of ?? */ |
| 765 | ink_types_3200, /* supported inks */ |
| 766 | standard_lum_adjustment, standard_hue_adjustment, standard_sat_adjustment |
| 767 | }, |
| 768 | }; |
| 769 | |
| 770 | |
| 771 | |
| 772 | |
| 773 | |
| 774 | typedef struct lexm_privdata_weave { |
| 775 | const lexmark_inkparam_t *ink_parameter; |
| 776 | int bidirectional; /* tells us if we are allowed to print bidirectional */ |
| 777 | int direction; /* stores the last direction or print head */ |
| 778 | int hoffset; |
| 779 | int model; |
| 780 | int width; |
| 781 | int ydpi; |
| 782 | int xdpi; |
| 783 | int physical_xdpi; |
| 784 | int last_pass_offset; |
| 785 | int jets; |
| 786 | int bitwidth; |
| 787 | int ncolors; |
| 788 | int horizontal_weave; |
| 789 | unsigned char *outbuf; |
| 790 | } lexm_privdata_weave; |
| 791 | |
| 792 | |
| 793 | /* |
| 794 | * internal functions |
| 795 | */ |
| 796 | static int model_to_index(int model) |
| 797 | { |
| 798 | unsigned int i; |
| 799 | unsigned int models= sizeof(lexmark_model_capabilities) / sizeof(lexmark_cap_t); |
| 800 | for (i=0; i<models; i++) { |
| 801 | if (lexmark_model_capabilities[i].model == model) { |
| 802 | return i; |
| 803 | } |
| 804 | } |
| 805 | return -1; |
| 806 | } |
| 807 | |
| 808 | |
| 809 | static const lexmark_cap_t * |
| 810 | lexmark_get_model_capabilities(const stp_vars_t *v, int model) |
| 811 | { |
| 812 | int i = model_to_index(model); |
| 813 | |
| 814 | if (i != -1) { |
| 815 | return &(lexmark_model_capabilities[i]); |
| 816 | } |
| 817 | stp_dprintf(STP_DBG_LEXMARK, v, |
| 818 | "lexmark: model %d not found in capabilities list.\n",model); |
| 819 | return &(lexmark_model_capabilities[0]); |
| 820 | } |
| 821 | |
| 822 | |
| 823 | |
| 824 | typedef struct |
| 825 | { |
| 826 | const char *name; |
| 827 | const char *text; |
| 828 | int paper_feed_sequence; |
| 829 | int platen_gap; |
| 830 | double base_density; |
| 831 | double k_lower_scale; |
| 832 | double k_upper; |
| 833 | double cyan; |
| 834 | double magenta; |
| 835 | double yellow; |
| 836 | double p_cyan; |
| 837 | double p_magenta; |
| 838 | double p_yellow; |
| 839 | double saturation; |
| 840 | double gamma; |
| 841 | int feed_adjustment; |
| 842 | int vacuum_intensity; |
| 843 | int paper_thickness; |
| 844 | const char *hue_adjustment; |
| 845 | const char *lum_adjustment; |
| 846 | const char *sat_adjustment; |
| 847 | } paper_t; |
| 848 | |
| 849 | |
| 850 | |
| 851 | static const paper_t lexmark_paper_list[] = |
| 852 | { |
| 853 | { "Plain", N_("Plain Paper"), |
| 854 | 1, 0, 0.80, .1, .5, 1.0, 1.0, 1.0, .9, 1.05, 1.15, |
| 855 | 1, 1.0, 0x6b, 0x1a, 0x01, |
| 856 | standard_hue_adjustment, standard_lum_adjustment, standard_sat_adjustment}, |
| 857 | { "GlossyFilm", N_("Glossy Film"), |
| 858 | 3, 0, 1.00 ,1, .999, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, |
| 859 | 1, 1.0, 0x6d, 0x00, 0x01, |
| 860 | standard_hue_adjustment, standard_lum_adjustment, standard_sat_adjustment}, |
| 861 | { "Transparency", N_("Transparencies"), |
| 862 | 3, 0, 1.00, 1, .999, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, |
| 863 | 1.0, 1.0, 0x6d, 0x00, 0x02, |
| 864 | standard_hue_adjustment, standard_lum_adjustment, standard_sat_adjustment}, |
| 865 | { "Envelope", N_("Envelopes"), |
| 866 | 4, 0, 0.80, .125, .5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, |
| 867 | 1, 1.0, 0x6b, 0x1a, 0x01, |
| 868 | standard_hue_adjustment, standard_lum_adjustment, standard_sat_adjustment}, |
| 869 | { "Matte", N_("Matte Paper"), |
| 870 | 7, 0, 0.85, 1.0, .999, 1.05, .9, 1.05, .9, 1.0, 1.1, |
| 871 | 1, 1.0, 0x00, 0x00, 0x02, |
| 872 | standard_hue_adjustment, standard_sat_adjustment, standard_sat_adjustment}, |
| 873 | { "Inkjet", N_("Inkjet Paper"), |
| 874 | 7, 0, 0.85, .25, .6, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, |
| 875 | 1, 1.0, 0x6b, 0x1a, 0x01, |
| 876 | standard_hue_adjustment, standard_lum_adjustment, standard_sat_adjustment}, |
| 877 | { "Coated", N_("Photo Quality Inkjet Paper"), |
| 878 | 7, 0, 1.00, 1.0, .999, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, |
| 879 | 1, 1.0, 0x6b, 0x1a, 0x01, |
| 880 | standard_hue_adjustment, standard_lum_adjustment, standard_sat_adjustment}, |
| 881 | { "Photo", N_("Photo Paper"), |
| 882 | 8, 0, 1.00, 1.0, .9, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, |
| 883 | 1, 1.0, 0x67, 0x00, 0x02, |
| 884 | standard_hue_adjustment, standard_lum_adjustment, standard_sat_adjustment}, |
| 885 | { "GlossyPhoto", N_("Premium Glossy Photo Paper"), |
| 886 | 8, 0, 1.10, 1, .999, 1.0, 1.0, 1.0, 1.0, 1.03, 1.0, |
| 887 | 1, 1.0, 0x80, 0x00, 0x02, |
| 888 | standard_hue_adjustment, standard_lum_adjustment, standard_sat_adjustment}, |
| 889 | { "Luster", N_("Premium Luster Photo Paper"), |
| 890 | 8, 0, 1.00, 1, .999, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, |
| 891 | 1.0, 1.0, 0x80, 0x00, 0x02, |
| 892 | standard_hue_adjustment, standard_lum_adjustment, standard_sat_adjustment}, |
| 893 | { "GlossyPaper", N_("Photo Quality Glossy Paper"), |
| 894 | 6, 0, 1.00, 1, .999, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, |
| 895 | 1.0, 1.0, 0x6b, 0x1a, 0x01, |
| 896 | standard_hue_adjustment, standard_lum_adjustment, standard_sat_adjustment}, |
| 897 | { "Ilford", N_("Ilford Heavy Paper"), |
| 898 | 8, 0, .85, .5, 1.35, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, |
| 899 | 1, 1.0, 0x80, 0x00, 0x02, |
| 900 | standard_hue_adjustment, standard_lum_adjustment, standard_sat_adjustment}, |
| 901 | { "Other", N_("Other"), |
| 902 | 0, 0, 0.80, 0.125, .5, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, |
| 903 | 1, 1.0, 0x6b, 0x1a, 0x01, |
| 904 | standard_hue_adjustment, standard_lum_adjustment, standard_sat_adjustment}, |
| 905 | }; |
| 906 | |
| 907 | static const int paper_type_count = sizeof(lexmark_paper_list) / sizeof(paper_t); |
| 908 | |
| 909 | static const lexmark_inkname_t * |
| 910 | lexmark_get_ink_type(const char *name, int printing_color, const lexmark_cap_t * caps) |
| 911 | { |
| 912 | int i = 0; |
| 913 | (void)printing_color; |
| 914 | const lexmark_inkname_t *ink_type = caps->ink_types; |
| 915 | |
| 916 | if (name) |
| 917 | for (i=0; ((ink_type[i].name != NULL) && |
| 918 | (strcmp(name, ink_type[i].name) != 0)); i++) ; |
| 919 | return &(ink_type[i]); |
| 920 | |
| 921 | } |
| 922 | |
| 923 | static const lexmark_inkparam_t * |
| 924 | lexmark_get_ink_parameter(const char *name, int printing_color, const lexmark_cap_t * caps, const stp_vars_t *nv) |
| 925 | { |
| 926 | const lexmark_inkname_t *ink_type = lexmark_get_ink_type(name, printing_color, caps); |
| 927 | (void)caps; |
| 928 | (void)nv; |
| 929 | |
| 930 | if (ink_type->name == NULL) { |
| 931 | return (NULL); /* not found ! */ |
| 932 | } |
| 933 | |
| 934 | return &(ink_type->ink_parameter[printing_color]); |
| 935 | } |
| 936 | |
| 937 | |
| 938 | static const paper_t * |
| 939 | get_media_type(const char *name, const lexmark_cap_t * caps) |
| 940 | { |
| 941 | (void)caps; |
| 942 | int i; |
| 943 | if (name) |
| 944 | { |
| 945 | for (i = 0; i < paper_type_count; i++) |
| 946 | { |
| 947 | if (!strcmp(name, lexmark_paper_list[i].name)) |
| 948 | return &(lexmark_paper_list[i]); |
| 949 | } |
| 950 | } |
| 951 | return NULL; |
| 952 | } |
| 953 | |
| 954 | #pragma GCC diagnostic push |
| 955 | #pragma GCC diagnostic ignored "-Wunused-function" |
| 956 | static inline int |
| 957 | lexmark_source_type(const stp_vars_t *v, const char *name, const lexmark_cap_t * caps) |
| 958 | { |
| 959 | (void)caps; |
| 960 | if (name) |
| 961 | { |
| 962 | if (!strcmp(name,"Auto")) return 4; |
| 963 | if (!strcmp(name,"Manual")) return 0; |
| 964 | if (!strcmp(name,"ManualNP")) return 1; |
| 965 | } |
| 966 | |
| 967 | stp_dprintf(STP_DBG_LEXMARK, v, |
| 968 | "lexmark: Unknown source type '%s' - reverting to auto\n",name); |
| 969 | |
| 970 | return 4; |
| 971 | } |
| 972 | #pragma GCC diagnostic pop |
| 973 | |
| 974 | |
| 975 | |
| 976 | /******************************* |
| 977 | lexmark_head_offset |
| 978 | *******************************/ |
| 979 | static const lexmark_lineoff_t * |
| 980 | lexmark_head_offset(const stp_vars_t *v, |
| 981 | int ydpi, /* i */ |
| 982 | const char *ink_type, /* i */ |
| 983 | const lexmark_cap_t * caps, /* i */ |
| 984 | const lexmark_inkparam_t *ink_parameter, /* i */ |
| 985 | lexmark_lineoff_t *lineoff_buffer) /* o */ |
| 986 | { |
| 987 | unsigned int i; |
| 988 | (void)ink_type; |
| 989 | |
| 990 | stp_dprintf(STP_DBG_LEXMARK, v, " size %d, size_v %d, size_v[0] %d\n", (int)sizeof(*lineoff_buffer), (int)sizeof(lineoff_buffer->v), (int)sizeof(lineoff_buffer->v[0])); |
| 991 | memcpy(lineoff_buffer, ink_parameter->head_offset, sizeof(*lineoff_buffer)); |
| 992 | |
| 993 | for (i=0; i < (sizeof(lineoff_buffer->v) / sizeof(lineoff_buffer->v[0])); i++) { |
| 994 | lineoff_buffer->v[i] /= (caps->y_raster_res / ydpi); |
| 995 | } |
| 996 | return (lineoff_buffer); |
| 997 | } |
| 998 | |
| 999 | |
| 1000 | #if 0 |
| 1001 | /******************************* |
| 1002 | lexmark_size_type |
| 1003 | *******************************/ |
| 1004 | /* This method is actually not used. |
| 1005 | Is there a possibility to set such value ???????????? */ |
| 1006 | static unsigned char |
| 1007 | lexmark_size_type(const stp_vars_t *v, const lexmark_cap_t * caps) |
| 1008 | { |
| 1009 | const stp_papersize_t *pp = stpi_get_papersize_by_size(v, stp_get_page_height(v), |
| 1010 | stp_get_page_width(v)); |
| 1011 | if (pp) |
| 1012 | { |
| 1013 | const char *name = pp->name; |
| 1014 | /* built ins: */ |
| 1015 | if (!strcmp(name,"A5")) return 0x01; |
| 1016 | if (!strcmp(name,"A4")) return 0x03; |
| 1017 | if (!strcmp(name,"B5")) return 0x08; |
| 1018 | if (!strcmp(name,"Letter")) return 0x0d; |
| 1019 | if (!strcmp(name,"Legal")) return 0x0f; |
| 1020 | if (!strcmp(name,"COM10")) return 0x16; |
| 1021 | if (!strcmp(name,"DL")) return 0x17; |
| 1022 | if (!strcmp(name,"LetterExtra")) return 0x2a; |
| 1023 | if (!strcmp(name,"A4Extra")) return 0x2b; |
| 1024 | if (!strcmp(name,"w288h144")) return 0x2d; |
| 1025 | /* custom */ |
| 1026 | |
| 1027 | stp_dprintf(STP_DBG_LEXMARK, v, "lexmark: Unknown paper size '%s' - using custom\n",name); |
| 1028 | } else { |
| 1029 | stp_dprintf(STP_DBG_LEXMARK, v, "lexmark: Couldn't look up paper size %dx%d - " |
| 1030 | "using custom\n",stp_get_page_height(v), stp_get_page_width(v)); |
| 1031 | } |
| 1032 | return 0; |
| 1033 | } |
| 1034 | #endif |
| 1035 | |
| 1036 | |
| 1037 | static int lexmark_get_phys_resolution_vertical(int model) |
| 1038 | { |
| 1039 | (void)model; |
| 1040 | return 600; |
| 1041 | } |
| 1042 | |
| 1043 | #if 0 |
| 1044 | static int lexmark_get_phys_resolution_horizontal(int model) |
| 1045 | { |
| 1046 | (void)model; |
| 1047 | return 1200; |
| 1048 | } |
| 1049 | #endif |
| 1050 | |
| 1051 | static const lexmark_res_t |
| 1052 | *lexmark_get_resolution_para(const stp_vars_t *v, int model, const char *resolution) |
| 1053 | { |
| 1054 | const lexmark_cap_t * caps= lexmark_get_model_capabilities(v, model); |
| 1055 | |
| 1056 | const lexmark_res_t *res = *(caps->res_parameters); /* get the resolution specific parameters of printer */ |
| 1057 | |
| 1058 | if (resolution) |
| 1059 | { |
| 1060 | while (res->hres) |
| 1061 | { |
| 1062 | if ((res->vres <= caps->max_ydpi) && (caps->max_ydpi != -1) && |
| 1063 | (res->hres <= caps->max_xdpi) && (caps->max_xdpi != -1) && |
| 1064 | (!strcmp(resolution, res->name))) |
| 1065 | { |
| 1066 | return res; |
| 1067 | } |
| 1068 | res++; |
| 1069 | } |
| 1070 | } |
| 1071 | stp_dprintf(STP_DBG_LEXMARK, v, "lexmark_get_resolution_para: resolution not found (%s)\n", resolution); |
| 1072 | return NULL; |
| 1073 | } |
| 1074 | |
| 1075 | |
| 1076 | static int |
| 1077 | lexmark_print_bidirectional(const stp_vars_t *v, int model, const char *resolution) |
| 1078 | { |
| 1079 | const lexmark_res_t *res_para = lexmark_get_resolution_para(v, model, resolution); |
| 1080 | return !res_para->unidirectional; |
| 1081 | } |
| 1082 | |
| 1083 | static const char * |
| 1084 | lexmark_lum_adjustment(const lexmark_cap_t * caps, const stp_vars_t *v) |
| 1085 | { |
| 1086 | (void)v; |
| 1087 | return (caps->lum_adjustment); |
| 1088 | } |
| 1089 | |
| 1090 | static const char * |
| 1091 | lexmark_hue_adjustment(const lexmark_cap_t * caps, const stp_vars_t *v) |
| 1092 | { |
| 1093 | (void)v; |
| 1094 | return (caps->hue_adjustment); |
| 1095 | } |
| 1096 | |
| 1097 | static const char * |
| 1098 | lexmark_sat_adjustment(const lexmark_cap_t * caps, const stp_vars_t *v) |
| 1099 | { |
| 1100 | (void)v; |
| 1101 | return (caps->sat_adjustment); |
| 1102 | } |
| 1103 | |
| 1104 | |
| 1105 | static void |
| 1106 | lexmark_describe_resolution(const stp_vars_t *v, |
| 1107 | stp_resolution_t *x, stp_resolution_t *y) |
| 1108 | { |
| 1109 | const char *resolution = stp_get_string_parameter(v, "Resolution"); |
| 1110 | const lexmark_res_t *res = |
| 1111 | lexmark_get_resolution_para(v, stp_get_model_id(v), resolution); |
| 1112 | |
| 1113 | if (res) |
| 1114 | { |
| 1115 | *x = res->hres; |
| 1116 | *y = res->vres; |
| 1117 | return; |
| 1118 | } |
| 1119 | *x = -1; |
| 1120 | *y = -1; |
| 1121 | } |
| 1122 | |
| 1123 | |
| 1124 | static stp_param_string_t media_sources[] = |
| 1125 | { |
| 1126 | { "Auto", N_("Auto Sheet Feeder") }, |
| 1127 | { "Manual", N_("Manual with Pause") }, |
| 1128 | { "ManualNP", N_("Manual without Pause") } |
| 1129 | }; |
| 1130 | |
| 1131 | |
| 1132 | /* |
| 1133 | * 'lexmark_parameters()' - Return the parameter values for the given parameter. |
| 1134 | */ |
| 1135 | |
| 1136 | static stp_parameter_list_t |
| 1137 | lexmark_list_parameters(const stp_vars_t *v) |
| 1138 | { |
| 1139 | stp_parameter_list_t *ret = stp_parameter_list_create(); |
| 1140 | stp_parameter_list_t *tmp_list; |
| 1141 | |
| 1142 | int i; |
| 1143 | |
| 1144 | /* Set up dithering */ |
| 1145 | tmp_list = stp_dither_list_parameters(v); |
| 1146 | stp_parameter_list_append(ret, tmp_list); |
| 1147 | stp_parameter_list_destroy(tmp_list); |
| 1148 | |
| 1149 | for (i = 0; i < the_parameter_count; i++) |
| 1150 | stp_parameter_list_add_param(ret, &(the_parameters[i])); |
| 1151 | for (i = 0; i < float_parameter_count; i++) |
| 1152 | stp_parameter_list_add_param(ret, &(float_parameters[i].param)); |
| 1153 | return ret; |
| 1154 | } |
| 1155 | |
| 1156 | static const char * |
| 1157 | lexmark_describe_output(const stp_vars_t *v) |
| 1158 | { |
| 1159 | int printing_color = 0; |
| 1160 | int model = stp_get_model_id(v); |
| 1161 | const lexmark_cap_t *caps = lexmark_get_model_capabilities(v, model); |
| 1162 | const char *print_mode = stp_get_string_parameter(v, "PrintingMode"); |
| 1163 | const char *ink_type = stp_get_string_parameter(v, "InkType"); |
| 1164 | const lexmark_inkparam_t *ink_parameter; |
| 1165 | |
| 1166 | if (!print_mode || strcmp(print_mode, "Color") == 0) |
| 1167 | printing_color = 1; |
| 1168 | |
| 1169 | ink_parameter = lexmark_get_ink_parameter(ink_type, printing_color, caps, v); |
| 1170 | |
| 1171 | if (!ink_parameter || ink_parameter->used_colors == COLOR_MODE_K || |
| 1172 | caps->inks == LEXMARK_INK_K || !printing_color) |
| 1173 | return "Grayscale"; |
| 1174 | else if (!(ink_parameter->used_colors & COLOR_MODE_K)) |
| 1175 | return "CMY"; |
| 1176 | else |
| 1177 | return "CMYK"; |
| 1178 | } |
| 1179 | |
| 1180 | static void |
| 1181 | lexmark_parameters(const stp_vars_t *v, const char *name, |
| 1182 | stp_parameter_t *description) |
| 1183 | { |
| 1184 | unsigned int i; |
| 1185 | |
| 1186 | const lexmark_cap_t * caps= lexmark_get_model_capabilities(v, stp_get_model_id(v)); |
| 1187 | description->p_type = STP_PARAMETER_TYPE_INVALID; |
| 1188 | |
| 1189 | if (name == NULL) |
| 1190 | return; |
| 1191 | |
| 1192 | for (i = 0; i < float_parameter_count; i++) |
| 1193 | if (strcmp(name, float_parameters[i].param.name) == 0) |
| 1194 | { |
| 1195 | stp_fill_parameter_settings(description, |
| 1196 | &(float_parameters[i].param)); |
| 1197 | description->deflt.dbl = float_parameters[i].defval; |
| 1198 | description->bounds.dbl.upper = float_parameters[i].max; |
| 1199 | description->bounds.dbl.lower = float_parameters[i].min; |
| 1200 | return; |
| 1201 | } |
| 1202 | |
| 1203 | for (i = 0; i < the_parameter_count; i++) |
| 1204 | if (strcmp(name, the_parameters[i].name) == 0) |
| 1205 | { |
| 1206 | stp_fill_parameter_settings(description, &(the_parameters[i])); |
| 1207 | break; |
| 1208 | } |
| 1209 | |
| 1210 | if (strcmp(name, "PageSize") == 0) |
| 1211 | { |
| 1212 | unsigned int height_limit, width_limit; |
| 1213 | unsigned int min_height_limit, min_width_limit; |
| 1214 | const stp_papersize_list_t *paper_sizes = stpi_get_standard_papersize_list(); |
| 1215 | const stp_papersize_list_item_t *ptli = |
| 1216 | stpi_papersize_list_get_start(paper_sizes); |
| 1217 | description->bounds.str = stp_string_list_create(); |
| 1218 | |
| 1219 | width_limit = caps->max_paper_width; |
| 1220 | height_limit = caps->max_paper_height; |
| 1221 | min_width_limit = caps->min_paper_width; |
| 1222 | min_height_limit = caps->min_paper_height; |
| 1223 | |
| 1224 | while (ptli) |
| 1225 | { |
| 1226 | const stp_papersize_t *pt = stpi_paperlist_item_get_data(ptli); |
| 1227 | |
| 1228 | if (pt->paper_size_type == PAPERSIZE_TYPE_STANDARD || |
| 1229 | pt->paper_size_type == PAPERSIZE_TYPE_ENVELOPE) { |
| 1230 | |
| 1231 | if (strlen(pt->name) > 0 && |
| 1232 | pt->width <= width_limit && pt->height <= height_limit && |
| 1233 | (pt->height >= min_height_limit || pt->height == 0) && |
| 1234 | (pt->width >= min_width_limit || pt->width == 0)) |
| 1235 | { |
| 1236 | if (stp_string_list_count(description->bounds.str) == 0) |
| 1237 | description->deflt.str = pt->name; |
| 1238 | stp_string_list_add_string(description->bounds.str, |
| 1239 | pt->name, gettext(pt->text)); |
| 1240 | } |
| 1241 | } |
| 1242 | ptli = stpi_paperlist_item_next(ptli); |
| 1243 | } |
| 1244 | } |
| 1245 | else if (strcmp(name, "Resolution") == 0) |
| 1246 | { |
| 1247 | const lexmark_res_t *res; |
| 1248 | description->bounds.str = stp_string_list_create(); |
| 1249 | |
| 1250 | res = *(caps->res_parameters); /* get resolution specific parameters of printer */ |
| 1251 | |
| 1252 | /* check for allowed resolutions */ |
| 1253 | while (res->hres) |
| 1254 | { |
| 1255 | if (stp_string_list_count(description->bounds.str) == 0) |
| 1256 | description->deflt.str = res->name; |
| 1257 | stp_string_list_add_string(description->bounds.str, |
| 1258 | res->name, gettext(res->text)); |
| 1259 | res++; |
| 1260 | } |
| 1261 | } |
| 1262 | else if (strcmp(name, "InkType") == 0) |
| 1263 | { |
| 1264 | description->bounds.str = stp_string_list_create(); |
| 1265 | description->deflt.str = caps->ink_types[0].name; |
| 1266 | for (i = 0; caps->ink_types[i].name != NULL; i++) |
| 1267 | stp_string_list_add_string(description->bounds.str, |
| 1268 | caps->ink_types[i].name, |
| 1269 | gettext(caps->ink_types[i].text)); |
| 1270 | } |
| 1271 | else if (strcmp(name, "MediaType") == 0) |
| 1272 | { |
| 1273 | description->bounds.str = stp_string_list_create(); |
| 1274 | description->deflt.str = lexmark_paper_list[0].name; |
| 1275 | for (i = 0; i < paper_type_count; i++) |
| 1276 | stp_string_list_add_string(description->bounds.str, |
| 1277 | lexmark_paper_list[i].name, |
| 1278 | gettext(lexmark_paper_list[i].text)); |
| 1279 | } |
| 1280 | else if (strcmp(name, "InputSlot") == 0) |
| 1281 | { |
| 1282 | description->bounds.str = stp_string_list_create(); |
| 1283 | description->deflt.str = media_sources[0].name; |
| 1284 | for (i = 0; i < sizeof(media_sources) / sizeof(stp_param_string_t); i++) |
| 1285 | stp_string_list_add_string(description->bounds.str, |
| 1286 | media_sources[i].name, |
| 1287 | gettext(media_sources[i].name)); |
| 1288 | } |
| 1289 | else if (strcmp(name, "InkChannels") == 0) |
| 1290 | { |
| 1291 | if (caps->inks & LEXMARK_INK_CcMmYyK) |
| 1292 | description->deflt.integer = 7; |
| 1293 | else if (caps->inks & LEXMARK_INK_CcMmYK) |
| 1294 | description->deflt.integer = 6; |
| 1295 | else if (caps->inks & LEXMARK_INK_CMYK) |
| 1296 | description->deflt.integer = 4; |
| 1297 | else if (caps->inks & LEXMARK_INK_CMY) |
| 1298 | description->deflt.integer = 3; |
| 1299 | else |
| 1300 | description->deflt.integer = 1; |
| 1301 | description->bounds.integer.lower = -1; |
| 1302 | description->bounds.integer.upper = -1; |
| 1303 | } |
| 1304 | else if (strcmp(name, "PrintingMode") == 0) |
| 1305 | { |
| 1306 | description->bounds.str = stp_string_list_create(); |
| 1307 | if (caps->inks != LEXMARK_INK_K) |
| 1308 | stp_string_list_add_string |
| 1309 | (description->bounds.str, "Color", _("Color")); |
| 1310 | stp_string_list_add_string |
| 1311 | (description->bounds.str, "BW", _("Black and White")); |
| 1312 | description->deflt.str = |
| 1313 | stp_string_list_param(description->bounds.str, 0)->name; |
| 1314 | } |
| 1315 | } |
| 1316 | |
| 1317 | /* |
| 1318 | * 'lexmark_imageable_area()' - Return the imageable area of the page. |
| 1319 | */ |
| 1320 | |
| 1321 | static void |
| 1322 | internal_imageable_area(const stp_vars_t *v, /* I */ |
| 1323 | int use_paper_margins, |
| 1324 | stp_dimension_t *left, /* O - Left position in points */ |
| 1325 | stp_dimension_t *right, /* O - Right position in points */ |
| 1326 | stp_dimension_t *bottom, /* O - Bottom position in points */ |
| 1327 | stp_dimension_t *top) /* O - Top position in points */ |
| 1328 | { |
| 1329 | stp_dimension_t width, length; /* Size of page */ |
| 1330 | stp_dimension_t left_margin = 0; |
| 1331 | stp_dimension_t right_margin = 0; |
| 1332 | stp_dimension_t bottom_margin = 0; |
| 1333 | stp_dimension_t top_margin = 0; |
| 1334 | const char *media_size = stp_get_string_parameter(v, "PageSize"); |
| 1335 | const stp_papersize_t *pt = NULL; |
| 1336 | const lexmark_cap_t *caps = |
| 1337 | lexmark_get_model_capabilities(v, stp_get_model_id(v)); |
| 1338 | |
| 1339 | |
| 1340 | if (media_size && use_paper_margins) |
| 1341 | pt = stp_describe_papersize(v, media_size); |
| 1342 | |
| 1343 | stp_default_media_size(v, &width, &length); |
| 1344 | if (pt) |
| 1345 | { |
| 1346 | left_margin = pt->left; |
| 1347 | right_margin = pt->right; |
| 1348 | bottom_margin = pt->bottom; |
| 1349 | top_margin = pt->top; |
| 1350 | } |
| 1351 | left_margin = max(left_margin, caps->border_left); |
| 1352 | right_margin = max(right_margin, caps->border_right); |
| 1353 | top_margin = max(top_margin, caps->border_top); |
| 1354 | bottom_margin = max(bottom_margin, caps->border_bottom); |
| 1355 | |
| 1356 | *left = left_margin; |
| 1357 | *right = width - right_margin; |
| 1358 | *top = top_margin; |
| 1359 | *bottom = length - bottom_margin; |
| 1360 | } |
| 1361 | |
| 1362 | static void |
| 1363 | lexmark_imageable_area(const stp_vars_t *v, /* I */ |
| 1364 | stp_dimension_t *left, /* O - Left position in points */ |
| 1365 | stp_dimension_t *right, /* O - Right position in points */ |
| 1366 | stp_dimension_t *bottom, /* O - Bottom position in points */ |
| 1367 | stp_dimension_t *top) /* O - Top position in points */ |
| 1368 | { |
| 1369 | internal_imageable_area(v, 1, left, right, bottom, top); |
| 1370 | } |
| 1371 | |
| 1372 | static void |
| 1373 | lexmark_limit(const stp_vars_t *v, /* I */ |
| 1374 | stp_dimension_t *width, |
| 1375 | stp_dimension_t *height, |
| 1376 | stp_dimension_t *min_width, |
| 1377 | stp_dimension_t *min_height) |
| 1378 | { |
| 1379 | const lexmark_cap_t * caps= lexmark_get_model_capabilities(v, stp_get_model_id(v)); |
| 1380 | *width = caps->max_paper_width; |
| 1381 | *height = caps->max_paper_height; |
| 1382 | *min_width = caps->min_paper_width; |
| 1383 | *min_height = caps->min_paper_height; |
| 1384 | } |
| 1385 | |
| 1386 | |
| 1387 | |
| 1388 | static int |
| 1389 | lexmark_init_printer(const stp_vars_t *v, const lexmark_cap_t * caps, |
| 1390 | int printing_color, |
| 1391 | const char *source_str, |
| 1392 | int xdpi, int ydpi, |
| 1393 | int page_width, int page_height, |
| 1394 | int top, int left, |
| 1395 | int use_dmt) |
| 1396 | { |
| 1397 | (void)printing_color; |
| 1398 | (void)source_str; |
| 1399 | (void)xdpi; |
| 1400 | (void)ydpi; |
| 1401 | (void)page_width; |
| 1402 | (void)page_height; |
| 1403 | (void)top; |
| 1404 | (void)left; |
| 1405 | (void)use_dmt; |
| 1406 | |
| 1407 | /* because the details of the header sequence are not known, we simply write it as one image. */ |
| 1408 | |
| 1409 | #define LXM_Z52_STARTSIZE 0x35 |
| 1410 | /* 300 dpi */ |
| 1411 | unsigned char startHeader_z52[LXM_Z52_STARTSIZE]={0x1b,0x2a,0x81,0x00,0x1c,0x56,0x49,0x00, |
| 1412 | 0x01,0x00,0x2c,0x01,0x00,0x00,0x60,0x09, |
| 1413 | 0xe4,0x0c,0x01,0x00,0x34,0x00,0x00,0x00, |
| 1414 | 0x08,0x00,0x08,0x00,0x1b,0x2a,0x07,0x76, |
| 1415 | 0x01,0x1b,0x2a,0x07,0x73,0x30,0x1b,0x2a, |
| 1416 | 0x6d,0x00,0x14,0x01,0xf4,0x02,0x00,0x01, |
| 1417 | 0xf0,0x1b,0x2a,0x07,0x63}; |
| 1418 | |
| 1419 | #define LXM_Z42_STARTSIZE 0x30 |
| 1420 | /* 600 dpi */ |
| 1421 | unsigned char startHeader_z42[LXM_Z42_STARTSIZE]={0x1B,0x2A,0x81,0x00,0x1C,0x50,0x41,0x00, |
| 1422 | 0x01,0x00,0x58,0x02,0x04,0x00,0xC0,0x12, |
| 1423 | 0xC8,0x19,0x02,0x00,0x50,0x00,0x14,0x00, |
| 1424 | 0x07,0x00,0x08,0x00,0x1B,0x2A,0x07,0x73, |
| 1425 | 0x30,0x1B,0x2A,0x6D,0x00,0x14,0x01,0xC0, |
| 1426 | 0x02,0x00,0x01,0xBE,0x1B,0x2A,0x07,0x63}; |
| 1427 | |
| 1428 | #define ESC2a "\033\052" |
| 1429 | |
| 1430 | |
| 1431 | |
| 1432 | #define LXM_3200_STARTSIZE 32 |
| 1433 | |
| 1434 | unsigned char startHeader_3200[LXM_3200_STARTSIZE] = |
| 1435 | { |
| 1436 | 0x1b, 0x2a, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1437 | 0x1b, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, |
| 1438 | 0x1b, 0x30, 0x80, 0x0C, 0x02, 0x00, 0x00, 0xbe, |
| 1439 | 0x1b, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21 |
| 1440 | }; |
| 1441 | |
| 1442 | /* write init sequence */ |
| 1443 | switch(caps->model) |
| 1444 | { |
| 1445 | case m_z52: |
| 1446 | stp_zfwrite((const char *) startHeader_z52, |
| 1447 | LXM_Z52_STARTSIZE,1,v); |
| 1448 | #ifdef DEBUG |
| 1449 | lex_write_tmp_file(dbgfileprn, (void *)startHeader_z52, LXM_Z52_STARTSIZE); |
| 1450 | #endif |
| 1451 | break; |
| 1452 | |
| 1453 | case m_z42: |
| 1454 | stp_zfwrite((const char *) startHeader_z42, |
| 1455 | LXM_Z42_STARTSIZE,1,v); |
| 1456 | #ifdef DEBUG |
| 1457 | lex_write_tmp_file(dbgfileprn, (void *)startHeader_z42, LXM_Z42_STARTSIZE); |
| 1458 | #endif |
| 1459 | break; |
| 1460 | |
| 1461 | case m_3200: |
| 1462 | stp_zfwrite((const char *) startHeader_3200, |
| 1463 | LXM_3200_STARTSIZE, 1, v); |
| 1464 | break; |
| 1465 | |
| 1466 | default: |
| 1467 | stp_eprintf(v, "Unknown printer !! %i\n", caps->model); |
| 1468 | return 0; |
| 1469 | } |
| 1470 | |
| 1471 | |
| 1472 | |
| 1473 | /* |
| 1474 | stp_dprintf(STP_DBG_LEXMARK, v, "lexmark: printable size = %dx%d (%dx%d) %02x%02x %02x%02x\n", |
| 1475 | page_width,page_height,printable_width,printable_length, |
| 1476 | arg_70_1,arg_70_2,arg_70_3,arg_70_4); |
| 1477 | */ |
| 1478 | return 1; |
| 1479 | } |
| 1480 | |
| 1481 | static void lexmark_deinit_printer(const stp_vars_t *v, const lexmark_cap_t * caps) |
| 1482 | { |
| 1483 | |
| 1484 | switch(caps->model) { |
| 1485 | case m_z52: |
| 1486 | { |
| 1487 | char buffer[40]; |
| 1488 | |
| 1489 | memcpy(buffer, ESC2a, 2); |
| 1490 | buffer[2] = 0x7; |
| 1491 | buffer[3] = 0x65; |
| 1492 | |
| 1493 | stp_dprintf(STP_DBG_LEXMARK, v, "lexmark: <<eject page.>> %x %x %x %x\n", buffer[0], buffer[1], buffer[2], buffer[3]); |
| 1494 | #ifdef DEBUG |
| 1495 | lex_write_tmp_file(dbgfileprn, (void *)&(buffer[0]), 4); |
| 1496 | #endif |
| 1497 | /* eject page */ |
| 1498 | stp_zfwrite(buffer, 1, 4, v); |
| 1499 | } |
| 1500 | break; |
| 1501 | |
| 1502 | case m_z42: |
| 1503 | { |
| 1504 | unsigned char buffer[12] = {0x1B,0x2A,0x07,0x65,0x1B,0x2A,0x82,0x00,0x00,0x00,0x00,0xAC}; |
| 1505 | stp_dprintf(STP_DBG_LEXMARK, v, "lexmark: <<eject page.>>\n"); |
| 1506 | #ifdef DEBUG |
| 1507 | lex_write_tmp_file(dbgfileprn, (void *)&(buffer[0]), 12); |
| 1508 | #endif |
| 1509 | /* eject page */ |
| 1510 | stp_zfwrite((char *)buffer, 1, 12, v); |
| 1511 | } |
| 1512 | break; |
| 1513 | |
| 1514 | case m_3200: |
| 1515 | { |
| 1516 | unsigned char buffer[24] = |
| 1517 | { |
| 1518 | 0x1b, 0x22, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1519 | 0x1b, 0x31, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 1520 | 0x1b, 0x33, 0x10, 0x00, 0x00, 0x00, 0x00, 0x33 |
| 1521 | }; |
| 1522 | |
| 1523 | stp_dprintf(STP_DBG_LEXMARK, v, "Headpos: %d\n", lxm3200_headpos); |
| 1524 | |
| 1525 | lxm3200_linetoeject += 2400; |
| 1526 | buffer[3] = lxm3200_linetoeject >> 8; |
| 1527 | buffer[4] = lxm3200_linetoeject & 0xff; |
| 1528 | buffer[7] = lexmark_calc_3200_checksum(&buffer[0]); |
| 1529 | buffer[11] = lxm3200_headpos >> 8; |
| 1530 | buffer[12] = lxm3200_headpos & 0xff; |
| 1531 | buffer[15] = lexmark_calc_3200_checksum(&buffer[8]); |
| 1532 | |
| 1533 | stp_zfwrite((const char *)buffer, 24, 1, v); |
| 1534 | } |
| 1535 | break; |
| 1536 | |
| 1537 | case m_lex7500: |
| 1538 | break; |
| 1539 | } |
| 1540 | |
| 1541 | } |
| 1542 | |
| 1543 | |
| 1544 | /* paper_shift() -- shift paper in printer -- units are unknown :-) |
| 1545 | */ |
| 1546 | static void paper_shift(const stp_vars_t *v, int offset, const lexmark_cap_t * caps) |
| 1547 | { |
| 1548 | switch(caps->model) { |
| 1549 | case m_z52: |
| 1550 | case m_z42: |
| 1551 | { |
| 1552 | unsigned char buf[5] = {0x1b, 0x2a, 0x3, 0x0, 0x0}; |
| 1553 | if(offset == 0)return; |
| 1554 | buf[3] = (unsigned char)(offset >> 8); |
| 1555 | buf[4] = (unsigned char)(offset & 0xFF); |
| 1556 | stp_zfwrite((const char *)buf, 1, 5, v); |
| 1557 | #ifdef DEBUG |
| 1558 | lex_write_tmp_file(dbgfileprn, (void *)buf, 5); |
| 1559 | #endif |
| 1560 | } |
| 1561 | break; |
| 1562 | |
| 1563 | case m_3200: |
| 1564 | { |
| 1565 | unsigned char buf[8] = {0x1b, 0x23, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00}; |
| 1566 | if(offset == 0)return; |
| 1567 | lxm3200_linetoeject -= offset; |
| 1568 | buf[3] = (unsigned char)(offset >> 8); |
| 1569 | buf[4] = (unsigned char)(offset & 0xff); |
| 1570 | buf[7] = lexmark_calc_3200_checksum(buf); |
| 1571 | stp_zfwrite((const char *)buf, 1, 8, v); |
| 1572 | } |
| 1573 | break; |
| 1574 | |
| 1575 | case m_lex7500: |
| 1576 | break; |
| 1577 | } |
| 1578 | |
| 1579 | stp_dprintf(STP_DBG_LEXMARK, v, "Lines to eject: %d\n", lxm3200_linetoeject); |
| 1580 | } |
| 1581 | |
| 1582 | /* |
| 1583 | * 'advance_buffer()' - Move (num) lines of length (len) down one line |
| 1584 | * and sets first line to 0s |
| 1585 | * accepts NULL pointers as buf |
| 1586 | * !!! buf must contain more than (num) lines !!! |
| 1587 | * also sets first line to 0s if num<1 |
| 1588 | */ |
| 1589 | #if 0 |
| 1590 | static void |
| 1591 | lexmark_advance_buffer(unsigned char *buf, int len, int num) |
| 1592 | { |
| 1593 | if (!buf || !len) return; |
| 1594 | if (num>0) memmove(buf+len,buf,len*num); |
| 1595 | memset(buf,0,len); |
| 1596 | } |
| 1597 | #endif |
| 1598 | |
| 1599 | static double |
| 1600 | get_double_param(stp_vars_t *v, const char *param) |
| 1601 | { |
| 1602 | if (param && stp_check_float_parameter(v, param, STP_PARAMETER_ACTIVE)) |
| 1603 | return stp_get_float_parameter(v, param); |
| 1604 | else |
| 1605 | return 1.0; |
| 1606 | } |
| 1607 | |
| 1608 | /********************************************************** |
| 1609 | * lexmark_print() - Print an image to a LEXMARK printer. |
| 1610 | **********************************************************/ |
| 1611 | /* This method should not be printer dependent (maybe it is because of nozzle count and other things) */ |
| 1612 | /* The method will set the printing method depending on the selected printer. |
| 1613 | It will define the colors to be used and the resolution. |
| 1614 | Additionally the pass_length will be defined. |
| 1615 | The method lexmark_write() is responsible to handle the received lines |
| 1616 | in a correct way. |
| 1617 | */ |
| 1618 | static int |
| 1619 | lexmark_do_print(stp_vars_t *v, stp_image_t *image) |
| 1620 | { |
| 1621 | int status = 1; |
| 1622 | int y; /* Looping vars */ |
| 1623 | stp_resolution_t xdpi, ydpi; /* Resolution */ |
| 1624 | stp_dimension_t page_width, /* Width of page */ |
| 1625 | page_height, /* Length of page */ |
| 1626 | page_left, |
| 1627 | page_top, |
| 1628 | page_right, |
| 1629 | page_bottom, |
| 1630 | page_true_width, /* True length of page */ |
| 1631 | page_true_height; /* True length of page */ |
| 1632 | int |
| 1633 | out_width, /* Width of image on page in pixels */ |
| 1634 | out_height, /* Length of image on page */ |
| 1635 | length, /* Length of raster data in bytes*/ |
| 1636 | buf_length, /* Length of raster data buffer (dmt) */ |
| 1637 | errdiv, /* Error dividend */ |
| 1638 | errmod, /* Error modulus */ |
| 1639 | errval, /* Current error value */ |
| 1640 | errline, /* Current raster line */ |
| 1641 | errlast; /* Last raster line loaded */ |
| 1642 | unsigned zero_mask = 0; |
| 1643 | int image_height; |
| 1644 | int use_dmt = 0; |
| 1645 | int pass_length=0; /* count of inkjets for one pass */ |
| 1646 | int add_top_offset=0; /* additional top offset */ |
| 1647 | int printMode = 0; |
| 1648 | /* Lexmark do not have different pixel sizes. We have to correct the density according the print resolution. */ |
| 1649 | double densityDivisor; /* This parameter is will adapt the density according the resolution */ |
| 1650 | double k_lower, k_upper; |
| 1651 | int physical_xdpi = 0; |
| 1652 | int physical_ydpi = 0; |
| 1653 | int i; |
| 1654 | |
| 1655 | stp_curve_t *lum_adjustment = NULL; |
| 1656 | stp_curve_t *hue_adjustment = NULL; |
| 1657 | stp_curve_t *sat_adjustment = NULL; |
| 1658 | |
| 1659 | /* weave parameters */ |
| 1660 | lexmark_linebufs_t cols; |
| 1661 | int nozzle_separation; |
| 1662 | int horizontal_passes; |
| 1663 | int ncolors; |
| 1664 | lexm_privdata_weave privdata; |
| 1665 | |
| 1666 | lexmark_lineoff_t lineoff_buffer; /* holds the line offsets of each color */ |
| 1667 | #ifdef DEBUG |
| 1668 | testdata td; |
| 1669 | #endif |
| 1670 | |
| 1671 | |
| 1672 | int model = stp_get_model_id(v); |
| 1673 | const char *resolution = stp_get_string_parameter(v, "Resolution"); |
| 1674 | const char *media_type = stp_get_string_parameter(v, "MediaType"); |
| 1675 | const char *media_source = stp_get_string_parameter(v, "InputSlot"); |
| 1676 | const char *print_mode = stp_get_string_parameter(v, "PrintingMode"); |
| 1677 | int printing_color = 0; |
| 1678 | const char *ink_type = stp_get_string_parameter(v, "InkType"); |
| 1679 | stp_dimension_t top = stp_get_top(v); |
| 1680 | stp_dimension_t left = stp_get_left(v); |
| 1681 | |
| 1682 | const lexmark_cap_t * caps= lexmark_get_model_capabilities(v, model); |
| 1683 | const lexmark_res_t *res_para_ptr = |
| 1684 | lexmark_get_resolution_para(v, model, resolution); |
| 1685 | const paper_t *media = get_media_type(media_type,caps); |
| 1686 | const lexmark_inkparam_t *ink_parameter; |
| 1687 | |
| 1688 | #ifdef DEBUG |
| 1689 | dbgfileprn = lex_open_tmp_file(); /* open file with xx */ |
| 1690 | #endif |
| 1691 | |
| 1692 | if (!stp_verify(v)) |
| 1693 | { |
| 1694 | stp_eprintf(v, "Print options not verified; cannot print.\n"); |
| 1695 | return 0; |
| 1696 | } |
| 1697 | if (strcmp(print_mode, "Color") == 0) |
| 1698 | printing_color = 1; |
| 1699 | |
| 1700 | ink_parameter = lexmark_get_ink_parameter(ink_type, printing_color, caps, v); |
| 1701 | |
| 1702 | if (ink_parameter == NULL) |
| 1703 | { |
| 1704 | stp_eprintf(v, "Illegal Ink Type specified; cannot print.\n"); |
| 1705 | return 0; |
| 1706 | } |
| 1707 | |
| 1708 | stp_image_init(image); |
| 1709 | |
| 1710 | /* force grayscale if image is grayscale |
| 1711 | * or single black cartridge installed |
| 1712 | */ |
| 1713 | |
| 1714 | if ((ink_parameter->used_colors == COLOR_MODE_K) || |
| 1715 | (caps->inks == LEXMARK_INK_K)) |
| 1716 | { |
| 1717 | printing_color = 0; |
| 1718 | stp_set_string_parameter(v, "PrintingMode", "BW"); |
| 1719 | } |
| 1720 | |
| 1721 | /* |
| 1722 | * Choose the correct color conversion function... |
| 1723 | */ |
| 1724 | |
| 1725 | |
| 1726 | ncolors = ink_parameter->ncolors; |
| 1727 | printMode = ink_parameter->used_colors; |
| 1728 | pass_length = ink_parameter->pass_length; |
| 1729 | add_top_offset = ink_parameter->v_top_head_offset; |
| 1730 | |
| 1731 | |
| 1732 | /* |
| 1733 | * Figure out the output resolution... |
| 1734 | */ |
| 1735 | |
| 1736 | stp_describe_resolution(v, &xdpi, &ydpi); |
| 1737 | stp_dprintf(STP_DBG_LEXMARK, v, "lexmark: resolution=%dx%d\n",(int)xdpi,(int)ydpi); |
| 1738 | |
| 1739 | switch (res_para_ptr->resid) { |
| 1740 | case DPI300: |
| 1741 | physical_xdpi = 300; |
| 1742 | physical_ydpi = lexmark_get_phys_resolution_vertical(model); |
| 1743 | break; |
| 1744 | case DPI600: |
| 1745 | physical_xdpi = 600; |
| 1746 | physical_ydpi = lexmark_get_phys_resolution_vertical(model); |
| 1747 | break; |
| 1748 | case DPI1200: |
| 1749 | case DPItest: |
| 1750 | physical_xdpi = 1200; |
| 1751 | physical_ydpi = lexmark_get_phys_resolution_vertical(model); |
| 1752 | break; |
| 1753 | default: |
| 1754 | return 0; |
| 1755 | break; |
| 1756 | } |
| 1757 | /* adapt the density */ |
| 1758 | densityDivisor = ((xdpi / 300)*(ydpi/ 600)); |
| 1759 | |
| 1760 | #ifdef DEBUG |
| 1761 | if (res_para_ptr->resid == DPItest) { |
| 1762 | stp_dprintf(STP_DBG_LEXMARK, v, "Start test print1\n"); |
| 1763 | doTestPrint = 1; |
| 1764 | } |
| 1765 | #endif |
| 1766 | |
| 1767 | if ((printMode & COLOR_MODE_PHOTO) == COLOR_MODE_PHOTO) { |
| 1768 | /* in case of photo mode we have to go a bit lighter */ |
| 1769 | densityDivisor /= 1.2; |
| 1770 | } |
| 1771 | |
| 1772 | nozzle_separation = ydpi / physical_ydpi; |
| 1773 | |
| 1774 | horizontal_passes = xdpi / physical_xdpi; |
| 1775 | stp_dprintf(STP_DBG_LEXMARK, v, "lexmark: horizontal_passes %i, xdpi %d, physical_xdpi %i\n", |
| 1776 | horizontal_passes, (int)xdpi, physical_xdpi); |
| 1777 | |
| 1778 | |
| 1779 | |
| 1780 | |
| 1781 | if (!strcmp(resolution+(strlen(resolution)-3),"DMT") && |
| 1782 | (caps->features & LEXMARK_CAP_DMT)) { |
| 1783 | use_dmt= 1; |
| 1784 | stp_dprintf(STP_DBG_LEXMARK, v, "lexmark: using drop modulation technology\n"); |
| 1785 | } |
| 1786 | |
| 1787 | /* |
| 1788 | * Compute the output size... |
| 1789 | */ |
| 1790 | |
| 1791 | out_width = stp_get_width(v); |
| 1792 | out_height = stp_get_height(v); |
| 1793 | |
| 1794 | internal_imageable_area(v, 0, &page_left, &page_right, |
| 1795 | &page_bottom, &page_top); |
| 1796 | left -= page_left; |
| 1797 | top -= page_top; |
| 1798 | page_width = page_right - page_left; |
| 1799 | page_height = page_bottom - page_top; |
| 1800 | |
| 1801 | stp_dprintf(STP_DBG_LEXMARK, v, "page_right %f, page_left %f, page_top %f, page_bottom %f, left %f, top %f\n",page_right, page_left, page_top, page_bottom,left, top); |
| 1802 | |
| 1803 | image_height = stp_image_height(image); |
| 1804 | |
| 1805 | stp_default_media_size(v, &page_true_width, &page_true_height); |
| 1806 | lxm3200_linetoeject = (page_true_height * 1200) / 72; |
| 1807 | |
| 1808 | |
| 1809 | if (!lexmark_init_printer(v, caps, printing_color, |
| 1810 | media_source, |
| 1811 | xdpi, ydpi, page_width, page_height, |
| 1812 | top,left,use_dmt)) |
| 1813 | return 0; |
| 1814 | |
| 1815 | /* |
| 1816 | * Convert image size to printer resolution... |
| 1817 | */ |
| 1818 | |
| 1819 | out_width = xdpi * out_width / 72; |
| 1820 | out_height = ydpi * out_height / 72; |
| 1821 | |
| 1822 | |
| 1823 | stp_dprintf(STP_DBG_LEXMARK, v, "border: left %f, x_raster_res %d, offset_left %d\n", left, caps->x_raster_res, caps->offset_left_border); |
| 1824 | |
| 1825 | left = ((caps->x_raster_res * left) / 72) + caps->offset_left_border; |
| 1826 | |
| 1827 | stp_dprintf(STP_DBG_LEXMARK, v, "border: left %f\n", left); |
| 1828 | |
| 1829 | |
| 1830 | |
| 1831 | #ifdef DEBUG |
| 1832 | if (doTestPrint == 1) { |
| 1833 | stp_dprintf(STP_DBG_LEXMARK, v, "Start test print\n"); |
| 1834 | testprint(&td); |
| 1835 | out_width = td.x; |
| 1836 | out_height = td.y; |
| 1837 | if (td.cols != 7) { |
| 1838 | printMode = COLOR_MODE_K | COLOR_MODE_M | COLOR_MODE_C | COLOR_MODE_Y; |
| 1839 | } else { |
| 1840 | printMode = COLOR_MODE_K | COLOR_MODE_M | COLOR_MODE_C | COLOR_MODE_Y | COLOR_MODE_LM | COLOR_MODE_LC; |
| 1841 | } |
| 1842 | } |
| 1843 | #endif |
| 1844 | |
| 1845 | /* |
| 1846 | * Allocate memory for the raster data... |
| 1847 | */ |
| 1848 | |
| 1849 | length = (out_width + 7) / 8; |
| 1850 | |
| 1851 | |
| 1852 | |
| 1853 | if (use_dmt) { |
| 1854 | /* buf_length= length*2; */ |
| 1855 | buf_length= length; |
| 1856 | } else { |
| 1857 | buf_length= length; |
| 1858 | } |
| 1859 | |
| 1860 | stp_dprintf(STP_DBG_LEXMARK, v, "lexmark: buflength is %d!\n",buf_length); |
| 1861 | |
| 1862 | |
| 1863 | /* Now we know the color which are used, let's get the memory for every color image */ |
| 1864 | cols.p.k = NULL; |
| 1865 | cols.p.c = NULL; |
| 1866 | cols.p.y = NULL; |
| 1867 | cols.p.m = NULL; |
| 1868 | cols.p.C = NULL; |
| 1869 | cols.p.M = NULL; |
| 1870 | cols.p.Y = NULL; |
| 1871 | |
| 1872 | |
| 1873 | if ((printMode & COLOR_MODE_C) == COLOR_MODE_C) { |
| 1874 | cols.p.c = stp_zalloc(buf_length+10); |
| 1875 | } |
| 1876 | if ((printMode & COLOR_MODE_Y) == COLOR_MODE_Y) { |
| 1877 | cols.p.y = stp_zalloc(buf_length+10); |
| 1878 | } |
| 1879 | if ((printMode & COLOR_MODE_M) == COLOR_MODE_M) { |
| 1880 | cols.p.m = stp_zalloc(buf_length+10); |
| 1881 | } |
| 1882 | if ((printMode & COLOR_MODE_K) == COLOR_MODE_K) { |
| 1883 | cols.p.k = stp_zalloc(buf_length+10); |
| 1884 | } |
| 1885 | if ((printMode & COLOR_MODE_LC) == COLOR_MODE_LC) { |
| 1886 | cols.p.C = stp_zalloc(buf_length+10); |
| 1887 | } |
| 1888 | if ((printMode & COLOR_MODE_LY) == COLOR_MODE_LY) { |
| 1889 | cols.p.Y = stp_zalloc(buf_length+10); |
| 1890 | } |
| 1891 | if ((printMode & COLOR_MODE_LM) == COLOR_MODE_LM) { |
| 1892 | cols.p.M = stp_zalloc(buf_length+10); |
| 1893 | } |
| 1894 | |
| 1895 | if (cols.p.k) |
| 1896 | { |
| 1897 | if (cols.p.c) |
| 1898 | stp_set_string_parameter(v, "STPIOutputType", "KCMY"); |
| 1899 | else |
| 1900 | stp_set_string_parameter(v, "STPIOutputType", "Grayscale"); |
| 1901 | } |
| 1902 | else |
| 1903 | stp_set_string_parameter(v, "STPIOutputType", "CMY"); |
| 1904 | |
| 1905 | stp_dprintf(STP_DBG_LEXMARK, v, "lexmark: driver will use colors %c%c%c%c%c%c%c\n", |
| 1906 | (cols.p.c) ? 'c' : ' ', |
| 1907 | (cols.p.C) ? 'C' : ' ', |
| 1908 | (cols.p.m) ? 'm' : ' ', |
| 1909 | (cols.p.M) ? 'M' : ' ', |
| 1910 | (cols.p.y) ? 'y' : ' ', |
| 1911 | (cols.p.Y) ? 'Y' : ' ', |
| 1912 | (cols.p.k) ? 'k' : ' '); |
| 1913 | |
| 1914 | /* initialize soft weaving */ |
| 1915 | privdata.ink_parameter = ink_parameter; |
| 1916 | privdata.bidirectional = lexmark_print_bidirectional(v, model, resolution); |
| 1917 | privdata.outbuf = stp_malloc((((((pass_length/8)*11))+40) * out_width)+2000); |
| 1918 | privdata.direction = 0; |
| 1919 | stp_allocate_component_data(v, "Driver", NULL, NULL, &privdata); |
| 1920 | /* lxm_nozzles_used = 1;*/ |
| 1921 | |
| 1922 | stp_initialize_weave(v, |
| 1923 | pass_length, /* jets */ |
| 1924 | nozzle_separation, /* separation */ |
| 1925 | horizontal_passes, /* h oversample */ |
| 1926 | res_para_ptr->vertical_passes, /* v passes */ |
| 1927 | res_para_ptr->vertical_oversample, /* v oversample */ |
| 1928 | ncolors, /* colors */ |
| 1929 | 1, /* bits/pixel */ |
| 1930 | out_width, /* line width */ |
| 1931 | out_height, |
| 1932 | ((top * ydpi) / 72)+(((caps->offset_top_border+add_top_offset)*ydpi) |
| 1933 | /caps->y_raster_res), |
| 1934 | (page_height * ydpi) / 72, |
| 1935 | (const int *) lexmark_head_offset(v, ydpi, ink_type, caps, ink_parameter, &lineoff_buffer), |
| 1936 | STP_WEAVE_ZIGZAG, /* weave_strategy */ |
| 1937 | flush_pass, |
| 1938 | stp_fill_uncompressed, /* fill_start */ |
| 1939 | stp_pack_uncompressed, /* pack */ |
| 1940 | stp_compute_uncompressed_linewidth); /* compute_linewidth */ |
| 1941 | privdata.last_pass_offset = 0; |
| 1942 | privdata.jets = pass_length; |
| 1943 | privdata.ncolors = ncolors; |
| 1944 | privdata.horizontal_weave = horizontal_passes; |
| 1945 | |
| 1946 | |
| 1947 | if (!stp_check_float_parameter(v, "Density", STP_PARAMETER_DEFAULTED)) |
| 1948 | { |
| 1949 | stp_set_float_parameter_active(v, "Density", STP_PARAMETER_ACTIVE); |
| 1950 | stp_set_float_parameter(v, "Density", 1.0); |
| 1951 | } |
| 1952 | |
| 1953 | stp_dprintf(STP_DBG_LEXMARK, v, "density is %f\n", |
| 1954 | stp_get_float_parameter(v, "Density")); |
| 1955 | |
| 1956 | stp_dprintf(STP_DBG_LEXMARK, v, "density is %f and will be changed to %f (%f)\n", |
| 1957 | stp_get_float_parameter(v, "Density"), |
| 1958 | stp_get_float_parameter(v, "Density") / densityDivisor, |
| 1959 | densityDivisor); |
| 1960 | |
| 1961 | /* Lexmark do not have different pixel sizes. We have to correct the density according the print resolution. */ |
| 1962 | stp_scale_float_parameter(v, "Density", 1.0 / densityDivisor); |
| 1963 | |
| 1964 | |
| 1965 | /* |
| 1966 | * Compute the LUT. For now, it's 8 bit, but that may eventually |
| 1967 | * sometimes change. |
| 1968 | */ |
| 1969 | if (ncolors > 4) |
| 1970 | k_lower = .5; |
| 1971 | else |
| 1972 | k_lower = .25; |
| 1973 | |
| 1974 | if (media) |
| 1975 | { |
| 1976 | stp_scale_float_parameter(v, "Density", media->base_density); |
| 1977 | stp_scale_float_parameter(v, "Cyan", media->p_cyan); |
| 1978 | stp_scale_float_parameter(v, "Magenta", media->p_magenta); |
| 1979 | stp_scale_float_parameter(v, "Yellow", media->p_yellow); |
| 1980 | k_lower *= media->k_lower_scale; |
| 1981 | k_upper = media->k_upper; |
| 1982 | } |
| 1983 | else |
| 1984 | { |
| 1985 | stp_scale_float_parameter(v, "Density", .8); |
| 1986 | k_lower *= .1; |
| 1987 | k_upper = .5; |
| 1988 | } |
| 1989 | if (stp_get_float_parameter(v, "Density") > 1.0) |
| 1990 | stp_set_float_parameter(v, "Density", 1.0); |
| 1991 | |
| 1992 | stp_dprintf(STP_DBG_LEXMARK, v, "density is %f\n",stp_get_float_parameter(v, "Density")); |
| 1993 | |
| 1994 | |
| 1995 | if (!stp_check_float_parameter(v, "GCRLower", STP_PARAMETER_ACTIVE)) |
| 1996 | stp_set_default_float_parameter(v, "GCRLower", k_lower); |
| 1997 | if (!stp_check_float_parameter(v, "GCRUpper", STP_PARAMETER_ACTIVE)) |
| 1998 | stp_set_default_float_parameter(v, "GCRUpper", k_upper); |
| 1999 | stp_dither_init(v, image, out_width, xdpi, ydpi); |
| 2000 | |
| 2001 | /* |
| 2002 | stpi_dither_set_black_lower(dither, .8 / ((1 << (use_dmt+1)) - 1));*/ |
| 2003 | /*stpi_dither_set_black_levels(dither, 0.5, 0.5, 0.5); |
| 2004 | stpi_dither_set_black_lower(dither, 0.4);*/ |
| 2005 | /* |
| 2006 | if (use_glossy_film) |
| 2007 | */ |
| 2008 | if (cols.p.k) |
| 2009 | { |
| 2010 | stp_dither_add_channel(v, cols.p.k, STP_ECOLOR_K, 0); |
| 2011 | stp_channel_set_black_channel(v, STP_ECOLOR_K); |
| 2012 | } |
| 2013 | if (cols.p.c) |
| 2014 | stp_dither_add_channel(v, cols.p.c, STP_ECOLOR_C, 0); |
| 2015 | if (cols.p.C) |
| 2016 | stp_dither_add_channel(v, cols.p.C, STP_ECOLOR_C, 1); |
| 2017 | if (cols.p.m) |
| 2018 | stp_dither_add_channel(v, cols.p.m, STP_ECOLOR_M, 0); |
| 2019 | if (cols.p.M) |
| 2020 | stp_dither_add_channel(v, cols.p.M, STP_ECOLOR_M, 1); |
| 2021 | if (cols.p.y) |
| 2022 | stp_dither_add_channel(v, cols.p.y, STP_ECOLOR_Y, 0); |
| 2023 | if (cols.p.Y) |
| 2024 | stp_dither_add_channel(v, cols.p.Y, STP_ECOLOR_Y, 1); |
| 2025 | |
| 2026 | if (!use_dmt) { |
| 2027 | if (cols.p.C) |
| 2028 | { |
| 2029 | stp_dither_set_inks_full(v, STP_ECOLOR_C, 2, photo_dither_shades, 1.0, |
| 2030 | 0.31 / .5); |
| 2031 | } |
| 2032 | if (cols.p.M) |
| 2033 | { |
| 2034 | stp_dither_set_inks_full(v, STP_ECOLOR_M, 2, photo_dither_shades, 1.0, |
| 2035 | 0.61 / .97); |
| 2036 | } |
| 2037 | if (cols.p.Y) |
| 2038 | { |
| 2039 | stp_dither_set_inks_full(v, STP_ECOLOR_Y, 2, photo_dither_shades, 1.0, |
| 2040 | 0.08); |
| 2041 | } |
| 2042 | } |
| 2043 | |
| 2044 | stp_channel_set_density_adjustment(v, STP_ECOLOR_K, 0, |
| 2045 | get_double_param(v, "BlackDensity") * |
| 2046 | get_double_param(v, "Density")); |
| 2047 | stp_channel_set_density_adjustment(v, STP_ECOLOR_C, 0, |
| 2048 | get_double_param(v, "CyanDensity") * |
| 2049 | get_double_param(v, "Density")); |
| 2050 | stp_channel_set_density_adjustment(v, STP_ECOLOR_M, 0, |
| 2051 | get_double_param(v, "MagentaDensity") * |
| 2052 | get_double_param(v, "Density")); |
| 2053 | stp_channel_set_density_adjustment(v, STP_ECOLOR_Y, 0, |
| 2054 | get_double_param(v, "YellowDensity") * |
| 2055 | get_double_param(v, "Density")); |
| 2056 | if (!use_dmt) { |
| 2057 | if (cols.p.C) |
| 2058 | { |
| 2059 | stp_channel_set_density_adjustment |
| 2060 | (v, STP_ECOLOR_C, 1, (get_double_param(v, "CyanDensity") * |
| 2061 | get_double_param(v, "LightCyanTrans") * |
| 2062 | get_double_param(v, "Density"))); |
| 2063 | } |
| 2064 | if (cols.p.M) |
| 2065 | { |
| 2066 | stp_channel_set_density_adjustment |
| 2067 | (v, STP_ECOLOR_M, 1, (get_double_param(v, "MagentaDensity") * |
| 2068 | get_double_param(v, "LightMagentaTrans") * |
| 2069 | get_double_param(v, "Density"))); |
| 2070 | } |
| 2071 | if (cols.p.Y) |
| 2072 | { |
| 2073 | stp_channel_set_density_adjustment |
| 2074 | (v, STP_ECOLOR_Y, 1, (get_double_param(v, "YellowDensity") * |
| 2075 | get_double_param(v, "LightYellowTrans") * |
| 2076 | get_double_param(v, "Density"))); |
| 2077 | } |
| 2078 | } |
| 2079 | |
| 2080 | /* |
| 2081 | * Output the page... |
| 2082 | */ |
| 2083 | |
| 2084 | if (!stp_check_curve_parameter(v, "HueMap", STP_PARAMETER_ACTIVE) && |
| 2085 | media->hue_adjustment) |
| 2086 | { |
| 2087 | hue_adjustment = stp_read_and_compose_curves |
| 2088 | (lexmark_hue_adjustment(caps, v), |
| 2089 | media ? media->hue_adjustment : NULL, STP_CURVE_COMPOSE_ADD, 384); |
| 2090 | stp_set_curve_parameter(v, "HueMap", hue_adjustment); |
| 2091 | stp_curve_destroy(hue_adjustment); |
| 2092 | } |
| 2093 | if (!stp_check_curve_parameter(v, "LumMap", STP_PARAMETER_ACTIVE) && |
| 2094 | media->lum_adjustment) |
| 2095 | { |
| 2096 | lum_adjustment = stp_read_and_compose_curves |
| 2097 | (lexmark_lum_adjustment(caps, v), |
| 2098 | media ? media->lum_adjustment : NULL, STP_CURVE_COMPOSE_MULTIPLY, 384); |
| 2099 | stp_set_curve_parameter(v, "LumMap", lum_adjustment); |
| 2100 | stp_curve_destroy(lum_adjustment); |
| 2101 | } |
| 2102 | if (!stp_check_curve_parameter(v, "SatMap", STP_PARAMETER_ACTIVE) && |
| 2103 | media->sat_adjustment) |
| 2104 | { |
| 2105 | sat_adjustment = stp_read_and_compose_curves |
| 2106 | (lexmark_sat_adjustment(caps, v), |
| 2107 | media ? media->sat_adjustment : NULL, STP_CURVE_COMPOSE_MULTIPLY, 384); |
| 2108 | stp_set_curve_parameter(v, "SatMap", sat_adjustment); |
| 2109 | stp_curve_destroy(sat_adjustment); |
| 2110 | } |
| 2111 | |
| 2112 | (void) stp_color_init(v, image, 65536); |
| 2113 | |
| 2114 | /* calculate the memory we need for one line of the printer image (hopefully we are right) */ |
| 2115 | stp_dprintf(STP_DBG_LEXMARK, v, "---------- buffer mem size = %d\n", (((((pass_length/8)*11)/10)+40) * out_width)+200); |
| 2116 | |
| 2117 | errdiv = image_height / out_height; |
| 2118 | errmod = image_height % out_height; |
| 2119 | errval = 0; |
| 2120 | errlast = -1; |
| 2121 | errline = 0; |
| 2122 | |
| 2123 | privdata.hoffset = left; |
| 2124 | privdata.ydpi = ydpi; |
| 2125 | privdata.model = model; |
| 2126 | privdata.width = out_width; |
| 2127 | privdata.xdpi = xdpi; |
| 2128 | privdata.physical_xdpi = physical_xdpi; |
| 2129 | privdata.bitwidth = 1; |
| 2130 | |
| 2131 | for (y = 0; y < out_height; y ++) |
| 2132 | { |
| 2133 | int duplicate_line = 1; |
| 2134 | |
| 2135 | if (errline != errlast) |
| 2136 | { |
| 2137 | errlast = errline; |
| 2138 | duplicate_line = 0; |
| 2139 | if (stp_color_get_row(v, image, errline, &zero_mask)) |
| 2140 | { |
| 2141 | status = 2; |
| 2142 | break; |
| 2143 | } |
| 2144 | } |
| 2145 | stp_dither(v, y, duplicate_line, zero_mask, NULL); |
| 2146 | stp_write_weave(v, (unsigned char **)cols.v); |
| 2147 | |
| 2148 | errval += errmod; |
| 2149 | errline += errdiv; |
| 2150 | if (errval >= out_height) |
| 2151 | { |
| 2152 | errval -= out_height; |
| 2153 | errline ++; |
| 2154 | } |
| 2155 | } |
| 2156 | stp_image_conclude(image); |
| 2157 | |
| 2158 | stp_flush_all(v); |
| 2159 | |
| 2160 | lexmark_deinit_printer(v, caps); |
| 2161 | |
| 2162 | /* |
| 2163 | * Cleanup... |
| 2164 | */ |
| 2165 | if (privdata.outbuf != NULL) { |
| 2166 | stp_free(privdata.outbuf);/* !!!!!!!!!!!!!! */ |
| 2167 | } |
| 2168 | |
| 2169 | for (i = 0; i < NCHANNELS; i++) |
| 2170 | if (cols.v[i]) |
| 2171 | stp_free(cols.v[i]); |
| 2172 | |
| 2173 | #ifdef DEBUG |
| 2174 | lex_tmp_file_deinit(dbgfileprn); |
| 2175 | #endif |
| 2176 | |
| 2177 | return status; |
| 2178 | } |
| 2179 | |
| 2180 | static int |
| 2181 | lexmark_print(const stp_vars_t *v, stp_image_t *image) |
| 2182 | { |
| 2183 | int status; |
| 2184 | stp_vars_t *nv = stp_vars_create_copy(v); |
| 2185 | stp_prune_inactive_options(nv); |
| 2186 | status = lexmark_do_print(nv, image); |
| 2187 | stp_vars_destroy(nv); |
| 2188 | return status; |
| 2189 | } |
| 2190 | |
| 2191 | static const stp_printfuncs_t print_lexmark_printfuncs = |
| 2192 | { |
| 2193 | lexmark_list_parameters, |
| 2194 | lexmark_parameters, |
| 2195 | stp_default_media_size, |
| 2196 | lexmark_imageable_area, |
| 2197 | lexmark_imageable_area, |
| 2198 | lexmark_limit, |
| 2199 | lexmark_print, |
| 2200 | lexmark_describe_resolution, |
| 2201 | lexmark_describe_output, |
| 2202 | stp_verify_printer_params, |
| 2203 | NULL, |
| 2204 | NULL, |
| 2205 | NULL, |
| 2206 | stpi_standard_describe_papersize |
| 2207 | }; |
| 2208 | |
| 2209 | |
| 2210 | |
| 2211 | /* lexmark_init_line |
| 2212 | This method is printer type dependent code. |
| 2213 | |
| 2214 | This method initializes the line to be printed. It will set |
| 2215 | the printer specific initialization which has to be done before |
| 2216 | the pixels of the image could be printed. |
| 2217 | */ |
| 2218 | static unsigned char * |
| 2219 | lexmark_init_line(const stp_vars_t *v, |
| 2220 | int mode, unsigned char *prnBuf, |
| 2221 | int pass_length, |
| 2222 | int offset, /* offset from left in 1/"x_raster_res" DIP (printer resolution)*/ |
| 2223 | int width, int direction, |
| 2224 | const lexmark_inkparam_t *ink_parameter, |
| 2225 | const lexmark_cap_t * caps /* I - Printer model */ |
| 2226 | ) |
| 2227 | { |
| 2228 | int pos1 = 0; |
| 2229 | int pos2 = 0; |
| 2230 | int abspos, disp; |
| 2231 | int hend = 0; |
| 2232 | int header_size = 0; |
| 2233 | |
| 2234 | |
| 2235 | /* stp_eprintf(v, "#### width %d, length %d, pass_length %d\n", width, length, pass_length);*/ |
| 2236 | /* first, we write the line header */ |
| 2237 | switch(caps->model) { |
| 2238 | case m_z52: |
| 2239 | case m_z42: |
| 2240 | if (caps->model == m_z52) |
| 2241 | { |
| 2242 | header_size = LXM_Z52_HEADERSIZE; |
| 2243 | memcpy(prnBuf, outbufHeader_z52, header_size); |
| 2244 | } |
| 2245 | if (caps->model == m_z42) |
| 2246 | { |
| 2247 | header_size = LXM_Z42_HEADERSIZE; |
| 2248 | memcpy(prnBuf, outbufHeader_z42, LXM_Z42_HEADERSIZE); |
| 2249 | } |
| 2250 | |
| 2251 | /* K could only be present if black is printed only. */ |
| 2252 | if ((mode & COLOR_MODE_K) || (mode & (COLOR_MODE_K | COLOR_MODE_LC | COLOR_MODE_LM))) { |
| 2253 | stp_dprintf(STP_DBG_LEXMARK, v, "set photo/black cartridge \n"); |
| 2254 | prnBuf[LX_Z52_COLOR_MODE_POS] = LX_Z52_BLACK_PRINT; |
| 2255 | |
| 2256 | if (direction) { |
| 2257 | } else { |
| 2258 | offset += ink_parameter->h_direction_offset; |
| 2259 | } |
| 2260 | } else { |
| 2261 | stp_dprintf(STP_DBG_LEXMARK, v, "set color cartridge \n"); |
| 2262 | prnBuf[LX_Z52_COLOR_MODE_POS] = LX_Z52_COLOR_PRINT; |
| 2263 | |
| 2264 | if (direction) { |
| 2265 | offset += ink_parameter->h_catridge_offset; |
| 2266 | } else { |
| 2267 | offset += ink_parameter->h_catridge_offset + ink_parameter->h_direction_offset; |
| 2268 | } |
| 2269 | } |
| 2270 | |
| 2271 | switch (mode & PRINT_MODE_MASK) { |
| 2272 | case PRINT_MODE_300: |
| 2273 | prnBuf[LX_Z52_RESOLUTION_POS] = LX_Z52_300_DPI; |
| 2274 | break; |
| 2275 | case PRINT_MODE_600: |
| 2276 | prnBuf[LX_Z52_RESOLUTION_POS] = LX_Z52_600_DPI; |
| 2277 | break; |
| 2278 | case PRINT_MODE_1200: |
| 2279 | prnBuf[LX_Z52_RESOLUTION_POS] = LX_Z52_1200_DPI; |
| 2280 | break; |
| 2281 | case PRINT_MODE_2400: |
| 2282 | prnBuf[LX_Z52_RESOLUTION_POS] = LX_Z52_2400_DPI; |
| 2283 | break; |
| 2284 | } |
| 2285 | |
| 2286 | |
| 2287 | if (direction) { |
| 2288 | prnBuf[LX_Z52_PRINT_DIRECTION_POS] = 1; |
| 2289 | } else { |
| 2290 | prnBuf[LX_Z52_PRINT_DIRECTION_POS] = 2; |
| 2291 | } |
| 2292 | |
| 2293 | /* set package count */ |
| 2294 | prnBuf[13] = (unsigned char)((width) >> 8); |
| 2295 | prnBuf[14] = (unsigned char)((width) & 0xFF); |
| 2296 | /* set horizontal offset */ |
| 2297 | prnBuf[15] =(unsigned char)(offset >> 8); |
| 2298 | prnBuf[16] =(unsigned char)(offset & 0xFF); |
| 2299 | |
| 2300 | if (caps->model == m_z42) { |
| 2301 | switch(mode & PRINT_MODE_MASK) { |
| 2302 | case PRINT_MODE_300: |
| 2303 | hend = (width-1)*(2400/300); |
| 2304 | break; |
| 2305 | case PRINT_MODE_600: |
| 2306 | hend = (width-1)*(2400/600); |
| 2307 | break; |
| 2308 | case PRINT_MODE_1200: |
| 2309 | hend = (width-1)*(2400/1200); |
| 2310 | break; |
| 2311 | case PRINT_MODE_2400: |
| 2312 | hend = (width-1)*(2400/2400); |
| 2313 | break; |
| 2314 | } |
| 2315 | hend += offset; |
| 2316 | prnBuf[17] = (unsigned char)(hend >> 8); |
| 2317 | prnBuf[18] = (unsigned char)(hend & 0xFF); |
| 2318 | |
| 2319 | prnBuf[10] = (pass_length==208 ? 0x1A : 0x18); |
| 2320 | } |
| 2321 | |
| 2322 | return prnBuf + header_size; /* return the position where the pixels have to be written */ |
| 2323 | break; |
| 2324 | case m_3200: |
| 2325 | memcpy(prnBuf, outbufHeader_3200, LXM_3200_HEADERSIZE); |
| 2326 | |
| 2327 | offset = (offset - 60) * 4; |
| 2328 | |
| 2329 | /* K could only be present if black is printed only. */ |
| 2330 | if((mode & COLOR_MODE_K) || |
| 2331 | (mode & (COLOR_MODE_K | COLOR_MODE_LC | COLOR_MODE_LM))) |
| 2332 | { |
| 2333 | disp = LXM3200_LEFTOFFS; |
| 2334 | prnBuf[2] = 0x00; |
| 2335 | } |
| 2336 | else |
| 2337 | { |
| 2338 | disp = LXM3200_RIGHTOFFS; |
| 2339 | prnBuf[2] = 0x80; |
| 2340 | } |
| 2341 | |
| 2342 | if(pass_length == 208) |
| 2343 | { |
| 2344 | prnBuf[2] |= 0x10; |
| 2345 | } |
| 2346 | |
| 2347 | switch(mode & PRINT_MODE_MASK) { |
| 2348 | case PRINT_MODE_300: |
| 2349 | prnBuf[2] |= 0x20; |
| 2350 | pos1 = offset + disp; |
| 2351 | pos2 = offset + (width * 4) + disp; |
| 2352 | break; |
| 2353 | |
| 2354 | case PRINT_MODE_600: |
| 2355 | prnBuf[2] |= 0x00; |
| 2356 | pos1 = offset + disp; |
| 2357 | pos2 = offset + (width * 2) + disp; |
| 2358 | break; |
| 2359 | |
| 2360 | case PRINT_MODE_1200: |
| 2361 | prnBuf[2] |= 0x40; |
| 2362 | pos1 = offset + disp; |
| 2363 | pos2 = (offset + width) + disp; |
| 2364 | break; |
| 2365 | } |
| 2366 | |
| 2367 | if(direction) |
| 2368 | prnBuf[2] |= 0x01; |
| 2369 | else |
| 2370 | prnBuf[2] |= 0x00; |
| 2371 | |
| 2372 | /* set package count */ |
| 2373 | prnBuf[3] = (unsigned char)((width) >> 8); |
| 2374 | prnBuf[4] = (unsigned char)((width) & 0xff); |
| 2375 | |
| 2376 | /* set horizontal offset */ |
| 2377 | prnBuf[21] = (unsigned char)(pos1 >> 8); |
| 2378 | prnBuf[22] = (unsigned char)(pos1 & 0xFF); |
| 2379 | |
| 2380 | abspos = ((((pos2 - 3600) >> 3) & 0xfff0) + 9); |
| 2381 | prnBuf[5] = (abspos-lxm3200_headpos) >> 8; |
| 2382 | prnBuf[6] = (abspos-lxm3200_headpos) & 0xff; |
| 2383 | |
| 2384 | lxm3200_headpos = abspos; |
| 2385 | |
| 2386 | if(LXM3200_RIGHTOFFS > 4816) |
| 2387 | abspos = (((LXM3200_RIGHTOFFS - 4800) >> 3) & 0xfff0); |
| 2388 | else |
| 2389 | abspos = (((LXM3200_RIGHTOFFS - 3600) >> 3) & 0xfff0); |
| 2390 | |
| 2391 | prnBuf[11] = (lxm3200_headpos-abspos) >> 8; |
| 2392 | prnBuf[12] = (lxm3200_headpos-abspos) & 0xff; |
| 2393 | |
| 2394 | lxm3200_headpos = abspos; |
| 2395 | |
| 2396 | prnBuf[7] = (unsigned char)lexmark_calc_3200_checksum(&prnBuf[0]); |
| 2397 | prnBuf[15] = (unsigned char)lexmark_calc_3200_checksum(&prnBuf[8]); |
| 2398 | prnBuf[23] = (unsigned char)lexmark_calc_3200_checksum(&prnBuf[16]); |
| 2399 | |
| 2400 | /* return the position where the pixels have to be written */ |
| 2401 | return prnBuf + LXM_3200_HEADERSIZE; |
| 2402 | break; |
| 2403 | |
| 2404 | case m_lex7500: |
| 2405 | stp_eprintf(v, "Lexmark 7500 not supported !\n"); |
| 2406 | return NULL; |
| 2407 | break; |
| 2408 | } |
| 2409 | return NULL; |
| 2410 | } |
| 2411 | |
| 2412 | |
| 2413 | typedef struct Lexmark_head_colors { |
| 2414 | int v_start; |
| 2415 | unsigned char *line; |
| 2416 | int head_nozzle_start; |
| 2417 | int head_nozzle_end; |
| 2418 | int used_jets; |
| 2419 | } Lexmark_head_colors; |
| 2420 | |
| 2421 | /* lexmark_write |
| 2422 | This method is has NO printer type dependent code. |
| 2423 | This method writes a single line of the print. The line consists of "pass_length" |
| 2424 | pixel lines (pixels, which could be printed with one pass by the printer. |
| 2425 | */ |
| 2426 | |
| 2427 | |
| 2428 | static int |
| 2429 | lexmark_write(const stp_vars_t *v, /* I - Print file or command */ |
| 2430 | unsigned char *prnBuf, /* mem block to buffer output */ |
| 2431 | int *paperShift, |
| 2432 | int direction, |
| 2433 | int pass_length, /* num of inks to print */ |
| 2434 | const lexmark_cap_t * caps, /* I - Printer model */ |
| 2435 | const lexmark_inkparam_t *ink_parameter, |
| 2436 | int xdpi, |
| 2437 | int yCount, |
| 2438 | Lexmark_head_colors *head_colors, |
| 2439 | int length, /* I - Length of bitmap data in bytes */ |
| 2440 | int mode, /* I - Which color */ |
| 2441 | int ydpi, /* I - Vertical resolution */ |
| 2442 | int width, /* I - Printed width in pixels */ |
| 2443 | int offset, /* I - Offset from left side in lexmark_cap_t.x_raster_res DPI */ |
| 2444 | int dmt) |
| 2445 | { |
| 2446 | unsigned char *tbits=NULL, *p=NULL; |
| 2447 | int clen; |
| 2448 | int x; /* actual vertical position */ |
| 2449 | int y; /* actual horizontal position */ |
| 2450 | int dy; /* horiz. inkjet position */ |
| 2451 | int x1; |
| 2452 | unsigned short pixelline; /* byte to be written */ |
| 2453 | unsigned int valid_bytes; /* bit list which tells the present bytes */ |
| 2454 | int xStart=0; /* count start for horizontal line */ |
| 2455 | int xEnd=0; |
| 2456 | int xIter=0; /* count direction for horizontal line */ |
| 2457 | int anyCol=0; |
| 2458 | int colIndex; |
| 2459 | int rwidth; /* real with used at printing (includes shift between even & odd nozzles) */ |
| 2460 | |
| 2461 | (void)ydpi; |
| 2462 | (void)dmt; |
| 2463 | |
| 2464 | /* stp_dprintf(STP_DBG_LEXMARK, v, "<%c>",("CMYKcmy"[coloridx])); */ |
| 2465 | stp_dprintf(STP_DBG_LEXMARK, v, "pass length %d\n", pass_length); |
| 2466 | |
| 2467 | |
| 2468 | /* first, we check the length of the line an cut it if necessary. */ |
| 2469 | if ((((width*caps->x_raster_res)/xdpi)+offset) > ((caps->max_paper_width*caps->x_raster_res)/72)) { |
| 2470 | /* line too long !! Cut the line */ |
| 2471 | stp_dprintf(STP_DBG_LEXMARK, v, "!! Line too long !! reduce it from %d", width); |
| 2472 | width = ((((caps->max_paper_width*caps->x_raster_res)/72) - offset)*xdpi)/caps->x_raster_res; |
| 2473 | stp_dprintf(STP_DBG_LEXMARK, v, " down to %d\n", width); |
| 2474 | } |
| 2475 | |
| 2476 | |
| 2477 | /* we have to write the initial sequence for a line */ |
| 2478 | |
| 2479 | stp_dprintf(STP_DBG_LEXMARK, v, "lexmark: printer line initialized.\n"); |
| 2480 | |
| 2481 | if (direction) { |
| 2482 | /* left to right */ |
| 2483 | xStart = -get_lr_shift(mode); |
| 2484 | xEnd = width-1; |
| 2485 | xIter = 1; |
| 2486 | rwidth = xEnd - xStart; |
| 2487 | } else { |
| 2488 | /* right to left ! */ |
| 2489 | xStart = width-1; |
| 2490 | xEnd = -get_lr_shift(mode); |
| 2491 | rwidth = xStart - xEnd; |
| 2492 | xIter = -1; |
| 2493 | } |
| 2494 | |
| 2495 | p = lexmark_init_line(v, mode, prnBuf, pass_length, offset, rwidth, |
| 2496 | direction, /* direction */ |
| 2497 | ink_parameter, caps); |
| 2498 | |
| 2499 | |
| 2500 | stp_dprintf(STP_DBG_LEXMARK, v, "lexmark: xStart %d, xEnd %d, xIter %d.\n", xStart, xEnd, xIter); |
| 2501 | |
| 2502 | /* now we can start to write the pixels */ |
| 2503 | yCount = 2; |
| 2504 | |
| 2505 | |
| 2506 | for (x=xStart; x != xEnd; x+=xIter) { |
| 2507 | int anyDots=0; /* tells us if there was any dot to print */ |
| 2508 | |
| 2509 | switch(caps->model) { |
| 2510 | case m_z52: |
| 2511 | tbits = p; |
| 2512 | *(p++) = 0x3F; |
| 2513 | tbits[1] = 0; /* here will be nice bitmap */ |
| 2514 | p++; |
| 2515 | break; |
| 2516 | |
| 2517 | case m_3200: |
| 2518 | case m_z42: |
| 2519 | tbits = p; |
| 2520 | p += 4; |
| 2521 | break; |
| 2522 | |
| 2523 | case m_lex7500: |
| 2524 | break; |
| 2525 | } |
| 2526 | |
| 2527 | |
| 2528 | pixelline =0; /* here we store 16 pixels */ |
| 2529 | valid_bytes = 0; /* for every valid word (16 bits) a corresponding bit will be set to 1. */ |
| 2530 | |
| 2531 | anyDots =0; |
| 2532 | x1 = x+get_lr_shift(mode); |
| 2533 | |
| 2534 | for (colIndex=0; colIndex < 3; colIndex++) { |
| 2535 | for (dy=head_colors[colIndex].head_nozzle_start,y=head_colors[colIndex].v_start*yCount; |
| 2536 | (dy < head_colors[colIndex].head_nozzle_end); |
| 2537 | y+=yCount, dy++) { /* we start counting with 1 !!!! */ |
| 2538 | if (head_colors[colIndex].line != NULL) { |
| 2539 | pixelline = pixelline << 1; |
| 2540 | if ((x >= 0) && |
| 2541 | ((dy - head_colors[colIndex].head_nozzle_start) < (head_colors[colIndex].used_jets/2))) |
| 2542 | pixelline = pixelline | ((head_colors[colIndex].line[(y*length)+(x/8)] >> (7-(x%8))) & 0x1); |
| 2543 | pixelline = pixelline << 1; |
| 2544 | if ((x1 < width) && |
| 2545 | (((dy - head_colors[colIndex].head_nozzle_start)+1) < (head_colors[colIndex].used_jets/2))) |
| 2546 | pixelline = pixelline | ((head_colors[colIndex].line[(((yCount>>1)+y)*length)+ (x1/8)] >> (7-(x1%8))) & 0x1); |
| 2547 | |
| 2548 | } else { |
| 2549 | pixelline = pixelline << 2; |
| 2550 | } |
| 2551 | switch(caps->model) { |
| 2552 | case m_z52: |
| 2553 | if ((dy%8) == 7) { |
| 2554 | /* we have two bytes, write them */ |
| 2555 | anyDots |= pixelline; |
| 2556 | if (pixelline) { |
| 2557 | /* we have some dots */ |
| 2558 | valid_bytes = valid_bytes >> 1; |
| 2559 | *((p++)) = (unsigned char)(pixelline >> 8); |
| 2560 | *((p++)) = (unsigned char)(pixelline & 0xff); |
| 2561 | } else { |
| 2562 | /* there are no dots ! */ |
| 2563 | valid_bytes = valid_bytes >> 1; |
| 2564 | valid_bytes |= 0x1000; |
| 2565 | } |
| 2566 | pixelline =0; |
| 2567 | } |
| 2568 | break; |
| 2569 | |
| 2570 | case m_3200: |
| 2571 | case m_z42: |
| 2572 | if((dy % 4) == 3) |
| 2573 | { |
| 2574 | anyDots |= pixelline; |
| 2575 | valid_bytes <<= 1; |
| 2576 | |
| 2577 | if(pixelline) |
| 2578 | *(p++) = (unsigned char)(pixelline & 0xff); |
| 2579 | else |
| 2580 | valid_bytes |= 0x01; |
| 2581 | |
| 2582 | pixelline = 0; |
| 2583 | } |
| 2584 | break; |
| 2585 | |
| 2586 | case m_lex7500: |
| 2587 | break; |
| 2588 | } |
| 2589 | } |
| 2590 | } |
| 2591 | |
| 2592 | switch(caps->model) { |
| 2593 | case m_z52: |
| 2594 | if (pass_length != 208) { |
| 2595 | valid_bytes = valid_bytes >> 1; |
| 2596 | valid_bytes |= 0x1000; |
| 2597 | } |
| 2598 | tbits[0] = 0x20 | ((unsigned char)((valid_bytes >> 8) & 0x1f)); |
| 2599 | tbits[1] = (unsigned char)(valid_bytes & 0xff); |
| 2600 | break; |
| 2601 | |
| 2602 | case m_z42: |
| 2603 | if ((p-tbits) & 1) *(p++)=0; /* z42 packets always have even length */ |
| 2604 | /* fall through */ |
| 2605 | case m_3200: |
| 2606 | tbits[0] = 0x80 | ((unsigned char)((valid_bytes >> 24) & 0x1f)); |
| 2607 | tbits[1] = (unsigned char)((valid_bytes >> 16) & 0xff); |
| 2608 | tbits[2] = (unsigned char)((valid_bytes >> 8) & 0xff); |
| 2609 | tbits[3] = (unsigned char)(valid_bytes & 0xff); |
| 2610 | break; |
| 2611 | |
| 2612 | case m_lex7500: |
| 2613 | break; |
| 2614 | } |
| 2615 | |
| 2616 | |
| 2617 | if (anyDots) { |
| 2618 | anyCol = 1; |
| 2619 | } else { |
| 2620 | /* there are no dots, make empty package */ |
| 2621 | /* stp_dprintf(STP_DBG_LEXMARK, v, "-- empty col %i\n", x); */ |
| 2622 | } |
| 2623 | } |
| 2624 | |
| 2625 | stp_dprintf(STP_DBG_LEXMARK, v, "lexmark: 4\n"); |
| 2626 | |
| 2627 | clen=((unsigned char *)p)-prnBuf; |
| 2628 | |
| 2629 | switch(caps->model) { |
| 2630 | case m_z52: |
| 2631 | case m_z42: |
| 2632 | prnBuf[IDX_SEQLEN] =(unsigned char)(clen >> 24); |
| 2633 | prnBuf[IDX_SEQLEN+1] =(unsigned char)(clen >> 16); |
| 2634 | prnBuf[IDX_SEQLEN+2] =(unsigned char)(clen >> 8); |
| 2635 | prnBuf[IDX_SEQLEN+3]=(unsigned char)(clen & 0xFF); |
| 2636 | break; |
| 2637 | |
| 2638 | case m_3200: |
| 2639 | prnBuf[18] = (unsigned char)((clen - LXM_3200_HEADERSIZE) >> 16); |
| 2640 | prnBuf[19] = (unsigned char)((clen - LXM_3200_HEADERSIZE) >> 8); |
| 2641 | prnBuf[20] = (unsigned char)((clen - LXM_3200_HEADERSIZE) & 0xff); |
| 2642 | prnBuf[23] = (unsigned char)lexmark_calc_3200_checksum(&prnBuf[16]); |
| 2643 | break; |
| 2644 | |
| 2645 | default: |
| 2646 | break; |
| 2647 | } |
| 2648 | |
| 2649 | if (anyCol) { |
| 2650 | /* fist, move the paper */ |
| 2651 | paper_shift(v, (*paperShift), caps); |
| 2652 | *paperShift=0; |
| 2653 | |
| 2654 | /* now we write the image line */ |
| 2655 | stp_zfwrite((const char *)prnBuf,1,clen,v); |
| 2656 | #ifdef DEBUG |
| 2657 | lex_write_tmp_file(dbgfileprn, (void *)prnBuf,clen); |
| 2658 | #endif |
| 2659 | stp_dprintf(STP_DBG_LEXMARK, v, "lexmark: line written.\n"); |
| 2660 | return 1; |
| 2661 | } else { |
| 2662 | stp_dprintf(STP_DBG_LEXMARK, v, "-- empty line\n"); |
| 2663 | return 0; |
| 2664 | } |
| 2665 | |
| 2666 | /* Send a line of raster graphics... */ |
| 2667 | } |
| 2668 | |
| 2669 | |
| 2670 | |
| 2671 | #ifdef DEBUG |
| 2672 | const stp_vars_t *lex_open_tmp_file() { |
| 2673 | int i; |
| 2674 | const stp_vars_t *ofile; |
| 2675 | char tmpstr[256]; |
| 2676 | |
| 2677 | stp_eprintf(v, " create file !\n"); |
| 2678 | for (i=0, sprintf(tmpstr, "/tmp/xx%d.prn", i), ofile = fopen(tmpstr, "r"); |
| 2679 | ofile != NULL; |
| 2680 | i++, sprintf(tmpstr, "/tmp/xx%d.prn", i), ofile = fopen(tmpstr, "r")) { |
| 2681 | if (ofile != NULL) |
| 2682 | { |
| 2683 | fclose(ofile); |
| 2684 | } |
| 2685 | } |
| 2686 | stp_eprintf(v, "Create file %s !\n", tmpstr); |
| 2687 | ofile = fopen(tmpstr, "wb"); |
| 2688 | STPI_ASSERT(ofile); |
| 2689 | return ofile; |
| 2690 | } |
| 2691 | |
| 2692 | void lex_tmp_file_deinit(const stp_vars_t *file) { |
| 2693 | stp_eprintf(v, "Close file %lx\n", file); |
| 2694 | fclose(file); |
| 2695 | } |
| 2696 | |
| 2697 | const stp_vars_t *lex_write_tmp_file(const stp_vars_t *ofile, void *data,int length) { |
| 2698 | fwrite(data, 1, length, ofile); |
| 2699 | } |
| 2700 | |
| 2701 | |
| 2702 | #endif |
| 2703 | |
| 2704 | |
| 2705 | static void |
| 2706 | flush_pass(stp_vars_t *v, int passno, int vertical_subpass) |
| 2707 | { |
| 2708 | stp_lineoff_t *lineoffs = stp_get_lineoffsets_by_pass(v, passno); |
| 2709 | stp_lineactive_t *lineactive = stp_get_lineactive_by_pass(v, passno); |
| 2710 | const stp_linebufs_t *bufs = stp_get_linebases_by_pass(v, passno); |
| 2711 | stp_pass_t *pass = stp_get_pass_by_pass(v, passno); |
| 2712 | stp_linecount_t *linecount = stp_get_linecount_by_pass(v, passno); |
| 2713 | lexm_privdata_weave *pd = |
| 2714 | (lexm_privdata_weave *) stp_get_component_data(v, "Driver"); |
| 2715 | int width = pd->width; |
| 2716 | int hoffset = pd->hoffset; |
| 2717 | int model = pd->model; |
| 2718 | int xdpi = pd->xdpi; |
| 2719 | int ydpi = pd->ydpi; |
| 2720 | int physical_xdpi = pd->physical_xdpi; |
| 2721 | int lwidth = (width + (pd->horizontal_weave - 1)) / pd->horizontal_weave; |
| 2722 | int microoffset = vertical_subpass & (pd->horizontal_weave - 1); |
| 2723 | |
| 2724 | int prn_mode; |
| 2725 | int j; /* color counter */ |
| 2726 | const lexmark_cap_t * caps= lexmark_get_model_capabilities(v, model); |
| 2727 | int paperShift; |
| 2728 | Lexmark_head_colors head_colors[3]={{0, NULL, 0, 64/2, 64}, |
| 2729 | {0, NULL, 64/2, 128/2, 64}, |
| 2730 | {0, NULL, 128/2, 192/2, 64}}; |
| 2731 | |
| 2732 | |
| 2733 | stp_dprintf(STP_DBG_LEXMARK, v, "Lexmark: flush_pass, here we are !\n"); |
| 2734 | stp_dprintf(STP_DBG_LEXMARK, v, " passno %d, pd->ncolors %d, width %d, lwidth %d, bitwidth %d\n", |
| 2735 | passno, pd->ncolors, width, lwidth, pd->bitwidth); |
| 2736 | stp_dprintf(STP_DBG_LEXMARK, v, "microoffset %d, vertical_subpass %d, pd->horizontal_weave %d\n", microoffset,vertical_subpass, pd->horizontal_weave); |
| 2737 | |
| 2738 | stp_dprintf(STP_DBG_LEXMARK, v, "Lexmark: last_pass_offset %d, logicalpassstart %d\n", pd->last_pass_offset, pass->logicalpassstart); |
| 2739 | stp_dprintf(STP_DBG_LEXMARK, v, "Lexmark: vertical adapt: caps->y_raster_res %d, ydpi %d, \n", caps->y_raster_res, ydpi); |
| 2740 | |
| 2741 | switch (physical_xdpi) { |
| 2742 | case 300: |
| 2743 | prn_mode = PRINT_MODE_300; |
| 2744 | break; |
| 2745 | case 600: |
| 2746 | prn_mode = PRINT_MODE_600; |
| 2747 | break; |
| 2748 | case 1200: |
| 2749 | prn_mode = PRINT_MODE_1200; |
| 2750 | break; |
| 2751 | default: |
| 2752 | stp_dprintf(STP_DBG_LEXMARK, v, "Error: Unsupported phys resolution (%d)\n", physical_xdpi); |
| 2753 | return; |
| 2754 | break; |
| 2755 | } |
| 2756 | /* calculate paper shift and adapt actual resolution to physical positioning resolution */ |
| 2757 | paperShift = (pass->logicalpassstart - pd->last_pass_offset) * (caps->y_raster_res/ydpi); |
| 2758 | for (j = 0; j < pd->ncolors; j++) |
| 2759 | stp_dprintf(STP_DBG_LEXMARK, v, "Color %d: active %d line %p jets %d offset %ld\n", |
| 2760 | j, lineactive[0].v[j], (void *)bufs[0].v[j], linecount[0].v[j], |
| 2761 | lineoffs[0].v[j]); |
| 2762 | |
| 2763 | /*** do we have to print something with the color cartridge ? ***/ |
| 2764 | if ((STP_ECOLOR_C < pd->ncolors) && (lineactive[0].v[STP_ECOLOR_C] > 0)) |
| 2765 | { |
| 2766 | head_colors[0].line = bufs[0].v[STP_ECOLOR_C]; |
| 2767 | head_colors[0].used_jets = linecount[0].v[STP_ECOLOR_C]; |
| 2768 | } |
| 2769 | else |
| 2770 | { |
| 2771 | head_colors[0].line = NULL; |
| 2772 | head_colors[0].used_jets = 0; |
| 2773 | } |
| 2774 | |
| 2775 | if ((STP_ECOLOR_M < pd->ncolors) && (lineactive[0].v[STP_ECOLOR_M] > 0)) |
| 2776 | { |
| 2777 | head_colors[1].line = bufs[0].v[STP_ECOLOR_M]; |
| 2778 | head_colors[1].used_jets = linecount[0].v[STP_ECOLOR_M]; |
| 2779 | } |
| 2780 | else |
| 2781 | { |
| 2782 | head_colors[1].line = 0; |
| 2783 | head_colors[1].used_jets = 0; |
| 2784 | } |
| 2785 | |
| 2786 | if ((STP_ECOLOR_Y < pd->ncolors) && (lineactive[0].v[STP_ECOLOR_Y] > 0)) |
| 2787 | { |
| 2788 | head_colors[2].line = bufs[0].v[STP_ECOLOR_Y]; |
| 2789 | head_colors[2].used_jets = linecount[0].v[STP_ECOLOR_Y]; |
| 2790 | } |
| 2791 | else |
| 2792 | { |
| 2793 | head_colors[2].line = 0; |
| 2794 | head_colors[2].used_jets = 0; |
| 2795 | } |
| 2796 | |
| 2797 | if ((head_colors[0].line != 0) || (head_colors[1].line != 0) || (head_colors[2].line != 0)) { |
| 2798 | |
| 2799 | |
| 2800 | |
| 2801 | stp_dprintf(STP_DBG_LEXMARK, v, "lexmark_write: lwidth %d\n", lwidth); |
| 2802 | lexmark_write(v, /* I - Print file or command */ |
| 2803 | pd->outbuf,/*unsigned char *prnBuf, mem block to buffer output */ |
| 2804 | &paperShift, /* int *paperShift, */ |
| 2805 | pd->direction, /* int direction, */ |
| 2806 | pd->jets, /* num of inks to print */ |
| 2807 | caps, /* const lexmark_cap_t * caps, I - Printer model */ |
| 2808 | pd->ink_parameter, |
| 2809 | xdpi, /* int xresolution, */ |
| 2810 | 2, /* yCount,*/ |
| 2811 | head_colors, /* Lexmark_head_colors *head_colors, */ |
| 2812 | (lwidth+7)/8, /* length, I - Length of bitmap data of one line in bytes */ |
| 2813 | prn_mode | COLOR_MODE_C | COLOR_MODE_Y | COLOR_MODE_M, /* mode, I - Which color */ |
| 2814 | ydpi, /* ydpi, I - Vertical resolution */ |
| 2815 | lwidth, /* width, I - Printed width in pixels*/ |
| 2816 | hoffset+microoffset, /* offset I - Offset from left side in x_raster_res DPI */ |
| 2817 | 0 /* dmt */); |
| 2818 | if (pd->bidirectional) |
| 2819 | pd->direction = (pd->direction +1) & 1; |
| 2820 | } |
| 2821 | |
| 2822 | |
| 2823 | /*** do we have to print something with black or photo cartridge ? ***/ |
| 2824 | /* we print with the photo or black cartridge */ |
| 2825 | |
| 2826 | if (pd->jets != 208) |
| 2827 | { |
| 2828 | /* we have photo or black cartridge */ |
| 2829 | if ((STP_ECOLOR_LC < pd->ncolors) && (lineactive[0].v[STP_ECOLOR_LC] > 0)) |
| 2830 | { |
| 2831 | head_colors[0].line = bufs[0].v[STP_ECOLOR_LC]; |
| 2832 | head_colors[0].used_jets = linecount[0].v[STP_ECOLOR_LC]; |
| 2833 | } |
| 2834 | else |
| 2835 | { |
| 2836 | head_colors[0].line = 0; |
| 2837 | head_colors[0].used_jets = 0; |
| 2838 | } |
| 2839 | |
| 2840 | if ((STP_ECOLOR_LM < pd->ncolors) && (lineactive[0].v[STP_ECOLOR_LM] > 0)) |
| 2841 | { |
| 2842 | head_colors[1].line = bufs[0].v[STP_ECOLOR_LM]; |
| 2843 | head_colors[1].used_jets = linecount[0].v[STP_ECOLOR_LM]; |
| 2844 | } |
| 2845 | else |
| 2846 | { |
| 2847 | head_colors[1].line = 0; |
| 2848 | head_colors[1].used_jets = 0; |
| 2849 | } |
| 2850 | |
| 2851 | if ((STP_ECOLOR_K < pd->ncolors) && (lineactive[0].v[STP_ECOLOR_K] > 0)) |
| 2852 | { |
| 2853 | head_colors[2].line = bufs[0].v[STP_ECOLOR_K]; |
| 2854 | head_colors[2].used_jets = linecount[0].v[STP_ECOLOR_K]; |
| 2855 | } |
| 2856 | else |
| 2857 | { |
| 2858 | head_colors[2].line = 0; |
| 2859 | head_colors[2].used_jets = 0; |
| 2860 | } |
| 2861 | } |
| 2862 | else |
| 2863 | { |
| 2864 | if ((STP_ECOLOR_K < pd->ncolors) && (lineactive[0].v[STP_ECOLOR_K] > 0)) |
| 2865 | { |
| 2866 | /* we have black cartridge; we have to print with all 208 jets at once */ |
| 2867 | head_colors[0].line = bufs[0].v[STP_ECOLOR_K]; |
| 2868 | head_colors[0].used_jets = linecount[0].v[STP_ECOLOR_K]; |
| 2869 | head_colors[0].head_nozzle_start = 0; |
| 2870 | head_colors[0].head_nozzle_end = pd->jets/2; |
| 2871 | head_colors[2].line = NULL; |
| 2872 | head_colors[2].used_jets = 0; |
| 2873 | head_colors[2].head_nozzle_start = 0; |
| 2874 | head_colors[2].head_nozzle_end = 0; |
| 2875 | head_colors[1].line = NULL; |
| 2876 | head_colors[1].used_jets = 0; |
| 2877 | head_colors[1].head_nozzle_start = 0; |
| 2878 | head_colors[1].head_nozzle_end = 0; |
| 2879 | } |
| 2880 | else |
| 2881 | { |
| 2882 | head_colors[2].line = NULL; |
| 2883 | head_colors[2].used_jets = 0; |
| 2884 | head_colors[2].head_nozzle_start = 0; |
| 2885 | head_colors[2].head_nozzle_end = 0; |
| 2886 | head_colors[1].line = NULL; |
| 2887 | head_colors[1].used_jets = 0; |
| 2888 | head_colors[1].head_nozzle_start = 0; |
| 2889 | head_colors[1].head_nozzle_end = 0; |
| 2890 | head_colors[0].line = NULL; |
| 2891 | head_colors[0].used_jets = 0; |
| 2892 | head_colors[0].head_nozzle_start = 0; |
| 2893 | head_colors[0].head_nozzle_end = 0; |
| 2894 | } |
| 2895 | } |
| 2896 | |
| 2897 | if ((head_colors[0].line != 0) || (head_colors[1].line != 0) || (head_colors[2].line != 0)) { |
| 2898 | |
| 2899 | lexmark_write(v, /* I - Print file or command */ |
| 2900 | pd->outbuf,/*unsigned char *prnBuf, mem block to buffer output */ |
| 2901 | &paperShift, /* int *paperShift, */ |
| 2902 | pd->direction, /* int direction, */ |
| 2903 | pd->jets, /* num of inks to print */ |
| 2904 | caps, /* const lexmark_cap_t * caps, I - Printer model */ |
| 2905 | pd->ink_parameter, |
| 2906 | xdpi, /* int xresolution, */ |
| 2907 | 2, /* yCount,*/ |
| 2908 | head_colors, /* Lexmark_head_colors *head_colors, */ |
| 2909 | (lwidth+7)/8, /* length, I - Length of bitmap data of one line in bytes */ |
| 2910 | prn_mode | COLOR_MODE_LC | COLOR_MODE_LM | COLOR_MODE_K, /* mode, I - Which color */ |
| 2911 | ydpi, /* ydpi, I - Vertical resolution */ |
| 2912 | lwidth, /* width, I - Printed width in pixels*/ |
| 2913 | hoffset+microoffset, /* offset I - Offset from left side in x_raster_res DPI */ |
| 2914 | 0 /* dmt */); |
| 2915 | if (pd->bidirectional) |
| 2916 | { |
| 2917 | pd->direction = (pd->direction +1) & 1; |
| 2918 | } |
| 2919 | } |
| 2920 | /* store paper position in respect if there was a paper shift */ |
| 2921 | pd->last_pass_offset = pass->logicalpassstart - (paperShift / (caps->y_raster_res/ydpi)); |
| 2922 | |
| 2923 | for (j = 0; j < pd->ncolors; j++) |
| 2924 | { |
| 2925 | lineoffs[0].v[j] = 0; |
| 2926 | linecount[0].v[j] = 0; |
| 2927 | } |
| 2928 | |
| 2929 | stp_dprintf(STP_DBG_LEXMARK, v, "lexmark_write finished\n"); |
| 2930 | |
| 2931 | } |
| 2932 | |
| 2933 | |
| 2934 | |
| 2935 | |
| 2936 | |
| 2937 | #ifdef DEBUG |
| 2938 | |
| 2939 | static void testprint(testdata *td) |
| 2940 | { |
| 2941 | int icol, i; |
| 2942 | char dummy1[256], dummy2[256]; |
| 2943 | lexmark_linebufs_t linebufs; |
| 2944 | |
| 2945 | /* init */ |
| 2946 | for (i=0; i < (sizeof(linebufs.v)/sizeof(linebufs.v[0])); i++) { |
| 2947 | linebufs.v[i] = NULL; |
| 2948 | } |
| 2949 | |
| 2950 | /*let's go */ |
| 2951 | td->ifile = fopen("/t1.ppm", "rb"); |
| 2952 | if (td->ifile != NULL) { |
| 2953 | /* find "{" */ |
| 2954 | fscanf(td->ifile, "%[^{]{%[^\"]\"%d %d %d %d\",", dummy1, dummy2, &(td->x), &(td->y), &(td->cols), &(td->deep)); |
| 2955 | td->cols -= 1; /* we reduce it by one because fist color will be ignored */ |
| 2956 | td->input_line = (char *)stp_malloc(td->x+10); |
| 2957 | stp_eprintf(v, "<%s> <%s>\n", dummy1, dummy2); |
| 2958 | stp_eprintf(v, "%d %d %d %d\n", td->x, td->y, td->cols, td->deep); |
| 2959 | if (td->cols > 16) { |
| 2960 | stp_eprintf(v, "too many colors !!\n"); |
| 2961 | return; |
| 2962 | } |
| 2963 | |
| 2964 | /* read the colors */ |
| 2965 | fscanf(td->ifile, "%[^\"]\"%c c %[^\"]\",", dummy1, dummy2, dummy2); /* jump over first color */ |
| 2966 | for (icol=0; icol < td->cols; icol++) { /* we ignore the first color. It is "no dot". */ |
| 2967 | fscanf(td->ifile, "%[^\"]\"%c c %[^\"]\",", dummy1, &(td->colchar[icol]), dummy2); |
| 2968 | stp_eprintf(v, "colchar %d <%c>\n", i, td->colchar[icol]); |
| 2969 | } |
| 2970 | |
| 2971 | |
| 2972 | if (td->cols > 5) { |
| 2973 | td->cols = 7; |
| 2974 | for (icol=0; icol < td->cols; icol++) { /* we ignore the first color. It is "no dot". */ |
| 2975 | linebufs.v[icol] = (char *)stp_malloc((td->x+7)/8); /* allocate the color */ |
| 2976 | } |
| 2977 | } else if (td->cols > 4) { |
| 2978 | td->cols = 5; |
| 2979 | for (icol=0; icol < td->cols; icol++) { /* we ignore the first color. It is "no dot". */ |
| 2980 | linebufs.v[icol] = (char *)stp_malloc((td->x+7)/8); /* allocate the color */ |
| 2981 | } |
| 2982 | } else { |
| 2983 | td->cols = 1; |
| 2984 | linebufs.v[0] = (char *)stp_malloc((td->x+7)/8); /* allocate the color */ |
| 2985 | } |
| 2986 | } else { |
| 2987 | stp_eprintf(v, "can't open file !\n"); |
| 2988 | } |
| 2989 | } |
| 2990 | |
| 2991 | |
| 2992 | static void readtestprintline(testdata *td, lexmark_linebufs_t *linebufs) |
| 2993 | { |
| 2994 | char dummy1[256]; |
| 2995 | int icol, ix; |
| 2996 | |
| 2997 | stp_eprintf(v, "start readtestprintline\n"); |
| 2998 | for (icol=0; icol < 7; icol++) { |
| 2999 | if (linebufs->v[icol] != NULL) { |
| 3000 | memset(linebufs->v[icol], 0, (td->x+7)/8); /* clean line */ |
| 3001 | } |
| 3002 | } |
| 3003 | stp_eprintf(v, "1 readtestprintline cols %d\n", td->cols); |
| 3004 | |
| 3005 | |
| 3006 | fscanf(td->ifile, "%[^\"]\"%[^\"]\",", dummy1, td->input_line); |
| 3007 | for (icol=0; icol < td->cols; icol++) { |
| 3008 | for (ix=0; ix < td->x; ix++) { |
| 3009 | if (td->input_line[ix] == td->colchar[icol]) { |
| 3010 | /* set the dot */ |
| 3011 | if (icol != 0) { |
| 3012 | linebufs->v[icol-1][ix/8] |= 1 << (ix%8); |
| 3013 | } else { |
| 3014 | /* this is specific, we set ymc */ |
| 3015 | linebufs->p.y[ix/8] |= 1 << (ix%8); |
| 3016 | linebufs->p.m[ix/8] |= 1 << (ix%8); |
| 3017 | linebufs->p.c[ix/8] |= 1 << (ix%8); |
| 3018 | } |
| 3019 | } |
| 3020 | } |
| 3021 | } |
| 3022 | /* stp_eprintf(v, "pixchar <%s><%s>\n",dummy1, td->input_line);*/ |
| 3023 | } |
| 3024 | |
| 3025 | #endif |
| 3026 | |
| 3027 | |
| 3028 | static stp_family_t print_lexmark_module_data = |
| 3029 | { |
| 3030 | &print_lexmark_printfuncs, |
| 3031 | NULL |
| 3032 | }; |
| 3033 | |
| 3034 | static int |
| 3035 | print_lexmark_module_init(void) |
| 3036 | { |
| 3037 | return stpi_family_register(print_lexmark_module_data.printer_list); |
| 3038 | } |
| 3039 | |
| 3040 | |
| 3041 | static int |
| 3042 | print_lexmark_module_exit(void) |
| 3043 | { |
| 3044 | return stpi_family_unregister(print_lexmark_module_data.printer_list); |
| 3045 | } |
| 3046 | |
| 3047 | |
| 3048 | /* Module header */ |
| 3049 | #define stp_module_version print_lexmark_LTX_stp_module_version |
| 3050 | #define stp_module_data print_lexmark_LTX_stp_module_data |
| 3051 | |
| 3052 | stp_module_version_t stp_module_version = {0, 0}; |
| 3053 | |
| 3054 | stp_module_t stp_module_data = |
| 3055 | { |
| 3056 | "lexmark", |
| 3057 | VERSION, |
| 3058 | "Lexmark family driver", |
| 3059 | STP_MODULE_CLASS_FAMILY, |
| 3060 | NULL, |
| 3061 | print_lexmark_module_init, |
| 3062 | print_lexmark_module_exit, |
| 3063 | (void *) &print_lexmark_module_data |
| 3064 | }; |