linux/drivers/gpu/drm/nouveau/dispnv50/head917d.c
<<
>>
Prefs
   1/*
   2 * Copyright 2018 Red Hat Inc.
   3 *
   4 * Permission is hereby granted, free of charge, to any person obtaining a
   5 * copy of this software and associated documentation files (the "Software"),
   6 * to deal in the Software without restriction, including without limitation
   7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
   8 * and/or sell copies of the Software, and to permit persons to whom the
   9 * Software is furnished to do so, subject to the following conditions:
  10 *
  11 * The above copyright notice and this permission notice shall be included in
  12 * all copies or substantial portions of the Software.
  13 *
  14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20 * OTHER DEALINGS IN THE SOFTWARE.
  21 */
  22#include "head.h"
  23#include "core.h"
  24
  25static void
  26head917d_dither(struct nv50_head *head, struct nv50_head_atom *asyh)
  27{
  28        struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
  29        u32 *push;
  30        if ((push = evo_wait(core, 2))) {
  31                evo_mthd(push, 0x04a0 + (head->base.index * 0x0300), 1);
  32                evo_data(push, asyh->dither.mode << 3 |
  33                               asyh->dither.bits << 1 |
  34                               asyh->dither.enable);
  35                evo_kick(push, core);
  36        }
  37}
  38
  39static void
  40head917d_base(struct nv50_head *head, struct nv50_head_atom *asyh)
  41{
  42        struct nv50_dmac *core = &nv50_disp(head->base.base.dev)->core->chan;
  43        u32 bounds = 0;
  44        u32 *push;
  45
  46        if (asyh->base.cpp) {
  47                switch (asyh->base.cpp) {
  48                case 8: bounds |= 0x00000500; break;
  49                case 4: bounds |= 0x00000300; break;
  50                case 2: bounds |= 0x00000100; break;
  51                case 1: bounds |= 0x00000000; break;
  52                default:
  53                        WARN_ON(1);
  54                        break;
  55                }
  56                bounds |= 0x00020001;
  57        }
  58
  59        if ((push = evo_wait(core, 2))) {
  60                evo_mthd(push, 0x04d0 + head->base.index * 0x300, 1);
  61                evo_data(push, bounds);
  62                evo_kick(push, core);
  63        }
  64}
  65
  66int
  67head917d_curs_layout(struct nv50_head *head, struct nv50_wndw_atom *asyw,
  68                     struct nv50_head_atom *asyh)
  69{
  70        switch (asyw->state.fb->width) {
  71        case  32: asyh->curs.layout = 0; break;
  72        case  64: asyh->curs.layout = 1; break;
  73        case 128: asyh->curs.layout = 2; break;
  74        case 256: asyh->curs.layout = 3; break;
  75        default:
  76                return -EINVAL;
  77        }
  78        return 0;
  79}
  80
  81const struct nv50_head_func
  82head917d = {
  83        .view = head907d_view,
  84        .mode = head907d_mode,
  85        .olut = head907d_olut,
  86        .olut_set = head907d_olut_set,
  87        .olut_clr = head907d_olut_clr,
  88        .core_calc = head507d_core_calc,
  89        .core_set = head907d_core_set,
  90        .core_clr = head907d_core_clr,
  91        .curs_layout = head917d_curs_layout,
  92        .curs_format = head507d_curs_format,
  93        .curs_set = head907d_curs_set,
  94        .curs_clr = head907d_curs_clr,
  95        .base = head917d_base,
  96        .ovly = head907d_ovly,
  97        .dither = head917d_dither,
  98        .procamp = head907d_procamp,
  99        .or = head907d_or,
 100};
 101