2
* Copyright (c) 2006 Jakub Jermar
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
9
* - Redistributions of source code must retain the above copyright
10
* notice, this list of conditions and the following disclaimer.
11
* - Redistributions in binary form must reproduce the above copyright
12
* notice, this list of conditions and the following disclaimer in the
13
* documentation and/or other materials provided with the distribution.
14
* - The name of the author may not be used to endorse or promote products
15
* derived from this software without specific prior written permission.
17
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
/** @addtogroup sparc64
35
#include <arch/drivers/scr.h>
36
#include <genarch/ofw/ofw_tree.h>
37
#include <genarch/fb/fb.h>
38
#include <genarch/fb/visuals.h>
39
#include <arch/types.h>
44
#define FFB_REG_24BPP 7
46
scr_type_t scr_type = SCR_UNKNOWN;
48
/** Initialize screen.
50
* Traverse OpenFirmware device tree in order to find necessary
51
* info about the screen device.
53
* @param node Screen device node.
55
void scr_init(ofw_tree_node_t *node)
57
ofw_tree_property_t *prop;
58
ofw_pci_reg_t *pci_reg;
59
ofw_pci_reg_t pci_abs_reg;
60
ofw_upa_reg_t *upa_reg;
61
ofw_sbus_reg_t *sbus_reg;
64
name = ofw_tree_node_name(node);
66
if (str_cmp(name, "SUNW,m64B") == 0)
68
else if (str_cmp(name, "SUNW,XVR-100") == 0)
70
else if (str_cmp(name, "SUNW,ffb") == 0)
72
else if (str_cmp(name, "cgsix") == 0)
75
if (scr_type == SCR_UNKNOWN) {
76
printf("Unknown screen device.\n");
81
unsigned int fb_offset = 0;
82
uint32_t fb_width = 0;
83
uint32_t fb_height = 0;
84
uint32_t fb_depth = 0;
85
uint32_t fb_linebytes = 0;
86
uint32_t fb_scanline = 0;
89
prop = ofw_tree_getprop(node, "width");
90
if (prop && prop->value)
91
fb_width = *((uint32_t *) prop->value);
93
prop = ofw_tree_getprop(node, "height");
94
if (prop && prop->value)
95
fb_height = *((uint32_t *) prop->value);
97
prop = ofw_tree_getprop(node, "depth");
98
if (prop && prop->value)
99
fb_depth = *((uint32_t *) prop->value);
101
prop = ofw_tree_getprop(node, "linebytes");
102
if (prop && prop->value)
103
fb_linebytes = *((uint32_t *) prop->value);
105
prop = ofw_tree_getprop(node, "reg");
107
panic("Cannot find 'reg' property.");
111
if (prop->size / sizeof(ofw_pci_reg_t) < 2) {
112
printf("Too few screen registers.\n");
116
pci_reg = &((ofw_pci_reg_t *) prop->value)[1];
118
if (!ofw_pci_reg_absolutize(node, pci_reg, &pci_abs_reg)) {
119
printf("Failed to absolutize fb register.\n");
123
if (!ofw_pci_apply_ranges(node->parent, &pci_abs_reg,
125
printf("Failed to determine screen address.\n");
131
fb_scanline = fb_linebytes * (fb_depth >> 3);
132
visual = VISUAL_INDIRECT_8;
135
fb_scanline = fb_linebytes * (fb_depth >> 3);
136
visual = VISUAL_RGB_5_6_5_BE;
139
fb_scanline = fb_linebytes * 4;
140
visual = VISUAL_BGR_8_8_8_0;
143
fb_scanline = fb_linebytes * (fb_depth >> 3);
144
visual = VISUAL_RGB_0_8_8_8;
147
printf("Unsupported bits per pixel.\n");
153
if (prop->size / sizeof(ofw_pci_reg_t) < 2) {
154
printf("Too few screen registers.\n");
158
pci_reg = &((ofw_pci_reg_t *) prop->value)[1];
160
if (!ofw_pci_reg_absolutize(node, pci_reg, &pci_abs_reg)) {
161
printf("Failed to absolutize fb register.\n");
165
if (!ofw_pci_apply_ranges(node->parent, &pci_abs_reg,
167
printf("Failed to determine screen address.\n");
171
fb_offset = 4 * 0x2000;
175
fb_scanline = fb_linebytes * (fb_depth >> 3);
176
visual = VISUAL_INDIRECT_8;
179
fb_scanline = fb_linebytes * (fb_depth >> 3);
180
visual = VISUAL_RGB_5_6_5_BE;
183
fb_scanline = fb_linebytes * 4;
184
visual = VISUAL_BGR_8_8_8_0;
187
fb_scanline = fb_linebytes * (fb_depth >> 3);
188
visual = VISUAL_RGB_0_8_8_8;
191
printf("Unsupported bits per pixel.\n");
198
visual = VISUAL_BGR_0_8_8_8;
200
upa_reg = &((ofw_upa_reg_t *) prop->value)[FFB_REG_24BPP];
201
if (!ofw_upa_apply_ranges(node->parent, upa_reg, &fb_addr)) {
202
printf("Failed to determine screen address.\n");
210
fb_scanline = fb_linebytes;
211
visual = VISUAL_INDIRECT_8;
214
printf("Not implemented.\n");
218
sbus_reg = &((ofw_sbus_reg_t *) prop->value)[0];
219
if (!ofw_sbus_apply_ranges(node->parent, sbus_reg, &fb_addr)) {
220
printf("Failed to determine screen address.\n");
226
panic("Unexpected type.");
229
fb_properties_t props = {
240
void scr_redraw(void)