Lines Matching refs:cptr

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