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