3 Rudolf Cornelissen 7/2004-08/2009
6 #define MODULE_BIT 0x04000000
10 /* Get some info about the device */
11 status_t
GET_ACCELERANT_DEVICE_INFO(accelerant_device_info
* adi
)
13 LOG(4,("GET_ACCELERANT_DEVICE_INFO: returning info\n"));
15 /* no info on version is provided, so presumably this is for my info */
18 sprintf(adi
->name
, si
->adi
.name
);
19 sprintf(adi
->chipset
, si
->adi
.chipset
);
20 sprintf(adi
->serial_no
, "unknown");
21 adi
->memory
= si
->ps
.memory_size
;
22 adi
->dac_speed
= si
->ps
.max_dac1_clock
;
29 /* Get the info fetched from the attached screen */
30 status_t
GET_EDID_INFO(void* info
, size_t size
, uint32
* _version
)
32 if (!si
->ps
.crtc1_screen
.have_full_edid
&& !si
->ps
.crtc2_screen
.have_full_edid
) {
33 LOG(4,("GET_EDID_INFO: EDID info not available\n"));
36 if (size
< sizeof(struct edid1_info
)) {
37 LOG(4,("GET_EDID_INFO: not enough memory available\n"));
38 return B_BUFFER_OVERFLOW
;
41 LOG(4,("GET_EDID_INFO: returning info\n"));
43 /* if we have two screens, make the best of it (go for the best compatible info) */
44 if (si
->ps
.crtc1_screen
.have_full_edid
&& si
->ps
.crtc2_screen
.have_full_edid
) {
45 /* return info on screen with lowest aspect (4:3 takes precedence over ws)
47 * allow 0.10 difference so 4:3 and 5:4 aspect screens are regarded as being the same. */
48 if (si
->ps
.crtc1_screen
.aspect
< (si
->ps
.crtc2_screen
.aspect
- 0.10)) {
49 memcpy(info
, &si
->ps
.crtc1_screen
.full_edid
, sizeof(struct edid1_info
));
51 if (si
->ps
.crtc1_screen
.aspect
> (si
->ps
.crtc2_screen
.aspect
+ 0.10)) {
52 memcpy(info
, &si
->ps
.crtc2_screen
.full_edid
, sizeof(struct edid1_info
));
54 /* both screens have the same aspect, return info on the one with
55 * the lowest native resolution */
56 if (si
->ps
.crtc1_screen
.timing
.h_display
< si
->ps
.crtc2_screen
.timing
.h_display
)
57 memcpy(info
, &si
->ps
.crtc1_screen
.full_edid
, sizeof(struct edid1_info
));
58 if (si
->ps
.crtc1_screen
.timing
.h_display
> si
->ps
.crtc2_screen
.timing
.h_display
)
59 memcpy(info
, &si
->ps
.crtc2_screen
.full_edid
, sizeof(struct edid1_info
));
61 /* if both screens have the same resolution and aspect, return info on the
62 * one used as main screen */
63 if (si
->ps
.crtc1_screen
.timing
.h_display
== si
->ps
.crtc2_screen
.timing
.h_display
) {
64 if (si
->ps
.crtc2_prim
)
65 memcpy(info
, &si
->ps
.crtc2_screen
.full_edid
, sizeof(struct edid1_info
));
67 memcpy(info
, &si
->ps
.crtc1_screen
.full_edid
, sizeof(struct edid1_info
));
72 /* there's just one screen of which we have EDID information, return it */
73 if (si
->ps
.crtc1_screen
.have_full_edid
)
74 memcpy(info
, &si
->ps
.crtc1_screen
.full_edid
, sizeof(struct edid1_info
));
76 memcpy(info
, &si
->ps
.crtc2_screen
.full_edid
, sizeof(struct edid1_info
));
79 *_version
= EDID_VERSION_1
;
83 /* Return the optimum (native) mode for the attached screen */
84 status_t
GET_PREFERRED_DISPLAY_MODE(display_mode
* preferredMode
)
86 if (si
->ps
.crtc1_screen
.have_full_edid
|| si
->ps
.crtc2_screen
.have_full_edid
) {
87 LOG(4,("GET_PREFERRED_DISPLAY_MODE: full EDID known, aborting (fetch EDID instead).\n"));
91 if (!si
->ps
.crtc1_screen
.have_native_edid
&& !si
->ps
.crtc2_screen
.have_native_edid
) {
92 LOG(4,("GET_PREFERRED_DISPLAY_MODE: native mode(s) not known\n"));
96 /* if we got here then we're probably on a laptop, but DDC/EDID may have failed
97 * for another reason as well. */
98 LOG(4,("GET_PREFERRED_DISPLAY_MODE: returning mode\n"));
100 /* if we have two screens, make the best of it (go for the best compatible mode) */
101 if (si
->ps
.crtc1_screen
.have_native_edid
&& si
->ps
.crtc2_screen
.have_native_edid
) {
102 /* return mode of screen with lowest aspect (4:3 takes precedence over ws)
104 * allow 0.10 difference so 4:3 and 5:4 aspect screens are regarded as being the same. */
105 if (si
->ps
.crtc1_screen
.aspect
< (si
->ps
.crtc2_screen
.aspect
- 0.10)) {
106 get_crtc1_screen_native_mode(preferredMode
);
108 if (si
->ps
.crtc1_screen
.aspect
> (si
->ps
.crtc2_screen
.aspect
+ 0.10)) {
109 get_crtc2_screen_native_mode(preferredMode
);
111 /* both screens have the same aspect, return mode of the one with
112 * the lowest native resolution */
113 if (si
->ps
.crtc1_screen
.timing
.h_display
< si
->ps
.crtc2_screen
.timing
.h_display
)
114 get_crtc1_screen_native_mode(preferredMode
);
115 if (si
->ps
.crtc1_screen
.timing
.h_display
> si
->ps
.crtc2_screen
.timing
.h_display
)
116 get_crtc2_screen_native_mode(preferredMode
);
118 /* if both screens have the same resolution and aspect, return mode of the
119 * one used as main screen */
120 if (si
->ps
.crtc1_screen
.timing
.h_display
== si
->ps
.crtc2_screen
.timing
.h_display
) {
121 if (si
->ps
.crtc2_prim
)
122 get_crtc2_screen_native_mode(preferredMode
);
124 get_crtc1_screen_native_mode(preferredMode
);
129 /* there's just one screen of which we have native mode information, return it's mode */
130 if (si
->ps
.crtc1_screen
.have_native_edid
)
131 get_crtc1_screen_native_mode(preferredMode
);
133 get_crtc2_screen_native_mode(preferredMode
);