V4L/DVB (4239): Handle boolean controls in pvrusb2
[linux-2.6] / drivers / media / video / pvrusb2 / pvrusb2-ctrl.h
1 /*
2  *
3  *  $Id$
4  *
5  *  Copyright (C) 2005 Mike Isely <isely@pobox.com>
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2 of the License
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21 #ifndef __PVRUSB2_CTRL_H
22 #define __PVRUSB2_CTRL_H
23
24 struct pvr2_ctrl;
25
26 enum pvr2_ctl_type {
27         pvr2_ctl_int = 0,
28         pvr2_ctl_enum = 1,
29         pvr2_ctl_bitmask = 2,
30         pvr2_ctl_bool = 3,
31 };
32
33
34 /* Set the given control. */
35 int pvr2_ctrl_set_value(struct pvr2_ctrl *,int val);
36
37 /* Set/clear specific bits of the given control. */
38 int pvr2_ctrl_set_mask_value(struct pvr2_ctrl *,int mask,int val);
39
40 /* Get the current value of the given control. */
41 int pvr2_ctrl_get_value(struct pvr2_ctrl *,int *valptr);
42
43 /* Retrieve control's type */
44 enum pvr2_ctl_type pvr2_ctrl_get_type(struct pvr2_ctrl *);
45
46 /* Retrieve control's maximum value (int type) */
47 int pvr2_ctrl_get_max(struct pvr2_ctrl *);
48
49 /* Retrieve control's minimum value (int type) */
50 int pvr2_ctrl_get_min(struct pvr2_ctrl *);
51
52 /* Retrieve control's default value (any type) */
53 int pvr2_ctrl_get_def(struct pvr2_ctrl *);
54
55 /* Retrieve control's enumeration count (enum only) */
56 int pvr2_ctrl_get_cnt(struct pvr2_ctrl *);
57
58 /* Retrieve control's valid mask bits (bit mask only) */
59 int pvr2_ctrl_get_mask(struct pvr2_ctrl *);
60
61 /* Retrieve the control's name */
62 const char *pvr2_ctrl_get_name(struct pvr2_ctrl *);
63
64 /* Retrieve the control's desc */
65 const char *pvr2_ctrl_get_desc(struct pvr2_ctrl *);
66
67 /* Retrieve a control enumeration or bit mask value */
68 int pvr2_ctrl_get_valname(struct pvr2_ctrl *,int,char *,unsigned int,
69                           unsigned int *);
70
71 /* Return true if control is writable */
72 int pvr2_ctrl_is_writable(struct pvr2_ctrl *);
73
74 /* Return true if control has custom symbolic representation */
75 int pvr2_ctrl_has_custom_symbols(struct pvr2_ctrl *);
76
77 /* Convert a given mask/val to a custom symbolic value */
78 int pvr2_ctrl_custom_value_to_sym(struct pvr2_ctrl *,
79                                   int mask,int val,
80                                   char *buf,unsigned int maxlen,
81                                   unsigned int *len);
82
83 /* Convert a symbolic value to a mask/value pair */
84 int pvr2_ctrl_custom_sym_to_value(struct pvr2_ctrl *,
85                                   const char *buf,unsigned int len,
86                                   int *maskptr,int *valptr);
87
88 /* Convert a given mask/val to a symbolic value */
89 int pvr2_ctrl_value_to_sym(struct pvr2_ctrl *,
90                            int mask,int val,
91                            char *buf,unsigned int maxlen,
92                            unsigned int *len);
93
94 /* Convert a symbolic value to a mask/value pair */
95 int pvr2_ctrl_sym_to_value(struct pvr2_ctrl *,
96                            const char *buf,unsigned int len,
97                            int *maskptr,int *valptr);
98
99 /* Convert a given mask/val to a symbolic value - must already be
100    inside of critical region. */
101 int pvr2_ctrl_value_to_sym_internal(struct pvr2_ctrl *,
102                            int mask,int val,
103                            char *buf,unsigned int maxlen,
104                            unsigned int *len);
105
106 #endif /* __PVRUSB2_CTRL_H */
107
108 /*
109   Stuff for Emacs to see, in order to encourage consistent editing style:
110   *** Local Variables: ***
111   *** mode: c ***
112   *** fill-column: 75 ***
113   *** tab-width: 8 ***
114   *** c-basic-offset: 8 ***
115   *** End: ***
116   */