~gma500/+junk/emgd152-natty

« back to all changes in this revision

Viewing changes to emgd-dkms-1.5.15.3082/emgd/include/utils.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: utils.h
 
4
 * $Revision: 1.6 $
 
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 _UTILS_H_
 
28
#define _UTILS_H_
 
29
 
 
30
#include <config.h>
 
31
#include <igd_mode.h>
 
32
#include <general.h>
 
33
#include <mode.h>
 
34
 
 
35
/* Get the MMIO pointer for a display context */
 
36
#define MMIO(dsp) \
 
37
 EMGD_MMIO((((igd_display_context_t *)dsp)->context->device_context.virt_mmadr))
 
38
 
 
39
/* Get the 2nd MMIO pointer for a display context */
 
40
#define MMIO_SDVO(dsp) \
 
41
 EMGD_MMIO(((igd_display_context_t *)dsp)->context->device_context.virt_mmadr_sdvo)
 
42
 
 
43
/* Definition: value = READ_MMIO_REG(igd_display_context_t *, reg) */
 
44
#define READ_MMIO_REG(dsp, reg) \
 
45
        EMGD_READ32( MMIO(dsp) +(reg) )
 
46
 
 
47
/* Definition: WRITE_MMIO_REG(igd_display_context_t *, reg, value) */
 
48
#define WRITE_MMIO_REG(dsp, reg, value) \
 
49
        EMGD_WRITE32(value, ( MMIO(dsp) + (reg) ) )
 
50
 
 
51
/* Definition:WRITE_MMIO_REG_BITS(igd_display_context_t *, reg, value, mask) */
 
52
#define WRITE_MMIO_REG_BITS(dsp, reg, data, mask) \
 
53
{                                                 \
 
54
        unsigned long tmp;                            \
 
55
        tmp = READ_MMIO_REG((dsp), (reg));            \
 
56
        tmp &= (~(mask));                             \
 
57
        tmp |= ((data) & (mask));                     \
 
58
        WRITE_MMIO_REG((dsp), (reg), (tmp));          \
 
59
}
 
60
 
 
61
#define PORT_TYPE(d) (PORT(d, (d->port_number))->port_type)
 
62
#define PORT_TYPE_DH(dh) \
 
63
        (PORT(dh, (((igd_display_context_t *)dh)->port_number))->port_type)
 
64
 
 
65
#ifdef CONFIG_TNC
 
66
/* Based on display port determine which mmio base to use:
 
67
 *       port_type == SDVO ==> use 0:3:0 device mmio
 
68
 *       port_type == LVDS ==> use 0:2:0 device mmio
 
69
 *       port_type == LPC  ==> use 0:31:0 device mmio
 
70
 */
 
71
#define MMIO_TNC(port_type) EMGD_MMIO(get_mmio_tnc(port_type))
 
72
 
 
73
#define READ_MMIO_REG_TNC(pt, reg) read_mmio_reg_tnc(pt, reg)
 
74
#define WRITE_MMIO_REG_TNC(pt, reg, value) write_mmio_reg_tnc(pt, reg, value)
 
75
 
 
76
/* Defined in micro_mode_tnc.c */
 
77
extern unsigned char *get_mmio_tnc(unsigned long port_type);
 
78
extern unsigned long read_mmio_reg_tnc(unsigned long port_type,
 
79
        unsigned long reg);
 
80
extern void write_mmio_reg_tnc(unsigned long port_type, unsigned long reg,
 
81
        unsigned long value);
 
82
#endif
 
83
 
 
84
 
 
85
/*
 
86
 * These are temporary macros used only within this header.
 
87
 * Individual config options use these macros to generate macros that look
 
88
 * like this:
 
89
 *
 
90
 * If CONFIG_FOO is defined
 
91
 *  OPT_FOO_SYMBOL(a)
 
92
 *  OPT_FOO_VALUE(a, b)
 
93
 *  OPT_FOO_VOID_CALL(fn)
 
94
 *  OPT_FOO_CALL(fn)
 
95
 */
 
96
#define OPTIONAL_VOID_CALL(fn) fn
 
97
#define OPTIONAL_CALL(fn)                       \
 
98
        {                                                               \
 
99
                int __ret;                                      \
 
100
                __ret = fn;                                     \
 
101
                if(__ret) {                                     \
 
102
                        EMGD_ERROR_EXIT("EXIT");        \
 
103
                        return __ret;                   \
 
104
                }                                                       \
 
105
        }
 
106
 
 
107
#define OPTIONAL_CALL_RET(ret, fn)      (ret) = (fn)
 
108
 
 
109
/*
 
110
 * Debug call macro should be used to call debug printing functions
 
111
 * that will only exist in debug builds.
 
112
 */
 
113
#ifdef DEBUG_BUILD_TYPE
 
114
#define OPT_DEBUG_SYMBOL(sym)      sym
 
115
#define OPT_DEBUG_VALUE(val, alt)  val
 
116
#define OPT_DEBUG_VOID_CALL(fn)    OPTIONAL_VOID_CALL(fn)
 
117
#define OPT_DEBUG_CALL(fn)         OPTIONAL_CALL(fn)
 
118
#define OPT_DEBUG_INLINE
 
119
#else
 
120
#define OPT_DEBUG_SYMBOL(sym)
 
121
#define OPT_DEBUG_VALUE(val, alt)  alt
 
122
#define OPT_DEBUG_VOID_CALL(fn)
 
123
#define OPT_DEBUG_CALL(fn)
 
124
#define OPT_DEBUG_INLINE           static __inline
 
125
#endif
 
126
 
 
127
/*
 
128
 * Micro Symbols are only used when CONFIG_MICRO is not defined.
 
129
 */
 
130
#ifndef CONFIG_MICRO
 
131
#define OPT_MICRO_SYMBOL(sym)         sym
 
132
#define OPT_MICRO_VALUE(val, alt)     val
 
133
#define OPT_MICRO_VOID_CALL(fn)       OPTIONAL_VOID_CALL(fn)
 
134
#define OPT_MICRO_CALL(fn)            OPTIONAL_CALL(fn)
 
135
#define OPT_MICRO_CALL_RET(ret, fn)   OPTIONAL_CALL_RET(ret, fn)
 
136
#else
 
137
#define OPT_MICRO_SYMBOL(sym)
 
138
#define OPT_MICRO_VALUE(val, alt)  alt
 
139
#define OPT_MICRO_VOID_CALL(fn)
 
140
#define OPT_MICRO_CALL(fn)
 
141
#define OPT_MICRO_CALL_RET(ret, fn)
 
142
#endif
 
143
 
 
144
 
 
145
#ifdef CONFIG_PLB
 
146
#define DISPATCH_PLB(p) {PCI_DEVICE_ID_VGA_PLB, p},
 
147
#else
 
148
#define DISPATCH_PLB(p)
 
149
#endif
 
150
#ifdef CONFIG_TNC
 
151
#define DISPATCH_TNC(p) {PCI_DEVICE_ID_VGA_TNC, p},
 
152
#define DISPATCH_TNC_A0(p) {PCI_DEVICE_ID_VGA_TNC_A0, p},
 
153
#define DISPATCH_LNC(p) {PCI_DEVICE_ID_VGA_LNC, p},
 
154
#else
 
155
#define DISPATCH_TNC(p)
 
156
#define DISPATCH_TNC_A0(p)
 
157
#define DISPATCH_LNC(p)
 
158
#endif
 
159
#define DISPATCH_END {0, NULL}
 
160
 
 
161
 
 
162
#endif // _UTILS_H_
 
163
 
 
164
/*----------------------------------------------------------------------------
 
165
 * File Revision History
 
166
 * $Id: utils.h,v 1.6 2010/08/06 17:50:21 rclovrie Exp $
 
167
 * $Source: /nfs/fm/proj/eia/cvsroot/koheo/linux/egd_drm/emgd/include/utils.h,v $
 
168
 *----------------------------------------------------------------------------
 
169
 */