aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2013-02-15 21:01:59 -0500
committerBen Skeggs <bskeggs@redhat.com>2013-02-20 01:00:59 -0500
commit8e992c8d9eebc2bd3246252ee5c0422dbbbce7ae (patch)
tree5f04740005c1ae59d11699eb9c4589c7e9e6bb0e /drivers/gpu/drm
parent548ddb6dec9964fc9c0812409f3e105b07324c4f (diff)
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: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r--drivers/gpu/drm/nouveau/core/include/subdev/bios/dcb.h2
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c29
2 files changed, 18 insertions, 13 deletions
diff --git a/drivers/gpu/drm/nouveau/core/include/subdev/bios/dcb.h b/drivers/gpu/drm/nouveau/core/include/subdev/bios/dcb.h
index 9e54678a1728..123270e9813a 100644
--- a/drivers/gpu/drm/nouveau/core/include/subdev/bios/dcb.h
+++ b/drivers/gpu/drm/nouveau/core/include/subdev/bios/dcb.h
@@ -16,6 +16,8 @@ enum dcb_output_type {
16 16
17struct dcb_output { 17struct dcb_output {
18 int index; /* may not be raw dcb index if merging has happened */ 18 int index; /* may not be raw dcb index if merging has happened */
19 u16 hasht;
20 u16 hashm;
19 enum dcb_output_type type; 21 enum dcb_output_type type;
20 uint8_t i2c_index; 22 uint8_t i2c_index;
21 uint8_t heads; 23 uint8_t heads;
diff --git a/drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c b/drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c
index 73a29da0415f..2d9b9d7a7992 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c
@@ -107,6 +107,18 @@ dcb_outp(struct nouveau_bios *bios, u8 idx, u8 *ver, u8 *len)
107 return 0x0000; 107 return 0x0000;
108} 108}
109 109
110static inline u16
111dcb_outp_hasht(struct dcb_output *outp)
112{
113 return (outp->extdev << 8) | (outp->location << 4) | outp->type;
114}
115
116static inline u16
117dcb_outp_hashm(struct dcb_output *outp)
118{
119 return (outp->heads << 8) | (outp->link << 6) | outp->or;
120}
121
110u16 122u16
111dcb_outp_parse(struct nouveau_bios *bios, u8 idx, u8 *ver, u8 *len, 123dcb_outp_parse(struct nouveau_bios *bios, u8 idx, u8 *ver, u8 *len,
112 struct dcb_output *outp) 124 struct dcb_output *outp)
@@ -143,29 +155,20 @@ dcb_outp_parse(struct nouveau_bios *bios, u8 idx, u8 *ver, u8 *len,
143 break; 155 break;
144 } 156 }
145 } 157 }
158
159 outp->hasht = dcb_outp_hasht(outp);
160 outp->hashm = dcb_outp_hashm(outp);
146 } 161 }
147 return dcb; 162 return dcb;
148} 163}
149 164
150static inline u16
151dcb_outp_hasht(struct dcb_output *outp)
152{
153 return (outp->location << 4) | outp->type;
154}
155
156static inline u16
157dcb_outp_hashm(struct dcb_output *outp)
158{
159 return (outp->heads << 8) | (outp->link << 6) | outp->or;
160}
161
162u16 165u16
163dcb_outp_match(struct nouveau_bios *bios, u16 type, u16 mask, 166dcb_outp_match(struct nouveau_bios *bios, u16 type, u16 mask,
164 u8 *ver, u8 *len, struct dcb_output *outp) 167 u8 *ver, u8 *len, struct dcb_output *outp)
165{ 168{
166 u16 dcb, idx = 0; 169 u16 dcb, idx = 0;
167 while ((dcb = dcb_outp_parse(bios, idx++, ver, len, outp))) { 170 while ((dcb = dcb_outp_parse(bios, idx++, ver, len, outp))) {
168 if (dcb_outp_hasht(outp) == type) { 171 if ((dcb_outp_hasht(outp) & 0x00ff) == (type & 0x00ff)) {
169 if ((dcb_outp_hashm(outp) & mask) == mask) 172 if ((dcb_outp_hashm(outp) & mask) == mask)
170 break; 173 break;
171 } 174 }