Skip to content

Commit

Permalink
Add support for all media types
Browse files Browse the repository at this point in the history
All four media types supported by the proprietary drivers have been implemented
  • Loading branch information
mounaiban committed Apr 7, 2020
1 parent 7384729 commit 0b71004
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 52 deletions.
19 changes: 8 additions & 11 deletions Canon-LBP2900.ppd
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
*%%%% 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"
*Product: "(LBP2900/LBP3010 r2c)"
*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
Expand Down Expand Up @@ -293,13 +293,6 @@
*DefaultColorModel: Gray
*ColorModel Gray/Grayscale: "<</cupsColorSpace 3/cupsColorOrder 0/cupsCompression 2>>setpagedevice"
*CloseUI: *ColorModel
*OpenUI *captMediaWeight/Media Type B (Experimental): PickOne
*OrderDependency: 11 AnySetup *captMediaWeight
*DefaultcaptMediaWeight: pt2-1
*captMediaWeight pt2-0/0: "<</MediaWeight 0>>setpagedevice"
*captMediaWeight pt2-1/Default: "<</MediaWeight 1>>setpagedevice"
*captMediaWeight pt2-2/2: "<</MediaWeight 2>>setpagedevice"
*CloseUI: *captMediaWeight
*OpenUI *captTonerSave/Toner Save: Boolean
*OrderDependency: 10 AnySetup *captTonerSave
*DefaultcaptTonerSave: False
Expand All @@ -315,7 +308,11 @@
*OrderDependency: 10 AnySetup *MediaType
*DefaultMediaType: Plain
*MediaType Plain/Plain Paper: "<</MediaType(Plain)/cupsMediaType 0>>setpagedevice"
*MediaType Thick/Thick Paper: "<</MediaType(Thick)/cupsMediaType 1>>setpagedevice"
*MediaType Heavy/Heavy Paper: "<</MediaType(Heavy)/cupsMediaType 1>>setpagedevice"
*MediaType PlainL/Plain Paper L: "<</MediaType(PlainL)/cupsMediaType 2>>setpagedevice"
*MediaType HeavyH/Heavy Paper H: "<</MediaType(HeavyH)/cupsMediaType 3>>setpagedevice"
*MediaType Transparency/Transparency: "<</MediaType(Transparency)/cupsMediaType 4>>setpagedevice"
*MediaType Envelope/Envelope: "<</MediaType(Envelope)/cupsMediaType 5>>setpagedevice"
*CloseUI: *MediaType
*DefaultFont: Courier
*Font AvantGarde-Book: Standard "(1.05)" Standard ROM
Expand Down Expand Up @@ -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.
19 changes: 8 additions & 11 deletions Canon-LBP3000.ppd
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
*%%%% 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"
*Product: "(LBP3000 r2c)"
*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
Expand Down Expand Up @@ -293,13 +293,6 @@
*DefaultColorModel: Gray
*ColorModel Gray/Grayscale: "<</cupsColorSpace 3/cupsColorOrder 0/cupsCompression 2>>setpagedevice"
*CloseUI: *ColorModel
*OpenUI *captMediaWeight/Media Type B (Experimental): PickOne
*OrderDependency: 11 AnySetup *captMediaWeight
*DefaultcaptMediaWeight: pt2-1
*captMediaWeight pt2-0/0: "<</MediaWeight 0>>setpagedevice"
*captMediaWeight pt2-1/Default: "<</MediaWeight 1>>setpagedevice"
*captMediaWeight pt2-2/2: "<</MediaWeight 2>>setpagedevice"
*CloseUI: *captMediaWeight
*OpenUI *captTonerSave/Toner Save: Boolean
*OrderDependency: 10 AnySetup *captTonerSave
*DefaultcaptTonerSave: False
Expand All @@ -315,7 +308,11 @@
*OrderDependency: 10 AnySetup *MediaType
*DefaultMediaType: Plain
*MediaType Plain/Plain Paper: "<</MediaType(Plain)/cupsMediaType 0>>setpagedevice"
*MediaType Thick/Thick Paper: "<</MediaType(Thick)/cupsMediaType 1>>setpagedevice"
*MediaType Heavy/Heavy Paper: "<</MediaType(Heavy)/cupsMediaType 1>>setpagedevice"
*MediaType PlainL/Plain Paper L: "<</MediaType(PlainL)/cupsMediaType 2>>setpagedevice"
*MediaType HeavyH/Heavy Paper H: "<</MediaType(HeavyH)/cupsMediaType 3>>setpagedevice"
*MediaType Transparency/Transparency: "<</MediaType(Transparency)/cupsMediaType 4>>setpagedevice"
*MediaType Envelope/Envelope: "<</MediaType(Envelope)/cupsMediaType 5>>setpagedevice"
*CloseUI: *MediaType
*DefaultFont: Courier
*Font AvantGarde-Book: Standard "(1.05)" Standard ROM
Expand Down Expand Up @@ -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.
23 changes: 5 additions & 18 deletions src/canon-lbp.drv
Original file line number Diff line number Diff line change
Expand Up @@ -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" "<</MediaWeight 0>>setpagedevice"
*Choice "pt2-1/Default" "<</MediaWeight 1>>setpagedevice"
Choice "pt2-2/2" "<</MediaWeight 2>>setpagedevice"

// Toner Save Option
Option "captTonerSave/Toner Save" Boolean AnySetup 10
*Choice False/Disabled "<</cupsCompression 0>>setpagedevice"
Expand All @@ -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
Expand Down
8 changes: 5 additions & 3 deletions src/paper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
3 changes: 1 addition & 2 deletions src/paper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
39 changes: 32 additions & 7 deletions src/prn_lbp2900.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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,
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 0b71004

Please sign in to comment.