From: Antonio Ospite Date: Fri, 17 Dec 2010 10:25:25 +0000 (+0100) Subject: Add 1280x1024 mode and UYUV pixel format. X-Git-Url: https://git.ao2.it/gspca_kinect.git/commitdiff_plain/e300459cf61b2167a588baf548bb98ad6e68220e?ds=inline Add 1280x1024 mode and UYUV pixel format. Also clean up setting registers in preparation for IR mode support. Signed-off-by: Antonio Ospite --- diff --git a/kinect.c b/kinect.c index c646490..1d7a74f 100644 --- a/kinect.c +++ b/kinect.c @@ -64,12 +64,30 @@ struct sd { static const struct ctrl sd_ctrls[] = { }; +#define MODE_640x480 0x0001 +#define MODE_1280x1024 0x0002 + +#define FORMAT_BAYER 0x0010 +#define FORMAT_UYUV 0x0020 + +#define FPS_HIGH 0x0100 + static const struct v4l2_pix_format color_camera_mode[] = { {640, 480, V4L2_PIX_FMT_SGRBG8, V4L2_FIELD_NONE, .bytesperline = 640, .sizeimage = 640 * 480, .colorspace = V4L2_COLORSPACE_SRGB, - .priv = 0}, + .priv = MODE_640x480 | FORMAT_BAYER | FPS_HIGH}, + {640, 480, V4L2_PIX_FMT_UYVY, V4L2_FIELD_NONE, + .bytesperline = 640 * 2, + .sizeimage = 640 * 480 * 2, + .colorspace = V4L2_COLORSPACE_SRGB, + .priv = MODE_640x480 | FORMAT_UYUV}, + {1280, 1024, V4L2_PIX_FMT_SGRBG8, V4L2_FIELD_NONE, + .bytesperline = 1280, + .sizeimage = 1280 * 1024, + .colorspace = V4L2_COLORSPACE_SRGB, + .priv = MODE_1280x1024 | FORMAT_BAYER}, }; static int kinect_write(struct usb_device *udev, uint8_t *data, uint16_t wLength) @@ -212,15 +230,45 @@ static int sd_init(struct gspca_dev *gspca_dev) static int sd_start(struct gspca_dev *gspca_dev) { - write_register(gspca_dev, 0x05, 0x00); // reset video stream - write_register(gspca_dev, 0x0c, 0x00); - write_register(gspca_dev, 0x0d, 0x01); - write_register(gspca_dev, 0x0e, 0x1e); // 30Hz bayer + int mode; + uint8_t fmt_reg, fmt_val; + uint8_t res_reg, res_val; + uint8_t fps_reg, fps_val; + + mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv; + + fmt_reg = 0x0c; + res_reg = 0x0d; + fps_reg = 0x0e; + + /* format */ + if (mode & FORMAT_UYUV) + fmt_val = 0x05; + else + fmt_val = 0x00; + + if (mode & MODE_1280x1024) + res_val = 0x02; + else + res_val = 0x01; + + if (mode & FPS_HIGH) + fps_val = 0x1e; + else + fps_val = 0x0f; + + /* Reset video stream */ + write_register(gspca_dev, 0x05, 0x00); + + write_register(gspca_dev, fmt_reg, fmt_val); + write_register(gspca_dev, res_reg, res_val); + write_register(gspca_dev, fps_reg, fps_val); - /* Video Format: Raw bayer data */ - write_register(gspca_dev, 0x05, 0x01); // start video stream + /* Start video stream */ + write_register(gspca_dev, 0x05, 0x01); - write_register(gspca_dev, 0x47, 0x00); // disable Hflip + /* disable Hflip */ + write_register(gspca_dev, 0x47, 0x00); return 0; }