drivers/media/i2c/ths7303.c
Source file repositories/reference/linux-study-clean/drivers/media/i2c/ths7303.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/i2c/ths7303.c- Extension
.c- Size
- 9604 bytes
- Lines
- 389
- 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/module.hlinux/slab.hmedia/i2c/ths7303.hmedia/v4l2-device.h
Detected Declarations
struct ths7303_stateenum ths7303_filter_modefunction ths7303_readfunction ths7303_writefunction ths7303_setvalfunction ths7303_s_std_outputfunction ths7303_configfunction ths7303_s_streamfunction ths7303_s_dv_timingsfunction ths7303_g_registerfunction ths7303_s_registerfunction ths7303_log_channel_statusfunction ths7303_log_statusfunction ths7303_probefunction ths7303_remove
Annotated Snippet
struct ths7303_state {
struct v4l2_subdev sd;
const struct ths7303_platform_data *pdata;
struct v4l2_bt_timings bt;
int std_id;
int stream_on;
};
enum ths7303_filter_mode {
THS7303_FILTER_MODE_480I_576I,
THS7303_FILTER_MODE_480P_576P,
THS7303_FILTER_MODE_720P_1080I,
THS7303_FILTER_MODE_1080P,
THS7303_FILTER_MODE_DISABLE
};
MODULE_DESCRIPTION("TI THS7303 video amplifier driver");
MODULE_AUTHOR("Chaithrika U S");
MODULE_LICENSE("GPL");
static inline struct ths7303_state *to_state(struct v4l2_subdev *sd)
{
return container_of(sd, struct ths7303_state, sd);
}
static int ths7303_read(struct v4l2_subdev *sd, u8 reg)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
return i2c_smbus_read_byte_data(client, reg);
}
static int ths7303_write(struct v4l2_subdev *sd, u8 reg, u8 val)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
int ret;
int i;
for (i = 0; i < 3; i++) {
ret = i2c_smbus_write_byte_data(client, reg, val);
if (ret == 0)
return 0;
}
return ret;
}
/* following function is used to set ths7303 */
static int ths7303_setval(struct v4l2_subdev *sd,
enum ths7303_filter_mode mode)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct ths7303_state *state = to_state(sd);
const struct ths7303_platform_data *pdata = state->pdata;
u8 val, sel = 0;
int err, disable = 0;
if (!client)
return -EINVAL;
switch (mode) {
case THS7303_FILTER_MODE_1080P:
sel = 0x3; /*1080p and SXGA/UXGA */
break;
case THS7303_FILTER_MODE_720P_1080I:
sel = 0x2; /*720p, 1080i and SVGA/XGA */
break;
case THS7303_FILTER_MODE_480P_576P:
sel = 0x1; /* EDTV 480p/576p and VGA */
break;
case THS7303_FILTER_MODE_480I_576I:
sel = 0x0; /* SDTV, S-Video, 480i/576i */
break;
default:
/* disable all channels */
disable = 1;
}
val = (sel << 6) | (sel << 3);
if (!disable)
val |= (pdata->ch_1 & 0x27);
err = ths7303_write(sd, THS7303_CHANNEL_1, val);
if (err)
goto out;
val = (sel << 6) | (sel << 3);
if (!disable)
val |= (pdata->ch_2 & 0x27);
err = ths7303_write(sd, THS7303_CHANNEL_2, val);
if (err)
goto out;
Annotation
- Immediate include surface: `linux/i2c.h`, `linux/module.h`, `linux/slab.h`, `media/i2c/ths7303.h`, `media/v4l2-device.h`.
- Detected declarations: `struct ths7303_state`, `enum ths7303_filter_mode`, `function ths7303_read`, `function ths7303_write`, `function ths7303_setval`, `function ths7303_s_std_output`, `function ths7303_config`, `function ths7303_s_stream`, `function ths7303_s_dv_timings`, `function ths7303_g_register`.
- 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.