aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video
diff options
context:
space:
mode:
authorLuc Saillard <luc@saillard.org>2007-04-22 22:54:36 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-04-27 14:45:50 -0400
commit9ee6d78cd4112c0f5a257a01383c64dadbf66da9 (patch)
tree6a240c9938d7970c5d13c40dcc21b20fb3c3369e /drivers/media/video
parent1de69238111a65283a4548d8fd4727397873a02f (diff)
V4L/DVB (5547): Add ENUM_FRAMESIZES and ENUM_FRAMEINTERVALS ioctls
This patch add support for the VIDIOC_ENUM_FRAMESIZES and VIDIOC_ENUM_FRAMEINTERVALS ioctl. * check if the maximum native framesize for raw mode is correct * raw mode framerates for all three chipset types Signed-off-by: Gregor Jasny <gjasny@web.de> Signed-off-by: Luc Saillard <luc@saillard.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video')
-rw-r--r--drivers/media/video/pwc/pwc-ctrl.c61
-rw-r--r--drivers/media/video/pwc/pwc-if.c2
-rw-r--r--drivers/media/video/pwc/pwc-ioctl.h36
-rw-r--r--drivers/media/video/pwc/pwc-kiara.c2
-rw-r--r--drivers/media/video/pwc/pwc-kiara.h5
-rw-r--r--drivers/media/video/pwc/pwc-timon.c4
-rw-r--r--drivers/media/video/pwc/pwc-timon.h6
-rw-r--r--drivers/media/video/pwc/pwc-v4l.c58
-rw-r--r--drivers/media/video/pwc/pwc.h5
9 files changed, 168 insertions, 11 deletions
diff --git a/drivers/media/video/pwc/pwc-ctrl.c b/drivers/media/video/pwc/pwc-ctrl.c
index 0bd115588f31..338ced7188f2 100644
--- a/drivers/media/video/pwc/pwc-ctrl.c
+++ b/drivers/media/video/pwc/pwc-ctrl.c
@@ -140,6 +140,8 @@ static const char *size2name[PSZ_MAX] =
140 An alternate value of 0 means this mode is not available at all. 140 An alternate value of 0 means this mode is not available at all.
141 */ 141 */
142 142
143#define PWC_FPS_MAX_NALA 8
144
143struct Nala_table_entry { 145struct Nala_table_entry {
144 char alternate; /* USB alternate setting */ 146 char alternate; /* USB alternate setting */
145 int compressed; /* Compressed yes/no */ 147 int compressed; /* Compressed yes/no */
@@ -147,7 +149,9 @@ struct Nala_table_entry {
147 unsigned char mode[3]; /* precomputed mode table */ 149 unsigned char mode[3]; /* precomputed mode table */
148}; 150};
149 151
150static struct Nala_table_entry Nala_table[PSZ_MAX][8] = 152static unsigned int Nala_fps_vector[PWC_FPS_MAX_NALA] = { 4, 5, 7, 10, 12, 15, 20, 24 };
153
154static struct Nala_table_entry Nala_table[PSZ_MAX][PWC_FPS_MAX_NALA] =
151{ 155{
152#include "pwc-nala.h" 156#include "pwc-nala.h"
153}; 157};
@@ -423,6 +427,59 @@ int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int frame
423 return 0; 427 return 0;
424} 428}
425 429
430static unsigned int pwc_get_fps_Nala(struct pwc_device *pdev, unsigned int index, unsigned int size)
431{
432 unsigned int i;
433
434 for (i = 0; i < PWC_FPS_MAX_NALA; i++) {
435 if (Nala_table[size][i].alternate) {
436 if (index--==0) return Nala_fps_vector[i];
437 }
438 }
439 return 0;
440}
441
442static unsigned int pwc_get_fps_Kiara(struct pwc_device *pdev, unsigned int index, unsigned int size)
443{
444 unsigned int i;
445
446 for (i = 0; i < PWC_FPS_MAX_KIARA; i++) {
447 if (Kiara_table[size][i][3].alternate) {
448 if (index--==0) return Kiara_fps_vector[i];
449 }
450 }
451 return 0;
452}
453
454static unsigned int pwc_get_fps_Timon(struct pwc_device *pdev, unsigned int index, unsigned int size)
455{
456 unsigned int i;
457
458 for (i=0; i < PWC_FPS_MAX_TIMON; i++) {
459 if (Timon_table[size][i][3].alternate) {
460 if (index--==0) return Timon_fps_vector[i];
461 }
462 }
463 return 0;
464}
465
466unsigned int pwc_get_fps(struct pwc_device *pdev, unsigned int index, unsigned int size)
467{
468 unsigned int ret;
469
470 if (DEVICE_USE_CODEC1(pdev->type)) {
471 ret = pwc_get_fps_Nala(pdev, index, size);
472
473 } else if (DEVICE_USE_CODEC3(pdev->type)) {
474 ret = pwc_get_fps_Kiara(pdev, index, size);
475
476 } else {
477 ret = pwc_get_fps_Timon(pdev, index, size);
478 }
479
480 return ret;
481}
482
426#define BLACK_Y 0 483#define BLACK_Y 0
427#define BLACK_U 128 484#define BLACK_U 128
428#define BLACK_V 128 485#define BLACK_V 128
@@ -1343,7 +1400,7 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
1343 ret = pwc_read_red_gain(pdev, &ARGR(wb).read_red); 1400 ret = pwc_read_red_gain(pdev, &ARGR(wb).read_red);
1344 if (ret < 0) 1401 if (ret < 0)
1345 break; 1402 break;
1346 ret =pwc_read_blue_gain(pdev, &ARGR(wb).read_blue); 1403 ret = pwc_read_blue_gain(pdev, &ARGR(wb).read_blue);
1347 if (ret < 0) 1404 if (ret < 0)
1348 break; 1405 break;
1349 } 1406 }
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c
index 6f091088d1c7..085332a503de 100644
--- a/drivers/media/video/pwc/pwc-if.c
+++ b/drivers/media/video/pwc/pwc-if.c
@@ -1493,7 +1493,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1493 case 0x0329: 1493 case 0x0329:
1494 PWC_INFO("Philips SPC 900NC USB webcam detected.\n"); 1494 PWC_INFO("Philips SPC 900NC USB webcam detected.\n");
1495 name = "Philips SPC 900NC webcam"; 1495 name = "Philips SPC 900NC webcam";
1496 type_id = 720; 1496 type_id = 740;
1497 break; 1497 break;
1498 default: 1498 default:
1499 return -ENODEV; 1499 return -ENODEV;
diff --git a/drivers/media/video/pwc/pwc-ioctl.h b/drivers/media/video/pwc/pwc-ioctl.h
index 784bc72521fa..cec660299768 100644
--- a/drivers/media/video/pwc/pwc-ioctl.h
+++ b/drivers/media/video/pwc/pwc-ioctl.h
@@ -2,7 +2,7 @@
2#define PWC_IOCTL_H 2#define PWC_IOCTL_H
3 3
4/* (C) 2001-2004 Nemosoft Unv. 4/* (C) 2001-2004 Nemosoft Unv.
5 (C) 2004 Luc Saillard (luc@saillard.org) 5 (C) 2004-2006 Luc Saillard (luc@saillard.org)
6 6
7 NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx 7 NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
8 driver and thus may have bugs that are not present in the original version. 8 driver and thus may have bugs that are not present in the original version.
@@ -25,7 +25,7 @@
25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26*/ 26*/
27 27
28/* This is pwc-ioctl.h belonging to PWC 8.12.1 28/* This is pwc-ioctl.h belonging to PWC 10.0.10
29 It contains structures and defines to communicate from user space 29 It contains structures and defines to communicate from user space
30 directly to the driver. 30 directly to the driver.
31 */ 31 */
@@ -51,6 +51,9 @@
51 ... the function 51 ... the function
52 */ 52 */
53 53
54#include <linux/types.h>
55#include <linux/version.h>
56
54 57
55 /* Enumeration of image sizes */ 58 /* Enumeration of image sizes */
56#define PSZ_SQCIF 0x00 59#define PSZ_SQCIF 0x00
@@ -65,6 +68,8 @@
65/* The frame rate is encoded in the video_window.flags parameter using 68/* The frame rate is encoded in the video_window.flags parameter using
66 the upper 16 bits, since some flags are defined nowadays. The following 69 the upper 16 bits, since some flags are defined nowadays. The following
67 defines provide a mask and shift to filter out this value. 70 defines provide a mask and shift to filter out this value.
71 This value can also be passing using the private flag when using v4l2 and
72 VIDIOC_S_FMT ioctl.
68 73
69 In 'Snapshot' mode the camera freezes its automatic exposure and colour 74 In 'Snapshot' mode the camera freezes its automatic exposure and colour
70 balance controls. 75 balance controls.
@@ -73,6 +78,8 @@
73#define PWC_FPS_MASK 0x00FF0000 78#define PWC_FPS_MASK 0x00FF0000
74#define PWC_FPS_FRMASK 0x003F0000 79#define PWC_FPS_FRMASK 0x003F0000
75#define PWC_FPS_SNAPSHOT 0x00400000 80#define PWC_FPS_SNAPSHOT 0x00400000
81#define PWC_QLT_MASK 0x03000000
82#define PWC_QLT_SHIFT 24
76 83
77 84
78/* structure for transferring x & y coordinates */ 85/* structure for transferring x & y coordinates */
@@ -289,4 +296,29 @@ struct pwc_table_init_buffer {
289}; 296};
290#define VIDIOCPWCGVIDTABLE _IOR('v', 216, struct pwc_table_init_buffer) 297#define VIDIOCPWCGVIDTABLE _IOR('v', 216, struct pwc_table_init_buffer)
291 298
299/*
300 * This is private command used when communicating with v4l2.
301 * In the future all private ioctl will be remove/replace to
302 * use interface offer by v4l2.
303 */
304
305#define V4L2_CID_PRIVATE_SAVE_USER (V4L2_CID_PRIVATE_BASE + 0)
306#define V4L2_CID_PRIVATE_RESTORE_USER (V4L2_CID_PRIVATE_BASE + 1)
307#define V4L2_CID_PRIVATE_RESTORE_FACTORY (V4L2_CID_PRIVATE_BASE + 2)
308#define V4L2_CID_PRIVATE_COLOUR_MODE (V4L2_CID_PRIVATE_BASE + 3)
309#define V4L2_CID_PRIVATE_AUTOCONTOUR (V4L2_CID_PRIVATE_BASE + 4)
310#define V4L2_CID_PRIVATE_CONTOUR (V4L2_CID_PRIVATE_BASE + 5)
311#define V4L2_CID_PRIVATE_BACKLIGHT (V4L2_CID_PRIVATE_BASE + 6)
312#define V4L2_CID_PRIVATE_FLICKERLESS (V4L2_CID_PRIVATE_BASE + 7)
313#define V4L2_CID_PRIVATE_NOISE_REDUCTION (V4L2_CID_PRIVATE_BASE + 8)
314
315struct pwc_raw_frame {
316 __le16 type; /* type of the webcam */
317 __le16 vbandlength; /* Size of 4lines compressed (used by the decompressor) */
318 __u8 cmd[4]; /* the four byte of the command (in case of nala,
319 only the first 3 bytes is filled) */
320 __u8 rawframe[0]; /* frame_size = H/4*vbandlength */
321} __attribute__ ((packed));
322
323
292#endif 324#endif
diff --git a/drivers/media/video/pwc/pwc-kiara.c b/drivers/media/video/pwc/pwc-kiara.c
index fec39cc5a9f1..f4ae83c0cf2b 100644
--- a/drivers/media/video/pwc/pwc-kiara.c
+++ b/drivers/media/video/pwc/pwc-kiara.c
@@ -42,6 +42,8 @@
42#include "pwc-kiara.h" 42#include "pwc-kiara.h"
43#include "pwc-uncompress.h" 43#include "pwc-uncompress.h"
44 44
45const unsigned int Kiara_fps_vector[PWC_FPS_MAX_KIARA] = { 5, 10, 15, 20, 25, 30 };
46
45const struct Kiara_table_entry Kiara_table[PSZ_MAX][6][4] = 47const struct Kiara_table_entry Kiara_table[PSZ_MAX][6][4] =
46{ 48{
47 /* SQCIF */ 49 /* SQCIF */
diff --git a/drivers/media/video/pwc/pwc-kiara.h b/drivers/media/video/pwc/pwc-kiara.h
index 0bdb22547d86..047dad8c15f7 100644
--- a/drivers/media/video/pwc/pwc-kiara.h
+++ b/drivers/media/video/pwc/pwc-kiara.h
@@ -29,6 +29,8 @@
29 29
30#include <media/pwc-ioctl.h> 30#include <media/pwc-ioctl.h>
31 31
32#define PWC_FPS_MAX_KIARA 6
33
32struct Kiara_table_entry 34struct Kiara_table_entry
33{ 35{
34 char alternate; /* USB alternate interface */ 36 char alternate; /* USB alternate interface */
@@ -37,8 +39,9 @@ struct Kiara_table_entry
37 unsigned char mode[12]; /* precomputed mode settings for cam */ 39 unsigned char mode[12]; /* precomputed mode settings for cam */
38}; 40};
39 41
40extern const struct Kiara_table_entry Kiara_table[PSZ_MAX][6][4]; 42extern const struct Kiara_table_entry Kiara_table[PSZ_MAX][PWC_FPS_MAX_KIARA][4];
41extern const unsigned int KiaraRomTable[8][2][16][8]; 43extern const unsigned int KiaraRomTable[8][2][16][8];
44extern const unsigned int Kiara_fps_vector[PWC_FPS_MAX_KIARA];
42 45
43#endif 46#endif
44 47
diff --git a/drivers/media/video/pwc/pwc-timon.c b/drivers/media/video/pwc/pwc-timon.c
index be65bdcd195b..c56c174b161c 100644
--- a/drivers/media/video/pwc/pwc-timon.c
+++ b/drivers/media/video/pwc/pwc-timon.c
@@ -40,7 +40,9 @@
40 40
41#include "pwc-timon.h" 41#include "pwc-timon.h"
42 42
43const struct Timon_table_entry Timon_table[PSZ_MAX][6][4] = 43const unsigned int Timon_fps_vector[PWC_FPS_MAX_TIMON] = { 5, 10, 15, 20, 25, 30 };
44
45const struct Timon_table_entry Timon_table[PSZ_MAX][PWC_FPS_MAX_TIMON][4] =
44{ 46{
45 /* SQCIF */ 47 /* SQCIF */
46 { 48 {
diff --git a/drivers/media/video/pwc/pwc-timon.h b/drivers/media/video/pwc/pwc-timon.h
index eef9e2cd4320..a6e22224c95f 100644
--- a/drivers/media/video/pwc/pwc-timon.h
+++ b/drivers/media/video/pwc/pwc-timon.h
@@ -44,6 +44,8 @@
44 44
45#include <media/pwc-ioctl.h> 45#include <media/pwc-ioctl.h>
46 46
47#define PWC_FPS_MAX_TIMON 6
48
47struct Timon_table_entry 49struct Timon_table_entry
48{ 50{
49 char alternate; /* USB alternate interface */ 51 char alternate; /* USB alternate interface */
@@ -52,9 +54,9 @@ struct Timon_table_entry
52 unsigned char mode[13]; /* precomputed mode settings for cam */ 54 unsigned char mode[13]; /* precomputed mode settings for cam */
53}; 55};
54 56
55extern const struct Timon_table_entry Timon_table[PSZ_MAX][6][4]; 57extern const struct Timon_table_entry Timon_table[PSZ_MAX][PWC_FPS_MAX_TIMON][4];
56extern const unsigned int TimonRomTable [16][2][16][8]; 58extern const unsigned int TimonRomTable [16][2][16][8];
57 59extern const unsigned int Timon_fps_vector[PWC_FPS_MAX_TIMON];
58 60
59#endif 61#endif
60 62
diff --git a/drivers/media/video/pwc/pwc-v4l.c b/drivers/media/video/pwc/pwc-v4l.c
index d5e6bc850643..e20251d05bf6 100644
--- a/drivers/media/video/pwc/pwc-v4l.c
+++ b/drivers/media/video/pwc/pwc-v4l.c
@@ -1193,6 +1193,64 @@ int pwc_video_do_ioctl(struct inode *inode, struct file *file,
1193 return 0; 1193 return 0;
1194 } 1194 }
1195 1195
1196 case VIDIOC_ENUM_FRAMESIZES:
1197 {
1198 struct v4l2_frmsizeenum *fsize = arg;
1199 unsigned int i = 0, index = fsize->index;
1200
1201 if (fsize->pixel_format == V4L2_PIX_FMT_YUV420) {
1202 for (i = 0; i < PSZ_MAX; i++) {
1203 if (pdev->image_mask & (1UL << i)) {
1204 if (!index--) {
1205 fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE;
1206 fsize->discrete.width = pwc_image_sizes[i].x;
1207 fsize->discrete.height = pwc_image_sizes[i].y;
1208 return 0;
1209 }
1210 }
1211 }
1212 } else if (fsize->index == 0 &&
1213 ((fsize->pixel_format == V4L2_PIX_FMT_PWC1 && DEVICE_USE_CODEC1(pdev->type)) ||
1214 (fsize->pixel_format == V4L2_PIX_FMT_PWC2 && DEVICE_USE_CODEC23(pdev->type)))) {
1215
1216 fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE;
1217 fsize->discrete.width = pdev->abs_max.x;
1218 fsize->discrete.height = pdev->abs_max.y;
1219 return 0;
1220 }
1221 return -EINVAL;
1222 }
1223
1224 case VIDIOC_ENUM_FRAMEINTERVALS:
1225 {
1226 struct v4l2_frmivalenum *fival = arg;
1227 int size = -1;
1228 unsigned int i;
1229
1230 for (i = 0; i < PSZ_MAX; i++) {
1231 if (pwc_image_sizes[i].x == fival->width &&
1232 pwc_image_sizes[i].y == fival->height) {
1233 size = i;
1234 break;
1235 }
1236 }
1237
1238 /* TODO: Support raw format */
1239 if (size < 0 || fival->pixel_format != V4L2_PIX_FMT_YUV420) {
1240 return -EINVAL;
1241 }
1242
1243 i = pwc_get_fps(pdev, fival->index, size);
1244 if (!i)
1245 return -EINVAL;
1246
1247 fival->type = V4L2_FRMIVAL_TYPE_DISCRETE;
1248 fival->discrete.numerator = 1;
1249 fival->discrete.denominator = i;
1250
1251 return 0;
1252 }
1253
1196 default: 1254 default:
1197 return pwc_ioctl(pdev, cmd, arg); 1255 return pwc_ioctl(pdev, cmd, arg);
1198 } /* ..switch */ 1256 } /* ..switch */
diff --git a/drivers/media/video/pwc/pwc.h b/drivers/media/video/pwc/pwc.h
index e778a2b8c280..acbb9312960a 100644
--- a/drivers/media/video/pwc/pwc.h
+++ b/drivers/media/video/pwc/pwc.h
@@ -44,7 +44,7 @@
44#define PWC_MINOR 0 44#define PWC_MINOR 0
45#define PWC_EXTRAMINOR 12 45#define PWC_EXTRAMINOR 12
46#define PWC_VERSION_CODE KERNEL_VERSION(PWC_MAJOR,PWC_MINOR,PWC_EXTRAMINOR) 46#define PWC_VERSION_CODE KERNEL_VERSION(PWC_MAJOR,PWC_MINOR,PWC_EXTRAMINOR)
47#define PWC_VERSION "10.0.12" 47#define PWC_VERSION "10.0.13"
48#define PWC_NAME "pwc" 48#define PWC_NAME "pwc"
49#define PFX PWC_NAME ": " 49#define PFX PWC_NAME ": "
50 50
@@ -85,7 +85,7 @@
85#define PWC_INFO(fmt, args...) printk(KERN_INFO PFX fmt, ##args) 85#define PWC_INFO(fmt, args...) printk(KERN_INFO PFX fmt, ##args)
86#define PWC_TRACE(fmt, args...) PWC_DEBUG(TRACE, fmt, ##args) 86#define PWC_TRACE(fmt, args...) PWC_DEBUG(TRACE, fmt, ##args)
87 87
88#else /* if ! CONFIG_PWC_DEBUG */ 88#else /* if ! CONFIG_USB_PWC_DEBUG */
89 89
90#define PWC_ERROR(fmt, args...) printk(KERN_ERR PFX fmt, ##args) 90#define PWC_ERROR(fmt, args...) printk(KERN_ERR PFX fmt, ##args)
91#define PWC_WARNING(fmt, args...) printk(KERN_WARNING PFX fmt, ##args) 91#define PWC_WARNING(fmt, args...) printk(KERN_WARNING PFX fmt, ##args)
@@ -287,6 +287,7 @@ void pwc_construct(struct pwc_device *pdev);
287/** Functions in pwc-ctrl.c */ 287/** Functions in pwc-ctrl.c */
288/* Request a certain video mode. Returns < 0 if not possible */ 288/* Request a certain video mode. Returns < 0 if not possible */
289extern int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int frames, int compression, int snapshot); 289extern int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int frames, int compression, int snapshot);
290extern unsigned int pwc_get_fps(struct pwc_device *pdev, unsigned int index, unsigned int size);
290/* Calculate the number of bytes per image (not frame) */ 291/* Calculate the number of bytes per image (not frame) */
291extern int pwc_mpt_reset(struct pwc_device *pdev, int flags); 292extern int pwc_mpt_reset(struct pwc_device *pdev, int flags);
292extern int pwc_mpt_set_angle(struct pwc_device *pdev, int pan, int tilt); 293extern int pwc_mpt_set_angle(struct pwc_device *pdev, int pan, int tilt);