Tizen 2.1 base
[platform/upstream/hplip.git] / prnt / hpijs / dj9xxvip.h
1 /*****************************************************************************\
2   dj9xxvip.h : Interface for the DJ9xxVIP class
3
4   Copyright (c) 1996 - 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 #ifndef APDK_DJ9XXVIP_H
33 #define APDK_DJ9XXVIP_H
34
35 APDK_BEGIN_NAMESPACE
36
37 //extern char *ModelString[MAX_ID_STRING];
38
39 /*!
40 \internal
41 */
42 class DJ9xxVIP : public Printer
43 {
44 public:
45     DJ9xxVIP(SystemServices* pSS, BOOL proto=FALSE);
46
47     Header* SelectHeader(PrintContext* pc);
48     DRIVER_ERROR VerifyPenInfo();
49     DRIVER_ERROR ParsePenInfo(PEN_TYPE& ePen, BOOL QueryPrinter=TRUE);
50     DISPLAY_STATUS ParseError(BYTE status_reg);
51
52     Compressor* CreateCompressor(unsigned int RasterSize);
53
54     virtual BOOL UseGUIMode(PrintMode* pPrintMode);
55     BOOL UseCMYK(unsigned int iPrintMode) { return FALSE; }
56
57     DRIVER_ERROR CleanPen();
58
59     virtual PAPER_SIZE MandatoryPaperSize();
60
61     virtual DRIVER_ERROR CheckInkLevel();
62
63     virtual BOOL PhotoTrayPresent(BOOL bQueryPrinter);
64
65     virtual PHOTOTRAY_STATE PhotoTrayEngaged (BOOL bQueryPrinter);
66
67     inline virtual BOOL SupportSeparateBlack (PrintMode *pCurrentMode)
68     {
69         if (pCurrentMode->medium == mediaAuto ||
70             pCurrentMode->medium == mediaPlain)
71         {
72             return TRUE;
73         }
74         return FALSE;
75     }
76 \r
77     virtual DRIVER_ERROR SetHint (PRINTER_HINT eHint, int iValue)\r
78     {\r
79         switch (eHint)\r
80         {\r
81             case PAGES_IN_DOC_HINT:\r
82             {\r
83                 m_iNumPages = iValue;\r
84                 break;\r
85             }\r
86             case SPEED_MECH_HINT:\r
87             {\r
88                 return SendSpeedMechCmd (iValue);\r
89             }\r
90             case EXTRA_DRYTIME_HINT:\r
91             {\r
92                 m_cExtraDryTime = (BYTE) (iValue & 0xFF);\r
93                 break;\r
94             }\r
95             case LEFT_OVERSPRAY_HINT:\r
96             {\r
97                 m_iLeftOverspray = iValue;\r
98                 break;\r
99             }\r
100             case RIGHT_OVERSPRAY_HINT:\r
101             {\r
102                 m_iRightOverspray = iValue;\r
103                 break;\r
104             }\r
105             case TOP_OVERSPRAY_HINT:\r
106             {\r
107                 m_iTopOverspray = iValue;\r
108                 break;\r
109             }\r
110             case BOTTOM_OVERSPRAY_HINT:\r
111             {\r
112                 m_iBottomOverspray = iValue;\r
113                 break;\r
114             }\r
115 \r
116             default:\r
117                 break;\r
118         }\r
119         return NO_ERROR;\r
120     }\r
121     virtual int GetHint (PRINTER_HINT eHint)\r
122     {\r
123         if (eHint == EXTRA_DRYTIME_HINT)\r
124         {\r
125             return (int) m_cExtraDryTime;\r
126         }\r
127         return 0;\r
128     }\r
129 \r
130     virtual DRIVER_ERROR AddPJLHeader ();\r
131 protected:
132
133 #ifdef APDK_HP_UX
134     virtual DJ9xxVIP & operator = (Printer& rhs)
135     {
136         return *this;
137     }\r
138 #endif
139
140     BOOL PCL3acceptsDriverware;
141     virtual BYTE PhotoTrayStatus(BOOL bQueryPrinter);
142         int             iNumMissingPens;
143     int     m_iLeftOverspray;\r
144     int     m_iTopOverspray;\r
145     int     m_iRightOverspray;\r
146     int     m_iBottomOverspray;\r
147
148 private:
149     BOOL IsPCL3DriverwareAvailable();\r
150     virtual DRIVER_ERROR SendSpeedMechCmd (BOOL bLastPage)\r
151     {\r
152         return NO_ERROR;\r
153     }\r
154     BYTE    m_cExtraDryTime;\r
155 }; //DJ9xxVIP
156
157
158 class DJ990Mode : public PrintMode
159 {
160 public:
161     DJ990Mode();
162 }; //AladdenMode
163
164
165 class GrayModeDJ990 : public GrayMode
166 {
167 public:
168     GrayModeDJ990 (uint32_t *map, BOOL PCL3OK);
169 }; //GrayModeDJ990
170
171 class DJ990CMYGrayMode : public PrintMode
172 {
173 public:
174     DJ990CMYGrayMode ();
175 }; //DJ990CMYGrayMode
176
177 #ifdef APDK_EXTENDED_MEDIASIZE
178 class DJ990KGrayMode : public PrintMode
179 {
180 public:
181     DJ990KGrayMode ();
182 }; //DJ990KGrayMode
183
184 class DJ9902400Mode : public PrintMode
185 {
186 public:
187     DJ9902400Mode ();\r
188     virtual inline BOOL MediaCompatible (MEDIATYPE eMedia)\r
189     {\r
190         return (eMedia == pmMediaType || eMedia == MEDIA_PHOTO);\r
191     }
192 }; // DJ9902400Mode
193
194 class DJ990DraftMode : public PrintMode
195 {
196 public:
197     DJ990DraftMode ();
198 }; // DJ990DraftMode
199
200 #endif // APDK_EXTENDED_MEDIASIZE
201
202 class DJ990BestMode : public PrintMode
203 {
204 public:
205     DJ990BestMode ();
206 };  // DJ990BestMode
207
208 class DJ990PhotoNormalMode : public PrintMode
209 {
210 public:
211     DJ990PhotoNormalMode ();
212 }; // DJ990 PhotoNormalMode
213
214 #ifdef APDK_HIGH_RES_MODES
215     const int VIP_BASE_RES = 600;
216 #else
217     const int VIP_BASE_RES = 300;
218 #endif
219
220 /////////////////////////////
221 #define kWhite 0x00FFFFFE
222 #define GetRed(x) (((x >> 16) & 0x0FF))
223 #define GetGreen(x) (((x >> 8) & 0x0FF))
224 #define GetBlue(x) ((x & 0x0FF))
225
226 #define kBertDecompressPixelSize 3
227
228 // Follows are all the masks for the command byte.
229 #define kTypeMask           0x80
230 #define kTypeShiftAmount    7
231
232 #define kCacheLiteralBitsMask 0x60
233 #define kCacheLiteralBitsShiftAmount 5
234
235 #define kCacheBitsMask 0x60
236 #define kCacheBitsShiftAmount 5
237
238 #define kRoffMask           0x18
239 #define kRoffShiftAmount    3
240
241 #define kReplace_countMask  0x07
242
243 // Now have the compiler check to make sure none of the masks overlap/underlap bits accidently.
244 #if ((kTypeMask | kCacheLiteralBitsMask | kRoffMask | kReplace_countMask) != 255)
245 #error "Your mask bits are messed up!"
246 #endif
247
248 #if ((kTypeMask | kCacheBitsMask | kRoffMask | kReplace_countMask) != 255)
249 #error "Your mask bits are messed up!"
250 #endif
251
252
253 enum
254 {
255     eLiteral = 0,
256     eRLE = 0x80
257 };
258
259 enum
260 {
261     eeNewPixel = 0x0,
262     eeWPixel = 0x20,
263     eeNEPixel = 0x40,
264     eeCachedColor = 0x60
265 };
266
267 enum
268 {
269     eNewColor       = 0x0,
270     eWestColor      = 0x1,
271     eNorthEastColor = 0x2,
272     eCachedColor    = 0x3
273 };
274
275
276 // Literal
277 #define M10_MAX_OFFSET0         2       /* Largest unscaled value an offset can have before extra byte is needed. */
278 #define M10_MAX_COUNT0          6       /* Largest unscaled and unbiased value a count can have before extra byte is needed */
279 #define M10_COUNT_START0        1       /* What a count of zero has a value of. */
280
281 // RLE
282 #define M10_MAX_OFFSET1         2
283 #define M10_MAX_COUNT1          6
284 #define M10_COUNT_START1        2
285
286 #ifndef MIN
287 #define MIN(a,b)    (((a)>=(b))?(b):(a))
288 #endif
289 #ifndef MAX
290 #define MAX(a,b)    (((a)<=(b))?(b):(a))
291 #endif
292
293 /*
294 We don't actually support 4-byte RGB for anything excpet VIP printers.
295 So implimenting this and documenting it as a build option is misleading.
296 We must make halftoning support 4-byte RGB before we can publish this.
297 If we hear from someone that they need support for 4-byte RGB (and it's
298 worth it) then we will add it to halftoning, put the define in config.h,
299 and uncomment the #if here.  1/17/2002 - JLM
300
301 #if defined(APDK_4BYTE_RGB)
302     #define getPixel get4Pixel
303     #define putPixel put4Pixel
304     const unsigned int BYTES_PER_PIXEL = 4;
305 #else
306 */
307     #define getPixel get3Pixel
308     #define putPixel put3Pixel
309     const unsigned int BYTES_PER_PIXEL = 3;
310 //#endif
311
312
313 /*!
314 \internal
315 */
316 class Mode10 : public Compressor
317 {
318 public:
319     Mode10(SystemServices* pSys, Printer* pPrinter, unsigned int RasterSize);
320     virtual ~Mode10();
321     BOOL Process(RASTERDATA* input);
322         BYTE* NextOutputRaster(COLORTYPE color);
323     void Flush();
324
325 private:
326     Printer* thePrinter;
327
328     inline uint32_t get4Pixel(unsigned char *pixAddress, unsigned int bPrint = FALSE)
329         {
330             #ifdef APDK_LITTLE_ENDIAN
331                 return (((unsigned int*)pixAddress)[0]) & kWhite;
332             #else
333                 return (((unsigned int*)pixAddress)[0]) & 0xFFFFFF00;
334             #endif
335         }
336
337
338     inline uint32_t get4Pixel(unsigned char *pixAddress, int pixelOffset)
339         {
340             #ifdef APDK_LITTLE_ENDIAN
341                 return ((unsigned int*)pixAddress)[pixelOffset] & kWhite;
342             #else
343                 return ((unsigned int*)pixAddress)[pixelOffset] & 0xFFFFFF00;
344             #endif
345         }
346
347
348     inline void put4Pixel(unsigned char *pixAddress, int pixelOffset, uint32_t pixel)
349         {
350             #ifdef APDK_LITTLE_ENDIAN
351                 (((unsigned int*)pixAddress)[pixelOffset] = pixel & kWhite);
352             #else
353                 (((unsigned int*)pixAddress)[pixelOffset] = pixel & 0xFFFFFF00);
354             #endif
355         }
356
357
358     inline void outputVLIBytesConsecutively(int number, unsigned char *&compressedDataPtr)
359     {
360         do
361         {
362             *compressedDataPtr++ = MIN(number, 255);
363             if (255 == number)
364             {
365                 *compressedDataPtr++ = 0;
366             }
367             number -= MIN(number,255);
368         } while (number);
369     }
370
371
372     void put3Pixel(BYTE* pixAddress, int pixelOffset, uint32_t pixel);
373     inline uint32_t get3Pixel(BYTE* pixAddress, int pixelOffset);
374     unsigned short ShortDelta(uint32_t lastPixel, uint32_t lastUpperPixel);
375
376
377 }; //Mode10
378
379 #ifdef APDK_DJ9xxVIP
380 //! DJ9xxVIPProxy
381 /*!
382 ******************************************************************************/
383 class DJ9xxVIPProxy : public PrinterProxy
384 {
385 public:
386     DJ9xxVIPProxy() : PrinterProxy(
387         "DJ9xxVIP",                     // family name
388         "DESKJET 96\0"                              // DeskJet 96x series
389         "DESKJET 98\0"                              // DeskJet 98x series
390         "DESKJET 99\0"                              // DeskJet 99x series
391         "deskjet 6122\0"                            // deskjet 6122
392         "deskjet 6127\0"                            // deskjet 6127
393         "PHOTOSMART 1115\0"
394         "PHOTOSMART 1215\0"                         // PSP 1215
395         "PHOTOSMART 1218\0"                         // PSP 1218
396         "PHOTOSMART 1115\0"                         // PSP 1115
397         "PHOTOSMART 1315\0"                         // PSP 1315
398         "HP BUSINESS INKJET 22\0"                   // 2200, 2230, 2250, 2280
399         "cp1160\0"                                  // CP 1160
400         "HP Color Inkjet CP1700\0"                  // CP 1700
401         "HP BUSINESS INKJET 22\0"
402         "dj450\0"
403                 "deskjet 450\0"
404 #ifdef APDK_MLC_PRINTER
405         "officejet d\0"                             // officejet d series
406                 "officejet 7100\0"                          // offjetjet 7100 series
407 #endif
408     ) {m_iPrinterType = eDJ9xxVIP;}
409     inline Printer* CreatePrinter(SystemServices* pSS) const { return new DJ9xxVIP(pSS); }
410         inline PRINTER_TYPE GetPrinterType() const { return eDJ9xxVIP;}
411         inline unsigned int GetModelBit() const { return 0x10000;}
412 };
413 #endif
414
415 APDK_END_NAMESPACE
416
417 #endif //APDK_DJ9XXVIP_H