提交 b969fa52 编写于 作者: E Emil Velikov 提交者: Ben Skeggs

drm/nv50-/disp: use the number of dac, sor, pior rather than hardcoded values

The values are already stored on chipset specific basis in the ctor.
Make the most of them and simplify the code further by using a temporary
variable to avoid code duplication.
Signed-off-by: NEmil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: NBen Skeggs <bskeggs@redhat.com>
上级 c98b8194
...@@ -628,7 +628,7 @@ nv50_disp_base_init(struct nouveau_object *object) ...@@ -628,7 +628,7 @@ nv50_disp_base_init(struct nouveau_object *object)
} }
/* ... PIOR caps */ /* ... PIOR caps */
for (i = 0; i < 3; i++) { for (i = 0; i < priv->pior.nr; i++) {
tmp = nv_rd32(priv, 0x61e000 + (i * 0x800)); tmp = nv_rd32(priv, 0x61e000 + (i * 0x800));
nv_wr32(priv, 0x6101f0 + (i * 0x04), tmp); nv_wr32(priv, 0x6101f0 + (i * 0x04), tmp);
} }
...@@ -834,10 +834,11 @@ exec_script(struct nv50_disp_priv *priv, int head, int id) ...@@ -834,10 +834,11 @@ exec_script(struct nv50_disp_priv *priv, int head, int id)
u8 ver, hdr, cnt, len; u8 ver, hdr, cnt, len;
u16 data; u16 data;
u32 ctrl = 0x00000000; u32 ctrl = 0x00000000;
u32 reg;
int i; int i;
/* DAC */ /* DAC */
for (i = 0; !(ctrl & (1 << head)) && i < 3; i++) for (i = 0; !(ctrl & (1 << head)) && i < priv->dac.nr; i++)
ctrl = nv_rd32(priv, 0x610b5c + (i * 8)); ctrl = nv_rd32(priv, 0x610b5c + (i * 8));
/* SOR */ /* SOR */
...@@ -845,19 +846,18 @@ exec_script(struct nv50_disp_priv *priv, int head, int id) ...@@ -845,19 +846,18 @@ exec_script(struct nv50_disp_priv *priv, int head, int id)
if (nv_device(priv)->chipset < 0x90 || if (nv_device(priv)->chipset < 0x90 ||
nv_device(priv)->chipset == 0x92 || nv_device(priv)->chipset == 0x92 ||
nv_device(priv)->chipset == 0xa0) { nv_device(priv)->chipset == 0xa0) {
for (i = 0; !(ctrl & (1 << head)) && i < 2; i++) reg = 0x610b74;
ctrl = nv_rd32(priv, 0x610b74 + (i * 8));
i += 4;
} else { } else {
for (i = 0; !(ctrl & (1 << head)) && i < 4; i++) reg = 0x610798;
ctrl = nv_rd32(priv, 0x610798 + (i * 8));
i += 4;
} }
for (i = 0; !(ctrl & (1 << head)) && i < priv->sor.nr; i++)
ctrl = nv_rd32(priv, reg + (i * 8));
i += 4;
} }
/* PIOR */ /* PIOR */
if (!(ctrl & (1 << head))) { if (!(ctrl & (1 << head))) {
for (i = 0; !(ctrl & (1 << head)) && i < 3; i++) for (i = 0; !(ctrl & (1 << head)) && i < priv->pior.nr; i++)
ctrl = nv_rd32(priv, 0x610b84 + (i * 8)); ctrl = nv_rd32(priv, 0x610b84 + (i * 8));
i += 8; i += 8;
} }
...@@ -893,10 +893,11 @@ exec_clkcmp(struct nv50_disp_priv *priv, int head, int id, u32 pclk, ...@@ -893,10 +893,11 @@ exec_clkcmp(struct nv50_disp_priv *priv, int head, int id, u32 pclk,
u8 ver, hdr, cnt, len; u8 ver, hdr, cnt, len;
u32 ctrl = 0x00000000; u32 ctrl = 0x00000000;
u32 data, conf = ~0; u32 data, conf = ~0;
u32 reg;
int i; int i;
/* DAC */ /* DAC */
for (i = 0; !(ctrl & (1 << head)) && i < 3; i++) for (i = 0; !(ctrl & (1 << head)) && i < priv->dac.nr; i++)
ctrl = nv_rd32(priv, 0x610b58 + (i * 8)); ctrl = nv_rd32(priv, 0x610b58 + (i * 8));
/* SOR */ /* SOR */
...@@ -904,19 +905,18 @@ exec_clkcmp(struct nv50_disp_priv *priv, int head, int id, u32 pclk, ...@@ -904,19 +905,18 @@ exec_clkcmp(struct nv50_disp_priv *priv, int head, int id, u32 pclk,
if (nv_device(priv)->chipset < 0x90 || if (nv_device(priv)->chipset < 0x90 ||
nv_device(priv)->chipset == 0x92 || nv_device(priv)->chipset == 0x92 ||
nv_device(priv)->chipset == 0xa0) { nv_device(priv)->chipset == 0xa0) {
for (i = 0; !(ctrl & (1 << head)) && i < 2; i++) reg = 0x610b70;
ctrl = nv_rd32(priv, 0x610b70 + (i * 8));
i += 4;
} else { } else {
for (i = 0; !(ctrl & (1 << head)) && i < 4; i++) reg = 0x610794;
ctrl = nv_rd32(priv, 0x610794 + (i * 8));
i += 4;
} }
for (i = 0; !(ctrl & (1 << head)) && i < priv->sor.nr; i++)
ctrl = nv_rd32(priv, reg + (i * 8));
i += 4;
} }
/* PIOR */ /* PIOR */
if (!(ctrl & (1 << head))) { if (!(ctrl & (1 << head))) {
for (i = 0; !(ctrl & (1 << head)) && i < 3; i++) for (i = 0; !(ctrl & (1 << head)) && i < priv->pior.nr; i++)
ctrl = nv_rd32(priv, 0x610b80 + (i * 8)); ctrl = nv_rd32(priv, 0x610b80 + (i * 8));
i += 8; i += 8;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册