38 #define NV_CIO_CRE_44_HEADA 0x0
39 #define NV_CIO_CRE_44_HEADB 0x3
40 #define FEATURE_MOBILE 0x10
44 #define BIOSLOG(sip, fmt, arg...) NV_DEBUG(sip->dev, fmt, ##arg)
45 #define LOG_OLD_VALUE(x)
61 for (i = 0; i <
length; i++)
72 int compare_record_len,
i = 0;
76 compare_record_len = 3;
78 compare_record_len = 4;
81 compareclk =
ROM16(bios->
data[clktable + compare_record_len * i]);
82 if (pxclk >= compareclk * 10) {
84 uint8_t tmdssub = bios->
data[clktable + 2 + compare_record_len *
i];
87 scriptptr =
ROM16(bios->
data[clktable + 2 + compare_record_len * i]);
102 NV_INFO(drm,
"0x%04X: Parsing digital output script table\n",
106 nouveau_bios_run_init_table(dev, scriptptr, dcbent, head);
118 if (!bios->
fp.xlated_entry || !sub || !scriptofs)
121 run_digital_op_script(dev, scriptofs, dcbent, head, bios->
fp.dual_link);
130 (dev->pci_device == 0x0179 || dev->pci_device == 0x0189 ||
131 dev->pci_device == 0x0329))
132 nv_write_tmds(dev, dcbent->
or, 0, 0x02, 0x72);
152 unsigned int outputset = (dcbent->
or == 4) ? 1 : 0;
165 scriptptr =
ROM16(bios->
data[bios->
fp.lvdsmanufacturerpointer + 7 + outputset * 2]);
169 scriptptr =
ROM16(bios->
data[bios->
fp.lvdsmanufacturerpointer + 11 + outputset * 2]);
172 clktable = bios->
fp.lvdsmanufacturerpointer + 15;
176 if (dcbent->
lvdsconf.use_straps_for_mode) {
177 if (bios->
fp.dual_link)
179 if (bios->
fp.if_is_24bit)
183 int cmpval_24bit = (dcbent->
or == 4) ? 4 : 1;
185 if (bios->
fp.dual_link) {
190 if (bios->
fp.strapless_is_24bit & cmpval_24bit)
196 NV_ERROR(drm,
"Pixel clock comparison table not found\n");
199 scriptptr = clkcmptable(bios, clktable, pxclk);
203 NV_ERROR(drm,
"LVDS output init script not found\n");
206 run_digital_op_script(dev, scriptptr, dcbent, head, bios->
fp.dual_link);
222 uint8_t lvds_ver = bios->
data[bios->
fp.lvdsmanufacturerpointer];
226 if (bios->
fp.last_script_invoc == (script << 1 | head) || !lvds_ver ||
227 (lvds_ver >= 0x30 && script ==
LVDS_INIT))
230 if (!bios->
fp.lvds_init_run) {
231 bios->
fp.lvds_init_run =
true;
237 if (script ==
LVDS_RESET && bios->
fp.power_off_for_reset)
240 NV_INFO(drm,
"Calling LVDS script %d:\n", script);
246 ret = call_lvds_manufacturer_script(dev, dcbent, head, script);
248 ret = run_lvds_table(dev, dcbent, head, script, pxclk);
250 bios->
fp.last_script_invoc = (script << 1 |
head);
274 uint8_t lvds_ver, headerlen, recordlen;
278 if (bios->
fp.lvdsmanufacturerpointer == 0x0) {
279 NV_ERROR(drm,
"Pointer to LVDS manufacturer table invalid\n");
283 lvds_ver = bios->
data[bios->
fp.lvdsmanufacturerpointer];
288 recordlen = bios->
data[bios->
fp.lvdsmanufacturerpointer + 1];
291 headerlen = bios->
data[bios->
fp.lvdsmanufacturerpointer + 1];
292 if (headerlen < 0x1f) {
293 NV_ERROR(drm,
"LVDS table header not understood\n");
296 recordlen = bios->
data[bios->
fp.lvdsmanufacturerpointer + 2];
299 headerlen = bios->
data[bios->
fp.lvdsmanufacturerpointer + 1];
300 if (headerlen < 0x7) {
301 NV_ERROR(drm,
"LVDS table header not understood\n");
304 recordlen = bios->
data[bios->
fp.lvdsmanufacturerpointer + 2];
308 "LVDS table revision %d.%d not currently supported\n",
309 lvds_ver >> 4, lvds_ver & 0xf);
335 return NVReadVgaCrtc5758(dev, 0, 0xf) & 0xf;
347 uint8_t fptable_ver, headerlen = 0, recordlen, fpentries = 0xf, fpindex;
348 int ret, ofs, fpstrapping;
351 if (bios->
fp.fptablepointer == 0x0) {
355 NV_ERROR(drm,
"Pointer to flat panel table invalid\n");
361 fptable = &bios->
data[bios->
fp.fptablepointer];
362 fptable_ver = fptable[0];
364 switch (fptable_ver) {
383 headerlen = fptable[1];
384 recordlen = fptable[2];
385 fpentries = fptable[3];
395 "FP table revision %d.%d not currently supported\n",
396 fptable_ver >> 4, fptable_ver & 0xf);
403 ret = parse_lvds_manufacturer_table_header(dev, bios, <h);
408 bios->
fp.fpxlatetableptr = bios->
fp.lvdsmanufacturerpointer +
412 if (bios->
fp.fpxlatetableptr == 0x0) {
413 NV_ERROR(drm,
"Pointer to flat panel xlat table invalid\n");
417 fpstrapping = get_fp_strap(dev, bios);
419 fpindex = bios->
data[bios->
fp.fpxlatetableptr +
420 fpstrapping * bios->
fp.xlatwidth];
422 if (fpindex > fpentries) {
423 NV_ERROR(drm,
"Bad flat panel table index\n");
429 bios->
fp_no_ddc = fpstrapping != 0xf || fpindex != 0xf;
436 if (fpstrapping == 0xf || fpindex == 0xf)
439 bios->
fp.mode_ptr = bios->
fp.fptablepointer + headerlen +
440 recordlen * fpindex + ofs;
442 NV_INFO(drm,
"BIOS FP mode: %dx%d (%dkHz pixel clock)\n",
457 return bios->
fp.mode_ptr;
481 mode->
flags |= (mode_entry[37] & 0x10) ?
483 mode->
flags |= (mode_entry[37] & 0x1) ?
493 return bios->
fp.mode_ptr;
525 int fpstrapping = get_fp_strap(dev, bios), lvdsmanufacturerindex = 0;
530 ret = parse_lvds_manufacturer_table_header(dev, bios, <h);
536 lvdsmanufacturerindex = bios->
data[
537 bios->
fp.fpxlatemanufacturertableptr +
544 if (chip_version < 0x25) {
550 lvdsmanufacturerindex =
551 (bios->
legacy.lvds_single_a_script_ptr & 1) ?
553 if (pxclk >= bios->
fp.duallink_transition_clk)
554 lvdsmanufacturerindex++;
555 }
else if (chip_version < 0x30) {
565 lvdsmanufacturerindex = 0;
568 lvdsmanufacturerindex = 0;
569 if (pxclk >= bios->
fp.duallink_transition_clk)
570 lvdsmanufacturerindex = 2;
572 lvdsmanufacturerindex = 3;
582 lvdsmanufacturerindex = fpstrapping;
585 NV_ERROR(drm,
"LVDS table revision not currently supported\n");
589 lvdsofs = bios->
fp.xlated_entry = bios->
fp.lvdsmanufacturerpointer + lth.
headerlen + lth.
recordlen * lvdsmanufacturerindex;
592 bios->
fp.power_off_for_reset = bios->
data[lvdsofs] & 1;
593 bios->
fp.reset_after_pclk_change = bios->
data[lvdsofs] & 2;
594 bios->
fp.dual_link = bios->
data[lvdsofs] & 4;
595 bios->
fp.link_c_increment = bios->
data[lvdsofs] & 8;
596 *if_is_24bit = bios->
data[lvdsofs] & 16;
604 bios->
fp.power_off_for_reset =
true;
605 bios->
fp.reset_after_pclk_change =
true;
611 bios->
fp.dual_link = bios->
data[lvdsofs] & 1;
612 bios->
fp.if_is_24bit = bios->
data[lvdsofs] & 2;
613 bios->
fp.strapless_is_24bit = bios->
data[bios->
fp.lvdsmanufacturerpointer + 4];
614 bios->
fp.duallink_transition_clk =
ROM16(bios->
data[bios->
fp.lvdsmanufacturerpointer + 5]) * 10;
620 bios->
fp.dual_link = (pxclk >= bios->
fp.duallink_transition_clk);
622 *dl = bios->
fp.dual_link;
635 if ((hash & 0x000000f0) != (dcb->
location << 4))
637 if ((hash & 0x0000000f) != dcb->
type)
639 if (!(hash & (dcb->
or << 16)))
646 if (hash & 0x00c00000) {
647 if (!(hash & (dcb->
sorconf.link << 22)))
689 if (!bios->
display.script_table_ptr) {
690 NV_ERROR(drm,
"No pointer to output script table\n");
701 if (table[0] != 0x20 && table[0] != 0x21) {
702 NV_ERROR(drm,
"Output script table version 0x%02x unknown\n",
737 NV_DEBUG(drm,
"Searching for output entry for %d %d %d\n",
739 for (i = 0; i < table[3]; i++) {
740 otable =
ROMPTR(dev, table[table[1] + (i * table[2])]);
746 NV_DEBUG(drm,
"failed to match any output table\n");
750 if (pclk < -2 || pclk > 0) {
752 for (i = 0; i < otable[5]; i++) {
753 if (
ROM16(otable[table[4] + i*6]) == type)
757 if (i == otable[5]) {
758 NV_ERROR(drm,
"Table 0x%04x not found for %d/%d, "
760 type, dcbent->
type, dcbent->
or);
766 script =
ROM16(otable[6]);
768 NV_DEBUG(drm,
"output script 0 not found\n");
772 NV_DEBUG(drm,
"0x%04X: parsing output script 0\n", script);
773 nouveau_bios_run_init_table(dev, script, dcbent, crtc);
776 script =
ROM16(otable[8]);
778 NV_DEBUG(drm,
"output script 1 not found\n");
782 NV_DEBUG(drm,
"0x%04X: parsing output script 1\n", script);
783 nouveau_bios_run_init_table(dev, script, dcbent, crtc);
787 script =
ROM16(otable[10]);
791 NV_DEBUG(drm,
"output script 2 not found\n");
795 NV_DEBUG(drm,
"0x%04X: parsing output script 2\n", script);
796 nouveau_bios_run_init_table(dev, script, dcbent, crtc);
799 script =
ROM16(otable[table[4] + i*6 + 2]);
801 script = clkcmptable(bios, script, pclk);
803 NV_DEBUG(drm,
"clock script 0 not found\n");
807 NV_DEBUG(drm,
"0x%04X: parsing clock script 0\n", script);
808 nouveau_bios_run_init_table(dev, script, dcbent, crtc);
811 script =
ROM16(otable[table[4] + i*6 + 4]);
813 script = clkcmptable(bios, script, -pclk);
815 NV_DEBUG(drm,
"clock script 1 not found\n");
819 NV_DEBUG(drm,
"0x%04X: parsing clock script 1\n", script);
820 nouveau_bios_run_init_table(dev, script, dcbent, crtc);
846 if (cv >= 0x17 && cv != 0x1a && cv != 0x20 &&
850 switch (
ffs(dcbent->
or)) {
852 clktable = bios->
tmds.output0_script_ptr;
856 clktable = bios->
tmds.output1_script_ptr;
861 NV_ERROR(drm,
"Pixel clock comparison table not found\n");
865 scriptptr = clkcmptable(bios, clktable, pxclk);
868 NV_ERROR(drm,
"TMDS output init script not found\n");
874 run_digital_op_script(dev, scriptptr, dcbent, head, pxclk >= 165000);
893 NV_INFO(drm,
"Bios version %02x.%02x.%02x.%02x\n",
894 bios->
data[offset + 3], bios->
data[offset + 2],
895 bios->
data[offset + 1], bios->
data[offset]);
933 if (bitentry->
length != 3) {
934 NV_ERROR(drm,
"Do not understand BIT A table\n");
940 if (load_table_ptr == 0x0) {
941 NV_DEBUG(drm,
"Pointer to BIT loadval table invalid\n");
945 version = bios->
data[load_table_ptr];
947 if (version != 0x10) {
948 NV_ERROR(drm,
"BIT loadval table version %d.%d not supported\n",
949 version >> 4, version & 0xF);
953 headerlen = bios->
data[load_table_ptr + 1];
954 entrylen = bios->
data[load_table_ptr + 2];
955 num_entries = bios->
data[load_table_ptr + 3];
957 if (headerlen != 4 || entrylen != 4 || num_entries != 2) {
958 NV_ERROR(drm,
"Do not understand BIT loadval table\n");
977 if (bitentry->
length < 10) {
978 NV_ERROR(drm,
"Do not understand BIT C table\n");
999 if (bitentry->
length != 4) {
1000 NV_ERROR(drm,
"Do not understand BIT display table\n");
1018 if (bitentry->
length < 14) {
1019 NV_ERROR(drm,
"Do not understand init table\n");
1023 parse_script_table_pointers(bios, bitentry->
offset);
1025 if (bitentry->
length >= 16)
1027 if (bitentry->
length >= 18)
1050 if (bitentry->
length < 6) {
1051 NV_ERROR(drm,
"BIT i table too short for needed information\n");
1055 parse_bios_version(dev, bios, bitentry->
offset);
1064 if (bitentry->
length < 15) {
1065 NV_WARN(drm,
"BIT i table not long enough for DAC load "
1066 "detection comparison table\n");
1082 dacver = bios->
data[daccmpoffset];
1083 dacheaderlen = bios->
data[daccmpoffset + 1];
1085 if (dacver != 0x00 && dacver != 0x10) {
1086 NV_WARN(drm,
"DAC load detection comparison table version "
1087 "%d.%d not known\n", dacver >> 4, dacver & 0xf);
1108 if (bitentry->
length != 2) {
1109 NV_ERROR(drm,
"Do not understand BIT LVDS table\n");
1140 if (bitentry->
length < 0x5)
1180 uint16_t tmdstableptr, script1, script2;
1182 if (bitentry->
length != 2) {
1183 NV_ERROR(drm,
"Do not understand BIT TMDS table\n");
1188 if (!tmdstableptr) {
1189 NV_ERROR(drm,
"Pointer to TMDS table invalid\n");
1193 NV_INFO(drm,
"TMDS table version %d.%d\n",
1194 bios->
data[tmdstableptr] >> 4, bios->
data[tmdstableptr] & 0xf);
1197 if (bios->
data[tmdstableptr] != 0x11)
1204 script1 =
ROM16(bios->
data[tmdstableptr + 7]);
1205 script2 =
ROM16(bios->
data[tmdstableptr + 9]);
1206 if (bios->
data[script1] !=
'q' || bios->
data[script2] !=
'q')
1207 NV_WARN(drm,
"TMDS table script pointers not stubbed\n");
1209 bios->
tmds.output0_script_ptr =
ROM16(bios->
data[tmdstableptr + 11]);
1210 bios->
tmds.output1_script_ptr =
ROM16(bios->
data[tmdstableptr + 13]);
1230 if (bitentry->
length != 3) {
1231 NV_ERROR(drm,
"Do not understand BIT U table\n");
1236 bios->
display.script_table_ptr = outputscripttableptr;
1245 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
1260 if (entry[0] ==
id) {
1284 return table->
parse_fn(dev, bios, &bitentry);
1286 NV_INFO(drm,
"BIT table '%c' not found\n", table->
id);
1291 parse_bit_structure(
struct nvbios *bios,
const uint16_t bitoffset)
1301 ret = parse_bit_table(bios, bitoffset, &
BIT_TABLE(
'i', i));
1305 parse_bit_table(bios, bitoffset, &
BIT_TABLE(
'A',
A));
1306 ret = parse_bit_table(bios, bitoffset, &
BIT_TABLE(
'C',
C));
1310 ret = parse_bit_table(bios, bitoffset, &
BIT_TABLE(
'I',
init));
1313 parse_bit_table(bios, bitoffset, &
BIT_TABLE(
'M',
M));
1314 parse_bit_table(bios, bitoffset, &
BIT_TABLE(
'L', lvds));
1315 parse_bit_table(bios, bitoffset, &
BIT_TABLE(
'T', tmds));
1316 parse_bit_table(bios, bitoffset, &
BIT_TABLE(
'U',
U));
1369 uint16_t legacy_scripts_offset, legacy_i2c_offset;
1375 bios->
fp.duallink_transition_clk = 90000;
1377 bmp_version_major = bmp[5];
1378 bmp_version_minor = bmp[6];
1380 NV_INFO(drm,
"BMP version %d.%d\n",
1381 bmp_version_major, bmp_version_minor);
1387 if (bmp_version_major < 5)
1395 if ((bmp_version_major < 5 && bmp_version_minor != 1) || bmp_version_major > 5) {
1396 NV_ERROR(drm,
"You have an unsupported BMP version. "
1397 "Please send in your bios\n");
1401 if (bmp_version_major == 0)
1404 else if (bmp_version_major == 1)
1406 else if (bmp_version_major == 2)
1408 else if (bmp_version_major == 3)
1411 else if (bmp_version_major == 4 || bmp_version_minor < 0x1)
1415 else if (bmp_version_minor < 0x6)
1417 else if (bmp_version_minor < 0x10)
1419 else if (bmp_version_minor == 0x10)
1421 else if (bmp_version_minor < 0x14)
1423 else if (bmp_version_minor < 0x24)
1430 else if (bmp_version_minor < 0x27)
1444 if (nv_cksum(bmp, 8)) {
1445 NV_ERROR(drm,
"Bad BMP checksum\n");
1457 parse_bios_version(dev, bios, offset + 10);
1459 if (bmp_version_major < 5 || bmp_version_minor < 0x10)
1461 legacy_scripts_offset = 18;
1462 if (bmp_version_major < 2)
1463 legacy_scripts_offset -= 4;
1467 if (bmp_version_major > 2) {
1473 legacy_i2c_offset = 0x48;
1475 legacy_i2c_offset = offset + 54;
1476 bios->
legacy.i2c_indices.crt = bios->
data[legacy_i2c_offset];
1477 bios->
legacy.i2c_indices.tv = bios->
data[legacy_i2c_offset + 1];
1478 bios->
legacy.i2c_indices.panel = bios->
data[legacy_i2c_offset + 2];
1480 if (bmplength > 74) {
1485 parse_script_table_pointers(bios, offset + 75);
1486 if (bmplength > 94) {
1487 bios->
tmds.output0_script_ptr =
ROM16(bmp[89]);
1488 bios->
tmds.output1_script_ptr =
ROM16(bmp[91]);
1494 bios->
legacy.lvds_single_a_script_ptr =
ROM16(bmp[95]);
1496 if (bmplength > 108) {
1497 bios->
fp.fptablepointer =
ROM16(bmp[105]);
1498 bios->
fp.fpxlatetableptr =
ROM16(bmp[107]);
1499 bios->
fp.xlatwidth = 1;
1501 if (bmplength > 120) {
1502 bios->
fp.lvdsmanufacturerpointer =
ROM16(bmp[117]);
1503 bios->
fp.fpxlatemanufacturertableptr =
ROM16(bmp[119]);
1505 if (bmplength > 143)
1508 if (bmplength > 157)
1509 bios->
fp.duallink_transition_clk =
ROM16(bmp[156]) * 10;
1518 for (i = 0; i <= (n - len); i++) {
1519 for (j = 0; j < len; j++)
1520 if (data[i + j] != str[j])
1535 if (nv_device(drm->
device)->card_type > NV_04)
1538 NV_WARN(drm,
"No DCB data found in VBIOS\n");
1542 if (dcb[0] >= 0x41) {
1543 NV_WARN(drm,
"DCB version 0x%02x unknown\n", dcb[0]);
1546 if (dcb[0] >= 0x30) {
1547 if (
ROM32(dcb[6]) == 0x4edcbdcb)
1550 if (dcb[0] >= 0x20) {
1551 if (
ROM32(dcb[4]) == 0x4edcbdcb)
1554 if (dcb[0] >= 0x15) {
1555 if (!
memcmp(&dcb[-7],
"DEV_REC", 7))
1575 NV_WARN(drm,
"No useful DCB data in VBIOS\n");
1579 NV_WARN(drm,
"DCB header validation failed\n");
1587 if (dcb && dcb[0] >= 0x30) {
1589 return dcb + dcb[1] + (idx * dcb[3]);
1591 if (dcb && dcb[0] >= 0x20) {
1593 u8 *
ent = dcb + 8 + (idx * 8);
1594 if (i2c && ent < i2c)
1597 if (dcb && dcb[0] >= 0x15) {
1599 u8 *
ent = dcb + 4 + (idx * 10);
1600 if (i2c && ent < i2c)
1614 if (
ROM32(outp[0]) == 0x00000000)
1616 if (
ROM32(outp[0]) == 0xffffffff)
1624 ret =
exec(dev, data, idx, outp);
1636 if (dcb && dcb[0] >= 0x30 && dcb[1] >= 0x16) {
1637 u8 *conntab =
ROMPTR(dev, dcb[0x14]);
1638 if (conntab && conntab[0] >= 0x30 && conntab[0] <= 0x40)
1648 if (conntab && idx < conntab[2])
1649 return conntab + conntab[1] + (idx * conntab[3]);
1663 static void fabricate_dcb_output(
struct dcb_table *dcb,
int type,
int i2c,
1666 struct dcb_output *entry = new_dcb_entry(dcb);
1682 entry->
type = conn & 0xf;
1684 entry->
heads = (conn >> 8) & 0xf;
1686 entry->
bus = (conn >> 16) & 0xf;
1687 entry->
location = (conn >> 20) & 0x3;
1688 entry->
or = (conn >> 24) & 0xf;
1690 switch (entry->
type) {
1697 (conf & 0xffff) * 10 :
1698 (conf & 0xff) * 10000;
1704 entry->
lvdsconf.use_straps_for_mode =
true;
1712 entry->
lvdsconf.use_straps_for_mode =
true;
1717 if (conf & 0x4 || conf & 0x8)
1718 entry->
lvdsconf.use_power_scripts =
true;
1722 entry->
lvdsconf.use_acpi_for_edid =
true;
1724 entry->
lvdsconf.use_power_scripts =
true;
1725 entry->
lvdsconf.sor.link = (conf & 0x00000030) >> 4;
1735 NV_ERROR(drm,
"Unknown LVDS configuration bits, "
1743 entry->
tvconf.has_component_output = conf & (0x8 << 4);
1745 entry->
tvconf.has_component_output =
false;
1750 entry->
dpconf.sor.link = (conf & 0x00000030) >> 4;
1751 switch ((conf & 0x00e00000) >> 21) {
1753 entry->
dpconf.link_bw = 162000;
1756 entry->
dpconf.link_bw = 270000;
1759 switch ((conf & 0x0f000000) >> 24) {
1761 entry->
dpconf.link_nr = 4;
1764 entry->
dpconf.link_nr = 2;
1767 entry->
dpconf.link_nr = 1;
1773 entry->
tmdsconf.sor.link = (conf & 0x00000030) >> 4;
1774 else if (dcb->
version >= 0x30)
1775 entry->
tmdsconf.slave_addr = (conf & 0x00000700) >> 8;
1776 else if (dcb->
version >= 0x22)
1777 entry->
tmdsconf.slave_addr = (conf & 0x00000070) >> 4;
1793 ((1 << (
ffs(entry->
or) - 1)) * 3 == entry->
or);
1799 if (conf & 0x100000)
1811 switch (conn & 0x0000000f) {
1829 NV_ERROR(drm,
"Unknown DCB type %d\n", conn & 0x0000000f);
1833 entry->
i2c_index = (conn & 0x0003c000) >> 14;
1834 entry->
heads = ((conn & 0x001c0000) >> 18) + 1;
1836 entry->
location = (conn & 0x01e00000) >> 21;
1837 entry->
bus = (conn & 0x0e000000) >> 25;
1840 switch (entry->
type) {
1842 entry->
crtconf.maxfreq = (conf & 0xffff) * 10;
1845 entry->
tvconf.has_component_output =
false;
1848 if ((conn & 0x00003f00) >> 8 != 0x10)
1849 entry->
lvdsconf.use_straps_for_mode =
true;
1850 entry->
lvdsconf.use_power_scripts =
true;
1869 int i, newentries = 0;
1871 for (i = 0; i < dcb->
entries; i++) {
1875 for (j = i + 1; j < dcb->
entries; j++) {
1878 if (jent->
type == 100)
1885 jent->
or == ient->
or) {
1886 NV_INFO(drm,
"Merging DCB entries %d and %d\n",
1895 for (i = 0; i < dcb->
entries; i++) {
1896 if (dcb->
entry[i].type == 100)
1899 if (newentries != i) {
1901 dcb->
entry[newentries].index = newentries;
1927 if (nv_match_device(dev, 0x040d, 0x1028, 0x019b)) {
1928 if (*conn == 0x02026312 && *conf == 0x00000020)
1937 if (nv_match_device(dev, 0x0201, 0x1462, 0x8851)) {
1938 if (*conn == 0xf2005014 && *conf == 0xffffffff) {
1948 if (nv_match_device(dev, 0x0ca3, 0x1682, 0x3003)) {
1979 if (nv_match_device(dev, 0x0615, 0x1682, 0x2605)) {
2002 if (nv_match_device(dev, 0x0421, 0x3842, 0xc793)) {
2003 if (idx == 0 && *conn == 0x02000300)
2006 if (idx == 1 && *conn == 0x04011310)
2009 if (idx == 2 && *conn == 0x02011312)
2020 int all_heads = (nv_two_heads(dev) ? 3 : 1);
2033 bios->
legacy.i2c_indices.crt, 1, 1);
2037 bios->
legacy.i2c_indices.tv,
2040 else if (bios->
tmds.output0_script_ptr ||
2041 bios->
tmds.output1_script_ptr)
2043 bios->
legacy.i2c_indices.panel,
2056 if (apply_dcb_encoder_quirks(dev, idx, &conn, &conf)) {
2057 struct dcb_output *entry = new_dcb_entry(dcb);
2059 NV_INFO(drm,
"DCB outp %02d: %08x %08x\n", idx, conn, conf);
2062 ret = parse_dcb20_entry(dev, dcb, conn, conf, entry);
2064 ret = parse_dcb15_entry(dev, dcb, conn, conf, entry);
2081 dcb_fake_connectors(
struct nvbios *bios)
2092 if (!nv_match_device(bios->
dev, 0x0392, 0x107d, 0x20a2)) {
2093 for (i = 0; i < dcbt->
entries; i++) {
2094 if (dcbt->
entry[i].connector)
2105 for (i = 0; i < dcbt->
entries; i++) {
2108 dcbt->
entry[
i].connector = idx++;
2112 dcbt->
entry[
i].connector = map[i2c] - 1;
2137 if (bios->
type == NVBIOS_BMP) {
2138 fabricate_dcb_encoder_table(dev, bios);
2145 NV_INFO(drm,
"DCB version %d.%d\n", dcbt[0] >> 4, dcbt[0] & 0xf);
2155 merge_like_dcb_entries(dev, dcb);
2163 if (conn[0] != 0xff) {
2164 NV_INFO(drm,
"DCB conn %02d: ", idx);
2171 dcb_fake_connectors(bios);
2175 static int load_nv17_hwsq_ucode_entry(
struct drm_device *dev,
struct nvbios *bios,
uint16_t hwsq_offset,
int entry)
2192 if (bios->
data[hwsq_offset] <= entry) {
2193 NV_ERROR(drm,
"Too few entries in HW sequencer table for "
2194 "requested entry\n");
2198 bytes_to_write = bios->
data[hwsq_offset + 1];
2200 if (bytes_to_write != 36) {
2201 NV_ERROR(drm,
"Unknown HW sequencer entry size\n");
2205 NV_INFO(drm,
"Loading NV17 power sequencing microcode\n");
2207 hwsq_entry_offset = hwsq_offset + 2 + entry * bytes_to_write;
2210 nv_wr32(device, 0x00001304,
ROM32(bios->
data[hwsq_entry_offset]));
2211 bytes_to_write -= 4;
2214 for (i = 0; i < bytes_to_write; i += 4)
2215 nv_wr32(device, 0x00001400 + i,
ROM32(bios->
data[hwsq_entry_offset + i + 4]));
2223 static int load_nv17_hw_sequencer_ucode(
struct drm_device *dev,
2235 const uint8_t hwsq_signature[] = {
'H',
'W',
'S',
'Q' };
2236 const int sz =
sizeof(hwsq_signature);
2239 hwsq_offset = findstr(bios->
data, bios->
length, hwsq_signature, sz);
2244 return load_nv17_hwsq_ucode_entry(dev, bios, hwsq_offset + sz, 0);
2252 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00 };
2258 return bios->
fp.edid;
2261 newoffset = findstr(&bios->
data[offset], searchlen,
2265 offset += newoffset;
2273 NV_INFO(drm,
"Found EDID in BIOS\n");
2278 static bool NVInitVBIOS(
struct drm_device *dev)
2292 static int nouveau_parse_vbios_struct(
struct drm_device *dev)
2296 const uint8_t bit_signature[] = { 0xff, 0xb8,
'B',
'I',
'T' };
2297 const uint8_t bmp_signature[] = { 0xff, 0x7f,
'N',
'V', 0x0 };
2301 bit_signature,
sizeof(bit_signature));
2303 NV_INFO(drm,
"BIT BIOS found\n");
2306 return parse_bit_structure(bios, offset + 6);
2310 bmp_signature,
sizeof(bmp_signature));
2312 NV_INFO(drm,
"BMP BIOS found\n");
2315 return parse_bmp_structure(dev, bios, offset);
2318 NV_ERROR(drm,
"No known BIOS signature found\n");
2330 bios->
state.crtchead = 0;
2333 load_nv17_hw_sequencer_ucode(dev, bios);
2336 bios->
fp.last_script_invoc = 0;
2337 bios->
fp.lvds_init_run =
false;
2340 if (nv_device(drm->
device)->card_type >= NV_50) {
2341 for (i = 0; bios->
execute && i < bios->
dcb.entries; i++) {
2343 &bios->
dcb.entry[i], -1);
2356 if (nv_device(drm->
device)->card_type >= NV_50) {
2357 if (NVReadVgaCrtc(dev, 0, 0x00) == 0 &&
2358 NVReadVgaCrtc(dev, 0, 0x1a) == 0)
2363 htotal = NVReadVgaCrtc(dev, 0, 0x06);
2364 htotal |= (NVReadVgaCrtc(dev, 0, 0x07) & 0x01) << 8;
2365 htotal |= (NVReadVgaCrtc(dev, 0, 0x07) & 0x20) << 4;
2366 htotal |= (NVReadVgaCrtc(dev, 0, 0x25) & 0x01) << 10;
2367 htotal |= (NVReadVgaCrtc(dev, 0, 0x41) & 0x01) << 11;
2369 return (htotal != 0);
2379 if (!NVInitVBIOS(dev))
2382 ret = nouveau_parse_vbios_struct(dev);
2386 ret = parse_dcb_table(dev, bios);
2397 if (!nouveau_bios_posted(dev)) {
2398 NV_INFO(drm,
"Adaptor not initialised, "
2399 "running VBIOS init tables.\n");
2413 ret = parse_fp_mode_table(dev, bios);