25 #include <linux/list.h>
26 #include <linux/module.h>
27 #include <linux/slab.h>
37 static unsigned int core_debug;
41 #define em28xx_coredbg(fmt, arg...) do {\
43 printk(KERN_INFO "%s %s :"fmt, \
44 dev->name, __func__ , ##arg); } while (0)
46 static unsigned int reg_debug;
50 #define em28xx_regdbg(fmt, arg...) do {\
52 printk(KERN_INFO "%s %s :"fmt, \
53 dev->name, __func__ , ##arg); } while (0)
59 static unsigned int disable_vbi;
64 #define em28xx_isocdbg(fmt, arg...) do {\
66 printk(KERN_INFO "%s %s :"fmt, \
67 dev->name, __func__ , ##arg); } while (0)
77 int pipe = usb_rcvctrlpipe(dev->
udev, 0);
87 "IN: %02x %02x %02x %02x %02x %02x %02x %02x ",
92 len & 0xff, len >> 8);
115 for (byte = 0; byte < len; byte++)
116 printk(
" %02x", (
unsigned char)buf[byte]);
153 int pipe = usb_sndctrlpipe(dev->
udev, 0);
165 "OUT: %02x %02x %02x %02x %02x %02x %02x %02x >>>",
169 reg & 0xff, reg >> 8,
170 len & 0xff, len >> 8);
172 for (byte = 0; byte < len; byte++)
173 printk(
" %02x", (
unsigned char)buf[byte]);
241 newval = (((
u8) oldval) & ~bitmask) | (val & bitmask);
251 static int em28xx_is_ac97_ready(
struct em28xx *
dev)
256 for (i = 0; i < 10; i++,
msleep(5)) {
265 em28xx_warn(
"AC97 command still being executed: not handled properly!\n");
276 u8 addr = (reg & 0x7f) | 0x80;
279 ret = em28xx_is_ac97_ready(dev);
288 (
u8 *)&val,
sizeof(val));
308 ret = em28xx_is_ac97_ready(dev);
339 static int set_ac97_input(
struct em28xx *dev)
352 if (amux == inputs[i].
mux)
364 static int em28xx_set_audio_source(
struct em28xx *dev)
369 if (dev->
board.is_em2800) {
380 if (dev->
board.has_msp34xx)
407 ret = set_ac97_input(dev);
447 xclk = dev->
board.xclk & 0x7f;
457 ret = em28xx_set_audio_source(dev);
468 vol = (0x1f - dev->
volume) | ((0x1f - dev->
volume) << 8);
517 em28xx_info(
"Config register raw data: 0x%02x\n", cfg);
526 }
else if ((cfg & EM28XX_CHIPCFG_AUDIOMASK) ==
530 }
else if ((cfg & EM28XX_CHIPCFG_AUDIOMASK) ==
551 em28xx_warn(
"AC97 chip type couldn't be determined\n");
562 vid = vid1 << 16 | vid2;
575 if (((vid == 0xffffffff) || (vid == 0x83847650)) && (feat == 0x6a90))
577 else if ((vid >> 8) == 0x838476)
587 em28xx_info(
"Empia 202 AC97 audio processor detected\n");
590 em28xx_info(
"Sigmatel audio processor detected(stac 97%02x)\n",
594 em28xx_warn(
"Unknown AC97 audio processor detected!\n");
648 start ? 0x10 : 0x00, 0x10);
658 if (dev->
board.is_webcam)
677 if (disable_vbi == 1)
694 dev->
format->reg | 0x20, 0xff);
724 xmin, ymin, xmax, ymax);
732 static int em28xx_capture_area_set(
struct em28xx *dev,
u8 hstart,
u8 vstart,
737 u8 overflow = (height >> 7 & 0x02) | (width >> 8 & 0x01);
740 (width | (overflow & 2) << 7),
741 (height | (overflow & 1) << 8));
755 if (dev->
board.is_em2800) {
756 mode = (v ? 0x20 : 0x00) | (h ? 0x10 : 0x00);
769 mode = (h ||
v) ? 0x30 : 0x00;
790 em28xx_accumulator_set(dev, 1, (width - 4) >> 2, 1, (height - 4) >> 2);
800 em28xx_capture_area_set(dev, 0, 2, width >> 2, height >> 2);
802 em28xx_capture_area_set(dev, 0, 0, width >> 2, height >> 2);
804 return em28xx_scaler_set(dev, dev->
hscale, dev->
vscale);
809 int errCode, prev_alt = dev->
alt;
811 unsigned int min_pkt_size = dev->
width * 2 + 4;
817 if (alt && alt < dev->num_alt) {
830 for (i = 0; i < dev->
num_alt; i++) {
844 if (dev->
alt != prev_alt) {
846 min_pkt_size, dev->
alt);
852 em28xx_errdev(
"cannot change alternate number to %d (error=%i)\n",
877 while (gpio->
sleep >= 0) {
878 if (gpio->
reg >= 0) {
897 if (dev->
mode == set_mode)
901 dev->
mode = set_mode;
908 dev->
mode = set_mode;
924 static void em28xx_irq_callback(
struct urb *
urb)
926 struct em28xx *dev = urb->context;
929 switch (urb->status) {
943 spin_lock(&dev->
slock);
945 spin_unlock(&dev->
slock);
948 for (i = 0; i < urb->number_of_packets; i++) {
949 urb->iso_frame_desc[
i].status = 0;
950 urb->iso_frame_desc[
i].actual_length = 0;
970 em28xx_isocdbg(
"em28xx: called em28xx_uninit_isoc in mode %d\n", mode);
973 isoc_bufs = &dev->
isoc_ctl.digital_bufs;
975 isoc_bufs = &dev->
isoc_ctl.analog_bufs;
977 for (i = 0; i < isoc_bufs->
num_bufs; i++) {
978 urb = isoc_bufs->
urb[
i];
987 urb->transfer_buffer_length,
1019 for (i = 0; i < isoc_bufs->
num_bufs; i++) {
1020 urb = isoc_bufs->
urb[
i];
1045 em28xx_isocdbg(
"em28xx: called em28xx_alloc_isoc in mode %d\n", mode);
1048 isoc_bufs = &dev->
isoc_ctl.digital_bufs;
1050 isoc_bufs = &dev->
isoc_ctl.analog_bufs;
1057 isoc_bufs->
urb = kzalloc(
sizeof(
void *)*num_bufs,
GFP_KERNEL);
1058 if (!isoc_bufs->
urb) {
1079 for (i = 0; i < isoc_bufs->
num_bufs; i++) {
1082 em28xx_err(
"cannot alloc isoc_ctl.urb %i\n", i);
1091 em28xx_err(
"unable to allocate %i bytes for transfer"
1104 pipe = usb_rcvisocpipe(dev->
udev,
1108 usb_fill_int_urb(urb, dev->
udev, pipe,
1110 em28xx_irq_callback, dev, 1);
1113 urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP;
1117 urb->iso_frame_desc[
j].offset =
k;
1118 urb->iso_frame_desc[
j].length =
1132 int max_packets,
int num_bufs,
int max_pkt_size,
1133 int (*isoc_copy) (
struct em28xx *dev,
struct urb *urb))
1142 em28xx_isocdbg(
"em28xx: called em28xx_init_isoc in mode %d\n", mode);
1144 dev->
isoc_ctl.isoc_copy = isoc_copy;
1147 isoc_bufs = &dev->
isoc_ctl.digital_bufs;
1151 isoc_bufs = &dev->
isoc_ctl.analog_bufs;
1157 num_bufs, max_pkt_size);
1168 for (i = 0; i < isoc_bufs->
num_bufs; i++) {
1171 em28xx_err(
"submit of urb %i failed (error=%i)\n", i,
1205 static LIST_HEAD(em28xx_extension_devlist);