summaryrefslogtreecommitdiff
path: root/src/rdc_2dtool.h
blob: 1763f2c7ac71a7edd20abe3c983b54c3c9bc9935 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
/* 
 * Copyright (C) 2009 RDC Semiconductor Co.,Ltd
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * For technical support : 
 *     <jason.lin@rdc.com.tw>
 */


/* Eng Capability Definition */
#define    ENG_CAP_Sync                         0x00000001
#define    ENG_CAP_ScreenToScreenCopy           0x00000002
#define    ENG_CAP_SolidFill                    0x00000004
#define    ENG_CAP_SolidLine                    0x00000008
#define    ENG_CAP_DashedLine                   0x00000010
#define    ENG_CAP_Mono8x8PatternFill           0x00000020
#define    ENG_CAP_Color8x8PatternFill          0x00000040
#define    ENG_CAP_CPUToScreenColorExpand       0x00000080
#define    ENG_CAP_ScreenToScreenColorExpand    0x00000100
#define    ENG_CAP_Clipping                     0x00000200    
#define ENG_CAP_ALL (ENG_CAP_Sync | ENG_CAP_ScreenToScreenCopy | ENG_CAP_SolidFill |    \
                     ENG_CAP_SolidLine | ENG_CAP_DashedLine |                \
                     ENG_CAP_Mono8x8PatternFill | ENG_CAP_Color8x8PatternFill |        \
                     ENG_CAP_Clipping);

#define    ENG_CAP_VIDEO_DISP                   0x00000400
#define    ENG_CAP_VIDEO_POS                    0x00000800
#define    ENG_CAP_HWC_MMIO                     0x00001000

/* CMDQ Definition */
#define    VM_CMD_QUEUE             0
#define    VM_CMD_MMIO              2

#define    CMD_QUEUE_SIZE_256K      0x00040000
#define    CMD_QUEUE_SIZE_512K      0x00080000
#define    CMD_QUEUE_SIZE_1M        0x00100000
#define    CMD_QUEUE_SIZE_2M        0x00200000
#define    CMD_QUEUE_SIZE_4M        0x00400000

/* CMD Type Info */
#define    PKT_NULL_CMD             0x00009561

#define    PKT_SINGLE_LENGTH        8
#define    PKT_SINGLE_CMD_HEADER    0x00009562

typedef struct  _PKT_SC
{
    ULONG    PKT_SC_dwHeader;
    ULONG    PKT_SC_dwData[1];
    
} PKT_SC, *PPKT_SC;

/* Eng Reg. Limitation */
#define    MAX_SRC_X                0x7FF
#define    MAX_SRC_Y                0x7FF
#define    MAX_DST_X                0x7FF
#define    MAX_DST_Y                0x7FF

#define    MASK_SRC_PITCH           0x1FFF
#define    MASK_DST_PITCH           0x1FFF
#define    MASK_DST_HEIGHT          0x7FF
#define    MASK_SRC_X               0xFFF
#define    MASK_SRC_Y               0xFFF
#define    MASK_DST_X               0xFFF
#define    MASK_DST_Y               0xFFF
#define    MASK_RECT_WIDTH          0x7FF
#define    MASK_RECT_HEIGHT         0x7FF
#define MASK_CLIP                   0xFFF
#define MASK_1ST_FLIP_BASE          0x0FFFFFF8

#define MASK_LINE_X                 0xFFF   
#define MASK_LINE_Y                 0xFFF
#define MASK_LINE_ERR               0x3FFFFF        
#define MASK_LINE_WIDTH             0x7FF        
#define MASK_LINE_K1                0x3FFFFF           
#define MASK_LINE_K2                0x3FFFFF
#define MASK_M2010LINE_X              0xFFF   
#define MASK_M2010LINE_Y              0xFFF

#define MAX_PATReg_Size             256

/* Eng Reg. Definition */  
/* MMIO Reg */
#define MMIOREG_SRC_BASE    (pRDC->MMIOVirtualAddr + 0x8000)                
#define MMIOREG_SRC_PITCH   (pRDC->MMIOVirtualAddr + 0x8004)
#define MMIOREG_DST_BASE    (pRDC->MMIOVirtualAddr + 0x8008)
#define MMIOREG_DST_PITCH   (pRDC->MMIOVirtualAddr + 0x800C)
#define MMIOREG_DST_XY      (pRDC->MMIOVirtualAddr + 0x8010)
#define MMIOREG_SRC_XY      (pRDC->MMIOVirtualAddr + 0x8014)
#define MMIOREG_RECT_XY     (pRDC->MMIOVirtualAddr + 0x8018)
#define MMIOREG_FG          (pRDC->MMIOVirtualAddr + 0x801C)
#define MMIOREG_BG          (pRDC->MMIOVirtualAddr + 0x8020)
#define MMIOREG_FG_SRC      (pRDC->MMIOVirtualAddr + 0x8024)
#define MMIOREG_BG_SRC      (pRDC->MMIOVirtualAddr + 0x8028)
#define MMIOREG_MONO1       (pRDC->MMIOVirtualAddr + 0x802C)
#define MMIOREG_MONO2       (pRDC->MMIOVirtualAddr + 0x8030)
#define MMIOREG_CLIP1       (pRDC->MMIOVirtualAddr + 0x8034)
#define MMIOREG_CLIP2       (pRDC->MMIOVirtualAddr + 0x8038)
#define MMIOREG_CMD         (pRDC->MMIOVirtualAddr + 0x803C)
#define MMIOREG_1ST_FLIP    (pRDC->MMIOVirtualAddr + 0x8040)
#define MMIOREG_PAT         (pRDC->MMIOVirtualAddr + 0x8100)    

#define MMIOREG_LINE_XY     (pRDC->MMIOVirtualAddr + 0x8010)  
#define MMIOREG_LINE_Err    (pRDC->MMIOVirtualAddr + 0x8014)  
#define MMIOREG_LINE_WIDTH  (pRDC->MMIOVirtualAddr + 0x8018)  
#define MMIOREG_LINE_K1     (pRDC->MMIOVirtualAddr + 0x8024)  
#define MMIOREG_LINE_K2     (pRDC->MMIOVirtualAddr + 0x8028)  
#define MMIOREG_LINE_STYLE1 (pRDC->MMIOVirtualAddr + 0x802C)  
#define MMIOREG_LINE_STYLE2 (pRDC->MMIOVirtualAddr + 0x8030)  
#define MMIOREG_LINE_XY2    (pRDC->MMIOVirtualAddr + 0x8014)
#define MMIOREG_LINE_NUMBER (pRDC->MMIOVirtualAddr + 0x8018)  

/* CMDQ Reg */
#define CMDQREG_SRC_BASE    (0x00 << 24)                       
#define CMDQREG_SRC_PITCH   (0x01 << 24)
#define CMDQREG_DST_BASE    (0x02 << 24)
#define CMDQREG_DST_PITCH   (0x03 << 24)
#define CMDQREG_DST_XY      (0x04 << 24)
#define CMDQREG_SRC_XY      (0x05 << 24)
#define CMDQREG_RECT_XY     (0x06 << 24)
#define CMDQREG_FG          (0x07 << 24)
#define CMDQREG_BG          (0x08 << 24)
#define CMDQREG_FG_SRC      (0x09 << 24)
#define CMDQREG_BG_SRC      (0x0A << 24)
#define CMDQREG_MONO1       (0x0B << 24)
#define CMDQREG_MONO2       (0x0C << 24)
#define CMDQREG_CLIP1       (0x0D << 24)
#define CMDQREG_CLIP2       (0x0E << 24)
#define CMDQREG_CMD         (0x0F << 24)
#define CMDQREG_PAT         (0x40 << 24)

#define CMDQREG_LINE_XY     (0x04 << 24)
#define CMDQREG_LINE_Err    (0x05 << 24)  
#define CMDQREG_LINE_WIDTH  (0x06 << 24)    
#define CMDQREG_LINE_K1     (0x09 << 24) 
#define CMDQREG_LINE_K2     (0x0A << 24)
#define CMDQREG_LINE_STYLE1 (0x0B << 24) 
#define CMDQREG_LINE_STYLE2 (0x0C << 24)
#define CMDQREG_LINE_XY2    (0x05 << 24)
#define CMDQREG_LINE_NUMBER (0x06 << 24)    

/* CMD Reg. Definition */
#define CMD_BITBLT              0x00000000
#define CMD_LINEDRAW            0x00000001
#define CMD_COLOREXP            0x00000002
#define CMD_ENHCOLOREXP         0x00000003
#define CMD_TRANSPARENTBLT      0x00000004
#define CMD_MASK                0x00000007
                  
#define CMD_DISABLE_CLIP        0x00000000   
#define CMD_ENABLE_CLIP         0x00000008

#define CMD_COLOR_08            0x00000000
#define CMD_COLOR_16            0x00000010
#define CMD_COLOR_32            0x00000020

#define CMD_SRC_SIQ             0x00000040

#define CMD_TRANSPARENT         0x00000080

#define CMD_PAT_FGCOLOR         0x00000000
#define CMD_PAT_MONOMASK        0x00010000
#define CMD_PAT_PATREG          0x00020000

#define CMD_OPAQUE              0x00000000
#define CMD_FONT_TRANSPARENT    0x00040000

#define CMD_X_INC               0x00000000    
#define CMD_X_DEC               0x00200000

#define CMD_Y_INC               0x00000000    
#define CMD_Y_DEC               0x00100000

#define CMD_NT_LINE             0x00000000
#define CMD_NORMAL_LINE         0x00400000

#define CMD_DRAW_LAST_PIXEL     0x00000000
#define CMD_NOT_DRAW_LAST_PIXEL 0x00800000

#define CMD_DISABLE_LINE_STYLE  0x00000000
#define CMD_ENABLE_LINE_STYLE   0x40000000

#define CMD_RESET_STYLE_COUNTER 0x80000000
#define CMD_NOT_RESET_STYLE_COUNTER 0x00000000

#define BURST_FORCE_CMD         0x80000000

/* Line */
#define LINEPARAM_XM            0x00000001
#define LINEPARAM_X_DEC         0x00000002
#define LINEPARAM_Y_DEC         0x00000004

typedef struct _LINEPARAM {
    USHORT  dsLineX;
    USHORT  dsLineY;
    USHORT  dsLineWidth;
    ULONG   dwErrorTerm;
    ULONG   dwK1Term;
    ULONG   dwK2Term;
    ULONG   dwLineAttributes;    
} LINEPARAM, *PLINEPARAM;

typedef struct {
    LONG    X1;
    LONG    Y1;
    LONG    X2;
    LONG    Y2;    
} _LINEInfo;

/* Macro */
/* MMIO 2D Macro */
#define RDCSetupSRCBase_MMIO(base) \
      { \
        do { \
           *(ULONG *)(MMIOREG_SRC_BASE) = (ULONG) (base); \
        } while (*(volatile ULONG *)(MMIOREG_SRC_BASE) != (ULONG) (base)); \
      }
#define RDCSetupSRCPitch_MMIO(pitch) \
      { \
        do { \
           *(ULONG *)(MMIOREG_SRC_PITCH) = (ULONG)(pitch << 16); \
        } while (*(volatile ULONG *)(MMIOREG_SRC_PITCH) != (ULONG)(pitch << 16)); \
      }
#define RDCSetupDSTBase_MMIO(base) \
      { \
        do { \
           *(ULONG *)(MMIOREG_DST_BASE) = (ULONG)(base); \
        } while (*(volatile ULONG *)(MMIOREG_DST_BASE) != (ULONG)(base)); \
      }      
#define RDCSetupDSTPitchHeight_MMIO(pitch, height) \
      { \
        ULONG dstpitch; \
        dstpitch = (ULONG)((pitch << 16) + ((height) & MASK_DST_HEIGHT)); \
        do { \
           *(ULONG *)(MMIOREG_DST_PITCH) = dstpitch; \
        } while (*(volatile ULONG *)(MMIOREG_DST_PITCH) != dstpitch); \
      }      
#define RDCSetupDSTXY_MMIO(x, y) \
      { \
        ULONG dstxy; \
        dstxy = (ULONG)(((x & MASK_DST_X) << 16) + (y & MASK_DST_Y)); \
        do { \
           *(ULONG *)(MMIOREG_DST_XY) = dstxy; \
        } while (*(volatile ULONG *)(MMIOREG_DST_XY) != dstxy); \
      }           
#define RDCSetupSRCXY_MMIO(x, y) \
      { \
        ULONG srcxy; \
        srcxy = (ULONG)(((x & MASK_SRC_X) << 16) + (y & MASK_SRC_Y)); \
        do { \
           *(ULONG *)(MMIOREG_SRC_XY) = srcxy; \
        } while (*(volatile ULONG *)(MMIOREG_SRC_XY) != srcxy); \
      }             
#define RDCSetupRECTXY_MMIO(x, y) \
      { \
        ULONG rectxy; \
        rectxy = (ULONG)(((x & MASK_RECT_WIDTH) << 16) + (y & MASK_RECT_WIDTH)); \
        do { \
           *(ULONG *)(MMIOREG_RECT_XY) = rectxy; \
        } while (*(volatile ULONG *)(MMIOREG_RECT_XY) != rectxy); \
      }  
#define RDCSetupFG_MMIO(color) \
      { \
        do { \
           *(ULONG *)(MMIOREG_FG) = (ULONG)(color); \
        } while (*(volatile ULONG *)(MMIOREG_FG) != (ULONG)(color)); \
      } 
#define RDCSetupBG_MMIO(color) \
      { \
        do { \
           *(ULONG *)(MMIOREG_BG) = (ULONG)(color); \
        } while (*(volatile ULONG *)(MMIOREG_BG) != (ULONG)(color)); \
      }
#define RDCSetupMONO1_MMIO(pat) \
      { \
        do { \
          *(ULONG *)(MMIOREG_MONO1) = (ULONG)(pat); \
        } while (*(volatile ULONG *)(MMIOREG_MONO1) != (ULONG)(pat)); \
      } 
#define RDCSetupMONO2_MMIO(pat) \
      { \
        do { \
          *(ULONG *)(MMIOREG_MONO2) = (ULONG)(pat); \
        } while (*(volatile ULONG *)(MMIOREG_MONO2) != (ULONG)(pat)); \
      }
#define RDCSetupCLIP1_MMIO(left, top) \
      { \
       ULONG clip1; \
       clip1 = (ULONG)(((left & MASK_CLIP) << 16) + (top & MASK_CLIP)); \
       do { \
          *(ULONG *)(MMIOREG_CLIP1) = clip1; \
       } while (*(volatile ULONG *)(MMIOREG_CLIP1) != clip1); \
      } 
#define RDCSetupCLIP2_MMIO(right, bottom) \
      { \
       ULONG clip2; \
       clip2 = (ULONG)(((right & MASK_CLIP) << 16) + (bottom & MASK_CLIP)); \
       do { \
          *(ULONG *)(MMIOREG_CLIP2) = clip2; \
       } while (*(volatile ULONG *)(MMIOREG_CLIP2) != clip2); \
      }                                                                                               
#define RDCSetupCMDReg_MMIO(reg) \
      { \
        *(ULONG *)(MMIOREG_CMD) = (ULONG)(reg);    \
      }
#define RDCSetupPatReg_MMIO(patreg, pat) \
      { \
       do { \
          *(ULONG *)(MMIOREG_PAT + patreg*4) = (ULONG)(pat); \
       } while (*(volatile ULONG *)(MMIOREG_PAT + patreg*4) != (ULONG)(pat)); \
      }      
                                
/* Line CMD */
#define RDCSetupLineXMErrTerm_MMIO(xm, err) \
      { \
        ULONG lineerr; \
        lineerr = (ULONG)((xm << 24) + (err & MASK_LINE_ERR)); \
        do { \
           *(ULONG *)(MMIOREG_LINE_Err) = lineerr; \
        } while (*(volatile ULONG *)(MMIOREG_LINE_Err) != lineerr); \
      }      
#define RDCSetupLineWidth_MMIO(width) \
      { \
        ULONG linewidth; \
        linewidth = (ULONG)((width & MASK_LINE_WIDTH) << 16); \
        do { \
          *(ULONG *)(MMIOREG_LINE_WIDTH) = linewidth; \
        } while (*(volatile ULONG *)(MMIOREG_LINE_WIDTH) != linewidth); \
      }
#define RDCSetupLineK1Term_MMIO(err) \
      { \
        do { \
          *(ULONG *)(MMIOREG_LINE_K1) = (ULONG)(err & MASK_LINE_K1); \
        } while (*(volatile ULONG *)(MMIOREG_LINE_K1) != (ULONG)(err & MASK_LINE_K1)); \
      }            
#define RDCSetupLineK2Term_MMIO(err) \
      { \
        do { \
           *(ULONG *)(MMIOREG_LINE_K2) = (ULONG)(err & MASK_LINE_K2); \
        } while (*(volatile ULONG *)(MMIOREG_LINE_K2) != (ULONG)(err & MASK_LINE_K2)); \
      }
#define RDCSetupLineStyle1_MMIO(pat) \
      { \
        do { \
           *(ULONG *)(MMIOREG_LINE_STYLE1) = (ULONG)(pat); \
        } while (*(volatile ULONG *)(MMIOREG_LINE_STYLE1) != (ULONG)(pat)); \
      } 
#define RDCSetupLineStyle2_MMIO(pat) \
      { \
        do { \
          *(ULONG *)(MMIOREG_LINE_STYLE2) = (ULONG)(pat); \
        } while (*(volatile ULONG *)(MMIOREG_LINE_STYLE2) != (ULONG)(pat)); \
      }

#define RDCSetupLineXY_MMIO(x, y) \
      { \
        ULONG linexy; \
        linexy = (ULONG)(((x & MASK_M2010LINE_X) << 16) + (y & MASK_M2010LINE_Y)); \
        do { \
           *(ULONG *)(MMIOREG_LINE_XY) = linexy; \
        } while (*(volatile ULONG *)(MMIOREG_LINE_XY) != linexy); \
      }
#define RDCSetupLineXY2_MMIO(x, y) \
      { \
        ULONG linexy; \
        linexy = (ULONG)(((x & MASK_M2010LINE_X) << 16) + (y & MASK_M2010LINE_Y)); \
        do { \
           *(ULONG *)(MMIOREG_LINE_XY2) = linexy; \
        } while (*(volatile ULONG *)(MMIOREG_LINE_XY2) != linexy); \
      }
#define RDCSetupLineNumber_MMIO(no) \
      { \
        do { \
           *(ULONG *)(MMIOREG_LINE_NUMBER) = (ULONG) no; \
        } while (*(volatile ULONG *)(MMIOREG_LINE_NUMBER) != (ULONG) no); \
      }

/* CMDQ Mode Macro */ 
#define mUpdateWritePointer *(ULONG *) (pRDC->CMDQInfo.pjWritePort) = (pRDC->CMDQInfo.ulWritePointer >>3)

/* General CMD */
#define RDCSetupSRCBase(addr, base) \
      { \
        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_SRC_BASE);     \
        addr->PKT_SC_dwData[0] = (ULONG)(base);                    \
      }
#define RDCSetupSRCPitch(addr, pitch) \
      { \
        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_SRC_PITCH);     \
        addr->PKT_SC_dwData[0] = (ULONG)(pitch << 16);                    \
      }
#define RDCSetupDSTBase(addr, base) \
      { \
        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_DST_BASE);     \
        addr->PKT_SC_dwData[0] = (ULONG)(base);                    \
      }      
#define RDCSetupDSTPitchHeight(addr, pitch, height) \
      { \
        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_DST_PITCH);     \
        addr->PKT_SC_dwData[0] = (ULONG)((pitch << 16) + ((height) & MASK_DST_HEIGHT));                    \
      }      
#define RDCSetupDSTXY(addr, x, y) \
      { \
        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_DST_XY);     \
        addr->PKT_SC_dwData[0] = (ULONG)(((x & MASK_DST_X) << 16) + (y & MASK_DST_Y));                    \
      }           
#define RDCSetupSRCXY(addr, x, y) \
      { \
        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_SRC_XY);     \
        addr->PKT_SC_dwData[0] = (ULONG)(((x & MASK_SRC_X) << 16) + (y & MASK_SRC_Y));                    \
      }             
#define RDCSetupRECTXY(addr, x, y) \
      { \
        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_RECT_XY);     \
        addr->PKT_SC_dwData[0] = (ULONG)(((x & MASK_RECT_WIDTH) << 16) + (y & MASK_RECT_WIDTH));                    \
      }  
#define RDCSetupFG(addr, color) \
      { \
        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_FG);     \
        addr->PKT_SC_dwData[0] = (ULONG)(color);                    \
      }
#define RDCSetupBG(addr, color) \
      { \
        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_BG);     \
        addr->PKT_SC_dwData[0] = (ULONG)(color);                    \
      }
#define RDCSetupMONO1(addr, pat) \
      { \
        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_MONO1);     \
        addr->PKT_SC_dwData[0] = (ULONG)(pat);                \
      }            
#define RDCSetupMONO2(addr, pat) \
      { \
        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_MONO2);     \
        addr->PKT_SC_dwData[0] = (ULONG)(pat);                \
      }     
#define RDCSetupCLIP1(addr, left, top) \
      { \
        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_CLIP1);     \
        addr->PKT_SC_dwData[0] = (ULONG)(((left & MASK_CLIP) << 16) + (top & MASK_CLIP));    \
      }            
#define RDCSetupCLIP2(addr, right, bottom) \
      { \
        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_CLIP2);     \
        addr->PKT_SC_dwData[0] = (ULONG)(((right & MASK_CLIP) << 16) + (bottom & MASK_CLIP));    \
      }                                                                                                    
#define RDCSetupCMDReg(addr, reg) \
      { \
        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_CMD);     \
        addr->PKT_SC_dwData[0] = (ULONG)(reg);                    \
      }
#define RDCSetupPatReg(addr, patreg, pat) \
      { \
        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + (CMDQREG_PAT + (patreg << 24)));     \
        addr->PKT_SC_dwData[0] = (ULONG)(pat);                \
      }    

/* Line CMD */
#define RDCSetupLineStyle1(addr, pat) \
      { \
        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_LINE_STYLE1);     \
        addr->PKT_SC_dwData[0] = (ULONG)(pat);                \
      }            
#define RDCSetupLineStyle2(addr, pat) \
      { \
        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_LINE_STYLE2);     \
        addr->PKT_SC_dwData[0] = (ULONG)(pat);                \
      }     

#define RDCSetupLineXY(addr, x, y) \
      { \
        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_LINE_XY);     \
        addr->PKT_SC_dwData[0] = (ULONG)(((x & MASK_M2010LINE_X) << 16) + (y & MASK_M2010LINE_Y));                    \
      }
#define RDCSetupLineXY2(addr, x, y) \
      { \
        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_LINE_XY2);     \
        addr->PKT_SC_dwData[0] = (ULONG)(((x & MASK_M2010LINE_X) << 16) + (y & MASK_M2010LINE_Y));                    \
      }
#define RDCSetupLineNumber(addr, no) \
      { \
        addr->PKT_SC_dwHeader  = (ULONG)(PKT_SINGLE_CMD_HEADER + CMDQREG_LINE_NUMBER);     \
        addr->PKT_SC_dwData[0] = (ULONG)(no);                    \
      }