Lines Matching refs:cptr
14 static int pvr2_ctrl_range_check(struct pvr2_ctrl *cptr,int val) in pvr2_ctrl_range_check() argument
16 if (cptr->info->check_value) { in pvr2_ctrl_range_check()
17 if (!cptr->info->check_value(cptr,val)) return -ERANGE; in pvr2_ctrl_range_check()
18 } else if (cptr->info->type == pvr2_ctl_enum) { in pvr2_ctrl_range_check()
20 if (val >= cptr->info->def.type_enum.count) return -ERANGE; in pvr2_ctrl_range_check()
23 lim = cptr->info->def.type_int.min_value; in pvr2_ctrl_range_check()
24 if (cptr->info->get_min_value) { in pvr2_ctrl_range_check()
25 cptr->info->get_min_value(cptr,&lim); in pvr2_ctrl_range_check()
28 lim = cptr->info->def.type_int.max_value; in pvr2_ctrl_range_check()
29 if (cptr->info->get_max_value) { in pvr2_ctrl_range_check()
30 cptr->info->get_max_value(cptr,&lim); in pvr2_ctrl_range_check()
39 int pvr2_ctrl_set_value(struct pvr2_ctrl *cptr,int val) in pvr2_ctrl_set_value() argument
41 return pvr2_ctrl_set_mask_value(cptr,~0,val); in pvr2_ctrl_set_value()
46 int pvr2_ctrl_set_mask_value(struct pvr2_ctrl *cptr,int mask,int val) in pvr2_ctrl_set_mask_value() argument
49 if (!cptr) return -EINVAL; in pvr2_ctrl_set_mask_value()
50 LOCK_TAKE(cptr->hdw->big_lock); do { in pvr2_ctrl_set_mask_value()
51 if (cptr->info->set_value) { in pvr2_ctrl_set_mask_value()
52 if (cptr->info->type == pvr2_ctl_bitmask) { in pvr2_ctrl_set_mask_value()
53 mask &= cptr->info->def.type_bitmask.valid_bits; in pvr2_ctrl_set_mask_value()
54 } else if ((cptr->info->type == pvr2_ctl_int)|| in pvr2_ctrl_set_mask_value()
55 (cptr->info->type == pvr2_ctl_enum)) { in pvr2_ctrl_set_mask_value()
56 ret = pvr2_ctrl_range_check(cptr,val); in pvr2_ctrl_set_mask_value()
58 } else if (cptr->info->type != pvr2_ctl_bool) { in pvr2_ctrl_set_mask_value()
61 ret = cptr->info->set_value(cptr,mask,val); in pvr2_ctrl_set_mask_value()
65 } while(0); LOCK_GIVE(cptr->hdw->big_lock); in pvr2_ctrl_set_mask_value()
71 int pvr2_ctrl_get_value(struct pvr2_ctrl *cptr,int *valptr) in pvr2_ctrl_get_value() argument
74 if (!cptr) return -EINVAL; in pvr2_ctrl_get_value()
75 LOCK_TAKE(cptr->hdw->big_lock); do { in pvr2_ctrl_get_value()
76 ret = cptr->info->get_value(cptr,valptr); in pvr2_ctrl_get_value()
77 } while(0); LOCK_GIVE(cptr->hdw->big_lock); in pvr2_ctrl_get_value()
83 enum pvr2_ctl_type pvr2_ctrl_get_type(struct pvr2_ctrl *cptr) in pvr2_ctrl_get_type() argument
85 if (!cptr) return pvr2_ctl_int; in pvr2_ctrl_get_type()
86 return cptr->info->type; in pvr2_ctrl_get_type()
91 int pvr2_ctrl_get_max(struct pvr2_ctrl *cptr) in pvr2_ctrl_get_max() argument
94 if (!cptr) return 0; in pvr2_ctrl_get_max()
95 LOCK_TAKE(cptr->hdw->big_lock); do { in pvr2_ctrl_get_max()
96 if (cptr->info->get_max_value) { in pvr2_ctrl_get_max()
97 cptr->info->get_max_value(cptr,&ret); in pvr2_ctrl_get_max()
98 } else if (cptr->info->type == pvr2_ctl_int) { in pvr2_ctrl_get_max()
99 ret = cptr->info->def.type_int.max_value; in pvr2_ctrl_get_max()
101 } while(0); LOCK_GIVE(cptr->hdw->big_lock); in pvr2_ctrl_get_max()
107 int pvr2_ctrl_get_min(struct pvr2_ctrl *cptr) in pvr2_ctrl_get_min() argument
110 if (!cptr) return 0; in pvr2_ctrl_get_min()
111 LOCK_TAKE(cptr->hdw->big_lock); do { in pvr2_ctrl_get_min()
112 if (cptr->info->get_min_value) { in pvr2_ctrl_get_min()
113 cptr->info->get_min_value(cptr,&ret); in pvr2_ctrl_get_min()
114 } else if (cptr->info->type == pvr2_ctl_int) { in pvr2_ctrl_get_min()
115 ret = cptr->info->def.type_int.min_value; in pvr2_ctrl_get_min()
117 } while(0); LOCK_GIVE(cptr->hdw->big_lock); in pvr2_ctrl_get_min()
123 int pvr2_ctrl_get_def(struct pvr2_ctrl *cptr, int *valptr) in pvr2_ctrl_get_def() argument
126 if (!cptr) return -EINVAL; in pvr2_ctrl_get_def()
127 LOCK_TAKE(cptr->hdw->big_lock); do { in pvr2_ctrl_get_def()
128 if (cptr->info->get_def_value) { in pvr2_ctrl_get_def()
129 ret = cptr->info->get_def_value(cptr, valptr); in pvr2_ctrl_get_def()
131 *valptr = cptr->info->default_value; in pvr2_ctrl_get_def()
133 } while(0); LOCK_GIVE(cptr->hdw->big_lock); in pvr2_ctrl_get_def()
139 int pvr2_ctrl_get_cnt(struct pvr2_ctrl *cptr) in pvr2_ctrl_get_cnt() argument
142 if (!cptr) return 0; in pvr2_ctrl_get_cnt()
143 LOCK_TAKE(cptr->hdw->big_lock); do { in pvr2_ctrl_get_cnt()
144 if (cptr->info->type == pvr2_ctl_enum) { in pvr2_ctrl_get_cnt()
145 ret = cptr->info->def.type_enum.count; in pvr2_ctrl_get_cnt()
147 } while(0); LOCK_GIVE(cptr->hdw->big_lock); in pvr2_ctrl_get_cnt()
153 int pvr2_ctrl_get_mask(struct pvr2_ctrl *cptr) in pvr2_ctrl_get_mask() argument
156 if (!cptr) return 0; in pvr2_ctrl_get_mask()
157 LOCK_TAKE(cptr->hdw->big_lock); do { in pvr2_ctrl_get_mask()
158 if (cptr->info->type == pvr2_ctl_bitmask) { in pvr2_ctrl_get_mask()
159 ret = cptr->info->def.type_bitmask.valid_bits; in pvr2_ctrl_get_mask()
161 } while(0); LOCK_GIVE(cptr->hdw->big_lock); in pvr2_ctrl_get_mask()
167 const char *pvr2_ctrl_get_name(struct pvr2_ctrl *cptr) in pvr2_ctrl_get_name() argument
169 if (!cptr) return NULL; in pvr2_ctrl_get_name()
170 return cptr->info->name; in pvr2_ctrl_get_name()
175 const char *pvr2_ctrl_get_desc(struct pvr2_ctrl *cptr) in pvr2_ctrl_get_desc() argument
177 if (!cptr) return NULL; in pvr2_ctrl_get_desc()
178 return cptr->info->desc; in pvr2_ctrl_get_desc()
183 int pvr2_ctrl_get_valname(struct pvr2_ctrl *cptr,int val, in pvr2_ctrl_get_valname() argument
188 if (!cptr) return 0; in pvr2_ctrl_get_valname()
190 LOCK_TAKE(cptr->hdw->big_lock); do { in pvr2_ctrl_get_valname()
191 if (cptr->info->type == pvr2_ctl_enum) { in pvr2_ctrl_get_valname()
193 names = cptr->info->def.type_enum.value_names; in pvr2_ctrl_get_valname()
194 if (pvr2_ctrl_range_check(cptr,val) == 0) { in pvr2_ctrl_get_valname()
204 } else if (cptr->info->type == pvr2_ctl_bitmask) { in pvr2_ctrl_get_valname()
208 names = cptr->info->def.type_bitmask.bit_names; in pvr2_ctrl_get_valname()
209 val &= cptr->info->def.type_bitmask.valid_bits; in pvr2_ctrl_get_valname()
219 } while(0); LOCK_GIVE(cptr->hdw->big_lock); in pvr2_ctrl_get_valname()
225 int pvr2_ctrl_get_v4lid(struct pvr2_ctrl *cptr) in pvr2_ctrl_get_v4lid() argument
227 if (!cptr) return 0; in pvr2_ctrl_get_v4lid()
228 return cptr->info->v4l_id; in pvr2_ctrl_get_v4lid()
232 unsigned int pvr2_ctrl_get_v4lflags(struct pvr2_ctrl *cptr) in pvr2_ctrl_get_v4lflags() argument
236 if (cptr->info->get_v4lflags) { in pvr2_ctrl_get_v4lflags()
237 flags = cptr->info->get_v4lflags(cptr); in pvr2_ctrl_get_v4lflags()
240 if (cptr->info->set_value) { in pvr2_ctrl_get_v4lflags()
251 int pvr2_ctrl_is_writable(struct pvr2_ctrl *cptr) in pvr2_ctrl_is_writable() argument
253 if (!cptr) return 0; in pvr2_ctrl_is_writable()
254 return cptr->info->set_value != NULL; in pvr2_ctrl_is_writable()
259 int pvr2_ctrl_has_custom_symbols(struct pvr2_ctrl *cptr) in pvr2_ctrl_has_custom_symbols() argument
261 if (!cptr) return 0; in pvr2_ctrl_has_custom_symbols()
262 if (!cptr->info->val_to_sym) return 0; in pvr2_ctrl_has_custom_symbols()
263 if (!cptr->info->sym_to_val) return 0; in pvr2_ctrl_has_custom_symbols()
269 int pvr2_ctrl_custom_value_to_sym(struct pvr2_ctrl *cptr, in pvr2_ctrl_custom_value_to_sym() argument
274 if (!cptr) return -EINVAL; in pvr2_ctrl_custom_value_to_sym()
275 if (!cptr->info->val_to_sym) return -EINVAL; in pvr2_ctrl_custom_value_to_sym()
276 return cptr->info->val_to_sym(cptr,mask,val,buf,maxlen,len); in pvr2_ctrl_custom_value_to_sym()
281 int pvr2_ctrl_custom_sym_to_value(struct pvr2_ctrl *cptr, in pvr2_ctrl_custom_sym_to_value() argument
285 if (!cptr) return -EINVAL; in pvr2_ctrl_custom_sym_to_value()
286 if (!cptr->info->sym_to_val) return -EINVAL; in pvr2_ctrl_custom_sym_to_value()
287 return cptr->info->sym_to_val(cptr,buf,len,maskptr,valptr); in pvr2_ctrl_custom_sym_to_value()
455 int pvr2_ctrl_sym_to_value(struct pvr2_ctrl *cptr, in pvr2_ctrl_sym_to_value() argument
475 LOCK_TAKE(cptr->hdw->big_lock); do { in pvr2_ctrl_sym_to_value()
476 if (cptr->info->type == pvr2_ctl_int) { in pvr2_ctrl_sym_to_value()
479 ret = pvr2_ctrl_range_check(cptr,*valptr); in pvr2_ctrl_sym_to_value()
482 } else if (cptr->info->type == pvr2_ctl_bool) { in pvr2_ctrl_sym_to_value()
491 } else if (cptr->info->type == pvr2_ctl_enum) { in pvr2_ctrl_sym_to_value()
494 cptr->info->def.type_enum.value_names, in pvr2_ctrl_sym_to_value()
495 cptr->info->def.type_enum.count); in pvr2_ctrl_sym_to_value()
497 ret = pvr2_ctrl_range_check(cptr,*valptr); in pvr2_ctrl_sym_to_value()
500 } else if (cptr->info->type == pvr2_ctl_bitmask) { in pvr2_ctrl_sym_to_value()
503 cptr->info->def.type_bitmask.bit_names, in pvr2_ctrl_sym_to_value()
504 cptr->info->def.type_bitmask.valid_bits); in pvr2_ctrl_sym_to_value()
506 } while(0); LOCK_GIVE(cptr->hdw->big_lock); in pvr2_ctrl_sym_to_value()
512 int pvr2_ctrl_value_to_sym_internal(struct pvr2_ctrl *cptr, in pvr2_ctrl_value_to_sym_internal() argument
520 if (cptr->info->type == pvr2_ctl_int) { in pvr2_ctrl_value_to_sym_internal()
523 } else if (cptr->info->type == pvr2_ctl_bool) { in pvr2_ctrl_value_to_sym_internal()
526 } else if (cptr->info->type == pvr2_ctl_enum) { in pvr2_ctrl_value_to_sym_internal()
528 names = cptr->info->def.type_enum.value_names; in pvr2_ctrl_value_to_sym_internal()
530 (val < cptr->info->def.type_enum.count)) { in pvr2_ctrl_value_to_sym_internal()
540 } else if (cptr->info->type == pvr2_ctl_bitmask) { in pvr2_ctrl_value_to_sym_internal()
542 val & mask & cptr->info->def.type_bitmask.valid_bits, in pvr2_ctrl_value_to_sym_internal()
544 cptr->info->def.type_bitmask.bit_names, in pvr2_ctrl_value_to_sym_internal()
552 int pvr2_ctrl_value_to_sym(struct pvr2_ctrl *cptr, in pvr2_ctrl_value_to_sym() argument
558 LOCK_TAKE(cptr->hdw->big_lock); do { in pvr2_ctrl_value_to_sym()
559 ret = pvr2_ctrl_value_to_sym_internal(cptr,mask,val, in pvr2_ctrl_value_to_sym()
561 } while(0); LOCK_GIVE(cptr->hdw->big_lock); in pvr2_ctrl_value_to_sym()