From 0b71004238738e63d4b9bdbccadda8ef26df9138 Mon Sep 17 00:00:00 2001 From: mounaiban <29518031+mounaiban@users.noreply.github.com> Date: Mon, 6 Apr 2020 23:32:59 +1000 Subject: [PATCH] Add support for all media types All four media types supported by the proprietary drivers have been implemented --- Canon-LBP2900.ppd | 19 ++++++++----------- Canon-LBP3000.ppd | 19 ++++++++----------- src/canon-lbp.drv | 23 +++++------------------ src/paper.c | 8 +++++--- src/paper.h | 3 +-- src/prn_lbp2900.c | 39 ++++++++++++++++++++++++++++++++------- 6 files changed, 59 insertions(+), 52 deletions(-) diff --git a/Canon-LBP2900.ppd b/Canon-LBP2900.ppd index bc7ddcb..b57a82b 100644 --- a/Canon-LBP2900.ppd +++ b/Canon-LBP2900.ppd @@ -3,7 +3,7 @@ *%%%% Created by the CUPS PPD Compiler CUPS v2.2.10. *% (C)2020 Moses Chong *FormatVersion: "4.3" -*FileVersion: "0.1.2" +*FileVersion: "0.1.3" *LanguageVersion: English *LanguageEncoding: ISOLatin1 *PCFileName: "CNLB2K9.ppd" @@ -11,7 +11,7 @@ *Manufacturer: "Canon Inc" *ModelName: "Canon Inc LBP2900/LBP3010 r2c" *ShortNickName: "Canon Inc LBP2900/LBP3010 r2c" -*NickName: "Canon Inc LBP2900/LBP3010 r2c, 0.1.2" +*NickName: "Canon Inc LBP2900/LBP3010 r2c, 0.1.3" *PSVersion: "(3010.000) 0" *LanguageLevel: "3" *ColorDevice: False @@ -293,13 +293,6 @@ *DefaultColorModel: Gray *ColorModel Gray/Grayscale: "<>setpagedevice" *CloseUI: *ColorModel -*OpenUI *captMediaWeight/Media Type B (Experimental): PickOne -*OrderDependency: 11 AnySetup *captMediaWeight -*DefaultcaptMediaWeight: pt2-1 -*captMediaWeight pt2-0/0: "<>setpagedevice" -*captMediaWeight pt2-1/Default: "<>setpagedevice" -*captMediaWeight pt2-2/2: "<>setpagedevice" -*CloseUI: *captMediaWeight *OpenUI *captTonerSave/Toner Save: Boolean *OrderDependency: 10 AnySetup *captTonerSave *DefaultcaptTonerSave: False @@ -315,7 +308,11 @@ *OrderDependency: 10 AnySetup *MediaType *DefaultMediaType: Plain *MediaType Plain/Plain Paper: "<>setpagedevice" -*MediaType Thick/Thick Paper: "<>setpagedevice" +*MediaType Heavy/Heavy Paper: "<>setpagedevice" +*MediaType PlainL/Plain Paper L: "<>setpagedevice" +*MediaType HeavyH/Heavy Paper H: "<>setpagedevice" +*MediaType Transparency/Transparency: "<>setpagedevice" +*MediaType Envelope/Envelope: "<>setpagedevice" *CloseUI: *MediaType *DefaultFont: Courier *Font AvantGarde-Book: Standard "(1.05)" Standard ROM @@ -353,4 +350,4 @@ *Font Times-Roman: Standard "(1.05)" Standard ROM *Font ZapfChancery-MediumItalic: Standard "(1.05)" Standard ROM *Font ZapfDingbats: Special "(001.005)" Special ROM -*% End of CNLB2K9.ppd, 21444 bytes. +*% End of CNLB2K9.ppd, 21449 bytes. diff --git a/Canon-LBP3000.ppd b/Canon-LBP3000.ppd index 9deaed8..3d2a7f1 100644 --- a/Canon-LBP3000.ppd +++ b/Canon-LBP3000.ppd @@ -3,7 +3,7 @@ *%%%% Created by the CUPS PPD Compiler CUPS v2.2.10. *% (C)2020 Moses Chong *FormatVersion: "4.3" -*FileVersion: "0.1.2" +*FileVersion: "0.1.3" *LanguageVersion: English *LanguageEncoding: ISOLatin1 *PCFileName: "CNLB3K.ppd" @@ -11,7 +11,7 @@ *Manufacturer: "Canon Inc" *ModelName: "Canon Inc LBP3000 r2c" *ShortNickName: "Canon Inc LBP3000 r2c" -*NickName: "Canon Inc LBP3000 r2c, 0.1.2" +*NickName: "Canon Inc LBP3000 r2c, 0.1.3" *PSVersion: "(3010.000) 0" *LanguageLevel: "3" *ColorDevice: False @@ -293,13 +293,6 @@ *DefaultColorModel: Gray *ColorModel Gray/Grayscale: "<>setpagedevice" *CloseUI: *ColorModel -*OpenUI *captMediaWeight/Media Type B (Experimental): PickOne -*OrderDependency: 11 AnySetup *captMediaWeight -*DefaultcaptMediaWeight: pt2-1 -*captMediaWeight pt2-0/0: "<>setpagedevice" -*captMediaWeight pt2-1/Default: "<>setpagedevice" -*captMediaWeight pt2-2/2: "<>setpagedevice" -*CloseUI: *captMediaWeight *OpenUI *captTonerSave/Toner Save: Boolean *OrderDependency: 10 AnySetup *captTonerSave *DefaultcaptTonerSave: False @@ -315,7 +308,11 @@ *OrderDependency: 10 AnySetup *MediaType *DefaultMediaType: Plain *MediaType Plain/Plain Paper: "<>setpagedevice" -*MediaType Thick/Thick Paper: "<>setpagedevice" +*MediaType Heavy/Heavy Paper: "<>setpagedevice" +*MediaType PlainL/Plain Paper L: "<>setpagedevice" +*MediaType HeavyH/Heavy Paper H: "<>setpagedevice" +*MediaType Transparency/Transparency: "<>setpagedevice" +*MediaType Envelope/Envelope: "<>setpagedevice" *CloseUI: *MediaType *DefaultFont: Courier *Font AvantGarde-Book: Standard "(1.05)" Standard ROM @@ -353,4 +350,4 @@ *Font Times-Roman: Standard "(1.05)" Standard ROM *Font ZapfChancery-MediumItalic: Standard "(1.05)" Standard ROM *Font ZapfDingbats: Special "(001.005)" Special ROM -*% End of CNLB3K.ppd, 21404 bytes. +*% End of CNLB3K.ppd, 21409 bytes. diff --git a/src/canon-lbp.drv b/src/canon-lbp.drv index b96f1d0..3da6774 100644 --- a/src/canon-lbp.drv +++ b/src/canon-lbp.drv @@ -102,23 +102,6 @@ Version 0.1.3 MediaSize Statement // End Less Common Sizes - // Paper Type B Options - /* - This option is wired directly to the pt2 register in the - page prologue (see prn_lbp2900.c). Its exact purpose is not - known, but it appears to be an adjustment to cater the printer - for different paper weights. - The proprietary drivers offers a 'Plain Paper L' and 'Heavy Paper H' - option. The LBP 3000 manual describes Heavy Paper H as an option - to 'get improved fixing properties' for thick paper and - Plain Paper L as an option reduce curling on plain paper. - And then there's the Transparency option for clear plastic film... - */ - Option "captMediaWeight/Media Type B (Experimental)" PickOne AnySetup 11 - Choice "pt2-0/0" "<>setpagedevice" - *Choice "pt2-1/Default" "<>setpagedevice" - Choice "pt2-2/2" "<>setpagedevice" - // Toner Save Option Option "captTonerSave/Toner Save" Boolean AnySetup 10 *Choice False/Disabled "<>setpagedevice" @@ -127,7 +110,11 @@ Version 0.1.3 *Resolution k 1 70 592 0 "600dpi/600 DPI" MaxSize 215.9mm 355.6mm // US Legal MediaType 0 "Plain/Plain Paper" - MediaType 1 "Thick/Thick Paper" + MediaType 1 "Heavy/Heavy Paper" + MediaType 2 "PlainL/Plain Paper L" + MediaType 3 "HeavyH/Heavy Paper H" + MediaType 4 "Transparency" + MediaType 5 "Envelope" VariablePaperSize yes { // nearly matched to Alexey Galakhov's original 2011 specs diff --git a/src/paper.c b/src/paper.c index 8f3a51f..19af997 100644 --- a/src/paper.c +++ b/src/paper.c @@ -22,11 +22,13 @@ void page_set_dims(struct page_dims_s *dims, const struct cups_page_header2_s *header) { - dims->media_type_a = header->cupsMediaType; - dims->media_type_b = header->MediaWeight; + dims->media_type = header->cupsMediaType; dims->paper_width = header->PageSize[0] * header->HWResolution[0] / 72; dims->paper_height = header->PageSize[1] * header->HWResolution[1] / 72; - //using cupsCompression to reduce ink darkness, like Zebra printers + /* + The use of cupsCompression to toggle toner save was inspired by the + use of the same attribute to control darkness in label printer drivers. + */ dims->toner_save = header->cupsCompression; dims->margin_height = header->Margins[0]; dims->margin_width = header->Margins[1]; diff --git a/src/paper.h b/src/paper.h index a072e1a..435db69 100644 --- a/src/paper.h +++ b/src/paper.h @@ -25,8 +25,7 @@ struct cups_page_header2_s; struct page_dims_s { /* set by CUPS */ - unsigned media_type_a; - unsigned media_type_b; + unsigned media_type; unsigned paper_width; unsigned paper_height; unsigned toner_save; diff --git a/src/prn_lbp2900.c b/src/prn_lbp2900.c index 9972077..f82eec9 100644 --- a/src/prn_lbp2900.c +++ b/src/prn_lbp2900.c @@ -157,16 +157,41 @@ static bool lbp2900_page_prologue(struct printer_state_s *state, const struct pa size_t s; uint8_t buf[16]; - uint8_t pt1 = dims->media_type_a; uint8_t save = dims->toner_save; - uint8_t pt2 = dims->media_type_b; // Please see .drv file + uint8_t fm = 0x00; /* fuser mode (temperature?) */ - fprintf(stderr, "DEBUG: CAPT: Media type: pt1=%u, pt2=%u\n", pt1, pt2); + switch (dims->media_type) { + case 0x00: + case 0x02: + /* Plain Paper & Plain Paper L */ + fm = 0x01; + break; + case 0x01: + /* Heavy Paper */ + fm = 0x01; + break; + case 0x03: + /* Heavy Paper H */ + fm = 0x02; + break; + case 0x04: + /* Transparency */ + fm = 0x13; + break; + case 0x05: + /* Envelope */ + fm = 0x1C; + break; + default: + fm = 0x01; + } + + fprintf(stderr, "DEBUG: CAPT: media_type=%u, fm=%u\n", dims->media_type, fm); uint8_t pageparms[] = { /* Bytes 0-21 (0x00 to 0x15) */ 0x00, 0x00, 0x30, 0x2A, /* sz */ 0x02, 0x00, 0x00, 0x00, - 0x1C, 0x1C, 0x1C, 0x1C, pt1, /* adapt */ 0x11, 0x04, 0x00, + 0x1C, 0x1C, 0x1C, 0x1C, dims->media_type, /* adapt */ 0x11, 0x04, 0x00, 0x01, 0x01, /* img ref */ 0x00, save, 0x00, 0x00, /* Bytes 22-33 (0x16 to 0x21) */ LO(dims->margin_height), HI(dims->margin_height), @@ -176,7 +201,7 @@ static bool lbp2900_page_prologue(struct printer_state_s *state, const struct pa LO(dims->paper_width), HI(dims->paper_width), LO(dims->paper_height), HI(dims->paper_height), /* Bytes 34-39 (0x22 to 0x27) */ - 0x00, 0x00, pt2, 0x00, 0x00, 0x00, + 0x00, 0x00, fm, 0x00, 0x00, 0x00, /* Spare bytes for later 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -274,11 +299,11 @@ static void lbp2900_page_setup(struct printer_state_s *state, struct page_dims_s *dims, unsigned width, unsigned height) { - // FIXME: Do we still need this function? + /* FIXME: Do we still need this function? */ (void) state; (void) width; (void) height; - // Get raster dimensions straight from CUPS in paper.c + /* Get raster dimensions straight from CUPS in paper.c */ dims->num_lines = dims->paper_height; dims->line_size = dims->paper_width / 8; dims->band_size = 70;