drivers/gpu/drm/nouveau/dispnv04/nouveau_i2c_encoder.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/nouveau/dispnv04/nouveau_i2c_encoder.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/nouveau/dispnv04/nouveau_i2c_encoder.c- Extension
.c- Size
- 3993 bytes
- Lines
- 126
- 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.
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hdispnv04/i2c/encoder_i2c.h
Detected Declarations
function Copyrightfunction nouveau_i2c_encoder_mode_fixupfunction nouveau_i2c_encoder_detectfunction nouveau_i2c_encoder_savefunction nouveau_i2c_encoder_restore
Annotated Snippet
#include <linux/module.h>
#include <dispnv04/i2c/encoder_i2c.h>
/**
* nouveau_i2c_encoder_init - Initialize an I2C slave encoder
* @dev: DRM device.
* @encoder: Encoder to be attached to the I2C device. You aren't
* required to have called drm_encoder_init() before.
* @adap: I2C adapter that will be used to communicate with
* the device.
* @info: Information that will be used to create the I2C device.
* Required fields are @addr and @type.
*
* Create an I2C device on the specified bus (the module containing its
* driver is transparently loaded) and attach it to the specified
* &nouveau_i2c_encoder. The @encoder_i2c_funcs field will be initialized with
* the hooks provided by the slave driver.
*
* If @info.platform_data is non-NULL it will be used as the initial
* slave config.
*
* Returns 0 on success or a negative errno on failure, in particular,
* -ENODEV is returned when no matching driver is found.
*/
int nouveau_i2c_encoder_init(struct drm_device *dev,
struct nouveau_i2c_encoder *encoder,
struct i2c_adapter *adap,
const struct i2c_board_info *info)
{
struct module *module = NULL;
struct i2c_client *client;
struct nouveau_i2c_encoder_driver *encoder_drv;
int err = 0;
request_module("%s%s", I2C_MODULE_PREFIX, info->type);
client = i2c_new_client_device(adap, info);
if (!i2c_client_has_driver(client)) {
err = -ENODEV;
goto fail_unregister;
}
module = client->dev.driver->owner;
if (!try_module_get(module)) {
err = -ENODEV;
goto fail_unregister;
}
encoder->i2c_client = client;
encoder_drv = to_nouveau_i2c_encoder_driver(to_i2c_driver(client->dev.driver));
err = encoder_drv->encoder_init(client, dev, encoder);
if (err)
goto fail_module_put;
if (info->platform_data)
encoder->encoder_i2c_funcs->set_config(&encoder->base,
info->platform_data);
return 0;
fail_module_put:
module_put(module);
fail_unregister:
i2c_unregister_device(client);
return err;
}
/*
* Wrapper fxns which can be plugged in to drm_encoder_helper_funcs:
*/
bool nouveau_i2c_encoder_mode_fixup(struct drm_encoder *encoder,
const struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode)
{
if (!get_encoder_i2c_funcs(encoder)->mode_fixup)
return true;
return get_encoder_i2c_funcs(encoder)->mode_fixup(encoder, mode, adjusted_mode);
}
enum drm_connector_status nouveau_i2c_encoder_detect(struct drm_encoder *encoder,
struct drm_connector *connector)
{
return get_encoder_i2c_funcs(encoder)->detect(encoder, connector);
}
Annotation
- Immediate include surface: `linux/module.h`, `dispnv04/i2c/encoder_i2c.h`.
- Detected declarations: `function Copyright`, `function nouveau_i2c_encoder_mode_fixup`, `function nouveau_i2c_encoder_detect`, `function nouveau_i2c_encoder_save`, `function nouveau_i2c_encoder_restore`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
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.