0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #include "head.h"
0023 #include "core.h"
0024
0025 #include "nvif/push.h"
0026 #include <nvif/push507c.h>
0027
0028 #include <nvhw/class/cl917d.h>
0029
0030 static int
0031 head917d_dither(struct nv50_head *head, struct nv50_head_atom *asyh)
0032 {
0033 struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
0034 const int i = head->base.index;
0035 int ret;
0036
0037 if ((ret = PUSH_WAIT(push, 2)))
0038 return ret;
0039
0040 PUSH_MTHD(push, NV917D, HEAD_SET_DITHER_CONTROL(i),
0041 NVVAL(NV917D, HEAD_SET_DITHER_CONTROL, ENABLE, asyh->dither.enable) |
0042 NVVAL(NV917D, HEAD_SET_DITHER_CONTROL, BITS, asyh->dither.bits) |
0043 NVVAL(NV917D, HEAD_SET_DITHER_CONTROL, MODE, asyh->dither.mode) |
0044 NVVAL(NV917D, HEAD_SET_DITHER_CONTROL, PHASE, 0));
0045 return 0;
0046 }
0047
0048 static int
0049 head917d_base(struct nv50_head *head, struct nv50_head_atom *asyh)
0050 {
0051 struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
0052 const int i = head->base.index;
0053 u32 bounds = 0;
0054 int ret;
0055
0056 if (asyh->base.cpp) {
0057 switch (asyh->base.cpp) {
0058 case 8: bounds |= NVDEF(NV917D, HEAD_SET_BASE_CHANNEL_USAGE_BOUNDS, PIXEL_DEPTH, BPP_64); break;
0059 case 4: bounds |= NVDEF(NV917D, HEAD_SET_BASE_CHANNEL_USAGE_BOUNDS, PIXEL_DEPTH, BPP_32); break;
0060 case 2: bounds |= NVDEF(NV917D, HEAD_SET_BASE_CHANNEL_USAGE_BOUNDS, PIXEL_DEPTH, BPP_16); break;
0061 case 1: bounds |= NVDEF(NV917D, HEAD_SET_BASE_CHANNEL_USAGE_BOUNDS, PIXEL_DEPTH, BPP_8); break;
0062 default:
0063 WARN_ON(1);
0064 break;
0065 }
0066 bounds |= NVDEF(NV917D, HEAD_SET_BASE_CHANNEL_USAGE_BOUNDS, USABLE, TRUE);
0067 bounds |= NVDEF(NV917D, HEAD_SET_BASE_CHANNEL_USAGE_BOUNDS, BASE_LUT, USAGE_1025);
0068 }
0069
0070 if ((ret = PUSH_WAIT(push, 2)))
0071 return ret;
0072
0073 PUSH_MTHD(push, NV917D, HEAD_SET_BASE_CHANNEL_USAGE_BOUNDS(i), bounds);
0074 return 0;
0075 }
0076
0077 static int
0078 head917d_curs_set(struct nv50_head *head, struct nv50_head_atom *asyh)
0079 {
0080 struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
0081 const int i = head->base.index;
0082 int ret;
0083
0084 ret = PUSH_WAIT(push, 5);
0085 if (ret)
0086 return ret;
0087
0088 PUSH_MTHD(push, NV917D, HEAD_SET_CONTROL_CURSOR(i),
0089 NVDEF(NV917D, HEAD_SET_CONTROL_CURSOR, ENABLE, ENABLE) |
0090 NVVAL(NV917D, HEAD_SET_CONTROL_CURSOR, FORMAT, asyh->curs.format) |
0091 NVVAL(NV917D, HEAD_SET_CONTROL_CURSOR, SIZE, asyh->curs.layout) |
0092 NVVAL(NV917D, HEAD_SET_CONTROL_CURSOR, HOT_SPOT_X, 0) |
0093 NVVAL(NV917D, HEAD_SET_CONTROL_CURSOR, HOT_SPOT_Y, 0) |
0094 NVDEF(NV917D, HEAD_SET_CONTROL_CURSOR, COMPOSITION, ALPHA_BLEND),
0095
0096 HEAD_SET_OFFSET_CURSOR(i), asyh->curs.offset >> 8);
0097
0098 PUSH_MTHD(push, NV917D, HEAD_SET_CONTEXT_DMA_CURSOR(i), asyh->curs.handle);
0099 return 0;
0100 }
0101
0102 int
0103 head917d_curs_layout(struct nv50_head *head, struct nv50_wndw_atom *asyw,
0104 struct nv50_head_atom *asyh)
0105 {
0106 switch (asyw->state.fb->width) {
0107 case 32: asyh->curs.layout = NV917D_HEAD_SET_CONTROL_CURSOR_SIZE_W32_H32; break;
0108 case 64: asyh->curs.layout = NV917D_HEAD_SET_CONTROL_CURSOR_SIZE_W64_H64; break;
0109 case 128: asyh->curs.layout = NV917D_HEAD_SET_CONTROL_CURSOR_SIZE_W128_H128; break;
0110 case 256: asyh->curs.layout = NV917D_HEAD_SET_CONTROL_CURSOR_SIZE_W256_H256; break;
0111 default:
0112 return -EINVAL;
0113 }
0114 return 0;
0115 }
0116
0117 const struct nv50_head_func
0118 head917d = {
0119 .view = head907d_view,
0120 .mode = head907d_mode,
0121 .olut = head907d_olut,
0122 .ilut_check = head907d_ilut_check,
0123 .olut_size = 1024,
0124 .olut_set = head907d_olut_set,
0125 .olut_clr = head907d_olut_clr,
0126 .core_calc = head507d_core_calc,
0127 .core_set = head907d_core_set,
0128 .core_clr = head907d_core_clr,
0129 .curs_layout = head917d_curs_layout,
0130 .curs_format = head507d_curs_format,
0131 .curs_set = head917d_curs_set,
0132 .curs_clr = head907d_curs_clr,
0133 .base = head917d_base,
0134 .ovly = head907d_ovly,
0135 .dither = head917d_dither,
0136 .procamp = head907d_procamp,
0137 .or = head907d_or,
0138 };