diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/video/usbvision/usbvision-cards.c | 132 | ||||
-rw-r--r-- | drivers/media/video/usbvision/usbvision-core.c | 695 | ||||
-rw-r--r-- | drivers/media/video/usbvision/usbvision-i2c.c | 41 | ||||
-rw-r--r-- | drivers/media/video/usbvision/usbvision-video.c | 328 | ||||
-rw-r--r-- | drivers/media/video/usbvision/usbvision.h | 47 |
5 files changed, 557 insertions, 686 deletions
diff --git a/drivers/media/video/usbvision/usbvision-cards.c b/drivers/media/video/usbvision/usbvision-cards.c index acfdb2bc7917..68b998bd203f 100644 --- a/drivers/media/video/usbvision/usbvision-cards.c +++ b/drivers/media/video/usbvision/usbvision-cards.c | |||
@@ -1026,78 +1026,78 @@ struct usbvision_device_data_st usbvision_device_data[] = { | |||
1026 | .model_string = "Hauppauge WinTv-USB", | 1026 | .model_string = "Hauppauge WinTv-USB", |
1027 | }, | 1027 | }, |
1028 | }; | 1028 | }; |
1029 | const int usbvision_device_data_size=ARRAY_SIZE(usbvision_device_data); | 1029 | const int usbvision_device_data_size = ARRAY_SIZE(usbvision_device_data); |
1030 | 1030 | ||
1031 | /* Supported Devices */ | 1031 | /* Supported Devices */ |
1032 | 1032 | ||
1033 | struct usb_device_id usbvision_table [] = { | 1033 | struct usb_device_id usbvision_table[] = { |
1034 | { USB_DEVICE(0x0a6f, 0x0400), .driver_info=XANBOO }, | 1034 | { USB_DEVICE(0x0a6f, 0x0400), .driver_info = XANBOO }, |
1035 | { USB_DEVICE(0x050d, 0x0106), .driver_info=BELKIN_VIDEOBUS_II }, | 1035 | { USB_DEVICE(0x050d, 0x0106), .driver_info = BELKIN_VIDEOBUS_II }, |
1036 | { USB_DEVICE(0x050d, 0x0207), .driver_info=BELKIN_VIDEOBUS }, | 1036 | { USB_DEVICE(0x050d, 0x0207), .driver_info = BELKIN_VIDEOBUS }, |
1037 | { USB_DEVICE(0x050d, 0x0208), .driver_info=BELKIN_USB_VIDEOBUS_II }, | 1037 | { USB_DEVICE(0x050d, 0x0208), .driver_info = BELKIN_USB_VIDEOBUS_II }, |
1038 | { USB_DEVICE(0x0571, 0x0002), .driver_info=ECHOFX_INTERVIEW_LITE }, | 1038 | { USB_DEVICE(0x0571, 0x0002), .driver_info = ECHOFX_INTERVIEW_LITE }, |
1039 | { USB_DEVICE(0x0573, 0x0003), .driver_info=USBGEAR_USBG_V1 }, | 1039 | { USB_DEVICE(0x0573, 0x0003), .driver_info = USBGEAR_USBG_V1 }, |
1040 | { USB_DEVICE(0x0573, 0x0400), .driver_info=D_LINK_V100 }, | 1040 | { USB_DEVICE(0x0573, 0x0400), .driver_info = D_LINK_V100 }, |
1041 | { USB_DEVICE(0x0573, 0x2000), .driver_info=X10_USB_CAMERA }, | 1041 | { USB_DEVICE(0x0573, 0x2000), .driver_info = X10_USB_CAMERA }, |
1042 | { USB_DEVICE(0x0573, 0x2d00), .driver_info=HPG_WINTV_LIVE_PAL_BG }, | 1042 | { USB_DEVICE(0x0573, 0x2d00), .driver_info = HPG_WINTV_LIVE_PAL_BG }, |
1043 | { USB_DEVICE(0x0573, 0x2d01), .driver_info=HPG_WINTV_LIVE_PRO_NTSC_MN }, | 1043 | { USB_DEVICE(0x0573, 0x2d01), .driver_info = HPG_WINTV_LIVE_PRO_NTSC_MN }, |
1044 | { USB_DEVICE(0x0573, 0x2101), .driver_info=ZORAN_PMD_NOGATECH }, | 1044 | { USB_DEVICE(0x0573, 0x2101), .driver_info = ZORAN_PMD_NOGATECH }, |
1045 | { USB_DEVICE(0x0573, 0x4100), .driver_info=NOGATECH_USB_TV_NTSC_FM }, | 1045 | { USB_DEVICE(0x0573, 0x4100), .driver_info = NOGATECH_USB_TV_NTSC_FM }, |
1046 | { USB_DEVICE(0x0573, 0x4110), .driver_info=PNY_USB_TV_NTSC_FM }, | 1046 | { USB_DEVICE(0x0573, 0x4110), .driver_info = PNY_USB_TV_NTSC_FM }, |
1047 | { USB_DEVICE(0x0573, 0x4450), .driver_info=PV_PLAYTV_USB_PRO_PAL_FM }, | 1047 | { USB_DEVICE(0x0573, 0x4450), .driver_info = PV_PLAYTV_USB_PRO_PAL_FM }, |
1048 | { USB_DEVICE(0x0573, 0x4550), .driver_info=ZT_721 }, | 1048 | { USB_DEVICE(0x0573, 0x4550), .driver_info = ZT_721 }, |
1049 | { USB_DEVICE(0x0573, 0x4d00), .driver_info=HPG_WINTV_NTSC_MN }, | 1049 | { USB_DEVICE(0x0573, 0x4d00), .driver_info = HPG_WINTV_NTSC_MN }, |
1050 | { USB_DEVICE(0x0573, 0x4d01), .driver_info=HPG_WINTV_PAL_BG }, | 1050 | { USB_DEVICE(0x0573, 0x4d01), .driver_info = HPG_WINTV_PAL_BG }, |
1051 | { USB_DEVICE(0x0573, 0x4d02), .driver_info=HPG_WINTV_PAL_I }, | 1051 | { USB_DEVICE(0x0573, 0x4d02), .driver_info = HPG_WINTV_PAL_I }, |
1052 | { USB_DEVICE(0x0573, 0x4d03), .driver_info=HPG_WINTV_PAL_SECAM_L }, | 1052 | { USB_DEVICE(0x0573, 0x4d03), .driver_info = HPG_WINTV_PAL_SECAM_L }, |
1053 | { USB_DEVICE(0x0573, 0x4d04), .driver_info=HPG_WINTV_PAL_D_K }, | 1053 | { USB_DEVICE(0x0573, 0x4d04), .driver_info = HPG_WINTV_PAL_D_K }, |
1054 | { USB_DEVICE(0x0573, 0x4d10), .driver_info=HPG_WINTV_NTSC_FM }, | 1054 | { USB_DEVICE(0x0573, 0x4d10), .driver_info = HPG_WINTV_NTSC_FM }, |
1055 | { USB_DEVICE(0x0573, 0x4d11), .driver_info=HPG_WINTV_PAL_BG_FM }, | 1055 | { USB_DEVICE(0x0573, 0x4d11), .driver_info = HPG_WINTV_PAL_BG_FM }, |
1056 | { USB_DEVICE(0x0573, 0x4d12), .driver_info=HPG_WINTV_PAL_I_FM }, | 1056 | { USB_DEVICE(0x0573, 0x4d12), .driver_info = HPG_WINTV_PAL_I_FM }, |
1057 | { USB_DEVICE(0x0573, 0x4d14), .driver_info=HPG_WINTV_PAL_D_K_FM }, | 1057 | { USB_DEVICE(0x0573, 0x4d14), .driver_info = HPG_WINTV_PAL_D_K_FM }, |
1058 | { USB_DEVICE(0x0573, 0x4d2a), .driver_info=HPG_WINTV_PRO_NTSC_MN }, | 1058 | { USB_DEVICE(0x0573, 0x4d2a), .driver_info = HPG_WINTV_PRO_NTSC_MN }, |
1059 | { USB_DEVICE(0x0573, 0x4d2b), .driver_info=HPG_WINTV_PRO_NTSC_MN_V2 }, | 1059 | { USB_DEVICE(0x0573, 0x4d2b), .driver_info = HPG_WINTV_PRO_NTSC_MN_V2 }, |
1060 | { USB_DEVICE(0x0573, 0x4d2c), .driver_info=HPG_WINTV_PRO_PAL }, | 1060 | { USB_DEVICE(0x0573, 0x4d2c), .driver_info = HPG_WINTV_PRO_PAL }, |
1061 | { USB_DEVICE(0x0573, 0x4d20), .driver_info = HPG_WINTV_PRO_NTSC_MN_V3 }, | 1061 | { USB_DEVICE(0x0573, 0x4d20), .driver_info = HPG_WINTV_PRO_NTSC_MN_V3 }, |
1062 | { USB_DEVICE(0x0573, 0x4d21), .driver_info=HPG_WINTV_PRO_PAL_BG }, | 1062 | { USB_DEVICE(0x0573, 0x4d21), .driver_info = HPG_WINTV_PRO_PAL_BG }, |
1063 | { USB_DEVICE(0x0573, 0x4d22), .driver_info=HPG_WINTV_PRO_PAL_I }, | 1063 | { USB_DEVICE(0x0573, 0x4d22), .driver_info = HPG_WINTV_PRO_PAL_I }, |
1064 | { USB_DEVICE(0x0573, 0x4d23), .driver_info=HPG_WINTV_PRO_PAL_SECAM_L }, | 1064 | { USB_DEVICE(0x0573, 0x4d23), .driver_info = HPG_WINTV_PRO_PAL_SECAM_L }, |
1065 | { USB_DEVICE(0x0573, 0x4d24), .driver_info=HPG_WINTV_PRO_PAL_D_K }, | 1065 | { USB_DEVICE(0x0573, 0x4d24), .driver_info = HPG_WINTV_PRO_PAL_D_K }, |
1066 | { USB_DEVICE(0x0573, 0x4d25), .driver_info=HPG_WINTV_PRO_PAL_SECAM }, | 1066 | { USB_DEVICE(0x0573, 0x4d25), .driver_info = HPG_WINTV_PRO_PAL_SECAM }, |
1067 | { USB_DEVICE(0x0573, 0x4d26), .driver_info=HPG_WINTV_PRO_PAL_SECAM_V2 }, | 1067 | { USB_DEVICE(0x0573, 0x4d26), .driver_info = HPG_WINTV_PRO_PAL_SECAM_V2 }, |
1068 | { USB_DEVICE(0x0573, 0x4d27), .driver_info=HPG_WINTV_PRO_PAL_BG_V2 }, | 1068 | { USB_DEVICE(0x0573, 0x4d27), .driver_info = HPG_WINTV_PRO_PAL_BG_V2 }, |
1069 | { USB_DEVICE(0x0573, 0x4d28), .driver_info=HPG_WINTV_PRO_PAL_BG_D_K }, | 1069 | { USB_DEVICE(0x0573, 0x4d28), .driver_info = HPG_WINTV_PRO_PAL_BG_D_K }, |
1070 | { USB_DEVICE(0x0573, 0x4d29), .driver_info=HPG_WINTV_PRO_PAL_I_D_K }, | 1070 | { USB_DEVICE(0x0573, 0x4d29), .driver_info = HPG_WINTV_PRO_PAL_I_D_K }, |
1071 | { USB_DEVICE(0x0573, 0x4d30), .driver_info=HPG_WINTV_PRO_NTSC_MN_FM }, | 1071 | { USB_DEVICE(0x0573, 0x4d30), .driver_info = HPG_WINTV_PRO_NTSC_MN_FM }, |
1072 | { USB_DEVICE(0x0573, 0x4d31), .driver_info=HPG_WINTV_PRO_PAL_BG_FM }, | 1072 | { USB_DEVICE(0x0573, 0x4d31), .driver_info = HPG_WINTV_PRO_PAL_BG_FM }, |
1073 | { USB_DEVICE(0x0573, 0x4d32), .driver_info=HPG_WINTV_PRO_PAL_I_FM }, | 1073 | { USB_DEVICE(0x0573, 0x4d32), .driver_info = HPG_WINTV_PRO_PAL_I_FM }, |
1074 | { USB_DEVICE(0x0573, 0x4d34), .driver_info=HPG_WINTV_PRO_PAL_D_K_FM }, | 1074 | { USB_DEVICE(0x0573, 0x4d34), .driver_info = HPG_WINTV_PRO_PAL_D_K_FM }, |
1075 | { USB_DEVICE(0x0573, 0x4d35), .driver_info=HPG_WINTV_PRO_TEMIC_PAL_FM }, | 1075 | { USB_DEVICE(0x0573, 0x4d35), .driver_info = HPG_WINTV_PRO_TEMIC_PAL_FM }, |
1076 | { USB_DEVICE(0x0573, 0x4d36), .driver_info=HPG_WINTV_PRO_TEMIC_PAL_BG_FM }, | 1076 | { USB_DEVICE(0x0573, 0x4d36), .driver_info = HPG_WINTV_PRO_TEMIC_PAL_BG_FM }, |
1077 | { USB_DEVICE(0x0573, 0x4d37), .driver_info=HPG_WINTV_PRO_PAL_FM }, | 1077 | { USB_DEVICE(0x0573, 0x4d37), .driver_info = HPG_WINTV_PRO_PAL_FM }, |
1078 | { USB_DEVICE(0x0573, 0x4d38), .driver_info=HPG_WINTV_PRO_NTSC_MN_FM_V2 }, | 1078 | { USB_DEVICE(0x0573, 0x4d38), .driver_info = HPG_WINTV_PRO_NTSC_MN_FM_V2 }, |
1079 | { USB_DEVICE(0x0768, 0x0006), .driver_info=CAMTEL_TVB330 }, | 1079 | { USB_DEVICE(0x0768, 0x0006), .driver_info = CAMTEL_TVB330 }, |
1080 | { USB_DEVICE(0x07d0, 0x0001), .driver_info=DIGITAL_VIDEO_CREATOR_I }, | 1080 | { USB_DEVICE(0x07d0, 0x0001), .driver_info = DIGITAL_VIDEO_CREATOR_I }, |
1081 | { USB_DEVICE(0x07d0, 0x0002), .driver_info=GLOBAL_VILLAGE_GV_007_NTSC }, | 1081 | { USB_DEVICE(0x07d0, 0x0002), .driver_info = GLOBAL_VILLAGE_GV_007_NTSC }, |
1082 | { USB_DEVICE(0x07d0, 0x0003), .driver_info=DAZZLE_DVC_50_REV_1_NTSC }, | 1082 | { USB_DEVICE(0x07d0, 0x0003), .driver_info = DAZZLE_DVC_50_REV_1_NTSC }, |
1083 | { USB_DEVICE(0x07d0, 0x0004), .driver_info=DAZZLE_DVC_80_REV_1_PAL }, | 1083 | { USB_DEVICE(0x07d0, 0x0004), .driver_info = DAZZLE_DVC_80_REV_1_PAL }, |
1084 | { USB_DEVICE(0x07d0, 0x0005), .driver_info=DAZZLE_DVC_90_REV_1_SECAM }, | 1084 | { USB_DEVICE(0x07d0, 0x0005), .driver_info = DAZZLE_DVC_90_REV_1_SECAM }, |
1085 | { USB_DEVICE(0x07f8, 0x9104), .driver_info=ESKAPE_LABS_MYTV2GO }, | 1085 | { USB_DEVICE(0x07f8, 0x9104), .driver_info = ESKAPE_LABS_MYTV2GO }, |
1086 | { USB_DEVICE(0x2304, 0x010d), .driver_info=PINNA_PCTV_USB_PAL }, | 1086 | { USB_DEVICE(0x2304, 0x010d), .driver_info = PINNA_PCTV_USB_PAL }, |
1087 | { USB_DEVICE(0x2304, 0x0109), .driver_info=PINNA_PCTV_USB_SECAM }, | 1087 | { USB_DEVICE(0x2304, 0x0109), .driver_info = PINNA_PCTV_USB_SECAM }, |
1088 | { USB_DEVICE(0x2304, 0x0110), .driver_info=PINNA_PCTV_USB_PAL_FM }, | 1088 | { USB_DEVICE(0x2304, 0x0110), .driver_info = PINNA_PCTV_USB_PAL_FM }, |
1089 | { USB_DEVICE(0x2304, 0x0111), .driver_info=MIRO_PCTV_USB }, | 1089 | { USB_DEVICE(0x2304, 0x0111), .driver_info = MIRO_PCTV_USB }, |
1090 | { USB_DEVICE(0x2304, 0x0112), .driver_info=PINNA_PCTV_USB_NTSC_FM }, | 1090 | { USB_DEVICE(0x2304, 0x0112), .driver_info = PINNA_PCTV_USB_NTSC_FM }, |
1091 | { USB_DEVICE(0x2304, 0x0113), | 1091 | { USB_DEVICE(0x2304, 0x0113), |
1092 | .driver_info = PINNA_PCTV_USB_NTSC_FM_V3 }, | 1092 | .driver_info = PINNA_PCTV_USB_NTSC_FM_V3 }, |
1093 | { USB_DEVICE(0x2304, 0x0210), .driver_info=PINNA_PCTV_USB_PAL_FM_V2 }, | 1093 | { USB_DEVICE(0x2304, 0x0210), .driver_info = PINNA_PCTV_USB_PAL_FM_V2 }, |
1094 | { USB_DEVICE(0x2304, 0x0212), .driver_info=PINNA_PCTV_USB_NTSC_FM_V2 }, | 1094 | { USB_DEVICE(0x2304, 0x0212), .driver_info = PINNA_PCTV_USB_NTSC_FM_V2 }, |
1095 | { USB_DEVICE(0x2304, 0x0214), .driver_info=PINNA_PCTV_USB_PAL_FM_V3 }, | 1095 | { USB_DEVICE(0x2304, 0x0214), .driver_info = PINNA_PCTV_USB_PAL_FM_V3 }, |
1096 | { USB_DEVICE(0x2304, 0x0300), .driver_info=PINNA_LINX_VD_IN_CAB_NTSC }, | 1096 | { USB_DEVICE(0x2304, 0x0300), .driver_info = PINNA_LINX_VD_IN_CAB_NTSC }, |
1097 | { USB_DEVICE(0x2304, 0x0301), .driver_info=PINNA_LINX_VD_IN_CAB_PAL }, | 1097 | { USB_DEVICE(0x2304, 0x0301), .driver_info = PINNA_LINX_VD_IN_CAB_PAL }, |
1098 | { USB_DEVICE(0x2304, 0x0419), .driver_info=PINNA_PCTV_BUNGEE_PAL_FM }, | 1098 | { USB_DEVICE(0x2304, 0x0419), .driver_info = PINNA_PCTV_BUNGEE_PAL_FM }, |
1099 | { USB_DEVICE(0x2400, 0x4200), .driver_info=HPG_WINTV }, | 1099 | { USB_DEVICE(0x2400, 0x4200), .driver_info = HPG_WINTV }, |
1100 | { }, /* terminate list */ | 1100 | { }, /* terminate list */ |
1101 | }; | 1101 | }; |
1102 | 1102 | ||
1103 | MODULE_DEVICE_TABLE (usb, usbvision_table); | 1103 | MODULE_DEVICE_TABLE(usb, usbvision_table); |
diff --git a/drivers/media/video/usbvision/usbvision-core.c b/drivers/media/video/usbvision/usbvision-core.c index 64a913323181..c8feb0d6fccf 100644 --- a/drivers/media/video/usbvision/usbvision-core.c +++ b/drivers/media/video/usbvision/usbvision-core.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include <linux/module.h> | 33 | #include <linux/module.h> |
34 | #include <linux/init.h> | 34 | #include <linux/init.h> |
35 | #include <linux/spinlock.h> | 35 | #include <linux/spinlock.h> |
36 | #include <asm/io.h> | 36 | #include <linux/io.h> |
37 | #include <linux/videodev2.h> | 37 | #include <linux/videodev2.h> |
38 | #include <linux/i2c.h> | 38 | #include <linux/i2c.h> |
39 | 39 | ||
@@ -46,12 +46,12 @@ | |||
46 | #include "usbvision.h" | 46 | #include "usbvision.h" |
47 | 47 | ||
48 | static unsigned int core_debug; | 48 | static unsigned int core_debug; |
49 | module_param(core_debug,int,0644); | 49 | module_param(core_debug, int, 0644); |
50 | MODULE_PARM_DESC(core_debug,"enable debug messages [core]"); | 50 | MODULE_PARM_DESC(core_debug, "enable debug messages [core]"); |
51 | 51 | ||
52 | static unsigned int force_testpattern; | 52 | static unsigned int force_testpattern; |
53 | module_param(force_testpattern,int,0644); | 53 | module_param(force_testpattern, int, 0644); |
54 | MODULE_PARM_DESC(force_testpattern,"enable test pattern display [core]"); | 54 | MODULE_PARM_DESC(force_testpattern, "enable test pattern display [core]"); |
55 | 55 | ||
56 | static int adjust_compression = 1; /* Set the compression to be adaptive */ | 56 | static int adjust_compression = 1; /* Set the compression to be adaptive */ |
57 | module_param(adjust_compression, int, 0444); | 57 | module_param(adjust_compression, int, 0444); |
@@ -82,15 +82,15 @@ MODULE_PARM_DESC(adjust_y_offset, "adjust Y offset display [core]"); | |||
82 | __func__, __LINE__ , ## args); \ | 82 | __func__, __LINE__ , ## args); \ |
83 | } | 83 | } |
84 | #else | 84 | #else |
85 | #define PDEBUG(level, fmt, args...) do {} while(0) | 85 | #define PDEBUG(level, fmt, args...) do {} while (0) |
86 | #endif | 86 | #endif |
87 | 87 | ||
88 | #define DBG_HEADER 1<<0 | 88 | #define DBG_HEADER (1 << 0) |
89 | #define DBG_IRQ 1<<1 | 89 | #define DBG_IRQ (1 << 1) |
90 | #define DBG_ISOC 1<<2 | 90 | #define DBG_ISOC (1 << 2) |
91 | #define DBG_PARSE 1<<3 | 91 | #define DBG_PARSE (1 << 3) |
92 | #define DBG_SCRATCH 1<<4 | 92 | #define DBG_SCRATCH (1 << 4) |
93 | #define DBG_FUNC 1<<5 | 93 | #define DBG_FUNC (1 << 5) |
94 | 94 | ||
95 | static const int max_imgwidth = MAX_FRAME_WIDTH; | 95 | static const int max_imgwidth = MAX_FRAME_WIDTH; |
96 | static const int max_imgheight = MAX_FRAME_HEIGHT; | 96 | static const int max_imgheight = MAX_FRAME_HEIGHT; |
@@ -107,10 +107,10 @@ static const int min_imgheight = MIN_FRAME_HEIGHT; | |||
107 | static const int scratch_buf_size = DEFAULT_SCRATCH_BUF_SIZE; | 107 | static const int scratch_buf_size = DEFAULT_SCRATCH_BUF_SIZE; |
108 | 108 | ||
109 | /* Function prototypes */ | 109 | /* Function prototypes */ |
110 | static int usbvision_request_intra (struct usb_usbvision *usbvision); | 110 | static int usbvision_request_intra(struct usb_usbvision *usbvision); |
111 | static int usbvision_unrequest_intra (struct usb_usbvision *usbvision); | 111 | static int usbvision_unrequest_intra(struct usb_usbvision *usbvision); |
112 | static int usbvision_adjust_compression (struct usb_usbvision *usbvision); | 112 | static int usbvision_adjust_compression(struct usb_usbvision *usbvision); |
113 | static int usbvision_measure_bandwidth (struct usb_usbvision *usbvision); | 113 | static int usbvision_measure_bandwidth(struct usb_usbvision *usbvision); |
114 | 114 | ||
115 | /*******************************/ | 115 | /*******************************/ |
116 | /* Memory management functions */ | 116 | /* Memory management functions */ |
@@ -176,7 +176,7 @@ static void usbvision_hexdump(const unsigned char *data, int len) | |||
176 | k += sprintf(&tmp[k], "%02x ", data[i]); | 176 | k += sprintf(&tmp[k], "%02x ", data[i]); |
177 | } | 177 | } |
178 | if (k > 0) | 178 | if (k > 0) |
179 | printk("%s\n", tmp); | 179 | printk(KERN_CONT "%s\n", tmp); |
180 | } | 180 | } |
181 | #endif | 181 | #endif |
182 | 182 | ||
@@ -186,9 +186,9 @@ static void usbvision_hexdump(const unsigned char *data, int len) | |||
186 | static int scratch_len(struct usb_usbvision *usbvision) /* This returns the amount of data actually in the buffer */ | 186 | static int scratch_len(struct usb_usbvision *usbvision) /* This returns the amount of data actually in the buffer */ |
187 | { | 187 | { |
188 | int len = usbvision->scratch_write_ptr - usbvision->scratch_read_ptr; | 188 | int len = usbvision->scratch_write_ptr - usbvision->scratch_read_ptr; |
189 | if (len < 0) { | 189 | |
190 | if (len < 0) | ||
190 | len += scratch_buf_size; | 191 | len += scratch_buf_size; |
191 | } | ||
192 | PDEBUG(DBG_SCRATCH, "scratch_len() = %d\n", len); | 192 | PDEBUG(DBG_SCRATCH, "scratch_len() = %d\n", len); |
193 | 193 | ||
194 | return len; | 194 | return len; |
@@ -199,9 +199,8 @@ static int scratch_len(struct usb_usbvision *usbvision) /* This returns the a | |||
199 | static int scratch_free(struct usb_usbvision *usbvision) | 199 | static int scratch_free(struct usb_usbvision *usbvision) |
200 | { | 200 | { |
201 | int free = usbvision->scratch_read_ptr - usbvision->scratch_write_ptr; | 201 | int free = usbvision->scratch_read_ptr - usbvision->scratch_write_ptr; |
202 | if (free <= 0) { | 202 | if (free <= 0) |
203 | free += scratch_buf_size; | 203 | free += scratch_buf_size; |
204 | } | ||
205 | if (free) { | 204 | if (free) { |
206 | free -= 1; /* at least one byte in the buffer must */ | 205 | free -= 1; /* at least one byte in the buffer must */ |
207 | /* left blank, otherwise there is no chance to differ between full and empty */ | 206 | /* left blank, otherwise there is no chance to differ between full and empty */ |
@@ -221,14 +220,12 @@ static int scratch_put(struct usb_usbvision *usbvision, unsigned char *data, | |||
221 | if (usbvision->scratch_write_ptr + len < scratch_buf_size) { | 220 | if (usbvision->scratch_write_ptr + len < scratch_buf_size) { |
222 | memcpy(usbvision->scratch + usbvision->scratch_write_ptr, data, len); | 221 | memcpy(usbvision->scratch + usbvision->scratch_write_ptr, data, len); |
223 | usbvision->scratch_write_ptr += len; | 222 | usbvision->scratch_write_ptr += len; |
224 | } | 223 | } else { |
225 | else { | ||
226 | len_part = scratch_buf_size - usbvision->scratch_write_ptr; | 224 | len_part = scratch_buf_size - usbvision->scratch_write_ptr; |
227 | memcpy(usbvision->scratch + usbvision->scratch_write_ptr, data, len_part); | 225 | memcpy(usbvision->scratch + usbvision->scratch_write_ptr, data, len_part); |
228 | if (len == len_part) { | 226 | if (len == len_part) { |
229 | usbvision->scratch_write_ptr = 0; /* just set write_ptr to zero */ | 227 | usbvision->scratch_write_ptr = 0; /* just set write_ptr to zero */ |
230 | } | 228 | } else { |
231 | else { | ||
232 | memcpy(usbvision->scratch, data + len_part, len - len_part); | 229 | memcpy(usbvision->scratch, data + len_part, len - len_part); |
233 | usbvision->scratch_write_ptr = len - len_part; | 230 | usbvision->scratch_write_ptr = len - len_part; |
234 | } | 231 | } |
@@ -255,17 +252,16 @@ static int scratch_get_extra(struct usb_usbvision *usbvision, | |||
255 | unsigned char *data, int *ptr, int len) | 252 | unsigned char *data, int *ptr, int len) |
256 | { | 253 | { |
257 | int len_part; | 254 | int len_part; |
255 | |||
258 | if (*ptr + len < scratch_buf_size) { | 256 | if (*ptr + len < scratch_buf_size) { |
259 | memcpy(data, usbvision->scratch + *ptr, len); | 257 | memcpy(data, usbvision->scratch + *ptr, len); |
260 | *ptr += len; | 258 | *ptr += len; |
261 | } | 259 | } else { |
262 | else { | ||
263 | len_part = scratch_buf_size - *ptr; | 260 | len_part = scratch_buf_size - *ptr; |
264 | memcpy(data, usbvision->scratch + *ptr, len_part); | 261 | memcpy(data, usbvision->scratch + *ptr, len_part); |
265 | if (len == len_part) { | 262 | if (len == len_part) { |
266 | *ptr = 0; /* just set the y_ptr to zero */ | 263 | *ptr = 0; /* just set the y_ptr to zero */ |
267 | } | 264 | } else { |
268 | else { | ||
269 | memcpy(data + len_part, usbvision->scratch, len - len_part); | 265 | memcpy(data + len_part, usbvision->scratch, len - len_part); |
270 | *ptr = len - len_part; | 266 | *ptr = len - len_part; |
271 | } | 267 | } |
@@ -281,7 +277,7 @@ static int scratch_get_extra(struct usb_usbvision *usbvision, | |||
281 | static void scratch_set_extra_ptr(struct usb_usbvision *usbvision, int *ptr, | 277 | static void scratch_set_extra_ptr(struct usb_usbvision *usbvision, int *ptr, |
282 | int len) | 278 | int len) |
283 | { | 279 | { |
284 | *ptr = (usbvision->scratch_read_ptr + len)%scratch_buf_size; | 280 | *ptr = (usbvision->scratch_read_ptr + len) % scratch_buf_size; |
285 | 281 | ||
286 | PDEBUG(DBG_SCRATCH, "ptr=%d\n", *ptr); | 282 | PDEBUG(DBG_SCRATCH, "ptr=%d\n", *ptr); |
287 | } | 283 | } |
@@ -301,17 +297,16 @@ static int scratch_get(struct usb_usbvision *usbvision, unsigned char *data, | |||
301 | int len) | 297 | int len) |
302 | { | 298 | { |
303 | int len_part; | 299 | int len_part; |
300 | |||
304 | if (usbvision->scratch_read_ptr + len < scratch_buf_size) { | 301 | if (usbvision->scratch_read_ptr + len < scratch_buf_size) { |
305 | memcpy(data, usbvision->scratch + usbvision->scratch_read_ptr, len); | 302 | memcpy(data, usbvision->scratch + usbvision->scratch_read_ptr, len); |
306 | usbvision->scratch_read_ptr += len; | 303 | usbvision->scratch_read_ptr += len; |
307 | } | 304 | } else { |
308 | else { | ||
309 | len_part = scratch_buf_size - usbvision->scratch_read_ptr; | 305 | len_part = scratch_buf_size - usbvision->scratch_read_ptr; |
310 | memcpy(data, usbvision->scratch + usbvision->scratch_read_ptr, len_part); | 306 | memcpy(data, usbvision->scratch + usbvision->scratch_read_ptr, len_part); |
311 | if (len == len_part) { | 307 | if (len == len_part) { |
312 | usbvision->scratch_read_ptr = 0; /* just set the read_ptr to zero */ | 308 | usbvision->scratch_read_ptr = 0; /* just set the read_ptr to zero */ |
313 | } | 309 | } else { |
314 | else { | ||
315 | memcpy(data + len_part, usbvision->scratch, len - len_part); | 310 | memcpy(data + len_part, usbvision->scratch, len - len_part); |
316 | usbvision->scratch_read_ptr = len - len_part; | 311 | usbvision->scratch_read_ptr = len - len_part; |
317 | } | 312 | } |
@@ -355,7 +350,6 @@ static int scratch_get_header(struct usb_usbvision *usbvision, | |||
355 | /* This removes len bytes of old data from the buffer */ | 350 | /* This removes len bytes of old data from the buffer */ |
356 | static void scratch_rm_old(struct usb_usbvision *usbvision, int len) | 351 | static void scratch_rm_old(struct usb_usbvision *usbvision, int len) |
357 | { | 352 | { |
358 | |||
359 | usbvision->scratch_read_ptr += len; | 353 | usbvision->scratch_read_ptr += len; |
360 | usbvision->scratch_read_ptr %= scratch_buf_size; | 354 | usbvision->scratch_read_ptr %= scratch_buf_size; |
361 | PDEBUG(DBG_SCRATCH, "read_ptr is now %d\n", usbvision->scratch_read_ptr); | 355 | PDEBUG(DBG_SCRATCH, "read_ptr is now %d\n", usbvision->scratch_read_ptr); |
@@ -378,7 +372,7 @@ int usbvision_scratch_alloc(struct usb_usbvision *usbvision) | |||
378 | { | 372 | { |
379 | usbvision->scratch = vmalloc_32(scratch_buf_size); | 373 | usbvision->scratch = vmalloc_32(scratch_buf_size); |
380 | scratch_reset(usbvision); | 374 | scratch_reset(usbvision); |
381 | if(usbvision->scratch == NULL) { | 375 | if (usbvision->scratch == NULL) { |
382 | dev_err(&usbvision->dev->dev, | 376 | dev_err(&usbvision->dev->dev, |
383 | "%s: unable to allocate %d bytes for scratch\n", | 377 | "%s: unable to allocate %d bytes for scratch\n", |
384 | __func__, scratch_buf_size); | 378 | __func__, scratch_buf_size); |
@@ -391,7 +385,6 @@ void usbvision_scratch_free(struct usb_usbvision *usbvision) | |||
391 | { | 385 | { |
392 | vfree(usbvision->scratch); | 386 | vfree(usbvision->scratch); |
393 | usbvision->scratch = NULL; | 387 | usbvision->scratch = NULL; |
394 | |||
395 | } | 388 | } |
396 | 389 | ||
397 | /* | 390 | /* |
@@ -476,7 +469,6 @@ static void usbvision_testpattern(struct usb_usbvision *usbvision, | |||
476 | frame->grabstate = frame_state_done; | 469 | frame->grabstate = frame_state_done; |
477 | frame->scanlength += scan_length; | 470 | frame->scanlength += scan_length; |
478 | ++num_pass; | 471 | ++num_pass; |
479 | |||
480 | } | 472 | } |
481 | 473 | ||
482 | /* | 474 | /* |
@@ -487,6 +479,7 @@ static void usbvision_testpattern(struct usb_usbvision *usbvision, | |||
487 | int usbvision_decompress_alloc(struct usb_usbvision *usbvision) | 479 | int usbvision_decompress_alloc(struct usb_usbvision *usbvision) |
488 | { | 480 | { |
489 | int IFB_size = MAX_FRAME_WIDTH * MAX_FRAME_HEIGHT * 3 / 2; | 481 | int IFB_size = MAX_FRAME_WIDTH * MAX_FRAME_HEIGHT * 3 / 2; |
482 | |||
490 | usbvision->intra_frame_buffer = vmalloc_32(IFB_size); | 483 | usbvision->intra_frame_buffer = vmalloc_32(IFB_size); |
491 | if (usbvision->intra_frame_buffer == NULL) { | 484 | if (usbvision->intra_frame_buffer == NULL) { |
492 | dev_err(&usbvision->dev->dev, | 485 | dev_err(&usbvision->dev->dev, |
@@ -545,8 +538,7 @@ static enum parse_state usbvision_find_header(struct usb_usbvision *usbvision) | |||
545 | usbvision_unrequest_intra(usbvision); | 538 | usbvision_unrequest_intra(usbvision); |
546 | break; | 539 | break; |
547 | } | 540 | } |
548 | } | 541 | } else { |
549 | else { | ||
550 | found_header = 1; | 542 | found_header = 1; |
551 | break; | 543 | break; |
552 | } | 544 | } |
@@ -555,16 +547,15 @@ static enum parse_state usbvision_find_header(struct usb_usbvision *usbvision) | |||
555 | if (found_header) { | 547 | if (found_header) { |
556 | frame->frmwidth = frame->isoc_header.frame_width * usbvision->stretch_width; | 548 | frame->frmwidth = frame->isoc_header.frame_width * usbvision->stretch_width; |
557 | frame->frmheight = frame->isoc_header.frame_height * usbvision->stretch_height; | 549 | frame->frmheight = frame->isoc_header.frame_height * usbvision->stretch_height; |
558 | frame->v4l2_linesize = (frame->frmwidth * frame->v4l2_format.depth)>> 3; | 550 | frame->v4l2_linesize = (frame->frmwidth * frame->v4l2_format.depth) >> 3; |
559 | } | 551 | } else { /* no header found */ |
560 | else { /* no header found */ | ||
561 | PDEBUG(DBG_HEADER, "skipping scratch data, no header"); | 552 | PDEBUG(DBG_HEADER, "skipping scratch data, no header"); |
562 | scratch_reset(usbvision); | 553 | scratch_reset(usbvision); |
563 | return parse_state_end_parse; | 554 | return parse_state_end_parse; |
564 | } | 555 | } |
565 | 556 | ||
566 | /* found header */ | 557 | /* found header */ |
567 | if (frame->isoc_header.data_format==ISOC_MODE_COMPRESS) { | 558 | if (frame->isoc_header.data_format == ISOC_MODE_COMPRESS) { |
568 | /* check isoc_header.frame_num for lost frames */ | 559 | /* check isoc_header.frame_num for lost frames */ |
569 | if (usbvision->last_isoc_frame_num >= 0) { | 560 | if (usbvision->last_isoc_frame_num >= 0) { |
570 | if (((usbvision->last_isoc_frame_num + 1) % 32) != frame->isoc_header.frame_num) { | 561 | if (((usbvision->last_isoc_frame_num + 1) % 32) != frame->isoc_header.frame_num) { |
@@ -594,7 +585,7 @@ static enum parse_state usbvision_parse_lines_422(struct usb_usbvision *usbvisio | |||
594 | unsigned char *f; | 585 | unsigned char *f; |
595 | int len; | 586 | int len; |
596 | int i; | 587 | int i; |
597 | unsigned char yuyv[4]={180, 128, 10, 128}; /* YUV components */ | 588 | unsigned char yuyv[4] = { 180, 128, 10, 128 }; /* YUV components */ |
598 | unsigned char rv, gv, bv; /* RGB components */ | 589 | unsigned char rv, gv, bv; /* RGB components */ |
599 | int clipmask_index, bytes_per_pixel; | 590 | int clipmask_index, bytes_per_pixel; |
600 | int stretch_bytes, clipmask_add; | 591 | int stretch_bytes, clipmask_add; |
@@ -603,31 +594,27 @@ static enum parse_state usbvision_parse_lines_422(struct usb_usbvision *usbvisio | |||
603 | f = frame->data + (frame->v4l2_linesize * frame->curline); | 594 | f = frame->data + (frame->v4l2_linesize * frame->curline); |
604 | 595 | ||
605 | /* Make sure there's enough data for the entire line */ | 596 | /* Make sure there's enough data for the entire line */ |
606 | len = (frame->isoc_header.frame_width * 2)+5; | 597 | len = (frame->isoc_header.frame_width * 2) + 5; |
607 | if (scratch_len(usbvision) < len) { | 598 | if (scratch_len(usbvision) < len) { |
608 | PDEBUG(DBG_PARSE, "out of data in line %d, need %u.\n", frame->curline, len); | 599 | PDEBUG(DBG_PARSE, "out of data in line %d, need %u.\n", frame->curline, len); |
609 | return parse_state_out; | 600 | return parse_state_out; |
610 | } | 601 | } |
611 | 602 | ||
612 | if ((frame->curline + 1) >= frame->frmheight) { | 603 | if ((frame->curline + 1) >= frame->frmheight) |
613 | return parse_state_next_frame; | 604 | return parse_state_next_frame; |
614 | } | ||
615 | 605 | ||
616 | bytes_per_pixel = frame->v4l2_format.bytes_per_pixel; | 606 | bytes_per_pixel = frame->v4l2_format.bytes_per_pixel; |
617 | stretch_bytes = (usbvision->stretch_width - 1) * bytes_per_pixel; | 607 | stretch_bytes = (usbvision->stretch_width - 1) * bytes_per_pixel; |
618 | clipmask_index = frame->curline * MAX_FRAME_WIDTH; | 608 | clipmask_index = frame->curline * MAX_FRAME_WIDTH; |
619 | clipmask_add = usbvision->stretch_width; | 609 | clipmask_add = usbvision->stretch_width; |
620 | 610 | ||
621 | for (i = 0; i < frame->frmwidth; i+=(2 * usbvision->stretch_width)) { | 611 | for (i = 0; i < frame->frmwidth; i += (2 * usbvision->stretch_width)) { |
622 | |||
623 | scratch_get(usbvision, &yuyv[0], 4); | 612 | scratch_get(usbvision, &yuyv[0], 4); |
624 | 613 | ||
625 | if (frame->v4l2_format.format == V4L2_PIX_FMT_YUYV) { | 614 | if (frame->v4l2_format.format == V4L2_PIX_FMT_YUYV) { |
626 | *f++ = yuyv[0]; /* Y */ | 615 | *f++ = yuyv[0]; /* Y */ |
627 | *f++ = yuyv[3]; /* U */ | 616 | *f++ = yuyv[3]; /* U */ |
628 | } | 617 | } else { |
629 | else { | ||
630 | |||
631 | YUV_TO_RGB_BY_THE_BOOK(yuyv[0], yuyv[1], yuyv[3], rv, gv, bv); | 618 | YUV_TO_RGB_BY_THE_BOOK(yuyv[0], yuyv[1], yuyv[3], rv, gv, bv); |
632 | switch (frame->v4l2_format.format) { | 619 | switch (frame->v4l2_format.format) { |
633 | case V4L2_PIX_FMT_RGB565: | 620 | case V4L2_PIX_FMT_RGB565: |
@@ -661,9 +648,7 @@ static enum parse_state usbvision_parse_lines_422(struct usb_usbvision *usbvisio | |||
661 | if (frame->v4l2_format.format == V4L2_PIX_FMT_YUYV) { | 648 | if (frame->v4l2_format.format == V4L2_PIX_FMT_YUYV) { |
662 | *f++ = yuyv[2]; /* Y */ | 649 | *f++ = yuyv[2]; /* Y */ |
663 | *f++ = yuyv[1]; /* V */ | 650 | *f++ = yuyv[1]; /* V */ |
664 | } | 651 | } else { |
665 | else { | ||
666 | |||
667 | YUV_TO_RGB_BY_THE_BOOK(yuyv[2], yuyv[1], yuyv[3], rv, gv, bv); | 652 | YUV_TO_RGB_BY_THE_BOOK(yuyv[2], yuyv[1], yuyv[3], rv, gv, bv); |
668 | switch (frame->v4l2_format.format) { | 653 | switch (frame->v4l2_format.format) { |
669 | case V4L2_PIX_FMT_RGB565: | 654 | case V4L2_PIX_FMT_RGB565: |
@@ -698,16 +683,13 @@ static enum parse_state usbvision_parse_lines_422(struct usb_usbvision *usbvisio | |||
698 | frame->curline += usbvision->stretch_height; | 683 | frame->curline += usbvision->stretch_height; |
699 | *pcopylen += frame->v4l2_linesize * usbvision->stretch_height; | 684 | *pcopylen += frame->v4l2_linesize * usbvision->stretch_height; |
700 | 685 | ||
701 | if (frame->curline >= frame->frmheight) { | 686 | if (frame->curline >= frame->frmheight) |
702 | return parse_state_next_frame; | 687 | return parse_state_next_frame; |
703 | } | 688 | return parse_state_continue; |
704 | else { | ||
705 | return parse_state_continue; | ||
706 | } | ||
707 | } | 689 | } |
708 | 690 | ||
709 | /* The decompression routine */ | 691 | /* The decompression routine */ |
710 | static int usbvision_decompress(struct usb_usbvision *usbvision,unsigned char *compressed, | 692 | static int usbvision_decompress(struct usb_usbvision *usbvision, unsigned char *compressed, |
711 | unsigned char *decompressed, int *start_pos, | 693 | unsigned char *decompressed, int *start_pos, |
712 | int *block_typestart_pos, int len) | 694 | int *block_typestart_pos, int len) |
713 | { | 695 | { |
@@ -728,9 +710,8 @@ static int usbvision_decompress(struct usb_usbvision *usbvision,unsigned char *c | |||
728 | rest_pixel = len; | 710 | rest_pixel = len; |
729 | 711 | ||
730 | for (idx = 0; idx < len; idx++) { | 712 | for (idx = 0; idx < len; idx++) { |
731 | |||
732 | if (block_len == 0) { | 713 | if (block_len == 0) { |
733 | if (block_type_len==0) { | 714 | if (block_type_len == 0) { |
734 | block_type_byte = compressed[block_type_pos]; | 715 | block_type_byte = compressed[block_type_pos]; |
735 | block_type_pos++; | 716 | block_type_pos++; |
736 | block_type_len = 4; | 717 | block_type_len = 4; |
@@ -742,7 +723,7 @@ static int usbvision_decompress(struct usb_usbvision *usbvision,unsigned char *c | |||
742 | 723 | ||
743 | pos = extra_pos; | 724 | pos = extra_pos; |
744 | if (block_type == 0) { | 725 | if (block_type == 0) { |
745 | if(rest_pixel >= 24) { | 726 | if (rest_pixel >= 24) { |
746 | idx += 23; | 727 | idx += 23; |
747 | rest_pixel -= 24; | 728 | rest_pixel -= 24; |
748 | integrator = decompressed[idx]; | 729 | integrator = decompressed[idx]; |
@@ -753,11 +734,10 @@ static int usbvision_decompress(struct usb_usbvision *usbvision,unsigned char *c | |||
753 | } else { | 734 | } else { |
754 | block_code = compressed[pos]; | 735 | block_code = compressed[pos]; |
755 | pos++; | 736 | pos++; |
756 | if (rest_pixel >= 24) { | 737 | if (rest_pixel >= 24) |
757 | block_len = 24; | 738 | block_len = 24; |
758 | } else { | 739 | else |
759 | block_len = rest_pixel; | 740 | block_len = rest_pixel; |
760 | } | ||
761 | rest_pixel -= block_len; | 741 | rest_pixel -= block_len; |
762 | extra_pos = pos + (block_len / 4); | 742 | extra_pos = pos + (block_len / 4); |
763 | } | 743 | } |
@@ -765,24 +745,23 @@ static int usbvision_decompress(struct usb_usbvision *usbvision,unsigned char *c | |||
765 | block_type_len -= 1; | 745 | block_type_len -= 1; |
766 | } | 746 | } |
767 | if (block_len > 0) { | 747 | if (block_len > 0) { |
768 | if ((block_len%4) == 0) { | 748 | if ((block_len % 4) == 0) { |
769 | block_byte = compressed[pos]; | 749 | block_byte = compressed[pos]; |
770 | pos++; | 750 | pos++; |
771 | } | 751 | } |
772 | if (block_type == 1) { /* inter Block */ | 752 | if (block_type == 1) /* inter Block */ |
773 | integrator = decompressed[idx]; | 753 | integrator = decompressed[idx]; |
774 | } | ||
775 | switch (block_byte & 0xC0) { | 754 | switch (block_byte & 0xC0) { |
776 | case 0x03<<6: | 755 | case 0x03 << 6: |
777 | integrator += compressed[extra_pos]; | 756 | integrator += compressed[extra_pos]; |
778 | extra_pos++; | 757 | extra_pos++; |
779 | break; | 758 | break; |
780 | case 0x02<<6: | 759 | case 0x02 << 6: |
781 | integrator += block_code; | 760 | integrator += block_code; |
782 | break; | 761 | break; |
783 | case 0x00: | 762 | case 0x00: |
784 | integrator -= block_code; | 763 | integrator -= block_code; |
785 | break; | 764 | break; |
786 | } | 765 | } |
787 | decompressed[idx] = integrator; | 766 | decompressed[idx] = integrator; |
788 | block_byte <<= 2; | 767 | block_byte <<= 2; |
@@ -811,45 +790,40 @@ static enum parse_state usbvision_parse_compress(struct usb_usbvision *usbvision | |||
811 | #define USBVISION_STRIP_HEADER_LEN 3 | 790 | #define USBVISION_STRIP_HEADER_LEN 3 |
812 | 791 | ||
813 | struct usbvision_frame *frame; | 792 | struct usbvision_frame *frame; |
814 | unsigned char *f,*u = NULL ,*v = NULL; | 793 | unsigned char *f, *u = NULL, *v = NULL; |
815 | unsigned char strip_data[USBVISION_STRIP_LEN_MAX]; | 794 | unsigned char strip_data[USBVISION_STRIP_LEN_MAX]; |
816 | unsigned char strip_header[USBVISION_STRIP_HEADER_LEN]; | 795 | unsigned char strip_header[USBVISION_STRIP_HEADER_LEN]; |
817 | int idx, idx_end, strip_len, strip_ptr, Startblock_pos, block_pos, block_type_pos; | 796 | int idx, idx_end, strip_len, strip_ptr, startblock_pos, block_pos, block_type_pos; |
818 | int clipmask_index, bytes_per_pixel, rc; | 797 | int clipmask_index, bytes_per_pixel, rc; |
819 | int image_size; | 798 | int image_size; |
820 | unsigned char rv, gv, bv; | 799 | unsigned char rv, gv, bv; |
821 | static unsigned char *Y, *U, *V; | 800 | static unsigned char *Y, *U, *V; |
822 | 801 | ||
823 | frame = usbvision->cur_frame; | 802 | frame = usbvision->cur_frame; |
824 | image_size = frame->frmwidth * frame->frmheight; | 803 | image_size = frame->frmwidth * frame->frmheight; |
825 | if ( (frame->v4l2_format.format == V4L2_PIX_FMT_YUV422P) || | 804 | if ((frame->v4l2_format.format == V4L2_PIX_FMT_YUV422P) || |
826 | (frame->v4l2_format.format == V4L2_PIX_FMT_YVU420) ) { /* this is a planar format */ | 805 | (frame->v4l2_format.format == V4L2_PIX_FMT_YVU420)) { /* this is a planar format */ |
827 | /* ... v4l2_linesize not used here. */ | 806 | /* ... v4l2_linesize not used here. */ |
828 | f = frame->data + (frame->width * frame->curline); | 807 | f = frame->data + (frame->width * frame->curline); |
829 | } else | 808 | } else |
830 | f = frame->data + (frame->v4l2_linesize * frame->curline); | 809 | f = frame->data + (frame->v4l2_linesize * frame->curline); |
831 | 810 | ||
832 | if (frame->v4l2_format.format == V4L2_PIX_FMT_YUYV){ /* initialise u and v pointers */ | 811 | if (frame->v4l2_format.format == V4L2_PIX_FMT_YUYV) { /* initialise u and v pointers */ |
833 | /* get base of u and b planes add halfoffset */ | 812 | /* get base of u and b planes add halfoffset */ |
834 | |||
835 | u = frame->data | 813 | u = frame->data |
836 | + image_size | 814 | + image_size |
837 | + (frame->frmwidth >>1) * frame->curline ; | 815 | + (frame->frmwidth >> 1) * frame->curline; |
838 | v = u + (image_size >>1 ); | 816 | v = u + (image_size >> 1); |
839 | 817 | } else if (frame->v4l2_format.format == V4L2_PIX_FMT_YVU420) { | |
840 | } else if (frame->v4l2_format.format == V4L2_PIX_FMT_YVU420){ | 818 | v = frame->data + image_size + ((frame->curline * (frame->width)) >> 2); |
841 | 819 | u = v + (image_size >> 2); | |
842 | v = frame->data + image_size + ((frame->curline* (frame->width))>>2) ; | ||
843 | u = v + (image_size >>2) ; | ||
844 | } | 820 | } |
845 | 821 | ||
846 | if (frame->curline == 0) { | 822 | if (frame->curline == 0) |
847 | usbvision_adjust_compression(usbvision); | 823 | usbvision_adjust_compression(usbvision); |
848 | } | ||
849 | 824 | ||
850 | if (scratch_len(usbvision) < USBVISION_STRIP_HEADER_LEN) { | 825 | if (scratch_len(usbvision) < USBVISION_STRIP_HEADER_LEN) |
851 | return parse_state_out; | 826 | return parse_state_out; |
852 | } | ||
853 | 827 | ||
854 | /* get strip header without changing the scratch_read_ptr */ | 828 | /* get strip header without changing the scratch_read_ptr */ |
855 | scratch_set_extra_ptr(usbvision, &strip_ptr, 0); | 829 | scratch_set_extra_ptr(usbvision, &strip_ptr, 0); |
@@ -863,7 +837,7 @@ static enum parse_state usbvision_parse_compress(struct usb_usbvision *usbvision | |||
863 | } | 837 | } |
864 | 838 | ||
865 | if (frame->curline != (int)strip_header[2]) { | 839 | if (frame->curline != (int)strip_header[2]) { |
866 | /* line number missmatch error */ | 840 | /* line number mismatch error */ |
867 | usbvision->strip_line_number_errors++; | 841 | usbvision->strip_line_number_errors++; |
868 | } | 842 | } |
869 | 843 | ||
@@ -883,8 +857,7 @@ static enum parse_state usbvision_parse_compress(struct usb_usbvision *usbvision | |||
883 | Y = usbvision->intra_frame_buffer + frame->frmwidth * frame->curline; | 857 | Y = usbvision->intra_frame_buffer + frame->frmwidth * frame->curline; |
884 | U = usbvision->intra_frame_buffer + image_size + (frame->frmwidth / 2) * (frame->curline / 2); | 858 | U = usbvision->intra_frame_buffer + image_size + (frame->frmwidth / 2) * (frame->curline / 2); |
885 | V = usbvision->intra_frame_buffer + image_size / 4 * 5 + (frame->frmwidth / 2) * (frame->curline / 2); | 859 | V = usbvision->intra_frame_buffer + image_size / 4 * 5 + (frame->frmwidth / 2) * (frame->curline / 2); |
886 | } | 860 | } else { |
887 | else { | ||
888 | return parse_state_next_frame; | 861 | return parse_state_next_frame; |
889 | } | 862 | } |
890 | 863 | ||
@@ -895,107 +868,87 @@ static enum parse_state usbvision_parse_compress(struct usb_usbvision *usbvision | |||
895 | 868 | ||
896 | idx_end = frame->frmwidth; | 869 | idx_end = frame->frmwidth; |
897 | block_type_pos = USBVISION_STRIP_HEADER_LEN; | 870 | block_type_pos = USBVISION_STRIP_HEADER_LEN; |
898 | Startblock_pos = block_type_pos + (idx_end - 1) / 96 + (idx_end / 2 - 1) / 96 + 2; | 871 | startblock_pos = block_type_pos + (idx_end - 1) / 96 + (idx_end / 2 - 1) / 96 + 2; |
899 | block_pos = Startblock_pos; | 872 | block_pos = startblock_pos; |
900 | 873 | ||
901 | usbvision->block_pos = block_pos; | 874 | usbvision->block_pos = block_pos; |
902 | 875 | ||
903 | if ((rc = usbvision_decompress(usbvision, strip_data, Y, &block_pos, &block_type_pos, idx_end)) != idx_end) { | 876 | rc = usbvision_decompress(usbvision, strip_data, Y, &block_pos, &block_type_pos, idx_end); |
904 | /* return parse_state_continue; */ | 877 | if (strip_len > usbvision->max_strip_len) |
905 | } | ||
906 | if (strip_len > usbvision->max_strip_len) { | ||
907 | usbvision->max_strip_len = strip_len; | 878 | usbvision->max_strip_len = strip_len; |
908 | } | ||
909 | 879 | ||
910 | if (frame->curline%2) { | 880 | if (frame->curline % 2) |
911 | if ((rc = usbvision_decompress(usbvision, strip_data, V, &block_pos, &block_type_pos, idx_end/2)) != idx_end/2) { | 881 | rc = usbvision_decompress(usbvision, strip_data, V, &block_pos, &block_type_pos, idx_end / 2); |
912 | /* return parse_state_continue; */ | 882 | else |
913 | } | 883 | rc = usbvision_decompress(usbvision, strip_data, U, &block_pos, &block_type_pos, idx_end / 2); |
914 | } | ||
915 | else { | ||
916 | if ((rc = usbvision_decompress(usbvision, strip_data, U, &block_pos, &block_type_pos, idx_end/2)) != idx_end/2) { | ||
917 | /* return parse_state_continue; */ | ||
918 | } | ||
919 | } | ||
920 | 884 | ||
921 | if (block_pos > usbvision->comprblock_pos) { | 885 | if (block_pos > usbvision->comprblock_pos) |
922 | usbvision->comprblock_pos = block_pos; | 886 | usbvision->comprblock_pos = block_pos; |
923 | } | 887 | if (block_pos > strip_len) |
924 | if (block_pos > strip_len) { | ||
925 | usbvision->strip_len_errors++; | 888 | usbvision->strip_len_errors++; |
926 | } | ||
927 | 889 | ||
928 | for (idx = 0; idx < idx_end; idx++) { | 890 | for (idx = 0; idx < idx_end; idx++) { |
929 | if(frame->v4l2_format.format == V4L2_PIX_FMT_YUYV) { | 891 | if (frame->v4l2_format.format == V4L2_PIX_FMT_YUYV) { |
930 | *f++ = Y[idx]; | 892 | *f++ = Y[idx]; |
931 | *f++ = idx & 0x01 ? U[idx/2] : V[idx/2]; | 893 | *f++ = idx & 0x01 ? U[idx / 2] : V[idx / 2]; |
932 | } | 894 | } else if (frame->v4l2_format.format == V4L2_PIX_FMT_YUV422P) { |
933 | else if(frame->v4l2_format.format == V4L2_PIX_FMT_YUV422P) { | ||
934 | *f++ = Y[idx]; | 895 | *f++ = Y[idx]; |
935 | if ( idx & 0x01) | 896 | if (idx & 0x01) |
936 | *u++ = U[idx>>1] ; | 897 | *u++ = U[idx >> 1]; |
937 | else | 898 | else |
938 | *v++ = V[idx>>1]; | 899 | *v++ = V[idx >> 1]; |
939 | } | 900 | } else if (frame->v4l2_format.format == V4L2_PIX_FMT_YVU420) { |
940 | else if (frame->v4l2_format.format == V4L2_PIX_FMT_YVU420) { | 901 | *f++ = Y[idx]; |
941 | *f++ = Y [idx]; | 902 | if (!((idx & 0x01) | (frame->curline & 0x01))) { |
942 | if ( !(( idx & 0x01 ) | ( frame->curline & 0x01 )) ){ | 903 | /* only need do this for 1 in 4 pixels */ |
943 | 904 | /* intraframe buffer is YUV420 format */ | |
944 | /* only need do this for 1 in 4 pixels */ | 905 | *u++ = U[idx >> 1]; |
945 | /* intraframe buffer is YUV420 format */ | 906 | *v++ = V[idx >> 1]; |
946 | |||
947 | *u++ = U[idx >>1]; | ||
948 | *v++ = V[idx >>1]; | ||
949 | } | 907 | } |
950 | 908 | } else { | |
951 | } | 909 | YUV_TO_RGB_BY_THE_BOOK(Y[idx], U[idx / 2], V[idx / 2], rv, gv, bv); |
952 | else { | ||
953 | YUV_TO_RGB_BY_THE_BOOK(Y[idx], U[idx/2], V[idx/2], rv, gv, bv); | ||
954 | switch (frame->v4l2_format.format) { | 910 | switch (frame->v4l2_format.format) { |
955 | case V4L2_PIX_FMT_GREY: | 911 | case V4L2_PIX_FMT_GREY: |
956 | *f++ = Y[idx]; | 912 | *f++ = Y[idx]; |
957 | break; | 913 | break; |
958 | case V4L2_PIX_FMT_RGB555: | 914 | case V4L2_PIX_FMT_RGB555: |
959 | *f++ = (0x1F & rv) | | 915 | *f++ = (0x1F & rv) | |
960 | (0xE0 & (gv << 5)); | 916 | (0xE0 & (gv << 5)); |
961 | *f++ = (0x03 & (gv >> 3)) | | 917 | *f++ = (0x03 & (gv >> 3)) | |
962 | (0x7C & (bv << 2)); | 918 | (0x7C & (bv << 2)); |
963 | break; | 919 | break; |
964 | case V4L2_PIX_FMT_RGB565: | 920 | case V4L2_PIX_FMT_RGB565: |
965 | *f++ = (0x1F & rv) | | 921 | *f++ = (0x1F & rv) | |
966 | (0xE0 & (gv << 5)); | 922 | (0xE0 & (gv << 5)); |
967 | *f++ = (0x07 & (gv >> 3)) | | 923 | *f++ = (0x07 & (gv >> 3)) | |
968 | (0xF8 & bv); | 924 | (0xF8 & bv); |
969 | break; | 925 | break; |
970 | case V4L2_PIX_FMT_RGB24: | 926 | case V4L2_PIX_FMT_RGB24: |
971 | *f++ = rv; | 927 | *f++ = rv; |
972 | *f++ = gv; | 928 | *f++ = gv; |
973 | *f++ = bv; | 929 | *f++ = bv; |
974 | break; | 930 | break; |
975 | case V4L2_PIX_FMT_RGB32: | 931 | case V4L2_PIX_FMT_RGB32: |
976 | *f++ = rv; | 932 | *f++ = rv; |
977 | *f++ = gv; | 933 | *f++ = gv; |
978 | *f++ = bv; | 934 | *f++ = bv; |
979 | f++; | 935 | f++; |
980 | break; | 936 | break; |
981 | } | 937 | } |
982 | } | 938 | } |
983 | clipmask_index++; | 939 | clipmask_index++; |
984 | } | 940 | } |
985 | /* Deal with non-integer no. of bytes for YUV420P */ | 941 | /* Deal with non-integer no. of bytes for YUV420P */ |
986 | if (frame->v4l2_format.format != V4L2_PIX_FMT_YVU420 ) | 942 | if (frame->v4l2_format.format != V4L2_PIX_FMT_YVU420) |
987 | *pcopylen += frame->v4l2_linesize; | 943 | *pcopylen += frame->v4l2_linesize; |
988 | else | 944 | else |
989 | *pcopylen += frame->curline & 0x01 ? frame->v4l2_linesize : frame->v4l2_linesize << 1; | 945 | *pcopylen += frame->curline & 0x01 ? frame->v4l2_linesize : frame->v4l2_linesize << 1; |
990 | 946 | ||
991 | frame->curline += 1; | 947 | frame->curline += 1; |
992 | 948 | ||
993 | if (frame->curline >= frame->frmheight) { | 949 | if (frame->curline >= frame->frmheight) |
994 | return parse_state_next_frame; | 950 | return parse_state_next_frame; |
995 | } | 951 | return parse_state_continue; |
996 | else { | ||
997 | return parse_state_continue; | ||
998 | } | ||
999 | 952 | ||
1000 | } | 953 | } |
1001 | 954 | ||
@@ -1016,11 +969,11 @@ static enum parse_state usbvision_parse_lines_420(struct usb_usbvision *usbvisio | |||
1016 | unsigned int pixel_per_line, block; | 969 | unsigned int pixel_per_line, block; |
1017 | int pixel, block_split; | 970 | int pixel, block_split; |
1018 | int y_ptr, u_ptr, v_ptr, y_odd_offset; | 971 | int y_ptr, u_ptr, v_ptr, y_odd_offset; |
1019 | const int y_block_size = 128; | 972 | const int y_block_size = 128; |
1020 | const int uv_block_size = 64; | 973 | const int uv_block_size = 64; |
1021 | const int sub_block_size = 32; | 974 | const int sub_block_size = 32; |
1022 | const int y_step[] = { 0, 0, 0, 2 }, y_step_size = 4; | 975 | const int y_step[] = { 0, 0, 0, 2 }, y_step_size = 4; |
1023 | const int uv_step[]= { 0, 0, 0, 4 }, uv_step_size = 4; | 976 | const int uv_step[] = { 0, 0, 0, 4 }, uv_step_size = 4; |
1024 | unsigned char y[2], u, v; /* YUV components */ | 977 | unsigned char y[2], u, v; /* YUV components */ |
1025 | int y_, u_, v_, vb, uvg, ur; | 978 | int y_, u_, v_, vb, uvg, ur; |
1026 | int r_, g_, b_; /* RGB components */ | 979 | int r_, g_, b_; /* RGB components */ |
@@ -1047,9 +1000,8 @@ static enum parse_state usbvision_parse_lines_420(struct usb_usbvision *usbvisio | |||
1047 | return parse_state_out; | 1000 | return parse_state_out; |
1048 | } | 1001 | } |
1049 | 1002 | ||
1050 | if ((frame->curline + 1) >= frame->frmheight) { | 1003 | if ((frame->curline + 1) >= frame->frmheight) |
1051 | return parse_state_next_frame; | 1004 | return parse_state_next_frame; |
1052 | } | ||
1053 | 1005 | ||
1054 | block_split = (pixel_per_line%y_block_size) ? 1 : 0; /* are some blocks splitted into different lines? */ | 1006 | block_split = (pixel_per_line%y_block_size) ? 1 : 0; /* are some blocks splitted into different lines? */ |
1055 | 1007 | ||
@@ -1061,11 +1013,8 @@ static enum parse_state usbvision_parse_lines_420(struct usb_usbvision *usbvisio | |||
1061 | scratch_set_extra_ptr(usbvision, &v_ptr, y_odd_offset | 1013 | scratch_set_extra_ptr(usbvision, &v_ptr, y_odd_offset |
1062 | + (4 - block_split) * sub_block_size); | 1014 | + (4 - block_split) * sub_block_size); |
1063 | 1015 | ||
1064 | for (block = 0; block < (pixel_per_line / sub_block_size); | 1016 | for (block = 0; block < (pixel_per_line / sub_block_size); block++) { |
1065 | block++) { | 1017 | for (pixel = 0; pixel < sub_block_size; pixel += 2) { |
1066 | |||
1067 | |||
1068 | for (pixel = 0; pixel < sub_block_size; pixel +=2) { | ||
1069 | scratch_get(usbvision, &y[0], 2); | 1018 | scratch_get(usbvision, &y[0], 2); |
1070 | scratch_get_extra(usbvision, &u, &u_ptr, 1); | 1019 | scratch_get_extra(usbvision, &u, &u_ptr, 1); |
1071 | scratch_get_extra(usbvision, &v, &v_ptr, 1); | 1020 | scratch_get_extra(usbvision, &v, &v_ptr, 1); |
@@ -1073,19 +1022,18 @@ static enum parse_state usbvision_parse_lines_420(struct usb_usbvision *usbvisio | |||
1073 | /* I don't use the YUV_TO_RGB macro for better performance */ | 1022 | /* I don't use the YUV_TO_RGB macro for better performance */ |
1074 | v_ = v - 128; | 1023 | v_ = v - 128; |
1075 | u_ = u - 128; | 1024 | u_ = u - 128; |
1076 | vb = 132252 * v_; | 1025 | vb = 132252 * v_; |
1077 | uvg= -53281 * u_ - 25625 * v_; | 1026 | uvg = -53281 * u_ - 25625 * v_; |
1078 | ur = 104595 * u_; | 1027 | ur = 104595 * u_; |
1079 | 1028 | ||
1080 | if(frame->v4l2_format.format == V4L2_PIX_FMT_YUYV) { | 1029 | if (frame->v4l2_format.format == V4L2_PIX_FMT_YUYV) { |
1081 | *f_even++ = y[0]; | 1030 | *f_even++ = y[0]; |
1082 | *f_even++ = v; | 1031 | *f_even++ = v; |
1083 | } | 1032 | } else { |
1084 | else { | ||
1085 | y_ = 76284 * (y[0] - 16); | 1033 | y_ = 76284 * (y[0] - 16); |
1086 | 1034 | ||
1087 | b_ = (y_ + vb) >> 16; | 1035 | b_ = (y_ + vb) >> 16; |
1088 | g_ = (y_ + uvg)>> 16; | 1036 | g_ = (y_ + uvg) >> 16; |
1089 | r_ = (y_ + ur) >> 16; | 1037 | r_ = (y_ + ur) >> 16; |
1090 | 1038 | ||
1091 | switch (frame->v4l2_format.format) { | 1039 | switch (frame->v4l2_format.format) { |
@@ -1121,15 +1069,14 @@ static enum parse_state usbvision_parse_lines_420(struct usb_usbvision *usbvisio | |||
1121 | clipmask_even_index += clipmask_add; | 1069 | clipmask_even_index += clipmask_add; |
1122 | f_even += stretch_bytes; | 1070 | f_even += stretch_bytes; |
1123 | 1071 | ||
1124 | if(frame->v4l2_format.format == V4L2_PIX_FMT_YUYV) { | 1072 | if (frame->v4l2_format.format == V4L2_PIX_FMT_YUYV) { |
1125 | *f_even++ = y[1]; | 1073 | *f_even++ = y[1]; |
1126 | *f_even++ = u; | 1074 | *f_even++ = u; |
1127 | } | 1075 | } else { |
1128 | else { | ||
1129 | y_ = 76284 * (y[1] - 16); | 1076 | y_ = 76284 * (y[1] - 16); |
1130 | 1077 | ||
1131 | b_ = (y_ + vb) >> 16; | 1078 | b_ = (y_ + vb) >> 16; |
1132 | g_ = (y_ + uvg)>> 16; | 1079 | g_ = (y_ + uvg) >> 16; |
1133 | r_ = (y_ + ur) >> 16; | 1080 | r_ = (y_ + ur) >> 16; |
1134 | 1081 | ||
1135 | switch (frame->v4l2_format.format) { | 1082 | switch (frame->v4l2_format.format) { |
@@ -1167,15 +1114,14 @@ static enum parse_state usbvision_parse_lines_420(struct usb_usbvision *usbvisio | |||
1167 | 1114 | ||
1168 | scratch_get_extra(usbvision, &y[0], &y_ptr, 2); | 1115 | scratch_get_extra(usbvision, &y[0], &y_ptr, 2); |
1169 | 1116 | ||
1170 | if(frame->v4l2_format.format == V4L2_PIX_FMT_YUYV) { | 1117 | if (frame->v4l2_format.format == V4L2_PIX_FMT_YUYV) { |
1171 | *f_odd++ = y[0]; | 1118 | *f_odd++ = y[0]; |
1172 | *f_odd++ = v; | 1119 | *f_odd++ = v; |
1173 | } | 1120 | } else { |
1174 | else { | ||
1175 | y_ = 76284 * (y[0] - 16); | 1121 | y_ = 76284 * (y[0] - 16); |
1176 | 1122 | ||
1177 | b_ = (y_ + vb) >> 16; | 1123 | b_ = (y_ + vb) >> 16; |
1178 | g_ = (y_ + uvg)>> 16; | 1124 | g_ = (y_ + uvg) >> 16; |
1179 | r_ = (y_ + ur) >> 16; | 1125 | r_ = (y_ + ur) >> 16; |
1180 | 1126 | ||
1181 | switch (frame->v4l2_format.format) { | 1127 | switch (frame->v4l2_format.format) { |
@@ -1211,15 +1157,14 @@ static enum parse_state usbvision_parse_lines_420(struct usb_usbvision *usbvisio | |||
1211 | clipmask_odd_index += clipmask_add; | 1157 | clipmask_odd_index += clipmask_add; |
1212 | f_odd += stretch_bytes; | 1158 | f_odd += stretch_bytes; |
1213 | 1159 | ||
1214 | if(frame->v4l2_format.format == V4L2_PIX_FMT_YUYV) { | 1160 | if (frame->v4l2_format.format == V4L2_PIX_FMT_YUYV) { |
1215 | *f_odd++ = y[1]; | 1161 | *f_odd++ = y[1]; |
1216 | *f_odd++ = u; | 1162 | *f_odd++ = u; |
1217 | } | 1163 | } else { |
1218 | else { | ||
1219 | y_ = 76284 * (y[1] - 16); | 1164 | y_ = 76284 * (y[1] - 16); |
1220 | 1165 | ||
1221 | b_ = (y_ + vb) >> 16; | 1166 | b_ = (y_ + vb) >> 16; |
1222 | g_ = (y_ + uvg)>> 16; | 1167 | g_ = (y_ + uvg) >> 16; |
1223 | r_ = (y_ + ur) >> 16; | 1168 | r_ = (y_ + ur) >> 16; |
1224 | 1169 | ||
1225 | switch (frame->v4l2_format.format) { | 1170 | switch (frame->v4l2_format.format) { |
@@ -1256,7 +1201,7 @@ static enum parse_state usbvision_parse_lines_420(struct usb_usbvision *usbvisio | |||
1256 | f_odd += stretch_bytes; | 1201 | f_odd += stretch_bytes; |
1257 | } | 1202 | } |
1258 | 1203 | ||
1259 | scratch_rm_old(usbvision,y_step[block % y_step_size] * sub_block_size); | 1204 | scratch_rm_old(usbvision, y_step[block % y_step_size] * sub_block_size); |
1260 | scratch_inc_extra_ptr(&y_ptr, y_step[(block + 2 * block_split) % y_step_size] | 1205 | scratch_inc_extra_ptr(&y_ptr, y_step[(block + 2 * block_split) % y_step_size] |
1261 | * sub_block_size); | 1206 | * sub_block_size); |
1262 | scratch_inc_extra_ptr(&u_ptr, uv_step[block % uv_step_size] | 1207 | scratch_inc_extra_ptr(&u_ptr, uv_step[block % uv_step_size] |
@@ -1273,8 +1218,7 @@ static enum parse_state usbvision_parse_lines_420(struct usb_usbvision *usbvisio | |||
1273 | 1218 | ||
1274 | if (frame->curline >= frame->frmheight) | 1219 | if (frame->curline >= frame->frmheight) |
1275 | return parse_state_next_frame; | 1220 | return parse_state_next_frame; |
1276 | else | 1221 | return parse_state_continue; |
1277 | return parse_state_continue; | ||
1278 | } | 1222 | } |
1279 | 1223 | ||
1280 | /* | 1224 | /* |
@@ -1297,34 +1241,24 @@ static void usbvision_parse_data(struct usb_usbvision *usbvision) | |||
1297 | PDEBUG(DBG_PARSE, "parsing len=%d\n", scratch_len(usbvision)); | 1241 | PDEBUG(DBG_PARSE, "parsing len=%d\n", scratch_len(usbvision)); |
1298 | 1242 | ||
1299 | while (1) { | 1243 | while (1) { |
1300 | |||
1301 | newstate = parse_state_out; | 1244 | newstate = parse_state_out; |
1302 | if (scratch_len(usbvision)) { | 1245 | if (scratch_len(usbvision)) { |
1303 | if (frame->scanstate == scan_state_scanning) { | 1246 | if (frame->scanstate == scan_state_scanning) { |
1304 | newstate = usbvision_find_header(usbvision); | 1247 | newstate = usbvision_find_header(usbvision); |
1305 | } | 1248 | } else if (frame->scanstate == scan_state_lines) { |
1306 | else if (frame->scanstate == scan_state_lines) { | 1249 | if (usbvision->isoc_mode == ISOC_MODE_YUV420) |
1307 | if (usbvision->isoc_mode == ISOC_MODE_YUV420) { | ||
1308 | newstate = usbvision_parse_lines_420(usbvision, ©len); | 1250 | newstate = usbvision_parse_lines_420(usbvision, ©len); |
1309 | } | 1251 | else if (usbvision->isoc_mode == ISOC_MODE_YUV422) |
1310 | else if (usbvision->isoc_mode == ISOC_MODE_YUV422) { | ||
1311 | newstate = usbvision_parse_lines_422(usbvision, ©len); | 1252 | newstate = usbvision_parse_lines_422(usbvision, ©len); |
1312 | } | 1253 | else if (usbvision->isoc_mode == ISOC_MODE_COMPRESS) |
1313 | else if (usbvision->isoc_mode == ISOC_MODE_COMPRESS) { | ||
1314 | newstate = usbvision_parse_compress(usbvision, ©len); | 1254 | newstate = usbvision_parse_compress(usbvision, ©len); |
1315 | } | ||
1316 | |||
1317 | } | 1255 | } |
1318 | } | 1256 | } |
1319 | if (newstate == parse_state_continue) { | 1257 | if (newstate == parse_state_continue) |
1320 | continue; | 1258 | continue; |
1321 | } | 1259 | if ((newstate == parse_state_next_frame) || (newstate == parse_state_out)) |
1322 | else if ((newstate == parse_state_next_frame) || (newstate == parse_state_out)) { | ||
1323 | break; | 1260 | break; |
1324 | } | 1261 | return; /* parse_state_end_parse */ |
1325 | else { | ||
1326 | return; /* parse_state_end_parse */ | ||
1327 | } | ||
1328 | } | 1262 | } |
1329 | 1263 | ||
1330 | if (newstate == parse_state_next_frame) { | 1264 | if (newstate == parse_state_next_frame) { |
@@ -1344,10 +1278,9 @@ static void usbvision_parse_data(struct usb_usbvision *usbvision) | |||
1344 | PDEBUG(DBG_PARSE, "Wake up !"); | 1278 | PDEBUG(DBG_PARSE, "Wake up !"); |
1345 | wake_up_interruptible(&usbvision->wait_frame); | 1279 | wake_up_interruptible(&usbvision->wait_frame); |
1346 | } | 1280 | } |
1347 | } | 1281 | } else { |
1348 | else | ||
1349 | frame->grabstate = frame_state_grabbing; | 1282 | frame->grabstate = frame_state_grabbing; |
1350 | 1283 | } | |
1351 | 1284 | ||
1352 | /* Update the frame's uncompressed length. */ | 1285 | /* Update the frame's uncompressed length. */ |
1353 | frame->scanlength += copylen; | 1286 | frame->scanlength += copylen; |
@@ -1381,14 +1314,12 @@ static int usbvision_compress_isochronous(struct usb_usbvision *usbvision, | |||
1381 | PDEBUG(DBG_ISOC, "error packet [%d]", i); | 1314 | PDEBUG(DBG_ISOC, "error packet [%d]", i); |
1382 | usbvision->isoc_skip_count++; | 1315 | usbvision->isoc_skip_count++; |
1383 | continue; | 1316 | continue; |
1384 | } | 1317 | } else if (packet_len == 0) { /* Frame end ????? */ |
1385 | else if (packet_len == 0) { /* Frame end ????? */ | ||
1386 | PDEBUG(DBG_ISOC, "null packet [%d]", i); | 1318 | PDEBUG(DBG_ISOC, "null packet [%d]", i); |
1387 | usbvision->isocstate=isoc_state_no_frame; | 1319 | usbvision->isocstate = isoc_state_no_frame; |
1388 | usbvision->isoc_skip_count++; | 1320 | usbvision->isoc_skip_count++; |
1389 | continue; | 1321 | continue; |
1390 | } | 1322 | } else if (packet_len > usbvision->isoc_packet_size) { |
1391 | else if (packet_len > usbvision->isoc_packet_size) { | ||
1392 | PDEBUG(DBG_ISOC, "packet[%d] > isoc_packet_size", i); | 1323 | PDEBUG(DBG_ISOC, "packet[%d] > isoc_packet_size", i); |
1393 | usbvision->isoc_skip_count++; | 1324 | usbvision->isoc_skip_count++; |
1394 | continue; | 1325 | continue; |
@@ -1396,8 +1327,8 @@ static int usbvision_compress_isochronous(struct usb_usbvision *usbvision, | |||
1396 | 1327 | ||
1397 | PDEBUG(DBG_ISOC, "packet ok [%d] len=%d", i, packet_len); | 1328 | PDEBUG(DBG_ISOC, "packet ok [%d] len=%d", i, packet_len); |
1398 | 1329 | ||
1399 | if (usbvision->isocstate==isoc_state_no_frame) { /* new frame begins */ | 1330 | if (usbvision->isocstate == isoc_state_no_frame) { /* new frame begins */ |
1400 | usbvision->isocstate=isoc_state_in_frame; | 1331 | usbvision->isocstate = isoc_state_in_frame; |
1401 | scratch_mark_header(usbvision); | 1332 | scratch_mark_header(usbvision); |
1402 | usbvision_measure_bandwidth(usbvision); | 1333 | usbvision_measure_bandwidth(usbvision); |
1403 | PDEBUG(DBG_ISOC, "packet with header"); | 1334 | PDEBUG(DBG_ISOC, "packet with header"); |
@@ -1412,7 +1343,6 @@ static int usbvision_compress_isochronous(struct usb_usbvision *usbvision, | |||
1412 | * your favorite evil here. | 1343 | * your favorite evil here. |
1413 | */ | 1344 | */ |
1414 | if (scratch_free(usbvision) < packet_len) { | 1345 | if (scratch_free(usbvision) < packet_len) { |
1415 | |||
1416 | usbvision->scratch_ovf_count++; | 1346 | usbvision->scratch_ovf_count++; |
1417 | PDEBUG(DBG_ISOC, "scratch buf overflow! scr_len: %d, n: %d", | 1347 | PDEBUG(DBG_ISOC, "scratch buf overflow! scr_len: %d, n: %d", |
1418 | scratch_len(usbvision), packet_len); | 1348 | scratch_len(usbvision), packet_len); |
@@ -1428,6 +1358,7 @@ static int usbvision_compress_isochronous(struct usb_usbvision *usbvision, | |||
1428 | #if ENABLE_HEXDUMP | 1358 | #if ENABLE_HEXDUMP |
1429 | if (totlen > 0) { | 1359 | if (totlen > 0) { |
1430 | static int foo; | 1360 | static int foo; |
1361 | |||
1431 | if (foo < 1) { | 1362 | if (foo < 1) { |
1432 | printk(KERN_DEBUG "+%d.\n", usbvision->scratchlen); | 1363 | printk(KERN_DEBUG "+%d.\n", usbvision->scratchlen); |
1433 | usbvision_hexdump(data0, (totlen > 64) ? 64 : totlen); | 1364 | usbvision_hexdump(data0, (totlen > 64) ? 64 : totlen); |
@@ -1435,7 +1366,7 @@ static int usbvision_compress_isochronous(struct usb_usbvision *usbvision, | |||
1435 | } | 1366 | } |
1436 | } | 1367 | } |
1437 | #endif | 1368 | #endif |
1438 | return totlen; | 1369 | return totlen; |
1439 | } | 1370 | } |
1440 | 1371 | ||
1441 | static void usbvision_isoc_irq(struct urb *urb) | 1372 | static void usbvision_isoc_irq(struct urb *urb) |
@@ -1452,9 +1383,8 @@ static void usbvision_isoc_irq(struct urb *urb) | |||
1452 | return; | 1383 | return; |
1453 | 1384 | ||
1454 | /* any urb with wrong status is ignored without acknowledgement */ | 1385 | /* any urb with wrong status is ignored without acknowledgement */ |
1455 | if (urb->status == -ENOENT) { | 1386 | if (urb->status == -ENOENT) |
1456 | return; | 1387 | return; |
1457 | } | ||
1458 | 1388 | ||
1459 | f = &usbvision->cur_frame; | 1389 | f = &usbvision->cur_frame; |
1460 | 1390 | ||
@@ -1476,26 +1406,23 @@ static void usbvision_isoc_irq(struct urb *urb) | |||
1476 | usbvision->urb_length = len; | 1406 | usbvision->urb_length = len; |
1477 | 1407 | ||
1478 | if (usbvision->streaming == stream_on) { | 1408 | if (usbvision->streaming == stream_on) { |
1479 | |||
1480 | /* If we collected enough data let's parse! */ | 1409 | /* If we collected enough data let's parse! */ |
1481 | if ((scratch_len(usbvision) > USBVISION_HEADER_LENGTH) && | 1410 | if (scratch_len(usbvision) > USBVISION_HEADER_LENGTH && |
1482 | (!list_empty(&(usbvision->inqueue))) ) { | 1411 | !list_empty(&(usbvision->inqueue))) { |
1483 | if (!(*f)) { | 1412 | if (!(*f)) { |
1484 | (*f) = list_entry(usbvision->inqueue.next, | 1413 | (*f) = list_entry(usbvision->inqueue.next, |
1485 | struct usbvision_frame, | 1414 | struct usbvision_frame, |
1486 | frame); | 1415 | frame); |
1487 | } | 1416 | } |
1488 | usbvision_parse_data(usbvision); | 1417 | usbvision_parse_data(usbvision); |
1489 | } | 1418 | } else { |
1490 | else { | ||
1491 | /* If we don't have a frame | 1419 | /* If we don't have a frame |
1492 | we're current working on, complain */ | 1420 | we're current working on, complain */ |
1493 | PDEBUG(DBG_IRQ, | 1421 | PDEBUG(DBG_IRQ, |
1494 | "received data, but no one needs it"); | 1422 | "received data, but no one needs it"); |
1495 | scratch_reset(usbvision); | 1423 | scratch_reset(usbvision); |
1496 | } | 1424 | } |
1497 | } | 1425 | } else { |
1498 | else { | ||
1499 | PDEBUG(DBG_IRQ, "received data, but no one needs it"); | 1426 | PDEBUG(DBG_IRQ, "received data, but no one needs it"); |
1500 | scratch_reset(usbvision); | 1427 | scratch_reset(usbvision); |
1501 | } | 1428 | } |
@@ -1509,9 +1436,9 @@ static void usbvision_isoc_irq(struct urb *urb) | |||
1509 | 1436 | ||
1510 | urb->status = 0; | 1437 | urb->status = 0; |
1511 | urb->dev = usbvision->dev; | 1438 | urb->dev = usbvision->dev; |
1512 | err_code = usb_submit_urb (urb, GFP_ATOMIC); | 1439 | err_code = usb_submit_urb(urb, GFP_ATOMIC); |
1513 | 1440 | ||
1514 | if(err_code) { | 1441 | if (err_code) { |
1515 | dev_err(&usbvision->dev->dev, | 1442 | dev_err(&usbvision->dev->dev, |
1516 | "%s: usb_submit_urb failed: error %d\n", | 1443 | "%s: usb_submit_urb failed: error %d\n", |
1517 | __func__, err_code); | 1444 | __func__, err_code); |
@@ -1587,24 +1514,21 @@ static void usbvision_ctrl_urb_complete(struct urb *urb) | |||
1587 | 1514 | ||
1588 | PDEBUG(DBG_IRQ, ""); | 1515 | PDEBUG(DBG_IRQ, ""); |
1589 | usbvision->ctrl_urb_busy = 0; | 1516 | usbvision->ctrl_urb_busy = 0; |
1590 | if (waitqueue_active(&usbvision->ctrl_urb_wq)) { | 1517 | if (waitqueue_active(&usbvision->ctrl_urb_wq)) |
1591 | wake_up_interruptible(&usbvision->ctrl_urb_wq); | 1518 | wake_up_interruptible(&usbvision->ctrl_urb_wq); |
1592 | } | ||
1593 | } | 1519 | } |
1594 | 1520 | ||
1595 | 1521 | ||
1596 | static int usbvision_write_reg_irq(struct usb_usbvision *usbvision,int address, | 1522 | static int usbvision_write_reg_irq(struct usb_usbvision *usbvision, int address, |
1597 | unsigned char *data, int len) | 1523 | unsigned char *data, int len) |
1598 | { | 1524 | { |
1599 | int err_code = 0; | 1525 | int err_code = 0; |
1600 | 1526 | ||
1601 | PDEBUG(DBG_IRQ, ""); | 1527 | PDEBUG(DBG_IRQ, ""); |
1602 | if (len > 8) { | 1528 | if (len > 8) |
1603 | return -EFAULT; | 1529 | return -EFAULT; |
1604 | } | 1530 | if (usbvision->ctrl_urb_busy) |
1605 | if (usbvision->ctrl_urb_busy) { | ||
1606 | return -EBUSY; | 1531 | return -EBUSY; |
1607 | } | ||
1608 | usbvision->ctrl_urb_busy = 1; | 1532 | usbvision->ctrl_urb_busy = 1; |
1609 | 1533 | ||
1610 | usbvision->ctrl_urb_setup.bRequestType = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT; | 1534 | usbvision->ctrl_urb_setup.bRequestType = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT; |
@@ -1612,7 +1536,7 @@ static int usbvision_write_reg_irq(struct usb_usbvision *usbvision,int address, | |||
1612 | usbvision->ctrl_urb_setup.wValue = 0; | 1536 | usbvision->ctrl_urb_setup.wValue = 0; |
1613 | usbvision->ctrl_urb_setup.wIndex = cpu_to_le16(address); | 1537 | usbvision->ctrl_urb_setup.wIndex = cpu_to_le16(address); |
1614 | usbvision->ctrl_urb_setup.wLength = cpu_to_le16(len); | 1538 | usbvision->ctrl_urb_setup.wLength = cpu_to_le16(len); |
1615 | usb_fill_control_urb (usbvision->ctrl_urb, usbvision->dev, | 1539 | usb_fill_control_urb(usbvision->ctrl_urb, usbvision->dev, |
1616 | usb_sndctrlpipe(usbvision->dev, 1), | 1540 | usb_sndctrlpipe(usbvision->dev, 1), |
1617 | (unsigned char *)&usbvision->ctrl_urb_setup, | 1541 | (unsigned char *)&usbvision->ctrl_urb_setup, |
1618 | (void *)usbvision->ctrl_urb_buffer, len, | 1542 | (void *)usbvision->ctrl_urb_buffer, len, |
@@ -1652,7 +1576,7 @@ static int usbvision_init_compression(struct usb_usbvision *usbvision) | |||
1652 | * return: 0 : no error | 1576 | * return: 0 : no error |
1653 | * sets used_bandwidth to 1-100 : 1-100% of full bandwidth resp. to isoc_packet_size | 1577 | * sets used_bandwidth to 1-100 : 1-100% of full bandwidth resp. to isoc_packet_size |
1654 | */ | 1578 | */ |
1655 | static int usbvision_measure_bandwidth (struct usb_usbvision *usbvision) | 1579 | static int usbvision_measure_bandwidth(struct usb_usbvision *usbvision) |
1656 | { | 1580 | { |
1657 | int err_code = 0; | 1581 | int err_code = 0; |
1658 | 1582 | ||
@@ -1672,7 +1596,7 @@ static int usbvision_measure_bandwidth (struct usb_usbvision *usbvision) | |||
1672 | return err_code; | 1596 | return err_code; |
1673 | } | 1597 | } |
1674 | 1598 | ||
1675 | static int usbvision_adjust_compression (struct usb_usbvision *usbvision) | 1599 | static int usbvision_adjust_compression(struct usb_usbvision *usbvision) |
1676 | { | 1600 | { |
1677 | int err_code = 0; | 1601 | int err_code = 0; |
1678 | unsigned char buffer[6]; | 1602 | unsigned char buffer[6]; |
@@ -1682,29 +1606,29 @@ static int usbvision_adjust_compression (struct usb_usbvision *usbvision) | |||
1682 | usbvision->compr_level += (usbvision->used_bandwidth - 90) / 2; | 1606 | usbvision->compr_level += (usbvision->used_bandwidth - 90) / 2; |
1683 | RESTRICT_TO_RANGE(usbvision->compr_level, 0, 100); | 1607 | RESTRICT_TO_RANGE(usbvision->compr_level, 0, 100); |
1684 | if (usbvision->compr_level != usbvision->last_compr_level) { | 1608 | if (usbvision->compr_level != usbvision->last_compr_level) { |
1685 | int distorsion; | 1609 | int distortion; |
1610 | |||
1686 | if (usbvision->bridge_type == BRIDGE_NT1004 || usbvision->bridge_type == BRIDGE_NT1005) { | 1611 | if (usbvision->bridge_type == BRIDGE_NT1004 || usbvision->bridge_type == BRIDGE_NT1005) { |
1687 | buffer[0] = (unsigned char)(4 + 16 * usbvision->compr_level / 100); /* PCM Threshold 1 */ | 1612 | buffer[0] = (unsigned char)(4 + 16 * usbvision->compr_level / 100); /* PCM Threshold 1 */ |
1688 | buffer[1] = (unsigned char)(4 + 8 * usbvision->compr_level / 100); /* PCM Threshold 2 */ | 1613 | buffer[1] = (unsigned char)(4 + 8 * usbvision->compr_level / 100); /* PCM Threshold 2 */ |
1689 | distorsion = 7 + 248 * usbvision->compr_level / 100; | 1614 | distortion = 7 + 248 * usbvision->compr_level / 100; |
1690 | buffer[2] = (unsigned char)(distorsion & 0xFF); /* Average distorsion Threshold (inter) */ | 1615 | buffer[2] = (unsigned char)(distortion & 0xFF); /* Average distortion Threshold (inter) */ |
1691 | buffer[3] = (unsigned char)(distorsion & 0xFF); /* Average distorsion Threshold (intra) */ | 1616 | buffer[3] = (unsigned char)(distortion & 0xFF); /* Average distortion Threshold (intra) */ |
1692 | distorsion = 1 + 42 * usbvision->compr_level / 100; | 1617 | distortion = 1 + 42 * usbvision->compr_level / 100; |
1693 | buffer[4] = (unsigned char)(distorsion & 0xFF); /* Maximum distorsion Threshold (inter) */ | 1618 | buffer[4] = (unsigned char)(distortion & 0xFF); /* Maximum distortion Threshold (inter) */ |
1694 | buffer[5] = (unsigned char)(distorsion & 0xFF); /* Maximum distorsion Threshold (intra) */ | 1619 | buffer[5] = (unsigned char)(distortion & 0xFF); /* Maximum distortion Threshold (intra) */ |
1695 | } | 1620 | } else { /* BRIDGE_NT1003 */ |
1696 | else { /* BRIDGE_NT1003 */ | ||
1697 | buffer[0] = (unsigned char)(4 + 16 * usbvision->compr_level / 100); /* PCM threshold 1 */ | 1621 | buffer[0] = (unsigned char)(4 + 16 * usbvision->compr_level / 100); /* PCM threshold 1 */ |
1698 | buffer[1] = (unsigned char)(4 + 8 * usbvision->compr_level / 100); /* PCM threshold 2 */ | 1622 | buffer[1] = (unsigned char)(4 + 8 * usbvision->compr_level / 100); /* PCM threshold 2 */ |
1699 | distorsion = 2 + 253 * usbvision->compr_level / 100; | 1623 | distortion = 2 + 253 * usbvision->compr_level / 100; |
1700 | buffer[2] = (unsigned char)(distorsion & 0xFF); /* distorsion threshold bit0-7 */ | 1624 | buffer[2] = (unsigned char)(distortion & 0xFF); /* distortion threshold bit0-7 */ |
1701 | buffer[3] = 0; /* (unsigned char)((distorsion >> 8) & 0x0F); distorsion threshold bit 8-11 */ | 1625 | buffer[3] = 0; /* (unsigned char)((distortion >> 8) & 0x0F); distortion threshold bit 8-11 */ |
1702 | distorsion = 0 + 43 * usbvision->compr_level / 100; | 1626 | distortion = 0 + 43 * usbvision->compr_level / 100; |
1703 | buffer[4] = (unsigned char)(distorsion & 0xFF); /* maximum distorsion bit0-7 */ | 1627 | buffer[4] = (unsigned char)(distortion & 0xFF); /* maximum distortion bit0-7 */ |
1704 | buffer[5] = 0; /* (unsigned char)((distorsion >> 8) & 0x01); maximum distorsion bit 8 */ | 1628 | buffer[5] = 0; /* (unsigned char)((distortion >> 8) & 0x01); maximum distortion bit 8 */ |
1705 | } | 1629 | } |
1706 | err_code = usbvision_write_reg_irq(usbvision, USBVISION_PCM_THR1, buffer, 6); | 1630 | err_code = usbvision_write_reg_irq(usbvision, USBVISION_PCM_THR1, buffer, 6); |
1707 | if (err_code == 0){ | 1631 | if (err_code == 0) { |
1708 | PDEBUG(DBG_IRQ, "new compr params %#02x %#02x %#02x %#02x %#02x %#02x", buffer[0], | 1632 | PDEBUG(DBG_IRQ, "new compr params %#02x %#02x %#02x %#02x %#02x %#02x", buffer[0], |
1709 | buffer[1], buffer[2], buffer[3], buffer[4], buffer[5]); | 1633 | buffer[1], buffer[2], buffer[3], buffer[4], buffer[5]); |
1710 | usbvision->last_compr_level = usbvision->compr_level; | 1634 | usbvision->last_compr_level = usbvision->compr_level; |
@@ -1714,7 +1638,7 @@ static int usbvision_adjust_compression (struct usb_usbvision *usbvision) | |||
1714 | return err_code; | 1638 | return err_code; |
1715 | } | 1639 | } |
1716 | 1640 | ||
1717 | static int usbvision_request_intra (struct usb_usbvision *usbvision) | 1641 | static int usbvision_request_intra(struct usb_usbvision *usbvision) |
1718 | { | 1642 | { |
1719 | int err_code = 0; | 1643 | int err_code = 0; |
1720 | unsigned char buffer[1]; | 1644 | unsigned char buffer[1]; |
@@ -1726,7 +1650,7 @@ static int usbvision_request_intra (struct usb_usbvision *usbvision) | |||
1726 | return err_code; | 1650 | return err_code; |
1727 | } | 1651 | } |
1728 | 1652 | ||
1729 | static int usbvision_unrequest_intra (struct usb_usbvision *usbvision) | 1653 | static int usbvision_unrequest_intra(struct usb_usbvision *usbvision) |
1730 | { | 1654 | { |
1731 | int err_code = 0; | 1655 | int err_code = 0; |
1732 | unsigned char buffer[1]; | 1656 | unsigned char buffer[1]; |
@@ -1749,10 +1673,9 @@ int usbvision_power_off(struct usb_usbvision *usbvision) | |||
1749 | PDEBUG(DBG_FUNC, ""); | 1673 | PDEBUG(DBG_FUNC, ""); |
1750 | 1674 | ||
1751 | err_code = usbvision_write_reg(usbvision, USBVISION_PWR_REG, USBVISION_SSPND_EN); | 1675 | err_code = usbvision_write_reg(usbvision, USBVISION_PWR_REG, USBVISION_SSPND_EN); |
1752 | if (err_code == 1) { | 1676 | if (err_code == 1) |
1753 | usbvision->power = 0; | 1677 | usbvision->power = 0; |
1754 | } | 1678 | PDEBUG(DBG_FUNC, "%s: err_code %d", (err_code != 1) ? "ERROR" : "power is off", err_code); |
1755 | PDEBUG(DBG_FUNC, "%s: err_code %d", (err_code!=1)?"ERROR":"power is off", err_code); | ||
1756 | return err_code; | 1679 | return err_code; |
1757 | } | 1680 | } |
1758 | 1681 | ||
@@ -1804,18 +1727,16 @@ int usbvision_set_output(struct usb_usbvision *usbvision, int width, | |||
1804 | { | 1727 | { |
1805 | int err_code = 0; | 1728 | int err_code = 0; |
1806 | int usb_width, usb_height; | 1729 | int usb_width, usb_height; |
1807 | unsigned int frame_rate=0, frame_drop=0; | 1730 | unsigned int frame_rate = 0, frame_drop = 0; |
1808 | unsigned char value[4]; | 1731 | unsigned char value[4]; |
1809 | 1732 | ||
1810 | if (!USBVISION_IS_OPERATIONAL(usbvision)) { | 1733 | if (!USBVISION_IS_OPERATIONAL(usbvision)) |
1811 | return 0; | 1734 | return 0; |
1812 | } | ||
1813 | 1735 | ||
1814 | if (width > MAX_USB_WIDTH) { | 1736 | if (width > MAX_USB_WIDTH) { |
1815 | usb_width = width / 2; | 1737 | usb_width = width / 2; |
1816 | usbvision->stretch_width = 2; | 1738 | usbvision->stretch_width = 2; |
1817 | } | 1739 | } else { |
1818 | else { | ||
1819 | usb_width = width; | 1740 | usb_width = width; |
1820 | usbvision->stretch_width = 1; | 1741 | usbvision->stretch_width = 1; |
1821 | } | 1742 | } |
@@ -1823,8 +1744,7 @@ int usbvision_set_output(struct usb_usbvision *usbvision, int width, | |||
1823 | if (height > MAX_USB_HEIGHT) { | 1744 | if (height > MAX_USB_HEIGHT) { |
1824 | usb_height = height / 2; | 1745 | usb_height = height / 2; |
1825 | usbvision->stretch_height = 2; | 1746 | usbvision->stretch_height = 2; |
1826 | } | 1747 | } else { |
1827 | else { | ||
1828 | usb_height = height; | 1748 | usb_height = height; |
1829 | usbvision->stretch_height = 1; | 1749 | usbvision->stretch_height = 1; |
1830 | } | 1750 | } |
@@ -1859,28 +1779,23 @@ int usbvision_set_output(struct usb_usbvision *usbvision, int width, | |||
1859 | usbvision->curheight = usbvision->stretch_height * usb_height; | 1779 | usbvision->curheight = usbvision->stretch_height * usb_height; |
1860 | } | 1780 | } |
1861 | 1781 | ||
1862 | if (usbvision->isoc_mode == ISOC_MODE_YUV422) { | 1782 | if (usbvision->isoc_mode == ISOC_MODE_YUV422) |
1863 | frame_rate = (usbvision->isoc_packet_size * 1000) / (usb_width * usb_height * 2); | 1783 | frame_rate = (usbvision->isoc_packet_size * 1000) / (usb_width * usb_height * 2); |
1864 | } | 1784 | else if (usbvision->isoc_mode == ISOC_MODE_YUV420) |
1865 | else if (usbvision->isoc_mode == ISOC_MODE_YUV420) { | ||
1866 | frame_rate = (usbvision->isoc_packet_size * 1000) / ((usb_width * usb_height * 12) / 8); | 1785 | frame_rate = (usbvision->isoc_packet_size * 1000) / ((usb_width * usb_height * 12) / 8); |
1867 | } | 1786 | else |
1868 | else { | ||
1869 | frame_rate = FRAMERATE_MAX; | 1787 | frame_rate = FRAMERATE_MAX; |
1870 | } | ||
1871 | 1788 | ||
1872 | if (usbvision->tvnorm_id & V4L2_STD_625_50) { | 1789 | if (usbvision->tvnorm_id & V4L2_STD_625_50) |
1873 | frame_drop = frame_rate * 32 / 25 - 1; | 1790 | frame_drop = frame_rate * 32 / 25 - 1; |
1874 | } | 1791 | else if (usbvision->tvnorm_id & V4L2_STD_525_60) |
1875 | else if (usbvision->tvnorm_id & V4L2_STD_525_60) { | ||
1876 | frame_drop = frame_rate * 32 / 30 - 1; | 1792 | frame_drop = frame_rate * 32 / 30 - 1; |
1877 | } | ||
1878 | 1793 | ||
1879 | RESTRICT_TO_RANGE(frame_drop, FRAMERATE_MIN, FRAMERATE_MAX); | 1794 | RESTRICT_TO_RANGE(frame_drop, FRAMERATE_MIN, FRAMERATE_MAX); |
1880 | 1795 | ||
1881 | PDEBUG(DBG_FUNC, "frame_rate %d fps, frame_drop %d", frame_rate, frame_drop); | 1796 | PDEBUG(DBG_FUNC, "frame_rate %d fps, frame_drop %d", frame_rate, frame_drop); |
1882 | 1797 | ||
1883 | frame_drop = FRAMERATE_MAX; /* We can allow the maximum here, because dropping is controlled */ | 1798 | frame_drop = FRAMERATE_MAX; /* We can allow the maximum here, because dropping is controlled */ |
1884 | 1799 | ||
1885 | /* frame_drop = 7; => frame_phase = 1, 5, 9, 13, 17, 21, 25, 0, 4, 8, ... | 1800 | /* frame_drop = 7; => frame_phase = 1, 5, 9, 13, 17, 21, 25, 0, 4, 8, ... |
1886 | => frame_skip = 4; | 1801 | => frame_skip = 4; |
@@ -1904,7 +1819,7 @@ int usbvision_frames_alloc(struct usb_usbvision *usbvision, int number_of_frames | |||
1904 | int i; | 1819 | int i; |
1905 | 1820 | ||
1906 | /* needs to be page aligned cause the buffers can be mapped individually! */ | 1821 | /* needs to be page aligned cause the buffers can be mapped individually! */ |
1907 | usbvision->max_frame_size = PAGE_ALIGN(usbvision->curwidth * | 1822 | usbvision->max_frame_size = PAGE_ALIGN(usbvision->curwidth * |
1908 | usbvision->curheight * | 1823 | usbvision->curheight * |
1909 | usbvision->palette.bytes_per_pixel); | 1824 | usbvision->palette.bytes_per_pixel); |
1910 | 1825 | ||
@@ -1912,9 +1827,9 @@ int usbvision_frames_alloc(struct usb_usbvision *usbvision, int number_of_frames | |||
1912 | usbvision->num_frames = number_of_frames; | 1827 | usbvision->num_frames = number_of_frames; |
1913 | while (usbvision->num_frames > 0) { | 1828 | while (usbvision->num_frames > 0) { |
1914 | usbvision->fbuf_size = usbvision->num_frames * usbvision->max_frame_size; | 1829 | usbvision->fbuf_size = usbvision->num_frames * usbvision->max_frame_size; |
1915 | if((usbvision->fbuf = usbvision_rvmalloc(usbvision->fbuf_size))) { | 1830 | usbvision->fbuf = usbvision_rvmalloc(usbvision->fbuf_size); |
1831 | if (usbvision->fbuf) | ||
1916 | break; | 1832 | break; |
1917 | } | ||
1918 | usbvision->num_frames--; | 1833 | usbvision->num_frames--; |
1919 | } | 1834 | } |
1920 | 1835 | ||
@@ -1937,7 +1852,8 @@ int usbvision_frames_alloc(struct usb_usbvision *usbvision, int number_of_frames | |||
1937 | usbvision->frame[i].height = usbvision->curheight; | 1852 | usbvision->frame[i].height = usbvision->curheight; |
1938 | usbvision->frame[i].bytes_read = 0; | 1853 | usbvision->frame[i].bytes_read = 0; |
1939 | } | 1854 | } |
1940 | PDEBUG(DBG_FUNC, "allocated %d frames (%d bytes per frame)",usbvision->num_frames,usbvision->max_frame_size); | 1855 | PDEBUG(DBG_FUNC, "allocated %d frames (%d bytes per frame)", |
1856 | usbvision->num_frames, usbvision->max_frame_size); | ||
1941 | return usbvision->num_frames; | 1857 | return usbvision->num_frames; |
1942 | } | 1858 | } |
1943 | 1859 | ||
@@ -1948,7 +1864,7 @@ int usbvision_frames_alloc(struct usb_usbvision *usbvision, int number_of_frames | |||
1948 | void usbvision_frames_free(struct usb_usbvision *usbvision) | 1864 | void usbvision_frames_free(struct usb_usbvision *usbvision) |
1949 | { | 1865 | { |
1950 | /* Have to free all that memory */ | 1866 | /* Have to free all that memory */ |
1951 | PDEBUG(DBG_FUNC, "free %d frames",usbvision->num_frames); | 1867 | PDEBUG(DBG_FUNC, "free %d frames", usbvision->num_frames); |
1952 | 1868 | ||
1953 | if (usbvision->fbuf != NULL) { | 1869 | if (usbvision->fbuf != NULL) { |
1954 | usbvision_rvfree(usbvision->fbuf, usbvision->fbuf_size); | 1870 | usbvision_rvfree(usbvision->fbuf, usbvision->fbuf_size); |
@@ -2033,18 +1949,17 @@ static int usbvision_set_compress_params(struct usb_usbvision *usbvision) | |||
2033 | if (usbvision->bridge_type == BRIDGE_NT1004) { | 1949 | if (usbvision->bridge_type == BRIDGE_NT1004) { |
2034 | value[0] = 20; /* PCM Threshold 1 */ | 1950 | value[0] = 20; /* PCM Threshold 1 */ |
2035 | value[1] = 12; /* PCM Threshold 2 */ | 1951 | value[1] = 12; /* PCM Threshold 2 */ |
2036 | value[2] = 255; /* Distorsion Threshold inter */ | 1952 | value[2] = 255; /* Distortion Threshold inter */ |
2037 | value[3] = 255; /* Distorsion Threshold intra */ | 1953 | value[3] = 255; /* Distortion Threshold intra */ |
2038 | value[4] = 43; /* Max Distorsion inter */ | 1954 | value[4] = 43; /* Max Distortion inter */ |
2039 | value[5] = 43; /* Max Distorsion intra */ | 1955 | value[5] = 43; /* Max Distortion intra */ |
2040 | } | 1956 | } else { |
2041 | else { | ||
2042 | value[0] = 20; /* PCM Threshold 1 */ | 1957 | value[0] = 20; /* PCM Threshold 1 */ |
2043 | value[1] = 12; /* PCM Threshold 2 */ | 1958 | value[1] = 12; /* PCM Threshold 2 */ |
2044 | value[2] = 255; /* Distorsion Threshold d7-d0 */ | 1959 | value[2] = 255; /* Distortion Threshold d7-d0 */ |
2045 | value[3] = 0; /* Distorsion Threshold d11-d8 */ | 1960 | value[3] = 0; /* Distortion Threshold d11-d8 */ |
2046 | value[4] = 43; /* Max Distorsion d7-d0 */ | 1961 | value[4] = 43; /* Max Distortion d7-d0 */ |
2047 | value[5] = 0; /* Max Distorsion d8 */ | 1962 | value[5] = 0; /* Max Distortion d8 */ |
2048 | } | 1963 | } |
2049 | 1964 | ||
2050 | if (!USBVISION_IS_OPERATIONAL(usbvision)) | 1965 | if (!USBVISION_IS_OPERATIONAL(usbvision)) |
@@ -2059,10 +1974,7 @@ static int usbvision_set_compress_params(struct usb_usbvision *usbvision) | |||
2059 | if (rc < 0) { | 1974 | if (rc < 0) { |
2060 | printk(KERN_ERR "%sERROR=%d. USBVISION stopped - " | 1975 | printk(KERN_ERR "%sERROR=%d. USBVISION stopped - " |
2061 | "reconnect or reload driver.\n", proc, rc); | 1976 | "reconnect or reload driver.\n", proc, rc); |
2062 | return rc; | ||
2063 | } | 1977 | } |
2064 | |||
2065 | |||
2066 | return rc; | 1978 | return rc; |
2067 | } | 1979 | } |
2068 | 1980 | ||
@@ -2087,7 +1999,7 @@ int usbvision_set_input(struct usb_usbvision *usbvision) | |||
2087 | /* Set input format expected from decoder*/ | 1999 | /* Set input format expected from decoder*/ |
2088 | if (usbvision_device_data[usbvision->dev_model].vin_reg1_override) { | 2000 | if (usbvision_device_data[usbvision->dev_model].vin_reg1_override) { |
2089 | value[0] = usbvision_device_data[usbvision->dev_model].vin_reg1; | 2001 | value[0] = usbvision_device_data[usbvision->dev_model].vin_reg1; |
2090 | } else if(usbvision_device_data[usbvision->dev_model].codec == CODEC_SAA7113) { | 2002 | } else if (usbvision_device_data[usbvision->dev_model].codec == CODEC_SAA7113) { |
2091 | /* SAA7113 uses 8 bit output */ | 2003 | /* SAA7113 uses 8 bit output */ |
2092 | value[0] = USBVISION_8_422_SYNC; | 2004 | value[0] = USBVISION_8_422_SYNC; |
2093 | } else { | 2005 | } else { |
@@ -2135,8 +2047,8 @@ int usbvision_set_input(struct usb_usbvision *usbvision) | |||
2135 | } | 2047 | } |
2136 | 2048 | ||
2137 | if (usbvision_device_data[usbvision->dev_model].x_offset >= 0) { | 2049 | if (usbvision_device_data[usbvision->dev_model].x_offset >= 0) { |
2138 | value[4]=usbvision_device_data[usbvision->dev_model].x_offset & 0xff; | 2050 | value[4] = usbvision_device_data[usbvision->dev_model].x_offset & 0xff; |
2139 | value[5]=(usbvision_device_data[usbvision->dev_model].x_offset & 0x0300) >> 8; | 2051 | value[5] = (usbvision_device_data[usbvision->dev_model].x_offset & 0x0300) >> 8; |
2140 | } | 2052 | } |
2141 | 2053 | ||
2142 | if (adjust_x_offset != -1) { | 2054 | if (adjust_x_offset != -1) { |
@@ -2145,8 +2057,8 @@ int usbvision_set_input(struct usb_usbvision *usbvision) | |||
2145 | } | 2057 | } |
2146 | 2058 | ||
2147 | if (usbvision_device_data[usbvision->dev_model].y_offset >= 0) { | 2059 | if (usbvision_device_data[usbvision->dev_model].y_offset >= 0) { |
2148 | value[6]=usbvision_device_data[usbvision->dev_model].y_offset & 0xff; | 2060 | value[6] = usbvision_device_data[usbvision->dev_model].y_offset & 0xff; |
2149 | value[7]=(usbvision_device_data[usbvision->dev_model].y_offset & 0x0300) >> 8; | 2061 | value[7] = (usbvision_device_data[usbvision->dev_model].y_offset & 0x0300) >> 8; |
2150 | } | 2062 | } |
2151 | 2063 | ||
2152 | if (adjust_y_offset != -1) { | 2064 | if (adjust_y_offset != -1) { |
@@ -2167,15 +2079,14 @@ int usbvision_set_input(struct usb_usbvision *usbvision) | |||
2167 | 2079 | ||
2168 | dvi_yuv_value = 0x00; /* U comes after V, Ya comes after U/V, Yb comes after Yb */ | 2080 | dvi_yuv_value = 0x00; /* U comes after V, Ya comes after U/V, Yb comes after Yb */ |
2169 | 2081 | ||
2170 | if(usbvision_device_data[usbvision->dev_model].dvi_yuv_override){ | 2082 | if (usbvision_device_data[usbvision->dev_model].dvi_yuv_override) { |
2171 | dvi_yuv_value = usbvision_device_data[usbvision->dev_model].dvi_yuv; | 2083 | dvi_yuv_value = usbvision_device_data[usbvision->dev_model].dvi_yuv; |
2172 | } | 2084 | } else if (usbvision_device_data[usbvision->dev_model].codec == CODEC_SAA7113) { |
2173 | else if(usbvision_device_data[usbvision->dev_model].codec == CODEC_SAA7113) { | 2085 | /* This changes as the fine sync control changes. Further investigation necessary */ |
2174 | /* This changes as the fine sync control changes. Further investigation necessary */ | ||
2175 | dvi_yuv_value = 0x06; | 2086 | dvi_yuv_value = 0x06; |
2176 | } | 2087 | } |
2177 | 2088 | ||
2178 | return (usbvision_write_reg(usbvision, USBVISION_DVI_YUV, dvi_yuv_value)); | 2089 | return usbvision_write_reg(usbvision, USBVISION_DVI_YUV, dvi_yuv_value); |
2179 | } | 2090 | } |
2180 | 2091 | ||
2181 | 2092 | ||
@@ -2204,8 +2115,7 @@ static int usbvision_set_dram_settings(struct usb_usbvision *usbvision) | |||
2204 | /* UR: 0x0E200-0x3FFFF = 204288 Words (1 Word = 2 Byte) */ | 2115 | /* UR: 0x0E200-0x3FFFF = 204288 Words (1 Word = 2 Byte) */ |
2205 | /* FDL: 0x00000-0x0E099 = 57498 Words */ | 2116 | /* FDL: 0x00000-0x0E099 = 57498 Words */ |
2206 | /* VDW: 0x0E3FF-0x3FFFF */ | 2117 | /* VDW: 0x0E3FF-0x3FFFF */ |
2207 | } | 2118 | } else { |
2208 | else { | ||
2209 | value[0] = 0x42; | 2119 | value[0] = 0x42; |
2210 | value[1] = 0x00; | 2120 | value[1] = 0x00; |
2211 | value[2] = 0xff; | 2121 | value[2] = 0xff; |
@@ -2218,14 +2128,14 @@ static int usbvision_set_dram_settings(struct usb_usbvision *usbvision) | |||
2218 | /* These are the values of the address of the video buffer, | 2128 | /* These are the values of the address of the video buffer, |
2219 | * they have to be loaded into the USBVISION_DRM_PRM1-8 | 2129 | * they have to be loaded into the USBVISION_DRM_PRM1-8 |
2220 | * | 2130 | * |
2221 | * Start address of video output buffer for read: drm_prm1-2 -> 0x00000 | 2131 | * Start address of video output buffer for read: drm_prm1-2 -> 0x00000 |
2222 | * End address of video output buffer for read: drm_prm1-3 -> 0x1ffff | 2132 | * End address of video output buffer for read: drm_prm1-3 -> 0x1ffff |
2223 | * Start address of video frame delay buffer: drm_prm1-4 -> 0x20000 | 2133 | * Start address of video frame delay buffer: drm_prm1-4 -> 0x20000 |
2224 | * Only used in compressed mode | 2134 | * Only used in compressed mode |
2225 | * End address of video frame delay buffer: drm_prm1-5-6 -> 0x3ffff | 2135 | * End address of video frame delay buffer: drm_prm1-5-6 -> 0x3ffff |
2226 | * Only used in compressed mode | 2136 | * Only used in compressed mode |
2227 | * Start address of video output buffer for write: drm_prm1-7 -> 0x00000 | 2137 | * Start address of video output buffer for write: drm_prm1-7 -> 0x00000 |
2228 | * End address of video output buffer for write: drm_prm1-8 -> 0x1ffff | 2138 | * End address of video output buffer for write: drm_prm1-8 -> 0x1ffff |
2229 | */ | 2139 | */ |
2230 | 2140 | ||
2231 | if (!USBVISION_IS_OPERATIONAL(usbvision)) | 2141 | if (!USBVISION_IS_OPERATIONAL(usbvision)) |
@@ -2243,8 +2153,9 @@ static int usbvision_set_dram_settings(struct usb_usbvision *usbvision) | |||
2243 | } | 2153 | } |
2244 | 2154 | ||
2245 | /* Restart the video buffer logic */ | 2155 | /* Restart the video buffer logic */ |
2246 | if ((rc = usbvision_write_reg(usbvision, USBVISION_DRM_CONT, USBVISION_RES_UR | | 2156 | rc = usbvision_write_reg(usbvision, USBVISION_DRM_CONT, USBVISION_RES_UR | |
2247 | USBVISION_RES_FDL | USBVISION_RES_VDW)) < 0) | 2157 | USBVISION_RES_FDL | USBVISION_RES_VDW); |
2158 | if (rc < 0) | ||
2248 | return rc; | 2159 | return rc; |
2249 | rc = usbvision_write_reg(usbvision, USBVISION_DRM_CONT, 0x00); | 2160 | rc = usbvision_write_reg(usbvision, USBVISION_DRM_CONT, 0x00); |
2250 | 2161 | ||
@@ -2267,16 +2178,15 @@ int usbvision_power_on(struct usb_usbvision *usbvision) | |||
2267 | 2178 | ||
2268 | usbvision_write_reg(usbvision, USBVISION_PWR_REG, USBVISION_SSPND_EN); | 2179 | usbvision_write_reg(usbvision, USBVISION_PWR_REG, USBVISION_SSPND_EN); |
2269 | usbvision_write_reg(usbvision, USBVISION_PWR_REG, | 2180 | usbvision_write_reg(usbvision, USBVISION_PWR_REG, |
2270 | USBVISION_SSPND_EN | USBVISION_RES2); | 2181 | USBVISION_SSPND_EN | USBVISION_RES2); |
2271 | 2182 | ||
2272 | usbvision_write_reg(usbvision, USBVISION_PWR_REG, | 2183 | usbvision_write_reg(usbvision, USBVISION_PWR_REG, |
2273 | USBVISION_SSPND_EN | USBVISION_PWR_VID); | 2184 | USBVISION_SSPND_EN | USBVISION_PWR_VID); |
2274 | err_code = usbvision_write_reg(usbvision, USBVISION_PWR_REG, | 2185 | err_code = usbvision_write_reg(usbvision, USBVISION_PWR_REG, |
2275 | USBVISION_SSPND_EN | USBVISION_PWR_VID | USBVISION_RES2); | 2186 | USBVISION_SSPND_EN | USBVISION_PWR_VID | USBVISION_RES2); |
2276 | if (err_code == 1) { | 2187 | if (err_code == 1) |
2277 | usbvision->power = 1; | 2188 | usbvision->power = 1; |
2278 | } | 2189 | PDEBUG(DBG_FUNC, "%s: err_code %d", (err_code < 0) ? "ERROR" : "power is on", err_code); |
2279 | PDEBUG(DBG_FUNC, "%s: err_code %d", (err_code<0)?"ERROR":"power is on", err_code); | ||
2280 | return err_code; | 2190 | return err_code; |
2281 | } | 2191 | } |
2282 | 2192 | ||
@@ -2294,7 +2204,7 @@ static void call_usbvision_power_off(struct work_struct *work) | |||
2294 | if (mutex_lock_interruptible(&usbvision->v4l2_lock)) | 2204 | if (mutex_lock_interruptible(&usbvision->v4l2_lock)) |
2295 | return; | 2205 | return; |
2296 | 2206 | ||
2297 | if(usbvision->user == 0) { | 2207 | if (usbvision->user == 0) { |
2298 | usbvision_i2c_unregister(usbvision); | 2208 | usbvision_i2c_unregister(usbvision); |
2299 | 2209 | ||
2300 | usbvision_power_off(usbvision); | 2210 | usbvision_power_off(usbvision); |
@@ -2305,7 +2215,7 @@ static void call_usbvision_power_off(struct work_struct *work) | |||
2305 | 2215 | ||
2306 | static void usbvision_power_off_timer(unsigned long data) | 2216 | static void usbvision_power_off_timer(unsigned long data) |
2307 | { | 2217 | { |
2308 | struct usb_usbvision *usbvision = (void *) data; | 2218 | struct usb_usbvision *usbvision = (void *)data; |
2309 | 2219 | ||
2310 | PDEBUG(DBG_FUNC, ""); | 2220 | PDEBUG(DBG_FUNC, ""); |
2311 | del_timer(&usbvision->power_off_timer); | 2221 | del_timer(&usbvision->power_off_timer); |
@@ -2316,7 +2226,7 @@ static void usbvision_power_off_timer(unsigned long data) | |||
2316 | void usbvision_init_power_off_timer(struct usb_usbvision *usbvision) | 2226 | void usbvision_init_power_off_timer(struct usb_usbvision *usbvision) |
2317 | { | 2227 | { |
2318 | init_timer(&usbvision->power_off_timer); | 2228 | init_timer(&usbvision->power_off_timer); |
2319 | usbvision->power_off_timer.data = (long) usbvision; | 2229 | usbvision->power_off_timer.data = (long)usbvision; |
2320 | usbvision->power_off_timer.function = usbvision_power_off_timer; | 2230 | usbvision->power_off_timer.function = usbvision_power_off_timer; |
2321 | } | 2231 | } |
2322 | 2232 | ||
@@ -2327,9 +2237,8 @@ void usbvision_set_power_off_timer(struct usb_usbvision *usbvision) | |||
2327 | 2237 | ||
2328 | void usbvision_reset_power_off_timer(struct usb_usbvision *usbvision) | 2238 | void usbvision_reset_power_off_timer(struct usb_usbvision *usbvision) |
2329 | { | 2239 | { |
2330 | if (timer_pending(&usbvision->power_off_timer)) { | 2240 | if (timer_pending(&usbvision->power_off_timer)) |
2331 | del_timer(&usbvision->power_off_timer); | 2241 | del_timer(&usbvision->power_off_timer); |
2332 | } | ||
2333 | } | 2242 | } |
2334 | 2243 | ||
2335 | /* | 2244 | /* |
@@ -2339,14 +2248,10 @@ void usbvision_reset_power_off_timer(struct usb_usbvision *usbvision) | |||
2339 | */ | 2248 | */ |
2340 | int usbvision_begin_streaming(struct usb_usbvision *usbvision) | 2249 | int usbvision_begin_streaming(struct usb_usbvision *usbvision) |
2341 | { | 2250 | { |
2342 | int err_code = 0; | 2251 | if (usbvision->isoc_mode == ISOC_MODE_COMPRESS) |
2343 | |||
2344 | if (usbvision->isoc_mode == ISOC_MODE_COMPRESS) { | ||
2345 | usbvision_init_compression(usbvision); | 2252 | usbvision_init_compression(usbvision); |
2346 | } | 2253 | return usbvision_write_reg(usbvision, USBVISION_VIN_REG2, |
2347 | err_code = usbvision_write_reg(usbvision, USBVISION_VIN_REG2, USBVISION_NOHVALID | | 2254 | USBVISION_NOHVALID | usbvision->vin_reg2_preset); |
2348 | usbvision->vin_reg2_preset); | ||
2349 | return err_code; | ||
2350 | } | 2255 | } |
2351 | 2256 | ||
2352 | /* | 2257 | /* |
@@ -2358,25 +2263,24 @@ int usbvision_restart_isoc(struct usb_usbvision *usbvision) | |||
2358 | { | 2263 | { |
2359 | int ret; | 2264 | int ret; |
2360 | 2265 | ||
2361 | if ( | 2266 | ret = usbvision_write_reg(usbvision, USBVISION_PWR_REG, |
2362 | (ret = | 2267 | USBVISION_SSPND_EN | USBVISION_PWR_VID); |
2363 | usbvision_write_reg(usbvision, USBVISION_PWR_REG, | 2268 | if (ret < 0) |
2364 | USBVISION_SSPND_EN | USBVISION_PWR_VID)) < 0) | ||
2365 | return ret; | 2269 | return ret; |
2366 | if ( | 2270 | ret = usbvision_write_reg(usbvision, USBVISION_PWR_REG, |
2367 | (ret = | ||
2368 | usbvision_write_reg(usbvision, USBVISION_PWR_REG, | ||
2369 | USBVISION_SSPND_EN | USBVISION_PWR_VID | | 2271 | USBVISION_SSPND_EN | USBVISION_PWR_VID | |
2370 | USBVISION_RES2)) < 0) | 2272 | USBVISION_RES2); |
2273 | if (ret < 0) | ||
2371 | return ret; | 2274 | return ret; |
2372 | if ( | 2275 | ret = usbvision_write_reg(usbvision, USBVISION_VIN_REG2, |
2373 | (ret = | ||
2374 | usbvision_write_reg(usbvision, USBVISION_VIN_REG2, | ||
2375 | USBVISION_KEEP_BLANK | USBVISION_NOHVALID | | 2276 | USBVISION_KEEP_BLANK | USBVISION_NOHVALID | |
2376 | usbvision->vin_reg2_preset)) < 0) return ret; | 2277 | usbvision->vin_reg2_preset); |
2278 | if (ret < 0) | ||
2279 | return ret; | ||
2377 | 2280 | ||
2378 | /* TODO: schedule timeout */ | 2281 | /* TODO: schedule timeout */ |
2379 | while ((usbvision_read_reg(usbvision, USBVISION_STATUS_REG) & 0x01) != 1); | 2282 | while ((usbvision_read_reg(usbvision, USBVISION_STATUS_REG) & 0x01) != 1) |
2283 | ; | ||
2380 | 2284 | ||
2381 | return 0; | 2285 | return 0; |
2382 | } | 2286 | } |
@@ -2384,7 +2288,7 @@ int usbvision_restart_isoc(struct usb_usbvision *usbvision) | |||
2384 | int usbvision_audio_off(struct usb_usbvision *usbvision) | 2288 | int usbvision_audio_off(struct usb_usbvision *usbvision) |
2385 | { | 2289 | { |
2386 | if (usbvision_write_reg(usbvision, USBVISION_IOPIN_REG, USBVISION_AUDIO_MUTE) < 0) { | 2290 | if (usbvision_write_reg(usbvision, USBVISION_IOPIN_REG, USBVISION_AUDIO_MUTE) < 0) { |
2387 | printk(KERN_ERR "usbvision_audio_off: can't wirte reg\n"); | 2291 | printk(KERN_ERR "usbvision_audio_off: can't write reg\n"); |
2388 | return -1; | 2292 | return -1; |
2389 | } | 2293 | } |
2390 | usbvision->audio_mute = 0; | 2294 | usbvision->audio_mute = 0; |
@@ -2404,7 +2308,7 @@ int usbvision_set_audio(struct usb_usbvision *usbvision, int audio_channel) | |||
2404 | return 0; | 2308 | return 0; |
2405 | } | 2309 | } |
2406 | 2310 | ||
2407 | int usbvision_setup(struct usb_usbvision *usbvision,int format) | 2311 | int usbvision_setup(struct usb_usbvision *usbvision, int format) |
2408 | { | 2312 | { |
2409 | usbvision_set_video_format(usbvision, format); | 2313 | usbvision_set_video_format(usbvision, format); |
2410 | usbvision_set_dram_settings(usbvision); | 2314 | usbvision_set_dram_settings(usbvision); |
@@ -2422,14 +2326,15 @@ int usbvision_set_alternate(struct usb_usbvision *dev) | |||
2422 | int err_code, prev_alt = dev->iface_alt; | 2326 | int err_code, prev_alt = dev->iface_alt; |
2423 | int i; | 2327 | int i; |
2424 | 2328 | ||
2425 | dev->iface_alt=0; | 2329 | dev->iface_alt = 0; |
2426 | for(i=0;i< dev->num_alt; i++) | 2330 | for (i = 0; i < dev->num_alt; i++) |
2427 | if(dev->alt_max_pkt_size[i]>dev->alt_max_pkt_size[dev->iface_alt]) | 2331 | if (dev->alt_max_pkt_size[i] > dev->alt_max_pkt_size[dev->iface_alt]) |
2428 | dev->iface_alt=i; | 2332 | dev->iface_alt = i; |
2429 | 2333 | ||
2430 | if (dev->iface_alt != prev_alt) { | 2334 | if (dev->iface_alt != prev_alt) { |
2431 | dev->isoc_packet_size = dev->alt_max_pkt_size[dev->iface_alt]; | 2335 | dev->isoc_packet_size = dev->alt_max_pkt_size[dev->iface_alt]; |
2432 | PDEBUG(DBG_FUNC,"setting alternate %d with max_packet_size=%u", dev->iface_alt,dev->isoc_packet_size); | 2336 | PDEBUG(DBG_FUNC, "setting alternate %d with max_packet_size=%u", |
2337 | dev->iface_alt, dev->isoc_packet_size); | ||
2433 | err_code = usb_set_interface(dev->dev, dev->iface, dev->iface_alt); | 2338 | err_code = usb_set_interface(dev->dev, dev->iface, dev->iface_alt); |
2434 | if (err_code < 0) { | 2339 | if (err_code < 0) { |
2435 | dev_err(&dev->dev->dev, | 2340 | dev_err(&dev->dev->dev, |
@@ -2549,7 +2454,7 @@ void usbvision_stop_isoc(struct usb_usbvision *usbvision) | |||
2549 | /* Unschedule all of the iso td's */ | 2454 | /* Unschedule all of the iso td's */ |
2550 | for (buf_idx = 0; buf_idx < USBVISION_NUMSBUF; buf_idx++) { | 2455 | for (buf_idx = 0; buf_idx < USBVISION_NUMSBUF; buf_idx++) { |
2551 | usb_kill_urb(usbvision->sbuf[buf_idx].urb); | 2456 | usb_kill_urb(usbvision->sbuf[buf_idx].urb); |
2552 | if (usbvision->sbuf[buf_idx].data){ | 2457 | if (usbvision->sbuf[buf_idx].data) { |
2553 | usb_free_coherent(usbvision->dev, | 2458 | usb_free_coherent(usbvision->dev, |
2554 | sb_size, | 2459 | sb_size, |
2555 | usbvision->sbuf[buf_idx].data, | 2460 | usbvision->sbuf[buf_idx].data, |
@@ -2563,9 +2468,8 @@ void usbvision_stop_isoc(struct usb_usbvision *usbvision) | |||
2563 | usbvision->streaming = stream_off; | 2468 | usbvision->streaming = stream_off; |
2564 | 2469 | ||
2565 | if (!usbvision->remove_pending) { | 2470 | if (!usbvision->remove_pending) { |
2566 | |||
2567 | /* Set packet size to 0 */ | 2471 | /* Set packet size to 0 */ |
2568 | usbvision->iface_alt=0; | 2472 | usbvision->iface_alt = 0; |
2569 | err_code = usb_set_interface(usbvision->dev, usbvision->iface, | 2473 | err_code = usb_set_interface(usbvision->dev, usbvision->iface, |
2570 | usbvision->iface_alt); | 2474 | usbvision->iface_alt); |
2571 | if (err_code < 0) { | 2475 | if (err_code < 0) { |
@@ -2590,8 +2494,8 @@ int usbvision_muxsel(struct usb_usbvision *usbvision, int channel) | |||
2590 | { | 2494 | { |
2591 | /* inputs #0 and #3 are constant for every SAA711x. */ | 2495 | /* inputs #0 and #3 are constant for every SAA711x. */ |
2592 | /* inputs #1 and #2 are variable for SAA7111 and SAA7113 */ | 2496 | /* inputs #1 and #2 are variable for SAA7111 and SAA7113 */ |
2593 | int mode[4]= {SAA7115_COMPOSITE0, 0, 0, SAA7115_COMPOSITE3}; | 2497 | int mode[4] = { SAA7115_COMPOSITE0, 0, 0, SAA7115_COMPOSITE3 }; |
2594 | int audio[]= {1, 0, 0, 0}; | 2498 | int audio[] = { 1, 0, 0, 0 }; |
2595 | /* channel 0 is TV with audiochannel 1 (tuner mono) */ | 2499 | /* channel 0 is TV with audiochannel 1 (tuner mono) */ |
2596 | /* channel 1 is Composite with audio channel 0 (line in) */ | 2500 | /* channel 1 is Composite with audio channel 0 (line in) */ |
2597 | /* channel 2 is S-Video with audio channel 0 (line in) */ | 2501 | /* channel 2 is S-Video with audio channel 0 (line in) */ |
@@ -2605,24 +2509,23 @@ int usbvision_muxsel(struct usb_usbvision *usbvision, int channel) | |||
2605 | /* Four video input devices -> channel: 0 = Chan White, 1 = Chan Green, 2 = Chan Yellow, 3 = Chan Red */ | 2509 | /* Four video input devices -> channel: 0 = Chan White, 1 = Chan Green, 2 = Chan Yellow, 3 = Chan Red */ |
2606 | 2510 | ||
2607 | switch (usbvision_device_data[usbvision->dev_model].codec) { | 2511 | switch (usbvision_device_data[usbvision->dev_model].codec) { |
2608 | case CODEC_SAA7113: | 2512 | case CODEC_SAA7113: |
2609 | mode[1] = SAA7115_COMPOSITE2; | 2513 | mode[1] = SAA7115_COMPOSITE2; |
2610 | if (switch_svideo_input) { | 2514 | if (switch_svideo_input) { |
2611 | /* To handle problems with S-Video Input for | 2515 | /* To handle problems with S-Video Input for |
2612 | * some devices. Use switch_svideo_input | 2516 | * some devices. Use switch_svideo_input |
2613 | * parameter when loading the module.*/ | 2517 | * parameter when loading the module.*/ |
2614 | mode[2] = SAA7115_COMPOSITE1; | 2518 | mode[2] = SAA7115_COMPOSITE1; |
2615 | } | 2519 | } else { |
2616 | else { | ||
2617 | mode[2] = SAA7115_SVIDEO1; | ||
2618 | } | ||
2619 | break; | ||
2620 | case CODEC_SAA7111: | ||
2621 | default: | ||
2622 | /* modes for saa7111 */ | ||
2623 | mode[1] = SAA7115_COMPOSITE1; | ||
2624 | mode[2] = SAA7115_SVIDEO1; | 2520 | mode[2] = SAA7115_SVIDEO1; |
2625 | break; | 2521 | } |
2522 | break; | ||
2523 | case CODEC_SAA7111: | ||
2524 | default: | ||
2525 | /* modes for saa7111 */ | ||
2526 | mode[1] = SAA7115_COMPOSITE1; | ||
2527 | mode[2] = SAA7115_SVIDEO1; | ||
2528 | break; | ||
2626 | } | 2529 | } |
2627 | call_all(usbvision, video, s_routing, mode[channel], 0, 0); | 2530 | call_all(usbvision, video, s_routing, mode[channel], 0, 0); |
2628 | usbvision_set_audio(usbvision, audio[channel]); | 2531 | usbvision_set_audio(usbvision, audio[channel]); |
diff --git a/drivers/media/video/usbvision/usbvision-i2c.c b/drivers/media/video/usbvision/usbvision-i2c.c index cb19c8448c56..05b1344181cd 100644 --- a/drivers/media/video/usbvision/usbvision-i2c.c +++ b/drivers/media/video/usbvision/usbvision-i2c.c | |||
@@ -28,18 +28,18 @@ | |||
28 | #include <linux/module.h> | 28 | #include <linux/module.h> |
29 | #include <linux/delay.h> | 29 | #include <linux/delay.h> |
30 | #include <linux/init.h> | 30 | #include <linux/init.h> |
31 | #include <asm/uaccess.h> | 31 | #include <linux/uaccess.h> |
32 | #include <linux/ioport.h> | 32 | #include <linux/ioport.h> |
33 | #include <linux/errno.h> | 33 | #include <linux/errno.h> |
34 | #include <linux/usb.h> | 34 | #include <linux/usb.h> |
35 | #include <linux/i2c.h> | 35 | #include <linux/i2c.h> |
36 | #include "usbvision.h" | 36 | #include "usbvision.h" |
37 | 37 | ||
38 | #define DBG_I2C 1<<0 | 38 | #define DBG_I2C (1 << 0) |
39 | 39 | ||
40 | static int i2c_debug; | 40 | static int i2c_debug; |
41 | 41 | ||
42 | module_param (i2c_debug, int, 0644); /* debug_i2c_usb mode of the device driver */ | 42 | module_param(i2c_debug, int, 0644); /* debug_i2c_usb mode of the device driver */ |
43 | MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]"); | 43 | MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]"); |
44 | 44 | ||
45 | #define PDEBUG(level, fmt, args...) { \ | 45 | #define PDEBUG(level, fmt, args...) { \ |
@@ -72,8 +72,8 @@ static inline int try_write_address(struct i2c_adapter *i2c_adap, | |||
72 | udelay(10); | 72 | udelay(10); |
73 | } | 73 | } |
74 | if (i) { | 74 | if (i) { |
75 | PDEBUG(DBG_I2C,"Needed %d retries for address %#2x", i, addr); | 75 | PDEBUG(DBG_I2C, "Needed %d retries for address %#2x", i, addr); |
76 | PDEBUG(DBG_I2C,"Maybe there's no device at this address"); | 76 | PDEBUG(DBG_I2C, "Maybe there's no device at this address"); |
77 | } | 77 | } |
78 | return ret; | 78 | return ret; |
79 | } | 79 | } |
@@ -96,8 +96,8 @@ static inline int try_read_address(struct i2c_adapter *i2c_adap, | |||
96 | udelay(10); | 96 | udelay(10); |
97 | } | 97 | } |
98 | if (i) { | 98 | if (i) { |
99 | PDEBUG(DBG_I2C,"Needed %d retries for address %#2x", i, addr); | 99 | PDEBUG(DBG_I2C, "Needed %d retries for address %#2x", i, addr); |
100 | PDEBUG(DBG_I2C,"Maybe there's no device at this address"); | 100 | PDEBUG(DBG_I2C, "Maybe there's no device at this address"); |
101 | } | 101 | } |
102 | return ret; | 102 | return ret; |
103 | } | 103 | } |
@@ -143,9 +143,8 @@ static inline int usb_find_address(struct i2c_adapter *i2c_adap, | |||
143 | else | 143 | else |
144 | ret = try_write_address(i2c_adap, addr, retries); | 144 | ret = try_write_address(i2c_adap, addr, retries); |
145 | 145 | ||
146 | if (ret != 1) { | 146 | if (ret != 1) |
147 | return -EREMOTEIO; | 147 | return -EREMOTEIO; |
148 | } | ||
149 | } | 148 | } |
150 | return 0; | 149 | return 0; |
151 | } | 150 | } |
@@ -164,22 +163,20 @@ usbvision_i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs[], int num) | |||
164 | pmsg = &msgs[i]; | 163 | pmsg = &msgs[i]; |
165 | ret = usb_find_address(i2c_adap, pmsg, i2c_adap->retries, &addr); | 164 | ret = usb_find_address(i2c_adap, pmsg, i2c_adap->retries, &addr); |
166 | if (ret != 0) { | 165 | if (ret != 0) { |
167 | PDEBUG(DBG_I2C,"got NAK from device, message #%d", i); | 166 | PDEBUG(DBG_I2C, "got NAK from device, message #%d", i); |
168 | return (ret < 0) ? ret : -EREMOTEIO; | 167 | return (ret < 0) ? ret : -EREMOTEIO; |
169 | } | 168 | } |
170 | 169 | ||
171 | if (pmsg->flags & I2C_M_RD) { | 170 | if (pmsg->flags & I2C_M_RD) { |
172 | /* read bytes into buffer */ | 171 | /* read bytes into buffer */ |
173 | ret = (usbvision_i2c_read(usbvision, addr, pmsg->buf, pmsg->len)); | 172 | ret = (usbvision_i2c_read(usbvision, addr, pmsg->buf, pmsg->len)); |
174 | if (ret < pmsg->len) { | 173 | if (ret < pmsg->len) |
175 | return (ret < 0) ? ret : -EREMOTEIO; | 174 | return (ret < 0) ? ret : -EREMOTEIO; |
176 | } | ||
177 | } else { | 175 | } else { |
178 | /* write bytes from buffer */ | 176 | /* write bytes from buffer */ |
179 | ret = (usbvision_i2c_write(usbvision, addr, pmsg->buf, pmsg->len)); | 177 | ret = (usbvision_i2c_write(usbvision, addr, pmsg->buf, pmsg->len)); |
180 | if (ret < pmsg->len) { | 178 | if (ret < pmsg->len) |
181 | return (ret < 0) ? ret : -EREMOTEIO; | 179 | return (ret < 0) ? ret : -EREMOTEIO; |
182 | } | ||
183 | } | 180 | } |
184 | } | 181 | } |
185 | return num; | 182 | return num; |
@@ -219,7 +216,7 @@ int usbvision_i2c_register(struct usb_usbvision *usbvision) | |||
219 | 216 | ||
220 | sprintf(usbvision->i2c_adap.name, "%s-%d-%s", i2c_adap_template.name, | 217 | sprintf(usbvision->i2c_adap.name, "%s-%d-%s", i2c_adap_template.name, |
221 | usbvision->dev->bus->busnum, usbvision->dev->devpath); | 218 | usbvision->dev->bus->busnum, usbvision->dev->devpath); |
222 | PDEBUG(DBG_I2C,"Adaptername: %s", usbvision->i2c_adap.name); | 219 | PDEBUG(DBG_I2C, "Adaptername: %s", usbvision->i2c_adap.name); |
223 | usbvision->i2c_adap.dev.parent = &usbvision->dev->dev; | 220 | usbvision->i2c_adap.dev.parent = &usbvision->dev->dev; |
224 | 221 | ||
225 | i2c_set_adapdata(&usbvision->i2c_adap, &usbvision->v4l2_dev); | 222 | i2c_set_adapdata(&usbvision->i2c_adap, &usbvision->v4l2_dev); |
@@ -293,7 +290,7 @@ int usbvision_i2c_unregister(struct usb_usbvision *usbvision) | |||
293 | i2c_del_adapter(&(usbvision->i2c_adap)); | 290 | i2c_del_adapter(&(usbvision->i2c_adap)); |
294 | usbvision->registered_i2c = 0; | 291 | usbvision->registered_i2c = 0; |
295 | 292 | ||
296 | PDEBUG(DBG_I2C,"i2c bus for %s unregistered", usbvision->i2c_adap.name); | 293 | PDEBUG(DBG_I2C, "i2c bus for %s unregistered", usbvision->i2c_adap.name); |
297 | 294 | ||
298 | return 0; | 295 | return 0; |
299 | } | 296 | } |
@@ -355,9 +352,9 @@ usbvision_i2c_read_max4(struct usb_usbvision *usbvision, unsigned char addr, | |||
355 | 352 | ||
356 | if (i2c_debug & DBG_I2C) { | 353 | if (i2c_debug & DBG_I2C) { |
357 | int idx; | 354 | int idx; |
358 | for (idx = 0; idx < len; idx++) { | 355 | |
359 | PDEBUG(DBG_I2C,"read %x from address %x", (unsigned char)buf[idx], addr); | 356 | for (idx = 0; idx < len; idx++) |
360 | } | 357 | PDEBUG(DBG_I2C, "read %x from address %x", (unsigned char)buf[idx], addr); |
361 | } | 358 | } |
362 | return len; | 359 | return len; |
363 | } | 360 | } |
@@ -416,9 +413,9 @@ static int usbvision_i2c_write_max4(struct usb_usbvision *usbvision, | |||
416 | 413 | ||
417 | if (i2c_debug & DBG_I2C) { | 414 | if (i2c_debug & DBG_I2C) { |
418 | int idx; | 415 | int idx; |
419 | for (idx = 0; idx < len; idx++) { | 416 | |
420 | PDEBUG(DBG_I2C,"wrote %x at address %x", (unsigned char)buf[idx], addr); | 417 | for (idx = 0; idx < len; idx++) |
421 | } | 418 | PDEBUG(DBG_I2C, "wrote %x at address %x", (unsigned char)buf[idx], addr); |
422 | } | 419 | } |
423 | return len; | 420 | return len; |
424 | } | 421 | } |
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c index 375355a8fe1c..6083137f0bf8 100644 --- a/drivers/media/video/usbvision/usbvision-video.c +++ b/drivers/media/video/usbvision/usbvision-video.c | |||
@@ -56,7 +56,7 @@ | |||
56 | #include <linux/module.h> | 56 | #include <linux/module.h> |
57 | #include <linux/init.h> | 57 | #include <linux/init.h> |
58 | #include <linux/spinlock.h> | 58 | #include <linux/spinlock.h> |
59 | #include <asm/io.h> | 59 | #include <linux/io.h> |
60 | #include <linux/videodev2.h> | 60 | #include <linux/videodev2.h> |
61 | #include <linux/i2c.h> | 61 | #include <linux/i2c.h> |
62 | 62 | ||
@@ -70,8 +70,8 @@ | |||
70 | #include "usbvision.h" | 70 | #include "usbvision.h" |
71 | #include "usbvision-cards.h" | 71 | #include "usbvision-cards.h" |
72 | 72 | ||
73 | #define DRIVER_AUTHOR "Joerg Heckenbach <joerg@heckenbach-aw.de>,\ | 73 | #define DRIVER_AUTHOR "Joerg Heckenbach <joerg@heckenbach-aw.de>, \ |
74 | Dwaine Garden <DwaineGarden@rogers.com>" | 74 | Dwaine Garden <DwaineGarden@rogers.com>" |
75 | #define DRIVER_NAME "usbvision" | 75 | #define DRIVER_NAME "usbvision" |
76 | #define DRIVER_ALIAS "USBVision" | 76 | #define DRIVER_ALIAS "USBVision" |
77 | #define DRIVER_DESC "USBVision USB Video Device Driver for Linux" | 77 | #define DRIVER_DESC "USBVision USB Video Device Driver for Linux" |
@@ -82,9 +82,9 @@ | |||
82 | #define USBVISION_DRIVER_VERSION KERNEL_VERSION(USBVISION_DRIVER_VERSION_MAJOR,\ | 82 | #define USBVISION_DRIVER_VERSION KERNEL_VERSION(USBVISION_DRIVER_VERSION_MAJOR,\ |
83 | USBVISION_DRIVER_VERSION_MINOR,\ | 83 | USBVISION_DRIVER_VERSION_MINOR,\ |
84 | USBVISION_DRIVER_VERSION_PATCHLEVEL) | 84 | USBVISION_DRIVER_VERSION_PATCHLEVEL) |
85 | #define USBVISION_VERSION_STRING __stringify(USBVISION_DRIVER_VERSION_MAJOR)\ | 85 | #define USBVISION_VERSION_STRING __stringify(USBVISION_DRIVER_VERSION_MAJOR) \ |
86 | "." __stringify(USBVISION_DRIVER_VERSION_MINOR)\ | 86 | "." __stringify(USBVISION_DRIVER_VERSION_MINOR) \ |
87 | "." __stringify(USBVISION_DRIVER_VERSION_PATCHLEVEL) | 87 | "." __stringify(USBVISION_DRIVER_VERSION_PATCHLEVEL) |
88 | 88 | ||
89 | #define ENABLE_HEXDUMP 0 /* Enable if you need it */ | 89 | #define ENABLE_HEXDUMP 0 /* Enable if you need it */ |
90 | 90 | ||
@@ -96,16 +96,16 @@ USBVISION_DRIVER_VERSION_PATCHLEVEL) | |||
96 | __func__, __LINE__ , ## args); \ | 96 | __func__, __LINE__ , ## args); \ |
97 | } | 97 | } |
98 | #else | 98 | #else |
99 | #define PDEBUG(level, fmt, args...) do {} while(0) | 99 | #define PDEBUG(level, fmt, args...) do {} while (0) |
100 | #endif | 100 | #endif |
101 | 101 | ||
102 | #define DBG_IO 1<<1 | 102 | #define DBG_IO (1 << 1) |
103 | #define DBG_PROBE 1<<2 | 103 | #define DBG_PROBE (1 << 2) |
104 | #define DBG_MMAP 1<<3 | 104 | #define DBG_MMAP (1 << 3) |
105 | 105 | ||
106 | /* String operations */ | 106 | /* String operations */ |
107 | #define rmspace(str) while(*str==' ') str++; | 107 | #define rmspace(str) while (*str == ' ') str++; |
108 | #define goto2next(str) while(*str!=' ') str++; while(*str==' ') str++; | 108 | #define goto2next(str) while (*str != ' ') str++; while (*str == ' ') str++; |
109 | 109 | ||
110 | 110 | ||
111 | /* sequential number of usbvision device */ | 111 | /* sequential number of usbvision device */ |
@@ -205,7 +205,7 @@ static ssize_t show_hue(struct device *cd, | |||
205 | struct v4l2_control ctrl; | 205 | struct v4l2_control ctrl; |
206 | ctrl.id = V4L2_CID_HUE; | 206 | ctrl.id = V4L2_CID_HUE; |
207 | ctrl.value = 0; | 207 | ctrl.value = 0; |
208 | if(usbvision->user) | 208 | if (usbvision->user) |
209 | call_all(usbvision, core, g_ctrl, &ctrl); | 209 | call_all(usbvision, core, g_ctrl, &ctrl); |
210 | return sprintf(buf, "%d\n", ctrl.value); | 210 | return sprintf(buf, "%d\n", ctrl.value); |
211 | } | 211 | } |
@@ -220,7 +220,7 @@ static ssize_t show_contrast(struct device *cd, | |||
220 | struct v4l2_control ctrl; | 220 | struct v4l2_control ctrl; |
221 | ctrl.id = V4L2_CID_CONTRAST; | 221 | ctrl.id = V4L2_CID_CONTRAST; |
222 | ctrl.value = 0; | 222 | ctrl.value = 0; |
223 | if(usbvision->user) | 223 | if (usbvision->user) |
224 | call_all(usbvision, core, g_ctrl, &ctrl); | 224 | call_all(usbvision, core, g_ctrl, &ctrl); |
225 | return sprintf(buf, "%d\n", ctrl.value); | 225 | return sprintf(buf, "%d\n", ctrl.value); |
226 | } | 226 | } |
@@ -235,7 +235,7 @@ static ssize_t show_brightness(struct device *cd, | |||
235 | struct v4l2_control ctrl; | 235 | struct v4l2_control ctrl; |
236 | ctrl.id = V4L2_CID_BRIGHTNESS; | 236 | ctrl.id = V4L2_CID_BRIGHTNESS; |
237 | ctrl.value = 0; | 237 | ctrl.value = 0; |
238 | if(usbvision->user) | 238 | if (usbvision->user) |
239 | call_all(usbvision, core, g_ctrl, &ctrl); | 239 | call_all(usbvision, core, g_ctrl, &ctrl); |
240 | return sprintf(buf, "%d\n", ctrl.value); | 240 | return sprintf(buf, "%d\n", ctrl.value); |
241 | } | 241 | } |
@@ -250,7 +250,7 @@ static ssize_t show_saturation(struct device *cd, | |||
250 | struct v4l2_control ctrl; | 250 | struct v4l2_control ctrl; |
251 | ctrl.id = V4L2_CID_SATURATION; | 251 | ctrl.id = V4L2_CID_SATURATION; |
252 | ctrl.value = 0; | 252 | ctrl.value = 0; |
253 | if(usbvision->user) | 253 | if (usbvision->user) |
254 | call_all(usbvision, core, g_ctrl, &ctrl); | 254 | call_all(usbvision, core, g_ctrl, &ctrl); |
255 | return sprintf(buf, "%d\n", ctrl.value); | 255 | return sprintf(buf, "%d\n", ctrl.value); |
256 | } | 256 | } |
@@ -263,7 +263,7 @@ static ssize_t show_streaming(struct device *cd, | |||
263 | container_of(cd, struct video_device, dev); | 263 | container_of(cd, struct video_device, dev); |
264 | struct usb_usbvision *usbvision = video_get_drvdata(vdev); | 264 | struct usb_usbvision *usbvision = video_get_drvdata(vdev); |
265 | return sprintf(buf, "%s\n", | 265 | return sprintf(buf, "%s\n", |
266 | YES_NO(usbvision->streaming==stream_on?1:0)); | 266 | YES_NO(usbvision->streaming == stream_on ? 1 : 0)); |
267 | } | 267 | } |
268 | static DEVICE_ATTR(streaming, S_IRUGO, show_streaming, NULL); | 268 | static DEVICE_ATTR(streaming, S_IRUGO, show_streaming, NULL); |
269 | 269 | ||
@@ -274,7 +274,7 @@ static ssize_t show_compression(struct device *cd, | |||
274 | container_of(cd, struct video_device, dev); | 274 | container_of(cd, struct video_device, dev); |
275 | struct usb_usbvision *usbvision = video_get_drvdata(vdev); | 275 | struct usb_usbvision *usbvision = video_get_drvdata(vdev); |
276 | return sprintf(buf, "%s\n", | 276 | return sprintf(buf, "%s\n", |
277 | YES_NO(usbvision->isoc_mode==ISOC_MODE_COMPRESS)); | 277 | YES_NO(usbvision->isoc_mode == ISOC_MODE_COMPRESS)); |
278 | } | 278 | } |
279 | static DEVICE_ATTR(compression, S_IRUGO, show_compression, NULL); | 279 | static DEVICE_ATTR(compression, S_IRUGO, show_compression, NULL); |
280 | 280 | ||
@@ -291,35 +291,36 @@ static DEVICE_ATTR(bridge, S_IRUGO, show_device_bridge, NULL); | |||
291 | static void usbvision_create_sysfs(struct video_device *vdev) | 291 | static void usbvision_create_sysfs(struct video_device *vdev) |
292 | { | 292 | { |
293 | int res; | 293 | int res; |
294 | |||
294 | if (!vdev) | 295 | if (!vdev) |
295 | return; | 296 | return; |
296 | do { | 297 | do { |
297 | res = device_create_file(&vdev->dev, &dev_attr_version); | 298 | res = device_create_file(&vdev->dev, &dev_attr_version); |
298 | if (res<0) | 299 | if (res < 0) |
299 | break; | 300 | break; |
300 | res = device_create_file(&vdev->dev, &dev_attr_model); | 301 | res = device_create_file(&vdev->dev, &dev_attr_model); |
301 | if (res<0) | 302 | if (res < 0) |
302 | break; | 303 | break; |
303 | res = device_create_file(&vdev->dev, &dev_attr_hue); | 304 | res = device_create_file(&vdev->dev, &dev_attr_hue); |
304 | if (res<0) | 305 | if (res < 0) |
305 | break; | 306 | break; |
306 | res = device_create_file(&vdev->dev, &dev_attr_contrast); | 307 | res = device_create_file(&vdev->dev, &dev_attr_contrast); |
307 | if (res<0) | 308 | if (res < 0) |
308 | break; | 309 | break; |
309 | res = device_create_file(&vdev->dev, &dev_attr_brightness); | 310 | res = device_create_file(&vdev->dev, &dev_attr_brightness); |
310 | if (res<0) | 311 | if (res < 0) |
311 | break; | 312 | break; |
312 | res = device_create_file(&vdev->dev, &dev_attr_saturation); | 313 | res = device_create_file(&vdev->dev, &dev_attr_saturation); |
313 | if (res<0) | 314 | if (res < 0) |
314 | break; | 315 | break; |
315 | res = device_create_file(&vdev->dev, &dev_attr_streaming); | 316 | res = device_create_file(&vdev->dev, &dev_attr_streaming); |
316 | if (res<0) | 317 | if (res < 0) |
317 | break; | 318 | break; |
318 | res = device_create_file(&vdev->dev, &dev_attr_compression); | 319 | res = device_create_file(&vdev->dev, &dev_attr_compression); |
319 | if (res<0) | 320 | if (res < 0) |
320 | break; | 321 | break; |
321 | res = device_create_file(&vdev->dev, &dev_attr_bridge); | 322 | res = device_create_file(&vdev->dev, &dev_attr_bridge); |
322 | if (res>=0) | 323 | if (res >= 0) |
323 | return; | 324 | return; |
324 | } while (0); | 325 | } while (0); |
325 | 326 | ||
@@ -363,7 +364,7 @@ static int usbvision_v4l2_open(struct file *file) | |||
363 | else { | 364 | else { |
364 | /* Allocate memory for the scratch ring buffer */ | 365 | /* Allocate memory for the scratch ring buffer */ |
365 | err_code = usbvision_scratch_alloc(usbvision); | 366 | err_code = usbvision_scratch_alloc(usbvision); |
366 | if (isoc_mode==ISOC_MODE_COMPRESS) { | 367 | if (isoc_mode == ISOC_MODE_COMPRESS) { |
367 | /* Allocate intermediate decompression buffers | 368 | /* Allocate intermediate decompression buffers |
368 | only if needed */ | 369 | only if needed */ |
369 | err_code = usbvision_decompress_alloc(usbvision); | 370 | err_code = usbvision_decompress_alloc(usbvision); |
@@ -385,7 +386,7 @@ static int usbvision_v4l2_open(struct file *file) | |||
385 | /* Send init sequence only once, it's large! */ | 386 | /* Send init sequence only once, it's large! */ |
386 | if (!usbvision->initialized) { | 387 | if (!usbvision->initialized) { |
387 | int setup_ok = 0; | 388 | int setup_ok = 0; |
388 | setup_ok = usbvision_setup(usbvision,isoc_mode); | 389 | setup_ok = usbvision_setup(usbvision, isoc_mode); |
389 | if (setup_ok) | 390 | if (setup_ok) |
390 | usbvision->initialized = 1; | 391 | usbvision->initialized = 1; |
391 | else | 392 | else |
@@ -396,7 +397,7 @@ static int usbvision_v4l2_open(struct file *file) | |||
396 | usbvision_begin_streaming(usbvision); | 397 | usbvision_begin_streaming(usbvision); |
397 | err_code = usbvision_init_isoc(usbvision); | 398 | err_code = usbvision_init_isoc(usbvision); |
398 | /* device must be initialized before isoc transfer */ | 399 | /* device must be initialized before isoc transfer */ |
399 | usbvision_muxsel(usbvision,0); | 400 | usbvision_muxsel(usbvision, 0); |
400 | usbvision->user++; | 401 | usbvision->user++; |
401 | } else { | 402 | } else { |
402 | if (power_on_at_open) { | 403 | if (power_on_at_open) { |
@@ -463,7 +464,7 @@ static int usbvision_v4l2_close(struct file *file) | |||
463 | * | 464 | * |
464 | */ | 465 | */ |
465 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 466 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
466 | static int vidioc_g_register (struct file *file, void *priv, | 467 | static int vidioc_g_register(struct file *file, void *priv, |
467 | struct v4l2_dbg_register *reg) | 468 | struct v4l2_dbg_register *reg) |
468 | { | 469 | { |
469 | struct usb_usbvision *usbvision = video_drvdata(file); | 470 | struct usb_usbvision *usbvision = video_drvdata(file); |
@@ -484,7 +485,7 @@ static int vidioc_g_register (struct file *file, void *priv, | |||
484 | return 0; | 485 | return 0; |
485 | } | 486 | } |
486 | 487 | ||
487 | static int vidioc_s_register (struct file *file, void *priv, | 488 | static int vidioc_s_register(struct file *file, void *priv, |
488 | struct v4l2_dbg_register *reg) | 489 | struct v4l2_dbg_register *reg) |
489 | { | 490 | { |
490 | struct usb_usbvision *usbvision = video_drvdata(file); | 491 | struct usb_usbvision *usbvision = video_drvdata(file); |
@@ -493,7 +494,7 @@ static int vidioc_s_register (struct file *file, void *priv, | |||
493 | if (!v4l2_chip_match_host(®->match)) | 494 | if (!v4l2_chip_match_host(®->match)) |
494 | return -EINVAL; | 495 | return -EINVAL; |
495 | /* NT100x has a 8-bit register space */ | 496 | /* NT100x has a 8-bit register space */ |
496 | err_code = usbvision_write_reg(usbvision, reg->reg&0xff, reg->val); | 497 | err_code = usbvision_write_reg(usbvision, reg->reg & 0xff, reg->val); |
497 | if (err_code < 0) { | 498 | if (err_code < 0) { |
498 | dev_err(&usbvision->vdev->dev, | 499 | dev_err(&usbvision->vdev->dev, |
499 | "%s: VIDIOC_DBG_S_REGISTER failed: error %d\n", | 500 | "%s: VIDIOC_DBG_S_REGISTER failed: error %d\n", |
@@ -504,7 +505,7 @@ static int vidioc_s_register (struct file *file, void *priv, | |||
504 | } | 505 | } |
505 | #endif | 506 | #endif |
506 | 507 | ||
507 | static int vidioc_querycap (struct file *file, void *priv, | 508 | static int vidioc_querycap(struct file *file, void *priv, |
508 | struct v4l2_capability *vc) | 509 | struct v4l2_capability *vc) |
509 | { | 510 | { |
510 | struct usb_usbvision *usbvision = video_drvdata(file); | 511 | struct usb_usbvision *usbvision = video_drvdata(file); |
@@ -523,7 +524,7 @@ static int vidioc_querycap (struct file *file, void *priv, | |||
523 | return 0; | 524 | return 0; |
524 | } | 525 | } |
525 | 526 | ||
526 | static int vidioc_enum_input (struct file *file, void *priv, | 527 | static int vidioc_enum_input(struct file *file, void *priv, |
527 | struct v4l2_input *vi) | 528 | struct v4l2_input *vi) |
528 | { | 529 | { |
529 | struct usb_usbvision *usbvision = video_drvdata(file); | 530 | struct usb_usbvision *usbvision = video_drvdata(file); |
@@ -531,14 +532,14 @@ static int vidioc_enum_input (struct file *file, void *priv, | |||
531 | 532 | ||
532 | if (vi->index >= usbvision->video_inputs) | 533 | if (vi->index >= usbvision->video_inputs) |
533 | return -EINVAL; | 534 | return -EINVAL; |
534 | if (usbvision->have_tuner) { | 535 | if (usbvision->have_tuner) |
535 | chan = vi->index; | 536 | chan = vi->index; |
536 | } else { | 537 | else |
537 | chan = vi->index + 1; /* skip Television string*/ | 538 | chan = vi->index + 1; /* skip Television string*/ |
538 | } | 539 | |
539 | /* Determine the requested input characteristics | 540 | /* Determine the requested input characteristics |
540 | specific for each usbvision card model */ | 541 | specific for each usbvision card model */ |
541 | switch(chan) { | 542 | switch (chan) { |
542 | case 0: | 543 | case 0: |
543 | if (usbvision_device_data[usbvision->dev_model].video_channels == 4) { | 544 | if (usbvision_device_data[usbvision->dev_model].video_channels == 4) { |
544 | strcpy(vi->name, "White Video Input"); | 545 | strcpy(vi->name, "White Video Input"); |
@@ -552,20 +553,18 @@ static int vidioc_enum_input (struct file *file, void *priv, | |||
552 | break; | 553 | break; |
553 | case 1: | 554 | case 1: |
554 | vi->type = V4L2_INPUT_TYPE_CAMERA; | 555 | vi->type = V4L2_INPUT_TYPE_CAMERA; |
555 | if (usbvision_device_data[usbvision->dev_model].video_channels == 4) { | 556 | if (usbvision_device_data[usbvision->dev_model].video_channels == 4) |
556 | strcpy(vi->name, "Green Video Input"); | 557 | strcpy(vi->name, "Green Video Input"); |
557 | } else { | 558 | else |
558 | strcpy(vi->name, "Composite Video Input"); | 559 | strcpy(vi->name, "Composite Video Input"); |
559 | } | ||
560 | vi->std = V4L2_STD_PAL; | 560 | vi->std = V4L2_STD_PAL; |
561 | break; | 561 | break; |
562 | case 2: | 562 | case 2: |
563 | vi->type = V4L2_INPUT_TYPE_CAMERA; | 563 | vi->type = V4L2_INPUT_TYPE_CAMERA; |
564 | if (usbvision_device_data[usbvision->dev_model].video_channels == 4) { | 564 | if (usbvision_device_data[usbvision->dev_model].video_channels == 4) |
565 | strcpy(vi->name, "Yellow Video Input"); | 565 | strcpy(vi->name, "Yellow Video Input"); |
566 | } else { | 566 | else |
567 | strcpy(vi->name, "S-Video Input"); | 567 | strcpy(vi->name, "S-Video Input"); |
568 | } | ||
569 | vi->std = V4L2_STD_PAL; | 568 | vi->std = V4L2_STD_PAL; |
570 | break; | 569 | break; |
571 | case 3: | 570 | case 3: |
@@ -577,7 +576,7 @@ static int vidioc_enum_input (struct file *file, void *priv, | |||
577 | return 0; | 576 | return 0; |
578 | } | 577 | } |
579 | 578 | ||
580 | static int vidioc_g_input (struct file *file, void *priv, unsigned int *input) | 579 | static int vidioc_g_input(struct file *file, void *priv, unsigned int *input) |
581 | { | 580 | { |
582 | struct usb_usbvision *usbvision = video_drvdata(file); | 581 | struct usb_usbvision *usbvision = video_drvdata(file); |
583 | 582 | ||
@@ -585,7 +584,7 @@ static int vidioc_g_input (struct file *file, void *priv, unsigned int *input) | |||
585 | return 0; | 584 | return 0; |
586 | } | 585 | } |
587 | 586 | ||
588 | static int vidioc_s_input (struct file *file, void *priv, unsigned int input) | 587 | static int vidioc_s_input(struct file *file, void *priv, unsigned int input) |
589 | { | 588 | { |
590 | struct usb_usbvision *usbvision = video_drvdata(file); | 589 | struct usb_usbvision *usbvision = video_drvdata(file); |
591 | 590 | ||
@@ -600,11 +599,11 @@ static int vidioc_s_input (struct file *file, void *priv, unsigned int input) | |||
600 | return 0; | 599 | return 0; |
601 | } | 600 | } |
602 | 601 | ||
603 | static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *id) | 602 | static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *id) |
604 | { | 603 | { |
605 | struct usb_usbvision *usbvision = video_drvdata(file); | 604 | struct usb_usbvision *usbvision = video_drvdata(file); |
606 | 605 | ||
607 | usbvision->tvnorm_id=*id; | 606 | usbvision->tvnorm_id = *id; |
608 | 607 | ||
609 | call_all(usbvision, core, s_std, usbvision->tvnorm_id); | 608 | call_all(usbvision, core, s_std, usbvision->tvnorm_id); |
610 | /* propagate the change to the decoder */ | 609 | /* propagate the change to the decoder */ |
@@ -613,14 +612,14 @@ static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *id) | |||
613 | return 0; | 612 | return 0; |
614 | } | 613 | } |
615 | 614 | ||
616 | static int vidioc_g_tuner (struct file *file, void *priv, | 615 | static int vidioc_g_tuner(struct file *file, void *priv, |
617 | struct v4l2_tuner *vt) | 616 | struct v4l2_tuner *vt) |
618 | { | 617 | { |
619 | struct usb_usbvision *usbvision = video_drvdata(file); | 618 | struct usb_usbvision *usbvision = video_drvdata(file); |
620 | 619 | ||
621 | if (!usbvision->have_tuner || vt->index) /* Only tuner 0 */ | 620 | if (!usbvision->have_tuner || vt->index) /* Only tuner 0 */ |
622 | return -EINVAL; | 621 | return -EINVAL; |
623 | if(usbvision->radio) { | 622 | if (usbvision->radio) { |
624 | strcpy(vt->name, "Radio"); | 623 | strcpy(vt->name, "Radio"); |
625 | vt->type = V4L2_TUNER_RADIO; | 624 | vt->type = V4L2_TUNER_RADIO; |
626 | } else { | 625 | } else { |
@@ -632,7 +631,7 @@ static int vidioc_g_tuner (struct file *file, void *priv, | |||
632 | return 0; | 631 | return 0; |
633 | } | 632 | } |
634 | 633 | ||
635 | static int vidioc_s_tuner (struct file *file, void *priv, | 634 | static int vidioc_s_tuner(struct file *file, void *priv, |
636 | struct v4l2_tuner *vt) | 635 | struct v4l2_tuner *vt) |
637 | { | 636 | { |
638 | struct usb_usbvision *usbvision = video_drvdata(file); | 637 | struct usb_usbvision *usbvision = video_drvdata(file); |
@@ -646,23 +645,22 @@ static int vidioc_s_tuner (struct file *file, void *priv, | |||
646 | return 0; | 645 | return 0; |
647 | } | 646 | } |
648 | 647 | ||
649 | static int vidioc_g_frequency (struct file *file, void *priv, | 648 | static int vidioc_g_frequency(struct file *file, void *priv, |
650 | struct v4l2_frequency *freq) | 649 | struct v4l2_frequency *freq) |
651 | { | 650 | { |
652 | struct usb_usbvision *usbvision = video_drvdata(file); | 651 | struct usb_usbvision *usbvision = video_drvdata(file); |
653 | 652 | ||
654 | freq->tuner = 0; /* Only one tuner */ | 653 | freq->tuner = 0; /* Only one tuner */ |
655 | if(usbvision->radio) { | 654 | if (usbvision->radio) |
656 | freq->type = V4L2_TUNER_RADIO; | 655 | freq->type = V4L2_TUNER_RADIO; |
657 | } else { | 656 | else |
658 | freq->type = V4L2_TUNER_ANALOG_TV; | 657 | freq->type = V4L2_TUNER_ANALOG_TV; |
659 | } | ||
660 | freq->frequency = usbvision->freq; | 658 | freq->frequency = usbvision->freq; |
661 | 659 | ||
662 | return 0; | 660 | return 0; |
663 | } | 661 | } |
664 | 662 | ||
665 | static int vidioc_s_frequency (struct file *file, void *priv, | 663 | static int vidioc_s_frequency(struct file *file, void *priv, |
666 | struct v4l2_frequency *freq) | 664 | struct v4l2_frequency *freq) |
667 | { | 665 | { |
668 | struct usb_usbvision *usbvision = video_drvdata(file); | 666 | struct usb_usbvision *usbvision = video_drvdata(file); |
@@ -677,30 +675,27 @@ static int vidioc_s_frequency (struct file *file, void *priv, | |||
677 | return 0; | 675 | return 0; |
678 | } | 676 | } |
679 | 677 | ||
680 | static int vidioc_g_audio (struct file *file, void *priv, struct v4l2_audio *a) | 678 | static int vidioc_g_audio(struct file *file, void *priv, struct v4l2_audio *a) |
681 | { | 679 | { |
682 | struct usb_usbvision *usbvision = video_drvdata(file); | 680 | struct usb_usbvision *usbvision = video_drvdata(file); |
683 | 681 | ||
684 | if(usbvision->radio) { | 682 | if (usbvision->radio) |
685 | strcpy(a->name,"Radio"); | 683 | strcpy(a->name, "Radio"); |
686 | } else { | 684 | else |
687 | strcpy(a->name, "TV"); | 685 | strcpy(a->name, "TV"); |
688 | } | ||
689 | 686 | ||
690 | return 0; | 687 | return 0; |
691 | } | 688 | } |
692 | 689 | ||
693 | static int vidioc_s_audio (struct file *file, void *fh, | 690 | static int vidioc_s_audio(struct file *file, void *fh, |
694 | struct v4l2_audio *a) | 691 | struct v4l2_audio *a) |
695 | { | 692 | { |
696 | if(a->index) { | 693 | if (a->index) |
697 | return -EINVAL; | 694 | return -EINVAL; |
698 | } | ||
699 | |||
700 | return 0; | 695 | return 0; |
701 | } | 696 | } |
702 | 697 | ||
703 | static int vidioc_queryctrl (struct file *file, void *priv, | 698 | static int vidioc_queryctrl(struct file *file, void *priv, |
704 | struct v4l2_queryctrl *ctrl) | 699 | struct v4l2_queryctrl *ctrl) |
705 | { | 700 | { |
706 | struct usb_usbvision *usbvision = video_drvdata(file); | 701 | struct usb_usbvision *usbvision = video_drvdata(file); |
@@ -713,52 +708,53 @@ static int vidioc_queryctrl (struct file *file, void *priv, | |||
713 | return 0; | 708 | return 0; |
714 | } | 709 | } |
715 | 710 | ||
716 | static int vidioc_g_ctrl (struct file *file, void *priv, | 711 | static int vidioc_g_ctrl(struct file *file, void *priv, |
717 | struct v4l2_control *ctrl) | 712 | struct v4l2_control *ctrl) |
718 | { | 713 | { |
719 | struct usb_usbvision *usbvision = video_drvdata(file); | 714 | struct usb_usbvision *usbvision = video_drvdata(file); |
720 | call_all(usbvision, core, g_ctrl, ctrl); | ||
721 | 715 | ||
716 | call_all(usbvision, core, g_ctrl, ctrl); | ||
722 | return 0; | 717 | return 0; |
723 | } | 718 | } |
724 | 719 | ||
725 | static int vidioc_s_ctrl (struct file *file, void *priv, | 720 | static int vidioc_s_ctrl(struct file *file, void *priv, |
726 | struct v4l2_control *ctrl) | 721 | struct v4l2_control *ctrl) |
727 | { | 722 | { |
728 | struct usb_usbvision *usbvision = video_drvdata(file); | 723 | struct usb_usbvision *usbvision = video_drvdata(file); |
729 | call_all(usbvision, core, s_ctrl, ctrl); | ||
730 | 724 | ||
725 | call_all(usbvision, core, s_ctrl, ctrl); | ||
731 | return 0; | 726 | return 0; |
732 | } | 727 | } |
733 | 728 | ||
734 | static int vidioc_reqbufs (struct file *file, | 729 | static int vidioc_reqbufs(struct file *file, |
735 | void *priv, struct v4l2_requestbuffers *vr) | 730 | void *priv, struct v4l2_requestbuffers *vr) |
736 | { | 731 | { |
737 | struct usb_usbvision *usbvision = video_drvdata(file); | 732 | struct usb_usbvision *usbvision = video_drvdata(file); |
738 | int ret; | 733 | int ret; |
739 | 734 | ||
740 | RESTRICT_TO_RANGE(vr->count,1,USBVISION_NUMFRAMES); | 735 | RESTRICT_TO_RANGE(vr->count, 1, USBVISION_NUMFRAMES); |
741 | 736 | ||
742 | /* Check input validity: | 737 | /* Check input validity: |
743 | the user must do a VIDEO CAPTURE and MMAP method. */ | 738 | the user must do a VIDEO CAPTURE and MMAP method. */ |
744 | if (vr->memory != V4L2_MEMORY_MMAP) | 739 | if (vr->memory != V4L2_MEMORY_MMAP) |
745 | return -EINVAL; | 740 | return -EINVAL; |
746 | 741 | ||
747 | if(usbvision->streaming == stream_on) { | 742 | if (usbvision->streaming == stream_on) { |
748 | if ((ret = usbvision_stream_interrupt(usbvision))) | 743 | ret = usbvision_stream_interrupt(usbvision); |
744 | if (ret) | ||
749 | return ret; | 745 | return ret; |
750 | } | 746 | } |
751 | 747 | ||
752 | usbvision_frames_free(usbvision); | 748 | usbvision_frames_free(usbvision); |
753 | usbvision_empty_framequeues(usbvision); | 749 | usbvision_empty_framequeues(usbvision); |
754 | vr->count = usbvision_frames_alloc(usbvision,vr->count); | 750 | vr->count = usbvision_frames_alloc(usbvision, vr->count); |
755 | 751 | ||
756 | usbvision->cur_frame = NULL; | 752 | usbvision->cur_frame = NULL; |
757 | 753 | ||
758 | return 0; | 754 | return 0; |
759 | } | 755 | } |
760 | 756 | ||
761 | static int vidioc_querybuf (struct file *file, | 757 | static int vidioc_querybuf(struct file *file, |
762 | void *priv, struct v4l2_buffer *vb) | 758 | void *priv, struct v4l2_buffer *vb) |
763 | { | 759 | { |
764 | struct usb_usbvision *usbvision = video_drvdata(file); | 760 | struct usb_usbvision *usbvision = video_drvdata(file); |
@@ -766,48 +762,45 @@ static int vidioc_querybuf (struct file *file, | |||
766 | 762 | ||
767 | /* FIXME : must control | 763 | /* FIXME : must control |
768 | that buffers are mapped (VIDIOC_REQBUFS has been called) */ | 764 | that buffers are mapped (VIDIOC_REQBUFS has been called) */ |
769 | if(vb->index>=usbvision->num_frames) { | 765 | if (vb->index >= usbvision->num_frames) |
770 | return -EINVAL; | 766 | return -EINVAL; |
771 | } | ||
772 | /* Updating the corresponding frame state */ | 767 | /* Updating the corresponding frame state */ |
773 | vb->flags = 0; | 768 | vb->flags = 0; |
774 | frame = &usbvision->frame[vb->index]; | 769 | frame = &usbvision->frame[vb->index]; |
775 | if(frame->grabstate >= frame_state_ready) | 770 | if (frame->grabstate >= frame_state_ready) |
776 | vb->flags |= V4L2_BUF_FLAG_QUEUED; | 771 | vb->flags |= V4L2_BUF_FLAG_QUEUED; |
777 | if(frame->grabstate >= frame_state_done) | 772 | if (frame->grabstate >= frame_state_done) |
778 | vb->flags |= V4L2_BUF_FLAG_DONE; | 773 | vb->flags |= V4L2_BUF_FLAG_DONE; |
779 | if(frame->grabstate == frame_state_unused) | 774 | if (frame->grabstate == frame_state_unused) |
780 | vb->flags |= V4L2_BUF_FLAG_MAPPED; | 775 | vb->flags |= V4L2_BUF_FLAG_MAPPED; |
781 | vb->memory = V4L2_MEMORY_MMAP; | 776 | vb->memory = V4L2_MEMORY_MMAP; |
782 | 777 | ||
783 | vb->m.offset = vb->index*PAGE_ALIGN(usbvision->max_frame_size); | 778 | vb->m.offset = vb->index * PAGE_ALIGN(usbvision->max_frame_size); |
784 | 779 | ||
785 | vb->memory = V4L2_MEMORY_MMAP; | 780 | vb->memory = V4L2_MEMORY_MMAP; |
786 | vb->field = V4L2_FIELD_NONE; | 781 | vb->field = V4L2_FIELD_NONE; |
787 | vb->length = usbvision->curwidth* | 782 | vb->length = usbvision->curwidth * |
788 | usbvision->curheight* | 783 | usbvision->curheight * |
789 | usbvision->palette.bytes_per_pixel; | 784 | usbvision->palette.bytes_per_pixel; |
790 | vb->timestamp = usbvision->frame[vb->index].timestamp; | 785 | vb->timestamp = usbvision->frame[vb->index].timestamp; |
791 | vb->sequence = usbvision->frame[vb->index].sequence; | 786 | vb->sequence = usbvision->frame[vb->index].sequence; |
792 | return 0; | 787 | return 0; |
793 | } | 788 | } |
794 | 789 | ||
795 | static int vidioc_qbuf (struct file *file, void *priv, struct v4l2_buffer *vb) | 790 | static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *vb) |
796 | { | 791 | { |
797 | struct usb_usbvision *usbvision = video_drvdata(file); | 792 | struct usb_usbvision *usbvision = video_drvdata(file); |
798 | struct usbvision_frame *frame; | 793 | struct usbvision_frame *frame; |
799 | unsigned long lock_flags; | 794 | unsigned long lock_flags; |
800 | 795 | ||
801 | /* FIXME : works only on VIDEO_CAPTURE MODE, MMAP. */ | 796 | /* FIXME : works only on VIDEO_CAPTURE MODE, MMAP. */ |
802 | if(vb->index>=usbvision->num_frames) { | 797 | if (vb->index >= usbvision->num_frames) |
803 | return -EINVAL; | 798 | return -EINVAL; |
804 | } | ||
805 | 799 | ||
806 | frame = &usbvision->frame[vb->index]; | 800 | frame = &usbvision->frame[vb->index]; |
807 | 801 | ||
808 | if (frame->grabstate != frame_state_unused) { | 802 | if (frame->grabstate != frame_state_unused) |
809 | return -EAGAIN; | 803 | return -EAGAIN; |
810 | } | ||
811 | 804 | ||
812 | /* Mark it as ready and enqueue frame */ | 805 | /* Mark it as ready and enqueue frame */ |
813 | frame->grabstate = frame_state_ready; | 806 | frame->grabstate = frame_state_ready; |
@@ -826,7 +819,7 @@ static int vidioc_qbuf (struct file *file, void *priv, struct v4l2_buffer *vb) | |||
826 | return 0; | 819 | return 0; |
827 | } | 820 | } |
828 | 821 | ||
829 | static int vidioc_dqbuf (struct file *file, void *priv, struct v4l2_buffer *vb) | 822 | static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *vb) |
830 | { | 823 | { |
831 | struct usb_usbvision *usbvision = video_drvdata(file); | 824 | struct usb_usbvision *usbvision = video_drvdata(file); |
832 | int ret; | 825 | int ret; |
@@ -882,7 +875,7 @@ static int vidioc_streamoff(struct file *file, | |||
882 | if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 875 | if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
883 | return -EINVAL; | 876 | return -EINVAL; |
884 | 877 | ||
885 | if(usbvision->streaming == stream_on) { | 878 | if (usbvision->streaming == stream_on) { |
886 | usbvision_stream_interrupt(usbvision); | 879 | usbvision_stream_interrupt(usbvision); |
887 | /* Stop all video streamings */ | 880 | /* Stop all video streamings */ |
888 | call_all(usbvision, video, s_stream, 0); | 881 | call_all(usbvision, video, s_stream, 0); |
@@ -892,18 +885,17 @@ static int vidioc_streamoff(struct file *file, | |||
892 | return 0; | 885 | return 0; |
893 | } | 886 | } |
894 | 887 | ||
895 | static int vidioc_enum_fmt_vid_cap (struct file *file, void *priv, | 888 | static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, |
896 | struct v4l2_fmtdesc *vfd) | 889 | struct v4l2_fmtdesc *vfd) |
897 | { | 890 | { |
898 | if(vfd->index>=USBVISION_SUPPORTED_PALETTES-1) { | 891 | if (vfd->index >= USBVISION_SUPPORTED_PALETTES - 1) |
899 | return -EINVAL; | 892 | return -EINVAL; |
900 | } | 893 | strcpy(vfd->description, usbvision_v4l2_format[vfd->index].desc); |
901 | strcpy(vfd->description,usbvision_v4l2_format[vfd->index].desc); | ||
902 | vfd->pixelformat = usbvision_v4l2_format[vfd->index].format; | 894 | vfd->pixelformat = usbvision_v4l2_format[vfd->index].format; |
903 | return 0; | 895 | return 0; |
904 | } | 896 | } |
905 | 897 | ||
906 | static int vidioc_g_fmt_vid_cap (struct file *file, void *priv, | 898 | static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, |
907 | struct v4l2_format *vf) | 899 | struct v4l2_format *vf) |
908 | { | 900 | { |
909 | struct usb_usbvision *usbvision = video_drvdata(file); | 901 | struct usb_usbvision *usbvision = video_drvdata(file); |
@@ -911,32 +903,31 @@ static int vidioc_g_fmt_vid_cap (struct file *file, void *priv, | |||
911 | vf->fmt.pix.height = usbvision->curheight; | 903 | vf->fmt.pix.height = usbvision->curheight; |
912 | vf->fmt.pix.pixelformat = usbvision->palette.format; | 904 | vf->fmt.pix.pixelformat = usbvision->palette.format; |
913 | vf->fmt.pix.bytesperline = | 905 | vf->fmt.pix.bytesperline = |
914 | usbvision->curwidth*usbvision->palette.bytes_per_pixel; | 906 | usbvision->curwidth * usbvision->palette.bytes_per_pixel; |
915 | vf->fmt.pix.sizeimage = vf->fmt.pix.bytesperline*usbvision->curheight; | 907 | vf->fmt.pix.sizeimage = vf->fmt.pix.bytesperline * usbvision->curheight; |
916 | vf->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; | 908 | vf->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; |
917 | vf->fmt.pix.field = V4L2_FIELD_NONE; /* Always progressive image */ | 909 | vf->fmt.pix.field = V4L2_FIELD_NONE; /* Always progressive image */ |
918 | 910 | ||
919 | return 0; | 911 | return 0; |
920 | } | 912 | } |
921 | 913 | ||
922 | static int vidioc_try_fmt_vid_cap (struct file *file, void *priv, | 914 | static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, |
923 | struct v4l2_format *vf) | 915 | struct v4l2_format *vf) |
924 | { | 916 | { |
925 | struct usb_usbvision *usbvision = video_drvdata(file); | 917 | struct usb_usbvision *usbvision = video_drvdata(file); |
926 | int format_idx; | 918 | int format_idx; |
927 | 919 | ||
928 | /* Find requested format in available ones */ | 920 | /* Find requested format in available ones */ |
929 | for(format_idx=0;format_idx<USBVISION_SUPPORTED_PALETTES;format_idx++) { | 921 | for (format_idx = 0; format_idx < USBVISION_SUPPORTED_PALETTES; format_idx++) { |
930 | if(vf->fmt.pix.pixelformat == | 922 | if (vf->fmt.pix.pixelformat == |
931 | usbvision_v4l2_format[format_idx].format) { | 923 | usbvision_v4l2_format[format_idx].format) { |
932 | usbvision->palette = usbvision_v4l2_format[format_idx]; | 924 | usbvision->palette = usbvision_v4l2_format[format_idx]; |
933 | break; | 925 | break; |
934 | } | 926 | } |
935 | } | 927 | } |
936 | /* robustness */ | 928 | /* robustness */ |
937 | if(format_idx == USBVISION_SUPPORTED_PALETTES) { | 929 | if (format_idx == USBVISION_SUPPORTED_PALETTES) |
938 | return -EINVAL; | 930 | return -EINVAL; |
939 | } | ||
940 | RESTRICT_TO_RANGE(vf->fmt.pix.width, MIN_FRAME_WIDTH, MAX_FRAME_WIDTH); | 931 | RESTRICT_TO_RANGE(vf->fmt.pix.width, MIN_FRAME_WIDTH, MAX_FRAME_WIDTH); |
941 | RESTRICT_TO_RANGE(vf->fmt.pix.height, MIN_FRAME_HEIGHT, MAX_FRAME_HEIGHT); | 932 | RESTRICT_TO_RANGE(vf->fmt.pix.height, MIN_FRAME_HEIGHT, MAX_FRAME_HEIGHT); |
942 | 933 | ||
@@ -953,13 +944,14 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, | |||
953 | struct usb_usbvision *usbvision = video_drvdata(file); | 944 | struct usb_usbvision *usbvision = video_drvdata(file); |
954 | int ret; | 945 | int ret; |
955 | 946 | ||
956 | if( 0 != (ret=vidioc_try_fmt_vid_cap (file, priv, vf)) ) { | 947 | ret = vidioc_try_fmt_vid_cap(file, priv, vf); |
948 | if (ret) | ||
957 | return ret; | 949 | return ret; |
958 | } | ||
959 | 950 | ||
960 | /* stop io in case it is already in progress */ | 951 | /* stop io in case it is already in progress */ |
961 | if(usbvision->streaming == stream_on) { | 952 | if (usbvision->streaming == stream_on) { |
962 | if ((ret = usbvision_stream_interrupt(usbvision))) | 953 | ret = usbvision_stream_interrupt(usbvision); |
954 | if (ret) | ||
963 | return ret; | 955 | return ret; |
964 | } | 956 | } |
965 | usbvision_frames_free(usbvision); | 957 | usbvision_frames_free(usbvision); |
@@ -979,8 +971,7 @@ static ssize_t usbvision_v4l2_read(struct file *file, char __user *buf, | |||
979 | struct usb_usbvision *usbvision = video_drvdata(file); | 971 | struct usb_usbvision *usbvision = video_drvdata(file); |
980 | int noblock = file->f_flags & O_NONBLOCK; | 972 | int noblock = file->f_flags & O_NONBLOCK; |
981 | unsigned long lock_flags; | 973 | unsigned long lock_flags; |
982 | 974 | int ret, i; | |
983 | int ret,i; | ||
984 | struct usbvision_frame *frame; | 975 | struct usbvision_frame *frame; |
985 | 976 | ||
986 | PDEBUG(DBG_IO, "%s: %ld bytes, noblock=%d", __func__, | 977 | PDEBUG(DBG_IO, "%s: %ld bytes, noblock=%d", __func__, |
@@ -992,15 +983,15 @@ static ssize_t usbvision_v4l2_read(struct file *file, char __user *buf, | |||
992 | /* This entry point is compatible with the mmap routines | 983 | /* This entry point is compatible with the mmap routines |
993 | so that a user can do either VIDIOC_QBUF/VIDIOC_DQBUF | 984 | so that a user can do either VIDIOC_QBUF/VIDIOC_DQBUF |
994 | to get frames or call read on the device. */ | 985 | to get frames or call read on the device. */ |
995 | if(!usbvision->num_frames) { | 986 | if (!usbvision->num_frames) { |
996 | /* First, allocate some frames to work with | 987 | /* First, allocate some frames to work with |
997 | if this has not been done with VIDIOC_REQBUF */ | 988 | if this has not been done with VIDIOC_REQBUF */ |
998 | usbvision_frames_free(usbvision); | 989 | usbvision_frames_free(usbvision); |
999 | usbvision_empty_framequeues(usbvision); | 990 | usbvision_empty_framequeues(usbvision); |
1000 | usbvision_frames_alloc(usbvision,USBVISION_NUMFRAMES); | 991 | usbvision_frames_alloc(usbvision, USBVISION_NUMFRAMES); |
1001 | } | 992 | } |
1002 | 993 | ||
1003 | if(usbvision->streaming != stream_on) { | 994 | if (usbvision->streaming != stream_on) { |
1004 | /* no stream is running, make it running ! */ | 995 | /* no stream is running, make it running ! */ |
1005 | usbvision->streaming = stream_on; | 996 | usbvision->streaming = stream_on; |
1006 | call_all(usbvision, video, s_stream, 1); | 997 | call_all(usbvision, video, s_stream, 1); |
@@ -1008,9 +999,9 @@ static ssize_t usbvision_v4l2_read(struct file *file, char __user *buf, | |||
1008 | 999 | ||
1009 | /* Then, enqueue as many frames as possible | 1000 | /* Then, enqueue as many frames as possible |
1010 | (like a user of VIDIOC_QBUF would do) */ | 1001 | (like a user of VIDIOC_QBUF would do) */ |
1011 | for(i=0;i<usbvision->num_frames;i++) { | 1002 | for (i = 0; i < usbvision->num_frames; i++) { |
1012 | frame = &usbvision->frame[i]; | 1003 | frame = &usbvision->frame[i]; |
1013 | if(frame->grabstate == frame_state_unused) { | 1004 | if (frame->grabstate == frame_state_unused) { |
1014 | /* Mark it as ready and enqueue frame */ | 1005 | /* Mark it as ready and enqueue frame */ |
1015 | frame->grabstate = frame_state_ready; | 1006 | frame->grabstate = frame_state_ready; |
1016 | frame->scanstate = scan_state_scanning; | 1007 | frame->scanstate = scan_state_scanning; |
@@ -1029,7 +1020,7 @@ static ssize_t usbvision_v4l2_read(struct file *file, char __user *buf, | |||
1029 | 1020 | ||
1030 | /* Then try to steal a frame (like a VIDIOC_DQBUF would do) */ | 1021 | /* Then try to steal a frame (like a VIDIOC_DQBUF would do) */ |
1031 | if (list_empty(&(usbvision->outqueue))) { | 1022 | if (list_empty(&(usbvision->outqueue))) { |
1032 | if(noblock) | 1023 | if (noblock) |
1033 | return -EAGAIN; | 1024 | return -EAGAIN; |
1034 | 1025 | ||
1035 | ret = wait_event_interruptible | 1026 | ret = wait_event_interruptible |
@@ -1059,9 +1050,8 @@ static ssize_t usbvision_v4l2_read(struct file *file, char __user *buf, | |||
1059 | if ((count + frame->bytes_read) > (unsigned long)frame->scanlength) | 1050 | if ((count + frame->bytes_read) > (unsigned long)frame->scanlength) |
1060 | count = frame->scanlength - frame->bytes_read; | 1051 | count = frame->scanlength - frame->bytes_read; |
1061 | 1052 | ||
1062 | if (copy_to_user(buf, frame->data + frame->bytes_read, count)) { | 1053 | if (copy_to_user(buf, frame->data + frame->bytes_read, count)) |
1063 | return -EFAULT; | 1054 | return -EFAULT; |
1064 | } | ||
1065 | 1055 | ||
1066 | frame->bytes_read += count; | 1056 | frame->bytes_read += count; |
1067 | PDEBUG(DBG_IO, "%s: {copy} count used=%ld, new bytes_read=%ld", | 1057 | PDEBUG(DBG_IO, "%s: {copy} count used=%ld, new bytes_read=%ld", |
@@ -1069,12 +1059,12 @@ static ssize_t usbvision_v4l2_read(struct file *file, char __user *buf, | |||
1069 | (unsigned long)count, frame->bytes_read); | 1059 | (unsigned long)count, frame->bytes_read); |
1070 | 1060 | ||
1071 | /* For now, forget the frame if it has not been read in one shot. */ | 1061 | /* For now, forget the frame if it has not been read in one shot. */ |
1072 | /* if (frame->bytes_read >= frame->scanlength) {*/ /* All data has been read */ | 1062 | /* if (frame->bytes_read >= frame->scanlength) {*/ /* All data has been read */ |
1073 | frame->bytes_read = 0; | 1063 | frame->bytes_read = 0; |
1074 | 1064 | ||
1075 | /* Mark it as available to be used again. */ | 1065 | /* Mark it as available to be used again. */ |
1076 | frame->grabstate = frame_state_unused; | 1066 | frame->grabstate = frame_state_unused; |
1077 | /* } */ | 1067 | /* } */ |
1078 | 1068 | ||
1079 | return count; | 1069 | return count; |
1080 | } | 1070 | } |
@@ -1089,9 +1079,8 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma) | |||
1089 | 1079 | ||
1090 | PDEBUG(DBG_MMAP, "mmap"); | 1080 | PDEBUG(DBG_MMAP, "mmap"); |
1091 | 1081 | ||
1092 | if (!USBVISION_IS_OPERATIONAL(usbvision)) { | 1082 | if (!USBVISION_IS_OPERATIONAL(usbvision)) |
1093 | return -EFAULT; | 1083 | return -EFAULT; |
1094 | } | ||
1095 | 1084 | ||
1096 | if (!(vma->vm_flags & VM_WRITE) || | 1085 | if (!(vma->vm_flags & VM_WRITE) || |
1097 | size != PAGE_ALIGN(usbvision->max_frame_size)) { | 1086 | size != PAGE_ALIGN(usbvision->max_frame_size)) { |
@@ -1115,7 +1104,6 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma) | |||
1115 | 1104 | ||
1116 | pos = usbvision->frame[i].data; | 1105 | pos = usbvision->frame[i].data; |
1117 | while (size > 0) { | 1106 | while (size > 0) { |
1118 | |||
1119 | if (vm_insert_page(vma, start, vmalloc_to_page(pos))) { | 1107 | if (vm_insert_page(vma, start, vmalloc_to_page(pos))) { |
1120 | PDEBUG(DBG_MMAP, "mmap: vm_insert_page failed"); | 1108 | PDEBUG(DBG_MMAP, "mmap: vm_insert_page failed"); |
1121 | return -EAGAIN; | 1109 | return -EAGAIN; |
@@ -1145,9 +1133,8 @@ static int usbvision_radio_open(struct file *file) | |||
1145 | "%s: Someone tried to open an already opened USBVision Radio!\n", | 1133 | "%s: Someone tried to open an already opened USBVision Radio!\n", |
1146 | __func__); | 1134 | __func__); |
1147 | err_code = -EBUSY; | 1135 | err_code = -EBUSY; |
1148 | } | 1136 | } else { |
1149 | else { | 1137 | if (power_on_at_open) { |
1150 | if(power_on_at_open) { | ||
1151 | usbvision_reset_power_off_timer(usbvision); | 1138 | usbvision_reset_power_off_timer(usbvision); |
1152 | if (usbvision->power == 0) { | 1139 | if (usbvision->power == 0) { |
1153 | usbvision_power_on(usbvision); | 1140 | usbvision_power_on(usbvision); |
@@ -1190,12 +1177,12 @@ static int usbvision_radio_close(struct file *file) | |||
1190 | PDEBUG(DBG_IO, ""); | 1177 | PDEBUG(DBG_IO, ""); |
1191 | 1178 | ||
1192 | /* Set packet size to 0 */ | 1179 | /* Set packet size to 0 */ |
1193 | usbvision->iface_alt=0; | 1180 | usbvision->iface_alt = 0; |
1194 | err_code = usb_set_interface(usbvision->dev, usbvision->iface, | 1181 | err_code = usb_set_interface(usbvision->dev, usbvision->iface, |
1195 | usbvision->iface_alt); | 1182 | usbvision->iface_alt); |
1196 | 1183 | ||
1197 | usbvision_audio_off(usbvision); | 1184 | usbvision_audio_off(usbvision); |
1198 | usbvision->radio=0; | 1185 | usbvision->radio = 0; |
1199 | usbvision->user--; | 1186 | usbvision->user--; |
1200 | 1187 | ||
1201 | if (power_on_at_open) { | 1188 | if (power_on_at_open) { |
@@ -1222,7 +1209,7 @@ static const struct v4l2_file_operations usbvision_fops = { | |||
1222 | .read = usbvision_v4l2_read, | 1209 | .read = usbvision_v4l2_read, |
1223 | .mmap = usbvision_v4l2_mmap, | 1210 | .mmap = usbvision_v4l2_mmap, |
1224 | .unlocked_ioctl = video_ioctl2, | 1211 | .unlocked_ioctl = video_ioctl2, |
1225 | /* .poll = video_poll, */ | 1212 | /* .poll = video_poll, */ |
1226 | }; | 1213 | }; |
1227 | 1214 | ||
1228 | static const struct v4l2_ioctl_ops usbvision_ioctl_ops = { | 1215 | static const struct v4l2_ioctl_ops usbvision_ioctl_ops = { |
@@ -1258,11 +1245,11 @@ static const struct v4l2_ioctl_ops usbvision_ioctl_ops = { | |||
1258 | 1245 | ||
1259 | static struct video_device usbvision_video_template = { | 1246 | static struct video_device usbvision_video_template = { |
1260 | .fops = &usbvision_fops, | 1247 | .fops = &usbvision_fops, |
1261 | .ioctl_ops = &usbvision_ioctl_ops, | 1248 | .ioctl_ops = &usbvision_ioctl_ops, |
1262 | .name = "usbvision-video", | 1249 | .name = "usbvision-video", |
1263 | .release = video_device_release, | 1250 | .release = video_device_release, |
1264 | .tvnorms = USBVISION_NORMS, | 1251 | .tvnorms = USBVISION_NORMS, |
1265 | .current_norm = V4L2_STD_PAL | 1252 | .current_norm = V4L2_STD_PAL |
1266 | }; | 1253 | }; |
1267 | 1254 | ||
1268 | 1255 | ||
@@ -1292,9 +1279,9 @@ static const struct v4l2_ioctl_ops usbvision_radio_ioctl_ops = { | |||
1292 | 1279 | ||
1293 | static struct video_device usbvision_radio_template = { | 1280 | static struct video_device usbvision_radio_template = { |
1294 | .fops = &usbvision_radio_fops, | 1281 | .fops = &usbvision_radio_fops, |
1295 | .name = "usbvision-radio", | 1282 | .name = "usbvision-radio", |
1296 | .release = video_device_release, | 1283 | .release = video_device_release, |
1297 | .ioctl_ops = &usbvision_radio_ioctl_ops, | 1284 | .ioctl_ops = &usbvision_radio_ioctl_ops, |
1298 | 1285 | ||
1299 | .tvnorms = USBVISION_NORMS, | 1286 | .tvnorms = USBVISION_NORMS, |
1300 | .current_norm = V4L2_STD_PAL | 1287 | .current_norm = V4L2_STD_PAL |
@@ -1315,9 +1302,8 @@ static struct video_device *usbvision_vdev_init(struct usb_usbvision *usbvision, | |||
1315 | } | 1302 | } |
1316 | 1303 | ||
1317 | vdev = video_device_alloc(); | 1304 | vdev = video_device_alloc(); |
1318 | if (NULL == vdev) { | 1305 | if (NULL == vdev) |
1319 | return NULL; | 1306 | return NULL; |
1320 | } | ||
1321 | *vdev = *vdev_template; | 1307 | *vdev = *vdev_template; |
1322 | vdev->lock = &usbvision->v4l2_lock; | 1308 | vdev->lock = &usbvision->v4l2_lock; |
1323 | vdev->v4l2_dev = &usbvision->v4l2_dev; | 1309 | vdev->v4l2_dev = &usbvision->v4l2_dev; |
@@ -1333,11 +1319,10 @@ static void usbvision_unregister_video(struct usb_usbvision *usbvision) | |||
1333 | if (usbvision->rdev) { | 1319 | if (usbvision->rdev) { |
1334 | PDEBUG(DBG_PROBE, "unregister %s [v4l2]", | 1320 | PDEBUG(DBG_PROBE, "unregister %s [v4l2]", |
1335 | video_device_node_name(usbvision->rdev)); | 1321 | video_device_node_name(usbvision->rdev)); |
1336 | if (video_is_registered(usbvision->rdev)) { | 1322 | if (video_is_registered(usbvision->rdev)) |
1337 | video_unregister_device(usbvision->rdev); | 1323 | video_unregister_device(usbvision->rdev); |
1338 | } else { | 1324 | else |
1339 | video_device_release(usbvision->rdev); | 1325 | video_device_release(usbvision->rdev); |
1340 | } | ||
1341 | usbvision->rdev = NULL; | 1326 | usbvision->rdev = NULL; |
1342 | } | 1327 | } |
1343 | 1328 | ||
@@ -1345,11 +1330,10 @@ static void usbvision_unregister_video(struct usb_usbvision *usbvision) | |||
1345 | if (usbvision->vdev) { | 1330 | if (usbvision->vdev) { |
1346 | PDEBUG(DBG_PROBE, "unregister %s [v4l2]", | 1331 | PDEBUG(DBG_PROBE, "unregister %s [v4l2]", |
1347 | video_device_node_name(usbvision->vdev)); | 1332 | video_device_node_name(usbvision->vdev)); |
1348 | if (video_is_registered(usbvision->vdev)) { | 1333 | if (video_is_registered(usbvision->vdev)) |
1349 | video_unregister_device(usbvision->vdev); | 1334 | video_unregister_device(usbvision->vdev); |
1350 | } else { | 1335 | else |
1351 | video_device_release(usbvision->vdev); | 1336 | video_device_release(usbvision->vdev); |
1352 | } | ||
1353 | usbvision->vdev = NULL; | 1337 | usbvision->vdev = NULL; |
1354 | } | 1338 | } |
1355 | } | 1339 | } |
@@ -1361,14 +1345,10 @@ static int __devinit usbvision_register_video(struct usb_usbvision *usbvision) | |||
1361 | usbvision->vdev = usbvision_vdev_init(usbvision, | 1345 | usbvision->vdev = usbvision_vdev_init(usbvision, |
1362 | &usbvision_video_template, | 1346 | &usbvision_video_template, |
1363 | "USBVision Video"); | 1347 | "USBVision Video"); |
1364 | if (usbvision->vdev == NULL) { | 1348 | if (usbvision->vdev == NULL) |
1365 | goto err_exit; | 1349 | goto err_exit; |
1366 | } | 1350 | if (video_register_device(usbvision->vdev, VFL_TYPE_GRABBER, video_nr) < 0) |
1367 | if (video_register_device(usbvision->vdev, | ||
1368 | VFL_TYPE_GRABBER, | ||
1369 | video_nr)<0) { | ||
1370 | goto err_exit; | 1351 | goto err_exit; |
1371 | } | ||
1372 | printk(KERN_INFO "USBVision[%d]: registered USBVision Video device %s [v4l2]\n", | 1352 | printk(KERN_INFO "USBVision[%d]: registered USBVision Video device %s [v4l2]\n", |
1373 | usbvision->nr, video_device_node_name(usbvision->vdev)); | 1353 | usbvision->nr, video_device_node_name(usbvision->vdev)); |
1374 | 1354 | ||
@@ -1378,14 +1358,10 @@ static int __devinit usbvision_register_video(struct usb_usbvision *usbvision) | |||
1378 | usbvision->rdev = usbvision_vdev_init(usbvision, | 1358 | usbvision->rdev = usbvision_vdev_init(usbvision, |
1379 | &usbvision_radio_template, | 1359 | &usbvision_radio_template, |
1380 | "USBVision Radio"); | 1360 | "USBVision Radio"); |
1381 | if (usbvision->rdev == NULL) { | 1361 | if (usbvision->rdev == NULL) |
1382 | goto err_exit; | 1362 | goto err_exit; |
1383 | } | 1363 | if (video_register_device(usbvision->rdev, VFL_TYPE_RADIO, radio_nr) < 0) |
1384 | if (video_register_device(usbvision->rdev, | ||
1385 | VFL_TYPE_RADIO, | ||
1386 | radio_nr)<0) { | ||
1387 | goto err_exit; | 1364 | goto err_exit; |
1388 | } | ||
1389 | printk(KERN_INFO "USBVision[%d]: registered USBVision Radio device %s [v4l2]\n", | 1365 | printk(KERN_INFO "USBVision[%d]: registered USBVision Radio device %s [v4l2]\n", |
1390 | usbvision->nr, video_device_node_name(usbvision->rdev)); | 1366 | usbvision->nr, video_device_node_name(usbvision->rdev)); |
1391 | } | 1367 | } |
@@ -1459,9 +1435,7 @@ static void usbvision_release(struct usb_usbvision *usbvision) | |||
1459 | usbvision_remove_sysfs(usbvision->vdev); | 1435 | usbvision_remove_sysfs(usbvision->vdev); |
1460 | usbvision_unregister_video(usbvision); | 1436 | usbvision_unregister_video(usbvision); |
1461 | 1437 | ||
1462 | if (usbvision->ctrl_urb) { | 1438 | usb_free_urb(usbvision->ctrl_urb); |
1463 | usb_free_urb(usbvision->ctrl_urb); | ||
1464 | } | ||
1465 | 1439 | ||
1466 | v4l2_device_unregister(&usbvision->v4l2_dev); | 1440 | v4l2_device_unregister(&usbvision->v4l2_dev); |
1467 | kfree(usbvision); | 1441 | kfree(usbvision); |
@@ -1520,25 +1494,24 @@ static int __devinit usbvision_probe(struct usb_interface *intf, | |||
1520 | const struct usb_host_interface *interface; | 1494 | const struct usb_host_interface *interface; |
1521 | struct usb_usbvision *usbvision = NULL; | 1495 | struct usb_usbvision *usbvision = NULL; |
1522 | const struct usb_endpoint_descriptor *endpoint; | 1496 | const struct usb_endpoint_descriptor *endpoint; |
1523 | int model,i; | 1497 | int model, i; |
1524 | 1498 | ||
1525 | PDEBUG(DBG_PROBE, "VID=%#04x, PID=%#04x, ifnum=%u", | 1499 | PDEBUG(DBG_PROBE, "VID=%#04x, PID=%#04x, ifnum=%u", |
1526 | dev->descriptor.idVendor, | 1500 | dev->descriptor.idVendor, |
1527 | dev->descriptor.idProduct, ifnum); | 1501 | dev->descriptor.idProduct, ifnum); |
1528 | 1502 | ||
1529 | model = devid->driver_info; | 1503 | model = devid->driver_info; |
1530 | if ( (model<0) || (model>=usbvision_device_data_size) ) { | 1504 | if (model < 0 || model >= usbvision_device_data_size) { |
1531 | PDEBUG(DBG_PROBE, "model out of bounds %d",model); | 1505 | PDEBUG(DBG_PROBE, "model out of bounds %d", model); |
1532 | return -ENODEV; | 1506 | return -ENODEV; |
1533 | } | 1507 | } |
1534 | printk(KERN_INFO "%s: %s found\n", __func__, | 1508 | printk(KERN_INFO "%s: %s found\n", __func__, |
1535 | usbvision_device_data[model].model_string); | 1509 | usbvision_device_data[model].model_string); |
1536 | 1510 | ||
1537 | if (usbvision_device_data[model].interface >= 0) { | 1511 | if (usbvision_device_data[model].interface >= 0) |
1538 | interface = &dev->actconfig->interface[usbvision_device_data[model].interface]->altsetting[0]; | 1512 | interface = &dev->actconfig->interface[usbvision_device_data[model].interface]->altsetting[0]; |
1539 | } else { | 1513 | else |
1540 | interface = &dev->actconfig->interface[ifnum]->altsetting[0]; | 1514 | interface = &dev->actconfig->interface[ifnum]->altsetting[0]; |
1541 | } | ||
1542 | endpoint = &interface->endpoint[1].desc; | 1515 | endpoint = &interface->endpoint[1].desc; |
1543 | if (!usb_endpoint_xfer_isoc(endpoint)) { | 1516 | if (!usb_endpoint_xfer_isoc(endpoint)) { |
1544 | dev_err(&intf->dev, "%s: interface %d. has non-ISO endpoint!\n", | 1517 | dev_err(&intf->dev, "%s: interface %d. has non-ISO endpoint!\n", |
@@ -1559,33 +1532,31 @@ static int __devinit usbvision_probe(struct usb_interface *intf, | |||
1559 | return -ENOMEM; | 1532 | return -ENOMEM; |
1560 | } | 1533 | } |
1561 | 1534 | ||
1562 | if (dev->descriptor.bNumConfigurations > 1) { | 1535 | if (dev->descriptor.bNumConfigurations > 1) |
1563 | usbvision->bridge_type = BRIDGE_NT1004; | 1536 | usbvision->bridge_type = BRIDGE_NT1004; |
1564 | } else if (model == DAZZLE_DVC_90_REV_1_SECAM) { | 1537 | else if (model == DAZZLE_DVC_90_REV_1_SECAM) |
1565 | usbvision->bridge_type = BRIDGE_NT1005; | 1538 | usbvision->bridge_type = BRIDGE_NT1005; |
1566 | } else { | 1539 | else |
1567 | usbvision->bridge_type = BRIDGE_NT1003; | 1540 | usbvision->bridge_type = BRIDGE_NT1003; |
1568 | } | ||
1569 | PDEBUG(DBG_PROBE, "bridge_type %d", usbvision->bridge_type); | 1541 | PDEBUG(DBG_PROBE, "bridge_type %d", usbvision->bridge_type); |
1570 | 1542 | ||
1571 | /* compute alternate max packet sizes */ | 1543 | /* compute alternate max packet sizes */ |
1572 | uif = dev->actconfig->interface[0]; | 1544 | uif = dev->actconfig->interface[0]; |
1573 | 1545 | ||
1574 | usbvision->num_alt=uif->num_altsetting; | 1546 | usbvision->num_alt = uif->num_altsetting; |
1575 | PDEBUG(DBG_PROBE, "Alternate settings: %i",usbvision->num_alt); | 1547 | PDEBUG(DBG_PROBE, "Alternate settings: %i", usbvision->num_alt); |
1576 | usbvision->alt_max_pkt_size = kmalloc(32* | 1548 | usbvision->alt_max_pkt_size = kmalloc(32 * usbvision->num_alt, GFP_KERNEL); |
1577 | usbvision->num_alt,GFP_KERNEL); | ||
1578 | if (usbvision->alt_max_pkt_size == NULL) { | 1549 | if (usbvision->alt_max_pkt_size == NULL) { |
1579 | dev_err(&intf->dev, "usbvision: out of memory!\n"); | 1550 | dev_err(&intf->dev, "usbvision: out of memory!\n"); |
1580 | return -ENOMEM; | 1551 | return -ENOMEM; |
1581 | } | 1552 | } |
1582 | 1553 | ||
1583 | for (i = 0; i < usbvision->num_alt ; i++) { | 1554 | for (i = 0; i < usbvision->num_alt; i++) { |
1584 | u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[1].desc. | 1555 | u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[1].desc. |
1585 | wMaxPacketSize); | 1556 | wMaxPacketSize); |
1586 | usbvision->alt_max_pkt_size[i] = | 1557 | usbvision->alt_max_pkt_size[i] = |
1587 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); | 1558 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); |
1588 | PDEBUG(DBG_PROBE, "Alternate setting %i, max size= %i",i, | 1559 | PDEBUG(DBG_PROBE, "Alternate setting %i, max size= %i", i, |
1589 | usbvision->alt_max_pkt_size[i]); | 1560 | usbvision->alt_max_pkt_size[i]); |
1590 | } | 1561 | } |
1591 | 1562 | ||
@@ -1593,9 +1564,8 @@ static int __devinit usbvision_probe(struct usb_interface *intf, | |||
1593 | usbvision->nr = usbvision_nr++; | 1564 | usbvision->nr = usbvision_nr++; |
1594 | 1565 | ||
1595 | usbvision->have_tuner = usbvision_device_data[model].tuner; | 1566 | usbvision->have_tuner = usbvision_device_data[model].tuner; |
1596 | if (usbvision->have_tuner) { | 1567 | if (usbvision->have_tuner) |
1597 | usbvision->tuner_type = usbvision_device_data[model].tuner_type; | 1568 | usbvision->tuner_type = usbvision_device_data[model].tuner_type; |
1598 | } | ||
1599 | 1569 | ||
1600 | usbvision->dev_model = model; | 1570 | usbvision->dev_model = model; |
1601 | usbvision->remove_pending = 0; | 1571 | usbvision->remove_pending = 0; |
@@ -1689,7 +1659,7 @@ static int __init usbvision_init(void) | |||
1689 | PDEBUG(DBG_MMAP, "MMAP debugging is enabled [video]"); | 1659 | PDEBUG(DBG_MMAP, "MMAP debugging is enabled [video]"); |
1690 | 1660 | ||
1691 | /* disable planar mode support unless compression enabled */ | 1661 | /* disable planar mode support unless compression enabled */ |
1692 | if (isoc_mode != ISOC_MODE_COMPRESS ) { | 1662 | if (isoc_mode != ISOC_MODE_COMPRESS) { |
1693 | /* FIXME : not the right way to set supported flag */ | 1663 | /* FIXME : not the right way to set supported flag */ |
1694 | usbvision_v4l2_format[6].supported = 0; /* V4L2_PIX_FMT_YVU420 */ | 1664 | usbvision_v4l2_format[6].supported = 0; /* V4L2_PIX_FMT_YVU420 */ |
1695 | usbvision_v4l2_format[7].supported = 0; /* V4L2_PIX_FMT_YUV422P */ | 1665 | usbvision_v4l2_format[7].supported = 0; /* V4L2_PIX_FMT_YUV422P */ |
@@ -1706,10 +1676,10 @@ static int __init usbvision_init(void) | |||
1706 | 1676 | ||
1707 | static void __exit usbvision_exit(void) | 1677 | static void __exit usbvision_exit(void) |
1708 | { | 1678 | { |
1709 | PDEBUG(DBG_PROBE, ""); | 1679 | PDEBUG(DBG_PROBE, ""); |
1710 | 1680 | ||
1711 | usb_deregister(&usbvision_driver); | 1681 | usb_deregister(&usbvision_driver); |
1712 | PDEBUG(DBG_PROBE, "success"); | 1682 | PDEBUG(DBG_PROBE, "success"); |
1713 | } | 1683 | } |
1714 | 1684 | ||
1715 | module_init(usbvision_init); | 1685 | module_init(usbvision_init); |
diff --git a/drivers/media/video/usbvision/usbvision.h b/drivers/media/video/usbvision/usbvision.h index 514115930b4a..8074787fd1ac 100644 --- a/drivers/media/video/usbvision/usbvision.h +++ b/drivers/media/video/usbvision/usbvision.h | |||
@@ -139,7 +139,7 @@ | |||
139 | #define MAX_USB_HEIGHT 240 /* 288 */ | 139 | #define MAX_USB_HEIGHT 240 /* 288 */ |
140 | #define MAX_FRAME_HEIGHT 240 /* 288 */ /* Streching sometimes causes crashes*/ | 140 | #define MAX_FRAME_HEIGHT 240 /* 288 */ /* Streching sometimes causes crashes*/ |
141 | 141 | ||
142 | #define MAX_FRAME_SIZE (MAX_FRAME_WIDTH * MAX_FRAME_HEIGHT * MAX_BYTES_PER_PIXEL) | 142 | #define MAX_FRAME_SIZE (MAX_FRAME_WIDTH * MAX_FRAME_HEIGHT * MAX_BYTES_PER_PIXEL) |
143 | #define USBVISION_CLIPMASK_SIZE (MAX_FRAME_WIDTH * MAX_FRAME_HEIGHT / 8) /* bytesize of clipmask */ | 143 | #define USBVISION_CLIPMASK_SIZE (MAX_FRAME_WIDTH * MAX_FRAME_HEIGHT / 8) /* bytesize of clipmask */ |
144 | 144 | ||
145 | #define USBVISION_URB_FRAMES 32 | 145 | #define USBVISION_URB_FRAMES 32 |
@@ -148,7 +148,7 @@ | |||
148 | #define USBVISION_NUMFRAMES 3 /* Maximum number of frames an application can get */ | 148 | #define USBVISION_NUMFRAMES 3 /* Maximum number of frames an application can get */ |
149 | #define USBVISION_NUMSBUF 2 /* Dimensioning the USB S buffering */ | 149 | #define USBVISION_NUMSBUF 2 /* Dimensioning the USB S buffering */ |
150 | 150 | ||
151 | #define USBVISION_POWEROFF_TIME 3 * (HZ) /* 3 seconds */ | 151 | #define USBVISION_POWEROFF_TIME (3 * HZ) /* 3 seconds */ |
152 | 152 | ||
153 | 153 | ||
154 | #define FRAMERATE_MIN 0 | 154 | #define FRAMERATE_MIN 0 |
@@ -161,7 +161,8 @@ enum { | |||
161 | }; | 161 | }; |
162 | 162 | ||
163 | /* This macro restricts an int variable to an inclusive range */ | 163 | /* This macro restricts an int variable to an inclusive range */ |
164 | #define RESTRICT_TO_RANGE(v,mi,ma) { if ((v) < (mi)) (v) = (mi); else if ((v) > (ma)) (v) = (ma); } | 164 | #define RESTRICT_TO_RANGE(v, mi, ma) \ |
165 | { if ((v) < (mi)) (v) = (mi); else if ((v) > (ma)) (v) = (ma); } | ||
165 | 166 | ||
166 | /* | 167 | /* |
167 | * We use macros to do YUV -> RGB conversion because this is | 168 | * We use macros to do YUV -> RGB conversion because this is |
@@ -183,18 +184,18 @@ enum { | |||
183 | * Make sure the output values are within [0..255] range. | 184 | * Make sure the output values are within [0..255] range. |
184 | */ | 185 | */ |
185 | #define LIMIT_RGB(x) (((x) < 0) ? 0 : (((x) > 255) ? 255 : (x))) | 186 | #define LIMIT_RGB(x) (((x) < 0) ? 0 : (((x) > 255) ? 255 : (x))) |
186 | #define YUV_TO_RGB_BY_THE_BOOK(my,mu,mv,mr,mg,mb) { \ | 187 | #define YUV_TO_RGB_BY_THE_BOOK(my, mu, mv, mr, mg, mb) { \ |
187 | int mm_y, mm_yc, mm_u, mm_v, mm_r, mm_g, mm_b; \ | 188 | int mm_y, mm_yc, mm_u, mm_v, mm_r, mm_g, mm_b; \ |
188 | mm_y = (my) - 16; \ | 189 | mm_y = (my) - 16; \ |
189 | mm_u = (mu) - 128; \ | 190 | mm_u = (mu) - 128; \ |
190 | mm_v = (mv) - 128; \ | 191 | mm_v = (mv) - 128; \ |
191 | mm_yc= mm_y * 76284; \ | 192 | mm_yc = mm_y * 76284; \ |
192 | mm_b = (mm_yc + 132252*mm_v ) >> 16; \ | 193 | mm_b = (mm_yc + 132252 * mm_v) >> 16; \ |
193 | mm_g = (mm_yc - 53281*mm_u - 25625*mm_v ) >> 16; \ | 194 | mm_g = (mm_yc - 53281 * mm_u - 25625 * mm_v) >> 16; \ |
194 | mm_r = (mm_yc + 104595*mm_u ) >> 16; \ | 195 | mm_r = (mm_yc + 104595 * mm_u) >> 16; \ |
195 | mb = LIMIT_RGB(mm_b); \ | 196 | mb = LIMIT_RGB(mm_b); \ |
196 | mg = LIMIT_RGB(mm_g); \ | 197 | mg = LIMIT_RGB(mm_g); \ |
197 | mr = LIMIT_RGB(mm_r); \ | 198 | mr = LIMIT_RGB(mm_r); \ |
198 | } | 199 | } |
199 | 200 | ||
200 | /* Debugging aid */ | 201 | /* Debugging aid */ |
@@ -202,7 +203,7 @@ enum { | |||
202 | wait_queue_head_t wq; \ | 203 | wait_queue_head_t wq; \ |
203 | init_waitqueue_head(&wq); \ | 204 | init_waitqueue_head(&wq); \ |
204 | printk(KERN_INFO "Say: %s\n", what); \ | 205 | printk(KERN_INFO "Say: %s\n", what); \ |
205 | interruptible_sleep_on_timeout (&wq, HZ*3); \ | 206 | interruptible_sleep_on_timeout(&wq, HZ * 3); \ |
206 | } | 207 | } |
207 | 208 | ||
208 | /* | 209 | /* |
@@ -265,8 +266,8 @@ struct usbvision_sbuf { | |||
265 | struct urb *urb; | 266 | struct urb *urb; |
266 | }; | 267 | }; |
267 | 268 | ||
268 | #define USBVISION_MAGIC_1 0x55 | 269 | #define USBVISION_MAGIC_1 0x55 |
269 | #define USBVISION_MAGIC_2 0xAA | 270 | #define USBVISION_MAGIC_2 0xAA |
270 | #define USBVISION_HEADER_LENGTH 0x0c | 271 | #define USBVISION_HEADER_LENGTH 0x0c |
271 | #define USBVISION_SAA7111_ADDR 0x48 | 272 | #define USBVISION_SAA7111_ADDR 0x48 |
272 | #define USBVISION_SAA7113_ADDR 0x4a | 273 | #define USBVISION_SAA7113_ADDR 0x4a |
@@ -358,8 +359,8 @@ extern struct usb_device_id usbvision_table[]; | |||
358 | 359 | ||
359 | struct usb_usbvision { | 360 | struct usb_usbvision { |
360 | struct v4l2_device v4l2_dev; | 361 | struct v4l2_device v4l2_dev; |
361 | struct video_device *vdev; /* Video Device */ | 362 | struct video_device *vdev; /* Video Device */ |
362 | struct video_device *rdev; /* Radio Device */ | 363 | struct video_device *rdev; /* Radio Device */ |
363 | 364 | ||
364 | /* i2c Declaration Section*/ | 365 | /* i2c Declaration Section*/ |
365 | struct i2c_adapter i2c_adap; | 366 | struct i2c_adapter i2c_adap; |
@@ -401,7 +402,7 @@ struct usb_usbvision { | |||
401 | enum stream_state streaming; /* Are we streaming Isochronous? */ | 402 | enum stream_state streaming; /* Are we streaming Isochronous? */ |
402 | int last_error; /* What calamity struck us? */ | 403 | int last_error; /* What calamity struck us? */ |
403 | int curwidth; /* width of the frame the device is currently set to*/ | 404 | int curwidth; /* width of the frame the device is currently set to*/ |
404 | int curheight; /* height of the frame the device is currently set to*/ | 405 | int curheight; /* height of the frame the device is currently set to*/ |
405 | int stretch_width; /* stretch-factor for frame width (from usb to screen)*/ | 406 | int stretch_width; /* stretch-factor for frame width (from usb to screen)*/ |
406 | int stretch_height; /* stretch-factor for frame height (from usb to screen)*/ | 407 | int stretch_height; /* stretch-factor for frame height (from usb to screen)*/ |
407 | char *fbuf; /* Videodev buffer area for mmap*/ | 408 | char *fbuf; /* Videodev buffer area for mmap*/ |
@@ -434,7 +435,7 @@ struct usb_usbvision { | |||
434 | 435 | ||
435 | /* Decompression stuff: */ | 436 | /* Decompression stuff: */ |
436 | unsigned char *intra_frame_buffer; /* Buffer for reference frame */ | 437 | unsigned char *intra_frame_buffer; /* Buffer for reference frame */ |
437 | int block_pos; /* for test only */ | 438 | int block_pos; /* for test only */ |
438 | int request_intra; /* 0 = normal; 1 = intra frame is requested; */ | 439 | int request_intra; /* 0 = normal; 1 = intra frame is requested; */ |
439 | int last_isoc_frame_num; /* check for lost isoc frames */ | 440 | int last_isoc_frame_num; /* check for lost isoc frames */ |
440 | int isoc_packet_size; /* need to calculate used_bandwidth */ | 441 | int isoc_packet_size; /* need to calculate used_bandwidth */ |
@@ -494,7 +495,7 @@ void usbvision_scratch_free(struct usb_usbvision *usbvision); | |||
494 | int usbvision_decompress_alloc(struct usb_usbvision *usbvision); | 495 | int usbvision_decompress_alloc(struct usb_usbvision *usbvision); |
495 | void usbvision_decompress_free(struct usb_usbvision *usbvision); | 496 | void usbvision_decompress_free(struct usb_usbvision *usbvision); |
496 | 497 | ||
497 | int usbvision_setup(struct usb_usbvision *usbvision,int format); | 498 | int usbvision_setup(struct usb_usbvision *usbvision, int format); |
498 | int usbvision_init_isoc(struct usb_usbvision *usbvision); | 499 | int usbvision_init_isoc(struct usb_usbvision *usbvision); |
499 | int usbvision_restart_isoc(struct usb_usbvision *usbvision); | 500 | int usbvision_restart_isoc(struct usb_usbvision *usbvision); |
500 | void usbvision_stop_isoc(struct usb_usbvision *usbvision); | 501 | void usbvision_stop_isoc(struct usb_usbvision *usbvision); |