Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright 2018 Red Hat Inc.
0003  *
0004  * Permission is hereby granted, free of charge, to any person obtaining a
0005  * copy of this software and associated documentation files (the "Software"),
0006  * to deal in the Software without restriction, including without limitation
0007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0008  * and/or sell copies of the Software, and to permit persons to whom the
0009  * Software is furnished to do so, subject to the following conditions:
0010  *
0011  * The above copyright notice and this permission notice shall be included in
0012  * all copies or substantial portions of the Software.
0013  *
0014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0017  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
0018  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0020  * OTHER DEALINGS IN THE SOFTWARE.
0021  */
0022 #include "wimm.h"
0023 #include "atom.h"
0024 #include "wndw.h"
0025 
0026 #include <nvif/if0014.h>
0027 #include <nvif/pushc37b.h>
0028 
0029 #include <nvhw/class/clc37b.h>
0030 
0031 static int
0032 wimmc37b_update(struct nv50_wndw *wndw, u32 *interlock)
0033 {
0034     struct nvif_push *push = wndw->wimm.push;
0035     int ret;
0036 
0037     if ((ret = PUSH_WAIT(push, 2)))
0038         return ret;
0039 
0040     PUSH_MTHD(push, NVC37B, UPDATE, 0x00000001 |
0041           NVVAL(NVC37B, UPDATE, INTERLOCK_WITH_WINDOW,
0042             !!(interlock[NV50_DISP_INTERLOCK_WNDW] & wndw->interlock.data)));
0043     return PUSH_KICK(push);
0044 }
0045 
0046 static int
0047 wimmc37b_point(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
0048 {
0049     struct nvif_push *push = wndw->wimm.push;
0050     int ret;
0051 
0052     if ((ret = PUSH_WAIT(push, 2)))
0053         return ret;
0054 
0055     PUSH_MTHD(push, NVC37B, SET_POINT_OUT(0),
0056           NVVAL(NVC37B, SET_POINT_OUT, X, asyw->point.x) |
0057           NVVAL(NVC37B, SET_POINT_OUT, Y, asyw->point.y));
0058     return 0;
0059 }
0060 
0061 static const struct nv50_wimm_func
0062 wimmc37b = {
0063     .point = wimmc37b_point,
0064     .update = wimmc37b_update,
0065 };
0066 
0067 static int
0068 wimmc37b_init_(const struct nv50_wimm_func *func, struct nouveau_drm *drm,
0069            s32 oclass, struct nv50_wndw *wndw)
0070 {
0071     struct nvif_disp_chan_v0 args = {
0072         .id = wndw->id,
0073     };
0074     struct nv50_disp *disp = nv50_disp(drm->dev);
0075     int ret;
0076 
0077     ret = nv50_dmac_create(&drm->client.device, &disp->disp->object,
0078                    &oclass, 0, &args, sizeof(args), -1,
0079                    &wndw->wimm);
0080     if (ret) {
0081         NV_ERROR(drm, "wimm%04x allocation failed: %d\n", oclass, ret);
0082         return ret;
0083     }
0084 
0085     wndw->interlock.wimm = wndw->interlock.data;
0086     wndw->immd = func;
0087     return 0;
0088 }
0089 
0090 int
0091 wimmc37b_init(struct nouveau_drm *drm, s32 oclass, struct nv50_wndw *wndw)
0092 {
0093     return wimmc37b_init_(&wimmc37b, drm, oclass, wndw);
0094 }