aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/emgd/include/igd_mode.h
blob: 5bcac3e0b5de64fb21666515d0f2e67dba8c1a31 (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
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
/* -*- pse-c -*-
 *-----------------------------------------------------------------------------
 * Filename: igd_mode.h
 * $Revision: 1.7 $
 *-----------------------------------------------------------------------------
 * Copyright © 2002-2010, Intel Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope 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, write to the Free Software Foundation, Inc.,
 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
 *
 *-----------------------------------------------------------------------------
 * Description:
 *  
 *-----------------------------------------------------------------------------
 */

#ifndef _IGD_MODE_H_
#define _IGD_MODE_H_

/*!
 * @defgroup pixel_formats Pixel Format Definitions
 * @ingroup display_group
 *
 * Pixel Format Definitions used in FB info data structure and
 * throughout IGD API functions. Pixel formats are comprised
 * of a Depth and Colorspace component combined (OR'd) with
 * a unique number. Pixel formats and their components are
 * defined with the following defines.
 *
 * @{
 */

/*!
 * This is a just to make use of the Pixel format explicit. This could
 * be replaced with an ENUM in the future.
 */
typedef unsigned long igd_pf_t;

/*!
 * @name Masks
 * Masks that may be used to seperate portions of the pixel format
 * definitions.
 *
 * @note Pixel Formats are maintained such that
 * (pixel_format & IGD_PF_FMT_MASK) >> IGD_PF_FMT_SHIFT
 * will always provide a unique index that can be used in a
 * lookup table.
 * @{
 */
#define IGD_PF_MASK                             0x0000FFFF
#define IGD_PF_TYPE_MASK                        0x0000FF00
#define IGD_PF_DEPTH_MASK                       0x000000FF
#define IGD_PF_FMT_MASK                         0x00FF0000
#define IGD_PF_FMT_SHIFT                        16
/*! @} */

/*!
 * @name Depths
 * Pixel Format depths in Bits per pixel.
 * @{
 */
#define PF_DEPTH_1                              0x00000001
#define PF_DEPTH_2                              0x00000002
#define PF_DEPTH_4                              0x00000004
#define PF_DEPTH_8                              0x00000008
#define PF_DEPTH_12                             0x0000000c
#define PF_DEPTH_16                             0x00000010
#define PF_DEPTH_24                             0x00000018
#define PF_DEPTH_32                             0x00000020
#define PF_DEPTH_64                             0x00000040
/*! @} */

/* Unknown Pixel Format */
#define IGD_PF_UNKNOWN							0x00000000

/*!
 * @name Colorspace
 * Colorspace components of the overall pixel format definition.
 * Several types may be OR'd together.
 * To check for equivalent types use  IGD_PF_TYPE(pf) == TYPE
 *
 * @{
 */
#define PF_TYPE_ALPHA                           0x00000100
#define PF_TYPE_RGB                             0x00000200
#define PF_TYPE_YUV                             0x00000400
#define PF_TYPE_PLANAR                          0x00000800
#define PF_TYPE_OTHER                           0x00001000
#define PF_TYPE_RGB_XOR                         0x00002000 /* Cursor */
#define PF_TYPE_COMP                            0x00004000 /* Compressed */

#define PF_TYPE_ARGB (PF_TYPE_ALPHA | PF_TYPE_RGB)
#define PF_TYPE_YUV_PACKED (PF_TYPE_YUV)
#define PF_TYPE_YUV_PLANAR (PF_TYPE_YUV | PF_TYPE_PLANAR)

/*! @} */

/*!
 * @name 8 Bit RGB Pixel Formats
 * @note Depth is bits per index (8)
 * @{
*/
#define IGD_PF_ARGB8_INDEXED     (PF_DEPTH_8  | PF_TYPE_ARGB | 0x00010000)
#define IGD_PF_ARGB4_INDEXED     (PF_DEPTH_4  | PF_TYPE_ARGB | 0x00020000)
/*! @} */

/*!
 * @name 16 Bit RGB Pixel Formats
 * @note Depth is bits per pixel (16)
 * @{
 */
#define IGD_PF_ARGB16_4444       (PF_DEPTH_16 | PF_TYPE_ARGB | 0x00030000)
#define IGD_PF_ARGB16_1555       (PF_DEPTH_16 | PF_TYPE_ARGB | 0x00040000)
#define IGD_PF_RGB16_565         (PF_DEPTH_16 | PF_TYPE_RGB  | 0x00050000)
#define IGD_PF_xRGB16_555        (PF_DEPTH_16 | PF_TYPE_RGB  | 0x00060000)
/*! @} */

/*!
 * @name 24 Bit RGB Pixel Formats
 * @note Depth is bits per pixel (24)
 * @{
 */
#define IGD_PF_RGB24             (PF_DEPTH_24 | PF_TYPE_RGB  | 0x00070000)
/*! @} */

/*!
 * @name 32 Bit RGB Pixel Formats
 * @note Depth is bits per pixel including unused bits (32).
 * @{
 */
#define IGD_PF_xRGB32_8888       (PF_DEPTH_32 | PF_TYPE_RGB  | 0x00080000)
#define IGD_PF_xRGB32            IGD_PF_xRGB32_8888
#define IGD_PF_ARGB32            (PF_DEPTH_32 | PF_TYPE_ARGB | 0x00090000)
#define IGD_PF_ARGB32_8888       IGD_PF_ARGB32
#define IGD_PF_xBGR32_8888       (PF_DEPTH_32 | PF_TYPE_RGB  | 0x000a0000)
#define IGD_PF_xBGR32            IGD_PF_xBGR32_8888
#define IGD_PF_ABGR32            (PF_DEPTH_32 | PF_TYPE_ARGB | 0x000b0000)
#define IGD_PF_ABGR32_8888       IGD_PF_ABGR32
/*! @} */

/*!
 * @name YUV Packed Pixel Formats
 * @note Depth is Effective bits per pixel
 *
 * @{
 */
#define IGD_PF_YUV422_PACKED_YUY2 (PF_DEPTH_16| PF_TYPE_YUV_PACKED| 0x000c0000)
#define IGD_PF_YUV422_PACKED_YVYU (PF_DEPTH_16| PF_TYPE_YUV_PACKED| 0x000d0000)
#define IGD_PF_YUV422_PACKED_UYVY (PF_DEPTH_16| PF_TYPE_YUV_PACKED| 0x000e0000)
#define IGD_PF_YUV422_PACKED_VYUY (PF_DEPTH_16| PF_TYPE_YUV_PACKED| 0x000f0000)
#define IGD_PF_YUV411_PACKED_Y41P (PF_DEPTH_12| PF_TYPE_YUV_PACKED| 0x00100000)
/*! @} */

/*!
 * @name YUV Planar Pixel Formats
 * @note Depth is Y plane bits per pixel
 * @{
 */
#define IGD_PF_YUV420_PLANAR_I420 (PF_DEPTH_8| PF_TYPE_YUV_PLANAR| 0x00110000)
#define IGD_PF_YUV420_PLANAR_IYUV IGD_PF_YUV420_PLANAR_I420
#define IGD_PF_YUV420_PLANAR_YV12 (PF_DEPTH_8| PF_TYPE_YUV_PLANAR| 0x00120000)
#define IGD_PF_YUV410_PLANAR_YVU9 (PF_DEPTH_8| PF_TYPE_YUV_PLANAR| 0x00130000)
#define IGD_PF_YUV420_PLANAR_NV12 (PF_DEPTH_8| PF_TYPE_YUV_PLANAR| 0x00140000)
/*! @} */

/*!
 * @name Cursor Pixel Formats
 * @{
 *
 * RGB_XOR_2: Palette = {Color 0, Color 1, Transparent, Invert Dest }
 * RGB_T_2: Palette = {Color 0, Color 1, Transparent, Color 2 }
 * RGB_2: Palette = {Color 0, Color 1, Color 2, Color 3 }
 */
#define IGD_PF_RGB_XOR_2      (PF_DEPTH_2  | PF_TYPE_RGB_XOR | 0x00150000)
#define IGD_PF_RGB_T_2        (PF_DEPTH_2  | PF_TYPE_RGB     | 0x00160000)
#define IGD_PF_RGB_2          (PF_DEPTH_2  | PF_TYPE_RGB     | 0x00170000)
/*! @} */

/*!
 * @name Bump Pixel Formats
 * @note Depth is bits per pixel
 * @{
 */
#define IGD_PF_DVDU_88             (PF_DEPTH_16 | PF_TYPE_OTHER | 0x00180000)
#define IGD_PF_LDVDU_655           (PF_DEPTH_16 | PF_TYPE_OTHER | 0x00190000)
#define IGD_PF_xLDVDU_8888         (PF_DEPTH_32 | PF_TYPE_OTHER | 0x001a0000)
/*! @} */

/*!
 * @name Compressed Pixel Formats
 * @note Depth is effective bits per pixel
 * @{
 */
#define IGD_PF_DXT1               (PF_DEPTH_4 | PF_TYPE_COMP | 0x001b0000)
#define IGD_PF_DXT2               (PF_DEPTH_8 | PF_TYPE_COMP | 0x001c0000)
#define IGD_PF_DXT3               (PF_DEPTH_8 | PF_TYPE_COMP | 0x001d0000)
#define IGD_PF_DXT4               (PF_DEPTH_8 | PF_TYPE_COMP | 0x001e0000)
#define IGD_PF_DXT5               (PF_DEPTH_8 | PF_TYPE_COMP | 0x001f0000)
/*! @} */

/*!
 * @name Depth Buffer Formats
 * @note Depth is bits per pixel
 * @{
 */
#define IGD_PF_Z16               (PF_DEPTH_16 | PF_TYPE_OTHER | 0x00200000)
#define IGD_PF_Z24               (PF_DEPTH_32 | PF_TYPE_OTHER | 0x00210000)
#define IGD_PF_S8Z24             (PF_DEPTH_32 | PF_TYPE_OTHER | 0x00220000)
/*! @} */

/*!
 * @name Other Pixel Formats
 *
 * - I8 8bit value replicated to all color channels.
 * - L8 8bit value replicated to RGB color channels, Alpha is 1.0.
 * - A8 8bit Alpha with RGB = 0.
 * - AL88 8bit Alpha, 8bit color replicated to RGB channels.
 * - AI44 4bit alpha 4bit palette color.
 * - IA44 4bit alpha 4bit palette color.
 * @{
 */
#define IGD_PF_I8               (PF_DEPTH_8 | PF_TYPE_OTHER | 0x00230000)
#define IGD_PF_L8               (PF_DEPTH_8 | PF_TYPE_OTHER | 0x00240000)
#define IGD_PF_A8               (PF_DEPTH_8 | PF_TYPE_ALPHA | 0x00250000)
#define IGD_PF_AL88             (PF_DEPTH_16 | PF_TYPE_ALPHA | PF_TYPE_OTHER | 0x00260000)
#define IGD_PF_AI44             (PF_DEPTH_8 | PF_TYPE_OTHER | 0x00270000)
#define IGD_PF_IA44             (PF_DEPTH_8 | PF_TYPE_OTHER | 0x00280000)

#define IGD_PF_L16              (PF_DEPTH_16 | PF_TYPE_OTHER | 0x00290000)
#define IGD_PF_ARGB32_2101010   (PF_DEPTH_32 | PF_TYPE_ARGB  | 0x002a0000)
#define IGD_PF_AWVU32_2101010	(PF_DEPTH_32 | PF_TYPE_OTHER | 0x002b0000)
#define IGD_PF_QWVU32_8888		(PF_DEPTH_32 | PF_TYPE_OTHER | 0x002c0000)
#define IGD_PF_GR32_1616        (PF_DEPTH_32 | PF_TYPE_OTHER | 0x002d0000)
#define IGD_PF_VU32_1616        (PF_DEPTH_32 | PF_TYPE_OTHER | 0x002e0000)

/*!
 * @name Floating-Point formats
 *
 * - R16F Floating-point format 16-bits for the Red Channel
 * - GR32_1616F 32-bit float format using 16 bits for red and green channel
 * - R32F IEEE Floating-Point s23e8 32-bits for the Red Channel
 * - ABGR32_16161616F - This is a 64-bit FP format.
 * - Z32F 32-bit float 3D depth buffer format.
 * @{
 */
#define IGD_PF_R16F                 (PF_DEPTH_16 | PF_TYPE_OTHER | 0x002f0000)
#define IGD_PF_GR32_1616F           (PF_DEPTH_32 | PF_TYPE_OTHER | 0x00300000)
#define IGD_PF_R32F                 (PF_DEPTH_32 | PF_TYPE_OTHER | 0x00310000)
#define IGD_PF_ABGR64_16161616F     (PF_DEPTH_64 | PF_TYPE_ARGB  | 0x00320000)
#define IGD_PF_Z32F                 (PF_DEPTH_32 | PF_TYPE_OTHER | 0x00330000)
/*! @} */

/*!
 * @name IGD_PF_NEXT array length helper
 *
 * This helper should always be set to the next available PF id. In this
 * manner any array that uses the id as an index can be defined as
 * unsigned long lookup_table[IGD_PF_NEXT] = {...}; and will then generate
 * compile warnings if the pixel format list length changes.
 */
#define IGD_PF_NEXT 0x34
/*!
 * @name Helper Macros
 * @{
 */

/*! Gets bits per pixel from pixel format */
#define IGD_PF_BPP(pf)   ((pf) & IGD_PF_DEPTH_MASK)
/*! Gets bits per pixel from pixel format */
#define IGD_PF_DEPTH(pf) IGD_PF_BPP(pf)
/*! Gets Bytes per pixel from pixel format */
#define IGD_PF_BYPP(pf)  ((IGD_PF_DEPTH(pf)+0x7)>>3)
/*! Gets Bytes required for line of pixels */
#define IGD_PF_PIXEL_BYTES(pf, np)  (((IGD_PF_BPP(pf)*np) +0x7)>>3)
/*! Gets numeric pf */
#define IGD_PF_NUM(pf) ((pf>>16) & 0xff)
/*! Gets pf type */
#define IGD_PF_TYPE(pf)  (pf & IGD_PF_TYPE_MASK)

/*! @} */
/*! @} */


/*
 * NOTE: When Adding pixel formats you must add correct definitions to
 * any pixel format lookup tables. See igd_2d.c
 */


/*!
 * @addtogroup display_group
 *
 * <B>Relavent Dispatch Functions</B>
 * - _igd_dispatch::query_dc()
 * - _igd_dispatch::query_mode_list()
 * - _igd_dispatch::free_mode_list()
 * - _igd_dispatch::alter_displays()
 *
 * @{
 */

/*!
 * The opaque display handle, returned from igd_alloc_display().
 * A display handle is needed for each physical display device.
 */
typedef void* igd_display_h;

/*!
 * The maximum number of displays available in the display configurations
 * below.
 */
#define IGD_MAX_DISPLAYS 2

/*!
 * @brief An opaque driver handle.
 *
 * This is an opaque driver handle. It is returned during driver init
 * and remains usable for the life of the driver.
 */
typedef void* igd_driver_h;

/*!
 * @name Display Configuration Definition
 * @anchor dc_defines
 *
 * The display configuration (dc) is a unique 32bit identifier that fully
 * describes all displays in use and how they are attached to planes and
 * pipes to form Single, Clone, Twin and Extended display setups.
 *
 * The DC is treated as 8 nibbles of information (nibble = 4 bits). Each
 * nibble position in the 32bit DC corresponds to a specific role as
 * follows:
 *
<PRE>
    0x12345678
      ||||||||-- Legacy Display Configuration (Single, Twin, Clone, Ext)
      |||||||--- Port Number for Primary Pipe Master
      ||||||---- Port Number for Primary Pipe Twin 1
      |||||----- Port Number for Primary Pipe Twin 2
      ||||------ Port Number for Primary Pipe Twin 3
      |||------- Port Number for Secondary Pipe Master
      ||-------- Port Number for Secondary Pipe Twin 1
      |--------- Port Number for Secondary Pipe Twin 2
</PRE>
 *
 * The legacy Display Configuration determines if the display is in Single
 * Twin, Clone or extended mode using the following defines. When a complex
 * (>2 displays) setup is defined, the legacy configuration will describe
 * only a portion of the complete system.
 *
 * - IGD_DISPLAY_CONFIG_SINGLE: A single primary display only.
 * - IGD_DISPLAY_CONFIG_CLONE: Two (or more) displays making use of two
 *    display pipes. In this configuration two sets of display timings are
 *    used with a single source data plane.
 * - IGD_DISPLAY_CONFIG_TWIN: Two (or more) displays using a single display
 *    pipe. In this configuration a single set of display timings are
 *    used for multiple displays.
 * - IGD_DISPLAY_CONFIG_EXTENDED: Two (or more) displays making use of two
 *    display pipes and two display planes. In this configuration two sets
 *    of display timings are used and two source data planes.
 *
 * @{
 */
#define IGD_DISPLAY_CONFIG_SINGLE   0x1
#define IGD_DISPLAY_CONFIG_CLONE    0x2
#define IGD_DISPLAY_CONFIG_TWIN     0x4
#define IGD_DISPLAY_CONFIG_EXTENDED 0x8
#define IGD_DISPLAY_CONFIG_MASK     0xf
/*! @} */

/*!
 * @name IGD_DC_PORT_NUMBER
 *
 * Given a display configuration value and an index, return the port
 * number at that position.
 */
#define IGD_DC_PORT_NUMBER(dc, i) (unsigned short) ((dc >> (i * 4)) & 0x0f)
#define IGD_DC_PRIMARY(dc) (IGD_DC_PORT_NUMBER(dc,1))
#define IGD_DC_SECONDARY(dc) (IGD_DC_PORT_NUMBER(dc,5))


/*!
 * @name IGD_DC_SINGLE
 * For a given dc, return true if it is in single display mode
 */
#define IGD_DC_SINGLE(dc)   ((dc & 0xf) == IGD_DISPLAY_CONFIG_SINGLE)
/*!
 * @name IGD_DC_TWIN
 * For a given dc, return true if it is in twin display mode
 */
#define IGD_DC_TWIN(dc)     ((dc & 0xf) == IGD_DISPLAY_CONFIG_TWIN)
/*!
 * @name IGD_DC_CLONE
 * For a given dc, return true if it is in clone display mode
 */
#define IGD_DC_CLONE(dc)    ((dc & 0xf) == IGD_DISPLAY_CONFIG_CLONE)
/*!
 * @name IGD_DC_EXTENDED
 * For a given dc, return true if it is in extended display mode
 */
#define IGD_DC_EXTENDED(dc) ((dc & 0xf) == IGD_DISPLAY_CONFIG_EXTENDED)

/*!
 * @name Query DC Flags
 * @anchor query_dc_flags
 *
 *   - IGD_QUERY_DC_ALL: Query All usable DCs.
 *   - IGD_QUERY_DC_PREFERRED: Returns only preferred dc's from the list
 *      of all usable dc's. Twin mode dc's are eliminated if an equivalent
 *      Clone dc is available. Only the most useful/flexible combination
 *      of 3 displays is returned rather than all combinations of the 3
 *      displays.
 *   - IGD_QUERY_DC_INIT: Returns a pointer to the initial dc to be used.
 *   - IGD_QUERY_DC_EXISTING: Returns a pointer to the initial dc that
 *      most closely matches the DC in use by the hardware. This can be
 *      used by an IAL to "discover" what the vBIOS has arranged and use
 *      that configuration. (NOT IMPLEMENTED)
 * @{
 */
#define IGD_QUERY_DC_ALL        0x0
#define IGD_QUERY_DC_PREFERRED  0x1
#define IGD_QUERY_DC_INIT       0x2
#define IGD_QUERY_DC_EXISTING   0x3
/*! @} */


/*!
 * @name DC index Flags
 * @anchor dc_index_flags
 *
 *  - IGD_DC_IDX_PRIMARY_MASTER: index to the primary display pipe master
 *  - IGD_DC_IDX_PRIMARY_TWIN1: index to the first primary display pipe's twin
 *  - IGD_DC_IDX_PRIMARY_TWIN2: index to the second primary display pipe's twin
 *  - IGD_DC_IDX_PRIMARY_TWIN3: index to the third primary display pipe's twin
 *  - IGD_DC_IDX_SECONDARY_MASTER: index to the secondary display pipe master
 *  - IGD_DC_IDX_SECONDARY_TWIN1: index to the first secondary display pipe's
 *     twin
 *  - IGD_DC_IDX_SECONDARY_TWIN2: index to the second secondary display pipe's
 *     twin
 * @{
 */
#define IGD_DC_IDX_PRIMARY_MASTER        0x1
#define IGD_DC_IDX_PRIMARY_TWIN1         0x2
#define IGD_DC_IDX_PRIMARY_TWIN2         0x3
#define IGD_DC_IDX_PRIMARY_TWIN3         0x4
#define IGD_DC_IDX_SECONDARY_MASTER      0x5
#define IGD_DC_IDX_SECONDARY_TWIN1       0x6
#define IGD_DC_IDX_SECONDARY_TWIN2       0x7
/*! @} */


/*!
 * @name Framebuffer Info Flags
 * @anchor fb_info_flags
 *
 * These bits may be set in the flags member of the _igd_framebuffer_info
 * data structure to alter the HALs behavior when calling
 * dispatch::alter_displays() All other flag bits must be 0 when calling.
 *
 *  - IGD_VBIOS_FB: The framebuffer info is not populated because the mode
 *     is being set with a VGA/VESA mode number. The HAL should instead
 *     return the framebuffer information to the caller when the mode
 *     has been set.
 *  - IGD_ENABLE_DISPLAY_GAMMA: The framebuffer data will be color corrected
 *     by using the 3*256 entry palette lookup table. Red, Green, and Blue
 *     8 bit color values will be looked up and converted to another value
 *     during display. The pixels are not modified. The caller must also
 *     set the palette using _igd_dispatch::set_palette_entries()
 *  - IGD_REUSE_FB: The HAL will use the incoming framebuffer info as the
 *     framebuffer. The HAL will allocate a framebuffer only if
 *     frambuffer_info.allocated == 0 and this is the first use of the
 *     display. If the offset has been changed, the caller is now responsible
 *     for freeing the previous framebuffer surface, and the HAL now fully
 *     owns the incoming surface, freeing it on shutdown etc.
 *  - IGD_MIN_PITCH: The allocation will use the input value
 *      of pitch as the minimum acceptable pitch. This allows a caller
 *      to allocate a surface with "extra" room between the width and
 *      pitch so that the width may later be expanded (use with caution).
 *
 * Additionally all surface flags will be populated by the HAL and
 * returned.
 * See: @ref surface_info_flags
 *
 * @{
 */
#define IGD_VBIOS_FB                            0x80000000
#define IGD_ENABLE_DISPLAY_GAMMA				0x40000000
#define IGD_REUSE_FB                            0x20000000
#define IGD_MIN_PITCH                           0x10000000
#define IGD_FB_FLAGS_MASK                       0xf0000000
/* @} */


/*!
 * @brief Framebuffer related mode setting data.
 *  See _igd_dispatch::alter_displays()
 *
 * Data structure that contains details relavent to the framebuffer
 * configuration. Used with igd_alter_display() to alter the framebuffer
 * size and format.
 *
 * The framebuffer may be larger or smaller than the display timings. When
 * larger the output will be cropped and can be used in a panning
 * configuration. When smaller the output will be centered.
 *
 */
typedef struct _igd_framebuffer_info {
	unsigned int width;           /*!< @brief width of fb */
	unsigned int height;          /*!< @brief height of fb */
	/*!
	 * @brief Output pitch in bytes of the fb
	 *
	 * The pitch is the number of bytes from the first pixel of a line to
	 * the first pixel of the next line. This can, and usually will, be
	 * larger than width * depth for alignment purposes.
	 */
	unsigned int screen_pitch;
	unsigned long fb_base_offset; /*!< @brief memory location of the fb */
	/*!< @brief Memory location of the currently visible buffer
	 *
	 * This is what is being displayed on the port, which may be another buffer
	 * (e.g. a PVR services swap-chain buffer) and not the frame buffer.
	 */
	unsigned long visible_offset;
	/*!
	 * @brief pixel format of the fb. See @ref pixel_formats
	 *
	 * This member is an input to the _igd_dispatch::alter_displays()
	 * function and must therefore be set to a pixel format that the
	 * hardware is capable of displaying as a framebuffer. The list
	 * of framebuffer pixel formats that are available can be queried
	 * by calling igd_dispatch::get_pixelformats()
	 */
	unsigned long pixel_format;
	unsigned long flags;          /*!< @brief See: @ref fb_info_flags */
	unsigned int allocated;       /*!< @brief 1 when allocated, 0 otherwise */
} igd_framebuffer_info_t, *pigd_framebuffer_info_t;


/*!
 * @name Display Info Flags
 *
 * Flags used with Display Info data structure to control boolean information.
 *
 * @note These flags are identical to the flags used with the port driver
 *  SDK. If any of these flags change, the corresponding flag in pd.h must
 *  also change.
 *
 * @{
 */

/* Enable/Disable Display  */
#define IGD_DISPLAY_DISABLE       0x00000000
#define IGD_DISPLAY_ENABLE        0x00000001

#define IGD_SCAN_MASK             0x80000000
#define IGD_SCAN_PROGRESSIVE      0x00000000
#define IGD_SCAN_INTERLACE        0x80000000

#define IGD_PIX_LINE_DOUBLE_MASK  0x60000000
#define IGD_DOUBLE_LINE_AND_PIXEL 0x60000000
#define IGD_LINE_DOUBLE           0x40000000
#define IGD_PIXEL_DOUBLE          0x20000000
#define IGD_MODE_TEXT             0x10000000

#define IGD_VSYNC_HIGH            0x08000000
#define IGD_HSYNC_HIGH            0x04000000
#define IGD_BLANK_LOW             0x02000000
#define IGD_MODE_VESA             0x01000000 /* VGA/VESA mode number is valid*/

#define IGD_MODE_STALL            0x00800000  /* Flag to enable stall signal */
#define IGD_MODE_SCALE            0x00400000  /* Request NATIVE pipe timings */

#define IGD_ASPECT_16_9           0x00200000  /* 16:9 aspect ratio */

#define IGD_MODE_DTD              0x00080000   /* Read from EDID */
#define IGD_MODE_DTD_USER         0x00040000   /* User defined timing */
#define IGD_MODE_DTD_FP_NATIVE    0x00020000   /* Native fp timing */
#define IGD_MODE_SUPPORTED        0x00010000

#define IGD_MODE_FACTORY          0x00008000   /* Factory supported mode */
#define IGD_MODE_RB               0x00004000   /* Reduced blanking mode */

/*
 * Port type definitions to be used in display_info flags.
 * Also used in port_type field of internal port data structure.
 */
#define IGD_PORT_MASK             0x000FF000
#define IGD_PORT_ANY              0x000FF000
#define IGD_PORT_ANALOG           0x00001000
#define IGD_PORT_DIGITAL          0x00002000
#define IGD_PORT_SDVO             IGD_PORT_DIGITAL
#define IGD_PORT_LVDS             0x00004000
#define IGD_PORT_RGBA             0x00008000 /* Enhanced DVO (Sunizona) */
#define IGD_PORT_TV               0x00010000 /* Integrated TV (Alviso)  */


/* Atom E6xx requires LPC device, define a port type to differentiate
 * with other devices such as 0:2:0, 0:3:0 */
#define IGD_PORT_LPC              0x80000000   /* LPC device 0:31:0 */

/*
 * Standard port definitions
 */
#define IGD_PORT_TYPE_TV          0x1
#define IGD_PORT_TYPE_SDVOB       0x2
#define IGD_PORT_TYPE_SDVOC       0x3
#define IGD_PORT_TYPE_LVDS        0x4
#define IGD_PORT_TYPE_ANALOG      0x5

/*! Max ports
 *  This is the maximum number of ports currently defined to encompass all
 *  hardware configurations. This should always match the largest defined
 *  port number in the port tables. Currently the largest port number is 5
 *  for the analog port.  If a larger port number is defined, then this
 *  number must be increased.
 */
#define IGD_MAX_PORTS             5


/*! @} */

/*!
 * @brief Display timing information for use with
 *   _igd_dispatch::alter_displays()
 */
typedef struct _igd_display_info {
	unsigned short width;
	unsigned short height;
	unsigned short refresh;
	unsigned long dclk;              /* in KHz */
	unsigned short htotal;
	unsigned short hblank_start;
	unsigned short hblank_end;
	unsigned short hsync_start;
	unsigned short hsync_end;
	unsigned short vtotal;
	unsigned short vblank_start;
	unsigned short vblank_end;
	unsigned short vsync_start;
	unsigned short vsync_end;
	short mode_number;
	unsigned long flags;
	unsigned short x_offset;
	unsigned short y_offset;
	/* unsigned short port_number; */
	/* void *pd_private_ptr; */  /* Pointer for use by the PD for any purpose. */
	void *private_ptr;  /* INTERNAL pointer for use by main driver only */
	unsigned short reserved_dd;     /* Reserved for device dependant layer */
	unsigned short reserved_dd_ext; /* Reserved for device dependant layer */
} igd_display_info_t, *pigd_display_info_t;


/*!
 * @name Query Modes Flags (deprecated)
 * @deprecated To be removed in IEGD 5.1
 *
 * Flags for use in igd_query_display function call
 *
 * @{
 */
#define IGD_QUERY_ALL_MODES   0x01
#define IGD_QUERY_PORT_MODES  0x00
/*! @} */


/*!
 * @name Query Mode List Flags
 * @anchor query_mode_list_flags
 *
 * Flags for use with _igd_dispatch::query_mode_list()
 *  - IGD_QUERY_PRIMARY_MODES: Query mode list for the primary pipe.
 *  - IGD_QUERY_SECONDARY_MODES: Query modes list for the secondary pipe.
 *  - IGD_QUERY_LIVE_MODES: Query the live modes instead of filtering
 *      and allocing a new list. This may be ORed with other bits.
 * @{
 */
#define IGD_QUERY_PRIMARY_MODES   0x0
#define IGD_QUERY_SECONDARY_MODES 0x1
#define IGD_QUERY_LIVE_MODES      0x2
/*! @} */


/*!
 * @name timing table end of list marker
 *
 * This value is used to mark the end of a timing list (igd_display_info_t).
 * It is stored in the width field.  This must match the value for
 * PD_TIMING_LIST_END in src/include/pd.h
 *
 * @{
 */
#define IGD_TIMING_TABLE_END     0xffff
/*! @} */

/*!
 * @name Alter Displays Flags
 * @anchor alter_displays_flags
 *
 * These flags are passed to _igd_dispatch::alter_displays() and are
 * defined as follows:
 * - IGD_TEST When set, this flag indicates that the mode should only be
 *    tested. The hardware will not be modified.
 * - IGD_FORCE_ALTER When set the hardware will be modified even if the
 *    mode is the same as the current mode.
 * - IGD_CLEAR_FB Clear the framebuffer to black after the mode set.
 *
 * These flags control which ring buffers are allocated for the display.
 * These ring buffers are used with all rendering functions and designate
 * the target for the rendering commands.
 *
 * - IGD_ALLOC_PRIORITY_NORMAL Command slot used for normal commands
 * - IGD_ALLOC_PRIORITY_INTERRUPT Command slot with highest priority, often
 *    used to send commands during interrupt time. This command slot is
 *    not fully functional.
 * - IGD_ALLOC_PRIORITY_POWER In theory this command slot could send power
 *    events with a higher priority than a regular command slot. In
 *    practice it is unused.
 * - IGD_ALLOC_PRIORITY_BIN Binner ring buffer. This command slot requires
 *    knowledge of how the hardware binner works.
 *
 * @bug The Priority Flags overlap with other alter_displays flags and
 *  need to be relocated for IEGD 5.1
 *
 * @{
 */
#define IGD_TEST                     0x08000000
#define IGD_FORCE_ALTER              0x04000000
#define IGD_CLEAR_FB                 0x02000000

#define IGD_ALLOC_PRIORITY_NORMAL    0x10000000
#define IGD_ALLOC_PRIORITY_INTERRUPT 0x20000000
#define IGD_ALLOC_PRIORITY_POWER     0x40000000
#define IGD_ALLOC_PRIORITY_BIN       0x80000000
/*! @} */

/*!
 * Display handle list and Display info list should be terminated with
 * this tag. List may contain nulls, they will be skipped.
 *
 * @note This value is -1 so it will work the same on 32 and 64 bit platforms
 */
#define IGD_LIST_END -1




/*!
 * @name Cursor Info Flags
 * @anchor cursor_info_flags
 *
 * Flags for use in the Cursor Info Structure
 *
 * @{
 */
#define IGD_CURSOR_ON              0x00000001
#define IGD_CURSOR_OFF             0x00000000
#define IGD_CURSOR_LOAD_ARGB_IMAGE 0x00000010
#define IGD_CURSOR_LOAD_XOR_IMAGE  0x00000020

#define IGD_CURSOR_GAMMA           0x00000002
#define IGD_CURSOR_LOCAL           0x00000004  /* Local Memory */
#define IGD_CLONE_CURSOR           0x00000001
/*! @} */

/*!
 * @brief Cursor Plane information
 *
 * This data structure is used as input and output to the
 * _igd_dispatch::alter_cursor() dispatch function.
 */
typedef struct _igd_cursor_info {
	unsigned long width;
	unsigned long height;
	unsigned long pixel_format;
	/*
	 * Use the XOR offset for all 2 bit formats, and the ARGB offset for
	 * 32bit formats. If either offset is 0 it should be assumed that the
	 * HAL cannot support it.
	 */
	unsigned long xor_offset;
	unsigned long xor_pitch;
	unsigned long argb_offset;
	unsigned long argb_pitch;
	long x_offset;
	long y_offset;
	long hot_x;
	long hot_y;
	unsigned long palette[4];
	unsigned long flags;
	unsigned long rotation;
	unsigned long render_scale_x;
	unsigned long render_scale_y;
	unsigned short off_screen;
} igd_cursor_info_t;

/*!
 * @name Get Scanline Defines
 * @anchor get_scanline_defs
 *
 * These defines are returned from the _igd_dispatch::get_scanline()
 * dispatch function in the place of scanline number when no number exists.
 *
 * @{
 */
#define IGD_IN_VBLANK -1
/*! @} */




/*!
 * @name Acess i2c Flags
 * @anchor access_i2c_flags
 *
 * These flags are used to control the flow of data in the
 * igd_dispatch::access_i2c() dispatch function.
 *
 * @{
 */
#define IGD_I2C_READ   0x00000001
#define IGD_I2C_WRITE  0x00000002
/*! @} */

/*!
 * @brief I2C data packet for use with _igd_dispatch::access_i2c()
 */
typedef struct _igd_i2c_reg {
	/*! @brief Serial bus id [0..6] for alm core, and 0 for whitney core */
	unsigned char bus_id;
	/*! @brief Data address byte of the device */
	unsigned char dab;
	/*! @brief Device register */
	unsigned char reg;
	/*! @brief Buffer for register values */
	unsigned char *buffer;
	/*! @brief number of bytes to read or write */
	unsigned char num_bytes;
	/*! @brief i2c bus speed in KHz */
	unsigned long i2c_speed;
} igd_i2c_reg_t;



typedef struct _igd_port_info {
	char pd_name[64];
	unsigned long driver_version;	/* Formatted as pd_version_t */
	unsigned long port_num;			/* Port Number */
	unsigned long display_type;		/* Type of display */
	int connected;					/* 1 - Display connected, 0 - Otherwise */
	char port_name[8];             /* Default port name (DVOA, sDVO-A, etc.) */
	unsigned long flags;           /* Attribute flags, currently used for interlace */ 	
} igd_port_info_t;



/*!
 * @name Alloc Display Flags (deprecated)
 *
 * Flags for use with the igd_alloc_display function call.
 * - IGD_NEW_ALL Default, request for new plane, pipe, port
 * - IGD_NEW_PIPE Request for an additional pipe & port, using the same plane
 *    from previous allocation
 * - IGD_NEW_PORT Request for an addition port, using the same pipe and plane
 *    from previous allocation
 *
 * @{
 */
#define IGD_NEW_MASK           0x00700000
#define IGD_NEW_ALL            0x00400000
#define IGD_NEW_PIPE           0x00200000
#define IGD_NEW_PORT           0x00100000
/*! @} */

typedef int (*_igd_query_modes_fn_t)(igd_display_h display_handle,
	igd_display_info_t **mode_list);
/*! @} */

/*----------------------------------------------------------------------------
 * File Revision History
 * $Id: igd_mode.h,v 1.7 2010/09/20 17:26:49 astead Exp $
 * $Source: /nfs/fm/proj/eia/cvsroot/koheo/linux/egd_drm/include/igd_mode.h,v $
 *----------------------------------------------------------------------------
 */

#endif /* _IGD_MODE_H_ */