include/linux/usb/typec_altmode.h

Source file repositories/reference/linux-study-clean/include/linux/usb/typec_altmode.h

File Facts

System
Linux kernel
Corpus path
include/linux/usb/typec_altmode.h
Extension
.h
Size
10659 bytes
Lines
288
Domain
Core OS
Bucket
Core Kernel Interface
Inferred role
Core OS: operation-table or driver-model contract
Status
pattern implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

struct device_driver driver;
};

#define to_altmode_driver(d) container_of(d, struct typec_altmode_driver, \
					  driver)

/**
 * typec_altmode_register_driver - registers a USB Type-C alternate mode
 * 				   device driver
 * @drv: pointer to struct typec_altmode_driver
 *
 * These drivers will be bind to the partner alternate mode devices. They will
 * handle all SVID specific communication.
 */
#define typec_altmode_register_driver(drv) \
		__typec_altmode_register_driver(drv, THIS_MODULE)
int __typec_altmode_register_driver(struct typec_altmode_driver *drv,
				    struct module *module);
/**
 * typec_altmode_unregister_driver - unregisters a USB Type-C alternate mode
 * 				     device driver
 * @drv: pointer to struct typec_altmode_driver
 *
 * These drivers will be bind to the partner alternate mode devices. They will
 * handle all SVID specific communication.
 */
void typec_altmode_unregister_driver(struct typec_altmode_driver *drv);

#define module_typec_altmode_driver(__typec_altmode_driver) \
	module_driver(__typec_altmode_driver, typec_altmode_register_driver, \
		      typec_altmode_unregister_driver)

/**
 * typec_mode_selection_start - Start an alternate mode selection process
 * @partner: Handle to the Type-C partner device
 * @delay: Delay between mode entry/exit attempts, ms
 * @timeout: Timeout for a mode entry attempt, ms
 *
 * This function initiates the process of attempting to enter an Alternate Mode
 * supported by the connected Type-C partner.
 * Returns 0 on success, or a negative error code on failure.
 */
int typec_mode_selection_start(struct typec_partner *partner,
			       const unsigned int delay, const unsigned int timeout);

/**
 * typec_altmode_state_update - Report the current status of an Alternate Mode
 * negotiation
 * @partner: Handle to the Type-C partner device
 * @svid: Standard or Vendor ID of the Alternate Mode. A value of 0 should be
 * passed if no mode is currently active
 * @result: Result of the entry operation. This should be 0 on success, or a
 * negative error code if the negotiation failed
 *
 * This function should be called by an Alternate Mode driver to report the
 * result of an asynchronous alternate mode entry request. It signals what the
 * current active SVID is (or 0 if none) and the success or failure status of
 * the last attempt.
 */
void typec_altmode_state_update(struct typec_partner *partner, const u16 svid,
				const int result);

/**
 * typec_mode_selection_delete - Delete an alternate mode selection instance
 * @partner: Handle to the Type-C partner device.
 *
 * This function cancels a pending alternate mode selection request that was
 * previously started with typec_mode_selection_start().
 * This is typically called when the partner disconnects.
 */
void typec_mode_selection_delete(struct typec_partner *partner);

#endif /* __USB_TYPEC_ALTMODE_H */

Annotation

Implementation Notes