diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2009-11-22 21:02:02 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-12-15 21:18:23 -0500 |
commit | 7eca61eb6a57a3aae10e77d9306cda0b8c23cdab (patch) | |
tree | 4d2e5fc8315e6a55d678cbda36d48c65109d6304 | |
parent | 6e8fdbd023ef6a05da444baacfea75fdf97bdc50 (diff) |
V4L/DVB (13590): cpia: convert it to use proc_fops
X-Patchwork-Id: 62090
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/video/cpia.c | 212 |
1 files changed, 105 insertions, 107 deletions
diff --git a/drivers/media/video/cpia.c b/drivers/media/video/cpia.c index d6f2653afb6c..551ddf216a4b 100644 --- a/drivers/media/video/cpia.c +++ b/drivers/media/video/cpia.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/fs.h> | 32 | #include <linux/fs.h> |
33 | #include <linux/vmalloc.h> | 33 | #include <linux/vmalloc.h> |
34 | #include <linux/sched.h> | 34 | #include <linux/sched.h> |
35 | #include <linux/seq_file.h> | ||
35 | #include <linux/slab.h> | 36 | #include <linux/slab.h> |
36 | #include <linux/proc_fs.h> | 37 | #include <linux/proc_fs.h> |
37 | #include <linux/ctype.h> | 38 | #include <linux/ctype.h> |
@@ -244,72 +245,67 @@ static void rvfree(void *mem, unsigned long size) | |||
244 | #ifdef CONFIG_PROC_FS | 245 | #ifdef CONFIG_PROC_FS |
245 | static struct proc_dir_entry *cpia_proc_root=NULL; | 246 | static struct proc_dir_entry *cpia_proc_root=NULL; |
246 | 247 | ||
247 | static int cpia_read_proc(char *page, char **start, off_t off, | 248 | static int cpia_proc_show(struct seq_file *m, void *v) |
248 | int count, int *eof, void *data) | ||
249 | { | 249 | { |
250 | char *out = page; | 250 | struct cam_data *cam = m->private; |
251 | int len, tmp; | 251 | int tmp; |
252 | struct cam_data *cam = data; | ||
253 | char tmpstr[29]; | 252 | char tmpstr[29]; |
254 | 253 | ||
255 | /* IMPORTANT: This output MUST be kept under PAGE_SIZE | 254 | seq_printf(m, "read-only\n-----------------------\n"); |
256 | * or we need to get more sophisticated. */ | 255 | seq_printf(m, "V4L Driver version: %d.%d.%d\n", |
257 | |||
258 | out += sprintf(out, "read-only\n-----------------------\n"); | ||
259 | out += sprintf(out, "V4L Driver version: %d.%d.%d\n", | ||
260 | CPIA_MAJ_VER, CPIA_MIN_VER, CPIA_PATCH_VER); | 256 | CPIA_MAJ_VER, CPIA_MIN_VER, CPIA_PATCH_VER); |
261 | out += sprintf(out, "CPIA Version: %d.%02d (%d.%d)\n", | 257 | seq_printf(m, "CPIA Version: %d.%02d (%d.%d)\n", |
262 | cam->params.version.firmwareVersion, | 258 | cam->params.version.firmwareVersion, |
263 | cam->params.version.firmwareRevision, | 259 | cam->params.version.firmwareRevision, |
264 | cam->params.version.vcVersion, | 260 | cam->params.version.vcVersion, |
265 | cam->params.version.vcRevision); | 261 | cam->params.version.vcRevision); |
266 | out += sprintf(out, "CPIA PnP-ID: %04x:%04x:%04x\n", | 262 | seq_printf(m, "CPIA PnP-ID: %04x:%04x:%04x\n", |
267 | cam->params.pnpID.vendor, cam->params.pnpID.product, | 263 | cam->params.pnpID.vendor, cam->params.pnpID.product, |
268 | cam->params.pnpID.deviceRevision); | 264 | cam->params.pnpID.deviceRevision); |
269 | out += sprintf(out, "VP-Version: %d.%d %04x\n", | 265 | seq_printf(m, "VP-Version: %d.%d %04x\n", |
270 | cam->params.vpVersion.vpVersion, | 266 | cam->params.vpVersion.vpVersion, |
271 | cam->params.vpVersion.vpRevision, | 267 | cam->params.vpVersion.vpRevision, |
272 | cam->params.vpVersion.cameraHeadID); | 268 | cam->params.vpVersion.cameraHeadID); |
273 | 269 | ||
274 | out += sprintf(out, "system_state: %#04x\n", | 270 | seq_printf(m, "system_state: %#04x\n", |
275 | cam->params.status.systemState); | 271 | cam->params.status.systemState); |
276 | out += sprintf(out, "grab_state: %#04x\n", | 272 | seq_printf(m, "grab_state: %#04x\n", |
277 | cam->params.status.grabState); | 273 | cam->params.status.grabState); |
278 | out += sprintf(out, "stream_state: %#04x\n", | 274 | seq_printf(m, "stream_state: %#04x\n", |
279 | cam->params.status.streamState); | 275 | cam->params.status.streamState); |
280 | out += sprintf(out, "fatal_error: %#04x\n", | 276 | seq_printf(m, "fatal_error: %#04x\n", |
281 | cam->params.status.fatalError); | 277 | cam->params.status.fatalError); |
282 | out += sprintf(out, "cmd_error: %#04x\n", | 278 | seq_printf(m, "cmd_error: %#04x\n", |
283 | cam->params.status.cmdError); | 279 | cam->params.status.cmdError); |
284 | out += sprintf(out, "debug_flags: %#04x\n", | 280 | seq_printf(m, "debug_flags: %#04x\n", |
285 | cam->params.status.debugFlags); | 281 | cam->params.status.debugFlags); |
286 | out += sprintf(out, "vp_status: %#04x\n", | 282 | seq_printf(m, "vp_status: %#04x\n", |
287 | cam->params.status.vpStatus); | 283 | cam->params.status.vpStatus); |
288 | out += sprintf(out, "error_code: %#04x\n", | 284 | seq_printf(m, "error_code: %#04x\n", |
289 | cam->params.status.errorCode); | 285 | cam->params.status.errorCode); |
290 | /* QX3 specific entries */ | 286 | /* QX3 specific entries */ |
291 | if (cam->params.qx3.qx3_detected) { | 287 | if (cam->params.qx3.qx3_detected) { |
292 | out += sprintf(out, "button: %4d\n", | 288 | seq_printf(m, "button: %4d\n", |
293 | cam->params.qx3.button); | 289 | cam->params.qx3.button); |
294 | out += sprintf(out, "cradled: %4d\n", | 290 | seq_printf(m, "cradled: %4d\n", |
295 | cam->params.qx3.cradled); | 291 | cam->params.qx3.cradled); |
296 | } | 292 | } |
297 | out += sprintf(out, "video_size: %s\n", | 293 | seq_printf(m, "video_size: %s\n", |
298 | cam->params.format.videoSize == VIDEOSIZE_CIF ? | 294 | cam->params.format.videoSize == VIDEOSIZE_CIF ? |
299 | "CIF " : "QCIF"); | 295 | "CIF " : "QCIF"); |
300 | out += sprintf(out, "roi: (%3d, %3d) to (%3d, %3d)\n", | 296 | seq_printf(m, "roi: (%3d, %3d) to (%3d, %3d)\n", |
301 | cam->params.roi.colStart*8, | 297 | cam->params.roi.colStart*8, |
302 | cam->params.roi.rowStart*4, | 298 | cam->params.roi.rowStart*4, |
303 | cam->params.roi.colEnd*8, | 299 | cam->params.roi.colEnd*8, |
304 | cam->params.roi.rowEnd*4); | 300 | cam->params.roi.rowEnd*4); |
305 | out += sprintf(out, "actual_fps: %3d\n", cam->fps); | 301 | seq_printf(m, "actual_fps: %3d\n", cam->fps); |
306 | out += sprintf(out, "transfer_rate: %4dkB/s\n", | 302 | seq_printf(m, "transfer_rate: %4dkB/s\n", |
307 | cam->transfer_rate); | 303 | cam->transfer_rate); |
308 | 304 | ||
309 | out += sprintf(out, "\nread-write\n"); | 305 | seq_printf(m, "\nread-write\n"); |
310 | out += sprintf(out, "----------------------- current min" | 306 | seq_printf(m, "----------------------- current min" |
311 | " max default comment\n"); | 307 | " max default comment\n"); |
312 | out += sprintf(out, "brightness: %8d %8d %8d %8d\n", | 308 | seq_printf(m, "brightness: %8d %8d %8d %8d\n", |
313 | cam->params.colourParams.brightness, 0, 100, 50); | 309 | cam->params.colourParams.brightness, 0, 100, 50); |
314 | if (cam->params.version.firmwareVersion == 1 && | 310 | if (cam->params.version.firmwareVersion == 1 && |
315 | cam->params.version.firmwareRevision == 2) | 311 | cam->params.version.firmwareRevision == 2) |
@@ -318,26 +314,26 @@ static int cpia_read_proc(char *page, char **start, off_t off, | |||
318 | else | 314 | else |
319 | tmp = 96; | 315 | tmp = 96; |
320 | 316 | ||
321 | out += sprintf(out, "contrast: %8d %8d %8d %8d" | 317 | seq_printf(m, "contrast: %8d %8d %8d %8d" |
322 | " steps of 8\n", | 318 | " steps of 8\n", |
323 | cam->params.colourParams.contrast, 0, tmp, 48); | 319 | cam->params.colourParams.contrast, 0, tmp, 48); |
324 | out += sprintf(out, "saturation: %8d %8d %8d %8d\n", | 320 | seq_printf(m, "saturation: %8d %8d %8d %8d\n", |
325 | cam->params.colourParams.saturation, 0, 100, 50); | 321 | cam->params.colourParams.saturation, 0, 100, 50); |
326 | tmp = (25000+5000*cam->params.sensorFps.baserate)/ | 322 | tmp = (25000+5000*cam->params.sensorFps.baserate)/ |
327 | (1<<cam->params.sensorFps.divisor); | 323 | (1<<cam->params.sensorFps.divisor); |
328 | out += sprintf(out, "sensor_fps: %4d.%03d %8d %8d %8d\n", | 324 | seq_printf(m, "sensor_fps: %4d.%03d %8d %8d %8d\n", |
329 | tmp/1000, tmp%1000, 3, 30, 15); | 325 | tmp/1000, tmp%1000, 3, 30, 15); |
330 | out += sprintf(out, "stream_start_line: %8d %8d %8d %8d\n", | 326 | seq_printf(m, "stream_start_line: %8d %8d %8d %8d\n", |
331 | 2*cam->params.streamStartLine, 0, | 327 | 2*cam->params.streamStartLine, 0, |
332 | cam->params.format.videoSize == VIDEOSIZE_CIF ? 288:144, | 328 | cam->params.format.videoSize == VIDEOSIZE_CIF ? 288:144, |
333 | cam->params.format.videoSize == VIDEOSIZE_CIF ? 240:120); | 329 | cam->params.format.videoSize == VIDEOSIZE_CIF ? 240:120); |
334 | out += sprintf(out, "sub_sample: %8s %8s %8s %8s\n", | 330 | seq_printf(m, "sub_sample: %8s %8s %8s %8s\n", |
335 | cam->params.format.subSample == SUBSAMPLE_420 ? | 331 | cam->params.format.subSample == SUBSAMPLE_420 ? |
336 | "420" : "422", "420", "422", "422"); | 332 | "420" : "422", "420", "422", "422"); |
337 | out += sprintf(out, "yuv_order: %8s %8s %8s %8s\n", | 333 | seq_printf(m, "yuv_order: %8s %8s %8s %8s\n", |
338 | cam->params.format.yuvOrder == YUVORDER_YUYV ? | 334 | cam->params.format.yuvOrder == YUVORDER_YUYV ? |
339 | "YUYV" : "UYVY", "YUYV" , "UYVY", "YUYV"); | 335 | "YUYV" : "UYVY", "YUYV" , "UYVY", "YUYV"); |
340 | out += sprintf(out, "ecp_timing: %8s %8s %8s %8s\n", | 336 | seq_printf(m, "ecp_timing: %8s %8s %8s %8s\n", |
341 | cam->params.ecpTiming ? "slow" : "normal", "slow", | 337 | cam->params.ecpTiming ? "slow" : "normal", "slow", |
342 | "normal", "normal"); | 338 | "normal", "normal"); |
343 | 339 | ||
@@ -346,13 +342,13 @@ static int cpia_read_proc(char *page, char **start, off_t off, | |||
346 | } else { | 342 | } else { |
347 | sprintf(tmpstr, "manual"); | 343 | sprintf(tmpstr, "manual"); |
348 | } | 344 | } |
349 | out += sprintf(out, "color_balance_mode: %8s %8s %8s" | 345 | seq_printf(m, "color_balance_mode: %8s %8s %8s" |
350 | " %8s\n", tmpstr, "manual", "auto", "auto"); | 346 | " %8s\n", tmpstr, "manual", "auto", "auto"); |
351 | out += sprintf(out, "red_gain: %8d %8d %8d %8d\n", | 347 | seq_printf(m, "red_gain: %8d %8d %8d %8d\n", |
352 | cam->params.colourBalance.redGain, 0, 212, 32); | 348 | cam->params.colourBalance.redGain, 0, 212, 32); |
353 | out += sprintf(out, "green_gain: %8d %8d %8d %8d\n", | 349 | seq_printf(m, "green_gain: %8d %8d %8d %8d\n", |
354 | cam->params.colourBalance.greenGain, 0, 212, 6); | 350 | cam->params.colourBalance.greenGain, 0, 212, 6); |
355 | out += sprintf(out, "blue_gain: %8d %8d %8d %8d\n", | 351 | seq_printf(m, "blue_gain: %8d %8d %8d %8d\n", |
356 | cam->params.colourBalance.blueGain, 0, 212, 92); | 352 | cam->params.colourBalance.blueGain, 0, 212, 92); |
357 | 353 | ||
358 | if (cam->params.version.firmwareVersion == 1 && | 354 | if (cam->params.version.firmwareVersion == 1 && |
@@ -363,10 +359,10 @@ static int cpia_read_proc(char *page, char **start, off_t off, | |||
363 | sprintf(tmpstr, "%8d %8d %8d", 1, 8, 2); | 359 | sprintf(tmpstr, "%8d %8d %8d", 1, 8, 2); |
364 | 360 | ||
365 | if (cam->params.exposure.gainMode == 0) | 361 | if (cam->params.exposure.gainMode == 0) |
366 | out += sprintf(out, "max_gain: unknown %28s" | 362 | seq_printf(m, "max_gain: unknown %28s" |
367 | " powers of 2\n", tmpstr); | 363 | " powers of 2\n", tmpstr); |
368 | else | 364 | else |
369 | out += sprintf(out, "max_gain: %8d %28s" | 365 | seq_printf(m, "max_gain: %8d %28s" |
370 | " 1,2,4 or 8 \n", | 366 | " 1,2,4 or 8 \n", |
371 | 1<<(cam->params.exposure.gainMode-1), tmpstr); | 367 | 1<<(cam->params.exposure.gainMode-1), tmpstr); |
372 | 368 | ||
@@ -382,12 +378,12 @@ static int cpia_read_proc(char *page, char **start, off_t off, | |||
382 | sprintf(tmpstr, "unknown"); | 378 | sprintf(tmpstr, "unknown"); |
383 | break; | 379 | break; |
384 | } | 380 | } |
385 | out += sprintf(out, "exposure_mode: %8s %8s %8s" | 381 | seq_printf(m, "exposure_mode: %8s %8s %8s" |
386 | " %8s\n", tmpstr, "manual", "auto", "auto"); | 382 | " %8s\n", tmpstr, "manual", "auto", "auto"); |
387 | out += sprintf(out, "centre_weight: %8s %8s %8s %8s\n", | 383 | seq_printf(m, "centre_weight: %8s %8s %8s %8s\n", |
388 | (2-cam->params.exposure.centreWeight) ? "on" : "off", | 384 | (2-cam->params.exposure.centreWeight) ? "on" : "off", |
389 | "off", "on", "on"); | 385 | "off", "on", "on"); |
390 | out += sprintf(out, "gain: %8d %8d max_gain %8d 1,2,4,8 possible\n", | 386 | seq_printf(m, "gain: %8d %8d max_gain %8d 1,2,4,8 possible\n", |
391 | 1<<cam->params.exposure.gain, 1, 1); | 387 | 1<<cam->params.exposure.gain, 1, 1); |
392 | if (cam->params.version.firmwareVersion == 1 && | 388 | if (cam->params.version.firmwareVersion == 1 && |
393 | cam->params.version.firmwareRevision == 2) | 389 | cam->params.version.firmwareRevision == 2) |
@@ -396,7 +392,7 @@ static int cpia_read_proc(char *page, char **start, off_t off, | |||
396 | else | 392 | else |
397 | tmp = 510; | 393 | tmp = 510; |
398 | 394 | ||
399 | out += sprintf(out, "fine_exp: %8d %8d %8d %8d\n", | 395 | seq_printf(m, "fine_exp: %8d %8d %8d %8d\n", |
400 | cam->params.exposure.fineExp*2, 0, tmp, 0); | 396 | cam->params.exposure.fineExp*2, 0, tmp, 0); |
401 | if (cam->params.version.firmwareVersion == 1 && | 397 | if (cam->params.version.firmwareVersion == 1 && |
402 | cam->params.version.firmwareRevision == 2) | 398 | cam->params.version.firmwareRevision == 2) |
@@ -405,127 +401,122 @@ static int cpia_read_proc(char *page, char **start, off_t off, | |||
405 | else | 401 | else |
406 | tmp = MAX_EXP; | 402 | tmp = MAX_EXP; |
407 | 403 | ||
408 | out += sprintf(out, "coarse_exp: %8d %8d %8d" | 404 | seq_printf(m, "coarse_exp: %8d %8d %8d" |
409 | " %8d\n", cam->params.exposure.coarseExpLo+ | 405 | " %8d\n", cam->params.exposure.coarseExpLo+ |
410 | 256*cam->params.exposure.coarseExpHi, 0, tmp, 185); | 406 | 256*cam->params.exposure.coarseExpHi, 0, tmp, 185); |
411 | out += sprintf(out, "red_comp: %8d %8d %8d %8d\n", | 407 | seq_printf(m, "red_comp: %8d %8d %8d %8d\n", |
412 | cam->params.exposure.redComp, COMP_RED, 255, COMP_RED); | 408 | cam->params.exposure.redComp, COMP_RED, 255, COMP_RED); |
413 | out += sprintf(out, "green1_comp: %8d %8d %8d %8d\n", | 409 | seq_printf(m, "green1_comp: %8d %8d %8d %8d\n", |
414 | cam->params.exposure.green1Comp, COMP_GREEN1, 255, | 410 | cam->params.exposure.green1Comp, COMP_GREEN1, 255, |
415 | COMP_GREEN1); | 411 | COMP_GREEN1); |
416 | out += sprintf(out, "green2_comp: %8d %8d %8d %8d\n", | 412 | seq_printf(m, "green2_comp: %8d %8d %8d %8d\n", |
417 | cam->params.exposure.green2Comp, COMP_GREEN2, 255, | 413 | cam->params.exposure.green2Comp, COMP_GREEN2, 255, |
418 | COMP_GREEN2); | 414 | COMP_GREEN2); |
419 | out += sprintf(out, "blue_comp: %8d %8d %8d %8d\n", | 415 | seq_printf(m, "blue_comp: %8d %8d %8d %8d\n", |
420 | cam->params.exposure.blueComp, COMP_BLUE, 255, COMP_BLUE); | 416 | cam->params.exposure.blueComp, COMP_BLUE, 255, COMP_BLUE); |
421 | 417 | ||
422 | out += sprintf(out, "apcor_gain1: %#8x %#8x %#8x %#8x\n", | 418 | seq_printf(m, "apcor_gain1: %#8x %#8x %#8x %#8x\n", |
423 | cam->params.apcor.gain1, 0, 0xff, 0x1c); | 419 | cam->params.apcor.gain1, 0, 0xff, 0x1c); |
424 | out += sprintf(out, "apcor_gain2: %#8x %#8x %#8x %#8x\n", | 420 | seq_printf(m, "apcor_gain2: %#8x %#8x %#8x %#8x\n", |
425 | cam->params.apcor.gain2, 0, 0xff, 0x1a); | 421 | cam->params.apcor.gain2, 0, 0xff, 0x1a); |
426 | out += sprintf(out, "apcor_gain4: %#8x %#8x %#8x %#8x\n", | 422 | seq_printf(m, "apcor_gain4: %#8x %#8x %#8x %#8x\n", |
427 | cam->params.apcor.gain4, 0, 0xff, 0x2d); | 423 | cam->params.apcor.gain4, 0, 0xff, 0x2d); |
428 | out += sprintf(out, "apcor_gain8: %#8x %#8x %#8x %#8x\n", | 424 | seq_printf(m, "apcor_gain8: %#8x %#8x %#8x %#8x\n", |
429 | cam->params.apcor.gain8, 0, 0xff, 0x2a); | 425 | cam->params.apcor.gain8, 0, 0xff, 0x2a); |
430 | out += sprintf(out, "vl_offset_gain1: %8d %8d %8d %8d\n", | 426 | seq_printf(m, "vl_offset_gain1: %8d %8d %8d %8d\n", |
431 | cam->params.vlOffset.gain1, 0, 255, 24); | 427 | cam->params.vlOffset.gain1, 0, 255, 24); |
432 | out += sprintf(out, "vl_offset_gain2: %8d %8d %8d %8d\n", | 428 | seq_printf(m, "vl_offset_gain2: %8d %8d %8d %8d\n", |
433 | cam->params.vlOffset.gain2, 0, 255, 28); | 429 | cam->params.vlOffset.gain2, 0, 255, 28); |
434 | out += sprintf(out, "vl_offset_gain4: %8d %8d %8d %8d\n", | 430 | seq_printf(m, "vl_offset_gain4: %8d %8d %8d %8d\n", |
435 | cam->params.vlOffset.gain4, 0, 255, 30); | 431 | cam->params.vlOffset.gain4, 0, 255, 30); |
436 | out += sprintf(out, "vl_offset_gain8: %8d %8d %8d %8d\n", | 432 | seq_printf(m, "vl_offset_gain8: %8d %8d %8d %8d\n", |
437 | cam->params.vlOffset.gain8, 0, 255, 30); | 433 | cam->params.vlOffset.gain8, 0, 255, 30); |
438 | out += sprintf(out, "flicker_control: %8s %8s %8s %8s\n", | 434 | seq_printf(m, "flicker_control: %8s %8s %8s %8s\n", |
439 | cam->params.flickerControl.flickerMode ? "on" : "off", | 435 | cam->params.flickerControl.flickerMode ? "on" : "off", |
440 | "off", "on", "off"); | 436 | "off", "on", "off"); |
441 | out += sprintf(out, "mains_frequency: %8d %8d %8d %8d" | 437 | seq_printf(m, "mains_frequency: %8d %8d %8d %8d" |
442 | " only 50/60\n", | 438 | " only 50/60\n", |
443 | cam->mainsFreq ? 60 : 50, 50, 60, 50); | 439 | cam->mainsFreq ? 60 : 50, 50, 60, 50); |
444 | if(cam->params.flickerControl.allowableOverExposure < 0) | 440 | if(cam->params.flickerControl.allowableOverExposure < 0) |
445 | out += sprintf(out, "allowable_overexposure: %4dauto auto %8d auto\n", | 441 | seq_printf(m, "allowable_overexposure: %4dauto auto %8d auto\n", |
446 | -cam->params.flickerControl.allowableOverExposure, | 442 | -cam->params.flickerControl.allowableOverExposure, |
447 | 255); | 443 | 255); |
448 | else | 444 | else |
449 | out += sprintf(out, "allowable_overexposure: %8d auto %8d auto\n", | 445 | seq_printf(m, "allowable_overexposure: %8d auto %8d auto\n", |
450 | cam->params.flickerControl.allowableOverExposure, | 446 | cam->params.flickerControl.allowableOverExposure, |
451 | 255); | 447 | 255); |
452 | out += sprintf(out, "compression_mode: "); | 448 | seq_printf(m, "compression_mode: "); |
453 | switch(cam->params.compression.mode) { | 449 | switch(cam->params.compression.mode) { |
454 | case CPIA_COMPRESSION_NONE: | 450 | case CPIA_COMPRESSION_NONE: |
455 | out += sprintf(out, "%8s", "none"); | 451 | seq_printf(m, "%8s", "none"); |
456 | break; | 452 | break; |
457 | case CPIA_COMPRESSION_AUTO: | 453 | case CPIA_COMPRESSION_AUTO: |
458 | out += sprintf(out, "%8s", "auto"); | 454 | seq_printf(m, "%8s", "auto"); |
459 | break; | 455 | break; |
460 | case CPIA_COMPRESSION_MANUAL: | 456 | case CPIA_COMPRESSION_MANUAL: |
461 | out += sprintf(out, "%8s", "manual"); | 457 | seq_printf(m, "%8s", "manual"); |
462 | break; | 458 | break; |
463 | default: | 459 | default: |
464 | out += sprintf(out, "%8s", "unknown"); | 460 | seq_printf(m, "%8s", "unknown"); |
465 | break; | 461 | break; |
466 | } | 462 | } |
467 | out += sprintf(out, " none,auto,manual auto\n"); | 463 | seq_printf(m, " none,auto,manual auto\n"); |
468 | out += sprintf(out, "decimation_enable: %8s %8s %8s %8s\n", | 464 | seq_printf(m, "decimation_enable: %8s %8s %8s %8s\n", |
469 | cam->params.compression.decimation == | 465 | cam->params.compression.decimation == |
470 | DECIMATION_ENAB ? "on":"off", "off", "on", | 466 | DECIMATION_ENAB ? "on":"off", "off", "on", |
471 | "off"); | 467 | "off"); |
472 | out += sprintf(out, "compression_target: %9s %9s %9s %9s\n", | 468 | seq_printf(m, "compression_target: %9s %9s %9s %9s\n", |
473 | cam->params.compressionTarget.frTargeting == | 469 | cam->params.compressionTarget.frTargeting == |
474 | CPIA_COMPRESSION_TARGET_FRAMERATE ? | 470 | CPIA_COMPRESSION_TARGET_FRAMERATE ? |
475 | "framerate":"quality", | 471 | "framerate":"quality", |
476 | "framerate", "quality", "quality"); | 472 | "framerate", "quality", "quality"); |
477 | out += sprintf(out, "target_framerate: %8d %8d %8d %8d\n", | 473 | seq_printf(m, "target_framerate: %8d %8d %8d %8d\n", |
478 | cam->params.compressionTarget.targetFR, 1, 30, 15); | 474 | cam->params.compressionTarget.targetFR, 1, 30, 15); |
479 | out += sprintf(out, "target_quality: %8d %8d %8d %8d\n", | 475 | seq_printf(m, "target_quality: %8d %8d %8d %8d\n", |
480 | cam->params.compressionTarget.targetQ, 1, 64, 5); | 476 | cam->params.compressionTarget.targetQ, 1, 64, 5); |
481 | out += sprintf(out, "y_threshold: %8d %8d %8d %8d\n", | 477 | seq_printf(m, "y_threshold: %8d %8d %8d %8d\n", |
482 | cam->params.yuvThreshold.yThreshold, 0, 31, 6); | 478 | cam->params.yuvThreshold.yThreshold, 0, 31, 6); |
483 | out += sprintf(out, "uv_threshold: %8d %8d %8d %8d\n", | 479 | seq_printf(m, "uv_threshold: %8d %8d %8d %8d\n", |
484 | cam->params.yuvThreshold.uvThreshold, 0, 31, 6); | 480 | cam->params.yuvThreshold.uvThreshold, 0, 31, 6); |
485 | out += sprintf(out, "hysteresis: %8d %8d %8d %8d\n", | 481 | seq_printf(m, "hysteresis: %8d %8d %8d %8d\n", |
486 | cam->params.compressionParams.hysteresis, 0, 255, 3); | 482 | cam->params.compressionParams.hysteresis, 0, 255, 3); |
487 | out += sprintf(out, "threshold_max: %8d %8d %8d %8d\n", | 483 | seq_printf(m, "threshold_max: %8d %8d %8d %8d\n", |
488 | cam->params.compressionParams.threshMax, 0, 255, 11); | 484 | cam->params.compressionParams.threshMax, 0, 255, 11); |
489 | out += sprintf(out, "small_step: %8d %8d %8d %8d\n", | 485 | seq_printf(m, "small_step: %8d %8d %8d %8d\n", |
490 | cam->params.compressionParams.smallStep, 0, 255, 1); | 486 | cam->params.compressionParams.smallStep, 0, 255, 1); |
491 | out += sprintf(out, "large_step: %8d %8d %8d %8d\n", | 487 | seq_printf(m, "large_step: %8d %8d %8d %8d\n", |
492 | cam->params.compressionParams.largeStep, 0, 255, 3); | 488 | cam->params.compressionParams.largeStep, 0, 255, 3); |
493 | out += sprintf(out, "decimation_hysteresis: %8d %8d %8d %8d\n", | 489 | seq_printf(m, "decimation_hysteresis: %8d %8d %8d %8d\n", |
494 | cam->params.compressionParams.decimationHysteresis, | 490 | cam->params.compressionParams.decimationHysteresis, |
495 | 0, 255, 2); | 491 | 0, 255, 2); |
496 | out += sprintf(out, "fr_diff_step_thresh: %8d %8d %8d %8d\n", | 492 | seq_printf(m, "fr_diff_step_thresh: %8d %8d %8d %8d\n", |
497 | cam->params.compressionParams.frDiffStepThresh, | 493 | cam->params.compressionParams.frDiffStepThresh, |
498 | 0, 255, 5); | 494 | 0, 255, 5); |
499 | out += sprintf(out, "q_diff_step_thresh: %8d %8d %8d %8d\n", | 495 | seq_printf(m, "q_diff_step_thresh: %8d %8d %8d %8d\n", |
500 | cam->params.compressionParams.qDiffStepThresh, | 496 | cam->params.compressionParams.qDiffStepThresh, |
501 | 0, 255, 3); | 497 | 0, 255, 3); |
502 | out += sprintf(out, "decimation_thresh_mod: %8d %8d %8d %8d\n", | 498 | seq_printf(m, "decimation_thresh_mod: %8d %8d %8d %8d\n", |
503 | cam->params.compressionParams.decimationThreshMod, | 499 | cam->params.compressionParams.decimationThreshMod, |
504 | 0, 255, 2); | 500 | 0, 255, 2); |
505 | /* QX3 specific entries */ | 501 | /* QX3 specific entries */ |
506 | if (cam->params.qx3.qx3_detected) { | 502 | if (cam->params.qx3.qx3_detected) { |
507 | out += sprintf(out, "toplight: %8s %8s %8s %8s\n", | 503 | seq_printf(m, "toplight: %8s %8s %8s %8s\n", |
508 | cam->params.qx3.toplight ? "on" : "off", | 504 | cam->params.qx3.toplight ? "on" : "off", |
509 | "off", "on", "off"); | 505 | "off", "on", "off"); |
510 | out += sprintf(out, "bottomlight: %8s %8s %8s %8s\n", | 506 | seq_printf(m, "bottomlight: %8s %8s %8s %8s\n", |
511 | cam->params.qx3.bottomlight ? "on" : "off", | 507 | cam->params.qx3.bottomlight ? "on" : "off", |
512 | "off", "on", "off"); | 508 | "off", "on", "off"); |
513 | } | 509 | } |
514 | 510 | ||
515 | len = out - page; | 511 | return 0; |
516 | len -= off; | ||
517 | if (len < count) { | ||
518 | *eof = 1; | ||
519 | if (len <= 0) return 0; | ||
520 | } else | ||
521 | len = count; | ||
522 | |||
523 | *start = page + off; | ||
524 | return len; | ||
525 | } | 512 | } |
526 | 513 | ||
514 | static int cpia_proc_open(struct inode *inode, struct file *file) | ||
515 | { | ||
516 | return single_open(file, cpia_proc_show, PDE(inode)->data); | ||
517 | } | ||
527 | 518 | ||
528 | static int match(char *checkstr, char **buffer, unsigned long *count, | 519 | static int match(char *checkstr, char **buffer, size_t *count, |
529 | int *find_colon, int *err) | 520 | int *find_colon, int *err) |
530 | { | 521 | { |
531 | int ret, colon_found = 1; | 522 | int ret, colon_found = 1; |
@@ -551,7 +542,7 @@ static int match(char *checkstr, char **buffer, unsigned long *count, | |||
551 | return ret; | 542 | return ret; |
552 | } | 543 | } |
553 | 544 | ||
554 | static unsigned long int value(char **buffer, unsigned long *count, int *err) | 545 | static unsigned long int value(char **buffer, size_t *count, int *err) |
555 | { | 546 | { |
556 | char *p; | 547 | char *p; |
557 | unsigned long int ret; | 548 | unsigned long int ret; |
@@ -565,10 +556,10 @@ static unsigned long int value(char **buffer, unsigned long *count, int *err) | |||
565 | return ret; | 556 | return ret; |
566 | } | 557 | } |
567 | 558 | ||
568 | static int cpia_write_proc(struct file *file, const char __user *buf, | 559 | static ssize_t cpia_proc_write(struct file *file, const char __user *buf, |
569 | unsigned long count, void *data) | 560 | size_t count, loff_t *pos) |
570 | { | 561 | { |
571 | struct cam_data *cam = data; | 562 | struct cam_data *cam = PDE(file->f_path.dentry->d_inode)->data; |
572 | struct cam_params new_params; | 563 | struct cam_params new_params; |
573 | char *page, *buffer; | 564 | char *page, *buffer; |
574 | int retval, find_colon; | 565 | int retval, find_colon; |
@@ -582,7 +573,7 @@ static int cpia_write_proc(struct file *file, const char __user *buf, | |||
582 | * from the comx driver | 573 | * from the comx driver |
583 | */ | 574 | */ |
584 | if (count > PAGE_SIZE) { | 575 | if (count > PAGE_SIZE) { |
585 | printk(KERN_ERR "count is %lu > %d!!!\n", count, (int)PAGE_SIZE); | 576 | printk(KERN_ERR "count is %zu > %d!!!\n", count, (int)PAGE_SIZE); |
586 | return -ENOSPC; | 577 | return -ENOSPC; |
587 | } | 578 | } |
588 | 579 | ||
@@ -1340,6 +1331,15 @@ out: | |||
1340 | return retval; | 1331 | return retval; |
1341 | } | 1332 | } |
1342 | 1333 | ||
1334 | static const struct file_operations cpia_proc_fops = { | ||
1335 | .owner = THIS_MODULE, | ||
1336 | .open = cpia_proc_open, | ||
1337 | .read = seq_read, | ||
1338 | .llseek = seq_lseek, | ||
1339 | .release = single_release, | ||
1340 | .write = cpia_proc_write, | ||
1341 | }; | ||
1342 | |||
1343 | static void create_proc_cpia_cam(struct cam_data *cam) | 1343 | static void create_proc_cpia_cam(struct cam_data *cam) |
1344 | { | 1344 | { |
1345 | struct proc_dir_entry *ent; | 1345 | struct proc_dir_entry *ent; |
@@ -1347,14 +1347,12 @@ static void create_proc_cpia_cam(struct cam_data *cam) | |||
1347 | if (!cpia_proc_root || !cam) | 1347 | if (!cpia_proc_root || !cam) |
1348 | return; | 1348 | return; |
1349 | 1349 | ||
1350 | ent = create_proc_entry(video_device_node_name(&cam->vdev), | 1350 | ent = proc_create_data(video_device_node_name(&cam->vdev), |
1351 | S_IFREG|S_IRUGO|S_IWUSR, cpia_proc_root); | 1351 | S_IRUGO|S_IWUSR, cpia_proc_root, |
1352 | &cpia_proc_fops, cam); | ||
1352 | if (!ent) | 1353 | if (!ent) |
1353 | return; | 1354 | return; |
1354 | 1355 | ||
1355 | ent->data = cam; | ||
1356 | ent->read_proc = cpia_read_proc; | ||
1357 | ent->write_proc = cpia_write_proc; | ||
1358 | /* | 1356 | /* |
1359 | size of the proc entry is 3736 bytes for the standard webcam; | 1357 | size of the proc entry is 3736 bytes for the standard webcam; |
1360 | the extra features of the QX3 microscope add 189 bytes. | 1358 | the extra features of the QX3 microscope add 189 bytes. |