~gma500/+junk/emgd152-natty

« back to all changes in this revision

Viewing changes to emgd-dkms-1.5.15.3082/emgd/include/pd.h

  • Committer: Luca Forina
  • Date: 2011-02-06 15:11:54 UTC
  • Revision ID: luca.forina@gmail.com-20110206151154-9dzn5ugxjub9qenb
Upload Emgd 1.5.2 for Natty (override Maverick)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- pse-c -*-
 
2
 *-----------------------------------------------------------------------------
 
3
 * Filename: pd.h
 
4
 * $Revision: 1.7 $
 
5
 *-----------------------------------------------------------------------------
 
6
 * Copyright © 2002-2010, Intel Corporation.
 
7
 *
 
8
 * This program is free software; you can redistribute it and/or modify it
 
9
 * under the terms and conditions of the GNU General Public License,
 
10
 * version 2, as published by the Free Software Foundation.
 
11
 *
 
12
 * This program is distributed in the hope it will be useful, but WITHOUT
 
13
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
14
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 
15
 * more details.
 
16
 *
 
17
 * You should have received a copy of the GNU General Public License along with
 
18
 * this program; if not, write to the Free Software Foundation, Inc.,
 
19
 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
 
20
 *
 
21
 *-----------------------------------------------------------------------------
 
22
 * Description:
 
23
 *  
 
24
 *-----------------------------------------------------------------------------
 
25
 */
 
26
 
 
27
#ifndef _PD_H_
 
28
#define _PD_H_
 
29
 
 
30
#include <igd_pd.h>
 
31
#include <igd_debug.h>
 
32
 
 
33
/* PD SDK version 2 bytes,
 
34
 *    1st byte is major version,
 
35
 *    second byte is minor version.
 
36
 */
 
37
 
 
38
/* Update the version number each time there is an
 
39
 * API Change or Change in data structures
 
40
 */
 
41
#define PD_SDK_VERSION    0x0300             /* PD SDK Version */
 
42
 
 
43
#ifndef NULL
 
44
#ifdef __cplusplus
 
45
#define NULL    0
 
46
#else
 
47
#define NULL    ((void *)0)
 
48
#endif
 
49
#endif
 
50
 
 
51
#ifndef TRUE
 
52
#define TRUE   1
 
53
#endif
 
54
 
 
55
#ifndef FALSE
 
56
#define FALSE  0
 
57
#endif
 
58
 
 
59
/* This needs to contain the unsigned long for vBIOS. */
 
60
#ifndef BIT
 
61
#define BIT(x) (1L<<x)
 
62
#endif
 
63
 
 
64
/* Macro to return:
 
65
 *    minimum, if the value < min value
 
66
 *    maximum, if the value > max value
 
67
 *    value, otherwise
 
68
 */
 
69
#define MINMAX(val, min, max) ((val < min) ? min : ((val > max) ? max : val))
 
70
 
 
71
#define PD_REG_LIST_END      0xFFFFFFFF
 
72
#define PD_DAB_LIST_END      0xFFFFFFFF
 
73
#define PD_TIMING_LIST_END   0xFFFF
 
74
 
 
75
/* Error codes used for return values */
 
76
#define  PD_SUCCESS           0x00    /* Success */
 
77
#define  PD_ERR_NOMEM         0x01    /* Unable to allocated requested mem */
 
78
#define  PD_ERR_NODEV         0x02    /* No Device/Codec found */
 
79
#define  PD_ERR_NODIS         0x03    /* No display found */
 
80
#define  PD_ERR_INVALID_PTR   0x04    /* Invalid pointer passed */
 
81
#define  PD_ERR_NULL_PTR      0x05    /* Null ptr passed */
 
82
#define  PD_ERR_DISPLAY_TYPE  0x06    /* Unsupported display type specified */
 
83
#define  PD_ERR_NOPORT_AVAIL  0x07    /* No port available */
 
84
#define  PD_ERR_INTERNAL      0x08    /* Critical internal error */
 
85
#define  PD_ERR_INVALID_POWER 0x09    /* Invalid power state specified */
 
86
#define  PD_ERR_HAND_SHAKE    0x0A    /* Magic cookie hand shake failed */
 
87
#define  PD_ERR_MODE_NOTSUPP  0x0B    /* Unsupported mode */
 
88
#define  PD_ERR_I2C_READ      0x0C    /* I2C read error */
 
89
#define  PD_ERR_I2C_WRITE     0x0D    /* I2C write error */
 
90
#define  PD_ERR_NULL_STATE    0x0E    /* Saved state is NULL */
 
91
/* PD_ERR_NOATTR removed. Return success with 0 count instead */
 
92
#define  PD_ERR_NO_TIMINGS    0x10    /* No timing list */
 
93
#define  PD_ERR_INVALID_ATTR  0x11    /* Invalid attribute */
 
94
#define  PD_ERR_INCORR_ATTR_VALUE 0x12 /* Incorrect attr value */
 
95
#define  PD_ERR_ATTR_CANT_CHANGE  0x13 /* Attribute value cannot be changed */
 
96
#define  PD_ERR_VER_MISMATCH      0x14 /* PD SDK version mismatch */
 
97
#define  PD_ERR_UNSUCCESSFUL      0x15 /* Operation unsuccessful */
 
98
 
 
99
typedef struct _pd_reg {
 
100
        unsigned long reg;
 
101
        unsigned long value;
 
102
}pd_reg_t;
 
103
 
 
104
 
 
105
/* The following structures holds CEA EDID Extension data
 
106
 * Edid and possibly display id would use this structure as
 
107
 * well. PD callback would have a callback function to one the
 
108
 * structure to retrieve EDID like data (ELD)
 
109
 */
 
110
 
 
111
 
 
112
#define CEA_IEEE_HDMI_ID        0x000C03
 
113
/* Aspect Ratio */
 
114
#define PD_ASPECT_RATIO_NO_DATA 0
 
115
#define PD_ASPECT_RATIO_4_3     1
 
116
#define PD_ASPECT_RATIO_16_9    2
 
117
/* ELD status */
 
118
#define ELD_AVAIL       0x01
 
119
#define ELD_CANNED      0x02
 
120
/* Transmitter audio charactheristic */
 
121
#define PD_AUDIO_CHAR_AVAIL     0x10
 
122
/* CEA data block type */
 
123
#define CEA_VIDEO_DATA_BLOCK    0x40
 
124
#define CEA_AUDIO_DATA_BLOCK    0x20
 
125
#define CEA_VENDOR_DATA_BLOCK   0x60
 
126
#define CEA_SPEAKER_DATA_BLOCK  0x80
 
127
/* Audio block Tag Code */
 
128
#define CEA_AUDIO_LPCM          1
 
129
#define CEA_AUDIO_AC3           2
 
130
#define CEA_AUDIO_MPG1          3
 
131
#define CEA_AUDIO_MP3           4
 
132
#define CEA_AUDIO_MPG2          5
 
133
#define CEA_AUDIO_AAC           6
 
134
#define CEA_AUDIO_DTS           7
 
135
#define CEA_AUDIO_ATRAC         8
 
136
#define CEA_AUDIO_SACD          9
 
137
#define CEA_AUDIO_DD_PLUS       10
 
138
#define CEA_AUDIO_DTS_HD        11
 
139
#define CEA_AUDIO_MLP           12
 
140
/* Pixel Replication */
 
141
#define PIX_REPLICATION_0       1
 
142
#define PIX_REPLICATION_1       2
 
143
#define PIX_REPLICATION_3       4
 
144
/* Quantization */
 
145
#define HDMI_QUANTIZATION_RGB_256       0x00
 
146
#define HDMI_QUANTIZATION_RGB_220       0x01
 
147
#define HDMI_QUANTIZATION_YUV_422       0x02
 
148
#define HDMI_QUANTIZATION_YUV_44        0x03
 
149
/* Colorimetry */
 
150
#define HDMI_COLORIMETRY_NODATA         0x00
 
151
#define HDMI_COLORIMETRY_ITU601         0x01 /* SMPTE 170M, ITU601 */
 
152
#define HDMI_COLORIMETRY_ITU709         0x02
 
153
/* Audio CAP(48,96,192)Khz refer to audio_cap in CEA ELD extension*/
 
154
#define CAP_48_KHZ      0
 
155
#define CAP_96_KHZ      1
 
156
#define CAP_192_KHZ     2
 
157
/* Vendor Specific Data Block */
 
158
#define VSBD_LATENCY_FIELD                      8
 
159
typedef struct _cea_audio_format_t{
 
160
        union{
 
161
                unsigned char byte1;
 
162
                struct{
 
163
                        unsigned char max_channels              : 3;
 
164
                        unsigned char audio_format_code : 4;
 
165
                        unsigned char reserve_byte1             : 1;
 
166
                };
 
167
        };
 
168
        union{
 
169
                unsigned char byte2;
 
170
                struct{
 
171
                        unsigned char _32khz                    : 1;
 
172
                        unsigned char _44khz                    : 1;
 
173
                        unsigned char _48khz                    : 1;
 
174
                        unsigned char _88khz                    : 1;
 
175
                        unsigned char _96khz                    : 1;
 
176
                        unsigned char _176khz                   : 1;
 
177
                        unsigned char _192khz                   : 1;
 
178
                        unsigned char reserve_byte2             : 1;
 
179
                };
 
180
        };
 
181
        /* 3rd byte differs between compressed & uncompressed audio */
 
182
        union{
 
183
                unsigned char max_bitrate;
 
184
                struct{
 
185
                        unsigned char _16bit            : 1;
 
186
                        unsigned char _20bit            : 1;
 
187
                        unsigned char _24bit            : 1;
 
188
                        unsigned char reserve_byte3     : 5;
 
189
                };
 
190
        };
 
191
 
 
192
}cea_audio_format_t;
 
193
 
 
194
typedef struct _speaker_allocation_data_t{
 
195
        struct{
 
196
                unsigned char   rsvd    : 1;
 
197
                unsigned char   rlc_rrc : 1;
 
198
                unsigned char   flc_frc : 1;
 
199
                unsigned char   rc              : 1;
 
200
                unsigned char   rl_rr   : 1;
 
201
                unsigned char   fc              : 1;
 
202
                unsigned char   lfe             : 1;
 
203
                unsigned char   fl_fr   : 1;
 
204
        };
 
205
        unsigned char reserved[2];
 
206
}speaker_allocation_data_t;
 
207
 
 
208
typedef union {
 
209
        unsigned char value;
 
210
        struct {
 
211
                unsigned char code: 7;
 
212
                unsigned char native: 1;
 
213
        };
 
214
} cea_video_blk_t;
 
215
 
 
216
typedef struct _audio_capability_t{
 
217
        unsigned char max_channels;
 
218
        unsigned char _20bit;
 
219
        unsigned char _24bit;
 
220
}audio_capability_t;
 
221
 
 
222
typedef struct _vsdb_t{
 
223
        union{
 
224
                unsigned char header;
 
225
                struct{
 
226
                        unsigned char vendor_block_size: 5;
 
227
                        unsigned char tag : 3;
 
228
                };
 
229
        };
 
230
        unsigned char   vendor_ieee_id[3];
 
231
        unsigned char   src_phy_add[2];
 
232
        unsigned char   support_ai;
 
233
        unsigned char   max_tmds_clck;
 
234
        union{
 
235
                unsigned char latency_fields;
 
236
                struct{
 
237
                        unsigned char reserve   : 6;
 
238
                        unsigned char i_latency : 1;
 
239
                        unsigned char p_latency : 1;
 
240
                };
 
241
        };
 
242
        unsigned char p_video_latency;
 
243
        unsigned char p_audio_latency;
 
244
        unsigned char i_video_latency;
 
245
        unsigned char i_audio_latency;
 
246
 
 
247
}vsdb_t;
 
248
 
 
249
typedef struct _cea_extension{
 
250
        unsigned char   rev_number;
 
251
        unsigned char   canned_eld;
 
252
        union{
 
253
                unsigned char   caps;
 
254
                struct{
 
255
                        unsigned char   total_native_format : 4;
 
256
                        unsigned char   YCC_422                         : 1;
 
257
                        unsigned char   YCC_444                         : 1;
 
258
                        unsigned char   audio_support           : 1;
 
259
                        unsigned char   underscan_support       : 1;
 
260
                };
 
261
        };
 
262
 
 
263
        /* Short Video Descriptor */
 
264
        int                                             total_short_video_desc;
 
265
        cea_video_blk_t                 *short_video_desc;
 
266
        /* Short Audio Descriptor */
 
267
        int                                             total_short_audio_desc;
 
268
        cea_audio_format_t              *short_audio_desc;
 
269
        /* Vendor Descriptor Block */
 
270
        unsigned char                   *vendor_data_block;
 
271
 
 
272
        unsigned char           audio_flag;             /* Define is ELD status */
 
273
        unsigned char           NPL;
 
274
        unsigned char           K0;
 
275
        unsigned char           K1;
 
276
        audio_capability_t      audio_cap[3];   /* Panel audio capability (48,96,192)Khz*/
 
277
 
 
278
        /* AVI Info frames data */
 
279
        int                                     pixel_rep;              /* Pixel replication */
 
280
        int                                     quantization;   /* Quantization */
 
281
        int                                     aspect_ratio;   /* Aspect Ratio */
 
282
        int                                     colorimetry;    /* Colorimetry */
 
283
        int                                     video_code;
 
284
        /* Consolidate ELD information here */
 
285
        union{
 
286
                unsigned char eld_ptr[256];
 
287
                struct {
 
288
                        union {
 
289
                                unsigned char version;
 
290
                                struct {
 
291
                                        unsigned char cea_ver: 3;
 
292
                                        unsigned char eld_ver: 5;
 
293
                                };
 
294
                        };
 
295
                        union {
 
296
                                unsigned char capability;
 
297
                                struct {
 
298
                                        unsigned char hdcp: 1;
 
299
                                        unsigned char repeater: 1;
 
300
                                        unsigned char _44ms: 1;
 
301
                                        unsigned char reserved1: 5;
 
302
                                };
 
303
                        };
 
304
                        union {
 
305
                                unsigned short length;
 
306
                                struct {
 
307
                                        unsigned short mnl: 3;
 
308
                                        unsigned short vsdbl: 3;
 
309
                                        unsigned short sadc: 4;
 
310
                                        unsigned short reserved2: 6;
 
311
                                };
 
312
                        };
 
313
                        unsigned short  manu_id;
 
314
                        unsigned short  prod_id;
 
315
                        unsigned char   LPCM_CAD[3];    /* LPCM for ELD */
 
316
                        unsigned char   speaker_alloc_block[3];
 
317
                        vsdb_t                  vendor_block;   /* 13 byte */
 
318
                        unsigned char   misc_data[229];
 
319
                };
 
320
        };
 
321
}cea_extension_t;
 
322
 
 
323
/* Following are the callback functions provided to port driver. It also
 
324
 * provides a call back context. Every time port driver has to pass this
 
325
 * callback context when calling a callback function.
 
326
 *
 
327
 * read_regs:     Port driver has to pass a list of pd_reg_t's which
 
328
 *                it want to read. The list has to end with PD_I2C_LIST_END.
 
329
 *                The values read will be set to the for every list->reg,
 
330
 *                value will be set in list->value.
 
331
 *
 
332
 *                Return value == 0 on success
 
333
 *                             != 0 on failure
 
334
 *
 
335
 * write_regs:    Port driver has to pass a list of pd_reg_t's which
 
336
 *                it want to write. The list has to end with PD_LIST_END.
 
337
 *                Caller has to provide already masked values. This callback
 
338
 *                function doesn't do any masking. If, port driver wants to
 
339
 *                write only some bits of a reg, first it has to read the
 
340
 *                register and then set bits and write the register.
 
341
 *
 
342
 *                Return value == 0 on success
 
343
 *                             != 0 on failure
 
344
 */
 
345
 
 
346
#define PD_REG_I2C    0x00000001
 
347
#define PD_REG_LPC    0x00000002
 
348
#define PD_REG_DMA    0x00000003
 
349
#define PD_REG_PCI    0x00000004
 
350
#define PD_REG_MIO    0x00000005   /* MMIO 32 bits    */
 
351
#define PD_REG_PIO8   0x00000006   /* Port IO 1 byte */
 
352
#define PD_REG_PIO16  0x00000007   /* Port IO 2 bytes */
 
353
#define PD_REG_PIO32  0x00000008   /* Port IO 4 bytes */
 
354
#define PD_REG_MIO8   0x00000009   /* MMIO 8 bits     */
 
355
#define PD_REG_BRIDGE_OPCODE  0x0000000D /* Host bridge read and write */
 
356
#define PD_REG_DDC            0x0000000E /* Read the ddc */
 
357
 
 
358
typedef int (*pd_read_regs_p)(void *callback_context, pd_reg_t *list,
 
359
                unsigned long type);
 
360
typedef int (*pd_write_regs_p)(void *callback_context, pd_reg_t *list,
 
361
                unsigned long type);
 
362
 
 
363
typedef struct _pd_callback {
 
364
        void *callback_context;
 
365
        pd_read_regs_p  read_regs;
 
366
        pd_write_regs_p write_regs;
 
367
        unsigned long port_num;                 /*      Added for SDVO port driver */
 
368
        cea_extension_t **eld;                  /* EDID like Data */
 
369
}pd_callback_t;
 
370
 
 
371
/* IMP NOTE: All below structures should be with same size.
 
372
 *         pd_attr_t            : General attribute structure
 
373
 *         pd_range_attr_t      : Range type attribute structure
 
374
 *         pd_list_attr_t       : List type attribute
 
375
 *         pd_list_entry_attr_t : Entry for a list
 
376
 *         pd_bool_attr_t       : Boolean type attribute
 
377
 *         pd_buffer_attr_t     : Buffer type attribute
 
378
 */
 
379
typedef igd_attr_t            pd_attr_t;
 
380
typedef igd_range_attr_t      pd_range_attr_t;
 
381
typedef igd_list_attr_t       pd_list_attr_t;
 
382
typedef igd_list_entry_attr_t pd_list_entry_attr_t;
 
383
typedef igd_bool_attr_t       pd_bool_attr_t;
 
384
typedef igd_buffer_attr_t     pd_buffer_attr_t;
 
385
 
 
386
#define ATTR(a)   ((pd_attr_t *)a)               /* General attr */
 
387
#define RATTR(a)  ((pd_range_attr_t *)a)         /* Range attr */
 
388
#define LHATTR(a) ((pd_list_attr_t *)a)          /* List head attr */
 
389
#define LEATTR(a) ((pd_list_entry_attr_t *)a)    /* List entry attr */
 
390
#define BATTR(a)  ((pd_bool_attr_t *)a)          /* Bool attr */
 
391
#define BUATTR(a) ((pd_buffer_attr_t *)a)        /* Buffer attr */
 
392
 
 
393
/* Timing structure flag defines */
 
394
#define PD_SCAN_INTERLACE        0x80000000
 
395
#define PD_LINE_DOUBLE           0x40000000
 
396
#define PD_PIXEL_DOUBLE          0x20000000
 
397
#define PD_MODE_TEXT             0x10000000  /* VGA Text mode */
 
398
 
 
399
#define PD_HSYNC_HIGH            0x08000000
 
400
#define PD_VSYNC_HIGH            0x04000000
 
401
#define PD_BLANK_LOW             0x02000000
 
402
#define PD_MODE_VESA             0x01000000 /* VGA/VESA mode number is valid */
 
403
 
 
404
#define PD_MODE_STALL            0x00800000   /* Flag to enable stall signal */
 
405
#define PD_MODE_SCALE            0x00400000   /* Request NATIVE timings */
 
406
 
 
407
#define PD_ASPECT_16_9           0x00200000   /* 16:9 aspect ratio, otherwise it is 4:3 */
 
408
#define PD_MODE_CEA                              0x00100000
 
409
 
 
410
#define PD_MODE_DTD              0x00080000   /* Read from EDID */
 
411
#define PD_MODE_DTD_USER         0x00040000   /* User defined timing */
 
412
#define PD_MODE_DTD_FP_NATIVE    0x00020000   /* Native fp timing */
 
413
#define PD_MODE_SUPPORTED        0x00010000
 
414
 
 
415
#define PD_MODE_FACTORY          0x00008000   /* Factory supported mode */
 
416
#define PD_MODE_RB               0x00004000   /* Reduced blanking mode */
 
417
 
 
418
/* Macro to put at the end timing table */
 
419
#define  PD_TIMING_TABLE_END \
 
420
{\
 
421
        PD_TIMING_LIST_END, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\
 
422
        NULL, 0, 0\
 
423
}\
 
424
 
 
425
/* Timing structure */
 
426
typedef struct _pd_timing {
 
427
        unsigned short width;           /* width */
 
428
        unsigned short height;          /* height */
 
429
        unsigned short refresh;         /* refresh rate */
 
430
        unsigned long  dclk;            /* refresh rate dot clock in kHz */
 
431
        unsigned short htotal;          /* horizontal total */
 
432
        unsigned short hblank_start;    /* horizontal blank start */
 
433
        unsigned short hblank_end;      /* horizontal blank end */
 
434
        unsigned short hsync_start;     /* horizontal sync start */
 
435
        unsigned short hsync_end;       /* horizontal sync end */
 
436
        unsigned short vtotal;          /* vertical total */
 
437
        unsigned short vblank_start;    /* vertical blank start */
 
438
        unsigned short vblank_end;      /* vertical blank end */
 
439
        unsigned short vsync_start;     /* vertical sync start */
 
440
        unsigned short vsync_end;       /* vertical sync end */
 
441
        short mode_number; /* VGA or VESA mode number */
 
442
        unsigned long mode_info_flags; /* Valid Flags
 
443
                                                                           - PD_SCAN_INTERLACE
 
444
                                                                           - PD_LINE_DOUBLE
 
445
                                                                           - PD_PIXEL_DOUBLE
 
446
                                                                           - PD_HSYNC_HIGH
 
447
                                                                           - PD_VSYNC_HIGH
 
448
                                                                           - PD_MODE_SUPPORTED
 
449
                                                                           - PD_MODE_DTD */
 
450
        unsigned short x_offset;
 
451
        unsigned short y_offset;
 
452
        void *extn_ptr;  /* INTERNAL pointer for use by main driver only */
 
453
        unsigned short reserved_dd; /* Reserved for device dependant layer */
 
454
        unsigned short reserved_dd_ext; /* Reserved for device dependant layer */
 
455
} pd_timing_t;
 
456
 
 
457
/* Bit field flags for pd_driver_t->driver_flags */
 
458
#define PD_FLAG_GANG_MODE       0x00000001   /* driver is running in gang mode*/
 
459
#define PD_FLAG_CLK_SOURCE      0x00000002   /* clk source is port driver */
 
460
#define PD_FLAG_PIPE_MASTER     0x00000004   /* master port driver */
 
461
#define PD_FLAG_REV_DATA_ORDER  0x00000008   /* reverse data order requested */
 
462
#define PD_FLAG_I740_DATA_ORDER 0x00000010   /* For I740 Data ordering. If this
 
463
                                                                                                flag isn't set, then it is
 
464
                                                                                                Flat panel data ordering */
 
465
#define PD_FLAG_DUAL_DVO        0x00000020   /* Same port driver will be loaded
 
466
                                                                                          * on both DVOB & DVOC with same
 
467
                                                                                          * DAB */
 
468
#define PD_FLAG_GANG_MODE_EVEN_ODD 0x00000040   /* pd wants gang mode in even
 
469
                                                                                                 * pixels on one DVO port &
 
470
                                                                                                 * odd pixels on other DVO port.
 
471
                                                                                                 * Default is upper half pixel
 
472
                                                                                                 * on one DVO port and lower
 
473
                                                                                                 * half on the other DVO port.
 
474
                                                                                                 */
 
475
#define PD_FLAG_UP_SCALING          0x00000080 /* pd supports up-scaling */
 
476
#define PD_FLAG_DOWN_SCALING        0x00000100 /* pd supports down-scaling */
 
477
#define PD_FLAG_CLOCK_MASTER        0x00000200 /* clock master port driver */
 
478
#define PD_FLAG_GANG_MODE_DVOCLKINV 0x00000400 /* GangMode DVO Clk inversion */
 
479
#define PD_FLAG_NO_VGA_2X_IMAGE     0x00000800 /* Gang Mode operation might
 
480
                                                                                                * request this flag */
 
481
 
 
482
/* Flag for set_mode function */
 
483
/* Though these are bit fields, both cannot be used at same time */
 
484
#define PD_SET_MODE_PIPE_A    0x1
 
485
#define PD_SET_MODE_PIPE_B    0x2
 
486
#define PD_SET_MODE_FLAG_TEST 0x4
 
487
 
 
488
/* Flags for save and restore */
 
489
#define PD_NO_RESTORE_FREE_STATE 0x1
 
490
 
 
491
/* Power Modes */
 
492
#define PD_POWER_MODE_D0  0x0
 
493
#define PD_POWER_MODE_D1  0x1
 
494
#define PD_POWER_MODE_D2  0x2
 
495
#define PD_POWER_MODE_D3  0x3
 
496
 
 
497
#define PD_FILE_SIZE       8   /* File name size for port driver excluding
 
498
                                                                * extension. Extension can be max of 3 chars. */
 
499
 
 
500
/* Following is the abstraction of port driver. Port driver passes this
 
501
 * driver information to display driver as part of registering itself with
 
502
 * display driver. pd_register(pd_driver_t *) is called from port driver
 
503
 * in its init function which is called whenever port driver is loaded.
 
504
 *
 
505
 * Port driver provides following list of functions to display driver.
 
506
 * Display driver calls these functions to do the required operations.
 
507
 *
 
508
 * type         - supporting display type for the port driver
 
509
 *
 
510
 * flags        - flags for the driver. And cannot be changed at runtime.
 
511
 *                Once these flags are passed to main driver, they will be
 
512
 *                used while setting the mode.
 
513
 *
 
514
 * context      - Driver's contextual information. The driver can save
 
515
 *                all needed state information in this opaque pointer
 
516
 *                such that the driver is entirely reentrant. No writeable
 
517
 *                data may be saved in any non-stack variables by a driver
 
518
 *                therefore all necessary data must be saved in a private
 
519
 *                structure and stored in this pointer. This pointer is
 
520
 *                passed to the driver with each function call.
 
521
 *
 
522
 * validate     - Display driver calls this function to validate the port
 
523
 *                driver by passing a magic cookie. Port driver does some
 
524
 *                magic operation and returns another cookie back to caller.
 
525
 *                If the returned cookie has correct value then the driver
 
526
 *                passes the validation, otherwise driver cannot communicate
 
527
 *                with display driver.
 
528
 *
 
529
 * open         - This function is to detect for any port device (codec).
 
530
 *                pd_callback_t has all the required callback functions
 
531
 *                to do this operation.
 
532
 *
 
533
 * init_device  - This function detects and initializes any display devices
 
534
 *                attached to the codec.
 
535
 *
 
536
 *                For ex: a multi function encoder can support a FlatPanel or
 
537
 *                TVout display. It has to detect and check for any
 
538
 *                Flatpanel or TVout display device attached, then it
 
539
 *                initializes the display devices.
 
540
 *
 
541
 * pd_close     - closes the display device and frees any memory allocated.
 
542
 *
 
543
 * set_mode     - sets/tests a mode. Display (or main) driver calls this
 
544
 *                function to set a mode when the encoder in D3 power state.
 
545
 *                At this time, DVO timings are off.
 
546
 *                If encoder wants to run setmode in any other power state,
 
547
 *                then first thing it needs to do is enter into that power
 
548
 *                state and then do setmode.
 
549
 *
 
550
 *                When this function returns it is expected that:
 
551
 *                   1. Either encoder is in D0 power state or
 
552
 *                      it defers until post_set_mode().
 
553
 *                   2. In case of external encoder (example: TVOut encoder)
 
554
 *                      driving the reference clock, the clock is running.
 
555
 *
 
556
 * post_set_mode- This is called after GMCH DVO timings are on.
 
557
 *                This function can be null if there is nothing to do.
 
558
 *                This is used to do any post processing on the encoder
 
559
 *                after GMCH starts driving the timings. When this function
 
560
 *                returns it is expected that the encoder is in D0 power state.
 
561
 *                Parameters:
 
562
 *                       context - port driver context
 
563
 *                       mode    - current timing
 
564
 *                       flags   - not used (for future use).
 
565
 *
 
566
 * set_attrs    - to set provided list of attributes.
 
567
 *
 
568
 * get_attrs    - to get list of attributes.
 
569
 *
 
570
 * get_timing_list - returns the list of supported modes for the current
 
571
 *                   attributes. For example if the TVFormat is NTSC, this
 
572
 *                   function will return only the modes supported for NTSC.
 
573
 *
 
574
 * set_power    - to set the power state of the display device.
 
575
 *
 
576
 * get_power    - to get the current power state of the display device.
 
577
 *
 
578
 * pd_save      - to save the current state of the registers.
 
579
 *                  - returns the current state in the double pointer 'state'.
 
580
 *
 
581
 * pd_restore   - to restore to the passed state. This functions frees the
 
582
 *                resources allocated that state.
 
583
 *                  - pass the previously saved state in 'state'.
 
584
 *
 
585
 *                If PD_NO_RESTORE_FREE_STATE is set, then it just frees
 
586
 *                the resources without restoring the state.
 
587
 *
 
588
 * pd_get_port_status - to get the status of port/display
 
589
 *
 
590
 *
 
591
 * All functions return value:
 
592
 *         == 0 - if success
 
593
 *         != 0 - if failure
 
594
 */
 
595
 
 
596
 
 
597
/* Note on version AA.BB.CC.DD
 
598
 * AA - Major version
 
599
 * BB - Minor version
 
600
 * CC - Patch version if any
 
601
 * DD - Bug fixes if any
 
602
 *
 
603
 * 01.00.00.00 is the first initial major version */
 
604
typedef struct _pd_version {
 
605
        unsigned char major;
 
606
        unsigned char minor;
 
607
        unsigned char patch;
 
608
        unsigned char bug_fix;
 
609
} pd_version_t;
 
610
 
 
611
 
 
612
typedef enum {
 
613
        PD_DISP_STATUS_DETACHED = 0,        /* Display is not connected */
 
614
        PD_DISP_STATUS_ATTACHED,            /* Display is connected     */
 
615
        PD_DISP_STATUS_UNKNOWN              /* Unable to determine      */
 
616
} pd_display_status_t;
 
617
 
 
618
/* Port/Display information */
 
619
typedef struct _pd_port_status {
 
620
        pd_display_status_t connected;      /* Display status                */
 
621
        unsigned long display_type;         /* Type of display, if connected */
 
622
} pd_port_status_t;
 
623
 
 
624
typedef struct _pd_driver {
 
625
        unsigned long pd_sdk_version;        /* PD SDK version - interface ver */
 
626
        char          name[PD_NAME_SIZE];    /* Descriptive name of port driver */
 
627
        char          num_devices;           /* Number of devices it is driving */
 
628
        pd_version_t  *version;              /* Driver version */
 
629
        unsigned long type;
 
630
        unsigned long flags;
 
631
        unsigned long *dab_list;             /* PD_DAB_LIST_END terminated list */
 
632
        unsigned long i2c_speed;             /* Encoder I2C speed in KHz */
 
633
        unsigned long (*validate)(unsigned long cookie);
 
634
        int (*open)       (pd_callback_t *callback, void **context);
 
635
        int (*init_device)(void *context);
 
636
        int (*pd_close)   (void *context);
 
637
        int (*set_mode)   (void *context, pd_timing_t *mode, unsigned long flags);
 
638
        int (*post_set_mode)(void *context, pd_timing_t *mode, unsigned long flags);
 
639
        int (*set_attrs)  (void *context, unsigned long num, pd_attr_t *list);
 
640
        int (*get_attrs)  (void *context, unsigned long *num, pd_attr_t **list);
 
641
        int (*get_timing_list)(void*context,pd_timing_t*in_list,pd_timing_t**list);
 
642
        int (*set_power)  (void *context, unsigned long state);
 
643
        int (*get_power)  (void *context, unsigned long *state);
 
644
        int (*pd_save)    (void *context, void **state, unsigned long flags);
 
645
        int (*pd_restore) (void *context, void *state, unsigned long flags);
 
646
        int (*pd_get_port_status) (void *context, pd_port_status_t *port_status);
 
647
} pd_driver_t;
 
648
 
 
649
/* Mode filter helper function for port drivers */
 
650
/* Structure representing encoder capabilities for mode filtering */
 
651
typedef struct _pd_dvo_info {
 
652
        unsigned long min_dclk;               /* Min clock */
 
653
        unsigned long max_dclk;               /* Max clock */
 
654
        unsigned char upscale;                /* Is upscalable? */
 
655
        unsigned char downscale;              /* Is downscalable? */
 
656
        unsigned short upscale_min_width;     /* Min upscale width */
 
657
        unsigned short upscale_min_height;    /* Min upscale height */
 
658
        unsigned short downscale_max_width;   /* Max downscale width */
 
659
        unsigned short downscale_max_height;  /* Max downscale height */
 
660
} pd_dvo_info_t;
 
661
 
 
662
typedef struct _pd_display_info {
 
663
        unsigned char panel_fit;   /* Incoming */
 
664
        unsigned char fixed_res;   /* Outgoing */
 
665
        unsigned short width;      /* Outgoing */
 
666
        unsigned short height;     /* Outgoing */
 
667
        pd_timing_t   *native_dtd; /* Outgoing */
 
668
} pd_display_info_t;
 
669
 
 
670
/* All following functions are provided to port drivers as a binary file.
 
671
 *
 
672
 * pd_register: This function is called by port driver to register with
 
673
 *              display driver. It passes its driver structure to display
 
674
 *              driver.
 
675
 *
 
676
 * pd_malloc:   This function is used to allocate any dynamic memory required
 
677
 *              in port driver. Port driver will pass the size of the memory
 
678
 *              it is requesting in bytes.
 
679
 *
 
680
 *              Return value == pointer to the allocated memory on success
 
681
 *                           == NULL if failed to allocated the memory
 
682
 *
 
683
 * pd_memset:   This function is used to set the passed byte in memory
 
684
 *              for size bytes.
 
685
 *
 
686
 * pd_memcpy:   This function is used to copy size bytes from src pointer to
 
687
 *              dest pointer.
 
688
 *
 
689
 * free:        This function is used to free the memory previously allocated
 
690
 *              using malloc callback function.
 
691
 *
 
692
 * usleep:      This function is used to get any delay in port driver.
 
693
 *              'usec' is specified in micro seconds.
 
694
 *
 
695
 *              No return value.
 
696
 * ui_usleep:   This function is used to get any delay in port driver uniterrupted.
 
697
 *              'usec' is specified in micro seconds.
 
698
 *
 
699
 *              No return value.
 
700
 *
 
701
 * printf:      This function is used to do any debug prints for port driver.
 
702
 *              This has exactly the same syntax and usage of standard
 
703
 *              printf in 'C'.
 
704
 *
 
705
 * strcpy:      This function is used to copy src string into dest string.
 
706
 *              This has exactly the same syntax and usage of standard
 
707
 *              strcpy in 'C'.
 
708
 *
 
709
 * filter:      This function is to filter the incoming mode list based on
 
710
 *              dvo_info. Memory is allocated for outgoing list. No changes
 
711
 *              to in_list.
 
712
 */
 
713
int   pd_register(void *handle, pd_driver_t *driver);
 
714
void *pd_malloc(unsigned long size);
 
715
void *pd_memset(void *address, int c, unsigned long size);
 
716
void *pd_memcpy(void *dst, void *src, unsigned long size);
 
717
void  pd_free  (void *address);
 
718
 
 
719
void  pd_usleep(unsigned long usec);
 
720
void  pd_ui_usleep(unsigned long usec);
 
721
char *pd_strcpy(char *dest, char const *src);
 
722
int  *pd_printf(const char *format, ...);
 
723
int   pd_check_attr(pd_attr_t *curr, pd_attr_t *in);
 
724
/* Mode filter helper function for port drivers */
 
725
int   pd_filter_timings(void *context, pd_timing_t *inlist, pd_timing_t **olist,
 
726
        pd_dvo_info_t *dvo_info, pd_display_info_t *display_info);
 
727
 
 
728
/* pd_get_attr() :  To return the request attr from the list.
 
729
 * In case of 'attr_id' is a list type attribute, then caller
 
730
 * can request either LIST head itself or list entry for that
 
731
 * attribute. */
 
732
#define PD_GET_ATTR_LIST            0x0001
 
733
#define PD_GET_ATTR_LIST_ENTRY      0x0002
 
734
pd_attr_t *pd_get_attr(pd_attr_t *attr_list, unsigned long num_attrs,
 
735
                unsigned long attr_id, unsigned long flag);
 
736
 
 
737
/*
 
738
// Typedefinitions 
 
739
typedef int        (*pd_register_p)  (void *handle, pd_driver_t *driver);
 
740
typedef void      *(*pd_malloc_p)(unsigned long size);
 
741
typedef void      *(*pd_memset_p)(void *address, int c, unsigned long size);
 
742
typedef void      *(*pd_memcpy_p)(void *dst, void *src, unsigned long size);
 
743
typedef void       (*pd_free_p)  (void *address);
 
744
typedef void       (*pd_usleep_p)(unsigned long usec);
 
745
typedef char      *(*pd_strcpy_p)(char *dest, char const *src);
 
746
typedef int       *(*pd_printf_p)(const char *format, ...);
 
747
typedef int        (*pd_check_attr_p)(pd_attr_t *curr, pd_attr_t *in);
 
748
typedef pd_attr_t *(*pd_get_attr_p)(pd_attr_t *attr_list,
 
749
                unsigned long num_attrs, unsigned long attr_id, unsigned long flag);
 
750
typedef emgd_debug_t *(*pd_get_emgd_debug_p)( void );
 
751
typedef unsigned long *(*pd_get_dropped_debug_messages_p)( void );
 
752
typedef void *(*pd_get_debug_log_mutex_p)( void );
 
753
 
 
754
// Mode filter helper function for port drivers 
 
755
typedef int        (*pd_filter_timings_p)(void *context, pd_timing_t *inlist,
 
756
                pd_timing_t **olist, pd_dvo_info_t *dvo_info,
 
757
                pd_display_info_t *display_info);
 
758
*/
 
759
#endif /* _PD_H_ */
 
760
 
 
761
/*----------------------------------------------------------------------------
 
762
 * File Revision History
 
763
 * $Id: pd.h,v 1.7 2010/07/23 16:54:50 bpaauwe Exp $
 
764
 * $Source: /nfs/fm/proj/eia/cvsroot/koheo/linux/egd_drm/emgd/include/pd.h,v $
 
765
 *----------------------------------------------------------------------------
 
766
 */