From 1e01a85510fe22fc5be28954f01374a87de788f6 Mon Sep 17 00:00:00 2001 From: GWater Date: Mon, 27 Oct 2008 21:07:07 +0100 Subject: [PATCH] Add support for 627b Signed-off-by: GWater --- microdia-dev.c | 5 +++++ microdia.h | 1 + ov7660.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ov7660.h | 1 + sn9c20x.c | 6 +++++- 5 files changed, 73 insertions(+), 1 deletion(-) diff --git a/microdia-dev.c b/microdia-dev.c index df76bc3..ae189dd 100644 --- a/microdia-dev.c +++ b/microdia-dev.c @@ -51,6 +51,11 @@ struct sensor_info sensors[] = { .name = "SOI968", .probe = ov965x_probe }, + { + .id = OV7660_SENSOR, + .name = "OV7660", + .probe = ov7660_probe + }, }; /** diff --git a/microdia.h b/microdia.h index 1e2b2ed..0669b6c 100644 --- a/microdia.h +++ b/microdia.h @@ -304,6 +304,7 @@ enum microdia_sensors { OV9650_SENSOR = 1, OV9655_SENSOR = 2, SOI968_SENSOR = 3, + OV7660_SENSOR = 4, }; diff --git a/ov7660.c b/ov7660.c index 5edb5f5..e79630c 100644 --- a/ov7660.c +++ b/ov7660.c @@ -241,3 +241,64 @@ errI2C: UDIA_ERROR("Failed to reset the Image Sensor (%d)!\n", ret); return ret; } + +struct microdia_video_format ov7660_fmts[] = { + { + .pix_fmt = V4L2_PIX_FMT_SBGGR8, + .desc = "Bayer 8bit (BGGR)", + .depth = 8, + .set_format = sn9c20x_set_raw + }, + { + .pix_fmt = V4L2_PIX_FMT_JPEG, + .desc = "JPEG (YUV 4:2:2)", + .depth = 16, + .set_format = sn9c20x_set_jpeg + } +}; + +struct microdia_video_resolution ov7660_resolutions[] = { + { + .width = 160, + .height = 120, + .scale = SN9C20X_1_4_SCALE, + .window = {0, 17, 640, 480} + }, + { + .width = 320, + .height = 240, + .scale = SN9C20X_1_2_SCALE, + .window = {0, 7, 640, 480} + }, + { + .width = 640, + .height = 480, + .scale = SN9C20X_NO_SCALE, + .window = {0, 7, 640, 480} + }, +}; + +int ov7660_probe(struct usb_microdia *dev) +{ + int ret; + __u8 buf[2]; + dev->camera.sensor_slave_address = 0x30; + ret = sn9c20x_read_i2c_data(dev, 2, 0x0a, buf); + if (ret == 0) { + if (buf[0] != 0x76) + return -EINVAL; + if (buf[1] == 0x60) { + ov7660_initialize(dev); + dev->camera.set_exposure = ov7660_set_exposure; + dev->camera.set_auto_exposure = ov7660_set_autoexposure; + dev->camera.modes = ov7660_resolutions; + dev->camera.nmodes = ARRAY_SIZE(ov7660_resolutions); + dev->camera.fmts = ov7660_fmts; + dev->camera.nfmts = ARRAY_SIZE(ov7660_fmts); + return OV7660_SENSOR; + } + } else { + UDIA_INFO("Failed on i2c read in ov7660 probe\n"); + } + return -EINVAL; +} diff --git a/ov7660.h b/ov7660.h index e9f8e12..55b8d0f 100644 --- a/ov7660.h +++ b/ov7660.h @@ -163,5 +163,6 @@ int ov7660_initialize(struct usb_microdia *); int ov7660_set_exposure(struct usb_microdia *); int ov7660_set_autoexposure(struct usb_microdia *dev); +int ov7660_probe(struct usb_microdia *dev); #endif diff --git a/sn9c20x.c b/sn9c20x.c index a53f7bd..10be691 100644 --- a/sn9c20x.c +++ b/sn9c20x.c @@ -250,7 +250,11 @@ int sn9c20x_set_LEDs(struct usb_microdia *dev, int enable) led[0] = 0x40; led[1] = 0x60; break; -*/ default: +*/ case 0x627b: + led[0] = 0x40; + led[1] = 0x60; + break; + default: led[0] = 0x00; led[1] = 0x20; } -- 2.11.4.GIT