Skip to content

Commit

Permalink
Fix LBP3000 support, add multiple page sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
mounaiban authored and Mounaiban committed Mar 28, 2020
1 parent 94b2bf2 commit 5c021f6
Show file tree
Hide file tree
Showing 8 changed files with 832 additions and 113 deletions.
88 changes: 0 additions & 88 deletions Canon-LBP-2900.ppd

This file was deleted.

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

Large diffs are not rendered by default.

342 changes: 342 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.2])

AC_CONFIG_SRCDIR([src/std.h])

Expand Down
126 changes: 126 additions & 0 deletions src/canon-lbp.drv
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/*
* 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.2
{
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

*Resolution k 1 70 592 0 "600dpi/600 DPI"
MaxSize 215.9mm 355.6mm // US Legal
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
MediaType 1 "Plain/Plain Paper"
PCFileName "CNLB3K.ppd"
}
}

2 changes: 2 additions & 0 deletions src/paper.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ void page_set_dims(struct page_dims_s *dims, const struct cups_page_header2_s *h
{
dims->paper_width = header->PageSize[0] * header->HWResolution[0] / 72;
dims->paper_height = header->PageSize[1] * header->HWResolution[1] / 72;
dims->margin_height = header->Margins[0];
dims->margin_width = header->Margins[1];
}
4 changes: 3 additions & 1 deletion src/paper.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
struct cups_page_header2_s;

struct page_dims_s {
/* set by */
/* set by CUPS */
unsigned paper_width;
unsigned paper_height;
unsigned margin_height;
unsigned margin_width;
/* set by printer ops */
unsigned line_size;
unsigned band_size;
Expand Down
44 changes: 21 additions & 23 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 @@ -157,23 +162,23 @@ static bool lbp2900_page_prologue(struct printer_state_s *state, const struct pa
uint8_t pt2 = 0x01;

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 */
/*
/* Spare bytes for later
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
*/
*/
};

(void) state;
Expand Down Expand Up @@ -266,22 +271,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 5c021f6

Please sign in to comment.