X-Git-Url: https://git.ao2.it/gspca_kinect.git/blobdiff_plain/e300459cf61b2167a588baf548bb98ad6e68220e..ec3eb590d008fb33305fb7d21eaba560bc3494bb:/kinect.c diff --git a/kinect.c b/kinect.c index 1d7a74f..883db90 100644 --- a/kinect.c +++ b/kinect.c @@ -65,14 +65,16 @@ static const struct ctrl sd_ctrls[] = { }; #define MODE_640x480 0x0001 -#define MODE_1280x1024 0x0002 +#define MODE_640x488 0x0002 +#define MODE_1280x1024 0x0004 #define FORMAT_BAYER 0x0010 -#define FORMAT_UYUV 0x0020 +#define FORMAT_UYVY 0x0020 +#define FORMAT_Y10B 0x0040 #define FPS_HIGH 0x0100 -static const struct v4l2_pix_format color_camera_mode[] = { +static const struct v4l2_pix_format video_camera_mode[] = { {640, 480, V4L2_PIX_FMT_SGRBG8, V4L2_FIELD_NONE, .bytesperline = 640, .sizeimage = 640 * 480, @@ -82,12 +84,22 @@ static const struct v4l2_pix_format color_camera_mode[] = { .bytesperline = 640 * 2, .sizeimage = 640 * 480 * 2, .colorspace = V4L2_COLORSPACE_SRGB, - .priv = MODE_640x480 | FORMAT_UYUV}, + .priv = MODE_640x480 | FORMAT_UYVY}, {1280, 1024, V4L2_PIX_FMT_SGRBG8, V4L2_FIELD_NONE, .bytesperline = 1280, .sizeimage = 1280 * 1024, .colorspace = V4L2_COLORSPACE_SRGB, .priv = MODE_1280x1024 | FORMAT_BAYER}, + {640, 488, V4L2_PIX_FMT_Y10BPACK, V4L2_FIELD_NONE, + .bytesperline = 640 * 10 / 8, + .sizeimage = 640 * 488 * 10 / 8, + .colorspace = V4L2_COLORSPACE_SRGB, + .priv = MODE_640x488 | FORMAT_Y10B | FPS_HIGH}, + {1280, 1024, V4L2_PIX_FMT_Y10BPACK, V4L2_FIELD_NONE, + .bytesperline = 1280 * 10 / 8, + .sizeimage = 1280 * 1024 * 10 / 8, + .colorspace = V4L2_COLORSPACE_SRGB, + .priv = MODE_1280x1024 | FORMAT_Y10B}, }; static int kinect_write(struct usb_device *udev, uint8_t *data, uint16_t wLength) @@ -211,8 +223,8 @@ static int sd_config(struct gspca_dev *gspca_dev, cam = &gspca_dev->cam; - cam->cam_mode = color_camera_mode; - cam->nmodes = ARRAY_SIZE(color_camera_mode); + cam->cam_mode = video_camera_mode; + cam->nmodes = ARRAY_SIZE(video_camera_mode); //cam->npkt = 15; //gspca_dev->pkt_size = 960 * 2; @@ -234,15 +246,24 @@ static int sd_start(struct gspca_dev *gspca_dev) uint8_t fmt_reg, fmt_val; uint8_t res_reg, res_val; uint8_t fps_reg, fps_val; + uint8_t mode_val; mode = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].priv; - fmt_reg = 0x0c; - res_reg = 0x0d; - fps_reg = 0x0e; + if (mode & FORMAT_Y10B) { + fmt_reg = 0x19; + res_reg = 0x1a; + fps_reg = 0x1b; + mode_val = 0x03; + } else { + fmt_reg = 0x0c; + res_reg = 0x0d; + fps_reg = 0x0e; + mode_val = 0x01; + } /* format */ - if (mode & FORMAT_UYUV) + if (mode & FORMAT_UYVY) fmt_val = 0x05; else fmt_val = 0x00; @@ -257,15 +278,33 @@ static int sd_start(struct gspca_dev *gspca_dev) else fps_val = 0x0f; + + /* turn off IR-reset function */ + write_register(gspca_dev, 0x105, 0x00); + /* Reset video stream */ write_register(gspca_dev, 0x05, 0x00); + /* Due to some ridiculous condition in the firmware, we have to start + * and stop the depth stream before the camera will hand us 1280x1024 + * IR. This is a stupid workaround, but we've yet to find a better + * solution. + * + * Thanks to Drew Fisher for figuring this out. + */ + if (mode & (FORMAT_Y10B | MODE_1280x1024)) { + write_register(gspca_dev, 0x13, 0x01); + write_register(gspca_dev, 0x14, 0x1e); + write_register(gspca_dev, 0x06, 0x02); + write_register(gspca_dev, 0x06, 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); /* Start video stream */ - write_register(gspca_dev, 0x05, 0x01); + write_register(gspca_dev, 0x05, mode_val); /* disable Hflip */ write_register(gspca_dev, 0x47, 0x00);