diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-12-07 12:47:10 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-12-29 05:16:59 -0500 |
commit | 86701c1d6a3ecae2f0e6771c730364d334d5a142 (patch) | |
tree | 40bec2f3b972df989937d9424ac1e65d9f3b7552 | |
parent | e78567d227ecd40543508342ba39a3dfba5af14f (diff) |
[media] gspca/sn9c20x: Get rid of scale "magic" numbers
Use macros for the supported scales, instead of using magic numbers
from 0 to 3.
Code become cleaner by using macros for it.
Acked-by: Jean-Francois Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/video/gspca/sn9c20x.c | 58 |
1 files changed, 33 insertions, 25 deletions
diff --git a/drivers/media/video/gspca/sn9c20x.c b/drivers/media/video/gspca/sn9c20x.c index 1e0f219188ac..e812598a677b 100644 --- a/drivers/media/video/gspca/sn9c20x.c +++ b/drivers/media/video/gspca/sn9c20x.c | |||
@@ -33,6 +33,14 @@ MODULE_LICENSE("GPL"); | |||
33 | 33 | ||
34 | #define MODULE_NAME "sn9c20x" | 34 | #define MODULE_NAME "sn9c20x" |
35 | 35 | ||
36 | /* | ||
37 | * Pixel format private data | ||
38 | */ | ||
39 | #define SCALE_MASK 0x0f | ||
40 | #define SCALE_160x120 0 | ||
41 | #define SCALE_320x240 1 | ||
42 | #define SCALE_640x480 2 | ||
43 | #define SCALE_1280x1024 3 | ||
36 | #define MODE_RAW 0x10 | 44 | #define MODE_RAW 0x10 |
37 | #define MODE_JPEG 0x20 | 45 | #define MODE_JPEG 0x20 |
38 | #define MODE_SXGA 0x80 | 46 | #define MODE_SXGA 0x80 |
@@ -348,47 +356,47 @@ static const struct v4l2_pix_format vga_mode[] = { | |||
348 | .bytesperline = 160, | 356 | .bytesperline = 160, |
349 | .sizeimage = 160 * 120 * 4 / 8 + 590, | 357 | .sizeimage = 160 * 120 * 4 / 8 + 590, |
350 | .colorspace = V4L2_COLORSPACE_JPEG, | 358 | .colorspace = V4L2_COLORSPACE_JPEG, |
351 | .priv = 0 | MODE_JPEG}, | 359 | .priv = SCALE_160x120 | MODE_JPEG}, |
352 | {160, 120, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, | 360 | {160, 120, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, |
353 | .bytesperline = 160, | 361 | .bytesperline = 160, |
354 | .sizeimage = 160 * 120, | 362 | .sizeimage = 160 * 120, |
355 | .colorspace = V4L2_COLORSPACE_SRGB, | 363 | .colorspace = V4L2_COLORSPACE_SRGB, |
356 | .priv = 0 | MODE_RAW}, | 364 | .priv = SCALE_160x120 | MODE_RAW}, |
357 | {160, 120, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, | 365 | {160, 120, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, |
358 | .bytesperline = 160, | 366 | .bytesperline = 160, |
359 | .sizeimage = 240 * 120, | 367 | .sizeimage = 240 * 120, |
360 | .colorspace = V4L2_COLORSPACE_SRGB, | 368 | .colorspace = V4L2_COLORSPACE_SRGB, |
361 | .priv = 0}, | 369 | .priv = SCALE_160x120}, |
362 | {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | 370 | {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
363 | .bytesperline = 320, | 371 | .bytesperline = 320, |
364 | .sizeimage = 320 * 240 * 3 / 8 + 590, | 372 | .sizeimage = 320 * 240 * 3 / 8 + 590, |
365 | .colorspace = V4L2_COLORSPACE_JPEG, | 373 | .colorspace = V4L2_COLORSPACE_JPEG, |
366 | .priv = 1 | MODE_JPEG}, | 374 | .priv = SCALE_320x240 | MODE_JPEG}, |
367 | {320, 240, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, | 375 | {320, 240, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, |
368 | .bytesperline = 320, | 376 | .bytesperline = 320, |
369 | .sizeimage = 320 * 240 , | 377 | .sizeimage = 320 * 240 , |
370 | .colorspace = V4L2_COLORSPACE_SRGB, | 378 | .colorspace = V4L2_COLORSPACE_SRGB, |
371 | .priv = 1 | MODE_RAW}, | 379 | .priv = SCALE_320x240 | MODE_RAW}, |
372 | {320, 240, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, | 380 | {320, 240, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, |
373 | .bytesperline = 320, | 381 | .bytesperline = 320, |
374 | .sizeimage = 480 * 240 , | 382 | .sizeimage = 480 * 240 , |
375 | .colorspace = V4L2_COLORSPACE_SRGB, | 383 | .colorspace = V4L2_COLORSPACE_SRGB, |
376 | .priv = 1}, | 384 | .priv = SCALE_320x240}, |
377 | {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | 385 | {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
378 | .bytesperline = 640, | 386 | .bytesperline = 640, |
379 | .sizeimage = 640 * 480 * 3 / 8 + 590, | 387 | .sizeimage = 640 * 480 * 3 / 8 + 590, |
380 | .colorspace = V4L2_COLORSPACE_JPEG, | 388 | .colorspace = V4L2_COLORSPACE_JPEG, |
381 | .priv = 2 | MODE_JPEG}, | 389 | .priv = SCALE_640x480 | MODE_JPEG}, |
382 | {640, 480, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, | 390 | {640, 480, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, |
383 | .bytesperline = 640, | 391 | .bytesperline = 640, |
384 | .sizeimage = 640 * 480, | 392 | .sizeimage = 640 * 480, |
385 | .colorspace = V4L2_COLORSPACE_SRGB, | 393 | .colorspace = V4L2_COLORSPACE_SRGB, |
386 | .priv = 2 | MODE_RAW}, | 394 | .priv = SCALE_640x480 | MODE_RAW}, |
387 | {640, 480, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, | 395 | {640, 480, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, |
388 | .bytesperline = 640, | 396 | .bytesperline = 640, |
389 | .sizeimage = 960 * 480, | 397 | .sizeimage = 960 * 480, |
390 | .colorspace = V4L2_COLORSPACE_SRGB, | 398 | .colorspace = V4L2_COLORSPACE_SRGB, |
391 | .priv = 2}, | 399 | .priv = SCALE_640x480}, |
392 | }; | 400 | }; |
393 | 401 | ||
394 | static const struct v4l2_pix_format sxga_mode[] = { | 402 | static const struct v4l2_pix_format sxga_mode[] = { |
@@ -396,52 +404,52 @@ static const struct v4l2_pix_format sxga_mode[] = { | |||
396 | .bytesperline = 160, | 404 | .bytesperline = 160, |
397 | .sizeimage = 160 * 120 * 4 / 8 + 590, | 405 | .sizeimage = 160 * 120 * 4 / 8 + 590, |
398 | .colorspace = V4L2_COLORSPACE_JPEG, | 406 | .colorspace = V4L2_COLORSPACE_JPEG, |
399 | .priv = 0 | MODE_JPEG}, | 407 | .priv = SCALE_160x120 | MODE_JPEG}, |
400 | {160, 120, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, | 408 | {160, 120, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, |
401 | .bytesperline = 160, | 409 | .bytesperline = 160, |
402 | .sizeimage = 160 * 120, | 410 | .sizeimage = 160 * 120, |
403 | .colorspace = V4L2_COLORSPACE_SRGB, | 411 | .colorspace = V4L2_COLORSPACE_SRGB, |
404 | .priv = 0 | MODE_RAW}, | 412 | .priv = SCALE_160x120 | MODE_RAW}, |
405 | {160, 120, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, | 413 | {160, 120, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, |
406 | .bytesperline = 160, | 414 | .bytesperline = 160, |
407 | .sizeimage = 240 * 120, | 415 | .sizeimage = 240 * 120, |
408 | .colorspace = V4L2_COLORSPACE_SRGB, | 416 | .colorspace = V4L2_COLORSPACE_SRGB, |
409 | .priv = 0}, | 417 | .priv = SCALE_160x120}, |
410 | {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | 418 | {320, 240, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
411 | .bytesperline = 320, | 419 | .bytesperline = 320, |
412 | .sizeimage = 320 * 240 * 3 / 8 + 590, | 420 | .sizeimage = 320 * 240 * 3 / 8 + 590, |
413 | .colorspace = V4L2_COLORSPACE_JPEG, | 421 | .colorspace = V4L2_COLORSPACE_JPEG, |
414 | .priv = 1 | MODE_JPEG}, | 422 | .priv = SCALE_320x240 | MODE_JPEG}, |
415 | {320, 240, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, | 423 | {320, 240, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, |
416 | .bytesperline = 320, | 424 | .bytesperline = 320, |
417 | .sizeimage = 320 * 240 , | 425 | .sizeimage = 320 * 240 , |
418 | .colorspace = V4L2_COLORSPACE_SRGB, | 426 | .colorspace = V4L2_COLORSPACE_SRGB, |
419 | .priv = 1 | MODE_RAW}, | 427 | .priv = SCALE_320x240 | MODE_RAW}, |
420 | {320, 240, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, | 428 | {320, 240, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, |
421 | .bytesperline = 320, | 429 | .bytesperline = 320, |
422 | .sizeimage = 480 * 240 , | 430 | .sizeimage = 480 * 240 , |
423 | .colorspace = V4L2_COLORSPACE_SRGB, | 431 | .colorspace = V4L2_COLORSPACE_SRGB, |
424 | .priv = 1}, | 432 | .priv = SCALE_320x240}, |
425 | {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, | 433 | {640, 480, V4L2_PIX_FMT_JPEG, V4L2_FIELD_NONE, |
426 | .bytesperline = 640, | 434 | .bytesperline = 640, |
427 | .sizeimage = 640 * 480 * 3 / 8 + 590, | 435 | .sizeimage = 640 * 480 * 3 / 8 + 590, |
428 | .colorspace = V4L2_COLORSPACE_JPEG, | 436 | .colorspace = V4L2_COLORSPACE_JPEG, |
429 | .priv = 2 | MODE_JPEG}, | 437 | .priv = SCALE_640x480 | MODE_JPEG}, |
430 | {640, 480, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, | 438 | {640, 480, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, |
431 | .bytesperline = 640, | 439 | .bytesperline = 640, |
432 | .sizeimage = 640 * 480, | 440 | .sizeimage = 640 * 480, |
433 | .colorspace = V4L2_COLORSPACE_SRGB, | 441 | .colorspace = V4L2_COLORSPACE_SRGB, |
434 | .priv = 2 | MODE_RAW}, | 442 | .priv = SCALE_640x480 | MODE_RAW}, |
435 | {640, 480, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, | 443 | {640, 480, V4L2_PIX_FMT_SN9C20X_I420, V4L2_FIELD_NONE, |
436 | .bytesperline = 640, | 444 | .bytesperline = 640, |
437 | .sizeimage = 960 * 480, | 445 | .sizeimage = 960 * 480, |
438 | .colorspace = V4L2_COLORSPACE_SRGB, | 446 | .colorspace = V4L2_COLORSPACE_SRGB, |
439 | .priv = 2}, | 447 | .priv = SCALE_640x480}, |
440 | {1280, 1024, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, | 448 | {1280, 1024, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE, |
441 | .bytesperline = 1280, | 449 | .bytesperline = 1280, |
442 | .sizeimage = 1280 * 1024, | 450 | .sizeimage = 1280 * 1024, |
443 | .colorspace = V4L2_COLORSPACE_SRGB, | 451 | .colorspace = V4L2_COLORSPACE_SRGB, |
444 | .priv = 3 | MODE_RAW | MODE_SXGA}, | 452 | .priv = SCALE_1280x1024 | MODE_RAW | MODE_SXGA}, |
445 | }; | 453 | }; |
446 | 454 | ||
447 | static const s16 hsv_red_x[] = { | 455 | static const s16 hsv_red_x[] = { |
@@ -2182,22 +2190,22 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
2182 | else if (mode & MODE_JPEG) | 2190 | else if (mode & MODE_JPEG) |
2183 | fmt = 0x2c; | 2191 | fmt = 0x2c; |
2184 | else | 2192 | else |
2185 | fmt = 0x2f; | 2193 | fmt = 0x2f; /* YUV 420 */ |
2186 | 2194 | ||
2187 | switch (mode & 0x0f) { | 2195 | switch (mode & SCALE_MASK) { |
2188 | case 3: | 2196 | case SCALE_1280x1024: |
2189 | scale = 0xc0; | 2197 | scale = 0xc0; |
2190 | info("Set 1280x1024"); | 2198 | info("Set 1280x1024"); |
2191 | break; | 2199 | break; |
2192 | case 2: | 2200 | case SCALE_640x480: |
2193 | scale = 0x80; | 2201 | scale = 0x80; |
2194 | info("Set 640x480"); | 2202 | info("Set 640x480"); |
2195 | break; | 2203 | break; |
2196 | case 1: | 2204 | case SCALE_320x240: |
2197 | scale = 0x90; | 2205 | scale = 0x90; |
2198 | info("Set 320x240"); | 2206 | info("Set 320x240"); |
2199 | break; | 2207 | break; |
2200 | case 0: | 2208 | case SCALE_160x120: |
2201 | scale = 0xa0; | 2209 | scale = 0xa0; |
2202 | info("Set 160x120"); | 2210 | info("Set 160x120"); |
2203 | break; | 2211 | break; |