~ubuntu-branches/ubuntu/trusty/xserver-xorg-video-nouveau/trusty

« back to all changes in this revision

Viewing changes to src/nv50_connector.c

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2008-07-06 20:26:53 UTC
  • Revision ID: james.westby@ubuntu.com-20080706202653-e99oiii765j3a0qn
Tags: upstream-0.0.10~git+20080706+b1f3169
ImportĀ upstreamĀ versionĀ 0.0.10~git+20080706+b1f3169

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2008 Maarten Maathuis
 
3
 *
 
4
 * Permission is hereby granted, free of charge, to any person obtaining a
 
5
 * copy of this software and associated documentation files (the "Software"),
 
6
 * to deal in the Software without restriction, including without limitation
 
7
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 
8
 * and/or sell copies of the Software, and to permit persons to whom the
 
9
 * Software is furnished to do so, subject to the following conditions:
 
10
 *
 
11
 * The above copyright notice and this permission notice shall be included in
 
12
 * all copies or substantial portions of the Software.
 
13
 *
 
14
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
15
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
16
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 
17
 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 
18
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
 
19
 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 
20
 * SOFTWARE.
 
21
 */
 
22
 
 
23
#include "nouveau_modeset.h"
 
24
#include "nouveau_crtc.h"
 
25
#include "nouveau_output.h"
 
26
#include "nouveau_connector.h"
 
27
 
 
28
static xf86MonPtr
 
29
NV50ConnectorGetEDID(nouveauConnectorPtr connector)
 
30
{
 
31
        ScrnInfoPtr pScrn = connector->scrn;
 
32
        NVPtr pNv = NVPTR(pScrn);
 
33
        xf86MonPtr rval = NULL;
 
34
 
 
35
        NVWrite(pNv, NV50_CONNECTOR_I2C_PORT(connector->pDDCBus->DriverPrivate.val), NV50_I2C_START);
 
36
 
 
37
        rval = xf86DoEDID_DDC2(pScrn->scrnIndex, connector->pDDCBus);
 
38
 
 
39
        NVWrite(pNv, NV50_CONNECTOR_I2C_PORT(connector->pDDCBus->DriverPrivate.val), NV50_I2C_STOP);
 
40
 
 
41
        return rval;
 
42
}
 
43
 
 
44
static xf86MonPtr
 
45
NV50ConnectorDDCDetect(nouveauConnectorPtr connector)
 
46
{
 
47
        ScrnInfoPtr pScrn = connector->scrn;
 
48
        xf86MonPtr ddc_mon;
 
49
 
 
50
        xf86DrvMsg(pScrn->scrnIndex, X_INFO, "NV50ConnectorDDCDetect is called.\n");
 
51
 
 
52
        if (!connector->pDDCBus)
 
53
                return FALSE;
 
54
 
 
55
        ddc_mon = NV50ConnectorGetEDID(connector);
 
56
 
 
57
        return ddc_mon;
 
58
}
 
59
 
 
60
static DisplayModePtr
 
61
NV50ConnectorGetDDCModes(nouveauConnectorPtr connector)
 
62
{
 
63
        ScrnInfoPtr pScrn = connector->scrn;
 
64
        xf86MonPtr ddc_mon;
 
65
 
 
66
        xf86DrvMsg(pScrn->scrnIndex, X_INFO, "NV50ConnectorGetDDCModes is called.\n");
 
67
 
 
68
        ddc_mon = NV50ConnectorGetEDID(connector);
 
69
 
 
70
        if (!ddc_mon)
 
71
                return NULL;
 
72
 
 
73
        return xf86DDCGetModes(pScrn->scrnIndex, ddc_mon);
 
74
}
 
75
 
 
76
void
 
77
NV50ConnectorInit(ScrnInfoPtr pScrn)
 
78
{
 
79
        int i;
 
80
        NVPtr pNv = NVPTR(pScrn);
 
81
 
 
82
        /* Maybe a bit overdone, because often only 3 or 4 connectors are present. */
 
83
        for (i = 0; i < MAX_NUM_DCB_ENTRIES; i++) {
 
84
                nouveauConnectorPtr connector = xnfcalloc(sizeof(nouveauConnectorRec), 1);
 
85
                connector->scrn = pScrn;
 
86
                connector->index = i;
 
87
 
 
88
                char connector_name[20];
 
89
                sprintf(connector_name, "Connector-%d", i);
 
90
                connector->name = xstrdup(connector_name);
 
91
 
 
92
                /* Function pointers. */
 
93
                connector->DDCDetect = NV50ConnectorDDCDetect;
 
94
                connector->GetDDCModes = NV50ConnectorGetDDCModes;
 
95
                connector->HotplugDetect = NULL;
 
96
 
 
97
                pNv->connector[i] = connector;
 
98
        }
 
99
}
 
100
 
 
101
void
 
102
NV50ConnectorDestroy(ScrnInfoPtr pScrn)
 
103
{
 
104
        int i;
 
105
        NVPtr pNv = NVPTR(pScrn);
 
106
 
 
107
        /* Maybe a bit overdone, because often only 3 or 4 connectors are present. */
 
108
        for (i = 0; i < MAX_NUM_DCB_ENTRIES; i++) {
 
109
                nouveauConnectorPtr connector = pNv->connector[i];
 
110
 
 
111
                xfree(connector->name);
 
112
                xfree(connector);
 
113
                pNv->connector[i] = NULL;
 
114
        }
 
115
}
 
116