linux/drivers/gpu/drm/nouveau/core/engine/mpeg/nv40.c
<<
>>
Prefs
   1/*
   2 * Copyright 2012 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 * Authors: Ben Skeggs
  23 */
  24
  25#include <core/os.h>
  26#include <core/class.h>
  27#include <core/engctx.h>
  28
  29#include <subdev/fb.h>
  30#include <subdev/timer.h>
  31#include <subdev/instmem.h>
  32
  33#include <engine/mpeg.h>
  34#include <engine/graph/nv40.h>
  35
  36struct nv40_mpeg_priv {
  37        struct nouveau_mpeg base;
  38};
  39
  40struct nv40_mpeg_chan {
  41        struct nouveau_mpeg_chan base;
  42};
  43
  44/*******************************************************************************
  45 * PMPEG context
  46 ******************************************************************************/
  47
  48static int
  49nv40_mpeg_context_ctor(struct nouveau_object *parent,
  50                       struct nouveau_object *engine,
  51                       struct nouveau_oclass *oclass, void *data, u32 size,
  52                       struct nouveau_object **pobject)
  53{
  54        struct nv40_mpeg_chan *chan;
  55        int ret;
  56
  57        ret = nouveau_mpeg_context_create(parent, engine, oclass, NULL,
  58                                          264 * 4, 16,
  59                                          NVOBJ_FLAG_ZERO_ALLOC, &chan);
  60        *pobject = nv_object(chan);
  61        if (ret)
  62                return ret;
  63
  64        nv_wo32(&chan->base.base, 0x78, 0x02001ec1);
  65        return 0;
  66}
  67
  68static int
  69nv40_mpeg_context_fini(struct nouveau_object *object, bool suspend)
  70{
  71
  72        struct nv40_mpeg_priv *priv = (void *)object->engine;
  73        struct nv40_mpeg_chan *chan = (void *)object;
  74        u32 inst = 0x80000000 | nv_gpuobj(chan)->addr >> 4;
  75
  76        nv_mask(priv, 0x00b32c, 0x00000001, 0x00000000);
  77        if (nv_rd32(priv, 0x00b318) == inst)
  78                nv_mask(priv, 0x00b318, 0x80000000, 0x00000000);
  79        nv_mask(priv, 0x00b32c, 0x00000001, 0x00000001);
  80        return 0;
  81}
  82
  83static struct nouveau_oclass
  84nv40_mpeg_cclass = {
  85        .handle = NV_ENGCTX(MPEG, 0x40),
  86        .ofuncs = &(struct nouveau_ofuncs) {
  87                .ctor = nv40_mpeg_context_ctor,
  88                .dtor = _nouveau_mpeg_context_dtor,
  89                .init = _nouveau_mpeg_context_init,
  90                .fini = nv40_mpeg_context_fini,
  91                .rd32 = _nouveau_mpeg_context_rd32,
  92                .wr32 = _nouveau_mpeg_context_wr32,
  93        },
  94};
  95
  96/*******************************************************************************
  97 * PMPEG engine/subdev functions
  98 ******************************************************************************/
  99
 100static void
 101nv40_mpeg_intr(struct nouveau_subdev *subdev)
 102{
 103        struct nv40_mpeg_priv *priv = (void *)subdev;
 104        u32 stat;
 105
 106        if ((stat = nv_rd32(priv, 0x00b100)))
 107                nv31_mpeg_intr(subdev);
 108
 109        if ((stat = nv_rd32(priv, 0x00b800))) {
 110                nv_error(priv, "PMSRCH 0x%08x\n", stat);
 111                nv_wr32(priv, 0x00b800, stat);
 112        }
 113}
 114
 115static int
 116nv40_mpeg_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
 117               struct nouveau_oclass *oclass, void *data, u32 size,
 118               struct nouveau_object **pobject)
 119{
 120        struct nv40_mpeg_priv *priv;
 121        int ret;
 122
 123        ret = nouveau_mpeg_create(parent, engine, oclass, &priv);
 124        *pobject = nv_object(priv);
 125        if (ret)
 126                return ret;
 127
 128        nv_subdev(priv)->unit = 0x00000002;
 129        nv_subdev(priv)->intr = nv40_mpeg_intr;
 130        nv_engine(priv)->cclass = &nv40_mpeg_cclass;
 131        nv_engine(priv)->sclass = nv31_mpeg_sclass;
 132        nv_engine(priv)->tile_prog = nv31_mpeg_tile_prog;
 133        return 0;
 134}
 135
 136struct nouveau_oclass
 137nv40_mpeg_oclass = {
 138        .handle = NV_ENGINE(MPEG, 0x40),
 139        .ofuncs = &(struct nouveau_ofuncs) {
 140                .ctor = nv40_mpeg_ctor,
 141                .dtor = _nouveau_mpeg_dtor,
 142                .init = nv31_mpeg_init,
 143                .fini = _nouveau_mpeg_fini,
 144        },
 145};
 146