diff options
author | Jonathan Corbet <corbet@lwn.net> | 2008-07-14 17:29:34 -0400 |
---|---|---|
committer | Jonathan Corbet <corbet@lwn.net> | 2008-07-14 17:29:34 -0400 |
commit | 2fceef397f9880b212a74c418290ce69e7ac00eb (patch) | |
tree | d9cc09ab992825ef7fede4a688103503e3caf655 /drivers/media/video/videodev.c | |
parent | feae1ef116ed381625d3731c5ae4f4ebcb3fa302 (diff) | |
parent | bce7f793daec3e65ec5c5705d2457b81fe7b5725 (diff) |
Merge commit 'v2.6.26' into bkl-removal
Diffstat (limited to 'drivers/media/video/videodev.c')
-rw-r--r-- | drivers/media/video/videodev.c | 245 |
1 files changed, 68 insertions, 177 deletions
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c index e5679c28163f..7649860a388d 100644 --- a/drivers/media/video/videodev.c +++ b/drivers/media/video/videodev.c | |||
@@ -52,12 +52,51 @@ | |||
52 | #define VIDEO_NUM_DEVICES 256 | 52 | #define VIDEO_NUM_DEVICES 256 |
53 | #define VIDEO_NAME "video4linux" | 53 | #define VIDEO_NAME "video4linux" |
54 | 54 | ||
55 | struct std_descr { | ||
56 | v4l2_std_id std; | ||
57 | const char *descr; | ||
58 | }; | ||
59 | |||
60 | static const struct std_descr standards[] = { | ||
61 | { V4L2_STD_NTSC, "NTSC" }, | ||
62 | { V4L2_STD_NTSC_M, "NTSC-M" }, | ||
63 | { V4L2_STD_NTSC_M_JP, "NTSC-M-JP" }, | ||
64 | { V4L2_STD_NTSC_M_KR, "NTSC-M-KR" }, | ||
65 | { V4L2_STD_NTSC_443, "NTSC-443" }, | ||
66 | { V4L2_STD_PAL, "PAL" }, | ||
67 | { V4L2_STD_PAL_BG, "PAL-BG" }, | ||
68 | { V4L2_STD_PAL_B, "PAL-B" }, | ||
69 | { V4L2_STD_PAL_B1, "PAL-B1" }, | ||
70 | { V4L2_STD_PAL_G, "PAL-G" }, | ||
71 | { V4L2_STD_PAL_H, "PAL-H" }, | ||
72 | { V4L2_STD_PAL_I, "PAL-I" }, | ||
73 | { V4L2_STD_PAL_DK, "PAL-DK" }, | ||
74 | { V4L2_STD_PAL_D, "PAL-D" }, | ||
75 | { V4L2_STD_PAL_D1, "PAL-D1" }, | ||
76 | { V4L2_STD_PAL_K, "PAL-K" }, | ||
77 | { V4L2_STD_PAL_M, "PAL-M" }, | ||
78 | { V4L2_STD_PAL_N, "PAL-N" }, | ||
79 | { V4L2_STD_PAL_Nc, "PAL-Nc" }, | ||
80 | { V4L2_STD_PAL_60, "PAL-60" }, | ||
81 | { V4L2_STD_SECAM, "SECAM" }, | ||
82 | { V4L2_STD_SECAM_B, "SECAM-B" }, | ||
83 | { V4L2_STD_SECAM_G, "SECAM-G" }, | ||
84 | { V4L2_STD_SECAM_H, "SECAM-H" }, | ||
85 | { V4L2_STD_SECAM_DK, "SECAM-DK" }, | ||
86 | { V4L2_STD_SECAM_D, "SECAM-D" }, | ||
87 | { V4L2_STD_SECAM_K, "SECAM-K" }, | ||
88 | { V4L2_STD_SECAM_K1, "SECAM-K1" }, | ||
89 | { V4L2_STD_SECAM_L, "SECAM-L" }, | ||
90 | { V4L2_STD_SECAM_LC, "SECAM-Lc" }, | ||
91 | { 0, "Unknown" } | ||
92 | }; | ||
93 | |||
55 | /* video4linux standard ID conversion to standard name | 94 | /* video4linux standard ID conversion to standard name |
56 | */ | 95 | */ |
57 | char *v4l2_norm_to_name(v4l2_std_id id) | 96 | const char *v4l2_norm_to_name(v4l2_std_id id) |
58 | { | 97 | { |
59 | char *name; | ||
60 | u32 myid = id; | 98 | u32 myid = id; |
99 | int i; | ||
61 | 100 | ||
62 | /* HACK: ppc32 architecture doesn't have __ucmpdi2 function to handle | 101 | /* HACK: ppc32 architecture doesn't have __ucmpdi2 function to handle |
63 | 64 bit comparations. So, on that architecture, with some gcc | 102 | 64 bit comparations. So, on that architecture, with some gcc |
@@ -65,110 +104,17 @@ char *v4l2_norm_to_name(v4l2_std_id id) | |||
65 | */ | 104 | */ |
66 | BUG_ON(myid != id); | 105 | BUG_ON(myid != id); |
67 | 106 | ||
68 | switch (myid) { | 107 | for (i = 0; standards[i].std; i++) |
69 | case V4L2_STD_PAL: | 108 | if (myid == standards[i].std) |
70 | name = "PAL"; | 109 | break; |
71 | break; | 110 | return standards[i].descr; |
72 | case V4L2_STD_PAL_BG: | ||
73 | name = "PAL-BG"; | ||
74 | break; | ||
75 | case V4L2_STD_PAL_DK: | ||
76 | name = "PAL-DK"; | ||
77 | break; | ||
78 | case V4L2_STD_PAL_B: | ||
79 | name = "PAL-B"; | ||
80 | break; | ||
81 | case V4L2_STD_PAL_B1: | ||
82 | name = "PAL-B1"; | ||
83 | break; | ||
84 | case V4L2_STD_PAL_G: | ||
85 | name = "PAL-G"; | ||
86 | break; | ||
87 | case V4L2_STD_PAL_H: | ||
88 | name = "PAL-H"; | ||
89 | break; | ||
90 | case V4L2_STD_PAL_I: | ||
91 | name = "PAL-I"; | ||
92 | break; | ||
93 | case V4L2_STD_PAL_D: | ||
94 | name = "PAL-D"; | ||
95 | break; | ||
96 | case V4L2_STD_PAL_D1: | ||
97 | name = "PAL-D1"; | ||
98 | break; | ||
99 | case V4L2_STD_PAL_K: | ||
100 | name = "PAL-K"; | ||
101 | break; | ||
102 | case V4L2_STD_PAL_M: | ||
103 | name = "PAL-M"; | ||
104 | break; | ||
105 | case V4L2_STD_PAL_N: | ||
106 | name = "PAL-N"; | ||
107 | break; | ||
108 | case V4L2_STD_PAL_Nc: | ||
109 | name = "PAL-Nc"; | ||
110 | break; | ||
111 | case V4L2_STD_PAL_60: | ||
112 | name = "PAL-60"; | ||
113 | break; | ||
114 | case V4L2_STD_NTSC: | ||
115 | name = "NTSC"; | ||
116 | break; | ||
117 | case V4L2_STD_NTSC_M: | ||
118 | name = "NTSC-M"; | ||
119 | break; | ||
120 | case V4L2_STD_NTSC_M_JP: | ||
121 | name = "NTSC-M-JP"; | ||
122 | break; | ||
123 | case V4L2_STD_NTSC_443: | ||
124 | name = "NTSC-443"; | ||
125 | break; | ||
126 | case V4L2_STD_NTSC_M_KR: | ||
127 | name = "NTSC-M-KR"; | ||
128 | break; | ||
129 | case V4L2_STD_SECAM: | ||
130 | name = "SECAM"; | ||
131 | break; | ||
132 | case V4L2_STD_SECAM_DK: | ||
133 | name = "SECAM-DK"; | ||
134 | break; | ||
135 | case V4L2_STD_SECAM_B: | ||
136 | name = "SECAM-B"; | ||
137 | break; | ||
138 | case V4L2_STD_SECAM_D: | ||
139 | name = "SECAM-D"; | ||
140 | break; | ||
141 | case V4L2_STD_SECAM_G: | ||
142 | name = "SECAM-G"; | ||
143 | break; | ||
144 | case V4L2_STD_SECAM_H: | ||
145 | name = "SECAM-H"; | ||
146 | break; | ||
147 | case V4L2_STD_SECAM_K: | ||
148 | name = "SECAM-K"; | ||
149 | break; | ||
150 | case V4L2_STD_SECAM_K1: | ||
151 | name = "SECAM-K1"; | ||
152 | break; | ||
153 | case V4L2_STD_SECAM_L: | ||
154 | name = "SECAM-L"; | ||
155 | break; | ||
156 | case V4L2_STD_SECAM_LC: | ||
157 | name = "SECAM-LC"; | ||
158 | break; | ||
159 | default: | ||
160 | name = "Unknown"; | ||
161 | break; | ||
162 | } | ||
163 | |||
164 | return name; | ||
165 | } | 111 | } |
166 | EXPORT_SYMBOL(v4l2_norm_to_name); | 112 | EXPORT_SYMBOL(v4l2_norm_to_name); |
167 | 113 | ||
168 | /* Fill in the fields of a v4l2_standard structure according to the | 114 | /* Fill in the fields of a v4l2_standard structure according to the |
169 | 'id' and 'transmission' parameters. Returns negative on error. */ | 115 | 'id' and 'transmission' parameters. Returns negative on error. */ |
170 | int v4l2_video_std_construct(struct v4l2_standard *vs, | 116 | int v4l2_video_std_construct(struct v4l2_standard *vs, |
171 | int id, char *name) | 117 | int id, const char *name) |
172 | { | 118 | { |
173 | u32 index = vs->index; | 119 | u32 index = vs->index; |
174 | 120 | ||
@@ -1222,95 +1168,40 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, | |||
1222 | case VIDIOC_ENUMSTD: | 1168 | case VIDIOC_ENUMSTD: |
1223 | { | 1169 | { |
1224 | struct v4l2_standard *p = arg; | 1170 | struct v4l2_standard *p = arg; |
1225 | v4l2_std_id id = vfd->tvnorms,curr_id=0; | 1171 | v4l2_std_id id = vfd->tvnorms, curr_id = 0; |
1226 | unsigned int index = p->index,i; | 1172 | unsigned int index = p->index, i, j = 0; |
1227 | 1173 | const char *descr = ""; | |
1228 | if (index<0) { | 1174 | |
1229 | ret=-EINVAL; | 1175 | /* Return norm array in a canonical way */ |
1230 | break; | 1176 | for (i = 0; i <= index && id; i++) { |
1231 | } | 1177 | /* last std value in the standards array is 0, so this |
1232 | 1178 | while always ends there since (id & 0) == 0. */ | |
1233 | /* Return norm array on a canonical way */ | 1179 | while ((id & standards[j].std) != standards[j].std) |
1234 | for (i=0;i<= index && id; i++) { | 1180 | j++; |
1235 | if ( (id & V4L2_STD_PAL) == V4L2_STD_PAL) { | 1181 | curr_id = standards[j].std; |
1236 | curr_id = V4L2_STD_PAL; | 1182 | descr = standards[j].descr; |
1237 | } else if ( (id & V4L2_STD_PAL_BG) == V4L2_STD_PAL_BG) { | 1183 | j++; |
1238 | curr_id = V4L2_STD_PAL_BG; | 1184 | if (curr_id == 0) |
1239 | } else if ( (id & V4L2_STD_PAL_DK) == V4L2_STD_PAL_DK) { | ||
1240 | curr_id = V4L2_STD_PAL_DK; | ||
1241 | } else if ( (id & V4L2_STD_PAL_B) == V4L2_STD_PAL_B) { | ||
1242 | curr_id = V4L2_STD_PAL_B; | ||
1243 | } else if ( (id & V4L2_STD_PAL_B1) == V4L2_STD_PAL_B1) { | ||
1244 | curr_id = V4L2_STD_PAL_B1; | ||
1245 | } else if ( (id & V4L2_STD_PAL_G) == V4L2_STD_PAL_G) { | ||
1246 | curr_id = V4L2_STD_PAL_G; | ||
1247 | } else if ( (id & V4L2_STD_PAL_H) == V4L2_STD_PAL_H) { | ||
1248 | curr_id = V4L2_STD_PAL_H; | ||
1249 | } else if ( (id & V4L2_STD_PAL_I) == V4L2_STD_PAL_I) { | ||
1250 | curr_id = V4L2_STD_PAL_I; | ||
1251 | } else if ( (id & V4L2_STD_PAL_D) == V4L2_STD_PAL_D) { | ||
1252 | curr_id = V4L2_STD_PAL_D; | ||
1253 | } else if ( (id & V4L2_STD_PAL_D1) == V4L2_STD_PAL_D1) { | ||
1254 | curr_id = V4L2_STD_PAL_D1; | ||
1255 | } else if ( (id & V4L2_STD_PAL_K) == V4L2_STD_PAL_K) { | ||
1256 | curr_id = V4L2_STD_PAL_K; | ||
1257 | } else if ( (id & V4L2_STD_PAL_M) == V4L2_STD_PAL_M) { | ||
1258 | curr_id = V4L2_STD_PAL_M; | ||
1259 | } else if ( (id & V4L2_STD_PAL_N) == V4L2_STD_PAL_N) { | ||
1260 | curr_id = V4L2_STD_PAL_N; | ||
1261 | } else if ( (id & V4L2_STD_PAL_Nc) == V4L2_STD_PAL_Nc) { | ||
1262 | curr_id = V4L2_STD_PAL_Nc; | ||
1263 | } else if ( (id & V4L2_STD_PAL_60) == V4L2_STD_PAL_60) { | ||
1264 | curr_id = V4L2_STD_PAL_60; | ||
1265 | } else if ( (id & V4L2_STD_NTSC) == V4L2_STD_NTSC) { | ||
1266 | curr_id = V4L2_STD_NTSC; | ||
1267 | } else if ( (id & V4L2_STD_NTSC_M) == V4L2_STD_NTSC_M) { | ||
1268 | curr_id = V4L2_STD_NTSC_M; | ||
1269 | } else if ( (id & V4L2_STD_NTSC_M_JP) == V4L2_STD_NTSC_M_JP) { | ||
1270 | curr_id = V4L2_STD_NTSC_M_JP; | ||
1271 | } else if ( (id & V4L2_STD_NTSC_443) == V4L2_STD_NTSC_443) { | ||
1272 | curr_id = V4L2_STD_NTSC_443; | ||
1273 | } else if ( (id & V4L2_STD_NTSC_M_KR) == V4L2_STD_NTSC_M_KR) { | ||
1274 | curr_id = V4L2_STD_NTSC_M_KR; | ||
1275 | } else if ( (id & V4L2_STD_SECAM) == V4L2_STD_SECAM) { | ||
1276 | curr_id = V4L2_STD_SECAM; | ||
1277 | } else if ( (id & V4L2_STD_SECAM_DK) == V4L2_STD_SECAM_DK) { | ||
1278 | curr_id = V4L2_STD_SECAM_DK; | ||
1279 | } else if ( (id & V4L2_STD_SECAM_B) == V4L2_STD_SECAM_B) { | ||
1280 | curr_id = V4L2_STD_SECAM_B; | ||
1281 | } else if ( (id & V4L2_STD_SECAM_D) == V4L2_STD_SECAM_D) { | ||
1282 | curr_id = V4L2_STD_SECAM_D; | ||
1283 | } else if ( (id & V4L2_STD_SECAM_G) == V4L2_STD_SECAM_G) { | ||
1284 | curr_id = V4L2_STD_SECAM_G; | ||
1285 | } else if ( (id & V4L2_STD_SECAM_H) == V4L2_STD_SECAM_H) { | ||
1286 | curr_id = V4L2_STD_SECAM_H; | ||
1287 | } else if ( (id & V4L2_STD_SECAM_K) == V4L2_STD_SECAM_K) { | ||
1288 | curr_id = V4L2_STD_SECAM_K; | ||
1289 | } else if ( (id & V4L2_STD_SECAM_K1) == V4L2_STD_SECAM_K1) { | ||
1290 | curr_id = V4L2_STD_SECAM_K1; | ||
1291 | } else if ( (id & V4L2_STD_SECAM_L) == V4L2_STD_SECAM_L) { | ||
1292 | curr_id = V4L2_STD_SECAM_L; | ||
1293 | } else if ( (id & V4L2_STD_SECAM_LC) == V4L2_STD_SECAM_LC) { | ||
1294 | curr_id = V4L2_STD_SECAM_LC; | ||
1295 | } else { | ||
1296 | break; | 1185 | break; |
1297 | } | 1186 | if (curr_id != V4L2_STD_PAL && |
1298 | id &= ~curr_id; | 1187 | curr_id != V4L2_STD_SECAM && |
1188 | curr_id != V4L2_STD_NTSC) | ||
1189 | id &= ~curr_id; | ||
1299 | } | 1190 | } |
1300 | if (i<=index) | 1191 | if (i <= index) |
1301 | return -EINVAL; | 1192 | return -EINVAL; |
1302 | 1193 | ||
1303 | v4l2_video_std_construct(p, curr_id,v4l2_norm_to_name(curr_id)); | 1194 | v4l2_video_std_construct(p, curr_id, descr); |
1304 | p->index = index; | 1195 | p->index = index; |
1305 | 1196 | ||
1306 | dbgarg (cmd, "index=%d, id=%Ld, name=%s, fps=%d/%d, " | 1197 | dbgarg(cmd, "index=%d, id=%Ld, name=%s, fps=%d/%d, " |
1307 | "framelines=%d\n", p->index, | 1198 | "framelines=%d\n", p->index, |
1308 | (unsigned long long)p->id, p->name, | 1199 | (unsigned long long)p->id, p->name, |
1309 | p->frameperiod.numerator, | 1200 | p->frameperiod.numerator, |
1310 | p->frameperiod.denominator, | 1201 | p->frameperiod.denominator, |
1311 | p->framelines); | 1202 | p->framelines); |
1312 | 1203 | ||
1313 | ret=0; | 1204 | ret = 0; |
1314 | break; | 1205 | break; |
1315 | } | 1206 | } |
1316 | case VIDIOC_G_STD: | 1207 | case VIDIOC_G_STD: |