2 * Copyright 2012-15 Advanced Micro Devices, Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
26 #include "reg_helper.h"
27 #include "core_types.h"
28 #include "dc_dmub_srv.h"
30 #include "dce_panel.h"
32 #define TO_DCE_PANEL(panel)\
33 container_of(panel, struct dce_panel, base)
39 dce_panel->base.ctx->logger
45 #define FN(reg_name, field_name) \
46 dce_panel->shift->field_name, dce_panel->mask->field_name
48 void dce_panel_hw_init(struct panel *panel)
53 bool dce_is_panel_backlight_on(struct panel *panel)
55 struct dce_panel *dce_panel = TO_DCE_PANEL(panel);
58 REG_GET(PWRSEQ_CNTL, BLON, &value);
63 bool dce_is_panel_powered_on(struct panel *panel)
65 struct dce_panel *dce_panel = TO_DCE_PANEL(panel);
66 uint32_t pwr_seq_state, dig_on, dig_on_ovrd;
68 REG_GET(PWRSEQ_STATE, PWRSEQ_TARGET_STATE_R, &pwr_seq_state);
70 REG_GET_2(PWRSEQ_CNTL, DIGON, &dig_on, DIGON_OVRD, &dig_on_ovrd);
72 return (pwr_seq_state == 1) || (dig_on == 1 && dig_on_ovrd == 1);
75 static void dce_panel_destroy(struct panel **panel)
77 struct dce_panel *dce_panel = TO_DCE_PANEL(*panel);
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,
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)
98 dce_panel->regs = regs;
99 dce_panel->shift = shift;
100 dce_panel->mask = mask;
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;