summaryrefslogtreecommitdiff
path: root/src/smi_output.c
blob: 43fe34326412b511bc6f9eed60688e6d3c267280 (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
/*
Copyright (C) 1994-1999 The XFree86 Project, Inc.  All Rights Reserved.
Copyright (C) 2000 Silicon Motion, Inc.  All Rights Reserved.
Copyright (C) 2008 Francisco Jerez. All Rights Reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT-
NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the names of The XFree86 Project and
Silicon Motion shall not be used in advertising or otherwise to promote the
sale, use or other dealings in this Software without prior written
authorization from The XFree86 Project or Silicon Motion.
*/

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "smi.h"
#include "smi_crtc.h"
#include "smilynx.h"
#include "smi_501.h"

static void
SMI_OutputCreateResources(xf86OutputPtr output)
{
    ENTER();
    /* Nothing */
    LEAVE();
}

static int
SMI_OutputModeValid(xf86OutputPtr output, DisplayModePtr mode)
{
    ScrnInfoPtr pScrn = output->scrn;
    SMIPtr pSmi = SMIPTR(pScrn);

    ENTER();

    if (pSmi->lcd &&
	(mode->HDisplay > pSmi->lcdWidth || mode->VDisplay > pSmi->lcdHeight))
	RETURN(MODE_PANEL);

    if (!(((mode->HDisplay == 1280) && (mode->VDisplay == 1024)) ||
	  ((mode->HDisplay == 1024) && (mode->VDisplay == 768)) ||
	  ((mode->HDisplay == 800) && (mode->VDisplay == 600)) ||
	  ((mode->HDisplay == 640) && (mode->VDisplay == 480)) ||
	  ((mode->HDisplay == 320) && (mode->VDisplay == 240)) ||
	  ((mode->HDisplay == 400) && (mode->VDisplay == 300)) ||
	  ((mode->HDisplay == 1280) && (mode->VDisplay == 960)) ||
	  ((mode->HDisplay == 1280) && (mode->VDisplay == 768)) ||
	  ((mode->HDisplay == 1024) && (mode->VDisplay == 600)) ||
	  ((mode->HDisplay == 800) && (mode->VDisplay == 480)) ||
	  ((mode->HDisplay == 720) && (mode->VDisplay == 540)) ||
	  ((mode->HDisplay == 720) && (mode->VDisplay == 480))))
	RETURN(MODE_BAD_WIDTH);


    if((mode->Clock < pSmi->clockRange.minClock) ||
       (mode->Clock > pSmi->clockRange.maxClock) ||
       ((mode->Flags & V_INTERLACE) && !pSmi->clockRange.interlaceAllowed) ||
       ((mode->Flags & V_DBLSCAN) && (mode->VScan > 1) && !pSmi->clockRange.doubleScanAllowed)){
	RETURN(MODE_CLOCK_RANGE);
    }


    RETURN(MODE_OK);
}

static Bool
SMI_OutputModeFixup(xf86OutputPtr output, DisplayModePtr mode, DisplayModePtr adjusted_mode)
{
    ENTER();

    /* Nothing */

    RETURN(TRUE);
}

static void
SMI_OutputPrepare(xf86OutputPtr output)
{
    ENTER();

    /* Nothing */

    LEAVE();
}

static void
SMI_OutputCommit(xf86OutputPtr output)
{
    ENTER();

    output->funcs->dpms(output,DPMSModeOn);

    LEAVE();
}

static void
SMI_OutputModeSet(xf86OutputPtr output, DisplayModePtr mode, DisplayModePtr adjusted_mode)
{
    ENTER();

    /* Nothing */

    LEAVE();
}

static xf86OutputStatus
SMI_OutputDetect(xf86OutputPtr output)
{
    ENTER();

    RETURN(XF86OutputStatusUnknown);
}

xf86OutputStatus
SMI_OutputDetect_lcd(xf86OutputPtr output)
{
    ENTER();

    RETURN(XF86OutputStatusConnected);
}

DisplayModePtr
SMI_OutputGetModes_native(xf86OutputPtr output)
{
    SMIPtr pSmi = SMIPTR(output->scrn);
    ENTER();

#ifdef HAVE_XMODES
    RETURN(xf86CVTMode(pSmi->lcdWidth, pSmi->lcdHeight, 60.0f, FALSE, FALSE));
#else
    RETURN(NULL);
#endif
}



static void
SMI_OutputDestroy(xf86OutputPtr output)
{
    ENTER();

    /* Nothing */

    LEAVE();
}

void
SMI_OutputFuncsInit_base(xf86OutputFuncsPtr outputFuncs)
{
    memset(outputFuncs,0,sizeof(outputFuncs));
    outputFuncs->create_resources = SMI_OutputCreateResources;
    outputFuncs->mode_valid = SMI_OutputModeValid;
    outputFuncs->mode_fixup = SMI_OutputModeFixup;
    outputFuncs->prepare = SMI_OutputPrepare;
    outputFuncs->commit = SMI_OutputCommit;
    outputFuncs->mode_set = SMI_OutputModeSet;
    outputFuncs->detect = SMI_OutputDetect;
    outputFuncs->destroy = SMI_OutputDestroy;
}

Bool
SMI_OutputPreInit(ScrnInfoPtr pScrn)
{
    SMIPtr pSmi = SMIPTR(pScrn);

    ENTER();

    if(SMI_MSOC_SERIES(pSmi->Chipset)){
	RETURN( SMI501_OutputPreInit(pScrn) );
    }else{
	RETURN( SMILynx_OutputPreInit(pScrn) );
    }
}