projects
/
gspca_kinect.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add a configurable stream_flag field
[gspca_kinect.git]
/
kinect.c
diff --git
a/kinect.c
b/kinect.c
index
883db90
..
174caa8
100644
(file)
--- a/
kinect.c
+++ b/
kinect.c
@@
-1,9
+1,9
@@
/*
* kinect sensor device camera, gspca driver
*
/*
* kinect sensor device camera, gspca driver
*
- * Copyright (C) 201
0
Antonio Ospite <ospite@studenti.unina.it>
+ * Copyright (C) 201
1
Antonio Ospite <ospite@studenti.unina.it>
*
*
- * Based on the OpenKinect project and libfreenect
by Ector Martin
+ * Based on the OpenKinect project and libfreenect
* http://openkinect.org/wiki/Init_Analysis
*
* This program is free software; you can redistribute it and/or modify
* http://openkinect.org/wiki/Init_Analysis
*
* This program is free software; you can redistribute it and/or modify
@@
-31,6
+31,11
@@
MODULE_AUTHOR("Antonio Ospite <ospite@studenti.unina.it>");
MODULE_DESCRIPTION("GSPCA/Kinect Sensor Device USB Camera Driver");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("GSPCA/Kinect Sensor Device USB Camera Driver");
MODULE_LICENSE("GPL");
+#ifdef DEBUG
+int gspca_debug = D_ERR | D_PROBE | D_CONF | D_STREAM | D_FRAM | D_PACK |
+ D_USBI | D_USBO | D_V4L2;
+#endif
+
struct pkt_hdr {
uint8_t magic[2];
uint8_t pad;
struct pkt_hdr {
uint8_t magic[2];
uint8_t pad;
@@
-49,13
+54,11
@@
typedef struct {
uint16_t tag;
} cam_hdr;
uint16_t tag;
} cam_hdr;
-int gspca_debug = D_ERR | D_PROBE | D_CONF | D_STREAM | D_FRAM | D_PACK |
- D_USBI | D_USBO | D_V4L2;
-
/* specific webcam descriptor */
struct sd {
/* 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 */
};
/* V4L2 controls supported by the driver */
@@
-145,7
+148,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));
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;
if (res < 0) {
err("send_cmd: Output control transfer failed (%d)", res);
return res;
@@
-154,7
+157,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);
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;
if (actual_len < sizeof(*rhdr)) {
err("send_cmd: Input control transfer failed (%d)", res);
return res;
@@
-221,6
+224,10
@@
static int sd_config(struct gspca_dev *gspca_dev,
sd->cam_tag = 0;
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 = &gspca_dev->cam;
cam->cam_mode = video_camera_mode;
@@
-319,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)
{
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);
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') {
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;
}
hdr->magic[0], hdr->magic[1]);
return;
}