drivers/media/dvb-frontends/lnbh29.c
Source file repositories/reference/linux-study-clean/drivers/media/dvb-frontends/lnbh29.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/dvb-frontends/lnbh29.c- Extension
.c- Size
- 3782 bytes
- Lines
- 169
- 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.
- 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/module.hlinux/init.hlinux/slab.hmedia/dvb_frontend.hlnbh29.h
Detected Declarations
struct lnbh29_privfunction lnbh29_read_vmonfunction lnbh29_set_voltagefunction lnbh29_releaseexport lnbh29_attach
Annotated Snippet
struct lnbh29_priv {
struct i2c_adapter *i2c;
u8 i2c_address;
u8 config[2];
};
#define LNBH29_STATUS_OLF BIT(0)
#define LNBH29_STATUS_OTF BIT(1)
#define LNBH29_STATUS_VMON BIT(2)
#define LNBH29_STATUS_PNG BIT(3)
#define LNBH29_STATUS_PDO BIT(4)
#define LNBH29_VSEL_MASK GENMASK(2, 0)
#define LNBH29_VSEL_0 0x00
/* Min: 13.188V, Typ: 13.667V, Max:14V */
#define LNBH29_VSEL_13 0x03
/* Min: 18.158V, Typ: 18.817V, Max:19.475V */
#define LNBH29_VSEL_18 0x07
static int lnbh29_read_vmon(struct lnbh29_priv *priv)
{
u8 addr = 0x00;
u8 status[2];
int ret;
struct i2c_msg msg[2] = {
{
.addr = priv->i2c_address,
.flags = 0,
.len = 1,
.buf = &addr
}, {
.addr = priv->i2c_address,
.flags = I2C_M_RD,
.len = sizeof(status),
.buf = status
}
};
ret = i2c_transfer(priv->i2c, msg, 2);
if (ret >= 0 && ret != 2)
ret = -EIO;
if (ret < 0) {
dev_dbg(&priv->i2c->dev, "LNBH29 I2C transfer failed (%d)\n",
ret);
return ret;
}
if (status[0] & (LNBH29_STATUS_OLF | LNBH29_STATUS_VMON)) {
dev_err(&priv->i2c->dev,
"LNBH29 voltage in failure state, status reg 0x%x\n",
status[0]);
return -EIO;
}
return 0;
}
static int lnbh29_set_voltage(struct dvb_frontend *fe,
enum fe_sec_voltage voltage)
{
struct lnbh29_priv *priv = fe->sec_priv;
u8 data_reg;
int ret;
struct i2c_msg msg = {
.addr = priv->i2c_address,
.flags = 0,
.len = sizeof(priv->config),
.buf = priv->config
};
switch (voltage) {
case SEC_VOLTAGE_OFF:
data_reg = LNBH29_VSEL_0;
break;
case SEC_VOLTAGE_13:
data_reg = LNBH29_VSEL_13;
break;
case SEC_VOLTAGE_18:
data_reg = LNBH29_VSEL_18;
break;
default:
return -EINVAL;
}
priv->config[1] &= ~LNBH29_VSEL_MASK;
priv->config[1] |= data_reg;
ret = i2c_transfer(priv->i2c, &msg, 1);
if (ret >= 0 && ret != 1)
ret = -EIO;
if (ret < 0) {
dev_err(&priv->i2c->dev, "LNBH29 I2C transfer error (%d)\n",
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/slab.h`, `media/dvb_frontend.h`, `lnbh29.h`.
- Detected declarations: `struct lnbh29_priv`, `function lnbh29_read_vmon`, `function lnbh29_set_voltage`, `function lnbh29_release`, `export lnbh29_attach`.
- 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.