From: Antonio Ospite Date: Thu, 7 Apr 2011 10:21:38 +0000 (+0200) Subject: Add a configurable stream_flag field X-Git-Url: https://git.ao2.it/gspca_kinect.git/commitdiff_plain/9e125d30a241de93889d470b1aca684c39ab9e26 Add a configurable stream_flag field For now only video stream is supported which has stream_flag = 0x80, but having the value hardcoded in the sd_pkt_scan routine didn't look pretty. This way there is more flexibility in preparation for adding depth stream support. Signed-off-by: Antonio Ospite --- diff --git a/kinect.c b/kinect.c index 0d8acda..174caa8 100644 --- a/kinect.c +++ b/kinect.c @@ -56,8 +56,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 */ @@ -223,6 +224,10 @@ 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; @@ -321,22 +326,21 @@ static void sd_stopN(struct gspca_dev *gspca_dev) 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; }