drivers/media/i2c/max9271.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/max9271.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/max9271.c- Extension
.c- Size
- 8226 bytes
- Lines
- 375
- Domain
- Driver Families
- Bucket
- drivers/media
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/delay.hlinux/i2c.hlinux/module.hmax9271.h
Detected Declarations
function Copyrightfunction max9271_writefunction max9271_pclk_detectfunction max9271_wake_upfunction max9271_set_serial_linkfunction max9271_configure_i2cfunction max9271_set_high_thresholdfunction max9271_configure_gmsl_linkfunction max9271_set_gpiosfunction max9271_clear_gpiosfunction max9271_enable_gpiosfunction max9271_disable_gpiosfunction max9271_verify_idfunction max9271_set_addressfunction max9271_set_deserializer_addressfunction max9271_set_translationexport max9271_wake_upexport max9271_set_serial_linkexport max9271_configure_i2cexport max9271_set_high_thresholdexport max9271_configure_gmsl_linkexport max9271_set_gpiosexport max9271_clear_gpiosexport max9271_enable_gpiosexport max9271_disable_gpiosexport max9271_verify_idexport max9271_set_addressexport max9271_set_deserializer_addressexport max9271_set_translation
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2017-2020 Jacopo Mondi
* Copyright (C) 2017-2020 Kieran Bingham
* Copyright (C) 2017-2020 Laurent Pinchart
* Copyright (C) 2017-2020 Niklas Söderlund
* Copyright (C) 2016 Renesas Electronics Corporation
* Copyright (C) 2015 Cogent Embedded, Inc.
*
* This file exports functions to control the Maxim MAX9271 GMSL serializer
* chip. This is not a self-contained driver, as MAX9271 is usually embedded in
* camera modules with at least one image sensor and optional additional
* components, such as uController units or ISPs/DSPs.
*
* Drivers for the camera modules (i.e. rdacm20/21) are expected to use
* functions exported from this library driver to maximize code re-use.
*/
#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include "max9271.h"
static int max9271_read(struct max9271_device *dev, u8 reg)
{
int ret;
dev_dbg(&dev->client->dev, "%s(0x%02x)\n", __func__, reg);
ret = i2c_smbus_read_byte_data(dev->client, reg);
if (ret < 0)
dev_dbg(&dev->client->dev,
"%s: register 0x%02x read failed (%d)\n",
__func__, reg, ret);
return ret;
}
static int max9271_write(struct max9271_device *dev, u8 reg, u8 val)
{
int ret;
dev_dbg(&dev->client->dev, "%s(0x%02x, 0x%02x)\n", __func__, reg, val);
ret = i2c_smbus_write_byte_data(dev->client, reg, val);
if (ret < 0)
dev_err(&dev->client->dev,
"%s: register 0x%02x write failed (%d)\n",
__func__, reg, ret);
return ret;
}
/*
* max9271_pclk_detect() - Detect valid pixel clock from image sensor
*
* Wait up to 10ms for a valid pixel clock.
*
* Returns 0 for success, < 0 for pixel clock not properly detected
*/
static int max9271_pclk_detect(struct max9271_device *dev)
{
unsigned int i;
int ret;
for (i = 0; i < 100; i++) {
ret = max9271_read(dev, 0x15);
if (ret < 0)
return ret;
if (ret & MAX9271_PCLKDET)
return 0;
usleep_range(50, 100);
}
dev_err(&dev->client->dev, "Unable to detect valid pixel clock\n");
return -EIO;
}
void max9271_wake_up(struct max9271_device *dev)
{
/*
* Use the chip default address as this function has to be called
* before any other one.
*/
dev->client->addr = MAX9271_DEFAULT_ADDR;
i2c_smbus_read_byte(dev->client);
Annotation
- Immediate include surface: `linux/delay.h`, `linux/i2c.h`, `linux/module.h`, `max9271.h`.
- Detected declarations: `function Copyright`, `function max9271_write`, `function max9271_pclk_detect`, `function max9271_wake_up`, `function max9271_set_serial_link`, `function max9271_configure_i2c`, `function max9271_set_high_threshold`, `function max9271_configure_gmsl_link`, `function max9271_set_gpios`, `function max9271_clear_gpios`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: integration 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.