drm/amd/display: Add HW rotation cursor changes to dcn10
[linux-2.6-microblaze.git] / drivers / gpu / drm / amd / display / dc / dce / dce_panel.c
1 /*
2  * Copyright 2012-15 Advanced Micro Devices, 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: AMD
23  *
24  */
25
26 #include "reg_helper.h"
27 #include "core_types.h"
28 #include "dc_dmub_srv.h"
29 #include "panel.h"
30 #include "dce_panel.h"
31
32 #define TO_DCE_PANEL(panel)\
33         container_of(panel, struct dce_panel, base)
34
35 #define CTX \
36         dce_panel->base.ctx
37
38 #define DC_LOGGER \
39         dce_panel->base.ctx->logger
40
41 #define REG(reg)\
42         dce_panel->regs->reg
43
44 #undef FN
45 #define FN(reg_name, field_name) \
46         dce_panel->shift->field_name, dce_panel->mask->field_name
47
48 void dce_panel_hw_init(struct panel *panel)
49 {
50
51 }
52
53 bool dce_is_panel_backlight_on(struct panel *panel)
54 {
55         struct dce_panel *dce_panel = TO_DCE_PANEL(panel);
56         uint32_t value;
57
58         REG_GET(PWRSEQ_CNTL, BLON, &value);
59
60         return value;
61 }
62
63 bool dce_is_panel_powered_on(struct panel *panel)
64 {
65         struct dce_panel *dce_panel = TO_DCE_PANEL(panel);
66         uint32_t pwr_seq_state, dig_on, dig_on_ovrd;
67
68         REG_GET(PWRSEQ_STATE, PWRSEQ_TARGET_STATE_R, &pwr_seq_state);
69
70         REG_GET_2(PWRSEQ_CNTL, DIGON, &dig_on, DIGON_OVRD, &dig_on_ovrd);
71
72         return (pwr_seq_state == 1) || (dig_on == 1 && dig_on_ovrd == 1);
73 }
74
75 static void dce_panel_destroy(struct panel **panel)
76 {
77         struct dce_panel *dce_panel = TO_DCE_PANEL(*panel);
78
79         kfree(dce_panel);
80         *panel = NULL;
81 }
82
83 static const struct panel_funcs dce_link_panel_funcs = {
84         .destroy = dce_panel_destroy,
85         .hw_init = dce_panel_hw_init,
86         .is_panel_backlight_on = dce_is_panel_backlight_on,
87         .is_panel_powered_on = dce_is_panel_powered_on,
88
89 };
90
91 void dce_panel_construct(
92         struct dce_panel *dce_panel,
93         const struct panel_init_data *init_data,
94         const struct dce_panel_registers *regs,
95         const struct dce_panel_shift *shift,
96         const struct dce_panel_mask *mask)
97 {
98         dce_panel->regs = regs;
99         dce_panel->shift = shift;
100         dce_panel->mask = mask;
101
102         dce_panel->base.funcs = &dce_link_panel_funcs;
103         dce_panel->base.ctx = init_data->ctx;
104         dce_panel->base.inst = init_data->inst;
105 }