summaryrefslogtreecommitdiff
path: root/linux/drivers/media/video/gspca
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2009-03-10 02:33:02 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-10 02:33:02 -0300
commita5f0c1eb5516fb321c59ba6adb6437288b5b20bf (patch)
tree130b457eae2dd2e44bd82889b24c69d337682242 /linux/drivers/media/video/gspca
parent9469f9975ef9cd00fb23ec27109511c4b2a27350 (diff)
parentb08b8d66d6c66efb91344fad801cabb14ced6c33 (diff)
downloadmediapointer-dvb-s2-a5f0c1eb5516fb321c59ba6adb6437288b5b20bf.tar.gz
mediapointer-dvb-s2-a5f0c1eb5516fb321c59ba6adb6437288b5b20bf.tar.bz2
merge: http://linuxtv.org/hg/~mkrufky/dibcom
From: Mauro Carvalho Chehab <mchehab@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'linux/drivers/media/video/gspca')
-rw-r--r--linux/drivers/media/video/gspca/gspca.c4
-rw-r--r--linux/drivers/media/video/gspca/m5602/m5602_s5k4aa.c6
-rw-r--r--linux/drivers/media/video/gspca/mars.c23
-rw-r--r--linux/drivers/media/video/gspca/sq905.c100
-rw-r--r--linux/drivers/media/video/gspca/vc032x.c2
5 files changed, 78 insertions, 57 deletions
diff --git a/linux/drivers/media/video/gspca/gspca.c b/linux/drivers/media/video/gspca/gspca.c
index 8d78b9287..d629ce1dc 100644
--- a/linux/drivers/media/video/gspca/gspca.c
+++ b/linux/drivers/media/video/gspca/gspca.c
@@ -1111,7 +1111,6 @@ static int vidioc_s_audio(struct file *file, void *priv,
static int vidioc_g_audio(struct file *file, void *priv,
struct v4l2_audio *audio)
{
- memset(audio, 0, sizeof *audio);
strcpy(audio->name, "Microphone");
return 0;
}
@@ -1145,7 +1144,6 @@ static int vidioc_enum_input(struct file *file, void *priv,
if (input->index != 0)
return -EINVAL;
- memset(input, 0, sizeof *input);
input->type = V4L2_INPUT_TYPE_CAMERA;
strncpy(input->name, gspca_dev->sd_desc->name,
sizeof input->name);
@@ -1353,7 +1351,6 @@ static int vidioc_g_parm(struct file *filp, void *priv,
{
struct gspca_dev *gspca_dev = priv;
- memset(parm, 0, sizeof *parm);
parm->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
parm->parm.capture.readbuffers = gspca_dev->nbufread;
@@ -1423,7 +1420,6 @@ static int vidiocgmbuf(struct file *file, void *priv,
{
struct v4l2_format fmt;
- memset(&fmt, 0, sizeof fmt);
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
i = gspca_dev->cam.nmodes - 1; /* highest mode */
fmt.fmt.pix.width = gspca_dev->cam.cam_mode[i].width;
diff --git a/linux/drivers/media/video/gspca/m5602/m5602_s5k4aa.c b/linux/drivers/media/video/gspca/m5602/m5602_s5k4aa.c
index 2bd7d4d99..7e79f7eca 100644
--- a/linux/drivers/media/video/gspca/m5602/m5602_s5k4aa.c
+++ b/linux/drivers/media/video/gspca/m5602/m5602_s5k4aa.c
@@ -104,7 +104,11 @@ int s5k4aa_probe(struct sd *sd)
}
/* Test some registers, but we don't know their exact meaning yet */
- if (m5602_read_sensor(sd, 0x00, prod_id, sizeof(prod_id)))
+ if (m5602_read_sensor(sd, 0x00, prod_id, 2))
+ return -ENODEV;
+ if (m5602_read_sensor(sd, 0x02, prod_id+2, 2))
+ return -ENODEV;
+ if (m5602_read_sensor(sd, 0x04, prod_id+4, 2))
return -ENODEV;
if (memcmp(prod_id, expected_prod_id, sizeof(prod_id)))
diff --git a/linux/drivers/media/video/gspca/mars.c b/linux/drivers/media/video/gspca/mars.c
index c5a19b5bc..5d54893eb 100644
--- a/linux/drivers/media/video/gspca/mars.c
+++ b/linux/drivers/media/video/gspca/mars.c
@@ -69,10 +69,10 @@ static struct ctrl sd_ctrls[] = {
.id = V4L2_CID_SATURATION,
.type = V4L2_CTRL_TYPE_INTEGER,
.name = "Color",
- .minimum = 0,
- .maximum = 220,
+ .minimum = 1,
+ .maximum = 255,
.step = 1,
-#define COLOR_DEF 190
+#define COLOR_DEF 200
.default_value = COLOR_DEF,
},
.set = sd_setcolors,
@@ -191,7 +191,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
struct sd *sd = (struct sd *) gspca_dev;
int err_code;
u8 *data;
- int i, val;
+ int i;
data = gspca_dev->usb_buf;
@@ -253,9 +253,11 @@ static int sd_start(struct gspca_dev *gspca_dev)
data[1] = 0; /* reg 94, Y Gain (auto) */
#if 1
/*jfm: from win trace*/
- val = sd->colors * 0x40 + 0x400;
- data[2] = val; /* reg 0x5f/0x60 (LE) = saturation */
- data[3] = val >> 8;
+ /* reg 0x5f/0x60 (LE) = saturation */
+ /* h (60): xxxx x100
+ * l (5f): xxxx x000 */
+ data[2] = sd->colors << 3;
+ data[3] = ((sd->colors >> 2) & 0xf8) | 0x04;
data[4] = sd->brightness; /* reg 0x61 = brightness */
data[5] = 0x00;
#else
@@ -403,10 +405,11 @@ static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val)
sd->colors = val;
if (gspca_dev->streaming) {
- val = val * 0x40 + 0x400;
+
+ /* see sd_start */
gspca_dev->usb_buf[0] = 0x5f;
- gspca_dev->usb_buf[1] = val;
- gspca_dev->usb_buf[2] = val >> 8;
+ gspca_dev->usb_buf[1] = sd->colors << 3;
+ gspca_dev->usb_buf[2] = ((sd->colors >> 2) & 0xf8) | 0x04;
reg_w(gspca_dev, 3);
}
return 0;
diff --git a/linux/drivers/media/video/gspca/sq905.c b/linux/drivers/media/video/gspca/sq905.c
index dafaed69e..da60eea51 100644
--- a/linux/drivers/media/video/gspca/sq905.c
+++ b/linux/drivers/media/video/gspca/sq905.c
@@ -60,23 +60,29 @@ MODULE_LICENSE("GPL");
#define SQ905_PING 0x07 /* when reading an "idling" command */
#define SQ905_READ_DONE 0xc0 /* ack bulk read completed */
+/* Any non-zero value in the bottom 2 bits of the 2nd byte of
+ * the ID appears to indicate the camera can do 640*480. If the
+ * LSB of that byte is set the image is just upside down, otherwise
+ * it is rotated 180 degrees. */
+#define SQ905_HIRES_MASK 0x00000300
+#define SQ905_ORIENTATION_MASK 0x00000100
+
/* Some command codes. These go in the "index" slot. */
#define SQ905_ID 0xf0 /* asks for model string */
#define SQ905_CONFIG 0x20 /* gets photo alloc. table, not used here */
#define SQ905_DATA 0x30 /* accesses photo data, not used here */
#define SQ905_CLEAR 0xa0 /* clear everything */
-#define SQ905_CAPTURE_LOW 0x60 /* Starts capture at 160x120 */
-#define SQ905_CAPTURE_MED 0x61 /* Starts capture at 320x240 */
+#define SQ905_CAPTURE_LOW 0x60 /* Starts capture at 160x120 */
+#define SQ905_CAPTURE_MED 0x61 /* Starts capture at 320x240 */
+#define SQ905_CAPTURE_HIGH 0x62 /* Starts capture at 640x480 (some cams only) */
/* note that the capture command also controls the output dimensions */
-/* 0x60 -> 160x120, 0x61 -> 320x240 0x62 -> 640x480 depends on camera */
-/* 0x62 is not correct, at least for some cams. Should be 0x63 ? */
/* Structure to hold all of our device specific stuff */
struct sd {
struct gspca_dev gspca_dev; /* !! must be the first item */
- u8 cam_type;
+ const struct v4l2_pix_format *cap_mode;
/*
* Driver stuff
@@ -85,33 +91,24 @@ struct sd {
struct workqueue_struct *work_thread;
};
-/* The driver only supports 320x240 so far. */
-static struct v4l2_pix_format sq905_mode[1] = {
+static struct v4l2_pix_format sq905_mode[] = {
+ { 160, 120, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
+ .bytesperline = 160,
+ .sizeimage = 160 * 120,
+ .colorspace = V4L2_COLORSPACE_SRGB,
+ .priv = 0},
{ 320, 240, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
.bytesperline = 320,
.sizeimage = 320 * 240,
.colorspace = V4L2_COLORSPACE_SRGB,
+ .priv = 0},
+ { 640, 480, V4L2_PIX_FMT_SBGGR8, V4L2_FIELD_NONE,
+ .bytesperline = 640,
+ .sizeimage = 640 * 480,
+ .colorspace = V4L2_COLORSPACE_SRGB,
.priv = 0}
};
-struct cam_type {
- u32 ident_word;
- char *name;
- struct v4l2_pix_format *min_mode;
- u8 num_modes;
- u8 sensor_flags;
-};
-
-#define SQ905_FLIP_HORIZ (1 << 0)
-#define SQ905_FLIP_VERT (1 << 1)
-
-/* Last entry is default if nothing else matches */
-static struct cam_type cam_types[] = {
- { 0x19010509, "PocketCam", &sq905_mode[0], 1, SQ905_FLIP_HORIZ },
- { 0x32010509, "Magpix", &sq905_mode[0], 1, SQ905_FLIP_HORIZ },
- { 0, "Default", &sq905_mode[0], 1, SQ905_FLIP_HORIZ | SQ905_FLIP_VERT }
-};
-
/*
* Send a command to the camera.
*/
@@ -240,7 +237,7 @@ static void sq905_dostream(struct work_struct *work)
/* request some data and then read it until we have
* a complete frame. */
- bytes_left = sq905_mode[0].sizeimage + FRAME_HEADER_LEN;
+ bytes_left = dev->cap_mode->sizeimage + FRAME_HEADER_LEN;
header_read = 0;
discarding = 0;
@@ -272,11 +269,18 @@ static void sq905_dostream(struct work_struct *work)
packet_type = INTER_PACKET;
}
frame = gspca_get_i_frame(gspca_dev);
- if (frame && !discarding)
+ if (frame && !discarding) {
gspca_frame_add(gspca_dev, packet_type,
frame, data, data_len);
- else
+ /* If entire frame fits in one packet we still
+ need to add a LAST_PACKET */
+ if ((packet_type == FIRST_PACKET) &&
+ (bytes_left == 0))
+ gspca_frame_add(gspca_dev, LAST_PACKET,
+ frame, data, 0);
+ } else {
discarding = 1;
+ }
}
/* acknowledge the frame */
mutex_lock(&gspca_dev->usb_lock);
@@ -301,8 +305,6 @@ static int sd_config(struct gspca_dev *gspca_dev,
struct cam *cam = &gspca_dev->cam;
struct sd *dev = (struct sd *) gspca_dev;
- cam->cam_mode = sq905_mode;
- cam->nmodes = 1;
/* We don't use the buffer gspca allocates so make it small. */
cam->bulk_size = 64;
@@ -328,7 +330,6 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
/* this function is called at probe and resume time */
static int sd_init(struct gspca_dev *gspca_dev)
{
- struct sd *dev = (struct sd *) gspca_dev;
u32 ident;
int ret;
@@ -344,17 +345,18 @@ static int sd_init(struct gspca_dev *gspca_dev)
ret = sq905_read_data(gspca_dev, gspca_dev->usb_buf, 4);
if (ret < 0)
return ret;
- /* usb_buf is allocated with kmalloc so is aligned. */
- ident = le32_to_cpup((u32 *)gspca_dev->usb_buf);
+ /* usb_buf is allocated with kmalloc so is aligned.
+ * Camera model number is the right way round if we assume this
+ * reverse engineered ID is supposed to be big endian. */
+ ident = be32_to_cpup((__be32 *)gspca_dev->usb_buf);
ret = sq905_command(gspca_dev, SQ905_CLEAR);
if (ret < 0)
return ret;
- dev->cam_type = 0;
- while (dev->cam_type < ARRAY_SIZE(cam_types) - 1 &&
- ident != cam_types[dev->cam_type].ident_word)
- dev->cam_type++;
- PDEBUG(D_CONF, "SQ905 camera %s, ID %08x detected",
- cam_types[dev->cam_type].name, ident);
+ PDEBUG(D_CONF, "SQ905 camera ID %08x detected", ident);
+ gspca_dev->cam.cam_mode = sq905_mode;
+ gspca_dev->cam.nmodes = ARRAY_SIZE(sq905_mode);
+ if (!(ident & SQ905_HIRES_MASK))
+ gspca_dev->cam.nmodes--;
return 0;
}
@@ -364,13 +366,29 @@ static int sd_start(struct gspca_dev *gspca_dev)
struct sd *dev = (struct sd *) gspca_dev;
int ret;
+ /* Set capture mode based on selected resolution. */
+ dev->cap_mode = gspca_dev->cam.cam_mode;
/* "Open the shutter" and set size, to start capture */
- ret = sq905_command(&dev->gspca_dev, SQ905_CAPTURE_MED);
+ switch (gspca_dev->width) {
+ case 640:
+ PDEBUG(D_STREAM, "Start streaming at high resolution");
+ dev->cap_mode += 2;
+ ret = sq905_command(&dev->gspca_dev, SQ905_CAPTURE_HIGH);
+ break;
+ case 320:
+ PDEBUG(D_STREAM, "Start streaming at medium resolution");
+ dev->cap_mode++;
+ ret = sq905_command(&dev->gspca_dev, SQ905_CAPTURE_MED);
+ break;
+ default:
+ PDEBUG(D_STREAM, "Start streaming at low resolution");
+ ret = sq905_command(&dev->gspca_dev, SQ905_CAPTURE_LOW);
+ }
+
if (ret < 0) {
PDEBUG(D_ERR, "Start streaming command failed");
return ret;
}
-
/* Start the workqueue function to do the streaming */
dev->work_thread = create_singlethread_workqueue(MODULE_NAME);
queue_work(dev->work_thread, &dev->work_struct);
diff --git a/linux/drivers/media/video/gspca/vc032x.c b/linux/drivers/media/video/gspca/vc032x.c
index 72cbf56c9..f1c149476 100644
--- a/linux/drivers/media/video/gspca/vc032x.c
+++ b/linux/drivers/media/video/gspca/vc032x.c
@@ -2316,7 +2316,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
break;
case SENSOR_MI1310_SOC:
GammaT = mi1320_gamma;
- MatrixT = mi0360_matrix;
+ MatrixT = mi1320_matrix;
switch (mode) {
case 1:
init = mi1310_socinitQVGA_JPG; /* 320x240 */