drivers/gpu/drm/mgag200/mgag200_vga_bmc.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/mgag200/mgag200_vga_bmc.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/mgag200/mgag200_vga_bmc.c
Extension
.c
Size
4796 bytes
Lines
158
Domain
Driver Families
Bucket
drivers/gpu
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0-only

#include <drm/drm_atomic_helper.h>
#include <drm/drm_edid.h>
#include <drm/drm_modeset_helper_vtables.h>
#include <drm/drm_print.h>
#include <drm/drm_probe_helper.h>

#include "mgag200_ddc.h"
#include "mgag200_drv.h"

static void mgag200_vga_bmc_encoder_atomic_disable(struct drm_encoder *encoder,
						   struct drm_atomic_commit *state)
{
	struct mga_device *mdev = to_mga_device(encoder->dev);

	if (mdev->info->sync_bmc)
		mgag200_bmc_stop_scanout(mdev);
}

static void mgag200_vga_bmc_encoder_atomic_enable(struct drm_encoder *encoder,
						  struct drm_atomic_commit *state)
{
	struct mga_device *mdev = to_mga_device(encoder->dev);

	if (mdev->info->sync_bmc)
		mgag200_bmc_start_scanout(mdev);
}

static int mgag200_vga_bmc_encoder_atomic_check(struct drm_encoder *encoder,
						struct drm_crtc_state *new_crtc_state,
						struct drm_connector_state *new_connector_state)
{
	struct mga_device *mdev = to_mga_device(encoder->dev);
	struct mgag200_crtc_state *new_mgag200_crtc_state = to_mgag200_crtc_state(new_crtc_state);

	new_mgag200_crtc_state->set_vidrst = mdev->info->sync_bmc;

	return 0;
}

static const struct drm_encoder_helper_funcs mgag200_dac_encoder_helper_funcs = {
	.atomic_disable = mgag200_vga_bmc_encoder_atomic_disable,
	.atomic_enable = mgag200_vga_bmc_encoder_atomic_enable,
	.atomic_check = mgag200_vga_bmc_encoder_atomic_check,
};

static const struct drm_encoder_funcs mgag200_dac_encoder_funcs = {
	.destroy = drm_encoder_cleanup
};

static int mgag200_vga_bmc_connector_helper_get_modes(struct drm_connector *connector)
{
	struct mga_device *mdev = to_mga_device(connector->dev);
	const struct mgag200_device_info *minfo = mdev->info;
	int count;

	count = drm_connector_helper_get_modes(connector);

	if (!count) {
		/*
		 * There's no EDID data without a connected monitor. Set BMC-
		 * compatible modes in this case. The XGA default resolution
		 * should work well for all BMCs.
		 */
		count = drm_add_modes_noedid(connector, minfo->max_hdisplay, minfo->max_vdisplay);
		if (count)
			drm_set_preferred_mode(connector, 1024, 768);
	}

	return count;
}

/*
 * There's no monitor connected if the DDC did not return an EDID. Still
 * return 'connected' as there's always a BMC. Incrementing the connector's
 * epoch counter triggers an update of the related properties.
 */
static int mgag200_vga_bmc_connector_helper_detect_ctx(struct drm_connector *connector,
						       struct drm_modeset_acquire_ctx *ctx,
						       bool force)
{
	enum drm_connector_status old_status, status;

	if (connector->edid_blob_ptr)
		old_status = connector_status_connected;
	else
		old_status = connector_status_disconnected;

	status = drm_connector_helper_detect_from_ddc(connector, ctx, force);

Annotation

Implementation Notes