drivers/usb/typec/altmodes/displayport.c
Source file repositories/reference/linux-study-clean/drivers/usb/typec/altmodes/displayport.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/typec/altmodes/displayport.c- Extension
.c- Size
- 20931 bytes
- Lines
- 859
- Domain
- Driver Families
- Bucket
- drivers/usb
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/delay.hlinux/mutex.hlinux/module.hlinux/property.hlinux/usb/pd_vdo.hlinux/usb/typec_dp.hdrm/drm_connector.hdisplayport.h
Detected Declarations
struct dp_altmodeenum dp_statefunction dp_altmode_notifyfunction dp_altmode_configurefunction dp_altmode_status_updatefunction dp_altmode_configuredfunction dp_altmode_configure_vdmfunction dp_altmode_configure_vdm_cablefunction dp_altmode_workfunction dp_altmode_attentionfunction dp_altmode_vdmfunction dp_cable_altmode_vdmfunction dp_altmode_activatefunction configuration_storefunction configuration_showfunction get_current_pin_assignmentsfunction pin_assignment_storefunction pin_assignment_showfunction hpd_showfunction irq_hpd_showfunction dp_altmode_probefunction DP_CAP_PIN_ASSIGN_UFP_Dfunction dp_altmode_removeexport dp_altmode_probeexport dp_altmode_remove
Annotated Snippet
struct dp_altmode {
struct typec_displayport_data data;
struct typec_displayport_data data_prime;
enum dp_state state;
bool hpd;
bool pending_hpd;
u32 irq_hpd_count;
/*
* hpd is mandatory for irq_hpd assertion, so irq_hpd also needs its own pending flag if
* both hpd and irq_hpd are asserted in the first Status Update before the pin assignment
* is configured.
*/
bool pending_irq_hpd;
struct mutex lock; /* device lock */
struct work_struct work;
struct typec_altmode *alt;
const struct typec_altmode *port;
struct fwnode_handle *connector_fwnode;
struct typec_altmode *plug_prime;
};
static int dp_altmode_notify(struct dp_altmode *dp)
{
unsigned long conf;
u8 state;
if (dp->data.conf) {
state = get_count_order(DP_CONF_GET_PIN_ASSIGN(dp->data.conf));
conf = TYPEC_MODAL_STATE(state);
} else {
conf = TYPEC_STATE_USB;
}
return typec_altmode_notify(dp->alt, conf, &dp->data);
}
static int dp_altmode_configure(struct dp_altmode *dp, u8 con)
{
u8 pin_assign = 0;
u32 conf;
u32 signal;
/* DP Signalling */
signal = DP_CAP_DP_SIGNALLING(dp->port->vdo) & DP_CAP_DP_SIGNALLING(dp->alt->vdo);
if (dp->plug_prime)
signal &= DP_CAP_DP_SIGNALLING(dp->plug_prime->vdo);
conf = signal << DP_CONF_SIGNALLING_SHIFT;
switch (con) {
case DP_STATUS_CON_DISABLED:
return 0;
case DP_STATUS_CON_DFP_D:
conf |= DP_CONF_UFP_U_AS_DFP_D;
pin_assign = DP_CAP_UFP_D_PIN_ASSIGN(dp->alt->vdo) &
DP_CAP_DFP_D_PIN_ASSIGN(dp->port->vdo);
/* Account for active cable capabilities */
if (dp->plug_prime)
pin_assign &= DP_CAP_DFP_D_PIN_ASSIGN(dp->plug_prime->vdo);
break;
case DP_STATUS_CON_UFP_D:
case DP_STATUS_CON_BOTH: /* NOTE: First acting as DP source */
conf |= DP_CONF_UFP_U_AS_UFP_D;
pin_assign = DP_CAP_PIN_ASSIGN_UFP_D(dp->alt->vdo) &
DP_CAP_PIN_ASSIGN_DFP_D(dp->port->vdo);
/* Account for active cable capabilities */
if (dp->plug_prime)
pin_assign &= DP_CAP_UFP_D_PIN_ASSIGN(dp->plug_prime->vdo);
break;
default:
break;
}
/* Determining the initial pin assignment. */
if (!DP_CONF_GET_PIN_ASSIGN(dp->data.conf)) {
/* Is USB together with DP preferred */
if (dp->data.status & DP_STATUS_PREFER_MULTI_FUNC &&
pin_assign & DP_PIN_ASSIGN_MULTI_FUNC_MASK)
pin_assign &= DP_PIN_ASSIGN_MULTI_FUNC_MASK;
else if (pin_assign & DP_PIN_ASSIGN_DP_ONLY_MASK) {
pin_assign &= DP_PIN_ASSIGN_DP_ONLY_MASK;
/* Default to pin assign C if available */
if (pin_assign & BIT(DP_PIN_ASSIGN_C))
pin_assign = BIT(DP_PIN_ASSIGN_C);
}
if (!pin_assign)
return -EINVAL;
Annotation
- Immediate include surface: `linux/delay.h`, `linux/mutex.h`, `linux/module.h`, `linux/property.h`, `linux/usb/pd_vdo.h`, `linux/usb/typec_dp.h`, `drm/drm_connector.h`, `displayport.h`.
- Detected declarations: `struct dp_altmode`, `enum dp_state`, `function dp_altmode_notify`, `function dp_altmode_configure`, `function dp_altmode_status_update`, `function dp_altmode_configured`, `function dp_altmode_configure_vdm`, `function dp_altmode_configure_vdm_cable`, `function dp_altmode_work`, `function dp_altmode_attention`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.