Skip to content

Commit

Permalink
Merge pull request agalakhov#24 from mounaiban/0.1.3-pr
Browse files Browse the repository at this point in the history
Fix LBP3000, add Toner Save Mode, multiple paper types, multiple paper sizes
  • Loading branch information
agalakhov authored Mar 30, 2020
2 parents 94b2bf2 + 7384729 commit b9b5983
Show file tree
Hide file tree
Showing 8 changed files with 900 additions and 117 deletions.
88 changes: 0 additions & 88 deletions Canon-LBP-2900.ppd

This file was deleted.

356 changes: 356 additions & 0 deletions Canon-LBP2900.ppd

Large diffs are not rendered by default.

356 changes: 356 additions & 0 deletions Canon-LBP3000.ppd

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AC_PREREQ([2.69])
AC_INIT([captdriver], [0.1.0])
AC_INIT([captdriver], [0.1.3])

AC_CONFIG_SRCDIR([src/std.h])

Expand Down
149 changes: 149 additions & 0 deletions src/canon-lbp.drv
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
/*
* Canon CAPT LBP Printers
* captdriver PPD Source File
* for use with CUPS ppdc to generate PPDs
*
*/
#include <font.defs>
#include <media.defs>

#media "SISG5/SIS G5" 169mm 239mm
#media "SISE5/SIS E5" 115mm 220mm
#media "SAC16K/SAC 16K" 188mm 260mm
#media "SAC32K/SAC 32K" 130mm 184mm

Copyright "(C)2020 Moses Chong"
ColorModel "Gray/Grayscale" k chunky 2
Filter application/vnd.cups-raster 1 rastertocapt
*Manufacturer "Canon Inc"
Version 0.1.3
{
Font *

// Common Sizes
*MediaSize A4
MediaSize A5
MediaSize A6
MediaSize B6
MediaSize C6
MediaSize EnvC5
MediaSize EnvC6
MediaSize EnvChou3
MediaSize EnvDL
MediaSize Env10
MediaSize EnvItalian
MediaSize Executive // US 7.25x10.5 inch
MediaSize Folio // SE Asian F4
MediaSize Legal
MediaSize Letter
MediaSize SISG5
MediaSize SISE5
MediaSize SAC16K
MediaSize SAC32K

// Less Common Sizes
/*
* Sizes A6 and larger, and no wider than US Legal have
* been included here.
*
* PROTIP: Delete this section and recompile PPD, for a
* less cluttered Paper Size menu in most applications,
* if you don't use these sizes. If you use any of them,
* move the sizes you need from below to the section above,
* then delete the rest.
*
* NOTE: Some of the sizes appear to be identical to
* another at least in terms of width and length. There
* could be other differences, and may be useful in managing
* multiple trays on printers that support them.
*
*/
MediaSize 7x9
MediaSize 8x10
MediaSize A4Small // Same dimensions as A4
MediaSize A4Plus // Longer than Folio (F4) by just one point
MediaSize A5Extra
MediaSize B5
MediaSize B7
MediaSize DoublePostcard
MediaSize Env9
MediaSize Env11
MediaSize Env12
MediaSize Env14
MediaSize EnvC65
MediaSize EnvChou4
MediaSize EnvISOB5
MediaSize EnvISOB6
MediaSize EnvKaku3
MediaSize EnvMonarch
MediaSize EnvPersonal
MediaSize EnvPRC1
MediaSize EnvPRC2
MediaSize EnvPRC3
MediaSize EnvPRC4
MediaSize EnvPRC5
MediaSize EnvPRC6
MediaSize EnvPRC7
MediaSize EnvPRC8
MediaSize EnvYou4
MediaSize FanFoldGerman
MediaSize FanFoldGermanLegal
MediaSize ISOB5
MediaSize ISOB5Extra
MediaSize ISOB6
MediaSize ISOB7
MediaSize LetterPlus
MediaSize Note // Same dimensions as Letter (US)
MediaSize Postcard
MediaSize PRC16K
MediaSize PRC32K
MediaSize PRC32KBig
MediaSize Quarto
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"
Choice True/Enabled "<</cupsCompression 1>>setpagedevice"

*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"
VariablePaperSize yes
{
// nearly matched to Alexey Galakhov's original 2011 specs
*ModelName "LBP2900/LBP3010 r2c"
FileName "Canon-LBP2900.ppd"
MinSize 75mm 105mm
HWmargins 4.7095835mm 4.7095835mm 4.709583mm 4.709583mm
PCFileName "CNLB2K9.ppd"
}

{
*ModelName "LBP3000 r2c"
FileName "Canon-LBP3000.ppd"
HWmargins 5mm 5mm 5mm 5mm
MinSize 75mm 105mm
PCFileName "CNLB3K.ppd"
}
}

7 changes: 6 additions & 1 deletion src/paper.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@
*/

#include "paper.h"

#include <cups/raster.h>

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->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
dims->toner_save = header->cupsCompression;
dims->margin_height = header->Margins[0];
dims->margin_width = header->Margins[1];
}
7 changes: 6 additions & 1 deletion src/paper.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,14 @@
struct cups_page_header2_s;

struct page_dims_s {
/* set by */
/* set by CUPS */
unsigned media_type_a;
unsigned media_type_b;
unsigned paper_width;
unsigned paper_height;
unsigned toner_save;
unsigned margin_height;
unsigned margin_width;
/* set by printer ops */
unsigned line_size;
unsigned band_size;
Expand Down
52 changes: 26 additions & 26 deletions src/prn_lbp2900.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,18 @@ static void lbp2900_job_prologue(struct printer_state_s *state)
static void lbp3000_job_prologue(struct printer_state_s *state)
{
(void) state;
uint8_t buf[8];
size_t size;

capt_sendrecv(CAPT_IDENT, NULL, 0, NULL, 0);
sleep(1);
capt_init_status();
lbp2900_get_status(state->ops);

capt_sendrecv(CAPT_START_0, NULL, 0, NULL, 0);
capt_sendrecv(CAPT_JOB_BEGIN, magicbuf_0, ARRAY_SIZE(magicbuf_0), NULL, 0);
capt_sendrecv(CAPT_JOB_BEGIN, magicbuf_0, ARRAY_SIZE(magicbuf_0), buf, &size);
job=WORD(buf[2], buf[3]);

/* LBP-3000 prints the very first printjob perfectly
* and then proceeds to hang at this (commented out)
* spot. That's the difference, or so it seems. */
Expand All @@ -152,28 +157,30 @@ static bool lbp2900_page_prologue(struct printer_state_s *state, const struct pa
size_t s;
uint8_t buf[16];

uint8_t pt1 = 0x01;
uint8_t save = 0x00;
uint8_t pt2 = 0x01;
uint8_t pt1 = dims->media_type_a;
uint8_t save = dims->toner_save;
uint8_t pt2 = dims->media_type_b; // Please see .drv file

fprintf(stderr, "DEBUG: CAPT: Media type: pt1=%u, pt2=%u\n", pt1, pt2);

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,
0x01, 0x01, /* img ref */ 0x00, save, 0x00, 0x00,
/* height margin 118 */ 0x76, 0x00,
/* width margin 78 */ 0x4e, 0x00,
LO(dims->line_size), HI(dims->line_size), LO(dims->num_lines), HI(dims->num_lines),
/* Bytes 22-33 (0x16 to 0x21) */
LO(dims->margin_height), HI(dims->margin_height),
LO(dims->margin_width), HI(dims->margin_width),
LO(dims->line_size), HI(dims->line_size),
LO(dims->num_lines), HI(dims->num_lines),
LO(dims->paper_width), HI(dims->paper_width),
LO(dims->paper_height), HI(dims->paper_height),
/* 34 bytes */
/* Bytes 34-39 (0x22 to 0x27) */
0x00, 0x00, pt2, 0x00, 0x00, 0x00,
/* 72 bytes */
/*
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
/* Spare bytes for later
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
*/
*/
};

(void) state;
Expand Down Expand Up @@ -266,22 +273,15 @@ static void lbp2900_job_epilogue(struct printer_state_s *state)
static void lbp2900_page_setup(struct printer_state_s *state,
struct page_dims_s *dims,
unsigned width, unsigned height)
{
/*
A4 4736x6778 or 4736x4520
Letter 4864x6368
Legal 4864x8192
Executive 4128x6080
3x5 1344x2528
*/
{
// FIXME: Do we still need this function?
(void) state;
(void) width;
(void) height;
// 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;
dims->line_size = 4736 / 8;
if (height > 6778)
dims->num_lines = 6778;
else
dims->num_lines = height;
}

static void lbp2900_wait_user(struct printer_state_s *state)
Expand Down

0 comments on commit b9b5983

Please sign in to comment.