Rev 3386 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3386 | Rev 4153 | ||
---|---|---|---|
Line 35... | Line 35... | ||
35 | #include <arch/drivers/scr.h> |
35 | #include <arch/drivers/scr.h> |
36 | #include <genarch/ofw/ofw_tree.h> |
36 | #include <genarch/ofw/ofw_tree.h> |
37 | #include <genarch/fb/fb.h> |
37 | #include <genarch/fb/fb.h> |
38 | #include <genarch/fb/visuals.h> |
38 | #include <genarch/fb/visuals.h> |
39 | #include <arch/types.h> |
39 | #include <arch/types.h> |
40 | #include <func.h> |
40 | #include <string.h> |
41 | #include <align.h> |
41 | #include <align.h> |
42 | #include <print.h> |
42 | #include <print.h> |
43 | 43 | ||
44 | #define FFB_REG_24BPP 7 |
44 | #define FFB_REG_24BPP 7 |
45 | 45 | ||
Line 53... | Line 53... | ||
53 | * @param node Screen device node. |
53 | * @param node Screen device node. |
54 | */ |
54 | */ |
55 | void scr_init(ofw_tree_node_t *node) |
55 | void scr_init(ofw_tree_node_t *node) |
56 | { |
56 | { |
57 | ofw_tree_property_t *prop; |
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; |
|
58 | const char *name; |
62 | const char *name; |
59 | 63 | ||
60 | name = ofw_tree_node_name(node); |
64 | name = ofw_tree_node_name(node); |
61 | 65 | ||
62 | if (strcmp(name, "SUNW,m64B") == 0) |
66 | if (strcmp(name, "SUNW,m64B") == 0) |
63 | scr_type = SCR_ATYFB; |
67 | scr_type = SCR_ATYFB; |
- | 68 | else if (strcmp(name, "SUNW,XVR-100") == 0) |
|
- | 69 | scr_type = SCR_XVR; |
|
64 | else if (strcmp(name, "SUNW,ffb") == 0) |
70 | else if (strcmp(name, "SUNW,ffb") == 0) |
65 | scr_type = SCR_FFB; |
71 | scr_type = SCR_FFB; |
66 | else if (strcmp(name, "cgsix") == 0) |
72 | else if (strcmp(name, "cgsix") == 0) |
67 | scr_type = SCR_CGSIX; |
73 | scr_type = SCR_CGSIX; |
68 | 74 | ||
69 | if (scr_type == SCR_UNKNOWN) { |
75 | if (scr_type == SCR_UNKNOWN) { |
70 | printf("Unknown keyboard device.\n"); |
76 | printf("Unknown screen device.\n"); |
71 | return; |
77 | return; |
72 | } |
78 | } |
73 | 79 | ||
74 | uintptr_t fb_addr; |
80 | uintptr_t fb_addr; |
- | 81 | unsigned int fb_offset = 0; |
|
75 | uint32_t fb_width = 0; |
82 | uint32_t fb_width = 0; |
76 | uint32_t fb_height = 0; |
83 | uint32_t fb_height = 0; |
77 | uint32_t fb_depth = 0; |
84 | uint32_t fb_depth = 0; |
78 | uint32_t fb_linebytes = 0; |
85 | uint32_t fb_linebytes = 0; |
79 | uint32_t fb_scanline = 0; |
86 | uint32_t fb_scanline = 0; |
Line 95... | Line 102... | ||
95 | if (prop && prop->value) |
102 | if (prop && prop->value) |
96 | fb_linebytes = *((uint32_t *) prop->value); |
103 | fb_linebytes = *((uint32_t *) prop->value); |
97 | 104 | ||
98 | prop = ofw_tree_getprop(node, "reg"); |
105 | prop = ofw_tree_getprop(node, "reg"); |
99 | if (!prop) |
106 | if (!prop) |
100 | panic("Can't find \"reg\" property.\n"); |
107 | panic("Cannot find 'reg' property."); |
101 | 108 | ||
102 | switch (scr_type) { |
109 | switch (scr_type) { |
103 | case SCR_ATYFB: |
110 | case SCR_ATYFB: |
104 | if (prop->size / sizeof(ofw_pci_reg_t) < 2) { |
111 | if (prop->size / sizeof(ofw_pci_reg_t) < 2) { |
105 | printf("Too few screen registers.\n"); |
112 | printf("Too few screen registers.\n"); |
106 | return; |
113 | return; |
107 | } |
114 | } |
108 | 115 | ||
109 | ofw_pci_reg_t *fb_reg = &((ofw_pci_reg_t *) prop->value)[1]; |
116 | pci_reg = &((ofw_pci_reg_t *) prop->value)[1]; |
110 | ofw_pci_reg_t abs_reg; |
- | |
111 | 117 | ||
112 | if (!ofw_pci_reg_absolutize(node, fb_reg, &abs_reg)) { |
118 | if (!ofw_pci_reg_absolutize(node, pci_reg, &pci_abs_reg)) { |
113 | printf("Failed to absolutize fb register.\n"); |
119 | printf("Failed to absolutize fb register.\n"); |
114 | return; |
120 | return; |
115 | } |
121 | } |
116 | 122 | ||
117 | if (!ofw_pci_apply_ranges(node->parent, &abs_reg , &fb_addr)) { |
123 | if (!ofw_pci_apply_ranges(node->parent, &pci_abs_reg, |
- | 124 | &fb_addr)) { |
|
118 | printf("Failed to determine screen address.\n"); |
125 | printf("Failed to determine screen address.\n"); |
119 | return; |
126 | return; |
120 | } |
127 | } |
121 | 128 | ||
122 | switch (fb_depth) { |
129 | switch (fb_depth) { |
Line 140... | Line 147... | ||
140 | printf("Unsupported bits per pixel.\n"); |
147 | printf("Unsupported bits per pixel.\n"); |
141 | return; |
148 | return; |
142 | } |
149 | } |
143 | 150 | ||
144 | break; |
151 | break; |
- | 152 | case SCR_XVR: |
|
- | 153 | if (prop->size / sizeof(ofw_pci_reg_t) < 2) { |
|
- | 154 | printf("Too few screen registers.\n"); |
|
- | 155 | return; |
|
- | 156 | } |
|
- | 157 | ||
- | 158 | pci_reg = &((ofw_pci_reg_t *) prop->value)[1]; |
|
- | 159 | ||
- | 160 | if (!ofw_pci_reg_absolutize(node, pci_reg, &pci_abs_reg)) { |
|
- | 161 | printf("Failed to absolutize fb register.\n"); |
|
- | 162 | return; |
|
- | 163 | } |
|
- | 164 | ||
- | 165 | if (!ofw_pci_apply_ranges(node->parent, &pci_abs_reg, |
|
- | 166 | &fb_addr)) { |
|
- | 167 | printf("Failed to determine screen address.\n"); |
|
- | 168 | return; |
|
- | 169 | } |
|
- | 170 | ||
- | 171 | fb_offset = 4 * 0x2000; |
|
- | 172 | ||
- | 173 | switch (fb_depth) { |
|
- | 174 | case 8: |
|
- | 175 | fb_scanline = fb_linebytes * (fb_depth >> 3); |
|
- | 176 | visual = VISUAL_INDIRECT_8; |
|
- | 177 | break; |
|
- | 178 | case 16: |
|
- | 179 | fb_scanline = fb_linebytes * (fb_depth >> 3); |
|
- | 180 | visual = VISUAL_RGB_5_6_5; |
|
- | 181 | break; |
|
- | 182 | case 24: |
|
- | 183 | fb_scanline = fb_linebytes * 4; |
|
- | 184 | visual = VISUAL_RGB_8_8_8_0; |
|
- | 185 | break; |
|
- | 186 | case 32: |
|
- | 187 | fb_scanline = fb_linebytes * (fb_depth >> 3); |
|
- | 188 | visual = VISUAL_RGB_0_8_8_8; |
|
- | 189 | break; |
|
- | 190 | default: |
|
- | 191 | printf("Unsupported bits per pixel.\n"); |
|
- | 192 | return; |
|
- | 193 | } |
|
- | 194 | ||
- | 195 | break; |
|
145 | case SCR_FFB: |
196 | case SCR_FFB: |
146 | fb_scanline = 8192; |
197 | fb_scanline = 8192; |
147 | visual = VISUAL_BGR_0_8_8_8; |
198 | visual = VISUAL_BGR_0_8_8_8; |
148 | 199 | ||
149 | ofw_upa_reg_t *reg = &((ofw_upa_reg_t *) prop->value)[FFB_REG_24BPP]; |
200 | upa_reg = &((ofw_upa_reg_t *) prop->value)[FFB_REG_24BPP]; |
150 | if (!ofw_upa_apply_ranges(node->parent, reg, &fb_addr)) { |
201 | if (!ofw_upa_apply_ranges(node->parent, upa_reg, &fb_addr)) { |
151 | printf("Failed to determine screen address.\n"); |
202 | printf("Failed to determine screen address.\n"); |
152 | return; |
203 | return; |
153 | } |
204 | } |
154 | 205 | ||
155 | break; |
206 | break; |
Line 162... | Line 213... | ||
162 | default: |
213 | default: |
163 | printf("Not implemented.\n"); |
214 | printf("Not implemented.\n"); |
164 | return; |
215 | return; |
165 | } |
216 | } |
166 | 217 | ||
167 | ofw_sbus_reg_t *cg6_reg = &((ofw_sbus_reg_t *) prop->value)[0]; |
218 | sbus_reg = &((ofw_sbus_reg_t *) prop->value)[0]; |
168 | if (!ofw_sbus_apply_ranges(node->parent, cg6_reg, &fb_addr)) { |
219 | if (!ofw_sbus_apply_ranges(node->parent, sbus_reg, &fb_addr)) { |
169 | printf("Failed to determine screen address.\n"); |
220 | printf("Failed to determine screen address.\n"); |
170 | return; |
221 | return; |
171 | } |
222 | } |
172 | 223 | ||
173 | break; |
224 | break; |
174 | default: |
225 | default: |
175 | panic("Unexpected type.\n"); |
226 | panic("Unexpected type."); |
176 | } |
227 | } |
177 | 228 | ||
- | 229 | fb_properties_t props = { |
|
- | 230 | .addr = fb_addr, |
|
- | 231 | .offset = fb_offset, |
|
- | 232 | .x = fb_width, |
|
- | 233 | .y = fb_height, |
|
178 | fb_init(fb_addr, fb_width, fb_height, fb_scanline, visual); |
234 | .scan = fb_scanline, |
- | 235 | .visual = visual, |
|
- | 236 | }; |
|
- | 237 | fb_init(&props); |
|
- | 238 | } |
|
- | 239 | ||
- | 240 | void scr_redraw(void) |
|
- | 241 | { |
|
- | 242 | fb_redraw(); |
|
179 | } |
243 | } |
180 | 244 | ||
181 | /** @} |
245 | /** @} |
182 | */ |
246 | */ |