2 * Copyright 2012 Red Hat Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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 COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
25 #include <core/device.h>
27 #include <subdev/bios.h>
28 #include <subdev/bios/dcb.h>
29 #include <subdev/bios/conn.h>
32 nvbios_connTe(struct nouveau_bios *bios, u8 *ver, u8 *hdr, u8 *cnt, u8 *len)
34 u32 dcb = dcb_table(bios, ver, hdr, cnt, len);
35 if (dcb && *ver >= 0x30 && *hdr >= 0x16) {
36 u32 data = nv_ro16(bios, dcb + 0x14);
38 *ver = nv_ro08(bios, data + 0);
39 *hdr = nv_ro08(bios, data + 1);
40 *cnt = nv_ro08(bios, data + 2);
41 *len = nv_ro08(bios, data + 3);
49 nvbios_connTp(struct nouveau_bios *bios, u8 *ver, u8 *hdr, u8 *cnt, u8 *len,
50 struct nvbios_connT *info)
52 u32 data = nvbios_connTe(bios, ver, hdr, cnt, len);
53 memset(info, 0x00, sizeof(*info));
54 switch (!!data * *ver) {
65 nvbios_connEe(struct nouveau_bios *bios, u8 idx, u8 *ver, u8 *len)
68 u32 data = nvbios_connTe(bios, ver, &hdr, &cnt, len);
69 if (data && idx < cnt)
70 return data + hdr + (idx * *len);
75 nvbios_connEp(struct nouveau_bios *bios, u8 idx, u8 *ver, u8 *len,
76 struct nvbios_connE *info)
78 u32 data = nvbios_connEe(bios, idx, ver, len);
79 memset(info, 0x00, sizeof(*info));
80 switch (!!data * *ver) {
83 info->type = nv_ro08(bios, data + 0x00);
84 info->location = nv_ro08(bios, data + 0x01) & 0x0f;
85 info->hpd = (nv_ro08(bios, data + 0x01) & 0x30) >> 4;
86 info->dp = (nv_ro08(bios, data + 0x01) & 0xc0) >> 6;
89 info->hpd |= (nv_ro08(bios, data + 0x02) & 0x03) << 2;
90 info->dp |= nv_ro08(bios, data + 0x02) & 0x0c;
91 info->di = (nv_ro08(bios, data + 0x02) & 0xf0) >> 4;
92 info->hpd |= (nv_ro08(bios, data + 0x03) & 0x07) << 4;
93 info->sr = (nv_ro08(bios, data + 0x03) & 0x08) >> 3;
94 info->lcdid = (nv_ro08(bios, data + 0x03) & 0x70) >> 4;