aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/em28xx
diff options
context:
space:
mode:
authorDouglas Schilling Landgraf <dougsland@gmail.com>2008-04-17 20:41:10 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-04-24 13:09:41 -0400
commit6ea54d938b6f81baa0952a8b15d3e67e6c268b8f (patch)
tree3cda23563cf6f6f05927b7f7c61eaa6605a0e10d /drivers/media/video/em28xx
parente6a353b0dc2686ae04805919e7a22430d2f1e29e (diff)
V4L/DVB (7607): CodingStyle fixes
Signed-off-by: Douglas Schilling Landgraf <dougsland@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/em28xx')
-rw-r--r--drivers/media/video/em28xx/em28xx-cards.c4
-rw-r--r--drivers/media/video/em28xx/em28xx-core.c63
-rw-r--r--drivers/media/video/em28xx/em28xx-dvb.c29
-rw-r--r--drivers/media/video/em28xx/em28xx-i2c.c156
-rw-r--r--drivers/media/video/em28xx/em28xx-input.c26
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c103
-rw-r--r--drivers/media/video/em28xx/em28xx.h47
7 files changed, 240 insertions, 188 deletions
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c
index fed2dc4473df..7dfea3ac9b2f 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -436,10 +436,10 @@ MODULE_DEVICE_TABLE(usb, em28xx_id_table);
436 436
437/* Board Hauppauge WinTV HVR 900 analog */ 437/* Board Hauppauge WinTV HVR 900 analog */
438struct em28xx_reg_seq hauppauge_wintv_hvr_900_analog[] = { 438struct em28xx_reg_seq hauppauge_wintv_hvr_900_analog[] = {
439 { -1, -1, 6}, 439 { -1, -1, 6},
440 {0x08, 0x2d, 10}, 440 {0x08, 0x2d, 10},
441 {0x08, 0x3d, 5}, 441 {0x08, 0x3d, 5},
442 { -1, -1, -1}, 442 { -1, -1, -1},
443}; 443};
444/* Board Hauppauge WinTV HVR 900 digital */ 444/* Board Hauppauge WinTV HVR 900 digital */
445struct em28xx_reg_seq hauppauge_wintv_hvr_900_digital[] = { 445struct em28xx_reg_seq hauppauge_wintv_hvr_900_digital[] = {
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c
index 77f64900717d..a742a57d3979 100644
--- a/drivers/media/video/em28xx/em28xx-core.c
+++ b/drivers/media/video/em28xx/em28xx-core.c
@@ -77,12 +77,12 @@ int em28xx_read_reg_req_len(struct em28xx *dev, u8 req, u16 reg,
77 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 77 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
78 0x0000, reg, buf, len, HZ); 78 0x0000, reg, buf, len, HZ);
79 79
80 if (reg_debug){ 80 if (reg_debug) {
81 printk(ret < 0 ? " failed!\n" : "%02x values: ", ret); 81 printk(ret < 0 ? " failed!\n" : "%02x values: ", ret);
82 for (byte = 0; byte < len; byte++) { 82 for (byte = 0; byte < len; byte++)
83 printk(" %02x", (unsigned char)buf[byte]); 83 printk(KERN_INFO " %02x", (unsigned char)buf[byte]);
84 } 84
85 printk("\n"); 85 printk(KERN_INFO "\n");
86 } 86 }
87 87
88 return ret; 88 return ret;
@@ -143,8 +143,8 @@ int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf,
143 if (reg_debug) { 143 if (reg_debug) {
144 int i; 144 int i;
145 for (i = 0; i < len; ++i) 145 for (i = 0; i < len; ++i)
146 printk (" %02x", (unsigned char)buf[i]); 146 printk(KERN_INFO " %02x", (unsigned char)buf[i]);
147 printk ("\n"); 147 printk(KERN_INFO "\n");
148 } 148 }
149 149
150 if (!bufs) 150 if (!bufs)
@@ -173,8 +173,12 @@ static int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val,
173{ 173{
174 int oldval; 174 int oldval;
175 u8 newval; 175 u8 newval;
176 if ((oldval = em28xx_read_reg(dev, reg)) < 0) 176
177 oldval = em28xx_read_reg(dev, reg);
178
179 if (oldval < 0)
177 return oldval; 180 return oldval;
181
178 newval = (((u8) oldval) & ~bitmask) | (val & bitmask); 182 newval = (((u8) oldval) & ~bitmask) | (val & bitmask);
179 return em28xx_write_regs(dev, reg, &newval, 1); 183 return em28xx_write_regs(dev, reg, &newval, 1);
180} 184}
@@ -187,20 +191,26 @@ static int em28xx_write_ac97(struct em28xx *dev, u8 reg, u8 *val)
187{ 191{
188 int ret, i; 192 int ret, i;
189 u8 addr = reg & 0x7f; 193 u8 addr = reg & 0x7f;
190 if ((ret = em28xx_write_regs(dev, AC97LSB_REG, val, 2)) < 0) 194
195 ret = em28xx_write_regs(dev, AC97LSB_REG, val, 2);
196 if (ret < 0)
191 return ret; 197 return ret;
192 if ((ret = em28xx_write_regs(dev, AC97ADDR_REG, &addr, 1)) < 0) 198
199 ret = em28xx_write_regs(dev, AC97ADDR_REG, &addr, 1);
200 if (ret < 0)
193 return ret; 201 return ret;
194 202
195 /* Wait up to 50 ms for AC97 command to complete */ 203 /* Wait up to 50 ms for AC97 command to complete */
196 for (i = 0; i < 10; i++) { 204 for (i = 0; i < 10; i++) {
197 if ((ret = em28xx_read_reg(dev, AC97BUSY_REG)) < 0) 205 ret = em28xx_read_reg(dev, AC97BUSY_REG);
206 if (ret < 0)
198 return ret; 207 return ret;
208
199 if (!(ret & 0x01)) 209 if (!(ret & 0x01))
200 return 0; 210 return 0;
201 msleep(5); 211 msleep(5);
202 } 212 }
203 em28xx_warn ("AC97 command still being executed: not handled properly!\n"); 213 em28xx_warn("AC97 command still being executed: not handled properly!\n");
204 return 0; 214 return 0;
205} 215}
206 216
@@ -338,11 +348,11 @@ int em28xx_capture_start(struct em28xx *dev, int start)
338 rc = em28xx_write_regs_req(dev, 0x00, 0x48, "\x00", 1); 348 rc = em28xx_write_regs_req(dev, 0x00, 0x48, "\x00", 1);
339 349
340 if (dev->mode == EM28XX_ANALOG_MODE) 350 if (dev->mode == EM28XX_ANALOG_MODE)
341 rc = em28xx_write_regs(dev, VINENABLE_REG,"\x67", 1); 351 rc = em28xx_write_regs(dev, VINENABLE_REG, "\x67", 1);
342 else 352 else
343 rc = em28xx_write_regs(dev, VINENABLE_REG,"\x37", 1); 353 rc = em28xx_write_regs(dev, VINENABLE_REG, "\x37", 1);
344 354
345 msleep (6); 355 msleep(6);
346 356
347 return rc; 357 return rc;
348} 358}
@@ -357,7 +367,8 @@ int em28xx_outfmt_set_yuv422(struct em28xx *dev)
357static int em28xx_accumulator_set(struct em28xx *dev, u8 xmin, u8 xmax, 367static int em28xx_accumulator_set(struct em28xx *dev, u8 xmin, u8 xmax,
358 u8 ymin, u8 ymax) 368 u8 ymin, u8 ymax)
359{ 369{
360 em28xx_coredbg("em28xx Scale: (%d,%d)-(%d,%d)\n", xmin, ymin, xmax, ymax); 370 em28xx_coredbg("em28xx Scale: (%d,%d)-(%d,%d)\n",
371 xmin, ymin, xmax, ymax);
361 372
362 em28xx_write_regs(dev, XMIN_REG, &xmin, 1); 373 em28xx_write_regs(dev, XMIN_REG, &xmin, 1);
363 em28xx_write_regs(dev, XMAX_REG, &xmax, 1); 374 em28xx_write_regs(dev, XMAX_REG, &xmax, 1);
@@ -372,7 +383,8 @@ static int em28xx_capture_area_set(struct em28xx *dev, u8 hstart, u8 vstart,
372 u8 cheight = height; 383 u8 cheight = height;
373 u8 overflow = (height >> 7 & 0x02) | (width >> 8 & 0x01); 384 u8 overflow = (height >> 7 & 0x02) | (width >> 8 & 0x01);
374 385
375 em28xx_coredbg("em28xx Area Set: (%d,%d)\n", (width | (overflow & 2) << 7), 386 em28xx_coredbg("em28xx Area Set: (%d,%d)\n",
387 (width | (overflow & 2) << 7),
376 (height | (overflow & 1) << 8)); 388 (height | (overflow & 1) << 8));
377 389
378 em28xx_write_regs(dev, HSTART_REG, &hstart, 1); 390 em28xx_write_regs(dev, HSTART_REG, &hstart, 1);
@@ -386,7 +398,7 @@ static int em28xx_scaler_set(struct em28xx *dev, u16 h, u16 v)
386{ 398{
387 u8 mode; 399 u8 mode;
388 /* the em2800 scaler only supports scaling down to 50% */ 400 /* the em2800 scaler only supports scaling down to 50% */
389 if(dev->is_em2800) 401 if (dev->is_em2800)
390 mode = (v ? 0x20 : 0x00) | (h ? 0x10 : 0x00); 402 mode = (v ? 0x20 : 0x00) | (h ? 0x10 : 0x00);
391 else { 403 else {
392 u8 buf[2]; 404 u8 buf[2];
@@ -396,7 +408,8 @@ static int em28xx_scaler_set(struct em28xx *dev, u16 h, u16 v)
396 buf[0] = v; 408 buf[0] = v;
397 buf[1] = v >> 8; 409 buf[1] = v >> 8;
398 em28xx_write_regs(dev, VSCALELOW_REG, (char *)buf, 2); 410 em28xx_write_regs(dev, VSCALELOW_REG, (char *)buf, 2);
399 /* it seems that both H and V scalers must be active to work correctly */ 411 /* it seems that both H and V scalers must be active
412 to work correctly */
400 mode = (h || v)? 0x30: 0x00; 413 mode = (h || v)? 0x30: 0x00;
401 } 414 }
402 return em28xx_write_reg_bits(dev, COMPR_REG, mode, 0x30); 415 return em28xx_write_reg_bits(dev, COMPR_REG, mode, 0x30);
@@ -449,7 +462,7 @@ int em28xx_set_alternate(struct em28xx *dev)
449 dev->alt, dev->max_pkt_size); 462 dev->alt, dev->max_pkt_size);
450 errCode = usb_set_interface(dev->udev, 0, dev->alt); 463 errCode = usb_set_interface(dev->udev, 0, dev->alt);
451 if (errCode < 0) { 464 if (errCode < 0) {
452 em28xx_errdev ("cannot change alternate number to %d (error=%i)\n", 465 em28xx_errdev("cannot change alternate number to %d (error=%i)\n",
453 dev->alt, errCode); 466 dev->alt, errCode);
454 return errCode; 467 return errCode;
455 } 468 }
@@ -507,9 +520,9 @@ void em28xx_uninit_isoc(struct em28xx *dev)
507 usb_unlink_urb(urb); 520 usb_unlink_urb(urb);
508 if (dev->isoc_ctl.transfer_buffer[i]) { 521 if (dev->isoc_ctl.transfer_buffer[i]) {
509 usb_buffer_free(dev->udev, 522 usb_buffer_free(dev->udev,
510 urb->transfer_buffer_length, 523 urb->transfer_buffer_length,
511 dev->isoc_ctl.transfer_buffer[i], 524 dev->isoc_ctl.transfer_buffer[i],
512 urb->transfer_dma); 525 urb->transfer_dma);
513 } 526 }
514 usb_free_urb(urb); 527 usb_free_urb(urb);
515 dev->isoc_ctl.urb[i] = NULL; 528 dev->isoc_ctl.urb[i] = NULL;
@@ -596,7 +609,9 @@ int em28xx_init_isoc(struct em28xx *dev, int max_packets,
596 'desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK' 609 'desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK'
597 should also be using 'desc.bInterval' 610 should also be using 'desc.bInterval'
598 */ 611 */
599 pipe = usb_rcvisocpipe(dev->udev, cap_type == EM28XX_ANALOG_CAPTURE ? 0x82 : 0x84); 612 pipe = usb_rcvisocpipe(dev->udev,
613 cap_type == EM28XX_ANALOG_CAPTURE ? 0x82 : 0x84);
614
600 usb_fill_int_urb(urb, dev->udev, pipe, 615 usb_fill_int_urb(urb, dev->udev, pipe,
601 dev->isoc_ctl.transfer_buffer[i], sb_size, 616 dev->isoc_ctl.transfer_buffer[i], sb_size,
602 em28xx_irq_callback, dma_q, 1); 617 em28xx_irq_callback, dma_q, 1);
diff --git a/drivers/media/video/em28xx/em28xx-dvb.c b/drivers/media/video/em28xx/em28xx-dvb.c
index 64816ae106e3..21b8f1d48024 100644
--- a/drivers/media/video/em28xx/em28xx-dvb.c
+++ b/drivers/media/video/em28xx/em28xx-dvb.c
@@ -97,7 +97,8 @@ static inline void print_err_status(struct em28xx *dev,
97 if (packet < 0) { 97 if (packet < 0) {
98 dprintk(1, "URB status %d [%s].\n", status, errmsg); 98 dprintk(1, "URB status %d [%s].\n", status, errmsg);
99 } else { 99 } else {
100 dprintk(1, "URB packet %d, status %d [%s].\n", packet, status, errmsg); 100 dprintk(1, "URB packet %d, status %d [%s].\n",
101 packet, status, errmsg);
101 } 102 }
102} 103}
103 104
@@ -134,18 +135,20 @@ static inline int dvb_isoc_copy(struct em28xx *dev, struct urb *urb)
134 return 0; 135 return 0;
135} 136}
136 137
137static int start_streaming(struct em28xx_dvb* dvb) { 138static int start_streaming(struct em28xx_dvb *dvb)
139{
138 struct em28xx *dev = dvb->adapter.priv; 140 struct em28xx *dev = dvb->adapter.priv;
139 141
140 usb_set_interface(dev->udev, 0, 1); 142 usb_set_interface(dev->udev, 0, 1);
141 dev->em28xx_write_regs_req(dev,0x00,0x48,"\x00",1); 143 dev->em28xx_write_regs_req(dev, 0x00, 0x48, "\x00", 1);
142 144
143 return em28xx_init_isoc(dev, EM28XX_DVB_MAX_PACKETS, 145 return em28xx_init_isoc(dev, EM28XX_DVB_MAX_PACKETS,
144 EM28XX_DVB_NUM_BUFS, EM28XX_DVB_MAX_PACKETSIZE, 146 EM28XX_DVB_NUM_BUFS, EM28XX_DVB_MAX_PACKETSIZE,
145 dvb_isoc_copy, EM28XX_DIGITAL_CAPTURE); 147 dvb_isoc_copy, EM28XX_DIGITAL_CAPTURE);
146} 148}
147 149
148static int stop_streaming(struct em28xx_dvb* dvb) { 150static int stop_streaming(struct em28xx_dvb *dvb)
151{
149 struct em28xx *dev = dvb->adapter.priv; 152 struct em28xx *dev = dvb->adapter.priv;
150 153
151 em28xx_uninit_isoc(dev); 154 em28xx_uninit_isoc(dev);
@@ -167,7 +170,8 @@ static int start_feed(struct dvb_demux_feed *feed)
167 170
168 if (dvb->nfeeds == 1) { 171 if (dvb->nfeeds == 1) {
169 ret = start_streaming(dvb); 172 ret = start_streaming(dvb);
170 if(ret < 0) rc = ret; 173 if (ret < 0)
174 rc = ret;
171 } 175 }
172 176
173 mutex_unlock(&dvb->lock); 177 mutex_unlock(&dvb->lock);
@@ -182,9 +186,10 @@ static int stop_feed(struct dvb_demux_feed *feed)
182 186
183 mutex_lock(&dvb->lock); 187 mutex_lock(&dvb->lock);
184 dvb->nfeeds--; 188 dvb->nfeeds--;
185 if (0 == dvb->nfeeds) { 189
190 if (0 == dvb->nfeeds)
186 err = stop_streaming(dvb); 191 err = stop_streaming(dvb);
187 } 192
188 mutex_unlock(&dvb->lock); 193 mutex_unlock(&dvb->lock);
189 return err; 194 return err;
190} 195}
@@ -212,7 +217,7 @@ static int attach_xc3028(u8 addr, struct em28xx *dev)
212 struct xc2028_ctrl ctl; 217 struct xc2028_ctrl ctl;
213 struct xc2028_config cfg; 218 struct xc2028_config cfg;
214 219
215 memset (&cfg, 0, sizeof(cfg)); 220 memset(&cfg, 0, sizeof(cfg));
216 cfg.i2c_adap = &dev->i2c_adap; 221 cfg.i2c_adap = &dev->i2c_adap;
217 cfg.i2c_addr = addr; 222 cfg.i2c_addr = addr;
218 cfg.ctrl = &ctl; 223 cfg.ctrl = &ctl;
@@ -360,8 +365,9 @@ static int dvb_init(struct em28xx *dev)
360 struct em28xx_dvb *dvb; 365 struct em28xx_dvb *dvb;
361 366
362 dvb = kzalloc(sizeof(struct em28xx_dvb), GFP_KERNEL); 367 dvb = kzalloc(sizeof(struct em28xx_dvb), GFP_KERNEL);
363 if(dvb == NULL) { 368
364 printk("em28xx_dvb: memory allocation failed\n"); 369 if (dvb == NULL) {
370 printk(KERN_INFO "em28xx_dvb: memory allocation failed\n");
365 return -ENOMEM; 371 return -ENOMEM;
366 } 372 }
367 dev->dvb = dvb; 373 dev->dvb = dvb;
@@ -410,9 +416,8 @@ static int dvb_init(struct em28xx *dev)
410 /* register everything */ 416 /* register everything */
411 result = register_dvb(dvb, THIS_MODULE, dev, &dev->udev->dev); 417 result = register_dvb(dvb, THIS_MODULE, dev, &dev->udev->dev);
412 418
413 if (result < 0) { 419 if (result < 0)
414 goto out_free; 420 goto out_free;
415 }
416 421
417 printk(KERN_INFO "Successfully loaded em28xx-dvb\n"); 422 printk(KERN_INFO "Successfully loaded em28xx-dvb\n");
418 return 0; 423 return 0;
diff --git a/drivers/media/video/em28xx/em28xx-i2c.c b/drivers/media/video/em28xx/em28xx-i2c.c
index 6e1b7b4e7668..6a78fd294cab 100644
--- a/drivers/media/video/em28xx/em28xx-i2c.c
+++ b/drivers/media/video/em28xx/em28xx-i2c.c
@@ -41,11 +41,21 @@ static unsigned int i2c_debug;
41module_param(i2c_debug, int, 0644); 41module_param(i2c_debug, int, 0644);
42MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]"); 42MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]");
43 43
44#define dprintk1(lvl,fmt, args...) if (i2c_debug>=lvl) do {\ 44
45 printk(fmt, ##args); } while (0) 45#define dprintk1(lvl, fmt, args...) \
46#define dprintk2(lvl,fmt, args...) if (i2c_debug>=lvl) do{ \ 46do { \
47 printk(KERN_DEBUG "%s at %s: " fmt, \ 47 if (i2c_debug >= lvl) { \
48 dev->name, __func__ , ##args); } while (0) 48 printk(fmt, ##args); \
49 } \
50} while (0)
51
52#define dprintk2(lvl, fmt, args...) \
53do { \
54 if (i2c_debug >= lvl) { \
55 printk(KERN_DEBUG "%s at %s: " fmt, \
56 dev->name, __func__ , ##args); \
57 } \
58} while (0)
49 59
50/* 60/*
51 * em2800_i2c_send_max4() 61 * em2800_i2c_send_max4()
@@ -235,16 +245,16 @@ static int em28xx_i2c_xfer(struct i2c_adapter *i2c_adap,
235 return 0; 245 return 0;
236 for (i = 0; i < num; i++) { 246 for (i = 0; i < num; i++) {
237 addr = msgs[i].addr << 1; 247 addr = msgs[i].addr << 1;
238 dprintk2(2,"%s %s addr=%x len=%d:", 248 dprintk2(2, "%s %s addr=%x len=%d:",
239 (msgs[i].flags & I2C_M_RD) ? "read" : "write", 249 (msgs[i].flags & I2C_M_RD) ? "read" : "write",
240 i == num - 1 ? "stop" : "nonstop", addr, msgs[i].len); 250 i == num - 1 ? "stop" : "nonstop", addr, msgs[i].len);
241 if (!msgs[i].len) { /* no len: check only for device presence */ 251 if (!msgs[i].len) { /* no len: check only for device presence */
242 if (dev->is_em2800) 252 if (dev->is_em2800)
243 rc = em2800_i2c_check_for_device(dev, addr); 253 rc = em2800_i2c_check_for_device(dev, addr);
244 else 254 else
245 rc = em28xx_i2c_check_for_device(dev, addr); 255 rc = em28xx_i2c_check_for_device(dev, addr);
246 if (rc < 0) { 256 if (rc < 0) {
247 dprintk2(2," no device\n"); 257 dprintk2(2, " no device\n");
248 return rc; 258 return rc;
249 } 259 }
250 260
@@ -258,14 +268,13 @@ static int em28xx_i2c_xfer(struct i2c_adapter *i2c_adap,
258 rc = em28xx_i2c_recv_bytes(dev, addr, 268 rc = em28xx_i2c_recv_bytes(dev, addr,
259 msgs[i].buf, 269 msgs[i].buf,
260 msgs[i].len); 270 msgs[i].len);
261 if (i2c_debug>=2) { 271 if (i2c_debug >= 2) {
262 for (byte = 0; byte < msgs[i].len; byte++) { 272 for (byte = 0; byte < msgs[i].len; byte++)
263 printk(" %02x", msgs[i].buf[byte]); 273 printk(" %02x", msgs[i].buf[byte]);
264 }
265 } 274 }
266 } else { 275 } else {
267 /* write bytes */ 276 /* write bytes */
268 if (i2c_debug>=2) { 277 if (i2c_debug >= 2) {
269 for (byte = 0; byte < msgs[i].len; byte++) 278 for (byte = 0; byte < msgs[i].len; byte++)
270 printk(" %02x", msgs[i].buf[byte]); 279 printk(" %02x", msgs[i].buf[byte]);
271 } 280 }
@@ -281,13 +290,13 @@ static int em28xx_i2c_xfer(struct i2c_adapter *i2c_adap,
281 } 290 }
282 if (rc < 0) 291 if (rc < 0)
283 goto err; 292 goto err;
284 if (i2c_debug>=2) 293 if (i2c_debug >= 2)
285 printk("\n"); 294 printk("\n");
286 } 295 }
287 296
288 return num; 297 return num;
289 err: 298err:
290 dprintk2(2," ERROR: %i\n", rc); 299 dprintk2(2, " ERROR: %i\n", rc);
291 return rc; 300 return rc;
292} 301}
293 302
@@ -330,7 +339,9 @@ static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned char *eedata, int len)
330 return -1; 339 return -1;
331 340
332 buf = 0; 341 buf = 0;
333 if (1 != (err = i2c_master_send(&dev->i2c_client, &buf, 1))) { 342
343 err = i2c_master_send(&dev->i2c_client, &buf, 1);
344 if (err != 1) {
334 printk(KERN_INFO "%s: Huh, no eeprom present (err=%d)?\n", 345 printk(KERN_INFO "%s: Huh, no eeprom present (err=%d)?\n",
335 dev->name, err); 346 dev->name, err);
336 return -1; 347 return -1;
@@ -403,8 +414,10 @@ static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned char *eedata, int len)
403 break; 414 break;
404 } 415 }
405 printk(KERN_INFO "Table at 0x%02x, strings=0x%04x, 0x%04x, 0x%04x\n", 416 printk(KERN_INFO "Table at 0x%02x, strings=0x%04x, 0x%04x, 0x%04x\n",
406 em_eeprom->string_idx_table,em_eeprom->string1, 417 em_eeprom->string_idx_table,
407 em_eeprom->string2,em_eeprom->string3); 418 em_eeprom->string1,
419 em_eeprom->string2,
420 em_eeprom->string3);
408 421
409 return 0; 422 return 0;
410} 423}
@@ -430,58 +443,61 @@ static int attach_inform(struct i2c_client *client)
430 struct em28xx *dev = client->adapter->algo_data; 443 struct em28xx *dev = client->adapter->algo_data;
431 444
432 switch (client->addr << 1) { 445 switch (client->addr << 1) {
433 case 0x86: 446 case 0x86:
434 case 0x84: 447 case 0x84:
435 case 0x96: 448 case 0x96:
436 case 0x94: 449 case 0x94:
437 { 450 {
438 struct v4l2_priv_tun_config tda9887_cfg; 451 struct v4l2_priv_tun_config tda9887_cfg;
439 452
440 struct tuner_setup tun_setup; 453 struct tuner_setup tun_setup;
441 454
442 tun_setup.mode_mask = T_ANALOG_TV | T_RADIO; 455 tun_setup.mode_mask = T_ANALOG_TV | T_RADIO;
443 tun_setup.type = TUNER_TDA9887; 456 tun_setup.type = TUNER_TDA9887;
444 tun_setup.addr = client->addr; 457 tun_setup.addr = client->addr;
445 458
446 em28xx_i2c_call_clients(dev, TUNER_SET_TYPE_ADDR, &tun_setup); 459 em28xx_i2c_call_clients(dev, TUNER_SET_TYPE_ADDR,
447 460 &tun_setup);
448 tda9887_cfg.tuner = TUNER_TDA9887; 461
449 tda9887_cfg.priv = &dev->tda9887_conf; 462 tda9887_cfg.tuner = TUNER_TDA9887;
450 em28xx_i2c_call_clients(dev, TUNER_SET_CONFIG, 463 tda9887_cfg.priv = &dev->tda9887_conf;
451 &tda9887_cfg); 464 em28xx_i2c_call_clients(dev, TUNER_SET_CONFIG,
452 break; 465 &tda9887_cfg);
453 } 466 break;
454 case 0x42: 467 }
455 dprintk1(1,"attach_inform: saa7114 detected.\n"); 468 case 0x42:
456 break; 469 dprintk1(1, "attach_inform: saa7114 detected.\n");
457 case 0x4a: 470 break;
458 dprintk1(1,"attach_inform: saa7113 detected.\n"); 471 case 0x4a:
459 break; 472 dprintk1(1, "attach_inform: saa7113 detected.\n");
460 case 0xa0: 473 break;
461 dprintk1(1,"attach_inform: eeprom detected.\n"); 474 case 0xa0:
462 break; 475 dprintk1(1, "attach_inform: eeprom detected.\n");
463 case 0x60: 476 break;
464 case 0x8e: 477 case 0x60:
465 { 478 case 0x8e:
466 struct IR_i2c *ir = i2c_get_clientdata(client); 479 {
467 dprintk1(1,"attach_inform: IR detected (%s).\n",ir->phys); 480 struct IR_i2c *ir = i2c_get_clientdata(client);
468 em28xx_set_ir(dev,ir); 481 dprintk1(1, "attach_inform: IR detected (%s).\n",
469 break; 482 ir->phys);
470 } 483 em28xx_set_ir(dev, ir);
471 case 0x80: 484 break;
472 case 0x88: 485 }
473 dprintk1(1,"attach_inform: msp34xx detected.\n"); 486 case 0x80:
474 break; 487 case 0x88:
475 case 0xb8: 488 dprintk1(1, "attach_inform: msp34xx detected.\n");
476 case 0xba: 489 break;
477 dprintk1(1,"attach_inform: tvp5150 detected.\n"); 490 case 0xb8:
478 break; 491 case 0xba:
479 492 dprintk1(1, "attach_inform: tvp5150 detected.\n");
480 default: 493 break;
481 if (!dev->tuner_addr) 494
482 dev->tuner_addr = client->addr; 495 default:
483 496 if (!dev->tuner_addr)
484 dprintk1(1,"attach inform: detected I2C address %x\n", client->addr << 1); 497 dev->tuner_addr = client->addr;
498
499 dprintk1(1, "attach inform: detected I2C address %x\n",
500 client->addr << 1);
485 501
486 } 502 }
487 503
diff --git a/drivers/media/video/em28xx/em28xx-input.c b/drivers/media/video/em28xx/em28xx-input.c
index 10da2fd8d987..bb5807159b8d 100644
--- a/drivers/media/video/em28xx/em28xx-input.c
+++ b/drivers/media/video/em28xx/em28xx-input.c
@@ -32,10 +32,12 @@
32 32
33static unsigned int ir_debug; 33static unsigned int ir_debug;
34module_param(ir_debug, int, 0644); 34module_param(ir_debug, int, 0644);
35MODULE_PARM_DESC(ir_debug,"enable debug messages [IR]"); 35MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]");
36 36
37#define dprintk(fmt, arg...) if (ir_debug) \ 37#define dprintk(fmt, arg...) \
38 printk(KERN_DEBUG "%s/ir: " fmt, ir->c.name , ## arg) 38 if (ir_debug) { \
39 printk(KERN_DEBUG "%s/ir: " fmt, ir->c.name , ## arg); \
40 }
39 41
40/* ----------------------------------------------------------------------- */ 42/* ----------------------------------------------------------------------- */
41 43
@@ -44,7 +46,7 @@ int em28xx_get_key_terratec(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
44 unsigned char b; 46 unsigned char b;
45 47
46 /* poll IR chip */ 48 /* poll IR chip */
47 if (1 != i2c_master_recv(&ir->c,&b,1)) { 49 if (1 != i2c_master_recv(&ir->c, &b, 1)) {
48 dprintk("read error\n"); 50 dprintk("read error\n");
49 return -EIO; 51 return -EIO;
50 } 52 }
@@ -74,24 +76,25 @@ int em28xx_get_key_em_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
74 unsigned char code; 76 unsigned char code;
75 77
76 /* poll IR chip */ 78 /* poll IR chip */
77 if (2 != i2c_master_recv(&ir->c,buf,2)) 79 if (2 != i2c_master_recv(&ir->c, buf, 2))
78 return -EIO; 80 return -EIO;
79 81
80 /* Does eliminate repeated parity code */ 82 /* Does eliminate repeated parity code */
81 if (buf[1]==0xff) 83 if (buf[1] == 0xff)
82 return 0; 84 return 0;
83 85
84 ir->old=buf[1]; 86 ir->old = buf[1];
85 87
86 /* Rearranges bits to the right order */ 88 /* Rearranges bits to the right order */
87 code= ((buf[0]&0x01)<<5) | /* 0010 0000 */ 89 code = ((buf[0]&0x01)<<5) | /* 0010 0000 */
88 ((buf[0]&0x02)<<3) | /* 0001 0000 */ 90 ((buf[0]&0x02)<<3) | /* 0001 0000 */
89 ((buf[0]&0x04)<<1) | /* 0000 1000 */ 91 ((buf[0]&0x04)<<1) | /* 0000 1000 */
90 ((buf[0]&0x08)>>1) | /* 0000 0100 */ 92 ((buf[0]&0x08)>>1) | /* 0000 0100 */
91 ((buf[0]&0x10)>>3) | /* 0000 0010 */ 93 ((buf[0]&0x10)>>3) | /* 0000 0010 */
92 ((buf[0]&0x20)>>5); /* 0000 0001 */ 94 ((buf[0]&0x20)>>5); /* 0000 0001 */
93 95
94 dprintk("ir hauppauge (em2840): code=0x%02x (rcv=0x%02x)\n",code,buf[0]); 96 dprintk("ir hauppauge (em2840): code=0x%02x (rcv=0x%02x)\n",
97 code, buf[0]);
95 98
96 /* return key */ 99 /* return key */
97 *ir_key = code; 100 *ir_key = code;
@@ -106,15 +109,14 @@ int em28xx_get_key_pinnacle_usb_grey(struct IR_i2c *ir, u32 *ir_key,
106 109
107 /* poll IR chip */ 110 /* poll IR chip */
108 111
109 if (3 != i2c_master_recv(&ir->c,buf,3)) { 112 if (3 != i2c_master_recv(&ir->c, buf, 3)) {
110 dprintk("read error\n"); 113 dprintk("read error\n");
111 return -EIO; 114 return -EIO;
112 } 115 }
113 116
114 dprintk("key %02x\n", buf[2]&0x3f); 117 dprintk("key %02x\n", buf[2]&0x3f);
115 if (buf[0]!=0x00){ 118 if (buf[0] != 0x00)
116 return 0; 119 return 0;
117 }
118 120
119 *ir_key = buf[2]&0x3f; 121 *ir_key = buf[2]&0x3f;
120 *ir_raw = buf[2]&0x3f; 122 *ir_raw = buf[2]&0x3f;
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index ffbc91f2ecbd..1ac90322d681 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -1,5 +1,6 @@
1/* 1/*
2 em28xx-video.c - driver for Empia EM2800/EM2820/2840 USB video capture devices 2 em28xx-video.c - driver for Empia EM2800/EM2820/2840 USB
3 video capture devices
3 4
4 Copyright (C) 2005 Ludovico Cavedon <cavedon@sssup.it> 5 Copyright (C) 2005 Ludovico Cavedon <cavedon@sssup.it>
5 Markus Rechberger <mrechberger@gmail.com> 6 Markus Rechberger <mrechberger@gmail.com>
@@ -58,10 +59,13 @@ static unsigned int isoc_debug;
58module_param(isoc_debug, int, 0644); 59module_param(isoc_debug, int, 0644);
59MODULE_PARM_DESC(isoc_debug, "enable debug messages [isoc transfers]"); 60MODULE_PARM_DESC(isoc_debug, "enable debug messages [isoc transfers]");
60 61
61#define em28xx_isocdbg(fmt, arg...) do {\ 62#define em28xx_isocdbg(fmt, arg...) \
62 if (isoc_debug) \ 63do {\
64 if (isoc_debug) { \
63 printk(KERN_INFO "%s %s :"fmt, \ 65 printk(KERN_INFO "%s %s :"fmt, \
64 dev->name, __func__ , ##arg); } while (0) 66 dev->name, __func__ , ##arg); \
67 } \
68 } while (0)
65 69
66MODULE_AUTHOR(DRIVER_AUTHOR); 70MODULE_AUTHOR(DRIVER_AUTHOR);
67MODULE_DESCRIPTION(DRIVER_DESC); 71MODULE_DESCRIPTION(DRIVER_DESC);
@@ -84,8 +88,8 @@ MODULE_PARM_DESC(vbi_nr, "vbi device numbers");
84MODULE_PARM_DESC(radio_nr, "radio device numbers"); 88MODULE_PARM_DESC(radio_nr, "radio device numbers");
85 89
86static unsigned int video_debug; 90static unsigned int video_debug;
87module_param(video_debug,int,0644); 91module_param(video_debug, int, 0644);
88MODULE_PARM_DESC(video_debug,"enable debug messages [video]"); 92MODULE_PARM_DESC(video_debug, "enable debug messages [video]");
89 93
90/* Bitmask marking allocated devices from 0 to EM28XX_MAXBOARDS */ 94/* Bitmask marking allocated devices from 0 to EM28XX_MAXBOARDS */
91static unsigned long em28xx_devused; 95static unsigned long em28xx_devused;
@@ -102,7 +106,7 @@ static struct v4l2_queryctrl em28xx_qctrl[] = {
102 .step = 0x1, 106 .step = 0x1,
103 .default_value = 0x1f, 107 .default_value = 0x1f,
104 .flags = 0, 108 .flags = 0,
105 },{ 109 }, {
106 .id = V4L2_CID_AUDIO_MUTE, 110 .id = V4L2_CID_AUDIO_MUTE,
107 .type = V4L2_CTRL_TYPE_BOOLEAN, 111 .type = V4L2_CTRL_TYPE_BOOLEAN,
108 .name = "Mute", 112 .name = "Mute",
@@ -390,7 +394,7 @@ buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size)
390 dev->mode = EM28XX_ANALOG_MODE; 394 dev->mode = EM28XX_ANALOG_MODE;
391 395
392 /* Ask tuner to go to analog mode */ 396 /* Ask tuner to go to analog mode */
393 memset (&f, 0, sizeof(f)); 397 memset(&f, 0, sizeof(f));
394 f.frequency = dev->ctl_freq; 398 f.frequency = dev->ctl_freq;
395 399
396 em28xx_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, &f); 400 em28xx_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, &f);
@@ -483,7 +487,8 @@ buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
483 487
484} 488}
485 489
486static void buffer_release(struct videobuf_queue *vq, struct videobuf_buffer *vb) 490static void buffer_release(struct videobuf_queue *vq,
491 struct videobuf_buffer *vb)
487{ 492{
488 struct em28xx_buffer *buf = container_of(vb, struct em28xx_buffer, vb); 493 struct em28xx_buffer *buf = container_of(vb, struct em28xx_buffer, vb);
489 struct em28xx_fh *fh = vq->priv_data; 494 struct em28xx_fh *fh = vq->priv_data;
@@ -501,7 +506,7 @@ static struct videobuf_queue_ops em28xx_video_qops = {
501 .buf_release = buffer_release, 506 .buf_release = buffer_release,
502}; 507};
503 508
504/********************* v4l2 interface ******************************************/ 509/********************* v4l2 interface **************************************/
505 510
506/* 511/*
507 * em28xx_config() 512 * em28xx_config()
@@ -516,9 +521,9 @@ static int em28xx_config(struct em28xx *dev)
516 521
517 /* enable vbi capturing */ 522 /* enable vbi capturing */
518 523
519/* em28xx_write_regs_req(dev,0x00,0x0e,"\xC0",1); audio register */ 524/* em28xx_write_regs_req(dev, 0x00, 0x0e, "\xC0", 1); audio register */
520/* em28xx_write_regs_req(dev,0x00,0x0f,"\x80",1); clk register */ 525/* em28xx_write_regs_req(dev, 0x00, 0x0f, "\x80", 1); clk register */
521 em28xx_write_regs_req(dev,0x00,0x11,"\x51",1); 526 em28xx_write_regs_req(dev, 0x00, 0x11, "\x51", 1);
522 527
523 dev->mute = 1; /* maybe not the right place... */ 528 dev->mute = 1; /* maybe not the right place... */
524 dev->volume = 0x1f; 529 dev->volume = 0x1f;
@@ -557,12 +562,15 @@ static void video_mux(struct em28xx *dev, int index)
557 em28xx_i2c_call_clients(dev, VIDIOC_INT_S_VIDEO_ROUTING, &route); 562 em28xx_i2c_call_clients(dev, VIDIOC_INT_S_VIDEO_ROUTING, &route);
558 563
559 if (dev->has_msp34xx) { 564 if (dev->has_msp34xx) {
560 if (dev->i2s_speed) 565 if (dev->i2s_speed) {
561 em28xx_i2c_call_clients(dev, VIDIOC_INT_I2S_CLOCK_FREQ, &dev->i2s_speed); 566 em28xx_i2c_call_clients(dev, VIDIOC_INT_I2S_CLOCK_FREQ,
567 &dev->i2s_speed);
568 }
562 route.input = dev->ctl_ainput; 569 route.input = dev->ctl_ainput;
563 route.output = MSP_OUTPUT(MSP_SC_IN_DSP_SCART1); 570 route.output = MSP_OUTPUT(MSP_SC_IN_DSP_SCART1);
564 /* Note: this is msp3400 specific */ 571 /* Note: this is msp3400 specific */
565 em28xx_i2c_call_clients(dev, VIDIOC_INT_S_AUDIO_ROUTING, &route); 572 em28xx_i2c_call_clients(dev, VIDIOC_INT_S_AUDIO_ROUTING,
573 &route);
566 } 574 }
567 575
568 em28xx_audio_analog_set(dev); 576 em28xx_audio_analog_set(dev);
@@ -802,7 +810,7 @@ out:
802 return rc; 810 return rc;
803} 811}
804 812
805static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *norm) 813static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id * norm)
806{ 814{
807 struct em28xx_fh *fh = priv; 815 struct em28xx_fh *fh = priv;
808 struct em28xx *dev = fh->dev; 816 struct em28xx *dev = fh->dev;
@@ -919,11 +927,11 @@ static int vidioc_g_audio(struct file *file, void *priv, struct v4l2_audio *a)
919 927
920 index = dev->ctl_ainput; 928 index = dev->ctl_ainput;
921 929
922 if (index == 0) { 930 if (index == 0)
923 strcpy(a->name, "Television"); 931 strcpy(a->name, "Television");
924 } else { 932 else
925 strcpy(a->name, "Line In"); 933 strcpy(a->name, "Line In");
926 } 934
927 a->capability = V4L2_AUDCAP_STEREO; 935 a->capability = V4L2_AUDCAP_STEREO;
928 a->index = index; 936 a->index = index;
929 937
@@ -1501,7 +1509,7 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
1501{ 1509{
1502 int minor = iminor(inode); 1510 int minor = iminor(inode);
1503 int errCode = 0, radio = 0; 1511 int errCode = 0, radio = 0;
1504 struct em28xx *h,*dev = NULL; 1512 struct em28xx *h, *dev = NULL;
1505 struct em28xx_fh *fh; 1513 struct em28xx_fh *fh;
1506 enum v4l2_buf_type fh_type = 0; 1514 enum v4l2_buf_type fh_type = 0;
1507 1515
@@ -1602,12 +1610,13 @@ static void em28xx_release_resources(struct em28xx *dev)
1602 usb_put_dev(dev->udev); 1610 usb_put_dev(dev->udev);
1603 1611
1604 /* Mark device as unused */ 1612 /* Mark device as unused */
1605 em28xx_devused&=~(1<<dev->devno); 1613 em28xx_devused &= ~(1<<dev->devno);
1606} 1614}
1607 1615
1608/* 1616/*
1609 * em28xx_v4l2_close() 1617 * em28xx_v4l2_close()
1610 * stops streaming and deallocates all resources allocated by the v4l2 calls and ioctls 1618 * stops streaming and deallocates all resources allocated by the v4l2
1619 * calls and ioctls
1611 */ 1620 */
1612static int em28xx_v4l2_close(struct inode *inode, struct file *filp) 1621static int em28xx_v4l2_close(struct inode *inode, struct file *filp)
1613{ 1622{
@@ -1660,7 +1669,7 @@ static int em28xx_v4l2_close(struct inode *inode, struct file *filp)
1660 * will allocate buffers when called for the first time 1669 * will allocate buffers when called for the first time
1661 */ 1670 */
1662static ssize_t 1671static ssize_t
1663em28xx_v4l2_read(struct file *filp, char __user * buf, size_t count, 1672em28xx_v4l2_read(struct file *filp, char __user *buf, size_t count,
1664 loff_t *pos) 1673 loff_t *pos)
1665{ 1674{
1666 struct em28xx_fh *fh = filp->private_data; 1675 struct em28xx_fh *fh = filp->private_data;
@@ -1825,7 +1834,7 @@ static struct video_device em28xx_radio_template = {
1825#endif 1834#endif
1826}; 1835};
1827 1836
1828/******************************** usb interface *****************************************/ 1837/******************************** usb interface ******************************/
1829 1838
1830 1839
1831static LIST_HEAD(em28xx_extension_devlist); 1840static LIST_HEAD(em28xx_extension_devlist);
@@ -2088,22 +2097,24 @@ static int em28xx_usb_probe(struct usb_interface *interface,
2088 ifnum = interface->altsetting[0].desc.bInterfaceNumber; 2097 ifnum = interface->altsetting[0].desc.bInterfaceNumber;
2089 2098
2090 /* Check to see next free device and mark as used */ 2099 /* Check to see next free device and mark as used */
2091 nr=find_first_zero_bit(&em28xx_devused,EM28XX_MAXBOARDS); 2100 nr = find_first_zero_bit(&em28xx_devused, EM28XX_MAXBOARDS);
2092 em28xx_devused|=1<<nr; 2101 em28xx_devused |= 1<<nr;
2093 2102
2094 /* Don't register audio interfaces */ 2103 /* Don't register audio interfaces */
2095 if (interface->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) { 2104 if (interface->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) {
2096 em28xx_err(DRIVER_NAME " audio device (%04x:%04x): interface %i, class %i\n", 2105 em28xx_err(DRIVER_NAME " audio device (%04x:%04x): interface %i, class %i\n",
2097 udev->descriptor.idVendor,udev->descriptor.idProduct, 2106 udev->descriptor.idVendor,
2107 udev->descriptor.idProduct,
2098 ifnum, 2108 ifnum,
2099 interface->altsetting[0].desc.bInterfaceClass); 2109 interface->altsetting[0].desc.bInterfaceClass);
2100 2110
2101 em28xx_devused&=~(1<<nr); 2111 em28xx_devused &= ~(1<<nr);
2102 return -ENODEV; 2112 return -ENODEV;
2103 } 2113 }
2104 2114
2105 em28xx_err(DRIVER_NAME " new video device (%04x:%04x): interface %i, class %i\n", 2115 em28xx_err(DRIVER_NAME " new video device (%04x:%04x): interface %i, class %i\n",
2106 udev->descriptor.idVendor,udev->descriptor.idProduct, 2116 udev->descriptor.idVendor,
2117 udev->descriptor.idProduct,
2107 ifnum, 2118 ifnum,
2108 interface->altsetting[0].desc.bInterfaceClass); 2119 interface->altsetting[0].desc.bInterfaceClass);
2109 2120
@@ -2113,18 +2124,19 @@ static int em28xx_usb_probe(struct usb_interface *interface,
2113 if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != 2124 if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) !=
2114 USB_ENDPOINT_XFER_ISOC) { 2125 USB_ENDPOINT_XFER_ISOC) {
2115 em28xx_err(DRIVER_NAME " probing error: endpoint is non-ISO endpoint!\n"); 2126 em28xx_err(DRIVER_NAME " probing error: endpoint is non-ISO endpoint!\n");
2116 em28xx_devused&=~(1<<nr); 2127 em28xx_devused &= ~(1<<nr);
2117 return -ENODEV; 2128 return -ENODEV;
2118 } 2129 }
2119 if ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT) { 2130 if ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT) {
2120 em28xx_err(DRIVER_NAME " probing error: endpoint is ISO OUT endpoint!\n"); 2131 em28xx_err(DRIVER_NAME " probing error: endpoint is ISO OUT endpoint!\n");
2121 em28xx_devused&=~(1<<nr); 2132 em28xx_devused &= ~(1<<nr);
2122 return -ENODEV; 2133 return -ENODEV;
2123 } 2134 }
2124 2135
2125 if (nr >= EM28XX_MAXBOARDS) { 2136 if (nr >= EM28XX_MAXBOARDS) {
2126 printk (DRIVER_NAME ": Supports only %i em28xx boards.\n",EM28XX_MAXBOARDS); 2137 printk(DRIVER_NAME ": Supports only %i em28xx boards.\n",
2127 em28xx_devused&=~(1<<nr); 2138 EM28XX_MAXBOARDS);
2139 em28xx_devused &= ~(1<<nr);
2128 return -ENOMEM; 2140 return -ENOMEM;
2129 } 2141 }
2130 2142
@@ -2132,7 +2144,7 @@ static int em28xx_usb_probe(struct usb_interface *interface,
2132 dev = kzalloc(sizeof(*dev), GFP_KERNEL); 2144 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
2133 if (dev == NULL) { 2145 if (dev == NULL) {
2134 em28xx_err(DRIVER_NAME ": out of memory!\n"); 2146 em28xx_err(DRIVER_NAME ": out of memory!\n");
2135 em28xx_devused&=~(1<<nr); 2147 em28xx_devused &= ~(1<<nr);
2136 return -ENOMEM; 2148 return -ENOMEM;
2137 } 2149 }
2138 2150
@@ -2156,14 +2168,14 @@ static int em28xx_usb_probe(struct usb_interface *interface,
2156 /* compute alternate max packet sizes */ 2168 /* compute alternate max packet sizes */
2157 uif = udev->actconfig->interface[0]; 2169 uif = udev->actconfig->interface[0];
2158 2170
2159 dev->num_alt=uif->num_altsetting; 2171 dev->num_alt = uif->num_altsetting;
2160 em28xx_info("Alternate settings: %i\n",dev->num_alt); 2172 em28xx_info("Alternate settings: %i\n", dev->num_alt);
2161// dev->alt_max_pkt_size = kmalloc(sizeof(*dev->alt_max_pkt_size)* 2173/* dev->alt_max_pkt_size = kmalloc(sizeof(*dev->alt_max_pkt_size)* */
2162 dev->alt_max_pkt_size = kmalloc(32* 2174 dev->alt_max_pkt_size = kmalloc(32 * dev->num_alt, GFP_KERNEL);
2163 dev->num_alt,GFP_KERNEL); 2175
2164 if (dev->alt_max_pkt_size == NULL) { 2176 if (dev->alt_max_pkt_size == NULL) {
2165 em28xx_errdev("out of memory!\n"); 2177 em28xx_errdev("out of memory!\n");
2166 em28xx_devused&=~(1<<nr); 2178 em28xx_devused &= ~(1<<nr);
2167 kfree(dev); 2179 kfree(dev);
2168 return -ENOMEM; 2180 return -ENOMEM;
2169 } 2181 }
@@ -2173,11 +2185,11 @@ static int em28xx_usb_probe(struct usb_interface *interface,
2173 wMaxPacketSize); 2185 wMaxPacketSize);
2174 dev->alt_max_pkt_size[i] = 2186 dev->alt_max_pkt_size[i] =
2175 (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); 2187 (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1);
2176 em28xx_info("Alternate setting %i, max size= %i\n",i, 2188 em28xx_info("Alternate setting %i, max size= %i\n", i,
2177 dev->alt_max_pkt_size[i]); 2189 dev->alt_max_pkt_size[i]);
2178 } 2190 }
2179 2191
2180 if ((card[nr]>=0)&&(card[nr]<em28xx_bcount)) 2192 if ((card[nr] >= 0) && (card[nr] < em28xx_bcount))
2181 dev->model = card[nr]; 2193 dev->model = card[nr];
2182 2194
2183 /* allocate device struct */ 2195 /* allocate device struct */
@@ -2213,7 +2225,8 @@ static void em28xx_usb_disconnect(struct usb_interface *interface)
2213 2225
2214 em28xx_info("disconnecting %s\n", dev->vdev->name); 2226 em28xx_info("disconnecting %s\n", dev->vdev->name);
2215 2227
2216 /* wait until all current v4l2 io is finished then deallocate resources */ 2228 /* wait until all current v4l2 io is finished then deallocate
2229 resources */
2217 mutex_lock(&dev->lock); 2230 mutex_lock(&dev->lock);
2218 2231
2219 wake_up_interruptible_all(&dev->open); 2232 wake_up_interruptible_all(&dev->open);
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h
index 91dce95cd19c..5b21efaf7844 100644
--- a/drivers/media/video/em28xx/em28xx.h
+++ b/drivers/media/video/em28xx/em28xx.h
@@ -365,7 +365,8 @@ struct em28xx {
365 unsigned int video_bytesread; /* Number of bytes read */ 365 unsigned int video_bytesread; /* Number of bytes read */
366 366
367 unsigned long hash; /* eeprom hash - for boards with generic ID */ 367 unsigned long hash; /* eeprom hash - for boards with generic ID */
368 unsigned long i2c_hash; /* i2c devicelist hash - for boards with generic ID */ 368 unsigned long i2c_hash; /* i2c devicelist hash -
369 for boards with generic ID */
369 370
370 struct em28xx_audio *adev; 371 struct em28xx_audio *adev;
371 372
@@ -399,14 +400,14 @@ struct em28xx {
399 struct urb *urb[EM28XX_NUM_BUFS]; /* urb for isoc transfers */ 400 struct urb *urb[EM28XX_NUM_BUFS]; /* urb for isoc transfers */
400 char *transfer_buffer[EM28XX_NUM_BUFS]; /* transfer buffers for isoc transfer */ 401 char *transfer_buffer[EM28XX_NUM_BUFS]; /* transfer buffers for isoc transfer */
401 /* helper funcs that call usb_control_msg */ 402 /* helper funcs that call usb_control_msg */
402 int (*em28xx_write_regs) (struct em28xx * dev, u16 reg, char *buf, 403 int (*em28xx_write_regs) (struct em28xx *dev, u16 reg,
403 int len);
404 int (*em28xx_read_reg) (struct em28xx * dev, u16 reg);
405 int (*em28xx_read_reg_req_len) (struct em28xx * dev, u8 req, u16 reg,
406 char *buf, int len); 404 char *buf, int len);
407 int (*em28xx_write_regs_req) (struct em28xx * dev, u8 req, u16 reg, 405 int (*em28xx_read_reg) (struct em28xx *dev, u16 reg);
406 int (*em28xx_read_reg_req_len) (struct em28xx *dev, u8 req, u16 reg,
407 char *buf, int len);
408 int (*em28xx_write_regs_req) (struct em28xx *dev, u8 req, u16 reg,
408 char *buf, int len); 409 char *buf, int len);
409 int (*em28xx_read_reg_req) (struct em28xx * dev, u8 req, u16 reg); 410 int (*em28xx_read_reg_req) (struct em28xx *dev, u8 req, u16 reg);
410 411
411 enum em28xx_mode mode; 412 enum em28xx_mode mode;
412 413
@@ -459,7 +460,7 @@ int em28xx_register_extension(struct em28xx_ops *dev);
459void em28xx_unregister_extension(struct em28xx_ops *dev); 460void em28xx_unregister_extension(struct em28xx_ops *dev);
460 461
461/* Provided by em28xx-cards.c */ 462/* Provided by em28xx-cards.c */
462extern int em2800_variant_detect(struct usb_device* udev,int model); 463extern int em2800_variant_detect(struct usb_device *udev, int model);
463extern void em28xx_pre_card_setup(struct em28xx *dev); 464extern void em28xx_pre_card_setup(struct em28xx *dev);
464extern void em28xx_card_setup(struct em28xx *dev); 465extern void em28xx_card_setup(struct em28xx *dev);
465extern struct em28xx_board em28xx_boards[]; 466extern struct em28xx_board em28xx_boards[];
@@ -557,80 +558,80 @@ int em28xx_get_key_pinnacle_usb_grey(struct IR_i2c *ir, u32 *ir_key,
557 printk(KERN_WARNING "%s: "fmt,\ 558 printk(KERN_WARNING "%s: "fmt,\
558 dev->name , ##arg); } while (0) 559 dev->name , ##arg); } while (0)
559 560
560inline static int em28xx_compression_disable(struct em28xx *dev) 561static inline int em28xx_compression_disable(struct em28xx *dev)
561{ 562{
562 /* side effect of disabling scaler and mixer */ 563 /* side effect of disabling scaler and mixer */
563 return em28xx_write_regs(dev, COMPR_REG, "\x00", 1); 564 return em28xx_write_regs(dev, COMPR_REG, "\x00", 1);
564} 565}
565 566
566inline static int em28xx_contrast_get(struct em28xx *dev) 567static inline int em28xx_contrast_get(struct em28xx *dev)
567{ 568{
568 return em28xx_read_reg(dev, YGAIN_REG) & 0x1f; 569 return em28xx_read_reg(dev, YGAIN_REG) & 0x1f;
569} 570}
570 571
571inline static int em28xx_brightness_get(struct em28xx *dev) 572static inline int em28xx_brightness_get(struct em28xx *dev)
572{ 573{
573 return em28xx_read_reg(dev, YOFFSET_REG); 574 return em28xx_read_reg(dev, YOFFSET_REG);
574} 575}
575 576
576inline static int em28xx_saturation_get(struct em28xx *dev) 577static inline int em28xx_saturation_get(struct em28xx *dev)
577{ 578{
578 return em28xx_read_reg(dev, UVGAIN_REG) & 0x1f; 579 return em28xx_read_reg(dev, UVGAIN_REG) & 0x1f;
579} 580}
580 581
581inline static int em28xx_u_balance_get(struct em28xx *dev) 582static inline int em28xx_u_balance_get(struct em28xx *dev)
582{ 583{
583 return em28xx_read_reg(dev, UOFFSET_REG); 584 return em28xx_read_reg(dev, UOFFSET_REG);
584} 585}
585 586
586inline static int em28xx_v_balance_get(struct em28xx *dev) 587static inline int em28xx_v_balance_get(struct em28xx *dev)
587{ 588{
588 return em28xx_read_reg(dev, VOFFSET_REG); 589 return em28xx_read_reg(dev, VOFFSET_REG);
589} 590}
590 591
591inline static int em28xx_gamma_get(struct em28xx *dev) 592static inline int em28xx_gamma_get(struct em28xx *dev)
592{ 593{
593 return em28xx_read_reg(dev, GAMMA_REG) & 0x3f; 594 return em28xx_read_reg(dev, GAMMA_REG) & 0x3f;
594} 595}
595 596
596inline static int em28xx_contrast_set(struct em28xx *dev, s32 val) 597static inline int em28xx_contrast_set(struct em28xx *dev, s32 val)
597{ 598{
598 u8 tmp = (u8) val; 599 u8 tmp = (u8) val;
599 return em28xx_write_regs(dev, YGAIN_REG, &tmp, 1); 600 return em28xx_write_regs(dev, YGAIN_REG, &tmp, 1);
600} 601}
601 602
602inline static int em28xx_brightness_set(struct em28xx *dev, s32 val) 603static inline int em28xx_brightness_set(struct em28xx *dev, s32 val)
603{ 604{
604 u8 tmp = (u8) val; 605 u8 tmp = (u8) val;
605 return em28xx_write_regs(dev, YOFFSET_REG, &tmp, 1); 606 return em28xx_write_regs(dev, YOFFSET_REG, &tmp, 1);
606} 607}
607 608
608inline static int em28xx_saturation_set(struct em28xx *dev, s32 val) 609static inline int em28xx_saturation_set(struct em28xx *dev, s32 val)
609{ 610{
610 u8 tmp = (u8) val; 611 u8 tmp = (u8) val;
611 return em28xx_write_regs(dev, UVGAIN_REG, &tmp, 1); 612 return em28xx_write_regs(dev, UVGAIN_REG, &tmp, 1);
612} 613}
613 614
614inline static int em28xx_u_balance_set(struct em28xx *dev, s32 val) 615static inline int em28xx_u_balance_set(struct em28xx *dev, s32 val)
615{ 616{
616 u8 tmp = (u8) val; 617 u8 tmp = (u8) val;
617 return em28xx_write_regs(dev, UOFFSET_REG, &tmp, 1); 618 return em28xx_write_regs(dev, UOFFSET_REG, &tmp, 1);
618} 619}
619 620
620inline static int em28xx_v_balance_set(struct em28xx *dev, s32 val) 621static inline int em28xx_v_balance_set(struct em28xx *dev, s32 val)
621{ 622{
622 u8 tmp = (u8) val; 623 u8 tmp = (u8) val;
623 return em28xx_write_regs(dev, VOFFSET_REG, &tmp, 1); 624 return em28xx_write_regs(dev, VOFFSET_REG, &tmp, 1);
624} 625}
625 626
626inline static int em28xx_gamma_set(struct em28xx *dev, s32 val) 627static inline int em28xx_gamma_set(struct em28xx *dev, s32 val)
627{ 628{
628 u8 tmp = (u8) val; 629 u8 tmp = (u8) val;
629 return em28xx_write_regs(dev, GAMMA_REG, &tmp, 1); 630 return em28xx_write_regs(dev, GAMMA_REG, &tmp, 1);
630} 631}
631 632
632/*FIXME: maxw should be dependent of alt mode */ 633/*FIXME: maxw should be dependent of alt mode */
633inline static unsigned int norm_maxw(struct em28xx *dev) 634static inline unsigned int norm_maxw(struct em28xx *dev)
634{ 635{
635 if (dev->max_range_640_480) 636 if (dev->max_range_640_480)
636 return 640; 637 return 640;
@@ -638,7 +639,7 @@ inline static unsigned int norm_maxw(struct em28xx *dev)
638 return 720; 639 return 720;
639} 640}
640 641
641inline static unsigned int norm_maxh(struct em28xx *dev) 642static inline unsigned int norm_maxh(struct em28xx *dev)
642{ 643{
643 if (dev->max_range_640_480) 644 if (dev->max_range_640_480)
644 return 480; 645 return 480;