aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca/sn9c20x.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2010-12-07 17:39:33 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-12-29 05:17:00 -0500
commitd162e7aac24bfd8b96881582368f976e7e464c25 (patch)
treeb7f9e4e3accac4d3ab5a07d1d78dfa3f03727cf4 /drivers/media/video/gspca/sn9c20x.c
parentd4b416f26279bbbe07faaff1c9cd19d6b3709b2e (diff)
[media] gspca/sn9c20x: Fix support for mt9m001 (mi1300) sensor
Support for mt9m001 (mi1300) is broken: - Table is incomplete; - Only one resolution is currently supported by the driver; - Resolution is incomplete; - it complains about broken JPEG headers. Use the same init found on em28xx driver, and properly report the output format as 8-bits GRAY. Acked-by: Jean-Francois Moine <moinejf@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/gspca/sn9c20x.c')
-rw-r--r--drivers/media/video/gspca/sn9c20x.c74
1 files changed, 61 insertions, 13 deletions
diff --git a/drivers/media/video/gspca/sn9c20x.c b/drivers/media/video/gspca/sn9c20x.c
index e812598a677b..cb08d00d0a31 100644
--- a/drivers/media/video/gspca/sn9c20x.c
+++ b/drivers/media/video/gspca/sn9c20x.c
@@ -452,6 +452,29 @@ static const struct v4l2_pix_format sxga_mode[] = {
452 .priv = SCALE_1280x1024 | MODE_RAW | MODE_SXGA}, 452 .priv = SCALE_1280x1024 | MODE_RAW | MODE_SXGA},
453}; 453};
454 454
455static const struct v4l2_pix_format mono_mode[] = {
456 {160, 120, V4L2_PIX_FMT_GREY, V4L2_FIELD_NONE,
457 .bytesperline = 160,
458 .sizeimage = 160 * 120,
459 .colorspace = V4L2_COLORSPACE_SRGB,
460 .priv = SCALE_160x120 | MODE_RAW},
461 {320, 240, V4L2_PIX_FMT_GREY, V4L2_FIELD_NONE,
462 .bytesperline = 320,
463 .sizeimage = 320 * 240 ,
464 .colorspace = V4L2_COLORSPACE_SRGB,
465 .priv = SCALE_320x240 | MODE_RAW},
466 {640, 480, V4L2_PIX_FMT_GREY, V4L2_FIELD_NONE,
467 .bytesperline = 640,
468 .sizeimage = 640 * 480,
469 .colorspace = V4L2_COLORSPACE_SRGB,
470 .priv = SCALE_640x480 | MODE_RAW},
471 {1280, 1024, V4L2_PIX_FMT_GREY, V4L2_FIELD_NONE,
472 .bytesperline = 1280,
473 .sizeimage = 1280 * 1024,
474 .colorspace = V4L2_COLORSPACE_SRGB,
475 .priv = SCALE_1280x1024 | MODE_RAW | MODE_SXGA},
476};
477
455static const s16 hsv_red_x[] = { 478static const s16 hsv_red_x[] = {
456 41, 44, 46, 48, 50, 52, 54, 56, 479 41, 44, 46, 48, 50, 52, 54, 56,
457 58, 60, 62, 64, 66, 68, 70, 72, 480 58, 60, 62, 64, 66, 68, 70, 72,
@@ -1037,16 +1060,19 @@ static struct i2c_reg_u16 mt9v011_init[] = {
1037}; 1060};
1038 1061
1039static struct i2c_reg_u16 mt9m001_init[] = { 1062static struct i2c_reg_u16 mt9m001_init[] = {
1040 {0x0d, 0x0001}, {0x0d, 0x0000}, {0x01, 0x000e}, 1063 {0x0d, 0x0001},
1041 {0x02, 0x0014}, {0x03, 0x03c1}, {0x04, 0x0501}, 1064 {0x0d, 0x0000},
1042 {0x05, 0x0083}, {0x06, 0x0006}, {0x0d, 0x0002}, 1065 {0x04, 0x0500}, /* hres = 1280 */
1043 {0x0a, 0x0000}, {0x0c, 0x0000}, {0x11, 0x0000}, 1066 {0x03, 0x0400}, /* vres = 1024 */
1044 {0x1e, 0x8000}, {0x5f, 0x8904}, {0x60, 0x0000}, 1067 {0x20, 0x1100},
1045 {0x61, 0x0000}, {0x62, 0x0498}, {0x63, 0x0000}, 1068 {0x06, 0x0010},
1046 {0x64, 0x0000}, {0x20, 0x111d}, {0x06, 0x00f2}, 1069 {0x2b, 0x0024},
1047 {0x05, 0x0013}, {0x09, 0x10f2}, {0x07, 0x0003}, 1070 {0x2e, 0x0024},
1048 {0x2b, 0x002a}, {0x2d, 0x002a}, {0x2c, 0x002a}, 1071 {0x35, 0x0024},
1049 {0x2e, 0x0029}, {0x07, 0x0002}, 1072 {0x2d, 0x0020},
1073 {0x2c, 0x0020},
1074 {0x09, 0x0ad4},
1075 {0x35, 0x0057},
1050}; 1076};
1051 1077
1052static struct i2c_reg_u16 mt9m111_init[] = { 1078static struct i2c_reg_u16 mt9m111_init[] = {
@@ -1442,6 +1468,25 @@ static int mt9m001_init_sensor(struct gspca_dev *gspca_dev)
1442{ 1468{
1443 struct sd *sd = (struct sd *) gspca_dev; 1469 struct sd *sd = (struct sd *) gspca_dev;
1444 int i; 1470 int i;
1471 u16 id;
1472
1473 if (i2c_r2(gspca_dev, 0x00, &id) < 0)
1474 return -EINVAL;
1475
1476 /* must be 0x8411 or 0x8421 for colour sensor and 8431 for bw */
1477 switch (id) {
1478 case 0x8411:
1479 case 0x8421:
1480 info("MT9M001 color sensor detected");
1481 break;
1482 case 0x8431:
1483 info("MT9M001 mono sensor detected");
1484 break;
1485 default:
1486 err("No MT9M001 chip detected, ID = %x\n", id);
1487 return -ENODEV;
1488 }
1489
1445 for (i = 0; i < ARRAY_SIZE(mt9m001_init); i++) { 1490 for (i = 0; i < ARRAY_SIZE(mt9m001_init); i++) {
1446 if (i2c_w2(gspca_dev, mt9m001_init[i].reg, 1491 if (i2c_w2(gspca_dev, mt9m001_init[i].reg,
1447 mt9m001_init[i].val) < 0) { 1492 mt9m001_init[i].val) < 0) {
@@ -1451,8 +1496,8 @@ static int mt9m001_init_sensor(struct gspca_dev *gspca_dev)
1451 } 1496 }
1452 /* disable hflip and vflip */ 1497 /* disable hflip and vflip */
1453 gspca_dev->ctrl_dis = (1 << HFLIP_IDX) | (1 << VFLIP_IDX); 1498 gspca_dev->ctrl_dis = (1 << HFLIP_IDX) | (1 << VFLIP_IDX);
1454 sd->hstart = 2; 1499 sd->hstart = 1;
1455 sd->vstart = 2; 1500 sd->vstart = 1;
1456 return 0; 1501 return 0;
1457} 1502}
1458 1503
@@ -1994,6 +2039,10 @@ static int sd_config(struct gspca_dev *gspca_dev,
1994 cam->cam_mode = sxga_mode; 2039 cam->cam_mode = sxga_mode;
1995 cam->nmodes = ARRAY_SIZE(sxga_mode); 2040 cam->nmodes = ARRAY_SIZE(sxga_mode);
1996 break; 2041 break;
2042 case SENSOR_MT9M001:
2043 cam->cam_mode = mono_mode;
2044 cam->nmodes = ARRAY_SIZE(mono_mode);
2045 break;
1997 default: 2046 default:
1998 cam->cam_mode = vga_mode; 2047 cam->cam_mode = vga_mode;
1999 cam->nmodes = ARRAY_SIZE(vga_mode); 2048 cam->nmodes = ARRAY_SIZE(vga_mode);
@@ -2092,7 +2141,6 @@ static int sd_init(struct gspca_dev *gspca_dev)
2092 case SENSOR_MT9M001: 2141 case SENSOR_MT9M001:
2093 if (mt9m001_init_sensor(gspca_dev) < 0) 2142 if (mt9m001_init_sensor(gspca_dev) < 0)
2094 return -ENODEV; 2143 return -ENODEV;
2095 info("MT9M001 sensor detected");
2096 break; 2144 break;
2097 case SENSOR_HV7131R: 2145 case SENSOR_HV7131R:
2098 if (hv7131r_init_sensor(gspca_dev) < 0) 2146 if (hv7131r_init_sensor(gspca_dev) < 0)