Tizen 2.1 base
[platform/upstream/hplip.git] / prnt / hpijs / dj3320.h
1 /*****************************************************************************\
2   DJ3320.h : Interface for the DJ3320 class
3
4   Copyright (c) 2001 - 2002, Hewlett-Packard Co.
5   All rights reserved.
6
7   Redistribution and use in source and binary forms, with or without
8   modification, are permitted provided that the following conditions
9   are met:
10   1. Redistributions of source code must retain the above copyright
11      notice, this list of conditions and the following disclaimer.
12   2. Redistributions in binary form must reproduce the above copyright
13      notice, this list of conditions and the following disclaimer in the
14      documentation and/or other materials provided with the distribution.
15   3. Neither the name of Hewlett-Packard nor the names of its
16      contributors may be used to endorse or promote products derived
17      from this software without specific prior written permission.
18
19   THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
20   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
22   NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
24   TO, PATENT INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
25   OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26   ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29   \***************************************************************************/
30
31 /*
32  *    Author: Raghothama Cauligi
33  */
34
35 #ifndef APDK_DJ3320_H
36 #define APDK_DJ3320_H
37
38 #include "config.h"
39
40 APDK_BEGIN_NAMESPACE
41
42 #include "ldlencap.h"
43
44 class   LDLEncap;
45
46 class DJ3320 : public Printer
47 {
48 public:
49     DJ3320 (SystemServices* pSS, BOOL proto = FALSE);
50
51     virtual ~DJ3320 ();
52
53     Header* SelectHeader(PrintContext* pc);
54     virtual DRIVER_ERROR Send (const BYTE *pWriteBuff, DWORD dwWriteLen);
55
56 #ifdef APDK_HP_UX
57     virtual DRIVER_ERROR Send (const BYTE *pWriteBuff)
58     {
59         return Send (pWriteBuff, strlen ((const char *) pWriteBuff));
60     }
61 #endif
62
63     virtual DRIVER_ERROR Encapsulate (const RASTERDATA *pRasterData, BOOL bLastPlane);
64     DRIVER_ERROR VerifyPenInfo ();
65     virtual DRIVER_ERROR ParsePenInfo (PEN_TYPE& ePen, BOOL QueryPrinter = TRUE);
66     virtual DRIVER_ERROR SkipRasters (int nBlankRasters);
67     virtual DRIVER_ERROR CleanPen ();
68     virtual DRIVER_ERROR Flush (int FlushSize);
69     DRIVER_ERROR SetPens (PEN_TYPE eNewPen);
70         virtual DRIVER_ERROR CheckInkLevel();
71
72     DISPLAY_STATUS ParseError (BYTE byStatusReg);
73     
74         inline virtual BOOL SupportSeparateBlack (PrintMode *pCurrentMode)
75     {
76         if (pCurrentMode->ColorDepth[1] == 2)
77         {
78             return FALSE;
79         }
80         return TRUE;
81     }
82     
83
84     LDLEncap    *pLDLEncap;
85     int         m_iBytesPerSwing;
86     int         m_iLdlVersion;
87     int         m_iColorPenResolution;\r
88     int         m_iBlackPenResolution;\r
89     int         m_iNumBlackNozzles;
90
91 protected:
92     DISPLAY_STATUS m_dsCurrentStatus;
93     virtual void InitPrintModes ();
94     virtual void AdjustResolution ()
95     {
96         return;
97     }
98
99 #ifdef APDK_HP_UX
100 protected:
101     virtual DJ3320& operator = (Printer& rhs)
102     {
103         return *this;
104     }
105 #endif
106
107 };
108
109 class DJ3320GrayMode : public PrintMode
110 {
111 public:
112     DJ3320GrayMode (PEN_TYPE ePen);
113 };
114
115 class DJ3320KDraftMode : public GrayMode
116 {
117 public:
118     DJ3320KDraftMode ();
119 };
120
121 class DJ3320DraftMode : public PrintMode
122 {
123 public:
124     DJ3320DraftMode (PEN_TYPE ePen);
125
126 };
127
128 class DJ3320NormalMode : public PrintMode
129 {
130 public:
131     DJ3320NormalMode (PEN_TYPE ePen);
132
133 };
134
135 class DJ3320PhotoMode : public PrintMode
136 {
137 public:
138     DJ3320PhotoMode ();
139 };
140
141 class DJ3600MDLNormalMode : public PrintMode
142 {
143 public:
144     DJ3600MDLNormalMode ();
145 };
146
147
148 class DJ3600MDLDraftMode : public PrintMode
149 {
150 public:
151     DJ3600MDLDraftMode ();
152
153 };
154
155 class DJ3600MDLPhotoMode : public PrintMode
156 {
157 public:
158     DJ3600MDLPhotoMode ();
159
160 };
161
162 #if defined (APDK_DJ3320)
163
164 //! DJ3320Proxy
165 /*!
166 ******************************************************************************/
167 class DJ3320Proxy : public PrinterProxy
168 {
169 public:
170     DJ3320Proxy() : PrinterProxy(
171         "DJ3320",                   // family name
172         "deskjet 3320\0"
173         "deskjet 3325\0"
174                 "deskjet 3420\0"
175         "deskjet 3425\0"
176                 "deskjet 3500\0"
177         "deskjet 3528\0"
178         "deskjet 3535\0"
179                 "Deskjet 3740\0"
180                 "Deskjet 3920\0"
181                 "Deskjet 3940\0"
182                 "Deskjet 3900\0"
183         "Deskjet D1360\0"
184         "Deskjet d14\0"\r
185         "Deskjet D15\0"\r
186         "Deskjet F22\0"
187 #ifdef APDK_MLC_PRINTER
188                 "psc 1100\0"
189                 "psc 1200\0"
190                 "officejet 4100\0"
191                 "officejet 4105\0"
192 #endif
193         "Officejet 43\0"
194         "officejet 4115\0"
195         "officejet 5500\0"
196         "psc 11\0"
197         "psc 12\0"
198         "psc 13\0"
199         "psc 16\0"
200     ) {m_iPrinterType = eDJ3320;}
201     inline Printer* CreatePrinter(SystemServices* pSS) const { return new DJ3320(pSS); }
202         inline PRINTER_TYPE GetPrinterType() const { return eDJ3320;}
203         inline unsigned int GetModelBit() const { return 0x100;}
204 };
205
206 #endif
207
208 #define SWATH_HEIGHT    100     // Number of color nozzles to be used
209
210 #ifdef  APDK_LDL_COMPRESS
211
212 /************************************************************/
213 /*  Compression Classes                                     */
214 /*                                                          */
215 /************************************************************/
216
217 #define ALLOW_FILL_NEXT_CMD 1
218
219 #define FILL_0000_CMD  0x1000
220 #define FILL_FFFF_CMD  0x2000
221 #define FILL_NEXT_CMD  0x3000
222 #define FILL_IMAGE_CMD 0x4000
223 #define FILL_ODD_CMD   0x5000
224 #define FILL_EVEN_CMD  0x6000
225
226 #define MAX_HEADER_FRAME_SIZE 512
227 #define MAX_DATA_FRAME_SIZE 6048
228 #define MAX_RUNLENGTH 5
229
230 typedef enum
231 {
232   IN_NOT,
233   IN_FIRST,
234   IN_IMAGE,
235   IN_COPY
236 } LDLCOMPMODE;
237
238 class comp_ptrs_t
239 {
240 public:
241         comp_ptrs_t (UInt16 *data,UInt16 datasize):image_ptr(data),raw_data(data),
242                                                                                                 data_length(datasize){};
243         comp_ptrs_t () {};
244         ~comp_ptrs_t () {};
245
246 public:
247     BOOL    Init(UInt16 *data, UInt16 datasize);
248     UInt16  *out_ptr, *image_ptr; /* image ptr points into the raw data */
249     UInt16  out_cnt,  image_cnt,  copy_cnt;
250     UInt16  out_array[2048+16];
251     UInt16  *raw_data;
252     UInt16  input_size;
253
254     UInt16  compress;
255     UInt16  display;
256     UInt16  run_length; /* minimun run length */
257
258     UInt16  data_length;  /* actual data size in record */
259     UInt16  image_bytes;  /* uncompressed size */
260     UInt16  command_number;
261     UInt16  data_type;
262 };
263 #endif  // APDK_LDL_COMPRESS
264
265 class LDLEncap //: public Compressor
266 {
267 public:
268     LDLEncap (DJ3320 *pPrinter, SystemServices *pSys, PrintContext *pc);
269     DRIVER_ERROR Encapsulate (const BYTE* input, DWORD size, BOOL bLastPlane);
270     ~LDLEncap ();
271
272     DRIVER_ERROR StartJob ();
273     DRIVER_ERROR EndPage ();
274     DRIVER_ERROR EndJob ();
275     DRIVER_ERROR Continue ();
276     DRIVER_ERROR CleanPen ();
277     void    Cancel ();
278     void    Flush ();
279     DRIVER_ERROR    SetVerticalSkip (int nBlankRasters);
280     void AllocateSwathBuffer (unsigned int RasterSize);
281
282     BOOL UpdateState (BOOL bInitialize);
283
284     DJ3320  *pPrinterXBow;
285     DRIVER_ERROR    constructor_error;
286
287     short int   *piCreditCount;
288     BYTE        byNumberOfCommands;
289     BYTE        byStatusBuff[DevIDBuffSize];
290     BOOL        bNewStatus;
291 //  BYTE        byQuery[QUERYSIZE];
292     BYTE        pbyCancel[CANCELSIZE];
293     BYTE        *pbySync;
294
295 private:
296     DRIVER_ERROR    StartPage ();
297
298     SystemServices  *m_pSys;
299     int     m_iRasterCount;
300     int     m_iImageWidth;
301     int     m_iXResolution;
302     int     m_iYResolution;
303     UInt16  m_sRefCount;
304     int     m_iNumColors;
305     char    m_cPrintDirection;
306     BYTE    *m_szCmdBuf;
307     BOOL    m_bLittleEndian;
308     PrintContext    *m_pthisPC;
309     BYTE    ***m_SwathData;
310     short   m_sSwathHeight;
311     int     m_iBlankRasters;
312     int     m_iVertPosn;
313     int     m_iLeftMargin;
314     BOOL    m_bBidirectionalPrintingOn;
315     Int16   m_iBitDepth;
316     BYTE    m_cPassNumber;
317     BYTE    m_cPlaneNumber;
318     BYTE    m_cPrintQuality;
319     BYTE    m_cMediaType;
320     BYTE    *m_szCompressBuf;
321     int     m_iNextRaster;
322     int     m_iNextColor;
323
324         BOOL    m_bStartPageNotSent;
325
326     UInt16  m_uVal16;
327     UInt32  m_uVal32;
328     BYTE    *m_cByte;
329     BYTE    *m_pbyPacketBuff;
330         DWORD   m_dwPacketBuffSize;
331
332 /*
333  *  Pen Alignment Values.
334  */
335
336     BYTE    m_cKtoCVertAlign;
337         BYTE    m_cPtoCVertAlign;
338
339     DRIVER_ERROR    PrintSweep (UInt32 SweepSize,
340                         BOOL ColorPresent,
341                         BOOL BlackPresent,
342                                                 BOOL PhotoPresent,
343                         Int32 VerticalPosition,
344                         Int32 LeftEdge,
345                         Int32 RightEdge,
346                         char PrintDirection,
347                         Int16 sFirstNozzle,
348                         Int16 sLastNozzle = 0);
349     DRIVER_ERROR    LoadSweepData (BYTE *dataPtr, int imagesize);
350     void            FillLidilHeader (void *pLidilHdr, int Command,
351                              UInt16 CmdLen, UInt16 DataLen);
352     unsigned int    GetSwathWidth (int iFirst, int iLast, int iWidth);
353     BOOL            IsBlankRaster (BYTE *input, int iWidth);
354     DRIVER_ERROR    ProcessSwath (int iCurRasterWidth);
355
356     BOOL            GetPackets (DWORD &dwBytesRead);
357
358 #ifdef  APDK_LDL_COMPRESS
359 /*
360  *  Compression Related
361  */
362
363         BOOL   GetFrameInfo (BYTE **outdata, UInt16 *datasize);
364         void   CompressData (Int16 compressmode = 1);
365
366         UInt16 FlushCopy (UInt16 value);
367         UInt16 FlushImage ();
368
369     comp_ptrs_t     *m_ldlCompressData;
370 #endif  // APDK_LDL_COMPRESS
371
372 };
373
374 #define WRITE16(value)  \
375         m_uVal16 = value; \
376         m_cByte = (BYTE *) &m_uVal16; \
377         if (m_bLittleEndian)       \
378         { \
379             m_szCmdBuf[index++] = m_cByte[1];  \
380             m_szCmdBuf[index++] = m_cByte[0]; \
381         } \
382         else \
383         { \
384             memcpy (m_szCmdBuf+index, m_cByte, 2); \
385             index += 2; \
386         }
387
388 #define WRITE32(value) \
389         m_uVal32 = value; \
390         m_cByte = (BYTE *) &m_uVal32; \
391         if (m_bLittleEndian)       \
392         { \
393             m_szCmdBuf[index++] = m_cByte[3];  \
394             m_szCmdBuf[index++] = m_cByte[2]; \
395             m_szCmdBuf[index++] = m_cByte[1]; \
396             m_szCmdBuf[index++] = m_cByte[0]; \
397         } \
398         else \
399         { \
400             memcpy (m_szCmdBuf+index, m_cByte, 4); \
401             index += 4; \
402         }
403
404 APDK_END_NAMESPACE
405
406 #endif //APDK_DJ3320_H