X-Git-Url: https://git.ao2.it/gspca_kinect.git/blobdiff_plain/740d4aae827fcf03ed914dfe9beeb28e7f0395e6..3a445ab5c3e5844cf8ae5f1b369dc4a439c14b58:/kinect.c?ds=inline diff --git a/kinect.c b/kinect.c index 0322bad..6c16413 100644 --- a/kinect.c +++ b/kinect.c @@ -5,7 +5,10 @@ * * Based on the OpenKinect project and libfreenect * http://openkinect.org/wiki/Init_Analysis - * + * + * Special thanks to Steven Toth and kernellabs.com for sponsoring a Kinect + * sensor device which I tested the driver on. + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -56,8 +59,9 @@ typedef struct { /* specific webcam descriptor */ struct sd { - struct gspca_dev gspca_dev; /* !! must be the first item */ - uint16_t cam_tag; + struct gspca_dev gspca_dev; /* !! must be the first item */ + uint16_t cam_tag; /* a sequence number for packets */ + uint8_t stream_flag; /* to identify different steram types */ }; /* V4L2 controls supported by the driver */ @@ -147,7 +151,7 @@ static int send_cmd(struct gspca_dev *gspca_dev, uint16_t cmd, void *cmdbuf, memcpy(obuf+sizeof(*chdr), cmdbuf, cmd_len); res = kinect_write(udev, obuf, cmd_len + sizeof(*chdr)); - info("Control cmd=%04x tag=%04x len=%04x: %d", cmd, sd->cam_tag, cmd_len, res); + PDEBUG(D_USBO, "Control cmd=%04x tag=%04x len=%04x: %d", cmd, sd->cam_tag, cmd_len, res); if (res < 0) { err("send_cmd: Output control transfer failed (%d)", res); return res; @@ -156,7 +160,7 @@ static int send_cmd(struct gspca_dev *gspca_dev, uint16_t cmd, void *cmdbuf, do { actual_len = kinect_read(udev, ibuf, 0x200); } while (actual_len == 0); - info("Control reply: %d", res); + PDEBUG(D_USBO, "Control reply: %d", res); if (actual_len < sizeof(*rhdr)) { err("send_cmd: Input control transfer failed (%d)", res); return res; @@ -223,13 +227,20 @@ static int sd_config(struct gspca_dev *gspca_dev, sd->cam_tag = 0; + /* Only color camera is supported for now, + * which has stream flag = 0x80 */ + sd->stream_flag = 0x80; + cam = &gspca_dev->cam; cam->cam_mode = video_camera_mode; cam->nmodes = ARRAY_SIZE(video_camera_mode); - //cam->npkt = 15; - //gspca_dev->pkt_size = 960 * 2; +#if 0 + /* Setting those values is not needed for color camera */ + cam->npkt = 15; + gspca_dev->pkt_size = 960 * 2; +#endif return 0; } @@ -316,27 +327,27 @@ static int sd_start(struct gspca_dev *gspca_dev) static void sd_stopN(struct gspca_dev *gspca_dev) { - write_register(gspca_dev, 0x05, 0x00); // reset video stream + /* reset video stream */ + write_register(gspca_dev, 0x05, 0x00); } static void sd_pkt_scan(struct gspca_dev *gspca_dev, u8 *__data, int len) { - //struct sd *sd = (struct sd *) gspca_dev; - + struct sd *sd = (struct sd *) gspca_dev; + struct pkt_hdr *hdr = (void*)__data; uint8_t *data = __data + sizeof(*hdr); int datalen = len - sizeof(*hdr); - /* strm->flag == 0x80 for the color camera stream */ - uint8_t sof = 0x80 | 1; - uint8_t mof = 0x80 | 2; - uint8_t eof = 0x80 | 5; + uint8_t sof = sd->stream_flag | 1; + uint8_t mof = sd->stream_flag | 2; + uint8_t eof = sd->stream_flag | 5; if (len < 12) return; if (hdr->magic[0] != 'R' || hdr->magic[1] != 'B') { - warn("[Stream %02x] Invalid magic %02x%02x", 0x80, //strm->flag + warn("[Stream %02x] Invalid magic %02x%02x", sd->stream_flag, hdr->magic[0], hdr->magic[1]); return; } @@ -351,7 +362,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, u8 *__data, int len) gspca_frame_add(gspca_dev, LAST_PACKET, data, datalen); else - warn("Not recognized..."); + warn("Packet type not recognized..."); } /* sub-driver description */