Commit 804ea3ec authored by Peter Rosin's avatar Peter Rosin Committed by Daniel Vetter

drm: nouveau: remove dead code and pointless local lut storage

The redundant fb helpers .load_lut, .gamma_set and .gamma_get are
no longer used. Remove the dead code and hook up the crtc .gamma_set
to use the crtc gamma_store directly instead of duplicating that
info locally.
Acked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarPeter Rosin <peda@axentia.se>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20170713162538.22788-12-peda@axentia.se
parent 9ed85e14
...@@ -764,13 +764,18 @@ nv_crtc_gamma_load(struct drm_crtc *crtc) ...@@ -764,13 +764,18 @@ nv_crtc_gamma_load(struct drm_crtc *crtc)
struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
struct drm_device *dev = nv_crtc->base.dev; struct drm_device *dev = nv_crtc->base.dev;
struct rgb { uint8_t r, g, b; } __attribute__((packed)) *rgbs; struct rgb { uint8_t r, g, b; } __attribute__((packed)) *rgbs;
u16 *r, *g, *b;
int i; int i;
rgbs = (struct rgb *)nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index].DAC; rgbs = (struct rgb *)nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index].DAC;
r = crtc->gamma_store;
g = r + crtc->gamma_size;
b = g + crtc->gamma_size;
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
rgbs[i].r = nv_crtc->lut.r[i] >> 8; rgbs[i].r = *r++ >> 8;
rgbs[i].g = nv_crtc->lut.g[i] >> 8; rgbs[i].g = *g++ >> 8;
rgbs[i].b = nv_crtc->lut.b[i] >> 8; rgbs[i].b = *b++ >> 8;
} }
nouveau_hw_load_state_palette(dev, nv_crtc->index, &nv04_display(dev)->mode_reg); nouveau_hw_load_state_palette(dev, nv_crtc->index, &nv04_display(dev)->mode_reg);
...@@ -792,13 +797,6 @@ nv_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, ...@@ -792,13 +797,6 @@ nv_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
struct drm_modeset_acquire_ctx *ctx) struct drm_modeset_acquire_ctx *ctx)
{ {
struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
int i;
for (i = 0; i < size; i++) {
nv_crtc->lut.r[i] = r[i];
nv_crtc->lut.g[i] = g[i];
nv_crtc->lut.b[i] = b[i];
}
/* We need to know the depth before we upload, but it's possible to /* We need to know the depth before we upload, but it's possible to
* get called before a framebuffer is bound. If this is the case, * get called before a framebuffer is bound. If this is the case,
...@@ -1095,7 +1093,6 @@ static const struct drm_crtc_helper_funcs nv04_crtc_helper_funcs = { ...@@ -1095,7 +1093,6 @@ static const struct drm_crtc_helper_funcs nv04_crtc_helper_funcs = {
.mode_set = nv_crtc_mode_set, .mode_set = nv_crtc_mode_set,
.mode_set_base = nv04_crtc_mode_set_base, .mode_set_base = nv04_crtc_mode_set_base,
.mode_set_base_atomic = nv04_crtc_mode_set_base_atomic, .mode_set_base_atomic = nv04_crtc_mode_set_base_atomic,
.load_lut = nv_crtc_gamma_load,
.disable = nv_crtc_disable, .disable = nv_crtc_disable,
}; };
...@@ -1103,17 +1100,12 @@ int ...@@ -1103,17 +1100,12 @@ int
nv04_crtc_create(struct drm_device *dev, int crtc_num) nv04_crtc_create(struct drm_device *dev, int crtc_num)
{ {
struct nouveau_crtc *nv_crtc; struct nouveau_crtc *nv_crtc;
int ret, i; int ret;
nv_crtc = kzalloc(sizeof(*nv_crtc), GFP_KERNEL); nv_crtc = kzalloc(sizeof(*nv_crtc), GFP_KERNEL);
if (!nv_crtc) if (!nv_crtc)
return -ENOMEM; return -ENOMEM;
for (i = 0; i < 256; i++) {
nv_crtc->lut.r[i] = i << 8;
nv_crtc->lut.g[i] = i << 8;
nv_crtc->lut.b[i] = i << 8;
}
nv_crtc->lut.depth = 0; nv_crtc->lut.depth = 0;
nv_crtc->index = crtc_num; nv_crtc->index = crtc_num;
......
...@@ -61,9 +61,6 @@ struct nouveau_crtc { ...@@ -61,9 +61,6 @@ struct nouveau_crtc {
struct { struct {
struct nouveau_bo *nvbo; struct nouveau_bo *nvbo;
uint16_t r[256];
uint16_t g[256];
uint16_t b[256];
int depth; int depth;
} lut; } lut;
......
...@@ -278,26 +278,6 @@ nouveau_fbcon_accel_init(struct drm_device *dev) ...@@ -278,26 +278,6 @@ nouveau_fbcon_accel_init(struct drm_device *dev)
info->fbops = &nouveau_fbcon_ops; info->fbops = &nouveau_fbcon_ops;
} }
static void nouveau_fbcon_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
u16 blue, int regno)
{
struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
nv_crtc->lut.r[regno] = red;
nv_crtc->lut.g[regno] = green;
nv_crtc->lut.b[regno] = blue;
}
static void nouveau_fbcon_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
u16 *blue, int regno)
{
struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
*red = nv_crtc->lut.r[regno];
*green = nv_crtc->lut.g[regno];
*blue = nv_crtc->lut.b[regno];
}
static void static void
nouveau_fbcon_zfill(struct drm_device *dev, struct nouveau_fbdev *fbcon) nouveau_fbcon_zfill(struct drm_device *dev, struct nouveau_fbdev *fbcon)
{ {
...@@ -467,8 +447,6 @@ void nouveau_fbcon_gpu_lockup(struct fb_info *info) ...@@ -467,8 +447,6 @@ void nouveau_fbcon_gpu_lockup(struct fb_info *info)
} }
static const struct drm_fb_helper_funcs nouveau_fbcon_helper_funcs = { static const struct drm_fb_helper_funcs nouveau_fbcon_helper_funcs = {
.gamma_set = nouveau_fbcon_gamma_set,
.gamma_get = nouveau_fbcon_gamma_get,
.fb_probe = nouveau_fbcon_create, .fb_probe = nouveau_fbcon_create,
}; };
......
...@@ -2205,28 +2205,29 @@ nv50_head_lut_load(struct drm_crtc *crtc) ...@@ -2205,28 +2205,29 @@ nv50_head_lut_load(struct drm_crtc *crtc)
struct nv50_disp *disp = nv50_disp(crtc->dev); struct nv50_disp *disp = nv50_disp(crtc->dev);
struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
void __iomem *lut = nvbo_kmap_obj_iovirtual(nv_crtc->lut.nvbo); void __iomem *lut = nvbo_kmap_obj_iovirtual(nv_crtc->lut.nvbo);
u16 *r, *g, *b;
int i; int i;
for (i = 0; i < 256; i++) { r = crtc->gamma_store;
u16 r = nv_crtc->lut.r[i] >> 2; g = r + crtc->gamma_size;
u16 g = nv_crtc->lut.g[i] >> 2; b = g + crtc->gamma_size;
u16 b = nv_crtc->lut.b[i] >> 2;
for (i = 0; i < 256; i++) {
if (disp->disp->oclass < GF110_DISP) { if (disp->disp->oclass < GF110_DISP) {
writew(r + 0x0000, lut + (i * 0x08) + 0); writew((*r++ >> 2) + 0x0000, lut + (i * 0x08) + 0);
writew(g + 0x0000, lut + (i * 0x08) + 2); writew((*g++ >> 2) + 0x0000, lut + (i * 0x08) + 2);
writew(b + 0x0000, lut + (i * 0x08) + 4); writew((*b++ >> 2) + 0x0000, lut + (i * 0x08) + 4);
} else { } else {
writew(r + 0x6000, lut + (i * 0x20) + 0); /* 0x6000 interferes with the 14-bit color??? */
writew(g + 0x6000, lut + (i * 0x20) + 2); writew((*r++ >> 2) + 0x6000, lut + (i * 0x20) + 0);
writew(b + 0x6000, lut + (i * 0x20) + 4); writew((*g++ >> 2) + 0x6000, lut + (i * 0x20) + 2);
writew((*b++ >> 2) + 0x6000, lut + (i * 0x20) + 4);
} }
} }
} }
static const struct drm_crtc_helper_funcs static const struct drm_crtc_helper_funcs
nv50_head_help = { nv50_head_help = {
.load_lut = nv50_head_lut_load,
.atomic_check = nv50_head_atomic_check, .atomic_check = nv50_head_atomic_check,
}; };
...@@ -2235,15 +2236,6 @@ nv50_head_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, ...@@ -2235,15 +2236,6 @@ nv50_head_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
uint32_t size, uint32_t size,
struct drm_modeset_acquire_ctx *ctx) struct drm_modeset_acquire_ctx *ctx)
{ {
struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
u32 i;
for (i = 0; i < size; i++) {
nv_crtc->lut.r[i] = r[i];
nv_crtc->lut.g[i] = g[i];
nv_crtc->lut.b[i] = b[i];
}
nv50_head_lut_load(crtc); nv50_head_lut_load(crtc);
return 0; return 0;
} }
...@@ -2341,19 +2333,13 @@ nv50_head_create(struct drm_device *dev, int index) ...@@ -2341,19 +2333,13 @@ nv50_head_create(struct drm_device *dev, int index)
struct nv50_base *base; struct nv50_base *base;
struct nv50_curs *curs; struct nv50_curs *curs;
struct drm_crtc *crtc; struct drm_crtc *crtc;
int ret, i; int ret;
head = kzalloc(sizeof(*head), GFP_KERNEL); head = kzalloc(sizeof(*head), GFP_KERNEL);
if (!head) if (!head)
return -ENOMEM; return -ENOMEM;
head->base.index = index; head->base.index = index;
for (i = 0; i < 256; i++) {
head->base.lut.r[i] = i << 8;
head->base.lut.g[i] = i << 8;
head->base.lut.b[i] = i << 8;
}
ret = nv50_base_new(drm, head, &base); ret = nv50_base_new(drm, head, &base);
if (ret == 0) if (ret == 0)
ret = nv50_curs_new(drm, head, &curs); ret = nv50_curs_new(drm, head, &curs);
......
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