Commit 7f245b20 authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau: merge parsed_dcb and bios_parsed_dcb into dcb_table

Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent a6678b2a
...@@ -700,7 +700,7 @@ static int dcb_entry_idx_from_crtchead(struct drm_device *dev) ...@@ -700,7 +700,7 @@ static int dcb_entry_idx_from_crtchead(struct drm_device *dev)
uint8_t dcb_entry = NVReadVgaCrtc5758(dev, bios->state.crtchead, 0); uint8_t dcb_entry = NVReadVgaCrtc5758(dev, bios->state.crtchead, 0);
if (dcb_entry > bios->bdcb.dcb.entries) { if (dcb_entry > bios->dcb.entries) {
NV_ERROR(dev, "CR58 doesn't have a valid DCB entry currently " NV_ERROR(dev, "CR58 doesn't have a valid DCB entry currently "
"(%02X)\n", dcb_entry); "(%02X)\n", dcb_entry);
dcb_entry = 0x7f; /* unused / invalid marker */ dcb_entry = 0x7f; /* unused / invalid marker */
...@@ -713,25 +713,26 @@ static struct nouveau_i2c_chan * ...@@ -713,25 +713,26 @@ static struct nouveau_i2c_chan *
init_i2c_device_find(struct drm_device *dev, int i2c_index) init_i2c_device_find(struct drm_device *dev, int i2c_index)
{ {
struct drm_nouveau_private *dev_priv = dev->dev_private; struct drm_nouveau_private *dev_priv = dev->dev_private;
struct bios_parsed_dcb *bdcb = &dev_priv->VBIOS.bdcb; struct dcb_table *dcb = &dev_priv->VBIOS.dcb;
if (i2c_index == 0xff) { if (i2c_index == 0xff) {
/* note: dcb_entry_idx_from_crtchead needs pre-script set-up */ /* note: dcb_entry_idx_from_crtchead needs pre-script set-up */
int idx = dcb_entry_idx_from_crtchead(dev), shift = 0; int idx = dcb_entry_idx_from_crtchead(dev), shift = 0;
int default_indices = bdcb->i2c_default_indices; int default_indices = dcb->i2c_default_indices;
if (idx != 0x7f && bdcb->dcb.entry[idx].i2c_upper_default) if (idx != 0x7f && dcb->entry[idx].i2c_upper_default)
shift = 4; shift = 4;
i2c_index = (default_indices >> shift) & 0xf; i2c_index = (default_indices >> shift) & 0xf;
} }
if (i2c_index == 0x80) /* g80+ */ if (i2c_index == 0x80) /* g80+ */
i2c_index = bdcb->i2c_default_indices & 0xf; i2c_index = dcb->i2c_default_indices & 0xf;
return nouveau_i2c_find(dev, i2c_index); return nouveau_i2c_find(dev, i2c_index);
} }
static uint32_t get_tmds_index_reg(struct drm_device *dev, uint8_t mlv) static uint32_t
get_tmds_index_reg(struct drm_device *dev, uint8_t mlv)
{ {
/* /*
* For mlv < 0x80, it is an index into a table of TMDS base addresses. * 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,6 +745,7 @@ static uint32_t get_tmds_index_reg(struct drm_device *dev, uint8_t mlv)
*/ */
struct drm_nouveau_private *dev_priv = dev->dev_private; struct drm_nouveau_private *dev_priv = dev->dev_private;
struct nvbios *bios = &dev_priv->VBIOS;
const int pramdac_offset[13] = { const int pramdac_offset[13] = {
0, 0, 0x8, 0, 0x2000, 0, 0, 0, 0x2008, 0, 0, 0, 0x2000 }; 0, 0, 0x8, 0, 0x2000, 0, 0, 0, 0x2008, 0, 0, 0, 0x2000 };
const uint32_t pramdac_table[4] = { 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,8 +758,7 @@ static uint32_t get_tmds_index_reg(struct drm_device *dev, uint8_t mlv)
dcb_entry = dcb_entry_idx_from_crtchead(dev); dcb_entry = dcb_entry_idx_from_crtchead(dev);
if (dcb_entry == 0x7f) if (dcb_entry == 0x7f)
return 0; return 0;
dacoffset = pramdac_offset[ dacoffset = pramdac_offset[bios->dcb.entry[dcb_entry].or];
dev_priv->VBIOS.bdcb.dcb.entry[dcb_entry].or];
if (mlv == 0x81) if (mlv == 0x81)
dacoffset ^= 8; dacoffset ^= 8;
return 0x6808b0 + dacoffset; return 0x6808b0 + dacoffset;
...@@ -2574,19 +2575,19 @@ init_gpio(struct nvbios *bios, uint16_t offset, struct init_exec *iexec) ...@@ -2574,19 +2575,19 @@ init_gpio(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
const uint32_t nv50_gpio_reg[4] = { 0xe104, 0xe108, 0xe280, 0xe284 }; const uint32_t nv50_gpio_reg[4] = { 0xe104, 0xe108, 0xe280, 0xe284 };
const uint32_t nv50_gpio_ctl[2] = { 0xe100, 0xe28c }; const uint32_t nv50_gpio_ctl[2] = { 0xe100, 0xe28c };
const uint8_t *gpio_table = &bios->data[bios->bdcb.gpio_table_ptr]; const uint8_t *gpio_table = &bios->data[bios->dcb.gpio_table_ptr];
const uint8_t *gpio_entry; const uint8_t *gpio_entry;
int i; int i;
if (!iexec->execute) if (!iexec->execute)
return 1; return 1;
if (bios->bdcb.version != 0x40) { if (bios->dcb.version != 0x40) {
NV_ERROR(bios->dev, "DCB table not version 4.0\n"); NV_ERROR(bios->dev, "DCB table not version 4.0\n");
return 0; return 0;
} }
if (!bios->bdcb.gpio_table_ptr) { if (!bios->dcb.gpio_table_ptr) {
NV_WARN(bios->dev, "Invalid pointer to INIT_8E table\n"); NV_WARN(bios->dev, "Invalid pointer to INIT_8E table\n");
return 0; return 0;
} }
...@@ -4796,10 +4797,10 @@ static int parse_bmp_structure(struct drm_device *dev, struct nvbios *bios, unsi ...@@ -4796,10 +4797,10 @@ static int parse_bmp_structure(struct drm_device *dev, struct nvbios *bios, unsi
uint16_t legacy_scripts_offset, legacy_i2c_offset; uint16_t legacy_scripts_offset, legacy_i2c_offset;
/* load needed defaults in case we can't parse this info */ /* load needed defaults in case we can't parse this info */
bios->bdcb.dcb.i2c[0].write = NV_CIO_CRE_DDC_WR__INDEX; bios->dcb.i2c[0].write = NV_CIO_CRE_DDC_WR__INDEX;
bios->bdcb.dcb.i2c[0].read = NV_CIO_CRE_DDC_STATUS__INDEX; bios->dcb.i2c[0].read = NV_CIO_CRE_DDC_STATUS__INDEX;
bios->bdcb.dcb.i2c[1].write = NV_CIO_CRE_DDC0_WR__INDEX; bios->dcb.i2c[1].write = NV_CIO_CRE_DDC0_WR__INDEX;
bios->bdcb.dcb.i2c[1].read = NV_CIO_CRE_DDC0_STATUS__INDEX; bios->dcb.i2c[1].read = NV_CIO_CRE_DDC0_STATUS__INDEX;
bios->pub.digital_min_front_porch = 0x4b; bios->pub.digital_min_front_porch = 0x4b;
bios->fmaxvco = 256000; bios->fmaxvco = 256000;
bios->fminvco = 128000; bios->fminvco = 128000;
...@@ -4907,10 +4908,10 @@ static int parse_bmp_structure(struct drm_device *dev, struct nvbios *bios, unsi ...@@ -4907,10 +4908,10 @@ static int parse_bmp_structure(struct drm_device *dev, struct nvbios *bios, unsi
bios->legacy.i2c_indices.crt = bios->data[legacy_i2c_offset]; bios->legacy.i2c_indices.crt = bios->data[legacy_i2c_offset];
bios->legacy.i2c_indices.tv = bios->data[legacy_i2c_offset + 1]; bios->legacy.i2c_indices.tv = bios->data[legacy_i2c_offset + 1];
bios->legacy.i2c_indices.panel = bios->data[legacy_i2c_offset + 2]; bios->legacy.i2c_indices.panel = bios->data[legacy_i2c_offset + 2];
bios->bdcb.dcb.i2c[0].write = bios->data[legacy_i2c_offset + 4]; bios->dcb.i2c[0].write = bios->data[legacy_i2c_offset + 4];
bios->bdcb.dcb.i2c[0].read = bios->data[legacy_i2c_offset + 5]; bios->dcb.i2c[0].read = bios->data[legacy_i2c_offset + 5];
bios->bdcb.dcb.i2c[1].write = bios->data[legacy_i2c_offset + 6]; bios->dcb.i2c[1].write = bios->data[legacy_i2c_offset + 6];
bios->bdcb.dcb.i2c[1].read = bios->data[legacy_i2c_offset + 7]; bios->dcb.i2c[1].read = bios->data[legacy_i2c_offset + 7];
if (bmplength > 74) { if (bmplength > 74) {
bios->fmaxvco = ROM32(bmp[67]); bios->fmaxvco = ROM32(bmp[67]);
...@@ -5037,7 +5038,7 @@ read_dcb_i2c_entry(struct drm_device *dev, int dcb_version, uint8_t *i2ctable, i ...@@ -5037,7 +5038,7 @@ read_dcb_i2c_entry(struct drm_device *dev, int dcb_version, uint8_t *i2ctable, i
static struct dcb_gpio_entry * static struct dcb_gpio_entry *
new_gpio_entry(struct nvbios *bios) new_gpio_entry(struct nvbios *bios)
{ {
struct dcb_gpio_table *gpio = &bios->bdcb.gpio; struct dcb_gpio_table *gpio = &bios->dcb.gpio;
return &gpio->entry[gpio->entries++]; return &gpio->entry[gpio->entries++];
} }
...@@ -5049,11 +5050,11 @@ nouveau_bios_gpio_entry(struct drm_device *dev, enum dcb_gpio_tag tag) ...@@ -5049,11 +5050,11 @@ nouveau_bios_gpio_entry(struct drm_device *dev, enum dcb_gpio_tag tag)
struct nvbios *bios = &dev_priv->VBIOS; struct nvbios *bios = &dev_priv->VBIOS;
int i; int i;
for (i = 0; i < bios->bdcb.gpio.entries; i++) { for (i = 0; i < bios->dcb.gpio.entries; i++) {
if (bios->bdcb.gpio.entry[i].tag != tag) if (bios->dcb.gpio.entry[i].tag != tag)
continue; continue;
return &bios->bdcb.gpio.entry[i]; return &bios->dcb.gpio.entry[i];
} }
return NULL; return NULL;
...@@ -5101,7 +5102,7 @@ static void ...@@ -5101,7 +5102,7 @@ static void
parse_dcb_gpio_table(struct nvbios *bios) parse_dcb_gpio_table(struct nvbios *bios)
{ {
struct drm_device *dev = bios->dev; struct drm_device *dev = bios->dev;
uint16_t gpio_table_ptr = bios->bdcb.gpio_table_ptr; uint16_t gpio_table_ptr = bios->dcb.gpio_table_ptr;
uint8_t *gpio_table = &bios->data[gpio_table_ptr]; uint8_t *gpio_table = &bios->data[gpio_table_ptr];
int header_len = gpio_table[1], int header_len = gpio_table[1],
entries = gpio_table[2], entries = gpio_table[2],
...@@ -5109,7 +5110,7 @@ parse_dcb_gpio_table(struct nvbios *bios) ...@@ -5109,7 +5110,7 @@ parse_dcb_gpio_table(struct nvbios *bios)
void (*parse_entry)(struct nvbios *, uint16_t) = NULL; void (*parse_entry)(struct nvbios *, uint16_t) = NULL;
int i; int i;
if (bios->bdcb.version >= 0x40) { if (bios->dcb.version >= 0x40) {
if (gpio_table_ptr && entry_len != 4) { if (gpio_table_ptr && entry_len != 4) {
NV_WARN(dev, "Invalid DCB GPIO table entry length.\n"); NV_WARN(dev, "Invalid DCB GPIO table entry length.\n");
return; return;
...@@ -5117,7 +5118,7 @@ parse_dcb_gpio_table(struct nvbios *bios) ...@@ -5117,7 +5118,7 @@ parse_dcb_gpio_table(struct nvbios *bios)
parse_entry = parse_dcb40_gpio_entry; parse_entry = parse_dcb40_gpio_entry;
} else if (bios->bdcb.version >= 0x30) { } else if (bios->dcb.version >= 0x30) {
if (gpio_table_ptr && entry_len != 2) { if (gpio_table_ptr && entry_len != 2) {
NV_WARN(dev, "Invalid DCB GPIO table entry length.\n"); NV_WARN(dev, "Invalid DCB GPIO table entry length.\n");
return; return;
...@@ -5125,7 +5126,7 @@ parse_dcb_gpio_table(struct nvbios *bios) ...@@ -5125,7 +5126,7 @@ parse_dcb_gpio_table(struct nvbios *bios)
parse_entry = parse_dcb30_gpio_entry; parse_entry = parse_dcb30_gpio_entry;
} else if (bios->bdcb.version >= 0x22) { } else if (bios->dcb.version >= 0x22) {
/* /*
* DCBs older than v3.0 don't really have a GPIO * DCBs older than v3.0 don't really have a GPIO
* table, instead they keep some GPIO info at fixed * table, instead they keep some GPIO info at fixed
...@@ -5162,10 +5163,10 @@ nouveau_bios_connector_entry(struct drm_device *dev, int index) ...@@ -5162,10 +5163,10 @@ nouveau_bios_connector_entry(struct drm_device *dev, int index)
struct nvbios *bios = &dev_priv->VBIOS; struct nvbios *bios = &dev_priv->VBIOS;
struct dcb_connector_table_entry *cte; struct dcb_connector_table_entry *cte;
if (index >= bios->bdcb.connector.entries) if (index >= bios->dcb.connector.entries)
return NULL; return NULL;
cte = &bios->bdcb.connector.entry[index]; cte = &bios->dcb.connector.entry[index];
if (cte->type == 0xff) if (cte->type == 0xff)
return NULL; return NULL;
...@@ -5176,13 +5177,13 @@ static void ...@@ -5176,13 +5177,13 @@ static void
parse_dcb_connector_table(struct nvbios *bios) parse_dcb_connector_table(struct nvbios *bios)
{ {
struct drm_device *dev = bios->dev; struct drm_device *dev = bios->dev;
struct dcb_connector_table *ct = &bios->bdcb.connector; struct dcb_connector_table *ct = &bios->dcb.connector;
struct dcb_connector_table_entry *cte; struct dcb_connector_table_entry *cte;
uint8_t *conntab = &bios->data[bios->bdcb.connector_table_ptr]; uint8_t *conntab = &bios->data[bios->dcb.connector_table_ptr];
uint8_t *entry; uint8_t *entry;
int i; int i;
if (!bios->bdcb.connector_table_ptr) { if (!bios->dcb.connector_table_ptr) {
NV_DEBUG_KMS(dev, "No DCB connector table present\n"); NV_DEBUG_KMS(dev, "No DCB connector table present\n");
return; return;
} }
...@@ -5232,7 +5233,7 @@ parse_dcb_connector_table(struct nvbios *bios) ...@@ -5232,7 +5233,7 @@ parse_dcb_connector_table(struct nvbios *bios)
} }
} }
static struct dcb_entry *new_dcb_entry(struct parsed_dcb *dcb) static struct dcb_entry *new_dcb_entry(struct dcb_table *dcb)
{ {
struct dcb_entry *entry = &dcb->entry[dcb->entries]; struct dcb_entry *entry = &dcb->entry[dcb->entries];
...@@ -5242,7 +5243,7 @@ static struct dcb_entry *new_dcb_entry(struct parsed_dcb *dcb) ...@@ -5242,7 +5243,7 @@ static struct dcb_entry *new_dcb_entry(struct parsed_dcb *dcb)
return entry; return entry;
} }
static void fabricate_vga_output(struct parsed_dcb *dcb, int i2c, int heads) static void fabricate_vga_output(struct dcb_table *dcb, int i2c, int heads)
{ {
struct dcb_entry *entry = new_dcb_entry(dcb); struct dcb_entry *entry = new_dcb_entry(dcb);
...@@ -5253,7 +5254,7 @@ static void fabricate_vga_output(struct parsed_dcb *dcb, int i2c, int heads) ...@@ -5253,7 +5254,7 @@ static void fabricate_vga_output(struct parsed_dcb *dcb, int i2c, int heads)
/* "or" mostly unused in early gen crt modesetting, 0 is fine */ /* "or" mostly unused in early gen crt modesetting, 0 is fine */
} }
static void fabricate_dvi_i_output(struct parsed_dcb *dcb, bool twoHeads) static void fabricate_dvi_i_output(struct dcb_table *dcb, bool twoHeads)
{ {
struct dcb_entry *entry = new_dcb_entry(dcb); struct dcb_entry *entry = new_dcb_entry(dcb);
...@@ -5280,7 +5281,7 @@ static void fabricate_dvi_i_output(struct parsed_dcb *dcb, bool twoHeads) ...@@ -5280,7 +5281,7 @@ static void fabricate_dvi_i_output(struct parsed_dcb *dcb, bool twoHeads)
#endif #endif
} }
static void fabricate_tv_output(struct parsed_dcb *dcb, bool twoHeads) static void fabricate_tv_output(struct dcb_table *dcb, bool twoHeads)
{ {
struct dcb_entry *entry = new_dcb_entry(dcb); struct dcb_entry *entry = new_dcb_entry(dcb);
...@@ -5291,13 +5292,13 @@ static void fabricate_tv_output(struct parsed_dcb *dcb, bool twoHeads) ...@@ -5291,13 +5292,13 @@ static void fabricate_tv_output(struct parsed_dcb *dcb, bool twoHeads)
} }
static bool static bool
parse_dcb20_entry(struct drm_device *dev, struct bios_parsed_dcb *bdcb, parse_dcb20_entry(struct drm_device *dev, struct dcb_table *dcb,
uint32_t conn, uint32_t conf, struct dcb_entry *entry) uint32_t conn, uint32_t conf, struct dcb_entry *entry)
{ {
entry->type = conn & 0xf; entry->type = conn & 0xf;
entry->i2c_index = (conn >> 4) & 0xf; entry->i2c_index = (conn >> 4) & 0xf;
entry->heads = (conn >> 8) & 0xf; entry->heads = (conn >> 8) & 0xf;
if (bdcb->version >= 0x40) if (dcb->version >= 0x40)
entry->connector = (conn >> 12) & 0xf; entry->connector = (conn >> 12) & 0xf;
entry->bus = (conn >> 16) & 0xf; entry->bus = (conn >> 16) & 0xf;
entry->location = (conn >> 20) & 0x3; entry->location = (conn >> 20) & 0x3;
...@@ -5315,7 +5316,7 @@ parse_dcb20_entry(struct drm_device *dev, struct bios_parsed_dcb *bdcb, ...@@ -5315,7 +5316,7 @@ parse_dcb20_entry(struct drm_device *dev, struct bios_parsed_dcb *bdcb,
* Although the rest of a CRT conf dword is usually * Although the rest of a CRT conf dword is usually
* zeros, mac biosen have stuff there so we must mask * zeros, mac biosen have stuff there so we must mask
*/ */
entry->crtconf.maxfreq = (bdcb->version < 0x30) ? entry->crtconf.maxfreq = (dcb->version < 0x30) ?
(conf & 0xffff) * 10 : (conf & 0xffff) * 10 :
(conf & 0xff) * 10000; (conf & 0xff) * 10000;
break; break;
...@@ -5324,7 +5325,7 @@ parse_dcb20_entry(struct drm_device *dev, struct bios_parsed_dcb *bdcb, ...@@ -5324,7 +5325,7 @@ parse_dcb20_entry(struct drm_device *dev, struct bios_parsed_dcb *bdcb,
uint32_t mask; uint32_t mask;
if (conf & 0x1) if (conf & 0x1)
entry->lvdsconf.use_straps_for_mode = true; entry->lvdsconf.use_straps_for_mode = true;
if (bdcb->version < 0x22) { if (dcb->version < 0x22) {
mask = ~0xd; mask = ~0xd;
/* /*
* The laptop in bug 14567 lies and claims to not use * 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,7 +5349,7 @@ parse_dcb20_entry(struct drm_device *dev, struct bios_parsed_dcb *bdcb,
* Until we even try to use these on G8x, it's * Until we even try to use these on G8x, it's
* useless reporting unknown bits. They all are. * useless reporting unknown bits. They all are.
*/ */
if (bdcb->version >= 0x40) if (dcb->version >= 0x40)
break; break;
NV_ERROR(dev, "Unknown LVDS configuration bits, " NV_ERROR(dev, "Unknown LVDS configuration bits, "
...@@ -5358,7 +5359,7 @@ parse_dcb20_entry(struct drm_device *dev, struct bios_parsed_dcb *bdcb, ...@@ -5358,7 +5359,7 @@ parse_dcb20_entry(struct drm_device *dev, struct bios_parsed_dcb *bdcb,
} }
case OUTPUT_TV: case OUTPUT_TV:
{ {
if (bdcb->version >= 0x30) if (dcb->version >= 0x30)
entry->tvconf.has_component_output = conf & (0x8 << 4); entry->tvconf.has_component_output = conf & (0x8 << 4);
else else
entry->tvconf.has_component_output = false; entry->tvconf.has_component_output = false;
...@@ -5385,7 +5386,7 @@ parse_dcb20_entry(struct drm_device *dev, struct bios_parsed_dcb *bdcb, ...@@ -5385,7 +5386,7 @@ parse_dcb20_entry(struct drm_device *dev, struct bios_parsed_dcb *bdcb,
break; break;
case 0xe: case 0xe:
/* weird g80 mobile type that "nv" treats as a terminator */ /* weird g80 mobile type that "nv" treats as a terminator */
bdcb->dcb.entries--; dcb->entries--;
return false; return false;
} }
...@@ -5397,7 +5398,7 @@ parse_dcb20_entry(struct drm_device *dev, struct bios_parsed_dcb *bdcb, ...@@ -5397,7 +5398,7 @@ parse_dcb20_entry(struct drm_device *dev, struct bios_parsed_dcb *bdcb,
} }
static bool static bool
parse_dcb15_entry(struct drm_device *dev, struct parsed_dcb *dcb, parse_dcb15_entry(struct drm_device *dev, struct dcb_table *dcb,
uint32_t conn, uint32_t conf, struct dcb_entry *entry) uint32_t conn, uint32_t conf, struct dcb_entry *entry)
{ {
switch (conn & 0x0000000f) { switch (conn & 0x0000000f) {
...@@ -5463,27 +5464,27 @@ parse_dcb15_entry(struct drm_device *dev, struct parsed_dcb *dcb, ...@@ -5463,27 +5464,27 @@ parse_dcb15_entry(struct drm_device *dev, struct parsed_dcb *dcb,
return true; return true;
} }
static bool parse_dcb_entry(struct drm_device *dev, struct bios_parsed_dcb *bdcb, static bool parse_dcb_entry(struct drm_device *dev, struct dcb_table *dcb,
uint32_t conn, uint32_t conf) uint32_t conn, uint32_t conf)
{ {
struct dcb_entry *entry = new_dcb_entry(&bdcb->dcb); struct dcb_entry *entry = new_dcb_entry(dcb);
bool ret; bool ret;
if (bdcb->version >= 0x20) if (dcb->version >= 0x20)
ret = parse_dcb20_entry(dev, bdcb, conn, conf, entry); ret = parse_dcb20_entry(dev, dcb, conn, conf, entry);
else else
ret = parse_dcb15_entry(dev, &bdcb->dcb, conn, conf, entry); ret = parse_dcb15_entry(dev, dcb, conn, conf, entry);
if (!ret) if (!ret)
return ret; return ret;
read_dcb_i2c_entry(dev, bdcb->version, bdcb->i2c_table, read_dcb_i2c_entry(dev, dcb->version, dcb->i2c_table,
entry->i2c_index, &bdcb->dcb.i2c[entry->i2c_index]); entry->i2c_index, &dcb->i2c[entry->i2c_index]);
return true; return true;
} }
static static
void merge_like_dcb_entries(struct drm_device *dev, struct parsed_dcb *dcb) void merge_like_dcb_entries(struct drm_device *dev, struct dcb_table *dcb)
{ {
/* /*
* DCB v2.0 lists each output combination separately. * DCB v2.0 lists each output combination separately.
...@@ -5535,8 +5536,7 @@ static int ...@@ -5535,8 +5536,7 @@ static int
parse_dcb_table(struct drm_device *dev, struct nvbios *bios, bool twoHeads) parse_dcb_table(struct drm_device *dev, struct nvbios *bios, bool twoHeads)
{ {
struct drm_nouveau_private *dev_priv = dev->dev_private; struct drm_nouveau_private *dev_priv = dev->dev_private;
struct bios_parsed_dcb *bdcb = &bios->bdcb; struct dcb_table *dcb = &bios->dcb;
struct parsed_dcb *dcb;
uint16_t dcbptr = 0, i2ctabptr = 0; uint16_t dcbptr = 0, i2ctabptr = 0;
uint8_t *dcbtable; uint8_t *dcbtable;
uint8_t headerlen = 0x4, entries = DCB_MAX_NUM_ENTRIES; 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,9 +5544,6 @@ parse_dcb_table(struct drm_device *dev, struct nvbios *bios, bool twoHeads)
int recordlength = 8, confofs = 4; int recordlength = 8, confofs = 4;
int i; int i;
dcb = bios->pub.dcb = &bdcb->dcb;
dcb->entries = 0;
/* get the offset from 0x36 */ /* get the offset from 0x36 */
if (dev_priv->card_type > NV_04) { if (dev_priv->card_type > NV_04) {
dcbptr = ROM16(bios->data[0x36]); dcbptr = ROM16(bios->data[0x36]);
...@@ -5568,21 +5565,21 @@ parse_dcb_table(struct drm_device *dev, struct nvbios *bios, bool twoHeads) ...@@ -5568,21 +5565,21 @@ parse_dcb_table(struct drm_device *dev, struct nvbios *bios, bool twoHeads)
dcbtable = &bios->data[dcbptr]; dcbtable = &bios->data[dcbptr];
/* get DCB version */ /* get DCB version */
bdcb->version = dcbtable[0]; dcb->version = dcbtable[0];
NV_TRACE(dev, "Found Display Configuration Block version %d.%d\n", NV_TRACE(dev, "Found Display Configuration Block version %d.%d\n",
bdcb->version >> 4, bdcb->version & 0xf); dcb->version >> 4, dcb->version & 0xf);
if (bdcb->version >= 0x20) { /* NV17+ */ if (dcb->version >= 0x20) { /* NV17+ */
uint32_t sig; uint32_t sig;
if (bdcb->version >= 0x30) { /* NV40+ */ if (dcb->version >= 0x30) { /* NV40+ */
headerlen = dcbtable[1]; headerlen = dcbtable[1];
entries = dcbtable[2]; entries = dcbtable[2];
recordlength = dcbtable[3]; recordlength = dcbtable[3];
i2ctabptr = ROM16(dcbtable[4]); i2ctabptr = ROM16(dcbtable[4]);
sig = ROM32(dcbtable[6]); sig = ROM32(dcbtable[6]);
bdcb->gpio_table_ptr = ROM16(dcbtable[10]); dcb->gpio_table_ptr = ROM16(dcbtable[10]);
bdcb->connector_table_ptr = ROM16(dcbtable[20]); dcb->connector_table_ptr = ROM16(dcbtable[20]);
} else { } else {
i2ctabptr = ROM16(dcbtable[2]); i2ctabptr = ROM16(dcbtable[2]);
sig = ROM32(dcbtable[4]); sig = ROM32(dcbtable[4]);
...@@ -5594,7 +5591,7 @@ parse_dcb_table(struct drm_device *dev, struct nvbios *bios, bool twoHeads) ...@@ -5594,7 +5591,7 @@ parse_dcb_table(struct drm_device *dev, struct nvbios *bios, bool twoHeads)
"signature (%08X)\n", sig); "signature (%08X)\n", sig);
return -EINVAL; return -EINVAL;
} }
} else if (bdcb->version >= 0x15) { /* some NV11 and NV20 */ } else if (dcb->version >= 0x15) { /* some NV11 and NV20 */
char sig[8] = { 0 }; char sig[8] = { 0 };
strncpy(sig, (char *)&dcbtable[-7], 7); strncpy(sig, (char *)&dcbtable[-7], 7);
...@@ -5642,9 +5639,9 @@ parse_dcb_table(struct drm_device *dev, struct nvbios *bios, bool twoHeads) ...@@ -5642,9 +5639,9 @@ parse_dcb_table(struct drm_device *dev, struct nvbios *bios, bool twoHeads)
if (!i2ctabptr) if (!i2ctabptr)
NV_WARN(dev, "No pointer to DCB I2C port table\n"); NV_WARN(dev, "No pointer to DCB I2C port table\n");
else { else {
bdcb->i2c_table = &bios->data[i2ctabptr]; dcb->i2c_table = &bios->data[i2ctabptr];
if (bdcb->version >= 0x30) if (dcb->version >= 0x30)
bdcb->i2c_default_indices = bdcb->i2c_table[4]; dcb->i2c_default_indices = dcb->i2c_table[4];
} }
parse_dcb_gpio_table(bios); parse_dcb_gpio_table(bios);
...@@ -5674,7 +5671,7 @@ parse_dcb_table(struct drm_device *dev, struct nvbios *bios, bool twoHeads) ...@@ -5674,7 +5671,7 @@ parse_dcb_table(struct drm_device *dev, struct nvbios *bios, bool twoHeads)
NV_TRACEWARN(dev, "Raw DCB entry %d: %08x %08x\n", NV_TRACEWARN(dev, "Raw DCB entry %d: %08x %08x\n",
dcb->entries, connection, config); dcb->entries, connection, config);
if (!parse_dcb_entry(dev, bdcb, connection, config)) if (!parse_dcb_entry(dev, dcb, connection, config))
break; break;
} }
...@@ -5682,7 +5679,7 @@ parse_dcb_table(struct drm_device *dev, struct nvbios *bios, bool twoHeads) ...@@ -5682,7 +5679,7 @@ parse_dcb_table(struct drm_device *dev, struct nvbios *bios, bool twoHeads)
* apart for v2.1+ not being known for requiring merging, this * apart for v2.1+ not being known for requiring merging, this
* guarantees dcbent->index is the index of the entry in the rom image * guarantees dcbent->index is the index of the entry in the rom image
*/ */
if (bdcb->version < 0x21) if (dcb->version < 0x21)
merge_like_dcb_entries(dev, dcb); merge_like_dcb_entries(dev, dcb);
return dcb->entries ? 0 : -ENXIO; return dcb->entries ? 0 : -ENXIO;
...@@ -5691,8 +5688,7 @@ parse_dcb_table(struct drm_device *dev, struct nvbios *bios, bool twoHeads) ...@@ -5691,8 +5688,7 @@ parse_dcb_table(struct drm_device *dev, struct nvbios *bios, bool twoHeads)
static void static void
fixup_legacy_connector(struct nvbios *bios) fixup_legacy_connector(struct nvbios *bios)
{ {
struct bios_parsed_dcb *bdcb = &bios->bdcb; struct dcb_table *dcb = &bios->dcb;
struct parsed_dcb *dcb = &bdcb->dcb;
int high = 0, i; int high = 0, i;
/* /*
...@@ -5701,7 +5697,7 @@ fixup_legacy_connector(struct nvbios *bios) ...@@ -5701,7 +5697,7 @@ fixup_legacy_connector(struct nvbios *bios)
* indices are all 0. We don't need the connector indices on pre-G80 * indices are all 0. We don't need the connector indices on pre-G80
* chips (yet?) so limit the use to DCB 4.0 and above. * chips (yet?) so limit the use to DCB 4.0 and above.
*/ */
if (bdcb->version >= 0x40) if (dcb->version >= 0x40)
return; return;
/* /*
...@@ -5741,7 +5737,7 @@ fixup_legacy_connector(struct nvbios *bios) ...@@ -5741,7 +5737,7 @@ fixup_legacy_connector(struct nvbios *bios)
static void static void
fixup_legacy_i2c(struct nvbios *bios) fixup_legacy_i2c(struct nvbios *bios)
{ {
struct parsed_dcb *dcb = &bios->bdcb.dcb; struct dcb_table *dcb = &bios->dcb;
int i; int i;
for (i = 0; i < dcb->entries; i++) { for (i = 0; i < dcb->entries; i++) {
...@@ -5947,9 +5943,9 @@ nouveau_run_vbios_init(struct drm_device *dev) ...@@ -5947,9 +5943,9 @@ nouveau_run_vbios_init(struct drm_device *dev)
} }
if (dev_priv->card_type >= NV_50) { if (dev_priv->card_type >= NV_50) {
for (i = 0; i < bios->bdcb.dcb.entries; i++) { for (i = 0; i < bios->dcb.entries; i++) {
nouveau_bios_run_display_table(dev, nouveau_bios_run_display_table(dev,
&bios->bdcb.dcb.entry[i], &bios->dcb.entry[i],
0, 0); 0, 0);
} }
} }
...@@ -5967,7 +5963,7 @@ nouveau_bios_i2c_devices_takedown(struct drm_device *dev) ...@@ -5967,7 +5963,7 @@ nouveau_bios_i2c_devices_takedown(struct drm_device *dev)
struct dcb_i2c_entry *entry; struct dcb_i2c_entry *entry;
int i; int i;
entry = &bios->bdcb.dcb.i2c[0]; entry = &bios->dcb.i2c[0];
for (i = 0; i < DCB_MAX_NUM_I2C_ENTRIES; i++, entry++) for (i = 0; i < DCB_MAX_NUM_I2C_ENTRIES; i++, entry++)
nouveau_i2c_fini(dev, entry); nouveau_i2c_fini(dev, entry);
} }
......
...@@ -77,12 +77,6 @@ struct dcb_i2c_entry { ...@@ -77,12 +77,6 @@ struct dcb_i2c_entry {
struct nouveau_i2c_chan *chan; struct nouveau_i2c_chan *chan;
}; };
struct parsed_dcb {
int entries;
struct dcb_entry entry[DCB_MAX_NUM_ENTRIES];
struct dcb_i2c_entry i2c[DCB_MAX_NUM_I2C_ENTRIES];
};
enum dcb_gpio_tag { enum dcb_gpio_tag {
DCB_GPIO_TVDAC0 = 0xc, DCB_GPIO_TVDAC0 = 0xc,
DCB_GPIO_TVDAC1 = 0x2d, DCB_GPIO_TVDAC1 = 0x2d,
...@@ -111,13 +105,15 @@ struct dcb_connector_table { ...@@ -111,13 +105,15 @@ struct dcb_connector_table {
struct dcb_connector_table_entry entry[DCB_MAX_NUM_CONNECTOR_ENTRIES]; struct dcb_connector_table_entry entry[DCB_MAX_NUM_CONNECTOR_ENTRIES];
}; };
struct bios_parsed_dcb { struct dcb_table {
uint8_t version; uint8_t version;
struct parsed_dcb dcb; int entries;
struct dcb_entry entry[DCB_MAX_NUM_ENTRIES];
uint8_t *i2c_table; uint8_t *i2c_table;
uint8_t i2c_default_indices; uint8_t i2c_default_indices;
struct dcb_i2c_entry i2c[DCB_MAX_NUM_I2C_ENTRIES];
uint16_t gpio_table_ptr; uint16_t gpio_table_ptr;
struct dcb_gpio_table gpio; struct dcb_gpio_table gpio;
...@@ -191,8 +187,6 @@ struct pll_lims { ...@@ -191,8 +187,6 @@ struct pll_lims {
}; };
struct nouveau_bios_info { struct nouveau_bios_info {
struct parsed_dcb *dcb;
uint8_t chip_version; uint8_t chip_version;
uint32_t dactestval; uint32_t dactestval;
...@@ -234,7 +228,7 @@ struct nvbios { ...@@ -234,7 +228,7 @@ struct nvbios {
uint16_t some_script_ptr; /* BIT I + 14 */ uint16_t some_script_ptr; /* BIT I + 14 */
uint16_t init96_tbl_ptr; /* BIT I + 16 */ uint16_t init96_tbl_ptr; /* BIT I + 16 */
struct bios_parsed_dcb bdcb; struct dcb_table dcb;
struct { struct {
int crtchead; int crtchead;
......
...@@ -259,11 +259,11 @@ nouveau_i2c_find(struct drm_device *dev, int index) ...@@ -259,11 +259,11 @@ nouveau_i2c_find(struct drm_device *dev, int index)
if (index >= DCB_MAX_NUM_I2C_ENTRIES) if (index >= DCB_MAX_NUM_I2C_ENTRIES)
return NULL; return NULL;
if (!bios->bdcb.dcb.i2c[index].chan) { if (!bios->dcb.i2c[index].chan) {
if (nouveau_i2c_init(dev, &bios->bdcb.dcb.i2c[index], index)) if (nouveau_i2c_init(dev, &bios->dcb.i2c[index], index))
return NULL; return NULL;
} }
return bios->bdcb.dcb.i2c[index].chan; return bios->dcb.i2c[index].chan;
} }
...@@ -93,7 +93,7 @@ int ...@@ -93,7 +93,7 @@ int
nv04_display_create(struct drm_device *dev) nv04_display_create(struct drm_device *dev)
{ {
struct drm_nouveau_private *dev_priv = dev->dev_private; struct drm_nouveau_private *dev_priv = dev->dev_private;
struct parsed_dcb *dcb = dev_priv->vbios->dcb; struct dcb_table *dcb = &dev_priv->VBIOS.dcb;
struct drm_encoder *encoder; struct drm_encoder *encoder;
struct drm_crtc *crtc; struct drm_crtc *crtc;
uint16_t connector[16] = { 0 }; uint16_t connector[16] = { 0 };
......
...@@ -262,7 +262,7 @@ int nv04_tv_create(struct drm_device *dev, struct dcb_entry *entry) ...@@ -262,7 +262,7 @@ int nv04_tv_create(struct drm_device *dev, struct dcb_entry *entry)
nv_encoder->or = ffs(entry->or) - 1; nv_encoder->or = ffs(entry->or) - 1;
/* Run the slave-specific initialization */ /* Run the slave-specific initialization */
adap = &dev_priv->vbios->dcb->i2c[i2c_index].chan->adapter; adap = &dev_priv->VBIOS.dcb.i2c[i2c_index].chan->adapter;
was_locked = NVLockVgaCrtcs(dev, false); was_locked = NVLockVgaCrtcs(dev, false);
......
...@@ -465,7 +465,7 @@ static int nv50_display_disable(struct drm_device *dev) ...@@ -465,7 +465,7 @@ static int nv50_display_disable(struct drm_device *dev)
int nv50_display_create(struct drm_device *dev) int nv50_display_create(struct drm_device *dev)
{ {
struct drm_nouveau_private *dev_priv = dev->dev_private; struct drm_nouveau_private *dev_priv = dev->dev_private;
struct parsed_dcb *dcb = dev_priv->vbios->dcb; struct dcb_table *dcb = &dev_priv->VBIOS.dcb;
uint32_t connector[16] = {}; uint32_t connector[16] = {};
int ret, i; int ret, i;
...@@ -667,8 +667,8 @@ nv50_display_irq_head(struct drm_device *dev, int *phead, ...@@ -667,8 +667,8 @@ nv50_display_irq_head(struct drm_device *dev, int *phead,
return -1; return -1;
} }
for (i = 0; i < dev_priv->vbios->dcb->entries; i++) { for (i = 0; i < dev_priv->VBIOS.dcb.entries; i++) {
struct dcb_entry *dcbent = &dev_priv->vbios->dcb->entry[i]; struct dcb_entry *dcbent = &dev_priv->VBIOS.dcb.entry[i];
if (dcbent->type != type) if (dcbent->type != type)
continue; continue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment