Skip to content

Commit dc06efb

Browse files
committed
drm/mgag200: vga-bmc: Transparently handle BMC
The VGA-BMC connector selects the VGA output if a display has been attached to the physical connector. Otherwise it selects the BMC output. In any case, the connector status is set to 'detected', so that the userspace compositor displays to it. Depending on the setting, the connector's display modes either come from the VGA monitor's EDID or from an internal list of BMC-compatible modes. Signed-off-by: Thomas Zimmermann <[email protected]> Reviewed-by: Jocelyn Falempe <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent f551072 commit dc06efb

File tree

1 file changed

+48
-2
lines changed

1 file changed

+48
-2
lines changed

drivers/gpu/drm/mgag200/mgag200_vga_bmc.c

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0-only
22

33
#include <drm/drm_atomic_helper.h>
4+
#include <drm/drm_edid.h>
45
#include <drm/drm_modeset_helper_vtables.h>
56
#include <drm/drm_probe_helper.h>
67

@@ -11,9 +12,54 @@ static const struct drm_encoder_funcs mgag200_dac_encoder_funcs = {
1112
.destroy = drm_encoder_cleanup
1213
};
1314

15+
static int mgag200_vga_bmc_connector_helper_get_modes(struct drm_connector *connector)
16+
{
17+
struct mga_device *mdev = to_mga_device(connector->dev);
18+
const struct mgag200_device_info *minfo = mdev->info;
19+
int count;
20+
21+
count = drm_connector_helper_get_modes(connector);
22+
23+
if (!count) {
24+
/*
25+
* There's no EDID data without a connected monitor. Set BMC-
26+
* compatible modes in this case. The XGA default resolution
27+
* should work well for all BMCs.
28+
*/
29+
count = drm_add_modes_noedid(connector, minfo->max_hdisplay, minfo->max_vdisplay);
30+
if (count)
31+
drm_set_preferred_mode(connector, 1024, 768);
32+
}
33+
34+
return count;
35+
}
36+
37+
/*
38+
* There's no monitor connected if the DDC did not return an EDID. Still
39+
* return 'connected' as there's always a BMC. Incrementing the connector's
40+
* epoch counter triggers an update of the related properties.
41+
*/
42+
static int mgag200_vga_bmc_connector_helper_detect_ctx(struct drm_connector *connector,
43+
struct drm_modeset_acquire_ctx *ctx,
44+
bool force)
45+
{
46+
enum drm_connector_status old_status, status;
47+
48+
if (connector->edid_blob_ptr)
49+
old_status = connector_status_connected;
50+
else
51+
old_status = connector_status_disconnected;
52+
53+
status = drm_connector_helper_detect_from_ddc(connector, ctx, force);
54+
55+
if (status != old_status)
56+
++connector->epoch_counter;
57+
return connector_status_connected;
58+
}
59+
1460
static const struct drm_connector_helper_funcs mgag200_vga_connector_helper_funcs = {
15-
.get_modes = drm_connector_helper_get_modes,
16-
.detect_ctx = drm_connector_helper_detect_from_ddc
61+
.get_modes = mgag200_vga_bmc_connector_helper_get_modes,
62+
.detect_ctx = mgag200_vga_bmc_connector_helper_detect_ctx,
1763
};
1864

1965
static const struct drm_connector_funcs mgag200_vga_connector_funcs = {

0 commit comments

Comments
 (0)