]> err.no Git - linux-2.6/blobdiff - drivers/media/video/ivtv/ivtv-ioctl.c
Merge branches 'at91', 'dyntick', 'ep93xx', 'iop', 'ixp', 'misc', 'orion', 'omap...
[linux-2.6] / drivers / media / video / ivtv / ivtv-ioctl.c
index 15cac1812122e22c11805e3fe006c5111f2581ae..26cc0f6699fdc9d44bfcdce386d2533f3cc06227 100644 (file)
@@ -38,7 +38,7 @@
 #include <linux/dvb/audio.h>
 #include <linux/i2c-id.h>
 
-u16 service2vbi(int type)
+u16 ivtv_service2vbi(int type)
 {
        switch (type) {
                case V4L2_SLICED_TELETEXT_B:
@@ -88,7 +88,7 @@ static u16 select_service_from_set(int field, int line, u16 set, int is_pal)
        return 0;
 }
 
-void expand_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal)
+void ivtv_expand_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal)
 {
        u16 set = fmt->service_set;
        int f, l;
@@ -115,7 +115,7 @@ static int check_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal)
        return set != 0;
 }
 
-u16 get_service_set(struct v4l2_sliced_vbi_format *fmt)
+u16 ivtv_get_service_set(struct v4l2_sliced_vbi_format *fmt)
 {
        int f, l;
        u16 set = 0;
@@ -243,20 +243,31 @@ static int ivtv_validate_speed(int cur_speed, int new_speed)
        int fact = new_speed < 0 ? -1 : 1;
        int s;
 
-       if (new_speed < 0) new_speed = -new_speed;
-       if (cur_speed < 0) cur_speed = -cur_speed;
+       if (cur_speed == 0)
+               cur_speed = 1000;
+       if (new_speed < 0)
+               new_speed = -new_speed;
+       if (cur_speed < 0)
+               cur_speed = -cur_speed;
 
        if (cur_speed <= new_speed) {
-               if (new_speed > 1500) return fact * 2000;
-               if (new_speed > 1000) return fact * 1500;
+               if (new_speed > 1500)
+                       return fact * 2000;
+               if (new_speed > 1000)
+                       return fact * 1500;
        }
        else {
-               if (new_speed >= 2000) return fact * 2000;
-               if (new_speed >= 1500) return fact * 1500;
-               if (new_speed >= 1000) return fact * 1000;
-       }
-       if (new_speed == 0) return 1000;
-       if (new_speed == 1 || new_speed == 1000) return fact * new_speed;
+               if (new_speed >= 2000)
+                       return fact * 2000;
+               if (new_speed >= 1500)
+                       return fact * 1500;
+               if (new_speed >= 1000)
+                       return fact * 1000;
+       }
+       if (new_speed == 0)
+               return 1000;
+       if (new_speed == 1 || new_speed == 1000)
+               return fact * new_speed;
 
        s = new_speed;
        new_speed = 1000 / new_speed;
@@ -455,7 +466,7 @@ static int ivtv_get_fmt(struct ivtv *itv, int streamtype, struct v4l2_format *fm
                        vbifmt->service_lines[0][23] = V4L2_SLICED_WSS_625;
                        vbifmt->service_lines[0][16] = V4L2_SLICED_VPS;
                }
-               vbifmt->service_set = get_service_set(vbifmt);
+               vbifmt->service_set = ivtv_get_service_set(vbifmt);
                break;
        }
 
@@ -470,12 +481,12 @@ static int ivtv_get_fmt(struct ivtv *itv, int streamtype, struct v4l2_format *fm
                if (streamtype == IVTV_DEC_STREAM_TYPE_VBI) {
                        vbifmt->service_set = itv->is_50hz ? V4L2_SLICED_VBI_625 :
                                                 V4L2_SLICED_VBI_525;
-                       expand_service_set(vbifmt, itv->is_50hz);
+                       ivtv_expand_service_set(vbifmt, itv->is_50hz);
                        break;
                }
 
                itv->video_dec_func(itv, VIDIOC_G_FMT, fmt);
-               vbifmt->service_set = get_service_set(vbifmt);
+               vbifmt->service_set = ivtv_get_service_set(vbifmt);
                break;
        }
        case V4L2_BUF_TYPE_VBI_OUTPUT:
@@ -629,9 +640,9 @@ static int ivtv_try_or_set_fmt(struct ivtv *itv, int streamtype,
        memset(vbifmt->reserved, 0, sizeof(vbifmt->reserved));
 
        if (vbifmt->service_set)
-               expand_service_set(vbifmt, itv->is_50hz);
+               ivtv_expand_service_set(vbifmt, itv->is_50hz);
        set = check_service_set(vbifmt, itv->is_50hz);
-       vbifmt->service_set = get_service_set(vbifmt);
+       vbifmt->service_set = ivtv_get_service_set(vbifmt);
 
        if (!set_fmt)
                return 0;
@@ -741,10 +752,9 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
                struct v4l2_capability *vcap = arg;
 
                memset(vcap, 0, sizeof(*vcap));
-               strcpy(vcap->driver, IVTV_DRIVER_NAME);     /* driver name */
-               strncpy(vcap->card, itv->card_name,
-                               sizeof(vcap->card)-1);      /* card type */
-               strcpy(vcap->bus_info, pci_name(itv->dev)); /* bus info... */
+               strlcpy(vcap->driver, IVTV_DRIVER_NAME, sizeof(vcap->driver));
+               strlcpy(vcap->card, itv->card_name, sizeof(vcap->card));
+               strlcpy(vcap->bus_info, pci_name(itv->dev), sizeof(vcap->bus_info));
                vcap->version = IVTV_DRIVER_VERSION;        /* version */
                vcap->capabilities = itv->v4l2_cap;         /* capabilities */
 
@@ -1018,7 +1028,7 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
                                ivtv_std_60hz : ivtv_std_50hz;
                vs->index = idx;
                vs->id = enum_stds[idx].std;
-               strcpy(vs->name, enum_stds[idx].name);
+               strlcpy(vs->name, enum_stds[idx].name, sizeof(vs->name));
                break;
        }
 
@@ -1102,10 +1112,10 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void
                ivtv_call_i2c_clients(itv, VIDIOC_G_TUNER, vt);
 
                if (test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags)) {
-                       strcpy(vt->name, "ivtv Radio Tuner");
+                       strlcpy(vt->name, "ivtv Radio Tuner", sizeof(vt->name));
                        vt->type = V4L2_TUNER_RADIO;
                } else {
-                       strcpy(vt->name, "ivtv TV Tuner");
+                       strlcpy(vt->name, "ivtv TV Tuner", sizeof(vt->name));
                        vt->type = V4L2_TUNER_ANALOG_TV;
                }
                break;