aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2010-02-23 18:56:18 -0500
committerBen Skeggs <bskeggs@redhat.com>2010-02-25 00:09:19 -0500
commit7f245b20e30515264b94f6373ef7d721155990a4 (patch)
tree51c730665e69d92e64eb7dbbbb00ed3cc2480603 /drivers/gpu
parenta6678b2ace023912000119a14eeb39a56050bc7c (diff)
drm/nouveau: merge parsed_dcb and bios_parsed_dcb into dcb_table
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bios.c148
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bios.h16
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_i2c.c6
-rw-r--r--drivers/gpu/drm/nouveau/nv04_display.c2
-rw-r--r--drivers/gpu/drm/nouveau/nv04_tv.c2
-rw-r--r--drivers/gpu/drm/nouveau/nv50_display.c6
6 files changed, 85 insertions, 95 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
index ab0ec225140e..e3baa84df62c 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bios.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
@@ -700,7 +700,7 @@ static int dcb_entry_idx_from_crtchead(struct drm_device *dev)
700 700
701 uint8_t dcb_entry = NVReadVgaCrtc5758(dev, bios->state.crtchead, 0); 701 uint8_t dcb_entry = NVReadVgaCrtc5758(dev, bios->state.crtchead, 0);
702 702
703 if (dcb_entry > bios->bdcb.dcb.entries) { 703 if (dcb_entry > bios->dcb.entries) {
704 NV_ERROR(dev, "CR58 doesn't have a valid DCB entry currently " 704 NV_ERROR(dev, "CR58 doesn't have a valid DCB entry currently "
705 "(%02X)\n", dcb_entry); 705 "(%02X)\n", dcb_entry);
706 dcb_entry = 0x7f; /* unused / invalid marker */ 706 dcb_entry = 0x7f; /* unused / invalid marker */
@@ -713,25 +713,26 @@ static struct nouveau_i2c_chan *
713init_i2c_device_find(struct drm_device *dev, int i2c_index) 713init_i2c_device_find(struct drm_device *dev, int i2c_index)
714{ 714{
715 struct drm_nouveau_private *dev_priv = dev->dev_private; 715 struct drm_nouveau_private *dev_priv = dev->dev_private;
716 struct bios_parsed_dcb *bdcb = &dev_priv->VBIOS.bdcb; 716 struct dcb_table *dcb = &dev_priv->VBIOS.dcb;
717 717
718 if (i2c_index == 0xff) { 718 if (i2c_index == 0xff) {
719 /* note: dcb_entry_idx_from_crtchead needs pre-script set-up */ 719 /* note: dcb_entry_idx_from_crtchead needs pre-script set-up */
720 int idx = dcb_entry_idx_from_crtchead(dev), shift = 0; 720 int idx = dcb_entry_idx_from_crtchead(dev), shift = 0;
721 int default_indices = bdcb->i2c_default_indices; 721 int default_indices = dcb->i2c_default_indices;
722 722
723 if (idx != 0x7f && bdcb->dcb.entry[idx].i2c_upper_default) 723 if (idx != 0x7f && dcb->entry[idx].i2c_upper_default)
724 shift = 4; 724 shift = 4;
725 725
726 i2c_index = (default_indices >> shift) & 0xf; 726 i2c_index = (default_indices >> shift) & 0xf;
727 } 727 }
728 if (i2c_index == 0x80) /* g80+ */ 728 if (i2c_index == 0x80) /* g80+ */
729 i2c_index = bdcb->i2c_default_indices & 0xf; 729 i2c_index = dcb->i2c_default_indices & 0xf;
730 730
731 return nouveau_i2c_find(dev, i2c_index); 731 return nouveau_i2c_find(dev, i2c_index);
732} 732}
733 733
734static uint32_t get_tmds_index_reg(struct drm_device *dev, uint8_t mlv) 734static uint32_t
735get_tmds_index_reg(struct drm_device *dev, uint8_t mlv)
735{ 736{
736 /* 737 /*
737 * For mlv < 0x80, it is an index into a table of TMDS base addresses. 738 * For mlv < 0x80, it is an index into a table of TMDS base addresses.
@@ -744,6 +745,7 @@ static uint32_t get_tmds_index_reg(struct drm_device *dev, uint8_t mlv)
744 */ 745 */
745 746
746 struct drm_nouveau_private *dev_priv = dev->dev_private; 747 struct drm_nouveau_private *dev_priv = dev->dev_private;
748 struct nvbios *bios = &dev_priv->VBIOS;
747 const int pramdac_offset[13] = { 749 const int pramdac_offset[13] = {
748 0, 0, 0x8, 0, 0x2000, 0, 0, 0, 0x2008, 0, 0, 0, 0x2000 }; 750 0, 0, 0x8, 0, 0x2000, 0, 0, 0, 0x2008, 0, 0, 0, 0x2000 };
749 const uint32_t pramdac_table[4] = { 751 const uint32_t pramdac_table[4] = {
@@ -756,8 +758,7 @@ static uint32_t get_tmds_index_reg(struct drm_device *dev, uint8_t mlv)
756 dcb_entry = dcb_entry_idx_from_crtchead(dev); 758 dcb_entry = dcb_entry_idx_from_crtchead(dev);
757 if (dcb_entry == 0x7f) 759 if (dcb_entry == 0x7f)
758 return 0; 760 return 0;
759 dacoffset = pramdac_offset[ 761 dacoffset = pramdac_offset[bios->dcb.entry[dcb_entry].or];
760 dev_priv->VBIOS.bdcb.dcb.entry[dcb_entry].or];
761 if (mlv == 0x81) 762 if (mlv == 0x81)
762 dacoffset ^= 8; 763 dacoffset ^= 8;
763 return 0x6808b0 + dacoffset; 764 return 0x6808b0 + dacoffset;
@@ -2574,19 +2575,19 @@ init_gpio(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
2574 2575
2575 const uint32_t nv50_gpio_reg[4] = { 0xe104, 0xe108, 0xe280, 0xe284 }; 2576 const uint32_t nv50_gpio_reg[4] = { 0xe104, 0xe108, 0xe280, 0xe284 };
2576 const uint32_t nv50_gpio_ctl[2] = { 0xe100, 0xe28c }; 2577 const uint32_t nv50_gpio_ctl[2] = { 0xe100, 0xe28c };
2577 const uint8_t *gpio_table = &bios->data[bios->bdcb.gpio_table_ptr]; 2578 const uint8_t *gpio_table = &bios->data[bios->dcb.gpio_table_ptr];
2578 const uint8_t *gpio_entry; 2579 const uint8_t *gpio_entry;
2579 int i; 2580 int i;
2580 2581
2581 if (!iexec->execute) 2582 if (!iexec->execute)
2582 return 1; 2583 return 1;
2583 2584
2584 if (bios->bdcb.version != 0x40) { 2585 if (bios->dcb.version != 0x40) {
2585 NV_ERROR(bios->dev, "DCB table not version 4.0\n"); 2586 NV_ERROR(bios->dev, "DCB table not version 4.0\n");
2586 return 0; 2587 return 0;
2587 } 2588 }
2588 2589
2589 if (!bios->bdcb.gpio_table_ptr) { 2590 if (!bios->dcb.gpio_table_ptr) {
2590 NV_WARN(bios->dev, "Invalid pointer to INIT_8E table\n"); 2591 NV_WARN(bios->dev, "Invalid pointer to INIT_8E table\n");
2591 return 0; 2592 return 0;
2592 } 2593 }
@@ -4796,10 +4797,10 @@ static int parse_bmp_structure(struct drm_device *dev, struct nvbios *bios, unsi
4796 uint16_t legacy_scripts_offset, legacy_i2c_offset; 4797 uint16_t legacy_scripts_offset, legacy_i2c_offset;
4797 4798
4798 /* load needed defaults in case we can't parse this info */ 4799 /* load needed defaults in case we can't parse this info */
4799 bios->bdcb.dcb.i2c[0].write = NV_CIO_CRE_DDC_WR__INDEX; 4800 bios->dcb.i2c[0].write = NV_CIO_CRE_DDC_WR__INDEX;
4800 bios->bdcb.dcb.i2c[0].read = NV_CIO_CRE_DDC_STATUS__INDEX; 4801 bios->dcb.i2c[0].read = NV_CIO_CRE_DDC_STATUS__INDEX;
4801 bios->bdcb.dcb.i2c[1].write = NV_CIO_CRE_DDC0_WR__INDEX; 4802 bios->dcb.i2c[1].write = NV_CIO_CRE_DDC0_WR__INDEX;
4802 bios->bdcb.dcb.i2c[1].read = NV_CIO_CRE_DDC0_STATUS__INDEX; 4803 bios->dcb.i2c[1].read = NV_CIO_CRE_DDC0_STATUS__INDEX;
4803 bios->pub.digital_min_front_porch = 0x4b; 4804 bios->pub.digital_min_front_porch = 0x4b;
4804 bios->fmaxvco = 256000; 4805 bios->fmaxvco = 256000;
4805 bios->fminvco = 128000; 4806 bios->fminvco = 128000;
@@ -4907,10 +4908,10 @@ static int parse_bmp_structure(struct drm_device *dev, struct nvbios *bios, unsi
4907 bios->legacy.i2c_indices.crt = bios->data[legacy_i2c_offset]; 4908 bios->legacy.i2c_indices.crt = bios->data[legacy_i2c_offset];
4908 bios->legacy.i2c_indices.tv = bios->data[legacy_i2c_offset + 1]; 4909 bios->legacy.i2c_indices.tv = bios->data[legacy_i2c_offset + 1];
4909 bios->legacy.i2c_indices.panel = bios->data[legacy_i2c_offset + 2]; 4910 bios->legacy.i2c_indices.panel = bios->data[legacy_i2c_offset + 2];
4910 bios->bdcb.dcb.i2c[0].write = bios->data[legacy_i2c_offset + 4]; 4911 bios->dcb.i2c[0].write = bios->data[legacy_i2c_offset + 4];
4911 bios->bdcb.dcb.i2c[0].read = bios->data[legacy_i2c_offset + 5]; 4912 bios->dcb.i2c[0].read = bios->data[legacy_i2c_offset + 5];
4912 bios->bdcb.dcb.i2c[1].write = bios->data[legacy_i2c_offset + 6]; 4913 bios->dcb.i2c[1].write = bios->data[legacy_i2c_offset + 6];
4913 bios->bdcb.dcb.i2c[1].read = bios->data[legacy_i2c_offset + 7]; 4914 bios->dcb.i2c[1].read = bios->data[legacy_i2c_offset + 7];
4914 4915
4915 if (bmplength > 74) { 4916 if (bmplength > 74) {
4916 bios->fmaxvco = ROM32(bmp[67]); 4917 bios->fmaxvco = ROM32(bmp[67]);
@@ -5037,7 +5038,7 @@ read_dcb_i2c_entry(struct drm_device *dev, int dcb_version, uint8_t *i2ctable, i
5037static struct dcb_gpio_entry * 5038static struct dcb_gpio_entry *
5038new_gpio_entry(struct nvbios *bios) 5039new_gpio_entry(struct nvbios *bios)
5039{ 5040{
5040 struct dcb_gpio_table *gpio = &bios->bdcb.gpio; 5041 struct dcb_gpio_table *gpio = &bios->dcb.gpio;
5041 5042
5042 return &gpio->entry[gpio->entries++]; 5043 return &gpio->entry[gpio->entries++];
5043} 5044}
@@ -5049,11 +5050,11 @@ nouveau_bios_gpio_entry(struct drm_device *dev, enum dcb_gpio_tag tag)
5049 struct nvbios *bios = &dev_priv->VBIOS; 5050 struct nvbios *bios = &dev_priv->VBIOS;
5050 int i; 5051 int i;
5051 5052
5052 for (i = 0; i < bios->bdcb.gpio.entries; i++) { 5053 for (i = 0; i < bios->dcb.gpio.entries; i++) {
5053 if (bios->bdcb.gpio.entry[i].tag != tag) 5054 if (bios->dcb.gpio.entry[i].tag != tag)
5054 continue; 5055 continue;
5055 5056
5056 return &bios->bdcb.gpio.entry[i]; 5057 return &bios->dcb.gpio.entry[i];
5057 } 5058 }
5058 5059
5059 return NULL; 5060 return NULL;
@@ -5101,7 +5102,7 @@ static void
5101parse_dcb_gpio_table(struct nvbios *bios) 5102parse_dcb_gpio_table(struct nvbios *bios)
5102{ 5103{
5103 struct drm_device *dev = bios->dev; 5104 struct drm_device *dev = bios->dev;
5104 uint16_t gpio_table_ptr = bios->bdcb.gpio_table_ptr; 5105 uint16_t gpio_table_ptr = bios->dcb.gpio_table_ptr;
5105 uint8_t *gpio_table = &bios->data[gpio_table_ptr]; 5106 uint8_t *gpio_table = &bios->data[gpio_table_ptr];
5106 int header_len = gpio_table[1], 5107 int header_len = gpio_table[1],
5107 entries = gpio_table[2], 5108 entries = gpio_table[2],
@@ -5109,7 +5110,7 @@ parse_dcb_gpio_table(struct nvbios *bios)
5109 void (*parse_entry)(struct nvbios *, uint16_t) = NULL; 5110 void (*parse_entry)(struct nvbios *, uint16_t) = NULL;
5110 int i; 5111 int i;
5111 5112
5112 if (bios->bdcb.version >= 0x40) { 5113 if (bios->dcb.version >= 0x40) {
5113 if (gpio_table_ptr && entry_len != 4) { 5114 if (gpio_table_ptr && entry_len != 4) {
5114 NV_WARN(dev, "Invalid DCB GPIO table entry length.\n"); 5115 NV_WARN(dev, "Invalid DCB GPIO table entry length.\n");
5115 return; 5116 return;
@@ -5117,7 +5118,7 @@ parse_dcb_gpio_table(struct nvbios *bios)
5117 5118
5118 parse_entry = parse_dcb40_gpio_entry; 5119 parse_entry = parse_dcb40_gpio_entry;
5119 5120
5120 } else if (bios->bdcb.version >= 0x30) { 5121 } else if (bios->dcb.version >= 0x30) {
5121 if (gpio_table_ptr && entry_len != 2) { 5122 if (gpio_table_ptr && entry_len != 2) {
5122 NV_WARN(dev, "Invalid DCB GPIO table entry length.\n"); 5123 NV_WARN(dev, "Invalid DCB GPIO table entry length.\n");
5123 return; 5124 return;
@@ -5125,7 +5126,7 @@ parse_dcb_gpio_table(struct nvbios *bios)
5125 5126
5126 parse_entry = parse_dcb30_gpio_entry; 5127 parse_entry = parse_dcb30_gpio_entry;
5127 5128
5128 } else if (bios->bdcb.version >= 0x22) { 5129 } else if (bios->dcb.version >= 0x22) {
5129 /* 5130 /*
5130 * DCBs older than v3.0 don't really have a GPIO 5131 * DCBs older than v3.0 don't really have a GPIO
5131 * table, instead they keep some GPIO info at fixed 5132 * table, instead they keep some GPIO info at fixed
@@ -5162,10 +5163,10 @@ nouveau_bios_connector_entry(struct drm_device *dev, int index)
5162 struct nvbios *bios = &dev_priv->VBIOS; 5163 struct nvbios *bios = &dev_priv->VBIOS;
5163 struct dcb_connector_table_entry *cte; 5164 struct dcb_connector_table_entry *cte;
5164 5165
5165 if (index >= bios->bdcb.connector.entries) 5166 if (index >= bios->dcb.connector.entries)
5166 return NULL; 5167 return NULL;
5167 5168
5168 cte = &bios->bdcb.connector.entry[index]; 5169 cte = &bios->dcb.connector.entry[index];
5169 if (cte->type == 0xff) 5170 if (cte->type == 0xff)
5170 return NULL; 5171 return NULL;
5171 5172
@@ -5176,13 +5177,13 @@ static void
5176parse_dcb_connector_table(struct nvbios *bios) 5177parse_dcb_connector_table(struct nvbios *bios)
5177{ 5178{
5178 struct drm_device *dev = bios->dev; 5179 struct drm_device *dev = bios->dev;
5179 struct dcb_connector_table *ct = &bios->bdcb.connector; 5180 struct dcb_connector_table *ct = &bios->dcb.connector;
5180 struct dcb_connector_table_entry *cte; 5181 struct dcb_connector_table_entry *cte;
5181 uint8_t *conntab = &bios->data[bios->bdcb.connector_table_ptr]; 5182 uint8_t *conntab = &bios->data[bios->dcb.connector_table_ptr];
5182 uint8_t *entry; 5183 uint8_t *entry;
5183 int i; 5184 int i;
5184 5185
5185 if (!bios->bdcb.connector_table_ptr) { 5186 if (!bios->dcb.connector_table_ptr) {
5186 NV_DEBUG_KMS(dev, "No DCB connector table present\n"); 5187 NV_DEBUG_KMS(dev, "No DCB connector table present\n");
5187 return; 5188 return;
5188 } 5189 }
@@ -5232,7 +5233,7 @@ parse_dcb_connector_table(struct nvbios *bios)
5232 } 5233 }
5233} 5234}
5234 5235
5235static struct dcb_entry *new_dcb_entry(struct parsed_dcb *dcb) 5236static struct dcb_entry *new_dcb_entry(struct dcb_table *dcb)
5236{ 5237{
5237 struct dcb_entry *entry = &dcb->entry[dcb->entries]; 5238 struct dcb_entry *entry = &dcb->entry[dcb->entries];
5238 5239
@@ -5242,7 +5243,7 @@ static struct dcb_entry *new_dcb_entry(struct parsed_dcb *dcb)
5242 return entry; 5243 return entry;
5243} 5244}
5244 5245
5245static void fabricate_vga_output(struct parsed_dcb *dcb, int i2c, int heads) 5246static void fabricate_vga_output(struct dcb_table *dcb, int i2c, int heads)
5246{ 5247{
5247 struct dcb_entry *entry = new_dcb_entry(dcb); 5248 struct dcb_entry *entry = new_dcb_entry(dcb);
5248 5249
@@ -5253,7 +5254,7 @@ static void fabricate_vga_output(struct parsed_dcb *dcb, int i2c, int heads)
5253 /* "or" mostly unused in early gen crt modesetting, 0 is fine */ 5254 /* "or" mostly unused in early gen crt modesetting, 0 is fine */
5254} 5255}
5255 5256
5256static void fabricate_dvi_i_output(struct parsed_dcb *dcb, bool twoHeads) 5257static void fabricate_dvi_i_output(struct dcb_table *dcb, bool twoHeads)
5257{ 5258{
5258 struct dcb_entry *entry = new_dcb_entry(dcb); 5259 struct dcb_entry *entry = new_dcb_entry(dcb);
5259 5260
@@ -5280,7 +5281,7 @@ static void fabricate_dvi_i_output(struct parsed_dcb *dcb, bool twoHeads)
5280#endif 5281#endif
5281} 5282}
5282 5283
5283static void fabricate_tv_output(struct parsed_dcb *dcb, bool twoHeads) 5284static void fabricate_tv_output(struct dcb_table *dcb, bool twoHeads)
5284{ 5285{
5285 struct dcb_entry *entry = new_dcb_entry(dcb); 5286 struct dcb_entry *entry = new_dcb_entry(dcb);
5286 5287
@@ -5291,13 +5292,13 @@ static void fabricate_tv_output(struct parsed_dcb *dcb, bool twoHeads)
5291} 5292}
5292 5293
5293static bool 5294static bool
5294parse_dcb20_entry(struct drm_device *dev, struct bios_parsed_dcb *bdcb, 5295parse_dcb20_entry(struct drm_device *dev, struct dcb_table *dcb,
5295 uint32_t conn, uint32_t conf, struct dcb_entry *entry) 5296 uint32_t conn, uint32_t conf, struct dcb_entry *entry)
5296{ 5297{
5297 entry->type = conn & 0xf; 5298 entry->type = conn & 0xf;
5298 entry->i2c_index = (conn >> 4) & 0xf; 5299 entry->i2c_index = (conn >> 4) & 0xf;
5299 entry->heads = (conn >> 8) & 0xf; 5300 entry->heads = (conn >> 8) & 0xf;
5300 if (bdcb->version >= 0x40) 5301 if (dcb->version >= 0x40)
5301 entry->connector = (conn >> 12) & 0xf; 5302 entry->connector = (conn >> 12) & 0xf;
5302 entry->bus = (conn >> 16) & 0xf; 5303 entry->bus = (conn >> 16) & 0xf;
5303 entry->location = (conn >> 20) & 0x3; 5304 entry->location = (conn >> 20) & 0x3;
@@ -5315,7 +5316,7 @@ parse_dcb20_entry(struct drm_device *dev, struct bios_parsed_dcb *bdcb,
5315 * Although the rest of a CRT conf dword is usually 5316 * Although the rest of a CRT conf dword is usually
5316 * zeros, mac biosen have stuff there so we must mask 5317 * zeros, mac biosen have stuff there so we must mask
5317 */ 5318 */
5318 entry->crtconf.maxfreq = (bdcb->version < 0x30) ? 5319 entry->crtconf.maxfreq = (dcb->version < 0x30) ?
5319 (conf & 0xffff) * 10 : 5320 (conf & 0xffff) * 10 :
5320 (conf & 0xff) * 10000; 5321 (conf & 0xff) * 10000;
5321 break; 5322 break;
@@ -5324,7 +5325,7 @@ parse_dcb20_entry(struct drm_device *dev, struct bios_parsed_dcb *bdcb,
5324 uint32_t mask; 5325 uint32_t mask;
5325 if (conf & 0x1) 5326 if (conf & 0x1)
5326 entry->lvdsconf.use_straps_for_mode = true; 5327 entry->lvdsconf.use_straps_for_mode = true;
5327 if (bdcb->version < 0x22) { 5328 if (dcb->version < 0x22) {
5328 mask = ~0xd; 5329 mask = ~0xd;
5329 /* 5330 /*
5330 * The laptop in bug 14567 lies and claims to not use 5331 * The laptop in bug 14567 lies and claims to not use
@@ -5348,7 +5349,7 @@ parse_dcb20_entry(struct drm_device *dev, struct bios_parsed_dcb *bdcb,
5348 * Until we even try to use these on G8x, it's 5349 * Until we even try to use these on G8x, it's
5349 * useless reporting unknown bits. They all are. 5350 * useless reporting unknown bits. They all are.
5350 */ 5351 */
5351 if (bdcb->version >= 0x40) 5352 if (dcb->version >= 0x40)
5352 break; 5353 break;
5353 5354
5354 NV_ERROR(dev, "Unknown LVDS configuration bits, " 5355 NV_ERROR(dev, "Unknown LVDS configuration bits, "
@@ -5358,7 +5359,7 @@ parse_dcb20_entry(struct drm_device *dev, struct bios_parsed_dcb *bdcb,
5358 } 5359 }
5359 case OUTPUT_TV: 5360 case OUTPUT_TV:
5360 { 5361 {
5361 if (bdcb->version >= 0x30) 5362 if (dcb->version >= 0x30)
5362 entry->tvconf.has_component_output = conf & (0x8 << 4); 5363 entry->tvconf.has_component_output = conf & (0x8 << 4);
5363 else 5364 else
5364 entry->tvconf.has_component_output = false; 5365 entry->tvconf.has_component_output = false;
@@ -5385,7 +5386,7 @@ parse_dcb20_entry(struct drm_device *dev, struct bios_parsed_dcb *bdcb,
5385 break; 5386 break;
5386 case 0xe: 5387 case 0xe:
5387 /* weird g80 mobile type that "nv" treats as a terminator */ 5388 /* weird g80 mobile type that "nv" treats as a terminator */
5388 bdcb->dcb.entries--; 5389 dcb->entries--;
5389 return false; 5390 return false;
5390 } 5391 }
5391 5392
@@ -5397,7 +5398,7 @@ parse_dcb20_entry(struct drm_device *dev, struct bios_parsed_dcb *bdcb,
5397} 5398}
5398 5399
5399static bool 5400static bool
5400parse_dcb15_entry(struct drm_device *dev, struct parsed_dcb *dcb, 5401parse_dcb15_entry(struct drm_device *dev, struct dcb_table *dcb,
5401 uint32_t conn, uint32_t conf, struct dcb_entry *entry) 5402 uint32_t conn, uint32_t conf, struct dcb_entry *entry)
5402{ 5403{
5403 switch (conn & 0x0000000f) { 5404 switch (conn & 0x0000000f) {
@@ -5463,27 +5464,27 @@ parse_dcb15_entry(struct drm_device *dev, struct parsed_dcb *dcb,
5463 return true; 5464 return true;
5464} 5465}
5465 5466
5466static bool parse_dcb_entry(struct drm_device *dev, struct bios_parsed_dcb *bdcb, 5467static bool parse_dcb_entry(struct drm_device *dev, struct dcb_table *dcb,
5467 uint32_t conn, uint32_t conf) 5468 uint32_t conn, uint32_t conf)
5468{ 5469{
5469 struct dcb_entry *entry = new_dcb_entry(&bdcb->dcb); 5470 struct dcb_entry *entry = new_dcb_entry(dcb);
5470 bool ret; 5471 bool ret;
5471 5472
5472 if (bdcb->version >= 0x20) 5473 if (dcb->version >= 0x20)
5473 ret = parse_dcb20_entry(dev, bdcb, conn, conf, entry); 5474 ret = parse_dcb20_entry(dev, dcb, conn, conf, entry);
5474 else 5475 else
5475 ret = parse_dcb15_entry(dev, &bdcb->dcb, conn, conf, entry); 5476 ret = parse_dcb15_entry(dev, dcb, conn, conf, entry);
5476 if (!ret) 5477 if (!ret)
5477 return ret; 5478 return ret;
5478 5479
5479 read_dcb_i2c_entry(dev, bdcb->version, bdcb->i2c_table, 5480 read_dcb_i2c_entry(dev, dcb->version, dcb->i2c_table,
5480 entry->i2c_index, &bdcb->dcb.i2c[entry->i2c_index]); 5481 entry->i2c_index, &dcb->i2c[entry->i2c_index]);
5481 5482
5482 return true; 5483 return true;
5483} 5484}
5484 5485
5485static 5486static
5486void merge_like_dcb_entries(struct drm_device *dev, struct parsed_dcb *dcb) 5487void merge_like_dcb_entries(struct drm_device *dev, struct dcb_table *dcb)
5487{ 5488{
5488 /* 5489 /*
5489 * DCB v2.0 lists each output combination separately. 5490 * DCB v2.0 lists each output combination separately.
@@ -5535,8 +5536,7 @@ static int
5535parse_dcb_table(struct drm_device *dev, struct nvbios *bios, bool twoHeads) 5536parse_dcb_table(struct drm_device *dev, struct nvbios *bios, bool twoHeads)
5536{ 5537{
5537 struct drm_nouveau_private *dev_priv = dev->dev_private; 5538 struct drm_nouveau_private *dev_priv = dev->dev_private;
5538 struct bios_parsed_dcb *bdcb = &bios->bdcb; 5539 struct dcb_table *dcb = &bios->dcb;
5539 struct parsed_dcb *dcb;
5540 uint16_t dcbptr = 0, i2ctabptr = 0; 5540 uint16_t dcbptr = 0, i2ctabptr = 0;
5541 uint8_t *dcbtable; 5541 uint8_t *dcbtable;
5542 uint8_t headerlen = 0x4, entries = DCB_MAX_NUM_ENTRIES; 5542 uint8_t headerlen = 0x4, entries = DCB_MAX_NUM_ENTRIES;
@@ -5544,9 +5544,6 @@ parse_dcb_table(struct drm_device *dev, struct nvbios *bios, bool twoHeads)
5544 int recordlength = 8, confofs = 4; 5544 int recordlength = 8, confofs = 4;
5545 int i; 5545 int i;
5546 5546
5547 dcb = bios->pub.dcb = &bdcb->dcb;
5548 dcb->entries = 0;
5549
5550 /* get the offset from 0x36 */ 5547 /* get the offset from 0x36 */
5551 if (dev_priv->card_type > NV_04) { 5548 if (dev_priv->card_type > NV_04) {
5552 dcbptr = ROM16(bios->data[0x36]); 5549 dcbptr = ROM16(bios->data[0x36]);
@@ -5568,21 +5565,21 @@ parse_dcb_table(struct drm_device *dev, struct nvbios *bios, bool twoHeads)
5568 dcbtable = &bios->data[dcbptr]; 5565 dcbtable = &bios->data[dcbptr];
5569 5566
5570 /* get DCB version */ 5567 /* get DCB version */
5571 bdcb->version = dcbtable[0]; 5568 dcb->version = dcbtable[0];
5572 NV_TRACE(dev, "Found Display Configuration Block version %d.%d\n", 5569 NV_TRACE(dev, "Found Display Configuration Block version %d.%d\n",
5573 bdcb->version >> 4, bdcb->version & 0xf); 5570 dcb->version >> 4, dcb->version & 0xf);
5574 5571
5575 if (bdcb->version >= 0x20) { /* NV17+ */ 5572 if (dcb->version >= 0x20) { /* NV17+ */
5576 uint32_t sig; 5573 uint32_t sig;
5577 5574
5578 if (bdcb->version >= 0x30) { /* NV40+ */ 5575 if (dcb->version >= 0x30) { /* NV40+ */
5579 headerlen = dcbtable[1]; 5576 headerlen = dcbtable[1];
5580 entries = dcbtable[2]; 5577 entries = dcbtable[2];
5581 recordlength = dcbtable[3]; 5578 recordlength = dcbtable[3];
5582 i2ctabptr = ROM16(dcbtable[4]); 5579 i2ctabptr = ROM16(dcbtable[4]);
5583 sig = ROM32(dcbtable[6]); 5580 sig = ROM32(dcbtable[6]);
5584 bdcb->gpio_table_ptr = ROM16(dcbtable[10]); 5581 dcb->gpio_table_ptr = ROM16(dcbtable[10]);
5585 bdcb->connector_table_ptr = ROM16(dcbtable[20]); 5582 dcb->connector_table_ptr = ROM16(dcbtable[20]);
5586 } else { 5583 } else {
5587 i2ctabptr = ROM16(dcbtable[2]); 5584 i2ctabptr = ROM16(dcbtable[2]);
5588 sig = ROM32(dcbtable[4]); 5585 sig = ROM32(dcbtable[4]);
@@ -5594,7 +5591,7 @@ parse_dcb_table(struct drm_device *dev, struct nvbios *bios, bool twoHeads)
5594 "signature (%08X)\n", sig); 5591 "signature (%08X)\n", sig);
5595 return -EINVAL; 5592 return -EINVAL;
5596 } 5593 }
5597 } else if (bdcb->version >= 0x15) { /* some NV11 and NV20 */ 5594 } else if (dcb->version >= 0x15) { /* some NV11 and NV20 */
5598 char sig[8] = { 0 }; 5595 char sig[8] = { 0 };
5599 5596
5600 strncpy(sig, (char *)&dcbtable[-7], 7); 5597 strncpy(sig, (char *)&dcbtable[-7], 7);
@@ -5642,9 +5639,9 @@ parse_dcb_table(struct drm_device *dev, struct nvbios *bios, bool twoHeads)
5642 if (!i2ctabptr) 5639 if (!i2ctabptr)
5643 NV_WARN(dev, "No pointer to DCB I2C port table\n"); 5640 NV_WARN(dev, "No pointer to DCB I2C port table\n");
5644 else { 5641 else {
5645 bdcb->i2c_table = &bios->data[i2ctabptr]; 5642 dcb->i2c_table = &bios->data[i2ctabptr];
5646 if (bdcb->version >= 0x30) 5643 if (dcb->version >= 0x30)
5647 bdcb->i2c_default_indices = bdcb->i2c_table[4]; 5644 dcb->i2c_default_indices = dcb->i2c_table[4];
5648 } 5645 }
5649 5646
5650 parse_dcb_gpio_table(bios); 5647 parse_dcb_gpio_table(bios);
@@ -5674,7 +5671,7 @@ parse_dcb_table(struct drm_device *dev, struct nvbios *bios, bool twoHeads)
5674 NV_TRACEWARN(dev, "Raw DCB entry %d: %08x %08x\n", 5671 NV_TRACEWARN(dev, "Raw DCB entry %d: %08x %08x\n",
5675 dcb->entries, connection, config); 5672 dcb->entries, connection, config);
5676 5673
5677 if (!parse_dcb_entry(dev, bdcb, connection, config)) 5674 if (!parse_dcb_entry(dev, dcb, connection, config))
5678 break; 5675 break;
5679 } 5676 }
5680 5677
@@ -5682,7 +5679,7 @@ parse_dcb_table(struct drm_device *dev, struct nvbios *bios, bool twoHeads)
5682 * apart for v2.1+ not being known for requiring merging, this 5679 * apart for v2.1+ not being known for requiring merging, this
5683 * guarantees dcbent->index is the index of the entry in the rom image 5680 * guarantees dcbent->index is the index of the entry in the rom image
5684 */ 5681 */
5685 if (bdcb->version < 0x21) 5682 if (dcb->version < 0x21)
5686 merge_like_dcb_entries(dev, dcb); 5683 merge_like_dcb_entries(dev, dcb);
5687 5684
5688 return dcb->entries ? 0 : -ENXIO; 5685 return dcb->entries ? 0 : -ENXIO;
@@ -5691,8 +5688,7 @@ parse_dcb_table(struct drm_device *dev, struct nvbios *bios, bool twoHeads)
5691static void 5688static void
5692fixup_legacy_connector(struct nvbios *bios) 5689fixup_legacy_connector(struct nvbios *bios)
5693{ 5690{
5694 struct bios_parsed_dcb *bdcb = &bios->bdcb; 5691 struct dcb_table *dcb = &bios->dcb;
5695 struct parsed_dcb *dcb = &bdcb->dcb;
5696 int high = 0, i; 5692 int high = 0, i;
5697 5693
5698 /* 5694 /*
@@ -5701,7 +5697,7 @@ fixup_legacy_connector(struct nvbios *bios)
5701 * indices are all 0. We don't need the connector indices on pre-G80 5697 * indices are all 0. We don't need the connector indices on pre-G80
5702 * chips (yet?) so limit the use to DCB 4.0 and above. 5698 * chips (yet?) so limit the use to DCB 4.0 and above.
5703 */ 5699 */
5704 if (bdcb->version >= 0x40) 5700 if (dcb->version >= 0x40)
5705 return; 5701 return;
5706 5702
5707 /* 5703 /*
@@ -5741,7 +5737,7 @@ fixup_legacy_connector(struct nvbios *bios)
5741static void 5737static void
5742fixup_legacy_i2c(struct nvbios *bios) 5738fixup_legacy_i2c(struct nvbios *bios)
5743{ 5739{
5744 struct parsed_dcb *dcb = &bios->bdcb.dcb; 5740 struct dcb_table *dcb = &bios->dcb;
5745 int i; 5741 int i;
5746 5742
5747 for (i = 0; i < dcb->entries; i++) { 5743 for (i = 0; i < dcb->entries; i++) {
@@ -5947,9 +5943,9 @@ nouveau_run_vbios_init(struct drm_device *dev)
5947 } 5943 }
5948 5944
5949 if (dev_priv->card_type >= NV_50) { 5945 if (dev_priv->card_type >= NV_50) {
5950 for (i = 0; i < bios->bdcb.dcb.entries; i++) { 5946 for (i = 0; i < bios->dcb.entries; i++) {
5951 nouveau_bios_run_display_table(dev, 5947 nouveau_bios_run_display_table(dev,
5952 &bios->bdcb.dcb.entry[i], 5948 &bios->dcb.entry[i],
5953 0, 0); 5949 0, 0);
5954 } 5950 }
5955 } 5951 }
@@ -5967,7 +5963,7 @@ nouveau_bios_i2c_devices_takedown(struct drm_device *dev)
5967 struct dcb_i2c_entry *entry; 5963 struct dcb_i2c_entry *entry;
5968 int i; 5964 int i;
5969 5965
5970 entry = &bios->bdcb.dcb.i2c[0]; 5966 entry = &bios->dcb.i2c[0];
5971 for (i = 0; i < DCB_MAX_NUM_I2C_ENTRIES; i++, entry++) 5967 for (i = 0; i < DCB_MAX_NUM_I2C_ENTRIES; i++, entry++)
5972 nouveau_i2c_fini(dev, entry); 5968 nouveau_i2c_fini(dev, entry);
5973} 5969}
diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.h b/drivers/gpu/drm/nouveau/nouveau_bios.h
index 73e6499e79d7..449a5f3d47d0 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bios.h
+++ b/drivers/gpu/drm/nouveau/nouveau_bios.h
@@ -77,12 +77,6 @@ struct dcb_i2c_entry {
77 struct nouveau_i2c_chan *chan; 77 struct nouveau_i2c_chan *chan;
78}; 78};
79 79
80struct parsed_dcb {
81 int entries;
82 struct dcb_entry entry[DCB_MAX_NUM_ENTRIES];
83 struct dcb_i2c_entry i2c[DCB_MAX_NUM_I2C_ENTRIES];
84};
85
86enum dcb_gpio_tag { 80enum dcb_gpio_tag {
87 DCB_GPIO_TVDAC0 = 0xc, 81 DCB_GPIO_TVDAC0 = 0xc,
88 DCB_GPIO_TVDAC1 = 0x2d, 82 DCB_GPIO_TVDAC1 = 0x2d,
@@ -111,13 +105,15 @@ struct dcb_connector_table {
111 struct dcb_connector_table_entry entry[DCB_MAX_NUM_CONNECTOR_ENTRIES]; 105 struct dcb_connector_table_entry entry[DCB_MAX_NUM_CONNECTOR_ENTRIES];
112}; 106};
113 107
114struct bios_parsed_dcb { 108struct dcb_table {
115 uint8_t version; 109 uint8_t version;
116 110
117 struct parsed_dcb dcb; 111 int entries;
112 struct dcb_entry entry[DCB_MAX_NUM_ENTRIES];
118 113
119 uint8_t *i2c_table; 114 uint8_t *i2c_table;
120 uint8_t i2c_default_indices; 115 uint8_t i2c_default_indices;
116 struct dcb_i2c_entry i2c[DCB_MAX_NUM_I2C_ENTRIES];
121 117
122 uint16_t gpio_table_ptr; 118 uint16_t gpio_table_ptr;
123 struct dcb_gpio_table gpio; 119 struct dcb_gpio_table gpio;
@@ -191,8 +187,6 @@ struct pll_lims {
191}; 187};
192 188
193struct nouveau_bios_info { 189struct nouveau_bios_info {
194 struct parsed_dcb *dcb;
195
196 uint8_t chip_version; 190 uint8_t chip_version;
197 191
198 uint32_t dactestval; 192 uint32_t dactestval;
@@ -234,7 +228,7 @@ struct nvbios {
234 uint16_t some_script_ptr; /* BIT I + 14 */ 228 uint16_t some_script_ptr; /* BIT I + 14 */
235 uint16_t init96_tbl_ptr; /* BIT I + 16 */ 229 uint16_t init96_tbl_ptr; /* BIT I + 16 */
236 230
237 struct bios_parsed_dcb bdcb; 231 struct dcb_table dcb;
238 232
239 struct { 233 struct {
240 int crtchead; 234 int crtchead;
diff --git a/drivers/gpu/drm/nouveau/nouveau_i2c.c b/drivers/gpu/drm/nouveau/nouveau_i2c.c
index f0162c4a6b90..05fa4983c7fb 100644
--- a/drivers/gpu/drm/nouveau/nouveau_i2c.c
+++ b/drivers/gpu/drm/nouveau/nouveau_i2c.c
@@ -259,11 +259,11 @@ nouveau_i2c_find(struct drm_device *dev, int index)
259 if (index >= DCB_MAX_NUM_I2C_ENTRIES) 259 if (index >= DCB_MAX_NUM_I2C_ENTRIES)
260 return NULL; 260 return NULL;
261 261
262 if (!bios->bdcb.dcb.i2c[index].chan) { 262 if (!bios->dcb.i2c[index].chan) {
263 if (nouveau_i2c_init(dev, &bios->bdcb.dcb.i2c[index], index)) 263 if (nouveau_i2c_init(dev, &bios->dcb.i2c[index], index))
264 return NULL; 264 return NULL;
265 } 265 }
266 266
267 return bios->bdcb.dcb.i2c[index].chan; 267 return bios->dcb.i2c[index].chan;
268} 268}
269 269
diff --git a/drivers/gpu/drm/nouveau/nv04_display.c b/drivers/gpu/drm/nouveau/nv04_display.c
index ef77215fa5b9..07a8b5502b62 100644
--- a/drivers/gpu/drm/nouveau/nv04_display.c
+++ b/drivers/gpu/drm/nouveau/nv04_display.c
@@ -93,7 +93,7 @@ int
93nv04_display_create(struct drm_device *dev) 93nv04_display_create(struct drm_device *dev)
94{ 94{
95 struct drm_nouveau_private *dev_priv = dev->dev_private; 95 struct drm_nouveau_private *dev_priv = dev->dev_private;
96 struct parsed_dcb *dcb = dev_priv->vbios->dcb; 96 struct dcb_table *dcb = &dev_priv->VBIOS.dcb;
97 struct drm_encoder *encoder; 97 struct drm_encoder *encoder;
98 struct drm_crtc *crtc; 98 struct drm_crtc *crtc;
99 uint16_t connector[16] = { 0 }; 99 uint16_t connector[16] = { 0 };
diff --git a/drivers/gpu/drm/nouveau/nv04_tv.c b/drivers/gpu/drm/nouveau/nv04_tv.c
index 9c63099e9c42..ce247123cde1 100644
--- a/drivers/gpu/drm/nouveau/nv04_tv.c
+++ b/drivers/gpu/drm/nouveau/nv04_tv.c
@@ -262,7 +262,7 @@ int nv04_tv_create(struct drm_device *dev, struct dcb_entry *entry)
262 nv_encoder->or = ffs(entry->or) - 1; 262 nv_encoder->or = ffs(entry->or) - 1;
263 263
264 /* Run the slave-specific initialization */ 264 /* Run the slave-specific initialization */
265 adap = &dev_priv->vbios->dcb->i2c[i2c_index].chan->adapter; 265 adap = &dev_priv->VBIOS.dcb.i2c[i2c_index].chan->adapter;
266 266
267 was_locked = NVLockVgaCrtcs(dev, false); 267 was_locked = NVLockVgaCrtcs(dev, false);
268 268
diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c
index 90f0bf59fbcd..34af3b277413 100644
--- a/drivers/gpu/drm/nouveau/nv50_display.c
+++ b/drivers/gpu/drm/nouveau/nv50_display.c
@@ -465,7 +465,7 @@ static int nv50_display_disable(struct drm_device *dev)
465int nv50_display_create(struct drm_device *dev) 465int nv50_display_create(struct drm_device *dev)
466{ 466{
467 struct drm_nouveau_private *dev_priv = dev->dev_private; 467 struct drm_nouveau_private *dev_priv = dev->dev_private;
468 struct parsed_dcb *dcb = dev_priv->vbios->dcb; 468 struct dcb_table *dcb = &dev_priv->VBIOS.dcb;
469 uint32_t connector[16] = {}; 469 uint32_t connector[16] = {};
470 int ret, i; 470 int ret, i;
471 471
@@ -667,8 +667,8 @@ nv50_display_irq_head(struct drm_device *dev, int *phead,
667 return -1; 667 return -1;
668 } 668 }
669 669
670 for (i = 0; i < dev_priv->vbios->dcb->entries; i++) { 670 for (i = 0; i < dev_priv->VBIOS.dcb.entries; i++) {
671 struct dcb_entry *dcbent = &dev_priv->vbios->dcb->entry[i]; 671 struct dcb_entry *dcbent = &dev_priv->VBIOS.dcb.entry[i];
672 672
673 if (dcbent->type != type) 673 if (dcbent->type != type)
674 continue; 674 continue;