V4L/DVB (8951): xc5000: dont pass devptr in xc5000_attach()
[safe/jmp/linux-2.6] / drivers / media / video / pwc / pwc-ctrl.c
index 0bd1155..dbc5607 100644 (file)
@@ -140,6 +140,8 @@ static const char *size2name[PSZ_MAX] =
    An alternate value of 0 means this mode is not available at all.
  */
 
+#define PWC_FPS_MAX_NALA 8
+
 struct Nala_table_entry {
        char alternate;                 /* USB alternate setting */
        int compressed;                 /* Compressed yes/no */
@@ -147,7 +149,9 @@ struct Nala_table_entry {
        unsigned char mode[3];          /* precomputed mode table */
 };
 
-static struct Nala_table_entry Nala_table[PSZ_MAX][8] =
+static unsigned int Nala_fps_vector[PWC_FPS_MAX_NALA] = { 4, 5, 7, 10, 12, 15, 20, 24 };
+
+static struct Nala_table_entry Nala_table[PSZ_MAX][PWC_FPS_MAX_NALA] =
 {
 #include "pwc-nala.h"
 };
@@ -423,6 +427,59 @@ int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int frame
        return 0;
 }
 
+static unsigned int pwc_get_fps_Nala(struct pwc_device *pdev, unsigned int index, unsigned int size)
+{
+       unsigned int i;
+
+       for (i = 0; i < PWC_FPS_MAX_NALA; i++) {
+               if (Nala_table[size][i].alternate) {
+                       if (index--==0) return Nala_fps_vector[i];
+               }
+       }
+       return 0;
+}
+
+static unsigned int pwc_get_fps_Kiara(struct pwc_device *pdev, unsigned int index, unsigned int size)
+{
+       unsigned int i;
+
+       for (i = 0; i < PWC_FPS_MAX_KIARA; i++) {
+               if (Kiara_table[size][i][3].alternate) {
+                       if (index--==0) return Kiara_fps_vector[i];
+               }
+       }
+       return 0;
+}
+
+static unsigned int pwc_get_fps_Timon(struct pwc_device *pdev, unsigned int index, unsigned int size)
+{
+       unsigned int i;
+
+       for (i=0; i < PWC_FPS_MAX_TIMON; i++) {
+               if (Timon_table[size][i][3].alternate) {
+                       if (index--==0) return Timon_fps_vector[i];
+               }
+       }
+       return 0;
+}
+
+unsigned int pwc_get_fps(struct pwc_device *pdev, unsigned int index, unsigned int size)
+{
+       unsigned int ret;
+
+       if (DEVICE_USE_CODEC1(pdev->type)) {
+               ret = pwc_get_fps_Nala(pdev, index, size);
+
+       } else if (DEVICE_USE_CODEC3(pdev->type)) {
+               ret = pwc_get_fps_Kiara(pdev, index, size);
+
+       } else {
+               ret = pwc_get_fps_Timon(pdev, index, size);
+       }
+
+       return ret;
+}
+
 #define BLACK_Y 0
 #define BLACK_U 128
 #define BLACK_V 128
@@ -1198,7 +1255,6 @@ int pwc_get_cmos_sensor(struct pwc_device *pdev, int *sensor)
    exactly the same otherwise.
  */
 
-
 /* define local variable for arg */
 #define ARG_DEF(ARG_type, ARG_name)\
        ARG_type *ARG_name = arg;
@@ -1211,7 +1267,6 @@ int pwc_get_cmos_sensor(struct pwc_device *pdev, int *sensor)
 /* copy local variable to arg */
 #define ARG_OUT(ARG_name) /* nothing */
 
-
 int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
 {
        int ret = 0;
@@ -1343,7 +1398,7 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
                                ret = pwc_read_red_gain(pdev, &ARGR(wb).read_red);
                                if (ret < 0)
                                        break;
-                               ret =pwc_read_blue_gain(pdev, &ARGR(wb).read_blue);
+                               ret = pwc_read_blue_gain(pdev, &ARGR(wb).read_blue);
                                if (ret < 0)
                                        break;
                        }
@@ -1580,18 +1635,18 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
 
        case VIDIOCPWCGVIDCMD:
        {
-               ARG_DEF(struct pwc_video_command, cmd);
-
-               ARGR(cmd).type = pdev->type;
-               ARGR(cmd).release = pdev->release;
-               ARGR(cmd).command_len = pdev->cmd_len;
-               memcpy(&ARGR(cmd).command_buf, pdev->cmd_buf, pdev->cmd_len);
-               ARGR(cmd).bandlength = pdev->vbandlength;
-               ARGR(cmd).frame_size = pdev->frame_size;
-               ARG_OUT(cmd)
+               ARG_DEF(struct pwc_video_command, vcmd);
+
+               ARGR(vcmd).type = pdev->type;
+               ARGR(vcmd).release = pdev->release;
+               ARGR(vcmd).command_len = pdev->cmd_len;
+               memcpy(&ARGR(vcmd).command_buf, pdev->cmd_buf, pdev->cmd_len);
+               ARGR(vcmd).bandlength = pdev->vbandlength;
+               ARGR(vcmd).frame_size = pdev->frame_size;
+               ARG_OUT(vcmd)
                break;
        }
-       /*
+       /*
        case VIDIOCPWCGVIDTABLE:
        {
                ARG_DEF(struct pwc_table_init_buffer, table);