linux/drivers/gpu/drm/nouveau/nvkm/engine/disp/dacgf119.c
<<
>>
Prefs
   1/*
   2 * Copyright 2017 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 "ior.h"
  23
  24static void
  25gf119_dac_clock(struct nvkm_ior *dac)
  26{
  27        struct nvkm_device *device = dac->disp->engine.subdev.device;
  28        const u32 doff = nv50_ior_base(dac);
  29        nvkm_mask(device, 0x612280 + doff, 0x07070707, 0x00000000);
  30}
  31
  32static void
  33gf119_dac_state(struct nvkm_ior *dac, struct nvkm_ior_state *state)
  34{
  35        struct nvkm_device *device = dac->disp->engine.subdev.device;
  36        const u32 coff = (state == &dac->asy) * 0x20000 + dac->id * 0x20;
  37        u32 ctrl = nvkm_rd32(device, 0x640180 + coff);
  38
  39        state->proto_evo = (ctrl & 0x00000f00) >> 8;
  40        switch (state->proto_evo) {
  41        case 0: state->proto = CRT; break;
  42        default:
  43                state->proto = UNKNOWN;
  44                break;
  45        }
  46
  47        state->head = ctrl & 0x0000000f;
  48}
  49
  50static const struct nvkm_ior_func
  51gf119_dac = {
  52        .state = gf119_dac_state,
  53        .power = nv50_dac_power,
  54        .sense = nv50_dac_sense,
  55        .clock = gf119_dac_clock,
  56};
  57
  58int
  59gf119_dac_new(struct nvkm_disp *disp, int id)
  60{
  61        return nvkm_ior_new_(&gf119_dac, disp, DAC, id);
  62}
  63
  64int
  65gf119_dac_cnt(struct nvkm_disp *disp, unsigned long *pmask)
  66{
  67        struct nvkm_device *device = disp->engine.subdev.device;
  68        *pmask = (nvkm_rd32(device, 0x612004) & 0x000000f0) >> 4;
  69        return 4;
  70}
  71