Commit 8e992c8d authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/bios: store a type/mask hash in parsed dcb data

Matches format used by a couple of other vbios tables, useful
to have laying around already calculated.
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 548ddb6d
...@@ -16,6 +16,8 @@ enum dcb_output_type { ...@@ -16,6 +16,8 @@ enum dcb_output_type {
struct dcb_output { struct dcb_output {
int index; /* may not be raw dcb index if merging has happened */ int index; /* may not be raw dcb index if merging has happened */
u16 hasht;
u16 hashm;
enum dcb_output_type type; enum dcb_output_type type;
uint8_t i2c_index; uint8_t i2c_index;
uint8_t heads; uint8_t heads;
......
...@@ -107,6 +107,18 @@ dcb_outp(struct nouveau_bios *bios, u8 idx, u8 *ver, u8 *len) ...@@ -107,6 +107,18 @@ dcb_outp(struct nouveau_bios *bios, u8 idx, u8 *ver, u8 *len)
return 0x0000; return 0x0000;
} }
static inline u16
dcb_outp_hasht(struct dcb_output *outp)
{
return (outp->extdev << 8) | (outp->location << 4) | outp->type;
}
static inline u16
dcb_outp_hashm(struct dcb_output *outp)
{
return (outp->heads << 8) | (outp->link << 6) | outp->or;
}
u16 u16
dcb_outp_parse(struct nouveau_bios *bios, u8 idx, u8 *ver, u8 *len, dcb_outp_parse(struct nouveau_bios *bios, u8 idx, u8 *ver, u8 *len,
struct dcb_output *outp) struct dcb_output *outp)
...@@ -143,29 +155,20 @@ dcb_outp_parse(struct nouveau_bios *bios, u8 idx, u8 *ver, u8 *len, ...@@ -143,29 +155,20 @@ dcb_outp_parse(struct nouveau_bios *bios, u8 idx, u8 *ver, u8 *len,
break; break;
} }
} }
outp->hasht = dcb_outp_hasht(outp);
outp->hashm = dcb_outp_hashm(outp);
} }
return dcb; return dcb;
} }
static inline u16
dcb_outp_hasht(struct dcb_output *outp)
{
return (outp->location << 4) | outp->type;
}
static inline u16
dcb_outp_hashm(struct dcb_output *outp)
{
return (outp->heads << 8) | (outp->link << 6) | outp->or;
}
u16 u16
dcb_outp_match(struct nouveau_bios *bios, u16 type, u16 mask, dcb_outp_match(struct nouveau_bios *bios, u16 type, u16 mask,
u8 *ver, u8 *len, struct dcb_output *outp) u8 *ver, u8 *len, struct dcb_output *outp)
{ {
u16 dcb, idx = 0; u16 dcb, idx = 0;
while ((dcb = dcb_outp_parse(bios, idx++, ver, len, outp))) { while ((dcb = dcb_outp_parse(bios, idx++, ver, len, outp))) {
if (dcb_outp_hasht(outp) == type) { if ((dcb_outp_hasht(outp) & 0x00ff) == (type & 0x00ff)) {
if ((dcb_outp_hashm(outp) & mask) == mask) if ((dcb_outp_hashm(outp) & mask) == mask)
break; break;
} }
......
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