Tizen 2.1 base
[platform/upstream/hplip.git] / prnt / hpijs / dj8x5.cpp
1 /*****************************************************************************\
2   dj8x5.cpp : Implimentation for the DJ8x5 class
3
4   Copyright (c) 1996 - 2001, 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 #if defined(APDK_DJ8xx)|| defined(APDK_DJ9xx)
33
34 #ifdef APDK_DJ8x5
35 #include "header.h"
36 #include "dj8xx.h"
37 #include "dj8x5.h"
38 #include "printerproxy.h"
39
40 APDK_BEGIN_NAMESPACE            // must be here for non-test harness case
41 extern BYTE* GetHT3x3_4();
42 extern BYTE* GetHT6x6_4();
43 APDK_END_NAMESPACE              // must be here for non-test harness case
44
45 APDK_BEGIN_NAMESPACE
46
47 extern uint32_t ulMapDJ8x5PlainNormal[ 9 * 9 * 9 ];
48 extern uint32_t ulMapDJ895_HB_KCMY[ 9 * 9 * 9 ];
49 extern uint32_t ulMapDJ8x5Draft[ 9 * 9 * 9 ];
50
51
52 DJ8x5Mode1::DJ8x5Mode1()
53 : PrintMode(ulMapDJ8x5PlainNormal)
54 // 600x600x1 K
55 // 300x300x2 CMY
56 {
57
58     ColorDepth[K]=1;  // 600x600x1 K
59
60     for (int i=1; i < 4; i++)
61         ColorDepth[i]=2;    // 300x300x2 CMY
62
63     ResolutionX[K] =
64     ResolutionY[K] = 600;
65
66     MixedRes = TRUE;
67
68     ColorFEDTable = GetHT3x3_4();
69
70     bFontCapable = FALSE;       // DJ8xx can't do fonts and hifipe at same time
71     dyeCount = 3;
72     CompatiblePens[0] = COLOR_PEN;
73 }
74
75 DJ8x5Mode2::DJ8x5Mode2()
76 : PrintMode(ulMapDJ895_HB_KCMY)
77 // 600x600x2 CMY
78 {
79     int i;
80     ColorDepth[K]=1;  // 600x600x1 K
81
82     for (i=1; i < 4; i++)
83         ColorDepth[i]=2;    // 600x600x2 CMY
84
85     for (i=0; i < 4; i++)
86         ResolutionX[i]=ResolutionY[i]=600;
87
88     BaseResX = BaseResY = 600;
89     MixedRes = FALSE;
90
91     medium     = mediaGlossy;
92     theQuality = qualityPresentation;
93
94     ColorFEDTable = GetHT6x6_4();
95
96      bFontCapable = FALSE;       // DJ8xx can't do fonts and hifipe at same time
97
98     dyeCount = 3;
99     CompatiblePens[0] = COLOR_PEN;
100
101     pmQuality   = QUALITY_BEST;
102     pmMediaType = MEDIA_PHOTO;
103 }
104
105 DJ8x5Mode3::DJ8x5Mode3()
106 : PrintMode(ulMapDJ8x5Draft)
107 // 300x300x1 CMY
108 {
109
110     dyeCount = 3;
111     CompatiblePens[0] = COLOR_PEN;
112     theQuality = qualityDraft;
113     pmQuality  = QUALITY_DRAFT;
114 }
115
116 DJ8x5::DJ8x5 (SystemServices* pSS, int numfonts, BOOL proto)
117     : DJ8xx (pSS, numfonts, TRUE)
118 {
119     CMYMap = ulMapDJ8x5Draft;
120
121 /*
122  *  If we don't have device id, we won't know about the pens installed.
123  *  But since both 825 and 845 ship with atleast a colorpen, we will
124  *  default to COLOR_PEN, so it will work okay out of the box.
125  */
126
127     if ((!proto) && (IOMode.bDevID))
128     {
129         constructor_error = VerifyPenInfo();
130         CERRCHECK;
131     }
132     else
133     {
134         ePen = COLOR_PEN;
135     }
136
137 // DJ8xx modes based on BOTH_PENS are already installed (i.e. pModes 0-4)
138
139     pMode[5]    = new DJ8x5Mode1 ();    // Normal Color CMY
140     pMode[6]    = new DJ8x5Mode2 ();    // Photo CMY
141     pMode[7]    = new DJ8x5Mode3 ();    // Draft Color CMY
142     ModeCount = 8;
143
144     DBG1("DJ8x5 created\n");
145 }
146
147 PEN_TYPE DJ8x5::DefaultPenSet()
148 {
149     return COLOR_PEN;
150 }
151
152 DRIVER_ERROR DJ8x5::VerifyPenInfo ()
153 {
154
155     DRIVER_ERROR err=NO_ERROR;
156
157     if(IOMode.bDevID == FALSE)
158         return err;
159
160     err = ParsePenInfo (ePen);
161
162     if(err == UNSUPPORTED_PEN) // probably Power Off - pens couldn't be read
163     {
164         DBG1("DJ8x5::Need to do a POWER ON to get penIDs\n");
165
166         if (pSS->BusyWait((DWORD)2000) == JOB_CANCELED)
167             return JOB_CANCELED;
168
169         DWORD length=sizeof (DJ895_Power_On);
170         err = pSS->ToDevice (DJ895_Power_On, &length);
171         ERRCHECK;
172
173         err = pSS->FlushIO ();
174         ERRCHECK;
175
176         // give the printer some time to power up
177         if (pSS->BusyWait ((DWORD) 2500) == JOB_CANCELED)
178             return JOB_CANCELED;
179
180         err = ParsePenInfo(ePen);
181     }
182
183     ERRCHECK;
184
185     // check for the normal case
186     if (ePen == BOTH_PENS)
187         return NO_ERROR;
188
189     while (ePen == NO_PEN)
190     {
191         pSS->DisplayPrinterStatus(DISPLAY_NO_PENS);
192
193         if (pSS->BusyWait(500) == JOB_CANCELED)
194             return JOB_CANCELED;
195
196         err =  ParsePenInfo(ePen);
197         ERRCHECK;
198     }
199
200     pSS->DisplayPrinterStatus(DISPLAY_PRINTING);
201
202     return NO_ERROR;
203 }
204
205 APDK_END_NAMESPACE
206
207 #endif // APDK_DJ8x5
208 #endif  // APDK_DJ895