drivers/media/tuners/tuner-i2c.h
Source file repositories/reference/linux-study-clean/drivers/media/tuners/tuner-i2c.h
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/tuners/tuner-i2c.h- Extension
.h- Size
- 5191 bytes
- Lines
- 173
- Domain
- Driver Families
- Bucket
- drivers/media
- 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.
- 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/i2c.hlinux/slab.h
Detected Declarations
struct tuner_i2c_propsfunction tuner_i2c_xfer_sendfunction tuner_i2c_xfer_recvfunction tuner_i2c_xfer_send_recv
Annotated Snippet
struct tuner_i2c_props {
u8 addr;
struct i2c_adapter *adap;
/* used for tuner instance management */
int count;
char *name;
};
static inline int tuner_i2c_xfer_send(struct tuner_i2c_props *props,
unsigned char *buf, int len)
{
struct i2c_msg msg = { .addr = props->addr, .flags = 0,
.buf = buf, .len = len };
int ret = i2c_transfer(props->adap, &msg, 1);
return (ret == 1) ? len : ret;
}
static inline int tuner_i2c_xfer_recv(struct tuner_i2c_props *props,
unsigned char *buf, int len)
{
struct i2c_msg msg = { .addr = props->addr, .flags = I2C_M_RD,
.buf = buf, .len = len };
int ret = i2c_transfer(props->adap, &msg, 1);
return (ret == 1) ? len : ret;
}
static inline int tuner_i2c_xfer_send_recv(struct tuner_i2c_props *props,
unsigned char *obuf, int olen,
unsigned char *ibuf, int ilen)
{
struct i2c_msg msg[2] = { { .addr = props->addr, .flags = 0,
.buf = obuf, .len = olen },
{ .addr = props->addr, .flags = I2C_M_RD,
.buf = ibuf, .len = ilen } };
int ret = i2c_transfer(props->adap, msg, 2);
return (ret == 2) ? ilen : ret;
}
/* Callers must declare as a global for the module:
*
* static LIST_HEAD(hybrid_tuner_instance_list);
*
* hybrid_tuner_instance_list should be the third argument
* passed into hybrid_tuner_request_state().
*
* state structure must contain the following:
*
* struct list_head hybrid_tuner_instance_list;
* struct tuner_i2c_props i2c_props;
*
* hybrid_tuner_instance_list (both within state structure and globally)
* is only required if the driver is using hybrid_tuner_request_state
* and hybrid_tuner_release_state to manage state sharing between
* multiple instances of hybrid tuners.
*/
#define tuner_printk(kernlvl, i2cprops, fmt, arg...) do { \
printk(kernlvl "%s %d-%04x: " fmt, i2cprops.name, \
i2cprops.adap ? \
i2c_adapter_id(i2cprops.adap) : -1, \
i2cprops.addr, ##arg); \
} while (0)
/* TO DO: convert all callers of these macros to pass in
* struct tuner_i2c_props, then remove the macro wrappers */
#define __tuner_warn(i2cprops, fmt, arg...) do { \
tuner_printk(KERN_WARNING, i2cprops, fmt, ##arg); \
} while (0)
#define __tuner_info(i2cprops, fmt, arg...) do { \
tuner_printk(KERN_INFO, i2cprops, fmt, ##arg); \
} while (0)
#define __tuner_err(i2cprops, fmt, arg...) do { \
tuner_printk(KERN_ERR, i2cprops, fmt, ##arg); \
} while (0)
#define __tuner_dbg(i2cprops, fmt, arg...) do { \
if ((debug)) \
tuner_printk(KERN_DEBUG, i2cprops, fmt, ##arg); \
} while (0)
#define tuner_warn(fmt, arg...) __tuner_warn(priv->i2c_props, fmt, ##arg)
#define tuner_info(fmt, arg...) __tuner_info(priv->i2c_props, fmt, ##arg)
#define tuner_err(fmt, arg...) __tuner_err(priv->i2c_props, fmt, ##arg)
Annotation
- Immediate include surface: `linux/i2c.h`, `linux/slab.h`.
- Detected declarations: `struct tuner_i2c_props`, `function tuner_i2c_xfer_send`, `function tuner_i2c_xfer_recv`, `function tuner_i2c_xfer_send_recv`.
- Atlas domain: Driver Families / drivers/media.
- 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.