Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright 2021 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 "wndw.h"
0023 #include "atom.h"
0024 
0025 #include <nvif/pushc37b.h>
0026 
0027 #include <nvhw/class/clc57e.h>
0028 
0029 static int
0030 wndwc67e_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
0031 {
0032     struct nvif_push *push = wndw->wndw.push;
0033     int ret;
0034 
0035     if ((ret = PUSH_WAIT(push, 17)))
0036         return ret;
0037 
0038     PUSH_MTHD(push, NVC57E, SET_PRESENT_CONTROL,
0039           NVVAL(NVC57E, SET_PRESENT_CONTROL, MIN_PRESENT_INTERVAL, asyw->image.interval) |
0040           NVVAL(NVC57E, SET_PRESENT_CONTROL, BEGIN_MODE, asyw->image.mode) |
0041           NVDEF(NVC57E, SET_PRESENT_CONTROL, TIMESTAMP_MODE, DISABLE));
0042 
0043     PUSH_MTHD(push, NVC57E, SET_SIZE,
0044           NVVAL(NVC57E, SET_SIZE, WIDTH, asyw->image.w) |
0045           NVVAL(NVC57E, SET_SIZE, HEIGHT, asyw->image.h),
0046 
0047                 SET_STORAGE,
0048           NVVAL(NVC57E, SET_STORAGE, BLOCK_HEIGHT, asyw->image.blockh),
0049 
0050                 SET_PARAMS,
0051           NVVAL(NVC57E, SET_PARAMS, FORMAT, asyw->image.format) |
0052           NVDEF(NVC57E, SET_PARAMS, CLAMP_BEFORE_BLEND, DISABLE) |
0053           NVDEF(NVC57E, SET_PARAMS, SWAP_UV, DISABLE) |
0054           NVDEF(NVC57E, SET_PARAMS, FMT_ROUNDING_MODE, ROUND_TO_NEAREST),
0055 
0056                 SET_PLANAR_STORAGE(0),
0057           NVVAL(NVC57E, SET_PLANAR_STORAGE, PITCH, asyw->image.blocks[0]) |
0058           NVVAL(NVC57E, SET_PLANAR_STORAGE, PITCH, asyw->image.pitch[0] >> 6));
0059 
0060     PUSH_MTHD(push, NVC57E, SET_CONTEXT_DMA_ISO(0), asyw->image.handle, 1);
0061     PUSH_MTHD(push, NVC57E, SET_OFFSET(0), asyw->image.offset[0] >> 8);
0062 
0063     PUSH_MTHD(push, NVC57E, SET_POINT_IN(0),
0064           NVVAL(NVC57E, SET_POINT_IN, X, asyw->state.src_x >> 16) |
0065           NVVAL(NVC57E, SET_POINT_IN, Y, asyw->state.src_y >> 16));
0066 
0067     PUSH_MTHD(push, NVC57E, SET_SIZE_IN,
0068           NVVAL(NVC57E, SET_SIZE_IN, WIDTH, asyw->state.src_w >> 16) |
0069           NVVAL(NVC57E, SET_SIZE_IN, HEIGHT, asyw->state.src_h >> 16));
0070 
0071     PUSH_MTHD(push, NVC57E, SET_SIZE_OUT,
0072           NVVAL(NVC57E, SET_SIZE_OUT, WIDTH, asyw->state.crtc_w) |
0073           NVVAL(NVC57E, SET_SIZE_OUT, HEIGHT, asyw->state.crtc_h));
0074     return 0;
0075 }
0076 
0077 static const struct nv50_wndw_func
0078 wndwc67e = {
0079     .acquire = wndwc37e_acquire,
0080     .release = wndwc37e_release,
0081     .sema_set = wndwc37e_sema_set,
0082     .sema_clr = wndwc37e_sema_clr,
0083     .ntfy_set = wndwc37e_ntfy_set,
0084     .ntfy_clr = wndwc37e_ntfy_clr,
0085     .ntfy_reset = corec37d_ntfy_init,
0086     .ntfy_wait_begun = base507c_ntfy_wait_begun,
0087     .ilut = wndwc57e_ilut,
0088     .ilut_identity = true,
0089     .ilut_size = 1024,
0090     .xlut_set = wndwc57e_ilut_set,
0091     .xlut_clr = wndwc57e_ilut_clr,
0092     .csc = base907c_csc,
0093     .csc_set = wndwc57e_csc_set,
0094     .csc_clr = wndwc57e_csc_clr,
0095     .image_set = wndwc67e_image_set,
0096     .image_clr = wndwc37e_image_clr,
0097     .blend_set = wndwc37e_blend_set,
0098     .update = wndwc37e_update,
0099 };
0100 
0101 int
0102 wndwc67e_new(struct nouveau_drm *drm, enum drm_plane_type type, int index,
0103          s32 oclass, struct nv50_wndw **pwndw)
0104 {
0105     return wndwc37e_new_(&wndwc67e, drm, type, index, oclass, BIT(index >> 1), pwndw);
0106 }