aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/Makefile7
-rw-r--r--drivers/media/common/tuners/Kconfig1
-rw-r--r--drivers/media/common/tuners/mxl5005s.c4
-rw-r--r--drivers/media/common/tuners/tda18271-common.c4
-rw-r--r--drivers/media/common/tuners/tda827x.c4
-rw-r--r--drivers/media/common/tuners/tea5761.c2
-rw-r--r--drivers/media/common/tuners/tuner-i2c.h8
-rw-r--r--drivers/media/common/tuners/tuner-simple.c6
-rw-r--r--drivers/media/common/tuners/tuner-xc2028.c87
-rw-r--r--drivers/media/dvb/b2c2/flexcop-usb.c2
-rw-r--r--drivers/media/dvb/cinergyT2/cinergyT2.c46
-rw-r--r--drivers/media/dvb/dvb-core/dvb_net.c12
-rw-r--r--drivers/media/dvb/dvb-usb/Kconfig2
-rw-r--r--drivers/media/dvb/dvb-usb/dib0700_devices.c21
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-firmware.c2
-rw-r--r--drivers/media/dvb/dvb-usb/gp8psk.c10
-rw-r--r--drivers/media/dvb/dvb-usb/m920x.c7
-rw-r--r--drivers/media/dvb/frontends/dib0070.h15
-rw-r--r--drivers/media/dvb/frontends/dib7000p.h15
-rw-r--r--drivers/media/dvb/frontends/or51132.c6
-rw-r--r--drivers/media/dvb/ttpci/av7110.c9
-rw-r--r--drivers/media/dvb/ttpci/av7110_av.c34
-rw-r--r--drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c2
-rw-r--r--drivers/media/dvb/ttusb-dec/Kconfig2
-rw-r--r--drivers/media/dvb/ttusb-dec/ttusb_dec.c25
-rw-r--r--drivers/media/dvb/ttusb-dec/ttusbdecfe.c10
-rw-r--r--drivers/media/video/Kconfig2
-rw-r--r--drivers/media/video/au0828/Kconfig2
-rw-r--r--drivers/media/video/au0828/au0828-dvb.c6
-rw-r--r--drivers/media/video/bt8xx/bttv-cards.c5
-rw-r--r--drivers/media/video/bt8xx/bttv-driver.c2
-rw-r--r--drivers/media/video/bt8xx/bttv-risc.c8
-rw-r--r--drivers/media/video/btcx-risc.c2
-rw-r--r--drivers/media/video/btcx-risc.h4
-rw-r--r--drivers/media/video/cx18/cx18-av-core.c81
-rw-r--r--drivers/media/video/cx18/cx18-cards.c4
-rw-r--r--drivers/media/video/cx18/cx18-controls.c6
-rw-r--r--drivers/media/video/cx18/cx18-driver.c26
-rw-r--r--drivers/media/video/cx18/cx18-driver.h9
-rw-r--r--drivers/media/video/cx18/cx18-fileops.c13
-rw-r--r--drivers/media/video/cx18/cx18-gpio.c33
-rw-r--r--drivers/media/video/cx18/cx18-ioctl.c12
-rw-r--r--drivers/media/video/cx18/cx18-irq.c12
-rw-r--r--drivers/media/video/cx18/cx18-mailbox.c8
-rw-r--r--drivers/media/video/cx18/cx18-streams.c37
-rw-r--r--drivers/media/video/cx23885/cx23885-core.c8
-rw-r--r--drivers/media/video/cx88/cx88-cards.c13
-rw-r--r--drivers/media/video/cx88/cx88-core.c8
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c8
-rw-r--r--drivers/media/video/ivtv/ivtv-driver.h10
-rw-r--r--drivers/media/video/ivtv/ivtv-fileops.c2
-rw-r--r--drivers/media/video/ivtv/ivtv-irq.c8
-rw-r--r--drivers/media/video/ivtv/ivtv-queue.c2
-rw-r--r--drivers/media/video/ivtv/ivtv-streams.c30
-rw-r--r--drivers/media/video/ivtv/ivtv-version.h4
-rw-r--r--drivers/media/video/ivtv/ivtv-yuv.c2
-rw-r--r--drivers/media/video/ivtv/ivtv-yuv.h2
-rw-r--r--drivers/media/video/saa7134/saa7134-empress.c3
-rw-r--r--drivers/media/video/tuner-core.c60
-rw-r--r--drivers/media/video/usbvideo/quickcam_messenger.c2
-rw-r--r--drivers/media/video/videobuf-core.c3
-rw-r--r--drivers/media/video/zoran.h4
-rw-r--r--drivers/media/video/zoran_device.c2
-rw-r--r--drivers/media/video/zoran_driver.c10
64 files changed, 438 insertions, 358 deletions
diff --git a/drivers/media/Makefile b/drivers/media/Makefile
index cc11c4c0e7e7..09a829d8a7e7 100644
--- a/drivers/media/Makefile
+++ b/drivers/media/Makefile
@@ -2,12 +2,7 @@
2# Makefile for the kernel multimedia device drivers. 2# Makefile for the kernel multimedia device drivers.
3# 3#
4 4
5obj-y := common/ 5obj-y += common/ video/
6
7obj-$(CONFIG_VIDEO_MEDIA) += common/
8
9# Since hybrid devices are here, should be compiled if DVB and/or V4L
10obj-$(CONFIG_VIDEO_MEDIA) += video/
11 6
12obj-$(CONFIG_VIDEO_DEV) += radio/ 7obj-$(CONFIG_VIDEO_DEV) += radio/
13obj-$(CONFIG_DVB_CORE) += dvb/ 8obj-$(CONFIG_DVB_CORE) += dvb/
diff --git a/drivers/media/common/tuners/Kconfig b/drivers/media/common/tuners/Kconfig
index d6206540476b..85482960d012 100644
--- a/drivers/media/common/tuners/Kconfig
+++ b/drivers/media/common/tuners/Kconfig
@@ -21,6 +21,7 @@ config MEDIA_TUNER
21 tristate 21 tristate
22 default VIDEO_MEDIA && I2C 22 default VIDEO_MEDIA && I2C
23 depends on VIDEO_MEDIA && I2C 23 depends on VIDEO_MEDIA && I2C
24 select FW_LOADER if !MEDIA_TUNER_CUSTOMIZE && HOTPLUG
24 select MEDIA_TUNER_XC2028 if !MEDIA_TUNER_CUSTOMIZE && HOTPLUG 25 select MEDIA_TUNER_XC2028 if !MEDIA_TUNER_CUSTOMIZE && HOTPLUG
25 select MEDIA_TUNER_XC5000 if !MEDIA_TUNER_CUSTOMIZE && HOTPLUG 26 select MEDIA_TUNER_XC5000 if !MEDIA_TUNER_CUSTOMIZE && HOTPLUG
26 select MEDIA_TUNER_MT20XX if !MEDIA_TUNER_CUSTOMIZE 27 select MEDIA_TUNER_MT20XX if !MEDIA_TUNER_CUSTOMIZE
diff --git a/drivers/media/common/tuners/mxl5005s.c b/drivers/media/common/tuners/mxl5005s.c
index 5d05b5390f66..0dc2bef9f6a3 100644
--- a/drivers/media/common/tuners/mxl5005s.c
+++ b/drivers/media/common/tuners/mxl5005s.c
@@ -101,7 +101,7 @@ enum {
101 MXL_QAM, 101 MXL_QAM,
102 MXL_ANALOG_CABLE, 102 MXL_ANALOG_CABLE,
103 MXL_ANALOG_OTA 103 MXL_ANALOG_OTA
104} tuner_modu_type; 104};
105 105
106/* MXL5005 Tuner Register Struct */ 106/* MXL5005 Tuner Register Struct */
107struct TunerReg { 107struct TunerReg {
@@ -194,7 +194,7 @@ enum {
194 RFSYN_DIVM, /* 88 */ 194 RFSYN_DIVM, /* 88 */
195 DN_BYPASS_AGC_I2C /* 89 */ 195 DN_BYPASS_AGC_I2C /* 89 */
196#endif 196#endif
197} MXL5005_ControlName; 197};
198 198
199/* 199/*
200 * The following context is source code provided by MaxLinear. 200 * The following context is source code provided by MaxLinear.
diff --git a/drivers/media/common/tuners/tda18271-common.c b/drivers/media/common/tuners/tda18271-common.c
index 42b5f5d4bfe6..f1894fec32b9 100644
--- a/drivers/media/common/tuners/tda18271-common.c
+++ b/drivers/media/common/tuners/tda18271-common.c
@@ -648,11 +648,11 @@ int tda18271_calc_rf_cal(struct dvb_frontend *fe, u32 *freq)
648 unsigned char *regs = priv->tda18271_regs; 648 unsigned char *regs = priv->tda18271_regs;
649 u8 val; 649 u8 val;
650 650
651 tda18271_lookup_map(fe, RF_CAL, freq, &val); 651 int ret = tda18271_lookup_map(fe, RF_CAL, freq, &val);
652 652
653 regs[R_EB14] = val; 653 regs[R_EB14] = val;
654 654
655 return 0; 655 return ret;
656} 656}
657 657
658/* 658/*
diff --git a/drivers/media/common/tuners/tda827x.c b/drivers/media/common/tuners/tda827x.c
index d30d2c9094d9..8555d9cf9051 100644
--- a/drivers/media/common/tuners/tda827x.c
+++ b/drivers/media/common/tuners/tda827x.c
@@ -418,13 +418,13 @@ static void tda827xa_lna_gain(struct dvb_frontend *fe, int high,
418 unsigned char buf[] = {0x22, 0x01}; 418 unsigned char buf[] = {0x22, 0x01};
419 int arg; 419 int arg;
420 int gp_func; 420 int gp_func;
421 struct i2c_msg msg = { .addr = priv->cfg->switch_addr, .flags = 0, 421 struct i2c_msg msg = { .flags = 0, .buf = buf, .len = sizeof(buf) };
422 .buf = buf, .len = sizeof(buf) };
423 422
424 if (NULL == priv->cfg) { 423 if (NULL == priv->cfg) {
425 dprintk("tda827x_config not defined, cannot set LNA gain!\n"); 424 dprintk("tda827x_config not defined, cannot set LNA gain!\n");
426 return; 425 return;
427 } 426 }
427 msg.addr = priv->cfg->switch_addr;
428 if (priv->cfg->config) { 428 if (priv->cfg->config) {
429 if (high) 429 if (high)
430 dprintk("setting LNA to high gain\n"); 430 dprintk("setting LNA to high gain\n");
diff --git a/drivers/media/common/tuners/tea5761.c b/drivers/media/common/tuners/tea5761.c
index b93cdef9ac73..b23dadeecd05 100644
--- a/drivers/media/common/tuners/tea5761.c
+++ b/drivers/media/common/tuners/tea5761.c
@@ -295,7 +295,7 @@ struct dvb_frontend *tea5761_attach(struct dvb_frontend *fe,
295{ 295{
296 struct tea5761_priv *priv = NULL; 296 struct tea5761_priv *priv = NULL;
297 297
298 if (tea5761_autodetection(i2c_adap, i2c_addr) == EINVAL) 298 if (tea5761_autodetection(i2c_adap, i2c_addr) != 0)
299 return NULL; 299 return NULL;
300 300
301 priv = kzalloc(sizeof(struct tea5761_priv), GFP_KERNEL); 301 priv = kzalloc(sizeof(struct tea5761_priv), GFP_KERNEL);
diff --git a/drivers/media/common/tuners/tuner-i2c.h b/drivers/media/common/tuners/tuner-i2c.h
index 3ad6c8e0b04c..cb1c7141f0c6 100644
--- a/drivers/media/common/tuners/tuner-i2c.h
+++ b/drivers/media/common/tuners/tuner-i2c.h
@@ -170,4 +170,12 @@ __fail: \
170 __ret; \ 170 __ret; \
171}) 171})
172 172
173#define hybrid_tuner_report_instance_count(state) \
174({ \
175 int __ret = 0; \
176 if (state) \
177 __ret = state->i2c_props.count; \
178 __ret; \
179})
180
173#endif /* __TUNER_I2C_H__ */ 181#endif /* __TUNER_I2C_H__ */
diff --git a/drivers/media/common/tuners/tuner-simple.c b/drivers/media/common/tuners/tuner-simple.c
index be8d903171b7..266c255cf0d8 100644
--- a/drivers/media/common/tuners/tuner-simple.c
+++ b/drivers/media/common/tuners/tuner-simple.c
@@ -1018,8 +1018,10 @@ struct dvb_frontend *simple_tuner_attach(struct dvb_frontend *fe,
1018 fe->ops.i2c_gate_ctrl(fe, 1); 1018 fe->ops.i2c_gate_ctrl(fe, 1);
1019 1019
1020 if (1 != i2c_transfer(i2c_adap, &msg, 1)) 1020 if (1 != i2c_transfer(i2c_adap, &msg, 1))
1021 tuner_warn("unable to probe %s, proceeding anyway.", 1021 printk(KERN_WARNING "tuner-simple %d-%04x: "
1022 tuners[type].name); 1022 "unable to probe %s, proceeding anyway.",
1023 i2c_adapter_id(i2c_adap), i2c_addr,
1024 tuners[type].name);
1023 1025
1024 if (fe->ops.i2c_gate_ctrl) 1026 if (fe->ops.i2c_gate_ctrl)
1025 fe->ops.i2c_gate_ctrl(fe, 0); 1027 fe->ops.i2c_gate_ctrl(fe, 0);
diff --git a/drivers/media/common/tuners/tuner-xc2028.c b/drivers/media/common/tuners/tuner-xc2028.c
index 9e9003cffc7f..0cbde17bfbb7 100644
--- a/drivers/media/common/tuners/tuner-xc2028.c
+++ b/drivers/media/common/tuners/tuner-xc2028.c
@@ -46,7 +46,7 @@ module_param_string(firmware_name, firmware_name, sizeof(firmware_name), 0);
46MODULE_PARM_DESC(firmware_name, "Firmware file name. Allows overriding the " 46MODULE_PARM_DESC(firmware_name, "Firmware file name. Allows overriding the "
47 "default firmware name\n"); 47 "default firmware name\n");
48 48
49static LIST_HEAD(xc2028_list); 49static LIST_HEAD(hybrid_tuner_instance_list);
50static DEFINE_MUTEX(xc2028_list_mutex); 50static DEFINE_MUTEX(xc2028_list_mutex);
51 51
52/* struct for storing firmware table */ 52/* struct for storing firmware table */
@@ -68,12 +68,11 @@ struct firmware_properties {
68}; 68};
69 69
70struct xc2028_data { 70struct xc2028_data {
71 struct list_head xc2028_list; 71 struct list_head hybrid_tuner_instance_list;
72 struct tuner_i2c_props i2c_props; 72 struct tuner_i2c_props i2c_props;
73 int (*tuner_callback) (void *dev, 73 int (*tuner_callback) (void *dev,
74 int command, int arg); 74 int command, int arg);
75 void *video_dev; 75 void *video_dev;
76 int count;
77 __u32 frequency; 76 __u32 frequency;
78 77
79 struct firmware_description *firm; 78 struct firmware_description *firm;
@@ -1072,20 +1071,19 @@ static int xc2028_dvb_release(struct dvb_frontend *fe)
1072 1071
1073 mutex_lock(&xc2028_list_mutex); 1072 mutex_lock(&xc2028_list_mutex);
1074 1073
1075 priv->count--; 1074 /* only perform final cleanup if this is the last instance */
1076 1075 if (hybrid_tuner_report_instance_count(priv) == 1) {
1077 if (!priv->count) {
1078 list_del(&priv->xc2028_list);
1079
1080 kfree(priv->ctrl.fname); 1076 kfree(priv->ctrl.fname);
1081
1082 free_firmware(priv); 1077 free_firmware(priv);
1083 kfree(priv);
1084 fe->tuner_priv = NULL;
1085 } 1078 }
1086 1079
1080 if (priv)
1081 hybrid_tuner_release_state(priv);
1082
1087 mutex_unlock(&xc2028_list_mutex); 1083 mutex_unlock(&xc2028_list_mutex);
1088 1084
1085 fe->tuner_priv = NULL;
1086
1089 return 0; 1087 return 0;
1090} 1088}
1091 1089
@@ -1150,7 +1148,7 @@ struct dvb_frontend *xc2028_attach(struct dvb_frontend *fe,
1150 struct xc2028_config *cfg) 1148 struct xc2028_config *cfg)
1151{ 1149{
1152 struct xc2028_data *priv; 1150 struct xc2028_data *priv;
1153 void *video_dev; 1151 int instance;
1154 1152
1155 if (debug) 1153 if (debug)
1156 printk(KERN_DEBUG "xc2028: Xcv2028/3028 init called!\n"); 1154 printk(KERN_DEBUG "xc2028: Xcv2028/3028 init called!\n");
@@ -1163,48 +1161,40 @@ struct dvb_frontend *xc2028_attach(struct dvb_frontend *fe,
1163 return NULL; 1161 return NULL;
1164 } 1162 }
1165 1163
1166 video_dev = cfg->i2c_adap->algo_data;
1167
1168 if (debug)
1169 printk(KERN_DEBUG "xc2028: video_dev =%p\n", video_dev);
1170
1171 mutex_lock(&xc2028_list_mutex); 1164 mutex_lock(&xc2028_list_mutex);
1172 1165
1173 list_for_each_entry(priv, &xc2028_list, xc2028_list) { 1166 instance = hybrid_tuner_request_state(struct xc2028_data, priv,
1174 if (&priv->i2c_props.adap->dev == &cfg->i2c_adap->dev) { 1167 hybrid_tuner_instance_list,
1175 video_dev = NULL; 1168 cfg->i2c_adap, cfg->i2c_addr,
1176 if (debug) 1169 "xc2028");
1177 printk(KERN_DEBUG "xc2028: reusing device\n"); 1170 switch (instance) {
1178 1171 case 0:
1179 break; 1172 /* memory allocation failure */
1180 } 1173 goto fail;
1181 } 1174 break;
1182 1175 case 1:
1183 if (video_dev) { 1176 /* new tuner instance */
1184 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
1185 if (priv == NULL) {
1186 mutex_unlock(&xc2028_list_mutex);
1187 return NULL;
1188 }
1189
1190 priv->i2c_props.addr = cfg->i2c_addr;
1191 priv->i2c_props.adap = cfg->i2c_adap;
1192 priv->i2c_props.name = "xc2028";
1193
1194 priv->video_dev = video_dev;
1195 priv->tuner_callback = cfg->callback; 1177 priv->tuner_callback = cfg->callback;
1196 priv->ctrl.max_len = 13; 1178 priv->ctrl.max_len = 13;
1197 1179
1198 mutex_init(&priv->lock); 1180 mutex_init(&priv->lock);
1199 1181
1200 list_add_tail(&priv->xc2028_list, &xc2028_list); 1182 /* analog side (tuner-core) uses i2c_adap->algo_data.
1201 } 1183 * digital side is not guaranteed to have algo_data defined.
1202 1184 *
1203 fe->tuner_priv = priv; 1185 * digital side will always have fe->dvb defined.
1204 priv->count++; 1186 * analog side (tuner-core) doesn't (yet) define fe->dvb.
1187 */
1188 priv->video_dev = ((fe->dvb) && (fe->dvb->priv)) ?
1189 fe->dvb->priv : cfg->i2c_adap->algo_data;
1205 1190
1206 if (debug) 1191 fe->tuner_priv = priv;
1207 printk(KERN_DEBUG "xc2028: usage count is %i\n", priv->count); 1192 break;
1193 case 2:
1194 /* existing tuner instance */
1195 fe->tuner_priv = priv;
1196 break;
1197 }
1208 1198
1209 memcpy(&fe->ops.tuner_ops, &xc2028_dvb_tuner_ops, 1199 memcpy(&fe->ops.tuner_ops, &xc2028_dvb_tuner_ops,
1210 sizeof(xc2028_dvb_tuner_ops)); 1200 sizeof(xc2028_dvb_tuner_ops));
@@ -1217,6 +1207,11 @@ struct dvb_frontend *xc2028_attach(struct dvb_frontend *fe,
1217 mutex_unlock(&xc2028_list_mutex); 1207 mutex_unlock(&xc2028_list_mutex);
1218 1208
1219 return fe; 1209 return fe;
1210fail:
1211 mutex_unlock(&xc2028_list_mutex);
1212
1213 xc2028_dvb_release(fe);
1214 return NULL;
1220} 1215}
1221 1216
1222EXPORT_SYMBOL(xc2028_attach); 1217EXPORT_SYMBOL(xc2028_attach);
diff --git a/drivers/media/dvb/b2c2/flexcop-usb.c b/drivers/media/dvb/b2c2/flexcop-usb.c
index 449fb5c3d0b1..ae0d76a5d51d 100644
--- a/drivers/media/dvb/b2c2/flexcop-usb.c
+++ b/drivers/media/dvb/b2c2/flexcop-usb.c
@@ -379,7 +379,7 @@ static void flexcop_usb_transfer_exit(struct flexcop_usb *fc_usb)
379 379
380static int flexcop_usb_transfer_init(struct flexcop_usb *fc_usb) 380static int flexcop_usb_transfer_init(struct flexcop_usb *fc_usb)
381{ 381{
382 u16 frame_size = fc_usb->uintf->cur_altsetting->endpoint[0].desc.wMaxPacketSize; 382 u16 frame_size = le16_to_cpu(fc_usb->uintf->cur_altsetting->endpoint[0].desc.wMaxPacketSize);
383 int bufsize = B2C2_USB_NUM_ISO_URB * B2C2_USB_FRAMES_PER_ISO * frame_size,i,j,ret; 383 int bufsize = B2C2_USB_NUM_ISO_URB * B2C2_USB_FRAMES_PER_ISO * frame_size,i,j,ret;
384 int buffer_offset = 0; 384 int buffer_offset = 0;
385 385
diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c
index f5010e8671b8..a824f3719f81 100644
--- a/drivers/media/dvb/cinergyT2/cinergyT2.c
+++ b/drivers/media/dvb/cinergyT2/cinergyT2.c
@@ -82,22 +82,22 @@ enum cinergyt2_ep1_cmd {
82 82
83struct dvbt_set_parameters_msg { 83struct dvbt_set_parameters_msg {
84 uint8_t cmd; 84 uint8_t cmd;
85 uint32_t freq; 85 __le32 freq;
86 uint8_t bandwidth; 86 uint8_t bandwidth;
87 uint16_t tps; 87 __le16 tps;
88 uint8_t flags; 88 uint8_t flags;
89} __attribute__((packed)); 89} __attribute__((packed));
90 90
91struct dvbt_get_status_msg { 91struct dvbt_get_status_msg {
92 uint32_t freq; 92 __le32 freq;
93 uint8_t bandwidth; 93 uint8_t bandwidth;
94 uint16_t tps; 94 __le16 tps;
95 uint8_t flags; 95 uint8_t flags;
96 uint16_t gain; 96 __le16 gain;
97 uint8_t snr; 97 uint8_t snr;
98 uint32_t viterbi_error_rate; 98 __le32 viterbi_error_rate;
99 uint32_t rs_error_rate; 99 __le32 rs_error_rate;
100 uint32_t uncorrected_block_count; 100 __le32 uncorrected_block_count;
101 uint8_t lock_bits; 101 uint8_t lock_bits;
102 uint8_t prev_lock_bits; 102 uint8_t prev_lock_bits;
103} __attribute__((packed)); 103} __attribute__((packed));
@@ -136,6 +136,7 @@ struct cinergyt2 {
136 wait_queue_head_t poll_wq; 136 wait_queue_head_t poll_wq;
137 int pending_fe_events; 137 int pending_fe_events;
138 int disconnect_pending; 138 int disconnect_pending;
139 unsigned int uncorrected_block_count;
139 atomic_t inuse; 140 atomic_t inuse;
140 141
141 void *streambuf; 142 void *streambuf;
@@ -147,7 +148,7 @@ struct cinergyt2 {
147 char phys[64]; 148 char phys[64];
148 struct delayed_work rc_query_work; 149 struct delayed_work rc_query_work;
149 int rc_input_event; 150 int rc_input_event;
150 u32 rc_last_code; 151 __le32 rc_last_code;
151 unsigned long last_event_jiffies; 152 unsigned long last_event_jiffies;
152#endif 153#endif
153}; 154};
@@ -160,7 +161,7 @@ enum {
160 161
161struct cinergyt2_rc_event { 162struct cinergyt2_rc_event {
162 char type; 163 char type;
163 uint32_t value; 164 __le32 value;
164} __attribute__((packed)); 165} __attribute__((packed));
165 166
166static const uint32_t rc_keys[] = { 167static const uint32_t rc_keys[] = {
@@ -619,8 +620,11 @@ static int cinergyt2_ioctl (struct inode *inode, struct file *file,
619 { 620 {
620 uint32_t unc_count; 621 uint32_t unc_count;
621 622
622 unc_count = stat->uncorrected_block_count; 623 if (mutex_lock_interruptible(&cinergyt2->sem))
623 stat->uncorrected_block_count = 0; 624 return -ERESTARTSYS;
625 unc_count = cinergyt2->uncorrected_block_count;
626 cinergyt2->uncorrected_block_count = 0;
627 mutex_unlock(&cinergyt2->sem);
624 628
625 /* UNC are already converted to host byte order... */ 629 /* UNC are already converted to host byte order... */
626 return put_user(unc_count,(__u32 __user *) arg); 630 return put_user(unc_count,(__u32 __user *) arg);
@@ -769,7 +773,7 @@ static void cinergyt2_query_rc (struct work_struct *work)
769 input_sync(cinergyt2->rc_input_dev); 773 input_sync(cinergyt2->rc_input_dev);
770 cinergyt2->rc_input_event = KEY_MAX; 774 cinergyt2->rc_input_event = KEY_MAX;
771 } 775 }
772 cinergyt2->rc_last_code = ~0; 776 cinergyt2->rc_last_code = cpu_to_le32(~0);
773 } 777 }
774 goto out; 778 goto out;
775 } 779 }
@@ -780,7 +784,7 @@ static void cinergyt2_query_rc (struct work_struct *work)
780 n, le32_to_cpu(rc_events[n].value), rc_events[n].type); 784 n, le32_to_cpu(rc_events[n].value), rc_events[n].type);
781 785
782 if (rc_events[n].type == CINERGYT2_RC_EVENT_TYPE_NEC && 786 if (rc_events[n].type == CINERGYT2_RC_EVENT_TYPE_NEC &&
783 rc_events[n].value == ~0) { 787 rc_events[n].value == cpu_to_le32(~0)) {
784 /* keyrepeat bit -> just repeat last rc_input_event */ 788 /* keyrepeat bit -> just repeat last rc_input_event */
785 } else { 789 } else {
786 cinergyt2->rc_input_event = KEY_MAX; 790 cinergyt2->rc_input_event = KEY_MAX;
@@ -795,7 +799,7 @@ static void cinergyt2_query_rc (struct work_struct *work)
795 799
796 if (cinergyt2->rc_input_event != KEY_MAX) { 800 if (cinergyt2->rc_input_event != KEY_MAX) {
797 if (rc_events[n].value == cinergyt2->rc_last_code && 801 if (rc_events[n].value == cinergyt2->rc_last_code &&
798 cinergyt2->rc_last_code != ~0) { 802 cinergyt2->rc_last_code != cpu_to_le32(~0)) {
799 /* emit a key-up so the double event is recognized */ 803 /* emit a key-up so the double event is recognized */
800 dprintk(1, "rc_input_event=%d UP\n", cinergyt2->rc_input_event); 804 dprintk(1, "rc_input_event=%d UP\n", cinergyt2->rc_input_event);
801 input_report_key(cinergyt2->rc_input_dev, 805 input_report_key(cinergyt2->rc_input_dev,
@@ -829,7 +833,7 @@ static int cinergyt2_register_rc(struct cinergyt2 *cinergyt2)
829 usb_make_path(cinergyt2->udev, cinergyt2->phys, sizeof(cinergyt2->phys)); 833 usb_make_path(cinergyt2->udev, cinergyt2->phys, sizeof(cinergyt2->phys));
830 strlcat(cinergyt2->phys, "/input0", sizeof(cinergyt2->phys)); 834 strlcat(cinergyt2->phys, "/input0", sizeof(cinergyt2->phys));
831 cinergyt2->rc_input_event = KEY_MAX; 835 cinergyt2->rc_input_event = KEY_MAX;
832 cinergyt2->rc_last_code = ~0; 836 cinergyt2->rc_last_code = cpu_to_le32(~0);
833 INIT_DELAYED_WORK(&cinergyt2->rc_query_work, cinergyt2_query_rc); 837 INIT_DELAYED_WORK(&cinergyt2->rc_query_work, cinergyt2_query_rc);
834 838
835 input_dev->name = DRIVER_NAME " remote control"; 839 input_dev->name = DRIVER_NAME " remote control";
@@ -840,8 +844,8 @@ static int cinergyt2_register_rc(struct cinergyt2 *cinergyt2)
840 input_dev->keycodesize = 0; 844 input_dev->keycodesize = 0;
841 input_dev->keycodemax = 0; 845 input_dev->keycodemax = 0;
842 input_dev->id.bustype = BUS_USB; 846 input_dev->id.bustype = BUS_USB;
843 input_dev->id.vendor = cinergyt2->udev->descriptor.idVendor; 847 input_dev->id.vendor = le16_to_cpu(cinergyt2->udev->descriptor.idVendor);
844 input_dev->id.product = cinergyt2->udev->descriptor.idProduct; 848 input_dev->id.product = le16_to_cpu(cinergyt2->udev->descriptor.idProduct);
845 input_dev->id.version = 1; 849 input_dev->id.version = 1;
846 input_dev->dev.parent = &cinergyt2->udev->dev; 850 input_dev->dev.parent = &cinergyt2->udev->dev;
847 851
@@ -889,18 +893,16 @@ static void cinergyt2_query (struct work_struct *work)
889 char cmd [] = { CINERGYT2_EP1_GET_TUNER_STATUS }; 893 char cmd [] = { CINERGYT2_EP1_GET_TUNER_STATUS };
890 struct dvbt_get_status_msg *s = &cinergyt2->status; 894 struct dvbt_get_status_msg *s = &cinergyt2->status;
891 uint8_t lock_bits; 895 uint8_t lock_bits;
892 uint32_t unc;
893 896
894 if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem)) 897 if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem))
895 return; 898 return;
896 899
897 unc = s->uncorrected_block_count;
898 lock_bits = s->lock_bits; 900 lock_bits = s->lock_bits;
899 901
900 cinergyt2_command(cinergyt2, cmd, sizeof(cmd), (char *) s, sizeof(*s)); 902 cinergyt2_command(cinergyt2, cmd, sizeof(cmd), (char *) s, sizeof(*s));
901 903
902 unc += le32_to_cpu(s->uncorrected_block_count); 904 cinergyt2->uncorrected_block_count +=
903 s->uncorrected_block_count = unc; 905 le32_to_cpu(s->uncorrected_block_count);
904 906
905 if (lock_bits != s->lock_bits) { 907 if (lock_bits != s->lock_bits) {
906 wake_up_interruptible(&cinergyt2->poll_wq); 908 wake_up_interruptible(&cinergyt2->poll_wq);
diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c
index 56d871cfd7fc..c2334aef4143 100644
--- a/drivers/media/dvb/dvb-core/dvb_net.c
+++ b/drivers/media/dvb/dvb-core/dvb_net.c
@@ -168,7 +168,7 @@ struct dvb_net_priv {
168 * stolen from eth.c out of the linux kernel, hacked for dvb-device 168 * stolen from eth.c out of the linux kernel, hacked for dvb-device
169 * by Michael Holzt <kju@debian.org> 169 * by Michael Holzt <kju@debian.org>
170 */ 170 */
171static unsigned short dvb_net_eth_type_trans(struct sk_buff *skb, 171static __be16 dvb_net_eth_type_trans(struct sk_buff *skb,
172 struct net_device *dev) 172 struct net_device *dev)
173{ 173{
174 struct ethhdr *eth; 174 struct ethhdr *eth;
@@ -277,10 +277,10 @@ static int handle_one_ule_extension( struct dvb_net_priv *p )
277 if(ext_len >= 0) { 277 if(ext_len >= 0) {
278 p->ule_next_hdr += ext_len; 278 p->ule_next_hdr += ext_len;
279 if (!p->ule_bridged) { 279 if (!p->ule_bridged) {
280 p->ule_sndu_type = ntohs(*(unsigned short *)p->ule_next_hdr); 280 p->ule_sndu_type = ntohs(*(__be16 *)p->ule_next_hdr);
281 p->ule_next_hdr += 2; 281 p->ule_next_hdr += 2;
282 } else { 282 } else {
283 p->ule_sndu_type = ntohs(*(unsigned short *)(p->ule_next_hdr + ((p->ule_dbit ? 2 : 3) * ETH_ALEN))); 283 p->ule_sndu_type = ntohs(*(__be16 *)(p->ule_next_hdr + ((p->ule_dbit ? 2 : 3) * ETH_ALEN)));
284 /* This assures the extension handling loop will terminate. */ 284 /* This assures the extension handling loop will terminate. */
285 } 285 }
286 } 286 }
@@ -294,7 +294,7 @@ static int handle_one_ule_extension( struct dvb_net_priv *p )
294 if (ule_optional_ext_handlers[htype]) 294 if (ule_optional_ext_handlers[htype])
295 (void)ule_optional_ext_handlers[htype]( p ); 295 (void)ule_optional_ext_handlers[htype]( p );
296 p->ule_next_hdr += ext_len; 296 p->ule_next_hdr += ext_len;
297 p->ule_sndu_type = ntohs( *(unsigned short *)(p->ule_next_hdr-2) ); 297 p->ule_sndu_type = ntohs( *(__be16 *)(p->ule_next_hdr-2) );
298 /* 298 /*
299 * note: the length of the next header type is included in the 299 * note: the length of the next header type is included in the
300 * length of THIS optional extension header 300 * length of THIS optional extension header
@@ -594,8 +594,8 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
594 /* Check for complete payload. */ 594 /* Check for complete payload. */
595 if (priv->ule_sndu_remain <= 0) { 595 if (priv->ule_sndu_remain <= 0) {
596 /* Check CRC32, we've got it in our skb already. */ 596 /* Check CRC32, we've got it in our skb already. */
597 unsigned short ulen = htons(priv->ule_sndu_len); 597 __be16 ulen = htons(priv->ule_sndu_len);
598 unsigned short utype = htons(priv->ule_sndu_type); 598 __be16 utype = htons(priv->ule_sndu_type);
599 const u8 *tail; 599 const u8 *tail;
600 struct kvec iov[3] = { 600 struct kvec iov[3] = {
601 { &ulen, sizeof ulen }, 601 { &ulen, sizeof ulen },
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig
index cf4584e48b6d..f00a0eb40420 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -1,6 +1,6 @@
1config DVB_USB 1config DVB_USB
2 tristate "Support for various USB DVB devices" 2 tristate "Support for various USB DVB devices"
3 depends on DVB_CORE && USB && I2C 3 depends on DVB_CORE && USB && I2C && INPUT
4 depends on HOTPLUG # due to FW_LOADER 4 depends on HOTPLUG # due to FW_LOADER
5 select FW_LOADER 5 select FW_LOADER
6 help 6 help
diff --git a/drivers/media/dvb/dvb-usb/dib0700_devices.c b/drivers/media/dvb/dvb-usb/dib0700_devices.c
index 346223856f59..c4d40fe01d57 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_devices.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_devices.c
@@ -111,8 +111,8 @@ static int bristol_tuner_attach(struct dvb_usb_adapter *adap)
111 struct i2c_adapter *tun_i2c = dib3000mc_get_tuner_i2c_master(adap->fe, 1); 111 struct i2c_adapter *tun_i2c = dib3000mc_get_tuner_i2c_master(adap->fe, 1);
112 s8 a; 112 s8 a;
113 int if1=1220; 113 int if1=1220;
114 if (adap->dev->udev->descriptor.idVendor == USB_VID_HAUPPAUGE && 114 if (adap->dev->udev->descriptor.idVendor == cpu_to_le16(USB_VID_HAUPPAUGE) &&
115 adap->dev->udev->descriptor.idProduct == USB_PID_HAUPPAUGE_NOVA_T_500_2) { 115 adap->dev->udev->descriptor.idProduct == cpu_to_le16(USB_PID_HAUPPAUGE_NOVA_T_500_2)) {
116 if (!eeprom_read(prim_i2c,0x59 + adap->id,&a)) if1=1220+a; 116 if (!eeprom_read(prim_i2c,0x59 + adap->id,&a)) if1=1220+a;
117 } 117 }
118 return dvb_attach(mt2060_attach,adap->fe, tun_i2c,&bristol_mt2060_config[adap->id], 118 return dvb_attach(mt2060_attach,adap->fe, tun_i2c,&bristol_mt2060_config[adap->id],
@@ -402,8 +402,8 @@ static int stk7700ph_frontend_attach(struct dvb_usb_adapter *adap)
402{ 402{
403 struct usb_device_descriptor *desc = &adap->dev->udev->descriptor; 403 struct usb_device_descriptor *desc = &adap->dev->udev->descriptor;
404 404
405 if (desc->idVendor == USB_VID_PINNACLE && 405 if (desc->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
406 desc->idProduct == USB_PID_PINNACLE_EXPRESSCARD_320CX) 406 desc->idProduct == cpu_to_le16(USB_PID_PINNACLE_EXPRESSCARD_320CX))
407 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); 407 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
408 else 408 else
409 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); 409 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
@@ -845,8 +845,8 @@ static int stk7700p_tuner_attach(struct dvb_usb_adapter *adap)
845 struct i2c_adapter *tun_i2c; 845 struct i2c_adapter *tun_i2c;
846 s8 a; 846 s8 a;
847 int if1=1220; 847 int if1=1220;
848 if (adap->dev->udev->descriptor.idVendor == USB_VID_HAUPPAUGE && 848 if (adap->dev->udev->descriptor.idVendor == cpu_to_le16(USB_VID_HAUPPAUGE) &&
849 adap->dev->udev->descriptor.idProduct == USB_PID_HAUPPAUGE_NOVA_T_STICK) { 849 adap->dev->udev->descriptor.idProduct == cpu_to_le16(USB_PID_HAUPPAUGE_NOVA_T_STICK)) {
850 if (!eeprom_read(prim_i2c,0x58,&a)) if1=1220+a; 850 if (!eeprom_read(prim_i2c,0x58,&a)) if1=1220+a;
851 } 851 }
852 if (st->is_dib7000pc) 852 if (st->is_dib7000pc)
@@ -990,11 +990,12 @@ static struct dib7000p_config dib7070p_dib7000p_config = {
990/* STK7070P */ 990/* STK7070P */
991static int stk7070p_frontend_attach(struct dvb_usb_adapter *adap) 991static int stk7070p_frontend_attach(struct dvb_usb_adapter *adap)
992{ 992{
993 if (adap->dev->udev->descriptor.idVendor == USB_VID_PINNACLE && 993 struct usb_device_descriptor *p = &adap->dev->udev->descriptor;
994 adap->dev->udev->descriptor.idProduct == USB_PID_PINNACLE_PCTV72E) 994 if (p->idVendor == cpu_to_le16(USB_VID_PINNACLE) &&
995 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); 995 p->idProduct == cpu_to_le16(USB_PID_PINNACLE_PCTV72E))
996 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0);
996 else 997 else
997 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); 998 dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1);
998 msleep(10); 999 msleep(10);
999 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1); 1000 dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1);
1000 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1); 1001 dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1);
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-firmware.c b/drivers/media/dvb/dvb-usb/dvb-usb-firmware.c
index e1112e39fb63..733a7ff7b207 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-firmware.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-firmware.c
@@ -127,7 +127,7 @@ int dvb_usb_get_hexline(const struct firmware *fw, struct hexline *hx,
127 if ((*pos + hx->len + 4) >= fw->size) 127 if ((*pos + hx->len + 4) >= fw->size)
128 return -EINVAL; 128 return -EINVAL;
129 129
130 hx->addr = le16_to_cpu( *((u16 *) &b[1]) ); 130 hx->addr = b[1] | (b[2] << 8);
131 hx->type = b[3]; 131 hx->type = b[3];
132 132
133 if (hx->type == 0x04) { 133 if (hx->type == 0x04) {
diff --git a/drivers/media/dvb/dvb-usb/gp8psk.c b/drivers/media/dvb/dvb-usb/gp8psk.c
index 9a942afaf0af..2653120673b7 100644
--- a/drivers/media/dvb/dvb-usb/gp8psk.c
+++ b/drivers/media/dvb/dvb-usb/gp8psk.c
@@ -146,24 +146,24 @@ static int gp8psk_power_ctrl(struct dvb_usb_device *d, int onoff)
146 if (gp_product_id == USB_PID_GENPIX_8PSK_REV_1_WARM) 146 if (gp_product_id == USB_PID_GENPIX_8PSK_REV_1_WARM)
147 if (! (status & bm8pskFW_Loaded)) /* BCM4500 firmware loaded */ 147 if (! (status & bm8pskFW_Loaded)) /* BCM4500 firmware loaded */
148 if(gp8psk_load_bcm4500fw(d)) 148 if(gp8psk_load_bcm4500fw(d))
149 return EINVAL; 149 return -EINVAL;
150 150
151 if (! (status & bmIntersilOn)) /* LNB Power */ 151 if (! (status & bmIntersilOn)) /* LNB Power */
152 if (gp8psk_usb_in_op(d, START_INTERSIL, 1, 0, 152 if (gp8psk_usb_in_op(d, START_INTERSIL, 1, 0,
153 &buf, 1)) 153 &buf, 1))
154 return EINVAL; 154 return -EINVAL;
155 155
156 /* Set DVB mode to 1 */ 156 /* Set DVB mode to 1 */
157 if (gp_product_id == USB_PID_GENPIX_8PSK_REV_1_WARM) 157 if (gp_product_id == USB_PID_GENPIX_8PSK_REV_1_WARM)
158 if (gp8psk_usb_out_op(d, SET_DVB_MODE, 1, 0, NULL, 0)) 158 if (gp8psk_usb_out_op(d, SET_DVB_MODE, 1, 0, NULL, 0))
159 return EINVAL; 159 return -EINVAL;
160 /* Abort possible TS (if previous tune crashed) */ 160 /* Abort possible TS (if previous tune crashed) */
161 if (gp8psk_usb_out_op(d, ARM_TRANSFER, 0, 0, NULL, 0)) 161 if (gp8psk_usb_out_op(d, ARM_TRANSFER, 0, 0, NULL, 0))
162 return EINVAL; 162 return -EINVAL;
163 } else { 163 } else {
164 /* Turn off LNB power */ 164 /* Turn off LNB power */
165 if (gp8psk_usb_in_op(d, START_INTERSIL, 0, 0, &buf, 1)) 165 if (gp8psk_usb_in_op(d, START_INTERSIL, 0, 0, &buf, 1))
166 return EINVAL; 166 return -EINVAL;
167 /* Turn off 8psk power */ 167 /* Turn off 8psk power */
168 if (gp8psk_usb_in_op(d, BOOT_8PSK, 0, 0, &buf, 1)) 168 if (gp8psk_usb_in_op(d, BOOT_8PSK, 0, 0, &buf, 1))
169 return -EINVAL; 169 return -EINVAL;
diff --git a/drivers/media/dvb/dvb-usb/m920x.c b/drivers/media/dvb/dvb-usb/m920x.c
index a12e6f784fda..54626a0dbf68 100644
--- a/drivers/media/dvb/dvb-usb/m920x.c
+++ b/drivers/media/dvb/dvb-usb/m920x.c
@@ -16,6 +16,7 @@
16#include "qt1010.h" 16#include "qt1010.h"
17#include "tda1004x.h" 17#include "tda1004x.h"
18#include "tda827x.h" 18#include "tda827x.h"
19#include <asm/unaligned.h>
19 20
20/* debug */ 21/* debug */
21static int dvb_usb_m920x_debug; 22static int dvb_usb_m920x_debug;
@@ -347,13 +348,13 @@ static int m920x_firmware_download(struct usb_device *udev, const struct firmwar
347 348
348 for (pass = 0; pass < 2; pass++) { 349 for (pass = 0; pass < 2; pass++) {
349 for (i = 0; i + (sizeof(u16) * 3) < fw->size;) { 350 for (i = 0; i + (sizeof(u16) * 3) < fw->size;) {
350 value = le16_to_cpu(*(u16 *)(fw->data + i)); 351 value = get_unaligned_le16(fw->data + i);
351 i += sizeof(u16); 352 i += sizeof(u16);
352 353
353 index = le16_to_cpu(*(u16 *)(fw->data + i)); 354 index = get_unaligned_le16(fw->data + i);
354 i += sizeof(u16); 355 i += sizeof(u16);
355 356
356 size = le16_to_cpu(*(u16 *)(fw->data + i)); 357 size = get_unaligned_le16(fw->data + i);
357 i += sizeof(u16); 358 i += sizeof(u16);
358 359
359 if (pass == 1) { 360 if (pass == 1) {
diff --git a/drivers/media/dvb/frontends/dib0070.h b/drivers/media/dvb/frontends/dib0070.h
index 786e37d33889..3eedfdf505bc 100644
--- a/drivers/media/dvb/frontends/dib0070.h
+++ b/drivers/media/dvb/frontends/dib0070.h
@@ -37,7 +37,20 @@ struct dib0070_config {
37 u8 flip_chip; 37 u8 flip_chip;
38}; 38};
39 39
40extern struct dvb_frontend * dib0070_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct dib0070_config *cfg); 40#if defined(CONFIG_DVB_TUNER_DIB0070) || (defined(CONFIG_DVB_TUNER_DIB0070_MODULE) && defined(MODULE))
41extern struct dvb_frontend *dib0070_attach(struct dvb_frontend *fe,
42 struct i2c_adapter *i2c,
43 struct dib0070_config *cfg);
44#else
45static inline struct dvb_frontend *dib0070_attach(struct dvb_frontend *fe,
46 struct i2c_adapter *i2c,
47 struct dib0070_config *cfg)
48{
49 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
50 return NULL;
51}
52#endif
53
41extern void dib0070_ctrl_agc_filter(struct dvb_frontend *, uint8_t open); 54extern void dib0070_ctrl_agc_filter(struct dvb_frontend *, uint8_t open);
42extern u16 dib0070_wbd_offset(struct dvb_frontend *); 55extern u16 dib0070_wbd_offset(struct dvb_frontend *);
43 56
diff --git a/drivers/media/dvb/frontends/dib7000p.h b/drivers/media/dvb/frontends/dib7000p.h
index 081bd81f3da2..07c4d12ed5b7 100644
--- a/drivers/media/dvb/frontends/dib7000p.h
+++ b/drivers/media/dvb/frontends/dib7000p.h
@@ -37,7 +37,20 @@ struct dib7000p_config {
37 37
38#define DEFAULT_DIB7000P_I2C_ADDRESS 18 38#define DEFAULT_DIB7000P_I2C_ADDRESS 18
39 39
40extern struct dvb_frontend * dib7000p_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib7000p_config *cfg); 40#if defined(CONFIG_DVB_DIB7000P) || (defined(CONFIG_DVB_DIB7000P_MODULE) && defined(MODULE))
41extern struct dvb_frontend *dib7000p_attach(struct i2c_adapter *i2c_adap,
42 u8 i2c_addr,
43 struct dib7000p_config *cfg);
44#else
45static inline struct dvb_frontend *dib7000p_attach(struct i2c_adapter *i2c_adap,
46 u8 i2c_addr,
47 struct dib7000p_config *cfg)
48{
49 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
50 return NULL;
51}
52#endif
53
41extern int dib7000p_i2c_enumeration(struct i2c_adapter *i2c, int no_of_demods, u8 default_addr, struct dib7000p_config cfg[]); 54extern int dib7000p_i2c_enumeration(struct i2c_adapter *i2c, int no_of_demods, u8 default_addr, struct dib7000p_config cfg[]);
42 55
43extern struct i2c_adapter * dib7000p_get_i2c_master(struct dvb_frontend *, enum dibx000_i2c_interface, int); 56extern struct i2c_adapter * dib7000p_get_i2c_master(struct dvb_frontend *, enum dibx000_i2c_interface, int);
diff --git a/drivers/media/dvb/frontends/or51132.c b/drivers/media/dvb/frontends/or51132.c
index c7b5785f81f2..5ed32544de39 100644
--- a/drivers/media/dvb/frontends/or51132.c
+++ b/drivers/media/dvb/frontends/or51132.c
@@ -126,7 +126,7 @@ static int or51132_readreg(struct or51132_state *state, u8 reg)
126 reg, err); 126 reg, err);
127 return -EREMOTEIO; 127 return -EREMOTEIO;
128 } 128 }
129 return le16_to_cpup((u16*)buf); 129 return buf[0] | (buf[1] << 8);
130} 130}
131 131
132static int or51132_load_firmware (struct dvb_frontend* fe, const struct firmware *fw) 132static int or51132_load_firmware (struct dvb_frontend* fe, const struct firmware *fw)
@@ -140,9 +140,9 @@ static int or51132_load_firmware (struct dvb_frontend* fe, const struct firmware
140 dprintk("Firmware is %Zd bytes\n",fw->size); 140 dprintk("Firmware is %Zd bytes\n",fw->size);
141 141
142 /* Get size of firmware A and B */ 142 /* Get size of firmware A and B */
143 firmwareAsize = le32_to_cpu(*((u32*)fw->data)); 143 firmwareAsize = le32_to_cpu(*((__le32*)fw->data));
144 dprintk("FirmwareA is %i bytes\n",firmwareAsize); 144 dprintk("FirmwareA is %i bytes\n",firmwareAsize);
145 firmwareBsize = le32_to_cpu(*((u32*)(fw->data+4))); 145 firmwareBsize = le32_to_cpu(*((__le32*)(fw->data+4)));
146 dprintk("FirmwareB is %i bytes\n",firmwareBsize); 146 dprintk("FirmwareB is %i bytes\n",firmwareBsize);
147 147
148 /* Upload firmware */ 148 /* Upload firmware */
diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c
index 747e7f1a6267..f05d43d8b5cf 100644
--- a/drivers/media/dvb/ttpci/av7110.c
+++ b/drivers/media/dvb/ttpci/av7110.c
@@ -51,6 +51,7 @@
51#include <linux/crc32.h> 51#include <linux/crc32.h>
52#include <linux/i2c.h> 52#include <linux/i2c.h>
53#include <linux/kthread.h> 53#include <linux/kthread.h>
54#include <asm/unaligned.h>
54 55
55#include <asm/system.h> 56#include <asm/system.h>
56 57
@@ -1461,9 +1462,9 @@ static int check_firmware(struct av7110* av7110)
1461 ptr += 4; 1462 ptr += 4;
1462 1463
1463 /* check dpram file */ 1464 /* check dpram file */
1464 crc = ntohl(*(u32*) ptr); 1465 crc = get_unaligned_be32(ptr);
1465 ptr += 4; 1466 ptr += 4;
1466 len = ntohl(*(u32*) ptr); 1467 len = get_unaligned_be32(ptr);
1467 ptr += 4; 1468 ptr += 4;
1468 if (len >= 512) { 1469 if (len >= 512) {
1469 printk("dvb-ttpci: dpram file is way too big.\n"); 1470 printk("dvb-ttpci: dpram file is way too big.\n");
@@ -1478,9 +1479,9 @@ static int check_firmware(struct av7110* av7110)
1478 ptr += len; 1479 ptr += len;
1479 1480
1480 /* check root file */ 1481 /* check root file */
1481 crc = ntohl(*(u32*) ptr); 1482 crc = get_unaligned_be32(ptr);
1482 ptr += 4; 1483 ptr += 4;
1483 len = ntohl(*(u32*) ptr); 1484 len = get_unaligned_be32(ptr);
1484 ptr += 4; 1485 ptr += 4;
1485 1486
1486 if (len <= 200000 || len >= 300000 || 1487 if (len <= 200000 || len >= 300000 ||
diff --git a/drivers/media/dvb/ttpci/av7110_av.c b/drivers/media/dvb/ttpci/av7110_av.c
index 3e6b650fbb81..ec55a968f204 100644
--- a/drivers/media/dvb/ttpci/av7110_av.c
+++ b/drivers/media/dvb/ttpci/av7110_av.c
@@ -965,8 +965,9 @@ static u8 iframe_header[] = { 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x80, 0x00, 0x
965 965
966static int play_iframe(struct av7110 *av7110, char __user *buf, unsigned int len, int nonblock) 966static int play_iframe(struct av7110 *av7110, char __user *buf, unsigned int len, int nonblock)
967{ 967{
968 int i, n; 968 unsigned i, n;
969 int progressive = 0; 969 int progressive = 0;
970 int match = 0;
970 971
971 dprintk(2, "av7110:%p, \n", av7110); 972 dprintk(2, "av7110:%p, \n", av7110);
972 973
@@ -975,12 +976,31 @@ static int play_iframe(struct av7110 *av7110, char __user *buf, unsigned int len
975 return -EBUSY; 976 return -EBUSY;
976 } 977 }
977 978
978 for (i = 0; i < len - 5; i++) { 979 /* search in buf for instances of 00 00 01 b5 1? */
979 /* get progressive flag from picture extension */ 980 for (i = 0; i < len; i++) {
980 if (buf[i] == 0x00 && buf[i+1] == 0x00 && 981 unsigned char c;
981 buf[i+2] == 0x01 && (unsigned char)buf[i+3] == 0xb5 && 982 if (get_user(c, buf + i))
982 (buf[i+4] & 0xf0) == 0x10) 983 return -EFAULT;
983 progressive = buf[i+5] & 0x08; 984 if (match == 5) {
985 progressive = c & 0x08;
986 match = 0;
987 }
988 if (c == 0x00) {
989 match = (match == 1 || match == 2) ? 2 : 1;
990 continue;
991 }
992 switch (match++) {
993 case 2: if (c == 0x01)
994 continue;
995 break;
996 case 3: if (c == 0xb5)
997 continue;
998 break;
999 case 4: if ((c & 0xf0) == 0x10)
1000 continue;
1001 break;
1002 }
1003 match = 0;
984 } 1004 }
985 1005
986 /* setting n always > 1, fixes problems when playing stillframes 1006 /* setting n always > 1, fixes problems when playing stillframes
diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
index 732ce4de512e..5d2d81ab2371 100644
--- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
+++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
@@ -552,7 +552,7 @@ static void ttusb_process_muxpack(struct ttusb *ttusb, const u8 * muxpack,
552 u16 csum = 0, cc; 552 u16 csum = 0, cc;
553 int i; 553 int i;
554 for (i = 0; i < len; i += 2) 554 for (i = 0; i < len; i += 2)
555 csum ^= le16_to_cpup((u16 *) (muxpack + i)); 555 csum ^= le16_to_cpup((__le16 *) (muxpack + i));
556 if (csum) { 556 if (csum) {
557 printk("%s: muxpack with incorrect checksum, ignoring\n", 557 printk("%s: muxpack with incorrect checksum, ignoring\n",
558 __func__); 558 __func__);
diff --git a/drivers/media/dvb/ttusb-dec/Kconfig b/drivers/media/dvb/ttusb-dec/Kconfig
index 0712899e39a4..a23cc0aa17d3 100644
--- a/drivers/media/dvb/ttusb-dec/Kconfig
+++ b/drivers/media/dvb/ttusb-dec/Kconfig
@@ -1,6 +1,6 @@
1config DVB_TTUSB_DEC 1config DVB_TTUSB_DEC
2 tristate "Technotrend/Hauppauge USB DEC devices" 2 tristate "Technotrend/Hauppauge USB DEC devices"
3 depends on DVB_CORE && USB 3 depends on DVB_CORE && USB && INPUT
4 depends on HOTPLUG # due to FW_LOADER 4 depends on HOTPLUG # due to FW_LOADER
5 select FW_LOADER 5 select FW_LOADER
6 select CRC32 6 select CRC32
diff --git a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
index 42eee04daa5d..fefdc05e84ac 100644
--- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c
+++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
@@ -343,7 +343,7 @@ static int ttusb_dec_get_stb_state (struct ttusb_dec *dec, unsigned int *mode,
343 u8 c[COMMAND_PACKET_SIZE]; 343 u8 c[COMMAND_PACKET_SIZE];
344 int c_length; 344 int c_length;
345 int result; 345 int result;
346 unsigned int tmp; 346 __be32 tmp;
347 347
348 dprintk("%s\n", __func__); 348 dprintk("%s\n", __func__);
349 349
@@ -398,9 +398,9 @@ static void ttusb_dec_set_pids(struct ttusb_dec *dec)
398 0x00, 0x00, 0xff, 0xff, 398 0x00, 0x00, 0xff, 0xff,
399 0xff, 0xff, 0xff, 0xff }; 399 0xff, 0xff, 0xff, 0xff };
400 400
401 u16 pcr = htons(dec->pid[DMX_PES_PCR]); 401 __be16 pcr = htons(dec->pid[DMX_PES_PCR]);
402 u16 audio = htons(dec->pid[DMX_PES_AUDIO]); 402 __be16 audio = htons(dec->pid[DMX_PES_AUDIO]);
403 u16 video = htons(dec->pid[DMX_PES_VIDEO]); 403 __be16 video = htons(dec->pid[DMX_PES_VIDEO]);
404 404
405 dprintk("%s\n", __func__); 405 dprintk("%s\n", __func__);
406 406
@@ -435,7 +435,7 @@ static void ttusb_dec_process_pva(struct ttusb_dec *dec, u8 *pva, int length)
435 case 0x01: { /* VideoStream */ 435 case 0x01: { /* VideoStream */
436 int prebytes = pva[5] & 0x03; 436 int prebytes = pva[5] & 0x03;
437 int postbytes = (pva[5] & 0x0c) >> 2; 437 int postbytes = (pva[5] & 0x0c) >> 2;
438 u16 v_pes_payload_length; 438 __be16 v_pes_payload_length;
439 439
440 if (output_pva) { 440 if (output_pva) {
441 dec->video_filter->feed->cb.ts(pva, length, NULL, 0, 441 dec->video_filter->feed->cb.ts(pva, length, NULL, 0,
@@ -1006,7 +1006,7 @@ static int ttusb_dec_start_sec_feed(struct dvb_demux_feed *dvbdmxfeed)
1006 0x00, 0x00, 0x00, 0x00, 1006 0x00, 0x00, 0x00, 0x00,
1007 0x00, 0x00, 0x00, 0x00, 1007 0x00, 0x00, 0x00, 0x00,
1008 0x00 }; 1008 0x00 };
1009 u16 pid; 1009 __be16 pid;
1010 u8 c[COMMAND_PACKET_SIZE]; 1010 u8 c[COMMAND_PACKET_SIZE];
1011 int c_length; 1011 int c_length;
1012 int result; 1012 int result;
@@ -1278,9 +1278,10 @@ static int ttusb_dec_boot_dsp(struct ttusb_dec *dec)
1278 u8 *firmware = NULL; 1278 u8 *firmware = NULL;
1279 size_t firmware_size = 0; 1279 size_t firmware_size = 0;
1280 u16 firmware_csum = 0; 1280 u16 firmware_csum = 0;
1281 u16 firmware_csum_ns; 1281 __be16 firmware_csum_ns;
1282 u32 firmware_size_nl; 1282 __be32 firmware_size_nl;
1283 u32 crc32_csum, crc32_check, tmp; 1283 u32 crc32_csum, crc32_check;
1284 __be32 tmp;
1284 const struct firmware *fw_entry = NULL; 1285 const struct firmware *fw_entry = NULL;
1285 1286
1286 dprintk("%s\n", __func__); 1287 dprintk("%s\n", __func__);
@@ -1306,7 +1307,7 @@ static int ttusb_dec_boot_dsp(struct ttusb_dec *dec)
1306 valid. */ 1307 valid. */
1307 crc32_csum = crc32(~0L, firmware, 56) ^ ~0L; 1308 crc32_csum = crc32(~0L, firmware, 56) ^ ~0L;
1308 memcpy(&tmp, &firmware[56], 4); 1309 memcpy(&tmp, &firmware[56], 4);
1309 crc32_check = htonl(tmp); 1310 crc32_check = ntohl(tmp);
1310 if (crc32_csum != crc32_check) { 1311 if (crc32_csum != crc32_check) {
1311 printk("%s: crc32 check of DSP code failed (calculated " 1312 printk("%s: crc32 check of DSP code failed (calculated "
1312 "0x%08x != 0x%08x in file), file invalid.\n", 1313 "0x%08x != 0x%08x in file), file invalid.\n",
@@ -1627,7 +1628,7 @@ static int ttusb_dec_probe(struct usb_interface *intf,
1627 1628
1628 usb_set_intfdata(intf, (void *)dec); 1629 usb_set_intfdata(intf, (void *)dec);
1629 1630
1630 switch (le16_to_cpu(id->idProduct)) { 1631 switch (id->idProduct) {
1631 case 0x1006: 1632 case 0x1006:
1632 ttusb_dec_set_model(dec, TTUSB_DEC3000S); 1633 ttusb_dec_set_model(dec, TTUSB_DEC3000S);
1633 break; 1634 break;
@@ -1652,7 +1653,7 @@ static int ttusb_dec_probe(struct usb_interface *intf,
1652 ttusb_dec_init_dvb(dec); 1653 ttusb_dec_init_dvb(dec);
1653 1654
1654 dec->adapter.priv = dec; 1655 dec->adapter.priv = dec;
1655 switch (le16_to_cpu(id->idProduct)) { 1656 switch (id->idProduct) {
1656 case 0x1006: 1657 case 0x1006:
1657 dec->fe = ttusbdecfe_dvbs_attach(&fe_config); 1658 dec->fe = ttusbdecfe_dvbs_attach(&fe_config);
1658 break; 1659 break;
diff --git a/drivers/media/dvb/ttusb-dec/ttusbdecfe.c b/drivers/media/dvb/ttusb-dec/ttusbdecfe.c
index eb5eaeccd7c4..443af24097f3 100644
--- a/drivers/media/dvb/ttusb-dec/ttusbdecfe.c
+++ b/drivers/media/dvb/ttusb-dec/ttusbdecfe.c
@@ -86,7 +86,7 @@ static int ttusbdecfe_dvbt_set_frontend(struct dvb_frontend* fe, struct dvb_fron
86 0x00, 0x00, 0x00, 0xff, 86 0x00, 0x00, 0x00, 0xff,
87 0x00, 0x00, 0x00, 0xff }; 87 0x00, 0x00, 0x00, 0xff };
88 88
89 u32 freq = htonl(p->frequency / 1000); 89 __be32 freq = htonl(p->frequency / 1000);
90 memcpy(&b[4], &freq, sizeof (u32)); 90 memcpy(&b[4], &freq, sizeof (u32));
91 state->config->send_command(fe, 0x71, sizeof(b), b, NULL, NULL); 91 state->config->send_command(fe, 0x71, sizeof(b), b, NULL, NULL);
92 92
@@ -117,10 +117,10 @@ static int ttusbdecfe_dvbs_set_frontend(struct dvb_frontend* fe, struct dvb_fron
117 0x00, 0x00, 0x00, 0x00, 117 0x00, 0x00, 0x00, 0x00,
118 0x00, 0x00, 0x00, 0x00, 118 0x00, 0x00, 0x00, 0x00,
119 0x00, 0x00, 0x00, 0x00 }; 119 0x00, 0x00, 0x00, 0x00 };
120 u32 freq; 120 __be32 freq;
121 u32 sym_rate; 121 __be32 sym_rate;
122 u32 band; 122 __be32 band;
123 u32 lnb_voltage; 123 __be32 lnb_voltage;
124 124
125 freq = htonl(p->frequency + 125 freq = htonl(p->frequency +
126 (state->hi_band ? LOF_HI : LOF_LO)); 126 (state->hi_band ? LOF_HI : LOF_LO));
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 89d8d37838a3..3b26fbd3e558 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -901,7 +901,7 @@ endif # V4L_USB_DRIVERS
901 901
902config SOC_CAMERA 902config SOC_CAMERA
903 tristate "SoC camera support" 903 tristate "SoC camera support"
904 depends on VIDEO_V4L2 904 depends on VIDEO_V4L2 && HAS_DMA
905 select VIDEOBUF_DMA_SG 905 select VIDEOBUF_DMA_SG
906 help 906 help
907 SoC Camera is a common API to several cameras, not connecting 907 SoC Camera is a common API to several cameras, not connecting
diff --git a/drivers/media/video/au0828/Kconfig b/drivers/media/video/au0828/Kconfig
index def10d086373..52b2491581a8 100644
--- a/drivers/media/video/au0828/Kconfig
+++ b/drivers/media/video/au0828/Kconfig
@@ -1,7 +1,7 @@
1 1
2config VIDEO_AU0828 2config VIDEO_AU0828
3 tristate "Auvitek AU0828 support" 3 tristate "Auvitek AU0828 support"
4 depends on VIDEO_DEV && I2C && INPUT && DVB_CORE && USB 4 depends on I2C && INPUT && DVB_CORE && USB
5 select I2C_ALGOBIT 5 select I2C_ALGOBIT
6 select VIDEO_TVEEPROM 6 select VIDEO_TVEEPROM
7 select DVB_AU8522 if !DVB_FE_CUSTOMIZE 7 select DVB_AU8522 if !DVB_FE_CUSTOMIZE
diff --git a/drivers/media/video/au0828/au0828-dvb.c b/drivers/media/video/au0828/au0828-dvb.c
index c86a5f17eca8..c6d470590380 100644
--- a/drivers/media/video/au0828/au0828-dvb.c
+++ b/drivers/media/video/au0828/au0828-dvb.c
@@ -353,12 +353,6 @@ int au0828_dvb_register(struct au0828_dev *dev)
353 return -1; 353 return -1;
354 } 354 }
355 355
356 /* Put the analog decoder in standby to keep it quiet */
357 au0828_call_i2c_clients(dev, TUNER_SET_STANDBY, NULL);
358
359 if (dvb->frontend->ops.analog_ops.standby)
360 dvb->frontend->ops.analog_ops.standby(dvb->frontend);
361
362 /* register everything */ 356 /* register everything */
363 ret = dvb_register(dev); 357 ret = dvb_register(dev);
364 if (ret < 0) { 358 if (ret < 0) {
diff --git a/drivers/media/video/bt8xx/bttv-cards.c b/drivers/media/video/bt8xx/bttv-cards.c
index f20a01cfc73e..8ef0424c26c4 100644
--- a/drivers/media/video/bt8xx/bttv-cards.c
+++ b/drivers/media/video/bt8xx/bttv-cards.c
@@ -34,6 +34,7 @@
34#include <linux/firmware.h> 34#include <linux/firmware.h>
35#include <net/checksum.h> 35#include <net/checksum.h>
36 36
37#include <asm/unaligned.h>
37#include <asm/io.h> 38#include <asm/io.h>
38 39
39#include "bttvp.h" 40#include "bttvp.h"
@@ -3858,7 +3859,7 @@ static void __devinit osprey_eeprom(struct bttv *btv, const u8 ee[256])
3858 ee += i; 3859 ee += i;
3859 3860
3860 /* found a valid descriptor */ 3861 /* found a valid descriptor */
3861 type = be16_to_cpup((u16*)(ee+4)); 3862 type = get_unaligned_be16((__be16 *)(ee+4));
3862 3863
3863 switch(type) { 3864 switch(type) {
3864 /* 848 based */ 3865 /* 848 based */
@@ -3918,7 +3919,7 @@ static void __devinit osprey_eeprom(struct bttv *btv, const u8 ee[256])
3918 btv->c.nr, type); 3919 btv->c.nr, type);
3919 break; 3920 break;
3920 } 3921 }
3921 serial = be32_to_cpup((u32*)(ee+6)); 3922 serial = get_unaligned_be32((__be32 *)(ee+6));
3922 } 3923 }
3923 3924
3924 printk(KERN_INFO "bttv%d: osprey eeprom: card=%d '%s' serial=%u\n", 3925 printk(KERN_INFO "bttv%d: osprey eeprom: card=%d '%s' serial=%u\n",
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index 2ca3e9cfb2bb..0165aac533bf 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -2613,7 +2613,7 @@ static int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf)
2613 struct bttv_fh *fh = priv; 2613 struct bttv_fh *fh = priv;
2614 2614
2615 mutex_lock(&fh->cap.vb_lock); 2615 mutex_lock(&fh->cap.vb_lock);
2616 retval = videobuf_mmap_setup(&fh->cap, gbuffers, gbufsize, 2616 retval = __videobuf_mmap_setup(&fh->cap, gbuffers, gbufsize,
2617 V4L2_MEMORY_MMAP); 2617 V4L2_MEMORY_MMAP);
2618 if (retval < 0) { 2618 if (retval < 0) {
2619 mutex_unlock(&fh->cap.vb_lock); 2619 mutex_unlock(&fh->cap.vb_lock);
diff --git a/drivers/media/video/bt8xx/bttv-risc.c b/drivers/media/video/bt8xx/bttv-risc.c
index e5979f77504c..0af586876e72 100644
--- a/drivers/media/video/bt8xx/bttv-risc.c
+++ b/drivers/media/video/bt8xx/bttv-risc.c
@@ -48,7 +48,7 @@ bttv_risc_packed(struct bttv *btv, struct btcx_riscmem *risc,
48{ 48{
49 u32 instructions,line,todo; 49 u32 instructions,line,todo;
50 struct scatterlist *sg; 50 struct scatterlist *sg;
51 u32 *rp; 51 __le32 *rp;
52 int rc; 52 int rc;
53 53
54 /* estimate risc mem: worst case is one write per page border + 54 /* estimate risc mem: worst case is one write per page border +
@@ -128,7 +128,8 @@ bttv_risc_planar(struct bttv *btv, struct btcx_riscmem *risc,
128 unsigned int cpadding) 128 unsigned int cpadding)
129{ 129{
130 unsigned int instructions,line,todo,ylen,chroma; 130 unsigned int instructions,line,todo,ylen,chroma;
131 u32 *rp,ri; 131 __le32 *rp;
132 u32 ri;
132 struct scatterlist *ysg; 133 struct scatterlist *ysg;
133 struct scatterlist *usg; 134 struct scatterlist *usg;
134 struct scatterlist *vsg; 135 struct scatterlist *vsg;
@@ -244,7 +245,8 @@ bttv_risc_overlay(struct bttv *btv, struct btcx_riscmem *risc,
244{ 245{
245 int dwords,rc,line,maxy,start,end,skip,nskips; 246 int dwords,rc,line,maxy,start,end,skip,nskips;
246 struct btcx_skiplist *skips; 247 struct btcx_skiplist *skips;
247 u32 *rp,ri,ra; 248 __le32 *rp;
249 u32 ri,ra;
248 u32 addr; 250 u32 addr;
249 251
250 /* skip list for window clipping */ 252 /* skip list for window clipping */
diff --git a/drivers/media/video/btcx-risc.c b/drivers/media/video/btcx-risc.c
index ce0840ccd594..f42701f82e7f 100644
--- a/drivers/media/video/btcx-risc.c
+++ b/drivers/media/video/btcx-risc.c
@@ -63,7 +63,7 @@ int btcx_riscmem_alloc(struct pci_dev *pci,
63 struct btcx_riscmem *risc, 63 struct btcx_riscmem *risc,
64 unsigned int size) 64 unsigned int size)
65{ 65{
66 u32 *cpu; 66 __le32 *cpu;
67 dma_addr_t dma; 67 dma_addr_t dma;
68 68
69 if (NULL != risc->cpu && risc->size < size) 69 if (NULL != risc->cpu && risc->size < size)
diff --git a/drivers/media/video/btcx-risc.h b/drivers/media/video/btcx-risc.h
index 503e6c6d7b69..861bc8112824 100644
--- a/drivers/media/video/btcx-risc.h
+++ b/drivers/media/video/btcx-risc.h
@@ -2,8 +2,8 @@
2 */ 2 */
3struct btcx_riscmem { 3struct btcx_riscmem {
4 unsigned int size; 4 unsigned int size;
5 u32 *cpu; 5 __le32 *cpu;
6 u32 *jmp; 6 __le32 *jmp;
7 dma_addr_t dma; 7 dma_addr_t dma;
8}; 8};
9 9
diff --git a/drivers/media/video/cx18/cx18-av-core.c b/drivers/media/video/cx18/cx18-av-core.c
index 66864904c99b..9a26751615c6 100644
--- a/drivers/media/video/cx18/cx18-av-core.c
+++ b/drivers/media/video/cx18/cx18-av-core.c
@@ -182,14 +182,16 @@ static void input_change(struct cx18 *cx)
182 if (std == V4L2_STD_NTSC_M_JP) { 182 if (std == V4L2_STD_NTSC_M_JP) {
183 /* Japan uses EIAJ audio standard */ 183 /* Japan uses EIAJ audio standard */
184 cx18_av_write(cx, 0x808, 0xf7); 184 cx18_av_write(cx, 0x808, 0xf7);
185 cx18_av_write(cx, 0x80b, 0x02);
185 } else if (std == V4L2_STD_NTSC_M_KR) { 186 } else if (std == V4L2_STD_NTSC_M_KR) {
186 /* South Korea uses A2 audio standard */ 187 /* South Korea uses A2 audio standard */
187 cx18_av_write(cx, 0x808, 0xf8); 188 cx18_av_write(cx, 0x808, 0xf8);
189 cx18_av_write(cx, 0x80b, 0x03);
188 } else { 190 } else {
189 /* Others use the BTSC audio standard */ 191 /* Others use the BTSC audio standard */
190 cx18_av_write(cx, 0x808, 0xf6); 192 cx18_av_write(cx, 0x808, 0xf6);
193 cx18_av_write(cx, 0x80b, 0x01);
191 } 194 }
192 cx18_av_write(cx, 0x80b, 0x00);
193 } else if (std & V4L2_STD_PAL) { 195 } else if (std & V4L2_STD_PAL) {
194 /* Follow tuner change procedure for PAL */ 196 /* Follow tuner change procedure for PAL */
195 cx18_av_write(cx, 0x808, 0xff); 197 cx18_av_write(cx, 0x808, 0xff);
@@ -741,8 +743,8 @@ static void log_audio_status(struct cx18 *cx)
741{ 743{
742 struct cx18_av_state *state = &cx->av_state; 744 struct cx18_av_state *state = &cx->av_state;
743 u8 download_ctl = cx18_av_read(cx, 0x803); 745 u8 download_ctl = cx18_av_read(cx, 0x803);
744 u8 mod_det_stat0 = cx18_av_read(cx, 0x805); 746 u8 mod_det_stat0 = cx18_av_read(cx, 0x804);
745 u8 mod_det_stat1 = cx18_av_read(cx, 0x804); 747 u8 mod_det_stat1 = cx18_av_read(cx, 0x805);
746 u8 audio_config = cx18_av_read(cx, 0x808); 748 u8 audio_config = cx18_av_read(cx, 0x808);
747 u8 pref_mode = cx18_av_read(cx, 0x809); 749 u8 pref_mode = cx18_av_read(cx, 0x809);
748 u8 afc0 = cx18_av_read(cx, 0x80b); 750 u8 afc0 = cx18_av_read(cx, 0x80b);
@@ -760,12 +762,12 @@ static void log_audio_status(struct cx18 *cx)
760 case 0x12: p = "dual with SAP"; break; 762 case 0x12: p = "dual with SAP"; break;
761 case 0x14: p = "tri with SAP"; break; 763 case 0x14: p = "tri with SAP"; break;
762 case 0xfe: p = "forced mode"; break; 764 case 0xfe: p = "forced mode"; break;
763 default: p = "not defined"; 765 default: p = "not defined"; break;
764 } 766 }
765 CX18_INFO("Detected audio mode: %s\n", p); 767 CX18_INFO("Detected audio mode: %s\n", p);
766 768
767 switch (mod_det_stat1) { 769 switch (mod_det_stat1) {
768 case 0x00: p = "BTSC"; break; 770 case 0x00: p = "not defined"; break;
769 case 0x01: p = "EIAJ"; break; 771 case 0x01: p = "EIAJ"; break;
770 case 0x02: p = "A2-M"; break; 772 case 0x02: p = "A2-M"; break;
771 case 0x03: p = "A2-BG"; break; 773 case 0x03: p = "A2-BG"; break;
@@ -779,8 +781,13 @@ static void log_audio_status(struct cx18 *cx)
779 case 0x0b: p = "NICAM-I"; break; 781 case 0x0b: p = "NICAM-I"; break;
780 case 0x0c: p = "NICAM-L"; break; 782 case 0x0c: p = "NICAM-L"; break;
781 case 0x0d: p = "BTSC/EIAJ/A2-M Mono (4.5 MHz FMMono)"; break; 783 case 0x0d: p = "BTSC/EIAJ/A2-M Mono (4.5 MHz FMMono)"; break;
784 case 0x0e: p = "IF FM Radio"; break;
785 case 0x0f: p = "BTSC"; break;
786 case 0x10: p = "detected chrominance"; break;
787 case 0xfd: p = "unknown audio standard"; break;
788 case 0xfe: p = "forced audio standard"; break;
782 case 0xff: p = "no detected audio standard"; break; 789 case 0xff: p = "no detected audio standard"; break;
783 default: p = "not defined"; 790 default: p = "not defined"; break;
784 } 791 }
785 CX18_INFO("Detected audio standard: %s\n", p); 792 CX18_INFO("Detected audio standard: %s\n", p);
786 CX18_INFO("Audio muted: %s\n", 793 CX18_INFO("Audio muted: %s\n",
@@ -789,22 +796,23 @@ static void log_audio_status(struct cx18 *cx)
789 (download_ctl & 0x10) ? "running" : "stopped"); 796 (download_ctl & 0x10) ? "running" : "stopped");
790 797
791 switch (audio_config >> 4) { 798 switch (audio_config >> 4) {
792 case 0x00: p = "BTSC"; break; 799 case 0x00: p = "undefined"; break;
793 case 0x01: p = "EIAJ"; break; 800 case 0x01: p = "BTSC"; break;
794 case 0x02: p = "A2-M"; break; 801 case 0x02: p = "EIAJ"; break;
795 case 0x03: p = "A2-BG"; break; 802 case 0x03: p = "A2-M"; break;
796 case 0x04: p = "A2-DK1"; break; 803 case 0x04: p = "A2-BG"; break;
797 case 0x05: p = "A2-DK2"; break; 804 case 0x05: p = "A2-DK1"; break;
798 case 0x06: p = "A2-DK3"; break; 805 case 0x06: p = "A2-DK2"; break;
799 case 0x07: p = "A1 (6.0 MHz FM Mono)"; break; 806 case 0x07: p = "A2-DK3"; break;
800 case 0x08: p = "AM-L"; break; 807 case 0x08: p = "A1 (6.0 MHz FM Mono)"; break;
801 case 0x09: p = "NICAM-BG"; break; 808 case 0x09: p = "AM-L"; break;
802 case 0x0a: p = "NICAM-DK"; break; 809 case 0x0a: p = "NICAM-BG"; break;
803 case 0x0b: p = "NICAM-I"; break; 810 case 0x0b: p = "NICAM-DK"; break;
804 case 0x0c: p = "NICAM-L"; break; 811 case 0x0c: p = "NICAM-I"; break;
805 case 0x0d: p = "FM radio"; break; 812 case 0x0d: p = "NICAM-L"; break;
813 case 0x0e: p = "FM radio"; break;
806 case 0x0f: p = "automatic detection"; break; 814 case 0x0f: p = "automatic detection"; break;
807 default: p = "undefined"; 815 default: p = "undefined"; break;
808 } 816 }
809 CX18_INFO("Configured audio standard: %s\n", p); 817 CX18_INFO("Configured audio standard: %s\n", p);
810 818
@@ -815,12 +823,9 @@ static void log_audio_status(struct cx18 *cx)
815 case 0x02: p = "MONO3 (STEREO forced MONO)"; break; 823 case 0x02: p = "MONO3 (STEREO forced MONO)"; break;
816 case 0x03: p = "MONO4 (NICAM ANALOG-Language C/Analog Fallback)"; break; 824 case 0x03: p = "MONO4 (NICAM ANALOG-Language C/Analog Fallback)"; break;
817 case 0x04: p = "STEREO"; break; 825 case 0x04: p = "STEREO"; break;
818 case 0x05: p = "DUAL1 (AB)"; break; 826 case 0x05: p = "DUAL1 (AC)"; break;
819 case 0x06: p = "DUAL2 (AC) (FM)"; break; 827 case 0x06: p = "DUAL2 (BC)"; break;
820 case 0x07: p = "DUAL3 (BC) (FM)"; break; 828 case 0x07: p = "DUAL3 (AB)"; break;
821 case 0x08: p = "DUAL4 (AC) (AM)"; break;
822 case 0x09: p = "DUAL5 (BC) (AM)"; break;
823 case 0x0a: p = "SAP"; break;
824 default: p = "undefined"; 829 default: p = "undefined";
825 } 830 }
826 CX18_INFO("Configured audio mode: %s\n", p); 831 CX18_INFO("Configured audio mode: %s\n", p);
@@ -835,9 +840,11 @@ static void log_audio_status(struct cx18 *cx)
835 case 0x06: p = "BTSC"; break; 840 case 0x06: p = "BTSC"; break;
836 case 0x07: p = "EIAJ"; break; 841 case 0x07: p = "EIAJ"; break;
837 case 0x08: p = "A2-M"; break; 842 case 0x08: p = "A2-M"; break;
838 case 0x09: p = "FM Radio"; break; 843 case 0x09: p = "FM Radio (4.5 MHz)"; break;
844 case 0x0a: p = "FM Radio (5.5 MHz)"; break;
845 case 0x0b: p = "S-Video"; break;
839 case 0x0f: p = "automatic standard and mode detection"; break; 846 case 0x0f: p = "automatic standard and mode detection"; break;
840 default: p = "undefined"; 847 default: p = "undefined"; break;
841 } 848 }
842 CX18_INFO("Configured audio system: %s\n", p); 849 CX18_INFO("Configured audio system: %s\n", p);
843 } 850 }
@@ -857,22 +864,24 @@ static void log_audio_status(struct cx18 *cx)
857 case 5: p = "language AC"; break; 864 case 5: p = "language AC"; break;
858 case 6: p = "language BC"; break; 865 case 6: p = "language BC"; break;
859 case 7: p = "language AB"; break; 866 case 7: p = "language AB"; break;
860 default: p = "undefined"; 867 default: p = "undefined"; break;
861 } 868 }
862 CX18_INFO("Preferred audio mode: %s\n", p); 869 CX18_INFO("Preferred audio mode: %s\n", p);
863 870
864 if ((audio_config & 0xf) == 0xf) { 871 if ((audio_config & 0xf) == 0xf) {
865 switch ((afc0 >> 2) & 0x1) { 872 switch ((afc0 >> 3) & 0x1) {
866 case 0: p = "system DK"; break; 873 case 0: p = "system DK"; break;
867 case 1: p = "system L"; break; 874 case 1: p = "system L"; break;
868 } 875 }
869 CX18_INFO("Selected 65 MHz format: %s\n", p); 876 CX18_INFO("Selected 65 MHz format: %s\n", p);
870 877
871 switch (afc0 & 0x3) { 878 switch (afc0 & 0x7) {
872 case 0: p = "BTSC"; break; 879 case 0: p = "Chroma"; break;
873 case 1: p = "EIAJ"; break; 880 case 1: p = "BTSC"; break;
874 case 2: p = "A2-M"; break; 881 case 2: p = "EIAJ"; break;
875 default: p = "undefined"; 882 case 3: p = "A2-M"; break;
883 case 4: p = "autodetect"; break;
884 default: p = "undefined"; break;
876 } 885 }
877 CX18_INFO("Selected 45 MHz format: %s\n", p); 886 CX18_INFO("Selected 45 MHz format: %s\n", p);
878 } 887 }
diff --git a/drivers/media/video/cx18/cx18-cards.c b/drivers/media/video/cx18/cx18-cards.c
index 553adbf2cd44..baccd079243d 100644
--- a/drivers/media/video/cx18/cx18-cards.c
+++ b/drivers/media/video/cx18/cx18-cards.c
@@ -126,7 +126,7 @@ static const struct cx18_card cx18_card_hvr1600_samsung = {
126 126
127/* ------------------------------------------------------------------------- */ 127/* ------------------------------------------------------------------------- */
128 128
129/* Compro VideoMate H900: not working at the moment! */ 129/* Compro VideoMate H900: note that this card is analog only! */
130 130
131static const struct cx18_card_pci_info cx18_pci_h900[] = { 131static const struct cx18_card_pci_info cx18_pci_h900[] = {
132 { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_COMPRO, 0xe100 }, 132 { PCI_DEVICE_ID_CX23418, CX18_PCI_ID_COMPRO, 0xe100 },
@@ -136,7 +136,7 @@ static const struct cx18_card_pci_info cx18_pci_h900[] = {
136static const struct cx18_card cx18_card_h900 = { 136static const struct cx18_card cx18_card_h900 = {
137 .type = CX18_CARD_COMPRO_H900, 137 .type = CX18_CARD_COMPRO_H900,
138 .name = "Compro VideoMate H900", 138 .name = "Compro VideoMate H900",
139 .comment = "DVB & VBI are not yet supported\n", 139 .comment = "VBI is not yet supported\n",
140 .v4l2_capabilities = CX18_CAP_ENCODER, 140 .v4l2_capabilities = CX18_CAP_ENCODER,
141 .hw_audio_ctrl = CX18_HW_CX23418, 141 .hw_audio_ctrl = CX18_HW_CX23418,
142 .hw_all = CX18_HW_TUNER, 142 .hw_all = CX18_HW_TUNER,
diff --git a/drivers/media/video/cx18/cx18-controls.c b/drivers/media/video/cx18/cx18-controls.c
index 2bdac5ebbb0d..87cf41021665 100644
--- a/drivers/media/video/cx18/cx18-controls.c
+++ b/drivers/media/video/cx18/cx18-controls.c
@@ -159,7 +159,7 @@ static int cx18_setup_vbi_fmt(struct cx18 *cx, enum v4l2_mpeg_stream_vbi_fmt fmt
159{ 159{
160 if (!(cx->v4l2_cap & V4L2_CAP_SLICED_VBI_CAPTURE)) 160 if (!(cx->v4l2_cap & V4L2_CAP_SLICED_VBI_CAPTURE))
161 return -EINVAL; 161 return -EINVAL;
162 if (atomic_read(&cx->capturing) > 0) 162 if (atomic_read(&cx->ana_capturing) > 0)
163 return -EBUSY; 163 return -EBUSY;
164 164
165 /* First try to allocate sliced VBI buffers if needed. */ 165 /* First try to allocate sliced VBI buffers if needed. */
@@ -235,7 +235,7 @@ int cx18_control_ioctls(struct cx18 *cx, unsigned int cmd, void *arg)
235 CX18_DEBUG_IOCTL("VIDIOC_S_EXT_CTRLS\n"); 235 CX18_DEBUG_IOCTL("VIDIOC_S_EXT_CTRLS\n");
236 if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG) { 236 if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG) {
237 struct cx2341x_mpeg_params p = cx->params; 237 struct cx2341x_mpeg_params p = cx->params;
238 int err = cx2341x_ext_ctrls(&p, atomic_read(&cx->capturing), arg, cmd); 238 int err = cx2341x_ext_ctrls(&p, atomic_read(&cx->ana_capturing), arg, cmd);
239 239
240 if (err) 240 if (err)
241 return err; 241 return err;
@@ -295,7 +295,7 @@ int cx18_control_ioctls(struct cx18 *cx, unsigned int cmd, void *arg)
295 CX18_DEBUG_IOCTL("VIDIOC_TRY_EXT_CTRLS\n"); 295 CX18_DEBUG_IOCTL("VIDIOC_TRY_EXT_CTRLS\n");
296 if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG) 296 if (c->ctrl_class == V4L2_CTRL_CLASS_MPEG)
297 return cx2341x_ext_ctrls(&cx->params, 297 return cx2341x_ext_ctrls(&cx->params,
298 atomic_read(&cx->capturing), arg, cmd); 298 atomic_read(&cx->ana_capturing), arg, cmd);
299 return -EINVAL; 299 return -EINVAL;
300 } 300 }
301 301
diff --git a/drivers/media/video/cx18/cx18-driver.c b/drivers/media/video/cx18/cx18-driver.c
index 0dd4e0529970..2b810bb2a4c7 100644
--- a/drivers/media/video/cx18/cx18-driver.c
+++ b/drivers/media/video/cx18/cx18-driver.c
@@ -670,7 +670,7 @@ static int __devinit cx18_probe(struct pci_dev *dev,
670 cx18_init_power(cx, 1); 670 cx18_init_power(cx, 1);
671 cx18_init_memory(cx); 671 cx18_init_memory(cx);
672 672
673 cx->scb = (struct cx18_scb *)(cx->enc_mem + SCB_OFFSET); 673 cx->scb = (struct cx18_scb __iomem *)(cx->enc_mem + SCB_OFFSET);
674 cx18_init_scb(cx); 674 cx18_init_scb(cx);
675 675
676 cx18_gpio_init(cx); 676 cx18_gpio_init(cx);
@@ -751,17 +751,6 @@ static int __devinit cx18_probe(struct pci_dev *dev,
751 if (cx->options.radio > 0) 751 if (cx->options.radio > 0)
752 cx->v4l2_cap |= V4L2_CAP_RADIO; 752 cx->v4l2_cap |= V4L2_CAP_RADIO;
753 753
754 retval = cx18_streams_setup(cx);
755 if (retval) {
756 CX18_ERR("Error %d setting up streams\n", retval);
757 goto free_irq;
758 }
759 retval = cx18_streams_register(cx);
760 if (retval) {
761 CX18_ERR("Error %d registering devices\n", retval);
762 goto free_streams;
763 }
764
765 if (cx->options.tuner > -1) { 754 if (cx->options.tuner > -1) {
766 struct tuner_setup setup; 755 struct tuner_setup setup;
767 756
@@ -788,7 +777,16 @@ static int __devinit cx18_probe(struct pci_dev *dev,
788 are not. */ 777 are not. */
789 cx->tuner_std = cx->std; 778 cx->tuner_std = cx->std;
790 779
791 cx18_init_on_first_open(cx); 780 retval = cx18_streams_setup(cx);
781 if (retval) {
782 CX18_ERR("Error %d setting up streams\n", retval);
783 goto free_irq;
784 }
785 retval = cx18_streams_register(cx);
786 if (retval) {
787 CX18_ERR("Error %d registering devices\n", retval);
788 goto free_streams;
789 }
792 790
793 CX18_INFO("Initialized card #%d: %s\n", cx->num, cx->card_name); 791 CX18_INFO("Initialized card #%d: %s\n", cx->num, cx->card_name);
794 792
@@ -889,7 +887,7 @@ static void cx18_remove(struct pci_dev *pci_dev)
889 887
890 /* Stop all captures */ 888 /* Stop all captures */
891 CX18_DEBUG_INFO("Stopping all streams\n"); 889 CX18_DEBUG_INFO("Stopping all streams\n");
892 if (atomic_read(&cx->capturing) > 0) 890 if (atomic_read(&cx->tot_capturing) > 0)
893 cx18_stop_all_captures(cx); 891 cx18_stop_all_captures(cx);
894 892
895 /* Interrupts */ 893 /* Interrupts */
diff --git a/drivers/media/video/cx18/cx18-driver.h b/drivers/media/video/cx18/cx18-driver.h
index a2a6c58d12fe..de14ab59a206 100644
--- a/drivers/media/video/cx18/cx18-driver.h
+++ b/drivers/media/video/cx18/cx18-driver.h
@@ -358,7 +358,7 @@ struct cx18 {
358 u32 v4l2_cap; /* V4L2 capabilities of card */ 358 u32 v4l2_cap; /* V4L2 capabilities of card */
359 u32 hw_flags; /* Hardware description of the board */ 359 u32 hw_flags; /* Hardware description of the board */
360 unsigned mdl_offset; 360 unsigned mdl_offset;
361 struct cx18_scb *scb; /* pointer to SCB */ 361 struct cx18_scb __iomem *scb; /* pointer to SCB */
362 362
363 struct cx18_av_state av_state; 363 struct cx18_av_state av_state;
364 364
@@ -380,7 +380,8 @@ struct cx18 {
380 int stream_buf_size[CX18_MAX_STREAMS]; /* Stream buffer size */ 380 int stream_buf_size[CX18_MAX_STREAMS]; /* Stream buffer size */
381 struct cx18_stream streams[CX18_MAX_STREAMS]; /* Stream data */ 381 struct cx18_stream streams[CX18_MAX_STREAMS]; /* Stream data */
382 unsigned long i_flags; /* global cx18 flags */ 382 unsigned long i_flags; /* global cx18 flags */
383 atomic_t capturing; /* count number of active capture streams */ 383 atomic_t ana_capturing; /* count number of active analog capture streams */
384 atomic_t tot_capturing; /* total count number of active capture streams */
384 spinlock_t lock; /* lock access to this struct */ 385 spinlock_t lock; /* lock access to this struct */
385 int search_pack_header; 386 int search_pack_header;
386 387
@@ -423,6 +424,10 @@ struct cx18 {
423 struct mutex i2c_bus_lock[2]; 424 struct mutex i2c_bus_lock[2];
424 struct i2c_client *i2c_clients[I2C_CLIENTS_MAX]; 425 struct i2c_client *i2c_clients[I2C_CLIENTS_MAX];
425 426
427 /* gpio */
428 u32 gpio_dir;
429 u32 gpio_val;
430
426 /* v4l2 and User settings */ 431 /* v4l2 and User settings */
427 432
428 /* codec settings */ 433 /* codec settings */
diff --git a/drivers/media/video/cx18/cx18-fileops.c b/drivers/media/video/cx18/cx18-fileops.c
index 0b3141db174b..1e537fe04a23 100644
--- a/drivers/media/video/cx18/cx18-fileops.c
+++ b/drivers/media/video/cx18/cx18-fileops.c
@@ -318,7 +318,7 @@ static ssize_t cx18_read(struct cx18_stream *s, char __user *ubuf,
318 size_t tot_written = 0; 318 size_t tot_written = 0;
319 int single_frame = 0; 319 int single_frame = 0;
320 320
321 if (atomic_read(&cx->capturing) == 0 && s->id == -1) { 321 if (atomic_read(&cx->ana_capturing) == 0 && s->id == -1) {
322 /* shouldn't happen */ 322 /* shouldn't happen */
323 CX18_DEBUG_WARN("Stream %s not initialized before read\n", 323 CX18_DEBUG_WARN("Stream %s not initialized before read\n",
324 s->name); 324 s->name);
@@ -361,7 +361,8 @@ static ssize_t cx18_read(struct cx18_stream *s, char __user *ubuf,
361 cx18_enqueue(s, buf, &s->q_free); 361 cx18_enqueue(s, buf, &s->q_free);
362 cx18_vapi(cx, CX18_CPU_DE_SET_MDL, 5, 362 cx18_vapi(cx, CX18_CPU_DE_SET_MDL, 5,
363 s->handle, 363 s->handle,
364 (void *)&cx->scb->cpu_mdl[buf->id] - cx->enc_mem, 364 (void __iomem *)&cx->scb->cpu_mdl[buf->id] -
365 cx->enc_mem,
365 1, buf->id, s->buf_size); 366 1, buf->id, s->buf_size);
366 } else 367 } else
367 cx18_enqueue(s, buf, &s->q_io); 368 cx18_enqueue(s, buf, &s->q_io);
@@ -581,7 +582,7 @@ int cx18_v4l2_close(struct inode *inode, struct file *filp)
581 cx18_call_i2c_clients(cx, VIDIOC_S_STD, &cx->std); 582 cx18_call_i2c_clients(cx, VIDIOC_S_STD, &cx->std);
582 /* Select correct audio input (i.e. TV tuner or Line in) */ 583 /* Select correct audio input (i.e. TV tuner or Line in) */
583 cx18_audio_set_io(cx); 584 cx18_audio_set_io(cx);
584 if (atomic_read(&cx->capturing) > 0) { 585 if (atomic_read(&cx->ana_capturing) > 0) {
585 /* Undo video mute */ 586 /* Undo video mute */
586 cx18_vapi(cx, CX18_CPU_SET_VIDEO_MUTE, 2, s->handle, 587 cx18_vapi(cx, CX18_CPU_SET_VIDEO_MUTE, 2, s->handle,
587 cx->params.video_mute | 588 cx->params.video_mute |
@@ -627,7 +628,7 @@ static int cx18_serialized_open(struct cx18_stream *s, struct file *filp)
627 } 628 }
628 629
629 if (!test_bit(CX18_F_I_RADIO_USER, &cx->i_flags)) { 630 if (!test_bit(CX18_F_I_RADIO_USER, &cx->i_flags)) {
630 if (atomic_read(&cx->capturing) > 0) { 631 if (atomic_read(&cx->ana_capturing) > 0) {
631 /* switching to radio while capture is 632 /* switching to radio while capture is
632 in progress is not polite */ 633 in progress is not polite */
633 cx18_release_stream(s); 634 cx18_release_stream(s);
@@ -694,7 +695,7 @@ int cx18_v4l2_open(struct inode *inode, struct file *filp)
694 695
695void cx18_mute(struct cx18 *cx) 696void cx18_mute(struct cx18 *cx)
696{ 697{
697 if (atomic_read(&cx->capturing)) 698 if (atomic_read(&cx->ana_capturing))
698 cx18_vapi(cx, CX18_CPU_SET_AUDIO_MUTE, 2, 699 cx18_vapi(cx, CX18_CPU_SET_AUDIO_MUTE, 2,
699 cx18_find_handle(cx), 1); 700 cx18_find_handle(cx), 1);
700 CX18_DEBUG_INFO("Mute\n"); 701 CX18_DEBUG_INFO("Mute\n");
@@ -702,7 +703,7 @@ void cx18_mute(struct cx18 *cx)
702 703
703void cx18_unmute(struct cx18 *cx) 704void cx18_unmute(struct cx18 *cx)
704{ 705{
705 if (atomic_read(&cx->capturing)) { 706 if (atomic_read(&cx->ana_capturing)) {
706 cx18_msleep_timeout(100, 0); 707 cx18_msleep_timeout(100, 0);
707 cx18_vapi(cx, CX18_CPU_SET_MISC_PARAMETERS, 2, 708 cx18_vapi(cx, CX18_CPU_SET_MISC_PARAMETERS, 2,
708 cx18_find_handle(cx), 12); 709 cx18_find_handle(cx), 12);
diff --git a/drivers/media/video/cx18/cx18-gpio.c b/drivers/media/video/cx18/cx18-gpio.c
index bb8bc86086d0..ceb63653c926 100644
--- a/drivers/media/video/cx18/cx18-gpio.c
+++ b/drivers/media/video/cx18/cx18-gpio.c
@@ -35,9 +35,6 @@
35#define CX18_REG_GPIO_OUT2 0xc78104 35#define CX18_REG_GPIO_OUT2 0xc78104
36#define CX18_REG_GPIO_DIR2 0xc7810c 36#define CX18_REG_GPIO_DIR2 0xc7810c
37 37
38static u32 gpio_dir;
39static u32 gpio_val;
40
41/* 38/*
42 * HVR-1600 GPIO pins, courtesy of Hauppauge: 39 * HVR-1600 GPIO pins, courtesy of Hauppauge:
43 * 40 *
@@ -49,24 +46,29 @@ static u32 gpio_val;
49 46
50static void gpio_write(struct cx18 *cx) 47static void gpio_write(struct cx18 *cx)
51{ 48{
52 write_reg((gpio_dir & 0xffff) << 16, CX18_REG_GPIO_DIR1); 49 u32 dir = cx->gpio_dir;
53 write_reg(((gpio_dir & 0xffff) << 16) | (gpio_val & 0xffff), 50 u32 val = cx->gpio_val;
51
52 write_reg((dir & 0xffff) << 16, CX18_REG_GPIO_DIR1);
53 write_reg(((dir & 0xffff) << 16) | (val & 0xffff),
54 CX18_REG_GPIO_OUT1); 54 CX18_REG_GPIO_OUT1);
55 write_reg(gpio_dir & 0xffff0000, CX18_REG_GPIO_DIR2); 55 write_reg(dir & 0xffff0000, CX18_REG_GPIO_DIR2);
56 write_reg((gpio_dir & 0xffff0000) | ((gpio_val & 0xffff0000) >> 16), 56 write_reg((dir & 0xffff0000) | ((val & 0xffff0000) >> 16),
57 CX18_REG_GPIO_OUT2); 57 CX18_REG_GPIO_OUT2);
58} 58}
59 59
60void cx18_gpio_init(struct cx18 *cx) 60void cx18_gpio_init(struct cx18 *cx)
61{ 61{
62 gpio_dir = cx->card->gpio_init.direction; 62 cx->gpio_dir = cx->card->gpio_init.direction;
63 gpio_val = cx->card->gpio_init.initial_value; 63 cx->gpio_val = cx->card->gpio_init.initial_value;
64 64
65 if (gpio_dir == 0) 65 if (cx->card->tuners[0].tuner == TUNER_XC2028) {
66 return; 66 cx->gpio_dir |= 1 << cx->card->xceive_pin;
67 cx->gpio_val |= 1 << cx->card->xceive_pin;
68 }
67 69
68 gpio_dir |= 1 << cx->card->xceive_pin; 70 if (cx->gpio_dir == 0)
69 gpio_val |= 1 << cx->card->xceive_pin; 71 return;
70 72
71 CX18_DEBUG_INFO("GPIO initial dir: %08x/%08x out: %08x/%08x\n", 73 CX18_DEBUG_INFO("GPIO initial dir: %08x/%08x out: %08x/%08x\n",
72 read_reg(CX18_REG_GPIO_DIR1), read_reg(CX18_REG_GPIO_DIR2), 74 read_reg(CX18_REG_GPIO_DIR1), read_reg(CX18_REG_GPIO_DIR2),
@@ -86,13 +88,12 @@ int cx18_reset_tuner_gpio(void *dev, int cmd, int value)
86 return 0; 88 return 0;
87 CX18_DEBUG_INFO("Resetting tuner\n"); 89 CX18_DEBUG_INFO("Resetting tuner\n");
88 90
89 gpio_dir |= 1 << cx->card->xceive_pin; 91 cx->gpio_val &= ~(1 << cx->card->xceive_pin);
90 gpio_val &= ~(1 << cx->card->xceive_pin);
91 92
92 gpio_write(cx); 93 gpio_write(cx);
93 schedule_timeout_interruptible(msecs_to_jiffies(1)); 94 schedule_timeout_interruptible(msecs_to_jiffies(1));
94 95
95 gpio_val |= 1 << cx->card->xceive_pin; 96 cx->gpio_val |= 1 << cx->card->xceive_pin;
96 gpio_write(cx); 97 gpio_write(cx);
97 schedule_timeout_interruptible(msecs_to_jiffies(1)); 98 schedule_timeout_interruptible(msecs_to_jiffies(1));
98 return 0; 99 return 0;
diff --git a/drivers/media/video/cx18/cx18-ioctl.c b/drivers/media/video/cx18/cx18-ioctl.c
index dbdcb86ec5aa..4151f1e5493f 100644
--- a/drivers/media/video/cx18/cx18-ioctl.c
+++ b/drivers/media/video/cx18/cx18-ioctl.c
@@ -247,7 +247,7 @@ static int cx18_try_or_set_fmt(struct cx18 *cx, int streamtype,
247 247
248 if (!set_fmt || (cx->params.width == w && cx->params.height == h)) 248 if (!set_fmt || (cx->params.width == w && cx->params.height == h))
249 return 0; 249 return 0;
250 if (atomic_read(&cx->capturing) > 0) 250 if (atomic_read(&cx->ana_capturing) > 0)
251 return -EBUSY; 251 return -EBUSY;
252 252
253 cx->params.width = w; 253 cx->params.width = w;
@@ -264,7 +264,7 @@ static int cx18_try_or_set_fmt(struct cx18 *cx, int streamtype,
264 if (fmt->type == V4L2_BUF_TYPE_VBI_CAPTURE) { 264 if (fmt->type == V4L2_BUF_TYPE_VBI_CAPTURE) {
265 if (set_fmt && streamtype == CX18_ENC_STREAM_TYPE_VBI && 265 if (set_fmt && streamtype == CX18_ENC_STREAM_TYPE_VBI &&
266 cx->vbi.sliced_in->service_set && 266 cx->vbi.sliced_in->service_set &&
267 atomic_read(&cx->capturing) > 0) 267 atomic_read(&cx->ana_capturing) > 0)
268 return -EBUSY; 268 return -EBUSY;
269 if (set_fmt) { 269 if (set_fmt) {
270 cx->vbi.sliced_in->service_set = 0; 270 cx->vbi.sliced_in->service_set = 0;
@@ -293,7 +293,7 @@ static int cx18_try_or_set_fmt(struct cx18 *cx, int streamtype,
293 return 0; 293 return 0;
294 if (set == 0) 294 if (set == 0)
295 return -EINVAL; 295 return -EINVAL;
296 if (atomic_read(&cx->capturing) > 0 && cx->vbi.sliced_in->service_set == 0) 296 if (atomic_read(&cx->ana_capturing) > 0 && cx->vbi.sliced_in->service_set == 0)
297 return -EBUSY; 297 return -EBUSY;
298 cx18_av_cmd(cx, VIDIOC_S_FMT, fmt); 298 cx18_av_cmd(cx, VIDIOC_S_FMT, fmt);
299 memcpy(cx->vbi.sliced_in, vbifmt, sizeof(*cx->vbi.sliced_in)); 299 memcpy(cx->vbi.sliced_in, vbifmt, sizeof(*cx->vbi.sliced_in));
@@ -581,7 +581,7 @@ int cx18_v4l2_ioctls(struct cx18 *cx, struct file *filp, unsigned cmd, void *arg
581 break; 581 break;
582 582
583 if (test_bit(CX18_F_I_RADIO_USER, &cx->i_flags) || 583 if (test_bit(CX18_F_I_RADIO_USER, &cx->i_flags) ||
584 atomic_read(&cx->capturing) > 0) { 584 atomic_read(&cx->ana_capturing) > 0) {
585 /* Switching standard would turn off the radio or mess 585 /* Switching standard would turn off the radio or mess
586 with already running streams, prevent that by 586 with already running streams, prevent that by
587 returning EBUSY. */ 587 returning EBUSY. */
@@ -677,7 +677,7 @@ int cx18_v4l2_ioctls(struct cx18 *cx, struct file *filp, unsigned cmd, void *arg
677 enc->flags = 0; 677 enc->flags = 0;
678 if (try) 678 if (try)
679 return 0; 679 return 0;
680 if (!atomic_read(&cx->capturing)) 680 if (!atomic_read(&cx->ana_capturing))
681 return -EPERM; 681 return -EPERM;
682 if (test_and_set_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags)) 682 if (test_and_set_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags))
683 return 0; 683 return 0;
@@ -689,7 +689,7 @@ int cx18_v4l2_ioctls(struct cx18 *cx, struct file *filp, unsigned cmd, void *arg
689 enc->flags = 0; 689 enc->flags = 0;
690 if (try) 690 if (try)
691 return 0; 691 return 0;
692 if (!atomic_read(&cx->capturing)) 692 if (!atomic_read(&cx->ana_capturing))
693 return -EPERM; 693 return -EPERM;
694 if (!test_and_clear_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags)) 694 if (!test_and_clear_bit(CX18_F_I_ENC_PAUSED, &cx->i_flags))
695 return 0; 695 return 0;
diff --git a/drivers/media/video/cx18/cx18-irq.c b/drivers/media/video/cx18/cx18-irq.c
index 6e14f8bda559..25114a5cbd57 100644
--- a/drivers/media/video/cx18/cx18-irq.c
+++ b/drivers/media/video/cx18/cx18-irq.c
@@ -75,7 +75,7 @@ static void epu_dma_done(struct cx18 *cx, struct cx18_mailbox *mb)
75 75
76 cx18_buf_sync_for_device(s, buf); 76 cx18_buf_sync_for_device(s, buf);
77 cx18_vapi(cx, CX18_CPU_DE_SET_MDL, 5, s->handle, 77 cx18_vapi(cx, CX18_CPU_DE_SET_MDL, 5, s->handle,
78 (void *)&cx->scb->cpu_mdl[buf->id] - cx->enc_mem, 78 (void __iomem *)&cx->scb->cpu_mdl[buf->id] - cx->enc_mem,
79 1, buf->id, s->buf_size); 79 1, buf->id, s->buf_size);
80 } else 80 } else
81 set_bit(CX18_F_B_NEED_BUF_SWAP, &buf->b_flags); 81 set_bit(CX18_F_B_NEED_BUF_SWAP, &buf->b_flags);
@@ -161,13 +161,15 @@ irqreturn_t cx18_irq_handler(int irq, void *dev_id)
161 */ 161 */
162 162
163 if (sw2) { 163 if (sw2) {
164 if (sw2 & (cx->scb->cpu2hpu_irq_ack | cx->scb->cpu2epu_irq_ack)) 164 if (sw2 & (readl(&cx->scb->cpu2hpu_irq_ack) |
165 readl(&cx->scb->cpu2epu_irq_ack)))
165 wake_up(&cx->mb_cpu_waitq); 166 wake_up(&cx->mb_cpu_waitq);
166 if (sw2 & (cx->scb->apu2hpu_irq_ack | cx->scb->apu2epu_irq_ack)) 167 if (sw2 & (readl(&cx->scb->apu2hpu_irq_ack) |
168 readl(&cx->scb->apu2epu_irq_ack)))
167 wake_up(&cx->mb_apu_waitq); 169 wake_up(&cx->mb_apu_waitq);
168 if (sw2 & cx->scb->epu2hpu_irq_ack) 170 if (sw2 & readl(&cx->scb->epu2hpu_irq_ack))
169 wake_up(&cx->mb_epu_waitq); 171 wake_up(&cx->mb_epu_waitq);
170 if (sw2 & cx->scb->hpu2epu_irq_ack) 172 if (sw2 & readl(&cx->scb->hpu2epu_irq_ack))
171 wake_up(&cx->mb_hpu_waitq); 173 wake_up(&cx->mb_hpu_waitq);
172 } 174 }
173 175
diff --git a/drivers/media/video/cx18/cx18-mailbox.c b/drivers/media/video/cx18/cx18-mailbox.c
index 0c5f328bca54..2a5ccef9185b 100644
--- a/drivers/media/video/cx18/cx18-mailbox.c
+++ b/drivers/media/video/cx18/cx18-mailbox.c
@@ -94,10 +94,10 @@ static const struct cx18_api_info *find_api_info(u32 cmd)
94 return NULL; 94 return NULL;
95} 95}
96 96
97static struct cx18_mailbox *cx18_mb_is_complete(struct cx18 *cx, int rpu, 97static struct cx18_mailbox __iomem *cx18_mb_is_complete(struct cx18 *cx, int rpu,
98 u32 *state, u32 *irq, u32 *req) 98 u32 *state, u32 *irq, u32 *req)
99{ 99{
100 struct cx18_mailbox *mb = NULL; 100 struct cx18_mailbox __iomem *mb = NULL;
101 int wait_count = 0; 101 int wait_count = 0;
102 u32 ack; 102 u32 ack;
103 103
@@ -142,7 +142,7 @@ static struct cx18_mailbox *cx18_mb_is_complete(struct cx18 *cx, int rpu,
142long cx18_mb_ack(struct cx18 *cx, const struct cx18_mailbox *mb) 142long cx18_mb_ack(struct cx18 *cx, const struct cx18_mailbox *mb)
143{ 143{
144 const struct cx18_api_info *info = find_api_info(mb->cmd); 144 const struct cx18_api_info *info = find_api_info(mb->cmd);
145 struct cx18_mailbox *ack_mb; 145 struct cx18_mailbox __iomem *ack_mb;
146 u32 ack_irq; 146 u32 ack_irq;
147 u8 rpu = CPU; 147 u8 rpu = CPU;
148 148
@@ -182,7 +182,7 @@ static int cx18_api_call(struct cx18 *cx, u32 cmd, int args, u32 data[])
182{ 182{
183 const struct cx18_api_info *info = find_api_info(cmd); 183 const struct cx18_api_info *info = find_api_info(cmd);
184 u32 state = 0, irq = 0, req, oldreq, err; 184 u32 state = 0, irq = 0, req, oldreq, err;
185 struct cx18_mailbox *mb; 185 struct cx18_mailbox __iomem *mb;
186 wait_queue_head_t *waitq; 186 wait_queue_head_t *waitq;
187 int timeout = 100; 187 int timeout = 100;
188 int cnt = 0; 188 int cnt = 0;
diff --git a/drivers/media/video/cx18/cx18-streams.c b/drivers/media/video/cx18/cx18-streams.c
index 4ca9d847f1b1..1b921a336092 100644
--- a/drivers/media/video/cx18/cx18-streams.c
+++ b/drivers/media/video/cx18/cx18-streams.c
@@ -36,12 +36,13 @@
36#define CX18_DSP0_INTERRUPT_MASK 0xd0004C 36#define CX18_DSP0_INTERRUPT_MASK 0xd0004C
37 37
38static struct file_operations cx18_v4l2_enc_fops = { 38static struct file_operations cx18_v4l2_enc_fops = {
39 .owner = THIS_MODULE, 39 .owner = THIS_MODULE,
40 .read = cx18_v4l2_read, 40 .read = cx18_v4l2_read,
41 .open = cx18_v4l2_open, 41 .open = cx18_v4l2_open,
42 .ioctl = cx18_v4l2_ioctl, 42 .ioctl = cx18_v4l2_ioctl,
43 .release = cx18_v4l2_close, 43 .compat_ioctl = v4l_compat_ioctl32,
44 .poll = cx18_v4l2_enc_poll, 44 .release = cx18_v4l2_close,
45 .poll = cx18_v4l2_enc_poll,
45}; 46};
46 47
47/* offset from 0 to register ts v4l2 minors on */ 48/* offset from 0 to register ts v4l2 minors on */
@@ -443,7 +444,7 @@ int cx18_start_v4l2_encode_stream(struct cx18_stream *s)
443 s->handle = data[0]; 444 s->handle = data[0];
444 cx18_vapi(cx, CX18_CPU_SET_CHANNEL_TYPE, 2, s->handle, captype); 445 cx18_vapi(cx, CX18_CPU_SET_CHANNEL_TYPE, 2, s->handle, captype);
445 446
446 if (atomic_read(&cx->capturing) == 0 && !ts) { 447 if (atomic_read(&cx->ana_capturing) == 0 && !ts) {
447 /* Stuff from Windows, we don't know what it is */ 448 /* Stuff from Windows, we don't know what it is */
448 cx18_vapi(cx, CX18_CPU_SET_VER_CROP_LINE, 2, s->handle, 0); 449 cx18_vapi(cx, CX18_CPU_SET_VER_CROP_LINE, 2, s->handle, 0);
449 cx18_vapi(cx, CX18_CPU_SET_MISC_PARAMETERS, 3, s->handle, 3, 1); 450 cx18_vapi(cx, CX18_CPU_SET_MISC_PARAMETERS, 3, s->handle, 3, 1);
@@ -466,14 +467,14 @@ int cx18_start_v4l2_encode_stream(struct cx18_stream *s)
466 cx2341x_update(cx, cx18_api_func, NULL, &cx->params); 467 cx2341x_update(cx, cx18_api_func, NULL, &cx->params);
467 } 468 }
468 469
469 if (atomic_read(&cx->capturing) == 0) { 470 if (atomic_read(&cx->tot_capturing) == 0) {
470 clear_bit(CX18_F_I_EOS, &cx->i_flags); 471 clear_bit(CX18_F_I_EOS, &cx->i_flags);
471 write_reg(7, CX18_DSP0_INTERRUPT_MASK); 472 write_reg(7, CX18_DSP0_INTERRUPT_MASK);
472 } 473 }
473 474
474 cx18_vapi(cx, CX18_CPU_DE_SET_MDL_ACK, 3, s->handle, 475 cx18_vapi(cx, CX18_CPU_DE_SET_MDL_ACK, 3, s->handle,
475 (void *)&cx->scb->cpu_mdl_ack[s->type][0] - cx->enc_mem, 476 (void __iomem *)&cx->scb->cpu_mdl_ack[s->type][0] - cx->enc_mem,
476 (void *)&cx->scb->cpu_mdl_ack[s->type][1] - cx->enc_mem); 477 (void __iomem *)&cx->scb->cpu_mdl_ack[s->type][1] - cx->enc_mem);
477 478
478 list_for_each(p, &s->q_free.list) { 479 list_for_each(p, &s->q_free.list) {
479 struct cx18_buffer *buf = list_entry(p, struct cx18_buffer, list); 480 struct cx18_buffer *buf = list_entry(p, struct cx18_buffer, list);
@@ -481,8 +482,8 @@ int cx18_start_v4l2_encode_stream(struct cx18_stream *s)
481 writel(buf->dma_handle, &cx->scb->cpu_mdl[buf->id].paddr); 482 writel(buf->dma_handle, &cx->scb->cpu_mdl[buf->id].paddr);
482 writel(s->buf_size, &cx->scb->cpu_mdl[buf->id].length); 483 writel(s->buf_size, &cx->scb->cpu_mdl[buf->id].length);
483 cx18_vapi(cx, CX18_CPU_DE_SET_MDL, 5, s->handle, 484 cx18_vapi(cx, CX18_CPU_DE_SET_MDL, 5, s->handle,
484 (void *)&cx->scb->cpu_mdl[buf->id] - cx->enc_mem, 1, 485 (void __iomem *)&cx->scb->cpu_mdl[buf->id] - cx->enc_mem,
485 buf->id, s->buf_size); 486 1, buf->id, s->buf_size);
486 } 487 }
487 /* begin_capture */ 488 /* begin_capture */
488 if (cx18_vapi(cx, CX18_CPU_CAPTURE_START, 1, s->handle)) { 489 if (cx18_vapi(cx, CX18_CPU_CAPTURE_START, 1, s->handle)) {
@@ -492,7 +493,9 @@ int cx18_start_v4l2_encode_stream(struct cx18_stream *s)
492 } 493 }
493 494
494 /* you're live! sit back and await interrupts :) */ 495 /* you're live! sit back and await interrupts :) */
495 atomic_inc(&cx->capturing); 496 if (!ts)
497 atomic_inc(&cx->ana_capturing);
498 atomic_inc(&cx->tot_capturing);
496 return 0; 499 return 0;
497} 500}
498 501
@@ -523,7 +526,7 @@ int cx18_stop_v4l2_encode_stream(struct cx18_stream *s, int gop_end)
523 526
524 CX18_DEBUG_INFO("Stop Capture\n"); 527 CX18_DEBUG_INFO("Stop Capture\n");
525 528
526 if (atomic_read(&cx->capturing) == 0) 529 if (atomic_read(&cx->tot_capturing) == 0)
527 return 0; 530 return 0;
528 531
529 if (s->type == CX18_ENC_STREAM_TYPE_MPG) 532 if (s->type == CX18_ENC_STREAM_TYPE_MPG)
@@ -537,7 +540,9 @@ int cx18_stop_v4l2_encode_stream(struct cx18_stream *s, int gop_end)
537 CX18_INFO("ignoring gop_end: not (yet?) supported by the firmware\n"); 540 CX18_INFO("ignoring gop_end: not (yet?) supported by the firmware\n");
538 } 541 }
539 542
540 atomic_dec(&cx->capturing); 543 if (s->type != CX18_ENC_STREAM_TYPE_TS)
544 atomic_dec(&cx->ana_capturing);
545 atomic_dec(&cx->tot_capturing);
541 546
542 /* Clear capture and no-read bits */ 547 /* Clear capture and no-read bits */
543 clear_bit(CX18_F_S_STREAMING, &s->s_flags); 548 clear_bit(CX18_F_S_STREAMING, &s->s_flags);
@@ -545,7 +550,7 @@ int cx18_stop_v4l2_encode_stream(struct cx18_stream *s, int gop_end)
545 cx18_vapi(cx, CX18_DESTROY_TASK, 1, s->handle); 550 cx18_vapi(cx, CX18_DESTROY_TASK, 1, s->handle);
546 s->handle = 0xffffffff; 551 s->handle = 0xffffffff;
547 552
548 if (atomic_read(&cx->capturing) > 0) 553 if (atomic_read(&cx->tot_capturing) > 0)
549 return 0; 554 return 0;
550 555
551 write_reg(5, CX18_DSP0_INTERRUPT_MASK); 556 write_reg(5, CX18_DSP0_INTERRUPT_MASK);
diff --git a/drivers/media/video/cx23885/cx23885-core.c b/drivers/media/video/cx23885/cx23885-core.c
index f24abcd06dea..c4cc2f3b8876 100644
--- a/drivers/media/video/cx23885/cx23885-core.c
+++ b/drivers/media/video/cx23885/cx23885-core.c
@@ -823,7 +823,7 @@ static void cx23885_dev_unregister(struct cx23885_dev *dev)
823 iounmap(dev->lmmio); 823 iounmap(dev->lmmio);
824} 824}
825 825
826static u32* cx23885_risc_field(u32 *rp, struct scatterlist *sglist, 826static __le32* cx23885_risc_field(__le32 *rp, struct scatterlist *sglist,
827 unsigned int offset, u32 sync_line, 827 unsigned int offset, u32 sync_line,
828 unsigned int bpl, unsigned int padding, 828 unsigned int bpl, unsigned int padding,
829 unsigned int lines) 829 unsigned int lines)
@@ -883,7 +883,7 @@ int cx23885_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc,
883 unsigned int padding, unsigned int lines) 883 unsigned int padding, unsigned int lines)
884{ 884{
885 u32 instructions, fields; 885 u32 instructions, fields;
886 u32 *rp; 886 __le32 *rp;
887 int rc; 887 int rc;
888 888
889 fields = 0; 889 fields = 0;
@@ -924,7 +924,7 @@ static int cx23885_risc_databuffer(struct pci_dev *pci,
924 unsigned int lines) 924 unsigned int lines)
925{ 925{
926 u32 instructions; 926 u32 instructions;
927 u32 *rp; 927 __le32 *rp;
928 int rc; 928 int rc;
929 929
930 /* estimate risc mem: worst case is one write per page border + 930 /* estimate risc mem: worst case is one write per page border +
@@ -951,7 +951,7 @@ static int cx23885_risc_databuffer(struct pci_dev *pci,
951int cx23885_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc, 951int cx23885_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc,
952 u32 reg, u32 mask, u32 value) 952 u32 reg, u32 mask, u32 value)
953{ 953{
954 u32 *rp; 954 __le32 *rp;
955 int rc; 955 int rc;
956 956
957 if ((rc = btcx_riscmem_alloc(pci, risc, 4*16)) < 0) 957 if ((rc = btcx_riscmem_alloc(pci, risc, 4*16)) < 0)
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c
index aeba26dc0a37..fa6d398e97b9 100644
--- a/drivers/media/video/cx88/cx88-cards.c
+++ b/drivers/media/video/cx88/cx88-cards.c
@@ -1493,10 +1493,16 @@ static const struct cx88_board cx88_boards[] = {
1493 }, 1493 },
1494 }, 1494 },
1495 [CX88_BOARD_POWERCOLOR_REAL_ANGEL] = { 1495 [CX88_BOARD_POWERCOLOR_REAL_ANGEL] = {
1496 .name = "PowerColor Real Angel 330", 1496 .name = "PowerColor RA330", /* Long names may confuse LIRC. */
1497 .tuner_type = TUNER_XC2028, 1497 .tuner_type = TUNER_XC2028,
1498 .tuner_addr = 0x61, 1498 .tuner_addr = 0x61,
1499 .input = { { 1499 .input = { {
1500 .type = CX88_VMUX_DEBUG,
1501 .vmux = 3, /* Due to the way the cx88 driver is written, */
1502 .gpio0 = 0x00ff, /* there is no way to deactivate audio pass- */
1503 .gpio1 = 0xf39d, /* through without this entry. Furthermore, if */
1504 .gpio3 = 0x0000, /* the TV mux entry is first, you get audio */
1505 }, { /* from the tuner on boot for a little while. */
1500 .type = CX88_VMUX_TELEVISION, 1506 .type = CX88_VMUX_TELEVISION,
1501 .vmux = 0, 1507 .vmux = 0,
1502 .gpio0 = 0x00ff, 1508 .gpio0 = 0x00ff,
@@ -2424,8 +2430,9 @@ void cx88_setup_xc3028(struct cx88_core *core, struct xc2028_ctrl *ctl)
2424 2430
2425 switch (core->boardnr) { 2431 switch (core->boardnr) {
2426 case CX88_BOARD_POWERCOLOR_REAL_ANGEL: 2432 case CX88_BOARD_POWERCOLOR_REAL_ANGEL:
2427 /* Doesn't work with firmware version 2.7 */ 2433 /* Now works with firmware version 2.7 */
2428 ctl->fname = "xc3028-v25.fw"; 2434 if (core->i2c_algo.udelay < 16)
2435 core->i2c_algo.udelay = 16;
2429 break; 2436 break;
2430 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO: 2437 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO:
2431 ctl->scode_table = XC3028_FE_ZARLINK456; 2438 ctl->scode_table = XC3028_FE_ZARLINK456;
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c
index c4d1aff1fdb4..60eeda3057e9 100644
--- a/drivers/media/video/cx88/cx88-core.c
+++ b/drivers/media/video/cx88/cx88-core.c
@@ -70,7 +70,7 @@ static DEFINE_MUTEX(devlist);
70 70
71/* @lpi: lines per IRQ, or 0 to not generate irqs. Note: IRQ to be 71/* @lpi: lines per IRQ, or 0 to not generate irqs. Note: IRQ to be
72 generated _after_ lpi lines are transferred. */ 72 generated _after_ lpi lines are transferred. */
73static u32* cx88_risc_field(u32 *rp, struct scatterlist *sglist, 73static __le32* cx88_risc_field(__le32 *rp, struct scatterlist *sglist,
74 unsigned int offset, u32 sync_line, 74 unsigned int offset, u32 sync_line,
75 unsigned int bpl, unsigned int padding, 75 unsigned int bpl, unsigned int padding,
76 unsigned int lines, unsigned int lpi) 76 unsigned int lines, unsigned int lpi)
@@ -130,7 +130,7 @@ int cx88_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc,
130 unsigned int bpl, unsigned int padding, unsigned int lines) 130 unsigned int bpl, unsigned int padding, unsigned int lines)
131{ 131{
132 u32 instructions,fields; 132 u32 instructions,fields;
133 u32 *rp; 133 __le32 *rp;
134 int rc; 134 int rc;
135 135
136 fields = 0; 136 fields = 0;
@@ -168,7 +168,7 @@ int cx88_risc_databuffer(struct pci_dev *pci, struct btcx_riscmem *risc,
168 unsigned int lines, unsigned int lpi) 168 unsigned int lines, unsigned int lpi)
169{ 169{
170 u32 instructions; 170 u32 instructions;
171 u32 *rp; 171 __le32 *rp;
172 int rc; 172 int rc;
173 173
174 /* estimate risc mem: worst case is one write per page border + 174 /* estimate risc mem: worst case is one write per page border +
@@ -193,7 +193,7 @@ int cx88_risc_databuffer(struct pci_dev *pci, struct btcx_riscmem *risc,
193int cx88_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc, 193int cx88_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc,
194 u32 reg, u32 mask, u32 value) 194 u32 reg, u32 mask, u32 value)
195{ 195{
196 u32 *rp; 196 __le32 *rp;
197 int rc; 197 int rc;
198 198
199 if ((rc = btcx_riscmem_alloc(pci, risc, 4*16)) < 0) 199 if ((rc = btcx_riscmem_alloc(pci, risc, 4*16)) < 0)
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index 8996175cc950..fb163ecd9216 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -1166,13 +1166,13 @@ static int vidioc_g_register(struct file *file, void *priv,
1166 1166
1167 reg->val = ret; 1167 reg->val = ret;
1168 } else { 1168 } else {
1169 u64 val = 0; 1169 __le64 val = 0;
1170 ret = em28xx_read_reg_req_len(dev, USB_REQ_GET_STATUS, 1170 ret = em28xx_read_reg_req_len(dev, USB_REQ_GET_STATUS,
1171 reg->reg, (char *)&val, 2); 1171 reg->reg, (char *)&val, 2);
1172 if (ret < 0) 1172 if (ret < 0)
1173 return ret; 1173 return ret;
1174 1174
1175 reg->val = cpu_to_le64((__u64)val); 1175 reg->val = le64_to_cpu(val);
1176 } 1176 }
1177 1177
1178 return 0; 1178 return 0;
@@ -1183,9 +1183,9 @@ static int vidioc_s_register(struct file *file, void *priv,
1183{ 1183{
1184 struct em28xx_fh *fh = priv; 1184 struct em28xx_fh *fh = priv;
1185 struct em28xx *dev = fh->dev; 1185 struct em28xx *dev = fh->dev;
1186 u64 buf; 1186 __le64 buf;
1187 1187
1188 buf = le64_to_cpu((__u64)reg->val); 1188 buf = cpu_to_le64(reg->val);
1189 1189
1190 return em28xx_write_regs(dev, reg->reg, (char *)&buf, 1190 return em28xx_write_regs(dev, reg->reg, (char *)&buf,
1191 em28xx_reg_len(reg->reg)); 1191 em28xx_reg_len(reg->reg));
diff --git a/drivers/media/video/ivtv/ivtv-driver.h b/drivers/media/video/ivtv/ivtv-driver.h
index ba06e813c58c..9d23b1efd36d 100644
--- a/drivers/media/video/ivtv/ivtv-driver.h
+++ b/drivers/media/video/ivtv/ivtv-driver.h
@@ -259,6 +259,12 @@ struct ivtv_mailbox_data {
259 259
260/* Scatter-Gather array element, used in DMA transfers */ 260/* Scatter-Gather array element, used in DMA transfers */
261struct ivtv_sg_element { 261struct ivtv_sg_element {
262 __le32 src;
263 __le32 dst;
264 __le32 size;
265};
266
267struct ivtv_sg_host_element {
262 u32 src; 268 u32 src;
263 u32 dst; 269 u32 dst;
264 u32 size; 270 u32 size;
@@ -349,8 +355,8 @@ struct ivtv_stream {
349 u16 dma_xfer_cnt; 355 u16 dma_xfer_cnt;
350 356
351 /* Base Dev SG Array for cx23415/6 */ 357 /* Base Dev SG Array for cx23415/6 */
352 struct ivtv_sg_element *sg_pending; 358 struct ivtv_sg_host_element *sg_pending;
353 struct ivtv_sg_element *sg_processing; 359 struct ivtv_sg_host_element *sg_processing;
354 struct ivtv_sg_element *sg_dma; 360 struct ivtv_sg_element *sg_dma;
355 dma_addr_t sg_handle; 361 dma_addr_t sg_handle;
356 int sg_pending_size; 362 int sg_pending_size;
diff --git a/drivers/media/video/ivtv/ivtv-fileops.c b/drivers/media/video/ivtv/ivtv-fileops.c
index f2fa434b677b..db813e071ce6 100644
--- a/drivers/media/video/ivtv/ivtv-fileops.c
+++ b/drivers/media/video/ivtv/ivtv-fileops.c
@@ -587,7 +587,7 @@ retry:
587 since we may get here before the stream has been fully set-up */ 587 since we may get here before the stream has been fully set-up */
588 if (mode == OUT_YUV && s->q_full.length == 0 && itv->dma_data_req_size) { 588 if (mode == OUT_YUV && s->q_full.length == 0 && itv->dma_data_req_size) {
589 while (count >= itv->dma_data_req_size) { 589 while (count >= itv->dma_data_req_size) {
590 if (!ivtv_yuv_udma_stream_frame (itv, (void *)user_buf)) { 590 if (!ivtv_yuv_udma_stream_frame (itv, (void __user *)user_buf)) {
591 bytes_written += itv->dma_data_req_size; 591 bytes_written += itv->dma_data_req_size;
592 user_buf += itv->dma_data_req_size; 592 user_buf += itv->dma_data_req_size;
593 count -= itv->dma_data_req_size; 593 count -= itv->dma_data_req_size;
diff --git a/drivers/media/video/ivtv/ivtv-irq.c b/drivers/media/video/ivtv/ivtv-irq.c
index d8ba3a4a8761..fba150a6cd23 100644
--- a/drivers/media/video/ivtv/ivtv-irq.c
+++ b/drivers/media/video/ivtv/ivtv-irq.c
@@ -231,14 +231,14 @@ static void dma_post(struct ivtv_stream *s)
231 struct ivtv_buffer *buf = NULL; 231 struct ivtv_buffer *buf = NULL;
232 struct list_head *p; 232 struct list_head *p;
233 u32 offset; 233 u32 offset;
234 u32 *u32buf; 234 __le32 *u32buf;
235 int x = 0; 235 int x = 0;
236 236
237 IVTV_DEBUG_HI_DMA("%s %s completed (%x)\n", ivtv_use_pio(s) ? "PIO" : "DMA", 237 IVTV_DEBUG_HI_DMA("%s %s completed (%x)\n", ivtv_use_pio(s) ? "PIO" : "DMA",
238 s->name, s->dma_offset); 238 s->name, s->dma_offset);
239 list_for_each(p, &s->q_dma.list) { 239 list_for_each(p, &s->q_dma.list) {
240 buf = list_entry(p, struct ivtv_buffer, list); 240 buf = list_entry(p, struct ivtv_buffer, list);
241 u32buf = (u32 *)buf->buf; 241 u32buf = (__le32 *)buf->buf;
242 242
243 /* Sync Buffer */ 243 /* Sync Buffer */
244 ivtv_buf_sync_for_cpu(s, buf); 244 ivtv_buf_sync_for_cpu(s, buf);
@@ -444,7 +444,7 @@ static void ivtv_dma_enc_start(struct ivtv_stream *s)
444 } 444 }
445 445
446 s->dma_xfer_cnt++; 446 s->dma_xfer_cnt++;
447 memcpy(s->sg_processing, s->sg_pending, sizeof(struct ivtv_sg_element) * s->sg_pending_size); 447 memcpy(s->sg_processing, s->sg_pending, sizeof(struct ivtv_sg_host_element) * s->sg_pending_size);
448 s->sg_processing_size = s->sg_pending_size; 448 s->sg_processing_size = s->sg_pending_size;
449 s->sg_pending_size = 0; 449 s->sg_pending_size = 0;
450 s->sg_processed = 0; 450 s->sg_processed = 0;
@@ -473,7 +473,7 @@ static void ivtv_dma_dec_start(struct ivtv_stream *s)
473 if (s->q_predma.bytesused) 473 if (s->q_predma.bytesused)
474 ivtv_queue_move(s, &s->q_predma, NULL, &s->q_dma, s->q_predma.bytesused); 474 ivtv_queue_move(s, &s->q_predma, NULL, &s->q_dma, s->q_predma.bytesused);
475 s->dma_xfer_cnt++; 475 s->dma_xfer_cnt++;
476 memcpy(s->sg_processing, s->sg_pending, sizeof(struct ivtv_sg_element) * s->sg_pending_size); 476 memcpy(s->sg_processing, s->sg_pending, sizeof(struct ivtv_sg_host_element) * s->sg_pending_size);
477 s->sg_processing_size = s->sg_pending_size; 477 s->sg_processing_size = s->sg_pending_size;
478 s->sg_pending_size = 0; 478 s->sg_pending_size = 0;
479 s->sg_processed = 0; 479 s->sg_processed = 0;
diff --git a/drivers/media/video/ivtv/ivtv-queue.c b/drivers/media/video/ivtv/ivtv-queue.c
index fc8b1eaa333b..71bd13e22e2e 100644
--- a/drivers/media/video/ivtv/ivtv-queue.c
+++ b/drivers/media/video/ivtv/ivtv-queue.c
@@ -193,7 +193,7 @@ void ivtv_flush_queues(struct ivtv_stream *s)
193int ivtv_stream_alloc(struct ivtv_stream *s) 193int ivtv_stream_alloc(struct ivtv_stream *s)
194{ 194{
195 struct ivtv *itv = s->itv; 195 struct ivtv *itv = s->itv;
196 int SGsize = sizeof(struct ivtv_sg_element) * s->buffers; 196 int SGsize = sizeof(struct ivtv_sg_host_element) * s->buffers;
197 int i; 197 int i;
198 198
199 if (s->buffers == 0) 199 if (s->buffers == 0)
diff --git a/drivers/media/video/ivtv/ivtv-streams.c b/drivers/media/video/ivtv/ivtv-streams.c
index c47c2b945147..c854285a4371 100644
--- a/drivers/media/video/ivtv/ivtv-streams.c
+++ b/drivers/media/video/ivtv/ivtv-streams.c
@@ -44,23 +44,25 @@
44#include "ivtv-streams.h" 44#include "ivtv-streams.h"
45 45
46static const struct file_operations ivtv_v4l2_enc_fops = { 46static const struct file_operations ivtv_v4l2_enc_fops = {
47 .owner = THIS_MODULE, 47 .owner = THIS_MODULE,
48 .read = ivtv_v4l2_read, 48 .read = ivtv_v4l2_read,
49 .write = ivtv_v4l2_write, 49 .write = ivtv_v4l2_write,
50 .open = ivtv_v4l2_open, 50 .open = ivtv_v4l2_open,
51 .ioctl = ivtv_v4l2_ioctl, 51 .ioctl = ivtv_v4l2_ioctl,
52 .release = ivtv_v4l2_close, 52 .compat_ioctl = v4l_compat_ioctl32,
53 .poll = ivtv_v4l2_enc_poll, 53 .release = ivtv_v4l2_close,
54 .poll = ivtv_v4l2_enc_poll,
54}; 55};
55 56
56static const struct file_operations ivtv_v4l2_dec_fops = { 57static const struct file_operations ivtv_v4l2_dec_fops = {
57 .owner = THIS_MODULE, 58 .owner = THIS_MODULE,
58 .read = ivtv_v4l2_read, 59 .read = ivtv_v4l2_read,
59 .write = ivtv_v4l2_write, 60 .write = ivtv_v4l2_write,
60 .open = ivtv_v4l2_open, 61 .open = ivtv_v4l2_open,
61 .ioctl = ivtv_v4l2_ioctl, 62 .ioctl = ivtv_v4l2_ioctl,
62 .release = ivtv_v4l2_close, 63 .compat_ioctl = v4l_compat_ioctl32,
63 .poll = ivtv_v4l2_dec_poll, 64 .release = ivtv_v4l2_close,
65 .poll = ivtv_v4l2_dec_poll,
64}; 66};
65 67
66#define IVTV_V4L2_DEC_MPG_OFFSET 16 /* offset from 0 to register decoder mpg v4l2 minors on */ 68#define IVTV_V4L2_DEC_MPG_OFFSET 16 /* offset from 0 to register decoder mpg v4l2 minors on */
diff --git a/drivers/media/video/ivtv/ivtv-version.h b/drivers/media/video/ivtv/ivtv-version.h
index 02c5ab071d1b..442f43f11b73 100644
--- a/drivers/media/video/ivtv/ivtv-version.h
+++ b/drivers/media/video/ivtv/ivtv-version.h
@@ -22,8 +22,8 @@
22 22
23#define IVTV_DRIVER_NAME "ivtv" 23#define IVTV_DRIVER_NAME "ivtv"
24#define IVTV_DRIVER_VERSION_MAJOR 1 24#define IVTV_DRIVER_VERSION_MAJOR 1
25#define IVTV_DRIVER_VERSION_MINOR 2 25#define IVTV_DRIVER_VERSION_MINOR 3
26#define IVTV_DRIVER_VERSION_PATCHLEVEL 1 26#define IVTV_DRIVER_VERSION_PATCHLEVEL 0
27 27
28#define IVTV_VERSION __stringify(IVTV_DRIVER_VERSION_MAJOR) "." __stringify(IVTV_DRIVER_VERSION_MINOR) "." __stringify(IVTV_DRIVER_VERSION_PATCHLEVEL) 28#define IVTV_VERSION __stringify(IVTV_DRIVER_VERSION_MAJOR) "." __stringify(IVTV_DRIVER_VERSION_MINOR) "." __stringify(IVTV_DRIVER_VERSION_PATCHLEVEL)
29#define IVTV_DRIVER_VERSION KERNEL_VERSION(IVTV_DRIVER_VERSION_MAJOR,IVTV_DRIVER_VERSION_MINOR,IVTV_DRIVER_VERSION_PATCHLEVEL) 29#define IVTV_DRIVER_VERSION KERNEL_VERSION(IVTV_DRIVER_VERSION_MAJOR,IVTV_DRIVER_VERSION_MINOR,IVTV_DRIVER_VERSION_PATCHLEVEL)
diff --git a/drivers/media/video/ivtv/ivtv-yuv.c b/drivers/media/video/ivtv/ivtv-yuv.c
index a9417f6e4087..3092ff1d00a0 100644
--- a/drivers/media/video/ivtv/ivtv-yuv.c
+++ b/drivers/media/video/ivtv/ivtv-yuv.c
@@ -1116,7 +1116,7 @@ void ivtv_yuv_setup_stream_frame(struct ivtv *itv)
1116} 1116}
1117 1117
1118/* Attempt to dma a frame from a user buffer */ 1118/* Attempt to dma a frame from a user buffer */
1119int ivtv_yuv_udma_stream_frame(struct ivtv *itv, void *src) 1119int ivtv_yuv_udma_stream_frame(struct ivtv *itv, void __user *src)
1120{ 1120{
1121 struct yuv_playback_info *yi = &itv->yuv_info; 1121 struct yuv_playback_info *yi = &itv->yuv_info;
1122 struct ivtv_dma_frame dma_args; 1122 struct ivtv_dma_frame dma_args;
diff --git a/drivers/media/video/ivtv/ivtv-yuv.h b/drivers/media/video/ivtv/ivtv-yuv.h
index 2fe5f1250762..ca5173fbf006 100644
--- a/drivers/media/video/ivtv/ivtv-yuv.h
+++ b/drivers/media/video/ivtv/ivtv-yuv.h
@@ -35,7 +35,7 @@ extern const u32 yuv_offset[IVTV_YUV_BUFFERS];
35 35
36int ivtv_yuv_filter_check(struct ivtv *itv); 36int ivtv_yuv_filter_check(struct ivtv *itv);
37void ivtv_yuv_setup_stream_frame(struct ivtv *itv); 37void ivtv_yuv_setup_stream_frame(struct ivtv *itv);
38int ivtv_yuv_udma_stream_frame(struct ivtv *itv, void *src); 38int ivtv_yuv_udma_stream_frame(struct ivtv *itv, void __user *src);
39void ivtv_yuv_frame_complete(struct ivtv *itv); 39void ivtv_yuv_frame_complete(struct ivtv *itv);
40int ivtv_yuv_prep_frame(struct ivtv *itv, struct ivtv_dma_frame *args); 40int ivtv_yuv_prep_frame(struct ivtv *itv, struct ivtv_dma_frame *args);
41void ivtv_yuv_close(struct ivtv *itv); 41void ivtv_yuv_close(struct ivtv *itv);
diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c
index 1314522a8130..81431ee41842 100644
--- a/drivers/media/video/saa7134/saa7134-empress.c
+++ b/drivers/media/video/saa7134/saa7134-empress.c
@@ -163,8 +163,7 @@ ts_mmap(struct file *file, struct vm_area_struct * vma)
163static int empress_querycap(struct file *file, void *priv, 163static int empress_querycap(struct file *file, void *priv,
164 struct v4l2_capability *cap) 164 struct v4l2_capability *cap)
165{ 165{
166 struct saa7134_fh *fh = priv; 166 struct saa7134_dev *dev = file->private_data;
167 struct saa7134_dev *dev = fh->dev;
168 167
169 strcpy(cap->driver, "saa7134"); 168 strcpy(cap->driver, "saa7134");
170 strlcpy(cap->card, saa7134_boards[dev->board].name, 169 strlcpy(cap->card, saa7134_boards[dev->board].name,
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index 198f0afb812e..0d12ace61665 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -92,6 +92,7 @@ struct tuner {
92 unsigned int type; /* chip type id */ 92 unsigned int type; /* chip type id */
93 unsigned int config; 93 unsigned int config;
94 int (*tuner_callback) (void *dev, int command, int arg); 94 int (*tuner_callback) (void *dev, int command, int arg);
95 const char *name;
95}; 96};
96 97
97/* standard i2c insmod options */ 98/* standard i2c insmod options */
@@ -330,13 +331,13 @@ static void tuner_i2c_address_check(struct tuner *t)
330 tuner_warn("Support for tuners in i2c address range 0x64 thru 0x6f\n"); 331 tuner_warn("Support for tuners in i2c address range 0x64 thru 0x6f\n");
331 tuner_warn("will soon be dropped. This message indicates that your\n"); 332 tuner_warn("will soon be dropped. This message indicates that your\n");
332 tuner_warn("hardware has a %s tuner at i2c address 0x%02x.\n", 333 tuner_warn("hardware has a %s tuner at i2c address 0x%02x.\n",
333 t->i2c->name, t->i2c->addr); 334 t->name, t->i2c->addr);
334 tuner_warn("To ensure continued support for your device, please\n"); 335 tuner_warn("To ensure continued support for your device, please\n");
335 tuner_warn("send a copy of this message, along with full dmesg\n"); 336 tuner_warn("send a copy of this message, along with full dmesg\n");
336 tuner_warn("output to v4l-dvb-maintainer@linuxtv.org\n"); 337 tuner_warn("output to v4l-dvb-maintainer@linuxtv.org\n");
337 tuner_warn("Please use subject line: \"obsolete tuner i2c address.\"\n"); 338 tuner_warn("Please use subject line: \"obsolete tuner i2c address.\"\n");
338 tuner_warn("driver: %s, addr: 0x%02x, type: %d (%s)\n", 339 tuner_warn("driver: %s, addr: 0x%02x, type: %d (%s)\n",
339 t->i2c->adapter->name, t->i2c->addr, t->type, t->i2c->name); 340 t->i2c->adapter->name, t->i2c->addr, t->type, t->name);
340 tuner_warn("====================== WARNING! ======================\n"); 341 tuner_warn("====================== WARNING! ======================\n");
341} 342}
342 343
@@ -470,19 +471,17 @@ static void set_type(struct i2c_client *c, unsigned int type,
470 if ((NULL == analog_ops->set_params) && 471 if ((NULL == analog_ops->set_params) &&
471 (fe_tuner_ops->set_analog_params)) { 472 (fe_tuner_ops->set_analog_params)) {
472 473
473 strlcpy(t->i2c->name, fe_tuner_ops->info.name, 474 t->name = fe_tuner_ops->info.name;
474 sizeof(t->i2c->name));
475 475
476 t->fe.analog_demod_priv = t; 476 t->fe.analog_demod_priv = t;
477 memcpy(analog_ops, &tuner_core_ops, 477 memcpy(analog_ops, &tuner_core_ops,
478 sizeof(struct analog_demod_ops)); 478 sizeof(struct analog_demod_ops));
479 479
480 } else { 480 } else {
481 strlcpy(t->i2c->name, analog_ops->info.name, 481 t->name = analog_ops->info.name;
482 sizeof(t->i2c->name));
483 } 482 }
484 483
485 tuner_dbg("type set to %s\n", t->i2c->name); 484 tuner_dbg("type set to %s\n", t->name);
486 485
487 if (t->mode_mask == T_UNINITIALIZED) 486 if (t->mode_mask == T_UNINITIALIZED)
488 t->mode_mask = new_mode_mask; 487 t->mode_mask = new_mode_mask;
@@ -537,7 +536,7 @@ static void set_addr(struct i2c_client *c, struct tuner_setup *tun_setup)
537static inline int check_mode(struct tuner *t, char *cmd) 536static inline int check_mode(struct tuner *t, char *cmd)
538{ 537{
539 if ((1 << t->mode & t->mode_mask) == 0) { 538 if ((1 << t->mode & t->mode_mask) == 0) {
540 return EINVAL; 539 return -EINVAL;
541 } 540 }
542 541
543 switch (t->mode) { 542 switch (t->mode) {
@@ -731,11 +730,11 @@ static inline int set_mode(struct i2c_client *client, struct tuner *t, int mode,
731 730
732 t->mode = mode; 731 t->mode = mode;
733 732
734 if (check_mode(t, cmd) == EINVAL) { 733 if (check_mode(t, cmd) == -EINVAL) {
735 t->mode = T_STANDBY; 734 t->mode = T_STANDBY;
736 if (analog_ops->standby) 735 if (analog_ops->standby)
737 analog_ops->standby(&t->fe); 736 analog_ops->standby(&t->fe);
738 return EINVAL; 737 return -EINVAL;
739 } 738 }
740 return 0; 739 return 0;
741} 740}
@@ -777,13 +776,13 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
777 break; 776 break;
778 case AUDC_SET_RADIO: 777 case AUDC_SET_RADIO:
779 if (set_mode(client, t, V4L2_TUNER_RADIO, "AUDC_SET_RADIO") 778 if (set_mode(client, t, V4L2_TUNER_RADIO, "AUDC_SET_RADIO")
780 == EINVAL) 779 == -EINVAL)
781 return 0; 780 return 0;
782 if (t->radio_freq) 781 if (t->radio_freq)
783 set_freq(client, t->radio_freq); 782 set_freq(client, t->radio_freq);
784 break; 783 break;
785 case TUNER_SET_STANDBY: 784 case TUNER_SET_STANDBY:
786 if (check_mode(t, "TUNER_SET_STANDBY") == EINVAL) 785 if (check_mode(t, "TUNER_SET_STANDBY") == -EINVAL)
787 return 0; 786 return 0;
788 t->mode = T_STANDBY; 787 t->mode = T_STANDBY;
789 if (analog_ops->standby) 788 if (analog_ops->standby)
@@ -791,9 +790,9 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
791 break; 790 break;
792#ifdef CONFIG_VIDEO_ALLOW_V4L1 791#ifdef CONFIG_VIDEO_ALLOW_V4L1
793 case VIDIOCSAUDIO: 792 case VIDIOCSAUDIO:
794 if (check_mode(t, "VIDIOCSAUDIO") == EINVAL) 793 if (check_mode(t, "VIDIOCSAUDIO") == -EINVAL)
795 return 0; 794 return 0;
796 if (check_v4l2(t) == EINVAL) 795 if (check_v4l2(t) == -EINVAL)
797 return 0; 796 return 0;
798 797
799 /* Should be implemented, since bttv calls it */ 798 /* Should be implemented, since bttv calls it */
@@ -811,10 +810,10 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
811 }; 810 };
812 struct video_channel *vc = arg; 811 struct video_channel *vc = arg;
813 812
814 if (check_v4l2(t) == EINVAL) 813 if (check_v4l2(t) == -EINVAL)
815 return 0; 814 return 0;
816 815
817 if (set_mode(client,t,V4L2_TUNER_ANALOG_TV, "VIDIOCSCHAN")==EINVAL) 816 if (set_mode(client,t,V4L2_TUNER_ANALOG_TV, "VIDIOCSCHAN")==-EINVAL)
818 return 0; 817 return 0;
819 818
820 if (vc->norm < ARRAY_SIZE(map)) 819 if (vc->norm < ARRAY_SIZE(map))
@@ -828,9 +827,9 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
828 { 827 {
829 unsigned long *v = arg; 828 unsigned long *v = arg;
830 829
831 if (check_mode(t, "VIDIOCSFREQ") == EINVAL) 830 if (check_mode(t, "VIDIOCSFREQ") == -EINVAL)
832 return 0; 831 return 0;
833 if (check_v4l2(t) == EINVAL) 832 if (check_v4l2(t) == -EINVAL)
834 return 0; 833 return 0;
835 834
836 set_freq(client, *v); 835 set_freq(client, *v);
@@ -840,9 +839,9 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
840 { 839 {
841 struct video_tuner *vt = arg; 840 struct video_tuner *vt = arg;
842 841
843 if (check_mode(t, "VIDIOCGTUNER") == EINVAL) 842 if (check_mode(t, "VIDIOCGTUNER") == -EINVAL)
844 return 0; 843 return 0;
845 if (check_v4l2(t) == EINVAL) 844 if (check_v4l2(t) == -EINVAL)
846 return 0; 845 return 0;
847 846
848 if (V4L2_TUNER_RADIO == t->mode) { 847 if (V4L2_TUNER_RADIO == t->mode) {
@@ -884,9 +883,9 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
884 { 883 {
885 struct video_audio *va = arg; 884 struct video_audio *va = arg;
886 885
887 if (check_mode(t, "VIDIOCGAUDIO") == EINVAL) 886 if (check_mode(t, "VIDIOCGAUDIO") == -EINVAL)
888 return 0; 887 return 0;
889 if (check_v4l2(t) == EINVAL) 888 if (check_v4l2(t) == -EINVAL)
890 return 0; 889 return 0;
891 890
892 if (V4L2_TUNER_RADIO == t->mode) { 891 if (V4L2_TUNER_RADIO == t->mode) {
@@ -926,7 +925,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
926 v4l2_std_id *id = arg; 925 v4l2_std_id *id = arg;
927 926
928 if (set_mode (client, t, V4L2_TUNER_ANALOG_TV, "VIDIOC_S_STD") 927 if (set_mode (client, t, V4L2_TUNER_ANALOG_TV, "VIDIOC_S_STD")
929 == EINVAL) 928 == -EINVAL)
930 return 0; 929 return 0;
931 930
932 switch_v4l2(); 931 switch_v4l2();
@@ -942,7 +941,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
942 struct v4l2_frequency *f = arg; 941 struct v4l2_frequency *f = arg;
943 942
944 if (set_mode (client, t, f->type, "VIDIOC_S_FREQUENCY") 943 if (set_mode (client, t, f->type, "VIDIOC_S_FREQUENCY")
945 == EINVAL) 944 == -EINVAL)
946 return 0; 945 return 0;
947 switch_v4l2(); 946 switch_v4l2();
948 set_freq(client,f->frequency); 947 set_freq(client,f->frequency);
@@ -953,7 +952,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
953 { 952 {
954 struct v4l2_frequency *f = arg; 953 struct v4l2_frequency *f = arg;
955 954
956 if (check_mode(t, "VIDIOC_G_FREQUENCY") == EINVAL) 955 if (check_mode(t, "VIDIOC_G_FREQUENCY") == -EINVAL)
957 return 0; 956 return 0;
958 switch_v4l2(); 957 switch_v4l2();
959 f->type = t->mode; 958 f->type = t->mode;
@@ -974,7 +973,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
974 { 973 {
975 struct v4l2_tuner *tuner = arg; 974 struct v4l2_tuner *tuner = arg;
976 975
977 if (check_mode(t, "VIDIOC_G_TUNER") == EINVAL) 976 if (check_mode(t, "VIDIOC_G_TUNER") == -EINVAL)
978 return 0; 977 return 0;
979 switch_v4l2(); 978 switch_v4l2();
980 979
@@ -1021,7 +1020,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
1021 { 1020 {
1022 struct v4l2_tuner *tuner = arg; 1021 struct v4l2_tuner *tuner = arg;
1023 1022
1024 if (check_mode(t, "VIDIOC_S_TUNER") == EINVAL) 1023 if (check_mode(t, "VIDIOC_S_TUNER") == -EINVAL)
1025 return 0; 1024 return 0;
1026 1025
1027 switch_v4l2(); 1026 switch_v4l2();
@@ -1115,6 +1114,7 @@ static int tuner_probe(struct i2c_client *client,
1115 if (NULL == t) 1114 if (NULL == t)
1116 return -ENOMEM; 1115 return -ENOMEM;
1117 t->i2c = client; 1116 t->i2c = client;
1117 t->name = "(tuner unset)";
1118 i2c_set_clientdata(client, t); 1118 i2c_set_clientdata(client, t);
1119 t->type = UNSET; 1119 t->type = UNSET;
1120 t->audmode = V4L2_TUNER_MODE_STEREO; 1120 t->audmode = V4L2_TUNER_MODE_STEREO;
@@ -1272,12 +1272,6 @@ static int tuner_remove(struct i2c_client *client)
1272 1272
1273 list_del(&t->list); 1273 list_del(&t->list);
1274 kfree(t); 1274 kfree(t);
1275
1276 /* The probing code has overwritten the device name, restore it so
1277 that reloading the driver will work. Ideally the device name
1278 should not be overwritten in the first place, but for now that
1279 will do. */
1280 strlcpy(client->name, "tuner", I2C_NAME_SIZE);
1281 return 0; 1275 return 0;
1282} 1276}
1283 1277
diff --git a/drivers/media/video/usbvideo/quickcam_messenger.c b/drivers/media/video/usbvideo/quickcam_messenger.c
index 32e536edf09d..3d26a30abe1e 100644
--- a/drivers/media/video/usbvideo/quickcam_messenger.c
+++ b/drivers/media/video/usbvideo/quickcam_messenger.c
@@ -210,7 +210,7 @@ static int qcm_stv_setb(struct usb_device *dev, u16 reg, u8 val)
210 return ret; 210 return ret;
211} 211}
212 212
213static int qcm_stv_setw(struct usb_device *dev, u16 reg, u16 val) 213static int qcm_stv_setw(struct usb_device *dev, u16 reg, __le16 val)
214{ 214{
215 int ret; 215 int ret;
216 216
diff --git a/drivers/media/video/videobuf-core.c b/drivers/media/video/videobuf-core.c
index 982f4463896c..0a88c44ace00 100644
--- a/drivers/media/video/videobuf-core.c
+++ b/drivers/media/video/videobuf-core.c
@@ -331,7 +331,7 @@ int videobuf_mmap_free(struct videobuf_queue *q)
331} 331}
332 332
333/* Locking: Caller holds q->vb_lock */ 333/* Locking: Caller holds q->vb_lock */
334static int __videobuf_mmap_setup(struct videobuf_queue *q, 334int __videobuf_mmap_setup(struct videobuf_queue *q,
335 unsigned int bcount, unsigned int bsize, 335 unsigned int bcount, unsigned int bsize,
336 enum v4l2_memory memory) 336 enum v4l2_memory memory)
337{ 337{
@@ -1129,6 +1129,7 @@ EXPORT_SYMBOL_GPL(videobuf_read_stream);
1129EXPORT_SYMBOL_GPL(videobuf_read_one); 1129EXPORT_SYMBOL_GPL(videobuf_read_one);
1130EXPORT_SYMBOL_GPL(videobuf_poll_stream); 1130EXPORT_SYMBOL_GPL(videobuf_poll_stream);
1131 1131
1132EXPORT_SYMBOL_GPL(__videobuf_mmap_setup);
1132EXPORT_SYMBOL_GPL(videobuf_mmap_setup); 1133EXPORT_SYMBOL_GPL(videobuf_mmap_setup);
1133EXPORT_SYMBOL_GPL(videobuf_mmap_free); 1134EXPORT_SYMBOL_GPL(videobuf_mmap_free);
1134EXPORT_SYMBOL_GPL(videobuf_mmap_mapper); 1135EXPORT_SYMBOL_GPL(videobuf_mmap_mapper);
diff --git a/drivers/media/video/zoran.h b/drivers/media/video/zoran.h
index 81cc3b00a079..46b7ad477ceb 100644
--- a/drivers/media/video/zoran.h
+++ b/drivers/media/video/zoran.h
@@ -285,7 +285,7 @@ struct zoran_mapping {
285 285
286struct zoran_jpg_buffer { 286struct zoran_jpg_buffer {
287 struct zoran_mapping *map; 287 struct zoran_mapping *map;
288 u32 *frag_tab; /* addresses of frag table */ 288 __le32 *frag_tab; /* addresses of frag table */
289 u32 frag_tab_bus; /* same value cached to save time in ISR */ 289 u32 frag_tab_bus; /* same value cached to save time in ISR */
290 enum zoran_buffer_state state; /* non-zero if corresponding buffer is in use in grab queue */ 290 enum zoran_buffer_state state; /* non-zero if corresponding buffer is in use in grab queue */
291 struct zoran_sync bs; /* DONE: info to return to application */ 291 struct zoran_sync bs; /* DONE: info to return to application */
@@ -450,7 +450,7 @@ struct zoran {
450 unsigned long jpg_queued_num; /* count of frames queued since grab/play started */ 450 unsigned long jpg_queued_num; /* count of frames queued since grab/play started */
451 451
452 /* zr36057's code buffer table */ 452 /* zr36057's code buffer table */
453 u32 *stat_com; /* stat_com[i] is indexed by dma_head/tail & BUZ_MASK_STAT_COM */ 453 __le32 *stat_com; /* stat_com[i] is indexed by dma_head/tail & BUZ_MASK_STAT_COM */
454 454
455 /* (value & BUZ_MASK_FRAME) corresponds to index in pend[] queue */ 455 /* (value & BUZ_MASK_FRAME) corresponds to index in pend[] queue */
456 int jpg_pend[BUZ_MAX_FRAME]; 456 int jpg_pend[BUZ_MAX_FRAME];
diff --git a/drivers/media/video/zoran_device.c b/drivers/media/video/zoran_device.c
index 37629ffd34c3..88d369708e4c 100644
--- a/drivers/media/video/zoran_device.c
+++ b/drivers/media/video/zoran_device.c
@@ -1320,7 +1320,7 @@ error_handler (struct zoran *zr,
1320 if (i) { 1320 if (i) {
1321 /* Rotate stat_comm entries to make current entry first */ 1321 /* Rotate stat_comm entries to make current entry first */
1322 int j; 1322 int j;
1323 u32 bus_addr[BUZ_NUM_STAT_COM]; 1323 __le32 bus_addr[BUZ_NUM_STAT_COM];
1324 1324
1325 /* Here we are copying the stat_com array, which 1325 /* Here we are copying the stat_com array, which
1326 * is already in little endian format, so 1326 * is already in little endian format, so
diff --git a/drivers/media/video/zoran_driver.c b/drivers/media/video/zoran_driver.c
index 345c77e46837..5394d7a5cfee 100644
--- a/drivers/media/video/zoran_driver.c
+++ b/drivers/media/video/zoran_driver.c
@@ -495,7 +495,7 @@ jpg_fbuffer_alloc (struct file *file)
495 jpg_fbuffer_free(file); 495 jpg_fbuffer_free(file);
496 return -ENOBUFS; 496 return -ENOBUFS;
497 } 497 }
498 fh->jpg_buffers.buffer[i].frag_tab = (u32 *) mem; 498 fh->jpg_buffers.buffer[i].frag_tab = (__le32 *) mem;
499 fh->jpg_buffers.buffer[i].frag_tab_bus = 499 fh->jpg_buffers.buffer[i].frag_tab_bus =
500 virt_to_bus((void *) mem); 500 virt_to_bus((void *) mem);
501 501
@@ -1167,7 +1167,7 @@ zoran_close_end_session (struct file *file)
1167 1167
1168 /* v4l capture */ 1168 /* v4l capture */
1169 if (fh->v4l_buffers.active != ZORAN_FREE) { 1169 if (fh->v4l_buffers.active != ZORAN_FREE) {
1170 long flags; 1170 unsigned long flags;
1171 1171
1172 spin_lock_irqsave(&zr->spinlock, flags); 1172 spin_lock_irqsave(&zr->spinlock, flags);
1173 zr36057_set_memgrab(zr, 0); 1173 zr36057_set_memgrab(zr, 0);
@@ -3436,7 +3436,7 @@ zoran_do_ioctl (struct inode *inode,
3436 3436
3437 /* unload capture */ 3437 /* unload capture */
3438 if (zr->v4l_memgrab_active) { 3438 if (zr->v4l_memgrab_active) {
3439 long flags; 3439 unsigned long flags;
3440 3440
3441 spin_lock_irqsave(&zr->spinlock, flags); 3441 spin_lock_irqsave(&zr->spinlock, flags);
3442 zr36057_set_memgrab(zr, 0); 3442 zr36057_set_memgrab(zr, 0);
@@ -4375,7 +4375,7 @@ zoran_vm_close (struct vm_area_struct *vma)
4375 mutex_lock(&zr->resource_lock); 4375 mutex_lock(&zr->resource_lock);
4376 4376
4377 if (fh->v4l_buffers.active != ZORAN_FREE) { 4377 if (fh->v4l_buffers.active != ZORAN_FREE) {
4378 long flags; 4378 unsigned long flags;
4379 4379
4380 spin_lock_irqsave(&zr->spinlock, flags); 4380 spin_lock_irqsave(&zr->spinlock, flags);
4381 zr36057_set_memgrab(zr, 0); 4381 zr36057_set_memgrab(zr, 0);
@@ -4506,7 +4506,7 @@ zoran_mmap (struct file *file,
4506 if (todo > fraglen) 4506 if (todo > fraglen)
4507 todo = fraglen; 4507 todo = fraglen;
4508 pos = 4508 pos =
4509 le32_to_cpu((unsigned long) fh->jpg_buffers. 4509 le32_to_cpu(fh->jpg_buffers.
4510 buffer[i].frag_tab[2 * j]); 4510 buffer[i].frag_tab[2 * j]);
4511 /* should just be pos on i386 */ 4511 /* should just be pos on i386 */
4512 page = virt_to_phys(bus_to_virt(pos)) 4512 page = virt_to_phys(bus_to_virt(pos))