Lines Matching +full:twisted +full:- +full:pair

2  * Copyright 2005-2006 Erik Waling
4 * Copyright 2007-2009 Stuart Bennett
33 #include <linux/io-mapping.h>
43 #define BIOSLOG(sip, fmt, arg...) NV_DEBUG(sip->dev, fmt, ##arg)
69 if (bios->major_version < 5) /* pre BIT */ in clkcmptable()
75 compareclk = ROM16(bios->data[clktable + compare_record_len * i]); in clkcmptable()
77 if (bios->major_version < 5) { in clkcmptable()
78 uint8_t tmdssub = bios->data[clktable + 2 + compare_record_len * i]; in clkcmptable()
79 scriptptr = ROM16(bios->data[bios->init_script_tbls_ptr + tmdssub * 2]); in clkcmptable()
81 scriptptr = ROM16(bios->data[clktable + 2 + compare_record_len * i]); in clkcmptable()
108 struct nvbios *bios = &drm->vbios; in call_lvds_manufacturer_script()
109 …uint8_t sub = bios->data[bios->fp.xlated_entry + script] + (bios->fp.link_c_increment && dcbent->o… in call_lvds_manufacturer_script()
110 uint16_t scriptofs = ROM16(bios->data[bios->init_script_tbls_ptr + sub * 2]); in call_lvds_manufacturer_script()
112 struct pci_dev *pdev = to_pci_dev(dev->dev); in call_lvds_manufacturer_script()
115 if (!bios->fp.xlated_entry || !sub || !scriptofs) in call_lvds_manufacturer_script()
116 return -EINVAL; in call_lvds_manufacturer_script()
118 run_digital_op_script(dev, scriptofs, dcbent, head, bios->fp.dual_link); in call_lvds_manufacturer_script()
121 /* off-on delay in ms */ in call_lvds_manufacturer_script()
122 mdelay(ROM16(bios->data[bios->fp.xlated_entry + 7])); in call_lvds_manufacturer_script()
127 (pdev->device == 0x0179 || pdev->device == 0x0189 || in call_lvds_manufacturer_script()
128 pdev->device == 0x0329)) in call_lvds_manufacturer_script()
129 nv_write_tmds(dev, dcbent->or, 0, 0x02, 0x72); in call_lvds_manufacturer_script()
140 * A bitmask byte and a dual-link transition pxclk value for use in in run_lvds_table()
148 struct nvbios *bios = &drm->vbios; in run_lvds_table()
149 unsigned int outputset = (dcbent->or == 4) ? 1 : 0; in run_lvds_table()
153 * For now we assume version 3.0 table - g80 support will need some in run_lvds_table()
159 return -ENOSYS; in run_lvds_table()
162 scriptptr = ROM16(bios->data[bios->fp.lvdsmanufacturerpointer + 7 + outputset * 2]); in run_lvds_table()
166 scriptptr = ROM16(bios->data[bios->fp.lvdsmanufacturerpointer + 11 + outputset * 2]); in run_lvds_table()
169 clktable = bios->fp.lvdsmanufacturerpointer + 15; in run_lvds_table()
170 if (dcbent->or == 4) in run_lvds_table()
173 if (dcbent->lvdsconf.use_straps_for_mode) { in run_lvds_table()
174 if (bios->fp.dual_link) in run_lvds_table()
176 if (bios->fp.if_is_24bit) in run_lvds_table()
180 int cmpval_24bit = (dcbent->or == 4) ? 4 : 1; in run_lvds_table()
182 if (bios->fp.dual_link) { in run_lvds_table()
187 if (bios->fp.strapless_is_24bit & cmpval_24bit) in run_lvds_table()
191 clktable = ROM16(bios->data[clktable]); in run_lvds_table()
194 return -ENOENT; in run_lvds_table()
201 return -ENOENT; in run_lvds_table()
203 run_digital_op_script(dev, scriptptr, dcbent, head, bios->fp.dual_link); in run_lvds_table()
217 struct nvif_object *device = &drm->client.device.object; in call_lvds_script()
218 struct nvbios *bios = &drm->vbios; in call_lvds_script()
219 uint8_t lvds_ver = bios->data[bios->fp.lvdsmanufacturerpointer]; in call_lvds_script()
223 if (bios->fp.last_script_invoc == (script << 1 | head) || !lvds_ver || in call_lvds_script()
227 if (!bios->fp.lvds_init_run) { in call_lvds_script()
228 bios->fp.lvds_init_run = true; in call_lvds_script()
232 if (script == LVDS_PANEL_ON && bios->fp.reset_after_pclk_change) in call_lvds_script()
234 if (script == LVDS_RESET && bios->fp.power_off_for_reset) in call_lvds_script()
239 /* don't let script change pll->head binding */ in call_lvds_script()
247 bios->fp.last_script_invoc = (script << 1 | head); in call_lvds_script()
275 if (bios->fp.lvdsmanufacturerpointer == 0x0) { in parse_lvds_manufacturer_table_header()
277 return -EINVAL; in parse_lvds_manufacturer_table_header()
280 lvds_ver = bios->data[bios->fp.lvdsmanufacturerpointer]; in parse_lvds_manufacturer_table_header()
285 recordlen = bios->data[bios->fp.lvdsmanufacturerpointer + 1]; in parse_lvds_manufacturer_table_header()
288 headerlen = bios->data[bios->fp.lvdsmanufacturerpointer + 1]; in parse_lvds_manufacturer_table_header()
291 return -EINVAL; in parse_lvds_manufacturer_table_header()
293 recordlen = bios->data[bios->fp.lvdsmanufacturerpointer + 2]; in parse_lvds_manufacturer_table_header()
296 headerlen = bios->data[bios->fp.lvdsmanufacturerpointer + 1]; in parse_lvds_manufacturer_table_header()
299 return -EINVAL; in parse_lvds_manufacturer_table_header()
301 recordlen = bios->data[bios->fp.lvdsmanufacturerpointer + 2]; in parse_lvds_manufacturer_table_header()
307 return -ENOSYS; in parse_lvds_manufacturer_table_header()
310 lth->lvds_ver = lvds_ver; in parse_lvds_manufacturer_table_header()
311 lth->headerlen = headerlen; in parse_lvds_manufacturer_table_header()
312 lth->recordlen = recordlen; in parse_lvds_manufacturer_table_header()
321 struct nvif_object *device = &drm->client.device.object; in get_fp_strap()
332 if (bios->major_version < 5 && bios->data[0x48] & 0x4) in get_fp_strap()
335 if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_MAXWELL) in get_fp_strap()
338 if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) in get_fp_strap()
352 if (bios->fp.fptablepointer == 0x0) { in parse_fp_mode_table()
355 bios->digital_min_front_porch = 0x4b; in parse_fp_mode_table()
359 fptable = &bios->data[bios->fp.fptablepointer]; in parse_fp_mode_table()
374 ofs = -1; in parse_fp_mode_table()
386 * RAMDAC_FP_HCRTC -> RAMDAC_FP_HSYNC_START gap in parse_fp_mode_table()
388 bios->digital_min_front_porch = fptable[4]; in parse_fp_mode_table()
389 ofs = -7; in parse_fp_mode_table()
395 return -ENOSYS; in parse_fp_mode_table()
398 if (!bios->is_mobile) /* !mobile only needs digital_min_front_porch */ in parse_fp_mode_table()
406 bios->fp.fpxlatetableptr = bios->fp.lvdsmanufacturerpointer + in parse_fp_mode_table()
408 bios->fp.xlatwidth = lth.recordlen; in parse_fp_mode_table()
410 if (bios->fp.fpxlatetableptr == 0x0) { in parse_fp_mode_table()
412 return -EINVAL; in parse_fp_mode_table()
417 fpindex = bios->data[bios->fp.fpxlatetableptr + in parse_fp_mode_table()
418 fpstrapping * bios->fp.xlatwidth]; in parse_fp_mode_table()
422 return -ENOENT; in parse_fp_mode_table()
427 bios->fp_no_ddc = fpstrapping != 0xf || fpindex != 0xf; in parse_fp_mode_table()
431 * panel using a strap-derived bios mode present. this condition in parse_fp_mode_table()
437 bios->fp.mode_ptr = bios->fp.fptablepointer + headerlen + in parse_fp_mode_table()
441 ROM16(bios->data[bios->fp.mode_ptr + 11]) + 1, in parse_fp_mode_table()
442 ROM16(bios->data[bios->fp.mode_ptr + 25]) + 1, in parse_fp_mode_table()
443 ROM16(bios->data[bios->fp.mode_ptr + 7]) * 10); in parse_fp_mode_table()
451 struct nvbios *bios = &drm->vbios; in nouveau_bios_fp_mode()
452 uint8_t *mode_entry = &bios->data[bios->fp.mode_ptr]; in nouveau_bios_fp_mode()
455 return bios->fp.mode_ptr; in nouveau_bios_fp_mode()
460 * bytes 1-2 are "panel type", including bits on whether Colour/mono, in nouveau_bios_fp_mode()
462 * bytes 3-6 are bits per colour in RGBX in nouveau_bios_fp_mode()
464 mode->clock = ROM16(mode_entry[7]) * 10; in nouveau_bios_fp_mode()
465 /* bytes 9-10 is HActive */ in nouveau_bios_fp_mode()
466 mode->hdisplay = ROM16(mode_entry[11]) + 1; in nouveau_bios_fp_mode()
468 * bytes 13-14 is HValid Start in nouveau_bios_fp_mode()
469 * bytes 15-16 is HValid End in nouveau_bios_fp_mode()
471 mode->hsync_start = ROM16(mode_entry[17]) + 1; in nouveau_bios_fp_mode()
472 mode->hsync_end = ROM16(mode_entry[19]) + 1; in nouveau_bios_fp_mode()
473 mode->htotal = ROM16(mode_entry[21]) + 1; in nouveau_bios_fp_mode()
474 /* bytes 23-24, 27-30 similarly, but vertical */ in nouveau_bios_fp_mode()
475 mode->vdisplay = ROM16(mode_entry[25]) + 1; in nouveau_bios_fp_mode()
476 mode->vsync_start = ROM16(mode_entry[31]) + 1; in nouveau_bios_fp_mode()
477 mode->vsync_end = ROM16(mode_entry[33]) + 1; in nouveau_bios_fp_mode()
478 mode->vtotal = ROM16(mode_entry[35]) + 1; in nouveau_bios_fp_mode()
479 mode->flags |= (mode_entry[37] & 0x10) ? in nouveau_bios_fp_mode()
481 mode->flags |= (mode_entry[37] & 0x1) ? in nouveau_bios_fp_mode()
484 * bytes 38-39 relate to spread spectrum settings in nouveau_bios_fp_mode()
485 * bytes 40-43 are something to do with PWM in nouveau_bios_fp_mode()
488 mode->status = MODE_OK; in nouveau_bios_fp_mode()
489 mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; in nouveau_bios_fp_mode()
491 return bios->fp.mode_ptr; in nouveau_bios_fp_mode()
499 * contains the dual-link transition pxclk (in 10s kHz), at byte 5 - if in nouveau_bios_parse_lvds_table()
513 * two bytes - the first as a config byte, the second for indexing the in nouveau_bios_parse_lvds_table()
518 * requiring tests against the native-mode pixel clock, cannot be done in nouveau_bios_parse_lvds_table()
519 * until later, when this function should be called with non-zero pxclk in nouveau_bios_parse_lvds_table()
522 struct nvbios *bios = &drm->vbios; in nouveau_bios_parse_lvds_table()
526 int ret, chip_version = bios->chip_version; in nouveau_bios_parse_lvds_table()
534 lvdsmanufacturerindex = bios->data[ in nouveau_bios_parse_lvds_table()
535 bios->fp.fpxlatemanufacturertableptr + in nouveau_bios_parse_lvds_table()
549 (bios->legacy.lvds_single_a_script_ptr & 1) ? in nouveau_bios_parse_lvds_table()
551 if (pxclk >= bios->fp.duallink_transition_clk) in nouveau_bios_parse_lvds_table()
554 /* nv28 behaviour (off-chip encoder) in nouveau_bios_parse_lvds_table()
567 if (pxclk >= bios->fp.duallink_transition_clk) in nouveau_bios_parse_lvds_table()
584 return -ENOSYS; in nouveau_bios_parse_lvds_table()
587 …lvdsofs = bios->fp.xlated_entry = bios->fp.lvdsmanufacturerpointer + lth.headerlen + lth.recordlen… in nouveau_bios_parse_lvds_table()
590 bios->fp.power_off_for_reset = bios->data[lvdsofs] & 1; in nouveau_bios_parse_lvds_table()
591 bios->fp.reset_after_pclk_change = bios->data[lvdsofs] & 2; in nouveau_bios_parse_lvds_table()
592 bios->fp.dual_link = bios->data[lvdsofs] & 4; in nouveau_bios_parse_lvds_table()
593 bios->fp.link_c_increment = bios->data[lvdsofs] & 8; in nouveau_bios_parse_lvds_table()
594 *if_is_24bit = bios->data[lvdsofs] & 16; in nouveau_bios_parse_lvds_table()
602 bios->fp.power_off_for_reset = true; in nouveau_bios_parse_lvds_table()
603 bios->fp.reset_after_pclk_change = true; in nouveau_bios_parse_lvds_table()
607 * over-written, and if_is_24bit isn't used in nouveau_bios_parse_lvds_table()
609 bios->fp.dual_link = bios->data[lvdsofs] & 1; in nouveau_bios_parse_lvds_table()
610 bios->fp.if_is_24bit = bios->data[lvdsofs] & 2; in nouveau_bios_parse_lvds_table()
611 bios->fp.strapless_is_24bit = bios->data[bios->fp.lvdsmanufacturerpointer + 4]; in nouveau_bios_parse_lvds_table()
612 bios->fp.duallink_transition_clk = ROM16(bios->data[bios->fp.lvdsmanufacturerpointer + 5]) * 10; in nouveau_bios_parse_lvds_table()
618 bios->fp.dual_link = (pxclk >= bios->fp.duallink_transition_clk); in nouveau_bios_parse_lvds_table()
620 *dl = bios->fp.dual_link; in nouveau_bios_parse_lvds_table()
637 struct nvif_object *device = &drm->client.device.object; in run_tmds_table()
638 struct nvbios *bios = &drm->vbios; in run_tmds_table()
639 int cv = bios->chip_version; in run_tmds_table()
643 /* pre-nv17 off-chip tmds uses scripts, post nv17 doesn't */ in run_tmds_table()
645 dcbent->location != DCB_LOC_ON_CHIP) in run_tmds_table()
648 switch (ffs(dcbent->or)) { in run_tmds_table()
650 clktable = bios->tmds.output0_script_ptr; in run_tmds_table()
654 clktable = bios->tmds.output1_script_ptr; in run_tmds_table()
660 return -EINVAL; in run_tmds_table()
667 return -ENOENT; in run_tmds_table()
670 /* don't let script change pll->head binding */ in run_tmds_table()
693 bios->init_script_tbls_ptr = ROM16(bios->data[offset]); in parse_script_table_pointers()
708 if (bitentry->length != 3) { in parse_bit_A_tbl_entry()
710 return -EINVAL; in parse_bit_A_tbl_entry()
713 load_table_ptr = ROM16(bios->data[bitentry->offset]); in parse_bit_A_tbl_entry()
717 return -EINVAL; in parse_bit_A_tbl_entry()
720 version = bios->data[load_table_ptr]; in parse_bit_A_tbl_entry()
725 return -ENOSYS; in parse_bit_A_tbl_entry()
728 headerlen = bios->data[load_table_ptr + 1]; in parse_bit_A_tbl_entry()
729 entrylen = bios->data[load_table_ptr + 2]; in parse_bit_A_tbl_entry()
730 num_entries = bios->data[load_table_ptr + 3]; in parse_bit_A_tbl_entry()
734 return -EINVAL; in parse_bit_A_tbl_entry()
737 /* First entry is normal dac, 2nd tv-out perhaps? */ in parse_bit_A_tbl_entry()
738 bios->dactestval = ROM32(bios->data[load_table_ptr + headerlen]) & 0x3ff; in parse_bit_A_tbl_entry()
747 * Starting at bitentry->offset: in parse_bit_display_tbl_entry()
749 * offset + 0 (16 bits): ??? table pointer - seems to have 18 byte in parse_bit_display_tbl_entry()
755 if (bitentry->length != 4) { in parse_bit_display_tbl_entry()
757 return -EINVAL; in parse_bit_display_tbl_entry()
760 bios->fp.fptablepointer = ROM16(bios->data[bitentry->offset + 2]); in parse_bit_display_tbl_entry()
774 if (bitentry->length < 14) { in parse_bit_init_tbl_entry()
776 return -EINVAL; in parse_bit_init_tbl_entry()
779 parse_script_table_pointers(bios, bitentry->offset); in parse_bit_init_tbl_entry()
800 if (bitentry->length < 6) { in parse_bit_i_tbl_entry()
802 return -EINVAL; in parse_bit_i_tbl_entry()
809 bios->feature_byte = bios->data[bitentry->offset + 5]; in parse_bit_i_tbl_entry()
810 bios->is_mobile = bios->feature_byte & FEATURE_MOBILE; in parse_bit_i_tbl_entry()
812 if (bitentry->length < 15) { in parse_bit_i_tbl_entry()
815 return -EINVAL; in parse_bit_i_tbl_entry()
818 daccmpoffset = ROM16(bios->data[bitentry->offset + 13]); in parse_bit_i_tbl_entry()
830 dacver = bios->data[daccmpoffset]; in parse_bit_i_tbl_entry()
831 dacheaderlen = bios->data[daccmpoffset + 1]; in parse_bit_i_tbl_entry()
836 return -ENOSYS; in parse_bit_i_tbl_entry()
839 bios->dactestval = ROM32(bios->data[daccmpoffset + dacheaderlen]); in parse_bit_i_tbl_entry()
840 bios->tvdactestval = ROM32(bios->data[daccmpoffset + dacheaderlen + 4]); in parse_bit_i_tbl_entry()
849 * Starting at bitentry->offset: in parse_bit_lvds_tbl_entry()
856 if (bitentry->length != 2) { in parse_bit_lvds_tbl_entry()
858 return -EINVAL; in parse_bit_lvds_tbl_entry()
865 bios->fp.lvdsmanufacturerpointer = ROM16(bios->data[bitentry->offset]); in parse_bit_lvds_tbl_entry()
881 * stuff that we don't use - their use currently unknown in parse_bit_M_tbl_entry()
888 if (bitentry->length < 0x5) in parse_bit_M_tbl_entry()
891 if (bitentry->version < 2) { in parse_bit_M_tbl_entry()
892 bios->ram_restrict_group_count = bios->data[bitentry->offset + 2]; in parse_bit_M_tbl_entry()
893 bios->ram_restrict_tbl_ptr = ROM16(bios->data[bitentry->offset + 3]); in parse_bit_M_tbl_entry()
895 bios->ram_restrict_group_count = bios->data[bitentry->offset + 0]; in parse_bit_M_tbl_entry()
896 bios->ram_restrict_tbl_ptr = ROM16(bios->data[bitentry->offset + 1]); in parse_bit_M_tbl_entry()
907 * Starting at bitentry->offset: in parse_bit_tmds_tbl_entry()
930 if (bitentry->length != 2) { in parse_bit_tmds_tbl_entry()
932 return -EINVAL; in parse_bit_tmds_tbl_entry()
935 tmdstableptr = ROM16(bios->data[bitentry->offset]); in parse_bit_tmds_tbl_entry()
938 return -EINVAL; in parse_bit_tmds_tbl_entry()
942 bios->data[tmdstableptr] >> 4, bios->data[tmdstableptr] & 0xf); in parse_bit_tmds_tbl_entry()
945 if (bios->data[tmdstableptr] != 0x11) in parse_bit_tmds_tbl_entry()
946 return -ENOSYS; in parse_bit_tmds_tbl_entry()
952 script1 = ROM16(bios->data[tmdstableptr + 7]); in parse_bit_tmds_tbl_entry()
953 script2 = ROM16(bios->data[tmdstableptr + 9]); in parse_bit_tmds_tbl_entry()
954 if (bios->data[script1] != 'q' || bios->data[script2] != 'q') in parse_bit_tmds_tbl_entry()
957 bios->tmds.output0_script_ptr = ROM16(bios->data[tmdstableptr + 11]); in parse_bit_tmds_tbl_entry()
958 bios->tmds.output1_script_ptr = ROM16(bios->data[tmdstableptr + 13]); in parse_bit_tmds_tbl_entry()
974 struct nvbios *bios = &drm->vbios; in bit_table()
977 if (bios->type != NVBIOS_BIT) in bit_table()
978 return -ENODEV; in bit_table()
980 entries = bios->data[bios->offset + 10]; in bit_table()
981 entry = &bios->data[bios->offset + 12]; in bit_table()
982 while (entries--) { in bit_table()
984 bit->id = entry[0]; in bit_table()
985 bit->version = entry[1]; in bit_table()
986 bit->length = ROM16(entry[2]); in bit_table()
987 bit->offset = ROM16(entry[4]); in bit_table()
988 bit->data = ROMPTR(dev, entry[4]); in bit_table()
992 entry += bios->data[bios->offset + 9]; in bit_table()
995 return -ENOENT; in bit_table()
1002 struct drm_device *dev = bios->dev; in parse_bit_table()
1006 if (bit_table(dev, table->id, &bitentry) == 0) in parse_bit_table()
1007 return table->parse_fn(dev, bios, &bitentry); in parse_bit_table()
1009 NV_INFO(drm, "BIT table '%c' not found\n", table->id); in parse_bit_table()
1010 return -ENOSYS; in parse_bit_table()
1020 * for use of bios->*_version or bios->feature_byte while parsing; in parse_bit_structure()
1027 if (bios->major_version >= 0x60) /* g80+ */ in parse_bit_structure()
1058 * offset + 54: index of I2C CRTC pair to use for CRT output in parse_bmp_structure()
1059 * offset + 55: index of I2C CRTC pair to use for TV output in parse_bmp_structure()
1060 * offset + 56: index of I2C CRTC pair to use for flat panel output in parse_bmp_structure()
1061 * offset + 58: write CRTC index for I2C pair 0 in parse_bmp_structure()
1062 * offset + 59: read CRTC index for I2C pair 0 in parse_bmp_structure()
1063 * offset + 60: write CRTC index for I2C pair 1 in parse_bmp_structure()
1064 * offset + 61: read CRTC index for I2C pair 1 in parse_bmp_structure()
1086 uint8_t *bmp = &bios->data[offset], bmp_version_major, bmp_version_minor; in parse_bmp_structure()
1091 bios->digital_min_front_porch = 0x4b; in parse_bmp_structure()
1092 bios->fmaxvco = 256000; in parse_bmp_structure()
1093 bios->fminvco = 128000; in parse_bmp_structure()
1094 bios->fp.duallink_transition_clk = 90000; in parse_bmp_structure()
1107 *(uint16_t *)&bios->data[0x36] = 0; in parse_bmp_structure()
1117 return -ENOSYS; in parse_bmp_structure()
1129 /* guessed - mem init tables added in this version */ in parse_bmp_structure()
1133 /* guessed - BMP I2C indices added in version 4*/ in parse_bmp_structure()
1165 return -EINVAL; in parse_bmp_structure()
1169 * Bit 4 seems to indicate either a mobile bios or a quadro card -- in parse_bmp_structure()
1170 * mobile behaviour consistent (nv11+), quadro only seen nv18gl-nv36gl in parse_bmp_structure()
1174 bios->feature_byte = bmp[9]; in parse_bmp_structure()
1177 bios->old_style_init = true; in parse_bmp_structure()
1180 legacy_scripts_offset -= 4; in parse_bmp_structure()
1181 bios->init_script_tbls_ptr = ROM16(bmp[legacy_scripts_offset]); in parse_bmp_structure()
1182 bios->extra_init_script_tbl_ptr = ROM16(bmp[legacy_scripts_offset + 2]); in parse_bmp_structure()
1185 bios->legacy.mem_init_tbl_ptr = ROM16(bmp[24]); in parse_bmp_structure()
1186 bios->legacy.sdr_seq_tbl_ptr = ROM16(bmp[26]); in parse_bmp_structure()
1187 bios->legacy.ddr_seq_tbl_ptr = ROM16(bmp[28]); in parse_bmp_structure()
1193 bios->legacy.i2c_indices.crt = bios->data[legacy_i2c_offset]; in parse_bmp_structure()
1194 bios->legacy.i2c_indices.tv = bios->data[legacy_i2c_offset + 1]; in parse_bmp_structure()
1195 bios->legacy.i2c_indices.panel = bios->data[legacy_i2c_offset + 2]; in parse_bmp_structure()
1198 bios->fmaxvco = ROM32(bmp[67]); in parse_bmp_structure()
1199 bios->fminvco = ROM32(bmp[71]); in parse_bmp_structure()
1204 bios->tmds.output0_script_ptr = ROM16(bmp[89]); in parse_bmp_structure()
1205 bios->tmds.output1_script_ptr = ROM16(bmp[91]); in parse_bmp_structure()
1211 bios->legacy.lvds_single_a_script_ptr = ROM16(bmp[95]); in parse_bmp_structure()
1214 bios->fp.fptablepointer = ROM16(bmp[105]); in parse_bmp_structure()
1215 bios->fp.fpxlatetableptr = ROM16(bmp[107]); in parse_bmp_structure()
1216 bios->fp.xlatwidth = 1; in parse_bmp_structure()
1219 bios->fp.lvdsmanufacturerpointer = ROM16(bmp[117]); in parse_bmp_structure()
1220 bios->fp.fpxlatemanufacturertableptr = ROM16(bmp[119]); in parse_bmp_structure()
1224 bios->pll_limit_tbl_ptr = ROM16(bmp[142]); in parse_bmp_structure()
1228 bios->fp.duallink_transition_clk = ROM16(bmp[156]) * 10; in parse_bmp_structure()
1237 for (i = 0; i <= (n - len); i++) { in findstr()
1254 if (drm->client.device.info.family > NV_DEVICE_INFO_V0_TNT) in olddcb_table()
1255 dcb = ROMPTR(dev, drm->vbios.data[0x36]); in olddcb_table()
1274 if (!memcmp(&dcb[-7], "DEV_REC", 7)) in olddcb_table()
1279 * always has the same single (crt) entry, even when tv-out in olddcb_table()
1330 int ret, idx = -1; in olddcb_outp_foreach()
1374 struct dcb_output *entry = &dcb->entry[dcb->entries]; in new_dcb_entry()
1377 entry->index = dcb->entries++; in new_dcb_entry()
1387 entry->type = type; in fabricate_dcb_output()
1388 entry->i2c_index = i2c; in fabricate_dcb_output()
1389 entry->heads = heads; in fabricate_dcb_output()
1391 entry->location = !DCB_LOC_ON_CHIP; /* ie OFF CHIP */ in fabricate_dcb_output()
1392 entry->or = or; in fabricate_dcb_output()
1402 entry->type = conn & 0xf; in parse_dcb20_entry()
1403 entry->i2c_index = (conn >> 4) & 0xf; in parse_dcb20_entry()
1404 entry->heads = (conn >> 8) & 0xf; in parse_dcb20_entry()
1405 entry->connector = (conn >> 12) & 0xf; in parse_dcb20_entry()
1406 entry->bus = (conn >> 16) & 0xf; in parse_dcb20_entry()
1407 entry->location = (conn >> 20) & 0x3; in parse_dcb20_entry()
1408 entry->or = (conn >> 24) & 0xf; in parse_dcb20_entry()
1410 switch (entry->type) { in parse_dcb20_entry()
1416 entry->crtconf.maxfreq = (dcb->version < 0x30) ? in parse_dcb20_entry()
1424 entry->lvdsconf.use_straps_for_mode = true; in parse_dcb20_entry()
1425 if (dcb->version < 0x22) { in parse_dcb20_entry()
1432 entry->lvdsconf.use_straps_for_mode = true; in parse_dcb20_entry()
1438 entry->lvdsconf.use_power_scripts = true; in parse_dcb20_entry()
1442 entry->lvdsconf.use_acpi_for_edid = true; in parse_dcb20_entry()
1444 entry->lvdsconf.use_power_scripts = true; in parse_dcb20_entry()
1445 entry->lvdsconf.sor.link = (conf & 0x00000030) >> 4; in parse_dcb20_entry()
1446 link = entry->lvdsconf.sor.link; in parse_dcb20_entry()
1453 if (dcb->version >= 0x40) in parse_dcb20_entry()
1463 if (dcb->version >= 0x30) in parse_dcb20_entry()
1464 entry->tvconf.has_component_output = conf & (0x8 << 4); in parse_dcb20_entry()
1466 entry->tvconf.has_component_output = false; in parse_dcb20_entry()
1471 entry->dpconf.sor.link = (conf & 0x00000030) >> 4; in parse_dcb20_entry()
1472 entry->extdev = (conf & 0x0000ff00) >> 8; in parse_dcb20_entry()
1475 entry->dpconf.link_bw = 162000; in parse_dcb20_entry()
1478 entry->dpconf.link_bw = 270000; in parse_dcb20_entry()
1481 entry->dpconf.link_bw = 540000; in parse_dcb20_entry()
1485 entry->dpconf.link_bw = 810000; in parse_dcb20_entry()
1491 entry->dpconf.link_nr = 4; in parse_dcb20_entry()
1495 entry->dpconf.link_nr = 2; in parse_dcb20_entry()
1498 entry->dpconf.link_nr = 1; in parse_dcb20_entry()
1501 link = entry->dpconf.sor.link; in parse_dcb20_entry()
1504 if (dcb->version >= 0x40) { in parse_dcb20_entry()
1505 entry->tmdsconf.sor.link = (conf & 0x00000030) >> 4; in parse_dcb20_entry()
1506 entry->extdev = (conf & 0x0000ff00) >> 8; in parse_dcb20_entry()
1507 link = entry->tmdsconf.sor.link; in parse_dcb20_entry()
1509 else if (dcb->version >= 0x30) in parse_dcb20_entry()
1510 entry->tmdsconf.slave_addr = (conf & 0x00000700) >> 8; in parse_dcb20_entry()
1511 else if (dcb->version >= 0x22) in parse_dcb20_entry()
1512 entry->tmdsconf.slave_addr = (conf & 0x00000070) >> 4; in parse_dcb20_entry()
1516 dcb->entries--; in parse_dcb20_entry()
1522 if (dcb->version < 0x40) { in parse_dcb20_entry()
1526 entry->duallink_possible = in parse_dcb20_entry()
1527 ((1 << (ffs(entry->or) - 1)) * 3 == entry->or); in parse_dcb20_entry()
1529 entry->duallink_possible = (entry->sorconf.link == 3); in parse_dcb20_entry()
1534 entry->i2c_upper_default = true; in parse_dcb20_entry()
1536 entry->hasht = (entry->extdev << 8) | (entry->location << 4) | in parse_dcb20_entry()
1537 entry->type; in parse_dcb20_entry()
1538 entry->hashm = (entry->heads << 8) | (link << 6) | entry->or; in parse_dcb20_entry()
1550 entry->type = DCB_OUTPUT_ANALOG; in parse_dcb15_entry()
1553 entry->type = DCB_OUTPUT_TV; in parse_dcb15_entry()
1558 entry->type = DCB_OUTPUT_LVDS; in parse_dcb15_entry()
1560 entry->type = DCB_OUTPUT_TMDS; in parse_dcb15_entry()
1563 entry->type = DCB_OUTPUT_LVDS; in parse_dcb15_entry()
1570 entry->i2c_index = (conn & 0x0003c000) >> 14; in parse_dcb15_entry()
1571 entry->heads = ((conn & 0x001c0000) >> 18) + 1; in parse_dcb15_entry()
1572 entry->or = entry->heads; /* same as heads, hopefully safe enough */ in parse_dcb15_entry()
1573 entry->location = (conn & 0x01e00000) >> 21; in parse_dcb15_entry()
1574 entry->bus = (conn & 0x0e000000) >> 25; in parse_dcb15_entry()
1575 entry->duallink_possible = false; in parse_dcb15_entry()
1577 switch (entry->type) { in parse_dcb15_entry()
1579 entry->crtconf.maxfreq = (conf & 0xffff) * 10; in parse_dcb15_entry()
1582 entry->tvconf.has_component_output = false; in parse_dcb15_entry()
1586 entry->lvdsconf.use_straps_for_mode = true; in parse_dcb15_entry()
1587 entry->lvdsconf.use_power_scripts = true; in parse_dcb15_entry()
1608 for (i = 0; i < dcb->entries; i++) { in merge_like_dcb_entries()
1609 struct dcb_output *ient = &dcb->entry[i]; in merge_like_dcb_entries()
1612 for (j = i + 1; j < dcb->entries; j++) { in merge_like_dcb_entries()
1613 struct dcb_output *jent = &dcb->entry[j]; in merge_like_dcb_entries()
1615 if (jent->type == 100) /* already merged entry */ in merge_like_dcb_entries()
1619 if (jent->i2c_index == ient->i2c_index && in merge_like_dcb_entries()
1620 jent->type == ient->type && in merge_like_dcb_entries()
1621 jent->location == ient->location && in merge_like_dcb_entries()
1622 jent->or == ient->or) { in merge_like_dcb_entries()
1625 ient->heads |= jent->heads; in merge_like_dcb_entries()
1626 jent->type = 100; /* dummy value */ in merge_like_dcb_entries()
1632 for (i = 0; i < dcb->entries; i++) { in merge_like_dcb_entries()
1633 if (dcb->entry[i].type == 100) in merge_like_dcb_entries()
1637 dcb->entry[newentries] = dcb->entry[i]; in merge_like_dcb_entries()
1638 dcb->entry[newentries].index = newentries; in merge_like_dcb_entries()
1643 dcb->entries = newentries; in merge_like_dcb_entries()
1650 struct dcb_table *dcb = &drm->vbios.dcb; in apply_dcb_encoder_quirks()
1681 /* XFX GT-240X-YA in apply_dcb_encoder_quirks()
1707 /* Some other twisted XFX board (rhbz#694914) in apply_dcb_encoder_quirks()
1710 * DVI-I connector actually point at two different ones, and in apply_dcb_encoder_quirks()
1738 /* fdo#50830: connector indices for VGA and DVI-I are backwards */ in apply_dcb_encoder_quirks()
1756 struct dcb_table *dcb = &bios->dcb; in fabricate_dcb_encoder_table()
1770 bios->legacy.i2c_indices.crt, 1, DCB_OUTPUT_B); in fabricate_dcb_encoder_table()
1772 if (nv04_tv_identify(dev, bios->legacy.i2c_indices.tv) >= 0) in fabricate_dcb_encoder_table()
1774 bios->legacy.i2c_indices.tv, in fabricate_dcb_encoder_table()
1777 else if (bios->tmds.output0_script_ptr || in fabricate_dcb_encoder_table()
1778 bios->tmds.output1_script_ptr) in fabricate_dcb_encoder_table()
1780 bios->legacy.i2c_indices.panel, in fabricate_dcb_encoder_table()
1788 struct dcb_table *dcb = &drm->vbios.dcb; in parse_dcb_entry()
1789 u32 conf = (dcb->version >= 0x20) ? ROM32(outp[4]) : ROM32(outp[6]); in parse_dcb_entry()
1798 if (dcb->version >= 0x20) in parse_dcb_entry()
1802 entry->id = idx; in parse_dcb_entry()
1807 /* Ignore the I2C index for on-chip TV-out, as there in parse_dcb_entry()
1811 if (entry->type == DCB_OUTPUT_TV && in parse_dcb_entry()
1812 entry->location == DCB_LOC_ON_CHIP) in parse_dcb_entry()
1813 entry->i2c_index = 0x0f; in parse_dcb_entry()
1822 struct dcb_table *dcbt = &bios->dcb; in dcb_fake_connectors()
1826 /* heuristic: if we ever get a non-zero connector field, assume in dcb_fake_connectors()
1831 if (!nv_match_device(bios->dev, 0x0392, 0x107d, 0x20a2)) { in dcb_fake_connectors()
1832 for (i = 0; i < dcbt->entries; i++) { in dcb_fake_connectors()
1833 if (dcbt->entry[i].connector) in dcb_fake_connectors()
1844 for (i = 0; i < dcbt->entries; i++) { in dcb_fake_connectors()
1845 u8 i2c = dcbt->entry[i].i2c_index; in dcb_fake_connectors()
1847 dcbt->entry[i].connector = idx++; in dcb_fake_connectors()
1851 dcbt->entry[i].connector = map[i2c] - 1; in dcb_fake_connectors()
1856 * table - just in case it has random, rather than stub, entries. in dcb_fake_connectors()
1859 u8 *conntab = olddcb_conntab(bios->dev); in dcb_fake_connectors()
1869 struct dcb_table *dcb = &bios->dcb; in parse_dcb_table()
1875 /* handle pre-DCB boards */ in parse_dcb_table()
1876 if (bios->type == NVBIOS_BMP) { in parse_dcb_table()
1881 return -EINVAL; in parse_dcb_table()
1886 dcb->version = dcbt[0]; in parse_dcb_table()
1891 * guarantees dcbent->index is the index of the entry in the rom image in parse_dcb_table()
1893 if (dcb->version < 0x21) in parse_dcb_table()
1897 idx = -1; in parse_dcb_table()
1924 struct nvif_object *device = &drm->client.device.object; in load_nv17_hwsq_ucode_entry()
1929 if (bios->data[hwsq_offset] <= entry) { in load_nv17_hwsq_ucode_entry()
1932 return -ENOENT; in load_nv17_hwsq_ucode_entry()
1935 bytes_to_write = bios->data[hwsq_offset + 1]; in load_nv17_hwsq_ucode_entry()
1939 return -EINVAL; in load_nv17_hwsq_ucode_entry()
1947 nvif_wr32(device, 0x00001304, ROM32(bios->data[hwsq_entry_offset])); in load_nv17_hwsq_ucode_entry()
1948 bytes_to_write -= 4; in load_nv17_hwsq_ucode_entry()
1952 nvif_wr32(device, 0x00001400 + i, ROM32(bios->data[hwsq_entry_offset + i + 4])); in load_nv17_hwsq_ucode_entry()
1976 hwsq_offset = findstr(bios->data, bios->length, hwsq_signature, sz); in load_nv17_hw_sequencer_ucode()
1987 struct nvbios *bios = &drm->vbios; in nouveau_bios_embedded_edid()
1994 if (bios->fp.edid) in nouveau_bios_embedded_edid()
1995 return bios->fp.edid; in nouveau_bios_embedded_edid()
1998 newoffset = findstr(&bios->data[offset], searchlen, in nouveau_bios_embedded_edid()
2003 if (!nv_cksum(&bios->data[offset], EDID1_LEN)) in nouveau_bios_embedded_edid()
2006 searchlen -= offset; in nouveau_bios_embedded_edid()
2012 return bios->fp.edid = &bios->data[offset]; in nouveau_bios_embedded_edid()
2019 struct nvbios *legacy = &drm->vbios; in NVInitVBIOS()
2022 spin_lock_init(&legacy->lock); in NVInitVBIOS()
2023 legacy->dev = dev; in NVInitVBIOS()
2025 legacy->data = bios->data; in NVInitVBIOS()
2026 legacy->length = bios->size; in NVInitVBIOS()
2027 legacy->major_version = bios->version.major; in NVInitVBIOS()
2028 legacy->chip_version = bios->version.chip; in NVInitVBIOS()
2029 if (bios->bit_offset) { in NVInitVBIOS()
2030 legacy->type = NVBIOS_BIT; in NVInitVBIOS()
2031 legacy->offset = bios->bit_offset; in NVInitVBIOS()
2032 return !parse_bit_structure(legacy, legacy->offset + 6); in NVInitVBIOS()
2034 if (bios->bmp_offset) { in NVInitVBIOS()
2035 legacy->type = NVBIOS_BMP; in NVInitVBIOS()
2036 legacy->offset = bios->bmp_offset; in NVInitVBIOS()
2037 return !parse_bmp_structure(dev, legacy, legacy->offset); in NVInitVBIOS()
2047 struct nvbios *bios = &drm->vbios; in nouveau_run_vbios_init()
2050 bios->state.crtchead = 0; in nouveau_run_vbios_init()
2052 if (bios->major_version < 5) /* BMP only */ in nouveau_run_vbios_init()
2055 if (bios->execute) { in nouveau_run_vbios_init()
2056 bios->fp.last_script_invoc = 0; in nouveau_run_vbios_init()
2057 bios->fp.lvds_init_run = false; in nouveau_run_vbios_init()
2069 if (drm->client.device.info.family >= NV_DEVICE_INFO_V0_TESLA) in nouveau_bios_posted()
2084 struct nvbios *bios = &drm->vbios; in nouveau_bios_init()
2088 if (!dev_is_pci(dev->dev) || in nouveau_bios_init()
2089 nvkm_gsp_rm(nvxx_device(drm)->gsp)) in nouveau_bios_init()
2093 return -ENODEV; in nouveau_bios_init()
2095 if (drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA) { in nouveau_bios_init()
2101 if (!bios->major_version) /* we don't run version 0 bios */ in nouveau_bios_init()
2105 bios->execute = false; in nouveau_bios_init()
2111 bios->execute = true; in nouveau_bios_init()
2119 if (bios->major_version < 5) in nouveau_bios_init()
2120 bios->is_mobile = NVReadVgaCrtc(dev, 0, NV_CIO_CRE_4B) & 0x40; in nouveau_bios_init()
2123 if (bios->is_mobile || bios->major_version >= 5) in nouveau_bios_init()
2127 bios->execute = true; in nouveau_bios_init()