aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/em28xx
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@brturbo.com.br>2005-11-09 00:38:27 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-09 10:56:27 -0500
commit3acf28095009509c9ca1e283de821b5be9ddede6 (patch)
tree824f31e6942ac09d977103f4a010e0a349b3afa2 /drivers/media/video/em28xx
parente0ec29b7e5aa1f4f1ff73ebd3003336dbe83e174 (diff)
[PATCH] v4l: 886: renamed common structures to em28xx
- Renamed common structures to em28xx Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/media/video/em28xx')
-rw-r--r--drivers/media/video/em28xx/em28xx-cards.c94
-rw-r--r--drivers/media/video/em28xx/em28xx-core.c274
-rw-r--r--drivers/media/video/em28xx/em28xx-i2c.c128
-rw-r--r--drivers/media/video/em28xx/em28xx-input.c4
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c601
-rw-r--r--drivers/media/video/em28xx/em28xx.h270
6 files changed, 686 insertions, 685 deletions
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c
index ecfc8a3374db..49107fd0c0d3 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -34,7 +34,7 @@
34 34
35#include "em28xx.h" 35#include "em28xx.h"
36 36
37struct em2820_board em2820_boards[] = { 37struct em28xx_board em28xx_boards[] = {
38 [EM2800_BOARD_UNKNOWN] = { 38 [EM2800_BOARD_UNKNOWN] = {
39 .name = "Unknown EM2800 video grabber", 39 .name = "Unknown EM2800 video grabber",
40 .is_em2800 = 1, 40 .is_em2800 = 1,
@@ -42,13 +42,13 @@ struct em2820_board em2820_boards[] = {
42 .norm = VIDEO_MODE_PAL, 42 .norm = VIDEO_MODE_PAL,
43 .tda9887_conf = TDA9887_PRESENT, 43 .tda9887_conf = TDA9887_PRESENT,
44 .has_tuner = 1, 44 .has_tuner = 1,
45 .decoder = EM2820_SAA7113, 45 .decoder = EM28XX_SAA7113,
46 .input = {{ 46 .input = {{
47 .type = EM2820_VMUX_COMPOSITE1, 47 .type = EM28XX_VMUX_COMPOSITE1,
48 .vmux = 0, 48 .vmux = 0,
49 .amux = 1, 49 .amux = 1,
50 },{ 50 },{
51 .type = EM2820_VMUX_SVIDEO, 51 .type = EM28XX_VMUX_SVIDEO,
52 .vmux = 9, 52 .vmux = 9,
53 .amux = 1, 53 .amux = 1,
54 }}, 54 }},
@@ -60,13 +60,13 @@ struct em2820_board em2820_boards[] = {
60 .norm = VIDEO_MODE_PAL, 60 .norm = VIDEO_MODE_PAL,
61 .tda9887_conf = TDA9887_PRESENT, 61 .tda9887_conf = TDA9887_PRESENT,
62 .has_tuner = 1, 62 .has_tuner = 1,
63 .decoder = EM2820_SAA7113, 63 .decoder = EM28XX_SAA7113,
64 .input = {{ 64 .input = {{
65 .type = EM2820_VMUX_COMPOSITE1, 65 .type = EM28XX_VMUX_COMPOSITE1,
66 .vmux = 0, 66 .vmux = 0,
67 .amux = 1, 67 .amux = 1,
68 },{ 68 },{
69 .type = EM2820_VMUX_SVIDEO, 69 .type = EM28XX_VMUX_SVIDEO,
70 .vmux = 9, 70 .vmux = 9,
71 .amux = 1, 71 .amux = 1,
72 }}, 72 }},
@@ -78,17 +78,17 @@ struct em2820_board em2820_boards[] = {
78 .tuner_type = TUNER_LG_PAL_NEW_TAPC, 78 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
79 .tda9887_conf = TDA9887_PRESENT, 79 .tda9887_conf = TDA9887_PRESENT,
80 .has_tuner = 1, 80 .has_tuner = 1,
81 .decoder = EM2820_SAA7113, 81 .decoder = EM28XX_SAA7113,
82 .input = {{ 82 .input = {{
83 .type = EM2820_VMUX_TELEVISION, 83 .type = EM28XX_VMUX_TELEVISION,
84 .vmux = 2, 84 .vmux = 2,
85 .amux = 0, 85 .amux = 0,
86 },{ 86 },{
87 .type = EM2820_VMUX_COMPOSITE1, 87 .type = EM28XX_VMUX_COMPOSITE1,
88 .vmux = 0, 88 .vmux = 0,
89 .amux = 1, 89 .amux = 1,
90 },{ 90 },{
91 .type = EM2820_VMUX_SVIDEO, 91 .type = EM28XX_VMUX_SVIDEO,
92 .vmux = 9, 92 .vmux = 9,
93 .amux = 1, 93 .amux = 1,
94 }}, 94 }},
@@ -100,17 +100,17 @@ struct em2820_board em2820_boards[] = {
100 .tuner_type = TUNER_LG_PAL_NEW_TAPC, 100 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
101 .tda9887_conf = TDA9887_PRESENT, 101 .tda9887_conf = TDA9887_PRESENT,
102 .has_tuner = 1, 102 .has_tuner = 1,
103 .decoder = EM2820_SAA7113, 103 .decoder = EM28XX_SAA7113,
104 .input = {{ 104 .input = {{
105 .type = EM2820_VMUX_TELEVISION, 105 .type = EM28XX_VMUX_TELEVISION,
106 .vmux = 2, 106 .vmux = 2,
107 .amux = 0, 107 .amux = 0,
108 },{ 108 },{
109 .type = EM2820_VMUX_COMPOSITE1, 109 .type = EM28XX_VMUX_COMPOSITE1,
110 .vmux = 0, 110 .vmux = 0,
111 .amux = 1, 111 .amux = 1,
112 },{ 112 },{
113 .type = EM2820_VMUX_SVIDEO, 113 .type = EM28XX_VMUX_SVIDEO,
114 .vmux = 9, 114 .vmux = 9,
115 .amux = 1, 115 .amux = 1,
116 }}, 116 }},
@@ -122,15 +122,15 @@ struct em2820_board em2820_boards[] = {
122 .tuner_type = TUNER_PHILIPS_FM1236_MK3, 122 .tuner_type = TUNER_PHILIPS_FM1236_MK3,
123 .tda9887_conf = TDA9887_PRESENT|TDA9887_PORT1_ACTIVE|TDA9887_PORT2_ACTIVE, 123 .tda9887_conf = TDA9887_PRESENT|TDA9887_PORT1_ACTIVE|TDA9887_PORT2_ACTIVE,
124 .has_tuner = 1, 124 .has_tuner = 1,
125 .decoder = EM2820_TVP5150, 125 .decoder = EM28XX_TVP5150,
126 .has_msp34xx = 1, 126 .has_msp34xx = 1,
127 /*FIXME: S-Video not tested */ 127 /*FIXME: S-Video not tested */
128 .input = {{ 128 .input = {{
129 .type = EM2820_VMUX_TELEVISION, 129 .type = EM28XX_VMUX_TELEVISION,
130 .vmux = 0, 130 .vmux = 0,
131 .amux = 0, 131 .amux = 0,
132 },{ 132 },{
133 .type = EM2820_VMUX_SVIDEO, 133 .type = EM28XX_VMUX_SVIDEO,
134 .vmux = 2, 134 .vmux = 2,
135 .amux = 1, 135 .amux = 1,
136 }}, 136 }},
@@ -142,17 +142,17 @@ struct em2820_board em2820_boards[] = {
142 .tuner_type = TUNER_LG_PAL_NEW_TAPC, 142 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
143 .tda9887_conf = TDA9887_PRESENT|TDA9887_PORT1_ACTIVE|TDA9887_PORT2_ACTIVE, 143 .tda9887_conf = TDA9887_PRESENT|TDA9887_PORT1_ACTIVE|TDA9887_PORT2_ACTIVE,
144 .has_tuner = 1, 144 .has_tuner = 1,
145 .decoder = EM2820_SAA7114, 145 .decoder = EM28XX_SAA7114,
146 .input = {{ 146 .input = {{
147 .type = EM2820_VMUX_TELEVISION, 147 .type = EM28XX_VMUX_TELEVISION,
148 .vmux = 4, 148 .vmux = 4,
149 .amux = 0, 149 .amux = 0,
150 },{ 150 },{
151 .type = EM2820_VMUX_COMPOSITE1, 151 .type = EM28XX_VMUX_COMPOSITE1,
152 .vmux = 0, 152 .vmux = 0,
153 .amux = 1, 153 .amux = 1,
154 },{ 154 },{
155 .type = EM2820_VMUX_SVIDEO, 155 .type = EM28XX_VMUX_SVIDEO,
156 .vmux = 9, 156 .vmux = 9,
157 .amux = 1, 157 .amux = 1,
158 }}, 158 }},
@@ -165,17 +165,17 @@ struct em2820_board em2820_boards[] = {
165 .tuner_type = TUNER_LG_PAL_NEW_TAPC, 165 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
166 .tda9887_conf = TDA9887_PRESENT, 166 .tda9887_conf = TDA9887_PRESENT,
167 .has_tuner = 1, 167 .has_tuner = 1,
168 .decoder = EM2820_SAA7113, 168 .decoder = EM28XX_SAA7113,
169 .input = {{ 169 .input = {{
170 .type = EM2820_VMUX_TELEVISION, 170 .type = EM28XX_VMUX_TELEVISION,
171 .vmux = 2, 171 .vmux = 2,
172 .amux = 0, 172 .amux = 0,
173 },{ 173 },{
174 .type = EM2820_VMUX_COMPOSITE1, 174 .type = EM28XX_VMUX_COMPOSITE1,
175 .vmux = 0, 175 .vmux = 0,
176 .amux = 1, 176 .amux = 1,
177 },{ 177 },{
178 .type = EM2820_VMUX_SVIDEO, 178 .type = EM28XX_VMUX_SVIDEO,
179 .vmux = 9, 179 .vmux = 9,
180 .amux = 1, 180 .amux = 1,
181 }}, 181 }},
@@ -188,17 +188,17 @@ struct em2820_board em2820_boards[] = {
188 .tuner_type = TUNER_LG_PAL_NEW_TAPC, 188 .tuner_type = TUNER_LG_PAL_NEW_TAPC,
189 .tda9887_conf = TDA9887_PRESENT, 189 .tda9887_conf = TDA9887_PRESENT,
190 .has_tuner = 1, 190 .has_tuner = 1,
191 .decoder = EM2820_SAA7113, 191 .decoder = EM28XX_SAA7113,
192 .input = {{ 192 .input = {{
193 .type = EM2820_VMUX_TELEVISION, 193 .type = EM28XX_VMUX_TELEVISION,
194 .vmux = 2, 194 .vmux = 2,
195 .amux = 0, 195 .amux = 0,
196 },{ 196 },{
197 .type = EM2820_VMUX_COMPOSITE1, 197 .type = EM28XX_VMUX_COMPOSITE1,
198 .vmux = 0, 198 .vmux = 0,
199 .amux = 1, 199 .amux = 1,
200 },{ 200 },{
201 .type = EM2820_VMUX_SVIDEO, 201 .type = EM28XX_VMUX_SVIDEO,
202 .vmux = 9, 202 .vmux = 9,
203 .amux = 1, 203 .amux = 1,
204 }}, 204 }},
@@ -211,17 +211,17 @@ struct em2820_board em2820_boards[] = {
211 .tuner_type = TUNER_PHILIPS_ATSC, 211 .tuner_type = TUNER_PHILIPS_ATSC,
212 .tda9887_conf = TDA9887_PRESENT, 212 .tda9887_conf = TDA9887_PRESENT,
213 .has_tuner = 1, 213 .has_tuner = 1,
214 .decoder = EM2820_SAA7113, 214 .decoder = EM28XX_SAA7113,
215 .input = {{ 215 .input = {{
216 .type = EM2820_VMUX_TELEVISION, 216 .type = EM28XX_VMUX_TELEVISION,
217 .vmux = 2, 217 .vmux = 2,
218 .amux = 0, 218 .amux = 0,
219 },{ 219 },{
220 .type = EM2820_VMUX_COMPOSITE1, 220 .type = EM28XX_VMUX_COMPOSITE1,
221 .vmux = 0, 221 .vmux = 0,
222 .amux = 1, 222 .amux = 1,
223 },{ 223 },{
224 .type = EM2820_VMUX_SVIDEO, 224 .type = EM28XX_VMUX_SVIDEO,
225 .vmux = 9, 225 .vmux = 9,
226 .amux = 1, 226 .amux = 1,
227 }}, 227 }},
@@ -231,22 +231,22 @@ struct em2820_board em2820_boards[] = {
231 .vchannels = 3, 231 .vchannels = 3,
232 .norm = VIDEO_MODE_PAL, 232 .norm = VIDEO_MODE_PAL,
233 .has_tuner = 0, 233 .has_tuner = 0,
234 .decoder = EM2820_SAA7113, 234 .decoder = EM28XX_SAA7113,
235 .input = {{ 235 .input = {{
236 .type = EM2820_VMUX_COMPOSITE1, 236 .type = EM28XX_VMUX_COMPOSITE1,
237 .vmux = 0, 237 .vmux = 0,
238 .amux = 1, 238 .amux = 1,
239 },{ 239 },{
240 .type = EM2820_VMUX_SVIDEO, 240 .type = EM28XX_VMUX_SVIDEO,
241 .vmux = 9, 241 .vmux = 9,
242 .amux = 1, 242 .amux = 1,
243 }}, 243 }},
244 }, 244 },
245}; 245};
246const unsigned int em2820_bcount = ARRAY_SIZE(em2820_boards); 246const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards);
247 247
248/* table of devices that work with this driver */ 248/* table of devices that work with this driver */
249struct usb_device_id em2820_id_table [] = { 249struct usb_device_id em28xx_id_table [] = {
250 { USB_DEVICE(0xeb1a, 0x2800), .driver_info = EM2800_BOARD_UNKNOWN }, 250 { USB_DEVICE(0xeb1a, 0x2800), .driver_info = EM2800_BOARD_UNKNOWN },
251 { USB_DEVICE(0xeb1a, 0x2820), .driver_info = EM2820_BOARD_MSI_VOX_USB_2 }, 251 { USB_DEVICE(0xeb1a, 0x2820), .driver_info = EM2820_BOARD_MSI_VOX_USB_2 },
252 { USB_DEVICE(0x0ccd, 0x0036), .driver_info = EM2820_BOARD_TERRATEC_CINERGY_250 }, 252 { USB_DEVICE(0x0ccd, 0x0036), .driver_info = EM2820_BOARD_TERRATEC_CINERGY_250 },
@@ -256,7 +256,7 @@ struct usb_device_id em2820_id_table [] = {
256 { }, 256 { },
257}; 257};
258 258
259void em2820_card_setup(struct em2820 *dev) 259void em28xx_card_setup(struct em28xx *dev)
260{ 260{
261 /* request some modules */ 261 /* request some modules */
262 if (dev->model == EM2820_BOARD_HAUPPAUGE_WINTV_USB_2) { 262 if (dev->model == EM2820_BOARD_HAUPPAUGE_WINTV_USB_2) {
@@ -274,14 +274,14 @@ void em2820_card_setup(struct em2820 *dev)
274 if (tv.audio_processor == AUDIO_CHIP_MSP34XX) { 274 if (tv.audio_processor == AUDIO_CHIP_MSP34XX) {
275 dev->has_msp34xx=1; 275 dev->has_msp34xx=1;
276 } else dev->has_msp34xx=0; 276 } else dev->has_msp34xx=0;
277 em2820_write_regs_req(dev,0x06,0x00,"\x40",1);// Serial Bus Frequency Select Register 277 em28xx_write_regs_req(dev,0x06,0x00,"\x40",1);// Serial Bus Frequency Select Register
278 em2820_write_regs_req(dev,0x0f,0x00,"\x87",1);// XCLK Frequency Select Register 278 em28xx_write_regs_req(dev,0x0f,0x00,"\x87",1);// XCLK Frequency Select Register
279 em2820_write_regs_req(dev,0x88,0x0d,"\xd0",1); 279 em28xx_write_regs_req(dev,0x88,0x0d,"\xd0",1);
280 } 280 }
281} 281}
282 282
283EXPORT_SYMBOL(em2820_boards); 283EXPORT_SYMBOL(em28xx_boards);
284EXPORT_SYMBOL(em2820_bcount); 284EXPORT_SYMBOL(em28xx_bcount);
285EXPORT_SYMBOL(em2820_id_table); 285EXPORT_SYMBOL(em28xx_id_table);
286 286
287MODULE_DEVICE_TABLE (usb, em2820_id_table); 287MODULE_DEVICE_TABLE (usb, em28xx_id_table);
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c
index e5aae4fa818a..045547e17656 100644
--- a/drivers/media/video/em28xx/em28xx-core.c
+++ b/drivers/media/video/em28xx/em28xx-core.c
@@ -1,5 +1,5 @@
1/* 1/*
2 em2820-core.c - driver for Empia EM2800/EM2820/2840 USB video capture devices 2 em28xx-core.c - driver for Empia EM2800/EM2820/2840 USB video capture devices
3 3
4 Copyright (C) 2005 Ludovico Cavedon <cavedon@sssup.it> 4 Copyright (C) 2005 Ludovico Cavedon <cavedon@sssup.it>
5 Markus Rechberger <mrechberger@gmail.com> 5 Markus Rechberger <mrechberger@gmail.com>
@@ -36,7 +36,7 @@ unsigned int core_debug;
36module_param(core_debug,int,0644); 36module_param(core_debug,int,0644);
37MODULE_PARM_DESC(core_debug,"enable debug messages [core]"); 37MODULE_PARM_DESC(core_debug,"enable debug messages [core]");
38 38
39#define em2820_coredbg(fmt, arg...) do {\ 39#define em28xx_coredbg(fmt, arg...) do {\
40 if (core_debug) \ 40 if (core_debug) \
41 printk(KERN_INFO "%s %s :"fmt, \ 41 printk(KERN_INFO "%s %s :"fmt, \
42 dev->name, __FUNCTION__ , ##arg); } while (0) 42 dev->name, __FUNCTION__ , ##arg); } while (0)
@@ -45,7 +45,7 @@ unsigned int reg_debug;
45module_param(reg_debug,int,0644); 45module_param(reg_debug,int,0644);
46MODULE_PARM_DESC(reg_debug,"enable debug messages [URB reg]"); 46MODULE_PARM_DESC(reg_debug,"enable debug messages [URB reg]");
47 47
48#define em2820_regdbg(fmt, arg...) do {\ 48#define em28xx_regdbg(fmt, arg...) do {\
49 if (reg_debug) \ 49 if (reg_debug) \
50 printk(KERN_INFO "%s %s :"fmt, \ 50 printk(KERN_INFO "%s %s :"fmt, \
51 dev->name, __FUNCTION__ , ##arg); } while (0) 51 dev->name, __FUNCTION__ , ##arg); } while (0)
@@ -54,12 +54,12 @@ unsigned int isoc_debug;
54module_param(isoc_debug,int,0644); 54module_param(isoc_debug,int,0644);
55MODULE_PARM_DESC(isoc_debug,"enable debug messages [isoc transfers]"); 55MODULE_PARM_DESC(isoc_debug,"enable debug messages [isoc transfers]");
56 56
57#define em2820_isocdbg(fmt, arg...) do {\ 57#define em28xx_isocdbg(fmt, arg...) do {\
58 if (isoc_debug) \ 58 if (isoc_debug) \
59 printk(KERN_INFO "%s %s :"fmt, \ 59 printk(KERN_INFO "%s %s :"fmt, \
60 dev->name, __FUNCTION__ , ##arg); } while (0) 60 dev->name, __FUNCTION__ , ##arg); } while (0)
61 61
62static int alt = EM2820_PINOUT; 62static int alt = EM28XX_PINOUT;
63module_param(alt, int, 0644); 63module_param(alt, int, 0644);
64MODULE_PARM_DESC(alt, "alternate setting to use for video endpoint"); 64MODULE_PARM_DESC(alt, "alternate setting to use for video endpoint");
65 65
@@ -88,7 +88,7 @@ static const char *v4l2_ioctls[] = {
88}; 88};
89#define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls) 89#define V4L2_IOCTLS ARRAY_SIZE(v4l2_ioctls)
90 90
91void em2820_print_ioctl(char *name, unsigned int cmd) 91void em28xx_print_ioctl(char *name, unsigned int cmd)
92{ 92{
93 char *dir; 93 char *dir;
94 94
@@ -159,17 +159,17 @@ static void rvfree(void *mem, size_t size)
159} 159}
160 160
161/* 161/*
162 * em2820_request_buffers() 162 * em28xx_request_buffers()
163 * allocate a number of buffers 163 * allocate a number of buffers
164 */ 164 */
165u32 em2820_request_buffers(struct em2820 *dev, u32 count) 165u32 em28xx_request_buffers(struct em28xx *dev, u32 count)
166{ 166{
167 const size_t imagesize = PAGE_ALIGN(dev->frame_size); /*needs to be page aligned cause the buffers can be mapped individually! */ 167 const size_t imagesize = PAGE_ALIGN(dev->frame_size); /*needs to be page aligned cause the buffers can be mapped individually! */
168 void *buff = NULL; 168 void *buff = NULL;
169 u32 i; 169 u32 i;
170 em2820_coredbg("requested %i buffers with size %i", count, imagesize); 170 em28xx_coredbg("requested %i buffers with size %i", count, imagesize);
171 if (count > EM2820_NUM_FRAMES) 171 if (count > EM28XX_NUM_FRAMES)
172 count = EM2820_NUM_FRAMES; 172 count = EM28XX_NUM_FRAMES;
173 173
174 dev->num_frames = count; 174 dev->num_frames = count;
175 while (dev->num_frames > 0) { 175 while (dev->num_frames > 0) {
@@ -193,10 +193,10 @@ u32 em2820_request_buffers(struct em2820 *dev, u32 count)
193} 193}
194 194
195/* 195/*
196 * em2820_queue_unusedframes() 196 * em28xx_queue_unusedframes()
197 * add all frames that are not currently in use to the inbuffer queue 197 * add all frames that are not currently in use to the inbuffer queue
198 */ 198 */
199void em2820_queue_unusedframes(struct em2820 *dev) 199void em28xx_queue_unusedframes(struct em28xx *dev)
200{ 200{
201 unsigned long lock_flags; 201 unsigned long lock_flags;
202 u32 i; 202 u32 i;
@@ -211,10 +211,10 @@ void em2820_queue_unusedframes(struct em2820 *dev)
211} 211}
212 212
213/* 213/*
214 * em2820_release_buffers() 214 * em28xx_release_buffers()
215 * free frame buffers 215 * free frame buffers
216 */ 216 */
217void em2820_release_buffers(struct em2820 *dev) 217void em28xx_release_buffers(struct em28xx *dev)
218{ 218{
219 if (dev->num_frames) { 219 if (dev->num_frames) {
220 rvfree(dev->frame[0].bufmem, 220 rvfree(dev->frame[0].bufmem,
@@ -224,15 +224,15 @@ void em2820_release_buffers(struct em2820 *dev)
224} 224}
225 225
226/* 226/*
227 * em2820_read_reg_req() 227 * em28xx_read_reg_req()
228 * reads data from the usb device specifying bRequest 228 * reads data from the usb device specifying bRequest
229 */ 229 */
230int em2820_read_reg_req_len(struct em2820 *dev, u8 req, u16 reg, 230int em28xx_read_reg_req_len(struct em28xx *dev, u8 req, u16 reg,
231 char *buf, int len) 231 char *buf, int len)
232{ 232{
233 int ret, byte; 233 int ret, byte;
234 234
235 em2820_regdbg("req=%02x, reg=%02x ", req, reg); 235 em28xx_regdbg("req=%02x, reg=%02x ", req, reg);
236 236
237 ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), req, 237 ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), req,
238 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 238 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
@@ -250,15 +250,15 @@ int em2820_read_reg_req_len(struct em2820 *dev, u8 req, u16 reg,
250} 250}
251 251
252/* 252/*
253 * em2820_read_reg_req() 253 * em28xx_read_reg_req()
254 * reads data from the usb device specifying bRequest 254 * reads data from the usb device specifying bRequest
255 */ 255 */
256int em2820_read_reg_req(struct em2820 *dev, u8 req, u16 reg) 256int em28xx_read_reg_req(struct em28xx *dev, u8 req, u16 reg)
257{ 257{
258 u8 val; 258 u8 val;
259 int ret; 259 int ret;
260 260
261 em2820_regdbg("req=%02x, reg=%02x:", req, reg); 261 em28xx_regdbg("req=%02x, reg=%02x:", req, reg);
262 262
263 ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), req, 263 ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), req,
264 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 264 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
@@ -273,16 +273,16 @@ int em2820_read_reg_req(struct em2820 *dev, u8 req, u16 reg)
273 return val; 273 return val;
274} 274}
275 275
276int em2820_read_reg(struct em2820 *dev, u16 reg) 276int em28xx_read_reg(struct em28xx *dev, u16 reg)
277{ 277{
278 return em2820_read_reg_req(dev, USB_REQ_GET_STATUS, reg); 278 return em28xx_read_reg_req(dev, USB_REQ_GET_STATUS, reg);
279} 279}
280 280
281/* 281/*
282 * em2820_write_regs_req() 282 * em28xx_write_regs_req()
283 * sends data to the usb device, specifying bRequest 283 * sends data to the usb device, specifying bRequest
284 */ 284 */
285int em2820_write_regs_req(struct em2820 *dev, u8 req, u16 reg, char *buf, 285int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf,
286 int len) 286 int len)
287{ 287{
288 int ret; 288 int ret;
@@ -290,7 +290,7 @@ int em2820_write_regs_req(struct em2820 *dev, u8 req, u16 reg, char *buf,
290 /*usb_control_msg seems to expect a kmalloced buffer */ 290 /*usb_control_msg seems to expect a kmalloced buffer */
291 unsigned char *bufs = kmalloc(len, GFP_KERNEL); 291 unsigned char *bufs = kmalloc(len, GFP_KERNEL);
292 292
293 em2820_regdbg("req=%02x reg=%02x:", req, reg); 293 em28xx_regdbg("req=%02x reg=%02x:", req, reg);
294 294
295 if (reg_debug) { 295 if (reg_debug) {
296 int i; 296 int i;
@@ -310,124 +310,124 @@ int em2820_write_regs_req(struct em2820 *dev, u8 req, u16 reg, char *buf,
310 return ret; 310 return ret;
311} 311}
312 312
313int em2820_write_regs(struct em2820 *dev, u16 reg, char *buf, int len) 313int em28xx_write_regs(struct em28xx *dev, u16 reg, char *buf, int len)
314{ 314{
315 return em2820_write_regs_req(dev, USB_REQ_GET_STATUS, reg, buf, len); 315 return em28xx_write_regs_req(dev, USB_REQ_GET_STATUS, reg, buf, len);
316} 316}
317 317
318/* 318/*
319 * em2820_write_reg_bits() 319 * em28xx_write_reg_bits()
320 * sets only some bits (specified by bitmask) of a register, by first reading 320 * sets only some bits (specified by bitmask) of a register, by first reading
321 * the actual value 321 * the actual value
322 */ 322 */
323int em2820_write_reg_bits(struct em2820 *dev, u16 reg, u8 val, 323int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val,
324 u8 bitmask) 324 u8 bitmask)
325{ 325{
326 int oldval; 326 int oldval;
327 u8 newval; 327 u8 newval;
328 if ((oldval = em2820_read_reg(dev, reg)) < 0) 328 if ((oldval = em28xx_read_reg(dev, reg)) < 0)
329 return oldval; 329 return oldval;
330 newval = (((u8) oldval) & ~bitmask) | (val & bitmask); 330 newval = (((u8) oldval) & ~bitmask) | (val & bitmask);
331 return em2820_write_regs(dev, reg, &newval, 1); 331 return em28xx_write_regs(dev, reg, &newval, 1);
332} 332}
333 333
334/* 334/*
335 * em2820_write_ac97() 335 * em28xx_write_ac97()
336 * write a 16 bit value to the specified AC97 address (LSB first!) 336 * write a 16 bit value to the specified AC97 address (LSB first!)
337 */ 337 */
338int em2820_write_ac97(struct em2820 *dev, u8 reg, u8 * val) 338int em28xx_write_ac97(struct em28xx *dev, u8 reg, u8 * val)
339{ 339{
340 int ret; 340 int ret;
341 u8 addr = reg & 0x7f; 341 u8 addr = reg & 0x7f;
342 if ((ret = em2820_write_regs(dev, AC97LSB_REG, val, 2)) < 0) 342 if ((ret = em28xx_write_regs(dev, AC97LSB_REG, val, 2)) < 0)
343 return ret; 343 return ret;
344 if ((ret = em2820_write_regs(dev, AC97ADDR_REG, &addr, 1)) < 0) 344 if ((ret = em28xx_write_regs(dev, AC97ADDR_REG, &addr, 1)) < 0)
345 return ret; 345 return ret;
346 if ((ret = em2820_read_reg(dev, AC97BUSY_REG)) < 0) 346 if ((ret = em28xx_read_reg(dev, AC97BUSY_REG)) < 0)
347 return ret; 347 return ret;
348 else if (((u8) ret) & 0x01) { 348 else if (((u8) ret) & 0x01) {
349 em2820_warn ("AC97 command still being exectuted: not handled properly!\n"); 349 em28xx_warn ("AC97 command still being exectuted: not handled properly!\n");
350 } 350 }
351 return 0; 351 return 0;
352} 352}
353 353
354int em2820_audio_analog_set(struct em2820 *dev) 354int em28xx_audio_analog_set(struct em28xx *dev)
355{ 355{
356 char s[2] = { 0x00, 0x00 }; 356 char s[2] = { 0x00, 0x00 };
357 s[0] |= 0x1f - dev->volume; 357 s[0] |= 0x1f - dev->volume;
358 s[1] |= 0x1f - dev->volume; 358 s[1] |= 0x1f - dev->volume;
359 if (dev->mute) 359 if (dev->mute)
360 s[1] |= 0x80; 360 s[1] |= 0x80;
361 return em2820_write_ac97(dev, MASTER_AC97, s); 361 return em28xx_write_ac97(dev, MASTER_AC97, s);
362} 362}
363 363
364 364
365int em2820_colorlevels_set_default(struct em2820 *dev) 365int em28xx_colorlevels_set_default(struct em28xx *dev)
366{ 366{
367 em2820_write_regs(dev, YGAIN_REG, "\x10", 1); /* contrast */ 367 em28xx_write_regs(dev, YGAIN_REG, "\x10", 1); /* contrast */
368 em2820_write_regs(dev, YOFFSET_REG, "\x00", 1); /* brightness */ 368 em28xx_write_regs(dev, YOFFSET_REG, "\x00", 1); /* brightness */
369 em2820_write_regs(dev, UVGAIN_REG, "\x10", 1); /* saturation */ 369 em28xx_write_regs(dev, UVGAIN_REG, "\x10", 1); /* saturation */
370 em2820_write_regs(dev, UOFFSET_REG, "\x00", 1); 370 em28xx_write_regs(dev, UOFFSET_REG, "\x00", 1);
371 em2820_write_regs(dev, VOFFSET_REG, "\x00", 1); 371 em28xx_write_regs(dev, VOFFSET_REG, "\x00", 1);
372 em2820_write_regs(dev, SHARPNESS_REG, "\x00", 1); 372 em28xx_write_regs(dev, SHARPNESS_REG, "\x00", 1);
373 373
374 em2820_write_regs(dev, GAMMA_REG, "\x20", 1); 374 em28xx_write_regs(dev, GAMMA_REG, "\x20", 1);
375 em2820_write_regs(dev, RGAIN_REG, "\x20", 1); 375 em28xx_write_regs(dev, RGAIN_REG, "\x20", 1);
376 em2820_write_regs(dev, GGAIN_REG, "\x20", 1); 376 em28xx_write_regs(dev, GGAIN_REG, "\x20", 1);
377 em2820_write_regs(dev, BGAIN_REG, "\x20", 1); 377 em28xx_write_regs(dev, BGAIN_REG, "\x20", 1);
378 em2820_write_regs(dev, ROFFSET_REG, "\x00", 1); 378 em28xx_write_regs(dev, ROFFSET_REG, "\x00", 1);
379 em2820_write_regs(dev, GOFFSET_REG, "\x00", 1); 379 em28xx_write_regs(dev, GOFFSET_REG, "\x00", 1);
380 return em2820_write_regs(dev, BOFFSET_REG, "\x00", 1); 380 return em28xx_write_regs(dev, BOFFSET_REG, "\x00", 1);
381} 381}
382 382
383int em2820_capture_start(struct em2820 *dev, int start) 383int em28xx_capture_start(struct em28xx *dev, int start)
384{ 384{
385 int ret; 385 int ret;
386 /* FIXME: which is the best order? */ 386 /* FIXME: which is the best order? */
387 /* video registers are sampled by VREF */ 387 /* video registers are sampled by VREF */
388 if ((ret = em2820_write_reg_bits(dev, USBSUSP_REG, start ? 0x10 : 0x00, 388 if ((ret = em28xx_write_reg_bits(dev, USBSUSP_REG, start ? 0x10 : 0x00,
389 0x10)) < 0) 389 0x10)) < 0)
390 return ret; 390 return ret;
391 /* enable video capture */ 391 /* enable video capture */
392 return em2820_write_regs(dev, VINENABLE_REG, start ? "\x67" : "\x27", 1); 392 return em28xx_write_regs(dev, VINENABLE_REG, start ? "\x67" : "\x27", 1);
393} 393}
394 394
395int em2820_outfmt_set_yuv422(struct em2820 *dev) 395int em28xx_outfmt_set_yuv422(struct em28xx *dev)
396{ 396{
397 em2820_write_regs(dev, OUTFMT_REG, "\x34", 1); 397 em28xx_write_regs(dev, OUTFMT_REG, "\x34", 1);
398 em2820_write_regs(dev, VINMODE_REG, "\x10", 1); 398 em28xx_write_regs(dev, VINMODE_REG, "\x10", 1);
399 return em2820_write_regs(dev, VINCTRL_REG, "\x11", 1); 399 return em28xx_write_regs(dev, VINCTRL_REG, "\x11", 1);
400} 400}
401 401
402int em2820_accumulator_set(struct em2820 *dev, u8 xmin, u8 xmax, u8 ymin, 402int em28xx_accumulator_set(struct em28xx *dev, u8 xmin, u8 xmax, u8 ymin,
403 u8 ymax) 403 u8 ymax)
404{ 404{
405 em2820_coredbg("em2820 Scale: (%d,%d)-(%d,%d)\n", xmin, ymin, xmax, ymax); 405 em28xx_coredbg("em28xx Scale: (%d,%d)-(%d,%d)\n", xmin, ymin, xmax, ymax);
406 406
407 em2820_write_regs(dev, XMIN_REG, &xmin, 1); 407 em28xx_write_regs(dev, XMIN_REG, &xmin, 1);
408 em2820_write_regs(dev, XMAX_REG, &xmax, 1); 408 em28xx_write_regs(dev, XMAX_REG, &xmax, 1);
409 em2820_write_regs(dev, YMIN_REG, &ymin, 1); 409 em28xx_write_regs(dev, YMIN_REG, &ymin, 1);
410 return em2820_write_regs(dev, YMAX_REG, &ymax, 1); 410 return em28xx_write_regs(dev, YMAX_REG, &ymax, 1);
411} 411}
412 412
413int em2820_capture_area_set(struct em2820 *dev, u8 hstart, u8 vstart, 413int em28xx_capture_area_set(struct em28xx *dev, u8 hstart, u8 vstart,
414 u16 width, u16 height) 414 u16 width, u16 height)
415{ 415{
416 u8 cwidth = width; 416 u8 cwidth = width;
417 u8 cheight = height; 417 u8 cheight = height;
418 u8 overflow = (height >> 7 & 0x02) | (width >> 8 & 0x01); 418 u8 overflow = (height >> 7 & 0x02) | (width >> 8 & 0x01);
419 419
420 em2820_coredbg("em2820 Area Set: (%d,%d)\n", (width | (overflow & 2) << 7), 420 em28xx_coredbg("em28xx Area Set: (%d,%d)\n", (width | (overflow & 2) << 7),
421 (height | (overflow & 1) << 8)); 421 (height | (overflow & 1) << 8));
422 422
423 em2820_write_regs(dev, HSTART_REG, &hstart, 1); 423 em28xx_write_regs(dev, HSTART_REG, &hstart, 1);
424 em2820_write_regs(dev, VSTART_REG, &vstart, 1); 424 em28xx_write_regs(dev, VSTART_REG, &vstart, 1);
425 em2820_write_regs(dev, CWIDTH_REG, &cwidth, 1); 425 em28xx_write_regs(dev, CWIDTH_REG, &cwidth, 1);
426 em2820_write_regs(dev, CHEIGHT_REG, &cheight, 1); 426 em28xx_write_regs(dev, CHEIGHT_REG, &cheight, 1);
427 return em2820_write_regs(dev, OFLOW_REG, &overflow, 1); 427 return em28xx_write_regs(dev, OFLOW_REG, &overflow, 1);
428} 428}
429 429
430int em2820_scaler_set(struct em2820 *dev, u16 h, u16 v) 430int em28xx_scaler_set(struct em28xx *dev, u16 h, u16 v)
431{ 431{
432 u8 mode; 432 u8 mode;
433 /* the em2800 scaler only supports scaling down to 50% */ 433 /* the em2800 scaler only supports scaling down to 50% */
@@ -437,34 +437,34 @@ int em2820_scaler_set(struct em2820 *dev, u16 h, u16 v)
437 u8 buf[2]; 437 u8 buf[2];
438 buf[0] = h; 438 buf[0] = h;
439 buf[1] = h >> 8; 439 buf[1] = h >> 8;
440 em2820_write_regs(dev, HSCALELOW_REG, (char *)buf, 2); 440 em28xx_write_regs(dev, HSCALELOW_REG, (char *)buf, 2);
441 buf[0] = v; 441 buf[0] = v;
442 buf[1] = v >> 8; 442 buf[1] = v >> 8;
443 em2820_write_regs(dev, VSCALELOW_REG, (char *)buf, 2); 443 em28xx_write_regs(dev, VSCALELOW_REG, (char *)buf, 2);
444 /* it seems that both H and V scalers must be active to work correctly */ 444 /* it seems that both H and V scalers must be active to work correctly */
445 mode = (h || v)? 0x30: 0x00; 445 mode = (h || v)? 0x30: 0x00;
446 } 446 }
447 return em2820_write_reg_bits(dev, COMPR_REG, mode, 0x30); 447 return em28xx_write_reg_bits(dev, COMPR_REG, mode, 0x30);
448} 448}
449 449
450/* FIXME: this only function read values from dev */ 450/* FIXME: this only function read values from dev */
451int em2820_resolution_set(struct em2820 *dev) 451int em28xx_resolution_set(struct em28xx *dev)
452{ 452{
453 int width, height; 453 int width, height;
454 width = norm_maxw(dev); 454 width = norm_maxw(dev);
455 height = norm_maxh(dev) >> 1; 455 height = norm_maxh(dev) >> 1;
456 456
457 em2820_outfmt_set_yuv422(dev); 457 em28xx_outfmt_set_yuv422(dev);
458 em2820_accumulator_set(dev, 1, (width - 4) >> 2, 1, (height - 4) >> 2); 458 em28xx_accumulator_set(dev, 1, (width - 4) >> 2, 1, (height - 4) >> 2);
459 em2820_capture_area_set(dev, 0, 0, width >> 2, height >> 2); 459 em28xx_capture_area_set(dev, 0, 0, width >> 2, height >> 2);
460 return em2820_scaler_set(dev, dev->hscale, dev->vscale); 460 return em28xx_scaler_set(dev, dev->hscale, dev->vscale);
461} 461}
462 462
463 463
464/******************* isoc transfer handling ****************************/ 464/******************* isoc transfer handling ****************************/
465 465
466#ifdef ENABLE_DEBUG_ISOC_FRAMES 466#ifdef ENABLE_DEBUG_ISOC_FRAMES
467static void em2820_isoc_dump(struct urb *urb, struct pt_regs *regs) 467static void em28xx_isoc_dump(struct urb *urb, struct pt_regs *regs)
468{ 468{
469 int len = 0; 469 int len = 0;
470 int ntrans = 0; 470 int ntrans = 0;
@@ -503,7 +503,7 @@ static void em2820_isoc_dump(struct urb *urb, struct pt_regs *regs)
503} 503}
504#endif 504#endif
505 505
506static inline int em2820_isoc_video(struct em2820 *dev,struct em2820_frame_t **f, 506static inline int em28xx_isoc_video(struct em28xx *dev,struct em28xx_frame_t **f,
507 unsigned long *lock_flags, unsigned char buf) 507 unsigned long *lock_flags, unsigned char buf)
508{ 508{
509 if (!(buf & 0x01)) { 509 if (!(buf & 0x01)) {
@@ -511,7 +511,7 @@ static inline int em2820_isoc_video(struct em2820 *dev,struct em2820_frame_t **f
511 /*previous frame is incomplete */ 511 /*previous frame is incomplete */
512 if ((*f)->fieldbytesused < dev->field_size) { 512 if ((*f)->fieldbytesused < dev->field_size) {
513 (*f)->state = F_ERROR; 513 (*f)->state = F_ERROR;
514 em2820_isocdbg ("dropping incomplete bottom field (%i missing bytes)", 514 em28xx_isocdbg ("dropping incomplete bottom field (%i missing bytes)",
515 dev->field_size-(*f)->fieldbytesused); 515 dev->field_size-(*f)->fieldbytesused);
516 } else { 516 } else {
517 (*f)->state = F_DONE; 517 (*f)->state = F_DONE;
@@ -524,13 +524,13 @@ static inline int em2820_isoc_video(struct em2820 *dev,struct em2820_frame_t **f
524 list_move_tail(&(*f)->frame, &dev->outqueue); 524 list_move_tail(&(*f)->frame, &dev->outqueue);
525 if (!list_empty(&dev->inqueue)) 525 if (!list_empty(&dev->inqueue))
526 (*f) = list_entry(dev-> inqueue.next, 526 (*f) = list_entry(dev-> inqueue.next,
527 struct em2820_frame_t,frame); 527 struct em28xx_frame_t,frame);
528 else 528 else
529 (*f) = NULL; 529 (*f) = NULL;
530 spin_unlock_irqrestore(&dev->queue_lock,*lock_flags); 530 spin_unlock_irqrestore(&dev->queue_lock,*lock_flags);
531 } 531 }
532 if (!(*f)) { 532 if (!(*f)) {
533 em2820_isocdbg ("new frame but no buffer is free"); 533 em28xx_isocdbg ("new frame but no buffer is free");
534 return -1; 534 return -1;
535 } 535 }
536 do_gettimeofday(&(*f)->buf.timestamp); 536 do_gettimeofday(&(*f)->buf.timestamp);
@@ -545,10 +545,10 @@ static inline int em2820_isoc_video(struct em2820 *dev,struct em2820_frame_t **f
545 if ((*f)->state == F_GRABBING) { 545 if ((*f)->state == F_GRABBING) {
546 if (!(*f)->top_field) { 546 if (!(*f)->top_field) {
547 (*f)->state = F_ERROR; 547 (*f)->state = F_ERROR;
548 em2820_isocdbg ("unexpected begin of bottom field; discarding it"); 548 em28xx_isocdbg ("unexpected begin of bottom field; discarding it");
549 } else if ((*f)-> fieldbytesused < dev->field_size - 172) { 549 } else if ((*f)-> fieldbytesused < dev->field_size - 172) {
550 (*f)->state = F_ERROR; 550 (*f)->state = F_ERROR;
551 em2820_isocdbg ("dropping incomplete top field (%i missing bytes)", 551 em28xx_isocdbg ("dropping incomplete top field (%i missing bytes)",
552 dev->field_size-(*f)->fieldbytesused); 552 dev->field_size-(*f)->fieldbytesused);
553 } else { 553 } else {
554 (*f)->top_field = 0; 554 (*f)->top_field = 0;
@@ -559,14 +559,14 @@ static inline int em2820_isoc_video(struct em2820 *dev,struct em2820_frame_t **f
559 return (0); 559 return (0);
560} 560}
561 561
562static inline void em2820_isoc_video_copy(struct em2820 *dev, 562static inline void em28xx_isoc_video_copy(struct em28xx *dev,
563 struct em2820_frame_t **f, unsigned char *buf, int len) 563 struct em28xx_frame_t **f, unsigned char *buf, int len)
564{ 564{
565 void *fieldstart, *startwrite, *startread; 565 void *fieldstart, *startwrite, *startread;
566 int linesdone, currlinedone, offset, lencopy,remain; 566 int linesdone, currlinedone, offset, lencopy,remain;
567 567
568 if(dev->frame_size != (*f)->buf.length){ 568 if(dev->frame_size != (*f)->buf.length){
569 em2820_err("frame_size %i and buf.length %i are different!!!\n",dev->frame_size,(*f)->buf.length); 569 em28xx_err("frame_size %i and buf.length %i are different!!!\n",dev->frame_size,(*f)->buf.length);
570 return; 570 return;
571 } 571 }
572 572
@@ -574,7 +574,7 @@ static inline void em2820_isoc_video_copy(struct em2820 *dev,
574 len =dev->field_size - (*f)->fieldbytesused; 574 len =dev->field_size - (*f)->fieldbytesused;
575 575
576 if (buf[0] != 0x88 && buf[0] != 0x22) { 576 if (buf[0] != 0x88 && buf[0] != 0x22) {
577 em2820_isocdbg("frame is not complete\n"); 577 em28xx_isocdbg("frame is not complete\n");
578 startread = buf; 578 startread = buf;
579 len+=4; 579 len+=4;
580 } else 580 } else
@@ -613,21 +613,21 @@ static inline void em2820_isoc_video_copy(struct em2820 *dev,
613} 613}
614 614
615/* 615/*
616 * em2820_isoIrq() 616 * em28xx_isoIrq()
617 * handles the incoming isoc urbs and fills the frames from our inqueue 617 * handles the incoming isoc urbs and fills the frames from our inqueue
618 */ 618 */
619void em2820_isocIrq(struct urb *urb, struct pt_regs *regs) 619void em28xx_isocIrq(struct urb *urb, struct pt_regs *regs)
620{ 620{
621 struct em2820 *dev = urb->context; 621 struct em28xx *dev = urb->context;
622 int i, status; 622 int i, status;
623 struct em2820_frame_t **f; 623 struct em28xx_frame_t **f;
624 unsigned long lock_flags; 624 unsigned long lock_flags;
625 625
626 if (!dev) 626 if (!dev)
627 return; 627 return;
628#ifdef ENABLE_DEBUG_ISOC_FRAMES 628#ifdef ENABLE_DEBUG_ISOC_FRAMES
629 if (isoc_debug>1) 629 if (isoc_debug>1)
630 em2820_isoc_dump(urb, regs); 630 em28xx_isoc_dump(urb, regs);
631#endif 631#endif
632 632
633 if (urb->status == -ENOENT) 633 if (urb->status == -ENOENT)
@@ -639,7 +639,7 @@ void em2820_isocIrq(struct urb *urb, struct pt_regs *regs)
639 dev->stream = STREAM_OFF; 639 dev->stream = STREAM_OFF;
640 if ((*f)) 640 if ((*f))
641 (*f)->state = F_QUEUED; 641 (*f)->state = F_QUEUED;
642 em2820_isocdbg("stream interrupted"); 642 em28xx_isocdbg("stream interrupted");
643 wake_up_interruptible(&dev->wait_stream); 643 wake_up_interruptible(&dev->wait_stream);
644 } 644 }
645 645
@@ -649,7 +649,7 @@ void em2820_isocIrq(struct urb *urb, struct pt_regs *regs)
649 if (dev->stream == STREAM_ON && !list_empty(&dev->inqueue)) { 649 if (dev->stream == STREAM_ON && !list_empty(&dev->inqueue)) {
650 if (!(*f)) 650 if (!(*f))
651 (*f) = list_entry(dev->inqueue.next, 651 (*f) = list_entry(dev->inqueue.next,
652 struct em2820_frame_t, frame); 652 struct em28xx_frame_t, frame);
653 653
654 for (i = 0; i < urb->number_of_packets; i++) { 654 for (i = 0; i < urb->number_of_packets; i++) {
655 unsigned char *buf = urb->transfer_buffer + 655 unsigned char *buf = urb->transfer_buffer +
@@ -657,34 +657,34 @@ void em2820_isocIrq(struct urb *urb, struct pt_regs *regs)
657 int len = urb->iso_frame_desc[i].actual_length - 4; 657 int len = urb->iso_frame_desc[i].actual_length - 4;
658 658
659 if (urb->iso_frame_desc[i].status) { 659 if (urb->iso_frame_desc[i].status) {
660 em2820_isocdbg("data error: [%d] len=%d, status=%d", i, 660 em28xx_isocdbg("data error: [%d] len=%d, status=%d", i,
661 urb->iso_frame_desc[i].actual_length, 661 urb->iso_frame_desc[i].actual_length,
662 urb->iso_frame_desc[i].status); 662 urb->iso_frame_desc[i].status);
663 if (urb->iso_frame_desc[i].status != -EPROTO) 663 if (urb->iso_frame_desc[i].status != -EPROTO)
664 continue; 664 continue;
665 } 665 }
666 if (urb->iso_frame_desc[i].actual_length <= 0) { 666 if (urb->iso_frame_desc[i].actual_length <= 0) {
667 em2820_isocdbg("packet %d is empty",i); 667 em28xx_isocdbg("packet %d is empty",i);
668 continue; 668 continue;
669 } 669 }
670 if (urb->iso_frame_desc[i].actual_length > 670 if (urb->iso_frame_desc[i].actual_length >
671 dev->max_pkt_size) { 671 dev->max_pkt_size) {
672 em2820_isocdbg("packet bigger than packet size"); 672 em28xx_isocdbg("packet bigger than packet size");
673 continue; 673 continue;
674 } 674 }
675 /*new frame */ 675 /*new frame */
676 if (buf[0] == 0x22 && buf[1] == 0x5a) { 676 if (buf[0] == 0x22 && buf[1] == 0x5a) {
677 em2820_isocdbg("Video frame, length=%i!",len); 677 em28xx_isocdbg("Video frame, length=%i!",len);
678 678
679 if (em2820_isoc_video(dev,f,&lock_flags,buf[2])) 679 if (em28xx_isoc_video(dev,f,&lock_flags,buf[2]))
680 break; 680 break;
681 } else if (buf[0]==0x33 && buf[1]==0x95 && buf[2]==0x00) { 681 } else if (buf[0]==0x33 && buf[1]==0x95 && buf[2]==0x00) {
682 em2820_isocdbg("VBI HEADER!!!"); 682 em28xx_isocdbg("VBI HEADER!!!");
683 } 683 }
684 684
685 /* actual copying */ 685 /* actual copying */
686 if ((*f)->state == F_GRABBING) { 686 if ((*f)->state == F_GRABBING) {
687 em2820_isoc_video_copy(dev,f,buf, len); 687 em28xx_isoc_video_copy(dev,f,buf, len);
688 } 688 }
689 } 689 }
690 } 690 }
@@ -696,7 +696,7 @@ void em2820_isocIrq(struct urb *urb, struct pt_regs *regs)
696 696
697 urb->status = 0; 697 urb->status = 0;
698 if ((status = usb_submit_urb(urb, GFP_ATOMIC))) { 698 if ((status = usb_submit_urb(urb, GFP_ATOMIC))) {
699 em2820_errdev("resubmit of urb failed (error=%i)\n", status); 699 em28xx_errdev("resubmit of urb failed (error=%i)\n", status);
700 dev->state |= DEV_MISCONFIGURED; 700 dev->state |= DEV_MISCONFIGURED;
701 } 701 }
702 wake_up_interruptible(&dev->wait_frame); 702 wake_up_interruptible(&dev->wait_frame);
@@ -704,58 +704,58 @@ void em2820_isocIrq(struct urb *urb, struct pt_regs *regs)
704} 704}
705 705
706/* 706/*
707 * em2820_uninit_isoc() 707 * em28xx_uninit_isoc()
708 * deallocates the buffers and urbs allocated during em2820_init_iosc() 708 * deallocates the buffers and urbs allocated during em28xx_init_iosc()
709 */ 709 */
710void em2820_uninit_isoc(struct em2820 *dev) 710void em28xx_uninit_isoc(struct em28xx *dev)
711{ 711{
712 int i; 712 int i;
713 713
714 for (i = 0; i < EM2820_NUM_BUFS; i++) { 714 for (i = 0; i < EM28XX_NUM_BUFS; i++) {
715 if (dev->urb[i]) { 715 if (dev->urb[i]) {
716 usb_kill_urb(dev->urb[i]); 716 usb_kill_urb(dev->urb[i]);
717 if (dev->transfer_buffer[i]){ 717 if (dev->transfer_buffer[i]){
718 usb_buffer_free(dev->udev,(EM2820_NUM_PACKETS*dev->max_pkt_size),dev->transfer_buffer[i],dev->urb[i]->transfer_dma); 718 usb_buffer_free(dev->udev,(EM28XX_NUM_PACKETS*dev->max_pkt_size),dev->transfer_buffer[i],dev->urb[i]->transfer_dma);
719 } 719 }
720 usb_free_urb(dev->urb[i]); 720 usb_free_urb(dev->urb[i]);
721 } 721 }
722 dev->urb[i] = NULL; 722 dev->urb[i] = NULL;
723 dev->transfer_buffer[i] = NULL; 723 dev->transfer_buffer[i] = NULL;
724 } 724 }
725 em2820_capture_start(dev, 0); 725 em28xx_capture_start(dev, 0);
726} 726}
727 727
728/* 728/*
729 * em2820_init_isoc() 729 * em28xx_init_isoc()
730 * allocates transfer buffers and submits the urbs for isoc transfer 730 * allocates transfer buffers and submits the urbs for isoc transfer
731 */ 731 */
732int em2820_init_isoc(struct em2820 *dev) 732int em28xx_init_isoc(struct em28xx *dev)
733{ 733{
734 /* change interface to 3 which allowes the biggest packet sizes */ 734 /* change interface to 3 which allowes the biggest packet sizes */
735 int i, errCode; 735 int i, errCode;
736 const int sb_size = EM2820_NUM_PACKETS * dev->max_pkt_size; 736 const int sb_size = EM28XX_NUM_PACKETS * dev->max_pkt_size;
737 737
738 /* reset streaming vars */ 738 /* reset streaming vars */
739 dev->frame_current = NULL; 739 dev->frame_current = NULL;
740 dev->frame_count = 0; 740 dev->frame_count = 0;
741 741
742 /* allocate urbs */ 742 /* allocate urbs */
743 for (i = 0; i < EM2820_NUM_BUFS; i++) { 743 for (i = 0; i < EM28XX_NUM_BUFS; i++) {
744 struct urb *urb; 744 struct urb *urb;
745 int j, k; 745 int j, k;
746 /* allocate transfer buffer */ 746 /* allocate transfer buffer */
747 urb = usb_alloc_urb(EM2820_NUM_PACKETS, GFP_KERNEL); 747 urb = usb_alloc_urb(EM28XX_NUM_PACKETS, GFP_KERNEL);
748 if (!urb){ 748 if (!urb){
749 em2820_errdev("cannot alloc urb %i\n", i); 749 em28xx_errdev("cannot alloc urb %i\n", i);
750 em2820_uninit_isoc(dev); 750 em28xx_uninit_isoc(dev);
751 return -ENOMEM; 751 return -ENOMEM;
752 } 752 }
753 dev->transfer_buffer[i] = usb_buffer_alloc(dev->udev, sb_size, GFP_KERNEL,&urb->transfer_dma); 753 dev->transfer_buffer[i] = usb_buffer_alloc(dev->udev, sb_size, GFP_KERNEL,&urb->transfer_dma);
754 if (!dev->transfer_buffer[i]) { 754 if (!dev->transfer_buffer[i]) {
755 em2820_errdev 755 em28xx_errdev
756 ("unable to allocate %i bytes for transfer buffer %i\n", 756 ("unable to allocate %i bytes for transfer buffer %i\n",
757 sb_size, i); 757 sb_size, i);
758 em2820_uninit_isoc(dev); 758 em28xx_uninit_isoc(dev);
759 return -ENOMEM; 759 return -ENOMEM;
760 } 760 }
761 memset(dev->transfer_buffer[i], 0, sb_size); 761 memset(dev->transfer_buffer[i], 0, sb_size);
@@ -765,10 +765,10 @@ int em2820_init_isoc(struct em2820 *dev)
765 urb->transfer_flags = URB_ISO_ASAP; 765 urb->transfer_flags = URB_ISO_ASAP;
766 urb->interval = 1; 766 urb->interval = 1;
767 urb->transfer_buffer = dev->transfer_buffer[i]; 767 urb->transfer_buffer = dev->transfer_buffer[i];
768 urb->complete = em2820_isocIrq; 768 urb->complete = em28xx_isocIrq;
769 urb->number_of_packets = EM2820_NUM_PACKETS; 769 urb->number_of_packets = EM28XX_NUM_PACKETS;
770 urb->transfer_buffer_length = sb_size; 770 urb->transfer_buffer_length = sb_size;
771 for (j = k = 0; j < EM2820_NUM_PACKETS; 771 for (j = k = 0; j < EM28XX_NUM_PACKETS;
772 j++, k += dev->max_pkt_size) { 772 j++, k += dev->max_pkt_size) {
773 urb->iso_frame_desc[j].offset = k; 773 urb->iso_frame_desc[j].offset = k;
774 urb->iso_frame_desc[j].length = 774 urb->iso_frame_desc[j].length =
@@ -778,12 +778,12 @@ int em2820_init_isoc(struct em2820 *dev)
778 } 778 }
779 779
780 /* submit urbs */ 780 /* submit urbs */
781 for (i = 0; i < EM2820_NUM_BUFS; i++) { 781 for (i = 0; i < EM28XX_NUM_BUFS; i++) {
782 errCode = usb_submit_urb(dev->urb[i], GFP_KERNEL); 782 errCode = usb_submit_urb(dev->urb[i], GFP_KERNEL);
783 if (errCode) { 783 if (errCode) {
784 em2820_errdev("submit of urb %i failed (error=%i)\n", i, 784 em28xx_errdev("submit of urb %i failed (error=%i)\n", i,
785 errCode); 785 errCode);
786 em2820_uninit_isoc(dev); 786 em28xx_uninit_isoc(dev);
787 return errCode; 787 return errCode;
788 } 788 }
789 } 789 }
@@ -791,21 +791,21 @@ int em2820_init_isoc(struct em2820 *dev)
791 return 0; 791 return 0;
792} 792}
793 793
794int em2820_set_alternate(struct em2820 *dev) 794int em28xx_set_alternate(struct em28xx *dev)
795{ 795{
796 int errCode, prev_alt = dev->alt; 796 int errCode, prev_alt = dev->alt;
797 dev->alt = alt; 797 dev->alt = alt;
798 if (dev->alt == 0) { 798 if (dev->alt == 0) {
799 int i; 799 int i;
800 if(dev->is_em2800){ /* always use the max packet size for em2800 based devices */ 800 if(dev->is_em2800){ /* always use the max packet size for em2800 based devices */
801 for(i=0;i< EM2820_MAX_ALT; i++) 801 for(i=0;i< EM28XX_MAX_ALT; i++)
802 if(dev->alt_max_pkt_size[i]>dev->alt_max_pkt_size[dev->alt]) 802 if(dev->alt_max_pkt_size[i]>dev->alt_max_pkt_size[dev->alt])
803 dev->alt=i; 803 dev->alt=i;
804 }else{ 804 }else{
805 unsigned int min_pkt_size = dev->field_size / 137; /* FIXME: empiric magic number */ 805 unsigned int min_pkt_size = dev->field_size / 137; /* FIXME: empiric magic number */
806 em2820_coredbg("minimum isoc packet size: %u", min_pkt_size); 806 em28xx_coredbg("minimum isoc packet size: %u", min_pkt_size);
807 dev->alt = 7; 807 dev->alt = 7;
808 for (i = 1; i < EM2820_MAX_ALT; i += 2) /* FIXME: skip even alternate: why do they not work? */ 808 for (i = 1; i < EM28XX_MAX_ALT; i += 2) /* FIXME: skip even alternate: why do they not work? */
809 if (dev->alt_max_pkt_size[i] >= min_pkt_size) { 809 if (dev->alt_max_pkt_size[i] >= min_pkt_size) {
810 dev->alt = i; 810 dev->alt = i;
811 break; 811 break;
@@ -815,11 +815,11 @@ int em2820_set_alternate(struct em2820 *dev)
815 815
816 if (dev->alt != prev_alt) { 816 if (dev->alt != prev_alt) {
817 dev->max_pkt_size = dev->alt_max_pkt_size[dev->alt]; 817 dev->max_pkt_size = dev->alt_max_pkt_size[dev->alt];
818 em2820_coredbg("setting alternate %d with wMaxPacketSize=%u", dev->alt, 818 em28xx_coredbg("setting alternate %d with wMaxPacketSize=%u", dev->alt,
819 dev->max_pkt_size); 819 dev->max_pkt_size);
820 errCode = usb_set_interface(dev->udev, 0, dev->alt); 820 errCode = usb_set_interface(dev->udev, 0, dev->alt);
821 if (errCode < 0) { 821 if (errCode < 0) {
822 em2820_errdev 822 em28xx_errdev
823 ("cannot change alternate number to %d (error=%i)\n", 823 ("cannot change alternate number to %d (error=%i)\n",
824 dev->alt, errCode); 824 dev->alt, errCode);
825 return errCode; 825 return errCode;
diff --git a/drivers/media/video/em28xx/em28xx-i2c.c b/drivers/media/video/em28xx/em28xx-i2c.c
index a62e66bd65f9..b32d9852f34c 100644
--- a/drivers/media/video/em28xx/em28xx-i2c.c
+++ b/drivers/media/video/em28xx/em28xx-i2c.c
@@ -50,7 +50,7 @@ MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]");
50 * em2800_i2c_send_max4() 50 * em2800_i2c_send_max4()
51 * send up to 4 bytes to the i2c device 51 * send up to 4 bytes to the i2c device
52 */ 52 */
53static int em2800_i2c_send_max4(struct em2820 *dev, unsigned char addr, 53static int em2800_i2c_send_max4(struct em28xx *dev, unsigned char addr,
54 char *buf, int len) 54 char *buf, int len)
55{ 55{
56 int ret; 56 int ret;
@@ -67,19 +67,19 @@ static int em2800_i2c_send_max4(struct em2820 *dev, unsigned char addr,
67 if (len > 3) 67 if (len > 3)
68 b2[0] = buf[3]; 68 b2[0] = buf[3];
69 69
70 ret = dev->em2820_write_regs(dev, 4 - len, &b2[4 - len], 2 + len); 70 ret = dev->em28xx_write_regs(dev, 4 - len, &b2[4 - len], 2 + len);
71 if (ret != 2 + len) { 71 if (ret != 2 + len) {
72 em2820_warn("writting to i2c device failed (error=%i)\n", ret); 72 em28xx_warn("writting to i2c device failed (error=%i)\n", ret);
73 return -EIO; 73 return -EIO;
74 } 74 }
75 for (write_timeout = EM2800_I2C_WRITE_TIMEOUT; write_timeout > 0; 75 for (write_timeout = EM2800_I2C_WRITE_TIMEOUT; write_timeout > 0;
76 write_timeout -= 5) { 76 write_timeout -= 5) {
77 ret = dev->em2820_read_reg(dev, 0x05); 77 ret = dev->em28xx_read_reg(dev, 0x05);
78 if (ret == 0x80 + len - 1) 78 if (ret == 0x80 + len - 1)
79 return len; 79 return len;
80 mdelay(5); 80 mdelay(5);
81 } 81 }
82 em2820_warn("i2c write timed out\n"); 82 em28xx_warn("i2c write timed out\n");
83 return -EIO; 83 return -EIO;
84} 84}
85 85
@@ -94,7 +94,7 @@ static int em2800_i2c_send_bytes(void *data, unsigned char addr, char *buf,
94 int wrcount = 0; 94 int wrcount = 0;
95 int count; 95 int count;
96 int maxLen = 4; 96 int maxLen = 4;
97 struct em2820 *dev = (struct em2820 *)data; 97 struct em28xx *dev = (struct em28xx *)data;
98 while (len > 0) { 98 while (len > 0) {
99 count = (len > maxLen) ? maxLen : len; 99 count = (len > maxLen) ? maxLen : len;
100 ret = em2800_i2c_send_max4(dev, addr, bufPtr, count); 100 ret = em2800_i2c_send_max4(dev, addr, bufPtr, count);
@@ -112,27 +112,27 @@ static int em2800_i2c_send_bytes(void *data, unsigned char addr, char *buf,
112 * em2800_i2c_check_for_device() 112 * em2800_i2c_check_for_device()
113 * check if there is a i2c_device at the supplied address 113 * check if there is a i2c_device at the supplied address
114 */ 114 */
115static int em2800_i2c_check_for_device(struct em2820 *dev, unsigned char addr) 115static int em2800_i2c_check_for_device(struct em28xx *dev, unsigned char addr)
116{ 116{
117 char msg; 117 char msg;
118 int ret; 118 int ret;
119 int write_timeout; 119 int write_timeout;
120 msg = addr; 120 msg = addr;
121 ret = dev->em2820_write_regs(dev, 0x04, &msg, 1); 121 ret = dev->em28xx_write_regs(dev, 0x04, &msg, 1);
122 if (ret < 0) { 122 if (ret < 0) {
123 em2820_warn("setting i2c device address failed (error=%i)\n", 123 em28xx_warn("setting i2c device address failed (error=%i)\n",
124 ret); 124 ret);
125 return ret; 125 return ret;
126 } 126 }
127 msg = 0x84; 127 msg = 0x84;
128 ret = dev->em2820_write_regs(dev, 0x05, &msg, 1); 128 ret = dev->em28xx_write_regs(dev, 0x05, &msg, 1);
129 if (ret < 0) { 129 if (ret < 0) {
130 em2820_warn("preparing i2c read failed (error=%i)\n", ret); 130 em28xx_warn("preparing i2c read failed (error=%i)\n", ret);
131 return ret; 131 return ret;
132 } 132 }
133 for (write_timeout = EM2800_I2C_WRITE_TIMEOUT; write_timeout > 0; 133 for (write_timeout = EM2800_I2C_WRITE_TIMEOUT; write_timeout > 0;
134 write_timeout -= 5) { 134 write_timeout -= 5) {
135 unsigned msg = dev->em2820_read_reg(dev, 0x5); 135 unsigned msg = dev->em28xx_read_reg(dev, 0x5);
136 if (msg == 0x94) 136 if (msg == 0x94)
137 return -ENODEV; 137 return -ENODEV;
138 else if (msg == 0x84) 138 else if (msg == 0x84)
@@ -146,21 +146,21 @@ static int em2800_i2c_check_for_device(struct em2820 *dev, unsigned char addr)
146 * em2800_i2c_recv_bytes() 146 * em2800_i2c_recv_bytes()
147 * read from the i2c device 147 * read from the i2c device
148 */ 148 */
149static int em2800_i2c_recv_bytes(struct em2820 *dev, unsigned char addr, 149static int em2800_i2c_recv_bytes(struct em28xx *dev, unsigned char addr,
150 char *buf, int len) 150 char *buf, int len)
151{ 151{
152 int ret; 152 int ret;
153 /* check for the device and set i2c read address */ 153 /* check for the device and set i2c read address */
154 ret = em2800_i2c_check_for_device(dev, addr); 154 ret = em2800_i2c_check_for_device(dev, addr);
155 if (ret) { 155 if (ret) {
156 em2820_warn 156 em28xx_warn
157 ("preparing read at i2c address 0x%x failed (error=%i)\n", 157 ("preparing read at i2c address 0x%x failed (error=%i)\n",
158 addr, ret); 158 addr, ret);
159 return ret; 159 return ret;
160 } 160 }
161 ret = dev->em2820_read_reg_req_len(dev, 0x0, 0x3, buf, len); 161 ret = dev->em28xx_read_reg_req_len(dev, 0x0, 0x3, buf, len);
162 if (ret < 0) { 162 if (ret < 0) {
163 em2820_warn("reading from i2c device at 0x%x failed (error=%i)", 163 em28xx_warn("reading from i2c device at 0x%x failed (error=%i)",
164 addr, ret); 164 addr, ret);
165 return ret; 165 return ret;
166 } 166 }
@@ -168,66 +168,66 @@ static int em2800_i2c_recv_bytes(struct em2820 *dev, unsigned char addr,
168} 168}
169 169
170/* 170/*
171 * em2820_i2c_send_bytes() 171 * em28xx_i2c_send_bytes()
172 * untested for more than 4 bytes 172 * untested for more than 4 bytes
173 */ 173 */
174static int em2820_i2c_send_bytes(void *data, unsigned char addr, char *buf, 174static int em28xx_i2c_send_bytes(void *data, unsigned char addr, char *buf,
175 short len, int stop) 175 short len, int stop)
176{ 176{
177 int wrcount = 0; 177 int wrcount = 0;
178 struct em2820 *dev = (struct em2820 *)data; 178 struct em28xx *dev = (struct em28xx *)data;
179 179
180 wrcount = dev->em2820_write_regs_req(dev, stop ? 2 : 3, addr, buf, len); 180 wrcount = dev->em28xx_write_regs_req(dev, stop ? 2 : 3, addr, buf, len);
181 181
182 return wrcount; 182 return wrcount;
183} 183}
184 184
185/* 185/*
186 * em2820_i2c_recv_bytes() 186 * em28xx_i2c_recv_bytes()
187 * read a byte from the i2c device 187 * read a byte from the i2c device
188 */ 188 */
189static int em2820_i2c_recv_bytes(struct em2820 *dev, unsigned char addr, 189static int em28xx_i2c_recv_bytes(struct em28xx *dev, unsigned char addr,
190 char *buf, int len) 190 char *buf, int len)
191{ 191{
192 int ret; 192 int ret;
193 ret = dev->em2820_read_reg_req_len(dev, 2, addr, buf, len); 193 ret = dev->em28xx_read_reg_req_len(dev, 2, addr, buf, len);
194 if (ret < 0) { 194 if (ret < 0) {
195 em2820_warn("reading i2c device failed (error=%i)\n", ret); 195 em28xx_warn("reading i2c device failed (error=%i)\n", ret);
196 return ret; 196 return ret;
197 } 197 }
198 if (dev->em2820_read_reg(dev, 0x5) != 0) 198 if (dev->em28xx_read_reg(dev, 0x5) != 0)
199 return -ENODEV; 199 return -ENODEV;
200 return ret; 200 return ret;
201} 201}
202 202
203/* 203/*
204 * em2820_i2c_check_for_device() 204 * em28xx_i2c_check_for_device()
205 * check if there is a i2c_device at the supplied address 205 * check if there is a i2c_device at the supplied address
206 */ 206 */
207static int em2820_i2c_check_for_device(struct em2820 *dev, unsigned char addr) 207static int em28xx_i2c_check_for_device(struct em28xx *dev, unsigned char addr)
208{ 208{
209 char msg; 209 char msg;
210 int ret; 210 int ret;
211 msg = addr; 211 msg = addr;
212 212
213 ret = dev->em2820_read_reg_req(dev, 2, addr); 213 ret = dev->em28xx_read_reg_req(dev, 2, addr);
214 if (ret < 0) { 214 if (ret < 0) {
215 em2820_warn("reading from i2c device failed (error=%i)\n", ret); 215 em28xx_warn("reading from i2c device failed (error=%i)\n", ret);
216 return ret; 216 return ret;
217 } 217 }
218 if (dev->em2820_read_reg(dev, 0x5) != 0) 218 if (dev->em28xx_read_reg(dev, 0x5) != 0)
219 return -ENODEV; 219 return -ENODEV;
220 return 0; 220 return 0;
221} 221}
222 222
223/* 223/*
224 * em2820_i2c_xfer() 224 * em28xx_i2c_xfer()
225 * the main i2c transfer function 225 * the main i2c transfer function
226 */ 226 */
227static int em2820_i2c_xfer(struct i2c_adapter *i2c_adap, 227static int em28xx_i2c_xfer(struct i2c_adapter *i2c_adap,
228 struct i2c_msg msgs[], int num) 228 struct i2c_msg msgs[], int num)
229{ 229{
230 struct em2820 *dev = i2c_adap->algo_data; 230 struct em28xx *dev = i2c_adap->algo_data;
231 int addr, rc, i, byte; 231 int addr, rc, i, byte;
232 232
233 if (num <= 0) 233 if (num <= 0)
@@ -241,7 +241,7 @@ static int em2820_i2c_xfer(struct i2c_adapter *i2c_adap,
241 if (dev->is_em2800) 241 if (dev->is_em2800)
242 rc = em2800_i2c_check_for_device(dev, addr); 242 rc = em2800_i2c_check_for_device(dev, addr);
243 else 243 else
244 rc = em2820_i2c_check_for_device(dev, addr); 244 rc = em28xx_i2c_check_for_device(dev, addr);
245 if (rc < 0) { 245 if (rc < 0) {
246 dprintk2(2," no device\n"); 246 dprintk2(2," no device\n");
247 return rc; 247 return rc;
@@ -254,7 +254,7 @@ static int em2820_i2c_xfer(struct i2c_adapter *i2c_adap,
254 msgs[i].buf, 254 msgs[i].buf,
255 msgs[i].len); 255 msgs[i].len);
256 else 256 else
257 rc = em2820_i2c_recv_bytes(dev, addr, 257 rc = em28xx_i2c_recv_bytes(dev, addr,
258 msgs[i].buf, 258 msgs[i].buf,
259 msgs[i].len); 259 msgs[i].len);
260 if (i2c_debug>=2) { 260 if (i2c_debug>=2) {
@@ -273,7 +273,7 @@ static int em2820_i2c_xfer(struct i2c_adapter *i2c_adap,
273 msgs[i].buf, 273 msgs[i].buf,
274 msgs[i].len); 274 msgs[i].len);
275 else 275 else
276 rc = em2820_i2c_send_bytes(dev, addr, 276 rc = em28xx_i2c_send_bytes(dev, addr,
277 msgs[i].buf, 277 msgs[i].buf,
278 msgs[i].len, 278 msgs[i].len,
279 i == num - 1); 279 i == num - 1);
@@ -290,10 +290,10 @@ static int em2820_i2c_xfer(struct i2c_adapter *i2c_adap,
290 return rc; 290 return rc;
291} 291}
292 292
293static int em2820_i2c_eeprom(struct em2820 *dev, unsigned char *eedata, int len) 293static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned char *eedata, int len)
294{ 294{
295 unsigned char buf, *p = eedata; 295 unsigned char buf, *p = eedata;
296 struct em2820_eeprom *em_eeprom = (void *)eedata; 296 struct em28xx_eeprom *em_eeprom = (void *)eedata;
297 int i, err, size = len, block; 297 int i, err, size = len, block;
298 298
299 dev->i2c_client.addr = 0xa0 >> 1; 299 dev->i2c_client.addr = 0xa0 >> 1;
@@ -410,9 +410,9 @@ static void dec_use(struct i2c_adapter *adap)
410} 410}
411#endif 411#endif
412 412
413static int em2820_set_tuner(int check_eeprom, struct i2c_client *client) 413static int em28xx_set_tuner(int check_eeprom, struct i2c_client *client)
414{ 414{
415 struct em2820 *dev = client->adapter->algo_data; 415 struct em28xx *dev = client->adapter->algo_data;
416 struct tuner_setup tun_setup; 416 struct tuner_setup tun_setup;
417 417
418 if (dev->has_tuner) { 418 if (dev->has_tuner) {
@@ -420,7 +420,7 @@ static int em2820_set_tuner(int check_eeprom, struct i2c_client *client)
420 tun_setup.type = dev->tuner_type; 420 tun_setup.type = dev->tuner_type;
421 tun_setup.addr = dev->tuner_addr; 421 tun_setup.addr = dev->tuner_addr;
422 422
423 em2820_i2c_call_clients(dev, TUNER_SET_TYPE_ADDR, &tun_setup); 423 em28xx_i2c_call_clients(dev, TUNER_SET_TYPE_ADDR, &tun_setup);
424 } 424 }
425 425
426 return (0); 426 return (0);
@@ -433,11 +433,11 @@ static int em2820_set_tuner(int check_eeprom, struct i2c_client *client)
433 */ 433 */
434static int attach_inform(struct i2c_client *client) 434static int attach_inform(struct i2c_client *client)
435{ 435{
436 struct em2820 *dev = client->adapter->algo_data; 436 struct em28xx *dev = client->adapter->algo_data;
437 437
438 switch (client->addr << 1) { 438 switch (client->addr << 1) {
439 case 0x86: 439 case 0x86:
440 em2820_i2c_call_clients(dev, TDA9887_SET_CONFIG, &dev->tda9887_conf); 440 em28xx_i2c_call_clients(dev, TDA9887_SET_CONFIG, &dev->tda9887_conf);
441 break; 441 break;
442 case 0x42: 442 case 0x42:
443 dprintk1(1,"attach_inform: saa7114 detected.\n"); 443 dprintk1(1,"attach_inform: saa7114 detected.\n");
@@ -453,7 +453,7 @@ static int attach_inform(struct i2c_client *client)
453 { 453 {
454 struct IR_i2c *ir = i2c_get_clientdata(client); 454 struct IR_i2c *ir = i2c_get_clientdata(client);
455 dprintk1(1,"attach_inform: IR detected (%s).\n",ir->phys); 455 dprintk1(1,"attach_inform: IR detected (%s).\n",ir->phys);
456 em2820_set_ir(dev,ir); 456 em28xx_set_ir(dev,ir);
457 break; 457 break;
458 } 458 }
459 case 0x80: 459 case 0x80:
@@ -467,19 +467,19 @@ static int attach_inform(struct i2c_client *client)
467 default: 467 default:
468 dprintk1(1,"attach inform: detected I2C address %x\n", client->addr << 1); 468 dprintk1(1,"attach inform: detected I2C address %x\n", client->addr << 1);
469 dev->tuner_addr = client->addr; 469 dev->tuner_addr = client->addr;
470 em2820_set_tuner(-1, client); 470 em28xx_set_tuner(-1, client);
471 } 471 }
472 472
473 return 0; 473 return 0;
474} 474}
475 475
476static struct i2c_algorithm em2820_algo = { 476static struct i2c_algorithm em28xx_algo = {
477 .master_xfer = em2820_i2c_xfer, 477 .master_xfer = em28xx_i2c_xfer,
478 .algo_control = algo_control, 478 .algo_control = algo_control,
479 .functionality = functionality, 479 .functionality = functionality,
480}; 480};
481 481
482static struct i2c_adapter em2820_adap_template = { 482static struct i2c_adapter em28xx_adap_template = {
483#ifdef I2C_PEC 483#ifdef I2C_PEC
484 .owner = THIS_MODULE, 484 .owner = THIS_MODULE,
485#else 485#else
@@ -489,14 +489,14 @@ static struct i2c_adapter em2820_adap_template = {
489#ifdef I2C_CLASS_TV_ANALOG 489#ifdef I2C_CLASS_TV_ANALOG
490 .class = I2C_CLASS_TV_ANALOG, 490 .class = I2C_CLASS_TV_ANALOG,
491#endif 491#endif
492 .name = "em2820", 492 .name = "em28xx",
493 .id = I2C_HW_B_EM2820, 493 .id = I2C_HW_B_EM28XX,
494 .algo = &em2820_algo, 494 .algo = &em28xx_algo,
495 .client_register = attach_inform, 495 .client_register = attach_inform,
496}; 496};
497 497
498static struct i2c_client em2820_client_template = { 498static struct i2c_client em28xx_client_template = {
499 .name = "em2820 internal", 499 .name = "em28xx internal",
500 .flags = I2C_CLIENT_ALLOW_USE, 500 .flags = I2C_CLIENT_ALLOW_USE,
501}; 501};
502 502
@@ -542,33 +542,33 @@ static void do_i2c_scan(char *name, struct i2c_client *c)
542} 542}
543 543
544/* 544/*
545 * em2820_i2c_call_clients() 545 * em28xx_i2c_call_clients()
546 * send commands to all attached i2c devices 546 * send commands to all attached i2c devices
547 */ 547 */
548void em2820_i2c_call_clients(struct em2820 *dev, unsigned int cmd, void *arg) 548void em28xx_i2c_call_clients(struct em28xx *dev, unsigned int cmd, void *arg)
549{ 549{
550 BUG_ON(NULL == dev->i2c_adap.algo_data); 550 BUG_ON(NULL == dev->i2c_adap.algo_data);
551 i2c_clients_command(&dev->i2c_adap, cmd, arg); 551 i2c_clients_command(&dev->i2c_adap, cmd, arg);
552} 552}
553 553
554/* 554/*
555 * em2820_i2c_register() 555 * em28xx_i2c_register()
556 * register i2c bus 556 * register i2c bus
557 */ 557 */
558int em2820_i2c_register(struct em2820 *dev) 558int em28xx_i2c_register(struct em28xx *dev)
559{ 559{
560 BUG_ON(!dev->em2820_write_regs || !dev->em2820_read_reg); 560 BUG_ON(!dev->em28xx_write_regs || !dev->em28xx_read_reg);
561 BUG_ON(!dev->em2820_write_regs_req || !dev->em2820_read_reg_req); 561 BUG_ON(!dev->em28xx_write_regs_req || !dev->em28xx_read_reg_req);
562 dev->i2c_adap = em2820_adap_template; 562 dev->i2c_adap = em28xx_adap_template;
563 dev->i2c_adap.dev.parent = &dev->udev->dev; 563 dev->i2c_adap.dev.parent = &dev->udev->dev;
564 strcpy(dev->i2c_adap.name, dev->name); 564 strcpy(dev->i2c_adap.name, dev->name);
565 dev->i2c_adap.algo_data = dev; 565 dev->i2c_adap.algo_data = dev;
566 i2c_add_adapter(&dev->i2c_adap); 566 i2c_add_adapter(&dev->i2c_adap);
567 567
568 dev->i2c_client = em2820_client_template; 568 dev->i2c_client = em28xx_client_template;
569 dev->i2c_client.adapter = &dev->i2c_adap; 569 dev->i2c_client.adapter = &dev->i2c_adap;
570 570
571 em2820_i2c_eeprom(dev, dev->eedata, sizeof(dev->eedata)); 571 em28xx_i2c_eeprom(dev, dev->eedata, sizeof(dev->eedata));
572 572
573 if (i2c_scan) 573 if (i2c_scan)
574 do_i2c_scan(dev->name, &dev->i2c_client); 574 do_i2c_scan(dev->name, &dev->i2c_client);
@@ -576,10 +576,10 @@ int em2820_i2c_register(struct em2820 *dev)
576} 576}
577 577
578/* 578/*
579 * em2820_i2c_unregister() 579 * em28xx_i2c_unregister()
580 * unregister i2c_bus 580 * unregister i2c_bus
581 */ 581 */
582int em2820_i2c_unregister(struct em2820 *dev) 582int em28xx_i2c_unregister(struct em28xx *dev)
583{ 583{
584 i2c_del_adapter(&dev->i2c_adap); 584 i2c_del_adapter(&dev->i2c_adap);
585 return 0; 585 return 0;
diff --git a/drivers/media/video/em28xx/em28xx-input.c b/drivers/media/video/em28xx/em28xx-input.c
index be7ba9b24d0d..32c49df58adc 100644
--- a/drivers/media/video/em28xx/em28xx-input.c
+++ b/drivers/media/video/em28xx/em28xx-input.c
@@ -142,7 +142,7 @@ static int get_key_em_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
142} 142}
143 143
144/* ----------------------------------------------------------------------- */ 144/* ----------------------------------------------------------------------- */
145void em2820_set_ir(struct em2820 * dev,struct IR_i2c *ir) 145void em28xx_set_ir(struct em28xx * dev,struct IR_i2c *ir)
146{ 146{
147 if (disable_ir) { 147 if (disable_ir) {
148 ir->get_key=NULL; 148 ir->get_key=NULL;
@@ -159,7 +159,7 @@ void em2820_set_ir(struct em2820 * dev,struct IR_i2c *ir)
159 case (EM2820_BOARD_TERRATEC_CINERGY_250): 159 case (EM2820_BOARD_TERRATEC_CINERGY_250):
160 ir->ir_codes = ir_codes_em_terratec; 160 ir->ir_codes = ir_codes_em_terratec;
161 ir->get_key = get_key_terratec; 161 ir->get_key = get_key_terratec;
162 snprintf(ir->c.name, sizeof(ir->c.name), "i2c IR (EM2820 Terratec)"); 162 snprintf(ir->c.name, sizeof(ir->c.name), "i2c IR (EM28XX Terratec)");
163 break; 163 break;
164 case (EM2820_BOARD_PINNACLE_USB_2): 164 case (EM2820_BOARD_PINNACLE_USB_2):
165 break; 165 break;
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index 5ae896a1dcf6..f6acce820791 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -28,6 +28,7 @@
28#include <linux/usb.h> 28#include <linux/usb.h>
29#include <linux/i2c.h> 29#include <linux/i2c.h>
30#include <linux/video_decoder.h> 30#include <linux/video_decoder.h>
31#include <linux/utsname.h>
31 32
32#include "em28xx.h" 33#include "em28xx.h"
33#include <media/tuner.h> 34#include <media/tuner.h>
@@ -39,9 +40,9 @@
39 40
40#define DRIVER_NAME "em28xx" 41#define DRIVER_NAME "em28xx"
41#define DRIVER_DESC "Empia em28xx based USB video device driver" 42#define DRIVER_DESC "Empia em28xx based USB video device driver"
42#define EM2820_VERSION_CODE KERNEL_VERSION(0, 0, 1) 43#define EM28XX_VERSION_CODE KERNEL_VERSION(0, 0, 1)
43 44
44#define em2820_videodbg(fmt, arg...) do {\ 45#define em28xx_videodbg(fmt, arg...) do {\
45 if (video_debug) \ 46 if (video_debug) \
46 printk(KERN_INFO "%s %s :"fmt, \ 47 printk(KERN_INFO "%s %s :"fmt, \
47 dev->name, __FUNCTION__ , ##arg); } while (0) 48 dev->name, __FUNCTION__ , ##arg); } while (0)
@@ -50,9 +51,9 @@ MODULE_AUTHOR(DRIVER_AUTHOR);
50MODULE_DESCRIPTION(DRIVER_DESC); 51MODULE_DESCRIPTION(DRIVER_DESC);
51MODULE_LICENSE("GPL"); 52MODULE_LICENSE("GPL");
52 53
53static LIST_HEAD(em2820_devlist); 54static LIST_HEAD(em28xx_devlist);
54 55
55static unsigned int card[] = {[0 ... (EM2820_MAXBOARDS - 1)] = UNSET }; 56static unsigned int card[] = {[0 ... (EM28XX_MAXBOARDS - 1)] = UNSET };
56 57
57module_param_array(card, int, NULL, 0444); 58module_param_array(card, int, NULL, 0444);
58MODULE_PARM_DESC(card,"card type"); 59MODULE_PARM_DESC(card,"card type");
@@ -66,7 +67,7 @@ module_param(video_debug,int,0644);
66MODULE_PARM_DESC(video_debug,"enable debug messages [video]"); 67MODULE_PARM_DESC(video_debug,"enable debug messages [video]");
67 68
68/* supported tv norms */ 69/* supported tv norms */
69static struct em2820_tvnorm tvnorms[] = { 70static struct em28xx_tvnorm tvnorms[] = {
70 { 71 {
71 .name = "PAL", 72 .name = "PAL",
72 .id = V4L2_STD_PAL, 73 .id = V4L2_STD_PAL,
@@ -106,7 +107,7 @@ static const unsigned char saa7114_i2c_init[] = {
106#define TVNORMS ARRAY_SIZE(tvnorms) 107#define TVNORMS ARRAY_SIZE(tvnorms)
107 108
108/* supported controls */ 109/* supported controls */
109static struct v4l2_queryctrl em2820_qctrl[] = { 110static struct v4l2_queryctrl em28xx_qctrl[] = {
110 { 111 {
111 .id = V4L2_CID_BRIGHTNESS, 112 .id = V4L2_CID_BRIGHTNESS,
112 .type = V4L2_CTRL_TYPE_INTEGER, 113 .type = V4L2_CTRL_TYPE_INTEGER,
@@ -182,10 +183,10 @@ static struct v4l2_queryctrl em2820_qctrl[] = {
182 } 183 }
183}; 184};
184 185
185static struct usb_driver em2820_usb_driver; 186static struct usb_driver em28xx_usb_driver;
186 187
187static DECLARE_MUTEX(em2820_sysfs_lock); 188static DECLARE_MUTEX(em28xx_sysfs_lock);
188static DECLARE_RWSEM(em2820_disconnect); 189static DECLARE_RWSEM(em28xx_disconnect);
189 190
190/********************* v4l2 interface ******************************************/ 191/********************* v4l2 interface ******************************************/
191 192
@@ -200,95 +201,95 @@ static inline unsigned long kvirt_to_pa(unsigned long adr)
200} 201}
201 202
202/* 203/*
203 * em2820_config() 204 * em28xx_config()
204 * inits registers with sane defaults 205 * inits registers with sane defaults
205 */ 206 */
206static int em2820_config(struct em2820 *dev) 207static int em28xx_config(struct em28xx *dev)
207{ 208{
208 209
209 /* Sets I2C speed to 100 KHz */ 210 /* Sets I2C speed to 100 KHz */
210 em2820_write_regs_req(dev, 0x00, 0x06, "\x40", 1); 211 em28xx_write_regs_req(dev, 0x00, 0x06, "\x40", 1);
211 212
212 /* enable vbi capturing */ 213 /* enable vbi capturing */
213 em2820_audio_usb_mute(dev, 1); 214 em28xx_audio_usb_mute(dev, 1);
214 dev->mute = 1; /* maybe not the right place... */ 215 dev->mute = 1; /* maybe not the right place... */
215 dev->volume = 0x1f; 216 dev->volume = 0x1f;
216 em2820_audio_analog_set(dev); 217 em28xx_audio_analog_set(dev);
217 em2820_audio_analog_setup(dev); 218 em28xx_audio_analog_setup(dev);
218 em2820_outfmt_set_yuv422(dev); 219 em28xx_outfmt_set_yuv422(dev);
219 em2820_colorlevels_set_default(dev); 220 em28xx_colorlevels_set_default(dev);
220 em2820_compression_disable(dev); 221 em28xx_compression_disable(dev);
221 222
222 return 0; 223 return 0;
223} 224}
224 225
225/* 226/*
226 * em2820_config_i2c() 227 * em28xx_config_i2c()
227 * configure i2c attached devices 228 * configure i2c attached devices
228 */ 229 */
229void em2820_config_i2c(struct em2820 *dev) 230void em28xx_config_i2c(struct em28xx *dev)
230{ 231{
231 struct v4l2_frequency f; 232 struct v4l2_frequency f;
232 struct video_decoder_init em2820_vdi = {.data = NULL }; 233 struct video_decoder_init em28xx_vdi = {.data = NULL };
233 234
234 235
235 /* configure decoder */ 236 /* configure decoder */
236 if(dev->model == EM2820_BOARD_MSI_VOX_USB_2){ 237 if(dev->model == EM2820_BOARD_MSI_VOX_USB_2){
237 em2820_vdi.data=saa7114_i2c_init; 238 em28xx_vdi.data=saa7114_i2c_init;
238 em2820_vdi.len=sizeof(saa7114_i2c_init); 239 em28xx_vdi.len=sizeof(saa7114_i2c_init);
239 } 240 }
240 241
241 242
242 em2820_i2c_call_clients(dev, DECODER_INIT, &em2820_vdi); 243 em28xx_i2c_call_clients(dev, DECODER_INIT, &em28xx_vdi);
243 em2820_i2c_call_clients(dev, DECODER_SET_INPUT, &dev->ctl_input); 244 em28xx_i2c_call_clients(dev, DECODER_SET_INPUT, &dev->ctl_input);
244/* em2820_i2c_call_clients(dev,DECODER_SET_PICTURE, &dev->vpic); */ 245/* em28xx_i2c_call_clients(dev,DECODER_SET_PICTURE, &dev->vpic); */
245/* em2820_i2c_call_clients(dev,DECODER_SET_NORM,&dev->tvnorm->id); */ 246/* em28xx_i2c_call_clients(dev,DECODER_SET_NORM,&dev->tvnorm->id); */
246/* em2820_i2c_call_clients(dev,DECODER_ENABLE_OUTPUT,&output); */ 247/* em28xx_i2c_call_clients(dev,DECODER_ENABLE_OUTPUT,&output); */
247/* em2820_i2c_call_clients(dev,DECODER_DUMP, NULL); */ 248/* em28xx_i2c_call_clients(dev,DECODER_DUMP, NULL); */
248 249
249 /* configure tuner */ 250 /* configure tuner */
250 f.tuner = 0; 251 f.tuner = 0;
251 f.type = V4L2_TUNER_ANALOG_TV; 252 f.type = V4L2_TUNER_ANALOG_TV;
252 f.frequency = 9076; /* FIXME:remove magic number */ 253 f.frequency = 9076; /* FIXME:remove magic number */
253 dev->ctl_freq = f.frequency; 254 dev->ctl_freq = f.frequency;
254 em2820_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, &f); 255 em28xx_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, &f);
255 256
256 /* configure tda9887 */ 257 /* configure tda9887 */
257 258
258 259
259/* em2820_i2c_call_clients(dev,VIDIOC_S_STD,&dev->tvnorm->id); */ 260/* em28xx_i2c_call_clients(dev,VIDIOC_S_STD,&dev->tvnorm->id); */
260} 261}
261 262
262/* 263/*
263 * em2820_empty_framequeues() 264 * em28xx_empty_framequeues()
264 * prepare queues for incoming and outgoing frames 265 * prepare queues for incoming and outgoing frames
265 */ 266 */
266static void em2820_empty_framequeues(struct em2820 *dev) 267static void em28xx_empty_framequeues(struct em28xx *dev)
267{ 268{
268 u32 i; 269 u32 i;
269 270
270 INIT_LIST_HEAD(&dev->inqueue); 271 INIT_LIST_HEAD(&dev->inqueue);
271 INIT_LIST_HEAD(&dev->outqueue); 272 INIT_LIST_HEAD(&dev->outqueue);
272 273
273 for (i = 0; i < EM2820_NUM_FRAMES; i++) { 274 for (i = 0; i < EM28XX_NUM_FRAMES; i++) {
274 dev->frame[i].state = F_UNUSED; 275 dev->frame[i].state = F_UNUSED;
275 dev->frame[i].buf.bytesused = 0; 276 dev->frame[i].buf.bytesused = 0;
276 } 277 }
277} 278}
278 279
279/* 280/*
280 * em2820_v4l2_open() 281 * em28xx_v4l2_open()
281 * inits the device and starts isoc transfer 282 * inits the device and starts isoc transfer
282 */ 283 */
283static int em2820_v4l2_open(struct inode *inode, struct file *filp) 284static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
284{ 285{
285 int minor = iminor(inode); 286 int minor = iminor(inode);
286 int errCode = 0; 287 int errCode = 0;
287 struct em2820 *h,*dev = NULL; 288 struct em28xx *h,*dev = NULL;
288 struct list_head *list; 289 struct list_head *list;
289 290
290 list_for_each(list,&em2820_devlist) { 291 list_for_each(list,&em28xx_devlist) {
291 h = list_entry(list, struct em2820, devlist); 292 h = list_entry(list, struct em28xx, devlist);
292 if (h->vdev->minor == minor) { 293 if (h->vdev->minor == minor) {
293 dev = h; 294 dev = h;
294 } 295 }
@@ -297,14 +298,14 @@ static int em2820_v4l2_open(struct inode *inode, struct file *filp)
297 filp->private_data=dev; 298 filp->private_data=dev;
298 299
299 300
300 em2820_videodbg("users=%d", dev->users); 301 em28xx_videodbg("users=%d", dev->users);
301 302
302 if (!down_read_trylock(&em2820_disconnect)) 303 if (!down_read_trylock(&em28xx_disconnect))
303 return -ERESTARTSYS; 304 return -ERESTARTSYS;
304 305
305 if (dev->users) { 306 if (dev->users) {
306 em2820_warn("this driver can be opened only once\n"); 307 em28xx_warn("this driver can be opened only once\n");
307 up_read(&em2820_disconnect); 308 up_read(&em28xx_disconnect);
308 return -EBUSY; 309 return -EBUSY;
309 } 310 }
310 311
@@ -322,7 +323,7 @@ static int em2820_v4l2_open(struct inode *inode, struct file *filp)
322 323
323 down(&dev->lock); 324 down(&dev->lock);
324 325
325 em2820_set_alternate(dev); 326 em28xx_set_alternate(dev);
326 327
327 dev->width = norm_maxw(dev); 328 dev->width = norm_maxw(dev);
328 dev->height = norm_maxh(dev); 329 dev->height = norm_maxh(dev);
@@ -332,11 +333,11 @@ static int em2820_v4l2_open(struct inode *inode, struct file *filp)
332 dev->hscale = 0; 333 dev->hscale = 0;
333 dev->vscale = 0; 334 dev->vscale = 0;
334 335
335 em2820_capture_start(dev, 1); 336 em28xx_capture_start(dev, 1);
336 em2820_resolution_set(dev); 337 em28xx_resolution_set(dev);
337 338
338 /* start the transfer */ 339 /* start the transfer */
339 errCode = em2820_init_isoc(dev); 340 errCode = em28xx_init_isoc(dev);
340 if (errCode) 341 if (errCode)
341 goto err; 342 goto err;
342 343
@@ -347,55 +348,55 @@ static int em2820_v4l2_open(struct inode *inode, struct file *filp)
347 dev->num_frames = 0; 348 dev->num_frames = 0;
348 349
349 /* prepare queues */ 350 /* prepare queues */
350 em2820_empty_framequeues(dev); 351 em28xx_empty_framequeues(dev);
351 352
352 dev->state |= DEV_INITIALIZED; 353 dev->state |= DEV_INITIALIZED;
353 354
354 err: 355 err:
355 up(&dev->lock); 356 up(&dev->lock);
356 up_read(&em2820_disconnect); 357 up_read(&em28xx_disconnect);
357 return errCode; 358 return errCode;
358} 359}
359 360
360/* 361/*
361 * em2820_realease_resources() 362 * em28xx_realease_resources()
362 * unregisters the v4l2,i2c and usb devices 363 * unregisters the v4l2,i2c and usb devices
363 * called when the device gets disconected or at module unload 364 * called when the device gets disconected or at module unload
364*/ 365*/
365static void em2820_release_resources(struct em2820 *dev) 366static void em28xx_release_resources(struct em28xx *dev)
366{ 367{
367 down(&em2820_sysfs_lock); 368 down(&em28xx_sysfs_lock);
368 369
369 em2820_info("V4L2 device /dev/video%d deregistered\n", 370 em28xx_info("V4L2 device /dev/video%d deregistered\n",
370 dev->vdev->minor); 371 dev->vdev->minor);
371 list_del(&dev->devlist); 372 list_del(&dev->devlist);
372 video_unregister_device(dev->vdev); 373 video_unregister_device(dev->vdev);
373/* video_unregister_device(dev->vbi_dev); */ 374/* video_unregister_device(dev->vbi_dev); */
374 em2820_i2c_unregister(dev); 375 em28xx_i2c_unregister(dev);
375 usb_put_dev(dev->udev); 376 usb_put_dev(dev->udev);
376 up(&em2820_sysfs_lock); 377 up(&em28xx_sysfs_lock);
377} 378}
378 379
379/* 380/*
380 * em2820_v4l2_close() 381 * em28xx_v4l2_close()
381 * stops streaming and deallocates all resources allocated by the v4l2 calls and ioctls 382 * stops streaming and deallocates all resources allocated by the v4l2 calls and ioctls
382 */ 383 */
383static int em2820_v4l2_close(struct inode *inode, struct file *filp) 384static int em28xx_v4l2_close(struct inode *inode, struct file *filp)
384{ 385{
385 int errCode; 386 int errCode;
386 struct em2820 *dev=filp->private_data; 387 struct em28xx *dev=filp->private_data;
387 388
388 em2820_videodbg("users=%d", dev->users); 389 em28xx_videodbg("users=%d", dev->users);
389 390
390 down(&dev->lock); 391 down(&dev->lock);
391 392
392 em2820_uninit_isoc(dev); 393 em28xx_uninit_isoc(dev);
393 394
394 em2820_release_buffers(dev); 395 em28xx_release_buffers(dev);
395 396
396 /* the device is already disconnect, free the remaining resources */ 397 /* the device is already disconnect, free the remaining resources */
397 if (dev->state & DEV_DISCONNECTED) { 398 if (dev->state & DEV_DISCONNECTED) {
398 em2820_release_resources(dev); 399 em28xx_release_resources(dev);
399 up(&dev->lock); 400 up(&dev->lock);
400 kfree(dev); 401 kfree(dev);
401 return 0; 402 return 0;
@@ -403,10 +404,10 @@ static int em2820_v4l2_close(struct inode *inode, struct file *filp)
403 404
404 /* set alternate 0 */ 405 /* set alternate 0 */
405 dev->alt = 0; 406 dev->alt = 0;
406 em2820_videodbg("setting alternate 0"); 407 em28xx_videodbg("setting alternate 0");
407 errCode = usb_set_interface(dev->udev, 0, 0); 408 errCode = usb_set_interface(dev->udev, 0, 0);
408 if (errCode < 0) { 409 if (errCode < 0) {
409 em2820_errdev ("cannot change alternate number to 0 (error=%i)\n", 410 em28xx_errdev ("cannot change alternate number to 0 (error=%i)\n",
410 errCode); 411 errCode);
411 } 412 }
412 413
@@ -417,49 +418,49 @@ static int em2820_v4l2_close(struct inode *inode, struct file *filp)
417} 418}
418 419
419/* 420/*
420 * em2820_v4l2_read() 421 * em28xx_v4l2_read()
421 * will allocate buffers when called for the first time 422 * will allocate buffers when called for the first time
422 */ 423 */
423static ssize_t 424static ssize_t
424em2820_v4l2_read(struct file *filp, char __user * buf, size_t count, 425em28xx_v4l2_read(struct file *filp, char __user * buf, size_t count,
425 loff_t * f_pos) 426 loff_t * f_pos)
426{ 427{
427 struct em2820_frame_t *f, *i; 428 struct em28xx_frame_t *f, *i;
428 unsigned long lock_flags; 429 unsigned long lock_flags;
429 int ret = 0; 430 int ret = 0;
430 struct em2820 *dev = filp->private_data; 431 struct em28xx *dev = filp->private_data;
431 432
432 if (down_interruptible(&dev->fileop_lock)) 433 if (down_interruptible(&dev->fileop_lock))
433 return -ERESTARTSYS; 434 return -ERESTARTSYS;
434 435
435 if (dev->state & DEV_DISCONNECTED) { 436 if (dev->state & DEV_DISCONNECTED) {
436 em2820_videodbg("device not present"); 437 em28xx_videodbg("device not present");
437 up(&dev->fileop_lock); 438 up(&dev->fileop_lock);
438 return -ENODEV; 439 return -ENODEV;
439 } 440 }
440 441
441 if (dev->state & DEV_MISCONFIGURED) { 442 if (dev->state & DEV_MISCONFIGURED) {
442 em2820_videodbg("device misconfigured; close and open it again"); 443 em28xx_videodbg("device misconfigured; close and open it again");
443 up(&dev->fileop_lock); 444 up(&dev->fileop_lock);
444 return -EIO; 445 return -EIO;
445 } 446 }
446 447
447 if (dev->io == IO_MMAP) { 448 if (dev->io == IO_MMAP) {
448 em2820_videodbg ("IO method is set to mmap; close and open" 449 em28xx_videodbg ("IO method is set to mmap; close and open"
449 " the device again to choose the read method"); 450 " the device again to choose the read method");
450 up(&dev->fileop_lock); 451 up(&dev->fileop_lock);
451 return -EINVAL; 452 return -EINVAL;
452 } 453 }
453 454
454 if (dev->io == IO_NONE) { 455 if (dev->io == IO_NONE) {
455 if (!em2820_request_buffers(dev, EM2820_NUM_READ_FRAMES)) { 456 if (!em28xx_request_buffers(dev, EM28XX_NUM_READ_FRAMES)) {
456 em2820_errdev("read failed, not enough memory\n"); 457 em28xx_errdev("read failed, not enough memory\n");
457 up(&dev->fileop_lock); 458 up(&dev->fileop_lock);
458 return -ENOMEM; 459 return -ENOMEM;
459 } 460 }
460 dev->io = IO_READ; 461 dev->io = IO_READ;
461 dev->stream = STREAM_ON; 462 dev->stream = STREAM_ON;
462 em2820_queue_unusedframes(dev); 463 em28xx_queue_unusedframes(dev);
463 } 464 }
464 465
465 if (!count) { 466 if (!count) {
@@ -486,7 +487,7 @@ em2820_v4l2_read(struct file *filp, char __user * buf, size_t count,
486 } 487 }
487 } 488 }
488 489
489 f = list_entry(dev->outqueue.prev, struct em2820_frame_t, frame); 490 f = list_entry(dev->outqueue.prev, struct em28xx_frame_t, frame);
490 491
491 spin_lock_irqsave(&dev->queue_lock, lock_flags); 492 spin_lock_irqsave(&dev->queue_lock, lock_flags);
492 list_for_each_entry(i, &dev->outqueue, frame) 493 list_for_each_entry(i, &dev->outqueue, frame)
@@ -494,7 +495,7 @@ em2820_v4l2_read(struct file *filp, char __user * buf, size_t count,
494 INIT_LIST_HEAD(&dev->outqueue); 495 INIT_LIST_HEAD(&dev->outqueue);
495 spin_unlock_irqrestore(&dev->queue_lock, lock_flags); 496 spin_unlock_irqrestore(&dev->queue_lock, lock_flags);
496 497
497 em2820_queue_unusedframes(dev); 498 em28xx_queue_unusedframes(dev);
498 499
499 if (count > f->buf.length) 500 if (count > f->buf.length)
500 count = f->buf.length; 501 count = f->buf.length;
@@ -511,26 +512,26 @@ em2820_v4l2_read(struct file *filp, char __user * buf, size_t count,
511} 512}
512 513
513/* 514/*
514 * em2820_v4l2_poll() 515 * em28xx_v4l2_poll()
515 * will allocate buffers when called for the first time 516 * will allocate buffers when called for the first time
516 */ 517 */
517static unsigned int em2820_v4l2_poll(struct file *filp, poll_table * wait) 518static unsigned int em28xx_v4l2_poll(struct file *filp, poll_table * wait)
518{ 519{
519 unsigned int mask = 0; 520 unsigned int mask = 0;
520 struct em2820 *dev = filp->private_data; 521 struct em28xx *dev = filp->private_data;
521 522
522 if (down_interruptible(&dev->fileop_lock)) 523 if (down_interruptible(&dev->fileop_lock))
523 return POLLERR; 524 return POLLERR;
524 525
525 if (dev->state & DEV_DISCONNECTED) { 526 if (dev->state & DEV_DISCONNECTED) {
526 em2820_videodbg("device not present"); 527 em28xx_videodbg("device not present");
527 } else if (dev->state & DEV_MISCONFIGURED) { 528 } else if (dev->state & DEV_MISCONFIGURED) {
528 em2820_videodbg("device is misconfigured; close and open it again"); 529 em28xx_videodbg("device is misconfigured; close and open it again");
529 } else { 530 } else {
530 if (dev->io == IO_NONE) { 531 if (dev->io == IO_NONE) {
531 if (!em2820_request_buffers 532 if (!em28xx_request_buffers
532 (dev, EM2820_NUM_READ_FRAMES)) { 533 (dev, EM28XX_NUM_READ_FRAMES)) {
533 em2820_warn 534 em28xx_warn
534 ("poll() failed, not enough memory\n"); 535 ("poll() failed, not enough memory\n");
535 } else { 536 } else {
536 dev->io = IO_READ; 537 dev->io = IO_READ;
@@ -539,7 +540,7 @@ static unsigned int em2820_v4l2_poll(struct file *filp, poll_table * wait)
539 } 540 }
540 541
541 if (dev->io == IO_READ) { 542 if (dev->io == IO_READ) {
542 em2820_queue_unusedframes(dev); 543 em28xx_queue_unusedframes(dev);
543 poll_wait(filp, &dev->wait_frame, wait); 544 poll_wait(filp, &dev->wait_frame, wait);
544 545
545 if (!list_empty(&dev->outqueue)) 546 if (!list_empty(&dev->outqueue))
@@ -556,51 +557,51 @@ static unsigned int em2820_v4l2_poll(struct file *filp, poll_table * wait)
556} 557}
557 558
558/* 559/*
559 * em2820_vm_open() 560 * em28xx_vm_open()
560 */ 561 */
561static void em2820_vm_open(struct vm_area_struct *vma) 562static void em28xx_vm_open(struct vm_area_struct *vma)
562{ 563{
563 struct em2820_frame_t *f = vma->vm_private_data; 564 struct em28xx_frame_t *f = vma->vm_private_data;
564 f->vma_use_count++; 565 f->vma_use_count++;
565} 566}
566 567
567/* 568/*
568 * em2820_vm_close() 569 * em28xx_vm_close()
569 */ 570 */
570static void em2820_vm_close(struct vm_area_struct *vma) 571static void em28xx_vm_close(struct vm_area_struct *vma)
571{ 572{
572 /* NOTE: buffers are not freed here */ 573 /* NOTE: buffers are not freed here */
573 struct em2820_frame_t *f = vma->vm_private_data; 574 struct em28xx_frame_t *f = vma->vm_private_data;
574 f->vma_use_count--; 575 f->vma_use_count--;
575} 576}
576 577
577static struct vm_operations_struct em2820_vm_ops = { 578static struct vm_operations_struct em28xx_vm_ops = {
578 .open = em2820_vm_open, 579 .open = em28xx_vm_open,
579 .close = em2820_vm_close, 580 .close = em28xx_vm_close,
580}; 581};
581 582
582/* 583/*
583 * em2820_v4l2_mmap() 584 * em28xx_v4l2_mmap()
584 */ 585 */
585static int em2820_v4l2_mmap(struct file *filp, struct vm_area_struct *vma) 586static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma)
586{ 587{
587 unsigned long size = vma->vm_end - vma->vm_start, 588 unsigned long size = vma->vm_end - vma->vm_start,
588 start = vma->vm_start, pos, page; 589 start = vma->vm_start, pos, page;
589 u32 i; 590 u32 i;
590 591
591 struct em2820 *dev = filp->private_data; 592 struct em28xx *dev = filp->private_data;
592 593
593 if (down_interruptible(&dev->fileop_lock)) 594 if (down_interruptible(&dev->fileop_lock))
594 return -ERESTARTSYS; 595 return -ERESTARTSYS;
595 596
596 if (dev->state & DEV_DISCONNECTED) { 597 if (dev->state & DEV_DISCONNECTED) {
597 em2820_videodbg("mmap: device not present"); 598 em28xx_videodbg("mmap: device not present");
598 up(&dev->fileop_lock); 599 up(&dev->fileop_lock);
599 return -ENODEV; 600 return -ENODEV;
600 } 601 }
601 602
602 if (dev->state & DEV_MISCONFIGURED) { 603 if (dev->state & DEV_MISCONFIGURED) {
603 em2820_videodbg ("mmap: Device is misconfigured; close and " 604 em28xx_videodbg ("mmap: Device is misconfigured; close and "
604 "open it again"); 605 "open it again");
605 up(&dev->fileop_lock); 606 up(&dev->fileop_lock);
606 return -EIO; 607 return -EIO;
@@ -617,7 +618,7 @@ static int em2820_v4l2_mmap(struct file *filp, struct vm_area_struct *vma)
617 break; 618 break;
618 } 619 }
619 if (i == dev->num_frames) { 620 if (i == dev->num_frames) {
620 em2820_videodbg("mmap: user supplied mapping address is out of range"); 621 em28xx_videodbg("mmap: user supplied mapping address is out of range");
621 up(&dev->fileop_lock); 622 up(&dev->fileop_lock);
622 return -EINVAL; 623 return -EINVAL;
623 } 624 }
@@ -631,7 +632,7 @@ static int em2820_v4l2_mmap(struct file *filp, struct vm_area_struct *vma)
631 page = vmalloc_to_pfn((void *)pos); 632 page = vmalloc_to_pfn((void *)pos);
632 if (remap_pfn_range(vma, start, page, PAGE_SIZE, 633 if (remap_pfn_range(vma, start, page, PAGE_SIZE,
633 vma->vm_page_prot)) { 634 vma->vm_page_prot)) {
634 em2820_videodbg("mmap: rename page map failed"); 635 em28xx_videodbg("mmap: rename page map failed");
635 up(&dev->fileop_lock); 636 up(&dev->fileop_lock);
636 return -EAGAIN; 637 return -EAGAIN;
637 } 638 }
@@ -640,19 +641,19 @@ static int em2820_v4l2_mmap(struct file *filp, struct vm_area_struct *vma)
640 size -= PAGE_SIZE; 641 size -= PAGE_SIZE;
641 } 642 }
642 643
643 vma->vm_ops = &em2820_vm_ops; 644 vma->vm_ops = &em28xx_vm_ops;
644 vma->vm_private_data = &dev->frame[i]; 645 vma->vm_private_data = &dev->frame[i];
645 646
646 em2820_vm_open(vma); 647 em28xx_vm_open(vma);
647 up(&dev->fileop_lock); 648 up(&dev->fileop_lock);
648 return 0; 649 return 0;
649} 650}
650 651
651/* 652/*
652 * em2820_get_ctrl() 653 * em28xx_get_ctrl()
653 * return the current saturation, brightness or contrast, mute state 654 * return the current saturation, brightness or contrast, mute state
654 */ 655 */
655static int em2820_get_ctrl(struct em2820 *dev, struct v4l2_control *ctrl) 656static int em28xx_get_ctrl(struct em28xx *dev, struct v4l2_control *ctrl)
656{ 657{
657 s32 tmp; 658 s32 tmp;
658 switch (ctrl->id) { 659 switch (ctrl->id) {
@@ -663,30 +664,30 @@ static int em2820_get_ctrl(struct em2820 *dev, struct v4l2_control *ctrl)
663 ctrl->value = dev->volume; 664 ctrl->value = dev->volume;
664 return 0; 665 return 0;
665 case V4L2_CID_BRIGHTNESS: 666 case V4L2_CID_BRIGHTNESS:
666 if ((tmp = em2820_brightness_get(dev)) < 0) 667 if ((tmp = em28xx_brightness_get(dev)) < 0)
667 return -EIO; 668 return -EIO;
668 ctrl->value = (s32) ((s8) tmp); /* FIXME: clenaer way to extend sign? */ 669 ctrl->value = (s32) ((s8) tmp); /* FIXME: clenaer way to extend sign? */
669 return 0; 670 return 0;
670 case V4L2_CID_CONTRAST: 671 case V4L2_CID_CONTRAST:
671 if ((ctrl->value = em2820_contrast_get(dev)) < 0) 672 if ((ctrl->value = em28xx_contrast_get(dev)) < 0)
672 return -EIO; 673 return -EIO;
673 return 0; 674 return 0;
674 case V4L2_CID_SATURATION: 675 case V4L2_CID_SATURATION:
675 if ((ctrl->value = em2820_saturation_get(dev)) < 0) 676 if ((ctrl->value = em28xx_saturation_get(dev)) < 0)
676 return -EIO; 677 return -EIO;
677 return 0; 678 return 0;
678 case V4L2_CID_RED_BALANCE: 679 case V4L2_CID_RED_BALANCE:
679 if ((tmp = em2820_v_balance_get(dev)) < 0) 680 if ((tmp = em28xx_v_balance_get(dev)) < 0)
680 return -EIO; 681 return -EIO;
681 ctrl->value = (s32) ((s8) tmp); /* FIXME: clenaer way to extend sign? */ 682 ctrl->value = (s32) ((s8) tmp); /* FIXME: clenaer way to extend sign? */
682 return 0; 683 return 0;
683 case V4L2_CID_BLUE_BALANCE: 684 case V4L2_CID_BLUE_BALANCE:
684 if ((tmp = em2820_u_balance_get(dev)) < 0) 685 if ((tmp = em28xx_u_balance_get(dev)) < 0)
685 return -EIO; 686 return -EIO;
686 ctrl->value = (s32) ((s8) tmp); /* FIXME: clenaer way to extend sign? */ 687 ctrl->value = (s32) ((s8) tmp); /* FIXME: clenaer way to extend sign? */
687 return 0; 688 return 0;
688 case V4L2_CID_GAMMA: 689 case V4L2_CID_GAMMA:
689 if ((ctrl->value = em2820_gamma_get(dev)) < 0) 690 if ((ctrl->value = em28xx_gamma_get(dev)) < 0)
690 return -EIO; 691 return -EIO;
691 return 0; 692 return 0;
692 default: 693 default:
@@ -695,44 +696,44 @@ static int em2820_get_ctrl(struct em2820 *dev, struct v4l2_control *ctrl)
695} 696}
696 697
697/* 698/*
698 * em2820_set_ctrl() 699 * em28xx_set_ctrl()
699 * mute or set new saturation, brightness or contrast 700 * mute or set new saturation, brightness or contrast
700 */ 701 */
701static int em2820_set_ctrl(struct em2820 *dev, const struct v4l2_control *ctrl) 702static int em28xx_set_ctrl(struct em28xx *dev, const struct v4l2_control *ctrl)
702{ 703{
703 switch (ctrl->id) { 704 switch (ctrl->id) {
704 case V4L2_CID_AUDIO_MUTE: 705 case V4L2_CID_AUDIO_MUTE:
705 if (ctrl->value != dev->mute) { 706 if (ctrl->value != dev->mute) {
706 dev->mute = ctrl->value; 707 dev->mute = ctrl->value;
707 em2820_audio_usb_mute(dev, ctrl->value); 708 em28xx_audio_usb_mute(dev, ctrl->value);
708 return em2820_audio_analog_set(dev); 709 return em28xx_audio_analog_set(dev);
709 } 710 }
710 return 0; 711 return 0;
711 case V4L2_CID_AUDIO_VOLUME: 712 case V4L2_CID_AUDIO_VOLUME:
712 dev->volume = ctrl->value; 713 dev->volume = ctrl->value;
713 return em2820_audio_analog_set(dev); 714 return em28xx_audio_analog_set(dev);
714 case V4L2_CID_BRIGHTNESS: 715 case V4L2_CID_BRIGHTNESS:
715 return em2820_brightness_set(dev, ctrl->value); 716 return em28xx_brightness_set(dev, ctrl->value);
716 case V4L2_CID_CONTRAST: 717 case V4L2_CID_CONTRAST:
717 return em2820_contrast_set(dev, ctrl->value); 718 return em28xx_contrast_set(dev, ctrl->value);
718 case V4L2_CID_SATURATION: 719 case V4L2_CID_SATURATION:
719 return em2820_saturation_set(dev, ctrl->value); 720 return em28xx_saturation_set(dev, ctrl->value);
720 case V4L2_CID_RED_BALANCE: 721 case V4L2_CID_RED_BALANCE:
721 return em2820_v_balance_set(dev, ctrl->value); 722 return em28xx_v_balance_set(dev, ctrl->value);
722 case V4L2_CID_BLUE_BALANCE: 723 case V4L2_CID_BLUE_BALANCE:
723 return em2820_u_balance_set(dev, ctrl->value); 724 return em28xx_u_balance_set(dev, ctrl->value);
724 case V4L2_CID_GAMMA: 725 case V4L2_CID_GAMMA:
725 return em2820_gamma_set(dev, ctrl->value); 726 return em28xx_gamma_set(dev, ctrl->value);
726 default: 727 default:
727 return -EINVAL; 728 return -EINVAL;
728 } 729 }
729} 730}
730 731
731/* 732/*
732 * em2820_stream_interrupt() 733 * em28xx_stream_interrupt()
733 * stops streaming 734 * stops streaming
734 */ 735 */
735static int em2820_stream_interrupt(struct em2820 *dev) 736static int em28xx_stream_interrupt(struct em28xx *dev)
736{ 737{
737 int ret = 0; 738 int ret = 0;
738 739
@@ -742,12 +743,12 @@ static int em2820_stream_interrupt(struct em2820 *dev)
742 ret = wait_event_timeout(dev->wait_stream, 743 ret = wait_event_timeout(dev->wait_stream,
743 (dev->stream == STREAM_OFF) || 744 (dev->stream == STREAM_OFF) ||
744 (dev->state & DEV_DISCONNECTED), 745 (dev->state & DEV_DISCONNECTED),
745 EM2820_URB_TIMEOUT); 746 EM28XX_URB_TIMEOUT);
746 if (dev->state & DEV_DISCONNECTED) 747 if (dev->state & DEV_DISCONNECTED)
747 return -ENODEV; 748 return -ENODEV;
748 else if (ret) { 749 else if (ret) {
749 dev->state |= DEV_MISCONFIGURED; 750 dev->state |= DEV_MISCONFIGURED;
750 em2820_videodbg("device is misconfigured; close and " 751 em28xx_videodbg("device is misconfigured; close and "
751 "open /dev/video%d again", dev->vdev->minor); 752 "open /dev/video%d again", dev->vdev->minor);
752 return ret; 753 return ret;
753 } 754 }
@@ -755,7 +756,7 @@ static int em2820_stream_interrupt(struct em2820 *dev)
755 return 0; 756 return 0;
756} 757}
757 758
758static int em2820_set_norm(struct em2820 *dev, int width, int height) 759static int em28xx_set_norm(struct em28xx *dev, int width, int height)
759{ 760{
760 unsigned int hscale, vscale; 761 unsigned int hscale, vscale;
761 unsigned int maxh, maxw; 762 unsigned int maxh, maxw;
@@ -794,41 +795,41 @@ static int em2820_set_norm(struct em2820 *dev, int width, int height)
794 dev->hscale = hscale; 795 dev->hscale = hscale;
795 dev->vscale = vscale; 796 dev->vscale = vscale;
796 797
797 em2820_resolution_set(dev); 798 em28xx_resolution_set(dev);
798 799
799 return 0; 800 return 0;
800} 801}
801 802
802static void video_mux(struct em2820 *dev, int index) 803static void video_mux(struct em28xx *dev, int index)
803{ 804{
804 int input, ainput; 805 int input, ainput;
805 806
806 input = INPUT(index)->vmux; 807 input = INPUT(index)->vmux;
807 dev->ctl_input = index; 808 dev->ctl_input = index;
808 809
809 em2820_i2c_call_clients(dev, DECODER_SET_INPUT, &input); 810 em28xx_i2c_call_clients(dev, DECODER_SET_INPUT, &input);
810 811
811 dev->ctl_ainput = INPUT(index)->amux; 812 dev->ctl_ainput = INPUT(index)->amux;
812 813
813 switch (dev->ctl_ainput) { 814 switch (dev->ctl_ainput) {
814 case 0: 815 case 0:
815 ainput = EM2820_AUDIO_SRC_TUNER; 816 ainput = EM28XX_AUDIO_SRC_TUNER;
816 break; 817 break;
817 default: 818 default:
818 ainput = EM2820_AUDIO_SRC_LINE; 819 ainput = EM28XX_AUDIO_SRC_LINE;
819 } 820 }
820 821
821 em2820_audio_source(dev, ainput); 822 em28xx_audio_source(dev, ainput);
822} 823}
823 824
824/* 825/*
825 * em2820_v4l2_do_ioctl() 826 * em28xx_v4l2_do_ioctl()
826 * This function is _not_ called directly, but from 827 * This function is _not_ called directly, but from
827 * em2820_v4l2_ioctl. Userspace 828 * em28xx_v4l2_ioctl. Userspace
828 * copying is done already, arg is a kernel pointer. 829 * copying is done already, arg is a kernel pointer.
829 */ 830 */
830static int em2820_do_ioctl(struct inode *inode, struct file *filp, 831static int em28xx_do_ioctl(struct inode *inode, struct file *filp,
831 struct em2820 *dev, unsigned int cmd, void *arg, 832 struct em28xx *dev, unsigned int cmd, void *arg,
832 v4l2_kioctl driver_ioctl) 833 v4l2_kioctl driver_ioctl)
833{ 834{
834 int ret; 835 int ret;
@@ -875,7 +876,7 @@ static int em2820_do_ioctl(struct inode *inode, struct file *filp,
875 down(&dev->lock); 876 down(&dev->lock);
876 dev->tvnorm = &tvnorms[i]; 877 dev->tvnorm = &tvnorms[i];
877 878
878 em2820_set_norm(dev, dev->width, dev->height); 879 em28xx_set_norm(dev, dev->width, dev->height);
879 880
880/* 881/*
881 dev->width=norm_maxw(dev); 882 dev->width=norm_maxw(dev);
@@ -886,18 +887,18 @@ static int em2820_do_ioctl(struct inode *inode, struct file *filp,
886 dev->hscale=0; 887 dev->hscale=0;
887 dev->vscale=0; 888 dev->vscale=0;
888 889
889 em2820_resolution_set(dev); 890 em28xx_resolution_set(dev);
890*/ 891*/
891/* 892/*
892 em2820_uninit_isoc(dev); 893 em28xx_uninit_isoc(dev);
893 em2820_set_alternate(dev); 894 em28xx_set_alternate(dev);
894 em2820_capture_start(dev, 1); 895 em28xx_capture_start(dev, 1);
895 em2820_resolution_set(dev); 896 em28xx_resolution_set(dev);
896 em2820_init_isoc(dev); 897 em28xx_init_isoc(dev);
897*/ 898*/
898 em2820_i2c_call_clients(dev, DECODER_SET_NORM, 899 em28xx_i2c_call_clients(dev, DECODER_SET_NORM,
899 &tvnorms[i].mode); 900 &tvnorms[i].mode);
900 em2820_i2c_call_clients(dev, VIDIOC_S_STD, 901 em28xx_i2c_call_clients(dev, VIDIOC_S_STD,
901 &dev->tvnorm->id); 902 &dev->tvnorm->id);
902 903
903 up(&dev->lock); 904 up(&dev->lock);
@@ -911,19 +912,19 @@ static int em2820_do_ioctl(struct inode *inode, struct file *filp,
911 struct v4l2_input *i = arg; 912 struct v4l2_input *i = arg;
912 unsigned int n; 913 unsigned int n;
913 static const char *iname[] = { 914 static const char *iname[] = {
914 [EM2820_VMUX_COMPOSITE1] = "Composite1", 915 [EM28XX_VMUX_COMPOSITE1] = "Composite1",
915 [EM2820_VMUX_COMPOSITE2] = "Composite2", 916 [EM28XX_VMUX_COMPOSITE2] = "Composite2",
916 [EM2820_VMUX_COMPOSITE3] = "Composite3", 917 [EM28XX_VMUX_COMPOSITE3] = "Composite3",
917 [EM2820_VMUX_COMPOSITE4] = "Composite4", 918 [EM28XX_VMUX_COMPOSITE4] = "Composite4",
918 [EM2820_VMUX_SVIDEO] = "S-Video", 919 [EM28XX_VMUX_SVIDEO] = "S-Video",
919 [EM2820_VMUX_TELEVISION] = "Television", 920 [EM28XX_VMUX_TELEVISION] = "Television",
920 [EM2820_VMUX_CABLE] = "Cable TV", 921 [EM28XX_VMUX_CABLE] = "Cable TV",
921 [EM2820_VMUX_DVB] = "DVB", 922 [EM28XX_VMUX_DVB] = "DVB",
922 [EM2820_VMUX_DEBUG] = "for debug only", 923 [EM28XX_VMUX_DEBUG] = "for debug only",
923 }; 924 };
924 925
925 n = i->index; 926 n = i->index;
926 if (n >= MAX_EM2820_INPUT) 927 if (n >= MAX_EM28XX_INPUT)
927 return -EINVAL; 928 return -EINVAL;
928 if (0 == INPUT(n)->type) 929 if (0 == INPUT(n)->type)
929 return -EINVAL; 930 return -EINVAL;
@@ -931,8 +932,8 @@ static int em2820_do_ioctl(struct inode *inode, struct file *filp,
931 i->index = n; 932 i->index = n;
932 i->type = V4L2_INPUT_TYPE_CAMERA; 933 i->type = V4L2_INPUT_TYPE_CAMERA;
933 strcpy(i->name, iname[INPUT(n)->type]); 934 strcpy(i->name, iname[INPUT(n)->type]);
934 if ((EM2820_VMUX_TELEVISION == INPUT(n)->type) || 935 if ((EM28XX_VMUX_TELEVISION == INPUT(n)->type) ||
935 (EM2820_VMUX_CABLE == INPUT(n)->type)) 936 (EM28XX_VMUX_CABLE == INPUT(n)->type))
936 i->type = V4L2_INPUT_TYPE_TUNER; 937 i->type = V4L2_INPUT_TYPE_TUNER;
937 for (n = 0; n < ARRAY_SIZE(tvnorms); n++) 938 for (n = 0; n < ARRAY_SIZE(tvnorms); n++)
938 i->std |= tvnorms[n].id; 939 i->std |= tvnorms[n].id;
@@ -951,7 +952,7 @@ static int em2820_do_ioctl(struct inode *inode, struct file *filp,
951 { 952 {
952 int *index = arg; 953 int *index = arg;
953 954
954 if (*index >= MAX_EM2820_INPUT) 955 if (*index >= MAX_EM28XX_INPUT)
955 return -EINVAL; 956 return -EINVAL;
956 if (0 == INPUT(*index)->type) 957 if (0 == INPUT(*index)->type)
957 return -EINVAL; 958 return -EINVAL;
@@ -997,10 +998,10 @@ static int em2820_do_ioctl(struct inode *inode, struct file *filp,
997 { 998 {
998 struct v4l2_queryctrl *qc = arg; 999 struct v4l2_queryctrl *qc = arg;
999 u8 i, n; 1000 u8 i, n;
1000 n = sizeof(em2820_qctrl) / sizeof(em2820_qctrl[0]); 1001 n = sizeof(em28xx_qctrl) / sizeof(em28xx_qctrl[0]);
1001 for (i = 0; i < n; i++) 1002 for (i = 0; i < n; i++)
1002 if (qc->id && qc->id == em2820_qctrl[i].id) { 1003 if (qc->id && qc->id == em28xx_qctrl[i].id) {
1003 memcpy(qc, &(em2820_qctrl[i]), 1004 memcpy(qc, &(em28xx_qctrl[i]),
1004 sizeof(*qc)); 1005 sizeof(*qc));
1005 return 0; 1006 return 0;
1006 } 1007 }
@@ -1013,7 +1014,7 @@ static int em2820_do_ioctl(struct inode *inode, struct file *filp,
1013 struct v4l2_control *ctrl = arg; 1014 struct v4l2_control *ctrl = arg;
1014 1015
1015 1016
1016 return em2820_get_ctrl(dev, ctrl); 1017 return em28xx_get_ctrl(dev, ctrl);
1017 } 1018 }
1018 1019
1019 case VIDIOC_S_CTRL_OLD: /* ??? */ 1020 case VIDIOC_S_CTRL_OLD: /* ??? */
@@ -1023,16 +1024,16 @@ static int em2820_do_ioctl(struct inode *inode, struct file *filp,
1023 u8 i, n; 1024 u8 i, n;
1024 1025
1025 1026
1026 n = sizeof(em2820_qctrl) / sizeof(em2820_qctrl[0]); 1027 n = sizeof(em28xx_qctrl) / sizeof(em28xx_qctrl[0]);
1027 for (i = 0; i < n; i++) 1028 for (i = 0; i < n; i++)
1028 if (ctrl->id == em2820_qctrl[i].id) { 1029 if (ctrl->id == em28xx_qctrl[i].id) {
1029 if (ctrl->value < 1030 if (ctrl->value <
1030 em2820_qctrl[i].minimum 1031 em28xx_qctrl[i].minimum
1031 || ctrl->value > 1032 || ctrl->value >
1032 em2820_qctrl[i].maximum) 1033 em28xx_qctrl[i].maximum)
1033 return -ERANGE; 1034 return -ERANGE;
1034 1035
1035 return em2820_set_ctrl(dev, ctrl); 1036 return em28xx_set_ctrl(dev, ctrl);
1036 } 1037 }
1037 return -EINVAL; 1038 return -EINVAL;
1038 } 1039 }
@@ -1052,16 +1053,16 @@ static int em2820_do_ioctl(struct inode *inode, struct file *filp,
1052 t->capability = V4L2_TUNER_CAP_NORM; 1053 t->capability = V4L2_TUNER_CAP_NORM;
1053 t->rangehigh = 0xffffffffUL; /* FIXME: set correct range */ 1054 t->rangehigh = 0xffffffffUL; /* FIXME: set correct range */
1054/* t->signal = 0xffff;*/ 1055/* t->signal = 0xffff;*/
1055/* em2820_i2c_call_clients(dev,VIDIOC_G_TUNER,t);*/ 1056/* em28xx_i2c_call_clients(dev,VIDIOC_G_TUNER,t);*/
1056 /* No way to get signal strength? */ 1057 /* No way to get signal strength? */
1057 down(&dev->lock); 1058 down(&dev->lock);
1058 em2820_i2c_call_clients(dev, DECODER_GET_STATUS, 1059 em28xx_i2c_call_clients(dev, DECODER_GET_STATUS,
1059 &status); 1060 &status);
1060 up(&dev->lock); 1061 up(&dev->lock);
1061 t->signal = 1062 t->signal =
1062 (status & DECODER_STATUS_GOOD) != 0 ? 0xffff : 0; 1063 (status & DECODER_STATUS_GOOD) != 0 ? 0xffff : 0;
1063 1064
1064 em2820_videodbg("VIDIO_G_TUNER: signal=%x, afc=%x", t->signal, 1065 em28xx_videodbg("VIDIO_G_TUNER: signal=%x, afc=%x", t->signal,
1065 t->afc); 1066 t->afc);
1066 return 0; 1067 return 0;
1067 } 1068 }
@@ -1080,13 +1081,13 @@ static int em2820_do_ioctl(struct inode *inode, struct file *filp,
1080/* t->signal = 0xffff; */ 1081/* t->signal = 0xffff; */
1081 /* No way to get signal strength? */ 1082 /* No way to get signal strength? */
1082 down(&dev->lock); 1083 down(&dev->lock);
1083 em2820_i2c_call_clients(dev, DECODER_GET_STATUS, 1084 em28xx_i2c_call_clients(dev, DECODER_GET_STATUS,
1084 &status); 1085 &status);
1085 up(&dev->lock); 1086 up(&dev->lock);
1086 t->signal = 1087 t->signal =
1087 (status & DECODER_STATUS_GOOD) != 0 ? 0xffff : 0; 1088 (status & DECODER_STATUS_GOOD) != 0 ? 0xffff : 0;
1088 1089
1089 em2820_videodbg("VIDIO_S_TUNER: signal=%x, afc=%x\n", 1090 em28xx_videodbg("VIDIO_S_TUNER: signal=%x, afc=%x\n",
1090 t->signal, t->afc); 1091 t->signal, t->afc);
1091 return 0; 1092 return 0;
1092 } 1093 }
@@ -1112,7 +1113,7 @@ static int em2820_do_ioctl(struct inode *inode, struct file *filp,
1112 1113
1113 down(&dev->lock); 1114 down(&dev->lock);
1114 dev->ctl_freq = f->frequency; 1115 dev->ctl_freq = f->frequency;
1115 em2820_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, f); 1116 em28xx_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, f);
1116 up(&dev->lock); 1117 up(&dev->lock);
1117 return 0; 1118 return 0;
1118 } 1119 }
@@ -1145,7 +1146,7 @@ static int em2820_do_ioctl(struct inode *inode, struct file *filp,
1145 1146
1146 dev->stream = STREAM_ON; /* FIXME: Start video capture here? */ 1147 dev->stream = STREAM_ON; /* FIXME: Start video capture here? */
1147 1148
1148 em2820_videodbg("VIDIOC_STREAMON: starting stream"); 1149 em28xx_videodbg("VIDIOC_STREAMON: starting stream");
1149 1150
1150 return 0; 1151 return 0;
1151 } 1152 }
@@ -1159,11 +1160,11 @@ static int em2820_do_ioctl(struct inode *inode, struct file *filp,
1159 return -EINVAL; 1160 return -EINVAL;
1160 1161
1161 if (dev->stream == STREAM_ON) { 1162 if (dev->stream == STREAM_ON) {
1162 em2820_videodbg ("VIDIOC_STREAMOFF: interrupting stream"); 1163 em28xx_videodbg ("VIDIOC_STREAMOFF: interrupting stream");
1163 if ((ret = em2820_stream_interrupt(dev))) 1164 if ((ret = em28xx_stream_interrupt(dev)))
1164 return ret; 1165 return ret;
1165 } 1166 }
1166 em2820_empty_framequeues(dev); 1167 em28xx_empty_framequeues(dev);
1167 1168
1168 return 0; 1169 return 0;
1169 } 1170 }
@@ -1175,21 +1176,21 @@ static int em2820_do_ioctl(struct inode *inode, struct file *filp,
1175} 1176}
1176 1177
1177/* 1178/*
1178 * em2820_v4l2_do_ioctl() 1179 * em28xx_v4l2_do_ioctl()
1179 * This function is _not_ called directly, but from 1180 * This function is _not_ called directly, but from
1180 * em2820_v4l2_ioctl. Userspace 1181 * em28xx_v4l2_ioctl. Userspace
1181 * copying is done already, arg is a kernel pointer. 1182 * copying is done already, arg is a kernel pointer.
1182 */ 1183 */
1183static int em2820_video_do_ioctl(struct inode *inode, struct file *filp, 1184static int em28xx_video_do_ioctl(struct inode *inode, struct file *filp,
1184 unsigned int cmd, void *arg) 1185 unsigned int cmd, void *arg)
1185{ 1186{
1186 struct em2820 *dev = filp->private_data; 1187 struct em28xx *dev = filp->private_data;
1187 1188
1188 if (!dev) 1189 if (!dev)
1189 return -ENODEV; 1190 return -ENODEV;
1190 1191
1191 if (video_debug > 1) 1192 if (video_debug > 1)
1192 em2820_print_ioctl(dev->name,cmd); 1193 em28xx_print_ioctl(dev->name,cmd);
1193 1194
1194 switch (cmd) { 1195 switch (cmd) {
1195 1196
@@ -1199,12 +1200,12 @@ static int em2820_video_do_ioctl(struct inode *inode, struct file *filp,
1199 struct v4l2_capability *cap = arg; 1200 struct v4l2_capability *cap = arg;
1200 1201
1201 memset(cap, 0, sizeof(*cap)); 1202 memset(cap, 0, sizeof(*cap));
1202 strlcpy(cap->driver, "em2820", sizeof(cap->driver)); 1203 strlcpy(cap->driver, "em28xx", sizeof(cap->driver));
1203 strlcpy(cap->card, em2820_boards[dev->model].name, 1204 strlcpy(cap->card, em28xx_boards[dev->model].name,
1204 sizeof(cap->card)); 1205 sizeof(cap->card));
1205 strlcpy(cap->bus_info, dev->udev->dev.bus_id, 1206 strlcpy(cap->bus_info, dev->udev->dev.bus_id,
1206 sizeof(cap->bus_info)); 1207 sizeof(cap->bus_info));
1207 cap->version = EM2820_VERSION_CODE; 1208 cap->version = EM28XX_VERSION_CODE;
1208 cap->capabilities = 1209 cap->capabilities =
1209 V4L2_CAP_VIDEO_CAPTURE | 1210 V4L2_CAP_VIDEO_CAPTURE |
1210 V4L2_CAP_AUDIO | 1211 V4L2_CAP_AUDIO |
@@ -1233,7 +1234,7 @@ static int em2820_video_do_ioctl(struct inode *inode, struct file *filp,
1233 { 1234 {
1234 struct v4l2_format *format = arg; 1235 struct v4l2_format *format = arg;
1235 1236
1236 em2820_videodbg("VIDIOC_G_FMT: type=%s", 1237 em28xx_videodbg("VIDIOC_G_FMT: type=%s",
1237 format->type == 1238 format->type ==
1238 V4L2_BUF_TYPE_VIDEO_CAPTURE ? 1239 V4L2_BUF_TYPE_VIDEO_CAPTURE ?
1239 "V4L2_BUF_TYPE_VIDEO_CAPTURE" : format->type == 1240 "V4L2_BUF_TYPE_VIDEO_CAPTURE" : format->type ==
@@ -1252,7 +1253,7 @@ static int em2820_video_do_ioctl(struct inode *inode, struct file *filp,
1252 format->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; 1253 format->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
1253 format->fmt.pix.field = dev->interlaced ? V4L2_FIELD_INTERLACED : V4L2_FIELD_TOP; /* FIXME: TOP? NONE? BOTTOM? ALTENATE? */ 1254 format->fmt.pix.field = dev->interlaced ? V4L2_FIELD_INTERLACED : V4L2_FIELD_TOP; /* FIXME: TOP? NONE? BOTTOM? ALTENATE? */
1254 1255
1255 em2820_videodbg("VIDIOC_G_FMT: %dx%d", dev->width, 1256 em28xx_videodbg("VIDIOC_G_FMT: %dx%d", dev->width,
1256 dev->height); 1257 dev->height);
1257 return 0; 1258 return 0;
1258 } 1259 }
@@ -1273,7 +1274,7 @@ static int em2820_video_do_ioctl(struct inode *inode, struct file *filp,
1273 1274
1274/* int both_fields; */ 1275/* int both_fields; */
1275 1276
1276 em2820_videodbg("%s: type=%s", 1277 em28xx_videodbg("%s: type=%s",
1277 cmd == 1278 cmd ==
1278 VIDIOC_TRY_FMT ? "VIDIOC_TRY_FMT" : 1279 VIDIOC_TRY_FMT ? "VIDIOC_TRY_FMT" :
1279 "VIDIOC_S_FMT", 1280 "VIDIOC_S_FMT",
@@ -1287,7 +1288,7 @@ static int em2820_video_do_ioctl(struct inode *inode, struct file *filp,
1287 if (format->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 1288 if (format->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1288 return -EINVAL; 1289 return -EINVAL;
1289 1290
1290 em2820_videodbg("%s: requested %dx%d", 1291 em28xx_videodbg("%s: requested %dx%d",
1291 cmd == 1292 cmd ==
1292 VIDIOC_TRY_FMT ? "VIDIOC_TRY_FMT" : 1293 VIDIOC_TRY_FMT ? "VIDIOC_TRY_FMT" :
1293 "VIDIOC_S_FMT", format->fmt.pix.width, 1294 "VIDIOC_S_FMT", format->fmt.pix.width,
@@ -1346,7 +1347,7 @@ static int em2820_video_do_ioctl(struct inode *inode, struct file *filp,
1346 format->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; 1347 format->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
1347 format->fmt.pix.field = V4L2_FIELD_INTERLACED; 1348 format->fmt.pix.field = V4L2_FIELD_INTERLACED;
1348 1349
1349 em2820_videodbg("%s: returned %dx%d (%d, %d)", 1350 em28xx_videodbg("%s: returned %dx%d (%d, %d)",
1350 cmd == 1351 cmd ==
1351 VIDIOC_TRY_FMT ? "VIDIOC_TRY_FMT" : 1352 VIDIOC_TRY_FMT ? "VIDIOC_TRY_FMT" :
1352 "VIDIOC_S_FMT", format->fmt.pix.width, 1353 "VIDIOC_S_FMT", format->fmt.pix.width,
@@ -1357,19 +1358,19 @@ static int em2820_video_do_ioctl(struct inode *inode, struct file *filp,
1357 1358
1358 for (i = 0; i < dev->num_frames; i++) 1359 for (i = 0; i < dev->num_frames; i++)
1359 if (dev->frame[i].vma_use_count) { 1360 if (dev->frame[i].vma_use_count) {
1360 em2820_videodbg("VIDIOC_S_FMT failed. " 1361 em28xx_videodbg("VIDIOC_S_FMT failed. "
1361 "Unmap the buffers first."); 1362 "Unmap the buffers first.");
1362 return -EINVAL; 1363 return -EINVAL;
1363 } 1364 }
1364 1365
1365 /* stop io in case it is already in progress */ 1366 /* stop io in case it is already in progress */
1366 if (dev->stream == STREAM_ON) { 1367 if (dev->stream == STREAM_ON) {
1367 em2820_videodbg("VIDIOC_SET_FMT: interupting stream"); 1368 em28xx_videodbg("VIDIOC_SET_FMT: interupting stream");
1368 if ((ret = em2820_stream_interrupt(dev))) 1369 if ((ret = em28xx_stream_interrupt(dev)))
1369 return ret; 1370 return ret;
1370 } 1371 }
1371 1372
1372 em2820_release_buffers(dev); 1373 em28xx_release_buffers(dev);
1373 dev->io = IO_NONE; 1374 dev->io = IO_NONE;
1374 1375
1375 /* set new image size */ 1376 /* set new image size */
@@ -1381,11 +1382,11 @@ static int em2820_video_do_ioctl(struct inode *inode, struct file *filp,
1381 dev->hscale = hscale; 1382 dev->hscale = hscale;
1382 dev->vscale = vscale; 1383 dev->vscale = vscale;
1383/* dev->both_fileds = both_fileds; */ 1384/* dev->both_fileds = both_fileds; */
1384 em2820_uninit_isoc(dev); 1385 em28xx_uninit_isoc(dev);
1385 em2820_set_alternate(dev); 1386 em28xx_set_alternate(dev);
1386 em2820_capture_start(dev, 1); 1387 em28xx_capture_start(dev, 1);
1387 em2820_resolution_set(dev); 1388 em28xx_resolution_set(dev);
1388 em2820_init_isoc(dev); 1389 em28xx_init_isoc(dev);
1389 1390
1390 return 0; 1391 return 0;
1391 } 1392 }
@@ -1402,7 +1403,7 @@ static int em2820_video_do_ioctl(struct inode *inode, struct file *filp,
1402 return -EINVAL; 1403 return -EINVAL;
1403 1404
1404 if (dev->io == IO_READ) { 1405 if (dev->io == IO_READ) {
1405 em2820_videodbg ("method is set to read;" 1406 em28xx_videodbg ("method is set to read;"
1406 " close and open the device again to" 1407 " close and open the device again to"
1407 " choose the mmap I/O method"); 1408 " choose the mmap I/O method");
1408 return -EINVAL; 1409 return -EINVAL;
@@ -1410,26 +1411,26 @@ static int em2820_video_do_ioctl(struct inode *inode, struct file *filp,
1410 1411
1411 for (i = 0; i < dev->num_frames; i++) 1412 for (i = 0; i < dev->num_frames; i++)
1412 if (dev->frame[i].vma_use_count) { 1413 if (dev->frame[i].vma_use_count) {
1413 em2820_videodbg ("VIDIOC_REQBUFS failed; previous buffers are still mapped"); 1414 em28xx_videodbg ("VIDIOC_REQBUFS failed; previous buffers are still mapped");
1414 return -EINVAL; 1415 return -EINVAL;
1415 } 1416 }
1416 1417
1417 if (dev->stream == STREAM_ON) { 1418 if (dev->stream == STREAM_ON) {
1418 em2820_videodbg("VIDIOC_REQBUFS: interrupting stream"); 1419 em28xx_videodbg("VIDIOC_REQBUFS: interrupting stream");
1419 if ((ret = em2820_stream_interrupt(dev))) 1420 if ((ret = em28xx_stream_interrupt(dev)))
1420 return ret; 1421 return ret;
1421 } 1422 }
1422 1423
1423 em2820_empty_framequeues(dev); 1424 em28xx_empty_framequeues(dev);
1424 1425
1425 em2820_release_buffers(dev); 1426 em28xx_release_buffers(dev);
1426 if (rb->count) 1427 if (rb->count)
1427 rb->count = 1428 rb->count =
1428 em2820_request_buffers(dev, rb->count); 1429 em28xx_request_buffers(dev, rb->count);
1429 1430
1430 dev->frame_current = NULL; 1431 dev->frame_current = NULL;
1431 1432
1432 em2820_videodbg ("VIDIOC_REQBUFS: setting io method to mmap: num bufs %i", 1433 em28xx_videodbg ("VIDIOC_REQBUFS: setting io method to mmap: num bufs %i",
1433 rb->count); 1434 rb->count);
1434 dev->io = rb->count ? IO_MMAP : IO_NONE; 1435 dev->io = rb->count ? IO_MMAP : IO_NONE;
1435 return 0; 1436 return 0;
@@ -1480,7 +1481,7 @@ static int em2820_video_do_ioctl(struct inode *inode, struct file *filp,
1480 case VIDIOC_DQBUF: 1481 case VIDIOC_DQBUF:
1481 { 1482 {
1482 struct v4l2_buffer *b = arg; 1483 struct v4l2_buffer *b = arg;
1483 struct em2820_frame_t *f; 1484 struct em28xx_frame_t *f;
1484 unsigned long lock_flags; 1485 unsigned long lock_flags;
1485 int ret = 0; 1486 int ret = 0;
1486 1487
@@ -1505,7 +1506,7 @@ static int em2820_video_do_ioctl(struct inode *inode, struct file *filp,
1505 1506
1506 spin_lock_irqsave(&dev->queue_lock, lock_flags); 1507 spin_lock_irqsave(&dev->queue_lock, lock_flags);
1507 f = list_entry(dev->outqueue.next, 1508 f = list_entry(dev->outqueue.next,
1508 struct em2820_frame_t, frame); 1509 struct em28xx_frame_t, frame);
1509 list_del(dev->outqueue.next); 1510 list_del(dev->outqueue.next);
1510 spin_unlock_irqrestore(&dev->queue_lock, lock_flags); 1511 spin_unlock_irqrestore(&dev->queue_lock, lock_flags);
1511 1512
@@ -1518,66 +1519,66 @@ static int em2820_video_do_ioctl(struct inode *inode, struct file *filp,
1518 return 0; 1519 return 0;
1519 } 1520 }
1520 default: 1521 default:
1521 return em2820_do_ioctl(inode, filp, dev, cmd, arg, 1522 return em28xx_do_ioctl(inode, filp, dev, cmd, arg,
1522 em2820_video_do_ioctl); 1523 em28xx_video_do_ioctl);
1523 } 1524 }
1524 return 0; 1525 return 0;
1525} 1526}
1526 1527
1527/* 1528/*
1528 * em2820_v4l2_ioctl() 1529 * em28xx_v4l2_ioctl()
1529 * handle v4l2 ioctl the main action happens in em2820_v4l2_do_ioctl() 1530 * handle v4l2 ioctl the main action happens in em28xx_v4l2_do_ioctl()
1530 */ 1531 */
1531static int em2820_v4l2_ioctl(struct inode *inode, struct file *filp, 1532static int em28xx_v4l2_ioctl(struct inode *inode, struct file *filp,
1532 unsigned int cmd, unsigned long arg) 1533 unsigned int cmd, unsigned long arg)
1533{ 1534{
1534 int ret = 0; 1535 int ret = 0;
1535 struct em2820 *dev = filp->private_data; 1536 struct em28xx *dev = filp->private_data;
1536 1537
1537 if (down_interruptible(&dev->fileop_lock)) 1538 if (down_interruptible(&dev->fileop_lock))
1538 return -ERESTARTSYS; 1539 return -ERESTARTSYS;
1539 1540
1540 if (dev->state & DEV_DISCONNECTED) { 1541 if (dev->state & DEV_DISCONNECTED) {
1541 em2820_errdev("v4l2 ioctl: device not present\n"); 1542 em28xx_errdev("v4l2 ioctl: device not present\n");
1542 up(&dev->fileop_lock); 1543 up(&dev->fileop_lock);
1543 return -ENODEV; 1544 return -ENODEV;
1544 } 1545 }
1545 1546
1546 if (dev->state & DEV_MISCONFIGURED) { 1547 if (dev->state & DEV_MISCONFIGURED) {
1547 em2820_errdev 1548 em28xx_errdev
1548 ("v4l2 ioctl: device is misconfigured; close and open it again\n"); 1549 ("v4l2 ioctl: device is misconfigured; close and open it again\n");
1549 up(&dev->fileop_lock); 1550 up(&dev->fileop_lock);
1550 return -EIO; 1551 return -EIO;
1551 } 1552 }
1552 1553
1553 ret = video_usercopy(inode, filp, cmd, arg, em2820_video_do_ioctl); 1554 ret = video_usercopy(inode, filp, cmd, arg, em28xx_video_do_ioctl);
1554 1555
1555 up(&dev->fileop_lock); 1556 up(&dev->fileop_lock);
1556 1557
1557 return ret; 1558 return ret;
1558} 1559}
1559 1560
1560static struct file_operations em2820_v4l_fops = { 1561static struct file_operations em28xx_v4l_fops = {
1561 .owner = THIS_MODULE, 1562 .owner = THIS_MODULE,
1562 .open = em2820_v4l2_open, 1563 .open = em28xx_v4l2_open,
1563 .release = em2820_v4l2_close, 1564 .release = em28xx_v4l2_close,
1564 .ioctl = em2820_v4l2_ioctl, 1565 .ioctl = em28xx_v4l2_ioctl,
1565 .read = em2820_v4l2_read, 1566 .read = em28xx_v4l2_read,
1566 .poll = em2820_v4l2_poll, 1567 .poll = em28xx_v4l2_poll,
1567 .mmap = em2820_v4l2_mmap, 1568 .mmap = em28xx_v4l2_mmap,
1568 .llseek = no_llseek, 1569 .llseek = no_llseek,
1569}; 1570};
1570 1571
1571/******************************** usb interface *****************************************/ 1572/******************************** usb interface *****************************************/
1572 1573
1573/* 1574/*
1574 * em2820_init_dev() 1575 * em28xx_init_dev()
1575 * allocates and inits the device structs, registers i2c bus and v4l device 1576 * allocates and inits the device structs, registers i2c bus and v4l device
1576 */ 1577 */
1577static int em2820_init_dev(struct em2820 **devhandle, struct usb_device *udev, 1578static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
1578 int minor, int model) 1579 int minor, int model)
1579{ 1580{
1580 struct em2820 *dev = *devhandle; 1581 struct em28xx *dev = *devhandle;
1581 int retval = -ENOMEM; 1582 int retval = -ENOMEM;
1582 int errCode, i; 1583 int errCode, i;
1583 unsigned int maxh, maxw; 1584 unsigned int maxh, maxw;
@@ -1588,33 +1589,33 @@ static int em2820_init_dev(struct em2820 **devhandle, struct usb_device *udev,
1588 init_MUTEX(&dev->lock); 1589 init_MUTEX(&dev->lock);
1589 init_waitqueue_head(&dev->open); 1590 init_waitqueue_head(&dev->open);
1590 1591
1591 dev->em2820_write_regs = em2820_write_regs; 1592 dev->em28xx_write_regs = em28xx_write_regs;
1592 dev->em2820_read_reg = em2820_read_reg; 1593 dev->em28xx_read_reg = em28xx_read_reg;
1593 dev->em2820_read_reg_req_len = em2820_read_reg_req_len; 1594 dev->em28xx_read_reg_req_len = em28xx_read_reg_req_len;
1594 dev->em2820_write_regs_req = em2820_write_regs_req; 1595 dev->em28xx_write_regs_req = em28xx_write_regs_req;
1595 dev->em2820_read_reg_req = em2820_read_reg_req; 1596 dev->em28xx_read_reg_req = em28xx_read_reg_req;
1596 dev->is_em2800 = em2820_boards[model].is_em2800; 1597 dev->is_em2800 = em28xx_boards[model].is_em2800;
1597 dev->has_tuner = em2820_boards[model].has_tuner; 1598 dev->has_tuner = em28xx_boards[model].has_tuner;
1598 dev->has_msp34xx = em2820_boards[model].has_msp34xx; 1599 dev->has_msp34xx = em28xx_boards[model].has_msp34xx;
1599 dev->tda9887_conf = em2820_boards[model].tda9887_conf; 1600 dev->tda9887_conf = em28xx_boards[model].tda9887_conf;
1600 dev->decoder = em2820_boards[model].decoder; 1601 dev->decoder = em28xx_boards[model].decoder;
1601 1602
1602 if (tuner >= 0) 1603 if (tuner >= 0)
1603 dev->tuner_type = tuner; 1604 dev->tuner_type = tuner;
1604 else 1605 else
1605 dev->tuner_type = em2820_boards[model].tuner_type; 1606 dev->tuner_type = em28xx_boards[model].tuner_type;
1606 1607
1607 dev->video_inputs = em2820_boards[model].vchannels; 1608 dev->video_inputs = em28xx_boards[model].vchannels;
1608 1609
1609 for (i = 0; i < TVNORMS; i++) 1610 for (i = 0; i < TVNORMS; i++)
1610 if (em2820_boards[model].norm == tvnorms[i].mode) 1611 if (em28xx_boards[model].norm == tvnorms[i].mode)
1611 break; 1612 break;
1612 if (i == TVNORMS) 1613 if (i == TVNORMS)
1613 i = 0; 1614 i = 0;
1614 1615
1615 dev->tvnorm = &tvnorms[i]; /* set default norm */ 1616 dev->tvnorm = &tvnorms[i]; /* set default norm */
1616 1617
1617 em2820_videodbg("tvnorm=%s\n", dev->tvnorm->name); 1618 em28xx_videodbg("tvnorm=%s\n", dev->tvnorm->name);
1618 1619
1619 maxw = norm_maxw(dev); 1620 maxw = norm_maxw(dev);
1620 maxh = norm_maxh(dev); 1621 maxh = norm_maxh(dev);
@@ -1622,7 +1623,7 @@ static int em2820_init_dev(struct em2820 **devhandle, struct usb_device *udev,
1622 /* set default image size */ 1623 /* set default image size */
1623 dev->width = maxw; 1624 dev->width = maxw;
1624 dev->height = maxh; 1625 dev->height = maxh;
1625 dev->interlaced = EM2820_INTERLACED_DEFAULT; 1626 dev->interlaced = EM28XX_INTERLACED_DEFAULT;
1626 dev->field_size = dev->width * dev->height; 1627 dev->field_size = dev->width * dev->height;
1627 dev->frame_size = 1628 dev->frame_size =
1628 dev->interlaced ? dev->field_size << 1 : dev->field_size; 1629 dev->interlaced ? dev->field_size << 1 : dev->field_size;
@@ -1644,7 +1645,7 @@ static int em2820_init_dev(struct em2820 **devhandle, struct usb_device *udev,
1644 /* compute alternate max packet sizes */ 1645 /* compute alternate max packet sizes */
1645 uif = dev->udev->actconfig->interface[0]; 1646 uif = dev->udev->actconfig->interface[0];
1646 dev->alt_max_pkt_size[0] = 0; 1647 dev->alt_max_pkt_size[0] = 0;
1647 for (i = 1; i <= EM2820_MAX_ALT && i < uif->num_altsetting ; i++) { 1648 for (i = 1; i <= EM28XX_MAX_ALT && i < uif->num_altsetting ; i++) {
1648 u16 tmp = 1649 u16 tmp =
1649 le16_to_cpu(uif->altsetting[i].endpoint[1].desc. 1650 le16_to_cpu(uif->altsetting[i].endpoint[1].desc.
1650 wMaxPacketSize); 1651 wMaxPacketSize);
@@ -1654,35 +1655,35 @@ static int em2820_init_dev(struct em2820 **devhandle, struct usb_device *udev,
1654 1655
1655#ifdef CONFIG_MODULES 1656#ifdef CONFIG_MODULES
1656 /* request some modules */ 1657 /* request some modules */
1657 if (dev->decoder == EM2820_SAA7113 || dev->decoder == EM2820_SAA7114) 1658 if (dev->decoder == EM28XX_SAA7113 || dev->decoder == EM28XX_SAA7114)
1658 request_module("saa711x"); 1659 request_module("saa711x");
1659 if (dev->decoder == EM2820_TVP5150) 1660 if (dev->decoder == EM28XX_TVP5150)
1660 request_module("tvp5150"); 1661 request_module("tvp5150");
1661 if (dev->has_tuner) 1662 if (dev->has_tuner)
1662 request_module("tuner"); 1663 request_module("tuner");
1663 if (dev->tda9887_conf) 1664 if (dev->tda9887_conf)
1664 request_module("tda9887"); 1665 request_module("tda9887");
1665#endif 1666#endif
1666 errCode = em2820_config(dev); 1667 errCode = em28xx_config(dev);
1667 if (errCode) { 1668 if (errCode) {
1668 em2820_errdev("error configuring device\n"); 1669 em28xx_errdev("error configuring device\n");
1669 kfree(dev); 1670 kfree(dev);
1670 return -ENOMEM; 1671 return -ENOMEM;
1671 } 1672 }
1672 1673
1673 down(&dev->lock); 1674 down(&dev->lock);
1674 /* register i2c bus */ 1675 /* register i2c bus */
1675 em2820_i2c_register(dev); 1676 em28xx_i2c_register(dev);
1676 1677
1677 /* Do board specific init and eeprom reading */ 1678 /* Do board specific init and eeprom reading */
1678 em2820_card_setup(dev); 1679 em28xx_card_setup(dev);
1679 1680
1680 /* configure the device */ 1681 /* configure the device */
1681 em2820_config_i2c(dev); 1682 em28xx_config_i2c(dev);
1682 1683
1683 up(&dev->lock); 1684 up(&dev->lock);
1684 1685
1685 errCode = em2820_config(dev); 1686 errCode = em28xx_config(dev);
1686 1687
1687#ifdef CONFIG_MODULES 1688#ifdef CONFIG_MODULES
1688 if (dev->has_msp34xx) 1689 if (dev->has_msp34xx)
@@ -1691,7 +1692,7 @@ static int em2820_init_dev(struct em2820 **devhandle, struct usb_device *udev,
1691 /* allocate and fill v4l2 device struct */ 1692 /* allocate and fill v4l2 device struct */
1692 dev->vdev = video_device_alloc(); 1693 dev->vdev = video_device_alloc();
1693 if (NULL == dev->vdev) { 1694 if (NULL == dev->vdev) {
1694 em2820_errdev("cannot allocate video_device.\n"); 1695 em28xx_errdev("cannot allocate video_device.\n");
1695 kfree(dev); 1696 kfree(dev);
1696 return -ENOMEM; 1697 return -ENOMEM;
1697 } 1698 }
@@ -1700,18 +1701,18 @@ static int em2820_init_dev(struct em2820 **devhandle, struct usb_device *udev,
1700 if (dev->has_tuner) 1701 if (dev->has_tuner)
1701 dev->vdev->type |= VID_TYPE_TUNER; 1702 dev->vdev->type |= VID_TYPE_TUNER;
1702 dev->vdev->hardware = 0; 1703 dev->vdev->hardware = 0;
1703 dev->vdev->fops = &em2820_v4l_fops; 1704 dev->vdev->fops = &em28xx_v4l_fops;
1704 dev->vdev->minor = -1; 1705 dev->vdev->minor = -1;
1705 dev->vdev->dev = &dev->udev->dev; 1706 dev->vdev->dev = &dev->udev->dev;
1706 dev->vdev->release = video_device_release; 1707 dev->vdev->release = video_device_release;
1707 snprintf(dev->vdev->name, sizeof(dev->vdev->name), "%s", 1708 snprintf(dev->vdev->name, sizeof(dev->vdev->name), "%s",
1708 "em2820 video"); 1709 "em28xx video");
1709 list_add_tail(&dev->devlist,&em2820_devlist); 1710 list_add_tail(&dev->devlist,&em28xx_devlist);
1710 1711
1711 /* register v4l2 device */ 1712 /* register v4l2 device */
1712 down(&dev->lock); 1713 down(&dev->lock);
1713 if ((retval = video_register_device(dev->vdev, VFL_TYPE_GRABBER, -1))) { 1714 if ((retval = video_register_device(dev->vdev, VFL_TYPE_GRABBER, -1))) {
1714 em2820_errdev("unable to register video device (error=%i).\n", 1715 em28xx_errdev("unable to register video device (error=%i).\n",
1715 retval); 1716 retval);
1716 up(&dev->lock); 1717 up(&dev->lock);
1717 list_del(&dev->devlist); 1718 list_del(&dev->devlist);
@@ -1721,9 +1722,9 @@ static int em2820_init_dev(struct em2820 **devhandle, struct usb_device *udev,
1721 } 1722 }
1722 if (dev->has_msp34xx) { 1723 if (dev->has_msp34xx) {
1723 /* Send a reset to other chips via gpio */ 1724 /* Send a reset to other chips via gpio */
1724 em2820_write_regs_req(dev, 0x00, 0x08, "\xf7", 1); 1725 em28xx_write_regs_req(dev, 0x00, 0x08, "\xf7", 1);
1725 udelay(2500); 1726 udelay(2500);
1726 em2820_write_regs_req(dev, 0x00, 0x08, "\xff", 1); 1727 em28xx_write_regs_req(dev, 0x00, 0x08, "\xff", 1);
1727 udelay(2500); 1728 udelay(2500);
1728 1729
1729 } 1730 }
@@ -1731,22 +1732,22 @@ static int em2820_init_dev(struct em2820 **devhandle, struct usb_device *udev,
1731 1732
1732 up(&dev->lock); 1733 up(&dev->lock);
1733 1734
1734 em2820_info("V4L2 device registered as /dev/video%d\n", 1735 em28xx_info("V4L2 device registered as /dev/video%d\n",
1735 dev->vdev->minor); 1736 dev->vdev->minor);
1736 1737
1737 return 0; 1738 return 0;
1738} 1739}
1739 1740
1740/* 1741/*
1741 * em2820_usb_probe() 1742 * em28xx_usb_probe()
1742 * checks for supported devices 1743 * checks for supported devices
1743 */ 1744 */
1744static int em2820_usb_probe(struct usb_interface *interface, 1745static int em28xx_usb_probe(struct usb_interface *interface,
1745 const struct usb_device_id *id) 1746 const struct usb_device_id *id)
1746{ 1747{
1747 const struct usb_endpoint_descriptor *endpoint; 1748 const struct usb_endpoint_descriptor *endpoint;
1748 struct usb_device *udev; 1749 struct usb_device *udev;
1749 struct em2820 *dev = NULL; 1750 struct em28xx *dev = NULL;
1750 int retval = -ENODEV; 1751 int retval = -ENODEV;
1751 int model,i,nr,ifnum; 1752 int model,i,nr,ifnum;
1752 1753
@@ -1756,14 +1757,14 @@ static int em2820_usb_probe(struct usb_interface *interface,
1756 1757
1757 /* Don't register audio interfaces */ 1758 /* Don't register audio interfaces */
1758 if (interface->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) { 1759 if (interface->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) {
1759 em2820_err(DRIVER_NAME " audio device (%04x:%04x): interface %i, class %i\n", 1760 em28xx_err(DRIVER_NAME " audio device (%04x:%04x): interface %i, class %i\n",
1760 udev->descriptor.idVendor,udev->descriptor.idProduct, 1761 udev->descriptor.idVendor,udev->descriptor.idProduct,
1761 ifnum, 1762 ifnum,
1762 interface->altsetting[0].desc.bInterfaceClass); 1763 interface->altsetting[0].desc.bInterfaceClass);
1763 return -ENODEV; 1764 return -ENODEV;
1764 } 1765 }
1765 1766
1766 em2820_err(DRIVER_NAME " new video device (%04x:%04x): interface %i, class %i\n", 1767 em28xx_err(DRIVER_NAME " new video device (%04x:%04x): interface %i, class %i\n",
1767 udev->descriptor.idVendor,udev->descriptor.idProduct, 1768 udev->descriptor.idVendor,udev->descriptor.idProduct,
1768 ifnum, 1769 ifnum,
1769 interface->altsetting[0].desc.bInterfaceClass); 1770 interface->altsetting[0].desc.bInterfaceClass);
@@ -1773,33 +1774,33 @@ static int em2820_usb_probe(struct usb_interface *interface,
1773 /* check if the the device has the iso in endpoint at the correct place */ 1774 /* check if the the device has the iso in endpoint at the correct place */
1774 if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != 1775 if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) !=
1775 USB_ENDPOINT_XFER_ISOC) { 1776 USB_ENDPOINT_XFER_ISOC) {
1776 em2820_err(DRIVER_NAME " probing error: endpoint is non-ISO endpoint!\n"); 1777 em28xx_err(DRIVER_NAME " probing error: endpoint is non-ISO endpoint!\n");
1777 return -ENODEV; 1778 return -ENODEV;
1778 } 1779 }
1779 if ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT) { 1780 if ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT) {
1780 em2820_err(DRIVER_NAME " probing error: endpoint is ISO OUT endpoint!\n"); 1781 em28xx_err(DRIVER_NAME " probing error: endpoint is ISO OUT endpoint!\n");
1781 return -ENODEV; 1782 return -ENODEV;
1782 } 1783 }
1783 1784
1784 model=id->driver_info; 1785 model=id->driver_info;
1785 nr=interface->minor; 1786 nr=interface->minor;
1786 1787
1787 if (nr>EM2820_MAXBOARDS) { 1788 if (nr>EM28XX_MAXBOARDS) {
1788 printk ("em2820: Supports only %i em28xx boards.\n",EM2820_MAXBOARDS); 1789 printk ("em28xx: Supports only %i em28xx boards.\n",EM28XX_MAXBOARDS);
1789 return -ENOMEM; 1790 return -ENOMEM;
1790 } 1791 }
1791 1792
1792 /* allocate memory for our device state and initialize it */ 1793 /* allocate memory for our device state and initialize it */
1793 dev = kmalloc(sizeof(*dev), GFP_KERNEL); 1794 dev = kmalloc(sizeof(*dev), GFP_KERNEL);
1794 if (dev == NULL) { 1795 if (dev == NULL) {
1795 em2820_err(DRIVER_NAME ": out of memory!\n"); 1796 em28xx_err(DRIVER_NAME ": out of memory!\n");
1796 return -ENOMEM; 1797 return -ENOMEM;
1797 } 1798 }
1798 memset(dev, 0, sizeof(*dev)); 1799 memset(dev, 0, sizeof(*dev));
1799 1800
1800 snprintf(dev->name, 29, "em2820 #%d", nr); 1801 snprintf(dev->name, 29, "em28xx #%d", nr);
1801 1802
1802 if ((card[nr]>=0)&&(card[nr]<em2820_bcount)) 1803 if ((card[nr]>=0)&&(card[nr]<em28xx_bcount))
1803 model=card[nr]; 1804 model=card[nr];
1804 1805
1805 if ((model==EM2800_BOARD_UNKNOWN)||(model==EM2820_BOARD_UNKNOWN)) { 1806 if ((model==EM2800_BOARD_UNKNOWN)||(model==EM2820_BOARD_UNKNOWN)) {
@@ -1811,18 +1812,18 @@ static int em2820_usb_probe(struct usb_interface *interface,
1811 dev->name,dev->name,dev->name,dev->name,dev->name); 1812 dev->name,dev->name,dev->name,dev->name,dev->name);
1812 printk("%s: Here is a list of valid choices for the card=<n> insmod option:\n", 1813 printk("%s: Here is a list of valid choices for the card=<n> insmod option:\n",
1813 dev->name); 1814 dev->name);
1814 for (i = 0; i < em2820_bcount; i++) { 1815 for (i = 0; i < em28xx_bcount; i++) {
1815 printk("%s: card=%d -> %s\n", 1816 printk("%s: card=%d -> %s\n",
1816 dev->name, i, em2820_boards[i].name); 1817 dev->name, i, em28xx_boards[i].name);
1817 } 1818 }
1818 } 1819 }
1819 1820
1820 /* allocate device struct */ 1821 /* allocate device struct */
1821 retval = em2820_init_dev(&dev, udev, nr, model); 1822 retval = em28xx_init_dev(&dev, udev, nr, model);
1822 if (retval) 1823 if (retval)
1823 return retval; 1824 return retval;
1824 1825
1825 em2820_info("Found %s\n", em2820_boards[model].name); 1826 em28xx_info("Found %s\n", em28xx_boards[model].name);
1826 1827
1827 /* save our data pointer in this interface device */ 1828 /* save our data pointer in this interface device */
1828 usb_set_intfdata(interface, dev); 1829 usb_set_intfdata(interface, dev);
@@ -1830,38 +1831,38 @@ static int em2820_usb_probe(struct usb_interface *interface,
1830} 1831}
1831 1832
1832/* 1833/*
1833 * em2820_usb_disconnect() 1834 * em28xx_usb_disconnect()
1834 * called when the device gets diconencted 1835 * called when the device gets diconencted
1835 * video device will be unregistered on v4l2_close in case it is still open 1836 * video device will be unregistered on v4l2_close in case it is still open
1836 */ 1837 */
1837static void em2820_usb_disconnect(struct usb_interface *interface) 1838static void em28xx_usb_disconnect(struct usb_interface *interface)
1838{ 1839{
1839 struct em2820 *dev = usb_get_intfdata(interface); 1840 struct em28xx *dev = usb_get_intfdata(interface);
1840 usb_set_intfdata(interface, NULL); 1841 usb_set_intfdata(interface, NULL);
1841 1842
1842 if (!dev) 1843 if (!dev)
1843 return; 1844 return;
1844 1845
1845 down_write(&em2820_disconnect); 1846 down_write(&em28xx_disconnect);
1846 1847
1847 down(&dev->lock); 1848 down(&dev->lock);
1848 1849
1849 em2820_info("disconnecting %s\n", dev->vdev->name); 1850 em28xx_info("disconnecting %s\n", dev->vdev->name);
1850 1851
1851 wake_up_interruptible_all(&dev->open); 1852 wake_up_interruptible_all(&dev->open);
1852 1853
1853 if (dev->users) { 1854 if (dev->users) {
1854 em2820_warn 1855 em28xx_warn
1855 ("device /dev/video%d is open! Deregistration and memory " 1856 ("device /dev/video%d is open! Deregistration and memory "
1856 "deallocation are deferred on close.\n", dev->vdev->minor); 1857 "deallocation are deferred on close.\n", dev->vdev->minor);
1857 dev->state |= DEV_MISCONFIGURED; 1858 dev->state |= DEV_MISCONFIGURED;
1858 em2820_uninit_isoc(dev); 1859 em28xx_uninit_isoc(dev);
1859 dev->state |= DEV_DISCONNECTED; 1860 dev->state |= DEV_DISCONNECTED;
1860 wake_up_interruptible(&dev->wait_frame); 1861 wake_up_interruptible(&dev->wait_frame);
1861 wake_up_interruptible(&dev->wait_stream); 1862 wake_up_interruptible(&dev->wait_stream);
1862 } else { 1863 } else {
1863 dev->state |= DEV_DISCONNECTED; 1864 dev->state |= DEV_DISCONNECTED;
1864 em2820_release_resources(dev); 1865 em28xx_release_resources(dev);
1865 } 1866 }
1866 1867
1867 up(&dev->lock); 1868 up(&dev->lock);
@@ -1869,44 +1870,44 @@ static void em2820_usb_disconnect(struct usb_interface *interface)
1869 if (!dev->users) 1870 if (!dev->users)
1870 kfree(dev); 1871 kfree(dev);
1871 1872
1872 up_write(&em2820_disconnect); 1873 up_write(&em28xx_disconnect);
1873 1874
1874} 1875}
1875 1876
1876static struct usb_driver em2820_usb_driver = { 1877static struct usb_driver em28xx_usb_driver = {
1877 .owner = THIS_MODULE, 1878 .owner = THIS_MODULE,
1878 .name = "em2820", 1879 .name = "em28xx",
1879 .probe = em2820_usb_probe, 1880 .probe = em28xx_usb_probe,
1880 .disconnect = em2820_usb_disconnect, 1881 .disconnect = em28xx_usb_disconnect,
1881 .id_table = em2820_id_table, 1882 .id_table = em28xx_id_table,
1882}; 1883};
1883 1884
1884static int __init em2820_module_init(void) 1885static int __init em28xx_module_init(void)
1885{ 1886{
1886 int result; 1887 int result;
1887 1888
1888 printk(KERN_INFO DRIVER_NAME " v4l2 driver version %d.%d.%d loaded\n", 1889 printk(KERN_INFO DRIVER_NAME " v4l2 driver version %d.%d.%d loaded\n",
1889 (EM2820_VERSION_CODE >> 16) & 0xff, 1890 (EM28XX_VERSION_CODE >> 16) & 0xff,
1890 (EM2820_VERSION_CODE >> 8) & 0xff, EM2820_VERSION_CODE & 0xff); 1891 (EM28XX_VERSION_CODE >> 8) & 0xff, EM28XX_VERSION_CODE & 0xff);
1891#ifdef SNAPSHOT 1892#ifdef SNAPSHOT
1892 printk(KERN_INFO DRIVER_NAME " snapshot date %04d-%02d-%02d\n", 1893 printk(KERN_INFO DRIVER_NAME " snapshot date %04d-%02d-%02d\n",
1893 SNAPSHOT / 10000, (SNAPSHOT / 100) % 100, SNAPSHOT % 100); 1894 SNAPSHOT / 10000, (SNAPSHOT / 100) % 100, SNAPSHOT % 100);
1894#endif 1895#endif
1895 1896
1896 /* register this driver with the USB subsystem */ 1897 /* register this driver with the USB subsystem */
1897 result = usb_register(&em2820_usb_driver); 1898 result = usb_register(&em28xx_usb_driver);
1898 if (result) 1899 if (result)
1899 em2820_err(DRIVER_NAME 1900 em28xx_err(DRIVER_NAME
1900 " usb_register failed. Error number %d.\n", result); 1901 " usb_register failed. Error number %d.\n", result);
1901 1902
1902 return result; 1903 return result;
1903} 1904}
1904 1905
1905static void __exit em2820_module_exit(void) 1906static void __exit em28xx_module_exit(void)
1906{ 1907{
1907 /* deregister this driver with the USB subsystem */ 1908 /* deregister this driver with the USB subsystem */
1908 usb_deregister(&em2820_usb_driver); 1909 usb_deregister(&em28xx_usb_driver);
1909} 1910}
1910 1911
1911module_init(em2820_module_init); 1912module_init(em28xx_module_init);
1912module_exit(em2820_module_exit); 1913module_exit(em28xx_module_exit);
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h
index 8c58c5b5fa36..d51f8c63bcf9 100644
--- a/drivers/media/video/em28xx/em28xx.h
+++ b/drivers/media/video/em28xx/em28xx.h
@@ -1,5 +1,5 @@
1/* 1/*
2 em2820-cards.c - driver for Empia EM2800/EM2820/2840 USB video capture devices 2 em28xx-cards.c - driver for Empia EM2800/EM2820/2840 USB video capture devices
3 3
4 Copyright (C) 2005 Markus Rechberger <mrechberger@gmail.com> 4 Copyright (C) 2005 Markus Rechberger <mrechberger@gmail.com>
5 Ludovico Cavedon <cavedon@sssup.it> 5 Ludovico Cavedon <cavedon@sssup.it>
@@ -22,8 +22,8 @@
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */ 23 */
24 24
25#ifndef _EM2820_H 25#ifndef _EM28XX_H
26#define _EM2820_H 26#define _EM28XX_H
27 27
28#include <linux/videodev.h> 28#include <linux/videodev.h>
29#include <linux/i2c.h> 29#include <linux/i2c.h>
@@ -45,27 +45,27 @@
45#define UNSET -1 45#define UNSET -1
46 46
47/* maximum number of em28xx boards */ 47/* maximum number of em28xx boards */
48#define EM2820_MAXBOARDS 1 /*FIXME: should be bigger */ 48#define EM28XX_MAXBOARDS 1 /*FIXME: should be bigger */
49 49
50/* maximum number of frames that can be queued */ 50/* maximum number of frames that can be queued */
51#define EM2820_NUM_FRAMES 5 51#define EM28XX_NUM_FRAMES 5
52/* number of frames that get used for v4l2_read() */ 52/* number of frames that get used for v4l2_read() */
53#define EM2820_NUM_READ_FRAMES 2 53#define EM28XX_NUM_READ_FRAMES 2
54 54
55/* number of buffers for isoc transfers */ 55/* number of buffers for isoc transfers */
56#define EM2820_NUM_BUFS 5 56#define EM28XX_NUM_BUFS 5
57 57
58/* number of packets for each buffer 58/* number of packets for each buffer
59 windows requests only 40 packets .. so we better do the same 59 windows requests only 40 packets .. so we better do the same
60 this is what I found out for all alternate numbers there! 60 this is what I found out for all alternate numbers there!
61 */ 61 */
62#define EM2820_NUM_PACKETS 40 62#define EM28XX_NUM_PACKETS 40
63 63
64/* default alternate; 0 means choose the best */ 64/* default alternate; 0 means choose the best */
65#define EM2820_PINOUT 0 65#define EM28XX_PINOUT 0
66#define EM2820_MAX_ALT 7 66#define EM28XX_MAX_ALT 7
67 67
68#define EM2820_INTERLACED_DEFAULT 1 68#define EM28XX_INTERLACED_DEFAULT 1
69 69
70/* 70/*
71#define (use usbview if you want to get the other alternate number infos) 71#define (use usbview if you want to get the other alternate number infos)
@@ -89,13 +89,13 @@
89*/ 89*/
90 90
91/* time to wait when stopping the isoc transfer */ 91/* time to wait when stopping the isoc transfer */
92#define EM2820_URB_TIMEOUT msecs_to_jiffies(EM2820_NUM_BUFS * EM2820_NUM_PACKETS) 92#define EM28XX_URB_TIMEOUT msecs_to_jiffies(EM28XX_NUM_BUFS * EM28XX_NUM_PACKETS)
93 93
94/* time in msecs to wait for i2c writes to finish */ 94/* time in msecs to wait for i2c writes to finish */
95#define EM2800_I2C_WRITE_TIMEOUT 20 95#define EM2800_I2C_WRITE_TIMEOUT 20
96 96
97/* the various frame states */ 97/* the various frame states */
98enum em2820_frame_state { 98enum em28xx_frame_state {
99 F_UNUSED = 0, 99 F_UNUSED = 0,
100 F_QUEUED, 100 F_QUEUED,
101 F_GRABBING, 101 F_GRABBING,
@@ -104,17 +104,17 @@ enum em2820_frame_state {
104}; 104};
105 105
106/* stream states */ 106/* stream states */
107enum em2820_stream_state { 107enum em28xx_stream_state {
108 STREAM_OFF, 108 STREAM_OFF,
109 STREAM_INTERRUPT, 109 STREAM_INTERRUPT,
110 STREAM_ON, 110 STREAM_ON,
111}; 111};
112 112
113/* frames */ 113/* frames */
114struct em2820_frame_t { 114struct em28xx_frame_t {
115 void *bufmem; 115 void *bufmem;
116 struct v4l2_buffer buf; 116 struct v4l2_buffer buf;
117 enum em2820_frame_state state; 117 enum em28xx_frame_state state;
118 struct list_head frame; 118 struct list_head frame;
119 unsigned long vma_use_count; 119 unsigned long vma_use_count;
120 int top_field; 120 int top_field;
@@ -122,7 +122,7 @@ struct em2820_frame_t {
122}; 122};
123 123
124/* io methods */ 124/* io methods */
125enum em2820_io_method { 125enum em28xx_io_method {
126 IO_NONE, 126 IO_NONE,
127 IO_READ, 127 IO_READ,
128 IO_MMAP, 128 IO_MMAP,
@@ -130,35 +130,35 @@ enum em2820_io_method {
130 130
131/* inputs */ 131/* inputs */
132 132
133#define MAX_EM2820_INPUT 4 133#define MAX_EM28XX_INPUT 4
134enum enum2820_itype { 134enum enum28xx_itype {
135 EM2820_VMUX_COMPOSITE1 = 1, 135 EM28XX_VMUX_COMPOSITE1 = 1,
136 EM2820_VMUX_COMPOSITE2, 136 EM28XX_VMUX_COMPOSITE2,
137 EM2820_VMUX_COMPOSITE3, 137 EM28XX_VMUX_COMPOSITE3,
138 EM2820_VMUX_COMPOSITE4, 138 EM28XX_VMUX_COMPOSITE4,
139 EM2820_VMUX_SVIDEO, 139 EM28XX_VMUX_SVIDEO,
140 EM2820_VMUX_TELEVISION, 140 EM28XX_VMUX_TELEVISION,
141 EM2820_VMUX_CABLE, 141 EM28XX_VMUX_CABLE,
142 EM2820_VMUX_DVB, 142 EM28XX_VMUX_DVB,
143 EM2820_VMUX_DEBUG, 143 EM28XX_VMUX_DEBUG,
144 EM2820_RADIO, 144 EM28XX_RADIO,
145}; 145};
146 146
147struct em2820_input { 147struct em28xx_input {
148 enum enum2820_itype type; 148 enum enum28xx_itype type;
149 unsigned int vmux; 149 unsigned int vmux;
150 unsigned int amux; 150 unsigned int amux;
151}; 151};
152 152
153#define INPUT(nr) (&em2820_boards[dev->model].input[nr]) 153#define INPUT(nr) (&em28xx_boards[dev->model].input[nr])
154 154
155enum em2820_decoder { 155enum em28xx_decoder {
156 EM2820_TVP5150, 156 EM28XX_TVP5150,
157 EM2820_SAA7113, 157 EM28XX_SAA7113,
158 EM2820_SAA7114 158 EM28XX_SAA7114
159}; 159};
160 160
161struct em2820_board { 161struct em28xx_board {
162 char *name; 162 char *name;
163 int vchannels; 163 int vchannels;
164 int norm; 164 int norm;
@@ -171,12 +171,12 @@ struct em2820_board {
171 unsigned int has_tuner:1; 171 unsigned int has_tuner:1;
172 unsigned int has_msp34xx:1; 172 unsigned int has_msp34xx:1;
173 173
174 enum em2820_decoder decoder; 174 enum em28xx_decoder decoder;
175 175
176 struct em2820_input input[MAX_EM2820_INPUT]; 176 struct em28xx_input input[MAX_EM28XX_INPUT];
177}; 177};
178 178
179struct em2820_eeprom { 179struct em28xx_eeprom {
180 u32 id; /* 0x9567eb1a */ 180 u32 id; /* 0x9567eb1a */
181 u16 vendor_ID; 181 u16 vendor_ID;
182 u16 product_ID; 182 u16 product_ID;
@@ -191,14 +191,14 @@ struct em2820_eeprom {
191}; 191};
192 192
193/* device states */ 193/* device states */
194enum em2820_dev_state { 194enum em28xx_dev_state {
195 DEV_INITIALIZED = 0x01, 195 DEV_INITIALIZED = 0x01,
196 DEV_DISCONNECTED = 0x02, 196 DEV_DISCONNECTED = 0x02,
197 DEV_MISCONFIGURED = 0x04, 197 DEV_MISCONFIGURED = 0x04,
198}; 198};
199 199
200/* tvnorms */ 200/* tvnorms */
201struct em2820_tvnorm { 201struct em28xx_tvnorm {
202 char *name; 202 char *name;
203 v4l2_std_id id; 203 v4l2_std_id id;
204 /* mode for saa7113h */ 204 /* mode for saa7113h */
@@ -206,7 +206,7 @@ struct em2820_tvnorm {
206}; 206};
207 207
208/* main device struct */ 208/* main device struct */
209struct em2820 { 209struct em28xx {
210 /* generic device properties */ 210 /* generic device properties */
211 char name[30]; /* name (including minor) of the device */ 211 char name[30]; /* name (including minor) of the device */
212 int model; /* index in the device_data struct */ 212 int model; /* index in the device_data struct */
@@ -217,7 +217,7 @@ struct em2820 {
217 unsigned int has_msp34xx:1; 217 unsigned int has_msp34xx:1;
218 unsigned int has_tda9887:1; 218 unsigned int has_tda9887:1;
219 219
220 enum em2820_decoder decoder; 220 enum em28xx_decoder decoder;
221 221
222 int tuner_type; /* type of the tuner */ 222 int tuner_type; /* type of the tuner */
223 int tuner_addr; /* tuner address */ 223 int tuner_addr; /* tuner address */
@@ -229,17 +229,17 @@ struct em2820 {
229 int users; /* user count for exclusive use */ 229 int users; /* user count for exclusive use */
230 struct video_device *vdev; /* video for linux device struct */ 230 struct video_device *vdev; /* video for linux device struct */
231 struct video_picture vpic; /* picture settings only used to init saa7113h */ 231 struct video_picture vpic; /* picture settings only used to init saa7113h */
232 struct em2820_tvnorm *tvnorm; /* selected tv norm */ 232 struct em28xx_tvnorm *tvnorm; /* selected tv norm */
233 int ctl_freq; /* selected frequency */ 233 int ctl_freq; /* selected frequency */
234 unsigned int ctl_input; /* selected input */ 234 unsigned int ctl_input; /* selected input */
235 unsigned int ctl_ainput; /* slected audio input */ 235 unsigned int ctl_ainput; /* slected audio input */
236 int mute; 236 int mute;
237 int volume; 237 int volume;
238 /* frame properties */ 238 /* frame properties */
239 struct em2820_frame_t frame[EM2820_NUM_FRAMES]; /* list of frames */ 239 struct em28xx_frame_t frame[EM28XX_NUM_FRAMES]; /* list of frames */
240 int num_frames; /* number of frames currently in use */ 240 int num_frames; /* number of frames currently in use */
241 unsigned int frame_count; /* total number of transfered frames */ 241 unsigned int frame_count; /* total number of transfered frames */
242 struct em2820_frame_t *frame_current; /* the frame that is being filled */ 242 struct em28xx_frame_t *frame_current; /* the frame that is being filled */
243 int width; /* current frame width */ 243 int width; /* current frame width */
244 int height; /* current frame height */ 244 int height; /* current frame height */
245 int frame_size; /* current frame size */ 245 int frame_size; /* current frame size */
@@ -251,9 +251,9 @@ struct em2820 {
251 int type; 251 int type;
252 252
253 /* states */ 253 /* states */
254 enum em2820_dev_state state; 254 enum em28xx_dev_state state;
255 enum em2820_stream_state stream; 255 enum em28xx_stream_state stream;
256 enum em2820_io_method io; 256 enum em28xx_io_method io;
257 /* locks */ 257 /* locks */
258 struct semaphore lock, fileop_lock; 258 struct semaphore lock, fileop_lock;
259 spinlock_t queue_lock; 259 spinlock_t queue_lock;
@@ -267,71 +267,71 @@ struct em2820 {
267 struct usb_device *udev; /* the usb device */ 267 struct usb_device *udev; /* the usb device */
268 int alt; /* alternate */ 268 int alt; /* alternate */
269 int max_pkt_size; /* max packet size of isoc transaction */ 269 int max_pkt_size; /* max packet size of isoc transaction */
270 unsigned int alt_max_pkt_size[EM2820_MAX_ALT + 1]; /* array of wMaxPacketSize */ 270 unsigned int alt_max_pkt_size[EM28XX_MAX_ALT + 1]; /* array of wMaxPacketSize */
271 struct urb *urb[EM2820_NUM_BUFS]; /* urb for isoc transfers */ 271 struct urb *urb[EM28XX_NUM_BUFS]; /* urb for isoc transfers */
272 char *transfer_buffer[EM2820_NUM_BUFS]; /* transfer buffers for isoc transfer */ 272 char *transfer_buffer[EM28XX_NUM_BUFS]; /* transfer buffers for isoc transfer */
273 /* helper funcs that call usb_control_msg */ 273 /* helper funcs that call usb_control_msg */
274 int (*em2820_write_regs) (struct em2820 * dev, u16 reg, char *buf, 274 int (*em28xx_write_regs) (struct em28xx * dev, u16 reg, char *buf,
275 int len); 275 int len);
276 int (*em2820_read_reg) (struct em2820 * dev, u16 reg); 276 int (*em28xx_read_reg) (struct em28xx * dev, u16 reg);
277 int (*em2820_read_reg_req_len) (struct em2820 * dev, u8 req, u16 reg, 277 int (*em28xx_read_reg_req_len) (struct em28xx * dev, u8 req, u16 reg,
278 char *buf, int len); 278 char *buf, int len);
279 int (*em2820_write_regs_req) (struct em2820 * dev, u8 req, u16 reg, 279 int (*em28xx_write_regs_req) (struct em28xx * dev, u8 req, u16 reg,
280 char *buf, int len); 280 char *buf, int len);
281 int (*em2820_read_reg_req) (struct em2820 * dev, u8 req, u16 reg); 281 int (*em28xx_read_reg_req) (struct em28xx * dev, u8 req, u16 reg);
282}; 282};
283 283
284/* Provided by em2820-i2c.c */ 284/* Provided by em28xx-i2c.c */
285 285
286void em2820_i2c_call_clients(struct em2820 *dev, unsigned int cmd, void *arg); 286void em28xx_i2c_call_clients(struct em28xx *dev, unsigned int cmd, void *arg);
287int em2820_i2c_register(struct em2820 *dev); 287int em28xx_i2c_register(struct em28xx *dev);
288int em2820_i2c_unregister(struct em2820 *dev); 288int em28xx_i2c_unregister(struct em28xx *dev);
289 289
290/* Provided by em2820-input.c */ 290/* Provided by em28xx-input.c */
291 291
292void em2820_set_ir(struct em2820 * dev,struct IR_i2c *ir); 292void em28xx_set_ir(struct em28xx * dev,struct IR_i2c *ir);
293 293
294/* Provided by em2820-core.c */ 294/* Provided by em28xx-core.c */
295 295
296void em2820_print_ioctl(char *name, unsigned int cmd); 296void em28xx_print_ioctl(char *name, unsigned int cmd);
297 297
298u32 em2820_request_buffers(struct em2820 *dev, u32 count); 298u32 em28xx_request_buffers(struct em28xx *dev, u32 count);
299void em2820_queue_unusedframes(struct em2820 *dev); 299void em28xx_queue_unusedframes(struct em28xx *dev);
300void em2820_release_buffers(struct em2820 *dev); 300void em28xx_release_buffers(struct em28xx *dev);
301 301
302int em2820_read_reg_req_len(struct em2820 *dev, u8 req, u16 reg, 302int em28xx_read_reg_req_len(struct em28xx *dev, u8 req, u16 reg,
303 char *buf, int len); 303 char *buf, int len);
304int em2820_read_reg_req(struct em2820 *dev, u8 req, u16 reg); 304int em28xx_read_reg_req(struct em28xx *dev, u8 req, u16 reg);
305int em2820_read_reg(struct em2820 *dev, u16 reg); 305int em28xx_read_reg(struct em28xx *dev, u16 reg);
306int em2820_write_regs_req(struct em2820 *dev, u8 req, u16 reg, char *buf, 306int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf,
307 int len); 307 int len);
308int em2820_write_regs(struct em2820 *dev, u16 reg, char *buf, int len); 308int em28xx_write_regs(struct em28xx *dev, u16 reg, char *buf, int len);
309int em2820_write_reg_bits(struct em2820 *dev, u16 reg, u8 val, 309int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val,
310 u8 bitmask); 310 u8 bitmask);
311int em2820_write_ac97(struct em2820 *dev, u8 reg, u8 * val); 311int em28xx_write_ac97(struct em28xx *dev, u8 reg, u8 * val);
312int em2820_audio_analog_set(struct em2820 *dev); 312int em28xx_audio_analog_set(struct em28xx *dev);
313int em2820_colorlevels_set_default(struct em2820 *dev); 313int em28xx_colorlevels_set_default(struct em28xx *dev);
314int em2820_capture_start(struct em2820 *dev, int start); 314int em28xx_capture_start(struct em28xx *dev, int start);
315int em2820_outfmt_set_yuv422(struct em2820 *dev); 315int em28xx_outfmt_set_yuv422(struct em28xx *dev);
316int em2820_accumulator_set(struct em2820 *dev, u8 xmin, u8 xmax, u8 ymin, 316int em28xx_accumulator_set(struct em28xx *dev, u8 xmin, u8 xmax, u8 ymin,
317 u8 ymax); 317 u8 ymax);
318int em2820_capture_area_set(struct em2820 *dev, u8 hstart, u8 vstart, 318int em28xx_capture_area_set(struct em28xx *dev, u8 hstart, u8 vstart,
319 u16 width, u16 height); 319 u16 width, u16 height);
320int em2820_scaler_set(struct em2820 *dev, u16 h, u16 v); 320int em28xx_scaler_set(struct em28xx *dev, u16 h, u16 v);
321int em2820_resolution_set(struct em2820 *dev); 321int em28xx_resolution_set(struct em28xx *dev);
322void em2820_isocIrq(struct urb *urb, struct pt_regs *regs); 322void em28xx_isocIrq(struct urb *urb, struct pt_regs *regs);
323int em2820_init_isoc(struct em2820 *dev); 323int em28xx_init_isoc(struct em28xx *dev);
324void em2820_uninit_isoc(struct em2820 *dev); 324void em28xx_uninit_isoc(struct em28xx *dev);
325int em2820_set_alternate(struct em2820 *dev); 325int em28xx_set_alternate(struct em28xx *dev);
326 326
327/* Provided by em2820-cards.c */ 327/* Provided by em28xx-cards.c */
328extern int em2800_variant_detect(struct usb_device* udev,int model); 328extern int em2800_variant_detect(struct usb_device* udev,int model);
329extern void em2820_card_setup(struct em2820 *dev); 329extern void em28xx_card_setup(struct em28xx *dev);
330extern struct em2820_board em2820_boards[]; 330extern struct em28xx_board em28xx_boards[];
331extern struct usb_device_id em2820_id_table[]; 331extern struct usb_device_id em28xx_id_table[];
332extern const unsigned int em2820_bcount; 332extern const unsigned int em28xx_bcount;
333 333
334/* em2820 registers */ 334/* em28xx registers */
335#define CHIPID_REG 0x0a 335#define CHIPID_REG 0x0a
336#define USBSUSP_REG 0x0c /* */ 336#define USBSUSP_REG 0x0c /* */
337 337
@@ -386,115 +386,115 @@ extern const unsigned int em2820_bcount;
386#define VIDEO_AC97 0x14 386#define VIDEO_AC97 0x14
387 387
388/* register settings */ 388/* register settings */
389#define EM2820_AUDIO_SRC_TUNER 0xc0 389#define EM28XX_AUDIO_SRC_TUNER 0xc0
390#define EM2820_AUDIO_SRC_LINE 0x80 390#define EM28XX_AUDIO_SRC_LINE 0x80
391 391
392/* printk macros */ 392/* printk macros */
393 393
394#define em2820_err(fmt, arg...) do {\ 394#define em28xx_err(fmt, arg...) do {\
395 printk(KERN_ERR fmt , ##arg); } while (0) 395 printk(KERN_ERR fmt , ##arg); } while (0)
396 396
397#define em2820_errdev(fmt, arg...) do {\ 397#define em28xx_errdev(fmt, arg...) do {\
398 printk(KERN_ERR "%s: "fmt,\ 398 printk(KERN_ERR "%s: "fmt,\
399 dev->name , ##arg); } while (0) 399 dev->name , ##arg); } while (0)
400 400
401#define em2820_info(fmt, arg...) do {\ 401#define em28xx_info(fmt, arg...) do {\
402 printk(KERN_INFO "%s: "fmt,\ 402 printk(KERN_INFO "%s: "fmt,\
403 dev->name , ##arg); } while (0) 403 dev->name , ##arg); } while (0)
404#define em2820_warn(fmt, arg...) do {\ 404#define em28xx_warn(fmt, arg...) do {\
405 printk(KERN_WARNING "%s: "fmt,\ 405 printk(KERN_WARNING "%s: "fmt,\
406 dev->name , ##arg); } while (0) 406 dev->name , ##arg); } while (0)
407 407
408inline static int em2820_audio_source(struct em2820 *dev, int input) 408inline static int em28xx_audio_source(struct em28xx *dev, int input)
409{ 409{
410 return em2820_write_reg_bits(dev, AUDIOSRC_REG, input, 0xc0); 410 return em28xx_write_reg_bits(dev, AUDIOSRC_REG, input, 0xc0);
411} 411}
412 412
413inline static int em2820_audio_usb_mute(struct em2820 *dev, int mute) 413inline static int em28xx_audio_usb_mute(struct em28xx *dev, int mute)
414{ 414{
415 return em2820_write_reg_bits(dev, XCLK_REG, mute ? 0x00 : 0x80, 0x80); 415 return em28xx_write_reg_bits(dev, XCLK_REG, mute ? 0x00 : 0x80, 0x80);
416} 416}
417 417
418inline static int em2820_audio_analog_setup(struct em2820 *dev) 418inline static int em28xx_audio_analog_setup(struct em28xx *dev)
419{ 419{
420 /* unmute video mixer with default volume level */ 420 /* unmute video mixer with default volume level */
421 return em2820_write_ac97(dev, VIDEO_AC97, "\x08\x08"); 421 return em28xx_write_ac97(dev, VIDEO_AC97, "\x08\x08");
422} 422}
423 423
424inline static int em2820_compression_disable(struct em2820 *dev) 424inline static int em28xx_compression_disable(struct em28xx *dev)
425{ 425{
426 /* side effect of disabling scaler and mixer */ 426 /* side effect of disabling scaler and mixer */
427 return em2820_write_regs(dev, COMPR_REG, "\x00", 1); 427 return em28xx_write_regs(dev, COMPR_REG, "\x00", 1);
428} 428}
429 429
430inline static int em2820_contrast_get(struct em2820 *dev) 430inline static int em28xx_contrast_get(struct em28xx *dev)
431{ 431{
432 return em2820_read_reg(dev, YGAIN_REG) & 0x1f; 432 return em28xx_read_reg(dev, YGAIN_REG) & 0x1f;
433} 433}
434 434
435inline static int em2820_brightness_get(struct em2820 *dev) 435inline static int em28xx_brightness_get(struct em28xx *dev)
436{ 436{
437 return em2820_read_reg(dev, YOFFSET_REG); 437 return em28xx_read_reg(dev, YOFFSET_REG);
438} 438}
439 439
440inline static int em2820_saturation_get(struct em2820 *dev) 440inline static int em28xx_saturation_get(struct em28xx *dev)
441{ 441{
442 return em2820_read_reg(dev, UVGAIN_REG) & 0x1f; 442 return em28xx_read_reg(dev, UVGAIN_REG) & 0x1f;
443} 443}
444 444
445inline static int em2820_u_balance_get(struct em2820 *dev) 445inline static int em28xx_u_balance_get(struct em28xx *dev)
446{ 446{
447 return em2820_read_reg(dev, UOFFSET_REG); 447 return em28xx_read_reg(dev, UOFFSET_REG);
448} 448}
449 449
450inline static int em2820_v_balance_get(struct em2820 *dev) 450inline static int em28xx_v_balance_get(struct em28xx *dev)
451{ 451{
452 return em2820_read_reg(dev, VOFFSET_REG); 452 return em28xx_read_reg(dev, VOFFSET_REG);
453} 453}
454 454
455inline static int em2820_gamma_get(struct em2820 *dev) 455inline static int em28xx_gamma_get(struct em28xx *dev)
456{ 456{
457 return em2820_read_reg(dev, GAMMA_REG) & 0x3f; 457 return em28xx_read_reg(dev, GAMMA_REG) & 0x3f;
458} 458}
459 459
460inline static int em2820_contrast_set(struct em2820 *dev, s32 val) 460inline static int em28xx_contrast_set(struct em28xx *dev, s32 val)
461{ 461{
462 u8 tmp = (u8) val; 462 u8 tmp = (u8) val;
463 return em2820_write_regs(dev, YGAIN_REG, &tmp, 1); 463 return em28xx_write_regs(dev, YGAIN_REG, &tmp, 1);
464} 464}
465 465
466inline static int em2820_brightness_set(struct em2820 *dev, s32 val) 466inline static int em28xx_brightness_set(struct em28xx *dev, s32 val)
467{ 467{
468 u8 tmp = (u8) val; 468 u8 tmp = (u8) val;
469 return em2820_write_regs(dev, YOFFSET_REG, &tmp, 1); 469 return em28xx_write_regs(dev, YOFFSET_REG, &tmp, 1);
470} 470}
471 471
472inline static int em2820_saturation_set(struct em2820 *dev, s32 val) 472inline static int em28xx_saturation_set(struct em28xx *dev, s32 val)
473{ 473{
474 u8 tmp = (u8) val; 474 u8 tmp = (u8) val;
475 return em2820_write_regs(dev, UVGAIN_REG, &tmp, 1); 475 return em28xx_write_regs(dev, UVGAIN_REG, &tmp, 1);
476} 476}
477 477
478inline static int em2820_u_balance_set(struct em2820 *dev, s32 val) 478inline static int em28xx_u_balance_set(struct em28xx *dev, s32 val)
479{ 479{
480 u8 tmp = (u8) val; 480 u8 tmp = (u8) val;
481 return em2820_write_regs(dev, UOFFSET_REG, &tmp, 1); 481 return em28xx_write_regs(dev, UOFFSET_REG, &tmp, 1);
482} 482}
483 483
484inline static int em2820_v_balance_set(struct em2820 *dev, s32 val) 484inline static int em28xx_v_balance_set(struct em28xx *dev, s32 val)
485{ 485{
486 u8 tmp = (u8) val; 486 u8 tmp = (u8) val;
487 return em2820_write_regs(dev, VOFFSET_REG, &tmp, 1); 487 return em28xx_write_regs(dev, VOFFSET_REG, &tmp, 1);
488} 488}
489 489
490inline static int em2820_gamma_set(struct em2820 *dev, s32 val) 490inline static int em28xx_gamma_set(struct em28xx *dev, s32 val)
491{ 491{
492 u8 tmp = (u8) val; 492 u8 tmp = (u8) val;
493 return em2820_write_regs(dev, GAMMA_REG, &tmp, 1); 493 return em28xx_write_regs(dev, GAMMA_REG, &tmp, 1);
494} 494}
495 495
496/*FIXME: maxw should be dependent of alt mode */ 496/*FIXME: maxw should be dependent of alt mode */
497inline static unsigned int norm_maxw(struct em2820 *dev) 497inline static unsigned int norm_maxw(struct em28xx *dev)
498{ 498{
499 switch(dev->model){ 499 switch(dev->model){
500 case (EM2820_BOARD_MSI_VOX_USB_2): return(640); 500 case (EM2820_BOARD_MSI_VOX_USB_2): return(640);
@@ -502,7 +502,7 @@ inline static unsigned int norm_maxw(struct em2820 *dev)
502 } 502 }
503} 503}
504 504
505inline static unsigned int norm_maxh(struct em2820 *dev) 505inline static unsigned int norm_maxh(struct em28xx *dev)
506{ 506{
507 switch(dev->model){ 507 switch(dev->model){
508 case (EM2820_BOARD_MSI_VOX_USB_2): return(480); 508 case (EM2820_BOARD_MSI_VOX_USB_2): return(480);