drivers/media/usb/pvrusb2/pvrusb2-ctrl.c
Source file repositories/reference/linux-study-clean/drivers/media/usb/pvrusb2/pvrusb2-ctrl.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/usb/pvrusb2/pvrusb2-ctrl.c- Extension
.c- Size
- 12903 bytes
- Lines
- 564
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
pvrusb2-ctrl.hpvrusb2-hdw-internal.hlinux/errno.hlinux/string.hlinux/mutex.h
Detected Declarations
function Copyrightfunction pvr2_ctrl_set_valuefunction pvr2_ctrl_set_mask_valuefunction pvr2_ctrl_get_valuefunction pvr2_ctrl_get_typefunction pvr2_ctrl_get_maxfunction pvr2_ctrl_get_minfunction pvr2_ctrl_get_deffunction pvr2_ctrl_get_cntfunction pvr2_ctrl_get_maskfunction pvr2_ctrl_get_valnamefunction pvr2_ctrl_get_v4lidfunction pvr2_ctrl_get_v4lflagsfunction pvr2_ctrl_is_writablefunction pvr2_ctrl_has_custom_symbolsfunction pvr2_ctrl_custom_value_to_symfunction pvr2_ctrl_custom_sym_to_valuefunction gen_bitmask_stringfunction parse_tokenfunction parse_mtokenfunction parse_tlistfunction pvr2_ctrl_sym_to_valuefunction pvr2_ctrl_value_to_sym_internalfunction pvr2_ctrl_value_to_sym
Annotated Snippet
if (cptr->info->get_min_value) {
cptr->info->get_min_value(cptr,&lim);
}
if (val < lim) return -ERANGE;
lim = cptr->info->def.type_int.max_value;
if (cptr->info->get_max_value) {
cptr->info->get_max_value(cptr,&lim);
}
if (val > lim) return -ERANGE;
}
return 0;
}
/* Set the given control. */
int pvr2_ctrl_set_value(struct pvr2_ctrl *cptr,int val)
{
return pvr2_ctrl_set_mask_value(cptr,~0,val);
}
/* Set/clear specific bits of the given control. */
int pvr2_ctrl_set_mask_value(struct pvr2_ctrl *cptr,int mask,int val)
{
int ret = 0;
if (!cptr) return -EINVAL;
LOCK_TAKE(cptr->hdw->big_lock); do {
if (cptr->info->set_value) {
if (cptr->info->type == pvr2_ctl_bitmask) {
mask &= cptr->info->def.type_bitmask.valid_bits;
} else if ((cptr->info->type == pvr2_ctl_int)||
(cptr->info->type == pvr2_ctl_enum)) {
ret = pvr2_ctrl_range_check(cptr,val);
if (ret < 0) break;
} else if (cptr->info->type != pvr2_ctl_bool) {
break;
}
ret = cptr->info->set_value(cptr,mask,val);
} else {
ret = -EPERM;
}
} while(0); LOCK_GIVE(cptr->hdw->big_lock);
return ret;
}
/* Get the current value of the given control. */
int pvr2_ctrl_get_value(struct pvr2_ctrl *cptr,int *valptr)
{
int ret = 0;
if (!cptr) return -EINVAL;
LOCK_TAKE(cptr->hdw->big_lock); do {
ret = cptr->info->get_value(cptr,valptr);
} while(0); LOCK_GIVE(cptr->hdw->big_lock);
return ret;
}
/* Retrieve control's type */
enum pvr2_ctl_type pvr2_ctrl_get_type(struct pvr2_ctrl *cptr)
{
if (!cptr) return pvr2_ctl_int;
return cptr->info->type;
}
/* Retrieve control's maximum value (int type) */
int pvr2_ctrl_get_max(struct pvr2_ctrl *cptr)
{
int ret = 0;
if (!cptr) return 0;
LOCK_TAKE(cptr->hdw->big_lock); do {
if (cptr->info->get_max_value) {
cptr->info->get_max_value(cptr,&ret);
} else if (cptr->info->type == pvr2_ctl_int) {
ret = cptr->info->def.type_int.max_value;
}
} while(0); LOCK_GIVE(cptr->hdw->big_lock);
return ret;
}
/* Retrieve control's minimum value (int type) */
int pvr2_ctrl_get_min(struct pvr2_ctrl *cptr)
{
int ret = 0;
if (!cptr) return 0;
LOCK_TAKE(cptr->hdw->big_lock); do {
if (cptr->info->get_min_value) {
cptr->info->get_min_value(cptr,&ret);
Annotation
- Immediate include surface: `pvrusb2-ctrl.h`, `pvrusb2-hdw-internal.h`, `linux/errno.h`, `linux/string.h`, `linux/mutex.h`.
- Detected declarations: `function Copyright`, `function pvr2_ctrl_set_value`, `function pvr2_ctrl_set_mask_value`, `function pvr2_ctrl_get_value`, `function pvr2_ctrl_get_type`, `function pvr2_ctrl_get_max`, `function pvr2_ctrl_get_min`, `function pvr2_ctrl_get_def`, `function pvr2_ctrl_get_cnt`, `function pvr2_ctrl_get_mask`.
- 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.